text: /**
   * Functions that max expects to be present when the file is loaded
   */
  
  /**
   * Registered message handlers
   *
   * @see anything
   */
  var messageHandlers = {};
  
  /**
   * Respond to messages
   *
   * Max expects <code>anything</code> to be present when the JavaScript is
   * loaded. We <i>can</i> override it later, but since it must be present, we
   * might as well make use of it. On the PureScript side, we will update
   * <code>messageHandlers</code>, and we will read it here.
   */
  function anything() {
    if(messageHandlers[inlet] !== undefined && typeof(messageHandlers[inlet][messagename]) === 'function') {
      messageHandlers[inlet][messagename](arguments);
    } else {
      throw ("anything: Unexpected message " + messagename + " on inlet " + inlet + "\n");
    }
  }
  // Generated by purs bundle 0.14.0
  var PS = {};
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Control.Semigroupoid"] = $PS["Control.Semigroupoid"] || {};
    var exports = $PS["Control.Semigroupoid"];
    var Semigroupoid = function (compose) {
        this.compose = compose;
    };
    var semigroupoidFn = new Semigroupoid(function (f) {
        return function (g) {
            return function (x) {
                return f(g(x));
            };
        };
    });
    exports["semigroupoidFn"] = semigroupoidFn;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Control.Category"] = $PS["Control.Category"] || {};
    var exports = $PS["Control.Category"];
    var Control_Semigroupoid = $PS["Control.Semigroupoid"];                
    var Category = function (Semigroupoid0, identity) {
        this.Semigroupoid0 = Semigroupoid0;
        this.identity = identity;
    };
    var identity = function (dict) {
        return dict.identity;
    };
    var categoryFn = new Category(function () {
        return Control_Semigroupoid.semigroupoidFn;
    }, function (x) {
        return x;
    });
    exports["identity"] = identity;
    exports["categoryFn"] = categoryFn;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Function"] = $PS["Data.Function"] || {};
    var exports = $PS["Data.Function"];
    var flip = function (f) {
        return function (b) {
            return function (a) {
                return f(a)(b);
            };
        };
    };
    var $$const = function (a) {
        return function (v) {
            return a;
        };
    };
    exports["flip"] = flip;
    exports["const"] = $$const;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.arrayMap = function (f) {
      return function (arr) {
        var l = arr.length;
        var result = new Array(l);
        for (var i = 0; i < l; i++) {
          result[i] = f(arr[i]);
        }
        return result;
      };
    };
  })(PS["Data.Functor"] = PS["Data.Functor"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Functor"] = $PS["Data.Functor"] || {};
    var exports = $PS["Data.Functor"];
    var $foreign = $PS["Data.Functor"];                
    var Functor = function (map) {
        this.map = map;
    };
    var map = function (dict) {
        return dict.map;
    };                                                                                             
    var functorArray = new Functor($foreign.arrayMap);
    exports["Functor"] = Functor;
    exports["map"] = map;
    exports["functorArray"] = functorArray;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Control.Apply"] = $PS["Control.Apply"] || {};
    var exports = $PS["Control.Apply"];
    var Control_Category = $PS["Control.Category"];
    var Data_Function = $PS["Data.Function"];
    var Data_Functor = $PS["Data.Functor"];            
    var Apply = function (Functor0, apply) {
        this.Functor0 = Functor0;
        this.apply = apply;
    };                      
    var apply = function (dict) {
        return dict.apply;
    };
    var applySecond = function (dictApply) {
        return function (a) {
            return function (b) {
                return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Data_Function["const"](Control_Category.identity(Control_Category.categoryFn)))(a))(b);
            };
        };
    };
    exports["Apply"] = Apply;
    exports["apply"] = apply;
    exports["applySecond"] = applySecond;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Control.Applicative"] = $PS["Control.Applicative"] || {};
    var exports = $PS["Control.Applicative"];
    var Control_Apply = $PS["Control.Apply"];          
    var Applicative = function (Apply0, pure) {
        this.Apply0 = Apply0;
        this.pure = pure;
    };
    var pure = function (dict) {
        return dict.pure;
    };
    var liftA1 = function (dictApplicative) {
        return function (f) {
            return function (a) {
                return Control_Apply.apply(dictApplicative.Apply0())(pure(dictApplicative)(f))(a);
            };
        };
    };
    exports["Applicative"] = Applicative;
    exports["pure"] = pure;
    exports["liftA1"] = liftA1;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Control.Bind"] = $PS["Control.Bind"] || {};
    var exports = $PS["Control.Bind"];                 
    var Bind = function (Apply0, bind) {
        this.Apply0 = Apply0;
        this.bind = bind;
    };                     
    var bind = function (dict) {
        return dict.bind;
    };
    exports["Bind"] = Bind;
    exports["bind"] = bind;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Control.Monad"] = $PS["Control.Monad"] || {};
    var exports = $PS["Control.Monad"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Bind = $PS["Control.Bind"];                
    var Monad = function (Applicative0, Bind1) {
        this.Applicative0 = Applicative0;
        this.Bind1 = Bind1;
    };
    var ap = function (dictMonad) {
        return function (f) {
            return function (a) {
                return Control_Bind.bind(dictMonad.Bind1())(f)(function (f$prime) {
                    return Control_Bind.bind(dictMonad.Bind1())(a)(function (a$prime) {
                        return Control_Applicative.pure(dictMonad.Applicative0())(f$prime(a$prime));
                    });
                });
            };
        };
    };
    exports["Monad"] = Monad;
    exports["ap"] = ap;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Boolean"] = $PS["Data.Boolean"] || {};
    var exports = $PS["Data.Boolean"];
    var otherwise = true;
    exports["otherwise"] = otherwise;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.topInt = 2147483647;
    exports.bottomInt = -2147483648;
  })(PS["Data.Bounded"] = PS["Data.Bounded"] || {});
  (function(exports) {
    "use strict";
  
    var unsafeCompareImpl = function (lt) {
      return function (eq) {
        return function (gt) {
          return function (x) {
            return function (y) {
              return x < y ? lt : x === y ? eq : gt;
            };
          };
        };
      };
    };                                         
    exports.ordIntImpl = unsafeCompareImpl;
    exports.ordNumberImpl = unsafeCompareImpl;
  })(PS["Data.Ord"] = PS["Data.Ord"] || {});
  (function(exports) {
    "use strict";
  
    var refEq = function (r1) {
      return function (r2) {
        return r1 === r2;
      };
    };                            
    exports.eqIntImpl = refEq;
    exports.eqNumberImpl = refEq;
  })(PS["Data.Eq"] = PS["Data.Eq"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Eq"] = $PS["Data.Eq"] || {};
    var exports = $PS["Data.Eq"];
    var $foreign = $PS["Data.Eq"];
    var Eq = function (eq) {
        this.eq = eq;
    }; 
    var eqNumber = new Eq($foreign.eqNumberImpl);
    var eqInt = new Eq($foreign.eqIntImpl);
    exports["eqInt"] = eqInt;
    exports["eqNumber"] = eqNumber;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Ordering"] = $PS["Data.Ordering"] || {};
    var exports = $PS["Data.Ordering"];              
    var LT = (function () {
        function LT() {
  
        };
        LT.value = new LT();
        return LT;
    })();
    var GT = (function () {
        function GT() {
  
        };
        GT.value = new GT();
        return GT;
    })();
    var EQ = (function () {
        function EQ() {
  
        };
        EQ.value = new EQ();
        return EQ;
    })();
    exports["LT"] = LT;
    exports["GT"] = GT;
    exports["EQ"] = EQ;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.numSub = function (n1) {
      return function (n2) {
        return n1 - n2;
      };
    };
  })(PS["Data.Ring"] = PS["Data.Ring"] || {});
  (function(exports) {
    "use strict";
  
    exports.numAdd = function (n1) {
      return function (n2) {
        return n1 + n2;
      };
    };
  
    exports.numMul = function (n1) {
      return function (n2) {
        return n1 * n2;
      };
    };
  })(PS["Data.Semiring"] = PS["Data.Semiring"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Semiring"] = $PS["Data.Semiring"] || {};
    var exports = $PS["Data.Semiring"];
    var $foreign = $PS["Data.Semiring"];
    var Semiring = function (add, mul, one, zero) {
        this.add = add;
        this.mul = mul;
        this.one = one;
        this.zero = zero;
    };
    var zero = function (dict) {
        return dict.zero;
    };                                                       
    var semiringNumber = new Semiring($foreign.numAdd, $foreign.numMul, 1.0, 0.0);
    var one = function (dict) {
        return dict.one;
    };
    exports["zero"] = zero;
    exports["one"] = one;
    exports["semiringNumber"] = semiringNumber;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Ring"] = $PS["Data.Ring"] || {};
    var exports = $PS["Data.Ring"];
    var $foreign = $PS["Data.Ring"];
    var Data_Semiring = $PS["Data.Semiring"];
    var Ring = function (Semiring0, sub) {
        this.Semiring0 = Semiring0;
        this.sub = sub;
    };
    var sub = function (dict) {
        return dict.sub;
    }; 
    var ringNumber = new Ring(function () {
        return Data_Semiring.semiringNumber;
    }, $foreign.numSub);
    var negate = function (dictRing) {
        return function (a) {
            return sub(dictRing)(Data_Semiring.zero(dictRing.Semiring0()))(a);
        };
    };
    exports["negate"] = negate;
    exports["ringNumber"] = ringNumber;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Ord"] = $PS["Data.Ord"] || {};
    var exports = $PS["Data.Ord"];
    var $foreign = $PS["Data.Ord"];
    var Data_Eq = $PS["Data.Eq"];
    var Data_Ordering = $PS["Data.Ordering"];
    var Data_Ring = $PS["Data.Ring"];
    var Data_Semiring = $PS["Data.Semiring"];
    var Ord = function (Eq0, compare) {
        this.Eq0 = Eq0;
        this.compare = compare;
    }; 
    var ordNumber = new Ord(function () {
        return Data_Eq.eqNumber;
    }, $foreign.ordNumberImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
    var ordInt = new Ord(function () {
        return Data_Eq.eqInt;
    }, $foreign.ordIntImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
    var compare = function (dict) {
        return dict.compare;
    };
    var greaterThanOrEq = function (dictOrd) {
        return function (a1) {
            return function (a2) {
                var v = compare(dictOrd)(a1)(a2);
                if (v instanceof Data_Ordering.LT) {
                    return false;
                };
                return true;
            };
        };
    };
    var signum = function (dictOrd) {
        return function (dictRing) {
            return function (x) {
                var $49 = greaterThanOrEq(dictOrd)(x)(Data_Semiring.zero(dictRing.Semiring0()));
                if ($49) {
                    return Data_Semiring.one(dictRing.Semiring0());
                };
                return Data_Ring.negate(dictRing)(Data_Semiring.one(dictRing.Semiring0()));
            };
        };
    };
    exports["signum"] = signum;
    exports["ordInt"] = ordInt;
    exports["ordNumber"] = ordNumber;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Bounded"] = $PS["Data.Bounded"] || {};
    var exports = $PS["Data.Bounded"];
    var $foreign = $PS["Data.Bounded"];
    var Data_Ord = $PS["Data.Ord"];
    var Bounded = function (Ord0, bottom, top) {
        this.Ord0 = Ord0;
        this.bottom = bottom;
        this.top = top;
    };
    var top = function (dict) {
        return dict.top;
    };                                            
    var boundedInt = new Bounded(function () {
        return Data_Ord.ordInt;
    }, $foreign.bottomInt, $foreign.topInt);
    var bottom = function (dict) {
        return dict.bottom;
    };
    exports["bottom"] = bottom;
    exports["top"] = top;
    exports["boundedInt"] = boundedInt;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.unit = {};
  })(PS["Data.Unit"] = PS["Data.Unit"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Unit"] = $PS["Data.Unit"] || {};
    var exports = $PS["Data.Unit"];
    var $foreign = $PS["Data.Unit"];
    exports["unit"] = $foreign.unit;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Foldable"] = $PS["Data.Foldable"] || {};
    var exports = $PS["Data.Foldable"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Apply = $PS["Control.Apply"];
    var Data_Function = $PS["Data.Function"];
    var Data_Unit = $PS["Data.Unit"];                
    var Foldable = function (foldMap, foldl, foldr) {
        this.foldMap = foldMap;
        this.foldl = foldl;
        this.foldr = foldr;
    };
    var foldr = function (dict) {
        return dict.foldr;
    };
    var traverse_ = function (dictApplicative) {
        return function (dictFoldable) {
            return function (f) {
                return foldr(dictFoldable)((function () {
                    var $311 = Control_Apply.applySecond(dictApplicative.Apply0());
                    return function ($312) {
                        return $311(f($312));
                    };
                })())(Control_Applicative.pure(dictApplicative)(Data_Unit.unit));
            };
        };
    };
    var for_ = function (dictApplicative) {
        return function (dictFoldable) {
            return Data_Function.flip(traverse_(dictApplicative)(dictFoldable));
        };
    };
    var foldl = function (dict) {
        return dict.foldl;
    };
    exports["Foldable"] = Foldable;
    exports["foldl"] = foldl;
    exports["for_"] = for_;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.runFn2 = function (fn) {
      return function (a) {
        return function (b) {
          return fn(a, b);
        };
      };
    };
  })(PS["Data.Function.Uncurried"] = PS["Data.Function.Uncurried"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Function.Uncurried"] = $PS["Data.Function.Uncurried"] || {};
    var exports = $PS["Data.Function.Uncurried"];
    var $foreign = $PS["Data.Function.Uncurried"];
    exports["runFn2"] = $foreign.runFn2;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.fromNumberImpl = function (just) {
      return function (nothing) {
        return function (n) {
          /* jshint bitwise: false */
          return (n | 0) === n ? just(n) : nothing;
        };
      };
    };
  
    exports.toNumber = function (n) {
      return n;
    };
  })(PS["Data.Int"] = PS["Data.Int"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Maybe"] = $PS["Data.Maybe"] || {};
    var exports = $PS["Data.Maybe"];
    var Control_Category = $PS["Control.Category"];  
    var Nothing = (function () {
        function Nothing() {
  
        };
        Nothing.value = new Nothing();
        return Nothing;
    })();
    var Just = (function () {
        function Just(value0) {
            this.value0 = value0;
        };
        Just.create = function (value0) {
            return new Just(value0);
        };
        return Just;
    })();
    var maybe = function (v) {
        return function (v1) {
            return function (v2) {
                if (v2 instanceof Nothing) {
                    return v;
                };
                if (v2 instanceof Just) {
                    return v1(v2.value0);
                };
                throw new Error("Failed pattern match at Data.Maybe (line 230, column 1 - line 230, column 51): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
            };
        };
    };
    var fromMaybe = function (a) {
        return maybe(a)(Control_Category.identity(Control_Category.categoryFn));
    };
    exports["Nothing"] = Nothing;
    exports["Just"] = Just;
    exports["fromMaybe"] = fromMaybe;
  })(PS);
  (function(exports) {
    /* globals exports */
    "use strict";               
  
    exports.isFinite = isFinite;
  })(PS["Data.Number"] = PS["Data.Number"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Number"] = $PS["Data.Number"] || {};
    var exports = $PS["Data.Number"];
    var $foreign = $PS["Data.Number"];
    exports["isFinite"] = $foreign["isFinite"];
  })(PS);
  (function(exports) {
    "use strict";
  
    // module Math
  
    exports.abs = Math.abs;    
  
    function nativeImul(a) {
      return function (b) {
        return Math.imul(a, b);
      };
    }
  
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
    function emulatedImul(a) {
      /*jshint bitwise: false*/
      return function (b) {
        var ah = a >>> 16 & 0xffff;
        var al = a & 0xffff;
        var bh = b >>> 16 & 0xffff;
        var bl = b & 0xffff;
        // the shift by 0 fixes the sign on the high part
        // the final |0 converts the unsigned value into a signed value
        return al * bl + (ah * bl + al * bh << 16 >>> 0) | 0;
      };
    } 
  
    exports.log = Math.log;
  
    exports.pow = function (n) {
      return function (p) {
        return Math.pow(n, p);
      };
    };
  
    exports.round = Math.round;
  })(PS["Math"] = PS["Math"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Math"] = $PS["Math"] || {};
    var exports = $PS["Math"];
    var $foreign = $PS["Math"];
    exports["abs"] = $foreign.abs;
    exports["log"] = $foreign.log;
    exports["pow"] = $foreign.pow;
    exports["round"] = $foreign.round;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Int"] = $PS["Data.Int"] || {};
    var exports = $PS["Data.Int"];
    var $foreign = $PS["Data.Int"];
    var Data_Boolean = $PS["Data.Boolean"];
    var Data_Bounded = $PS["Data.Bounded"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Number = $PS["Data.Number"];
    var $$Math = $PS["Math"];         
    var fromNumber = $foreign.fromNumberImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
    var unsafeClamp = function (x) {
        if (!Data_Number["isFinite"](x)) {
            return 0;
        };
        if (x >= $foreign.toNumber(Data_Bounded.top(Data_Bounded.boundedInt))) {
            return Data_Bounded.top(Data_Bounded.boundedInt);
        };
        if (x <= $foreign.toNumber(Data_Bounded.bottom(Data_Bounded.boundedInt))) {
            return Data_Bounded.bottom(Data_Bounded.boundedInt);
        };
        if (Data_Boolean.otherwise) {
            return Data_Maybe.fromMaybe(0)(fromNumber(x));
        };
        throw new Error("Failed pattern match at Data.Int (line 66, column 1 - line 66, column 29): " + [ x.constructor.name ]);
    };
    var round = function ($23) {
        return unsafeClamp($$Math.round($23));
    };
    exports["round"] = round;
    exports["toNumber"] = $foreign.toNumber;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Monoid"] = $PS["Data.Monoid"] || {};
    var exports = $PS["Data.Monoid"];
    var mempty = function (dict) {
        return dict.mempty;
    };
    exports["mempty"] = mempty;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.Semigroup"] = $PS["Data.Semigroup"] || {};
    var exports = $PS["Data.Semigroup"];
    var append = function (dict) {
        return dict.append;
    };
    exports["append"] = append;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.List.Types"] = $PS["Data.List.Types"] || {};
    var exports = $PS["Data.List.Types"];
    var Data_Foldable = $PS["Data.Foldable"];
    var Data_Function = $PS["Data.Function"];
    var Data_Monoid = $PS["Data.Monoid"];
    var Data_Semigroup = $PS["Data.Semigroup"];                    
    var Nil = (function () {
        function Nil() {
  
        };
        Nil.value = new Nil();
        return Nil;
    })();
    var Cons = (function () {
        function Cons(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        Cons.create = function (value0) {
            return function (value1) {
                return new Cons(value0, value1);
            };
        };
        return Cons;
    })();                                                                
    var foldableList = new Data_Foldable.Foldable(function (dictMonoid) {
        return function (f) {
            return Data_Foldable.foldl(foldableList)(function (acc) {
                var $204 = Data_Semigroup.append(dictMonoid.Semigroup0())(acc);
                return function ($205) {
                    return $204(f($205));
                };
            })(Data_Monoid.mempty(dictMonoid));
        };
    }, function (f) {
        var go = function ($copy_b) {
            return function ($copy_v) {
                var $tco_var_b = $copy_b;
                var $tco_done = false;
                var $tco_result;
                function $tco_loop(b, v) {
                    if (v instanceof Nil) {
                        $tco_done = true;
                        return b;
                    };
                    if (v instanceof Cons) {
                        $tco_var_b = f(b)(v.value0);
                        $copy_v = v.value1;
                        return;
                    };
                    throw new Error("Failed pattern match at Data.List.Types (line 112, column 12 - line 114, column 30): " + [ v.constructor.name ]);
                };
                while (!$tco_done) {
                    $tco_result = $tco_loop($tco_var_b, $copy_v);
                };
                return $tco_result;
            };
        };
        return go;
    }, function (f) {
        return function (b) {
            var rev = (function () {
                var go = function ($copy_acc) {
                    return function ($copy_v) {
                        var $tco_var_acc = $copy_acc;
                        var $tco_done = false;
                        var $tco_result;
                        function $tco_loop(acc, v) {
                            if (v instanceof Nil) {
                                $tco_done = true;
                                return acc;
                            };
                            if (v instanceof Cons) {
                                $tco_var_acc = new Cons(v.value0, acc);
                                $copy_v = v.value1;
                                return;
                            };
                            throw new Error("Failed pattern match at Data.List.Types (line 108, column 7 - line 108, column 23): " + [ acc.constructor.name, v.constructor.name ]);
                        };
                        while (!$tco_done) {
                            $tco_result = $tco_loop($tco_var_acc, $copy_v);
                        };
                        return $tco_result;
                    };
                };
                return go(Nil.value);
            })();
            var $206 = Data_Foldable.foldl(foldableList)(Data_Function.flip(f))(b);
            return function ($207) {
                return $206(rev($207));
            };
        };
    });
    exports["Nil"] = Nil;
    exports["Cons"] = Cons;
    exports["foldableList"] = foldableList;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Data.List"] = $PS["Data.List"] || {};
    var exports = $PS["Data.List"];
    var Data_Boolean = $PS["Data.Boolean"];
    var Data_List_Types = $PS["Data.List.Types"];
    var singleton = function (a) {
        return new Data_List_Types.Cons(a, Data_List_Types.Nil.value);
    };
    var range = function (start) {
        return function (end) {
            if (start === end) {
                return singleton(start);
            };
            if (Data_Boolean.otherwise) {
                var go = function ($copy_s) {
                    return function ($copy_e) {
                        return function ($copy_step) {
                            return function ($copy_rest) {
                                var $tco_var_s = $copy_s;
                                var $tco_var_e = $copy_e;
                                var $tco_var_step = $copy_step;
                                var $tco_done = false;
                                var $tco_result;
                                function $tco_loop(s, e, step, rest) {
                                    if (s === e) {
                                        $tco_done = true;
                                        return new Data_List_Types.Cons(s, rest);
                                    };
                                    if (Data_Boolean.otherwise) {
                                        $tco_var_s = s + step | 0;
                                        $tco_var_e = e;
                                        $tco_var_step = step;
                                        $copy_rest = new Data_List_Types.Cons(s, rest);
                                        return;
                                    };
                                    throw new Error("Failed pattern match at Data.List (line 152, column 3 - line 153, column 65): " + [ s.constructor.name, e.constructor.name, step.constructor.name, rest.constructor.name ]);
                                };
                                while (!$tco_done) {
                                    $tco_result = $tco_loop($tco_var_s, $tco_var_e, $tco_var_step, $copy_rest);
                                };
                                return $tco_result;
                            };
                        };
                    };
                };
                return go(end)(start)((function () {
                    var $225 = start > end;
                    if ($225) {
                        return 1;
                    };
                    return -1 | 0;
                })())(Data_List_Types.Nil.value);
            };
            throw new Error("Failed pattern match at Data.List (line 148, column 1 - line 148, column 32): " + [ start.constructor.name, end.constructor.name ]);
        };
    };
    exports["range"] = range;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.pureE = function (a) {
      return function () {
        return a;
      };
    };
  
    exports.bindE = function (a) {
      return function (f) {
        return function () {
          return f(a())();
        };
      };
    };
  })(PS["Effect"] = PS["Effect"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Effect"] = $PS["Effect"] || {};
    var exports = $PS["Effect"];
    var $foreign = $PS["Effect"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Apply = $PS["Control.Apply"];
    var Control_Bind = $PS["Control.Bind"];
    var Control_Monad = $PS["Control.Monad"];
    var Data_Functor = $PS["Data.Functor"];                    
    var monadEffect = new Control_Monad.Monad(function () {
        return applicativeEffect;
    }, function () {
        return bindEffect;
    });
    var bindEffect = new Control_Bind.Bind(function () {
        return applyEffect;
    }, $foreign.bindE);
    var applyEffect = new Control_Apply.Apply(function () {
        return functorEffect;
    }, Control_Monad.ap(monadEffect));
    var applicativeEffect = new Control_Applicative.Applicative(function () {
        return applyEffect;
    }, $foreign.pureE);
    var functorEffect = new Data_Functor.Functor(Control_Applicative.liftA1(applicativeEffect));
    exports["applicativeEffect"] = applicativeEffect;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.new = function (val) {
      return function () {
        return { value: val };
      };
    };
  
    exports.modifyImpl = function (f) {
      return function (ref) {
        return function () {
          var t = f(ref.value);
          ref.value = t.state;
          return t.value;
        };
      };
    };
  })(PS["Effect.Ref"] = PS["Effect.Ref"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Effect.Ref"] = $PS["Effect.Ref"] || {};
    var exports = $PS["Effect.Ref"];
    var $foreign = $PS["Effect.Ref"];          
    var modify$prime = $foreign.modifyImpl;
    var modify = function (f) {
        return modify$prime(function (s) {
            var s$prime = f(s);
            return {
                state: s$prime,
                value: s$prime
            };
        });
    };
    exports["modify"] = modify;
    exports["new"] = $foreign["new"];
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.mkEffectFn1 = function mkEffectFn1(fn) {
      return function(x) {
        return fn(x)();
      };
    };
  })(PS["Effect.Uncurried"] = PS["Effect.Uncurried"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Effect.Uncurried"] = $PS["Effect.Uncurried"] || {};
    var exports = $PS["Effect.Uncurried"];
    var $foreign = $PS["Effect.Uncurried"];
    exports["mkEffectFn1"] = $foreign.mkEffectFn1;
  })(PS);
  (function(exports) {
    exports.getArgImpl = function(arguments, i) {
      if(i < arguments.length) {
        return arguments[i];
      } else {
        throw ( "getArgImpl: Argument "
              + i
              + " out of range ("
              + arguments.length
              + ")\n"
              );
      }
    }
  })(PS["MaxForLive.Arguments"] = PS["MaxForLive.Arguments"] || {});
  (function(exports) {
    exports.fromMaxIntImpl = function(x) {
      if(typeof(x) === 'number') {
        return x;
      } else {
        throw ( "fromMaxIntImpl: Argument "
              + x
              + " has unexpected type "
              + typeof(x)
              + " (expected Int)\n"
              );
      }
    }
  
    exports.fromMaxNumberImpl = function(x) {
      if(typeof(x) === 'number') {
        return x;
      } else {
        throw ( "fromMaxNumberImpl: Argument "
              + x
              + " has unexpected type "
              + typeof(x)
              + " (expected Number)\n"
              );
      }
    }
  })(PS["MaxForLive.Conversions"] = PS["MaxForLive.Conversions"] || {});
  (function(exports) {
    "use strict";
  
    // module Unsafe.Coerce
  
    exports.unsafeCoerce = function (x) {
      return x;
    };
  })(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Unsafe.Coerce"] = $PS["Unsafe.Coerce"] || {};
    var exports = $PS["Unsafe.Coerce"];
    var $foreign = $PS["Unsafe.Coerce"];
    exports["unsafeCoerce"] = $foreign.unsafeCoerce;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["MaxForLive.Conversions"] = $PS["MaxForLive.Conversions"] || {};
    var exports = $PS["MaxForLive.Conversions"];
    var $foreign = $PS["MaxForLive.Conversions"];
    var Data_Functor = $PS["Data.Functor"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];
    var ToMax = function (toMax) {
        this.toMax = toMax;
    };
    var FromMax = function (fromMax) {
        this.fromMax = fromMax;
    };                                                                                    
    var toMaxInt = new ToMax(Unsafe_Coerce.unsafeCoerce);
    var toMax = function (dict) {
        return dict.toMax;
    };
    var toMaxArray = function (dictToMax) {
        return new ToMax((function () {
            var $15 = Data_Functor.map(Data_Functor.functorArray)(toMax(dictToMax));
            return function ($16) {
                return $15($16);
            };
        })());
    };                                                          
    var fromMaxNumber = new FromMax($foreign.fromMaxNumberImpl);
    var fromMaxInt = new FromMax($foreign.fromMaxIntImpl);
    var fromMax = function (dict) {
        return dict.fromMax;
    };
    exports["fromMax"] = fromMax;
    exports["toMax"] = toMax;
    exports["fromMaxInt"] = fromMaxInt;
    exports["fromMaxNumber"] = fromMaxNumber;
    exports["toMaxInt"] = toMaxInt;
    exports["toMaxArray"] = toMaxArray;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["MaxForLive.Arguments"] = $PS["MaxForLive.Arguments"] || {};
    var exports = $PS["MaxForLive.Arguments"];
    var $foreign = $PS["MaxForLive.Arguments"];
    var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];
    var MaxForLive_Conversions = $PS["MaxForLive.Conversions"];
    var getArg = function (dictFromMax) {
        return function (xs) {
            var $5 = MaxForLive_Conversions.fromMax(dictFromMax);
            var $6 = Data_Function_Uncurried.runFn2($foreign.getArgImpl)(xs);
            return function ($7) {
                return $5($6($7));
            };
        };
    };
    exports["getArg"] = getArg;
  })(PS);
  (function(exports) {
     
  
    exports.setInlets = function(numInlets) {
      return function() {
        inlets = numInlets;
      }
    }
  
    exports.setOutlets = function(numOutlets) {
      return function() {
        outlets = numOutlets;
      }
    }
  
    exports.outletImpl = function(i, x) {
      outlet(i, x);
    }
  })(PS["MaxForLive.Global"] = PS["MaxForLive.Global"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["MaxForLive.Global"] = $PS["MaxForLive.Global"] || {};
    var exports = $PS["MaxForLive.Global"];
    var $foreign = $PS["MaxForLive.Global"];
    var MaxForLive_Conversions = $PS["MaxForLive.Conversions"];
    var outlet = function (dictToMax) {
        return function (i) {
            return function (x) {
                return function () {
                    return $foreign.outletImpl(i, MaxForLive_Conversions.toMax(dictToMax)(x));
                };
            };
        };
    };
    exports["outlet"] = outlet;
    exports["setInlets"] = $foreign.setInlets;
    exports["setOutlets"] = $foreign.setOutlets;
  })(PS);
  (function(exports) {
    exports.setHandlerImpl = function(inlet, message, handler) {
      if(messageHandlers[inlet] === undefined) {
        messageHandlers[inlet] = {};
      }
  
      messageHandlers[inlet][message] = handler;
    }
  })(PS["MaxForLive.Handlers"] = PS["MaxForLive.Handlers"] || {});
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["MaxForLive.Handlers"] = $PS["MaxForLive.Handlers"] || {};
    var exports = $PS["MaxForLive.Handlers"];
    var $foreign = $PS["MaxForLive.Handlers"];
    var Data_Function = $PS["Data.Function"];
    var Effect_Uncurried = $PS["Effect.Uncurried"];
    var MaxForLive_Arguments = $PS["MaxForLive.Arguments"];                
    var InvokeHandler = function (invokeHandler) {
        this.invokeHandler = invokeHandler;
    };
    var invokeNoArgs = new InvokeHandler(function (_i) {
        return Data_Function["const"];
    });
    var invokeHandler = function (dict) {
        return dict.invokeHandler;
    };
    var invokeWithArg = function (dictFromMax) {
        return function (dictInvokeHandler) {
            return new InvokeHandler(function (i) {
                return function (f) {
                    return function (xs) {
                        return invokeHandler(dictInvokeHandler)(i + 1 | 0)(f(MaxForLive_Arguments.getArg(dictFromMax)(xs)(i)))(xs);
                    };
                };
            });
        };
    };
    var setHandler = function (dictInvokeHandler) {
        return function (v) {
            return function () {
                return $foreign.setHandlerImpl(v.inlet, v.msg, Effect_Uncurried.mkEffectFn1(invokeHandler(dictInvokeHandler)(0)(v.handler)));
            };
        };
    };
    exports["setHandler"] = setHandler;
    exports["invokeNoArgs"] = invokeNoArgs;
    exports["invokeWithArg"] = invokeWithArg;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Velocity.Range"] = $PS["Velocity.Range"] || {};
    var exports = $PS["Velocity.Range"];
    var Data_Int = $PS["Data.Int"];
    var Data_Ord = $PS["Data.Ord"];
    var Data_Ring = $PS["Data.Ring"];
    var $$Math = $PS["Math"];                
    var withValue = function (lo) {
        return function (hi) {
            return function (x) {
                return {
                    lo: lo,
                    hi: hi,
                    x: Data_Int.toNumber(x)
                };
            };
        };
    };
    var withPosition = function (lo) {
        return function (hi) {
            return function (p) {
                return {
                    lo: lo,
                    hi: hi,
                    x: lo + (hi - lo) * p
                };
            };
        };
    };
    var width = function (v) {
        return v.hi - v.lo;
    };
    var position = function (v) {
        return (v.x - v.lo) / width(v);
    };
    var scale = function (lo$prime) {
        return function (hi$prime) {
            return function (r) {
                var v = (function () {
                    var $12 = lo$prime <= hi$prime;
                    if ($12) {
                        return {
                            lo: Data_Int.toNumber(lo$prime),
                            hi: Data_Int.toNumber(hi$prime)
                        };
                    };
                    return {
                        lo: Data_Int.toNumber(hi$prime),
                        hi: Data_Int.toNumber(lo$prime)
                    };
                })();
                return withPosition(v.lo)(v.hi)(position(r));
            };
        };
    };
    var from = function (v) {
        return Data_Int.round(v.x);
    };
    var expand = function (mu) {
        return function (r) {
            return {
                lo: r.lo,
                hi: r.hi,
                x: Data_Ord.signum(Data_Ord.ordNumber)(Data_Ring.ringNumber)(r.x) * (1.0 / mu) * ($$Math.pow(1.0 + mu)($$Math.abs(r.x)) - 1.0)
            };
        };
    };
    var compress = function (mu) {
        return function (r) {
            return {
                lo: r.lo,
                hi: r.hi,
                x: (Data_Ord.signum(Data_Ord.ordNumber)(Data_Ring.ringNumber)(r.x) * $$Math.log(1.0 + mu * $$Math.abs(r.x))) / $$Math.log(1.0 + mu)
            };
        };
    };
    exports["withValue"] = withValue;
    exports["from"] = from;
    exports["scale"] = scale;
    exports["compress"] = compress;
    exports["expand"] = expand;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Velocity.Curve"] = $PS["Velocity.Curve"] || {};
    var exports = $PS["Velocity.Curve"];
    var Control_Category = $PS["Control.Category"];
    var Data_Boolean = $PS["Data.Boolean"];
    var $$Math = $PS["Math"];
    var Velocity_Range = $PS["Velocity.Range"];                
    var setOutLo = function (n) {
        return function (c) {
            return {
                drive: c.drive,
                comp: c.comp,
                outLo: n,
                outHi: c.outHi
            };
        };
    };
    var setOutHi = function (n) {
        return function (c) {
            return {
                drive: c.drive,
                comp: c.comp,
                outLo: c.outLo,
                outHi: n
            };
        };
    };
    var setDrive = function (n) {
        return function (c) {
            return {
                drive: n,
                comp: c.comp,
                outLo: c.outLo,
                outHi: c.outHi
            };
        };
    };
    var setComp = function (n) {
        return function (c) {
            return {
                drive: c.drive,
                comp: n,
                outLo: c.outLo,
                outHi: c.outHi
            };
        };
    };
    var leaveNoteOff = function (v) {
        return function (v1) {
            if (v1 === 0) {
                return 0;
            };
            return v(v1);
        };
    };
    var $$default = {
        drive: 0.0,
        comp: 0.0,
        outLo: 0,
        outHi: 127
    };
    var compand = function (comp) {
        var mu = function (f) {
            return $$Math.pow(10.0)(2.0 * $$Math.abs(f));
        };
        if (comp > 0.0) {
            return Velocity_Range.compress(mu(comp));
        };
        if (comp < 0.0) {
            return Velocity_Range.expand(mu(comp));
        };
        if (Data_Boolean.otherwise) {
            return Control_Category.identity(Control_Category.categoryFn);
        };
        throw new Error("Failed pattern match at Velocity.Curve (line 83, column 5 - line 86, column 33): " + [ comp.constructor.name ]);
    };
    var apply = function (v) {
        return leaveNoteOff((function () {
            var $15 = Velocity_Range.scale(v.outLo)(v.outHi);
            var $16 = compand(v.comp);
            var $17 = Velocity_Range.scale(-1 | 0)(1);
            var $18 = compand(v.drive);
            var $19 = Velocity_Range.scale(0)(1);
            var $20 = Velocity_Range.withValue(0.0)(127.0);
            return function ($21) {
                return Velocity_Range.from($15($16($17($18($19($20($21)))))));
            };
        })());
    };
    exports["default"] = $$default;
    exports["setDrive"] = setDrive;
    exports["setComp"] = setComp;
    exports["setOutLo"] = setOutLo;
    exports["setOutHi"] = setOutHi;
    exports["apply"] = apply;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.14.0
    "use strict";
    $PS["Velocity"] = $PS["Velocity"] || {};
    var exports = $PS["Velocity"];
    var Data_Foldable = $PS["Data.Foldable"];
    var Data_List = $PS["Data.List"];
    var Data_List_Types = $PS["Data.List.Types"];
    var Data_Unit = $PS["Data.Unit"];
    var Effect = $PS["Effect"];
    var Effect_Ref = $PS["Effect.Ref"];
    var MaxForLive_Conversions = $PS["MaxForLive.Conversions"];
    var MaxForLive_Global = $PS["MaxForLive.Global"];
    var MaxForLive_Handlers = $PS["MaxForLive.Handlers"];
    var Velocity_Curve = $PS["Velocity.Curve"];                
    var updateCurve = function (ref) {
        return function (upd) {
            return function (a) {
                return function __do() {
                    var c = Effect_Ref.modify(upd(a))(ref)();
                    return Data_Foldable.for_(Effect.applicativeEffect)(Data_List_Types.foldableList)(Data_List.range(0)(127))(function (i) {
                        return MaxForLive_Global.outlet(MaxForLive_Conversions.toMaxArray(MaxForLive_Conversions.toMaxInt))(0)([ i, Velocity_Curve.apply(c)(i) ]);
                    })();
                };
            };
        };
    };
    var main = function __do() {
        MaxForLive_Global.setInlets(4)();
        MaxForLive_Global.setOutlets(1)();
        var state = Effect_Ref["new"](Velocity_Curve["default"])();
        MaxForLive_Handlers.setHandler(MaxForLive_Handlers.invokeWithArg(MaxForLive_Conversions.fromMaxNumber)(MaxForLive_Handlers.invokeNoArgs))({
            inlet: 0,
            msg: "msg_float",
            handler: updateCurve(state)(Velocity_Curve.setDrive)
        })();
        MaxForLive_Handlers.setHandler(MaxForLive_Handlers.invokeWithArg(MaxForLive_Conversions.fromMaxNumber)(MaxForLive_Handlers.invokeNoArgs))({
            inlet: 1,
            msg: "msg_float",
            handler: updateCurve(state)(Velocity_Curve.setComp)
        })();
        MaxForLive_Handlers.setHandler(MaxForLive_Handlers.invokeWithArg(MaxForLive_Conversions.fromMaxInt)(MaxForLive_Handlers.invokeNoArgs))({
            inlet: 2,
            msg: "msg_int",
            handler: updateCurve(state)(Velocity_Curve.setOutLo)
        })();
        MaxForLive_Handlers.setHandler(MaxForLive_Handlers.invokeWithArg(MaxForLive_Conversions.fromMaxInt)(MaxForLive_Handlers.invokeNoArgs))({
            inlet: 3,
            msg: "msg_int",
            handler: updateCurve(state)(Velocity_Curve.setOutHi)
        })();
        return Data_Unit.unit;
    };
    exports["main"] = main;
  })(PS);
  PS["Velocity"].main();
  /* END */
  