text: (function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"),require("diff_match_patch"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror","diff_match_patch"],a)}else{a(CodeMirror,diff_match_patch)}}})(function(u,Q){var l=u.Pos;var F="http://www.w3.org/2000/svg";function i(V,W){this.mv=V;this.type=W;this.classes=W=="left"?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}i.prototype={constructor:i,init:function(X,W,V){this.edit=this.mv.edit;(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this);this.orig=u(X,m({value:W,readOnly:!this.mv.options.allowEditingOriginals},m(V)));this.orig.state.diffViews=[this];this.diff=b(A(W),A(V.value));this.chunks=o(this.diff);this.diffOutOfDate=this.dealigned=false;this.showDifferences=V.showDifferences!==false;this.forceUpdate=O(this);r(this,true,false);e(this)},setShowDifferences:function(V){V=V!==false;if(V!=this.showDifferences){this.showDifferences=V;this.forceUpdate("full")}}};function G(V){if(V.diffOutOfDate){V.diff=b(V.orig.getValue(),V.edit.getValue());V.chunks=o(V.diff);V.diffOutOfDate=false;u.signal(V.edit,"updateDiff",V.diff)}}var U=false;function O(W){var ac={from:0,to:0,marked:[]};var aa={from:0,to:0,marked:[]};var V,ad=false;function X(ae){U=true;ad=false;if(ae=="full"){if(W.svg){E(W.svg)}if(W.copyButtons){E(W.copyButtons)}S(W.edit,ac.marked,W.classes);S(W.orig,aa.marked,W.classes);ac.from=ac.to=aa.from=aa.to=0}G(W);if(W.showDifferences){q(W.edit,W.diff,ac,DIFF_INSERT,W.classes);q(W.orig,W.diff,aa,DIFF_DELETE,W.classes)}n(W);if(W.mv.options.connect=="align"){f(W)}U=false}function Y(ae){if(U){return}W.dealigned=true;ab(ae)}function ab(ae){if(U||ad){return}clearTimeout(V);if(ae===true){ad=true}V=setTimeout(X,ae===true?20:250)}function Z(ae,af){if(!W.diffOutOfDate){W.diffOutOfDate=true;ac.from=ac.to=aa.from=aa.to=0}Y(af.text.length-1!=af.to.line-af.from.line)}W.edit.on("change",Z);W.orig.on("change",Z);W.edit.on("markerAdded",Y);W.edit.on("markerCleared",Y);W.orig.on("markerAdded",Y);W.orig.on("markerCleared",Y);W.edit.on("viewportChange",function(){ab(false)});W.orig.on("viewportChange",function(){ab(false)});X();return X}function e(V){V.edit.on("scroll",function(){x(V,DIFF_INSERT)&&n(V)});V.orig.on("scroll",function(){x(V,DIFF_DELETE)&&n(V)})}function x(ah,Z){if(ah.diffOutOfDate){return false}if(!ah.lockScroll){return true}var aa,ac,X=+new Date;if(Z==DIFF_INSERT){aa=ah.edit;ac=ah.orig}else{aa=ah.orig;ac=ah.edit}if(aa.state.scrollSetBy==ah&&(aa.state.scrollSetAt||0)+50>X){return false}var V=aa.getScrollInfo();if(ah.mv.options.connect=="align"){Y=V.top}else{var W=0.5*V.clientHeight,af=V.top+W;var al=aa.lineAtHeight(af,"local");var aj=T(ah.chunks,al,Z==DIFF_INSERT);var am=M(aa,Z==DIFF_INSERT?aj.edit:aj.orig);var ae=M(ac,Z==DIFF_INSERT?aj.orig:aj.edit);var ad=(af-am.top)/(am.bot-am.top);var Y=(ae.top-W)+ad*(ae.bot-ae.top);var ab,ag;if(Y>V.top&&(ag=V.top/W)<1){Y=Y*ag+V.top*(1-ag)}else{if((ab=V.height-V.clientHeight-V.top)<W){var ak=ac.getScrollInfo();var ai=ak.height-ak.clientHeight-Y;if(ai>ab&&(ag=ab/W)<1){Y=Y*ag+(ak.height-ak.clientHeight-ab)*(1-ag)}}}}ac.scrollTo(V.left,Y);ac.state.scrollSetAt=X;ac.state.scrollSetBy=ah;return true}function M(V,W){var X=W.after;if(X==null){X=V.lastLine()+1}return{top:V.heightAtLine(W.before||0,"local"),bot:V.heightAtLine(X,"local")}}function r(V,X,W){V.lockScroll=X;if(X&&W!=false){x(V,DIFF_INSERT)&&n(V)}V.lockButton.innerHTML=X?"\u21db\u21da":"\u21db&nbsp;&nbsp;\u21da"}function S(Y,V,X){for(var W=0;W<V.length;++W){var Z=V[W];if(Z instanceof u.TextMarker){Z.clear()}else{if(Z.parent){Y.removeLineClass(Z,"background",X.chunk);Y.removeLineClass(Z,"background",X.start);Y.removeLineClass(Z,"background",X.end)}}}V.length=0}function q(Y,aa,Z,X,W){var V=Y.getViewport();Y.operation(function(){if(Z.from==Z.to||V.from-Z.to>20||Z.from-V.to>20){S(Y,Z.marked,W);d(Y,aa,X,Z.marked,V.from,V.to,W);Z.from=V.from;Z.to=V.to}else{if(V.from<Z.from){d(Y,aa,X,Z.marked,V.from,Z.from,W);Z.from=V.from}if(V.to>Z.to){d(Y,aa,X,Z.marked,Z.to,V.to,W);Z.to=V.to}}})}function d(ac,af,ab,al,ak,X,an){var ad=l(0,0);var ah=l(ak,0),ag=ac.clipPos(l(X-1));var V=ab==DIFF_DELETE?an.del:an.insert;function ae(ax,at){var aw=Math.max(ak,ax),au=Math.min(X,at);for(var av=aw;av<au;++av){var ar=ac.addLineClass(av,"background",an.chunk);if(av==ax){ac.addLineClass(ar,"background",an.start)}if(av==at-1){ac.addLineClass(ar,"background",an.end)}al.push(ar)}if(ax==at&&aw==at&&au==at){if(aw){al.push(ac.addLineClass(aw-1,"background",an.end))}else{al.push(ac.addLineClass(aw,"background",an.start))}}}var aq=0;for(var am=0;am<af.length;++am){var aj=af[am],W=aj[0],ai=aj[1];if(W==DIFF_EQUAL){var aa=ad.line+(H(af,am)?0:1);C(ad,ai);var Z=ad.line+(K(af,am)?1:0);if(Z>aa){if(am){ae(aq,aa)}aq=Z}}else{if(W==ab){var Y=C(ad,ai,true);var ap=I(ah,ad),ao=j(ag,Y);if(!N(ap,ao)){al.push(ac.markText(ap,ao,{className:V}))}ad=Y}}}if(aq<=ad.line){ae(aq,ad.line+1)}}function n(Z){if(!Z.showDifferences){return}if(Z.svg){E(Z.svg);var W=Z.gap.offsetWidth;h(Z.svg,"width",W,"height",Z.gap.offsetHeight)}if(Z.copyButtons){E(Z.copyButtons)}var ac=Z.edit.getViewport(),X=Z.orig.getViewport();var V=Z.edit.getScrollInfo().top,ab=Z.orig.getScrollInfo().top;for(var Y=0;Y<Z.chunks.length;Y++){var aa=Z.chunks[Y];if(aa.editFrom<=ac.to&&aa.editTo>=ac.from&&aa.origFrom<=X.to&&aa.origTo>=X.from){a(Z,aa,ab,V,W)}}}function y(aa,Z){var Y=0,X=0;for(var W=0;W<Z.length;W++){var V=Z[W];if(V.editTo>aa&&V.editFrom<=aa){return null}if(V.editFrom>aa){break}Y=V.editTo;X=V.origTo}return X+(aa-Y)}function k(aa,V){var Z=[];for(var Y=0;Y<aa.chunks.length;Y++){var X=aa.chunks[Y];Z.push([X.origTo,X.editTo,V?y(X.editTo,V.chunks):null])}if(V){for(var Y=0;Y<V.chunks.length;Y++){var X=V.chunks[Y];for(var W=0;W<Z.length;W++){var ab=Z[W];if(ab[1]==X.editTo){W=-1;break}else{if(ab[1]>X.editTo){break}}}if(W>-1){Z.splice(W-1,0,[y(X.editTo,aa.chunks),X.editTo,X.origTo])}}}return Z}function f(V,W){if(!V.dealigned&&!W){return}if(!V.orig.curOp){return V.orig.operation(function(){f(V,W)})}V.dealigned=false;var Z=V.mv.left==V?V.mv.right:V.mv.left;if(Z){G(Z);Z.dealigned=false}var Y=k(V,Z);var ad=V.mv.aligners;for(var X=0;X<ad.length;X++){ad[X].clear()}ad.length=0;var ac=[V.orig,V.edit],ab=[];if(Z){ac.push(Z.orig)}for(var X=0;X<ac.length;X++){ab.push(ac[X].getScrollInfo().top)}for(var aa=0;aa<Y.length;aa++){J(ac,Y[aa],ad)}for(var X=0;X<ac.length;X++){ac[X].scrollTo(null,ab[X])}}function J(V,W,Z){var Y=0,ac=[];for(var X=0;X<V.length;X++){if(W[X]!=null){var ab=V[X].heightAtLine(W[X],"local");ac[X]=ab;Y=Math.max(Y,ab)}}for(var X=0;X<V.length;X++){if(W[X]!=null){var aa=Y-ac[X];if(aa>1){Z.push(B(V[X],W[X],aa))}}}}function B(W,X,Z){var V=true;if(X>W.lastLine()){X--;V=false}var Y=document.createElement("div");Y.className="CodeMirror-merge-spacer";Y.style.height=Z+"px";Y.style.minWidth="1px";return W.addLineWidget(X,Y,{height:Z,above:V})}function a(ad,ac,ah,W,ab){var Y=ad.type=="left";var af=ad.orig.heightAtLine(ac.origFrom,"local")-ah;if(ad.svg){var V=af;var aa=ad.edit.heightAtLine(ac.editFrom,"local")-W;if(Y){var am=V;V=aa;aa=am}var Z=ad.orig.heightAtLine(ac.origTo,"local")-ah;var ai=ad.edit.heightAtLine(ac.editTo,"local")-W;if(Y){var am=Z;Z=ai;ai=am}var ag=" C "+ab/2+" "+aa+" "+ab/2+" "+V+" "+(ab+2)+" "+V;var ae=" C "+ab/2+" "+Z+" "+ab/2+" "+ai+" -1 "+ai;h(ad.svg.appendChild(document.createElementNS(F,"path")),"d","M -1 "+aa+ag+" L "+(ab+2)+" "+Z+ae+" z","class",ad.classes.connect)}if(ad.copyButtons){var ak=ad.copyButtons.appendChild(L("div",ad.type=="left"?"\u21dd":"\u21dc","CodeMirror-merge-copy"));var aj=ad.mv.options.allowEditingOriginals;ak.title=aj?"Push to left":"Revert chunk";ak.chunk=ac;ak.style.top=af+"px";if(aj){var al=ad.orig.heightAtLine(ac.editFrom,"local")-W;var X=ad.copyButtons.appendChild(L("div",ad.type=="right"?"\u21dd":"\u21dc","CodeMirror-merge-copy-reverse"));X.title="Push to right";X.chunk={editFrom:ac.origFrom,editTo:ac.origTo,origFrom:ac.editFrom,origTo:ac.editTo};X.style.top=al+"px";ad.type=="right"?X.style.left="2px":X.style.right="2px"}}}function p(W,Y,X,V){if(W.diffOutOfDate){return}Y.replaceRange(X.getRange(l(V.origFrom,0),l(V.origTo,0)),l(V.editFrom,0),l(V.editTo,0))}var t=u.MergeView=function(aa,ak){if(!(this instanceof t)){return new t(aa,ak)}this.options=ak;var ad=ak.origLeft,ab=ak.origRight==null?ak.orig:ak.origRight;var ag=ad!=null,al=ab!=null;var ae=1+(ag?1:0)+(al?1:0);var X=[],Z=this.left=null,ah=this.right=null;var aj=this;if(ag){Z=this.left=new i(this,"left");var W=L("div",null,"CodeMirror-merge-pane");X.push(W);X.push(z(Z))}var ac=L("div",null,"CodeMirror-merge-pane");X.push(ac);if(al){ah=this.right=new i(this,"right");X.push(z(ah));var af=L("div",null,"CodeMirror-merge-pane");X.push(af)}(al?af:ac).className+=" CodeMirror-merge-pane-rightmost";X.push(L("div",null,null,"height: 0; clear: both;"));var Y=this.wrap=aa.appendChild(L("div",X,"CodeMirror-merge CodeMirror-merge-"+ae+"pane"));this.edit=u(ac,m(ak));if(Z){Z.init(W,ad,ak)}if(ah){ah.init(af,ab,ak)}if(ak.collapseIdentical){U=true;this.editor().operation(function(){P(aj,ak.collapseIdentical)});U=false}if(ak.connect=="align"){this.aligners=[];f(this.left||this.right,true)}var V=function(){if(Z){n(Z)}if(ah){n(ah)}};u.on(window,"resize",V);var ai=setInterval(function(){for(var am=Y.parentNode;am&&am!=document.body;am=am.parentNode){}if(!am){clearInterval(ai);u.off(window,"resize",V)}},5000)};function z(Y){var X=Y.lockButton=L("div",null,"CodeMirror-merge-scrolllock");X.title="Toggle locked scrolling";var Z=L("div",[X],"CodeMirror-merge-scrolllock-wrap");u.on(X,"click",function(){r(Y,!Y.lockScroll)});var W=[Z];if(Y.mv.options.revertButtons!==false){Y.copyButtons=L("div",null,"CodeMirror-merge-copybuttons-"+Y.type);u.on(Y.copyButtons,"click",function(ab){var aa=ab.target||ab.srcElement;if(!aa.chunk){return}if(aa.className=="CodeMirror-merge-copy-reverse"){p(Y,Y.orig,Y.edit,aa.chunk);return}p(Y,Y.edit,Y.orig,aa.chunk)});W.unshift(Y.copyButtons)}if(Y.mv.options.connect!="align"){var V=document.createElementNS&&document.createElementNS(F,"svg");if(V&&!V.createSVGRect){V=null}Y.svg=V;if(V){W.push(V)}}return Y.gap=L("div",W,"CodeMirror-merge-gap")}t.prototype={constuctor:t,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(V){if(this.right){this.right.setShowDifferences(V)}if(this.left){this.left.setShowDifferences(V)}},rightChunks:function(){if(this.right){G(this.right);return this.right.chunks}},leftChunks:function(){if(this.left){G(this.left);return this.left.chunks}}};function A(V){if(typeof V=="string"){return V}else{return V.getValue()}}var D=new Q();function b(W,V){var Z=D.diff_main(W,V);D.diff_cleanupSemantic(Z);for(var Y=0;Y<Z.length;++Y){var X=Z[Y];if(!X[1]){Z.splice(Y--,1)}else{if(Y&&Z[Y-1][0]==X[0]){Z.splice(Y--,1);Z[Y][1]+=X[1]}}}return Z}function o(ai){var aa=[];var af=0,ae=0;var aj=l(0,0),ah=l(0,0);for(var X=0;X<ai.length;++X){var W=ai[X],ag=W[0];if(ag==DIFF_EQUAL){var V=H(ai,X)?0:1;var Z=aj.line+V,Y=ah.line+V;C(aj,W[1],null,ah);var ab=K(ai,X)?1:0;var ad=aj.line+ab,ac=ah.line+ab;if(ad>Z){if(X){aa.push({origFrom:ae,origTo:Y,editFrom:af,editTo:Z})}af=ad;ae=ac}}else{C(ag==DIFF_INSERT?aj:ah,W[1])}}if(af<=aj.line||ae<=ah.line){aa.push({origFrom:ae,origTo:ah.line+1,editFrom:af,editTo:aj.line+1})}return aa}function K(X,V){if(V==X.length-1){return true}var W=X[V+1][1];if(W.length==1||W.charCodeAt(0)!=10){return false}if(V==X.length-2){return true}W=X[V+2][1];return W.length>1&&W.charCodeAt(0)==10}function H(X,V){if(V==0){return true}var W=X[V-1][1];if(W.charCodeAt(W.length-1)!=10){return false}if(V==1){return true}W=X[V-2][1];return W.charCodeAt(W.length-1)==10}function T(Z,V,ab){var ad,af,X,aa;for(var W=0;W<Z.length;W++){var ac=Z[W];var ae=ab?ac.editFrom:ac.origFrom;var Y=ab?ac.editTo:ac.origTo;if(af==null){if(ae>V){af=ac.editFrom;aa=ac.origFrom}else{if(Y>V){af=ac.editTo;aa=ac.origTo}}}if(Y<=V){ad=ac.editTo;X=ac.origTo}else{if(ae<=V){ad=ac.editFrom;X=ac.origFrom}}}return{edit:{before:ad,after:af},orig:{before:X,after:aa}}}function w(W,aa,Z){W.addLineClass(aa,"wrap","CodeMirror-merge-collapsed-line");var X=document.createElement("span");X.className="CodeMirror-merge-collapsed-widget";X.title="Identical text collapsed. Click to expand.";var Y=W.markText(l(aa,0),l(Z-1),{inclusiveLeft:true,inclusiveRight:true,replacedWith:X,clearOnEnter:true});function V(){Y.clear();W.removeLineClass(aa,"wrap","CodeMirror-merge-collapsed-line")}X.addEventListener("click",V);return{mark:Y,clear:V}}function s(X,aa){var Z=[];function V(){for(var ac=0;ac<Z.length;ac++){Z[ac].clear()}}for(var W=0;W<aa.length;W++){var Y=aa[W];var ab=w(Y.cm,Y.line,Y.line+X);Z.push(ab);ab.mark.on("clear",V)}return Z[0].mark}function v(Z,aa,ab,V){for(var Y=0;Y<Z.chunks.length;Y++){var X=Z.chunks[Y];for(var W=X.editFrom-aa;W<X.editTo+aa;W++){var ac=W+ab;if(ac>=0&&ac<V.length){V[ac]=false}}}}function P(ae,Y){if(typeof Y!="number"){Y=2}var aa=[],ad=ae.editor(),V=ad.firstLine();for(var W=V,ab=ad.lastLine();W<=ab;W++){aa.push(true)}if(ae.left){v(ae.left,Y,V,aa)}if(ae.right){v(ae.right,Y,V,aa)}for(var Z=0;Z<aa.length;Z++){if(aa[Z]){var ag=Z+V;for(var af=1;Z<aa.length-1&&aa[Z+1];Z++,af++){}if(af>Y){var ac=[{line:ag,cm:ad}];if(ae.left){ac.push({line:y(ag,ae.left.chunks),cm:ae.left.orig})}if(ae.right){ac.push({line:y(ag,ae.right.chunks),cm:ae.right.orig})}var X=s(af,ac);if(ae.options.onCollapse){ae.options.onCollapse(ae,ag,af,X)}}}}}function L(V,Z,Y,X){var aa=document.createElement(V);if(Y){aa.className=Y}if(X){aa.style.cssText=X}if(typeof Z=="string"){aa.appendChild(document.createTextNode(Z))}else{if(Z){for(var W=0;W<Z.length;++W){aa.appendChild(Z[W])}}}return aa}function E(W){for(var V=W.childNodes.length;V>0;--V){W.removeChild(W.firstChild)}}function h(V){for(var W=1;W<arguments.length;W+=2){V.setAttribute(arguments[W],arguments[W+1])}}function m(W,V){if(!V){V={}}for(var X in W){if(W.hasOwnProperty(X)){V[X]=W[X]}}return V}function C(ab,Z,aa,W){var Y=aa?l(ab.line,ab.ch):ab,V=0;for(;;){var X=Z.indexOf("\n",V);if(X==-1){break}++Y.line;if(W){++W.line}V=X+1}Y.ch=(V?0:Y.ch)+(Z.length-V);if(W){W.ch=(V?0:W.ch)+(Z.length-V)}return Y}function j(W,V){return(W.line-V.line||W.ch-V.ch)<0?W:V}function I(W,V){return(W.line-V.line||W.ch-V.ch)>0?W:V}function N(W,V){return W.line==V.line&&W.ch==V.ch}function c(aa,Z,V){for(var X=aa.length-1;X>=0;X--){var W=aa[X];var Y=(V?W.origTo:W.editTo)-1;if(Y<Z){return Y}}}function g(aa,Z,V){for(var X=0;X<aa.length;X++){var W=aa[X];var Y=(V?W.origFrom:W.editFrom);if(Y>Z){return Y}}}function R(aa,W){var ac=null,ab=aa.state.diffViews,ad=aa.getCursor().line;if(ab){for(var Y=0;Y<ab.length;Y++){var V=ab[Y],X=aa==V.orig;G(V);var Z=W<0?c(V.chunks,ad,X):g(V.chunks,ad,X);if(Z!=null&&(ac==null||(W<0?Z>ac:Z<ac))){ac=Z}}}if(ac!=null){aa.setCursor(ac,0)}else{return u.Pass}}u.commands.goNextDiff=function(V){return R(V,1)};u.commands.goPrevDiff=function(V){return R(V,-1)}});