mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-05 20:09:06 +00:00
2 lines
50 KiB
JavaScript
2 lines
50 KiB
JavaScript
// @license released into the public domain
|
||
"use strict";var wikEdDiffConfig,WED,WikEdDiff=function(){this.config={fullDiff:!1,showBlockMoves:!0,charDiff:!0,repeatedDiff:!0,recursiveDiff:!0,recursionMax:10,unlinkBlocks:!0,unlinkMax:5,blockMinLength:3,coloredBlocks:!1,noUnicodeSymbols:!1,stripTrailingNewline:!0,debug:!1,timer:!1,unitTesting:!1,regExpLetters:"a-zA-Z0-9"+"00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05270531-055605590561-058705D0-05EA05F0-05F20620-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280840-085808A008A2-08AC0904-0939093D09500958-09610971-09770979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10CF10CF20D05-0D0C0D0E-0D100D12-0D3A0D3D0D4E0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC-0EDF0F000F40-0F470F49-0F6C0F88-0F8C1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510C710CD10D0-10FA10FC-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1BBA-1BE51C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11CF51CF61D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209C21022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2CF22CF32D00-2D252D272D2D2D30-2D672D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31BA31F0-31FF3400-4DB54E00-9FCCA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78B-A78EA790-A793A7A0-A7AAA7F8-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDAAE0-AAEAAAF2-AAF4AB01-AB06AB09-AB0EAB11-AB16AB20-AB26AB28-AB2EABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC".replace(/(\w{4})/g,"\\u$1"),regExpNewLines:"\\u0085\\u2028",regExpNewLinesAll:"\\n\\r\\u0085\\u2028",regExpBlanks:" \\t\\x0b\\u2000-\\u200b\\u202f\\u205f\\u3000",regExpFullStops:"\\u0589\\u06D4\\u0701\\u0702\\u0964\\u0DF4\\u1362\\u166E\\u1803\\u1809\\u2CF9\\u2CFE\\u2E3C\\u3002\\uA4FF\\uA60E\\uA6F3\\uFE52\\uFF0E\\uFF61",regExpNewParagraph:"\\f\\u2029",regExpExclamationMarks:"\\u01C3\\u01C3\\u01C3\\u055C\\u055C\\u07F9\\u1944\\u1944\\u203C\\u203C\\u2048\\u2048\\uFE15\\uFE57\\uFF01",regExpQuestionMarks:"\\u037E\\u055E\\u061F\\u1367\\u1945\\u2047\\u2049\\u2CFA\\u2CFB\\u2E2E\\uA60F\\uA6F7\\uFE56\\uFF1F",clipHeadingLeft:1500,clipParagraphLeftMax:1500,clipParagraphLeftMin:500,clipLineLeftMax:1e3,clipLineLeftMin:500,clipBlankLeftMax:1e3,clipBlankLeftMin:500,clipCharsLeft:500,clipHeadingRight:1500,clipParagraphRightMax:1500,clipParagraphRightMin:500,clipLineRightMax:1e3,clipLineRightMin:500,clipBlankRightMax:1e3,clipBlankRightMin:500,clipCharsRight:500,clipLinesRightMax:10,clipLinesLeftMax:10,clipSkipLines:5,clipSkipChars:1e3,cssMarkLeft:"◀",cssMarkRight:"▶",stylesheet:'.wikEdDiffInsert {font-weight: bold; background-color: #bbddff; color: #222; border-radius: 0.25em; padding: 0.2em 1px; } .wikEdDiffInsertBlank { background-color: #66bbff; } .wikEdDiffFragment:hover .wikEdDiffInsertBlank { background-color: #bbddff; } .wikEdDiffDelete {font-weight: bold; background-color: #ffe49c; color: #222; border-radius: 0.25em; padding: 0.2em 1px; } .wikEdDiffDeleteBlank { background-color: #ffd064; } .wikEdDiffFragment:hover .wikEdDiffDeleteBlank { background-color: #ffe49c; } .wikEdDiffBlock {font-weight: bold; background-color: #e8e8e8; border-radius: 0.25em; padding: 0.2em 1px; margin: 0 1px; } .wikEdDiffBlock { color: #000; } .wikEdDiffBlock0 { background-color: #ffff80; } .wikEdDiffBlock1 { background-color: #d0ff80; } .wikEdDiffBlock2 { background-color: #ffd8f0; } .wikEdDiffBlock3 { background-color: #c0ffff; } .wikEdDiffBlock4 { background-color: #fff888; } .wikEdDiffBlock5 { background-color: #bbccff; } .wikEdDiffBlock6 { background-color: #e8c8ff; } .wikEdDiffBlock7 { background-color: #ffbbbb; } .wikEdDiffBlock8 { background-color: #a0e8a0; } .wikEdDiffBlockHighlight {background-color: #777; color: #fff; border: solid #777; border-width: 1px 0; } .wikEdDiffMarkLeft, .wikEdDiffMarkRight {font-weight: bold; background-color: #ffe49c; color: #666; border-radius: 0.25em; padding: 0.2em; margin: 0 1px; } .wikEdDiffMarkLeft:before { content: "{cssMarkLeft}"; } .wikEdDiffMarkRight:before { content: "{cssMarkRight}"; } .wikEdDiffMarkLeft.wikEdDiffNoUnicode:before { content: "<"; } .wikEdDiffMarkRight.wikEdDiffNoUnicode:before { content: ">"; } .wikEdDiffMark { background-color: #e8e8e8; color: #666; } .wikEdDiffMark0 { background-color: #ffff60; } .wikEdDiffMark1 { background-color: #c8f880; } .wikEdDiffMark2 { background-color: #ffd0f0; } .wikEdDiffMark3 { background-color: #a0ffff; } .wikEdDiffMark4 { background-color: #fff860; } .wikEdDiffMark5 { background-color: #b0c0ff; } .wikEdDiffMark6 { background-color: #e0c0ff; } .wikEdDiffMark7 { background-color: #ffa8a8; } .wikEdDiffMark8 { background-color: #98e898; } .wikEdDiffMarkHighlight { background-color: #777; color: #fff; } .wikEdDiffContainer { } .wikEdDiffFragment {white-space: pre-wrap; background-color: var(--background-color-base, #fff); border: #bbb solid; border-width: 1px 1px 1px 0.5em; border-radius: 0.5em; font-family: sans-serif; font-size: 88%; line-height: 1.6; box-shadow: 2px 2px 2px #ddd; padding: 1em; margin: 0; } .wikEdDiffNoChange { background: #f0f0f0; border: 1px #bbb solid; border-radius: 0.5em; line-height: 1.6; box-shadow: 2px 2px 2px #ddd; padding: 0.5em; margin: 1em 0; text-align: center; } .wikEdDiffSeparator { margin-bottom: 1em; } .wikEdDiffOmittedChars { } .wikEdDiffNewline:before { content: "¶"; color: transparent; } .wikEdDiffBlock:hover .wikEdDiffNewline:before { color: #aaa; } .wikEdDiffBlockHighlight .wikEdDiffNewline:before { color: transparent; } .wikEdDiffBlockHighlight:hover .wikEdDiffNewline:before { color: #ccc; } .wikEdDiffBlockHighlight:hover .wikEdDiffInsert .wikEdDiffNewline:before, .wikEdDiffInsert:hover .wikEdDiffNewline:before{ color: #999; } .wikEdDiffBlockHighlight:hover .wikEdDiffDelete .wikEdDiffNewline:before, .wikEdDiffDelete:hover .wikEdDiffNewline:before{ color: #aaa; } .wikEdDiffTab { position: relative; } .wikEdDiffTabSymbol { position: absolute; top: -0.2em; } .wikEdDiffTabSymbol:before { content: "→"; font-size: smaller; color: #ccc; } .wikEdDiffBlock .wikEdDiffTabSymbol:before { color: #aaa; } .wikEdDiffBlockHighlight .wikEdDiffTabSymbol:before { color: #aaa; } .wikEdDiffInsert .wikEdDiffTabSymbol:before { color: #aaa; } .wikEdDiffDelete .wikEdDiffTabSymbol:before { color: #bbb; } .wikEdDiffSpace { position: relative; } .wikEdDiffSpaceSymbol { position: absolute; top: -0.2em; left: -0.05em; } .wikEdDiffSpaceSymbol:before { content: "·"; color: transparent; } .wikEdDiffBlock:hover .wikEdDiffSpaceSymbol:before { color: #999; } .wikEdDiffBlockHighlight .wikEdDiffSpaceSymbol:before { color: transparent; } .wikEdDiffBlockHighlight:hover .wikEdDiffSpaceSymbol:before { color: #ddd; } .wikEdDiffBlockHighlight:hover .wikEdDiffInsert .wikEdDiffSpaceSymbol:before,.wikEdDiffInsert:hover .wikEdDiffSpaceSymbol:before { color: #888; } .wikEdDiffBlockHighlight:hover .wikEdDiffDelete .wikEdDiffSpaceSymbol:before,.wikEdDiffDelete:hover .wikEdDiffSpaceSymbol:before { color: #999; } .wikEdDiffError .wikEdDiffFragment,.wikEdDiffError .wikEdDiffNoChange{ background: #faa; }'},this.config.regExp={split:{paragraph:new RegExp("(\\r\\n|\\n|\\r){2,}|["+this.config.regExpNewParagraph+"]","g"),line:new RegExp("\\r\\n|\\n|\\r|["+this.config.regExpNewLinesAll+"]","g"),sentence:new RegExp("[^"+this.config.regExpBlanks+"].*?[.!?:;"+this.config.regExpFullStops+this.config.regExpExclamationMarks+this.config.regExpQuestionMarks+"]+(?=["+this.config.regExpBlanks+"]|$)","g"),chunk:new RegExp('\\[\\[[^\\[\\]\\n]+\\]\\]|\\{\\{[^\\{\\}\\n]+\\}\\}|\\[[^\\[\\]\\n]+\\]|<\\/?[^<>\\[\\]\\{\\}\\n]+>|\\[\\[[^\\[\\]\\|\\n]+\\]\\]\\||\\{\\{[^\\{\\}\\|\\n]+\\||\\b((https?:|)\\/\\/)[^\\x00-\\x20\\s"\\[\\]\\x7f]+',"g"),word:new RegExp("(\\w+|[_"+this.config.regExpLetters+"])+(['’][_"+this.config.regExpLetters+"]*)*|\\[\\[|\\]\\]|\\{\\{|\\}\\}|&\\w+;|'''|''|==+|\\{\\||\\|\\}|\\|-|.","g"),character:/./g},blankOnlyToken:new RegExp("[^"+this.config.regExpBlanks+this.config.regExpNewLinesAll+this.config.regExpNewParagraph+"]"),slideStop:new RegExp("["+this.config.regExpNewLinesAll+this.config.regExpNewParagraph+"]$"),slideBorder:new RegExp("["+this.config.regExpBlanks+"]$"),countWords:new RegExp("(\\w+|[_"+this.config.regExpLetters+"])+(['’][_"+this.config.regExpLetters+"]*)*","g"),countChunks:new RegExp('\\[\\[[^\\[\\]\\n]+\\]\\]|\\{\\{[^\\{\\}\\n]+\\}\\}|\\[[^\\[\\]\\n]+\\]|<\\/?[^<>\\[\\]\\{\\}\\n]+>|\\[\\[[^\\[\\]\\|\\n]+\\]\\]\\||\\{\\{[^\\{\\}\\|\\n]+\\||\\b((https?:|)\\/\\/)[^\\x00-\\x20\\s"\\[\\]\\x7f]+',"g"),blankBlock:/^([^\t\S]+|[^\t])$/,clipLine:new RegExp("["+this.config.regExpNewLinesAll+this.config.regExpNewParagraph+"]+","g"),clipHeading:new RegExp("( ^|\\n)(==+.+?==+|\\{\\||\\|\\}).*?(?=\\n|$)","g"),clipParagraph:new RegExp("( (\\r\\n|\\n|\\r){2,}|["+this.config.regExpNewParagraph+"])+","g"),clipBlank:new RegExp("["+this.config.regExpBlanks+"]+","g"),clipTrimNewLinesLeft:new RegExp("["+this.config.regExpNewLinesAll+this.config.regExpNewParagraph+"]+$","g"),clipTrimNewLinesRight:new RegExp("^["+this.config.regExpNewLinesAll+this.config.regExpNewParagraph+"]+","g"),clipTrimBlanksLeft:new RegExp("["+this.config.regExpBlanks+this.config.regExpNewLinesAll+this.config.regExpNewParagraph+"]+$","g"),clipTrimBlanksRight:new RegExp("^["+this.config.regExpBlanks+this.config.regExpNewLinesAll+this.config.regExpNewParagraph+"]+","g")},this.config.msg={"wiked-diff-empty":"(No difference)","wiked-diff-same":"=","wiked-diff-ins":"+","wiked-diff-del":"-","wiked-diff-block-left":"◀","wiked-diff-block-right":"▶","wiked-diff-block-left-nounicode":"<","wiked-diff-block-right-nounicode":">","wiked-diff-error":"Error: diff not consistent with versions!"},this.config.htmlCode={noChangeStart:'<div class="wikEdDiffNoChange" title="'+this.config.msg["wiked-diff-same"]+'">',noChangeEnd:"</div>",containerStart:'<div class="wikEdDiffContainer" id="wikEdDiffContainer">',containerEnd:"</div>",fragmentStart:'<pre class="wikEdDiffFragment" style="white-space: pre-wrap;">',fragmentEnd:"</pre>",separator:'<div class="wikEdDiffSeparator"></div>',insertStart:'<span class="wikEdDiffInsert" title="'+this.config.msg["wiked-diff-ins"]+'">',insertStartBlank:'<span class="wikEdDiffInsert wikEdDiffInsertBlank" title="'+this.config.msg["wiked-diff-ins"]+'">',insertEnd:"</span>",deleteStart:'<span class="wikEdDiffDelete" title="'+this.config.msg["wiked-diff-del"]+'">',deleteStartBlank:'<span class="wikEdDiffDelete wikEdDiffDeleteBlank" title="'+this.config.msg["wiked-diff-del"]+'">',deleteEnd:"</span>",blockStart:'<span class="wikEdDiffBlock"title="{title}" id="wikEdDiffBlock{number}"onmouseover="wikEdDiffBlockHandler(undefined, this, \'mouseover\');">',blockColoredStart:'<span class="wikEdDiffBlock wikEdDiffBlock wikEdDiffBlock{number}"title="{title}" id="wikEdDiffBlock{number}"onmouseover="wikEdDiffBlockHandler(undefined, this, \'mouseover\');">',blockEnd:"</span>",markLeft:'<span class="wikEdDiffMarkLeft{nounicode}"title="{title}" id="wikEdDiffMark{number}"onmouseover="wikEdDiffBlockHandler(undefined, this, \'mouseover\');"></span>',markLeftColored:'<span class="wikEdDiffMarkLeft{nounicode} wikEdDiffMark wikEdDiffMark{number}"title="{title}" id="wikEdDiffMark{number}"onmouseover="wikEdDiffBlockHandler(undefined, this, \'mouseover\');"></span>',markRight:'<span class="wikEdDiffMarkRight{nounicode}"title="{title}" id="wikEdDiffMark{number}"onmouseover="wikEdDiffBlockHandler(undefined, this, \'mouseover\');"></span>',markRightColored:'<span class="wikEdDiffMarkRight{nounicode} wikEdDiffMark wikEdDiffMark{number}"title="{title}" id="wikEdDiffMark{number}"onmouseover="wikEdDiffBlockHandler(undefined, this, \'mouseover\');"></span>',newline:'<span class="wikEdDiffNewline">\n</span>',tab:'<span class="wikEdDiffTab"><span class="wikEdDiffTabSymbol"></span>\t</span>',space:'<span class="wikEdDiffSpace"><span class="wikEdDiffSpaceSymbol"></span> </span>',omittedChars:'<span class="wikEdDiffOmittedChars">…</span>',errorStart:'<div class="wikEdDiffError" title="Error: diff not consistent with versions!">',errorEnd:"</div>"},this.config.blockHandler=function(t,i,e){void 0===t&&void 0!==window.event&&(t=window.event);var n=i.id.replace(/\D/g,""),o=document.getElementById("wikEdDiffBlock"+n),l=document.getElementById("wikEdDiffMark"+n);if(null!==o&&null!==l){if("mouseover"===e&&(i.onmouseover=null,i.onmouseout=function(t){window.wikEdDiffBlockHandler(t,i,"mouseout")},i.onclick=function(t){window.wikEdDiffBlockHandler(t,i,"click")},o.className+=" wikEdDiffBlockHighlight",l.className+=" wikEdDiffMarkHighlight"),("mouseout"===e||"click"===e)&&(i.onmouseout=null,i.onmouseover=function(t){window.wikEdDiffBlockHandler(t,i,"mouseover")},"click"!==e)){o.className=o.className.replace(/ wikEdDiffBlockHighlight/g,""),l.className=l.className.replace(/ wikEdDiffMarkHighlight/g,"");var s=document.getElementById("wikEdDiffContainer");if(null!==s)for(var r=s.getElementsByTagName("span"),h=r.length,f=0;f<h;f++)r[f]!==o&&r[f]!==l&&(-1!==r[f].className.indexOf(" wikEdDiffBlockHighlight")?r[f].className=r[f].className.replace(/ wikEdDiffBlockHighlight/g,""):-1!==r[f].className.indexOf(" wikEdDiffMarkHighlight")&&(r[f].className=r[f].className.replace(/ wikEdDiffMarkHighlight/g,"")))}if("click"===e){var c,a,d,k=0,g=c=i===o?l:o;do{k+=g.offsetTop}while(null!==(g=g.offsetParent));a=void 0!==window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop,void 0!==t.pageY?d=t.pageY:void 0!==t.clientY&&(d=t.clientY+a);var u=12;void 0!==window.getComputedStyle&&(u=parseInt(window.getComputedStyle(c).getPropertyValue("line-height"))),window.scroll(0,k+a-d+u/2)}}},this.newText=null,this.oldText=null,this.symbols={token:[],hashTable:{},linked:!1},this.bordersDown=[],this.bordersUp=[],this.blocks=[],this.maxWords=0,this.groups=[],this.sections=[],this.timer={},this.recursionTimer=[],this.error=!1,this.fragments=[],this.html="",this.init=function(){if("object"==typeof wikEdDiffConfig&&this.deepCopy(wikEdDiffConfig,this.config),this.addStyleSheet(this.config.stylesheet),!0===this.config.showBlockMoves)if("object"==typeof GM_info){var t="var wikEdDiffBlockHandler = "+this.config.blockHandler.toString()+";";this.addScript(t)}else window.wikEdDiffBlockHandler=this.config.blockHandler},this.diff=function(t,i){return!0===this.config.timer&&this.time("total"),!0===this.config.timer&&this.time("diff"),this.error=!1,!0===this.config.stripTrailingNewline&&"\n"===i.substr(-1)&&t.substr(!1)&&(i=i.substr(0,i.length-1),t=t.substr(0,t.length-1)),this.newText=new WikEdDiff.WikEdDiffText(i,this),this.oldText=new WikEdDiff.WikEdDiffText(t,this),this.newText.text===this.oldText.text?(this.html=this.config.htmlCode.containerStart+this.config.htmlCode.noChangeStart+this.htmlEscape(this.config.msg["wiked-diff-empty"])+this.config.htmlCode.noChangeEnd+this.config.htmlCode.containerEnd,this.html):""===this.oldText.text||"\n"===this.oldText.text&&"\n"===this.newText.text.charAt(this.newText.text.length-1)?(this.html=this.config.htmlCode.containerStart+this.config.htmlCode.fragmentStart+this.config.htmlCode.insertStart+this.htmlEscape(this.newText.text)+this.config.htmlCode.insertEnd+this.config.htmlCode.fragmentEnd+this.config.htmlCode.containerEnd,this.html):""===this.newText.text||"\n"===this.newText.text&&"\n"===this.oldText.text.charAt(this.oldText.text.length-1)?(this.html=this.config.htmlCode.containerStart+this.config.htmlCode.fragmentStart+this.config.htmlCode.deleteStart+this.htmlEscape(this.oldText.text)+this.config.htmlCode.deleteEnd+this.config.htmlCode.fragmentEnd+this.config.htmlCode.containerEnd,this.html):(!0===this.config.timer&&this.time("paragraph split"),this.newText.splitText("paragraph"),this.oldText.splitText("paragraph"),!0===this.config.timer&&this.timeEnd("paragraph split"),this.calculateDiff("line"),!0===this.config.timer&&this.time("line split"),this.newText.splitRefine("line"),this.oldText.splitRefine("line"),!0===this.config.timer&&this.timeEnd("line split"),this.calculateDiff("line"),!0===this.config.timer&&this.time("sentence split"),this.newText.splitRefine("sentence"),this.oldText.splitRefine("sentence"),!0===this.config.timer&&this.timeEnd("sentence split"),this.calculateDiff("sentence"),!0===this.config.timer&&this.time("chunk split"),this.newText.splitRefine("chunk"),this.oldText.splitRefine("chunk"),!0===this.config.timer&&this.timeEnd("chunk split"),this.calculateDiff("chunk"),!0===this.config.timer&&this.time("word split"),this.newText.splitRefine("word"),this.oldText.splitRefine("word"),!0===this.config.timer&&this.timeEnd("word split"),this.calculateDiff("word",!0),!0===this.config.timer&&this.time("word slide"),this.slideGaps(this.newText,this.oldText),this.slideGaps(this.oldText,this.newText),!0===this.config.timer&&this.timeEnd("word slide"),!0===this.config.charDiff&&(!0===this.config.timer&&this.time("character split"),this.splitRefineChars(),!0===this.config.timer&&this.timeEnd("character split"),this.calculateDiff("character",!0),!0===this.config.timer&&this.time("character slide"),this.slideGaps(this.newText,this.oldText),this.slideGaps(this.oldText,this.newText),!0===this.config.timer&&this.timeEnd("character slide")),this.symbols=void 0,this.bordersDown=void 0,this.bordersUp=void 0,this.newText.words=void 0,this.oldText.words=void 0,this.newText.enumerateTokens(),this.oldText.enumerateTokens(),!0===this.config.timer&&this.time("blocks"),this.detectBlocks(),!0===this.config.timer&&this.timeEnd("blocks"),this.newText.tokens=void 0,this.oldText.tokens=void 0,this.getDiffFragments(),this.blocks=void 0,this.groups=void 0,this.sections=void 0,!0===this.config.timer&&this.timeEnd("diff"),!0===this.config.unitTesting&&(!0===this.config.timer&&this.time("unit tests"),this.unitTests(),!0===this.config.timer&&this.timeEnd("unit tests")),!1===this.config.fullDiff&&(!0===this.config.timer&&this.time("clip"),this.clipDiffFragments(),!0===this.config.timer&&this.timeEnd("clip")),!0===this.config.timer&&this.time("html"),this.getDiffHtml(),!0===this.config.timer&&this.timeEnd("html"),""===this.html&&(this.html=this.config.htmlCode.containerStart+this.config.htmlCode.noChangeStart+this.htmlEscape(this.config.msg["wiked-diff-empty"])+this.config.htmlCode.noChangeEnd+this.config.htmlCode.containerEnd),!0===this.error&&(this.html=this.config.htmlCode.errorStart+this.html+this.config.htmlCode.errorEnd),!0===this.config.timer&&this.timeEnd("total"),this.html)},this.splitRefineChars=function(){for(var t=[],i=null,e=this.newText.first,n=this.oldText.first;null!==e;){var o=this.newText.tokens[e].link,l=null;null!==n&&(l=this.oldText.tokens[n].link),null===i&&null===o&&null===l?(i=t.length,t.push({newFirst:e,newLast:e,newTokens:1,oldFirst:n,oldLast:n,oldTokens:null,charSplit:null})):null!==i&&null===o?(t[i].newLast=e,t[i].newTokens++):null!==i&&null!==o&&(i=null),null!==o&&(n=this.oldText.tokens[o].next),e=this.newText.tokens[e].next}var s=t.length;for(i=0;i<s;i++)for(n=t[i].oldFirst;null!==n&&null!==this.oldText.tokens[n]&&null===this.oldText.tokens[n].link;)t[i].oldLast=n,t[i].oldTokens++,n=this.oldText.tokens[n].next;for(s=t.length,i=0;i<s;i++){var r=!0;if(t[i].newTokens!==t[i].oldTokens){if(1===t[i].newTokens&&3===t[i].oldTokens){var h=this.newText.tokens[t[i].newFirst].token,f=this.oldText.tokens[t[i].oldFirst].token,c=this.oldText.tokens[t[i].oldLast].token;if(0!==h.indexOf(f)||h.indexOf(c)!==h.length-c.length)continue}else{if(1!==t[i].oldTokens||3!==t[i].newTokens)continue;h=this.oldText.tokens[t[i].oldFirst].token,f=this.newText.tokens[t[i].newFirst].token,c=this.newText.tokens[t[i].newLast].token;if(0!==h.indexOf(f)||h.indexOf(c)!==h.length-c.length)continue}t[i].charSplit=!0}else{for(e=t[i].newFirst,n=t[i].oldFirst;null!==e;){var a,d,k=this.newText.tokens[e].token,g=this.oldText.tokens[n].token;if(k.length<g.length?(a=k,d=g):(a=g,d=k),k.length!==g.length){for(var u=0;u<a.length&&k.charAt(u)===g.charAt(u);)u++;for(var p=0;p<a.length&&k.charAt(k.length-1-p)===g.charAt(g.length-1-p);)p++;if(u+p!==a.length&&-1===d.indexOf(a)&&u<a.length/2&&p<a.length/2){r=!1;break}}else if(k!==g){for(var m=0,x=a.length,w=0;w<x;w++)a.charAt(w)===d.charAt(w)&&m++;if(m/a.length<.49){r=!1;break}}if(e===t[i].newLast)break;e=this.newText.tokens[e].next,n=this.oldText.tokens[n].next}t[i].charSplit=r}}for(s=t.length,i=0;i<s;i++)if(!0===t[i].charSplit){e=t[i].newFirst,n=t[i].oldFirst;for(var E=e-t[i].newLast,b=n-t[i].oldLast;null!==e||null!==n;)E===b&&this.newText.tokens[e].token===this.oldText.tokens[n].token?(this.newText.tokens[e].link=n,this.oldText.tokens[n].link=e):(null!==e&&this.newText.splitText("character",e),null!==n&&this.oldText.splitText("character",n)),e===t[i].newLast&&(e=null),n===t[i].oldLast&&(n=null),null!==e&&(e=this.newText.tokens[e].next),null!==n&&(n=this.oldText.tokens[n].next)}},this.slideGaps=function(t,i){for(var e=this.config.regExp.slideBorder,n=this.config.regExp.slideStop,o=t.first,l=null;null!==o;){if(null===l&&null===t.tokens[o].link)l=o;else if(null!==l&&null!==t.tokens[o].link){var s=l,r=t.tokens[o].prev,h=s,f=t.tokens[r].next;null!==h&&null!==f&&null===t.tokens[h].link&&null!==t.tokens[f].link&&t.tokens[h].token===t.tokens[f].token&&(t.tokens[h].link=t.tokens[f].link,i.tokens[t.tokens[h].link].link=h,t.tokens[f].link=null,s=t.tokens[s].next,r=t.tokens[r].next,h=t.tokens[h].next,f=t.tokens[f].next);h=t.tokens[s].prev,f=r;var c=e.test(t.tokens[s].token),a=h;if(null===t.tokens[f].link)for(;null!==h&&null!==f&&null!==t.tokens[h].link&&t.tokens[h].token===t.tokens[f].token;){if(null!==h){if(!0===n.test(t.tokens[h].token)){a=h;break}e.test(t.tokens[h].token)!==c&&(a=h)}h=t.tokens[h].prev,f=t.tokens[f].prev}for(h=t.tokens[s].prev,f=r;null!==h&&null!==f&&h!==a&&null!==t.tokens[h].link&&null===t.tokens[f].link&&t.tokens[h].token===t.tokens[f].token;)t.tokens[f].link=t.tokens[h].link,i.tokens[t.tokens[f].link].link=f,t.tokens[h].link=null,h=t.tokens[h].prev,f=t.tokens[f].prev;l=null}o=t.tokens[o].next}},this.calculateDiff=function(t,i,e,n,o,l,s){var r,h,f;void 0===e&&(e=!1),void 0===i&&(i=!1),void 0===n&&(n=this.newText.first),void 0===o&&(o=this.oldText.first),void 0===l&&(l=!1),void 0===s&&(s=0),!0===this.config.timer&&!1===e&&0===s&&this.time(t),!0===this.config.timer&&!1===e&&this.time(t+s),0===s&&!1===e?(r=this.symbols,h=this.bordersDown,f=this.bordersUp):(r={token:[],hashTable:{},linked:!1},h=[],f=[]);for(var c=[],a=[],d=n;null!==d;){if(null===this.newText.tokens[d].link){var k=this.newText.tokens[d].token;if(!1===Object.prototype.hasOwnProperty.call(r.hashTable,k))r.hashTable[k]=r.token.length,r.token.push({newCount:1,oldCount:0,newToken:d,oldToken:null});else{var g=r.hashTable[k];r.token[g].newCount++}}else if(s>0)break;d=!1===l?this.newText.tokens[d].next:this.newText.tokens[d].prev}for(var u=o;null!==u;){if(null===this.oldText.tokens[u].link){k=this.oldText.tokens[u].token;if(!1===Object.prototype.hasOwnProperty.call(r.hashTable,k))r.hashTable[k]=r.token.length,r.token.push({newCount:0,oldCount:1,newToken:null,oldToken:u});else{g=r.hashTable[k];r.token[g].oldCount++,r.token[g].oldToken=u}}else if(s>0)break;u=!1===l?this.oldText.tokens[u].next:this.oldText.tokens[u].prev}var p=r.token.length;for(d=0;d<p;d++)if(1===r.token[d].newCount&&1===r.token[d].oldCount){var m=r.token[d].newToken,x=r.token[d].oldToken,w=this.newText.tokens[m],E=this.oldText.tokens[x];if(null===w.link&&!0===this.config.regExp.blankOnlyToken.test(w.token)&&(w.link=x,E.link=m,r.linked=!0,h.push([m,x]),f.push([m,x]),0===s)){var b=!1;if("character"===t)b=!0;else{var D=((k=w.token).match(this.config.regExp.countWords)||[]).concat(k.match(this.config.regExp.countChunks)||[]),B=D.length;if(B>=this.config.blockMinLength)b=!0;else for(d=0;d<B;d++){var A=D[d];if(1===this.oldText.words[A]&&1===this.newText.words[A]&&!0===Object.prototype.hasOwnProperty.call(this.oldText.words,A)&&!0===Object.prototype.hasOwnProperty.call(this.newText.words,A)){b=!0;break}}}!0===b&&(w.unique=!0,E.unique=!0)}}if(!0===r.linked){for(var C=h.length,v=0;v<C;v++){var T=d=h[v][0],F=u=h[v][1];for(d=this.newText.tokens[d].next,u=this.oldText.tokens[u].next;null!==d&&null!==u&&null===this.newText.tokens[d].link&&null===this.oldText.tokens[u].link;){if(this.newText.tokens[d].token!==this.oldText.tokens[u].token){a.push([T,F]);break}this.newText.tokens[d].link=u,this.oldText.tokens[u].link=d,T=d,F=u,d=this.newText.tokens[d].next,u=this.oldText.tokens[u].next}}for(C=f.length,v=0;v<C;v++){T=d=f[v][0],F=u=f[v][1];for(d=this.newText.tokens[d].prev,u=this.oldText.tokens[u].prev;null!==d&&null!==u&&null===this.newText.tokens[d].link&&null===this.oldText.tokens[u].link;){if(this.newText.tokens[d].token!==this.oldText.tokens[u].token){c.push([T,F]);break}this.newText.tokens[d].link=u,this.oldText.tokens[u].link=d,T=d,F=u,d=this.newText.tokens[d].prev,u=this.oldText.tokens[u].prev}}if(0===s&&!1===e){for(d=this.newText.first,u=this.oldText.first,T=null,F=null;null!==d&&null!==u&&null===this.newText.tokens[d].link&&null===this.oldText.tokens[u].link&&this.newText.tokens[d].token===this.oldText.tokens[u].token;)this.newText.tokens[d].link=u,this.oldText.tokens[u].link=d,T=d,F=u,d=this.newText.tokens[d].next,u=this.oldText.tokens[u].next;for(null!==T&&a.push([T,F]),d=this.newText.last,u=this.oldText.last,T=null,F=null;null!==d&&null!==u&&null===this.newText.tokens[d].link&&null===this.oldText.tokens[u].link&&this.newText.tokens[d].token===this.oldText.tokens[u].token;)this.newText.tokens[d].link=u,this.oldText.tokens[u].link=d,T=d,F=u,d=this.newText.tokens[d].prev,u=this.oldText.tokens[u].prev;null!==T&&c.push([T,F])}if(0===s&&!1===e?(this.bordersDown=a,this.bordersUp=c):(this.bordersDown=this.bordersDown.concat(a),this.bordersUp=this.bordersUp.concat(c)),!1===e&&!0===this.config.repeatedDiff){var S=!0;this.calculateDiff(t,i,S,n,o,l,s)}if(!0===i&&!0===this.config.recursiveDiff&&s<this.config.recursionMax){C=a.length;for(v=0;v<C;v++){d=a[v][0],u=a[v][1];if(d=this.newText.tokens[d].next,u=this.oldText.tokens[u].next,null!==d&&null!==u&&null===this.newText.tokens[d].link&&null===this.oldText.tokens[u].link){S=!1;var y=!1;this.calculateDiff(t,i,S,d,u,y,s+1)}}C=c.length;for(v=0;v<C;v++){d=c[v][0],u=c[v][1];if(d=this.newText.tokens[d].prev,u=this.oldText.tokens[u].prev,null!==d&&null!==u&&null===this.newText.tokens[d].link&&null===this.oldText.tokens[u].link){S=!1,y=!0;this.calculateDiff(t,i,S,d,u,y,s+1)}}}}!0===this.config.timer&&!1===e&&(void 0===this.recursionTimer[s]&&(this.recursionTimer[s]=0),this.recursionTimer[s]+=this.timeEnd(t+s,!0)),!0===this.config.timer&&!1===e&&0===s&&(this.timeRecursionEnd(t),this.timeEnd(t))},this.detectBlocks=function(){!0===this.config.debug&&(this.oldText.debugText("Old text"),this.newText.debugText("New text")),this.getSameBlocks(),this.getSections(),this.getGroups(),this.setFixed();var t=0;if(!0===this.config.unlinkBlocks&&this.config.blockMinLength>0&&this.maxWords>=this.config.blockMinLength){!0===this.config.timer&&this.time("total unlinking");for(var i=!0;!0===i&&t<this.config.unlinkMax;)!0===(i=this.unlinkBlocks())&&(t++,this.slideGaps(this.newText,this.oldText),this.slideGaps(this.oldText,this.newText),this.maxWords=0,this.getSameBlocks(),this.getSections(),this.getGroups(),this.setFixed());!0===this.config.timer&&this.timeEnd("total unlinking")}this.getDelBlocks(),this.positionDelBlocks(),this.getInsBlocks(),this.setInsGroups(),this.insertMarks(),!0!==this.config.timer&&!0!==this.config.debug||console.log("Unlink count: ",t),!0===this.config.debug&&(this.debugGroups("Groups"),this.debugBlocks("Blocks"))},this.getSameBlocks=function(){!0===this.config.timer&&this.time("getSameBlocks");var t=this.blocks;t.splice(0);for(var i=this.oldText.first,e=null;null!==i;){for(;null!==i&&null===this.oldText.tokens[i].link;)i=this.oldText.tokens[i].next;if(null!==i){for(var n=e=this.oldText.tokens[i].link,o=i,l=0,s=!1,r="";null!==e&&null!==i&&this.oldText.tokens[i].link===e;)r+=this.oldText.tokens[i].token,l++,!0===this.newText.tokens[e].unique&&(s=!0),e=this.newText.tokens[e].next,i=this.oldText.tokens[i].next;t.push({oldBlock:t.length,newBlock:null,oldNumber:this.oldText.tokens[o].number,newNumber:this.newText.tokens[n].number,oldStart:o,count:l,unique:s,words:this.wordCount(r),chars:r.length,type:"=",section:null,group:null,fixed:null,moved:null,text:r})}}t.sort((function(t,i){return t.newNumber-i.newNumber}));for(var h=t.length,f=0;f<h;f++)t[f].newBlock=f;!0===this.config.timer&&this.timeEnd("getSameBlocks")},this.getSections=function(){!0===this.config.timer&&this.time("getSections");var t=this.blocks,i=this.sections;i.splice(0);for(var e=t.length,n=0;n<e;n++){for(var o=n,l=n,s=t[o].oldNumber,r=s,h=o+1;h<e;h++)t[h].oldNumber>s?s=t[h].oldNumber:t[h].oldNumber<r&&(l=h,r=s);if(l>o){for(var f=o;f<=l;f++)t[f].section=i.length;i.push({blockStart:o,blockEnd:l}),n=l}}!0===this.config.timer&&this.timeEnd("getSections")},this.getGroups=function(){!0===this.config.timer&&this.time("getGroups");var t=this.blocks,i=this.groups;i.splice(0);for(var e=t.length,n=0;n<e;n++){for(var o=n,l=n,s=t[o].oldBlock,r=this.wordCount(t[n].text),h=r,f=t[n].unique,c=t[n].chars,a=l+1;a<e&&t[a].oldBlock===s+1;a++)s=t[a].oldBlock,t[a].words>h&&(h=t[a].words),!0===t[a].unique&&(f=!0),r+=t[a].words,c+=t[a].chars,l=a;if(l>=o){var d=!1;null===t[o].section&&(d=!0);for(a=o;a<=l;a++)t[a].group=i.length,t[a].fixed=d;i.push({oldNumber:t[o].oldNumber,blockStart:o,blockEnd:l,unique:f,maxWords:h,words:r,chars:c,fixed:d,movedFrom:null,color:null}),n=l,h>this.maxWords&&(this.maxWords=h)}}!0===this.config.timer&&this.timeEnd("getGroups")},this.setFixed=function(){!0===this.config.timer&&this.time("setFixed");for(var t=this.blocks,i=this.groups,e=this.sections,n=e.length,o=0;o<n;o++){for(var l=e[o].blockStart,s=e[o].blockEnd,r=t[l].group,h=t[s].group,f=[],c=0,a=null,d=r;d<=h;d++){var k=this.findMaxPath(d,h,f);k.chars>c&&(a=k.path,c=k.chars)}var g=a.length;for(d=0;d<g;d++){var u=a[d];i[u].fixed=!0;for(var p=i[u].blockStart;p<=i[u].blockEnd;p++)t[p].fixed=!0}}!0===this.config.timer&&this.timeEnd("setFixed")},this.findMaxPath=function(t,i,e){for(var n=this.groups,o=0,l=n[t].oldNumber,s={path:[],chars:0},r=t+1;r<=i;r++){var h;if(!(n[r].oldNumber<l))(h=void 0!==e[r]?{path:e[r].path.slice(),chars:e[r].chars}:this.findMaxPath(r,i,e)).chars>o&&(o=h.chars,s=h)}return s.path.unshift(t),s.chars+=n[t].chars,void 0===e[t]&&(e[t]={path:s.path.slice(),chars:s.chars}),s},this.unlinkBlocks=function(){for(var t=this.blocks,i=this.groups,e=!1,n=i.length,o=0;o<n;o++){var l=i[o].blockStart,s=i[o].blockEnd;if(i[o].maxWords<this.config.blockMinLength&&!1===i[o].unique)for(var r=l;r<=s;r++)"="===t[r].type&&(this.unlinkSingleBlock(t[r]),e=!0);else{for(r=l;r<=s;r++)if("="===t[r].type){if(t[r].words>1||!0===t[r].unique)break;this.unlinkSingleBlock(t[r]),e=!0,l=r}for(r=s;r>l;r--)if("="===t[r].type){if(t[r].words>1||1===t[r].words&&!0===t[r].unique)break;this.unlinkSingleBlock(t[r]),e=!0}}}return e},this.unlinkSingleBlock=function(t){for(var i=t.oldStart,e=0;e<t.count;e++)this.newText.tokens[this.oldText.tokens[i].link].link=null,this.oldText.tokens[i].link=null,i=this.oldText.tokens[i].next},this.getDelBlocks=function(){!0===this.config.timer&&this.time("getDelBlocks");for(var t=this.blocks,i=this.oldText.first,e=null;null!==i;){for(var n=i,o=0,l="";null!==i&&null===this.oldText.tokens[i].link;)o++,l+=this.oldText.tokens[i].token,i=this.oldText.tokens[i].next;if(0!==o&&t.push({oldBlock:null,newBlock:null,oldNumber:this.oldText.tokens[n].number,newNumber:null,oldStart:n,count:o,unique:!1,words:null,chars:l.length,type:"-",section:null,group:null,fixed:null,moved:null,text:l}),null!==i)for(e=this.oldText.tokens[i].link;null!==e&&null!==i&&this.oldText.tokens[i].link===e;)e=this.newText.tokens[e].next,i=this.oldText.tokens[i].next}!0===this.config.timer&&this.timeEnd("getDelBlocks")},this.positionDelBlocks=function(){!0===this.config.timer&&this.time("positionDelBlocks");var t=this.blocks,i=this.groups,e=t.slice();e.sort((function(t,i){return t.oldNumber-i.oldNumber}));for(var n=e.length,o=0;o<n;o++){var l=e[o];if("-"===l.type){var s=null,r=null;o>0&&(r=t[s=e[o-1].newBlock]);var h=null,f=null;o<e.length-1&&(f=t[h=e[o+1].newBlock]);var c=null;if(null!==r&&"="===r.type&&!0===r.fixed)c=r;else if(null!==f&&"="===f.type&&!0===f.fixed)c=f;else if(null!==r&&"="===r.type&&s!==i[r.group].blockEnd)c=r;else if(null!==f&&"="===f.type&&h!==i[f.group].blockStart)c=f;else for(var a=o;a>=0;a--)if("="===e[a].type&&!0===e[a].fixed){c=e[a];break}null===c?l.newNumber=-1:(l.newNumber=c.newNumber,l.section=c.section,l.group=c.group,l.fixed=c.fixed)}}this.sortBlocks(),!0===this.config.timer&&this.timeEnd("positionDelBlocks")},this.getInsBlocks=function(){!0===this.config.timer&&this.time("getInsBlocks");for(var t=this.blocks,i=this.newText.first;null!==i;){for(;null!==i&&null!==this.newText.tokens[i].link;)i=this.newText.tokens[i].next;if(null!==i){for(var e=i,n=0,o="";null!==i&&null===this.newText.tokens[i].link;)n++,o+=this.newText.tokens[i].token,i=this.newText.tokens[i].next;t.push({oldBlock:null,newBlock:null,oldNumber:null,newNumber:this.newText.tokens[e].number,oldStart:null,count:n,unique:!1,words:null,chars:o.length,type:"+",section:null,group:null,fixed:null,moved:null,text:o})}}this.sortBlocks(),!0===this.config.timer&&this.timeEnd("getInsBlocks")},this.sortBlocks=function(){var t=this.blocks,i=this.groups;t.sort((function(t,i){var e=t.newNumber-i.newNumber;return 0===e&&(e=t.oldNumber-i.oldNumber),e}));for(var e=null,n=t.length,o=0;o<n;o++){var l=t[o].group;null!==l&&(l!==e&&(i[e=t[o].group].blockStart=o,i[e].oldNumber=t[o].oldNumber),i[l].blockEnd=o)}},this.setInsGroups=function(){!0===this.config.timer&&this.time("setInsGroups");for(var t=this.blocks,i=this.groups,e=i.length,n=0;n<e;n++)for(var o=i[n].fixed,l=i[n].blockStart;l<=i[n].blockEnd;l++)null===t[l].group&&(t[l].group=n,t[l].fixed=o);var s=t.length;for(l=0;l<s;l++)null===t[l].group&&(t[l].group=i.length,i.push({oldNumber:t[l].oldNumber,blockStart:l,blockEnd:l,unique:t[l].unique,maxWords:t[l].words,words:t[l].words,chars:t[l].chars,fixed:t[l].fixed,movedFrom:null,color:null}));!0===this.config.timer&&this.timeEnd("setInsGroups")},this.insertMarks=function(){!0===this.config.timer&&this.time("insertMarks");for(var t=this.blocks,i=this.groups,e=[],n=1,o=t.slice(),l=o.length,s=0;s<l;s++)o[s].number=s;o.sort((function(t,i){var e=t.oldNumber-i.oldNumber;return 0===e&&(e=t.newNumber-i.newNumber),e}));var r=[];for(s=0;s<l;s++)r[o[s].number]=s;var h=i.length;for(e=0;e<h;e++){var f=i[e];if(!1===f.fixed){var c=f.oldNumber,a=null;(d=r[f.blockStart])>0&&(a=o[d-1]);var d,k=null;(d=r[f.blockEnd])<o.length-1&&(k=o[d+1]);var g,u,p=null;if(null!==a&&"="===a.type&&!0===a.fixed)p=a;else if(null!==k&&"="===k.type&&!0===k.fixed)p=k;else for(var m=r[f.blockStart]-1;m>=0;m--)if("="===o[m].type&&!0===o[m].fixed){p=o[m];break}null===p?(g=-1,u=i.length,i.push({oldNumber:0,blockStart:t.length,blockEnd:t.length,unique:!1,maxWords:null,words:null,chars:0,fixed:null,movedFrom:null,color:null})):(g=p.newNumber,u=p.group),t.push({oldBlock:null,newBlock:null,oldNumber:c,newNumber:g,oldStart:null,count:null,unique:null,words:null,chars:0,type:"|",section:null,group:u,fixed:!0,moved:e,text:""}),f.color=n,f.movedFrom=u,n++}}this.sortBlocks(),!0===this.config.timer&&this.timeEnd("insertMarks")},this.getDiffFragments=function(){var t=this.blocks,i=this.groups,e=this.fragments,n=i.slice();n.sort((function(t,i){return t.blockStart-i.blockStart}));for(var o=n.length,l=0;l<o;l++){var s=n[l].blockStart,r=n[l].blockEnd,h=n[l].color;if(null!==h)c=n[l].movedFrom<t[s].group?"(<":"(>",e.push({text:"",type:c,color:h});for(var f=s;f<=r;f++){var c;if("="===(c=t[f].type)||"-"===c||"+"===c)e.push({text:t[f].text,type:c,color:h});else if("|"===c){for(var a,d=i[t[f].moved],k="",g=d.blockStart;g<=d.blockEnd;g++)"="!==t[g].type&&"-"!==t[g].type||(k+=t[g].text);a=d.blockStart<s?"<":">",e.push({text:k,type:a,color:d.color})}}null!==h&&e.push({text:"",type:" )",color:h})}for(var u=e.length,p=1;p<u;p++)e[p].type===e[p-1].type&&e[p].color===e[p-1].color&&""!==e[p].text&&""!==e[p-1].text&&(e[p-1].text+=e[p].text,e.splice(p,1),p--);e.unshift({text:"",type:"{",color:null},{text:"",type:"[",color:null}),e.push({text:"",type:"]",color:null},{text:"",type:"}",color:null})},this.clipDiffFragments=function(){var t=this.fragments;if(5!==t.length){var i=this.config.clipHeadingRight;this.config.clipParagraphRightMin<i&&(i=this.config.clipParagraphRightMin),this.config.clipLineRightMin<i&&(i=this.config.clipLineRightMin),this.config.clipBlankRightMin<i&&(i=this.config.clipBlankRightMin),this.config.clipCharsRight<i&&(i=this.config.clipCharsRight);var e=this.config.clipHeadingLeft;this.config.clipParagraphLeftMin<e&&(e=this.config.clipParagraphLeftMin),this.config.clipLineLeftMin<e&&(e=this.config.clipLineLeftMin),this.config.clipBlankLeftMin<e&&(e=this.config.clipBlankLeftMin),this.config.clipCharsLeft<e&&(e=this.config.clipCharsLeft);for(var n=t.length,o=0;o<n;o++){var l=t[o].type,s=t[o].color;if("="===l&&null===s){var r=t[o].text,h=r.length;if(!(h<i&&h<e)){for(var f,c=[],a=null;null!==(f=this.config.regExp.clipLine.exec(r));)c.push(f.index),a=this.config.regExp.clipLine.lastIndex;0!==c[0]&&c.unshift(0),a!==h&&c.push(h);for(var d=[],k=[];null!==(f=this.config.regExp.clipHeading.exec(r));)d.push(f.index),k.push(f.index+f[0].length);var g=[];for(a=null;null!==(f=this.config.regExp.clipParagraph.exec(r));)g.push(f.index),a=this.config.regExp.clipParagraph.lastIndex;0!==g[0]&&g.unshift(0),a!==h&&g.push(h);var u=null,p=null,m="",x="";if(2!==o){var w=h;if(this.config.clipLinesLeftMax<c.length&&(w=c[this.config.clipLinesLeftMax]),null===p)for(var E=k.length,b=0;b<E&&!(k[b]>this.config.clipHeadingLeft||k[b]>w);b++){p=k[b],x="heading";break}if(null===p){var D=g.length;for(b=0;b<D&&!(g[b]>this.config.clipParagraphLeftMax||g[b]>w);b++)if(g[b]>this.config.clipParagraphLeftMin){p=g[b],x="paragraph";break}}if(null===p){var B=c.length;for(b=0;b<B&&!(c[b]>this.config.clipLineLeftMax||c[b]>w);b++)if(c[b]>this.config.clipLineLeftMin){p=c[b],x="line";break}}null===p&&(this.config.regExp.clipBlank.lastIndex=this.config.clipBlankLeftMin,null!==(f=this.config.regExp.clipBlank.exec(r))&&f.index<this.config.clipBlankLeftMax&&f.index<w&&(p=f.index,x="blank")),null===p&&this.config.clipCharsLeft<w&&(p=this.config.clipCharsLeft,x="chars"),null===p&&(p=w,x="fixed")}if(o!==t.length-3){var A=0;if(c.length>=this.config.clipLinesRightMax&&(A=c[c.length-this.config.clipLinesRightMax]),null===u)for(b=d.length-1;b>=0&&!(d[b]<h-this.config.clipHeadingRight||d[b]<A);b--){u=d[b],m="heading";break}if(null===u)for(b=g.length-1;b>=0&&!(g[b]<h-this.config.clipParagraphRightMax||g[b]<A);b--)if(g[b]<h-this.config.clipParagraphRightMin){u=g[b],m="paragraph";break}if(null===u)for(b=c.length-1;b>=0&&!(c[b]<h-this.config.clipLineRightMax||c[b]<A);b--)if(c[b]<h-this.config.clipLineRightMin){u=c[b],m="line";break}if(null===u){var C=h-this.config.clipBlankRightMax;C<A&&(C=A),this.config.regExp.clipBlank.lastIndex=C;for(var v=null;null!==(f=this.config.regExp.clipBlank.exec(r));){if(f.index>h-this.config.clipBlankRightMin){null!==v&&(u=v,m="blank");break}v=f.index}}null===u&&h-this.config.clipCharsRight>A&&(u=h-this.config.clipCharsRight,m="chars"),null===u&&(u=A,m="fixed")}if(null!==p&&null!==u){if(p>u)continue;if(u-p<this.config.clipSkipChars)continue;var T=0;for(B=c.length,b=0;b<B&&!(c[b]>u||T>this.config.clipSkipLines);b++)c[b]>p&&T++;if(T<this.config.clipSkipLines)continue}if(null!==p||null!==u){var F=null,S=null;null!==p&&(F=(F=r.slice(0,p)).replace(this.config.regExp.clipTrimNewLinesLeft,""),"chars"===x?(S="~",F=F.replace(this.config.regExp.clipTrimBlanksLeft,"")):"blank"===x&&(S=" ~",F=F.replace(this.config.regExp.clipTrimBlanksLeft,"")));var y=null,M=null;null!==u&&(y=(y=r.slice(u)).replace(this.config.regExp.clipTrimNewLinesRight,""),"chars"===m?(M="~",y=y.replace(this.config.regExp.clipTrimBlanksRight,"")):"blank"===m&&(M="~ ",y=y.replace(this.config.regExp.clipTrimBlanksRight,""))),t.splice(o,1),n--,null!==p&&(t.splice(o++,0,{text:F,type:"=",color:null}),n++,null!==S&&(t.splice(o++,0,{text:"",type:S,color:null}),n++)),null!==p&&null!==u&&(t.splice(o++,0,{text:"",type:"]",color:null}),t.splice(o++,0,{text:"",type:",",color:null}),t.splice(o++,0,{text:"",type:"[",color:null}),n+=3),null!==u&&(null!==M&&(t.splice(o++,0,{text:"",type:M,color:null}),n++),t.splice(o++,0,{text:y,type:"=",color:null}),n++)}}}}!0===this.config.debug&&this.debugFragments("Fragments")}},this.getDiffHtml=function(t){var i=this.fragments;if(5!==i.length||"="!==i[2].type){for(var e=[],n=i.length,o=0;o<n;o++){var l=i[o].text,s=i[o].type,r=i[o].color,h="",f=!1;if(""!==l&&(f=this.config.regExp.blankBlock.test(l)),"{"===s?h=this.config.htmlCode.containerStart:"}"===s&&(h=this.config.htmlCode.containerEnd),"["===s?h=this.config.htmlCode.fragmentStart:"]"===s?h=this.config.htmlCode.fragmentEnd:","===s&&(h=this.config.htmlCode.separator),"~"===s&&(h=this.config.htmlCode.omittedChars)," ~"===s&&(h=" "+this.config.htmlCode.omittedChars),"~ "===s)h=this.config.htmlCode.omittedChars+" ";else if("(<"===s){if("old"!==t)c=!0===this.config.noUnicodeSymbols?this.config.msg["wiked-diff-block-left-nounicode"]:this.config.msg["wiked-diff-block-left"],h=!0===this.config.coloredBlocks?this.config.htmlCode.blockColoredStart:this.config.htmlCode.blockStart,h=this.htmlCustomize(h,r,c)}else if("(>"===s){var c;if("old"!==t)c=!0===this.config.noUnicodeSymbols?this.config.msg["wiked-diff-block-right-nounicode"]:this.config.msg["wiked-diff-block-right"],h=!0===this.config.coloredBlocks?this.config.htmlCode.blockColoredStart:this.config.htmlCode.blockStart,h=this.htmlCustomize(h,r,c)}else" )"===s&&"old"!==t&&(h=this.config.htmlCode.blockEnd);"="===s?(l=this.htmlEscape(l),null!==r?"old"!==t&&(h=this.markupBlanks(l,!0)):h=this.markupBlanks(l)):"-"===s?"new"!==t&&("old"===t&&null!==r||(l=this.htmlEscape(l),l=this.markupBlanks(l,!0),h=!0===f?this.config.htmlCode.deleteStartBlank:this.config.htmlCode.deleteStart,h+=l+this.config.htmlCode.deleteEnd)):"+"===s?"old"!==t&&(l=this.htmlEscape(l),l=this.markupBlanks(l,!0),h=!0===f?this.config.htmlCode.insertStartBlank:this.config.htmlCode.insertStart,h+=l+this.config.htmlCode.insertEnd):"<"!==s&&">"!==s||"new"!==t&&(!1===this.config.showBlockMoves||"old"===t?(l=this.htmlEscape(l),l=this.markupBlanks(l,!0),h="old"===t?!0===this.config.coloredBlocks?this.htmlCustomize(this.config.htmlCode.blockColoredStart,r)+l+this.config.htmlCode.blockEnd:this.htmlCustomize(this.config.htmlCode.blockStart,r)+l+this.config.htmlCode.blockEnd:!0===f?this.config.htmlCode.deleteStartBlank+l+this.config.htmlCode.deleteEnd:this.config.htmlCode.deleteStart+l+this.config.htmlCode.deleteEnd):h="<"===s?!0===this.config.coloredBlocks?this.htmlCustomize(this.config.htmlCode.markLeftColored,r,l):this.htmlCustomize(this.config.htmlCode.markLeft,r,l):!0===this.config.coloredBlocks?this.htmlCustomize(this.config.htmlCode.markRightColored,r,l):this.htmlCustomize(this.config.htmlCode.markRight,r,l)),e.push(h)}this.html=e.join("")}else this.html=""},this.htmlCustomize=function(t,i,e){if(t=t.replace(/\{number\}/g,i),t=!0===this.config.noUnicodeSymbols?t.replace(/\{nounicode\}/g," wikEdDiffNoUnicode"):t.replace(/\{nounicode\}/g,""),void 0!==e){var n=" [...] ";e.length>512&&(e=e.substr(0,377)+n+e.substr(e.length-128)),e=(e=(e=this.htmlEscape(e)).replace(/\t/g," ")).replace(/ /g," "),t=t.replace(/\{title\}/,e)}return t},this.htmlEscape=function(t){return t=(t=(t=(t=t.replace(/&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/"/g,""")},this.markupBlanks=function(t,i){return!0===i&&(t=(t=t.replace(/ /g,this.config.htmlCode.space)).replace(/\n/g,this.config.htmlCode.newline)),t=t.replace(/\t/g,this.config.htmlCode.tab)},this.wordCount=function(t){return(t.match(this.config.regExp.countWords)||[]).length},this.unitTests=function(){var t,i;this.getDiffHtml("new"),(t=this.html.replace(/<[^>]*>/g,""))!==(i=this.htmlEscape(this.newText.text))?(console.log("Error: wikEdDiff unit test failure: diff not consistent with new text version!"),this.error=!0,console.log("new text:\n",i),console.log("new diff:\n",t)):console.log("OK: wikEdDiff unit test passed: diff consistent with new text."),this.getDiffHtml("old"),(t=this.html.replace(/<[^>]*>/g,""))!==(i=this.htmlEscape(this.oldText.text))?(console.log("Error: wikEdDiff unit test failure: diff not consistent with old text version!"),this.error=!0,console.log("old text:\n",i),console.log("old diff:\n",t)):console.log("OK: wikEdDiff unit test passed: diff consistent with old text.")},this.debugBlocks=function(t,i){void 0===i&&(i=this.blocks);for(var e="\ni \toldBl \tnewBl \toldNm \tnewNm \toldSt \tcount \tuniq\twords \tchars \ttype \tsect \tgroup \tfixed \tmoved \ttext\n",n=i.length,o=0;o<n;o++)e+=o+" \t"+i[o].oldBlock+" \t"+i[o].newBlock+" \t"+i[o].oldNumber+" \t"+i[o].newNumber+" \t"+i[o].oldStart+" \t"+i[o].count+" \t"+i[o].unique+" \t"+i[o].words+" \t"+i[o].chars+" \t"+i[o].type+" \t"+i[o].section+" \t"+i[o].group+" \t"+i[o].fixed+" \t"+i[o].moved+" \t"+this.debugShortenText(i[o].text)+"\n";console.log(t+":\n"+e)},this.debugGroups=function(t,i){void 0===i&&(i=this.groups);for(var e="\ni \toldNm \tblSta \tblEnd \tuniq \tmaxWo\twords \tchars \tfixed \toldNm \tmFrom \tcolor\n",n=0;n<i.length;n++)e+=n+" \t"+i[n].oldNumber+" \t"+i[n].blockStart+" \t"+i[n].blockEnd+" \t"+i[n].unique+" \t"+i[n].maxWords+" \t"+i[n].words+" \t"+i[n].chars+" \t"+i[n].fixed+" \t"+i[n].oldNumber+" \t"+i[n].movedFrom+" \t"+i[n].color+"\n";console.log(t+":\n"+e)},this.debugFragments=function(t){for(var i=this.fragments,e="\ni \ttype \tcolor \ttext\n",n=i.length,o=0;o<n;o++)e+=o+' \t"'+i[o].type+'" \t'+i[o].color+" \t"+this.debugShortenText(i[o].text,120,40)+"\n";console.log(t+":\n"+e)},this.debugBorders=function(t,i){for(var e="\ni \t[ new \told ]\n",n=i.length,o=0;o<n;o++)e+=o+" \t[ "+i[o][0]+" \t"+i[o][1]+" ]\n";console.log(t,e)},this.debugShortenText=function(t,i,e){return"string"!=typeof t&&(t=t.toString()),void 0===i&&(i=50),void 0===e&&(e=15),(t=(t=t.replace(/\n/g,"\\n")).replace(/\t/g," ")).length>i&&(t=t.substr(0,i-1-e)+"…"+t.substr(t.length-e)),'"'+t+'"'},this.time=function(t){this.timer[t]=(new Date).getTime()},this.timeEnd=function(t,i){var e=0;if(void 0!==this.timer[t]){var n=this.timer[t];e=(new Date).getTime()-n,this.timer[t]=void 0,!0!==i&&console.log(t+": "+e.toFixed(2)+" ms")}return e},this.timeRecursionEnd=function(t){if(this.recursionTimer.length>1){for(var i=this.recursionTimer.length-1,e=0;e<i;e++)this.recursionTimer[e]-=this.recursionTimer[e+1];var n=this.recursionTimer.length;for(e=0;e<n;e++)console.log(t+" recursion "+e+": "+this.recursionTimer[e].toFixed(2)+" ms")}this.recursionTimer=[]},this.debug=function(t,i){void 0===i?console.log(t):console.log(t+": "+i)},this.addScript=function(t){if(null===document.getElementById("wikEdDiffBlockHandler")){var i=document.createElement("script");i.id="wikEdDiffBlockHandler",void 0!==i.innerText?i.innerText=t:i.textContent=t,document.getElementsByTagName("head")[0].appendChild(i)}},this.addStyleSheet=function(t){if(null===document.getElementById("wikEdDiffStyles")){t=(t=t.replace(/\{cssMarkLeft\}/g,this.config.cssMarkLeft)).replace(/\{cssMarkRight\}/g,this.config.cssMarkRight);var i=document.createElement("style");i.id="wikEdDiffStyles",i.type="text/css",void 0!==i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t)),document.getElementsByTagName("head")[0].appendChild(i)}},this.deepCopy=function(t,i){for(var e in t)!0===Object.prototype.hasOwnProperty.call(t,e)&&("object"==typeof t[e]?this.deepCopy(t[e],i[e]):i[e]=t[e])},this.init()};WikEdDiff.WikEdDiffText=function(t,i){this.parent=i,this.text=null,this.tokens=[],this.first=null,this.last=null,this.words={},this.init=function(){"string"!=typeof t&&(t=t.toString()),this.text=t.replace(/\r\n?/g,"\n"),!0===this.parent.config.timer&&this.parent.time("wordParse"),this.wordParse(this.parent.config.regExp.countWords),this.wordParse(this.parent.config.regExp.countChunks),!0===this.parent.config.timer&&this.parent.timeEnd("wordParse")},this.wordParse=function(t){var i=this.text.match(t);if(null!==i)for(var e=i.length,n=0;n<e;n++){var o=i[n];!1===Object.prototype.hasOwnProperty.call(this.words,o)?this.words[o]=1:this.words[o]++}},this.splitText=function(t,i){var e=null,n=null,o=this.tokens.length,l=o,s="";void 0===i?s=this.text:(e=this.tokens[i].prev,n=this.tokens[i].next,s=this.tokens[i].token);for(var r,h=0,f=[],c=0,a=this.parent.config.regExp.split[t];null!==(r=a.exec(s));)r.index>c&&f.push(s.substring(c,r.index)),f.push(r[0]),c=a.lastIndex;c<s.length&&f.push(s.substring(c));for(var d=f.length,k=0;k<d;k++)this.tokens.push({token:f[k],prev:e,next:null,link:null,number:null,unique:!1}),h++,null!==e&&(this.tokens[e].next=o),e=o,o++;h>0&&void 0!==i&&(null!==e&&(this.tokens[e].next=n),null!==n&&(this.tokens[n].prev=e)),h>0&&(void 0===i?(this.first=0,this.last=e):(i===this.first&&(this.first=l),i===this.last&&(this.last=e)))},this.splitRefine=function(t){for(var i=this.first;null!==i;)null===this.tokens[i].link&&this.splitText(t,i),i=this.tokens[i].next},this.enumerateTokens=function(){for(var t=0,i=this.first;null!==i;)this.tokens[i].number=t,t++,i=this.tokens[i].next},this.debugText=function(t){var e=this.tokens,n="first: "+this.first+"\tlast: "+this.last+"\n";n+='\ni \tlink \t(prev \tnext) \tuniq \t#num \t"token"\n';for(var o=this.first;null!==o;)n+=o+" \t"+e[o].link+" \t("+e[o].prev+" \t"+e[o].next+") \t"+e[o].unique+" \t#"+e[o].number+" \t"+i.debugShortenText(e[o].token)+"\n",o=e[o].next;console.log(t+":\n"+n)},this.init()}; |