var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_"; $jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var a=0;return function(b){return $jscomp.SYMBOL_PREFIX+(b||"")+a++}}(); $jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}}; $jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.arrayIterator=function(a){var b=0;return $jscomp.iteratorPrototype(function(){return ba||1342177279>>=1)b+=b;return d}},"es6","es3");resultToDraw={colorLine:[],stepDiff:[],currentLine:0,tab:""};dialogLoadFromURL=currentEditor=myCodeMirrorResult2=myCodeMirrorResult1=myCodeMirrorText2=myCodeMirrorText1=null;PDFJS.workersrc="proxy.php?url=./lib/pdf.js/pdf.worker.js"; function getTextFromDocument(a){return a.promise.then(function(a){for(var b=a.pdfInfo.numPages,d=[],e=1;e<=b;e++){var f=a.getPage(e);d.push(f.then(function(a){return a.getTextContent().then(function(a){return a.items.map(function(a){return a.str}).join("\n")})}))}return Promise.all(d).then(function(a){return a.join("\n")})})}function getTextFromURL(a){a=PDFJS.getDocument(a);return getTextFromDocument(a)}function getTextFromData(a){a=PDFJS.getDocument(a);return getTextFromDocument(a)} function displayLoadURLDialog(a){currentEditor=a;dialogLoadFromURL.show();document.getElementById("url").focus()}function loadFromURL(a){var b=currentEditor,c=document.getElementById("url").value;getTextFromURL(c).then(function(c){b&&c&&b.setValue(c);dialogLoadFromURL.hide();a&&a()},function(a){services.billboard.setAndDisplay("editor-error","An error has occured: ".reason);console.error()})} function onChangeText(){services.billboard.emptyAndHide(["editor-error1","editor-valid1"]);services.billboard.emptyAndHide(["editor-error2","editor-valid2"]);document.getElementById("result").style.display="";resultToDraw={colorLine:[],stepDiff:[],currentLine:0,tab:""};var a="",b="",c=[];currentDiff=null;try{var d=myCodeMirrorText1.getValue("\n"),e=myCodeMirrorText2.getValue("\n"),f=[],g=!1;JsDiff.diffChars(d,e).forEach(function(a){a.added?(g?f[f.length-1].value2=void 0===f[f.length-1].value2?a.value: f[f.length-1].value2+a.value:f.push({value2:a.value}),g=!0):a.removed?(g?f[f.length-1].value1=void 0===f[f.length-1].value1?a.value:f[f.length-1].value1+a.value:f.push({value1:a.value}),g=!0):(f.push({value:a.value}),g=!1)});var m=function(a,b,c){a={id:a,lineFrom:0,chFrom:0,lineTo:0,chTo:0};b=b.split(/\r?\n/);a.lineFrom=b.length-1;a.chFrom=b[b.length-1].length;-1===c.indexOf("\n")?b[b.length-1]+=c:(c=c.split(/\r?\n/),b[b.length-1]+=c[0],b=b.concat(c.slice(1)));a.lineTo=b.length-1;a.chTo=b[b.length- 1].length;return a},h="",k="";f.forEach(function(d){if(void 0!==d.value){var e=d.value.split(/\r?\n/);1d?b+="\n".repeat(e-d):a+="\n".repeat(d-e),k=h="")});a+=h;b+=k;myCodeMirrorResult1.setValue(a);myCodeMirrorResult2.setValue(b);var n=null;c.forEach(function(a){(1==a.id?myCodeMirrorResult1:myCodeMirrorResult2).markText({line:a.lineFrom,ch:a.chFrom},{line:a.lineTo,ch:a.chTo},{className:"pdf-compare-added"});null==n||a.lineFrom>n?(resultToDraw.stepDiff.push({line:a.lineFrom,to:a.lineTo}),n=a.lineTo):resultToDraw.stepDiff[resultToDraw.stepDiff.length- 1].to=a.lineTo});document.getElementById("nb-diff").innerHTML=resultToDraw.stepDiff.length+" difference(s) between the two PDF documents";if(""!=e&&""!=d){var r=location.href;location.href="proxy.php?url=#result";history.replaceState(null,null,r)}}catch(l){services.billboard.setAndDisplay("editor-error1","An error has occured: "+l.message)}next()} function onScroll(a){setTimeout(function(){var b=a.getScrollInfo();b&&(myCodeMirrorResult1==a?myCodeMirrorResult2.scrollTo(b.left,b.top):myCodeMirrorResult1.scrollTo(b.left,b.top))},10)}document.getElementById("file-input-text").addEventListener("change",function(a){services.file.readSingleFile(a,ReadModeEnum.ARRAY_BUFFER,function(a){getTextFromData(a).then(function(a){myCodeMirrorText1.setValue(a)})})},!1); document.getElementById("file-input-text-2").addEventListener("change",function(a){services.file.readSingleFile(a,ReadModeEnum.ARRAY_BUFFER,function(a){getTextFromData(a).then(function(a){myCodeMirrorText2.setValue(a)})})},!1);var dropZone=document.getElementById("dropZone"),dropZone2=document.getElementById("dropZone2");setTimeout(function(){document.getElementById("result").style.display="none"},5);currentDiff=null; function removeSelectionPrevious(a,b){if(b)for(var c=b.line;c<=b.to;c++)c==b.line&&a.removeLineClass(c,"background","pdf-compare-select-top"),c==b.to&&a.removeLineClass(c,"background","pdf-compare-select-bottom"),c!=b.line&&c!=b.to&&a.removeLineClass(c,"background","pdf-compare-select-middle")} function jumpToLine(a,b){var c=a.charCoords({line:b.line,ch:0},"local").top,d=a.getScrollerElement().offsetHeight/4;a.scrollTo(null,c-d);for(c=b.line;c<=b.to;c++)c==b.line&&a.addLineClass(c,"background","pdf-compare-select-top"),c==b.to&&a.addLineClass(c,"background","pdf-compare-select-bottom"),c!=b.line&&c!=b.to&&a.addLineClass(c,"background","pdf-compare-select-middle")} function previous(){null!=currentDiff&&(resultToDraw.stepDiff.sort(function(a,b){return b.line-a.line}),resultToDraw.stepDiff.some(function(a){return a.linecurrentDiff.line?(removeSelectionPrevious(myCodeMirrorResult1,currentDiff),removeSelectionPrevious(myCodeMirrorResult2,currentDiff),currentDiff=a,jumpToLine(myCodeMirrorResult1,currentDiff),jumpToLine(myCodeMirrorResult2,currentDiff),!0):!1})} function loadURL(a){var b=new URL(window.location.href),c=b.searchParams.get("url1");b=b.searchParams.get("url2");var d=0;c&&c.length&&d++;b&&b.length&&d++;if(0==d)return a();c&&c.length&&(currentEditor=myCodeMirrorText1,document.getElementById("url").value=c,loadFromURL(function(){d--;0==d&&(a(),onChangeText())}));b&&b.length&&(currentEditor=myCodeMirrorText2,document.getElementById("url").value=b,loadFromURL(function(){d--;0==d&&(a(),onChangeText())}))} addEvent(window,"load",function(){myCodeMirrorText1=services.codeMirror.create("editor-container-text",{lineNumbers:!0,lineWrapping:!0,viewportMargin:Infinity});myCodeMirrorText2=services.codeMirror.create("editor-container-text-2",{lineNumbers:!0,lineWrapping:!0,viewportMargin:Infinity});myCodeMirrorResult1=services.codeMirror.create("editor-container-result1",{readOnly:!0,lineNumbers:!1,lineWrapping:!0,viewportMargin:Infinity,styleSelectedText:!0});myCodeMirrorResult2=services.codeMirror.create("editor-container-result2", {readOnly:!0,lineNumbers:!1,lineWrapping:!0,viewportMargin:Infinity,styleSelectedText:!0});services.file.dragAndDrop(dropZone,ReadModeEnum.ARRAY_BUFFER,function(a){getTextFromData(a).then(function(a){myCodeMirrorText1.setValue(a)})});services.file.dragAndDrop(dropZone2,ReadModeEnum.ARRAY_BUFFER,function(a){getTextFromData(a).then(function(a){myCodeMirrorText2.setValue(a)})});dialogLoadFromURL=new A11yDialog(document.getElementById("dialog-load-from-url"));loadURL(function(){myCodeMirrorText1.on("change", onChangeText);myCodeMirrorText2.on("change",onChangeText);myCodeMirrorResult1.on("scroll",function(){onScroll(myCodeMirrorResult1)});myCodeMirrorResult2.on("scroll",function(){onScroll(myCodeMirrorResult2)})})});