diff --git a/benchmark/manners/manners.nools b/benchmark/manners/manners.nools index c3c80ab..2a6eb71 100644 --- a/benchmark/manners/manners.nools +++ b/benchmark/manners/manners.nools @@ -106,7 +106,6 @@ rule findSeating { not(chosen : Chosen chosen.id == sid && chosen.guestName == leftGuestName && chosen.hobby == rightGuestHobby); } then { - console.log("findSeating"); assert(new Seating({ id : countValue, pid : sid, @@ -132,7 +131,6 @@ rule makePath { not( p2 : Path p2.id == sid && p2.guestName == pathGuestName); } then { - console.log("makePath"); assert(new Path({id : sid, seat : pathSeat, guestName : pathGuestName})); } } @@ -143,7 +141,6 @@ rule pathDone { s : Seating s.path == false; } then { - console.log("pathDone"); modify(s, function(){ this.path = true; }); @@ -171,7 +168,6 @@ rule continue { c : Context c.state == 'check'; } then { - console.log("continue"); modify(c, function(){this.state = 'assign'}); } } diff --git a/benchmark/sendMoreMoney/benchmark.js b/benchmark/sendMoreMoney/benchmark.js new file mode 100644 index 0000000..ba53640 --- /dev/null +++ b/benchmark/sendMoreMoney/benchmark.js @@ -0,0 +1,14 @@ +"use strict"; + +var nools = require("../../index"), + flow = nools.compile(__dirname + "/sendMoreMoney.nools"); + +var start = new Date(), + session; +console.log("starting"); +(session = flow.getSession(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)).match().then(function () { + console.log("%dms", +(new Date()) - start); + session.dispose(); +}); + + diff --git a/benchmark/sendMoreMoney/sendMoreMoney.nools b/benchmark/sendMoreMoney/sendMoreMoney.nools new file mode 100644 index 0000000..8183380 --- /dev/null +++ b/benchmark/sendMoreMoney/sendMoreMoney.nools @@ -0,0 +1,18 @@ +rule SendMoreMoney { + when { + s : Number s != 0; + e : Number e != s; + n : Number n != s && n != e; + d : Number d != s && d != e && d != n; + m : Number m != 0 && m != s && m != e && m != n && m != d; + o : Number o != s && o != e && o != n && o != d && o != m; + r : Number r != s && r != e && r != n && r != d && r != m && r != o; + y : Number y != s && y != e && y != n && y != d && y != m && y != o && y != r + && (s*1000 + e*100 + n*10 + d + m*1000 + o*100 + r*10 + e) == (m*10000 + o*1000 + n*100 + e*10 + y); + } + then { + console.log('pathDone', {s : s, e : e, n : n, d : d, m : m, o: o, r : r, y : y}); + console.log((s*1000 + e*100 + n*10 + d + m*1000 + o*100 + r*10 + e)); + console.log((m*10000 + o*1000 + n*100 + e*10 + y)) + } +} \ No newline at end of file diff --git a/benchmark/waltzDb/waltzDb.nools b/benchmark/waltzDb/waltzDb.nools index 891d347..e0607fd 100644 --- a/benchmark/waltzDb/waltzDb.nools +++ b/benchmark/waltzDb/waltzDb.nools @@ -829,7 +829,7 @@ rule visit_2j_2 { // ; (write edge_label (crlf)) // (make edge_label ^p1 ^p2 ^l_name ^l_id ) // (make edge_label ^p1 ^p2 ^l_name ^l_id )) -rule visit_2j_0 { +rule visit_2j_3 { when { s : Stage s.value == 'VISITING_2J'; j : Junction j.visited == 'now' {name : name, basePoint : basePoint, p1 : p1, p2 : p2}; @@ -922,7 +922,7 @@ rule start_checking { // --> // (modify 1 ^value remove_label) // (make illegal ^bp ^l_id )) -rule checking1 { +rule checking { when { stage : Stage stage.value == 'CHECKING'; junction : Junction junction.visited == 'check' {basePoint : basePoint}; diff --git a/docs-md/examples.md b/docs-md/examples.md index 8cf9a0b..f600335 100644 --- a/docs-md/examples.md +++ b/docs-md/examples.md @@ -2,6 +2,7 @@ * [Conways 2D](./examples/browser/conways_2d.html) * [Conways 3D](./examples/browser/conways_3d.html) + * [Sudoku](./examples/browser/sudoku.html) * [Fibonacci](./examples/browser/fibonacci.html) * [Miss Manners](./examples/browser/manners.html) * [Diagnosis](./examples/browser/diagnose.html) diff --git a/docs/History.html b/docs/History.html index bc09f06..de60546 100644 --- a/docs/History.html +++ b/docs/History.html @@ -178,6 +178,18 @@ +

0.2.0 / 2013-10-14

+
    +
  • Nools now supports true modify!!!
      +
    • This is a major leap forward for nools opening the door for more complex actions and expressions in the rules.
    • +
    +
  • +
  • Added support from for from conditions in the rhs.
  • +
  • Fixed issue #81.
  • +
  • Fixed issue #82.
  • +
  • Added new sudoku web example.
  • +
  • Added Send More Money benchmark see #78.
  • +

0.1.14

  • Fixed issue with async actions and early match termination.
  • diff --git a/docs/examples.html b/docs/examples.html index 6c8e337..7d94e33 100644 --- a/docs/examples.html +++ b/docs/examples.html @@ -182,6 +182,7 @@

    Examples

    • Conways 2D
    • Conways 3D
    • +
    • Sudoku
    • Fibonacci
    • Miss Manners
    • Diagnosis
    • diff --git a/docs/examples/browser/assets/array-extended.js b/docs/examples/browser/assets/array-extended.js new file mode 100644 index 0000000..ba1aad0 --- /dev/null +++ b/docs/examples/browser/assets/array-extended.js @@ -0,0 +1,3 @@ +/*! array-extended - v0.0.9 - 2013-06-17 + * Copyright (c) 2013 Doug Martin; Licensed MIT */ +!function(){"use strict";function a(a,b,c){function d(a,b){return o(b,function(b,c){return N(c)||(c=[c]),c.unshift(a),b.unshift(c),b},[])}function e(a,b,c){for(var d=[],e=0;e>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=a(require("extended"),require("is-extended"),require("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(b,c,d){return a(b,c,d)}):this.arrayExtended=a(this.extended,this.isExtended,this.argumentsExtended)}.call(this); \ No newline at end of file diff --git a/docs/examples/browser/assets/conways.css b/docs/examples/browser/assets/conways.css index 78a3af0..b4eced4 100644 --- a/docs/examples/browser/assets/conways.css +++ b/docs/examples/browser/assets/conways.css @@ -152,6 +152,23 @@ input[type="submit"], input[type="button"] { box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2); } +.sudoku .col { + width: 50px; + height: 50px; + font-size: 30px; + vertical-align: middle; + text-align: center; +} + +.sudoku .col.error { + background-color: rgba(255, 0, 0, 0.43); +} + +.sudoku #grid{ + width: 465px; + height: 470px; +} + .col.live { background-color: black; } diff --git a/docs/examples/browser/rules/conways3d.nools b/docs/examples/browser/rules/conways3d.nools index e9af56a..4f71c5f 100644 --- a/docs/examples/browser/rules/conways3d.nools +++ b/docs/examples/browser/rules/conways3d.nools @@ -71,6 +71,8 @@ rule Transition { if(cell.transition()){ emit("cell-transition", cell); transitioned = true; + }else{ + retract(cell); } }); emit("evaluate"); diff --git a/docs/examples/browser/rules/sudoku.nools b/docs/examples/browser/rules/sudoku.nools new file mode 100644 index 0000000..cd2661f --- /dev/null +++ b/docs/examples/browser/rules/sudoku.nools @@ -0,0 +1,377 @@ + +rule "terminate group" { + salience: -100; + agenda-group: "validate"; + when { + $state: String $state == "validate"; + } + then{ + console.log("Validation complete." ); + retract($state); + halt(); + } +} + + + +rule "duplicate in cell col" { + agenda-group: "validate"; + when{ + $c: Cell $c.value; + $e: Cell $e.value == $c.value from $c.exCells; + } + then { + emit("invalid", $c); + emit("invalid", $e); + } +} + + +rule "halt after setup" { + when{ + $ctr: Counter $ctr.count == 0; + } + then{ + console.log("halt after setup"); + halt(); + } +} + + +rule "emergency halt 2" { + salience: 100; + when{ + $c: Cell !$c.value && $c.count == 0; + } + then{ + console.log("emergency halt cell without a value and no free values"); + halt(); + //process.exit(); + } + +} + +// A Setting object is inserted to define the value of a Cell. +// Rule "set a value" updates the cell and all cell groups containing it. +rule "set a value"{ + when{ + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // a matching Cell, with no value set + $c: Cell $c.rowNo == $rn && $c.colNo == $cn && !$c.value {cellRow: $cr, cellCol: $cc, cellSqr: $cs}; + } + then { + // modify the Cell by setting its value + modify( $c, function(){ this.blockExcept(); this.value = $v;}); + emit("set-value", $c); + console.log( "set cell " + $c.toString() ); + modify( $cr, function(){ this.blockValue( $v ) }); + modify( $cc, function(){ this.blockValue( $v ) }); + modify( $cs, function(){ this.blockValue( $v ) }); + } +} + + +// Rule for removing a value from all cells that are siblings +// in one of the three cell groups. +rule "eliminate a value from Cell" { + salience: 1; + when{ + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // the matching Cell, with the value already set + $mc : Cell $mc.rowNo == $rn && $mc.colNo == $cn && $mc.value == $v {exCells: $exCells}; + + // for all Cells that are in cahoots with the updated cell + $c: Cell $v in $c.free from $exCells; + } + then{ + console.log( "clear " + $v + " from cell " + $c.posAsString() + " because of " + $mc.posAsString() ); + // modify a related Cell by blocking the assigned value + modify( $c, function(){ this.blockValue( $v ); }); + } +} + +//Rule for elimination the Setting fact. +rule "retract setting"{ + when { + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // the matching Cell, with the value already set + $c: Cell $c.rowNo == $rn && $c.colNo == $cn && $c.value == $v; + + // This is the negation of the last pattern in the previous rule. + // Now the Setting fact can be safely retracted. + not( $x: Cell $v in $x.free && $x in $c.exCells); + // count down + $ctr: Counter {count: $count}; + + } + then{ + console.log("retracting " + $s.toString()); + // Discard the Setter fact. + retract( $s ); + console.log("COUNT = %s", $count); + modify( $ctr, function(){ this.count = $count - 1;}); + console.log( "done setting cell " + $c.toString() ); + } +} + + +// Detect a set of candidate values with cardinality 1 for some Cell. +// This is the value to be set. +rule "single"{ + when { + // There is currently no setting under way. + not($ns: Setting); + + // One element in the "free" set. + $c: Cell $c.count == 1 {rowNo: $rn, colNo: $cn}; + } + then { + var i = $c.freeValue(); + console.log( "single " + i + " at " + $c.posAsString() ); + // Insert another Setter fact. + assert( new Setting( $rn, $cn, i ) ); + } +} + +// Detect a set of candidate values with a value that is the only one +// in one of its groups. This is the value to be set. +rule "hidden single" { + when{ + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + // Some integer. + $i: Number; + + // The "free" set contains this number. + $c: Cell $c.count > 1 && $i in $c.free {rowNo: $rn, colNo: $cn}; + + // We have a cell group containing this cell $c + $cg: CellGroup $c in $cg.cells; + // but no other cell from that group contains $i + not ($nc2: Cell $nc2 != $c && $i in $nc2.free from $cg.cells); + } + then { + console.log( "hidden single " + $i + " at " + $c.posAsString() ); + // Insert another Setter fact. + assert( new Setting( $rn, $cn, $i ) ); + } +} + + +// A "naked pair" is two cells in some cell group with their sets of +// permissible values being equal with cardinality 2. These two values +// can be removed from all other candidate lists in the group. +rule "naked pair" { + when { + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + + // One cell with two candidates. + $c1: Cell $c1.count == 2 {free: $f1, cellRow: $r1, rowNo: $rn1, colNo: $cn1, cellSqr: $b1}; + + // The containing cell group. + $cg: CellGroup $cg.count > 2 && $c1 in $cg.cells; + + // Another cell with two candidates, not the one we already have. + $c2: Cell( $c2 != $c1 && deepEqual($c2.free, $f1) ) from $cg.cells; + + // Get one of the "naked pair". + $v: Number from $c1.free; + + // Get some other cell with a candidate equal to one from the pair. + $c3: Cell $c3 != $c1 && $c3 != $c2 && $c3.count > 1 && $v in $c3.free from $cg.cells; + } + then{ + console.log( "remove " + $v + " from " + $c3.posAsString() + " due to naked pair at " + $c1.posAsString() + ":[" + $f1.join(",") + "] and " + $c2.posAsString() + ":[" + $c2.free.join(",") + "]" ); + // Remove the value. + modify( $c3, function(){ this.blockValue( $v ); }); + } +} + +// If two cells within the same cell group contain candidate sets with more than +// two values, with two values being in both of them but in none of the other +// cells, then we have a "hidden pair". We can remove all other candidates from +// these two cells. +// +rule "hidden pair in row" { + when{ + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + // Establish a pair of Integer facts + $i1: Number; + $i2: Number $i2 > $i1; + + // Look for a Cell with these two among its candidates. (The upper bound on + // the number of candidates avoids a lot of useless work during startup.) + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellRow: $cellRow}; + + // Get another one from the same row, with the same pair among its candidates, + $c2: Cell $c2 != $c1 && $c2.cellRow == $cellRow && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + + // Assertain that no other cell in the group has one of these two values. + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellRow.cells) + } + then{ + console.log( "hidden pair in row at " + $c1.posAsString() + " and " + $c2.posAsString() ); + // Set the candidate lists of these two Cells to the "hidden pair". + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + +rule "hidden pair in column"{ + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i1: Number; + $i2: Number $i2 > $i1; + + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellCol: $cellCol}; + $c2: Cell $c2 != $c1 && $c2.cellCol == $cellCol && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellCol.cells) + } + then{ + console.log( "hidden pair in column at " + $c1.posAsString() + " and " + $c2.posAsString() ); + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + +rule "hidden pair in square" { + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i1: Number; + $i2: Number $i2 > $i1; + + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellSqr: $cellSqr}; + $c2: Cell $c2 != $c1 && $c2.cellSqr == $cellSqr && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellSqr.cells) + } + then{ + console.log( "hidden pair in square " + $c1.posAsString() + " and " + $c2.posAsString() ); + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + + +rule "X-wings in rows" { + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + $ca1: Cell $ca1.count > 1 && $i in $ca1.free {cellRow: $ra, rowNo: $rano, cellCol: $c1,colNo: $c1no}; + $cb1: Cell $cb1.count > 1 && $i in $cb1.free && $cb1.rowNo > $rano && $cb1.cellCol == $c1 {cellRow: $rb, rowNo: $rbno}; + not($nc2: Cell $nc2 != $ca1 && $nc2 != $cb1 && $i in $nc2.free from $c1.cells); + + $ca2: Cell $ca2.count > 1 && $1 in $ca2.free && $ca2.cellRow == $ra && $ca2.colNo > $c1no {cellCol: $c2, colNo: $c2no}; + $cb2: Cell $cb2.count > 1 && $i in $cb2.free && $cb2.cellRow == $rb && $cb2.cellCol == $c2; + not($nc3: Cell $nc3 != $ca2 && $nc3 != $cb2 && $i in $nc3.free from $c2.cells); + + $cx: Cell ($cx.rowNo == $rano || $cx.rowNo == $rbno) && $cx.colNo != $c1no && $cx.colNo != $c2no && $cx.count > 1 && $i in $cx.free; + } + then{ + + console.log( "X-wing with " + $i + " in rows " + + $ca1.posAsString() + " - " + $cb1.posAsString() + + $ca2.posAsString() + " - " + $cb2.posAsString() + ", remove from " + $cx.posAsString() ); + + modify( $cx, function(){ this.blockValue( $i ) }); + } +} + +rule "X-wings in columns"{ + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + + $ca1: Cell $ca1.count > 1 && $i in $ca1.free {cellRow: $ra, rowNo: $rano, cellCol: $c1,colNo: $c1no}; + + $ca2: Cell $ca2.count > 1 && $i in $ca2.free && $ca2.colNo > $c1No && $ca2.cellRow == $ra {cellCol: $c2, colNo: $c2no}; + not( $nc2: Cell $nc2 != $ca1 && $nc2 != $ca2 && $i in $nc2.free from $ra.cells); + + $cb1: Cell $cb1.count > 1 && $i in $cb1.free && $cb1.cellCol == $c1 && $cb1.rowNo > $rano {cellRow: $rb, rowNo: $rbno}; + $cb2: Cell $cb2.count > 1 && $i in $cb2.free && $cb2.cellCol == $c2 && $cb2.cellRow == $rb; + not($nc3: Cell $nc3 != $cb1 && $nc3 != $cb2 && $i in $nc3.free from $rb.cells); + + $cx: Cell ($cx.colNo == $c1no || $cx.colNo == $c2no) && $cx.rowNo != $rano && $cx.rowNo != $rbno && $cx.count > 1 && $i in $cx.free; + } + then{ + + console.log( "X-wing with " + $i + " in columns " + + $ca1.posAsString() + " - " + $ca2.posAsString() + + $cb1.posAsString() + " - " + $cb2.posAsString() + ", remove from " + $cx.posAsString() ); + + modify( $cx, function(){this.blockValue( $i ) }); + } +} + +rule "intersection removal column" { + when { + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + // occurs in a Cell + $c: Cell $i in $c.free {cellSqr: $cs, cellCol: $cc}; + // but not in another cell of the same square and a different column + not($nc2: Cell $nc2 != $c && $i in $nc2.free && $nc2.cellSqr == $cs && $nc2.cellCol != $cc ); + + // but there is a cell in the same column and another sqstuare containing this value + $cx: Cell $cx.count > 1 && $i in $cx.free && $cx.cellCol == $cc && $cx.cellSqr != $cs; + } + then{ + // remove the value from that other cell + //if (explain) { + console.log( "column elimination due to " + $c.posAsString() + + ": remove " + $i + " from " + $cx.posAsString() ); + //} + modify( $cx, function(){this.blockValue( $i ) }); + } +} + +rule "intersection removal row"{ + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + // occurs in a Cell + $c: Cell $i in $c.free {cellSqr: $cs, cellRow: $cr}; + // but not in another cell of the same square and a different row + not($nc2: Cell $nc2 != $c && $i in $nc2.free && $nc2.cellSqr == $cs && $nc2.cellRow != $cr); + + // but there is a cell in the same row and another square containing this value + $cx: Cell $cx.count > 1 && $i in $cx.free && $cx.cellRow == $cr && $cx.cellSqr != $cs; + } + then { + // remove the value from that other cell + //if (explain) { + console.log( "row elimination due to " + $c.posAsString() + + ": remove " + $i + " from " + $cx.posAsString() ); + //} + modify( $cx, function(){ this.blockValue( $i ) }); + } +} diff --git a/docs/examples/browser/src/sudoku.js b/docs/examples/browser/src/sudoku.js new file mode 100644 index 0000000..31da919 --- /dev/null +++ b/docs/examples/browser/src/sudoku.js @@ -0,0 +1,368 @@ +(function () { + /*global $:true*/ + var declare = this.declare, + arr = this.arrayExtended, + unique = arr.unique; + + var allNine = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + + var SetOfNine = declare({ + instance: { + + free: null, + count: 0, + + constructor: function () { + this.count = (this.free = allNine.slice()).length; + }, + + blockValue: function (value) { + var index = arr.indexOf(this.free, value); + if (index !== -1) { + this.free.splice(index, 1); + this.count = this.free.length; + } + return this; + }, + + blockExcept: function (values) { + this.free = values || []; + this.count = this.free.length; + return this; + }, + + freeValue: function () { + return this.free[0]; + } + } + }).as(this, "SetOfNine"); + + var CellGroup = SetOfNine.extend({ + instance: { + cells: null, + + constructor: function () { + this._super(arguments); + this.cells = []; + }, + + addCell: function (cell) { + this.cells.push(cell); + } + } + }).as(this, "CellGroup"); + + + var CellFile = CellGroup.extend({ + instance: { + number: null, + + constructor: function (number) { + this._super(arguments); + this.number = number; + }, + + toString: function () { + var ret = [], cells = this.cells; + for (var i = 0, l = cells.length; i < l; i++) { + ret.push(cells[i].toString()); + } + return ret.join(", "); + } + } + }).as(this, "CellFile"); + + var Cell = SetOfNine.extend({ + instance: { + value: null, + cellRow: null, + cellCol: null, + cellSqr: null, + exCells: null, + el: null, + + constructor: function () { + this._super(arguments); + this.exCells = []; + }, + + makeReferences: function (cr, col, sqr) { + this.cellRow = cr; + this.cellCol = col; + this.cellSqr = sqr; + this.colNo = col.number; + this.rowNo = cr.number; + this.exCells = unique(this.exCells.concat(cr.cells).concat(col.cells).concat(sqr.cells)); + this.exCells.splice(this.exCells.indexOf(this), 1); + return this; + }, + + toString: function () { + return [this.posAsString(), this.valueAsString()].join(": "); + }, + + valueAsString: function () { + return this.value === null ? " ": this.value; + }, + + posAsString: function () { + return ["[", this.cellRow.number, ",", this.cellCol.number, "]"].join(""); + } + } + }).as(this, "Cell"); + + var CellCol = CellFile.extend({ + instance: { + toString: function () { + return ["Column ", this.number, ": ", this._super(arguments)]; + } + } + }).as(this, "CellCol"); + + + var CellRow = CellFile.extend({ + instance: { + toString: function () { + return ["Row ", this.number, ": ", this._super(arguments)]; + } + } + }).as(this, "CellRow"); + + var CellSqr = CellGroup.extend({ + instance: { + constructor: function (cr1, cr2, cr3, cc1, cc2, cc3) { + this._super(arguments); + for (var i = cr1.number; i <= cr3.number; i++) { + this.addCell(cc1.cells[i]); + this.addCell(cc2.cells[i]); + this.addCell(cc3.cells[i]); + } + + } + } + }).as(this, "CellSqr"); + + var Counter = declare({ + instance: { + count: 0, + constructor: function (count) { + this.count = count; + } + } + }).as(this, "Counter"); + + + var Setting = declare({ + instance: { + rowNo: null, + colNo: null, + value: null, + + constructor: function (row, col, value) { + this.rowNo = row; + this.colNo = col; + this.value = value; + }, + + toString: function () { + return "Setting [" + this.rowNo + "," + this.colNo + "] : " + this.value; + } + + } + }).as(this, "Setting"); + + + var Stepping = declare({ + instance: { + emergency: false + } + }).as(this, "Stepping"); + + var Sudoku = declare({ + instance: { + + constructor: function (flow, statsListener) { + this.rows = []; + this.cols = []; + this.sqrs = []; + this.cells = []; + this.flow = flow; + this.statsListener = statsListener; + this.session = null; + this.stepping = null; + }, + + stop: function () { + if (this.session) { + this.session.halt(); + this.session.dispose(); + } + return this; + }, + + clear: function () { + this.stop(); + this.setCellValues([]); + }, + + step: function () { + this.session.modify(this.counter, function () { + this.count = 1; + }); + if (!this.stepping) { + this.session.assert(new Stepping()); + } + return this.session.matchUntilHalt(function (err) { + if (err) { + console.log(err); + } + }); + }, + + solve: function () { + this.session.modify(this.counter, function () { + this.count = Infinity; + }); + if (this.stepping) { + this.session.retract(this.stepping); + } + return this.session.match(function (err) { + if (err) { + console.log(err); + } + }); + }, + + setCellValue: function setCellValue(cell) { + cell.el.text(cell.value ? cell.value: ""); + return cell; + }, + + create: function () { + var grid; + (grid = $("#grid")).empty(); + var rows = this.rows, cols = this.cols, sqrs = this.sqrs, session = this.session; + for (var i = 0; i < 9; i++) { + session.assert(i + 1); + rows[i] = new CellRow(i); + cols[i] = new CellCol(i); + } + + var cells = this.cells = [], iCol; + for (var iRow = 0; iRow < 9; iRow++) { + var rowDom = $("
      ").addClass("row").appendTo(grid); + cells[iRow] = []; + for (iCol = 0; iCol < 9; iCol++) { + var cell = cells[iRow][iCol] = new Cell(); + cell.el = $("
      ").appendTo(rowDom); + rows[iRow].addCell(cell); + cols[iCol].addCell(cell); + } + } + + for (i = 0; i < 3; i++) { + sqrs[i] = []; + for (var j = 0; j < 3; j++) { + sqrs[i][j] = new CellSqr(rows[i * 3], rows[i * 3 + 1], rows[i * 3 + 2], + cols[j * 3], cols[j * 3 + 1], cols[j * 3 + 2]); + } + } + + for (iRow = 0; iRow < 9; iRow++) { + for (iCol = 0; iCol < 9; iCol++) { + session.assert(cells[iRow][iCol].makeReferences(rows[iRow], cols[iCol], sqrs[Math.floor(iRow / 3)][Math.floor(iCol / 3)])); + } + session.assert(rows[iRow]); + session.assert(cols[iRow]); + session.assert(sqrs[Math.floor(iRow / 3)][iRow % 3]); + } + return this; + }, + + setCellValues: function (cellValues) { + this.stop(); + var session = (this.session = this.statsListener.listen(this.flow.getSession())) + .on("set-value", this.setCellValue); + + var s000 = new Setting(0, 0, 0); + this.session.assert(s000); + this.create(); + + var initial = 0; + for (var iRow = 0; iRow < 9; iRow++) { + var row = cellValues[iRow] || []; + for (var iCol = 0; iCol < 9; iCol++) { + var value = row[iCol] || null; + if (value) { + session.assert(new Setting(iRow, iCol, value)); + initial++; + //console.log(initial); + } + } + } + var counter = this.counter = new Counter(initial); + this.session.assert(counter); + this.session.retract(s000); + return this.session.matchUntilHalt(function (err) { + if (err) { + console.log(err); + } + this.dumpGrid(); + }.bind(this)); + }, + + dumpGrid: function () { + var cells = this.cells; + var print = [" "]; + for (var iCol = 0; iCol < 9; iCol++) { + print.push("Col: " + iCol + " "); + } + console.log(print.join("")); + for (var iRow = 0; iRow < 9; iRow++) { + print = ["Row " + (iRow) + ": "]; + for (iCol = 0; iCol < 9; iCol++) { + if (cells[iRow][iCol].value !== null) { + print.push(" --- " + cells[iRow][iCol].value + " --- "); + } else { + var perms = cells[iRow][iCol].free, sb = []; + for (var i = 1; i <= 9; i++) { + if (perms.indexOf(i) !== -1) { + sb.push(i); + } else { + sb.push(' '); + } + } + print.push(" % " + sb.join("")); + } + } + console.log(print.join("")); + } + }, + + setInvalidCellValue: function setCellValue(cell) { + cell.el.addClass("error"); + return cell; + }, + + validate: function () { + this.session.assert("validate"); + return this.session.focus("validate") + .on("invalid", this.setInvalidCellValue) + .matchUntilHalt(); + } + + } + }); + + this.Sudoku = Sudoku; +}).call(this); + + + + + + + + + + diff --git a/docs/examples/browser/src/sudokuPatterns.js b/docs/examples/browser/src/sudokuPatterns.js new file mode 100644 index 0000000..c73a45c --- /dev/null +++ b/docs/examples/browser/src/sudokuPatterns.js @@ -0,0 +1,90 @@ +(function () { + + this.sudokuExamples = { + Simple: [ + [null, 5, 6, 8, null, 1, 9, 4, null], + [9, null, null, 6, null, 5, null, null, 3], + [7, null, null, 4, 9, 3, null, null, 8], + [8, 9, 7, null, 4, null, 6, 3, 5], + [null, null, 3, 9, null, 6, 8, null, null], + [4, 6, 5, null, 8, null, 2, 9, 1], + [5, null, null, 2, 6, 9, null, null, 7], + [6, null, null, 5, null, 4, null, null, 9], + [null, 4, 9, 7, null, 8, 3, 5, null] + ], + + Medium: [ + [8, 4, 7, null, null, null, 2, 5, 6], + [5, null, null, null, 8, null, null, null, 4], + [2, null, null, null, 7, null, null, null, 8], + [null, null, null, 3, null, 8, null, null, null], + [null, 5, 1, null, null, null, 8, 7, 2], + [null, null, null, 5, null, 7, null, null, null], + [4, null, null, null, 5, null, null, null, 7], + [6, null, null, null, 3, null, null, null, 9], + [1, 3, 2, null, null, null, 4, 8, 5] + ], + + "Hard 1": [ + [null, null, null, null, 5, 1, null, 8, null], + [null, 8, null, null, 4, null, null, null, 5], + [null, null, 3, null, null, null, 2, null, null], + [null, null, null, null, 6, null, null, null, 9], + [6, 7, null, 4, null, 9, null, 1, 3], + [8, null, null, null, 3, null, null, null, null], + [null, null, 2, null, null, null, 4, null, null], + [5, null, null, null, 9, null, null, 2, null], + [null, 9, null, 7, 1, null, null, null, null] + ], + + "Hard 2": [ + [null, null, null, 6, null, null, 1, null, null], + [null, null, null, null, null, 5, null, null, 6], + [5, null, 7, null, null, null, 2, 3, null], + [null, 8, null, 9, null, 7, null, null, null], + [9, 3, null, null, null, null, null, 6, 7], + [null, null, null, 4, null, 6, null, 1, null], + [null, 7, 4, null, null, null, 9, null, 1], + [8, null, null, 7, null, null, null, null, null], + [null, null, 3, null, null, 8, null, null, null] + ], + + "Hard 3": [ + [null, 8, null, null, null, 6, null, null, 5], + [2, null, null, null, null, null, 4, 8, null], + [null, null, 9, null, null, 8, null, 1, null], + [null, null, null, null, 8, null, 1, null, 2], + [null, null, null, 3, null, 1, null, null, null], + [6, null, 1, null, 9, null, null, null, null], + [null, 9, null, 4, null, null, 8, null, null], + [null, 7, 6, null, null, null, null, null, 3], + [1, null, null, 7, null, null, null, 5, null] + ], + + "Hard 4": [ + [null, null, null, null, null, 4, null, 9, 5], + [6, 7, null, 5, null, null, null, 1, null], + [null, null, null, 6, null, 9, null, null, null], + [null, 2, null, null, null, null, 4, null, null], + [8, 1, null, null, null, null, null, 7, 2], + [null, null, 7, null, null, null, null, 8, null], + [null, null, null, 3, null, 5, null, null, null], + [null, 6, null, null, null, 1, null, 5, 8], + [7, 3, null, 9, null, null, null, null, null] + ], + + "Broken": [ + [5, null, null, null, null, 4, null, 9, 5], + [6, 7, null, 5, null, null, null, 1, null], + [null, null, null, 6, null, 9, null, null, null], + [null, 2, null, null, null, null, 4, null, null], + [8, 1, null, null, null, null, null, 7, 2], + [null, null, 7, null, null, null, null, 8, null], + [8, null, null, 3, null, 5, null, null, null], + [null, 6, null, null, null, 1, null, 5, 8], + [7, 3, null, 9, null, null, null, null, null] + ] + + }; + +}).call(this); \ No newline at end of file diff --git a/docs/examples/browser/sudoku.html b/docs/examples/browser/sudoku.html new file mode 100644 index 0000000..81afdba --- /dev/null +++ b/docs/examples/browser/sudoku.html @@ -0,0 +1,146 @@ + + + + + + Sudoku + + + + + + +
      +
      +

      Sudoku

      + +
      + + + + + + +
      +
      +
      +
      + +
      +
      +
      + + + + + + + + + + + + + + + + + + + + diff --git a/docs/index.html b/docs/index.html index 1531906..6930902 100644 --- a/docs/index.html +++ b/docs/index.html @@ -191,7 +191,12 @@

      Usage

    • Flows -

      The examples and tests are a -great place to get started. You can ask your questions on the Nools Google group.

      +

      Resources

      +

      Defining a flow

      When using nools you define a flow which acts as a container for rules that can later be used to get @@ -375,13 +389,18 @@

      Working with a session

      Working with facts

      Facts are items that the rules should try to match.

      -

      To add facts to the session use assert method.

      +

      +

      Assert

      +

      To add facts to the session use assert method.

      session.assert(new Message("hello"));
       session.assert(new Message("hello world"));
       session.assert(new Message("goodbye"));

      As a convenience any object passed into getSession will also be asserted.

      +

      Note assert is typically used pre engine execution and during the execution of the rules.

      flow.getSession(new Message("hello"), new Message("hello world"), new Message("goodbye"));
      -

      To retract facts from the session use the retract method.

      +

      +

      Retract

      +

      To remove facts from the session use the retract method.

      var m = new Message("hello");
       
       //assert the fact into the engine
      @@ -389,7 +408,10 @@ 

      Working with facts

      //remove the fact from the engine session.retract(m);
      -

      To modify a fact use the modify method.

      +

      Note retract is typically used during the execution of the rules.

      +

      +

      Modify

      +

      To modify a fact use the modify method.

      Note modify will not work with immutable objects (i.e. strings).

      
       var m = new Message("hello");
      @@ -399,8 +421,7 @@ 

      Working with facts

      m.message = "hello goodbye"; session.modify(m);
      -

      assert is typically used pre engine execution and during the execution of the rules.

      -

      modify and retract are typically used during the execution of the rules.

      +

      Note modify is typically used during the execution of the rules.

      Firing the rules

      When you get a session from a flow no rules will be fired until the match method is called.

      @@ -771,6 +792,38 @@

      Salience

      this.rule("Hello1", {salience: 10}, [Message, "m", "m.name == 'Hello'"], function (facts) { }); +

      Or using the DSL

      +
      rule Hello4 {
      +    salience: 7;
      +    when {
      +        m: Message m.name == 'hello';
      +    }
      +    then {}
      +}
      +
      +rule Hello3 {
      +    salience: 8;
      +    when {
      +        m: Message m.name == 'hello';
      +    }
      +    then {}
      +}
      +
      +rule Hello2 {
      +    salience: 9;
      +    when {
      +        m: Message m.name == 'hello';
      +    }
      +    then {}
      +}
      +
      +rule Hello1 {
      +    salience: 10;
      +    when {
      +        m: Message m.name == 'hello';
      +    }
      +    then {}
      +}

      In the above flow we define four rules each with a different salience, when a single message is asserted they will fire in order of salience (highest to lowest).

      var fired = [];
       flow1
      @@ -916,6 +969,75 @@ 

      Constraints

    • Reference(optional) - An object where the keys are properties on the current object, and values are aliases to use. The alias may be used in succeeding patterns.

    • +

      +

      Not Constraint

      +

      The not constraint allow you to check that particular fact does not exist.

      +
      
      +[
      +    [Number, "n1"],
      +    ["not", Number, "n2", "n1 > n2"]
      +]
      +

      Or using the DSL.

      +
      
      +when {
      +    n1: Number;
      +    not(n2: Number n1 > n2);
      +}
      +

      The previous example will check that for all numbers in the workingMemory there is not one that is greater than n1.

      +

      +

      Or Constraint

      +

      The or constraint can be used to check for either one fact or another.

      +
      
      +[
      +    ["or",
      +        [String, "s", "s == 'hello'"],
      +        [String, "s", "s == 'world'"]
      +    ]
      +]
      +

      Using the DSL.

      +
      when {
      +    or(
      +        s : String s == 'hello',
      +        s : String s == 'world'
      +    );
      +}
      +

      The previous example will evaluate to true if you have a string in workingMemory that equals hello or `world.

      +

      +

      From Constraint

      +

      The from modifier allows for the checking of facts that are not necessarily in the workingMemory but instead exist as a property on a fact.

      +
      [
      +    [Person, "p"],
      +    [Address, "a", "a.zipcode == 88847", "from p.address"],
      +    [String, "first", "first == 'bob'", "from p.firstName"],
      +    [String, "last", "last == 'yukon'", "from p.lastName"]
      +]
      +

      Or using the DSL.

      +
      when {
      +    p: Person:
      +    a: Address a.zipcode == 88847 from p.address;
      +    first: String first == 'bob' from p.firstName;
      +    last: String last == 'yukon' from p.lastName;
      +}
      +

      The above example will used the address, firstName and lastName from the person fact.

      +

      You can also use the from modifier to check facts that create a graph.

      +

      For example assume the person object from above has friends that are also of type Person.

      +
      [
      +    [Person, "p"],
      +    [Person, "friend", "friend.firstName != p.firstName", "from p.friends"],
      +    [String, "first", "first =~ /^a/", "from friend.firstName"]
      +]
      +

      Or using the DSL.

      +
      when {
      +    p: Person;
      +    friend: Person friend.firstName != p.firstName;
      +    first: String first =~ /^a/ from friend.firstName;
      +}
      +

      The above example will pull the friend fact from the friends array property on fact p, and first from the friend's firstName.

      +

      You could achieve the same thing using the following code if you assert all friends into working memory.

      +
      when {
      +    p: Person;
      +    friend: Person friend in p.friends && friend.firstName != p.firstName && p.firstName =~ /^a/;
      +}

      Action

      The action is a function that should be fired when all patterns in the rule match. The action is called in the scope diff --git a/docs/nools.js b/docs/nools.js index 945c126..f0d5d62 100644 --- a/docs/nools.js +++ b/docs/nools.js @@ -1,10 +1,10 @@ -/*! nools - v0.1.14 - 2013-10-02 +/*! nools - v0.2.0 - 2013-10-14 * http://c2fo.github.com/nools * Copyright (c) 2013 Doug Martin (http://c2fo.com); Licensed */ -!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf&&j>f&&f++;);c=g[f]-h[f],c||(c=i-j)}return c||(c=a.recency-b.recency),c>0?1:-1},j=e({instance:{constructor:function(){this.memory={},this.memoryValues=new g},clear:function(){this.memoryValues.clear(),this.memory={},this.memory.length=this.memoryValues.length=0},get:function(a){var b=this.memory[a.id];return b?b.data:[]},remove:function(a){for(var b,c,e,f,g=a.match.facts,h=g.length,i=this.memoryValues,j=this.memory,k=-1;++k-1;)c=h[i],f.remove(c),e.remove(c),g.remove(c);h.length=0},retract:function(a,b){var c=this.rules[a.name],d=c.tree,e=c.factTable,f=this.getAgendaGroup(a.rule.agendaGroup);d.traverse(d.__root,k,function(a){b(a)&&(e.remove(a),f.remove(a),d.remove(a))})},insert:function(a,b){var c=this.rules[a.name],d=a.rule,e=d.agendaGroup;c.tree.insert(b),this.getAgendaGroup(e).insert(b),e&&d.autoFocus&&this.setFocus(e),c.factTable.insert(b)},dispose:function(){for(var a in this.agendaGroups)this.agendaGroups[a].clear();var b=this.rules;for(a in b)a in b&&(b[a].tree.clear(),b[a].factTable.clear());this.rules={}}}})},{"./extended":11,events:47}],4:[function(require,module,exports){"use strict";var extd=require("../extended"),forEach=extd.forEach,isString=extd.isString;exports.modifiers=["assert","modify","retract","emit","halt","focus"];var createFunction=function(body,defined,scope,scopeNames,definedNames){var declares=[];forEach(definedNames,function(a){-1!==body.indexOf(a)&&declares.push("var "+a+"= defined."+a+";")}),forEach(scopeNames,function(a){-1!==body.indexOf(a)&&declares.push("var "+a+"= scope."+a+";")}),body=["((function(){",declares.join(""),"\n return ",body,"\n})())"].join("");try{return eval(body)}catch(e){throw new Error("Invalid action : "+body+"\n"+e.message)}},createDefined=function(){var a=function(a){a=isString(a)?new Function("return "+a+";")():a;var b=a.hasOwnProperty("constructor")&&"function"==typeof a.constructor?a.constructor:function(b){b=b||{};for(var c in b)c in a&&(this[c]=b[c])},c=b.prototype;for(var d in a)c[d]=a[d];return b};return function(b){return a(b.properties)}}();exports.createFunction=createFunction,exports.createDefined=createDefined},{"../extended":11}],5:[function(a,b,c){var d=a("__browserify_Buffer").Buffer,e=a("../extended"),f=a("../parser"),g=a("../constraintMatcher.js"),h=e.indexOf,i=e.forEach,j=e.removeDuplicates,k=e.map,l=e.hash,m=l.keys,n=e.merge,o=a("../rule"),p=a("./common"),q=p.createDefined,r=p.createFunction,s=function(a,b,c,d){var f=[];i(b,function(b){-1!==a.indexOf(b)&&f.push("var "+b+"= facts."+b+";")}),e(c).keys().forEach(function(b){-1!==a.indexOf(b)&&f.push("var "+b+"= defined."+b+";")}),e(d).keys().forEach(function(b){-1!==a.indexOf(b)&&f.push("var "+b+"= scope."+b+";")});var g=["facts","flow"];/next\(.*\)/.test(a)&&g.push("next"),a="with(flow){"+f.join("")+a+"}";try{return new Function("defined, scope","return "+new Function(g.join(","),a).toString())(c,d)}catch(h){throw new Error("Invalid action : "+a+"\n"+h.message)}},t=function(){var a=function(a,b,c,d,j){var k=[],l=a[0],m=a[1],n=a[2],o=a[3];if(e.isHash(n)&&(o=n,n=null),!l||!(l=d[l]))throw new Error("Invalid class "+a[0]+" for rule "+j);if(k.push(l),k.push(m,n,o),c.push(k),b.push(m),n&&i(g.getIdentifiers(f.parseConstraint(n)),function(a){b.push(a)}),e.isObject(o))for(var p in o){var q=o[p];-1===h(b,q)&&b.push(q)}};return function(b,c,d){var f=b.name;if(e.isEmpty(b))throw new Error("Rule is empty");var g=b.options||{};g.scope=d;var h=b.constraints||[],k=h.length;k||(h=["true"]);var l=b.action;if(e.isUndefined(l))throw new Error("No action was defined for rule "+f);var m=[],n=[];return e(h).forEach(function(b){if(b.length){var d=b[0];if("not"===d){var e=[];b.shift(),a(b,n,e,c,f);var g=e[0];g.unshift(d),m.push(g)}else if("or"===d){var h=[d];b.shift(),i(b,function(b){a(b,n,h,c,f)}),m.push(h)}else a(b,n,m,c,f),n=j(n)}}),o.createRule(f,g,m,s(l,n,c,d))}}();c.parse=function(a,b){return f.parseRuleSet(a,b)},c.compile=function(a,b,c,f){e.isFunction(b)?(c=b,b={}):(b=b||{},c=null);var g=a.name||b.name;if(!g)throw new Error("Name must be present in JSON or options");var h=new f(g),j=n({Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},b.define||{});"undefined"!=typeof d&&(j.Buffer=d);var l=n({console:console},b.scope);i(a.define,function(a){j[a.name]=q(a)}),e(j).forEach(function(a,b){h.addDefined(b,a)});var o=e(a.scope).pluck("name").union(e(l).keys().value()).value(),p=k(m(j),function(a){return a});i(a.scope,function(a){l[a.name]=r(a.body,j,l,o,p)});var s=a.rules;return s.length&&i(s,function(a){h.__rules=h.__rules.concat(t(a,j,l))}),c&&c.call(h,h),h},c.transpile=a("./transpile").transpile},{"../constraintMatcher.js":8,"../extended":11,"../parser":31,"../rule":36,"./common":4,"./transpile":6,__browserify_Buffer:50}],6:[function(a,b,c){function d(a){a=l(a)?new Function("return "+a+";")():a;var b,c=["(function(){"];a.hasOwnProperty("constructor")&&"function"==typeof a.constructor?c.push("var Defined = "+a.constructor.toString()+";"):c.push("var Defined = function(opts){ for(var i in opts){if(opts.hasOwnProperty(i)){this[i] = opts[i];}}};"),c.push("var proto = Defined.prototype;");for(var d in a)a.hasOwnProperty(d)&&(b=a[d],c.push("proto."+d+" = "+(h.isFunction(b)?b.toString():h.format("%j",b))+";"));return c.push("return Defined;"),c.push("}())"),c.join("")}function e(a,b,c,d){var e=[];i(b,function(b){-1!==a.indexOf(b)&&e.push("var "+b+"= facts."+b+";")}),h(c).keys().forEach(function(b){-1!==a.indexOf(b)&&e.push("var "+b+"= defined."+b+";")}),h(d).keys().forEach(function(b){-1!==a.indexOf(b)&&e.push("var "+b+"= scope."+b+";")});var f=["facts","flow"];/next\(.*\)/.test(a)&&f.push("next"),a=e.join("")+a;try{return["function(",f.join(","),"){with(flow){",a,"}}"].join("")}catch(g){throw new Error("Invalid action : "+a+"\n"+g.message)}}function f(a,b){a=a.slice(0);var c=[];if("or"===a[0])return c.push('["'+a.shift()+'"'),c.push(h.map(a,function(a){return f(a,b)}).join(",")+"]"),c;if("not"===a[0]&&c.push('"',a.shift(),'", '),b.push(a[1]),c.push(a[0],', "'+a[1].replace(/"/g,'\\"')+'"'),a.splice(0,2),a.length){var d=a.shift();h.isString(d)?(c.push(',"'+d.replace(/"/g,'\\"'),'"'),i(m.getIdentifiers(n.parseConstraint(d)),function(a){b.push(a)})):(c.push(',"true"'),a.unshift(d))}if(a.length){var e=a.shift();h(e).values().forEach(function(a){-1===j(b,a)&&b.push(a)}),c.push(","+h.format("%j",[e]))}return"["+c.join("")+"]"}var g=a("__browserify_Buffer").Buffer,h=a("../extended"),i=h.forEach,j=h.indexOf,k=h.merge,l=h.isString,m=a("../constraintMatcher"),n=a("../parser");c.transpile=function(a,b){b=b||{};var c=[];c.push("(function(){"),c.push("return function(options){"),c.push("options = options || {};"),c.push("var bind = function(scope, fn){return function(){return fn.apply(scope, arguments);};}, defined = options.defined || {}, scope = options.scope || {};");var i=k({Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},b.define||{});"undefined"!=typeof g&&(i.Buffer=g);var j=k({console:console},b.scope);return c.push(["return nools.flow('",b.name,"', function(){"].join("")),c.push(h(a.define||[]).map(function(a){var b=a.name;return a[b]={},["var",b,"= defined."+b,"= this.addDefined('"+b+"',",d(a.properties)+");"].join(" ")}).value().join("\n")),c.push(h(a.scope||[]).map(function(a){var b=a.name;return j[b]={},["var",b,"= scope."+b,"= ",a.body,";"].join(" ")}).value().join("\n")),c.push("scope.console = console;\n"),c.push(h(a.rules||[]).map(function(a){var b=[],c=["this.rule('",a.name.replace(/'/g,"\\'"),"'"],d=h.merge(a.options||{},{scope:"scope"});return c.push(",",h.format("%j",[d]).replace(/(:"scope")/,":scope")),a.constraints&&!h.isEmpty(a.constraints)&&(c.push(", ["),c.push(h(a.constraints).map(function(a){return f(a,b)}).value().join(",")),c.push("]")),c.push(",",e(a.action,b,i,j)),c.push(");"),c.join("")}).value().join("")),c.push("});"),c.push("};"),c.push("}());"),c.join("")}},{"../constraintMatcher":8,"../extended":11,"../parser":31,__browserify_Buffer:50}],7:[function(a,b,c){"use strict";var d,e=a("./extended"),f=e.merge,g=e.instanceOf,h=e.filter,i=e.declare,j=i({instance:{constructor:function(b,c){d||(d=a("./constraintMatcher")),this.type=b,this.constraint=c},assert:function(){throw new Error("not implemented")},equal:function(a){return g(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return[this.get("alias")]}}}});j.extend({instance:{constructor:function(a){this._super(["object",a])},assert:function(a){return a instanceof this.constraint||a.constructor===this.constraint},equal:function(a){return g(a,this._static)&&this.constraint===a.constraint}}}).as(c,"ObjectConstraint"),j.extend({instance:{constructor:function(a,b){this._super(["equality",a]),b=b||{},this.pattern=b.pattern,this._matcher=d.getMatcher(a,b.scope||{})},assert:function(a){return this._matcher(a)}}}).as(c,"EqualityConstraint"),j.extend({instance:{constructor:function(){this._super(["equality",[!0]])},equal:function(a){return g(a,this._static)&&this.get("alias")===a.get("alias")},assert:function(){return!0}}}).as(c,"TrueConstraint"),j.extend({instance:{constructor:function(a,b){this.cache={},this._super(["reference",a]),b=b||{},this.values=[],this.pattern=b.pattern,this._options=b,this._matcher=d.getMatcher(a,b.scope||{})},assert:function(a){try{return this._matcher(a)}catch(b){throw new Error("Error with evaluating pattern "+this.pattern+" "+b.message)}},merge:function(a){var b=this;return a instanceof this._static&&(b=new this._static([this.constraint,a.constraint,"and"],f({},this._options,this._options)),b._alias=this._alias||a._alias,b.vars=this.vars.concat(a.vars)),b},equal:function(a){return g(a,this._static)&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return this.vars},alias:function(){return this._alias}},setters:{alias:function(a){this._alias=a,this.vars=h(d.getIdentifiers(this.constraint),function(b){return b!==a})}}}}).as(c,"ReferenceConstraint"),j.extend({instance:{constructor:function(a){this._super(["hash",a])},equal:function(a){return e.instanceOf(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"HashConstraint")},{"./constraintMatcher":8,"./extended":11}],8:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isArray,f=d.forEach,g=d.some,h=d.map,i=d.indexOf,j=d.isNumber,k=d.removeDuplicates,l=a("./constraint"),m={indexOf:d.indexOf,now:function(){return new Date},Date:function(a,b,c,d,e,f,g){var h=new Date;return j(a)&&h.setYear(a),j(b)&&h.setMonth(b),j(c)&&h.setDate(c),j(d)&&h.setHours(d),j(e)&&h.setMinutes(e),j(f)&&h.setSeconds(f),j(g)&&h.setMilliseconds(g),h},lengthOf:function(a,b){return a.length===b},isTrue:function(a){return a===!0},isFalse:function(a){return a===!1},isNotNull:function(a){return null!==a},dateCmp:function(a,b){return d.compare(a,b)}};f(["years","days","months","hours","minutes","seconds"],function(a){m[a+"FromNow"]=d[a+"FromNow"],m[a+"Ago"]=d[a+"Ago"]}),f(["isArray","isNumber","isHash","isObject","isDate","isBoolean","isString","isRegExp","isNull","isEmpty","isUndefined","isDefined","isUndefinedOrNull","isPromiseLike","isFunction","deepEqual"],function(a){var b=d[a];m[a]=function(){return b.apply(d,arguments)}});var n={equal:function(a,b){var c=!1;return a===b?c=!0:a[2]===b[2]&&(c=-1!==i(["string","number","boolean","regexp","identifier","null"],a[2])?a[0]===b[0]:"unary"===a[2]||"logicalNot"===a[2]?this.equal(a[0],b[0]):this.equal(a[0],b[0])&&this.equal(a[1],b[1])),c},getIdentifiers:function(a){var b=[],c=a[2];if("identifier"===c)return[a[0]];if("function"===c)b=b.concat(this.getIdentifiers(a[0])).concat(this.getIdentifiers(a[1]));else if("string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c)if("prop"===c){if(b=b.concat(this.getIdentifiers(a[0])),a[1])for(var d=a[1];e(d);){if("function"===d[2]){b=b.concat(this.getIdentifiers(d[1]));break}d=d[1]}}else a[0]&&(b=b.concat(this.getIdentifiers(a[0]))),a[1]&&(b=b.concat(this.getIdentifiers(a[1])));return k(b)},toConstraints:function(a,b){var c=[],d=b.alias,e=b.scope||{},f=a[2];return"and"===f?c=c.concat(this.toConstraints(a[0],b)).concat(this.toConstraints(a[1],b)):("composite"===f||"or"===f||"lt"===f||"gt"===f||"lte"===f||"gte"===f||"like"===f||"notLike"===f||"eq"===f||"neq"===f||"in"===f||"notIn"===f||"prop"===f||"propLookup"===f||"function"===f||"logicalNot"===f)&&(g(this.getIdentifiers(a),function(a){return!(a===d||a in m||a in e)})?c.push(new l.ReferenceConstraint(a,b)):c.push(new l.EqualityConstraint(a,b))),c},parse:function(a){return this[a[2]](a[0],a[1])},composite:function(a){return this.parse(a)},and:function(a,b){return["(",this.parse(a),"&&",this.parse(b),")"].join(" ")},or:function(a,b){return["(",this.parse(a),"||",this.parse(b),")"].join(" ")},prop:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"['",this.parse(b),"']"].join("")},propLookup:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"[",this.parse(b),"]"].join("")},unary:function(a){return-1*this.parse(a)},plus:function(a,b){return[this.parse(a),"+",this.parse(b)].join(" ")},minus:function(a,b){return[this.parse(a),"-",this.parse(b)].join(" ")},mult:function(a,b){return[this.parse(a),"*",this.parse(b)].join(" ")},div:function(a,b){return[this.parse(a),"/",this.parse(b)].join(" ")},mod:function(a,b){return[this.parse(a),"%",this.parse(b)].join(" ")},lt:function(a,b){return[this.parse(a),"<",this.parse(b)].join(" ")},gt:function(a,b){return[this.parse(a),">",this.parse(b)].join(" ")},lte:function(a,b){return[this.parse(a),"<=",this.parse(b)].join(" ")},gte:function(a,b){return[this.parse(a),">=",this.parse(b)].join(" ")},like:function(a,b){return[this.parse(b),".test(",this.parse(a),")"].join("")},notLike:function(a,b){return["!",this.parse(b),".test(",this.parse(a),")"].join("")},eq:function(a,b){return[this.parse(a),"===",this.parse(b)].join(" ")},neq:function(a,b){return[this.parse(a),"!==",this.parse(b)].join(" ")},"in":function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) != -1"].join("")},notIn:function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) == -1"].join("")},arguments:function(a,b){var c=[];return a&&c.push(this.parse(a)),b&&c.push(this.parse(b)),c.join(",")},array:function(a){var b=[];return a?(b=this.parse(a),e(b)?b:["[",b,"]"].join("")):["[",b.join(","),"]"].join("")},"function":function(a,b){var c=this.parse(b);return[this.parse(a),"(",c,")"].join("")},string:function(a){return"'"+a+"'"},number:function(a){return a},"boolean":function(a){return a},regexp:function(a){return a},identifier:function(a){return a},"null":function(){return"null"},logicalNot:function(a){return["!(",this.parse(a),")"].join("")}},o=c.toJs=function(a,b){var c=n.parse(a);b=b||{};var d=n.getIdentifiers(a),e="var indexOf = definedFuncs.indexOf;"+h(d,function(a){var c=["var ",a," = "];return m.hasOwnProperty(a)?c.push("definedFuncs['",a,"']"):b.hasOwnProperty(a)?c.push("scope['",a,"']"):c.push("'",a,"' in fact ? fact['",a,"'] : hash['",a,"']"),c.push(";"),c.join("")}).join("")+" return !!("+c+");",f=new Function("fact, hash, definedFuncs, scope",e);return function(a,c){return f(a,c,m,b)}};c.getMatcher=function(a,b){return o(a,b)},c.toConstraints=function(a,b){return n.toConstraints(a,b)},c.equal=function(a,b){return n.equal(a,b)},c.getIdentifiers=function(a){return n.getIdentifiers(a)}},{"./constraint":7,"./extended":11}],9:[function(a,b){"use strict";var c=a("./extended"),d=c.declare,e=c.merge,f=c.union,g=Array.prototype.slice,h=d({instance:{constructor:function(a){this.isMatch=!0,a instanceof this._static?(this.isMatch=a.isMatch,this.facts=g.call(a.facts),this.factIds=g.call(a.factIds),this.hashCode=this.factIds.join(":"),this.factHash=e({},a.factHash),this.recency=g.call(a.recency)):a?(this.facts=[a],this.factIds=[a.id],this.recency=[a.recency],this.hashCode=a.id+"",this.factHash=a.factHash||{}):(this.facts=[],this.factIds=[],this.factHash={},this.hashCode="")},merge:function(a){var b=new this._static;return b.isMatch=a.isMatch,b.facts=this.facts.concat(a.facts),b.factIds=this.factIds.concat(a.factIds),b.hashCode=b.factIds.join(":"),b.factHash=e({},this.factHash,a.factHash),b.recency=f(this.recency,a.recency),b}}}),i=d({instance:{match:null,factHash:null,fact:null,hashCode:null,paths:null,constructor:function(a,b,c){this.fact=a,this.paths=b||null;var d=this.match=c||new h(a);this.factHash=d.factHash,this.hashCode=d.hashCode,this.factIds=d.factIds},set:function(a,b){return this.factHash[a]=b,this},isMatch:function(a){return this.match.isMatch=a,this},clone:function(a,b,c){return new i(a||this.fact,b||this.path,c||this.match)}}}).as(b)},{"./extended":11}],10:[function(a,b){var c=a("./extended"),d=c.Promise,e=a("./nextTick"),f=c.isPromiseLike;d.extend({instance:{looping:!1,constructor:function(a,b){this._super([]),this.flow=a,this.agenda=a.agenda,this.rootNode=a.rootNode,this.matchUntilHalt=!!b,c.bindAll(this,["onAlter","callNext"])},halt:function(){this.__halted=!0,this.looping||this.callback()},onAlter:function(){this.flowAltered=!0,this.looping||!this.matchUntilHalt||this.__halted||this.callNext()},setup:function(){var a=this.flow;this.rootNode.resetCounter(),a.on("assert",this.onAlter),a.on("modify",this.onAlter),a.on("retract",this.onAlter)},tearDown:function(){var a=this.flow;a.removeListener("assert",this.onAlter),a.removeListener("modify",this.onAlter),a.removeListener("retract",this.onAlter)},__handleAsyncNext:function(a){var b=this,c=b.agenda;return a.addCallback(function(){b.looping=!1,c.isEmpty()?(!b.matchUntilHalt||b.__halted)&&b.callback():(b.flowAltered&&(b.rootNode.incrementCounter(),b.flowAltered=!1),b.__halted?b.callback():b.callNext()),b=null}).addErrback(this.errback)},__handleSyncNext:function(a){return this.looping=!1,this.agenda.isEmpty()||this.flowAltered&&(this.rootNode.incrementCounter(),this.flowAltered=!1),a&&!this.__halted?e(this.callNext):(!this.matchUntilHalt||this.__halted)&&this.callback(),a},callback:function(){this.tearDown(),this._super(arguments)},callNext:function(){this.looping=!0;var a=this.agenda.fireNext();return f(a)?this.__handleAsyncNext(a):this.__handleSyncNext(a)},execute:function(){return this.setup(),this.callNext(),this}}}).as(b)},{"./extended":11,"./nextTick":16}],11:[function(a,b){b.exports=a("extended")().register(a("array-extended")).register(a("date-extended")).register(a("object-extended")).register(a("string-extended")).register(a("promise-extended")).register(a("function-extended")).register(a("is-extended")).register("HashTable",a("ht")).register("declare",a("declare.js")).register(a("leafy")).register("LinkedList",a("./linkedList"))},{"./linkedList":15,"array-extended":39,"date-extended":40,"declare.js":42,extended:43,"function-extended":46,ht:52,"is-extended":53,leafy:54,"object-extended":55,"promise-extended":56,"string-extended":57}],12:[function(a,b){"use strict";var c=a("./extended"),d=c.bind,e=c.declare,f=a("./nodes"),g=a("events").EventEmitter,h=a("./workingMemory"),i=h.WorkingMemory,j=a("./executionStrategy"),k=a("./agenda");b.exports=e(g,{instance:{name:null,executionStrategy:null,constructor:function(a){this.env=null,this.name=a,this.__rules={},this.workingMemory=new i,this.agenda=new k(this),this.agenda.on("fire",d(this,"emit","fire")),this.agenda.on("focused",d(this,"emit","focused")),this.rootNode=new f.RootNode(this.workingMemory,this.agenda)},focus:function(a){return this.agenda.setFocus(a),this},halt:function(){var a=this.executionStrategy;return a.matchUntilHalt&&a.halt(),this},dispose:function(){this.workingMemory.dispose(),this.agenda.dispose(),this.rootNode.dispose()},assert:function(a){return this.rootNode.assertFact(this.workingMemory.assertFact(a)),this.emit("assert",a),a},retract:function(a){return this.rootNode.retractFact(this.workingMemory.retractFact(a)),this.emit("retract",a),a},modify:function(a,b){return this.rootNode.retractFact(this.workingMemory.retractFact(a)),"function"==typeof b&&b.call(a,a),this.emit("modify",a),this.rootNode.assertFact(this.workingMemory.assertFact(a)),a},print:function(){this.rootNode.print()},containsRule:function(a){return this.rootNode.containsRule(a)},rule:function(a){this.rootNode.assertRule(a)},matchUntilHalt:function(a){return(this.executionStrategy=new j(this,!0)).execute().classic(a).promise()},match:function(a){return(this.executionStrategy=new j(this)).execute().classic(a).promise()}}})},{"./agenda":3,"./executionStrategy":10,"./extended":11,"./nodes":20,"./workingMemory":37,events:47}],13:[function(a,b){"use strict";var c=a("./extended"),d=c.instanceOf,e=c.forEach,f=c.declare,g=a("./pattern").InitialFact,h=a("./rule"),i=a("./flow"),j={},k=f({instance:{constructor:function(a,b){if(this.name=a,this.cb=b,this.__rules=[],this.__defined={},b&&b.call(this,this),j.hasOwnProperty(a))throw new Error("Flow with "+a+" already defined");j[a]=this},getDefined:function(a){var b=this.__defined[a.toLowerCase()];if(!b)throw new Error(a+" flow class is not defined");return b},addDefined:function(a,b){return this.__defined[a.toLowerCase()]=b,b},rule:function(){return this.__rules=this.__rules.concat(h.createRule.apply(h,arguments)),this},getSession:function(){var a=new i(this.name);e(this.__rules,function(b){a.rule(b)}),a.assert(new g);for(var b=0,c=arguments.length;c>b;b++)a.assert(arguments[b]);return a},containsRule:function(a){return c.some(this.__rules,function(b){return b.name===a})}},"static":{getFlow:function(a){return j[a]},hasFlow:function(a){return c.has(j,a)},deleteFlow:function(a){return d(a,k)&&(a=a.name),delete j[a],k},deleteFlows:function(){for(var a in j)a in j&&delete j[a];return k},create:function(a,b){return new k(a,b)}}}).as(b)},{"./extended":11,"./flow":12,"./pattern":35,"./rule":36}],14:[function(a,b,c){"use strict";function d(a){return/\.nools$/.test(a)}function e(a){var b;return b=d(a)?i.parse(g.readFileSync(a,"utf8"),a):i.parse(a)}var f=a("./extended"),g=a("fs"),h=a("path"),i=a("./compile"),j=a("./flowContainer");c.Flow=j,c.getFlow=j.getFlow,c.hasFlow=j.hasFlow,c.deleteFlow=function(a){return j.deleteFlow(a),this},c.deleteFlows=function(){return j.deleteFlows(),this},c.flow=j.create,c.compile=function(a,b,c){if(f.isFunction(b)?(c=b,b={}):(b=b||{},c=null),f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),!b.name)throw new Error("Name required when compiling nools source");return i.compile(a,b,c,j)},c.transpile=function(a,b){return b=b||{},f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),i.transpile(a,b)},c.parse=e},{"./compile":5,"./extended":11,"./flowContainer":13,fs:48,path:49}],15:[function(a,b){var c=a("declare.js");c({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null},push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,d},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,a.data=a.prev=a.next=null,this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},clear:function(){this.head=this.tail=null,this.length=0}}}).as(b)},{"declare.js":42}],16:[function(a,b){var c,d=a("__browserify_process"),e=a("./extended");if("function"==typeof setImmediate)c="undefined"!=typeof window?e.bind(window,setImmediate):setImmediate;else if("undefined"!=typeof d)c=d.nextTick;else if("undefined"!=typeof MessageChannel){var f=new MessageChannel,g={},h=g;f.port1.onmessage=function(){g=g.next;var a=g.task;delete g.task,a()},c=function(a){h=h.next={task:a},f.port2.postMessage(0)}}else c=function(a){setTimeout(a,0)};b.exports=c},{"./extended":11,__browserify_process:51}],17:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias")},toString:function(){return"AliasNode"+this.__count},assert:function(a){return this.__propagate("assert",a.set(this.alias,a.fact.object))},retract:function(a){this.propagateRetract(a.fact)},equal:function(a){return a instanceof this._static&&this.alias===a.alias}}}).as(b)},{"./alphaNode":18}],18:[function(a,b){"use strict";var c=a("./node");c.extend({instance:{constructor:function(a){this._super([]),this.constraint=a},toString:function(){return"AlphaNode "+this.__count},equal:function(a){return this.constraint.equal(a.constraint)}}}).as(b)},{"./node":24}],19:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments)},assert:function(a){this.constraint.assert(a.factHash)&&this.__propagate("assert",a)},toString:function(){return"EqualityNode"+this.__count}}}).as(b)},{"./alphaNode":18}],20:[function(a,b,c){"use strict";var d=a("../extended"),e=d.forEach,f=d.some,g=d.declare,h=a("../pattern.js"),i=h.ObjectPattern,j=h.NotPattern,k=h.CompositePattern,l=h.InitialFactPattern,m=a("../constraint"),n=m.HashConstraint,o=m.ReferenceConstraint,p=a("./aliasNode"),q=a("./equalityNode"),r=a("./joinNode"),s=a("./notNode"),t=a("./leftAdapterNode"),u=a("./rightAdapterNode"),v=a("./typeNode"),w=a("./terminalNode"),x=a("./propertyNode");g({instance:{constructor:function(a,b){this.terminalNodes=[],this.joinNodes=[],this.nodes=[],this.constraints=[],this.typeNodes=[],this.__ruleCount=0,this.bucket={counter:0,recency:0},this.agendaTree=b},assertRule:function(a){var b=new w(this.bucket,this.__ruleCount++,a,this.agendaTree);this.__addToNetwork(a,a.pattern,b),this.__mergeJoinNodes(),this.terminalNodes.push(b)},resetCounter:function(){this.bucket.counter=0},incrementCounter:function(){this.bucket.counter++},assertFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].assert(a)},retractFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].retract(a)},containsRule:function(a){return f(this.terminalNodes,function(b){return b.rule.name===a})},dispose:function(){for(var a=this.typeNodes,b=a.length-1;b>=0;b--)a[b].dispose()},__mergeJoinNodes:function(){for(var a=this.joinNodes,b=0;b=0;c--){var d=b[c];if(a.equal(d))return d}return b.push(a),a},__createTypeNode:function(a,b){for(var c=new v(b.get("constraints")[0]),d=this.typeNodes,e=d.length-1;e>=0;e--){var f=d[e];if(c.equal(f))return f}return d.push(c),c},__createEqualityNode:function(a,b){return this.__checkEqual(new q(b)).addRule(a)},__createPropertyNode:function(a,b){return this.__checkEqual(new x(b)).addRule(a)},__createAliasNode:function(a,b){return this.__checkEqual(new p(b)).addRule(a)},__createAdapterNode:function(a,b){return("left"===b?new t:new u).addRule(a)},__createJoinNode:function(a,b,c,d){var e;b.rightPattern instanceof j?e=new s:(e=new r,this.joinNodes.push(e));var f=e;if(c instanceof r){var g=this.__createAdapterNode(a,d);f.addOutNode(g,b),f=g}return f.addOutNode(c,b),e.addRule(a)},__addToNetwork:function(a,b,c,d){if(b instanceof i){if(b instanceof j&&(!d||"left"===d))return this.__createBetaNode(a,new k(new l,b),c,d);this.__createAlphaNode(a,b,c,d)}else b instanceof k&&this.__createBetaNode(a,b,c,d)},__createBetaNode:function(a,b,c,d){var e=this.__createJoinNode(a,b,c,d);return this.__addToNetwork(a,b.rightPattern,e,"right"),this.__addToNetwork(a,b.leftPattern,e,"left"),c.addParentNode(e),e},__createAlphaNode:function(a,b,c,d){var e=b.get("constraints"),f=this.__createTypeNode(a,b),g=this.__createAliasNode(a,b);f.addOutNode(g,b),g.addParentNode(f);for(var h=g,i=e.length-1;i>0;i--){var j,k=e[i];if(k instanceof n)j=this.__createPropertyNode(a,k);else{if(k instanceof o){c.constraint.addConstraint(k);continue}j=this.__createEqualityNode(a,k)}h.addOutNode(j,b),j.addParentNode(h),h=j}if(c instanceof r){var l=this.__createAdapterNode(a,d);l.addParentNode(h),h.addOutNode(l,b),h=l}return c.addParentNode(h),h.addOutNode(c,b),f},print:function(){e(this.terminalNodes,function(a){a.print(" ")})}}}).as(c,"RootNode")},{"../constraint":7,"../extended":11,"../pattern.js":35,"./aliasNode":17,"./equalityNode":19,"./joinNode":21,"./leftAdapterNode":23,"./notNode":25,"./propertyNode":26,"./rightAdapterNode":27,"./terminalNode":28,"./typeNode":29}],21:[function(a,b){var c=a("../extended"),d=c.hash.values,e=c.indexOf,f=a("./node"),g=a("./joinReferenceNode");f.extend({instance:{constructor:function(){this._super([]),this.constraint=new g,this.leftMemory={},this.rightMemory={},this.leftTuples=[],this.rightTuples=[]},dispose:function(){this.leftMemory={},this.rightMemory={}},disposeLeft:function(a){this.leftMemory={},this.propagateDispose(a)},disposeRight:function(a){this.rightMemory={},this.propagateDispose(a)},hashCode:function(){return"JoinNode "+this.__count},toString:function(){return"JoinNode "+this.__count -},retractResolve:function(a){for(var b=d(this.leftMemory),c=b.length,f=this.leftTuples;--c>-1;)for(var g,h=b[c],i=h.length;--i>-1;)if(g=h[i],this.resolve(g.match,a)){f.splice(e(f,g),1),h.splice(i,1);break}this._propagateRetractResolve(a)},retractLeft:function(a){var b,c,d=this.leftMemory[a.id],f=this.leftTuples;if(d){for(b=-1,c=d.length;++be;e++)this.addOutNode(d,c[e]);a.nodes.remove(d)},this);for(var b=a.parentNodes,c=0,d=a.parentNodes.l;d>c;c++){var e=b[c];this.addParentNode(e),e.nodes.remove(a)}return this},resolve:function(a,b){return a.hashCode===b.hashCode},print:function(a){console.log(a+this.toString()),d(this.parentNodes,function(b){b.print(" "+a)})},addOutNode:function(a,b){this.nodes.contains(a)||this.nodes.put(a,[]),this.nodes.get(a).push(b),this.__entrySet=this.nodes.entrySet()},addParentNode:function(a){-1===e(this.parentNodes,a)&&this.parentNodes.push(a)},shareable:function(){return!1},__propagate:function(a,b,c){c=c||this.nodes;for(var d,e,g,h,j=this.__entrySet,k=j.length;--k>-1;)d=j[k],e=d.key,g=d.value,b.paths?(h=f(g,b.paths)).length&&e[a](new i(b.fact,h,b.match)):e[a](b)},dispose:function(a){this.propagateDispose(a)},retract:function(a){this.propagateRetract(a)},propagateDispose:function(a,b){b=b||this.nodes;for(var c=this.__entrySet,d=c.length-1;d>=0;d--){var e=c[d],f=e.key;f.dispose(a)}},propagateAssert:function(a,b){this.__propagate("assert",a,b||this.nodes)},propagateRetract:function(a,b){this.__propagate("retract",a,b||this.nodes)},assert:function(a){this.propagateAssert(a)},propagateModify:function(a,b){this.__propagate("modify",a,b||this.nodes)}}}).as(b)},{"../context":9,"../extended":11}],25:[function(a,b){var c=a("./joinNode"),d=a("../context"),e=a("../extended"),f=e.indexOf;c.extend({instance:{constructor:function(){this._super(arguments),this.leftTupleMemory={},this.allTuples={}},toString:function(){return"NotNode "+this.__count},retractRight:function(a){var b=this.rightMemory,c=b[a.id],e=this.constraint;if(delete b[a.id],c){var g=f(this.rightTuples,c);this.rightTuples.splice(g,1);for(var h,i,j,k=c.blocking,l=this.rightTuples,m=l.length;h=k.pop();){for(h.blocker=null,e.setLeftContext(h),j=g;m>j;j++)if(i=l[j],e.setRightContext(i),e.isMatch()){h.blocker=i,i.blocking.push(h),this.__addToLeftTupleMemory(h);break}h.blocker||(this.__removeFromLeftTupleMemory(h),this.__addToLeftMemory(h).propagateAssert(new d(h.fact,null,h.match)))}e.clearContexts()}},retractLeft:function(a){for(var b,c,d,e=a.id,g=this.allTuples[a.id]||[];g.length;)b=g.pop(),-1!==f(b.factIds,e)&&(this.__removeFromAllTupleMemory(b),this.__removeFromLeftMemory(b),this.__removeFromLeftTupleMemory(b),(d=b.blocker)&&(c=d.blocking,c.splice(f(c,b),1),b.blocker=null));delete this.leftMemory[e],delete this.leftTupleMemory[e],this.propagateRetract(a)},assertLeft:function(a){var b,c=this.rightTuples,e=this.constraint,f=-1,g=c.length;if(0!==g)for(e.setLeftContext(a);++f-1;)b=c[d],e.setLeftContext(b).isMatch()&&(this._propagateRetractResolve(b.match),this.__removeFromLeftMemory(b),b.blocker=a,a.blocking.push(b),this.__addToLeftTupleMemory(b));e.clearContexts()},__removeFromLeftMemory:function(a){for(var b,c=this.leftMemory[a.fact.id]||[],d=this.leftTuples,e=0,g=d.length;g>e;e++)if(b=d[e],b===a){d.splice(e,1),c.splice(f(c,b),1);break}return this},__removeFromLeftTupleMemory:function(a){for(var b,c=this.leftTupleMemory[a.fact.id]||[],d=0,e=c.length;e>d;d++)if(b=c[d],b===a){c.splice(d,1);break}return this},__addToAllTupleMemory:function(a){for(var b,c,d=a.factIds,e=-1,g=d.length,h=this.allTuples;++eg;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("assert",c)},toString:function(){return"PropertyNode"+this.__count}}}).as(b)},{"../context":9,"../extended":11,"./alphaNode":18}],27:[function(a,b){var c=a("./node");c.extend({instance:{retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},propagateAssert:function(a){this.__propagate("assertRight",a)},propagateRetract:function(a){this.__propagate("retractRight",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},modify:function(a){this.__propagate("modifyRight",a)},toString:function(){return"RightAdapterNode "+this.__count}}}).as(b)},{"./node":24}],28:[function(a,b){var c=a("./node"),d=a("../extended"),e=d.bind,f=d.removeDuplicates;c.extend({instance:{constructor:function(a,b,c,d){this._super([]),this.resolve=e(this,this.resolve),this.rule=c,this.index=b,this.name=this.rule.name,this.agenda=d,this.bucket=a,d.register(this)},__assertModify:function(a){var b=a.match;if(b.recency.sort(function(a,b){return a-b}).reverse(),b.facts=f(b.facts),b.isMatch){var c=this.rule,d=this.bucket;this.agenda.insert(this,{rule:c,index:this.index,name:c.name,recency:d.recency++,match:b,counter:d.counter})}},assert:function(a){this.__assertModify(a)},modify:function(a){this.__assertModify(a)},retract:function(a){this.agenda.removeByFact(this,a)},retractRight:function(a){this.agenda.removeByFact(this,a)},retractLeft:function(a){this.agenda.removeByFact(this,a)},assertLeft:function(a){this.__assertModify(a)},assertRight:function(a){this.__assertModify(a)},retractResolve:function(a){var b=this.resolve;this.agenda.retract(this,function(c){return b(c.match,a)})},toString:function(){return"TerminalNode "+this.rule.name}}}).as(b)},{"../extended":11,"./node":24}],29:[function(a,b){var c=a("./alphaNode"),d=a("../context");c.extend({instance:{assert:function(a){this.constraint.assert(a.object)&&this.__propagate("assert",a)},retract:function(a){this.constraint.assert(a.object)&&this.propagateRetract(a)},toString:function(){return"TypeNode"+this.__count},dispose:function(){for(var a=this.__entrySet,b=a.length-1;b>=0;b--){var c=a[b],d=c.key,e=c.value;d.dispose({paths:e})}},__propagate:function(a,b){for(var c=this.__entrySet,e=c.length-1;e>=0;e--){var f=c[e],g=f.key,h=f.value;g[a](new d(b,h))}}}}).as(b)},{"../context":9,"./alphaNode":18}],30:[function(a,b,c){var d=a("__browserify_process"),e=function(){function a(){this.yy={}}var b={trace:function(){},yy:{},symbols_:{error:2,expressions:3,EXPRESSION:4,EOF:5,UNARY_EXPRESSION:6,LITERAL_EXPRESSION:7,"-":8,"!":9,MULTIPLICATIVE_EXPRESSION:10,"*":11,"/":12,"%":13,ADDITIVE_EXPRESSION:14,"+":15,EXPONENT_EXPRESSION:16,"^":17,RELATIONAL_EXPRESSION:18,"<":19,">":20,"<=":21,">=":22,EQUALITY_EXPRESSION:23,"==":24,"!=":25,"=~":26,"!=~":27,IN_EXPRESSION:28,"in":29,ARRAY_EXPRESSION:30,notIn:31,OBJECT_EXPRESSION:32,AND_EXPRESSION:33,"&&":34,OR_EXPRESSION:35,"||":36,ARGUMENT_LIST:37,",":38,IDENTIFIER_EXPRESSION:39,IDENTIFIER:40,".":41,"[":42,STRING_EXPRESSION:43,"]":44,"(":45,")":46,STRING:47,NUMBER_EXPRESSION:48,NUMBER:49,REGEXP_EXPRESSION:50,REGEXP:51,BOOLEAN_EXPRESSION:52,BOOLEAN:53,NULL_EXPRESSION:54,NULL:55,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",45:"(",46:")",47:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"},productions_:[0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,3],[32,4],[43,1],[48,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 3:this.$=[f[g],null,"unary"];break;case 4:this.$=[f[g],null,"logicalNot"];break;case 6:this.$=[f[g-2],f[g],"mult"];break;case 7:this.$=[f[g-2],f[g],"div"];break;case 8:this.$=[f[g-2],f[g],"mod"];break;case 10:this.$=[f[g-2],f[g],"plus"];break;case 11:this.$=[f[g-2],f[g],"minus"];break;case 13:this.$=[f[g-2],f[g],"pow"];break;case 15:this.$=[f[g-2],f[g],"lt"];break;case 16:this.$=[f[g-2],f[g],"gt"];break;case 17:this.$=[f[g-2],f[g],"lte"];break;case 18:this.$=[f[g-2],f[g],"gte"];break;case 20:this.$=[f[g-2],f[g],"eq"];break;case 21:this.$=[f[g-2],f[g],"neq"];break;case 22:this.$=[f[g-2],f[g],"like"];break;case 23:this.$=[f[g-2],f[g],"notLike"];break;case 25:this.$=[f[g-2],f[g],"in"];break;case 26:this.$=[f[g-2],f[g],"notIn"];break;case 27:this.$=[f[g-2],f[g],"in"];break;case 28:this.$=[f[g-2],f[g],"notIn"];break;case 30:this.$=[f[g-2],f[g],"and"];break;case 32:this.$=[f[g-2],f[g],"or"];break;case 34:this.$=[f[g-2],f[g],"arguments"];break;case 35:this.$=[String(a),null,"identifier"];break;case 37:this.$=[f[g-2],f[g],"prop"];break;case 38:this.$=[f[g-3],f[g-1],"propLookup"];break;case 39:this.$=[f[g-3],f[g-1],"propLookup"];break;case 40:this.$=[f[g-2],[null,null,"arguments"],"function"];break;case 41:this.$=[f[g-3],f[g-1],"function"];break;case 42:this.$=[String(a.replace(/^['|"]|['|"]$/g,"")),null,"string"];break;case 43:this.$=[Number(a),null,"number"];break;case 44:this.$=[a,null,"regexp"];break;case 45:this.$=["true"==a.replace(/^\s+/,""),null,"boolean"];break;case 46:this.$=[null,null,"null"];break;case 47:this.$=[null,null,"array"];break;case 48:this.$=[f[g-1],null,"array"];break;case 56:this.$=[f[g-1],null,"composite"]}},table:[{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,57],36:[1,32],46:[2,57]},{5:[2,31],34:[1,33],36:[2,31],46:[2,31]},{5:[2,29],34:[2,29],36:[2,29],46:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],46:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],46:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],46:[2,19]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],46:[2,49]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],46:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],46:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],46:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],46:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],41:[1,44],42:[1,45],44:[2,54],45:[1,46],46:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],44:[2,55],46:[2,55]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],46:[2,14]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],44:[2,42],46:[2,42]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],46:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],46:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],46:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],46:[2,46]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],45:[2,36],46:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],46:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],45:[2,35],46:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],46:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],46:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:76,39:23,40:[1,26],43:75,47:[1,18]},{7:51,30:15,32:14,37:78,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],46:[1,77],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{46:[1,79]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:80,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],46:[2,47]},{38:[1,82],44:[1,81]},{38:[2,33],44:[2,33],46:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:83,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:85,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],46:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],46:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],46:[2,4]},{5:[2,32],34:[1,33],36:[2,32],46:[2,32]},{5:[2,30],34:[2,30],36:[2,30],46:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],46:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],46:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],46:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],46:[2,23]},{5:[2,25],34:[2,25],36:[2,25],46:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],45:[1,46],46:[2,27]},{5:[2,26],34:[2,26],36:[2,26],46:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],45:[1,46],46:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],46:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],46:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],46:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],46:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],45:[2,37],46:[2,37]},{44:[1,88]},{41:[1,44],42:[1,45],44:[1,89],45:[1,46]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],45:[2,40],46:[2,40]},{38:[1,82],46:[1,90]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],46:[2,56]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],46:[2,13]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],46:[2,48]},{7:91,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],46:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],46:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],46:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],46:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],46:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],45:[2,38],46:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],45:[2,39],46:[2,39]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],45:[2,41],46:[2,41]},{38:[2,34],44:[2,34],46:[2,34]}],defaultActions:{31:[2,1]},parseError:function(a,b){if(!b.recoverable)throw new Error(a);this.trace(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||m,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n);var o=this.lexer.options&&this.lexer.options.ranges;this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var p,q,r,s,t,u,v,w,x,y={};;){if(r=d[d.length-1],this.defaultActions[r]?s=this.defaultActions[r]:((null===p||"undefined"==typeof p)&&(p=b()),s=g[r]&&g[r][p]),"undefined"==typeof s||!s.length||!s[0]){var z="";x=[];for(u in g[r])this.terminals_[u]&&u>l&&x.push("'"+this.terminals_[u]+"'");z=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(i+1)+": Unexpected "+(p==m?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(z,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:n,expected:x})}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:d.push(p),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(s[1]),p=null,q?(p=q,q=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:if(v=this.productions_[s[1]][1],y.$=e[e.length-v],y._$={first_line:f[f.length-(v||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(v||1)].first_column,last_column:f[f.length-1].last_column},o&&(y._$.range=[f[f.length-(v||1)].range[0],f[f.length-1].range[1]]),t=this.performAction.call(y,h,j,i,this.yy,s[1],e,f),"undefined"!=typeof t)return t;v&&(d=d.slice(0,2*-1*v),e=e.slice(0,-1*v),f=f.slice(0,-1*v)),d.push(this.productions_[s[1]][0]),e.push(y.$),f.push(y._$),w=g[d[d.length-2]][d[d.length-1]],d.push(w);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c; -if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;fb[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1?a:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){switch(c){case 0:return 29;case 1:return 31;case 2:return"from";case 3:return 24;case 4:return 25;case 5:return 21;case 6:return 19;case 7:return 22;case 8:return 20;case 9:return 26;case 10:return 27;case 11:return 34;case 12:return 36;case 13:return 55;case 14:return 53;case 15:break;case 16:return 49;case 17:return 47;case 18:return 47;case 19:return 40;case 20:return 51;case 21:return 41;case 22:return 11;case 23:return 12;case 24:return 13;case 25:return 38;case 26:return 8;case 27:return 26;case 28:return 27;case 29:return 24;case 30:return 24;case 31:return 25;case 32:return 25;case 33:return 21;case 34:return 22;case 35:return 20;case 36:return 19;case 37:return 34;case 38:return 36;case 39:return 15;case 40:return 17;case 41:return 45;case 42:return 44;case 43:return 42;case 44:return 46;case 45:return 9;case 46:return 5}},rules:[/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s+null\b)/,/^(?:\s+(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:==)/,/^(?:===)/,/^(?:!=)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();"undefined"!=typeof a&&"undefined"!=typeof c&&(c.parser=e,c.Parser=e.Parser,c.parse=function(){return e.parse.apply(e,arguments)},c.main=function(b){b[1]||(console.log("Usage: "+b[0]+" FILE"),d.exit(1));var e=a("fs").readFileSync(a("path").normalize(b[1]),"utf8");return c.parser.parse(e)},"undefined"!=typeof b&&a.main===b&&c.main(d.argv.slice(1)))},{__browserify_process:51,fs:48,path:49}],31:[function(a,b,c){!function(){"use strict";var b=a("./constraint/parser"),d=a("./nools/nool.parser");c.parseConstraint=function(a){try{return b.parse(a)}catch(c){throw new Error("Invalid expression '"+a+"'")}},c.parseRuleSet=function(a,b){return d.parse(a,b)}}()},{"./constraint/parser":30,"./nools/nool.parser":32}],32:[function(a,b,c){"use strict";var d=a("./tokens.js"),e=a("../../extended"),f=e.hash.keys,g=a("./util.js"),h=function(a,b,c){var d=a;a=a.replace(/\/\/(.*)[\n|\r|\r\n]/g,"").replace(/\n|\r|\r\n/g," ");for(var e,i=new RegExp("^("+f(b).join("|")+")");a&&-1!==(e=g.findNextTokenIndex(a));){a=a.substr(e);var j=a.match(i);if(null===j)throw new Error("Error parsing "+a);if(j=j[1],!(j in b))throw new Error("Unknown token"+j);try{a=b[j](a,c,h).replace(/^\s*|\s*$/g,"")}catch(k){throw new Error("Invalid "+j+" definition \n"+k.message+"; \nstarting at : "+d)}}};c.parse=function(a,b){var c={define:[],rules:[],scope:[],loaded:[],file:b};return h(a,d,c),c}},{"../../extended":11,"./tokens.js":33,"./util.js":34}],33:[function(require,module,exports){var process=require("__browserify_process"),utils=require("./util.js"),fs=require("fs"),indexOf=require("../../extended").indexOf,isWhiteSpace=function(a){return 0===a.replace(/[\s|\n|\r|\t]/g,"").length},ruleTokens={salience:function(){var a=/^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=parseInt(d[2],10);if(isNaN(e))throw new Error("Invalid salience/priority "+d[2]);return c.options.priority=e,b.replace(d[0],"")}throw new Error("invalid format")}}(),agendaGroup:function(){var a=/^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid agenda-group "+d[2]);return c.options.agendaGroup=e.replace(/^["']|["']$/g,""),b.replace(d[0],"")}throw new Error("invalid format")}}(),autoFocus:function(){var a=/^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid auto-focus "+d[2]);return c.options.autoFocus="true"===e?!0:!1,b.replace(d[0],"")}throw new Error("invalid format")}}(),"agenda-group":function(){return this.agendaGroup.apply(this,arguments)},"auto-focus":function(){return this.autoFocus.apply(this,arguments)},priority:function(){return this.salience.apply(this,arguments)},when:function(){var ruleRegExp=/^(\$?\w+) *: *(\w+)(.*)/,joinFunc=function(a,b){return"; "+b},constraintRegExp=/(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/,predicateExp=/^(\w+) *\((.*)\)$/m,parseRules=function(str){for(var rules=[],ruleLines=str.split(";"),l=ruleLines.length,ruleLine,i=0;l>i&&(ruleLine=ruleLines[i].replace(/^\s*|\s*$/g,"").replace(/\n/g,""));i++)if(!isWhiteSpace(ruleLine)){var rule=[];if(predicateExp.test(ruleLine)){var m=ruleLine.match(predicateExp),pred=m[1].replace(/^\s*|\s*$/g,"");if(rule.push(pred),ruleLine=m[2].replace(/^\s*|\s*$/g,""),"or"===pred){rule=rule.concat(parseRules(ruleLine.replace(/,\s*(\$?\w+\s*:)/g,joinFunc))),rules.push(rule);continue}}var parts=ruleLine.match(ruleRegExp);if(!parts||!parts.length)throw new Error("Invalid constraint "+ruleLine);rule.push(parts[2],parts[1]);var constraints=parts[3].replace(/^\s*|\s*$/g,""),hashParts=constraints.match(constraintRegExp);if(hashParts){var hash=hashParts[1],constraint=constraints.replace(hash,"");constraint&&rule.push(constraint.replace(/^\s*|\s*$/g,"")),hash&&rule.push(eval("("+hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g,'"$1" : "$2"')+")"))}else constraints&&!isWhiteSpace(constraints)&&rule.push(constraints);rules.push(rule)}return rules};return function(a,b){var c=a.replace(/^when\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(d,""),b.constraints=parseRules(d.replace(/^\{\s*|\}\s*$/g,"")),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}(),then:function(){return function(a,b){if(b.action)throw new Error("action already defined for rule"+b.name);var c=a.replace(/^then\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");if(c=c.replace(d,""),b.action||(b.action=d.replace(/^\{\s*|\}\s*$/g,"")),!isWhiteSpace(c))throw new Error("Error parsing then block "+a);return c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}()},topLevelTokens={"/":function(a){return a.match(/^\/\*/)?a.replace(/\/\*.*?\*\//,""):a},define:function(a,b){var c=a.replace(/^define\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){d=d[1];var e=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(e,""),b.define.push({name:d,properties:"("+e+")"}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"import":function(a,b,c){if("undefined"!=typeof window)throw new Error("import cannot be used in a browser");var d=a.replace(/^import\s*/,"");if("("===utils.findNextToken(d)){var e=utils.getParamList(d);if(d=d.replace(e,"").replace(/^\s*|\s*$/g,""),";"===utils.findNextToken(d)&&(d=d.replace(/\s*;/,"")),e=e.replace(/[\(|\)]/g,"").split(","),1===e.length){if(e=utils.resolve(b.file||process.cwd(),e[0].replace(/["|']/g,"")),-1===indexOf(b.loaded,e)){var f=b.file;b.file=e,c(fs.readFileSync(e,"utf8"),topLevelTokens,b),b.loaded.push(e),b.file=f}return d}throw new Error("import accepts a single file")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(d)+"'")},global:function(a,b){var c=a.replace(/^global\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"="===utils.findNextToken(c)){d=d[1].replace(/^\s+|\s+$/g,"");var e=utils.getTokensBetween(c,"=",";",!0).join(""),f=e.substring(1,e.length-1);if(f=f.replace(/^\s+|\s+$/g,""),/^require\(/.test(f)){var g=utils.getParamList(f.replace("require")).replace(/[\(|\)]/g,"").split(",");1===g.length&&(g=g[0].replace(/["|']/g,""),f=["require('",utils.resolve(b.file||process.cwd(),g),"')"].join(""))}return b.scope.push({name:d,body:f}),c=c.replace(e,"")}throw new Error("unexpected token : expected : '=' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"function":function(a,b){var c=a.replace(/^function\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);if(d){if(c=c.replace(d[0],""),"("===utils.findNextToken(c)){d=d[1];var e=utils.getParamList(c);if(c=c.replace(e,"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){var f=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(f,""),b.scope.push({name:d,body:"function"+e+f}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},rule:function(a,b,c){var d=a.replace(/^rule\s*/,""),e=d.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);if(e){if(d=d.replace(e[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(d)){e=e[1].replace(/^["']|["']$/g,"");var f={name:e,options:{},constraints:null,action:null},g=utils.getTokensBetween(d,"{","}",!0).join("");return d=d.replace(g,""),c(g.replace(/^\{\s*|\}\s*$/g,""),ruleTokens,f),b.rules.push(f),d}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(d)+"'")}throw new Error("missing name")}};module.exports=topLevelTokens},{"../../extended":11,"./util.js":34,__browserify_process:51,fs:48}],34:[function(a,b,c){var d=a("__browserify_process"),e=a("path"),f=/[\s|\n|\r|\t]/,g=e.sep||("win32"===d.platform?"\\":"/"),h={"{":"}","}":"{","(":")",")":"(","[":"]"},i=c.getTokensBetween=function(a,b,c,d){var e=0,f=[];b||(b=h[c],e=1),c||(c=h[b]),a=Object(a);for(var g,i=!1,j=0,k=!1;g=a.charAt(j++);)if(g===b)e++,i?f.push(g):(i=!0,d&&f.push(g));else if(g===c&&j){if(e--,0===e){d&&f.push(g),k=!0;break}f.push(g)}else i&&f.push(g);if(!k)throw new Error("Unable to match "+b+" in "+a);return f};c.getParamList=function(a){return i(a,"(",")",!0).join("")},c.resolve=function(a,b){return""!==e.extname(a)&&(a=e.dirname(a)),1===b.split(g).length?b:e.resolve(a,b)};var j=c.findNextTokenIndex=function(a,b,c){b=b||0,c=c||a.length;var d=-1,e=a.length;for((!c||c>e)&&(c=e);c>b;b++){var g=a.charAt(b);if(!f.test(g)){d=b;break}}return d};c.findNextToken=function(a,b,c){return a.charAt(j(a,b,c))}},{__browserify_process:51,path:49}],35:[function(a,b,c){!function(){"use strict";var b=a("./extended"),d=b.merge,e=b.forEach,f=b.declare,g=a("./constraintMatcher"),h=a("./constraint"),i=f({}),j=i.extend({instance:{constructor:function(a,c,f,i,j){j=j||{},this.type=a,this.alias=c,this.conditions=f,this.pattern=j.pattern,this.constraints=[new h.ObjectConstraint(a)];var k=g.toConstraints(f,d({alias:c},j));if(k.length)this.constraints=this.constraints.concat(k);else{var l=new h.TrueConstraint;this.constraints.push(l)}if(i&&!b.isEmpty(i)){var m=new h.HashConstraint(i);this.constraints.push(m)}e(this.constraints,function(a){a.set("alias",c)})},hasConstraint:function(a){return b.some(this.constraints,function(b){return b instanceof a})},hashCode:function(){return[this.type,this.alias,b.format("%j",this.conditions)].join(":")},toString:function(){return b.format("%j",this.constraints)}}}).as(c,"ObjectPattern");j.extend().as(c,"NotPattern"),i.extend({instance:{constructor:function(a,b){this.leftPattern=a,this.rightPattern=b},hashCode:function(){return[this.leftPattern.hashCode(),this.rightPattern.hashCode()].join(":")},getters:{constraints:function(){return this.leftPattern.constraints.concat(this.rightPattern.constraints)}}}}).as(c,"CompositePattern");var k=f({}).as(c,"InitialFact");j.extend({instance:{constructor:function(){this._super([k,"i",[],{}])},assert:function(){return!0}}}).as(c,"InitialFactPattern")}()},{"./constraint":7,"./constraintMatcher":8,"./extended":11}],36:[function(a,b,c){"use strict";function d(a,b,c,d){e.isArray(b)?(d=c,c=b):b=b||{};var g=e.every(c,function(a){return f(a)});g&&1===c.length&&(c=c[0],g=!1);var h=[],i=b.scope||{};if(c.scope=i,g){for(var j,k=function(a,b){n[b]?e(n).forEach(function(b){b.push(a)}):(n[b]=0===b?[]:n[b-1].slice(),0!==b&&n[b].pop(),n[b].push(a))},l=c.length,n=[],o=0;l>o;o++)j=c[o],j.scope=i,e.forEach(p(j),k);h=e.map(n,function(c){for(var e=null,f=0;f>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.arrayExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":38,extended:43,"is-extended":53}],40:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c,d){a=""+a,c=c||" ";for(var e=a.length;b>e;)d?a+=c:a=c+a,e++;return a}function e(a,c,d){var f=a;if(b.isString(f)){if(a.length>c)if(d){var g=a.length;f=a.substring(g-c,g)}else f=a.substring(0,c)}else f=e(""+f,c);return f}function f(a,c,d){if(!b.isArray(a)||"function"!=typeof c)throw new TypeError;for(var e=Object(a),f=e.length>>>0,g=0;f>g;g++)if(g in e&&!c.call(d,e[g],g,e))return!1;return!0}function g(a,b){return A.difference(new Date(a.getFullYear(),0,1,a.getHours()),a,null,b)+1}function h(a,b,c){b=b||0;var d=a[c?"getUTCFullYear":"getFullYear"](),e=new Date(d,0,1).getDay(),f=(e-b+7)%7,h=o((g(a)+f-1)/7);return e===b&&h++,h}function i(a){var b=a.toString(),c="",d=b.indexOf("(");return d>-1&&(c=b.substring(++d,b.indexOf(")"))),c}function j(a,b){return a.replace(/([a-z])\1*/gi,function(a){var c,d=a.charAt(0),e=a.length,f="0?",g="0{0,2}";if("y"===d)c="\\d{2,4}";else if("M"===d)c=e>2?"\\S+?":"1[0-2]|"+f+"[1-9]";else if("D"===d)c="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+g+"[1-9][0-9]|"+f+"[1-9]";else if("d"===d)c="3[01]|[12]\\d|"+f+"[1-9]";else if("w"===d)c="[1-4][0-9]|5[0-3]|"+f+"[1-9]";else if("E"===d)c="\\S+";else if("h"===d)c="1[0-2]|"+f+"[1-9]";else if("K"===d)c="1[01]|"+f+"\\d";else if("H"===d)c="1\\d|2[0-3]|"+f+"\\d";else if("k"===d)c="1\\d|2[0-4]|"+f+"[1-9]";else if("m"===d||"s"===d)c="[0-5]\\d";else if("S"===d)c="\\d{"+e+"}";else if("a"===d){var h="AM",i="PM";c=h+"|"+i,h!==h.toLowerCase()&&(c+="|"+h.toLowerCase()),i!==i.toLowerCase()&&(c+="|"+i.toLowerCase()),c=c.replace(/\./g,"\\.")}else c="v"===d||"z"===d||"Z"===d||"G"===d||"q"===d||"Q"===d?".*":" "===d?"\\s*":d+"*";return b&&b.push(a),"("+c+")"}).replace(/[\xa0 ]/g,"[\\s\\xa0]")}function k(a){B[a+"sFromNow"]=function(b){return A.add(new Date,a,b)},B[a+"sAgo"]=function(b){return A.add(new Date,a,-b)}}for(var l=function(){function a(a,b,c){return a=a.replace(/s$/,""),e.hasOwnProperty(a)?e[a](b,c):[c,"UTC"+a.charAt(0).toUpperCase()+a.substring(1)+"s",!1]}function b(a,b,c,e){return a=a.replace(/s$/,""),d(f[a](b,c,e))}var c=Math.floor,d=Math.round,e={day:function(a,b){return[b,"Date",!1]},weekday:function(a,b){var c,d,e=b%5,f=a.getDay(),g=0;e?(c=e,d=parseInt(b/5,10)):(c=b>0?5:-5,d=b>0?(b-5)/5:(b+5)/5),6===f&&b>0?g=1:0===f&&0>b&&(g=-1);var h=f+c;return(0===h||6===h)&&(g=b>0?2:-2),[7*d+c+g,"Date",!1]},year:function(a,b){return[b,"FullYear",!0]},week:function(a,b){return[7*b,"Date",!1]},quarter:function(a,b){return[3*b,"Month",!0]},month:function(a,b){return[b,"Month",!0]}},f={quarter:function(a,b,d){var e=b.getFullYear()-a.getFullYear(),f=a[d?"getUTCMonth":"getMonth"](),g=b[d?"getUTCMonth":"getMonth"](),h=c(f/3)+1,i=c(g/3)+1;return i+=4*e,i-h},weekday:function(a,c,d){var e,f=b("day",a,c,d),g=f%7;if(0===g)f=5*b("week",a,c,d);else{var h=0,i=a[d?"getUTCDay":"getDay"](),j=c[d?"getUTCDay":"getDay"]();e=parseInt(f/7,10);var k=new Date(+a);k.setDate(k[d?"getUTCDate":"getDate"]()+7*e);var l=k[d?"getUTCDay":"getDay"]();f>0?6===i||6===j?h=-1:0===i?h=0:(0===j||l+g>5)&&(h=-2):0>f&&(6===i?h=0:0===i||0===j?h=1:(6===j||0>l+g)&&(h=2)),f+=h,f-=2*e}return f},year:function(a,b){return b.getFullYear()-a.getFullYear()},month:function(a,b,c){var d=a[c?"getUTCMonth":"getMonth"](),e=b[c?"getUTCMonth":"getMonth"]();return e-d+12*(b.getFullYear()-a.getFullYear())},week:function(a,c,e){return d(b("day",a,c,e)/7)},day:function(a,b){return 1.1574074074074074e-8*(b.getTime()-a.getTime())},hour:function(a,b){return 2.7777777777777776e-7*(b.getTime()-a.getTime())},minute:function(a,b){return 16666666666666667e-21*(b.getTime()-a.getTime())},second:function(a,b){return.001*(b.getTime()-a.getTime())},millisecond:function(a,b){return b.getTime()-a.getTime()}};return{addTransform:a,differenceTransform:b}}(),m=l.addTransform,n=l.differenceTransform,o=Math.floor,p=Math.round,q=Math.min,r=Math.pow,s=Math.ceil,t=Math.abs,u=["January","February","March","April","May","June","July","August","September","October","November","December"],v=["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y=["Before Christ","Anno Domini"],z=["BC","AD"],A={getDaysInMonth:function(a){var b=a.getMonth(),c=[31,28,31,30,31,30,31,31,30,31,30,31];return 1===b&&A.isLeapYear(a)?29:c[b]},isLeapYear:function(a,b){var c=a[b?"getUTCFullYear":"getFullYear"]();return 0===c%400||0===c%4&&0!==c%100},isWeekend:function(a,b){var c=(a||new Date)[b?"getUTCDay":"getDay"]();return 0===c||6===c},getTimezoneName:i,compare:function(a,b,c){return a=new Date(+a),b=new Date(+(b||new Date)),"date"===c?(a.setHours(0,0,0,0),b.setHours(0,0,0,0)):"time"===c&&(a.setFullYear(0,0,0),b.setFullYear(0,0,0)),a>b?1:b>a?-1:0},add:function(a,b,c){var d=m(b,a,c||0);c=d[0];var e=d[1],f=new Date(+a),g=d[2];return e&&f["set"+e](f["get"+e]()+c),g&&f.getDate()E?z:y)[0>f?0:1];else if("y"===D)B=f,E>1&&(2===E?B=e(""+B,2,!0):C=!0);else if("Q"===D.toUpperCase())B=s((j+1)/3),C=!0;else if("M"===D)3>E?(B=j+1,C=!0):B=(3===E?v:u)[j];else if("w"===D)B=h(a,0,c),C=!0;else if("D"===D)B=g(a,c),C=!0;else if("E"===D)3>E?(B=k+1,C=!0):B=(-3===E?x:w)[k];else if("a"===D)B=12>m?"AM":"PM";else if("h"===D)B=m%12||12,C=!0;else if("K"===D)B=m%12,C=!0;else if("k"===D)B=m||24,C=!0;else if("S"===D)B=p(A*r(10,E-3)),C=!0;else if("z"===D||"v"===D||"Z"===D){if(B=i(a),"z"!==D&&"v"!==D||B||(E=4),!B||"Z"===D){var F=a.getTimezoneOffset(),G=[F>=0?"-":"+",d(o(t(F)/60),2,"0"),d(t(F)%60,2,"0")];4===E&&(G.splice(0,0,"GMT"),G.splice(3,0,":")),B=G.join("")}}else B=b;else B=""+n,C=!0;else B=""+m,C=!0;return C&&(B=d(B,E,"0")),B})}},B={},C=["year","month","day","hour","minute","second"],D=0,E=C.length;E>D;D++)k(C[D]);var F={parseDate:function(a,b){if(!b)throw new Error("format required when calling dateExtender.parse");var d=[],e=j(b,d),g=new RegExp("^"+e+"$","i"),h=g.exec(a);if(!h)return null;var i=[1970,0,1,0,0,0,0],k="",l=f(h,function(a,b){if(b){var e=d[b-1],f=e.length,g=e.charAt(0);if("y"===g)if(100>a){a=parseInt(a,10);var h=""+(new Date).getFullYear(),j=100*h.substring(0,2),l=q(h.substring(2,4)+20,99);i[0]=l>a?j+a:j-100+a}else i[0]=a;else if("M"===g){if(f>2){var m,n,o=u;3===f&&(o=v),a=a.replace(".","").toLowerCase();var p=!1;for(m=0,n=o.length;n>m&&!p;m++){var r=o[m].replace(".","").toLocaleLowerCase();r===a&&(a=m,p=!0)}if(!p)return!1}else a--;i[1]=a}else if("E"===g||"e"===g){var s=w;3===f&&(s=x),a=a.toLowerCase(),s=c.map(s,function(a){return a.toLowerCase()});var t=c.indexOf(s,a);if(-1===t){if(a=parseInt(a,10),isNaN(a)||a>s.length)return!1}else a=t}else if("D"===g||"d"===g)"D"===g&&(i[1]=0),i[2]=a;else if("a"===g){var y="am",z="pm",A=/\./g;a=a.replace(A,"").toLowerCase(),k=a===z?"p":a===y?"a":""}else"k"===g||"h"===g||"H"===g||"K"===g?("k"===g&&24===+a&&(a=0),i[3]=a):"m"===g?i[4]=a:"s"===g?i[5]=a:"S"===g&&(i[6]=a)}return!0});if(l){var m=+i[3];"p"===k&&12>m?i[3]=m+12:"a"===k&&12===m&&(i[3]=0);var n=new Date(i[0],i[1],i[2],i[3],i[4],i[5],i[6]),o=-1!==c.indexOf(d,"d"),p=-1!==c.indexOf(d,"M"),r=i[1],s=i[2],t=n.getMonth(),y=n.getDate();return p&&t>r||o&&y>s?null:n}return null}},G=a.define(b.isDate,A).define(b.isString,F).define(b.isNumber,B);for(D in A)A.hasOwnProperty(D)&&(G[D]=A[D]);for(D in F)F.hasOwnProperty(D)&&(G[D]=F[D]);for(D in B)B.hasOwnProperty(D)&&(G[D]=B[D]);return G}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.dateExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":39,extended:43,"is-extended":53}],41:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b) -}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){switch(arguments.length){case 0:this.constructor.call(this);break;case 1:this.constructor.call(this,arguments[0]);break;case 2:this.constructor.call(this,arguments[0],arguments[1]);break;case 3:this.constructor.call(this,arguments[0],arguments[1],arguments[2]);break;default:this.constructor.apply(this,arguments)}}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],42:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":41}],43:[function(a,b,c){!function(){"use strict";function d(a){function b(){var b=a.define();return b.expose({register:function(a,c){c||(c=a,a=null);var d=typeof c;if(a)b[a]=c;else if(c&&"function"===d)b.extend(c);else{if("object"!==d)throw new TypeError("extended.register must be called with an extender function");b.expose(c)}return b},define:function(){return a.define.apply(a,arguments)}}),b}function c(){return b()}return function(){function a(a,b){var c,d;for(c in b)b.hasOwnProperty(c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}return function(b){b||(b={});for(var c=1,d=arguments.length;d>c;c++)a(b,arguments[c]);return b}}(),c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}.call(this)},{extender:45}],44:[function(a,b,c){!function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}.call(this)},{"declare.js":42}],45:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":44}],46:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c){if(c=o(arguments,2),m(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!m(b)&&!n(b))throw new Error(b+" is not a function");return m(b)?function(){var d=a[b];if(n(d)){var e=c.concat(o(arguments));return d.apply(a,e)}return d}:c.length?function(){var d=c.concat(o(arguments));return b.apply(a,d)}:function(){return b.apply(a,arguments)}}function e(a,b){if(b=o(arguments,1),!m(a)&&!n(a))throw new Error(a+" must be the name of a property or function to execute");return m(a)?function(){var c=o(arguments),d=c.shift(),e=d[a];return n(e)?(c=b.concat(c),e.apply(d,c)):e}:function(){var c=o(arguments),d=c.shift();return c=b.concat(c),a.apply(d,c)}}function f(a,b,c){if(c=o(arguments,2),m(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!m(b)&&!n(b))throw new Error(b+" is not a function");return m(b)?function(){var d=a[b];return n(d)?d.apply(a,c):d}:function(){return b.apply(a,c)}}function g(a){var b=o(arguments,1);if(!l(a)&&!n(a))throw new TypeError("scope must be an object");if(1===b.length&&k(b[0])&&(b=b[0]),!b.length){b=[];for(var c in a)a.hasOwnProperty(c)&&n(a[c])&&b.push(c)}for(var e=0,f=b.length;f>e;e++)a[b[e]]=d(a,a[b[e]]);return a}function h(a,b){if(b=o(arguments,1),!m(a)&&!n(a))throw new Error(a+" must be the name of a property or function to execute");return m(a)?function(){var c=this[a];if(n(c)){var d=b.concat(o(arguments));return c.apply(this,d)}return c}:function(){var c=b.concat(o(arguments));return a.apply(this,c)}}function i(a,b){return function(){var c=o(arguments);return b?a.apply(this,arguments):function(){return a.apply(this,c.concat(o(arguments)))}}}function j(a,b,c){var e;if(e=c?d(c,b):b,a)for(var f=a-1,g=f;g>=0;g--)e=i(e,g===f);return e}var k=b.isArray,l=b.isObject,m=b.isString,n=b.isFunction,o=c.argsToArray;return a.define(l,{bind:d,bindAll:g,bindIgnore:f,curry:function(a,b,c){return j(b,c,a)}}).define(n,{bind:function(a,b){return d.apply(this,[b,a].concat(o(arguments,2)))},bindIgnore:function(a,b){return f.apply(this,[b,a].concat(o(arguments,2)))},partial:h,applyFirst:e,curry:function(a,b,c){return j(b,a,c)},noWrap:{f:function(){return this.value()}}}).define(m,{bind:function(a,b){return d(b,a)},bindIgnore:function(a,b){return f(b,a)},partial:h,applyFirst:e,curry:function(a,b,c){return j(b,a,c)}}).expose({bind:d,bindAll:g,bindIgnore:f,partial:h,applyFirst:e,curry:j})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.functionExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":38,extended:43,"is-extended":53}],47:[function(a,b,c){function d(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;ce;e++)d[e].apply(this,c);return!0}return!1},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var e=d(c,b);if(0>e)return this;c.splice(e,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},f.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0}},{__browserify_process:51}],48:[function(){},{}],49:[function(a,b,c){function d(a,b){for(var c=[],d=0;d=0;d--){var e=a[d];"."==e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var f=a("__browserify_process"),g=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){for(var a="",b=!1,c=arguments.length;c>=-1&&!b;c--){var g=c>=0?arguments[c]:f.cwd();"string"==typeof g&&g&&(a=g+"/"+a,b="/"===g.charAt(0))}return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b="/"===a.charAt(0),c="/"===a.slice(-1);return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){return a&&"string"==typeof a}).join("/"))},c.dirname=function(a){var b=g.exec(a)[1]||"",c=!1;return b?1===b.length||c&&b.length<=3&&":"===b.charAt(1)?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=g.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return g.exec(a)[3]||""},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i=0;e--)if(f[e]!=g[e])return!1;for(e=f.length-1;e>=0;e--)if(d=f[e],!h(a[d],b[d]))return!1;return!0}function l(a,b){return a&&b?b instanceof RegExp?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function m(a,b,c,d){var e;"string"==typeof c&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f("Missing expected exception"+d),!a&&l(e,c)&&f("Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util"),o=a("buffer").Buffer,p=Array.prototype.slice,q=b.exports=g;q.AssertionError=function(a){this.name="AssertionError",this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var b=a.stackStartFunction||f;Error.captureStackTrace&&Error.captureStackTrace(this,b)},n.inherits(q.AssertionError,Error),q.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",e(JSON.stringify(this.actual,d),128),this.operator,e(JSON.stringify(this.expected,d),128)].join(" ")},q.AssertionError.__proto__=Error.prototype,q.fail=f,q.ok=g,q.equal=function(a,b,c){a!=b&&f(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",q.notStrictEqual)},q.throws=function(){m.apply(this,[!0].concat(p.call(arguments)))},q.doesNotThrow=function(){m.apply(this,[!1].concat(p.call(arguments)))},q.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(a,b,c){function d(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&d(a.__proto__)}function e(a){return a instanceof RegExp||"object"==typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function f(a){if(a instanceof Date)return!0;if("object"!=typeof a)return!1;var b=Date.prototype&&h(Date.prototype),c=a.__proto__&&h(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}a("events"),c.isArray=d,c.isDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,i,j){function k(a,i){if(a&&"function"==typeof a.inspect&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(i);switch(typeof a){case"undefined":return m("undefined","undefined");case"string":var j="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return m(j,"string");case"number":return m(""+a,"number");case"boolean":return m(""+a,"boolean")}if(null===a)return m("null","null");var n=g(a),o=b?h(a):n;if("function"==typeof a&&0===o.length){if(e(a))return m(""+a,"regexp");var p=a.name?": "+a.name:"";return m("[Function"+p+"]","special")}if(f(a)&&0===o.length)return m(a.toUTCString(),"date");var q,r,s;if(d(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]),"function"==typeof a){var t=a.name?": "+a.name:"";q=e(a)?" "+a:" [Function"+t+"]"}else q="";if(f(a)&&(q=" "+a.toUTCString()),0===o.length)return s[0]+q+s[1];if(0>i)return e(a)?m(""+a,"regexp"):m("[Object]","special");l.push(a);var u=o.map(function(b){var c,e;if(a.__lookupGetter__&&(a.__lookupGetter__(b)?e=a.__lookupSetter__(b)?m("[Getter/Setter]","special"):m("[Getter]","special"):a.__lookupSetter__(b)&&(e=m("[Setter]","special"))),n.indexOf(b)<0&&(c="["+b+"]"),e||(l.indexOf(a[b])<0?(e=null===i?k(a[b]):k(a[b],i-1),e.indexOf("\n")>-1&&(e=d(a)?e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=m("[Circular]","special")),"undefined"==typeof c){if("Array"===r&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=m(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=m(c,"string"))}return c+": "+e});l.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return u=w>50?s[0]+(""===q?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:s[0]+q+" "+u.join(", ")+" "+s[1]}var l=[],m=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return j||(m=function(a){return a}),k(a,"undefined"==typeof i?2:i)},c.log=function(){},c.pump=null;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},i=Object.create||function(a,b){var c;if(null===a)c={__proto__:null};else{if("object"!=typeof a)throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return"undefined"!=typeof b&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=i(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})};var j=/%[sdj%]/g;c.format=function(a){if("string"!=typeof a){for(var b=[],d=0;d=f)return a;switch(a){case"%s":return String(e[d++]);case"%d":return Number(e[d++]);case"%j":return JSON.stringify(e[d++]);default:return a}}),h=e[d];f>d;h=e[++d])g+=null===h||"object"!=typeof h?" "+h:" "+c.inspect(h);return g}},{events:4}],5:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],6:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(a,b,c){!function(a){function b(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;cf;f++)d[f].apply(this,c);return!0}return!1},d.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(e(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:f,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},d.prototype.removeListener=function(a,c){if("function"!=typeof c)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var d=this._events[a];if(e(d)){var f=b(d,c);if(0>f)return this;d.splice(f,1),0==d.length&&delete this._events[a]}else this._events[a]===c&&delete this._events[a];return this},d.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},d.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),e(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(a,b){b.exports=a("q9TxCC")},{}],q9TxCC:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used=a.length?0:(c?(e=a.parent[a.offset+b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8*(d?1-f:f)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>8*(d?3-f:f)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fthis.length)throw new Error("oob");if(b>c)throw new Error("oob");for(var d=b;c>d;d++)this[d]=a},c.SlowBuffer=d,c.Buffer=l,l.poolSize=8192;var E;l.isBuffer=function(a){return a instanceof l||a instanceof d},l.concat=function(a,b){if(!Array.isArray(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new l(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;cd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=c.length?void 0:c.parent[c.offset+a]},l.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},l.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},l.prototype.readUInt32LE=function(a,b){return p(this,a,!1,b)},l.prototype.readUInt32BE=function(a,b){return p(this,a,!0,b)},l.prototype.readInt8=function(a,b){var c,d=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=d.length?void 0:(c=128&d.parent[d.offset+a],c?-1*(255-d.parent[d.offset+a]+1):d.parent[d.offset+a])},l.prototype.readInt16LE=function(a,b){return q(this,a,!1,b)},l.prototype.readInt16BE=function(a,b){return q(this,a,!0,b)},l.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},l.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},l.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},l.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},l.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},l.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},l.prototype.writeUInt8=function(a,b,c){var d=this;c||(D.ok(void 0!==a&&null!==a,"missing value"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],8:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],3:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used>>0):(e=a.parent[a.offset+b+2]<<16,e|=a.parent[a.offset+b+1]<<8,e|=a.parent[a.offset+b],e+=a.parent[a.offset+b+3]<<24>>>0),e}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8,a.parent[a.offset+c+1]=255&b):(a.parent[a.offset+c+1]=(65280&b)>>>8,a.parent[a.offset+c]=255&b)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>24,a.parent[a.offset+c+1]=255&b>>>16,a.parent[a.offset+c+2]=255&b>>>8,a.parent[a.offset+c+3]=255&b):(a.parent[a.offset+c+3]=255&b>>>24,a.parent[a.offset+c+2]=255&b>>>16,a.parent[a.offset+c+1]=255&b>>>8,a.parent[a.offset+c]=255&b)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}]},{},[]),b.exports=a("buffer-browserify")},{}],51:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener; -if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],52:[function(a,b,c){!function(){"use strict";function d(a){var b=function(a){return"string"==typeof a?a:"object"==typeof a?a.hashCode?a.hashCode():""+a:""+a},c=a.declare({instance:{constructor:function(){this.__entries=[],this.__keys=[],this.__values=[]},pushValue:function(a,b){return this.__keys.push(a),this.__values.push(b),this.__entries.push({key:a,value:b}),b},remove:function(a){for(var b,c=null,d=this.__entries,e=this.__keys,f=this.__values,g=d.length-1;g>=0;g--)if((b=d[g])&&b.key===a)return d.splice(g,1),e.splice(g,1),f.splice(g,1),b.value;return c},set:function(a,b){for(var c=null,d=this.__entries,e=this.__values,f=d.length-1;f>=0;f--){var g=d[f];if(g&&a===g.key){e[f]=b,g.value=b,c=b;break}}return c||d.push({key:a,value:b}),c},find:function(a){for(var b,c=null,d=this.__entries,e=d.length-1;e>=0;e--)if(b=d[e],b&&a===b.key){c=b.value;break}return c},getEntrySet:function(){return this.__entries},getKeys:function(){return this.__keys},getValues:function(){return this.__values}}});return a.declare({instance:{constructor:function(){this.__map={}},entrySet:function(){var a=[],b=this.__map;for(var c in b)b.hasOwnProperty(c)&&(a=a.concat(b[c].getEntrySet()));return a},put:function(a,d){var e=b(a),f=null;return(f=this.__map[e])||(f=this.__map[e]=new c),f.pushValue(a,d),d},remove:function(a){var c=b(a),d=null,e=this.__map[c];return e&&(d=e.remove(a)),d},get:function(a){var c,d=b(a),e=null;return(c=this.__map[d])&&(e=c.find(a)),e},set:function(a,d){var e=b(a),f=null,g=null,h=this.__map;return f=(g=h[e])?g.set(a,d):(h[e]=new c).pushValue(a,d)},contains:function(a){var c=b(a),d=!1,e=null;return(e=this.__map[c])&&(d=!!e.find(a)),d},concat:function(a){if(a instanceof this._static){for(var b=new this._static,c=a.entrySet().concat(this.entrySet()),d=c.length-1;d>=0;d--){var e=c[d];b.put(e.key,e.value)}return b}throw new TypeError("When joining hashtables the joining arg must be a HashTable")},filter:function(b,c){var d=this.entrySet(),e=new this._static;d=a.filter(d,b,c);for(var f=d.length-1;f>=0;f--){var g=d[f];e.put(g.key,g.value)}return e},forEach:function(b,c){var d=this.entrySet();a.forEach(d,b,c)},every:function(b,c){var d=this.entrySet();return a.every(d,b,c)},map:function(b,c){var d=this.entrySet();return a.map(d,b,c)},some:function(b,c){var d=this.entrySet();return a.some(d,b,c)},reduce:function(b,c){var d=this.entrySet();return a.reduce(d,b,c)},reduceRight:function(b,c){var d=this.entrySet();return a.reduceRight(d,b,c)},clear:function(){this.__map={}},keys:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getKeys());return a},values:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getValues());return a},isEmpty:function(){return 0===this.keys().length}}})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")))):"function"==typeof define?define(["extended","declare","is-extended","array-extended"],function(a,b,c,e){return d(a().register("declare",b).register(c).register(e))}):this.Ht=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended))}.call(this)},{"array-extended":39,"declare.js":42,extended:43,"is-extended":53}],53:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;!function(){"use strict";function e(a){function b(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}.call(this)},{__browserify_Buffer:50,extended:43}],54:[function(a,b,c){!function(){"use strict";function d(a){function b(a,b){var c=0;return a>b?1:b>a?-1:b?c:1}var c=a.multiply,d=a.declare({instance:{__printNode:function(b,d){var e=[];a.isUndefinedOrNull(b)?(e.push(c(" ",d)),e.push("~"),console.log(e.join(""))):(this.__printNode(b.right,d+1),e.push(c(" ",d)),e.push(b.data+"\n"),console.log(e.join("")),this.__printNode(b.left,d+1))},constructor:function(a){a=a||{},this.compare=a.compare||b,this.__root=null},insert:function(){throw new Error("Not Implemented")},remove:function(){throw new Error("Not Implemented")},clear:function(){this.__root=null},isEmpty:function(){return!this.__root},traverseWithCondition:function(a,b,c){var e=!0;return a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.IN_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.POST_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e&&(e=this.traverseWithCondition(a.right,b,c)),e&&(e=c(a.data)))):b===d.REVERSE_ORDER&&(e=this.traverseWithCondition(a.right,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c))))),e},traverse:function(a,b,c){a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(c(a.data),this.traverse(a.left,b,c),this.traverse(a.right,b,c)):b===d.IN_ORDER?(this.traverse(a.left,b,c),c(a.data),this.traverse(a.right,b,c)):b===d.POST_ORDER?(this.traverse(a.left,b,c),this.traverse(a.right,b,c),c(a.data)):b===d.REVERSE_ORDER&&(this.traverse(a.right,b,c),c(a.data),this.traverse(a.left,b,c)))},forEach:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this,this.traverse(this.__root,c,function(c){a.call(b,c,this)})},map:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){e.insert(a.call(b,c,this))}),e},filter:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){a.call(b,c,this)&&e.insert(c)}),e},reduce:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduce.apply(a,f)},reduceRight:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduceRight.apply(a,f)},every:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=!1;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this)}),e},some:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this),!e}),e},toArray:function(a){a=a||d.IN_ORDER;var b=[];return this.traverse(this.__root,a,function(a){b.push(a)}),b},contains:function(a){for(var b=!1,c=this.__root;null!==c;){var d=this.compare(a,c.data);d?c=c[-1===d?"left":"right"]:(b=!0,c=null)}return b},find:function(a){for(var b,c=this.__root;c;){var d=this.compare(a,c.data);if(!d){b=c.data;break}c=c[-1===d?"left":"right"]}return b},findLessThan:function(a,b){var c=[],e=this.compare;return this.traverseWithCondition(this.__root,d.IN_ORDER,function(d){var f=e(a,d);return!b&&0===f||1===f?(c.push(d),!0):!1}),c},findGreaterThan:function(a,b){var c=[],e=this.compare;return this.traverse(this.__root,d.REVERSE_ORDER,function(d){var f=e(a,d);return!b&&0===f||-1===f?(c.push(d),!0):!1}),c},print:function(){this.__printNode(this.__root,0)}},"static":{PRE_ORDER:"pre_order",IN_ORDER:"in_order",POST_ORDER:"post_order",REVERSE_ORDER:"reverse_order"}}),e=function(){var a=Math.abs,b=function(a){return{data:a,balance:0,left:null,right:null}},e=function(a,b,c){var d=a[c];return a[c]=d[b],d[b]=a,d},f=function(a,b,c){return a[c]=e(a[c],c,b),e(a,b,c)},g=function(a,b,c){var d="left"===b?"right":"left",e=a[b],f=e[d];0===f.balance?a.balance=e.balance=0:f.balance===c?(a.balance=-c,e.balance=0):(a.balance=0,e.balance=c),f.balance=0},h=function(a,b){var c="left"===b?"right":"left",d=a[b],h="left"===b?-1:1;return d.balance===h?(a.balance=d.balance=0,a=e(a,c,b)):(g(a,b,h),a=f(a,c,b)),a},i=function(a,b,c){var d="left"===b?"right":"left",h=a[d],i="left"===b?-1:1;return h.balance===-i?(a.balance=h.balance=0,a=e(a,b,d)):h.balance===i?(g(a,d,-i),a=f(a,b,d)):(a.balance=-i,h.balance=i,a=e(a,b,d),c.done=!0),a},j=function(c,d,e,f){if(null===c||void 0===c)c=b(d);else{var g=-1===f(d,c.data)?"left":"right";c[g]=j(c[g],d,e,f),e.done||(c.balance+="left"===g?-1:1,0===c.balance?e.done=!0:a(c.balance)>1&&(c=h(c,g),e.done=!0))}return c},k=function(b,c,d,e){var f,g,h,j;if(b){if(g=e(c,b.data),0===g){var l=b.left,m=b.right;if(!l||!m)return f=l?"left":"right",h=b[f];for(var n=l;null!==(m=n.right);)n=m;b.data=n.data,c=n.data}if(f=-1===e(b.data,c)?"right":"left",b[f]=k(b[f],c,d,e),!d.done){j=b.balance+="left"===f?1:-1;var o=a(j);1===o?d.done=!0:o>1&&(b=i(b,f,d))}}return b};return d.extend({instance:{insert:function(a){var b={done:!1};this.__root=j(this.__root,a,b,this.compare)},remove:function(a){this.__root=k(this.__root,a,{done:!1},this.compare)},__printNode:function(a,b){var d=[];a?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.balance+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),f=function(){function a(a,b){return{data:a,level:b,left:g,right:g}}function b(a){if(0!==a.level&&a.left.level===a.level){var b=a.left;a.left=b.right,b.right=a,a=b}return a}function e(a){if(0!==a.level&&a.right.right.level===a.level){var b=a.right;a.right=b.left,b.left=a,a=b,a.level++}return a}function f(c,d,h){if(c===g)c=a(d,1);else{var i=-1===h(d,c.data)?"left":"right";c[i]=f(c[i],d,h),c=b(c),c=e(c)}return c}var g={level:0,data:null},h=function(a,c,d){var f,i;if(a!==g){var j=d(c,a.data);if(0===j)if(f=a.left,i=a.right,f!==g&&i!==g){for(var k=f;k.right!==g;)k=k.right;a.data=k.data,a.left=h(f,k.data,d)}else a=a[f===g?"right":"left"];else{var l=-1===j?"left":"right";a[l]=h(a[l],c,d)}}if(a!==g){var m=a.level,n=a.left.level,o=a.right.level;(m-1>n||m-1>o)&&(o>--a.level&&(a.right.level=a.level),a=b(a),a=e(a))}return a};return d.extend({instance:{isEmpty:function(){return this.__root===g||this._super(arguments)},insert:function(a){this.__root||(this.__root=g),this.__root=f(this.__root,a,this.compare)},remove:function(a){this.__root=h(this.__root,a,this.compare)},traverseWithCondition:function(a){var b=!0;return a!==g?this._super(arguments):b},traverse:function(a){a!==g&&this._super(arguments)},contains:function(){return this.__root!==g?this._super(arguments):!1},__printNode:function(a,b){var d=[];a&&a.data?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.level+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),g=d.extend({instance:{insert:function(a){if(!this.__root)return this.__root={data:a,parent:null,left:null,right:null};for(var b=this.compare,c=this.__root;null!==c;){var d=b(a,c.data);if(!d)return;var e=-1===d?"left":"right",f=c[e];if(!f)return c[e]={data:a,parent:c,left:null,right:null};c=f}},remove:function(a){if(null!==this.__root){for(var b,c={right:this.__root},d=c,e=null,f="right";null!==d[f];){b=d,d=d[f];var g=this.compare(a,d.data);g||(e=d),f=-1===g?"left":"right"}null!==e&&(e.data=d.data,b[b.right===d?"right":"left"]=d[null===d.left?"right":"left"]),this.__root=c.right}}}}),h=function(){var a="RED",b="BLACK",e=function(a){return null!==a&&a.red},f=function(a){return{data:a,red:!0,left:null,right:null}},g=function(a,b,c){if(!a)return f(b);var d=c(b,a.data);if(d){var j=-1===d?"left":"right",k="left"===j?"right":"left";a[j]=g(a[j],b,c);var l=a[j];if(e(l)){var m=a[k];e(m)?(a.red=!0,l.red=!1,m.red=!1):e(l[j])?a=h(a,k):e(l[k])&&(a=i(a,k))}}return a},h=function(a,b){var c="left"===b?"right":"left",d=a[c];return a[c]=d[b],d[b]=a,a.red=!0,d.red=!1,d},i=function(a,b){var c="left"===b?"right":"left";return a[c]=h(a[c],c),h(a,b)},j=function(a,b,c,d){if(a){var f;if(0===d(b,a.data)){if(!a.left||!a.right){var g=a[a.left?"left":"right"];return e(a)?c.done=!0:e(g)&&(g.red=!1,c.done=!0),g}for(var h,i=a.right;null!==i.left;)h=i,i=i.left;h&&(h.left=null),a.data=i.data,b=i.data}f=-1===d(b,a.data)?"left":"right",a[f]=j(a[f],b,c,d),c.done||(a=k(a,f,c))}else c.done=!0;return a},k=function(a,b,c){var d="left"===b?"right":"left",f=a,g=f[d];if(e(g)&&(a=h(a,b),g=f[d]),null!==g)if(e(g.left)||e(g.right)){var j=f.red,k=a===f;f=(e(g[d])?h:i)(f,b),f.red=j,f.left.red=f.right.red=0,k?a=f:a[b]=f,c.done=!0}else e(f)&&(c.done=!0),f.red=0,g.red=1;return a};return d.extend({instance:{insert:function(a){this.__root=g(this.__root,a,this.compare),this.__root.red=!1},remove:function(a){var b={done:!1},c=j(this.__root,a,b,this.compare);return null!==c&&(c.red=0),this.__root=c,a},__printNode:function(d,e){var f=[];d?(this.__printNode(d.right,e+1),f.push(c(" ",e)),f.push((d.red?a:b)+":"+d.data+"\n"),console.log(f.join("")),this.__printNode(d.left,e+1)):(f.push(c(" ",e)),f.push("~"),console.log(f.join("")))}}})}();return{Tree:d,AVLTree:e,AnderssonTree:f,BinaryTree:g,RedBlackTree:h,IN_ORDER:d.IN_ORDER,PRE_ORDER:d.PRE_ORDER,POST_ORDER:d.POST_ORDER,REVERSE_ORDER:d.REVERSE_ORDER}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")).register(a("string-extended")))):"function"==typeof define?define(["extended","declare.js","is-extended","array-extended","string-extended"],function(a,b,c,e,f){return d(a().register("declare",b).register(c).register(e).register(f))}):this.leafy=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended).register(this.stringExtended))}.call(this)},{"array-extended":39,"declare.js":42,extended:43,"is-extended":53,"string-extended":57}],55:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b){var c,d;for(c in b)t.call(b,c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}function e(a,b){var c,d,f;for(c in b)t.call(b,c)&&(d=b[c],f=a[c],p(f,d)||(a[c]=r(f)&&r(d)?e(f,d):r(d)?e({},d):d));return a}function f(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)d(a,arguments[b]);return a}function g(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)e(a,arguments[b]);return a}function h(a,b){var c=a.prototype||a;return f(c,b),a}function i(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e=l(a),f=0,g=e.length;g>f;++f)d=e[f],b.call(c||a,a[d],d,a);return a}function j(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e,f=l(a),g={},h=0,i=f.length;i>h;++h)d=f[h],e=a[d],b.call(c||a,e,d,a)&&(g[d]=e);return g}function k(a){if(!r(a))throw new TypeError;for(var b=l(a),c=[],d=0,e=b.length;e>d;++d)c.push(a[b[d]]);return c}function l(a){if(!r(a))throw new TypeError;var b=[];for(var c in a)t.call(a,c)&&b.push(c);return b}function m(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d={},e=0,f=c.length;f>e;++e)b=c[e],d[a[b]]=b;return d}function n(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d=[],e=0,f=c.length;f>e;++e)b=c[e],d.push([b,a[b]]);return d}function o(a,b){if(!r(a))throw new TypeError;q(b)&&(b=[b]);for(var c,d=s(l(a),b),e={},f=0,g=d.length;g>f;++f)c=d[f],e[c]=a[c];return e}var p=b.deepEqual,q=b.isString,r=b.isHash,s=c.difference,t=Object.prototype.hasOwnProperty,u=b.isFunction,v={forEach:i,filter:j,invert:m,values:k,toArray:n,keys:l,omit:o},w={extend:h,merge:f,deepMerge:g,omit:o},x=a.define(b.isObject,w).define(r,v).define(b.isFunction,{extend:h}).expose({hash:v}).expose(w),y=x.extend;return x.extend=function(){return 1===arguments.length?y.extend.apply(x,arguments):(h.apply(null,arguments),void 0)},x}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.objectExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":39,extended:43,"is-extended":53}],56:[function(a,b,c){var d=a("__browserify_process");!function(){"use strict";function e(a,b,c,e,f,g){function h(a,b){return function(){try{l(a.apply(null,arguments)).addCallback(b).addErrback(b)}catch(c){b.errback(c)}}}function i(a,b,c){var d=(new G).callback();return v(a,function(a){d=d.then(c?a:B(null,a)),c||(d=d.then(function(a){return b.push(a),b}))}),d}function j(a){return!w(a)&&y(a.then)}function k(a){var b=new G;return a.then(A(b,"callback"),A(b,"errback")),b.promise()}function l(a){var b;return a=C(arguments),a.length?1===a.length?(a=a.pop(),j(a)?a.addCallback&&a.addErrback?(b=new G,a.addCallback(b.callback),a.addErrback(b.errback)):b=k(a):b=x(a)&&c.every(a,j)?new H(a,!0).promise():(new G).callback(a)):b=new H(c.map(a,function(a){return l(a)}),!0).promise():b=(new G).callback(a).promise(),b}function m(a,b){return function(){var c=new G,d=C(arguments);return d.push(c.resolve),a.apply(b||this,d),c.promise()}}function n(a){if(x(a))return i(a,[],!1);throw new Error("When calling promise.serial the first argument must be an array")}function o(a){if(x(a))return i(a,[],!0);throw new Error("When calling promise.serial the first argument must be an array")}function p(a,b){a=C(arguments);var c=!1;b=a.pop();var d=l(a);return function(){return c?l(b.apply(this,arguments)):(a=arguments,d.then(A(this,function(){return c=!0,b.apply(this,a)})))}}function q(){return new G}function r(a){return new H(a,!0).promise()}function s(a){return q().errback(a)}function t(a){return q().callback(a)}var u,v=c.forEach,w=e.isUndefinedOrNull,x=e.isArray,y=e.isFunction,z=e.isBoolean,A=f.bind,B=f.bindIgnore,C=g.argsToArray;if("function"==typeof setImmediate)u="undefined"!=typeof window?setImmediate.bind(window):setImmediate;else if("undefined"!=typeof d)u=function(a){d.nextTick(a)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,E={},F=E;D.port1.onmessage=function(){E=E.next;var a=E.task;delete E.task,a()},u=function(a){F=F.next={task:a},D.port2.postMessage(0)}}else u=function(a){setTimeout(a,0)};var G=a({instance:{__fired:!1,__results:null,__error:null,__errorCbs:null,__cbs:null,constructor:function(){this.__errorCbs=[],this.__cbs=[],f.bindAll(this,["callback","errback","resolve","classic","__resolve","addCallback","addErrback"])},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__error?this.__errorCbs:this.__cbs,c=b.length,d=this.__error||this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(this,b)})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=a.callback),this.__fired&&this.__results?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=a.errback),this.__fired&&this.__error?this.__callNextTick(a,this.__error):this.__errorCbs.push(a)),this},callback:function(){return this.__fired||(this.__results=arguments,this.__resolve()),this.promise()},errback:function(){return this.__fired||(this.__error=arguments,this.__resolve()),this.promise()},resolve:function(a){return a?this.errback(a):this.callback.apply(this,C(arguments,1)),this},classic:function(a){return"function"==typeof a&&(this.addErrback(function(b){a(b)}),this.addCallback(function(){a.apply(this,[null].concat(C(arguments)))})),this},then:function(a,b){var c=new G,d=c;return y(b)&&(d=h(b,c)),this.addErrback(d),y(a)?this.addCallback(h(a,c)):this.addCallback(c),c.promise()},both:function(a){return this.then(a,a)},promise:function(){var a={then:A(this,"then"),both:A(this,"both"),promise:function(){return a}};return v(["addCallback","addErrback","classic"],function(b){a[b]=A(this,function(){return this[b].apply(this,arguments),a})},this),a}}}),H=G.extend({instance:{__results:null,__errors:null,__promiseLength:0,__defLength:0,__firedLength:0,normalizeResults:!1,constructor:function(a,b){this.__errors=[],this.__results=[],this.normalizeResults=z(b)?b:!1,this._super(arguments),a&&a.length?(this.__defLength=a.length,v(a,this.__addPromise,this)):this.__resolve()},__addPromise:function(a,b){a.then(A(this,function(){var a=C(arguments);a.unshift(b),this.callback.apply(this,a)}),A(this,function(){var a=C(arguments);a.unshift(b),this.errback.apply(this,a)}))},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__errors.length?this.__errorCbs:this.__cbs,c=b.length,d=this.__errors.length?this.__errors:this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(null,[b])})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=A(a,"callback")),this.__fired&&!this.__errors.length?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=A(a,"errback")),this.__fired&&this.__errors.length?this.__callNextTick(a,this.__errors):this.__errorCbs.push(a)),this},callback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__results[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()},errback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__errors[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()}}});return b.define({isPromiseLike:j}).expose({isPromiseLike:j,when:l,wrap:m,wait:p,serial:n,chain:o,Promise:G,PromiseList:H,promise:q,defer:q,deferredList:r,reject:s,resolve:t})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("declare.js"),a("extended"),a("array-extended"),a("is-extended"),a("function-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["declare","extended","array-extended","is-extended","function-extended","arguments-extended"],function(a,b,c,d,f,g){return e(a,b,c,d,f,g)}):this.promiseExtended=e(this.declare,this.extended,this.arrayExtended,this.isExtended,this.functionExtended,this.argumentsExtended)}.call(this)},{__browserify_process:51,"arguments-extended":38,"array-extended":39,"declare.js":42,extended:43,"function-extended":46,"is-extended":53}],57:[function(a,b,c){!function(){"use strict";function d(a,b,c,d){function e(a,b){var c=a;if(x.test(b)){var d=b.match(x),e=d[1],f=d[3],g=d[4];g&&(g=parseInt(g,10),c=c.length0?"+":"")+d),k&&(k=parseInt(k,10),d=d.lengthe;)d?a+=c:a=c+a,e++;return a}function i(a,c,d){var e=a;if(b.isString(e)){if(a.length>c)if(d){var f=a.length;e=a.substring(f-c,f)}else e=a.substring(0,c)}else e=i(""+e,c);return e}function j(a,d){if(d instanceof Array){var h=0,i=d.length;return a.replace(v,function(a,b,j){var k,l;if(!(i>h))return a;if(k=d[h++],"%s"===a||"%d"===a||"%D"===a)l=k+"";else if("%Z"===a)l=k.toUTCString();else if("%j"===a)try{l=s(k)}catch(m){throw new Error("stringExtended.format : Unable to parse json from ",k)}else switch(b=b.replace(/^\[|\]$/g,""),j){case"s":l=e(k,b);break;case"d":l=f(k,b);break;case"j":l=g(k,b);break;case"D":l=c.format(k,b);break;case"Z":l=c.format(k,b,!0)}return l})}if(t(d))return a.replace(w,function(a,h,i){if(i=d[i],!b.isUndefined(i)){if(!h)return""+i;if(b.isString(i))return e(i,h);if(b.isNumber(i))return f(i,h);if(b.isDate(i))return c.format(i,h);if(b.isObject(i))return g(i,h)}return a});var k=u.call(arguments).slice(1);return j(a,k)}function k(a,b){var c=[];return a&&(a.indexOf(b)>0?c=a.replace(/\s+/g,"").split(b):c.push(a)),c}function l(a,b){var c=[];if(b)for(var d=0;b>d;d++)c.push(a);return c.join("")}function m(a,c){var d,e,f;if(c)if(b.isArray(a))for(d=[],e=0,f=a.length;f>e;e++)d.push(m(a[e],c));else if(c instanceof Array)for(d=a,e=0,f=c.length;f>e;e++)d=m(d,c[e]);else c in z&&(d="["+z[c]+"m"+a+"");return d}function n(a,b){return a.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(a){return b&&-1!==d.indexOf(b,a)?a:"\\"+a})}function o(a){return a.replace(/^\s*|\s*$/g,"")}function p(a){return a.replace(/^\s*/,"")}function q(a){return a.replace(/\s*$/,"")}function r(a){return 0===a.length}var s;"undefined"==typeof JSON?function(){function a(a){return 10>a?"0"+a:a}function c(c){return b.isDate(c)?isFinite(c.valueOf())?c.getUTCFullYear()+"-"+a(c.getUTCMonth()+1)+"-"+a(c.getUTCDate())+"T"+a(c.getUTCHours())+":"+a(c.getUTCMinutes())+":"+a(c.getUTCSeconds())+"Z":null:i(c)?c.valueOf():c}function d(a){return j.lastIndex=0,j.test(a)?'"'+a.replace(j,function(a){var b=k[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(a,b){var i,j,k,l,m,n=f,o=b[a];switch(o&&(o=c(o)),"function"==typeof h&&(o=h.call(b,a,o)),typeof o){case"string":return d(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";if(f+=g,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(l=o.length,i=0;l>i;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":f?"[\n"+f+m.join(",\n"+f)+"\n"+n+"]":"["+m.join(",")+"]",f=n,k}if(h&&"object"==typeof h)for(l=h.length,i=0;l>i;i+=1)"string"==typeof h[i]&&(j=h[i],k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));else for(j in o)Object.prototype.hasOwnProperty.call(o,j)&&(k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));return k=0===m.length?"{}":f?"{\n"+f+m.join(",\n"+f)+"\n"+n+"}":"{"+m.join(",")+"}",f=n,k}}var f,g,h,i=b.tester().isString().isNumber().isBoolean().tester(),j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};s=function(a,b,c){var d;if(f="",g="","number"==typeof c)for(d=0;c>d;d+=1)g+=" ";else"string"==typeof c&&(g=c);if(h=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return e("",{"":a})}}():s=JSON.stringify;var t=b.isHash,u=Array.prototype.slice,v=/%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g,w=/\{(?:\[([^\[|\]]*)\])?(\w+)\}/g,x=/(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/,y=/([1-9][0-9]*)$/g,z={bold:1,bright:1,italic:3,underline:4,blink:5,inverse:7,crossedOut:9,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,redBackground:41,greenBackground:42,yellowBackground:43,blueBackground:44,magentaBackground:45,cyanBackground:46,whiteBackground:47,encircled:52,overlined:53,grey:90,black:90},A={SMILEY:"☺",SOLID_SMILEY:"☻",HEART:"♥",DIAMOND:"♦",CLOVE:"♣",SPADE:"♠",DOT:"•",SQUARE_CIRCLE:"◘",CIRCLE:"○",FILLED_SQUARE_CIRCLE:"◙",MALE:"♂",FEMALE:"♀",EIGHT_NOTE:"♪",DOUBLE_EIGHTH_NOTE:"♫",SUN:"☼",PLAY:"►",REWIND:"◄",UP_DOWN:"↕",PILCROW:"¶",SECTION:"§",THICK_MINUS:"▬",SMALL_UP_DOWN:"↨",UP_ARROW:"↑",DOWN_ARROW:"↓",RIGHT_ARROW:"→",LEFT_ARROW:"←",RIGHT_ANGLE:"∟",LEFT_RIGHT_ARROW:"↔",TRIANGLE:"▲",DOWN_TRIANGLE:"▼",HOUSE:"⌂",C_CEDILLA:"Ç",U_UMLAUT:"ü",E_ACCENT:"é",A_LOWER_CIRCUMFLEX:"â",A_LOWER_UMLAUT:"ä",A_LOWER_GRAVE_ACCENT:"à",A_LOWER_CIRCLE_OVER:"å",C_LOWER_CIRCUMFLEX:"ç",E_LOWER_CIRCUMFLEX:"ê",E_LOWER_UMLAUT:"ë",E_LOWER_GRAVE_ACCENT:"è",I_LOWER_UMLAUT:"ï",I_LOWER_CIRCUMFLEX:"î",I_LOWER_GRAVE_ACCENT:"ì",A_UPPER_UMLAUT:"Ä",A_UPPER_CIRCLE:"Å",E_UPPER_ACCENT:"É",A_E_LOWER:"æ",A_E_UPPER:"Æ",O_LOWER_CIRCUMFLEX:"ô",O_LOWER_UMLAUT:"ö",O_LOWER_GRAVE_ACCENT:"ò",U_LOWER_CIRCUMFLEX:"û",U_LOWER_GRAVE_ACCENT:"ù",Y_LOWER_UMLAUT:"ÿ",O_UPPER_UMLAUT:"Ö",U_UPPER_UMLAUT:"Ü",CENTS:"¢",POUND:"£",YEN:"¥",CURRENCY:"¤",PTS:"₧",FUNCTION:"ƒ",A_LOWER_ACCENT:"á",I_LOWER_ACCENT:"í",O_LOWER_ACCENT:"ó",U_LOWER_ACCENT:"ú",N_LOWER_TILDE:"ñ",N_UPPER_TILDE:"Ñ",A_SUPER:"ª",O_SUPER:"º",UPSIDEDOWN_QUESTION:"¿",SIDEWAYS_L:"⌐",NEGATION:"¬",ONE_HALF:"½",ONE_FOURTH:"¼",UPSIDEDOWN_EXCLAMATION:"¡",DOUBLE_LEFT:"«",DOUBLE_RIGHT:"»",LIGHT_SHADED_BOX:"░",MEDIUM_SHADED_BOX:"▒",DARK_SHADED_BOX:"▓",VERTICAL_LINE:"│",MAZE__SINGLE_RIGHT_T:"┤",MAZE_SINGLE_RIGHT_TOP:"┐",MAZE_SINGLE_RIGHT_BOTTOM_SMALL:"┘",MAZE_SINGLE_LEFT_TOP_SMALL:"┌",MAZE_SINGLE_LEFT_BOTTOM_SMALL:"└",MAZE_SINGLE_LEFT_T:"├",MAZE_SINGLE_BOTTOM_T:"┴",MAZE_SINGLE_TOP_T:"┬",MAZE_SINGLE_CENTER:"┼",MAZE_SINGLE_HORIZONTAL_LINE:"─",MAZE_SINGLE_RIGHT_DOUBLECENTER_T:"╡",MAZE_SINGLE_RIGHT_DOUBLE_BL:"╛",MAZE_SINGLE_RIGHT_DOUBLE_T:"╢",MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP:"╖",MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP:"╕",MAZE_SINGLE_LEFT_DOUBLE_T:"╞",MAZE_SINGLE_BOTTOM_DOUBLE_T:"╧",MAZE_SINGLE_TOP_DOUBLE_T:"╤",MAZE_SINGLE_TOP_DOUBLECENTER_T:"╥",MAZE_SINGLE_BOTTOM_DOUBLECENTER_T:"╨",MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM:"╘",MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP:"╒",MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP:"╓",MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM:"╙",MAZE_SINGLE_LEFT_TOP:"Γ",MAZE_SINGLE_RIGHT_BOTTOM:"╜",MAZE_SINGLE_LEFT_CENTER:"╟",MAZE_SINGLE_DOUBLECENTER_CENTER:"╫",MAZE_SINGLE_DOUBLECROSS_CENTER:"╪",MAZE_DOUBLE_LEFT_CENTER:"╣",MAZE_DOUBLE_VERTICAL:"║",MAZE_DOUBLE_RIGHT_TOP:"╗",MAZE_DOUBLE_RIGHT_BOTTOM:"╝",MAZE_DOUBLE_LEFT_BOTTOM:"╚",MAZE_DOUBLE_LEFT_TOP:"╔",MAZE_DOUBLE_BOTTOM_T:"╩",MAZE_DOUBLE_TOP_T:"╦",MAZE_DOUBLE_LEFT_T:"╠",MAZE_DOUBLE_HORIZONTAL:"═",MAZE_DOUBLE_CROSS:"╬",SOLID_RECTANGLE:"█",THICK_LEFT_VERTICAL:"▌",THICK_RIGHT_VERTICAL:"▐",SOLID_SMALL_RECTANGLE_BOTTOM:"▄",SOLID_SMALL_RECTANGLE_TOP:"▀",PHI_UPPER:"Φ",INFINITY:"∞",INTERSECTION:"∩",DEFINITION:"≡",PLUS_MINUS:"±",GT_EQ:"≥",LT_EQ:"≤",THEREFORE:"⌠",SINCE:"∵",DOESNOT_EXIST:"∄",EXISTS:"∃",FOR_ALL:"∀",EXCLUSIVE_OR:"⊕",BECAUSE:"⌡",DIVIDE:"÷",APPROX:"≈",DEGREE:"°",BOLD_DOT:"∙",DOT_SMALL:"·",CHECK:"√",ITALIC_X:"✗",SUPER_N:"ⁿ",SQUARED:"²",CUBED:"³",SOLID_BOX:"■",PERMILE:"‰",REGISTERED_TM:"®",COPYRIGHT:"©",TRADEMARK:"™",BETA:"β",GAMMA:"γ",ZETA:"ζ",ETA:"η",IOTA:"ι",KAPPA:"κ",LAMBDA:"λ",NU:"ν",XI:"ξ",OMICRON:"ο",RHO:"ρ",UPSILON:"υ",CHI_LOWER:"φ",CHI_UPPER:"χ",PSI:"ψ",ALPHA:"α",ESZETT:"ß",PI:"π",SIGMA_UPPER:"Σ",SIGMA_LOWER:"σ",MU:"µ",TAU:"τ",THETA:"Θ",OMEGA:"Ω",DELTA:"δ",PHI_LOWER:"φ",EPSILON:"ε"},B={toArray:k,pad:h,truncate:i,multiply:l,format:j,style:m,escape:n,trim:o,trimLeft:p,trimRight:q,isEmpty:r}; -return a.define(b.isString,B).define(b.isArray,{style:m}).expose(B).expose({characters:A})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("date-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","date-extended","array-extended"],function(a,b,c,e){return d(a,b,c,e)}):this.stringExtended=d(this.extended,this.isExtended,this.dateExtended,this.arrayExtended)}.call(this)},{"array-extended":39,"date-extended":40,extended:43,"is-extended":53}]},{},[1]); \ No newline at end of file +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gc&&g>c&&c++;);var h=d[c]-e[c];return h||(h=f-g),h}function g(a,b){return a.recency-b.recency}var h=a("./extended").map,i={salience:d,bucketCounter:e,factRecency:f,activationRecency:g};c.strategies=i,c.strategy=function(a){a=h(a,function(a){return i[a]});var b=a.length;return function(c,d){var e=-1,f=0,g=c===d||c.name===d.name&&c.hashCode===d.hashCode;if(!g){for(;++e0?1:-1}return f}}},{"./extended":12}],8:[function(a,b,c){"use strict";var d,e=a("./extended"),f=e.deepEqual,g=e.merge,h=e.instanceOf,i=e.filter,j=e.declare,k=0,l=j({instance:{constructor:function(b,c){d||(d=a("./constraintMatcher")),this.id=k++,this.type=b,this.constraint=c},assert:function(){throw new Error("not implemented")},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return[this.get("alias")]}}}});l.extend({instance:{constructor:function(a){this._super(["object",a])},assert:function(a){return a instanceof this.constraint||a.constructor===this.constraint},equal:function(a){return h(a,this._static)&&this.constraint===a.constraint}}}).as(c,"ObjectConstraint"),l.extend({instance:{constructor:function(a,b){this._super(["equality",a]),b=b||{},this.pattern=b.pattern,this._matcher=d.getMatcher(a,b.scope||{})},assert:function(a){return this._matcher(a)}}}).as(c,"EqualityConstraint"),l.extend({instance:{constructor:function(){this._super(["equality",[!0]])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")},assert:function(){return!0}}}).as(c,"TrueConstraint"),l.extend({instance:{constructor:function(a,b){this.cache={},this._super(["reference",a]),b=b||{},this.values=[],this.pattern=b.pattern,this._options=b,this._matcher=d.getMatcher(a,b.scope||{})},assert:function(a){try{return this._matcher(a)}catch(b){throw new Error("Error with evaluating pattern "+this.pattern+" "+b.message)}},merge:function(a){var b=this;return a instanceof this._static&&(b=new this._static([this.constraint,a.constraint,"and"],g({},this._options,this._options)),b._alias=this._alias||a._alias,b.vars=this.vars.concat(a.vars)),b},equal:function(a){return h(a,this._static)&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return this.vars},alias:function(){return this._alias}},setters:{alias:function(a){this._alias=a,this.vars=i(d.getIdentifiers(this.constraint),function(b){return b!==a})}}}}).as(c,"ReferenceConstraint"),l.extend({instance:{constructor:function(a){this._super(["hash",a])},equal:function(a){return e.instanceOf(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"HashConstraint"),l.extend({instance:{constructor:function(a,b){this.type="from",this.prop=a,this.constraints=b},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&f(this.constraints,a.constraints)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"FromConstraint")},{"./constraintMatcher":9,"./extended":12}],9:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isArray,f=d.forEach,g=d.some,h=d.map,i=d.indexOf,j=d.isNumber,k=d.removeDuplicates,l=a("./constraint"),m={indexOf:d.indexOf,now:function(){return new Date},Date:function(a,b,c,d,e,f,g){var h=new Date;return j(a)&&h.setYear(a),j(b)&&h.setMonth(b),j(c)&&h.setDate(c),j(d)&&h.setHours(d),j(e)&&h.setMinutes(e),j(f)&&h.setSeconds(f),j(g)&&h.setMilliseconds(g),h},lengthOf:function(a,b){return a.length===b},isTrue:function(a){return a===!0},isFalse:function(a){return a===!1},isNotNull:function(a){return null!==a},dateCmp:function(a,b){return d.compare(a,b)}};f(["years","days","months","hours","minutes","seconds"],function(a){m[a+"FromNow"]=d[a+"FromNow"],m[a+"Ago"]=d[a+"Ago"]}),f(["isArray","isNumber","isHash","isObject","isDate","isBoolean","isString","isRegExp","isNull","isEmpty","isUndefined","isDefined","isUndefinedOrNull","isPromiseLike","isFunction","deepEqual"],function(a){var b=d[a];m[a]=function(){return b.apply(d,arguments)}});var n={equal:function(a,b){var c=!1;return a===b?c=!0:a[2]===b[2]&&(c=-1!==i(["string","number","boolean","regexp","identifier","null"],a[2])?a[0]===b[0]:"unary"===a[2]||"logicalNot"===a[2]?this.equal(a[0],b[0]):this.equal(a[0],b[0])&&this.equal(a[1],b[1])),c},getIdentifiers:function(a){var b=[],c=a[2];if("identifier"===c)return[a[0]];if("function"===c)b=b.concat(this.getIdentifiers(a[0])).concat(this.getIdentifiers(a[1]));else if("string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c)if("prop"===c){if(b=b.concat(this.getIdentifiers(a[0])),a[1])for(var d=a[1];e(d);){if("function"===d[2]){b=b.concat(this.getIdentifiers(d[1]));break}d=d[1]}}else a[0]&&(b=b.concat(this.getIdentifiers(a[0]))),a[1]&&(b=b.concat(this.getIdentifiers(a[1])));return k(b)},toConstraints:function(a,b){var c=[],d=b.alias,e=b.scope||{},f=a[2];return"and"===f?c=c.concat(this.toConstraints(a[0],b)).concat(this.toConstraints(a[1],b)):("composite"===f||"or"===f||"lt"===f||"gt"===f||"lte"===f||"gte"===f||"like"===f||"notLike"===f||"eq"===f||"neq"===f||"in"===f||"notIn"===f||"prop"===f||"propLookup"===f||"function"===f||"logicalNot"===f)&&(g(this.getIdentifiers(a),function(a){return!(a===d||a in m||a in e)})?c.push(new l.ReferenceConstraint(a,b)):c.push(new l.EqualityConstraint(a,b))),c},parse:function(a){return this[a[2]](a[0],a[1])},composite:function(a){return this.parse(a)},and:function(a,b){return["(",this.parse(a),"&&",this.parse(b),")"].join(" ")},or:function(a,b){return["(",this.parse(a),"||",this.parse(b),")"].join(" ")},prop:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"['",this.parse(b),"']"].join("")},propLookup:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"[",this.parse(b),"]"].join("")},unary:function(a){return-1*this.parse(a)},plus:function(a,b){return[this.parse(a),"+",this.parse(b)].join(" ")},minus:function(a,b){return[this.parse(a),"-",this.parse(b)].join(" ")},mult:function(a,b){return[this.parse(a),"*",this.parse(b)].join(" ")},div:function(a,b){return[this.parse(a),"/",this.parse(b)].join(" ")},mod:function(a,b){return[this.parse(a),"%",this.parse(b)].join(" ")},lt:function(a,b){return[this.parse(a),"<",this.parse(b)].join(" ")},gt:function(a,b){return[this.parse(a),">",this.parse(b)].join(" ")},lte:function(a,b){return[this.parse(a),"<=",this.parse(b)].join(" ")},gte:function(a,b){return[this.parse(a),">=",this.parse(b)].join(" ")},like:function(a,b){return[this.parse(b),".test(",this.parse(a),")"].join("")},notLike:function(a,b){return["!",this.parse(b),".test(",this.parse(a),")"].join("")},eq:function(a,b){return[this.parse(a),"===",this.parse(b)].join(" ")},neq:function(a,b){return[this.parse(a),"!==",this.parse(b)].join(" ")},"in":function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) != -1"].join("")},notIn:function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) == -1"].join("")},arguments:function(a,b){var c=[];return a&&c.push(this.parse(a)),b&&c.push(this.parse(b)),c.join(",")},array:function(a){var b=[];return a?(b=this.parse(a),e(b)?b:["[",b,"]"].join("")):["[",b.join(","),"]"].join("")},"function":function(a,b){var c=this.parse(b);return[this.parse(a),"(",c,")"].join("")},string:function(a){return"'"+a+"'"},number:function(a){return a},"boolean":function(a){return a},regexp:function(a){return a},identifier:function(a){return a},"null":function(){return"null"},logicalNot:function(a){return["!(",this.parse(a),")"].join("")}},o=c.toJs=function(a,b){var c=n.parse(a);b=b||{};var d=n.getIdentifiers(a),e="var indexOf = definedFuncs.indexOf;"+h(d,function(a){var c=["var ",a," = "];return m.hasOwnProperty(a)?c.push("definedFuncs['",a,"']"):b.hasOwnProperty(a)?c.push("scope['",a,"']"):c.push("'",a,"' in fact ? fact['",a,"'] : hash['",a,"']"),c.push(";"),c.join("")}).join("")+" return !!("+c+");",f=new Function("fact, hash, definedFuncs, scope",e);return function(a,c){return f(a,c,m,b)}};c.getMatcher=function(a,b){return o(a,b)},c.toConstraints=function(a,b){return n.toConstraints(a,b)},c.equal=function(a,b){return n.equal(a,b)},c.getIdentifiers=function(a){return n.getIdentifiers(a)}},{"./constraint":8,"./extended":12}],10:[function(a,b){"use strict";var c=a("./extended"),d=c.isBoolean,e=c.declare,f=c.merge,g=c.union,h=Array.prototype.slice,i=e({instance:{constructor:function(a){this.isMatch=!0,a instanceof this._static?(this.isMatch=a.isMatch,this.facts=h.call(a.facts),this.factIds=h.call(a.factIds),this.hashCode=this.factIds.join(":"),this.factHash=f({},a.factHash),this.recency=h.call(a.recency)):a?(this.facts=[a],this.factIds=[a.id],this.recency=[a.recency],this.hashCode=a.id+"",this.factHash=a.factHash||{}):(this.facts=[],this.factIds=[],this.factHash={},this.hashCode="")},merge:function(a){var b=new this._static;return b.isMatch=a.isMatch,b.facts=this.facts.concat(a.facts),b.factIds=this.factIds.concat(a.factIds),b.hashCode=b.factIds.join(":"),b.factHash=f({},this.factHash,a.factHash),b.recency=g(this.recency,a.recency),b}}}),j=e({instance:{match:null,factHash:null,fact:null,hashCode:null,paths:null,constructor:function(a,b,c){this.fact=a,this.paths=b||null;var d=this.match=c||new i(a);this.factHash=d.factHash,this.hashCode=d.hashCode,this.factIds=d.factIds},set:function(a,b){return this.factHash[a]=b,this},isMatch:function(a){return d(a)?(this.match.isMatch=a,this):this.match.isMatch},mergeMatch:function(a){var b=this.match=this.match.merge(a);return this.factHash=b.factHash,this.hashCode=b.hashCode,this.factIds=b.factIds,this},clone:function(a,b,c){return new j(a||this.fact,b||this.path,c||this.match)}}}).as(b)},{"./extended":12}],11:[function(a,b){var c=a("./extended"),d=c.Promise,e=a("./nextTick"),f=c.isPromiseLike;d.extend({instance:{looping:!1,constructor:function(a,b){this._super([]),this.flow=a,this.agenda=a.agenda,this.rootNode=a.rootNode,this.matchUntilHalt=!!b,c.bindAll(this,["onAlter","callNext"])},halt:function(){this.__halted=!0,this.looping||this.callback()},onAlter:function(){this.flowAltered=!0,this.looping||!this.matchUntilHalt||this.__halted||this.callNext()},setup:function(){var a=this.flow;this.rootNode.resetCounter(),a.on("assert",this.onAlter),a.on("modify",this.onAlter),a.on("retract",this.onAlter)},tearDown:function(){var a=this.flow;a.removeListener("assert",this.onAlter),a.removeListener("modify",this.onAlter),a.removeListener("retract",this.onAlter)},__handleAsyncNext:function(a){var b=this,c=b.agenda;return a.addCallback(function(){b.looping=!1,c.isEmpty()?(!b.matchUntilHalt||b.__halted)&&b.callback():(b.flowAltered&&(b.rootNode.incrementCounter(),b.flowAltered=!1),b.__halted?b.callback():b.callNext()),b=null}).addErrback(this.errback)},__handleSyncNext:function(a){return this.looping=!1,this.agenda.isEmpty()||this.flowAltered&&(this.rootNode.incrementCounter(),this.flowAltered=!1),a&&!this.__halted?e(this.callNext):(!this.matchUntilHalt||this.__halted)&&this.callback(),a},callback:function(){this.tearDown(),this._super(arguments)},callNext:function(){this.looping=!0;var a=this.agenda.fireNext();return f(a)?this.__handleAsyncNext(a):this.__handleSyncNext(a)},execute:function(){return this.setup(),this.callNext(),this}}}).as(b)},{"./extended":12,"./nextTick":17}],12:[function(a,b){function c(a){var b=a.match(/(\w+)\(\)$/);return b?(a=b[1],function(b){return b[a]()}):function(b){return b[a]}}function d(a){if(a=a.split("."),1===a.length)return c(a[0]);var b=f(a,function(a){return c(a)}),d=b.length;return function(a){for(var c=-1,e=a;++cb;b++)a.assert(arguments[b]);return a},containsRule:function(a){return c.some(this.__rules,function(b){return b.name===a})}},"static":{getFlow:function(a){return j[a]},hasFlow:function(a){return c.has(j,a)},deleteFlow:function(a){return d(a,k)&&(a=a.name),delete j[a],k},deleteFlows:function(){for(var a in j)a in j&&delete j[a];return k},create:function(a,b){return new k(a,b)}}}).as(b)},{"./extended":12,"./flow":13,"./pattern":38,"./rule":39}],15:[function(a,b,c){"use strict";function d(a){return/\.nools$/.test(a)}function e(a){var b;return b=d(a)?i.parse(g.readFileSync(a,"utf8"),a):i.parse(a)}var f=a("./extended"),g=a("fs"),h=a("path"),i=a("./compile"),j=a("./flowContainer");c.Flow=j,c.getFlow=j.getFlow,c.hasFlow=j.hasFlow,c.deleteFlow=function(a){return j.deleteFlow(a),this},c.deleteFlows=function(){return j.deleteFlows(),this},c.flow=j.create,c.compile=function(a,b,c){if(f.isFunction(b)?(c=b,b={}):(b=b||{},c=null),f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),!b.name)throw new Error("Name required when compiling nools source");return i.compile(a,b,c,j)},c.transpile=function(a,b){return b=b||{},f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),i.transpile(a,b)},c.parse=e},{"./compile":5,"./extended":12,"./flowContainer":14,fs:51,path:52}],16:[function(a,b){var c=a("declare.js");c({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null},push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,d},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},clear:function(){this.head=this.tail=null,this.length=0}}}).as(b)},{"declare.js":45}],17:[function(a,b){var c,d=a("__browserify_process"),e=a("./extended");if("function"==typeof setImmediate)c="undefined"!=typeof window?e.bind(window,setImmediate):setImmediate;else if("undefined"!=typeof d)c=d.nextTick;else if("undefined"!=typeof MessageChannel){var f=new MessageChannel,g={},h=g;f.port1.onmessage=function(){g=g.next;var a=g.task;delete g.task,a()},c=function(a){h=h.next={task:a},f.port2.postMessage(0)}}else c=function(a){setTimeout(a,0)};b.exports=c},{"./extended":12,__browserify_process:54}],18:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias")},toString:function(){return"AliasNode"+this.__count},assert:function(a){return this.__propagate("assert",a.set(this.alias,a.fact.object))},modify:function(a){return this.__propagate("modify",a.set(this.alias,a.fact.object))},retract:function(a){return this.__propagate("retract",a.set(this.alias,a.fact.object))},equal:function(a){return a instanceof this._static&&this.alias===a.alias}}}).as(b)},{"./alphaNode":19}],19:[function(a,b){"use strict";var c=a("./node");c.extend({instance:{constructor:function(a){this._super([]),this.constraint=a},toString:function(){return"AlphaNode "+this.__count},equal:function(a){return this.constraint.equal(a.constraint)}}}).as(b)},{"./node":27}],20:[function(a,b){function c(a){for(var b=[],c=a.paths,d=-1,e=c.length;++dd;d++)this.__checkMatch(a,c[d],!0);else this.__checkMatch(a,c,!0)},__checkMatch:function(a,b,c){var d;return(d=this.__createMatch(a,b)).isMatch()&&c&&this.__propagate("assert",d.clone()),d},__createMatch:function(a,b){if(this.type.assert(b)){var c,d=this.workingMemory.getFactHandle(b,!0),e=new i(d).set(this.alias,b),f=d.id,g=e.factHash,h=a.factHash;for(var j in h)g[j]=h[j];for(var k=this.__equalityConstraints,l=this.__variables,m=-1,o=k.length;++mc;c++)b=this.__checkMatch(a,k[c],!1),b.isMatch()&&(e=b.fact.id,e in j?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone()));else b=this.__checkMatch(a,k,!1),b.isMatch()&&(e=b.fact.id,e in j?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone()));for(c in j)c in i||(this.removeFromFromMemory(j[c]),this.__propagate("retract",j[c].clone()))}else this.assertLeft(a);f=a.fact,e=f.id;var l=this.fromMemory[e];if(this.fromMemory[e]={},l){var n,o,p,q,r=f.object;for(c in l)o=l[c],n=o[0],p=o[1],q=p.isMatch(),n.hashCode!==a.hashCode&&(b=this.__createMatch(n,r,!1),q&&this.__propagate("retract",p.clone()),b.isMatch()&&this.__propagate(q?"modify":"assert",b.clone())) +}},assertLeft:function(a){this.__addToLeftMemory(a),a.fromMatches={},this.__createMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")},toString:function(){return"FromNode"+this.__count}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":24}],22:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.plucker,k=d.forEach,l=d.isArray;c.extend({instance:{constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.pattern=a,this.type=a.get("constraints")[0],this.alias=a.get("alias"),this.plucker=j(this.from=a.from),this.fromMemory={};var c=this.__equalityConstraints=[],d=[];k(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},retractLeft:function(a){var b=this.removeFromLeftMemory(a);b&&(b=b.data,b.blocked||this.__propagate("retract",b.clone()))},__modify:function(a,b){var c=b.blocked,d=a.factHash,e=this.plucker(d);if(l(e)){for(var f=0,g=e.length;g>f;f++)if(this.__isMatch(a,e[f],!0)){a.blocked=!0;break}}else a.blocked=this.__isMatch(a,e,!0);var h=a.blocked;h?c||this.__propagate("retract",b.clone()):c?this.__propagate("assert",a.clone()):this.__propagate("modify",a.clone())},modifyLeft:function(a){var b=this.removeFromLeftMemory(a);if(!b)throw new Error;this.__addToLeftMemory(a),this.__modify(a,b.data);var c=this.fromMemory[a.fact.id];if(this.fromMemory[a.fact.id]={},c)for(var d in c)if(d!==a.hashCode){var e=c[d];b=this.removeFromLeftMemory(e),b&&(e=e.clone(),e.blocked=!1,this.__addToLeftMemory(e),this.__modify(e,b.data))}},__findMatches:function(a){var b=a.factHash,c=this.plucker(b),d=!1;if(l(c)){for(var e=0,f=c.length;f>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,void 0;this.__propagate("assert",a.clone())}else(a.blocked=this.__isMatch(a,c,!0))||this.__propagate("assert",a.clone());return d},__isMatch:function(a,b,c){var d=!1;if(this.type.assert(b)){var e=this.workingMemory.getFactHandle(b),f=new i(e,null).mergeMatch(a.match).set(this.alias,b);if(c){var g=this.fromMemory[e.id];g||(g=this.fromMemory[e.id]={}),g[a.hashCode]=a}for(var h=f.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k].assert(h)){d=!1;break}d=!0}}return d},removeFromLeftMemory:function(){return this._super(arguments)},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")},retractRight:function(){throw new Error("Shouldnt have gotten here")},toString:function(){return"FromNode"+this.__count}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":24}],23:[function(a,b,c){"use strict";var d=a("../extended"),e=d.forEach,f=d.some,g=d.declare,h=a("../pattern.js"),i=h.ObjectPattern,j=h.FromPattern,k=h.FromNotPattern,l=h.NotPattern,m=h.CompositePattern,n=h.InitialFactPattern,o=a("../constraint"),p=o.HashConstraint,q=o.ReferenceConstraint,r=a("./aliasNode"),s=a("./equalityNode"),t=a("./joinNode"),u=a("./notNode"),v=a("./fromNode"),w=a("./fromNotNode"),x=a("./leftAdapterNode"),y=a("./rightAdapterNode"),z=a("./typeNode"),A=a("./terminalNode"),B=a("./propertyNode");g({instance:{constructor:function(a,b){this.terminalNodes=[],this.joinNodes=[],this.nodes=[],this.constraints=[],this.typeNodes=[],this.__ruleCount=0,this.bucket={counter:0,recency:0},this.agendaTree=b,this.workingMemory=a},assertRule:function(a){var b=new A(this.bucket,this.__ruleCount++,a,this.agendaTree);this.__addToNetwork(a,a.pattern,b),this.__mergeJoinNodes(),this.terminalNodes.push(b)},resetCounter:function(){this.bucket.counter=0},incrementCounter:function(){this.bucket.counter++},assertFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].assert(a)},retractFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].retract(a)},modifyFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].modify(a)},containsRule:function(a){return f(this.terminalNodes,function(b){return b.rule.name===a})},dispose:function(){for(var a=this.typeNodes,b=a.length-1;b>=0;b--)a[b].dispose()},__mergeJoinNodes:function(){for(var a=this.joinNodes,b=0;b=0;c--){var d=b[c];if(a.equal(d))return d}return b.push(a),a},__createTypeNode:function(a,b){for(var c=new z(b.get("constraints")[0]),d=this.typeNodes,e=d.length-1;e>=0;e--){var f=d[e];if(c.equal(f))return f}return d.push(c),c},__createEqualityNode:function(a,b){return this.__checkEqual(new s(b)).addRule(a)},__createPropertyNode:function(a,b){return this.__checkEqual(new B(b)).addRule(a)},__createAliasNode:function(a,b){return this.__checkEqual(new r(b)).addRule(a)},__createAdapterNode:function(a,b){return("left"===b?new x:new y).addRule(a)},__createJoinNode:function(a,b,c,d){var e;b.rightPattern instanceof l?e=new u:b.rightPattern instanceof k?e=new w(b.rightPattern,this.workingMemory):b.rightPattern instanceof j?e=new v(b.rightPattern,this.workingMemory):(e=new t,this.joinNodes.push(e)),e.__rule__=a;var f=e;if(c instanceof t){var g=this.__createAdapterNode(a,d);f.addOutNode(g,b),f=g}return f.addOutNode(c,b),e.addRule(a)},__addToNetwork:function(a,b,c,d){b instanceof i?!(b instanceof l||b instanceof j||b instanceof k)||d&&"left"!==d?this.__createAlphaNode(a,b,c,d):b instanceof k?this.__createBetaNode(a,new m(new n,b),c,d):this.__createBetaNode(a,new m(new n,b),c,d):b instanceof m&&this.__createBetaNode(a,b,c,d)},__createBetaNode:function(a,b,c,d){var e=this.__createJoinNode(a,b,c,d);return this.__addToNetwork(a,b.rightPattern,e,"right"),this.__addToNetwork(a,b.leftPattern,e,"left"),c.addParentNode(e),e},__createAlphaNode:function(a,b,c,d){var e,f;if(!(b instanceof j)){var g=b.get("constraints");e=this.__createTypeNode(a,b);var h=this.__createAliasNode(a,b);e.addOutNode(h,b),h.addParentNode(e),f=h;for(var i=g.length-1;i>0;i--){var k,l=g[i];if(l instanceof p)k=this.__createPropertyNode(a,l);else{if(l instanceof q){c.constraint.addConstraint(l);continue}k=this.__createEqualityNode(a,l)}f.addOutNode(k,b),k.addParentNode(f),f=k}if(c instanceof t){var m=this.__createAdapterNode(a,d);m.addParentNode(f),f.addOutNode(m,b),f=m}return c.addParentNode(f),f.addOutNode(c,b),e}},print:function(){e(this.terminalNodes,function(a){a.print(" ")})}}}).as(c,"RootNode")},{"../constraint":8,"../extended":12,"../pattern.js":38,"./aliasNode":18,"./equalityNode":20,"./fromNode":21,"./fromNotNode":22,"./joinNode":24,"./leftAdapterNode":26,"./notNode":28,"./propertyNode":29,"./rightAdapterNode":30,"./terminalNode":31,"./typeNode":32}],24:[function(a,b){var c=a("../extended"),d=c.hash.values,e=a("./node"),f=a("./joinReferenceNode"),g=a("../linkedList");e.extend({instance:{constructor:function(){this._super([]),this.constraint=new f,this.leftMemory={},this.rightMemory={},this.leftTuples=new g,this.rightTuples=new g},dispose:function(){this.leftMemory={},this.rightMemory={},this.leftTuples.clear(),this.rightTuples.clear()},disposeLeft:function(a){this.leftMemory={},this.leftTuples.clear(),this.propagateDispose(a)},disposeRight:function(a){this.rightMemory={},this.rightTuples.clear(),this.propagateDispose(a)},hashCode:function(){return"JoinNode "+this.__count},toString:function(){return"JoinNode "+this.__count},retractLeft:function(a){if(a=this.removeFromLeftMemory(a),!a)throw new Error;a=a.data;for(var b=d(a.rightMatches),c=-1,e=b.length;++ce;e++)this.addOutNode(d,c[e]);a.nodes.remove(d)},this);for(var b=a.parentNodes,c=0,d=a.parentNodes.l;d>c;c++){var e=b[c];this.addParentNode(e),e.nodes.remove(a)}return this},resolve:function(a,b){return a.hashCode===b.hashCode},print:function(a){console.log(a+this.toString()),d(this.parentNodes,function(b){b.print(" "+a)})},addOutNode:function(a,b){this.nodes.contains(a)||this.nodes.put(a,[]),this.nodes.get(a).push(b),this.__entrySet=this.nodes.entrySet()},addParentNode:function(a){-1===e(this.parentNodes,a)&&this.parentNodes.push(a)},shareable:function(){return!1},__propagate:function(a,b){for(var c,d,e,g,h=this.__entrySet,j=h.length;--j>-1;)c=h[j],d=c.key,e=c.value,b.paths?(g=f(e,b.paths)).length&&d[a](new i(b.fact,g,b.match)):d[a](b)},dispose:function(a){this.propagateDispose(a)},retract:function(a){this.propagateRetract(a)},propagateDispose:function(a,b){b=b||this.nodes;for(var c=this.__entrySet,d=c.length-1;d>=0;d--){var e=c[d],f=e.key;f.dispose(a)}},propagateAssert:function(a){this.__propagate("assert",a)},propagateRetract:function(a){this.__propagate("retract",a)},assert:function(a){this.propagateAssert(a)},modify:function(a){this.propagateModify(a)},propagateModify:function(a){this.__propagate("modify",a)}}}).as(b)},{"../context":10,"../extended":12}],28:[function(a,b){var c=a("./joinNode"),d=a("../linkedList");c.extend({instance:{constructor:function(){this._super(arguments),this.leftTupleMemory={}},toString:function(){return"NotNode "+this.__count},retractRight:function(a){var b=this.removeFromRightMemory(a);if(!b)throw new Error;var c=b.data,d=c.blocking;if(d.length){for(var e,f,g,h=this.rightTuples,i=this.constraint,j={next:d.head},k=h.length;j=j.next;){if(e=j.data,this.removeFromLeftBlockedMemory(e),0!==k){for(i.setLeftContext(e),f=b;f=f.next;)if(i.setRightContext(g=f.data).isMatch()){e.blocker=g,this.addToLeftBlockedMemory(g.blocking.push(e)),e=null;break}i.clearContexts()}e&&(this.__addToLeftMemory(e),this.__propagate("assert",e.clone()))}d.clear()}},retractLeft:function(a){var b=this.removeFromLeftMemory(a);if(b)this.__propagate("retract",b.data.clone());else if(!this.removeFromLeftBlockedMemory(a))throw new Error},assertLeft:function(a){var b,c,d=this.rightTuples,e=this.constraint;if(d.length){for(b={next:d.head},e.setLeftContext(a);(b=b.next)&&a;)e.setRightContext(c=b.data).isMatch()&&(a.blocker=c,this.addToLeftBlockedMemory(c.blocking.push(a)),a=null);e.clearContexts()}a&&(this.__addToLeftMemory(a),this.__propagate("assert",a.clone()))},assertRight:function(a){this.__addToRightMemory(a),a.blocking=new d;var b,c,e=this.leftTuples,f=this.constraint;if(e.length){for(c={next:e.head},f.setRightContext(a);c=c.next;)b=c.data,f.setLeftContext(b).isMatch()&&(this.__propagate("retract",b.clone()),this.removeFromLeftMemory(b),b.blocker=a,this.addToLeftBlockedMemory(a.blocking.push(b)));f.clearContexts()}},addToLeftBlockedMemory:function(a){var b=a.data,c=b.hashCode,d=this.leftMemory[c];return this.leftTupleMemory[c]=a,d&&this.leftTuples.remove(d),this},removeFromLeftBlockedMemory:function(a){var b=this.leftTupleMemory[a.hashCode]||null;return b&&(delete this.leftTupleMemory[a.hashCode],b.data.blocker.blocking.remove(b)),b},modifyLeft:function(a){var b,c,d,e,f=this.removeFromLeftMemory(a),g=this.constraint,h=this.rightTuples,i=h.length,j=!1;if(f||(f=this.removeFromLeftBlockedMemory(a),j=!0),!f)throw new Error;if(b=f.data,b&&b.blocker&&(e=this.rightMemory[b.blocker.hashCode]),e&&(g.setLeftContext(a),g.setRightContext(d=e.data).isMatch()&&(j||this.__propagate("retract",b.clone()),a.blocker=d,this.addToLeftBlockedMemory(d.blocking.push(a)),a=null)),a&&i){for(c={next:h.head},g.setLeftContext(a);c=c.next;)if(g.setRightContext(d=c.data).isMatch()){j||this.__propagate("retract",b.clone()),this.addToLeftBlockedMemory(d.blocking.push(a)),a.blocker=d,a=null;break}g.clearContexts()}a&&(this.__addToLeftMemory(a),j?this.__propagate("assert",a.clone()):this.__propagate("modify",a.clone()))},modifyRight:function(a){var b=this.removeFromRightMemory(a);if(!b)throw new Error;var c,e,f=b.data,g=this.leftTuples,h=g.length,i=this.constraint,j=f.blocking;if(this.__addToRightMemory(a),a.blocking=new d,h||j.length){if(h)for(i.setRightContext(a),e={next:g.head};e=e.next;)c=e.data,i.setLeftContext(c).isMatch()&&(this.__propagate("retract",c.clone()),this.removeFromLeftMemory(c),this.addToLeftBlockedMemory(a.blocking.push(c)),c.blocker=a);if(j.length){for(var k,l={next:j.head};l=l.next;){if(c=l.data,c.blocker=null,i.setRightContext(a),i.setLeftContext(c),i.isMatch())return c.blocker=a,this.addToLeftBlockedMemory(a.blocking.push(c)),c=null,void 0;for(c.blocker=null,e=b;e=e.next;)if(i.setRightContext(k=e.data).isMatch()){c.blocker=k,this.addToLeftBlockedMemory(k.blocking.push(c)),c=null;break}c&&(this.__addToLeftMemory(c),this.__propagate("assert",c.clone())),i.clearContexts()}i.clearContexts()}}}}}).as(b)},{"../linkedList":16,"./joinNode":24}],29:[function(a,b){var c=a("./alphaNode"),d=a("../context"),e=a("../extended");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias"),this.varLength=(this.variables=e(this.constraint.get("variables")).toArray().value()).length},assert:function(a){var b,c=new d(a.fact,a.paths),e=this.variables,f=a.fact.object;c.set(this.alias,f);for(var g=0,h=this.varLength;h>g;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("assert",c)},retract:function(a){this.__propagate("retract",new d(a.fact,a.paths))},modify:function(a){var b,c=new d(a.fact,a.paths),e=this.variables,f=a.fact.object;c.set(this.alias,f);for(var g=0,h=this.varLength;h>g;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("modify",c)},toString:function(){return"PropertyNode"+this.__count}}}).as(b)},{"../context":10,"../extended":12,"./alphaNode":19}],30:[function(a,b){var c=a("./node");c.extend({instance:{retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},propagateAssert:function(a){this.__propagate("assertRight",a)},propagateRetract:function(a){this.__propagate("retractRight",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyRight",a)},toString:function(){return"RightAdapterNode "+this.__count}}}).as(b)},{"./node":27}],31:[function(a,b){var c=a("./node"),d=a("../extended"),e=d.bind,f=d.removeDuplicates;c.extend({instance:{constructor:function(a,b,c,d){this._super([]),this.resolve=e(this,this.resolve),this.rule=c,this.index=b,this.name=this.rule.name,this.agenda=d,this.bucket=a,d.register(this)},__assertModify:function(a){var b=a.match;if(b.recency.sort(function(a,b){return a-b}).reverse(),b.facts=f(b.facts),b.isMatch){var c=this.rule,d=this.bucket;this.agenda.insert(this,{rule:c,hashCode:a.hashCode,index:this.index,name:c.name,recency:d.recency++,match:b,counter:d.counter})}},assert:function(a){this.__assertModify(a)},modify:function(a){this.agenda.retract(this,a),this.__assertModify(a)},retract:function(a){this.agenda.retract(this,a)},retractRight:function(a){this.agenda.retract(this,a)},retractLeft:function(a){this.agenda.retract(this,a)},assertLeft:function(a){this.__assertModify(a)},assertRight:function(a){this.__assertModify(a)},toString:function(){return"TerminalNode "+this.rule.name}}}).as(b)},{"../extended":12,"./node":27}],32:[function(a,b){var c=a("./alphaNode"),d=a("../context");c.extend({instance:{assert:function(a){this.constraint.assert(a.object)&&this.__propagate("assert",a)},modify:function(a){this.constraint.assert(a.object)&&this.__propagate("modify",a)},retract:function(a){this.constraint.assert(a.object)&&this.__propagate("retract",a)},toString:function(){return"TypeNode"+this.__count},dispose:function(){for(var a=this.__entrySet,b=a.length-1;b>=0;b--){var c=a[b],d=c.key,e=c.value;d.dispose({paths:e})}},__propagate:function(a,b){for(var c=this.__entrySet,e=-1,f=c.length;++e":20,"<=":21,">=":22,EQUALITY_EXPRESSION:23,"==":24,"!=":25,"=~":26,"!=~":27,IN_EXPRESSION:28,"in":29,ARRAY_EXPRESSION:30,notIn:31,OBJECT_EXPRESSION:32,AND_EXPRESSION:33,"&&":34,OR_EXPRESSION:35,"||":36,ARGUMENT_LIST:37,",":38,IDENTIFIER_EXPRESSION:39,IDENTIFIER:40,".":41,"[":42,STRING_EXPRESSION:43,"]":44,NUMBER_EXPRESSION:45,"(":46,")":47,STRING:48,NUMBER:49,REGEXP_EXPRESSION:50,REGEXP:51,BOOLEAN_EXPRESSION:52,BOOLEAN:53,NULL_EXPRESSION:54,NULL:55,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",46:"(",47:")",48:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"},productions_:[0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,4],[32,3],[32,4],[43,1],[45,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 3:this.$=[f[g],null,"unary"];break;case 4:this.$=[f[g],null,"logicalNot"];break;case 6:this.$=[f[g-2],f[g],"mult"];break;case 7:this.$=[f[g-2],f[g],"div"];break;case 8:this.$=[f[g-2],f[g],"mod"];break;case 10:this.$=[f[g-2],f[g],"plus"];break;case 11:this.$=[f[g-2],f[g],"minus"];break;case 13:this.$=[f[g-2],f[g],"pow"];break;case 15:this.$=[f[g-2],f[g],"lt"];break;case 16:this.$=[f[g-2],f[g],"gt"];break;case 17:this.$=[f[g-2],f[g],"lte"];break;case 18:this.$=[f[g-2],f[g],"gte"];break;case 20:this.$=[f[g-2],f[g],"eq"];break;case 21:this.$=[f[g-2],f[g],"neq"];break;case 22:this.$=[f[g-2],f[g],"like"];break;case 23:this.$=[f[g-2],f[g],"notLike"];break;case 25:this.$=[f[g-2],f[g],"in"];break;case 26:this.$=[f[g-2],f[g],"notIn"];break;case 27:this.$=[f[g-2],f[g],"in"];break;case 28:this.$=[f[g-2],f[g],"notIn"];break;case 30:this.$=[f[g-2],f[g],"and"];break;case 32:this.$=[f[g-2],f[g],"or"];break;case 34:this.$=[f[g-2],f[g],"arguments"];break;case 35:this.$=[String(a),null,"identifier"];break;case 37:this.$=[f[g-2],f[g],"prop"];break;case 38:this.$=[f[g-3],f[g-1],"propLookup"];break;case 39:this.$=[f[g-3],f[g-1],"propLookup"];break;case 40:this.$=[f[g-3],f[g-1],"propLookup"];break;case 41:this.$=[f[g-2],[null,null,"arguments"],"function"];break;case 42:this.$=[f[g-3],f[g-1],"function"];break;case 43:this.$=[String(a.replace(/^['|"]|['|"]$/g,"")),null,"string"];break;case 44:this.$=[Number(a),null,"number"];break;case 45:this.$=[a,null,"regexp"];break;case 46:this.$=["true"==a.replace(/^\s+/,""),null,"boolean"];break;case 47:this.$=[null,null,"null"];break;case 48:this.$=[null,null,"array"];break;case 49:this.$=[f[g-1],null,"array"];break;case 57:this.$=[f[g-1],null,"composite"]}},table:[{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,58],36:[1,32],47:[2,58]},{5:[2,31],34:[1,33],36:[2,31],47:[2,31]},{5:[2,29],34:[2,29],36:[2,29],47:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],47:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],47:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],47:[2,19]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],47:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],47:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],47:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],47:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],44:[2,54],47:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],41:[1,44],42:[1,45],44:[2,55],46:[1,46],47:[2,55]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],47:[2,56]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],47:[2,14]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],47:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],47:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],47:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],47:[2,46]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],47:[2,47]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],46:[2,36],47:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],47:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],46:[2,35],47:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],47:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],47:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:77,39:23,40:[1,26],43:75,45:76,48:[1,18],49:[1,19]},{7:51,30:15,32:14,37:79,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],47:[1,78],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{47:[1,80]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:81,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],47:[2,48]},{38:[1,83],44:[1,82]},{38:[2,33],44:[2,33],47:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:85,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:88,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],47:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],47:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],47:[2,4]},{5:[2,32],34:[1,33],36:[2,32],47:[2,32]},{5:[2,30],34:[2,30],36:[2,30],47:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],47:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],47:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],47:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],47:[2,23]},{5:[2,25],34:[2,25],36:[2,25],47:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],46:[1,46],47:[2,27]},{5:[2,26],34:[2,26],36:[2,26],47:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],46:[1,46],47:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],47:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],47:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],47:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],47:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],46:[2,37],47:[2,37]},{44:[1,89]},{44:[1,90]},{41:[1,44],42:[1,45],44:[1,91],46:[1,46]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],46:[2,41],47:[2,41]},{38:[1,83],47:[1,92]},{5:[2,57],8:[2,57],11:[2,57],12:[2,57],13:[2,57],15:[2,57],17:[2,57],19:[2,57],20:[2,57],21:[2,57],22:[2,57],24:[2,57],25:[2,57],26:[2,57],27:[2,57],29:[2,57],31:[2,57],34:[2,57],36:[2,57],38:[2,57],44:[2,57],47:[2,57]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],47:[2,13]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],47:[2,49]},{7:93,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],47:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],47:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],47:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],47:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],47:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],46:[2,38],47:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],46:[2,39],47:[2,39]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],46:[2,40],47:[2,40]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],41:[2,42],42:[2,42],44:[2,42],46:[2,42],47:[2,42]},{38:[2,34],44:[2,34],47:[2,34]}],defaultActions:{31:[2,1]},parseError:function(a,b){if(!b.recoverable)throw new Error(a); +this.trace(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||m,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n);var o=this.lexer.options&&this.lexer.options.ranges;this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var p,q,r,s,t,u,v,w,x,y={};;){if(r=d[d.length-1],this.defaultActions[r]?s=this.defaultActions[r]:((null===p||"undefined"==typeof p)&&(p=b()),s=g[r]&&g[r][p]),"undefined"==typeof s||!s.length||!s[0]){var z="";x=[];for(u in g[r])this.terminals_[u]&&u>l&&x.push("'"+this.terminals_[u]+"'");z=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(i+1)+": Unexpected "+(p==m?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(z,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:n,expected:x})}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:d.push(p),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(s[1]),p=null,q?(p=q,q=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:if(v=this.productions_[s[1]][1],y.$=e[e.length-v],y._$={first_line:f[f.length-(v||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(v||1)].first_column,last_column:f[f.length-1].last_column},o&&(y._$.range=[f[f.length-(v||1)].range[0],f[f.length-1].range[1]]),t=this.performAction.call(y,h,j,i,this.yy,s[1],e,f),"undefined"!=typeof t)return t;v&&(d=d.slice(0,2*-1*v),e=e.slice(0,-1*v),f=f.slice(0,-1*v)),d.push(this.productions_[s[1]][0]),e.push(y.$),f.push(y._$),w=g[d[d.length-2]][d[d.length-1]],d.push(w);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;fb[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1?a:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){switch(c){case 0:return 29;case 1:return 31;case 2:return"from";case 3:return 24;case 4:return 25;case 5:return 21;case 6:return 19;case 7:return 22;case 8:return 20;case 9:return 26;case 10:return 27;case 11:return 34;case 12:return 36;case 13:return 55;case 14:return 53;case 15:break;case 16:return 49;case 17:return 48;case 18:return 48;case 19:return 40;case 20:return 51;case 21:return 41;case 22:return 11;case 23:return 12;case 24:return 13;case 25:return 38;case 26:return 8;case 27:return 26;case 28:return 27;case 29:return 24;case 30:return 24;case 31:return 25;case 32:return 25;case 33:return 21;case 34:return 22;case 35:return 20;case 36:return 19;case 37:return 34;case 38:return 36;case 39:return 15;case 40:return 17;case 41:return 46;case 42:return 44;case 43:return 42;case 44:return 47;case 45:return 9;case 46:return 5}},rules:[/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s+null\b)/,/^(?:\s+(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:==)/,/^(?:===)/,/^(?:!=)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();"undefined"!=typeof a&&"undefined"!=typeof c&&(c.parser=e,c.Parser=e.Parser,c.parse=function(){return e.parse.apply(e,arguments)},c.main=function(b){b[1]||(console.log("Usage: "+b[0]+" FILE"),d.exit(1));var e=a("fs").readFileSync(a("path").normalize(b[1]),"utf8");return c.parser.parse(e)},"undefined"!=typeof b&&a.main===b&&c.main(d.argv.slice(1)))},{__browserify_process:54,fs:51,path:52}],34:[function(a,b,c){!function(){"use strict";var b=a("./constraint/parser"),d=a("./nools/nool.parser");c.parseConstraint=function(a){try{return b.parse(a)}catch(c){throw new Error("Invalid expression '"+a+"'")}},c.parseRuleSet=function(a,b){return d.parse(a,b)}}()},{"./constraint/parser":33,"./nools/nool.parser":35}],35:[function(a,b,c){"use strict";var d=a("./tokens.js"),e=a("../../extended"),f=e.hash.keys,g=a("./util.js"),h=function(a,b,c){var d=a;a=a.replace(/\/\/(.*)/g,"").replace(/\n|\r|\r\n/g," ");for(var e,i=new RegExp("^("+f(b).join("|")+")");a&&-1!==(e=g.findNextTokenIndex(a));){a=a.substr(e);var j=a.match(i);if(null===j)throw new Error("Error parsing "+a);if(j=j[1],!(j in b))throw new Error("Unknown token"+j);try{a=b[j](a,c,h).replace(/^\s*|\s*$/g,"")}catch(k){throw new Error("Invalid "+j+" definition \n"+k.message+"; \nstarting at : "+d)}}};c.parse=function(a,b){var c={define:[],rules:[],scope:[],loaded:[],file:b};return h(a,d,c),c}},{"../../extended":12,"./tokens.js":36,"./util.js":37}],36:[function(require,module,exports){var process=require("__browserify_process"),utils=require("./util.js"),fs=require("fs"),indexOf=require("../../extended").indexOf,isWhiteSpace=function(a){return 0===a.replace(/[\s|\n|\r|\t]/g,"").length},ruleTokens={salience:function(){var a=/^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=parseInt(d[2],10);if(isNaN(e))throw new Error("Invalid salience/priority "+d[2]);return c.options.priority=e,b.replace(d[0],"")}throw new Error("invalid format")}}(),agendaGroup:function(){var a=/^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid agenda-group "+d[2]);return c.options.agendaGroup=e.replace(/^["']|["']$/g,""),b.replace(d[0],"")}throw new Error("invalid format")}}(),autoFocus:function(){var a=/^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid auto-focus "+d[2]);return c.options.autoFocus="true"===e?!0:!1,b.replace(d[0],"")}throw new Error("invalid format")}}(),"agenda-group":function(){return this.agendaGroup.apply(this,arguments)},"auto-focus":function(){return this.autoFocus.apply(this,arguments)},priority:function(){return this.salience.apply(this,arguments)},when:function(){var ruleRegExp=/^(\$?\w+) *: *(\w+)(.*)/,joinFunc=function(a,b){return"; "+b},constraintRegExp=/(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/,predicateExp=/^(\w+) *\((.*)\)$/m,fromRegExp=/(\bfrom\s+.*)/,parseRules=function(str){for(var rules=[],ruleLines=str.split(";"),l=ruleLines.length,ruleLine,i=0;l>i&&(ruleLine=ruleLines[i].replace(/^\s*|\s*$/g,"").replace(/\n/g,""));i++)if(!isWhiteSpace(ruleLine)){var rule=[];if(predicateExp.test(ruleLine)){var m=ruleLine.match(predicateExp),pred=m[1].replace(/^\s*|\s*$/g,"");if(rule.push(pred),ruleLine=m[2].replace(/^\s*|\s*$/g,""),"or"===pred){rule=rule.concat(parseRules(ruleLine.replace(/,\s*(\$?\w+\s*:)/g,joinFunc))),rules.push(rule);continue}}var parts=ruleLine.match(ruleRegExp);if(!parts||!parts.length)throw new Error("Invalid constraint "+ruleLine);rule.push(parts[2],parts[1]);var constraints=parts[3].replace(/^\s*|\s*$/g,""),hashParts=constraints.match(constraintRegExp),from=null,fromMatch;if(hashParts){var hash=hashParts[1],constraint=constraints.replace(hash,"");fromRegExp.test(constraint)&&(fromMatch=constraint.match(fromRegExp),from=fromMatch[0],constraint=constraint.replace(fromMatch[0],"")),constraint&&rule.push(constraint.replace(/^\s*|\s*$/g,"")),hash&&rule.push(eval("("+hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g,'"$1" : "$2"')+")"))}else constraints&&!isWhiteSpace(constraints)&&(fromRegExp.test(constraints)&&(fromMatch=constraints.match(fromRegExp),from=fromMatch[0],constraints=constraints.replace(fromMatch[0],"")),rule.push(constraints));from&&rule.push(from),rules.push(rule)}return rules};return function(a,b){var c=a.replace(/^when\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(d,""),b.constraints=parseRules(d.replace(/^\{\s*|\}\s*$/g,"")),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}(),then:function(){return function(a,b){if(b.action)throw new Error("action already defined for rule"+b.name);var c=a.replace(/^then\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");if(c=c.replace(d,""),b.action||(b.action=d.replace(/^\{\s*|\}\s*$/g,"")),!isWhiteSpace(c))throw new Error("Error parsing then block "+a);return c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}()},topLevelTokens={"/":function(a){return a.match(/^\/\*/)?a.replace(/\/\*.*?\*\//,""):a},define:function(a,b){var c=a.replace(/^define\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){d=d[1];var e=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(e,""),b.define.push({name:d,properties:"("+e+")"}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"import":function(a,b,c){if("undefined"!=typeof window)throw new Error("import cannot be used in a browser");var d=a.replace(/^import\s*/,"");if("("===utils.findNextToken(d)){var e=utils.getParamList(d);if(d=d.replace(e,"").replace(/^\s*|\s*$/g,""),";"===utils.findNextToken(d)&&(d=d.replace(/\s*;/,"")),e=e.replace(/[\(|\)]/g,"").split(","),1===e.length){if(e=utils.resolve(b.file||process.cwd(),e[0].replace(/["|']/g,"")),-1===indexOf(b.loaded,e)){var f=b.file;b.file=e,c(fs.readFileSync(e,"utf8"),topLevelTokens,b),b.loaded.push(e),b.file=f}return d}throw new Error("import accepts a single file")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(d)+"'")},global:function(a,b){var c=a.replace(/^global\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"="===utils.findNextToken(c)){d=d[1].replace(/^\s+|\s+$/g,"");var e=utils.getTokensBetween(c,"=",";",!0).join(""),f=e.substring(1,e.length-1);if(f=f.replace(/^\s+|\s+$/g,""),/^require\(/.test(f)){var g=utils.getParamList(f.replace("require")).replace(/[\(|\)]/g,"").split(",");1===g.length&&(g=g[0].replace(/["|']/g,""),f=["require('",utils.resolve(b.file||process.cwd(),g),"')"].join(""))}return b.scope.push({name:d,body:f}),c=c.replace(e,"")}throw new Error("unexpected token : expected : '=' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"function":function(a,b){var c=a.replace(/^function\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);if(d){if(c=c.replace(d[0],""),"("===utils.findNextToken(c)){d=d[1];var e=utils.getParamList(c);if(c=c.replace(e,"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){var f=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(f,""),b.scope.push({name:d,body:"function"+e+f}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},rule:function(a,b,c){var d=a.replace(/^rule\s*/,""),e=d.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);if(e){if(d=d.replace(e[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(d)){e=e[1].replace(/^["']|["']$/g,"");var f={name:e,options:{},constraints:null,action:null},g=utils.getTokensBetween(d,"{","}",!0).join("");return d=d.replace(g,""),c(g.replace(/^\{\s*|\}\s*$/g,""),ruleTokens,f),b.rules.push(f),d}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(d)+"'")}throw new Error("missing name")}};module.exports=topLevelTokens},{"../../extended":12,"./util.js":37,__browserify_process:54,fs:51}],37:[function(a,b,c){var d=a("__browserify_process"),e=a("path"),f=/[\s|\n|\r|\t]/,g=e.sep||("win32"===d.platform?"\\":"/"),h={"{":"}","}":"{","(":")",")":"(","[":"]"},i=c.getTokensBetween=function(a,b,c,d){var e=0,f=[];b||(b=h[c],e=1),c||(c=h[b]),a=Object(a);for(var g,i=!1,j=0,k=!1;g=a.charAt(j++);)if(g===b)e++,i?f.push(g):(i=!0,d&&f.push(g));else if(g===c&&j){if(e--,0===e){d&&f.push(g),k=!0;break}f.push(g)}else i&&f.push(g);if(!k)throw new Error("Unable to match "+b+" in "+a);return f};c.getParamList=function(a){return i(a,"(",")",!0).join("")},c.resolve=function(a,b){return""!==e.extname(a)&&(a=e.dirname(a)),1===b.split(g).length?b:e.resolve(a,b)};var j=c.findNextTokenIndex=function(a,b,c){b=b||0,c=c||a.length;var d=-1,e=a.length;for((!c||c>e)&&(c=e);c>b;b++){var g=a.charAt(b);if(!f.test(g)){d=b;break}}return d};c.findNextToken=function(a,b,c){return a.charAt(j(a,b,c))}},{__browserify_process:54,path:52}],38:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isEmpty,f=d.merge,g=d.forEach,h=d.declare,i=a("./constraintMatcher"),j=a("./constraint"),k=j.EqualityConstraint,l=0,m=h({}),n=m.extend({instance:{constructor:function(a,b,c,d,h){h=h||{},this.id=l++,this.type=a,this.alias=b,this.conditions=c,this.pattern=h.pattern;var k=[new j.ObjectConstraint(a)],m=i.toConstraints(c,f({alias:b},h));if(m.length)k=k.concat(m);else{var n=new j.TrueConstraint;k.push(n)}if(d&&!e(d)){var o=new j.HashConstraint(d);k.push(o)}g(k,function(a){a.set("alias",b)}),this.constraints=k},getSpecificity:function(){for(var a=this.constraints,b=0,c=0,d=a.length;d>c;c++)a[c]instanceof k&&b++;return b},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions)].join(":")},toString:function(){return d.format("%j",this.constraints)}}}).as(c,"ObjectPattern"),o=n.extend({instance:{constructor:function(a,b,c,d,e,f){this._super([a,b,c,d,f]),this.from=e.from},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},getSpecificity:function(){return this._super(arguments)+1},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions),this.from.from].join(":")},toString:function(){return d.format("%j from %s",this.constraints,this.from.from)}}}).as(c,"FromPattern");o.extend().as(c,"FromNotPattern"),n.extend().as(c,"NotPattern"),m.extend({instance:{constructor:function(a,b){this.id=l++,this.leftPattern=a,this.rightPattern=b},hashCode:function(){return[this.leftPattern.hashCode(),this.rightPattern.hashCode()].join(":")},getSpecificity:function(){return this.rightPattern.getSpecificity()+this.leftPattern.getSpecificity()},getters:{constraints:function(){return this.leftPattern.constraints.concat(this.rightPattern.constraints)}}}}).as(c,"CompositePattern");var p=h({constuctor:function(){this.id=l++}}).as(c,"InitialFact");n.extend({instance:{constructor:function(){this._super([p,"i",[],{}])},assert:function(){return!0}}}).as(c,"InitialFactPattern")},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],39:[function(a,b,c){"use strict";function d(a,b,c,d){f(b)?(d=c,c=b):b=b||{};var g=e.every(c,function(a){return f(a)});g&&1===c.length&&(c=c[0],g=!1);var h=[],i=b.scope||{};if(c.scope=i,g){for(var j,k=function(a,b){m[b]?e(m).forEach(function(b){b.push(a)}):(m[b]=0===b?[]:m[b-1].slice(),0!==b&&m[b].pop(),m[b].push(a))},l=c.length,m=[],n=0;l>n;n++)j=c[n],j.scope=i,e.forEach(w(j),k);h=e.map(m,function(c){for(var e=null,f=0;f>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.arrayExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":41,extended:46,"is-extended":56}],43:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c,d){a=""+a,c=c||" ";for(var e=a.length;b>e;)d?a+=c:a=c+a,e++;return a}function e(a,c,d){var f=a;if(b.isString(f)){if(a.length>c)if(d){var g=a.length;f=a.substring(g-c,g)}else f=a.substring(0,c)}else f=e(""+f,c);return f}function f(a,c,d){if(!b.isArray(a)||"function"!=typeof c)throw new TypeError; +for(var e=Object(a),f=e.length>>>0,g=0;f>g;g++)if(g in e&&!c.call(d,e[g],g,e))return!1;return!0}function g(a,b){return A.difference(new Date(a.getFullYear(),0,1,a.getHours()),a,null,b)+1}function h(a,b,c){b=b||0;var d=a[c?"getUTCFullYear":"getFullYear"](),e=new Date(d,0,1).getDay(),f=(e-b+7)%7,h=o((g(a)+f-1)/7);return e===b&&h++,h}function i(a){var b=a.toString(),c="",d=b.indexOf("(");return d>-1&&(c=b.substring(++d,b.indexOf(")"))),c}function j(a,b){return a.replace(/([a-z])\1*/gi,function(a){var c,d=a.charAt(0),e=a.length,f="0?",g="0{0,2}";if("y"===d)c="\\d{2,4}";else if("M"===d)c=e>2?"\\S+?":"1[0-2]|"+f+"[1-9]";else if("D"===d)c="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+g+"[1-9][0-9]|"+f+"[1-9]";else if("d"===d)c="3[01]|[12]\\d|"+f+"[1-9]";else if("w"===d)c="[1-4][0-9]|5[0-3]|"+f+"[1-9]";else if("E"===d)c="\\S+";else if("h"===d)c="1[0-2]|"+f+"[1-9]";else if("K"===d)c="1[01]|"+f+"\\d";else if("H"===d)c="1\\d|2[0-3]|"+f+"\\d";else if("k"===d)c="1\\d|2[0-4]|"+f+"[1-9]";else if("m"===d||"s"===d)c="[0-5]\\d";else if("S"===d)c="\\d{"+e+"}";else if("a"===d){var h="AM",i="PM";c=h+"|"+i,h!==h.toLowerCase()&&(c+="|"+h.toLowerCase()),i!==i.toLowerCase()&&(c+="|"+i.toLowerCase()),c=c.replace(/\./g,"\\.")}else c="v"===d||"z"===d||"Z"===d||"G"===d||"q"===d||"Q"===d?".*":" "===d?"\\s*":d+"*";return b&&b.push(a),"("+c+")"}).replace(/[\xa0 ]/g,"[\\s\\xa0]")}function k(a){B[a+"sFromNow"]=function(b){return A.add(new Date,a,b)},B[a+"sAgo"]=function(b){return A.add(new Date,a,-b)}}for(var l=function(){function a(a,b,c){return a=a.replace(/s$/,""),e.hasOwnProperty(a)?e[a](b,c):[c,"UTC"+a.charAt(0).toUpperCase()+a.substring(1)+"s",!1]}function b(a,b,c,e){return a=a.replace(/s$/,""),d(f[a](b,c,e))}var c=Math.floor,d=Math.round,e={day:function(a,b){return[b,"Date",!1]},weekday:function(a,b){var c,d,e=b%5,f=a.getDay(),g=0;e?(c=e,d=parseInt(b/5,10)):(c=b>0?5:-5,d=b>0?(b-5)/5:(b+5)/5),6===f&&b>0?g=1:0===f&&0>b&&(g=-1);var h=f+c;return(0===h||6===h)&&(g=b>0?2:-2),[7*d+c+g,"Date",!1]},year:function(a,b){return[b,"FullYear",!0]},week:function(a,b){return[7*b,"Date",!1]},quarter:function(a,b){return[3*b,"Month",!0]},month:function(a,b){return[b,"Month",!0]}},f={quarter:function(a,b,d){var e=b.getFullYear()-a.getFullYear(),f=a[d?"getUTCMonth":"getMonth"](),g=b[d?"getUTCMonth":"getMonth"](),h=c(f/3)+1,i=c(g/3)+1;return i+=4*e,i-h},weekday:function(a,c,d){var e,f=b("day",a,c,d),g=f%7;if(0===g)f=5*b("week",a,c,d);else{var h=0,i=a[d?"getUTCDay":"getDay"](),j=c[d?"getUTCDay":"getDay"]();e=parseInt(f/7,10);var k=new Date(+a);k.setDate(k[d?"getUTCDate":"getDate"]()+7*e);var l=k[d?"getUTCDay":"getDay"]();f>0?6===i||6===j?h=-1:0===i?h=0:(0===j||l+g>5)&&(h=-2):0>f&&(6===i?h=0:0===i||0===j?h=1:(6===j||0>l+g)&&(h=2)),f+=h,f-=2*e}return f},year:function(a,b){return b.getFullYear()-a.getFullYear()},month:function(a,b,c){var d=a[c?"getUTCMonth":"getMonth"](),e=b[c?"getUTCMonth":"getMonth"]();return e-d+12*(b.getFullYear()-a.getFullYear())},week:function(a,c,e){return d(b("day",a,c,e)/7)},day:function(a,b){return 1.1574074074074074e-8*(b.getTime()-a.getTime())},hour:function(a,b){return 2.7777777777777776e-7*(b.getTime()-a.getTime())},minute:function(a,b){return 16666666666666667e-21*(b.getTime()-a.getTime())},second:function(a,b){return.001*(b.getTime()-a.getTime())},millisecond:function(a,b){return b.getTime()-a.getTime()}};return{addTransform:a,differenceTransform:b}}(),m=l.addTransform,n=l.differenceTransform,o=Math.floor,p=Math.round,q=Math.min,r=Math.pow,s=Math.ceil,t=Math.abs,u=["January","February","March","April","May","June","July","August","September","October","November","December"],v=["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y=["Before Christ","Anno Domini"],z=["BC","AD"],A={getDaysInMonth:function(a){var b=a.getMonth(),c=[31,28,31,30,31,30,31,31,30,31,30,31];return 1===b&&A.isLeapYear(a)?29:c[b]},isLeapYear:function(a,b){var c=a[b?"getUTCFullYear":"getFullYear"]();return 0===c%400||0===c%4&&0!==c%100},isWeekend:function(a,b){var c=(a||new Date)[b?"getUTCDay":"getDay"]();return 0===c||6===c},getTimezoneName:i,compare:function(a,b,c){return a=new Date(+a),b=new Date(+(b||new Date)),"date"===c?(a.setHours(0,0,0,0),b.setHours(0,0,0,0)):"time"===c&&(a.setFullYear(0,0,0),b.setFullYear(0,0,0)),a>b?1:b>a?-1:0},add:function(a,b,c){var d=m(b,a,c||0);c=d[0];var e=d[1],f=new Date(+a),g=d[2];return e&&f["set"+e](f["get"+e]()+c),g&&f.getDate()E?z:y)[0>f?0:1];else if("y"===D)B=f,E>1&&(2===E?B=e(""+B,2,!0):C=!0);else if("Q"===D.toUpperCase())B=s((j+1)/3),C=!0;else if("M"===D)3>E?(B=j+1,C=!0):B=(3===E?v:u)[j];else if("w"===D)B=h(a,0,c),C=!0;else if("D"===D)B=g(a,c),C=!0;else if("E"===D)3>E?(B=k+1,C=!0):B=(-3===E?x:w)[k];else if("a"===D)B=12>m?"AM":"PM";else if("h"===D)B=m%12||12,C=!0;else if("K"===D)B=m%12,C=!0;else if("k"===D)B=m||24,C=!0;else if("S"===D)B=p(A*r(10,E-3)),C=!0;else if("z"===D||"v"===D||"Z"===D){if(B=i(a),"z"!==D&&"v"!==D||B||(E=4),!B||"Z"===D){var F=a.getTimezoneOffset(),G=[F>=0?"-":"+",d(o(t(F)/60),2,"0"),d(t(F)%60,2,"0")];4===E&&(G.splice(0,0,"GMT"),G.splice(3,0,":")),B=G.join("")}}else B=b;else B=""+n,C=!0;else B=""+m,C=!0;return C&&(B=d(B,E,"0")),B})}},B={},C=["year","month","day","hour","minute","second"],D=0,E=C.length;E>D;D++)k(C[D]);var F={parseDate:function(a,b){if(!b)throw new Error("format required when calling dateExtender.parse");var d=[],e=j(b,d),g=new RegExp("^"+e+"$","i"),h=g.exec(a);if(!h)return null;var i=[1970,0,1,0,0,0,0],k="",l=f(h,function(a,b){if(b){var e=d[b-1],f=e.length,g=e.charAt(0);if("y"===g)if(100>a){a=parseInt(a,10);var h=""+(new Date).getFullYear(),j=100*h.substring(0,2),l=q(h.substring(2,4)+20,99);i[0]=l>a?j+a:j-100+a}else i[0]=a;else if("M"===g){if(f>2){var m,n,o=u;3===f&&(o=v),a=a.replace(".","").toLowerCase();var p=!1;for(m=0,n=o.length;n>m&&!p;m++){var r=o[m].replace(".","").toLocaleLowerCase();r===a&&(a=m,p=!0)}if(!p)return!1}else a--;i[1]=a}else if("E"===g||"e"===g){var s=w;3===f&&(s=x),a=a.toLowerCase(),s=c.map(s,function(a){return a.toLowerCase()});var t=c.indexOf(s,a);if(-1===t){if(a=parseInt(a,10),isNaN(a)||a>s.length)return!1}else a=t}else if("D"===g||"d"===g)"D"===g&&(i[1]=0),i[2]=a;else if("a"===g){var y="am",z="pm",A=/\./g;a=a.replace(A,"").toLowerCase(),k=a===z?"p":a===y?"a":""}else"k"===g||"h"===g||"H"===g||"K"===g?("k"===g&&24===+a&&(a=0),i[3]=a):"m"===g?i[4]=a:"s"===g?i[5]=a:"S"===g&&(i[6]=a)}return!0});if(l){var m=+i[3];"p"===k&&12>m?i[3]=m+12:"a"===k&&12===m&&(i[3]=0);var n=new Date(i[0],i[1],i[2],i[3],i[4],i[5],i[6]),o=-1!==c.indexOf(d,"d"),p=-1!==c.indexOf(d,"M"),r=i[1],s=i[2],t=n.getMonth(),y=n.getDate();return p&&t>r||o&&y>s?null:n}return null}},G=a.define(b.isDate,A).define(b.isString,F).define(b.isNumber,B);for(D in A)A.hasOwnProperty(D)&&(G[D]=A[D]);for(D in F)F.hasOwnProperty(D)&&(G[D]=F[D]);for(D in B)B.hasOwnProperty(D)&&(G[D]=B[D]);return G}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.dateExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":42,extended:46,"is-extended":56}],44:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b)}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){switch(arguments.length){case 0:this.constructor.call(this);break;case 1:this.constructor.call(this,arguments[0]);break;case 2:this.constructor.call(this,arguments[0],arguments[1]);break;case 3:this.constructor.call(this,arguments[0],arguments[1],arguments[2]);break;default:this.constructor.apply(this,arguments)}}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],45:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":44}],46:[function(a,b,c){!function(){"use strict";function d(a){function b(){var b=a.define();return b.expose({register:function(a,c){c||(c=a,a=null);var d=typeof c;if(a)b[a]=c;else if(c&&"function"===d)b.extend(c);else{if("object"!==d)throw new TypeError("extended.register must be called with an extender function");b.expose(c)}return b},define:function(){return a.define.apply(a,arguments)}}),b}function c(){return b()}return function(){function a(a,b){var c,d;for(c in b)b.hasOwnProperty(c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}return function(b){b||(b={});for(var c=1,d=arguments.length;d>c;c++)a(b,arguments[c]);return b}}(),c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}.call(this)},{extender:48}],47:[function(a,b,c){!function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}.call(this)},{"declare.js":45}],48:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":47}],49:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c){if(c=o(arguments,2),m(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!m(b)&&!n(b))throw new Error(b+" is not a function");return m(b)?function(){var d=a[b];if(n(d)){var e=c.concat(o(arguments));return d.apply(a,e)}return d}:c.length?function(){var d=c.concat(o(arguments));return b.apply(a,d)}:function(){return b.apply(a,arguments)}}function e(a,b){if(b=o(arguments,1),!m(a)&&!n(a))throw new Error(a+" must be the name of a property or function to execute");return m(a)?function(){var c=o(arguments),d=c.shift(),e=d[a];return n(e)?(c=b.concat(c),e.apply(d,c)):e}:function(){var c=o(arguments),d=c.shift();return c=b.concat(c),a.apply(d,c)}}function f(a,b,c){if(c=o(arguments,2),m(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!m(b)&&!n(b))throw new Error(b+" is not a function");return m(b)?function(){var d=a[b];return n(d)?d.apply(a,c):d}:function(){return b.apply(a,c)}}function g(a){var b=o(arguments,1);if(!l(a)&&!n(a))throw new TypeError("scope must be an object");if(1===b.length&&k(b[0])&&(b=b[0]),!b.length){b=[];for(var c in a)a.hasOwnProperty(c)&&n(a[c])&&b.push(c)}for(var e=0,f=b.length;f>e;e++)a[b[e]]=d(a,a[b[e]]);return a}function h(a,b){if(b=o(arguments,1),!m(a)&&!n(a))throw new Error(a+" must be the name of a property or function to execute");return m(a)?function(){var c=this[a];if(n(c)){var d=b.concat(o(arguments));return c.apply(this,d)}return c}:function(){var c=b.concat(o(arguments));return a.apply(this,c)}}function i(a,b){return function(){var c=o(arguments);return b?a.apply(this,arguments):function(){return a.apply(this,c.concat(o(arguments)))}}}function j(a,b,c){var e;if(e=c?d(c,b):b,a)for(var f=a-1,g=f;g>=0;g--)e=i(e,g===f);return e}var k=b.isArray,l=b.isObject,m=b.isString,n=b.isFunction,o=c.argsToArray;return a.define(l,{bind:d,bindAll:g,bindIgnore:f,curry:function(a,b,c){return j(b,c,a)}}).define(n,{bind:function(a,b){return d.apply(this,[b,a].concat(o(arguments,2)))},bindIgnore:function(a,b){return f.apply(this,[b,a].concat(o(arguments,2)))},partial:h,applyFirst:e,curry:function(a,b,c){return j(b,a,c)},noWrap:{f:function(){return this.value()}}}).define(m,{bind:function(a,b){return d(b,a)},bindIgnore:function(a,b){return f(b,a)},partial:h,applyFirst:e,curry:function(a,b,c){return j(b,a,c)}}).expose({bind:d,bindAll:g,bindIgnore:f,partial:h,applyFirst:e,curry:j})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.functionExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":41,extended:46,"is-extended":56}],50:[function(a,b,c){function d(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;ce;e++)d[e].apply(this,c);return!0}return!1},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var e=d(c,b);if(0>e)return this;c.splice(e,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},f.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0}},{__browserify_process:54}],51:[function(){},{}],52:[function(a,b,c){function d(a,b){for(var c=[],d=0;d=0;d--){var e=a[d];"."==e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var f=a("__browserify_process"),g=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){for(var a="",b=!1,c=arguments.length;c>=-1&&!b;c--){var g=c>=0?arguments[c]:f.cwd();"string"==typeof g&&g&&(a=g+"/"+a,b="/"===g.charAt(0))}return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b="/"===a.charAt(0),c="/"===a.slice(-1);return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){return a&&"string"==typeof a}).join("/"))},c.dirname=function(a){var b=g.exec(a)[1]||"",c=!1;return b?1===b.length||c&&b.length<=3&&":"===b.charAt(1)?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=g.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return g.exec(a)[3]||""},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i=0;e--)if(f[e]!=g[e])return!1;for(e=f.length-1;e>=0;e--)if(d=f[e],!h(a[d],b[d]))return!1;return!0}function l(a,b){return a&&b?b instanceof RegExp?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function m(a,b,c,d){var e;"string"==typeof c&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f("Missing expected exception"+d),!a&&l(e,c)&&f("Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util"),o=a("buffer").Buffer,p=Array.prototype.slice,q=b.exports=g;q.AssertionError=function(a){this.name="AssertionError",this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var b=a.stackStartFunction||f;Error.captureStackTrace&&Error.captureStackTrace(this,b)},n.inherits(q.AssertionError,Error),q.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",e(JSON.stringify(this.actual,d),128),this.operator,e(JSON.stringify(this.expected,d),128)].join(" ")},q.AssertionError.__proto__=Error.prototype,q.fail=f,q.ok=g,q.equal=function(a,b,c){a!=b&&f(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",q.notStrictEqual)},q.throws=function(){m.apply(this,[!0].concat(p.call(arguments)))},q.doesNotThrow=function(){m.apply(this,[!1].concat(p.call(arguments)))},q.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(a,b,c){function d(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&d(a.__proto__)}function e(a){return a instanceof RegExp||"object"==typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function f(a){if(a instanceof Date)return!0;if("object"!=typeof a)return!1;var b=Date.prototype&&h(Date.prototype),c=a.__proto__&&h(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}a("events"),c.isArray=d,c.isDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,i,j){function k(a,i){if(a&&"function"==typeof a.inspect&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(i);switch(typeof a){case"undefined":return m("undefined","undefined");case"string":var j="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return m(j,"string");case"number":return m(""+a,"number");case"boolean":return m(""+a,"boolean")}if(null===a)return m("null","null");var n=g(a),o=b?h(a):n;if("function"==typeof a&&0===o.length){if(e(a))return m(""+a,"regexp");var p=a.name?": "+a.name:"";return m("[Function"+p+"]","special")}if(f(a)&&0===o.length)return m(a.toUTCString(),"date");var q,r,s;if(d(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]),"function"==typeof a){var t=a.name?": "+a.name:"";q=e(a)?" "+a:" [Function"+t+"]"}else q="";if(f(a)&&(q=" "+a.toUTCString()),0===o.length)return s[0]+q+s[1];if(0>i)return e(a)?m(""+a,"regexp"):m("[Object]","special");l.push(a);var u=o.map(function(b){var c,e;if(a.__lookupGetter__&&(a.__lookupGetter__(b)?e=a.__lookupSetter__(b)?m("[Getter/Setter]","special"):m("[Getter]","special"):a.__lookupSetter__(b)&&(e=m("[Setter]","special"))),n.indexOf(b)<0&&(c="["+b+"]"),e||(l.indexOf(a[b])<0?(e=null===i?k(a[b]):k(a[b],i-1),e.indexOf("\n")>-1&&(e=d(a)?e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=m("[Circular]","special")),"undefined"==typeof c){if("Array"===r&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=m(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=m(c,"string"))}return c+": "+e});l.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return u=w>50?s[0]+(""===q?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:s[0]+q+" "+u.join(", ")+" "+s[1]}var l=[],m=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return j||(m=function(a){return a}),k(a,"undefined"==typeof i?2:i)},c.log=function(){},c.pump=null;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},i=Object.create||function(a,b){var c;if(null===a)c={__proto__:null};else{if("object"!=typeof a)throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return"undefined"!=typeof b&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=i(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})};var j=/%[sdj%]/g;c.format=function(a){if("string"!=typeof a){for(var b=[],d=0;d=f)return a;switch(a){case"%s":return String(e[d++]);case"%d":return Number(e[d++]);case"%j":return JSON.stringify(e[d++]);default:return a}}),h=e[d];f>d;h=e[++d])g+=null===h||"object"!=typeof h?" "+h:" "+c.inspect(h);return g}},{events:4}],5:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d) +},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],6:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(a,b,c){!function(a){function b(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;cf;f++)d[f].apply(this,c);return!0}return!1},d.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(e(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:f,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},d.prototype.removeListener=function(a,c){if("function"!=typeof c)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var d=this._events[a];if(e(d)){var f=b(d,c);if(0>f)return this;d.splice(f,1),0==d.length&&delete this._events[a]}else this._events[a]===c&&delete this._events[a];return this},d.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},d.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),e(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(a,b){b.exports=a("q9TxCC")},{}],q9TxCC:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used=a.length?0:(c?(e=a.parent[a.offset+b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8*(d?1-f:f)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>8*(d?3-f:f)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fthis.length)throw new Error("oob");if(b>c)throw new Error("oob");for(var d=b;c>d;d++)this[d]=a},c.SlowBuffer=d,c.Buffer=l,l.poolSize=8192;var E;l.isBuffer=function(a){return a instanceof l||a instanceof d},l.concat=function(a,b){if(!Array.isArray(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new l(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;cd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=c.length?void 0:c.parent[c.offset+a]},l.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},l.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},l.prototype.readUInt32LE=function(a,b){return p(this,a,!1,b)},l.prototype.readUInt32BE=function(a,b){return p(this,a,!0,b)},l.prototype.readInt8=function(a,b){var c,d=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=d.length?void 0:(c=128&d.parent[d.offset+a],c?-1*(255-d.parent[d.offset+a]+1):d.parent[d.offset+a])},l.prototype.readInt16LE=function(a,b){return q(this,a,!1,b)},l.prototype.readInt16BE=function(a,b){return q(this,a,!0,b)},l.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},l.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},l.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},l.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},l.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},l.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},l.prototype.writeUInt8=function(a,b,c){var d=this;c||(D.ok(void 0!==a&&null!==a,"missing value"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],8:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],3:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used>>0):(e=a.parent[a.offset+b+2]<<16,e|=a.parent[a.offset+b+1]<<8,e|=a.parent[a.offset+b],e+=a.parent[a.offset+b+3]<<24>>>0),e}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8,a.parent[a.offset+c+1]=255&b):(a.parent[a.offset+c+1]=(65280&b)>>>8,a.parent[a.offset+c]=255&b)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>24,a.parent[a.offset+c+1]=255&b>>>16,a.parent[a.offset+c+2]=255&b>>>8,a.parent[a.offset+c+3]=255&b):(a.parent[a.offset+c+3]=255&b>>>24,a.parent[a.offset+c+2]=255&b>>>16,a.parent[a.offset+c+1]=255&b>>>8,a.parent[a.offset+c]=255&b)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="..."; +break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}]},{},[]),b.exports=a("buffer-browserify")},{}],54:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],55:[function(a,b,c){!function(){"use strict";function d(a){var b=function(a){return"string"==typeof a?a:"object"==typeof a?a.hashCode?a.hashCode():""+a:""+a},c=a.declare({instance:{constructor:function(){this.__entries=[],this.__keys=[],this.__values=[]},pushValue:function(a,b){return this.__keys.push(a),this.__values.push(b),this.__entries.push({key:a,value:b}),b},remove:function(a){for(var b,c=null,d=this.__entries,e=this.__keys,f=this.__values,g=d.length-1;g>=0;g--)if((b=d[g])&&b.key===a)return d.splice(g,1),e.splice(g,1),f.splice(g,1),b.value;return c},set:function(a,b){for(var c=null,d=this.__entries,e=this.__values,f=d.length-1;f>=0;f--){var g=d[f];if(g&&a===g.key){e[f]=b,g.value=b,c=b;break}}return c||d.push({key:a,value:b}),c},find:function(a){for(var b,c=null,d=this.__entries,e=d.length-1;e>=0;e--)if(b=d[e],b&&a===b.key){c=b.value;break}return c},getEntrySet:function(){return this.__entries},getKeys:function(){return this.__keys},getValues:function(){return this.__values}}});return a.declare({instance:{constructor:function(){this.__map={}},entrySet:function(){var a=[],b=this.__map;for(var c in b)b.hasOwnProperty(c)&&(a=a.concat(b[c].getEntrySet()));return a},put:function(a,d){var e=b(a),f=null;return(f=this.__map[e])||(f=this.__map[e]=new c),f.pushValue(a,d),d},remove:function(a){var c=b(a),d=null,e=this.__map[c];return e&&(d=e.remove(a)),d},get:function(a){var c,d=b(a),e=null;return(c=this.__map[d])&&(e=c.find(a)),e},set:function(a,d){var e=b(a),f=null,g=null,h=this.__map;return f=(g=h[e])?g.set(a,d):(h[e]=new c).pushValue(a,d)},contains:function(a){var c=b(a),d=!1,e=null;return(e=this.__map[c])&&(d=!!e.find(a)),d},concat:function(a){if(a instanceof this._static){for(var b=new this._static,c=a.entrySet().concat(this.entrySet()),d=c.length-1;d>=0;d--){var e=c[d];b.put(e.key,e.value)}return b}throw new TypeError("When joining hashtables the joining arg must be a HashTable")},filter:function(b,c){var d=this.entrySet(),e=new this._static;d=a.filter(d,b,c);for(var f=d.length-1;f>=0;f--){var g=d[f];e.put(g.key,g.value)}return e},forEach:function(b,c){var d=this.entrySet();a.forEach(d,b,c)},every:function(b,c){var d=this.entrySet();return a.every(d,b,c)},map:function(b,c){var d=this.entrySet();return a.map(d,b,c)},some:function(b,c){var d=this.entrySet();return a.some(d,b,c)},reduce:function(b,c){var d=this.entrySet();return a.reduce(d,b,c)},reduceRight:function(b,c){var d=this.entrySet();return a.reduceRight(d,b,c)},clear:function(){this.__map={}},keys:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getKeys());return a},values:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getValues());return a},isEmpty:function(){return 0===this.keys().length}}})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")))):"function"==typeof define?define(["extended","declare","is-extended","array-extended"],function(a,b,c,e){return d(a().register("declare",b).register(c).register(e))}):this.Ht=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended))}.call(this)},{"array-extended":42,"declare.js":45,extended:46,"is-extended":56}],56:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;!function(){"use strict";function e(a){function b(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}.call(this)},{__browserify_Buffer:53,extended:46}],57:[function(a,b,c){!function(){"use strict";function d(a){function b(a,b){var c=0;return a>b?1:b>a?-1:b?c:1}var c=a.multiply,d=a.declare({instance:{__printNode:function(b,d){var e=[];a.isUndefinedOrNull(b)?(e.push(c(" ",d)),e.push("~"),console.log(e.join(""))):(this.__printNode(b.right,d+1),e.push(c(" ",d)),e.push(b.data+"\n"),console.log(e.join("")),this.__printNode(b.left,d+1))},constructor:function(a){a=a||{},this.compare=a.compare||b,this.__root=null},insert:function(){throw new Error("Not Implemented")},remove:function(){throw new Error("Not Implemented")},clear:function(){this.__root=null},isEmpty:function(){return!this.__root},traverseWithCondition:function(a,b,c){var e=!0;return a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.IN_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.POST_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e&&(e=this.traverseWithCondition(a.right,b,c)),e&&(e=c(a.data)))):b===d.REVERSE_ORDER&&(e=this.traverseWithCondition(a.right,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c))))),e},traverse:function(a,b,c){a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(c(a.data),this.traverse(a.left,b,c),this.traverse(a.right,b,c)):b===d.IN_ORDER?(this.traverse(a.left,b,c),c(a.data),this.traverse(a.right,b,c)):b===d.POST_ORDER?(this.traverse(a.left,b,c),this.traverse(a.right,b,c),c(a.data)):b===d.REVERSE_ORDER&&(this.traverse(a.right,b,c),c(a.data),this.traverse(a.left,b,c)))},forEach:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this,this.traverse(this.__root,c,function(c){a.call(b,c,this)})},map:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){e.insert(a.call(b,c,this))}),e},filter:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){a.call(b,c,this)&&e.insert(c)}),e},reduce:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduce.apply(a,f)},reduceRight:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduceRight.apply(a,f)},every:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=!1;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this)}),e},some:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this),!e}),e},toArray:function(a){a=a||d.IN_ORDER;var b=[];return this.traverse(this.__root,a,function(a){b.push(a)}),b},contains:function(a){for(var b=!1,c=this.__root;null!==c;){var d=this.compare(a,c.data);d?c=c[-1===d?"left":"right"]:(b=!0,c=null)}return b},find:function(a){for(var b,c=this.__root;c;){var d=this.compare(a,c.data);if(!d){b=c.data;break}c=c[-1===d?"left":"right"]}return b},findLessThan:function(a,b){var c=[],e=this.compare;return this.traverseWithCondition(this.__root,d.IN_ORDER,function(d){var f=e(a,d);return!b&&0===f||1===f?(c.push(d),!0):!1}),c},findGreaterThan:function(a,b){var c=[],e=this.compare;return this.traverse(this.__root,d.REVERSE_ORDER,function(d){var f=e(a,d);return!b&&0===f||-1===f?(c.push(d),!0):!1}),c},print:function(){this.__printNode(this.__root,0)}},"static":{PRE_ORDER:"pre_order",IN_ORDER:"in_order",POST_ORDER:"post_order",REVERSE_ORDER:"reverse_order"}}),e=function(){var a=Math.abs,b=function(a){return{data:a,balance:0,left:null,right:null}},e=function(a,b,c){var d=a[c];return a[c]=d[b],d[b]=a,d},f=function(a,b,c){return a[c]=e(a[c],c,b),e(a,b,c)},g=function(a,b,c){var d="left"===b?"right":"left",e=a[b],f=e[d];0===f.balance?a.balance=e.balance=0:f.balance===c?(a.balance=-c,e.balance=0):(a.balance=0,e.balance=c),f.balance=0},h=function(a,b){var c="left"===b?"right":"left",d=a[b],h="left"===b?-1:1;return d.balance===h?(a.balance=d.balance=0,a=e(a,c,b)):(g(a,b,h),a=f(a,c,b)),a},i=function(a,b,c){var d="left"===b?"right":"left",h=a[d],i="left"===b?-1:1;return h.balance===-i?(a.balance=h.balance=0,a=e(a,b,d)):h.balance===i?(g(a,d,-i),a=f(a,b,d)):(a.balance=-i,h.balance=i,a=e(a,b,d),c.done=!0),a},j=function(c,d,e,f){if(null===c||void 0===c)c=b(d);else{var g=-1===f(d,c.data)?"left":"right";c[g]=j(c[g],d,e,f),e.done||(c.balance+="left"===g?-1:1,0===c.balance?e.done=!0:a(c.balance)>1&&(c=h(c,g),e.done=!0))}return c},k=function(b,c,d,e){var f,g,h,j;if(b){if(g=e(c,b.data),0===g){var l=b.left,m=b.right;if(!l||!m)return f=l?"left":"right",h=b[f];for(var n=l;null!==(m=n.right);)n=m;b.data=n.data,c=n.data}if(f=-1===e(b.data,c)?"right":"left",b[f]=k(b[f],c,d,e),!d.done){j=b.balance+="left"===f?1:-1;var o=a(j);1===o?d.done=!0:o>1&&(b=i(b,f,d))}}return b};return d.extend({instance:{insert:function(a){var b={done:!1};this.__root=j(this.__root,a,b,this.compare)},remove:function(a){this.__root=k(this.__root,a,{done:!1},this.compare)},__printNode:function(a,b){var d=[];a?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.balance+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),f=function(){function a(a,b){return{data:a,level:b,left:g,right:g}}function b(a){if(0!==a.level&&a.left.level===a.level){var b=a.left;a.left=b.right,b.right=a,a=b}return a}function e(a){if(0!==a.level&&a.right.right.level===a.level){var b=a.right;a.right=b.left,b.left=a,a=b,a.level++}return a}function f(c,d,h){if(c===g)c=a(d,1);else{var i=-1===h(d,c.data)?"left":"right";c[i]=f(c[i],d,h),c=b(c),c=e(c)}return c}var g={level:0,data:null},h=function(a,c,d){var f,i;if(a!==g){var j=d(c,a.data);if(0===j)if(f=a.left,i=a.right,f!==g&&i!==g){for(var k=f;k.right!==g;)k=k.right;a.data=k.data,a.left=h(f,k.data,d)}else a=a[f===g?"right":"left"];else{var l=-1===j?"left":"right";a[l]=h(a[l],c,d)}}if(a!==g){var m=a.level,n=a.left.level,o=a.right.level;(m-1>n||m-1>o)&&(o>--a.level&&(a.right.level=a.level),a=b(a),a=e(a))}return a};return d.extend({instance:{isEmpty:function(){return this.__root===g||this._super(arguments)},insert:function(a){this.__root||(this.__root=g),this.__root=f(this.__root,a,this.compare)},remove:function(a){this.__root=h(this.__root,a,this.compare)},traverseWithCondition:function(a){var b=!0;return a!==g?this._super(arguments):b},traverse:function(a){a!==g&&this._super(arguments)},contains:function(){return this.__root!==g?this._super(arguments):!1},__printNode:function(a,b){var d=[];a&&a.data?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.level+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),g=d.extend({instance:{insert:function(a){if(!this.__root)return this.__root={data:a,parent:null,left:null,right:null};for(var b=this.compare,c=this.__root;null!==c;){var d=b(a,c.data);if(!d)return;var e=-1===d?"left":"right",f=c[e];if(!f)return c[e]={data:a,parent:c,left:null,right:null};c=f}},remove:function(a){if(null!==this.__root){for(var b,c={right:this.__root},d=c,e=null,f="right";null!==d[f];){b=d,d=d[f];var g=this.compare(a,d.data);g||(e=d),f=-1===g?"left":"right"}null!==e&&(e.data=d.data,b[b.right===d?"right":"left"]=d[null===d.left?"right":"left"]),this.__root=c.right}}}}),h=function(){var a="RED",b="BLACK",e=function(a){return null!==a&&a.red},f=function(a){return{data:a,red:!0,left:null,right:null}},g=function(a,b,c){if(!a)return f(b);var d=c(b,a.data);if(d){var j=-1===d?"left":"right",k="left"===j?"right":"left";a[j]=g(a[j],b,c);var l=a[j];if(e(l)){var m=a[k];e(m)?(a.red=!0,l.red=!1,m.red=!1):e(l[j])?a=h(a,k):e(l[k])&&(a=i(a,k))}}return a},h=function(a,b){var c="left"===b?"right":"left",d=a[c];return a[c]=d[b],d[b]=a,a.red=!0,d.red=!1,d},i=function(a,b){var c="left"===b?"right":"left";return a[c]=h(a[c],c),h(a,b)},j=function(a,b,c,d){if(a){var f;if(0===d(b,a.data)){if(!a.left||!a.right){var g=a[a.left?"left":"right"];return e(a)?c.done=!0:e(g)&&(g.red=!1,c.done=!0),g}for(var h,i=a.right;null!==i.left;)h=i,i=i.left;h&&(h.left=null),a.data=i.data,b=i.data}f=-1===d(b,a.data)?"left":"right",a[f]=j(a[f],b,c,d),c.done||(a=k(a,f,c))}else c.done=!0;return a},k=function(a,b,c){var d="left"===b?"right":"left",f=a,g=f[d];if(e(g)&&(a=h(a,b),g=f[d]),null!==g)if(e(g.left)||e(g.right)){var j=f.red,k=a===f;f=(e(g[d])?h:i)(f,b),f.red=j,f.left.red=f.right.red=0,k?a=f:a[b]=f,c.done=!0}else e(f)&&(c.done=!0),f.red=0,g.red=1;return a};return d.extend({instance:{insert:function(a){this.__root=g(this.__root,a,this.compare),this.__root.red=!1},remove:function(a){var b={done:!1},c=j(this.__root,a,b,this.compare);return null!==c&&(c.red=0),this.__root=c,a},__printNode:function(d,e){var f=[];d?(this.__printNode(d.right,e+1),f.push(c(" ",e)),f.push((d.red?a:b)+":"+d.data+"\n"),console.log(f.join("")),this.__printNode(d.left,e+1)):(f.push(c(" ",e)),f.push("~"),console.log(f.join("")))}}})}();return{Tree:d,AVLTree:e,AnderssonTree:f,BinaryTree:g,RedBlackTree:h,IN_ORDER:d.IN_ORDER,PRE_ORDER:d.PRE_ORDER,POST_ORDER:d.POST_ORDER,REVERSE_ORDER:d.REVERSE_ORDER}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")).register(a("string-extended")))):"function"==typeof define?define(["extended","declare.js","is-extended","array-extended","string-extended"],function(a,b,c,e,f){return d(a().register("declare",b).register(c).register(e).register(f))}):this.leafy=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended).register(this.stringExtended))}.call(this)},{"array-extended":42,"declare.js":45,extended:46,"is-extended":56,"string-extended":60}],58:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b){var c,d;for(c in b)t.call(b,c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}function e(a,b){var c,d,f;for(c in b)t.call(b,c)&&(d=b[c],f=a[c],p(f,d)||(a[c]=r(f)&&r(d)?e(f,d):r(d)?e({},d):d));return a}function f(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)d(a,arguments[b]);return a}function g(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)e(a,arguments[b]);return a}function h(a,b){var c=a.prototype||a;return f(c,b),a}function i(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e=l(a),f=0,g=e.length;g>f;++f)d=e[f],b.call(c||a,a[d],d,a);return a}function j(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e,f=l(a),g={},h=0,i=f.length;i>h;++h)d=f[h],e=a[d],b.call(c||a,e,d,a)&&(g[d]=e);return g}function k(a){if(!r(a))throw new TypeError;for(var b=l(a),c=[],d=0,e=b.length;e>d;++d)c.push(a[b[d]]);return c}function l(a){if(!r(a))throw new TypeError;var b=[];for(var c in a)t.call(a,c)&&b.push(c);return b}function m(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d={},e=0,f=c.length;f>e;++e)b=c[e],d[a[b]]=b;return d}function n(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d=[],e=0,f=c.length;f>e;++e)b=c[e],d.push([b,a[b]]);return d}function o(a,b){if(!r(a))throw new TypeError;q(b)&&(b=[b]);for(var c,d=s(l(a),b),e={},f=0,g=d.length;g>f;++f)c=d[f],e[c]=a[c];return e}var p=b.deepEqual,q=b.isString,r=b.isHash,s=c.difference,t=Object.prototype.hasOwnProperty,u=b.isFunction,v={forEach:i,filter:j,invert:m,values:k,toArray:n,keys:l,omit:o},w={extend:h,merge:f,deepMerge:g,omit:o},x=a.define(b.isObject,w).define(r,v).define(b.isFunction,{extend:h}).expose({hash:v}).expose(w),y=x.extend;return x.extend=function(){return 1===arguments.length?y.extend.apply(x,arguments):(h.apply(null,arguments),void 0)},x}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.objectExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":42,extended:46,"is-extended":56}],59:[function(a,b,c){var d=a("__browserify_process");!function(){"use strict";function e(a,b,c,e,f,g){function h(a,b){return function(){try{l(a.apply(null,arguments)).addCallback(b).addErrback(b)}catch(c){b.errback(c)}}}function i(a,b,c){var d=(new G).callback();return v(a,function(a){d=d.then(c?a:B(null,a)),c||(d=d.then(function(a){return b.push(a),b}))}),d}function j(a){return!w(a)&&y(a.then)}function k(a){var b=new G;return a.then(A(b,"callback"),A(b,"errback")),b.promise()}function l(a){var b;return a=C(arguments),a.length?1===a.length?(a=a.pop(),j(a)?a.addCallback&&a.addErrback?(b=new G,a.addCallback(b.callback),a.addErrback(b.errback)):b=k(a):b=x(a)&&c.every(a,j)?new H(a,!0).promise():(new G).callback(a)):b=new H(c.map(a,function(a){return l(a)}),!0).promise():b=(new G).callback(a).promise(),b}function m(a,b){return function(){var c=new G,d=C(arguments);return d.push(c.resolve),a.apply(b||this,d),c.promise()}}function n(a){if(x(a))return i(a,[],!1);throw new Error("When calling promise.serial the first argument must be an array")}function o(a){if(x(a))return i(a,[],!0);throw new Error("When calling promise.serial the first argument must be an array")}function p(a,b){a=C(arguments);var c=!1;b=a.pop();var d=l(a);return function(){return c?l(b.apply(this,arguments)):(a=arguments,d.then(A(this,function(){return c=!0,b.apply(this,a)})))}}function q(){return new G}function r(a){return new H(a,!0).promise()}function s(a){return q().errback(a)}function t(a){return q().callback(a)}var u,v=c.forEach,w=e.isUndefinedOrNull,x=e.isArray,y=e.isFunction,z=e.isBoolean,A=f.bind,B=f.bindIgnore,C=g.argsToArray;if("function"==typeof setImmediate)u="undefined"!=typeof window?setImmediate.bind(window):setImmediate;else if("undefined"!=typeof d)u=function(a){d.nextTick(a)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,E={},F=E;D.port1.onmessage=function(){E=E.next;var a=E.task;delete E.task,a()},u=function(a){F=F.next={task:a},D.port2.postMessage(0)}}else u=function(a){setTimeout(a,0)};var G=a({instance:{__fired:!1,__results:null,__error:null,__errorCbs:null,__cbs:null,constructor:function(){this.__errorCbs=[],this.__cbs=[],f.bindAll(this,["callback","errback","resolve","classic","__resolve","addCallback","addErrback"])},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__error?this.__errorCbs:this.__cbs,c=b.length,d=this.__error||this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(this,b)})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=a.callback),this.__fired&&this.__results?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=a.errback),this.__fired&&this.__error?this.__callNextTick(a,this.__error):this.__errorCbs.push(a)),this},callback:function(){return this.__fired||(this.__results=arguments,this.__resolve()),this.promise()},errback:function(){return this.__fired||(this.__error=arguments,this.__resolve()),this.promise()},resolve:function(a){return a?this.errback(a):this.callback.apply(this,C(arguments,1)),this +},classic:function(a){return"function"==typeof a&&(this.addErrback(function(b){a(b)}),this.addCallback(function(){a.apply(this,[null].concat(C(arguments)))})),this},then:function(a,b){var c=new G,d=c;return y(b)&&(d=h(b,c)),this.addErrback(d),y(a)?this.addCallback(h(a,c)):this.addCallback(c),c.promise()},both:function(a){return this.then(a,a)},promise:function(){var a={then:A(this,"then"),both:A(this,"both"),promise:function(){return a}};return v(["addCallback","addErrback","classic"],function(b){a[b]=A(this,function(){return this[b].apply(this,arguments),a})},this),a}}}),H=G.extend({instance:{__results:null,__errors:null,__promiseLength:0,__defLength:0,__firedLength:0,normalizeResults:!1,constructor:function(a,b){this.__errors=[],this.__results=[],this.normalizeResults=z(b)?b:!1,this._super(arguments),a&&a.length?(this.__defLength=a.length,v(a,this.__addPromise,this)):this.__resolve()},__addPromise:function(a,b){a.then(A(this,function(){var a=C(arguments);a.unshift(b),this.callback.apply(this,a)}),A(this,function(){var a=C(arguments);a.unshift(b),this.errback.apply(this,a)}))},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__errors.length?this.__errorCbs:this.__cbs,c=b.length,d=this.__errors.length?this.__errors:this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(null,[b])})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=A(a,"callback")),this.__fired&&!this.__errors.length?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=A(a,"errback")),this.__fired&&this.__errors.length?this.__callNextTick(a,this.__errors):this.__errorCbs.push(a)),this},callback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__results[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()},errback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__errors[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()}}});return b.define({isPromiseLike:j}).expose({isPromiseLike:j,when:l,wrap:m,wait:p,serial:n,chain:o,Promise:G,PromiseList:H,promise:q,defer:q,deferredList:r,reject:s,resolve:t})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("declare.js"),a("extended"),a("array-extended"),a("is-extended"),a("function-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["declare","extended","array-extended","is-extended","function-extended","arguments-extended"],function(a,b,c,d,f,g){return e(a,b,c,d,f,g)}):this.promiseExtended=e(this.declare,this.extended,this.arrayExtended,this.isExtended,this.functionExtended,this.argumentsExtended)}.call(this)},{__browserify_process:54,"arguments-extended":41,"array-extended":42,"declare.js":45,extended:46,"function-extended":49,"is-extended":56}],60:[function(a,b,c){!function(){"use strict";function d(a,b,c,d){function e(a,b){var c=a;if(x.test(b)){var d=b.match(x),e=d[1],f=d[3],g=d[4];g&&(g=parseInt(g,10),c=c.length0?"+":"")+d),k&&(k=parseInt(k,10),d=d.lengthe;)d?a+=c:a=c+a,e++;return a}function i(a,c,d){var e=a;if(b.isString(e)){if(a.length>c)if(d){var f=a.length;e=a.substring(f-c,f)}else e=a.substring(0,c)}else e=i(""+e,c);return e}function j(a,d){if(d instanceof Array){var h=0,i=d.length;return a.replace(v,function(a,b,j){var k,l;if(!(i>h))return a;if(k=d[h++],"%s"===a||"%d"===a||"%D"===a)l=k+"";else if("%Z"===a)l=k.toUTCString();else if("%j"===a)try{l=s(k)}catch(m){throw new Error("stringExtended.format : Unable to parse json from ",k)}else switch(b=b.replace(/^\[|\]$/g,""),j){case"s":l=e(k,b);break;case"d":l=f(k,b);break;case"j":l=g(k,b);break;case"D":l=c.format(k,b);break;case"Z":l=c.format(k,b,!0)}return l})}if(t(d))return a.replace(w,function(a,h,i){if(i=d[i],!b.isUndefined(i)){if(!h)return""+i;if(b.isString(i))return e(i,h);if(b.isNumber(i))return f(i,h);if(b.isDate(i))return c.format(i,h);if(b.isObject(i))return g(i,h)}return a});var k=u.call(arguments).slice(1);return j(a,k)}function k(a,b){var c=[];return a&&(a.indexOf(b)>0?c=a.replace(/\s+/g,"").split(b):c.push(a)),c}function l(a,b){var c=[];if(b)for(var d=0;b>d;d++)c.push(a);return c.join("")}function m(a,c){var d,e,f;if(c)if(b.isArray(a))for(d=[],e=0,f=a.length;f>e;e++)d.push(m(a[e],c));else if(c instanceof Array)for(d=a,e=0,f=c.length;f>e;e++)d=m(d,c[e]);else c in z&&(d="["+z[c]+"m"+a+"");return d}function n(a,b){return a.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(a){return b&&-1!==d.indexOf(b,a)?a:"\\"+a})}function o(a){return a.replace(/^\s*|\s*$/g,"")}function p(a){return a.replace(/^\s*/,"")}function q(a){return a.replace(/\s*$/,"")}function r(a){return 0===a.length}var s;"undefined"==typeof JSON?function(){function a(a){return 10>a?"0"+a:a}function c(c){return b.isDate(c)?isFinite(c.valueOf())?c.getUTCFullYear()+"-"+a(c.getUTCMonth()+1)+"-"+a(c.getUTCDate())+"T"+a(c.getUTCHours())+":"+a(c.getUTCMinutes())+":"+a(c.getUTCSeconds())+"Z":null:i(c)?c.valueOf():c}function d(a){return j.lastIndex=0,j.test(a)?'"'+a.replace(j,function(a){var b=k[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(a,b){var i,j,k,l,m,n=f,o=b[a];switch(o&&(o=c(o)),"function"==typeof h&&(o=h.call(b,a,o)),typeof o){case"string":return d(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";if(f+=g,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(l=o.length,i=0;l>i;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":f?"[\n"+f+m.join(",\n"+f)+"\n"+n+"]":"["+m.join(",")+"]",f=n,k}if(h&&"object"==typeof h)for(l=h.length,i=0;l>i;i+=1)"string"==typeof h[i]&&(j=h[i],k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));else for(j in o)Object.prototype.hasOwnProperty.call(o,j)&&(k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));return k=0===m.length?"{}":f?"{\n"+f+m.join(",\n"+f)+"\n"+n+"}":"{"+m.join(",")+"}",f=n,k}}var f,g,h,i=b.tester().isString().isNumber().isBoolean().tester(),j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};s=function(a,b,c){var d;if(f="",g="","number"==typeof c)for(d=0;c>d;d+=1)g+=" ";else"string"==typeof c&&(g=c);if(h=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return e("",{"":a})}}():s=JSON.stringify;var t=b.isHash,u=Array.prototype.slice,v=/%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g,w=/\{(?:\[([^\[|\]]*)\])?(\w+)\}/g,x=/(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/,y=/([1-9][0-9]*)$/g,z={bold:1,bright:1,italic:3,underline:4,blink:5,inverse:7,crossedOut:9,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,redBackground:41,greenBackground:42,yellowBackground:43,blueBackground:44,magentaBackground:45,cyanBackground:46,whiteBackground:47,encircled:52,overlined:53,grey:90,black:90},A={SMILEY:"☺",SOLID_SMILEY:"☻",HEART:"♥",DIAMOND:"♦",CLOVE:"♣",SPADE:"♠",DOT:"•",SQUARE_CIRCLE:"◘",CIRCLE:"○",FILLED_SQUARE_CIRCLE:"◙",MALE:"♂",FEMALE:"♀",EIGHT_NOTE:"♪",DOUBLE_EIGHTH_NOTE:"♫",SUN:"☼",PLAY:"►",REWIND:"◄",UP_DOWN:"↕",PILCROW:"¶",SECTION:"§",THICK_MINUS:"▬",SMALL_UP_DOWN:"↨",UP_ARROW:"↑",DOWN_ARROW:"↓",RIGHT_ARROW:"→",LEFT_ARROW:"←",RIGHT_ANGLE:"∟",LEFT_RIGHT_ARROW:"↔",TRIANGLE:"▲",DOWN_TRIANGLE:"▼",HOUSE:"⌂",C_CEDILLA:"Ç",U_UMLAUT:"ü",E_ACCENT:"é",A_LOWER_CIRCUMFLEX:"â",A_LOWER_UMLAUT:"ä",A_LOWER_GRAVE_ACCENT:"à",A_LOWER_CIRCLE_OVER:"å",C_LOWER_CIRCUMFLEX:"ç",E_LOWER_CIRCUMFLEX:"ê",E_LOWER_UMLAUT:"ë",E_LOWER_GRAVE_ACCENT:"è",I_LOWER_UMLAUT:"ï",I_LOWER_CIRCUMFLEX:"î",I_LOWER_GRAVE_ACCENT:"ì",A_UPPER_UMLAUT:"Ä",A_UPPER_CIRCLE:"Å",E_UPPER_ACCENT:"É",A_E_LOWER:"æ",A_E_UPPER:"Æ",O_LOWER_CIRCUMFLEX:"ô",O_LOWER_UMLAUT:"ö",O_LOWER_GRAVE_ACCENT:"ò",U_LOWER_CIRCUMFLEX:"û",U_LOWER_GRAVE_ACCENT:"ù",Y_LOWER_UMLAUT:"ÿ",O_UPPER_UMLAUT:"Ö",U_UPPER_UMLAUT:"Ü",CENTS:"¢",POUND:"£",YEN:"¥",CURRENCY:"¤",PTS:"₧",FUNCTION:"ƒ",A_LOWER_ACCENT:"á",I_LOWER_ACCENT:"í",O_LOWER_ACCENT:"ó",U_LOWER_ACCENT:"ú",N_LOWER_TILDE:"ñ",N_UPPER_TILDE:"Ñ",A_SUPER:"ª",O_SUPER:"º",UPSIDEDOWN_QUESTION:"¿",SIDEWAYS_L:"⌐",NEGATION:"¬",ONE_HALF:"½",ONE_FOURTH:"¼",UPSIDEDOWN_EXCLAMATION:"¡",DOUBLE_LEFT:"«",DOUBLE_RIGHT:"»",LIGHT_SHADED_BOX:"░",MEDIUM_SHADED_BOX:"▒",DARK_SHADED_BOX:"▓",VERTICAL_LINE:"│",MAZE__SINGLE_RIGHT_T:"┤",MAZE_SINGLE_RIGHT_TOP:"┐",MAZE_SINGLE_RIGHT_BOTTOM_SMALL:"┘",MAZE_SINGLE_LEFT_TOP_SMALL:"┌",MAZE_SINGLE_LEFT_BOTTOM_SMALL:"└",MAZE_SINGLE_LEFT_T:"├",MAZE_SINGLE_BOTTOM_T:"┴",MAZE_SINGLE_TOP_T:"┬",MAZE_SINGLE_CENTER:"┼",MAZE_SINGLE_HORIZONTAL_LINE:"─",MAZE_SINGLE_RIGHT_DOUBLECENTER_T:"╡",MAZE_SINGLE_RIGHT_DOUBLE_BL:"╛",MAZE_SINGLE_RIGHT_DOUBLE_T:"╢",MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP:"╖",MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP:"╕",MAZE_SINGLE_LEFT_DOUBLE_T:"╞",MAZE_SINGLE_BOTTOM_DOUBLE_T:"╧",MAZE_SINGLE_TOP_DOUBLE_T:"╤",MAZE_SINGLE_TOP_DOUBLECENTER_T:"╥",MAZE_SINGLE_BOTTOM_DOUBLECENTER_T:"╨",MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM:"╘",MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP:"╒",MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP:"╓",MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM:"╙",MAZE_SINGLE_LEFT_TOP:"Γ",MAZE_SINGLE_RIGHT_BOTTOM:"╜",MAZE_SINGLE_LEFT_CENTER:"╟",MAZE_SINGLE_DOUBLECENTER_CENTER:"╫",MAZE_SINGLE_DOUBLECROSS_CENTER:"╪",MAZE_DOUBLE_LEFT_CENTER:"╣",MAZE_DOUBLE_VERTICAL:"║",MAZE_DOUBLE_RIGHT_TOP:"╗",MAZE_DOUBLE_RIGHT_BOTTOM:"╝",MAZE_DOUBLE_LEFT_BOTTOM:"╚",MAZE_DOUBLE_LEFT_TOP:"╔",MAZE_DOUBLE_BOTTOM_T:"╩",MAZE_DOUBLE_TOP_T:"╦",MAZE_DOUBLE_LEFT_T:"╠",MAZE_DOUBLE_HORIZONTAL:"═",MAZE_DOUBLE_CROSS:"╬",SOLID_RECTANGLE:"█",THICK_LEFT_VERTICAL:"▌",THICK_RIGHT_VERTICAL:"▐",SOLID_SMALL_RECTANGLE_BOTTOM:"▄",SOLID_SMALL_RECTANGLE_TOP:"▀",PHI_UPPER:"Φ",INFINITY:"∞",INTERSECTION:"∩",DEFINITION:"≡",PLUS_MINUS:"±",GT_EQ:"≥",LT_EQ:"≤",THEREFORE:"⌠",SINCE:"∵",DOESNOT_EXIST:"∄",EXISTS:"∃",FOR_ALL:"∀",EXCLUSIVE_OR:"⊕",BECAUSE:"⌡",DIVIDE:"÷",APPROX:"≈",DEGREE:"°",BOLD_DOT:"∙",DOT_SMALL:"·",CHECK:"√",ITALIC_X:"✗",SUPER_N:"ⁿ",SQUARED:"²",CUBED:"³",SOLID_BOX:"■",PERMILE:"‰",REGISTERED_TM:"®",COPYRIGHT:"©",TRADEMARK:"™",BETA:"β",GAMMA:"γ",ZETA:"ζ",ETA:"η",IOTA:"ι",KAPPA:"κ",LAMBDA:"λ",NU:"ν",XI:"ξ",OMICRON:"ο",RHO:"ρ",UPSILON:"υ",CHI_LOWER:"φ",CHI_UPPER:"χ",PSI:"ψ",ALPHA:"α",ESZETT:"ß",PI:"π",SIGMA_UPPER:"Σ",SIGMA_LOWER:"σ",MU:"µ",TAU:"τ",THETA:"Θ",OMEGA:"Ω",DELTA:"δ",PHI_LOWER:"φ",EPSILON:"ε"},B={toArray:k,pad:h,truncate:i,multiply:l,format:j,style:m,escape:n,trim:o,trimLeft:p,trimRight:q,isEmpty:r};return a.define(b.isString,B).define(b.isArray,{style:m}).expose(B).expose({characters:A})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("date-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","date-extended","array-extended"],function(a,b,c,e){return d(a,b,c,e)}):this.stringExtended=d(this.extended,this.isExtended,this.dateExtended,this.arrayExtended)}.call(this)},{"array-extended":42,"date-extended":43,extended:46,"is-extended":56}]},{},[1]); \ No newline at end of file diff --git a/examples/browser/assets/array-extended.js b/examples/browser/assets/array-extended.js new file mode 100644 index 0000000..ba1aad0 --- /dev/null +++ b/examples/browser/assets/array-extended.js @@ -0,0 +1,3 @@ +/*! array-extended - v0.0.9 - 2013-06-17 + * Copyright (c) 2013 Doug Martin; Licensed MIT */ +!function(){"use strict";function a(a,b,c){function d(a,b){return o(b,function(b,c){return N(c)||(c=[c]),c.unshift(a),b.unshift(c),b},[])}function e(a,b,c){for(var d=[],e=0;e>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(module.exports=a(require("extended"),require("is-extended"),require("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(b,c,d){return a(b,c,d)}):this.arrayExtended=a(this.extended,this.isExtended,this.argumentsExtended)}.call(this); \ No newline at end of file diff --git a/examples/browser/assets/conways.css b/examples/browser/assets/conways.css index 78a3af0..b4eced4 100644 --- a/examples/browser/assets/conways.css +++ b/examples/browser/assets/conways.css @@ -152,6 +152,23 @@ input[type="submit"], input[type="button"] { box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2); } +.sudoku .col { + width: 50px; + height: 50px; + font-size: 30px; + vertical-align: middle; + text-align: center; +} + +.sudoku .col.error { + background-color: rgba(255, 0, 0, 0.43); +} + +.sudoku #grid{ + width: 465px; + height: 470px; +} + .col.live { background-color: black; } diff --git a/examples/browser/rules/conways3d.nools b/examples/browser/rules/conways3d.nools index e9af56a..4f71c5f 100644 --- a/examples/browser/rules/conways3d.nools +++ b/examples/browser/rules/conways3d.nools @@ -71,6 +71,8 @@ rule Transition { if(cell.transition()){ emit("cell-transition", cell); transitioned = true; + }else{ + retract(cell); } }); emit("evaluate"); diff --git a/examples/browser/rules/sudoku.nools b/examples/browser/rules/sudoku.nools new file mode 100644 index 0000000..cd2661f --- /dev/null +++ b/examples/browser/rules/sudoku.nools @@ -0,0 +1,377 @@ + +rule "terminate group" { + salience: -100; + agenda-group: "validate"; + when { + $state: String $state == "validate"; + } + then{ + console.log("Validation complete." ); + retract($state); + halt(); + } +} + + + +rule "duplicate in cell col" { + agenda-group: "validate"; + when{ + $c: Cell $c.value; + $e: Cell $e.value == $c.value from $c.exCells; + } + then { + emit("invalid", $c); + emit("invalid", $e); + } +} + + +rule "halt after setup" { + when{ + $ctr: Counter $ctr.count == 0; + } + then{ + console.log("halt after setup"); + halt(); + } +} + + +rule "emergency halt 2" { + salience: 100; + when{ + $c: Cell !$c.value && $c.count == 0; + } + then{ + console.log("emergency halt cell without a value and no free values"); + halt(); + //process.exit(); + } + +} + +// A Setting object is inserted to define the value of a Cell. +// Rule "set a value" updates the cell and all cell groups containing it. +rule "set a value"{ + when{ + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // a matching Cell, with no value set + $c: Cell $c.rowNo == $rn && $c.colNo == $cn && !$c.value {cellRow: $cr, cellCol: $cc, cellSqr: $cs}; + } + then { + // modify the Cell by setting its value + modify( $c, function(){ this.blockExcept(); this.value = $v;}); + emit("set-value", $c); + console.log( "set cell " + $c.toString() ); + modify( $cr, function(){ this.blockValue( $v ) }); + modify( $cc, function(){ this.blockValue( $v ) }); + modify( $cs, function(){ this.blockValue( $v ) }); + } +} + + +// Rule for removing a value from all cells that are siblings +// in one of the three cell groups. +rule "eliminate a value from Cell" { + salience: 1; + when{ + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // the matching Cell, with the value already set + $mc : Cell $mc.rowNo == $rn && $mc.colNo == $cn && $mc.value == $v {exCells: $exCells}; + + // for all Cells that are in cahoots with the updated cell + $c: Cell $v in $c.free from $exCells; + } + then{ + console.log( "clear " + $v + " from cell " + $c.posAsString() + " because of " + $mc.posAsString() ); + // modify a related Cell by blocking the assigned value + modify( $c, function(){ this.blockValue( $v ); }); + } +} + +//Rule for elimination the Setting fact. +rule "retract setting"{ + when { + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // the matching Cell, with the value already set + $c: Cell $c.rowNo == $rn && $c.colNo == $cn && $c.value == $v; + + // This is the negation of the last pattern in the previous rule. + // Now the Setting fact can be safely retracted. + not( $x: Cell $v in $x.free && $x in $c.exCells); + // count down + $ctr: Counter {count: $count}; + + } + then{ + console.log("retracting " + $s.toString()); + // Discard the Setter fact. + retract( $s ); + console.log("COUNT = %s", $count); + modify( $ctr, function(){ this.count = $count - 1;}); + console.log( "done setting cell " + $c.toString() ); + } +} + + +// Detect a set of candidate values with cardinality 1 for some Cell. +// This is the value to be set. +rule "single"{ + when { + // There is currently no setting under way. + not($ns: Setting); + + // One element in the "free" set. + $c: Cell $c.count == 1 {rowNo: $rn, colNo: $cn}; + } + then { + var i = $c.freeValue(); + console.log( "single " + i + " at " + $c.posAsString() ); + // Insert another Setter fact. + assert( new Setting( $rn, $cn, i ) ); + } +} + +// Detect a set of candidate values with a value that is the only one +// in one of its groups. This is the value to be set. +rule "hidden single" { + when{ + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + // Some integer. + $i: Number; + + // The "free" set contains this number. + $c: Cell $c.count > 1 && $i in $c.free {rowNo: $rn, colNo: $cn}; + + // We have a cell group containing this cell $c + $cg: CellGroup $c in $cg.cells; + // but no other cell from that group contains $i + not ($nc2: Cell $nc2 != $c && $i in $nc2.free from $cg.cells); + } + then { + console.log( "hidden single " + $i + " at " + $c.posAsString() ); + // Insert another Setter fact. + assert( new Setting( $rn, $cn, $i ) ); + } +} + + +// A "naked pair" is two cells in some cell group with their sets of +// permissible values being equal with cardinality 2. These two values +// can be removed from all other candidate lists in the group. +rule "naked pair" { + when { + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + + // One cell with two candidates. + $c1: Cell $c1.count == 2 {free: $f1, cellRow: $r1, rowNo: $rn1, colNo: $cn1, cellSqr: $b1}; + + // The containing cell group. + $cg: CellGroup $cg.count > 2 && $c1 in $cg.cells; + + // Another cell with two candidates, not the one we already have. + $c2: Cell( $c2 != $c1 && deepEqual($c2.free, $f1) ) from $cg.cells; + + // Get one of the "naked pair". + $v: Number from $c1.free; + + // Get some other cell with a candidate equal to one from the pair. + $c3: Cell $c3 != $c1 && $c3 != $c2 && $c3.count > 1 && $v in $c3.free from $cg.cells; + } + then{ + console.log( "remove " + $v + " from " + $c3.posAsString() + " due to naked pair at " + $c1.posAsString() + ":[" + $f1.join(",") + "] and " + $c2.posAsString() + ":[" + $c2.free.join(",") + "]" ); + // Remove the value. + modify( $c3, function(){ this.blockValue( $v ); }); + } +} + +// If two cells within the same cell group contain candidate sets with more than +// two values, with two values being in both of them but in none of the other +// cells, then we have a "hidden pair". We can remove all other candidates from +// these two cells. +// +rule "hidden pair in row" { + when{ + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + // Establish a pair of Integer facts + $i1: Number; + $i2: Number $i2 > $i1; + + // Look for a Cell with these two among its candidates. (The upper bound on + // the number of candidates avoids a lot of useless work during startup.) + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellRow: $cellRow}; + + // Get another one from the same row, with the same pair among its candidates, + $c2: Cell $c2 != $c1 && $c2.cellRow == $cellRow && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + + // Assertain that no other cell in the group has one of these two values. + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellRow.cells) + } + then{ + console.log( "hidden pair in row at " + $c1.posAsString() + " and " + $c2.posAsString() ); + // Set the candidate lists of these two Cells to the "hidden pair". + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + +rule "hidden pair in column"{ + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i1: Number; + $i2: Number $i2 > $i1; + + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellCol: $cellCol}; + $c2: Cell $c2 != $c1 && $c2.cellCol == $cellCol && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellCol.cells) + } + then{ + console.log( "hidden pair in column at " + $c1.posAsString() + " and " + $c2.posAsString() ); + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + +rule "hidden pair in square" { + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i1: Number; + $i2: Number $i2 > $i1; + + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellSqr: $cellSqr}; + $c2: Cell $c2 != $c1 && $c2.cellSqr == $cellSqr && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellSqr.cells) + } + then{ + console.log( "hidden pair in square " + $c1.posAsString() + " and " + $c2.posAsString() ); + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + + +rule "X-wings in rows" { + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + $ca1: Cell $ca1.count > 1 && $i in $ca1.free {cellRow: $ra, rowNo: $rano, cellCol: $c1,colNo: $c1no}; + $cb1: Cell $cb1.count > 1 && $i in $cb1.free && $cb1.rowNo > $rano && $cb1.cellCol == $c1 {cellRow: $rb, rowNo: $rbno}; + not($nc2: Cell $nc2 != $ca1 && $nc2 != $cb1 && $i in $nc2.free from $c1.cells); + + $ca2: Cell $ca2.count > 1 && $1 in $ca2.free && $ca2.cellRow == $ra && $ca2.colNo > $c1no {cellCol: $c2, colNo: $c2no}; + $cb2: Cell $cb2.count > 1 && $i in $cb2.free && $cb2.cellRow == $rb && $cb2.cellCol == $c2; + not($nc3: Cell $nc3 != $ca2 && $nc3 != $cb2 && $i in $nc3.free from $c2.cells); + + $cx: Cell ($cx.rowNo == $rano || $cx.rowNo == $rbno) && $cx.colNo != $c1no && $cx.colNo != $c2no && $cx.count > 1 && $i in $cx.free; + } + then{ + + console.log( "X-wing with " + $i + " in rows " + + $ca1.posAsString() + " - " + $cb1.posAsString() + + $ca2.posAsString() + " - " + $cb2.posAsString() + ", remove from " + $cx.posAsString() ); + + modify( $cx, function(){ this.blockValue( $i ) }); + } +} + +rule "X-wings in columns"{ + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + + $ca1: Cell $ca1.count > 1 && $i in $ca1.free {cellRow: $ra, rowNo: $rano, cellCol: $c1,colNo: $c1no}; + + $ca2: Cell $ca2.count > 1 && $i in $ca2.free && $ca2.colNo > $c1No && $ca2.cellRow == $ra {cellCol: $c2, colNo: $c2no}; + not( $nc2: Cell $nc2 != $ca1 && $nc2 != $ca2 && $i in $nc2.free from $ra.cells); + + $cb1: Cell $cb1.count > 1 && $i in $cb1.free && $cb1.cellCol == $c1 && $cb1.rowNo > $rano {cellRow: $rb, rowNo: $rbno}; + $cb2: Cell $cb2.count > 1 && $i in $cb2.free && $cb2.cellCol == $c2 && $cb2.cellRow == $rb; + not($nc3: Cell $nc3 != $cb1 && $nc3 != $cb2 && $i in $nc3.free from $rb.cells); + + $cx: Cell ($cx.colNo == $c1no || $cx.colNo == $c2no) && $cx.rowNo != $rano && $cx.rowNo != $rbno && $cx.count > 1 && $i in $cx.free; + } + then{ + + console.log( "X-wing with " + $i + " in columns " + + $ca1.posAsString() + " - " + $ca2.posAsString() + + $cb1.posAsString() + " - " + $cb2.posAsString() + ", remove from " + $cx.posAsString() ); + + modify( $cx, function(){this.blockValue( $i ) }); + } +} + +rule "intersection removal column" { + when { + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + // occurs in a Cell + $c: Cell $i in $c.free {cellSqr: $cs, cellCol: $cc}; + // but not in another cell of the same square and a different column + not($nc2: Cell $nc2 != $c && $i in $nc2.free && $nc2.cellSqr == $cs && $nc2.cellCol != $cc ); + + // but there is a cell in the same column and another sqstuare containing this value + $cx: Cell $cx.count > 1 && $i in $cx.free && $cx.cellCol == $cc && $cx.cellSqr != $cs; + } + then{ + // remove the value from that other cell + //if (explain) { + console.log( "column elimination due to " + $c.posAsString() + + ": remove " + $i + " from " + $cx.posAsString() ); + //} + modify( $cx, function(){this.blockValue( $i ) }); + } +} + +rule "intersection removal row"{ + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + // occurs in a Cell + $c: Cell $i in $c.free {cellSqr: $cs, cellRow: $cr}; + // but not in another cell of the same square and a different row + not($nc2: Cell $nc2 != $c && $i in $nc2.free && $nc2.cellSqr == $cs && $nc2.cellRow != $cr); + + // but there is a cell in the same row and another square containing this value + $cx: Cell $cx.count > 1 && $i in $cx.free && $cx.cellRow == $cr && $cx.cellSqr != $cs; + } + then { + // remove the value from that other cell + //if (explain) { + console.log( "row elimination due to " + $c.posAsString() + + ": remove " + $i + " from " + $cx.posAsString() ); + //} + modify( $cx, function(){ this.blockValue( $i ) }); + } +} diff --git a/examples/browser/src/sudoku.js b/examples/browser/src/sudoku.js new file mode 100644 index 0000000..31da919 --- /dev/null +++ b/examples/browser/src/sudoku.js @@ -0,0 +1,368 @@ +(function () { + /*global $:true*/ + var declare = this.declare, + arr = this.arrayExtended, + unique = arr.unique; + + var allNine = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + + var SetOfNine = declare({ + instance: { + + free: null, + count: 0, + + constructor: function () { + this.count = (this.free = allNine.slice()).length; + }, + + blockValue: function (value) { + var index = arr.indexOf(this.free, value); + if (index !== -1) { + this.free.splice(index, 1); + this.count = this.free.length; + } + return this; + }, + + blockExcept: function (values) { + this.free = values || []; + this.count = this.free.length; + return this; + }, + + freeValue: function () { + return this.free[0]; + } + } + }).as(this, "SetOfNine"); + + var CellGroup = SetOfNine.extend({ + instance: { + cells: null, + + constructor: function () { + this._super(arguments); + this.cells = []; + }, + + addCell: function (cell) { + this.cells.push(cell); + } + } + }).as(this, "CellGroup"); + + + var CellFile = CellGroup.extend({ + instance: { + number: null, + + constructor: function (number) { + this._super(arguments); + this.number = number; + }, + + toString: function () { + var ret = [], cells = this.cells; + for (var i = 0, l = cells.length; i < l; i++) { + ret.push(cells[i].toString()); + } + return ret.join(", "); + } + } + }).as(this, "CellFile"); + + var Cell = SetOfNine.extend({ + instance: { + value: null, + cellRow: null, + cellCol: null, + cellSqr: null, + exCells: null, + el: null, + + constructor: function () { + this._super(arguments); + this.exCells = []; + }, + + makeReferences: function (cr, col, sqr) { + this.cellRow = cr; + this.cellCol = col; + this.cellSqr = sqr; + this.colNo = col.number; + this.rowNo = cr.number; + this.exCells = unique(this.exCells.concat(cr.cells).concat(col.cells).concat(sqr.cells)); + this.exCells.splice(this.exCells.indexOf(this), 1); + return this; + }, + + toString: function () { + return [this.posAsString(), this.valueAsString()].join(": "); + }, + + valueAsString: function () { + return this.value === null ? " ": this.value; + }, + + posAsString: function () { + return ["[", this.cellRow.number, ",", this.cellCol.number, "]"].join(""); + } + } + }).as(this, "Cell"); + + var CellCol = CellFile.extend({ + instance: { + toString: function () { + return ["Column ", this.number, ": ", this._super(arguments)]; + } + } + }).as(this, "CellCol"); + + + var CellRow = CellFile.extend({ + instance: { + toString: function () { + return ["Row ", this.number, ": ", this._super(arguments)]; + } + } + }).as(this, "CellRow"); + + var CellSqr = CellGroup.extend({ + instance: { + constructor: function (cr1, cr2, cr3, cc1, cc2, cc3) { + this._super(arguments); + for (var i = cr1.number; i <= cr3.number; i++) { + this.addCell(cc1.cells[i]); + this.addCell(cc2.cells[i]); + this.addCell(cc3.cells[i]); + } + + } + } + }).as(this, "CellSqr"); + + var Counter = declare({ + instance: { + count: 0, + constructor: function (count) { + this.count = count; + } + } + }).as(this, "Counter"); + + + var Setting = declare({ + instance: { + rowNo: null, + colNo: null, + value: null, + + constructor: function (row, col, value) { + this.rowNo = row; + this.colNo = col; + this.value = value; + }, + + toString: function () { + return "Setting [" + this.rowNo + "," + this.colNo + "] : " + this.value; + } + + } + }).as(this, "Setting"); + + + var Stepping = declare({ + instance: { + emergency: false + } + }).as(this, "Stepping"); + + var Sudoku = declare({ + instance: { + + constructor: function (flow, statsListener) { + this.rows = []; + this.cols = []; + this.sqrs = []; + this.cells = []; + this.flow = flow; + this.statsListener = statsListener; + this.session = null; + this.stepping = null; + }, + + stop: function () { + if (this.session) { + this.session.halt(); + this.session.dispose(); + } + return this; + }, + + clear: function () { + this.stop(); + this.setCellValues([]); + }, + + step: function () { + this.session.modify(this.counter, function () { + this.count = 1; + }); + if (!this.stepping) { + this.session.assert(new Stepping()); + } + return this.session.matchUntilHalt(function (err) { + if (err) { + console.log(err); + } + }); + }, + + solve: function () { + this.session.modify(this.counter, function () { + this.count = Infinity; + }); + if (this.stepping) { + this.session.retract(this.stepping); + } + return this.session.match(function (err) { + if (err) { + console.log(err); + } + }); + }, + + setCellValue: function setCellValue(cell) { + cell.el.text(cell.value ? cell.value: ""); + return cell; + }, + + create: function () { + var grid; + (grid = $("#grid")).empty(); + var rows = this.rows, cols = this.cols, sqrs = this.sqrs, session = this.session; + for (var i = 0; i < 9; i++) { + session.assert(i + 1); + rows[i] = new CellRow(i); + cols[i] = new CellCol(i); + } + + var cells = this.cells = [], iCol; + for (var iRow = 0; iRow < 9; iRow++) { + var rowDom = $("

      ").addClass("row").appendTo(grid); + cells[iRow] = []; + for (iCol = 0; iCol < 9; iCol++) { + var cell = cells[iRow][iCol] = new Cell(); + cell.el = $("
      ").appendTo(rowDom); + rows[iRow].addCell(cell); + cols[iCol].addCell(cell); + } + } + + for (i = 0; i < 3; i++) { + sqrs[i] = []; + for (var j = 0; j < 3; j++) { + sqrs[i][j] = new CellSqr(rows[i * 3], rows[i * 3 + 1], rows[i * 3 + 2], + cols[j * 3], cols[j * 3 + 1], cols[j * 3 + 2]); + } + } + + for (iRow = 0; iRow < 9; iRow++) { + for (iCol = 0; iCol < 9; iCol++) { + session.assert(cells[iRow][iCol].makeReferences(rows[iRow], cols[iCol], sqrs[Math.floor(iRow / 3)][Math.floor(iCol / 3)])); + } + session.assert(rows[iRow]); + session.assert(cols[iRow]); + session.assert(sqrs[Math.floor(iRow / 3)][iRow % 3]); + } + return this; + }, + + setCellValues: function (cellValues) { + this.stop(); + var session = (this.session = this.statsListener.listen(this.flow.getSession())) + .on("set-value", this.setCellValue); + + var s000 = new Setting(0, 0, 0); + this.session.assert(s000); + this.create(); + + var initial = 0; + for (var iRow = 0; iRow < 9; iRow++) { + var row = cellValues[iRow] || []; + for (var iCol = 0; iCol < 9; iCol++) { + var value = row[iCol] || null; + if (value) { + session.assert(new Setting(iRow, iCol, value)); + initial++; + //console.log(initial); + } + } + } + var counter = this.counter = new Counter(initial); + this.session.assert(counter); + this.session.retract(s000); + return this.session.matchUntilHalt(function (err) { + if (err) { + console.log(err); + } + this.dumpGrid(); + }.bind(this)); + }, + + dumpGrid: function () { + var cells = this.cells; + var print = [" "]; + for (var iCol = 0; iCol < 9; iCol++) { + print.push("Col: " + iCol + " "); + } + console.log(print.join("")); + for (var iRow = 0; iRow < 9; iRow++) { + print = ["Row " + (iRow) + ": "]; + for (iCol = 0; iCol < 9; iCol++) { + if (cells[iRow][iCol].value !== null) { + print.push(" --- " + cells[iRow][iCol].value + " --- "); + } else { + var perms = cells[iRow][iCol].free, sb = []; + for (var i = 1; i <= 9; i++) { + if (perms.indexOf(i) !== -1) { + sb.push(i); + } else { + sb.push(' '); + } + } + print.push(" % " + sb.join("")); + } + } + console.log(print.join("")); + } + }, + + setInvalidCellValue: function setCellValue(cell) { + cell.el.addClass("error"); + return cell; + }, + + validate: function () { + this.session.assert("validate"); + return this.session.focus("validate") + .on("invalid", this.setInvalidCellValue) + .matchUntilHalt(); + } + + } + }); + + this.Sudoku = Sudoku; +}).call(this); + + + + + + + + + + diff --git a/examples/browser/src/sudokuPatterns.js b/examples/browser/src/sudokuPatterns.js new file mode 100644 index 0000000..c73a45c --- /dev/null +++ b/examples/browser/src/sudokuPatterns.js @@ -0,0 +1,90 @@ +(function () { + + this.sudokuExamples = { + Simple: [ + [null, 5, 6, 8, null, 1, 9, 4, null], + [9, null, null, 6, null, 5, null, null, 3], + [7, null, null, 4, 9, 3, null, null, 8], + [8, 9, 7, null, 4, null, 6, 3, 5], + [null, null, 3, 9, null, 6, 8, null, null], + [4, 6, 5, null, 8, null, 2, 9, 1], + [5, null, null, 2, 6, 9, null, null, 7], + [6, null, null, 5, null, 4, null, null, 9], + [null, 4, 9, 7, null, 8, 3, 5, null] + ], + + Medium: [ + [8, 4, 7, null, null, null, 2, 5, 6], + [5, null, null, null, 8, null, null, null, 4], + [2, null, null, null, 7, null, null, null, 8], + [null, null, null, 3, null, 8, null, null, null], + [null, 5, 1, null, null, null, 8, 7, 2], + [null, null, null, 5, null, 7, null, null, null], + [4, null, null, null, 5, null, null, null, 7], + [6, null, null, null, 3, null, null, null, 9], + [1, 3, 2, null, null, null, 4, 8, 5] + ], + + "Hard 1": [ + [null, null, null, null, 5, 1, null, 8, null], + [null, 8, null, null, 4, null, null, null, 5], + [null, null, 3, null, null, null, 2, null, null], + [null, null, null, null, 6, null, null, null, 9], + [6, 7, null, 4, null, 9, null, 1, 3], + [8, null, null, null, 3, null, null, null, null], + [null, null, 2, null, null, null, 4, null, null], + [5, null, null, null, 9, null, null, 2, null], + [null, 9, null, 7, 1, null, null, null, null] + ], + + "Hard 2": [ + [null, null, null, 6, null, null, 1, null, null], + [null, null, null, null, null, 5, null, null, 6], + [5, null, 7, null, null, null, 2, 3, null], + [null, 8, null, 9, null, 7, null, null, null], + [9, 3, null, null, null, null, null, 6, 7], + [null, null, null, 4, null, 6, null, 1, null], + [null, 7, 4, null, null, null, 9, null, 1], + [8, null, null, 7, null, null, null, null, null], + [null, null, 3, null, null, 8, null, null, null] + ], + + "Hard 3": [ + [null, 8, null, null, null, 6, null, null, 5], + [2, null, null, null, null, null, 4, 8, null], + [null, null, 9, null, null, 8, null, 1, null], + [null, null, null, null, 8, null, 1, null, 2], + [null, null, null, 3, null, 1, null, null, null], + [6, null, 1, null, 9, null, null, null, null], + [null, 9, null, 4, null, null, 8, null, null], + [null, 7, 6, null, null, null, null, null, 3], + [1, null, null, 7, null, null, null, 5, null] + ], + + "Hard 4": [ + [null, null, null, null, null, 4, null, 9, 5], + [6, 7, null, 5, null, null, null, 1, null], + [null, null, null, 6, null, 9, null, null, null], + [null, 2, null, null, null, null, 4, null, null], + [8, 1, null, null, null, null, null, 7, 2], + [null, null, 7, null, null, null, null, 8, null], + [null, null, null, 3, null, 5, null, null, null], + [null, 6, null, null, null, 1, null, 5, 8], + [7, 3, null, 9, null, null, null, null, null] + ], + + "Broken": [ + [5, null, null, null, null, 4, null, 9, 5], + [6, 7, null, 5, null, null, null, 1, null], + [null, null, null, 6, null, 9, null, null, null], + [null, 2, null, null, null, null, 4, null, null], + [8, 1, null, null, null, null, null, 7, 2], + [null, null, 7, null, null, null, null, 8, null], + [8, null, null, 3, null, 5, null, null, null], + [null, 6, null, null, null, 1, null, 5, 8], + [7, 3, null, 9, null, null, null, null, null] + ] + + }; + +}).call(this); \ No newline at end of file diff --git a/examples/browser/sudoku.html b/examples/browser/sudoku.html new file mode 100644 index 0000000..81afdba --- /dev/null +++ b/examples/browser/sudoku.html @@ -0,0 +1,146 @@ + + + + + + Sudoku + + + + + + +
      +
      +

      Sudoku

      + +
      + + + + + + +
      +
      +
      +
      + +
      +
      +
      + + + + + + + + + + + + + + + + + + + + diff --git a/examples/counter/counter.nools b/examples/counter/counter.nools index c0f71ad..77c3673 100644 --- a/examples/counter/counter.nools +++ b/examples/counter/counter.nools @@ -26,7 +26,7 @@ rule "not count" { } } -rule count { +rule count1 { when{ $ctr: Counter $ctr.count % 1000 == 0 {count: $count} } @@ -36,7 +36,7 @@ rule count { } } -rule count { +rule count2 { when{ $ctr: Counter {count: $count} } diff --git a/examples/counter/index.js b/examples/counter/index.js index 1653efb..7715a42 100644 --- a/examples/counter/index.js +++ b/examples/counter/index.js @@ -4,4 +4,7 @@ var flow = nools.compile(require.resolve("./counter.nools")); flow.getSession().matchUntilHalt().then(function () { //halt finally invoked + console.log("done"); +}, function () { + console.log(err); }); diff --git a/examples/sudoku/index.js b/examples/sudoku/index.js new file mode 100644 index 0000000..1524f48 --- /dev/null +++ b/examples/sudoku/index.js @@ -0,0 +1,121 @@ +var nools = require("../../index.js"), + sudoku = require("./lib/sudoku"); + +var flow = nools.compile(require.resolve("./lib/rules/sudoku.nools"), { + define: { + CellGroup: sudoku.CellGroup, + Cell: sudoku.Cell, + CellCol: sudoku.CellCol, + CellRow: sudoku.CellCol, + CellSqr: sudoku.CellSqr, + Counter: sudoku.Counter, + Setting: sudoku.Setting, + Stepping: sudoku.Stepping + }, + scope: { + explain: true + } +}); + + +var simple = [ + [null, 5, 6, 8, null, 1, 9, 4, null], + [9, null, null, 6, null, 5, null, null, 3], + [7, null, null, 4, 9, 3, null, null, 8], + [8, 9, 7, null, 4, null, 6, 3, 5], + [null, null, 3, 9, null, 6, 8, null, null], + [4, 6, 5, null, 8, null, 2, 9, 1], + [5, null, null, 2, 6, 9, null, null, 7], + [6, null, null, 5, null, 4, null, null, 9], + [null, 4, 9, 7, null, 8, 3, 5, null] +]; + +var medium = [ + [8, 4, 7, null, null, null, 2, 5, 6], + [5, null, null, null, 8, null, null, null, 4], + [2, null, null, null, 7, null, null, null, 8], + [null, null, null, 3, null, 8, null, null, null], + [null, 5, 1, null, null, null, 8, 7, 2], + [null, null, null, 5, null, 7, null, null, null], + [4, null, null, null, 5, null, null, null, 7], + [6, null, null, null, 3, null, null, null, 9], + [1, 3, 2, null, null, null, 4, 8, 5] +]; + +var hard1 = [ + [null, null, null, null, 5, 1, null, 8, null], + [null, 8, null, null, 4, null, null, null, 5], + [null, null, 3, null, null, null, 2, null, null], + [null, null, null, null, 6, null, null, null, 9], + [6, 7, null, 4, null, 9, null, 1, 3], + [8, null, null, null, 3, null, null, null, null], + [null, null, 2, null, null, null, 4, null, null], + [5, null, null, null, 9, null, null, 2, null], + [null, 9, null, 7, 1, null, null, null, null] +]; + +var hard2 = [ + [null, null, null, 6, null, null, 1, null, null], + [null, null, null, null, null, 5, null, null, 6], + [5, null, 7, null, null, null, 2, 3, null], + [null, 8, null, 9, null, 7, null, null, null], + [9, 3, null, null, null, null, null, 6, 7], + [null, null, null, 4, null, 6, null, 1, null], + [null, 7, 4, null, null, null, 9, null, 1], + [8, null, null, 7, null, null, null, null, null], + [null, null, 3, null, null, 8, null, null, null] +]; + +var hard3 = [ + [null, 8, null, null, null, 6, null, null, 5], + [2, null, null, null, null, null, 4, 8, null], + [null, null, 9, null, null, 8, null, 1, null], + [null, null, null, null, 8, null, 1, null, 2], + [null, null, null, 3, null, 1, null, null, null], + [6, null, 1, null, 9, null, null, null, null], + [null, 9, null, 4, null, null, 8, null, null], + [null, 7, 6, null, null, null, null, null, 3], + [1, null, null, 7, null, null, null, 5, null] +]; + +var hard4 = [ + [null, null, null, null, null, 4, null, 9, 5], + [6, 7, null, 5, null, null, null, 1, null], + [null, null, null, 6, null, 9, null, null, null], + [null, 2, null, null, null, null, 4, null, null], + [8, 1, null, null, null, null, null, 7, 2], + [null, null, 7, null, null, null, null, 8, null], + [null, null, null, 3, null, 5, null, null, null], + [null, 6, null, null, null, 1, null, 5, 8], + [7, 3, null, 9, null, null, null, null, null] +]; + +var sud = new sudoku.Sudoku(flow); +var repl = require("repl"); +sud.setCellValues(hard4).then(function () { + var sudokuRepl = repl.start("sudoku>>"); + sudokuRepl.context.print = sud.dumpGrid.bind(sud); + sudokuRepl.context.step = function () { + sud.step().classic(function (err) { + if (err) { + console.log(err.stack); + } else { + sud.dumpGrid(); + } + }); + }; + sudokuRepl.context.solve = function () { + sud.solve().classic(function (err) { + if (err) { + console.log(err.stack); + } else { + sud.dumpGrid(); + } + process.exit(); + }); + }; +}); + + + + diff --git a/examples/sudoku/lib/rules/sudoku.nools b/examples/sudoku/lib/rules/sudoku.nools new file mode 100644 index 0000000..088a4f5 --- /dev/null +++ b/examples/sudoku/lib/rules/sudoku.nools @@ -0,0 +1,386 @@ + +rule "halt after setup" { +// salience: 9; + when{ +// not($s: Setting); + $ctr: Counter $ctr.count == 0; + } + then{ + console.log("halt after setup"); + halt(); + } +} + +//rule "emergency halt" { +// salience: -100; +// when{ +// $s: Stepping; +// } +// then{ +// console.log("emergency halt"); +// modify($s, function(){ +// this.emergency = true; +// }); +// halt(); +// } +// +//} + +rule "emergency halt 2" { + salience: 100; + when{ + $c: Cell !$c.value && $c.count == 0; + } + then{ + console.log("emergency halt cell without a value and no free values"); + halt(); + //process.exit(); + } + +} + +// A Setting object is inserted to define the value of a Cell. +// Rule "set a value" updates the cell and all cell groups containing it. +rule "set a value"{ + when{ + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // a matching Cell, with no value set + $c: Cell $c.rowNo == $rn && $c.colNo == $cn && !$c.value {cellRow: $cr, cellCol: $cc, cellSqr: $cs}; + } + then { + // modify the Cell by setting its value + emit("set-value", $c); + modify( $c, function(){ this.blockExcept(); this.value = $v;}); + console.log( "set cell " + $c.toString() ); + modify( $cr, function(){ this.blockValue( $v ) }); + modify( $cc, function(){ this.blockValue( $v ) }); + modify( $cs, function(){ this.blockValue( $v ) }); + } +} + + +// Rule for removing a value from all cells that are siblings +// in one of the three cell groups. +rule "eliminate a value from Cell" { + salience: 1; + when{ + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // the matching Cell, with the value already set + $mc : Cell $mc.rowNo == $rn && $mc.colNo == $cn && $mc.value == $v {exCells: $exCells}; + + // for all Cells that are in cahoots with the updated cell + $c: Cell $v in $c.free from $exCells; + } + then{ + console.log( "clear " + $v + " from cell " + $c.posAsString() + " because of " + $mc.posAsString() ); + // modify a related Cell by blocking the assigned value + modify( $c, function(){ this.blockValue( $v ); }); + } +} + +//Rule for elimination the Setting fact. +rule "retract setting"{ +// salience: 8; + when { + // a Setting with row and column number, and a value + $s: Setting {rowNo: $rn, colNo: $cn, value: $v}; + + // the matching Cell, with the value already set + $c: Cell $c.rowNo == $rn && $c.colNo == $cn && $c.value == $v; + + // This is the negation of the last pattern in the previous rule. + // Now the Setting fact can be safely retracted. + not( $x: Cell $v in $x.free && $x in $c.exCells); + // count down + $ctr: Counter {count: $count}; + + } + then{ + console.log("retracting " + $s.toString()); + // Discard the Setter fact. + retract( $s ); + console.log("COUNT = %s", $count); + modify( $ctr, function(){ this.count = $count - 1;}); + console.log( "done setting cell " + $c.toString() ); + } +} + + +// Detect a set of candidate values with cardinality 1 for some Cell. +// This is the value to be set. +rule "single"{ +// salience: 7; + when { + // There is currently no setting under way. + not($ns: Setting); + + // One element in the "free" set. + $c: Cell $c.count == 1 {rowNo: $rn, colNo: $cn}; + } + then { + var i = $c.freeValue(); + console.log( "single " + i + " at " + $c.posAsString() ); + // Insert another Setter fact. + assert( new Setting( $rn, $cn, i ) ); + } +} + +// Detect a set of candidate values with a value that is the only one +// in one of its groups. This is the value to be set. +rule "hidden single" { +// salience: 6; + when{ + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + // Some integer. + $i: Number; + + // The "free" set contains this number. + $c: Cell $c.count > 1 && $i in $c.free {rowNo: $rn, colNo: $cn}; + + // We have a cell group containing this cell $c + $cg: CellGroup $c in $cg.cells; + // but no other cell from that group contains $i + not ($nc2: Cell $nc2 != $c && $i in $nc2.free from $cg.cells); + } + then { + console.log( "hidden single " + $i + " at " + $c.posAsString() ); + // Insert another Setter fact. + assert( new Setting( $rn, $cn, $i ) ); + } +} + + +// A "naked pair" is two cells in some cell group with their sets of +// permissible values being equal with cardinality 2. These two values +// can be removed from all other candidate lists in the group. +rule "naked pair" { +// salience: 5; + when { + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + + // One cell with two candidates. + $c1: Cell $c1.count == 2 {free: $f1, cellRow: $r1, rowNo: $rn1, colNo: $cn1, cellSqr: $b1}; + + // The containing cell group. + $cg: CellGroup $cg.count > 2 && $c1 in $cg.cells; + + // Another cell with two candidates, not the one we already have. + $c2: Cell( $c2 != $c1 && deepEqual($c2.free, $f1) ) from $cg.cells; + + // Get one of the "naked pair". + $v: Number from $c1.free; + + // Get some other cell with a candidate equal to one from the pair. + $c3: Cell $c3 != $c1 && $c3 != $c2 && $c3.count > 1 && $v in $c3.free from $cg.cells; + } + then{ + console.log( "remove " + $v + " from " + $c3.posAsString() + " due to naked pair at " + $c1.posAsString() + ":[" + $f1.join(",") + "] and " + $c2.posAsString() + ":[" + $c2.free.join(",") + "]" ); + // Remove the value. + modify( $c3, function(){ this.blockValue( $v ); }); + } +} + +// If two cells within the same cell group contain candidate sets with more than +// two values, with two values being in both of them but in none of the other +// cells, then we have a "hidden pair". We can remove all other candidates from +// these two cells. +// +rule "hidden pair in row" { +// salience: 4; + when{ + // There is currently no setting under way. + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + // Establish a pair of Integer facts + $i1: Number; + $i2: Number $i2 > $i1; + + // Look for a Cell with these two among its candidates. (The upper bound on + // the number of candidates avoids a lot of useless work during startup.) + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellRow: $cellRow}; + + // Get another one from the same row, with the same pair among its candidates, + $c2: Cell $c2 != $c1 && $c2.cellRow == $cellRow && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + + // Assertain that no other cell in the group has one of these two values. + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellRow.cells) + } + then{ + console.log( "hidden pair in row at " + $c1.posAsString() + " and " + $c2.posAsString() ); + // Set the candidate lists of these two Cells to the "hidden pair". + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + +rule "hidden pair in column"{ +// salience: 3; + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i1: Number; + $i2: Number $i2 > $i1; + + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellCol: $cellCol}; + $c2: Cell $c2 != $c1 && $c2.cellCol == $cellCol && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellCol.cells) + } + then{ + console.log( "hidden pair in column at " + $c1.posAsString() + " and " + $c2.posAsString() ); + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + +rule "hidden pair in square" { +// salience: 2; + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i1: Number; + $i2: Number $i2 > $i1; + + $c1: Cell $c1.count > 2 && $c1.count < 9 && $i1 in $c1.free && $i2 in $c1.free {rowNo: $rn1, colNo: $cn1, cellSqr: $cellSqr}; + $c2: Cell $c2 != $c1 && $c2.cellSqr == $cellSqr && $c2.count > 2 && $i1 in $c2.free && $i2 in $c2.free; + + not($nc2: Cell $nc2 != $c1 && $nc2 != $c2 && ($i1 in $nc2.free || $i2 in $nc2.free ) from $cellSqr.cells) + } + then{ + console.log( "hidden pair in square " + $c1.posAsString() + " and " + $c2.posAsString() ); + modify( $c1, function(){this.blockExcept([$i1, $i2]) }); + modify( $c2, function(){this.blockExcept([$i1, $i2]) }); + } +} + + +rule "X-wings in rows" { + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + $ca1: Cell $ca1.count > 1 && $i in $ca1.free {cellRow: $ra, rowNo: $rano, cellCol: $c1,colNo: $c1no}; + $cb1: Cell $cb1.count > 1 && $i in $cb1.free && $cb1.rowNo > $rano && $cb1.cellCol == $c1 {cellRow: $rb, rowNo: $rbno}; + not($nc2: Cell $nc2 != $ca1 && $nc2 != $cb1 && $i in $nc2.free from $c1.cells); + + $ca2: Cell $ca2.count > 1 && $1 in $ca2.free && $ca2.cellRow == $ra && $ca2.colNo > $c1no {cellCol: $c2, colNo: $c2no}; + $cb2: Cell $cb2.count > 1 && $i in $cb2.free && $cb2.cellRow == $rb && $cb2.cellCol == $c2; + not($nc3: Cell $nc3 != $ca2 && $nc3 != $cb2 && $i in $nc3.free from $c2.cells); + + $cx: Cell ($cx.rowNo == $rano || $cx.rowNo == $rbno) && $cx.colNo != $c1no && $cx.colNo != $c2no && $cx.count > 1 && $i in $cx.free; + } + then{ + + console.log( "X-wing with " + $i + " in rows " + + $ca1.posAsString() + " - " + $cb1.posAsString() + + $ca2.posAsString() + " - " + $cb2.posAsString() + ", remove from " + $cx.posAsString() ); + + modify( $cx, function(){ this.blockValue( $i ) }); + } +} + +rule "X-wings in columns"{ + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + + $ca1: Cell $ca1.count > 1 && $i in $ca1.free {cellRow: $ra, rowNo: $rano, cellCol: $c1,colNo: $c1no}; + + $ca2: Cell $ca2.count > 1 && $i in $ca2.free && $ca2.colNo > $c1No && $ca2.cellRow == $ra {cellCol: $c2, colNo: $c2no}; + not( $nc2: Cell $nc2 != $ca1 && $nc2 != $ca2 && $i in $nc2.free from $ra.cells); + + $cb1: Cell $cb1.count > 1 && $i in $cb1.free && $cb1.cellCol == $c1 && $cb1.rowNo > $rano {cellRow: $rb, rowNo: $rbno}; + $cb2: Cell $cb2.count > 1 && $i in $cb2.free && $cb2.cellCol == $c2 && $cb2.cellRow == $rb; + not($nc3: Cell $nc3 != $cb1 && $nc3 != $cb2 && $i in $nc3.free from $rb.cells); + + $cx: Cell ($cx.colNo == $c1no || $cx.colNo == $c2no) && $cx.rowNo != $rano && $cx.rowNo != $rbno && $cx.count > 1 && $i in $cx.free; + } + then{ + + console.log( "X-wing with " + $i + " in columns " + + $ca1.posAsString() + " - " + $ca2.posAsString() + + $cb1.posAsString() + " - " + $cb2.posAsString() + ", remove from " + $cx.posAsString() ); + + modify( $cx, function(){this.blockValue( $i ) }); + } +} + +rule "intersection removal column" { +// salience: -1; + when { + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + + // occurs in a Cell + $c: Cell $i in $c.free {cellSqr: $cs, cellCol: $cc}; + // but not in another cell of the same square and a different column + not($nc2: Cell $nc2 != $c && $i in $nc2.free && $nc2.cellSqr == $cs && $nc2.cellCol != $cc ); + + // but there is a cell in the same column and another sqstuare containing this value + $cx: Cell $cx.count > 1 && $i in $cx.free && $cx.cellCol == $cc && $cx.cellSqr != $cs; + } + then{ + // remove the value from that other cell + //if (explain) { + console.log( "column elimination due to " + $c.posAsString() + + ": remove " + $i + " from " + $cx.posAsString() ); + //} + modify( $cx, function(){this.blockValue( $i ) }); + } +} + +rule "intersection removal row"{ +// salience: -2; + when{ + not($ns: Setting); + not($nc: Cell $nc.count == 1 ); + + $i: Number; + // occurs in a Cell + $c: Cell $i in $c.free {cellSqr: $cs, cellRow: $cr}; + // but not in another cell of the same square and a different row + not($nc2: Cell $nc2 != $c && $i in $nc2.free && $nc2.cellSqr == $cs && $nc2.cellRow != $cr); + + // but there is a cell in the same row and another square containing this value + $cx: Cell $cx.count > 1 && $i in $cx.free && $cx.cellRow == $cr && $cx.cellSqr != $cs; + } + then { + // remove the value from that other cell + //if (explain) { + console.log( "row elimination due to " + $c.posAsString() + + ": remove " + $i + " from " + $cx.posAsString() ); + //} + modify( $cx, function(){ this.blockValue( $i ) }); + } +} +//// +////// Y-wing +////// $c1: Cell( count == 2 ) contains a, b +////// $c2: Cell( count == 2 ) contains a, c +////// $c3: Cell( count == 2 ) contains b, c +////// //g12: CellGroup() contains $c1, $c2 +////// //g1e: CellGroup() contains $c1, $c3 +//// +////// $cx: Cell( count > 1 ) contains c +////// // //g12: CellGroup() contains $c1, $c2 +//// +//// diff --git a/examples/sudoku/lib/rules/validate.nools b/examples/sudoku/lib/rules/validate.nools new file mode 100644 index 0000000..e79a504 --- /dev/null +++ b/examples/sudoku/lib/rules/validate.nools @@ -0,0 +1,42 @@ + +rule "terminate group" { + salience: -100 + when {} + then{ + console.log("Validation complete." ); + halt(); + } +} + +rule "duplicate in cell row" { + when{ + $c: Cell $c.value !== null {$v: value}; + $cr: CellRow $c in $cr.cells; + $e: Cell $e != $c && $e.value == $v && $e.cellRow == $cr; + } + then{ + console.log( "cell " + $c.toString() + " has a duplicate in row " + $cr.getNumber() ); + } +} + +rule "duplicate in cell col" { + when{ + $c: Cell $c.value !== null {$v: value}; + $cc: CellCol $c in $cc.cells; + $e: Cell $e != $c && $e.value == $v && $e.cellCol == $cc; + } + then { + console.log( "cell " + $c.toString() + " has a duplicate in col " + $cc.getNumber() ); + } +} + +rule "duplicate in cell sqr" { + when{ + $c: Cell $c.value !== null {$v: value}; + $cs: CellSqr $c in $cs.cells; + $e: Cell $e != $c && $e.value == $v && $e.cellSqr == $cs + } + then{ + System.out.println( "cell " + $c.toString() + " has duplicate in its square of nine." ); + } +} diff --git a/examples/sudoku/lib/sudoku.js b/examples/sudoku/lib/sudoku.js new file mode 100644 index 0000000..bd7a6ab --- /dev/null +++ b/examples/sudoku/lib/sudoku.js @@ -0,0 +1,332 @@ +var declare = require("declare.js"), + arr = require("array-extended"), + format = require("string-extended").format, + unique = arr.unique; + +var allNine = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + +var SetOfNine = declare({ + instance: { + + free: null, + count: 0, + + constructor: function () { + this.count = (this.free = allNine.slice()).length; + }, + + blockValue: function (value) { + var index = arr.indexOf(this.free, value); + if (index !== -1) { + this.free.splice(index, 1); + this.count = this.free.length; + } + return this; + }, + + blockExcept: function (values) { + this.free = values || []; + this.count = this.free.length; + return this; + }, + + freeValue: function () { + return this.free[0]; + } + } +}).as(exports, "SetOfNine"); + +var CellGroup = SetOfNine.extend({ + instance: { + cells: null, + + constructor: function () { + this._super(arguments); + this.cells = []; + }, + + addCell: function (cell) { + this.cells.push(cell); + } + } +}).as(exports, "CellGroup"); + + +var CellFile = CellGroup.extend({ + instance: { + number: null, + + constructor: function (number) { + this._super(arguments); + this.number = number; + }, + + toString: function () { + var ret = [], cells = this.cells; + for (var i = 0, l = cells.length; i < l; i++) { + ret.push(cells[i].toString()); + } + return ret.join(", "); + } + } +}).as(exports, "CellFile"); + +var Cell = SetOfNine.extend({ + instance: { + value: null, + cellRow: null, + cellCol: null, + CellSqr: null, + exCells: null, + + constructor: function () { + this._super(arguments); + this.exCells = []; + }, + + makeReferences: function (cr, col, sqr) { + this.cellRow = cr; + this.cellCol = col; + this.cellSqr = sqr; + this.colNo = col.number; + this.rowNo = cr.number; + this.exCells = unique(this.exCells.concat(cr.cells).concat(col.cells).concat(sqr.cells)); + this.exCells.splice(this.exCells.indexOf(this), 1); + return this; + }, + + toString: function () { + return [this.posAsString(), this.valueAsString()].join(": "); + }, + + valueAsString: function () { + return this.value === null ? " " : this.value; + }, + + posAsString: function () { + return ["[", this.cellRow.number, ",", this.cellCol.number, "]"].join(""); + } + } +}).as(exports, "Cell"); + +var CellCol = CellFile.extend({ + instance: { + toString: function () { + return ["Column ", this.number, ": ", this._super(arguments)]; + } + } +}).as(exports, "CellCol"); + + +var CellRow = CellFile.extend({ + instance: { + toString: function () { + return ["Row ", this.number, ": ", this._super(arguments)]; + } + } +}).as(exports, "CellRow"); + +var CellSqr = CellGroup.extend({ + instance: { + constructor: function (cr1, cr2, cr3, cc1, cc2, cc3) { + this._super(arguments); + for (var i = cr1.number; i <= cr3.number; i++) { + this.addCell(cc1.cells[i]); + this.addCell(cc2.cells[i]); + this.addCell(cc3.cells[i]); + } + + } + } +}).as(exports, "CellSqr"); + +var Counter = declare({ + instance: { + count: 0, + constructor: function (count) { + this.count = count; + } + } +}).as(exports, "Counter"); + + +var Setting = declare({ + instance: { + rowNo: null, + colNo: null, + value: null, + + constructor: function (row, col, value) { + this.rowNo = row; + this.colNo = col; + this.value = value; + }, + + toString: function () { + return "Setting [" + this.rowNo + "," + this.colNo + "] : " + this.value; + } + + } +}).as(exports, "Setting"); + + +var Stepping = declare({ + instance: { + emergency: false + } +}).as(exports, "Stepping"); + +var Sudoku = declare({ + instance: { + + constructor: function (flow) { + this.rows = []; + this.cols = []; + this.sqrs = []; + this.cells = []; + this.solvedCount = 0; + this.flow = flow; + this.session = null; + this.stepping = null; + }, + + step: function () { + this.session.halt(); + this.session.modify(this.counter, function () { + this.count = 1; + }); + if (!this.stepping) { + this.session.assert((this.stepping = new Stepping())); + } + return this.session.matchUntilHalt(function (err) { + if (err) { + console.log("ERROR %s", err.stack); + } + }); + }, + + solve: function () { + var self = this; + return this.step().then(function () { + self.dumpGrid(); + if (self.solvedCount !== 81) { + return self.solve(); + } + }); + }, + + create: function () { + var rows = this.rows, cols = this.cols, sqrs = this.sqrs, session = this.session; + for (var i = 0; i < 9; i++) { + session.assert(i + 1); + rows[i] = new CellRow(i); + cols[i] = new CellCol(i); + } + + var cells = this.cells = [], iCol; + for (var iRow = 0; iRow < 9; iRow++) { + cells[iRow] = []; + for (iCol = 0; iCol < 9; iCol++) { + var cell = cells[iRow][iCol] = new Cell(); + rows[iRow].addCell(cell); + cols[iCol].addCell(cell); + } + } + + for (i = 0; i < 3; i++) { + sqrs[i] = []; + for (var j = 0; j < 3; j++) { + sqrs[i][j] = new CellSqr(rows[i * 3], rows[i * 3 + 1], rows[i * 3 + 2], + cols[j * 3], cols[j * 3 + 1], cols[j * 3 + 2]); + } + } + + for (iRow = 0; iRow < 9; iRow++) { + for (iCol = 0; iCol < 9; iCol++) { + session.assert(cells[iRow][iCol].makeReferences(rows[iRow], cols[iCol], sqrs[Math.floor(iRow / 3)][Math.floor(iCol / 3)])); + } + session.assert(rows[iRow]); + session.assert(cols[iRow]); + session.assert(sqrs[Math.floor(iRow / 3)][iRow % 3]); + } + return this; + }, + + setCellValues: function (cellValues) { + var session = this.session; + if (session !== null) { + session.dispose(); + } + var self = this; + var session = (this.session = this.flow.getSession()) + .on("set-cell", function () { + self.solvedCount++; + }); + + var s000 = new Setting(0, 0, 0); + this.session.assert(s000); + this.create(); + + var initial = 0; + for (var iRow = 0; iRow < 9; iRow++) { + for (var iCol = 0; iCol < 9; iCol++) { + var value = cellValues[iRow][iCol]; + if (value) { + session.assert(new Setting(iRow, iCol, value)); + initial++; + //console.log(initial); + } + } + } + var counter = this.counter = new Counter(initial); + this.session.assert(counter); + this.session.retract(s000); + return this.session.matchUntilHalt(function (err) { + if (err) { + console.log("ERROR %s", err.stack); + } + this.dumpGrid(); + }.bind(this)); + }, + + dumpGrid: function () { + var cells = this.cells; + var print = [" "]; + for (var iCol = 0; iCol < 9; iCol++) { + print.push(format("Col: %d ", iCol)); + } + console.log(print.join("")); + for (var iRow = 0; iRow < 9; iRow++) { + var print = ["Row " + (iRow) + ": "]; + for (iCol = 0; iCol < 9; iCol++) { + if (cells[iRow][iCol].value !== null) { + print.push(format(" --- %d --- ", cells[iRow][iCol].value)); + } else { + var perms = cells[iRow][iCol].free, sb = []; + for (var i = 1; i <= 9; i++) { + if (perms.indexOf(i) !== -1) { + sb.push(i); + } else { + sb.push(' '); + } + } + print.push(format(" %-10s", sb.join(""))); + } + } + console.log(print.join("")); + } + } + + } +}).as(exports, "Sudoku"); + + + + + + + + + + + diff --git a/history.md b/history.md index e2244aa..3b2e144 100644 --- a/history.md +++ b/history.md @@ -1,3 +1,14 @@ +#0.2.0 / 2013-10-14 + +* Nools now supports true modify!!! + * This is a major leap forward for `nools` opening the door for more complex actions and expressions in the rules. +* Added support from for `from` conditions in the `rhs`. +* Fixed issue [#81](https://github.com/C2FO/nools/issues/81). +* Fixed issue [#82](https://github.com/C2FO/nools/issues/82). +* Added new `sudoku` web example. +* Added [Send More Money](http://en.wikipedia.org/wiki/Verbal_arithmetic) benchmark see [#78](https://github.com/C2FO/nools/issues/78). + + #0.1.14 * Fixed issue with async actions and early match termination. diff --git a/lib/agenda.js b/lib/agenda.js index dc97b3c..ac692fd 100644 --- a/lib/agenda.js +++ b/lib/agenda.js @@ -1,41 +1,12 @@ "use strict"; var extd = require("./extended"), - indexOf = extd.indexOf, +//indexOf = extd.indexOf, declare = extd.declare, AVLTree = extd.AVLTree, LinkedList = extd.LinkedList, - EventEmitter = require("events").EventEmitter; + EventEmitter = require("events").EventEmitter, + sortAgenda = require("./conflict").strategy(["salience", "activationRecency"]); -var sortAgenda = function (a, b) { - /*jshint noempty:false*/ - if (a === b) { - return 0; - } - var ret; - var p1 = a.rule.priority, p2 = b.rule.priority; - if (p1 !== p2) { - ret = p1 - p2; - } else if (a.counter !== b.counter) { - ret = a.counter - b.counter; - } - if (!ret) { - - var i = 0; - var aMatchRecency = a.match.recency, - bMatchRecency = b.match.recency, aLength = aMatchRecency.length - 1, bLength = bMatchRecency.length - 1; - while (aMatchRecency[i] === bMatchRecency[i] && i < aLength && i < bLength && i++) { - } - ret = aMatchRecency[i] - bMatchRecency[i]; - if (!ret) { - ret = aLength - bLength; - } - // } - } - if (!ret) { - ret = a.recency - b.recency; - } - return ret > 0 ? 1 : -1; -}; var FactHash = declare({ instance: { @@ -47,60 +18,33 @@ var FactHash = declare({ clear: function () { this.memoryValues.clear(); this.memory = {}; - this.memory.length = this.memoryValues.length = 0; - }, - - get: function (k) { - var node = this.memory[k.id]; - return node ? node.data : []; }, remove: function (v) { - var facts = v.match.facts, - l = facts.length, - mv = this.memoryValues, - m = this.memory, - i = -1, - arr, index, node, fId; - while (++i < l) { - fId = facts[i].id; - node = m[fId]; - arr = node.data; - index = indexOf(arr, v); - arr.splice(index, 1); - if (arr.length === 0) { - mv.remove(node); - delete m[fId]; - } + var hashCode = v.hashCode, + memory = this.memory, + ret = memory[hashCode]; + if (ret) { + this.memoryValues.remove(ret); + delete memory[hashCode]; } + return ret; }, insert: function (insert) { - var facts = insert.match.facts, - mv = this.memoryValues, - m = this.memory, - l = facts.length, - i = -1, - node, o, arr, fId; - while (++i < l) { - o = facts[i]; - fId = o.id; - node = m[o.id]; - if (!node) { - m[fId] = mv.push((arr = [])); - } else { - arr = node.data; - } - arr.push(insert); + var hashCode = insert.hashCode; + if (hashCode in this.memory) { + throw new Error("Activation already in agenda " + insert.rule.name + " agenda"); } + this.memoryValues.push((this.memory[hashCode] = insert)); } } }); -var REVERSE_ORDER = AVLTree.REVERSE_ORDER, DEFAULT_AGENDA_GROUP = "main"; +var DEFAULT_AGENDA_GROUP = "main"; module.exports = declare(EventEmitter, { instance: { @@ -194,30 +138,27 @@ module.exports = declare(EventEmitter, { return v; }, - removeByFact: function (node, fact) { - var rule = this.rules[node.name], tree = rule.tree, factTable = rule.factTable; - var ma = this.getAgendaGroup(node.rule.agendaGroup); - var remove = factTable.get(fact) || []; - var i = remove.length, r; - while (--i > -1) { - r = remove[i]; - factTable.remove(r); - tree.remove(r); - ma.remove(r); + peek: function () { + var tree = this.getFocusedAgenda(), root = tree.__root; + while (root.right) { + root = root.right; } - remove.length = 0; + return root.data; }, - retract: function (node, cb) { - var rule = this.rules[node.name], tree = rule.tree, factTable = rule.factTable; - var ma = this.getAgendaGroup(node.rule.agendaGroup); - tree.traverse(tree.__root, REVERSE_ORDER, function (v) { - if (cb(v)) { - factTable.remove(v); - ma.remove(v); - tree.remove(v); - } - }); + modify: function (node, context) { + this.retract(node, context); + this.insert(node, context); + }, + + retract: function (node, retract) { + var rule = this.rules[node.name]; + retract.rule = node; + var activation = rule.factTable.remove(retract); + if (activation) { + this.getAgendaGroup(node.rule.agendaGroup).remove(activation); + rule.tree.remove(activation); + } }, insert: function (node, insert) { diff --git a/lib/conflict.js b/lib/conflict.js new file mode 100644 index 0000000..d5e600c --- /dev/null +++ b/lib/conflict.js @@ -0,0 +1,54 @@ +var map = require("./extended").map; + +function salience(a, b) { + return a.rule.priority - b.rule.priority; +} + +function bucketCounter(a, b) { + return a.counter - b.counter; +} + +function factRecency(a, b) { + /*jshint noempty: false*/ + var i = 0; + var aMatchRecency = a.match.recency, + bMatchRecency = b.match.recency, aLength = aMatchRecency.length - 1, bLength = bMatchRecency.length - 1; + while (aMatchRecency[i] === bMatchRecency[i] && i < aLength && i < bLength && i++) { + } + var ret = aMatchRecency[i] - bMatchRecency[i]; + if (!ret) { + ret = aLength - bLength; + } + return ret; +} + +function activationRecency(a, b) { + return a.recency - b.recency; +} + +var strategies = { + salience: salience, + bucketCounter: bucketCounter, + factRecency: factRecency, + activationRecency: activationRecency +}; + +exports.strategies = strategies; +exports.strategy = function (strats) { + strats = map(strats, function (s) { + return strategies[s]; + }); + var stratsLength = strats.length; + + return function (a, b) { + var i = -1, ret = 0; + var equal = (a === b) || (a.name === b.name && a.hashCode === b.hashCode); + if (!equal) { + while (++i < stratsLength && !ret) { + ret = strats[i](a, b); + } + ret = ret > 0 ? 1: -1; + } + return ret; + }; +}; \ No newline at end of file diff --git a/lib/constraint.js b/lib/constraint.js index 8f4d2fe..dea1880 100644 --- a/lib/constraint.js +++ b/lib/constraint.js @@ -1,12 +1,14 @@ "use strict"; var extd = require("./extended"), + deepEqual = extd.deepEqual, merge = extd.merge, instanceOf = extd.instanceOf, filter = extd.filter, declare = extd.declare, constraintMatcher; +var id = 0; var Constraint = declare({ instance: { @@ -14,6 +16,7 @@ var Constraint = declare({ if (!constraintMatcher) { constraintMatcher = require("./constraintMatcher"); } + this.id = id++; this.type = type; this.constraint = constraint; }, @@ -168,5 +171,30 @@ Constraint.extend({ } }).as(exports, "HashConstraint"); +Constraint.extend({ + instance: { + constructor: function (prop, constraints) { + this.type = "from"; + this.prop = prop; + this.constraints = constraints; + }, + + equal: function (constraint) { + return instanceOf(constraint, this._static) && this.get("alias") === constraint.get("alias") && deepEqual(this.constraints, constraint.constraints); + }, + + "assert": function () { + return true; + }, + + getters: { + variables: function () { + return this.constraint; + } + } + + } +}).as(exports, "FromConstraint"); + diff --git a/lib/context.js b/lib/context.js index 0ea8b27..246b9db 100644 --- a/lib/context.js +++ b/lib/context.js @@ -1,5 +1,6 @@ "use strict"; var extd = require("./extended"), + isBoolean = extd.isBoolean, declare = extd.declare, merge = extd.merge, union = extd.union, @@ -66,7 +67,19 @@ var Context = declare({ }, isMatch: function (isMatch) { - this.match.isMatch = isMatch; + if (isBoolean(isMatch)) { + this.match.isMatch = isMatch; + } else { + return this.match.isMatch; + } + return this; + }, + + mergeMatch: function (merge) { + var match = this.match = this.match.merge(merge); + this.factHash = match.factHash; + this.hashCode = match.hashCode; + this.factIds = match.factIds; return this; }, diff --git a/lib/extended.js b/lib/extended.js index 08f132f..2323252 100644 --- a/lib/extended.js +++ b/lib/extended.js @@ -1,11 +1,48 @@ +var arr = require("array-extended"), + map = arr.map; + +function plucked(prop) { + var exec = prop.match(/(\w+)\(\)$/); + if (exec) { + prop = exec[1]; + return function (item) { + return item[prop](); + }; + } else { + return function (item) { + return item[prop]; + }; + } +} + +function plucker(prop) { + prop = prop.split("."); + if (prop.length === 1) { + return plucked(prop[0]); + } else { + var pluckers = map(prop, function (prop) { + return plucked(prop); + }); + var l = pluckers.length; + return function (item) { + var i = -1, res = item; + while (++i < l) { + res = pluckers[i](res); + } + return res; + }; + } +} + module.exports = require("extended")() - .register(require("array-extended")) + .register(arr) .register(require("date-extended")) .register(require("object-extended")) .register(require("string-extended")) .register(require("promise-extended")) .register(require("function-extended")) .register(require("is-extended")) + .register("plucker", plucker) .register("HashTable", require("ht")) .register("declare", require("declare.js")) .register(require("leafy")) diff --git a/lib/flow.js b/lib/flow.js index eaafd8a..a2b0276 100644 --- a/lib/flow.js +++ b/lib/flow.js @@ -65,12 +65,11 @@ module.exports = declare(EventEmitter, { // retract followed by an assert. modify: function (fact, cb) { //fact = this.workingMemory.getFact(fact); - this.rootNode.retractFact(this.workingMemory.retractFact(fact)); if ("function" === typeof cb) { cb.call(fact, fact); } + this.rootNode.modifyFact(this.workingMemory.modifyFact(fact)); this.emit("modify", fact); - this.rootNode.assertFact(this.workingMemory.assertFact(fact)); return fact; }, diff --git a/lib/linkedList.js b/lib/linkedList.js index 0015409..e551e8d 100644 --- a/lib/linkedList.js +++ b/lib/linkedList.js @@ -32,7 +32,7 @@ declare({ } else { this.tail = node.prev; } - node.data = node.prev = node.next = null; + //node.data = node.prev = node.next = null; this.length--; }, diff --git a/lib/nodes/aliasNode.js b/lib/nodes/aliasNode.js index d221dd1..f65bfe6 100644 --- a/lib/nodes/aliasNode.js +++ b/lib/nodes/aliasNode.js @@ -16,8 +16,12 @@ AlphaNode.extend({ return this.__propagate("assert", context.set(this.alias, context.fact.object)); }, - retract: function (assertable) { - this.propagateRetract(assertable.fact); + modify: function (context) { + return this.__propagate("modify", context.set(this.alias, context.fact.object)); + }, + + retract: function (context) { + return this.__propagate("retract", context.set(this.alias, context.fact.object)); }, equal: function (other) { diff --git a/lib/nodes/equalityNode.js b/lib/nodes/equalityNode.js index 9a09f32..7db5ec1 100644 --- a/lib/nodes/equalityNode.js +++ b/lib/nodes/equalityNode.js @@ -1,18 +1,53 @@ var AlphaNode = require("./alphaNode"); +function createContextHash(context) { + var ret = [], + paths = context.paths, + i = -1, + l = paths.length; + while (++i < l) { + ret.push(paths[i].id); + } + ret.push(context.hashCode); + return ret.join(":"); + +} + AlphaNode.extend({ instance: { constructor: function () { + this.memory = {}; this._super(arguments); }, assert: function (context) { - if (this.constraint.assert(context.factHash)) { + var hashCode = createContextHash(context); + if ((this.memory[hashCode] = this.constraint.assert(context.factHash))) { this.__propagate("assert", context); } }, + modify: function (context) { + var memory = this.memory, + hashCode = createContextHash(context), + wasMatch = memory[hashCode]; + if ((memory[hashCode] = this.constraint.assert(context.factHash))) { + this.__propagate(wasMatch ? "modify": "assert", context); + } else if (wasMatch) { + this.__propagate("retract", context); + } + }, + + retract: function (context) { + var hashCode = createContextHash(context), + memory = this.memory; + if (memory[hashCode]) { + this.__propagate("retract", context); + } + memory[hashCode] = null; + }, + toString: function () { return "EqualityNode" + this.__count; } diff --git a/lib/nodes/fromNode.js b/lib/nodes/fromNode.js new file mode 100644 index 0000000..7625037 --- /dev/null +++ b/lib/nodes/fromNode.js @@ -0,0 +1,218 @@ +var Node = require("./joinNode"), + extd = require("../extended"), + constraint = require("../constraint"), + EqualityConstraint = constraint.EqualityConstraint, + HashConstraint = constraint.HashConstraint, + ReferenceConstraint = constraint.ReferenceConstraint, + Context = require("../context"), + plucker = extd.plucker, + isEmpty = extd.isEmpty, + forEach = extd.forEach, + isArray = extd.isArray; + +var DEFAULT_MATCH = { + isMatch: function () { + return false; + } +}; + + +Node.extend({ + instance: { + + constructor: function (pattern, wm) { + this._super(arguments); + this.workingMemory = wm; + this.fromMemory = {}; + this.pattern = pattern; + this.type = pattern.get("constraints")[0]; + this.alias = pattern.get("alias"); + this.plucker = plucker(this.from = pattern.from); + var eqConstraints = this.__equalityConstraints = []; + var vars = []; + forEach(this.constraints = this.pattern.get("constraints").slice(1), function (c) { + if (c instanceof EqualityConstraint || c instanceof ReferenceConstraint) { + eqConstraints.push(c); + } else if (c instanceof HashConstraint) { + vars = vars.concat(c.get("variables")); + } + }); + this.__variables = vars; + }, + + __createMatches: function (context) { + var fh = context.factHash, o = this.plucker(fh); + if (isArray(o)) { + for (var i = 0, l = o.length; i < l; i++) { + this.__checkMatch(context, o[i], true); + } + } else { + this.__checkMatch(context, o, true); + } + }, + + __checkMatch: function (context, o, propogate) { + var newContext; + if ((newContext = this.__createMatch(context, o)).isMatch() && propogate) { + this.__propagate("assert", newContext.clone()); + } + return newContext; + }, + + __createMatch: function (lc, o) { + if (this.type.assert(o)) { + var createdFact = this.workingMemory.getFactHandle(o, true), + createdContext, + rc = new Context(createdFact) + .set(this.alias, o), + createdFactId = createdFact.id; + var fh = rc.factHash, lcFh = lc.factHash; + for (var key in lcFh) { + fh[key] = lcFh[key]; + } + var eqConstraints = this.__equalityConstraints, vars = this.__variables, i = -1, l = eqConstraints.length; + while (++i < l) { + if (!eqConstraints[i].assert(fh)) { + createdContext = DEFAULT_MATCH; + break; + } + } + var fm = this.fromMemory[createdFactId]; + if (!fm) { + fm = this.fromMemory[createdFactId] = {}; + } + if (!createdContext) { + var prop; + i = -1; + l = vars.length; + while (++i < l) { + prop = vars[i]; + fh[prop] = o[prop]; + } + lc.fromMatches[createdFact.id] = createdContext = rc.clone(createdFact, null, lc.match.merge(rc.match)); + } + fm[lc.hashCode] = [lc, createdContext]; + return createdContext; + } + return DEFAULT_MATCH; + }, + + retractRight: function () { + throw new Error("Shouldnt have gotten here"); + }, + + removeFromFromMemory: function (context) { + var factId = context.fact.id; + var fm = this.fromMemory[factId]; + if (fm) { + var entry; + for (var i in fm) { + entry = fm[i]; + if (entry[1] === context) { + delete fm[i]; + if (isEmpty(fm)) { + delete this.fromMemory[factId]; + } + break; + } + } + } + + }, + + retractLeft: function (context) { + var ctx = this.removeFromLeftMemory(context); + if (ctx) { + ctx = ctx.data; + var fromMatches = ctx.fromMatches; + for (var i in fromMatches) { + this.removeFromFromMemory(fromMatches[i]); + this.__propagate("retract", fromMatches[i].clone()); + } + } + }, + + modifyLeft: function (context) { + var ctx = this.removeFromLeftMemory(context), newContext, i, l, factId, fact; + if (ctx) { + this.__addToLeftMemory(context); + + var leftContext = ctx.data, + fromMatches = (context.fromMatches = {}), + rightMatches = leftContext.fromMatches, + o = this.plucker(context.factHash); + + if (isArray(o)) { + for (i = 0, l = o.length; i < l; i++) { + newContext = this.__checkMatch(context, o[i], false); + if (newContext.isMatch()) { + factId = newContext.fact.id; + if (factId in rightMatches) { + this.__propagate("modify", newContext.clone()); + } else { + this.__propagate("assert", newContext.clone()); + } + } + } + } else { + newContext = this.__checkMatch(context, o, false); + if (newContext.isMatch()) { + factId = newContext.fact.id; + if (factId in rightMatches) { + this.__propagate("modify", newContext.clone()); + } else { + this.__propagate("assert", newContext.clone()); + } + } + } + for (i in rightMatches) { + if (!(i in fromMatches)) { + this.removeFromFromMemory(rightMatches[i]); + this.__propagate("retract", rightMatches[i].clone()); + } + } + } else { + this.assertLeft(context); + } + fact = context.fact; + factId = fact.id; + var fm = this.fromMemory[factId]; + this.fromMemory[factId] = {}; + if (fm) { + var lc, entry, cc, createdIsMatch, factObject = fact.object; + for (i in fm) { + entry = fm[i]; + lc = entry[0]; + cc = entry[1]; + createdIsMatch = cc.isMatch(); + if (lc.hashCode !== context.hashCode) { + newContext = this.__createMatch(lc, factObject, false); + if (createdIsMatch) { + this.__propagate("retract", cc.clone()); + } + if (newContext.isMatch()) { + this.__propagate(createdIsMatch ? "modify": "assert", newContext.clone()); + } + + } + } + } + }, + + assertLeft: function (context) { + this.__addToLeftMemory(context); + context.fromMatches = {}; + this.__createMatches(context); + }, + + assertRight: function () { + throw new Error("Shouldnt have gotten here"); + }, + + + toString: function () { + return "FromNode" + this.__count; + } + + } +}).as(module); \ No newline at end of file diff --git a/lib/nodes/fromNotNode.js b/lib/nodes/fromNotNode.js new file mode 100644 index 0000000..c1636f1 --- /dev/null +++ b/lib/nodes/fromNotNode.js @@ -0,0 +1,165 @@ +var Node = require("./joinNode"), + extd = require("../extended"), + constraint = require("../constraint"), + EqualityConstraint = constraint.EqualityConstraint, + HashConstraint = constraint.HashConstraint, + ReferenceConstraint = constraint.ReferenceConstraint, + Context = require("../context"), + plucker = extd.plucker, + forEach = extd.forEach, + isArray = extd.isArray; + +Node.extend({ + instance: { + + constructor: function (pattern, workingMemory) { + this._super(arguments); + this.workingMemory = workingMemory; + this.pattern = pattern; + this.type = pattern.get("constraints")[0]; + this.alias = pattern.get("alias"); + this.plucker = plucker(this.from = pattern.from); + this.fromMemory = {}; + var eqConstraints = this.__equalityConstraints = []; + var vars = []; + forEach(this.constraints = this.pattern.get("constraints").slice(1), function (c) { + if (c instanceof EqualityConstraint || c instanceof ReferenceConstraint) { + eqConstraints.push(c); + } else if (c instanceof HashConstraint) { + vars = vars.concat(c.get("variables")); + } + }); + this.__variables = vars; + + }, + + retractLeft: function (context) { + var ctx = this.removeFromLeftMemory(context); + if (ctx) { + ctx = ctx.data; + if (!ctx.blocked) { + this.__propagate("retract", ctx.clone()); + } + } + }, + + __modify: function (context, leftContext) { + var leftContextBlocked = leftContext.blocked; + var fh = context.factHash, o = this.plucker(fh); + if (isArray(o)) { + for (var i = 0, l = o.length; i < l; i++) { + if (this.__isMatch(context, o[i], true)) { + context.blocked = true; + break; + } + } + } else { + context.blocked = this.__isMatch(context, o, true); + } + var newContextBlocked = context.blocked; + if (!newContextBlocked) { + if (leftContextBlocked) { + this.__propagate("assert", context.clone()); + } else { + this.__propagate("modify", context.clone()); + } + } else if (!leftContextBlocked) { + this.__propagate("retract", leftContext.clone()); + } + + }, + + modifyLeft: function (context) { + var ctx = this.removeFromLeftMemory(context); + if (ctx) { + this.__addToLeftMemory(context); + this.__modify(context, ctx.data); + } else { + throw new Error(); + } + var fm = this.fromMemory[context.fact.id]; + this.fromMemory[context.fact.id] = {}; + if (fm) { + for (var i in fm) { + // update any contexts associated with this fact + if (i !== context.hashCode) { + var lc = fm[i]; + ctx = this.removeFromLeftMemory(lc); + if (ctx) { + lc = lc.clone(); + lc.blocked = false; + this.__addToLeftMemory(lc); + this.__modify(lc, ctx.data); + } + } + } + } + }, + + __findMatches: function (context) { + var fh = context.factHash, o = this.plucker(fh), isMatch = false; + if (isArray(o)) { + for (var i = 0, l = o.length; i < l; i++) { + if (this.__isMatch(context, o[i], true)) { + context.blocked = true; + return; + } + } + this.__propagate("assert", context.clone()); + } else if (!(context.blocked = this.__isMatch(context, o, true))) { + this.__propagate("assert", context.clone()); + } + return isMatch; + }, + + __isMatch: function (oc, o, add) { + var ret = false; + if (this.type.assert(o)) { + var createdFact = this.workingMemory.getFactHandle(o); + var context = new Context(createdFact, null) + .mergeMatch(oc.match) + .set(this.alias, o); + if (add) { + var fm = this.fromMemory[createdFact.id]; + if (!fm) { + fm = this.fromMemory[createdFact.id] = {}; + } + fm[oc.hashCode] = oc; + } + var fh = context.factHash; + var eqConstraints = this.__equalityConstraints; + for (var i = 0, l = eqConstraints.length; i < l; i++) { + if (eqConstraints[i].assert(fh)) { + ret = true; + } else { + ret = false; + break; + } + } + } + return ret; + }, + + removeFromLeftMemory: function () { + return this._super(arguments); + }, + + assertLeft: function (context) { + this.__addToLeftMemory(context); + this.__findMatches(context); + }, + + assertRight: function () { + throw new Error("Shouldnt have gotten here"); + }, + + retractRight: function () { + throw new Error("Shouldnt have gotten here"); + }, + + toString: function () { + return "FromNode" + this.__count; + } + + } +}).as(module); \ No newline at end of file diff --git a/lib/nodes/index.js b/lib/nodes/index.js index 49ef321..27b7923 100644 --- a/lib/nodes/index.js +++ b/lib/nodes/index.js @@ -5,6 +5,8 @@ var extd = require("../extended"), declare = extd.declare, pattern = require("../pattern.js"), ObjectPattern = pattern.ObjectPattern, + FromPattern = pattern.FromPattern, + FromNotPattern = pattern.FromNotPattern, NotPattern = pattern.NotPattern, CompositePattern = pattern.CompositePattern, InitialFactPattern = pattern.InitialFactPattern, @@ -15,6 +17,8 @@ var extd = require("../extended"), EqualityNode = require("./equalityNode"), JoinNode = require("./joinNode"), NotNode = require("./notNode"), + FromNode = require("./fromNode"), + FromNotNode = require("./fromNotNode"), LeftAdapterNode = require("./leftAdapterNode"), RightAdapterNode = require("./rightAdapterNode"), TypeNode = require("./typeNode"), @@ -35,6 +39,7 @@ declare({ recency: 0 }; this.agendaTree = agendaTree; + this.workingMemory = wm; }, assertRule: function (rule) { @@ -66,6 +71,13 @@ declare({ } }, + modifyFact: function (fact) { + var typeNodes = this.typeNodes, i = typeNodes.length - 1; + for (; i >= 0; i--) { + typeNodes[i].modify(fact); + } + }, + containsRule: function (name) { return some(this.terminalNodes, function (n) { @@ -129,17 +141,22 @@ declare({ }, __createAdapterNode: function (rule, side) { - return (side === "left" ? new LeftAdapterNode() : new RightAdapterNode()).addRule(rule); + return (side === "left" ? new LeftAdapterNode(): new RightAdapterNode()).addRule(rule); }, __createJoinNode: function (rule, pattern, outNode, side) { var joinNode; if (pattern.rightPattern instanceof NotPattern) { joinNode = new NotNode(); + } else if (pattern.rightPattern instanceof FromNotPattern) { + joinNode = new FromNotNode(pattern.rightPattern, this.workingMemory); + } else if (pattern.rightPattern instanceof FromPattern) { + joinNode = new FromNode(pattern.rightPattern, this.workingMemory); } else { joinNode = new JoinNode(); this.joinNodes.push(joinNode); } + joinNode["__rule__"] = rule; var parentNode = joinNode; if (outNode instanceof JoinNode) { var adapterNode = this.__createAdapterNode(rule, side); @@ -152,10 +169,15 @@ declare({ __addToNetwork: function (rule, pattern, outNode, side) { if (pattern instanceof ObjectPattern) { - if (pattern instanceof NotPattern && (!side || side === "left")) { - return this.__createBetaNode(rule, new CompositePattern(new InitialFactPattern(), pattern), outNode, side); + if ((pattern instanceof NotPattern || pattern instanceof FromPattern || pattern instanceof FromNotPattern) && (!side || side === "left")) { + if (pattern instanceof FromNotPattern) { + this.__createBetaNode(rule, new CompositePattern(new InitialFactPattern(), pattern), outNode, side); + } else { + this.__createBetaNode(rule, new CompositePattern(new InitialFactPattern(), pattern), outNode, side); + } + } else { + this.__createAlphaNode(rule, pattern, outNode, side); } - this.__createAlphaNode(rule, pattern, outNode, side); } else if (pattern instanceof CompositePattern) { this.__createBetaNode(rule, pattern, outNode, side); } @@ -171,36 +193,41 @@ declare({ __createAlphaNode: function (rule, pattern, outNode, side) { - var constraints = pattern.get("constraints"); - var typeNode = this.__createTypeNode(rule, pattern); - var aliasNode = this.__createAliasNode(rule, pattern); - typeNode.addOutNode(aliasNode, pattern); - aliasNode.addParentNode(typeNode); - var parentNode = aliasNode; - var i = constraints.length - 1; - for (; i > 0; i--) { - var constraint = constraints[i], node; - if (constraint instanceof HashConstraint) { - node = this.__createPropertyNode(rule, constraint); - } else if (constraint instanceof ReferenceConstraint) { - outNode.constraint.addConstraint(constraint); - continue; - } else { - node = this.__createEqualityNode(rule, constraint); + var typeNode, parentNode; + if (!(pattern instanceof FromPattern)) { + + var constraints = pattern.get("constraints"); + typeNode = this.__createTypeNode(rule, pattern); + var aliasNode = this.__createAliasNode(rule, pattern); + typeNode.addOutNode(aliasNode, pattern); + aliasNode.addParentNode(typeNode); + parentNode = aliasNode; + var i = constraints.length - 1; + for (; i > 0; i--) { + var constraint = constraints[i], node; + if (constraint instanceof HashConstraint) { + node = this.__createPropertyNode(rule, constraint); + } else if (constraint instanceof ReferenceConstraint) { + outNode.constraint.addConstraint(constraint); + continue; + } else { + node = this.__createEqualityNode(rule, constraint); + } + parentNode.addOutNode(node, pattern); + node.addParentNode(parentNode); + parentNode = node; } - parentNode.addOutNode(node, pattern); - node.addParentNode(parentNode); - parentNode = node; - } - if (outNode instanceof JoinNode) { - var adapterNode = this.__createAdapterNode(rule, side); - adapterNode.addParentNode(parentNode); - parentNode.addOutNode(adapterNode, pattern); - parentNode = adapterNode; + + if (outNode instanceof JoinNode) { + var adapterNode = this.__createAdapterNode(rule, side); + adapterNode.addParentNode(parentNode); + parentNode.addOutNode(adapterNode, pattern); + parentNode = adapterNode; + } + outNode.addParentNode(parentNode); + parentNode.addOutNode(outNode, pattern); + return typeNode; } - outNode.addParentNode(parentNode); - parentNode.addOutNode(outNode, pattern); - return typeNode; }, print: function () { diff --git a/lib/nodes/joinNode.js b/lib/nodes/joinNode.js index 9e80431..f6766b9 100644 --- a/lib/nodes/joinNode.js +++ b/lib/nodes/joinNode.js @@ -1,8 +1,8 @@ var extd = require("../extended"), values = extd.hash.values, - indexOf = extd.indexOf, Node = require("./node"), - JoinReferenceNode = require("./joinReferenceNode"); + JoinReferenceNode = require("./joinReferenceNode"), + LinkedList = require("../linkedList"); Node.extend({ @@ -12,22 +12,26 @@ Node.extend({ this.constraint = new JoinReferenceNode(); this.leftMemory = {}; this.rightMemory = {}; - this.leftTuples = []; - this.rightTuples = []; + this.leftTuples = new LinkedList(); + this.rightTuples = new LinkedList(); }, dispose: function () { this.leftMemory = {}; this.rightMemory = {}; + this.leftTuples.clear(); + this.rightTuples.clear(); }, disposeLeft: function (fact) { this.leftMemory = {}; + this.leftTuples.clear(); this.propagateDispose(fact); }, disposeRight: function (fact) { this.rightMemory = {}; + this.rightTuples.clear(); this.propagateDispose(fact); }, @@ -39,100 +43,245 @@ Node.extend({ return "JoinNode " + this.__count; }, - retractResolve: function (match) { - var es = values(this.leftMemory), j = es.length, leftTuples = this.leftTuples; - while (--j > -1) { - var contexts = es[j], i = contexts.length, context; - while (--i > -1) { - context = contexts[i]; - if (this.resolve(context.match, match)) { - leftTuples.splice(indexOf(leftTuples, context), 1); - contexts.splice(i, 1); - break; - } + retractLeft: function (context) { + context = this.removeFromLeftMemory(context); + if (context) { + context = context.data; + var rightMathces = values(context.rightMatches), + i = -1, + l = rightMathces.length; + while (++i < l) { + this.__propagate("retract", rightMathces[i]); } + }else{ + throw new Error(); } - this._propagateRetractResolve(match); + return this; }, - retractLeft: function (fact) { - var contexts = this.leftMemory[fact.id], tuples = this.leftTuples, i, l; - if (contexts) { - i = -1; - l = contexts.length; + retractRight: function (context) { + context = this.removeFromRightMemory(context); + if (context) { + context = context.data; + var leftMatches = values(context.leftMatches), + i = -1, + l = leftMatches.length; while (++i < l) { - tuples.splice(indexOf(tuples, contexts[i]), 1); + this.__propagate("retract", leftMatches[i]); + } + }else{ + throw new Error(); + } + return this; + }, + + propagateFromLeft: function (context, constraint, rm) { + var mr; + if ((mr = constraint.setRightContext(rm).match()).isMatch) { + this.__propagate("assert", this.__addToMemoryMatches(rm, context, context.clone(null, null, mr))); + } + return this; + }, + + propagateFromRight: function (context, constraint, lm) { + var mr; + if ((mr = constraint.setLeftContext(lm).match()).isMatch) { + this.__propagate("assert", this.__addToMemoryMatches(context, lm, context.clone(null, null, mr))); + } + return this; + }, + + assertLeft: function (context) { + if (this.__addToLeftMemory(context)) { + var rm = this.rightTuples, node = {next: rm.head}, thisConstraint = this.constraint; + if (rm.length) { + thisConstraint.setLeftContext(context); + while ((node = node.next)) { + this.propagateFromLeft(context, thisConstraint, node.data); + } + thisConstraint.clearContexts(); } - delete this.leftMemory[fact.id]; } else { - var tuple; - for (i = 0; i < tuples.length; i++) { - tuple = tuples[i]; - if (indexOf(tuple.factIds, fact.id) !== -1) { - tuples.splice(i, 1); + this.modifyLeft(context); + } + }, + + assertRight: function (context) { + if (this.__addToRightMemory(context)) { + var lm = this.leftTuples; + if (lm.length) { + var node = {next: lm.head}, thisConstraint = this.constraint; + thisConstraint.setRightContext(context); + while ((node = node.next)) { + this.propagateFromRight(context, thisConstraint, node.data); } + thisConstraint.clearContexts(); } + } else { + this.modifyRight(context); } - this.propagateRetract(fact); }, - retractRight: function (fact) { - var context = this.rightMemory[fact.id], tuples = this.rightTuples; - if (context) { - tuples.splice(indexOf(tuples, context), 1); - delete this.rightMemory[fact.id]; + modifyLeft: function (context) { + var previousContext; + if ((previousContext = this.removeFromLeftMemory(context))) { + previousContext = previousContext.data; + this.__addToLeftMemory(context); + var rm = this.rightTuples, l = rm.length; + if (!l) { + this.propagateRetract(context); + } else { + var thisConstraint = this.constraint, + node = {next: rm.head}, + rightMatches = previousContext.rightMatches; + thisConstraint.setLeftContext(context); + while ((node = node.next)) { + this.propagateAssertModifyFromLeft(context, rightMatches, thisConstraint, node.data); + } + thisConstraint.clearContexts(); + + } } else { - var tuple; - for (var i = 0; i < tuples.length; i++) { - tuple = tuples[i]; - if (indexOf(tuple.factIds, fact.id) !== -1) { - tuples.splice(i, 1); + throw new Error(); + } + + }, + + modifyRight: function (context) { + var previousContext; + if ((previousContext = this.removeFromRightMemory(context))) { + previousContext = previousContext.data; + this.__addToRightMemory(context); + var lm = this.leftTuples; + if (!lm.length) { + this.propagateRetract(context); + } else { + var thisConstraint = this.constraint, + leftMatches = previousContext.leftMatches, + node = {next: lm.head}; + thisConstraint.setRightContext(context); + while ((node = node.next)) { + this.propagateAssertModifyFromRight(context, leftMatches, thisConstraint, node.data); } + thisConstraint.clearContexts(); } + } else { + throw new Error(); } - this.propagateRetract(fact); + }, - assertLeft: function (context) { - this.__addToLeftMemory(context); - var rm = this.rightTuples, i = -1, l = rm.length, thisConstraint = this.constraint, mr; - thisConstraint.setLeftContext(context); - while (++i < l) { - if ((mr = thisConstraint.setRightContext(rm[i]).match()).isMatch) { - this.__propagate("assert", context.clone(null, null, mr)); + propagateAssertModifyFromLeft: function (context, rightMatches, constraint, rm) { + var factId = rm.hashCode, mr; + if (factId in rightMatches) { + mr = constraint.setRightContext(rm).match(); + var mrIsMatch = mr.isMatch; + if (!mrIsMatch) { + this.__propagate("retract", rightMatches[factId].clone()); + } else { + this.__propagate("modify", this.__addToMemoryMatches(rm, context, context.clone(null, null, mr))); } + } else { + this.propagateFromLeft(context, constraint, rm); } - thisConstraint.clearContexts(); }, - assertRight: function (context) { - var fact = context.fact; - this.rightMemory[fact.id] = context; - this.rightTuples.push(context); - var fl = this.leftTuples, i = -1, l = fl.length, thisConstraint = this.constraint, mr; - thisConstraint.setRightContext(context); - while (++i < l) { - if ((mr = thisConstraint.setLeftContext(fl[i]).match()).isMatch) { - this.__propagate("assert", context.clone(null, null, mr)); + propagateAssertModifyFromRight: function (context, leftMatches, constraint, lm) { + var factId = lm.hashCode, mr; + if (factId in leftMatches) { + mr = constraint.setLeftContext(lm).match(); + var mrIsMatch = mr.isMatch; + if (!mrIsMatch) { + this.__propagate("retract", leftMatches[factId].clone()); + } else { + this.__propagate("modify", this.__addToMemoryMatches(context, lm, context.clone(null, null, mr))); + } + } else { + this.propagateFromRight(context, constraint, lm); + } + }, + + removeFromRightMemory: function (context) { + var hashCode = context.hashCode, ret; + context = this.rightMemory[hashCode] || null; + var tuples = this.rightTuples; + if (context) { + var leftMemory = this.leftMemory; + ret = context.data; + var leftMatches = ret.leftMatches; + tuples.remove(context); + for (var i in leftMatches) { + delete leftMemory[i].data.rightMatches[hashCode]; + } + delete this.rightMemory[hashCode]; + } + return context; + }, + + removeFromLeftMemory: function (context) { + var hashCode = context.hashCode; + context = this.leftMemory[hashCode] || null; + if (context) { + var rightMemory = this.rightMemory; + var rightMatches = context.data.rightMatches; + this.leftTuples.remove(context); + for (var i in rightMatches) { + delete rightMemory[i].data.leftMatches[hashCode]; } + delete this.leftMemory[hashCode]; } - thisConstraint.clearContexts(); + return context; }, - _propagateRetractResolve: function (context) { - this.__propagate("retractResolve", context); + getRightMemoryMatches: function (context) { + var lm = this.leftMemory[context.hashCode], ret = {}; + if (lm) { + ret = lm.rightMatches; + } + return ret; }, + __addToMemoryMatches: function (rightContext, leftContext, createdContext) { + var rightFactId = rightContext.hashCode, + rm = this.rightMemory[rightFactId], + lm, leftFactId = leftContext.hashCode; + if (rm) { + rm = rm.data; + if (leftFactId in rm.leftMatches) { + throw new Error("Duplicate left fact entry"); + } + rm.leftMatches[leftFactId] = createdContext; + } + lm = this.leftMemory[leftFactId]; + if (lm) { + lm = lm.data; + if (rightFactId in lm.rightMatches) { + throw new Error("Duplicate right fact entry"); + } + lm.rightMatches[rightFactId] = createdContext; + } + return createdContext; + }, + + __addToRightMemory: function (context) { + var hashCode = context.hashCode, rm = this.rightMemory; + if (hashCode in rm) { + return false; + } + rm[hashCode] = this.rightTuples.push(context); + context.leftMatches = {}; + return true; + }, + + __addToLeftMemory: function (context) { - var o = context.fact; - var lm = this.leftMemory[o.id]; - if (!lm) { - lm = []; - this.leftMemory[o.id] = lm; - } - this.leftTuples.push(context); - lm.push(context); - return this; + var hashCode = context.hashCode, lm = this.leftMemory; + if (hashCode in lm) { + return false; + } + lm[hashCode] = this.leftTuples.push(context); + context.rightMatches = {}; + return true; } } diff --git a/lib/nodes/joinReferenceNode.js b/lib/nodes/joinReferenceNode.js index 56d90b9..e77960f 100644 --- a/lib/nodes/joinReferenceNode.js +++ b/lib/nodes/joinReferenceNode.js @@ -1,9 +1,16 @@ var Node = require("./node"); + +var DEFUALT_CONSTRAINT = { + assert: function () { + return true; + } +}; + Node.extend({ instance: { - constraint: null, + constraint: DEFUALT_CONSTRAINT, __lc: null, __rc: null, __varLength: 0, @@ -51,12 +58,12 @@ Node.extend({ clearLeftContext: function () { this.__lc = null; var fh = this.__fh = {}, rc = this.__rc; - fh[this.__alias] = rc ? rc.fact.object : null; + fh[this.__alias] = rc ? rc.fact.object: null; return this; }, addConstraint: function (constraint) { - if (this.constraint === null) { + if (this.constraint === DEFUALT_CONSTRAINT) { this.constraint = constraint; } else { this.constraint = this.constraint.merge(constraint); @@ -66,17 +73,13 @@ Node.extend({ }, equal: function (constraint) { - if (this.constraint !== null) { + if (this.constraint !== DEFUALT_CONSTRAINT) { return this.constraint.equal(constraint.constraint); } }, isMatch: function () { - var constraint = this.constraint, ret = true; - if (constraint !== null) { - ret = constraint.assert(this.__fh); - } - return ret; + return this.constraint.assert(this.__fh); }, match: function () { diff --git a/lib/nodes/leftAdapterNode.js b/lib/nodes/leftAdapterNode.js index e96d9a1..3f96a6d 100644 --- a/lib/nodes/leftAdapterNode.js +++ b/lib/nodes/leftAdapterNode.js @@ -14,7 +14,7 @@ Node.extend({ this.__propagate("retractResolve", context); }, - modify: function (context) { + propagateModify: function (context) { this.__propagate("modifyLeft", context); }, diff --git a/lib/nodes/node.js b/lib/nodes/node.js index 6302942..4039847 100644 --- a/lib/nodes/node.js +++ b/lib/nodes/node.js @@ -70,8 +70,7 @@ declare({ return false; }, - __propagate: function (method, context, outNodes) { - outNodes = outNodes || this.nodes; + __propagate: function (method, context) { var entrySet = this.__entrySet, i = entrySet.length, entry, outNode, paths, continuingPaths; while (--i > -1) { entry = entrySet[i]; @@ -104,20 +103,24 @@ declare({ } }, - propagateAssert: function (assertable, outNodes) { - this.__propagate("assert", assertable, outNodes || this.nodes); + propagateAssert: function (assertable) { + this.__propagate("assert", assertable); }, - propagateRetract: function (assertable, outNodes) { - this.__propagate("retract", assertable, outNodes || this.nodes); + propagateRetract: function (assertable) { + this.__propagate("retract", assertable); }, assert: function (assertable) { this.propagateAssert(assertable); }, - propagateModify: function (assertable, outNodes) { - this.__propagate("modify", assertable, outNodes || this.nodes); + modify: function (assertable) { + this.propagateModify(assertable); + }, + + propagateModify: function (assertable) { + this.__propagate("modify", assertable); } } diff --git a/lib/nodes/notNode.js b/lib/nodes/notNode.js index ac3d94d..85b3826 100644 --- a/lib/nodes/notNode.js +++ b/lib/nodes/notNode.js @@ -1,7 +1,5 @@ var JoinNode = require("./joinNode"), - Context = require("../context"), - extd = require("../extended"), - indexOf = extd.indexOf; + LinkedList = require("../linkedList"); JoinNode.extend({ instance: { @@ -9,7 +7,6 @@ JoinNode.extend({ constructor: function () { this._super(arguments); this.leftTupleMemory = {}; - this.allTuples = {}; }, @@ -18,167 +15,257 @@ JoinNode.extend({ }, - retractRight: function (fact) { - var rightMemory = this.rightMemory; - var rightContext = rightMemory[fact.id], thisConstraint = this.constraint; - delete rightMemory[fact.id]; - if (rightContext) { - var index = indexOf(this.rightTuples, rightContext); - this.rightTuples.splice(index, 1); - var fl = rightContext.blocking, leftContext; - var rValues = this.rightTuples, k = rValues.length, rc, j; - while ((leftContext = fl.pop())) { - leftContext.blocker = null; - thisConstraint.setLeftContext(leftContext); - for (j = index; j < k; j++) { - rc = rValues[j]; - thisConstraint.setRightContext(rc); - if (thisConstraint.isMatch()) { - leftContext.blocker = rc; - rc.blocking.push(leftContext); - this.__addToLeftTupleMemory(leftContext); - break; + retractRight: function (context) { + var ctx = this.removeFromRightMemory(context); + if (ctx) { + var rightContext = ctx.data; + var blocking = rightContext.blocking; + if (blocking.length) { + //if we are blocking left contexts + var leftContext, rightTuples = this.rightTuples, thisConstraint = this.constraint, blockingNode = {next: blocking.head}, node, l = rightTuples.length, rc; + while ((blockingNode = blockingNode.next)) { + leftContext = blockingNode.data; + this.removeFromLeftBlockedMemory(leftContext); + if (l !== 0) { + thisConstraint.setLeftContext(leftContext); + node = ctx; + while ((node = node.next)) { + if (thisConstraint.setRightContext(rc = node.data).isMatch()) { + leftContext.blocker = rc; + this.addToLeftBlockedMemory(rc.blocking.push(leftContext)); + leftContext = null; + break; + } + } + thisConstraint.clearContexts(); + } + if (leftContext) { + this.__addToLeftMemory(leftContext); + this.__propagate("assert", leftContext.clone()); } } - if (!leftContext.blocker) { - this.__removeFromLeftTupleMemory(leftContext); - this.__addToLeftMemory(leftContext).propagateAssert(new Context(leftContext.fact, null, leftContext.match)); - } + blocking.clear(); } - thisConstraint.clearContexts(); + } else { + throw new Error(); } + }, - retractLeft: function (fact) { - var factId = fact.id, tuples = this.allTuples[fact.id] || [], context, blocking, blocker; - while (tuples.length) { - context = tuples.pop(); - if (indexOf(context.factIds, factId) !== -1) { - this.__removeFromAllTupleMemory(context); - this.__removeFromLeftMemory(context); - this.__removeFromLeftTupleMemory(context); - if ((blocker = context.blocker)) { - blocking = blocker.blocking; - blocking.splice(indexOf(blocking, context), 1); - context.blocker = null; - } + retractLeft: function (context) { + var ctx = this.removeFromLeftMemory(context); + if (ctx) { + this.__propagate("retract", ctx.data.clone()); + } else { + if (!this.removeFromLeftBlockedMemory(context)) { + throw new Error(); } } - delete this.leftMemory[factId]; - delete this.leftTupleMemory[factId]; - this.propagateRetract(fact); - }, assertLeft: function (context) { - var values = this.rightTuples, thisConstraint = this.constraint, i = -1, l = values.length, rc; - if (l !== 0) { + var values = this.rightTuples, + node, + thisConstraint = this.constraint, rc; + if (values.length) { + node = {next: values.head}; thisConstraint.setLeftContext(context); - while (++i < l) { - if (thisConstraint.setRightContext(rc = values[i]).isMatch()) { + while ((node = node.next) && context) { + if (thisConstraint.setRightContext(rc = node.data).isMatch()) { context.blocker = rc; - rc.blocking.push(context); - this.__addToLeftTupleMemory(context); + this.addToLeftBlockedMemory(rc.blocking.push(context)); context = null; - break; } } + thisConstraint.clearContexts(); } if (context) { - this.__addToLeftMemory(context).propagateAssert(new Context(context.fact, null, context.match)); + this.__addToLeftMemory(context); + this.__propagate("assert", context.clone()); } }, assertRight: function (context) { - context.blocking = []; - this.rightTuples.push(context); - this.rightMemory[context.fact.id] = context; - var fl = this.leftTuples, i = fl.length, leftContext, thisConstraint = this.constraint; - thisConstraint.setRightContext(context); - while (--i > -1) { - leftContext = fl[i]; - if (thisConstraint.setLeftContext(leftContext).isMatch()) { - this._propagateRetractResolve(leftContext.match); - //blocked so remove from memory - this.__removeFromLeftMemory(leftContext); - leftContext.blocker = context; - context.blocking.push(leftContext); - this.__addToLeftTupleMemory(leftContext); + this.__addToRightMemory(context); + context.blocking = new LinkedList(); + var fl = this.leftTuples, leftContext, node, thisConstraint = this.constraint; + if (fl.length) { + node = {next: fl.head}; + thisConstraint.setRightContext(context); + while ((node = node.next)) { + leftContext = node.data; + if (thisConstraint.setLeftContext(leftContext).isMatch()) { + this.__propagate("retract", leftContext.clone()); + this.removeFromLeftMemory(leftContext); + leftContext.blocker = context; + this.addToLeftBlockedMemory(context.blocking.push(leftContext)); + } } + thisConstraint.clearContexts(); } - thisConstraint.clearContexts(); }, - __removeFromLeftMemory: function (context) { - var leftMemories = this.leftMemory[context.fact.id] || [], lc, tuples = this.leftTuples; - for (var i = 0, l = tuples.length; i < l; i++) { - lc = tuples[i]; - if (lc === context) { - tuples.splice(i, 1); - leftMemories.splice(indexOf(leftMemories, lc), 1); - break; - } + addToLeftBlockedMemory: function (context) { + var data = context.data, hashCode = data.hashCode; + var ctx = this.leftMemory[hashCode]; + this.leftTupleMemory[hashCode] = context; + if (ctx) { + this.leftTuples.remove(ctx); } return this; }, - __removeFromLeftTupleMemory: function (context) { - var leftMemories = this.leftTupleMemory[context.fact.id] || [], lc; - for (var i = 0, l = leftMemories.length; i < l; i++) { - lc = leftMemories[i]; - if (lc === context) { - leftMemories.splice(i, 1); - break; - } + removeFromLeftBlockedMemory: function (context) { + var ret = this.leftTupleMemory[context.hashCode] || null; + if (ret) { + delete this.leftTupleMemory[context.hashCode]; + ret.data.blocker.blocking.remove(ret); } - return this; + return ret; }, - __addToAllTupleMemory: function (context) { - var factIds = context.factIds, i = -1, l = factIds.length, factId, allTuples = this.allTuples, tuples; - while (++i < l) { - factId = factIds[i]; - tuples = allTuples[factId] = (allTuples[factId] || []); - if (indexOf(tuples, context) === -1) { - tuples.push(context); - } + modifyLeft: function (context) { + var ctx = this.removeFromLeftMemory(context), + leftContext, + thisConstraint = this.constraint, + rightTuples = this.rightTuples, + l = rightTuples.length, + isBlocked = false, + node, rc, blocker; + if (!ctx) { + //blocked before + ctx = this.removeFromLeftBlockedMemory(context); + isBlocked = true; } - return this; + if (ctx) { + leftContext = ctx.data; - }, + if (leftContext && leftContext.blocker) { + //we were blocked before so only check nodes previous to our blocker + blocker = this.rightMemory[leftContext.blocker.hashCode]; + } + if (blocker) { + thisConstraint.setLeftContext(context); + if (thisConstraint.setRightContext(rc = blocker.data).isMatch()) { + //we cant be proagated so retract previous + if (!isBlocked) { + //we were asserted before so retract + this.__propagate("retract", leftContext.clone()); + } + context.blocker = rc; + this.addToLeftBlockedMemory(rc.blocking.push(context)); + context = null; + } + } + if (context && l) { + node = {next: rightTuples.head}; + //we were propogated before + thisConstraint.setLeftContext(context); + while ((node = node.next)) { + if (thisConstraint.setRightContext(rc = node.data).isMatch()) { + //we cant be proagated so retract previous + if (!isBlocked) { + //we were asserted before so retract + this.__propagate("retract", leftContext.clone()); + } + this.addToLeftBlockedMemory(rc.blocking.push(context)); + context.blocker = rc; + context = null; + break; + } + } + thisConstraint.clearContexts(); + } + if (context) { + //we can still be propogated + this.__addToLeftMemory(context); + if (!isBlocked) { + //we weren't blocked before so modify + this.__propagate("modify", context.clone()); + } else { + //we were blocked before but aren't now + this.__propagate("assert", context.clone()); + } - __removeFromAllTupleMemory: function (context) { - var factIds = context.factIds, i = -1, l = factIds.length, factId, allTuples = this.allTuples, tuples, index; - while (++i < l) { - factId = factIds[i]; - tuples = allTuples[factId]; - index = indexOf(tuples, context); - if (index !== -1) { - tuples.splice(i, 1); } + } else { + throw new Error(); } - return this; }, + modifyRight: function (context) { + var ctx = this.removeFromRightMemory(context); + if (ctx) { + var rightContext = ctx.data, + leftTuples = this.leftTuples, + leftTuplesLength = leftTuples.length, + leftContext, + thisConstraint = this.constraint, + node, + blocking = rightContext.blocking; + this.__addToRightMemory(context); + context.blocking = new LinkedList(); + if (leftTuplesLength || blocking.length) { + if (leftTuplesLength) { + //check currently left tuples in memory + thisConstraint.setRightContext(context); + node = {next: leftTuples.head}; + while ((node = node.next)) { + leftContext = node.data; + if (thisConstraint.setLeftContext(leftContext).isMatch()) { + this.__propagate("retract", leftContext.clone()); + this.removeFromLeftMemory(leftContext); + this.addToLeftBlockedMemory(context.blocking.push(leftContext)); + leftContext.blocker = context; + } + } + } - __addToLeftMemory: function (context) { - this._super(arguments); - this.__addToAllTupleMemory(context); - return this; - }, + if (blocking.length) { + var rc; + //check old blocked contexts + //check if the same contexts blocked before are still blocked + var blockingNode = {next: blocking.head}; + while ((blockingNode = blockingNode.next)) { + leftContext = blockingNode.data; + leftContext.blocker = null; + thisConstraint.setRightContext(context); + thisConstraint.setLeftContext(leftContext); + if (thisConstraint.isMatch()) { + leftContext.blocker = context; + this.addToLeftBlockedMemory(context.blocking.push(leftContext)); + leftContext = null; + return; + } else { + //we arent blocked anymore + leftContext.blocker = null; + node = ctx; + while ((node = node.next)) { + if (thisConstraint.setRightContext(rc = node.data).isMatch()) { + leftContext.blocker = rc; + this.addToLeftBlockedMemory(rc.blocking.push(leftContext)); + leftContext = null; + break; + } + } + if (leftContext) { + this.__addToLeftMemory(leftContext); + this.__propagate("assert", leftContext.clone()); + } + thisConstraint.clearContexts(); + } + } + thisConstraint.clearContexts(); + } - __addToLeftTupleMemory: function (context) { - var o = context.fact; - var lm = this.leftTupleMemory[o.id]; - if (!lm) { - lm = []; - this.leftTupleMemory[o.id] = lm; + } + } else { + throw new Error(); } - lm.push(context); - this.__addToAllTupleMemory(context); - return this; + + } } }).as(module); \ No newline at end of file diff --git a/lib/nodes/propertyNode.js b/lib/nodes/propertyNode.js index e83acd1..5b24edd 100644 --- a/lib/nodes/propertyNode.js +++ b/lib/nodes/propertyNode.js @@ -24,6 +24,22 @@ AlphaNode.extend({ }, + retract: function (context) { + this.__propagate("retract", new Context(context.fact, context.paths)); + }, + + modify: function (context) { + var c = new Context(context.fact, context.paths); + var variables = this.variables, o = context.fact.object, item; + c.set(this.alias, o); + for (var i = 0, l = this.varLength; i < l; i++) { + item = variables[i]; + c.set(item[1], o[item[0]]); + } + this.__propagate("modify", c); + }, + + toString: function () { return "PropertyNode" + this.__count; } diff --git a/lib/nodes/rightAdapterNode.js b/lib/nodes/rightAdapterNode.js index 3a5d504..98fa684 100644 --- a/lib/nodes/rightAdapterNode.js +++ b/lib/nodes/rightAdapterNode.js @@ -23,7 +23,7 @@ Node.extend({ this.__propagate("retractResolve", context); }, - modify: function (context) { + propagateModify: function (context) { this.__propagate("modifyRight", context); }, diff --git a/lib/nodes/terminalNode.js b/lib/nodes/terminalNode.js index e0d7608..5e9d7b2 100644 --- a/lib/nodes/terminalNode.js +++ b/lib/nodes/terminalNode.js @@ -27,6 +27,7 @@ Node.extend({ var rule = this.rule, bucket = this.bucket; this.agenda.insert(this, { rule: rule, + hashCode: context.hashCode, index: this.index, name: rule.name, recency: bucket.recency++, @@ -41,19 +42,20 @@ Node.extend({ }, modify: function (context) { + this.agenda.retract(this, context); this.__assertModify(context); }, - retract: function (fact) { - this.agenda.removeByFact(this, fact); + retract: function (context) { + this.agenda.retract(this, context); }, - retractRight: function (fact) { - this.agenda.removeByFact(this, fact); + retractRight: function (context) { + this.agenda.retract(this, context); }, - retractLeft: function (fact) { - this.agenda.removeByFact(this, fact); + retractLeft: function (context) { + this.agenda.retract(this, context); }, assertLeft: function (context) { @@ -64,13 +66,6 @@ Node.extend({ this.__assertModify(context); }, - retractResolve: function (match) { - var resolve = this.resolve; - this.agenda.retract(this, function (v) { - return resolve(v.match, match); - }); - }, - toString: function () { return "TerminalNode " + this.rule.name; } diff --git a/lib/nodes/typeNode.js b/lib/nodes/typeNode.js index b3e10ca..b28bf15 100644 --- a/lib/nodes/typeNode.js +++ b/lib/nodes/typeNode.js @@ -10,9 +10,15 @@ AlphaNode.extend({ } }, + modify: function (fact) { + if (this.constraint.assert(fact.object)) { + this.__propagate("modify", fact); + } + }, + retract: function (fact) { if (this.constraint.assert(fact.object)) { - this.propagateRetract(fact); + this.__propagate("retract", fact); } }, @@ -29,8 +35,8 @@ AlphaNode.extend({ }, __propagate: function (method, fact) { - var es = this.__entrySet, i = es.length - 1; - for (; i >= 0; i--) { + var es = this.__entrySet, i = -1, l = es.length; + while (++i < l) { var e = es[i], outNode = e.key, paths = e.value; outNode[method](new Context(fact, paths)); } diff --git a/lib/parser/constraint/grammar.js b/lib/parser/constraint/grammar.js index c367ff6..b8b1689 100644 --- a/lib/parser/constraint/grammar.js +++ b/lib/parser/constraint/grammar.js @@ -129,6 +129,7 @@ var grammar = { "IDENTIFIER_EXPRESSION", [ "OBJECT_EXPRESSION . IDENTIFIER_EXPRESSION", "$$ = [$1,$3, 'prop'];" ], [ "OBJECT_EXPRESSION [ STRING_EXPRESSION ]", "$$ = [$1,$3, 'propLookup'];" ], + [ "OBJECT_EXPRESSION [ NUMBER_EXPRESSION ]", "$$ = [$1,$3, 'propLookup'];" ], [ "OBJECT_EXPRESSION [ OBJECT_EXPRESSION ]", "$$ = [$1,$3, 'propLookup'];" ], [ "OBJECT_EXPRESSION ( )", "$$ = [$1, [null, null, 'arguments'], 'function']"], [ "OBJECT_EXPRESSION ( ARGUMENT_LIST )", "$$ = [$1, $3, 'function']"] diff --git a/lib/parser/constraint/parser.js b/lib/parser/constraint/parser.js index 4e7f0be..d4e2341 100644 --- a/lib/parser/constraint/parser.js +++ b/lib/parser/constraint/parser.js @@ -74,9 +74,9 @@ var parser = (function(){ var parser = {trace: function trace() { }, yy: {}, -symbols_: {"error":2,"expressions":3,"EXPRESSION":4,"EOF":5,"UNARY_EXPRESSION":6,"LITERAL_EXPRESSION":7,"-":8,"!":9,"MULTIPLICATIVE_EXPRESSION":10,"*":11,"/":12,"%":13,"ADDITIVE_EXPRESSION":14,"+":15,"EXPONENT_EXPRESSION":16,"^":17,"RELATIONAL_EXPRESSION":18,"<":19,">":20,"<=":21,">=":22,"EQUALITY_EXPRESSION":23,"==":24,"!=":25,"=~":26,"!=~":27,"IN_EXPRESSION":28,"in":29,"ARRAY_EXPRESSION":30,"notIn":31,"OBJECT_EXPRESSION":32,"AND_EXPRESSION":33,"&&":34,"OR_EXPRESSION":35,"||":36,"ARGUMENT_LIST":37,",":38,"IDENTIFIER_EXPRESSION":39,"IDENTIFIER":40,".":41,"[":42,"STRING_EXPRESSION":43,"]":44,"(":45,")":46,"STRING":47,"NUMBER_EXPRESSION":48,"NUMBER":49,"REGEXP_EXPRESSION":50,"REGEXP":51,"BOOLEAN_EXPRESSION":52,"BOOLEAN":53,"NULL_EXPRESSION":54,"NULL":55,"$accept":0,"$end":1}, -terminals_: {2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",45:"(",46:")",47:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"}, -productions_: [0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,3],[32,4],[43,1],[48,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]], +symbols_: {"error":2,"expressions":3,"EXPRESSION":4,"EOF":5,"UNARY_EXPRESSION":6,"LITERAL_EXPRESSION":7,"-":8,"!":9,"MULTIPLICATIVE_EXPRESSION":10,"*":11,"/":12,"%":13,"ADDITIVE_EXPRESSION":14,"+":15,"EXPONENT_EXPRESSION":16,"^":17,"RELATIONAL_EXPRESSION":18,"<":19,">":20,"<=":21,">=":22,"EQUALITY_EXPRESSION":23,"==":24,"!=":25,"=~":26,"!=~":27,"IN_EXPRESSION":28,"in":29,"ARRAY_EXPRESSION":30,"notIn":31,"OBJECT_EXPRESSION":32,"AND_EXPRESSION":33,"&&":34,"OR_EXPRESSION":35,"||":36,"ARGUMENT_LIST":37,",":38,"IDENTIFIER_EXPRESSION":39,"IDENTIFIER":40,".":41,"[":42,"STRING_EXPRESSION":43,"]":44,"NUMBER_EXPRESSION":45,"(":46,")":47,"STRING":48,"NUMBER":49,"REGEXP_EXPRESSION":50,"REGEXP":51,"BOOLEAN_EXPRESSION":52,"BOOLEAN":53,"NULL_EXPRESSION":54,"NULL":55,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",46:"(",47:")",48:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"}, +productions_: [0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,4],[32,3],[32,4],[43,1],[45,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ @@ -138,29 +138,31 @@ case 38:this.$ = [$$[$0-3],$$[$0-1], 'propLookup']; break; case 39:this.$ = [$$[$0-3],$$[$0-1], 'propLookup']; break; -case 40:this.$ = [$$[$0-2], [null, null, 'arguments'], 'function'] +case 40:this.$ = [$$[$0-3],$$[$0-1], 'propLookup']; break; -case 41:this.$ = [$$[$0-3], $$[$0-1], 'function'] +case 41:this.$ = [$$[$0-2], [null, null, 'arguments'], 'function'] break; -case 42:this.$ = [String(yytext.replace(/^['|"]|['|"]$/g, '')), null, 'string']; +case 42:this.$ = [$$[$0-3], $$[$0-1], 'function'] break; -case 43:this.$ = [Number(yytext), null, 'number']; +case 43:this.$ = [String(yytext.replace(/^['|"]|['|"]$/g, '')), null, 'string']; break; -case 44:this.$ = [yytext, null, 'regexp']; +case 44:this.$ = [Number(yytext), null, 'number']; break; -case 45:this.$ = [yytext.replace(/^\s+/, '') == 'true', null, 'boolean']; +case 45:this.$ = [yytext, null, 'regexp']; break; -case 46:this.$ = [null, null, 'null']; +case 46:this.$ = [yytext.replace(/^\s+/, '') == 'true', null, 'boolean']; break; -case 47:this.$ = [null, null, 'array']; +case 47:this.$ = [null, null, 'null']; break; -case 48:this.$ = [$$[$0-1], null, 'array']; +case 48:this.$ = [null, null, 'array']; break; -case 56:this.$ = [$$[$0-1], null, 'composite'] +case 49:this.$ = [$$[$0-1], null, 'array']; +break; +case 57:this.$ = [$$[$0-1], null, 'composite'] break; } }, -table: [{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,57],36:[1,32],46:[2,57]},{5:[2,31],34:[1,33],36:[2,31],46:[2,31]},{5:[2,29],34:[2,29],36:[2,29],46:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],46:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],46:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],46:[2,19]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],46:[2,49]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],46:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],46:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],46:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],46:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],41:[1,44],42:[1,45],44:[2,54],45:[1,46],46:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],44:[2,55],46:[2,55]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],46:[2,14]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],44:[2,42],46:[2,42]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],46:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],46:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],46:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],46:[2,46]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],45:[2,36],46:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],46:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],45:[2,35],46:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],46:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],46:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:76,39:23,40:[1,26],43:75,47:[1,18]},{7:51,30:15,32:14,37:78,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],46:[1,77],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{46:[1,79]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:80,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],46:[2,47]},{38:[1,82],44:[1,81]},{38:[2,33],44:[2,33],46:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:83,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:85,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],46:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],46:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],46:[2,4]},{5:[2,32],34:[1,33],36:[2,32],46:[2,32]},{5:[2,30],34:[2,30],36:[2,30],46:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],46:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],46:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],46:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],46:[2,23]},{5:[2,25],34:[2,25],36:[2,25],46:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],45:[1,46],46:[2,27]},{5:[2,26],34:[2,26],36:[2,26],46:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],45:[1,46],46:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],46:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],46:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],46:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],46:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],45:[2,37],46:[2,37]},{44:[1,88]},{41:[1,44],42:[1,45],44:[1,89],45:[1,46]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],45:[2,40],46:[2,40]},{38:[1,82],46:[1,90]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],46:[2,56]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],46:[2,13]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],46:[2,48]},{7:91,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],46:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],46:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],46:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],46:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],46:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],45:[2,38],46:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],45:[2,39],46:[2,39]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],45:[2,41],46:[2,41]},{38:[2,34],44:[2,34],46:[2,34]}], +table: [{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,58],36:[1,32],47:[2,58]},{5:[2,31],34:[1,33],36:[2,31],47:[2,31]},{5:[2,29],34:[2,29],36:[2,29],47:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],47:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],47:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],47:[2,19]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],47:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],47:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],47:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],47:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],44:[2,54],47:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],41:[1,44],42:[1,45],44:[2,55],46:[1,46],47:[2,55]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],47:[2,56]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],47:[2,14]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],47:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],47:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],47:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],47:[2,46]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],47:[2,47]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],46:[2,36],47:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],47:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],46:[2,35],47:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],47:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],47:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:77,39:23,40:[1,26],43:75,45:76,48:[1,18],49:[1,19]},{7:51,30:15,32:14,37:79,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],47:[1,78],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{47:[1,80]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:81,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],47:[2,48]},{38:[1,83],44:[1,82]},{38:[2,33],44:[2,33],47:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:85,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:88,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],47:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],47:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],47:[2,4]},{5:[2,32],34:[1,33],36:[2,32],47:[2,32]},{5:[2,30],34:[2,30],36:[2,30],47:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],47:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],47:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],47:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],47:[2,23]},{5:[2,25],34:[2,25],36:[2,25],47:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],46:[1,46],47:[2,27]},{5:[2,26],34:[2,26],36:[2,26],47:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],46:[1,46],47:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],47:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],47:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],47:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],47:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],46:[2,37],47:[2,37]},{44:[1,89]},{44:[1,90]},{41:[1,44],42:[1,45],44:[1,91],46:[1,46]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],46:[2,41],47:[2,41]},{38:[1,83],47:[1,92]},{5:[2,57],8:[2,57],11:[2,57],12:[2,57],13:[2,57],15:[2,57],17:[2,57],19:[2,57],20:[2,57],21:[2,57],22:[2,57],24:[2,57],25:[2,57],26:[2,57],27:[2,57],29:[2,57],31:[2,57],34:[2,57],36:[2,57],38:[2,57],44:[2,57],47:[2,57]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],47:[2,13]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],47:[2,49]},{7:93,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],47:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],47:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],47:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],47:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],47:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],46:[2,38],47:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],46:[2,39],47:[2,39]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],46:[2,40],47:[2,40]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],41:[2,42],42:[2,42],44:[2,42],46:[2,42],47:[2,42]},{38:[2,34],44:[2,34],47:[2,34]}], defaultActions: {31:[2,1]}, parseError: function parseError(str, hash) { if (hash.recoverable) { @@ -652,9 +654,9 @@ case 15:/* skip whitespace */ break; case 16:return 49; break; -case 17:return 47; +case 17:return 48; break; -case 18:return 47; +case 18:return 48; break; case 19:return 40; break; @@ -700,13 +702,13 @@ case 39:return 15; break; case 40:return 17; break; -case 41:return 45; +case 41:return 46; break; case 42:return 44; break; case 43:return 42; break; -case 44:return 46; +case 44:return 47; break; case 45:return 9; break; diff --git a/lib/parser/nools/nool.parser.js b/lib/parser/nools/nool.parser.js index 60f8f15..71d4012 100644 --- a/lib/parser/nools/nool.parser.js +++ b/lib/parser/nools/nool.parser.js @@ -7,7 +7,7 @@ var tokens = require("./tokens.js"), var parse = function (src, keywords, context) { var orig = src; - src = src.replace(/\/\/(.*)[\n|\r|\r\n]/g, "").replace(/\n|\r|\r\n/g, " "); + src = src.replace(/\/\/(.*)/g, "").replace(/\n|\r|\r\n/g, " "); var blockTypes = new RegExp("^(" + keys(keywords).join("|") + ")"), index; while (src && (index = utils.findNextTokenIndex(src)) !== -1) { diff --git a/lib/parser/nools/tokens.js b/lib/parser/nools/tokens.js index c1cc91e..98e918b 100644 --- a/lib/parser/nools/tokens.js +++ b/lib/parser/nools/tokens.js @@ -85,6 +85,7 @@ var ruleTokens = { }; var constraintRegExp = /(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/; var predicateExp = /^(\w+) *\((.*)\)$/m; + var fromRegExp = /(\bfrom\s+.*)/; var parseRules = function (str) { var rules = []; var ruleLines = str.split(";"), l = ruleLines.length, ruleLine; @@ -107,9 +108,14 @@ var ruleTokens = { if (parts && parts.length) { rule.push(parts[2], parts[1]); var constraints = parts[3].replace(/^\s*|\s*$/g, ""); - var hashParts = constraints.match(constraintRegExp); + var hashParts = constraints.match(constraintRegExp), from = null, fromMatch; if (hashParts) { var hash = hashParts[1], constraint = constraints.replace(hash, ""); + if (fromRegExp.test(constraint)) { + fromMatch = constraint.match(fromRegExp); + from = fromMatch[0]; + constraint = constraint.replace(fromMatch[0], ""); + } if (constraint) { rule.push(constraint.replace(/^\s*|\s*$/g, "")); } @@ -117,8 +123,16 @@ var ruleTokens = { rule.push(eval("(" + hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g, '"$1" : "$2"') + ")")); } } else if (constraints && !isWhiteSpace(constraints)) { + if (fromRegExp.test(constraints)) { + fromMatch = constraints.match(fromRegExp); + from = fromMatch[0]; + constraints = constraints.replace(fromMatch[0], ""); + } rule.push(constraints); } + if (from) { + rule.push(from); + } rules.push(rule); } else { throw new Error("Invalid constraint " + ruleLine); diff --git a/lib/pattern.js b/lib/pattern.js index 1a98eec..7c389fb 100644 --- a/lib/pattern.js +++ b/lib/pattern.js @@ -1,93 +1,145 @@ -(function () { - "use strict"; - var extd = require("./extended"), - merge = extd.merge, - forEach = extd.forEach, - declare = extd.declare, - constraintMatcher = require("./constraintMatcher"), - constraint = require("./constraint"); - - - var Pattern = declare({}); - - var ObjectPattern = Pattern.extend({ - instance: { - constructor: function (type, alias, conditions, store, options) { - options = options || {}; - this.type = type; - this.alias = alias; - this.conditions = conditions; - this.pattern = options.pattern; - this.constraints = [new constraint.ObjectConstraint(type)]; - var constrnts = constraintMatcher.toConstraints(conditions, merge({alias: alias}, options)); - if (constrnts.length) { - this.constraints = this.constraints.concat(constrnts); - } else { - var cnstrnt = new constraint.TrueConstraint(); - this.constraints.push(cnstrnt); - } - if (store && !extd.isEmpty(store)) { - var atm = new constraint.HashConstraint(store); - this.constraints.push(atm); +"use strict"; +var extd = require("./extended"), + isEmpty = extd.isEmpty, + merge = extd.merge, + forEach = extd.forEach, + declare = extd.declare, + constraintMatcher = require("./constraintMatcher"), + constraint = require("./constraint"), + EqualityConstraint = constraint.EqualityConstraint; + +var id = 0; +var Pattern = declare({}); + +var ObjectPattern = Pattern.extend({ + instance: { + constructor: function (type, alias, conditions, store, options) { + options = options || {}; + this.id = id++; + this.type = type; + this.alias = alias; + this.conditions = conditions; + this.pattern = options.pattern; + var constraints = [new constraint.ObjectConstraint(type)]; + var constrnts = constraintMatcher.toConstraints(conditions, merge({alias: alias}, options)); + if (constrnts.length) { + constraints = constraints.concat(constrnts); + } else { + var cnstrnt = new constraint.TrueConstraint(); + constraints.push(cnstrnt); + } + if (store && !isEmpty(store)) { + var atm = new constraint.HashConstraint(store); + constraints.push(atm); + } + + forEach(constraints, function (constraint) { + constraint.set("alias", alias); + }); + this.constraints = constraints; + }, + + getSpecificity: function () { + var constraints = this.constraints, specificity = 0; + for (var i = 0, l = constraints.length; i < l; i++) { + if (constraints[i] instanceof EqualityConstraint) { + specificity++; } - forEach(this.constraints, function (constraint) { - constraint.set("alias", alias); - }); - }, - - hasConstraint: function (type) { - return extd.some(this.constraints, function (c) { - return c instanceof type; - }); - }, - - hashCode: function () { - return [this.type, this.alias, extd.format("%j", this.conditions)].join(":"); - }, - - toString: function () { - return extd.format("%j", this.constraints); } + return specificity; + }, + + hasConstraint: function (type) { + return extd.some(this.constraints, function (c) { + return c instanceof type; + }); + }, + + hashCode: function () { + return [this.type, this.alias, extd.format("%j", this.conditions)].join(":"); + }, + + toString: function () { + return extd.format("%j", this.constraints); } - }).as(exports, "ObjectPattern"); + } +}).as(exports, "ObjectPattern"); + +var FromPattern = ObjectPattern.extend({ + instance: { + constructor: function (type, alias, conditions, store, from, options) { + this._super([type, alias, conditions, store, options]); + this.from = from.from; + }, + + hasConstraint: function (type) { + return extd.some(this.constraints, function (c) { + return c instanceof type; + }); + }, + + getSpecificity: function () { + return this._super(arguments) + 1; + }, + + hashCode: function () { + return [this.type, this.alias, extd.format("%j", this.conditions), this.from.from].join(":"); + }, + + toString: function () { + return extd.format("%j from %s", this.constraints, this.from.from); + } + } +}).as(exports, "FromPattern"); - ObjectPattern.extend().as(exports, "NotPattern"); - Pattern.extend({ +FromPattern.extend().as(exports, "FromNotPattern"); +ObjectPattern.extend().as(exports, "NotPattern"); - instance: { - constructor: function (left, right) { - this.leftPattern = left; - this.rightPattern = right; - }, +Pattern.extend({ - hashCode: function () { - return [this.leftPattern.hashCode(), this.rightPattern.hashCode()].join(":"); - }, + instance: { + constructor: function (left, right) { + this.id = id++; + this.leftPattern = left; + this.rightPattern = right; + }, - getters: { - constraints: function () { - return this.leftPattern.constraints.concat(this.rightPattern.constraints); - } + hashCode: function () { + return [this.leftPattern.hashCode(), this.rightPattern.hashCode()].join(":"); + }, + + getSpecificity: function () { + return this.rightPattern.getSpecificity() + this.leftPattern.getSpecificity(); + }, + + getters: { + constraints: function () { + return this.leftPattern.constraints.concat(this.rightPattern.constraints); } } + } - }).as(exports, "CompositePattern"); +}).as(exports, "CompositePattern"); - var InitialFact = declare({}).as(exports, "InitialFact"); +var InitialFact = declare({ + constuctor: function(){ + this.id = id++; + } +}).as(exports, "InitialFact"); - ObjectPattern.extend({ - instance: { - constructor: function () { - this._super([InitialFact, "i", [], {}]); - }, +ObjectPattern.extend({ + instance: { + constructor: function () { + this._super([InitialFact, "i", [], {}]); + }, - assert: function () { - return true; - } + assert: function () { + return true; } - }).as(exports, "InitialFactPattern"); + } +}).as(exports, "InitialFactPattern"); + -})(); diff --git a/lib/rule.js b/lib/rule.js index 1dd4b66..12eb172 100644 --- a/lib/rule.js +++ b/lib/rule.js @@ -3,12 +3,63 @@ var extd = require("./extended"), isArray = extd.isArray, Promise = extd.Promise, declare = extd.declare, + isHash = extd.isHash, + isString = extd.isString, + format = extd.format, parser = require("./parser"), pattern = require("./pattern"), ObjectPattern = pattern.ObjectPattern, + FromPattern = pattern.FromPattern, NotPattern = pattern.NotPattern, + FromNotPattern = pattern.FromNotPattern, CompositePattern = pattern.CompositePattern; +var parseExtra = extd + .switcher() + .isUndefinedOrNull(function () { + return null; + }) + .isLike(/^from +/, function (s) { + return {from: s.replace(/^from +/, "").replace(/^\s*|\s*$/g, "")}; + }) + .def(function (o) { + throw new Error("invalid rule constraint option " + o); + }) + .switcher(); + +var normailizeConstraint = extd + .switcher() + .isLength(1, function (c) { + throw new Error("invalid rule constraint " + format("%j", [c])); + }) + .isLength(2, function (c) { + c.push("true"); + return c; + }) + //handle case where c[2] is a hash rather than a constraint string + .isLength(3, function (c) { + if (isHash(c[2])) { + c.splice(2, 0, "true"); + } + return c; + }) + //handle case where c[3] is a from clause rather than a hash for references + .isLength(4, function (c) { + if (isString(c[3])) { + c.splice(3, 0, null); + c[4] = parseExtra(c[4]); + } + return c; + }) + .def(function (c) { + if (c.length === 5) { + c[4] = parseExtra(c[4]); + } + return c; + }) + .switcher(); + + var getParamTypeSwitch = extd .switcher() .isEq("string", function () { @@ -68,29 +119,56 @@ var parsePattern = extd }) .contains("not", 0, function (condition) { condition.shift(); - return [ - new NotPattern( - getParamType(condition[0]), - condition[1] || "m", - parser.parseConstraint(condition[2] || "true"), - condition[3] || {}, - {scope: condition.scope, pattern: condition[2]} - ) - ]; + condition = normailizeConstraint(condition); + if (condition[4] && condition[4].from) { + return [ + new FromNotPattern( + getParamType(condition[0]), + condition[1] || "m", + parser.parseConstraint(condition[2] || "true"), + condition[3] || {}, + condition[4], + {scope: condition.scope, pattern: condition[2]} + ) + ]; + } else { + return [ + new NotPattern( + getParamType(condition[0]), + condition[1] || "m", + parser.parseConstraint(condition[2] || "true"), + condition[3] || {}, + {scope: condition.scope, pattern: condition[2]} + ) + ]; + } }) .def(function (condition) { - return [ - new ObjectPattern( - getParamType(condition[0]), - condition[1] || "m", - parser.parseConstraint(condition[2] || "true"), - condition[3] || {}, - {scope: condition.scope, pattern: condition[2]} - ) - ]; + condition = normailizeConstraint(condition); + if (condition[4] && condition[4].from) { + return [ + new FromPattern( + getParamType(condition[0]), + condition[1] || "m", + parser.parseConstraint(condition[2] || "true"), + condition[3] || {}, + condition[4], + {scope: condition.scope, pattern: condition[2]} + ) + ]; + } else { + return [ + new ObjectPattern( + getParamType(condition[0]), + condition[1] || "m", + parser.parseConstraint(condition[2] || "true"), + condition[3] || {}, + {scope: condition.scope, pattern: condition[2]} + ) + ]; + } }).switcher(); - var Rule = declare({ instance: { constructor: function (name, options, pattern, cb) { @@ -121,7 +199,7 @@ var Rule = declare({ }); function createRule(name, options, conditions, cb) { - if (extd.isArray(options)) { + if (isArray(options)) { cb = conditions; conditions = options; } else { diff --git a/lib/workingMemory.js b/lib/workingMemory.js index 9a66546..c3c9287 100644 --- a/lib/workingMemory.js +++ b/lib/workingMemory.js @@ -1,8 +1,7 @@ "use strict"; -var declare = require("declare.js"); - - -var id = 0; +var declare = require("declare.js"), + LinkedList = require("./linkedList"), + id = 0; var Fact = declare({ @@ -30,26 +29,69 @@ declare({ constructor: function () { this.recency = 0; - this.facts = []; + this.facts = new LinkedList(); }, dispose: function () { - this.facts.length = 0; + this.facts.clear(); + }, + + getFactHandle: function (o) { + var head = {next: this.facts.head}, ret; + while ((head = head.next)) { + var existingFact = head.data; + if (existingFact.equals(o)) { + return existingFact; + } + } + if (!ret) { + ret = new Fact(o); + ret.recency = this.recency++; + //this.facts.push(ret); + } + return ret; + }, + + modifyFact: function (fact) { + var head = {next: this.facts.head}; + while ((head = head.next)) { + var existingFact = head.data; + if (existingFact.equals(fact)) { + existingFact.recency = this.recency++; + return existingFact; + } + } + //if we made it here we did not find the fact + throw new Error("the fact to modify does not exist"); }, assertFact: function (fact) { - fact = new Fact(fact); - fact.recency = this.recency++; - this.facts.push(fact); - return fact; + var ret = new Fact(fact); + ret.recency = this.recency++; + this.facts.push(ret); + return ret; +// var head = {next: this.facts.head}, ret; +// while ((head = head.next)) { +// var existingFact = head.data; +// if (existingFact.equals(fact)) { +// ret = existingFact; +// break; +// } +// } +// if (!ret) { +// ret = new Fact(fact); +// ret.recency = this.recency++; +// this.facts.push(ret); +// } +// return ret; }, retractFact: function (fact) { - var facts = this.facts, l = facts.length, i = -1, existingFact; - while (++i < l) { - existingFact = facts[i]; + var facts = this.facts, head = {next: facts.head}; + while ((head = head.next)) { + var existingFact = head.data; if (existingFact.equals(fact)) { - this.facts.splice(i, 1); + facts.remove(head); return existingFact; } } diff --git a/nools.js b/nools.js index 110d6c6..3802591 100644 --- a/nools.js +++ b/nools.js @@ -25,45 +25,16 @@ },{"../":2}],2:[function(require,module,exports){ module.exports = exports = require("./lib"); -},{"./lib":14}],3:[function(require,module,exports){ +},{"./lib":15}],3:[function(require,module,exports){ "use strict"; var extd = require("./extended"), - indexOf = extd.indexOf, +//indexOf = extd.indexOf, declare = extd.declare, AVLTree = extd.AVLTree, LinkedList = extd.LinkedList, - EventEmitter = require("events").EventEmitter; - -var sortAgenda = function (a, b) { - /*jshint noempty:false*/ - if (a === b) { - return 0; - } - var ret; - var p1 = a.rule.priority, p2 = b.rule.priority; - if (p1 !== p2) { - ret = p1 - p2; - } else if (a.counter !== b.counter) { - ret = a.counter - b.counter; - } - if (!ret) { + EventEmitter = require("events").EventEmitter, + sortAgenda = require("./conflict").strategy(["salience", "activationRecency"]); - var i = 0; - var aMatchRecency = a.match.recency, - bMatchRecency = b.match.recency, aLength = aMatchRecency.length - 1, bLength = bMatchRecency.length - 1; - while (aMatchRecency[i] === bMatchRecency[i] && i < aLength && i < bLength && i++) { - } - ret = aMatchRecency[i] - bMatchRecency[i]; - if (!ret) { - ret = aLength - bLength; - } - // } - } - if (!ret) { - ret = a.recency - b.recency; - } - return ret > 0 ? 1 : -1; -}; var FactHash = declare({ instance: { @@ -75,60 +46,33 @@ var FactHash = declare({ clear: function () { this.memoryValues.clear(); this.memory = {}; - this.memory.length = this.memoryValues.length = 0; - }, - - get: function (k) { - var node = this.memory[k.id]; - return node ? node.data : []; }, remove: function (v) { - var facts = v.match.facts, - l = facts.length, - mv = this.memoryValues, - m = this.memory, - i = -1, - arr, index, node, fId; - while (++i < l) { - fId = facts[i].id; - node = m[fId]; - arr = node.data; - index = indexOf(arr, v); - arr.splice(index, 1); - if (arr.length === 0) { - mv.remove(node); - delete m[fId]; - } + var hashCode = v.hashCode, + memory = this.memory, + ret = memory[hashCode]; + if (ret) { + this.memoryValues.remove(ret); + delete memory[hashCode]; } + return ret; }, insert: function (insert) { - var facts = insert.match.facts, - mv = this.memoryValues, - m = this.memory, - l = facts.length, - i = -1, - node, o, arr, fId; - while (++i < l) { - o = facts[i]; - fId = o.id; - node = m[o.id]; - if (!node) { - m[fId] = mv.push((arr = [])); - } else { - arr = node.data; - } - arr.push(insert); + var hashCode = insert.hashCode; + if (hashCode in this.memory) { + throw new Error("Activation already in agenda " + insert.rule.name + " agenda"); } + this.memoryValues.push((this.memory[hashCode] = insert)); } } }); -var REVERSE_ORDER = AVLTree.REVERSE_ORDER, DEFAULT_AGENDA_GROUP = "main"; +var DEFAULT_AGENDA_GROUP = "main"; module.exports = declare(EventEmitter, { instance: { @@ -222,30 +166,27 @@ module.exports = declare(EventEmitter, { return v; }, - removeByFact: function (node, fact) { - var rule = this.rules[node.name], tree = rule.tree, factTable = rule.factTable; - var ma = this.getAgendaGroup(node.rule.agendaGroup); - var remove = factTable.get(fact) || []; - var i = remove.length, r; - while (--i > -1) { - r = remove[i]; - factTable.remove(r); - tree.remove(r); - ma.remove(r); + peek: function () { + var tree = this.getFocusedAgenda(), root = tree.__root; + while (root.right) { + root = root.right; } - remove.length = 0; + return root.data; }, - retract: function (node, cb) { - var rule = this.rules[node.name], tree = rule.tree, factTable = rule.factTable; - var ma = this.getAgendaGroup(node.rule.agendaGroup); - tree.traverse(tree.__root, REVERSE_ORDER, function (v) { - if (cb(v)) { - factTable.remove(v); - ma.remove(v); - tree.remove(v); - } - }); + modify: function (node, context) { + this.retract(node, context); + this.insert(node, context); + }, + + retract: function (node, retract) { + var rule = this.rules[node.name]; + retract.rule = node; + var activation = rule.factTable.remove(retract); + if (activation) { + this.getAgendaGroup(node.rule.agendaGroup).remove(activation); + rule.tree.remove(activation); + } }, insert: function (node, insert) { @@ -278,7 +219,7 @@ module.exports = declare(EventEmitter, { } }); -},{"./extended":11,"events":47}],4:[function(require,module,exports){ +},{"./conflict":7,"./extended":12,"events":50}],4:[function(require,module,exports){ /*jshint evil:true*/ "use strict"; var extd = require("../extended"), @@ -335,7 +276,7 @@ var createDefined = (function () { exports.createFunction = createFunction; exports.createDefined = createDefined; -},{"../extended":11}],5:[function(require,module,exports){ +},{"../extended":12}],5:[function(require,module,exports){ var Buffer=require("__browserify_Buffer").Buffer;/*jshint evil:true*/ "use strict"; var extd = require("../extended"), @@ -526,7 +467,7 @@ exports.transpile = require("./transpile").transpile; -},{"../constraintMatcher.js":8,"../extended":11,"../parser":31,"../rule":36,"./common":4,"./transpile":6,"__browserify_Buffer":50}],6:[function(require,module,exports){ +},{"../constraintMatcher.js":9,"../extended":12,"../parser":34,"../rule":39,"./common":4,"./transpile":6,"__browserify_Buffer":53}],6:[function(require,module,exports){ var Buffer=require("__browserify_Buffer").Buffer;var extd = require("../extended"), forEach = extd.forEach, indexOf = extd.indexOf, @@ -678,16 +619,73 @@ exports.transpile = function (flowObj, options) { -},{"../constraintMatcher":8,"../extended":11,"../parser":31,"__browserify_Buffer":50}],7:[function(require,module,exports){ +},{"../constraintMatcher":9,"../extended":12,"../parser":34,"__browserify_Buffer":53}],7:[function(require,module,exports){ +var map = require("./extended").map; + +function salience(a, b) { + return a.rule.priority - b.rule.priority; +} + +function bucketCounter(a, b) { + return a.counter - b.counter; +} + +function factRecency(a, b) { + /*jshint noempty: false*/ + var i = 0; + var aMatchRecency = a.match.recency, + bMatchRecency = b.match.recency, aLength = aMatchRecency.length - 1, bLength = bMatchRecency.length - 1; + while (aMatchRecency[i] === bMatchRecency[i] && i < aLength && i < bLength && i++) { + } + var ret = aMatchRecency[i] - bMatchRecency[i]; + if (!ret) { + ret = aLength - bLength; + } + return ret; +} + +function activationRecency(a, b) { + return a.recency - b.recency; +} + +var strategies = { + salience: salience, + bucketCounter: bucketCounter, + factRecency: factRecency, + activationRecency: activationRecency +}; + +exports.strategies = strategies; +exports.strategy = function (strats) { + strats = map(strats, function (s) { + return strategies[s]; + }); + var stratsLength = strats.length; + + return function (a, b) { + var i = -1, ret = 0; + var equal = (a === b) || (a.name === b.name && a.hashCode === b.hashCode); + if (!equal) { + while (++i < stratsLength && !ret) { + ret = strats[i](a, b); + } + ret = ret > 0 ? 1: -1; + } + return ret; + }; +}; +},{"./extended":12}],8:[function(require,module,exports){ "use strict"; var extd = require("./extended"), + deepEqual = extd.deepEqual, merge = extd.merge, instanceOf = extd.instanceOf, filter = extd.filter, declare = extd.declare, constraintMatcher; +var id = 0; var Constraint = declare({ instance: { @@ -695,6 +693,7 @@ var Constraint = declare({ if (!constraintMatcher) { constraintMatcher = require("./constraintMatcher"); } + this.id = id++; this.type = type; this.constraint = constraint; }, @@ -849,10 +848,35 @@ Constraint.extend({ } }).as(exports, "HashConstraint"); +Constraint.extend({ + instance: { + constructor: function (prop, constraints) { + this.type = "from"; + this.prop = prop; + this.constraints = constraints; + }, + equal: function (constraint) { + return instanceOf(constraint, this._static) && this.get("alias") === constraint.get("alias") && deepEqual(this.constraints, constraint.constraints); + }, + "assert": function () { + return true; + }, -},{"./constraintMatcher":8,"./extended":11}],8:[function(require,module,exports){ + getters: { + variables: function () { + return this.constraint; + } + } + + } +}).as(exports, "FromConstraint"); + + + + +},{"./constraintMatcher":9,"./extended":12}],9:[function(require,module,exports){ "use strict"; var extd = require("./extended"), @@ -1225,9 +1249,10 @@ exports.getIdentifiers = function (constraint) { -},{"./constraint":7,"./extended":11}],9:[function(require,module,exports){ +},{"./constraint":8,"./extended":12}],10:[function(require,module,exports){ "use strict"; var extd = require("./extended"), + isBoolean = extd.isBoolean, declare = extd.declare, merge = extd.merge, union = extd.union, @@ -1294,7 +1319,19 @@ var Context = declare({ }, isMatch: function (isMatch) { - this.match.isMatch = isMatch; + if (isBoolean(isMatch)) { + this.match.isMatch = isMatch; + } else { + return this.match.isMatch; + } + return this; + }, + + mergeMatch: function (merge) { + var match = this.match = this.match.merge(merge); + this.factHash = match.factHash; + this.hashCode = match.hashCode; + this.factIds = match.factIds; return this; }, @@ -1306,7 +1343,7 @@ var Context = declare({ -},{"./extended":11}],10:[function(require,module,exports){ +},{"./extended":12}],11:[function(require,module,exports){ var extd = require("./extended"), Promise = extd.Promise, nextTick = require("./nextTick"), @@ -1411,22 +1448,59 @@ Promise.extend({ } } }).as(module); -},{"./extended":11,"./nextTick":16}],11:[function(require,module,exports){ +},{"./extended":12,"./nextTick":17}],12:[function(require,module,exports){ +var arr = require("array-extended"), + map = arr.map; + +function plucked(prop) { + var exec = prop.match(/(\w+)\(\)$/); + if (exec) { + prop = exec[1]; + return function (item) { + return item[prop](); + }; + } else { + return function (item) { + return item[prop]; + }; + } +} + +function plucker(prop) { + prop = prop.split("."); + if (prop.length === 1) { + return plucked(prop[0]); + } else { + var pluckers = map(prop, function (prop) { + return plucked(prop); + }); + var l = pluckers.length; + return function (item) { + var i = -1, res = item; + while (++i < l) { + res = pluckers[i](res); + } + return res; + }; + } +} + module.exports = require("extended")() - .register(require("array-extended")) + .register(arr) .register(require("date-extended")) .register(require("object-extended")) .register(require("string-extended")) .register(require("promise-extended")) .register(require("function-extended")) .register(require("is-extended")) + .register("plucker", plucker) .register("HashTable", require("ht")) .register("declare", require("declare.js")) .register(require("leafy")) .register("LinkedList", require("./linkedList")); -},{"./linkedList":15,"array-extended":39,"date-extended":40,"declare.js":42,"extended":43,"function-extended":46,"ht":52,"is-extended":53,"leafy":54,"object-extended":55,"promise-extended":56,"string-extended":57}],12:[function(require,module,exports){ +},{"./linkedList":16,"array-extended":42,"date-extended":43,"declare.js":45,"extended":46,"function-extended":49,"ht":55,"is-extended":56,"leafy":57,"object-extended":58,"promise-extended":59,"string-extended":60}],13:[function(require,module,exports){ "use strict"; var extd = require("./extended"), bind = extd.bind, @@ -1494,12 +1568,11 @@ module.exports = declare(EventEmitter, { // retract followed by an assert. modify: function (fact, cb) { //fact = this.workingMemory.getFact(fact); - this.rootNode.retractFact(this.workingMemory.retractFact(fact)); if ("function" === typeof cb) { cb.call(fact, fact); } + this.rootNode.modifyFact(this.workingMemory.modifyFact(fact)); this.emit("modify", fact); - this.rootNode.assertFact(this.workingMemory.assertFact(fact)); return fact; }, @@ -1525,7 +1598,7 @@ module.exports = declare(EventEmitter, { } }); -},{"./agenda":3,"./executionStrategy":10,"./extended":11,"./nodes":20,"./workingMemory":37,"events":47}],13:[function(require,module,exports){ +},{"./agenda":3,"./executionStrategy":11,"./extended":12,"./nodes":23,"./workingMemory":40,"events":50}],14:[function(require,module,exports){ "use strict"; var extd = require("./extended"), instanceOf = extd.instanceOf, @@ -1626,7 +1699,7 @@ var FlowContainer = declare({ } }).as(module); -},{"./extended":11,"./flow":12,"./pattern":35,"./rule":36}],14:[function(require,module,exports){ +},{"./extended":12,"./flow":13,"./pattern":38,"./rule":39}],15:[function(require,module,exports){ /** * * @projectName nools @@ -1702,7 +1775,7 @@ exports.transpile = function (file, options) { }; exports.parse = parse; -},{"./compile":5,"./extended":11,"./flowContainer":13,"fs":48,"path":49}],15:[function(require,module,exports){ +},{"./compile":5,"./extended":12,"./flowContainer":14,"fs":51,"path":52}],16:[function(require,module,exports){ var declare = require("declare.js"); declare({ @@ -1737,7 +1810,7 @@ declare({ } else { this.tail = node.prev; } - node.data = node.prev = node.next = null; + //node.data = node.prev = node.next = null; this.length--; }, @@ -1757,7 +1830,7 @@ declare({ }).as(module); -},{"declare.js":42}],16:[function(require,module,exports){ +},{"declare.js":45}],17:[function(require,module,exports){ var process=require("__browserify_process");/*global setImmediate, window, MessageChannel*/ var extd = require("./extended"); var nextTick; @@ -1795,7 +1868,7 @@ if (typeof setImmediate === "function") { } module.exports = nextTick; -},{"./extended":11,"__browserify_process":51}],17:[function(require,module,exports){ +},{"./extended":12,"__browserify_process":54}],18:[function(require,module,exports){ var AlphaNode = require("./alphaNode"); AlphaNode.extend({ @@ -1814,8 +1887,12 @@ AlphaNode.extend({ return this.__propagate("assert", context.set(this.alias, context.fact.object)); }, - retract: function (assertable) { - this.propagateRetract(assertable.fact); + modify: function (context) { + return this.__propagate("modify", context.set(this.alias, context.fact.object)); + }, + + retract: function (context) { + return this.__propagate("retract", context.set(this.alias, context.fact.object)); }, equal: function (other) { @@ -1823,7 +1900,7 @@ AlphaNode.extend({ } } }).as(module); -},{"./alphaNode":18}],18:[function(require,module,exports){ +},{"./alphaNode":19}],19:[function(require,module,exports){ "use strict"; var Node = require("./node"); @@ -1843,28 +1920,448 @@ Node.extend({ } } }).as(module); -},{"./node":24}],19:[function(require,module,exports){ +},{"./node":27}],20:[function(require,module,exports){ var AlphaNode = require("./alphaNode"); +function createContextHash(context) { + var ret = [], + paths = context.paths, + i = -1, + l = paths.length; + while (++i < l) { + ret.push(paths[i].id); + } + ret.push(context.hashCode); + return ret.join(":"); + +} + AlphaNode.extend({ instance: { constructor: function () { + this.memory = {}; this._super(arguments); }, assert: function (context) { - if (this.constraint.assert(context.factHash)) { + var hashCode = createContextHash(context); + if ((this.memory[hashCode] = this.constraint.assert(context.factHash))) { this.__propagate("assert", context); } }, + modify: function (context) { + var memory = this.memory, + hashCode = createContextHash(context), + wasMatch = memory[hashCode]; + if ((memory[hashCode] = this.constraint.assert(context.factHash))) { + this.__propagate(wasMatch ? "modify": "assert", context); + } else if (wasMatch) { + this.__propagate("retract", context); + } + }, + + retract: function (context) { + var hashCode = createContextHash(context), + memory = this.memory; + if (memory[hashCode]) { + this.__propagate("retract", context); + } + memory[hashCode] = null; + }, + toString: function () { return "EqualityNode" + this.__count; } } }).as(module); -},{"./alphaNode":18}],20:[function(require,module,exports){ +},{"./alphaNode":19}],21:[function(require,module,exports){ +var Node = require("./joinNode"), + extd = require("../extended"), + constraint = require("../constraint"), + EqualityConstraint = constraint.EqualityConstraint, + HashConstraint = constraint.HashConstraint, + ReferenceConstraint = constraint.ReferenceConstraint, + Context = require("../context"), + plucker = extd.plucker, + isEmpty = extd.isEmpty, + forEach = extd.forEach, + isArray = extd.isArray; + +var DEFAULT_MATCH = { + isMatch: function () { + return false; + } +}; + + +Node.extend({ + instance: { + + constructor: function (pattern, wm) { + this._super(arguments); + this.workingMemory = wm; + this.fromMemory = {}; + this.pattern = pattern; + this.type = pattern.get("constraints")[0]; + this.alias = pattern.get("alias"); + this.plucker = plucker(this.from = pattern.from); + var eqConstraints = this.__equalityConstraints = []; + var vars = []; + forEach(this.constraints = this.pattern.get("constraints").slice(1), function (c) { + if (c instanceof EqualityConstraint || c instanceof ReferenceConstraint) { + eqConstraints.push(c); + } else if (c instanceof HashConstraint) { + vars = vars.concat(c.get("variables")); + } + }); + this.__variables = vars; + }, + + __createMatches: function (context) { + var fh = context.factHash, o = this.plucker(fh); + if (isArray(o)) { + for (var i = 0, l = o.length; i < l; i++) { + this.__checkMatch(context, o[i], true); + } + } else { + this.__checkMatch(context, o, true); + } + }, + + __checkMatch: function (context, o, propogate) { + var newContext; + if ((newContext = this.__createMatch(context, o)).isMatch() && propogate) { + this.__propagate("assert", newContext.clone()); + } + return newContext; + }, + + __createMatch: function (lc, o) { + if (this.type.assert(o)) { + var createdFact = this.workingMemory.getFactHandle(o, true), + createdContext, + rc = new Context(createdFact) + .set(this.alias, o), + createdFactId = createdFact.id; + var fh = rc.factHash, lcFh = lc.factHash; + for (var key in lcFh) { + fh[key] = lcFh[key]; + } + var eqConstraints = this.__equalityConstraints, vars = this.__variables, i = -1, l = eqConstraints.length; + while (++i < l) { + if (!eqConstraints[i].assert(fh)) { + createdContext = DEFAULT_MATCH; + break; + } + } + var fm = this.fromMemory[createdFactId]; + if (!fm) { + fm = this.fromMemory[createdFactId] = {}; + } + if (!createdContext) { + var prop; + i = -1; + l = vars.length; + while (++i < l) { + prop = vars[i]; + fh[prop] = o[prop]; + } + lc.fromMatches[createdFact.id] = createdContext = rc.clone(createdFact, null, lc.match.merge(rc.match)); + } + fm[lc.hashCode] = [lc, createdContext]; + return createdContext; + } + return DEFAULT_MATCH; + }, + + retractRight: function () { + throw new Error("Shouldnt have gotten here"); + }, + + removeFromFromMemory: function (context) { + var factId = context.fact.id; + var fm = this.fromMemory[factId]; + if (fm) { + var entry; + for (var i in fm) { + entry = fm[i]; + if (entry[1] === context) { + delete fm[i]; + if (isEmpty(fm)) { + delete this.fromMemory[factId]; + } + break; + } + } + } + + }, + + retractLeft: function (context) { + var ctx = this.removeFromLeftMemory(context); + if (ctx) { + ctx = ctx.data; + var fromMatches = ctx.fromMatches; + for (var i in fromMatches) { + this.removeFromFromMemory(fromMatches[i]); + this.__propagate("retract", fromMatches[i].clone()); + } + } + }, + + modifyLeft: function (context) { + var ctx = this.removeFromLeftMemory(context), newContext, i, l, factId, fact; + if (ctx) { + this.__addToLeftMemory(context); + + var leftContext = ctx.data, + fromMatches = (context.fromMatches = {}), + rightMatches = leftContext.fromMatches, + o = this.plucker(context.factHash); + + if (isArray(o)) { + for (i = 0, l = o.length; i < l; i++) { + newContext = this.__checkMatch(context, o[i], false); + if (newContext.isMatch()) { + factId = newContext.fact.id; + if (factId in rightMatches) { + this.__propagate("modify", newContext.clone()); + } else { + this.__propagate("assert", newContext.clone()); + } + } + } + } else { + newContext = this.__checkMatch(context, o, false); + if (newContext.isMatch()) { + factId = newContext.fact.id; + if (factId in rightMatches) { + this.__propagate("modify", newContext.clone()); + } else { + this.__propagate("assert", newContext.clone()); + } + } + } + for (i in rightMatches) { + if (!(i in fromMatches)) { + this.removeFromFromMemory(rightMatches[i]); + this.__propagate("retract", rightMatches[i].clone()); + } + } + } else { + this.assertLeft(context); + } + fact = context.fact; + factId = fact.id; + var fm = this.fromMemory[factId]; + this.fromMemory[factId] = {}; + if (fm) { + var lc, entry, cc, createdIsMatch, factObject = fact.object; + for (i in fm) { + entry = fm[i]; + lc = entry[0]; + cc = entry[1]; + createdIsMatch = cc.isMatch(); + if (lc.hashCode !== context.hashCode) { + newContext = this.__createMatch(lc, factObject, false); + if (createdIsMatch) { + this.__propagate("retract", cc.clone()); + } + if (newContext.isMatch()) { + this.__propagate(createdIsMatch ? "modify": "assert", newContext.clone()); + } + + } + } + } + }, + + assertLeft: function (context) { + this.__addToLeftMemory(context); + context.fromMatches = {}; + this.__createMatches(context); + }, + + assertRight: function () { + throw new Error("Shouldnt have gotten here"); + }, + + + toString: function () { + return "FromNode" + this.__count; + } + + } +}).as(module); +},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":24}],22:[function(require,module,exports){ +var Node = require("./joinNode"), + extd = require("../extended"), + constraint = require("../constraint"), + EqualityConstraint = constraint.EqualityConstraint, + HashConstraint = constraint.HashConstraint, + ReferenceConstraint = constraint.ReferenceConstraint, + Context = require("../context"), + plucker = extd.plucker, + forEach = extd.forEach, + isArray = extd.isArray; + +Node.extend({ + instance: { + + constructor: function (pattern, workingMemory) { + this._super(arguments); + this.workingMemory = workingMemory; + this.pattern = pattern; + this.type = pattern.get("constraints")[0]; + this.alias = pattern.get("alias"); + this.plucker = plucker(this.from = pattern.from); + this.fromMemory = {}; + var eqConstraints = this.__equalityConstraints = []; + var vars = []; + forEach(this.constraints = this.pattern.get("constraints").slice(1), function (c) { + if (c instanceof EqualityConstraint || c instanceof ReferenceConstraint) { + eqConstraints.push(c); + } else if (c instanceof HashConstraint) { + vars = vars.concat(c.get("variables")); + } + }); + this.__variables = vars; + + }, + + retractLeft: function (context) { + var ctx = this.removeFromLeftMemory(context); + if (ctx) { + ctx = ctx.data; + if (!ctx.blocked) { + this.__propagate("retract", ctx.clone()); + } + } + }, + + __modify: function (context, leftContext) { + var leftContextBlocked = leftContext.blocked; + var fh = context.factHash, o = this.plucker(fh); + if (isArray(o)) { + for (var i = 0, l = o.length; i < l; i++) { + if (this.__isMatch(context, o[i], true)) { + context.blocked = true; + break; + } + } + } else { + context.blocked = this.__isMatch(context, o, true); + } + var newContextBlocked = context.blocked; + if (!newContextBlocked) { + if (leftContextBlocked) { + this.__propagate("assert", context.clone()); + } else { + this.__propagate("modify", context.clone()); + } + } else if (!leftContextBlocked) { + this.__propagate("retract", leftContext.clone()); + } + + }, + + modifyLeft: function (context) { + var ctx = this.removeFromLeftMemory(context); + if (ctx) { + this.__addToLeftMemory(context); + this.__modify(context, ctx.data); + } else { + throw new Error(); + } + var fm = this.fromMemory[context.fact.id]; + this.fromMemory[context.fact.id] = {}; + if (fm) { + for (var i in fm) { + // update any contexts associated with this fact + if (i !== context.hashCode) { + var lc = fm[i]; + ctx = this.removeFromLeftMemory(lc); + if (ctx) { + lc = lc.clone(); + lc.blocked = false; + this.__addToLeftMemory(lc); + this.__modify(lc, ctx.data); + } + } + } + } + }, + + __findMatches: function (context) { + var fh = context.factHash, o = this.plucker(fh), isMatch = false; + if (isArray(o)) { + for (var i = 0, l = o.length; i < l; i++) { + if (this.__isMatch(context, o[i], true)) { + context.blocked = true; + return; + } + } + this.__propagate("assert", context.clone()); + } else if (!(context.blocked = this.__isMatch(context, o, true))) { + this.__propagate("assert", context.clone()); + } + return isMatch; + }, + + __isMatch: function (oc, o, add) { + var ret = false; + if (this.type.assert(o)) { + var createdFact = this.workingMemory.getFactHandle(o); + var context = new Context(createdFact, null) + .mergeMatch(oc.match) + .set(this.alias, o); + if (add) { + var fm = this.fromMemory[createdFact.id]; + if (!fm) { + fm = this.fromMemory[createdFact.id] = {}; + } + fm[oc.hashCode] = oc; + } + var fh = context.factHash; + var eqConstraints = this.__equalityConstraints; + for (var i = 0, l = eqConstraints.length; i < l; i++) { + if (eqConstraints[i].assert(fh)) { + ret = true; + } else { + ret = false; + break; + } + } + } + return ret; + }, + + removeFromLeftMemory: function () { + return this._super(arguments); + }, + + assertLeft: function (context) { + this.__addToLeftMemory(context); + this.__findMatches(context); + }, + + assertRight: function () { + throw new Error("Shouldnt have gotten here"); + }, + + retractRight: function () { + throw new Error("Shouldnt have gotten here"); + }, + + toString: function () { + return "FromNode" + this.__count; + } + + } +}).as(module); +},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":24}],23:[function(require,module,exports){ "use strict"; var extd = require("../extended"), forEach = extd.forEach, @@ -1872,6 +2369,8 @@ var extd = require("../extended"), declare = extd.declare, pattern = require("../pattern.js"), ObjectPattern = pattern.ObjectPattern, + FromPattern = pattern.FromPattern, + FromNotPattern = pattern.FromNotPattern, NotPattern = pattern.NotPattern, CompositePattern = pattern.CompositePattern, InitialFactPattern = pattern.InitialFactPattern, @@ -1882,6 +2381,8 @@ var extd = require("../extended"), EqualityNode = require("./equalityNode"), JoinNode = require("./joinNode"), NotNode = require("./notNode"), + FromNode = require("./fromNode"), + FromNotNode = require("./fromNotNode"), LeftAdapterNode = require("./leftAdapterNode"), RightAdapterNode = require("./rightAdapterNode"), TypeNode = require("./typeNode"), @@ -1902,6 +2403,7 @@ declare({ recency: 0 }; this.agendaTree = agendaTree; + this.workingMemory = wm; }, assertRule: function (rule) { @@ -1933,6 +2435,13 @@ declare({ } }, + modifyFact: function (fact) { + var typeNodes = this.typeNodes, i = typeNodes.length - 1; + for (; i >= 0; i--) { + typeNodes[i].modify(fact); + } + }, + containsRule: function (name) { return some(this.terminalNodes, function (n) { @@ -1996,17 +2505,22 @@ declare({ }, __createAdapterNode: function (rule, side) { - return (side === "left" ? new LeftAdapterNode() : new RightAdapterNode()).addRule(rule); + return (side === "left" ? new LeftAdapterNode(): new RightAdapterNode()).addRule(rule); }, __createJoinNode: function (rule, pattern, outNode, side) { var joinNode; if (pattern.rightPattern instanceof NotPattern) { joinNode = new NotNode(); + } else if (pattern.rightPattern instanceof FromNotPattern) { + joinNode = new FromNotNode(pattern.rightPattern, this.workingMemory); + } else if (pattern.rightPattern instanceof FromPattern) { + joinNode = new FromNode(pattern.rightPattern, this.workingMemory); } else { joinNode = new JoinNode(); this.joinNodes.push(joinNode); } + joinNode["__rule__"] = rule; var parentNode = joinNode; if (outNode instanceof JoinNode) { var adapterNode = this.__createAdapterNode(rule, side); @@ -2019,10 +2533,15 @@ declare({ __addToNetwork: function (rule, pattern, outNode, side) { if (pattern instanceof ObjectPattern) { - if (pattern instanceof NotPattern && (!side || side === "left")) { - return this.__createBetaNode(rule, new CompositePattern(new InitialFactPattern(), pattern), outNode, side); + if ((pattern instanceof NotPattern || pattern instanceof FromPattern || pattern instanceof FromNotPattern) && (!side || side === "left")) { + if (pattern instanceof FromNotPattern) { + this.__createBetaNode(rule, new CompositePattern(new InitialFactPattern(), pattern), outNode, side); + } else { + this.__createBetaNode(rule, new CompositePattern(new InitialFactPattern(), pattern), outNode, side); + } + } else { + this.__createAlphaNode(rule, pattern, outNode, side); } - this.__createAlphaNode(rule, pattern, outNode, side); } else if (pattern instanceof CompositePattern) { this.__createBetaNode(rule, pattern, outNode, side); } @@ -2038,36 +2557,41 @@ declare({ __createAlphaNode: function (rule, pattern, outNode, side) { - var constraints = pattern.get("constraints"); - var typeNode = this.__createTypeNode(rule, pattern); - var aliasNode = this.__createAliasNode(rule, pattern); - typeNode.addOutNode(aliasNode, pattern); - aliasNode.addParentNode(typeNode); - var parentNode = aliasNode; - var i = constraints.length - 1; - for (; i > 0; i--) { - var constraint = constraints[i], node; - if (constraint instanceof HashConstraint) { - node = this.__createPropertyNode(rule, constraint); - } else if (constraint instanceof ReferenceConstraint) { - outNode.constraint.addConstraint(constraint); - continue; - } else { - node = this.__createEqualityNode(rule, constraint); + var typeNode, parentNode; + if (!(pattern instanceof FromPattern)) { + + var constraints = pattern.get("constraints"); + typeNode = this.__createTypeNode(rule, pattern); + var aliasNode = this.__createAliasNode(rule, pattern); + typeNode.addOutNode(aliasNode, pattern); + aliasNode.addParentNode(typeNode); + parentNode = aliasNode; + var i = constraints.length - 1; + for (; i > 0; i--) { + var constraint = constraints[i], node; + if (constraint instanceof HashConstraint) { + node = this.__createPropertyNode(rule, constraint); + } else if (constraint instanceof ReferenceConstraint) { + outNode.constraint.addConstraint(constraint); + continue; + } else { + node = this.__createEqualityNode(rule, constraint); + } + parentNode.addOutNode(node, pattern); + node.addParentNode(parentNode); + parentNode = node; } - parentNode.addOutNode(node, pattern); - node.addParentNode(parentNode); - parentNode = node; - } - if (outNode instanceof JoinNode) { - var adapterNode = this.__createAdapterNode(rule, side); - adapterNode.addParentNode(parentNode); - parentNode.addOutNode(adapterNode, pattern); - parentNode = adapterNode; + + if (outNode instanceof JoinNode) { + var adapterNode = this.__createAdapterNode(rule, side); + adapterNode.addParentNode(parentNode); + parentNode.addOutNode(adapterNode, pattern); + parentNode = adapterNode; + } + outNode.addParentNode(parentNode); + parentNode.addOutNode(outNode, pattern); + return typeNode; } - outNode.addParentNode(parentNode); - parentNode.addOutNode(outNode, pattern); - return typeNode; }, print: function () { @@ -2083,12 +2607,12 @@ declare({ -},{"../constraint":7,"../extended":11,"../pattern.js":35,"./aliasNode":17,"./equalityNode":19,"./joinNode":21,"./leftAdapterNode":23,"./notNode":25,"./propertyNode":26,"./rightAdapterNode":27,"./terminalNode":28,"./typeNode":29}],21:[function(require,module,exports){ +},{"../constraint":8,"../extended":12,"../pattern.js":38,"./aliasNode":18,"./equalityNode":20,"./fromNode":21,"./fromNotNode":22,"./joinNode":24,"./leftAdapterNode":26,"./notNode":28,"./propertyNode":29,"./rightAdapterNode":30,"./terminalNode":31,"./typeNode":32}],24:[function(require,module,exports){ var extd = require("../extended"), values = extd.hash.values, - indexOf = extd.indexOf, Node = require("./node"), - JoinReferenceNode = require("./joinReferenceNode"); + JoinReferenceNode = require("./joinReferenceNode"), + LinkedList = require("../linkedList"); Node.extend({ @@ -2098,22 +2622,26 @@ Node.extend({ this.constraint = new JoinReferenceNode(); this.leftMemory = {}; this.rightMemory = {}; - this.leftTuples = []; - this.rightTuples = []; + this.leftTuples = new LinkedList(); + this.rightTuples = new LinkedList(); }, dispose: function () { this.leftMemory = {}; this.rightMemory = {}; + this.leftTuples.clear(); + this.rightTuples.clear(); }, disposeLeft: function (fact) { this.leftMemory = {}; + this.leftTuples.clear(); this.propagateDispose(fact); }, disposeRight: function (fact) { this.rightMemory = {}; + this.rightTuples.clear(); this.propagateDispose(fact); }, @@ -2125,111 +2653,263 @@ Node.extend({ return "JoinNode " + this.__count; }, - retractResolve: function (match) { - var es = values(this.leftMemory), j = es.length, leftTuples = this.leftTuples; - while (--j > -1) { - var contexts = es[j], i = contexts.length, context; - while (--i > -1) { - context = contexts[i]; - if (this.resolve(context.match, match)) { - leftTuples.splice(indexOf(leftTuples, context), 1); - contexts.splice(i, 1); - break; - } + retractLeft: function (context) { + context = this.removeFromLeftMemory(context); + if (context) { + context = context.data; + var rightMathces = values(context.rightMatches), + i = -1, + l = rightMathces.length; + while (++i < l) { + this.__propagate("retract", rightMathces[i]); } + }else{ + throw new Error(); } - this._propagateRetractResolve(match); + return this; }, - retractLeft: function (fact) { - var contexts = this.leftMemory[fact.id], tuples = this.leftTuples, i, l; - if (contexts) { - i = -1; - l = contexts.length; + retractRight: function (context) { + context = this.removeFromRightMemory(context); + if (context) { + context = context.data; + var leftMatches = values(context.leftMatches), + i = -1, + l = leftMatches.length; while (++i < l) { - tuples.splice(indexOf(tuples, contexts[i]), 1); + this.__propagate("retract", leftMatches[i]); + } + }else{ + throw new Error(); + } + return this; + }, + + propagateFromLeft: function (context, constraint, rm) { + var mr; + if ((mr = constraint.setRightContext(rm).match()).isMatch) { + this.__propagate("assert", this.__addToMemoryMatches(rm, context, context.clone(null, null, mr))); + } + return this; + }, + + propagateFromRight: function (context, constraint, lm) { + var mr; + if ((mr = constraint.setLeftContext(lm).match()).isMatch) { + this.__propagate("assert", this.__addToMemoryMatches(context, lm, context.clone(null, null, mr))); + } + return this; + }, + + assertLeft: function (context) { + if (this.__addToLeftMemory(context)) { + var rm = this.rightTuples, node = {next: rm.head}, thisConstraint = this.constraint; + if (rm.length) { + thisConstraint.setLeftContext(context); + while ((node = node.next)) { + this.propagateFromLeft(context, thisConstraint, node.data); + } + thisConstraint.clearContexts(); + } + } else { + this.modifyLeft(context); + } + }, + + assertRight: function (context) { + if (this.__addToRightMemory(context)) { + var lm = this.leftTuples; + if (lm.length) { + var node = {next: lm.head}, thisConstraint = this.constraint; + thisConstraint.setRightContext(context); + while ((node = node.next)) { + this.propagateFromRight(context, thisConstraint, node.data); + } + thisConstraint.clearContexts(); } - delete this.leftMemory[fact.id]; } else { - var tuple; - for (i = 0; i < tuples.length; i++) { - tuple = tuples[i]; - if (indexOf(tuple.factIds, fact.id) !== -1) { - tuples.splice(i, 1); + this.modifyRight(context); + } + }, + + modifyLeft: function (context) { + var previousContext; + if ((previousContext = this.removeFromLeftMemory(context))) { + previousContext = previousContext.data; + this.__addToLeftMemory(context); + var rm = this.rightTuples, l = rm.length; + if (!l) { + this.propagateRetract(context); + } else { + var thisConstraint = this.constraint, + node = {next: rm.head}, + rightMatches = previousContext.rightMatches; + thisConstraint.setLeftContext(context); + while ((node = node.next)) { + this.propagateAssertModifyFromLeft(context, rightMatches, thisConstraint, node.data); } + thisConstraint.clearContexts(); + + } + } else { + throw new Error(); + } + + }, + + modifyRight: function (context) { + var previousContext; + if ((previousContext = this.removeFromRightMemory(context))) { + previousContext = previousContext.data; + this.__addToRightMemory(context); + var lm = this.leftTuples; + if (!lm.length) { + this.propagateRetract(context); + } else { + var thisConstraint = this.constraint, + leftMatches = previousContext.leftMatches, + node = {next: lm.head}; + thisConstraint.setRightContext(context); + while ((node = node.next)) { + this.propagateAssertModifyFromRight(context, leftMatches, thisConstraint, node.data); + } + thisConstraint.clearContexts(); + } + } else { + throw new Error(); + } + + }, + + propagateAssertModifyFromLeft: function (context, rightMatches, constraint, rm) { + var factId = rm.hashCode, mr; + if (factId in rightMatches) { + mr = constraint.setRightContext(rm).match(); + var mrIsMatch = mr.isMatch; + if (!mrIsMatch) { + this.__propagate("retract", rightMatches[factId].clone()); + } else { + this.__propagate("modify", this.__addToMemoryMatches(rm, context, context.clone(null, null, mr))); + } + } else { + this.propagateFromLeft(context, constraint, rm); + } + }, + + propagateAssertModifyFromRight: function (context, leftMatches, constraint, lm) { + var factId = lm.hashCode, mr; + if (factId in leftMatches) { + mr = constraint.setLeftContext(lm).match(); + var mrIsMatch = mr.isMatch; + if (!mrIsMatch) { + this.__propagate("retract", leftMatches[factId].clone()); + } else { + this.__propagate("modify", this.__addToMemoryMatches(context, lm, context.clone(null, null, mr))); + } + } else { + this.propagateFromRight(context, constraint, lm); + } + }, + + removeFromRightMemory: function (context) { + var hashCode = context.hashCode, ret; + context = this.rightMemory[hashCode] || null; + var tuples = this.rightTuples; + if (context) { + var leftMemory = this.leftMemory; + ret = context.data; + var leftMatches = ret.leftMatches; + tuples.remove(context); + for (var i in leftMatches) { + delete leftMemory[i].data.rightMatches[hashCode]; } + delete this.rightMemory[hashCode]; } - this.propagateRetract(fact); + return context; }, - retractRight: function (fact) { - var context = this.rightMemory[fact.id], tuples = this.rightTuples; + removeFromLeftMemory: function (context) { + var hashCode = context.hashCode; + context = this.leftMemory[hashCode] || null; if (context) { - tuples.splice(indexOf(tuples, context), 1); - delete this.rightMemory[fact.id]; - } else { - var tuple; - for (var i = 0; i < tuples.length; i++) { - tuple = tuples[i]; - if (indexOf(tuple.factIds, fact.id) !== -1) { - tuples.splice(i, 1); - } + var rightMemory = this.rightMemory; + var rightMatches = context.data.rightMatches; + this.leftTuples.remove(context); + for (var i in rightMatches) { + delete rightMemory[i].data.leftMatches[hashCode]; } + delete this.leftMemory[hashCode]; } - this.propagateRetract(fact); + return context; }, - assertLeft: function (context) { - this.__addToLeftMemory(context); - var rm = this.rightTuples, i = -1, l = rm.length, thisConstraint = this.constraint, mr; - thisConstraint.setLeftContext(context); - while (++i < l) { - if ((mr = thisConstraint.setRightContext(rm[i]).match()).isMatch) { - this.__propagate("assert", context.clone(null, null, mr)); - } + getRightMemoryMatches: function (context) { + var lm = this.leftMemory[context.hashCode], ret = {}; + if (lm) { + ret = lm.rightMatches; } - thisConstraint.clearContexts(); + return ret; }, - assertRight: function (context) { - var fact = context.fact; - this.rightMemory[fact.id] = context; - this.rightTuples.push(context); - var fl = this.leftTuples, i = -1, l = fl.length, thisConstraint = this.constraint, mr; - thisConstraint.setRightContext(context); - while (++i < l) { - if ((mr = thisConstraint.setLeftContext(fl[i]).match()).isMatch) { - this.__propagate("assert", context.clone(null, null, mr)); + __addToMemoryMatches: function (rightContext, leftContext, createdContext) { + var rightFactId = rightContext.hashCode, + rm = this.rightMemory[rightFactId], + lm, leftFactId = leftContext.hashCode; + if (rm) { + rm = rm.data; + if (leftFactId in rm.leftMatches) { + throw new Error("Duplicate left fact entry"); + } + rm.leftMatches[leftFactId] = createdContext; + } + lm = this.leftMemory[leftFactId]; + if (lm) { + lm = lm.data; + if (rightFactId in lm.rightMatches) { + throw new Error("Duplicate right fact entry"); } + lm.rightMatches[rightFactId] = createdContext; } - thisConstraint.clearContexts(); + return createdContext; }, - _propagateRetractResolve: function (context) { - this.__propagate("retractResolve", context); + __addToRightMemory: function (context) { + var hashCode = context.hashCode, rm = this.rightMemory; + if (hashCode in rm) { + return false; + } + rm[hashCode] = this.rightTuples.push(context); + context.leftMatches = {}; + return true; }, + __addToLeftMemory: function (context) { - var o = context.fact; - var lm = this.leftMemory[o.id]; - if (!lm) { - lm = []; - this.leftMemory[o.id] = lm; - } - this.leftTuples.push(context); - lm.push(context); - return this; + var hashCode = context.hashCode, lm = this.leftMemory; + if (hashCode in lm) { + return false; + } + lm[hashCode] = this.leftTuples.push(context); + context.rightMatches = {}; + return true; } } }).as(module); -},{"../extended":11,"./joinReferenceNode":22,"./node":24}],22:[function(require,module,exports){ +},{"../extended":12,"../linkedList":16,"./joinReferenceNode":25,"./node":27}],25:[function(require,module,exports){ var Node = require("./node"); + +var DEFUALT_CONSTRAINT = { + assert: function () { + return true; + } +}; + Node.extend({ instance: { - constraint: null, + constraint: DEFUALT_CONSTRAINT, __lc: null, __rc: null, __varLength: 0, @@ -2277,12 +2957,12 @@ Node.extend({ clearLeftContext: function () { this.__lc = null; var fh = this.__fh = {}, rc = this.__rc; - fh[this.__alias] = rc ? rc.fact.object : null; + fh[this.__alias] = rc ? rc.fact.object: null; return this; }, addConstraint: function (constraint) { - if (this.constraint === null) { + if (this.constraint === DEFUALT_CONSTRAINT) { this.constraint = constraint; } else { this.constraint = this.constraint.merge(constraint); @@ -2292,17 +2972,13 @@ Node.extend({ }, equal: function (constraint) { - if (this.constraint !== null) { + if (this.constraint !== DEFUALT_CONSTRAINT) { return this.constraint.equal(constraint.constraint); } }, isMatch: function () { - var constraint = this.constraint, ret = true; - if (constraint !== null) { - ret = constraint.assert(this.__fh); - } - return ret; + return this.constraint.assert(this.__fh); }, match: function () { @@ -2321,7 +2997,7 @@ Node.extend({ } }).as(module); -},{"./node":24}],23:[function(require,module,exports){ +},{"./node":27}],26:[function(require,module,exports){ var Node = require("./node"); Node.extend({ @@ -2338,7 +3014,7 @@ Node.extend({ this.__propagate("retractResolve", context); }, - modify: function (context) { + propagateModify: function (context) { this.__propagate("modifyLeft", context); }, @@ -2356,7 +3032,7 @@ Node.extend({ } }).as(module); -},{"./node":24}],24:[function(require,module,exports){ +},{"./node":27}],27:[function(require,module,exports){ var extd = require("../extended"), forEach = extd.forEach, indexOf = extd.indexOf, @@ -2429,8 +3105,7 @@ declare({ return false; }, - __propagate: function (method, context, outNodes) { - outNodes = outNodes || this.nodes; + __propagate: function (method, context) { var entrySet = this.__entrySet, i = entrySet.length, entry, outNode, paths, continuingPaths; while (--i > -1) { entry = entrySet[i]; @@ -2463,30 +3138,32 @@ declare({ } }, - propagateAssert: function (assertable, outNodes) { - this.__propagate("assert", assertable, outNodes || this.nodes); + propagateAssert: function (assertable) { + this.__propagate("assert", assertable); }, - propagateRetract: function (assertable, outNodes) { - this.__propagate("retract", assertable, outNodes || this.nodes); + propagateRetract: function (assertable) { + this.__propagate("retract", assertable); }, assert: function (assertable) { this.propagateAssert(assertable); }, - propagateModify: function (assertable, outNodes) { - this.__propagate("modify", assertable, outNodes || this.nodes); + modify: function (assertable) { + this.propagateModify(assertable); + }, + + propagateModify: function (assertable) { + this.__propagate("modify", assertable); } } }).as(module); -},{"../context":9,"../extended":11}],25:[function(require,module,exports){ +},{"../context":10,"../extended":12}],28:[function(require,module,exports){ var JoinNode = require("./joinNode"), - Context = require("../context"), - extd = require("../extended"), - indexOf = extd.indexOf; + LinkedList = require("../linkedList"); JoinNode.extend({ instance: { @@ -2494,7 +3171,6 @@ JoinNode.extend({ constructor: function () { this._super(arguments); this.leftTupleMemory = {}; - this.allTuples = {}; }, @@ -2503,171 +3179,261 @@ JoinNode.extend({ }, - retractRight: function (fact) { - var rightMemory = this.rightMemory; - var rightContext = rightMemory[fact.id], thisConstraint = this.constraint; - delete rightMemory[fact.id]; - if (rightContext) { - var index = indexOf(this.rightTuples, rightContext); - this.rightTuples.splice(index, 1); - var fl = rightContext.blocking, leftContext; - var rValues = this.rightTuples, k = rValues.length, rc, j; - while ((leftContext = fl.pop())) { - leftContext.blocker = null; - thisConstraint.setLeftContext(leftContext); - for (j = index; j < k; j++) { - rc = rValues[j]; - thisConstraint.setRightContext(rc); - if (thisConstraint.isMatch()) { - leftContext.blocker = rc; - rc.blocking.push(leftContext); - this.__addToLeftTupleMemory(leftContext); - break; + retractRight: function (context) { + var ctx = this.removeFromRightMemory(context); + if (ctx) { + var rightContext = ctx.data; + var blocking = rightContext.blocking; + if (blocking.length) { + //if we are blocking left contexts + var leftContext, rightTuples = this.rightTuples, thisConstraint = this.constraint, blockingNode = {next: blocking.head}, node, l = rightTuples.length, rc; + while ((blockingNode = blockingNode.next)) { + leftContext = blockingNode.data; + this.removeFromLeftBlockedMemory(leftContext); + if (l !== 0) { + thisConstraint.setLeftContext(leftContext); + node = ctx; + while ((node = node.next)) { + if (thisConstraint.setRightContext(rc = node.data).isMatch()) { + leftContext.blocker = rc; + this.addToLeftBlockedMemory(rc.blocking.push(leftContext)); + leftContext = null; + break; + } + } + thisConstraint.clearContexts(); + } + if (leftContext) { + this.__addToLeftMemory(leftContext); + this.__propagate("assert", leftContext.clone()); } } - if (!leftContext.blocker) { - this.__removeFromLeftTupleMemory(leftContext); - this.__addToLeftMemory(leftContext).propagateAssert(new Context(leftContext.fact, null, leftContext.match)); - } + blocking.clear(); } - thisConstraint.clearContexts(); + } else { + throw new Error(); } + }, - retractLeft: function (fact) { - var factId = fact.id, tuples = this.allTuples[fact.id] || [], context, blocking, blocker; - while (tuples.length) { - context = tuples.pop(); - if (indexOf(context.factIds, factId) !== -1) { - this.__removeFromAllTupleMemory(context); - this.__removeFromLeftMemory(context); - this.__removeFromLeftTupleMemory(context); - if ((blocker = context.blocker)) { - blocking = blocker.blocking; - blocking.splice(indexOf(blocking, context), 1); - context.blocker = null; - } + retractLeft: function (context) { + var ctx = this.removeFromLeftMemory(context); + if (ctx) { + this.__propagate("retract", ctx.data.clone()); + } else { + if (!this.removeFromLeftBlockedMemory(context)) { + throw new Error(); } } - delete this.leftMemory[factId]; - delete this.leftTupleMemory[factId]; - this.propagateRetract(fact); - }, assertLeft: function (context) { - var values = this.rightTuples, thisConstraint = this.constraint, i = -1, l = values.length, rc; - if (l !== 0) { + var values = this.rightTuples, + node, + thisConstraint = this.constraint, rc; + if (values.length) { + node = {next: values.head}; thisConstraint.setLeftContext(context); - while (++i < l) { - if (thisConstraint.setRightContext(rc = values[i]).isMatch()) { + while ((node = node.next) && context) { + if (thisConstraint.setRightContext(rc = node.data).isMatch()) { context.blocker = rc; - rc.blocking.push(context); - this.__addToLeftTupleMemory(context); + this.addToLeftBlockedMemory(rc.blocking.push(context)); context = null; - break; } } + thisConstraint.clearContexts(); } if (context) { - this.__addToLeftMemory(context).propagateAssert(new Context(context.fact, null, context.match)); + this.__addToLeftMemory(context); + this.__propagate("assert", context.clone()); } }, assertRight: function (context) { - context.blocking = []; - this.rightTuples.push(context); - this.rightMemory[context.fact.id] = context; - var fl = this.leftTuples, i = fl.length, leftContext, thisConstraint = this.constraint; - thisConstraint.setRightContext(context); - while (--i > -1) { - leftContext = fl[i]; - if (thisConstraint.setLeftContext(leftContext).isMatch()) { - this._propagateRetractResolve(leftContext.match); - //blocked so remove from memory - this.__removeFromLeftMemory(leftContext); - leftContext.blocker = context; - context.blocking.push(leftContext); - this.__addToLeftTupleMemory(leftContext); - } - } - thisConstraint.clearContexts(); - }, - - __removeFromLeftMemory: function (context) { - var leftMemories = this.leftMemory[context.fact.id] || [], lc, tuples = this.leftTuples; - for (var i = 0, l = tuples.length; i < l; i++) { - lc = tuples[i]; - if (lc === context) { - tuples.splice(i, 1); - leftMemories.splice(indexOf(leftMemories, lc), 1); - break; + this.__addToRightMemory(context); + context.blocking = new LinkedList(); + var fl = this.leftTuples, leftContext, node, thisConstraint = this.constraint; + if (fl.length) { + node = {next: fl.head}; + thisConstraint.setRightContext(context); + while ((node = node.next)) { + leftContext = node.data; + if (thisConstraint.setLeftContext(leftContext).isMatch()) { + this.__propagate("retract", leftContext.clone()); + this.removeFromLeftMemory(leftContext); + leftContext.blocker = context; + this.addToLeftBlockedMemory(context.blocking.push(leftContext)); + } } + thisConstraint.clearContexts(); } - return this; }, - __removeFromLeftTupleMemory: function (context) { - var leftMemories = this.leftTupleMemory[context.fact.id] || [], lc; - for (var i = 0, l = leftMemories.length; i < l; i++) { - lc = leftMemories[i]; - if (lc === context) { - leftMemories.splice(i, 1); - break; - } + addToLeftBlockedMemory: function (context) { + var data = context.data, hashCode = data.hashCode; + var ctx = this.leftMemory[hashCode]; + this.leftTupleMemory[hashCode] = context; + if (ctx) { + this.leftTuples.remove(ctx); } return this; }, - __addToAllTupleMemory: function (context) { - var factIds = context.factIds, i = -1, l = factIds.length, factId, allTuples = this.allTuples, tuples; - while (++i < l) { - factId = factIds[i]; - tuples = allTuples[factId] = (allTuples[factId] || []); - if (indexOf(tuples, context) === -1) { - tuples.push(context); - } + removeFromLeftBlockedMemory: function (context) { + var ret = this.leftTupleMemory[context.hashCode] || null; + if (ret) { + delete this.leftTupleMemory[context.hashCode]; + ret.data.blocker.blocking.remove(ret); } - return this; - + return ret; }, - __removeFromAllTupleMemory: function (context) { - var factIds = context.factIds, i = -1, l = factIds.length, factId, allTuples = this.allTuples, tuples, index; - while (++i < l) { - factId = factIds[i]; - tuples = allTuples[factId]; - index = indexOf(tuples, context); - if (index !== -1) { - tuples.splice(i, 1); + modifyLeft: function (context) { + var ctx = this.removeFromLeftMemory(context), + leftContext, + thisConstraint = this.constraint, + rightTuples = this.rightTuples, + l = rightTuples.length, + isBlocked = false, + node, rc, blocker; + if (!ctx) { + //blocked before + ctx = this.removeFromLeftBlockedMemory(context); + isBlocked = true; + } + if (ctx) { + leftContext = ctx.data; + + if (leftContext && leftContext.blocker) { + //we were blocked before so only check nodes previous to our blocker + blocker = this.rightMemory[leftContext.blocker.hashCode]; + } + if (blocker) { + thisConstraint.setLeftContext(context); + if (thisConstraint.setRightContext(rc = blocker.data).isMatch()) { + //we cant be proagated so retract previous + if (!isBlocked) { + //we were asserted before so retract + this.__propagate("retract", leftContext.clone()); + } + context.blocker = rc; + this.addToLeftBlockedMemory(rc.blocking.push(context)); + context = null; + } } - } - return this; - - }, + if (context && l) { + node = {next: rightTuples.head}; + //we were propogated before + thisConstraint.setLeftContext(context); + while ((node = node.next)) { + if (thisConstraint.setRightContext(rc = node.data).isMatch()) { + //we cant be proagated so retract previous + if (!isBlocked) { + //we were asserted before so retract + this.__propagate("retract", leftContext.clone()); + } + this.addToLeftBlockedMemory(rc.blocking.push(context)); + context.blocker = rc; + context = null; + break; + } + } + thisConstraint.clearContexts(); + } + if (context) { + //we can still be propogated + this.__addToLeftMemory(context); + if (!isBlocked) { + //we weren't blocked before so modify + this.__propagate("modify", context.clone()); + } else { + //we were blocked before but aren't now + this.__propagate("assert", context.clone()); + } + } + } else { + throw new Error(); + } + + }, + + modifyRight: function (context) { + var ctx = this.removeFromRightMemory(context); + if (ctx) { + var rightContext = ctx.data, + leftTuples = this.leftTuples, + leftTuplesLength = leftTuples.length, + leftContext, + thisConstraint = this.constraint, + node, + blocking = rightContext.blocking; + this.__addToRightMemory(context); + context.blocking = new LinkedList(); + if (leftTuplesLength || blocking.length) { + if (leftTuplesLength) { + //check currently left tuples in memory + thisConstraint.setRightContext(context); + node = {next: leftTuples.head}; + while ((node = node.next)) { + leftContext = node.data; + if (thisConstraint.setLeftContext(leftContext).isMatch()) { + this.__propagate("retract", leftContext.clone()); + this.removeFromLeftMemory(leftContext); + this.addToLeftBlockedMemory(context.blocking.push(leftContext)); + leftContext.blocker = context; + } + } + } - __addToLeftMemory: function (context) { - this._super(arguments); - this.__addToAllTupleMemory(context); - return this; - }, + if (blocking.length) { + var rc; + //check old blocked contexts + //check if the same contexts blocked before are still blocked + var blockingNode = {next: blocking.head}; + while ((blockingNode = blockingNode.next)) { + leftContext = blockingNode.data; + leftContext.blocker = null; + thisConstraint.setRightContext(context); + thisConstraint.setLeftContext(leftContext); + if (thisConstraint.isMatch()) { + leftContext.blocker = context; + this.addToLeftBlockedMemory(context.blocking.push(leftContext)); + leftContext = null; + return; + } else { + //we arent blocked anymore + leftContext.blocker = null; + node = ctx; + while ((node = node.next)) { + if (thisConstraint.setRightContext(rc = node.data).isMatch()) { + leftContext.blocker = rc; + this.addToLeftBlockedMemory(rc.blocking.push(leftContext)); + leftContext = null; + break; + } + } + if (leftContext) { + this.__addToLeftMemory(leftContext); + this.__propagate("assert", leftContext.clone()); + } + thisConstraint.clearContexts(); + } + } + thisConstraint.clearContexts(); + } - __addToLeftTupleMemory: function (context) { - var o = context.fact; - var lm = this.leftTupleMemory[o.id]; - if (!lm) { - lm = []; - this.leftTupleMemory[o.id] = lm; + } + } else { + throw new Error(); } - lm.push(context); - this.__addToAllTupleMemory(context); - return this; + + } } }).as(module); -},{"../context":9,"../extended":11,"./joinNode":21}],26:[function(require,module,exports){ +},{"../linkedList":16,"./joinNode":24}],29:[function(require,module,exports){ var AlphaNode = require("./alphaNode"), Context = require("../context"), extd = require("../extended"); @@ -2694,6 +3460,22 @@ AlphaNode.extend({ }, + retract: function (context) { + this.__propagate("retract", new Context(context.fact, context.paths)); + }, + + modify: function (context) { + var c = new Context(context.fact, context.paths); + var variables = this.variables, o = context.fact.object, item; + c.set(this.alias, o); + for (var i = 0, l = this.varLength; i < l; i++) { + item = variables[i]; + c.set(item[1], o[item[0]]); + } + this.__propagate("modify", c); + }, + + toString: function () { return "PropertyNode" + this.__count; } @@ -2702,7 +3484,7 @@ AlphaNode.extend({ -},{"../context":9,"../extended":11,"./alphaNode":18}],27:[function(require,module,exports){ +},{"../context":10,"../extended":12,"./alphaNode":19}],30:[function(require,module,exports){ var Node = require("./node"); Node.extend({ @@ -2728,7 +3510,7 @@ Node.extend({ this.__propagate("retractResolve", context); }, - modify: function (context) { + propagateModify: function (context) { this.__propagate("modifyRight", context); }, @@ -2737,7 +3519,7 @@ Node.extend({ } } }).as(module); -},{"./node":24}],28:[function(require,module,exports){ +},{"./node":27}],31:[function(require,module,exports){ var Node = require("./node"), extd = require("../extended"), bind = extd.bind, @@ -2767,6 +3549,7 @@ Node.extend({ var rule = this.rule, bucket = this.bucket; this.agenda.insert(this, { rule: rule, + hashCode: context.hashCode, index: this.index, name: rule.name, recency: bucket.recency++, @@ -2781,19 +3564,20 @@ Node.extend({ }, modify: function (context) { + this.agenda.retract(this, context); this.__assertModify(context); }, - retract: function (fact) { - this.agenda.removeByFact(this, fact); + retract: function (context) { + this.agenda.retract(this, context); }, - retractRight: function (fact) { - this.agenda.removeByFact(this, fact); + retractRight: function (context) { + this.agenda.retract(this, context); }, - retractLeft: function (fact) { - this.agenda.removeByFact(this, fact); + retractLeft: function (context) { + this.agenda.retract(this, context); }, assertLeft: function (context) { @@ -2804,19 +3588,12 @@ Node.extend({ this.__assertModify(context); }, - retractResolve: function (match) { - var resolve = this.resolve; - this.agenda.retract(this, function (v) { - return resolve(v.match, match); - }); - }, - toString: function () { return "TerminalNode " + this.rule.name; } } }).as(module); -},{"../extended":11,"./node":24}],29:[function(require,module,exports){ +},{"../extended":12,"./node":27}],32:[function(require,module,exports){ var AlphaNode = require("./alphaNode"), Context = require("../context"); @@ -2829,9 +3606,15 @@ AlphaNode.extend({ } }, + modify: function (fact) { + if (this.constraint.assert(fact.object)) { + this.__propagate("modify", fact); + } + }, + retract: function (fact) { if (this.constraint.assert(fact.object)) { - this.propagateRetract(fact); + this.__propagate("retract", fact); } }, @@ -2848,15 +3631,15 @@ AlphaNode.extend({ }, __propagate: function (method, fact) { - var es = this.__entrySet, i = es.length - 1; - for (; i >= 0; i--) { + var es = this.__entrySet, i = -1, l = es.length; + while (++i < l) { var e = es[i], outNode = e.key, paths = e.value; outNode[method](new Context(fact, paths)); } } } }).as(module); -},{"../context":9,"./alphaNode":18}],30:[function(require,module,exports){ +},{"../context":10,"./alphaNode":19}],33:[function(require,module,exports){ var process=require("__browserify_process");/* parser generated by jison 0.4.6 */ /* Returns a Parser object of the following structure: @@ -2933,9 +3716,9 @@ var process=require("__browserify_process");/* parser generated by jison 0.4.6 * var parser = (function(){ var parser = {trace: function trace() { }, yy: {}, -symbols_: {"error":2,"expressions":3,"EXPRESSION":4,"EOF":5,"UNARY_EXPRESSION":6,"LITERAL_EXPRESSION":7,"-":8,"!":9,"MULTIPLICATIVE_EXPRESSION":10,"*":11,"/":12,"%":13,"ADDITIVE_EXPRESSION":14,"+":15,"EXPONENT_EXPRESSION":16,"^":17,"RELATIONAL_EXPRESSION":18,"<":19,">":20,"<=":21,">=":22,"EQUALITY_EXPRESSION":23,"==":24,"!=":25,"=~":26,"!=~":27,"IN_EXPRESSION":28,"in":29,"ARRAY_EXPRESSION":30,"notIn":31,"OBJECT_EXPRESSION":32,"AND_EXPRESSION":33,"&&":34,"OR_EXPRESSION":35,"||":36,"ARGUMENT_LIST":37,",":38,"IDENTIFIER_EXPRESSION":39,"IDENTIFIER":40,".":41,"[":42,"STRING_EXPRESSION":43,"]":44,"(":45,")":46,"STRING":47,"NUMBER_EXPRESSION":48,"NUMBER":49,"REGEXP_EXPRESSION":50,"REGEXP":51,"BOOLEAN_EXPRESSION":52,"BOOLEAN":53,"NULL_EXPRESSION":54,"NULL":55,"$accept":0,"$end":1}, -terminals_: {2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",45:"(",46:")",47:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"}, -productions_: [0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,3],[32,4],[43,1],[48,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]], +symbols_: {"error":2,"expressions":3,"EXPRESSION":4,"EOF":5,"UNARY_EXPRESSION":6,"LITERAL_EXPRESSION":7,"-":8,"!":9,"MULTIPLICATIVE_EXPRESSION":10,"*":11,"/":12,"%":13,"ADDITIVE_EXPRESSION":14,"+":15,"EXPONENT_EXPRESSION":16,"^":17,"RELATIONAL_EXPRESSION":18,"<":19,">":20,"<=":21,">=":22,"EQUALITY_EXPRESSION":23,"==":24,"!=":25,"=~":26,"!=~":27,"IN_EXPRESSION":28,"in":29,"ARRAY_EXPRESSION":30,"notIn":31,"OBJECT_EXPRESSION":32,"AND_EXPRESSION":33,"&&":34,"OR_EXPRESSION":35,"||":36,"ARGUMENT_LIST":37,",":38,"IDENTIFIER_EXPRESSION":39,"IDENTIFIER":40,".":41,"[":42,"STRING_EXPRESSION":43,"]":44,"NUMBER_EXPRESSION":45,"(":46,")":47,"STRING":48,"NUMBER":49,"REGEXP_EXPRESSION":50,"REGEXP":51,"BOOLEAN_EXPRESSION":52,"BOOLEAN":53,"NULL_EXPRESSION":54,"NULL":55,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",46:"(",47:")",48:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"}, +productions_: [0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,4],[32,3],[32,4],[43,1],[45,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ @@ -2997,29 +3780,31 @@ case 38:this.$ = [$$[$0-3],$$[$0-1], 'propLookup']; break; case 39:this.$ = [$$[$0-3],$$[$0-1], 'propLookup']; break; -case 40:this.$ = [$$[$0-2], [null, null, 'arguments'], 'function'] +case 40:this.$ = [$$[$0-3],$$[$0-1], 'propLookup']; +break; +case 41:this.$ = [$$[$0-2], [null, null, 'arguments'], 'function'] break; -case 41:this.$ = [$$[$0-3], $$[$0-1], 'function'] +case 42:this.$ = [$$[$0-3], $$[$0-1], 'function'] break; -case 42:this.$ = [String(yytext.replace(/^['|"]|['|"]$/g, '')), null, 'string']; +case 43:this.$ = [String(yytext.replace(/^['|"]|['|"]$/g, '')), null, 'string']; break; -case 43:this.$ = [Number(yytext), null, 'number']; +case 44:this.$ = [Number(yytext), null, 'number']; break; -case 44:this.$ = [yytext, null, 'regexp']; +case 45:this.$ = [yytext, null, 'regexp']; break; -case 45:this.$ = [yytext.replace(/^\s+/, '') == 'true', null, 'boolean']; +case 46:this.$ = [yytext.replace(/^\s+/, '') == 'true', null, 'boolean']; break; -case 46:this.$ = [null, null, 'null']; +case 47:this.$ = [null, null, 'null']; break; -case 47:this.$ = [null, null, 'array']; +case 48:this.$ = [null, null, 'array']; break; -case 48:this.$ = [$$[$0-1], null, 'array']; +case 49:this.$ = [$$[$0-1], null, 'array']; break; -case 56:this.$ = [$$[$0-1], null, 'composite'] +case 57:this.$ = [$$[$0-1], null, 'composite'] break; } }, -table: [{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,57],36:[1,32],46:[2,57]},{5:[2,31],34:[1,33],36:[2,31],46:[2,31]},{5:[2,29],34:[2,29],36:[2,29],46:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],46:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],46:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],46:[2,19]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],46:[2,49]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],46:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],46:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],46:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],46:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],41:[1,44],42:[1,45],44:[2,54],45:[1,46],46:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],44:[2,55],46:[2,55]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],46:[2,14]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],44:[2,42],46:[2,42]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],46:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],46:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],46:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],46:[2,46]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],45:[2,36],46:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],46:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],45:[2,35],46:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],46:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],46:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:76,39:23,40:[1,26],43:75,47:[1,18]},{7:51,30:15,32:14,37:78,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],46:[1,77],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{46:[1,79]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:80,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],46:[2,47]},{38:[1,82],44:[1,81]},{38:[2,33],44:[2,33],46:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:83,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:85,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],46:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],46:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],46:[2,4]},{5:[2,32],34:[1,33],36:[2,32],46:[2,32]},{5:[2,30],34:[2,30],36:[2,30],46:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],46:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],46:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],46:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],46:[2,23]},{5:[2,25],34:[2,25],36:[2,25],46:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],45:[1,46],46:[2,27]},{5:[2,26],34:[2,26],36:[2,26],46:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],45:[1,46],46:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],46:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],46:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],46:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],46:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],45:[2,37],46:[2,37]},{44:[1,88]},{41:[1,44],42:[1,45],44:[1,89],45:[1,46]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],45:[2,40],46:[2,40]},{38:[1,82],46:[1,90]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],46:[2,56]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],46:[2,13]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],46:[2,48]},{7:91,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],46:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],46:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],46:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],46:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],46:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],45:[2,38],46:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],45:[2,39],46:[2,39]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],45:[2,41],46:[2,41]},{38:[2,34],44:[2,34],46:[2,34]}], +table: [{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,58],36:[1,32],47:[2,58]},{5:[2,31],34:[1,33],36:[2,31],47:[2,31]},{5:[2,29],34:[2,29],36:[2,29],47:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],47:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],47:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],47:[2,19]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],47:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],47:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],47:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],47:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],44:[2,54],47:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],41:[1,44],42:[1,45],44:[2,55],46:[1,46],47:[2,55]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],47:[2,56]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],47:[2,14]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],47:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],47:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],47:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],47:[2,46]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],47:[2,47]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],46:[2,36],47:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],47:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],46:[2,35],47:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],47:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],47:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:77,39:23,40:[1,26],43:75,45:76,48:[1,18],49:[1,19]},{7:51,30:15,32:14,37:79,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],47:[1,78],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{47:[1,80]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:81,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],47:[2,48]},{38:[1,83],44:[1,82]},{38:[2,33],44:[2,33],47:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:85,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:88,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],47:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],47:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],47:[2,4]},{5:[2,32],34:[1,33],36:[2,32],47:[2,32]},{5:[2,30],34:[2,30],36:[2,30],47:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],47:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],47:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],47:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],47:[2,23]},{5:[2,25],34:[2,25],36:[2,25],47:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],46:[1,46],47:[2,27]},{5:[2,26],34:[2,26],36:[2,26],47:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],46:[1,46],47:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],47:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],47:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],47:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],47:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],46:[2,37],47:[2,37]},{44:[1,89]},{44:[1,90]},{41:[1,44],42:[1,45],44:[1,91],46:[1,46]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],46:[2,41],47:[2,41]},{38:[1,83],47:[1,92]},{5:[2,57],8:[2,57],11:[2,57],12:[2,57],13:[2,57],15:[2,57],17:[2,57],19:[2,57],20:[2,57],21:[2,57],22:[2,57],24:[2,57],25:[2,57],26:[2,57],27:[2,57],29:[2,57],31:[2,57],34:[2,57],36:[2,57],38:[2,57],44:[2,57],47:[2,57]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],47:[2,13]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],47:[2,49]},{7:93,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],47:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],47:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],47:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],47:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],47:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],46:[2,38],47:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],46:[2,39],47:[2,39]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],46:[2,40],47:[2,40]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],41:[2,42],42:[2,42],44:[2,42],46:[2,42],47:[2,42]},{38:[2,34],44:[2,34],47:[2,34]}], defaultActions: {31:[2,1]}, parseError: function parseError(str, hash) { if (hash.recoverable) { @@ -3511,9 +4296,9 @@ case 15:/* skip whitespace */ break; case 16:return 49; break; -case 17:return 47; +case 17:return 48; break; -case 18:return 47; +case 18:return 48; break; case 19:return 40; break; @@ -3559,13 +4344,13 @@ case 39:return 15; break; case 40:return 17; break; -case 41:return 45; +case 41:return 46; break; case 42:return 44; break; case 43:return 42; break; -case 44:return 46; +case 44:return 47; break; case 45:return 9; break; @@ -3603,7 +4388,7 @@ if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } } -},{"__browserify_process":51,"fs":48,"path":49}],31:[function(require,module,exports){ +},{"__browserify_process":54,"fs":51,"path":52}],34:[function(require,module,exports){ (function () { "use strict"; var constraintParser = require("./constraint/parser"), @@ -3621,7 +4406,7 @@ if (typeof module !== 'undefined' && require.main === module) { return noolParser.parse(source, file); }; })(); -},{"./constraint/parser":30,"./nools/nool.parser":32}],32:[function(require,module,exports){ +},{"./constraint/parser":33,"./nools/nool.parser":35}],35:[function(require,module,exports){ "use strict"; var tokens = require("./tokens.js"), @@ -3631,7 +4416,7 @@ var tokens = require("./tokens.js"), var parse = function (src, keywords, context) { var orig = src; - src = src.replace(/\/\/(.*)[\n|\r|\r\n]/g, "").replace(/\n|\r|\r\n/g, " "); + src = src.replace(/\/\/(.*)/g, "").replace(/\n|\r|\r\n/g, " "); var blockTypes = new RegExp("^(" + keys(keywords).join("|") + ")"), index; while (src && (index = utils.findNextTokenIndex(src)) !== -1) { @@ -3661,7 +4446,7 @@ exports.parse = function (src, file) { }; -},{"../../extended":11,"./tokens.js":33,"./util.js":34}],33:[function(require,module,exports){ +},{"../../extended":12,"./tokens.js":36,"./util.js":37}],36:[function(require,module,exports){ var process=require("__browserify_process");"use strict"; var utils = require("./util.js"), @@ -3749,6 +4534,7 @@ var ruleTokens = { }; var constraintRegExp = /(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/; var predicateExp = /^(\w+) *\((.*)\)$/m; + var fromRegExp = /(\bfrom\s+.*)/; var parseRules = function (str) { var rules = []; var ruleLines = str.split(";"), l = ruleLines.length, ruleLine; @@ -3771,9 +4557,14 @@ var ruleTokens = { if (parts && parts.length) { rule.push(parts[2], parts[1]); var constraints = parts[3].replace(/^\s*|\s*$/g, ""); - var hashParts = constraints.match(constraintRegExp); + var hashParts = constraints.match(constraintRegExp), from = null, fromMatch; if (hashParts) { var hash = hashParts[1], constraint = constraints.replace(hash, ""); + if (fromRegExp.test(constraint)) { + fromMatch = constraint.match(fromRegExp); + from = fromMatch[0]; + constraint = constraint.replace(fromMatch[0], ""); + } if (constraint) { rule.push(constraint.replace(/^\s*|\s*$/g, "")); } @@ -3781,8 +4572,16 @@ var ruleTokens = { rule.push(eval("(" + hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g, '"$1" : "$2"') + ")")); } } else if (constraints && !isWhiteSpace(constraints)) { + if (fromRegExp.test(constraints)) { + fromMatch = constraints.match(fromRegExp); + from = fromMatch[0]; + constraints = constraints.replace(fromMatch[0], ""); + } rule.push(constraints); } + if (from) { + rule.push(from); + } rules.push(rule); } else { throw new Error("Invalid constraint " + ruleLine); @@ -3972,7 +4771,7 @@ var topLevelTokens = { module.exports = topLevelTokens; -},{"../../extended":11,"./util.js":34,"__browserify_process":51,"fs":48}],34:[function(require,module,exports){ +},{"../../extended":12,"./util.js":37,"__browserify_process":54,"fs":51}],37:[function(require,module,exports){ var process=require("__browserify_process");"use strict"; var path = require("path"); @@ -4064,113 +4863,216 @@ var findNextTokenIndex = exports.findNextTokenIndex = function (str, startIndex, exports.findNextToken = function (str, startIndex, endIndex) { return str.charAt(findNextTokenIndex(str, startIndex, endIndex)); }; -},{"__browserify_process":51,"path":49}],35:[function(require,module,exports){ -(function () { - "use strict"; - var extd = require("./extended"), - merge = extd.merge, - forEach = extd.forEach, - declare = extd.declare, - constraintMatcher = require("./constraintMatcher"), - constraint = require("./constraint"); - - - var Pattern = declare({}); - - var ObjectPattern = Pattern.extend({ - instance: { - constructor: function (type, alias, conditions, store, options) { - options = options || {}; - this.type = type; - this.alias = alias; - this.conditions = conditions; - this.pattern = options.pattern; - this.constraints = [new constraint.ObjectConstraint(type)]; - var constrnts = constraintMatcher.toConstraints(conditions, merge({alias: alias}, options)); - if (constrnts.length) { - this.constraints = this.constraints.concat(constrnts); - } else { - var cnstrnt = new constraint.TrueConstraint(); - this.constraints.push(cnstrnt); - } - if (store && !extd.isEmpty(store)) { - var atm = new constraint.HashConstraint(store); - this.constraints.push(atm); - } - forEach(this.constraints, function (constraint) { - constraint.set("alias", alias); - }); - }, +},{"__browserify_process":54,"path":52}],38:[function(require,module,exports){ +"use strict"; +var extd = require("./extended"), + isEmpty = extd.isEmpty, + merge = extd.merge, + forEach = extd.forEach, + declare = extd.declare, + constraintMatcher = require("./constraintMatcher"), + constraint = require("./constraint"), + EqualityConstraint = constraint.EqualityConstraint; - hasConstraint: function (type) { - return extd.some(this.constraints, function (c) { - return c instanceof type; - }); - }, +var id = 0; +var Pattern = declare({}); - hashCode: function () { - return [this.type, this.alias, extd.format("%j", this.conditions)].join(":"); - }, +var ObjectPattern = Pattern.extend({ + instance: { + constructor: function (type, alias, conditions, store, options) { + options = options || {}; + this.id = id++; + this.type = type; + this.alias = alias; + this.conditions = conditions; + this.pattern = options.pattern; + var constraints = [new constraint.ObjectConstraint(type)]; + var constrnts = constraintMatcher.toConstraints(conditions, merge({alias: alias}, options)); + if (constrnts.length) { + constraints = constraints.concat(constrnts); + } else { + var cnstrnt = new constraint.TrueConstraint(); + constraints.push(cnstrnt); + } + if (store && !isEmpty(store)) { + var atm = new constraint.HashConstraint(store); + constraints.push(atm); + } + + forEach(constraints, function (constraint) { + constraint.set("alias", alias); + }); + this.constraints = constraints; + }, - toString: function () { - return extd.format("%j", this.constraints); + getSpecificity: function () { + var constraints = this.constraints, specificity = 0; + for (var i = 0, l = constraints.length; i < l; i++) { + if (constraints[i] instanceof EqualityConstraint) { + specificity++; + } } + return specificity; + }, + + hasConstraint: function (type) { + return extd.some(this.constraints, function (c) { + return c instanceof type; + }); + }, + + hashCode: function () { + return [this.type, this.alias, extd.format("%j", this.conditions)].join(":"); + }, + + toString: function () { + return extd.format("%j", this.constraints); } - }).as(exports, "ObjectPattern"); + } +}).as(exports, "ObjectPattern"); - ObjectPattern.extend().as(exports, "NotPattern"); +var FromPattern = ObjectPattern.extend({ + instance: { + constructor: function (type, alias, conditions, store, from, options) { + this._super([type, alias, conditions, store, options]); + this.from = from.from; + }, - Pattern.extend({ + hasConstraint: function (type) { + return extd.some(this.constraints, function (c) { + return c instanceof type; + }); + }, - instance: { - constructor: function (left, right) { - this.leftPattern = left; - this.rightPattern = right; - }, + getSpecificity: function () { + return this._super(arguments) + 1; + }, - hashCode: function () { - return [this.leftPattern.hashCode(), this.rightPattern.hashCode()].join(":"); - }, + hashCode: function () { + return [this.type, this.alias, extd.format("%j", this.conditions), this.from.from].join(":"); + }, - getters: { - constraints: function () { - return this.leftPattern.constraints.concat(this.rightPattern.constraints); - } - } + toString: function () { + return extd.format("%j from %s", this.constraints, this.from.from); } + } +}).as(exports, "FromPattern"); - }).as(exports, "CompositePattern"); +FromPattern.extend().as(exports, "FromNotPattern"); +ObjectPattern.extend().as(exports, "NotPattern"); - var InitialFact = declare({}).as(exports, "InitialFact"); +Pattern.extend({ - ObjectPattern.extend({ - instance: { - constructor: function () { - this._super([InitialFact, "i", [], {}]); - }, + instance: { + constructor: function (left, right) { + this.id = id++; + this.leftPattern = left; + this.rightPattern = right; + }, - assert: function () { - return true; + hashCode: function () { + return [this.leftPattern.hashCode(), this.rightPattern.hashCode()].join(":"); + }, + + getSpecificity: function () { + return this.rightPattern.getSpecificity() + this.leftPattern.getSpecificity(); + }, + + getters: { + constraints: function () { + return this.leftPattern.constraints.concat(this.rightPattern.constraints); } } - }).as(exports, "InitialFactPattern"); + } -})(); +}).as(exports, "CompositePattern"); -},{"./constraint":7,"./constraintMatcher":8,"./extended":11}],36:[function(require,module,exports){ +var InitialFact = declare({ + constuctor: function(){ + this.id = id++; + } +}).as(exports, "InitialFact"); + +ObjectPattern.extend({ + instance: { + constructor: function () { + this._super([InitialFact, "i", [], {}]); + }, + + assert: function () { + return true; + } + } +}).as(exports, "InitialFactPattern"); + + + + +},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],39:[function(require,module,exports){ "use strict"; var extd = require("./extended"), isArray = extd.isArray, Promise = extd.Promise, declare = extd.declare, + isHash = extd.isHash, + isString = extd.isString, + format = extd.format, parser = require("./parser"), pattern = require("./pattern"), ObjectPattern = pattern.ObjectPattern, + FromPattern = pattern.FromPattern, NotPattern = pattern.NotPattern, + FromNotPattern = pattern.FromNotPattern, CompositePattern = pattern.CompositePattern; +var parseExtra = extd + .switcher() + .isUndefinedOrNull(function () { + return null; + }) + .isLike(/^from +/, function (s) { + return {from: s.replace(/^from +/, "").replace(/^\s*|\s*$/g, "")}; + }) + .def(function (o) { + throw new Error("invalid rule constraint option " + o); + }) + .switcher(); + +var normailizeConstraint = extd + .switcher() + .isLength(1, function (c) { + throw new Error("invalid rule constraint " + format("%j", [c])); + }) + .isLength(2, function (c) { + c.push("true"); + return c; + }) + //handle case where c[2] is a hash rather than a constraint string + .isLength(3, function (c) { + if (isHash(c[2])) { + c.splice(2, 0, "true"); + } + return c; + }) + //handle case where c[3] is a from clause rather than a hash for references + .isLength(4, function (c) { + if (isString(c[3])) { + c.splice(3, 0, null); + c[4] = parseExtra(c[4]); + } + return c; + }) + .def(function (c) { + if (c.length === 5) { + c[4] = parseExtra(c[4]); + } + return c; + }) + .switcher(); + + var getParamTypeSwitch = extd .switcher() .isEq("string", function () { @@ -4230,29 +5132,56 @@ var parsePattern = extd }) .contains("not", 0, function (condition) { condition.shift(); - return [ - new NotPattern( - getParamType(condition[0]), - condition[1] || "m", - parser.parseConstraint(condition[2] || "true"), - condition[3] || {}, - {scope: condition.scope, pattern: condition[2]} - ) - ]; + condition = normailizeConstraint(condition); + if (condition[4] && condition[4].from) { + return [ + new FromNotPattern( + getParamType(condition[0]), + condition[1] || "m", + parser.parseConstraint(condition[2] || "true"), + condition[3] || {}, + condition[4], + {scope: condition.scope, pattern: condition[2]} + ) + ]; + } else { + return [ + new NotPattern( + getParamType(condition[0]), + condition[1] || "m", + parser.parseConstraint(condition[2] || "true"), + condition[3] || {}, + {scope: condition.scope, pattern: condition[2]} + ) + ]; + } }) .def(function (condition) { - return [ - new ObjectPattern( - getParamType(condition[0]), - condition[1] || "m", - parser.parseConstraint(condition[2] || "true"), - condition[3] || {}, - {scope: condition.scope, pattern: condition[2]} - ) - ]; + condition = normailizeConstraint(condition); + if (condition[4] && condition[4].from) { + return [ + new FromPattern( + getParamType(condition[0]), + condition[1] || "m", + parser.parseConstraint(condition[2] || "true"), + condition[3] || {}, + condition[4], + {scope: condition.scope, pattern: condition[2]} + ) + ]; + } else { + return [ + new ObjectPattern( + getParamType(condition[0]), + condition[1] || "m", + parser.parseConstraint(condition[2] || "true"), + condition[3] || {}, + {scope: condition.scope, pattern: condition[2]} + ) + ]; + } }).switcher(); - var Rule = declare({ instance: { constructor: function (name, options, pattern, cb) { @@ -4283,7 +5212,7 @@ var Rule = declare({ }); function createRule(name, options, conditions, cb) { - if (extd.isArray(options)) { + if (isArray(options)) { cb = conditions; conditions = options; } else { @@ -4346,12 +5275,11 @@ exports.createRule = createRule; -},{"./extended":11,"./parser":31,"./pattern":35}],37:[function(require,module,exports){ +},{"./extended":12,"./parser":34,"./pattern":38}],40:[function(require,module,exports){ "use strict"; -var declare = require("declare.js"); - - -var id = 0; +var declare = require("declare.js"), + LinkedList = require("./linkedList"), + id = 0; var Fact = declare({ @@ -4379,26 +5307,69 @@ declare({ constructor: function () { this.recency = 0; - this.facts = []; + this.facts = new LinkedList(); }, dispose: function () { - this.facts.length = 0; + this.facts.clear(); + }, + + getFactHandle: function (o) { + var head = {next: this.facts.head}, ret; + while ((head = head.next)) { + var existingFact = head.data; + if (existingFact.equals(o)) { + return existingFact; + } + } + if (!ret) { + ret = new Fact(o); + ret.recency = this.recency++; + //this.facts.push(ret); + } + return ret; + }, + + modifyFact: function (fact) { + var head = {next: this.facts.head}; + while ((head = head.next)) { + var existingFact = head.data; + if (existingFact.equals(fact)) { + existingFact.recency = this.recency++; + return existingFact; + } + } + //if we made it here we did not find the fact + throw new Error("the fact to modify does not exist"); }, assertFact: function (fact) { - fact = new Fact(fact); - fact.recency = this.recency++; - this.facts.push(fact); - return fact; + var ret = new Fact(fact); + ret.recency = this.recency++; + this.facts.push(ret); + return ret; +// var head = {next: this.facts.head}, ret; +// while ((head = head.next)) { +// var existingFact = head.data; +// if (existingFact.equals(fact)) { +// ret = existingFact; +// break; +// } +// } +// if (!ret) { +// ret = new Fact(fact); +// ret.recency = this.recency++; +// this.facts.push(ret); +// } +// return ret; }, retractFact: function (fact) { - var facts = this.facts, l = facts.length, i = -1, existingFact; - while (++i < l) { - existingFact = facts[i]; + var facts = this.facts, head = {next: facts.head}; + while ((head = head.next)) { + var existingFact = head.data; if (existingFact.equals(fact)) { - this.facts.splice(i, 1); + facts.remove(head); return existingFact; } } @@ -4412,7 +5383,7 @@ declare({ }).as(exports, "WorkingMemory"); -},{"declare.js":42}],38:[function(require,module,exports){ +},{"./linkedList":16,"declare.js":45}],41:[function(require,module,exports){ (function () { "use strict"; @@ -4457,7 +5428,7 @@ declare({ }).call(this); -},{"extended":43,"is-extended":53}],39:[function(require,module,exports){ +},{"extended":46,"is-extended":56}],42:[function(require,module,exports){ (function () { "use strict"; /*global define*/ @@ -5127,7 +6098,7 @@ declare({ -},{"arguments-extended":38,"extended":43,"is-extended":53}],40:[function(require,module,exports){ +},{"arguments-extended":41,"extended":46,"is-extended":56}],43:[function(require,module,exports){ (function () { "use strict"; @@ -6075,7 +7046,7 @@ declare({ -},{"array-extended":39,"extended":43,"is-extended":53}],41:[function(require,module,exports){ +},{"array-extended":42,"extended":46,"is-extended":56}],44:[function(require,module,exports){ (function () { /** @@ -7002,9 +7973,9 @@ declare({ -},{}],42:[function(require,module,exports){ +},{}],45:[function(require,module,exports){ module.exports = require("./declare.js"); -},{"./declare.js":41}],43:[function(require,module,exports){ +},{"./declare.js":44}],46:[function(require,module,exports){ (function () { "use strict"; /*global extender is, dateExtended*/ @@ -7103,7 +8074,7 @@ module.exports = require("./declare.js"); -},{"extender":45}],44:[function(require,module,exports){ +},{"extender":48}],47:[function(require,module,exports){ (function () { /*jshint strict:false*/ @@ -7644,9 +8615,9 @@ module.exports = require("./declare.js"); } }).call(this); -},{"declare.js":42}],45:[function(require,module,exports){ +},{"declare.js":45}],48:[function(require,module,exports){ module.exports = require("./extender.js"); -},{"./extender.js":44}],46:[function(require,module,exports){ +},{"./extender.js":47}],49:[function(require,module,exports){ (function () { "use strict"; @@ -7885,7 +8856,7 @@ module.exports = require("./extender.js"); -},{"arguments-extended":38,"extended":43,"is-extended":53}],47:[function(require,module,exports){ +},{"arguments-extended":41,"extended":46,"is-extended":56}],50:[function(require,module,exports){ var process=require("__browserify_process");if (!process.EventEmitter) process.EventEmitter = function () {}; var EventEmitter = exports.EventEmitter = process.EventEmitter; @@ -8081,10 +9052,10 @@ EventEmitter.listenerCount = function(emitter, type) { return ret; }; -},{"__browserify_process":51}],48:[function(require,module,exports){ +},{"__browserify_process":54}],51:[function(require,module,exports){ // nothing to see here... no file methods for the browser -},{}],49:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ var process=require("__browserify_process");function filter (xs, fn) { var res = []; for (var i = 0; i < xs.length; i++) { @@ -8263,7 +9234,7 @@ exports.relative = function(from, to) { exports.sep = '/'; -},{"__browserify_process":51}],50:[function(require,module,exports){ +},{"__browserify_process":54}],53:[function(require,module,exports){ require=(function(e,t,n,r){function i(r){if(!n[r]){if(!t[r]){if(e)return e(r);throw new Error("Cannot find module '"+r+"'")}var s=n[r]={exports:{}};t[r][0](function(e){var n=t[r][1][e];return i(n?n:e)},s,s.exports)}return n[r].exports}for(var s=0;sf&&j>f&&f++;);c=g[f]-h[f],c||(c=i-j)}return c||(c=a.recency-b.recency),c>0?1:-1},j=e({instance:{constructor:function(){this.memory={},this.memoryValues=new g},clear:function(){this.memoryValues.clear(),this.memory={},this.memory.length=this.memoryValues.length=0},get:function(a){var b=this.memory[a.id];return b?b.data:[]},remove:function(a){for(var b,c,e,f,g=a.match.facts,h=g.length,i=this.memoryValues,j=this.memory,k=-1;++k-1;)c=h[i],f.remove(c),e.remove(c),g.remove(c);h.length=0},retract:function(a,b){var c=this.rules[a.name],d=c.tree,e=c.factTable,f=this.getAgendaGroup(a.rule.agendaGroup);d.traverse(d.__root,k,function(a){b(a)&&(e.remove(a),f.remove(a),d.remove(a))})},insert:function(a,b){var c=this.rules[a.name],d=a.rule,e=d.agendaGroup;c.tree.insert(b),this.getAgendaGroup(e).insert(b),e&&d.autoFocus&&this.setFocus(e),c.factTable.insert(b)},dispose:function(){for(var a in this.agendaGroups)this.agendaGroups[a].clear();var b=this.rules;for(a in b)a in b&&(b[a].tree.clear(),b[a].factTable.clear());this.rules={}}}})},{"./extended":11,events:47}],4:[function(require,module,exports){"use strict";var extd=require("../extended"),forEach=extd.forEach,isString=extd.isString;exports.modifiers=["assert","modify","retract","emit","halt","focus"];var createFunction=function(body,defined,scope,scopeNames,definedNames){var declares=[];forEach(definedNames,function(a){-1!==body.indexOf(a)&&declares.push("var "+a+"= defined."+a+";")}),forEach(scopeNames,function(a){-1!==body.indexOf(a)&&declares.push("var "+a+"= scope."+a+";")}),body=["((function(){",declares.join(""),"\n return ",body,"\n})())"].join("");try{return eval(body)}catch(e){throw new Error("Invalid action : "+body+"\n"+e.message)}},createDefined=function(){var a=function(a){a=isString(a)?new Function("return "+a+";")():a;var b=a.hasOwnProperty("constructor")&&"function"==typeof a.constructor?a.constructor:function(b){b=b||{};for(var c in b)c in a&&(this[c]=b[c])},c=b.prototype;for(var d in a)c[d]=a[d];return b};return function(b){return a(b.properties)}}();exports.createFunction=createFunction,exports.createDefined=createDefined},{"../extended":11}],5:[function(a,b,c){var d=a("__browserify_Buffer").Buffer,e=a("../extended"),f=a("../parser"),g=a("../constraintMatcher.js"),h=e.indexOf,i=e.forEach,j=e.removeDuplicates,k=e.map,l=e.hash,m=l.keys,n=e.merge,o=a("../rule"),p=a("./common"),q=p.createDefined,r=p.createFunction,s=function(a,b,c,d){var f=[];i(b,function(b){-1!==a.indexOf(b)&&f.push("var "+b+"= facts."+b+";")}),e(c).keys().forEach(function(b){-1!==a.indexOf(b)&&f.push("var "+b+"= defined."+b+";")}),e(d).keys().forEach(function(b){-1!==a.indexOf(b)&&f.push("var "+b+"= scope."+b+";")});var g=["facts","flow"];/next\(.*\)/.test(a)&&g.push("next"),a="with(flow){"+f.join("")+a+"}";try{return new Function("defined, scope","return "+new Function(g.join(","),a).toString())(c,d)}catch(h){throw new Error("Invalid action : "+a+"\n"+h.message)}},t=function(){var a=function(a,b,c,d,j){var k=[],l=a[0],m=a[1],n=a[2],o=a[3];if(e.isHash(n)&&(o=n,n=null),!l||!(l=d[l]))throw new Error("Invalid class "+a[0]+" for rule "+j);if(k.push(l),k.push(m,n,o),c.push(k),b.push(m),n&&i(g.getIdentifiers(f.parseConstraint(n)),function(a){b.push(a)}),e.isObject(o))for(var p in o){var q=o[p];-1===h(b,q)&&b.push(q)}};return function(b,c,d){var f=b.name;if(e.isEmpty(b))throw new Error("Rule is empty");var g=b.options||{};g.scope=d;var h=b.constraints||[],k=h.length;k||(h=["true"]);var l=b.action;if(e.isUndefined(l))throw new Error("No action was defined for rule "+f);var m=[],n=[];return e(h).forEach(function(b){if(b.length){var d=b[0];if("not"===d){var e=[];b.shift(),a(b,n,e,c,f);var g=e[0];g.unshift(d),m.push(g)}else if("or"===d){var h=[d];b.shift(),i(b,function(b){a(b,n,h,c,f)}),m.push(h)}else a(b,n,m,c,f),n=j(n)}}),o.createRule(f,g,m,s(l,n,c,d))}}();c.parse=function(a,b){return f.parseRuleSet(a,b)},c.compile=function(a,b,c,f){e.isFunction(b)?(c=b,b={}):(b=b||{},c=null);var g=a.name||b.name;if(!g)throw new Error("Name must be present in JSON or options");var h=new f(g),j=n({Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},b.define||{});"undefined"!=typeof d&&(j.Buffer=d);var l=n({console:console},b.scope);i(a.define,function(a){j[a.name]=q(a)}),e(j).forEach(function(a,b){h.addDefined(b,a)});var o=e(a.scope).pluck("name").union(e(l).keys().value()).value(),p=k(m(j),function(a){return a});i(a.scope,function(a){l[a.name]=r(a.body,j,l,o,p)});var s=a.rules;return s.length&&i(s,function(a){h.__rules=h.__rules.concat(t(a,j,l))}),c&&c.call(h,h),h},c.transpile=a("./transpile").transpile},{"../constraintMatcher.js":8,"../extended":11,"../parser":31,"../rule":36,"./common":4,"./transpile":6,__browserify_Buffer:50}],6:[function(a,b,c){function d(a){a=l(a)?new Function("return "+a+";")():a;var b,c=["(function(){"];a.hasOwnProperty("constructor")&&"function"==typeof a.constructor?c.push("var Defined = "+a.constructor.toString()+";"):c.push("var Defined = function(opts){ for(var i in opts){if(opts.hasOwnProperty(i)){this[i] = opts[i];}}};"),c.push("var proto = Defined.prototype;");for(var d in a)a.hasOwnProperty(d)&&(b=a[d],c.push("proto."+d+" = "+(h.isFunction(b)?b.toString():h.format("%j",b))+";"));return c.push("return Defined;"),c.push("}())"),c.join("")}function e(a,b,c,d){var e=[];i(b,function(b){-1!==a.indexOf(b)&&e.push("var "+b+"= facts."+b+";")}),h(c).keys().forEach(function(b){-1!==a.indexOf(b)&&e.push("var "+b+"= defined."+b+";")}),h(d).keys().forEach(function(b){-1!==a.indexOf(b)&&e.push("var "+b+"= scope."+b+";")});var f=["facts","flow"];/next\(.*\)/.test(a)&&f.push("next"),a=e.join("")+a;try{return["function(",f.join(","),"){with(flow){",a,"}}"].join("")}catch(g){throw new Error("Invalid action : "+a+"\n"+g.message)}}function f(a,b){a=a.slice(0);var c=[];if("or"===a[0])return c.push('["'+a.shift()+'"'),c.push(h.map(a,function(a){return f(a,b)}).join(",")+"]"),c;if("not"===a[0]&&c.push('"',a.shift(),'", '),b.push(a[1]),c.push(a[0],', "'+a[1].replace(/"/g,'\\"')+'"'),a.splice(0,2),a.length){var d=a.shift();h.isString(d)?(c.push(',"'+d.replace(/"/g,'\\"'),'"'),i(m.getIdentifiers(n.parseConstraint(d)),function(a){b.push(a)})):(c.push(',"true"'),a.unshift(d))}if(a.length){var e=a.shift();h(e).values().forEach(function(a){-1===j(b,a)&&b.push(a)}),c.push(","+h.format("%j",[e]))}return"["+c.join("")+"]"}var g=a("__browserify_Buffer").Buffer,h=a("../extended"),i=h.forEach,j=h.indexOf,k=h.merge,l=h.isString,m=a("../constraintMatcher"),n=a("../parser");c.transpile=function(a,b){b=b||{};var c=[];c.push("(function(){"),c.push("return function(options){"),c.push("options = options || {};"),c.push("var bind = function(scope, fn){return function(){return fn.apply(scope, arguments);};}, defined = options.defined || {}, scope = options.scope || {};");var i=k({Array:Array,String:String,Number:Number,Boolean:Boolean,RegExp:RegExp,Date:Date,Object:Object},b.define||{});"undefined"!=typeof g&&(i.Buffer=g);var j=k({console:console},b.scope);return c.push(["return nools.flow('",b.name,"', function(){"].join("")),c.push(h(a.define||[]).map(function(a){var b=a.name;return a[b]={},["var",b,"= defined."+b,"= this.addDefined('"+b+"',",d(a.properties)+");"].join(" ")}).value().join("\n")),c.push(h(a.scope||[]).map(function(a){var b=a.name;return j[b]={},["var",b,"= scope."+b,"= ",a.body,";"].join(" ")}).value().join("\n")),c.push("scope.console = console;\n"),c.push(h(a.rules||[]).map(function(a){var b=[],c=["this.rule('",a.name.replace(/'/g,"\\'"),"'"],d=h.merge(a.options||{},{scope:"scope"});return c.push(",",h.format("%j",[d]).replace(/(:"scope")/,":scope")),a.constraints&&!h.isEmpty(a.constraints)&&(c.push(", ["),c.push(h(a.constraints).map(function(a){return f(a,b)}).value().join(",")),c.push("]")),c.push(",",e(a.action,b,i,j)),c.push(");"),c.join("")}).value().join("")),c.push("});"),c.push("};"),c.push("}());"),c.join("")}},{"../constraintMatcher":8,"../extended":11,"../parser":31,__browserify_Buffer:50}],7:[function(a,b,c){"use strict";var d,e=a("./extended"),f=e.merge,g=e.instanceOf,h=e.filter,i=e.declare,j=i({instance:{constructor:function(b,c){d||(d=a("./constraintMatcher")),this.type=b,this.constraint=c},assert:function(){throw new Error("not implemented")},equal:function(a){return g(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return[this.get("alias")]}}}});j.extend({instance:{constructor:function(a){this._super(["object",a])},assert:function(a){return a instanceof this.constraint||a.constructor===this.constraint},equal:function(a){return g(a,this._static)&&this.constraint===a.constraint}}}).as(c,"ObjectConstraint"),j.extend({instance:{constructor:function(a,b){this._super(["equality",a]),b=b||{},this.pattern=b.pattern,this._matcher=d.getMatcher(a,b.scope||{})},assert:function(a){return this._matcher(a)}}}).as(c,"EqualityConstraint"),j.extend({instance:{constructor:function(){this._super(["equality",[!0]])},equal:function(a){return g(a,this._static)&&this.get("alias")===a.get("alias")},assert:function(){return!0}}}).as(c,"TrueConstraint"),j.extend({instance:{constructor:function(a,b){this.cache={},this._super(["reference",a]),b=b||{},this.values=[],this.pattern=b.pattern,this._options=b,this._matcher=d.getMatcher(a,b.scope||{})},assert:function(a){try{return this._matcher(a)}catch(b){throw new Error("Error with evaluating pattern "+this.pattern+" "+b.message)}},merge:function(a){var b=this;return a instanceof this._static&&(b=new this._static([this.constraint,a.constraint,"and"],f({},this._options,this._options)),b._alias=this._alias||a._alias,b.vars=this.vars.concat(a.vars)),b},equal:function(a){return g(a,this._static)&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return this.vars},alias:function(){return this._alias}},setters:{alias:function(a){this._alias=a,this.vars=h(d.getIdentifiers(this.constraint),function(b){return b!==a})}}}}).as(c,"ReferenceConstraint"),j.extend({instance:{constructor:function(a){this._super(["hash",a])},equal:function(a){return e.instanceOf(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"HashConstraint")},{"./constraintMatcher":8,"./extended":11}],8:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isArray,f=d.forEach,g=d.some,h=d.map,i=d.indexOf,j=d.isNumber,k=d.removeDuplicates,l=a("./constraint"),m={indexOf:d.indexOf,now:function(){return new Date},Date:function(a,b,c,d,e,f,g){var h=new Date;return j(a)&&h.setYear(a),j(b)&&h.setMonth(b),j(c)&&h.setDate(c),j(d)&&h.setHours(d),j(e)&&h.setMinutes(e),j(f)&&h.setSeconds(f),j(g)&&h.setMilliseconds(g),h},lengthOf:function(a,b){return a.length===b},isTrue:function(a){return a===!0},isFalse:function(a){return a===!1},isNotNull:function(a){return null!==a},dateCmp:function(a,b){return d.compare(a,b)}};f(["years","days","months","hours","minutes","seconds"],function(a){m[a+"FromNow"]=d[a+"FromNow"],m[a+"Ago"]=d[a+"Ago"]}),f(["isArray","isNumber","isHash","isObject","isDate","isBoolean","isString","isRegExp","isNull","isEmpty","isUndefined","isDefined","isUndefinedOrNull","isPromiseLike","isFunction","deepEqual"],function(a){var b=d[a];m[a]=function(){return b.apply(d,arguments)}});var n={equal:function(a,b){var c=!1;return a===b?c=!0:a[2]===b[2]&&(c=-1!==i(["string","number","boolean","regexp","identifier","null"],a[2])?a[0]===b[0]:"unary"===a[2]||"logicalNot"===a[2]?this.equal(a[0],b[0]):this.equal(a[0],b[0])&&this.equal(a[1],b[1])),c},getIdentifiers:function(a){var b=[],c=a[2];if("identifier"===c)return[a[0]];if("function"===c)b=b.concat(this.getIdentifiers(a[0])).concat(this.getIdentifiers(a[1]));else if("string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c)if("prop"===c){if(b=b.concat(this.getIdentifiers(a[0])),a[1])for(var d=a[1];e(d);){if("function"===d[2]){b=b.concat(this.getIdentifiers(d[1]));break}d=d[1]}}else a[0]&&(b=b.concat(this.getIdentifiers(a[0]))),a[1]&&(b=b.concat(this.getIdentifiers(a[1])));return k(b)},toConstraints:function(a,b){var c=[],d=b.alias,e=b.scope||{},f=a[2];return"and"===f?c=c.concat(this.toConstraints(a[0],b)).concat(this.toConstraints(a[1],b)):("composite"===f||"or"===f||"lt"===f||"gt"===f||"lte"===f||"gte"===f||"like"===f||"notLike"===f||"eq"===f||"neq"===f||"in"===f||"notIn"===f||"prop"===f||"propLookup"===f||"function"===f||"logicalNot"===f)&&(g(this.getIdentifiers(a),function(a){return!(a===d||a in m||a in e)})?c.push(new l.ReferenceConstraint(a,b)):c.push(new l.EqualityConstraint(a,b))),c},parse:function(a){return this[a[2]](a[0],a[1])},composite:function(a){return this.parse(a)},and:function(a,b){return["(",this.parse(a),"&&",this.parse(b),")"].join(" ")},or:function(a,b){return["(",this.parse(a),"||",this.parse(b),")"].join(" ")},prop:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"['",this.parse(b),"']"].join("")},propLookup:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"[",this.parse(b),"]"].join("")},unary:function(a){return-1*this.parse(a)},plus:function(a,b){return[this.parse(a),"+",this.parse(b)].join(" ")},minus:function(a,b){return[this.parse(a),"-",this.parse(b)].join(" ")},mult:function(a,b){return[this.parse(a),"*",this.parse(b)].join(" ")},div:function(a,b){return[this.parse(a),"/",this.parse(b)].join(" ")},mod:function(a,b){return[this.parse(a),"%",this.parse(b)].join(" ")},lt:function(a,b){return[this.parse(a),"<",this.parse(b)].join(" ")},gt:function(a,b){return[this.parse(a),">",this.parse(b)].join(" ")},lte:function(a,b){return[this.parse(a),"<=",this.parse(b)].join(" ")},gte:function(a,b){return[this.parse(a),">=",this.parse(b)].join(" ")},like:function(a,b){return[this.parse(b),".test(",this.parse(a),")"].join("")},notLike:function(a,b){return["!",this.parse(b),".test(",this.parse(a),")"].join("")},eq:function(a,b){return[this.parse(a),"===",this.parse(b)].join(" ")},neq:function(a,b){return[this.parse(a),"!==",this.parse(b)].join(" ")},"in":function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) != -1"].join("")},notIn:function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) == -1"].join("")},arguments:function(a,b){var c=[];return a&&c.push(this.parse(a)),b&&c.push(this.parse(b)),c.join(",")},array:function(a){var b=[];return a?(b=this.parse(a),e(b)?b:["[",b,"]"].join("")):["[",b.join(","),"]"].join("")},"function":function(a,b){var c=this.parse(b);return[this.parse(a),"(",c,")"].join("")},string:function(a){return"'"+a+"'"},number:function(a){return a},"boolean":function(a){return a},regexp:function(a){return a},identifier:function(a){return a},"null":function(){return"null"},logicalNot:function(a){return["!(",this.parse(a),")"].join("")}},o=c.toJs=function(a,b){var c=n.parse(a);b=b||{};var d=n.getIdentifiers(a),e="var indexOf = definedFuncs.indexOf;"+h(d,function(a){var c=["var ",a," = "];return m.hasOwnProperty(a)?c.push("definedFuncs['",a,"']"):b.hasOwnProperty(a)?c.push("scope['",a,"']"):c.push("'",a,"' in fact ? fact['",a,"'] : hash['",a,"']"),c.push(";"),c.join("")}).join("")+" return !!("+c+");",f=new Function("fact, hash, definedFuncs, scope",e);return function(a,c){return f(a,c,m,b)}};c.getMatcher=function(a,b){return o(a,b)},c.toConstraints=function(a,b){return n.toConstraints(a,b)},c.equal=function(a,b){return n.equal(a,b)},c.getIdentifiers=function(a){return n.getIdentifiers(a)}},{"./constraint":7,"./extended":11}],9:[function(a,b){"use strict";var c=a("./extended"),d=c.declare,e=c.merge,f=c.union,g=Array.prototype.slice,h=d({instance:{constructor:function(a){this.isMatch=!0,a instanceof this._static?(this.isMatch=a.isMatch,this.facts=g.call(a.facts),this.factIds=g.call(a.factIds),this.hashCode=this.factIds.join(":"),this.factHash=e({},a.factHash),this.recency=g.call(a.recency)):a?(this.facts=[a],this.factIds=[a.id],this.recency=[a.recency],this.hashCode=a.id+"",this.factHash=a.factHash||{}):(this.facts=[],this.factIds=[],this.factHash={},this.hashCode="")},merge:function(a){var b=new this._static;return b.isMatch=a.isMatch,b.facts=this.facts.concat(a.facts),b.factIds=this.factIds.concat(a.factIds),b.hashCode=b.factIds.join(":"),b.factHash=e({},this.factHash,a.factHash),b.recency=f(this.recency,a.recency),b}}}),i=d({instance:{match:null,factHash:null,fact:null,hashCode:null,paths:null,constructor:function(a,b,c){this.fact=a,this.paths=b||null;var d=this.match=c||new h(a);this.factHash=d.factHash,this.hashCode=d.hashCode,this.factIds=d.factIds},set:function(a,b){return this.factHash[a]=b,this},isMatch:function(a){return this.match.isMatch=a,this},clone:function(a,b,c){return new i(a||this.fact,b||this.path,c||this.match)}}}).as(b)},{"./extended":11}],10:[function(a,b){var c=a("./extended"),d=c.Promise,e=a("./nextTick"),f=c.isPromiseLike;d.extend({instance:{looping:!1,constructor:function(a,b){this._super([]),this.flow=a,this.agenda=a.agenda,this.rootNode=a.rootNode,this.matchUntilHalt=!!b,c.bindAll(this,["onAlter","callNext"])},halt:function(){this.__halted=!0,this.looping||this.callback()},onAlter:function(){this.flowAltered=!0,this.looping||!this.matchUntilHalt||this.__halted||this.callNext()},setup:function(){var a=this.flow;this.rootNode.resetCounter(),a.on("assert",this.onAlter),a.on("modify",this.onAlter),a.on("retract",this.onAlter)},tearDown:function(){var a=this.flow;a.removeListener("assert",this.onAlter),a.removeListener("modify",this.onAlter),a.removeListener("retract",this.onAlter)},__handleAsyncNext:function(a){var b=this,c=b.agenda;return a.addCallback(function(){b.looping=!1,c.isEmpty()?(!b.matchUntilHalt||b.__halted)&&b.callback():(b.flowAltered&&(b.rootNode.incrementCounter(),b.flowAltered=!1),b.__halted?b.callback():b.callNext()),b=null}).addErrback(this.errback)},__handleSyncNext:function(a){return this.looping=!1,this.agenda.isEmpty()||this.flowAltered&&(this.rootNode.incrementCounter(),this.flowAltered=!1),a&&!this.__halted?e(this.callNext):(!this.matchUntilHalt||this.__halted)&&this.callback(),a},callback:function(){this.tearDown(),this._super(arguments)},callNext:function(){this.looping=!0;var a=this.agenda.fireNext();return f(a)?this.__handleAsyncNext(a):this.__handleSyncNext(a)},execute:function(){return this.setup(),this.callNext(),this}}}).as(b)},{"./extended":11,"./nextTick":16}],11:[function(a,b){b.exports=a("extended")().register(a("array-extended")).register(a("date-extended")).register(a("object-extended")).register(a("string-extended")).register(a("promise-extended")).register(a("function-extended")).register(a("is-extended")).register("HashTable",a("ht")).register("declare",a("declare.js")).register(a("leafy")).register("LinkedList",a("./linkedList"))},{"./linkedList":15,"array-extended":39,"date-extended":40,"declare.js":42,extended:43,"function-extended":46,ht:52,"is-extended":53,leafy:54,"object-extended":55,"promise-extended":56,"string-extended":57}],12:[function(a,b){"use strict";var c=a("./extended"),d=c.bind,e=c.declare,f=a("./nodes"),g=a("events").EventEmitter,h=a("./workingMemory"),i=h.WorkingMemory,j=a("./executionStrategy"),k=a("./agenda");b.exports=e(g,{instance:{name:null,executionStrategy:null,constructor:function(a){this.env=null,this.name=a,this.__rules={},this.workingMemory=new i,this.agenda=new k(this),this.agenda.on("fire",d(this,"emit","fire")),this.agenda.on("focused",d(this,"emit","focused")),this.rootNode=new f.RootNode(this.workingMemory,this.agenda)},focus:function(a){return this.agenda.setFocus(a),this},halt:function(){var a=this.executionStrategy;return a.matchUntilHalt&&a.halt(),this},dispose:function(){this.workingMemory.dispose(),this.agenda.dispose(),this.rootNode.dispose()},assert:function(a){return this.rootNode.assertFact(this.workingMemory.assertFact(a)),this.emit("assert",a),a},retract:function(a){return this.rootNode.retractFact(this.workingMemory.retractFact(a)),this.emit("retract",a),a},modify:function(a,b){return this.rootNode.retractFact(this.workingMemory.retractFact(a)),"function"==typeof b&&b.call(a,a),this.emit("modify",a),this.rootNode.assertFact(this.workingMemory.assertFact(a)),a},print:function(){this.rootNode.print()},containsRule:function(a){return this.rootNode.containsRule(a)},rule:function(a){this.rootNode.assertRule(a)},matchUntilHalt:function(a){return(this.executionStrategy=new j(this,!0)).execute().classic(a).promise()},match:function(a){return(this.executionStrategy=new j(this)).execute().classic(a).promise()}}})},{"./agenda":3,"./executionStrategy":10,"./extended":11,"./nodes":20,"./workingMemory":37,events:47}],13:[function(a,b){"use strict";var c=a("./extended"),d=c.instanceOf,e=c.forEach,f=c.declare,g=a("./pattern").InitialFact,h=a("./rule"),i=a("./flow"),j={},k=f({instance:{constructor:function(a,b){if(this.name=a,this.cb=b,this.__rules=[],this.__defined={},b&&b.call(this,this),j.hasOwnProperty(a))throw new Error("Flow with "+a+" already defined");j[a]=this},getDefined:function(a){var b=this.__defined[a.toLowerCase()];if(!b)throw new Error(a+" flow class is not defined");return b},addDefined:function(a,b){return this.__defined[a.toLowerCase()]=b,b},rule:function(){return this.__rules=this.__rules.concat(h.createRule.apply(h,arguments)),this},getSession:function(){var a=new i(this.name);e(this.__rules,function(b){a.rule(b)}),a.assert(new g);for(var b=0,c=arguments.length;c>b;b++)a.assert(arguments[b]);return a},containsRule:function(a){return c.some(this.__rules,function(b){return b.name===a})}},"static":{getFlow:function(a){return j[a]},hasFlow:function(a){return c.has(j,a)},deleteFlow:function(a){return d(a,k)&&(a=a.name),delete j[a],k},deleteFlows:function(){for(var a in j)a in j&&delete j[a];return k},create:function(a,b){return new k(a,b)}}}).as(b)},{"./extended":11,"./flow":12,"./pattern":35,"./rule":36}],14:[function(a,b,c){"use strict";function d(a){return/\.nools$/.test(a)}function e(a){var b;return b=d(a)?i.parse(g.readFileSync(a,"utf8"),a):i.parse(a)}var f=a("./extended"),g=a("fs"),h=a("path"),i=a("./compile"),j=a("./flowContainer");c.Flow=j,c.getFlow=j.getFlow,c.hasFlow=j.hasFlow,c.deleteFlow=function(a){return j.deleteFlow(a),this},c.deleteFlows=function(){return j.deleteFlows(),this},c.flow=j.create,c.compile=function(a,b,c){if(f.isFunction(b)?(c=b,b={}):(b=b||{},c=null),f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),!b.name)throw new Error("Name required when compiling nools source");return i.compile(a,b,c,j)},c.transpile=function(a,b){return b=b||{},f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),i.transpile(a,b)},c.parse=e},{"./compile":5,"./extended":11,"./flowContainer":13,fs:48,path:49}],15:[function(a,b){var c=a("declare.js");c({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null},push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,d},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,a.data=a.prev=a.next=null,this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},clear:function(){this.head=this.tail=null,this.length=0}}}).as(b)},{"declare.js":42}],16:[function(a,b){var c,d=a("__browserify_process"),e=a("./extended");if("function"==typeof setImmediate)c="undefined"!=typeof window?e.bind(window,setImmediate):setImmediate;else if("undefined"!=typeof d)c=d.nextTick;else if("undefined"!=typeof MessageChannel){var f=new MessageChannel,g={},h=g;f.port1.onmessage=function(){g=g.next;var a=g.task;delete g.task,a()},c=function(a){h=h.next={task:a},f.port2.postMessage(0)}}else c=function(a){setTimeout(a,0)};b.exports=c},{"./extended":11,__browserify_process:51}],17:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias")},toString:function(){return"AliasNode"+this.__count},assert:function(a){return this.__propagate("assert",a.set(this.alias,a.fact.object))},retract:function(a){this.propagateRetract(a.fact)},equal:function(a){return a instanceof this._static&&this.alias===a.alias}}}).as(b)},{"./alphaNode":18}],18:[function(a,b){"use strict";var c=a("./node");c.extend({instance:{constructor:function(a){this._super([]),this.constraint=a},toString:function(){return"AlphaNode "+this.__count},equal:function(a){return this.constraint.equal(a.constraint)}}}).as(b)},{"./node":24}],19:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments)},assert:function(a){this.constraint.assert(a.factHash)&&this.__propagate("assert",a)},toString:function(){return"EqualityNode"+this.__count}}}).as(b)},{"./alphaNode":18}],20:[function(a,b,c){"use strict";var d=a("../extended"),e=d.forEach,f=d.some,g=d.declare,h=a("../pattern.js"),i=h.ObjectPattern,j=h.NotPattern,k=h.CompositePattern,l=h.InitialFactPattern,m=a("../constraint"),n=m.HashConstraint,o=m.ReferenceConstraint,p=a("./aliasNode"),q=a("./equalityNode"),r=a("./joinNode"),s=a("./notNode"),t=a("./leftAdapterNode"),u=a("./rightAdapterNode"),v=a("./typeNode"),w=a("./terminalNode"),x=a("./propertyNode");g({instance:{constructor:function(a,b){this.terminalNodes=[],this.joinNodes=[],this.nodes=[],this.constraints=[],this.typeNodes=[],this.__ruleCount=0,this.bucket={counter:0,recency:0},this.agendaTree=b},assertRule:function(a){var b=new w(this.bucket,this.__ruleCount++,a,this.agendaTree);this.__addToNetwork(a,a.pattern,b),this.__mergeJoinNodes(),this.terminalNodes.push(b)},resetCounter:function(){this.bucket.counter=0},incrementCounter:function(){this.bucket.counter++},assertFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].assert(a)},retractFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].retract(a)},containsRule:function(a){return f(this.terminalNodes,function(b){return b.rule.name===a})},dispose:function(){for(var a=this.typeNodes,b=a.length-1;b>=0;b--)a[b].dispose()},__mergeJoinNodes:function(){for(var a=this.joinNodes,b=0;b=0;c--){var d=b[c];if(a.equal(d))return d}return b.push(a),a},__createTypeNode:function(a,b){for(var c=new v(b.get("constraints")[0]),d=this.typeNodes,e=d.length-1;e>=0;e--){var f=d[e];if(c.equal(f))return f}return d.push(c),c},__createEqualityNode:function(a,b){return this.__checkEqual(new q(b)).addRule(a)},__createPropertyNode:function(a,b){return this.__checkEqual(new x(b)).addRule(a)},__createAliasNode:function(a,b){return this.__checkEqual(new p(b)).addRule(a)},__createAdapterNode:function(a,b){return("left"===b?new t:new u).addRule(a)},__createJoinNode:function(a,b,c,d){var e;b.rightPattern instanceof j?e=new s:(e=new r,this.joinNodes.push(e));var f=e;if(c instanceof r){var g=this.__createAdapterNode(a,d);f.addOutNode(g,b),f=g}return f.addOutNode(c,b),e.addRule(a)},__addToNetwork:function(a,b,c,d){if(b instanceof i){if(b instanceof j&&(!d||"left"===d))return this.__createBetaNode(a,new k(new l,b),c,d);this.__createAlphaNode(a,b,c,d)}else b instanceof k&&this.__createBetaNode(a,b,c,d)},__createBetaNode:function(a,b,c,d){var e=this.__createJoinNode(a,b,c,d);return this.__addToNetwork(a,b.rightPattern,e,"right"),this.__addToNetwork(a,b.leftPattern,e,"left"),c.addParentNode(e),e},__createAlphaNode:function(a,b,c,d){var e=b.get("constraints"),f=this.__createTypeNode(a,b),g=this.__createAliasNode(a,b);f.addOutNode(g,b),g.addParentNode(f);for(var h=g,i=e.length-1;i>0;i--){var j,k=e[i];if(k instanceof n)j=this.__createPropertyNode(a,k);else{if(k instanceof o){c.constraint.addConstraint(k);continue}j=this.__createEqualityNode(a,k)}h.addOutNode(j,b),j.addParentNode(h),h=j}if(c instanceof r){var l=this.__createAdapterNode(a,d);l.addParentNode(h),h.addOutNode(l,b),h=l}return c.addParentNode(h),h.addOutNode(c,b),f},print:function(){e(this.terminalNodes,function(a){a.print(" ")})}}}).as(c,"RootNode")},{"../constraint":7,"../extended":11,"../pattern.js":35,"./aliasNode":17,"./equalityNode":19,"./joinNode":21,"./leftAdapterNode":23,"./notNode":25,"./propertyNode":26,"./rightAdapterNode":27,"./terminalNode":28,"./typeNode":29}],21:[function(a,b){var c=a("../extended"),d=c.hash.values,e=c.indexOf,f=a("./node"),g=a("./joinReferenceNode");f.extend({instance:{constructor:function(){this._super([]),this.constraint=new g,this.leftMemory={},this.rightMemory={},this.leftTuples=[],this.rightTuples=[]},dispose:function(){this.leftMemory={},this.rightMemory={}},disposeLeft:function(a){this.leftMemory={},this.propagateDispose(a)},disposeRight:function(a){this.rightMemory={},this.propagateDispose(a)},hashCode:function(){return"JoinNode "+this.__count},toString:function(){return"JoinNode "+this.__count -},retractResolve:function(a){for(var b=d(this.leftMemory),c=b.length,f=this.leftTuples;--c>-1;)for(var g,h=b[c],i=h.length;--i>-1;)if(g=h[i],this.resolve(g.match,a)){f.splice(e(f,g),1),h.splice(i,1);break}this._propagateRetractResolve(a)},retractLeft:function(a){var b,c,d=this.leftMemory[a.id],f=this.leftTuples;if(d){for(b=-1,c=d.length;++be;e++)this.addOutNode(d,c[e]);a.nodes.remove(d)},this);for(var b=a.parentNodes,c=0,d=a.parentNodes.l;d>c;c++){var e=b[c];this.addParentNode(e),e.nodes.remove(a)}return this},resolve:function(a,b){return a.hashCode===b.hashCode},print:function(a){console.log(a+this.toString()),d(this.parentNodes,function(b){b.print(" "+a)})},addOutNode:function(a,b){this.nodes.contains(a)||this.nodes.put(a,[]),this.nodes.get(a).push(b),this.__entrySet=this.nodes.entrySet()},addParentNode:function(a){-1===e(this.parentNodes,a)&&this.parentNodes.push(a)},shareable:function(){return!1},__propagate:function(a,b,c){c=c||this.nodes;for(var d,e,g,h,j=this.__entrySet,k=j.length;--k>-1;)d=j[k],e=d.key,g=d.value,b.paths?(h=f(g,b.paths)).length&&e[a](new i(b.fact,h,b.match)):e[a](b)},dispose:function(a){this.propagateDispose(a)},retract:function(a){this.propagateRetract(a)},propagateDispose:function(a,b){b=b||this.nodes;for(var c=this.__entrySet,d=c.length-1;d>=0;d--){var e=c[d],f=e.key;f.dispose(a)}},propagateAssert:function(a,b){this.__propagate("assert",a,b||this.nodes)},propagateRetract:function(a,b){this.__propagate("retract",a,b||this.nodes)},assert:function(a){this.propagateAssert(a)},propagateModify:function(a,b){this.__propagate("modify",a,b||this.nodes)}}}).as(b)},{"../context":9,"../extended":11}],25:[function(a,b){var c=a("./joinNode"),d=a("../context"),e=a("../extended"),f=e.indexOf;c.extend({instance:{constructor:function(){this._super(arguments),this.leftTupleMemory={},this.allTuples={}},toString:function(){return"NotNode "+this.__count},retractRight:function(a){var b=this.rightMemory,c=b[a.id],e=this.constraint;if(delete b[a.id],c){var g=f(this.rightTuples,c);this.rightTuples.splice(g,1);for(var h,i,j,k=c.blocking,l=this.rightTuples,m=l.length;h=k.pop();){for(h.blocker=null,e.setLeftContext(h),j=g;m>j;j++)if(i=l[j],e.setRightContext(i),e.isMatch()){h.blocker=i,i.blocking.push(h),this.__addToLeftTupleMemory(h);break}h.blocker||(this.__removeFromLeftTupleMemory(h),this.__addToLeftMemory(h).propagateAssert(new d(h.fact,null,h.match)))}e.clearContexts()}},retractLeft:function(a){for(var b,c,d,e=a.id,g=this.allTuples[a.id]||[];g.length;)b=g.pop(),-1!==f(b.factIds,e)&&(this.__removeFromAllTupleMemory(b),this.__removeFromLeftMemory(b),this.__removeFromLeftTupleMemory(b),(d=b.blocker)&&(c=d.blocking,c.splice(f(c,b),1),b.blocker=null));delete this.leftMemory[e],delete this.leftTupleMemory[e],this.propagateRetract(a)},assertLeft:function(a){var b,c=this.rightTuples,e=this.constraint,f=-1,g=c.length;if(0!==g)for(e.setLeftContext(a);++f-1;)b=c[d],e.setLeftContext(b).isMatch()&&(this._propagateRetractResolve(b.match),this.__removeFromLeftMemory(b),b.blocker=a,a.blocking.push(b),this.__addToLeftTupleMemory(b));e.clearContexts()},__removeFromLeftMemory:function(a){for(var b,c=this.leftMemory[a.fact.id]||[],d=this.leftTuples,e=0,g=d.length;g>e;e++)if(b=d[e],b===a){d.splice(e,1),c.splice(f(c,b),1);break}return this},__removeFromLeftTupleMemory:function(a){for(var b,c=this.leftTupleMemory[a.fact.id]||[],d=0,e=c.length;e>d;d++)if(b=c[d],b===a){c.splice(d,1);break}return this},__addToAllTupleMemory:function(a){for(var b,c,d=a.factIds,e=-1,g=d.length,h=this.allTuples;++eg;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("assert",c)},toString:function(){return"PropertyNode"+this.__count}}}).as(b)},{"../context":9,"../extended":11,"./alphaNode":18}],27:[function(a,b){var c=a("./node");c.extend({instance:{retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},propagateAssert:function(a){this.__propagate("assertRight",a)},propagateRetract:function(a){this.__propagate("retractRight",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},modify:function(a){this.__propagate("modifyRight",a)},toString:function(){return"RightAdapterNode "+this.__count}}}).as(b)},{"./node":24}],28:[function(a,b){var c=a("./node"),d=a("../extended"),e=d.bind,f=d.removeDuplicates;c.extend({instance:{constructor:function(a,b,c,d){this._super([]),this.resolve=e(this,this.resolve),this.rule=c,this.index=b,this.name=this.rule.name,this.agenda=d,this.bucket=a,d.register(this)},__assertModify:function(a){var b=a.match;if(b.recency.sort(function(a,b){return a-b}).reverse(),b.facts=f(b.facts),b.isMatch){var c=this.rule,d=this.bucket;this.agenda.insert(this,{rule:c,index:this.index,name:c.name,recency:d.recency++,match:b,counter:d.counter})}},assert:function(a){this.__assertModify(a)},modify:function(a){this.__assertModify(a)},retract:function(a){this.agenda.removeByFact(this,a)},retractRight:function(a){this.agenda.removeByFact(this,a)},retractLeft:function(a){this.agenda.removeByFact(this,a)},assertLeft:function(a){this.__assertModify(a)},assertRight:function(a){this.__assertModify(a)},retractResolve:function(a){var b=this.resolve;this.agenda.retract(this,function(c){return b(c.match,a)})},toString:function(){return"TerminalNode "+this.rule.name}}}).as(b)},{"../extended":11,"./node":24}],29:[function(a,b){var c=a("./alphaNode"),d=a("../context");c.extend({instance:{assert:function(a){this.constraint.assert(a.object)&&this.__propagate("assert",a)},retract:function(a){this.constraint.assert(a.object)&&this.propagateRetract(a)},toString:function(){return"TypeNode"+this.__count},dispose:function(){for(var a=this.__entrySet,b=a.length-1;b>=0;b--){var c=a[b],d=c.key,e=c.value;d.dispose({paths:e})}},__propagate:function(a,b){for(var c=this.__entrySet,e=c.length-1;e>=0;e--){var f=c[e],g=f.key,h=f.value;g[a](new d(b,h))}}}}).as(b)},{"../context":9,"./alphaNode":18}],30:[function(a,b,c){var d=a("__browserify_process"),e=function(){function a(){this.yy={}}var b={trace:function(){},yy:{},symbols_:{error:2,expressions:3,EXPRESSION:4,EOF:5,UNARY_EXPRESSION:6,LITERAL_EXPRESSION:7,"-":8,"!":9,MULTIPLICATIVE_EXPRESSION:10,"*":11,"/":12,"%":13,ADDITIVE_EXPRESSION:14,"+":15,EXPONENT_EXPRESSION:16,"^":17,RELATIONAL_EXPRESSION:18,"<":19,">":20,"<=":21,">=":22,EQUALITY_EXPRESSION:23,"==":24,"!=":25,"=~":26,"!=~":27,IN_EXPRESSION:28,"in":29,ARRAY_EXPRESSION:30,notIn:31,OBJECT_EXPRESSION:32,AND_EXPRESSION:33,"&&":34,OR_EXPRESSION:35,"||":36,ARGUMENT_LIST:37,",":38,IDENTIFIER_EXPRESSION:39,IDENTIFIER:40,".":41,"[":42,STRING_EXPRESSION:43,"]":44,"(":45,")":46,STRING:47,NUMBER_EXPRESSION:48,NUMBER:49,REGEXP_EXPRESSION:50,REGEXP:51,BOOLEAN_EXPRESSION:52,BOOLEAN:53,NULL_EXPRESSION:54,NULL:55,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",45:"(",46:")",47:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"},productions_:[0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,3],[32,4],[43,1],[48,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 3:this.$=[f[g],null,"unary"];break;case 4:this.$=[f[g],null,"logicalNot"];break;case 6:this.$=[f[g-2],f[g],"mult"];break;case 7:this.$=[f[g-2],f[g],"div"];break;case 8:this.$=[f[g-2],f[g],"mod"];break;case 10:this.$=[f[g-2],f[g],"plus"];break;case 11:this.$=[f[g-2],f[g],"minus"];break;case 13:this.$=[f[g-2],f[g],"pow"];break;case 15:this.$=[f[g-2],f[g],"lt"];break;case 16:this.$=[f[g-2],f[g],"gt"];break;case 17:this.$=[f[g-2],f[g],"lte"];break;case 18:this.$=[f[g-2],f[g],"gte"];break;case 20:this.$=[f[g-2],f[g],"eq"];break;case 21:this.$=[f[g-2],f[g],"neq"];break;case 22:this.$=[f[g-2],f[g],"like"];break;case 23:this.$=[f[g-2],f[g],"notLike"];break;case 25:this.$=[f[g-2],f[g],"in"];break;case 26:this.$=[f[g-2],f[g],"notIn"];break;case 27:this.$=[f[g-2],f[g],"in"];break;case 28:this.$=[f[g-2],f[g],"notIn"];break;case 30:this.$=[f[g-2],f[g],"and"];break;case 32:this.$=[f[g-2],f[g],"or"];break;case 34:this.$=[f[g-2],f[g],"arguments"];break;case 35:this.$=[String(a),null,"identifier"];break;case 37:this.$=[f[g-2],f[g],"prop"];break;case 38:this.$=[f[g-3],f[g-1],"propLookup"];break;case 39:this.$=[f[g-3],f[g-1],"propLookup"];break;case 40:this.$=[f[g-2],[null,null,"arguments"],"function"];break;case 41:this.$=[f[g-3],f[g-1],"function"];break;case 42:this.$=[String(a.replace(/^['|"]|['|"]$/g,"")),null,"string"];break;case 43:this.$=[Number(a),null,"number"];break;case 44:this.$=[a,null,"regexp"];break;case 45:this.$=["true"==a.replace(/^\s+/,""),null,"boolean"];break;case 46:this.$=[null,null,"null"];break;case 47:this.$=[null,null,"array"];break;case 48:this.$=[f[g-1],null,"array"];break;case 56:this.$=[f[g-1],null,"composite"]}},table:[{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,57],36:[1,32],46:[2,57]},{5:[2,31],34:[1,33],36:[2,31],46:[2,31]},{5:[2,29],34:[2,29],36:[2,29],46:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],46:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],46:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],46:[2,19]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],46:[2,49]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],46:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],46:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],46:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],46:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],41:[1,44],42:[1,45],44:[2,54],45:[1,46],46:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],44:[2,55],46:[2,55]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],46:[2,14]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],44:[2,42],46:[2,42]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],46:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],46:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],46:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],46:[2,46]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],45:[2,36],46:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],46:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],45:[2,35],46:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],46:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],46:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:76,39:23,40:[1,26],43:75,47:[1,18]},{7:51,30:15,32:14,37:78,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],46:[1,77],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{46:[1,79]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:80,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],46:[2,47]},{38:[1,82],44:[1,81]},{38:[2,33],44:[2,33],46:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:83,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:85,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],46:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],46:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],46:[2,4]},{5:[2,32],34:[1,33],36:[2,32],46:[2,32]},{5:[2,30],34:[2,30],36:[2,30],46:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],46:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],46:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],46:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],46:[2,23]},{5:[2,25],34:[2,25],36:[2,25],46:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],45:[1,46],46:[2,27]},{5:[2,26],34:[2,26],36:[2,26],46:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],45:[1,46],46:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],46:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],46:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],46:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],46:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],45:[2,37],46:[2,37]},{44:[1,88]},{41:[1,44],42:[1,45],44:[1,89],45:[1,46]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],45:[2,40],46:[2,40]},{38:[1,82],46:[1,90]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],46:[2,56]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],46:[2,13]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],46:[2,48]},{7:91,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:[1,16],47:[1,18],48:10,49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],46:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],46:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],46:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],46:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],46:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],45:[2,38],46:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],45:[2,39],46:[2,39]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],45:[2,41],46:[2,41]},{38:[2,34],44:[2,34],46:[2,34]}],defaultActions:{31:[2,1]},parseError:function(a,b){if(!b.recoverable)throw new Error(a);this.trace(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||m,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n);var o=this.lexer.options&&this.lexer.options.ranges;this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var p,q,r,s,t,u,v,w,x,y={};;){if(r=d[d.length-1],this.defaultActions[r]?s=this.defaultActions[r]:((null===p||"undefined"==typeof p)&&(p=b()),s=g[r]&&g[r][p]),"undefined"==typeof s||!s.length||!s[0]){var z="";x=[];for(u in g[r])this.terminals_[u]&&u>l&&x.push("'"+this.terminals_[u]+"'");z=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(i+1)+": Unexpected "+(p==m?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(z,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:n,expected:x})}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:d.push(p),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(s[1]),p=null,q?(p=q,q=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:if(v=this.productions_[s[1]][1],y.$=e[e.length-v],y._$={first_line:f[f.length-(v||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(v||1)].first_column,last_column:f[f.length-1].last_column},o&&(y._$.range=[f[f.length-(v||1)].range[0],f[f.length-1].range[1]]),t=this.performAction.call(y,h,j,i,this.yy,s[1],e,f),"undefined"!=typeof t)return t;v&&(d=d.slice(0,2*-1*v),e=e.slice(0,-1*v),f=f.slice(0,-1*v)),d.push(this.productions_[s[1]][0]),e.push(y.$),f.push(y._$),w=g[d[d.length-2]][d[d.length-1]],d.push(w);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c; -if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;fb[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1?a:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){switch(c){case 0:return 29;case 1:return 31;case 2:return"from";case 3:return 24;case 4:return 25;case 5:return 21;case 6:return 19;case 7:return 22;case 8:return 20;case 9:return 26;case 10:return 27;case 11:return 34;case 12:return 36;case 13:return 55;case 14:return 53;case 15:break;case 16:return 49;case 17:return 47;case 18:return 47;case 19:return 40;case 20:return 51;case 21:return 41;case 22:return 11;case 23:return 12;case 24:return 13;case 25:return 38;case 26:return 8;case 27:return 26;case 28:return 27;case 29:return 24;case 30:return 24;case 31:return 25;case 32:return 25;case 33:return 21;case 34:return 22;case 35:return 20;case 36:return 19;case 37:return 34;case 38:return 36;case 39:return 15;case 40:return 17;case 41:return 45;case 42:return 44;case 43:return 42;case 44:return 46;case 45:return 9;case 46:return 5}},rules:[/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s+null\b)/,/^(?:\s+(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:==)/,/^(?:===)/,/^(?:!=)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();"undefined"!=typeof a&&"undefined"!=typeof c&&(c.parser=e,c.Parser=e.Parser,c.parse=function(){return e.parse.apply(e,arguments)},c.main=function(b){b[1]||(console.log("Usage: "+b[0]+" FILE"),d.exit(1));var e=a("fs").readFileSync(a("path").normalize(b[1]),"utf8");return c.parser.parse(e)},"undefined"!=typeof b&&a.main===b&&c.main(d.argv.slice(1)))},{__browserify_process:51,fs:48,path:49}],31:[function(a,b,c){!function(){"use strict";var b=a("./constraint/parser"),d=a("./nools/nool.parser");c.parseConstraint=function(a){try{return b.parse(a)}catch(c){throw new Error("Invalid expression '"+a+"'")}},c.parseRuleSet=function(a,b){return d.parse(a,b)}}()},{"./constraint/parser":30,"./nools/nool.parser":32}],32:[function(a,b,c){"use strict";var d=a("./tokens.js"),e=a("../../extended"),f=e.hash.keys,g=a("./util.js"),h=function(a,b,c){var d=a;a=a.replace(/\/\/(.*)[\n|\r|\r\n]/g,"").replace(/\n|\r|\r\n/g," ");for(var e,i=new RegExp("^("+f(b).join("|")+")");a&&-1!==(e=g.findNextTokenIndex(a));){a=a.substr(e);var j=a.match(i);if(null===j)throw new Error("Error parsing "+a);if(j=j[1],!(j in b))throw new Error("Unknown token"+j);try{a=b[j](a,c,h).replace(/^\s*|\s*$/g,"")}catch(k){throw new Error("Invalid "+j+" definition \n"+k.message+"; \nstarting at : "+d)}}};c.parse=function(a,b){var c={define:[],rules:[],scope:[],loaded:[],file:b};return h(a,d,c),c}},{"../../extended":11,"./tokens.js":33,"./util.js":34}],33:[function(require,module,exports){var process=require("__browserify_process"),utils=require("./util.js"),fs=require("fs"),indexOf=require("../../extended").indexOf,isWhiteSpace=function(a){return 0===a.replace(/[\s|\n|\r|\t]/g,"").length},ruleTokens={salience:function(){var a=/^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=parseInt(d[2],10);if(isNaN(e))throw new Error("Invalid salience/priority "+d[2]);return c.options.priority=e,b.replace(d[0],"")}throw new Error("invalid format")}}(),agendaGroup:function(){var a=/^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid agenda-group "+d[2]);return c.options.agendaGroup=e.replace(/^["']|["']$/g,""),b.replace(d[0],"")}throw new Error("invalid format")}}(),autoFocus:function(){var a=/^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid auto-focus "+d[2]);return c.options.autoFocus="true"===e?!0:!1,b.replace(d[0],"")}throw new Error("invalid format")}}(),"agenda-group":function(){return this.agendaGroup.apply(this,arguments)},"auto-focus":function(){return this.autoFocus.apply(this,arguments)},priority:function(){return this.salience.apply(this,arguments)},when:function(){var ruleRegExp=/^(\$?\w+) *: *(\w+)(.*)/,joinFunc=function(a,b){return"; "+b},constraintRegExp=/(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/,predicateExp=/^(\w+) *\((.*)\)$/m,parseRules=function(str){for(var rules=[],ruleLines=str.split(";"),l=ruleLines.length,ruleLine,i=0;l>i&&(ruleLine=ruleLines[i].replace(/^\s*|\s*$/g,"").replace(/\n/g,""));i++)if(!isWhiteSpace(ruleLine)){var rule=[];if(predicateExp.test(ruleLine)){var m=ruleLine.match(predicateExp),pred=m[1].replace(/^\s*|\s*$/g,"");if(rule.push(pred),ruleLine=m[2].replace(/^\s*|\s*$/g,""),"or"===pred){rule=rule.concat(parseRules(ruleLine.replace(/,\s*(\$?\w+\s*:)/g,joinFunc))),rules.push(rule);continue}}var parts=ruleLine.match(ruleRegExp);if(!parts||!parts.length)throw new Error("Invalid constraint "+ruleLine);rule.push(parts[2],parts[1]);var constraints=parts[3].replace(/^\s*|\s*$/g,""),hashParts=constraints.match(constraintRegExp);if(hashParts){var hash=hashParts[1],constraint=constraints.replace(hash,"");constraint&&rule.push(constraint.replace(/^\s*|\s*$/g,"")),hash&&rule.push(eval("("+hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g,'"$1" : "$2"')+")"))}else constraints&&!isWhiteSpace(constraints)&&rule.push(constraints);rules.push(rule)}return rules};return function(a,b){var c=a.replace(/^when\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(d,""),b.constraints=parseRules(d.replace(/^\{\s*|\}\s*$/g,"")),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}(),then:function(){return function(a,b){if(b.action)throw new Error("action already defined for rule"+b.name);var c=a.replace(/^then\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");if(c=c.replace(d,""),b.action||(b.action=d.replace(/^\{\s*|\}\s*$/g,"")),!isWhiteSpace(c))throw new Error("Error parsing then block "+a);return c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}()},topLevelTokens={"/":function(a){return a.match(/^\/\*/)?a.replace(/\/\*.*?\*\//,""):a},define:function(a,b){var c=a.replace(/^define\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){d=d[1];var e=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(e,""),b.define.push({name:d,properties:"("+e+")"}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"import":function(a,b,c){if("undefined"!=typeof window)throw new Error("import cannot be used in a browser");var d=a.replace(/^import\s*/,"");if("("===utils.findNextToken(d)){var e=utils.getParamList(d);if(d=d.replace(e,"").replace(/^\s*|\s*$/g,""),";"===utils.findNextToken(d)&&(d=d.replace(/\s*;/,"")),e=e.replace(/[\(|\)]/g,"").split(","),1===e.length){if(e=utils.resolve(b.file||process.cwd(),e[0].replace(/["|']/g,"")),-1===indexOf(b.loaded,e)){var f=b.file;b.file=e,c(fs.readFileSync(e,"utf8"),topLevelTokens,b),b.loaded.push(e),b.file=f}return d}throw new Error("import accepts a single file")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(d)+"'")},global:function(a,b){var c=a.replace(/^global\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"="===utils.findNextToken(c)){d=d[1].replace(/^\s+|\s+$/g,"");var e=utils.getTokensBetween(c,"=",";",!0).join(""),f=e.substring(1,e.length-1);if(f=f.replace(/^\s+|\s+$/g,""),/^require\(/.test(f)){var g=utils.getParamList(f.replace("require")).replace(/[\(|\)]/g,"").split(",");1===g.length&&(g=g[0].replace(/["|']/g,""),f=["require('",utils.resolve(b.file||process.cwd(),g),"')"].join(""))}return b.scope.push({name:d,body:f}),c=c.replace(e,"")}throw new Error("unexpected token : expected : '=' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"function":function(a,b){var c=a.replace(/^function\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);if(d){if(c=c.replace(d[0],""),"("===utils.findNextToken(c)){d=d[1];var e=utils.getParamList(c);if(c=c.replace(e,"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){var f=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(f,""),b.scope.push({name:d,body:"function"+e+f}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},rule:function(a,b,c){var d=a.replace(/^rule\s*/,""),e=d.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);if(e){if(d=d.replace(e[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(d)){e=e[1].replace(/^["']|["']$/g,"");var f={name:e,options:{},constraints:null,action:null},g=utils.getTokensBetween(d,"{","}",!0).join("");return d=d.replace(g,""),c(g.replace(/^\{\s*|\}\s*$/g,""),ruleTokens,f),b.rules.push(f),d}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(d)+"'")}throw new Error("missing name")}};module.exports=topLevelTokens},{"../../extended":11,"./util.js":34,__browserify_process:51,fs:48}],34:[function(a,b,c){var d=a("__browserify_process"),e=a("path"),f=/[\s|\n|\r|\t]/,g=e.sep||("win32"===d.platform?"\\":"/"),h={"{":"}","}":"{","(":")",")":"(","[":"]"},i=c.getTokensBetween=function(a,b,c,d){var e=0,f=[];b||(b=h[c],e=1),c||(c=h[b]),a=Object(a);for(var g,i=!1,j=0,k=!1;g=a.charAt(j++);)if(g===b)e++,i?f.push(g):(i=!0,d&&f.push(g));else if(g===c&&j){if(e--,0===e){d&&f.push(g),k=!0;break}f.push(g)}else i&&f.push(g);if(!k)throw new Error("Unable to match "+b+" in "+a);return f};c.getParamList=function(a){return i(a,"(",")",!0).join("")},c.resolve=function(a,b){return""!==e.extname(a)&&(a=e.dirname(a)),1===b.split(g).length?b:e.resolve(a,b)};var j=c.findNextTokenIndex=function(a,b,c){b=b||0,c=c||a.length;var d=-1,e=a.length;for((!c||c>e)&&(c=e);c>b;b++){var g=a.charAt(b);if(!f.test(g)){d=b;break}}return d};c.findNextToken=function(a,b,c){return a.charAt(j(a,b,c))}},{__browserify_process:51,path:49}],35:[function(a,b,c){!function(){"use strict";var b=a("./extended"),d=b.merge,e=b.forEach,f=b.declare,g=a("./constraintMatcher"),h=a("./constraint"),i=f({}),j=i.extend({instance:{constructor:function(a,c,f,i,j){j=j||{},this.type=a,this.alias=c,this.conditions=f,this.pattern=j.pattern,this.constraints=[new h.ObjectConstraint(a)];var k=g.toConstraints(f,d({alias:c},j));if(k.length)this.constraints=this.constraints.concat(k);else{var l=new h.TrueConstraint;this.constraints.push(l)}if(i&&!b.isEmpty(i)){var m=new h.HashConstraint(i);this.constraints.push(m)}e(this.constraints,function(a){a.set("alias",c)})},hasConstraint:function(a){return b.some(this.constraints,function(b){return b instanceof a})},hashCode:function(){return[this.type,this.alias,b.format("%j",this.conditions)].join(":")},toString:function(){return b.format("%j",this.constraints)}}}).as(c,"ObjectPattern");j.extend().as(c,"NotPattern"),i.extend({instance:{constructor:function(a,b){this.leftPattern=a,this.rightPattern=b},hashCode:function(){return[this.leftPattern.hashCode(),this.rightPattern.hashCode()].join(":")},getters:{constraints:function(){return this.leftPattern.constraints.concat(this.rightPattern.constraints)}}}}).as(c,"CompositePattern");var k=f({}).as(c,"InitialFact");j.extend({instance:{constructor:function(){this._super([k,"i",[],{}])},assert:function(){return!0}}}).as(c,"InitialFactPattern")}()},{"./constraint":7,"./constraintMatcher":8,"./extended":11}],36:[function(a,b,c){"use strict";function d(a,b,c,d){e.isArray(b)?(d=c,c=b):b=b||{};var g=e.every(c,function(a){return f(a)});g&&1===c.length&&(c=c[0],g=!1);var h=[],i=b.scope||{};if(c.scope=i,g){for(var j,k=function(a,b){n[b]?e(n).forEach(function(b){b.push(a)}):(n[b]=0===b?[]:n[b-1].slice(),0!==b&&n[b].pop(),n[b].push(a))},l=c.length,n=[],o=0;l>o;o++)j=c[o],j.scope=i,e.forEach(p(j),k);h=e.map(n,function(c){for(var e=null,f=0;f>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.arrayExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":38,extended:43,"is-extended":53}],40:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c,d){a=""+a,c=c||" ";for(var e=a.length;b>e;)d?a+=c:a=c+a,e++;return a}function e(a,c,d){var f=a;if(b.isString(f)){if(a.length>c)if(d){var g=a.length;f=a.substring(g-c,g)}else f=a.substring(0,c)}else f=e(""+f,c);return f}function f(a,c,d){if(!b.isArray(a)||"function"!=typeof c)throw new TypeError;for(var e=Object(a),f=e.length>>>0,g=0;f>g;g++)if(g in e&&!c.call(d,e[g],g,e))return!1;return!0}function g(a,b){return A.difference(new Date(a.getFullYear(),0,1,a.getHours()),a,null,b)+1}function h(a,b,c){b=b||0;var d=a[c?"getUTCFullYear":"getFullYear"](),e=new Date(d,0,1).getDay(),f=(e-b+7)%7,h=o((g(a)+f-1)/7);return e===b&&h++,h}function i(a){var b=a.toString(),c="",d=b.indexOf("(");return d>-1&&(c=b.substring(++d,b.indexOf(")"))),c}function j(a,b){return a.replace(/([a-z])\1*/gi,function(a){var c,d=a.charAt(0),e=a.length,f="0?",g="0{0,2}";if("y"===d)c="\\d{2,4}";else if("M"===d)c=e>2?"\\S+?":"1[0-2]|"+f+"[1-9]";else if("D"===d)c="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+g+"[1-9][0-9]|"+f+"[1-9]";else if("d"===d)c="3[01]|[12]\\d|"+f+"[1-9]";else if("w"===d)c="[1-4][0-9]|5[0-3]|"+f+"[1-9]";else if("E"===d)c="\\S+";else if("h"===d)c="1[0-2]|"+f+"[1-9]";else if("K"===d)c="1[01]|"+f+"\\d";else if("H"===d)c="1\\d|2[0-3]|"+f+"\\d";else if("k"===d)c="1\\d|2[0-4]|"+f+"[1-9]";else if("m"===d||"s"===d)c="[0-5]\\d";else if("S"===d)c="\\d{"+e+"}";else if("a"===d){var h="AM",i="PM";c=h+"|"+i,h!==h.toLowerCase()&&(c+="|"+h.toLowerCase()),i!==i.toLowerCase()&&(c+="|"+i.toLowerCase()),c=c.replace(/\./g,"\\.")}else c="v"===d||"z"===d||"Z"===d||"G"===d||"q"===d||"Q"===d?".*":" "===d?"\\s*":d+"*";return b&&b.push(a),"("+c+")"}).replace(/[\xa0 ]/g,"[\\s\\xa0]")}function k(a){B[a+"sFromNow"]=function(b){return A.add(new Date,a,b)},B[a+"sAgo"]=function(b){return A.add(new Date,a,-b)}}for(var l=function(){function a(a,b,c){return a=a.replace(/s$/,""),e.hasOwnProperty(a)?e[a](b,c):[c,"UTC"+a.charAt(0).toUpperCase()+a.substring(1)+"s",!1]}function b(a,b,c,e){return a=a.replace(/s$/,""),d(f[a](b,c,e))}var c=Math.floor,d=Math.round,e={day:function(a,b){return[b,"Date",!1]},weekday:function(a,b){var c,d,e=b%5,f=a.getDay(),g=0;e?(c=e,d=parseInt(b/5,10)):(c=b>0?5:-5,d=b>0?(b-5)/5:(b+5)/5),6===f&&b>0?g=1:0===f&&0>b&&(g=-1);var h=f+c;return(0===h||6===h)&&(g=b>0?2:-2),[7*d+c+g,"Date",!1]},year:function(a,b){return[b,"FullYear",!0]},week:function(a,b){return[7*b,"Date",!1]},quarter:function(a,b){return[3*b,"Month",!0]},month:function(a,b){return[b,"Month",!0]}},f={quarter:function(a,b,d){var e=b.getFullYear()-a.getFullYear(),f=a[d?"getUTCMonth":"getMonth"](),g=b[d?"getUTCMonth":"getMonth"](),h=c(f/3)+1,i=c(g/3)+1;return i+=4*e,i-h},weekday:function(a,c,d){var e,f=b("day",a,c,d),g=f%7;if(0===g)f=5*b("week",a,c,d);else{var h=0,i=a[d?"getUTCDay":"getDay"](),j=c[d?"getUTCDay":"getDay"]();e=parseInt(f/7,10);var k=new Date(+a);k.setDate(k[d?"getUTCDate":"getDate"]()+7*e);var l=k[d?"getUTCDay":"getDay"]();f>0?6===i||6===j?h=-1:0===i?h=0:(0===j||l+g>5)&&(h=-2):0>f&&(6===i?h=0:0===i||0===j?h=1:(6===j||0>l+g)&&(h=2)),f+=h,f-=2*e}return f},year:function(a,b){return b.getFullYear()-a.getFullYear()},month:function(a,b,c){var d=a[c?"getUTCMonth":"getMonth"](),e=b[c?"getUTCMonth":"getMonth"]();return e-d+12*(b.getFullYear()-a.getFullYear())},week:function(a,c,e){return d(b("day",a,c,e)/7)},day:function(a,b){return 1.1574074074074074e-8*(b.getTime()-a.getTime())},hour:function(a,b){return 2.7777777777777776e-7*(b.getTime()-a.getTime())},minute:function(a,b){return 16666666666666667e-21*(b.getTime()-a.getTime())},second:function(a,b){return.001*(b.getTime()-a.getTime())},millisecond:function(a,b){return b.getTime()-a.getTime()}};return{addTransform:a,differenceTransform:b}}(),m=l.addTransform,n=l.differenceTransform,o=Math.floor,p=Math.round,q=Math.min,r=Math.pow,s=Math.ceil,t=Math.abs,u=["January","February","March","April","May","June","July","August","September","October","November","December"],v=["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y=["Before Christ","Anno Domini"],z=["BC","AD"],A={getDaysInMonth:function(a){var b=a.getMonth(),c=[31,28,31,30,31,30,31,31,30,31,30,31];return 1===b&&A.isLeapYear(a)?29:c[b]},isLeapYear:function(a,b){var c=a[b?"getUTCFullYear":"getFullYear"]();return 0===c%400||0===c%4&&0!==c%100},isWeekend:function(a,b){var c=(a||new Date)[b?"getUTCDay":"getDay"]();return 0===c||6===c},getTimezoneName:i,compare:function(a,b,c){return a=new Date(+a),b=new Date(+(b||new Date)),"date"===c?(a.setHours(0,0,0,0),b.setHours(0,0,0,0)):"time"===c&&(a.setFullYear(0,0,0),b.setFullYear(0,0,0)),a>b?1:b>a?-1:0},add:function(a,b,c){var d=m(b,a,c||0);c=d[0];var e=d[1],f=new Date(+a),g=d[2];return e&&f["set"+e](f["get"+e]()+c),g&&f.getDate()E?z:y)[0>f?0:1];else if("y"===D)B=f,E>1&&(2===E?B=e(""+B,2,!0):C=!0);else if("Q"===D.toUpperCase())B=s((j+1)/3),C=!0;else if("M"===D)3>E?(B=j+1,C=!0):B=(3===E?v:u)[j];else if("w"===D)B=h(a,0,c),C=!0;else if("D"===D)B=g(a,c),C=!0;else if("E"===D)3>E?(B=k+1,C=!0):B=(-3===E?x:w)[k];else if("a"===D)B=12>m?"AM":"PM";else if("h"===D)B=m%12||12,C=!0;else if("K"===D)B=m%12,C=!0;else if("k"===D)B=m||24,C=!0;else if("S"===D)B=p(A*r(10,E-3)),C=!0;else if("z"===D||"v"===D||"Z"===D){if(B=i(a),"z"!==D&&"v"!==D||B||(E=4),!B||"Z"===D){var F=a.getTimezoneOffset(),G=[F>=0?"-":"+",d(o(t(F)/60),2,"0"),d(t(F)%60,2,"0")];4===E&&(G.splice(0,0,"GMT"),G.splice(3,0,":")),B=G.join("")}}else B=b;else B=""+n,C=!0;else B=""+m,C=!0;return C&&(B=d(B,E,"0")),B})}},B={},C=["year","month","day","hour","minute","second"],D=0,E=C.length;E>D;D++)k(C[D]);var F={parseDate:function(a,b){if(!b)throw new Error("format required when calling dateExtender.parse");var d=[],e=j(b,d),g=new RegExp("^"+e+"$","i"),h=g.exec(a);if(!h)return null;var i=[1970,0,1,0,0,0,0],k="",l=f(h,function(a,b){if(b){var e=d[b-1],f=e.length,g=e.charAt(0);if("y"===g)if(100>a){a=parseInt(a,10);var h=""+(new Date).getFullYear(),j=100*h.substring(0,2),l=q(h.substring(2,4)+20,99);i[0]=l>a?j+a:j-100+a}else i[0]=a;else if("M"===g){if(f>2){var m,n,o=u;3===f&&(o=v),a=a.replace(".","").toLowerCase();var p=!1;for(m=0,n=o.length;n>m&&!p;m++){var r=o[m].replace(".","").toLocaleLowerCase();r===a&&(a=m,p=!0)}if(!p)return!1}else a--;i[1]=a}else if("E"===g||"e"===g){var s=w;3===f&&(s=x),a=a.toLowerCase(),s=c.map(s,function(a){return a.toLowerCase()});var t=c.indexOf(s,a);if(-1===t){if(a=parseInt(a,10),isNaN(a)||a>s.length)return!1}else a=t}else if("D"===g||"d"===g)"D"===g&&(i[1]=0),i[2]=a;else if("a"===g){var y="am",z="pm",A=/\./g;a=a.replace(A,"").toLowerCase(),k=a===z?"p":a===y?"a":""}else"k"===g||"h"===g||"H"===g||"K"===g?("k"===g&&24===+a&&(a=0),i[3]=a):"m"===g?i[4]=a:"s"===g?i[5]=a:"S"===g&&(i[6]=a)}return!0});if(l){var m=+i[3];"p"===k&&12>m?i[3]=m+12:"a"===k&&12===m&&(i[3]=0);var n=new Date(i[0],i[1],i[2],i[3],i[4],i[5],i[6]),o=-1!==c.indexOf(d,"d"),p=-1!==c.indexOf(d,"M"),r=i[1],s=i[2],t=n.getMonth(),y=n.getDate();return p&&t>r||o&&y>s?null:n}return null}},G=a.define(b.isDate,A).define(b.isString,F).define(b.isNumber,B);for(D in A)A.hasOwnProperty(D)&&(G[D]=A[D]);for(D in F)F.hasOwnProperty(D)&&(G[D]=F[D]);for(D in B)B.hasOwnProperty(D)&&(G[D]=B[D]);return G}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.dateExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":39,extended:43,"is-extended":53}],41:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b) -}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){switch(arguments.length){case 0:this.constructor.call(this);break;case 1:this.constructor.call(this,arguments[0]);break;case 2:this.constructor.call(this,arguments[0],arguments[1]);break;case 3:this.constructor.call(this,arguments[0],arguments[1],arguments[2]);break;default:this.constructor.apply(this,arguments)}}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],42:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":41}],43:[function(a,b,c){!function(){"use strict";function d(a){function b(){var b=a.define();return b.expose({register:function(a,c){c||(c=a,a=null);var d=typeof c;if(a)b[a]=c;else if(c&&"function"===d)b.extend(c);else{if("object"!==d)throw new TypeError("extended.register must be called with an extender function");b.expose(c)}return b},define:function(){return a.define.apply(a,arguments)}}),b}function c(){return b()}return function(){function a(a,b){var c,d;for(c in b)b.hasOwnProperty(c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}return function(b){b||(b={});for(var c=1,d=arguments.length;d>c;c++)a(b,arguments[c]);return b}}(),c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}.call(this)},{extender:45}],44:[function(a,b,c){!function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}.call(this)},{"declare.js":42}],45:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":44}],46:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c){if(c=o(arguments,2),m(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!m(b)&&!n(b))throw new Error(b+" is not a function");return m(b)?function(){var d=a[b];if(n(d)){var e=c.concat(o(arguments));return d.apply(a,e)}return d}:c.length?function(){var d=c.concat(o(arguments));return b.apply(a,d)}:function(){return b.apply(a,arguments)}}function e(a,b){if(b=o(arguments,1),!m(a)&&!n(a))throw new Error(a+" must be the name of a property or function to execute");return m(a)?function(){var c=o(arguments),d=c.shift(),e=d[a];return n(e)?(c=b.concat(c),e.apply(d,c)):e}:function(){var c=o(arguments),d=c.shift();return c=b.concat(c),a.apply(d,c)}}function f(a,b,c){if(c=o(arguments,2),m(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!m(b)&&!n(b))throw new Error(b+" is not a function");return m(b)?function(){var d=a[b];return n(d)?d.apply(a,c):d}:function(){return b.apply(a,c)}}function g(a){var b=o(arguments,1);if(!l(a)&&!n(a))throw new TypeError("scope must be an object");if(1===b.length&&k(b[0])&&(b=b[0]),!b.length){b=[];for(var c in a)a.hasOwnProperty(c)&&n(a[c])&&b.push(c)}for(var e=0,f=b.length;f>e;e++)a[b[e]]=d(a,a[b[e]]);return a}function h(a,b){if(b=o(arguments,1),!m(a)&&!n(a))throw new Error(a+" must be the name of a property or function to execute");return m(a)?function(){var c=this[a];if(n(c)){var d=b.concat(o(arguments));return c.apply(this,d)}return c}:function(){var c=b.concat(o(arguments));return a.apply(this,c)}}function i(a,b){return function(){var c=o(arguments);return b?a.apply(this,arguments):function(){return a.apply(this,c.concat(o(arguments)))}}}function j(a,b,c){var e;if(e=c?d(c,b):b,a)for(var f=a-1,g=f;g>=0;g--)e=i(e,g===f);return e}var k=b.isArray,l=b.isObject,m=b.isString,n=b.isFunction,o=c.argsToArray;return a.define(l,{bind:d,bindAll:g,bindIgnore:f,curry:function(a,b,c){return j(b,c,a)}}).define(n,{bind:function(a,b){return d.apply(this,[b,a].concat(o(arguments,2)))},bindIgnore:function(a,b){return f.apply(this,[b,a].concat(o(arguments,2)))},partial:h,applyFirst:e,curry:function(a,b,c){return j(b,a,c)},noWrap:{f:function(){return this.value()}}}).define(m,{bind:function(a,b){return d(b,a)},bindIgnore:function(a,b){return f(b,a)},partial:h,applyFirst:e,curry:function(a,b,c){return j(b,a,c)}}).expose({bind:d,bindAll:g,bindIgnore:f,partial:h,applyFirst:e,curry:j})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.functionExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":38,extended:43,"is-extended":53}],47:[function(a,b,c){function d(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;ce;e++)d[e].apply(this,c);return!0}return!1},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var e=d(c,b);if(0>e)return this;c.splice(e,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},f.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0}},{__browserify_process:51}],48:[function(){},{}],49:[function(a,b,c){function d(a,b){for(var c=[],d=0;d=0;d--){var e=a[d];"."==e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var f=a("__browserify_process"),g=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){for(var a="",b=!1,c=arguments.length;c>=-1&&!b;c--){var g=c>=0?arguments[c]:f.cwd();"string"==typeof g&&g&&(a=g+"/"+a,b="/"===g.charAt(0))}return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b="/"===a.charAt(0),c="/"===a.slice(-1);return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){return a&&"string"==typeof a}).join("/"))},c.dirname=function(a){var b=g.exec(a)[1]||"",c=!1;return b?1===b.length||c&&b.length<=3&&":"===b.charAt(1)?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=g.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return g.exec(a)[3]||""},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i=0;e--)if(f[e]!=g[e])return!1;for(e=f.length-1;e>=0;e--)if(d=f[e],!h(a[d],b[d]))return!1;return!0}function l(a,b){return a&&b?b instanceof RegExp?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function m(a,b,c,d){var e;"string"==typeof c&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f("Missing expected exception"+d),!a&&l(e,c)&&f("Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util"),o=a("buffer").Buffer,p=Array.prototype.slice,q=b.exports=g;q.AssertionError=function(a){this.name="AssertionError",this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var b=a.stackStartFunction||f;Error.captureStackTrace&&Error.captureStackTrace(this,b)},n.inherits(q.AssertionError,Error),q.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",e(JSON.stringify(this.actual,d),128),this.operator,e(JSON.stringify(this.expected,d),128)].join(" ")},q.AssertionError.__proto__=Error.prototype,q.fail=f,q.ok=g,q.equal=function(a,b,c){a!=b&&f(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",q.notStrictEqual)},q.throws=function(){m.apply(this,[!0].concat(p.call(arguments)))},q.doesNotThrow=function(){m.apply(this,[!1].concat(p.call(arguments)))},q.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(a,b,c){function d(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&d(a.__proto__)}function e(a){return a instanceof RegExp||"object"==typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function f(a){if(a instanceof Date)return!0;if("object"!=typeof a)return!1;var b=Date.prototype&&h(Date.prototype),c=a.__proto__&&h(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}a("events"),c.isArray=d,c.isDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,i,j){function k(a,i){if(a&&"function"==typeof a.inspect&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(i);switch(typeof a){case"undefined":return m("undefined","undefined");case"string":var j="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return m(j,"string");case"number":return m(""+a,"number");case"boolean":return m(""+a,"boolean")}if(null===a)return m("null","null");var n=g(a),o=b?h(a):n;if("function"==typeof a&&0===o.length){if(e(a))return m(""+a,"regexp");var p=a.name?": "+a.name:"";return m("[Function"+p+"]","special")}if(f(a)&&0===o.length)return m(a.toUTCString(),"date");var q,r,s;if(d(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]),"function"==typeof a){var t=a.name?": "+a.name:"";q=e(a)?" "+a:" [Function"+t+"]"}else q="";if(f(a)&&(q=" "+a.toUTCString()),0===o.length)return s[0]+q+s[1];if(0>i)return e(a)?m(""+a,"regexp"):m("[Object]","special");l.push(a);var u=o.map(function(b){var c,e;if(a.__lookupGetter__&&(a.__lookupGetter__(b)?e=a.__lookupSetter__(b)?m("[Getter/Setter]","special"):m("[Getter]","special"):a.__lookupSetter__(b)&&(e=m("[Setter]","special"))),n.indexOf(b)<0&&(c="["+b+"]"),e||(l.indexOf(a[b])<0?(e=null===i?k(a[b]):k(a[b],i-1),e.indexOf("\n")>-1&&(e=d(a)?e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=m("[Circular]","special")),"undefined"==typeof c){if("Array"===r&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=m(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=m(c,"string"))}return c+": "+e});l.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return u=w>50?s[0]+(""===q?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:s[0]+q+" "+u.join(", ")+" "+s[1]}var l=[],m=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return j||(m=function(a){return a}),k(a,"undefined"==typeof i?2:i)},c.log=function(){},c.pump=null;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},i=Object.create||function(a,b){var c;if(null===a)c={__proto__:null};else{if("object"!=typeof a)throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return"undefined"!=typeof b&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=i(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})};var j=/%[sdj%]/g;c.format=function(a){if("string"!=typeof a){for(var b=[],d=0;d=f)return a;switch(a){case"%s":return String(e[d++]);case"%d":return Number(e[d++]);case"%j":return JSON.stringify(e[d++]);default:return a}}),h=e[d];f>d;h=e[++d])g+=null===h||"object"!=typeof h?" "+h:" "+c.inspect(h);return g}},{events:4}],5:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],6:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(a,b,c){!function(a){function b(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;cf;f++)d[f].apply(this,c);return!0}return!1},d.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(e(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:f,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},d.prototype.removeListener=function(a,c){if("function"!=typeof c)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var d=this._events[a];if(e(d)){var f=b(d,c);if(0>f)return this;d.splice(f,1),0==d.length&&delete this._events[a]}else this._events[a]===c&&delete this._events[a];return this},d.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},d.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),e(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(a,b){b.exports=a("q9TxCC")},{}],q9TxCC:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used=a.length?0:(c?(e=a.parent[a.offset+b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8*(d?1-f:f)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>8*(d?3-f:f)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fthis.length)throw new Error("oob");if(b>c)throw new Error("oob");for(var d=b;c>d;d++)this[d]=a},c.SlowBuffer=d,c.Buffer=l,l.poolSize=8192;var E;l.isBuffer=function(a){return a instanceof l||a instanceof d},l.concat=function(a,b){if(!Array.isArray(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new l(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;cd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=c.length?void 0:c.parent[c.offset+a]},l.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},l.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},l.prototype.readUInt32LE=function(a,b){return p(this,a,!1,b)},l.prototype.readUInt32BE=function(a,b){return p(this,a,!0,b)},l.prototype.readInt8=function(a,b){var c,d=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=d.length?void 0:(c=128&d.parent[d.offset+a],c?-1*(255-d.parent[d.offset+a]+1):d.parent[d.offset+a])},l.prototype.readInt16LE=function(a,b){return q(this,a,!1,b)},l.prototype.readInt16BE=function(a,b){return q(this,a,!0,b)},l.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},l.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},l.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},l.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},l.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},l.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},l.prototype.writeUInt8=function(a,b,c){var d=this;c||(D.ok(void 0!==a&&null!==a,"missing value"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],8:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],3:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used>>0):(e=a.parent[a.offset+b+2]<<16,e|=a.parent[a.offset+b+1]<<8,e|=a.parent[a.offset+b],e+=a.parent[a.offset+b+3]<<24>>>0),e}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8,a.parent[a.offset+c+1]=255&b):(a.parent[a.offset+c+1]=(65280&b)>>>8,a.parent[a.offset+c]=255&b)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>24,a.parent[a.offset+c+1]=255&b>>>16,a.parent[a.offset+c+2]=255&b>>>8,a.parent[a.offset+c+3]=255&b):(a.parent[a.offset+c+3]=255&b>>>24,a.parent[a.offset+c+2]=255&b>>>16,a.parent[a.offset+c+1]=255&b>>>8,a.parent[a.offset+c]=255&b)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}]},{},[]),b.exports=a("buffer-browserify")},{}],51:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener; -if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],52:[function(a,b,c){!function(){"use strict";function d(a){var b=function(a){return"string"==typeof a?a:"object"==typeof a?a.hashCode?a.hashCode():""+a:""+a},c=a.declare({instance:{constructor:function(){this.__entries=[],this.__keys=[],this.__values=[]},pushValue:function(a,b){return this.__keys.push(a),this.__values.push(b),this.__entries.push({key:a,value:b}),b},remove:function(a){for(var b,c=null,d=this.__entries,e=this.__keys,f=this.__values,g=d.length-1;g>=0;g--)if((b=d[g])&&b.key===a)return d.splice(g,1),e.splice(g,1),f.splice(g,1),b.value;return c},set:function(a,b){for(var c=null,d=this.__entries,e=this.__values,f=d.length-1;f>=0;f--){var g=d[f];if(g&&a===g.key){e[f]=b,g.value=b,c=b;break}}return c||d.push({key:a,value:b}),c},find:function(a){for(var b,c=null,d=this.__entries,e=d.length-1;e>=0;e--)if(b=d[e],b&&a===b.key){c=b.value;break}return c},getEntrySet:function(){return this.__entries},getKeys:function(){return this.__keys},getValues:function(){return this.__values}}});return a.declare({instance:{constructor:function(){this.__map={}},entrySet:function(){var a=[],b=this.__map;for(var c in b)b.hasOwnProperty(c)&&(a=a.concat(b[c].getEntrySet()));return a},put:function(a,d){var e=b(a),f=null;return(f=this.__map[e])||(f=this.__map[e]=new c),f.pushValue(a,d),d},remove:function(a){var c=b(a),d=null,e=this.__map[c];return e&&(d=e.remove(a)),d},get:function(a){var c,d=b(a),e=null;return(c=this.__map[d])&&(e=c.find(a)),e},set:function(a,d){var e=b(a),f=null,g=null,h=this.__map;return f=(g=h[e])?g.set(a,d):(h[e]=new c).pushValue(a,d)},contains:function(a){var c=b(a),d=!1,e=null;return(e=this.__map[c])&&(d=!!e.find(a)),d},concat:function(a){if(a instanceof this._static){for(var b=new this._static,c=a.entrySet().concat(this.entrySet()),d=c.length-1;d>=0;d--){var e=c[d];b.put(e.key,e.value)}return b}throw new TypeError("When joining hashtables the joining arg must be a HashTable")},filter:function(b,c){var d=this.entrySet(),e=new this._static;d=a.filter(d,b,c);for(var f=d.length-1;f>=0;f--){var g=d[f];e.put(g.key,g.value)}return e},forEach:function(b,c){var d=this.entrySet();a.forEach(d,b,c)},every:function(b,c){var d=this.entrySet();return a.every(d,b,c)},map:function(b,c){var d=this.entrySet();return a.map(d,b,c)},some:function(b,c){var d=this.entrySet();return a.some(d,b,c)},reduce:function(b,c){var d=this.entrySet();return a.reduce(d,b,c)},reduceRight:function(b,c){var d=this.entrySet();return a.reduceRight(d,b,c)},clear:function(){this.__map={}},keys:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getKeys());return a},values:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getValues());return a},isEmpty:function(){return 0===this.keys().length}}})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")))):"function"==typeof define?define(["extended","declare","is-extended","array-extended"],function(a,b,c,e){return d(a().register("declare",b).register(c).register(e))}):this.Ht=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended))}.call(this)},{"array-extended":39,"declare.js":42,extended:43,"is-extended":53}],53:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;!function(){"use strict";function e(a){function b(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}.call(this)},{__browserify_Buffer:50,extended:43}],54:[function(a,b,c){!function(){"use strict";function d(a){function b(a,b){var c=0;return a>b?1:b>a?-1:b?c:1}var c=a.multiply,d=a.declare({instance:{__printNode:function(b,d){var e=[];a.isUndefinedOrNull(b)?(e.push(c(" ",d)),e.push("~"),console.log(e.join(""))):(this.__printNode(b.right,d+1),e.push(c(" ",d)),e.push(b.data+"\n"),console.log(e.join("")),this.__printNode(b.left,d+1))},constructor:function(a){a=a||{},this.compare=a.compare||b,this.__root=null},insert:function(){throw new Error("Not Implemented")},remove:function(){throw new Error("Not Implemented")},clear:function(){this.__root=null},isEmpty:function(){return!this.__root},traverseWithCondition:function(a,b,c){var e=!0;return a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.IN_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.POST_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e&&(e=this.traverseWithCondition(a.right,b,c)),e&&(e=c(a.data)))):b===d.REVERSE_ORDER&&(e=this.traverseWithCondition(a.right,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c))))),e},traverse:function(a,b,c){a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(c(a.data),this.traverse(a.left,b,c),this.traverse(a.right,b,c)):b===d.IN_ORDER?(this.traverse(a.left,b,c),c(a.data),this.traverse(a.right,b,c)):b===d.POST_ORDER?(this.traverse(a.left,b,c),this.traverse(a.right,b,c),c(a.data)):b===d.REVERSE_ORDER&&(this.traverse(a.right,b,c),c(a.data),this.traverse(a.left,b,c)))},forEach:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this,this.traverse(this.__root,c,function(c){a.call(b,c,this)})},map:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){e.insert(a.call(b,c,this))}),e},filter:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){a.call(b,c,this)&&e.insert(c)}),e},reduce:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduce.apply(a,f)},reduceRight:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduceRight.apply(a,f)},every:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=!1;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this)}),e},some:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this),!e}),e},toArray:function(a){a=a||d.IN_ORDER;var b=[];return this.traverse(this.__root,a,function(a){b.push(a)}),b},contains:function(a){for(var b=!1,c=this.__root;null!==c;){var d=this.compare(a,c.data);d?c=c[-1===d?"left":"right"]:(b=!0,c=null)}return b},find:function(a){for(var b,c=this.__root;c;){var d=this.compare(a,c.data);if(!d){b=c.data;break}c=c[-1===d?"left":"right"]}return b},findLessThan:function(a,b){var c=[],e=this.compare;return this.traverseWithCondition(this.__root,d.IN_ORDER,function(d){var f=e(a,d);return!b&&0===f||1===f?(c.push(d),!0):!1}),c},findGreaterThan:function(a,b){var c=[],e=this.compare;return this.traverse(this.__root,d.REVERSE_ORDER,function(d){var f=e(a,d);return!b&&0===f||-1===f?(c.push(d),!0):!1}),c},print:function(){this.__printNode(this.__root,0)}},"static":{PRE_ORDER:"pre_order",IN_ORDER:"in_order",POST_ORDER:"post_order",REVERSE_ORDER:"reverse_order"}}),e=function(){var a=Math.abs,b=function(a){return{data:a,balance:0,left:null,right:null}},e=function(a,b,c){var d=a[c];return a[c]=d[b],d[b]=a,d},f=function(a,b,c){return a[c]=e(a[c],c,b),e(a,b,c)},g=function(a,b,c){var d="left"===b?"right":"left",e=a[b],f=e[d];0===f.balance?a.balance=e.balance=0:f.balance===c?(a.balance=-c,e.balance=0):(a.balance=0,e.balance=c),f.balance=0},h=function(a,b){var c="left"===b?"right":"left",d=a[b],h="left"===b?-1:1;return d.balance===h?(a.balance=d.balance=0,a=e(a,c,b)):(g(a,b,h),a=f(a,c,b)),a},i=function(a,b,c){var d="left"===b?"right":"left",h=a[d],i="left"===b?-1:1;return h.balance===-i?(a.balance=h.balance=0,a=e(a,b,d)):h.balance===i?(g(a,d,-i),a=f(a,b,d)):(a.balance=-i,h.balance=i,a=e(a,b,d),c.done=!0),a},j=function(c,d,e,f){if(null===c||void 0===c)c=b(d);else{var g=-1===f(d,c.data)?"left":"right";c[g]=j(c[g],d,e,f),e.done||(c.balance+="left"===g?-1:1,0===c.balance?e.done=!0:a(c.balance)>1&&(c=h(c,g),e.done=!0))}return c},k=function(b,c,d,e){var f,g,h,j;if(b){if(g=e(c,b.data),0===g){var l=b.left,m=b.right;if(!l||!m)return f=l?"left":"right",h=b[f];for(var n=l;null!==(m=n.right);)n=m;b.data=n.data,c=n.data}if(f=-1===e(b.data,c)?"right":"left",b[f]=k(b[f],c,d,e),!d.done){j=b.balance+="left"===f?1:-1;var o=a(j);1===o?d.done=!0:o>1&&(b=i(b,f,d))}}return b};return d.extend({instance:{insert:function(a){var b={done:!1};this.__root=j(this.__root,a,b,this.compare)},remove:function(a){this.__root=k(this.__root,a,{done:!1},this.compare)},__printNode:function(a,b){var d=[];a?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.balance+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),f=function(){function a(a,b){return{data:a,level:b,left:g,right:g}}function b(a){if(0!==a.level&&a.left.level===a.level){var b=a.left;a.left=b.right,b.right=a,a=b}return a}function e(a){if(0!==a.level&&a.right.right.level===a.level){var b=a.right;a.right=b.left,b.left=a,a=b,a.level++}return a}function f(c,d,h){if(c===g)c=a(d,1);else{var i=-1===h(d,c.data)?"left":"right";c[i]=f(c[i],d,h),c=b(c),c=e(c)}return c}var g={level:0,data:null},h=function(a,c,d){var f,i;if(a!==g){var j=d(c,a.data);if(0===j)if(f=a.left,i=a.right,f!==g&&i!==g){for(var k=f;k.right!==g;)k=k.right;a.data=k.data,a.left=h(f,k.data,d)}else a=a[f===g?"right":"left"];else{var l=-1===j?"left":"right";a[l]=h(a[l],c,d)}}if(a!==g){var m=a.level,n=a.left.level,o=a.right.level;(m-1>n||m-1>o)&&(o>--a.level&&(a.right.level=a.level),a=b(a),a=e(a))}return a};return d.extend({instance:{isEmpty:function(){return this.__root===g||this._super(arguments)},insert:function(a){this.__root||(this.__root=g),this.__root=f(this.__root,a,this.compare)},remove:function(a){this.__root=h(this.__root,a,this.compare)},traverseWithCondition:function(a){var b=!0;return a!==g?this._super(arguments):b},traverse:function(a){a!==g&&this._super(arguments)},contains:function(){return this.__root!==g?this._super(arguments):!1},__printNode:function(a,b){var d=[];a&&a.data?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.level+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),g=d.extend({instance:{insert:function(a){if(!this.__root)return this.__root={data:a,parent:null,left:null,right:null};for(var b=this.compare,c=this.__root;null!==c;){var d=b(a,c.data);if(!d)return;var e=-1===d?"left":"right",f=c[e];if(!f)return c[e]={data:a,parent:c,left:null,right:null};c=f}},remove:function(a){if(null!==this.__root){for(var b,c={right:this.__root},d=c,e=null,f="right";null!==d[f];){b=d,d=d[f];var g=this.compare(a,d.data);g||(e=d),f=-1===g?"left":"right"}null!==e&&(e.data=d.data,b[b.right===d?"right":"left"]=d[null===d.left?"right":"left"]),this.__root=c.right}}}}),h=function(){var a="RED",b="BLACK",e=function(a){return null!==a&&a.red},f=function(a){return{data:a,red:!0,left:null,right:null}},g=function(a,b,c){if(!a)return f(b);var d=c(b,a.data);if(d){var j=-1===d?"left":"right",k="left"===j?"right":"left";a[j]=g(a[j],b,c);var l=a[j];if(e(l)){var m=a[k];e(m)?(a.red=!0,l.red=!1,m.red=!1):e(l[j])?a=h(a,k):e(l[k])&&(a=i(a,k))}}return a},h=function(a,b){var c="left"===b?"right":"left",d=a[c];return a[c]=d[b],d[b]=a,a.red=!0,d.red=!1,d},i=function(a,b){var c="left"===b?"right":"left";return a[c]=h(a[c],c),h(a,b)},j=function(a,b,c,d){if(a){var f;if(0===d(b,a.data)){if(!a.left||!a.right){var g=a[a.left?"left":"right"];return e(a)?c.done=!0:e(g)&&(g.red=!1,c.done=!0),g}for(var h,i=a.right;null!==i.left;)h=i,i=i.left;h&&(h.left=null),a.data=i.data,b=i.data}f=-1===d(b,a.data)?"left":"right",a[f]=j(a[f],b,c,d),c.done||(a=k(a,f,c))}else c.done=!0;return a},k=function(a,b,c){var d="left"===b?"right":"left",f=a,g=f[d];if(e(g)&&(a=h(a,b),g=f[d]),null!==g)if(e(g.left)||e(g.right)){var j=f.red,k=a===f;f=(e(g[d])?h:i)(f,b),f.red=j,f.left.red=f.right.red=0,k?a=f:a[b]=f,c.done=!0}else e(f)&&(c.done=!0),f.red=0,g.red=1;return a};return d.extend({instance:{insert:function(a){this.__root=g(this.__root,a,this.compare),this.__root.red=!1},remove:function(a){var b={done:!1},c=j(this.__root,a,b,this.compare);return null!==c&&(c.red=0),this.__root=c,a},__printNode:function(d,e){var f=[];d?(this.__printNode(d.right,e+1),f.push(c(" ",e)),f.push((d.red?a:b)+":"+d.data+"\n"),console.log(f.join("")),this.__printNode(d.left,e+1)):(f.push(c(" ",e)),f.push("~"),console.log(f.join("")))}}})}();return{Tree:d,AVLTree:e,AnderssonTree:f,BinaryTree:g,RedBlackTree:h,IN_ORDER:d.IN_ORDER,PRE_ORDER:d.PRE_ORDER,POST_ORDER:d.POST_ORDER,REVERSE_ORDER:d.REVERSE_ORDER}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")).register(a("string-extended")))):"function"==typeof define?define(["extended","declare.js","is-extended","array-extended","string-extended"],function(a,b,c,e,f){return d(a().register("declare",b).register(c).register(e).register(f))}):this.leafy=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended).register(this.stringExtended))}.call(this)},{"array-extended":39,"declare.js":42,extended:43,"is-extended":53,"string-extended":57}],55:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b){var c,d;for(c in b)t.call(b,c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}function e(a,b){var c,d,f;for(c in b)t.call(b,c)&&(d=b[c],f=a[c],p(f,d)||(a[c]=r(f)&&r(d)?e(f,d):r(d)?e({},d):d));return a}function f(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)d(a,arguments[b]);return a}function g(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)e(a,arguments[b]);return a}function h(a,b){var c=a.prototype||a;return f(c,b),a}function i(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e=l(a),f=0,g=e.length;g>f;++f)d=e[f],b.call(c||a,a[d],d,a);return a}function j(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e,f=l(a),g={},h=0,i=f.length;i>h;++h)d=f[h],e=a[d],b.call(c||a,e,d,a)&&(g[d]=e);return g}function k(a){if(!r(a))throw new TypeError;for(var b=l(a),c=[],d=0,e=b.length;e>d;++d)c.push(a[b[d]]);return c}function l(a){if(!r(a))throw new TypeError;var b=[];for(var c in a)t.call(a,c)&&b.push(c);return b}function m(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d={},e=0,f=c.length;f>e;++e)b=c[e],d[a[b]]=b;return d}function n(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d=[],e=0,f=c.length;f>e;++e)b=c[e],d.push([b,a[b]]);return d}function o(a,b){if(!r(a))throw new TypeError;q(b)&&(b=[b]);for(var c,d=s(l(a),b),e={},f=0,g=d.length;g>f;++f)c=d[f],e[c]=a[c];return e}var p=b.deepEqual,q=b.isString,r=b.isHash,s=c.difference,t=Object.prototype.hasOwnProperty,u=b.isFunction,v={forEach:i,filter:j,invert:m,values:k,toArray:n,keys:l,omit:o},w={extend:h,merge:f,deepMerge:g,omit:o},x=a.define(b.isObject,w).define(r,v).define(b.isFunction,{extend:h}).expose({hash:v}).expose(w),y=x.extend;return x.extend=function(){return 1===arguments.length?y.extend.apply(x,arguments):(h.apply(null,arguments),void 0)},x}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.objectExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":39,extended:43,"is-extended":53}],56:[function(a,b,c){var d=a("__browserify_process");!function(){"use strict";function e(a,b,c,e,f,g){function h(a,b){return function(){try{l(a.apply(null,arguments)).addCallback(b).addErrback(b)}catch(c){b.errback(c)}}}function i(a,b,c){var d=(new G).callback();return v(a,function(a){d=d.then(c?a:B(null,a)),c||(d=d.then(function(a){return b.push(a),b}))}),d}function j(a){return!w(a)&&y(a.then)}function k(a){var b=new G;return a.then(A(b,"callback"),A(b,"errback")),b.promise()}function l(a){var b;return a=C(arguments),a.length?1===a.length?(a=a.pop(),j(a)?a.addCallback&&a.addErrback?(b=new G,a.addCallback(b.callback),a.addErrback(b.errback)):b=k(a):b=x(a)&&c.every(a,j)?new H(a,!0).promise():(new G).callback(a)):b=new H(c.map(a,function(a){return l(a)}),!0).promise():b=(new G).callback(a).promise(),b}function m(a,b){return function(){var c=new G,d=C(arguments);return d.push(c.resolve),a.apply(b||this,d),c.promise()}}function n(a){if(x(a))return i(a,[],!1);throw new Error("When calling promise.serial the first argument must be an array")}function o(a){if(x(a))return i(a,[],!0);throw new Error("When calling promise.serial the first argument must be an array")}function p(a,b){a=C(arguments);var c=!1;b=a.pop();var d=l(a);return function(){return c?l(b.apply(this,arguments)):(a=arguments,d.then(A(this,function(){return c=!0,b.apply(this,a)})))}}function q(){return new G}function r(a){return new H(a,!0).promise()}function s(a){return q().errback(a)}function t(a){return q().callback(a)}var u,v=c.forEach,w=e.isUndefinedOrNull,x=e.isArray,y=e.isFunction,z=e.isBoolean,A=f.bind,B=f.bindIgnore,C=g.argsToArray;if("function"==typeof setImmediate)u="undefined"!=typeof window?setImmediate.bind(window):setImmediate;else if("undefined"!=typeof d)u=function(a){d.nextTick(a)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,E={},F=E;D.port1.onmessage=function(){E=E.next;var a=E.task;delete E.task,a()},u=function(a){F=F.next={task:a},D.port2.postMessage(0)}}else u=function(a){setTimeout(a,0)};var G=a({instance:{__fired:!1,__results:null,__error:null,__errorCbs:null,__cbs:null,constructor:function(){this.__errorCbs=[],this.__cbs=[],f.bindAll(this,["callback","errback","resolve","classic","__resolve","addCallback","addErrback"])},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__error?this.__errorCbs:this.__cbs,c=b.length,d=this.__error||this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(this,b)})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=a.callback),this.__fired&&this.__results?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=a.errback),this.__fired&&this.__error?this.__callNextTick(a,this.__error):this.__errorCbs.push(a)),this},callback:function(){return this.__fired||(this.__results=arguments,this.__resolve()),this.promise()},errback:function(){return this.__fired||(this.__error=arguments,this.__resolve()),this.promise()},resolve:function(a){return a?this.errback(a):this.callback.apply(this,C(arguments,1)),this},classic:function(a){return"function"==typeof a&&(this.addErrback(function(b){a(b)}),this.addCallback(function(){a.apply(this,[null].concat(C(arguments)))})),this},then:function(a,b){var c=new G,d=c;return y(b)&&(d=h(b,c)),this.addErrback(d),y(a)?this.addCallback(h(a,c)):this.addCallback(c),c.promise()},both:function(a){return this.then(a,a)},promise:function(){var a={then:A(this,"then"),both:A(this,"both"),promise:function(){return a}};return v(["addCallback","addErrback","classic"],function(b){a[b]=A(this,function(){return this[b].apply(this,arguments),a})},this),a}}}),H=G.extend({instance:{__results:null,__errors:null,__promiseLength:0,__defLength:0,__firedLength:0,normalizeResults:!1,constructor:function(a,b){this.__errors=[],this.__results=[],this.normalizeResults=z(b)?b:!1,this._super(arguments),a&&a.length?(this.__defLength=a.length,v(a,this.__addPromise,this)):this.__resolve()},__addPromise:function(a,b){a.then(A(this,function(){var a=C(arguments);a.unshift(b),this.callback.apply(this,a)}),A(this,function(){var a=C(arguments);a.unshift(b),this.errback.apply(this,a)}))},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__errors.length?this.__errorCbs:this.__cbs,c=b.length,d=this.__errors.length?this.__errors:this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(null,[b])})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=A(a,"callback")),this.__fired&&!this.__errors.length?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=A(a,"errback")),this.__fired&&this.__errors.length?this.__callNextTick(a,this.__errors):this.__errorCbs.push(a)),this},callback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__results[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()},errback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__errors[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()}}});return b.define({isPromiseLike:j}).expose({isPromiseLike:j,when:l,wrap:m,wait:p,serial:n,chain:o,Promise:G,PromiseList:H,promise:q,defer:q,deferredList:r,reject:s,resolve:t})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("declare.js"),a("extended"),a("array-extended"),a("is-extended"),a("function-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["declare","extended","array-extended","is-extended","function-extended","arguments-extended"],function(a,b,c,d,f,g){return e(a,b,c,d,f,g)}):this.promiseExtended=e(this.declare,this.extended,this.arrayExtended,this.isExtended,this.functionExtended,this.argumentsExtended)}.call(this)},{__browserify_process:51,"arguments-extended":38,"array-extended":39,"declare.js":42,extended:43,"function-extended":46,"is-extended":53}],57:[function(a,b,c){!function(){"use strict";function d(a,b,c,d){function e(a,b){var c=a;if(x.test(b)){var d=b.match(x),e=d[1],f=d[3],g=d[4];g&&(g=parseInt(g,10),c=c.length0?"+":"")+d),k&&(k=parseInt(k,10),d=d.lengthe;)d?a+=c:a=c+a,e++;return a}function i(a,c,d){var e=a;if(b.isString(e)){if(a.length>c)if(d){var f=a.length;e=a.substring(f-c,f)}else e=a.substring(0,c)}else e=i(""+e,c);return e}function j(a,d){if(d instanceof Array){var h=0,i=d.length;return a.replace(v,function(a,b,j){var k,l;if(!(i>h))return a;if(k=d[h++],"%s"===a||"%d"===a||"%D"===a)l=k+"";else if("%Z"===a)l=k.toUTCString();else if("%j"===a)try{l=s(k)}catch(m){throw new Error("stringExtended.format : Unable to parse json from ",k)}else switch(b=b.replace(/^\[|\]$/g,""),j){case"s":l=e(k,b);break;case"d":l=f(k,b);break;case"j":l=g(k,b);break;case"D":l=c.format(k,b);break;case"Z":l=c.format(k,b,!0)}return l})}if(t(d))return a.replace(w,function(a,h,i){if(i=d[i],!b.isUndefined(i)){if(!h)return""+i;if(b.isString(i))return e(i,h);if(b.isNumber(i))return f(i,h);if(b.isDate(i))return c.format(i,h);if(b.isObject(i))return g(i,h)}return a});var k=u.call(arguments).slice(1);return j(a,k)}function k(a,b){var c=[];return a&&(a.indexOf(b)>0?c=a.replace(/\s+/g,"").split(b):c.push(a)),c}function l(a,b){var c=[];if(b)for(var d=0;b>d;d++)c.push(a);return c.join("")}function m(a,c){var d,e,f;if(c)if(b.isArray(a))for(d=[],e=0,f=a.length;f>e;e++)d.push(m(a[e],c));else if(c instanceof Array)for(d=a,e=0,f=c.length;f>e;e++)d=m(d,c[e]);else c in z&&(d="["+z[c]+"m"+a+"");return d}function n(a,b){return a.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(a){return b&&-1!==d.indexOf(b,a)?a:"\\"+a})}function o(a){return a.replace(/^\s*|\s*$/g,"")}function p(a){return a.replace(/^\s*/,"")}function q(a){return a.replace(/\s*$/,"")}function r(a){return 0===a.length}var s;"undefined"==typeof JSON?function(){function a(a){return 10>a?"0"+a:a}function c(c){return b.isDate(c)?isFinite(c.valueOf())?c.getUTCFullYear()+"-"+a(c.getUTCMonth()+1)+"-"+a(c.getUTCDate())+"T"+a(c.getUTCHours())+":"+a(c.getUTCMinutes())+":"+a(c.getUTCSeconds())+"Z":null:i(c)?c.valueOf():c}function d(a){return j.lastIndex=0,j.test(a)?'"'+a.replace(j,function(a){var b=k[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(a,b){var i,j,k,l,m,n=f,o=b[a];switch(o&&(o=c(o)),"function"==typeof h&&(o=h.call(b,a,o)),typeof o){case"string":return d(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";if(f+=g,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(l=o.length,i=0;l>i;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":f?"[\n"+f+m.join(",\n"+f)+"\n"+n+"]":"["+m.join(",")+"]",f=n,k}if(h&&"object"==typeof h)for(l=h.length,i=0;l>i;i+=1)"string"==typeof h[i]&&(j=h[i],k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));else for(j in o)Object.prototype.hasOwnProperty.call(o,j)&&(k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));return k=0===m.length?"{}":f?"{\n"+f+m.join(",\n"+f)+"\n"+n+"}":"{"+m.join(",")+"}",f=n,k}}var f,g,h,i=b.tester().isString().isNumber().isBoolean().tester(),j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};s=function(a,b,c){var d;if(f="",g="","number"==typeof c)for(d=0;c>d;d+=1)g+=" ";else"string"==typeof c&&(g=c);if(h=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return e("",{"":a})}}():s=JSON.stringify;var t=b.isHash,u=Array.prototype.slice,v=/%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g,w=/\{(?:\[([^\[|\]]*)\])?(\w+)\}/g,x=/(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/,y=/([1-9][0-9]*)$/g,z={bold:1,bright:1,italic:3,underline:4,blink:5,inverse:7,crossedOut:9,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,redBackground:41,greenBackground:42,yellowBackground:43,blueBackground:44,magentaBackground:45,cyanBackground:46,whiteBackground:47,encircled:52,overlined:53,grey:90,black:90},A={SMILEY:"☺",SOLID_SMILEY:"☻",HEART:"♥",DIAMOND:"♦",CLOVE:"♣",SPADE:"♠",DOT:"•",SQUARE_CIRCLE:"◘",CIRCLE:"○",FILLED_SQUARE_CIRCLE:"◙",MALE:"♂",FEMALE:"♀",EIGHT_NOTE:"♪",DOUBLE_EIGHTH_NOTE:"♫",SUN:"☼",PLAY:"►",REWIND:"◄",UP_DOWN:"↕",PILCROW:"¶",SECTION:"§",THICK_MINUS:"▬",SMALL_UP_DOWN:"↨",UP_ARROW:"↑",DOWN_ARROW:"↓",RIGHT_ARROW:"→",LEFT_ARROW:"←",RIGHT_ANGLE:"∟",LEFT_RIGHT_ARROW:"↔",TRIANGLE:"▲",DOWN_TRIANGLE:"▼",HOUSE:"⌂",C_CEDILLA:"Ç",U_UMLAUT:"ü",E_ACCENT:"é",A_LOWER_CIRCUMFLEX:"â",A_LOWER_UMLAUT:"ä",A_LOWER_GRAVE_ACCENT:"à",A_LOWER_CIRCLE_OVER:"å",C_LOWER_CIRCUMFLEX:"ç",E_LOWER_CIRCUMFLEX:"ê",E_LOWER_UMLAUT:"ë",E_LOWER_GRAVE_ACCENT:"è",I_LOWER_UMLAUT:"ï",I_LOWER_CIRCUMFLEX:"î",I_LOWER_GRAVE_ACCENT:"ì",A_UPPER_UMLAUT:"Ä",A_UPPER_CIRCLE:"Å",E_UPPER_ACCENT:"É",A_E_LOWER:"æ",A_E_UPPER:"Æ",O_LOWER_CIRCUMFLEX:"ô",O_LOWER_UMLAUT:"ö",O_LOWER_GRAVE_ACCENT:"ò",U_LOWER_CIRCUMFLEX:"û",U_LOWER_GRAVE_ACCENT:"ù",Y_LOWER_UMLAUT:"ÿ",O_UPPER_UMLAUT:"Ö",U_UPPER_UMLAUT:"Ü",CENTS:"¢",POUND:"£",YEN:"¥",CURRENCY:"¤",PTS:"₧",FUNCTION:"ƒ",A_LOWER_ACCENT:"á",I_LOWER_ACCENT:"í",O_LOWER_ACCENT:"ó",U_LOWER_ACCENT:"ú",N_LOWER_TILDE:"ñ",N_UPPER_TILDE:"Ñ",A_SUPER:"ª",O_SUPER:"º",UPSIDEDOWN_QUESTION:"¿",SIDEWAYS_L:"⌐",NEGATION:"¬",ONE_HALF:"½",ONE_FOURTH:"¼",UPSIDEDOWN_EXCLAMATION:"¡",DOUBLE_LEFT:"«",DOUBLE_RIGHT:"»",LIGHT_SHADED_BOX:"░",MEDIUM_SHADED_BOX:"▒",DARK_SHADED_BOX:"▓",VERTICAL_LINE:"│",MAZE__SINGLE_RIGHT_T:"┤",MAZE_SINGLE_RIGHT_TOP:"┐",MAZE_SINGLE_RIGHT_BOTTOM_SMALL:"┘",MAZE_SINGLE_LEFT_TOP_SMALL:"┌",MAZE_SINGLE_LEFT_BOTTOM_SMALL:"└",MAZE_SINGLE_LEFT_T:"├",MAZE_SINGLE_BOTTOM_T:"┴",MAZE_SINGLE_TOP_T:"┬",MAZE_SINGLE_CENTER:"┼",MAZE_SINGLE_HORIZONTAL_LINE:"─",MAZE_SINGLE_RIGHT_DOUBLECENTER_T:"╡",MAZE_SINGLE_RIGHT_DOUBLE_BL:"╛",MAZE_SINGLE_RIGHT_DOUBLE_T:"╢",MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP:"╖",MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP:"╕",MAZE_SINGLE_LEFT_DOUBLE_T:"╞",MAZE_SINGLE_BOTTOM_DOUBLE_T:"╧",MAZE_SINGLE_TOP_DOUBLE_T:"╤",MAZE_SINGLE_TOP_DOUBLECENTER_T:"╥",MAZE_SINGLE_BOTTOM_DOUBLECENTER_T:"╨",MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM:"╘",MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP:"╒",MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP:"╓",MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM:"╙",MAZE_SINGLE_LEFT_TOP:"Γ",MAZE_SINGLE_RIGHT_BOTTOM:"╜",MAZE_SINGLE_LEFT_CENTER:"╟",MAZE_SINGLE_DOUBLECENTER_CENTER:"╫",MAZE_SINGLE_DOUBLECROSS_CENTER:"╪",MAZE_DOUBLE_LEFT_CENTER:"╣",MAZE_DOUBLE_VERTICAL:"║",MAZE_DOUBLE_RIGHT_TOP:"╗",MAZE_DOUBLE_RIGHT_BOTTOM:"╝",MAZE_DOUBLE_LEFT_BOTTOM:"╚",MAZE_DOUBLE_LEFT_TOP:"╔",MAZE_DOUBLE_BOTTOM_T:"╩",MAZE_DOUBLE_TOP_T:"╦",MAZE_DOUBLE_LEFT_T:"╠",MAZE_DOUBLE_HORIZONTAL:"═",MAZE_DOUBLE_CROSS:"╬",SOLID_RECTANGLE:"█",THICK_LEFT_VERTICAL:"▌",THICK_RIGHT_VERTICAL:"▐",SOLID_SMALL_RECTANGLE_BOTTOM:"▄",SOLID_SMALL_RECTANGLE_TOP:"▀",PHI_UPPER:"Φ",INFINITY:"∞",INTERSECTION:"∩",DEFINITION:"≡",PLUS_MINUS:"±",GT_EQ:"≥",LT_EQ:"≤",THEREFORE:"⌠",SINCE:"∵",DOESNOT_EXIST:"∄",EXISTS:"∃",FOR_ALL:"∀",EXCLUSIVE_OR:"⊕",BECAUSE:"⌡",DIVIDE:"÷",APPROX:"≈",DEGREE:"°",BOLD_DOT:"∙",DOT_SMALL:"·",CHECK:"√",ITALIC_X:"✗",SUPER_N:"ⁿ",SQUARED:"²",CUBED:"³",SOLID_BOX:"■",PERMILE:"‰",REGISTERED_TM:"®",COPYRIGHT:"©",TRADEMARK:"™",BETA:"β",GAMMA:"γ",ZETA:"ζ",ETA:"η",IOTA:"ι",KAPPA:"κ",LAMBDA:"λ",NU:"ν",XI:"ξ",OMICRON:"ο",RHO:"ρ",UPSILON:"υ",CHI_LOWER:"φ",CHI_UPPER:"χ",PSI:"ψ",ALPHA:"α",ESZETT:"ß",PI:"π",SIGMA_UPPER:"Σ",SIGMA_LOWER:"σ",MU:"µ",TAU:"τ",THETA:"Θ",OMEGA:"Ω",DELTA:"δ",PHI_LOWER:"φ",EPSILON:"ε"},B={toArray:k,pad:h,truncate:i,multiply:l,format:j,style:m,escape:n,trim:o,trimLeft:p,trimRight:q,isEmpty:r}; -return a.define(b.isString,B).define(b.isArray,{style:m}).expose(B).expose({characters:A})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("date-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","date-extended","array-extended"],function(a,b,c,e){return d(a,b,c,e)}):this.stringExtended=d(this.extended,this.isExtended,this.dateExtended,this.arrayExtended)}.call(this)},{"array-extended":39,"date-extended":40,extended:43,"is-extended":53}]},{},[1]); \ No newline at end of file +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gc&&g>c&&c++;);var h=d[c]-e[c];return h||(h=f-g),h}function g(a,b){return a.recency-b.recency}var h=a("./extended").map,i={salience:d,bucketCounter:e,factRecency:f,activationRecency:g};c.strategies=i,c.strategy=function(a){a=h(a,function(a){return i[a]});var b=a.length;return function(c,d){var e=-1,f=0,g=c===d||c.name===d.name&&c.hashCode===d.hashCode;if(!g){for(;++e0?1:-1}return f}}},{"./extended":12}],8:[function(a,b,c){"use strict";var d,e=a("./extended"),f=e.deepEqual,g=e.merge,h=e.instanceOf,i=e.filter,j=e.declare,k=0,l=j({instance:{constructor:function(b,c){d||(d=a("./constraintMatcher")),this.id=k++,this.type=b,this.constraint=c},assert:function(){throw new Error("not implemented")},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return[this.get("alias")]}}}});l.extend({instance:{constructor:function(a){this._super(["object",a])},assert:function(a){return a instanceof this.constraint||a.constructor===this.constraint},equal:function(a){return h(a,this._static)&&this.constraint===a.constraint}}}).as(c,"ObjectConstraint"),l.extend({instance:{constructor:function(a,b){this._super(["equality",a]),b=b||{},this.pattern=b.pattern,this._matcher=d.getMatcher(a,b.scope||{})},assert:function(a){return this._matcher(a)}}}).as(c,"EqualityConstraint"),l.extend({instance:{constructor:function(){this._super(["equality",[!0]])},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")},assert:function(){return!0}}}).as(c,"TrueConstraint"),l.extend({instance:{constructor:function(a,b){this.cache={},this._super(["reference",a]),b=b||{},this.values=[],this.pattern=b.pattern,this._options=b,this._matcher=d.getMatcher(a,b.scope||{})},assert:function(a){try{return this._matcher(a)}catch(b){throw new Error("Error with evaluating pattern "+this.pattern+" "+b.message)}},merge:function(a){var b=this;return a instanceof this._static&&(b=new this._static([this.constraint,a.constraint,"and"],g({},this._options,this._options)),b._alias=this._alias||a._alias,b.vars=this.vars.concat(a.vars)),b},equal:function(a){return h(a,this._static)&&e.deepEqual(this.constraint,a.constraint)},getters:{variables:function(){return this.vars},alias:function(){return this._alias}},setters:{alias:function(a){this._alias=a,this.vars=i(d.getIdentifiers(this.constraint),function(b){return b!==a})}}}}).as(c,"ReferenceConstraint"),l.extend({instance:{constructor:function(a){this._super(["hash",a])},equal:function(a){return e.instanceOf(a,this._static)&&this.get("alias")===a.get("alias")&&e.deepEqual(this.constraint,a.constraint)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"HashConstraint"),l.extend({instance:{constructor:function(a,b){this.type="from",this.prop=a,this.constraints=b},equal:function(a){return h(a,this._static)&&this.get("alias")===a.get("alias")&&f(this.constraints,a.constraints)},assert:function(){return!0},getters:{variables:function(){return this.constraint}}}}).as(c,"FromConstraint")},{"./constraintMatcher":9,"./extended":12}],9:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isArray,f=d.forEach,g=d.some,h=d.map,i=d.indexOf,j=d.isNumber,k=d.removeDuplicates,l=a("./constraint"),m={indexOf:d.indexOf,now:function(){return new Date},Date:function(a,b,c,d,e,f,g){var h=new Date;return j(a)&&h.setYear(a),j(b)&&h.setMonth(b),j(c)&&h.setDate(c),j(d)&&h.setHours(d),j(e)&&h.setMinutes(e),j(f)&&h.setSeconds(f),j(g)&&h.setMilliseconds(g),h},lengthOf:function(a,b){return a.length===b},isTrue:function(a){return a===!0},isFalse:function(a){return a===!1},isNotNull:function(a){return null!==a},dateCmp:function(a,b){return d.compare(a,b)}};f(["years","days","months","hours","minutes","seconds"],function(a){m[a+"FromNow"]=d[a+"FromNow"],m[a+"Ago"]=d[a+"Ago"]}),f(["isArray","isNumber","isHash","isObject","isDate","isBoolean","isString","isRegExp","isNull","isEmpty","isUndefined","isDefined","isUndefinedOrNull","isPromiseLike","isFunction","deepEqual"],function(a){var b=d[a];m[a]=function(){return b.apply(d,arguments)}});var n={equal:function(a,b){var c=!1;return a===b?c=!0:a[2]===b[2]&&(c=-1!==i(["string","number","boolean","regexp","identifier","null"],a[2])?a[0]===b[0]:"unary"===a[2]||"logicalNot"===a[2]?this.equal(a[0],b[0]):this.equal(a[0],b[0])&&this.equal(a[1],b[1])),c},getIdentifiers:function(a){var b=[],c=a[2];if("identifier"===c)return[a[0]];if("function"===c)b=b.concat(this.getIdentifiers(a[0])).concat(this.getIdentifiers(a[1]));else if("string"!==c&&"number"!==c&&"boolean"!==c&&"regexp"!==c&&"unary"!==c&&"unary"!==c)if("prop"===c){if(b=b.concat(this.getIdentifiers(a[0])),a[1])for(var d=a[1];e(d);){if("function"===d[2]){b=b.concat(this.getIdentifiers(d[1]));break}d=d[1]}}else a[0]&&(b=b.concat(this.getIdentifiers(a[0]))),a[1]&&(b=b.concat(this.getIdentifiers(a[1])));return k(b)},toConstraints:function(a,b){var c=[],d=b.alias,e=b.scope||{},f=a[2];return"and"===f?c=c.concat(this.toConstraints(a[0],b)).concat(this.toConstraints(a[1],b)):("composite"===f||"or"===f||"lt"===f||"gt"===f||"lte"===f||"gte"===f||"like"===f||"notLike"===f||"eq"===f||"neq"===f||"in"===f||"notIn"===f||"prop"===f||"propLookup"===f||"function"===f||"logicalNot"===f)&&(g(this.getIdentifiers(a),function(a){return!(a===d||a in m||a in e)})?c.push(new l.ReferenceConstraint(a,b)):c.push(new l.EqualityConstraint(a,b))),c},parse:function(a){return this[a[2]](a[0],a[1])},composite:function(a){return this.parse(a)},and:function(a,b){return["(",this.parse(a),"&&",this.parse(b),")"].join(" ")},or:function(a,b){return["(",this.parse(a),"||",this.parse(b),")"].join(" ")},prop:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"['",this.parse(b),"']"].join("")},propLookup:function(a,b){return"function"===b[2]?[this.parse(a),this.parse(b)].join("."):[this.parse(a),"[",this.parse(b),"]"].join("")},unary:function(a){return-1*this.parse(a)},plus:function(a,b){return[this.parse(a),"+",this.parse(b)].join(" ")},minus:function(a,b){return[this.parse(a),"-",this.parse(b)].join(" ")},mult:function(a,b){return[this.parse(a),"*",this.parse(b)].join(" ")},div:function(a,b){return[this.parse(a),"/",this.parse(b)].join(" ")},mod:function(a,b){return[this.parse(a),"%",this.parse(b)].join(" ")},lt:function(a,b){return[this.parse(a),"<",this.parse(b)].join(" ")},gt:function(a,b){return[this.parse(a),">",this.parse(b)].join(" ")},lte:function(a,b){return[this.parse(a),"<=",this.parse(b)].join(" ")},gte:function(a,b){return[this.parse(a),">=",this.parse(b)].join(" ")},like:function(a,b){return[this.parse(b),".test(",this.parse(a),")"].join("")},notLike:function(a,b){return["!",this.parse(b),".test(",this.parse(a),")"].join("")},eq:function(a,b){return[this.parse(a),"===",this.parse(b)].join(" ")},neq:function(a,b){return[this.parse(a),"!==",this.parse(b)].join(" ")},"in":function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) != -1"].join("")},notIn:function(a,b){return["(indexOf(",this.parse(b),",",this.parse(a),")) == -1"].join("")},arguments:function(a,b){var c=[];return a&&c.push(this.parse(a)),b&&c.push(this.parse(b)),c.join(",")},array:function(a){var b=[];return a?(b=this.parse(a),e(b)?b:["[",b,"]"].join("")):["[",b.join(","),"]"].join("")},"function":function(a,b){var c=this.parse(b);return[this.parse(a),"(",c,")"].join("")},string:function(a){return"'"+a+"'"},number:function(a){return a},"boolean":function(a){return a},regexp:function(a){return a},identifier:function(a){return a},"null":function(){return"null"},logicalNot:function(a){return["!(",this.parse(a),")"].join("")}},o=c.toJs=function(a,b){var c=n.parse(a);b=b||{};var d=n.getIdentifiers(a),e="var indexOf = definedFuncs.indexOf;"+h(d,function(a){var c=["var ",a," = "];return m.hasOwnProperty(a)?c.push("definedFuncs['",a,"']"):b.hasOwnProperty(a)?c.push("scope['",a,"']"):c.push("'",a,"' in fact ? fact['",a,"'] : hash['",a,"']"),c.push(";"),c.join("")}).join("")+" return !!("+c+");",f=new Function("fact, hash, definedFuncs, scope",e);return function(a,c){return f(a,c,m,b)}};c.getMatcher=function(a,b){return o(a,b)},c.toConstraints=function(a,b){return n.toConstraints(a,b)},c.equal=function(a,b){return n.equal(a,b)},c.getIdentifiers=function(a){return n.getIdentifiers(a)}},{"./constraint":8,"./extended":12}],10:[function(a,b){"use strict";var c=a("./extended"),d=c.isBoolean,e=c.declare,f=c.merge,g=c.union,h=Array.prototype.slice,i=e({instance:{constructor:function(a){this.isMatch=!0,a instanceof this._static?(this.isMatch=a.isMatch,this.facts=h.call(a.facts),this.factIds=h.call(a.factIds),this.hashCode=this.factIds.join(":"),this.factHash=f({},a.factHash),this.recency=h.call(a.recency)):a?(this.facts=[a],this.factIds=[a.id],this.recency=[a.recency],this.hashCode=a.id+"",this.factHash=a.factHash||{}):(this.facts=[],this.factIds=[],this.factHash={},this.hashCode="")},merge:function(a){var b=new this._static;return b.isMatch=a.isMatch,b.facts=this.facts.concat(a.facts),b.factIds=this.factIds.concat(a.factIds),b.hashCode=b.factIds.join(":"),b.factHash=f({},this.factHash,a.factHash),b.recency=g(this.recency,a.recency),b}}}),j=e({instance:{match:null,factHash:null,fact:null,hashCode:null,paths:null,constructor:function(a,b,c){this.fact=a,this.paths=b||null;var d=this.match=c||new i(a);this.factHash=d.factHash,this.hashCode=d.hashCode,this.factIds=d.factIds},set:function(a,b){return this.factHash[a]=b,this},isMatch:function(a){return d(a)?(this.match.isMatch=a,this):this.match.isMatch},mergeMatch:function(a){var b=this.match=this.match.merge(a);return this.factHash=b.factHash,this.hashCode=b.hashCode,this.factIds=b.factIds,this},clone:function(a,b,c){return new j(a||this.fact,b||this.path,c||this.match)}}}).as(b)},{"./extended":12}],11:[function(a,b){var c=a("./extended"),d=c.Promise,e=a("./nextTick"),f=c.isPromiseLike;d.extend({instance:{looping:!1,constructor:function(a,b){this._super([]),this.flow=a,this.agenda=a.agenda,this.rootNode=a.rootNode,this.matchUntilHalt=!!b,c.bindAll(this,["onAlter","callNext"])},halt:function(){this.__halted=!0,this.looping||this.callback()},onAlter:function(){this.flowAltered=!0,this.looping||!this.matchUntilHalt||this.__halted||this.callNext()},setup:function(){var a=this.flow;this.rootNode.resetCounter(),a.on("assert",this.onAlter),a.on("modify",this.onAlter),a.on("retract",this.onAlter)},tearDown:function(){var a=this.flow;a.removeListener("assert",this.onAlter),a.removeListener("modify",this.onAlter),a.removeListener("retract",this.onAlter)},__handleAsyncNext:function(a){var b=this,c=b.agenda;return a.addCallback(function(){b.looping=!1,c.isEmpty()?(!b.matchUntilHalt||b.__halted)&&b.callback():(b.flowAltered&&(b.rootNode.incrementCounter(),b.flowAltered=!1),b.__halted?b.callback():b.callNext()),b=null}).addErrback(this.errback)},__handleSyncNext:function(a){return this.looping=!1,this.agenda.isEmpty()||this.flowAltered&&(this.rootNode.incrementCounter(),this.flowAltered=!1),a&&!this.__halted?e(this.callNext):(!this.matchUntilHalt||this.__halted)&&this.callback(),a},callback:function(){this.tearDown(),this._super(arguments)},callNext:function(){this.looping=!0;var a=this.agenda.fireNext();return f(a)?this.__handleAsyncNext(a):this.__handleSyncNext(a)},execute:function(){return this.setup(),this.callNext(),this}}}).as(b)},{"./extended":12,"./nextTick":17}],12:[function(a,b){function c(a){var b=a.match(/(\w+)\(\)$/);return b?(a=b[1],function(b){return b[a]()}):function(b){return b[a]}}function d(a){if(a=a.split("."),1===a.length)return c(a[0]);var b=f(a,function(a){return c(a)}),d=b.length;return function(a){for(var c=-1,e=a;++cb;b++)a.assert(arguments[b]);return a},containsRule:function(a){return c.some(this.__rules,function(b){return b.name===a})}},"static":{getFlow:function(a){return j[a]},hasFlow:function(a){return c.has(j,a)},deleteFlow:function(a){return d(a,k)&&(a=a.name),delete j[a],k},deleteFlows:function(){for(var a in j)a in j&&delete j[a];return k},create:function(a,b){return new k(a,b)}}}).as(b)},{"./extended":12,"./flow":13,"./pattern":38,"./rule":39}],15:[function(a,b,c){"use strict";function d(a){return/\.nools$/.test(a)}function e(a){var b;return b=d(a)?i.parse(g.readFileSync(a,"utf8"),a):i.parse(a)}var f=a("./extended"),g=a("fs"),h=a("path"),i=a("./compile"),j=a("./flowContainer");c.Flow=j,c.getFlow=j.getFlow,c.hasFlow=j.hasFlow,c.deleteFlow=function(a){return j.deleteFlow(a),this},c.deleteFlows=function(){return j.deleteFlows(),this},c.flow=j.create,c.compile=function(a,b,c){if(f.isFunction(b)?(c=b,b={}):(b=b||{},c=null),f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),!b.name)throw new Error("Name required when compiling nools source");return i.compile(a,b,c,j)},c.transpile=function(a,b){return b=b||{},f.isString(a)&&(b.name=b.name||(d(a)?h.basename(a,h.extname(a)):null),a=e(a)),i.transpile(a,b)},c.parse=e},{"./compile":5,"./extended":12,"./flowContainer":14,fs:51,path:52}],16:[function(a,b){var c=a("declare.js");c({instance:{constructor:function(){this.head=null,this.tail=null,this.length=null},push:function(a){var b=this.tail,c=this.head,d={data:a,prev:b,next:null};return b&&(this.tail.next=d),this.tail=d,c||(this.head=d),this.length++,d},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev,this.length--},forEach:function(a){for(var b={next:this.head};b=b.next;)a(b.data)},clear:function(){this.head=this.tail=null,this.length=0}}}).as(b)},{"declare.js":45}],17:[function(a,b){var c,d=a("__browserify_process"),e=a("./extended");if("function"==typeof setImmediate)c="undefined"!=typeof window?e.bind(window,setImmediate):setImmediate;else if("undefined"!=typeof d)c=d.nextTick;else if("undefined"!=typeof MessageChannel){var f=new MessageChannel,g={},h=g;f.port1.onmessage=function(){g=g.next;var a=g.task;delete g.task,a()},c=function(a){h=h.next={task:a},f.port2.postMessage(0)}}else c=function(a){setTimeout(a,0)};b.exports=c},{"./extended":12,__browserify_process:54}],18:[function(a,b){var c=a("./alphaNode");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias")},toString:function(){return"AliasNode"+this.__count},assert:function(a){return this.__propagate("assert",a.set(this.alias,a.fact.object))},modify:function(a){return this.__propagate("modify",a.set(this.alias,a.fact.object))},retract:function(a){return this.__propagate("retract",a.set(this.alias,a.fact.object))},equal:function(a){return a instanceof this._static&&this.alias===a.alias}}}).as(b)},{"./alphaNode":19}],19:[function(a,b){"use strict";var c=a("./node");c.extend({instance:{constructor:function(a){this._super([]),this.constraint=a},toString:function(){return"AlphaNode "+this.__count},equal:function(a){return this.constraint.equal(a.constraint)}}}).as(b)},{"./node":27}],20:[function(a,b){function c(a){for(var b=[],c=a.paths,d=-1,e=c.length;++dd;d++)this.__checkMatch(a,c[d],!0);else this.__checkMatch(a,c,!0)},__checkMatch:function(a,b,c){var d;return(d=this.__createMatch(a,b)).isMatch()&&c&&this.__propagate("assert",d.clone()),d},__createMatch:function(a,b){if(this.type.assert(b)){var c,d=this.workingMemory.getFactHandle(b,!0),e=new i(d).set(this.alias,b),f=d.id,g=e.factHash,h=a.factHash;for(var j in h)g[j]=h[j];for(var k=this.__equalityConstraints,l=this.__variables,m=-1,o=k.length;++mc;c++)b=this.__checkMatch(a,k[c],!1),b.isMatch()&&(e=b.fact.id,e in j?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone()));else b=this.__checkMatch(a,k,!1),b.isMatch()&&(e=b.fact.id,e in j?this.__propagate("modify",b.clone()):this.__propagate("assert",b.clone()));for(c in j)c in i||(this.removeFromFromMemory(j[c]),this.__propagate("retract",j[c].clone()))}else this.assertLeft(a);f=a.fact,e=f.id;var l=this.fromMemory[e];if(this.fromMemory[e]={},l){var n,o,p,q,r=f.object;for(c in l)o=l[c],n=o[0],p=o[1],q=p.isMatch(),n.hashCode!==a.hashCode&&(b=this.__createMatch(n,r,!1),q&&this.__propagate("retract",p.clone()),b.isMatch()&&this.__propagate(q?"modify":"assert",b.clone())) +}},assertLeft:function(a){this.__addToLeftMemory(a),a.fromMatches={},this.__createMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")},toString:function(){return"FromNode"+this.__count}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":24}],22:[function(a,b){var c=a("./joinNode"),d=a("../extended"),e=a("../constraint"),f=e.EqualityConstraint,g=e.HashConstraint,h=e.ReferenceConstraint,i=a("../context"),j=d.plucker,k=d.forEach,l=d.isArray;c.extend({instance:{constructor:function(a,b){this._super(arguments),this.workingMemory=b,this.pattern=a,this.type=a.get("constraints")[0],this.alias=a.get("alias"),this.plucker=j(this.from=a.from),this.fromMemory={};var c=this.__equalityConstraints=[],d=[];k(this.constraints=this.pattern.get("constraints").slice(1),function(a){a instanceof f||a instanceof h?c.push(a):a instanceof g&&(d=d.concat(a.get("variables")))}),this.__variables=d},retractLeft:function(a){var b=this.removeFromLeftMemory(a);b&&(b=b.data,b.blocked||this.__propagate("retract",b.clone()))},__modify:function(a,b){var c=b.blocked,d=a.factHash,e=this.plucker(d);if(l(e)){for(var f=0,g=e.length;g>f;f++)if(this.__isMatch(a,e[f],!0)){a.blocked=!0;break}}else a.blocked=this.__isMatch(a,e,!0);var h=a.blocked;h?c||this.__propagate("retract",b.clone()):c?this.__propagate("assert",a.clone()):this.__propagate("modify",a.clone())},modifyLeft:function(a){var b=this.removeFromLeftMemory(a);if(!b)throw new Error;this.__addToLeftMemory(a),this.__modify(a,b.data);var c=this.fromMemory[a.fact.id];if(this.fromMemory[a.fact.id]={},c)for(var d in c)if(d!==a.hashCode){var e=c[d];b=this.removeFromLeftMemory(e),b&&(e=e.clone(),e.blocked=!1,this.__addToLeftMemory(e),this.__modify(e,b.data))}},__findMatches:function(a){var b=a.factHash,c=this.plucker(b),d=!1;if(l(c)){for(var e=0,f=c.length;f>e;e++)if(this.__isMatch(a,c[e],!0))return a.blocked=!0,void 0;this.__propagate("assert",a.clone())}else(a.blocked=this.__isMatch(a,c,!0))||this.__propagate("assert",a.clone());return d},__isMatch:function(a,b,c){var d=!1;if(this.type.assert(b)){var e=this.workingMemory.getFactHandle(b),f=new i(e,null).mergeMatch(a.match).set(this.alias,b);if(c){var g=this.fromMemory[e.id];g||(g=this.fromMemory[e.id]={}),g[a.hashCode]=a}for(var h=f.factHash,j=this.__equalityConstraints,k=0,l=j.length;l>k;k++){if(!j[k].assert(h)){d=!1;break}d=!0}}return d},removeFromLeftMemory:function(){return this._super(arguments)},assertLeft:function(a){this.__addToLeftMemory(a),this.__findMatches(a)},assertRight:function(){throw new Error("Shouldnt have gotten here")},retractRight:function(){throw new Error("Shouldnt have gotten here")},toString:function(){return"FromNode"+this.__count}}}).as(b)},{"../constraint":8,"../context":10,"../extended":12,"./joinNode":24}],23:[function(a,b,c){"use strict";var d=a("../extended"),e=d.forEach,f=d.some,g=d.declare,h=a("../pattern.js"),i=h.ObjectPattern,j=h.FromPattern,k=h.FromNotPattern,l=h.NotPattern,m=h.CompositePattern,n=h.InitialFactPattern,o=a("../constraint"),p=o.HashConstraint,q=o.ReferenceConstraint,r=a("./aliasNode"),s=a("./equalityNode"),t=a("./joinNode"),u=a("./notNode"),v=a("./fromNode"),w=a("./fromNotNode"),x=a("./leftAdapterNode"),y=a("./rightAdapterNode"),z=a("./typeNode"),A=a("./terminalNode"),B=a("./propertyNode");g({instance:{constructor:function(a,b){this.terminalNodes=[],this.joinNodes=[],this.nodes=[],this.constraints=[],this.typeNodes=[],this.__ruleCount=0,this.bucket={counter:0,recency:0},this.agendaTree=b,this.workingMemory=a},assertRule:function(a){var b=new A(this.bucket,this.__ruleCount++,a,this.agendaTree);this.__addToNetwork(a,a.pattern,b),this.__mergeJoinNodes(),this.terminalNodes.push(b)},resetCounter:function(){this.bucket.counter=0},incrementCounter:function(){this.bucket.counter++},assertFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].assert(a)},retractFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].retract(a)},modifyFact:function(a){for(var b=this.typeNodes,c=b.length-1;c>=0;c--)b[c].modify(a)},containsRule:function(a){return f(this.terminalNodes,function(b){return b.rule.name===a})},dispose:function(){for(var a=this.typeNodes,b=a.length-1;b>=0;b--)a[b].dispose()},__mergeJoinNodes:function(){for(var a=this.joinNodes,b=0;b=0;c--){var d=b[c];if(a.equal(d))return d}return b.push(a),a},__createTypeNode:function(a,b){for(var c=new z(b.get("constraints")[0]),d=this.typeNodes,e=d.length-1;e>=0;e--){var f=d[e];if(c.equal(f))return f}return d.push(c),c},__createEqualityNode:function(a,b){return this.__checkEqual(new s(b)).addRule(a)},__createPropertyNode:function(a,b){return this.__checkEqual(new B(b)).addRule(a)},__createAliasNode:function(a,b){return this.__checkEqual(new r(b)).addRule(a)},__createAdapterNode:function(a,b){return("left"===b?new x:new y).addRule(a)},__createJoinNode:function(a,b,c,d){var e;b.rightPattern instanceof l?e=new u:b.rightPattern instanceof k?e=new w(b.rightPattern,this.workingMemory):b.rightPattern instanceof j?e=new v(b.rightPattern,this.workingMemory):(e=new t,this.joinNodes.push(e)),e.__rule__=a;var f=e;if(c instanceof t){var g=this.__createAdapterNode(a,d);f.addOutNode(g,b),f=g}return f.addOutNode(c,b),e.addRule(a)},__addToNetwork:function(a,b,c,d){b instanceof i?!(b instanceof l||b instanceof j||b instanceof k)||d&&"left"!==d?this.__createAlphaNode(a,b,c,d):b instanceof k?this.__createBetaNode(a,new m(new n,b),c,d):this.__createBetaNode(a,new m(new n,b),c,d):b instanceof m&&this.__createBetaNode(a,b,c,d)},__createBetaNode:function(a,b,c,d){var e=this.__createJoinNode(a,b,c,d);return this.__addToNetwork(a,b.rightPattern,e,"right"),this.__addToNetwork(a,b.leftPattern,e,"left"),c.addParentNode(e),e},__createAlphaNode:function(a,b,c,d){var e,f;if(!(b instanceof j)){var g=b.get("constraints");e=this.__createTypeNode(a,b);var h=this.__createAliasNode(a,b);e.addOutNode(h,b),h.addParentNode(e),f=h;for(var i=g.length-1;i>0;i--){var k,l=g[i];if(l instanceof p)k=this.__createPropertyNode(a,l);else{if(l instanceof q){c.constraint.addConstraint(l);continue}k=this.__createEqualityNode(a,l)}f.addOutNode(k,b),k.addParentNode(f),f=k}if(c instanceof t){var m=this.__createAdapterNode(a,d);m.addParentNode(f),f.addOutNode(m,b),f=m}return c.addParentNode(f),f.addOutNode(c,b),e}},print:function(){e(this.terminalNodes,function(a){a.print(" ")})}}}).as(c,"RootNode")},{"../constraint":8,"../extended":12,"../pattern.js":38,"./aliasNode":18,"./equalityNode":20,"./fromNode":21,"./fromNotNode":22,"./joinNode":24,"./leftAdapterNode":26,"./notNode":28,"./propertyNode":29,"./rightAdapterNode":30,"./terminalNode":31,"./typeNode":32}],24:[function(a,b){var c=a("../extended"),d=c.hash.values,e=a("./node"),f=a("./joinReferenceNode"),g=a("../linkedList");e.extend({instance:{constructor:function(){this._super([]),this.constraint=new f,this.leftMemory={},this.rightMemory={},this.leftTuples=new g,this.rightTuples=new g},dispose:function(){this.leftMemory={},this.rightMemory={},this.leftTuples.clear(),this.rightTuples.clear()},disposeLeft:function(a){this.leftMemory={},this.leftTuples.clear(),this.propagateDispose(a)},disposeRight:function(a){this.rightMemory={},this.rightTuples.clear(),this.propagateDispose(a)},hashCode:function(){return"JoinNode "+this.__count},toString:function(){return"JoinNode "+this.__count},retractLeft:function(a){if(a=this.removeFromLeftMemory(a),!a)throw new Error;a=a.data;for(var b=d(a.rightMatches),c=-1,e=b.length;++ce;e++)this.addOutNode(d,c[e]);a.nodes.remove(d)},this);for(var b=a.parentNodes,c=0,d=a.parentNodes.l;d>c;c++){var e=b[c];this.addParentNode(e),e.nodes.remove(a)}return this},resolve:function(a,b){return a.hashCode===b.hashCode},print:function(a){console.log(a+this.toString()),d(this.parentNodes,function(b){b.print(" "+a)})},addOutNode:function(a,b){this.nodes.contains(a)||this.nodes.put(a,[]),this.nodes.get(a).push(b),this.__entrySet=this.nodes.entrySet()},addParentNode:function(a){-1===e(this.parentNodes,a)&&this.parentNodes.push(a)},shareable:function(){return!1},__propagate:function(a,b){for(var c,d,e,g,h=this.__entrySet,j=h.length;--j>-1;)c=h[j],d=c.key,e=c.value,b.paths?(g=f(e,b.paths)).length&&d[a](new i(b.fact,g,b.match)):d[a](b)},dispose:function(a){this.propagateDispose(a)},retract:function(a){this.propagateRetract(a)},propagateDispose:function(a,b){b=b||this.nodes;for(var c=this.__entrySet,d=c.length-1;d>=0;d--){var e=c[d],f=e.key;f.dispose(a)}},propagateAssert:function(a){this.__propagate("assert",a)},propagateRetract:function(a){this.__propagate("retract",a)},assert:function(a){this.propagateAssert(a)},modify:function(a){this.propagateModify(a)},propagateModify:function(a){this.__propagate("modify",a)}}}).as(b)},{"../context":10,"../extended":12}],28:[function(a,b){var c=a("./joinNode"),d=a("../linkedList");c.extend({instance:{constructor:function(){this._super(arguments),this.leftTupleMemory={}},toString:function(){return"NotNode "+this.__count},retractRight:function(a){var b=this.removeFromRightMemory(a);if(!b)throw new Error;var c=b.data,d=c.blocking;if(d.length){for(var e,f,g,h=this.rightTuples,i=this.constraint,j={next:d.head},k=h.length;j=j.next;){if(e=j.data,this.removeFromLeftBlockedMemory(e),0!==k){for(i.setLeftContext(e),f=b;f=f.next;)if(i.setRightContext(g=f.data).isMatch()){e.blocker=g,this.addToLeftBlockedMemory(g.blocking.push(e)),e=null;break}i.clearContexts()}e&&(this.__addToLeftMemory(e),this.__propagate("assert",e.clone()))}d.clear()}},retractLeft:function(a){var b=this.removeFromLeftMemory(a);if(b)this.__propagate("retract",b.data.clone());else if(!this.removeFromLeftBlockedMemory(a))throw new Error},assertLeft:function(a){var b,c,d=this.rightTuples,e=this.constraint;if(d.length){for(b={next:d.head},e.setLeftContext(a);(b=b.next)&&a;)e.setRightContext(c=b.data).isMatch()&&(a.blocker=c,this.addToLeftBlockedMemory(c.blocking.push(a)),a=null);e.clearContexts()}a&&(this.__addToLeftMemory(a),this.__propagate("assert",a.clone()))},assertRight:function(a){this.__addToRightMemory(a),a.blocking=new d;var b,c,e=this.leftTuples,f=this.constraint;if(e.length){for(c={next:e.head},f.setRightContext(a);c=c.next;)b=c.data,f.setLeftContext(b).isMatch()&&(this.__propagate("retract",b.clone()),this.removeFromLeftMemory(b),b.blocker=a,this.addToLeftBlockedMemory(a.blocking.push(b)));f.clearContexts()}},addToLeftBlockedMemory:function(a){var b=a.data,c=b.hashCode,d=this.leftMemory[c];return this.leftTupleMemory[c]=a,d&&this.leftTuples.remove(d),this},removeFromLeftBlockedMemory:function(a){var b=this.leftTupleMemory[a.hashCode]||null;return b&&(delete this.leftTupleMemory[a.hashCode],b.data.blocker.blocking.remove(b)),b},modifyLeft:function(a){var b,c,d,e,f=this.removeFromLeftMemory(a),g=this.constraint,h=this.rightTuples,i=h.length,j=!1;if(f||(f=this.removeFromLeftBlockedMemory(a),j=!0),!f)throw new Error;if(b=f.data,b&&b.blocker&&(e=this.rightMemory[b.blocker.hashCode]),e&&(g.setLeftContext(a),g.setRightContext(d=e.data).isMatch()&&(j||this.__propagate("retract",b.clone()),a.blocker=d,this.addToLeftBlockedMemory(d.blocking.push(a)),a=null)),a&&i){for(c={next:h.head},g.setLeftContext(a);c=c.next;)if(g.setRightContext(d=c.data).isMatch()){j||this.__propagate("retract",b.clone()),this.addToLeftBlockedMemory(d.blocking.push(a)),a.blocker=d,a=null;break}g.clearContexts()}a&&(this.__addToLeftMemory(a),j?this.__propagate("assert",a.clone()):this.__propagate("modify",a.clone()))},modifyRight:function(a){var b=this.removeFromRightMemory(a);if(!b)throw new Error;var c,e,f=b.data,g=this.leftTuples,h=g.length,i=this.constraint,j=f.blocking;if(this.__addToRightMemory(a),a.blocking=new d,h||j.length){if(h)for(i.setRightContext(a),e={next:g.head};e=e.next;)c=e.data,i.setLeftContext(c).isMatch()&&(this.__propagate("retract",c.clone()),this.removeFromLeftMemory(c),this.addToLeftBlockedMemory(a.blocking.push(c)),c.blocker=a);if(j.length){for(var k,l={next:j.head};l=l.next;){if(c=l.data,c.blocker=null,i.setRightContext(a),i.setLeftContext(c),i.isMatch())return c.blocker=a,this.addToLeftBlockedMemory(a.blocking.push(c)),c=null,void 0;for(c.blocker=null,e=b;e=e.next;)if(i.setRightContext(k=e.data).isMatch()){c.blocker=k,this.addToLeftBlockedMemory(k.blocking.push(c)),c=null;break}c&&(this.__addToLeftMemory(c),this.__propagate("assert",c.clone())),i.clearContexts()}i.clearContexts()}}}}}).as(b)},{"../linkedList":16,"./joinNode":24}],29:[function(a,b){var c=a("./alphaNode"),d=a("../context"),e=a("../extended");c.extend({instance:{constructor:function(){this._super(arguments),this.alias=this.constraint.get("alias"),this.varLength=(this.variables=e(this.constraint.get("variables")).toArray().value()).length},assert:function(a){var b,c=new d(a.fact,a.paths),e=this.variables,f=a.fact.object;c.set(this.alias,f);for(var g=0,h=this.varLength;h>g;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("assert",c)},retract:function(a){this.__propagate("retract",new d(a.fact,a.paths))},modify:function(a){var b,c=new d(a.fact,a.paths),e=this.variables,f=a.fact.object;c.set(this.alias,f);for(var g=0,h=this.varLength;h>g;g++)b=e[g],c.set(b[1],f[b[0]]);this.__propagate("modify",c)},toString:function(){return"PropertyNode"+this.__count}}}).as(b)},{"../context":10,"../extended":12,"./alphaNode":19}],30:[function(a,b){var c=a("./node");c.extend({instance:{retractResolve:function(a){this.__propagate("retractResolve",a)},dispose:function(a){this.propagateDispose(a)},propagateAssert:function(a){this.__propagate("assertRight",a)},propagateRetract:function(a){this.__propagate("retractRight",a)},propagateResolve:function(a){this.__propagate("retractResolve",a)},propagateModify:function(a){this.__propagate("modifyRight",a)},toString:function(){return"RightAdapterNode "+this.__count}}}).as(b)},{"./node":27}],31:[function(a,b){var c=a("./node"),d=a("../extended"),e=d.bind,f=d.removeDuplicates;c.extend({instance:{constructor:function(a,b,c,d){this._super([]),this.resolve=e(this,this.resolve),this.rule=c,this.index=b,this.name=this.rule.name,this.agenda=d,this.bucket=a,d.register(this)},__assertModify:function(a){var b=a.match;if(b.recency.sort(function(a,b){return a-b}).reverse(),b.facts=f(b.facts),b.isMatch){var c=this.rule,d=this.bucket;this.agenda.insert(this,{rule:c,hashCode:a.hashCode,index:this.index,name:c.name,recency:d.recency++,match:b,counter:d.counter})}},assert:function(a){this.__assertModify(a)},modify:function(a){this.agenda.retract(this,a),this.__assertModify(a)},retract:function(a){this.agenda.retract(this,a)},retractRight:function(a){this.agenda.retract(this,a)},retractLeft:function(a){this.agenda.retract(this,a)},assertLeft:function(a){this.__assertModify(a)},assertRight:function(a){this.__assertModify(a)},toString:function(){return"TerminalNode "+this.rule.name}}}).as(b)},{"../extended":12,"./node":27}],32:[function(a,b){var c=a("./alphaNode"),d=a("../context");c.extend({instance:{assert:function(a){this.constraint.assert(a.object)&&this.__propagate("assert",a)},modify:function(a){this.constraint.assert(a.object)&&this.__propagate("modify",a)},retract:function(a){this.constraint.assert(a.object)&&this.__propagate("retract",a)},toString:function(){return"TypeNode"+this.__count},dispose:function(){for(var a=this.__entrySet,b=a.length-1;b>=0;b--){var c=a[b],d=c.key,e=c.value;d.dispose({paths:e})}},__propagate:function(a,b){for(var c=this.__entrySet,e=-1,f=c.length;++e":20,"<=":21,">=":22,EQUALITY_EXPRESSION:23,"==":24,"!=":25,"=~":26,"!=~":27,IN_EXPRESSION:28,"in":29,ARRAY_EXPRESSION:30,notIn:31,OBJECT_EXPRESSION:32,AND_EXPRESSION:33,"&&":34,OR_EXPRESSION:35,"||":36,ARGUMENT_LIST:37,",":38,IDENTIFIER_EXPRESSION:39,IDENTIFIER:40,".":41,"[":42,STRING_EXPRESSION:43,"]":44,NUMBER_EXPRESSION:45,"(":46,")":47,STRING:48,NUMBER:49,REGEXP_EXPRESSION:50,REGEXP:51,BOOLEAN_EXPRESSION:52,BOOLEAN:53,NULL_EXPRESSION:54,NULL:55,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"-",9:"!",11:"*",12:"/",13:"%",15:"+",17:"^",19:"<",20:">",21:"<=",22:">=",24:"==",25:"!=",26:"=~",27:"!=~",29:"in",31:"notIn",34:"&&",36:"||",38:",",40:"IDENTIFIER",41:".",42:"[",44:"]",46:"(",47:")",48:"STRING",49:"NUMBER",51:"REGEXP",53:"BOOLEAN",55:"NULL"},productions_:[0,[3,2],[6,1],[6,2],[6,2],[10,1],[10,3],[10,3],[10,3],[14,1],[14,3],[14,3],[16,1],[16,3],[18,1],[18,3],[18,3],[18,3],[18,3],[23,1],[23,3],[23,3],[23,3],[23,3],[28,1],[28,3],[28,3],[28,3],[28,3],[33,1],[33,3],[35,1],[35,3],[37,1],[37,3],[39,1],[32,1],[32,3],[32,4],[32,4],[32,4],[32,3],[32,4],[43,1],[45,1],[50,1],[52,1],[54,1],[30,2],[30,3],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,3],[4,1]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 3:this.$=[f[g],null,"unary"];break;case 4:this.$=[f[g],null,"logicalNot"];break;case 6:this.$=[f[g-2],f[g],"mult"];break;case 7:this.$=[f[g-2],f[g],"div"];break;case 8:this.$=[f[g-2],f[g],"mod"];break;case 10:this.$=[f[g-2],f[g],"plus"];break;case 11:this.$=[f[g-2],f[g],"minus"];break;case 13:this.$=[f[g-2],f[g],"pow"];break;case 15:this.$=[f[g-2],f[g],"lt"];break;case 16:this.$=[f[g-2],f[g],"gt"];break;case 17:this.$=[f[g-2],f[g],"lte"];break;case 18:this.$=[f[g-2],f[g],"gte"];break;case 20:this.$=[f[g-2],f[g],"eq"];break;case 21:this.$=[f[g-2],f[g],"neq"];break;case 22:this.$=[f[g-2],f[g],"like"];break;case 23:this.$=[f[g-2],f[g],"notLike"];break;case 25:this.$=[f[g-2],f[g],"in"];break;case 26:this.$=[f[g-2],f[g],"notIn"];break;case 27:this.$=[f[g-2],f[g],"in"];break;case 28:this.$=[f[g-2],f[g],"notIn"];break;case 30:this.$=[f[g-2],f[g],"and"];break;case 32:this.$=[f[g-2],f[g],"or"];break;case 34:this.$=[f[g-2],f[g],"arguments"];break;case 35:this.$=[String(a),null,"identifier"];break;case 37:this.$=[f[g-2],f[g],"prop"];break;case 38:this.$=[f[g-3],f[g-1],"propLookup"];break;case 39:this.$=[f[g-3],f[g-1],"propLookup"];break;case 40:this.$=[f[g-3],f[g-1],"propLookup"];break;case 41:this.$=[f[g-2],[null,null,"arguments"],"function"];break;case 42:this.$=[f[g-3],f[g-1],"function"];break;case 43:this.$=[String(a.replace(/^['|"]|['|"]$/g,"")),null,"string"];break;case 44:this.$=[Number(a),null,"number"];break;case 45:this.$=[a,null,"regexp"];break;case 46:this.$=["true"==a.replace(/^\s+/,""),null,"boolean"];break;case 47:this.$=[null,null,"null"];break;case 48:this.$=[null,null,"array"];break;case 49:this.$=[f[g-1],null,"array"];break;case 57:this.$=[f[g-1],null,"composite"]}},table:[{3:1,4:2,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[3]},{5:[1,31]},{5:[2,58],36:[1,32],47:[2,58]},{5:[2,31],34:[1,33],36:[2,31],47:[2,31]},{5:[2,29],34:[2,29],36:[2,29],47:[2,29]},{5:[2,24],24:[1,34],25:[1,35],26:[1,36],27:[1,37],34:[2,24],36:[2,24],47:[2,24]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],29:[1,38],31:[1,39],34:[2,2],36:[2,2],47:[2,2]},{5:[2,19],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,19],25:[2,19],26:[2,19],27:[2,19],34:[2,19],36:[2,19],47:[2,19]},{5:[2,50],8:[2,50],11:[2,50],12:[2,50],13:[2,50],15:[2,50],17:[2,50],19:[2,50],20:[2,50],21:[2,50],22:[2,50],24:[2,50],25:[2,50],26:[2,50],27:[2,50],29:[2,50],31:[2,50],34:[2,50],36:[2,50],38:[2,50],44:[2,50],47:[2,50]},{5:[2,51],8:[2,51],11:[2,51],12:[2,51],13:[2,51],15:[2,51],17:[2,51],19:[2,51],20:[2,51],21:[2,51],22:[2,51],24:[2,51],25:[2,51],26:[2,51],27:[2,51],29:[2,51],31:[2,51],34:[2,51],36:[2,51],38:[2,51],44:[2,51],47:[2,51]},{5:[2,52],8:[2,52],11:[2,52],12:[2,52],13:[2,52],15:[2,52],17:[2,52],19:[2,52],20:[2,52],21:[2,52],22:[2,52],24:[2,52],25:[2,52],26:[2,52],27:[2,52],29:[2,52],31:[2,52],34:[2,52],36:[2,52],38:[2,52],44:[2,52],47:[2,52]},{5:[2,53],8:[2,53],11:[2,53],12:[2,53],13:[2,53],15:[2,53],17:[2,53],19:[2,53],20:[2,53],21:[2,53],22:[2,53],24:[2,53],25:[2,53],26:[2,53],27:[2,53],29:[2,53],31:[2,53],34:[2,53],36:[2,53],38:[2,53],44:[2,53],47:[2,53]},{5:[2,54],8:[2,54],11:[2,54],12:[2,54],13:[2,54],15:[2,54],17:[2,54],19:[2,54],20:[2,54],21:[2,54],22:[2,54],24:[2,54],25:[2,54],26:[2,54],27:[2,54],29:[2,54],31:[2,54],34:[2,54],36:[2,54],38:[2,54],44:[2,54],47:[2,54]},{5:[2,55],8:[2,55],11:[2,55],12:[2,55],13:[2,55],15:[2,55],17:[2,55],19:[2,55],20:[2,55],21:[2,55],22:[2,55],24:[2,55],25:[2,55],26:[2,55],27:[2,55],29:[2,55],31:[2,55],34:[2,55],36:[2,55],38:[2,55],41:[1,44],42:[1,45],44:[2,55],46:[1,46],47:[2,55]},{5:[2,56],8:[2,56],11:[2,56],12:[2,56],13:[2,56],15:[2,56],17:[2,56],19:[2,56],20:[2,56],21:[2,56],22:[2,56],24:[2,56],25:[2,56],26:[2,56],27:[2,56],29:[2,56],31:[2,56],34:[2,56],36:[2,56],38:[2,56],44:[2,56],47:[2,56]},{4:47,6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:4,35:3,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,14],17:[1,48],19:[2,14],20:[2,14],21:[2,14],22:[2,14],24:[2,14],25:[2,14],26:[2,14],27:[2,14],34:[2,14],36:[2,14],47:[2,14]},{5:[2,43],8:[2,43],11:[2,43],12:[2,43],13:[2,43],15:[2,43],17:[2,43],19:[2,43],20:[2,43],21:[2,43],22:[2,43],24:[2,43],25:[2,43],26:[2,43],27:[2,43],29:[2,43],31:[2,43],34:[2,43],36:[2,43],38:[2,43],44:[2,43],47:[2,43]},{5:[2,44],8:[2,44],11:[2,44],12:[2,44],13:[2,44],15:[2,44],17:[2,44],19:[2,44],20:[2,44],21:[2,44],22:[2,44],24:[2,44],25:[2,44],26:[2,44],27:[2,44],29:[2,44],31:[2,44],34:[2,44],36:[2,44],38:[2,44],44:[2,44],47:[2,44]},{5:[2,45],8:[2,45],11:[2,45],12:[2,45],13:[2,45],15:[2,45],17:[2,45],19:[2,45],20:[2,45],21:[2,45],22:[2,45],24:[2,45],25:[2,45],26:[2,45],27:[2,45],29:[2,45],31:[2,45],34:[2,45],36:[2,45],38:[2,45],44:[2,45],47:[2,45]},{5:[2,46],8:[2,46],11:[2,46],12:[2,46],13:[2,46],15:[2,46],17:[2,46],19:[2,46],20:[2,46],21:[2,46],22:[2,46],24:[2,46],25:[2,46],26:[2,46],27:[2,46],29:[2,46],31:[2,46],34:[2,46],36:[2,46],38:[2,46],44:[2,46],47:[2,46]},{5:[2,47],8:[2,47],11:[2,47],12:[2,47],13:[2,47],15:[2,47],17:[2,47],19:[2,47],20:[2,47],21:[2,47],22:[2,47],24:[2,47],25:[2,47],26:[2,47],27:[2,47],29:[2,47],31:[2,47],34:[2,47],36:[2,47],38:[2,47],44:[2,47],47:[2,47]},{5:[2,36],8:[2,36],11:[2,36],12:[2,36],13:[2,36],15:[2,36],17:[2,36],19:[2,36],20:[2,36],21:[2,36],22:[2,36],24:[2,36],25:[2,36],26:[2,36],27:[2,36],29:[2,36],31:[2,36],34:[2,36],36:[2,36],38:[2,36],41:[2,36],42:[2,36],44:[2,36],46:[2,36],47:[2,36]},{7:51,30:15,32:14,37:50,39:23,40:[1,26],42:[1,24],43:9,44:[1,49],45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,12],8:[1,53],15:[1,52],17:[2,12],19:[2,12],20:[2,12],21:[2,12],22:[2,12],24:[2,12],25:[2,12],26:[2,12],27:[2,12],34:[2,12],36:[2,12],47:[2,12]},{5:[2,35],8:[2,35],11:[2,35],12:[2,35],13:[2,35],15:[2,35],17:[2,35],19:[2,35],20:[2,35],21:[2,35],22:[2,35],24:[2,35],25:[2,35],26:[2,35],27:[2,35],29:[2,35],31:[2,35],34:[2,35],36:[2,35],38:[2,35],41:[2,35],42:[2,35],44:[2,35],46:[2,35],47:[2,35]},{5:[2,9],8:[2,9],11:[1,54],12:[1,55],13:[1,56],15:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],22:[2,9],24:[2,9],25:[2,9],26:[2,9],27:[2,9],34:[2,9],36:[2,9],47:[2,9]},{5:[2,5],8:[2,5],11:[2,5],12:[2,5],13:[2,5],15:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],22:[2,5],24:[2,5],25:[2,5],26:[2,5],27:[2,5],34:[2,5],36:[2,5],47:[2,5]},{6:57,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:59,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{1:[2,1]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:5,30:15,32:14,33:60,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:7,8:[1,29],9:[1,30],10:27,14:25,16:17,18:8,23:6,28:61,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:62,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:63,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:64,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:17,18:65,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{30:66,32:67,39:23,40:[1,26],42:[1,24]},{30:68,32:69,39:23,40:[1,26],42:[1,24]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:70,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:71,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:72,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:25,16:73,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{39:74,40:[1,26]},{32:77,39:23,40:[1,26],43:75,45:76,48:[1,18],49:[1,19]},{7:51,30:15,32:14,37:79,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],47:[1,78],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{47:[1,80]},{6:28,7:58,8:[1,29],9:[1,30],10:27,14:81,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,48],8:[2,48],11:[2,48],12:[2,48],13:[2,48],15:[2,48],17:[2,48],19:[2,48],20:[2,48],21:[2,48],22:[2,48],24:[2,48],25:[2,48],26:[2,48],27:[2,48],29:[2,48],31:[2,48],34:[2,48],36:[2,48],38:[2,48],44:[2,48],47:[2,48]},{38:[1,83],44:[1,82]},{38:[2,33],44:[2,33],47:[2,33]},{6:28,7:58,8:[1,29],9:[1,30],10:84,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:28,7:58,8:[1,29],9:[1,30],10:85,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:86,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:87,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{6:88,7:58,8:[1,29],9:[1,30],30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,3],8:[2,3],11:[2,3],12:[2,3],13:[2,3],15:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],22:[2,3],24:[2,3],25:[2,3],26:[2,3],27:[2,3],34:[2,3],36:[2,3],47:[2,3]},{5:[2,2],8:[2,2],11:[2,2],12:[2,2],13:[2,2],15:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],22:[2,2],24:[2,2],25:[2,2],26:[2,2],27:[2,2],34:[2,2],36:[2,2],47:[2,2]},{5:[2,4],8:[2,4],11:[2,4],12:[2,4],13:[2,4],15:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],22:[2,4],24:[2,4],25:[2,4],26:[2,4],27:[2,4],34:[2,4],36:[2,4],47:[2,4]},{5:[2,32],34:[1,33],36:[2,32],47:[2,32]},{5:[2,30],34:[2,30],36:[2,30],47:[2,30]},{5:[2,20],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,20],25:[2,20],26:[2,20],27:[2,20],34:[2,20],36:[2,20],47:[2,20]},{5:[2,21],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,21],25:[2,21],26:[2,21],27:[2,21],34:[2,21],36:[2,21],47:[2,21]},{5:[2,22],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,22],25:[2,22],26:[2,22],27:[2,22],34:[2,22],36:[2,22],47:[2,22]},{5:[2,23],19:[1,40],20:[1,41],21:[1,42],22:[1,43],24:[2,23],25:[2,23],26:[2,23],27:[2,23],34:[2,23],36:[2,23],47:[2,23]},{5:[2,25],34:[2,25],36:[2,25],47:[2,25]},{5:[2,27],34:[2,27],36:[2,27],41:[1,44],42:[1,45],46:[1,46],47:[2,27]},{5:[2,26],34:[2,26],36:[2,26],47:[2,26]},{5:[2,28],34:[2,28],36:[2,28],41:[1,44],42:[1,45],46:[1,46],47:[2,28]},{5:[2,15],17:[1,48],19:[2,15],20:[2,15],21:[2,15],22:[2,15],24:[2,15],25:[2,15],26:[2,15],27:[2,15],34:[2,15],36:[2,15],47:[2,15]},{5:[2,16],17:[1,48],19:[2,16],20:[2,16],21:[2,16],22:[2,16],24:[2,16],25:[2,16],26:[2,16],27:[2,16],34:[2,16],36:[2,16],47:[2,16]},{5:[2,17],17:[1,48],19:[2,17],20:[2,17],21:[2,17],22:[2,17],24:[2,17],25:[2,17],26:[2,17],27:[2,17],34:[2,17],36:[2,17],47:[2,17]},{5:[2,18],17:[1,48],19:[2,18],20:[2,18],21:[2,18],22:[2,18],24:[2,18],25:[2,18],26:[2,18],27:[2,18],34:[2,18],36:[2,18],47:[2,18]},{5:[2,37],8:[2,37],11:[2,37],12:[2,37],13:[2,37],15:[2,37],17:[2,37],19:[2,37],20:[2,37],21:[2,37],22:[2,37],24:[2,37],25:[2,37],26:[2,37],27:[2,37],29:[2,37],31:[2,37],34:[2,37],36:[2,37],38:[2,37],41:[2,37],42:[2,37],44:[2,37],46:[2,37],47:[2,37]},{44:[1,89]},{44:[1,90]},{41:[1,44],42:[1,45],44:[1,91],46:[1,46]},{5:[2,41],8:[2,41],11:[2,41],12:[2,41],13:[2,41],15:[2,41],17:[2,41],19:[2,41],20:[2,41],21:[2,41],22:[2,41],24:[2,41],25:[2,41],26:[2,41],27:[2,41],29:[2,41],31:[2,41],34:[2,41],36:[2,41],38:[2,41],41:[2,41],42:[2,41],44:[2,41],46:[2,41],47:[2,41]},{38:[1,83],47:[1,92]},{5:[2,57],8:[2,57],11:[2,57],12:[2,57],13:[2,57],15:[2,57],17:[2,57],19:[2,57],20:[2,57],21:[2,57],22:[2,57],24:[2,57],25:[2,57],26:[2,57],27:[2,57],29:[2,57],31:[2,57],34:[2,57],36:[2,57],38:[2,57],44:[2,57],47:[2,57]},{5:[2,13],8:[1,53],15:[1,52],17:[2,13],19:[2,13],20:[2,13],21:[2,13],22:[2,13],24:[2,13],25:[2,13],26:[2,13],27:[2,13],34:[2,13],36:[2,13],47:[2,13]},{5:[2,49],8:[2,49],11:[2,49],12:[2,49],13:[2,49],15:[2,49],17:[2,49],19:[2,49],20:[2,49],21:[2,49],22:[2,49],24:[2,49],25:[2,49],26:[2,49],27:[2,49],29:[2,49],31:[2,49],34:[2,49],36:[2,49],38:[2,49],44:[2,49],47:[2,49]},{7:93,30:15,32:14,39:23,40:[1,26],42:[1,24],43:9,45:10,46:[1,16],48:[1,18],49:[1,19],50:11,51:[1,20],52:12,53:[1,21],54:13,55:[1,22]},{5:[2,10],8:[2,10],11:[1,54],12:[1,55],13:[1,56],15:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],22:[2,10],24:[2,10],25:[2,10],26:[2,10],27:[2,10],34:[2,10],36:[2,10],47:[2,10]},{5:[2,11],8:[2,11],11:[1,54],12:[1,55],13:[1,56],15:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],22:[2,11],24:[2,11],25:[2,11],26:[2,11],27:[2,11],34:[2,11],36:[2,11],47:[2,11]},{5:[2,6],8:[2,6],11:[2,6],12:[2,6],13:[2,6],15:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],22:[2,6],24:[2,6],25:[2,6],26:[2,6],27:[2,6],34:[2,6],36:[2,6],47:[2,6]},{5:[2,7],8:[2,7],11:[2,7],12:[2,7],13:[2,7],15:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],22:[2,7],24:[2,7],25:[2,7],26:[2,7],27:[2,7],34:[2,7],36:[2,7],47:[2,7]},{5:[2,8],8:[2,8],11:[2,8],12:[2,8],13:[2,8],15:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],22:[2,8],24:[2,8],25:[2,8],26:[2,8],27:[2,8],34:[2,8],36:[2,8],47:[2,8]},{5:[2,38],8:[2,38],11:[2,38],12:[2,38],13:[2,38],15:[2,38],17:[2,38],19:[2,38],20:[2,38],21:[2,38],22:[2,38],24:[2,38],25:[2,38],26:[2,38],27:[2,38],29:[2,38],31:[2,38],34:[2,38],36:[2,38],38:[2,38],41:[2,38],42:[2,38],44:[2,38],46:[2,38],47:[2,38]},{5:[2,39],8:[2,39],11:[2,39],12:[2,39],13:[2,39],15:[2,39],17:[2,39],19:[2,39],20:[2,39],21:[2,39],22:[2,39],24:[2,39],25:[2,39],26:[2,39],27:[2,39],29:[2,39],31:[2,39],34:[2,39],36:[2,39],38:[2,39],41:[2,39],42:[2,39],44:[2,39],46:[2,39],47:[2,39]},{5:[2,40],8:[2,40],11:[2,40],12:[2,40],13:[2,40],15:[2,40],17:[2,40],19:[2,40],20:[2,40],21:[2,40],22:[2,40],24:[2,40],25:[2,40],26:[2,40],27:[2,40],29:[2,40],31:[2,40],34:[2,40],36:[2,40],38:[2,40],41:[2,40],42:[2,40],44:[2,40],46:[2,40],47:[2,40]},{5:[2,42],8:[2,42],11:[2,42],12:[2,42],13:[2,42],15:[2,42],17:[2,42],19:[2,42],20:[2,42],21:[2,42],22:[2,42],24:[2,42],25:[2,42],26:[2,42],27:[2,42],29:[2,42],31:[2,42],34:[2,42],36:[2,42],38:[2,42],41:[2,42],42:[2,42],44:[2,42],46:[2,42],47:[2,42]},{38:[2,34],44:[2,34],47:[2,34]}],defaultActions:{31:[2,1]},parseError:function(a,b){if(!b.recoverable)throw new Error(a); +this.trace(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||m,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n);var o=this.lexer.options&&this.lexer.options.ranges;this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var p,q,r,s,t,u,v,w,x,y={};;){if(r=d[d.length-1],this.defaultActions[r]?s=this.defaultActions[r]:((null===p||"undefined"==typeof p)&&(p=b()),s=g[r]&&g[r][p]),"undefined"==typeof s||!s.length||!s[0]){var z="";x=[];for(u in g[r])this.terminals_[u]&&u>l&&x.push("'"+this.terminals_[u]+"'");z=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(i+1)+": Unexpected "+(p==m?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(z,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:n,expected:x})}if(s[0]instanceof Array&&s.length>1)throw new Error("Parse Error: multiple actions possible at state: "+r+", token: "+p);switch(s[0]){case 1:d.push(p),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(s[1]),p=null,q?(p=q,q=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:if(v=this.productions_[s[1]][1],y.$=e[e.length-v],y._$={first_line:f[f.length-(v||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(v||1)].first_column,last_column:f[f.length-1].last_column},o&&(y._$.range=[f[f.length-(v||1)].range[0],f[f.length-1].range[1]]),t=this.performAction.call(y,h,j,i,this.yy,s[1],e,f),"undefined"!=typeof t)return t;v&&(d=d.slice(0,2*-1*v),e=e.slice(0,-1*v),f=f.slice(0,-1*v)),d.push(this.productions_[s[1]][0]),e.push(y.$),f.push(y._$),w=g[d[d.length-2]][d[d.length-1]],d.push(w);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;fb[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1?a:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){switch(c){case 0:return 29;case 1:return 31;case 2:return"from";case 3:return 24;case 4:return 25;case 5:return 21;case 6:return 19;case 7:return 22;case 8:return 20;case 9:return 26;case 10:return 27;case 11:return 34;case 12:return 36;case 13:return 55;case 14:return 53;case 15:break;case 16:return 49;case 17:return 48;case 18:return 48;case 19:return 40;case 20:return 51;case 21:return 41;case 22:return 11;case 23:return 12;case 24:return 13;case 25:return 38;case 26:return 8;case 27:return 26;case 28:return 27;case 29:return 24;case 30:return 24;case 31:return 25;case 32:return 25;case 33:return 21;case 34:return 22;case 35:return 20;case 36:return 19;case 37:return 34;case 38:return 36;case 39:return 15;case 40:return 17;case 41:return 46;case 42:return 44;case 43:return 42;case 44:return 47;case 45:return 9;case 46:return 5}},rules:[/^(?:\s+in\b)/,/^(?:\s+notIn\b)/,/^(?:\s+from\b)/,/^(?:\s+(eq|EQ)\b)/,/^(?:\s+(neq|NEQ)\b)/,/^(?:\s+(lte|LTE)\b)/,/^(?:\s+(lt|LT)\b)/,/^(?:\s+(gte|GTE)\b)/,/^(?:\s+(gt|GT)\b)/,/^(?:\s+(like|LIKE)\b)/,/^(?:\s+(notLike|NOT_LIKE)\b)/,/^(?:\s+(and|AND)\b)/,/^(?:\s+(or|OR)\b)/,/^(?:\s+null\b)/,/^(?:\s+(true|false)\b)/,/^(?:\s+)/,/^(?:-?[0-9]+(?:\.[0-9]+)?\b)/,/^(?:'[^']*')/,/^(?:"[^"]*")/,/^(?:([a-zA-Z_$][0-9a-zA-Z_$]*))/,/^(?:^\/((?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4})(?!\w))/,/^(?:\.)/,/^(?:\*)/,/^(?:\/)/,/^(?:\%)/,/^(?:,)/,/^(?:-)/,/^(?:=~)/,/^(?:!=~)/,/^(?:==)/,/^(?:===)/,/^(?:!=)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:>)/,/^(?:<)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\])/,/^(?:\[)/,/^(?:\))/,/^(?:!)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();"undefined"!=typeof a&&"undefined"!=typeof c&&(c.parser=e,c.Parser=e.Parser,c.parse=function(){return e.parse.apply(e,arguments)},c.main=function(b){b[1]||(console.log("Usage: "+b[0]+" FILE"),d.exit(1));var e=a("fs").readFileSync(a("path").normalize(b[1]),"utf8");return c.parser.parse(e)},"undefined"!=typeof b&&a.main===b&&c.main(d.argv.slice(1)))},{__browserify_process:54,fs:51,path:52}],34:[function(a,b,c){!function(){"use strict";var b=a("./constraint/parser"),d=a("./nools/nool.parser");c.parseConstraint=function(a){try{return b.parse(a)}catch(c){throw new Error("Invalid expression '"+a+"'")}},c.parseRuleSet=function(a,b){return d.parse(a,b)}}()},{"./constraint/parser":33,"./nools/nool.parser":35}],35:[function(a,b,c){"use strict";var d=a("./tokens.js"),e=a("../../extended"),f=e.hash.keys,g=a("./util.js"),h=function(a,b,c){var d=a;a=a.replace(/\/\/(.*)/g,"").replace(/\n|\r|\r\n/g," ");for(var e,i=new RegExp("^("+f(b).join("|")+")");a&&-1!==(e=g.findNextTokenIndex(a));){a=a.substr(e);var j=a.match(i);if(null===j)throw new Error("Error parsing "+a);if(j=j[1],!(j in b))throw new Error("Unknown token"+j);try{a=b[j](a,c,h).replace(/^\s*|\s*$/g,"")}catch(k){throw new Error("Invalid "+j+" definition \n"+k.message+"; \nstarting at : "+d)}}};c.parse=function(a,b){var c={define:[],rules:[],scope:[],loaded:[],file:b};return h(a,d,c),c}},{"../../extended":12,"./tokens.js":36,"./util.js":37}],36:[function(require,module,exports){var process=require("__browserify_process"),utils=require("./util.js"),fs=require("fs"),indexOf=require("../../extended").indexOf,isWhiteSpace=function(a){return 0===a.replace(/[\s|\n|\r|\t]/g,"").length},ruleTokens={salience:function(){var a=/^(salience|priority)\s*:\s*(-?\d+)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=parseInt(d[2],10);if(isNaN(e))throw new Error("Invalid salience/priority "+d[2]);return c.options.priority=e,b.replace(d[0],"")}throw new Error("invalid format")}}(),agendaGroup:function(){var a=/^(agenda-group|agendaGroup)\s*:\s*([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid agenda-group "+d[2]);return c.options.agendaGroup=e.replace(/^["']|["']$/g,""),b.replace(d[0],"")}throw new Error("invalid format")}}(),autoFocus:function(){var a=/^(auto-focus|autoFocus)\s*:\s*(true|false)\s*[,;]?/;return function(b,c){if(a.test(b)){var d=b.match(a),e=d[2];if(!e)throw new Error("Invalid auto-focus "+d[2]);return c.options.autoFocus="true"===e?!0:!1,b.replace(d[0],"")}throw new Error("invalid format")}}(),"agenda-group":function(){return this.agendaGroup.apply(this,arguments)},"auto-focus":function(){return this.autoFocus.apply(this,arguments)},priority:function(){return this.salience.apply(this,arguments)},when:function(){var ruleRegExp=/^(\$?\w+) *: *(\w+)(.*)/,joinFunc=function(a,b){return"; "+b},constraintRegExp=/(\{ *(?:["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']? *(?:, *["']?\$?\w+["']?\s*:\s*["']?\$?\w+["']?)*)+ *\})/,predicateExp=/^(\w+) *\((.*)\)$/m,fromRegExp=/(\bfrom\s+.*)/,parseRules=function(str){for(var rules=[],ruleLines=str.split(";"),l=ruleLines.length,ruleLine,i=0;l>i&&(ruleLine=ruleLines[i].replace(/^\s*|\s*$/g,"").replace(/\n/g,""));i++)if(!isWhiteSpace(ruleLine)){var rule=[];if(predicateExp.test(ruleLine)){var m=ruleLine.match(predicateExp),pred=m[1].replace(/^\s*|\s*$/g,"");if(rule.push(pred),ruleLine=m[2].replace(/^\s*|\s*$/g,""),"or"===pred){rule=rule.concat(parseRules(ruleLine.replace(/,\s*(\$?\w+\s*:)/g,joinFunc))),rules.push(rule);continue}}var parts=ruleLine.match(ruleRegExp);if(!parts||!parts.length)throw new Error("Invalid constraint "+ruleLine);rule.push(parts[2],parts[1]);var constraints=parts[3].replace(/^\s*|\s*$/g,""),hashParts=constraints.match(constraintRegExp),from=null,fromMatch;if(hashParts){var hash=hashParts[1],constraint=constraints.replace(hash,"");fromRegExp.test(constraint)&&(fromMatch=constraint.match(fromRegExp),from=fromMatch[0],constraint=constraint.replace(fromMatch[0],"")),constraint&&rule.push(constraint.replace(/^\s*|\s*$/g,"")),hash&&rule.push(eval("("+hash.replace(/(\$?\w+)\s*:\s*(\$?\w+)/g,'"$1" : "$2"')+")"))}else constraints&&!isWhiteSpace(constraints)&&(fromRegExp.test(constraints)&&(fromMatch=constraints.match(fromRegExp),from=fromMatch[0],constraints=constraints.replace(fromMatch[0],"")),rule.push(constraints));from&&rule.push(from),rules.push(rule)}return rules};return function(a,b){var c=a.replace(/^when\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(d,""),b.constraints=parseRules(d.replace(/^\{\s*|\}\s*$/g,"")),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}(),then:function(){return function(a,b){if(b.action)throw new Error("action already defined for rule"+b.name);var c=a.replace(/^then\s*/,"").replace(/^\s*|\s*$/g,"");if("{"===utils.findNextToken(c)){var d=utils.getTokensBetween(c,"{","}",!0).join("");if(c=c.replace(d,""),b.action||(b.action=d.replace(/^\{\s*|\}\s*$/g,"")),!isWhiteSpace(c))throw new Error("Error parsing then block "+a);return c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}}()},topLevelTokens={"/":function(a){return a.match(/^\/\*/)?a.replace(/\/\*.*?\*\//,""):a},define:function(a,b){var c=a.replace(/^define\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){d=d[1];var e=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(e,""),b.define.push({name:d,properties:"("+e+")"}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"import":function(a,b,c){if("undefined"!=typeof window)throw new Error("import cannot be used in a browser");var d=a.replace(/^import\s*/,"");if("("===utils.findNextToken(d)){var e=utils.getParamList(d);if(d=d.replace(e,"").replace(/^\s*|\s*$/g,""),";"===utils.findNextToken(d)&&(d=d.replace(/\s*;/,"")),e=e.replace(/[\(|\)]/g,"").split(","),1===e.length){if(e=utils.resolve(b.file||process.cwd(),e[0].replace(/["|']/g,"")),-1===indexOf(b.loaded,e)){var f=b.file;b.file=e,c(fs.readFileSync(e,"utf8"),topLevelTokens,b),b.loaded.push(e),b.file=f}return d}throw new Error("import accepts a single file")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(d)+"'")},global:function(a,b){var c=a.replace(/^global\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*\s*)/);if(d){if(c=c.replace(d[0],"").replace(/^\s*|\s*$/g,""),"="===utils.findNextToken(c)){d=d[1].replace(/^\s+|\s+$/g,"");var e=utils.getTokensBetween(c,"=",";",!0).join(""),f=e.substring(1,e.length-1);if(f=f.replace(/^\s+|\s+$/g,""),/^require\(/.test(f)){var g=utils.getParamList(f.replace("require")).replace(/[\(|\)]/g,"").split(",");1===g.length&&(g=g[0].replace(/["|']/g,""),f=["require('",utils.resolve(b.file||process.cwd(),g),"')"].join(""))}return b.scope.push({name:d,body:f}),c=c.replace(e,"")}throw new Error("unexpected token : expected : '=' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},"function":function(a,b){var c=a.replace(/^function\s*/,""),d=c.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*/);if(d){if(c=c.replace(d[0],""),"("===utils.findNextToken(c)){d=d[1];var e=utils.getParamList(c);if(c=c.replace(e,"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(c)){var f=utils.getTokensBetween(c,"{","}",!0).join("");return c=c.replace(f,""),b.scope.push({name:d,body:"function"+e+f}),c}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(c)+"'")}throw new Error("unexpected token : expected : '(' found : '"+utils.findNextToken(c)+"'")}throw new Error("missing name")},rule:function(a,b,c){var d=a.replace(/^rule\s*/,""),e=d.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*|"[^"]*"|'[^']*')/);if(e){if(d=d.replace(e[0],"").replace(/^\s*|\s*$/g,""),"{"===utils.findNextToken(d)){e=e[1].replace(/^["']|["']$/g,"");var f={name:e,options:{},constraints:null,action:null},g=utils.getTokensBetween(d,"{","}",!0).join("");return d=d.replace(g,""),c(g.replace(/^\{\s*|\}\s*$/g,""),ruleTokens,f),b.rules.push(f),d}throw new Error("unexpected token : expected : '{' found : '"+utils.findNextToken(d)+"'")}throw new Error("missing name")}};module.exports=topLevelTokens},{"../../extended":12,"./util.js":37,__browserify_process:54,fs:51}],37:[function(a,b,c){var d=a("__browserify_process"),e=a("path"),f=/[\s|\n|\r|\t]/,g=e.sep||("win32"===d.platform?"\\":"/"),h={"{":"}","}":"{","(":")",")":"(","[":"]"},i=c.getTokensBetween=function(a,b,c,d){var e=0,f=[];b||(b=h[c],e=1),c||(c=h[b]),a=Object(a);for(var g,i=!1,j=0,k=!1;g=a.charAt(j++);)if(g===b)e++,i?f.push(g):(i=!0,d&&f.push(g));else if(g===c&&j){if(e--,0===e){d&&f.push(g),k=!0;break}f.push(g)}else i&&f.push(g);if(!k)throw new Error("Unable to match "+b+" in "+a);return f};c.getParamList=function(a){return i(a,"(",")",!0).join("")},c.resolve=function(a,b){return""!==e.extname(a)&&(a=e.dirname(a)),1===b.split(g).length?b:e.resolve(a,b)};var j=c.findNextTokenIndex=function(a,b,c){b=b||0,c=c||a.length;var d=-1,e=a.length;for((!c||c>e)&&(c=e);c>b;b++){var g=a.charAt(b);if(!f.test(g)){d=b;break}}return d};c.findNextToken=function(a,b,c){return a.charAt(j(a,b,c))}},{__browserify_process:54,path:52}],38:[function(a,b,c){"use strict";var d=a("./extended"),e=d.isEmpty,f=d.merge,g=d.forEach,h=d.declare,i=a("./constraintMatcher"),j=a("./constraint"),k=j.EqualityConstraint,l=0,m=h({}),n=m.extend({instance:{constructor:function(a,b,c,d,h){h=h||{},this.id=l++,this.type=a,this.alias=b,this.conditions=c,this.pattern=h.pattern;var k=[new j.ObjectConstraint(a)],m=i.toConstraints(c,f({alias:b},h));if(m.length)k=k.concat(m);else{var n=new j.TrueConstraint;k.push(n)}if(d&&!e(d)){var o=new j.HashConstraint(d);k.push(o)}g(k,function(a){a.set("alias",b)}),this.constraints=k},getSpecificity:function(){for(var a=this.constraints,b=0,c=0,d=a.length;d>c;c++)a[c]instanceof k&&b++;return b},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions)].join(":")},toString:function(){return d.format("%j",this.constraints)}}}).as(c,"ObjectPattern"),o=n.extend({instance:{constructor:function(a,b,c,d,e,f){this._super([a,b,c,d,f]),this.from=e.from},hasConstraint:function(a){return d.some(this.constraints,function(b){return b instanceof a})},getSpecificity:function(){return this._super(arguments)+1},hashCode:function(){return[this.type,this.alias,d.format("%j",this.conditions),this.from.from].join(":")},toString:function(){return d.format("%j from %s",this.constraints,this.from.from)}}}).as(c,"FromPattern");o.extend().as(c,"FromNotPattern"),n.extend().as(c,"NotPattern"),m.extend({instance:{constructor:function(a,b){this.id=l++,this.leftPattern=a,this.rightPattern=b},hashCode:function(){return[this.leftPattern.hashCode(),this.rightPattern.hashCode()].join(":")},getSpecificity:function(){return this.rightPattern.getSpecificity()+this.leftPattern.getSpecificity()},getters:{constraints:function(){return this.leftPattern.constraints.concat(this.rightPattern.constraints)}}}}).as(c,"CompositePattern");var p=h({constuctor:function(){this.id=l++}}).as(c,"InitialFact");n.extend({instance:{constructor:function(){this._super([p,"i",[],{}])},assert:function(){return!0}}}).as(c,"InitialFactPattern")},{"./constraint":8,"./constraintMatcher":9,"./extended":12}],39:[function(a,b,c){"use strict";function d(a,b,c,d){f(b)?(d=c,c=b):b=b||{};var g=e.every(c,function(a){return f(a)});g&&1===c.length&&(c=c[0],g=!1);var h=[],i=b.scope||{};if(c.scope=i,g){for(var j,k=function(a,b){m[b]?e(m).forEach(function(b){b.push(a)}):(m[b]=0===b?[]:m[b-1].slice(),0!==b&&m[b].pop(),m[b].push(a))},l=c.length,m=[],n=0;l>n;n++)j=c[n],j.scope=i,e.forEach(w(j),k);h=e.map(m,function(c){for(var e=null,f=0;f>>0;if(0===d)return-1;var e=d;arguments.length>2&&(e=Number(arguments[2]),e!==e?e=0:0!==e&&e!==1/0&&e!==-(1/0)&&(e=(e>0||-1)*P(Q(e))));for(var f=e>=0?R(e,d-1):d-Q(e);f>=0;f--)if(f in c&&c[f]===b)return f;return-1}function i(a,b,c){if(a&&X&&X===a.filter)return a.filter(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)if(g in d){var h=d[g];b.call(c,h,g,d)&&f.push(h)}return f}function j(a,b,c){if(!N(a)||"function"!=typeof b)throw new TypeError;if(a&&T&&T===a.forEach)return a.forEach(b,c),a;for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);return a}function k(a,b,c){if(a&&Y&&Y===a.every)return a.every(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&!b.call(c,d[f],f,d))return!1;return!0}function l(a,b,c){if(a&&Z&&Z===a.some)return a.some(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=0;e>f;f++)if(f in d&&b.call(c,d[f],f,d))return!0;return!1}function m(a,b,c){if(a&&U&&U===a.map)return a.map(b,c);if(!N(a)||"function"!=typeof b)throw new TypeError;for(var d=Object(a),e=d.length>>>0,f=[],g=0;e>g;g++)g in d&&f.push(b.call(c,d[g],g,d));return f}function n(a,b,c){var d=arguments.length>2;if(a&&V&&V===a.reduce)return d?a.reduce(b,c):a.reduce(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=0,f=a.length>>0;if(arguments.length<3){if(0===f)throw new TypeError("Array length is 0 and no second argument");c=a[0],e=1}else c=arguments[2];for(;f>e;)e in a&&(c=b.call(void 0,c,a[e],e,a)),++e;return c}function o(a,b,c){var d=arguments.length>2;if(a&&W&&W===a.reduceRight)return d?a.reduceRight(b,c):a.reduceRight(b);if(!N(a)||"function"!=typeof b)throw new TypeError;var e=Object(a),f=e.length>>>0;if(0===f&&2===arguments.length)throw new TypeError;var g=f-1;if(arguments.length>=3)c=arguments[2];else for(;;)if(g in a){c=a[g--];break}for(;g>=0;)g in e&&(c=b.call(void 0,c,e[g],g,e)),g--;return c}function p(a){var c=[];if(null!==a){var d=$(arguments);if(1===d.length)if(N(a))c=a;else if(b.isHash(a))for(var e in a)a.hasOwnProperty(e)&&c.push([e,a[e]]);else c.push(a);else j(d,function(a){c=c.concat(p(a))})}return c}function q(a){return a=a||[],a.length?n(a,function(a,b){return a+b}):0}function r(a){if(a=a||[],a.length){var c=q(a);if(b.isNumber(c))return c/a.length;throw new Error("Cannot average an array of non numbers.")}return 0}function s(a,b){return _(a,b)}function t(a,b){return _(a,b)[0]}function u(a,b){return _(a,b)[a.length-1]}function v(a){var b=a,c=J($(arguments,1));return N(a)&&(b=i(a,function(a){return-1===g(c,a)})),b}function w(a){var b,c=[],d=-1,e=0;if(a)for(b=a.length;++d0?(c.push(c.shift()),b--):(c.unshift(c.pop()),b++),y(c,b)):c}function z(a,b){var c=[];if(N(a)){var d=a.slice(0);"number"!=typeof b&&(b=a.length),b?b<=a.length&&(c=n(a,function(a,c,f){var g;return g=b>1?e(c,y(d,f).slice(1),b):[[c]],a.concat(g)},[])):c=[[]]}return c}function A(){var a=[],c=$(arguments);if(c.length>1){var d=c.shift();N(d)&&(a=n(d,function(a,d,e){for(var f=[d],g=0;gd;d++)c.push(a[b[d]]||null);return c}function D(){var a=[],b=$(arguments);if(b.length>1){for(var c=0,d=b.length;d>c;c++)a=a.concat(b[c]);a=w(a)}return a}function E(){var a,b,c=[],d=-1;if(a=arguments.length>1?$(arguments):arguments[0],N(a))for(c=a[0],d=0,b=a.length;++d1?c:p(a),n(b,function(a,b){return a.concat(b)},[])}function K(a,b){b=b.split(".");var c=a.slice(0);return j(b,function(a){var b=a.match(/(\w+)\(\)$/);c=m(c,function(c){return b?c[b[1]]():c[a]})}),c}function L(a,b,c){return c=$(arguments,2),m(a,function(a){var d=M(b)?a[b]:b;return d.apply(a,c)})}var M=b.isString,N=Array.isArray||b.isArray,O=b.isDate,P=Math.floor,Q=Math.abs,R=(Math.max,Math.min),S=Array.prototype,T=(S.indexOf,S.forEach),U=S.map,V=S.reduce,W=S.reduceRight,X=S.filter,Y=S.every,Z=S.some,$=c.argsToArray,_=function(){var a=function(a,b){return k(a,b)},b=function(a,b){return a-b},c=function(a,b){return a.getTime()-b.getTime()};return function(d,e){var f=[];return N(d)&&(f=d.slice(),e?"function"==typeof e?f.sort(e):f.sort(function(a,b){var c=a[e],d=b[e];return M(c)&&M(d)?c>d?1:d>c?-1:0:O(c)&&O(d)?c.getTime()-d.getTime():c-d}):a(f,M)?f.sort():a(f,O)?f.sort(c):f.sort(b)),f}}(),ab={toArray:p,sum:q,avg:r,sort:s,min:t,max:u,difference:v,removeDuplicates:w,unique:x,rotate:y,permutations:z,zip:A,transpose:B,valuesAt:C,union:D,intersect:E,powerSet:F,cartesian:G,compact:H,multiply:I,flatten:J,pluck:K,invoke:L,forEach:j,map:m,filter:i,reduce:n,reduceRight:o,some:l,every:k,indexOf:g,lastIndexOf:h};return a.define(N,ab).expose(ab)}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.arrayExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":41,extended:46,"is-extended":56}],43:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c,d){a=""+a,c=c||" ";for(var e=a.length;b>e;)d?a+=c:a=c+a,e++;return a}function e(a,c,d){var f=a;if(b.isString(f)){if(a.length>c)if(d){var g=a.length;f=a.substring(g-c,g)}else f=a.substring(0,c)}else f=e(""+f,c);return f}function f(a,c,d){if(!b.isArray(a)||"function"!=typeof c)throw new TypeError; +for(var e=Object(a),f=e.length>>>0,g=0;f>g;g++)if(g in e&&!c.call(d,e[g],g,e))return!1;return!0}function g(a,b){return A.difference(new Date(a.getFullYear(),0,1,a.getHours()),a,null,b)+1}function h(a,b,c){b=b||0;var d=a[c?"getUTCFullYear":"getFullYear"](),e=new Date(d,0,1).getDay(),f=(e-b+7)%7,h=o((g(a)+f-1)/7);return e===b&&h++,h}function i(a){var b=a.toString(),c="",d=b.indexOf("(");return d>-1&&(c=b.substring(++d,b.indexOf(")"))),c}function j(a,b){return a.replace(/([a-z])\1*/gi,function(a){var c,d=a.charAt(0),e=a.length,f="0?",g="0{0,2}";if("y"===d)c="\\d{2,4}";else if("M"===d)c=e>2?"\\S+?":"1[0-2]|"+f+"[1-9]";else if("D"===d)c="[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|"+g+"[1-9][0-9]|"+f+"[1-9]";else if("d"===d)c="3[01]|[12]\\d|"+f+"[1-9]";else if("w"===d)c="[1-4][0-9]|5[0-3]|"+f+"[1-9]";else if("E"===d)c="\\S+";else if("h"===d)c="1[0-2]|"+f+"[1-9]";else if("K"===d)c="1[01]|"+f+"\\d";else if("H"===d)c="1\\d|2[0-3]|"+f+"\\d";else if("k"===d)c="1\\d|2[0-4]|"+f+"[1-9]";else if("m"===d||"s"===d)c="[0-5]\\d";else if("S"===d)c="\\d{"+e+"}";else if("a"===d){var h="AM",i="PM";c=h+"|"+i,h!==h.toLowerCase()&&(c+="|"+h.toLowerCase()),i!==i.toLowerCase()&&(c+="|"+i.toLowerCase()),c=c.replace(/\./g,"\\.")}else c="v"===d||"z"===d||"Z"===d||"G"===d||"q"===d||"Q"===d?".*":" "===d?"\\s*":d+"*";return b&&b.push(a),"("+c+")"}).replace(/[\xa0 ]/g,"[\\s\\xa0]")}function k(a){B[a+"sFromNow"]=function(b){return A.add(new Date,a,b)},B[a+"sAgo"]=function(b){return A.add(new Date,a,-b)}}for(var l=function(){function a(a,b,c){return a=a.replace(/s$/,""),e.hasOwnProperty(a)?e[a](b,c):[c,"UTC"+a.charAt(0).toUpperCase()+a.substring(1)+"s",!1]}function b(a,b,c,e){return a=a.replace(/s$/,""),d(f[a](b,c,e))}var c=Math.floor,d=Math.round,e={day:function(a,b){return[b,"Date",!1]},weekday:function(a,b){var c,d,e=b%5,f=a.getDay(),g=0;e?(c=e,d=parseInt(b/5,10)):(c=b>0?5:-5,d=b>0?(b-5)/5:(b+5)/5),6===f&&b>0?g=1:0===f&&0>b&&(g=-1);var h=f+c;return(0===h||6===h)&&(g=b>0?2:-2),[7*d+c+g,"Date",!1]},year:function(a,b){return[b,"FullYear",!0]},week:function(a,b){return[7*b,"Date",!1]},quarter:function(a,b){return[3*b,"Month",!0]},month:function(a,b){return[b,"Month",!0]}},f={quarter:function(a,b,d){var e=b.getFullYear()-a.getFullYear(),f=a[d?"getUTCMonth":"getMonth"](),g=b[d?"getUTCMonth":"getMonth"](),h=c(f/3)+1,i=c(g/3)+1;return i+=4*e,i-h},weekday:function(a,c,d){var e,f=b("day",a,c,d),g=f%7;if(0===g)f=5*b("week",a,c,d);else{var h=0,i=a[d?"getUTCDay":"getDay"](),j=c[d?"getUTCDay":"getDay"]();e=parseInt(f/7,10);var k=new Date(+a);k.setDate(k[d?"getUTCDate":"getDate"]()+7*e);var l=k[d?"getUTCDay":"getDay"]();f>0?6===i||6===j?h=-1:0===i?h=0:(0===j||l+g>5)&&(h=-2):0>f&&(6===i?h=0:0===i||0===j?h=1:(6===j||0>l+g)&&(h=2)),f+=h,f-=2*e}return f},year:function(a,b){return b.getFullYear()-a.getFullYear()},month:function(a,b,c){var d=a[c?"getUTCMonth":"getMonth"](),e=b[c?"getUTCMonth":"getMonth"]();return e-d+12*(b.getFullYear()-a.getFullYear())},week:function(a,c,e){return d(b("day",a,c,e)/7)},day:function(a,b){return 1.1574074074074074e-8*(b.getTime()-a.getTime())},hour:function(a,b){return 2.7777777777777776e-7*(b.getTime()-a.getTime())},minute:function(a,b){return 16666666666666667e-21*(b.getTime()-a.getTime())},second:function(a,b){return.001*(b.getTime()-a.getTime())},millisecond:function(a,b){return b.getTime()-a.getTime()}};return{addTransform:a,differenceTransform:b}}(),m=l.addTransform,n=l.differenceTransform,o=Math.floor,p=Math.round,q=Math.min,r=Math.pow,s=Math.ceil,t=Math.abs,u=["January","February","March","April","May","June","July","August","September","October","November","December"],v=["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y=["Before Christ","Anno Domini"],z=["BC","AD"],A={getDaysInMonth:function(a){var b=a.getMonth(),c=[31,28,31,30,31,30,31,31,30,31,30,31];return 1===b&&A.isLeapYear(a)?29:c[b]},isLeapYear:function(a,b){var c=a[b?"getUTCFullYear":"getFullYear"]();return 0===c%400||0===c%4&&0!==c%100},isWeekend:function(a,b){var c=(a||new Date)[b?"getUTCDay":"getDay"]();return 0===c||6===c},getTimezoneName:i,compare:function(a,b,c){return a=new Date(+a),b=new Date(+(b||new Date)),"date"===c?(a.setHours(0,0,0,0),b.setHours(0,0,0,0)):"time"===c&&(a.setFullYear(0,0,0),b.setFullYear(0,0,0)),a>b?1:b>a?-1:0},add:function(a,b,c){var d=m(b,a,c||0);c=d[0];var e=d[1],f=new Date(+a),g=d[2];return e&&f["set"+e](f["get"+e]()+c),g&&f.getDate()E?z:y)[0>f?0:1];else if("y"===D)B=f,E>1&&(2===E?B=e(""+B,2,!0):C=!0);else if("Q"===D.toUpperCase())B=s((j+1)/3),C=!0;else if("M"===D)3>E?(B=j+1,C=!0):B=(3===E?v:u)[j];else if("w"===D)B=h(a,0,c),C=!0;else if("D"===D)B=g(a,c),C=!0;else if("E"===D)3>E?(B=k+1,C=!0):B=(-3===E?x:w)[k];else if("a"===D)B=12>m?"AM":"PM";else if("h"===D)B=m%12||12,C=!0;else if("K"===D)B=m%12,C=!0;else if("k"===D)B=m||24,C=!0;else if("S"===D)B=p(A*r(10,E-3)),C=!0;else if("z"===D||"v"===D||"Z"===D){if(B=i(a),"z"!==D&&"v"!==D||B||(E=4),!B||"Z"===D){var F=a.getTimezoneOffset(),G=[F>=0?"-":"+",d(o(t(F)/60),2,"0"),d(t(F)%60,2,"0")];4===E&&(G.splice(0,0,"GMT"),G.splice(3,0,":")),B=G.join("")}}else B=b;else B=""+n,C=!0;else B=""+m,C=!0;return C&&(B=d(B,E,"0")),B})}},B={},C=["year","month","day","hour","minute","second"],D=0,E=C.length;E>D;D++)k(C[D]);var F={parseDate:function(a,b){if(!b)throw new Error("format required when calling dateExtender.parse");var d=[],e=j(b,d),g=new RegExp("^"+e+"$","i"),h=g.exec(a);if(!h)return null;var i=[1970,0,1,0,0,0,0],k="",l=f(h,function(a,b){if(b){var e=d[b-1],f=e.length,g=e.charAt(0);if("y"===g)if(100>a){a=parseInt(a,10);var h=""+(new Date).getFullYear(),j=100*h.substring(0,2),l=q(h.substring(2,4)+20,99);i[0]=l>a?j+a:j-100+a}else i[0]=a;else if("M"===g){if(f>2){var m,n,o=u;3===f&&(o=v),a=a.replace(".","").toLowerCase();var p=!1;for(m=0,n=o.length;n>m&&!p;m++){var r=o[m].replace(".","").toLocaleLowerCase();r===a&&(a=m,p=!0)}if(!p)return!1}else a--;i[1]=a}else if("E"===g||"e"===g){var s=w;3===f&&(s=x),a=a.toLowerCase(),s=c.map(s,function(a){return a.toLowerCase()});var t=c.indexOf(s,a);if(-1===t){if(a=parseInt(a,10),isNaN(a)||a>s.length)return!1}else a=t}else if("D"===g||"d"===g)"D"===g&&(i[1]=0),i[2]=a;else if("a"===g){var y="am",z="pm",A=/\./g;a=a.replace(A,"").toLowerCase(),k=a===z?"p":a===y?"a":""}else"k"===g||"h"===g||"H"===g||"K"===g?("k"===g&&24===+a&&(a=0),i[3]=a):"m"===g?i[4]=a:"s"===g?i[5]=a:"S"===g&&(i[6]=a)}return!0});if(l){var m=+i[3];"p"===k&&12>m?i[3]=m+12:"a"===k&&12===m&&(i[3]=0);var n=new Date(i[0],i[1],i[2],i[3],i[4],i[5],i[6]),o=-1!==c.indexOf(d,"d"),p=-1!==c.indexOf(d,"M"),r=i[1],s=i[2],t=n.getMonth(),y=n.getDate();return p&&t>r||o&&y>s?null:n}return null}},G=a.define(b.isDate,A).define(b.isString,F).define(b.isNumber,B);for(D in A)A.hasOwnProperty(D)&&(G[D]=A[D]);for(D in F)F.hasOwnProperty(D)&&(G[D]=F[D]);for(D in B)B.hasOwnProperty(D)&&(G[D]=B[D]);return G}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.dateExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":42,extended:46,"is-extended":56}],44:[function(a,b,c){!function(){function a(){function a(a,b){return b=b||0,x.call(a,b)}function b(a){return"[object Array]"===Object.prototype.toString.call(a)}function c(a){var b;return null!==a&&a!==b&&"object"==typeof a}function d(a){var b=c(a);return b&&a.constructor===Object}function e(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function f(a,b,c){var d,f;for(d in b)b.hasOwnProperty(d)&&-1===e(c,d)&&(f=b[d],d in a&&a[d]===f||(a[d]=f));return a}function g(a){var c=this.__meta,d=c.supers,e=d.length,f=c.superMeta,g=f.pos;if(e>g){a=a?B(a)||b(a)?a:[a]:[];var h,i=f.name,j=f.f;do if(h=d[g][i],"function"==typeof h&&(h=h._f||h)!==j)return f.pos=1+g,h.apply(this,a);while(e>++g)}return null}function h(){var a=this.__meta,b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.bind(this);while(c>++e)}return null}function i(a){var b=this.__getters__;return b.hasOwnProperty(a)?b[a].apply(this):this[a]}function j(b,c){var e=this.__setters__;if(!d(b))return e.hasOwnProperty(b)?e[b].apply(this,a(arguments,1)):this[b]=c;for(var f in b){var g=b[f];e.hasOwnProperty(f)?e[b].call(this,g):this[f]=g}}function k(){var a=this.__meta||{},b=a.supers,c=b.length,d=a.superMeta,e=d.pos;if(c>e){var f,g=d.name,h=d.f;do if(f=b[e][g],"function"==typeof f&&(f=f._f||f)!==h)return d.pos=1+e,f.apply(this,arguments);while(c>++e)}return null}function l(a,b){if(a.toString().match(A)){var c=function(){var c,d=this.__meta||{},e=d.superMeta;switch(d.superMeta={f:a,pos:0,name:b},arguments.length){case 0:c=a.call(this);break;case 1:c=a.call(this,arguments[0]);break;case 2:c=a.call(this,arguments[0],arguments[1]);break;case 3:c=a.call(this,arguments[0],arguments[1],arguments[2]);break;default:c=a.apply(this,arguments)}return d.superMeta=e,c};return c._f=a,c}return a._f=a,a}function m(a,b){var c=b.setters||{},d=a.__setters__,e=a.__getters__;for(var f in c)d.hasOwnProperty(f)||(d[f]=c[f]);c=b.getters||{};for(f in c)e.hasOwnProperty(f)||(e[f]=c[f]);for(var g in b)if("getters"!==g&&"setters"!==g){var h=b[g];"function"==typeof h?a.hasOwnProperty(g)||(a[g]=l(k,g)):a[g]=h}}function n(){for(var b=a(arguments),c=b.length,d=this.prototype,e=d.__meta,f=this.__meta,g=d.__meta.bases,h=g.slice(),i=f.supers||[],j=e.supers||[],k=0;c>k;k++){var l=b[k],n=l.prototype,p=n.__meta,q=l.__meta;!p&&(p=n.__meta={proto:n||{}}),!q&&(q=l.__meta={proto:l.__proto__||{}}),m(d,p.proto||{}),m(this,q.proto||{}),o(l.prototype,j,g),o(l,i,h)}return this}function o(a,b,c){var d=a.__meta;!d&&(d=a.__meta={});var f=a.__meta.unique;if(!f&&(d.unique="declare"+ ++y),-1===e(c,f)){c.push(f);for(var g=a.__meta.supers||[],h=g.length-1||0;h>=0;)o(g[h--],b,c);b.unshift(a)}}function p(a,b){var c=b.setters,d=a.__setters__,e=a.__getters__;if(c)for(var f in c)d[f]=c[f];if(c=b.getters||{})for(f in c)e[f]=c[f];for(f in b)if("getters"!=f&&"setters"!=f){var g=b[f];if("function"==typeof g){var h=g.__meta||{};a[f]=h.isConstructor?g:l(g,f)}else a[f]=g}}function q(a,b){return a&&b?a[b]=this:a.exports=a=this,this}function r(a){return u(this,a)}function s(a){z.prototype=a.prototype;var b=new z;return z.prototype=null,b}function t(a,c,e){var i={},j=[],m="declare"+ ++y,q=[],r=[],t=[],u=[],v={supers:t,unique:m,bases:q,superMeta:{f:null,pos:0,name:null}},x={supers:u,unique:m,bases:r,isConstructor:!0,superMeta:{f:null,pos:0,name:null}};if(d(c)&&!e&&(e=c,c=w),"function"==typeof c||b(c)?(j=b(c)?c:[c],c=j.shift(),a.__meta=x,i=s(c),i.__meta=v,i.__getters__=f({},i.__getters__||{}),i.__setters__=f({},i.__setters__||{}),a.__getters__=f({},a.__getters__||{}),a.__setters__=f({},a.__setters__||{}),o(c.prototype,t,q),o(c,u,r)):(a.__meta=x,i.__meta=v,i.__getters__=i.__getters__||{},i.__setters__=i.__setters__||{},a.__getters__=a.__getters__||{},a.__setters__=a.__setters__||{}),a.prototype=i,e){var z=v.proto=e.instance||{},A=x.proto=e.static||{};A.init=A.init||k,p(i,z),p(a,A),i.constructor=z.hasOwnProperty("constructor")?l(z.constructor,"constructor"):z.constructor=l(k,"constructor")}else v.proto={},x.proto={},a.init=l(k,"init"),i.constructor=l(k,"constructor");j.length&&n.apply(a,j),c&&f(a,f(f({},c),a)),i._super=a._super=g,i._getSuper=a._getSuper=h,i._static=a}function u(a,b){function c(){switch(arguments.length){case 0:this.constructor.call(this);break;case 1:this.constructor.call(this,arguments[0]);break;case 2:this.constructor.call(this,arguments[0],arguments[1]);break;case 3:this.constructor.call(this,arguments[0],arguments[1],arguments[2]);break;default:this.constructor.apply(this,arguments)}}return t(c,a,b),c.init()||c}function v(a,b){function c(){return d||(this.constructor.apply(this,arguments),d=this),d}var d;return t(c,a,b),c.init()||c}var w,x=Array.prototype.slice,y=0,z=new Function,A=/(super)/g,B=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};return B(arguments)||(B=function(a){return!(!a||!a.hasOwnProperty("callee"))}),w=u({instance:{get:i,set:j},"static":{get:i,set:j,mixin:n,extend:r,as:q}}),u.singleton=v,u}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=a()):"function"==typeof define&&define.amd?define(a):this.declare=a()}()},{}],45:[function(a,b){b.exports=a("./declare.js")},{"./declare.js":44}],46:[function(a,b,c){!function(){"use strict";function d(a){function b(){var b=a.define();return b.expose({register:function(a,c){c||(c=a,a=null);var d=typeof c;if(a)b[a]=c;else if(c&&"function"===d)b.extend(c);else{if("object"!==d)throw new TypeError("extended.register must be called with an extender function");b.expose(c)}return b},define:function(){return a.define.apply(a,arguments)}}),b}function c(){return b()}return function(){function a(a,b){var c,d;for(c in b)b.hasOwnProperty(c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}return function(b){b||(b={});for(var c=1,d=arguments.length;d>c;c++)a(b,arguments[c]);return b}}(),c.define=function(){return a.define.apply(a,arguments)},c}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extender"))):"function"==typeof define&&define.amd?define(["extender"],function(a){return d(a)}):this.extended=d(this.extender)}.call(this)},{extender:48}],47:[function(a,b,c){!function(){function d(a){function b(a,b){if(a&&a.length)for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(b){function c(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);a.unshift(this._value);var b=c.apply(this,a);return b!==e?this.__extender__(b):this},a[b]=d}function d(a,b,c){if("function"!=typeof c)throw new TypeError("when extending type you must provide a function");var d;d="constructor"===b?function(){this._super(arguments),c.apply(this,arguments)}:function(){var a=f.call(arguments);return a.unshift(this._value),c.apply(this,a)},a[b]=d}function h(a,b,e){for(var f in b)b.hasOwnProperty(f)&&("getters"!==f&&"setters"!==f?"noWrap"===f?h(a,b[f],!0):e?d(a,f,b[f]):c(a,f,b[f]):a[f]=b[f])}function i(a){var b,c,d=a;if(!(a instanceof m)){var e=m;for(b=0,c=n.length;c>b;b++){var f=n[b];f[0](a)&&(e=e.extend({instance:f[1]}))}d=new e(a),d.__extender__=i}return d}function j(){return!0}function k(a,b){if(arguments.length){"object"==typeof a&&(b=a,a=j),b=b||{};var d={};h(d,b),d.hasOwnProperty("constructor")||(b.hasOwnProperty("constructor")?c(d,"constructor",b.constructor):d.constructor=function(){this._super(arguments)}),n.push([a,d])}return i}function l(a){return a&&a.hasOwnProperty("__defined__")&&(i.__defined__=n=n.concat(a.__defined__)),g(i,a,["define","extend","expose","__defined__"]),i}b=b||[];var m=a({instance:{constructor:function(a){this._value=a},value:function(){return this._value},eq:function(a){return this.__extender__(this._value===a)},neq:function(a){return this.__extender__(this._value!==a)},print:function(){return console.log(this._value),this}}}),n=[];return i.define=k,i.extend=l,i.expose=function(){for(var a,b=0,c=arguments.length;c>b;b++)a=arguments[b],"object"==typeof a&&g(i,a,["define","extend","expose","__defined__"]);return i},i.__defined__=n,i}var e,f=Array.prototype.slice,g=function(){function a(a,c,d){var e,f;for(e in c)c.hasOwnProperty(e)&&-1===b(d,e)&&(f=c[e],e in a&&a[e]===f||(a[e]=f));return a}return function(b){b||(b={});var d=arguments.length,e=arguments[arguments.length-1];c(e)?d--:e=[];for(var f=1;d>f;f++)a(b,arguments[f],e);return b}}();return{define:function(){return d().define.apply(d,arguments)},extend:function(a){return d().define().extend(a)}}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("declare.js"))):"function"==typeof define&&define.amd?define(["declare"],function(a){return d(a)}):this.extender=d(this.declare)}.call(this)},{"declare.js":45}],48:[function(a,b){b.exports=a("./extender.js")},{"./extender.js":47}],49:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b,c){if(c=o(arguments,2),m(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!m(b)&&!n(b))throw new Error(b+" is not a function");return m(b)?function(){var d=a[b];if(n(d)){var e=c.concat(o(arguments));return d.apply(a,e)}return d}:c.length?function(){var d=c.concat(o(arguments));return b.apply(a,d)}:function(){return b.apply(a,arguments)}}function e(a,b){if(b=o(arguments,1),!m(a)&&!n(a))throw new Error(a+" must be the name of a property or function to execute");return m(a)?function(){var c=o(arguments),d=c.shift(),e=d[a];return n(e)?(c=b.concat(c),e.apply(d,c)):e}:function(){var c=o(arguments),d=c.shift();return c=b.concat(c),a.apply(d,c)}}function f(a,b,c){if(c=o(arguments,2),m(b)&&!(b in a))throw new Error(b+" property not defined in scope");if(!m(b)&&!n(b))throw new Error(b+" is not a function");return m(b)?function(){var d=a[b];return n(d)?d.apply(a,c):d}:function(){return b.apply(a,c)}}function g(a){var b=o(arguments,1);if(!l(a)&&!n(a))throw new TypeError("scope must be an object");if(1===b.length&&k(b[0])&&(b=b[0]),!b.length){b=[];for(var c in a)a.hasOwnProperty(c)&&n(a[c])&&b.push(c)}for(var e=0,f=b.length;f>e;e++)a[b[e]]=d(a,a[b[e]]);return a}function h(a,b){if(b=o(arguments,1),!m(a)&&!n(a))throw new Error(a+" must be the name of a property or function to execute");return m(a)?function(){var c=this[a];if(n(c)){var d=b.concat(o(arguments));return c.apply(this,d)}return c}:function(){var c=b.concat(o(arguments));return a.apply(this,c)}}function i(a,b){return function(){var c=o(arguments);return b?a.apply(this,arguments):function(){return a.apply(this,c.concat(o(arguments)))}}}function j(a,b,c){var e;if(e=c?d(c,b):b,a)for(var f=a-1,g=f;g>=0;g--)e=i(e,g===f);return e}var k=b.isArray,l=b.isObject,m=b.isString,n=b.isFunction,o=c.argsToArray;return a.define(l,{bind:d,bindAll:g,bindIgnore:f,curry:function(a,b,c){return j(b,c,a)}}).define(n,{bind:function(a,b){return d.apply(this,[b,a].concat(o(arguments,2)))},bindIgnore:function(a,b){return f.apply(this,[b,a].concat(o(arguments,2)))},partial:h,applyFirst:e,curry:function(a,b,c){return j(b,a,c)},noWrap:{f:function(){return this.value()}}}).define(m,{bind:function(a,b){return d(b,a)},bindIgnore:function(a,b){return f(b,a)},partial:h,applyFirst:e,curry:function(a,b,c){return j(b,a,c)}}).expose({bind:d,bindAll:g,bindIgnore:f,partial:h,applyFirst:e,curry:j})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","arguments-extended"],function(a,b,c){return d(a,b,c)}):this.functionExtended=d(this.extended,this.isExtended,this.argumentsExtended)}.call(this)},{"arguments-extended":41,extended:46,"is-extended":56}],50:[function(a,b,c){function d(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;ce;e++)d[e].apply(this,c);return!0}return!1},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var e=d(c,b);if(0>e)return this;c.splice(e,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},f.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0}},{__browserify_process:54}],51:[function(){},{}],52:[function(a,b,c){function d(a,b){for(var c=[],d=0;d=0;d--){var e=a[d];"."==e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var f=a("__browserify_process"),g=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){for(var a="",b=!1,c=arguments.length;c>=-1&&!b;c--){var g=c>=0?arguments[c]:f.cwd();"string"==typeof g&&g&&(a=g+"/"+a,b="/"===g.charAt(0))}return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b="/"===a.charAt(0),c="/"===a.slice(-1);return a=e(d(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){return a&&"string"==typeof a}).join("/"))},c.dirname=function(a){var b=g.exec(a)[1]||"",c=!1;return b?1===b.length||c&&b.length<=3&&":"===b.charAt(1)?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=g.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return g.exec(a)[3]||""},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i=0;e--)if(f[e]!=g[e])return!1;for(e=f.length-1;e>=0;e--)if(d=f[e],!h(a[d],b[d]))return!1;return!0}function l(a,b){return a&&b?b instanceof RegExp?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function m(a,b,c,d){var e;"string"==typeof c&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f("Missing expected exception"+d),!a&&l(e,c)&&f("Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util"),o=a("buffer").Buffer,p=Array.prototype.slice,q=b.exports=g;q.AssertionError=function(a){this.name="AssertionError",this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var b=a.stackStartFunction||f;Error.captureStackTrace&&Error.captureStackTrace(this,b)},n.inherits(q.AssertionError,Error),q.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",e(JSON.stringify(this.actual,d),128),this.operator,e(JSON.stringify(this.expected,d),128)].join(" ")},q.AssertionError.__proto__=Error.prototype,q.fail=f,q.ok=g,q.equal=function(a,b,c){a!=b&&f(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",q.notStrictEqual)},q.throws=function(){m.apply(this,[!0].concat(p.call(arguments)))},q.doesNotThrow=function(){m.apply(this,[!1].concat(p.call(arguments)))},q.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(a,b,c){function d(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&d(a.__proto__)}function e(a){return a instanceof RegExp||"object"==typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function f(a){if(a instanceof Date)return!0;if("object"!=typeof a)return!1;var b=Date.prototype&&h(Date.prototype),c=a.__proto__&&h(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}a("events"),c.isArray=d,c.isDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,i,j){function k(a,i){if(a&&"function"==typeof a.inspect&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(i);switch(typeof a){case"undefined":return m("undefined","undefined");case"string":var j="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return m(j,"string");case"number":return m(""+a,"number");case"boolean":return m(""+a,"boolean")}if(null===a)return m("null","null");var n=g(a),o=b?h(a):n;if("function"==typeof a&&0===o.length){if(e(a))return m(""+a,"regexp");var p=a.name?": "+a.name:"";return m("[Function"+p+"]","special")}if(f(a)&&0===o.length)return m(a.toUTCString(),"date");var q,r,s;if(d(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]),"function"==typeof a){var t=a.name?": "+a.name:"";q=e(a)?" "+a:" [Function"+t+"]"}else q="";if(f(a)&&(q=" "+a.toUTCString()),0===o.length)return s[0]+q+s[1];if(0>i)return e(a)?m(""+a,"regexp"):m("[Object]","special");l.push(a);var u=o.map(function(b){var c,e;if(a.__lookupGetter__&&(a.__lookupGetter__(b)?e=a.__lookupSetter__(b)?m("[Getter/Setter]","special"):m("[Getter]","special"):a.__lookupSetter__(b)&&(e=m("[Setter]","special"))),n.indexOf(b)<0&&(c="["+b+"]"),e||(l.indexOf(a[b])<0?(e=null===i?k(a[b]):k(a[b],i-1),e.indexOf("\n")>-1&&(e=d(a)?e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=m("[Circular]","special")),"undefined"==typeof c){if("Array"===r&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=m(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=m(c,"string"))}return c+": "+e});l.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return u=w>50?s[0]+(""===q?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:s[0]+q+" "+u.join(", ")+" "+s[1]}var l=[],m=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return j||(m=function(a){return a}),k(a,"undefined"==typeof i?2:i)},c.log=function(){},c.pump=null;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},i=Object.create||function(a,b){var c;if(null===a)c={__proto__:null};else{if("object"!=typeof a)throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return"undefined"!=typeof b&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=i(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})};var j=/%[sdj%]/g;c.format=function(a){if("string"!=typeof a){for(var b=[],d=0;d=f)return a;switch(a){case"%s":return String(e[d++]);case"%d":return Number(e[d++]);case"%j":return JSON.stringify(e[d++]);default:return a}}),h=e[d];f>d;h=e[++d])g+=null===h||"object"!=typeof h?" "+h:" "+c.inspect(h);return g}},{events:4}],5:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d) +},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],6:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(a,b,c){!function(a){function b(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;cf;f++)d[f].apply(this,c);return!0}return!1},d.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(e(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:f,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},d.prototype.removeListener=function(a,c){if("function"!=typeof c)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var d=this._events[a];if(e(d)){var f=b(d,c);if(0>f)return this;d.splice(f,1),0==d.length&&delete this._events[a]}else this._events[a]===c&&delete this._events[a];return this},d.prototype.removeAllListeners=function(a){return 0===arguments.length?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},d.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),e(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(a,b){b.exports=a("q9TxCC")},{}],q9TxCC:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used=a.length?0:(c?(e=a.parent[a.offset+b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8*(d?1-f:f)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>8*(d?3-f:f)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fthis.length)throw new Error("oob");if(b>c)throw new Error("oob");for(var d=b;c>d;d++)this[d]=a},c.SlowBuffer=d,c.Buffer=l,l.poolSize=8192;var E;l.isBuffer=function(a){return a instanceof l||a instanceof d},l.concat=function(a,b){if(!Array.isArray(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new l(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;cd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=c.length?void 0:c.parent[c.offset+a]},l.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},l.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},l.prototype.readUInt32LE=function(a,b){return p(this,a,!1,b)},l.prototype.readUInt32BE=function(a,b){return p(this,a,!0,b)},l.prototype.readInt8=function(a,b){var c,d=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=d.length?void 0:(c=128&d.parent[d.offset+a],c?-1*(255-d.parent[d.offset+a]+1):d.parent[d.offset+a])},l.prototype.readInt16LE=function(a,b){return q(this,a,!1,b)},l.prototype.readInt16BE=function(a,b){return q(this,a,!0,b)},l.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},l.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},l.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},l.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},l.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},l.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},l.prototype.writeUInt8=function(a,b,c){var d=this;c||(D.ok(void 0!==a&&null!==a,"missing value"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],8:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],3:[function(a,b,c){function d(a){this.length=a}function e(a){return 16>a?"0"+a.toString(16):a.toString(16)}function f(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function j(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function k(a){return a=~~Math.ceil(+a),0>a?0:a}function l(a,b,c){if(!(this instanceof l))return new l(a,b,c);var e;if("number"==typeof c)this.length=k(b),this.parent=a,this.offset=c;else{switch(e=typeof a){case"number":this.length=k(a);break;case"string":this.length=l.byteLength(a,b);break;case"object":this.length=k(a.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new d(this.length),this.offset=0):((!E||E.length-E.used>>0):(e=a.parent[a.offset+b+2]<<16,e|=a.parent[a.offset+b+1]<<8,e|=a.parent[a.offset+b],e+=a.parent[a.offset+b+3]<<24>>>0),e}function q(a,b,c,d){var e,f;return d||(D.ok("boolean"==typeof c,"missing or invalid endian"),D.ok(void 0!==b&&null!==b,"missing offset"),D.ok(b+1=0,"specified a negative value for writing an unsigned value"),D.ok(b>=a,"value is larger than maximum value for type"),D.ok(Math.floor(a)===a,"value has a fractional component")}function v(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1>>8,a.parent[a.offset+c+1]=255&b):(a.parent[a.offset+c+1]=(65280&b)>>>8,a.parent[a.offset+c]=255&b)}function w(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3>>24,a.parent[a.offset+c+1]=255&b>>>16,a.parent[a.offset+c+2]=255&b>>>8,a.parent[a.offset+c+3]=255&b):(a.parent[a.offset+c+3]=255&b>>>24,a.parent[a.offset+c+2]=255&b>>>16,a.parent[a.offset+c+1]=255&b>>>8,a.parent[a.offset+c]=255&b)}function x(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value"),D.ok(Math.floor(a)===a,"value has a fractional component")}function y(a,b,c){D.ok("number"==typeof a,"cannot write a non-number as a number"),D.ok(b>=a,"value larger than maximum allowed value"),D.ok(a>=c,"value smaller than minimum allowed value")}function z(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+1=0?v(a,b,c,d,e):v(a,65535+b+1,c,d,e)}function A(a,b,c,d,e){e||(D.ok(void 0!==b&&null!==b,"missing value"),D.ok("boolean"==typeof d,"missing or invalid endian"),D.ok(void 0!==c&&null!==c,"missing offset"),D.ok(c+3=0?w(a,b,c,d,e):w(a,4294967295+b+1,c,d,e)}function B(b,c,d,e,f){f||(D.ok(void 0!==c&&null!==c,"missing value"),D.ok("boolean"==typeof e,"missing or invalid endian"),D.ok(void 0!==d&&null!==d,"missing offset"),D.ok(d+3d;d++)if(a[d]=e(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},d.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",f=a;b>f;f++)d+=e(this[f]);return d},d.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},d.prototype.hexWrite=function(a,b,c){b=+b||0;var e=this.length-b;c?(c=+c,c>e&&(c=e)):c=e;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return d._charsWritten=2*g,g},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},d.prototype.slice=function(a,b){if(void 0===b&&(b=this.length),b>this.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this,b-a,+a)},d.prototype.copy=function(a,b,c,d){for(var e=[],f=c;d>f;f++)D.ok("undefined"!=typeof this[f],"copying undefined buffer bytes!"),e.push(this[f]);for(var f=b;fd;d++)if(a[d]=e(this.parent[d+this.offset]),d==c.INSPECT_MAX_BYTES){a[d+1]="..."; +break}return""},l.prototype.get=function(a){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]},l.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this.parent[this.offset+a]=b},l.prototype.write=function(a,b,c,e){if(isFinite(b))isFinite(c)||(e=c,c=void 0);else{var f=e;e=b,b=c,c=f}b=+b||0;var g=this.length-b;c?(c=+c,c>g&&(c=g)):c=g,e=String(e||"utf8").toLowerCase();var h;switch(e){case"hex":h=this.parent.hexWrite(a,this.offset+b,c);break;case"utf8":case"utf-8":h=this.parent.utf8Write(a,this.offset+b,c);break;case"ascii":h=this.parent.asciiWrite(a,this.offset+b,c);break;case"binary":h=this.parent.binaryWrite(a,this.offset+b,c);break;case"base64":h=this.parent.base64Write(a,this.offset+b,c);break;case"ucs2":case"ucs-2":h=this.parent.ucs2Write(a,this.offset+b,c);break;default:throw new Error("Unknown encoding")}return l._charsWritten=d._charsWritten,h},l.prototype.toString=function(a,b,c){switch(a=String(a||"utf8").toLowerCase(),"undefined"==typeof b||0>b?b=0:b>this.length&&(b=this.length),"undefined"==typeof c||c>this.length?c=this.length:0>c&&(c=0),b+=this.offset,c+=this.offset,a){case"hex":return this.parent.hexSlice(b,c);case"utf8":case"utf-8":return this.parent.utf8Slice(b,c);case"ascii":return this.parent.asciiSlice(b,c);case"binary":return this.parent.binarySlice(b,c);case"base64":return this.parent.base64Slice(b,c);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},l.byteLength=d.byteLength,l.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),"number"!=typeof a||isNaN(a))throw new Error("value is not a number");if(b>c)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");return this.parent.fill(a,b+this.offset,c+this.offset)},l.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");return d>this.length&&(d=this.length),a.length-bthis.length)throw new Error("oob");if(a>b)throw new Error("oob");return new l(this.parent,b-a,+a+this.offset)},l.prototype.utf8Slice=function(a,b){return this.toString("utf8",a,b)},l.prototype.binarySlice=function(a,b){return this.toString("binary",a,b)},l.prototype.asciiSlice=function(a,b){return this.toString("ascii",a,b)},l.prototype.utf8Write=function(a,b){return this.write(a,b,"utf8")},l.prototype.binaryWrite=function(a,b){return this.write(a,b,"binary")},l.prototype.asciiWrite=function(a,b){return this.write(a,b,"ascii")},l.prototype.readUInt8=function(a,b){var c=this;return b||(D.ok(void 0!==a&&null!==a,"missing offset"),D.ok(a=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},l.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!1,c)},l.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!0,c)},l.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!1,c)},l.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!0,c)},l.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!1,c)},l.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!0,c)},l.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!1,c)},l.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!0,c)},d.prototype.readUInt8=l.prototype.readUInt8,d.prototype.readUInt16LE=l.prototype.readUInt16LE,d.prototype.readUInt16BE=l.prototype.readUInt16BE,d.prototype.readUInt32LE=l.prototype.readUInt32LE,d.prototype.readUInt32BE=l.prototype.readUInt32BE,d.prototype.readInt8=l.prototype.readInt8,d.prototype.readInt16LE=l.prototype.readInt16LE,d.prototype.readInt16BE=l.prototype.readInt16BE,d.prototype.readInt32LE=l.prototype.readInt32LE,d.prototype.readInt32BE=l.prototype.readInt32BE,d.prototype.readFloatLE=l.prototype.readFloatLE,d.prototype.readFloatBE=l.prototype.readFloatBE,d.prototype.readDoubleLE=l.prototype.readDoubleLE,d.prototype.readDoubleBE=l.prototype.readDoubleBE,d.prototype.writeUInt8=l.prototype.writeUInt8,d.prototype.writeUInt16LE=l.prototype.writeUInt16LE,d.prototype.writeUInt16BE=l.prototype.writeUInt16BE,d.prototype.writeUInt32LE=l.prototype.writeUInt32LE,d.prototype.writeUInt32BE=l.prototype.writeUInt32BE,d.prototype.writeInt8=l.prototype.writeInt8,d.prototype.writeInt16LE=l.prototype.writeInt16LE,d.prototype.writeInt16BE=l.prototype.writeInt16BE,d.prototype.writeInt32LE=l.prototype.writeInt32LE,d.prototype.writeInt32BE=l.prototype.writeInt32BE,d.prototype.writeFloatLE=l.prototype.writeFloatLE,d.prototype.writeFloatBE=l.prototype.writeFloatBE,d.prototype.writeDoubleLE=l.prototype.writeDoubleLE,d.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}]},{},[]),b.exports=a("buffer-browserify")},{}],54:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],55:[function(a,b,c){!function(){"use strict";function d(a){var b=function(a){return"string"==typeof a?a:"object"==typeof a?a.hashCode?a.hashCode():""+a:""+a},c=a.declare({instance:{constructor:function(){this.__entries=[],this.__keys=[],this.__values=[]},pushValue:function(a,b){return this.__keys.push(a),this.__values.push(b),this.__entries.push({key:a,value:b}),b},remove:function(a){for(var b,c=null,d=this.__entries,e=this.__keys,f=this.__values,g=d.length-1;g>=0;g--)if((b=d[g])&&b.key===a)return d.splice(g,1),e.splice(g,1),f.splice(g,1),b.value;return c},set:function(a,b){for(var c=null,d=this.__entries,e=this.__values,f=d.length-1;f>=0;f--){var g=d[f];if(g&&a===g.key){e[f]=b,g.value=b,c=b;break}}return c||d.push({key:a,value:b}),c},find:function(a){for(var b,c=null,d=this.__entries,e=d.length-1;e>=0;e--)if(b=d[e],b&&a===b.key){c=b.value;break}return c},getEntrySet:function(){return this.__entries},getKeys:function(){return this.__keys},getValues:function(){return this.__values}}});return a.declare({instance:{constructor:function(){this.__map={}},entrySet:function(){var a=[],b=this.__map;for(var c in b)b.hasOwnProperty(c)&&(a=a.concat(b[c].getEntrySet()));return a},put:function(a,d){var e=b(a),f=null;return(f=this.__map[e])||(f=this.__map[e]=new c),f.pushValue(a,d),d},remove:function(a){var c=b(a),d=null,e=this.__map[c];return e&&(d=e.remove(a)),d},get:function(a){var c,d=b(a),e=null;return(c=this.__map[d])&&(e=c.find(a)),e},set:function(a,d){var e=b(a),f=null,g=null,h=this.__map;return f=(g=h[e])?g.set(a,d):(h[e]=new c).pushValue(a,d)},contains:function(a){var c=b(a),d=!1,e=null;return(e=this.__map[c])&&(d=!!e.find(a)),d},concat:function(a){if(a instanceof this._static){for(var b=new this._static,c=a.entrySet().concat(this.entrySet()),d=c.length-1;d>=0;d--){var e=c[d];b.put(e.key,e.value)}return b}throw new TypeError("When joining hashtables the joining arg must be a HashTable")},filter:function(b,c){var d=this.entrySet(),e=new this._static;d=a.filter(d,b,c);for(var f=d.length-1;f>=0;f--){var g=d[f];e.put(g.key,g.value)}return e},forEach:function(b,c){var d=this.entrySet();a.forEach(d,b,c)},every:function(b,c){var d=this.entrySet();return a.every(d,b,c)},map:function(b,c){var d=this.entrySet();return a.map(d,b,c)},some:function(b,c){var d=this.entrySet();return a.some(d,b,c)},reduce:function(b,c){var d=this.entrySet();return a.reduce(d,b,c)},reduceRight:function(b,c){var d=this.entrySet();return a.reduceRight(d,b,c)},clear:function(){this.__map={}},keys:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getKeys());return a},values:function(){var a=[],b=this.__map;for(var c in b)a=a.concat(b[c].getValues());return a},isEmpty:function(){return 0===this.keys().length}}})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")))):"function"==typeof define?define(["extended","declare","is-extended","array-extended"],function(a,b,c,e){return d(a().register("declare",b).register(c).register(e))}):this.Ht=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended))}.call(this)},{"array-extended":42,"declare.js":45,extended:46,"is-extended":56}],56:[function(a,b,c){var d=a("__browserify_Buffer").Buffer;!function(){"use strict";function e(a){function b(a,b){var c=-1,d=0,e=a.length,f=[];for(b=b||0,c+=b;++c=0;f--)if(g[f]!==h[f])return!1;for(f=g.length-1;f>=0;f--)if(d=g[f],!e(a[d],b[d]))return!1}catch(i){return!1}return!0}function g(a){return null!==a&&"object"==typeof a}function h(a){var b=g(a);return b&&a.constructor===Object&&!a.nodeType&&!a.setInterval}function i(a){return W(a)?0===a.length:g(a)?0===c(a).length:r(a)||X(a)?0===a.length:!0}function j(a){return a===!0||a===!1||"[object Boolean]"===U.call(a)}function k(a){return"undefined"==typeof a}function l(a){return!k(a)}function m(a){return k(a)||n(a)}function n(a){return null===a}function o(a,b){return V(b)?a instanceof b:!1}function p(a){return"[object RegExp]"===U.call(a)}function q(a){return"[object Date]"===U.call(a)}function r(a){return"[object String]"===U.call(a)}function s(a){return"[object Number]"===U.call(a)}function t(a){return a===!0}function u(a){return a===!1}function v(a){return!n(a)}function w(a,b){return a==b}function x(a,b){return a!=b}function y(a,b){return a===b}function z(a,b){return a!==b}function A(a,b){if(X(b)&&Array.prototype.indexOf||r(b))return b.indexOf(a)>-1;if(X(b))for(var c=0,d=b.length;d>c;c++)if(w(a,b[c]))return!0;return!1}function B(a,b){return!A(a,b)}function C(a,b){return b>a}function D(a,b){return b>=a}function E(a,b){return a>b}function F(a,b){return a>=b}function G(a,b){return r(b)?null!==(""+a).match(b):p(b)?b.test(a):!1}function H(a,b){return!G(a,b)}function I(a,b){return A(b,a)}function J(a,b){return!A(b,a)}function K(a,b,c){return X(a)&&a.length>c?w(a[c],b):!1}function L(a,b,c){return X(a)?!w(a[c],b):!1}function M(a,b){return T.call(a,b)}function N(a,b){return!M(a,b)}function O(a,b){return M(a,"length")?a.length===b:!1}function P(a,b){return M(a,"length")?a.length!==b:!1}function Q(a){Z[a]=function(){this._testers.push(Y[a])}}function R(a){$[a]=function(){var c,d=b(arguments,1),e=Y[a],f=!0;if(d.length<=e.length-1)throw new TypeError("A handler must be defined when calling using switch");if(c=d.pop(),j(c)&&(f=c,c=d.pop()),!V(c))throw new TypeError("handler must be defined");this._cases.push(function(a){return e.apply(Y,a.concat(d))?[f,c.apply(this,a)]:[!1]})}}var S=Array.prototype.slice,T=Object.prototype.hasOwnProperty,U=Object.prototype.toString,V=function(a){return"[object Function]"===U.call(a)};"undefined"==typeof window||V(window.alert)||function(a){V=function(b){return"[object Function]"===U.call(b)||b===a}}(window.alert);var W=function(a){return"[object Arguments]"===U.call(a)};W(arguments)||(W=function(a){return!(!a||!T.call(a,"callee"))});var X=Array.isArray||function(a){return"[object Array]"===U.call(a)},Y={isFunction:V,isObject:g,isEmpty:i,isHash:h,isNumber:s,isString:r,isDate:q,isArray:X,isBoolean:j,isUndefined:k,isDefined:l,isUndefinedOrNull:m,isNull:n,isArguments:W,instanceOf:o,isRegExp:p,deepEqual:e,isTrue:t,isFalse:u,isNotNull:v,isEq:w,isNeq:x,isSeq:y,isSneq:z,isIn:A,isNotIn:B,isLt:C,isLte:D,isGt:E,isGte:F,isLike:G,isNotLike:H,contains:I,notContains:J,has:M,notHas:N,isLength:O,isNotLength:P,containsAt:K,notContainsAt:L},Z={constructor:function(){this._testers=[]},noWrap:{tester:function(){var a=this._testers;return function(b){for(var c=!1,d=0,e=a.length;e>d&&!c;d++)c=a[d](b);return c}}}},$={constructor:function(){this._cases=[],this.__default=null},def:function(a,b){this.__default=b},noWrap:{switcher:function(){var a=this._cases,c=this.__default;return function(){for(var d,e=!1,f=b(arguments),g=0,h=a.length;h>g&&!e;g++)if(d=a[g](f),d.length>1&&(d[1]||d[0]))return d[1];return!e&&c?c.apply(this,f):void 0}}}};for(var _ in Y)T.call(Y,_)&&(R(_),Q(_));var ab=a.define(Y).expose(Y);return ab.tester=a.define(Z),ab.switcher=a.define($),ab}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("extended"))):"function"==typeof define&&define.amd?define(["extended"],function(a){return e(a)}):this.isExtended=e(this.extended)}.call(this)},{__browserify_Buffer:53,extended:46}],57:[function(a,b,c){!function(){"use strict";function d(a){function b(a,b){var c=0;return a>b?1:b>a?-1:b?c:1}var c=a.multiply,d=a.declare({instance:{__printNode:function(b,d){var e=[];a.isUndefinedOrNull(b)?(e.push(c(" ",d)),e.push("~"),console.log(e.join(""))):(this.__printNode(b.right,d+1),e.push(c(" ",d)),e.push(b.data+"\n"),console.log(e.join("")),this.__printNode(b.left,d+1))},constructor:function(a){a=a||{},this.compare=a.compare||b,this.__root=null},insert:function(){throw new Error("Not Implemented")},remove:function(){throw new Error("Not Implemented")},clear:function(){this.__root=null},isEmpty:function(){return!this.__root},traverseWithCondition:function(a,b,c){var e=!0;return a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.IN_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.right,b,c)))):b===d.POST_ORDER?(e=this.traverseWithCondition(a.left,b,c),e&&(e&&(e=this.traverseWithCondition(a.right,b,c)),e&&(e=c(a.data)))):b===d.REVERSE_ORDER&&(e=this.traverseWithCondition(a.right,b,c),e&&(e=c(a.data),e&&(e=this.traverseWithCondition(a.left,b,c))))),e},traverse:function(a,b,c){a&&(b=b||d.PRE_ORDER,b===d.PRE_ORDER?(c(a.data),this.traverse(a.left,b,c),this.traverse(a.right,b,c)):b===d.IN_ORDER?(this.traverse(a.left,b,c),c(a.data),this.traverse(a.right,b,c)):b===d.POST_ORDER?(this.traverse(a.left,b,c),this.traverse(a.right,b,c),c(a.data)):b===d.REVERSE_ORDER&&(this.traverse(a.right,b,c),c(a.data),this.traverse(a.left,b,c)))},forEach:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this,this.traverse(this.__root,c,function(c){a.call(b,c,this)})},map:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){e.insert(a.call(b,c,this))}),e},filter:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=new this._static;return this.traverse(this.__root,c,function(c){a.call(b,c,this)&&e.insert(c)}),e},reduce:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduce.apply(a,f)},reduceRight:function(b,c,d){var e=this.toArray(d),f=[e,b];return a.isUndefinedOrNull(c)||f.push(c),a.reduceRight.apply(a,f)},every:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e=!1;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this)}),e},some:function(a,b,c){if("function"!=typeof a)throw new TypeError;c=c||d.IN_ORDER,b=b||this;var e;return this.traverseWithCondition(this.__root,c,function(c){return e=a.call(b,c,this),!e}),e},toArray:function(a){a=a||d.IN_ORDER;var b=[];return this.traverse(this.__root,a,function(a){b.push(a)}),b},contains:function(a){for(var b=!1,c=this.__root;null!==c;){var d=this.compare(a,c.data);d?c=c[-1===d?"left":"right"]:(b=!0,c=null)}return b},find:function(a){for(var b,c=this.__root;c;){var d=this.compare(a,c.data);if(!d){b=c.data;break}c=c[-1===d?"left":"right"]}return b},findLessThan:function(a,b){var c=[],e=this.compare;return this.traverseWithCondition(this.__root,d.IN_ORDER,function(d){var f=e(a,d);return!b&&0===f||1===f?(c.push(d),!0):!1}),c},findGreaterThan:function(a,b){var c=[],e=this.compare;return this.traverse(this.__root,d.REVERSE_ORDER,function(d){var f=e(a,d);return!b&&0===f||-1===f?(c.push(d),!0):!1}),c},print:function(){this.__printNode(this.__root,0)}},"static":{PRE_ORDER:"pre_order",IN_ORDER:"in_order",POST_ORDER:"post_order",REVERSE_ORDER:"reverse_order"}}),e=function(){var a=Math.abs,b=function(a){return{data:a,balance:0,left:null,right:null}},e=function(a,b,c){var d=a[c];return a[c]=d[b],d[b]=a,d},f=function(a,b,c){return a[c]=e(a[c],c,b),e(a,b,c)},g=function(a,b,c){var d="left"===b?"right":"left",e=a[b],f=e[d];0===f.balance?a.balance=e.balance=0:f.balance===c?(a.balance=-c,e.balance=0):(a.balance=0,e.balance=c),f.balance=0},h=function(a,b){var c="left"===b?"right":"left",d=a[b],h="left"===b?-1:1;return d.balance===h?(a.balance=d.balance=0,a=e(a,c,b)):(g(a,b,h),a=f(a,c,b)),a},i=function(a,b,c){var d="left"===b?"right":"left",h=a[d],i="left"===b?-1:1;return h.balance===-i?(a.balance=h.balance=0,a=e(a,b,d)):h.balance===i?(g(a,d,-i),a=f(a,b,d)):(a.balance=-i,h.balance=i,a=e(a,b,d),c.done=!0),a},j=function(c,d,e,f){if(null===c||void 0===c)c=b(d);else{var g=-1===f(d,c.data)?"left":"right";c[g]=j(c[g],d,e,f),e.done||(c.balance+="left"===g?-1:1,0===c.balance?e.done=!0:a(c.balance)>1&&(c=h(c,g),e.done=!0))}return c},k=function(b,c,d,e){var f,g,h,j;if(b){if(g=e(c,b.data),0===g){var l=b.left,m=b.right;if(!l||!m)return f=l?"left":"right",h=b[f];for(var n=l;null!==(m=n.right);)n=m;b.data=n.data,c=n.data}if(f=-1===e(b.data,c)?"right":"left",b[f]=k(b[f],c,d,e),!d.done){j=b.balance+="left"===f?1:-1;var o=a(j);1===o?d.done=!0:o>1&&(b=i(b,f,d))}}return b};return d.extend({instance:{insert:function(a){var b={done:!1};this.__root=j(this.__root,a,b,this.compare)},remove:function(a){this.__root=k(this.__root,a,{done:!1},this.compare)},__printNode:function(a,b){var d=[];a?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.balance+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),f=function(){function a(a,b){return{data:a,level:b,left:g,right:g}}function b(a){if(0!==a.level&&a.left.level===a.level){var b=a.left;a.left=b.right,b.right=a,a=b}return a}function e(a){if(0!==a.level&&a.right.right.level===a.level){var b=a.right;a.right=b.left,b.left=a,a=b,a.level++}return a}function f(c,d,h){if(c===g)c=a(d,1);else{var i=-1===h(d,c.data)?"left":"right";c[i]=f(c[i],d,h),c=b(c),c=e(c)}return c}var g={level:0,data:null},h=function(a,c,d){var f,i;if(a!==g){var j=d(c,a.data);if(0===j)if(f=a.left,i=a.right,f!==g&&i!==g){for(var k=f;k.right!==g;)k=k.right;a.data=k.data,a.left=h(f,k.data,d)}else a=a[f===g?"right":"left"];else{var l=-1===j?"left":"right";a[l]=h(a[l],c,d)}}if(a!==g){var m=a.level,n=a.left.level,o=a.right.level;(m-1>n||m-1>o)&&(o>--a.level&&(a.right.level=a.level),a=b(a),a=e(a))}return a};return d.extend({instance:{isEmpty:function(){return this.__root===g||this._super(arguments)},insert:function(a){this.__root||(this.__root=g),this.__root=f(this.__root,a,this.compare)},remove:function(a){this.__root=h(this.__root,a,this.compare)},traverseWithCondition:function(a){var b=!0;return a!==g?this._super(arguments):b},traverse:function(a){a!==g&&this._super(arguments)},contains:function(){return this.__root!==g?this._super(arguments):!1},__printNode:function(a,b){var d=[];a&&a.data?(this.__printNode(a.right,b+1),d.push(c(" ",b)),d.push(a.data+":"+a.level+"\n"),console.log(d.join("")),this.__printNode(a.left,b+1)):(d.push(c(" ",b)),d.push("~"),console.log(d.join("")))}}})}(),g=d.extend({instance:{insert:function(a){if(!this.__root)return this.__root={data:a,parent:null,left:null,right:null};for(var b=this.compare,c=this.__root;null!==c;){var d=b(a,c.data);if(!d)return;var e=-1===d?"left":"right",f=c[e];if(!f)return c[e]={data:a,parent:c,left:null,right:null};c=f}},remove:function(a){if(null!==this.__root){for(var b,c={right:this.__root},d=c,e=null,f="right";null!==d[f];){b=d,d=d[f];var g=this.compare(a,d.data);g||(e=d),f=-1===g?"left":"right"}null!==e&&(e.data=d.data,b[b.right===d?"right":"left"]=d[null===d.left?"right":"left"]),this.__root=c.right}}}}),h=function(){var a="RED",b="BLACK",e=function(a){return null!==a&&a.red},f=function(a){return{data:a,red:!0,left:null,right:null}},g=function(a,b,c){if(!a)return f(b);var d=c(b,a.data);if(d){var j=-1===d?"left":"right",k="left"===j?"right":"left";a[j]=g(a[j],b,c);var l=a[j];if(e(l)){var m=a[k];e(m)?(a.red=!0,l.red=!1,m.red=!1):e(l[j])?a=h(a,k):e(l[k])&&(a=i(a,k))}}return a},h=function(a,b){var c="left"===b?"right":"left",d=a[c];return a[c]=d[b],d[b]=a,a.red=!0,d.red=!1,d},i=function(a,b){var c="left"===b?"right":"left";return a[c]=h(a[c],c),h(a,b)},j=function(a,b,c,d){if(a){var f;if(0===d(b,a.data)){if(!a.left||!a.right){var g=a[a.left?"left":"right"];return e(a)?c.done=!0:e(g)&&(g.red=!1,c.done=!0),g}for(var h,i=a.right;null!==i.left;)h=i,i=i.left;h&&(h.left=null),a.data=i.data,b=i.data}f=-1===d(b,a.data)?"left":"right",a[f]=j(a[f],b,c,d),c.done||(a=k(a,f,c))}else c.done=!0;return a},k=function(a,b,c){var d="left"===b?"right":"left",f=a,g=f[d];if(e(g)&&(a=h(a,b),g=f[d]),null!==g)if(e(g.left)||e(g.right)){var j=f.red,k=a===f;f=(e(g[d])?h:i)(f,b),f.red=j,f.left.red=f.right.red=0,k?a=f:a[b]=f,c.done=!0}else e(f)&&(c.done=!0),f.red=0,g.red=1;return a};return d.extend({instance:{insert:function(a){this.__root=g(this.__root,a,this.compare),this.__root.red=!1},remove:function(a){var b={done:!1},c=j(this.__root,a,b,this.compare);return null!==c&&(c.red=0),this.__root=c,a},__printNode:function(d,e){var f=[];d?(this.__printNode(d.right,e+1),f.push(c(" ",e)),f.push((d.red?a:b)+":"+d.data+"\n"),console.log(f.join("")),this.__printNode(d.left,e+1)):(f.push(c(" ",e)),f.push("~"),console.log(f.join("")))}}})}();return{Tree:d,AVLTree:e,AnderssonTree:f,BinaryTree:g,RedBlackTree:h,IN_ORDER:d.IN_ORDER,PRE_ORDER:d.PRE_ORDER,POST_ORDER:d.POST_ORDER,REVERSE_ORDER:d.REVERSE_ORDER}}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended")().register("declare",a("declare.js")).register(a("is-extended")).register(a("array-extended")).register(a("string-extended")))):"function"==typeof define?define(["extended","declare.js","is-extended","array-extended","string-extended"],function(a,b,c,e,f){return d(a().register("declare",b).register(c).register(e).register(f))}):this.leafy=d(this.extended().register("declare",this.declare).register(this.isExtended).register(this.arrayExtended).register(this.stringExtended))}.call(this)},{"array-extended":42,"declare.js":45,extended:46,"is-extended":56,"string-extended":60}],58:[function(a,b,c){!function(){"use strict";function d(a,b,c){function d(a,b){var c,d;for(c in b)t.call(b,c)&&(d=b[c],c in a&&a[c]===d||(a[c]=d));return a}function e(a,b){var c,d,f;for(c in b)t.call(b,c)&&(d=b[c],f=a[c],p(f,d)||(a[c]=r(f)&&r(d)?e(f,d):r(d)?e({},d):d));return a}function f(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)d(a,arguments[b]);return a}function g(a){a||(a={});for(var b=1,c=arguments.length;c>b;b++)e(a,arguments[b]);return a}function h(a,b){var c=a.prototype||a;return f(c,b),a}function i(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e=l(a),f=0,g=e.length;g>f;++f)d=e[f],b.call(c||a,a[d],d,a);return a}function j(a,b,c){if(!r(a)||!u(b))throw new TypeError;for(var d,e,f=l(a),g={},h=0,i=f.length;i>h;++h)d=f[h],e=a[d],b.call(c||a,e,d,a)&&(g[d]=e);return g}function k(a){if(!r(a))throw new TypeError;for(var b=l(a),c=[],d=0,e=b.length;e>d;++d)c.push(a[b[d]]);return c}function l(a){if(!r(a))throw new TypeError;var b=[];for(var c in a)t.call(a,c)&&b.push(c);return b}function m(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d={},e=0,f=c.length;f>e;++e)b=c[e],d[a[b]]=b;return d}function n(a){if(!r(a))throw new TypeError;for(var b,c=l(a),d=[],e=0,f=c.length;f>e;++e)b=c[e],d.push([b,a[b]]);return d}function o(a,b){if(!r(a))throw new TypeError;q(b)&&(b=[b]);for(var c,d=s(l(a),b),e={},f=0,g=d.length;g>f;++f)c=d[f],e[c]=a[c];return e}var p=b.deepEqual,q=b.isString,r=b.isHash,s=c.difference,t=Object.prototype.hasOwnProperty,u=b.isFunction,v={forEach:i,filter:j,invert:m,values:k,toArray:n,keys:l,omit:o},w={extend:h,merge:f,deepMerge:g,omit:o},x=a.define(b.isObject,w).define(r,v).define(b.isFunction,{extend:h}).expose({hash:v}).expose(w),y=x.extend;return x.extend=function(){return 1===arguments.length?y.extend.apply(x,arguments):(h.apply(null,arguments),void 0)},x}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","array-extended"],function(a,b,c){return d(a,b,c)}):this.objectExtended=d(this.extended,this.isExtended,this.arrayExtended)}.call(this)},{"array-extended":42,extended:46,"is-extended":56}],59:[function(a,b,c){var d=a("__browserify_process");!function(){"use strict";function e(a,b,c,e,f,g){function h(a,b){return function(){try{l(a.apply(null,arguments)).addCallback(b).addErrback(b)}catch(c){b.errback(c)}}}function i(a,b,c){var d=(new G).callback();return v(a,function(a){d=d.then(c?a:B(null,a)),c||(d=d.then(function(a){return b.push(a),b}))}),d}function j(a){return!w(a)&&y(a.then)}function k(a){var b=new G;return a.then(A(b,"callback"),A(b,"errback")),b.promise()}function l(a){var b;return a=C(arguments),a.length?1===a.length?(a=a.pop(),j(a)?a.addCallback&&a.addErrback?(b=new G,a.addCallback(b.callback),a.addErrback(b.errback)):b=k(a):b=x(a)&&c.every(a,j)?new H(a,!0).promise():(new G).callback(a)):b=new H(c.map(a,function(a){return l(a)}),!0).promise():b=(new G).callback(a).promise(),b}function m(a,b){return function(){var c=new G,d=C(arguments);return d.push(c.resolve),a.apply(b||this,d),c.promise()}}function n(a){if(x(a))return i(a,[],!1);throw new Error("When calling promise.serial the first argument must be an array")}function o(a){if(x(a))return i(a,[],!0);throw new Error("When calling promise.serial the first argument must be an array")}function p(a,b){a=C(arguments);var c=!1;b=a.pop();var d=l(a);return function(){return c?l(b.apply(this,arguments)):(a=arguments,d.then(A(this,function(){return c=!0,b.apply(this,a)})))}}function q(){return new G}function r(a){return new H(a,!0).promise()}function s(a){return q().errback(a)}function t(a){return q().callback(a)}var u,v=c.forEach,w=e.isUndefinedOrNull,x=e.isArray,y=e.isFunction,z=e.isBoolean,A=f.bind,B=f.bindIgnore,C=g.argsToArray;if("function"==typeof setImmediate)u="undefined"!=typeof window?setImmediate.bind(window):setImmediate;else if("undefined"!=typeof d)u=function(a){d.nextTick(a)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,E={},F=E;D.port1.onmessage=function(){E=E.next;var a=E.task;delete E.task,a()},u=function(a){F=F.next={task:a},D.port2.postMessage(0)}}else u=function(a){setTimeout(a,0)};var G=a({instance:{__fired:!1,__results:null,__error:null,__errorCbs:null,__cbs:null,constructor:function(){this.__errorCbs=[],this.__cbs=[],f.bindAll(this,["callback","errback","resolve","classic","__resolve","addCallback","addErrback"])},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__error?this.__errorCbs:this.__cbs,c=b.length,d=this.__error||this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(this,b)})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=a.callback),this.__fired&&this.__results?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=a.errback),this.__fired&&this.__error?this.__callNextTick(a,this.__error):this.__errorCbs.push(a)),this},callback:function(){return this.__fired||(this.__results=arguments,this.__resolve()),this.promise()},errback:function(){return this.__fired||(this.__error=arguments,this.__resolve()),this.promise()},resolve:function(a){return a?this.errback(a):this.callback.apply(this,C(arguments,1)),this +},classic:function(a){return"function"==typeof a&&(this.addErrback(function(b){a(b)}),this.addCallback(function(){a.apply(this,[null].concat(C(arguments)))})),this},then:function(a,b){var c=new G,d=c;return y(b)&&(d=h(b,c)),this.addErrback(d),y(a)?this.addCallback(h(a,c)):this.addCallback(c),c.promise()},both:function(a){return this.then(a,a)},promise:function(){var a={then:A(this,"then"),both:A(this,"both"),promise:function(){return a}};return v(["addCallback","addErrback","classic"],function(b){a[b]=A(this,function(){return this[b].apply(this,arguments),a})},this),a}}}),H=G.extend({instance:{__results:null,__errors:null,__promiseLength:0,__defLength:0,__firedLength:0,normalizeResults:!1,constructor:function(a,b){this.__errors=[],this.__results=[],this.normalizeResults=z(b)?b:!1,this._super(arguments),a&&a.length?(this.__defLength=a.length,v(a,this.__addPromise,this)):this.__resolve()},__addPromise:function(a,b){a.then(A(this,function(){var a=C(arguments);a.unshift(b),this.callback.apply(this,a)}),A(this,function(){var a=C(arguments);a.unshift(b),this.errback.apply(this,a)}))},__resolve:function(){if(!this.__fired){this.__fired=!0;var a,b=this.__errors.length?this.__errorCbs:this.__cbs,c=b.length,d=this.__errors.length?this.__errors:this.__results;for(a=0;c>a;a++)this.__callNextTick(b[a],d)}},__callNextTick:function(a,b){u(function(){a.apply(null,[b])})},addCallback:function(a){return a&&(j(a)&&a.callback&&(a=A(a,"callback")),this.__fired&&!this.__errors.length?this.__callNextTick(a,this.__results):this.__cbs.push(a)),this},addErrback:function(a){return a&&(j(a)&&a.errback&&(a=A(a,"errback")),this.__fired&&this.__errors.length?this.__callNextTick(a,this.__errors):this.__errorCbs.push(a)),this},callback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__results[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()},errback:function(a){if(this.__fired)throw new Error("Already fired!");var b=C(arguments);return this.normalizeResults&&(b=b.slice(1),b=1===b.length?b.pop():b),this.__errors[a]=b,this.__firedLength++,this.__firedLength===this.__defLength&&this.__resolve(),this.promise()}}});return b.define({isPromiseLike:j}).expose({isPromiseLike:j,when:l,wrap:m,wait:p,serial:n,chain:o,Promise:G,PromiseList:H,promise:q,defer:q,deferredList:r,reject:s,resolve:t})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=e(a("declare.js"),a("extended"),a("array-extended"),a("is-extended"),a("function-extended"),a("arguments-extended"))):"function"==typeof define&&define.amd?define(["declare","extended","array-extended","is-extended","function-extended","arguments-extended"],function(a,b,c,d,f,g){return e(a,b,c,d,f,g)}):this.promiseExtended=e(this.declare,this.extended,this.arrayExtended,this.isExtended,this.functionExtended,this.argumentsExtended)}.call(this)},{__browserify_process:54,"arguments-extended":41,"array-extended":42,"declare.js":45,extended:46,"function-extended":49,"is-extended":56}],60:[function(a,b,c){!function(){"use strict";function d(a,b,c,d){function e(a,b){var c=a;if(x.test(b)){var d=b.match(x),e=d[1],f=d[3],g=d[4];g&&(g=parseInt(g,10),c=c.length0?"+":"")+d),k&&(k=parseInt(k,10),d=d.lengthe;)d?a+=c:a=c+a,e++;return a}function i(a,c,d){var e=a;if(b.isString(e)){if(a.length>c)if(d){var f=a.length;e=a.substring(f-c,f)}else e=a.substring(0,c)}else e=i(""+e,c);return e}function j(a,d){if(d instanceof Array){var h=0,i=d.length;return a.replace(v,function(a,b,j){var k,l;if(!(i>h))return a;if(k=d[h++],"%s"===a||"%d"===a||"%D"===a)l=k+"";else if("%Z"===a)l=k.toUTCString();else if("%j"===a)try{l=s(k)}catch(m){throw new Error("stringExtended.format : Unable to parse json from ",k)}else switch(b=b.replace(/^\[|\]$/g,""),j){case"s":l=e(k,b);break;case"d":l=f(k,b);break;case"j":l=g(k,b);break;case"D":l=c.format(k,b);break;case"Z":l=c.format(k,b,!0)}return l})}if(t(d))return a.replace(w,function(a,h,i){if(i=d[i],!b.isUndefined(i)){if(!h)return""+i;if(b.isString(i))return e(i,h);if(b.isNumber(i))return f(i,h);if(b.isDate(i))return c.format(i,h);if(b.isObject(i))return g(i,h)}return a});var k=u.call(arguments).slice(1);return j(a,k)}function k(a,b){var c=[];return a&&(a.indexOf(b)>0?c=a.replace(/\s+/g,"").split(b):c.push(a)),c}function l(a,b){var c=[];if(b)for(var d=0;b>d;d++)c.push(a);return c.join("")}function m(a,c){var d,e,f;if(c)if(b.isArray(a))for(d=[],e=0,f=a.length;f>e;e++)d.push(m(a[e],c));else if(c instanceof Array)for(d=a,e=0,f=c.length;f>e;e++)d=m(d,c[e]);else c in z&&(d="["+z[c]+"m"+a+"");return d}function n(a,b){return a.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(a){return b&&-1!==d.indexOf(b,a)?a:"\\"+a})}function o(a){return a.replace(/^\s*|\s*$/g,"")}function p(a){return a.replace(/^\s*/,"")}function q(a){return a.replace(/\s*$/,"")}function r(a){return 0===a.length}var s;"undefined"==typeof JSON?function(){function a(a){return 10>a?"0"+a:a}function c(c){return b.isDate(c)?isFinite(c.valueOf())?c.getUTCFullYear()+"-"+a(c.getUTCMonth()+1)+"-"+a(c.getUTCDate())+"T"+a(c.getUTCHours())+":"+a(c.getUTCMinutes())+":"+a(c.getUTCSeconds())+"Z":null:i(c)?c.valueOf():c}function d(a){return j.lastIndex=0,j.test(a)?'"'+a.replace(j,function(a){var b=k[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(a,b){var i,j,k,l,m,n=f,o=b[a];switch(o&&(o=c(o)),"function"==typeof h&&(o=h.call(b,a,o)),typeof o){case"string":return d(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";if(f+=g,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(l=o.length,i=0;l>i;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":f?"[\n"+f+m.join(",\n"+f)+"\n"+n+"]":"["+m.join(",")+"]",f=n,k}if(h&&"object"==typeof h)for(l=h.length,i=0;l>i;i+=1)"string"==typeof h[i]&&(j=h[i],k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));else for(j in o)Object.prototype.hasOwnProperty.call(o,j)&&(k=e(j,o),k&&m.push(d(j)+(f?": ":":")+k));return k=0===m.length?"{}":f?"{\n"+f+m.join(",\n"+f)+"\n"+n+"}":"{"+m.join(",")+"}",f=n,k}}var f,g,h,i=b.tester().isString().isNumber().isBoolean().tester(),j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};s=function(a,b,c){var d;if(f="",g="","number"==typeof c)for(d=0;c>d;d+=1)g+=" ";else"string"==typeof c&&(g=c);if(h=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return e("",{"":a})}}():s=JSON.stringify;var t=b.isHash,u=Array.prototype.slice,v=/%((?:-?\+?.?\d*)?|(?:\[[^\[|\]]*\]))?([sjdDZ])/g,w=/\{(?:\[([^\[|\]]*)\])?(\w+)\}/g,x=/(-?)(\+?)([A-Z|a-z|\W]?)([1-9][0-9]*)?$/,y=/([1-9][0-9]*)$/g,z={bold:1,bright:1,italic:3,underline:4,blink:5,inverse:7,crossedOut:9,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,redBackground:41,greenBackground:42,yellowBackground:43,blueBackground:44,magentaBackground:45,cyanBackground:46,whiteBackground:47,encircled:52,overlined:53,grey:90,black:90},A={SMILEY:"☺",SOLID_SMILEY:"☻",HEART:"♥",DIAMOND:"♦",CLOVE:"♣",SPADE:"♠",DOT:"•",SQUARE_CIRCLE:"◘",CIRCLE:"○",FILLED_SQUARE_CIRCLE:"◙",MALE:"♂",FEMALE:"♀",EIGHT_NOTE:"♪",DOUBLE_EIGHTH_NOTE:"♫",SUN:"☼",PLAY:"►",REWIND:"◄",UP_DOWN:"↕",PILCROW:"¶",SECTION:"§",THICK_MINUS:"▬",SMALL_UP_DOWN:"↨",UP_ARROW:"↑",DOWN_ARROW:"↓",RIGHT_ARROW:"→",LEFT_ARROW:"←",RIGHT_ANGLE:"∟",LEFT_RIGHT_ARROW:"↔",TRIANGLE:"▲",DOWN_TRIANGLE:"▼",HOUSE:"⌂",C_CEDILLA:"Ç",U_UMLAUT:"ü",E_ACCENT:"é",A_LOWER_CIRCUMFLEX:"â",A_LOWER_UMLAUT:"ä",A_LOWER_GRAVE_ACCENT:"à",A_LOWER_CIRCLE_OVER:"å",C_LOWER_CIRCUMFLEX:"ç",E_LOWER_CIRCUMFLEX:"ê",E_LOWER_UMLAUT:"ë",E_LOWER_GRAVE_ACCENT:"è",I_LOWER_UMLAUT:"ï",I_LOWER_CIRCUMFLEX:"î",I_LOWER_GRAVE_ACCENT:"ì",A_UPPER_UMLAUT:"Ä",A_UPPER_CIRCLE:"Å",E_UPPER_ACCENT:"É",A_E_LOWER:"æ",A_E_UPPER:"Æ",O_LOWER_CIRCUMFLEX:"ô",O_LOWER_UMLAUT:"ö",O_LOWER_GRAVE_ACCENT:"ò",U_LOWER_CIRCUMFLEX:"û",U_LOWER_GRAVE_ACCENT:"ù",Y_LOWER_UMLAUT:"ÿ",O_UPPER_UMLAUT:"Ö",U_UPPER_UMLAUT:"Ü",CENTS:"¢",POUND:"£",YEN:"¥",CURRENCY:"¤",PTS:"₧",FUNCTION:"ƒ",A_LOWER_ACCENT:"á",I_LOWER_ACCENT:"í",O_LOWER_ACCENT:"ó",U_LOWER_ACCENT:"ú",N_LOWER_TILDE:"ñ",N_UPPER_TILDE:"Ñ",A_SUPER:"ª",O_SUPER:"º",UPSIDEDOWN_QUESTION:"¿",SIDEWAYS_L:"⌐",NEGATION:"¬",ONE_HALF:"½",ONE_FOURTH:"¼",UPSIDEDOWN_EXCLAMATION:"¡",DOUBLE_LEFT:"«",DOUBLE_RIGHT:"»",LIGHT_SHADED_BOX:"░",MEDIUM_SHADED_BOX:"▒",DARK_SHADED_BOX:"▓",VERTICAL_LINE:"│",MAZE__SINGLE_RIGHT_T:"┤",MAZE_SINGLE_RIGHT_TOP:"┐",MAZE_SINGLE_RIGHT_BOTTOM_SMALL:"┘",MAZE_SINGLE_LEFT_TOP_SMALL:"┌",MAZE_SINGLE_LEFT_BOTTOM_SMALL:"└",MAZE_SINGLE_LEFT_T:"├",MAZE_SINGLE_BOTTOM_T:"┴",MAZE_SINGLE_TOP_T:"┬",MAZE_SINGLE_CENTER:"┼",MAZE_SINGLE_HORIZONTAL_LINE:"─",MAZE_SINGLE_RIGHT_DOUBLECENTER_T:"╡",MAZE_SINGLE_RIGHT_DOUBLE_BL:"╛",MAZE_SINGLE_RIGHT_DOUBLE_T:"╢",MAZE_SINGLE_RIGHT_DOUBLEBOTTOM_TOP:"╖",MAZE_SINGLE_RIGHT_DOUBLELEFT_TOP:"╕",MAZE_SINGLE_LEFT_DOUBLE_T:"╞",MAZE_SINGLE_BOTTOM_DOUBLE_T:"╧",MAZE_SINGLE_TOP_DOUBLE_T:"╤",MAZE_SINGLE_TOP_DOUBLECENTER_T:"╥",MAZE_SINGLE_BOTTOM_DOUBLECENTER_T:"╨",MAZE_SINGLE_LEFT_DOUBLERIGHT_BOTTOM:"╘",MAZE_SINGLE_LEFT_DOUBLERIGHT_TOP:"╒",MAZE_SINGLE_LEFT_DOUBLEBOTTOM_TOP:"╓",MAZE_SINGLE_LEFT_DOUBLETOP_BOTTOM:"╙",MAZE_SINGLE_LEFT_TOP:"Γ",MAZE_SINGLE_RIGHT_BOTTOM:"╜",MAZE_SINGLE_LEFT_CENTER:"╟",MAZE_SINGLE_DOUBLECENTER_CENTER:"╫",MAZE_SINGLE_DOUBLECROSS_CENTER:"╪",MAZE_DOUBLE_LEFT_CENTER:"╣",MAZE_DOUBLE_VERTICAL:"║",MAZE_DOUBLE_RIGHT_TOP:"╗",MAZE_DOUBLE_RIGHT_BOTTOM:"╝",MAZE_DOUBLE_LEFT_BOTTOM:"╚",MAZE_DOUBLE_LEFT_TOP:"╔",MAZE_DOUBLE_BOTTOM_T:"╩",MAZE_DOUBLE_TOP_T:"╦",MAZE_DOUBLE_LEFT_T:"╠",MAZE_DOUBLE_HORIZONTAL:"═",MAZE_DOUBLE_CROSS:"╬",SOLID_RECTANGLE:"█",THICK_LEFT_VERTICAL:"▌",THICK_RIGHT_VERTICAL:"▐",SOLID_SMALL_RECTANGLE_BOTTOM:"▄",SOLID_SMALL_RECTANGLE_TOP:"▀",PHI_UPPER:"Φ",INFINITY:"∞",INTERSECTION:"∩",DEFINITION:"≡",PLUS_MINUS:"±",GT_EQ:"≥",LT_EQ:"≤",THEREFORE:"⌠",SINCE:"∵",DOESNOT_EXIST:"∄",EXISTS:"∃",FOR_ALL:"∀",EXCLUSIVE_OR:"⊕",BECAUSE:"⌡",DIVIDE:"÷",APPROX:"≈",DEGREE:"°",BOLD_DOT:"∙",DOT_SMALL:"·",CHECK:"√",ITALIC_X:"✗",SUPER_N:"ⁿ",SQUARED:"²",CUBED:"³",SOLID_BOX:"■",PERMILE:"‰",REGISTERED_TM:"®",COPYRIGHT:"©",TRADEMARK:"™",BETA:"β",GAMMA:"γ",ZETA:"ζ",ETA:"η",IOTA:"ι",KAPPA:"κ",LAMBDA:"λ",NU:"ν",XI:"ξ",OMICRON:"ο",RHO:"ρ",UPSILON:"υ",CHI_LOWER:"φ",CHI_UPPER:"χ",PSI:"ψ",ALPHA:"α",ESZETT:"ß",PI:"π",SIGMA_UPPER:"Σ",SIGMA_LOWER:"σ",MU:"µ",TAU:"τ",THETA:"Θ",OMEGA:"Ω",DELTA:"δ",PHI_LOWER:"φ",EPSILON:"ε"},B={toArray:k,pad:h,truncate:i,multiply:l,format:j,style:m,escape:n,trim:o,trimLeft:p,trimRight:q,isEmpty:r};return a.define(b.isString,B).define(b.isArray,{style:m}).expose(B).expose({characters:A})}"undefined"!=typeof c?"undefined"!=typeof b&&b.exports&&(b.exports=d(a("extended"),a("is-extended"),a("date-extended"),a("array-extended"))):"function"==typeof define&&define.amd?define(["extended","is-extended","date-extended","array-extended"],function(a,b,c,e){return d(a,b,c,e)}):this.stringExtended=d(this.extended,this.isExtended,this.dateExtended,this.arrayExtended)}.call(this)},{"array-extended":42,"date-extended":43,extended:46,"is-extended":56}]},{},[1]); \ No newline at end of file diff --git a/package.json b/package.json index 07b7425..fbef763 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nools", "description": "A rules engine for node", - "version": "0.1.14", + "version": "0.2.0", "bin": { "nools": "./bin/nools" }, diff --git a/readme.md b/readme.md index fd1ae67..5468ae3 100644 --- a/readme.md +++ b/readme.md @@ -19,7 +19,10 @@ Or [download the source](https://raw.github.com/C2FO/nools/master/nools.js) ([mi * Flows * [Defining A Flow](#flow) * [Sessions](#session) - * [Facts](#facts) + * [Facts](#facts) + * [Assert](#facts-assert) + * [Retract](#facts-retract) + * [Modify](#facts-modify) * [Firing](#firing) * [Disposing](#disposing) * [Removing A Flow](#removing-flow) @@ -33,16 +36,19 @@ Or [download the source](https://raw.github.com/C2FO/nools/master/nools.js) ([mi * [Salience](#rule-salience) * [Scope](#rule-scope) * [Constraints](#constraints) + * [Not](#not-constraint) + * [Or](#or-constraint) + * [From](#from-constraint) * [Actions](#action) * [Globals](#globals) * [Import](#import) * [Browser Support](#browser-support) * [Fibonacci](#fib) - - -The [examples](https://github.com/C2FO/nools/tree/master/examples) and [tests](https://github.com/C2FO/nools/tree/master/test) are a -great place to get started. You can ask your questions on the [Nools Google group](https://groups.google.com/forum/#!forum/nools). +## Resources + * [Nools Google group](https://groups.google.com/forum/#!forum/nools) + * [Examples](http://c2fo.github.io/nools/examples.html) + * [Tests](https://github.com/C2FO/nools/tree/master/test) ## Defining a flow @@ -236,8 +242,10 @@ var session = flow.getSession(); Facts are items that the rules should try to match. + +### Assert -To add facts to the session use **assert** method. +To add facts to the session use `assert` method. ```javascript session.assert(new Message("hello")); @@ -247,11 +255,16 @@ session.assert(new Message("goodbye")); As a convenience any object passed into **getSession** will also be asserted. +**Note** assert is typically used pre engine execution and during the execution of the rules. + ```javascript flow.getSession(new Message("hello"), new Message("hello world"), new Message("goodbye")); ``` -To retract facts from the session use the **retract** method. + +### Retract + +To remove facts from the session use the `retract` method. ```javascript var m = new Message("hello"); @@ -264,7 +277,13 @@ session.retract(m); ``` -To modify a fact use the **modify** method. +**Note** `retract` is typically used during the execution of the rules. + + +### Modify + + +To modify a fact use the `modify` method. **Note** modify will not work with immutable objects (i.e. strings). @@ -280,9 +299,7 @@ session.modify(m); ``` -**assert** is typically used pre engine execution and during the execution of the rules. - -**modify** and **retract** are typically used during the execution of the rules. +**Note** `modify` is typically used during the execution of the rules. @@ -762,6 +779,43 @@ this.rule("Hello1", {salience: 10}, [Message, "m", "m.name == 'Hello'"], functio }); ``` +Or using the DSL + +```javascript +rule Hello4 { + salience: 7; + when { + m: Message m.name == 'hello'; + } + then {} +} + +rule Hello3 { + salience: 8; + when { + m: Message m.name == 'hello'; + } + then {} +} + +rule Hello2 { + salience: 9; + when { + m: Message m.name == 'hello'; + } + then {} +} + +rule Hello1 { + salience: 10; + when { + m: Message m.name == 'hello'; + } + then {} +} + +``` + In the above flow we define four rules each with a different salience, when a single message is asserted they will fire in order of salience (highest to lowest). ```javascript @@ -935,6 +989,123 @@ when { 4. Reference(optional) - An object where the keys are properties on the current object, and values are aliases to use. The alias may be used in succeeding patterns. + +#### Not Constraint + +The `not` constraint allow you to check that particular `fact` does **not** exist. + +```javascript + +[ + [Number, "n1"], + ["not", Number, "n2", "n1 > n2"] +] + +``` + +Or using the DSL. + +``` + +when { + n1: Number; + not(n2: Number n1 > n2); +} + +``` + +The previous example will check that for all numbers in the `workingMemory` there is **not** one that is greater than `n1`. + + +#### Or Constraint + +The `or` constraint can be used to check for either one fact or another. + +```javascript + +[ + ["or", + [String, "s", "s == 'hello'"], + [String, "s", "s == 'world'"] + ] +] + +``` + +Using the DSL. + +``` +when { + or( + s : String s == 'hello', + s : String s == 'world' + ); +} +``` + +The previous example will evaluate to `true` if you have a string in `workingMemory` that equals `hello` or `world. + + + +#### From Constraint + +The `from` modifier allows for the checking of facts that are not necessarily in the `workingMemory` but instead exist as a property on a fact. + +```javascript +[ + [Person, "p"], + [Address, "a", "a.zipcode == 88847", "from p.address"], + [String, "first", "first == 'bob'", "from p.firstName"], + [String, "last", "last == 'yukon'", "from p.lastName"] +] +``` + +Or using the DSL. + +``` +when { + p: Person: + a: Address a.zipcode == 88847 from p.address; + first: String first == 'bob' from p.firstName; + last: String last == 'yukon' from p.lastName; +} +``` + +The above example will used the address, firstName and lastName from the `person` fact. + +You can also use the `from` modifier to check facts that create a graph. + +For example assume the person object from above has friends that are also of type `Person`. + +```javascript +[ + [Person, "p"], + [Person, "friend", "friend.firstName != p.firstName", "from p.friends"], + [String, "first", "first =~ /^a/", "from friend.firstName"] +] +``` + +Or using the DSL. + +``` +when { + p: Person; + friend: Person friend.firstName != p.firstName; + first: String first =~ /^a/ from friend.firstName; +} +``` + +The above example will pull the `friend` fact from the friends array property on fact `p`, and first from the `friend`'s `firstName`. + +You could achieve the same thing using the following code if you assert all friends into working memory. + +``` +when { + p: Person; + friend: Person friend in p.friends && friend.firstName != p.firstName && p.firstName =~ /^a/; +} +``` + ### Action diff --git a/test/constraintMatcher.test.js b/test/constraintMatcher.test.js index 75899ff..5899f29 100644 --- a/test/constraintMatcher.test.js +++ b/test/constraintMatcher.test.js @@ -1,6 +1,8 @@ "use strict"; var it = require("it"), - assert = require("assert"), parser = require("../lib/parser"), constraintMatcher = require("../lib/constraintMatcher"); + assert = require("assert"), + parser = require("../lib/parser"), + constraintMatcher = require("../lib/constraintMatcher"); it.describe("constraint matcher", function (it) { diff --git a/test/flow.test.js b/test/flow.test.js index b0e2ecb..42d27b3 100644 --- a/test/flow.test.js +++ b/test/flow.test.js @@ -139,37 +139,14 @@ it.describe("Flow", function (it) { }); - it.describe("errors", function (it) { - - var HelloFact = declare({ - instance: { - value: true - } - }); - - var flow = nools.flow("error flow", function (flow) { - flow.rule("hello rule", [HelloFact, "h"], function () { - throw new Error("thrown error"); - }); - }); - - it.should("handle errors", function () { - var session = flow.getSession(); - session.assert(new HelloFact()); - return session.match().then(assert.fail, function () { - assert.ok(true); - }); - }); - - }); - it.describe("not rule", function (it) { it.describe("with a single fact", function (it) { var called = 0; var flow = nools.flow("notRuleSingleFact", function (flow) { - flow.rule("hello rule", ["not", String, "s", "s == 'hello'"], function () { + flow.rule("hello rule", ["not", String, "s", "s == 'hello'"], function (facts) { + assert.isUndefined(facts.s); called++; }); }); @@ -182,7 +159,7 @@ it.describe("Flow", function (it) { it.should(" not call when a string that does equal 'hello'", function () { called = 0; - flow.getSession("hello").match().then(function () { + return flow.getSession("hello").match().then(function () { assert.equal(called, 0); }); }); @@ -201,7 +178,7 @@ it.describe("Flow", function (it) { var flow1 = nools.flow("notRuleMultiFact", function (flow) { flow.rule("order rule", [ [Number, "n1"], - ["not", Number, "n2", "n1 > n2"] + ["not", Number, "n2", "n1 != n2 && n1 > n2"] ], function (facts, flow) { arr.push(facts.n1); flow.retract(facts.n1); @@ -234,6 +211,114 @@ it.describe("Flow", function (it) { }); }); + it.describe("modifying facts", function (it) { + var called = 0, arr = []; + + function Num(num) { + this.value = num; + } + + var flow1 = nools.flow("notRuleModifyFact", function (flow) { + flow.rule("not rule", [ + [Num, "n1"], + ["not", Num, "n2", "n1 != n2 && n1.value > n2.value"] + ], function () { + }); + }); + + it.should("handle modifications", function () { + var num1 = new Num(1), + num2 = new Num(2), + num3 = new Num(3), + num4 = new Num(4), + num5 = new Num(5); + var session = flow1.getSession(), + activationTree = session.agenda.rules["not rule"].tree; + + session.assert(num1); + session.assert(num2); + session.assert(num3); + session.assert(num4); + session.assert(num5); + var activations = activationTree.toArray(); + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num1); + session.modify(num1, function () { + this.value = 6; + }); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num2); + session.modify(num2, function () { + this.value = 7; + }); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num3); + session.modify(num3, function () { + this.value = 8; + }); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num4); + session.modify(num4, function () { + this.value = 9; + }); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num5); + session.modify(num5, function () { + this.value = 10; + }); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num1); + + session.retract(num1); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num2); + + session.retract(num2); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num3); + + session.retract(num3); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num4); + + session.retract(num4); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num5); + + session.retract(num5); + activations = activationTree.toArray() + assert.lengthOf(activations, 0); + + session.assert(num5); + session.assert(num4); + session.assert(num3); + session.assert(num2); + session.assert(num1); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num1); + session.retract(num1); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num2); + session.assert(num1); + activations = activationTree.toArray() + assert.lengthOf(activations, 1); + assert.equal(activations[0].match.factHash.n1, num1); + + }); + }); + + }); it.describe("or rule", function (it) { @@ -362,6 +447,464 @@ it.describe("Flow", function (it) { }); + it.describe("rule with from", function (it) { + + it.describe("with non array properties", function (it) { + + var called = 0; + var Address = declare({ + instance: { + constructor: function (zip) { + this.zipcode = zip; + } + } + }); + var Person = declare({ + instance: { + constructor: function (first, last, address) { + this.firstName = first; + this.lastName = last; + this.address = address; + } + } + }); + + var flow = nools.flow("from flow", function (flow) { + flow.rule("from rule 1", [ + [Person, "p"], + [Address, "a", "a.zipcode == 88847", "from p.address"], + [String, "first", "first == 'bob'", "from p.firstName"], + [String, "last", "last == 'yukon'", "from p.lastName"] + ], function (facts) { + assert.equal(facts.a, facts.p.address); + assert.equal(facts.a.zipcode, 88847); + assert.equal(facts.first, "bob"); + assert.equal(facts.last, "yukon"); + called++; + }); + + flow.rule("from rule 2", [ + [Person, "p"], + [Address, "a", "a.zipcode == 88845", "from p.address"], + [String, "first", "first == 'bob'", "from p.firstName"], + [String, "last", "last == 'yukon'", "from p.lastName"] + ], function (facts) { + assert.equal(facts.a, facts.p.address); + assert.equal(facts.a.zipcode, 88845); + assert.equal(facts.first, "bob"); + assert.equal(facts.last, "yukon"); + called++; + }); + + flow.rule("from rule 3", [ + [Person, "p"], + [Address, "a", "a.zipcode == 88847", "from p.address"], + [String, "first", "first == 'sally'", "from p.firstName"], + [String, "last", "last == 'yukon'", "from p.lastName"] + ], function (facts) { + assert.equal(facts.a, facts.p.address); + assert.equal(facts.a.zipcode, 88847); + assert.equal(facts.first, "sally"); + assert.equal(facts.last, "yukon"); + called++; + }); + + flow.rule("from rule 4", [ + [Person, "p"], + [Address, "a", "a.zipcode == 88845", "from p.address"], + [String, "first", "first == 'sally'", "from p.firstName"], + [String, "last", "last == 'yukons'", "from p.lastName"] + ], function (facts) { + assert.equal(facts.a, facts.p.address); + assert.equal(facts.a.zipcode, 88845); + assert.equal(facts.first, "sally"); + assert.equal(facts.last, "yukons"); + called++; + }); + }); + + it.should("create the proper match contexts", function () { + var session = flow.getSession(); + session.assert(new Person("bob", "yukon", new Address(88847))); + session.assert(new Person("sally", "yukons", new Address(88847))); + return session.match().then(function () { + assert.equal(called, 1); + }); + }); + + it.should("propagate modified facts properly", function () { + var fired = []; + var session = flow.getSession() + .on("fire", function (name, rule) { + fired.push(name); + }); + var p = new Person("bob", "yukon", new Address(88847)); + session.assert(p); + return session.match().then(function () { + assert.deepEqual(fired, ["from rule 1"]); + fired.length = 0; + session.modify(p, function () { + this.address = new Address(88845) + }); + return session.match().then(function () { + assert.deepEqual(fired, ["from rule 2"]); + fired.length = 0; + session.modify(p, function () { + this.address = new Address(88847); + this.firstName = "sally"; + }); + return session.match().then(function () { + assert.deepEqual(fired, ["from rule 3"]); + fired.length = 0; + session.modify(p, function () { + this.address = new Address(88845); + this.lastName = "yukons" + }); + return session.match().then(function () { + assert.deepEqual(fired, ["from rule 4"]); + fired.length = 0; + }); + }); + }); + + }); + }); + + it.should("retract facts properly", function () { + var session = flow.getSession(); + var p = new Person("bob", "yukon", new Address(88847)); + session.assert(p); + assert.equal(session.agenda.peek().name, "from rule 1"); + session.retract(p); + assert.isTrue(session.agenda.isEmpty()); + }); + }); + + it.describe("with array properties", function (it) { + + var called = 0; + var Person = declare({ + instance: { + constructor: function (first, last, friends) { + this.firstName = first; + this.lastName = last; + this.friends = friends || []; + } + } + }); + + var flow = nools.flow("from flow with arrays", function (flow) { + flow.rule("from rule 1", [ + [Person, "p"], + [Person, "friend", "friend.firstName != p.firstName", "from p.friends"], + [String, "first", "first =~ /^a/", "from friend.firstName"] + ], function (facts) { + assert.isTrue(/^a/.test(facts.first)); + called++; + }); + + flow.rule("from rule 2", [ + [Person, "p"], + [Person, "friend", "friend.firstName != p.firstName", "from p.friends"], + [String, "first", "first =~ /^b/", "from friend.firstName"] + ], function (facts) { + assert.isTrue(/^b/.test(facts.first)); + called++; + }); + }); + + it.should("create all cross product matches", function () { + var fired = [], names = []; + var session = flow.getSession() + .on("fire", function (name, facts) { + if (facts.first.match(/^b/)) { + assert.equal(name, "from rule 2"); + } else { + assert.equal(name, "from rule 1"); + } + names.push([facts.p.firstName, facts.first]); + fired.push(name); + }); + var persons = [ + new Person("bob", "yukon"), + new Person("andy", "yukon"), + new Person("andrew", "yukon"), + new Person("billy", "yukon"), + new Person("sally", "yukon") + ]; + //create graph + for (var i = 0, l = persons.length; i < l; i++) { + var p = persons[i], f; + for (var j = 0, l2 = persons.length; j < l2; j++) { + f = persons[j]; + if (f !== p) { + p.friends.push(f); + } + } + session.assert(p); + } + return session.match().then(function () { + assert.equal(called, 16); + assert.deepEqual(fired, [ + 'from rule 1', + 'from rule 1', + 'from rule 2', + 'from rule 2', + 'from rule 1', + 'from rule 1', + 'from rule 2', + 'from rule 1', + 'from rule 2', + 'from rule 2', + 'from rule 1', + 'from rule 2', + 'from rule 2', + 'from rule 1', + 'from rule 1', + 'from rule 2' + ]); + fired.length = 0; + session.modify(persons[0], function () { + this.firstName = "craig"; + }); + session.modify(persons[1], function () { + this.firstName = "sally"; + }); + session.modify(persons[2], function () { + this.firstName = "thede"; + }); + session.modify(persons[3], function () { + this.firstName = "jake"; + }); + session.modify(persons[4], function () { + this.firstName = "john"; + }); + return session.match().then(function () { + assert.lengthOf(fired, 0); + fired.length = 0; + names.length = 0; + session.modify(persons[0], function () { + this.firstName = "bob"; + }); + session.modify(persons[1], function () { + this.firstName = "bobby"; + }); + session.modify(persons[2], function () { + this.firstName = "billy"; + }); + session.modify(persons[3], function () { + this.firstName = "brian"; + }); + session.modify(persons[4], function () { + this.firstName = "bryan"; + }); + return session.match().then(function () { + names.sort(function (a, b) { + return a[0] === b[0] ? a[1] === b[1] ? 0: a[1] > b[1] ? 1: -1: a[0] > b[0] ? 1: -1; + }); + assert.deepEqual(names, [ + [ 'billy', 'bob' ], + [ 'billy', 'bobby' ], + [ 'billy', 'brian' ], + [ 'billy', 'bryan' ], + [ 'bob', 'billy' ], + [ 'bob', 'bobby' ], + [ 'bob', 'brian' ], + [ 'bob', 'bryan' ], + + [ 'bobby', 'billy' ], + [ 'bobby', 'bob' ], + [ 'bobby', 'brian' ], + [ 'bobby', 'bryan' ], + + [ 'brian', 'billy' ], + [ 'brian', 'bob' ], + [ 'brian', 'bobby' ], + [ 'brian', 'bryan' ], + + [ 'bryan', 'billy' ], + [ 'bryan', 'bob' ], + [ 'bryan', 'bobby' ], + [ 'bryan', 'brian' ] + ]); + assert.lengthOf(fired, 20); + }) + }) + + }); + }); + + it.should("retract all cross product matches", function () { + var session = flow.getSession(); + var persons = [ + new Person("bob", "yukon"), + new Person("andy", "yukon"), + new Person("andrew", "yukon"), + new Person("billy", "yukon"), + new Person("sally", "yukon") + ]; + //create graph + for (var i = 0, l = persons.length; i < l; i++) { + var p = persons[i], f; + for (var j = 0, l2 = persons.length; j < l2; j++) { + f = persons[j]; + if (f !== p) { + p.friends.push(f); + } + } + session.assert(p); + } + assert.equal(session.agenda.getFocusedAgenda().toArray().length, 16); + for (i = 0, l = persons.length; i < l; i++) { + session.retract(persons[i]); + } + assert.equal(session.agenda.getFocusedAgenda().toArray().length, 0); + }); + }); + + it.describe("with not node", function (it) { + + var called1 = 0, called2 = 0; + var Person = declare({ + instance: { + constructor: function (first, last, friends) { + this.firstName = first; + this.lastName = last; + this.friends = friends || []; + } + } + }); + + var flow = nools.flow("from flow with from and not", function (flow) { + flow.rule("from not rule 1", [ + [Person, "p"], + ["not", Person, "friend", "p != friend && friend.lastName != p.lastName", "from p.friends"] + ], function (facts) { + assert.isUndefined(facts.friend); + called1++; + }); + + flow.rule("from not rule 2", [ + [Person, "p"], + ["not", Person, "friend", "p != friend && friend.lastName == p.lastName", "from p.friends"] + ], function (facts) { + assert.isUndefined(facts.friend); + called2++; + }); + }); + + it.should("only fullfill if all facts evaluate to false", function () { + var session = flow.getSession(); + var persons = [ + new Person("bob", "yukon"), + new Person("andy", "yukon"), + new Person("andrew", "yukon"), + new Person("billy", "yukon"), + new Person("sally", "yukon") + ]; + //create graph + for (var i = 0, l = persons.length; i < l; i++) { + var p = persons[i], f; + for (var j = 0, l2 = persons.length; j < l2; j++) { + f = persons[j]; +// if (f !== p) { + p.friends.push(f); +// } + } + session.assert(p); + } + return session.match().then(function () { + assert.equal(called1, 5); + assert.equal(called2, 0); + called1 = called2 = 0; + session.modify(persons[0], function () { + this.lastName = "yukon"; + }); + session.modify(persons[1], function () { + this.lastName = "yuko"; + }); + session.modify(persons[2], function () { + this.lastName = "yuk"; + }); + session.modify(persons[3], function () { + this.lastName = "yu"; + }); + session.modify(persons[4], function () { + this.lastName = "y"; + }); + + return session.match().then(function () { + assert.equal(called1, 0); + assert.equal(called2, 5); + called1 = called2 = 0; + session.modify(persons[0], function () { + this.lastName = "yukon"; + }); + session.modify(persons[1], function () { + this.lastName = "yukon"; + }); + session.modify(persons[2], function () { + this.lastName = "yukon"; + }); + session.modify(persons[3], function () { + this.lastName = "yukon"; + }); + session.modify(persons[4], function () { + this.lastName = "yukon"; + }); + session.modify(persons[0], function () { + this.lastName = "yukon"; + }); + session.modify(persons[1], function () { + this.lastName = "yuko"; + }); + session.modify(persons[2], function () { + this.lastName = "yuk"; + }); + session.modify(persons[3], function () { + this.lastName = "yu"; + }); + session.modify(persons[4], function () { + this.lastName = "y"; + }); + return session.match().then(function () { + assert.equal(called1, 0); + assert.equal(called2, 5); + }); + }); + }); + }); + + it.should("only fullfill if all facts evaluate to false", function () { + called1 = 0, called2 = 0; + var session = flow.getSession(); + var persons = [ + new Person("bob", "yukon"), + new Person("andy", "yukon"), + new Person("andrew", "yukon"), + new Person("billy", "yukon"), + new Person("sally", "yukon"), + new Person("sally", "yukons") + ]; + //create graph + for (var i = 0, l = persons.length; i < l; i++) { + var p = persons[i], f; + for (var j = 0, l2 = persons.length; j < l2; j++) { + f = persons[j]; + p.friends.push(f); + } + session.assert(p); + } + return session.match().then(function () { + assert.equal(called1, 0); + assert.equal(called2, 1); + }); + }); + }); + + }); + + it.describe("scope option", function (it) { function isEqualTo(str, eq) { @@ -813,7 +1356,7 @@ it.describe("Flow", function (it) { this.assert(f2); }); - flow.rule("Bootstrap", [Fibonacci, "f", "f.value == -1 && (f.sequence == 1 || f.sequence == 2)"], function (facts, flow) { + flow.rule("Bootstrap", [Fibonacci, "f", "f.value == -1 && (f.sequence == 1 || f.sequence == 2)"], function (facts) { this.modify(facts.f, function () { this.value = 1; }); diff --git a/test/issues.test.js b/test/issues.test.js index cf56c6b..0f7ec94 100644 --- a/test/issues.test.js +++ b/test/issues.test.js @@ -91,4 +91,67 @@ it.describe("issues", function (it) { }); }); + + it.describe("81", function (it) { + + it.should("allow array references when compiling rules", function () { + + function ActualWeightDomain(values) { + this.values = values; + } + + function ActualWeightEnteredValue(value) { + this.value = value; + } + + function ActualWeightValue() { + + } + + var src = "rule CheckAndAssertActualWeight {" + + " when {" + + " actualWeight_domain: ActualWeightDomain {values: _domainValues};" + + " actualWeight_EnteredValue: ActualWeightEnteredValue" + + " (" + + " actualWeight_EnteredValue.value >= _domainValues[0] &&" + + " actualWeight_EnteredValue.value <= _domainValues[1]" + + " ) {value : _entered};" + + "}" + + "then {" + + " assert( new ActualWeightValue({value:_entered}) );" + + "}" + + "}"; + + var flow = nools.compile(src, {name: "issue81", define: { + "ActualWeightDomain": ActualWeightDomain, + "ActualWeightEnteredValue": ActualWeightEnteredValue, + ActualWeightValue: ActualWeightValue + }}); + var fired = []; + var session = flow.getSession(new ActualWeightEnteredValue(1), new ActualWeightDomain([1, 2])).on("fire", function (name) { + fired.push(name); + }); + return session.match().then(function () { + assert.deepEqual(fired, ["CheckAndAssertActualWeight"]); + fired.length = 0; + session = flow.getSession(new ActualWeightEnteredValue(5), new ActualWeightDomain([1, 2])).on("fire", function (name) { + fired.push(name); + }); + return session.match().then(function () { + assert.deepEqual(fired, []); + }); + }); + + }); + + }); + + it.describe("82", function (it) { + + it.should("allow a trailing comment when using the dsl", function () { + nools.compile("rule 'hello' {when {s: String s == 'hello';}then{console.log(s);}} //test comment ", {name: "issue82"}); + }); + + }); + }); \ No newline at end of file diff --git a/test/noolsParser.test.js b/test/noolsParser.test.js index 774c66f..6d60688 100644 --- a/test/noolsParser.test.js +++ b/test/noolsParser.test.js @@ -505,6 +505,66 @@ it.describe("nools dsl parser", function (it) { assert.deepEqual(parsed, parsed2); }); + it.should("parse when clause with from", function () { + var parsed = noolsParser.parse("rule TestRule { when { p : Person p.name eq 'Test'; a: Address a.zipcode == 88847 from p.address;} then {console.log($test);}}"); + assert.deepEqual(parsed, { + "define": [], + "rules": [ + { + "name": "TestRule", + "options": {}, + "constraints": [ + [ + "Person", + "p", + "p.name eq 'Test'" + ], + [ + "Address", + "a", + "a.zipcode == 88847 ", + "from p.address" + ] + ], + "action": "console.log($test);" + } + ], + "scope": [], + "loaded": [], + "file": undefined + }); + parsed = noolsParser.parse("rule TestRule { when { p : Person p.name eq 'Test'; a: Address a.zipcode == 88847 {zipcode: zipCode} from p.address;} then {console.log($test);}}"); + assert.deepEqual(parsed, { + "define": [], + "rules": [ + { + "name": "TestRule", + "options": {}, + "constraints": [ + [ + "Person", + "p", + "p.name eq 'Test'" + ], + [ + "Address", + "a", + "a.zipcode == 88847", + { + "zipcode": "zipCode" + }, + "from p.address" + ] + ], + "action": "console.log($test);" + } + ], + "scope": [], + "loaded": [], + "file": undefined + }); + }); + it.should("parse rules with a string name in double quotes", function () { var parsed = noolsParser.parse('rule "' + "test rule" + '"' + " { when { c : Clazz {test : test} c.name eq 'Test';} then {console.log($test);}}"); assert.deepEqual(parsed, { diff --git a/test/rules.test.js b/test/rules.test.js index ecc26f7..62feb6b 100644 --- a/test/rules.test.js +++ b/test/rules.test.js @@ -428,7 +428,7 @@ it.describe("Rule",function (it) { }); }); - it.should("should create a composite rule", function () { + it.should("create a composite rule", function () { var rule = rules.createRule("My Rule", [ ["string", "s"], ["string", "s2", "s2 == s"] @@ -455,7 +455,7 @@ it.describe("Rule",function (it) { assert.strictEqual(rule.cb, cb); }); - it.should("should create a not pattern", function () { + it.should("create a not pattern", function () { var rule = rules.createRule("My Rule", [ ["string", "s"], ["not", "string", "s2", "s2 == s"] @@ -482,7 +482,7 @@ it.describe("Rule",function (it) { assert.strictEqual(rule.cb, cb); }); - it.should("should create a or pattern", function () { + it.should("create a or pattern", function () { var ruleArr = rules.createRule("My Rule", [ ["string", "s"], ["or", @@ -513,6 +513,66 @@ it.describe("Rule",function (it) { assert.strictEqual(rule.cb, cb); } }); + + it.should("include reference store in constraints", function () { + var ruleArr = rules.createRule("My Rule", [ + ["Hash", "h", {name: "name"}], + ["string", "s2", "s2 == name", {length: "length"}] + ], cb); + assert.isNotNull(ruleArr); + assert.lengthOf(ruleArr, 1); + + var rule = ruleArr[0]; + assert.equal(rule.name, "My Rule"); + assert.isNotNull(rule.pattern); + var pattern = rule.pattern; + assert.instanceOf(pattern, patterns.CompositePattern); + assert.instanceOf(pattern.leftPattern, patterns.ObjectPattern); + assert.instanceOf(pattern.rightPattern, patterns.ObjectPattern); + assert.equal(pattern.leftPattern.alias, "h"); + assert.equal(pattern.rightPattern.alias, "s2"); + var constrnts = pattern.leftPattern.constraints; + assert.lengthOf(constrnts, 3); + assert.instanceOf(constrnts[0], constraints.ObjectConstraint); + assert.instanceOf(constrnts[1], constraints.TrueConstraint); + assert.instanceOf(constrnts[2], constraints.HashConstraint); + constrnts = pattern.rightPattern.constraints; + assert.lengthOf(constrnts, 3); + assert.instanceOf(constrnts[0], constraints.ObjectConstraint); + assert.instanceOf(constrnts[1], constraints.ReferenceConstraint); + assert.instanceOf(constrnts[2], constraints.HashConstraint); + assert.strictEqual(rule.cb, cb); + }); + + it.should("should include from constraints", function () { + var ruleArr = rules.createRule("My Rule", [ + ["Hash", "h", {name: "name"}], + ["string", "s2", "s2 == name", {length: "length"}, "from name"] + ], cb); + assert.isNotNull(ruleArr); + assert.lengthOf(ruleArr, 1); + + var rule = ruleArr[0]; + assert.equal(rule.name, "My Rule"); + assert.isNotNull(rule.pattern); + var pattern = rule.pattern; + assert.instanceOf(pattern, patterns.CompositePattern); + assert.instanceOf(pattern.leftPattern, patterns.ObjectPattern); + assert.instanceOf(pattern.rightPattern, patterns.FromPattern); + assert.equal(pattern.leftPattern.alias, "h"); + assert.equal(pattern.rightPattern.alias, "s2"); + var constrnts = pattern.leftPattern.constraints; + assert.lengthOf(constrnts, 3); + assert.instanceOf(constrnts[0], constraints.ObjectConstraint); + assert.instanceOf(constrnts[1], constraints.TrueConstraint); + assert.instanceOf(constrnts[2], constraints.HashConstraint); + constrnts = pattern.rightPattern.constraints; + assert.lengthOf(constrnts, 3); + assert.instanceOf(constrnts[0], constraints.ObjectConstraint); + assert.instanceOf(constrnts[1], constraints.ReferenceConstraint); + assert.instanceOf(constrnts[2], constraints.HashConstraint); + assert.equal(pattern.rightPattern.from, "name"); + }); }); }).as(module);