var FontInspector=function(){function f(){for(var c=document.querySelectorAll("div["+e+"]"),a=0,b=c.length;a<b;++a)c[a].className="debuggerHideText"}function h(c,a){for(var b=document.querySelectorAll("div["+e+"="+c+"]"),d=0,f=b.length;d<f;++d)b[d].className=a?"debuggerShowText":"debuggerHideText"}function b(c){if(c.target.dataset.fontName&&"DIV"===c.target.tagName.toUpperCase())for(var c=c.target.dataset.fontName,a=document.getElementsByTagName("input"),e=0;e<a.length;++e){var b=a[e];b.dataset.fontName===
c&&(b.checked=!b.checked,h(c,b.checked),b.scrollIntoView())}}var d,a=!1,e="data-font-name";return{id:"FontInspector",name:"Font Inspector",panel:null,manager:null,init:function(){var c=this.panel;c.setAttribute("style","padding: 5px;");var a=document.createElement("button");a.addEventListener("click",f);a.textContent="Refresh";c.appendChild(a);d=document.createElement("div");c.appendChild(d)},cleanup:function(){d.textContent=""},enabled:!1,get active(){return a},set active(c){if(a=c)document.body.addEventListener("click",
b,!0),f();else{document.body.removeEventListener("click",b,!0);for(var c=document.querySelectorAll("div["+e+"]"),g=0,d=c.length;g<d;++g)c[g].className=""}},fontAdded:function(c,a){var e=function(c,a){for(var e=document.createElement("table"),b=0;b<a.length;b++){var g=document.createElement("tr"),d=document.createElement("td");d.textContent=a[b];g.appendChild(d);d=document.createElement("td");d.textContent=c[a[b]].toString();g.appendChild(d);e.appendChild(g)}return e}(c,["name","type"]),b=c.loadedName,
k=document.createElement("div"),o=document.createElement("span");o.textContent=b;var n=document.createElement("a");a?(a=/url\(['"]?([^\)"']+)/.exec(a),n.href=a[1]):c.data&&(a=URL.createObjectURL(new Blob([c.data],{type:c.mimeType})),n.href=a);n.textContent="Download";var l=document.createElement("a");l.href="";l.textContent="Log";l.addEventListener("click",function(a){a.preventDefault();console.log(c)});var j=document.createElement("input");j.setAttribute("type","checkbox");j.dataset.fontName=b;j.addEventListener("click",
function(a,c){return function(){h(c,a.checked)}}(j,b));k.appendChild(j);k.appendChild(o);k.appendChild(document.createTextNode(" "));k.appendChild(n);k.appendChild(document.createTextNode(" "));k.appendChild(l);k.appendChild(e);d.appendChild(k);setTimeout(function(){this.active&&f()}.bind(this),2E3)}}}(),StepperManager=function(){var f=[],h=null,b=null,d=null,a={};return{id:"Stepper",name:"Stepper",panel:null,manager:null,init:function(){var e=this;this.panel.setAttribute("style","padding: 5px;");
b=document.createElement("div");d=document.createElement("select");d.addEventListener("change",function(){e.selectStepper(this.value)});b.appendChild(d);h=document.createElement("div");this.panel.appendChild(b);this.panel.appendChild(h);sessionStorage.getItem("pdfjsBreakPoints")&&(a=JSON.parse(sessionStorage.getItem("pdfjsBreakPoints")))},cleanup:function(){d.textContent="";h.textContent="";f=[]},enabled:!1,active:!1,create:function(e){var c=document.createElement("div");c.id="stepper"+e;c.setAttribute("hidden",
!0);c.className="stepper";h.appendChild(c);var b=document.createElement("option");b.textContent="Page "+(e+1);b.value=e;d.appendChild(b);c=new Stepper(c,e,a[e]||[]);f.push(c);1===f.length&&this.selectStepper(e,!1);return c},selectStepper:function(a,c){var b,a=a|0;c&&this.manager.selectPanel(this);for(b=0;b<f.length;++b){var i=f[b];i.pageIndex===a?i.panel.removeAttribute("hidden"):i.panel.setAttribute("hidden",!0)}i=d.options;for(b=0;b<i.length;++b){var m=i[b];m.selected=(m.value|0)===a}},saveBreakPoints:function(b,
c){a[b]=c;sessionStorage.setItem("pdfjsBreakPoints",JSON.stringify(a))}}}(),Stepper=function(){function f(a,b){var c=document.createElement(a);b&&(c.textContent=b);return c}function h(a){if("string"===typeof a)return 75>=a.length?a:a.substr(0,75)+"...";if("object"!==typeof a||null===a)return a;if("length"in a){var b=[],c,d;for(c=0,d=Math.min(10,a.length);c<d;c++)b.push(h(a[c]));c<a.length&&b.push("...");return b}b={};for(c in a)b[c]=h(a[c]);return b}function b(a,b,c){this.panel=a;this.breakPoint=
0;this.nextBreakPoint=null;this.pageIndex=b;this.breakPoints=c;this.currentIdx=-1;this.operatorListIdx=0}var d=null;b.prototype={init:function(){var a=this.panel,b=f("div","c=continue, s=step"),c=f("table");b.appendChild(c);c.cellSpacing=0;var g=f("tr");c.appendChild(g);g.appendChild(f("th","Break"));g.appendChild(f("th","Idx"));g.appendChild(f("th","fn"));g.appendChild(f("th","args"));a.appendChild(b);this.table=c;if(!d){d=Object.create(null);for(var i in PDFJS.OPS)d[PDFJS.OPS[i]]=i}},updateOperatorList:function(a){function b(){var a=
+this.dataset.idx;this.checked?c.breakPoints.push(a):c.breakPoints.splice(c.breakPoints.indexOf(a),1);StepperManager.saveBreakPoints(c.pageIndex,c.breakPoints)}var c=this;if(!(15E3<this.operatorListIdx)){for(var g=document.createDocumentFragment(),i=Math.min(15E3,a.fnArray.length),m=this.operatorListIdx;m<i;m++){var k=f("tr");k.className="line";k.dataset.idx=m;g.appendChild(k);var o=-1!==this.breakPoints.indexOf(m),n=a.argsArray[m]||[],l=f("td"),j=f("input");j.type="checkbox";j.className="points";
j.checked=o;j.dataset.idx=m;j.onclick=b;l.appendChild(j);k.appendChild(l);k.appendChild(f("td",m.toString()));o=d[a.fnArray[m]];l=n;if("showText"===o){for(var n=n[0],l=[],j=[],q=0;q<n.length;q++){var p=n[q];"object"===typeof p&&null!==p?j.push(p.fontChar):(0<j.length&&(l.push(j.join("")),j=[]),l.push(p))}0<j.length&&l.push(j.join(""));l=[l]}k.appendChild(f("td",o));k.appendChild(f("td",JSON.stringify(h(l))))}i<a.fnArray.length&&(k=f("tr"),i=f("td","..."),i.colspan=4,g.appendChild(i));this.operatorListIdx=
a.fnArray.length;this.table.appendChild(g)}},getNextBreakPoint:function(){this.breakPoints.sort(function(a,b){return a-b});for(var a=0;a<this.breakPoints.length;a++)if(this.breakPoints[a]>this.currentIdx)return this.breakPoints[a];return null},breakIt:function(a,b){StepperManager.selectStepper(this.pageIndex,!0);var c=this,d=document;c.currentIdx=a;var f=function(a){switch(a.keyCode){case 83:d.removeEventListener("keydown",f,!1);c.nextBreakPoint=c.currentIdx+1;c.goTo(-1);b();break;case 67:d.removeEventListener("keydown",
f,!1),a=c.getNextBreakPoint(),c.nextBreakPoint=a,c.goTo(-1),b()}};d.addEventListener("keydown",f,!1);c.goTo(a)},goTo:function(a){for(var b=this.panel.getElementsByClassName("line"),c=0,d=b.length;c<d;++c){var f=b[c];(f.dataset.idx|0)===a?(f.style.backgroundColor="rgb(251,250,207)",f.scrollIntoView()):f.style.backgroundColor=null}}};return b}(),Stats=function(){function f(b){for(;b.hasChildNodes();)b.removeChild(b.lastChild)}function h(d){for(var a=0,e=b.length;a<e;++a)if(b[a].pageNumber===d)return a;
return!1}var b=[];return{id:"Stats",name:"Stats",panel:null,manager:null,init:function(){this.panel.setAttribute("style","padding: 5px;");PDFJS.enableStats=!0},enabled:!1,active:!1,add:function(d,a){if(a){var e=h(d);!1!==e&&(this.panel.removeChild(b[e].div),b.splice(e,1));e=document.createElement("div");e.className="stats";var c=document.createElement("div");c.className="title";c.textContent="Page: "+d;var g=document.createElement("div");g.textContent=a.toString();e.appendChild(c);e.appendChild(g);
b.push({pageNumber:d,div:e});b.sort(function(a,b){return a.pageNumber-b.pageNumber});f(this.panel);e=0;for(c=b.length;e<c;++e)this.panel.appendChild(b[e].div)}},cleanup:function(){b=[];f(this.panel)}}}(),PDFBug=function(){var f=[],h=null;return{tools:[FontInspector,StepperManager,Stats],enable:function(b){var d=!1,a=this.tools;1===b.length&&"all"===b[0]&&(d=!0);for(var e=0;e<a.length;++e){var c=a[e];if(d||-1!==b.indexOf(c.id))c.enabled=!0}d||a.sort(function(c,d){var e=b.indexOf(c.id),e=0>e?a.length:
e,f=b.indexOf(d.id),f=0>f?a.length:f;return e-f})},init:function(){var b=document.createElement("div");b.id="PDFBug";var d=document.createElement("div");d.setAttribute("class","controls");b.appendChild(d);var a=document.createElement("div");a.setAttribute("class","panels");b.appendChild(a);var e=document.getElementById("viewerContainer");e.appendChild(b);e.style.right="300px";for(var b=this.tools,c=this,e=0;e<b.length;++e){var g=b[e],i=document.createElement("div"),h=document.createElement("button");
h.textContent=g.name;h.addEventListener("click",function(a){return function(b){b.preventDefault();c.selectPanel(a)}}(e));d.appendChild(h);a.appendChild(i);g.panel=i;g.manager=this;g.enabled?g.init():i.textContent=g.name+' is disabled. To enable add  "'+g.id+'" to the pdfBug parameter and refresh (seperate multiple by commas).';f.push(h)}this.selectPanel(0)},cleanup:function(){for(var b=0,d=this.tools.length;b<d;b++)this.tools[b].enabled&&this.tools[b].cleanup()},selectPanel:function(b){"number"!==
typeof b&&(b=this.tools.indexOf(b));if(b!==h){h=b;for(var d=this.tools,a=0;a<d.length;++a)a===b?(f[a].setAttribute("class","active"),d[a].active=!0,d[a].panel.removeAttribute("hidden")):(f[a].setAttribute("class",""),d[a].active=!1,d[a].panel.setAttribute("hidden","true"))}}}}();
