From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- support/pdbf-toolkit/data/pdf.worker.js | 1465 +++++++++++++++++++++++++++++++ 1 file changed, 1465 insertions(+) create mode 100644 support/pdbf-toolkit/data/pdf.worker.js (limited to 'support/pdbf-toolkit/data/pdf.worker.js') diff --git a/support/pdbf-toolkit/data/pdf.worker.js b/support/pdbf-toolkit/data/pdf.worker.js new file mode 100644 index 0000000000..6d6634673a --- /dev/null +++ b/support/pdbf-toolkit/data/pdf.worker.js @@ -0,0 +1,1465 @@ +if(typeof PDFJS==="undefined")(typeof window!=="undefined"?window:this).PDFJS={};PDFJS.version="1.0.907";PDFJS.build="e9072ac"; +(function pdfjsWrapper(){var globalScope=typeof window==="undefined"?this:window;var isWorker=typeof window==="undefined";var FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];var TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};var ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};var AnnotationType={WIDGET:1,TEXT:2,LINK:3};var StreamType={UNKNOWN:0,FLATE:1,LZW:2,DCT:3,JPX:4, +JBIG:5,A85:6,AHX:7,CCF:8,RL:9};var FontType={UNKNOWN:0,TYPE1:1,TYPE1C:2,CIDFONTTYPE0:3,CIDFONTTYPE0C:4,TRUETYPE:5,CIDFONTTYPE2:6,TYPE3:7,OPENTYPE:8,TYPE0:9,MMTYPE1:10};if(!globalScope.PDFJS)globalScope.PDFJS={};globalScope.PDFJS.pdfBug=false;PDFJS.VERBOSITY_LEVELS={errors:0,warnings:1,infos:5};var OPS=PDFJS.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15, +curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49, +setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76, +endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};function info(msg){if(PDFJS.verbosity>=PDFJS.VERBOSITY_LEVELS.infos)console.log("Info: "+msg)}function warn(msg){if(PDFJS.verbosity>=PDFJS.VERBOSITY_LEVELS.warnings)console.log("Warning: "+ +msg)}function error(msg){if(arguments.length>1){var logArguments=["Error:"];logArguments.push.apply(logArguments,arguments);console.log.apply(console,logArguments);msg=[].join.call(arguments," ")}else console.log("Error: "+msg);console.log(backtrace());UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);throw new Error(msg);}function backtrace(){try{throw new Error;}catch(e){return e.stack?e.stack.split("\n").slice(2).join("\n"):""}}function assert(cond,msg){if(!cond)error(msg)}var UNSUPPORTED_FEATURES= +PDFJS.UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",smask:"smask",shadingPattern:"shadingPattern",font:"font"};var UnsupportedManager=PDFJS.UnsupportedManager=function UnsupportedManagerClosure(){var listeners=[];return{listen:function(cb){listeners.push(cb)},notify:function(featureId){warn('Unsupported feature "'+featureId+'"');for(var i=0,ii=listeners.length;i=0?i:pathLength;i=baseUrl.lastIndexOf("?",pathLength);pathLength=i>=0?i:pathLength;var prefixLength=baseUrl.lastIndexOf("/",pathLength);return baseUrl.substring(0,prefixLength+1)+url}}function isValidUrl(url,allowRelative){if(!url)return false;var protocol=/^[a-z][a-z0-9+\-.]*(?=:)/i.exec(url); +if(!protocol)return allowRelative;protocol=protocol[0].toLowerCase();switch(protocol){case "http":case "https":case "ftp":case "mailto":return true;default:return false}}PDFJS.isValidUrl=isValidUrl;function shadow(obj,prop,value){Object.defineProperty(obj,prop,{value:value,enumerable:true,configurable:true,writable:false});return value}var PasswordResponses=PDFJS.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};var PasswordException=function PasswordExceptionClosure(){function PasswordException(msg, +code){this.name="PasswordException";this.message=msg;this.code=code}PasswordException.prototype=new Error;PasswordException.constructor=PasswordException;return PasswordException}();PDFJS.PasswordException=PasswordException;var UnknownErrorException=function UnknownErrorExceptionClosure(){function UnknownErrorException(msg,details){this.name="UnknownErrorException";this.message=msg;this.details=details}UnknownErrorException.prototype=new Error;UnknownErrorException.constructor=UnknownErrorException; +return UnknownErrorException}();PDFJS.UnknownErrorException=UnknownErrorException;var InvalidPDFException=function InvalidPDFExceptionClosure(){function InvalidPDFException(msg){this.name="InvalidPDFException";this.message=msg}InvalidPDFException.prototype=new Error;InvalidPDFException.constructor=InvalidPDFException;return InvalidPDFException}();PDFJS.InvalidPDFException=InvalidPDFException;var MissingPDFException=function MissingPDFExceptionClosure(){function MissingPDFException(msg){this.name= +"MissingPDFException";this.message=msg}MissingPDFException.prototype=new Error;MissingPDFException.constructor=MissingPDFException;return MissingPDFException}();PDFJS.MissingPDFException=MissingPDFException;var UnexpectedResponseException=function UnexpectedResponseExceptionClosure(){function UnexpectedResponseException(msg,status){this.name="UnexpectedResponseException";this.message=msg;this.status=status}UnexpectedResponseException.prototype=new Error;UnexpectedResponseException.constructor=UnexpectedResponseException; +return UnexpectedResponseException}();PDFJS.UnexpectedResponseException=UnexpectedResponseException;var NotImplementedException=function NotImplementedExceptionClosure(){function NotImplementedException(msg){this.message=msg}NotImplementedException.prototype=new Error;NotImplementedException.prototype.name="NotImplementedException";NotImplementedException.constructor=NotImplementedException;return NotImplementedException}();var MissingDataException=function MissingDataExceptionClosure(){function MissingDataException(begin, +end){this.begin=begin;this.end=end;this.message="Missing data ["+begin+", "+end+")"}MissingDataException.prototype=new Error;MissingDataException.prototype.name="MissingDataException";MissingDataException.constructor=MissingDataException;return MissingDataException}();var XRefParseException=function XRefParseExceptionClosure(){function XRefParseException(msg){this.message=msg}XRefParseException.prototype=new Error;XRefParseException.prototype.name="XRefParseException";XRefParseException.constructor= +XRefParseException;return XRefParseException}();function bytesToString(bytes){var length=bytes.length;var MAX_ARGUMENT_COUNT=8192;if(length>24&255,value>>16&255,value>>8&255,value&255)}function log2(x){var n=1,i=0;while(x>n){n<<=1;i++}return i}function readInt8(data,start){return data[start]<<24>>24}function readUint16(data,offset){return data[offset]<<8|data[offset+1]}function readUint32(data,offset){return(data[offset]<<24|data[offset+1]<<16|data[offset+2]<<8|data[offset+3])>>>0}function isLittleEndian(){var buffer8= +new Uint8Array(2);buffer8[0]=1;var buffer16=new Uint16Array(buffer8.buffer);return buffer16[0]===1}Object.defineProperty(PDFJS,"isLittleEndian",{configurable:true,get:function PDFJS_isLittleEndian(){return shadow(PDFJS,"isLittleEndian",isLittleEndian())}});function hasCanvasTypedArrays(){var canvas=document.createElement("canvas");canvas.width=canvas.height=1;var ctx=canvas.getContext("2d");var imageData=ctx.createImageData(1,1);return typeof imageData.data.buffer!=="undefined"}Object.defineProperty(PDFJS, +"hasCanvasTypedArrays",{configurable:true,get:function PDFJS_hasCanvasTypedArrays(){return shadow(PDFJS,"hasCanvasTypedArrays",hasCanvasTypedArrays())}});var Uint32ArrayView=function Uint32ArrayViewClosure(){function Uint32ArrayView(buffer,length){this.buffer=buffer;this.byteLength=buffer.length;this.length=length===undefined?this.byteLength>>2:length;ensureUint32ArrayViewProps(this.length)}Uint32ArrayView.prototype=Object.create(null);var uint32ArrayViewSetters=0;function createUint32ArrayProp(index){return{get:function(){var buffer= +this.buffer,offset=index<<2;return(buffer[offset]|buffer[offset+1]<<8|buffer[offset+2]<<16|buffer[offset+3]<<24)>>>0},set:function(value){var buffer=this.buffer,offset=index<<2;buffer[offset]=value&255;buffer[offset+1]=value>>8&255;buffer[offset+2]=value>>16&255;buffer[offset+3]=value>>>24&255}}}function ensureUint32ArrayViewProps(length){while(uint32ArrayViewSettersrect[2]){r[0]=rect[2];r[2]=rect[0]}if(rect[1]>rect[3]){r[1]=rect[3];r[3]=rect[1]}return r};Util.intersect=function Util_intersect(rect1,rect2){function compare(a,b){return a-b}var orderedX=[rect1[0],rect1[2],rect2[0],rect2[2]].sort(compare),orderedY=[rect1[1],rect1[3],rect2[1],rect2[3]].sort(compare),result=[];rect1=Util.normalizeRect(rect1);rect2=Util.normalizeRect(rect2);if(orderedX[0]===rect1[0]&&orderedX[1]===rect2[0]||orderedX[0]===rect2[0]&&orderedX[1]===rect1[0]){result[0]= +orderedX[1];result[2]=orderedX[2]}else return false;if(orderedY[0]===rect1[1]&&orderedY[1]===rect2[1]||orderedY[0]===rect2[1]&&orderedY[1]===rect1[1]){result[1]=orderedY[1];result[3]=orderedY[2]}else return false;return result};Util.sign=function Util_sign(num){return num<0?-1:1};Util.appendToArray=function Util_appendToArray(arr1,arr2){Array.prototype.push.apply(arr1,arr2)};Util.prependToArray=function Util_prependToArray(arr1,arr2){Array.prototype.unshift.apply(arr1,arr2)};Util.extendObj=function extendObj(obj1, +obj2){for(var key in obj2)obj1[key]=obj2[key]};Util.getInheritableProperty=function Util_getInheritableProperty(dict,name){while(dict&&!dict.has(name))dict=dict.get("Parent");if(!dict)return null;return dict.get(name)};Util.inherit=function Util_inherit(sub,base,prototype){sub.prototype=Object.create(base.prototype);sub.prototype.constructor=sub;for(var prop in prototype)sub.prototype[prop]=prototype[prop]};Util.loadScript=function Util_loadScript(src,callback){var script=document.createElement("script"); +var loaded=false;script.setAttribute("src",src);if(callback)script.onload=function(){if(!loaded)callback();loaded=true};document.getElementsByTagName("head")[0].appendChild(script)};return Util}();var PageViewport=PDFJS.PageViewport=function PageViewportClosure(){function PageViewport(viewBox,scale,rotation,offsetX,offsetY,dontFlip){this.viewBox=viewBox;this.scale=scale;this.rotation=rotation;this.offsetX=offsetX;this.offsetY=offsetY;var centerX=(viewBox[2]+viewBox[0])/2;var centerY=(viewBox[3]+viewBox[1])/ +2;var rotateA,rotateB,rotateC,rotateD;rotation=rotation%360;rotation=rotation<0?rotation+360:rotation;switch(rotation){case 180:rotateA=-1;rotateB=0;rotateC=0;rotateD=1;break;case 90:rotateA=0;rotateB=1;rotateC=1;rotateD=0;break;case 270:rotateA=0;rotateB=-1;rotateC=-1;rotateD=0;break;default:rotateA=1;rotateB=0;rotateC=0;rotateD=-1;break}if(dontFlip){rotateC=-rotateC;rotateD=-rotateD}var offsetCanvasX,offsetCanvasY;var width,height;if(rotateA===0){offsetCanvasX=Math.abs(centerY-viewBox[1])*scale+ +offsetX;offsetCanvasY=Math.abs(centerX-viewBox[0])*scale+offsetY;width=Math.abs(viewBox[3]-viewBox[1])*scale;height=Math.abs(viewBox[2]-viewBox[0])*scale}else{offsetCanvasX=Math.abs(centerX-viewBox[0])*scale+offsetX;offsetCanvasY=Math.abs(centerY-viewBox[1])*scale+offsetY;width=Math.abs(viewBox[2]-viewBox[0])*scale;height=Math.abs(viewBox[3]-viewBox[1])*scale}this.transform=[rotateA*scale,rotateB*scale,rotateC*scale,rotateD*scale,offsetCanvasX-rotateA*scale*centerX-rotateC*scale*centerY,offsetCanvasY- +rotateB*scale*centerX-rotateD*scale*centerY];this.width=width;this.height=height;this.fontScale=scale}PageViewport.prototype={clone:function PageViewPort_clone(args){args=args||{};var scale="scale"in args?args.scale:this.scale;var rotation="rotation"in args?args.rotation:this.rotation;return new PageViewport(this.viewBox.slice(),scale,rotation,this.offsetX,this.offsetY,args.dontFlip)},convertToViewportPoint:function PageViewport_convertToViewportPoint(x,y){return Util.applyTransform([x,y],this.transform)}, +convertToViewportRectangle:function PageViewport_convertToViewportRectangle(rect){var tl=Util.applyTransform([rect[0],rect[1]],this.transform);var br=Util.applyTransform([rect[2],rect[3]],this.transform);return[tl[0],tl[1],br[0],br[1]]},convertToPdfPoint:function PageViewport_convertToPdfPoint(x,y){return Util.applyInverseTransform([x,y],this.transform)}};return PageViewport}();var PDFStringTranslateTable=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToPDFString(str){var i,n=str.length,strBuf=[];if(str[0]==="\u00fe"&&str[1]==="\u00ff")for(i=2;i0){var handler=this.handlers.shift();var nextStatus=handler.thisPromise._status;var nextValue=handler.thisPromise._value;try{if(nextStatus===STATUS_RESOLVED){if(typeof handler.onResolve==="function")nextValue=handler.onResolve(nextValue)}else if(typeof handler.onReject=== +"function"){nextValue=handler.onReject(nextValue);nextStatus=STATUS_RESOLVED;if(handler.thisPromise._unhandledRejection)this.removeUnhandeledRejection(handler.thisPromise)}}catch(ex){nextStatus=STATUS_REJECTED;nextValue=ex}handler.nextPromise._updateStatus(nextStatus,nextValue);if(Date.now()>=timeoutAt)break}if(this.handlers.length>0){setTimeout(this.runHandlers.bind(this),0);return}this.running=false},addUnhandledRejection:function addUnhandledRejection(promise){this.unhandledRejections.push({promise:promise, +time:Date.now()});this.scheduleRejectionCheck()},removeUnhandeledRejection:function removeUnhandeledRejection(promise){promise._unhandledRejection=false;for(var i=0;iREJECTION_TIMEOUT){var unhandled=this.unhandledRejections[i].promise._value;var msg="Unhandled rejection: "+unhandled;if(unhandled.stack)msg+="\n"+unhandled.stack;warn(msg);this.unhandledRejections.splice(i);i--}if(this.unhandledRejections.length)this.scheduleRejectionCheck()}.bind(this),REJECTION_TIMEOUT)}};function Promise(resolver){this._status=STATUS_PENDING;this._handlers=[];try{resolver.call(this,this._resolve.bind(this), +this._reject.bind(this))}catch(e){this._reject(e)}}Promise.all=function Promise_all(promises){var resolveAll,rejectAll;var deferred=new Promise(function(resolve,reject){resolveAll=resolve;rejectAll=reject});var unresolved=promises.length;var results=[];if(unresolved===0){resolveAll(results);return deferred}function reject(reason){if(deferred._status===STATUS_REJECTED)return;results=[];rejectAll(reason)}for(var i=0,ii=promises.length;ilongest)longest=name.length}for(i=0,ii=times.length;i>2,d2=(b1&3)<<4|b2>>4;var d3=i+1>6:64;var d4=i+2=2&&pendingRequest.onHeadersReceived){pendingRequest.onHeadersReceived();delete pendingRequest.onHeadersReceived}if(xhr.readyState!== +4)return;if(!(xhrId in this.pendingRequests))return;delete this.pendingRequests[xhrId];if(xhr.status===0&&this.isHttp){if(pendingRequest.onError)pendingRequest.onError(xhr.status);return}var xhrStatus=xhr.status||OK_RESPONSE;var ok_response_on_range_request=xhrStatus===OK_RESPONSE&&pendingRequest.expectedStatus===PARTIAL_CONTENT_RESPONSE;if(!ok_response_on_range_request&&xhrStatus!==pendingRequest.expectedStatus){if(pendingRequest.onError)pendingRequest.onError(xhr.status);return}this.loadedRequests[xhrId]= +true;var chunk=getArrayBuffer(xhr);if(xhrStatus===PARTIAL_CONTENT_RESPONSE){var rangeHeader=xhr.getResponseHeader("Content-Range");var matches=/bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);var begin=parseInt(matches[1],10);pendingRequest.onDone({begin:begin,chunk:chunk})}else if(pendingRequest.onProgressiveData)pendingRequest.onDone(null);else pendingRequest.onDone({begin:0,chunk:chunk})},hasPendingRequests:function NetworkManager_hasPendingRequests(){for(var xhrId in this.pendingRequests)return true; +return false},getRequestXhr:function NetworkManager_getXhr(xhrId){return this.pendingRequests[xhrId].xhr},isStreamingRequest:function NetworkManager_isStreamingRequest(xhrId){return!!this.pendingRequests[xhrId].onProgressiveData},isPendingRequest:function NetworkManager_isPendingRequest(xhrId){return xhrId in this.pendingRequests},isLoadedRequest:function NetworkManager_isLoadedRequest(xhrId){return xhrId in this.loadedRequests},abortAllRequests:function NetworkManager_abortAllRequests(){for(var xhrId in this.pendingRequests)this.abortRequest(xhrId| +0)},abortRequest:function NetworkManager_abortRequest(xhrId){var xhr=this.pendingRequests[xhrId].xhr;delete this.pendingRequests[xhrId];xhr.abort()}};return NetworkManager}();var ChunkedStream=function ChunkedStreamClosure(){function ChunkedStream(length,chunkSize,manager){this.bytes=new Uint8Array(length);this.start=0;this.pos=0;this.end=length;this.chunkSize=chunkSize;this.loadedChunks=[];this.numChunksLoaded=0;this.numChunks=Math.ceil(length/chunkSize);this.manager=manager;this.progressiveDataLength= +0;this.lastSuccessfulEnsureByteChunk=-1}ChunkedStream.prototype={getMissingChunks:function ChunkedStream_getMissingChunks(){var chunks=[];for(var chunk=0,n=this.numChunks;chunk=this.end?this.numChunks:Math.floor(position/this.chunkSize);var curChunk;for(curChunk=beginChunk;curChunk=end)return;if(end<=this.progressiveDataLength)return;var chunkSize=this.chunkSize;var beginChunk=Math.floor(begin/chunkSize);var endChunk=Math.floor((end-1)/chunkSize)+1;for(var chunk=beginChunk;chunk=this.end)return-1; +this.ensureByte(pos);return this.bytes[this.pos++]},getUint16:function ChunkedStream_getUint16(){var b0=this.getByte();var b1=this.getByte();return(b0<<8)+b1},getInt32:function ChunkedStream_getInt32(){var b0=this.getByte();var b1=this.getByte();var b2=this.getByte();var b3=this.getByte();return(b0<<24)+(b1<<16)+(b2<<8)+b3},getBytes:function ChunkedStream_getBytes(length){var bytes=this.bytes;var pos=this.pos;var strEnd=this.end;if(!length){this.ensureRange(pos,strEnd);return bytes.subarray(pos,strEnd)}var end= +pos+length;if(end>strEnd)end=strEnd;this.ensureRange(pos,end);this.pos=end;return bytes.subarray(pos,end)},peekByte:function ChunkedStream_peekByte(){var peekedByte=this.getByte();this.pos--;return peekedByte},peekBytes:function ChunkedStream_peekBytes(length){var bytes=this.getBytes(length);this.pos-=bytes.length;return bytes},getByteRange:function ChunkedStream_getBytes(begin,end){this.ensureRange(begin,end);return this.bytes.subarray(begin,end)},skip:function ChunkedStream_skip(n){if(!n)n=1;this.pos+= +n},reset:function ChunkedStream_reset(){this.pos=this.start},moveStart:function ChunkedStream_moveStart(){this.start=this.pos},makeSubStream:function ChunkedStream_makeSubStream(start,length,dict){this.ensureRange(start,start+length);function ChunkedStreamSubstream(){}ChunkedStreamSubstream.prototype=Object.create(this);ChunkedStreamSubstream.prototype.getMissingChunks=function(){var chunkSize=this.chunkSize;var beginChunk=Math.floor(this.start/chunkSize);var endChunk=Math.floor((this.end-1)/chunkSize)+ +1;var missingChunks=[];for(var chunk=beginChunk;chunk=0&&prevChunk+1!==chunk){groupedChunks.push({beginChunk:beginChunk,endChunk:prevChunk+1});beginChunk=chunk}if(i+1===chunks.length)groupedChunks.push({beginChunk:beginChunk,endChunk:chunk+1});prevChunk=chunk}return groupedChunks},onProgress:function ChunkedStreamManager_onProgress(args){var bytesLoaded= +this.stream.numChunksLoaded*this.chunkSize+args.loaded;this.msgHandler.send("DocProgress",{loaded:bytesLoaded,total:this.length})},onReceiveData:function ChunkedStreamManager_onReceiveData(args){var chunk=args.chunk;var isProgressive=args.begin===undefined;var begin=isProgressive?this.progressiveDataLength:args.begin;var end=begin+chunk.byteLength;var beginChunk=Math.floor(begin/this.chunkSize);var endChunk=end=360)rotate=rotate%360;else if(rotate<0)rotate=(rotate%360+360)%360;return shadow(this,"rotate",rotate)},getContentStream:function Page_getContentStream(){var content=this.content;var stream;if(isArray(content)){var xref= +this.xref;var i,n=content.length;var streams=[];for(i=0;i0,"stream must have data");this.pdfManager=pdfManager;this.stream=stream;var xref=new XRef(this.stream,password,pdfManager);this.xref=xref}function find(stream,needle,limit,backwards){var pos=stream.pos;var end=stream.end;var strBuf=[];if(pos+ +limit>end)limit=end-pos;for(var n=0;n0){pos-=step-"startxref".length;if(pos<0)pos=0;stream.pos=pos;found=find(stream,"startxref",step,true)}if(found){stream.skip(9);var ch;do ch=stream.getByte();while(Lexer.isSpace(ch)); +var str="";while(ch>=32&&ch<=57){str+=String.fromCharCode(ch);ch=stream.getByte()}startXRef=parseInt(str,10);if(isNaN(startXRef))startXRef=0}}return shadow(this,"startXRef",startXRef)},get mainXRefEntriesOffset(){var mainXRefEntriesOffset=0;var linearization=this.linearization;if(linearization)mainXRefEntriesOffset=linearization.mainXRefEntriesOffset;return shadow(this,"mainXRefEntriesOffset",mainXRefEntriesOffset)},checkHeader:function PDFDocument_checkHeader(){var stream=this.stream;stream.reset(); +if(find(stream,"%PDF-",1024)){stream.moveStart();var MAX_VERSION_LENGTH=12;var version="",ch;while((ch=stream.getByte())>32){if(version.length>=MAX_VERSION_LENGTH)break;version+=String.fromCharCode(ch)}this.pdfFormatVersion=version.substring(5);return}},parseStartXRef:function PDFDocument_parseStartXRef(){var startXRef=this.startXRef;this.xref.setStartXRef(startXRef)},setup:function PDFDocument_setup(recoveryMode){this.xref.parse(recoveryMode);this.catalog=new Catalog(this.pdfManager,this.xref)}, +get numPages(){var linearization=this.linearization;var num=linearization?linearization.numPages:this.catalog.numPages;return shadow(this,"numPages",num)},get documentInfo(){var docInfo={PDFFormatVersion:this.pdfFormatVersion,IsAcroFormPresent:!!this.acroForm,IsXFAPresent:!!this.xfa};var infoDict;try{infoDict=this.xref.trailer.get("Info")}catch(err){info("The document information dictionary is invalid.")}if(infoDict){var validEntries=DocumentInfoValidators.entries;for(var key in validEntries)if(infoDict.has(key)){var value= +infoDict.get(key);if(validEntries[key](value))docInfo[key]=typeof value!=="string"?value:stringToPDFString(value);else info('Bad value in document info for "'+key+'"')}}return shadow(this,"documentInfo",docInfo)},get fingerprint(){var xref=this.xref,hash,fileID="";if(xref.trailer.has("ID"))hash=stringToBytes(xref.trailer.get("ID")[0]);else hash=calculateMD5(this.stream.bytes.subarray(0,100),0,100);for(var i=0,n=hash.length;i +0){var item=queue.shift();var itemObj=item.obj;var objId=itemObj.objId;if(objId&&objId in processed){item.target[item.key]=processed[objId];continue}var dereferenced=Object.create(null);for(key in itemObj.map){obj=itemObj.get(key);if(obj instanceof Dict)if(isRecursionAllowedFor(obj))queue.push({target:dereferenced,key:key,obj:obj});else dereferenced[key]=itemObj.getRaw(key);else dereferenced[key]=obj}if(objId)processed[objId]=dereferenced;item.target[item.key]=dereferenced}return all},set:function Dict_set(key, +value){this.map[key]=value},has:function Dict_has(key){return key in this.map},forEach:function Dict_forEach(callback){for(var key in this.map)callback(key,this.get(key))}};Dict.empty=new Dict(null);return Dict}();var Ref=function RefClosure(){function Ref(num,gen){this.num=num;this.gen=gen}Ref.prototype={toString:function Ref_toString(){var str=this.num+"R";if(this.gen!==0)str+=this.gen;return str}};return Ref}();var RefSet=function RefSetClosure(){function RefSet(){this.dict={}}RefSet.prototype= +{has:function RefSet_has(ref){return ref.toString()in this.dict},put:function RefSet_put(ref){this.dict[ref.toString()]=true},remove:function RefSet_remove(ref){delete this.dict[ref.toString()]}};return RefSet}();var RefSetCache=function RefSetCacheClosure(){function RefSetCache(){this.dict=Object.create(null)}RefSetCache.prototype={get:function RefSetCache_get(ref){return this.dict[ref.toString()]},has:function RefSetCache_has(ref){return ref.toString()in this.dict},put:function RefSetCache_put(ref, +obj){this.dict[ref.toString()]=obj},putAlias:function RefSetCache_putAlias(ref,aliasRef){this.dict[ref.toString()]=this.get(aliasRef)},forEach:function RefSetCache_forEach(fn,thisArg){for(var i in this.dict)fn.call(thisArg,this.dict[i])},clear:function RefSetCache_clear(){this.dict=Object.create(null)}};return RefSetCache}();var Catalog=function CatalogClosure(){function Catalog(pdfManager,xref){this.pdfManager=pdfManager;this.xref=xref;this.catDict=xref.getCatalogObj();this.fontCache=new RefSetCache; +assert(isDict(this.catDict),"catalog object is not a dictionary");this.pagePromises=[]}Catalog.prototype={get metadata(){var streamRef=this.catDict.getRaw("Metadata");if(!isRef(streamRef))return shadow(this,"metadata",null);var encryptMetadata=!this.xref.encrypt?false:this.xref.encrypt.encryptMetadata;var stream=this.xref.fetch(streamRef,!encryptMetadata);var metadata;if(stream&&isDict(stream.dict)){var type=stream.dict.get("Type");var subtype=stream.dict.get("Subtype");if(isName(type)&&isName(subtype)&& +type.name==="Metadata"&&subtype.name==="XML")try{metadata=stringToUTF8String(bytesToString(stream.getBytes()))}catch(e){info("Skipping invalid metadata.")}}return shadow(this,"metadata",metadata)},get toplevelPagesDict(){var pagesObj=this.catDict.get("Pages");assert(isDict(pagesObj),"invalid top-level pages dictionary");return shadow(this,"toplevelPagesDict",pagesObj)},get documentOutline(){var obj=null;try{obj=this.readDocumentOutline()}catch(ex){if(ex instanceof MissingDataException)throw ex;warn("Unable to read document outline")}return shadow(this, +"documentOutline",obj)},readDocumentOutline:function Catalog_readDocumentOutline(){var xref=this.xref;var obj=this.catDict.get("Outlines");var root={items:[]};if(isDict(obj)){obj=obj.getRaw("First");var processed=new RefSet;if(isRef(obj)){var queue=[{obj:obj,parent:root}];processed.put(obj);while(queue.length>0){var i=queue.shift();var outlineDict=xref.fetchIfRef(i.obj);if(outlineDict===null)continue;if(!outlineDict.has("Title"))error("Invalid outline item");var dest=outlineDict.get("A");if(dest)dest= +dest.get("D");else if(outlineDict.has("Dest")){dest=outlineDict.getRaw("Dest");if(isName(dest))dest=dest.name}var title=outlineDict.get("Title");var outlineItem={dest:dest,title:stringToPDFString(title),color:outlineDict.get("C")||[0,0,0],count:outlineDict.get("Count"),bold:!!(outlineDict.get("F")&2),italic:!!(outlineDict.get("F")&1),items:[]};i.parent.items.push(outlineItem);obj=outlineDict.getRaw("First");if(isRef(obj)&&!processed.has(obj)){queue.push({obj:obj,parent:outlineItem});processed.put(obj)}obj= +outlineDict.getRaw("Next");if(isRef(obj)&&!processed.has(obj)){queue.push({obj:obj,parent:i.parent});processed.put(obj)}}}}return root.items.length>0?root.items:null},get numPages(){var obj=this.toplevelPagesDict.get("Count");assert(isInt(obj),"page count in top level pages object is not an integer");return shadow(this,"num",obj)},get destinations(){function fetchDestination(dest){return isDict(dest)?dest.get("D"):dest}var xref=this.xref;var dests={},nameTreeRef,nameDictionaryRef;var obj=this.catDict.get("Names"); +if(obj&&obj.has("Dests"))nameTreeRef=obj.getRaw("Dests");else if(this.catDict.has("Dests"))nameDictionaryRef=this.catDict.get("Dests");if(nameDictionaryRef){obj=nameDictionaryRef;obj.forEach(function catalogForEach(key,value){if(!value)return;dests[key]=fetchDestination(value)})}if(nameTreeRef){var nameTree=new NameTree(nameTreeRef,xref);var names=nameTree.getAll();for(var name in names){if(!names.hasOwnProperty(name))continue;dests[name]=fetchDestination(names[name])}}return shadow(this,"destinations", +dests)},getDestination:function Catalog_getDestination(destinationId){function fetchDestination(dest){return isDict(dest)?dest.get("D"):dest}var xref=this.xref;var dest,nameTreeRef,nameDictionaryRef;var obj=this.catDict.get("Names");if(obj&&obj.has("Dests"))nameTreeRef=obj.getRaw("Dests");else if(this.catDict.has("Dests"))nameDictionaryRef=this.catDict.get("Dests");if(nameDictionaryRef){obj=nameDictionaryRef;obj.forEach(function catalogForEach(key,value){if(!value)return;if(key===destinationId)dest= +fetchDestination(value)})}if(nameTreeRef){var nameTree=new NameTree(nameTreeRef,xref);dest=fetchDestination(nameTree.get(destinationId))}return dest},get attachments(){var xref=this.xref;var attachments=null,nameTreeRef;var obj=this.catDict.get("Names");if(obj)nameTreeRef=obj.getRaw("EmbeddedFiles");if(nameTreeRef){var nameTree=new NameTree(nameTreeRef,xref);var names=nameTree.getAll();for(var name in names){if(!names.hasOwnProperty(name))continue;var fs=new FileSpec(names[name],xref);if(!attachments)attachments= +{};attachments[stringToPDFString(name)]=fs.serializable}}return shadow(this,"attachments",attachments)},get javaScript(){var xref=this.xref;var obj=this.catDict.get("Names");var javaScript=[];if(obj&&obj.has("JavaScript")){var nameTree=new NameTree(obj.getRaw("JavaScript"),xref);var names=nameTree.getAll();for(var name in names){if(!names.hasOwnProperty(name))continue;var jsDict=names[name];if(!isDict(jsDict))continue;var type=jsDict.get("S");if(!isName(type)||type.name!=="JavaScript")continue;var js= +jsDict.get("JS");if(!isString(js)&&!isStream(js))continue;if(isStream(js))js=bytesToString(js.getBytes());javaScript.push(stringToPDFString(js))}}var openactionDict=this.catDict.get("OpenAction");if(isDict(openactionDict)){var objType=openactionDict.get("Type");var actionType=openactionDict.get("S");var action=openactionDict.get("N");var isPrintAction=isName(objType)&&objType.name==="Action"&&isName(actionType)&&actionType.name==="Named"&&isName(action)&&action.name==="Print";if(isPrintAction)javaScript.push("print(true);")}return shadow(this, +"javaScript",javaScript)},cleanup:function Catalog_cleanup(){var promises=[];this.fontCache.forEach(function(promise){promises.push(promise)});return Promise.all(promises).then(function(translatedFonts){for(var i=0,ii=translatedFonts.length;i=0;last--)nodesToVisit.push(kids[last])}capability.reject("Page index "+pageIndex+" not found.")}next();return capability.promise},getPageIndex:function Catalog_getPageIndex(ref){var xref=this.xref;function pagesBeforeRef(kidRef){var total=0;var parentRef;return xref.fetchAsync(kidRef).then(function(node){if(!node)return null;parentRef=node.getRaw("Parent");return node.getAsync("Parent")}).then(function(parent){if(!parent)return null; +return parent.getAsync("Kids")}).then(function(kids){if(!kids)return null;var kidPromises=[];var found=false;for(var i=0;i0){var first=entryRanges[0];var n=entryRanges[1];if(!isInt(first)||!isInt(n))error("Invalid XRef range fields: "+first+", "+n);if(!isInt(typeFieldWidth)||!isInt(offsetFieldWidth)||!isInt(generationFieldWidth))error("Invalid XRef entry fields length: "+first+", "+n);for(i=streamState.entryNum;i=data.length)break;token+=String.fromCharCode(ch);ch=data[offset]}return token}function skipUntil(data,offset,what){var length=what.length,dataLength=data.length;var skipped=0;while(offset=length)break;offset++;skipped++}return skipped}var trailerBytes=new Uint8Array([116, +114,97,105,108,101,114]);var startxrefBytes=new Uint8Array([115,116,97,114,116,120,114,101,102]);var endobjBytes=new Uint8Array([101,110,100,111,98,106]);var xrefBytes=new Uint8Array([47,88,82,101,102]);var stream=this.stream;stream.pos=0;var buffer=stream.getBytes();var position=stream.start,length=buffer.length;var trailers=[],xrefStms=[];while(position=length)break;ch= +buffer[position]}while(ch!==13&&ch!==10);continue}var token=readToken(buffer,position);var m;if(token==="xref"){position+=skipUntil(buffer,position,trailerBytes);trailers.push(position);position+=skipUntil(buffer,position,startxrefBytes)}else if(m=/^(\d+)\s+(\d+)\s+obj\b/.exec(token)){this.entries[m[1]]={offset:position,gen:m[2]|0,uncompressed:true};var contentLength=skipUntil(buffer,position,endobjBytes)+7;var content=buffer.subarray(position,position+contentLength);var xrefTagOffset=skipUntil(content, +0,xrefBytes);if(xrefTagOffset0){var i,n;var obj=xref.fetchIfRef(queue.shift());if(!isDict(obj))continue; +if(obj.has("Kids")){var kids=obj.get("Kids");for(i=0,n=kids.length;iMAX_NAMES_LEVELS){warn("Search depth limit for named destionations has been reached.");return null}var kids=kidsOrNames.get("Kids");if(!isArray(kids))return null;l=0;r=kids.length-1;while(l<=r){m=l+r>>1;var kid=xref.fetchIfRef(kids[m]);var limits=kid.get("Limits");if(destinationIdlimits[1])l=m+1;else{kidsOrNames=xref.fetchIfRef(kids[m]);break}}if(l>r)return null}var names=kidsOrNames.get("Names");if(isArray(names)){l=0;r=names.length-2;while(l<= +r){m=l+r&~1;if(destinationIdnames[m])l=m+2;else return xref.fetchIfRef(names[m+1])}}return null}};return NameTree}();var FileSpec=function FileSpecClosure(){function FileSpec(root,xref){if(!root||!isDict(root))return;this.xref=xref;this.root=root;if(root.has("FS"))this.fs=root.get("FS");this.description=root.has("Desc")?stringToPDFString(root.get("Desc")):"";if(root.has("RF"))warn("Related file specifications are not supported");this.contentAvailable=true;if(!root.has("EF")){this.contentAvailable= +false;warn("Non-embedded file specifications are not supported")}}function pickPlatformItem(dict){if(dict.has("UF"))return dict.get("UF");else if(dict.has("F"))return dict.get("F");else if(dict.has("Unix"))return dict.get("Unix");else if(dict.has("Mac"))return dict.get("Mac");else if(dict.has("DOS"))return dict.get("DOS");else return null}FileSpec.prototype={get filename(){if(!this._filename&&this.root){var filename=pickPlatformItem(this.root)||"unnamed";this._filename=stringToPDFString(filename).replace(/\\\\/g, +"\\").replace(/\\\//g,"/").replace(/\\/g,"/")}return this._filename},get content(){if(!this.contentAvailable)return null;if(!this.contentRef&&this.root)this.contentRef=pickPlatformItem(this.root.get("EF"));var content=null;if(this.contentRef){var xref=this.xref;var fileObj=xref.fetchIfRef(this.contentRef);if(fileObj&&isStream(fileObj))content=fileObj.getBytes();else warn("Embedded file specification points to non-existing/invalid "+"content")}else warn("Embedded file specification does not have a content"); +return content},get serializable(){return{filename:this.filename,content:this.content}}};return FileSpec}();var ObjectLoader=function(){function mayHaveChildren(value){return isRef(value)||isDict(value)||isArray(value)||isStream(value)}function addChildren(node,nodesToVisit){var value;if(isDict(node)||isStream(node)){var map;if(isDict(node))map=node.map;else map=node.dict.map;for(var key in map){value=map[key];if(mayHaveChildren(value))nodesToVisit.push(value)}}else if(isArray(node))for(var i=0,ii= +node.length;i0&&dashArray)if(!isArray(dashArray))data.borderWidth=0;else{var dashArrayLength=dashArray.length;if(dashArrayLength>0){var isInvalid=false;var numPositive=0;for(var i=0;i=0;if(!validNumber){isInvalid=true;break}else if(dashArray[i]>0)numPositive++}if(isInvalid||numPositive===0)data.borderWidth=0}}}this.appearance=getDefaultAppearance(dict);data.hasAppearance= +!!this.appearance;data.id=params.ref.num}Annotation.prototype={getData:function Annotation_getData(){return this.data},isInvisible:function Annotation_isInvisible(){var data=this.data;if(data&&SUPPORTED_TYPES.indexOf(data.subtype)!==-1)return false;else return!!(data&&data.annotationFlags&&data.annotationFlags&1)},isViewable:function Annotation_isViewable(){var data=this.data;return!!(!this.isInvisible()&&data&&(!data.annotationFlags||!(data.annotationFlags&34))&&data.rect)},isPrintable:function Annotation_isPrintable(){var data= +this.data;return!!(!this.isInvisible()&&data&&data.annotationFlags&&data.annotationFlags&4&&!(data.annotationFlags&2)&&data.rect)},loadResources:function Annotation_loadResources(keys){return new Promise(function(resolve,reject){this.appearance.dict.getAsync("Resources").then(function(resources){if(!resources){resolve();return}var objectLoader=new ObjectLoader(resources.map,keys,resources.xref);objectLoader.load().then(function(){resolve(resources)},reject)},reject)}.bind(this))},getOperatorList:function Annotation_getOperatorList(evaluator){if(!this.appearance)return Promise.resolve(new OperatorList); +var data=this.data;var appearanceDict=this.appearance.dict;var resourcesPromise=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]);var bbox=appearanceDict.get("BBox")||[0,0,1,1];var matrix=appearanceDict.get("Matrix")||[1,0,0,1,0,0];var transform=getTransformMatrix(data.rect,bbox,matrix);var self=this;return resourcesPromise.then(function(resources){var opList=new OperatorList;opList.addOp(OPS.beginAnnotation,[data.rect,transform,matrix]);return evaluator.getOperatorList(self.appearance, +resources,opList).then(function(){opList.addOp(OPS.endAnnotation,[]);self.appearance.reset();return opList})})}};Annotation.getConstructor=function Annotation_getConstructor(subtype,fieldType){if(!subtype)return;if(subtype==="Link")return LinkAnnotation;else if(subtype==="Text")return TextAnnotation;else if(subtype==="Widget"){if(!fieldType)return;if(fieldType==="Tx")return TextWidgetAnnotation;else return WidgetAnnotation}else return Annotation};Annotation.fromRef=function Annotation_fromRef(xref, +ref){var dict=xref.fetchIfRef(ref);if(!isDict(dict))return;var subtype=dict.get("Subtype");subtype=isName(subtype)?subtype.name:"";if(!subtype)return;var fieldType=Util.getInheritableProperty(dict,"FT");fieldType=isName(fieldType)?fieldType.name:"";var Constructor=Annotation.getConstructor(subtype,fieldType);if(!Constructor)return;var params={dict:dict,ref:ref};var annotation=new Constructor(params);if(annotation.isViewable()||annotation.isPrintable())return annotation;else if(SUPPORTED_TYPES.indexOf(subtype)=== +-1)warn("unimplemented annotation type: "+subtype)};Annotation.appendToOperatorList=function Annotation_appendToOperatorList(annotations,opList,pdfManager,partialEvaluator,intent){function reject(e){annotationsReadyCapability.reject(e)}var annotationsReadyCapability=createPromiseCapability();var annotationPromises=[];for(var i=0,n=annotations.length;i>codeSize)*sampleMul;codeBuf&=(1<max)v=max;else if(v0)dmin=bounds[i-1];var dmax= +domain[1];if(i>1;var numInputs=domain.length>>1;var evaluator=new PostScriptEvaluator(code);var cache={};var MAX_CACHE_SIZE=2048*4;var cache_available=MAX_CACHE_SIZE;var tmpBuf= +new Float32Array(numInputs);return function constructPostScriptFromIRResult(src,srcOffset,dest,destOffset){var i,value;var key="";var input=tmpBuf;for(i=0;ibound)value=bound}output[i]=value}if(cache_available>0){cache_available--;cache[key]=output}output.set(dest,destOffset)}}}}();function isPDFFunction(v){var fnDict;if(typeof v!=="object")return false;else if(isDict(v))fnDict=v;else if(isStream(v))fnDict=v.dict;else return false;return fnDict.has("FunctionType")}var PostScriptStack=function PostScriptStackClosure(){var MAX_STACK_SIZE=100;function PostScriptStack(initialStack){this.stack= +!initialStack?[]:Array.prototype.slice.call(initialStack,0)}PostScriptStack.prototype={push:function PostScriptStack_push(value){if(this.stack.length>=MAX_STACK_SIZE)error("PostScript function stack overflow.");this.stack.push(value)},pop:function PostScriptStack_pop(){if(this.stack.length<=0)error("PostScript function stack underflow.");return this.stack.pop()},copy:function PostScriptStack_copy(n){if(this.stack.length+n>=MAX_STACK_SIZE)error("PostScript function stack overflow.");var stack=this.stack; +for(var i=stack.length-n,j=n-1;j>=0;j--,i++)stack.push(stack[i])},index:function PostScriptStack_index(n){this.push(this.stack[this.stack.length-n-1])},roll:function PostScriptStack_roll(n,p){var stack=this.stack;var l=stack.length-n;var r=stack.length-1,c=l+(p-Math.floor(p/n)*n),i,j,t;for(i=l,j=r;i0)stack.push(a<>b);break;case "ceiling":a=stack.pop();stack.push(Math.ceil(a)); +break;case "copy":a=stack.pop();stack.copy(a);break;case "cos":a=stack.pop();stack.push(Math.cos(a));break;case "cvi":a=stack.pop()|0;stack.push(a);break;case "cvr":break;case "div":b=stack.pop();a=stack.pop();stack.push(a/b);break;case "dup":stack.copy(1);break;case "eq":b=stack.pop();a=stack.pop();stack.push(a===b);break;case "exch":stack.roll(2,1);break;case "exp":b=stack.pop();a=stack.pop();stack.push(Math.pow(a,b));break;case "false":stack.push(false);break;case "floor":a=stack.pop();stack.push(Math.floor(a)); +break;case "ge":b=stack.pop();a=stack.pop();stack.push(a>=b);break;case "gt":b=stack.pop();a=stack.pop();stack.push(a>b);break;case "idiv":b=stack.pop();a=stack.pop();stack.push(a/b|0);break;case "index":a=stack.pop();stack.index(a);break;case "le":b=stack.pop();a=stack.pop();stack.push(a<=b);break;case "ln":a=stack.pop();stack.push(Math.log(a));break;case "log":a=stack.pop();stack.push(Math.log(a)/Math.LN10);break;case "lt":b=stack.pop();a=stack.pop();stack.push(a=max)return new AstLiteral(max);else if(num1.max<=max)return num1;return new AstMin(num1,max)}function PostScriptCompiler(){}PostScriptCompiler.prototype={compile:function PostScriptCompiler_compile(code,domain,range){var stack= +[];var i,ii;var instructions=[];var inputSize=domain.length>>1,outputSize=range.length>>1;var lastRegister=0;var n,j,min,max;var num1,num2,ast1,ast2,tmpVar,item;for(i=0;iexpr.min){out.unshift("Math.max(",min,", ");out.push(")")}if(maxnumComponentColors&&this.name!=="DeviceGray"&&this.name!=="DeviceRGB"){var allColors=bpc<= +8?new Uint8Array(numComponentColors):new Uint16Array(numComponentColors);var key;for(i=0;i255?255:c;dest[destOffset]=dest[destOffset+1]=dest[destOffset+2]=c},getRgbBuffer:function DeviceGrayCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var scale=255/((1<255?255:r;dest[destOffset+1]=g<0?0:g>255?255:g;dest[destOffset+2]=b<0?0:b>255?255:b},getRgbBuffer:function DeviceRgbCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){if(bits===8&&alpha01===0){dest.set(src.subarray(srcOffset,srcOffset+count*3),destOffset);return}var scale=255/((1<255?255:r<0?0:r;dest[destOffset+1]=g>255?255:g<0?0:g;dest[destOffset+2]=b>255?255:b<0?0:b}function DeviceCmykCS(){this.name="DeviceCMYK";this.numComps=4;this.defaultColor=new Float32Array([0,0,0,1])}DeviceCmykCS.prototype={getRgb:ColorSpace.prototype.getRgb,getRgbItem:function DeviceCmykCS_getRgbItem(src,srcOffset,dest,destOffset){convertToRgb(src,srcOffset,1,dest,destOffset)},getRgbBuffer:function DeviceCmykCS_getRgbBuffer(src, +srcOffset,count,dest,destOffset,bits,alpha01){var scale=1/((1<8)return Math.pow((L+16)/116,3);return L* +DECODE_L_CONSTANT}function compensateBlackPoint(sourceBlackPoint,XYZ_Flat,result){if(sourceBlackPoint[0]===0&&sourceBlackPoint[1]===0&&sourceBlackPoint[2]===0){result[0]=XYZ_Flat[0];result[1]=XYZ_Flat[1];result[2]=XYZ_Flat[2];return}var zeroDecodeL=decodeL(0);var X_DST=zeroDecodeL;var X_SRC=decodeL(sourceBlackPoint[0]);var Y_DST=zeroDecodeL;var Y_SRC=decodeL(sourceBlackPoint[1]);var Z_DST=zeroDecodeL;var Z_SRC=decodeL(sourceBlackPoint[2]);var X_Scale=(1-X_DST)/(1-X_SRC);var X_Offset=1-X_Scale;var Y_Scale= +(1-Y_DST)/(1-Y_SRC);var Y_Offset=1-Y_Scale;var Z_Scale=(1-Z_DST)/(1-Z_SRC);var Z_Offset=1-Z_Scale;result[0]=XYZ_Flat[0]*X_Scale+X_Offset;result[1]=XYZ_Flat[1]*Y_Scale+Y_Offset;result[2]=XYZ_Flat[2]*Z_Scale+Z_Offset}function normalizeWhitePointToFlat(sourceWhitePoint,XYZ_In,result){if(sourceWhitePoint[0]===1&&sourceWhitePoint[2]===1){result[0]=XYZ_In[0];result[1]=XYZ_In[1];result[2]=XYZ_In[2];return}var LMS=result;matrixProduct(BRADFORD_SCALE_MATRIX,XYZ_In,LMS);var LMS_Flat=tempNormalizeMatrix;convertToFlat(sourceWhitePoint, +LMS,LMS_Flat);matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX,LMS_Flat,result)}function normalizeWhitePointToD65(sourceWhitePoint,XYZ_In,result){var LMS=result;matrixProduct(BRADFORD_SCALE_MATRIX,XYZ_In,LMS);var LMS_D65=tempNormalizeMatrix;convertToD65(sourceWhitePoint,LMS,LMS_D65);matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX,LMS_D65,result)}function convertToRgb(cs,src,srcOffset,dest,destOffset,scale){var A=adjustToRange(0,1,src[srcOffset]*scale);var B=adjustToRange(0,1,src[srcOffset+1]*scale);var C= +adjustToRange(0,1,src[srcOffset+2]*scale);var AGR=Math.pow(A,cs.GR);var BGG=Math.pow(B,cs.GG);var CGB=Math.pow(C,cs.GB);var X=cs.MXA*AGR+cs.MXB*BGG+cs.MXC*CGB;var Y=cs.MYA*AGR+cs.MYB*BGG+cs.MYC*CGB;var Z=cs.MZA*AGR+cs.MZB*BGG+cs.MZC*CGB;var XYZ=tempConvertMatrix1;XYZ[0]=X;XYZ[1]=Y;XYZ[2]=Z;var XYZ_Flat=tempConvertMatrix2;normalizeWhitePointToFlat(cs.whitePoint,XYZ,XYZ_Flat);var XYZ_Black=tempConvertMatrix1;compensateBlackPoint(cs.blackPoint,XYZ_Flat,XYZ_Black);var XYZ_D65=tempConvertMatrix2;normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, +XYZ_Black,XYZ_D65);var SRGB=tempConvertMatrix1;matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX,XYZ_D65,SRGB);var sR=sRGBTransferFunction(SRGB[0]);var sG=sRGBTransferFunction(SRGB[1]);var sB=sRGBTransferFunction(SRGB[2]);dest[destOffset]=Math.round(sR*255);dest[destOffset+1]=Math.round(sG*255);dest[destOffset+2]=Math.round(sB*255)}CalRGBCS.prototype={getRgb:function CalRGBCS_getRgb(src,srcOffset){var rgb=new Uint8Array(3);this.getRgbItem(src,srcOffset,rgb,0);return rgb},getRgbItem:function CalRGBCS_getRgbItem(src, +srcOffset,dest,destOffset){convertToRgb(this,src,srcOffset,dest,destOffset,1)},getRgbBuffer:function CalRGBCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var scale=1/((1<this.amax||this.bmin>this.bmax){info("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin= +-100;this.bmax=100}}function fn_g(x){if(x>=6/29)return x*x*x;else return 108/841*(x-4/29)}function decode(value,high1,low2,high2){return low2+value*(high2-low2)/high1}function convertToRgb(cs,src,srcOffset,maxVal,dest,destOffset){var Ls=src[srcOffset];var as=src[srcOffset+1];var bs=src[srcOffset+2];if(maxVal!==false){Ls=decode(Ls,maxVal,0,100);as=decode(as,maxVal,cs.amin,cs.amax);bs=decode(bs,maxVal,cs.bmin,cs.bmax)}as=as>cs.amax?cs.amax:ascs.bmax?cs.bmax:bs=1?255:Math.sqrt(r)*255|0;dest[destOffset+1]=g<=0?0:g>=1?255:Math.sqrt(g)*255|0;dest[destOffset+2]=b<=0?0:b>=1?255:Math.sqrt(b)*255|0}LabCS.prototype={getRgb:ColorSpace.prototype.getRgb, +getRgbItem:function LabCS_getRgbItem(src,srcOffset,dest,destOffset){convertToRgb(this,src,srcOffset,false,dest,destOffset)},getRgbBuffer:function LabCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var maxVal=(1<>5&255;padded[i++]=length>>13&255;padded[i++]=length>>21&255;padded[i++]=length>>>29&255;padded[i++]=0;padded[i++]=0;padded[i++]=0;var w=new Int32Array(16);for(i=0;i>>32-rotate)|0;a=tmp}h0=h0+a|0;h1=h1+b|0;h2=h2+c|0;h3=h3+d|0}return new Uint8Array([h0&255,h0>>8&255,h0>>16&255,h0>>>24&255,h1&255,h1>>8&255,h1>>16&255,h1>>>24&255,h2&255,h2>>8&255,h2>>16&255,h2>>>24&255,h3&255,h3>>8&255,h3>>16&255,h3>>>24&255])}return hash}();var Word64=function Word64Closure(){function Word64(highInteger,lowInteger){this.high=highInteger|0;this.low=lowInteger|0} +Word64.prototype={and:function Word64_and(word){this.high&=word.high;this.low&=word.low},xor:function Word64_xor(word){this.high^=word.high;this.low^=word.low},or:function Word64_or(word){this.high|=word.high;this.low|=word.low},shiftRight:function Word64_shiftRight(places){if(places>=32){this.low=this.high>>>places-32|0;this.high=0}else{this.low=this.low>>>places|this.high<<32-places;this.high=this.high>>>places|0}},shiftLeft:function Word64_shiftLeft(places){if(places>=32){this.high=this.low<>>32-places;this.low=this.low<>>places|high<<32-places;this.high=high>>>places|low<<32-places},not:function Word64_not(){this.high=~this.high;this.low=~this.low},add:function Word64_add(word){var lowAdd=(this.low>>>0)+(word.low>>>0);var highAdd=(this.high>>>0)+(word.high>>>0); +if(lowAdd>4294967295)highAdd+=1;this.low=lowAdd|0;this.high=highAdd|0},copyTo:function Word64_copyTo(bytes,offset){bytes[offset]=this.high>>>24&255;bytes[offset+1]=this.high>>16&255;bytes[offset+2]=this.high>>8&255;bytes[offset+3]=this.high&255;bytes[offset+4]=this.low>>>24&255;bytes[offset+5]=this.low>>16&255;bytes[offset+6]=this.low>>8&255;bytes[offset+7]=this.low&255},assign:function Word64_assign(word){this.high=word.high;this.low=word.low}};return Word64}();var calculateSHA256=function calculateSHA256Closure(){function rotr(x, +n){return x>>>n|x<<32-n}function ch(x,y,z){return x&y^~x&z}function maj(x,y,z){return x&y^x&z^y&z}function sigma(x){return rotr(x,2)^rotr(x,13)^rotr(x,22)}function sigmaPrime(x){return rotr(x,6)^rotr(x,11)^rotr(x,25)}function littleSigma(x){return rotr(x,7)^rotr(x,18)^x>>>3}function littleSigmaPrime(x){return rotr(x,17)^rotr(x,19)^x>>>10}var k=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103, +3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187, +3204031479,3329325298];function hash(data,offset,length){var h0=1779033703,h1=3144134277,h2=1013904242,h3=2773480762,h4=1359893119,h5=2600822924,h6=528734635,h7=1541459225;var paddedLength=Math.ceil((length+9)/64)*64;var padded=new Uint8Array(paddedLength);var i,j,n;for(i=0;i>>29&255;padded[i++]=length>>21&255;padded[i++]=length>>13&255;padded[i++]= +length>>5&255;padded[i++]=length<<3&255;var w=new Uint32Array(64);for(i=0;i>24&255,h0>>16&255,h0>>8&255,h0&255,h1>>24&255,h1>>16&255,h1>>8&255,h1&255,h2>>24&255,h2>>16&255,h2>>8&255,h2&255,h3>>24&255,h3>>16&255,h3>>8&255,h3&255,h4>>24&255,h4>>16&255,h4>>8&255,h4&255,h5>>24&255,h5>>16&255,h5>>8&255,h5&255,h6>>24&255,h6>>16&255,h6>>8&255,h6&255,h7>>24&255,h7>>16&255,h7>>8&255,h7&255])}return hash}();var calculateSHA512=function calculateSHA512Closure(){function ch(result,x,y,z,tmp){result.assign(x);result.and(y);tmp.assign(x);tmp.not(); +tmp.and(z);result.xor(tmp)}function maj(result,x,y,z,tmp){result.assign(x);result.and(y);tmp.assign(x);tmp.and(z);result.xor(tmp);tmp.assign(y);tmp.and(z);result.xor(tmp)}function sigma(result,x,tmp){result.assign(x);result.rotateRight(28);tmp.assign(x);tmp.rotateRight(34);result.xor(tmp);tmp.assign(x);tmp.rotateRight(39);result.xor(tmp)}function sigmaPrime(result,x,tmp){result.assign(x);result.rotateRight(14);tmp.assign(x);tmp.rotateRight(18);result.xor(tmp);tmp.assign(x);tmp.rotateRight(41);result.xor(tmp)} +function littleSigma(result,x,tmp){result.assign(x);result.rotateRight(1);tmp.assign(x);tmp.rotateRight(8);result.xor(tmp);tmp.assign(x);tmp.shiftRight(7);result.xor(tmp)}function littleSigmaPrime(result,x,tmp){result.assign(x);result.rotateRight(19);tmp.assign(x);tmp.rotateRight(61);result.xor(tmp);tmp.assign(x);tmp.shiftRight(6);result.xor(tmp)}var k=[new Word64(1116352408,3609767458),new Word64(1899447441,602891725),new Word64(3049323471,3964484399),new Word64(3921009573,2173295548),new Word64(961987163, +4081628472),new Word64(1508970993,3053834265),new Word64(2453635748,2937671579),new Word64(2870763221,3664609560),new Word64(3624381080,2734883394),new Word64(310598401,1164996542),new Word64(607225278,1323610764),new Word64(1426881987,3590304994),new Word64(1925078388,4068182383),new Word64(2162078206,991336113),new Word64(2614888103,633803317),new Word64(3248222580,3479774868),new Word64(3835390401,2666613458),new Word64(4022224774,944711139),new Word64(264347078,2341262773),new Word64(604807628, +2007800933),new Word64(770255983,1495990901),new Word64(1249150122,1856431235),new Word64(1555081692,3175218132),new Word64(1996064986,2198950837),new Word64(2554220882,3999719339),new Word64(2821834349,766784016),new Word64(2952996808,2566594879),new Word64(3210313671,3203337956),new Word64(3336571891,1034457026),new Word64(3584528711,2466948901),new Word64(113926993,3758326383),new Word64(338241895,168717936),new Word64(666307205,1188179964),new Word64(773529912,1546045734),new Word64(1294757372, +1522805485),new Word64(1396182291,2643833823),new Word64(1695183700,2343527390),new Word64(1986661051,1014477480),new Word64(2177026350,1206759142),new Word64(2456956037,344077627),new Word64(2730485921,1290863460),new Word64(2820302411,3158454273),new Word64(3259730800,3505952657),new Word64(3345764771,106217008),new Word64(3516065817,3606008344),new Word64(3600352804,1432725776),new Word64(4094571909,1467031594),new Word64(275423344,851169720),new Word64(430227734,3100823752),new Word64(506948616, +1363258195),new Word64(659060556,3750685593),new Word64(883997877,3785050280),new Word64(958139571,3318307427),new Word64(1322822218,3812723403),new Word64(1537002063,2003034995),new Word64(1747873779,3602036899),new Word64(1955562222,1575990012),new Word64(2024104815,1125592928),new Word64(2227730452,2716904306),new Word64(2361852424,442776044),new Word64(2428436474,593698344),new Word64(2756734187,3733110249),new Word64(3204031479,2999351573),new Word64(3329325298,3815920427),new Word64(3391569614, +3928383900),new Word64(3515267271,566280711),new Word64(3940187606,3454069534),new Word64(4118630271,4000239992),new Word64(116418474,1914138554),new Word64(174292421,2731055270),new Word64(289380356,3203993006),new Word64(460393269,320620315),new Word64(685471733,587496836),new Word64(852142971,1086792851),new Word64(1017036298,365543100),new Word64(1126000580,2618297676),new Word64(1288033470,3409855158),new Word64(1501505948,4234509866),new Word64(1607167915,987167468),new Word64(1816402316,1246189591)]; +function hash(data,offset,length,mode384){mode384=!!mode384;var h0,h1,h2,h3,h4,h5,h6,h7;if(!mode384){h0=new Word64(1779033703,4089235720);h1=new Word64(3144134277,2227873595);h2=new Word64(1013904242,4271175723);h3=new Word64(2773480762,1595750129);h4=new Word64(1359893119,2917565137);h5=new Word64(2600822924,725511199);h6=new Word64(528734635,4215389547);h7=new Word64(1541459225,327033209)}else{h0=new Word64(3418070365,3238371032);h1=new Word64(1654270250,914150663);h2=new Word64(2438529370,812702999); +h3=new Word64(355462360,4144912697);h4=new Word64(1731405415,4290775857);h5=new Word64(2394180231,1750603025);h6=new Word64(3675008525,1694076839);h7=new Word64(1203062813,3204075428)}var paddedLength=Math.ceil((length+17)/128)*128;var padded=new Uint8Array(paddedLength);var i,j,n;for(i=0;i>>29&255;padded[i++]=length>>21&255;padded[i++]=length>>13&255;padded[i++]=length>>5&255;padded[i++]=length<<3&255;var w=new Array(80);for(i=0;i<80;i++)w[i]=new Word64(0,0);var a=new Word64(0,0),b=new Word64(0,0),c=new Word64(0,0);var d=new Word64(0,0),e=new Word64(0,0),f=new Word64(0,0);var g=new Word64(0,0),h=new Word64(0,0);var t1=new Word64(0,0),t2=new Word64(0,0);var tmp1=new Word64(0,0),tmp2=new Word64(0,0),tmp3;for(i=0;i=1;--i){t=state[13];state[13]=state[9];state[9]=state[5];state[5]=state[1];state[1]=t;t=state[14];u=state[10];state[14]=state[6];state[10]=state[2];state[6]=t;state[2]=u;t=state[15];u=state[11];v=state[7];state[15]=state[3];state[11]=t;state[7]=u;state[3]=v;for(j=0;j<16;++j)state[j]=inv_s[state[j]];for(j=0,k=i*16;j<16;++j,++k)state[j]^=key[k];for(j= +0;j<16;j+=4){var s0=mix[state[j]],s1=mix[state[j+1]],s2=mix[state[j+2]],s3=mix[state[j+3]];t=s0^s1>>>8^s1<<24^s2>>>16^s2<<16^s3>>>24^s3<<8;state[j]=t>>>24&255;state[j+1]=t>>16&255;state[j+2]=t>>8&255;state[j+3]=t&255}}t=state[13];state[13]=state[9];state[9]=state[5];state[5]=state[1];state[1]=t;t=state[14];u=state[10];state[14]=state[6];state[10]=state[2];state[6]=t;state[2]=u;t=state[15];u=state[11];v=state[7];state[15]=state[3];state[11]=t;state[7]=u;state[3]=v;for(j=0;j<16;++j){state[j]=inv_s[state[j]]; +state[j]^=key[j]}return state}function encrypt128(input,key){var t,u,v,k;var state=new Uint8Array(16);state.set(input);for(j=0;j<16;++j)state[j]^=key[j];for(i=1;i<10;i++){for(j=0;j<16;++j)state[j]=s[state[j]];v=state[1];state[1]=state[5];state[5]=state[9];state[9]=state[13];state[13]=v;v=state[2];u=state[6];state[2]=state[10];state[6]=state[14];state[10]=v;state[14]=u;v=state[3];u=state[7];t=state[11];state[3]=state[15];state[7]=v;state[11]=u;state[15]=t;for(var j=0;j<16;j+=4){var s0=state[j+0],s1= +state[j+1];var s2=state[j+2],s3=state[j+3];t=s0^s1^s2^s3;state[j+0]^=t^mixCol[s0^s1];state[j+1]^=t^mixCol[s1^s2];state[j+2]^=t^mixCol[s2^s3];state[j+3]^=t^mixCol[s3^s0]}for(j=0,k=i*16;j<16;++j,++k)state[j]^=key[k]}for(j=0;j<16;++j)state[j]=s[state[j]];v=state[1];state[1]=state[5];state[5]=state[9];state[9]=state[13];state[13]=v;v=state[2];u=state[6];state[2]=state[10];state[6]=state[14];state[10]=v;state[14]=u;v=state[3];u=state[7];t=state[11];state[3]=state[15];state[7]=v;state[11]=u;state[15]=t; +for(j=0,k=160;j<16;++j,++k)state[j]^=key[k];return state}function AES128Cipher(key){this.key=expandKey128(key);this.buffer=new Uint8Array(16);this.bufferPosition=0}function decryptBlock2(data,finalize){var i,j,ii,sourceLength=data.length,buffer=this.buffer,bufferLength=this.bufferPosition,result=[],iv=this.iv;for(i=0;i=ii;--i)if(lastBlock[i]!==psLen){psLen=0;break}outputLength-=psLen;result[result.length-1]=lastBlock.subarray(0,16-psLen)}}var output=new Uint8Array(outputLength);for(i=0,j=0,ii=result.length;i=256)r=(r^27)&255}for(var n=0;n<4;++n){result[j]=t1^=result[j-32];j++;result[j]=t2^=result[j-32];j++;result[j]=t3^=result[j-32];j++;result[j]=t4^=result[j-32];j++}}return result}function decrypt256(input,key){var state=new Uint8Array(16);state.set(input);var i,j,k;var t,u,v;for(j=0,k=224;j<16;++j,++k)state[j]^=key[k];for(i=13;i>=1;--i){t= +state[13];state[13]=state[9];state[9]=state[5];state[5]=state[1];state[1]=t;t=state[14];u=state[10];state[14]=state[6];state[10]=state[2];state[6]=t;state[2]=u;t=state[15];u=state[11];v=state[7];state[15]=state[3];state[11]=t;state[7]=u;state[3]=v;for(j=0;j<16;++j)state[j]=inv_s[state[j]];for(j=0,k=i*16;j<16;++j,++k)state[j]^=key[k];for(j=0;j<16;j+=4){var s0=mix[state[j]],s1=mix[state[j+1]],s2=mix[state[j+2]],s3=mix[state[j+3]];t=s0^s1>>>8^s1<<24^s2>>>16^s2<<16^s3>>>24^s3<<8;state[j]=t>>>24&255;state[j+ +1]=t>>16&255;state[j+2]=t>>8&255;state[j+3]=t&255}}t=state[13];state[13]=state[9];state[9]=state[5];state[5]=state[1];state[1]=t;t=state[14];u=state[10];state[14]=state[6];state[10]=state[2];state[6]=t;state[2]=u;t=state[15];u=state[11];v=state[7];state[15]=state[3];state[11]=t;state[7]=u;state[3]=v;for(j=0;j<16;++j){state[j]=inv_s[state[j]];state[j]^=key[j]}return state}function encrypt256(input,key){var t,u,v,k;var state=new Uint8Array(16);state.set(input);for(j=0;j<16;++j)state[j]^=key[j];for(i= +1;i<14;i++){for(j=0;j<16;++j)state[j]=s[state[j]];v=state[1];state[1]=state[5];state[5]=state[9];state[9]=state[13];state[13]=v;v=state[2];u=state[6];state[2]=state[10];state[6]=state[14];state[10]=v;state[14]=u;v=state[3];u=state[7];t=state[11];state[3]=state[15];state[7]=v;state[11]=u;state[15]=t;for(var j=0;j<16;j+=4){var s0=state[j+0],s1=state[j+1];var s2=state[j+2],s3=state[j+3];t=s0^s1^s2^s3;state[j+0]^=t^mixCol[s0^s1];state[j+1]^=t^mixCol[s1^s2];state[j+2]^=t^mixCol[s2^s3];state[j+3]^=t^mixCol[s3^ +s0]}for(j=0,k=i*16;j<16;++j,++k)state[j]^=key[k]}for(j=0;j<16;++j)state[j]=s[state[j]];v=state[1];state[1]=state[5];state[5]=state[9];state[9]=state[13];state[13]=v;v=state[2];u=state[6];state[2]=state[10];state[6]=state[14];state[10]=v;state[14]=u;v=state[3];u=state[7];t=state[11];state[3]=state[15];state[7]=v;state[11]=u;state[15]=t;for(j=0,k=224;j<16;++j,++k)state[j]^=key[k];return state}function AES256Cipher(key){this.key=expandKey256(key);this.buffer=new Uint8Array(16);this.bufferPosition=0} +function decryptBlock2(data,finalize){var i,j,ii,sourceLength=data.length,buffer=this.buffer,bufferLength=this.bufferPosition,result=[],iv=this.iv;for(i=0;i=ii;--i)if(lastBlock[i]!==psLen){psLen=0;break}outputLength-=psLen;result[result.length-1]=lastBlock.subarray(0,16-psLen)}}var output=new Uint8Array(outputLength);for(i=0,j=0,ii=result.length;ii-32){var arrayLength=password.length+k.length+userBytes.length;var k1=new Uint8Array(arrayLength*64);var array=concatArrays(password,k);array=concatArrays(array,userBytes);for(var j=0,pos=0;j<64;j++,pos+=arrayLength)k1.set(array,pos);var cipher=new AES128Cipher(k.subarray(0,16));e=cipher.encrypt(k1,k.subarray(16,32));var remainder=0;for(var z=0;z<16;z++){remainder*=256%3;remainder%=3;remainder+=(e[z]>>> +0)%3;remainder%=3}if(remainder===0)k=calculateSHA256(e,0,e.length);else if(remainder===1)k=calculateSHA384(e,0,e.length);else if(remainder===2)k=calculateSHA512(e,0,e.length);i++}return k.subarray(0,32)}function PDF20(){}function compareByteArrays(array1,array2){if(array1.length!==array2.length)return false;for(var i=0;i>8&255;hashData[i++]=flags>>16&255;hashData[i++]=flags>>>24&255;for(j=0,n=fileId.length;j=4&&!encryptMetadata){hashData[i++]=255;hashData[i++]=255;hashData[i++]=255;hashData[i++]=255}var hash=calculateMD5(hashData,0,i);var keyLengthInBytes=keyLength>>3;if(revision>=3)for(j=0;j<50;++j)hash=calculateMD5(hash,0,keyLengthInBytes);var encryptionKey=hash.subarray(0,keyLengthInBytes);var cipher,checkData;if(revision>=3){for(i=0;i<32;++i)hashData[i]=defaultPasswordBytes[i]; +for(j=0,n=fileId.length;j>3;if(revision>=3)for(j=0;j<50;++j)hash=calculateMD5(hash,0,hash.length);var cipher,userPassword;if(revision>= +3){userPassword=ownerPassword;var derivedKey=new Uint8Array(keyLengthInBytes),k;for(j=19;j>=0;j--){for(k=0;k=4){this.cf=dict.get("CF");this.stmf=dict.get("StmF")||identityName;this.strf=dict.get("StrF")||identityName;this.eff=dict.get("EFF")||this.strf}}function buildObjectKey(num,gen,encryptionKey,isAes){var key=new Uint8Array(encryptionKey.length+9),i,n;for(i=0,n=encryptionKey.length;i>8&255;key[i++]=num>>16&255;key[i++]=gen&255;key[i++]=gen>>8&255;if(isAes){key[i++]= +115;key[i++]=65;key[i++]=108;key[i++]=84}var hash=calculateMD5(key,0,i);return hash.subarray(0,Math.min(encryptionKey.length+5,16))}function buildCipherConstructor(cf,name,num,gen,key){var cryptFilter=cf.get(name.name);var cfm;if(cryptFilter!==null&&cryptFilter!==undefined)cfm=cryptFilter.get("CFM");if(!cfm||cfm.name==="None")return function cipherTransformFactoryBuildCipherConstructorNone(){return new NullCipher};if("V2"===cfm.name)return function cipherTransformFactoryBuildCipherConstructorV2(){return new ARCFourCipher(buildObjectKey(num, +gen,key,false))};if("AESV2"===cfm.name)return function cipherTransformFactoryBuildCipherConstructorAESV2(){return new AES128Cipher(buildObjectKey(num,gen,key,true))};if("AESV3"===cfm.name)return function cipherTransformFactoryBuildCipherConstructorAESV3(){return new AES256Cipher(key)};error("Unknown crypto method")}CipherTransformFactory.prototype={createCipherTransform:function CipherTransformFactory_createCipherTransform(num,gen){if(this.algorithm===4||this.algorithm===5)return new CipherTransform(buildCipherConstructor(this.cf, +this.stmf,num,gen,this.encryptionKey),buildCipherConstructor(this.cf,this.strf,num,gen,this.encryptionKey));var key=buildObjectKey(num,gen,this.encryptionKey,false);var cipherConstructor=function buildCipherCipherConstructor(){return new ARCFourCipher(key)};return new CipherTransform(cipherConstructor,cipherConstructor)}};return CipherTransformFactory}();var PatternType={FUNCTION_BASED:1,AXIAL:2,RADIAL:3,FREE_FORM_MESH:4,LATTICE_FORM_MESH:5,COONS_PATCH_MESH:6,TENSOR_PATCH_MESH:7};var Pattern=function PatternClosure(){function Pattern(){error("should not call Pattern constructor")} +Pattern.prototype={getPattern:function Pattern_getPattern(ctx){error("Should not call Pattern.getStyle: "+ctx)}};Pattern.parseShading=function Pattern_parseShading(shading,matrix,xref,res){var dict=isStream(shading)?shading.dict:shading;var type=dict.get("ShadingType");switch(type){case PatternType.AXIAL:case PatternType.RADIAL:return new Shadings.RadialAxial(dict,matrix,xref,res);case PatternType.FREE_FORM_MESH:case PatternType.LATTICE_FORM_MESH:case PatternType.COONS_PATCH_MESH:case PatternType.TENSOR_PATCH_MESH:return new Shadings.Mesh(shading, +matrix,xref,res);default:UnsupportedManager.notify(UNSUPPORTED_FEATURES.shadingPattern);return new Shadings.Dummy}};return Pattern}();var Shadings={};Shadings.SMALL_NUMBER=.01;Shadings.RadialAxial=function RadialAxialClosure(){function RadialAxial(dict,matrix,xref,res){this.matrix=matrix;this.coordsArr=dict.get("Coords");this.shadingType=dict.get("ShadingType");this.type="Pattern";var cs=dict.get("ColorSpace","CS");cs=ColorSpace.parse(cs,xref,res);this.cs=cs;var t0=0,t1=1;if(dict.has("Domain")){var domainArr= +dict.get("Domain");t0=domainArr[0];t1=domainArr[1]}var extendStart=false,extendEnd=false;if(dict.has("Extend")){var extendArr=dict.get("Extend");extendStart=extendArr[0];extendEnd=extendArr[1]}if(this.shadingType===PatternType.RADIAL&&(!extendStart||!extendEnd)){var x1=this.coordsArr[0];var y1=this.coordsArr[1];var r1=this.coordsArr[2];var x2=this.coordsArr[3];var y2=this.coordsArr[4];var r2=this.coordsArr[5];var distance=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));if(r1<=r2+distance&&r2<=r1+distance)warn("Unsupported radial gradient.")}this.extendStart= +extendStart;this.extendEnd=extendEnd;var fnObj=dict.get("Function");var fn=PDFFunction.parseArray(xref,fnObj);var diff=t1-t0;var step=diff/10;var colorStops=this.colorStops=[];if(t0>=t1||step<=0){info("Bad shading domain.");return}var color=new Float32Array(cs.numComps),ratio=new Float32Array(1);var rgbColor;for(var i=t0;i<=t1;i+=step){ratio[0]=i;fn(ratio,0,color,0);rgbColor=cs.getRgb(color,0);var cssColor=Util.makeCssRgb(rgbColor);colorStops.push([(i-t0)/diff,cssColor])}var background="transparent"; +if(dict.has("Background")){rgbColor=cs.getRgb(dict.get("Background"),0);background=Util.makeCssRgb(rgbColor)}if(!extendStart){colorStops.unshift([0,background]);colorStops[1][0]+=Shadings.SMALL_NUMBER}if(!extendEnd){colorStops[colorStops.length-1][0]-=Shadings.SMALL_NUMBER;colorStops.push([1,background])}this.colorStops=colorStops}RadialAxial.prototype={getIR:function RadialAxial_getIR(){var coordsArr=this.coordsArr;var shadingType=this.shadingType;var type,p0,p1,r0,r1;if(shadingType===PatternType.AXIAL){p0= +[coordsArr[0],coordsArr[1]];p1=[coordsArr[2],coordsArr[3]];r0=null;r1=null;type="axial"}else if(shadingType===PatternType.RADIAL){p0=[coordsArr[0],coordsArr[1]];p1=[coordsArr[3],coordsArr[4]];r0=coordsArr[2];r1=coordsArr[5];type="radial"}else error("getPattern type unknown: "+shadingType);var matrix=this.matrix;if(matrix){p0=Util.applyTransform(p0,matrix);p1=Util.applyTransform(p1,matrix)}return["RadialAxial",type,this.colorStops,p0,p1,r0,r1]}};return RadialAxial}();Shadings.Mesh=function MeshClosure(){function MeshStreamReader(stream, +context){this.stream=stream;this.context=context;this.buffer=0;this.bufferLength=0;var numComps=context.numComps;this.tmpCompsBuf=new Float32Array(numComps);var csNumComps=context.colorSpace;this.tmpCsCompsBuf=context.colorFn?new Float32Array(csNumComps):this.tmpCompsBuf}MeshStreamReader.prototype={get hasData(){if(this.stream.end)return this.stream.pos0)return true;var nextByte=this.stream.getByte();if(nextByte<0)return false;this.buffer=nextByte;this.bufferLength= +8;return true},readBits:function MeshStreamReader_readBits(n){var buffer=this.buffer;var bufferLength=this.bufferLength;if(n===32){if(bufferLength===0)return(this.stream.getByte()<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte())>>>0;buffer=buffer<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte();var nextByte=this.stream.getByte();this.buffer=nextByte&(1<>bufferLength)>>>0}if(n===8&& +bufferLength===0)return this.stream.getByte();while(bufferLength>bufferLength},align:function MeshStreamReader_align(){this.buffer=0;this.bufferLength=0},readFlag:function MeshStreamReader_readFlag(){return this.readBits(this.context.bitsPerFlag)},readCoordinate:function MeshStreamReader_readCoordinate(){var bitsPerCoordinate=this.context.bitsPerCoordinate; +var xi=this.readBits(bitsPerCoordinate);var yi=this.readBits(bitsPerCoordinate);var decode=this.context.decode;var scale=bitsPerCoordinate<32?1/((1<x?x:minX;minY=minY>y?y:minY;maxX=maxX=2,"Invalid VerticesPerRow");decodeType5Shading(this,reader,verticesPerRow);break;case PatternType.COONS_PATCH_MESH:decodeType6Shading(this,reader);patchMesh=true;break;case PatternType.TENSOR_PATCH_MESH:decodeType7Shading(this,reader);patchMesh=true;break;default:error("Unsupported mesh type.");break}if(patchMesh){updateBounds(this);for(var i=0,ii=this.figures.length;iPDFJS.maxImageSize){warn("Image exceeded maximum allowed size and was removed.");return}var imageMask=dict.get("ImageMask","IM")||false;var imgData,args;if(imageMask){var width=dict.get("Width","W");var height=dict.get("Height","H");var bitStrideLength=width+7>>3;var imgArray=image.getBytes(bitStrideLength* +height);var decode=dict.get("Decode","D");var inverseDecode=!!decode&&decode[0]>0;imgData=PDFImage.createMask(imgArray,width,height,image instanceof DecodeStream,inverseDecode);imgData.cached=true;args=[imgData];operatorList.addOp(OPS.paintImageMaskXObject,args);if(cacheKey){cache.key=cacheKey;cache.fn=OPS.paintImageMaskXObject;cache.args=args}return}var softMask=dict.get("SMask","SM")||false;var mask=dict.get("Mask")||false;var SMALL_IMAGE_DIMENSIONS=200;if(inline&&!softMask&&!mask&&!(image instanceof +JpegStream)&&w+h=0)operatorList.addOp(OPS.setGState,[gStateObj])})},loadFont:function PartialEvaluator_loadFont(fontName,font,xref,resources){function errorFont(){return Promise.resolve(new TranslatedFont("g_font_error",new ErrorFont("Font "+fontName+" is not available"),font))}var fontRef;if(font){assert(isRef(font));fontRef=font}else{var fontRes=resources.get("Font");if(fontRes)fontRef=fontRes.getRaw(fontName); +else{warn("fontRes not available");return errorFont()}}if(!fontRef){warn("fontRef not available");return errorFont()}if(this.fontCache.has(fontRef))return this.fontCache.get(fontRef);font=xref.fetchIfRef(fontRef);if(!isDict(font))return errorFont();if(font.translated)return font.translated;var fontCapability=createPromiseCapability();var preEvaluatedFont=this.preEvaluateFont(font,xref);var descriptor=preEvaluatedFont.descriptor;var fontID=fontRef.num+"_"+fontRef.gen;if(isDict(descriptor)){if(!descriptor.fontAliases)descriptor.fontAliases= +Object.create(null);var fontAliases=descriptor.fontAliases;var hash=preEvaluatedFont.hash;if(fontAliases[hash]){var aliasFontRef=fontAliases[hash].aliasRef;if(aliasFontRef&&this.fontCache.has(aliasFontRef)){this.fontCache.putAlias(fontRef,aliasFontRef);return this.fontCache.get(fontRef)}}if(!fontAliases[hash])fontAliases[hash]={fontID:Font.getFontID()};fontAliases[hash].aliasRef=fontRef;fontID=fontAliases[hash].fontID}var fontRefIsDict=isDict(fontRef);if(!fontRefIsDict)this.fontCache.put(fontRef, +fontCapability.promise);font.loadedName="g_font_"+(fontRefIsDict?fontName.replace(/\W/g,""):fontID);font.translated=fontCapability.promise;var translatedPromise;try{translatedPromise=Promise.resolve(this.translateFont(preEvaluatedFont,xref))}catch(e){translatedPromise=Promise.reject(e)}translatedPromise.then(function(translatedFont){if(translatedFont.fontType!==undefined){var xrefFontStats=xref.stats.fontTypes;xrefFontStats[translatedFont.fontType]=true}fontCapability.resolve(new TranslatedFont(font.loadedName, +translatedFont,font))},function(reason){UnsupportedManager.notify(UNSUPPORTED_FEATURES.font);try{var descriptor=preEvaluatedFont.descriptor;var fontFile3=descriptor&&descriptor.get("FontFile3");var subtype=fontFile3&&fontFile3.get("Subtype");var fontType=getFontType(preEvaluatedFont.type,subtype&&subtype.name);var xrefFontStats=xref.stats.fontTypes;xrefFontStats[fontType]=true}catch(ex){}fontCapability.resolve(new TranslatedFont(font.loadedName,new ErrorFont(reason instanceof Error?reason.message: +reason),font))});return fontCapability.promise},buildPath:function PartialEvaluator_buildPath(operatorList,fn,args){var lastIndex=operatorList.length-1;if(!args)args=[];if(lastIndex<0||operatorList.fnArray[lastIndex]!==OPS.constructPath)operatorList.addOp(OPS.constructPath,[[fn],args]);else{var opArgs=operatorList.argsArray[lastIndex];opArgs[0].push(fn);Array.prototype.push.apply(opArgs[1],args)}},handleColorN:function PartialEvaluator_handleColorN(operatorList,fn,args,cs,patterns,resources,xref){var patternName= +args[args.length-1];var pattern;if(isName(patternName)&&(pattern=patterns.get(patternName.name))){var dict=isStream(pattern)?pattern.dict:pattern;var typeNum=dict.get("PatternType");if(typeNum===TILING_PATTERN){var color=cs.base?cs.base.getRgb(args,0):null;return this.handleTilingType(fn,color,resources,pattern,dict,operatorList)}else if(typeNum===SHADING_PATTERN){var shading=dict.get("Shading");var matrix=dict.get("Matrix");pattern=Pattern.parseShading(shading,matrix,xref,resources);operatorList.addOp(fn, +pattern.getIR());return Promise.resolve()}else return Promise.reject("Unknown PatternType: "+typeNum)}operatorList.addOp(fn,args);return Promise.resolve()},getOperatorList:function PartialEvaluator_getOperatorList(stream,resources,operatorList,initialState){var self=this;var xref=this.xref;var imageCache={};assert(operatorList);resources=resources||Dict.empty;var xobjs=resources.get("XObject")||Dict.empty;var patterns=resources.get("Pattern")||Dict.empty;var stateManager=new StateManager(initialState|| +new EvalState);var preprocessor=new EvaluatorPreprocessor(stream,xref,stateManager);var timeSlotManager=new TimeSlotManager;return new Promise(function next(resolve,reject){timeSlotManager.reset();var stop,operation={},i,ii,cs;while(!(stop=timeSlotManager.check())){operation.args=null;if(!preprocessor.read(operation))break;var args=operation.args;var fn=operation.fn;switch(fn|0){case OPS.paintXObject:if(args[0].code)break;var name=args[0].name;if(imageCache.key===name){operatorList.addOp(imageCache.fn, +imageCache.args);args=null;continue}var xobj=xobjs.get(name);if(xobj){assert(isStream(xobj),"XObject should be a stream");var type=xobj.dict.get("Subtype");assert(isName(type),"XObject should have a Name subtype");if(type.name==="Form"){stateManager.save();return self.buildFormXObject(resources,xobj,null,operatorList,stateManager.state.clone()).then(function(){stateManager.restore();next(resolve,reject)},reject)}else if(type.name==="Image"){self.buildPaintImageXObject(resources,xobj,false,operatorList, +name,imageCache);args=null;continue}else if(type.name==="PS"){info("Ignored XObject subtype PS");continue}else error("Unhandled XObject subtype "+type.name)}break;case OPS.setFont:var fontSize=args[1];return self.handleSetFont(resources,args,null,operatorList,stateManager.state).then(function(loadedName){operatorList.addDependency(loadedName);operatorList.addOp(OPS.setFont,[loadedName,fontSize]);next(resolve,reject)},reject);case OPS.endInlineImage:var cacheKey=args[0].cacheKey;if(cacheKey&&imageCache.key=== +cacheKey){operatorList.addOp(imageCache.fn,imageCache.args);args=null;continue}self.buildPaintImageXObject(resources,args[0],true,operatorList,cacheKey,imageCache);args=null;continue;case OPS.showText:args[0]=self.handleText(args[0],stateManager.state);break;case OPS.showSpacedText:var arr=args[0];var combinedGlyphs=[];var arrLength=arr.length;for(i=0;i0){var fakeSpaces=-items[j]/textState.font.spaceWidth;if(fakeSpaces>MULTI_SPACE_FACTOR){fakeSpaces=Math.round(fakeSpaces);while(fakeSpaces--)textChunk.str.push(" ")}else if(fakeSpaces>SPACE_FACTOR)textChunk.str.push(" ")}}bidiTexts.push(runBidi(textChunk));break;case OPS.showText:bidiTexts.push(runBidi(buildTextGeometry(args[0]))); +break;case OPS.nextLineShowText:textState.carriageReturn();bidiTexts.push(runBidi(buildTextGeometry(args[0])));break;case OPS.nextLineSetSpacingShowText:textState.wordSpacing=args[0];textState.charSpacing=args[1];textState.carriageReturn();bidiTexts.push(runBidi(buildTextGeometry(args[2])));break;case OPS.paintXObject:if(args[0].code)break;if(!xobjs)xobjs=resources.get("XObject")||Dict.empty;var name=args[0].name;if(xobjsCache.key===name){if(xobjsCache.texts){Util.appendToArray(bidiTexts,xobjsCache.texts.items); +Util.extendObj(textContent.styles,xobjsCache.texts.styles)}break}var xobj=xobjs.get(name);if(!xobj)break;assert(isStream(xobj),"XObject should be a stream");var type=xobj.dict.get("Subtype");assert(isName(type),"XObject should have a Name subtype");if("Form"!==type.name){xobjsCache.key=name;xobjsCache.texts=null;break}stateManager.save();var matrix=xobj.dict.get("Matrix");if(isArray(matrix)&&matrix.length===6)stateManager.transform(matrix);return self.getTextContent(xobj,xobj.dict.get("Resources")|| +resources,stateManager).then(function(formTextContent){Util.appendToArray(bidiTexts,formTextContent.items);Util.extendObj(textContent.styles,formTextContent.styles);stateManager.restore();xobjsCache.key=name;xobjsCache.texts=formTextContent;next(resolve,reject)},reject);case OPS.setGState:var dictName=args[0];var extGState=resources.get("ExtGState");if(!isDict(extGState)||!extGState.has(dictName.name))break;var gsStateMap=extGState.get(dictName.name);var gsStateFont=null;for(var key in gsStateMap)if(key=== +"Font"){assert(!gsStateFont);gsStateFont=gsStateMap[key]}if(gsStateFont){textState.fontSize=gsStateFont[1];return handleSetFont(gsStateFont[0]).then(function(){next(resolve,reject)},reject)}break}}if(stop){deferred.then(function(){next(resolve,reject)});return}resolve(textContent)})},extractDataStructures:function partialEvaluatorExtractDataStructures(dict,baseDict,xref,properties){var toUnicode=dict.get("ToUnicode")||baseDict.get("ToUnicode");if(toUnicode)properties.toUnicode=this.readToUnicode(toUnicode); +if(properties.composite){var cidSystemInfo=dict.get("CIDSystemInfo");if(isDict(cidSystemInfo))properties.cidSystemInfo={registry:cidSystemInfo.get("Registry"),ordering:cidSystemInfo.get("Ordering"),supplement:cidSystemInfo.get("Supplement")};var cidToGidMap=dict.get("CIDToGIDMap");if(isStream(cidToGidMap))properties.cidToGidMap=this.readCidToGidMap(cidToGidMap)}var differences=[];var baseEncodingName=null;var encoding;if(dict.has("Encoding")){encoding=dict.get("Encoding");if(isDict(encoding)){baseEncodingName= +encoding.get("BaseEncoding");baseEncodingName=isName(baseEncodingName)?baseEncodingName.name:null;if(encoding.has("Differences")){var diffEncoding=encoding.get("Differences");var index=0;for(var j=0,jj=diffEncoding.length;j>1;result[code]=glyphID}return result},extractWidths:function PartialEvaluator_extractWidths(dict,xref,descriptor,properties){var glyphsWidths=[];var defaultWidth=0;var glyphsVMetrics=[];var defaultVMetrics;var i,ii,j,jj,start,code,widths;if(properties.composite){defaultWidth=dict.get("DW")||1E3;widths=dict.get("W");if(widths)for(i=0,ii=widths.length;i=CHUNK_SIZE)this.flush();else if(this.fnArray.length>=CHUNK_SIZE_ABOUT&&(fn===OPS.restore||fn===OPS.endText))this.flush()},addDependency:function(dependency){if(dependency in this.dependencies)return;this.dependencies[dependency]=true;this.addOp(OPS.dependency,[dependency])},addDependencies:function(dependencies){for(var key in dependencies)this.addDependency(key)}, +addOpList:function(opList){Util.extendObj(this.dependencies,opList.dependencies);for(var i=0,ii=opList.length;inumArgs){nonProcessedArgs.push(args.shift());argsLength--}while(argsLengthnumArgs)info("Command "+fn+": expected [0,"+numArgs+"] args, but received "+argsLength+" args");this.preprocessCommand(fn, +args);operation.fn=fn;operation.args=args;return true}else{if(isEOF(obj))return false;if(obj!==null){if(!args)args=[];args.push(obj instanceof Dict?obj.getAll():obj);assert(args.length<=33,"Too many arguments")}}}},preprocessCommand:function EvaluatorPreprocessor_preprocessCommand(fn,args){switch(fn|0){case OPS.save:this.stateManager.save();break;case OPS.restore:this.stateManager.restore();break;case OPS.transform:this.stateManager.transform(args);break}}};return EvaluatorPreprocessor}();var QueueOptimizer= +function QueueOptimizerClosure(){function addState(parentState,pattern,fn){var state=parentState;for(var i=0,ii=pattern.length-1;iMAX_WIDTH){maxX=Math.max(maxX,currentX);currentY+=maxLineHeight+2*IMAGE_PADDING;currentX=0;maxLineHeight=0}map.push({transform:transform,x:currentX,y:currentY,w:img.width,h:img.height});currentX+=img.width+2*IMAGE_PADDING;maxLineHeight=Math.max(maxLineHeight,img.height)}var imgWidth=Math.max(maxX,currentX)+IMAGE_PADDING;var imgHeight=currentY+maxLineHeight+IMAGE_PADDING;var imgData=new Uint8Array(imgWidth*imgHeight*4);var imgRowSize= +imgWidth<<2;for(q=0;q=0){data[offset-4]=data[offset];data[offset-3]=data[offset+1];data[offset- +2]=data[offset+2];data[offset-1]=data[offset+3];data[offset+rowSize]=data[offset+rowSize-4];data[offset+rowSize+1]=data[offset+rowSize-3];data[offset+rowSize+2]=data[offset+rowSize-2];data[offset+rowSize+3]=data[offset+rowSize-1];offset-=imgRowSize}}fnArray.splice(iFirstSave,count*4,OPS.paintInlineImageXObjectGroup);argsArray.splice(iFirstSave,count*4,[{width:imgWidth,height:imgHeight,kind:ImageKind.RGBA_32BPP,data:imgData},map]);return iFirstSave+1});addState(InitialState,[OPS.save,OPS.transform, +OPS.paintImageMaskXObject,OPS.restore],function foundImageMaskGroup(context){var MIN_IMAGES_IN_MASKS_BLOCK=10;var MAX_IMAGES_IN_MASKS_BLOCK=100;var MAX_SAME_IMAGES_IN_MASKS_BLOCK=1E3;var fnArray=context.fnArray,argsArray=context.argsArray;var curr=context.iCurr;var iFirstSave=curr-3;var iFirstTransform=curr-2;var iFirstPIMXO=curr-1;var i=iFirstSave+4;var ii=fnArray.length;while(i+3=4&& +fnArray[iFirstBeginText-4]===fnArray[iFirstSetFont]&&fnArray[iFirstBeginText-3]===fnArray[iFirstSetTextMatrix]&&fnArray[iFirstBeginText-2]===fnArray[iFirstShowText]&&fnArray[iFirstBeginText-1]===fnArray[iFirstEndText]&&argsArray[iFirstBeginText-4][0]===firstSetFontArg0&&argsArray[iFirstBeginText-4][1]===firstSetFontArg1){count++;iFirst-=5}var iEndText=iFirst+4;for(var q=1;q>>0;var codespaceRange=codespaceRanges[n];for(var k=0,kk=codespaceRange.length;k=low&&c<=high){out.charcode=c;out.length=n+1;return}}}out.charcode=0;out.length=1}};return CMap}();var IdentityCMap=function IdentityCMapClosure(){function IdentityCMap(vertical,n){CMap.call(this);this.vertical=vertical;this.addCodespaceRange(n,0,65535)}Util.inherit(IdentityCMap,CMap,{});IdentityCMap.prototype= +{addCodespaceRange:CMap.prototype.addCodespaceRange,mapCidRange:function(low,high,dstLow){error("should not call mapCidRange")},mapBfRange:function(low,high,dstLow){error("should not call mapBfRange")},mapBfRangeToArray:function(low,high,array){error("should not call mapBfRangeToArray")},mapOne:function(src,dst){error("should not call mapCidOne")},lookup:function(code){return isInt(code)&&code<=65535?code:undefined},contains:function(code){return isInt(code)&&code<=65535},forEach:function(callback){for(var i= +0;i<=65535;i++)callback(i,i)},charCodeOf:function(value){return isInt(value)&&value<=65535?value:-1},getMap:function(){var map=new Array(65536);for(var i=0;i<=65535;i++)map[i]=i;return map},readCharCode:CMap.prototype.readCharCode};return IdentityCMap}();var BinaryCMapReader=function BinaryCMapReaderClosure(){function fetchBinaryData(url){var nonBinaryRequest=PDFJS.disableWorker;var request=new XMLHttpRequest;request.open("GET",url,false);if(!nonBinaryRequest)try{request.responseType="arraybuffer"; +nonBinaryRequest=request.responseType!=="arraybuffer"}catch(e){nonBinaryRequest=true}if(nonBinaryRequest&&request.overrideMimeType)request.overrideMimeType("text/plain; charset=x-user-defined");request.send(null);if(nonBinaryRequest?!request.responseText:!request.response)error("Unable to get binary cMap at: "+url);if(nonBinaryRequest){var data=Array.prototype.map.call(request.responseText,function(ch){return ch.charCodeAt(0)&255});return new Uint8Array(data)}return new Uint8Array(request.response)} +function hexToInt(a,size){var n=0;for(var i=0;i<=size;i++)n=n<<8|a[i];return n>>>0}function hexToStr(a,size){if(size===1)return String.fromCharCode(a[0],a[1]);if(size===3)return String.fromCharCode(a[0],a[1],a[2],a[3]);return String.fromCharCode.apply(null,a.subarray(0,size+1))}function addHex(a,b,size){var c=0;for(var i=size;i>=0;i--){c+=a[i]+b[i];a[i]=c&255;c>>=8}}function incHex(a,size){var c=1;for(var i=size;i>=0&&c>0;i--){c+=a[i];a[i]=c&255;c>>=8}}var MAX_NUM_SIZE=16;var MAX_ENCODED_NUM_SIZE= +19;function BinaryCMapStream(data){this.buffer=data;this.pos=0;this.end=data.length;this.tmpBuf=new Uint8Array(MAX_ENCODED_NUM_SIZE)}BinaryCMapStream.prototype={readByte:function(){if(this.pos>=this.end)return-1;return this.buffer[this.pos++]},readNumber:function(){var n=0;var last;do{var b=this.readByte();if(b<0)error("unexpected EOF in bcmap");last=!(b&128);n=n<<7|b&127}while(!last);return n},readSigned:function(){var n=this.readNumber();return n&1?~(n>>>1):n>>>1},readHex:function(num,size){num.set(this.buffer.subarray(this.pos, +this.pos+size+1));this.pos+=size+1},readHexNumber:function(num,size){var last;var stack=this.tmpBuf,sp=0;do{var b=this.readByte();if(b<0)error("unexpected EOF in bcmap");last=!(b&128);stack[sp++]=b&127}while(!last);var i=size,buffer=0,bufferSize=0;while(i>=0){while(bufferSize<8&&stack.length>0){buffer=stack[--sp]<>=8;bufferSize-=8}},readHexSigned:function(num,size){this.readHexNumber(num,size);var sign=num[size]&1?255:0;var c=0;for(var i= +0;i<=size;i++){c=(c&1)<<8|num[i];num[i]=c>>1^sign}},readString:function(){var len=this.readNumber();var s="";for(var i=0;i=0){var type=b>>5;if(type===7){switch(b&31){case 0:stream.readString();break;case 1:useCMap=stream.readString();break}continue}var sequence=!!(b&16);var dataSize=b&15;assert(dataSize+1<=MAX_NUM_SIZE);var ucs2DataSize=1;var subitemsCount=stream.readNumber();var i;switch(type){case 0:stream.readHex(start,dataSize);stream.readHexNumber(end,dataSize);addHex(end,start,dataSize);cMap.addCodespaceRange(dataSize+1,hexToInt(start, +dataSize),hexToInt(end,dataSize));for(i=1;i>>0}function expectString(obj){if(!isString(obj))error("Malformed CMap: expected string.")}function expectInt(obj){if(!isInt(obj))error("Malformed CMap: expected int.")}function parseBfChar(cMap,lexer){while(true){var obj= +lexer.getObj();if(isEOF(obj))break;if(isCmd(obj,"endbfchar"))return;expectString(obj);var src=strToInt(obj);obj=lexer.getObj();expectString(obj);var dst=obj;cMap.mapOne(src,dst)}}function parseBfRange(cMap,lexer){while(true){var obj=lexer.getObj();if(isEOF(obj))break;if(isCmd(obj,"endbfrange"))return;expectString(obj);var low=strToInt(obj);obj=lexer.getObj();expectString(obj);var high=strToInt(obj);obj=lexer.getObj();if(isInt(obj)||isString(obj)){var dstLow=isInt(obj)?String.fromCharCode(obj):obj; +cMap.mapBfRange(low,high,dstLow)}else if(isCmd(obj,"[")){obj=lexer.getObj();var array=[];while(!isCmd(obj,"]")&&!isEOF(obj)){array.push(obj);obj=lexer.getObj()}cMap.mapBfRangeToArray(low,high,array)}else break}error("Invalid bf range.")}function parseCidChar(cMap,lexer){while(true){var obj=lexer.getObj();if(isEOF(obj))break;if(isCmd(obj,"endcidchar"))return;expectString(obj);var src=strToInt(obj);obj=lexer.getObj();expectInt(obj);var dst=obj;cMap.mapOne(src,dst)}}function parseCidRange(cMap,lexer){while(true){var obj= +lexer.getObj();if(isEOF(obj))break;if(isCmd(obj,"endcidrange"))return;expectString(obj);var low=strToInt(obj);obj=lexer.getObj();expectString(obj);var high=strToInt(obj);obj=lexer.getObj();expectInt(obj);var dstLow=obj;cMap.mapCidRange(low,high,dstLow)}}function parseCodespaceRange(cMap,lexer){while(true){var obj=lexer.getObj();if(isEOF(obj))break;if(isCmd(obj,"endcodespacerange"))return;if(!isString(obj))break;var low=strToInt(obj);obj=lexer.getObj();if(!isString(obj))break;var high=strToInt(obj); +cMap.addCodespaceRange(obj.length,low,high)}error("Invalid codespace range.")}function parseWMode(cMap,lexer){var obj=lexer.getObj();if(isInt(obj))cMap.vertical=!!obj}function parseCMap(cMap,lexer,builtInCMapParams,useCMap){var previous;var embededUseCMap;objLoop:while(true){var obj=lexer.getObj();if(isEOF(obj))break;else if(isName(obj)){if(obj.name==="WMode")parseWMode(cMap,lexer);previous=obj}else if(isCmd(obj))switch(obj.cmd){case "endcmap":break objLoop;case "usecmap":if(isName(previous))embededUseCMap= +previous.name;break;case "begincodespacerange":parseCodespaceRange(cMap,lexer);break;case "beginbfchar":parseBfChar(cMap,lexer);break;case "begincidchar":parseCidChar(cMap,lexer);break;case "beginbfrange":parseBfRange(cMap,lexer);break;case "begincidrange":parseCidRange(cMap,lexer);break}}if(!useCMap&&embededUseCMap)useCMap=embededUseCMap;if(useCMap)extendCMap(cMap,builtInCMapParams,useCMap)}function extendCMap(cMap,builtInCMapParams,useCMap){cMap.useCMap=createBuiltInCMap(useCMap,builtInCMapParams); +if(cMap.numCodespaceRanges===0){var useCodespaceRanges=cMap.useCMap.codespaceRanges;for(var i=0;i=65520&&code<=65535)return 0;else if(code>=62976&&code<=63743)return SpecialPUASymbols[code]||code;return code} +var UnicodeRanges=[{"begin":0,"end":127},{"begin":128,"end":255},{"begin":256,"end":383},{"begin":384,"end":591},{"begin":592,"end":687},{"begin":688,"end":767},{"begin":768,"end":879},{"begin":880,"end":1023},{"begin":11392,"end":11519},{"begin":1024,"end":1279},{"begin":1328,"end":1423},{"begin":1424,"end":1535},{"begin":42240,"end":42559},{"begin":1536,"end":1791},{"begin":1984,"end":2047},{"begin":2304,"end":2431},{"begin":2432,"end":2559},{"begin":2560,"end":2687},{"begin":2688,"end":2815},{"begin":2816, +"end":2943},{"begin":2944,"end":3071},{"begin":3072,"end":3199},{"begin":3200,"end":3327},{"begin":3328,"end":3455},{"begin":3584,"end":3711},{"begin":3712,"end":3839},{"begin":4256,"end":4351},{"begin":6912,"end":7039},{"begin":4352,"end":4607},{"begin":7680,"end":7935},{"begin":7936,"end":8191},{"begin":8192,"end":8303},{"begin":8304,"end":8351},{"begin":8352,"end":8399},{"begin":8400,"end":8447},{"begin":8448,"end":8527},{"begin":8528,"end":8591},{"begin":8592,"end":8703},{"begin":8704,"end":8959}, +{"begin":8960,"end":9215},{"begin":9216,"end":9279},{"begin":9280,"end":9311},{"begin":9312,"end":9471},{"begin":9472,"end":9599},{"begin":9600,"end":9631},{"begin":9632,"end":9727},{"begin":9728,"end":9983},{"begin":9984,"end":10175},{"begin":12288,"end":12351},{"begin":12352,"end":12447},{"begin":12448,"end":12543},{"begin":12544,"end":12591},{"begin":12592,"end":12687},{"begin":43072,"end":43135},{"begin":12800,"end":13055},{"begin":13056,"end":13311},{"begin":44032,"end":55215},{"begin":55296, +"end":57343},{"begin":67840,"end":67871},{"begin":19968,"end":40959},{"begin":57344,"end":63743},{"begin":12736,"end":12783},{"begin":64256,"end":64335},{"begin":64336,"end":65023},{"begin":65056,"end":65071},{"begin":65040,"end":65055},{"begin":65104,"end":65135},{"begin":65136,"end":65279},{"begin":65280,"end":65519},{"begin":65520,"end":65535},{"begin":3840,"end":4095},{"begin":1792,"end":1871},{"begin":1920,"end":1983},{"begin":3456,"end":3583},{"begin":4096,"end":4255},{"begin":4608,"end":4991}, +{"begin":5024,"end":5119},{"begin":5120,"end":5759},{"begin":5760,"end":5791},{"begin":5792,"end":5887},{"begin":6016,"end":6143},{"begin":6144,"end":6319},{"begin":10240,"end":10495},{"begin":40960,"end":42127},{"begin":5888,"end":5919},{"begin":66304,"end":66351},{"begin":66352,"end":66383},{"begin":66560,"end":66639},{"begin":118784,"end":119039},{"begin":119808,"end":120831},{"begin":1044480,"end":1048573},{"begin":65024,"end":65039},{"begin":917504,"end":917631},{"begin":6400,"end":6479},{"begin":6480, +"end":6527},{"begin":6528,"end":6623},{"begin":6656,"end":6687},{"begin":11264,"end":11359},{"begin":11568,"end":11647},{"begin":19904,"end":19967},{"begin":43008,"end":43055},{"begin":65536,"end":65663},{"begin":65856,"end":65935},{"begin":66432,"end":66463},{"begin":66464,"end":66527},{"begin":66640,"end":66687},{"begin":66688,"end":66735},{"begin":67584,"end":67647},{"begin":68096,"end":68191},{"begin":119552,"end":119647},{"begin":73728,"end":74751},{"begin":119648,"end":119679},{"begin":7040, +"end":7103},{"begin":7168,"end":7247},{"begin":7248,"end":7295},{"begin":43136,"end":43231},{"begin":43264,"end":43311},{"begin":43312,"end":43359},{"begin":43520,"end":43615},{"begin":65936,"end":65999},{"begin":66E3,"end":66047},{"begin":66208,"end":66271},{"begin":127024,"end":127135}];var MacStandardGlyphOrdering=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen", +"period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla", +"Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal", +"greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl", +"periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior", +"threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function getUnicodeRangeFor(value){for(var i=0,ii=UnicodeRanges.length;i=range.begin&&value=range.begin&&value=range.begin&&value=0;ii--)s+=chars[ii];return s}function adjustWidths(properties){if(properties.fontMatrix[0]===FONT_IDENTITY_MATRIX[0])return;var scale=.001/properties.fontMatrix[0];var glyphsWidths=properties.widths;for(var glyph in glyphsWidths)glyphsWidths[glyph]*=scale;properties.defaultWidth*=scale}function getFontType(type,subtype){switch(type){case "Type1":return subtype=== +"Type1C"?FontType.TYPE1C:FontType.TYPE1;case "CIDFontType0":return subtype==="CIDFontType0C"?FontType.CIDFONTTYPE0C:FontType.CIDFONTTYPE0;case "OpenType":return FontType.OPENTYPE;case "TrueType":return FontType.TRUETYPE;case "CIDFontType2":return FontType.CIDFONTTYPE2;case "MMType1":return FontType.MMTYPE1;case "Type0":return FontType.TYPE0;default:return FontType.UNKNOWN}}var Glyph=function GlyphClosure(){function Glyph(fontChar,unicode,accent,width,vmetric,operatorListId){this.fontChar=fontChar; +this.unicode=unicode;this.accent=accent;this.width=width;this.vmetric=vmetric;this.operatorListId=operatorListId}Glyph.prototype.matchesForCache=function(fontChar,unicode,accent,width,vmetric,operatorListId){return this.fontChar===fontChar&&this.unicode===unicode&&this.accent===accent&&this.width===width&&this.vmetric===vmetric&&this.operatorListId===operatorListId};return Glyph}();var ToUnicodeMap=function ToUnicodeMapClosure(){function ToUnicodeMap(cmap){this._map=cmap}ToUnicodeMap.prototype={get length(){return this._map.length}, +forEach:function(callback){for(var charCode in this._map)callback(charCode,this._map[charCode].charCodeAt(0))},get:function(i){return this._map[i]},charCodeOf:function(v){return this._map.indexOf(v)}};return ToUnicodeMap}();var IdentityToUnicodeMap=function IdentityToUnicodeMapClosure(){function IdentityToUnicodeMap(firstChar,lastChar){this.firstChar=firstChar;this.lastChar=lastChar}IdentityToUnicodeMap.prototype={get length(){error("should not access .length")},forEach:function(callback){for(var i= +this.firstChar,ii=this.lastChar;i<=ii;i++)callback(i,i)},get:function(i){if(this.firstChar<=i&&i<=this.lastChar)return String.fromCharCode(i);return undefined},charCodeOf:function(v){error("should not call .charCodeOf")}};return IdentityToUnicodeMap}();var OpenTypeFileBuilder=function OpenTypeFileBuilderClosure(){function writeInt16(dest,offset,num){dest[offset]=num>>8&255;dest[offset+1]=num&255}function writeInt32(dest,offset,num){dest[offset]=num>>24&255;dest[offset+1]=num>>16&255;dest[offset+2]= +num>>8&255;dest[offset+3]=num&255}function writeData(dest,offset,data){var i,ii;if(data instanceof Uint8Array)dest.set(data,offset);else if(typeof data==="string")for(i=0,ii=data.length;imaxPower2){maxPower2<<=1;log2++}var searchRange=maxPower2*entrySize;return{range:searchRange,entry:log2,rangeShift:entrySize*entriesCount-searchRange}};var OTF_HEADER_SIZE=12;var OTF_TABLE_ENTRY_SIZE=16;OpenTypeFileBuilder.prototype={toArray:function OpenTypeFileBuilder_toArray(){var sfnt=this.sfnt;var tables=this.tables;var tablesNames=Object.keys(tables);tablesNames.sort();var numTables=tablesNames.length;var i,j,jj,table,tableName;var offset=OTF_HEADER_SIZE+numTables* +OTF_TABLE_ENTRY_SIZE;var tableOffsets=[offset];for(i=0;i>>0;offset+=paddedLength;tableOffsets.push(offset)}var file=new Uint8Array(offset);for(i=0;i1?names[1]:names[0];names=names.split(/[-,_]/g)[0];this.isSerifFont=!!(properties.flags&FontFlags.Serif);this.isSymbolicFont=!!(properties.flags&FontFlags.Symbolic);this.isMonospace=!!(properties.flags&FontFlags.FixedPitch);var type=properties.type;var subtype=properties.subtype;this.type=type;this.fallbackName= +this.isMonospace?"monospace":this.isSerifFont?"serif":"sans-serif";this.differences=properties.differences;this.widths=properties.widths;this.defaultWidth=properties.defaultWidth;this.composite=properties.composite;this.wideChars=properties.wideChars;this.cMap=properties.cMap;this.ascent=properties.ascent/PDF_GLYPH_SPACE_UNITS;this.descent=properties.descent/PDF_GLYPH_SPACE_UNITS;this.fontMatrix=properties.fontMatrix;this.toUnicode=properties.toUnicode=this.buildToUnicode(properties);this.toFontChar= +[];if(properties.type==="Type3"){for(charCode=0;charCode<256;charCode++)this.toFontChar[charCode]=this.differences[charCode]||properties.defaultEncoding[charCode];this.fontType=FontType.TYPE3;return}this.cidEncoding=properties.cidEncoding;this.vertical=properties.vertical;if(this.vertical){this.vmetrics=properties.vmetrics;this.defaultVMetrics=properties.defaultVMetrics}if(!file||file.isEmpty){if(file)warn('Font file is empty in "'+name+'" ('+this.loadedName+")");this.missingFile=true;var fontName= +name.replace(/[,_]/g,"-");var isStandardFont=fontName in stdFontMap;fontName=stdFontMap[fontName]||nonStdFontMap[fontName]||fontName;this.bold=fontName.search(/bold/gi)!==-1;this.italic=fontName.search(/oblique/gi)!==-1||fontName.search(/italic/gi)!==-1;this.black=name.search(/Black/g)!==-1;this.remeasure=Object.keys(this.widths).length>0;if(isStandardFont&&type==="CIDFontType2"&&properties.cidEncoding.indexOf("Identity-")===0){var map=[];for(var code in GlyphMapForStandardFonts)map[+code]=GlyphMapForStandardFonts[code]; +var isIdentityUnicode=this.toUnicode instanceof IdentityToUnicodeMap;if(!isIdentityUnicode)this.toUnicode.forEach(function(charCode,unicodeCharCode){map[+charCode]=unicodeCharCode});this.toFontChar=map;this.toUnicode=new ToUnicodeMap(map)}else if(/Symbol/i.test(fontName)){var symbols=Encodings.SymbolSetEncoding;for(charCode in symbols){fontChar=GlyphsUnicode[symbols[charCode]];if(!fontChar)continue;this.toFontChar[charCode]=fontChar}for(charCode in properties.differences){fontChar=GlyphsUnicode[properties.differences[charCode]]; +if(!fontChar)continue;this.toFontChar[charCode]=fontChar}}else if(/Dingbats/i.test(fontName)){var dingbats=Encodings.ZapfDingbatsEncoding;for(charCode in dingbats){fontChar=DingbatsGlyphsUnicode[dingbats[charCode]];if(!fontChar)continue;this.toFontChar[charCode]=fontChar}for(charCode in properties.differences){fontChar=DingbatsGlyphsUnicode[properties.differences[charCode]];if(!fontChar)continue;this.toFontChar[charCode]=fontChar}}else if(isStandardFont){this.toFontChar=[];for(charCode in properties.defaultEncoding){glyphName= +properties.differences[charCode]||properties.defaultEncoding[charCode];this.toFontChar[charCode]=GlyphsUnicode[glyphName]}}else{var unicodeCharCode,notCidFont=type.indexOf("CIDFontType")===-1;this.toUnicode.forEach(function(charCode,unicodeCharCode){if(notCidFont){glyphName=properties.differences[charCode]||properties.defaultEncoding[charCode];unicodeCharCode=GlyphsUnicode[glyphName]||unicodeCharCode}this.toFontChar[charCode]=unicodeCharCode}.bind(this))}this.loadedName=fontName.split("-")[0];this.loading= +false;this.fontType=getFontType(type,subtype);return}if(subtype==="Type1C"&&(type!=="Type1"&&type!=="MMType1"))if(isTrueTypeFile(file))subtype="TrueType";else type="Type1";if(subtype==="CIDFontType0C"&&type!=="CIDFontType0")type="CIDFontType0";if(subtype==="OpenType")type="OpenType";var data;switch(type){case "MMType1":info("MMType1 font ("+name+"), falling back to Type1.");case "Type1":case "CIDFontType0":this.mimetype="font/opentype";var cff=subtype==="Type1C"||subtype==="CIDFontType0C"?new CFFFont(file, +properties):new Type1Font(name,file,properties);adjustWidths(properties);data=this.convert(name,cff,properties);break;case "OpenType":case "TrueType":case "CIDFontType2":this.mimetype="font/opentype";data=this.checkAndRepair(name,file,properties);if(this.isOpenType)type="OpenType";break;default:error("Font "+type+" is not supported");break}this.data=data;this.fontType=getFontType(type,subtype);this.fontMatrix=properties.fontMatrix;this.widths=properties.widths;this.defaultWidth=properties.defaultWidth; +this.encoding=properties.baseEncoding;this.seacMap=properties.seacMap;this.loading=true}Font.getFontID=function(){var ID=1;return function Font_getFontID(){return String(ID++)}}();function int16(b0,b1){return(b0<<8)+b1}function int32(b0,b1,b2,b3){return(b0<<24)+(b1<<16)+(b2<<8)+b3}function string16(value){return String.fromCharCode(value>>8&255,value&255)}function safeString16(value){value=value>32767?32767:value<-32768?-32768:value;return String.fromCharCode(value>>8&255,value&255)}function isTrueTypeFile(file){var header= +file.peekBytes(4);return readUint32(header,0)===65536}function adjustMapping(charCodeToGlyphId,properties){var toUnicode=properties.toUnicode;var isSymbolic=!!(properties.flags&FontFlags.Symbolic);var isIdentityUnicode=properties.toUnicode instanceof IdentityToUnicodeMap;var isCidFontType2=properties.type==="CIDFontType2";var newMap=Object.create(null);var toFontChar=[];var usedFontCharCodes=[];var nextAvailableFontCharCode=PRIVATE_USE_OFFSET_START;for(var originalCharCode in charCodeToGlyphId){originalCharCode|= +0;var glyphId=charCodeToGlyphId[originalCharCode];var fontCharCode=originalCharCode;if(!isIdentityUnicode)if(toUnicode.get(originalCharCode)!==undefined){var unicode=toUnicode.get(fontCharCode);if(unicode.length===1)fontCharCode=unicode.charCodeAt(0)}else if(isCidFontType2)fontCharCode=nextAvailableFontCharCode;if((usedFontCharCodes[fontCharCode]!==undefined||fontCharCode<=31||fontCharCode===127||fontCharCode===173||fontCharCode>=128&&fontCharCode<=159||fontCharCode>=65520&&fontCharCode<=65535||isSymbolic&& +isIdentityUnicode)&&nextAvailableFontCharCode<=PRIVATE_USE_OFFSET_END){do{fontCharCode=nextAvailableFontCharCode++;if(SKIP_PRIVATE_USE_RANGE_F000_TO_F01F&&fontCharCode===61440){fontCharCode=61472;nextAvailableFontCharCode=fontCharCode+1}}while(usedFontCharCodes[fontCharCode]!==undefined&&nextAvailableFontCharCode<=PRIVATE_USE_OFFSET_END)}newMap[fontCharCode]=glyphId;toFontChar[originalCharCode]=fontCharCode;usedFontCharCodes[fontCharCode]=true}return{toFontChar:toFontChar,charCodeToGlyphId:newMap, +nextAvailableFontCharCode:nextAvailableFontCharCode}}function getRanges(glyphs){var codes=[];for(var charCode in glyphs)codes.push({fontCharCode:charCode|0,glyphId:glyphs[charCode]});codes.sort(function fontGetRangesSort(a,b){return a.fontCharCode-b.fontCharCode});var ranges=[];var length=codes.length;for(var n=0;n65535?2:1;var cmap="\x00\x00"+string16(numTables)+"\x00\u0003"+"\x00\u0001"+string32(4+numTables*8);var i,ii,j,jj;for(i=ranges.length-1;i>=0;--i)if(ranges[i][0]<=65535)break;var bmpLength=i+1;if(ranges[i][0]<65535&&ranges[i][1]===65535)ranges[i][1]=65534;var trailingRangesCount=ranges[i][1]<65535?1:0;var segCount=bmpLength+trailingRangesCount; +var searchParams=OpenTypeFileBuilder.getSearchParams(segCount,2);var startCount="";var endCount="";var idDeltas="";var idRangeOffsets="";var glyphsIds="";var bias=0;var range,start,end,codes;for(i=0,ii=bmpLength;i0){endCount+="\u00ff\u00ff";startCount+="\u00ff\u00ff";idDeltas+="\x00\u0001";idRangeOffsets+="\x00\x00"}var format314="\x00\x00"+string16(2*segCount)+string16(searchParams.range)+string16(searchParams.entry)+string16(searchParams.rangeShift)+endCount+"\x00\x00"+ +startCount+idDeltas+idRangeOffsets+glyphsIds;var format31012="";var header31012="";if(numTables>1){cmap+="\x00\u0003"+"\x00\n"+string32(4+numTables*8+4+format314.length);format31012="";for(i=0,ii=ranges.length;ilastChar)return false;stream.getBytes(6);var usWinAscent= +stream.getUint16();if(usWinAscent===0)return false;os2.data[8]=os2.data[9]=0;return true}function createOS2Table(properties,charstrings,override){override=override||{unitsPerEm:0,yMax:0,yMin:0,ascent:0,descent:0};var ulUnicodeRange1=0;var ulUnicodeRange2=0;var ulUnicodeRange3=0;var ulUnicodeRange4=0;var firstCharIndex=null;var lastCharIndex=0;if(charstrings)for(var code in charstrings){code|=0;if(firstCharIndex>code||!firstCharIndex)firstCharIndex=code;if(lastCharIndex 123 are reserved for internal usage")}else{firstCharIndex=0;lastCharIndex=255}var bbox=properties.bbox||[0,0,0,0];var unitsPerEm=override.unitsPerEm||1/(properties.fontMatrix||FONT_IDENTITY_MATRIX)[0];var scale=properties.ascentScaled?1:unitsPerEm/ +PDF_GLYPH_SPACE_UNITS;var typoAscent=override.ascent||Math.round(scale*(properties.ascent||bbox[3]));var typoDescent=override.descent||Math.round(scale*(properties.descent||bbox[1]));if(typoDescent>0&&properties.descent>0&&bbox[1]<0)typoDescent=-typoDescent;var winAscent=override.yMax||typoAscent;var winDescent=-override.yMin||-typoDescent;return"\x00\u0003"+"\u0002$"+"\u0001\u00f4"+"\x00\u0005"+"\x00\x00"+"\u0002\u008a"+"\u0002\u00bb"+"\x00\x00"+"\x00\u008c"+"\u0002\u008a"+"\u0002\u00bb"+"\x00\x00"+ +"\u0001\u00df"+"\x001"+"\u0001\u0002"+"\x00\x00"+"\x00\x00\u0006"+String.fromCharCode(properties.fixedPitch?9:0)+"\x00\x00\x00\x00\x00\x00"+string32(ulUnicodeRange1)+string32(ulUnicodeRange2)+string32(ulUnicodeRange3)+string32(ulUnicodeRange4)+"*21*"+string16(properties.italicAngle?1:0)+string16(firstCharIndex||properties.firstChar)+string16(lastCharIndex||properties.lastChar)+string16(typoAscent)+string16(typoDescent)+"\x00d"+string16(winAscent)+string16(winDescent)+"\x00\x00\x00\x00"+"\x00\x00\x00\x00"+ +string16(properties.xHeight)+string16(properties.capHeight)+string16(0)+string16(firstCharIndex||properties.firstChar)+"\x00\u0003"}function createPostTable(properties){var angle=Math.floor(properties.italicAngle*Math.pow(2,16));return"\x00\u0003\x00\x00"+string32(angle)+"\x00\x00"+"\x00\x00"+string32(properties.fixedPitch)+"\x00\x00\x00\x00"+"\x00\x00\x00\x00"+"\x00\x00\x00\x00"+"\x00\x00\x00\x00"}function createNameTable(name,proto){if(!proto)proto=[[],[]];var strings=[proto[0][0]||"Original licence", +proto[0][1]||name,proto[0][2]||"Unknown",proto[0][3]||"uniqueID",proto[0][4]||name,proto[0][5]||"Version 0.11",proto[0][6]||"",proto[0][7]||"Unknown",proto[0][8]||"Unknown",proto[0][9]||"Unknown"];var stringsUnicode=[];var i,ii,j,jj,str;for(i=0,ii=strings.length;i>>0;var length=file.getInt32()>>>0;var previousPosition=file.pos;file.pos=file.start?file.start:0;file.skip(offset);var data=file.getBytes(length);file.pos=previousPosition;if(tag==="head"){data[8]=data[9]=data[10]=data[11]=0;data[17]|=32}return{tag:tag,checksum:checksum,length:length,offset:offset,data:data}}function readOpenTypeHeader(ttf){return{version:bytesToString(ttf.getBytes(4)),numTables:ttf.getUint16(),searchRange:ttf.getUint16(),entrySelector:ttf.getUint16(), +rangeShift:ttf.getUint16()}}function readCmapTable(cmap,font,isSymbolicFont){var segment;var start=(font.start?font.start:0)+cmap.offset;font.pos=start;var version=font.getUint16();var numTables=font.getUint16();var potentialTable;var canBreak=false;for(var i=0;i>>0;var useTable=false;if(platformId===1&&encodingId===0)useTable=true;else if(!isSymbolicFont&&platformId===3&&encodingId===1){useTable= +true;canBreak=true}else if(isSymbolicFont&&platformId===3&&encodingId===0){useTable=true;canBreak=true}if(useTable)potentialTable={platformId:platformId,encodingId:encodingId,offset:offset};if(canBreak)break}if(!potentialTable){warn("Could not find a preferred cmap table.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:false}}font.pos=start+potentialTable.offset;var format=font.getUint16();var length=font.getUint16();var language=font.getUint16();var hasShortCmap=false;var mappings= +[];var j,glyphId;if(format===0){for(j=0;j<256;j++){var index=font.getByte();if(!index)continue;mappings.push({charCode:j,glyphId:index})}hasShortCmap=true}else if(format===4){var segCount=font.getUint16()>>1;font.getBytes(6);var segIndex,segments=[];for(segIndex=0;segIndex>1)-(segCount-segIndex);segment.offsetIndex=offsetIndex;offsetsCount=Math.max(offsetsCount,offsetIndex+segment.end-segment.start+1)}var offsets=[];for(j=0;jnumGlyphs){info("The numOfMetrics ("+numOfMetrics+") should not be "+"greater than the numGlyphs ("+numGlyphs+")");numOfMetrics=numGlyphs;header.data[34]=(numOfMetrics&65280)>>8;header.data[35]=numOfMetrics&255}var numOfSidebearings=numGlyphs-numOfMetrics;var numMissing=numOfSidebearings-(metrics.length-numOfMetrics*4>>1);if(numMissing>0){var entries=new Uint8Array(metrics.length+numMissing*2);entries.set(metrics.data);metrics.data=entries}}function sanitizeGlyph(source,sourceStart, +sourceEnd,dest,destStart,hintsValid){if(sourceEnd-sourceStart<=12)return 0;var glyf=source.subarray(sourceStart,sourceEnd);var contoursCount=glyf[0]<<8|glyf[1];if(contoursCount&32768){dest.set(glyf,destStart);return glyf.length}var i,j=10,flagsCount=0;for(i=0;iglyf.length)return 0;if(!hintsValid&&instructionsLength>0){dest.set(glyf.subarray(0,instructionsStart),destStart);dest.set([0,0],destStart+instructionsStart);dest.set(glyf.subarray(instructionsEnd,glyphDataLength), +destStart+instructionsStart+2);glyphDataLength-=instructionsLength;if(glyf.length-glyphDataLength>3)glyphDataLength=glyphDataLength+3&~3;return glyphDataLength}if(glyf.length-glyphDataLength>3){glyphDataLength=glyphDataLength+3&~3;dest.set(glyf.subarray(0,glyphDataLength),destStart);return glyphDataLength}dest.set(glyf,destStart);return glyf.length}function sanitizeHead(head,numGlyphs,locaLength){var data=head.data;var version=int32(data[0],data[1],data[2],data[3]);if(version>>16!==1){info("Attempting to fix invalid version in head table: "+ +version);data[0]=0;data[1]=1;data[2]=0;data[3]=0}var indexToLocFormat=int16(data[50],data[51]);if(indexToLocFormat<0||indexToLocFormat>1){info("Attempting to fix invalid indexToLocFormat in head table: "+indexToLocFormat);var numGlyphsPlusOne=numGlyphs+1;if(locaLength===numGlyphsPlusOne<<1){data[50]=0;data[51]=0}else if(locaLength===numGlyphsPlusOne<<2){data[50]=0;data[51]=1}else warn("Could not fix indexToLocFormat: "+indexToLocFormat)}}function sanitizeGlyphLocations(loca,glyf,numGlyphs,isGlyphLocationsLong, +hintsValid,dupFirstEntry){var itemSize,itemDecode,itemEncode;if(isGlyphLocationsLong){itemSize=4;itemDecode=function fontItemDecodeLong(data,offset){return data[offset]<<24|data[offset+1]<<16|data[offset+2]<<8|data[offset+3]};itemEncode=function fontItemEncodeLong(data,offset,value){data[offset]=value>>>24&255;data[offset+1]=value>>16&255;data[offset+2]=value>>8&255;data[offset+3]=value&255}}else{itemSize=2;itemDecode=function fontItemDecode(data,offset){return data[offset]<<9|data[offset+1]<<1}; +itemEncode=function fontItemEncode(data,offset,value){data[offset]=value>>9&255;data[offset+1]=value>>1&255}}var locaData=loca.data;var locaDataSize=itemSize*(1+numGlyphs);if(locaData.length!==locaDataSize){locaData=new Uint8Array(locaDataSize);locaData.set(loca.data.subarray(0,locaDataSize));loca.data=locaData}var oldGlyfData=glyf.data;var oldGlyfDataLength=oldGlyfData.length;var newGlyfData=new Uint8Array(oldGlyfDataLength);var startOffset=itemDecode(locaData,0);var writeOffset=0;itemEncode(locaData, +0,writeOffset);var i,j;for(i=0,j=itemSize;ioldGlyfDataLength&&(oldGlyfDataLength+3&~3)===endOffset)endOffset=oldGlyfDataLength;if(endOffset>oldGlyfDataLength){itemEncode(locaData,j,writeOffset);startOffset=endOffset;continue}var newLength=sanitizeGlyph(oldGlyfData,startOffset,endOffset,newGlyfData,writeOffset,hintsValid);writeOffset+=newLength;itemEncode(locaData,j,writeOffset);startOffset=endOffset}if(writeOffset===0){var simpleGlyph= +new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(i=0,j=itemSize;ifirstEntryLength+writeOffset)glyf.data=newGlyfData.subarray(0,firstEntryLength+writeOffset);else{glyf.data=new Uint8Array(firstEntryLength+writeOffset);glyf.data.set(newGlyfData.subarray(0,writeOffset))}glyf.data.set(newGlyfData.subarray(0,firstEntryLength), +writeOffset);itemEncode(loca.data,locaData.length-itemSize,writeOffset+firstEntryLength)}else glyf.data=newGlyfData.subarray(0,writeOffset)}function readPostScriptTable(post,properties,maxpNumGlyphs){var start=(font.start?font.start:0)+post.offset;font.pos=start;var length=post.length,end=start+length;var version=font.getInt32();font.getBytes(28);var glyphNames;var valid=true;var i;switch(version){case 65536:glyphNames=MacStandardGlyphOrdering;break;case 131072:var numGlyphs=font.getUint16();if(numGlyphs!== +maxpNumGlyphs){valid=false;break}var glyphNameIndexes=[];for(i=0;i=32768){valid=false;break}glyphNameIndexes.push(index)}if(!valid)break;var customNames=[];var strBuf=[];while(font.posend)continue;font.pos=pos;var nameIndex=record.name;if(record.encoding){var str="";for(var j=0,jj=record.length;j0)i+=offset-1}if(!inFDEF&&!inELSE){var stackDelta=op<=142?TTOpsStackDeltas[op]:op>=192&&op<=223?-1:op>=224?-2:0;if(op>=113&&op<=117){n=stack.pop();if(n===n)stackDelta=-n*2}while(stackDelta<0&&stack.length>0){stack.pop();stackDelta++}while(stackDelta>0){stack.push(NaN); +stackDelta--}}}ttContext.tooComplexToFollowFunctions=tooComplexToFollowFunctions;var content=[data];if(i>data.length)content.push(new Uint8Array(i-data.length));if(lastDeff>lastEndf){warn("TT: complementing a missing function tail");content.push(new Uint8Array([34,45]))}foldTTTable(table,content)}function checkInvalidFunctions(ttContext,maxFunctionDefs){if(ttContext.tooComplexToFollowFunctions)return;if(ttContext.functionsDefined.length>maxFunctionDefs){warn("TT: more functions defined than expected"); +ttContext.hintsValid=false;return}for(var j=0,jj=ttContext.functionsUsed.length;jmaxFunctionDefs){warn("TT: invalid function id: "+j);ttContext.hintsValid=false;return}if(ttContext.functionsUsed[j]&&!ttContext.functionsDefined[j]){warn("TT: undefined function: "+j);ttContext.hintsValid=false;return}}}function foldTTTable(table,content){if(content.length>1){var newLength=0;var j,jj;for(j=0,jj=content.length;j=65536&&tables.maxp.length>=22){font.pos+=8;var maxZones=font.getUint16();if(maxZones>2){tables.maxp.data[14]=0;tables.maxp.data[15]=2}font.pos+=4;maxFunctionDefs=font.getUint16()}var dupFirstEntry=false;if(properties.type==="CIDFontType2"&&properties.toUnicode&&properties.toUnicode.get(0)>"\x00"){dupFirstEntry= +true;numGlyphs++;tables.maxp.data[4]=numGlyphs>>8;tables.maxp.data[5]=numGlyphs&255}var hintsValid=sanitizeTTPrograms(tables.fpgm,tables.prep,tables["cvt "],maxFunctionDefs);if(!hintsValid){delete tables.fpgm;delete tables.prep;delete tables["cvt "]}sanitizeMetrics(font,tables.hhea,tables.hmtx,numGlyphs);if(!tables.head)error('Required "head" table is not found');sanitizeHead(tables.head,numGlyphs,isTrueType?tables.loca.length:0);if(isTrueType){var isGlyphLocationsLong=int16(tables.head.data[50], +tables.head.data[51]);sanitizeGlyphLocations(tables.loca,tables.glyf,numGlyphs,isGlyphLocationsLong,hintsValid,dupFirstEntry)}if(!tables.hhea)error('Required "hhea" table is not found');if(tables.hhea.data[10]===0&&tables.hhea.data[11]===0){tables.hhea.data[10]=255;tables.hhea.data[11]=255}if(tables.post){var valid=readPostScriptTable(tables.post,properties,numGlyphs);if(!valid)tables.post=null}var charCodeToGlyphId=[],charCode;if(properties.type==="CIDFontType2"){var cidToGidMap=properties.cidToGidMap|| +[];var cidToGidMapLength=cidToGidMap.length;properties.cMap.forEach(function(charCode,cid){assert(cid<=65535,"Max size of CID is 65,535");var glyphId=-1;if(cidToGidMapLength===0)glyphId=charCode;else if(cidToGidMap[cid]!==undefined)glyphId=cidToGidMap[cid];if(glyphId>=0&&glyphId0)charCodeToGlyphId[charCode]=glyphId}}}else for(i=0;i=3)code=+glyphName.substr(1);break}if(code){if(baseEncodingName&&code===+charcode){var baseEncoding=Encodings[baseEncodingName]; +if(baseEncoding&&(glyphName=baseEncoding[charcode])){toUnicode[charcode]=String.fromCharCode(GlyphsUnicode[glyphName]);continue}}toUnicode[charcode]=String.fromCharCode(code)}continue}toUnicode[charcode]=String.fromCharCode(GlyphsUnicode[glyphName])}return new ToUnicodeMap(toUnicode)}if(properties.composite&&(properties.cMap.builtInCMap&&!(properties.cMap instanceof IdentityCMap)||properties.cidSystemInfo.registry==="Adobe"&&(properties.cidSystemInfo.ordering==="GB1"||properties.cidSystemInfo.ordering=== +"CNS1"||properties.cidSystemInfo.ordering==="Japan1"||properties.cidSystemInfo.ordering==="Korea1"))){var registry=properties.cidSystemInfo.registry;var ordering=properties.cidSystemInfo.ordering;var ucs2CMapName=new Name(registry+"-"+ordering+"-UCS2");var ucs2CMap=CMapFactory.create(ucs2CMapName,{url:PDFJS.cMapUrl,packed:PDFJS.cMapPacked},null);var cMap=properties.cMap;toUnicode=[];cMap.forEach(function(charcode,cid){assert(cid<=65535,"Max size of CID is 65,535");var ucs2=ucs2CMap.lookup(cid);if(ucs2)toUnicode[charcode]= +String.fromCharCode((ucs2.charCodeAt(0)<<8)+ucs2.charCodeAt(1))});return new ToUnicodeMap(toUnicode)}return new IdentityToUnicodeMap(properties.firstChar,properties.lastChar)},get spaceWidth(){if("_shadowWidth"in this)return this._shadowWidth;var possibleSpaceReplacements=["space","minus","one","i"];var width;for(var i=0,ii=possibleSpaceReplacements.length;i=0)charCodeToGlyphId[charCode]=glyphId}}else if(!!(properties.flags&FontFlags.Symbolic))for(charCode in builtInEncoding)charCodeToGlyphId[charCode]=builtInEncoding[charCode];else{baseEncoding=Encodings.StandardEncoding; +for(charCode=0;charCode=0)charCodeToGlyphId[charCode]=glyphId}}var differences=properties.differences;if(differences)for(charCode in differences){var glyphName=differences[charCode];glyphId=glyphNames.indexOf(glyphName);if(glyphId>=0)charCodeToGlyphId[charCode]=glyphId}return charCodeToGlyphId}var Type1CharString=function Type1CharStringClosure(){var COMMAND_MAP={"hstem":[1],"vstem":[3],"vmoveto":[4],"rlineto":[5], +"hlineto":[6],"vlineto":[7],"rrcurveto":[8],"callsubr":[10],"flex":[12,35],"drop":[12,18],"endchar":[14],"rmoveto":[21],"hmoveto":[22],"vhcurveto":[30],"hvcurveto":[31]};function Type1CharString(){this.width=0;this.lsb=0;this.flexing=false;this.output=[];this.stack=[]}Type1CharString.prototype={convert:function Type1CharString_convert(encoded,subrs){var count=encoded.length;var error=false;var wx,sbx,subrNumber;for(var i=0;istackLength)return true;var start=stackLength-howManyArgs;for(var i=start;i>8&255,value&255);else{value=65536* +value|0;this.output.push(255,value>>24&255,value>>16&255,value>>8&255,value&255)}}this.output.push.apply(this.output,command);if(keepStack)this.stack.splice(start,howManyArgs);else this.stack.length=0;return false}};return Type1CharString}();var Type1Parser=function Type1ParserClosure(){var EEXEC_ENCRYPT_KEY=55665;var CHAR_STRS_ENCRYPT_KEY=4330;function isHexDigit(code){return code>=48&&code<=57||code>=65&&code<=70||code>=97&&code<=102}function decrypt(data,key,discardNumber){var r=key|0,c1=52845, +c2=22719;var count=data.length;var decrypted=new Uint8Array(count);for(var i=0;i>8;r=(value+r)*c1+c2&(1<<16)-1}return Array.prototype.slice.call(decrypted,discardNumber)}function decryptAscii(data,key,discardNumber){var r=key|0,c1=52845,c2=22719;var count=data.length,maybeLength=count>>>1;var decrypted=new Uint8Array(maybeLength);var i,j;for(i=0,j=0;i>8;r=(value+r)*c1+c2&(1<<16)-1}}return Array.prototype.slice.call(decrypted,discardNumber,j)}function isSpecial(c){return c===47||c===91||c===93||c===123||c===125||c===40||c===41}function Type1Parser(stream,encrypted){if(encrypted){var data=stream.getBytes();var isBinary=!(isHexDigit(data[0])&&isHexDigit(data[1])&&isHexDigit(data[2])&&isHexDigit(data[3]));stream=new Stream(isBinary?decrypt(data, +EEXEC_ENCRYPT_KEY,4):decryptAscii(data,EEXEC_ENCRYPT_KEY,4))}this.stream=stream;this.nextChar()}Type1Parser.prototype={readNumberArray:function Type1Parser_readNumberArray(){this.getToken();var array=[];while(true){var token=this.getToken();if(token===null||token==="]"||token==="}")break;array.push(parseFloat(token||0))}return array},readNumber:function Type1Parser_readNumber(){var token=this.getToken();return parseFloat(token||0)},readInt:function Type1Parser_readInt(){var token=this.getToken(); +return parseInt(token||0,10)|0},readBoolean:function Type1Parser_readBoolean(){var token=this.getToken();return token==="true"?1:0},nextChar:function Type1_nextChar(){return this.currentChar=this.stream.getByte()},getToken:function Type1Parser_getToken(){var comment=false;var ch=this.currentChar;while(true){if(ch===-1)return null;if(comment){if(ch===10||ch===13)comment=false}else if(ch===37)comment=true;else if(!Lexer.isSpace(ch))break;ch=this.nextChar()}if(isSpecial(ch)){this.nextChar();return String.fromCharCode(ch)}var token= +"";do{token+=String.fromCharCode(ch);ch=this.nextChar()}while(ch>=0&&!Lexer.isSpace(ch)&&!isSpecial(ch));return token},extractFontProgram:function Type1Parser_extractFontProgram(){var stream=this.stream;var subrs=[],charstrings=[];var program={subrs:[],charstrings:[],properties:{"privateData":{"lenIV":4}}};var token,length,data,lenIV,encoded;while((token=this.getToken())!==null){if(token!=="/")continue;token=this.getToken();switch(token){case "CharStrings":this.getToken();this.getToken();this.getToken(); +this.getToken();while(true){token=this.getToken();if(token===null||token==="end")break;if(token!=="/")continue;var glyph=this.getToken();length=this.readInt();this.getToken();data=stream.makeSubStream(stream.pos,length);lenIV=program.properties.privateData["lenIV"];encoded=decrypt(data.getBytes(),CHAR_STRS_ENCRYPT_KEY,lenIV);stream.skip(length);this.nextChar();token=this.getToken();if(token==="noaccess")this.getToken();charstrings.push({glyph:glyph,encoded:encoded})}break;case "Subrs":var num=this.readInt(); +this.getToken();while((token=this.getToken())==="dup"){var index=this.readInt();length=this.readInt();this.getToken();data=stream.makeSubStream(stream.pos,length);lenIV=program.properties.privateData["lenIV"];encoded=decrypt(data.getBytes(),CHAR_STRS_ENCRYPT_KEY,lenIV);stream.skip(length);this.nextChar();token=this.getToken();if(token==="noaccess")this.getToken();subrs[index]=encoded}break;case "BlueValues":case "OtherBlues":case "FamilyBlues":case "FamilyOtherBlues":var blueArray=this.readNumberArray(); +if(blueArray.length>0&&blueArray.length%2===0&&HINTING_ENABLED)program.properties.privateData[token]=blueArray;break;case "StemSnapH":case "StemSnapV":program.properties.privateData[token]=this.readNumberArray();break;case "StdHW":case "StdVW":program.properties.privateData[token]=this.readNumberArray()[0];break;case "BlueShift":case "lenIV":case "BlueFuzz":case "BlueScale":case "LanguageGroup":case "ExpansionFactor":program.properties.privateData[token]=this.readNumber();break;case "ForceBold":program.properties.privateData[token]= +this.readBoolean();break}}for(var i=0;i=0)builtInEncoding[charCode]=glyphId}}return type1FontGlyphMapping(properties,builtInEncoding,glyphNames)},getSeacs:function Type1Font_getSeacs(charstrings){var i,ii;var seacMap=[];for(i= +0,ii=charstrings.length;i>8&255,index&255)}cff.charset=new CFFCharset(false,0,[],charsetArray);var charStringsIndex=new CFFIndex;charStringsIndex.add([139,14]);for(i=0;i0;j--)value[j]-=value[j-1];privateDict.setByName(field,value)}cff.topDict.privateDict=privateDict;var subrIndex=new CFFIndex;for(i=0,ii=subrs.length;i=bytesLength)error("Invalid CFF header");else if(offset!==0){info("cff data is shifted");bytes=bytes.subarray(offset);this.bytes=bytes}var major=bytes[0];var minor=bytes[1];var hdrSize=bytes[2];var offSize=bytes[3];var header=new CFFHeader(major,minor,hdrSize,offSize);return{obj:header,endPos:hdrSize}},parseDict:function CFFParser_parseDict(dict){var pos=0;function parseOperand(){var value= +dict[pos++];if(value===30)return parseFloatOperand(pos);else if(value===28){value=dict[pos++];value=(value<<24|dict[pos++]<<16)>>16;return value}else if(value===29){value=dict[pos++];value=value<<8|dict[pos++];value=value<<8|dict[pos++];value=value<<8|dict[pos++];return value}else if(value>=32&&value<=246)return value-139;else if(value>=247&&value<=250)return(value-247)*256+dict[pos++]+108;else if(value>=251&&value<=254)return-((value-251)*256)-dict[pos++]-108;else error("255 is not a valid DICT command"); +return-1}function parseFloatOperand(){var str="";var eof=15;var lookup=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];var length=dict.length;while(pos>4;var b2=b&15;if(b1===eof)break;str+=lookup[b1];if(b2===eof)break;str+=lookup[b2]}return parseFloat(str)}var operands=[];var entries=[];pos=0;var end=dict.length;while(pos126||c===91||c===93||c===40||c===41||c===123||c===125||c===60||c===62||c===47||c===37||c===35){data[j]=95;continue}data[j]=c}names.push(bytesToString(data))}return names},parseStringIndex:function CFFParser_parseStringIndex(index){var strings= +new CFFStrings;for(var i=0,ii=index.count;i>16;j+=2; +stackSize++}else if(value===14){if(stackSize>=4){stackSize-=4;if(SEAC_ANALYSIS_ENABLED){seacs[i]=stack.slice(stackSize,stackSize+4);valid=false}}validationCommand=CharstringValidationData[value]}else if(value>=32&&value<=246){stack[stackSize]=value-139;stackSize++}else if(value>=247&&value<=254){stack[stackSize]=value<251?(value-247<<8)+data[j]+108:-(value-251<<8)-data[j]-108;j++;stackSize++}else if(value===255){stack[stackSize]=(data[j]<<24|data[j+1]<<16|data[j+2]<<8|data[j+3])/65536;j+=4;stackSize++}else if(value=== +19||value===20){hints+=stackSize>>1;j+=hints+7>>3;stackSize%=2;validationCommand=CharstringValidationData[value]}else validationCommand=CharstringValidationData[value];if(validationCommand){if(validationCommand.stem)hints+=stackSize>>1;if("min"in validationCommand)if(!undefStack&&stackSize=2&&validationCommand.stem)stackSize%=2;else if(stackSize>1)warn("Found too many parameters for stack-clearing command");if(stackSize>0&&stack[stackSize-1]>=0)widths[i]=stack[stackSize-1]}if("stackDelta"in validationCommand){if("stackFn"in validationCommand)validationCommand.stackFn(stack,stackSize);stackSize+=validationCommand.stackDelta}else if(validationCommand.stackClearing)stackSize=0;else if(validationCommand.resetStack){stackSize=0;undefStack= +false}else if(validationCommand.undefStack){stackSize=0;undefStack=true;firstStackClearing=false}}}if(!valid)charStrings.set(i,new Uint8Array([14]))}return{charStrings:charStrings,seacs:seacs,widths:widths}},emptyPrivateDictionary:function CFFParser_emptyPrivateDictionary(parentDict){var privateDict=this.createDict(CFFPrivateDict,[],parentDict.strings);parentDict.setByKey(18,[0,0]);parentDict.privateDict=privateDict},parsePrivateDict:function CFFParser_parsePrivateDict(parentDict){if(!parentDict.hasName("Private")){this.emptyPrivateDictionary(parentDict); +return}var privateOffset=parentDict.getByName("Private");if(!isArray(privateOffset)||privateOffset.length!==2){parentDict.removeByName("Private");return}var size=privateOffset[0];var offset=privateOffset[1];if(size===0||offset>=this.bytes.length){this.emptyPrivateDictionary(parentDict);return}var privateDictEnd=offset+size;var dictData=this.bytes.subarray(offset,privateDictEnd);var dict=this.parseDict(dictData);var privateDict=this.createDict(CFFPrivateDict,dict,parentDict.strings);parentDict.privateDict= +privateDict;if(!privateDict.getByName("Subrs"))return;var subrsOffset=privateDict.getByName("Subrs");var relativeOffset=offset+subrsOffset;if(subrsOffset===0||relativeOffset>=this.bytes.length){this.emptyPrivateDictionary(parentDict);return}var subrsIndex=this.parseIndex(relativeOffset);privateDict.subrsIndex=subrsIndex.obj},parseCharsets:function CFFParser_parseCharsets(pos,length,strings,cid){if(pos===0)return new CFFCharset(true,CFFCharsetPredefinedTypes.ISO_ADOBE,ISOAdobeCharset);else if(pos=== +1)return new CFFCharset(true,CFFCharsetPredefinedTypes.EXPERT,ExpertCharset);else if(pos===2)return new CFFCharset(true,CFFCharsetPredefinedTypes.EXPERT_SUBSET,ExpertSubsetCharset);var bytes=this.bytes;var start=pos;var format=bytes[pos++];var charset=[".notdef"];var id,count,i;length-=1;switch(format){case 0:for(i=0;i=0&&index<=390)return CFFStandardStrings[index];if(index-391<=this.strings.length)return this.strings[index-391];return CFFStandardStrings[0]},add:function CFFStrings_add(value){this.strings.push(value)},get count(){return this.strings.length}}; +return CFFStrings}();var CFFIndex=function CFFIndexClosure(){function CFFIndex(){this.objects=[];this.length=0}CFFIndex.prototype={add:function CFFIndex_add(data){this.length+=data.length;this.objects.push(data)},set:function CFFIndex_set(index,data){this.length+=data.length-this.objects[index].length;this.objects[index]=data},get:function CFFIndex_get(index){return this.objects[index]},get count(){return this.objects.length}};return CFFIndex}();var CFFDict=function CFFDictClosure(){function CFFDict(tables, +strings){this.keyToNameMap=tables.keyToNameMap;this.nameToKeyMap=tables.nameToKeyMap;this.defaults=tables.defaults;this.types=tables.types;this.opcodes=tables.opcodes;this.order=tables.order;this.strings=strings;this.values={}}CFFDict.prototype={setByKey:function CFFDict_setByKey(key,value){if(!(key in this.keyToNameMap))return false;if(value.length===0)return true;var type=this.types[key];if(type==="num"||type==="sid"||type==="offset")value=value[0];this.values[key]=value;return true},setByName:function CFFDict_setByName(name, +value){if(!(name in this.nameToKeyMap))error('Invalid dictionary name "'+name+'"');this.values[this.nameToKeyMap[name]]=value},hasName:function CFFDict_hasName(name){return this.nameToKeyMap[name]in this.values},getByName:function CFFDict_getByName(name){if(!(name in this.nameToKeyMap))error('Invalid dictionary name "'+name+'"');var key=this.nameToKeyMap[name];if(!(key in this.values))return this.defaults[key];return this.values[key]},removeByName:function CFFDict_removeByName(name){delete this.values[this.nameToKeyMap[name]]}}; +CFFDict.createTables=function CFFDict_createTables(layout){var tables={keyToNameMap:{},nameToKeyMap:{},defaults:{},types:{},opcodes:{},order:[]};for(var i=0,ii=layout.length;i>24&255;data[offset2]=value>>16&255;data[offset3]=value>>8&255;data[offset4]= +value&255}}};return CFFOffsetTracker}();var CFFCompiler=function CFFCompilerClosure(){function CFFCompiler(cff){this.cff=cff}CFFCompiler.prototype={compile:function CFFCompiler_compile(){var cff=this.cff;var output={data:[],length:0,add:function CFFCompiler_add(data){this.data=this.data.concat(data);this.length=this.data.length}};var header=this.compileHeader(cff.header);output.add(header);var nameIndex=this.compileNameIndex(cff.names);output.add(nameIndex);if(cff.isCIDFont)if(cff.topDict.hasName("FontMatrix")){var base= +cff.topDict.getByName("FontMatrix");cff.topDict.removeByName("FontMatrix");for(var i=0,ii=cff.fdArray.length;i=-107&&value<=107)code=[value+139];else if(value>=108&&value<=1131){value=[value-108];code=[(value>>8)+247,value&255]}else if(value>=-1131&&value<=-108){value=-value-108;code=[(value>>8)+251,value&255]}else if(value>=-32768&&value<=32767)code=[28,value>>8&255,value&255];else code=[29,value>>24&255,value>>16&255,value>>8&255,value&255];return code},compileHeader:function CFFCompiler_compileHeader(header){return[header.major, +header.minor,header.hdrSize,header.offSize]},compileNameIndex:function CFFCompiler_compileNameIndex(names){var nameIndex=new CFFIndex;for(var i=0,ii=names.length;i>8&255,count&255];var lastOffset=1,i;for(i=0;i> +8&255,relativeOffset&255);else if(offsetSize===3)data.push(relativeOffset>>16&255,relativeOffset>>8&255,relativeOffset&255);else data.push(relativeOffset>>>24&255,relativeOffset>>16&255,relativeOffset>>8&255,relativeOffset&255);if(objects[i])relativeOffset+=objects[i].length}for(i=0;i>1;p=start+offset+14;ranges=[];for(i=0;i>1;if(code>16;var flags;var x=0,y=0;i+=10;if(numberOfContours<0){do{flags=code[i]<<8|code[i+1];var glyphIndex=code[i+2]<<8|code[i+3];i+=4;var arg1,arg2;if(flags& +1){arg1=(code[i]<<24|code[i+1]<<16)>>16;arg2=(code[i+2]<<24|code[i+3]<<16)>>16;i+=4}else{arg1=code[i++];arg2=code[i++]}if(flags&2){x=arg1;y=arg2}else{x=0;y=0}var scaleX=1,scaleY=1,scale01=0,scale10=0;if(flags&8){scaleX=scaleY=(code[i]<<24|code[i+1]<<16)/1073741824;i+=2}else if(flags&64){scaleX=(code[i]<<24|code[i+1]<<16)/1073741824;scaleY=(code[i+2]<<24|code[i+3]<<16)/1073741824;i+=4}else if(flags&128){scaleX=(code[i]<<24|code[i+1]<<16)/1073741824;scale01=(code[i+2]<<24|code[i+3]<<16)/1073741824; +scale10=(code[i+4]<<24|code[i+5]<<16)/1073741824;scaleY=(code[i+6]<<24|code[i+7]<<16)/1073741824;i+=8}var subglyph=font.glyphs[glyphIndex];if(subglyph){js.push("c.save();");js.push("c.transform("+scaleX+","+scale01+","+scale10+","+scaleY+","+x+","+y+");");compileGlyf(subglyph,js,font);js.push("c.restore();")}}while(flags&32)}else{var endPtsOfContours=[];var j,jj;for(j=0;j0)points.push({flags:flags})}for(j=0;j>16;i+=2;break;case 2:x-=code[i++];break;case 18:x+=code[i++];break}points[j].x=x}for(j=0;j>16;i+=2;break; +case 4:y-=code[i++];break;case 36:y+=code[i++];break}points[j].y=y}var startPoint=0;for(i=0;i>1;stackClean=true;break;case 3:stems+=stack.length>>1;stackClean=true;break;case 4:y+=stack.pop();moveTo(x,y);stackClean=true;break;case 5:while(stack.length>0){x+=stack.shift();y+=stack.shift();lineTo(x,y)}break;case 6:while(stack.length> +0){x+=stack.shift();lineTo(x,y);if(stack.length===0)break;y+=stack.shift();lineTo(x,y)}break;case 7:while(stack.length>0){y+=stack.shift();lineTo(x,y);if(stack.length===0)break;x+=stack.shift();lineTo(x,y)}break;case 8:while(stack.length>0){xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y)}break;case 10:n=stack.pop()+font.subrsBias;subrCode=font.subrs[n];if(subrCode)parse(subrCode);break;case 11:return; +case 12:v=code[i++];switch(v){case 34:xa=x+stack.shift();xb=xa+stack.shift();y1=y+stack.shift();x=xb+stack.shift();bezierCurveTo(xa,y,xb,y1,x,y1);xa=x+stack.shift();xb=xa+stack.shift();x=xb+stack.shift();bezierCurveTo(xa,y1,xb,y,x,y);break;case 35:xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y);xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift(); +bezierCurveTo(xa,ya,xb,yb,x,y);stack.pop();break;case 36:xa=x+stack.shift();y1=y+stack.shift();xb=xa+stack.shift();y2=y1+stack.shift();x=xb+stack.shift();bezierCurveTo(xa,y1,xb,y2,x,y2);xa=x+stack.shift();xb=xa+stack.shift();y3=y2+stack.shift();x=xb+stack.shift();bezierCurveTo(xa,y2,xb,y3,x,y);break;case 37:var x0=x,y0=y;xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y);xa=x+stack.shift();ya=y+stack.shift(); +xb=xa+stack.shift();yb=ya+stack.shift();x=xb;y=yb;if(Math.abs(x-x0)>Math.abs(y-y0))x+=stack.shift();else y+=stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y);break;default:error("unknown operator: 12 "+v)}break;case 14:if(stack.length>=4){var achar=stack.pop();var bchar=stack.pop();y=stack.pop();x=stack.pop();js.push("c.save();");js.push("c.translate("+x+","+y+");");var gid=lookupCmap(font.cmap,String.fromCharCode(font.glyphNameMap[Encodings.StandardEncoding[achar]]));compileCharString(font.glyphs[gid], +js,font);js.push("c.restore();");gid=lookupCmap(font.cmap,String.fromCharCode(font.glyphNameMap[Encodings.StandardEncoding[bchar]]));compileCharString(font.glyphs[gid],js,font)}return;case 18:stems+=stack.length>>1;stackClean=true;break;case 19:stems+=stack.length>>1;i+=stems+7>>3;stackClean=true;break;case 20:stems+=stack.length>>1;i+=stems+7>>3;stackClean=true;break;case 21:y+=stack.pop();x+=stack.pop();moveTo(x,y);stackClean=true;break;case 22:x+=stack.pop();moveTo(x,y);stackClean=true;break;case 23:stems+= +stack.length>>1;stackClean=true;break;case 24:while(stack.length>2){xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y)}x+=stack.shift();y+=stack.shift();lineTo(x,y);break;case 25:while(stack.length>6){x+=stack.shift();y+=stack.shift();lineTo(x,y)}xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y);break;case 26:if(stack.length% +2)x+=stack.shift();while(stack.length>0){xa=x;ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb;y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y)}break;case 27:if(stack.length%2)y+=stack.shift();while(stack.length>0){xa=x+stack.shift();ya=y;xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb;bezierCurveTo(xa,ya,xb,yb,x,y)}break;case 28:stack.push((code[i]<<24|code[i+1]<<16)>>16);i+=2;break;case 29:n=stack.pop()+font.gsubrsBias;subrCode=font.gsubrs[n];if(subrCode)parse(subrCode); +break;case 30:while(stack.length>0){xa=x;ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+(stack.length===1?stack.shift():0);bezierCurveTo(xa,ya,xb,yb,x,y);if(stack.length===0)break;xa=x+stack.shift();ya=y;xb=xa+stack.shift();yb=ya+stack.shift();y=yb+stack.shift();x=xb+(stack.length===1?stack.shift():0);bezierCurveTo(xa,ya,xb,yb,x,y)}break;case 31:while(stack.length>0){xa=x+stack.shift();ya=y;xb=xa+stack.shift();yb=ya+stack.shift();y=yb+stack.shift();x=xb+(stack.length=== +1?stack.shift():0);bezierCurveTo(xa,ya,xb,yb,x,y);if(stack.length===0)break;xa=x;ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+(stack.length===1?stack.shift():0);bezierCurveTo(xa,ya,xb,yb,x,y)}break;default:if(v<32)error("unknown operator: "+v);if(v<247)stack.push(v-139);else if(v<251)stack.push((v-247)*256+code[i++]+108);else if(v<255)stack.push(-(v-251)*256-code[i++]-108);else{stack.push((code[i]<<24|code[i+1]<<16|code[i+2]<<8|code[i+3])/65536);i+=4}break}if(stackClean)stack.length= +0}}parse(code)}var noop="";function CompiledFont(fontMatrix){this.compiledGlyphs={};this.fontMatrix=fontMatrix}CompiledFont.prototype={getPathJs:function(unicode){var gid=lookupCmap(this.cmap,unicode);var fn=this.compiledGlyphs[gid];if(!fn)this.compiledGlyphs[gid]=fn=this.compileGlyph(this.glyphs[gid]);return fn},compileGlyph:function(code){if(!code||code.length===0||code[0]===14)return noop;var js=[];js.push("c.save();");js.push("c.transform("+this.fontMatrix.join(",")+");");js.push("c.scale(size, -size);"); +this.compileGlyphImpl(code,js);js.push("c.restore();");return js.join("\n")},compileGlyphImpl:function(){error("Children classes should implement this.")},hasBuiltPath:function(unicode){var gid=lookupCmap(this.cmap,unicode);return gid in this.compiledGlyphs}};function TrueTypeCompiled(glyphs,cmap,fontMatrix){fontMatrix=fontMatrix||[4.88E-4,0,0,4.88E-4,0,0];CompiledFont.call(this,fontMatrix);this.glyphs=glyphs;this.cmap=cmap;this.compiledGlyphs=[]}Util.inherit(TrueTypeCompiled,CompiledFont,{compileGlyphImpl:function(code, +js){compileGlyf(code,js,this)}});function Type2Compiled(cffInfo,cmap,fontMatrix,glyphNameMap){fontMatrix=fontMatrix||[.001,0,0,.001,0,0];CompiledFont.call(this,fontMatrix);this.glyphs=cffInfo.glyphs;this.gsubrs=cffInfo.gsubrs||[];this.subrs=cffInfo.subrs||[];this.cmap=cmap;this.glyphNameMap=glyphNameMap||GlyphsUnicode;this.compiledGlyphs=[];this.gsubrsBias=this.gsubrs.length<1240?107:this.gsubrs.length<33900?1131:32768;this.subrsBias=this.subrs.length<1240?107:this.subrs.length<33900?1131:32768}Util.inherit(Type2Compiled, +CompiledFont,{compileGlyphImpl:function(code,js){compileCharString(code,js,this)}});return{create:function FontRendererFactory_create(font){var data=new Uint8Array(font.data);var cmap,glyf,loca,cff,indexToLocFormat,unitsPerEm;var numTables=getUshort(data,4);for(var i=0,p=12;imax?max:value}function PDFImage(xref,res,image,inline,smask,mask,isMask){this.image=image;var dict=image.dict;if(dict.has("Filter")){var filter=dict.get("Filter").name;if(filter==="JPXDecode"){var jpxImage=new JpxImage;jpxImage.parseImageProperties(image.stream);image.stream.reset();image.bitsPerComponent=jpxImage.bitsPerComponent;image.numComps=jpxImage.componentsCount}else if(filter==="JBIG2Decode"){image.bitsPerComponent= +1;image.numComps=1}}this.width=dict.get("Width","W");this.height=dict.get("Height","H");if(this.width<1||this.height<1)error("Invalid image width: "+this.width+" or height: "+this.height);this.interpolate=dict.get("Interpolate","I")||false;this.imageMask=dict.get("ImageMask","IM")||false;this.matte=dict.get("Matte")||false;var bitsPerComponent=image.bitsPerComponent;if(!bitsPerComponent){bitsPerComponent=dict.get("BitsPerComponent","BPC");if(!bitsPerComponent)if(this.imageMask)bitsPerComponent=1; +else error("Bits per component missing in image: "+this.imageMask)}this.bpc=bitsPerComponent;if(!this.imageMask){var colorSpace=dict.get("ColorSpace","CS");if(!colorSpace){info("JPX images (which do not require color spaces)");switch(image.numComps){case 1:colorSpace=Name.get("DeviceGray");break;case 3:colorSpace=Name.get("DeviceRGB");break;case 4:colorSpace=Name.get("DeviceCMYK");break;default:error("JPX images with "+this.numComps+" color components not supported.")}}this.colorSpace=ColorSpace.parse(colorSpace, +xref,res);this.numComps=this.colorSpace.numComps}this.decode=dict.get("Decode","D");this.needsDecode=false;if(this.decode&&(this.colorSpace&&!this.colorSpace.isDefaultDecode(this.decode)||isMask&&!ColorSpace.isDefaultDecode(this.decode,1))){this.needsDecode=true;var max=(1<>3)*height;var actualLength=imgArray.byteLength;var haveFullData=computedLength===actualLength;var data,i;if(imageIsFromDecodeStream&&(!inverseDecode||haveFullData))data=imgArray;else if(!inverseDecode){data=new Uint8Array(actualLength);data.set(imgArray)}else{data=new Uint8Array(computedLength);data.set(imgArray);for(i=actualLength;i>7&1;output[i+1]=buf>>6&1;output[i+2]=buf>>5&1;output[i+3]=buf>>4&1;output[i+4]=buf>>3&1;output[i+5]=buf>>2&1;output[i+6]=buf>>1&1;output[i+7]=buf&1;i+=8}if(i>=1}}}}else{var bits=0;buf=0;for(i=0,ii=length;i< +ii;++i){if(i%rowComps===0){buf=0;bits=0}while(bits>remainingBits;output[i]=value<0?0:value>max?max:value;buf=buf&(1<mask[maskOffset+1]){opacity=255;break}}alphaBuf[i]=opacity}}else error("Unknown mask format.");if(alphaBuf)for(i=0,j=3,ii=width*actualHeight;i=255?255:r|0;buffer[i+1]=g<=0?0:g>=255?255:g|0;buffer[i+2]=b<=0?0:b>=255?255:b|0}},createImageData:function PDFImage_createImageData(forceRGBA){var drawWidth= +this.drawWidth;var drawHeight=this.drawHeight;var imgData={width:drawWidth,height:drawHeight};var numComps=this.numComps;var originalWidth=this.width;var originalHeight=this.height;var bpc=this.bpc;var rowBytes=originalWidth*numComps*bpc+7>>3;var imgArray;if(!forceRGBA){var kind;if(this.colorSpace.name==="DeviceGray"&&bpc===1)kind=ImageKind.GRAYSCALE_1BPP;else if(this.colorSpace.name==="DeviceRGB"&&bpc===8&&!this.needsDecode)kind=ImageKind.RGB_24BPP;if(kind&&!this.smask&&!this.mask&&drawWidth===originalWidth&& +drawHeight===originalHeight){imgData.kind=kind;imgArray=this.getImageBytes(originalHeight*rowBytes);if(this.image instanceof DecodeStream)imgData.data=imgArray;else{var newArray=new Uint8Array(imgArray.length);newArray.set(imgArray);imgData.data=newArray}if(this.needsDecode){assert(kind===ImageKind.GRAYSCALE_1BPP);var buffer=imgData.data;for(var i=0,ii=buffer.length;i>3;var imgArray=this.getImageBytes(height*rowBytes);var comps=this.getComponents(imgArray);var i,length;if(bpc===1){length=width*height;if(this.needsDecode)for(i=0;i>")&&!isEOF(this.buf1)){if(!isName(this.buf1)){info("Malformed dictionary: key must be a name object");this.shift();continue}var key=this.buf1.name;this.shift();if(isEOF(this.buf1))break; +dict.set(key,this.getObj(cipherTransform))}if(isEOF(this.buf1))error("End of file inside dictionary");if(isCmd(this.buf2,"stream"))return this.allowStreams?this.makeStream(dict,cipherTransform):dict;this.shift();return dict;default:return buf1}if(isInt(buf1)){var num=buf1;if(isInt(this.buf1)&&isCmd(this.buf2,"R")){var ref=new Ref(num,this.buf1);this.shift();this.shift();return ref}return num}if(isString(buf1)){var str=buf1;if(cipherTransform)str=cipherTransform.decryptString(str);return str}return buf1}, +makeInlineImage:function Parser_makeInlineImage(cipherTransform){var lexer=this.lexer;var stream=lexer.stream;var dict=new Dict(null);while(!isCmd(this.buf1,"ID")&&!isEOF(this.buf1)){if(!isName(this.buf1))error("Dictionary key must be a name object");var key=this.buf1.name;this.shift();if(isEOF(this.buf1))break;dict.set(key,this.getObj(cipherTransform))}var startPos=stream.pos;var state=0,ch,i,ii;var E=69,I=73,SPACE=32,NL=10,CR=13;while((ch=stream.getByte())!==-1)if(state===0)state=ch===E?1:0;else if(state=== +1)state=ch===I?2:0;else{assert(state===2);if(ch===SPACE||ch===NL||ch===CR){var n=5;var followingBytes=stream.peekBytes(n);for(i=0;i127)){state=0;break}}if(state===2)break}else state=0}var length=stream.pos-4-startPos;var imageStream=stream.makeSubStream(startPos,length,dict);var MAX_LENGTH_TO_CACHE=1E3;var cacheImage=false,adler32;if(length=ENDSTREAM_SIGNATURE_LENGTH){i++;found=true;break}}}if(found){skipped+=i-ENDSTREAM_SIGNATURE_LENGTH;stream.pos+=i-ENDSTREAM_SIGNATURE_LENGTH;break}skipped+=scanLength;stream.pos+=scanLength}if(!found)error("Missing endstream");length=skipped;lexer.nextChar();this.shift();this.shift()}this.shift();stream=stream.makeSubStream(pos,length,dict);if(cipherTransform)stream=cipherTransform.createStream(stream, +length);stream=this.filter(stream,dict,length);stream.dict=dict;return stream},filter:function Parser_filter(stream,dict,length){var filter=this.fetchIfRef(dict.get("Filter","F"));var params=this.fetchIfRef(dict.get("DecodeParms","DP"));if(isName(filter))return this.makeFilter(stream,filter.name,length,params);var maybeLength=length;if(isArray(filter)){var filterArray=filter;var paramsArray=params;for(var i=0,ii=filterArray.length;i=48&&ch<=57)return ch&15;if(ch>=65&&ch<=70||ch>=97&&ch<=102)return(ch&15)+9;return-1}Lexer.prototype={nextChar:function Lexer_nextChar(){return this.currentChar= +this.stream.getByte()},peekChar:function Lexer_peekChar(){return this.stream.peekByte()},getNumber:function Lexer_getNumber(){var ch=this.currentChar;var eNotation=false;var divideBy=0;var sign=1;if(ch===45){sign=-1;ch=this.nextChar()}else if(ch===43)ch=this.nextChar();if(ch===46){divideBy=10;ch=this.nextChar()}if(ch<48||ch>57){error("Invalid number: "+String.fromCharCode(ch));return 0}var baseValue=ch-48;var powerValue=0;var powerValueSign=1;while((ch=this.nextChar())>=0)if(48<=ch&&ch<=57){var currentDigit= +ch-48;if(eNotation)powerValue=powerValue*10+currentDigit;else{if(divideBy!==0)divideBy*=10;baseValue=baseValue*10+currentDigit}}else if(ch===46)if(divideBy===0)divideBy=1;else break;else if(ch===45)warn("Badly formated number");else if(ch===69||ch===101){ch=this.peekChar();if(ch===43||ch===45){powerValueSign=ch===45?-1:1;this.nextChar()}else if(ch<48||ch>57)break;eNotation=true}else break;if(divideBy!==0)baseValue/=divideBy;if(eNotation)baseValue*=Math.pow(10,powerValueSign*powerValue);return sign* +baseValue},getString:function Lexer_getString(){var numParen=1;var done=false;var strBuf=this.strBuf;strBuf.length=0;var ch=this.nextChar();while(true){var charBuffered=false;switch(ch|0){case -1:warn("Unterminated string");done=true;break;case 40:++numParen;strBuf.push("(");break;case 41:if(--numParen===0){this.nextChar();done=true}else strBuf.push(")");break;case 92:ch=this.nextChar();switch(ch){case -1:warn("Unterminated string");done=true;break;case 110:strBuf.push("\n");break;case 114:strBuf.push("\r"); +break;case 116:strBuf.push("\t");break;case 98:strBuf.push("\b");break;case 102:strBuf.push("\f");break;case 92:case 40:case 41:strBuf.push(String.fromCharCode(ch));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:var x=ch&15;ch=this.nextChar();charBuffered=true;if(ch>=48&&ch<=55){x=(x<<3)+(ch&15);ch=this.nextChar();if(ch>=48&&ch<=55){charBuffered=false;x=(x<<3)+(ch&15)}}strBuf.push(String.fromCharCode(x));break;case 13:if(this.peekChar()===10)this.nextChar();break;case 10:break; +default:strBuf.push(String.fromCharCode(ch));break}break;default:strBuf.push(String.fromCharCode(ch));break}if(done)break;if(!charBuffered)ch=this.nextChar()}return strBuf.join("")},getName:function Lexer_getName(){var ch;var strBuf=this.strBuf;strBuf.length=0;while((ch=this.nextChar())>=0&&!specialChars[ch])if(ch===35){ch=this.nextChar();var x=toHexDigit(ch);if(x!==-1){var x2=toHexDigit(this.nextChar());if(x2===-1)error("Illegal digit in hex char in name: "+x2);strBuf.push(String.fromCharCode(x<< +4|x2))}else strBuf.push("#",String.fromCharCode(ch))}else strBuf.push(String.fromCharCode(ch));if(strBuf.length>128)error("Warning: name token is longer than allowed by the spec: "+strBuf.length);return Name.get(strBuf.join(""))},getHexString:function Lexer_getHexString(){var strBuf=this.strBuf;strBuf.length=0;var ch=this.currentChar;var isFirstHex=true;var firstDigit;var secondDigit;while(true)if(ch<0){warn("Unterminated hex string");break}else if(ch===62){this.nextChar();break}else if(specialChars[ch]=== +1){ch=this.nextChar();continue}else{if(isFirstHex){firstDigit=toHexDigit(ch);if(firstDigit===-1){warn('Ignoring invalid character "'+ch+'" in hex string');ch=this.nextChar();continue}}else{secondDigit=toHexDigit(ch);if(secondDigit===-1){warn('Ignoring invalid character "'+ch+'" in hex string');ch=this.nextChar();continue}strBuf.push(String.fromCharCode(firstDigit<<4|secondDigit))}isFirstHex=!isFirstHex;ch=this.nextChar()}return strBuf.join("")},getObj:function Lexer_getObj(){var comment=false;var ch= +this.currentChar;while(true){if(ch<0)return EOF;if(comment){if(ch===10||ch===13)comment=false}else if(ch===37)comment=true;else if(specialChars[ch]!==1)break;ch=this.nextChar()}switch(ch|0){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return this.getNumber();case 40:return this.getString();case 47:return this.getName();case 91:this.nextChar();return Cmd.get("[");case 93:this.nextChar();return Cmd.get("]");case 60:ch=this.nextChar();if(ch=== +60){this.nextChar();return Cmd.get("<<")}return this.getHexString();case 62:ch=this.nextChar();if(ch===62){this.nextChar();return Cmd.get(">>")}return Cmd.get(">");case 123:this.nextChar();return Cmd.get("{");case 125:this.nextChar();return Cmd.get("}");case 41:error("Illegal character: "+ch);break}var str=String.fromCharCode(ch);var knownCommands=this.knownCommands;var knownCommandFound=knownCommands&&knownCommands[str]!==undefined;while((ch=this.nextChar())>=0&&!specialChars[ch]){var possibleCommand= +str+String.fromCharCode(ch);if(knownCommandFound&&knownCommands[possibleCommand]===undefined)break;if(str.length===128)error("Command token too long: "+str.length);str=possibleCommand;knownCommandFound=knownCommands&&knownCommands[str]!==undefined}if(str==="true")return true;if(str==="false")return false;if(str==="null")return null;return Cmd.get(str)},skipToNextLine:function Lexer_skipToNextLine(){var ch=this.currentChar;while(ch>=0){if(ch===13){ch=this.nextChar();if(ch===10)this.nextChar();break}else if(ch=== +10){this.nextChar();break}ch=this.nextChar()}}};return Lexer}();var Linearization={create:function LinearizationCreate(stream){function getInt(name,allowZeroValue){var obj=linDict.get(name);if(isInt(obj)&&(allowZeroValue?obj>=0:obj>0))return obj;throw new Error('The "'+name+'" parameter in the linearization '+"dictionary is invalid.");}function getHints(){var hints=linDict.get("H"),hintsLength,item;if(isArray(hints)&&((hintsLength=hints.length)===2||hintsLength===4)){for(var index=0;index0))throw new Error("Hint ("+index+") in the linearization dictionary is invalid.");return hints}throw new Error("Hint array in the linearization dictionary is invalid.");}var parser=new Parser(new Lexer(stream),false,null);var obj1=parser.getObj();var obj2=parser.getObj();var obj3=parser.getObj();var linDict=parser.getObj();var obj,length;if(!(isInt(obj1)&&isInt(obj2)&&isCmd(obj3,"obj")&&isDict(linDict)&&isNum(obj=linDict.get("Linearized"))&&obj>0))return null;else if((length= +getInt("L"))!==stream.length)throw new Error('The "L" parameter in the linearization dictionary '+"does not equal the stream length.");return{length:length,hints:getHints(),objectNumberFirst:getInt("O"),endFirst:getInt("E"),numPages:getInt("N"),mainXRefEntriesOffset:getInt("T"),pageFirst:linDict.has("P")?getInt("P",true):0}}};var PostScriptParser=function PostScriptParserClosure(){function PostScriptParser(lexer){this.lexer=lexer;this.operators=[];this.token=null;this.prev=null}PostScriptParser.prototype= +{nextToken:function PostScriptParser_nextToken(){this.prev=this.token;this.token=this.lexer.getToken()},accept:function PostScriptParser_accept(type){if(this.token.type===type){this.nextToken();return true}return false},expect:function PostScriptParser_expect(type){if(this.accept(type))return true;error("Unexpected symbol: found "+this.token.type+" expected "+type+".")},parse:function PostScriptParser_parse(){this.nextToken();this.expect(PostScriptTokenTypes.LBRACE);this.parseBlock();this.expect(PostScriptTokenTypes.RBRACE); +return this.operators},parseBlock:function PostScriptParser_parseBlock(){while(true)if(this.accept(PostScriptTokenTypes.NUMBER))this.operators.push(this.prev.value);else if(this.accept(PostScriptTokenTypes.OPERATOR))this.operators.push(this.prev.value);else if(this.accept(PostScriptTokenTypes.LBRACE))this.parseCondition();else return},parseCondition:function PostScriptParser_parseCondition(){var conditionLocation=this.operators.length;this.operators.push(null,null);this.parseBlock();this.expect(PostScriptTokenTypes.RBRACE); +if(this.accept(PostScriptTokenTypes.IF)){this.operators[conditionLocation]=this.operators.length;this.operators[conditionLocation+1]="jz"}else if(this.accept(PostScriptTokenTypes.LBRACE)){var jumpLocation=this.operators.length;this.operators.push(null,null);var endOfTrue=this.operators.length;this.parseBlock();this.expect(PostScriptTokenTypes.RBRACE);this.expect(PostScriptTokenTypes.IFELSE);this.operators[jumpLocation]=this.operators.length;this.operators[jumpLocation+1]="j";this.operators[conditionLocation]= +endOfTrue;this.operators[conditionLocation+1]="jz"}else error("PS Function: error parsing conditional.")}};return PostScriptParser}();var PostScriptTokenTypes={LBRACE:0,RBRACE:1,NUMBER:2,OPERATOR:3,IF:4,IFELSE:5};var PostScriptToken=function PostScriptTokenClosure(){function PostScriptToken(type,value){this.type=type;this.value=value}var opCache={};PostScriptToken.getOperator=function PostScriptToken_getOperator(op){var opValue=opCache[op];if(opValue)return opValue;return opCache[op]=new PostScriptToken(PostScriptTokenTypes.OPERATOR, +op)};PostScriptToken.LBRACE=new PostScriptToken(PostScriptTokenTypes.LBRACE,"{");PostScriptToken.RBRACE=new PostScriptToken(PostScriptTokenTypes.RBRACE,"}");PostScriptToken.IF=new PostScriptToken(PostScriptTokenTypes.IF,"IF");PostScriptToken.IFELSE=new PostScriptToken(PostScriptTokenTypes.IFELSE,"IFELSE");return PostScriptToken}();var PostScriptLexer=function PostScriptLexerClosure(){function PostScriptLexer(stream){this.stream=stream;this.nextChar();this.strBuf=[]}PostScriptLexer.prototype={nextChar:function PostScriptLexer_nextChar(){return this.currentChar= +this.stream.getByte()},getToken:function PostScriptLexer_getToken(){var comment=false;var ch=this.currentChar;while(true){if(ch<0)return EOF;if(comment){if(ch===10||ch===13)comment=false}else if(ch===37)comment=true;else if(!Lexer.isSpace(ch))break;ch=this.nextChar()}switch(ch|0){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return new PostScriptToken(PostScriptTokenTypes.NUMBER,this.getNumber());case 123:this.nextChar();return PostScriptToken.LBRACE; +case 125:this.nextChar();return PostScriptToken.RBRACE}var strBuf=this.strBuf;strBuf.length=0;strBuf[0]=String.fromCharCode(ch);while((ch=this.nextChar())>=0&&(ch>=65&&ch<=90||ch>=97&&ch<=122))strBuf.push(String.fromCharCode(ch));var str=strBuf.join("");switch(str.toLowerCase()){case "if":return PostScriptToken.IF;case "ifelse":return PostScriptToken.IFELSE;default:return PostScriptToken.getOperator(str)}},getNumber:function PostScriptLexer_getNumber(){var ch=this.currentChar;var strBuf=this.strBuf; +strBuf.length=0;strBuf[0]=String.fromCharCode(ch);while((ch=this.nextChar())>=0)if(ch>=48&&ch<=57||ch===45||ch===46)strBuf.push(String.fromCharCode(ch));else break;var value=parseFloat(strBuf.join(""));if(isNaN(value))error("Invalid floating point number: "+value);return value}};return PostScriptLexer}();var Stream=function StreamClosure(){function Stream(arrayBuffer,start,length,dict){this.bytes=arrayBuffer instanceof Uint8Array?arrayBuffer:new Uint8Array(arrayBuffer);this.start=start||0;this.pos= +this.start;this.end=start+length||this.bytes.length;this.dict=dict}Stream.prototype={get length(){return this.end-this.start},get isEmpty(){return this.length===0},getByte:function Stream_getByte(){if(this.pos>=this.end)return-1;return this.bytes[this.pos++]},getUint16:function Stream_getUint16(){var b0=this.getByte();var b1=this.getByte();return(b0<<8)+b1},getInt32:function Stream_getInt32(){var b0=this.getByte();var b1=this.getByte();var b2=this.getByte();var b3=this.getByte();return(b0<<24)+(b1<< +16)+(b2<<8)+b3},getBytes:function Stream_getBytes(length){var bytes=this.bytes;var pos=this.pos;var strEnd=this.end;if(!length)return bytes.subarray(pos,strEnd);var end=pos+length;if(end>strEnd)end=strEnd;this.pos=end;return bytes.subarray(pos,end)},peekByte:function Stream_peekByte(){var peekedByte=this.getByte();this.pos--;return peekedByte},peekBytes:function Stream_peekBytes(length){var bytes=this.getBytes(length);this.pos-=bytes.length;return bytes},skip:function Stream_skip(n){if(!n)n=1;this.pos+= +n},reset:function Stream_reset(){this.pos=this.start},moveStart:function Stream_moveStart(){this.start=this.pos},makeSubStream:function Stream_makeSubStream(start,length,dict){return new Stream(this.bytes.buffer,start,length,dict)},isStream:true};return Stream}();var StringStream=function StringStreamClosure(){function StringStream(str){var length=str.length;var bytes=new Uint8Array(length);for(var n=0;nbufEnd)end=bufEnd}else{while(!this.eof)this.readBlock();end=this.bufferLength}this.pos=end;return this.buffer.subarray(pos,end)},peekByte:function DecodeStream_peekByte(){var peekedByte= +this.getByte();this.pos--;return peekedByte},peekBytes:function DecodeStream_peekBytes(length){var bytes=this.getBytes(length);this.pos-=bytes.length;return bytes},makeSubStream:function DecodeStream_makeSubStream(start,length,dict){var end=start+length;while(this.bufferLength<=end&&!this.eof)this.readBlock();return new Stream(this.buffer,start,length,dict)},skip:function DecodeStream_skip(n){if(!n)n=1;this.pos+=n},reset:function DecodeStream_reset(){this.pos=0},getBaseStreams:function DecodeStream_getBaseStreams(){if(this.str&& +this.str.getBaseStreams)return this.str.getBaseStreams();return[]}};return DecodeStream}();var StreamsSequenceStream=function StreamsSequenceStreamClosure(){function StreamsSequenceStream(streams){this.streams=streams;DecodeStream.call(this,null)}StreamsSequenceStream.prototype=Object.create(DecodeStream.prototype);StreamsSequenceStream.prototype.readBlock=function streamSequenceStreamReadBlock(){var streams=this.streams;if(streams.length===0){this.eof=true;return}var stream=streams.shift();var chunk= +stream.getBytes();var bufferLength=this.bufferLength;var newLength=bufferLength+chunk.length;var buffer=this.ensureBuffer(newLength);buffer.set(chunk,bufferLength);this.bufferLength=newLength};StreamsSequenceStream.prototype.getBaseStreams=function StreamsSequenceStream_getBaseStreams(){var baseStreams=[];for(var i=0,ii=this.streams.length;i>bits;this.codeSize=codeSize-=bits;return b};FlateStream.prototype.getCode=function FlateStream_getCode(table){var str=this.str;var codes=table[0];var maxLen=table[1];var codeSize=this.codeSize;var codeBuf=this.codeBuf;var b;while(codeSize>16;var codeVal=code&65535;if(codeLen<1||codeSize>codeLen;this.codeSize=codeSize-codeLen;return codeVal};FlateStream.prototype.generateHuffmanTable=function flateStreamGenerateHuffmanTable(lengths){var n=lengths.length;var maxLen=0;var i;for(i=0;imaxLen)maxLen=lengths[i];var size=1<>=1}for(i=code2;i>=1;if(hdr===0){var b;if((b=str.getByte())===-1)error("Bad block header in flate stream");var blockLen=b;if((b= +str.getByte())===-1)error("Bad block header in flate stream");blockLen|=b<<8;if((b=str.getByte())===-1)error("Bad block header in flate stream");var check=b;if((b=str.getByte())===-1)error("Bad block header in flate stream");check|=b<<8;if(check!==(~blockLen&65535)&&(blockLen!==0||check!==0))error("Bad uncompressed block length in flate stream");this.codeBuf=0;this.codeSize=0;var bufferLength=this.bufferLength;buffer=this.ensureBuffer(bufferLength+blockLen);var end=bufferLength+blockLen;this.bufferLength= +end;if(blockLen===0){if(str.peekByte()===-1)this.eof=true}else for(var n=bufferLength;n0)codeLengths[i++]=what}litCodeTable=this.generateHuffmanTable(codeLengths.subarray(0,numLitCodes));distCodeTable=this.generateHuffmanTable(codeLengths.subarray(numLitCodes,codes))}else error("Unknown block type in flate stream");buffer=this.buffer;var limit=buffer?buffer.length:0;var pos=this.bufferLength;while(true){var code1=this.getCode(litCodeTable);if(code1<256){if(pos+1>=limit){buffer=this.ensureBuffer(pos+1);limit=buffer.length}buffer[pos++]=code1;continue}if(code1=== +256){this.bufferLength=pos;return}code1-=257;code1=lengthDecode[code1];var code2=code1>>16;if(code2>0)code2=this.getBits(code2);len=(code1&65535)+code2;code1=this.getCode(distCodeTable);code1=distDecode[code1];code2=code1>>16;if(code2>0)code2=this.getBits(code2);var dist=(code1&65535)+code2;if(pos+len>=limit){buffer=this.ensureBuffer(pos+len);limit=buffer.length}for(var k=0;k15))error("Unsupported predictor: "+predictor);if(predictor===2)this.readBlock=this.readBlockTiff;else this.readBlock=this.readBlockPng;this.str=str;this.dict=str.dict;var colors=this.colors=params.get("Colors")||1;var bits=this.bits=params.get("BitsPerComponent")||8;var columns=this.columns=params.get("Columns")||1;this.pixBytes=colors*bits+7>>3;this.rowBytes= +columns*colors*bits+7>>3;DecodeStream.call(this,maybeLength);return this}PredictorStream.prototype=Object.create(DecodeStream.prototype);PredictorStream.prototype.readBlockTiff=function predictorStreamReadBlockTiff(){var rowBytes=this.rowBytes;var bufferLength=this.bufferLength;var buffer=this.ensureBuffer(bufferLength+rowBytes);var bits=this.bits;var colors=this.colors;var rawBytes=this.str.getBytes(rowBytes);this.eof=!rawBytes.length;if(this.eof)return;var inbuf=0,outbuf=0;var inbits=0,outbits= +0;var pos=bufferLength;var i;if(bits===1)for(i=0;i>colors)&255;inbuf&=65535}else if(bits===8){for(i=0;i>inbits-bits)&bitMask;inbits-=bits;outbuf=outbuf<=8){buffer[k++]=outbuf>>outbits-8&255;outbits-=8}}if(outbits>0)buffer[k++]=(outbuf<<8-outbits)+(inbuf&(1<<8-outbits)-1)}this.bufferLength+=rowBytes};PredictorStream.prototype.readBlockPng=function predictorStreamReadBlockPng(){var rowBytes=this.rowBytes;var pixBytes=this.pixBytes;var predictor=this.str.getByte();var rawBytes=this.str.getBytes(rowBytes);this.eof= +!rawBytes.length;if(this.eof)return;var bufferLength=this.bufferLength;var buffer=this.ensureBuffer(bufferLength+rowBytes);var prevRow=buffer.subarray(bufferLength-rowBytes,bufferLength);if(prevRow.length===0)prevRow=new Uint8Array(rowBytes);var i,j=bufferLength,up,c;switch(predictor){case 0:for(i=0;i>1)+rawBytes[i];for(;i>1)+rawBytes[i]&255;j++}break;case 4:for(i=0;i1)warn("JBIG2 - 'DecodeParms' array with multiple elements "+"not supported.");decodeParams=xref.fetchIfRef(decodeParams[0])}if(decodeParams&&decodeParams.has("JBIG2Globals")){var globalsStream=decodeParams.get("JBIG2Globals");var globals=globalsStream.getBytes();chunks.push({data:globals,start:0,end:globals.length})}chunks.push({data:this.bytes, +start:0,end:this.bytes.length});var data=jbig2Image.parseChunks(chunks);var dataLength=data.length;for(var i=0;i0;var decrypt=this.decrypt;chunk=decrypt(chunk,!hasMoreData);var bufferLength=this.bufferLength;var i,n=chunk.length;var buffer=this.ensureBuffer(bufferLength+n);for(i=0;i< +n;i++)buffer[bufferLength++]=chunk[i];this.bufferLength=bufferLength};return DecryptStream}();var Ascii85Stream=function Ascii85StreamClosure(){function Ascii85Stream(str,maybeLength){this.str=str;this.dict=str.dict;this.input=new Uint8Array(5);if(maybeLength)maybeLength=.8*maybeLength;DecodeStream.call(this,maybeLength)}Ascii85Stream.prototype=Object.create(DecodeStream.prototype);Ascii85Stream.prototype.readBlock=function Ascii85Stream_readBlock(){var TILDA_CHAR=126;var Z_LOWER_CHAR=122;var EOF= +-1;var str=this.str;var c=str.getByte();while(Lexer.isSpace(c))c=str.getByte();if(c===EOF||c===TILDA_CHAR){this.eof=true;return}var bufferLength=this.bufferLength,buffer;var i;if(c===Z_LOWER_CHAR){buffer=this.ensureBuffer(bufferLength+4);for(i=0;i<4;++i)buffer[bufferLength+i]=0;this.bufferLength+=4}else{var input=this.input;input[0]=c;for(i=1;i<5;++i){c=str.getByte();while(Lexer.isSpace(c))c=str.getByte();input[i]=c;if(c===EOF||c===TILDA_CHAR)break}buffer=this.ensureBuffer(bufferLength+i-1);this.bufferLength+= +i-1;if(i<5){for(;i<5;++i)input[i]=33+84;this.eof=true}var t=0;for(i=0;i<5;++i)t=t*85+(input[i]-33);for(i=3;i>=0;--i){buffer[bufferLength+i]=t&255;t>>=8}}};return Ascii85Stream}();var AsciiHexStream=function AsciiHexStreamClosure(){function AsciiHexStream(str,maybeLength){this.str=str;this.dict=str.dict;this.firstDigit=-1;if(maybeLength)maybeLength=.5*maybeLength;DecodeStream.call(this,maybeLength)}AsciiHexStream.prototype=Object.create(DecodeStream.prototype);AsciiHexStream.prototype.readBlock=function AsciiHexStream_readBlock(){var UPSTREAM_BLOCK_SIZE= +8E3;var bytes=this.str.getBytes(UPSTREAM_BLOCK_SIZE);if(!bytes.length){this.eof=true;return}var maxDecodeLength=bytes.length+1>>1;var buffer=this.ensureBuffer(this.bufferLength+maxDecodeLength);var bufferLength=this.bufferLength;var firstDigit=this.firstDigit;for(var i=0,ii=bytes.length;i=48&&ch<=57)digit=ch&15;else if(ch>=65&&ch<=70||ch>=97&&ch<=102)digit=(ch&15)+9;else if(ch===62){this.eof=true;break}else continue;if(firstDigit<0)firstDigit=digit;else{buffer[bufferLength++]= +firstDigit<<4|digit;firstDigit=-1}}if(firstDigit>=0&&this.eof){buffer[bufferLength++]=firstDigit<<4;firstDigit=-1}this.firstDigit=firstDigit;this.bufferLength=bufferLength};return AsciiHexStream}();var RunLengthStream=function RunLengthStreamClosure(){function RunLengthStream(str,maybeLength){this.str=str;this.dict=str.dict;DecodeStream.call(this,maybeLength)}RunLengthStream.prototype=Object.create(DecodeStream.prototype);RunLengthStream.prototype.readBlock=function RunLengthStream_readBlock(){var repeatHeader= +this.str.getBytes(2);if(!repeatHeader||repeatHeader.length<2||repeatHeader[0]===128){this.eof=true;return}var buffer;var bufferLength=this.bufferLength;var n=repeatHeader[0];if(n<128){buffer=this.ensureBuffer(bufferLength+n+1);buffer[bufferLength++]=repeatHeader[1];if(n>0){var source=this.str.getBytes(n);buffer.set(source,bufferLength);bufferLength+=n}}else{n=257-n;var b=repeatHeader[1];buffer=this.ensureBuffer(bufferLength+n+1);for(var i=0;i0){this.nextLine2D=!this.lookBits(1);this.eatBits(1)}DecodeStream.call(this,maybeLength)}CCITTFaxStream.prototype=Object.create(DecodeStream.prototype);CCITTFaxStream.prototype.readBlock= +function CCITTFaxStream_readBlock(){while(!this.eof){var c=this.lookChar();this.ensureBuffer(this.bufferLength+1);this.buffer[this.bufferLength++]=c}};CCITTFaxStream.prototype.addPixels=function ccittFaxStreamAddPixels(a1,blackPixels){var codingLine=this.codingLine;var codingPos=this.codingPos;if(a1>codingLine[codingPos]){if(a1>this.columns){info("row is wrong length");this.err=true;a1=this.columns}if(codingPos&1^blackPixels)++codingPos;codingLine[codingPos]=a1}this.codingPos=codingPos};CCITTFaxStream.prototype.addPixelsNeg= +function ccittFaxStreamAddPixelsNeg(a1,blackPixels){var codingLine=this.codingLine;var codingPos=this.codingPos;if(a1>codingLine[codingPos]){if(a1>this.columns){info("row is wrong length");this.err=true;a1=this.columns}if(codingPos&1^blackPixels)++codingPos;codingLine[codingPos]=a1}else if(a10&&a1=64);do code2+=code3=this.getWhiteCode();while(code3>=64)}else{do code1+=code3=this.getWhiteCode();while(code3>=64);do code2+=code3=this.getBlackCode();while(code3>=64)}this.addPixels(codingLine[this.codingPos]+code1,blackPixels);if(codingLine[this.codingPos]0)--refPos;else++refPos;while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]0)--refPos;else++refPos;while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]0)--refPos;else++refPos;while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]=64)}else{do code1+=code3=this.getWhiteCode();while(code3>=64)}this.addPixels(codingLine[this.codingPos]+ +code1,blackPixels);blackPixels^=1}}var gotEOL=false;if(!this.eoblock&&this.row===this.rows-1)this.eof=true;else if(this.eoline||!this.byteAlign){code1=this.lookBits(12);if(this.eoline)while(code1!==EOF&&code1!==1){this.eatBits(1);code1=this.lookBits(12)}else while(code1===0){this.eatBits(1);code1=this.lookBits(12)}if(code1===1){this.eatBits(12);gotEOL=true}else if(code1===EOF)this.eof=true}if(this.byteAlign&&!gotEOL)this.inputBits&=~7;if(!this.eof&&this.encoding>0){this.nextLine2D=!this.lookBits(1); +this.eatBits(1)}if(this.eoblock&&gotEOL&&this.byteAlign){code1=this.lookBits(12);if(code1===1){this.eatBits(12);if(this.encoding>0){this.lookBits(1);this.eatBits(1)}if(this.encoding>=0)for(i=0;i<4;++i){code1=this.lookBits(12);if(code1!==1)info("bad rtc code: "+code1);this.eatBits(12);if(this.encoding>0){this.lookBits(1);this.eatBits(1)}}this.eof=true}}else if(this.err&&this.eoline){while(true){code1=this.lookBits(13);if(code1===EOF){this.eof=true;return null}if(code1>>1===1)break;this.eatBits(1)}this.eatBits(12); +if(this.encoding>0){this.eatBits(1);this.nextLine2D=!(code1&1)}}if(codingLine[0]>0)this.outputBits=codingLine[this.codingPos=0];else this.outputBits=codingLine[this.codingPos=1];this.row++}var c;if(this.outputBits>=8){c=this.codingPos&1?0:255;this.outputBits-=8;if(this.outputBits===0&&codingLine[this.codingPos]bits){c<<=bits;if(!(this.codingPos&1))c|=255>>8-bits; +this.outputBits-=bits;bits=0}else{c<<=this.outputBits;if(!(this.codingPos&1))c|=255>>8-this.outputBits;bits-=this.outputBits;this.outputBits=0;if(codingLine[this.codingPos]0){c<<=bits;bits=0}}while(bits)}if(this.black)c^=255;return c};CCITTFaxStream.prototype.findTableCode=function ccittFaxStreamFindTableCode(start,end,table,limit){var limitValue=limit||0;for(var i=start;i<=end;++i){var code= +this.lookBits(i);if(code===EOF)return[true,1,false];if(i=limitValue){var p=table[code-limitValue];if(p[0]===i){this.eatBits(i);return[true,p[1],true]}}}return[false,0,false]};CCITTFaxStream.prototype.getTwoDimCode=function ccittFaxStreamGetTwoDimCode(){var code=0;var p;if(this.eoblock){code=this.lookBits(7);p=twoDimTable[code];if(p&&p[0]>0){this.eatBits(p[0]);return p[1]}}else{var result=this.findTableCode(1,7,twoDimTable);if(result[0]&&result[2])return result[1]}info("Bad two dim code"); +return EOF};CCITTFaxStream.prototype.getWhiteCode=function ccittFaxStreamGetWhiteCode(){var code=0;var p;if(this.eoblock){code=this.lookBits(12);if(code===EOF)return 1;if(code>>5===0)p=whiteTable1[code];else p=whiteTable2[code>>3];if(p[0]>0){this.eatBits(p[0]);return p[1]}}else{var result=this.findTableCode(1,9,whiteTable2);if(result[0])return result[1];result=this.findTableCode(11,12,whiteTable1);if(result[0])return result[1]}info("bad white code");this.eatBits(1);return 1};CCITTFaxStream.prototype.getBlackCode= +function ccittFaxStreamGetBlackCode(){var code,p;if(this.eoblock){code=this.lookBits(13);if(code===EOF)return 1;if(code>>7===0)p=blackTable1[code];else if(code>>9===0&&code>>7!==0)p=blackTable2[(code>>1)-64];else p=blackTable3[code>>7];if(p[0]>0){this.eatBits(p[0]);return p[1]}}else{var result=this.findTableCode(2,6,blackTable3);if(result[0])return result[1];result=this.findTableCode(7,12,blackTable2,64);if(result[0])return result[1];result=this.findTableCode(10,13,blackTable1);if(result[0])return result[1]}info("bad black code"); +this.eatBits(1);return 1};CCITTFaxStream.prototype.lookBits=function CCITTFaxStream_lookBits(n){var c;while(this.inputBits>16-n}this.inputBuf=(this.inputBuf<<8)+c;this.inputBits+=8}return this.inputBuf>>this.inputBits-n&65535>>16-n};CCITTFaxStream.prototype.eatBits=function CCITTFaxStream_eatBits(n){if((this.inputBits-=n)<0)this.inputBits=0};return CCITTFaxStream}();var LZWStream=function LZWStreamClosure(){function LZWStream(str, +maybeLength,earlyChange){this.str=str;this.dict=str.dict;this.cachedData=0;this.bitsCached=0;var maxLzwDictionarySize=4096;var lzwState={earlyChange:earlyChange,codeLength:9,nextCode:258,dictionaryValues:new Uint8Array(maxLzwDictionarySize),dictionaryLengths:new Uint16Array(maxLzwDictionarySize),dictionaryPrevCodes:new Uint16Array(maxLzwDictionarySize),currentSequence:new Uint8Array(maxLzwDictionarySize),currentSequenceLength:0};for(var i=0;i<256;++i){lzwState.dictionaryValues[i]=i;lzwState.dictionaryLengths[i]= +1}this.lzwState=lzwState;DecodeStream.call(this,maybeLength)}LZWStream.prototype=Object.create(DecodeStream.prototype);LZWStream.prototype.readBits=function LZWStream_readBits(n){var bitsCached=this.bitsCached;var cachedData=this.cachedData;while(bitsCached>>bitsCached&(1<0;if(code<256){currentSequence[0]=code;currentSequenceLength=1}else if(code>=258)if(code=0;j--){currentSequence[j]=dictionaryValues[q];q=dictionaryPrevCodes[q]}}else currentSequence[currentSequenceLength++]= +currentSequence[0];else if(code===256){codeLength=9;nextCode=258;currentSequenceLength=0;continue}else{this.eof=true;delete this.lzwState;break}if(hasPrev){dictionaryPrevCodes[nextCode]=prevCode;dictionaryLengths[nextCode]=dictionaryLengths[prevCode]+1;dictionaryValues[nextCode]=currentSequence[0];nextCode++;codeLength=nextCode+earlyChange&nextCode+earlyChange-1?codeLength:Math.min(Math.log(nextCode+earlyChange)/.6931471805599453+1,12)|0}prevCode=code;decodedLength+=currentSequenceLength;if(estimatedDecodedSize< +decodedLength){do estimatedDecodedSize+=decodedSizeDelta;while(estimatedDecodedSize>9&127;this.clow=this.clow<<7&65535;this.ct-=7;this.a=32768}ArithmeticDecoder.prototype={byteIn:function ArithmeticDecoder_byteIn(){var data=this.data; +var bp=this.bp;if(data[bp]===255){var b1=data[bp+1];if(b1>143){this.clow+=65280;this.ct=8}else{bp++;this.clow+=data[bp]<<9;this.ct=7;this.bp=bp}}else{bp++;this.clow+=bp65535){this.chigh+=this.clow>>16;this.clow&=65535}},readBit:function ArithmeticDecoder_readBit(contexts,pos){var cx_index=contexts[pos]>>1,cx_mps=contexts[pos]&1;var qeTableIcx=QeTable[cx_index];var qeIcx=qeTableIcx.qe;var d;var a=this.a-qeIcx;if(this.chigh>15&1;this.clow=this.clow<<1&65535;this.ct--}while((a&32768)===0);this.a=a;contexts[pos]=cx_index<< +1|cx_mps;return d}};return ArithmeticDecoder}();var JpegImage=function jpegImage(){var dctZigZag=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);var dctCos1=4017;var dctSin1=799;var dctCos3=3406;var dctSin3=2276;var dctCos6=1567;var dctSin6=3784;var dctSqrt2=5793;var dctSqrt1d2=2896;function constructor(){}function buildHuffmanTable(codeLengths,values){var k= +0,code=[],i,j,length=16;while(length>0&&!codeLengths[length-1])length--;code.push({children:[],index:0});var p=code[0],q;for(i=0;i0)p=code.pop();p.index++;code.push(p);while(code.length<=i){code.push(q={children:[],index:0});p.children[p.index]=q.children;p=q}k++}if(i+10){bitsCount--;return bitsData>>bitsCount&1}bitsData= +data[offset++];if(bitsData===255){var nextByte=data[offset++];if(nextByte)throw"unexpected marker: "+(bitsData<<8|nextByte).toString(16);}bitsCount=7;return bitsData>>>7}function decodeHuffman(tree){var node=tree;var bit;while((bit=readBit())!==null){node=node[bit];if(typeof node==="number")return node;if(typeof node!=="object")throw"invalid huffman sequence";}return null}function receive(length){var n=0;while(length>0){var bit=readBit();if(bit===null)return;n=n<<1|bit;length--}return n}function receiveAndExtend(length){if(length=== +1)return readBit()===1?1:-1;var n=receive(length);if(n>=1<>4;if(s===0){if(r<15)break;k+=16;continue}k+=r;var z=dctZigZag[k];component.blockData[offset+z]=receiveAndExtend(s);k++}}function decodeDCFirst(component, +offset){var t=decodeHuffman(component.huffmanTableDC);var diff=t===0?0:receiveAndExtend(t)<0){eobrun--;return}var k=spectralStart,e=spectralEnd;while(k<=e){var rs=decodeHuffman(component.huffmanTableAC);var s=rs&15,r=rs>>4;if(s===0){if(r<15){eobrun=receive(r)+(1<>4;if(s===0)if(r<15){eobrun=receive(r)+(1<=65488&&marker<=65495)offset+=2;else break}return offset-startOffset}function quantizeAndInverse(component,blockBufferOffset,p){var qt=component.quantizationTable,blockData=component.blockData;var v0,v1,v2,v3,v4,v5,v6,v7;var p0,p1,p2,p3,p4,p5,p6,p7;var t;for(var row=0;row<64;row+=8){p0=blockData[blockBufferOffset+row];p1=blockData[blockBufferOffset+row+1];p2=blockData[blockBufferOffset+row+2];p3=blockData[blockBufferOffset+row+3];p4=blockData[blockBufferOffset+ +row+4];p5=blockData[blockBufferOffset+row+5];p6=blockData[blockBufferOffset+row+6];p7=blockData[blockBufferOffset+row+7];p0*=qt[row];if((p1|p2|p3|p4|p5|p6|p7)===0){t=dctSqrt2*p0+512>>10;p[row]=t;p[row+1]=t;p[row+2]=t;p[row+3]=t;p[row+4]=t;p[row+5]=t;p[row+6]=t;p[row+7]=t;continue}p1*=qt[row+1];p2*=qt[row+2];p3*=qt[row+3];p4*=qt[row+4];p5*=qt[row+5];p6*=qt[row+6];p7*=qt[row+7];v0=dctSqrt2*p0+128>>8;v1=dctSqrt2*p4+128>>8;v2=p2;v3=p6;v4=dctSqrt1d2*(p1-p7)+128>>8;v7=dctSqrt1d2*(p1+p7)+128>>8;v5=p3<<4; +v6=p5<<4;v0=v0+v1+1>>1;v1=v0-v1;t=v2*dctSin6+v3*dctCos6+128>>8;v2=v2*dctCos6-v3*dctSin6+128>>8;v3=t;v4=v4+v6+1>>1;v6=v4-v6;v7=v7+v5+1>>1;v5=v7-v5;v0=v0+v3+1>>1;v3=v0-v3;v1=v1+v2+1>>1;v2=v1-v2;t=v4*dctSin3+v7*dctCos3+2048>>12;v4=v4*dctCos3-v7*dctSin3+2048>>12;v7=t;t=v5*dctSin1+v6*dctCos1+2048>>12;v5=v5*dctCos1-v6*dctSin1+2048>>12;v6=t;p[row]=v0+v7;p[row+7]=v0-v7;p[row+1]=v1+v6;p[row+6]=v1-v6;p[row+2]=v2+v5;p[row+5]=v2-v5;p[row+3]=v3+v4;p[row+4]=v3-v4}for(var col=0;col<8;++col){p0=p[col];p1=p[col+8]; +p2=p[col+16];p3=p[col+24];p4=p[col+32];p5=p[col+40];p6=p[col+48];p7=p[col+56];if((p1|p2|p3|p4|p5|p6|p7)===0){t=dctSqrt2*p0+8192>>14;t=t<-2040?0:t>=2024?255:t+2056>>4;blockData[blockBufferOffset+col]=t;blockData[blockBufferOffset+col+8]=t;blockData[blockBufferOffset+col+16]=t;blockData[blockBufferOffset+col+24]=t;blockData[blockBufferOffset+col+32]=t;blockData[blockBufferOffset+col+40]=t;blockData[blockBufferOffset+col+48]=t;blockData[blockBufferOffset+col+56]=t;continue}v0=dctSqrt2*p0+2048>>12;v1= +dctSqrt2*p4+2048>>12;v2=p2;v3=p6;v4=dctSqrt1d2*(p1-p7)+2048>>12;v7=dctSqrt1d2*(p1+p7)+2048>>12;v5=p3;v6=p5;v0=(v0+v1+1>>1)+4112;v1=v0-v1;t=v2*dctSin6+v3*dctCos6+2048>>12;v2=v2*dctCos6-v3*dctSin6+2048>>12;v3=t;v4=v4+v6+1>>1;v6=v4-v6;v7=v7+v5+1>>1;v5=v7-v5;v0=v0+v3+1>>1;v3=v0-v3;v1=v1+v2+1>>1;v2=v1-v2;t=v4*dctSin3+v7*dctCos3+2048>>12;v4=v4*dctCos3-v7*dctSin3+2048>>12;v7=t;t=v5*dctSin1+v6*dctCos1+2048>>12;v5=v5*dctCos1-v6*dctSin1+2048>>12;v6=t;p0=v0+v7;p7=v0-v7;p1=v1+v6;p6=v1-v6;p2=v2+v5;p5=v2-v5;p3= +v3+v4;p4=v3-v4;p0=p0<16?0:p0>=4080?255:p0>>4;p1=p1<16?0:p1>=4080?255:p1>>4;p2=p2<16?0:p2>=4080?255:p2>>4;p3=p3<16?0:p3>=4080?255:p3>>4;p4=p4<16?0:p4>=4080?255:p4>>4;p5=p5<16?0:p5>=4080?255:p5>>4;p6=p6<16?0:p6>=4080?255:p6>>4;p7=p7<16?0:p7>=4080?255:p7>>4;blockData[blockBufferOffset+col]=p0;blockData[blockBufferOffset+col+8]=p1;blockData[blockBufferOffset+col+16]=p2;blockData[blockBufferOffset+col+24]=p3;blockData[blockBufferOffset+col+32]=p4;blockData[blockBufferOffset+col+40]=p5;blockData[blockBufferOffset+ +col+48]=p6;blockData[blockBufferOffset+col+56]=p7}}function buildComponentData(frame,component){var blocksPerLine=component.blocksPerLine;var blocksPerColumn=component.blocksPerColumn;var computationBuffer=new Int16Array(64);for(var blockRow=0;blockRow=255?255:a}constructor.prototype={parse:function parse(data){function readUint16(){var value=data[offset]<<8|data[offset+1];offset+=2;return value}function readDataBlock(){var length=readUint16();var array=data.subarray(offset,offset+length-2);offset+=array.length;return array}function prepareComponents(frame){var mcusPerLine=Math.ceil(frame.samplesPerLine/8/frame.maxH);var mcusPerColumn=Math.ceil(frame.scanLines/8/frame.maxV);for(var i=0;i>4===0)for(j=0;j<64;j++){z=dctZigZag[j];tableData[z]=data[offset++]}else if(quantizationTableSpec>>4===1)for(j=0;j<64;j++){z= +dctZigZag[j];tableData[z]=readUint16()}else throw"DQT: invalid table spec";quantizationTables[quantizationTableSpec&15]=tableData}break;case 65472:case 65473:case 65474:if(frame)throw"Only single frame JPEGs supported";readUint16();frame={};frame.extended=fileMarker===65473;frame.progressive=fileMarker===65474;frame.precision=data[offset++];frame.scanLines=readUint16();frame.samplesPerLine=readUint16();frame.components=[];frame.componentIds={};var componentsCount=data[offset++],componentId;var maxH= +0,maxV=0;for(i=0;i>4;var v=data[offset+1]&15;if(maxH>4===0?huffmanTablesDC:huffmanTablesAC)[huffmanTableSpec&15]=buildHuffmanTable(codeLengths,huffmanValues)}break;case 65501:readUint16();resetInterval=readUint16();break;case 65498:var scanLength=readUint16();var selectorsCount=data[offset++];var components=[],component;for(i=0;i< +selectorsCount;i++){var componentIndex=frame.componentIds[data[offset++]];component=frame.components[componentIndex];var tableSpec=data[offset++];component.huffmanTableDC=huffmanTablesDC[tableSpec>>4];component.huffmanTableAC=huffmanTablesAC[tableSpec&15];components.push(component)}var spectralStart=data[offset++];var spectralEnd=data[offset++];var successiveApproximation=data[offset++];var processed=decodeScan(data,offset,frame,components,resetInterval,spectralStart,spectralEnd,successiveApproximation>> +4,successiveApproximation&15);offset+=processed;break;default:if(data[offset-3]===255&&data[offset-2]>=192&&data[offset-2]<=254){offset-=3;break}throw"unknown JPEG marker "+fileMarker.toString(16);}fileMarker=readUint16()}this.width=frame.samplesPerLine;this.height=frame.scanLines;this.jfif=jfif;this.adobe=adobe;this.components=[];for(i=0;i>8)+transform[k+1];return data},_isColorConversionNeeded:function isColorConversionNeeded(){if(this.adobe&&this.adobe.transformCode)return true;else if(this.numComponents===3)return true;else return false},_convertYccToRgb:function convertYccToRgb(data){var Y,Cb,Cr;for(var i=0,length=data.length;i=0?255:r<=min?0:255+r*scale|0;data[offset++]= +g>=0?255:g<=min?0:255+g*scale|0;data[offset++]=b>=0?255:b<=min?0:255+b*scale|0}return data},getData:function getData(width,height,forceRGBoutput){if(this.numComponents>4)throw"Unsupported color mode";var data=this._getLinearizedBlockData(width,height);if(this.numComponents===3)return this._convertYccToRgb(data);else if(this.numComponents===4)if(this._isColorConversionNeeded())if(forceRGBoutput)return this._convertYcckToRgb(data);else return this._convertYcckToCmyk(data);else if(forceRGBoutput)return this._convertCmykToRgb(data); +return data}};return constructor}();var JpxImage=function JpxImageClosure(){var SubbandsGainLog2={"LL":0,"LH":1,"HL":1,"HH":2};function JpxImage(){this.failOnCorruptedImage=false}JpxImage.prototype={parse:function JpxImage_parse(data){var head=readUint16(data,0);if(head===65359){this.parseCodestream(data,0,data.length);return}var position=0,length=data.length;while(position=0){var oldByte=newByte;newByte=stream.getByte();var code=oldByte<<8|newByte;if(code===65361){stream.skip(4);var Xsiz=stream.getInt32()>>>0;var Ysiz=stream.getInt32()>>>0;var XOsiz=stream.getInt32()>>>0;var YOsiz=stream.getInt32()>>>0;stream.skip(16);var Csiz=stream.getUint16();this.width=Xsiz-XOsiz;this.height=Ysiz-YOsiz;this.componentsCount=Csiz;this.bitsPerComponent=8;return}}throw new Error("JPX Error: No size marker found in JPX stream");},parseCodestream:function JpxImage_parseCodestream(data, +start,end){var context={};try{var doNotRecover=false;var position=start;while(position+1>5;spqcds=[];while(j>3;spqcd.mu=0}else{spqcd.epsilon=data[j]>>3;spqcd.mu=(data[j]&7)<<8|data[j+1];j+=2}spqcds.push(spqcd)}qcd.SPqcds=spqcds;if(context.mainHeader)context.QCD=qcd;else{context.currentTile.QCD=qcd;context.currentTile.QCC=[]}break;case 65373:length=readUint16(data,position);var qcc={};j=position+2;var cqcc;if(context.SIZ.Csiz<257)cqcc=data[j++];else{cqcc=readUint16(data,j);j+=2}sqcd=data[j++];switch(sqcd&31){case 0:spqcdSize= +8;scalarExpounded=true;break;case 1:spqcdSize=16;scalarExpounded=false;break;case 2:spqcdSize=16;scalarExpounded=true;break;default:throw new Error("JPX Error: Invalid SQcd value "+sqcd);}qcc.noQuantization=spqcdSize===8;qcc.scalarExpounded=scalarExpounded;qcc.guardBits=sqcd>>5;spqcds=[];while(j>3;spqcd.mu=0}else{spqcd.epsilon=data[j]>>3;spqcd.mu=(data[j]&7)<<8|data[j+1];j+=2}spqcds.push(spqcd)}qcc.SPqcds=spqcds;if(context.mainHeader)context.QCC[cqcc]= +qcc;else context.currentTile.QCC[cqcc]=qcc;break;case 65362:length=readUint16(data,position);var cod={};j=position+2;var scod=data[j++];cod.entropyCoderWithCustomPrecincts=!!(scod&1);cod.sopMarkerUsed=!!(scod&2);cod.ephMarkerUsed=!!(scod&4);cod.progressionOrder=data[j++];cod.layersCount=readUint16(data,j);j+=2;cod.multipleComponentTransform=data[j++];cod.decompositionLevelsCount=data[j++];cod.xcb=(data[j++]&15)+2;cod.ycb=(data[j++]&15)+2;var blockStyle=data[j++];cod.selectiveArithmeticCodingBypass= +!!(blockStyle&1);cod.resetContextProbabilities=!!(blockStyle&2);cod.terminationOnEachCodingPass=!!(blockStyle&4);cod.verticalyStripe=!!(blockStyle&8);cod.predictableTermination=!!(blockStyle&16);cod.segmentationSymbolUsed=!!(blockStyle&32);cod.reversibleTransformation=data[j++];if(cod.entropyCoderWithCustomPrecincts){var precinctsSizes=[];while(j>4})}cod.precinctsSizes=precinctsSizes}var unsupported= +[];if(cod.sopMarkerUsed)unsupported.push("sopMarkerUsed");if(cod.ephMarkerUsed)unsupported.push("ephMarkerUsed");if(cod.selectiveArithmeticCodingBypass)unsupported.push("selectiveArithmeticCodingBypass");if(cod.resetContextProbabilities)unsupported.push("resetContextProbabilities");if(cod.terminationOnEachCodingPass)unsupported.push("terminationOnEachCodingPass");if(cod.verticalyStripe)unsupported.push("verticalyStripe");if(cod.predictableTermination)unsupported.push("predictableTermination");if(unsupported.length> +0){doNotRecover=true;throw new Error("JPX Error: Unsupported COD options ("+unsupported.join(", ")+")");}if(context.mainHeader)context.COD=cod;else{context.currentTile.COD=cod;context.currentTile.COC=[]}break;case 65424:length=readUint16(data,position);tile={};tile.index=readUint16(data,position+2);tile.length=readUint32(data,position+4);tile.dataEnd=tile.length+position-2;tile.partIndex=data[position+8];tile.partsCount=data[position+9];context.mainHeader=false;if(tile.partIndex===0){tile.COD=context.COD; +tile.COC=context.COC.slice(0);tile.QCD=context.QCD;tile.QCC=context.QCC.slice(0)}context.currentTile=tile;break;case 65427:tile=context.currentTile;if(tile.partIndex===0){initializeTile(context,tile.index);buildPackets(context)}length=tile.dataEnd-position;parseTilePackets(context,data,position,length);break;case 65380:length=readUint16(data,position);break;case 65363:throw new Error("JPX Error: Codestream code 0xFF53 (COC) is "+"not implemented");default:throw new Error("JPX Error: Unknown codestream code: "+ +code.toString(16));}position+=length}}catch(e){if(doNotRecover||this.failOnCorruptedImage)throw e;else warn("Trying to recover from "+e.message)}this.tiles=transformComponents(context);this.width=context.SIZ.Xsiz-context.SIZ.XOsiz;this.height=context.SIZ.Ysiz-context.SIZ.YOsiz;this.componentsCount=context.SIZ.Csiz}};function calculateComponentDimensions(component,siz){component.x0=Math.ceil(siz.XOsiz/component.XRsiz);component.x1=Math.ceil(siz.Xsiz/component.XRsiz);component.y0=Math.ceil(siz.YOsiz/ +component.YRsiz);component.y1=Math.ceil(siz.Ysiz/component.YRsiz);component.width=component.x1-component.x0;component.height=component.y1-component.y0}function calculateTileGrids(context,components){var siz=context.SIZ;var tile,tiles=[];var numXtiles=Math.ceil((siz.Xsiz-siz.XTOsiz)/siz.XTsiz);var numYtiles=Math.ceil((siz.Ysiz-siz.YTOsiz)/siz.YTsiz);for(var q=0;q0?Math.min(codOrCoc.xcb,result.PPx-1):Math.min(codOrCoc.xcb,result.PPx);result.ycb_=r>0?Math.min(codOrCoc.ycb,result.PPy-1):Math.min(codOrCoc.ycb,result.PPy);return result}function buildPrecincts(context,resolution,dimensions){var precinctWidth=1<resolution.trx0?Math.ceil(resolution.trx1/precinctWidth)-Math.floor(resolution.trx0/precinctWidth):0;var numprecinctshigh= +resolution.try1>resolution.try0?Math.ceil(resolution.try1/precinctHeight)-Math.floor(resolution.try0/precinctHeight):0;var numprecincts=numprecinctswide*numprecinctshigh;var precinctXOffset=Math.floor(resolution.trx0/precinctWidth)*precinctWidth;var precinctYOffset=Math.floor(resolution.try0/precinctHeight)*precinctHeight;resolution.precinctParameters={precinctXOffset:precinctXOffset,precinctYOffset:precinctYOffset,precinctWidth:precinctWidth,precinctHeight:precinctHeight,numprecinctswide:numprecinctswide, +numprecinctshigh:numprecinctshigh,numprecincts:numprecincts}}function buildCodeblocks(context,subband,dimensions){var xcb_=dimensions.xcb_;var ycb_=dimensions.ycb_;var codeblockWidth=1<>xcb_;var cby0=subband.tby0>>ycb_;var cbx1=subband.tbx1+codeblockWidth-1>>xcb_;var cby1=subband.tby1+codeblockHeight-1>>ycb_;var precinctParameters=subband.resolution.precinctParameters;var codeblocks=[];var precincts=[];var i,j,codeblock,precinctNumber;for(j= +cby0;jprecinct.cbxMax)precinct.cbxMax=i;if(jprecinct.cbyMax)precinct.cbyMax=j}else precincts[precinctNumber]= +precinct={cbxMin:i,cbyMin:j,cbxMax:i,cbyMax:j};codeblock.precinct=precinct}subband.codeblockParameters={codeblockWidth:xcb_,codeblockHeight:ycb_,numcodeblockwide:cbx1-cbx0+1,numcodeblockhigh:cby1-cby0+1};subband.codeblocks=codeblocks;subband.precincts=precincts}function createPacket(resolution,precinctNumber,layerNumber){var precinctCodeblocks=[];var subbands=resolution.subbands;for(var i=0,ii=subbands.length;icomponent.codingStyleParameters.decompositionLevelsCount)continue;var resolution=component.resolutions[r];var numprecincts=resolution.precinctParameters.numprecincts;for(;kcomponent.codingStyleParameters.decompositionLevelsCount)continue;var resolution=component.resolutions[r];var numprecincts=resolution.precinctParameters.numprecincts;for(;k>>bufferSize&(1<0){var packetItem=queue.shift();codeblock=packetItem.codeblock;if(!("data"in codeblock))codeblock.data=[];codeblock.data.push({data:data,start:offset+position,end:offset+position+packetItem.dataLength,codingpasses:packetItem.codingpasses}); +position+=packetItem.dataLength}}return position}function copyCoefficients(coefficients,levelWidth,levelHeight,subband,delta,mb,reversible,segmentationSymbolUsed){var x0=subband.tbx0;var y0=subband.tby0;var width=subband.tbx1-subband.tbx0;var codeblocks=subband.codeblocks;var right=subband.type.charAt(0)==="H"?1:0;var bottom=subband.type.charAt(1)==="H"?levelWidth:0;for(var i=0,ii=codeblocks.length;i=mb)coefficients[pos]=n;else coefficients[pos]=n*(1<0?1-i:0)}else{mu=spqcds[b].mu;epsilon=spqcds[b].epsilon;b++}var subband=resolution.subbands[j];var gainLog2=SubbandsGainLog2[subband.type];var delta=reversible?1:Math.pow(2,precision+gainLog2-epsilon)*(1+mu/2048);var mb=guardBits+epsilon- +1;copyCoefficients(coefficients,width,height,subband,delta,mb,reversible,segmentationSymbolUsed)}subbandCoefficients.push({width:width,height:height,items:coefficients})}var result=transform.calculate(subbandCoefficients,component.tcx0,component.tcy0);return{left:component.tcx0,top:component.tcy0,width:result.width,height:result.height,items:result.items}}function transformComponents(context){var siz=context.SIZ;var components=context.components;var componentsCount=siz.Csiz;var resultImages=[];for(var i= +0,ii=context.tiles.length;i=max?255:r>>shift;out[pos++]=g<=0?0:g>=max?255:g>>shift;out[pos++]=b<=0?0:b>=max?255:b>>shift}else for(j=0;j>2);r=g+y2;b=g+y1;out[pos++]=r<=0?0:r>=max?255:r>>shift;out[pos++]=g<=0?0:g>=max?255:g>>shift;out[pos++]=b<=0?0:b>=max?255:b>>shift}if(fourComponents)for(j=0,pos=3;j=maxK?255:k+ +offset>>shift}}else for(c=0;c=max?255:val+offset>>shift;pos+=componentsCount}}resultImages.push(result)}return resultImages}function initializeTile(context,tileIndex){var siz=context.SIZ;var componentsCount=siz.Csiz;var tile=context.tiles[tileIndex];for(var c=0;c>=1;j>>=1;currentLevel++}currentLevel--;level=this.levels[currentLevel];level.items[level.index]=value;this.currentLevel=currentLevel; +delete this.value},incrementValue:function TagTree_incrementValue(){var level=this.levels[this.currentLevel];level.items[level.index]++},nextLevel:function TagTree_nextLevel(){var currentLevel=this.currentLevel;var level=this.levels[currentLevel];var value=level.items[level.index];currentLevel--;if(currentLevel<0){this.value=value;return false}this.currentLevel=currentLevel;level=this.levels[currentLevel];level.items[level.index]=value;return true}};return TagTree}();var InclusionTree=function InclusionTreeClosure(){function InclusionTree(width, +height,defaultValue){var levelsLength=log2(Math.max(width,height))+1;this.levels=[];for(var i=0;istopValue){this.currentLevel=currentLevel;this.propagateValues();return false}i>>=1;j>>=1;currentLevel++}this.currentLevel=currentLevel-1;return true},incrementValue:function InclusionTree_incrementValue(stopValue){var level=this.levels[this.currentLevel];level.items[level.index]=stopValue+1;this.propagateValues()},propagateValues:function InclusionTree_propagateValues(){var levelIndex=this.currentLevel; +var level=this.levels[levelIndex];var currentValue=level.items[level.index];while(--levelIndex>=0){level=this.levels[levelIndex];level.items[level.index]=currentValue}},nextLevel:function InclusionTree_nextLevel(){var currentLevel=this.currentLevel;var level=this.levels[currentLevel];var value=level.items[level.index];level.items[level.index]=255;currentLevel--;if(currentLevel<0)return false;this.currentLevel=currentLevel;level=this.levels[currentLevel];level.items[level.index]=value;return true}}; +return InclusionTree}();var BitModel=function BitModelClosure(){var UNIFORM_CONTEXT=17;var RUNLENGTH_CONTEXT=18;var LLAndLHContextsLabel=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]);var HLContextLabel=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]);var HHContextLabel= +new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]);function BitModel(width,height,subband,zeroBitPlanes,mb){this.width=width;this.height=height;this.contextLabelTable=subband==="HH"?HHContextLabel:subband==="HL"?HLContextLabel:LLAndLHContextsLabel;var coefficientCount=width*height;this.neighborsSignificance=new Uint8Array(coefficientCount);this.coefficentsSign=new Uint8Array(coefficientCount); +this.coefficentsMagnitude=mb>14?new Uint32Array(coefficientCount):mb>6?new Uint16Array(coefficientCount):new Uint8Array(coefficientCount);this.processingFlags=new Uint8Array(coefficientCount);var bitsDecoded=new Uint8Array(coefficientCount);if(zeroBitPlanes!==0)for(var i=0;i0;var right=column+10){i=index-width;if(left)neighborsSignificance[i-1]+=16;if(right)neighborsSignificance[i+1]+=16;neighborsSignificance[i]+=4}if(row+1=height)break;processingFlags[index]&=processedInverseMask;if(coefficentsMagnitude[index]||!neighborsSignificance[index])continue;var contextLabel=labels[neighborsSignificance[index]]; +var decision=decoder.readBit(contexts,contextLabel);if(decision){var sign=this.decodeSignBit(i,j,index);coefficentsSign[index]=sign;coefficentsMagnitude[index]=1;this.setNeighborsSignificance(i,j,index);processingFlags[index]|=firstMagnitudeBitMask}bitsDecoded[index]++;processingFlags[index]|=processedMask}}},decodeSignBit:function BitModel_decodeSignBit(row,column,index){var width=this.width,height=this.height;var coefficentsMagnitude=this.coefficentsMagnitude;var coefficentsSign=this.coefficentsSign; +var contribution,sign0,sign1,significance1;var contextLabel,decoded;significance1=column>0&&coefficentsMagnitude[index-1]!==0;if(column+10&&coefficentsMagnitude[index- +width]!==0;if(row+1=0){contextLabel=9+contribution;decoded=this.decoder.readBit(this.contexts,contextLabel)}else{contextLabel= +9-contribution;decoded=this.decoder.readBit(this.contexts,contextLabel)^1}return decoded},runMagnitudeRefinementPass:function BitModel_runMagnitudeRefinementPass(){var decoder=this.decoder;var width=this.width,height=this.height;var coefficentsMagnitude=this.coefficentsMagnitude;var neighborsSignificance=this.neighborsSignificance;var contexts=this.contexts;var bitsDecoded=this.bitsDecoded;var processingFlags=this.processingFlags;var processedMask=1;var firstMagnitudeBitMask=2;var length=width*height; +var width4=width*4;for(var index0=0,indexNext;index0>1;offset=offset|0;var j,n,current,next;var alpha= +-1.586134342059924;var beta=-.052980118572961;var gamma=.882911075530934;var delta=.443506852043971;var K=1.230174104914001;var K_=1/K;j=offset-3;for(n=len+4;n--;j+=2)x[j]*=K_;j=offset-2;current=delta*x[j-1];for(n=len+3;n--;j+=2){next=delta*x[j+1];x[j]=K*x[j]-current-next;if(n--){j+=2;current=delta*x[j+1];x[j]=K*x[j]-current-next}else break}j=offset-1;current=gamma*x[j-1];for(n=len+2;n--;j+=2){next=gamma*x[j+1];x[j]-=current+next;if(n--){j+=2;current=gamma*x[j+1];x[j]-=current+next}else break}j=offset; +current=beta*x[j-1];for(n=len+1;n--;j+=2){next=beta*x[j+1];x[j]-=current+next;if(n--){j+=2;current=beta*x[j+1];x[j]-=current+next}else break}if(len!==0){j=offset+1;current=alpha*x[j-1];for(n=len;n--;j+=2){next=alpha*x[j+1];x[j]-=current+next;if(n--){j+=2;current=alpha*x[j+1];x[j]-=current+next}else break}}};return IrreversibleTransform}();var ReversibleTransform=function ReversibleTransformClosure(){function ReversibleTransform(){Transform.call(this)}ReversibleTransform.prototype=Object.create(Transform.prototype); +ReversibleTransform.prototype.filter=function reversibleTransformFilter(x,offset,length){var len=length>>1;offset=offset|0;var j,n;for(j=offset,n=len+1;n--;j+=2)x[j]-=x[j-1]+x[j+1]+2>>2;for(j=offset+1,n=len;n--;j+=2)x[j]+=x[j-1]+x[j+1]>>1};return ReversibleTransform}();return JpxImage}();var Jbig2Image=function Jbig2ImageClosure(){function ContextCache(){}ContextCache.prototype={getContexts:function(id){if(id in this)return this[id];return this[id]=new Int8Array(1<<16)}};function DecodingContext(data, +start,end){this.data=data;this.start=start;this.end=end}DecodingContext.prototype={get decoder(){var decoder=new ArithmeticDecoder(this.data,this.start,this.end);return shadow(this,"decoder",decoder)},get contextCache(){var cache=new ContextCache;return shadow(this,"contextCache",cache)}};function decodeInteger(contextCache,procedure,decoder){var contexts=contextCache.getContexts(procedure);var prev=1;function readBits(length){var v=0;for(var i=0;i>>0}var sign=readBits(1);var value=readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(32)+4436:readBits(12)+340:readBits(8)+84:readBits(6)+20:readBits(4)+4:readBits(2);return sign===0?value:value>0?-value:null}function decodeIAID(contextCache,decoder,codeLength){var contexts=contextCache.getContexts("IAID");var prev=1;for(var i=0;i=sbb_left&&j=sbb_top){contextLabel=contextLabel<<1&reuseMask;for(k=0;k=0&&j0=0){bit=bitmap[i0][j0];if(bit)contextLabel|=bit<=width)contextLabel<<=1;else contextLabel=contextLabel<<1|bitmap[i0][j0]}for(k=0;k=referenceHeight||j0<0||j0>=referenceWidth)contextLabel<<= +1;else contextLabel=contextLabel<<1|referenceBitmap[i0][j0]}var pixel=decoder.readBit(contexts,contextLabel);row[j]=pixel}}return bitmap}function decodeSymbolDictionary(huffman,refinement,symbols,numberOfNewSymbols,numberOfExportedSymbols,huffmanTables,templateIndex,at,refinementTemplateIndex,refinementAt,decodingContext){if(huffman)error("JBIG2 error: huffman is not supported");var newSymbols=[];var currentHeight=0;var symbolCodeLength=log2(symbols.length+numberOfNewSymbols);var decoder=decodingContext.decoder; +var contextCache=decodingContext.contextCache;while(newSymbols.length1)bitmap=decodeTextRegion(huffman, +refinement,currentWidth,currentHeight,0,numberOfInstances,1,symbols.concat(newSymbols),symbolCodeLength,0,0,1,0,huffmanTables,refinementTemplateIndex,refinementAt,decodingContext);else{var symbolId=decodeIAID(contextCache,decoder,symbolCodeLength);var rdx=decodeInteger(contextCache,"IARDX",decoder);var rdy=decodeInteger(contextCache,"IARDY",decoder);var symbol=symbolId>1)+rdx,(rdh>>1)+rdy,false,refinementAt,decodingContext)}var offsetT=t-(referenceCorner&1?0:symbolHeight);var offsetS=currentS-(referenceCorner&2?symbolWidth:0);var s2,t2,symbolRow;if(transposed){for(s2=0;s2>5&7;var retainBits=[referredFlags&31];var position=start+6;if(referredFlags===7){referredToCount=readUint32(data,position-1)&536870911;position+=3;var bytes=referredToCount+7>>3;retainBits[0]=data[position++];while(--bytes>0)retainBits.push(data[position++])}else if(referredFlags===5|| +referredFlags===6)error("JBIG2 error: invalid referred-to flags");segmentHeader.retainBits=retainBits;var referredToSegmentNumberSize=segmentHeader.number<=256?1:segmentHeader.number<=65536?2:4;var referredTo=[];var i,ii;for(i=0;i>>24&255;searchPattern[3]=genericRegionInfo.height>>16&255;searchPattern[4]=genericRegionInfo.height>>8&255;searchPattern[5]=genericRegionInfo.height&255;for(i=position,ii=data.length;i>2&3;dictionary.huffmanDWSelector=dictionaryFlags>>4&3;dictionary.bitmapSizeSelector=dictionaryFlags>>6&1;dictionary.aggregationInstancesSelector=dictionaryFlags>>7&1;dictionary.bitmapCodingContextUsed=!!(dictionaryFlags&256);dictionary.bitmapCodingContextRetained=!!(dictionaryFlags&512);dictionary.template=dictionaryFlags>> +10&3;dictionary.refinementTemplate=dictionaryFlags>>12&1;position+=2;if(!dictionary.huffman){atLength=dictionary.template===0?4:1;at=[];for(i=0;i>2&3);textRegion.referenceCorner= +textRegionSegmentFlags>>4&3;textRegion.transposed=!!(textRegionSegmentFlags&64);textRegion.combinationOperator=textRegionSegmentFlags>>7&3;textRegion.defaultPixelValue=textRegionSegmentFlags>>9&1;textRegion.dsOffset=textRegionSegmentFlags<<17>>27;textRegion.refinementTemplate=textRegionSegmentFlags>>15&1;if(textRegion.huffman){var textRegionHuffmanFlags=readUint16(data,position);position+=2;textRegion.huffmanFS=textRegionHuffmanFlags&3;textRegion.huffmanDS=textRegionHuffmanFlags>>2&3;textRegion.huffmanDT= +textRegionHuffmanFlags>>4&3;textRegion.huffmanRefinementDW=textRegionHuffmanFlags>>6&3;textRegion.huffmanRefinementDH=textRegionHuffmanFlags>>8&3;textRegion.huffmanRefinementDX=textRegionHuffmanFlags>>10&3;textRegion.huffmanRefinementDY=textRegionHuffmanFlags>>12&3;textRegion.huffmanRefinementSizeSelector=!!(textRegionHuffmanFlags&14)}if(textRegion.refinement&&!textRegion.refinementTemplate){at=[];for(i=0;i<2;i++){at.push({x:readInt8(data,position),y:readInt8(data,position+1)});position+=2}textRegion.refinementAt= +at}textRegion.numberOfSymbolInstances=readUint32(data,position);position+=4;if(textRegion.huffman)error("JBIG2 error: huffman is not supported");args=[textRegion,header.referredTo,data,position,end];break;case 38:case 39:var genericRegion={};genericRegion.info=readRegionSegmentInformation(data,position);position+=RegionSegmentInformationFieldLength;var genericRegionSegmentFlags=data[position++];genericRegion.mmr=!!(genericRegionSegmentFlags&1);genericRegion.template=genericRegionSegmentFlags>>1&3; +genericRegion.prediction=!!(genericRegionSegmentFlags&8);if(!genericRegion.mmr){atLength=genericRegion.template===0?4:1;at=[];for(i=0;i>2&1;pageInfo.combinationOperator=pageSegmentFlags>>3&3;pageInfo.requiresBuffer=!!(pageSegmentFlags&32);pageInfo.combinationOperatorOverride=!!(pageSegmentFlags&64);args=[pageInfo];break;case 49:break;case 50:break;case 51:break;case 62:break;default:error("JBIG2 error: segment type "+ +header.typeName+"("+header.type+") is not implemented")}var callbackName="on"+header.typeName;if(callbackName in visitor)visitor[callbackName].apply(visitor,args)}function processSegments(segments,visitor){for(var i=0,ii=segments.length;i>3;var buffer=new Uint8Array(rowSize*info.height);if(info.defaultPixelValue)for(var i=0,ii=buffer.length;i>3;var combinationOperator=pageInfo.combinationOperatorOverride?regionInfo.combinationOperator:pageInfo.combinationOperator;var buffer=this.buffer;var mask0=128>>(regionInfo.x&7);var offset0=regionInfo.y*rowSize+(regionInfo.x>>3);var i,j,mask,offset;switch(combinationOperator){case 0:for(i=0;i>=1;if(!mask){mask=128;offset++}}offset0+=rowSize}break;case 2:for(i=0;i>=1;if(!mask){mask=128;offset++}}offset0+=rowSize}break;default:error("JBIG2 error: operator "+combinationOperator+" is not supported")}},onImmediateGenericRegion:function SimpleSegmentVisitor_onImmediateGenericRegion(region,data,start,end){var regionInfo=region.info;var decodingContext=new DecodingContext(data,start,end);var bitmap=decodeBitmap(region.mmr,regionInfo.width,regionInfo.height,region.template,region.prediction, +null,region.at,decodingContext);this.drawBitmap(regionInfo,bitmap)},onImmediateLosslessGenericRegion:function SimpleSegmentVisitor_onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function SimpleSegmentVisitor_onSymbolDictionary(dictionary,currentSegment,referredSegments,data,start,end){var huffmanTables;if(dictionary.huffman)error("JBIG2 error: huffman is not supported");var symbols=this.symbols;if(!symbols)this.symbols=symbols={};var inputSymbols= +[];for(var i=0,ii=referredSegments.length;i=0;--j){if(types[j]!== +"ET")break;types[j]="EN"}for(j=i+1;j0)before=types[i-1];var after=eor;if(end+1level&&isOdd(level))lowestOddLevel= +level}for(level=highestLevel;level>=lowestOddLevel;--level){var start=-1;for(i=0,ii=levels.length;i=0){reverseValues(chars,start,i);start=-1}}else if(start<0)start=i;if(start>=0)reverseValues(chars,start,levels.length)}var result="";for(i=0,ii=chars.length;i")result+=ch}return createBidiText(result,isLTR)}return bidi}();"use strict";var MurmurHash3_64=function MurmurHash3_64Closure(seed){var MASK_HIGH=4294901760;var MASK_LOW= +65535;function MurmurHash3_64(seed){var SEED=3285377520;this.h1=seed?seed&4294967295:SEED;this.h2=seed?seed&4294967295:SEED}var alwaysUseUint32ArrayView=false;try{new Uint32Array((new Uint8Array(5)).buffer,0,1)}catch(e){alwaysUseUint32ArrayView=true}MurmurHash3_64.prototype={update:function MurmurHash3_64_update(input){var useUint32ArrayView=alwaysUseUint32ArrayView;var i;if(typeof input==="string"){var data=new Uint8Array(input.length*2);var length=0;for(i=0;i>>8;data[length++]=code&255}}}else if(input instanceof Uint8Array){data=input;length=data.length}else if(typeof input==="object"&&"length"in input){data=input;length=data.length;useUint32ArrayView=true}else throw new Error("Wrong data format in MurmurHash3_64_update. "+"Input must be a string or array.");var blockCounts=length>>2;var tailLength=length-blockCounts*4;var dataUint32=useUint32ArrayView?new Uint32ArrayView(data,blockCounts):new Uint32Array(data.buffer, +0,blockCounts);var k1=0;var k2=0;var h1=this.h1;var h2=this.h2;var C1=3432918353;var C2=461845907;var C1_LOW=C1&MASK_LOW;var C2_LOW=C2&MASK_LOW;for(i=0;i>>17;k1=k1*C2&MASK_HIGH|k1*C2_LOW&MASK_LOW;h1^=k1;h1=h1<<13|h1>>>19;h1=h1*5+3864292196}else{k2=dataUint32[i];k2=k2*C1&MASK_HIGH|k2*C1_LOW&MASK_LOW;k2=k2<<15|k2>>>17;k2=k2*C2&MASK_HIGH|k2*C2_LOW&MASK_LOW;h2^=k2;h2=h2<<13|h2>>>19;h2=h2*5+3864292196}k1=0;switch(tailLength){case 3:k1^= +data[blockCounts*4+2]<<16;case 2:k1^=data[blockCounts*4+1]<<8;case 1:k1^=data[blockCounts*4];k1=k1*C1&MASK_HIGH|k1*C1_LOW&MASK_LOW;k1=k1<<15|k1>>>17;k1=k1*C2&MASK_HIGH|k1*C2_LOW&MASK_LOW;if(blockCounts&1)h1^=k1;else h2^=k1}this.h1=h1;this.h2=h2;return this},hexdigest:function MurmurHash3_64_hexdigest(){var h1=this.h1;var h2=this.h2;h1^=h2>>>1;h1=h1*3981806797&MASK_HIGH|h1*36045&MASK_LOW;h2=h2*4283543511&MASK_HIGH|((h2<<16|h1>>>16)*2950163797&MASK_HIGH)>>>16;h1^=h2>>>1;h1=h1*444984403&MASK_HIGH|h1* +60499&MASK_LOW;h2=h2*3301882366&MASK_HIGH|((h2<<16|h1>>>16)*3120437893&MASK_HIGH)>>>16;h1^=h2>>>1;for(var i=0,arr=[h1,h2],str="";i>>0).toString(16);while(hex.length<8)hex="0"+hex;str+=hex}return str}};return MurmurHash3_64}()}).call(typeof window==="undefined"?this:window); +if(!PDFJS.workerSrc&&typeof document!=="undefined")PDFJS.workerSrc=function(){var scriptTagContainer=document.body||document.getElementsByTagName("head")[0];var pdfjsSrc=scriptTagContainer.lastChild.src;return pdfjsSrc&&pdfjsSrc.replace(/\.js$/i,".worker.js")}(); -- cgit v1.2.3