viewer.js.map 724 KB

1
  1. {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///web/viewer.js","webpack:///web/app.js","webpack:///node_modules/babel-runtime/regenerator/index.js","webpack:///node_modules/regenerator-runtime/runtime-module.js","webpack:///node_modules/regenerator-runtime/runtime.js","webpack:///node_modules/webpack/buildin/module.js","webpack:///web/ui_utils.js","webpack:///web/pdfjs.js","webpack:///web/pdf_cursor_tools.js","webpack:///web/grab_to_pan.js","webpack:///web/pdf_rendering_queue.js","webpack:///web/pdf_sidebar.js","webpack:///web/app_options.js","webpack:///web/viewer_compatibility.js","webpack:///web/dom_events.js","webpack:///web/overlay_manager.js","webpack:///web/password_prompt.js","webpack:///web/pdf_attachment_viewer.js","webpack:///web/pdf_document_properties.js","webpack:///web/pdf_find_bar.js","webpack:///web/pdf_find_controller.js","webpack:///web/pdf_find_utils.js","webpack:///web/pdf_history.js","webpack:///web/pdf_link_service.js","webpack:///web/pdf_outline_viewer.js","webpack:///web/pdf_presentation_mode.js","webpack:///web/pdf_sidebar_resizer.js","webpack:///web/pdf_thumbnail_viewer.js","webpack:///web/pdf_thumbnail_view.js","webpack:///web/pdf_viewer.js","webpack:///web/base_viewer.js","webpack:///web/annotation_layer_builder.js","webpack:///web/pdf_page_view.js","webpack:///web/text_layer_builder.js","webpack:///web/secondary_toolbar.js","webpack:///web/pdf_single_page_viewer.js","webpack:///web/toolbar.js","webpack:///web/view_history.js","webpack:///web/genericcom.js","webpack:///web/preferences.js","webpack:///web/download_manager.js","webpack:///web/genericl10n.js","webpack:///external/webL10n/l10n.js","webpack:///web/pdf_print_service.js"],"names":["pdfjsWebApp","require","pdfjsWebAppOptions","appContainer","document","mainContainer","viewerContainer","eventBus","toolbar","container","numPages","pageNumber","scaleSelectContainer","scaleSelect","customScaleOption","previous","next","zoomIn","zoomOut","viewFind","openFile","print","presentationModeButton","download","viewBookmark","secondaryToolbar","toggleButton","toolbarButtonContainer","openFileButton","printButton","downloadButton","viewBookmarkButton","firstPageButton","lastPageButton","pageRotateCwButton","pageRotateCcwButton","cursorSelectToolButton","cursorHandToolButton","scrollVerticalButton","scrollHorizontalButton","scrollWrappedButton","spreadNoneButton","spreadOddButton","spreadEvenButton","documentPropertiesButton","fullscreen","contextFirstPage","contextLastPage","contextPageRotateCw","contextPageRotateCcw","sidebar","outerContainer","thumbnailButton","outlineButton","attachmentsButton","thumbnailView","outlineView","attachmentsView","sidebarResizer","resizer","findBar","bar","findField","highlightAllCheckbox","caseSensitiveCheckbox","entireWordCheckbox","findMsg","findResultsCount","findPreviousButton","findNextButton","passwordOverlay","overlayName","label","input","submitButton","cancelButton","documentProperties","closeButton","fields","errorWrapper","errorMessage","errorMoreInfo","moreInfoButton","lessInfoButton","printContainer","openFileInputName","debuggerScriptPath","config","window","DEFAULT_SCALE_DELTA","DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT","FORCE_PAGES_LOADED_TIMEOUT","DefaultExternalServices","updateFindControlState","updateFindMatchesCount","initPassiveLoading","fallback","reportTelemetry","createDownloadManager","createPreferences","createL10n","supportsIntegratedFind","supportsDocumentFonts","supportsDocumentColors","supportedMouseWheelZoomModifierKeys","ctrlKey","metaKey","PDFViewerApplication","initialBookmark","initialized","fellback","appConfig","pdfDocument","pdfLoadingTask","printService","pdfViewer","pdfThumbnailViewer","pdfRenderingQueue","pdfPresentationMode","pdfDocumentProperties","pdfLinkService","pdfHistory","pdfSidebar","pdfSidebarResizer","pdfOutlineViewer","pdfAttachmentViewer","pdfCursorTools","store","downloadManager","overlayManager","preferences","l10n","isInitialViewSet","downloadComplete","isViewerEmbedded","url","baseUrl","externalServices","_boundEvents","contentDispositionFilename","AppOptions","LinkTarget","source","OVERRIDES","disableFontFace","disableRange","disableStream","textLayerMode","TextLayerMode","prefs","name","waitOn","hash","hashParams","parseQueryString","viewer","enabled","loadAndEnablePDFBug","console","reason","locale","dir","dispatchToDOM","getGlobalEventBus","externalLinkTarget","externalLinkRel","disableCreateObjectURL","findController","linkService","renderingQueue","renderer","enableWebGL","imageResourcesPath","renderInteractiveForms","enablePrintAutoRotate","useOnlyCssZoom","maxCanvasPixels","thumbnailContainer","cursorToolOnLoad","contextMenuItems","sidebarConfig","Object","run","newScale","Math","PDFPrintServiceFactory","doc","support","shadow","setTitleUsingUrl","title","getPDFFileNameFromURL","decodeURIComponent","getFilenameFromUrl","setTitle","promise","PDFBug","workerParameters","GlobalWorkerOptions","parameters","file","apiParameters","prop","args","loadingTask","getDocument","loaded","message","exception","loadingErrorMessage","filename","blob","type","error","moreInfoText","version","build","moreInfo","stack","line","errorWrapperConfig","Promise","parts","progress","percent","level","isNaN","disableAutoFetch","clearTimeout","load","firstPagePromise","pageModePromise","baseDocumentUrl","pagesPromise","onePageRendered","resetHistory","storePromise","page","zoom","scrollLeft","scrollTop","rotation","sidebarView","SidebarView","scrollMode","spreadMode","values","parseInt","pageMode","apiPageModeToSidebarView","setTimeout","i","numLabels","labels","javaScript","UNSUPPORTED_FEATURES","regex","ii","js","info","metadata","pdfTitle","setInitialView","setRotation","isValidRotation","setViewerModes","Number","cleanup","RendererType","forceRendering","beforePrint","pagesOverview","afterPrint","rotatePages","newRotation","requestPresentationMode","bindEvents","bindWindowEvents","unbindEvents","unbindWindowEvents","HOSTED_VIEWER_ORIGINS","validateFileURL","viewerOrigin","origin","protocol","ex","loadScript","PDFWorker","queryString","params","fileInput","files","evt","webViewerOpenFileViaURL","xhr","pageIndex","pageView","Stats","mode","view","action","switchInProgress","PresentationModeState","active","location","href","currentPage","loading","RenderingStates","currentScaleValue","webViewerFileInputChange","URL","originalUrl","fileReader","buffer","query","phraseSearch","caseSensitive","entireWord","highlightAll","findPrevious","result","zoomDisabled","previousScale","delta","normalizeWheelEventDelta","MOUSE_WHEEL_DELTA_PER_PAGE_SCALE","ticks","currentScale","scaleCorrectionFactor","rect","dx","dy","zoomDisabledTimeout","handled","ensureViewerFocused","cmd","isViewerInPresentationMode","findState","curElement","curElementTagName","turnPage","turnOnlyIfPageFit","CursorTool","instance","supportsPrinting","createPrintService","module","g","Function","hadRuntime","oldRuntime","Op","hasOwn","$Symbol","iteratorSymbol","asyncIteratorSymbol","toStringTagSymbol","inModule","runtime","global","protoGenerator","outerFn","generator","context","tryLocsList","makeInvokeMethod","arg","fn","GenStateSuspendedStart","GenStateSuspendedYield","GenStateExecuting","GenStateCompleted","ContinueSentinel","IteratorPrototype","getProto","NativeIteratorPrototype","Gp","GeneratorFunctionPrototype","Generator","GeneratorFunction","prototype","ctor","genFun","__await","record","tryCatch","reject","value","invoke","resolve","previousPromise","defineIteratorMethods","AsyncIterator","iter","wrap","state","method","delegate","delegateResult","maybeInvokeDelegate","done","entry","tryLoc","locs","keys","key","iteratorMethod","iterable","Context","constructor","reset","stop","rootEntry","rootRecord","dispatchException","handle","hasCatch","hasFinally","abrupt","finallyEntry","complete","finish","resetTryEntry","thrown","delegateYield","iterator","resultName","nextLoc","enumerable","get","CSS_UNITS","DEFAULT_SCALE_VALUE","DEFAULT_SCALE","MIN_SCALE","MAX_SCALE","UNKNOWN_SCALE","MAX_AUTO_SCALE","SCROLLBAR_PADDING","VERTICAL_PADDING","UNKNOWN","NORMAL","CHANGING","FULLSCREEN","CANVAS","SVG","DISABLE","ENABLE","ENABLE_ENHANCE","NullL10n","formatL10nValue","devicePixelRatio","backingStoreRatio","ctx","pixelRatio","sx","sy","scaled","skipOverflowHiddenElements","parent","element","offsetY","offsetX","getComputedStyle","spot","debounceScroll","rAF","currentX","viewAreaElement","lastX","currentY","lastY","callback","right","down","_eventHandler","param","minIndex","maxIndex","items","condition","currentIndex","currentItem","xinv","limit","x_","x","a","b","c","d","p","q","r","changeOrientation","rotate","width","height","index","elt","views","pageTop","sortByVisibility","horizontal","top","scrollEl","bottom","left","elementBottom","elementRight","visible","firstVisibleElementInd","binarySearchFirstItem","backtrackBeforeAllVisibleElements","lastEdge","currentWidth","currentHeight","viewWidth","viewHeight","viewRight","viewBottom","hiddenHeight","hiddenWidth","percentVisible","id","y","first","last","pc","defaultFilename","isDataSchema","reURI","reFilename","splitURI","suggestedFilename","angle","MOUSE_DOM_DELTA_PIXEL_MODE","MOUSE_DOM_DELTA_LINE_MODE","MOUSE_PIXELS_PER_LINE","MOUSE_LINES_PER_PAGE","size","WaitOnType","EVENT","TIMEOUT","delay","target","eventHandler","handler","timeoutHandler","timeout","animationStarted","on","eventListeners","off","dispatch","Array","listener","_dispatchDOMEvent","details","obj","event","units","progressSize","setWidth","scrollbarWidth","clamp","moved","len","arr","write","read","pdfjsLib","__non_webpack_require__","SELECT","HAND","ZOOM","switchTool","tool","disableActiveTool","previouslyActive","options","overlay","GrabToPan","CSS_CLASS_GRAB","activate","deactivate","toggle","ignoreTarget","node","_onmousedown","focusedElement","_onmousemove","isLeftMouseReleased","xDiff","yDiff","behavior","_endPan","prefix","matchesSelector","isNotIEorIsIE10plus","chrome","isChrome15OrOpera15plus","isSafari6plus","navigator","CLEANUP_TIMEOUT","INITIAL","RUNNING","PAUSED","FINISHED","setViewer","setThumbnailViewer","isHighestPriority","renderHighestPriority","getHighestPriority","visibleViews","numVisible","nextPageIndex","previousPageIndex","isViewFinished","renderView","continueRendering","UI_NOTIFICATION_CLASS","NONE","THUMBS","OUTLINE","ATTACHMENTS","isViewPreserved","switchView","forceOpen","isViewChanged","shouldForceRendering","pagesCount","_showUINotification","_hideUINotification","removeNotification","outlineCount","OptionKind","VIEWER","API","WORKER","defaultOptions","kind","defaultUrl","defaultZoomValue","disableHistory","disablePageLabels","disablePageMode","eventBusDispatchToDOM","viewerCompatibilityParams","pdfBugEnabled","showPreviousViewOnLoad","sidebarViewOnLoad","scrollModeOnLoad","spreadModeOnLoad","cMapPacked","cMapUrl","apiCompatibilityParams","isEvalSupported","maxImageSize","pdfBug","postMessageTransfers","verbosity","workerPort","workerSrc","userOptions","defaultOption","userOption","compatibilityParams","userAgent","isAndroid","isIOS","exports","cssTransform","attachmentsCount","globalEventBus","attachDOMEventsToEventBus","callerCloseMethod","canForceClose","_keyDown","e","PasswordResponses","promptString","password","setUpdateCallback","keepRenderedCapability","_dispatchEvent","_bindPdfLink","button","blobUrl","createObjectURL","viewerUrl","encodeURIComponent","_bindLink","render","attachments","names","item","removeNullCharacters","div","_appendAttachment","DEFAULT_FIELD_CONTENT","NON_METRIC_LOCALES","US_PAGE_NAMES","METRIC_PAGE_NAMES","isPortrait","pageNames","freezeFieldData","writable","configurable","currentPageNumber","pagesRotation","getPageSizeInches","fileSize","data","setDocument","setFileSize","_updateUI","content","_parseFileSize","kb","size_kb","size_b","size_mb","_parsePageSize","pageSizeInches","isPortraitOrientation","sizeInches","sizeMillimeters","pageName","getPageName","exactMillimeters","intMillimeters","_parseDate","dateToParse","year","month","day","hours","minutes","seconds","utRel","offsetHours","offsetMinutes","date","Date","dateString","timeString","time","_parseLinearization","isLinearized","MATCHES_COUNT_LIMIT","dispatchEvent","updateUIState","notFound","status","FindState","updateResultsCount","current","total","matchesCountMsg","findbarHeight","inputContainerHeight","FOUND","NOT_FOUND","WRAPPED","PENDING","FIND_TIMEOUT","CHARACTERS_TO_NORMALIZE","replace","executeCommand","pageIdx","matchIdx","_normalize","_prepareMatches","currentElem","matchesWithLength","nextElem","prevElem","isSubTerm","matches","matchesLength","_isEntireWord","startIdx","getCharacterType","endIdx","_calculatePhraseMatch","queryLen","pageContent","_calculateWordMatch","queryArray","subquery","subqueryLen","match","matchLength","skipped","_calculateMatch","pageMatchesCount","extractTextCapability","pdfPage","normalizeWhitespace","textItems","textContent","strBuf","j","jj","_updatePage","currentPageIndex","offset","numPageMatches","_matchesReady","numMatches","_advanceOffsetPage","found","_updateMatch","wrapped","previousPage","_onFindBarClose","matchesCount","_updateUIState","CharacterType","SPACE","ALPHA_LETTER","PUNCT","HAN_LETTER","KATAKANA_LETTER","HIRAGANA_LETTER","HALFWIDTH_KATAKANA_LETTER","THAI_LETTER","charCode","isAlphabeticalScript","isAscii","isAsciiSpace","isAsciiAlpha","isAsciiDigit","isThai","isHan","isKatakana","isHiragana","isHalfwidthKatakana","HASH_CHANGE_TIMEOUT","POSITION_UPDATED_THRESHOLD","UPDATE_VIEWAREA_TIMEOUT","unescape","initialize","reInitialized","parseCurrentHash","destination","JSON","push","namedDest","forceReplace","isDestArraysEqual","dest","_pushOrReplaceState","shouldReplace","newState","fingerprint","uid","temporary","_tryPushCurrentPosition","position","_isValidState","_updateInternalState","removeTemporary","_updateViewarea","_popState","newHash","hashChanged","waitOnEventOrTimeout","destHash","nameddest","second","isEntryEqual","firstDest","secondDest","setHistory","navigateTo","goToDestination","destRef","explicitDest","destArray","getDestinationHash","escape","str","getAnchorUrl","setHash","zoomArgs","zoomArg","zoomArgNumber","parseFloat","allowNegativeOffset","isValidExplicitDestination","executeNamedAction","cachePageRef","refStr","pageRef","_cachedPageNumber","destLength","allowNull","DEFAULT_TITLE","addLinkAttributes","newWindow","rel","_setStyles","styleStr","_addToggleButton","toggler","shouldShowAll","_toggleOutlineItem","togglers","root","show","outline","fragment","queue","hasAnyNesting","levelData","itemsDiv","DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS","DELAY_BEFORE_HIDING_CONTROLS","ACTIVE_SELECTOR","CONTROLS_SELECTOR","MOUSE_SCROLL_COOLDOWN_TIME","PAGE_SWITCH_THRESHOLD","SWIPE_MIN_DISTANCE_THRESHOLD","SWIPE_ANGLE_THRESHOLD","Element","_mouseWheel","currentTime","storedTime","totalDelta","success","_mouseDown","isInternalLink","_touchSwipe","startX","startY","endX","endY","absAngle","SIDEBAR_WIDTH_VAR","SIDEBAR_MIN_WIDTH","SIDEBAR_RESIZING_CLASS","CSS","_updateWidth","maxWidth","_mouseMove","_mouseUp","updated","THUMBNAIL_SCROLL_MARGIN","THUMBNAIL_SELECTED_CLASS","watchScroll","getThumbnail","getVisibleElements","scrollThumbnailIntoView","prevThumbnailView","visibleThumbs","numVisibleThumbs","shouldScroll","scrollIntoView","PDFThumbnailView","viewport","firstPage","pageNum","thumbnail","defaultViewport","disableCanvasToImageConversion","setPageLabels","_ensurePdfPageLoaded","thumbView","MAX_NUM_SCALING_STEPS","THUMBNAIL_CANVAS_BORDER_WIDTH","THUMBNAIL_WIDTH","TempImageFactory","tempCanvasCache","getCanvas","tempCanvas","alpha","destroyCanvas","anchor","ring","borderAdjustment","setPdfPage","totalRotation","childNodes","update","scale","noCtxScale","_getPageDrawContext","canvas","outputScale","getOutputScale","className","image","renderCapability","finishRenderTask","renderTask","drawViewport","renderContinueCallback","renderContext","canvasContext","setImage","img","reducedWidth","reducedHeight","reducedImage","reducedImageCtx","setPageLabel","pageSpot","_scrollIntoView","pageDiv","ScrollMode","visiblePages","numVisiblePages","currentId","stillFullyVisible","DEFAULT_CACHE_SIZE","VERTICAL","HORIZONTAL","SpreadMode","ODD","EVEN","pageIdsToKeep","iMax","pagesToKeep","moveToEndOfArray","getPageView","_setCurrentPageNumber","resetCurrentPageView","val","pageLabel","pagesCapability","isOnePageRenderedResolved","onePageRenderedCapability","bindOnAfterAndBeforeDraw","textLayerFactory","annotationLayerFactory","getPagesLeft","_setScaleDispatchEvent","preset","presetValue","_setScaleUpdatePages","noScroll","newValue","isSameScale","_setScale","noPadding","hPadding","vPadding","pageWidthScale","pageHeightScale","horizontalScale","scrollPageIntoView","pageWidth","pageHeight","widthScale","heightScale","boundingRect","_resizeBuffer","suggestedCacheSize","_updateLocation","normalizedScaleValue","pdfOpenParams","currentPageView","topLeft","intLeft","intTop","containsElement","currentlyVisiblePages","scrollAhead","createTextLayerBuilder","enhanceTextSelection","createAnnotationLayerBuilder","isFirstPagePortrait","_updateScrollMode","_updateSpreadMode","pages","parity","spread","firstPageView","intent","dontFlip","AnnotationLayer","annotations","MAX_CANVAS_PIXELS","removeFromDOM","_resetZoomLayer","zoomLayerCanvas","keepZoomLayer","keepAnnotations","currentZoomLayerNode","currentAnnotationNode","isScalingRestricted","cancelRendering","renderingState","redrawAnnotations","relativeRotation","absRotation","scaleX","scaleY","textLayerViewport","textRelativeRotation","textAbsRotation","textLayerDiv","transX","transY","getPagePoint","canvasWrapper","textLayer","finishPaintTask","paintTask","resultPromise","readableStream","paintOnCanvas","onRenderContinue","cancel","isCanvasHidden","showCanvas","actualSizeViewport","pixelsInViewport","maxScale","sfx","approximateFraction","sfy","roundToDivide","transform","paintOnSvg","cancelled","ensureNotCancelled","svgGfx","svg","wrapper","EXPAND_DIVS_TIMEOUT","MATCH_SCROLL_OFFSET_TOP","MATCH_SCROLL_OFFSET_LEFT","endOfContent","numTextDivs","textLayerFrag","textContentStream","textDivs","textContentItemsStr","setTextContentStream","setTextContent","convertMatches","iIndex","end","ret","m","begin","divIdx","renderMatches","prevEnd","isSelectedPage","selectedMatchIdx","infinity","appendTextToDiv","span","i0","i1","isSelected","highlightSuffix","beginText","n0","n1","clearedUntilDivIdx","n","pageMatches","pageMatchesLength","expandDivsTimer","adjustTop","divBounds","eventName","close","eventDetails","lastPage","pageRotateCw","pageRotateCcw","setPageNumber","setPagesCount","_bindCursorToolsListener","buttons","_bindScrollModeListener","isScrollModeHorizontal","scrollModeChanged","_bindSpreadModeListener","spreadModeChanged","previousPageView","viewerNodes","scrolledDown","previousLocation","PAGE_NUMBER_LOADING_INDICATOR","SCALE_SELECT_CONTAINER_PADDING","SCALE_SELECT_PADDING","setPageScale","self","resetNumPages","pageScale","customScale","predefinedValueFound","option","updateLoadingIndicatorState","pageNumberInput","select","DEFAULT_VIEW_HISTORY_CACHE_SIZE","cacheSize","database","databaseStr","length","branch","localStorage","properties","GenericCom","GenericExternalServices","defaultPreferences","defaultValue","prefValue","valueType","defaultType","DISABLE_CREATE_OBJECT_URL","downloadUrl","createValidAbsoluteUrl","downloadData","webL10n","gL10nData","gTextData","gTextProp","gLanguage","gMacros","gReadyState","gAsyncResourceLoading","script","l10nId","l10nArgs","evtObject","onSuccess","onFailure","baseURL","text","dictionary","reBlank","reComment","reSection","reImport","reSplit","entries","rawText","currentLang","genericLang","lang","skipLang","loadImport","tmp","evalString","xhrLoadText","parseRawLines","parsedPropertiesCallback","parseProperties","langLinks","langCount","dict","defaultLocale","anyCaseLang","fireL10nReadyEvent","onResourceLoaded","gResourceCount","link","parseResource","resource","locales2rules","list","start","pluralRules","isBetween","getPluralRules","rv","substIndexes","substArguments","reIndex","reMatch","macroName","paramName","macro","reArgs","getL10nAttributes","getL10nData","getChildElementCount","children","l","textNode","count","getTranslatableChildren","elementCount","translateElement","getData","getText","getLanguage","setLanguage","loadLocale","getDirection","rtlList","shortCode","translate","getReadyState","ready","activeService","scratchCanvas","PRINT_RESOLUTION","PRINT_UNITS","PDFPrintService","layout","body","hasEqualPageSizes","pageSize","destroy","ensureOverlay","renderPages","pageCount","renderNextPage","renderProgress","renderPage","useRenderedPage","printItem","performPrint","throwIfInactive","activeServiceOnEntry","progressContainer","progressBar","progressPerc","hasAttachEvent","stopPropagationIfNeeded","overlayPromise"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;AClFA;AAqCA;AAAA,IArCA,2BAqCA;AACoE;AAClEA,gBAAcC,mBAAOA,CAD6C,CACpDA,CAAdD;AACAE,uBAAqBD,mBAAOA,CAFsC,EAE7CA,CAArBC;AAxCF;AAAA;AA+CiE;AAC/DD,qBAAOA,CADwD,EAC/DA;AAhDF;AAAA;AAqD2E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GhCA,WAHgC,EAGhCA,aAHgC,EAGhCA,cAHgC,EAGhCA,IAHgC,EAGqC;AACnE,uBAAmB;AACjB,YAAM,UADW,0CACX,CAAN;AAFiE;AAInE87B,oBAAgB,gEAJmD,IAInD,CAAhBA;AAEA,WANmE,aAMnE;AAT8B;AAAA,CAAlC/lC;QAaA,e,GAAA,e","file":"viewer.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/* Copyright 2016 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/* globals chrome */\n\n'use strict';\n\nif (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {\n var defaultUrl; // eslint-disable-line no-var\n\n (function rewriteUrlClosure() {\n // Run this code outside DOMContentLoaded to make sure that the URL\n // is rewritten as soon as possible.\n let queryString = document.location.search.slice(1);\n let m = /(^|&)file=([^&]*)/.exec(queryString);\n defaultUrl = m ? decodeURIComponent(m[2]) : '';\n\n // Example: chrome-extension://.../http://example.com/file.pdf\n let humanReadableUrl = '/' + defaultUrl + location.hash;\n history.replaceState(history.state, '', humanReadableUrl);\n if (top === window) {\n chrome.runtime.sendMessage('showPageAction');\n }\n })();\n}\n\nlet pdfjsWebApp, pdfjsWebAppOptions;\nif (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {\n pdfjsWebApp = require('./app.js');\n pdfjsWebAppOptions = require('./app_options.js');\n}\n\nif (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n require('./firefoxcom.js');\n require('./firefox_print_service.js');\n}\nif (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {\n require('./genericcom.js');\n}\nif (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {\n require('./chromecom.js');\n}\nif (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME || GENERIC')) {\n require('./pdf_print_service.js');\n}\n\nfunction getViewerConfiguration() {\n return {\n appContainer: document.body,\n mainContainer: document.getElementById('viewerContainer'),\n viewerContainer: document.getElementById('viewer'),\n eventBus: null, // using global event bus with DOM events\n toolbar: {\n container: document.getElementById('toolbarViewer'),\n numPages: document.getElementById('numPages'),\n pageNumber: document.getElementById('pageNumber'),\n scaleSelectContainer: document.getElementById('scaleSelectContainer'),\n scaleSelect: document.getElementById('scaleSelect'),\n customScaleOption: document.getElementById('customScaleOption'),\n previous: document.getElementById('previous'),\n next: document.getElementById('next'),\n zoomIn: document.getElementById('zoomIn'),\n zoomOut: document.getElementById('zoomOut'),\n viewFind: document.getElementById('viewFind'),\n openFile: document.getElementById('openFile'),\n print: document.getElementById('print'),\n presentationModeButton: document.getElementById('presentationMode'),\n download: document.getElementById('download'),\n viewBookmark: document.getElementById('viewBookmark'),\n },\n secondaryToolbar: {\n toolbar: document.getElementById('secondaryToolbar'),\n toggleButton: document.getElementById('secondaryToolbarToggle'),\n toolbarButtonContainer:\n document.getElementById('secondaryToolbarButtonContainer'),\n presentationModeButton:\n document.getElementById('secondaryPresentationMode'),\n openFileButton: document.getElementById('secondaryOpenFile'),\n printButton: document.getElementById('secondaryPrint'),\n downloadButton: document.getElementById('secondaryDownload'),\n viewBookmarkButton: document.getElementById('secondaryViewBookmark'),\n firstPageButton: document.getElementById('firstPage'),\n lastPageButton: document.getElementById('lastPage'),\n pageRotateCwButton: document.getElementById('pageRotateCw'),\n pageRotateCcwButton: document.getElementById('pageRotateCcw'),\n cursorSelectToolButton: document.getElementById('cursorSelectTool'),\n cursorHandToolButton: document.getElementById('cursorHandTool'),\n scrollVerticalButton: document.getElementById('scrollVertical'),\n scrollHorizontalButton: document.getElementById('scrollHorizontal'),\n scrollWrappedButton: document.getElementById('scrollWrapped'),\n spreadNoneButton: document.getElementById('spreadNone'),\n spreadOddButton: document.getElementById('spreadOdd'),\n spreadEvenButton: document.getElementById('spreadEven'),\n documentPropertiesButton: document.getElementById('documentProperties'),\n },\n fullscreen: {\n contextFirstPage: document.getElementById('contextFirstPage'),\n contextLastPage: document.getElementById('contextLastPage'),\n contextPageRotateCw: document.getElementById('contextPageRotateCw'),\n contextPageRotateCcw: document.getElementById('contextPageRotateCcw'),\n },\n sidebar: {\n // Divs (and sidebar button)\n outerContainer: document.getElementById('outerContainer'),\n viewerContainer: document.getElementById('viewerContainer'),\n toggleButton: document.getElementById('sidebarToggle'),\n // Buttons\n thumbnailButton: document.getElementById('viewThumbnail'),\n outlineButton: document.getElementById('viewOutline'),\n attachmentsButton: document.getElementById('viewAttachments'),\n // Views\n thumbnailView: document.getElementById('thumbnailView'),\n outlineView: document.getElementById('outlineView'),\n attachmentsView: document.getElementById('attachmentsView'),\n },\n sidebarResizer: {\n outerContainer: document.getElementById('outerContainer'),\n resizer: document.getElementById('sidebarResizer'),\n },\n findBar: {\n bar: document.getElementById('findbar'),\n toggleButton: document.getElementById('viewFind'),\n findField: document.getElementById('findInput'),\n highlightAllCheckbox: document.getElementById('findHighlightAll'),\n caseSensitiveCheckbox: document.getElementById('findMatchCase'),\n entireWordCheckbox: document.getElementById('findEntireWord'),\n findMsg: document.getElementById('findMsg'),\n findResultsCount: document.getElementById('findResultsCount'),\n findPreviousButton: document.getElementById('findPrevious'),\n findNextButton: document.getElementById('findNext'),\n },\n passwordOverlay: {\n overlayName: 'passwordOverlay',\n container: document.getElementById('passwordOverlay'),\n label: document.getElementById('passwordText'),\n input: document.getElementById('password'),\n submitButton: document.getElementById('passwordSubmit'),\n cancelButton: document.getElementById('passwordCancel'),\n },\n documentProperties: {\n overlayName: 'documentPropertiesOverlay',\n container: document.getElementById('documentPropertiesOverlay'),\n closeButton: document.getElementById('documentPropertiesClose'),\n fields: {\n 'fileName': document.getElementById('fileNameField'),\n 'fileSize': document.getElementById('fileSizeField'),\n 'title': document.getElementById('titleField'),\n 'author': document.getElementById('authorField'),\n 'subject': document.getElementById('subjectField'),\n 'keywords': document.getElementById('keywordsField'),\n 'creationDate': document.getElementById('creationDateField'),\n 'modificationDate': document.getElementById('modificationDateField'),\n 'creator': document.getElementById('creatorField'),\n 'producer': document.getElementById('producerField'),\n 'version': document.getElementById('versionField'),\n 'pageCount': document.getElementById('pageCountField'),\n 'pageSize': document.getElementById('pageSizeField'),\n 'linearized': document.getElementById('linearizedField'),\n },\n },\n errorWrapper: {\n container: document.getElementById('errorWrapper'),\n errorMessage: document.getElementById('errorMessage'),\n closeButton: document.getElementById('errorClose'),\n errorMoreInfo: document.getElementById('errorMoreInfo'),\n moreInfoButton: document.getElementById('errorShowMore'),\n lessInfoButton: document.getElementById('errorShowLess'),\n },\n printContainer: document.getElementById('printContainer'),\n openFileInputName: 'fileInput',\n debuggerScriptPath: './debugger.js',\n };\n}\n\nfunction webViewerLoad() {\n let config = getViewerConfiguration();\n if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {\n Promise.all([\n SystemJS.import('pdfjs-web/app'),\n SystemJS.import('pdfjs-web/app_options'),\n SystemJS.import('pdfjs-web/genericcom'),\n SystemJS.import('pdfjs-web/pdf_print_service'),\n ]).then(function([app, appOptions, ...otherModules]) {\n window.PDFViewerApplication = app.PDFViewerApplication;\n window.PDFViewerApplicationOptions = appOptions.AppOptions;\n app.PDFViewerApplication.run(config);\n });\n } else {\n if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {\n pdfjsWebAppOptions.AppOptions.set('defaultUrl', defaultUrl);\n }\n\n window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;\n window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;\n pdfjsWebApp.PDFViewerApplication.run(config);\n }\n}\n\nif (document.readyState === 'interactive' ||\n document.readyState === 'complete') {\n webViewerLoad();\n} else {\n document.addEventListener('DOMContentLoaded', webViewerLoad, true);\n}\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/* globals PDFBug, Stats */\n\nimport {\n animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, isValidRotation,\n MAX_SCALE, MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta,\n parseQueryString, PresentationModeState, ProgressBar, RendererType,\n TextLayerMode\n} from './ui_utils';\nimport {\n build, createObjectURL, getDocument, getFilenameFromUrl, GlobalWorkerOptions,\n InvalidPDFException, LinkTarget, loadScript, MissingPDFException, OPS,\n PDFWorker, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, URL,\n version\n} from 'pdfjs-lib';\nimport { CursorTool, PDFCursorTools } from './pdf_cursor_tools';\nimport { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';\nimport { PDFSidebar, SidebarView } from './pdf_sidebar';\nimport { AppOptions } from './app_options';\nimport { getGlobalEventBus } from './dom_events';\nimport { OverlayManager } from './overlay_manager';\nimport { PasswordPrompt } from './password_prompt';\nimport { PDFAttachmentViewer } from './pdf_attachment_viewer';\nimport { PDFDocumentProperties } from './pdf_document_properties';\nimport { PDFFindBar } from './pdf_find_bar';\nimport { PDFFindController } from './pdf_find_controller';\nimport { PDFHistory } from './pdf_history';\nimport { PDFLinkService } from './pdf_link_service';\nimport { PDFOutlineViewer } from './pdf_outline_viewer';\nimport { PDFPresentationMode } from './pdf_presentation_mode';\nimport { PDFSidebarResizer } from './pdf_sidebar_resizer';\nimport { PDFThumbnailViewer } from './pdf_thumbnail_viewer';\nimport { PDFViewer } from './pdf_viewer';\nimport { SecondaryToolbar } from './secondary_toolbar';\nimport { Toolbar } from './toolbar';\nimport { ViewHistory } from './view_history';\n\nconst DEFAULT_SCALE_DELTA = 1.1;\nconst DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; // ms\nconst FORCE_PAGES_LOADED_TIMEOUT = 10000; // ms\n\nconst DefaultExternalServices = {\n updateFindControlState(data) {},\n updateFindMatchesCount(data) {},\n initPassiveLoading(callbacks) {},\n fallback(data, callback) {},\n reportTelemetry(data) {},\n createDownloadManager(options) {\n throw new Error('Not implemented: createDownloadManager');\n },\n createPreferences() {\n throw new Error('Not implemented: createPreferences');\n },\n createL10n(options) {\n throw new Error('Not implemented: createL10n');\n },\n supportsIntegratedFind: false,\n supportsDocumentFonts: true,\n supportsDocumentColors: true,\n supportedMouseWheelZoomModifierKeys: {\n ctrlKey: true,\n metaKey: true,\n },\n};\n\nlet PDFViewerApplication = {\n initialBookmark: document.location.hash.substring(1),\n initialized: false,\n fellback: false,\n appConfig: null,\n pdfDocument: null,\n pdfLoadingTask: null,\n printService: null,\n /** @type {PDFViewer} */\n pdfViewer: null,\n /** @type {PDFThumbnailViewer} */\n pdfThumbnailViewer: null,\n /** @type {PDFRenderingQueue} */\n pdfRenderingQueue: null,\n /** @type {PDFPresentationMode} */\n pdfPresentationMode: null,\n /** @type {PDFDocumentProperties} */\n pdfDocumentProperties: null,\n /** @type {PDFLinkService} */\n pdfLinkService: null,\n /** @type {PDFHistory} */\n pdfHistory: null,\n /** @type {PDFSidebar} */\n pdfSidebar: null,\n /** @type {PDFSidebarResizer} */\n pdfSidebarResizer: null,\n /** @type {PDFOutlineViewer} */\n pdfOutlineViewer: null,\n /** @type {PDFAttachmentViewer} */\n pdfAttachmentViewer: null,\n /** @type {PDFCursorTools} */\n pdfCursorTools: null,\n /** @type {ViewHistory} */\n store: null,\n /** @type {DownloadManager} */\n downloadManager: null,\n /** @type {OverlayManager} */\n overlayManager: null,\n /** @type {Preferences} */\n preferences: null,\n /** @type {Toolbar} */\n toolbar: null,\n /** @type {SecondaryToolbar} */\n secondaryToolbar: null,\n /** @type {EventBus} */\n eventBus: null,\n /** @type {IL10n} */\n l10n: null,\n isInitialViewSet: false,\n downloadComplete: false,\n isViewerEmbedded: (window.parent !== window),\n url: '',\n baseUrl: '',\n externalServices: DefaultExternalServices,\n _boundEvents: {},\n contentDispositionFilename: null,\n\n // Called once when the document is loaded.\n async initialize(appConfig) {\n this.preferences = this.externalServices.createPreferences();\n this.appConfig = appConfig;\n\n await this._readPreferences();\n await this._parseHashParameters();\n await this._initializeL10n();\n\n if (this.isViewerEmbedded &&\n AppOptions.get('externalLinkTarget') === LinkTarget.NONE) {\n // Prevent external links from \"replacing\" the viewer,\n // when it's embedded in e.g. an <iframe> or an <object>.\n AppOptions.set('externalLinkTarget', LinkTarget.TOP);\n }\n await this._initializeViewerComponents();\n\n // Bind the various event handlers *after* the viewer has been\n // initialized, to prevent errors if an event arrives too soon.\n this.bindEvents();\n this.bindWindowEvents();\n\n // We can start UI localization now.\n let appContainer = appConfig.appContainer || document.documentElement;\n this.l10n.translate(appContainer).then(() => {\n // Dispatch the 'localized' event on the `eventBus` once the viewer\n // has been fully initialized and translated.\n this.eventBus.dispatch('localized', { source: this, });\n });\n\n this.initialized = true;\n },\n\n /**\n * @private\n */\n async _readPreferences() {\n // A subset of the Preferences that `AppOptions`, for compatibility reasons,\n // is allowed to override if the `AppOptions` values matches the ones below.\n const OVERRIDES = {\n disableFontFace: true,\n disableRange: true,\n disableStream: true,\n textLayerMode: TextLayerMode.DISABLE,\n };\n\n try {\n const prefs = await this.preferences.getAll();\n for (let name in prefs) {\n if ((name in OVERRIDES) && AppOptions.get(name) === OVERRIDES[name]) {\n continue;\n }\n AppOptions.set(name, prefs[name]);\n }\n } catch (reason) { }\n },\n\n /**\n * @private\n */\n async _parseHashParameters() {\n if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION') &&\n !AppOptions.get('pdfBugEnabled')) {\n return;\n }\n const waitOn = [];\n\n // Special debugging flags in the hash section of the URL.\n let hash = document.location.hash.substring(1);\n let hashParams = parseQueryString(hash);\n\n if ('disableworker' in hashParams &&\n hashParams['disableworker'] === 'true') {\n waitOn.push(loadFakeWorker());\n }\n if ('disablerange' in hashParams) {\n AppOptions.set('disableRange', hashParams['disablerange'] === 'true');\n }\n if ('disablestream' in hashParams) {\n AppOptions.set('disableStream', hashParams['disablestream'] === 'true');\n }\n if ('disableautofetch' in hashParams) {\n AppOptions.set('disableAutoFetch',\n hashParams['disableautofetch'] === 'true');\n }\n if ('disablefontface' in hashParams) {\n AppOptions.set('disableFontFace',\n hashParams['disablefontface'] === 'true');\n }\n if ('disablehistory' in hashParams) {\n AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');\n }\n if ('webgl' in hashParams) {\n AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');\n }\n if ('useonlycsszoom' in hashParams) {\n AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');\n }\n if ('verbosity' in hashParams) {\n AppOptions.set('verbosity', hashParams['verbosity'] | 0);\n }\n if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) &&\n hashParams['disablebcmaps'] === 'true') {\n AppOptions.set('cMapUrl', '../external/cmaps/');\n AppOptions.set('cMapPacked', false);\n }\n if ('textlayer' in hashParams) {\n switch (hashParams['textlayer']) {\n case 'off':\n AppOptions.set('textLayerMode', TextLayerMode.DISABLE);\n break;\n case 'visible':\n case 'shadow':\n case 'hover':\n let viewer = this.appConfig.viewerContainer;\n viewer.classList.add('textLayer-' + hashParams['textlayer']);\n break;\n }\n }\n if ('pdfbug' in hashParams) {\n AppOptions.set('pdfBug', true);\n let enabled = hashParams['pdfbug'].split(',');\n waitOn.push(loadAndEnablePDFBug(enabled));\n }\n // It is not possible to change locale for the (various) extension builds.\n if ((typeof PDFJSDev === 'undefined' ||\n PDFJSDev.test('!PRODUCTION || GENERIC')) && 'locale' in hashParams) {\n AppOptions.set('locale', hashParams['locale']);\n }\n\n return Promise.all(waitOn).catch((reason) => {\n console.error(`_parseHashParameters: \"${reason.message}\".`);\n });\n },\n\n /**\n * @private\n */\n async _initializeL10n() {\n this.l10n = this.externalServices.createL10n({\n locale: AppOptions.get('locale'),\n });\n const dir = await this.l10n.getDirection();\n document.getElementsByTagName('html')[0].dir = dir;\n },\n\n /**\n * @private\n */\n async _initializeViewerComponents() {\n const appConfig = this.appConfig;\n\n this.overlayManager = new OverlayManager();\n\n const dispatchToDOM = AppOptions.get('eventBusDispatchToDOM');\n const eventBus = appConfig.eventBus || getGlobalEventBus(dispatchToDOM);\n this.eventBus = eventBus;\n\n let pdfRenderingQueue = new PDFRenderingQueue();\n pdfRenderingQueue.onIdle = this.cleanup.bind(this);\n this.pdfRenderingQueue = pdfRenderingQueue;\n\n let pdfLinkService = new PDFLinkService({\n eventBus,\n externalLinkTarget: AppOptions.get('externalLinkTarget'),\n externalLinkRel: AppOptions.get('externalLinkRel'),\n });\n this.pdfLinkService = pdfLinkService;\n\n let downloadManager = this.externalServices.createDownloadManager({\n disableCreateObjectURL: AppOptions.get('disableCreateObjectURL'),\n });\n this.downloadManager = downloadManager;\n\n const findController = new PDFFindController({\n linkService: pdfLinkService,\n eventBus,\n });\n this.findController = findController;\n\n const container = appConfig.mainContainer;\n const viewer = appConfig.viewerContainer;\n this.pdfViewer = new PDFViewer({\n container,\n viewer,\n eventBus,\n renderingQueue: pdfRenderingQueue,\n linkService: pdfLinkService,\n downloadManager,\n findController,\n renderer: AppOptions.get('renderer'),\n enableWebGL: AppOptions.get('enableWebGL'),\n l10n: this.l10n,\n textLayerMode: AppOptions.get('textLayerMode'),\n imageResourcesPath: AppOptions.get('imageResourcesPath'),\n renderInteractiveForms: AppOptions.get('renderInteractiveForms'),\n enablePrintAutoRotate: AppOptions.get('enablePrintAutoRotate'),\n useOnlyCssZoom: AppOptions.get('useOnlyCssZoom'),\n maxCanvasPixels: AppOptions.get('maxCanvasPixels'),\n });\n pdfRenderingQueue.setViewer(this.pdfViewer);\n pdfLinkService.setViewer(this.pdfViewer);\n\n let thumbnailContainer = appConfig.sidebar.thumbnailView;\n this.pdfThumbnailViewer = new PDFThumbnailViewer({\n container: thumbnailContainer,\n renderingQueue: pdfRenderingQueue,\n linkService: pdfLinkService,\n l10n: this.l10n,\n });\n pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);\n\n this.pdfHistory = new PDFHistory({\n linkService: pdfLinkService,\n eventBus,\n });\n pdfLinkService.setHistory(this.pdfHistory);\n\n this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);\n\n this.pdfDocumentProperties =\n new PDFDocumentProperties(appConfig.documentProperties,\n this.overlayManager, eventBus, this.l10n);\n\n this.pdfCursorTools = new PDFCursorTools({\n container,\n eventBus,\n cursorToolOnLoad: AppOptions.get('cursorToolOnLoad'),\n });\n\n this.toolbar = new Toolbar(appConfig.toolbar, eventBus, this.l10n);\n\n this.secondaryToolbar =\n new SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);\n\n if (this.supportsFullscreen) {\n this.pdfPresentationMode = new PDFPresentationMode({\n container,\n viewer,\n pdfViewer: this.pdfViewer,\n eventBus,\n contextMenuItems: appConfig.fullscreen,\n });\n }\n\n this.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay,\n this.overlayManager, this.l10n);\n\n this.pdfOutlineViewer = new PDFOutlineViewer({\n container: appConfig.sidebar.outlineView,\n eventBus,\n linkService: pdfLinkService,\n });\n\n this.pdfAttachmentViewer = new PDFAttachmentViewer({\n container: appConfig.sidebar.attachmentsView,\n eventBus,\n downloadManager,\n });\n\n // TODO: improve `PDFSidebar` constructor parameter passing\n let sidebarConfig = Object.create(appConfig.sidebar);\n sidebarConfig.pdfViewer = this.pdfViewer;\n sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer;\n this.pdfSidebar = new PDFSidebar(sidebarConfig, eventBus, this.l10n);\n this.pdfSidebar.onToggled = this.forceRendering.bind(this);\n\n this.pdfSidebarResizer = new PDFSidebarResizer(appConfig.sidebarResizer,\n eventBus, this.l10n);\n },\n\n run(config) {\n this.initialize(config).then(webViewerInitialized);\n },\n\n zoomIn(ticks) {\n let newScale = this.pdfViewer.currentScale;\n do {\n newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);\n newScale = Math.ceil(newScale * 10) / 10;\n newScale = Math.min(MAX_SCALE, newScale);\n } while (--ticks > 0 && newScale < MAX_SCALE);\n this.pdfViewer.currentScaleValue = newScale;\n },\n\n zoomOut(ticks) {\n let newScale = this.pdfViewer.currentScale;\n do {\n newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);\n newScale = Math.floor(newScale * 10) / 10;\n newScale = Math.max(MIN_SCALE, newScale);\n } while (--ticks > 0 && newScale > MIN_SCALE);\n this.pdfViewer.currentScaleValue = newScale;\n },\n\n get pagesCount() {\n return this.pdfDocument ? this.pdfDocument.numPages : 0;\n },\n\n set page(val) {\n this.pdfViewer.currentPageNumber = val;\n },\n\n get page() {\n return this.pdfViewer.currentPageNumber;\n },\n\n get printing() {\n return !!this.printService;\n },\n\n get supportsPrinting() {\n return PDFPrintServiceFactory.instance.supportsPrinting;\n },\n\n get supportsFullscreen() {\n let support;\n if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {\n support = document.fullscreenEnabled === true ||\n document.mozFullScreenEnabled === true;\n } else {\n let doc = document.documentElement;\n support = !!(doc.requestFullscreen || doc.mozRequestFullScreen ||\n doc.webkitRequestFullScreen || doc.msRequestFullscreen);\n\n if (document.fullscreenEnabled === false ||\n document.mozFullScreenEnabled === false ||\n document.webkitFullscreenEnabled === false ||\n document.msFullscreenEnabled === false) {\n support = false;\n }\n }\n return shadow(this, 'supportsFullscreen', support);\n },\n\n get supportsIntegratedFind() {\n return this.externalServices.supportsIntegratedFind;\n },\n\n get supportsDocumentFonts() {\n return this.externalServices.supportsDocumentFonts;\n },\n\n get supportsDocumentColors() {\n return this.externalServices.supportsDocumentColors;\n },\n\n get loadingBar() {\n let bar = new ProgressBar('#loadingBar');\n return shadow(this, 'loadingBar', bar);\n },\n\n get supportedMouseWheelZoomModifierKeys() {\n return this.externalServices.supportedMouseWheelZoomModifierKeys;\n },\n\n initPassiveLoading() {\n if (typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {\n throw new Error('Not implemented: initPassiveLoading');\n }\n this.externalServices.initPassiveLoading({\n onOpenWithTransport(url, length, transport) {\n PDFViewerApplication.open(url, { range: transport, });\n\n if (length) {\n PDFViewerApplication.pdfDocumentProperties.setFileSize(length);\n }\n },\n onOpenWithData(data) {\n PDFViewerApplication.open(data);\n },\n onOpenWithURL(url, length, originalUrl) {\n let file = url, args = null;\n if (length !== undefined) {\n args = { length, };\n }\n if (originalUrl !== undefined) {\n file = { url, originalUrl, };\n }\n PDFViewerApplication.open(file, args);\n },\n onError(err) {\n PDFViewerApplication.l10n.get('loading_error', null,\n 'An error occurred while loading the PDF.').then((msg) => {\n PDFViewerApplication.error(msg, err);\n });\n },\n onProgress(loaded, total) {\n PDFViewerApplication.progress(loaded / total);\n },\n });\n },\n\n setTitleUsingUrl(url = '') {\n this.url = url;\n this.baseUrl = url.split('#')[0];\n let title = getPDFFileNameFromURL(url, '');\n if (!title) {\n try {\n title = decodeURIComponent(getFilenameFromUrl(url)) || url;\n } catch (ex) {\n // decodeURIComponent may throw URIError,\n // fall back to using the unprocessed url in that case\n title = url;\n }\n }\n this.setTitle(title);\n },\n\n setTitle(title) {\n if (this.isViewerEmbedded) {\n // Embedded PDF viewers should not be changing their parent page's title.\n return;\n }\n document.title = title;\n },\n\n /**\n * Closes opened PDF document.\n * @returns {Promise} - Returns the promise, which is resolved when all\n * destruction is completed.\n */\n async close() {\n let errorWrapper = this.appConfig.errorWrapper.container;\n errorWrapper.setAttribute('hidden', 'true');\n\n if (!this.pdfLoadingTask) {\n return;\n }\n\n let promise = this.pdfLoadingTask.destroy();\n this.pdfLoadingTask = null;\n\n if (this.pdfDocument) {\n this.pdfDocument = null;\n\n this.pdfThumbnailViewer.setDocument(null);\n this.pdfViewer.setDocument(null);\n this.pdfLinkService.setDocument(null);\n this.pdfDocumentProperties.setDocument(null);\n }\n this.store = null;\n this.isInitialViewSet = false;\n this.downloadComplete = false;\n this.url = '';\n this.baseUrl = '';\n this.contentDispositionFilename = null;\n\n this.pdfSidebar.reset();\n this.pdfOutlineViewer.reset();\n this.pdfAttachmentViewer.reset();\n\n this.findBar.reset();\n this.toolbar.reset();\n this.secondaryToolbar.reset();\n\n if (typeof PDFBug !== 'undefined') {\n PDFBug.cleanup();\n }\n return promise;\n },\n\n /**\n * Opens PDF document specified by URL or array with additional arguments.\n * @param {string|TypedArray|ArrayBuffer} file - PDF location or binary data.\n * @param {Object} args - (optional) Additional arguments for the getDocument\n * call, e.g. HTTP headers ('httpHeaders') or\n * alternative data transport ('range').\n * @returns {Promise} - Returns the promise, which is resolved when document\n * is opened.\n */\n async open(file, args) {\n if (this.pdfLoadingTask) {\n // We need to destroy already opened document.\n await this.close();\n }\n // Set the necessary global worker parameters, using the available options.\n const workerParameters = AppOptions.getAll('worker');\n for (let key in workerParameters) {\n GlobalWorkerOptions[key] = workerParameters[key];\n }\n\n let parameters = Object.create(null);\n if (typeof file === 'string') { // URL\n this.setTitleUsingUrl(file);\n parameters.url = file;\n } else if (file && 'byteLength' in file) { // ArrayBuffer\n parameters.data = file;\n } else if (file.url && file.originalUrl) {\n this.setTitleUsingUrl(file.originalUrl);\n parameters.url = file.url;\n }\n if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {\n parameters.docBaseUrl = document.URL.split('#')[0];\n } else if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {\n parameters.docBaseUrl = this.baseUrl;\n }\n // Set the necessary API parameters, using the available options.\n const apiParameters = AppOptions.getAll('api');\n for (let key in apiParameters) {\n parameters[key] = apiParameters[key];\n }\n\n if (args) {\n for (let prop in args) {\n if (prop === 'length') {\n this.pdfDocumentProperties.setFileSize(args[prop]);\n }\n parameters[prop] = args[prop];\n }\n }\n\n let loadingTask = getDocument(parameters);\n this.pdfLoadingTask = loadingTask;\n\n loadingTask.onPassword = (updateCallback, reason) => {\n this.passwordPrompt.setUpdateCallback(updateCallback, reason);\n this.passwordPrompt.open();\n };\n\n loadingTask.onProgress = ({ loaded, total, }) => {\n this.progress(loaded / total);\n };\n\n // Listen for unsupported features to trigger the fallback UI.\n loadingTask.onUnsupportedFeature = this.fallback.bind(this);\n\n return loadingTask.promise.then((pdfDocument) => {\n this.load(pdfDocument);\n }, (exception) => {\n if (loadingTask !== this.pdfLoadingTask) {\n return; // Ignore errors for previously opened PDF files.\n }\n\n let message = exception && exception.message;\n let loadingErrorMessage;\n if (exception instanceof InvalidPDFException) {\n // change error message also for other builds\n loadingErrorMessage = this.l10n.get('invalid_file_error', null,\n 'Invalid or corrupted PDF file.');\n } else if (exception instanceof MissingPDFException) {\n // special message for missing PDF's\n loadingErrorMessage = this.l10n.get('missing_file_error', null,\n 'Missing PDF file.');\n } else if (exception instanceof UnexpectedResponseException) {\n loadingErrorMessage = this.l10n.get('unexpected_response_error', null,\n 'Unexpected server response.');\n } else {\n loadingErrorMessage = this.l10n.get('loading_error', null,\n 'An error occurred while loading the PDF.');\n }\n\n return loadingErrorMessage.then((msg) => {\n this.error(msg, { message, });\n throw new Error(msg);\n });\n });\n },\n\n download() {\n function downloadByUrl() {\n downloadManager.downloadUrl(url, filename);\n }\n\n let url = this.baseUrl;\n // Use this.url instead of this.baseUrl to perform filename detection based\n // on the reference fragment as ultimate fallback if needed.\n let filename = this.contentDispositionFilename ||\n getPDFFileNameFromURL(this.url);\n let downloadManager = this.downloadManager;\n downloadManager.onerror = (err) => {\n // This error won't really be helpful because it's likely the\n // fallback won't work either (or is already open).\n this.error(`PDF failed to download: ${err}`);\n };\n\n // When the PDF document isn't ready, or the PDF file is still downloading,\n // simply download using the URL.\n if (!this.pdfDocument || !this.downloadComplete) {\n downloadByUrl();\n return;\n }\n\n this.pdfDocument.getData().then(function(data) {\n const blob = new Blob([data], { type: 'application/pdf', });\n downloadManager.download(blob, url, filename);\n }).catch(downloadByUrl); // Error occurred, try downloading with the URL.\n },\n\n fallback(featureId) {\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n // Only trigger the fallback once so we don't spam the user with messages\n // for one PDF.\n if (this.fellback) {\n return;\n }\n this.fellback = true;\n this.externalServices.fallback({\n featureId,\n url: this.baseUrl,\n }, function response(download) {\n if (!download) {\n return;\n }\n PDFViewerApplication.download();\n });\n }\n },\n\n /**\n * Show the error box.\n * @param {String} message A message that is human readable.\n * @param {Object} moreInfo (optional) Further information about the error\n * that is more technical. Should have a 'message'\n * and optionally a 'stack' property.\n */\n error(message, moreInfo) {\n let moreInfoText = [this.l10n.get('error_version_info',\n { version: version || '?', build: build || '?', },\n 'PDF.js v{{version}} (build: {{build}})')];\n if (moreInfo) {\n moreInfoText.push(\n this.l10n.get('error_message', { message: moreInfo.message, },\n 'Message: {{message}}'));\n if (moreInfo.stack) {\n moreInfoText.push(\n this.l10n.get('error_stack', { stack: moreInfo.stack, },\n 'Stack: {{stack}}'));\n } else {\n if (moreInfo.filename) {\n moreInfoText.push(\n this.l10n.get('error_file', { file: moreInfo.filename, },\n 'File: {{file}}'));\n }\n if (moreInfo.lineNumber) {\n moreInfoText.push(\n this.l10n.get('error_line', { line: moreInfo.lineNumber, },\n 'Line: {{line}}'));\n }\n }\n }\n\n if (typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n let errorWrapperConfig = this.appConfig.errorWrapper;\n let errorWrapper = errorWrapperConfig.container;\n errorWrapper.removeAttribute('hidden');\n\n let errorMessage = errorWrapperConfig.errorMessage;\n errorMessage.textContent = message;\n\n let closeButton = errorWrapperConfig.closeButton;\n closeButton.onclick = function() {\n errorWrapper.setAttribute('hidden', 'true');\n };\n\n let errorMoreInfo = errorWrapperConfig.errorMoreInfo;\n let moreInfoButton = errorWrapperConfig.moreInfoButton;\n let lessInfoButton = errorWrapperConfig.lessInfoButton;\n moreInfoButton.onclick = function() {\n errorMoreInfo.removeAttribute('hidden');\n moreInfoButton.setAttribute('hidden', 'true');\n lessInfoButton.removeAttribute('hidden');\n errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';\n };\n lessInfoButton.onclick = function() {\n errorMoreInfo.setAttribute('hidden', 'true');\n moreInfoButton.removeAttribute('hidden');\n lessInfoButton.setAttribute('hidden', 'true');\n };\n moreInfoButton.oncontextmenu = noContextMenuHandler;\n lessInfoButton.oncontextmenu = noContextMenuHandler;\n closeButton.oncontextmenu = noContextMenuHandler;\n moreInfoButton.removeAttribute('hidden');\n lessInfoButton.setAttribute('hidden', 'true');\n Promise.all(moreInfoText).then((parts) => {\n errorMoreInfo.value = parts.join('\\n');\n });\n } else {\n Promise.all(moreInfoText).then((parts) => {\n console.error(message + '\\n' + parts.join('\\n'));\n });\n this.fallback();\n }\n },\n\n progress(level) {\n if (this.downloadComplete) {\n // Don't accidentally show the loading bar again when the entire file has\n // already been fetched (only an issue when disableAutoFetch is enabled).\n return;\n }\n let percent = Math.round(level * 100);\n // When we transition from full request to range requests, it's possible\n // that we discard some of the loaded data. This can cause the loading\n // bar to move backwards. So prevent this by only updating the bar if it\n // increases.\n if (percent > this.loadingBar.percent || isNaN(percent)) {\n this.loadingBar.percent = percent;\n\n // When disableAutoFetch is enabled, it's not uncommon for the entire file\n // to never be fetched (depends on e.g. the file structure). In this case\n // the loading bar will not be completely filled, nor will it be hidden.\n // To prevent displaying a partially filled loading bar permanently, we\n // hide it when no data has been loaded during a certain amount of time.\n const disableAutoFetch = this.pdfDocument ?\n this.pdfDocument.loadingParams['disableAutoFetch'] :\n AppOptions.get('disableAutoFetch');\n\n if (disableAutoFetch && percent) {\n if (this.disableAutoFetchLoadingBarTimeout) {\n clearTimeout(this.disableAutoFetchLoadingBarTimeout);\n this.disableAutoFetchLoadingBarTimeout = null;\n }\n this.loadingBar.show();\n\n this.disableAutoFetchLoadingBarTimeout = setTimeout(() => {\n this.loadingBar.hide();\n this.disableAutoFetchLoadingBarTimeout = null;\n }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);\n }\n }\n },\n\n load(pdfDocument) {\n this.pdfDocument = pdfDocument;\n\n pdfDocument.getDownloadInfo().then(() => {\n this.downloadComplete = true;\n this.loadingBar.hide();\n\n firstPagePromise.then(() => {\n this.eventBus.dispatch('documentloaded', { source: this, });\n // TODO: Remove the following event, i.e. 'documentload',\n // once the mozilla-central tests have been updated.\n this.eventBus.dispatch('documentload', { source: this, });\n });\n });\n\n // Since the `setInitialView` call below depends on this being resolved,\n // fetch it early to avoid delaying initial rendering of the PDF document.\n let pageModePromise = pdfDocument.getPageMode().catch(\n function() { /* Avoid breaking initial rendering; ignoring errors. */ });\n\n this.toolbar.setPagesCount(pdfDocument.numPages, false);\n this.secondaryToolbar.setPagesCount(pdfDocument.numPages);\n\n const store = this.store = new ViewHistory(pdfDocument.fingerprint);\n\n let baseDocumentUrl;\n if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n baseDocumentUrl = null;\n } else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n baseDocumentUrl = this.baseUrl;\n } else if (PDFJSDev.test('CHROME')) {\n baseDocumentUrl = location.href.split('#')[0];\n }\n this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);\n this.pdfDocumentProperties.setDocument(pdfDocument, this.url);\n\n let pdfViewer = this.pdfViewer;\n pdfViewer.setDocument(pdfDocument);\n let firstPagePromise = pdfViewer.firstPagePromise;\n let pagesPromise = pdfViewer.pagesPromise;\n let onePageRendered = pdfViewer.onePageRendered;\n\n let pdfThumbnailViewer = this.pdfThumbnailViewer;\n pdfThumbnailViewer.setDocument(pdfDocument);\n\n firstPagePromise.then((pdfPage) => {\n this.loadingBar.setWidth(this.appConfig.viewerContainer);\n\n if (!AppOptions.get('disableHistory') && !this.isViewerEmbedded) {\n // The browsing history is only enabled when the viewer is standalone,\n // i.e. not when it is embedded in a web page.\n let resetHistory = !AppOptions.get('showPreviousViewOnLoad');\n this.pdfHistory.initialize(pdfDocument.fingerprint, resetHistory);\n\n if (this.pdfHistory.initialBookmark) {\n this.initialBookmark = this.pdfHistory.initialBookmark;\n\n this.initialRotation = this.pdfHistory.initialRotation;\n }\n }\n\n let storePromise = store.getMultiple({\n page: null,\n zoom: DEFAULT_SCALE_VALUE,\n scrollLeft: '0',\n scrollTop: '0',\n rotation: null,\n sidebarView: SidebarView.NONE,\n scrollMode: null,\n spreadMode: null,\n }).catch(() => { /* Unable to read from storage; ignoring errors. */ });\n\n Promise.all([\n storePromise, pageModePromise,\n ]).then(async ([values = {}, pageMode]) => {\n const initialBookmark = this.initialBookmark;\n // Initialize the default values, from user preferences.\n const zoom = AppOptions.get('defaultZoomValue');\n let hash = zoom ? `zoom=${zoom}` : null;\n\n let rotation = null;\n let sidebarView = AppOptions.get('sidebarViewOnLoad');\n let scrollMode = AppOptions.get('scrollModeOnLoad');\n let spreadMode = AppOptions.get('spreadModeOnLoad');\n\n if (values.page && AppOptions.get('showPreviousViewOnLoad')) {\n hash = 'page=' + values.page + '&zoom=' + (zoom || values.zoom) +\n ',' + values.scrollLeft + ',' + values.scrollTop;\n\n rotation = parseInt(values.rotation, 10);\n sidebarView = sidebarView || (values.sidebarView | 0);\n scrollMode = scrollMode || (values.scrollMode | 0);\n spreadMode = spreadMode || (values.spreadMode | 0);\n }\n if (pageMode && !AppOptions.get('disablePageMode')) {\n // Always let the user preference/history take precedence.\n sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);\n }\n\n this.setInitialView(hash, {\n rotation, sidebarView, scrollMode, spreadMode,\n });\n this.eventBus.dispatch('documentinit', { source: this, });\n // Make all navigation keys work on document load,\n // unless the viewer is embedded in a web page.\n if (!this.isViewerEmbedded) {\n pdfViewer.focus();\n }\n\n // For documents with different page sizes, once all pages are resolved,\n // ensure that the correct location becomes visible on load.\n // (To reduce the risk, in very large and/or slow loading documents,\n // that the location changes *after* the user has started interacting\n // with the viewer, wait for either `pagesPromise` or a timeout.)\n await Promise.race([\n pagesPromise,\n new Promise((resolve) => {\n setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);\n }),\n ]);\n if (!initialBookmark && !hash) {\n return;\n }\n if (pdfViewer.hasEqualPageSizes) {\n return;\n }\n this.initialBookmark = initialBookmark;\n\n // eslint-disable-next-line no-self-assign\n pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;\n // Re-apply the initial document location.\n this.setInitialView(hash);\n }).then(function() {\n // At this point, rendering of the initial page(s) should always have\n // started (and may even have completed).\n // To prevent any future issues, e.g. the document being completely\n // blank on load, always trigger rendering here.\n pdfViewer.update();\n });\n });\n\n pdfDocument.getPageLabels().then((labels) => {\n if (!labels || AppOptions.get('disablePageLabels')) {\n return;\n }\n let i = 0, numLabels = labels.length;\n if (numLabels !== this.pagesCount) {\n console.error('The number of Page Labels does not match ' +\n 'the number of pages in the document.');\n return;\n }\n // Ignore page labels that correspond to standard page numbering.\n while (i < numLabels && labels[i] === (i + 1).toString()) {\n i++;\n }\n if (i === numLabels) {\n return;\n }\n\n pdfViewer.setPageLabels(labels);\n pdfThumbnailViewer.setPageLabels(labels);\n\n // Changing toolbar page display to use labels and we need to set\n // the label of the current page.\n this.toolbar.setPagesCount(pdfDocument.numPages, true);\n this.toolbar.setPageNumber(pdfViewer.currentPageNumber,\n pdfViewer.currentPageLabel);\n });\n\n pagesPromise.then(() => {\n if (!this.supportsPrinting) {\n return;\n }\n pdfDocument.getJavaScript().then((javaScript) => {\n if (!javaScript) {\n return;\n }\n javaScript.some((js) => {\n if (!js) { // Don't warn/fallback for empty JavaScript actions.\n return false;\n }\n console.warn('Warning: JavaScript is not supported');\n this.fallback(UNSUPPORTED_FEATURES.javaScript);\n return true;\n });\n\n // Hack to support auto printing.\n let regex = /\\bprint\\s*\\(/;\n for (let i = 0, ii = javaScript.length; i < ii; i++) {\n let js = javaScript[i];\n if (js && regex.test(js)) {\n setTimeout(function() {\n window.print();\n });\n return;\n }\n }\n });\n });\n\n Promise.all([onePageRendered, animationStarted]).then(() => {\n pdfDocument.getOutline().then((outline) => {\n this.pdfOutlineViewer.render({ outline, });\n });\n pdfDocument.getAttachments().then((attachments) => {\n this.pdfAttachmentViewer.render({ attachments, });\n });\n });\n\n pdfDocument.getMetadata().then(\n ({ info, metadata, contentDispositionFilename, }) => {\n this.documentInfo = info;\n this.metadata = metadata;\n this.contentDispositionFilename = contentDispositionFilename;\n\n // Provides some basic debug information\n console.log('PDF ' + pdfDocument.fingerprint + ' [' +\n info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() +\n ' / ' + (info.Creator || '-').trim() + ']' +\n ' (PDF.js: ' + (version || '-') +\n (AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');\n\n let pdfTitle;\n if (metadata && metadata.has('dc:title')) {\n let title = metadata.get('dc:title');\n // Ghostscript sometimes return 'Untitled', sets the title to 'Untitled'\n if (title !== 'Untitled') {\n pdfTitle = title;\n }\n }\n\n if (!pdfTitle && info && info['Title']) {\n pdfTitle = info['Title'];\n }\n\n if (pdfTitle) {\n this.setTitle(\n `${pdfTitle} - ${contentDispositionFilename || document.title}`);\n } else if (contentDispositionFilename) {\n this.setTitle(contentDispositionFilename);\n }\n\n if (info.IsAcroFormPresent) {\n console.warn('Warning: AcroForm/XFA is not supported');\n this.fallback(UNSUPPORTED_FEATURES.forms);\n }\n\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n let versionId = String(info.PDFFormatVersion).slice(-1) | 0;\n let generatorId = 0;\n const KNOWN_GENERATORS = [\n 'acrobat distiller', 'acrobat pdfwriter', 'adobe livecycle',\n 'adobe pdf library', 'adobe photoshop', 'ghostscript', 'tcpdf',\n 'cairo', 'dvipdfm', 'dvips', 'pdftex', 'pdfkit', 'itext', 'prince',\n 'quarkxpress', 'mac os x', 'microsoft', 'openoffice', 'oracle',\n 'luradocument', 'pdf-xchange', 'antenna house', 'aspose.cells', 'fpdf'\n ];\n if (info.Producer) {\n KNOWN_GENERATORS.some(function (generator, s, i) {\n if (!generator.includes(s)) {\n return false;\n }\n generatorId = i + 1;\n return true;\n }.bind(null, info.Producer.toLowerCase()));\n }\n let formType = !info.IsAcroFormPresent ? null : info.IsXFAPresent ?\n 'xfa' : 'acroform';\n this.externalServices.reportTelemetry({\n type: 'documentInfo',\n version: versionId,\n generator: generatorId,\n formType,\n });\n }\n });\n },\n\n setInitialView(storedHash, { rotation, sidebarView,\n scrollMode, spreadMode, } = {}) {\n let setRotation = (angle) => {\n if (isValidRotation(angle)) {\n this.pdfViewer.pagesRotation = angle;\n }\n };\n let setViewerModes = (scroll, spread) => {\n if (Number.isInteger(scroll)) {\n this.pdfViewer.scrollMode = scroll;\n }\n if (Number.isInteger(spread)) {\n this.pdfViewer.spreadMode = spread;\n }\n };\n\n // Putting these before isInitialViewSet = true prevents these values from\n // being stored in the document history (and overriding any future changes\n // made to the corresponding global preferences), just this once.\n setViewerModes(scrollMode, spreadMode);\n\n this.isInitialViewSet = true;\n this.pdfSidebar.setInitialView(sidebarView);\n\n if (this.initialBookmark) {\n setRotation(this.initialRotation);\n delete this.initialRotation;\n\n this.pdfLinkService.setHash(this.initialBookmark);\n this.initialBookmark = null;\n } else if (storedHash) {\n setRotation(rotation);\n\n this.pdfLinkService.setHash(storedHash);\n }\n\n // Ensure that the correct page number is displayed in the UI,\n // even if the active page didn't change during document load.\n this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber,\n this.pdfViewer.currentPageLabel);\n this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);\n\n if (!this.pdfViewer.currentScaleValue) {\n // Scale was not initialized: invalid bookmark or scale was not specified.\n // Setting the default one.\n this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;\n }\n },\n\n cleanup() {\n if (!this.pdfDocument) {\n return; // run cleanup when document is loaded\n }\n this.pdfViewer.cleanup();\n this.pdfThumbnailViewer.cleanup();\n\n // We don't want to remove fonts used by active page SVGs.\n if (this.pdfViewer.renderer !== RendererType.SVG) {\n this.pdfDocument.cleanup();\n }\n },\n\n forceRendering() {\n this.pdfRenderingQueue.printing = this.printing;\n this.pdfRenderingQueue.isThumbnailViewEnabled =\n this.pdfSidebar.isThumbnailViewVisible;\n this.pdfRenderingQueue.renderHighestPriority();\n },\n\n beforePrint() {\n if (this.printService) {\n // There is no way to suppress beforePrint/afterPrint events,\n // but PDFPrintService may generate double events -- this will ignore\n // the second event that will be coming from native window.print().\n return;\n }\n\n if (!this.supportsPrinting) {\n this.l10n.get('printing_not_supported', null,\n 'Warning: Printing is not fully supported by ' +\n 'this browser.').then((printMessage) => {\n this.error(printMessage);\n });\n return;\n }\n\n // The beforePrint is a sync method and we need to know layout before\n // returning from this method. Ensure that we can get sizes of the pages.\n if (!this.pdfViewer.pageViewsReady) {\n this.l10n.get('printing_not_ready', null,\n 'Warning: The PDF is not fully loaded for printing.').\n then((notReadyMessage) => {\n window.alert(notReadyMessage);\n });\n return;\n }\n\n let pagesOverview = this.pdfViewer.getPagesOverview();\n let printContainer = this.appConfig.printContainer;\n let printService = PDFPrintServiceFactory.instance.createPrintService(\n this.pdfDocument, pagesOverview, printContainer, this.l10n);\n this.printService = printService;\n this.forceRendering();\n\n printService.layout();\n\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n this.externalServices.reportTelemetry({\n type: 'print',\n });\n }\n },\n\n afterPrint: function pdfViewSetupAfterPrint() {\n if (this.printService) {\n this.printService.destroy();\n this.printService = null;\n }\n this.forceRendering();\n },\n\n rotatePages(delta) {\n if (!this.pdfDocument) {\n return;\n }\n let newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;\n this.pdfViewer.pagesRotation = newRotation;\n // Note that the thumbnail viewer is updated, and rendering is triggered,\n // in the 'rotationchanging' event handler.\n },\n\n requestPresentationMode() {\n if (!this.pdfPresentationMode) {\n return;\n }\n this.pdfPresentationMode.request();\n },\n\n bindEvents() {\n let { eventBus, _boundEvents, } = this;\n\n _boundEvents.beforePrint = this.beforePrint.bind(this);\n _boundEvents.afterPrint = this.afterPrint.bind(this);\n\n eventBus.on('resize', webViewerResize);\n eventBus.on('hashchange', webViewerHashchange);\n eventBus.on('beforeprint', _boundEvents.beforePrint);\n eventBus.on('afterprint', _boundEvents.afterPrint);\n eventBus.on('pagerendered', webViewerPageRendered);\n eventBus.on('textlayerrendered', webViewerTextLayerRendered);\n eventBus.on('updateviewarea', webViewerUpdateViewarea);\n eventBus.on('pagechanging', webViewerPageChanging);\n eventBus.on('scalechanging', webViewerScaleChanging);\n eventBus.on('rotationchanging', webViewerRotationChanging);\n eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);\n eventBus.on('pagemode', webViewerPageMode);\n eventBus.on('namedaction', webViewerNamedAction);\n eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);\n eventBus.on('presentationmode', webViewerPresentationMode);\n eventBus.on('openfile', webViewerOpenFile);\n eventBus.on('print', webViewerPrint);\n eventBus.on('download', webViewerDownload);\n eventBus.on('firstpage', webViewerFirstPage);\n eventBus.on('lastpage', webViewerLastPage);\n eventBus.on('nextpage', webViewerNextPage);\n eventBus.on('previouspage', webViewerPreviousPage);\n eventBus.on('zoomin', webViewerZoomIn);\n eventBus.on('zoomout', webViewerZoomOut);\n eventBus.on('pagenumberchanged', webViewerPageNumberChanged);\n eventBus.on('scalechanged', webViewerScaleChanged);\n eventBus.on('rotatecw', webViewerRotateCw);\n eventBus.on('rotateccw', webViewerRotateCcw);\n eventBus.on('switchscrollmode', webViewerSwitchScrollMode);\n eventBus.on('scrollmodechanged', webViewerScrollModeChanged);\n eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);\n eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);\n eventBus.on('documentproperties', webViewerDocumentProperties);\n eventBus.on('find', webViewerFind);\n eventBus.on('findfromurlhash', webViewerFindFromUrlHash);\n eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);\n eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);\n if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n eventBus.on('fileinputchange', webViewerFileInputChange);\n }\n },\n\n bindWindowEvents() {\n let { eventBus, _boundEvents, } = this;\n\n _boundEvents.windowResize = () => {\n eventBus.dispatch('resize', { source: window, });\n };\n _boundEvents.windowHashChange = () => {\n eventBus.dispatch('hashchange', {\n source: window,\n hash: document.location.hash.substring(1),\n });\n };\n _boundEvents.windowBeforePrint = () => {\n eventBus.dispatch('beforeprint', { source: window, });\n };\n _boundEvents.windowAfterPrint = () => {\n eventBus.dispatch('afterprint', { source: window, });\n };\n\n window.addEventListener('wheel', webViewerWheel);\n window.addEventListener('click', webViewerClick);\n window.addEventListener('keydown', webViewerKeyDown);\n window.addEventListener('resize', _boundEvents.windowResize);\n window.addEventListener('hashchange', _boundEvents.windowHashChange);\n window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);\n window.addEventListener('afterprint', _boundEvents.windowAfterPrint);\n },\n\n unbindEvents() {\n let { eventBus, _boundEvents, } = this;\n\n eventBus.off('resize', webViewerResize);\n eventBus.off('hashchange', webViewerHashchange);\n eventBus.off('beforeprint', _boundEvents.beforePrint);\n eventBus.off('afterprint', _boundEvents.afterPrint);\n eventBus.off('pagerendered', webViewerPageRendered);\n eventBus.off('textlayerrendered', webViewerTextLayerRendered);\n eventBus.off('updateviewarea', webViewerUpdateViewarea);\n eventBus.off('pagechanging', webViewerPageChanging);\n eventBus.off('scalechanging', webViewerScaleChanging);\n eventBus.off('rotationchanging', webViewerRotationChanging);\n eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);\n eventBus.off('pagemode', webViewerPageMode);\n eventBus.off('namedaction', webViewerNamedAction);\n eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);\n eventBus.off('presentationmode', webViewerPresentationMode);\n eventBus.off('openfile', webViewerOpenFile);\n eventBus.off('print', webViewerPrint);\n eventBus.off('download', webViewerDownload);\n eventBus.off('firstpage', webViewerFirstPage);\n eventBus.off('lastpage', webViewerLastPage);\n eventBus.off('nextpage', webViewerNextPage);\n eventBus.off('previouspage', webViewerPreviousPage);\n eventBus.off('zoomin', webViewerZoomIn);\n eventBus.off('zoomout', webViewerZoomOut);\n eventBus.off('pagenumberchanged', webViewerPageNumberChanged);\n eventBus.off('scalechanged', webViewerScaleChanged);\n eventBus.off('rotatecw', webViewerRotateCw);\n eventBus.off('rotateccw', webViewerRotateCcw);\n eventBus.off('switchscrollmode', webViewerSwitchScrollMode);\n eventBus.off('scrollmodechanged', webViewerScrollModeChanged);\n eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);\n eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);\n eventBus.off('documentproperties', webViewerDocumentProperties);\n eventBus.off('find', webViewerFind);\n eventBus.off('findfromurlhash', webViewerFindFromUrlHash);\n eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);\n eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);\n if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n eventBus.off('fileinputchange', webViewerFileInputChange);\n }\n\n _boundEvents.beforePrint = null;\n _boundEvents.afterPrint = null;\n },\n\n unbindWindowEvents() {\n let { _boundEvents, } = this;\n\n window.removeEventListener('wheel', webViewerWheel);\n window.removeEventListener('click', webViewerClick);\n window.removeEventListener('keydown', webViewerKeyDown);\n window.removeEventListener('resize', _boundEvents.windowResize);\n window.removeEventListener('hashchange', _boundEvents.windowHashChange);\n window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);\n window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);\n\n _boundEvents.windowResize = null;\n _boundEvents.windowHashChange = null;\n _boundEvents.windowBeforePrint = null;\n _boundEvents.windowAfterPrint = null;\n },\n};\n\nlet validateFileURL;\nif (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n const HOSTED_VIEWER_ORIGINS = ['null',\n 'http://mozilla.github.io', 'https://mozilla.github.io'];\n validateFileURL = function validateFileURL(file) {\n if (file === undefined) {\n return;\n }\n try {\n let viewerOrigin = new URL(window.location.href).origin || 'null';\n if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {\n // Hosted or local viewer, allow for any file locations\n return;\n }\n let { origin, protocol, } = new URL(file, window.location.href);\n // Removing of the following line will not guarantee that the viewer will\n // start accepting URLs from foreign origin -- CORS headers on the remote\n // server must be properly configured.\n // IE10 / IE11 does not include an origin in `blob:`-URLs. So don't block\n // any blob:-URL. The browser's same-origin policy will block requests to\n // blob:-URLs from other origins, so this is safe.\n if (origin !== viewerOrigin && protocol !== 'blob:') {\n throw new Error('file origin does not match viewer\\'s');\n }\n } catch (ex) {\n let message = ex && ex.message;\n PDFViewerApplication.l10n.get('loading_error', null,\n 'An error occurred while loading the PDF.').\n then((loadingErrorMessage) => {\n PDFViewerApplication.error(loadingErrorMessage, { message, });\n });\n throw ex;\n }\n };\n}\n\nfunction loadFakeWorker() {\n if (!GlobalWorkerOptions.workerSrc) {\n GlobalWorkerOptions.workerSrc = AppOptions.get('workerSrc');\n }\n if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {\n return new Promise(function(resolve, reject) {\n if (typeof SystemJS === 'object') {\n SystemJS.import('pdfjs/core/worker').then((worker) => {\n window.pdfjsWorker = worker;\n resolve();\n }).catch(reject);\n } else if (typeof require === 'function') {\n try {\n window.pdfjsWorker = require('../src/core/worker.js');\n resolve();\n } catch (ex) {\n reject(ex);\n }\n } else {\n reject(new Error(\n 'SystemJS or CommonJS must be used to load fake worker.'));\n }\n });\n }\n return loadScript(PDFWorker.getWorkerSrc());\n}\n\nfunction loadAndEnablePDFBug(enabledTabs) {\n let appConfig = PDFViewerApplication.appConfig;\n return loadScript(appConfig.debuggerScriptPath).then(function() {\n PDFBug.enable(enabledTabs);\n PDFBug.init({\n OPS,\n createObjectURL,\n }, appConfig.mainContainer);\n });\n}\n\nfunction webViewerInitialized() {\n let appConfig = PDFViewerApplication.appConfig;\n let file;\n if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n let queryString = document.location.search.substring(1);\n let params = parseQueryString(queryString);\n file = 'file' in params ? params.file : AppOptions.get('defaultUrl');\n validateFileURL(file);\n } else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n file = window.location.href.split('#')[0];\n } else if (PDFJSDev.test('CHROME')) {\n file = AppOptions.get('defaultUrl');\n }\n\n if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n let fileInput = document.createElement('input');\n fileInput.id = appConfig.openFileInputName;\n fileInput.className = 'fileInput';\n fileInput.setAttribute('type', 'file');\n fileInput.oncontextmenu = noContextMenuHandler;\n document.body.appendChild(fileInput);\n\n if (!window.File || !window.FileReader ||\n !window.FileList || !window.Blob) {\n appConfig.toolbar.openFile.setAttribute('hidden', 'true');\n appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');\n } else {\n fileInput.value = null;\n }\n\n fileInput.addEventListener('change', function(evt) {\n let files = evt.target.files;\n if (!files || files.length === 0) {\n return;\n }\n PDFViewerApplication.eventBus.dispatch('fileinputchange', {\n source: this,\n fileInput: evt.target,\n });\n });\n\n // Enable draging-and-dropping a new PDF file onto the viewerContainer.\n appConfig.mainContainer.addEventListener('dragover', function(evt) {\n evt.preventDefault();\n\n evt.dataTransfer.dropEffect = 'move';\n });\n appConfig.mainContainer.addEventListener('drop', function(evt) {\n evt.preventDefault();\n\n const files = evt.dataTransfer.files;\n if (!files || files.length === 0) {\n return;\n }\n PDFViewerApplication.eventBus.dispatch('fileinputchange', {\n source: this,\n fileInput: evt.dataTransfer,\n });\n });\n } else {\n appConfig.toolbar.openFile.setAttribute('hidden', 'true');\n appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');\n }\n\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL') &&\n !PDFViewerApplication.supportsDocumentFonts) {\n AppOptions.set('disableFontFace', true);\n PDFViewerApplication.l10n.get('web_fonts_disabled', null,\n 'Web fonts are disabled: unable to use embedded PDF fonts.').\n then((msg) => {\n console.warn(msg);\n });\n }\n\n if (!PDFViewerApplication.supportsPrinting) {\n appConfig.toolbar.print.classList.add('hidden');\n appConfig.secondaryToolbar.printButton.classList.add('hidden');\n }\n\n if (!PDFViewerApplication.supportsFullscreen) {\n appConfig.toolbar.presentationModeButton.classList.add('hidden');\n appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');\n }\n\n if (PDFViewerApplication.supportsIntegratedFind) {\n appConfig.toolbar.viewFind.classList.add('hidden');\n }\n\n appConfig.mainContainer.addEventListener('transitionend', function(evt) {\n if (evt.target === /* mainContainer */ this) {\n PDFViewerApplication.eventBus.dispatch('resize', { source: this, });\n }\n }, true);\n\n appConfig.sidebar.toggleButton.addEventListener('click', function() {\n PDFViewerApplication.pdfSidebar.toggle();\n });\n\n try {\n webViewerOpenFileViaURL(file);\n } catch (reason) {\n PDFViewerApplication.l10n.get('loading_error', null,\n 'An error occurred while loading the PDF.').then((msg) => {\n PDFViewerApplication.error(msg, reason);\n });\n }\n}\n\nlet webViewerOpenFileViaURL;\nif (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {\n if (file && file.lastIndexOf('file:', 0) === 0) {\n // file:-scheme. Load the contents in the main thread because QtWebKit\n // cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded\n // very quickly, so there is no need to set up progress event listeners.\n PDFViewerApplication.setTitleUsingUrl(file);\n let xhr = new XMLHttpRequest();\n xhr.onload = function() {\n PDFViewerApplication.open(new Uint8Array(xhr.response));\n };\n try {\n xhr.open('GET', file);\n xhr.responseType = 'arraybuffer';\n xhr.send();\n } catch (ex) {\n throw ex;\n }\n return;\n }\n\n if (file) {\n PDFViewerApplication.open(file);\n }\n };\n} else if (PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {\n webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {\n PDFViewerApplication.setTitleUsingUrl(file);\n PDFViewerApplication.initPassiveLoading();\n };\n} else {\n webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {\n if (file) {\n throw new Error('Not implemented: webViewerOpenFileViaURL');\n }\n };\n}\n\nfunction webViewerPageRendered(evt) {\n let pageNumber = evt.pageNumber;\n let pageIndex = pageNumber - 1;\n let pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);\n\n // If the page is still visible when it has finished rendering,\n // ensure that the page number input loading indicator is hidden.\n if (pageNumber === PDFViewerApplication.page) {\n PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);\n }\n\n // Prevent errors in the edge-case where the PDF document is removed *before*\n // the 'pagerendered' event handler is invoked.\n if (!pageView) {\n return;\n }\n\n // Use the rendered page to set the corresponding thumbnail image.\n if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {\n let thumbnailView = PDFViewerApplication.pdfThumbnailViewer.\n getThumbnail(pageIndex);\n thumbnailView.setImage(pageView);\n }\n\n if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {\n Stats.add(pageNumber, pageView.stats);\n }\n\n if (pageView.error) {\n PDFViewerApplication.l10n.get('rendering_error', null,\n 'An error occurred while rendering the page.').then((msg) => {\n PDFViewerApplication.error(msg, pageView.error);\n });\n }\n\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n PDFViewerApplication.externalServices.reportTelemetry({\n type: 'pageInfo',\n });\n // It is a good time to report stream and font types.\n PDFViewerApplication.pdfDocument.getStats().then(function (stats) {\n PDFViewerApplication.externalServices.reportTelemetry({\n type: 'documentStats',\n stats,\n });\n });\n }\n}\n\nfunction webViewerTextLayerRendered(evt) {\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL') &&\n evt.numTextDivs > 0 && !PDFViewerApplication.supportsDocumentColors) {\n PDFViewerApplication.l10n.get('document_colors_not_allowed', null,\n 'PDF documents are not allowed to use their own colors: ' +\n '\\'Allow pages to choose their own colors\\' ' +\n 'is deactivated in the browser.').\n then((msg) => {\n console.error(msg);\n });\n PDFViewerApplication.fallback();\n }\n}\n\nfunction webViewerPageMode(evt) {\n // Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`.\n let mode = evt.mode, view;\n switch (mode) {\n case 'thumbs':\n view = SidebarView.THUMBS;\n break;\n case 'bookmarks':\n case 'outline':\n view = SidebarView.OUTLINE;\n break;\n case 'attachments':\n view = SidebarView.ATTACHMENTS;\n break;\n case 'none':\n view = SidebarView.NONE;\n break;\n default:\n console.error('Invalid \"pagemode\" hash parameter: ' + mode);\n return;\n }\n PDFViewerApplication.pdfSidebar.switchView(view, /* forceOpen = */ true);\n}\n\nfunction webViewerNamedAction(evt) {\n // Processing couple of named actions that might be useful.\n // See also PDFLinkService.executeNamedAction\n let action = evt.action;\n switch (action) {\n case 'GoToPage':\n PDFViewerApplication.appConfig.toolbar.pageNumber.select();\n break;\n\n case 'Find':\n if (!PDFViewerApplication.supportsIntegratedFind) {\n PDFViewerApplication.findBar.toggle();\n }\n break;\n }\n}\n\nfunction webViewerPresentationModeChanged(evt) {\n let { active, switchInProgress, } = evt;\n PDFViewerApplication.pdfViewer.presentationModeState =\n switchInProgress ? PresentationModeState.CHANGING :\n active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL;\n}\n\nfunction webViewerSidebarViewChanged(evt) {\n PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled =\n PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;\n\n let store = PDFViewerApplication.store;\n if (store && PDFViewerApplication.isInitialViewSet) {\n // Only update the storage when the document has been loaded *and* rendered.\n store.set('sidebarView', evt.view).catch(function() { });\n }\n}\n\nfunction webViewerUpdateViewarea(evt) {\n let location = evt.location, store = PDFViewerApplication.store;\n\n if (store && PDFViewerApplication.isInitialViewSet) {\n store.setMultiple({\n 'page': location.pageNumber,\n 'zoom': location.scale,\n 'scrollLeft': location.left,\n 'scrollTop': location.top,\n 'rotation': location.rotation,\n }).catch(function() { /* unable to write to storage */ });\n }\n let href =\n PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);\n PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;\n PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href =\n href;\n\n // Show/hide the loading indicator in the page number input element.\n let currentPage =\n PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);\n let loading = currentPage.renderingState !== RenderingStates.FINISHED;\n PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);\n}\n\nfunction webViewerScrollModeChanged(evt) {\n let store = PDFViewerApplication.store;\n if (store && PDFViewerApplication.isInitialViewSet) {\n // Only update the storage when the document has been loaded *and* rendered.\n store.set('scrollMode', evt.mode).catch(function() { });\n }\n}\n\nfunction webViewerSpreadModeChanged(evt) {\n let store = PDFViewerApplication.store;\n if (store && PDFViewerApplication.isInitialViewSet) {\n // Only update the storage when the document has been loaded *and* rendered.\n store.set('spreadMode', evt.mode).catch(function() { });\n }\n}\n\nfunction webViewerResize() {\n let { pdfDocument, pdfViewer, } = PDFViewerApplication;\n if (!pdfDocument) {\n return;\n }\n let currentScaleValue = pdfViewer.currentScaleValue;\n if (currentScaleValue === 'auto' ||\n currentScaleValue === 'page-fit' ||\n currentScaleValue === 'page-width') {\n // Note: the scale is constant for 'page-actual'.\n pdfViewer.currentScaleValue = currentScaleValue;\n }\n pdfViewer.update();\n}\n\nfunction webViewerHashchange(evt) {\n let hash = evt.hash;\n if (!hash) {\n return;\n }\n if (!PDFViewerApplication.isInitialViewSet) {\n PDFViewerApplication.initialBookmark = hash;\n } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {\n PDFViewerApplication.pdfLinkService.setHash(hash);\n }\n}\n\nlet webViewerFileInputChange;\nif (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n webViewerFileInputChange = function webViewerFileInputChange(evt) {\n if (PDFViewerApplication.pdfViewer &&\n PDFViewerApplication.pdfViewer.isInPresentationMode) {\n return; // Opening a new PDF file isn't supported in Presentation Mode.\n }\n let file = evt.fileInput.files[0];\n\n if (URL.createObjectURL && !AppOptions.get('disableCreateObjectURL')) {\n let url = URL.createObjectURL(file);\n if (file.name) {\n url = { url, originalUrl: file.name, };\n }\n PDFViewerApplication.open(url);\n } else {\n PDFViewerApplication.setTitleUsingUrl(file.name);\n // Read the local file into a Uint8Array.\n let fileReader = new FileReader();\n fileReader.onload = function webViewerChangeFileReaderOnload(evt) {\n let buffer = evt.target.result;\n PDFViewerApplication.open(new Uint8Array(buffer));\n };\n fileReader.readAsArrayBuffer(file);\n }\n\n // URL does not reflect proper document location - hiding some icons.\n let appConfig = PDFViewerApplication.appConfig;\n appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');\n appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden',\n 'true');\n appConfig.toolbar.download.setAttribute('hidden', 'true');\n appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');\n };\n}\n\nfunction webViewerPresentationMode() {\n PDFViewerApplication.requestPresentationMode();\n}\nfunction webViewerOpenFile() {\n if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n let openFileInputName = PDFViewerApplication.appConfig.openFileInputName;\n document.getElementById(openFileInputName).click();\n }\n}\nfunction webViewerPrint() {\n window.print();\n}\nfunction webViewerDownload() {\n PDFViewerApplication.download();\n}\nfunction webViewerFirstPage() {\n if (PDFViewerApplication.pdfDocument) {\n PDFViewerApplication.page = 1;\n }\n}\nfunction webViewerLastPage() {\n if (PDFViewerApplication.pdfDocument) {\n PDFViewerApplication.page = PDFViewerApplication.pagesCount;\n }\n}\nfunction webViewerNextPage() {\n PDFViewerApplication.page++;\n}\nfunction webViewerPreviousPage() {\n PDFViewerApplication.page--;\n}\nfunction webViewerZoomIn() {\n PDFViewerApplication.zoomIn();\n}\nfunction webViewerZoomOut() {\n PDFViewerApplication.zoomOut();\n}\nfunction webViewerPageNumberChanged(evt) {\n let pdfViewer = PDFViewerApplication.pdfViewer;\n pdfViewer.currentPageLabel = evt.value;\n\n // Ensure that the page number input displays the correct value, even if the\n // value entered by the user was invalid (e.g. a floating point number).\n if (evt.value !== pdfViewer.currentPageNumber.toString() &&\n evt.value !== pdfViewer.currentPageLabel) {\n PDFViewerApplication.toolbar.setPageNumber(\n pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);\n }\n}\nfunction webViewerScaleChanged(evt) {\n PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;\n}\nfunction webViewerRotateCw() {\n PDFViewerApplication.rotatePages(90);\n}\nfunction webViewerRotateCcw() {\n PDFViewerApplication.rotatePages(-90);\n}\nfunction webViewerSwitchScrollMode(evt) {\n PDFViewerApplication.pdfViewer.scrollMode = evt.mode;\n}\nfunction webViewerSwitchSpreadMode(evt) {\n PDFViewerApplication.pdfViewer.spreadMode = evt.mode;\n}\nfunction webViewerDocumentProperties() {\n PDFViewerApplication.pdfDocumentProperties.open();\n}\n\nfunction webViewerFind(evt) {\n PDFViewerApplication.findController.executeCommand('find' + evt.type, {\n query: evt.query,\n phraseSearch: evt.phraseSearch,\n caseSensitive: evt.caseSensitive,\n entireWord: evt.entireWord,\n highlightAll: evt.highlightAll,\n findPrevious: evt.findPrevious,\n });\n}\n\nfunction webViewerFindFromUrlHash(evt) {\n PDFViewerApplication.findController.executeCommand('find', {\n query: evt.query,\n phraseSearch: evt.phraseSearch,\n caseSensitive: false,\n entireWord: false,\n highlightAll: true,\n findPrevious: false,\n });\n}\n\nfunction webViewerUpdateFindMatchesCount({ matchesCount, }) {\n if (PDFViewerApplication.supportsIntegratedFind) {\n PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);\n } else {\n PDFViewerApplication.findBar.updateResultsCount(matchesCount);\n }\n}\n\nfunction webViewerUpdateFindControlState({ state, previous, matchesCount, }) {\n if (PDFViewerApplication.supportsIntegratedFind) {\n PDFViewerApplication.externalServices.updateFindControlState({\n result: state,\n findPrevious: previous,\n matchesCount,\n });\n } else {\n PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);\n }\n}\n\nfunction webViewerScaleChanging(evt) {\n PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);\n\n PDFViewerApplication.pdfViewer.update();\n}\n\nfunction webViewerRotationChanging(evt) {\n PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;\n\n PDFViewerApplication.forceRendering();\n // Ensure that the active page doesn't change during rotation.\n PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;\n}\n\nfunction webViewerPageChanging(evt) {\n let page = evt.pageNumber;\n\n PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);\n PDFViewerApplication.secondaryToolbar.setPageNumber(page);\n\n if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {\n PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);\n }\n\n // We need to update stats.\n if (typeof Stats !== 'undefined' && Stats.enabled) {\n let pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);\n if (pageView && pageView.stats) {\n Stats.add(page, pageView.stats);\n }\n }\n}\n\nlet zoomDisabled = false, zoomDisabledTimeout;\nfunction webViewerWheel(evt) {\n let pdfViewer = PDFViewerApplication.pdfViewer;\n if (pdfViewer.isInPresentationMode) {\n return;\n }\n\n if (evt.ctrlKey || evt.metaKey) {\n let support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;\n if ((evt.ctrlKey && !support.ctrlKey) ||\n (evt.metaKey && !support.metaKey)) {\n return;\n }\n // Only zoom the pages, not the entire viewer.\n evt.preventDefault();\n // NOTE: this check must be placed *after* preventDefault.\n if (zoomDisabled) {\n return;\n }\n\n let previousScale = pdfViewer.currentScale;\n\n let delta = normalizeWheelEventDelta(evt);\n\n const MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;\n let ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;\n if (ticks < 0) {\n PDFViewerApplication.zoomOut(-ticks);\n } else {\n PDFViewerApplication.zoomIn(ticks);\n }\n\n let currentScale = pdfViewer.currentScale;\n if (previousScale !== currentScale) {\n // After scaling the page via zoomIn/zoomOut, the position of the upper-\n // left corner is restored. When the mouse wheel is used, the position\n // under the cursor should be restored instead.\n let scaleCorrectionFactor = currentScale / previousScale - 1;\n let rect = pdfViewer.container.getBoundingClientRect();\n let dx = evt.clientX - rect.left;\n let dy = evt.clientY - rect.top;\n pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;\n pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;\n }\n } else {\n zoomDisabled = true;\n clearTimeout(zoomDisabledTimeout);\n zoomDisabledTimeout = setTimeout(function () {\n zoomDisabled = false;\n }, 1000);\n }\n}\n\nfunction webViewerClick(evt) {\n if (!PDFViewerApplication.secondaryToolbar.isOpen) {\n return;\n }\n let appConfig = PDFViewerApplication.appConfig;\n if (PDFViewerApplication.pdfViewer.containsElement(evt.target) ||\n (appConfig.toolbar.container.contains(evt.target) &&\n evt.target !== appConfig.secondaryToolbar.toggleButton)) {\n PDFViewerApplication.secondaryToolbar.close();\n }\n}\n\nfunction webViewerKeyDown(evt) {\n if (PDFViewerApplication.overlayManager.active) {\n return;\n }\n\n let handled = false, ensureViewerFocused = false;\n let cmd = (evt.ctrlKey ? 1 : 0) |\n (evt.altKey ? 2 : 0) |\n (evt.shiftKey ? 4 : 0) |\n (evt.metaKey ? 8 : 0);\n\n let pdfViewer = PDFViewerApplication.pdfViewer;\n let isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;\n\n // First, handle the key bindings that are independent whether an input\n // control is selected or not.\n if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {\n // either CTRL or META key with optional SHIFT.\n switch (evt.keyCode) {\n case 70: // f\n if (!PDFViewerApplication.supportsIntegratedFind) {\n PDFViewerApplication.findBar.open();\n handled = true;\n }\n break;\n case 71: // g\n if (!PDFViewerApplication.supportsIntegratedFind) {\n let findState = PDFViewerApplication.findController.state;\n if (findState) {\n PDFViewerApplication.findController.executeCommand('findagain', {\n query: findState.query,\n phraseSearch: findState.phraseSearch,\n caseSensitive: findState.caseSensitive,\n entireWord: findState.entireWord,\n highlightAll: findState.highlightAll,\n findPrevious: cmd === 5 || cmd === 12,\n });\n }\n handled = true;\n }\n break;\n case 61: // FF/Mac '='\n case 107: // FF '+' and '='\n case 187: // Chrome '+'\n case 171: // FF with German keyboard\n if (!isViewerInPresentationMode) {\n PDFViewerApplication.zoomIn();\n }\n handled = true;\n break;\n case 173: // FF/Mac '-'\n case 109: // FF '-'\n case 189: // Chrome '-'\n if (!isViewerInPresentationMode) {\n PDFViewerApplication.zoomOut();\n }\n handled = true;\n break;\n case 48: // '0'\n case 96: // '0' on Numpad of Swedish keyboard\n if (!isViewerInPresentationMode) {\n // keeping it unhandled (to restore page zoom to 100%)\n setTimeout(function () {\n // ... and resetting the scale after browser adjusts its scale\n pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;\n });\n handled = false;\n }\n break;\n\n case 38: // up arrow\n if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {\n PDFViewerApplication.page = 1;\n handled = true;\n ensureViewerFocused = true;\n }\n break;\n case 40: // down arrow\n if (isViewerInPresentationMode ||\n PDFViewerApplication.page < PDFViewerApplication.pagesCount) {\n PDFViewerApplication.page = PDFViewerApplication.pagesCount;\n handled = true;\n ensureViewerFocused = true;\n }\n break;\n }\n }\n\n if (typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n // CTRL or META without shift\n if (cmd === 1 || cmd === 8) {\n switch (evt.keyCode) {\n case 83: // s\n PDFViewerApplication.download();\n handled = true;\n break;\n }\n }\n }\n\n // CTRL+ALT or Option+Command\n if (cmd === 3 || cmd === 10) {\n switch (evt.keyCode) {\n case 80: // p\n PDFViewerApplication.requestPresentationMode();\n handled = true;\n break;\n case 71: // g\n // focuses input#pageNumber field\n PDFViewerApplication.appConfig.toolbar.pageNumber.select();\n handled = true;\n break;\n }\n }\n\n if (handled) {\n if (ensureViewerFocused && !isViewerInPresentationMode) {\n pdfViewer.focus();\n }\n evt.preventDefault();\n return;\n }\n\n // Some shortcuts should not get handled if a control/input element\n // is selected.\n let curElement = document.activeElement || document.querySelector(':focus');\n let curElementTagName = curElement && curElement.tagName.toUpperCase();\n if (curElementTagName === 'INPUT' ||\n curElementTagName === 'TEXTAREA' ||\n curElementTagName === 'SELECT') {\n // Make sure that the secondary toolbar is closed when Escape is pressed.\n if (evt.keyCode !== 27) { // 'Esc'\n return;\n }\n }\n\n if (cmd === 0) { // no control key pressed at all.\n let turnPage = 0, turnOnlyIfPageFit = false;\n switch (evt.keyCode) {\n case 38: // up arrow\n case 33: // pg up\n // vertical scrolling using arrow/pg keys\n if (pdfViewer.isVerticalScrollbarEnabled) {\n turnOnlyIfPageFit = true;\n }\n turnPage = -1;\n break;\n case 8: // backspace\n if (!isViewerInPresentationMode) {\n turnOnlyIfPageFit = true;\n }\n turnPage = -1;\n break;\n case 37: // left arrow\n // horizontal scrolling using arrow keys\n if (pdfViewer.isHorizontalScrollbarEnabled) {\n turnOnlyIfPageFit = true;\n }\n /* falls through */\n case 75: // 'k'\n case 80: // 'p'\n turnPage = -1;\n break;\n case 27: // esc key\n if (PDFViewerApplication.secondaryToolbar.isOpen) {\n PDFViewerApplication.secondaryToolbar.close();\n handled = true;\n }\n if (!PDFViewerApplication.supportsIntegratedFind &&\n PDFViewerApplication.findBar.opened) {\n PDFViewerApplication.findBar.close();\n handled = true;\n }\n break;\n case 40: // down arrow\n case 34: // pg down\n // vertical scrolling using arrow/pg keys\n if (pdfViewer.isVerticalScrollbarEnabled) {\n turnOnlyIfPageFit = true;\n }\n turnPage = 1;\n break;\n case 13: // enter key\n case 32: // spacebar\n if (!isViewerInPresentationMode) {\n turnOnlyIfPageFit = true;\n }\n turnPage = 1;\n break;\n case 39: // right arrow\n // horizontal scrolling using arrow keys\n if (pdfViewer.isHorizontalScrollbarEnabled) {\n turnOnlyIfPageFit = true;\n }\n /* falls through */\n case 74: // 'j'\n case 78: // 'n'\n turnPage = 1;\n break;\n\n case 36: // home\n if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {\n PDFViewerApplication.page = 1;\n handled = true;\n ensureViewerFocused = true;\n }\n break;\n case 35: // end\n if (isViewerInPresentationMode ||\n PDFViewerApplication.page < PDFViewerApplication.pagesCount) {\n PDFViewerApplication.page = PDFViewerApplication.pagesCount;\n handled = true;\n ensureViewerFocused = true;\n }\n break;\n\n case 83: // 's'\n PDFViewerApplication.pdfCursorTools.switchTool(CursorTool.SELECT);\n break;\n case 72: // 'h'\n PDFViewerApplication.pdfCursorTools.switchTool(CursorTool.HAND);\n break;\n\n case 82: // 'r'\n PDFViewerApplication.rotatePages(90);\n break;\n }\n\n if (turnPage !== 0 &&\n (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {\n if (turnPage > 0) {\n if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {\n PDFViewerApplication.page++;\n }\n } else {\n if (PDFViewerApplication.page > 1) {\n PDFViewerApplication.page--;\n }\n }\n handled = true;\n }\n }\n\n if (cmd === 4) { // shift-key\n switch (evt.keyCode) {\n case 13: // enter key\n case 32: // spacebar\n if (!isViewerInPresentationMode &&\n pdfViewer.currentScaleValue !== 'page-fit') {\n break;\n }\n if (PDFViewerApplication.page > 1) {\n PDFViewerApplication.page--;\n }\n handled = true;\n break;\n\n case 82: // 'r'\n PDFViewerApplication.rotatePages(-90);\n break;\n }\n }\n\n if (!handled && !isViewerInPresentationMode) {\n // 33=Page Up 34=Page Down 35=End 36=Home\n // 37=Left 38=Up 39=Right 40=Down\n // 32=Spacebar\n if ((evt.keyCode >= 33 && evt.keyCode <= 40) ||\n (evt.keyCode === 32 && curElementTagName !== 'BUTTON')) {\n ensureViewerFocused = true;\n }\n }\n\n if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {\n // The page container is not focused, but a page navigation key has been\n // pressed. Change the focus to the viewer container to make sure that\n // navigation by keyboard works as expected.\n pdfViewer.focus();\n }\n\n if (handled) {\n evt.preventDefault();\n }\n}\n\n/**\n * Converts API PageMode values to the format used by `PDFSidebar`.\n * NOTE: There's also a \"FullScreen\" parameter which is not possible to support,\n * since the Fullscreen API used in browsers requires that entering\n * fullscreen mode only occurs as a result of a user-initiated event.\n * @param {string} mode - The API PageMode value.\n * @returns {number} A value from {SidebarView}.\n */\nfunction apiPageModeToSidebarView(mode) {\n switch (mode) {\n case 'UseNone':\n return SidebarView.NONE;\n case 'UseThumbs':\n return SidebarView.THUMBS;\n case 'UseOutlines':\n return SidebarView.OUTLINE;\n case 'UseAttachments':\n return SidebarView.ATTACHMENTS;\n case 'UseOC':\n // Not implemented, since we don't support Optional Content Groups yet.\n }\n return SidebarView.NONE; // Default value.\n}\n\n/* Abstract factory for the print service. */\nlet PDFPrintServiceFactory = {\n instance: {\n supportsPrinting: false,\n createPrintService() {\n throw new Error('Not implemented: createPrintService');\n },\n },\n};\n\nexport {\n PDFViewerApplication,\n DefaultExternalServices,\n PDFPrintServiceFactory,\n};\n","module.exports = require(\"regenerator-runtime\");\n","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// This method of obtaining a reference to the global object needs to be\n// kept identical to the way it is obtained in runtime.js\nvar g = (function() { return this })() || Function(\"return this\")();\n\n// Use `getOwnPropertyNames` because not all browsers support calling\n// `hasOwnProperty` on the global `self` object in a worker. See #183.\nvar hadRuntime = g.regeneratorRuntime &&\n Object.getOwnPropertyNames(g).indexOf(\"regeneratorRuntime\") >= 0;\n\n// Save the old regeneratorRuntime in case it needs to be restored later.\nvar oldRuntime = hadRuntime && g.regeneratorRuntime;\n\n// Force reevalutation of runtime.js.\ng.regeneratorRuntime = undefined;\n\nmodule.exports = require(\"./runtime\");\n\nif (hadRuntime) {\n // Restore the original runtime.\n g.regeneratorRuntime = oldRuntime;\n} else {\n // Remove the global property added by runtime.js.\n try {\n delete g.regeneratorRuntime;\n } catch(e) {\n g.regeneratorRuntime = undefined;\n }\n}\n","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n!(function(global) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n var inModule = typeof module === \"object\";\n var runtime = global.regeneratorRuntime;\n if (runtime) {\n if (inModule) {\n // If regeneratorRuntime is defined globally and we're in a module,\n // make the exports object identical to regeneratorRuntime.\n module.exports = runtime;\n }\n // Don't bother evaluating the rest of this file if the runtime was\n // already defined globally.\n return;\n }\n\n // Define the runtime globally (as expected by generated code) as either\n // module.exports (if we're in a module) or a new, empty object.\n runtime = global.regeneratorRuntime = inModule ? module.exports : {};\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n runtime.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n runtime.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n runtime.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n runtime.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return Promise.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration. If the Promise is rejected, however, the\n // result for this iteration will be rejected with the same\n // reason. Note that rejections of yielded Promises are not\n // thrown back into the generator function, as is the case\n // when an awaited Promise is rejected. This difference in\n // behavior between yield and await is important, because it\n // allows the consumer to decide what to do with the yielded\n // rejection (swallow it and continue, manually .throw it back\n // into the generator, abandon iteration, whatever). With\n // await, by contrast, there is no opportunity to examine the\n // rejection reason outside the generator function, so the\n // only option is to throw it from the await expression, and\n // let the generator function handle the exception.\n result.value = unwrapped;\n resolve(result);\n }, reject);\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n runtime.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return runtime.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n if (delegate.iterator.return) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n runtime.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n runtime.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n})(\n // In sloppy mode, unbound `this` refers to the global object, fallback to\n // Function constructor if we're in global strict mode. That is sadly a form\n // of indirect eval which violates Content Security Policy.\n (function() { return this })() || Function(\"return this\")()\n);\n","module.exports = function(module) {\r\n\tif (!module.webpackPolyfill) {\r\n\t\tmodule.deprecate = function() {};\r\n\t\tmodule.paths = [];\r\n\t\t// module.parent = undefined by default\r\n\t\tif (!module.children) module.children = [];\r\n\t\tObject.defineProperty(module, \"loaded\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.l;\r\n\t\t\t}\r\n\t\t});\r\n\t\tObject.defineProperty(module, \"id\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.i;\r\n\t\t\t}\r\n\t\t});\r\n\t\tmodule.webpackPolyfill = 1;\r\n\t}\r\n\treturn module;\r\n};\r\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst CSS_UNITS = 96.0 / 72.0;\nconst DEFAULT_SCALE_VALUE = 'auto';\nconst DEFAULT_SCALE = 1.0;\nconst MIN_SCALE = 0.10;\nconst MAX_SCALE = 10.0;\nconst UNKNOWN_SCALE = 0;\nconst MAX_AUTO_SCALE = 1.25;\nconst SCROLLBAR_PADDING = 40;\nconst VERTICAL_PADDING = 5;\n\nconst PresentationModeState = {\n UNKNOWN: 0,\n NORMAL: 1,\n CHANGING: 2,\n FULLSCREEN: 3,\n};\n\nconst RendererType = {\n CANVAS: 'canvas',\n SVG: 'svg',\n};\n\nconst TextLayerMode = {\n DISABLE: 0,\n ENABLE: 1,\n ENABLE_ENHANCE: 2,\n};\n\n// Replaces {{arguments}} with their values.\nfunction formatL10nValue(text, args) {\n if (!args) {\n return text;\n }\n return text.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (all, name) => {\n return (name in args ? args[name] : '{{' + name + '}}');\n });\n}\n\n/**\n * No-op implementation of the localization service.\n * @implements {IL10n}\n */\nlet NullL10n = {\n async getLanguage() {\n return 'en-us';\n },\n\n async getDirection() {\n return 'ltr';\n },\n\n async get(property, args, fallback) {\n return formatL10nValue(fallback, args);\n },\n\n async translate(element) { },\n};\n\n/**\n * Returns scale factor for the canvas. It makes sense for the HiDPI displays.\n * @return {Object} The object with horizontal (sx) and vertical (sy)\n scales. The scaled property is set to false if scaling is\n not required, true otherwise.\n */\nfunction getOutputScale(ctx) {\n let devicePixelRatio = window.devicePixelRatio || 1;\n let backingStoreRatio = ctx.webkitBackingStorePixelRatio ||\n ctx.mozBackingStorePixelRatio ||\n ctx.msBackingStorePixelRatio ||\n ctx.oBackingStorePixelRatio ||\n ctx.backingStorePixelRatio || 1;\n let pixelRatio = devicePixelRatio / backingStoreRatio;\n return {\n sx: pixelRatio,\n sy: pixelRatio,\n scaled: pixelRatio !== 1,\n };\n}\n\n/**\n * Scrolls specified element into view of its parent.\n * @param {Object} element - The element to be visible.\n * @param {Object} spot - An object with optional top and left properties,\n * specifying the offset from the top left edge.\n * @param {boolean} skipOverflowHiddenElements - Ignore elements that have\n * the CSS rule `overflow: hidden;` set. The default is false.\n */\nfunction scrollIntoView(element, spot, skipOverflowHiddenElements = false) {\n // Assuming offsetParent is available (it's not available when viewer is in\n // hidden iframe or object). We have to scroll: if the offsetParent is not set\n // producing the error. See also animationStarted.\n let parent = element.offsetParent;\n if (!parent) {\n console.error('offsetParent is not set -- cannot scroll');\n return;\n }\n let offsetY = element.offsetTop + element.clientTop;\n let offsetX = element.offsetLeft + element.clientLeft;\n while ((parent.clientHeight === parent.scrollHeight &&\n parent.clientWidth === parent.scrollWidth) ||\n (skipOverflowHiddenElements &&\n getComputedStyle(parent).overflow === 'hidden')) {\n if (parent.dataset._scaleY) {\n offsetY /= parent.dataset._scaleY;\n offsetX /= parent.dataset._scaleX;\n }\n offsetY += parent.offsetTop;\n offsetX += parent.offsetLeft;\n parent = parent.offsetParent;\n if (!parent) {\n return; // no need to scroll\n }\n }\n if (spot) {\n if (spot.top !== undefined) {\n offsetY += spot.top;\n }\n if (spot.left !== undefined) {\n offsetX += spot.left;\n parent.scrollLeft = offsetX;\n }\n }\n parent.scrollTop = offsetY;\n}\n\n/**\n * Helper function to start monitoring the scroll event and converting them into\n * PDF.js friendly one: with scroll debounce and scroll direction.\n */\nfunction watchScroll(viewAreaElement, callback) {\n let debounceScroll = function(evt) {\n if (rAF) {\n return;\n }\n // schedule an invocation of scroll for next animation frame.\n rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {\n rAF = null;\n\n let currentX = viewAreaElement.scrollLeft;\n let lastX = state.lastX;\n if (currentX !== lastX) {\n state.right = currentX > lastX;\n }\n state.lastX = currentX;\n let currentY = viewAreaElement.scrollTop;\n let lastY = state.lastY;\n if (currentY !== lastY) {\n state.down = currentY > lastY;\n }\n state.lastY = currentY;\n callback(state);\n });\n };\n\n let state = {\n right: true,\n down: true,\n lastX: viewAreaElement.scrollLeft,\n lastY: viewAreaElement.scrollTop,\n _eventHandler: debounceScroll,\n };\n\n let rAF = null;\n viewAreaElement.addEventListener('scroll', debounceScroll, true);\n return state;\n}\n\n/**\n * Helper function to parse query string (e.g. ?param1=value&parm2=...).\n */\nfunction parseQueryString(query) {\n let parts = query.split('&');\n let params = Object.create(null);\n for (let i = 0, ii = parts.length; i < ii; ++i) {\n let param = parts[i].split('=');\n let key = param[0].toLowerCase();\n let value = param.length > 1 ? param[1] : null;\n params[decodeURIComponent(key)] = decodeURIComponent(value);\n }\n return params;\n}\n\n/**\n * Use binary search to find the index of the first item in a given array which\n * passes a given condition. The items are expected to be sorted in the sense\n * that if the condition is true for one item in the array, then it is also true\n * for all following items.\n *\n * @returns {Number} Index of the first array element to pass the test,\n * or |items.length| if no such element exists.\n */\nfunction binarySearchFirstItem(items, condition) {\n let minIndex = 0;\n let maxIndex = items.length - 1;\n\n if (items.length === 0 || !condition(items[maxIndex])) {\n return items.length;\n }\n if (condition(items[minIndex])) {\n return minIndex;\n }\n\n while (minIndex < maxIndex) {\n let currentIndex = (minIndex + maxIndex) >> 1;\n let currentItem = items[currentIndex];\n if (condition(currentItem)) {\n maxIndex = currentIndex;\n } else {\n minIndex = currentIndex + 1;\n }\n }\n return minIndex; /* === maxIndex */\n}\n\n/**\n * Approximates float number as a fraction using Farey sequence (max order\n * of 8).\n * @param {number} x - Positive float number.\n * @returns {Array} Estimated fraction: the first array item is a numerator,\n * the second one is a denominator.\n */\nfunction approximateFraction(x) {\n // Fast paths for int numbers or their inversions.\n if (Math.floor(x) === x) {\n return [x, 1];\n }\n let xinv = 1 / x;\n let limit = 8;\n if (xinv > limit) {\n return [1, limit];\n } else if (Math.floor(xinv) === xinv) {\n return [1, xinv];\n }\n\n let x_ = x > 1 ? xinv : x;\n // a/b and c/d are neighbours in Farey sequence.\n let a = 0, b = 1, c = 1, d = 1;\n // Limiting search to order 8.\n while (true) {\n // Generating next term in sequence (order of q).\n let p = a + c, q = b + d;\n if (q > limit) {\n break;\n }\n if (x_ <= p / q) {\n c = p; d = q;\n } else {\n a = p; b = q;\n }\n }\n let result;\n // Select closest of the neighbours to x.\n if (x_ - a / b < c / d - x_) {\n result = x_ === x ? [a, b] : [b, a];\n } else {\n result = x_ === x ? [c, d] : [d, c];\n }\n return result;\n}\n\nfunction roundToDivide(x, div) {\n let r = x % div;\n return r === 0 ? x : Math.round(x - r + div);\n}\n\n/**\n * Gets the size of the specified page, converted from PDF units to inches.\n * @param {Object} An Object containing the properties: {Array} `view`,\n * {number} `userUnit`, and {number} `rotate`.\n * @return {Object} An Object containing the properties: {number} `width`\n * and {number} `height`, given in inches.\n */\nfunction getPageSizeInches({ view, userUnit, rotate, }) {\n const [x1, y1, x2, y2] = view;\n // We need to take the page rotation into account as well.\n const changeOrientation = rotate % 180 !== 0;\n\n const width = (x2 - x1) / 72 * userUnit;\n const height = (y2 - y1) / 72 * userUnit;\n\n return {\n width: (changeOrientation ? height : width),\n height: (changeOrientation ? width : height),\n };\n}\n\n/**\n * Helper function for getVisibleElements.\n *\n * @param {number} index - initial guess at the first visible element\n * @param {Array} views - array of pages, into which `index` is an index\n * @param {number} top - the top of the scroll pane\n * @returns {number} less than or equal to `index` that is definitely at or\n * before the first visible element in `views`, but not by too much. (Usually,\n * this will be the first element in the first partially visible row in\n * `views`, although sometimes it goes back one row further.)\n */\nfunction backtrackBeforeAllVisibleElements(index, views, top) {\n // binarySearchFirstItem's assumption is that the input is ordered, with only\n // one index where the conditions flips from false to true: [false ...,\n // true...]. With vertical scrolling and spreads, it is possible to have\n // [false ..., true, false, true ...]. With wrapped scrolling we can have a\n // similar sequence, with many more mixed true and false in the middle.\n //\n // So there is no guarantee that the binary search yields the index of the\n // first visible element. It could have been any of the other visible elements\n // that were preceded by a hidden element.\n\n // Of course, if either this element or the previous (hidden) element is also\n // the first element, there's nothing to worry about.\n if (index < 2) {\n return index;\n }\n\n // That aside, the possible cases are represented below.\n //\n // **** = fully hidden\n // A*B* = mix of partially visible and/or hidden pages\n // CDEF = fully visible\n //\n // (1) Binary search could have returned A, in which case we can stop.\n // (2) Binary search could also have returned B, in which case we need to\n // check the whole row.\n // (3) Binary search could also have returned C, in which case we need to\n // check the whole previous row.\n //\n // There's one other possibility:\n //\n // **** = fully hidden\n // ABCD = mix of fully and/or partially visible pages\n //\n // (4) Binary search could only have returned A.\n\n // Initially assume that we need to find the beginning of the current row\n // (case 1, 2, or 4), which means finding a page that is above the current\n // page's top. If the found page is partially visible, we're definitely not in\n // case 3, and this assumption is correct.\n let elt = views[index].div;\n let pageTop = elt.offsetTop + elt.clientTop;\n\n if (pageTop >= top) {\n // The found page is fully visible, so we're actually either in case 3 or 4,\n // and unfortunately we can't tell the difference between them without\n // scanning the entire previous row, so we just conservatively assume that\n // we do need to backtrack to that row. In both cases, the previous page is\n // in the previous row, so use its top instead.\n elt = views[index - 1].div;\n pageTop = elt.offsetTop + elt.clientTop;\n }\n\n // Now we backtrack to the first page that still has its bottom below\n // `pageTop`, which is the top of a page in the first visible row (unless\n // we're in case 4, in which case it's the row before that).\n // `index` is found by binary search, so the page at `index - 1` is\n // invisible and we can start looking for potentially visible pages from\n // `index - 2`. (However, if this loop terminates on its first iteration,\n // which is the case when pages are stacked vertically, `index` should remain\n // unchanged, so we use a distinct loop variable.)\n for (let i = index - 2; i >= 0; --i) {\n elt = views[i].div;\n if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {\n // We have reached the previous row, so stop now.\n // This loop is expected to terminate relatively quickly because the\n // number of pages per row is expected to be small.\n break;\n }\n index = i;\n }\n return index;\n}\n\n/**\n * Generic helper to find out what elements are visible within a scroll pane.\n *\n * Well, pretty generic. There are some assumptions placed on the elements\n * referenced by `views`:\n * - If `horizontal`, no left of any earlier element is to the right of the\n * left of any later element.\n * - Otherwise, `views` can be split into contiguous rows where, within a row,\n * no top of any element is below the bottom of any other element, and\n * between rows, no bottom of any element in an earlier row is below the\n * top of any element in a later row.\n *\n * (Here, top, left, etc. all refer to the padding edge of the element in\n * question. For pages, that ends up being equivalent to the bounding box of the\n * rendering canvas. Earlier and later refer to index in `views`, not page\n * layout.)\n *\n * @param scrollEl {HTMLElement} - a container that can possibly scroll\n * @param views {Array} - objects with a `div` property that contains an\n * HTMLElement, which should all be descendents of `scrollEl` satisfying the\n * above layout assumptions\n * @param sortByVisibility {boolean} - if true, the returned elements are sorted\n * in descending order of the percent of their padding box that is visible\n * @param horizontal {boolean} - if true, the elements are assumed to be laid\n * out horizontally instead of vertically\n * @returns {Object} `{ first, last, views: [{ id, x, y, view, percent }] }`\n */\nfunction getVisibleElements(scrollEl, views, sortByVisibility = false,\n horizontal = false) {\n let top = scrollEl.scrollTop, bottom = top + scrollEl.clientHeight;\n let left = scrollEl.scrollLeft, right = left + scrollEl.clientWidth;\n\n // Throughout this \"generic\" function, comments will assume we're working with\n // PDF document pages, which is the most important and complex case. In this\n // case, the visible elements we're actually interested is the page canvas,\n // which is contained in a wrapper which adds no padding/border/margin, which\n // is itself contained in `view.div` which adds no padding (but does add a\n // border). So, as specified in this function's doc comment, this function\n // does all of its work on the padding edge of the provided views, starting at\n // offsetLeft/Top (which includes margin) and adding clientLeft/Top (which is\n // the border). Adding clientWidth/Height gets us the bottom-right corner of\n // the padding edge.\n function isElementBottomAfterViewTop(view) {\n let element = view.div;\n let elementBottom =\n element.offsetTop + element.clientTop + element.clientHeight;\n return elementBottom > top;\n }\n function isElementRightAfterViewLeft(view) {\n let element = view.div;\n let elementRight =\n element.offsetLeft + element.clientLeft + element.clientWidth;\n return elementRight > left;\n }\n\n let visible = [], view, element;\n let currentHeight, viewHeight, viewBottom, hiddenHeight;\n let currentWidth, viewWidth, viewRight, hiddenWidth;\n let percentVisible;\n let firstVisibleElementInd = views.length === 0 ? 0 :\n binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft :\n isElementBottomAfterViewTop);\n\n if (views.length > 0 && !horizontal) {\n // In wrapped scrolling (or vertical scrolling with spreads), with some page\n // sizes, isElementBottomAfterViewTop doesn't satisfy the binary search\n // condition: there can be pages with bottoms above the view top between\n // pages with bottoms below. This function detects and corrects that error;\n // see it for more comments.\n firstVisibleElementInd =\n backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);\n }\n\n // lastEdge acts as a cutoff for us to stop looping, because we know all\n // subsequent pages will be hidden.\n //\n // When using wrapped scrolling or vertical scrolling with spreads, we can't\n // simply stop the first time we reach a page below the bottom of the view;\n // the tops of subsequent pages on the same row could still be visible. In\n // horizontal scrolling, we don't have that issue, so we can stop as soon as\n // we pass `right`, without needing the code below that handles the -1 case.\n let lastEdge = horizontal ? right : -1;\n\n for (let i = firstVisibleElementInd, ii = views.length; i < ii; i++) {\n view = views[i];\n element = view.div;\n currentWidth = element.offsetLeft + element.clientLeft;\n currentHeight = element.offsetTop + element.clientTop;\n viewWidth = element.clientWidth;\n viewHeight = element.clientHeight;\n viewRight = currentWidth + viewWidth;\n viewBottom = currentHeight + viewHeight;\n\n if (lastEdge === -1) {\n // As commented above, this is only needed in non-horizontal cases.\n // Setting lastEdge to the bottom of the first page that is partially\n // visible ensures that the next page fully below lastEdge is on the\n // next row, which has to be fully hidden along with all subsequent rows.\n if (viewBottom >= bottom) {\n lastEdge = viewBottom;\n }\n } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {\n break;\n }\n\n if (viewBottom <= top || currentHeight >= bottom ||\n viewRight <= left || currentWidth >= right) {\n continue;\n }\n\n hiddenHeight = Math.max(0, top - currentHeight) +\n Math.max(0, viewBottom - bottom);\n hiddenWidth = Math.max(0, left - currentWidth) +\n Math.max(0, viewRight - right);\n percentVisible = ((viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) *\n 100 / viewHeight / viewWidth) | 0;\n\n visible.push({\n id: view.id,\n x: currentWidth,\n y: currentHeight,\n view,\n percent: percentVisible,\n });\n }\n\n let first = visible[0];\n let last = visible[visible.length - 1];\n\n if (sortByVisibility) {\n visible.sort(function(a, b) {\n let pc = a.percent - b.percent;\n if (Math.abs(pc) > 0.001) {\n return -pc;\n }\n return a.id - b.id; // ensure stability\n });\n }\n return { first, last, views: visible, };\n}\n\n/**\n * Event handler to suppress context menu.\n */\nfunction noContextMenuHandler(evt) {\n evt.preventDefault();\n}\n\nfunction isDataSchema(url) {\n let i = 0, ii = url.length;\n while (i < ii && url[i].trim() === '') {\n i++;\n }\n return url.substring(i, i + 5).toLowerCase() === 'data:';\n}\n\n/**\n * Returns the filename or guessed filename from the url (see issue 3455).\n * @param {string} url - The original PDF location.\n * @param {string} defaultFilename - The value returned if the filename is\n * unknown, or the protocol is unsupported.\n * @returns {string} Guessed PDF filename.\n */\nfunction getPDFFileNameFromURL(url, defaultFilename = 'document.pdf') {\n if (typeof url !== 'string') {\n return defaultFilename;\n }\n if (isDataSchema(url)) {\n console.warn('getPDFFileNameFromURL: ' +\n 'ignoring \"data:\" URL for performance reasons.');\n return defaultFilename;\n }\n const reURI = /^(?:(?:[^:]+:)?\\/\\/[^\\/]+)?([^?#]*)(\\?[^#]*)?(#.*)?$/;\n // SCHEME HOST 1.PATH 2.QUERY 3.REF\n // Pattern to get last matching NAME.pdf\n const reFilename = /[^\\/?#=]+\\.pdf\\b(?!.*\\.pdf\\b)/i;\n let splitURI = reURI.exec(url);\n let suggestedFilename = reFilename.exec(splitURI[1]) ||\n reFilename.exec(splitURI[2]) ||\n reFilename.exec(splitURI[3]);\n if (suggestedFilename) {\n suggestedFilename = suggestedFilename[0];\n if (suggestedFilename.includes('%')) {\n // URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf\n try {\n suggestedFilename =\n reFilename.exec(decodeURIComponent(suggestedFilename))[0];\n } catch (ex) { // Possible (extremely rare) errors:\n // URIError \"Malformed URI\", e.g. for \"%AA.pdf\"\n // TypeError \"null has no properties\", e.g. for \"%2F.pdf\"\n }\n }\n }\n return suggestedFilename || defaultFilename;\n}\n\nfunction normalizeWheelEventDelta(evt) {\n let delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);\n let angle = Math.atan2(evt.deltaY, evt.deltaX);\n if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {\n // All that is left-up oriented has to change the sign.\n delta = -delta;\n }\n\n const MOUSE_DOM_DELTA_PIXEL_MODE = 0;\n const MOUSE_DOM_DELTA_LINE_MODE = 1;\n const MOUSE_PIXELS_PER_LINE = 30;\n const MOUSE_LINES_PER_PAGE = 30;\n\n // Converts delta to per-page units\n if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {\n delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;\n } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {\n delta /= MOUSE_LINES_PER_PAGE;\n }\n return delta;\n}\n\nfunction isValidRotation(angle) {\n return Number.isInteger(angle) && angle % 90 === 0;\n}\n\nfunction isPortraitOrientation(size) {\n return size.width <= size.height;\n}\n\nconst WaitOnType = {\n EVENT: 'event',\n TIMEOUT: 'timeout',\n};\n\n/**\n * @typedef {Object} WaitOnEventOrTimeoutParameters\n * @property {Object} target - The event target, can for example be:\n * `window`, `document`, a DOM element, or an {EventBus} instance.\n * @property {string} name - The name of the event.\n * @property {number} delay - The delay, in milliseconds, after which the\n * timeout occurs (if the event wasn't already dispatched).\n */\n\n/**\n * Allows waiting for an event or a timeout, whichever occurs first.\n * Can be used to ensure that an action always occurs, even when an event\n * arrives late or not at all.\n *\n * @param {WaitOnEventOrTimeoutParameters}\n * @returns {Promise} A promise that is resolved with a {WaitOnType} value.\n */\nfunction waitOnEventOrTimeout({ target, name, delay = 0, }) {\n return new Promise(function(resolve, reject) {\n if (typeof target !== 'object' || !(name && typeof name === 'string') ||\n !(Number.isInteger(delay) && delay >= 0)) {\n throw new Error('waitOnEventOrTimeout - invalid parameters.');\n }\n\n function handler(type) {\n if (target instanceof EventBus) {\n target.off(name, eventHandler);\n } else {\n target.removeEventListener(name, eventHandler);\n }\n\n if (timeout) {\n clearTimeout(timeout);\n }\n resolve(type);\n }\n\n const eventHandler = handler.bind(null, WaitOnType.EVENT);\n if (target instanceof EventBus) {\n target.on(name, eventHandler);\n } else {\n target.addEventListener(name, eventHandler);\n }\n\n const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);\n let timeout = setTimeout(timeoutHandler, delay);\n });\n}\n\n/**\n * Promise that is resolved when DOM window becomes visible.\n */\nlet animationStarted = new Promise(function (resolve) {\n if ((typeof PDFJSDev !== 'undefined' && PDFJSDev.test('LIB')) &&\n typeof window === 'undefined') {\n // Prevent \"ReferenceError: window is not defined\" errors when running the\n // unit-tests in Node.js/Travis.\n setTimeout(resolve, 20);\n return;\n }\n window.requestAnimationFrame(resolve);\n});\n\n/**\n * Simple event bus for an application. Listeners are attached using the\n * `on` and `off` methods. To raise an event, the `dispatch` method shall be\n * used.\n */\nclass EventBus {\n constructor({ dispatchToDOM = false, } = {}) {\n this._listeners = Object.create(null);\n this._dispatchToDOM = dispatchToDOM === true;\n }\n\n on(eventName, listener) {\n let eventListeners = this._listeners[eventName];\n if (!eventListeners) {\n eventListeners = [];\n this._listeners[eventName] = eventListeners;\n }\n eventListeners.push(listener);\n }\n\n off(eventName, listener) {\n let eventListeners = this._listeners[eventName];\n let i;\n if (!eventListeners || ((i = eventListeners.indexOf(listener)) < 0)) {\n return;\n }\n eventListeners.splice(i, 1);\n }\n\n dispatch(eventName) {\n let eventListeners = this._listeners[eventName];\n if (!eventListeners || eventListeners.length === 0) {\n if (this._dispatchToDOM) {\n const args = Array.prototype.slice.call(arguments, 1);\n this._dispatchDOMEvent(eventName, args);\n }\n return;\n }\n // Passing all arguments after the eventName to the listeners.\n const args = Array.prototype.slice.call(arguments, 1);\n // Making copy of the listeners array in case if it will be modified\n // during dispatch.\n eventListeners.slice(0).forEach(function (listener) {\n listener.apply(null, args);\n });\n if (this._dispatchToDOM) {\n this._dispatchDOMEvent(eventName, args);\n }\n }\n\n /**\n * @private\n */\n _dispatchDOMEvent(eventName, args = null) {\n if (!this._dispatchToDOM) {\n return;\n }\n const details = Object.create(null);\n if (args && args.length > 0) {\n const obj = args[0];\n for (let key in obj) {\n const value = obj[key];\n if (key === 'source') {\n if (value === window || value === document) {\n return; // No need to re-dispatch (already) global events.\n }\n continue; // Ignore the `source` property.\n }\n details[key] = value;\n }\n }\n const event = document.createEvent('CustomEvent');\n event.initCustomEvent(eventName, true, true, details);\n document.dispatchEvent(event);\n }\n}\n\nfunction clamp(v, min, max) {\n return Math.min(Math.max(v, min), max);\n}\n\nclass ProgressBar {\n constructor(id, { height, width, units, } = {}) {\n this.visible = true;\n\n // Fetch the sub-elements for later.\n this.div = document.querySelector(id + ' .progress');\n // Get the loading bar element, so it can be resized to fit the viewer.\n this.bar = this.div.parentNode;\n\n // Get options, with sensible defaults.\n this.height = height || 100;\n this.width = width || 100;\n this.units = units || '%';\n\n // Initialize heights.\n this.div.style.height = this.height + this.units;\n this.percent = 0;\n }\n\n _updateBar() {\n if (this._indeterminate) {\n this.div.classList.add('indeterminate');\n this.div.style.width = this.width + this.units;\n return;\n }\n\n this.div.classList.remove('indeterminate');\n let progressSize = this.width * this._percent / 100;\n this.div.style.width = progressSize + this.units;\n }\n\n get percent() {\n return this._percent;\n }\n\n set percent(val) {\n this._indeterminate = isNaN(val);\n this._percent = clamp(val, 0, 100);\n this._updateBar();\n }\n\n setWidth(viewer) {\n if (!viewer) {\n return;\n }\n let container = viewer.parentNode;\n let scrollbarWidth = container.offsetWidth - viewer.offsetWidth;\n if (scrollbarWidth > 0) {\n this.bar.setAttribute('style', 'width: calc(100% - ' +\n scrollbarWidth + 'px);');\n }\n }\n\n hide() {\n if (!this.visible) {\n return;\n }\n this.visible = false;\n this.bar.classList.add('hidden');\n document.body.classList.remove('loadingInProgress');\n }\n\n show() {\n if (this.visible) {\n return;\n }\n this.visible = true;\n document.body.classList.add('loadingInProgress');\n this.bar.classList.remove('hidden');\n }\n}\n\n/**\n * Moves all elements of an array that satisfy condition to the end of the\n * array, preserving the order of the rest.\n */\nfunction moveToEndOfArray(arr, condition) {\n const moved = [], len = arr.length;\n let write = 0;\n for (let read = 0; read < len; ++read) {\n if (condition(arr[read])) {\n moved.push(arr[read]);\n } else {\n arr[write] = arr[read];\n ++write;\n }\n }\n for (let read = 0; write < len; ++read, ++write) {\n arr[write] = moved[read];\n }\n}\n\nexport {\n CSS_UNITS,\n DEFAULT_SCALE_VALUE,\n DEFAULT_SCALE,\n MIN_SCALE,\n MAX_SCALE,\n UNKNOWN_SCALE,\n MAX_AUTO_SCALE,\n SCROLLBAR_PADDING,\n VERTICAL_PADDING,\n isValidRotation,\n isPortraitOrientation,\n PresentationModeState,\n RendererType,\n TextLayerMode,\n NullL10n,\n EventBus,\n ProgressBar,\n getPDFFileNameFromURL,\n noContextMenuHandler,\n parseQueryString,\n backtrackBeforeAllVisibleElements, // only exported for testing\n getVisibleElements,\n roundToDivide,\n getPageSizeInches,\n approximateFraction,\n getOutputScale,\n scrollIntoView,\n watchScroll,\n binarySearchFirstItem,\n normalizeWheelEventDelta,\n animationStarted,\n WaitOnType,\n waitOnEventOrTimeout,\n moveToEndOfArray,\n};\n","/* Copyright 2016 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/* globals module, __non_webpack_require__ */\n\n'use strict';\n\nlet pdfjsLib;\nif (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {\n pdfjsLib = window['pdfjs-dist/build/pdf'];\n} else {\n pdfjsLib = __non_webpack_require__('../build/pdf.js');\n}\nmodule.exports = pdfjsLib;\n","/* Copyright 2017 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GrabToPan } from './grab_to_pan';\n\nconst CursorTool = {\n SELECT: 0, // The default value.\n HAND: 1,\n ZOOM: 2,\n};\n\n/**\n * @typedef {Object} PDFCursorToolsOptions\n * @property {HTMLDivElement} container - The document container.\n * @property {EventBus} eventBus - The application event bus.\n * @property {number} cursorToolOnLoad - (optional) The cursor tool that will be\n * enabled on load; the constants from {CursorTool} should be used.\n * The default value is `CursorTool.SELECT`.\n */\n\nclass PDFCursorTools {\n /**\n * @param {PDFCursorToolsOptions} options\n */\n constructor({ container, eventBus, cursorToolOnLoad = CursorTool.SELECT, }) {\n this.container = container;\n this.eventBus = eventBus;\n\n this.active = CursorTool.SELECT;\n this.activeBeforePresentationMode = null;\n\n this.handTool = new GrabToPan({\n element: this.container,\n });\n\n this._addEventListeners();\n\n // Defer the initial `switchTool` call, to give other viewer components\n // time to initialize *and* register 'cursortoolchanged' event listeners.\n Promise.resolve().then(() => {\n this.switchTool(cursorToolOnLoad);\n });\n }\n\n /**\n * @returns {number} One of the values in {CursorTool}.\n */\n get activeTool() {\n return this.active;\n }\n\n /**\n * NOTE: This method is ignored while Presentation Mode is active.\n * @param {number} tool - The cursor mode that should be switched to,\n * must be one of the values in {CursorTool}.\n */\n switchTool(tool) {\n if (this.activeBeforePresentationMode !== null) {\n return; // Cursor tools cannot be used in Presentation Mode.\n }\n if (tool === this.active) {\n return; // The requested tool is already active.\n }\n\n let disableActiveTool = () => {\n switch (this.active) {\n case CursorTool.SELECT:\n break;\n case CursorTool.HAND:\n this.handTool.deactivate();\n break;\n case CursorTool.ZOOM:\n /* falls through */\n }\n };\n\n switch (tool) { // Enable the new cursor tool.\n case CursorTool.SELECT:\n disableActiveTool();\n break;\n case CursorTool.HAND:\n disableActiveTool();\n this.handTool.activate();\n break;\n case CursorTool.ZOOM:\n /* falls through */\n default:\n console.error(`switchTool: \"${tool}\" is an unsupported value.`);\n return;\n }\n // Update the active tool *after* it has been validated above,\n // in order to prevent setting it to an invalid state.\n this.active = tool;\n\n this._dispatchEvent();\n }\n\n /**\n * @private\n */\n _dispatchEvent() {\n this.eventBus.dispatch('cursortoolchanged', {\n source: this,\n tool: this.active,\n });\n }\n\n /**\n * @private\n */\n _addEventListeners() {\n this.eventBus.on('switchcursortool', (evt) => {\n this.switchTool(evt.tool);\n });\n\n this.eventBus.on('presentationmodechanged', (evt) => {\n if (evt.switchInProgress) {\n return;\n }\n let previouslyActive;\n\n if (evt.active) {\n previouslyActive = this.active;\n\n this.switchTool(CursorTool.SELECT);\n this.activeBeforePresentationMode = previouslyActive;\n } else {\n previouslyActive = this.activeBeforePresentationMode;\n\n this.activeBeforePresentationMode = null;\n this.switchTool(previouslyActive);\n }\n });\n }\n}\n\nexport {\n CursorTool,\n PDFCursorTools,\n};\n","/* Copyright 2013 Rob Wu <rob@robwu.nl>\n * https://github.com/Rob--W/grab-to-pan.js\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/* eslint-disable no-var */\n\n/**\n * Construct a GrabToPan instance for a given HTML element.\n * @param options.element {Element}\n * @param options.ignoreTarget {function} optional. See `ignoreTarget(node)`\n * @param options.onActiveChanged {function(boolean)} optional. Called\n * when grab-to-pan is (de)activated. The first argument is a boolean that\n * shows whether grab-to-pan is activated.\n */\nfunction GrabToPan(options) {\n this.element = options.element;\n this.document = options.element.ownerDocument;\n if (typeof options.ignoreTarget === 'function') {\n this.ignoreTarget = options.ignoreTarget;\n }\n this.onActiveChanged = options.onActiveChanged;\n\n // Bind the contexts to ensure that `this` always points to\n // the GrabToPan instance.\n this.activate = this.activate.bind(this);\n this.deactivate = this.deactivate.bind(this);\n this.toggle = this.toggle.bind(this);\n this._onmousedown = this._onmousedown.bind(this);\n this._onmousemove = this._onmousemove.bind(this);\n this._endPan = this._endPan.bind(this);\n\n // This overlay will be inserted in the document when the mouse moves during\n // a grab operation, to ensure that the cursor has the desired appearance.\n var overlay = this.overlay = document.createElement('div');\n overlay.className = 'grab-to-pan-grabbing';\n}\nGrabToPan.prototype = {\n /**\n * Class name of element which can be grabbed\n */\n CSS_CLASS_GRAB: 'grab-to-pan-grab',\n\n /**\n * Bind a mousedown event to the element to enable grab-detection.\n */\n activate: function GrabToPan_activate() {\n if (!this.active) {\n this.active = true;\n this.element.addEventListener('mousedown', this._onmousedown, true);\n this.element.classList.add(this.CSS_CLASS_GRAB);\n if (this.onActiveChanged) {\n this.onActiveChanged(true);\n }\n }\n },\n\n /**\n * Removes all events. Any pending pan session is immediately stopped.\n */\n deactivate: function GrabToPan_deactivate() {\n if (this.active) {\n this.active = false;\n this.element.removeEventListener('mousedown', this._onmousedown, true);\n this._endPan();\n this.element.classList.remove(this.CSS_CLASS_GRAB);\n if (this.onActiveChanged) {\n this.onActiveChanged(false);\n }\n }\n },\n\n toggle: function GrabToPan_toggle() {\n if (this.active) {\n this.deactivate();\n } else {\n this.activate();\n }\n },\n\n /**\n * Whether to not pan if the target element is clicked.\n * Override this method to change the default behaviour.\n *\n * @param node {Element} The target of the event\n * @return {boolean} Whether to not react to the click event.\n */\n ignoreTarget: function GrabToPan_ignoreTarget(node) {\n // Use matchesSelector to check whether the clicked element\n // is (a child of) an input element / link\n return node[matchesSelector](\n 'a[href], a[href] *, input, textarea, button, button *, select, option'\n );\n },\n\n /**\n * @private\n */\n _onmousedown: function GrabToPan__onmousedown(event) {\n if (event.button !== 0 || this.ignoreTarget(event.target)) {\n return;\n }\n if (event.originalTarget) {\n try {\n // eslint-disable-next-line no-unused-expressions\n event.originalTarget.tagName;\n } catch (e) {\n // Mozilla-specific: element is a scrollbar (XUL element)\n return;\n }\n }\n\n this.scrollLeftStart = this.element.scrollLeft;\n this.scrollTopStart = this.element.scrollTop;\n this.clientXStart = event.clientX;\n this.clientYStart = event.clientY;\n this.document.addEventListener('mousemove', this._onmousemove, true);\n this.document.addEventListener('mouseup', this._endPan, true);\n // When a scroll event occurs before a mousemove, assume that the user\n // dragged a scrollbar (necessary for Opera Presto, Safari and IE)\n // (not needed for Chrome/Firefox)\n this.element.addEventListener('scroll', this._endPan, true);\n event.preventDefault();\n event.stopPropagation();\n\n var focusedElement = document.activeElement;\n if (focusedElement && !focusedElement.contains(event.target)) {\n focusedElement.blur();\n }\n },\n\n /**\n * @private\n */\n _onmousemove: function GrabToPan__onmousemove(event) {\n this.element.removeEventListener('scroll', this._endPan, true);\n if (isLeftMouseReleased(event)) {\n this._endPan();\n return;\n }\n var xDiff = event.clientX - this.clientXStart;\n var yDiff = event.clientY - this.clientYStart;\n var scrollTop = this.scrollTopStart - yDiff;\n var scrollLeft = this.scrollLeftStart - xDiff;\n if (this.element.scrollTo) {\n this.element.scrollTo({\n top: scrollTop,\n left: scrollLeft,\n behavior: 'instant',\n });\n } else {\n this.element.scrollTop = scrollTop;\n this.element.scrollLeft = scrollLeft;\n }\n if (!this.overlay.parentNode) {\n document.body.appendChild(this.overlay);\n }\n },\n\n /**\n * @private\n */\n _endPan: function GrabToPan__endPan() {\n this.element.removeEventListener('scroll', this._endPan, true);\n this.document.removeEventListener('mousemove', this._onmousemove, true);\n this.document.removeEventListener('mouseup', this._endPan, true);\n // Note: ChildNode.remove doesn't throw if the parentNode is undefined.\n this.overlay.remove();\n },\n};\n\n// Get the correct (vendor-prefixed) name of the matches method.\nvar matchesSelector;\n['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function(prefix) {\n var name = prefix + 'atches';\n if (name in document.documentElement) {\n matchesSelector = name;\n }\n name += 'Selector';\n if (name in document.documentElement) {\n matchesSelector = name;\n }\n return matchesSelector; // If found, then truthy, and [].some() ends.\n});\n\n// Browser sniffing because it's impossible to feature-detect\n// whether event.which for onmousemove is reliable\nvar isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;\nvar chrome = window.chrome;\nvar isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);\n// ^ Chrome 15+ ^ Opera 15+\nvar isSafari6plus = /Apple/.test(navigator.vendor) &&\n /Version\\/([6-9]\\d*|[1-5]\\d+)/.test(navigator.userAgent);\n\n/**\n * Whether the left mouse is not pressed.\n * @param event {MouseEvent}\n * @return {boolean} True if the left mouse button is not pressed.\n * False if unsure or if the left mouse button is pressed.\n */\nfunction isLeftMouseReleased(event) {\n if ('buttons' in event && isNotIEorIsIE10plus) {\n // http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-buttons\n // Firefox 15+\n // Internet Explorer 10+\n return !(event.buttons & 1);\n }\n if (isChrome15OrOpera15plus || isSafari6plus) {\n // Chrome 14+\n // Opera 15+\n // Safari 6.0+\n return event.which === 0;\n }\n}\n\nexport {\n GrabToPan,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst CLEANUP_TIMEOUT = 30000;\n\nconst RenderingStates = {\n INITIAL: 0,\n RUNNING: 1,\n PAUSED: 2,\n FINISHED: 3,\n};\n\n/**\n * Controls rendering of the views for pages and thumbnails.\n */\nclass PDFRenderingQueue {\n constructor() {\n this.pdfViewer = null;\n this.pdfThumbnailViewer = null;\n this.onIdle = null;\n this.highestPriorityPage = null;\n this.idleTimeout = null;\n this.printing = false;\n this.isThumbnailViewEnabled = false;\n }\n\n /**\n * @param {PDFViewer} pdfViewer\n */\n setViewer(pdfViewer) {\n this.pdfViewer = pdfViewer;\n }\n\n /**\n * @param {PDFThumbnailViewer} pdfThumbnailViewer\n */\n setThumbnailViewer(pdfThumbnailViewer) {\n this.pdfThumbnailViewer = pdfThumbnailViewer;\n }\n\n /**\n * @param {IRenderableView} view\n * @returns {boolean}\n */\n isHighestPriority(view) {\n return this.highestPriorityPage === view.renderingId;\n }\n\n /**\n * @param {Object} currentlyVisiblePages\n */\n renderHighestPriority(currentlyVisiblePages) {\n if (this.idleTimeout) {\n clearTimeout(this.idleTimeout);\n this.idleTimeout = null;\n }\n\n // Pages have a higher priority than thumbnails, so check them first.\n if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {\n return;\n }\n // No pages needed rendering, so check thumbnails.\n if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {\n if (this.pdfThumbnailViewer.forceRendering()) {\n return;\n }\n }\n\n if (this.printing) {\n // If printing is currently ongoing do not reschedule cleanup.\n return;\n }\n\n if (this.onIdle) {\n this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);\n }\n }\n\n /**\n * @param {Object} visible\n * @param {Array} views\n * @param {boolean} scrolledDown\n */\n getHighestPriority(visible, views, scrolledDown) {\n /**\n * The state has changed. Figure out which page has the highest priority to\n * render next (if any).\n *\n * Priority:\n * 1. visible pages\n * 2. if last scrolled down, the page after the visible pages, or\n * if last scrolled up, the page before the visible pages\n */\n let visibleViews = visible.views;\n\n let numVisible = visibleViews.length;\n if (numVisible === 0) {\n return false;\n }\n for (let i = 0; i < numVisible; ++i) {\n let view = visibleViews[i].view;\n if (!this.isViewFinished(view)) {\n return view;\n }\n }\n\n // All the visible views have rendered; try to render next/previous pages.\n if (scrolledDown) {\n let nextPageIndex = visible.last.id;\n // IDs start at 1, so no need to add 1.\n if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {\n return views[nextPageIndex];\n }\n } else {\n let previousPageIndex = visible.first.id - 2;\n if (views[previousPageIndex] &&\n !this.isViewFinished(views[previousPageIndex])) {\n return views[previousPageIndex];\n }\n }\n // Everything that needs to be rendered has been.\n return null;\n }\n\n /**\n * @param {IRenderableView} view\n * @returns {boolean}\n */\n isViewFinished(view) {\n return view.renderingState === RenderingStates.FINISHED;\n }\n\n /**\n * Render a page or thumbnail view. This calls the appropriate function\n * based on the views state. If the view is already rendered it will return\n * `false`.\n *\n * @param {IRenderableView} view\n */\n renderView(view) {\n switch (view.renderingState) {\n case RenderingStates.FINISHED:\n return false;\n case RenderingStates.PAUSED:\n this.highestPriorityPage = view.renderingId;\n view.resume();\n break;\n case RenderingStates.RUNNING:\n this.highestPriorityPage = view.renderingId;\n break;\n case RenderingStates.INITIAL:\n this.highestPriorityPage = view.renderingId;\n let continueRendering = () => {\n this.renderHighestPriority();\n };\n view.draw().then(continueRendering, continueRendering);\n break;\n }\n return true;\n }\n}\n\nexport {\n RenderingStates,\n PDFRenderingQueue,\n};\n","/* Copyright 2016 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NullL10n } from './ui_utils';\nimport { RenderingStates } from './pdf_rendering_queue';\n\nconst UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';\n\nconst SidebarView = {\n NONE: 0,\n THUMBS: 1,\n OUTLINE: 2,\n ATTACHMENTS: 3,\n};\n\n/**\n * @typedef {Object} PDFSidebarOptions\n * @property {PDFViewer} pdfViewer - The document viewer.\n * @property {PDFThumbnailViewer} pdfThumbnailViewer - The thumbnail viewer.\n * @property {HTMLDivElement} outerContainer - The outer container\n * (encasing both the viewer and sidebar elements).\n * @property {HTMLDivElement} viewerContainer - The viewer container\n * (in which the viewer element is placed).\n * @property {HTMLButtonElement} toggleButton - The button used for\n * opening/closing the sidebar.\n * @property {HTMLButtonElement} thumbnailButton - The button used to show\n * the thumbnail view.\n * @property {HTMLButtonElement} outlineButton - The button used to show\n * the outline view.\n * @property {HTMLButtonElement} attachmentsButton - The button used to show\n * the attachments view.\n * @property {HTMLDivElement} thumbnailView - The container in which\n * the thumbnails are placed.\n * @property {HTMLDivElement} outlineView - The container in which\n * the outline is placed.\n * @property {HTMLDivElement} attachmentsView - The container in which\n * the attachments are placed.\n * @property {boolean} disableNotification - (optional) Disable the notification\n * for documents containing outline/attachments. The default value is `false`.\n */\n\nclass PDFSidebar {\n /**\n * @param {PDFSidebarOptions} options\n * @param {EventBus} eventBus - The application event bus.\n * @param {IL10n} l10n - Localization service.\n */\n constructor(options, eventBus, l10n = NullL10n) {\n this.isOpen = false;\n this.active = SidebarView.THUMBS;\n this.isInitialViewSet = false;\n\n /**\n * Callback used when the sidebar has been opened/closed, to ensure that\n * the viewers (PDFViewer/PDFThumbnailViewer) are updated correctly.\n */\n this.onToggled = null;\n\n this.pdfViewer = options.pdfViewer;\n this.pdfThumbnailViewer = options.pdfThumbnailViewer;\n\n this.outerContainer = options.outerContainer;\n this.viewerContainer = options.viewerContainer;\n this.toggleButton = options.toggleButton;\n\n this.thumbnailButton = options.thumbnailButton;\n this.outlineButton = options.outlineButton;\n this.attachmentsButton = options.attachmentsButton;\n\n this.thumbnailView = options.thumbnailView;\n this.outlineView = options.outlineView;\n this.attachmentsView = options.attachmentsView;\n\n this.disableNotification = options.disableNotification || false;\n\n this.eventBus = eventBus;\n this.l10n = l10n;\n\n this._addEventListeners();\n }\n\n reset() {\n this.isInitialViewSet = false;\n\n this._hideUINotification(null);\n this.switchView(SidebarView.THUMBS);\n\n this.outlineButton.disabled = false;\n this.attachmentsButton.disabled = false;\n }\n\n /**\n * @returns {number} One of the values in {SidebarView}.\n */\n get visibleView() {\n return (this.isOpen ? this.active : SidebarView.NONE);\n }\n\n get isThumbnailViewVisible() {\n return (this.isOpen && this.active === SidebarView.THUMBS);\n }\n\n get isOutlineViewVisible() {\n return (this.isOpen && this.active === SidebarView.OUTLINE);\n }\n\n get isAttachmentsViewVisible() {\n return (this.isOpen && this.active === SidebarView.ATTACHMENTS);\n }\n\n /**\n * @param {number} view - The sidebar view that should become visible,\n * must be one of the values in {SidebarView}.\n */\n setInitialView(view = SidebarView.NONE) {\n if (this.isInitialViewSet) {\n return;\n }\n this.isInitialViewSet = true;\n\n if (this.isOpen && view === SidebarView.NONE) {\n this._dispatchEvent();\n // If the user has already manually opened the sidebar,\n // immediately closing it would be bad UX.\n return;\n }\n let isViewPreserved = (view === this.visibleView);\n this.switchView(view, /* forceOpen */ true);\n\n if (isViewPreserved) {\n // Prevent dispatching two back-to-back `sidebarviewchanged` events,\n // since `this.switchView` dispatched the event if the view changed.\n this._dispatchEvent();\n }\n }\n\n /**\n * @param {number} view - The sidebar view that should be switched to,\n * must be one of the values in {SidebarView}.\n * @param {boolean} forceOpen - (optional) Ensure that the sidebar is open.\n * The default value is `false`.\n */\n switchView(view, forceOpen = false) {\n if (view === SidebarView.NONE) {\n this.close();\n return;\n }\n let isViewChanged = (view !== this.active);\n let shouldForceRendering = false;\n\n switch (view) {\n case SidebarView.THUMBS:\n this.thumbnailButton.classList.add('toggled');\n this.outlineButton.classList.remove('toggled');\n this.attachmentsButton.classList.remove('toggled');\n\n this.thumbnailView.classList.remove('hidden');\n this.outlineView.classList.add('hidden');\n this.attachmentsView.classList.add('hidden');\n\n if (this.isOpen && isViewChanged) {\n this._updateThumbnailViewer();\n shouldForceRendering = true;\n }\n break;\n case SidebarView.OUTLINE:\n if (this.outlineButton.disabled) {\n return;\n }\n this.thumbnailButton.classList.remove('toggled');\n this.outlineButton.classList.add('toggled');\n this.attachmentsButton.classList.remove('toggled');\n\n this.thumbnailView.classList.add('hidden');\n this.outlineView.classList.remove('hidden');\n this.attachmentsView.classList.add('hidden');\n break;\n case SidebarView.ATTACHMENTS:\n if (this.attachmentsButton.disabled) {\n return;\n }\n this.thumbnailButton.classList.remove('toggled');\n this.outlineButton.classList.remove('toggled');\n this.attachmentsButton.classList.add('toggled');\n\n this.thumbnailView.classList.add('hidden');\n this.outlineView.classList.add('hidden');\n this.attachmentsView.classList.remove('hidden');\n break;\n default:\n console.error('PDFSidebar_switchView: \"' + view +\n '\" is an unsupported value.');\n return;\n }\n // Update the active view *after* it has been validated above,\n // in order to prevent setting it to an invalid state.\n this.active = view | 0;\n\n if (forceOpen && !this.isOpen) {\n this.open();\n return; // NOTE: Opening will trigger rendering, and dispatch the event.\n }\n if (shouldForceRendering) {\n this._forceRendering();\n }\n if (isViewChanged) {\n this._dispatchEvent();\n }\n this._hideUINotification(this.active);\n }\n\n open() {\n if (this.isOpen) {\n return;\n }\n this.isOpen = true;\n this.toggleButton.classList.add('toggled');\n\n this.outerContainer.classList.add('sidebarMoving');\n this.outerContainer.classList.add('sidebarOpen');\n\n if (this.active === SidebarView.THUMBS) {\n this._updateThumbnailViewer();\n }\n this._forceRendering();\n this._dispatchEvent();\n\n this._hideUINotification(this.active);\n }\n\n close() {\n if (!this.isOpen) {\n return;\n }\n this.isOpen = false;\n this.toggleButton.classList.remove('toggled');\n\n this.outerContainer.classList.add('sidebarMoving');\n this.outerContainer.classList.remove('sidebarOpen');\n\n this._forceRendering();\n this._dispatchEvent();\n }\n\n toggle() {\n if (this.isOpen) {\n this.close();\n } else {\n this.open();\n }\n }\n\n /**\n * @private\n */\n _dispatchEvent() {\n this.eventBus.dispatch('sidebarviewchanged', {\n source: this,\n view: this.visibleView,\n });\n }\n\n /**\n * @private\n */\n _forceRendering() {\n if (this.onToggled) {\n this.onToggled();\n } else { // Fallback\n this.pdfViewer.forceRendering();\n this.pdfThumbnailViewer.forceRendering();\n }\n }\n\n /**\n * @private\n */\n _updateThumbnailViewer() {\n let { pdfViewer, pdfThumbnailViewer, } = this;\n\n // Use the rendered pages to set the corresponding thumbnail images.\n let pagesCount = pdfViewer.pagesCount;\n for (let pageIndex = 0; pageIndex < pagesCount; pageIndex++) {\n let pageView = pdfViewer.getPageView(pageIndex);\n if (pageView && pageView.renderingState === RenderingStates.FINISHED) {\n let thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);\n thumbnailView.setImage(pageView);\n }\n }\n pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);\n }\n\n /**\n * @private\n */\n _showUINotification(view) {\n if (this.disableNotification) {\n return;\n }\n\n this.l10n.get('toggle_sidebar_notification.title', null,\n 'Toggle Sidebar (document contains outline/attachments)').\n then((msg) => {\n this.toggleButton.title = msg;\n });\n\n if (!this.isOpen) {\n // Only show the notification on the `toggleButton` if the sidebar is\n // currently closed, to avoid unnecessarily bothering the user.\n this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);\n } else if (view === this.active) {\n // If the sidebar is currently open *and* the `view` is visible, do not\n // bother the user with a notification on the corresponding button.\n return;\n }\n\n switch (view) {\n case SidebarView.OUTLINE:\n this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);\n break;\n case SidebarView.ATTACHMENTS:\n this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);\n break;\n }\n }\n\n /**\n * @private\n */\n _hideUINotification(view) {\n if (this.disableNotification) {\n return;\n }\n\n let removeNotification = (view) => {\n switch (view) {\n case SidebarView.OUTLINE:\n this.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);\n break;\n case SidebarView.ATTACHMENTS:\n this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);\n break;\n }\n };\n\n if (!this.isOpen && view !== null) {\n // Only hide the notifications when the sidebar is currently open,\n // or when it is being reset (i.e. `view === null`).\n return;\n }\n this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);\n\n if (view !== null) {\n removeNotification(view);\n return;\n }\n for (view in SidebarView) { // Remove all sidebar notifications on reset.\n removeNotification(SidebarView[view]);\n }\n\n this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').\n then((msg) => {\n this.toggleButton.title = msg;\n });\n }\n\n /**\n * @private\n */\n _addEventListeners() {\n this.viewerContainer.addEventListener('transitionend', (evt) => {\n if (evt.target === this.viewerContainer) {\n this.outerContainer.classList.remove('sidebarMoving');\n }\n });\n\n // Buttons for switching views.\n this.thumbnailButton.addEventListener('click', () => {\n this.switchView(SidebarView.THUMBS);\n });\n\n this.outlineButton.addEventListener('click', () => {\n this.switchView(SidebarView.OUTLINE);\n });\n this.outlineButton.addEventListener('dblclick', () => {\n this.eventBus.dispatch('toggleoutlinetree', { source: this, });\n });\n\n this.attachmentsButton.addEventListener('click', () => {\n this.switchView(SidebarView.ATTACHMENTS);\n });\n\n // Disable/enable views.\n this.eventBus.on('outlineloaded', (evt) => {\n let outlineCount = evt.outlineCount;\n\n this.outlineButton.disabled = !outlineCount;\n\n if (outlineCount) {\n this._showUINotification(SidebarView.OUTLINE);\n } else if (this.active === SidebarView.OUTLINE) {\n // If the outline view was opened during document load, switch away\n // from it if it turns out that the document has no outline.\n this.switchView(SidebarView.THUMBS);\n }\n });\n\n this.eventBus.on('attachmentsloaded', (evt) => {\n if (evt.attachmentsCount) {\n this.attachmentsButton.disabled = false;\n\n this._showUINotification(SidebarView.ATTACHMENTS);\n return;\n }\n\n // Attempt to avoid temporarily disabling, and switching away from, the\n // attachment view for documents that do not contain proper attachments\n // but *only* FileAttachment annotations. Hence we defer those operations\n // slightly to allow time for parsing any FileAttachment annotations that\n // may be present on the *initially* rendered page of the document.\n Promise.resolve().then(() => {\n if (this.attachmentsView.hasChildNodes()) {\n // FileAttachment annotations were appended to the attachment view.\n return;\n }\n this.attachmentsButton.disabled = true;\n\n if (this.active === SidebarView.ATTACHMENTS) {\n // If the attachment view was opened during document load, switch away\n // from it if it turns out that the document has no attachments.\n this.switchView(SidebarView.THUMBS);\n }\n });\n });\n\n // Update the thumbnailViewer, if visible, when exiting presentation mode.\n this.eventBus.on('presentationmodechanged', (evt) => {\n if (!evt.active && !evt.switchInProgress && this.isThumbnailViewVisible) {\n this._updateThumbnailViewer();\n }\n });\n }\n}\n\nexport {\n SidebarView,\n PDFSidebar,\n};\n","/* Copyright 2018 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { apiCompatibilityParams } from 'pdfjs-lib';\nimport { viewerCompatibilityParams } from './viewer_compatibility';\n\nconst OptionKind = {\n VIEWER: 'viewer',\n API: 'api',\n WORKER: 'worker',\n};\n\n/**\n * PLEASE NOTE: To avoid introducing unnecessary dependencies, we specify the\n * values below *explicitly* rather than relying on imported types;\n * compare with the format of `default_preferences.json`.\n */\nconst defaultOptions = {\n cursorToolOnLoad: {\n /** @type {number} */\n value: 0,\n kind: OptionKind.VIEWER,\n },\n defaultUrl: {\n /** @type {string} */\n value: 'compressed.tracemonkey-pldi-09.pdf',\n kind: OptionKind.VIEWER,\n },\n defaultZoomValue: {\n /** @type {string} */\n value: '',\n kind: OptionKind.VIEWER,\n },\n disableHistory: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n disablePageLabels: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n disablePageMode: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n enablePrintAutoRotate: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n enableWebGL: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n eventBusDispatchToDOM: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n externalLinkRel: {\n /** @type {string} */\n value: 'noopener noreferrer nofollow',\n kind: OptionKind.VIEWER,\n },\n externalLinkTarget: {\n /** @type {number} */\n value: 0,\n kind: OptionKind.VIEWER,\n },\n imageResourcesPath: {\n /** @type {string} */\n value: './images/',\n kind: OptionKind.VIEWER,\n },\n /**\n * The `locale` is, conditionally, defined below.\n */\n maxCanvasPixels: {\n /** @type {number} */\n value: viewerCompatibilityParams.maxCanvasPixels || 16777216,\n kind: OptionKind.VIEWER,\n },\n pdfBugEnabled: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n renderer: {\n /** @type {string} */\n value: 'canvas',\n kind: OptionKind.VIEWER,\n },\n renderInteractiveForms: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n showPreviousViewOnLoad: {\n /** @type {boolean} */\n value: true,\n kind: OptionKind.VIEWER,\n },\n sidebarViewOnLoad: {\n /** @type {number} */\n value: 0,\n kind: OptionKind.VIEWER,\n },\n scrollModeOnLoad: {\n /** @type {number} */\n value: 0,\n kind: OptionKind.VIEWER,\n },\n spreadModeOnLoad: {\n /** @type {number} */\n value: 0,\n kind: OptionKind.VIEWER,\n },\n textLayerMode: {\n /** @type {number} */\n value: 1,\n kind: OptionKind.VIEWER,\n },\n useOnlyCssZoom: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.VIEWER,\n },\n\n cMapPacked: {\n /** @type {boolean} */\n value: true,\n kind: OptionKind.API,\n },\n cMapUrl: {\n /** @type {string} */\n value: (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ?\n '../external/bcmaps/' : '../web/cmaps/'),\n kind: OptionKind.API,\n },\n disableAutoFetch: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.API,\n },\n disableCreateObjectURL: {\n /** @type {boolean} */\n value: apiCompatibilityParams.disableCreateObjectURL || false,\n kind: OptionKind.API,\n },\n disableFontFace: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.API,\n },\n disableRange: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.API,\n },\n disableStream: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.API,\n },\n isEvalSupported: {\n /** @type {boolean} */\n value: true,\n kind: OptionKind.API,\n },\n maxImageSize: {\n /** @type {number} */\n value: -1,\n kind: OptionKind.API,\n },\n pdfBug: {\n /** @type {boolean} */\n value: false,\n kind: OptionKind.API,\n },\n postMessageTransfers: {\n /** @type {boolean} */\n value: true,\n kind: OptionKind.API,\n },\n verbosity: {\n /** @type {number} */\n value: 1,\n kind: OptionKind.API,\n },\n\n workerPort: {\n /** @type {Object} */\n value: null,\n kind: OptionKind.WORKER,\n },\n workerSrc: {\n /** @type {string} */\n value: (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ?\n '../src/worker_loader.js' : '../build/pdf.worker.js'),\n kind: OptionKind.WORKER,\n },\n};\nif (typeof PDFJSDev === 'undefined' ||\n PDFJSDev.test('!PRODUCTION || GENERIC')) {\n defaultOptions.locale = {\n /** @type {string} */\n value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'),\n kind: OptionKind.VIEWER,\n };\n}\n\nconst userOptions = Object.create(null);\n\nclass AppOptions {\n constructor() {\n throw new Error('Cannot initialize AppOptions.');\n }\n\n static get(name) {\n let defaultOption = defaultOptions[name], userOption = userOptions[name];\n if (userOption !== undefined) {\n return userOption;\n }\n return (defaultOption !== undefined ? defaultOption.value : undefined);\n }\n\n static getAll(kind = null) {\n let options = Object.create(null);\n for (let name in defaultOptions) {\n let defaultOption = defaultOptions[name], userOption = userOptions[name];\n if (kind && defaultOption.kind !== kind) {\n continue;\n }\n options[name] = (userOption !== undefined ?\n userOption : defaultOption.value);\n }\n return options;\n }\n\n static set(name, value) {\n userOptions[name] = value;\n }\n\n static remove(name) {\n delete userOptions[name];\n }\n}\n\nexport {\n AppOptions,\n OptionKind,\n};\n","/* Copyright 2018 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet compatibilityParams = Object.create(null);\nif (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n const userAgent =\n (typeof navigator !== 'undefined' && navigator.userAgent) || '';\n const isAndroid = /Android/.test(userAgent);\n const isIOS = /\\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);\n\n // Limit canvas size to 5 mega-pixels on mobile.\n // Support: Android, iOS\n (function checkCanvasSizeLimitation() {\n if (isIOS || isAndroid) {\n compatibilityParams.maxCanvasPixels = 5242880;\n }\n })();\n}\n\nexports.viewerCompatibilityParams = Object.freeze(compatibilityParams);\n","/* Copyright 2016 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { EventBus } from './ui_utils';\n\n// Attaching to the application event bus to dispatch events to the DOM for\n// backwards viewer API compatibility.\nfunction attachDOMEventsToEventBus(eventBus) {\n eventBus.on('documentload', function() {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('documentload', true, true, {});\n window.dispatchEvent(event);\n });\n eventBus.on('pagerendered', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('pagerendered', true, true, {\n pageNumber: evt.pageNumber,\n cssTransform: evt.cssTransform,\n });\n evt.source.div.dispatchEvent(event);\n });\n eventBus.on('textlayerrendered', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('textlayerrendered', true, true, {\n pageNumber: evt.pageNumber,\n });\n evt.source.textLayerDiv.dispatchEvent(event);\n });\n eventBus.on('pagechange', function(evt) {\n let event = document.createEvent('UIEvents');\n event.initUIEvent('pagechange', true, true, window, 0);\n event.pageNumber = evt.pageNumber;\n evt.source.container.dispatchEvent(event);\n });\n eventBus.on('pagesinit', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('pagesinit', true, true, null);\n evt.source.container.dispatchEvent(event);\n });\n eventBus.on('pagesloaded', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('pagesloaded', true, true, {\n pagesCount: evt.pagesCount,\n });\n evt.source.container.dispatchEvent(event);\n });\n eventBus.on('scalechange', function(evt) {\n let event = document.createEvent('UIEvents');\n event.initUIEvent('scalechange', true, true, window, 0);\n event.scale = evt.scale;\n event.presetValue = evt.presetValue;\n evt.source.container.dispatchEvent(event);\n });\n eventBus.on('updateviewarea', function(evt) {\n let event = document.createEvent('UIEvents');\n event.initUIEvent('updateviewarea', true, true, window, 0);\n event.location = evt.location;\n evt.source.container.dispatchEvent(event);\n });\n eventBus.on('find', function(evt) {\n if (evt.source === window) {\n return; // event comes from FirefoxCom, no need to replicate\n }\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('find' + evt.type, true, true, {\n query: evt.query,\n phraseSearch: evt.phraseSearch,\n caseSensitive: evt.caseSensitive,\n highlightAll: evt.highlightAll,\n findPrevious: evt.findPrevious,\n });\n window.dispatchEvent(event);\n });\n eventBus.on('attachmentsloaded', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('attachmentsloaded', true, true, {\n attachmentsCount: evt.attachmentsCount,\n });\n evt.source.container.dispatchEvent(event);\n });\n eventBus.on('sidebarviewchanged', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('sidebarviewchanged', true, true, {\n view: evt.view,\n });\n evt.source.outerContainer.dispatchEvent(event);\n });\n eventBus.on('pagemode', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('pagemode', true, true, {\n mode: evt.mode,\n });\n evt.source.pdfViewer.container.dispatchEvent(event);\n });\n eventBus.on('namedaction', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('namedaction', true, true, {\n action: evt.action,\n });\n evt.source.pdfViewer.container.dispatchEvent(event);\n });\n eventBus.on('presentationmodechanged', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('presentationmodechanged', true, true, {\n active: evt.active,\n switchInProgress: evt.switchInProgress,\n });\n window.dispatchEvent(event);\n });\n eventBus.on('outlineloaded', function(evt) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent('outlineloaded', true, true, {\n outlineCount: evt.outlineCount,\n });\n evt.source.container.dispatchEvent(event);\n });\n}\n\nlet globalEventBus = null;\nfunction getGlobalEventBus(dispatchToDOM = false) {\n if (!globalEventBus) {\n globalEventBus = new EventBus({ dispatchToDOM, });\n if (!dispatchToDOM) {\n attachDOMEventsToEventBus(globalEventBus);\n }\n }\n return globalEventBus;\n}\n\nexport {\n attachDOMEventsToEventBus,\n getGlobalEventBus,\n};\n","/* Copyright 2014 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass OverlayManager {\n constructor() {\n this._overlays = {};\n this._active = null;\n this._keyDownBound = this._keyDown.bind(this);\n }\n\n get active() {\n return this._active;\n }\n\n /**\n * @param {string} name - The name of the overlay that is registered.\n * @param {HTMLDivElement} element - The overlay's DOM element.\n * @param {function} callerCloseMethod - (optional) The method that, if\n * present, calls `OverlayManager.close` from the object\n * registering the overlay. Access to this method is\n * necessary in order to run cleanup code when e.g.\n * the overlay is force closed. The default is `null`.\n * @param {boolean} canForceClose - (optional) Indicates if opening the\n * overlay closes an active overlay. The default is `false`.\n * @returns {Promise} A promise that is resolved when the overlay has been\n * registered.\n */\n async register(name, element, callerCloseMethod = null,\n canForceClose = false) {\n let container;\n if (!name || !element || !(container = element.parentNode)) {\n throw new Error('Not enough parameters.');\n } else if (this._overlays[name]) {\n throw new Error('The overlay is already registered.');\n }\n this._overlays[name] = {\n element,\n container,\n callerCloseMethod,\n canForceClose,\n };\n }\n\n /**\n * @param {string} name - The name of the overlay that is unregistered.\n * @returns {Promise} A promise that is resolved when the overlay has been\n * unregistered.\n */\n async unregister(name) {\n if (!this._overlays[name]) {\n throw new Error('The overlay does not exist.');\n } else if (this._active === name) {\n throw new Error('The overlay cannot be removed while it is active.');\n }\n delete this._overlays[name];\n }\n\n /**\n * @param {string} name - The name of the overlay that should be opened.\n * @returns {Promise} A promise that is resolved when the overlay has been\n * opened.\n */\n async open(name) {\n if (!this._overlays[name]) {\n throw new Error('The overlay does not exist.');\n } else if (this._active) {\n if (this._overlays[name].canForceClose) {\n this._closeThroughCaller();\n } else if (this._active === name) {\n throw new Error('The overlay is already active.');\n } else {\n throw new Error('Another overlay is currently active.');\n }\n }\n this._active = name;\n this._overlays[this._active].element.classList.remove('hidden');\n this._overlays[this._active].container.classList.remove('hidden');\n\n window.addEventListener('keydown', this._keyDownBound);\n }\n\n /**\n * @param {string} name - The name of the overlay that should be closed.\n * @returns {Promise} A promise that is resolved when the overlay has been\n * closed.\n */\n async close(name) {\n if (!this._overlays[name]) {\n throw new Error('The overlay does not exist.');\n } else if (!this._active) {\n throw new Error('The overlay is currently not active.');\n } else if (this._active !== name) {\n throw new Error('Another overlay is currently active.');\n }\n this._overlays[this._active].container.classList.add('hidden');\n this._overlays[this._active].element.classList.add('hidden');\n this._active = null;\n\n window.removeEventListener('keydown', this._keyDownBound);\n }\n\n /**\n * @private\n */\n _keyDown(evt) {\n if (this._active && evt.keyCode === 27) { // Esc key.\n this._closeThroughCaller();\n evt.preventDefault();\n }\n }\n\n /**\n * @private\n */\n _closeThroughCaller() {\n if (this._overlays[this._active].callerCloseMethod) {\n this._overlays[this._active].callerCloseMethod();\n }\n if (this._active) {\n this.close(this._active);\n }\n }\n}\n\nexport {\n OverlayManager,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NullL10n } from './ui_utils';\nimport { PasswordResponses } from 'pdfjs-lib';\n\n/**\n * @typedef {Object} PasswordPromptOptions\n * @property {string} overlayName - Name of the overlay for the overlay manager.\n * @property {HTMLDivElement} container - Div container for the overlay.\n * @property {HTMLParagraphElement} label - Label containing instructions for\n * entering the password.\n * @property {HTMLInputElement} input - Input field for entering the password.\n * @property {HTMLButtonElement} submitButton - Button for submitting the\n * password.\n * @property {HTMLButtonElement} cancelButton - Button for cancelling password\n * entry.\n */\n\nclass PasswordPrompt {\n /**\n * @param {PasswordPromptOptions} options\n * @param {OverlayManager} overlayManager - Manager for the viewer overlays.\n * @param {IL10n} l10n - Localization service.\n */\n constructor(options, overlayManager, l10n = NullL10n) {\n this.overlayName = options.overlayName;\n this.container = options.container;\n this.label = options.label;\n this.input = options.input;\n this.submitButton = options.submitButton;\n this.cancelButton = options.cancelButton;\n this.overlayManager = overlayManager;\n this.l10n = l10n;\n\n this.updateCallback = null;\n this.reason = null;\n\n // Attach the event listeners.\n this.submitButton.addEventListener('click', this.verify.bind(this));\n this.cancelButton.addEventListener('click', this.close.bind(this));\n this.input.addEventListener('keydown', (e) => {\n if (e.keyCode === 13) { // Enter key\n this.verify();\n }\n });\n\n this.overlayManager.register(this.overlayName, this.container,\n this.close.bind(this), true);\n }\n\n open() {\n this.overlayManager.open(this.overlayName).then(() => {\n this.input.focus();\n\n let promptString;\n if (this.reason === PasswordResponses.INCORRECT_PASSWORD) {\n promptString = this.l10n.get('password_invalid', null,\n 'Invalid password. Please try again.');\n } else {\n promptString = this.l10n.get('password_label', null,\n 'Enter the password to open this PDF file.');\n }\n\n promptString.then((msg) => {\n this.label.textContent = msg;\n });\n });\n }\n\n close() {\n this.overlayManager.close(this.overlayName).then(() => {\n this.input.value = '';\n });\n }\n\n verify() {\n let password = this.input.value;\n if (password && password.length > 0) {\n this.close();\n return this.updateCallback(password);\n }\n }\n\n setUpdateCallback(updateCallback, reason) {\n this.updateCallback = updateCallback;\n this.reason = reason;\n }\n}\n\nexport {\n PasswordPrompt,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createObjectURL, createPromiseCapability, getFilenameFromUrl,\n removeNullCharacters\n} from 'pdfjs-lib';\n\n/**\n * @typedef {Object} PDFAttachmentViewerOptions\n * @property {HTMLDivElement} container - The viewer element.\n * @property {EventBus} eventBus - The application event bus.\n * @property {DownloadManager} downloadManager - The download manager.\n */\n\n/**\n * @typedef {Object} PDFAttachmentViewerRenderParameters\n * @property {Object|null} attachments - A lookup table of attachment objects.\n */\n\nclass PDFAttachmentViewer {\n /**\n * @param {PDFAttachmentViewerOptions} options\n */\n constructor({ container, eventBus, downloadManager, }) {\n this.container = container;\n this.eventBus = eventBus;\n this.downloadManager = downloadManager;\n\n this.reset();\n\n this.eventBus.on('fileattachmentannotation',\n this._appendAttachment.bind(this));\n }\n\n reset(keepRenderedCapability = false) {\n this.attachments = null;\n\n // Remove the attachments from the DOM.\n this.container.textContent = '';\n\n if (!keepRenderedCapability) {\n // NOTE: The *only* situation in which the `_renderedCapability` should\n // not be replaced is when appending file attachment annotations.\n this._renderedCapability = createPromiseCapability();\n }\n }\n\n /**\n * @private\n */\n _dispatchEvent(attachmentsCount) {\n this._renderedCapability.resolve();\n\n this.eventBus.dispatch('attachmentsloaded', {\n source: this,\n attachmentsCount,\n });\n }\n\n /**\n * @private\n */\n _bindPdfLink(button, content, filename) {\n if (this.downloadManager.disableCreateObjectURL) {\n throw new Error(\n 'bindPdfLink: Unsupported \"disableCreateObjectURL\" value.');\n }\n let blobUrl;\n button.onclick = function() {\n if (!blobUrl) {\n blobUrl = createObjectURL(content, 'application/pdf');\n }\n let viewerUrl;\n if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n // The current URL is the viewer, let's use it and append the file.\n viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);\n } else if (PDFJSDev.test('CHROME')) {\n // In the Chrome extension, the URL is rewritten using the history API\n // in viewer.js, so an absolute URL must be generated.\n // eslint-disable-next-line no-undef\n viewerUrl = chrome.runtime.getURL('/content/web/viewer.html') +\n '?file=' + encodeURIComponent(blobUrl + '#' + filename);\n } else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n // Let Firefox's content handler catch the URL and display the PDF.\n viewerUrl = blobUrl + '?' + encodeURIComponent(filename);\n }\n window.open(viewerUrl);\n return false;\n };\n }\n\n /**\n * @private\n */\n _bindLink(button, content, filename) {\n button.onclick = () => {\n this.downloadManager.downloadData(content, filename, '');\n return false;\n };\n }\n\n /**\n * @param {PDFAttachmentViewerRenderParameters} params\n */\n render({ attachments, keepRenderedCapability = false, }) {\n let attachmentsCount = 0;\n\n if (this.attachments) {\n this.reset(keepRenderedCapability === true);\n }\n this.attachments = attachments || null;\n\n if (!attachments) {\n this._dispatchEvent(attachmentsCount);\n return;\n }\n\n let names = Object.keys(attachments).sort(function(a, b) {\n return a.toLowerCase().localeCompare(b.toLowerCase());\n });\n attachmentsCount = names.length;\n\n for (let i = 0; i < attachmentsCount; i++) {\n let item = attachments[names[i]];\n let filename = removeNullCharacters(getFilenameFromUrl(item.filename));\n\n let div = document.createElement('div');\n div.className = 'attachmentsItem';\n let button = document.createElement('button');\n button.textContent = filename;\n if (/\\.pdf$/i.test(filename) &&\n !this.downloadManager.disableCreateObjectURL) {\n this._bindPdfLink(button, item.content, filename);\n } else {\n this._bindLink(button, item.content, filename);\n }\n\n div.appendChild(button);\n this.container.appendChild(div);\n }\n\n this._dispatchEvent(attachmentsCount);\n }\n\n /**\n * Used to append FileAttachment annotations to the sidebar.\n * @private\n */\n _appendAttachment({ id, filename, content, }) {\n this._renderedCapability.promise.then(() => {\n let attachments = this.attachments;\n\n if (!attachments) {\n attachments = Object.create(null);\n } else {\n for (let name in attachments) {\n if (id === name) {\n return; // Ignore the new attachment if it already exists.\n }\n }\n }\n attachments[id] = {\n filename,\n content,\n };\n this.render({\n attachments,\n keepRenderedCapability: true,\n });\n });\n }\n}\n\nexport {\n PDFAttachmentViewer,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation, NullL10n\n} from './ui_utils';\nimport { createPromiseCapability } from 'pdfjs-lib';\n\nconst DEFAULT_FIELD_CONTENT = '-';\n\n// See https://en.wikibooks.org/wiki/Lentis/Conversion_to_the_Metric_Standard_in_the_United_States\nconst NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];\n\n// Should use the format: `width x height`, in portrait orientation.\n// See https://en.wikipedia.org/wiki/Paper_size\nconst US_PAGE_NAMES = {\n '8.5x11': 'Letter',\n '8.5x14': 'Legal',\n};\nconst METRIC_PAGE_NAMES = {\n '297x420': 'A3',\n '210x297': 'A4',\n};\n\nfunction getPageName(size, isPortrait, pageNames) {\n const width = (isPortrait ? size.width : size.height);\n const height = (isPortrait ? size.height : size.width);\n\n return pageNames[`${width}x${height}`];\n}\n\n/**\n * @typedef {Object} PDFDocumentPropertiesOptions\n * @property {string} overlayName - Name/identifier for the overlay.\n * @property {Object} fields - Names and elements of the overlay's fields.\n * @property {HTMLDivElement} container - Div container for the overlay.\n * @property {HTMLButtonElement} closeButton - Button for closing the overlay.\n */\n\nclass PDFDocumentProperties {\n /**\n * @param {PDFDocumentPropertiesOptions} options\n * @param {OverlayManager} overlayManager - Manager for the viewer overlays.\n * @param {EventBus} eventBus - The application event bus.\n * @param {IL10n} l10n - Localization service.\n */\n constructor({ overlayName, fields, container, closeButton, },\n overlayManager, eventBus, l10n = NullL10n) {\n this.overlayName = overlayName;\n this.fields = fields;\n this.container = container;\n this.overlayManager = overlayManager;\n this.l10n = l10n;\n\n this._reset();\n\n if (closeButton) { // Bind the event listener for the Close button.\n closeButton.addEventListener('click', this.close.bind(this));\n }\n this.overlayManager.register(this.overlayName, this.container,\n this.close.bind(this));\n\n if (eventBus) {\n eventBus.on('pagechanging', (evt) => {\n this._currentPageNumber = evt.pageNumber;\n });\n eventBus.on('rotationchanging', (evt) => {\n this._pagesRotation = evt.pagesRotation;\n });\n }\n\n this._isNonMetricLocale = true; // The default viewer locale is 'en-us'.\n l10n.getLanguage().then((locale) => {\n this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);\n });\n }\n\n /**\n * Open the document properties overlay.\n */\n open() {\n let freezeFieldData = (data) => {\n Object.defineProperty(this, 'fieldData', {\n value: Object.freeze(data),\n writable: false,\n enumerable: true,\n configurable: true,\n });\n };\n\n Promise.all([this.overlayManager.open(this.overlayName),\n this._dataAvailableCapability.promise]).then(() => {\n const currentPageNumber = this._currentPageNumber;\n const pagesRotation = this._pagesRotation;\n\n // If the document properties were previously fetched (for this PDF file),\n // just update the dialog immediately to avoid redundant lookups.\n if (this.fieldData &&\n currentPageNumber === this.fieldData['_currentPageNumber'] &&\n pagesRotation === this.fieldData['_pagesRotation']) {\n this._updateUI();\n return;\n }\n\n // Get the document properties.\n this.pdfDocument.getMetadata().then(\n ({ info, metadata, contentDispositionFilename, }) => {\n return Promise.all([\n info,\n metadata,\n contentDispositionFilename || getPDFFileNameFromURL(this.url || ''),\n this._parseFileSize(this.maybeFileSize),\n this._parseDate(info.CreationDate),\n this._parseDate(info.ModDate),\n this.pdfDocument.getPage(currentPageNumber).then((pdfPage) => {\n return this._parsePageSize(getPageSizeInches(pdfPage),\n pagesRotation);\n }),\n this._parseLinearization(info.IsLinearized),\n ]);\n }).then(([info, metadata, fileName, fileSize, creationDate, modDate,\n pageSize, isLinearized]) => {\n freezeFieldData({\n 'fileName': fileName,\n 'fileSize': fileSize,\n 'title': info.Title,\n 'author': info.Author,\n 'subject': info.Subject,\n 'keywords': info.Keywords,\n 'creationDate': creationDate,\n 'modificationDate': modDate,\n 'creator': info.Creator,\n 'producer': info.Producer,\n 'version': info.PDFFormatVersion,\n 'pageCount': this.pdfDocument.numPages,\n 'pageSize': pageSize,\n 'linearized': isLinearized,\n '_currentPageNumber': currentPageNumber,\n '_pagesRotation': pagesRotation,\n });\n this._updateUI();\n\n // Get the correct fileSize, since it may not have been set (if\n // `this.setFileSize` wasn't called) or may be incorrectly set.\n return this.pdfDocument.getDownloadInfo();\n }).then(({ length, }) => {\n this.maybeFileSize = length;\n return this._parseFileSize(length);\n }).then((fileSize) => {\n if (fileSize === this.fieldData['fileSize']) {\n return; // The fileSize has already been correctly set.\n }\n let data = Object.assign(Object.create(null), this.fieldData);\n data['fileSize'] = fileSize;\n\n freezeFieldData(data);\n this._updateUI();\n });\n });\n }\n\n /**\n * Close the document properties overlay.\n */\n close() {\n this.overlayManager.close(this.overlayName);\n }\n\n /**\n * Set a reference to the PDF document and the URL in order\n * to populate the overlay fields with the document properties.\n * Note that the overlay will contain no information if this method\n * is not called.\n *\n * @param {PDFDocumentProxy} pdfDocument - A reference to the PDF document.\n * @param {string} url - The URL of the document.\n */\n setDocument(pdfDocument, url = null) {\n if (this.pdfDocument) {\n this._reset();\n this._updateUI(true);\n }\n if (!pdfDocument) {\n return;\n }\n this.pdfDocument = pdfDocument;\n this.url = url;\n\n this._dataAvailableCapability.resolve();\n }\n\n /**\n * Set the file size of the PDF document. This method is used to\n * update the file size in the document properties overlay once it\n * is known so we do not have to wait until the entire file is loaded.\n *\n * @param {number} fileSize - The file size of the PDF document.\n */\n setFileSize(fileSize) {\n if (Number.isInteger(fileSize) && fileSize > 0) {\n this.maybeFileSize = fileSize;\n }\n }\n\n /**\n * @private\n */\n _reset() {\n this.pdfDocument = null;\n this.url = null;\n\n this.maybeFileSize = 0;\n delete this.fieldData;\n this._dataAvailableCapability = createPromiseCapability();\n this._currentPageNumber = 1;\n this._pagesRotation = 0;\n }\n\n /**\n * Always updates all of the dialog fields, to prevent inconsistent UI state.\n * NOTE: If the contents of a particular field is neither a non-empty string,\n * nor a number, it will fall back to `DEFAULT_FIELD_CONTENT`.\n * @private\n */\n _updateUI(reset = false) {\n if (reset || !this.fieldData) {\n for (let id in this.fields) {\n this.fields[id].textContent = DEFAULT_FIELD_CONTENT;\n }\n return;\n }\n if (this.overlayManager.active !== this.overlayName) {\n // Don't bother updating the dialog if has already been closed,\n // since it will be updated the next time `this.open` is called.\n return;\n }\n for (let id in this.fields) {\n let content = this.fieldData[id];\n this.fields[id].textContent = (content || content === 0) ?\n content : DEFAULT_FIELD_CONTENT;\n }\n }\n\n /**\n * @private\n */\n _parseFileSize(fileSize = 0) {\n let kb = fileSize / 1024;\n if (!kb) {\n return Promise.resolve(undefined);\n } else if (kb < 1024) {\n return this.l10n.get('document_properties_kb', {\n size_kb: (+kb.toPrecision(3)).toLocaleString(),\n size_b: fileSize.toLocaleString(),\n }, '{{size_kb}} KB ({{size_b}} bytes)');\n }\n return this.l10n.get('document_properties_mb', {\n size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),\n size_b: fileSize.toLocaleString(),\n }, '{{size_mb}} MB ({{size_b}} bytes)');\n }\n\n /**\n * @private\n */\n _parsePageSize(pageSizeInches, pagesRotation) {\n if (!pageSizeInches) {\n return Promise.resolve(undefined);\n }\n // Take the viewer rotation into account as well; compare with Adobe Reader.\n if (pagesRotation % 180 !== 0) {\n pageSizeInches = {\n width: pageSizeInches.height,\n height: pageSizeInches.width,\n };\n }\n const isPortrait = isPortraitOrientation(pageSizeInches);\n\n let sizeInches = {\n width: Math.round(pageSizeInches.width * 100) / 100,\n height: Math.round(pageSizeInches.height * 100) / 100,\n };\n // 1in == 25.4mm; no need to round to 2 decimals for millimeters.\n let sizeMillimeters = {\n width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,\n height: Math.round(pageSizeInches.height * 25.4 * 10) / 10,\n };\n\n let pageName = null;\n let name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) ||\n getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);\n\n if (!name && !(Number.isInteger(sizeMillimeters.width) &&\n Number.isInteger(sizeMillimeters.height))) {\n // Attempt to improve the page name detection by falling back to fuzzy\n // matching of the metric dimensions, to account for e.g. rounding errors\n // and/or PDF files that define the page sizes in an imprecise manner.\n const exactMillimeters = {\n width: pageSizeInches.width * 25.4,\n height: pageSizeInches.height * 25.4,\n };\n const intMillimeters = {\n width: Math.round(sizeMillimeters.width),\n height: Math.round(sizeMillimeters.height),\n };\n\n // Try to avoid false positives, by only considering \"small\" differences.\n if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 &&\n Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {\n\n name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);\n if (name) {\n // Update *both* sizes, computed above, to ensure that the displayed\n // dimensions always correspond to the detected page name.\n sizeInches = {\n width: Math.round(intMillimeters.width / 25.4 * 100) / 100,\n height: Math.round(intMillimeters.height / 25.4 * 100) / 100,\n };\n sizeMillimeters = intMillimeters;\n }\n }\n }\n if (name) {\n pageName = this.l10n.get('document_properties_page_size_name_' +\n name.toLowerCase(), null, name);\n }\n\n return Promise.all([\n (this._isNonMetricLocale ? sizeInches : sizeMillimeters),\n this.l10n.get('document_properties_page_size_unit_' +\n (this._isNonMetricLocale ? 'inches' : 'millimeters'), null,\n this._isNonMetricLocale ? 'in' : 'mm'),\n pageName,\n this.l10n.get('document_properties_page_size_orientation_' +\n (isPortrait ? 'portrait' : 'landscape'), null,\n isPortrait ? 'portrait' : 'landscape'),\n ]).then(([{ width, height, }, unit, name, orientation]) => {\n return this.l10n.get('document_properties_page_size_dimension_' +\n (name ? 'name_' : '') + 'string', {\n width: width.toLocaleString(),\n height: height.toLocaleString(),\n unit,\n name,\n orientation,\n }, '{{width}} × {{height}} {{unit}} (' +\n (name ? '{{name}}, ' : '') + '{{orientation}})');\n });\n }\n\n /**\n * @private\n */\n _parseDate(inputDate) {\n if (!inputDate) {\n return;\n }\n // This is implemented according to the PDF specification, but note that\n // Adobe Reader doesn't handle changing the date to universal time\n // and doesn't use the user's time zone (they're effectively ignoring\n // the HH' and mm' parts of the date string).\n let dateToParse = inputDate;\n\n // Remove the D: prefix if it is available.\n if (dateToParse.substring(0, 2) === 'D:') {\n dateToParse = dateToParse.substring(2);\n }\n\n // Get all elements from the PDF date string.\n // JavaScript's `Date` object expects the month to be between\n // 0 and 11 instead of 1 and 12, so we're correcting for this.\n let year = parseInt(dateToParse.substring(0, 4), 10);\n let month = parseInt(dateToParse.substring(4, 6), 10) - 1;\n let day = parseInt(dateToParse.substring(6, 8), 10);\n let hours = parseInt(dateToParse.substring(8, 10), 10);\n let minutes = parseInt(dateToParse.substring(10, 12), 10);\n let seconds = parseInt(dateToParse.substring(12, 14), 10);\n let utRel = dateToParse.substring(14, 15);\n let offsetHours = parseInt(dateToParse.substring(15, 17), 10);\n let offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);\n\n // As per spec, utRel = 'Z' means equal to universal time.\n // The other cases ('-' and '+') have to be handled here.\n if (utRel === '-') {\n hours += offsetHours;\n minutes += offsetMinutes;\n } else if (utRel === '+') {\n hours -= offsetHours;\n minutes -= offsetMinutes;\n }\n\n // Return the new date format from the user's locale.\n let date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));\n let dateString = date.toLocaleDateString();\n let timeString = date.toLocaleTimeString();\n return this.l10n.get('document_properties_date_string',\n { date: dateString, time: timeString, },\n '{{date}}, {{time}}');\n }\n\n /**\n * @private\n */\n _parseLinearization(isLinearized) {\n return this.l10n.get('document_properties_linearized_' +\n (isLinearized ? 'yes' : 'no'), null,\n (isLinearized ? 'Yes' : 'No'));\n }\n}\n\nexport {\n PDFDocumentProperties,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getGlobalEventBus, NullL10n } from './ui_utils';\nimport { FindState } from './pdf_find_controller';\n\nconst MATCHES_COUNT_LIMIT = 1000;\n\n/**\n * Creates a \"search bar\" given a set of DOM elements that act as controls\n * for searching or for setting search preferences in the UI. This object\n * also sets up the appropriate events for the controls. Actual searching\n * is done by PDFFindController.\n */\nclass PDFFindBar {\n constructor(options, eventBus = getGlobalEventBus(), l10n = NullL10n) {\n this.opened = false;\n\n this.bar = options.bar || null;\n this.toggleButton = options.toggleButton || null;\n this.findField = options.findField || null;\n this.highlightAll = options.highlightAllCheckbox || null;\n this.caseSensitive = options.caseSensitiveCheckbox || null;\n this.entireWord = options.entireWordCheckbox || null;\n this.findMsg = options.findMsg || null;\n this.findResultsCount = options.findResultsCount || null;\n this.findPreviousButton = options.findPreviousButton || null;\n this.findNextButton = options.findNextButton || null;\n this.eventBus = eventBus;\n this.l10n = l10n;\n\n // Add event listeners to the DOM elements.\n this.toggleButton.addEventListener('click', () => {\n this.toggle();\n });\n\n this.findField.addEventListener('input', () => {\n this.dispatchEvent('');\n });\n\n this.bar.addEventListener('keydown', (e) => {\n switch (e.keyCode) {\n case 13: // Enter\n if (e.target === this.findField) {\n this.dispatchEvent('again', e.shiftKey);\n }\n break;\n case 27: // Escape\n this.close();\n break;\n }\n });\n\n this.findPreviousButton.addEventListener('click', () => {\n this.dispatchEvent('again', true);\n });\n\n this.findNextButton.addEventListener('click', () => {\n this.dispatchEvent('again', false);\n });\n\n this.highlightAll.addEventListener('click', () => {\n this.dispatchEvent('highlightallchange');\n });\n\n this.caseSensitive.addEventListener('click', () => {\n this.dispatchEvent('casesensitivitychange');\n });\n\n this.entireWord.addEventListener('click', () => {\n this.dispatchEvent('entirewordchange');\n });\n\n this.eventBus.on('resize', this._adjustWidth.bind(this));\n }\n\n reset() {\n this.updateUIState();\n }\n\n dispatchEvent(type, findPrev) {\n this.eventBus.dispatch('find', {\n source: this,\n type,\n query: this.findField.value,\n phraseSearch: true,\n caseSensitive: this.caseSensitive.checked,\n entireWord: this.entireWord.checked,\n highlightAll: this.highlightAll.checked,\n findPrevious: findPrev,\n });\n }\n\n updateUIState(state, previous, matchesCount) {\n let notFound = false;\n let findMsg = '';\n let status = '';\n\n switch (state) {\n case FindState.FOUND:\n break;\n\n case FindState.PENDING:\n status = 'pending';\n break;\n\n case FindState.NOT_FOUND:\n findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');\n notFound = true;\n break;\n\n case FindState.WRAPPED:\n if (previous) {\n findMsg = this.l10n.get('find_reached_top', null,\n 'Reached top of document, continued from bottom');\n } else {\n findMsg = this.l10n.get('find_reached_bottom', null,\n 'Reached end of document, continued from top');\n }\n break;\n }\n\n this.findField.classList.toggle('notFound', notFound);\n this.findField.setAttribute('data-status', status);\n\n Promise.resolve(findMsg).then((msg) => {\n this.findMsg.textContent = msg;\n this._adjustWidth();\n });\n\n this.updateResultsCount(matchesCount);\n }\n\n updateResultsCount({ current = 0, total = 0, } = {}) {\n if (!this.findResultsCount) {\n return; // No UI control is provided.\n }\n let matchesCountMsg = '', limit = MATCHES_COUNT_LIMIT;\n\n if (total > 0) {\n if (total > limit) {\n if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {\n // TODO: Remove this hard-coded `[other]` form once plural support has\n // been implemented in the mozilla-central specific `l10n.js` file.\n matchesCountMsg = this.l10n.get('find_match_count_limit[other]', {\n limit,\n }, 'More than {{limit}} matches');\n } else {\n matchesCountMsg = this.l10n.get('find_match_count_limit', {\n limit,\n }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));\n }\n } else {\n if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {\n // TODO: Remove this hard-coded `[other]` form once plural support has\n // been implemented in the mozilla-central specific `l10n.js` file.\n matchesCountMsg = this.l10n.get('find_match_count[other]', {\n current,\n total,\n }, '{{current}} of {{total}} matches');\n } else {\n matchesCountMsg = this.l10n.get('find_match_count', {\n current,\n total,\n }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));\n }\n }\n }\n Promise.resolve(matchesCountMsg).then((msg) => {\n this.findResultsCount.textContent = msg;\n this.findResultsCount.classList[!total ? 'add' : 'remove']('hidden');\n // Since `updateResultsCount` may be called from `PDFFindController`,\n // ensure that the width of the findbar is always updated correctly.\n this._adjustWidth();\n });\n }\n\n open() {\n if (!this.opened) {\n this.opened = true;\n this.toggleButton.classList.add('toggled');\n this.bar.classList.remove('hidden');\n }\n this.findField.select();\n this.findField.focus();\n\n this._adjustWidth();\n }\n\n close() {\n if (!this.opened) {\n return;\n }\n this.opened = false;\n this.toggleButton.classList.remove('toggled');\n this.bar.classList.add('hidden');\n\n this.eventBus.dispatch('findbarclose', { source: this, });\n }\n\n toggle() {\n if (this.opened) {\n this.close();\n } else {\n this.open();\n }\n }\n\n /**\n * @private\n */\n _adjustWidth() {\n if (!this.opened) {\n return;\n }\n\n // The find bar has an absolute position and thus the browser extends\n // its width to the maximum possible width once the find bar does not fit\n // entirely within the window anymore (and its elements are automatically\n // wrapped). Here we detect and fix that.\n this.bar.classList.remove('wrapContainers');\n\n let findbarHeight = this.bar.clientHeight;\n let inputContainerHeight = this.bar.firstElementChild.clientHeight;\n\n if (findbarHeight > inputContainerHeight) {\n // The findbar is taller than the input container, which means that\n // the browser wrapped some of the elements. For a consistent look,\n // wrap all of them to adjust the width of the find bar.\n this.bar.classList.add('wrapContainers');\n }\n }\n}\n\nexport {\n PDFFindBar,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createPromiseCapability } from 'pdfjs-lib';\nimport { getCharacterType } from './pdf_find_utils';\nimport { getGlobalEventBus } from './dom_events';\n\nconst FindState = {\n FOUND: 0,\n NOT_FOUND: 1,\n WRAPPED: 2,\n PENDING: 3,\n};\n\nconst FIND_TIMEOUT = 250; // ms\n\nconst CHARACTERS_TO_NORMALIZE = {\n '\\u2018': '\\'', // Left single quotation mark\n '\\u2019': '\\'', // Right single quotation mark\n '\\u201A': '\\'', // Single low-9 quotation mark\n '\\u201B': '\\'', // Single high-reversed-9 quotation mark\n '\\u201C': '\"', // Left double quotation mark\n '\\u201D': '\"', // Right double quotation mark\n '\\u201E': '\"', // Double low-9 quotation mark\n '\\u201F': '\"', // Double high-reversed-9 quotation mark\n '\\u00BC': '1/4', // Vulgar fraction one quarter\n '\\u00BD': '1/2', // Vulgar fraction one half\n '\\u00BE': '3/4', // Vulgar fraction three quarters\n};\n\n/**\n * @typedef {Object} PDFFindControllerOptions\n * @property {IPDFLinkService} linkService - The navigation/linking service.\n * @property {EventBus} eventBus - The application event bus.\n */\n\n/**\n * Provides search functionality to find a given string in a PDF document.\n */\nclass PDFFindController {\n /**\n * @param {PDFFindControllerOptions} options\n */\n constructor({ linkService, eventBus = getGlobalEventBus(), }) {\n this._linkService = linkService;\n this._eventBus = eventBus;\n\n this._reset();\n eventBus.on('findbarclose', this._onFindBarClose.bind(this));\n\n // Compile the regular expression for text normalization once.\n const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');\n this._normalizationRegex = new RegExp(`[${replace}]`, 'g');\n }\n\n get highlightMatches() {\n return this._highlightMatches;\n }\n\n get pageMatches() {\n return this._pageMatches;\n }\n\n get pageMatchesLength() {\n return this._pageMatchesLength;\n }\n\n get selected() {\n return this._selected;\n }\n\n get state() {\n return this._state;\n }\n\n /**\n * Set a reference to the PDF document in order to search it.\n * Note that searching is not possible if this method is not called.\n *\n * @param {PDFDocumentProxy} pdfDocument - The PDF document to search.\n */\n setDocument(pdfDocument) {\n if (this._pdfDocument) {\n this._reset();\n }\n if (!pdfDocument) {\n return;\n }\n this._pdfDocument = pdfDocument;\n this._firstPageCapability.resolve();\n }\n\n executeCommand(cmd, state) {\n const pdfDocument = this._pdfDocument;\n\n if (this._state === null || cmd !== 'findagain') {\n this._dirtyMatch = true;\n }\n this._state = state;\n this._updateUIState(FindState.PENDING);\n\n this._firstPageCapability.promise.then(() => {\n if (!this._pdfDocument ||\n (pdfDocument && this._pdfDocument !== pdfDocument)) {\n // If the document was closed before searching began, or if the search\n // operation was relevant for a previously opened document, do nothing.\n return;\n }\n this._extractText();\n\n if (this._findTimeout) {\n clearTimeout(this._findTimeout);\n this._findTimeout = null;\n }\n if (cmd === 'find') {\n // Trigger the find action with a small delay to avoid starting the\n // search when the user is still typing (saving resources).\n this._findTimeout = setTimeout(() => {\n this._nextMatch();\n this._findTimeout = null;\n }, FIND_TIMEOUT);\n } else {\n this._nextMatch();\n }\n });\n }\n\n _reset() {\n this._highlightMatches = false;\n this._pdfDocument = null;\n this._pageMatches = [];\n this._pageMatchesLength = null;\n this._state = null;\n this._selected = { // Currently selected match.\n pageIdx: -1,\n matchIdx: -1,\n };\n this._offset = { // Where the find algorithm currently is in the document.\n pageIdx: null,\n matchIdx: null,\n };\n this._extractTextPromises = [];\n this._pageContents = []; // Stores the text for each page.\n this._matchesCountTotal = 0;\n this._pagesToSearch = null;\n this._pendingFindMatches = Object.create(null);\n this._resumePageIdx = null;\n this._dirtyMatch = false;\n clearTimeout(this._findTimeout);\n this._findTimeout = null;\n\n this._firstPageCapability = createPromiseCapability();\n }\n\n _normalize(text) {\n return text.replace(this._normalizationRegex, function(ch) {\n return CHARACTERS_TO_NORMALIZE[ch];\n });\n }\n\n /**\n * Helper for multi-term search that fills the `matchesWithLength` array\n * and handles cases where one search term includes another search term (for\n * example, \"tamed tame\" or \"this is\"). It looks for intersecting terms in\n * the `matches` and keeps elements with a longer match length.\n */\n _prepareMatches(matchesWithLength, matches, matchesLength) {\n function isSubTerm(matchesWithLength, currentIndex) {\n const currentElem = matchesWithLength[currentIndex];\n const nextElem = matchesWithLength[currentIndex + 1];\n\n // Check for cases like \"TAMEd TAME\".\n if (currentIndex < matchesWithLength.length - 1 &&\n currentElem.match === nextElem.match) {\n currentElem.skipped = true;\n return true;\n }\n\n // Check for cases like \"thIS IS\".\n for (let i = currentIndex - 1; i >= 0; i--) {\n const prevElem = matchesWithLength[i];\n if (prevElem.skipped) {\n continue;\n }\n if (prevElem.match + prevElem.matchLength < currentElem.match) {\n break;\n }\n if (prevElem.match + prevElem.matchLength >=\n currentElem.match + currentElem.matchLength) {\n currentElem.skipped = true;\n return true;\n }\n }\n return false;\n }\n\n // Sort the array of `{ match: <match>, matchLength: <matchLength> }`\n // objects on increasing index first and on the length otherwise.\n matchesWithLength.sort(function(a, b) {\n return a.match === b.match ? a.matchLength - b.matchLength :\n a.match - b.match;\n });\n for (let i = 0, len = matchesWithLength.length; i < len; i++) {\n if (isSubTerm(matchesWithLength, i)) {\n continue;\n }\n matches.push(matchesWithLength[i].match);\n matchesLength.push(matchesWithLength[i].matchLength);\n }\n }\n\n /**\n * Determine if the search query constitutes a \"whole word\", by comparing the\n * first/last character type with the preceding/following character type.\n */\n _isEntireWord(content, startIdx, length) {\n if (startIdx > 0) {\n const first = content.charCodeAt(startIdx);\n const limit = content.charCodeAt(startIdx - 1);\n if (getCharacterType(first) === getCharacterType(limit)) {\n return false;\n }\n }\n const endIdx = (startIdx + length - 1);\n if (endIdx < (content.length - 1)) {\n const last = content.charCodeAt(endIdx);\n const limit = content.charCodeAt(endIdx + 1);\n if (getCharacterType(last) === getCharacterType(limit)) {\n return false;\n }\n }\n return true;\n }\n\n _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {\n const matches = [];\n const queryLen = query.length;\n\n let matchIdx = -queryLen;\n while (true) {\n matchIdx = pageContent.indexOf(query, matchIdx + queryLen);\n if (matchIdx === -1) {\n break;\n }\n if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {\n continue;\n }\n matches.push(matchIdx);\n }\n this._pageMatches[pageIndex] = matches;\n }\n\n _calculateWordMatch(query, pageIndex, pageContent, entireWord) {\n const matchesWithLength = [];\n\n // Divide the query into pieces and search for text in each piece.\n const queryArray = query.match(/\\S+/g);\n for (let i = 0, len = queryArray.length; i < len; i++) {\n const subquery = queryArray[i];\n const subqueryLen = subquery.length;\n\n let matchIdx = -subqueryLen;\n while (true) {\n matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);\n if (matchIdx === -1) {\n break;\n }\n if (entireWord &&\n !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {\n continue;\n }\n // Other searches do not, so we store the length.\n matchesWithLength.push({\n match: matchIdx,\n matchLength: subqueryLen,\n skipped: false,\n });\n }\n }\n\n // Prepare arrays for storing the matches.\n if (!this._pageMatchesLength) {\n this._pageMatchesLength = [];\n }\n this._pageMatchesLength[pageIndex] = [];\n this._pageMatches[pageIndex] = [];\n\n // Sort `matchesWithLength`, remove intersecting terms and put the result\n // into the two arrays.\n this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex],\n this._pageMatchesLength[pageIndex]);\n }\n\n _calculateMatch(pageIndex) {\n let pageContent = this._normalize(this._pageContents[pageIndex]);\n let query = this._normalize(this._state.query);\n const { caseSensitive, entireWord, phraseSearch, } = this._state;\n\n if (query.length === 0) {\n // Do nothing: the matches should be wiped out already.\n return;\n }\n\n if (!caseSensitive) {\n pageContent = pageContent.toLowerCase();\n query = query.toLowerCase();\n }\n\n if (phraseSearch) {\n this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);\n } else {\n this._calculateWordMatch(query, pageIndex, pageContent, entireWord);\n }\n\n this._updatePage(pageIndex);\n if (this._resumePageIdx === pageIndex) {\n this._resumePageIdx = null;\n this._nextPageMatch();\n }\n\n // Update the match count.\n const pageMatchesCount = this._pageMatches[pageIndex].length;\n if (pageMatchesCount > 0) {\n this._matchesCountTotal += pageMatchesCount;\n this._updateUIResultsCount();\n }\n }\n\n _extractText() {\n // Perform text extraction once if this method is called multiple times.\n if (this._extractTextPromises.length > 0) {\n return;\n }\n\n let promise = Promise.resolve();\n for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {\n const extractTextCapability = createPromiseCapability();\n this._extractTextPromises[i] = extractTextCapability.promise;\n\n promise = promise.then(() => {\n return this._pdfDocument.getPage(i + 1).then((pdfPage) => {\n return pdfPage.getTextContent({\n normalizeWhitespace: true,\n });\n }).then((textContent) => {\n const textItems = textContent.items;\n const strBuf = [];\n\n for (let j = 0, jj = textItems.length; j < jj; j++) {\n strBuf.push(textItems[j].str);\n }\n\n // Store the page content (text items) as one string.\n this._pageContents[i] = strBuf.join('');\n extractTextCapability.resolve(i);\n }, (reason) => {\n console.error(`Unable to get text content for page ${i + 1}`, reason);\n // Page error -- assuming no text content.\n this._pageContents[i] = '';\n extractTextCapability.resolve(i);\n });\n });\n }\n }\n\n _updatePage(index) {\n if (this._selected.pageIdx === index) {\n // If the page is selected, scroll the page into view, which triggers\n // rendering the page, which adds the text layer. Once the text layer\n // is built, it will scroll to the selected match.\n this._linkService.page = index + 1;\n }\n\n this._eventBus.dispatch('updatetextlayermatches', {\n source: this,\n pageIndex: index,\n });\n }\n\n _nextMatch() {\n const previous = this._state.findPrevious;\n const currentPageIndex = this._linkService.page - 1;\n const numPages = this._linkService.pagesCount;\n\n this._highlightMatches = true;\n\n if (this._dirtyMatch) {\n // Need to recalculate the matches, reset everything.\n this._dirtyMatch = false;\n this._selected.pageIdx = this._selected.matchIdx = -1;\n this._offset.pageIdx = currentPageIndex;\n this._offset.matchIdx = null;\n this._resumePageIdx = null;\n this._pageMatches.length = 0;\n this._pageMatchesLength = null;\n this._matchesCountTotal = 0;\n\n for (let i = 0; i < numPages; i++) {\n // Wipe out any previously highlighted matches.\n this._updatePage(i);\n\n // Start finding the matches as soon as the text is extracted.\n if (!(i in this._pendingFindMatches)) {\n this._pendingFindMatches[i] = true;\n this._extractTextPromises[i].then((pageIdx) => {\n delete this._pendingFindMatches[pageIdx];\n this._calculateMatch(pageIdx);\n });\n }\n }\n }\n\n // If there's no query there's no point in searching.\n if (this._state.query === '') {\n this._updateUIState(FindState.FOUND);\n return;\n }\n\n // If we're waiting on a page, we return since we can't do anything else.\n if (this._resumePageIdx) {\n return;\n }\n\n const offset = this._offset;\n // Keep track of how many pages we should maximally iterate through.\n this._pagesToSearch = numPages;\n // If there's already a `matchIdx` that means we are iterating through a\n // page's matches.\n if (offset.matchIdx !== null) {\n const numPageMatches = this._pageMatches[offset.pageIdx].length;\n if ((!previous && offset.matchIdx + 1 < numPageMatches) ||\n (previous && offset.matchIdx > 0)) {\n // The simple case; we just have advance the matchIdx to select\n // the next match on the page.\n offset.matchIdx = (previous ? offset.matchIdx - 1 :\n offset.matchIdx + 1);\n this._updateMatch(/* found = */ true);\n return;\n }\n // We went beyond the current page's matches, so we advance to\n // the next page.\n this._advanceOffsetPage(previous);\n }\n // Start searching through the page.\n this._nextPageMatch();\n }\n\n _matchesReady(matches) {\n const offset = this._offset;\n const numMatches = matches.length;\n const previous = this._state.findPrevious;\n\n if (numMatches) {\n // There were matches for the page, so initialize `matchIdx`.\n offset.matchIdx = (previous ? numMatches - 1 : 0);\n this._updateMatch(/* found = */ true);\n return true;\n }\n // No matches, so attempt to search the next page.\n this._advanceOffsetPage(previous);\n if (offset.wrapped) {\n offset.matchIdx = null;\n if (this._pagesToSearch < 0) {\n // No point in wrapping again, there were no matches.\n this._updateMatch(/* found = */ false);\n // While matches were not found, searching for a page\n // with matches should nevertheless halt.\n return true;\n }\n }\n // Matches were not found (and searching is not done).\n return false;\n }\n\n _nextPageMatch() {\n if (this._resumePageIdx !== null) {\n console.error('There can only be one pending page.');\n }\n\n let matches = null;\n do {\n const pageIdx = this._offset.pageIdx;\n matches = this._pageMatches[pageIdx];\n if (!matches) {\n // The matches don't exist yet for processing by `_matchesReady`,\n // so set a resume point for when they do exist.\n this._resumePageIdx = pageIdx;\n break;\n }\n } while (!this._matchesReady(matches));\n }\n\n _advanceOffsetPage(previous) {\n const offset = this._offset;\n const numPages = this._linkService.pagesCount;\n offset.pageIdx = (previous ? offset.pageIdx - 1 : offset.pageIdx + 1);\n offset.matchIdx = null;\n\n this._pagesToSearch--;\n\n if (offset.pageIdx >= numPages || offset.pageIdx < 0) {\n offset.pageIdx = (previous ? numPages - 1 : 0);\n offset.wrapped = true;\n }\n }\n\n _updateMatch(found = false) {\n let state = FindState.NOT_FOUND;\n const wrapped = this._offset.wrapped;\n this._offset.wrapped = false;\n\n if (found) {\n const previousPage = this._selected.pageIdx;\n this._selected.pageIdx = this._offset.pageIdx;\n this._selected.matchIdx = this._offset.matchIdx;\n state = (wrapped ? FindState.WRAPPED : FindState.FOUND);\n\n // Update the currently selected page to wipe out any selected matches.\n if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {\n this._updatePage(previousPage);\n }\n }\n\n this._updateUIState(state, this._state.findPrevious);\n if (this._selected.pageIdx !== -1) {\n this._updatePage(this._selected.pageIdx);\n }\n }\n\n _onFindBarClose(evt) {\n const pdfDocument = this._pdfDocument;\n // Since searching is asynchronous, ensure that the removal of highlighted\n // matches (from the UI) is async too such that the 'updatetextlayermatches'\n // events will always be dispatched in the expected order.\n this._firstPageCapability.promise.then(() => {\n if (!this._pdfDocument ||\n (pdfDocument && this._pdfDocument !== pdfDocument)) {\n // Only update the UI if the document is open, and is the current one.\n return;\n }\n if (this._findTimeout) {\n clearTimeout(this._findTimeout);\n this._findTimeout = null;\n // Avoid the UI being in a pending state if the findbar is re-opened.\n this._updateUIState(FindState.FOUND);\n }\n this._highlightMatches = false;\n\n this._eventBus.dispatch('updatetextlayermatches', {\n source: this,\n pageIndex: -1,\n });\n });\n }\n\n _requestMatchesCount() {\n const { pageIdx, matchIdx, } = this._selected;\n let current = 0, total = this._matchesCountTotal;\n if (matchIdx !== -1) {\n for (let i = 0; i < pageIdx; i++) {\n current += (this._pageMatches[i] && this._pageMatches[i].length) || 0;\n }\n current += matchIdx + 1;\n }\n // When searching starts, this method may be called before the `pageMatches`\n // have been counted (in `_calculateMatch`). Ensure that the UI won't show\n // temporarily broken state when the active find result doesn't make sense.\n if (current < 1 || current > total) {\n current = total = 0;\n }\n return { current, total, };\n }\n\n _updateUIResultsCount() {\n this._eventBus.dispatch('updatefindmatchescount', {\n source: this,\n matchesCount: this._requestMatchesCount(),\n });\n }\n\n _updateUIState(state, previous) {\n this._eventBus.dispatch('updatefindcontrolstate', {\n source: this,\n state,\n previous,\n matchesCount: this._requestMatchesCount(),\n });\n }\n}\n\nexport {\n FindState,\n PDFFindController,\n};\n","/* Copyright 2018 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst CharacterType = {\n SPACE: 0,\n ALPHA_LETTER: 1,\n PUNCT: 2,\n HAN_LETTER: 3,\n KATAKANA_LETTER: 4,\n HIRAGANA_LETTER: 5,\n HALFWIDTH_KATAKANA_LETTER: 6,\n THAI_LETTER: 7,\n};\n\nfunction isAlphabeticalScript(charCode) {\n return charCode < 0x2E80;\n}\n\nfunction isAscii(charCode) {\n return (charCode & 0xFF80) === 0;\n}\n\nfunction isAsciiAlpha(charCode) {\n return (charCode >= /* a = */ 0x61 && charCode <= /* z = */ 0x7A) ||\n (charCode >= /* A = */ 0x41 && charCode <= /* Z = */ 0x5A);\n}\n\nfunction isAsciiDigit(charCode) {\n return (charCode >= /* 0 = */ 0x30 && charCode <= /* 9 = */ 0x39);\n}\n\nfunction isAsciiSpace(charCode) {\n return (charCode === /* SPACE = */ 0x20 || charCode === /* TAB = */ 0x09 ||\n charCode === /* CR = */ 0x0D || charCode === /* LF = */ 0x0A);\n}\n\nfunction isHan(charCode) {\n return (charCode >= 0x3400 && charCode <= 0x9FFF) ||\n (charCode >= 0xF900 && charCode <= 0xFAFF);\n}\n\nfunction isKatakana(charCode) {\n return (charCode >= 0x30A0 && charCode <= 0x30FF);\n}\n\nfunction isHiragana(charCode) {\n return (charCode >= 0x3040 && charCode <= 0x309F);\n}\n\nfunction isHalfwidthKatakana(charCode) {\n return (charCode >= 0xFF60 && charCode <= 0xFF9F);\n}\n\nfunction isThai(charCode) {\n return (charCode & 0xFF80) === 0x0E00;\n}\n\n/**\n * This function is based on the word-break detection implemented in:\n * https://hg.mozilla.org/mozilla-central/file/tip/intl/lwbrk/WordBreaker.cpp\n */\nfunction getCharacterType(charCode) {\n if (isAlphabeticalScript(charCode)) {\n if (isAscii(charCode)) {\n if (isAsciiSpace(charCode)) {\n return CharacterType.SPACE;\n } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) ||\n charCode === /* UNDERSCORE = */ 0x5F) {\n return CharacterType.ALPHA_LETTER;\n }\n return CharacterType.PUNCT;\n } else if (isThai(charCode)) {\n return CharacterType.THAI_LETTER;\n } else if (charCode === /* NBSP = */ 0xA0) {\n return CharacterType.SPACE;\n }\n return CharacterType.ALPHA_LETTER;\n }\n\n if (isHan(charCode)) {\n return CharacterType.HAN_LETTER;\n } else if (isKatakana(charCode)) {\n return CharacterType.KATAKANA_LETTER;\n } else if (isHiragana(charCode)) {\n return CharacterType.HIRAGANA_LETTER;\n } else if (isHalfwidthKatakana(charCode)) {\n return CharacterType.HALFWIDTH_KATAKANA_LETTER;\n }\n return CharacterType.ALPHA_LETTER;\n}\n\nexport {\n CharacterType,\n getCharacterType,\n};\n","/* Copyright 2017 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n isValidRotation, parseQueryString, waitOnEventOrTimeout\n} from './ui_utils';\nimport { getGlobalEventBus } from './dom_events';\n\n// Heuristic value used when force-resetting `this._blockHashChange`.\nconst HASH_CHANGE_TIMEOUT = 1000; // milliseconds\n// Heuristic value used when adding the current position to the browser history.\nconst POSITION_UPDATED_THRESHOLD = 50;\n// Heuristic value used when adding a temporary position to the browser history.\nconst UPDATE_VIEWAREA_TIMEOUT = 1000; // milliseconds\n\n/**\n * @typedef {Object} PDFHistoryOptions\n * @property {IPDFLinkService} linkService - The navigation/linking service.\n * @property {EventBus} eventBus - The application event bus.\n */\n\n/**\n * @typedef {Object} PushParameters\n * @property {string} namedDest - (optional) The named destination. If absent,\n * a stringified version of `explicitDest` is used.\n * @property {Array} explicitDest - The explicit destination array.\n * @property {number} pageNumber - The page to which the destination points.\n */\n\nfunction getCurrentHash() {\n return document.location.hash;\n}\n\nfunction parseCurrentHash(linkService) {\n let hash = unescape(getCurrentHash()).substring(1);\n let params = parseQueryString(hash);\n\n let page = params.page | 0;\n if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {\n page = null;\n }\n return { hash, page, rotation: linkService.rotation, };\n}\n\nclass PDFHistory {\n /**\n * @param {PDFHistoryOptions} options\n */\n constructor({ linkService, eventBus, }) {\n this.linkService = linkService;\n this.eventBus = eventBus || getGlobalEventBus();\n\n this.initialized = false;\n this.initialBookmark = null;\n this.initialRotation = null;\n\n this._boundEvents = Object.create(null);\n this._isViewerInPresentationMode = false;\n this._isPagesLoaded = false;\n\n // Ensure that we don't miss either a 'presentationmodechanged' or a\n // 'pagesloaded' event, by registering the listeners immediately.\n this.eventBus.on('presentationmodechanged', (evt) => {\n this._isViewerInPresentationMode = evt.active || evt.switchInProgress;\n });\n this.eventBus.on('pagesloaded', (evt) => {\n this._isPagesLoaded = !!evt.pagesCount;\n });\n }\n\n /**\n * Initialize the history for the PDF document, using either the current\n * browser history entry or the document hash, whichever is present.\n * @param {string} fingerprint - The PDF document's unique fingerprint.\n * @param {boolean} resetHistory - (optional) Reset the browsing history.\n */\n initialize(fingerprint, resetHistory = false) {\n if (!fingerprint || typeof fingerprint !== 'string') {\n console.error(\n 'PDFHistory.initialize: The \"fingerprint\" must be a non-empty string.');\n return;\n }\n let reInitialized = this.initialized && this.fingerprint !== fingerprint;\n this.fingerprint = fingerprint;\n\n if (!this.initialized) {\n this._bindEvents();\n }\n let state = window.history.state;\n\n this.initialized = true;\n this.initialBookmark = null;\n this.initialRotation = null;\n\n this._popStateInProgress = false;\n this._blockHashChange = 0;\n this._currentHash = getCurrentHash();\n this._numPositionUpdates = 0;\n\n this._uid = this._maxUid = 0;\n this._destination = null;\n this._position = null;\n\n if (!this._isValidState(state) || resetHistory) {\n let { hash, page, rotation, } = parseCurrentHash(this.linkService);\n\n if (!hash || reInitialized || resetHistory) {\n // Ensure that the browser history is reset on PDF document load.\n this._pushOrReplaceState(null, /* forceReplace = */ true);\n return;\n }\n // Ensure that the browser history is initialized correctly when\n // the document hash is present on PDF document load.\n this._pushOrReplaceState({ hash, page, rotation, },\n /* forceReplace = */ true);\n return;\n }\n\n // The browser history contains a valid entry, ensure that the history is\n // initialized correctly on PDF document load.\n let destination = state.destination;\n this._updateInternalState(destination, state.uid,\n /* removeTemporary = */ true);\n if (this._uid > this._maxUid) {\n this._maxUid = this._uid;\n }\n\n if (destination.rotation !== undefined) {\n this.initialRotation = destination.rotation;\n }\n if (destination.dest) {\n this.initialBookmark = JSON.stringify(destination.dest);\n\n // If the history is updated, e.g. through the user changing the hash,\n // before the initial destination has become visible, then we do *not*\n // want to potentially add `this._position` to the browser history.\n this._destination.page = null;\n } else if (destination.hash) {\n this.initialBookmark = destination.hash;\n } else if (destination.page) {\n // Fallback case; shouldn't be necessary, but better safe than sorry.\n this.initialBookmark = `page=${destination.page}`;\n }\n }\n\n /**\n * Push an internal destination to the browser history.\n * @param {PushParameters}\n */\n push({ namedDest, explicitDest, pageNumber, }) {\n if (!this.initialized) {\n return;\n }\n if ((namedDest && typeof namedDest !== 'string') ||\n !Array.isArray(explicitDest) ||\n !(Number.isInteger(pageNumber) &&\n pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {\n console.error('PDFHistory.push: Invalid parameters.');\n return;\n }\n\n let hash = namedDest || JSON.stringify(explicitDest);\n if (!hash) {\n // The hash *should* never be undefined, but if that were to occur,\n // avoid any possible issues by not updating the browser history.\n return;\n }\n\n let forceReplace = false;\n if (this._destination &&\n (isDestHashesEqual(this._destination.hash, hash) ||\n isDestArraysEqual(this._destination.dest, explicitDest))) {\n // When the new destination is identical to `this._destination`, and\n // its `page` is undefined, replace the current browser history entry.\n // NOTE: This can only occur if `this._destination` was set either:\n // - through the document hash being specified on load.\n // - through the user changing the hash of the document.\n if (this._destination.page) {\n return;\n }\n forceReplace = true;\n }\n if (this._popStateInProgress && !forceReplace) {\n return;\n }\n\n this._pushOrReplaceState({\n dest: explicitDest,\n hash,\n page: pageNumber,\n rotation: this.linkService.rotation,\n }, forceReplace);\n\n if (!this._popStateInProgress) {\n // Prevent the browser history from updating while the new destination is\n // being scrolled into view, to avoid potentially inconsistent state.\n this._popStateInProgress = true;\n // We defer the resetting of `this._popStateInProgress`, to account for\n // e.g. zooming occuring when the new destination is being navigated to.\n Promise.resolve().then(() => {\n this._popStateInProgress = false;\n });\n }\n }\n\n /**\n * Push the current position to the browser history.\n */\n pushCurrentPosition() {\n if (!this.initialized || this._popStateInProgress) {\n return;\n }\n this._tryPushCurrentPosition();\n }\n\n /**\n * Go back one step in the browser history.\n * NOTE: Avoids navigating away from the document, useful for \"named actions\".\n */\n back() {\n if (!this.initialized || this._popStateInProgress) {\n return;\n }\n let state = window.history.state;\n if (this._isValidState(state) && state.uid > 0) {\n window.history.back();\n }\n }\n\n /**\n * Go forward one step in the browser history.\n * NOTE: Avoids navigating away from the document, useful for \"named actions\".\n */\n forward() {\n if (!this.initialized || this._popStateInProgress) {\n return;\n }\n let state = window.history.state;\n if (this._isValidState(state) && state.uid < this._maxUid) {\n window.history.forward();\n }\n }\n\n /**\n * @returns {boolean} Indicating if the user is currently moving through the\n * browser history, useful e.g. for skipping the next 'hashchange' event.\n */\n get popStateInProgress() {\n return this.initialized &&\n (this._popStateInProgress || this._blockHashChange > 0);\n }\n\n /**\n * @private\n */\n _pushOrReplaceState(destination, forceReplace = false) {\n let shouldReplace = forceReplace || !this._destination;\n let newState = {\n fingerprint: this.fingerprint,\n uid: shouldReplace ? this._uid : (this._uid + 1),\n destination,\n };\n\n if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME') &&\n window.history.state && window.history.state.chromecomState) {\n // history.state.chromecomState is managed by chromecom.js.\n newState.chromecomState = window.history.state.chromecomState;\n }\n this._updateInternalState(destination, newState.uid);\n\n if (shouldReplace) {\n window.history.replaceState(newState, '');\n } else {\n this._maxUid = this._uid;\n window.history.pushState(newState, '');\n }\n\n if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME') &&\n top === window) {\n // eslint-disable-next-line no-undef\n chrome.runtime.sendMessage('showPageAction');\n }\n }\n\n /**\n * @private\n */\n _tryPushCurrentPosition(temporary = false) {\n if (!this._position) {\n return;\n }\n let position = this._position;\n if (temporary) {\n position = Object.assign(Object.create(null), this._position);\n position.temporary = true;\n }\n\n if (!this._destination) {\n this._pushOrReplaceState(position);\n return;\n }\n if (this._destination.temporary) {\n // Always replace a previous *temporary* position.\n this._pushOrReplaceState(position, /* forceReplace = */ true);\n return;\n }\n if (this._destination.hash === position.hash) {\n return; // The current document position has not changed.\n }\n if (!this._destination.page &&\n (POSITION_UPDATED_THRESHOLD <= 0 ||\n this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {\n // `this._destination` was set through the user changing the hash of\n // the document. Do not add `this._position` to the browser history,\n // to avoid \"flooding\" it with lots of (nearly) identical entries,\n // since we cannot ensure that the document position has changed.\n return;\n }\n\n let forceReplace = false;\n if (this._destination.page === position.first ||\n this._destination.page === position.page) {\n // When the `page` of `this._destination` is still visible, do not\n // update the browsing history when `this._destination` either:\n // - contains an internal destination, since in this case we\n // cannot ensure that the document position has actually changed.\n // - was set through the user changing the hash of the document.\n if (this._destination.dest || !this._destination.first) {\n return;\n }\n // To avoid \"flooding\" the browser history, replace the current entry.\n forceReplace = true;\n }\n this._pushOrReplaceState(position, forceReplace);\n }\n\n /**\n * @private\n */\n _isValidState(state) {\n if (!state) {\n return false;\n }\n if (state.fingerprint !== this.fingerprint) {\n // This should only occur in viewers with support for opening more than\n // one PDF document, e.g. the GENERIC viewer.\n return false;\n }\n if (!Number.isInteger(state.uid) || state.uid < 0) {\n return false;\n }\n if (state.destination === null || typeof state.destination !== 'object') {\n return false;\n }\n return true;\n }\n\n /**\n * @private\n */\n _updateInternalState(destination, uid, removeTemporary = false) {\n if (this._updateViewareaTimeout) {\n // When updating `this._destination`, make sure that we always wait for\n // the next 'updateviewarea' event before (potentially) attempting to\n // push the current position to the browser history.\n clearTimeout(this._updateViewareaTimeout);\n this._updateViewareaTimeout = null;\n }\n if (removeTemporary && destination && destination.temporary) {\n // When the `destination` comes from the browser history,\n // we no longer treat it as a *temporary* position.\n delete destination.temporary;\n }\n this._destination = destination;\n this._uid = uid;\n // This should always be reset when `this._destination` is updated.\n this._numPositionUpdates = 0;\n }\n\n /**\n * @private\n */\n _updateViewarea({ location, }) {\n if (this._updateViewareaTimeout) {\n clearTimeout(this._updateViewareaTimeout);\n this._updateViewareaTimeout = null;\n }\n\n this._position = {\n hash: this._isViewerInPresentationMode ?\n `page=${location.pageNumber}` : location.pdfOpenParams.substring(1),\n page: this.linkService.page,\n first: location.pageNumber,\n rotation: location.rotation,\n };\n\n if (this._popStateInProgress) {\n return;\n }\n\n if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded &&\n this._destination && !this._destination.page) {\n // If the current destination was set through the user changing the hash\n // of the document, we will usually not try to push the current position\n // to the browser history; see `this._tryPushCurrentPosition()`.\n //\n // To prevent `this._tryPushCurrentPosition()` from effectively being\n // reduced to a no-op in this case, we will assume that the position\n // *did* in fact change if the 'updateviewarea' event was dispatched\n // more than `POSITION_UPDATED_THRESHOLD` times.\n this._numPositionUpdates++;\n }\n\n if (UPDATE_VIEWAREA_TIMEOUT > 0) {\n // When closing the browser, a 'pagehide' event will be dispatched which\n // *should* allow us to push the current position to the browser history.\n // In practice, it seems that the event is arriving too late in order for\n // the session history to be successfully updated.\n // (For additional details, please refer to the discussion in\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1153393.)\n //\n // To workaround this we attempt to *temporarily* add the current position\n // to the browser history only when the viewer is *idle*,\n // i.e. when scrolling and/or zooming does not occur.\n //\n // PLEASE NOTE: It's absolutely imperative that the browser history is\n // *not* updated too often, since that would render the viewer more or\n // less unusable. Hence the use of a timeout to delay the update until\n // the viewer has been idle for `UPDATE_VIEWAREA_TIMEOUT` milliseconds.\n this._updateViewareaTimeout = setTimeout(() => {\n if (!this._popStateInProgress) {\n this._tryPushCurrentPosition(/* temporary = */ true);\n }\n this._updateViewareaTimeout = null;\n }, UPDATE_VIEWAREA_TIMEOUT);\n }\n }\n\n /**\n * @private\n */\n _popState({ state, }) {\n let newHash = getCurrentHash(), hashChanged = this._currentHash !== newHash;\n this._currentHash = newHash;\n\n if (!state ||\n (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME') &&\n state.chromecomState && !this._isValidState(state))) {\n // This case corresponds to the user changing the hash of the document.\n this._uid++;\n\n let { hash, page, rotation, } = parseCurrentHash(this.linkService);\n this._pushOrReplaceState({ hash, page, rotation, },\n /* forceReplace = */ true);\n return;\n }\n if (!this._isValidState(state)) {\n // This should only occur in viewers with support for opening more than\n // one PDF document, e.g. the GENERIC viewer.\n return;\n }\n\n // Prevent the browser history from updating until the new destination,\n // as stored in the browser history, has been scrolled into view.\n this._popStateInProgress = true;\n\n if (hashChanged) {\n // When the hash changed, implying that the 'popstate' event will be\n // followed by a 'hashchange' event, then we do *not* want to update the\n // browser history when handling the 'hashchange' event (in web/app.js)\n // since that would *overwrite* the new destination navigated to below.\n //\n // To avoid accidentally disabling all future user-initiated hash changes,\n // if there's e.g. another 'hashchange' listener that stops the event\n // propagation, we make sure to always force-reset `this._blockHashChange`\n // after `HASH_CHANGE_TIMEOUT` milliseconds have passed.\n this._blockHashChange++;\n waitOnEventOrTimeout({\n target: window,\n name: 'hashchange',\n delay: HASH_CHANGE_TIMEOUT,\n }).then(() => {\n this._blockHashChange--;\n });\n }\n\n // Navigate to the new destination.\n let destination = state.destination;\n this._updateInternalState(destination, state.uid,\n /* removeTemporary = */ true);\n if (this._uid > this._maxUid) {\n this._maxUid = this._uid;\n }\n\n if (isValidRotation(destination.rotation)) {\n this.linkService.rotation = destination.rotation;\n }\n if (destination.dest) {\n this.linkService.navigateTo(destination.dest);\n } else if (destination.hash) {\n this.linkService.setHash(destination.hash);\n } else if (destination.page) {\n // Fallback case; shouldn't be necessary, but better safe than sorry.\n this.linkService.page = destination.page;\n }\n\n // Since `PDFLinkService.navigateTo` is asynchronous, we thus defer the\n // resetting of `this._popStateInProgress` slightly.\n Promise.resolve().then(() => {\n this._popStateInProgress = false;\n });\n }\n\n /**\n * @private\n */\n _bindEvents() {\n let { _boundEvents, eventBus, } = this;\n\n _boundEvents.updateViewarea = this._updateViewarea.bind(this);\n _boundEvents.popState = this._popState.bind(this);\n _boundEvents.pageHide = (evt) => {\n // Attempt to push the `this._position` into the browser history when\n // navigating away from the document. This is *only* done if the history\n // is empty/temporary, since otherwise an existing browser history entry\n // will end up being overwritten (given that new entries cannot be pushed\n // into the browser history when the 'unload' event has already fired).\n if (!this._destination || this._destination.temporary) {\n this._tryPushCurrentPosition();\n }\n };\n\n eventBus.on('updateviewarea', _boundEvents.updateViewarea);\n window.addEventListener('popstate', _boundEvents.popState);\n window.addEventListener('pagehide', _boundEvents.pageHide);\n }\n}\n\nfunction isDestHashesEqual(destHash, pushHash) {\n if (typeof destHash !== 'string' || typeof pushHash !== 'string') {\n return false;\n }\n if (destHash === pushHash) {\n return true;\n }\n let { nameddest, } = parseQueryString(destHash);\n if (nameddest === pushHash) {\n return true;\n }\n return false;\n}\n\nfunction isDestArraysEqual(firstDest, secondDest) {\n function isEntryEqual(first, second) {\n if (typeof first !== typeof second) {\n return false;\n }\n if (Array.isArray(first) || Array.isArray(second)) {\n return false;\n }\n if (first !== null && typeof first === 'object' && second !== null) {\n if (Object.keys(first).length !== Object.keys(second).length) {\n return false;\n }\n for (let key in first) {\n if (!isEntryEqual(first[key], second[key])) {\n return false;\n }\n }\n return true;\n }\n return first === second || (Number.isNaN(first) && Number.isNaN(second));\n }\n\n if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {\n return false;\n }\n if (firstDest.length !== secondDest.length) {\n return false;\n }\n for (let i = 0, ii = firstDest.length; i < ii; i++) {\n if (!isEntryEqual(firstDest[i], secondDest[i])) {\n return false;\n }\n }\n return true;\n}\n\nexport {\n PDFHistory,\n isDestHashesEqual,\n isDestArraysEqual,\n};\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getGlobalEventBus } from './dom_events';\nimport { parseQueryString } from './ui_utils';\n\n/**\n * @typedef {Object} PDFLinkServiceOptions\n * @property {EventBus} eventBus - The application event bus.\n * @property {number} externalLinkTarget - (optional) Specifies the `target`\n * attribute for external links. Must use one of the values from {LinkTarget}.\n * Defaults to using no target.\n * @property {string} externalLinkRel - (optional) Specifies the `rel` attribute\n * for external links. Defaults to stripping the referrer.\n */\n\n/**\n * Performs navigation functions inside PDF, such as opening specified page,\n * or destination.\n * @implements {IPDFLinkService}\n */\nclass PDFLinkService {\n /**\n * @param {PDFLinkServiceOptions} options\n */\n constructor({ eventBus, externalLinkTarget = null,\n externalLinkRel = null, } = {}) {\n this.eventBus = eventBus || getGlobalEventBus();\n this.externalLinkTarget = externalLinkTarget;\n this.externalLinkRel = externalLinkRel;\n\n this.baseUrl = null;\n this.pdfDocument = null;\n this.pdfViewer = null;\n this.pdfHistory = null;\n\n this._pagesRefCache = null;\n }\n\n setDocument(pdfDocument, baseUrl = null) {\n this.baseUrl = baseUrl;\n this.pdfDocument = pdfDocument;\n this._pagesRefCache = Object.create(null);\n }\n\n setViewer(pdfViewer) {\n this.pdfViewer = pdfViewer;\n }\n\n setHistory(pdfHistory) {\n this.pdfHistory = pdfHistory;\n }\n\n /**\n * @returns {number}\n */\n get pagesCount() {\n return this.pdfDocument ? this.pdfDocument.numPages : 0;\n }\n\n /**\n * @returns {number}\n */\n get page() {\n return this.pdfViewer.currentPageNumber;\n }\n\n /**\n * @param {number} value\n */\n set page(value) {\n this.pdfViewer.currentPageNumber = value;\n }\n\n /**\n * @returns {number}\n */\n get rotation() {\n return this.pdfViewer.pagesRotation;\n }\n\n /**\n * @param {number} value\n */\n set rotation(value) {\n this.pdfViewer.pagesRotation = value;\n }\n\n /**\n * @param {string|Array} dest - The named, or explicit, PDF destination.\n */\n navigateTo(dest) {\n let goToDestination = ({ namedDest, explicitDest, }) => {\n // Dest array looks like that: <page-ref> </XYZ|/FitXXX> <args..>\n let destRef = explicitDest[0], pageNumber;\n\n if (destRef instanceof Object) {\n pageNumber = this._cachedPageNumber(destRef);\n\n if (pageNumber === null) {\n // Fetch the page reference if it's not yet available. This could\n // only occur during loading, before all pages have been resolved.\n this.pdfDocument.getPageIndex(destRef).then((pageIndex) => {\n this.cachePageRef(pageIndex + 1, destRef);\n goToDestination({ namedDest, explicitDest, });\n }).catch(() => {\n console.error(`PDFLinkService.navigateTo: \"${destRef}\" is not ` +\n `a valid page reference, for dest=\"${dest}\".`);\n });\n return;\n }\n } else if (Number.isInteger(destRef)) {\n pageNumber = destRef + 1;\n } else {\n console.error(`PDFLinkService.navigateTo: \"${destRef}\" is not ` +\n `a valid destination reference, for dest=\"${dest}\".`);\n return;\n }\n if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {\n console.error(`PDFLinkService.navigateTo: \"${pageNumber}\" is not ` +\n `a valid page number, for dest=\"${dest}\".`);\n return;\n }\n\n if (this.pdfHistory) {\n // Update the browser history before scrolling the new destination into\n // view, to be able to accurately capture the current document position.\n this.pdfHistory.pushCurrentPosition();\n this.pdfHistory.push({ namedDest, explicitDest, pageNumber, });\n }\n\n this.pdfViewer.scrollPageIntoView({\n pageNumber,\n destArray: explicitDest,\n });\n };\n\n new Promise((resolve, reject) => {\n if (typeof dest === 'string') {\n this.pdfDocument.getDestination(dest).then((destArray) => {\n resolve({\n namedDest: dest,\n explicitDest: destArray,\n });\n });\n return;\n }\n resolve({\n namedDest: '',\n explicitDest: dest,\n });\n }).then((data) => {\n if (!Array.isArray(data.explicitDest)) {\n console.error(`PDFLinkService.navigateTo: \"${data.explicitDest}\" is` +\n ` not a valid destination array, for dest=\"${dest}\".`);\n return;\n }\n goToDestination(data);\n });\n }\n\n /**\n * @param {string|Array} dest - The PDF destination object.\n * @returns {string} The hyperlink to the PDF object.\n */\n getDestinationHash(dest) {\n if (typeof dest === 'string') {\n return this.getAnchorUrl('#' + escape(dest));\n }\n if (Array.isArray(dest)) {\n let str = JSON.stringify(dest);\n return this.getAnchorUrl('#' + escape(str));\n }\n return this.getAnchorUrl('');\n }\n\n /**\n * Prefix the full url on anchor links to make sure that links are resolved\n * relative to the current URL instead of the one defined in <base href>.\n * @param {String} anchor The anchor hash, including the #.\n * @returns {string} The hyperlink to the PDF object.\n */\n getAnchorUrl(anchor) {\n return (this.baseUrl || '') + anchor;\n }\n\n /**\n * @param {string} hash\n */\n setHash(hash) {\n let pageNumber, dest;\n if (hash.includes('=')) {\n let params = parseQueryString(hash);\n if ('search' in params) {\n this.eventBus.dispatch('findfromurlhash', {\n source: this,\n query: params['search'].replace(/\"/g, ''),\n phraseSearch: (params['phrase'] === 'true'),\n });\n }\n // borrowing syntax from \"Parameters for Opening PDF Files\"\n if ('nameddest' in params) {\n this.navigateTo(params.nameddest);\n return;\n }\n if ('page' in params) {\n pageNumber = (params.page | 0) || 1;\n }\n if ('zoom' in params) {\n // Build the destination array.\n let zoomArgs = params.zoom.split(','); // scale,left,top\n let zoomArg = zoomArgs[0];\n let zoomArgNumber = parseFloat(zoomArg);\n\n if (!zoomArg.includes('Fit')) {\n // If the zoomArg is a number, it has to get divided by 100. If it's\n // a string, it should stay as it is.\n dest = [null, { name: 'XYZ', },\n zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null,\n zoomArgs.length > 2 ? (zoomArgs[2] | 0) : null,\n (zoomArgNumber ? zoomArgNumber / 100 : zoomArg)];\n } else {\n if (zoomArg === 'Fit' || zoomArg === 'FitB') {\n dest = [null, { name: zoomArg, }];\n } else if ((zoomArg === 'FitH' || zoomArg === 'FitBH') ||\n (zoomArg === 'FitV' || zoomArg === 'FitBV')) {\n dest = [null, { name: zoomArg, },\n zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null];\n } else if (zoomArg === 'FitR') {\n if (zoomArgs.length !== 5) {\n console.error(\n 'PDFLinkService.setHash: Not enough parameters for \"FitR\".');\n } else {\n dest = [null, { name: zoomArg, },\n (zoomArgs[1] | 0), (zoomArgs[2] | 0),\n (zoomArgs[3] | 0), (zoomArgs[4] | 0)];\n }\n } else {\n console.error(`PDFLinkService.setHash: \"${zoomArg}\" is not ` +\n 'a valid zoom value.');\n }\n }\n }\n if (dest) {\n this.pdfViewer.scrollPageIntoView({\n pageNumber: pageNumber || this.page,\n destArray: dest,\n allowNegativeOffset: true,\n });\n } else if (pageNumber) {\n this.page = pageNumber; // simple page\n }\n if ('pagemode' in params) {\n this.eventBus.dispatch('pagemode', {\n source: this,\n mode: params.pagemode,\n });\n }\n } else { // Named (or explicit) destination.\n dest = unescape(hash);\n try {\n dest = JSON.parse(dest);\n\n if (!Array.isArray(dest)) {\n // Avoid incorrectly rejecting a valid named destination, such as\n // e.g. \"4.3\" or \"true\", because `JSON.parse` converted its type.\n dest = dest.toString();\n }\n } catch (ex) {}\n\n if (typeof dest === 'string' || isValidExplicitDestination(dest)) {\n this.navigateTo(dest);\n return;\n }\n console.error(`PDFLinkService.setHash: \"${unescape(hash)}\" is not ` +\n 'a valid destination.');\n }\n }\n\n /**\n * @param {string} action\n */\n executeNamedAction(action) {\n // See PDF reference, table 8.45 - Named action\n switch (action) {\n case 'GoBack':\n if (this.pdfHistory) {\n this.pdfHistory.back();\n }\n break;\n\n case 'GoForward':\n if (this.pdfHistory) {\n this.pdfHistory.forward();\n }\n break;\n\n case 'NextPage':\n if (this.page < this.pagesCount) {\n this.page++;\n }\n break;\n\n case 'PrevPage':\n if (this.page > 1) {\n this.page--;\n }\n break;\n\n case 'LastPage':\n this.page = this.pagesCount;\n break;\n\n case 'FirstPage':\n this.page = 1;\n break;\n\n default:\n break; // No action according to spec\n }\n\n this.eventBus.dispatch('namedaction', {\n source: this,\n action,\n });\n }\n\n /**\n * @param {number} pageNum - page number.\n * @param {Object} pageRef - reference to the page.\n */\n cachePageRef(pageNum, pageRef) {\n if (!pageRef) {\n return;\n }\n let refStr = pageRef.num + ' ' + pageRef.gen + ' R';\n this._pagesRefCache[refStr] = pageNum;\n }\n\n _cachedPageNumber(pageRef) {\n let refStr = pageRef.num + ' ' + pageRef.gen + ' R';\n return (this._pagesRefCache && this._pagesRefCache[refStr]) || null;\n }\n}\n\nfunction isValidExplicitDestination(dest) {\n if (!Array.isArray(dest)) {\n return false;\n }\n let destLength = dest.length, allowNull = true;\n if (destLength < 2) {\n return false;\n }\n let page = dest[0];\n if (!(typeof page === 'object' &&\n Number.isInteger(page.num) && Number.isInteger(page.gen)) &&\n !(Number.isInteger(page) && page >= 0)) {\n return false;\n }\n let zoom = dest[1];\n if (!(typeof zoom === 'object' && typeof zoom.name === 'string')) {\n return false;\n }\n switch (zoom.name) {\n case 'XYZ':\n if (destLength !== 5) {\n return false;\n }\n break;\n case 'Fit':\n case 'FitB':\n return destLength === 2;\n case 'FitH':\n case 'FitBH':\n case 'FitV':\n case 'FitBV':\n if (destLength !== 3) {\n return false;\n }\n break;\n case 'FitR':\n if (destLength !== 6) {\n return false;\n }\n allowNull = false;\n break;\n default:\n return false;\n }\n for (let i = 2; i < destLength; i++) {\n let param = dest[i];\n if (!(typeof param === 'number' || (allowNull && param === null))) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * @implements {IPDFLinkService}\n */\nclass SimpleLinkService {\n constructor() {\n this.externalLinkTarget = null;\n this.externalLinkRel = null;\n }\n\n /**\n * @returns {number}\n */\n get pagesCount() {\n return 0;\n }\n\n /**\n * @returns {number}\n */\n get page() {\n return 0;\n }\n\n /**\n * @param {number} value\n */\n set page(value) {}\n\n /**\n * @returns {number}\n */\n get rotation() {\n return 0;\n }\n\n /**\n * @param {number} value\n */\n set rotation(value) {}\n\n /**\n * @param dest - The PDF destination object.\n */\n navigateTo(dest) {}\n\n /**\n * @param dest - The PDF destination object.\n * @returns {string} The hyperlink to the PDF object.\n */\n getDestinationHash(dest) {\n return '#';\n }\n\n /**\n * @param hash - The PDF parameters/hash.\n * @returns {string} The hyperlink to the PDF object.\n */\n getAnchorUrl(hash) {\n return '#';\n }\n\n /**\n * @param {string} hash\n */\n setHash(hash) {}\n\n /**\n * @param {string} action\n */\n executeNamedAction(action) {}\n\n /**\n * @param {number} pageNum - page number.\n * @param {Object} pageRef - reference to the page.\n */\n cachePageRef(pageNum, pageRef) {}\n}\n\nexport {\n PDFLinkService,\n SimpleLinkService,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { addLinkAttributes, LinkTarget, removeNullCharacters } from 'pdfjs-lib';\n\nconst DEFAULT_TITLE = '\\u2013';\n\n/**\n * @typedef {Object} PDFOutlineViewerOptions\n * @property {HTMLDivElement} container - The viewer element.\n * @property {IPDFLinkService} linkService - The navigation/linking service.\n * @property {EventBus} eventBus - The application event bus.\n */\n\n/**\n * @typedef {Object} PDFOutlineViewerRenderParameters\n * @property {Array|null} outline - An array of outline objects.\n */\n\nclass PDFOutlineViewer {\n /**\n * @param {PDFOutlineViewerOptions} options\n */\n constructor({ container, linkService, eventBus, }) {\n this.container = container;\n this.linkService = linkService;\n this.eventBus = eventBus;\n\n this.reset();\n\n eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));\n }\n\n reset() {\n this.outline = null;\n this.lastToggleIsShow = true;\n\n // Remove the outline from the DOM.\n this.container.textContent = '';\n\n // Ensure that the left (right in RTL locales) margin is always reset,\n // to prevent incorrect outline alignment if a new document is opened.\n this.container.classList.remove('outlineWithDeepNesting');\n }\n\n /**\n * @private\n */\n _dispatchEvent(outlineCount) {\n this.eventBus.dispatch('outlineloaded', {\n source: this,\n outlineCount,\n });\n }\n\n /**\n * @private\n */\n _bindLink(element, { url, newWindow, dest, }) {\n let { linkService, } = this;\n\n if (url) {\n addLinkAttributes(element, {\n url,\n target: (newWindow ? LinkTarget.BLANK : linkService.externalLinkTarget),\n rel: linkService.externalLinkRel,\n });\n return;\n }\n\n element.href = linkService.getDestinationHash(dest);\n element.onclick = () => {\n if (dest) {\n linkService.navigateTo(dest);\n }\n return false;\n };\n }\n\n /**\n * @private\n */\n _setStyles(element, { bold, italic, }) {\n let styleStr = '';\n if (bold) {\n styleStr += 'font-weight: bold;';\n }\n if (italic) {\n styleStr += 'font-style: italic;';\n }\n\n if (styleStr) {\n element.setAttribute('style', styleStr);\n }\n }\n\n /**\n * Prepend a button before an outline item which allows the user to toggle\n * the visibility of all outline items at that level.\n *\n * @private\n */\n _addToggleButton(div) {\n let toggler = document.createElement('div');\n toggler.className = 'outlineItemToggler';\n toggler.onclick = (evt) => {\n evt.stopPropagation();\n toggler.classList.toggle('outlineItemsHidden');\n\n if (evt.shiftKey) {\n let shouldShowAll = !toggler.classList.contains('outlineItemsHidden');\n this._toggleOutlineItem(div, shouldShowAll);\n }\n };\n div.insertBefore(toggler, div.firstChild);\n }\n\n /**\n * Toggle the visibility of the subtree of an outline item.\n *\n * @param {Element} root - the root of the outline (sub)tree.\n * @param {boolean} show - whether to show the outline (sub)tree. If false,\n * the outline subtree rooted at |root| will be collapsed.\n *\n * @private\n */\n _toggleOutlineItem(root, show) {\n this.lastToggleIsShow = show;\n let togglers = root.querySelectorAll('.outlineItemToggler');\n for (let i = 0, ii = togglers.length; i < ii; ++i) {\n togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden');\n }\n }\n\n /**\n * Collapse or expand all subtrees of the outline.\n */\n toggleOutlineTree() {\n if (!this.outline) {\n return;\n }\n this._toggleOutlineItem(this.container, !this.lastToggleIsShow);\n }\n\n /**\n * @param {PDFOutlineViewerRenderParameters} params\n */\n render({ outline, }) {\n let outlineCount = 0;\n\n if (this.outline) {\n this.reset();\n }\n this.outline = outline || null;\n\n if (!outline) {\n this._dispatchEvent(outlineCount);\n return;\n }\n\n let fragment = document.createDocumentFragment();\n let queue = [{ parent: fragment, items: this.outline, }];\n let hasAnyNesting = false;\n while (queue.length > 0) {\n let levelData = queue.shift();\n for (let i = 0, len = levelData.items.length; i < len; i++) {\n let item = levelData.items[i];\n\n let div = document.createElement('div');\n div.className = 'outlineItem';\n\n let element = document.createElement('a');\n this._bindLink(element, item);\n this._setStyles(element, item);\n element.textContent =\n removeNullCharacters(item.title) || DEFAULT_TITLE;\n\n div.appendChild(element);\n\n if (item.items.length > 0) {\n hasAnyNesting = true;\n this._addToggleButton(div);\n\n let itemsDiv = document.createElement('div');\n itemsDiv.className = 'outlineItems';\n div.appendChild(itemsDiv);\n queue.push({ parent: itemsDiv, items: item.items, });\n }\n\n levelData.parent.appendChild(div);\n outlineCount++;\n }\n }\n if (hasAnyNesting) {\n this.container.classList.add('outlineWithDeepNesting');\n }\n\n this.container.appendChild(fragment);\n\n this._dispatchEvent(outlineCount);\n }\n}\n\nexport {\n PDFOutlineViewer,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { normalizeWheelEventDelta } from './ui_utils';\n\nconst DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500; // in ms\nconst DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms\nconst ACTIVE_SELECTOR = 'pdfPresentationMode';\nconst CONTROLS_SELECTOR = 'pdfPresentationModeControls';\nconst MOUSE_SCROLL_COOLDOWN_TIME = 50; // in ms\nconst PAGE_SWITCH_THRESHOLD = 0.1;\n\n// Number of CSS pixels for a movement to count as a swipe.\nconst SWIPE_MIN_DISTANCE_THRESHOLD = 50;\n\n// Swipe angle deviation from the x or y axis before it is not\n// considered a swipe in that direction any more.\nconst SWIPE_ANGLE_THRESHOLD = Math.PI / 6;\n\n/**\n * @typedef {Object} PDFPresentationModeOptions\n * @property {HTMLDivElement} container - The container for the viewer element.\n * @property {HTMLDivElement} viewer - (optional) The viewer element.\n * @property {PDFViewer} pdfViewer - The document viewer.\n * @property {EventBus} eventBus - The application event bus.\n * @property {Array} contextMenuItems - (optional) The menu items that are added\n * to the context menu in Presentation Mode.\n */\n\nclass PDFPresentationMode {\n /**\n * @param {PDFPresentationModeOptions} options\n */\n constructor({ container, viewer = null, pdfViewer, eventBus,\n contextMenuItems = null, }) {\n this.container = container;\n this.viewer = viewer || container.firstElementChild;\n this.pdfViewer = pdfViewer;\n this.eventBus = eventBus;\n\n this.active = false;\n this.args = null;\n this.contextMenuOpen = false;\n this.mouseScrollTimeStamp = 0;\n this.mouseScrollDelta = 0;\n this.touchSwipeState = null;\n\n if (contextMenuItems) {\n contextMenuItems.contextFirstPage.addEventListener('click', () => {\n this.contextMenuOpen = false;\n this.eventBus.dispatch('firstpage', { source: this, });\n });\n contextMenuItems.contextLastPage.addEventListener('click', () => {\n this.contextMenuOpen = false;\n this.eventBus.dispatch('lastpage', { source: this, });\n });\n contextMenuItems.contextPageRotateCw.addEventListener('click', () => {\n this.contextMenuOpen = false;\n this.eventBus.dispatch('rotatecw', { source: this, });\n });\n contextMenuItems.contextPageRotateCcw.addEventListener('click', () => {\n this.contextMenuOpen = false;\n this.eventBus.dispatch('rotateccw', { source: this, });\n });\n }\n }\n\n /**\n * Request the browser to enter fullscreen mode.\n * @returns {boolean} Indicating if the request was successful.\n */\n request() {\n if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {\n return false;\n }\n this._addFullscreenChangeListeners();\n this._setSwitchInProgress();\n this._notifyStateChange();\n\n if (this.container.requestFullscreen) {\n this.container.requestFullscreen();\n } else if (this.container.mozRequestFullScreen) {\n this.container.mozRequestFullScreen();\n } else if (this.container.webkitRequestFullscreen) {\n this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n } else if (this.container.msRequestFullscreen) {\n this.container.msRequestFullscreen();\n } else {\n return false;\n }\n\n this.args = {\n page: this.pdfViewer.currentPageNumber,\n previousScale: this.pdfViewer.currentScaleValue,\n };\n\n return true;\n }\n\n /**\n * @private\n */\n _mouseWheel(evt) {\n if (!this.active) {\n return;\n }\n\n evt.preventDefault();\n\n let delta = normalizeWheelEventDelta(evt);\n let currentTime = (new Date()).getTime();\n let storedTime = this.mouseScrollTimeStamp;\n\n // If we've already switched page, avoid accidentally switching again.\n if (currentTime > storedTime &&\n currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {\n return;\n }\n // If the scroll direction changed, reset the accumulated scroll delta.\n if ((this.mouseScrollDelta > 0 && delta < 0) ||\n (this.mouseScrollDelta < 0 && delta > 0)) {\n this._resetMouseScrollState();\n }\n this.mouseScrollDelta += delta;\n\n if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {\n let totalDelta = this.mouseScrollDelta;\n this._resetMouseScrollState();\n let success = totalDelta > 0 ? this._goToPreviousPage()\n : this._goToNextPage();\n if (success) {\n this.mouseScrollTimeStamp = currentTime;\n }\n }\n }\n\n get isFullscreen() {\n return !!(document.fullscreenElement || document.mozFullScreen ||\n document.webkitIsFullScreen || document.msFullscreenElement);\n }\n\n /**\n * @private\n */\n _goToPreviousPage() {\n let page = this.pdfViewer.currentPageNumber;\n // If we're at the first page, we don't need to do anything.\n if (page <= 1) {\n return false;\n }\n this.pdfViewer.currentPageNumber = (page - 1);\n return true;\n }\n\n /**\n * @private\n */\n _goToNextPage() {\n let page = this.pdfViewer.currentPageNumber;\n // If we're at the last page, we don't need to do anything.\n if (page >= this.pdfViewer.pagesCount) {\n return false;\n }\n this.pdfViewer.currentPageNumber = (page + 1);\n return true;\n }\n\n /**\n * @private\n */\n _notifyStateChange() {\n this.eventBus.dispatch('presentationmodechanged', {\n source: this,\n active: this.active,\n switchInProgress: !!this.switchInProgress,\n });\n }\n\n /**\n * Used to initialize a timeout when requesting Presentation Mode,\n * i.e. when the browser is requested to enter fullscreen mode.\n * This timeout is used to prevent the current page from being scrolled\n * partially, or completely, out of view when entering Presentation Mode.\n * NOTE: This issue seems limited to certain zoom levels (e.g. page-width).\n *\n * @private\n */\n _setSwitchInProgress() {\n if (this.switchInProgress) {\n clearTimeout(this.switchInProgress);\n }\n this.switchInProgress = setTimeout(() => {\n this._removeFullscreenChangeListeners();\n delete this.switchInProgress;\n this._notifyStateChange();\n }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);\n }\n\n /**\n * @private\n */\n _resetSwitchInProgress() {\n if (this.switchInProgress) {\n clearTimeout(this.switchInProgress);\n delete this.switchInProgress;\n }\n }\n\n /**\n * @private\n */\n _enter() {\n this.active = true;\n this._resetSwitchInProgress();\n this._notifyStateChange();\n this.container.classList.add(ACTIVE_SELECTOR);\n\n // Ensure that the correct page is scrolled into view when entering\n // Presentation Mode, by waiting until fullscreen mode in enabled.\n setTimeout(() => {\n this.pdfViewer.currentPageNumber = this.args.page;\n this.pdfViewer.currentScaleValue = 'page-fit';\n }, 0);\n\n this._addWindowListeners();\n this._showControls();\n this.contextMenuOpen = false;\n this.container.setAttribute('contextmenu', 'viewerContextMenu');\n\n // Text selection is disabled in Presentation Mode, thus it's not possible\n // for the user to deselect text that is selected (e.g. with \"Select all\")\n // when entering Presentation Mode, hence we remove any active selection.\n window.getSelection().removeAllRanges();\n }\n\n /**\n * @private\n */\n _exit() {\n let page = this.pdfViewer.currentPageNumber;\n this.container.classList.remove(ACTIVE_SELECTOR);\n\n // Ensure that the correct page is scrolled into view when exiting\n // Presentation Mode, by waiting until fullscreen mode is disabled.\n setTimeout(() => {\n this.active = false;\n this._removeFullscreenChangeListeners();\n this._notifyStateChange();\n\n this.pdfViewer.currentScaleValue = this.args.previousScale;\n this.pdfViewer.currentPageNumber = page;\n this.args = null;\n }, 0);\n\n this._removeWindowListeners();\n this._hideControls();\n this._resetMouseScrollState();\n this.container.removeAttribute('contextmenu');\n this.contextMenuOpen = false;\n }\n\n /**\n * @private\n */\n _mouseDown(evt) {\n if (this.contextMenuOpen) {\n this.contextMenuOpen = false;\n evt.preventDefault();\n return;\n }\n if (evt.button === 0) {\n // Enable clicking of links in presentation mode. Note: only links\n // pointing to destinations in the current PDF document work.\n let isInternalLink = (evt.target.href &&\n evt.target.classList.contains('internalLink'));\n if (!isInternalLink) {\n // Unless an internal link was clicked, advance one page.\n evt.preventDefault();\n\n if (evt.shiftKey) {\n this._goToPreviousPage();\n } else {\n this._goToNextPage();\n }\n }\n }\n }\n\n /**\n * @private\n */\n _contextMenu() {\n this.contextMenuOpen = true;\n }\n\n /**\n * @private\n */\n _showControls() {\n if (this.controlsTimeout) {\n clearTimeout(this.controlsTimeout);\n } else {\n this.container.classList.add(CONTROLS_SELECTOR);\n }\n this.controlsTimeout = setTimeout(() => {\n this.container.classList.remove(CONTROLS_SELECTOR);\n delete this.controlsTimeout;\n }, DELAY_BEFORE_HIDING_CONTROLS);\n }\n\n /**\n * @private\n */\n _hideControls() {\n if (!this.controlsTimeout) {\n return;\n }\n clearTimeout(this.controlsTimeout);\n this.container.classList.remove(CONTROLS_SELECTOR);\n delete this.controlsTimeout;\n }\n\n /**\n * Resets the properties used for tracking mouse scrolling events.\n *\n * @private\n */\n _resetMouseScrollState() {\n this.mouseScrollTimeStamp = 0;\n this.mouseScrollDelta = 0;\n }\n\n /**\n * @private\n */\n _touchSwipe(evt) {\n if (!this.active) {\n return;\n }\n if (evt.touches.length > 1) {\n // Multiple touch points detected; cancel the swipe.\n this.touchSwipeState = null;\n return;\n }\n\n switch (evt.type) {\n case 'touchstart':\n this.touchSwipeState = {\n startX: evt.touches[0].pageX,\n startY: evt.touches[0].pageY,\n endX: evt.touches[0].pageX,\n endY: evt.touches[0].pageY,\n };\n break;\n case 'touchmove':\n if (this.touchSwipeState === null) {\n return;\n }\n this.touchSwipeState.endX = evt.touches[0].pageX;\n this.touchSwipeState.endY = evt.touches[0].pageY;\n // Avoid the swipe from triggering browser gestures (Chrome in\n // particular has some sort of swipe gesture in fullscreen mode).\n evt.preventDefault();\n break;\n case 'touchend':\n if (this.touchSwipeState === null) {\n return;\n }\n let delta = 0;\n let dx = this.touchSwipeState.endX - this.touchSwipeState.startX;\n let dy = this.touchSwipeState.endY - this.touchSwipeState.startY;\n let absAngle = Math.abs(Math.atan2(dy, dx));\n if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD &&\n (absAngle <= SWIPE_ANGLE_THRESHOLD ||\n absAngle >= (Math.PI - SWIPE_ANGLE_THRESHOLD))) {\n // Horizontal swipe.\n delta = dx;\n } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD &&\n Math.abs(absAngle - (Math.PI / 2)) <= SWIPE_ANGLE_THRESHOLD) {\n // Vertical swipe.\n delta = dy;\n }\n if (delta > 0) {\n this._goToPreviousPage();\n } else if (delta < 0) {\n this._goToNextPage();\n }\n break;\n }\n }\n\n /**\n * @private\n */\n _addWindowListeners() {\n this.showControlsBind = this._showControls.bind(this);\n this.mouseDownBind = this._mouseDown.bind(this);\n this.mouseWheelBind = this._mouseWheel.bind(this);\n this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);\n this.contextMenuBind = this._contextMenu.bind(this);\n this.touchSwipeBind = this._touchSwipe.bind(this);\n\n window.addEventListener('mousemove', this.showControlsBind);\n window.addEventListener('mousedown', this.mouseDownBind);\n window.addEventListener('wheel', this.mouseWheelBind);\n window.addEventListener('keydown', this.resetMouseScrollStateBind);\n window.addEventListener('contextmenu', this.contextMenuBind);\n window.addEventListener('touchstart', this.touchSwipeBind);\n window.addEventListener('touchmove', this.touchSwipeBind);\n window.addEventListener('touchend', this.touchSwipeBind);\n }\n\n /**\n * @private\n */\n _removeWindowListeners() {\n window.removeEventListener('mousemove', this.showControlsBind);\n window.removeEventListener('mousedown', this.mouseDownBind);\n window.removeEventListener('wheel', this.mouseWheelBind);\n window.removeEventListener('keydown', this.resetMouseScrollStateBind);\n window.removeEventListener('contextmenu', this.contextMenuBind);\n window.removeEventListener('touchstart', this.touchSwipeBind);\n window.removeEventListener('touchmove', this.touchSwipeBind);\n window.removeEventListener('touchend', this.touchSwipeBind);\n\n delete this.showControlsBind;\n delete this.mouseDownBind;\n delete this.mouseWheelBind;\n delete this.resetMouseScrollStateBind;\n delete this.contextMenuBind;\n delete this.touchSwipeBind;\n }\n\n /**\n * @private\n */\n _fullscreenChange() {\n if (this.isFullscreen) {\n this._enter();\n } else {\n this._exit();\n }\n }\n\n /**\n * @private\n */\n _addFullscreenChangeListeners() {\n this.fullscreenChangeBind = this._fullscreenChange.bind(this);\n\n window.addEventListener('fullscreenchange', this.fullscreenChangeBind);\n window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);\n if (typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n window.addEventListener('webkitfullscreenchange',\n this.fullscreenChangeBind);\n window.addEventListener('MSFullscreenChange',\n this.fullscreenChangeBind);\n }\n }\n\n /**\n * @private\n */\n _removeFullscreenChangeListeners() {\n window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);\n window.removeEventListener('mozfullscreenchange',\n this.fullscreenChangeBind);\n if (typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n window.removeEventListener('webkitfullscreenchange',\n this.fullscreenChangeBind);\n window.removeEventListener('MSFullscreenChange',\n this.fullscreenChangeBind);\n }\n\n delete this.fullscreenChangeBind;\n }\n}\n\nexport {\n PDFPresentationMode,\n};\n","/* Copyright 2017 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NullL10n } from './ui_utils';\n\nconst SIDEBAR_WIDTH_VAR = '--sidebar-width';\nconst SIDEBAR_MIN_WIDTH = 200; // pixels\nconst SIDEBAR_RESIZING_CLASS = 'sidebarResizing';\n\n/**\n * @typedef {Object} PDFSidebarResizerOptions\n * @property {HTMLDivElement} outerContainer - The outer container\n * (encasing both the viewer and sidebar elements).\n * @property {HTMLDivElement} resizer - The DOM element that can be dragged in\n * order to adjust the width of the sidebar.\n */\n\nclass PDFSidebarResizer {\n /**\n * @param {PDFSidebarResizerOptions} options\n * @param {EventBus} eventBus - The application event bus.\n * @param {IL10n} l10n - Localization service.\n */\n constructor(options, eventBus, l10n = NullL10n) {\n this.enabled = false;\n this.isRTL = false;\n this.sidebarOpen = false;\n this.doc = document.documentElement;\n this._width = null;\n this._outerContainerWidth = null;\n this._boundEvents = Object.create(null);\n\n this.outerContainer = options.outerContainer;\n this.resizer = options.resizer;\n this.eventBus = eventBus;\n this.l10n = l10n;\n\n if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' ||\n !CSS.supports(SIDEBAR_WIDTH_VAR, `calc(-1 * ${SIDEBAR_MIN_WIDTH}px)`)) {\n console.warn('PDFSidebarResizer: ' +\n 'The browser does not support resizing of the sidebar.');\n return;\n }\n this.enabled = true;\n this.resizer.classList.remove('hidden'); // Show the resizer DOM element.\n\n this.l10n.getDirection().then((dir) => {\n this.isRTL = (dir === 'rtl');\n });\n this._addEventListeners();\n }\n\n /**\n * returns {number}\n */\n get outerContainerWidth() {\n if (!this._outerContainerWidth) {\n this._outerContainerWidth = this.outerContainer.clientWidth;\n }\n return this._outerContainerWidth;\n }\n\n /**\n * @private\n * returns {boolean} Indicating if the sidebar width was updated.\n */\n _updateWidth(width = 0) {\n if (!this.enabled) {\n return false;\n }\n // Prevent the sidebar from becoming too narrow, or from occupying more\n // than half of the available viewer width.\n const maxWidth = Math.floor(this.outerContainerWidth / 2);\n if (width > maxWidth) {\n width = maxWidth;\n }\n if (width < SIDEBAR_MIN_WIDTH) {\n width = SIDEBAR_MIN_WIDTH;\n }\n // Only update the UI when the sidebar width did in fact change.\n if (width === this._width) {\n return false;\n }\n this._width = width;\n this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);\n return true;\n }\n\n /**\n * @private\n */\n _mouseMove(evt) {\n let width = evt.clientX;\n // For sidebar resizing to work correctly in RTL mode, invert the width.\n if (this.isRTL) {\n width = this.outerContainerWidth - width;\n }\n this._updateWidth(width);\n }\n\n /**\n * @private\n */\n _mouseUp(evt) {\n // Re-enable the `transition-duration` rules when sidebar resizing ends...\n this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);\n // ... and ensure that rendering will always be triggered.\n this.eventBus.dispatch('resize', { source: this, });\n\n let _boundEvents = this._boundEvents;\n window.removeEventListener('mousemove', _boundEvents.mouseMove);\n window.removeEventListener('mouseup', _boundEvents.mouseUp);\n }\n\n /**\n * @private\n */\n _addEventListeners() {\n if (!this.enabled) {\n return;\n }\n let _boundEvents = this._boundEvents;\n _boundEvents.mouseMove = this._mouseMove.bind(this);\n _boundEvents.mouseUp = this._mouseUp.bind(this);\n\n this.resizer.addEventListener('mousedown', (evt) => {\n if (evt.button !== 0) {\n return;\n }\n // Disable the `transition-duration` rules when sidebar resizing begins,\n // in order to improve responsiveness and to avoid visual glitches.\n this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);\n\n window.addEventListener('mousemove', _boundEvents.mouseMove);\n window.addEventListener('mouseup', _boundEvents.mouseUp);\n });\n\n this.eventBus.on('sidebarviewchanged', (evt) => {\n this.sidebarOpen = !!(evt && evt.view);\n });\n\n this.eventBus.on('resize', (evt) => {\n // When the *entire* viewer is resized, such that it becomes narrower,\n // ensure that the sidebar doesn't end up being too wide.\n if (evt && evt.source === window) {\n // Always reset the cached width when the viewer is resized.\n this._outerContainerWidth = null;\n\n if (this._width) {\n // NOTE: If the sidebar is closed, we don't need to worry about\n // visual glitches nor ensure that rendering is triggered.\n if (this.sidebarOpen) {\n this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);\n let updated = this._updateWidth(this._width);\n\n Promise.resolve().then(() => {\n this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);\n // Trigger rendering if the sidebar width changed, to avoid\n // depending on the order in which 'resize' events are handled.\n if (updated) {\n this.eventBus.dispatch('resize', { source: this, });\n }\n });\n } else {\n this._updateWidth(this._width);\n }\n }\n }\n });\n }\n}\n\nexport {\n PDFSidebarResizer,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n getVisibleElements, isValidRotation, NullL10n, scrollIntoView, watchScroll\n} from './ui_utils';\nimport { PDFThumbnailView } from './pdf_thumbnail_view';\n\nconst THUMBNAIL_SCROLL_MARGIN = -19;\nconst THUMBNAIL_SELECTED_CLASS = 'selected';\n\n/**\n * @typedef {Object} PDFThumbnailViewerOptions\n * @property {HTMLDivElement} container - The container for the thumbnail\n * elements.\n * @property {IPDFLinkService} linkService - The navigation/linking service.\n * @property {PDFRenderingQueue} renderingQueue - The rendering queue object.\n * @property {IL10n} l10n - Localization service.\n */\n\n/**\n * Viewer control to display thumbnails for pages in a PDF document.\n *\n * @implements {IRenderableView}\n */\nclass PDFThumbnailViewer {\n /**\n * @param {PDFThumbnailViewerOptions} options\n */\n constructor({ container, linkService, renderingQueue, l10n = NullL10n, }) {\n this.container = container;\n this.linkService = linkService;\n this.renderingQueue = renderingQueue;\n this.l10n = l10n;\n\n this.scroll = watchScroll(this.container, this._scrollUpdated.bind(this));\n this._resetView();\n }\n\n /**\n * @private\n */\n _scrollUpdated() {\n this.renderingQueue.renderHighestPriority();\n }\n\n getThumbnail(index) {\n return this._thumbnails[index];\n }\n\n /**\n * @private\n */\n _getVisibleThumbs() {\n return getVisibleElements(this.container, this._thumbnails);\n }\n\n scrollThumbnailIntoView(pageNumber) {\n if (!this.pdfDocument) {\n return;\n }\n const thumbnailView = this._thumbnails[pageNumber - 1];\n\n if (!thumbnailView) {\n console.error('scrollThumbnailIntoView: Invalid \"pageNumber\" parameter.');\n return;\n }\n\n if (pageNumber !== this._currentPageNumber) {\n const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];\n // Remove the highlight from the previous thumbnail...\n prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);\n // ... and add the highlight to the new thumbnail.\n thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);\n }\n let visibleThumbs = this._getVisibleThumbs();\n let numVisibleThumbs = visibleThumbs.views.length;\n\n // If the thumbnail isn't currently visible, scroll it into view.\n if (numVisibleThumbs > 0) {\n let first = visibleThumbs.first.id;\n // Account for only one thumbnail being visible.\n let last = (numVisibleThumbs > 1 ? visibleThumbs.last.id : first);\n\n let shouldScroll = false;\n if (pageNumber <= first || pageNumber >= last) {\n shouldScroll = true;\n } else {\n visibleThumbs.views.some(function(view) {\n if (view.id !== pageNumber) {\n return false;\n }\n shouldScroll = view.percent < 100;\n return true;\n });\n }\n if (shouldScroll) {\n scrollIntoView(thumbnailView.div, { top: THUMBNAIL_SCROLL_MARGIN, });\n }\n }\n\n this._currentPageNumber = pageNumber;\n }\n\n get pagesRotation() {\n return this._pagesRotation;\n }\n\n set pagesRotation(rotation) {\n if (!isValidRotation(rotation)) {\n throw new Error('Invalid thumbnails rotation angle.');\n }\n if (!this.pdfDocument) {\n return;\n }\n if (this._pagesRotation === rotation) {\n return; // The rotation didn't change.\n }\n this._pagesRotation = rotation;\n\n for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {\n this._thumbnails[i].update(rotation);\n }\n }\n\n cleanup() {\n PDFThumbnailView.cleanup();\n }\n\n /**\n * @private\n */\n _resetView() {\n this._thumbnails = [];\n this._currentPageNumber = 1;\n this._pageLabels = null;\n this._pagesRotation = 0;\n this._pagesRequests = [];\n\n // Remove the thumbnails from the DOM.\n this.container.textContent = '';\n }\n\n setDocument(pdfDocument) {\n if (this.pdfDocument) {\n this._cancelRendering();\n this._resetView();\n }\n\n this.pdfDocument = pdfDocument;\n if (!pdfDocument) {\n return;\n }\n\n pdfDocument.getPage(1).then((firstPage) => {\n let pagesCount = pdfDocument.numPages;\n let viewport = firstPage.getViewport(1.0);\n for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {\n let thumbnail = new PDFThumbnailView({\n container: this.container,\n id: pageNum,\n defaultViewport: viewport.clone(),\n linkService: this.linkService,\n renderingQueue: this.renderingQueue,\n disableCanvasToImageConversion: false,\n l10n: this.l10n,\n });\n this._thumbnails.push(thumbnail);\n }\n\n // Ensure that the current thumbnail is always highlighted on load.\n const thumbnailView = this._thumbnails[this._currentPageNumber - 1];\n thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);\n }).catch((reason) => {\n console.error('Unable to initialize thumbnail viewer', reason);\n });\n }\n\n /**\n * @private\n */\n _cancelRendering() {\n for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {\n if (this._thumbnails[i]) {\n this._thumbnails[i].cancelRendering();\n }\n }\n }\n\n /**\n * @param {Array|null} labels\n */\n setPageLabels(labels) {\n if (!this.pdfDocument) {\n return;\n }\n if (!labels) {\n this._pageLabels = null;\n } else if (!(Array.isArray(labels) &&\n this.pdfDocument.numPages === labels.length)) {\n this._pageLabels = null;\n console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');\n } else {\n this._pageLabels = labels;\n }\n // Update all the `PDFThumbnailView` instances.\n for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {\n let label = this._pageLabels && this._pageLabels[i];\n this._thumbnails[i].setPageLabel(label);\n }\n }\n\n /**\n * @param {PDFThumbnailView} thumbView\n * @returns {PDFPage}\n * @private\n */\n _ensurePdfPageLoaded(thumbView) {\n if (thumbView.pdfPage) {\n return Promise.resolve(thumbView.pdfPage);\n }\n let pageNumber = thumbView.id;\n if (this._pagesRequests[pageNumber]) {\n return this._pagesRequests[pageNumber];\n }\n let promise = this.pdfDocument.getPage(pageNumber).then((pdfPage) => {\n thumbView.setPdfPage(pdfPage);\n this._pagesRequests[pageNumber] = null;\n return pdfPage;\n }).catch((reason) => {\n console.error('Unable to get page for thumb view', reason);\n // Page error -- there is nothing can be done.\n this._pagesRequests[pageNumber] = null;\n });\n this._pagesRequests[pageNumber] = promise;\n return promise;\n }\n\n forceRendering() {\n let visibleThumbs = this._getVisibleThumbs();\n let thumbView = this.renderingQueue.getHighestPriority(visibleThumbs,\n this._thumbnails,\n this.scroll.down);\n if (thumbView) {\n this._ensurePdfPageLoaded(thumbView).then(() => {\n this.renderingQueue.renderView(thumbView);\n });\n return true;\n }\n return false;\n }\n}\n\nexport {\n PDFThumbnailViewer,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createPromiseCapability, RenderingCancelledException\n} from 'pdfjs-lib';\nimport { getOutputScale, NullL10n } from './ui_utils';\nimport { RenderingStates } from './pdf_rendering_queue';\n\nconst MAX_NUM_SCALING_STEPS = 3;\nconst THUMBNAIL_CANVAS_BORDER_WIDTH = 1; // px\nconst THUMBNAIL_WIDTH = 98; // px\n\n/**\n * @typedef {Object} PDFThumbnailViewOptions\n * @property {HTMLDivElement} container - The viewer element.\n * @property {number} id - The thumbnail's unique ID (normally its number).\n * @property {PageViewport} defaultViewport - The page viewport.\n * @property {IPDFLinkService} linkService - The navigation/linking service.\n * @property {PDFRenderingQueue} renderingQueue - The rendering queue object.\n * @property {boolean} disableCanvasToImageConversion - (optional) Don't convert\n * the canvas thumbnails to images. This prevents `toDataURL` calls,\n * but increases the overall memory usage. The default value is `false`.\n * @property {IL10n} l10n - Localization service.\n */\n\nconst TempImageFactory = (function TempImageFactoryClosure() {\n let tempCanvasCache = null;\n\n return {\n getCanvas(width, height) {\n let tempCanvas = tempCanvasCache;\n if (!tempCanvas) {\n tempCanvas = document.createElement('canvas');\n tempCanvasCache = tempCanvas;\n }\n tempCanvas.width = width;\n tempCanvas.height = height;\n\n // Since this is a temporary canvas, we need to fill it with a white\n // background ourselves. `_getPageDrawContext` uses CSS rules for this.\n if (typeof PDFJSDev === 'undefined' ||\n PDFJSDev.test('MOZCENTRAL || FIREFOX || GENERIC')) {\n tempCanvas.mozOpaque = true;\n }\n\n let ctx = tempCanvas.getContext('2d', { alpha: false, });\n ctx.save();\n ctx.fillStyle = 'rgb(255, 255, 255)';\n ctx.fillRect(0, 0, width, height);\n ctx.restore();\n return tempCanvas;\n },\n\n destroyCanvas() {\n let tempCanvas = tempCanvasCache;\n if (tempCanvas) {\n // Zeroing the width and height causes Firefox to release graphics\n // resources immediately, which can greatly reduce memory consumption.\n tempCanvas.width = 0;\n tempCanvas.height = 0;\n }\n tempCanvasCache = null;\n },\n };\n})();\n\n/**\n * @implements {IRenderableView}\n */\nclass PDFThumbnailView {\n /**\n * @param {PDFThumbnailViewOptions} options\n */\n constructor({ container, id, defaultViewport, linkService, renderingQueue,\n disableCanvasToImageConversion = false, l10n = NullL10n, }) {\n this.id = id;\n this.renderingId = 'thumbnail' + id;\n this.pageLabel = null;\n\n this.pdfPage = null;\n this.rotation = 0;\n this.viewport = defaultViewport;\n this.pdfPageRotate = defaultViewport.rotation;\n\n this.linkService = linkService;\n this.renderingQueue = renderingQueue;\n\n this.renderTask = null;\n this.renderingState = RenderingStates.INITIAL;\n this.resume = null;\n this.disableCanvasToImageConversion = disableCanvasToImageConversion;\n\n this.pageWidth = this.viewport.width;\n this.pageHeight = this.viewport.height;\n this.pageRatio = this.pageWidth / this.pageHeight;\n\n this.canvasWidth = THUMBNAIL_WIDTH;\n this.canvasHeight = (this.canvasWidth / this.pageRatio) | 0;\n this.scale = this.canvasWidth / this.pageWidth;\n\n this.l10n = l10n;\n\n let anchor = document.createElement('a');\n anchor.href = linkService.getAnchorUrl('#page=' + id);\n this.l10n.get('thumb_page_title', { page: id, }, 'Page {{page}}').\n then((msg) => {\n anchor.title = msg;\n });\n anchor.onclick = function() {\n linkService.page = id;\n return false;\n };\n this.anchor = anchor;\n\n let div = document.createElement('div');\n div.className = 'thumbnail';\n div.setAttribute('data-page-number', this.id);\n this.div = div;\n\n let ring = document.createElement('div');\n ring.className = 'thumbnailSelectionRing';\n let borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;\n ring.style.width = this.canvasWidth + borderAdjustment + 'px';\n ring.style.height = this.canvasHeight + borderAdjustment + 'px';\n this.ring = ring;\n\n div.appendChild(ring);\n anchor.appendChild(div);\n container.appendChild(anchor);\n }\n\n setPdfPage(pdfPage) {\n this.pdfPage = pdfPage;\n this.pdfPageRotate = pdfPage.rotate;\n let totalRotation = (this.rotation + this.pdfPageRotate) % 360;\n this.viewport = pdfPage.getViewport(1, totalRotation);\n this.reset();\n }\n\n reset() {\n this.cancelRendering();\n\n this.pageWidth = this.viewport.width;\n this.pageHeight = this.viewport.height;\n this.pageRatio = this.pageWidth / this.pageHeight;\n\n this.canvasHeight = (this.canvasWidth / this.pageRatio) | 0;\n this.scale = (this.canvasWidth / this.pageWidth);\n\n this.div.removeAttribute('data-loaded');\n let ring = this.ring;\n let childNodes = ring.childNodes;\n for (let i = childNodes.length - 1; i >= 0; i--) {\n ring.removeChild(childNodes[i]);\n }\n let borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;\n ring.style.width = this.canvasWidth + borderAdjustment + 'px';\n ring.style.height = this.canvasHeight + borderAdjustment + 'px';\n\n if (this.canvas) {\n // Zeroing the width and height causes Firefox to release graphics\n // resources immediately, which can greatly reduce memory consumption.\n this.canvas.width = 0;\n this.canvas.height = 0;\n delete this.canvas;\n }\n if (this.image) {\n this.image.removeAttribute('src');\n delete this.image;\n }\n }\n\n update(rotation) {\n if (typeof rotation !== 'undefined') {\n this.rotation = rotation;\n }\n let totalRotation = (this.rotation + this.pdfPageRotate) % 360;\n this.viewport = this.viewport.clone({\n scale: 1,\n rotation: totalRotation,\n });\n this.reset();\n }\n\n cancelRendering() {\n if (this.renderTask) {\n this.renderTask.cancel();\n this.renderTask = null;\n }\n this.renderingState = RenderingStates.INITIAL;\n this.resume = null;\n }\n\n /**\n * @private\n */\n _getPageDrawContext(noCtxScale = false) {\n let canvas = document.createElement('canvas');\n // Keep the no-thumbnail outline visible, i.e. `data-loaded === false`,\n // until rendering/image conversion is complete, to avoid display issues.\n this.canvas = canvas;\n\n if (typeof PDFJSDev === 'undefined' ||\n PDFJSDev.test('MOZCENTRAL || FIREFOX || GENERIC')) {\n canvas.mozOpaque = true;\n }\n let ctx = canvas.getContext('2d', { alpha: false, });\n let outputScale = getOutputScale(ctx);\n\n canvas.width = (this.canvasWidth * outputScale.sx) | 0;\n canvas.height = (this.canvasHeight * outputScale.sy) | 0;\n canvas.style.width = this.canvasWidth + 'px';\n canvas.style.height = this.canvasHeight + 'px';\n\n if (!noCtxScale && outputScale.scaled) {\n ctx.scale(outputScale.sx, outputScale.sy);\n }\n return ctx;\n }\n\n /**\n * @private\n */\n _convertCanvasToImage() {\n if (!this.canvas) {\n return;\n }\n if (this.renderingState !== RenderingStates.FINISHED) {\n return;\n }\n let id = this.renderingId;\n let className = 'thumbnailImage';\n\n if (this.disableCanvasToImageConversion) {\n this.canvas.id = id;\n this.canvas.className = className;\n this.l10n.get('thumb_page_canvas', { page: this.pageId, },\n 'Thumbnail of Page {{page}}').then((msg) => {\n this.canvas.setAttribute('aria-label', msg);\n });\n\n this.div.setAttribute('data-loaded', true);\n this.ring.appendChild(this.canvas);\n return;\n }\n let image = document.createElement('img');\n image.id = id;\n image.className = className;\n this.l10n.get('thumb_page_canvas', { page: this.pageId, },\n 'Thumbnail of Page {{page}}').\n then((msg) => {\n image.setAttribute('aria-label', msg);\n });\n\n image.style.width = this.canvasWidth + 'px';\n image.style.height = this.canvasHeight + 'px';\n\n image.src = this.canvas.toDataURL();\n this.image = image;\n\n this.div.setAttribute('data-loaded', true);\n this.ring.appendChild(image);\n\n // Zeroing the width and height causes Firefox to release graphics\n // resources immediately, which can greatly reduce memory consumption.\n this.canvas.width = 0;\n this.canvas.height = 0;\n delete this.canvas;\n }\n\n draw() {\n if (this.renderingState !== RenderingStates.INITIAL) {\n console.error('Must be in new state before drawing');\n return Promise.resolve(undefined);\n }\n this.renderingState = RenderingStates.RUNNING;\n\n let renderCapability = createPromiseCapability();\n let finishRenderTask = (error) => {\n // The renderTask may have been replaced by a new one, so only remove\n // the reference to the renderTask if it matches the one that is\n // triggering this callback.\n if (renderTask === this.renderTask) {\n this.renderTask = null;\n }\n\n if (error instanceof RenderingCancelledException) {\n renderCapability.resolve(undefined);\n return;\n }\n\n this.renderingState = RenderingStates.FINISHED;\n this._convertCanvasToImage();\n\n if (!error) {\n renderCapability.resolve(undefined);\n } else {\n renderCapability.reject(error);\n }\n };\n\n let ctx = this._getPageDrawContext();\n let drawViewport = this.viewport.clone({ scale: this.scale, });\n let renderContinueCallback = (cont) => {\n if (!this.renderingQueue.isHighestPriority(this)) {\n this.renderingState = RenderingStates.PAUSED;\n this.resume = () => {\n this.renderingState = RenderingStates.RUNNING;\n cont();\n };\n return;\n }\n cont();\n };\n\n let renderContext = {\n canvasContext: ctx,\n viewport: drawViewport,\n };\n let renderTask = this.renderTask = this.pdfPage.render(renderContext);\n renderTask.onContinue = renderContinueCallback;\n\n renderTask.promise.then(function() {\n finishRenderTask(null);\n }, function(error) {\n finishRenderTask(error);\n });\n return renderCapability.promise;\n }\n\n setImage(pageView) {\n if (this.renderingState !== RenderingStates.INITIAL) {\n return;\n }\n let img = pageView.canvas;\n if (!img) {\n return;\n }\n if (!this.pdfPage) {\n this.setPdfPage(pageView.pdfPage);\n }\n\n this.renderingState = RenderingStates.FINISHED;\n\n let ctx = this._getPageDrawContext(true);\n let canvas = ctx.canvas;\n if (img.width <= 2 * canvas.width) {\n ctx.drawImage(img, 0, 0, img.width, img.height,\n 0, 0, canvas.width, canvas.height);\n this._convertCanvasToImage();\n return;\n }\n\n // drawImage does an awful job of rescaling the image, doing it gradually.\n let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;\n let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;\n let reducedImage = TempImageFactory.getCanvas(reducedWidth,\n reducedHeight);\n let reducedImageCtx = reducedImage.getContext('2d');\n\n while (reducedWidth > img.width || reducedHeight > img.height) {\n reducedWidth >>= 1;\n reducedHeight >>= 1;\n }\n reducedImageCtx.drawImage(img, 0, 0, img.width, img.height,\n 0, 0, reducedWidth, reducedHeight);\n while (reducedWidth > 2 * canvas.width) {\n reducedImageCtx.drawImage(reducedImage,\n 0, 0, reducedWidth, reducedHeight,\n 0, 0, reducedWidth >> 1, reducedHeight >> 1);\n reducedWidth >>= 1;\n reducedHeight >>= 1;\n }\n ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight,\n 0, 0, canvas.width, canvas.height);\n this._convertCanvasToImage();\n }\n\n get pageId() {\n return (this.pageLabel !== null ? this.pageLabel : this.id);\n }\n\n /**\n * @param {string|null} label\n */\n setPageLabel(label) {\n this.pageLabel = (typeof label === 'string' ? label : null);\n\n this.l10n.get('thumb_page_title', { page: this.pageId, },\n 'Page {{page}}').then((msg) => {\n this.anchor.title = msg;\n });\n\n if (this.renderingState !== RenderingStates.FINISHED) {\n return;\n }\n\n this.l10n.get('thumb_page_canvas', { page: this.pageId, },\n 'Thumbnail of Page {{page}}').then((ariaLabel) => {\n if (this.image) {\n this.image.setAttribute('aria-label', ariaLabel);\n } else if (this.disableCanvasToImageConversion && this.canvas) {\n this.canvas.setAttribute('aria-label', ariaLabel);\n }\n });\n }\n\n static cleanup() {\n TempImageFactory.destroyCanvas();\n }\n}\n\nexport {\n PDFThumbnailView,\n};\n","/* Copyright 2014 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BaseViewer, ScrollMode } from './base_viewer';\nimport { getVisibleElements, scrollIntoView } from './ui_utils';\nimport { shadow } from 'pdfjs-lib';\n\nclass PDFViewer extends BaseViewer {\n get _setDocumentViewerElement() {\n return shadow(this, '_setDocumentViewerElement', this.viewer);\n }\n\n _scrollIntoView({ pageDiv, pageSpot = null, }) {\n if (!pageSpot && !this.isInPresentationMode) {\n const left = pageDiv.offsetLeft + pageDiv.clientLeft;\n const right = left + pageDiv.clientWidth;\n const { scrollLeft, clientWidth, } = this.container;\n if (this._scrollMode === ScrollMode.HORIZONTAL ||\n left < scrollLeft || right > scrollLeft + clientWidth) {\n pageSpot = { left: 0, top: 0, };\n }\n }\n scrollIntoView(pageDiv, pageSpot);\n }\n\n _getVisiblePages() {\n if (!this.isInPresentationMode) {\n return getVisibleElements(this.container, this._pages, true,\n this._scrollMode === ScrollMode.HORIZONTAL);\n }\n // The algorithm in getVisibleElements doesn't work in all browsers and\n // configurations when presentation mode is active.\n let currentPage = this._pages[this._currentPageNumber - 1];\n let visible = [{ id: currentPage.id, view: currentPage, }];\n return { first: currentPage, last: currentPage, views: visible, };\n }\n\n update() {\n let visible = this._getVisiblePages();\n let visiblePages = visible.views, numVisiblePages = visiblePages.length;\n\n if (numVisiblePages === 0) {\n return;\n }\n this._resizeBuffer(numVisiblePages, visiblePages);\n\n this.renderingQueue.renderHighestPriority(visible);\n\n let currentId = this._currentPageNumber;\n let stillFullyVisible = false;\n\n for (let i = 0; i < numVisiblePages; ++i) {\n let page = visiblePages[i];\n\n if (page.percent < 100) {\n break;\n }\n if (page.id === currentId) {\n stillFullyVisible = true;\n break;\n }\n }\n\n if (!stillFullyVisible) {\n currentId = visiblePages[0].id;\n }\n if (!this.isInPresentationMode) {\n this._setCurrentPageNumber(currentId);\n }\n\n this._updateLocation(visible.first);\n this.eventBus.dispatch('updateviewarea', {\n source: this,\n location: this._location,\n });\n }\n\n get _isScrollModeHorizontal() {\n // Used to ensure that pre-rendering of the next/previous page works\n // correctly, since Scroll/Spread modes are ignored in Presentation Mode.\n return (this.isInPresentationMode ?\n false : this._scrollMode === ScrollMode.HORIZONTAL);\n }\n}\n\nexport {\n PDFViewer,\n};\n","/* Copyright 2014 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CSS_UNITS, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, isPortraitOrientation,\n isValidRotation, MAX_AUTO_SCALE, moveToEndOfArray, NullL10n,\n PresentationModeState, RendererType, SCROLLBAR_PADDING, TextLayerMode,\n UNKNOWN_SCALE, VERTICAL_PADDING, watchScroll\n} from './ui_utils';\nimport { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';\nimport { AnnotationLayerBuilder } from './annotation_layer_builder';\nimport { createPromiseCapability } from 'pdfjs-lib';\nimport { getGlobalEventBus } from './dom_events';\nimport { PDFPageView } from './pdf_page_view';\nimport { SimpleLinkService } from './pdf_link_service';\nimport { TextLayerBuilder } from './text_layer_builder';\n\nconst DEFAULT_CACHE_SIZE = 10;\n\nconst ScrollMode = {\n VERTICAL: 0, // The default value.\n HORIZONTAL: 1,\n WRAPPED: 2,\n};\n\nconst SpreadMode = {\n NONE: 0, // The default value.\n ODD: 1,\n EVEN: 2,\n};\n\n/**\n * @typedef {Object} PDFViewerOptions\n * @property {HTMLDivElement} container - The container for the viewer element.\n * @property {HTMLDivElement} viewer - (optional) The viewer element.\n * @property {EventBus} eventBus - The application event bus.\n * @property {IPDFLinkService} linkService - The navigation/linking service.\n * @property {DownloadManager} downloadManager - (optional) The download\n * manager component.\n * @property {PDFFindController} findController - (optional) The find\n * controller component.\n * @property {PDFRenderingQueue} renderingQueue - (optional) The rendering\n * queue object.\n * @property {boolean} removePageBorders - (optional) Removes the border shadow\n * around the pages. The default value is `false`.\n * @property {number} textLayerMode - (optional) Controls if the text layer used\n * for selection and searching is created, and if the improved text selection\n * behaviour is enabled. The constants from {TextLayerMode} should be used.\n * The default value is `TextLayerMode.ENABLE`.\n * @property {string} imageResourcesPath - (optional) Path for image resources,\n * mainly for annotation icons. Include trailing slash.\n * @property {boolean} renderInteractiveForms - (optional) Enables rendering of\n * interactive form elements. The default is `false`.\n * @property {boolean} enablePrintAutoRotate - (optional) Enables automatic\n * rotation of pages whose orientation differ from the first page upon\n * printing. The default is `false`.\n * @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.\n * @property {boolean} enableWebGL - (optional) Enables WebGL accelerated\n * rendering for some operations. The default value is `false`.\n * @property {boolean} useOnlyCssZoom - (optional) Enables CSS only zooming.\n * The default value is `false`.\n * @property {number} maxCanvasPixels - (optional) The maximum supported canvas\n * size in total pixels, i.e. width * height. Use -1 for no limit.\n * The default value is 4096 * 4096 (16 mega-pixels).\n * @property {IL10n} l10n - Localization service.\n */\n\nfunction PDFPageViewBuffer(size) {\n let data = [];\n this.push = function(view) {\n let i = data.indexOf(view);\n if (i >= 0) {\n data.splice(i, 1);\n }\n data.push(view);\n if (data.length > size) {\n data.shift().destroy();\n }\n };\n /**\n * After calling resize, the size of the buffer will be newSize. The optional\n * parameter pagesToKeep is, if present, an array of pages to push to the back\n * of the buffer, delaying their destruction. The size of pagesToKeep has no\n * impact on the final size of the buffer; if pagesToKeep has length larger\n * than newSize, some of those pages will be destroyed anyway.\n */\n this.resize = function(newSize, pagesToKeep) {\n size = newSize;\n if (pagesToKeep) {\n const pageIdsToKeep = new Set();\n for (let i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {\n pageIdsToKeep.add(pagesToKeep[i].id);\n }\n moveToEndOfArray(data, function(page) {\n return pageIdsToKeep.has(page.id);\n });\n }\n while (data.length > size) {\n data.shift().destroy();\n }\n };\n}\n\nfunction isSameScale(oldScale, newScale) {\n if (newScale === oldScale) {\n return true;\n }\n if (Math.abs(newScale - oldScale) < 1e-15) {\n // Prevent unnecessary re-rendering of all pages when the scale\n // changes only because of limited numerical precision.\n return true;\n }\n return false;\n}\n\n/**\n * Simple viewer control to display PDF content/pages.\n * @implements {IRenderableView}\n */\nclass BaseViewer {\n /**\n * @param {PDFViewerOptions} options\n */\n constructor(options) {\n if (this.constructor === BaseViewer) {\n throw new Error('Cannot initialize BaseViewer.');\n }\n this._name = this.constructor.name;\n\n this.container = options.container;\n this.viewer = options.viewer || options.container.firstElementChild;\n this.eventBus = options.eventBus || getGlobalEventBus();\n this.linkService = options.linkService || new SimpleLinkService();\n this.downloadManager = options.downloadManager || null;\n this.findController = options.findController || null;\n this.removePageBorders = options.removePageBorders || false;\n this.textLayerMode = Number.isInteger(options.textLayerMode) ?\n options.textLayerMode : TextLayerMode.ENABLE;\n this.imageResourcesPath = options.imageResourcesPath || '';\n this.renderInteractiveForms = options.renderInteractiveForms || false;\n this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;\n this.renderer = options.renderer || RendererType.CANVAS;\n this.enableWebGL = options.enableWebGL || false;\n this.useOnlyCssZoom = options.useOnlyCssZoom || false;\n this.maxCanvasPixels = options.maxCanvasPixels;\n this.l10n = options.l10n || NullL10n;\n\n this.defaultRenderingQueue = !options.renderingQueue;\n if (this.defaultRenderingQueue) {\n // Custom rendering queue is not specified, using default one\n this.renderingQueue = new PDFRenderingQueue();\n this.renderingQueue.setViewer(this);\n } else {\n this.renderingQueue = options.renderingQueue;\n }\n\n this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this));\n this.presentationModeState = PresentationModeState.UNKNOWN;\n this._resetView();\n\n if (this.removePageBorders) {\n this.viewer.classList.add('removePageBorders');\n }\n // Defer the dispatching of this event, to give other viewer components\n // time to initialize *and* register 'baseviewerinit' event listeners.\n Promise.resolve().then(() => {\n this.eventBus.dispatch('baseviewerinit', { source: this, });\n });\n }\n\n get pagesCount() {\n return this._pages.length;\n }\n\n getPageView(index) {\n return this._pages[index];\n }\n\n /**\n * @returns {boolean} true if all {PDFPageView} objects are initialized.\n */\n get pageViewsReady() {\n return this._pageViewsReady;\n }\n\n /**\n * @returns {number}\n */\n get currentPageNumber() {\n return this._currentPageNumber;\n }\n\n /**\n * @param {number} val - The page number.\n */\n set currentPageNumber(val) {\n if (!Number.isInteger(val)) {\n throw new Error('Invalid page number.');\n }\n if (!this.pdfDocument) {\n return;\n }\n // The intent can be to just reset a scroll position and/or scale.\n this._setCurrentPageNumber(val, /* resetCurrentPageView = */ true);\n }\n\n /**\n * @private\n */\n _setCurrentPageNumber(val, resetCurrentPageView = false) {\n if (this._currentPageNumber === val) {\n if (resetCurrentPageView) {\n this._resetCurrentPageView();\n }\n return;\n }\n\n if (!(0 < val && val <= this.pagesCount)) {\n console.error(\n `${this._name}._setCurrentPageNumber: \"${val}\" is out of bounds.`);\n return;\n }\n\n let arg = {\n source: this,\n pageNumber: val,\n pageLabel: this._pageLabels && this._pageLabels[val - 1],\n };\n this._currentPageNumber = val;\n this.eventBus.dispatch('pagechanging', arg);\n this.eventBus.dispatch('pagechange', arg);\n\n if (resetCurrentPageView) {\n this._resetCurrentPageView();\n }\n }\n\n /**\n * @returns {string|null} Returns the current page label,\n * or `null` if no page labels exist.\n */\n get currentPageLabel() {\n return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];\n }\n\n /**\n * @param {string} val - The page label.\n */\n set currentPageLabel(val) {\n let pageNumber = val | 0; // Fallback page number.\n if (this._pageLabels) {\n let i = this._pageLabels.indexOf(val);\n if (i >= 0) {\n pageNumber = i + 1;\n }\n }\n this.currentPageNumber = pageNumber;\n }\n\n /**\n * @returns {number}\n */\n get currentScale() {\n return this._currentScale !== UNKNOWN_SCALE ? this._currentScale :\n DEFAULT_SCALE;\n }\n\n /**\n * @param {number} val - Scale of the pages in percents.\n */\n set currentScale(val) {\n if (isNaN(val)) {\n throw new Error('Invalid numeric scale');\n }\n if (!this.pdfDocument) {\n return;\n }\n this._setScale(val, false);\n }\n\n /**\n * @returns {string}\n */\n get currentScaleValue() {\n return this._currentScaleValue;\n }\n\n /**\n * @param val - The scale of the pages (in percent or predefined value).\n */\n set currentScaleValue(val) {\n if (!this.pdfDocument) {\n return;\n }\n this._setScale(val, false);\n }\n\n /**\n * @returns {number}\n */\n get pagesRotation() {\n return this._pagesRotation;\n }\n\n /**\n * @param {number} rotation - The rotation of the pages (0, 90, 180, 270).\n */\n set pagesRotation(rotation) {\n if (!isValidRotation(rotation)) {\n throw new Error('Invalid pages rotation angle.');\n }\n if (!this.pdfDocument) {\n return;\n }\n if (this._pagesRotation === rotation) {\n return; // The rotation didn't change.\n }\n this._pagesRotation = rotation;\n\n let pageNumber = this._currentPageNumber;\n\n for (let i = 0, ii = this._pages.length; i < ii; i++) {\n let pageView = this._pages[i];\n pageView.update(pageView.scale, rotation);\n }\n // Prevent errors in case the rotation changes *before* the scale has been\n // set to a non-default value.\n if (this._currentScaleValue) {\n this._setScale(this._currentScaleValue, true);\n }\n\n this.eventBus.dispatch('rotationchanging', {\n source: this,\n pagesRotation: rotation,\n pageNumber,\n });\n\n if (this.defaultRenderingQueue) {\n this.update();\n }\n }\n\n get _setDocumentViewerElement() {\n throw new Error('Not implemented: _setDocumentViewerElement');\n }\n\n /**\n * @param pdfDocument {PDFDocument}\n */\n setDocument(pdfDocument) {\n if (this.pdfDocument) {\n this._cancelRendering();\n this._resetView();\n\n if (this.findController) {\n this.findController.setDocument(null);\n }\n }\n\n this.pdfDocument = pdfDocument;\n if (!pdfDocument) {\n return;\n }\n let pagesCount = pdfDocument.numPages;\n\n let pagesCapability = createPromiseCapability();\n this.pagesPromise = pagesCapability.promise;\n\n pagesCapability.promise.then(() => {\n this._pageViewsReady = true;\n this.eventBus.dispatch('pagesloaded', {\n source: this,\n pagesCount,\n });\n });\n\n let isOnePageRenderedResolved = false;\n let onePageRenderedCapability = createPromiseCapability();\n this.onePageRendered = onePageRenderedCapability.promise;\n\n let bindOnAfterAndBeforeDraw = (pageView) => {\n pageView.onBeforeDraw = () => {\n // Add the page to the buffer at the start of drawing. That way it can\n // be evicted from the buffer and destroyed even if we pause its\n // rendering.\n this._buffer.push(pageView);\n };\n pageView.onAfterDraw = () => {\n if (!isOnePageRenderedResolved) {\n isOnePageRenderedResolved = true;\n onePageRenderedCapability.resolve();\n }\n };\n };\n\n let firstPagePromise = pdfDocument.getPage(1);\n this.firstPagePromise = firstPagePromise;\n\n // Fetch a single page so we can get a viewport that will be the default\n // viewport for all pages\n firstPagePromise.then((pdfPage) => {\n let scale = this.currentScale;\n let viewport = pdfPage.getViewport(scale * CSS_UNITS);\n for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {\n let textLayerFactory = null;\n if (this.textLayerMode !== TextLayerMode.DISABLE) {\n textLayerFactory = this;\n }\n let pageView = new PDFPageView({\n container: this._setDocumentViewerElement,\n eventBus: this.eventBus,\n id: pageNum,\n scale,\n defaultViewport: viewport.clone(),\n renderingQueue: this.renderingQueue,\n textLayerFactory,\n textLayerMode: this.textLayerMode,\n annotationLayerFactory: this,\n imageResourcesPath: this.imageResourcesPath,\n renderInteractiveForms: this.renderInteractiveForms,\n renderer: this.renderer,\n enableWebGL: this.enableWebGL,\n useOnlyCssZoom: this.useOnlyCssZoom,\n maxCanvasPixels: this.maxCanvasPixels,\n l10n: this.l10n,\n });\n bindOnAfterAndBeforeDraw(pageView);\n this._pages.push(pageView);\n }\n if (this._spreadMode !== SpreadMode.NONE) {\n this._updateSpreadMode();\n }\n\n // Fetch all the pages since the viewport is needed before printing\n // starts to create the correct size canvas. Wait until one page is\n // rendered so we don't tie up too many resources early on.\n onePageRenderedCapability.promise.then(() => {\n if (pdfDocument.loadingParams['disableAutoFetch']) {\n // XXX: Printing is semi-broken with auto fetch disabled.\n pagesCapability.resolve();\n return;\n }\n let getPagesLeft = pagesCount;\n for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {\n pdfDocument.getPage(pageNum).then((pdfPage) => {\n let pageView = this._pages[pageNum - 1];\n if (!pageView.pdfPage) {\n pageView.setPdfPage(pdfPage);\n }\n this.linkService.cachePageRef(pageNum, pdfPage.ref);\n if (--getPagesLeft === 0) {\n pagesCapability.resolve();\n }\n }, (reason) => {\n console.error(`Unable to get page ${pageNum} to initialize viewer`,\n reason);\n if (--getPagesLeft === 0) {\n pagesCapability.resolve();\n }\n });\n }\n });\n\n this.eventBus.dispatch('pagesinit', { source: this, });\n\n if (this.findController) {\n this.findController.setDocument(pdfDocument); // Enable searching.\n }\n if (this.defaultRenderingQueue) {\n this.update();\n }\n }).catch((reason) => {\n console.error('Unable to initialize viewer', reason);\n });\n }\n\n /**\n * @param {Array|null} labels\n */\n setPageLabels(labels) {\n if (!this.pdfDocument) {\n return;\n }\n if (!labels) {\n this._pageLabels = null;\n } else if (!(Array.isArray(labels) &&\n this.pdfDocument.numPages === labels.length)) {\n this._pageLabels = null;\n console.error(`${this._name}.setPageLabels: Invalid page labels.`);\n } else {\n this._pageLabels = labels;\n }\n // Update all the `PDFPageView` instances.\n for (let i = 0, ii = this._pages.length; i < ii; i++) {\n let pageView = this._pages[i];\n let label = this._pageLabels && this._pageLabels[i];\n pageView.setPageLabel(label);\n }\n }\n\n _resetView() {\n this._pages = [];\n this._currentPageNumber = 1;\n this._currentScale = UNKNOWN_SCALE;\n this._currentScaleValue = null;\n this._pageLabels = null;\n this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);\n this._location = null;\n this._pagesRotation = 0;\n this._pagesRequests = [];\n this._pageViewsReady = false;\n this._scrollMode = ScrollMode.VERTICAL;\n this._spreadMode = SpreadMode.NONE;\n\n // Remove the pages from the DOM...\n this.viewer.textContent = '';\n // ... and reset the Scroll mode CSS class(es) afterwards.\n this._updateScrollMode();\n }\n\n _scrollUpdate() {\n if (this.pagesCount === 0) {\n return;\n }\n this.update();\n }\n\n _scrollIntoView({ pageDiv, pageSpot = null, pageNumber = null, }) {\n throw new Error('Not implemented: _scrollIntoView');\n }\n\n _setScaleDispatchEvent(newScale, newValue, preset = false) {\n let arg = {\n source: this,\n scale: newScale,\n presetValue: preset ? newValue : undefined,\n };\n this.eventBus.dispatch('scalechanging', arg);\n this.eventBus.dispatch('scalechange', arg);\n }\n\n _setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) {\n this._currentScaleValue = newValue.toString();\n\n if (isSameScale(this._currentScale, newScale)) {\n if (preset) {\n this._setScaleDispatchEvent(newScale, newValue, true);\n }\n return;\n }\n\n for (let i = 0, ii = this._pages.length; i < ii; i++) {\n this._pages[i].update(newScale);\n }\n this._currentScale = newScale;\n\n if (!noScroll) {\n let page = this._currentPageNumber, dest;\n if (this._location &&\n !(this.isInPresentationMode || this.isChangingPresentationMode)) {\n page = this._location.pageNumber;\n dest = [null, { name: 'XYZ', }, this._location.left,\n this._location.top, null];\n }\n this.scrollPageIntoView({\n pageNumber: page,\n destArray: dest,\n allowNegativeOffset: true,\n });\n }\n\n this._setScaleDispatchEvent(newScale, newValue, preset);\n\n if (this.defaultRenderingQueue) {\n this.update();\n }\n }\n\n _setScale(value, noScroll = false) {\n let scale = parseFloat(value);\n\n if (scale > 0) {\n this._setScaleUpdatePages(scale, value, noScroll, /* preset = */ false);\n } else {\n let currentPage = this._pages[this._currentPageNumber - 1];\n if (!currentPage) {\n return;\n }\n const noPadding = (this.isInPresentationMode || this.removePageBorders);\n let hPadding = noPadding ? 0 : SCROLLBAR_PADDING;\n let vPadding = noPadding ? 0 : VERTICAL_PADDING;\n\n if (!noPadding && this._isScrollModeHorizontal) {\n [hPadding, vPadding] = [vPadding, hPadding]; // Swap the padding values.\n }\n let pageWidthScale = (this.container.clientWidth - hPadding) /\n currentPage.width * currentPage.scale;\n let pageHeightScale = (this.container.clientHeight - vPadding) /\n currentPage.height * currentPage.scale;\n switch (value) {\n case 'page-actual':\n scale = 1;\n break;\n case 'page-width':\n scale = pageWidthScale;\n break;\n case 'page-height':\n scale = pageHeightScale;\n break;\n case 'page-fit':\n scale = Math.min(pageWidthScale, pageHeightScale);\n break;\n case 'auto':\n // For pages in landscape mode, fit the page height to the viewer\n // *unless* the page would thus become too wide to fit horizontally.\n let horizontalScale = isPortraitOrientation(currentPage) ?\n pageWidthScale : Math.min(pageHeightScale, pageWidthScale);\n scale = Math.min(MAX_AUTO_SCALE, horizontalScale);\n break;\n default:\n console.error(\n `${this._name}._setScale: \"${value}\" is an unknown zoom value.`);\n return;\n }\n this._setScaleUpdatePages(scale, value, noScroll, /* preset = */ true);\n }\n }\n\n /**\n * Refreshes page view: scrolls to the current page and updates the scale.\n * @private\n */\n _resetCurrentPageView() {\n if (this.isInPresentationMode) {\n // Fixes the case when PDF has different page sizes.\n this._setScale(this._currentScaleValue, true);\n }\n\n let pageView = this._pages[this._currentPageNumber - 1];\n this._scrollIntoView({ pageDiv: pageView.div, });\n }\n\n /**\n * @typedef ScrollPageIntoViewParameters\n * @property {number} pageNumber - The page number.\n * @property {Array} destArray - (optional) The original PDF destination\n * array, in the format: <page-ref> </XYZ|/FitXXX> <args..>\n * @property {boolean} allowNegativeOffset - (optional) Allow negative page\n * offsets. The default value is `false`.\n */\n\n /**\n * Scrolls page into view.\n * @param {ScrollPageIntoViewParameters} params\n */\n scrollPageIntoView(params) {\n if (!this.pdfDocument) {\n return;\n }\n let pageNumber = params.pageNumber || 0;\n let dest = params.destArray || null;\n let allowNegativeOffset = params.allowNegativeOffset || false;\n\n if (this.isInPresentationMode || !dest) {\n this._setCurrentPageNumber(pageNumber, /* resetCurrentPageView = */ true);\n return;\n }\n\n let pageView = this._pages[pageNumber - 1];\n if (!pageView) {\n console.error(\n `${this._name}.scrollPageIntoView: Invalid \"pageNumber\" parameter.`);\n return;\n }\n let x = 0, y = 0;\n let width = 0, height = 0, widthScale, heightScale;\n let changeOrientation = (pageView.rotation % 180 === 0 ? false : true);\n let pageWidth = (changeOrientation ? pageView.height : pageView.width) /\n pageView.scale / CSS_UNITS;\n let pageHeight = (changeOrientation ? pageView.width : pageView.height) /\n pageView.scale / CSS_UNITS;\n let scale = 0;\n switch (dest[1].name) {\n case 'XYZ':\n x = dest[2];\n y = dest[3];\n scale = dest[4];\n // If x and/or y coordinates are not supplied, default to\n // _top_ left of the page (not the obvious bottom left,\n // since aligning the bottom of the intended page with the\n // top of the window is rarely helpful).\n x = x !== null ? x : 0;\n y = y !== null ? y : pageHeight;\n break;\n case 'Fit':\n case 'FitB':\n scale = 'page-fit';\n break;\n case 'FitH':\n case 'FitBH':\n y = dest[2];\n scale = 'page-width';\n // According to the PDF spec, section 12.3.2.2, a `null` value in the\n // parameter should maintain the position relative to the new page.\n if (y === null && this._location) {\n x = this._location.left;\n y = this._location.top;\n }\n break;\n case 'FitV':\n case 'FitBV':\n x = dest[2];\n width = pageWidth;\n height = pageHeight;\n scale = 'page-height';\n break;\n case 'FitR':\n x = dest[2];\n y = dest[3];\n width = dest[4] - x;\n height = dest[5] - y;\n let hPadding = this.removePageBorders ? 0 : SCROLLBAR_PADDING;\n let vPadding = this.removePageBorders ? 0 : VERTICAL_PADDING;\n\n widthScale = (this.container.clientWidth - hPadding) /\n width / CSS_UNITS;\n heightScale = (this.container.clientHeight - vPadding) /\n height / CSS_UNITS;\n scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));\n break;\n default:\n console.error(`${this._name}.scrollPageIntoView: \"${dest[1].name}\" ` +\n 'is not a valid destination type.');\n return;\n }\n\n if (scale && scale !== this._currentScale) {\n this.currentScaleValue = scale;\n } else if (this._currentScale === UNKNOWN_SCALE) {\n this.currentScaleValue = DEFAULT_SCALE_VALUE;\n }\n\n if (scale === 'page-fit' && !dest[4]) {\n this._scrollIntoView({\n pageDiv: pageView.div,\n pageNumber,\n });\n return;\n }\n\n let boundingRect = [\n pageView.viewport.convertToViewportPoint(x, y),\n pageView.viewport.convertToViewportPoint(x + width, y + height)\n ];\n let left = Math.min(boundingRect[0][0], boundingRect[1][0]);\n let top = Math.min(boundingRect[0][1], boundingRect[1][1]);\n\n if (!allowNegativeOffset) {\n // Some bad PDF generators will create destinations with e.g. top values\n // that exceeds the page height. Ensure that offsets are not negative,\n // to prevent a previous page from becoming visible (fixes bug 874482).\n left = Math.max(left, 0);\n top = Math.max(top, 0);\n }\n this._scrollIntoView({\n pageDiv: pageView.div,\n pageSpot: { left, top, },\n pageNumber,\n });\n }\n\n /**\n * visiblePages is optional; if present, it should be an array of pages and in\n * practice its length is going to be numVisiblePages, but this is not\n * required. The new size of the buffer depends only on numVisiblePages.\n */\n _resizeBuffer(numVisiblePages, visiblePages) {\n let suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE,\n 2 * numVisiblePages + 1);\n this._buffer.resize(suggestedCacheSize, visiblePages);\n }\n\n _updateLocation(firstPage) {\n let currentScale = this._currentScale;\n let currentScaleValue = this._currentScaleValue;\n let normalizedScaleValue =\n parseFloat(currentScaleValue) === currentScale ?\n Math.round(currentScale * 10000) / 100 : currentScaleValue;\n\n let pageNumber = firstPage.id;\n let pdfOpenParams = '#page=' + pageNumber;\n pdfOpenParams += '&zoom=' + normalizedScaleValue;\n let currentPageView = this._pages[pageNumber - 1];\n let container = this.container;\n let topLeft = currentPageView.getPagePoint(\n (container.scrollLeft - firstPage.x),\n (container.scrollTop - firstPage.y));\n let intLeft = Math.round(topLeft[0]);\n let intTop = Math.round(topLeft[1]);\n pdfOpenParams += ',' + intLeft + ',' + intTop;\n\n this._location = {\n pageNumber,\n scale: normalizedScaleValue,\n top: intTop,\n left: intLeft,\n rotation: this._pagesRotation,\n pdfOpenParams,\n };\n }\n\n update() {\n throw new Error('Not implemented: update');\n }\n\n containsElement(element) {\n return this.container.contains(element);\n }\n\n focus() {\n this.container.focus();\n }\n\n get _isScrollModeHorizontal() {\n throw new Error('Not implemented: _isScrollModeHorizontal');\n }\n\n get isInPresentationMode() {\n return this.presentationModeState === PresentationModeState.FULLSCREEN;\n }\n\n get isChangingPresentationMode() {\n return this.presentationModeState === PresentationModeState.CHANGING;\n }\n\n get isHorizontalScrollbarEnabled() {\n return (this.isInPresentationMode ?\n false : (this.container.scrollWidth > this.container.clientWidth));\n }\n\n get isVerticalScrollbarEnabled() {\n return (this.isInPresentationMode ?\n false : (this.container.scrollHeight > this.container.clientHeight));\n }\n\n _getVisiblePages() {\n throw new Error('Not implemented: _getVisiblePages');\n }\n\n cleanup() {\n for (let i = 0, ii = this._pages.length; i < ii; i++) {\n if (this._pages[i] &&\n this._pages[i].renderingState !== RenderingStates.FINISHED) {\n this._pages[i].reset();\n }\n }\n }\n\n /**\n * @private\n */\n _cancelRendering() {\n for (let i = 0, ii = this._pages.length; i < ii; i++) {\n if (this._pages[i]) {\n this._pages[i].cancelRendering();\n }\n }\n }\n\n /**\n * @param {PDFPageView} pageView\n * @returns {Promise} Returns a promise containing a {PDFPageProxy} object.\n * @private\n */\n _ensurePdfPageLoaded(pageView) {\n if (pageView.pdfPage) {\n return Promise.resolve(pageView.pdfPage);\n }\n let pageNumber = pageView.id;\n if (this._pagesRequests[pageNumber]) {\n return this._pagesRequests[pageNumber];\n }\n let promise = this.pdfDocument.getPage(pageNumber).then((pdfPage) => {\n if (!pageView.pdfPage) {\n pageView.setPdfPage(pdfPage);\n }\n this._pagesRequests[pageNumber] = null;\n return pdfPage;\n }).catch((reason) => {\n console.error('Unable to get page for page view', reason);\n // Page error -- there is nothing can be done.\n this._pagesRequests[pageNumber] = null;\n });\n this._pagesRequests[pageNumber] = promise;\n return promise;\n }\n\n forceRendering(currentlyVisiblePages) {\n let visiblePages = currentlyVisiblePages || this._getVisiblePages();\n let scrollAhead = (this._isScrollModeHorizontal ?\n this.scroll.right : this.scroll.down);\n let pageView = this.renderingQueue.getHighestPriority(visiblePages,\n this._pages,\n scrollAhead);\n if (pageView) {\n this._ensurePdfPageLoaded(pageView).then(() => {\n this.renderingQueue.renderView(pageView);\n });\n return true;\n }\n return false;\n }\n\n /**\n * @param {HTMLDivElement} textLayerDiv\n * @param {number} pageIndex\n * @param {PageViewport} viewport\n * @returns {TextLayerBuilder}\n */\n createTextLayerBuilder(textLayerDiv, pageIndex, viewport,\n enhanceTextSelection = false) {\n return new TextLayerBuilder({\n textLayerDiv,\n eventBus: this.eventBus,\n pageIndex,\n viewport,\n findController: this.isInPresentationMode ? null : this.findController,\n enhanceTextSelection: this.isInPresentationMode ? false :\n enhanceTextSelection,\n });\n }\n\n /**\n * @param {HTMLDivElement} pageDiv\n * @param {PDFPage} pdfPage\n * @param {string} imageResourcesPath - (optional) Path for image resources,\n * mainly for annotation icons. Include trailing slash.\n * @param {boolean} renderInteractiveForms\n * @param {IL10n} l10n\n * @returns {AnnotationLayerBuilder}\n */\n createAnnotationLayerBuilder(pageDiv, pdfPage, imageResourcesPath = '',\n renderInteractiveForms = false,\n l10n = NullL10n) {\n return new AnnotationLayerBuilder({\n pageDiv,\n pdfPage,\n imageResourcesPath,\n renderInteractiveForms,\n linkService: this.linkService,\n downloadManager: this.downloadManager,\n l10n,\n });\n }\n\n /**\n * @returns {boolean} Whether all pages of the PDF document have identical\n * widths and heights.\n */\n get hasEqualPageSizes() {\n let firstPageView = this._pages[0];\n for (let i = 1, ii = this._pages.length; i < ii; ++i) {\n let pageView = this._pages[i];\n if (pageView.width !== firstPageView.width ||\n pageView.height !== firstPageView.height) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Returns sizes of the pages.\n * @returns {Array} Array of objects with width/height/rotation fields.\n */\n getPagesOverview() {\n let pagesOverview = this._pages.map(function(pageView) {\n let viewport = pageView.pdfPage.getViewport(1);\n return {\n width: viewport.width,\n height: viewport.height,\n rotation: viewport.rotation,\n };\n });\n if (!this.enablePrintAutoRotate) {\n return pagesOverview;\n }\n let isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);\n return pagesOverview.map(function (size) {\n if (isFirstPagePortrait === isPortraitOrientation(size)) {\n return size;\n }\n return {\n width: size.height,\n height: size.width,\n rotation: (size.rotation + 90) % 360,\n };\n });\n }\n\n /**\n * @return {number} One of the values in {ScrollMode}.\n */\n get scrollMode() {\n return this._scrollMode;\n }\n\n /**\n * @param {number} mode - The direction in which the document pages should be\n * laid out within the scrolling container.\n * The constants from {ScrollMode} should be used.\n */\n set scrollMode(mode) {\n if (this._scrollMode === mode) {\n return; // The Scroll mode didn't change.\n }\n if (!Number.isInteger(mode) || !Object.values(ScrollMode).includes(mode)) {\n throw new Error(`Invalid scroll mode: ${mode}`);\n }\n this._scrollMode = mode;\n this.eventBus.dispatch('scrollmodechanged', { source: this, mode, });\n\n this._updateScrollMode(/* pageNumber = */ this._currentPageNumber);\n }\n\n _updateScrollMode(pageNumber = null) {\n const scrollMode = this._scrollMode, viewer = this.viewer;\n\n viewer.classList.toggle('scrollHorizontal',\n scrollMode === ScrollMode.HORIZONTAL);\n viewer.classList.toggle('scrollWrapped',\n scrollMode === ScrollMode.WRAPPED);\n\n if (!this.pdfDocument || !pageNumber) {\n return;\n }\n // Non-numeric scale values can be sensitive to the scroll orientation.\n // Call this before re-scrolling to the current page, to ensure that any\n // changes in scale don't move the current page.\n if (this._currentScaleValue && isNaN(this._currentScaleValue)) {\n this._setScale(this._currentScaleValue, true);\n }\n this.scrollPageIntoView({ pageNumber, });\n this.update();\n }\n\n /**\n * @return {number} One of the values in {SpreadMode}.\n */\n get spreadMode() {\n return this._spreadMode;\n }\n\n /**\n * @param {number} mode - Group the pages in spreads, starting with odd- or\n * even-number pages (unless `SpreadMode.NONE` is used).\n * The constants from {SpreadMode} should be used.\n */\n set spreadMode(mode) {\n if (this._spreadMode === mode) {\n return; // The Spread mode didn't change.\n }\n if (!Number.isInteger(mode) || !Object.values(SpreadMode).includes(mode)) {\n throw new Error(`Invalid spread mode: ${mode}`);\n }\n this._spreadMode = mode;\n this.eventBus.dispatch('spreadmodechanged', { source: this, mode, });\n\n this._updateSpreadMode(/* pageNumber = */ this._currentPageNumber);\n }\n\n _updateSpreadMode(pageNumber = null) {\n if (!this.pdfDocument) {\n return;\n }\n const viewer = this.viewer, pages = this._pages;\n // Temporarily remove all the pages from the DOM.\n viewer.textContent = '';\n\n if (this._spreadMode === SpreadMode.NONE) {\n for (let i = 0, iMax = pages.length; i < iMax; ++i) {\n viewer.appendChild(pages[i].div);\n }\n } else {\n const parity = this._spreadMode - 1;\n let spread = null;\n for (let i = 0, iMax = pages.length; i < iMax; ++i) {\n if (spread === null) {\n spread = document.createElement('div');\n spread.className = 'spread';\n viewer.appendChild(spread);\n } else if (i % 2 === parity) {\n spread = spread.cloneNode(false);\n viewer.appendChild(spread);\n }\n spread.appendChild(pages[i].div);\n }\n }\n\n if (!pageNumber) {\n return;\n }\n this.scrollPageIntoView({ pageNumber, });\n this.update();\n }\n}\n\nexport {\n BaseViewer,\n ScrollMode,\n SpreadMode,\n};\n","/* Copyright 2014 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AnnotationLayer } from 'pdfjs-lib';\nimport { NullL10n } from './ui_utils';\nimport { SimpleLinkService } from './pdf_link_service';\n\n/**\n * @typedef {Object} AnnotationLayerBuilderOptions\n * @property {HTMLDivElement} pageDiv\n * @property {PDFPage} pdfPage\n * @property {string} imageResourcesPath - (optional) Path for image resources,\n * mainly for annotation icons. Include trailing slash.\n * @property {boolean} renderInteractiveForms\n * @property {IPDFLinkService} linkService\n * @property {DownloadManager} downloadManager\n * @property {IL10n} l10n - Localization service.\n */\n\nclass AnnotationLayerBuilder {\n /**\n * @param {AnnotationLayerBuilderOptions} options\n */\n constructor({ pageDiv, pdfPage, linkService, downloadManager,\n imageResourcesPath = '', renderInteractiveForms = false,\n l10n = NullL10n, }) {\n this.pageDiv = pageDiv;\n this.pdfPage = pdfPage;\n this.linkService = linkService;\n this.downloadManager = downloadManager;\n this.imageResourcesPath = imageResourcesPath;\n this.renderInteractiveForms = renderInteractiveForms;\n this.l10n = l10n;\n\n this.div = null;\n this._cancelled = false;\n }\n\n /**\n * @param {PageViewport} viewport\n * @param {string} intent (default value is 'display')\n */\n render(viewport, intent = 'display') {\n this.pdfPage.getAnnotations({ intent, }).then((annotations) => {\n if (this._cancelled) {\n return;\n }\n\n let parameters = {\n viewport: viewport.clone({ dontFlip: true, }),\n div: this.div,\n annotations,\n page: this.pdfPage,\n imageResourcesPath: this.imageResourcesPath,\n renderInteractiveForms: this.renderInteractiveForms,\n linkService: this.linkService,\n downloadManager: this.downloadManager,\n };\n\n if (this.div) {\n // If an annotationLayer already exists, refresh its children's\n // transformation matrices.\n AnnotationLayer.update(parameters);\n } else {\n // Create an annotation layer div and render the annotations\n // if there is at least one annotation.\n if (annotations.length === 0) {\n return;\n }\n this.div = document.createElement('div');\n this.div.className = 'annotationLayer';\n this.pageDiv.appendChild(this.div);\n parameters.div = this.div;\n\n AnnotationLayer.render(parameters);\n this.l10n.translate(this.div);\n }\n });\n }\n\n cancel() {\n this._cancelled = true;\n }\n\n hide() {\n if (!this.div) {\n return;\n }\n this.div.setAttribute('hidden', 'true');\n }\n}\n\n/**\n * @implements IPDFAnnotationLayerFactory\n */\nclass DefaultAnnotationLayerFactory {\n /**\n * @param {HTMLDivElement} pageDiv\n * @param {PDFPage} pdfPage\n * @param {string} imageResourcesPath - (optional) Path for image resources,\n * mainly for annotation icons. Include trailing slash.\n * @param {boolean} renderInteractiveForms\n * @param {IL10n} l10n\n * @returns {AnnotationLayerBuilder}\n */\n createAnnotationLayerBuilder(pageDiv, pdfPage, imageResourcesPath = '',\n renderInteractiveForms = false,\n l10n = NullL10n) {\n return new AnnotationLayerBuilder({\n pageDiv,\n pdfPage,\n imageResourcesPath,\n renderInteractiveForms,\n linkService: new SimpleLinkService(),\n l10n,\n });\n }\n}\n\nexport {\n AnnotationLayerBuilder,\n DefaultAnnotationLayerFactory,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n approximateFraction, CSS_UNITS, DEFAULT_SCALE, getOutputScale, NullL10n,\n RendererType, roundToDivide, TextLayerMode\n} from './ui_utils';\nimport {\n createPromiseCapability, RenderingCancelledException, SVGGraphics\n} from 'pdfjs-lib';\nimport { getGlobalEventBus } from './dom_events';\nimport { RenderingStates } from './pdf_rendering_queue';\nimport { viewerCompatibilityParams } from './viewer_compatibility';\n\n/**\n * @typedef {Object} PDFPageViewOptions\n * @property {HTMLDivElement} container - The viewer element.\n * @property {EventBus} eventBus - The application event bus.\n * @property {number} id - The page unique ID (normally its number).\n * @property {number} scale - The page scale display.\n * @property {PageViewport} defaultViewport - The page viewport.\n * @property {PDFRenderingQueue} renderingQueue - The rendering queue object.\n * @property {IPDFTextLayerFactory} textLayerFactory\n * @property {number} textLayerMode - (optional) Controls if the text layer used\n * for selection and searching is created, and if the improved text selection\n * behaviour is enabled. The constants from {TextLayerMode} should be used.\n * The default value is `TextLayerMode.ENABLE`.\n * @property {IPDFAnnotationLayerFactory} annotationLayerFactory\n * @property {string} imageResourcesPath - (optional) Path for image resources,\n * mainly for annotation icons. Include trailing slash.\n * @property {boolean} renderInteractiveForms - Turns on rendering of\n * interactive form elements. The default is `false`.\n * @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.\n * @property {boolean} enableWebGL - (optional) Enables WebGL accelerated\n * rendering for some operations. The default value is `false`.\n * @property {boolean} useOnlyCssZoom - (optional) Enables CSS only zooming.\n * The default value is `false`.\n * @property {number} maxCanvasPixels - (optional) The maximum supported canvas\n * size in total pixels, i.e. width * height. Use -1 for no limit.\n * The default value is 4096 * 4096 (16 mega-pixels).\n * @property {IL10n} l10n - Localization service.\n */\n\nconst MAX_CANVAS_PIXELS = viewerCompatibilityParams.maxCanvasPixels || 16777216;\n\n/**\n * @implements {IRenderableView}\n */\nclass PDFPageView {\n /**\n * @param {PDFPageViewOptions} options\n */\n constructor(options) {\n let container = options.container;\n let defaultViewport = options.defaultViewport;\n\n this.id = options.id;\n this.renderingId = 'page' + this.id;\n\n this.pdfPage = null;\n this.pageLabel = null;\n this.rotation = 0;\n this.scale = options.scale || DEFAULT_SCALE;\n this.viewport = defaultViewport;\n this.pdfPageRotate = defaultViewport.rotation;\n this.hasRestrictedScaling = false;\n this.textLayerMode = Number.isInteger(options.textLayerMode) ?\n options.textLayerMode : TextLayerMode.ENABLE;\n this.imageResourcesPath = options.imageResourcesPath || '';\n this.renderInteractiveForms = options.renderInteractiveForms || false;\n this.useOnlyCssZoom = options.useOnlyCssZoom || false;\n this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;\n\n this.eventBus = options.eventBus || getGlobalEventBus();\n this.renderingQueue = options.renderingQueue;\n this.textLayerFactory = options.textLayerFactory;\n this.annotationLayerFactory = options.annotationLayerFactory;\n this.renderer = options.renderer || RendererType.CANVAS;\n this.enableWebGL = options.enableWebGL || false;\n this.l10n = options.l10n || NullL10n;\n\n this.paintTask = null;\n this.paintedViewportMap = new WeakMap();\n this.renderingState = RenderingStates.INITIAL;\n this.resume = null;\n this.error = null;\n\n this.onBeforeDraw = null;\n this.onAfterDraw = null;\n\n this.annotationLayer = null;\n this.textLayer = null;\n this.zoomLayer = null;\n\n let div = document.createElement('div');\n div.className = 'page';\n div.style.width = Math.floor(this.viewport.width) + 'px';\n div.style.height = Math.floor(this.viewport.height) + 'px';\n div.setAttribute('data-page-number', this.id);\n this.div = div;\n\n container.appendChild(div);\n }\n\n setPdfPage(pdfPage) {\n this.pdfPage = pdfPage;\n this.pdfPageRotate = pdfPage.rotate;\n\n let totalRotation = (this.rotation + this.pdfPageRotate) % 360;\n this.viewport = pdfPage.getViewport(this.scale * CSS_UNITS,\n totalRotation);\n this.stats = pdfPage.stats;\n this.reset();\n }\n\n destroy() {\n this.reset();\n if (this.pdfPage) {\n this.pdfPage.cleanup();\n }\n }\n\n /**\n * @private\n */\n _resetZoomLayer(removeFromDOM = false) {\n if (!this.zoomLayer) {\n return;\n }\n let zoomLayerCanvas = this.zoomLayer.firstChild;\n this.paintedViewportMap.delete(zoomLayerCanvas);\n // Zeroing the width and height causes Firefox to release graphics\n // resources immediately, which can greatly reduce memory consumption.\n zoomLayerCanvas.width = 0;\n zoomLayerCanvas.height = 0;\n\n if (removeFromDOM) {\n // Note: `ChildNode.remove` doesn't throw if the parent node is undefined.\n this.zoomLayer.remove();\n }\n this.zoomLayer = null;\n }\n\n reset(keepZoomLayer = false, keepAnnotations = false) {\n this.cancelRendering(keepAnnotations);\n\n let div = this.div;\n div.style.width = Math.floor(this.viewport.width) + 'px';\n div.style.height = Math.floor(this.viewport.height) + 'px';\n\n let childNodes = div.childNodes;\n let currentZoomLayerNode = (keepZoomLayer && this.zoomLayer) || null;\n let currentAnnotationNode = (keepAnnotations && this.annotationLayer &&\n this.annotationLayer.div) || null;\n for (let i = childNodes.length - 1; i >= 0; i--) {\n let node = childNodes[i];\n if (currentZoomLayerNode === node || currentAnnotationNode === node) {\n continue;\n }\n div.removeChild(node);\n }\n div.removeAttribute('data-loaded');\n\n if (currentAnnotationNode) {\n // Hide the annotation layer until all elements are resized\n // so they are not displayed on the already resized page.\n this.annotationLayer.hide();\n } else if (this.annotationLayer) {\n this.annotationLayer.cancel();\n this.annotationLayer = null;\n }\n\n if (!currentZoomLayerNode) {\n if (this.canvas) {\n this.paintedViewportMap.delete(this.canvas);\n // Zeroing the width and height causes Firefox to release graphics\n // resources immediately, which can greatly reduce memory consumption.\n this.canvas.width = 0;\n this.canvas.height = 0;\n delete this.canvas;\n }\n this._resetZoomLayer();\n }\n if (this.svg) {\n this.paintedViewportMap.delete(this.svg);\n delete this.svg;\n }\n\n this.loadingIconDiv = document.createElement('div');\n this.loadingIconDiv.className = 'loadingIcon';\n div.appendChild(this.loadingIconDiv);\n }\n\n update(scale, rotation) {\n this.scale = scale || this.scale;\n if (typeof rotation !== 'undefined') { // The rotation may be zero.\n this.rotation = rotation;\n }\n\n let totalRotation = (this.rotation + this.pdfPageRotate) % 360;\n this.viewport = this.viewport.clone({\n scale: this.scale * CSS_UNITS,\n rotation: totalRotation,\n });\n\n if (this.svg) {\n this.cssTransform(this.svg, true);\n\n this.eventBus.dispatch('pagerendered', {\n source: this,\n pageNumber: this.id,\n cssTransform: true,\n });\n return;\n }\n\n let isScalingRestricted = false;\n if (this.canvas && this.maxCanvasPixels > 0) {\n let outputScale = this.outputScale;\n if (((Math.floor(this.viewport.width) * outputScale.sx) | 0) *\n ((Math.floor(this.viewport.height) * outputScale.sy) | 0) >\n this.maxCanvasPixels) {\n isScalingRestricted = true;\n }\n }\n\n if (this.canvas) {\n if (this.useOnlyCssZoom ||\n (this.hasRestrictedScaling && isScalingRestricted)) {\n this.cssTransform(this.canvas, true);\n\n this.eventBus.dispatch('pagerendered', {\n source: this,\n pageNumber: this.id,\n cssTransform: true,\n });\n return;\n }\n if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {\n this.zoomLayer = this.canvas.parentNode;\n this.zoomLayer.style.position = 'absolute';\n }\n }\n if (this.zoomLayer) {\n this.cssTransform(this.zoomLayer.firstChild);\n }\n this.reset(/* keepZoomLayer = */ true, /* keepAnnotations = */ true);\n }\n\n cancelRendering(keepAnnotations = false) {\n const renderingState = this.renderingState;\n\n if (this.paintTask) {\n this.paintTask.cancel();\n this.paintTask = null;\n }\n this.renderingState = RenderingStates.INITIAL;\n this.resume = null;\n\n if (this.textLayer) {\n this.textLayer.cancel();\n this.textLayer = null;\n }\n if (!keepAnnotations && this.annotationLayer) {\n this.annotationLayer.cancel();\n this.annotationLayer = null;\n }\n\n if (renderingState !== RenderingStates.INITIAL) {\n this.eventBus.dispatch('pagecancelled', {\n source: this,\n pageNumber: this.id,\n renderingState,\n });\n }\n }\n\n cssTransform(target, redrawAnnotations = false) {\n // Scale target (canvas or svg), its wrapper and page container.\n let width = this.viewport.width;\n let height = this.viewport.height;\n let div = this.div;\n target.style.width = target.parentNode.style.width = div.style.width =\n Math.floor(width) + 'px';\n target.style.height = target.parentNode.style.height = div.style.height =\n Math.floor(height) + 'px';\n // The canvas may have been originally rotated; rotate relative to that.\n let relativeRotation = this.viewport.rotation -\n this.paintedViewportMap.get(target).rotation;\n let absRotation = Math.abs(relativeRotation);\n let scaleX = 1, scaleY = 1;\n if (absRotation === 90 || absRotation === 270) {\n // Scale x and y because of the rotation.\n scaleX = height / width;\n scaleY = width / height;\n }\n let cssTransform = 'rotate(' + relativeRotation + 'deg) ' +\n 'scale(' + scaleX + ',' + scaleY + ')';\n target.style.transform = cssTransform;\n\n if (this.textLayer) {\n // Rotating the text layer is more complicated since the divs inside the\n // the text layer are rotated.\n // TODO: This could probably be simplified by drawing the text layer in\n // one orientation and then rotating overall.\n let textLayerViewport = this.textLayer.viewport;\n let textRelativeRotation = this.viewport.rotation -\n textLayerViewport.rotation;\n let textAbsRotation = Math.abs(textRelativeRotation);\n let scale = width / textLayerViewport.width;\n if (textAbsRotation === 90 || textAbsRotation === 270) {\n scale = width / textLayerViewport.height;\n }\n let textLayerDiv = this.textLayer.textLayerDiv;\n let transX, transY;\n switch (textAbsRotation) {\n case 0:\n transX = transY = 0;\n break;\n case 90:\n transX = 0;\n transY = '-' + textLayerDiv.style.height;\n break;\n case 180:\n transX = '-' + textLayerDiv.style.width;\n transY = '-' + textLayerDiv.style.height;\n break;\n case 270:\n transX = '-' + textLayerDiv.style.width;\n transY = 0;\n break;\n default:\n console.error('Bad rotation value.');\n break;\n }\n\n textLayerDiv.style.transform =\n 'rotate(' + textAbsRotation + 'deg) ' +\n 'scale(' + scale + ', ' + scale + ') ' +\n 'translate(' + transX + ', ' + transY + ')';\n textLayerDiv.style.transformOrigin = '0% 0%';\n }\n\n if (redrawAnnotations && this.annotationLayer) {\n this.annotationLayer.render(this.viewport, 'display');\n }\n }\n\n get width() {\n return this.viewport.width;\n }\n\n get height() {\n return this.viewport.height;\n }\n\n getPagePoint(x, y) {\n return this.viewport.convertToPdfPoint(x, y);\n }\n\n draw() {\n if (this.renderingState !== RenderingStates.INITIAL) {\n console.error('Must be in new state before drawing');\n this.reset(); // Ensure that we reset all state to prevent issues.\n }\n\n if (!this.pdfPage) {\n this.renderingState = RenderingStates.FINISHED;\n return Promise.reject(new Error('Page is not loaded'));\n }\n\n this.renderingState = RenderingStates.RUNNING;\n\n let pdfPage = this.pdfPage;\n let div = this.div;\n // Wrap the canvas so that if it has a CSS transform for high DPI the\n // overflow will be hidden in Firefox.\n let canvasWrapper = document.createElement('div');\n canvasWrapper.style.width = div.style.width;\n canvasWrapper.style.height = div.style.height;\n canvasWrapper.classList.add('canvasWrapper');\n\n if (this.annotationLayer && this.annotationLayer.div) {\n // The annotation layer needs to stay on top.\n div.insertBefore(canvasWrapper, this.annotationLayer.div);\n } else {\n div.appendChild(canvasWrapper);\n }\n\n let textLayer = null;\n if (this.textLayerMode !== TextLayerMode.DISABLE && this.textLayerFactory) {\n let textLayerDiv = document.createElement('div');\n textLayerDiv.className = 'textLayer';\n textLayerDiv.style.width = canvasWrapper.style.width;\n textLayerDiv.style.height = canvasWrapper.style.height;\n if (this.annotationLayer && this.annotationLayer.div) {\n // The annotation layer needs to stay on top.\n div.insertBefore(textLayerDiv, this.annotationLayer.div);\n } else {\n div.appendChild(textLayerDiv);\n }\n\n textLayer = this.textLayerFactory.\n createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport,\n this.textLayerMode === TextLayerMode.ENABLE_ENHANCE);\n }\n this.textLayer = textLayer;\n\n let renderContinueCallback = null;\n if (this.renderingQueue) {\n renderContinueCallback = (cont) => {\n if (!this.renderingQueue.isHighestPriority(this)) {\n this.renderingState = RenderingStates.PAUSED;\n this.resume = () => {\n this.renderingState = RenderingStates.RUNNING;\n cont();\n };\n return;\n }\n cont();\n };\n }\n\n let finishPaintTask = (error) => {\n // The paintTask may have been replaced by a new one, so only remove\n // the reference to the paintTask if it matches the one that is\n // triggering this callback.\n if (paintTask === this.paintTask) {\n this.paintTask = null;\n }\n\n if (error instanceof RenderingCancelledException) {\n this.error = null;\n return Promise.resolve(undefined);\n }\n\n this.renderingState = RenderingStates.FINISHED;\n\n if (this.loadingIconDiv) {\n div.removeChild(this.loadingIconDiv);\n delete this.loadingIconDiv;\n }\n this._resetZoomLayer(/* removeFromDOM = */ true);\n\n this.error = error;\n this.stats = pdfPage.stats;\n if (this.onAfterDraw) {\n this.onAfterDraw();\n }\n this.eventBus.dispatch('pagerendered', {\n source: this,\n pageNumber: this.id,\n cssTransform: false,\n });\n\n if (error) {\n return Promise.reject(error);\n }\n return Promise.resolve(undefined);\n };\n\n let paintTask = this.renderer === RendererType.SVG ?\n this.paintOnSvg(canvasWrapper) :\n this.paintOnCanvas(canvasWrapper);\n paintTask.onRenderContinue = renderContinueCallback;\n this.paintTask = paintTask;\n\n let resultPromise = paintTask.promise.then(function() {\n return finishPaintTask(null).then(function () {\n if (textLayer) {\n let readableStream = pdfPage.streamTextContent({\n normalizeWhitespace: true,\n });\n textLayer.setTextContentStream(readableStream);\n textLayer.render();\n }\n });\n }, function(reason) {\n return finishPaintTask(reason);\n });\n\n if (this.annotationLayerFactory) {\n if (!this.annotationLayer) {\n this.annotationLayer = this.annotationLayerFactory.\n createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath,\n this.renderInteractiveForms, this.l10n);\n }\n this.annotationLayer.render(this.viewport, 'display');\n }\n div.setAttribute('data-loaded', true);\n\n if (this.onBeforeDraw) {\n this.onBeforeDraw();\n }\n return resultPromise;\n }\n\n paintOnCanvas(canvasWrapper) {\n let renderCapability = createPromiseCapability();\n let result = {\n promise: renderCapability.promise,\n onRenderContinue(cont) {\n cont();\n },\n cancel() {\n renderTask.cancel();\n },\n };\n\n let viewport = this.viewport;\n let canvas = document.createElement('canvas');\n canvas.id = this.renderingId;\n\n // Keep the canvas hidden until the first draw callback, or until drawing\n // is complete when `!this.renderingQueue`, to prevent black flickering.\n canvas.setAttribute('hidden', 'hidden');\n let isCanvasHidden = true;\n let showCanvas = function () {\n if (isCanvasHidden) {\n canvas.removeAttribute('hidden');\n isCanvasHidden = false;\n }\n };\n\n canvasWrapper.appendChild(canvas);\n this.canvas = canvas;\n\n if (typeof PDFJSDev === 'undefined' ||\n PDFJSDev.test('MOZCENTRAL || FIREFOX || GENERIC')) {\n canvas.mozOpaque = true;\n }\n\n let ctx = canvas.getContext('2d', { alpha: false, });\n let outputScale = getOutputScale(ctx);\n this.outputScale = outputScale;\n\n if (this.useOnlyCssZoom) {\n let actualSizeViewport = viewport.clone({ scale: CSS_UNITS, });\n // Use a scale that makes the canvas have the originally intended size\n // of the page.\n outputScale.sx *= actualSizeViewport.width / viewport.width;\n outputScale.sy *= actualSizeViewport.height / viewport.height;\n outputScale.scaled = true;\n }\n\n if (this.maxCanvasPixels > 0) {\n let pixelsInViewport = viewport.width * viewport.height;\n let maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);\n if (outputScale.sx > maxScale || outputScale.sy > maxScale) {\n outputScale.sx = maxScale;\n outputScale.sy = maxScale;\n outputScale.scaled = true;\n this.hasRestrictedScaling = true;\n } else {\n this.hasRestrictedScaling = false;\n }\n }\n\n let sfx = approximateFraction(outputScale.sx);\n let sfy = approximateFraction(outputScale.sy);\n canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);\n canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);\n canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';\n canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';\n // Add the viewport so it's known what it was originally drawn with.\n this.paintedViewportMap.set(canvas, viewport);\n\n // Rendering area\n let transform = !outputScale.scaled ? null :\n [outputScale.sx, 0, 0, outputScale.sy, 0, 0];\n let renderContext = {\n canvasContext: ctx,\n transform,\n viewport: this.viewport,\n enableWebGL: this.enableWebGL,\n renderInteractiveForms: this.renderInteractiveForms,\n };\n let renderTask = this.pdfPage.render(renderContext);\n renderTask.onContinue = function (cont) {\n showCanvas();\n if (result.onRenderContinue) {\n result.onRenderContinue(cont);\n } else {\n cont();\n }\n };\n\n renderTask.promise.then(function() {\n showCanvas();\n renderCapability.resolve(undefined);\n }, function(error) {\n showCanvas();\n renderCapability.reject(error);\n });\n return result;\n }\n\n paintOnSvg(wrapper) {\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {\n // Return a mock object, to prevent errors such as e.g.\n // \"TypeError: paintTask.promise is undefined\".\n return {\n promise: Promise.reject(new Error('SVG rendering is not supported.')),\n onRenderContinue(cont) { },\n cancel() { },\n };\n }\n\n let cancelled = false;\n let ensureNotCancelled = () => {\n if (cancelled) {\n throw new RenderingCancelledException(\n 'Rendering cancelled, page ' + this.id, 'svg');\n }\n };\n\n let pdfPage = this.pdfPage;\n let actualSizeViewport = this.viewport.clone({ scale: CSS_UNITS, });\n let promise = pdfPage.getOperatorList().then((opList) => {\n ensureNotCancelled();\n let svgGfx = new SVGGraphics(pdfPage.commonObjs, pdfPage.objs);\n return svgGfx.getSVG(opList, actualSizeViewport).then((svg) => {\n ensureNotCancelled();\n this.svg = svg;\n this.paintedViewportMap.set(svg, actualSizeViewport);\n\n svg.style.width = wrapper.style.width;\n svg.style.height = wrapper.style.height;\n this.renderingState = RenderingStates.FINISHED;\n wrapper.appendChild(svg);\n });\n });\n\n return {\n promise,\n onRenderContinue(cont) {\n cont();\n },\n cancel() {\n cancelled = true;\n },\n };\n }\n\n /**\n * @param {string|null} label\n */\n setPageLabel(label) {\n this.pageLabel = (typeof label === 'string' ? label : null);\n\n if (this.pageLabel !== null) {\n this.div.setAttribute('data-page-label', this.pageLabel);\n } else {\n this.div.removeAttribute('data-page-label');\n }\n }\n}\n\nexport {\n PDFPageView,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getGlobalEventBus } from './dom_events';\nimport { renderTextLayer } from 'pdfjs-lib';\nimport { scrollIntoView } from './ui_utils';\n\nconst EXPAND_DIVS_TIMEOUT = 300; // ms\nconst MATCH_SCROLL_OFFSET_TOP = -50;\nconst MATCH_SCROLL_OFFSET_LEFT = -400;\n\n/**\n * @typedef {Object} TextLayerBuilderOptions\n * @property {HTMLDivElement} textLayerDiv - The text layer container.\n * @property {EventBus} eventBus - The application event bus.\n * @property {number} pageIndex - The page index.\n * @property {PageViewport} viewport - The viewport of the text layer.\n * @property {PDFFindController} findController\n * @property {boolean} enhanceTextSelection - Option to turn on improved\n * text selection.\n */\n\n/**\n * The text layer builder provides text selection functionality for the PDF.\n * It does this by creating overlay divs over the PDF's text. These divs\n * contain text that matches the PDF text they are overlaying. This object\n * also provides a way to highlight text that is being searched for.\n */\nclass TextLayerBuilder {\n constructor({ textLayerDiv, eventBus, pageIndex, viewport,\n findController = null, enhanceTextSelection = false, }) {\n this.textLayerDiv = textLayerDiv;\n this.eventBus = eventBus || getGlobalEventBus();\n this.textContent = null;\n this.textContentItemsStr = [];\n this.textContentStream = null;\n this.renderingDone = false;\n this.pageIdx = pageIndex;\n this.pageNumber = this.pageIdx + 1;\n this.matches = [];\n this.viewport = viewport;\n this.textDivs = [];\n this.findController = findController;\n this.textLayerRenderTask = null;\n this.enhanceTextSelection = enhanceTextSelection;\n\n this._boundEvents = Object.create(null);\n this._bindEvents();\n\n this._bindMouse();\n }\n\n /**\n * @private\n */\n _finishRendering() {\n this.renderingDone = true;\n\n if (!this.enhanceTextSelection) {\n let endOfContent = document.createElement('div');\n endOfContent.className = 'endOfContent';\n this.textLayerDiv.appendChild(endOfContent);\n }\n\n this.eventBus.dispatch('textlayerrendered', {\n source: this,\n pageNumber: this.pageNumber,\n numTextDivs: this.textDivs.length,\n });\n }\n\n /**\n * Renders the text layer.\n *\n * @param {number} timeout - (optional) wait for a specified amount of\n * milliseconds before rendering\n */\n render(timeout = 0) {\n if (!(this.textContent || this.textContentStream) || this.renderingDone) {\n return;\n }\n this.cancel();\n\n this.textDivs = [];\n let textLayerFrag = document.createDocumentFragment();\n this.textLayerRenderTask = renderTextLayer({\n textContent: this.textContent,\n textContentStream: this.textContentStream,\n container: textLayerFrag,\n viewport: this.viewport,\n textDivs: this.textDivs,\n textContentItemsStr: this.textContentItemsStr,\n timeout,\n enhanceTextSelection: this.enhanceTextSelection,\n });\n this.textLayerRenderTask.promise.then(() => {\n this.textLayerDiv.appendChild(textLayerFrag);\n this._finishRendering();\n this.updateMatches();\n }, function (reason) {\n // Cancelled or failed to render text layer; skipping errors.\n });\n }\n\n /**\n * Cancel rendering of the text layer.\n */\n cancel() {\n if (this.textLayerRenderTask) {\n this.textLayerRenderTask.cancel();\n this.textLayerRenderTask = null;\n }\n }\n\n setTextContentStream(readableStream) {\n this.cancel();\n this.textContentStream = readableStream;\n }\n\n setTextContent(textContent) {\n this.cancel();\n this.textContent = textContent;\n }\n\n convertMatches(matches, matchesLength) {\n let i = 0;\n let iIndex = 0;\n let textContentItemsStr = this.textContentItemsStr;\n let end = textContentItemsStr.length - 1;\n let queryLen = (this.findController === null ?\n 0 : this.findController.state.query.length);\n let ret = [];\n if (!matches) {\n return ret;\n }\n for (let m = 0, len = matches.length; m < len; m++) {\n // Calculate the start position.\n let matchIdx = matches[m];\n\n // Loop over the divIdxs.\n while (i !== end && matchIdx >=\n (iIndex + textContentItemsStr[i].length)) {\n iIndex += textContentItemsStr[i].length;\n i++;\n }\n\n if (i === textContentItemsStr.length) {\n console.error('Could not find a matching mapping');\n }\n\n let match = {\n begin: {\n divIdx: i,\n offset: matchIdx - iIndex,\n },\n };\n\n // Calculate the end position.\n if (matchesLength) { // Multiterm search.\n matchIdx += matchesLength[m];\n } else { // Phrase search.\n matchIdx += queryLen;\n }\n\n // Somewhat the same array as above, but use > instead of >= to get\n // the end position right.\n while (i !== end && matchIdx >\n (iIndex + textContentItemsStr[i].length)) {\n iIndex += textContentItemsStr[i].length;\n i++;\n }\n\n match.end = {\n divIdx: i,\n offset: matchIdx - iIndex,\n };\n ret.push(match);\n }\n\n return ret;\n }\n\n renderMatches(matches) {\n // Early exit if there is nothing to render.\n if (matches.length === 0) {\n return;\n }\n\n let textContentItemsStr = this.textContentItemsStr;\n let textDivs = this.textDivs;\n let prevEnd = null;\n let pageIdx = this.pageIdx;\n let isSelectedPage = (this.findController === null ?\n false : (pageIdx === this.findController.selected.pageIdx));\n let selectedMatchIdx = (this.findController === null ?\n -1 : this.findController.selected.matchIdx);\n let highlightAll = (this.findController === null ?\n false : this.findController.state.highlightAll);\n let infinity = {\n divIdx: -1,\n offset: undefined,\n };\n\n function beginText(begin, className) {\n let divIdx = begin.divIdx;\n textDivs[divIdx].textContent = '';\n appendTextToDiv(divIdx, 0, begin.offset, className);\n }\n\n function appendTextToDiv(divIdx, fromOffset, toOffset, className) {\n let div = textDivs[divIdx];\n let content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);\n let node = document.createTextNode(content);\n if (className) {\n let span = document.createElement('span');\n span.className = className;\n span.appendChild(node);\n div.appendChild(span);\n return;\n }\n div.appendChild(node);\n }\n\n let i0 = selectedMatchIdx, i1 = i0 + 1;\n if (highlightAll) {\n i0 = 0;\n i1 = matches.length;\n } else if (!isSelectedPage) {\n // Not highlighting all and this isn't the selected page, so do nothing.\n return;\n }\n\n for (let i = i0; i < i1; i++) {\n let match = matches[i];\n let begin = match.begin;\n let end = match.end;\n let isSelected = (isSelectedPage && i === selectedMatchIdx);\n let highlightSuffix = (isSelected ? ' selected' : '');\n\n // Scroll the selected match into view.\n if (this.findController) {\n if (this.findController.selected.matchIdx === i &&\n this.findController.selected.pageIdx === pageIdx) {\n const spot = {\n top: MATCH_SCROLL_OFFSET_TOP,\n left: MATCH_SCROLL_OFFSET_LEFT,\n };\n scrollIntoView(textDivs[begin.divIdx], spot,\n /* skipOverflowHiddenElements = */ true);\n }\n }\n\n // Match inside new div.\n if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {\n // If there was a previous div, then add the text at the end.\n if (prevEnd !== null) {\n appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);\n }\n // Clear the divs and set the content until the starting point.\n beginText(begin);\n } else {\n appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);\n }\n\n if (begin.divIdx === end.divIdx) {\n appendTextToDiv(begin.divIdx, begin.offset, end.offset,\n 'highlight' + highlightSuffix);\n } else {\n appendTextToDiv(begin.divIdx, begin.offset, infinity.offset,\n 'highlight begin' + highlightSuffix);\n for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {\n textDivs[n0].className = 'highlight middle' + highlightSuffix;\n }\n beginText(end, 'highlight end' + highlightSuffix);\n }\n prevEnd = end;\n }\n\n if (prevEnd) {\n appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);\n }\n }\n\n updateMatches() {\n // Only show matches when all rendering is done.\n if (!this.renderingDone) {\n return;\n }\n\n // Clear all matches.\n let matches = this.matches;\n let textDivs = this.textDivs;\n let textContentItemsStr = this.textContentItemsStr;\n let clearedUntilDivIdx = -1;\n\n // Clear all current matches.\n for (let i = 0, len = matches.length; i < len; i++) {\n let match = matches[i];\n let begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);\n for (let n = begin, end = match.end.divIdx; n <= end; n++) {\n let div = textDivs[n];\n div.textContent = textContentItemsStr[n];\n div.className = '';\n }\n clearedUntilDivIdx = match.end.divIdx + 1;\n }\n\n if (!this.findController || !this.findController.highlightMatches) {\n return;\n }\n\n // Convert the matches on the page controller into the match format\n // used for the textLayer.\n let pageMatches, pageMatchesLength;\n if (this.findController !== null) {\n pageMatches = this.findController.pageMatches[this.pageIdx] || null;\n pageMatchesLength = (this.findController.pageMatchesLength) ?\n this.findController.pageMatchesLength[this.pageIdx] || null : null;\n }\n\n this.matches = this.convertMatches(pageMatches, pageMatchesLength);\n this.renderMatches(this.matches);\n }\n\n /**\n * @private\n */\n _bindEvents() {\n const { eventBus, _boundEvents, } = this;\n\n _boundEvents.pageCancelled = (evt) => {\n if (evt.pageNumber !== this.pageNumber) {\n return;\n }\n if (this.textLayerRenderTask) {\n console.error('TextLayerBuilder._bindEvents: `this.cancel()` should ' +\n 'have been called when the page was reset, or rendering cancelled.');\n return;\n }\n // Ensure that all event listeners are cleaned up when the page is reset,\n // since re-rendering will create new `TextLayerBuilder` instances and the\n // number of (stale) event listeners would otherwise grow without bound.\n for (const name in _boundEvents) {\n eventBus.off(name.toLowerCase(), _boundEvents[name]);\n delete _boundEvents[name];\n }\n };\n _boundEvents.updateTextLayerMatches = (evt) => {\n if (evt.pageIndex !== this.pageIdx && evt.pageIndex !== -1) {\n return;\n }\n this.updateMatches();\n };\n\n eventBus.on('pagecancelled', _boundEvents.pageCancelled);\n eventBus.on('updatetextlayermatches', _boundEvents.updateTextLayerMatches);\n }\n\n /**\n * Improves text selection by adding an additional div where the mouse was\n * clicked. This reduces flickering of the content if the mouse is slowly\n * dragged up or down.\n *\n * @private\n */\n _bindMouse() {\n let div = this.textLayerDiv;\n let expandDivsTimer = null;\n\n div.addEventListener('mousedown', (evt) => {\n if (this.enhanceTextSelection && this.textLayerRenderTask) {\n this.textLayerRenderTask.expandTextDivs(true);\n if ((typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL')) &&\n expandDivsTimer) {\n clearTimeout(expandDivsTimer);\n expandDivsTimer = null;\n }\n return;\n }\n\n let end = div.querySelector('.endOfContent');\n if (!end) {\n return;\n }\n if (typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n // On non-Firefox browsers, the selection will feel better if the height\n // of the `endOfContent` div is adjusted to start at mouse click\n // location. This avoids flickering when the selection moves up.\n // However it does not work when selection is started on empty space.\n let adjustTop = evt.target !== div;\n if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {\n adjustTop = adjustTop && window.getComputedStyle(end).\n getPropertyValue('-moz-user-select') !== 'none';\n }\n if (adjustTop) {\n let divBounds = div.getBoundingClientRect();\n let r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);\n end.style.top = (r * 100).toFixed(2) + '%';\n }\n }\n end.classList.add('active');\n });\n\n div.addEventListener('mouseup', () => {\n if (this.enhanceTextSelection && this.textLayerRenderTask) {\n if (typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n expandDivsTimer = setTimeout(() => {\n if (this.textLayerRenderTask) {\n this.textLayerRenderTask.expandTextDivs(false);\n }\n expandDivsTimer = null;\n }, EXPAND_DIVS_TIMEOUT);\n } else {\n this.textLayerRenderTask.expandTextDivs(false);\n }\n return;\n }\n\n let end = div.querySelector('.endOfContent');\n if (!end) {\n return;\n }\n if (typeof PDFJSDev === 'undefined' ||\n !PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n end.style.top = '';\n }\n end.classList.remove('active');\n });\n }\n}\n\n/**\n * @implements IPDFTextLayerFactory\n */\nclass DefaultTextLayerFactory {\n /**\n * @param {HTMLDivElement} textLayerDiv\n * @param {number} pageIndex\n * @param {PageViewport} viewport\n * @param {boolean} enhanceTextSelection\n * @returns {TextLayerBuilder}\n */\n createTextLayerBuilder(textLayerDiv, pageIndex, viewport,\n enhanceTextSelection = false) {\n return new TextLayerBuilder({\n textLayerDiv,\n pageIndex,\n viewport,\n enhanceTextSelection,\n });\n }\n}\n\nexport {\n TextLayerBuilder,\n DefaultTextLayerFactory,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScrollMode, SpreadMode } from './base_viewer';\nimport { CursorTool } from './pdf_cursor_tools';\nimport { PDFSinglePageViewer } from './pdf_single_page_viewer';\nimport { SCROLLBAR_PADDING } from './ui_utils';\n\n/**\n * @typedef {Object} SecondaryToolbarOptions\n * @property {HTMLDivElement} toolbar - Container for the secondary toolbar.\n * @property {HTMLButtonElement} toggleButton - Button to toggle the visibility\n * of the secondary toolbar.\n * @property {HTMLDivElement} toolbarButtonContainer - Container where all the\n * toolbar buttons are placed. The maximum height of the toolbar is controlled\n * dynamically by adjusting the 'max-height' CSS property of this DOM element.\n * @property {HTMLButtonElement} presentationModeButton - Button for entering\n * presentation mode.\n * @property {HTMLButtonElement} openFileButton - Button to open a file.\n * @property {HTMLButtonElement} printButton - Button to print the document.\n * @property {HTMLButtonElement} downloadButton - Button to download the\n * document.\n * @property {HTMLLinkElement} viewBookmarkButton - Button to obtain a bookmark\n * link to the current location in the document.\n * @property {HTMLButtonElement} firstPageButton - Button to go to the first\n * page in the document.\n * @property {HTMLButtonElement} lastPageButton - Button to go to the last page\n * in the document.\n * @property {HTMLButtonElement} pageRotateCwButton - Button to rotate the pages\n * clockwise.\n * @property {HTMLButtonElement} pageRotateCcwButton - Button to rotate the\n * pages counterclockwise.\n * @property {HTMLButtonElement} cursorSelectToolButton - Button to enable the\n * select tool.\n * @property {HTMLButtonElement} cursorHandToolButton - Button to enable the\n * hand tool.\n * @property {HTMLButtonElement} documentPropertiesButton - Button for opening\n * the document properties dialog.\n */\n\nclass SecondaryToolbar {\n /**\n * @param {SecondaryToolbarOptions} options\n * @param {HTMLDivElement} mainContainer\n * @param {EventBus} eventBus\n */\n constructor(options, mainContainer, eventBus) {\n this.toolbar = options.toolbar;\n this.toggleButton = options.toggleButton;\n this.toolbarButtonContainer = options.toolbarButtonContainer;\n this.buttons = [\n { element: options.presentationModeButton, eventName: 'presentationmode',\n close: true, },\n { element: options.openFileButton, eventName: 'openfile', close: true, },\n { element: options.printButton, eventName: 'print', close: true, },\n { element: options.downloadButton, eventName: 'download', close: true, },\n { element: options.viewBookmarkButton, eventName: null, close: true, },\n { element: options.firstPageButton, eventName: 'firstpage',\n close: true, },\n { element: options.lastPageButton, eventName: 'lastpage', close: true, },\n { element: options.pageRotateCwButton, eventName: 'rotatecw',\n close: false, },\n { element: options.pageRotateCcwButton, eventName: 'rotateccw',\n close: false, },\n { element: options.cursorSelectToolButton, eventName: 'switchcursortool',\n eventDetails: { tool: CursorTool.SELECT, }, close: true, },\n { element: options.cursorHandToolButton, eventName: 'switchcursortool',\n eventDetails: { tool: CursorTool.HAND, }, close: true, },\n { element: options.scrollVerticalButton, eventName: 'switchscrollmode',\n eventDetails: { mode: ScrollMode.VERTICAL, }, close: true, },\n { element: options.scrollHorizontalButton, eventName: 'switchscrollmode',\n eventDetails: { mode: ScrollMode.HORIZONTAL, }, close: true, },\n { element: options.scrollWrappedButton, eventName: 'switchscrollmode',\n eventDetails: { mode: ScrollMode.WRAPPED, }, close: true, },\n { element: options.spreadNoneButton, eventName: 'switchspreadmode',\n eventDetails: { mode: SpreadMode.NONE, }, close: true, },\n { element: options.spreadOddButton, eventName: 'switchspreadmode',\n eventDetails: { mode: SpreadMode.ODD, }, close: true, },\n { element: options.spreadEvenButton, eventName: 'switchspreadmode',\n eventDetails: { mode: SpreadMode.EVEN, }, close: true, },\n { element: options.documentPropertiesButton,\n eventName: 'documentproperties', close: true, },\n ];\n this.items = {\n firstPage: options.firstPageButton,\n lastPage: options.lastPageButton,\n pageRotateCw: options.pageRotateCwButton,\n pageRotateCcw: options.pageRotateCcwButton,\n };\n\n this.mainContainer = mainContainer;\n this.eventBus = eventBus;\n\n this.opened = false;\n this.containerHeight = null;\n this.previousContainerHeight = null;\n\n this.reset();\n\n // Bind the event listeners for click, cursor tool, and scroll/spread mode\n // actions.\n this._bindClickListeners();\n this._bindCursorToolsListener(options);\n this._bindScrollModeListener(options);\n this._bindSpreadModeListener(options);\n\n // Bind the event listener for adjusting the 'max-height' of the toolbar.\n this.eventBus.on('resize', this._setMaxHeight.bind(this));\n\n // Hide the Scroll/Spread mode buttons, when they're not applicable to the\n // current `BaseViewer` instance (in particular `PDFSinglePageViewer`).\n this.eventBus.on('baseviewerinit', (evt) => {\n if (evt.source instanceof PDFSinglePageViewer) {\n this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons',\n 'hiddenSpreadModeButtons');\n } else {\n this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons',\n 'hiddenSpreadModeButtons');\n }\n });\n }\n\n /**\n * @return {boolean}\n */\n get isOpen() {\n return this.opened;\n }\n\n setPageNumber(pageNumber) {\n this.pageNumber = pageNumber;\n this._updateUIState();\n }\n\n setPagesCount(pagesCount) {\n this.pagesCount = pagesCount;\n this._updateUIState();\n }\n\n reset() {\n this.pageNumber = 0;\n this.pagesCount = 0;\n this._updateUIState();\n\n // Reset the Scroll/Spread buttons too, since they're document specific.\n this.eventBus.dispatch('secondarytoolbarreset', { source: this, });\n }\n\n _updateUIState() {\n this.items.firstPage.disabled = (this.pageNumber <= 1);\n this.items.lastPage.disabled = (this.pageNumber >= this.pagesCount);\n this.items.pageRotateCw.disabled = this.pagesCount === 0;\n this.items.pageRotateCcw.disabled = this.pagesCount === 0;\n }\n\n _bindClickListeners() {\n // Button to toggle the visibility of the secondary toolbar.\n this.toggleButton.addEventListener('click', this.toggle.bind(this));\n\n // All items within the secondary toolbar.\n for (let button in this.buttons) {\n let { element, eventName, close, eventDetails, } = this.buttons[button];\n\n element.addEventListener('click', (evt) => {\n if (eventName !== null) {\n let details = { source: this, };\n for (let property in eventDetails) {\n details[property] = eventDetails[property];\n }\n this.eventBus.dispatch(eventName, details);\n }\n if (close) {\n this.close();\n }\n });\n }\n }\n\n _bindCursorToolsListener(buttons) {\n this.eventBus.on('cursortoolchanged', function(evt) {\n buttons.cursorSelectToolButton.classList.remove('toggled');\n buttons.cursorHandToolButton.classList.remove('toggled');\n\n switch (evt.tool) {\n case CursorTool.SELECT:\n buttons.cursorSelectToolButton.classList.add('toggled');\n break;\n case CursorTool.HAND:\n buttons.cursorHandToolButton.classList.add('toggled');\n break;\n }\n });\n }\n\n _bindScrollModeListener(buttons) {\n function scrollModeChanged(evt) {\n buttons.scrollVerticalButton.classList.remove('toggled');\n buttons.scrollHorizontalButton.classList.remove('toggled');\n buttons.scrollWrappedButton.classList.remove('toggled');\n\n switch (evt.mode) {\n case ScrollMode.VERTICAL:\n buttons.scrollVerticalButton.classList.add('toggled');\n break;\n case ScrollMode.HORIZONTAL:\n buttons.scrollHorizontalButton.classList.add('toggled');\n break;\n case ScrollMode.WRAPPED:\n buttons.scrollWrappedButton.classList.add('toggled');\n break;\n }\n\n // Temporarily *disable* the Spread buttons when horizontal scrolling is\n // enabled, since the non-default Spread modes doesn't affect the layout.\n const isScrollModeHorizontal = (evt.mode === ScrollMode.HORIZONTAL);\n buttons.spreadNoneButton.disabled = isScrollModeHorizontal;\n buttons.spreadOddButton.disabled = isScrollModeHorizontal;\n buttons.spreadEvenButton.disabled = isScrollModeHorizontal;\n }\n this.eventBus.on('scrollmodechanged', scrollModeChanged);\n\n this.eventBus.on('secondarytoolbarreset', (evt) => {\n if (evt.source === this) {\n scrollModeChanged({ mode: ScrollMode.VERTICAL, });\n }\n });\n }\n\n _bindSpreadModeListener(buttons) {\n function spreadModeChanged(evt) {\n buttons.spreadNoneButton.classList.remove('toggled');\n buttons.spreadOddButton.classList.remove('toggled');\n buttons.spreadEvenButton.classList.remove('toggled');\n\n switch (evt.mode) {\n case SpreadMode.NONE:\n buttons.spreadNoneButton.classList.add('toggled');\n break;\n case SpreadMode.ODD:\n buttons.spreadOddButton.classList.add('toggled');\n break;\n case SpreadMode.EVEN:\n buttons.spreadEvenButton.classList.add('toggled');\n break;\n }\n }\n this.eventBus.on('spreadmodechanged', spreadModeChanged);\n\n this.eventBus.on('secondarytoolbarreset', (evt) => {\n if (evt.source === this) {\n spreadModeChanged({ mode: SpreadMode.NONE, });\n }\n });\n }\n\n open() {\n if (this.opened) {\n return;\n }\n this.opened = true;\n this._setMaxHeight();\n\n this.toggleButton.classList.add('toggled');\n this.toolbar.classList.remove('hidden');\n }\n\n close() {\n if (!this.opened) {\n return;\n }\n this.opened = false;\n this.toolbar.classList.add('hidden');\n this.toggleButton.classList.remove('toggled');\n }\n\n toggle() {\n if (this.opened) {\n this.close();\n } else {\n this.open();\n }\n }\n\n /**\n * @private\n */\n _setMaxHeight() {\n if (!this.opened) {\n return; // Only adjust the 'max-height' if the toolbar is visible.\n }\n this.containerHeight = this.mainContainer.clientHeight;\n\n if (this.containerHeight === this.previousContainerHeight) {\n return;\n }\n this.toolbarButtonContainer.setAttribute('style',\n 'max-height: ' + (this.containerHeight - SCROLLBAR_PADDING) + 'px;');\n\n this.previousContainerHeight = this.containerHeight;\n }\n}\n\nexport {\n SecondaryToolbar,\n};\n","/* Copyright 2017 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BaseViewer } from './base_viewer';\nimport { scrollIntoView } from './ui_utils';\nimport { shadow } from 'pdfjs-lib';\n\nclass PDFSinglePageViewer extends BaseViewer {\n constructor(options) {\n super(options);\n\n this.eventBus.on('pagesinit', (evt) => {\n // Since the pages are placed in a `DocumentFragment`, make sure that\n // the current page becomes visible upon loading of the document.\n this._ensurePageViewVisible();\n });\n }\n\n get _setDocumentViewerElement() {\n // Since we only want to display *one* page at a time when using the\n // `PDFSinglePageViewer`, we cannot append them to the `viewer` DOM element.\n // Instead, they are placed in a `DocumentFragment`, and only the current\n // page is displayed in the viewer (refer to `this._ensurePageViewVisible`).\n return shadow(this, '_setDocumentViewerElement', this._shadowViewer);\n }\n\n _resetView() {\n super._resetView();\n this._previousPageNumber = 1;\n this._shadowViewer = document.createDocumentFragment();\n }\n\n _ensurePageViewVisible() {\n let pageView = this._pages[this._currentPageNumber - 1];\n let previousPageView = this._pages[this._previousPageNumber - 1];\n\n let viewerNodes = this.viewer.childNodes;\n switch (viewerNodes.length) {\n case 0: // Should *only* occur on initial loading.\n this.viewer.appendChild(pageView.div);\n break;\n case 1: // The normal page-switching case.\n if (viewerNodes[0] !== previousPageView.div) {\n throw new Error(\n '_ensurePageViewVisible: Unexpected previously visible page.');\n }\n if (pageView === previousPageView) {\n break; // The correct page is already visible.\n }\n // Switch visible pages, and reset the viewerContainer scroll position.\n this._shadowViewer.appendChild(previousPageView.div);\n this.viewer.appendChild(pageView.div);\n\n this.container.scrollTop = 0;\n break;\n default:\n throw new Error(\n '_ensurePageViewVisible: Only one page should be visible at a time.');\n }\n this._previousPageNumber = this._currentPageNumber;\n }\n\n _scrollUpdate() {\n if (this._updateScrollDown) {\n this._updateScrollDown();\n }\n super._scrollUpdate();\n }\n\n _scrollIntoView({ pageDiv, pageSpot = null, pageNumber = null, }) {\n if (pageNumber) { // Ensure that `this._currentPageNumber` is correct.\n this._setCurrentPageNumber(pageNumber);\n }\n let scrolledDown = this._currentPageNumber >= this._previousPageNumber;\n let previousLocation = this._location;\n this._ensurePageViewVisible();\n\n scrollIntoView(pageDiv, pageSpot);\n\n // Since scrolling is tracked using `requestAnimationFrame`, update the\n // scroll direction during the next `this._scrollUpdate` invocation.\n this._updateScrollDown = () => {\n this.scroll.down = scrolledDown;\n delete this._updateScrollDown;\n };\n // If the scroll position doesn't change as a result of the `scrollIntoView`\n // call, ensure that rendering always occurs to avoid showing a blank page.\n setTimeout(() => {\n if (this._location === previousLocation) {\n if (this._updateScrollDown) {\n this._updateScrollDown();\n }\n this.update();\n }\n }, 0);\n }\n\n _getVisiblePages() {\n if (!this.pagesCount) {\n return { views: [], };\n }\n let pageView = this._pages[this._currentPageNumber - 1];\n // NOTE: Compute the `x` and `y` properties of the current view,\n // since `this._updateLocation` depends of them being available.\n let element = pageView.div;\n\n let view = {\n id: pageView.id,\n x: element.offsetLeft + element.clientLeft,\n y: element.offsetTop + element.clientTop,\n view: pageView,\n };\n return { first: view, last: view, views: [view], };\n }\n\n update() {\n let visible = this._getVisiblePages();\n let visiblePages = visible.views, numVisiblePages = visiblePages.length;\n\n if (numVisiblePages === 0) {\n return;\n }\n this._resizeBuffer(numVisiblePages);\n\n this.renderingQueue.renderHighestPriority(visible);\n\n this._updateLocation(visible.first);\n this.eventBus.dispatch('updateviewarea', {\n source: this,\n location: this._location,\n });\n }\n\n get _isScrollModeHorizontal() {\n // The Scroll/Spread modes are never used in `PDFSinglePageViewer`.\n return shadow(this, '_isScrollModeHorizontal', false);\n }\n\n _updateScrollMode() { }\n\n _updateSpreadMode() { }\n}\n\nexport {\n PDFSinglePageViewer,\n};\n","/* Copyright 2016 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n animationStarted, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, MAX_SCALE,\n MIN_SCALE, noContextMenuHandler, NullL10n\n} from './ui_utils';\n\nconst PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';\nconst SCALE_SELECT_CONTAINER_PADDING = 8;\nconst SCALE_SELECT_PADDING = 22;\n\n/**\n * @typedef {Object} ToolbarOptions\n * @property {HTMLDivElement} container - Container for the secondary toolbar.\n * @property {HTMLSpanElement} numPages - Label that contains number of pages.\n * @property {HTMLInputElement} pageNumber - Control for display and user input\n * of the current page number.\n * @property {HTMLSpanElement} scaleSelectContainer - Container where scale\n * controls are placed. The width is adjusted on UI initialization.\n * @property {HTMLSelectElement} scaleSelect - Scale selection control.\n * @property {HTMLOptionElement} customScaleOption - The item used to display\n * a non-predefined scale.\n * @property {HTMLButtonElement} previous - Button to go to the previous page.\n * @property {HTMLButtonElement} next - Button to go to the next page.\n * @property {HTMLButtonElement} zoomIn - Button to zoom in the pages.\n * @property {HTMLButtonElement} zoomOut - Button to zoom out the pages.\n * @property {HTMLButtonElement} viewFind - Button to open find bar.\n * @property {HTMLButtonElement} openFile - Button to open a new document.\n * @property {HTMLButtonElement} presentationModeButton - Button to switch to\n * presentation mode.\n * @property {HTMLButtonElement} download - Button to download the document.\n * @property {HTMLAElement} viewBookmark - Element to link current url of\n * the page view.\n */\n\nclass Toolbar {\n /**\n * @param {ToolbarOptions} options\n * @param {EventBus} eventBus\n * @param {IL10n} l10n - Localization service.\n */\n constructor(options, eventBus, l10n = NullL10n) {\n this.toolbar = options.container;\n this.eventBus = eventBus;\n this.l10n = l10n;\n this.items = options;\n\n this._wasLocalized = false;\n this.reset();\n\n // Bind the event listeners for click and hand tool actions.\n this._bindListeners();\n }\n\n setPageNumber(pageNumber, pageLabel) {\n this.pageNumber = pageNumber;\n this.pageLabel = pageLabel;\n this._updateUIState(false);\n }\n\n setPagesCount(pagesCount, hasPageLabels) {\n this.pagesCount = pagesCount;\n this.hasPageLabels = hasPageLabels;\n this._updateUIState(true);\n }\n\n setPageScale(pageScaleValue, pageScale) {\n this.pageScaleValue = (pageScaleValue || pageScale).toString();\n this.pageScale = pageScale;\n this._updateUIState(false);\n }\n\n reset() {\n this.pageNumber = 0;\n this.pageLabel = null;\n this.hasPageLabels = false;\n this.pagesCount = 0;\n this.pageScaleValue = DEFAULT_SCALE_VALUE;\n this.pageScale = DEFAULT_SCALE;\n this._updateUIState(true);\n }\n\n _bindListeners() {\n let { eventBus, items, } = this;\n let self = this;\n\n items.previous.addEventListener('click', function() {\n eventBus.dispatch('previouspage', { source: self, });\n });\n\n items.next.addEventListener('click', function() {\n eventBus.dispatch('nextpage', { source: self, });\n });\n\n items.zoomIn.addEventListener('click', function() {\n eventBus.dispatch('zoomin', { source: self, });\n });\n\n items.zoomOut.addEventListener('click', function() {\n eventBus.dispatch('zoomout', { source: self, });\n });\n\n items.pageNumber.addEventListener('click', function() {\n this.select();\n });\n\n items.pageNumber.addEventListener('change', function() {\n eventBus.dispatch('pagenumberchanged', {\n source: self,\n value: this.value,\n });\n });\n\n items.scaleSelect.addEventListener('change', function() {\n if (this.value === 'custom') {\n return;\n }\n eventBus.dispatch('scalechanged', {\n source: self,\n value: this.value,\n });\n });\n\n items.presentationModeButton.addEventListener('click', function() {\n eventBus.dispatch('presentationmode', { source: self, });\n });\n\n items.openFile.addEventListener('click', function() {\n eventBus.dispatch('openfile', { source: self, });\n });\n\n items.print.addEventListener('click', function() {\n eventBus.dispatch('print', { source: self, });\n });\n\n items.download.addEventListener('click', function() {\n eventBus.dispatch('download', { source: self, });\n });\n\n // Suppress context menus for some controls.\n items.scaleSelect.oncontextmenu = noContextMenuHandler;\n\n eventBus.on('localized', () => {\n this._localized();\n });\n }\n\n _localized() {\n this._wasLocalized = true;\n this._adjustScaleWidth();\n this._updateUIState(true);\n }\n\n _updateUIState(resetNumPages = false) {\n if (!this._wasLocalized) {\n // Don't update the UI state until we localize the toolbar.\n return;\n }\n const { pageNumber, pagesCount, pageScaleValue, pageScale, items, } = this;\n\n if (resetNumPages) {\n if (this.hasPageLabels) {\n items.pageNumber.type = 'text';\n } else {\n items.pageNumber.type = 'number';\n this.l10n.get('of_pages', { pagesCount, }, 'of {{pagesCount}}').\n then((msg) => {\n items.numPages.textContent = msg;\n });\n }\n items.pageNumber.max = pagesCount;\n }\n\n if (this.hasPageLabels) {\n items.pageNumber.value = this.pageLabel;\n this.l10n.get('page_of_pages', { pageNumber, pagesCount, },\n '({{pageNumber}} of {{pagesCount}})').then((msg) => {\n items.numPages.textContent = msg;\n });\n } else {\n items.pageNumber.value = pageNumber;\n }\n\n items.previous.disabled = (pageNumber <= 1);\n items.next.disabled = (pageNumber >= pagesCount);\n\n items.zoomOut.disabled = (pageScale <= MIN_SCALE);\n items.zoomIn.disabled = (pageScale >= MAX_SCALE);\n\n let customScale = Math.round(pageScale * 10000) / 100;\n this.l10n.get('page_scale_percent', { scale: customScale, },\n '{{scale}}%').then((msg) => {\n let options = items.scaleSelect.options;\n let predefinedValueFound = false;\n for (let i = 0, ii = options.length; i < ii; i++) {\n let option = options[i];\n if (option.value !== pageScaleValue) {\n option.selected = false;\n continue;\n }\n option.selected = true;\n predefinedValueFound = true;\n }\n if (!predefinedValueFound) {\n items.customScaleOption.textContent = msg;\n items.customScaleOption.selected = true;\n }\n });\n }\n\n updateLoadingIndicatorState(loading = false) {\n let pageNumberInput = this.items.pageNumber;\n\n pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);\n }\n\n _adjustScaleWidth() {\n let container = this.items.scaleSelectContainer;\n let select = this.items.scaleSelect;\n\n animationStarted.then(function() {\n // Adjust the width of the zoom box to fit the content.\n // Note: If the window is narrow enough that the zoom box is not\n // visible, we temporarily show it to be able to adjust its width.\n if (container.clientWidth === 0) {\n container.setAttribute('style', 'display: inherit;');\n }\n if (container.clientWidth > 0) {\n select.setAttribute('style', 'min-width: inherit;');\n let width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;\n select.setAttribute('style', 'min-width: ' +\n (width + SCALE_SELECT_PADDING) + 'px;');\n container.setAttribute('style', 'min-width: ' + width + 'px; ' +\n 'max-width: ' + width + 'px;');\n }\n });\n }\n}\n\nexport {\n Toolbar,\n};\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;\n\n/**\n * View History - This is a utility for saving various view parameters for\n * recently opened files.\n *\n * The way that the view parameters are stored depends on how PDF.js is built,\n * for 'gulp <flag>' the following cases exist:\n * - FIREFOX or MOZCENTRAL - uses sessionStorage.\n * - GENERIC or CHROME - uses localStorage, if it is available.\n */\nclass ViewHistory {\n constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) {\n this.fingerprint = fingerprint;\n this.cacheSize = cacheSize;\n\n this._initializedPromise = this._readFromStorage().then((databaseStr) => {\n let database = JSON.parse(databaseStr || '{}');\n if (!('files' in database)) {\n database.files = [];\n } else {\n while (database.files.length >= this.cacheSize) {\n database.files.shift();\n }\n }\n let index = -1;\n for (let i = 0, length = database.files.length; i < length; i++) {\n let branch = database.files[i];\n if (branch.fingerprint === this.fingerprint) {\n index = i;\n break;\n }\n }\n if (index === -1) {\n index = database.files.push({ fingerprint: this.fingerprint, }) - 1;\n }\n this.file = database.files[index];\n this.database = database;\n });\n }\n\n async _writeToStorage() {\n let databaseStr = JSON.stringify(this.database);\n\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n sessionStorage.setItem('pdfjs.history', databaseStr);\n return;\n }\n localStorage.setItem('pdfjs.history', databaseStr);\n }\n\n async _readFromStorage() {\n if (typeof PDFJSDev !== 'undefined' &&\n PDFJSDev.test('FIREFOX || MOZCENTRAL')) {\n return sessionStorage.getItem('pdfjs.history');\n }\n return localStorage.getItem('pdfjs.history');\n }\n\n async set(name, val) {\n await this._initializedPromise;\n this.file[name] = val;\n return this._writeToStorage();\n }\n\n async setMultiple(properties) {\n await this._initializedPromise;\n for (let name in properties) {\n this.file[name] = properties[name];\n }\n return this._writeToStorage();\n }\n\n async get(name, defaultValue) {\n await this._initializedPromise;\n let val = this.file[name];\n return val !== undefined ? val : defaultValue;\n }\n\n async getMultiple(properties) {\n await this._initializedPromise;\n let values = Object.create(null);\n\n for (let name in properties) {\n let val = this.file[name];\n values[name] = val !== undefined ? val : properties[name];\n }\n return values;\n }\n}\n\nexport {\n ViewHistory,\n};\n","/* Copyright 2017 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DefaultExternalServices, PDFViewerApplication } from './app';\nimport { BasePreferences } from './preferences';\nimport { DownloadManager } from './download_manager';\nimport { GenericL10n } from './genericl10n';\n\nif (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('GENERIC')) {\n throw new Error('Module \"pdfjs-web/genericcom\" shall not be used outside ' +\n 'GENERIC build.');\n}\n\nlet GenericCom = {};\n\nclass GenericPreferences extends BasePreferences {\n async _writeToStorage(prefObj) {\n localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));\n }\n\n async _readFromStorage(prefObj) {\n return JSON.parse(localStorage.getItem('pdfjs.preferences'));\n }\n}\n\nlet GenericExternalServices = Object.create(DefaultExternalServices);\nGenericExternalServices.createDownloadManager = function(options) {\n return new DownloadManager(options);\n};\nGenericExternalServices.createPreferences = function() {\n return new GenericPreferences();\n};\nGenericExternalServices.createL10n = function({ locale = 'en-US', }) {\n return new GenericL10n(locale);\n};\nPDFViewerApplication.externalServices = GenericExternalServices;\n\nexport {\n GenericCom,\n};\n","/* Copyright 2013 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet defaultPreferences = null;\nfunction getDefaultPreferences() {\n if (!defaultPreferences) {\n if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {\n defaultPreferences = Promise.resolve(\n PDFJSDev.json('$ROOT/web/default_preferences.json'));\n } else {\n defaultPreferences = new Promise(function (resolve) {\n let xhr = new XMLHttpRequest();\n xhr.open('GET', 'default_preferences.json');\n xhr.onload = xhr.onerror = function loaded() {\n try {\n resolve(JSON.parse(xhr.responseText));\n } catch (e) {\n console.error(`Unable to load default preferences: ${e}`);\n resolve({});\n }\n };\n xhr.send();\n });\n }\n }\n return defaultPreferences;\n}\n\n/**\n * BasePreferences - Abstract base class for storing persistent settings.\n * Used for settings that should be applied to all opened documents,\n * or every time the viewer is loaded.\n */\nclass BasePreferences {\n constructor() {\n if (this.constructor === BasePreferences) {\n throw new Error('Cannot initialize BasePreferences.');\n }\n this.prefs = null;\n\n this._initializedPromise = getDefaultPreferences().then((defaults) => {\n Object.defineProperty(this, 'defaults', {\n value: Object.freeze(defaults),\n writable: false,\n enumerable: true,\n configurable: false,\n });\n\n this.prefs = Object.assign(Object.create(null), defaults);\n return this._readFromStorage(defaults);\n }).then((prefs) => {\n if (!prefs) {\n return;\n }\n for (let name in prefs) {\n const defaultValue = this.defaults[name], prefValue = prefs[name];\n // Ignore preferences not present in, or whose types don't match,\n // the default values.\n if (defaultValue === undefined ||\n typeof prefValue !== typeof defaultValue) {\n continue;\n }\n this.prefs[name] = prefValue;\n }\n });\n }\n\n /**\n * Stub function for writing preferences to storage.\n * @param {Object} prefObj The preferences that should be written to storage.\n * @return {Promise} A promise that is resolved when the preference values\n * have been written.\n */\n async _writeToStorage(prefObj) {\n throw new Error('Not implemented: _writeToStorage');\n }\n\n /**\n * Stub function for reading preferences from storage.\n * @param {Object} prefObj The preferences that should be read from storage.\n * @return {Promise} A promise that is resolved with an {Object} containing\n * the preferences that have been read.\n */\n async _readFromStorage(prefObj) {\n throw new Error('Not implemented: _readFromStorage');\n }\n\n /**\n * Reset the preferences to their default values and update storage.\n * @return {Promise} A promise that is resolved when the preference values\n * have been reset.\n */\n async reset() {\n await this._initializedPromise;\n this.prefs = Object.assign(Object.create(null), this.defaults);\n return this._writeToStorage(this.defaults);\n }\n\n /**\n * Set the value of a preference.\n * @param {string} name The name of the preference that should be changed.\n * @param {boolean|number|string} value The new value of the preference.\n * @return {Promise} A promise that is resolved when the value has been set,\n * provided that the preference exists and the types match.\n */\n async set(name, value) {\n await this._initializedPromise;\n let defaultValue = this.defaults[name];\n\n if (defaultValue === undefined) {\n throw new Error(`Set preference: \"${name}\" is undefined.`);\n } else if (value === undefined) {\n throw new Error('Set preference: no value is specified.');\n }\n let valueType = typeof value;\n let defaultType = typeof defaultValue;\n\n if (valueType !== defaultType) {\n if (valueType === 'number' && defaultType === 'string') {\n value = value.toString();\n } else {\n throw new Error(`Set preference: \"${value}\" is a ${valueType}, ` +\n `expected a ${defaultType}.`);\n }\n } else {\n if (valueType === 'number' && !Number.isInteger(value)) {\n throw new Error(`Set preference: \"${value}\" must be an integer.`);\n }\n }\n this.prefs[name] = value;\n return this._writeToStorage(this.prefs);\n }\n\n /**\n * Get the value of a preference.\n * @param {string} name The name of the preference whose value is requested.\n * @return {Promise} A promise that is resolved with a {boolean|number|string}\n * containing the value of the preference.\n */\n async get(name) {\n await this._initializedPromise;\n let defaultValue = this.defaults[name];\n\n if (defaultValue === undefined) {\n throw new Error(`Get preference: \"${name}\" is undefined.`);\n } else {\n let prefValue = this.prefs[name];\n\n if (prefValue !== undefined) {\n return prefValue;\n }\n }\n return defaultValue;\n }\n\n /**\n * Get the values of all preferences.\n * @return {Promise} A promise that is resolved with an {Object} containing\n * the values of all preferences.\n */\n async getAll() {\n await this._initializedPromise;\n return Object.assign(Object.create(null), this.defaults, this.prefs);\n }\n}\n\nexport {\n BasePreferences,\n};\n","/* Copyright 2013 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n apiCompatibilityParams, createObjectURL, createValidAbsoluteUrl, URL\n} from 'pdfjs-lib';\n\nif (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('CHROME || GENERIC')) {\n throw new Error('Module \"pdfjs-web/download_manager\" shall not be used ' +\n 'outside CHROME and GENERIC builds.');\n}\n\nconst DISABLE_CREATE_OBJECT_URL =\n apiCompatibilityParams.disableCreateObjectURL || false;\n\nfunction download(blobUrl, filename) {\n let a = document.createElement('a');\n if (!a.click) {\n throw new Error('DownloadManager: \"a.click()\" is not supported.');\n }\n a.href = blobUrl;\n a.target = '_parent';\n // Use a.download if available. This increases the likelihood that\n // the file is downloaded instead of opened by another PDF plugin.\n if ('download' in a) {\n a.download = filename;\n }\n // <a> must be in the document for IE and recent Firefox versions,\n // otherwise .click() is ignored.\n (document.body || document.documentElement).appendChild(a);\n a.click();\n a.remove();\n}\n\nclass DownloadManager {\n constructor({ disableCreateObjectURL = DISABLE_CREATE_OBJECT_URL, }) {\n this.disableCreateObjectURL = disableCreateObjectURL;\n }\n\n downloadUrl(url, filename) {\n if (!createValidAbsoluteUrl(url, 'http://example.com')) {\n return; // restricted/invalid URL\n }\n download(url + '#pdfjs.action=download', filename);\n }\n\n downloadData(data, filename, contentType) {\n if (navigator.msSaveBlob) { // IE10 and above\n return navigator.msSaveBlob(new Blob([data], { type: contentType, }),\n filename);\n }\n let blobUrl = createObjectURL(data, contentType,\n this.disableCreateObjectURL);\n download(blobUrl, filename);\n }\n\n download(blob, url, filename) {\n if (navigator.msSaveBlob) {\n // IE10 / IE11\n if (!navigator.msSaveBlob(blob, filename)) {\n this.downloadUrl(url, filename);\n }\n return;\n }\n\n if (this.disableCreateObjectURL) {\n // URL.createObjectURL is not supported\n this.downloadUrl(url, filename);\n return;\n }\n\n let blobUrl = URL.createObjectURL(blob);\n download(blobUrl, filename);\n }\n}\n\nexport {\n DownloadManager,\n};\n","/* Copyright 2017 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport '../external/webL10n/l10n';\n\nlet webL10n = document.webL10n;\n\nclass GenericL10n {\n constructor(lang) {\n this._lang = lang;\n this._ready = new Promise((resolve, reject) => {\n webL10n.setLanguage(lang, () => {\n resolve(webL10n);\n });\n });\n }\n\n async getLanguage() {\n const l10n = await this._ready;\n return l10n.getLanguage();\n }\n\n async getDirection() {\n const l10n = await this._ready;\n return l10n.getDirection();\n }\n\n async get(property, args, fallback) {\n const l10n = await this._ready;\n return l10n.get(property, args, fallback);\n }\n\n async translate(element) {\n const l10n = await this._ready;\n return l10n.translate(element);\n }\n}\n\nexport {\n GenericL10n,\n};\n","/**\n * Copyright (c) 2011-2013 Fabien Cazenave, Mozilla.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n/*\n Additional modifications for PDF.js project:\n - Disables language initialization on page loading.\n - Disables document translation on page loading.\n - Removes consoleWarn and consoleLog and use console.log/warn directly.\n - Removes window._ assignment.\n - Remove compatibility code for OldIE.\n*/\n\n/*jshint browser: true, devel: true, es5: true, globalstrict: true */\n'use strict';\n\ndocument.webL10n = (function(window, document, undefined) {\n var gL10nData = {};\n var gTextData = '';\n var gTextProp = 'textContent';\n var gLanguage = '';\n var gMacros = {};\n var gReadyState = 'loading';\n\n\n /**\n * Synchronously loading l10n resources significantly minimizes flickering\n * from displaying the app with non-localized strings and then updating the\n * strings. Although this will block all script execution on this page, we\n * expect that the l10n resources are available locally on flash-storage.\n *\n * As synchronous XHR is generally considered as a bad idea, we're still\n * loading l10n resources asynchronously -- but we keep this in a setting,\n * just in case... and applications using this library should hide their\n * content until the `localized' event happens.\n */\n\n var gAsyncResourceLoading = true; // read-only\n\n\n /**\n * DOM helpers for the so-called \"HTML API\".\n *\n * These functions are written for modern browsers. For old versions of IE,\n * they're overridden in the 'startup' section at the end of this file.\n */\n\n function getL10nResourceLinks() {\n return document.querySelectorAll('link[type=\"application/l10n\"]');\n }\n\n function getL10nDictionary() {\n var script = document.querySelector('script[type=\"application/l10n\"]');\n // TODO: support multiple and external JSON dictionaries\n return script ? JSON.parse(script.innerHTML) : null;\n }\n\n function getTranslatableChildren(element) {\n return element ? element.querySelectorAll('*[data-l10n-id]') : [];\n }\n\n function getL10nAttributes(element) {\n if (!element)\n return {};\n\n var l10nId = element.getAttribute('data-l10n-id');\n var l10nArgs = element.getAttribute('data-l10n-args');\n var args = {};\n if (l10nArgs) {\n try {\n args = JSON.parse(l10nArgs);\n } catch (e) {\n console.warn('could not parse arguments for #' + l10nId);\n }\n }\n return { id: l10nId, args: args };\n }\n\n function fireL10nReadyEvent(lang) {\n var evtObject = document.createEvent('Event');\n evtObject.initEvent('localized', true, false);\n evtObject.language = lang;\n document.dispatchEvent(evtObject);\n }\n\n function xhrLoadText(url, onSuccess, onFailure) {\n onSuccess = onSuccess || function _onSuccess(data) {};\n onFailure = onFailure || function _onFailure() {};\n\n var xhr = new XMLHttpRequest();\n xhr.open('GET', url, gAsyncResourceLoading);\n if (xhr.overrideMimeType) {\n xhr.overrideMimeType('text/plain; charset=utf-8');\n }\n xhr.onreadystatechange = function() {\n if (xhr.readyState == 4) {\n if (xhr.status == 200 || xhr.status === 0) {\n onSuccess(xhr.responseText);\n } else {\n onFailure();\n }\n }\n };\n xhr.onerror = onFailure;\n xhr.ontimeout = onFailure;\n\n // in Firefox OS with the app:// protocol, trying to XHR a non-existing\n // URL will raise an exception here -- hence this ugly try...catch.\n try {\n xhr.send(null);\n } catch (e) {\n onFailure();\n }\n }\n\n\n /**\n * l10n resource parser:\n * - reads (async XHR) the l10n resource matching `lang';\n * - imports linked resources (synchronously) when specified;\n * - parses the text data (fills `gL10nData' and `gTextData');\n * - triggers success/failure callbacks when done.\n *\n * @param {string} href\n * URL of the l10n resource to parse.\n *\n * @param {string} lang\n * locale (language) to parse. Must be a lowercase string.\n *\n * @param {Function} successCallback\n * triggered when the l10n resource has been successfully parsed.\n *\n * @param {Function} failureCallback\n * triggered when the an error has occurred.\n *\n * @return {void}\n * uses the following global variables: gL10nData, gTextData, gTextProp.\n */\n\n function parseResource(href, lang, successCallback, failureCallback) {\n var baseURL = href.replace(/[^\\/]*$/, '') || './';\n\n // handle escaped characters (backslashes) in a string\n function evalString(text) {\n if (text.lastIndexOf('\\\\') < 0)\n return text;\n return text.replace(/\\\\\\\\/g, '\\\\')\n .replace(/\\\\n/g, '\\n')\n .replace(/\\\\r/g, '\\r')\n .replace(/\\\\t/g, '\\t')\n .replace(/\\\\b/g, '\\b')\n .replace(/\\\\f/g, '\\f')\n .replace(/\\\\{/g, '{')\n .replace(/\\\\}/g, '}')\n .replace(/\\\\\"/g, '\"')\n .replace(/\\\\'/g, \"'\");\n }\n\n // parse *.properties text data into an l10n dictionary\n // If gAsyncResourceLoading is false, then the callback will be called\n // synchronously. Otherwise it is called asynchronously.\n function parseProperties(text, parsedPropertiesCallback) {\n var dictionary = {};\n\n // token expressions\n var reBlank = /^\\s*|\\s*$/;\n var reComment = /^\\s*#|^\\s*$/;\n var reSection = /^\\s*\\[(.*)\\]\\s*$/;\n var reImport = /^\\s*@import\\s+url\\((.*)\\)\\s*$/i;\n var reSplit = /^([^=\\s]*)\\s*=\\s*(.+)$/; // TODO: escape EOLs with '\\'\n\n // parse the *.properties file into an associative array\n function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {\n var entries = rawText.replace(reBlank, '').split(/[\\r\\n]+/);\n var currentLang = '*';\n var genericLang = lang.split('-', 1)[0];\n var skipLang = false;\n var match = '';\n\n function nextEntry() {\n // Use infinite loop instead of recursion to avoid reaching the\n // maximum recursion limit for content with many lines.\n while (true) {\n if (!entries.length) {\n parsedRawLinesCallback();\n return;\n }\n var line = entries.shift();\n\n // comment or blank line?\n if (reComment.test(line))\n continue;\n\n // the extended syntax supports [lang] sections and @import rules\n if (extendedSyntax) {\n match = reSection.exec(line);\n if (match) { // section start?\n // RFC 4646, section 4.4, \"All comparisons MUST be performed\n // in a case-insensitive manner.\"\n\n currentLang = match[1].toLowerCase();\n skipLang = (currentLang !== '*') &&\n (currentLang !== lang) && (currentLang !== genericLang);\n continue;\n } else if (skipLang) {\n continue;\n }\n match = reImport.exec(line);\n if (match) { // @import rule?\n loadImport(baseURL + match[1], nextEntry);\n return;\n }\n }\n\n // key-value pair\n var tmp = line.match(reSplit);\n if (tmp && tmp.length == 3) {\n dictionary[tmp[1]] = evalString(tmp[2]);\n }\n }\n }\n nextEntry();\n }\n\n // import another *.properties file\n function loadImport(url, callback) {\n xhrLoadText(url, function(content) {\n parseRawLines(content, false, callback); // don't allow recursive imports\n }, function () {\n console.warn(url + ' not found.');\n callback();\n });\n }\n\n // fill the dictionary\n parseRawLines(text, true, function() {\n parsedPropertiesCallback(dictionary);\n });\n }\n\n // load and parse l10n data (warning: global variables are used here)\n xhrLoadText(href, function(response) {\n gTextData += response; // mostly for debug\n\n // parse *.properties text data into an l10n dictionary\n parseProperties(response, function(data) {\n\n // find attribute descriptions, if any\n for (var key in data) {\n var id, prop, index = key.lastIndexOf('.');\n if (index > 0) { // an attribute has been specified\n id = key.substring(0, index);\n prop = key.substring(index + 1);\n } else { // no attribute: assuming text content by default\n id = key;\n prop = gTextProp;\n }\n if (!gL10nData[id]) {\n gL10nData[id] = {};\n }\n gL10nData[id][prop] = data[key];\n }\n\n // trigger callback\n if (successCallback) {\n successCallback();\n }\n });\n }, failureCallback);\n }\n\n // load and parse all resources for the specified locale\n function loadLocale(lang, callback) {\n // RFC 4646, section 2.1 states that language tags have to be treated as\n // case-insensitive. Convert to lowercase for case-insensitive comparisons.\n if (lang) {\n lang = lang.toLowerCase();\n }\n\n callback = callback || function _callback() {};\n\n clear();\n gLanguage = lang;\n\n // check all <link type=\"application/l10n\" href=\"...\" /> nodes\n // and load the resource files\n var langLinks = getL10nResourceLinks();\n var langCount = langLinks.length;\n if (langCount === 0) {\n // we might have a pre-compiled dictionary instead\n var dict = getL10nDictionary();\n if (dict && dict.locales && dict.default_locale) {\n console.log('using the embedded JSON directory, early way out');\n gL10nData = dict.locales[lang];\n if (!gL10nData) {\n var defaultLocale = dict.default_locale.toLowerCase();\n for (var anyCaseLang in dict.locales) {\n anyCaseLang = anyCaseLang.toLowerCase();\n if (anyCaseLang === lang) {\n gL10nData = dict.locales[lang];\n break;\n } else if (anyCaseLang === defaultLocale) {\n gL10nData = dict.locales[defaultLocale];\n }\n }\n }\n callback();\n } else {\n console.log('no resource to load, early way out');\n }\n // early way out\n fireL10nReadyEvent(lang);\n gReadyState = 'complete';\n return;\n }\n\n // start the callback when all resources are loaded\n var onResourceLoaded = null;\n var gResourceCount = 0;\n onResourceLoaded = function() {\n gResourceCount++;\n if (gResourceCount >= langCount) {\n callback();\n fireL10nReadyEvent(lang);\n gReadyState = 'complete';\n }\n };\n\n // load all resource files\n function L10nResourceLink(link) {\n var href = link.href;\n // Note: If |gAsyncResourceLoading| is false, then the following callbacks\n // are synchronously called.\n this.load = function(lang, callback) {\n parseResource(href, lang, callback, function() {\n console.warn(href + ' not found.');\n // lang not found, used default resource instead\n console.warn('\"' + lang + '\" resource not found');\n gLanguage = '';\n // Resource not loaded, but we still need to call the callback.\n callback();\n });\n };\n }\n\n for (var i = 0; i < langCount; i++) {\n var resource = new L10nResourceLink(langLinks[i]);\n resource.load(lang, onResourceLoaded);\n }\n }\n\n // clear all l10n data\n function clear() {\n gL10nData = {};\n gTextData = '';\n gLanguage = '';\n // TODO: clear all non predefined macros.\n // There's no such macro /yet/ but we're planning to have some...\n }\n\n\n /**\n * Get rules for plural forms (shared with JetPack), see:\n * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html\n * https://github.com/mozilla/addon-sdk/blob/master/python-lib/plural-rules-generator.p\n *\n * @param {string} lang\n * locale (language) used.\n *\n * @return {Function}\n * returns a function that gives the plural form name for a given integer:\n * var fun = getPluralRules('en');\n * fun(1) -> 'one'\n * fun(0) -> 'other'\n * fun(1000) -> 'other'.\n */\n\n function getPluralRules(lang) {\n var locales2rules = {\n 'af': 3,\n 'ak': 4,\n 'am': 4,\n 'ar': 1,\n 'asa': 3,\n 'az': 0,\n 'be': 11,\n 'bem': 3,\n 'bez': 3,\n 'bg': 3,\n 'bh': 4,\n 'bm': 0,\n 'bn': 3,\n 'bo': 0,\n 'br': 20,\n 'brx': 3,\n 'bs': 11,\n 'ca': 3,\n 'cgg': 3,\n 'chr': 3,\n 'cs': 12,\n 'cy': 17,\n 'da': 3,\n 'de': 3,\n 'dv': 3,\n 'dz': 0,\n 'ee': 3,\n 'el': 3,\n 'en': 3,\n 'eo': 3,\n 'es': 3,\n 'et': 3,\n 'eu': 3,\n 'fa': 0,\n 'ff': 5,\n 'fi': 3,\n 'fil': 4,\n 'fo': 3,\n 'fr': 5,\n 'fur': 3,\n 'fy': 3,\n 'ga': 8,\n 'gd': 24,\n 'gl': 3,\n 'gsw': 3,\n 'gu': 3,\n 'guw': 4,\n 'gv': 23,\n 'ha': 3,\n 'haw': 3,\n 'he': 2,\n 'hi': 4,\n 'hr': 11,\n 'hu': 0,\n 'id': 0,\n 'ig': 0,\n 'ii': 0,\n 'is': 3,\n 'it': 3,\n 'iu': 7,\n 'ja': 0,\n 'jmc': 3,\n 'jv': 0,\n 'ka': 0,\n 'kab': 5,\n 'kaj': 3,\n 'kcg': 3,\n 'kde': 0,\n 'kea': 0,\n 'kk': 3,\n 'kl': 3,\n 'km': 0,\n 'kn': 0,\n 'ko': 0,\n 'ksb': 3,\n 'ksh': 21,\n 'ku': 3,\n 'kw': 7,\n 'lag': 18,\n 'lb': 3,\n 'lg': 3,\n 'ln': 4,\n 'lo': 0,\n 'lt': 10,\n 'lv': 6,\n 'mas': 3,\n 'mg': 4,\n 'mk': 16,\n 'ml': 3,\n 'mn': 3,\n 'mo': 9,\n 'mr': 3,\n 'ms': 0,\n 'mt': 15,\n 'my': 0,\n 'nah': 3,\n 'naq': 7,\n 'nb': 3,\n 'nd': 3,\n 'ne': 3,\n 'nl': 3,\n 'nn': 3,\n 'no': 3,\n 'nr': 3,\n 'nso': 4,\n 'ny': 3,\n 'nyn': 3,\n 'om': 3,\n 'or': 3,\n 'pa': 3,\n 'pap': 3,\n 'pl': 13,\n 'ps': 3,\n 'pt': 3,\n 'rm': 3,\n 'ro': 9,\n 'rof': 3,\n 'ru': 11,\n 'rwk': 3,\n 'sah': 0,\n 'saq': 3,\n 'se': 7,\n 'seh': 3,\n 'ses': 0,\n 'sg': 0,\n 'sh': 11,\n 'shi': 19,\n 'sk': 12,\n 'sl': 14,\n 'sma': 7,\n 'smi': 7,\n 'smj': 7,\n 'smn': 7,\n 'sms': 7,\n 'sn': 3,\n 'so': 3,\n 'sq': 3,\n 'sr': 11,\n 'ss': 3,\n 'ssy': 3,\n 'st': 3,\n 'sv': 3,\n 'sw': 3,\n 'syr': 3,\n 'ta': 3,\n 'te': 3,\n 'teo': 3,\n 'th': 0,\n 'ti': 4,\n 'tig': 3,\n 'tk': 3,\n 'tl': 4,\n 'tn': 3,\n 'to': 0,\n 'tr': 0,\n 'ts': 3,\n 'tzm': 22,\n 'uk': 11,\n 'ur': 3,\n 've': 3,\n 'vi': 0,\n 'vun': 3,\n 'wa': 4,\n 'wae': 3,\n 'wo': 0,\n 'xh': 3,\n 'xog': 3,\n 'yo': 0,\n 'zh': 0,\n 'zu': 3\n };\n\n // utility functions for plural rules methods\n function isIn(n, list) {\n return list.indexOf(n) !== -1;\n }\n function isBetween(n, start, end) {\n return start <= n && n <= end;\n }\n\n // list of all plural rules methods:\n // map an integer to the plural form name to use\n var pluralRules = {\n '0': function(n) {\n return 'other';\n },\n '1': function(n) {\n if ((isBetween((n % 100), 3, 10)))\n return 'few';\n if (n === 0)\n return 'zero';\n if ((isBetween((n % 100), 11, 99)))\n return 'many';\n if (n == 2)\n return 'two';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '2': function(n) {\n if (n !== 0 && (n % 10) === 0)\n return 'many';\n if (n == 2)\n return 'two';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '3': function(n) {\n if (n == 1)\n return 'one';\n return 'other';\n },\n '4': function(n) {\n if ((isBetween(n, 0, 1)))\n return 'one';\n return 'other';\n },\n '5': function(n) {\n if ((isBetween(n, 0, 2)) && n != 2)\n return 'one';\n return 'other';\n },\n '6': function(n) {\n if (n === 0)\n return 'zero';\n if ((n % 10) == 1 && (n % 100) != 11)\n return 'one';\n return 'other';\n },\n '7': function(n) {\n if (n == 2)\n return 'two';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '8': function(n) {\n if ((isBetween(n, 3, 6)))\n return 'few';\n if ((isBetween(n, 7, 10)))\n return 'many';\n if (n == 2)\n return 'two';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '9': function(n) {\n if (n === 0 || n != 1 && (isBetween((n % 100), 1, 19)))\n return 'few';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '10': function(n) {\n if ((isBetween((n % 10), 2, 9)) && !(isBetween((n % 100), 11, 19)))\n return 'few';\n if ((n % 10) == 1 && !(isBetween((n % 100), 11, 19)))\n return 'one';\n return 'other';\n },\n '11': function(n) {\n if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14)))\n return 'few';\n if ((n % 10) === 0 ||\n (isBetween((n % 10), 5, 9)) ||\n (isBetween((n % 100), 11, 14)))\n return 'many';\n if ((n % 10) == 1 && (n % 100) != 11)\n return 'one';\n return 'other';\n },\n '12': function(n) {\n if ((isBetween(n, 2, 4)))\n return 'few';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '13': function(n) {\n if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14)))\n return 'few';\n if (n != 1 && (isBetween((n % 10), 0, 1)) ||\n (isBetween((n % 10), 5, 9)) ||\n (isBetween((n % 100), 12, 14)))\n return 'many';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '14': function(n) {\n if ((isBetween((n % 100), 3, 4)))\n return 'few';\n if ((n % 100) == 2)\n return 'two';\n if ((n % 100) == 1)\n return 'one';\n return 'other';\n },\n '15': function(n) {\n if (n === 0 || (isBetween((n % 100), 2, 10)))\n return 'few';\n if ((isBetween((n % 100), 11, 19)))\n return 'many';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '16': function(n) {\n if ((n % 10) == 1 && n != 11)\n return 'one';\n return 'other';\n },\n '17': function(n) {\n if (n == 3)\n return 'few';\n if (n === 0)\n return 'zero';\n if (n == 6)\n return 'many';\n if (n == 2)\n return 'two';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '18': function(n) {\n if (n === 0)\n return 'zero';\n if ((isBetween(n, 0, 2)) && n !== 0 && n != 2)\n return 'one';\n return 'other';\n },\n '19': function(n) {\n if ((isBetween(n, 2, 10)))\n return 'few';\n if ((isBetween(n, 0, 1)))\n return 'one';\n return 'other';\n },\n '20': function(n) {\n if ((isBetween((n % 10), 3, 4) || ((n % 10) == 9)) && !(\n isBetween((n % 100), 10, 19) ||\n isBetween((n % 100), 70, 79) ||\n isBetween((n % 100), 90, 99)\n ))\n return 'few';\n if ((n % 1000000) === 0 && n !== 0)\n return 'many';\n if ((n % 10) == 2 && !isIn((n % 100), [12, 72, 92]))\n return 'two';\n if ((n % 10) == 1 && !isIn((n % 100), [11, 71, 91]))\n return 'one';\n return 'other';\n },\n '21': function(n) {\n if (n === 0)\n return 'zero';\n if (n == 1)\n return 'one';\n return 'other';\n },\n '22': function(n) {\n if ((isBetween(n, 0, 1)) || (isBetween(n, 11, 99)))\n return 'one';\n return 'other';\n },\n '23': function(n) {\n if ((isBetween((n % 10), 1, 2)) || (n % 20) === 0)\n return 'one';\n return 'other';\n },\n '24': function(n) {\n if ((isBetween(n, 3, 10) || isBetween(n, 13, 19)))\n return 'few';\n if (isIn(n, [2, 12]))\n return 'two';\n if (isIn(n, [1, 11]))\n return 'one';\n return 'other';\n }\n };\n\n // return a function that gives the plural form name for a given integer\n var index = locales2rules[lang.replace(/-.*$/, '')];\n if (!(index in pluralRules)) {\n console.warn('plural form unknown for [' + lang + ']');\n return function() { return 'other'; };\n }\n return pluralRules[index];\n }\n\n // pre-defined 'plural' macro\n gMacros.plural = function(str, param, key, prop) {\n var n = parseFloat(param);\n if (isNaN(n))\n return str;\n\n // TODO: support other properties (l20n still doesn't...)\n if (prop != gTextProp)\n return str;\n\n // initialize _pluralRules\n if (!gMacros._pluralRules) {\n gMacros._pluralRules = getPluralRules(gLanguage);\n }\n var index = '[' + gMacros._pluralRules(n) + ']';\n\n // try to find a [zero|one|two] key if it's defined\n if (n === 0 && (key + '[zero]') in gL10nData) {\n str = gL10nData[key + '[zero]'][prop];\n } else if (n == 1 && (key + '[one]') in gL10nData) {\n str = gL10nData[key + '[one]'][prop];\n } else if (n == 2 && (key + '[two]') in gL10nData) {\n str = gL10nData[key + '[two]'][prop];\n } else if ((key + index) in gL10nData) {\n str = gL10nData[key + index][prop];\n } else if ((key + '[other]') in gL10nData) {\n str = gL10nData[key + '[other]'][prop];\n }\n\n return str;\n };\n\n\n /**\n * l10n dictionary functions\n */\n\n // fetch an l10n object, warn if not found, apply `args' if possible\n function getL10nData(key, args, fallback) {\n var data = gL10nData[key];\n if (!data) {\n console.warn('#' + key + ' is undefined.');\n if (!fallback) {\n return null;\n }\n data = fallback;\n }\n\n /** This is where l10n expressions should be processed.\n * The plan is to support C-style expressions from the l20n project;\n * until then, only two kinds of simple expressions are supported:\n * {[ index ]} and {{ arguments }}.\n */\n var rv = {};\n for (var prop in data) {\n var str = data[prop];\n str = substIndexes(str, args, key, prop);\n str = substArguments(str, args, key);\n rv[prop] = str;\n }\n return rv;\n }\n\n // replace {[macros]} with their values\n function substIndexes(str, args, key, prop) {\n var reIndex = /\\{\\[\\s*([a-zA-Z]+)\\(([a-zA-Z]+)\\)\\s*\\]\\}/;\n var reMatch = reIndex.exec(str);\n if (!reMatch || !reMatch.length)\n return str;\n\n // an index/macro has been found\n // Note: at the moment, only one parameter is supported\n var macroName = reMatch[1];\n var paramName = reMatch[2];\n var param;\n if (args && paramName in args) {\n param = args[paramName];\n } else if (paramName in gL10nData) {\n param = gL10nData[paramName];\n }\n\n // there's no macro parser yet: it has to be defined in gMacros\n if (macroName in gMacros) {\n var macro = gMacros[macroName];\n str = macro(str, param, key, prop);\n }\n return str;\n }\n\n // replace {{arguments}} with their values\n function substArguments(str, args, key) {\n var reArgs = /\\{\\{\\s*(.+?)\\s*\\}\\}/g;\n return str.replace(reArgs, function(matched_text, arg) {\n if (args && arg in args) {\n return args[arg];\n }\n if (arg in gL10nData) {\n return gL10nData[arg];\n }\n console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');\n return matched_text;\n });\n }\n\n // translate an HTML element\n function translateElement(element) {\n var l10n = getL10nAttributes(element);\n if (!l10n.id)\n return;\n\n // get the related l10n object\n var data = getL10nData(l10n.id, l10n.args);\n if (!data) {\n console.warn('#' + l10n.id + ' is undefined.');\n return;\n }\n\n // translate element (TODO: security checks?)\n if (data[gTextProp]) { // XXX\n if (getChildElementCount(element) === 0) {\n element[gTextProp] = data[gTextProp];\n } else {\n // this element has element children: replace the content of the first\n // (non-empty) child textNode and clear other child textNodes\n var children = element.childNodes;\n var found = false;\n for (var i = 0, l = children.length; i < l; i++) {\n if (children[i].nodeType === 3 && /\\S/.test(children[i].nodeValue)) {\n if (found) {\n children[i].nodeValue = '';\n } else {\n children[i].nodeValue = data[gTextProp];\n found = true;\n }\n }\n }\n // if no (non-empty) textNode is found, insert a textNode before the\n // first element child.\n if (!found) {\n var textNode = document.createTextNode(data[gTextProp]);\n element.insertBefore(textNode, element.firstChild);\n }\n }\n delete data[gTextProp];\n }\n\n for (var k in data) {\n element[k] = data[k];\n }\n }\n\n // webkit browsers don't currently support 'children' on SVG elements...\n function getChildElementCount(element) {\n if (element.children) {\n return element.children.length;\n }\n if (typeof element.childElementCount !== 'undefined') {\n return element.childElementCount;\n }\n var count = 0;\n for (var i = 0; i < element.childNodes.length; i++) {\n count += element.nodeType === 1 ? 1 : 0;\n }\n return count;\n }\n\n // translate an HTML subtree\n function translateFragment(element) {\n element = element || document.documentElement;\n\n // check all translatable children (= w/ a `data-l10n-id' attribute)\n var children = getTranslatableChildren(element);\n var elementCount = children.length;\n for (var i = 0; i < elementCount; i++) {\n translateElement(children[i]);\n }\n\n // translate element itself if necessary\n translateElement(element);\n }\n\n return {\n // get a localized string\n get: function(key, args, fallbackString) {\n var index = key.lastIndexOf('.');\n var prop = gTextProp;\n if (index > 0) { // An attribute has been specified\n prop = key.substring(index + 1);\n key = key.substring(0, index);\n }\n var fallback;\n if (fallbackString) {\n fallback = {};\n fallback[prop] = fallbackString;\n }\n var data = getL10nData(key, args, fallback);\n if (data && prop in data) {\n return data[prop];\n }\n return '{{' + key + '}}';\n },\n\n // debug\n getData: function() { return gL10nData; },\n getText: function() { return gTextData; },\n\n // get|set the document language\n getLanguage: function() { return gLanguage; },\n setLanguage: function(lang, callback) {\n loadLocale(lang, function() {\n if (callback)\n callback();\n });\n },\n\n // get the direction (ltr|rtl) of the current language\n getDirection: function() {\n // http://www.w3.org/International/questions/qa-scripts\n // Arabic, Hebrew, Farsi, Pashto, Urdu\n var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];\n var shortCode = gLanguage.split('-', 1)[0];\n return (rtlList.indexOf(shortCode) >= 0) ? 'rtl' : 'ltr';\n },\n\n // translate an element or document fragment\n translate: translateFragment,\n\n // this can be used to prevent race conditions\n getReadyState: function() { return gReadyState; },\n ready: function(callback) {\n if (!callback) {\n return;\n } else if (gReadyState == 'complete' || gReadyState == 'interactive') {\n window.setTimeout(function() {\n callback();\n });\n } else if (document.addEventListener) {\n document.addEventListener('localized', function once() {\n document.removeEventListener('localized', once);\n callback();\n });\n }\n }\n };\n}) (window, document);\n","/* Copyright 2016 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CSS_UNITS, NullL10n } from './ui_utils';\nimport { PDFPrintServiceFactory, PDFViewerApplication } from './app';\nimport { URL } from 'pdfjs-lib';\n\nlet activeService = null;\nlet overlayManager = null;\n\n// Renders the page to the canvas of the given print service, and returns\n// the suggested dimensions of the output page.\nfunction renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {\n let scratchCanvas = activeService.scratchCanvas;\n\n // The size of the canvas in pixels for printing.\n const PRINT_RESOLUTION = 150;\n const PRINT_UNITS = PRINT_RESOLUTION / 72.0;\n scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);\n scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);\n\n // The physical size of the img as specified by the PDF document.\n let width = Math.floor(size.width * CSS_UNITS) + 'px';\n let height = Math.floor(size.height * CSS_UNITS) + 'px';\n\n let ctx = scratchCanvas.getContext('2d');\n ctx.save();\n ctx.fillStyle = 'rgb(255, 255, 255)';\n ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);\n ctx.restore();\n\n return pdfDocument.getPage(pageNumber).then(function(pdfPage) {\n let renderContext = {\n canvasContext: ctx,\n transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],\n viewport: pdfPage.getViewport(1, size.rotation),\n intent: 'print',\n };\n return pdfPage.render(renderContext).promise;\n }).then(function() {\n return {\n width,\n height,\n };\n });\n}\n\nfunction PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {\n this.pdfDocument = pdfDocument;\n this.pagesOverview = pagesOverview;\n this.printContainer = printContainer;\n this.l10n = l10n || NullL10n;\n this.disableCreateObjectURL =\n pdfDocument.loadingParams['disableCreateObjectURL'];\n this.currentPage = -1;\n // The temporary canvas where renderPage paints one page at a time.\n this.scratchCanvas = document.createElement('canvas');\n}\n\nPDFPrintService.prototype = {\n layout() {\n this.throwIfInactive();\n\n let body = document.querySelector('body');\n body.setAttribute('data-pdfjsprinting', true);\n\n let hasEqualPageSizes = this.pagesOverview.every(function(size) {\n return size.width === this.pagesOverview[0].width &&\n size.height === this.pagesOverview[0].height;\n }, this);\n if (!hasEqualPageSizes) {\n console.warn('Not all pages have the same size. The printed ' +\n 'result may be incorrect!');\n }\n\n // Insert a @page + size rule to make sure that the page size is correctly\n // set. Note that we assume that all pages have the same size, because\n // variable-size pages are not supported yet (e.g. in Chrome & Firefox).\n // TODO(robwu): Use named pages when size calculation bugs get resolved\n // (e.g. https://crbug.com/355116) AND when support for named pages is\n // added (http://www.w3.org/TR/css3-page/#using-named-pages).\n // In browsers where @page + size is not supported (such as Firefox,\n // https://bugzil.la/851441), the next stylesheet will be ignored and the\n // user has to select the correct paper size in the UI if wanted.\n this.pageStyleSheet = document.createElement('style');\n let pageSize = this.pagesOverview[0];\n this.pageStyleSheet.textContent =\n // \"size:<width> <height>\" is what we need. But also add \"A4\" because\n // Firefox incorrectly reports support for the other value.\n '@supports ((size:A4) and (size:1pt 1pt)) {' +\n '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' +\n '}';\n body.appendChild(this.pageStyleSheet);\n },\n\n destroy() {\n if (activeService !== this) {\n // |activeService| cannot be replaced without calling destroy() first,\n // so if it differs then an external consumer has a stale reference to\n // us.\n return;\n }\n this.printContainer.textContent = '';\n if (this.pageStyleSheet) {\n this.pageStyleSheet.remove();\n this.pageStyleSheet = null;\n }\n this.scratchCanvas.width = this.scratchCanvas.height = 0;\n this.scratchCanvas = null;\n activeService = null;\n ensureOverlay().then(function() {\n if (overlayManager.active !== 'printServiceOverlay') {\n return; // overlay was already closed\n }\n overlayManager.close('printServiceOverlay');\n });\n },\n\n renderPages() {\n let pageCount = this.pagesOverview.length;\n let renderNextPage = (resolve, reject) => {\n this.throwIfInactive();\n if (++this.currentPage >= pageCount) {\n renderProgress(pageCount, pageCount, this.l10n);\n resolve();\n return;\n }\n let index = this.currentPage;\n renderProgress(index, pageCount, this.l10n);\n renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index])\n .then(this.useRenderedPage.bind(this))\n .then(function() {\n renderNextPage(resolve, reject);\n }, reject);\n };\n return new Promise(renderNextPage);\n },\n\n useRenderedPage(printItem) {\n this.throwIfInactive();\n let img = document.createElement('img');\n img.style.width = printItem.width;\n img.style.height = printItem.height;\n\n let scratchCanvas = this.scratchCanvas;\n if (('toBlob' in scratchCanvas) && !this.disableCreateObjectURL) {\n scratchCanvas.toBlob(function(blob) {\n img.src = URL.createObjectURL(blob);\n });\n } else {\n img.src = scratchCanvas.toDataURL();\n }\n\n let wrapper = document.createElement('div');\n wrapper.appendChild(img);\n this.printContainer.appendChild(wrapper);\n\n return new Promise(function(resolve, reject) {\n img.onload = resolve;\n img.onerror = reject;\n });\n },\n\n performPrint() {\n this.throwIfInactive();\n return new Promise((resolve) => {\n // Push window.print in the macrotask queue to avoid being affected by\n // the deprecation of running print() code in a microtask, see\n // https://github.com/mozilla/pdf.js/issues/7547.\n setTimeout(() => {\n if (!this.active) {\n resolve();\n return;\n }\n print.call(window);\n // Delay promise resolution in case print() was not synchronous.\n setTimeout(resolve, 20); // Tidy-up.\n }, 0);\n });\n },\n\n get active() {\n return this === activeService;\n },\n\n throwIfInactive() {\n if (!this.active) {\n throw new Error('This print request was cancelled or completed.');\n }\n },\n};\n\nlet print = window.print;\nwindow.print = function print() {\n if (activeService) {\n console.warn('Ignored window.print() because of a pending print job.');\n return;\n }\n ensureOverlay().then(function() {\n if (activeService) {\n overlayManager.open('printServiceOverlay');\n }\n });\n\n try {\n dispatchEvent('beforeprint');\n } finally {\n if (!activeService) {\n console.error('Expected print service to be initialized.');\n ensureOverlay().then(function() {\n if (overlayManager.active === 'printServiceOverlay') {\n overlayManager.close('printServiceOverlay');\n }\n });\n return; // eslint-disable-line no-unsafe-finally\n }\n let activeServiceOnEntry = activeService;\n activeService.renderPages().then(function() {\n return activeServiceOnEntry.performPrint();\n }).catch(function() {\n // Ignore any error messages.\n }).then(function() {\n // aborts acts on the \"active\" print request, so we need to check\n // whether the print request (activeServiceOnEntry) is still active.\n // Without the check, an unrelated print request (created after aborting\n // this print request while the pages were being generated) would be\n // aborted.\n if (activeServiceOnEntry.active) {\n abort();\n }\n });\n }\n};\n\nfunction dispatchEvent(eventType) {\n let event = document.createEvent('CustomEvent');\n event.initCustomEvent(eventType, false, false, 'custom');\n window.dispatchEvent(event);\n}\n\nfunction abort() {\n if (activeService) {\n activeService.destroy();\n dispatchEvent('afterprint');\n }\n}\n\nfunction renderProgress(index, total, l10n) {\n let progressContainer = document.getElementById('printServiceOverlay');\n let progress = Math.round(100 * index / total);\n let progressBar = progressContainer.querySelector('progress');\n let progressPerc = progressContainer.querySelector('.relative-progress');\n progressBar.value = progress;\n l10n.get('print_progress_percent', { progress, }, progress + '%').\n then((msg) => {\n progressPerc.textContent = msg;\n });\n}\n\nlet hasAttachEvent = !!document.attachEvent;\n\nwindow.addEventListener('keydown', function(event) {\n // Intercept Cmd/Ctrl + P in all browsers.\n // Also intercept Cmd/Ctrl + Shift + P in Chrome and Opera\n if (event.keyCode === /* P= */ 80 && (event.ctrlKey || event.metaKey) &&\n !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {\n window.print();\n if (hasAttachEvent) {\n // Only attachEvent can cancel Ctrl + P dialog in IE <=10\n // attachEvent is gone in IE11, so the dialog will re-appear in IE11.\n return;\n }\n event.preventDefault();\n if (event.stopImmediatePropagation) {\n event.stopImmediatePropagation();\n } else {\n event.stopPropagation();\n }\n return;\n }\n}, true);\nif (hasAttachEvent) {\n document.attachEvent('onkeydown', function(event) {\n event = event || window.event;\n if (event.keyCode === /* P= */ 80 && event.ctrlKey) {\n event.keyCode = 0;\n return false;\n }\n });\n}\n\nif ('onbeforeprint' in window) {\n // Do not propagate before/afterprint events when they are not triggered\n // from within this polyfill. (FF /IE / Chrome 63+).\n let stopPropagationIfNeeded = function(event) {\n if (event.detail !== 'custom' && event.stopImmediatePropagation) {\n event.stopImmediatePropagation();\n }\n };\n window.addEventListener('beforeprint', stopPropagationIfNeeded);\n window.addEventListener('afterprint', stopPropagationIfNeeded);\n}\n\nlet overlayPromise;\nfunction ensureOverlay() {\n if (!overlayPromise) {\n overlayManager = PDFViewerApplication.overlayManager;\n if (!overlayManager) {\n throw new Error('The overlay manager has not yet been initialized.');\n }\n\n overlayPromise = overlayManager.register('printServiceOverlay',\n document.getElementById('printServiceOverlay'), abort, true);\n document.getElementById('printCancel').onclick = abort;\n }\n return overlayPromise;\n}\n\nPDFPrintServiceFactory.instance = {\n supportsPrinting: true,\n\n createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {\n if (activeService) {\n throw new Error('The print service is created and active.');\n }\n activeService = new PDFPrintService(pdfDocument, pagesOverview,\n printContainer, l10n);\n return activeService;\n },\n};\n\nexport {\n PDFPrintService,\n};\n"],"sourceRoot":""}