/* @preserve Brauhaus.js Diff Plugin Copyright 2013 Jens Taylor https://github.com/homebrewing/brauhaus-diff */ (function(){var t,e,n,r,i,o,l,s,a,f,u,c,h,y,p,g,b,j,v,d,m,z,w,S=[].slice,_={}.hasOwnProperty;t=null!=(m=this.Brauhaus)?m:require("brauhaus"),b=null!=(z=this.MurmurHash3)?z:require("imurmurhash"),g=null!=(w=this.Levenshtein)?w:require("fast-levenshtein"),i="undefined"!=typeof exports&&null!==exports?exports:{},t.Diff=i,h=function(t,e){var n;return n=Math.max(t.length,e.length),n>3?.25:1/n},a={exportUtil:!1,usingBrauhausStyles:null!=t.STYLES&&"function"==typeof t.getStyles,removeDefaultValues:!1,enablePostDiff:!0,enablePostApply:!0,fuzzyStrings:h},i.configure=function(t){var e,n,o,l;if("object"!=typeof t)return i;for(l=Object.keys(t),n=0,o=l.length;o>n;n++)e=l[n],a[e]=t[e];return r.normalize(a),a.exportUtil&&null==i.util&&(i.util=y),i},t.Fermentable.prototype._diffKeys=["name","late",["weight","color","yield"]],t.Spice.prototype._diffKeys=["name",["use","form"],["time","weight","aa"]],t.Yeast.prototype._diffKeys=["name",["type","form"],"attenuation"],t.MashStep.prototype._diffKeys=[["name","type"],["waterRatio","temp","endTemp","time","rampTime"]],y={getKeys:function(t,e){var n,r,i,o,l;i=[],n=[];for(r in t)l=t[r],y.keyPass(r,l)&&(r in e&&y.keyPass(r,e[r])?n.push(r):i.push(r));o=[];for(r in e)l=e[r],y.keyPass(r,l)&&(r in t&&y.keyPass(r,t[r])||o.push(r));return[i,o,n]},keyPass:function(t,e){return"function"==typeof e||"_"===t.charAt(0)?!1:!0},isEmpty:function(t){var e,n;if(t instanceof Array)return 0===t.length;for(e in t)if(n=t[e],y.keyPass(e,n))return!1;return!0},areAll:function(){var t,e,n,r,i;for(n=arguments[0],e=2<=arguments.length?S.call(arguments,1):[],r=0,i=e.length;i>r;r++)if(t=e[r],!(t instanceof n))return!1;return e.length>0?!0:!1},areAny:function(t,e){var n,r,i;for(r=0,i=e.length;i>r;r++)if(n=e[r],n instanceof t)return!0;return!1},compatibleTypes:function(t,e){var n,r,i,o;return t instanceof Array!=e instanceof Array?!1:t instanceof e.constructor||e instanceof t.constructor?!0:(o=y.getKeys(t,e),r=o[0],i=o[1],n=o[2],n.length>.75*(r.length+i.length+n.length))},hash:function(t){var e;return null!=t._diffKeys?(e=b(),y.hashObjKeys(e,t,t._diffKeys)):e=b(JSON.stringify(t)),e.result().toString(32)},hashObjKeys:function(t,e,n){var r,i,o;for(i=0,o=n.length;o>i;i++)r=n[i],r instanceof Array?y.hashObjKeys(t,e,r):(t.hash(r),t.hash(":"),t.hash(e[r].toString()),t.hash("|"))},diffCopy:function(t,e){var n,r,i;if(n="function"==typeof t.toJSON?t.toJSON():y.shallowCopy(t,!0),n instanceof Object){for(r in n)i=n[r],y.keyPass(r,i)||delete n[r];if(e.removeDefaultValues===!0)for(r in t)t.hasOwnProperty(r)||delete n[r]}return n},shallowCopy:function(t,e){var n,r,i;if(t instanceof Array)n=t.slice();else if(t instanceof Object&&!(t instanceof Function))if(e){n={};for(r in t)i=t[r],n[r]=i}else{n=Object.create(Object.getPrototypeOf(t));for(r in t)_.call(t,r)&&(i=t[r],n[r]=i)}return null!=n?n:t},checkKeyVal:function(t,e,n,r){return y.areAll(Array,t,n)?y.arrayCompare(t,n)&&y.arrayCompare(e,r):t===n&&e===r},getKeyVal:function(t,e){var n,r;return null!=t._diffKeyVal&&null!=t._diffKeyVal[e]?t._diffKeyVal[e]:(null!=t._diffKeys&&null!=t._diffKeys[e]?(n=t._diffKeys[e],r=y.getValForKey(t,n)):n="_nokey",null==t._diffKeyVal&&(t._diffKeyVal=[]),t._diffKeyVal[e]=[n,r])},getValForKey:function(t,e){var n,r,i,o,l;if(e instanceof Array){for(l=[],i=0,o=e.length;o>i;i++)n=e[i],l.push(r=y.getValForKey(t,n));return l}return t[e]},arrayCompare:function(t,e){var n,r,i;if(t===e)return!0;if(t.length!==e.length)return!1;for(n=r=0,i=t.length;i>=0?i>r:r>i;n=i>=0?++r:--r)if(y.areAll(Array,t[n],e[n])){if(!y.arrayCompare(t[n],e[n]))return!1}else if(t[n]!==e[n])return!1;return!0},getKeyValScore:function(t,e,n,r,i){var o,l,s,a;if(l=0,y.areAll(Array,t,n))for(o=s=0,a=t.length;a>=0?a>s:s>a;o=a>=0?++s:--s)l+=y.getKeyValScore(t[o],e[o],n[o],r[o],i,i.dontScoreKeys);else t===n&&(i.dontScoreKeys||(l=1),e===r?++l:i.fuzzyStrings&&"string"==typeof e&&"string"==typeof r&&(l+=.95*y.fuzzyMatch(e,r,i)));return l},getMatchScore:function(t,e,n){var r,i,o,l,s,a,f,u,c,h;for(f=[],u=n.start_level;;){if(c=y.getKeyVal(t,u),r=c[0],i=c[1],h=y.getKeyVal(e,u),l=h[0],s=h[1],o="_nokey"!==r,a="_nokey"!==l,o&&a)f.push(y.getKeyValScore(r,i,l,s,n));else{if(!o&&!a)break;f.push(0)}++u}return 0===f.length&&f.push(0),f},fuzzyMatch:function(t,e,n){var r,i,o,l,s,a,f;if(t.length=o?n._fuzzyMatchCache[s][l]=1-o:t.indexOf(" ")>=0&&e.indexOf(" ")>=0?(t=null!=n._fuzzySortCache[t]?n._fuzzySortCache[t]:n._fuzzySortCache[t]=t.split(" ").filter(function(t){return""!==t}).sort().join(" "),e=null!=n._fuzzySortCache[e]?n._fuzzySortCache[e]:n._fuzzySortCache[e]=e.split(" ").filter(function(t){return""!==t}).sort().join(" "),o=g.get(t,e)/i,n._fuzzyMatchCache[s][l]=r>=o?1-o:0):n._fuzzyMatchCache[s][l]=0},getOne:function(t){return t instanceof e?t.obj instanceof Array?y.getOne(t.obj[0]):t.obj:t},Directions:{LeftToRight:1,RightToLeft:2},getDirection:function(t){var e;return t?"number"==typeof t?t:(e=t.charAt(0).toLowerCase(),"f"!==e&&"r"!==e?y.Directions.LeftToRight:y.Directions.RightToLeft):y.Directions.LeftToRight},simpleCompare:function(t,e){return y.areAll(Object,t,e)?!0:null==t&&null==e?!0:t===e}},o=function(){function t(e){return e instanceof t?e:this instanceof t?(this.fail=null!=e?e:!0,this.state=[],this.canFail="function"==typeof this.fail||!!this.fail,void 0):new t(e)}return t.prototype.push=function(t){return this.canFail?this.state.push(t):void 0},t.prototype.pop=function(){return this.canFail?this.state.pop():void 0},t.prototype.check=function(t,e){var n,r,i;if(this.canFail&&!y.simpleCompare(t,e)&&(r="function"==typeof this.fail,r&&this.fail(this.state,t,e)||!r&&this.fail))throw i=this.state.length?this.state.join("."):"none",n=new Error("Diff encountered an inconsistency "+("(key: "+i+", expected: "+t+", actual: "+e+")")),n.keys=this.state,n.expected=t,n.actual=e,n},t}(),r=function(){function t(e){var n,r;if(e instanceof t)return e;if(!(this instanceof t))return new t(e);if(null!=e)for(n in e)_.call(e,n)&&(r=e[n],this[n]=r);t.normalize(this)}return t.normalize=function(t){var e;return t.hasOwnProperty("exportUtil")&&(t.exportUtil=!!t.exportUtil),t.hasOwnProperty("usingBrauhausStyles")&&(t.usingBrauhausStyles=!!t.usingBrauhausStyles),t.hasOwnProperty("removeDefaultValues")&&(t.removeDefaultValues=!!t.removeDefaultValues),t.hasOwnProperty("enablePostDiff")&&(t.enablePostDiff=!!t.enablePostDiff),t.hasOwnProperty("enablePostApply")&&(t.enablePostApply=!!t.enablePostApply),t.hasOwnProperty("fuzzyStrings")&&(t.fuzzyStrings===!0?t.fuzzyStrings=h:"number"==typeof t.fuzzyStrings?(e=function(t){return function(){return t}},t.fuzzyStrings=e(t.fuzzyStrings)):t.fuzzyStrings="function"==typeof t.fuzzyStrings?t.fuzzyStrings:!1),t},t}(),r.prototype=a,y.FailState=o,y.ConvertToOptions=r,e=function(){function t(t,e,n,r){this.key=t,this.val=e,this.obj=n,this.level=r}return t.Type={Unique:1,List:2,Category:3},t.prototype.add=function(t){return this.obj instanceof Array||(this.obj=[this.obj]),this.obj.push(t),this},t.prototype.remove=function(e){var n,r,i,o,l,s,a,f,u,c;if(r=!1,s=this.getType(),s===t.Type.Category)for(u=y.getKeyVal(e,this.level+1),o=u[0],l=u[1],c=this.obj,i=a=0,f=c.length;f>a&&(n=c[i],!y.checkKeyVal(o,l,n.key,n.val)||(r=n.remove(e,this.level+1),null===n.obj&&this.cleanUp(i,1),!r));i=++a);else s===t.Type.List?(i=this.obj.indexOf(e),i>=0&&(this.cleanUp(i,1),r=!0)):this.obj===e&&(this.obj=null,r=!0);return r},t.prototype.cleanUp=function(e,n){if(this.obj instanceof Array){if(this.obj.length===n)return this.obj=null;if(n>0&&this.obj.splice(e,n),1===this.obj.length&&!(this.obj[0]instanceof t))return this.obj=this.obj[0]}else if(n>0)return this.obj=null},t.prototype.getType=function(){return this.obj instanceof Array?this.obj.length>0&&this.obj[0]instanceof t?t.Type.Category:t.Type.List:t.Type.Unique},t.categorize=function(e){return t.processLevel(new t("_root",null,e,-1))},t.processLevel=function(e){var n,r,i,o,l,s,a,f,u,c,h,p,g,b;if(!(e.obj instanceof Array))return e;for(r=function(t,e){var r,i,o;for(i=0,o=n.length;o>i;i++)if(r=n[i],y.checkKeyVal(r.key,r.val,t,e))return r},o=e.level+1,n=[],g=e.obj,u=0,h=g.length;h>u;u++)s=g[u],b=y.getKeyVal(s,o),i=b[0],f=b[1],l=r(i,f),null!=l?l.add(s):n.push(new t(i,f,s,o));if(1!==n.length||"_nokey"!==n[0].key){for(c=0,p=n.length;p>c;c++)a=n[c],t.processLevel(a,o);e.obj=n}return e},t}(),n=function(){function t(n){this.cat=n,this.i=0,n.getType()===e.Type.Category&&(this.subit=new t(n.obj[0]))}return t.prototype.next=function(){var e;if(e=null,this.cat.obj instanceof Array)if(null!=this.subit)for(e=this.subit.next();null==e&&!(++this.i>=this.cat.obj.length);)this.subit=new t(this.cat.obj[this.i]),e=this.subit.next();else this.in;n++)if(e=t[n],!(e instanceof Object)||e instanceof Array)return!1;return!0},r=i(t)&&i(e)?new l(t,e,n):new s(t,e,n)):r=y.areAll(Object,t,e)&&y.compatibleTypes(t,e)?new s(t,e,n):t!==e?new f(t,e,n):{},r},d=function(t,e,n,r){var i,o;r.enablePostDiff&&("function"==typeof(null!=t?t.postDiff:void 0)?i=t.postDiff:"function"==typeof(null!=t?t.constructor.postDiff:void 0)&&(i=t.constructor.postDiff),"function"==typeof(null!=e?e.postDiff:void 0)?o=e.postDiff:"function"==typeof(null!=e?e.constructor.postDiff:void 0)&&(o=e.constructor.postDiff),null!=i&&i(t,e,n,r),null!=o&&o!==i&&o(t,e,n,r))},i.apply=function(t,e,n,o){var l,s,a,f,u,c,h;if("string"==typeof e)e=i.parse(e);else if(e instanceof Array)for(s=f=0,c=e.length;c>f;s=++f)l=e[s],"string"==typeof l&&(e[s]=i.parse(l));if(a="string"==typeof n?r({direction:n,fail:o}):r(n),e instanceof Array)for(u=0,h=e.length;h>u;u++)l=e[u],t=l.apply(t,a);else t=e.apply(t,a);return t},v=function(t,e,n){return n.enablePostApply&&("function"==typeof(null!=t?t.postApply:void 0)?t.postApply(t,e,n):"function"==typeof(null!=t?t.constructor.postApply:void 0)&&t.constructor.postApply(t,e,n)),t},i.combine=function(){throw new Error("not implemented yet")},i.parse=function(t){var e;return"string"==typeof t&&(e=JSON.parse(t)),c(null!=e?e:t)},c=function(t){var e;if(t instanceof Array){if(t.length>0&&null!=(null!=(e=t[0])?e._h:void 0))return l.fromObject(t);if(2===t.length)return f.fromObject(t);throw new TypeError("Trying to inflate non-diff object: "+JSON.stringify(t))}if(t instanceof Object)return s.fromObject(t);throw new TypeError("Trying to inflate non-diff object: "+JSON.stringify(t))},f=function(){function t(t,e,n){n=r(n),this.left=!(t instanceof Array)&&t instanceof Object?y.diffCopy(t,n):t,this.right=!(e instanceof Array)&&e instanceof Object?y.diffCopy(e,n):e,d(t,e,this,n)}return t.prototype.toJSON=function(){return[this.left,this.right]},t.prototype.apply=function(t,e,n){var i;return e=r(e),i=e.fail=o(e.fail),e.direction=y.getDirection(e.direction),e.direction===y.Directions.LeftToRight?(i.check(this.left,t),t=null!=n?new n(this.right):this.right):(i.check(this.right,t),t=null!=n?new n(this.left):this.left),v(t,this,e)},t.fromObject=function(e){return new t(e[0],e[1])},t}(),s=function(){function t(t,e,n){var o,l,s,a,u,c,h,p,g,b,j,v,m,z,w,S;if(null!=t||null!=e){for(n=r(n),a="function"==typeof t.toJSON?t.toJSON():t,c="function"==typeof e.toJSON?e.toJSON():e,z=y.getKeys(a,c),s=z[0],u=z[1],o=z[2],p=0,j=s.length;j>p;p++)l=s[p],this[l]=new f(a[l],null,n);for(g=0,v=u.length;v>g;g++)l=u[g],this[l]=new f(null,c[l],n);for(b=0,m=o.length;m>b;b++)l=o[b],h=i.diff(null!=(w=a[l])?w:null,null!=(S=c[l])?S:null,n),y.isEmpty(h)||(this[l]=h);d(t,e,this,n)}}return t.prototype.apply=function(t,e,n){var i,s,a,f,u;if(!(t instanceof Object))throw new Error("Object diff being applied to non-object");t=y.shallowCopy(t),e=r(e),i=e.fail=o(e.fail);for(s in this)f=this[s],y.keyPass(s,f)&&(a=null!=(u=t._paramMap)?u[s]:void 0,i.push(s),f instanceof l&&!(t[s]instanceof Array)?i.check("array",typeof t[s]):t[s]=f.apply(t[s],e,a),i.pop());return null!=n&&(t=new n(t)),v(t,this,e)},t.fromObject=function(e){var n,r,i;n=new t;for(r in e)i=e[r],n[r]=c(i);return n},t}(),l=function(){function t(t,o,l){var s,a,u,c,h,p,g,b,v,m,z,w,S;if(null!=t||null!=o){if(l=r(l),c=e.categorize(t),b=e.categorize(o),g=j.getPairs(c,b,l),null!=c.obj&&null!=b.obj&&(g=g.concat(j.fuzzyMatch(c,b,l))),null!=c.obj)for(u=new n(c);null!=(h=u.next());)g.push([h,null]);if(null!=b.obj)for(u=new n(b);null!=(v=u.next());)g.push([null,v]);for(this.diff=[],z=0,w=g.length;w>z;z++)p=g[z],null!=p[0]&&null!=p[1]?(delete p[0]._diffKeyVal,delete p[1]._diffKeyVal,s=i.diff(p[0],p[1]),y.isEmpty(s)||(s._h=new f(y.hash(p[0]),y.hash(p[1]),l))):(m=null!=(S=p[0])?S:p[1],delete m._diffKeyVal,s=y.diffCopy(m,l),a=y.hash(m),s._h=null!=p[0]?new f(a,null,l):new f(null,a,l)),y.isEmpty(s)||this.diff.push(s);0===this.diff.length&&delete this.diff,d(t,o,this,l)}}return t.prototype.toJSON=function(){var t;return null!=(t=this.diff)?t:[]},t.getPairs=function(t,n,r){var i,o;return i=t.getType(),o=n.getType(),i===e.Type.Unique?o===e.Type.Unique?j.uniqueVsUnique(t,n,r):j.uniqueVsArray(t,n,r,!1):o===e.Type.Unique?j.uniqueVsArray(n,t,r,!0):i===e.Type.Category?o===e.Type.Category?j.catVsCat(t,n,r):j.listVsCategory(n,t,r,!0):o===e.Type.Category?j.listVsCategory(t,n,r,!1):j.listVsList(t,n,r)},t.uniqueVsUnique=function(t,e){var n;return n=[[t.obj,e.obj]],t.cleanUp(0,1),e.cleanUp(0,1),n},t.uniqueVsArray=function(t,e,n,r){var i,o;return i=j.takeBestMatch(t.obj,e,n),null!=i?(o=r?[[i,t.obj]]:[[t.obj,i]],t.cleanUp(0,1),o):[]},t.listVsCategory=function(t,e,n,r){var i,o,l,s,a,f,u;for(s=[],i=0,u=t.obj,a=0,f=u.length;f>a&&(o=u[a],l=j.takeBestMatch(o,e,n),null!=l)&&(s.push(r?[l,o]:[o,l]),++i,null!=e.obj);a++);return t.cleanUp(0,i),s},t.listVsList=function(t,e){var n,r,i,o;for(i=[],r=Math.min(t.obj.length,e.obj.length),n=o=0;r>=0?r>o:o>r;n=r>=0?++o:--o)i.push([t.obj[n],e.obj[n]]);return t.cleanUp(0,r),e.cleanUp(0,r),i},t.catVsCat=function(t,e,n,r){var i,o,l,s,a,f,u,c,h,p,g,b;for(null==r&&(r=t.level>=0),i=0,s=[],p=t.obj,f=0,c=p.length;c>f;f++){for(b=p[f],l=t.obj[i],g=e.obj,o=u=0,h=g.length;h>u;o=++u)if(a=g[o],y.checkKeyVal(l.key,l.val,a.key,a.val)){s=s.concat(j.getPairs(l,a,n)),null===a.obj&&e.obj.splice(o,1);break}if(null===l.obj?t.obj.splice(i,1):++i,0===e.obj.length)break}return t.cleanUp(0,0),e.cleanUp(0,0),r&&null!=t.obj&&null!=e.obj&&(s=s.concat(j.catVsCatSecondPass(t,e,n))),s},t.catVsCatSecondPass=function(t,e,r){var i,o,l,s,a,f;for(i=function(n,o,l){var s;return s=j.bestMatch(o,l?t.obj:e.obj,r,t.level+1),n===s?l?[n,o]:[o,n]:i(o,s,!l)},f=[];;){if(null==e.obj||null==t.obj)break;if(o=new n(t),s=o.next(),null==s)break;if(!(e.obj instanceof Array)){f.push([s,e.obj]),o.remove(),e.cleanUp(0,1);break}if(l=j.bestMatch(s,e.obj,r,t.level+1),null==l)break;a=i(s,l,!0),a[0]===s?o.remove():t.remove(a[0]),e.remove(a[1]),f.push(a)}return f},t.bestMatch=function(t,n,r,i){var o,l,s,a,f,u,c,h,p,g,b,v;for(f=[],a=0,b=y.getKeyVal(t,i),u=b[0],c=b[1],h=function(t,e,n){var i;return i=y.getKeyValScore(u,c,t,e,r),i>a?(f=n instanceof Array?[].concat(n):[n],a=i):i===a?n instanceof Array?f=f.concat(n):f.push(n):void 0},p=0,g=n.length;g>p;p++)o=n[p],o instanceof e?h(o.key,o.val,o.obj):(v=y.getKeyVal(o,i),l=v[0],s=v[1],h(l,s,o));if("_nokey"===u){if(f.length>0)return y.getOne(f[0])}else if(f.length>0)return 1!==f.length||f[0]instanceof e?j.bestMatch(t,f,r,i+1):f[0]},t.takeBestMatch=function(t,e,n){var r,i;return r=e.obj instanceof Array?e.obj:[e.obj],i=j.bestMatch(t,r,n,e.level+1),null!=i&&e.remove(i),i},t.fuzzyMatch=function(t,e,n){var r,i,o,l,s;for(o=new j.FuzzyMatcher(t,e,n),l=[];null!=(i=o.next());)r=i[0],s=i[1],l=l.concat(j.getPairs(t.obj[r],e.obj[s],n)),null==t.obj[r].obj&&o.clearLeft(r),null==e.obj[s].obj&&o.clearRight(s);return j.fuzzyCleanUp(t),j.fuzzyCleanUp(e),l},t.fuzzyCleanUp=function(t){var e,n,r;for(e=n=r=t.obj.length-1;0>=r?0>=n:n>=0;e=0>=r?++n:--n)null==t.obj[e].obj&&t.obj.splice(e,1);return t.cleanUp(0,0)},t.fromObject=function(e){var n,r,i,o;for(n=new t,n.diff=[],i=0,o=e.length;o>i;i++)r=e[i],null!=r._h[0]&&null!=r._h[1]?n.diff.push(c(r)):(r._h=c(r._h),n.diff.push(r));return n},t.prototype.apply=function(t,e,n){var i,l,s,a,f,u,c,h,p,g;if(!(t instanceof Array))throw new Error("Array diff being applied to non-array");for(t=y.shallowCopy(t),e=r(e),l=e.fail=o(e.fail),i=y.getDirection(e.direction)===y.Directions.LeftToRight,s=function(){var e,n,r;for(r=[],e=0,n=t.length;n>e;e++)c=t[e],r.push(y.hash(c));return r}(),g=this.diff,h=0,p=g.length;p>h;h++)c=g[h],f=j.determineType(c,i),a=s.indexOf(i?1===f?c._h.right:c._h.left:1===f?c._h.left:c._h.right),a>=0?0===f?(l.push(a),t[a]=c.apply(t[a],e),l.pop()):2===f?(s.splice(a,1),t.splice(a,1)):(l.push(a),l.check(null,s[a]),l.pop(),u=y.diffCopy(c,e),t.push(null!=n?new n(u):u)):1===f?(u=y.diffCopy(c,e),t.push(null!=n?new n(u):u)):(l.push(-1),l.check(i?c._h.left:c._h.right,null),l.pop());return v(t,this,e)},t.determineType=function(t,e){if(null!=t._h.left)return null!=t._h.right?0:e?2:1;if(null!=t._h.right)return e?1:2;throw new Error("Array diff missing object hashes")},t}(),l.FuzzyMatcher=function(){function t(t,e,n){var r,i,o,l,s,a,f,u,c;for(this.l=0,this.scores=[],n.dontScoreKeys=!0,u=t.obj,l=0,a=u.length;a>l;l++){for(r=u[l],o=[],c=e.obj,s=0,f=c.length;f>s;s++)i=c[s],o.push(y.getKeyValScore(r.key,r.val,i.key,i.val,n));this.scores.push(o)}delete n.dontScoreKeys}return t.prototype.next=function(){var t,e,n,r,i;for(t=n=r=this.l,i=this.scores.length;i>=r?i>n:n>i;t=i>=r?++n:--n)if(this.l=t,e=this.scores[t].indexOf(Math.max.apply(Math,this.scores[t])),this.scores[t][e]>0)return this.topDown(t,e)},t.prototype.clearLeft=function(t){return this.scores[t]=[]},t.prototype.clearRight=function(t){var e,n,r,i;for(i=this.scores,n=0,r=i.length;r>n;n++)e=i[n],e.length>=t&&(e[t]=0)},t.prototype.topDown=function(t,e){var n,r,i,o,l,s,a;for(i=0,n=0,a=this.scores,r=l=0,s=a.length;s>l;r=++l)o=a[r],o[e]>i&&(n=r,i=o[e]);return n===t?[t,e]:this.leftRight(n,e)},t.prototype.leftRight=function(t,e){var n;return n=this.scores[t].indexOf(Math.max.apply(Math,this.scores[t])),n===e?[t,e]:this.topDown(t,n)},t}(),j=l,y.ValueDiff=f,y.ObjectDiff=s,y.ObjectArrayDiff=l,t.Recipe.postDiff=function(t,e,n,r){var i,o,l,s,a,c,h,y,g,b,j,v,d,m;if(r.usingBrauhausStyles&&null!=n.style)if(n.style instanceof f){if(null!=(null!=(y=n.style.left)?y.name:void 0)&&null!=n.style.left.category&&null!=p(n.style.left.category,n.style.left.name)&&u(n.style.left),null!=(null!=(g=n.style.right)?g.name:void 0)&&null!=n.style.right.category&&null!=p(n.style.right.category,n.style.right.name))return u(n.style.right)}else if(o=null!=(b=null!=(j=n.style.name)?j.left:void 0)?b:t.style.name,i=null!=(v=null!=(d=n.style.category)?d.left:void 0)?v:t.style.category,s=null!=(m=null!=(a=n.style.name)?a.right:void 0)?m:e.style.name,l=null!=(c=null!=(h=n.style.category)?h.right:void 0)?c:e.style.category,null!=p(i,o)&&null!=p(l,s))return u(n.style)},t.Recipe.postApply=function(t,e,n){var r,i,o;return n.usingBrauhausStyles&&(r=p(null!=(i=t.style)?i.category:void 0,null!=(o=t.style)?o.name:void 0),null!=r)?t.style=r:void 0},p=function(e,n){var r;try{return t.getStyle(e,n)}catch(i){r=i}},u=function(t){var e;for(e in t)_.call(t,e)&&"name"!==e&&"category"!==e&&delete t[e]}}).call(this);