-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinidiff.min.js
32 lines (30 loc) · 27 KB
/
inidiff.min.js
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
/**
* Diff Match and Patch
*
* Copyright 2006 Google Inc.
* http://code.google.com/p/google-diff-match-patch/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function diff_match_patch(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32}var DIFF_DELETE=-1,DIFF_INSERT=1,DIFF_EQUAL=0;diff_match_patch.Diff,diff_match_patch.prototype.diff_main=function(t,e,h,n){"undefined"==typeof n&&(n=this.Diff_Timeout<=0?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout);var i=n;if(null==t||null==e)throw new Error("Null input. (diff_main)");if(t==e)return t?[[DIFF_EQUAL,t]]:[];"undefined"==typeof h&&(h=!0);var r=h,a=this.diff_commonPrefix(t,e),f=t.substring(0,a);t=t.substring(a),e=e.substring(a),a=this.diff_commonSuffix(t,e);var s=t.substring(t.length-a);t=t.substring(0,t.length-a),e=e.substring(0,e.length-a);var l=this.diff_compute_(t,e,r,i);return f&&l.unshift([DIFF_EQUAL,f]),s&&l.push([DIFF_EQUAL,s]),this.diff_cleanupMerge(l),l},diff_match_patch.prototype.diff_compute_=function(t,e,h,n){var i;if(!t)return[[DIFF_INSERT,e]];if(!e)return[[DIFF_DELETE,t]];var r=t.length>e.length?t:e,a=t.length>e.length?e:t,f=r.indexOf(a);if(-1!=f)return i=[[DIFF_INSERT,r.substring(0,f)],[DIFF_EQUAL,a],[DIFF_INSERT,r.substring(f+a.length)]],t.length>e.length&&(i[0][0]=i[2][0]=DIFF_DELETE),i;if(1==a.length)return[[DIFF_DELETE,t],[DIFF_INSERT,e]];var s=this.diff_halfMatch_(t,e);if(s){var l=s[0],c=s[1],g=s[2],_=s[3],o=s[4],p=this.diff_main(l,g,h,n),d=this.diff_main(c,_,h,n);return p.concat([[DIFF_EQUAL,o]],d)}return h&&t.length>100&&e.length>100?this.diff_lineMode_(t,e,n):this.diff_bisect_(t,e,n)},diff_match_patch.prototype.diff_lineMode_=function(t,e,h){var n=this.diff_linesToChars_(t,e);t=n.chars1,e=n.chars2;var i=n.lineArray,r=this.diff_main(t,e,!1,h);this.diff_charsToLines_(r,i),this.diff_cleanupSemantic(r),r.push([DIFF_EQUAL,""]);for(var a=0,f=0,s=0,l="",c="";a<r.length;){switch(r[a][0]){case DIFF_INSERT:s++,c+=r[a][1];break;case DIFF_DELETE:f++,l+=r[a][1];break;case DIFF_EQUAL:if(f>=1&&s>=1){r.splice(a-f-s,f+s),a=a-f-s;for(var n=this.diff_main(l,c,!1,h),g=n.length-1;g>=0;g--)r.splice(a,0,n[g]);a+=n.length}s=0,f=0,l="",c=""}a++}return r.pop(),r},diff_match_patch.prototype.diff_bisect_=function(t,e,h){for(var n=t.length,i=e.length,r=Math.ceil((n+i)/2),a=r,f=2*r,s=new Array(f),l=new Array(f),c=0;f>c;c++)s[c]=-1,l[c]=-1;s[a+1]=0,l[a+1]=0;for(var g=n-i,_=g%2!=0,o=0,p=0,d=0,u=0,F=0;r>F&&!((new Date).getTime()>h);F++){for(var E=-F+o;F-p>=E;E+=2){var m,D=a+E;m=E==-F||E!=F&&s[D-1]<s[D+1]?s[D+1]:s[D-1]+1;for(var I=m-E;n>m&&i>I&&t.charAt(m)==e.charAt(I);)m++,I++;if(s[D]=m,m>n)p+=2;else if(I>i)o+=2;else if(_){var b=a+g-E;if(b>=0&&f>b&&-1!=l[b]){var v=n-l[b];if(m>=v)return this.diff_bisectSplit_(t,e,m,I,h)}}}for(var x=-F+d;F-u>=x;x+=2){var v,b=a+x;v=x==-F||x!=F&&l[b-1]<l[b+1]?l[b+1]:l[b-1]+1;for(var L=v-x;n>v&&i>L&&t.charAt(n-v-1)==e.charAt(i-L-1);)v++,L++;if(l[b]=v,v>n)u+=2;else if(L>i)d+=2;else if(!_){var D=a+g-x;if(D>=0&&f>D&&-1!=s[D]){var m=s[D],I=a+m-D;if(v=n-v,m>=v)return this.diff_bisectSplit_(t,e,m,I,h)}}}}return[[DIFF_DELETE,t],[DIFF_INSERT,e]]},diff_match_patch.prototype.diff_bisectSplit_=function(t,e,h,n,i){var r=t.substring(0,h),a=e.substring(0,n),f=t.substring(h),s=e.substring(n),l=this.diff_main(r,a,!1,i),c=this.diff_main(f,s,!1,i);return l.concat(c)},diff_match_patch.prototype.diff_linesToChars_=function(t,e){function h(t){for(var e="",h=0,r=-1,a=n.length;r<t.length-1;){r=t.indexOf("\n",h),-1==r&&(r=t.length-1);var f=t.substring(h,r+1);h=r+1,(i.hasOwnProperty?i.hasOwnProperty(f):void 0!==i[f])?e+=String.fromCharCode(i[f]):(e+=String.fromCharCode(a),i[f]=a,n[a++]=f)}return e}var n=[],i={};n[0]="";var r=h(t),a=h(e);return{chars1:r,chars2:a,lineArray:n}},diff_match_patch.prototype.diff_charsToLines_=function(t,e){for(var h=0;h<t.length;h++){for(var n=t[h][1],i=[],r=0;r<n.length;r++)i[r]=e[n.charCodeAt(r)];t[h][1]=i.join("")}},diff_match_patch.prototype.diff_commonPrefix=function(t,e){if(!t||!e||t.charAt(0)!=e.charAt(0))return 0;for(var h=0,n=Math.min(t.length,e.length),i=n,r=0;i>h;)t.substring(r,i)==e.substring(r,i)?(h=i,r=h):n=i,i=Math.floor((n-h)/2+h);return i},diff_match_patch.prototype.diff_commonSuffix=function(t,e){if(!t||!e||t.charAt(t.length-1)!=e.charAt(e.length-1))return 0;for(var h=0,n=Math.min(t.length,e.length),i=n,r=0;i>h;)t.substring(t.length-i,t.length-r)==e.substring(e.length-i,e.length-r)?(h=i,r=h):n=i,i=Math.floor((n-h)/2+h);return i},diff_match_patch.prototype.diff_commonOverlap_=function(t,e){var h=t.length,n=e.length;if(0==h||0==n)return 0;h>n?t=t.substring(h-n):n>h&&(e=e.substring(0,h));var i=Math.min(h,n);if(t==e)return i;for(var r=0,a=1;;){var f=t.substring(i-a),s=e.indexOf(f);if(-1==s)return r;a+=s,(0==s||t.substring(i-a)==e.substring(0,a))&&(r=a,a++)}},diff_match_patch.prototype.diff_halfMatch_=function(t,e){function h(t,e,h){for(var n,i,r,f,s=t.substring(h,h+Math.floor(t.length/4)),l=-1,c="";-1!=(l=e.indexOf(s,l+1));){var g=a.diff_commonPrefix(t.substring(h),e.substring(l)),_=a.diff_commonSuffix(t.substring(0,h),e.substring(0,l));c.length<_+g&&(c=e.substring(l-_,l)+e.substring(l,l+g),n=t.substring(0,h-_),i=t.substring(h+g),r=e.substring(0,l-_),f=e.substring(l+g))}return 2*c.length>=t.length?[n,i,r,f,c]:null}if(this.Diff_Timeout<=0)return null;var n=t.length>e.length?t:e,i=t.length>e.length?e:t;if(n.length<4||2*i.length<n.length)return null;var r,a=this,f=h(n,i,Math.ceil(n.length/4)),s=h(n,i,Math.ceil(n.length/2));if(!f&&!s)return null;r=s?f&&f[4].length>s[4].length?f:s:f;var l,c,g,_;t.length>e.length?(l=r[0],c=r[1],g=r[2],_=r[3]):(g=r[0],_=r[1],l=r[2],c=r[3]);var o=r[4];return[l,c,g,_,o]},diff_match_patch.prototype.diff_cleanupSemantic=function(t){for(var e=!1,h=[],n=0,i=null,r=0,a=0,f=0,s=0,l=0;r<t.length;)t[r][0]==DIFF_EQUAL?(h[n++]=r,a=s,f=l,s=0,l=0,i=t[r][1]):(t[r][0]==DIFF_INSERT?s+=t[r][1].length:l+=t[r][1].length,i&&i.length<=Math.max(a,f)&&i.length<=Math.max(s,l)&&(t.splice(h[n-1],0,[DIFF_DELETE,i]),t[h[n-1]+1][0]=DIFF_INSERT,n--,n--,r=n>0?h[n-1]:-1,a=0,f=0,s=0,l=0,i=null,e=!0)),r++;for(e&&this.diff_cleanupMerge(t),this.diff_cleanupSemanticLossless(t),r=1;r<t.length;){if(t[r-1][0]==DIFF_DELETE&&t[r][0]==DIFF_INSERT){var c=t[r-1][1],g=t[r][1],_=this.diff_commonOverlap_(c,g),o=this.diff_commonOverlap_(g,c);_>=o?(_>=c.length/2||_>=g.length/2)&&(t.splice(r,0,[DIFF_EQUAL,g.substring(0,_)]),t[r-1][1]=c.substring(0,c.length-_),t[r+1][1]=g.substring(_),r++):(o>=c.length/2||o>=g.length/2)&&(t.splice(r,0,[DIFF_EQUAL,c.substring(0,o)]),t[r-1][0]=DIFF_INSERT,t[r-1][1]=g.substring(0,g.length-o),t[r+1][0]=DIFF_DELETE,t[r+1][1]=c.substring(o),r++),r++}r++}},diff_match_patch.prototype.diff_cleanupSemanticLossless=function(t){function e(t,e){if(!t||!e)return 6;var h=t.charAt(t.length-1),n=e.charAt(0),i=h.match(diff_match_patch.nonAlphaNumericRegex_),r=n.match(diff_match_patch.nonAlphaNumericRegex_),a=i&&h.match(diff_match_patch.whitespaceRegex_),f=r&&n.match(diff_match_patch.whitespaceRegex_),s=a&&h.match(diff_match_patch.linebreakRegex_),l=f&&n.match(diff_match_patch.linebreakRegex_),c=s&&t.match(diff_match_patch.blanklineEndRegex_),g=l&&e.match(diff_match_patch.blanklineStartRegex_);return c||g?5:s||l?4:i&&!a&&f?3:a||f?2:i||r?1:0}for(var h=1;h<t.length-1;){if(t[h-1][0]==DIFF_EQUAL&&t[h+1][0]==DIFF_EQUAL){var n=t[h-1][1],i=t[h][1],r=t[h+1][1],a=this.diff_commonSuffix(n,i);if(a){var f=i.substring(i.length-a);n=n.substring(0,n.length-a),i=f+i.substring(0,i.length-a),r=f+r}for(var s=n,l=i,c=r,g=e(n,i)+e(i,r);i.charAt(0)===r.charAt(0);){n+=i.charAt(0),i=i.substring(1)+r.charAt(0),r=r.substring(1);var _=e(n,i)+e(i,r);_>=g&&(g=_,s=n,l=i,c=r)}t[h-1][1]!=s&&(s?t[h-1][1]=s:(t.splice(h-1,1),h--),t[h][1]=l,c?t[h+1][1]=c:(t.splice(h+1,1),h--))}h++}},diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,diff_match_patch.whitespaceRegex_=/\s/,diff_match_patch.linebreakRegex_=/[\r\n]/,diff_match_patch.blanklineEndRegex_=/\n\r?\n$/,diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/,diff_match_patch.prototype.diff_cleanupEfficiency=function(t){for(var e=!1,h=[],n=0,i=null,r=0,a=!1,f=!1,s=!1,l=!1;r<t.length;)t[r][0]==DIFF_EQUAL?(t[r][1].length<this.Diff_EditCost&&(s||l)?(h[n++]=r,a=s,f=l,i=t[r][1]):(n=0,i=null),s=l=!1):(t[r][0]==DIFF_DELETE?l=!0:s=!0,i&&(a&&f&&s&&l||i.length<this.Diff_EditCost/2&&a+f+s+l==3)&&(t.splice(h[n-1],0,[DIFF_DELETE,i]),t[h[n-1]+1][0]=DIFF_INSERT,n--,i=null,a&&f?(s=l=!0,n=0):(n--,r=n>0?h[n-1]:-1,s=l=!1),e=!0)),r++;e&&this.diff_cleanupMerge(t)},diff_match_patch.prototype.diff_cleanupMerge=function(t){t.push([DIFF_EQUAL,""]);for(var e,h=0,n=0,i=0,r="",a="";h<t.length;)switch(t[h][0]){case DIFF_INSERT:i++,a+=t[h][1],h++;break;case DIFF_DELETE:n++,r+=t[h][1],h++;break;case DIFF_EQUAL:n+i>1?(0!==n&&0!==i&&(e=this.diff_commonPrefix(a,r),0!==e&&(h-n-i>0&&t[h-n-i-1][0]==DIFF_EQUAL?t[h-n-i-1][1]+=a.substring(0,e):(t.splice(0,0,[DIFF_EQUAL,a.substring(0,e)]),h++),a=a.substring(e),r=r.substring(e)),e=this.diff_commonSuffix(a,r),0!==e&&(t[h][1]=a.substring(a.length-e)+t[h][1],a=a.substring(0,a.length-e),r=r.substring(0,r.length-e))),0===n?t.splice(h-i,n+i,[DIFF_INSERT,a]):0===i?t.splice(h-n,n+i,[DIFF_DELETE,r]):t.splice(h-n-i,n+i,[DIFF_DELETE,r],[DIFF_INSERT,a]),h=h-n-i+(n?1:0)+(i?1:0)+1):0!==h&&t[h-1][0]==DIFF_EQUAL?(t[h-1][1]+=t[h][1],t.splice(h,1)):h++,i=0,n=0,r="",a=""}""===t[t.length-1][1]&&t.pop();var f=!1;for(h=1;h<t.length-1;)t[h-1][0]==DIFF_EQUAL&&t[h+1][0]==DIFF_EQUAL&&(t[h][1].substring(t[h][1].length-t[h-1][1].length)==t[h-1][1]?(t[h][1]=t[h-1][1]+t[h][1].substring(0,t[h][1].length-t[h-1][1].length),t[h+1][1]=t[h-1][1]+t[h+1][1],t.splice(h-1,1),f=!0):t[h][1].substring(0,t[h+1][1].length)==t[h+1][1]&&(t[h-1][1]+=t[h+1][1],t[h][1]=t[h][1].substring(t[h+1][1].length)+t[h+1][1],t.splice(h+1,1),f=!0)),h++;f&&this.diff_cleanupMerge(t)},diff_match_patch.prototype.diff_xIndex=function(t,e){var h,n=0,i=0,r=0,a=0;for(h=0;h<t.length&&(t[h][0]!==DIFF_INSERT&&(n+=t[h][1].length),t[h][0]!==DIFF_DELETE&&(i+=t[h][1].length),!(n>e));h++)r=n,a=i;return t.length!=h&&t[h][0]===DIFF_DELETE?a:a+(e-r)},diff_match_patch.prototype.diff_prettyHtml=function(t){for(var e=/&/g,h=/</g,n=/>/g,i="<del",r="<ins",a="<span",f="\n",s=[],l=[],c=0;c<t.length;c++){var g=t[c][0],_=t[c][1],o=_.replace(e,"&").replace(h,"<").replace(n,">"),p=o.split(f);switch(g){case DIFF_INSERT:for(var d=[],u=0;u<p.length;u++)""===p[u]?d.push(""):d.push('<ins class="insert">'+p[u]+"</ins>");o=d.join(f),l.push(o);break;case DIFF_DELETE:for(var d=[],u=0;u<p.length;u++)""===p[u]?d.push(""):d.push('<del class="delete">'+p[u]+"</del>");o=d.join(f),s.push(o);break;case DIFF_EQUAL:for(var d=[],u=0;u<p.length;u++)""===p[u]?d.push(""):d.push("<span>"+p[u]+"</span>");o=d.join(f),s.push(o),l.push(o)}}var F=1,E=1,m=0,D=0,I=s.join("").split(f),b=l.join("").split(f),v=[],c=0;for(v.push(' <table class="inidiff"><thead><tr><th></th><th class="texttitle">Base Text</th><th></th><th class="texttitle">New Text</th></tr></thead><tbody>');m<I.length||D<b.length;)c++,m>=I.length||D<b.length&&0===b[D].indexOf(r)&&-1===b[D].indexOf(a)?(v.push('<tr><th></th><td class="empty"></td><th>'+E+'</th><td class="insert">'+b[D]+"</td></tr>"),D++,E++):D>=b.length||m<I.length&&0===I[m].indexOf(i)&&-1===I[m].indexOf(a)?(v.push("<tr><th>"+F+'</th><td class="delete">'+I[m]+'</td><th></th><td class="empty"></td></tr>'),m++,F++):-1!==I[m].indexOf(i)||-1!==b[D].indexOf(r)?(v.push("<tr><th>"+F+'</th><td class="replace">'+I[m]+"</td><th>"+E+'</th><td class="replace">'+b[D]+"</td></tr>"),m++,D++,F++,E++):(v.push("<tr><th>"+F+'</th><td class="equal">'+I[m]+"</td><th>"+E+'</th><td class="equal">'+b[D]+"</td></tr>"),m++,D++,F++,E++);return v.push("</tbody></table>"),v.join("")},diff_match_patch.prototype.diff_text1=function(t){for(var e=[],h=0;h<t.length;h++)t[h][0]!==DIFF_INSERT&&(e[h]=t[h][1]);return e.join("")},diff_match_patch.prototype.diff_text2=function(t){for(var e=[],h=0;h<t.length;h++)t[h][0]!==DIFF_DELETE&&(e[h]=t[h][1]);return e.join("")},diff_match_patch.prototype.diff_levenshtein=function(t){for(var e=0,h=0,n=0,i=0;i<t.length;i++){var r=t[i][0],a=t[i][1];switch(r){case DIFF_INSERT:h+=a.length;break;case DIFF_DELETE:n+=a.length;break;case DIFF_EQUAL:e+=Math.max(h,n),h=0,n=0}}return e+=Math.max(h,n)},diff_match_patch.prototype.diff_toDelta=function(t){for(var e=[],h=0;h<t.length;h++)switch(t[h][0]){case DIFF_INSERT:e[h]="+"+encodeURI(t[h][1]);break;case DIFF_DELETE:e[h]="-"+t[h][1].length;break;case DIFF_EQUAL:e[h]="="+t[h][1].length}return e.join(" ").replace(/%20/g," ")},diff_match_patch.prototype.diff_fromDelta=function(t,e){for(var h=[],n=0,i=0,r=e.split(/\t/g),a=0;a<r.length;a++){var f=r[a].substring(1);switch(r[a].charAt(0)){case"+":try{h[n++]=[DIFF_INSERT,decodeURI(f)]}catch(s){throw new Error("Illegal escape in diff_fromDelta: "+f)}break;case"-":case"=":var l=parseInt(f,10);if(isNaN(l)||0>l)throw new Error("Invalid number in diff_fromDelta: "+f);var c=t.substring(i,i+=l);"="==r[a].charAt(0)?h[n++]=[DIFF_EQUAL,c]:h[n++]=[DIFF_DELETE,c];break;default:if(r[a])throw new Error("Invalid diff operation in diff_fromDelta: "+r[a])}}if(i!=t.length)throw new Error("Delta length ("+i+") does not equal source text length ("+t.length+").");return h},diff_match_patch.prototype.match_main=function(t,e,h){if(null==t||null==e||null==h)throw new Error("Null input. (match_main)");return h=Math.max(0,Math.min(h,t.length)),t==e?0:t.length?t.substring(h,h+e.length)==e?h:this.match_bitap_(t,e,h):-1},diff_match_patch.prototype.match_bitap_=function(t,e,h){function n(t,n){var i=t/e.length,a=Math.abs(h-n);return r.Match_Distance?i+a/r.Match_Distance:a?1:i}if(e.length>this.Match_MaxBits)throw new Error("Pattern too long for this browser.");var i=this.match_alphabet_(e),r=this,a=this.Match_Threshold,f=t.indexOf(e,h);-1!=f&&(a=Math.min(n(0,f),a),f=t.lastIndexOf(e,h+e.length),-1!=f&&(a=Math.min(n(0,f),a)));var s=1<<e.length-1;f=-1;for(var l,c,g,_=e.length+t.length,o=0;o<e.length;o++){for(l=0,c=_;c>l;)n(o,h+c)<=a?l=c:_=c,c=Math.floor((_-l)/2+l);_=c;var p=Math.max(1,h-c+1),d=Math.min(h+c,t.length)+e.length,u=Array(d+2);u[d+1]=(1<<o)-1;for(var F=d;F>=p;F--){var E=i[t.charAt(F-1)];if(0===o?u[F]=(u[F+1]<<1|1)&E:u[F]=(u[F+1]<<1|1)&E|((g[F+1]|g[F])<<1|1)|g[F+1],u[F]&s){var m=n(o,F-1);if(a>=m){if(a=m,f=F-1,!(f>h))break;p=Math.max(1,2*h-f)}}}if(n(o+1,h)>a)break;g=u}return f},diff_match_patch.prototype.match_alphabet_=function(t){for(var e={},h=0;h<t.length;h++)e[t.charAt(h)]=0;for(var h=0;h<t.length;h++)e[t.charAt(h)]|=1<<t.length-h-1;return e},diff_match_patch.prototype.patch_addContext_=function(t,e){if(0!=e.length){for(var h=e.substring(t.start2,t.start2+t.length1),n=0;e.indexOf(h)!=e.lastIndexOf(h)&&h.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)n+=this.Patch_Margin,h=e.substring(t.start2-n,t.start2+t.length1+n);n+=this.Patch_Margin;var i=e.substring(t.start2-n,t.start2);i&&t.diffs.unshift([DIFF_EQUAL,i]);var r=e.substring(t.start2+t.length1,t.start2+t.length1+n);r&&t.diffs.push([DIFF_EQUAL,r]),t.start1-=i.length,t.start2-=i.length,t.length1+=i.length+r.length,t.length2+=i.length+r.length}},diff_match_patch.prototype.patch_make=function(t,e,h){var n,i;if("string"==typeof t&&"string"==typeof e&&"undefined"==typeof h)n=t,i=this.diff_main(n,e,!0),i.length>2&&(this.diff_cleanupSemantic(i),this.diff_cleanupEfficiency(i));else if(t&&"object"==typeof t&&"undefined"==typeof e&&"undefined"==typeof h)i=t,n=this.diff_text1(i);else if("string"==typeof t&&e&&"object"==typeof e&&"undefined"==typeof h)n=t,i=e;else{if("string"!=typeof t||"string"!=typeof e||!h||"object"!=typeof h)throw new Error("Unknown call format to patch_make.");n=t,i=h}if(0===i.length)return[];for(var r=[],a=new diff_match_patch.patch_obj,f=0,s=0,l=0,c=n,g=n,_=0;_<i.length;_++){var o=i[_][0],p=i[_][1];switch(f||o===DIFF_EQUAL||(a.start1=s,a.start2=l),o){case DIFF_INSERT:a.diffs[f++]=i[_],a.length2+=p.length,g=g.substring(0,l)+p+g.substring(l);break;case DIFF_DELETE:a.length1+=p.length,a.diffs[f++]=i[_],g=g.substring(0,l)+g.substring(l+p.length);break;case DIFF_EQUAL:p.length<=2*this.Patch_Margin&&f&&i.length!=_+1?(a.diffs[f++]=i[_],a.length1+=p.length,a.length2+=p.length):p.length>=2*this.Patch_Margin&&f&&(this.patch_addContext_(a,c),r.push(a),a=new diff_match_patch.patch_obj,f=0,c=g,s=l)}o!==DIFF_INSERT&&(s+=p.length),o!==DIFF_DELETE&&(l+=p.length)}return f&&(this.patch_addContext_(a,c),r.push(a)),r},diff_match_patch.prototype.patch_deepCopy=function(t){for(var e=[],h=0;h<t.length;h++){var n=t[h],i=new diff_match_patch.patch_obj;i.diffs=[];for(var r=0;r<n.diffs.length;r++)i.diffs[r]=n.diffs[r].slice();i.start1=n.start1,i.start2=n.start2,i.length1=n.length1,i.length2=n.length2,e[h]=i}return e},diff_match_patch.prototype.patch_apply=function(t,e){if(0==t.length)return[e,[]];t=this.patch_deepCopy(t);var h=this.patch_addPadding(t);e=h+e+h,this.patch_splitMax(t);for(var n=0,i=[],r=0;r<t.length;r++){var a,f=t[r].start2+n,s=this.diff_text1(t[r].diffs),l=-1;if(s.length>this.Match_MaxBits?(a=this.match_main(e,s.substring(0,this.Match_MaxBits),f),-1!=a&&(l=this.match_main(e,s.substring(s.length-this.Match_MaxBits),f+s.length-this.Match_MaxBits),(-1==l||a>=l)&&(a=-1))):a=this.match_main(e,s,f),-1==a)i[r]=!1,n-=t[r].length2-t[r].length1;else{i[r]=!0,n=a-f;var c;if(c=-1==l?e.substring(a,a+s.length):e.substring(a,l+this.Match_MaxBits),s==c)e=e.substring(0,a)+this.diff_text2(t[r].diffs)+e.substring(a+s.length);else{var g=this.diff_main(s,c,!1);if(s.length>this.Match_MaxBits&&this.diff_levenshtein(g)/s.length>this.Patch_DeleteThreshold)i[r]=!1;else{this.diff_cleanupSemanticLossless(g);for(var _,o=0,p=0;p<t[r].diffs.length;p++){var d=t[r].diffs[p];d[0]!==DIFF_EQUAL&&(_=this.diff_xIndex(g,o)),d[0]===DIFF_INSERT?e=e.substring(0,a+_)+d[1]+e.substring(a+_):d[0]===DIFF_DELETE&&(e=e.substring(0,a+_)+e.substring(a+this.diff_xIndex(g,o+d[1].length))),d[0]!==DIFF_DELETE&&(o+=d[1].length)}}}}}return e=e.substring(h.length,e.length-h.length),[e,i]},diff_match_patch.prototype.patch_addPadding=function(t){for(var e=this.Patch_Margin,h="",n=1;e>=n;n++)h+=String.fromCharCode(n);for(var n=0;n<t.length;n++)t[n].start1+=e,t[n].start2+=e;var i=t[0],r=i.diffs;if(0==r.length||r[0][0]!=DIFF_EQUAL)r.unshift([DIFF_EQUAL,h]),i.start1-=e,i.start2-=e,i.length1+=e,i.length2+=e;else if(e>r[0][1].length){var a=e-r[0][1].length;r[0][1]=h.substring(r[0][1].length)+r[0][1],i.start1-=a,i.start2-=a,i.length1+=a,i.length2+=a}if(i=t[t.length-1],r=i.diffs,0==r.length||r[r.length-1][0]!=DIFF_EQUAL)r.push([DIFF_EQUAL,h]),i.length1+=e,i.length2+=e;else if(e>r[r.length-1][1].length){var a=e-r[r.length-1][1].length;r[r.length-1][1]+=h.substring(0,a),i.length1+=a,i.length2+=a}return h},diff_match_patch.prototype.patch_splitMax=function(t){for(var e=this.Match_MaxBits,h=0;h<t.length;h++)if(!(t[h].length1<=e)){var n=t[h];t.splice(h--,1);for(var i=n.start1,r=n.start2,a="";0!==n.diffs.length;){var f=new diff_match_patch.patch_obj,s=!0;for(f.start1=i-a.length,f.start2=r-a.length,""!==a&&(f.length1=f.length2=a.length,f.diffs.push([DIFF_EQUAL,a]));0!==n.diffs.length&&f.length1<e-this.Patch_Margin;){var l=n.diffs[0][0],c=n.diffs[0][1];l===DIFF_INSERT?(f.length2+=c.length,r+=c.length,f.diffs.push(n.diffs.shift()),s=!1):l===DIFF_DELETE&&1==f.diffs.length&&f.diffs[0][0]==DIFF_EQUAL&&c.length>2*e?(f.length1+=c.length,i+=c.length,s=!1,f.diffs.push([l,c]),n.diffs.shift()):(c=c.substring(0,e-f.length1-this.Patch_Margin),f.length1+=c.length,i+=c.length,l===DIFF_EQUAL?(f.length2+=c.length,r+=c.length):s=!1,f.diffs.push([l,c]),c==n.diffs[0][1]?n.diffs.shift():n.diffs[0][1]=n.diffs[0][1].substring(c.length))}a=this.diff_text2(f.diffs),a=a.substring(a.length-this.Patch_Margin);var g=this.diff_text1(n.diffs).substring(0,this.Patch_Margin);""!==g&&(f.length1+=g.length,f.length2+=g.length,0!==f.diffs.length&&f.diffs[f.diffs.length-1][0]===DIFF_EQUAL?f.diffs[f.diffs.length-1][1]+=g:f.diffs.push([DIFF_EQUAL,g])),s||t.splice(++h,0,f)}}},diff_match_patch.prototype.patch_toText=function(t){for(var e=[],h=0;h<t.length;h++)e[h]=t[h];return e.join("")},diff_match_patch.prototype.patch_fromText=function(t){var e=[];if(!t)return e;for(var h=t.split("\n"),n=0,i=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;n<h.length;){var r=h[n].match(i);if(!r)throw new Error("Invalid patch string: "+h[n]);var a=new diff_match_patch.patch_obj;for(e.push(a),a.start1=parseInt(r[1],10),""===r[2]?(a.start1--,a.length1=1):"0"==r[2]?a.length1=0:(a.start1--,a.length1=parseInt(r[2],10)),a.start2=parseInt(r[3],10),""===r[4]?(a.start2--,a.length2=1):"0"==r[4]?a.length2=0:(a.start2--,a.length2=parseInt(r[4],10)),n++;n<h.length;){var f=h[n].charAt(0);try{var s=decodeURI(h[n].substring(1))}catch(l){throw new Error("Illegal escape in patch_fromText: "+s)}if("-"==f)a.diffs.push([DIFF_DELETE,s]);else if("+"==f)a.diffs.push([DIFF_INSERT,s]);else if(" "==f)a.diffs.push([DIFF_EQUAL,s]);else{if("@"==f)break;if(""!==f)throw new Error('Invalid patch mode "'+f+'" in: '+s)}n++}}return e},diff_match_patch.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0},diff_match_patch.patch_obj.prototype.toString=function(){var t,e;t=0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1,e=0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2;for(var h,n=["@@ -"+t+" +"+e+" @@\n"],i=0;i<this.diffs.length;i++){switch(this.diffs[i][0]){case DIFF_INSERT:h="+";break;case DIFF_DELETE:h="-";break;case DIFF_EQUAL:h=" "}n[i+1]=h+encodeURI(this.diffs[i][1])+"\n"}return n.join("").replace(/%20/g," ")},this.diff_match_patch=diff_match_patch,this.DIFF_DELETE=DIFF_DELETE,this.DIFF_INSERT=DIFF_INSERT,this.DIFF_EQUAL=DIFF_EQUAL;
// Ini v1.0
//
// Ini file parser supporting Git config syntax.
//
// Licensed under the MIT License
// Copyright 2012 Iván -DrSlump- Montes <[email protected]>
!function(t){function e(t){this.sect=new e.Section(null),t&&this.parse(t)}function n(t){return t.replace(/(^\s*)|(\s*$)/g,"")}var i="DEFAULT";e.prototype.get=function(t,n){""===t&&(t=i);var r=this.sect.get(t);return r instanceof e.Section&&(r=r.get(n)),r instanceof e.Property&&(r=r.value),r},e.prototype.parse=function(t){var e,r,o,s,c,a,p="",u=t.split(/\r\n|\r|\n/);for(a=this.sect.section(i),e=0;e<u.length;e++)if(r=u[e].replace(/^\s+/,"").replace(/\s+$/,""),0!==r.length)if("#"!==r.charAt(0)&&";"!==r.charAt(0))if("["!==r.charAt(0))"\\"!==r.charAt(r.length-1)?(p=p.length>0?p+" "+r:r,o=/^([^=]+)(\s*=\s*("(\\"|.)*"|[^#;]*)?)?/.exec(p),o&&o[0].length&&(s=n(o[1]),o[3]&&o[3].length?(c=o[3],c=c.replace(/^\s+|\s+$/g,""),'"'===c.charAt(0)&&'"'===c.charAt(c.length-1)?(c=c.substr(1,c.length-2),c=c.replace(/\\\\/g,"\\").replace(/\"/g,'"').replace(/\\n/g,"\n").replace(/\\t/g," ").replace(/\\b/g,"\b")):/^(yes|on|true)$/i.test(c)?c=!0:/^(no|off|false)$/i.test(c)?c=!1:/^[0-9]+$/i.test(c)&&(c=parseInt(c,10))):c=o[2]?"":!0,a.property(s,c)),p=""):p+=r.substr(0,r.length-1);else{var h=this;r.replace(/^\s*\[\s*([^\s\]"]+)(\s+"([^"]+))?/,function(t,e,n,i){a=h.sect.section(e,i||null)})}else a.comment(r.substr(1).replace(/^\s+/,""));else a.line()},e.prototype.toObject=function(){return this.sect.toObject()},e.prototype.toString=function(){return this.sect.toString()},e.parse=function(t){return new e(t)},e.Section=function(t,e){this.key=this.name=t,this.label=e||null,this.items=[],e&&(this.key+=":"+e)},e.Section.prototype.add=function(t){this.items.push(t)},e.Section.prototype.get=function(t){var e,n;for(e=this.items.length;e--;)if(n=this.items[e],"undefined"!=typeof n.key&&t===n.key)return n;return null},e.Section.prototype.section=function(t,n){for(var i=this.items,r=0;r<i.length;r++)if(i[r].name===t&&i[r].label===n)return i[r];var o=new e.Section(t,n);return this.add(o),o},e.Section.prototype.comment=function(t){var n=new e.Comment(t);return this.add(n),n},e.Section.prototype.line=function(){var t=new e.EmptyLine;return this.add(t),t},e.Section.prototype.property=function(t,n){var i=new e.Property(t,n);return this.add(i),i},e.Section.prototype.toObject=function(){var t,n={},i=this.items;for(t=0;t<i.length;t++)i[t]instanceof e.Section&&(n[i[t].key]=i[t].toObject()),i[t]instanceof e.Property&&(n[i[t].key]=i[t].value);return n},e.Section.prototype.toString=function(){for(var t="",n=0;n<this.items.length;n++)this.items[n]instanceof e.Section&&null!==this.items[n].name&&(t+="["+this.items[n].name,null!==this.items[n].label&&(t+=' "'+this.items[n].label+'"'),t+="]\n"),t+=this.items[n]+"\n";return t},e.Comment=function(t){this.text=t},e.Comment.prototype.toString=function(){return"# "+this.text},e.EmptyLine=function(){},e.EmptyLine.prototype.toString=function(){return""},e.Property=function(t,e){this.key=this.name=t,this.value=e},e.Property.prototype.toString=function(){if(null===this.value)return this.name;if(this.value===!1)return this.name+" = no";if(this.value===!0)return this.name+" = yes";var t=this.value.replace(/\n/g,"\\\n");return-1!==t.indexOf("#")||-1!==t.indexOf(";")?this.name+' = "'+t.replace(/"/g,'\\"')+'"':this.name+" = "+t},t.Ini=e}("undefined"!=typeof exports?exports:this);
// inidiff.js - Compare two ini file and efficiently return a list of differences
// Licensed under the MIT License
// Author: l2x <[email protected]>
!function(){function e(e,i){this.oldText=e,this.newText=i}function i(e,i){var t=e.toObject(),d=i.toObject(),r={add:{},update:{},"delete":{}};for(var o in d)for(var n in d[o]){var a=e.get(o,n);null!==a?a===d[o][n]||(void 0===r.update[o]&&(r.update[o]={}),r.update[o][n]=d[o][n]):(void 0===r.add[o]&&(r.add[o]={}),r.add[o][n]=d[o][n])}for(var o in t)for(var n in t[o]){var a=i.get(o,n);null!==a||(void 0===r["delete"][o]&&(r["delete"][o]={}),r["delete"][o][n]=t[o][n])}return r}e.prototype.prettyHtml=function(){var e=new diff_match_patch,i=e.diff_main(this.oldText,this.newText);return e.diff_cleanupEfficiency(i),e.diff_prettyHtml(i)},e.prototype.diff=function(){var e=new Ini(this.oldText),t=new Ini(this.newText);return i(e,t)},this.IniDiff=e;var t=".inidiff{border-collapse:collapse;border:1px solid darkgray;white-space:pre-wrap;word-wrap: break-word;word-break: break-all;}.inidiff tbody{font-family:Courier,monospace}.inidiff tbody th{font-family:verdana,arial,'Bitstream Vera Sans',helvetica,sans-serif;background:#EED;font-size:11px;font-weight:normal;min-width:30px;border:1px solid #BBC;color:#886;padding:.3em .5em .1em 2em;text-align:right;vertical-align:top}.inidiff thead{border-bottom:1px solid #BBC;background:#efefef;font-family:Verdana}.inidiff thead th.texttitle{text-align:left}.inidiff tbody td{padding:.2em 1em;vertical-align:top}.inidiff .empty{background-color:#DDD}.inidiff .replace{background-color:#FD8}.inidiff .delete{background-color:#E99}.inidiff .skip{background-color:#efefef;border:1px solid #AAA;border-right:1px solid #BBC}.inidiff .insert{background-color:#9E9}.inidiff th.author{text-align:right;border-top:1px solid #BBC;background:#efefef}.inidiff tr:hover th{background:#ddd!important}.inidiff ins.insert{text-decoration:none}.inidiff del.delete{text-decoration:none}";document.write('<style type="text/css">'+t+"</style>")}();