ngx-extended-pdf-viewer
Version:
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
22 lines • 324 kB
JavaScript
window.ngxZone.runOutsideAngular(() => {
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright 2023 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* JavaScript code in this page
*/(()=>{"use strict";var e=[,(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.GenericCom=void 0;var n=i(2),s=i(45),r=i(46),o=i(47),a=i(49);t.GenericCom={};class GenericPreferences extends s.BasePreferences{async _writeToStorage(e){try{localStorage.setItem("pdfjs.preferences",JSON.stringify(e))}catch(e){}}async _readFromStorage(e){try{return JSON.parse(localStorage.getItem("pdfjs.preferences"))}catch(e){return{}}}}class GenericExternalServices extends n.DefaultExternalServices{static createDownloadManager(){return new r.DownloadManager}static createPreferences(){return new GenericPreferences}static createL10n({locale:e="en-US"}){return new o.GenericL10n(e)}static createScripting({sandboxBundleSrc:e}){return new a.GenericScripting(e)}}n.PDFViewerApplication.externalServices=GenericExternalServices},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFViewerApplication=t.PDFPrintServiceFactory=t.DefaultExternalServices=void 0;var n=i(3),s=i(4),r=i(5),o=i(6),a=i(7),l=i(8),h=i(9),d=i(10),c=i(11),u=i(12),p=i(14),g=i(16),f=i(17),m=i(18),w=i(20),b=i(21),v=i(22),y=i(23),P=i(24),_=i(25),S=i(26),E=i(27),C=i(29),T=i(42),x=i(43),L=i(44);const I=1e3,M=-1,A=1,D={AUTOMATIC:0,LIGHT:1,DARK:2};class DefaultExternalServices{constructor(){throw new Error("Cannot initialize DefaultExternalServices.")}static updateFindControlState(e){}static updateFindMatchesCount(e){}static initPassiveLoading(e){}static reportTelemetry(e){}static createDownloadManager(){throw new Error("Not implemented: createDownloadManager")}static createPreferences(){throw new Error("Not implemented: createPreferences")}static createL10n(e){throw new Error("Not implemented: createL10n")}static createScripting(e){throw new Error("Not implemented: createScripting")}static get supportsPinchToZoom(){return(0,s.shadow)(this,"supportsPinchToZoom",!0)}static get supportsIntegratedFind(){return(0,s.shadow)(this,"supportsIntegratedFind",!1)}static get supportsDocumentFonts(){return(0,s.shadow)(this,"supportsDocumentFonts",!0)}static get supportedMouseWheelZoomModifierKeys(){return(0,s.shadow)(this,"supportedMouseWheelZoomModifierKeys",{ctrlKey:!0,metaKey:!0})}static get isInAutomation(){return(0,s.shadow)(this,"isInAutomation",!1)}static updateEditorStates(e){throw new Error("Not implemented: updateEditorStates")}static get canvasMaxAreaInBytes(){return(0,s.shadow)(this,"canvasMaxAreaInBytes",-1)}static getNimbusExperimentData(){return(0,s.shadow)(this,"getNimbusExperimentData",Promise.resolve(null))}}t.DefaultExternalServices=DefaultExternalServices;const B=t.PDFViewerApplication={initialBookmark:document.location.hash.substring(1),_initializedCapability:new s.PromiseCapability,appConfig:null,pdfDocument:null,pdfLoadingTask:null,printService:null,pdfViewer:null,pdfThumbnailViewer:null,pdfRenderingQueue:null,pdfPresentationMode:null,pdfDocumentProperties:null,pdfLinkService:null,pdfHistory:null,pdfSidebar:null,pdfOutlineViewer:null,pdfAttachmentViewer:null,pdfLayerViewer:null,pdfCursorTools:null,pdfScriptingManager:null,store:null,downloadManager:null,overlayManager:null,preferences:null,toolbar:null,secondaryToolbar:null,eventBus:null,l10n:null,annotationEditorParams:null,isInitialViewSet:!1,downloadComplete:!1,isViewerEmbedded:window.parent!==window,url:"",baseUrl:"",_downloadUrl:"",externalServices:DefaultExternalServices,_boundEvents:Object.create(null),documentInfo:null,metadata:null,_contentDispositionFilename:null,_contentLength:null,_saveInProgress:!1,_wheelUnusedTicks:0,_wheelUnusedFactor:1,_touchUnusedTicks:0,_touchUnusedFactor:1,_PDFBug:null,_hasAnnotationEditors:!1,_title:document.title,_printAnnotationStoragePromise:null,_touchInfo:null,_isCtrlKeyDown:!1,_nimbusDataPromise:null,async initialize(e){this.preferences=this.externalServices.createPreferences();this.appConfig=e;await this._initializeOptions();this._forceCssTheme();await this._initializeL10n();this.isViewerEmbedded&&o.AppOptions.get("externalLinkTarget")===l.LinkTarget.NONE&&o.AppOptions.set("externalLinkTarget",l.LinkTarget.TOP);await this._initializeViewerComponents();this.bindEvents();this.bindWindowEvents();const t=e.appContainer||document.documentElement;this.l10n.translate(t).then((()=>{this.eventBus.dispatch("localized",{source:this})}));this._initializedCapability.resolve();this.initializeLoadingBar()},async _initializeOptions(){if(o.AppOptions.get("disablePreferences"))o.AppOptions.get("pdfBugEnabled")&&await this._parseHashParams();else{o.AppOptions._hasUserOptions()&&globalThis.ngxConsole.warn('_initializeOptions: The Preferences may override manually set AppOptions; please use the "disablePreferences"-option in order to prevent that.');try{o.AppOptions.setAll(await this.preferences.getAll())}catch(e){globalThis.ngxConsole.error(`_initializeOptions: "${e?.message}".`)}o.AppOptions.get("pdfBugEnabled")&&await this._parseHashParams()}},async _parseHashParams(){const e=document.location.hash.substring(1);if(!e)return;const{mainContainer:t,viewerContainer:i}=this.appConfig,r=(0,n.parseQueryString)(e);if("true"===r.get("disableworker"))try{await async function loadFakeWorker(){s.GlobalWorkerOptions.workerSrc||=o.AppOptions.get("workerSrc");"Function"===s.GlobalWorkerOptions.workerSrc.constructor.name&&(s.GlobalWorkerOptions.workerSrc=s.GlobalWorkerOptions.workerSrc());await(0,s.loadScript)(s.PDFWorker.workerSrc)}()}catch(e){console.error(`_parseHashParams: "${e.message}".`)}r.has("disablerange")&&o.AppOptions.set("disableRange","true"===r.get("disablerange"));r.has("disablestream")&&o.AppOptions.set("disableStream","true"===r.get("disablestream"));r.has("disableautofetch")&&o.AppOptions.set("disableAutoFetch","true"===r.get("disableautofetch"));r.has("disablefontface")&&o.AppOptions.set("disableFontFace","true"===r.get("disablefontface"));r.has("disablehistory")&&o.AppOptions.set("disableHistory","true"===r.get("disablehistory"));r.has("verbosity")&&o.AppOptions.set("verbosity",0|r.get("verbosity"));if(r.has("textlayer"))switch(r.get("textlayer")){case"off":o.AppOptions.set("textLayerMode",n.TextLayerMode.DISABLE);break;case"visible":case"shadow":case"hover":i.classList.add(`textLayer-${r.get("textlayer")}`);try{await loadPDFBug(this);this._PDFBug.loadCSS()}catch(e){console.error(`_parseHashParams: "${e.message}".`)}}if(r.has("pdfbug")){o.AppOptions.set("pdfBug",!0);o.AppOptions.set("fontExtraProperties",!0);const e=r.get("pdfbug").split(",");try{await loadPDFBug(this);this._PDFBug.init(t,e)}catch(e){console.error(`_parseHashParams: "${e.message}".`)}}r.has("locale")&&o.AppOptions.set("locale",r.get("locale"))},async _initializeL10n(){this.l10n=this.externalServices.createL10n({locale:o.AppOptions.get("locale")});const e=await this.l10n.getDirection();document.getElementsByTagName("html")[0].dir=e},_forceCssTheme(){const e=o.AppOptions.get("viewerCssTheme");if(e!==D.AUTOMATIC&&Object.values(D).includes(e))try{const t=document.styleSheets[0],i=t?.cssRules||[];for(let n=0,s=i.length;n<s;n++){const s=i[n];if(s instanceof CSSMediaRule&&"(prefers-color-scheme: dark)"===s.media?.[0]){if(e===D.LIGHT){t.deleteRule(n);return}const i=/^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(s.cssText);if(i?.[1]){t.deleteRule(n);t.insertRule(i[1],n)}return}}}catch(e){globalThis.ngxConsole.error(`_forceCssTheme: "${e?.message}".`)}},async _initializeViewerComponents(){const{appConfig:e,externalServices:t,l10n:i}=this,r=t.isInAutomation?new a.AutomationEventBus:new a.EventBus;this.eventBus=r;this.overlayManager=new d.OverlayManager;const L=new P.PDFRenderingQueue;L.onIdle=this._cleanup.bind(this);this.pdfRenderingQueue=L;const I=new l.PDFLinkService({eventBus:r,externalLinkTarget:o.AppOptions.get("externalLinkTarget"),externalLinkRel:o.AppOptions.get("externalLinkRel"),ignoreDestinationZoom:o.AppOptions.get("ignoreDestinationZoom")});this.pdfLinkService=I;const M=t.createDownloadManager();this.downloadManager=M;const A=new m.PDFFindController({linkService:I,eventBus:r,pageViewMode:o.AppOptions.get("pageViewMode"),updateMatchesCountOnProgress:!0});this.findController=A;const D=new _.PDFScriptingManager({eventBus:r,sandboxBundleSrc:o.AppOptions.get("sandboxBundleSrc"),externalServices:t,docProperties:this._scriptingDocProperties.bind(this)});this.pdfScriptingManager=D;const B=e.mainContainer,N=e.viewerContainer,O=o.AppOptions.get("annotationEditorMode"),R=o.AppOptions.get("isOffscreenCanvasSupported")&&s.FeatureTest.isOffscreenCanvasSupported,V=o.AppOptions.get("forcePageColors")||window.matchMedia("(forced-colors: active)").matches?{background:o.AppOptions.get("pageColorsBackground"),foreground:o.AppOptions.get("pageColorsForeground")}:null,k=new C.PDFViewer({container:B,viewer:N,eventBus:r,renderingQueue:L,linkService:I,downloadManager:M,findController:A,scriptingManager:o.AppOptions.get("enableScripting")&&D,l10n:i,textLayerMode:o.AppOptions.get("textLayerMode"),annotationMode:o.AppOptions.get("annotationMode"),annotationEditorMode:O,imageResourcesPath:o.AppOptions.get("imageResourcesPath"),removePageBorders:o.AppOptions.get("removePageBorders"),enablePrintAutoRotate:o.AppOptions.get("enablePrintAutoRotate"),isOffscreenCanvasSupported:R,maxCanvasPixels:o.AppOptions.get("maxCanvasPixels"),pageViewMode:o.AppOptions.get("pageViewMode"),enablePermissions:o.AppOptions.get("enablePermissions"),pageColors:V});this.pdfViewer=k;L.setViewer(k);I.setViewer(k);D.setViewer(k);if(e.sidebar?.thumbnailView){this.pdfThumbnailViewer=new E.PDFThumbnailViewer({container:e.sidebar.thumbnailView,eventBus:r,renderingQueue:L,linkService:I,l10n:i,pageColors:V});L.setThumbnailViewer(this.pdfThumbnailViewer)}if(!this.isViewerEmbedded&&!o.AppOptions.get("disableHistory")){this.pdfHistory=new w.PDFHistory({linkService:I,eventBus:r});I.setHistory(this.pdfHistory)}!this.supportsIntegratedFind&&e.findBar&&(this.findBar=new f.PDFFindBar(e.findBar,r,i));if(e.annotationEditorParams)if(O!==s.AnnotationEditorType.DISABLE){o.AppOptions.get("enableStampEditor")&&R&&e.toolbar?.editorStampButton?.classList.remove("hidden");this.annotationEditorParams=new h.AnnotationEditorParams(e.annotationEditorParams,r)}else for(const e of["editorModeButtons","editorModeSeparator"])document.getElementById(e)?.classList.add("hidden");e.documentProperties&&(this.pdfDocumentProperties=new g.PDFDocumentProperties(e.documentProperties,this.overlayManager,r,i,(()=>this._docFilename)));e.secondaryToolbar?.cursorHandToolButton&&(this.pdfCursorTools=new p.PDFCursorTools({container:B,eventBus:r,cursorToolOnLoad:o.AppOptions.get("cursorToolOnLoad")}));e.toolbar&&(this.toolbar=new x.Toolbar(e.toolbar,r,i));e.secondaryToolbar&&(this.secondaryToolbar=new T.SecondaryToolbar(e.secondaryToolbar,r,t));this.supportsFullscreen&&(e.toolbar?.presentationModeButton||e.secondaryToolbar?.presentationModeButton)&&(this.pdfPresentationMode=new y.PDFPresentationMode({container:B,pdfViewer:k,eventBus:r}));let F=o.AppOptions.get("passwordPrompt");F||e.passwordOverlay&&(F=new c.PasswordPrompt(e.passwordOverlay,this.overlayManager,i,this.isViewerEmbedded));this.passwordPrompt=F;e.sidebar?.outlineView&&(this.pdfOutlineViewer=new v.PDFOutlineViewer({container:e.sidebar.outlineView,eventBus:r,linkService:I,downloadManager:M}));e.sidebar?.attachmentsView&&(this.pdfAttachmentViewer=new u.PDFAttachmentViewer({container:e.sidebar.attachmentsView,eventBus:r,downloadManager:M}));e.sidebar?.layersView&&(this.pdfLayerViewer=new b.PDFLayerViewer({container:e.sidebar.layersView,eventBus:r,l10n:i}));if(e.sidebar){this.pdfSidebar=new S.PDFSidebar({elements:e.sidebar,eventBus:r,l10n:i});this.pdfSidebar.onToggled=this.forceRendering.bind(this);this.pdfSidebar.onUpdateThumbnails=()=>{for(const e of k.getCachedPageViews())e.renderingState===n.RenderingStates.FINISHED&&this.pdfThumbnailViewer.getThumbnail(e.id-1)?.setImage(e);this.pdfThumbnailViewer.scrollThumbnailIntoView(k.currentPageNumber)}}},async run(e){await this.initialize(e);const{appConfig:t,eventBus:i}=this;let s;const r=document.location.search.substring(1);s=(0,n.parseQueryString)(r).get("file")??o.AppOptions.get("defaultUrl");validateFileURL(s);const a=t.openFileInput;a.value=null;a.addEventListener("change",(function(e){const{files:t}=e.target;t&&0!==t.length&&i.dispatch("fileinputchange",{source:this,fileInput:e.target})}));t.mainContainer.addEventListener("dragover",(function(e){if(o.AppOptions.get("enableDragAndDrop")){e.preventDefault();e.dataTransfer.dropEffect="copy"===e.dataTransfer.effectAllowed?"copy":"move"}}));t.mainContainer.addEventListener("drop",(function(e){e.preventDefault();const{files:t}=e.dataTransfer;t&&0!==t.length&&i.dispatch("fileinputchange",{source:this,fileInput:e.dataTransfer,dropEvent:e})}));if(!this.supportsDocumentFonts){o.AppOptions.set("disableFontFace",!0);this.l10n.get("web_fonts_disabled").then((e=>{console.warn(e)}))}if(!this.supportsPrinting){t.toolbar?.print?.classList.add("hidden");t.secondaryToolbar?.printButton.classList.add("hidden")}if(!this.supportsFullscreen){t.toolbar.presentationModeButton.classList.add("hidden");t.secondaryToolbar?.presentationModeButton.classList.add("hidden")}this.supportsIntegratedFind&&t.toolbar?.viewFind?.classList.add("hidden");t.mainContainer.addEventListener("transitionend",(function(e){e.target===this&&i.dispatch("resize",{source:this})}),!0);try{s?this.open({url:s}):this._hideViewBookmark()}catch(e){l10n.get("loading_error").then((t=>{this._documentError(t,e);B.onError&&B.onError(e)}))}},get initialized(){return this._initializedCapability.settled},get initializedPromise(){return this._initializedCapability.promise},zoomIn(e,t){this.pdfViewer.isInPresentationMode||this.pdfViewer.increaseScale({drawingDelay:o.AppOptions.get("defaultZoomDelay"),steps:e,scaleFactor:t})},zoomOut(e,t){this.pdfViewer.isInPresentationMode||this.pdfViewer.decreaseScale({drawingDelay:o.AppOptions.get("defaultZoomDelay"),steps:e,scaleFactor:t})},zoomReset(){this.pdfViewer.isInPresentationMode||(this.pdfViewer.currentScaleValue=n.DEFAULT_SCALE_VALUE)},get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0},get page(){return this.pdfViewer.currentPageNumber},set page(e){this.pdfViewer.currentPageNumber=e},get supportsPrinting(){return O.instance.supportsPrinting},get supportsFullscreen(){return(0,s.shadow)(this,"supportsFullscreen",document.fullscreenEnabled)},get supportsPinchToZoom(){return this.externalServices.supportsPinchToZoom},get supportsIntegratedFind(){return this.externalServices.supportsIntegratedFind},get supportsDocumentFonts(){return this.externalServices.supportsDocumentFonts},initializeLoadingBar(){const e=document.getElementById("loadingBar"),t=e?new n.ProgressBar(e):null;t?.hide();return(0,s.shadow)(this,"loadingBar",t)},get supportedMouseWheelZoomModifierKeys(){return this.externalServices.supportedMouseWheelZoomModifierKeys},initPassiveLoading(e){throw new Error("Not implemented: initPassiveLoading")},setTitleUsingUrl(e="",t=null){},setTitle(e=this._title){this._title=e;if(this.isViewerEmbedded)return;const t=this._hasAnnotationEditors&&!this.pdfRenderingQueue.printing;document.title=`${t?"* ":""}${e}`},get _docFilename(){return this._contentDispositionFilename||(0,s.getPdfFilenameFromUrl)(this.url)},_hideViewBookmark(){if(!this.appConfig)return;const{secondaryToolbar:e}=this.appConfig;e?.viewBookmarkButton.classList.add("hidden");e?.presentationModeButton.classList.contains("hidden")&&document.getElementById("viewBookmarkSeparator")?.classList.add("hidden")},async close(){this._unblockDocumentLoadEvent();this._hideViewBookmark();if(!this.pdfLoadingTask)return;if(this.pdfDocument?.annotationStorage.size>0&&this._annotationStorageModified)try{await this.save()}catch{}const e=[];e.push(this.pdfLoadingTask.destroy());this.pdfLoadingTask=null;if(this.pdfDocument){this.pdfDocument=null;this.pdfThumbnailViewer?.setDocument(null);this.pdfViewer.setDocument(null);this.pdfLinkService.setDocument(null);this.pdfDocumentProperties?.setDocument(null)}this.pdfLinkService.externalLinkEnabled=!0;this.store=null;this.isInitialViewSet=!1;this.downloadComplete=!1;this.url="";this.baseUrl="";this._downloadUrl="";this.documentInfo=null;this.metadata=null;this._contentDispositionFilename=null;this._contentLength=null;this._saveInProgress=!1;this._hasAnnotationEditors=!1;e.push(this.pdfScriptingManager.destroyPromise,this.passwordPrompt.close());this.setTitle();this.pdfSidebar?.reset();this.pdfOutlineViewer?.reset();this.pdfAttachmentViewer?.reset();this.pdfLayerViewer?.reset();this.pdfHistory?.reset();this.findBar?.reset();this.toolbar?.reset();this.secondaryToolbar?.reset();this._PDFBug?.cleanup();await Promise.all(e)},async open(e){window.adjacentPagesLoader=void 0;this.pdfViewer?.destroyBookMode();window.ngxZone.runOutsideAngular((async()=>{let t=!1;if("string"==typeof e){e={url:e};t=!0}else if(e?.byteLength){e={data:e};t=!0}t&&console.error("The `PDFViewerApplication.open` signature was updated, please use an object instead.");this.pdfLoadingTask&&await this.close();const i=o.AppOptions.getAll(o.OptionKind.WORKER);Object.assign(s.GlobalWorkerOptions,i);e.url&&this.setTitleUsingUrl(e.originalUrl||e.url,e.url);const n=o.AppOptions.getAll(o.OptionKind.API),r={canvasMaxAreaInBytes:this.externalServices.canvasMaxAreaInBytes,...n,...e},a=(0,s.getDocument)(r);this.pdfLoadingTask=a;a.onPassword=(e,t)=>{this.isViewerEmbedded&&this._unblockDocumentLoadEvent();this.pdfLinkService.externalLinkEnabled=!1;this.passwordPrompt.setUpdateCallback(e,t);this.passwordPrompt.open()};a.onProgress=({loaded:e,total:t})=>{this.progress(e/t);this.eventBus?.dispatch("progress",{source:this,type:"load",total:t,loaded:e,percent:100*e/t})};return a.promise.then((e=>{this.load(e)}),(e=>{if(a!==this.pdfLoadingTask)return;let t="loading_error";e instanceof s.InvalidPDFException?t="invalid_file_error":e instanceof s.MissingPDFException?t="missing_file_error":e instanceof s.UnexpectedResponseException&&(t="unexpected_response_error");B.onError&&B.onError(e);return this.l10n.get(t).then((t=>{this._documentError(t,{message:e?.message});throw e}))}))}))},_ensureDownloadComplete(){if(!this.pdfDocument||!this.downloadComplete)throw new Error("PDF document not downloaded.")},async download(e={}){const t=this._downloadUrl,i=this._docFilename;try{this._ensureDownloadComplete();const n=await this.pdfDocument.getData(),s=new Blob([n],{type:"application/pdf"});await this.downloadManager.download(s,t,i,e)}catch{await this.downloadManager.downloadUrl(t,i,e)}},async save(e={}){if(this._saveInProgress)return;this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();const t=this._downloadUrl,i=this._docFilename;try{this._ensureDownloadComplete();const n=await this.pdfDocument.saveDocument(),s=new Blob([n],{type:"application/pdf"});await this.downloadManager.download(s,t,i,e)}catch(t){globalThis.ngxConsole.error(`Error when saving the document: ${t.message}`);await this.download(e)}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}this._hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"save"}})},downloadOrSave(e={}){this.pdfDocument?.annotationStorage.size>0?this.save(e):this.download(e)},async _exportWithAnnotations(){if(this._saveInProgress)throw new Error("Already downloading");this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();try{this._ensureDownloadComplete();const e=await this.pdfDocument.saveDocument();return new Blob([e],{type:"application/pdf"})}catch(e){throw new Error(`Error when saving the document: ${e.message}`)}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}},async _exportWithoutAnnotations(){try{this._ensureDownloadComplete();const e=await this.pdfDocument.getData();return new Blob([e],{type:"application/pdf"})}catch(e){throw new Error(`Error when saving the document: ${e.message}`)}},async export(){return this.pdfDocument?.annotationStorage.size>0?this._exportWithAnnotations():this._exportWithoutAnnotations()},openInExternalApp(){this.downloadOrSave({openInExternalApp:!0})},_documentError(e,t=null){this._unblockDocumentLoadEvent();this._otherError(e,t);this.eventBus.dispatch("documenterror",{source:this,message:e,reason:t?.message??null})},_otherError(e,t=null){const i=[`PDF.js v${s.version||"?"} (build: ${s.build||"?"})`];if(t){i.push(`Message: ${t.message}`);if(t.stack)i.push(`Stack: ${t.stack}`);else{t.filename&&i.push(`File: ${t.filename}`);t.lineNumber&&i.push(`Line: ${t.lineNumber}`)}}console.error(`${e}\n\n${i.join("\n")}`)},progress(e){if(!this.loadingBar||this.downloadComplete)return;const t=Math.round(100*e);if(!(t<=this.loadingBar.percent)){this.loadingBar.percent=t;(this.pdfDocument?.loadingParams.disableAutoFetch??o.AppOptions.get("disableAutoFetch"))&&this.loadingBar.setDisableAutoFetch()}},load(e){this.pdfDocument=e;e.getDownloadInfo().then((({length:e})=>{this._contentLength=e;this.downloadComplete=!0;this.loadingBar?.hide();a.then((()=>{this.eventBus?.dispatch("documentloaded",{source:this})}))}));const t=e.getPageLayout().catch((()=>{})),i=e.getPageMode().catch((()=>{})),s=e.getOpenAction().catch((()=>{}));this.toolbar?.setPagesCount(e.numPages,!1);this.secondaryToolbar?.setPagesCount(e.numPages);this.pdfLinkService.setDocument(e);this.pdfDocumentProperties?.setDocument(e);const r=this.pdfViewer;r.setDocument(e);const{firstPagePromise:a,onePageRendered:l,pagesPromise:h}=r;this.pdfThumbnailViewer?.setDocument(e);const d=(this.store=new L.ViewHistory(e.fingerprints[0])).getMultiple({page:null,zoom:n.DEFAULT_SCALE_VALUE,scrollLeft:"0",scrollTop:"0",rotation:null,sidebarView:n.SidebarView.UNKNOWN,scrollMode:n.ScrollMode.UNKNOWN,spreadMode:n.SpreadMode.UNKNOWN}).catch((()=>{}));a.then((a=>{this.loadingBar?.setWidth(this.appConfig.viewerContainer);this._initializeAnnotationStorageCallbacks(e);Promise.all([n.animationStarted,d,t,i,s]).then((async([t,i,s,a,l])=>{const d=o.AppOptions.get("viewOnLoad");this._initializePdfHistory({fingerprint:e.fingerprints[0],viewOnLoad:d,initialDest:l?.dest});const c=this.initialBookmark,u=o.AppOptions.get("defaultZoomValue");let p=u?`zoom=${u}`:null,g=null,f=o.AppOptions.get("sidebarViewOnLoad"),m=o.AppOptions.get("scrollModeOnLoad"),w=o.AppOptions.get("spreadModeOnLoad");if(i?.page&&d!==A){p=`page=${i.page}&zoom=${u||i.zoom},${i.scrollLeft},${i.scrollTop}`;g=parseInt(i.rotation,10);f===n.SidebarView.UNKNOWN&&(f=0|i.sidebarView);m===n.ScrollMode.UNKNOWN&&(m=0|i.scrollMode);w===n.SpreadMode.UNKNOWN&&(w=0|i.spreadMode)}a&&f===n.SidebarView.UNKNOWN&&(f=(0,n.apiPageModeToSidebarView)(a));if(s&&m===n.ScrollMode.UNKNOWN&&w===n.SpreadMode.UNKNOWN){w=(0,n.apiPageLayoutToViewerModes)(s).spreadMode}this.setInitialView(p,{rotation:g,sidebarView:f,scrollMode:m,spreadMode:w});this.eventBus.dispatch("documentinit",{source:this});this.isViewerEmbedded||r.focus();await Promise.race([h,new Promise((e=>{setTimeout(e,10)}))]);if((c||p)&&!r.hasEqualPageSizes){this.initialBookmark=c;r.currentScaleValue=r.currentScaleValue;this.setInitialView(p)}})).catch((()=>{this.setInitialView()})).then((function(){r.update()}))}));h.then((()=>{this._unblockDocumentLoadEvent();this._initializeAutoPrint(e,s)}),(e=>{B.onError&&B.onError(e);this.l10n.get("loading_error").then((t=>{this._documentError(t,{message:e?.message})}))}));l.then((t=>{this.externalServices.reportTelemetry({type:"pageInfo",timestamp:t.timestamp});this.pdfOutlineViewer&&e.getOutline().then((t=>{e===this.pdfDocument&&this.pdfOutlineViewer.render({outline:t,pdfDocument:e})}));this.pdfAttachmentViewer&&e.getAttachments().then((t=>{e===this.pdfDocument&&this.pdfAttachmentViewer.render({attachments:t})}));this.pdfLayerViewer&&r.optionalContentConfigPromise.then((t=>{e===this.pdfDocument&&this.pdfLayerViewer.render({optionalContentConfig:t,pdfDocument:e})}))}));this._initializePageLabels(e);this._initializeMetadata(e)},async _scriptingDocProperties(e){if(!this.documentInfo){await new Promise((e=>{this.eventBus._on("metadataloaded",e,{once:!0})}));if(e!==this.pdfDocument)return null}if(!this._contentLength){await new Promise((e=>{this.eventBus._on("documentloaded",e,{once:!0})}));if(e!==this.pdfDocument)return null}return{...this.documentInfo,baseURL:this.baseUrl,filesize:this._contentLength,filename:this._docFilename,metadata:this.metadata?.getRaw(),authors:this.metadata?.get("dc:creator"),numPages:this.pagesCount,URL:this.url}},async _initializeAutoPrint(e,t){const[i,s]=await Promise.all([t,this.pdfViewer.enableScripting?null:e.getJSActions()]);if(e!==this.pdfDocument)return;let r="Print"===i?.action;if(s){globalThis.ngxConsole.warn("Warning: JavaScript support is not enabled");for(const e in s){if(r)break;switch(e){case"WillClose":case"WillSave":case"DidSave":case"WillPrint":case"DidPrint":continue}r=s[e].some((e=>n.AutoPrintRegExp.test(e)))}}r&&this.triggerPrinting()},async _initializeMetadata(e){const{info:t,metadata:i,contentDispositionFilename:n,contentLength:o}=await e.getMetadata();if(e!==this.pdfDocument)return;this.documentInfo=t;this.metadata=i;this._contentDispositionFilename??=n;this._contentLength??=o;const a=window.PDFViewerApplicationOptions;(!a||a.get("verbosity")>0)&&globalThis.ngxConsole.log(`PDF ${e.fingerprints[0]} [${t.PDFFormatVersion} ${(t.Producer||"-").trim()} / ${(t.Creator||"-").trim()}] (PDF.js: ${s.version||"?"} [${s.build||"?"}]) modified by ngx-extended-pdf-viewer ${r.ngxExtendedPdfViewerVersion}`);let l=t.Title;const h=i?.get("dc:title");h&&("Untitled"===h||/[\uFFF0-\uFFFF]/g.test(h)||(l=h));l?this.setTitle(`${l} - ${this._contentDispositionFilename||this._title}`):this._contentDispositionFilename&&this.setTitle(this._contentDispositionFilename);!t.IsXFAPresent||t.IsAcroFormPresent||e.isPureXfa?!t.IsAcroFormPresent&&!t.IsXFAPresent||this.pdfViewer.renderForms||console.warn("Warning: Interactive form support is not enabled"):e.loadingParams.enableXfa?globalThis.ngxConsole.warn("Warning: XFA Foreground documents are not supported"):globalThis.ngxConsole.warn("Warning: XFA support is not enabled");t.IsSignaturesPresent&&console.warn("Warning: Digital signatures validation is not supported");this.eventBus.dispatch("metadataloaded",{source:this})},async _initializePageLabels(e){const t=await e.getPageLabels();if(e!==this.pdfDocument)return;if(!t||o.AppOptions.get("disablePageLabels"))return;const i=t.length;let n=0,s=0;for(let e=0;e<i;e++){const i=t[e];if(i===(e+1).toString())n++;else{if(""!==i)break;s++}}if(n>=i||s>=i)return;const{pdfViewer:r,pdfThumbnailViewer:a,toolbar:l}=this;r.setPageLabels(t);a?.setPageLabels(t);l?.setPagesCount(i,!0);l?.setPageNumber(r.currentPageNumber,r.currentPageLabel)},_initializePdfHistory({fingerprint:e,viewOnLoad:t,initialDest:i=null}){if(this.pdfHistory){this.pdfHistory.initialize({fingerprint:e,resetHistory:t===A,updateUrl:o.AppOptions.get("historyUpdateUrl")});if(this.pdfHistory.initialBookmark){this.initialBookmark=this.pdfHistory.initialBookmark;this.initialRotation=this.pdfHistory.initialRotation}if(i&&!this.initialBookmark&&t===M){this.initialBookmark=JSON.stringify(i);this.pdfHistory.push({explicitDest:i,pageNumber:null})}}},_initializeAnnotationStorageCallbacks(e){if(e!==this.pdfDocument)return;const{annotationStorage:t}=e;t.onSetModified=()=>{window.addEventListener("beforeunload",beforeUnload);this._annotationStorageModified=!0};t.onResetModified=()=>{window.removeEventListener("beforeunload",beforeUnload);delete this._annotationStorageModified};t.onAnnotationEditor=e=>{this._hasAnnotationEditors=!!e;this.setTitle();e&&this.externalServices.reportTelemetry({type:"editing",data:{type:e}})}},setInitialView(e,{rotation:t,sidebarView:i,scrollMode:s,spreadMode:r}={}){const setRotation=e=>{(0,n.isValidRotation)(e)&&(this.pdfViewer.pagesRotation=e)};this.isInitialViewSet=!0;this.pdfSidebar?.setInitialView(i);((e,t)=>{(0,n.isValidScrollMode)(e)&&(this.pdfViewer.scrollMode=e);(0,n.isValidSpreadMode)(t)&&(this.pdfViewer.spreadMode=t)})(s,r);if(this.initialBookmark){setRotation(this.initialRotation);delete this.initialRotation;this.pdfLinkService.setHash(this.initialBookmark);this.initialBookmark=null}else if(e){setRotation(t);this.pdfLinkService.setHash(e)}this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber,this.pdfViewer.currentPageLabel);this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);if(!this.pdfViewer.currentScaleValue){const e=PDFViewerApplicationOptions.get("defaultZoomValue");e&&(this.pdfViewer.currentScaleValue=e)}},_cleanup(){if(this.pdfDocument){this.pdfViewer.cleanup();this.pdfThumbnailViewer?.cleanup();this.pdfDocument.cleanup()}},forceRendering(){this.pdfRenderingQueue.printing=!!this.printService;this.pdfRenderingQueue.isThumbnailViewEnabled=this.pdfSidebar?.visibleView===n.SidebarView.THUMBS;this.pdfRenderingQueue.renderHighestPriority()},beforePrint(){this._printAnnotationStoragePromise=this.pdfScriptingManager.dispatchWillPrint().catch((()=>{})).then((()=>this.pdfDocument?.annotationStorage.print));if(this.printService)return;if(!this.supportsPrinting){this.l10n.get("printing_not_supported").then((e=>{this._otherError(e)}));return}if(!this.pdfViewer.pageViewsReady){this.l10n.get("printing_not_ready").then((e=>{window.alert(e)}));return}const e=this.pdfViewer.getPagesOverview(),t=this.appConfig.printContainer,i=o.AppOptions.get("printResolution"),n=this.pdfViewer.optionalContentConfigPromise,s=O.instance.createPrintService(this.pdfDocument,e,t,i,n,this._printAnnotationStoragePromise,this.l10n,this.pdfViewer.eventBus);this.printService=s;this.forceRendering();this.setTitle();s.layout();this._hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"print"}})},afterPrint(){if(this._printAnnotationStoragePromise){this._printAnnotationStoragePromise.then((()=>{this.pdfScriptingManager.dispatchDidPrint()}));this._printAnnotationStoragePromise=null}if(this.printService){this.printService.destroy();this.printService=null;this.pdfDocument?.annotationStorage.resetModified()}this.forceRendering();this.setTitle()},rotatePages(e){this.pdfViewer.pagesRotation+=e},requestPresentationMode(){this.pdfPresentationMode?.request()},triggerPrinting(){this.supportsPrinting&&window.printPDF()},bindEvents(){const{eventBus:e,_boundEvents:t}=this;t.beforePrint=this.beforePrint.bind(this);t.afterPrint=this.afterPrint.bind(this);e._on("resize",webViewerResize);e._on("hashchange",webViewerHashchange);e._on("beforeprint",t.beforePrint);e._on("afterprint",t.afterPrint);e._on("pagerender",webViewerPageRender);e._on("pagerendered",webViewerPageRendered);e._on("updateviewarea",webViewerUpdateViewarea);e._on("pagechanging",webViewerPageChanging);e._on("scalechanging",webViewerScaleChanging);e._on("rotationchanging",webViewerRotationChanging);e._on("sidebarviewchanged",webViewerSidebarViewChanged);e._on("pagemode",webViewerPageMode);e._on("namedaction",webViewerNamedAction);e._on("presentationmodechanged",webViewerPresentationModeChanged);e._on("presentationmode",webViewerPresentationMode);e._on("switchannotationeditormode",webViewerSwitchAnnotationEditorMode);e._on("switchannotationeditorparams",webViewerSwitchAnnotationEditorParams);e._on("print",webViewerPrint);e._on("download",webViewerDownload);e._on("openinexternalapp",webViewerOpenInExternalApp);e._on("firstpage",webViewerFirstPage);e._on("lastpage",webViewerLastPage);e._on("nextpage",webViewerNextPage);e._on("previouspage",webViewerPreviousPage);e._on("zoomin",webViewerZoomIn);e._on("zoomout",webViewerZoomOut);e._on("zoomreset",webViewerZoomReset);e._on("pagenumberchanged",webViewerPageNumberChanged);e._on("scalechanged",webViewerScaleChanged);e._on("rotatecw",webViewerRotateCw);e._on("rotateccw",webViewerRotateCcw);e._on("optionalcontentconfig",webViewerOptionalContentConfig);e._on("switchscrollmode",webViewerSwitchScrollMode);e._on("scrollmodechanged",webViewerScrollModeChanged);e._on("switchspreadmode",webViewerSwitchSpreadMode);e._on("spreadmodechanged",webViewerSpreadModeChanged);e._on("documentproperties",webViewerDocumentProperties);e._on("findfromurlhash",webViewerFindFromUrlHash);e._on("updatefindmatchescount",webViewerUpdateFindMatchesCount);e._on("updatefindcontrolstate",webViewerUpdateFindControlState);if(o.AppOptions.get("pdfBug")){t.reportPageStatsPDFBug=reportPageStatsPDFBug;e._on("pagerendered",t.reportPageStatsPDFBug);e._on("pagechanging",t.reportPageStatsPDFBug)}e._on("fileinputchange",webViewerFileInputChange);e._on("openfile",webViewerOpenFile)},bindWindowEvents(){const{eventBus:e,_boundEvents:t}=this;!function addWindowResolutionChange(e=null){e&&function webViewerResolutionChange(e){B.pdfViewer.refresh()}();const i=window.matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`);i.addEventListener("change",addWindowResolutionChange,{once:!0});t.removeWindowResolutionChange||=function(){i.removeEventListener("change",addWindowResolutionChange);t.removeWindowResolutionChange=null}}();t.windowResize=()=>{e.dispatch("resize",{source:window})};t.windowHashChange=()=>{e.dispatch("hashchange",{source:window,hash:document.location.hash.substring(1)})};t.windowBeforePrint=()=>{e.dispatch("beforeprint",{source:window})};t.windowAfterPrint=()=>{e.dispatch("afterprint",{source:window})};t.windowUpdateFromSandbox=t=>{e.dispatch("updatefromsandbox",{source:window,detail:t.detail})};window.addEventListener("visibilitychange",webViewerVisibilityChange);const i=document.getElementById("viewerContainer");i?.addEventListener("wheel",webViewerWheel,{passive:!1});const n=document.getElementById("mainContainer");n?.addEventListener("touchstart",webViewerTouchStart,{passive:!1});n?.addEventListener("touchmove",webViewerTouchMove,{passive:!1});n?.addEventListener("touchend",webViewerTouchEnd,{passive:!1});window.addEventListener("click",webViewerClick);window.addEventListener("keydown",webViewerKeyDown);window.addEventListener("keyup",webViewerKeyUp);window.addEventListener("resize",t.windowResize);window.addEventListener("hashchange",t.windowHashChange);window.addEventListener("beforeprint",t.windowBeforePrint);window.addEventListener("afterprint",t.windowAfterPrint);window.addEventListener("updatefromsandbox",t.windowUpdateFromSandbox)},unbindEvents(){const{eventBus:e,_boundEvents:t}=this;e._off("resize",webViewerResize);e._off("hashchange",webViewerHashchange);e._off("beforeprint",t.beforePrint);e._off("afterprint",t.afterPrint);e._off("pagerender",webViewerPageRender);e._off("pagerendered",webViewerPageRendered);e._off("updateviewarea",webViewerUpdateViewarea);e._off("pagechanging",webViewerPageChanging);e._off("scalechanging",webViewerScaleChanging);e._off("rotationchanging",webViewerRotationChanging);e._off("sidebarviewchanged",webViewerSidebarViewChanged);e._off("pagemode",webViewerPageMode);e._off("namedaction",webViewerNamedAction);e._off("presentationmodechanged",webViewerPresentationModeChanged);e._off("presentationmode",webViewerPresentationMode);e._off("print",webViewerPrint);e._off("download",webViewerDownload);e._off("openinexternalapp",webViewerOpenInExternalApp);e._off("firstpage",webViewerFirstPage);e._off("lastpage",webViewerLastPage);e._off("nextpage",webViewerNextPage);e._off("previouspage",webViewerPreviousPage);e._off("zoomin",webViewerZoomIn);e._off("zoomout",webViewerZoomOut);e._off("zoomreset",webViewerZoomReset);e._off("pagenumberchanged",webViewerPageNumberChanged);e._off("scalechanged",webViewerScaleChanged);e._off("rotatecw",webViewerRotateCw);e._off("rotateccw",webViewerRotateCcw);e._off("optionalcontentconfig",webViewerOptionalContentConfig);e._off("switchscrollmode",webViewerSwitchScrollMode);e._off("scrollmodechanged",webViewerScrollModeChanged);e._off("switchspreadmode",webViewerSwitchSpreadMode);e._off("spreadmodechanged",webViewerSpreadModeChanged);e._off("documentproperties",webViewerDocumentProperties);e._off("findfromurlhash",webViewerFindFromUrlHash);e._off("updatefindmatchescount",webViewerUpdateFindMatchesCount);e._off("updatefindcontrolstate",webViewerUpdateFindControlState);if(t.reportPageStatsPDFBug){e._off("pagerendered",t.reportPageStatsPDFBug);e._off("pagechanging",t.reportPageStatsPDFBug);t.reportPageStatsPDFBug=null}e._off("fileinputchange",webViewerFileInputChange);e._off("openfile",webViewerOpenFile);t.beforePrint=null;t.afterPrint=null},unbindWindowEvents(){const{_boundEvents:e}=this;window.removeEventListener("visibilitychange",webViewerVisibilityChange);window.removeEventListener("wheel",webViewerWheel,{passive:!1});const t=document.getElementById("mainContainer");if(t){t.removeEventListener("touchstart",webViewerTouchStart,{passive:!1});t.removeEventListener("touchmove",webViewerTouchMove,{passive:!1});t.removeEventListener("touchend",webViewerTouchEnd,{passive:!1})}window.removeEventListener("click",webViewerClick);window.removeEventListener("keydown",webViewerKeyDown);window.removeEventListener("keyup",webViewerKeyUp);window.removeEventListener("resize",e.windowResize);window.removeEventListener("hashchange",e.windowHashChange);window.removeEventListener("beforeprint",e.windowBeforePrint);window.removeEventListener("afterprint",e.windowAfterPrint);window.removeEventListener("updatefromsandbox",e.windowUpdateFromSandbox);e.removeWindowResolutionChange?.();e.windowResize=null;e.windowHashChange=null;e.windowBeforePrint=null;e.windowAfterPrint=null;e.windowUpdateFromSandbox=null},_accumulateTicks(e,t){(this[t]>0&&e<0||this[t]<0&&e>0)&&(this[t]=0);this[t]+=e;const i=Math.trunc(this[t]);this[t]-=i;return i},_accumulateFactor(e,t,i){if(1===t)return 1;(this[i]>1&&t<1||this[i]<1&&t>1)&&(this[i]=1);const n=Math.floor(e*t*this[i]*100)/(100*e);this[i]=t/n;return n},_centerAtPos(e,t,i){const{pdfViewer:n}=this,s=n.currentScale/e-1;if(0!==s){const[e,r]=n.containerTopLeft;n.container.scrollLeft+=(t-r)*s;n.container.scrollTop+=(i-e)*s}},_unblockDocumentLoadEvent(){document.blockUnblockOnload?.(!1);this._unblockDocumentLoadEvent=()=>{}},get scriptingReady(){return this.pdfScriptingManager.ready}};{const e=["null","http://mozilla.github.io","https://mozilla.github.io"];var validateFileURL=function(t){if(t)try{const i=new URL(window.location.href).origin||"null";if(e.includes(i))return;if(new URL(t,window.location.href).origin!==i)throw new Error("file origin does not match viewer's")}catch(e){B.onError&&B.onError(e);B.l10n.get("loading_error").then((t=>{B._documentError(t,{message:e?.message})}));throw e}}}async function loadPDFBug(e){}function reportPageStatsPDFBug({pageNumber:e}){if(!globalThis.Stats?.enabled)return;const t=B.pdfViewer.getPageView(e-1);globalThis.Stats.add(e,t?.pdfPage?.stats)}function webViewerPageRender({pageNumber:e}){e===B.page&&B.toolbar?.updateLoadingIndicatorState(!0)}function webViewerPageRendered({pageNumber:e,error:t}){e===B.page&&B.toolbar?.updateLoadingIndicatorState(!1);if(B.pdfSidebar?.visibleView===n.SidebarView.THUMBS){const t=B.pdfViewer.getPageView(e-1),i=B.pdfThumbnailViewer?.getThumbnail(e-1);t&&i?.setImage(t)}t&&B.l10n.get("rendering_error").then((e=>{B._otherError(e,t)}))}function webViewerPageMode({mode:e}){let t;switch(e){case"thumbs":t=n.SidebarView.THUMBS;break;case"bookmarks":case"outline":t=n.SidebarView.OUTLINE;break;case"attachments":t=n.SidebarView.ATTACHMENTS;break;case"layers":t=n.SidebarView.LAYERS;break;case"none":t=n.SidebarView.NONE;break;default:globalThis.ngxConsole.error('Invalid "pagemode" hash parameter: '+e);return}B.pdfSidebar?.switchView(t,!0)}function webViewerNamedAction(e){switch(e.action){case"GoToPage":B.appConfig.toolbar?.pageNumber.select();break;case"Find":B.supportsIntegratedFind||B?.findBar.toggle();break;case"Print":B.triggerPrinting();break;case"SaveAs":B.downloadOrSave()}}function webViewerPresentationModeChanged(e){B.pdfViewer.presentationModeState=e.state}function webViewerSidebarViewChanged({view:e}){B.pdfRenderingQueue.isThumbnailViewEnabled=e===n.SidebarView.THUMBS;B.isInitialViewSet&&B.store?.set("sidebarView",e).catch((()=>{}))}function webViewerUpdateViewarea({location:e}){if(B.isInitialViewSet){const t={};void 0===e.pageNumber&&null===e.pageNumber||(t.page=e.pageNumber);e.scale&&(t.zoom=e.scale);e.left&&(t.scrollLeft=e.left);e.top&&(t.scrollTop=e.top);void 0===e.rotation&&null===e.rotation||(t.rotation=e.rotation);B.store?.setMultiple(t).catch((()=>{}))}if(B.appConfig.secondaryToolbar){const t=B.pdfLinkService.getAnchorUrl(e.pdfOpenParams);B.appConfig.secondaryToolbar.viewBookmarkButton.href=t}}function webViewerScrollModeChanged(e){B.isInitialViewSet&&!B.pdfViewer.isInPresentationMode&&B.store?.set("scrollMode",e.mode).catch((()=>{}))}function webViewerSpreadModeChanged(e){B.isInitialViewSet&&!B.pdfViewer.isInPresentationMode&&B.store?.set("spreadMode",e.mode).catch((()=>{}))}function webViewerResize(){const{pdfDocument:e,pdfViewer:t,pdfRenderingQueue:i}=B;if(i.printing&&window.matchMedia("print").matches)return;if(!e)return;const n=t.currentScaleValue;"auto"!==n&&"page-fit"!==n&&"page-width"!==n||(t.currentScaleValue=n);t.update()}function webViewerHashchange(e){const t=e.hash;t&&(B.isInitialViewSet?B.pdfHistory?.popStateInProgress||B.pdfLinkService.setHash(t):B.initialBookmark=t)}var webViewerFileInputChange=function(e){if(B.pdfViewer?.isInPresentationMode)return;const t=e.fileInput.files[0];B.open({url:URL.createObjectURL(t),originalUrl:t.name});globalThis.setNgxExtendedPdfViewerSource&&globalThis.setNgxExtendedPdfViewerSource(t.name??URL.createObjectURL(t))},webViewerOpenFile=function(e){B.appConfig.openFileInput.click()};function webViewerPresentationMode(){B.requestPresentationMode()}function webViewerSwitchAnnotationEditorMode(e){B.pdfViewer.annotationEditorMode=e}function webViewerSwitchAnnotationEditorParams(e){B.pdfViewer.annotationEditorParams=e}function webViewerPrint(){B.triggerPrinting()}function webViewerDownload(){B.downloadOrSave()}function webViewerOpenInExternalApp(){B.openInExternalApp()}function webViewerFirstPage(){B.page=1}function webViewerLastPage(){B.page=B.pagesCount}function webViewerNextPage(){B.pdfViewer.nextPage()}function webViewerPreviousPage(){B.pdfViewer.previousPage()}function webViewerZoomIn(){B.zoomIn()}function webViewerZoomOut(){B.zoomOut()}function webViewerZoomReset(){B.zoomReset()}function webViewerPageNumberChanged(e){const t=B.pdfViewer;""!==e.value&&B.pdfLinkService.goToPage(e.value);e.value!==t.currentPageNumber.toString()&&e.value!==t.currentPageLabel&&B.toolbar?.setPageNumber(t.currentPageNumber,t.currentPageLabel)}function webViewerScaleChanged(e){B.pdfViewer.currentScaleValue=e.value}function webViewerRotateCw(){B.rotatePages(90)}function webViewerRotateCcw(){B.rotatePages(-90)}function webViewerOptionalContentConfig(e){B.pdfViewer.optionalContentConfigPromise=e.promise}function webViewerSwitchScrollMode(e){B.pdfViewer.scrollMode=e.mode}function webViewerSwitchSpreadMode(e){B.pdfViewer.spreadMode=e.mode}function webViewerDocumentProperties(){B.pdfDocumentProperties?.open()}function webViewerFindFromUrlHash(e){B.eventBus.dispatch("find",{source:e.source,type:"",query:e.query,caseSensitive:!1,entireWord:!1,highlightAll:!0,findPrevious:!1,matchDiacritics:!0})}function webViewerUpdateFindMatchesCount({matchesCount:e}){B.supportsIntegratedFind?B.externalServices.updateFindMatchesCount(e):B.findBar.updateResultsCount(e)}function webViewerUpdateFindControlState({state:e,previous:t,matchesCount:i,rawQuery:n}){B.supportsIntegratedFind?B.externalServices.updateFindControlState({result:e,findPrevious:t,matchesCount:i,rawQuery:n}):B.findBar?.updateUIState(e,t,i)}function webViewerScaleChanging(e){B.toolbar?.setPageScale(e.presetValue,e.scale);B.pdfViewer.update()}function webViewerRotationChanging(e){B.pdfThumbnailViewer&&(B.pdfThumbnailViewer.pagesRotation=e.pagesRotation);B.forceRendering();B.pdfViewer.currentPageNumber=e.pageNumber}function webViewerPageChanging({pageNumber:e,pageLabel:t}){B.toolbar?.setPageNumber(e,t);B.secondaryToolbar?.setPageNumber(e);B.pdfSidebar?.visibleView===n.SidebarView.THUMBS&&B.pdfThumbnailViewer?.scrollThumbnailIntoView(e);const i=B.pdfViewer.getPageView(e-1);B.toolbar?.updateLoadingIndicatorState(i?.renderingState===n.RenderingStates.RUNNING);const s=document.getElementById("pageNumber");if(s){const e=new CustomEvent("page-change");s.dispatchEvent(e)}}function webViewerVisibilityChange(e){"visible"===document.visibilityState&&setZoomDisabledTimeout()}let N=null;function setZoomDisabledTimeout(){N&&clearTimeout(N);N=setTimeout((function(){N=null}),I)}function webViewerWheel(e){const t=document.getElementById("viewerContainer");if(t.parentNode.querySelector(":hover")!==t)return;const{pdfViewer:i,supportedMouseWheelZoomModifierKeys:s,supportsPinchToZoom:r}=B;if(i.isInPresentationMode)return;const o=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(window.isKeyIgnored&&window.isKeyIgnored(o,"WHEEL"))return;const a=e.deltaMode;let l=Math.exp(-e.deltaY/100);const h=e.ctrlKey&&!B._isCtrlKeyDown&&a===WheelEvent.DOM_DELTA_PIXEL&&0===e.deltaX&&(Math.abs(l-1)<.05||!1)&&0===e.deltaZ;if(h||e.ctrlKey&&s.ctrlKey||e.metaKey&&s.metaKey){e.preventDefault();if(N||"hidden"===document.visibilityState)return;const t=i.currentScale;if(h&&r){l=B._accumulateFactor(t,l,"_wheelUnusedFactor");if(l<1)B.zoomOut(null,l);else{if(!(l>1))return;B.zoomIn(null,l)}}else{const t=(0,n.normalizeWheelEventDirection)(e);let i=0;if(a===WheelEvent.DOM_DELTA_LINE||a===WheelEvent.DOM_DELTA_PAGE)i=Math.abs(t)>=1?Math.sign(t):B._accumulateTicks(t,"_wheelUnusedTicks");else{const e=30;i=B._accumulateTicks(t/e,"_wheelUnusedTicks")}if(i<0)B.zoomOut(-i);else{if(!(i>0))return;B.zoomIn(i)}}B._centerAtPos(t,e.clientX,e.clientY)}else setZoomDisabledTimeout()}function webViewerTouchStart(e){if(B.pdfViewer.isInPresentationMode||e.touches.length<2)return;e.preventDefault();if(2!==e.touches.length){B._touchInfo=null;return}let[t,i]=e.touches;t.identifier>i.identifier&&([t,i]=[i,t]);B._touchInfo={touch0X:t.pageX,touch0Y:t.pageY,touch1X:i.pageX,touch1Y:i.pageY}}function webViewerTouchMove(e){if(!B._touchInfo||2!==e.touches.length)return;const{pdfViewer:t,_touchInfo:i,supportsPinchToZoom:n}=B;let[s,r]=e.touches;s.identifier>r.identifier&&([s,r]=[r,s]);const{pageX:o,pageY:a}=s,{pageX:l,pageY:h}=r,{touch0X:d,touch0Y:c,touch1X:u,touch1Y:p}=i;if(Math.abs(d-o)<=1&&Math.abs(c-a)<=1&&Math.abs(u-l)<=1&&Math.abs(p-h)<=1)return;i.touch0X=o;i.touch0Y=a;i.touch1X=l;i.touch1Y=h;if(d===o&&c===a){const e=u-o,t=p-a,i=l-o,n=h-a,s=e*n-t*i;if(Math.abs(s)>.02*Math.hypot(e,t)*Math.hypot(i,n))return}else if(u===l&&p===h){const e=d-l,t=c-h,i=o-l,n=a-h,s=e*n-t*i;if(Math.abs(s)>.02*Math.hypot(e,t)*Math.hypot(i,n))return}else{if((o-d)*(l-u)+(a-c)*(h-p)>=0)return}e.preventDefault();const g=Math.hypot(o-l,a-h)||1,f=Math.hypot(d-u,c-p)||1,m=t.currentScale;if(n){const e=B._accumulateFactor(m,g/f,"_touchUnusedFactor");if(e<1)B.zoomOut(null,e);else{if(!(e>1))return;B.zoomIn(null,e)}}else{const e=30,t=B._accumulateTicks((g-f)/e,"_touchUnusedTicks");if(t<0)B.zoomOut(-t);else{if(!(t>0))return;B.zoomIn(t)}}B._centerAtPos(m,(o+l)/2,(a+h)/2)}function webViewerTouchEnd(e){if(B._touchInfo){e.preventDefault();B._touchInfo=null;B._touchUnusedTicks=0;B._touchUnusedFactor=1}}function webViewerClick(e){if(!B.secondaryToolbar?.isOpen)return;const t=B.appConfig;if(B.pdfViewer.containsElement(e.target)||t.toolbar?.container.contains(e.target)&&e.target!==t.secondaryToolbar?.toggleButton){if(e.target&&e.target.parentElement===t.secondaryToolbar.toggleButton)return;if(e.target&&e.target.parentElement&&e.target.parentElement.parentElement===t.secondaryToolbar.toggleButton)return;B.secondaryToolbar.close()}}function webViewerKeyUp(e){"Control"===e.key&&(B._isCtrlKeyDown=!1)}function webViewerKeyDown(e){B._isCtrlKeyDown="Control"===e.key;if(B.overlayManager.active)return;const{eventBus:t,pdfViewer:i}=B,s=i.isInPresentationMode;let r=!1,o=!1;const a=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(window.isKeyIgnored&&window.isKeyIgnored(a,e.keyCode))return;if(1===a||8===a||5===a||12===a)switch(e.keyCode){case 70:if(!B.supportsIntegratedFind&&!e.shiftKey){B.findBar?.open();r=!0}break;case 71:if(!B.supportsIntegratedFind){const{state:e}=B.findController;if(e){const i={source:window,type:"again",findPrevious:5===a||12===a};t.dispatch("find",{...e,...i})}r=!0}break;case 61:case 107:case 187:case 171:B.zoomIn();r=!0;break;case 173:case 109:case 189:B.zoomOut();r=!0;break;case 48:case 96:if(!s){setTimeout((function(){B.zoomReset()}));r=!1}break;case 38:if(s||B.page>1){B.page=1;r=!0;o=!0}break;case 40:if(s||B.page<B.pagesCount){B.page=B.pagesCount;r=!0;o=!0}}if(1===a||8===a)switch(e.keyCode){case 83:t.dispatch("download",{source:window});r=!0;break;case 79:t.dispatch("openfile",{source:window});r=!0}if(3===a||10===a)switch(e.keyCode){case 80:B.requestPresentationMode();r=!0;B.externalServices.reportTelemetry({type:"buttons",data:{id:"presentationModeKeyboard"}});break;case 71:if(B.appConfig.toolbar){B.appConfig.toolbar.pageNumber.select();r=!0}}if(r){o&&!s&&i.focus();e.preventDefault();return}const l=(0,n.getActiveOrFocusedElement)(),h=l?.tagName.toUpperCase();if("INPUT"!==h&&"TEXTAREA"!==h&&"SELECT"!==h&&!l?.isContentEditable||27===e.keyCode){if(0===a){let t=0,a=!1;switch(e.keyCode){case 38:case 33:i.isVerticalScrollbarEnabled&&(a=!0);t=-1;break;case 8:s||(a=!0);t=-1;break;case 37:i.isHo