=0;t--){var c=r["_"+(n=a[t])],l=o.splice(n,1)[0];3===c[2]&&i.push({index:c[1],value:l})}var u=(i=i.sort(D("index"))).length;for(t=0;t0)for(t=0;tr?r++:i>=r&&st.length?e:t,i=e.length>t.length?t:e,s=a.indexOf(i);if(-1!=s)return o=[[1,a.substring(0,s)],[0,i],[1,a.substring(s+i.length)]],e.length>t.length&&(o[0][0]=o[2][0]=-1),o;if(1==i.length)return[[-1,e],[1,t]];var c=this.diff_halfMatch_(e,t);if(c){var l=c[0],u=c[1],f=c[2],p=c[3],d=c[4],h=this.diff_main(l,f,n,r),v=this.diff_main(u,p,n,r);return h.concat([[0,d]],v)}return n&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,r):this.diff_bisect_(e,t,r)},t.prototype.diff_lineMode_=function(e,t,n){e=(u=this.diff_linesToChars_(e,t)).chars1,t=u.chars2;var r=u.lineArray,o=this.diff_main(e,t,!1,n);this.diff_charsToLines_(o,r),this.diff_cleanupSemantic(o),o.push([0,""]);for(var a=0,i=0,s=0,c="",l="";a=1&&s>=1){o.splice(a-i-s,i+s),a=a-i-s;for(var u,f=(u=this.diff_main(c,l,!1,n)).length-1;f>=0;f--)o.splice(a,0,u[f]);a+=u.length}s=0,i=0,c="",l=""}a++}return o.pop(),o},t.prototype.diff_bisect_=function(e,t,n){for(var r=e.length,o=t.length,a=Math.ceil((r+o)/2),i=a,s=2*a,c=new Array(s),l=new Array(s),u=0;un);m++){for(var y=-m+d;y<=m-h;y+=2){for(var b=i+y,w=(O=y==-m||y!=m&&c[b-1]r)h+=2;else if(w>o)d+=2;else if(p&&(E=i+f-y)>=0&&E=(S=r-l[E]))return this.diff_bisectSplit_(e,t,O,w,n)}for(var x=-m+v;x<=m-g;x+=2){for(var S,E=i+x,I=(S=x==-m||x!=m&&l[E-1]r)g+=2;else if(I>o)v+=2;else if(!p){var O;if((b=i+f-x)>=0&&b=(S=r-S))return this.diff_bisectSplit_(e,t,O,w,n)}}}return[[-1,e],[1,t]]},t.prototype.diff_bisectSplit_=function(e,t,n,r,o){var a=e.substring(0,n),i=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,i,!1,o),u=this.diff_main(s,c,!1,o);return l.concat(u)},t.prototype.diff_linesToChars_=function(e,t){var n=[],r={};function o(e){for(var t="",o=0,a=-1,i=n.length;ar?e=e.substring(n-r):nt.length?e:t,r=e.length>t.length?t:e;if(n.length<4||2*r.length=e.length?[r,a,i,s,u]:null}var i,s,c,l,u,f=a(n,r,Math.ceil(n.length/4)),p=a(n,r,Math.ceil(n.length/2));return f||p?(i=p?f&&f[4].length>p[4].length?f:p:f,e.length>t.length?(s=i[0],c=i[1],l=i[2],u=i[3]):(l=i[0],u=i[1],s=i[2],c=i[3]),[s,c,l,u,i[4]]):null},t.prototype.diff_cleanupSemantic=function(e){for(var t=!1,n=[],r=0,o=null,a=0,i=0,s=0,c=0,l=0;a0?n[r-1]:-1,i=0,s=0,c=0,l=0,o=null,t=!0)),a++;for(t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),a=1;a=d?(p>=u.length/2||p>=f.length/2)&&(e.splice(a,0,[0,f.substring(0,p)]),e[a-1][1]=u.substring(0,u.length-p),e[a+1][1]=f.substring(p),a++):(d>=u.length/2||d>=f.length/2)&&(e.splice(a,0,[0,u.substring(0,d)]),e[a-1][0]=1,e[a-1][1]=f.substring(0,f.length-d),e[a+1][0]=-1,e[a+1][1]=u.substring(d),a++),a++}a++}},t.prototype.diff_cleanupSemanticLossless=function(e){function n(e,n){if(!e||!n)return 6;var r=e.charAt(e.length-1),o=n.charAt(0),a=r.match(t.nonAlphaNumericRegex_),i=o.match(t.nonAlphaNumericRegex_),s=a&&r.match(t.whitespaceRegex_),c=i&&o.match(t.whitespaceRegex_),l=s&&r.match(t.linebreakRegex_),u=c&&o.match(t.linebreakRegex_),f=l&&e.match(t.blanklineEndRegex_),p=u&&n.match(t.blanklineStartRegex_);return f||p?5:l||u?4:a&&!s&&c?3:s||c?2:a||i?1:0}for(var r=1;r=p&&(p=d,l=o,u=a,f=i)}e[r-1][1]!=l&&(l?e[r-1][1]=l:(e.splice(r-1,1),r--),e[r][1]=u,f?e[r+1][1]=f:(e.splice(r+1,1),r--))}r++}},t.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,t.whitespaceRegex_=/\s/,t.linebreakRegex_=/[\r\n]/,t.blanklineEndRegex_=/\n\r?\n$/,t.blanklineStartRegex_=/^\r?\n\r?\n/,t.prototype.diff_cleanupEfficiency=function(e){for(var t=!1,n=[],r=0,o=null,a=0,i=!1,s=!1,c=!1,l=!1;a0?n[r-1]:-1,c=l=!1),t=!0)),a++;t&&this.diff_cleanupMerge(e)},t.prototype.diff_cleanupMerge=function(e){e.push([0,""]);for(var t,n=0,r=0,o=0,a="",i="";n1?(0!==r&&0!==o&&(0!==(t=this.diff_commonPrefix(i,a))&&(n-r-o>0&&0==e[n-r-o-1][0]?e[n-r-o-1][1]+=i.substring(0,t):(e.splice(0,0,[0,i.substring(0,t)]),n++),i=i.substring(t),a=a.substring(t)),0!==(t=this.diff_commonSuffix(i,a))&&(e[n][1]=i.substring(i.length-t)+e[n][1],i=i.substring(0,i.length-t),a=a.substring(0,a.length-t))),0===r?e.splice(n-o,r+o,[1,i]):0===o?e.splice(n-r,r+o,[-1,a]):e.splice(n-r-o,r+o,[-1,a],[1,i]),n=n-r-o+(r?1:0)+(o?1:0)+1):0!==n&&0==e[n-1][0]?(e[n-1][1]+=e[n][1],e.splice(n,1)):n++,o=0,r=0,a="",i=""}""===e[e.length-1][1]&&e.pop();var s=!1;for(n=1;nt));n++)a=r,i=o;return e.length!=n&&-1===e[n][0]?i:i+(t-a)},t.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,r=//g,a=/\n/g,i=0;i");switch(s){case 1:t[i]=''+c+"";break;case-1:t[i]=''+c+"";break;case 0:t[i]=""+c+""}}return t.join("")},t.prototype.diff_text1=function(e){for(var t=[],n=0;nthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var r=this.match_alphabet_(t),o=this;function a(e,r){var a=e/t.length,i=Math.abs(n-r);return o.Match_Distance?a+i/o.Match_Distance:i?1:a}var i=this.Match_Threshold,s=e.indexOf(t,n);-1!=s&&(i=Math.min(a(0,s),i),-1!=(s=e.lastIndexOf(t,n+t.length))&&(i=Math.min(a(0,s),i)));var c,l,u=1<=h;m--){var y=r[e.charAt(m-1)];if(g[m]=0===d?(g[m+1]<<1|1)&y:(g[m+1]<<1|1)&y|(f[m+1]|f[m])<<1|1|f[m+1],g[m]&u){var b=a(d,m-1);if(b<=i){if(i=b,!((s=m-1)>n))break;h=Math.max(1,2*n-s)}}}if(a(d+1,n)>i)break;f=g}return s},t.prototype.match_alphabet_=function(e){for(var t={},n=0;n2&&(this.diff_cleanupSemantic(a),this.diff_cleanupEfficiency(a));else if(e&&"object"==typeof e&&void 0===n&&void 0===r)a=e,o=this.diff_text1(a);else if("string"==typeof e&&n&&"object"==typeof n&&void 0===r)o=e,a=n;else{if("string"!=typeof e||"string"!=typeof n||!r||"object"!=typeof r)throw new Error("Unknown call format to patch_make.");o=e,a=r}if(0===a.length)return[];for(var i=[],s=new t.patch_obj,c=0,l=0,u=0,f=o,p=o,d=0;d=2*this.Patch_Margin&&c&&(this.patch_addContext_(s,f),i.push(s),s=new t.patch_obj,c=0,f=p,l=u)}1!==h&&(l+=v.length),-1!==h&&(u+=v.length)}return c&&(this.patch_addContext_(s,f),i.push(s)),i},t.prototype.patch_deepCopy=function(e){for(var n=[],r=0;rthis.Match_MaxBits?-1!=(i=this.match_main(t,l.substring(0,this.Match_MaxBits),c))&&(-1==(u=this.match_main(t,l.substring(l.length-this.Match_MaxBits),c+l.length-this.Match_MaxBits))||i>=u)&&(i=-1):i=this.match_main(t,l,c),-1==i)o[a]=!1,r-=e[a].length2-e[a].length1;else if(o[a]=!0,r=i-c,l==(s=-1==u?t.substring(i,i+l.length):t.substring(i,u+this.Match_MaxBits)))t=t.substring(0,i)+this.diff_text2(e[a].diffs)+t.substring(i+l.length);else{var f=this.diff_main(l,s,!1);if(l.length>this.Match_MaxBits&&this.diff_levenshtein(f)/l.length>this.Patch_DeleteThreshold)o[a]=!1;else{this.diff_cleanupSemanticLossless(f);for(var p,d=0,h=0;ha[0][1].length){var i=t-a[0][1].length;a[0][1]=n.substring(a[0][1].length)+a[0][1],o.start1-=i,o.start2-=i,o.length1+=i,o.length2+=i}return 0==(a=(o=e[e.length-1]).diffs).length||0!=a[a.length-1][0]?(a.push([0,n]),o.length1+=t,o.length2+=t):t>a[a.length-1][1].length&&(i=t-a[a.length-1][1].length,a[a.length-1][1]+=n.substring(0,i),o.length1+=i,o.length2+=i),n},t.prototype.patch_splitMax=function(e){for(var n=this.Match_MaxBits,r=0;r2*n?(c.length1+=f.length,a+=f.length,l=!1,c.diffs.push([u,f]),o.diffs.shift()):(f=f.substring(0,n-c.length1-this.Patch_Margin),c.length1+=f.length,a+=f.length,0===u?(c.length2+=f.length,i+=f.length):l=!1,c.diffs.push([u,f]),f==o.diffs[0][1]?o.diffs.shift():o.diffs[0][1]=o.diffs[0][1].substring(f.length))}s=(s=this.diff_text2(c.diffs)).substring(s.length-this.Patch_Margin);var p=this.diff_text1(o.diffs).substring(0,this.Patch_Margin);""!==p&&(c.length1+=p.length,c.length2+=p.length,0!==c.diffs.length&&0===c.diffs[c.diffs.length-1][0]?c.diffs[c.diffs.length-1][1]+=p:c.diffs.push([0,p])),l||e.splice(++r,0,c)}}},t.prototype.patch_toText=function(e){for(var t=[],n=0;n'+t+"")}},{key:"formatValue",value:function(e,t){e.out(""+re(JSON.stringify(t,null,2))+"
")}},{key:"formatTextDiffString",value:function(e,t){var n=this.parseTextDiff(t);e.out('');for(var r=0,o=n.length;r'+a.location.line+''+a.location.chr+'
');for(var i=a.pieces,s=0,c=i.length;s'+re(decodeURI(l.text))+"")}e.out("
")}e.out("
")}},{key:"rootBegin",value:function(e,t,n){var r="jsondiffpatch-"+t+(n?" jsondiffpatch-child-node-type-"+n:"");e.out('')}},{key:"rootEnd",value:function(e){e.out("
"+(e.hasArrows?'