/**
 * @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
 */var e={d:(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{PDFViewerApplication:()=>us,PDFViewerApplicationConstants:()=>dr,PDFViewerApplicationOptions:()=>Q});const i="auto",n={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},s=0,r=1,a=2,o=3,l=-1,d=0,h=1,c=2,u=3,p=4,g=0,f=1,m=2,b={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},v={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2},w=0,y=1,P=/\bprint\s*\(/;class _{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}}function C(e,t,i=!1){let n=e.offsetParent;if(!n)return void console.error("offsetParent is not set -- cannot scroll");let s=e.offsetTop+e.clientTop,r=e.offsetLeft+e.clientLeft;for(;n.clientHeight===n.scrollHeight&&n.clientWidth===n.scrollWidth||i&&(n.classList.contains("markedContent")||"hidden"===getComputedStyle(n).overflow);)if(s+=n.offsetTop,r+=n.offsetLeft,n=n.offsetParent,!n)return;t&&(void 0!==t.top&&(s+=t.top),void 0!==t.left&&(r+=t.left,n.scrollLeft=r)),n.scrollTop=s}function S(e,t,i=void 0){const n=function(i){r||(r=window.requestAnimationFrame(function(){r=null;const i=e.scrollLeft,n=s.lastX;i!==n&&(s.right=i>n),s.lastX=i;const a=e.scrollTop,o=s.lastY;a!==o&&(s.down=a>o),s.lastY=a,t(s)}))},s={right:!0,down:!0,lastX:e.scrollLeft,lastY:e.scrollTop,_eventHandler:n};let r=null;return e.addEventListener("scroll",n,{useCapture:!0,signal:i}),i?.addEventListener("abort",()=>window.cancelAnimationFrame(r),{once:!0}),s}function E(e){const t=new Map;for(const[i,n]of new URLSearchParams(e))t.set(i.toLowerCase(),n);return t}const L=/[\x00-\x1F]/g;function I(e,t=!1){return L.test(e)?t?e.replaceAll(L,e=>"\0"===e?"":" "):e.replaceAll("\0",""):e}function x(e,t,i=0){let n=i,s=e.length-1;if(s<0||!t(e[s]))return e.length;if(t(e[n]))return n;for(;n<s;){const i=n+s>>1;t(e[i])?s=i:n=i+1}return n}function M(e){if(Math.floor(e)===e)return[e,1];const t=1/e;if(t>8)return[1,8];if(Math.floor(t)===t)return[1,t];const i=e>1?t:e;let n,s=0,r=1,a=1,o=1;for(;;){const e=s+a,t=r+o;if(t>8)break;i<=e/t?(a=e,o=t):(s=e,r=t)}return n=i-s/r<a/o-i?i===e?[s,r]:[r,s]:i===e?[a,o]:[o,a],n}function T(e,t){return e-e%t}function k({scrollEl:e,views:t,sortByVisibility:i=!1,horizontal:n=!1,rtl:s=!1}){const r=e.scrollTop,a=r+e.clientHeight,o=e.scrollLeft,l=o+e.clientWidth;const d=[],h=new Set,c=t.length;let u=x(t,n?function(e){const t=e.div,i=t.offsetLeft+t.clientLeft,n=i+t.clientWidth;return s?i<l:n>o}:function(e){const t=e.div;return t.offsetTop+t.clientTop+t.clientHeight>r});u>0&&u<c&&!n&&(u=function(e,t,i){if(e<2)return e;let n=t[e].div,s=n.offsetTop+n.clientTop;s>=i&&(n=t[e-1].div,s=n.offsetTop+n.clientTop);for(let i=e-2;i>=0&&(n=t[i].div,!(n.offsetTop+n.clientTop+n.clientHeight<=s));--i)e=i;return e}(u,t,r));let p=n?l:-1;for(let e=u;e<c;e++){const i=t[e],s=i.div,c=s.offsetLeft+s.clientLeft,u=s.offsetTop+s.clientTop,g=s.clientWidth,f=s.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((n?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;d.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),h.add(i.id)}const g=d[0],f=d.at(-1);return i&&d.sort(function(e,t){const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id}),{first:g,last:f,views:d,ids:h}}function A(e){let t=Math.hypot(e.deltaX,e.deltaY);const i=Math.atan2(e.deltaY,e.deltaX);return-.25*Math.PI<i&&i<.75*Math.PI&&(t=-t),t}function D(e){return Number.isInteger(e)&&e%90==0}function B(e){return Number.isInteger(e)&&Object.values(b).includes(e)&&e!==b.UNKNOWN}function N(e){return Number.isInteger(e)&&Object.values(v).includes(e)&&e!==v.UNKNOWN}function O(e){return e.width<=e.height}const F=new Promise(function(e){window.requestAnimationFrame(e)}),V=document.documentElement.style;class R{#e=null;#t=null;#i=0;#n=null;#s=!0;constructor(e){this.#e=e.classList,this.#n=e.style}get percent(){return this.#i}set percent(e){var t,i,n;this.#i=(t=e,i=0,n=100,Math.min(Math.max(t,i),n)),isNaN(e)?this.#e.add("indeterminate"):(this.#e.remove("indeterminate"),this.#n.setProperty("--progressBar-percent",`${this.#i}%`))}setWidth(e){if(!e)return;const t=e.parentNode.offsetWidth-e.offsetWidth;t>0&&this.#n.setProperty("--progressBar-end-offset",`${t}px`)}setDisableAutoFetch(e=5e3){isNaN(this.#i)||(this.#t&&clearTimeout(this.#t),this.show(),this.#t=setTimeout(()=>{this.#t=null,this.hide()},e))}hide(){this.#s&&(this.#s=!1,this.#e.add("hidden"))}show(){this.#s||(this.#s=!0,this.#e.remove("hidden"))}}function j(e){let t=b.VERTICAL,i=v.NONE;switch(e){case"SinglePage":t=b.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=b.PAGE;case"TwoColumnLeft":i=v.ODD;break;case"TwoPageRight":t=b.PAGE;case"TwoColumnRight":i=v.EVEN}return{scrollMode:t,spreadMode:i}}function H(e,t,i=null){e.classList.toggle("toggled",t),e.setAttribute("aria-checked",t),i?.classList.toggle("hidden",!t)}function z(e,t,i=null){e.classList.toggle("toggled",t),e.setAttribute("aria-expanded",t),i?.classList.toggle("hidden",!t)}{var U=Object.create(null);const e=navigator.userAgent||"",t=navigator.platform||"",i=navigator.maxTouchPoints||1,n=/Android/.test(e);(/\b(iPad|iPhone|iPod)(?=;)/.test(e)||"MacIntel"===t&&i>1||n)&&(U.maxCanvasPixels=5242880)}const $=1,W=2,Z=4,X=8,G=128,K={canvasMaxAreaInBytes:{value:-1,kind:$+Z},isInAutomation:{value:!1,kind:$},supportsCaretBrowsingMode:{value:!1,kind:$},supportsDocumentFonts:{value:!0,kind:$},supportsIntegratedFind:{value:!1,kind:$},supportsMouseWheelZoomCtrlKey:{value:!0,kind:$},supportsMouseWheelZoomMetaKey:{value:!0,kind:$},supportsPinchToZoom:{value:!0,kind:$},annotationEditorMode:{value:0,kind:W+G},annotationMode:{value:2,kind:W+G},cursorToolOnLoad:{value:0,kind:W+G},debuggerSrc:{value:"./debugger.mjs",kind:W},defaultZoomDelay:{value:400,kind:W+G},defaultZoomValue:{value:"",kind:W+G},disableHistory:{value:!1,kind:W},disablePageLabels:{value:!1,kind:W+G},enableHighlightEditor:{value:!1,kind:W+G},enableHighlightFloatingButton:{value:!1,kind:W+G},enableML:{value:!1,kind:W+G},enablePermissions:{value:!1,kind:W+G},enablePrintAutoRotate:{value:!0,kind:W+G},enableScripting:{value:!0,kind:W+G},enableStampEditor:{value:!0,kind:W+G},externalLinkRel:{value:"noopener noreferrer nofollow",kind:W},externalLinkTarget:{value:0,kind:W+G},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:W+G},historyUpdateUrl:{value:!1,kind:W+G},ignoreDestinationZoom:{value:!1,kind:W+G},imageResourcesPath:{value:"./images/",kind:W},maxCanvasPixels:{value:2**25,kind:W},forcePageColors:{value:!1,kind:W+G},pageColorsBackground:{value:"Canvas",kind:W+G},pageColorsForeground:{value:"CanvasText",kind:W+G},pdfBugEnabled:{value:!1,kind:W+G},printResolution:{value:150,kind:W},sidebarViewOnLoad:{value:-1,kind:W+G},scrollModeOnLoad:{value:-1,kind:W+G},spreadModeOnLoad:{value:-1,kind:W+G},textLayerMode:{value:1,kind:W+G},viewOnLoad:{value:0,kind:W+G},cMapPacked:{value:!0,kind:Z},cMapUrl:{value:"../web/cmaps/",kind:Z},disableAutoFetch:{value:!1,kind:Z+G},disableFontFace:{value:!1,kind:Z+G},disableRange:{value:!1,kind:Z+G},disableStream:{value:!1,kind:Z+G},docBaseUrl:{value:"",kind:Z},enableHWA:{value:!0,kind:Z+W+G},enableXfa:{value:!0,kind:Z+G},fontExtraProperties:{value:!1,kind:Z},isEvalSupported:{value:!0,kind:Z},isOffscreenCanvasSupported:{value:!0,kind:Z},maxImageSize:{value:-1,kind:Z},pdfBug:{value:!1,kind:Z},standardFontDataUrl:{value:"../web/standard_fonts/",kind:Z},verbosity:{value:1,kind:Z},workerPort:{value:null,kind:X},workerSrc:{value:"../build/pdf.worker.mjs",kind:X}};K.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:W},K.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:W},K.viewerCssTheme={value:0,kind:W+G},K.disablePreferences={value:!1,kind:W},K.locale={value:navigator.language||"en-US",kind:W};const q=Object.create(null);for(const e in U)q[e]=U[e];class Q{constructor(){throw new Error("Cannot initialize AppOptions.")}static get(e){return q[e]??K[e]?.value??void 0}static getAll(e=null,t=!1){const i=Object.create(null);for(const n in K){const s=K[n];(!e||e&s.kind)&&(i[n]=t?s.value:q[n]??s.value)}return i}static set(e,t){q[e]=t}static setAll(e,t=!1){if(t){if(this.get("disablePreferences"))return;for(const e in q)if(void 0===U[e]){console.warn('setAll: The Preferences may override manually set AppOptions; please use the "disablePreferences"-option in order to prevent that.');break}}for(const t in e)q[t]=e[t]}static remove(e){delete q[e];const t=U[e];void 0!==t&&(q[e]=t)}}const J={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class Y{externalLinkEnabled=!0;constructor({eventBus:e,externalLinkTarget:t=null,externalLinkRel:i=null,ignoreDestinationZoom:n=!1}={}){this.eventBus=e,this.externalLinkTarget=t,this.externalLinkRel=i,this._ignoreDestinationZoom=n,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(e,t=null){this.baseUrl=t,this.pdfDocument=e}setViewer(e){this.pdfViewer=e}setHistory(e){this.pdfHistory=e}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(e){this.pdfDocument&&(this.pdfViewer.currentPageNumber=e)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(e){this.pdfDocument&&(this.pdfViewer.pagesRotation=e)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}async goToDestination(e){if(!this.pdfDocument)return;let t,i,n;if("string"==typeof e?(t=e,i=await this.pdfDocument.getDestination(e)):(t=null,i=await e),!Array.isArray(i))return void console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${e}".`);const[s]=i;if(s&&"object"==typeof s){if(n=this.pdfDocument.cachedPageNumber(s),!n)try{n=await this.pdfDocument.getPageIndex(s)+1}catch{return void console.error(`goToDestination: "${s}" is not a valid page reference, for dest="${e}".`)}}else Number.isInteger(s)&&(n=s+1);!n||n<1||n>this.pagesCount?console.error(`goToDestination: "${n}" is not a valid page number, for dest="${e}".`):(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:t,explicitDest:i,pageNumber:n})),this.pdfViewer.scrollPageIntoView({pageNumber:n,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom}))}goToPage(e){if(!this.pdfDocument)return;const t="string"==typeof e&&this.pdfViewer.pageLabelToPageNumber(e)||0|e;Number.isInteger(t)&&t>0&&t<=this.pagesCount?(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(t)),this.pdfViewer.scrollPageIntoView({pageNumber:t})):console.error(`PDFLinkService.goToPage: "${e}" is not a valid page.`)}addLinkAttributes(e,t,i=!1){if(!t||"string"!=typeof t)throw new Error('A valid "url" parameter must provided.');const n=i?J.BLANK:this.externalLinkTarget,s=this.externalLinkRel;this.externalLinkEnabled?e.href=e.title=t:(e.href="",e.title=`Disabled: ${t}`,e.onclick=()=>!1);let r="";switch(n){case J.NONE:break;case J.SELF:r="_self";break;case J.BLANK:r="_blank";break;case J.PARENT:r="_parent";break;case J.TOP:r="_top"}e.target=r,e.rel="string"==typeof s?s:"noopener noreferrer nofollow"}getDestinationHash(e){if("string"==typeof e){if(e.length>0)return this.getAnchorUrl("#"+escape(e))}else if(Array.isArray(e)){const t=JSON.stringify(e);if(t.length>0)return this.getAnchorUrl("#"+escape(t))}return this.getAnchorUrl("")}getAnchorUrl(e){return this.baseUrl?this.baseUrl+e:e}setHash(e){if(!this.pdfDocument)return;let t,i;if(e.includes("=")){const n=E(e);if(n.has("search")){const e=n.get("search").replaceAll('"',""),t="true"===n.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:t?e:e.match(/\S+/g)})}if(n.has("page")&&(t=0|n.get("page")||1),n.has("zoom")){const e=n.get("zoom").split(","),t=e[0],s=parseFloat(t);t.includes("Fit")?"Fit"===t||"FitB"===t?i=[null,{name:t}]:"FitH"===t||"FitBH"===t||"FitV"===t||"FitBV"===t?i=[null,{name:t},e.length>1?0|e[1]:null]:"FitR"===t?5!==e.length?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:t},0|e[1],0|e[2],0|e[3],0|e[4]]:console.error(`PDFLinkService.setHash: "${t}" is not a valid zoom value.`):i=[null,{name:"XYZ"},e.length>1?0|e[1]:null,e.length>2?0|e[2]:null,s?s/100:t]}return i?this.pdfViewer.scrollPageIntoView({pageNumber:t||this.page,destArray:i,allowNegativeOffset:!0}):t&&(this.page=t),n.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:n.get("pagemode")}),void(n.has("nameddest")&&this.goToDestination(n.get("nameddest")))}i=unescape(e);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||Y.#r(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(e)}" is not a valid destination.`)}executeNamedAction(e){if(this.pdfDocument){switch(e){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:e})}}async executeSetOCGState(e){if(!this.pdfDocument)return;const t=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;t===this.pdfDocument&&(i.setOCGState(e),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}static#r(e){if(!Array.isArray(e)||e.length<2)return!1;const[t,i,...n]=e;if(!("object"==typeof t&&Number.isInteger(t?.num)&&Number.isInteger(t?.gen)||Number.isInteger(t)))return!1;if("object"!=typeof i||"string"!=typeof i?.name)return!1;let s=!0;switch(i.name){case"XYZ":if(3!==n.length)return!1;break;case"Fit":case"FitB":return 0===n.length;case"FitH":case"FitBH":case"FitV":case"FitBV":if(1!==n.length)return!1;break;case"FitR":if(4!==n.length)return!1;s=!1;break;default:return!1}for(const e of n)if(!("number"==typeof e||s&&null===e))return!1;return!0}}class ee extends Y{setDocument(e,t=null){}}const{AbortException:te,AnnotationEditorLayer:ie,AnnotationEditorParamsType:ne,AnnotationEditorType:se,AnnotationEditorUIManager:re,AnnotationLayer:ae,AnnotationMode:oe,build:le,CMapCompressionType:de,ColorPicker:he,createValidAbsoluteUrl:ce,DOMSVGFactory:ue,DrawLayer:pe,FeatureTest:ge,fetchData:fe,getDocument:me,getFilenameFromUrl:be,getPdfFilenameFromUrl:ve,getXfaPageViewport:we,GlobalWorkerOptions:ye,ImageKind:Pe,InvalidPDFException:_e,isDataScheme:Ce,isPdfFile:Se,MissingPDFException:Ee,noContextMenu:Le,normalizeUnicode:Ie,OPS:xe,Outliner:Me,PasswordResponses:Te,PDFDataRangeTransport:ke,PDFDateString:Ae,PDFWorker:De,PermissionFlag:Be,PixelsPerInch:Ne,RenderingCancelledException:Oe,renderTextLayer:Fe,setLayerDimensions:Ve,shadow:Re,TextLayer:je,UnexpectedResponseException:He,updateTextLayer:ze,Util:Ue,VerbosityLevel:$e,version:We,XfaLayer:Ze}=globalThis.pdfjsLib,Xe="event",Ge="timeout";async function Ke({target:e,name:t,delay:i=0}){if("object"!=typeof e||!t||"string"!=typeof t||!(Number.isInteger(i)&&i>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:n,resolve:s}=Promise.withResolvers(),r=new AbortController;function a(e){r.abort(),clearTimeout(o),s(e)}e[e instanceof qe?"_on":"addEventListener"](t,a.bind(null,Xe),{signal:r.signal});const o=setTimeout(a.bind(null,Ge),i);return n}class qe{#a=Object.create(null);on(e,t,i=null){this._on(e,t,{external:!0,once:i?.once,signal:i?.signal})}off(e,t,i=null){this._off(e,t)}dispatch(e,t){const i=this.#a[e];if(!i||0===i.length)return;let n;for(const{listener:s,external:r,once:a}of i.slice(0))a&&this._off(e,s),r?(n||=[]).push(s):s(t);if(n){for(const e of n)e(t);n=null}}_on(e,t,i=null){let n=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted)return void console.error("Cannot use an `aborted` signal.");const r=()=>this._off(e,t);n=()=>s.removeEventListener("abort",r),s.addEventListener("abort",r)}(this.#a[e]||=[]).push({listener:t,external:!0===i?.external,once:!0===i?.once,rmAbort:n})}_off(e,t,i=null){const n=this.#a[e];if(n)for(let e=0,i=n.length;e<i;e++){const i=n[e];if(i.listener===t)return i.rmAbort?.(),void n.splice(e,1)}}}class Qe{constructor(){if(this.constructor===Qe)throw new Error("Cannot initialize BaseExternalServices.")}updateFindControlState(e){}updateFindMatchesCount(e){}initPassiveLoading(){}reportTelemetry(e){}async createL10n(){throw new Error("Not implemented: createL10n")}createScripting(){throw new Error("Not implemented: createScripting")}updateEditorStates(e){throw new Error("Not implemented: updateEditorStates")}async getNimbusExperimentData(){}async getGlobalEventNames(){return null}dispatchGlobalEvent(e){}}class Je{#o=Object.freeze({canvasMaxAreaInBytes:-1,isInAutomation:!1,supportsCaretBrowsingMode:!1,supportsDocumentFonts:!0,supportsIntegratedFind:!1,supportsMouseWheelZoomCtrlKey:!0,supportsMouseWheelZoomMetaKey:!0,supportsPinchToZoom:!0});#l=Object.freeze({annotationEditorMode:0,annotationMode:2,cursorToolOnLoad:0,defaultZoomDelay:400,defaultZoomValue:"",disablePageLabels:!1,enableHighlightEditor:!1,enableHighlightFloatingButton:!1,enableML:!1,enablePermissions:!1,enablePrintAutoRotate:!0,enableScripting:!0,enableStampEditor:!0,externalLinkTarget:0,highlightEditorColors:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",historyUpdateUrl:!1,ignoreDestinationZoom:!1,forcePageColors:!1,pageColorsBackground:"Canvas",pageColorsForeground:"CanvasText",pdfBugEnabled:!1,sidebarViewOnLoad:-1,scrollModeOnLoad:-1,spreadModeOnLoad:-1,textLayerMode:1,viewOnLoad:0,disableAutoFetch:!1,disableFontFace:!1,disableRange:!1,disableStream:!1,enableHWA:!0,enableXfa:!0,viewerCssTheme:0});#d=Object.create(null);#h=null;constructor(){if(this.constructor===Je)throw new Error("Cannot initialize BasePreferences.");this.#h=this._readFromStorage(this.#l).then(({browserPrefs:e,prefs:t})=>{const i=Object.create(null);for(const[t,n]of Object.entries(this.#o)){const s=e?.[t];i[t]=typeof s==typeof n?s:n}for(const[e,n]of Object.entries(this.#l)){const s=t?.[e];i[e]=this.#d[e]=typeof s==typeof n?s:n}Q.setAll(i,!0)})}async _writeToStorage(e){throw new Error("Not implemented: _writeToStorage")}async _readFromStorage(e){throw new Error("Not implemented: _readFromStorage")}#c({name:e,value:t}){throw new Error("Not implemented: #updatePref")}async reset(){await this.#h;const e=structuredClone(this.#d);this.#d=Object.create(null);try{await this._writeToStorage(this.#l)}catch(t){throw this.#d=e,t}}async set(e,t){await this.#h;const i=this.#l[e],n=structuredClone(this.#d);if(void 0===i)throw new Error(`Set preference: "${e}" is undefined.`);if(void 0===t)throw new Error("Set preference: no value is specified.");const s=typeof t,r=typeof i;if(s!==r){if("number"!==s||"string"!==r)throw new Error(`Set preference: "${t}" is a ${s}, expected a ${r}.`);t=t.toString()}else if("number"===s&&!Number.isInteger(t))throw new Error(`Set preference: "${t}" must be an integer.`);this.#d[e]=t;try{await this._writeToStorage(this.#d)}catch(e){throw this.#d=n,e}}async get(e){await this.#h;const t=this.#l[e];if(void 0===t)throw new Error(`Get preference: "${e}" is undefined.`);return this.#d[e]??t}get initializedPromise(){return this.#h}}class Ye{constructor(e){this.value=e}valueOf(){return this.value}}class et extends Ye{constructor(e="???"){super(e)}toString(e){return`{${this.value}}`}}class tt extends Ye{constructor(e,t={}){super(e),this.opts=t}toString(e){try{return e.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(t){return e.reportError(t),this.value.toString(10)}}}class it extends Ye{constructor(e,t={}){super(e),this.opts=t}toString(e){try{return e.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(t){return e.reportError(t),new Date(this.value).toISOString()}}}function nt(e,t,i){if(i===t)return!0;if(i instanceof tt&&t instanceof tt&&i.value===t.value)return!0;if(t instanceof tt&&"string"==typeof i){if(i===e.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value))return!0}return!1}function st(e,t,i){return t[i]?lt(e,t[i].value):(e.reportError(new RangeError("No default")),new et)}function rt(e,t){const i=[],n=Object.create(null);for(const s of t)"narg"===s.type?n[s.name]=at(e,s.value):i.push(at(e,s));return{positional:i,named:n}}function at(e,t){switch(t.type){case"str":return t.value;case"num":return new tt(t.value,{minimumFractionDigits:t.precision});case"var":return function(e,{name:t}){let i;if(e.params){if(!Object.prototype.hasOwnProperty.call(e.params,t))return new et(`$${t}`);i=e.params[t]}else{if(!e.args||!Object.prototype.hasOwnProperty.call(e.args,t))return e.reportError(new ReferenceError(`Unknown variable: $${t}`)),new et(`$${t}`);i=e.args[t]}if(i instanceof Ye)return i;switch(typeof i){case"string":return i;case"number":return new tt(i);case"object":if(i instanceof Date)return new it(i.getTime());default:return e.reportError(new TypeError(`Variable type not supported: $${t}, ${typeof i}`)),new et(`$${t}`)}}(e,t);case"mesg":return function(e,{name:t,attr:i}){const n=e.bundle._messages.get(t);if(!n)return e.reportError(new ReferenceError(`Unknown message: ${t}`)),new et(t);if(i){const s=n.attributes[i];return s?lt(e,s):(e.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new et(`${t}.${i}`))}if(n.value)return lt(e,n.value);return e.reportError(new ReferenceError(`No value: ${t}`)),new et(t)}(e,t);case"term":return function(e,{name:t,attr:i,args:n}){const s=`-${t}`,r=e.bundle._terms.get(s);if(!r)return e.reportError(new ReferenceError(`Unknown term: ${s}`)),new et(s);if(i){const t=r.attributes[i];if(t){e.params=rt(e,n).named;const i=lt(e,t);return e.params=null,i}return e.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new et(`${s}.${i}`)}e.params=rt(e,n).named;const a=lt(e,r.value);return e.params=null,a}(e,t);case"func":return function(e,{name:t,args:i}){let n=e.bundle._functions[t];if(!n)return e.reportError(new ReferenceError(`Unknown function: ${t}()`)),new et(`${t}()`);if("function"!=typeof n)return e.reportError(new TypeError(`Function ${t}() is not callable`)),new et(`${t}()`);try{let t=rt(e,i);return n(t.positional,t.named)}catch(i){return e.reportError(i),new et(`${t}()`)}}(e,t);case"select":return function(e,{selector:t,variants:i,star:n}){let s=at(e,t);if(s instanceof et)return st(e,i,n);for(const t of i){if(nt(e,s,at(e,t.key)))return lt(e,t.value)}return st(e,i,n)}(e,t);default:return new et}}function ot(e,t){if(e.dirty.has(t))return e.reportError(new RangeError("Cyclic reference")),new et;e.dirty.add(t);const i=[],n=e.bundle._useIsolating&&t.length>1;for(const s of t)if("string"!=typeof s){if(e.placeables++,e.placeables>100)throw e.dirty.delete(t),new RangeError(`Too many placeables expanded: ${e.placeables}, max allowed is 100`);n&&i.push("⁨"),i.push(at(e,s).toString(e)),n&&i.push("⁩")}else i.push(e.bundle._transform(s));return e.dirty.delete(t),i.join("")}function lt(e,t){return"string"==typeof t?e.bundle._transform(t):ot(e,t)}class dt{constructor(e,t,i){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=e,this.errors=t,this.args=i}reportError(e){if(!(this.errors&&e instanceof Error))throw e;this.errors.push(e)}memoizeIntlObject(e,t){let i=this.bundle._intls.get(e);i||(i={},this.bundle._intls.set(e,i));let n=JSON.stringify(t);return i[n]||(i[n]=new e(this.bundle.locales,t)),i[n]}}function ht(e,t){const i=Object.create(null);for(const[n,s]of Object.entries(e))t.includes(n)&&(i[n]=s.valueOf());return i}const ct=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function ut(e,t){let i=e[0];if(i instanceof et)return new et(`NUMBER(${i.valueOf()})`);if(i instanceof tt)return new tt(i.valueOf(),{...i.opts,...ht(t,ct)});if(i instanceof it)return new tt(i.valueOf(),{...ht(t,ct)});throw new TypeError("Invalid argument to NUMBER")}const pt=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function gt(e,t){let i=e[0];if(i instanceof et)return new et(`DATETIME(${i.valueOf()})`);if(i instanceof it)return new it(i.valueOf(),{...i.opts,...ht(t,pt)});if(i instanceof tt)return new it(i.valueOf(),{...ht(t,pt)});throw new TypeError("Invalid argument to DATETIME")}const ft=new Map;class mt{constructor(e,{functions:t,useIsolating:i=!0,transform:n=e=>e}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(e)?e:[e],this._functions={NUMBER:ut,DATETIME:gt,...t},this._useIsolating=i,this._transform=n,this._intls=function(e){const t=Array.isArray(e)?e.join(" "):e;let i=ft.get(t);return void 0===i&&(i=new Map,ft.set(t,i)),i}(e)}hasMessage(e){return this._messages.has(e)}getMessage(e){return this._messages.get(e)}addResource(e,{allowOverrides:t=!1}={}){const i=[];for(let n=0;n<e.body.length;n++){let s=e.body[n];if(s.id.startsWith("-")){if(!1===t&&this._terms.has(s.id)){i.push(new Error(`Attempt to override an existing term: "${s.id}"`));continue}this._terms.set(s.id,s)}else{if(!1===t&&this._messages.has(s.id)){i.push(new Error(`Attempt to override an existing message: "${s.id}"`));continue}this._messages.set(s.id,s)}}return i}formatPattern(e,t=null,i=null){if("string"==typeof e)return this._transform(e);let n=new dt(this,i,t);try{return ot(n,e).toString(n)}catch(e){if(n.errors&&e instanceof Error)return n.errors.push(e),(new et).toString(n);throw e}}}const bt=/^(-?[a-zA-Z][\w-]*) *= */gm,vt=/\.([a-zA-Z][\w-]*) *= */y,wt=/\*?\[/y,yt=/(-?[0-9]+(?:\.([0-9]+))?)/y,Pt=/([a-zA-Z][\w-]*)/y,_t=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Ct=/^[A-Z][A-Z0-9_-]*$/,St=/([^{}\n\r]+)/y,Et=/([^\\"\n\r]*)/y,Lt=/\\([\\"])/y,It=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,xt=/^\n+/,Mt=/ +$/,Tt=/ *\r?\n/g,kt=/( *)$/,At=/{\s*/y,Dt=/\s*}/y,Bt=/\[\s*/y,Nt=/\s*] */y,Ot=/\s*\(\s*/y,Ft=/\s*->\s*/y,Vt=/\s*:\s*/y,Rt=/\s*,?\s*/y,jt=/\s+/y;class Ht{constructor(e){this.body=[],bt.lastIndex=0;let t=0;for(;;){let i=bt.exec(e);if(null===i)break;t=bt.lastIndex;try{this.body.push(o(i[1]))}catch(e){if(e instanceof SyntaxError)continue;throw e}}function i(i){return i.lastIndex=t,i.test(e)}function n(i,n){if(e[t]===i)return t++,!0;if(n)throw new n(`Expected ${i}`);return!1}function s(e,n){if(i(e))return t=e.lastIndex,!0;if(n)throw new n(`Expected ${e.toString()}`);return!1}function r(i){i.lastIndex=t;let n=i.exec(e);if(null===n)throw new SyntaxError(`Expected ${i.toString()}`);return t=i.lastIndex,n}function a(e){return r(e)[1]}function o(e){let t=l(),n=function(){let e=Object.create(null);for(;i(vt);){let t=a(vt),i=l();if(null===i)throw new SyntaxError("Expected attribute value");e[t]=i}return e}();if(null===t&&0===Object.keys(n).length)throw new SyntaxError("Expected message value or attributes");return{id:e,value:t,attributes:n}}function l(){let n;if(i(St)&&(n=a(St)),"{"===e[t]||"}"===e[t])return d(n?[n]:[],1/0);let s=b();return s?n?d([n,s],s.length):(s.value=v(s.value,xt),d([s],s.length)):n?v(n,Mt):null}function d(n=[],s){for(;;){if(i(St)){n.push(a(St));continue}if("{"===e[t]){n.push(h());continue}if("}"===e[t])throw new SyntaxError("Unbalanced closing brace");let r=b();if(!r)break;n.push(r),s=Math.min(s,r.length)}let r=n.length-1,o=n[r];"string"==typeof o&&(n[r]=v(o,Mt));let l=[];for(let e of n)e instanceof zt&&(e=e.value.slice(0,e.value.length-s)),e&&l.push(e);return l}function h(){s(At,SyntaxError);let e=c();if(s(Dt))return e;if(s(Ft)){let t=function(){let e,t=[],s=0;for(;i(wt);){n("*")&&(e=s);let i=p(),r=l();if(null===r)throw new SyntaxError("Expected variant value");t[s++]={key:i,value:r}}if(0===s)return null;if(void 0===e)throw new SyntaxError("Expected default variant");return{variants:t,star:e}}();return s(Dt,SyntaxError),{type:"select",selector:e,...t}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===e[t])return h();if(i(_t)){let[,i,n,a=null]=r(_t);if("$"===i)return{type:"var",name:n};if(s(Ot)){let r=function(){let i=[];for(;;){switch(e[t]){case")":return t++,i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(u()),s(Rt)}}();if("-"===i)return{type:"term",name:n,attr:a,args:r};if(Ct.test(n))return{type:"func",name:n,args:r};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:n,attr:a,args:[]}:{type:"mesg",name:n,attr:a}}return g()}function u(){let e=c();return"mesg"!==e.type?e:s(Vt)?{type:"narg",name:e.name,value:g()}:e}function p(){let e;return s(Bt,SyntaxError),e=i(yt)?f():{type:"str",value:a(Pt)},s(Nt,SyntaxError),e}function g(){if(i(yt))return f();if('"'===e[t])return function(){n('"',SyntaxError);let i="";for(;;){if(i+=a(Et),"\\"!==e[t]){if(n('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=m()}}();throw new SyntaxError("Invalid expression")}function f(){let[,e,t=""]=r(yt),i=t.length;return{type:"num",value:parseFloat(e),precision:i}}function m(){if(i(Lt))return a(Lt);if(i(It)){let[,e,t]=r(It),i=parseInt(e||t,16);return i<=55295||57344<=i?String.fromCodePoint(i):"�"}throw new SyntaxError("Unknown escape sequence")}function b(){let i=t;switch(s(jt),e[t]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return w(e.slice(i,t))}return" "===e[t-1]&&w(e.slice(i,t))}function v(e,t){return e.replace(t,"")}function w(e){let t=e.replace(Tt,"\n"),i=kt.exec(e)[1].length;return new zt(t,i)}}}class zt{constructor(e,t){this.value=e,this.length=t}}const Ut=/<|&#?\w+;/,$t={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},Wt={"http://www.w3.org/1999/xhtml":{global:["title","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function Zt(e,t){const{value:i}=t;if("string"==typeof i)if("title"===e.localName&&"http://www.w3.org/1999/xhtml"===e.namespaceURI)e.textContent=i;else if(Ut.test(i)){const t=e.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");t.innerHTML=i,function(e,t){for(const i of e.childNodes)if(i.nodeType!==i.TEXT_NODE){if(i.hasAttribute("data-l10n-name")){const n=Kt(t,i);e.replaceChild(n,i);continue}if(Jt(i)){const t=qt(i);e.replaceChild(t,i);continue}console.warn(`An element of forbidden type "${i.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`),e.replaceChild(Qt(i),i)}t.textContent="",t.appendChild(e)}(t.content,e)}else e.textContent=i;Gt(t,e)}function Xt(e,t){if(!e)return!1;for(let i of e)if(i.name===t)return!0;return!1}function Gt(e,t){const i=t.hasAttribute("data-l10n-attrs")?t.getAttribute("data-l10n-attrs").split(",").map(e=>e.trim()):null;for(const n of Array.from(t.attributes))Yt(n.name,t,i)&&!Xt(e.attributes,n.name)&&t.removeAttribute(n.name);if(e.attributes)for(const n of Array.from(e.attributes))Yt(n.name,t,i)&&t.getAttribute(n.name)!==n.value&&t.setAttribute(n.name,n.value)}function Kt(e,t){const i=t.getAttribute("data-l10n-name"),n=e.querySelector(`[data-l10n-name="${i}"]`);if(!n)return console.warn(`An element named "${i}" wasn't found in the source.`),Qt(t);if(n.localName!==t.localName)return console.warn(`An element named "${i}" was found in the translation but its type ${t.localName} didn't match the element found in the source (${n.localName}).`),Qt(t);e.removeChild(n);return ei(t,n.cloneNode(!1))}function qt(e){const t=e.ownerDocument.createElement(e.localName);return ei(e,t)}function Qt(e){return e.ownerDocument.createTextNode(e.textContent)}function Jt(e){const t=$t[e.namespaceURI];return t&&t.includes(e.localName)}function Yt(e,t,i=null){if(i&&i.includes(e))return!0;const n=Wt[t.namespaceURI];if(!n)return!1;const s=e.toLowerCase(),r=t.localName;if(n.global.includes(s))return!0;if(!n[r])return!1;if(n[r].includes(s))return!0;if("http://www.w3.org/1999/xhtml"===t.namespaceURI&&"input"===r&&"value"===s){const e=t.type.toLowerCase();if("submit"===e||"button"===e||"reset"===e)return!0}return!1}function ei(e,t){return t.textContent=e.textContent,Gt(e,t),t}class ti extends Array{static from(e){return e instanceof this?e:new this(e)}}Symbol.iterator;class ii extends ti{constructor(e){if(super(),Symbol.asyncIterator in Object(e))this.iterator=e[Symbol.asyncIterator]();else{if(!(Symbol.iterator in Object(e)))throw new TypeError("Argument must implement the iteration protocol.");this.iterator=e[Symbol.iterator]()}}[Symbol.asyncIterator](){const e=this;let t=0;return{next:async()=>(e.length<=t&&e.push(e.iterator.next()),e[t++])}}async touchNext(e=1){let t=0;for(;t++<e;){const e=this[this.length-1];if(e&&(await e).done)break;this.push(this.iterator.next())}return this[this.length-1]}}class ni{constructor(e=[],t){this.resourceIds=e,this.generateBundles=t,this.onChange(!0)}addResourceIds(e,t=!1){return this.resourceIds.push(...e),this.onChange(t),this.resourceIds.length}removeResourceIds(e){return this.resourceIds=this.resourceIds.filter(t=>!e.includes(t)),this.onChange(),this.resourceIds.length}async formatWithFallback(e,t){const i=[];let n=!1;for await(const s of this.bundles){n=!0;const r=ai(t,s,e,i);if(0===r.size)break;if("undefined"!=typeof console){const e=s.locales[0],t=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${e}: ${t}`)}}return n||"undefined"==typeof console||console.warn(`[fluent] Request for keys failed because no resource bundles got generated.\n  keys: ${JSON.stringify(e)}.\n  resourceIds: ${JSON.stringify(this.resourceIds)}.`),i}formatMessages(e){return this.formatWithFallback(e,ri)}formatValues(e){return this.formatWithFallback(e,si)}async formatValue(e,t){const[i]=await this.formatValues([{id:e,args:t}]);return i}handleEvent(){this.onChange()}onChange(e=!1){this.bundles=ii.from(this.generateBundles(this.resourceIds)),e&&this.bundles.touchNext(2)}}function si(e,t,i,n){return i.value?e.formatPattern(i.value,n,t):null}function ri(e,t,i,n){const s={value:null,attributes:null};i.value&&(s.value=e.formatPattern(i.value,n,t));let r=Object.keys(i.attributes);if(r.length>0){s.attributes=new Array(r.length);for(let[a,o]of r.entries()){let r=e.formatPattern(i.attributes[o],n,t);s.attributes[a]={name:o,value:r}}}return s}function ai(e,t,i,n){const s=[],r=new Set;return i.forEach(({id:i,args:a},o)=>{if(void 0!==n[o])return;let l=t.getMessage(i);if(l){if(s.length=0,n[o]=e(t,s,l,a),s.length>0&&"undefined"!=typeof console){const e=t.locales[0],n=s.join(", ");console.warn(`[fluent][resolver] errors in ${e}/${i}: ${n}.`)}}else r.add(i)}),r}const oi="data-l10n-id",li="data-l10n-args",di=`[${oi}]`;class hi extends ni{constructor(e,t){super(e,t),this.roots=new Set,this.pendingrAF=null,this.pendingElements=new Set,this.windowElement=null,this.mutationObserver=null,this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[oi,li]}}onChange(e=!1){super.onChange(e),this.roots&&this.translateRoots()}setAttributes(e,t,i){return e.setAttribute(oi,t),i?e.setAttribute(li,JSON.stringify(i)):e.removeAttribute(li),e}getAttributes(e){return{id:e.getAttribute(oi),args:JSON.parse(e.getAttribute(li)||null)}}connectRoot(e){for(const t of this.roots)if(t===e||t.contains(e)||e.contains(t))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==e.ownerDocument.defaultView)throw new Error("Cannot connect a root:\n          DOMLocalization already has a root from a different window.")}else this.windowElement=e.ownerDocument.defaultView,this.mutationObserver=new this.windowElement.MutationObserver(e=>this.translateMutations(e));this.roots.add(e),this.mutationObserver.observe(e,this.observerConfig)}disconnectRoot(e){return this.roots.delete(e),this.pauseObserving(),0===this.roots.size?(this.mutationObserver=null,this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF),this.windowElement=null,this.pendingrAF=null,this.pendingElements.clear(),!0):(this.resumeObserving(),!1)}translateRoots(){const e=Array.from(this.roots);return Promise.all(e.map(e=>this.translateFragment(e)))}pauseObserving(){this.mutationObserver&&(this.translateMutations(this.mutationObserver.takeRecords()),this.mutationObserver.disconnect())}resumeObserving(){if(this.mutationObserver)for(const e of this.roots)this.mutationObserver.observe(e,this.observerConfig)}translateMutations(e){for(const t of e)switch(t.type){case"attributes":t.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(t.target);break;case"childList":for(const e of t.addedNodes)if(e.nodeType===e.ELEMENT_NODE)if(e.childElementCount)for(const t of this.getTranslatables(e))this.pendingElements.add(t);else e.hasAttribute(oi)&&this.pendingElements.add(e)}this.pendingElements.size>0&&null===this.pendingrAF&&(this.pendingrAF=this.windowElement.requestAnimationFrame(()=>{this.translateElements(Array.from(this.pendingElements)),this.pendingElements.clear(),this.pendingrAF=null}))}translateFragment(e){return this.translateElements(this.getTranslatables(e))}async translateElements(e){if(!e.length)return;const t=e.map(this.getKeysForElement),i=await this.formatMessages(t);return this.applyTranslations(e,i)}applyTranslations(e,t){this.pauseObserving();for(let i=0;i<e.length;i++)void 0!==t[i]&&Zt(e[i],t[i]);this.resumeObserving()}getTranslatables(e){const t=Array.from(e.querySelectorAll(di));return"function"==typeof e.hasAttribute&&e.hasAttribute(oi)&&t.push(e),t}getKeysForElement(e){return{id:e.getAttribute(oi),args:JSON.parse(e.getAttribute(li)||null)}}}class ci{#u;#p=new Set;#g;#f;constructor({lang:e,isRTL:t},i=null){this.#g=ci.#m(e),this.#f=i,this.#u=t??ci.#b(this.#g)?"rtl":"ltr"}_setL10n(e){this.#f=e}getLanguage(){return this.#g}getDirection(){return this.#u}async get(e,t=null,i){if(Array.isArray(e)){e=e.map(e=>({id:e}));return(await this.#f.formatMessages(e)).map(e=>e.value)}const n=await this.#f.formatMessages([{id:e,args:t}]);return n?.[0].value||i}async translate(e){this.#p.add(e);try{this.#f.connectRoot(e),await this.#f.translateRoots()}catch{}}async destroy(){for(const e of this.#p)this.#f.disconnectRoot(e);this.#p.clear(),this.#f.pauseObserving()}pause(){this.#f.pauseObserving()}resume(){this.#f.resumeObserving()}static#m(e){return{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[e=e?.toLowerCase()||"en-us"]||e}static#b(e){const t=e.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(t)}}function ui(e,t){const i=new Ht(t),n=new mt(e),s=n.addResource(i);return s.length&&console.error("L10n errors",s),n}class pi extends ci{constructor(e){super({lang:e});const t=e?pi.#v.bind(pi,"en-us",this.getLanguage()):pi.#w.bind(pi,this.getLanguage());this._setL10n(new hi([],t))}static async*#v(e,t){const{baseURL:i,paths:n}=await this.#y(),s=[t];if(e!==t){const i=t.split("-",1)[0];i!==t&&s.push(i),s.push(e)}for(const e of s){const t=await this.#P(e,i,n);t?yield t:"en-us"===e&&(yield this.#_(e))}}static async#P(e,t,i){const n=i[e];if(!n)return null;const s=new URL(n,t);return ui(e,await fe(s,"text"))}static async#y(){try{const{href:e}=document.querySelector('link[type="application/l10n"]'),t=await fe(e,"json");return{baseURL:e.replace(/[^/]*$/,"")||"./",paths:t}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#w(e){yield this.#_(e)}static async#_(e){return ui(e,"pdfjs-previous-button =\n    .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n    .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n    .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n    .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n    .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n    .title = Zoom\npdfjs-presentation-mode-button =\n    .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n    .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n    .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n    .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n    .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n    .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n    .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n    .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n    .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n    .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n    .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n    .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n    .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n    .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n    .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n    .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n    .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n    .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n    .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n    .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n    .title = Document Properties…\npdfjs-document-properties-button-label = Document Properties…\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-kb = { $size_kb } KB ({ $size_b } bytes)\npdfjs-document-properties-mb = { $size_mb } MB ({ $size_b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-string = { $date }, { $time }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing…\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n    .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n    .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n    .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n    .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n    .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n    .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n    .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n    .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n    .title = Page { $page }\npdfjs-thumb-page-canvas =\n    .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n    .title = Find\n    .placeholder = Find in document…\npdfjs-find-previous-button =\n    .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n    .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n    { $total ->\n        [one] { $current } of { $total } match\n       *[other] { $current } of { $total } matches\n    }\npdfjs-find-match-count-limit =\n    { $limit ->\n        [one] More than { $limit } match\n       *[other] More than { $limit } matches\n    }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n    .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-string = { $date }, { $time }\npdfjs-text-annotation-type =\n    .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n    .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n    .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n    .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n    .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n    .title = Highlight\n    .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n    .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n    .title = Remove text\npdfjs-editor-remove-stamp-button =\n    .title = Remove image\npdfjs-editor-remove-highlight-button =\n    .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n    .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n    .title = Change thickness when highlighting items other than text\npdfjs-free-text =\n    .aria-label = Text Editor\npdfjs-free-text-default-content = Start typing…\npdfjs-ink =\n    .aria-label = Draw Editor\npdfjs-ink-canvas =\n    .aria-label = User-created image\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n    .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-label-top-left = Top left corner — resize\npdfjs-editor-resizer-label-top-middle = Top middle — resize\npdfjs-editor-resizer-label-top-right = Top right corner — resize\npdfjs-editor-resizer-label-middle-right = Middle right — resize\npdfjs-editor-resizer-label-bottom-right = Bottom right corner — resize\npdfjs-editor-resizer-label-bottom-middle = Bottom middle — resize\npdfjs-editor-resizer-label-bottom-left = Bottom left corner — resize\npdfjs-editor-resizer-label-middle-left = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n    .title = Change color\npdfjs-editor-colorpicker-dropdown =\n    .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n    .title = Yellow\npdfjs-editor-colorpicker-green =\n    .title = Green\npdfjs-editor-colorpicker-blue =\n    .title = Blue\npdfjs-editor-colorpicker-pink =\n    .title = Pink\npdfjs-editor-colorpicker-red =\n    .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n    .title = Show all")}}class gi{constructor(e){this._ready=new Promise((t,i)=>{import(e).then(e=>{t(e.QuickJSSandbox())}).catch(i)})}async createSandbox(e){(await this._ready).create(e)}async dispatchEventInSandbox(e){const t=await this._ready;setTimeout(()=>t.dispatchEvent(e),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}class fi extends Je{async _writeToStorage(e){localStorage.setItem("pdfjs.preferences",JSON.stringify(e))}async _readFromStorage(e){return{prefs:JSON.parse(localStorage.getItem("pdfjs.preferences"))}}}class mi extends Qe{async createL10n(){return new pi(Q.get("locale"))}createScripting(){return new gi(Q.get("sandboxBundleSrc"))}}class bi{async guess(){return null}}class vi{#C=this.#S.bind(this);#E=this.#L.bind(this);#I=this.#x.bind(this);#M=null;#T;#k;#A;#D=!1;#B;#N;#O;#F;#V;#R;#j=null;#H=null;#z=null;#U;#$=null;constructor({dialog:e,optionDescription:t,optionDecorative:i,textarea:n,cancelButton:s,saveButton:r},a,o,l){this.#k=e,this.#B=t,this.#N=i,this.#V=n,this.#T=s,this.#F=r,this.#O=o,this.#A=l,this.#U=a,e.addEventListener("close",this.#W.bind(this)),e.addEventListener("contextmenu",e=>{e.target!==this.#V&&e.preventDefault()}),s.addEventListener("click",this.#Z.bind(this)),r.addEventListener("click",this.#X.bind(this)),t.addEventListener("change",this.#C),i.addEventListener("change",this.#C),this.#O.register(e)}get _elements(){return Re(this,"_elements",[this.#B,this.#N,this.#V,this.#F,this.#T])}#G(){if(this.#H)return;const e=new ue,t=this.#H=e.createElement("svg");t.setAttribute("width","0"),t.setAttribute("height","0");const i=e.createElement("defs");t.append(i);const n=e.createElement("mask");i.append(n),n.setAttribute("id","alttext-manager-mask"),n.setAttribute("maskContentUnits","objectBoundingBox");let s=e.createElement("rect");n.append(s),s.setAttribute("fill","white"),s.setAttribute("width","1"),s.setAttribute("height","1"),s.setAttribute("x","0"),s.setAttribute("y","0"),s=this.#z=e.createElement("rect"),n.append(s),s.setAttribute("fill","black"),this.#k.append(t)}async editAltText(e,t){if(this.#M||!t)return;this.#G(),this.#D=!1;for(const e of this._elements)e.addEventListener("click",this.#I);const{altText:i,decorative:n}=t.altTextData;!0===n?(this.#N.checked=!0,this.#B.checked=!1):(this.#N.checked=!1,this.#B.checked=!0),this.#j=this.#V.value=i?.trim()||"",this.#S(),this.#M=t,this.#R=e,this.#R.removeEditListeners(),this.#A._on("resize",this.#E);try{await this.#O.open(this.#k),this.#L()}catch(e){throw this.#W(),e}}#L(){if(!this.#M)return;const e=this.#k,{style:t}=e,{x:i,y:n,width:s,height:r}=this.#U.getBoundingClientRect(),{innerWidth:a,innerHeight:o}=window,{width:l,height:d}=e.getBoundingClientRect(),{x:h,y:c,width:u,height:p}=this.#M.getClientDimensions(),g=10,f="ltr"===this.#R.direction,m=Math.max(h,i),b=Math.min(h+u,i+s),v=Math.max(c,n),w=Math.min(c+p,n+r);this.#z.setAttribute("width",""+(b-m)/a),this.#z.setAttribute("height",""+(w-v)/o),this.#z.setAttribute("x",""+m/a),this.#z.setAttribute("y",""+v/o);let y=null,P=Math.max(c,0);P+=Math.min(o-(P+d),0),f?h+u+g+l<a?y=h+u+g:h>l+g&&(y=h-l-g):h>l+g?y=h-l-g:h+u+g+l<a&&(y=h+u+g),null===y&&(P=null,y=Math.max(h,0),y+=Math.min(a-(y+l),0),c>d+g?P=c-d-g:c+p+g+d<o&&(P=c+p+g)),null!==P?(e.classList.add("positioned"),f?t.left=`${y}px`:t.right=a-y-l+"px",t.top=`${P}px`):(e.classList.remove("positioned"),t.left="",t.top="")}#Z(){this.#O.active===this.#k&&this.#O.close(this.#k)}#W(){this.#M._reportTelemetry(this.#$||{action:"alt_text_cancel",alt_text_keyboard:!this.#D}),this.#$=null,this.#K(),this.#R?.addEditListeners(),this.#A._off("resize",this.#E),this.#M.altTextFinish(),this.#M=null,this.#R=null}#S(){this.#V.disabled=this.#N.checked}#X(){const e=this.#V.value.trim(),t=this.#N.checked;this.#M.altTextData={altText:e,decorative:t},this.#$={action:"alt_text_save",alt_text_description:!!e,alt_text_edit:!!this.#j&&this.#j!==e,alt_text_decorative:t,alt_text_keyboard:!this.#D},this.#Z()}#x(e){0!==e.detail&&(this.#D=!0,this.#K())}#K(){for(const e of this._elements)e.removeEventListener("click",this.#I)}destroy(){this.#R=null,this.#Z(),this.#H?.remove(),this.#H=this.#z=null}}class wi{constructor(e,t){this.eventBus=t,this.#q(e)}#q({editorFreeTextFontSize:e,editorFreeTextColor:t,editorInkColor:i,editorInkThickness:n,editorInkOpacity:s,editorStampAddImage:r,editorFreeHighlightThickness:a,editorHighlightShowAll:o}){const l=(e,t)=>{this.eventBus.dispatch("switchannotationeditorparams",{source:this,type:ne[e],value:t})};e.addEventListener("input",function(){l("FREETEXT_SIZE",this.valueAsNumber)}),t.addEventListener("input",function(){l("FREETEXT_COLOR",this.value)}),i.addEventListener("input",function(){l("INK_COLOR",this.value)}),n.addEventListener("input",function(){l("INK_THICKNESS",this.valueAsNumber)}),s.addEventListener("input",function(){l("INK_OPACITY",this.valueAsNumber)}),r.addEventListener("click",()=>{l("CREATE")}),a.addEventListener("input",function(){l("HIGHLIGHT_THICKNESS",this.valueAsNumber)}),o.addEventListener("click",function(){const e="true"===this.getAttribute("aria-pressed");this.setAttribute("aria-pressed",!e),l("HIGHLIGHT_SHOW_ALL",!e)}),this.eventBus._on("annotationeditorparamschanged",r=>{for(const[l,d]of r.details)switch(l){case ne.FREETEXT_SIZE:e.value=d;break;case ne.FREETEXT_COLOR:t.value=d;break;case ne.INK_COLOR:i.value=d;break;case ne.INK_THICKNESS:n.value=d;break;case ne.INK_OPACITY:s.value=d;break;case ne.HIGHLIGHT_THICKNESS:a.value=d;break;case ne.HIGHLIGHT_FREE:a.disabled=!d;break;case ne.HIGHLIGHT_SHOW_ALL:o.setAttribute("aria-pressed",d)}})}}const yi=.1;class Pi{#Q;#J;#Y;constructor(e,t,i){this.#Q=e,this.#Y=t,this.#J=i?.getBoundingClientRect().height??0}#ee(e,t){const i=e.y,n=e.bottom,s=e.y+e.height/2,r=t.y,a=t.bottom,o=t.y+t.height/2;return i<=o&&o<=n||r<=s&&s<=a}#te(e,t,i,n){const s=e.y+e.height/2;return(n?i>=s:i<=s)&&e.x-yi<=t&&t<=e.right+yi}#ie(e){return e.top>=this.#J&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}#ne(e,t){const{focusNode:i,focusOffset:n}=e,s=document.createRange();s.setStart(i,n),s.setEnd(i,n);const r=s.getBoundingClientRect();return[r.x,t?r.top:r.bottom]}static#se(e,t){if(!document.caretPositionFromPoint){const{startContainer:i,startOffset:n}=document.caretRangeFromPoint(e,t);return{offsetNode:i,offset:n}}return document.caretPositionFromPoint(e,t)}#re(e,t,i,n,s){if(s||=n.getBoundingClientRect(),t<=s.x+yi)return void(i?e.extend(n.firstChild,0):e.setPosition(n.firstChild,0));if(s.right-yi<=t){const{lastChild:t}=n;return void(i?e.extend(t,t.length):e.setPosition(t,t.length))}const r=s.y+s.height/2;let a=Pi.#se(t,r),o=a.offsetNode?.parentElement;if(o&&o!==n){const e=document.elementsFromPoint(t,r),i=[];for(const t of e){if(t===n)break;const{style:e}=t;i.push([t,e.visibility]),e.visibility="hidden"}a=Pi.#se(t,r),o=a.offsetNode?.parentElement;for(const[e,t]of i)e.style.visibility=t}o===n?i?e.extend(a.offsetNode,a.offset):e.setPosition(a.offsetNode,a.offset):i?e.extend(n.firstChild,0):e.setPosition(n.firstChild,0)}#ae(e,t,i,n,s){this.#ie(n)?this.#re(t,s,e,i,n):(this.#Q.addEventListener("scrollend",this.#re.bind(this,t,s,e,i,null),{once:!0}),i.scrollIntoView())}#oe(e,t){for(;;){const i=e.closest(".page"),n=parseInt(i.getAttribute("data-page-number")),s=t?n-1:n+1;if(!(e=this.#Y.querySelector(`.page[data-page-number="${s}"] .textLayer`)))return null;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=t?r.lastChild():r.firstChild();if(a)return a}}moveCaret(e,t){const i=document.getSelection();if(0===i.rangeCount)return;const{focusNode:n}=i,s=n.nodeType!==Node.ELEMENT_NODE?n.parentElement:n,r=s.closest(".textLayer");if(!r)return;const a=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);a.currentNode=n;const o=s.getBoundingClientRect();let l=null;const d=(e?a.previousSibling:a.nextSibling).bind(a);for(;d();){const e=a.currentNode.parentElement;if(!this.#ee(o,e.getBoundingClientRect())){l=e;break}}if(!l){const s=this.#oe(r,e);if(!s)return;if(t){const t=(e?a.firstChild():a.lastChild())||n;i.extend(t,e?0:t.length);const r=document.createRange();return r.setStart(s,e?s.length:0),r.setEnd(s,e?s.length:0),void i.addRange(r)}const[o]=this.#ne(i,e),{parentElement:l}=s;return void this.#ae(t,i,l,l.getBoundingClientRect(),o)}const[h,c]=this.#ne(i,e),u=l.getBoundingClientRect();if(this.#te(u,h,c,e))this.#ae(t,i,l,u,h);else{for(;d();){const n=a.currentNode.parentElement,s=n.getBoundingClientRect();if(!this.#ee(u,s))break;if(this.#te(s,h,c,e))return void this.#ae(t,i,n,s,h)}this.#ae(t,i,l,u,h)}}}function _i(e,t){const i=document.createElement("a");if(!i.click)throw new Error('DownloadManager: "a.click()" is not supported.');i.href=e,i.target="_parent","download"in i&&(i.download=t),(document.body||document.documentElement).append(i),i.click(),i.remove()}class Ci{#le=new WeakMap;downloadData(e,t,i){_i(URL.createObjectURL(new Blob([e],{type:i})),t)}openOrDownloadData(e,t,i=null){const n=Se(t),s=n?"application/pdf":"";if(n){let n,r=this.#le.get(e);r||(r=URL.createObjectURL(new Blob([e],{type:s})),this.#le.set(e,r)),n="?file="+encodeURIComponent(r+"#"+t),i&&(n+=`#${escape(i)}`);try{return window.open(n),!0}catch(t){console.error(`openOrDownloadData: ${t}`),URL.revokeObjectURL(r),this.#le.delete(e)}}return this.downloadData(e,t,s),!1}download(e,t,i,n){let s;if(e)s=URL.createObjectURL(new Blob([e],{type:"application/pdf"}));else{if(!ce(t,"http://example.com"))return void console.error(`download - not a valid URL: ${t}`);s=t+"#pdfjs.action=download"}_i(s,i)}}class Si{#de=new WeakMap;#he=null;get active(){return this.#he}async register(e,t=!1){if("object"!=typeof e)throw new Error("Not enough parameters.");if(this.#de.has(e))throw new Error("The overlay is already registered.");this.#de.set(e,{canForceClose:t}),e.addEventListener("cancel",e=>{this.#he=null})}async open(e){if(!this.#de.has(e))throw new Error("The overlay does not exist.");if(this.#he){if(this.#he===e)throw new Error("The overlay is already active.");if(!this.#de.get(e).canForceClose)throw new Error("Another overlay is currently active.");await this.close()}this.#he=e,e.showModal()}async close(e=this.#he){if(!this.#de.has(e))throw new Error("The overlay does not exist.");if(!this.#he)throw new Error("The overlay is currently not active.");if(this.#he!==e)throw new Error("Another overlay is currently active.");e.close(),this.#he=null}}class Ei{#ce=null;#ue=null;#pe=null;constructor(e,t,i=!1){this.dialog=e.dialog,this.label=e.label,this.input=e.input,this.submitButton=e.submitButton,this.cancelButton=e.cancelButton,this.overlayManager=t,this._isViewerEmbedded=i,this.submitButton.addEventListener("click",this.#ge.bind(this)),this.cancelButton.addEventListener("click",this.close.bind(this)),this.input.addEventListener("keydown",e=>{13===e.keyCode&&this.#ge()}),this.overlayManager.register(this.dialog,!0),this.dialog.addEventListener("close",this.#fe.bind(this))}async open(){await(this.#ce?.promise),this.#ce=Promise.withResolvers();try{await this.overlayManager.open(this.dialog)}catch(e){throw this.#ce.resolve(),e}const e=this.#pe===Te.INCORRECT_PASSWORD;this._isViewerEmbedded&&!e||this.input.focus(),this.label.setAttribute("data-l10n-id","pdfjs-password-"+(e?"invalid":"label"))}async close(){this.overlayManager.active===this.dialog&&this.overlayManager.close(this.dialog)}#ge(){const e=this.input.value;e?.length>0&&this.#me(e)}#fe(){this.#me(new Error("PasswordPrompt cancelled.")),this.#ce.resolve()}#me(e){this.#ue&&(this.close(),this.input.value="",this.#ue(e),this.#ue=null)}async setUpdateCallback(e,t){this.#ce&&await this.#ce.promise,this.#ue=e,this.#pe=t}}const Li="selected";class Ii{constructor(e){if(this.constructor===Ii)throw new Error("Cannot initialize BaseTreeViewer.");this.container=e.container,this.eventBus=e.eventBus,this._l10n=e.l10n,this.reset()}reset(){this._pdfDocument=null,this._lastToggleIsShow=!0,this._currentTreeItem=null,this.container.textContent="",this.container.classList.remove("treeWithDeepNesting")}_dispatchEvent(e){throw new Error("Not implemented: _dispatchEvent")}_bindLink(e,t){throw new Error("Not implemented: _bindLink")}_normalizeTextContent(e){return I(e,!0)||"–"}_addToggleButton(e,t=!1){const i=document.createElement("div");i.className="treeItemToggler",t&&i.classList.add("treeItemsHidden"),i.onclick=t=>{if(t.stopPropagation(),i.classList.toggle("treeItemsHidden"),t.shiftKey){const t=!i.classList.contains("treeItemsHidden");this._toggleTreeItem(e,t)}},e.prepend(i)}_toggleTreeItem(e,t=!1){this._l10n.pause(),this._lastToggleIsShow=t;for(const i of e.querySelectorAll(".treeItemToggler"))i.classList.toggle("treeItemsHidden",!t);this._l10n.resume()}_toggleAllTreeItems(){this._toggleTreeItem(this.container,!this._lastToggleIsShow)}_finishRendering(e,t,i=!1){i&&(this.container.classList.add("treeWithDeepNesting"),this._lastToggleIsShow=!e.querySelector(".treeItemsHidden")),this._l10n.pause(),this.container.append(e),this._l10n.resume(),this._dispatchEvent(t)}render(e){throw new Error("Not implemented: render")}_updateCurrentTreeItem(e=null){this._currentTreeItem&&(this._currentTreeItem.classList.remove(Li),this._currentTreeItem=null),e&&(e.classList.add(Li),this._currentTreeItem=e)}_scrollToCurrentTreeItem(e){if(!e)return;this._l10n.pause();let t=e.parentNode;for(;t&&t!==this.container;){if(t.classList.contains("treeItem")){const e=t.firstElementChild;e?.classList.remove("treeItemsHidden")}t=t.parentNode}this._l10n.resume(),this._updateCurrentTreeItem(e),this.container.scrollTo(e.offsetLeft,e.offsetTop+-100)}}class xi extends Ii{constructor(e){super(e),this.downloadManager=e.downloadManager,this.eventBus._on("fileattachmentannotation",this.#be.bind(this))}reset(e=!1){super.reset(),this._attachments=null,e||(this._renderedCapability=Promise.withResolvers()),this._pendingDispatchEvent=!1}async _dispatchEvent(e){this._renderedCapability.resolve(),(0!==e||this._pendingDispatchEvent||(this._pendingDispatchEvent=!0,await Ke({target:this.eventBus,name:"annotationlayerrendered",delay:1e3}),this._pendingDispatchEvent))&&(this._pendingDispatchEvent=!1,this.eventBus.dispatch("attachmentsloaded",{source:this,attachmentsCount:e}))}_bindLink(e,{content:t,description:i,filename:n}){i&&(e.title=i),e.onclick=()=>(this.downloadManager.openOrDownloadData(t,n),!1)}render({attachments:e,keepRenderedCapability:t=!1}){if(this._attachments&&this.reset(t),this._attachments=e||null,!e)return void this._dispatchEvent(0);const i=document.createDocumentFragment();let n=0;for(const t in e){const s=e[t],r=document.createElement("div");r.className="treeItem";const a=document.createElement("a");this._bindLink(a,s),a.textContent=this._normalizeTextContent(s.filename),r.append(a),i.append(r),n++}this._finishRendering(i,n)}#be(e){const t=this._renderedCapability.promise;t.then(()=>{if(t!==this._renderedCapability.promise)return;const i=this._attachments||Object.create(null);for(const t in i)if(e.filename===t)return;i[e.filename]=e,this.render({attachments:i,keepRenderedCapability:!0})})}}const Mi="grab-to-pan-grab";class Ti{constructor({element:e}){this.element=e,this.document=e.ownerDocument,this.activate=this.activate.bind(this),this.deactivate=this.deactivate.bind(this),this.toggle=this.toggle.bind(this),this._onMouseDown=this.#ve.bind(this),this._onMouseMove=this.#we.bind(this),this._endPan=this.#ye.bind(this);(this.overlay=document.createElement("div")).className="grab-to-pan-grabbing"}activate(){this.active||(this.active=!0,this.element.addEventListener("mousedown",this._onMouseDown,!0),this.element.classList.add(Mi))}deactivate(){this.active&&(this.active=!1,this.element.removeEventListener("mousedown",this._onMouseDown,!0),this._endPan(),this.element.classList.remove(Mi))}toggle(){this.active?this.deactivate():this.activate()}ignoreTarget(e){return e.matches("a[href], a[href] *, input, textarea, button, button *, select, option")}#ve(e){if(0!==e.button||this.ignoreTarget(e.target))return;if(e.originalTarget)try{e.originalTarget.tagName}catch{return}this.scrollLeftStart=this.element.scrollLeft,this.scrollTopStart=this.element.scrollTop,this.clientXStart=e.clientX,this.clientYStart=e.clientY,this.document.addEventListener("mousemove",this._onMouseMove,!0),this.document.addEventListener("mouseup",this._endPan,!0),this.element.addEventListener("scroll",this._endPan,!0),e.preventDefault(),e.stopPropagation();const t=document.activeElement;t&&!t.contains(e.target)&&t.blur()}#we(e){if(this.element.removeEventListener("scroll",this._endPan,!0),!(1&e.buttons))return void this._endPan();const t=e.clientX-this.clientXStart,i=e.clientY-this.clientYStart;this.element.scrollTo({top:this.scrollTopStart-i,left:this.scrollLeftStart-t,behavior:"instant"}),this.overlay.parentNode||document.body.append(this.overlay)}#ye(){this.element.removeEventListener("scroll",this._endPan,!0),this.document.removeEventListener("mousemove",this._onMouseMove,!0),this.document.removeEventListener("mouseup",this._endPan,!0),this.overlay.remove()}}class ki{#he=w;#Pe=null;constructor({container:e,eventBus:t,cursorToolOnLoad:i=w}){this.container=e,this.eventBus=t,this.#_e(),Promise.resolve().then(()=>{this.switchTool(i)})}get activeTool(){return this.#he}switchTool(e){if(null!==this.#Pe)return;if(e===this.#he)return;const t=()=>{switch(this.#he){case w:break;case y:this._handTool.deactivate()}};switch(e){case w:t();break;case y:t(),this._handTool.activate();break;default:return void console.error(`switchTool: "${e}" is an unsupported value.`)}this.#he=e,this.eventBus.dispatch("cursortoolchanged",{source:this,tool:e})}#_e(){this.eventBus._on("switchcursortool",i=>{i.reset?null!==this.#Pe&&(e=se.NONE,t=r,n()):this.switchTool(i.tool)});let e=se.NONE,t=r;const i=()=>{const e=this.#he;this.switchTool(w),this.#Pe??=e},n=()=>{const i=this.#Pe;null!==i&&e===se.NONE&&t===r&&(this.#Pe=null,this.switchTool(i))};this.eventBus._on("annotationeditormodechanged",({mode:t})=>{e=t,t===se.NONE?n():i()}),this.eventBus._on("presentationmodechanged",({state:e})=>{t=e,e===r?n():e===o&&i()})}get _handTool(){return Re(this,"_handTool",new Ti({element:this.container}))}}const Ai=["en-us","en-lr","my"],Di={"8.5x11":"letter","8.5x14":"legal"},Bi={"297x420":"a-three","210x297":"a-four"};function Ni(e,t,i){return i[`${t?e.width:e.height}x${t?e.height:e.width}`]}class Oi{#Ce=null;constructor({dialog:e,fields:t,closeButton:i},n,s,r,a){this.dialog=e,this.fields=t,this.overlayManager=n,this.l10n=r,this._fileNameLookup=a,this.#Se(),i.addEventListener("click",this.close.bind(this)),this.overlayManager.register(this.dialog),s._on("pagechanging",e=>{this._currentPageNumber=e.pageNumber}),s._on("rotationchanging",e=>{this._pagesRotation=e.pagesRotation}),this._isNonMetricLocale=Ai.includes(r.getLanguage())}async open(){await Promise.all([this.overlayManager.open(this.dialog),this._dataAvailableCapability.promise]);const e=this._currentPageNumber,t=this._pagesRotation;if(this.#Ce&&e===this.#Ce._currentPageNumber&&t===this.#Ce._pagesRotation)return void this.#Ee();const{info:i,contentLength:n}=await this.pdfDocument.getMetadata(),[s,r,a,o,l,d]=await Promise.all([this._fileNameLookup(),this.#Le(n),this.#Ie(i.CreationDate),this.#Ie(i.ModDate),this.pdfDocument.getPage(e).then(e=>this.#xe(function({view:e,userUnit:t,rotate:i}){const[n,s,r,a]=e,o=i%180!=0,l=(r-n)/72*t,d=(a-s)/72*t;return{width:o?d:l,height:o?l:d}}(e),t)),this.#Me(i.IsLinearized)]);this.#Ce=Object.freeze({fileName:s,fileSize:r,title:i.Title,author:i.Author,subject:i.Subject,keywords:i.Keywords,creationDate:a,modificationDate:o,creator:i.Creator,producer:i.Producer,version:i.PDFFormatVersion,pageCount:this.pdfDocument.numPages,pageSize:l,linearized:d,_currentPageNumber:e,_pagesRotation:t}),this.#Ee();const{length:h}=await this.pdfDocument.getDownloadInfo();if(n===h)return;const c=Object.assign(Object.create(null),this.#Ce);c.fileSize=await this.#Le(h),this.#Ce=Object.freeze(c),this.#Ee()}async close(){this.overlayManager.close(this.dialog)}setDocument(e){this.pdfDocument&&(this.#Se(),this.#Ee(!0)),e&&(this.pdfDocument=e,this._dataAvailableCapability.resolve())}#Se(){this.pdfDocument=null,this.#Ce=null,this._dataAvailableCapability=Promise.withResolvers(),this._currentPageNumber=1,this._pagesRotation=0}#Ee(e=!1){if(!e&&this.#Ce){if(this.overlayManager.active===this.dialog)for(const e in this.fields){const t=this.#Ce[e];this.fields[e].textContent=t||0===t?t:"-"}}else for(const e in this.fields)this.fields[e].textContent="-"}async#Le(e=0){const t=e/1024,i=t/1024;if(t)return this.l10n.get("pdfjs-document-properties-"+(i>=1?"mb":"kb"),{size_mb:i>=1&&(+i.toPrecision(3)).toLocaleString(),size_kb:i<1&&(+t.toPrecision(3)).toLocaleString(),size_b:e.toLocaleString()})}async#xe(e,t){if(!e)return;t%180!=0&&(e={width:e.height,height:e.width});const i=O(e);let n={width:Math.round(100*e.width)/100,height:Math.round(100*e.height)/100},s={width:Math.round(25.4*e.width*10)/10,height:Math.round(25.4*e.height*10)/10},r=Ni(n,i,Di)||Ni(s,i,Bi);if(!(r||Number.isInteger(s.width)&&Number.isInteger(s.height))){const t={width:25.4*e.width,height:25.4*e.height},a={width:Math.round(s.width),height:Math.round(s.height)};Math.abs(t.width-a.width)<.1&&Math.abs(t.height-a.height)<.1&&(r=Ni(a,i,Bi),r&&(n={width:Math.round(a.width/25.4*100)/100,height:Math.round(a.height/25.4*100)/100},s=a))}const[{width:a,height:o},l,d,h]=await Promise.all([this._isNonMetricLocale?n:s,this.l10n.get("pdfjs-document-properties-page-size-unit-"+(this._isNonMetricLocale?"inches":"millimeters")),r&&this.l10n.get(`pdfjs-document-properties-page-size-name-${r}`),this.l10n.get("pdfjs-document-properties-page-size-orientation-"+(i?"portrait":"landscape"))]);return this.l10n.get(`pdfjs-document-properties-page-size-dimension-${d?"name-":""}string`,{width:a.toLocaleString(),height:o.toLocaleString(),unit:l,name:d,orientation:h})}async#Ie(e){const t=Ae.toDateObject(e);if(t)return this.l10n.get("pdfjs-document-properties-date-string",{date:t.toLocaleDateString(),time:t.toLocaleTimeString()})}#Me(e){return this.l10n.get("pdfjs-document-properties-linearized-"+(e?"yes":"no"))}}const Fi=0,Vi=1,Ri=2,ji=3,Hi=4,zi=5,Ui=6,$i=7;function Wi(e){return function(e){return e<11904}(e)?function(e){return!(65408&e)}(e)?function(e){return 32===e||9===e||13===e||10===e}(e)?Fi:function(e){return e>=97&&e<=122||e>=65&&e<=90}(e)||function(e){return e>=48&&e<=57}(e)||95===e?Vi:Ri:function(e){return 3584==(65408&e)}(e)?$i:160===e?Fi:Vi:function(e){return e>=13312&&e<=40959||e>=63744&&e<=64255}(e)?ji:function(e){return e>=12448&&e<=12543}(e)?Hi:function(e){return e>=12352&&e<=12447}(e)?zi:function(e){return e>=65376&&e<=65439}(e)?Ui:Vi}let Zi;const Xi=0,Gi=1,Ki=2,qi=3,Qi={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},Ji=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let Yi;const en=/\p{M}+/gu,tn=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,nn=/([^\p{M}])\p{M}*$/u,sn=/^\p{M}*([^\p{M}])/u,rn=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,an=new Map,on=new Map;let ln=null,dn=null;function hn(e){const t=[];let i,n;for(;null!==(i=rn.exec(e));){let{index:e}=i;for(const n of i[0]){let i=an.get(n);i||(i=n.normalize("NFD").length,an.set(n,i)),t.push([i,e++])}}if(0===t.length&&ln)n=ln;else if(t.length>0&&dn)n=dn;else{const e=`([${Object.keys(Qi).join("")}])|([${Zi||=" ¨ª¯²-µ¸-º¼-¾Ĳ-ĳĿ-ŀŉſǄ-ǌǱ-ǳʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕　〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ﬀ-ﬆﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ！-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ￠-￦",Zi}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n)|(\\n)`;n=0===t.length?ln=new RegExp(e+"|(\\u0000)","gum"):dn=new RegExp(e+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const s=[];for(;null!==(i=en.exec(e));)s.push([i[0].length,i.index]);let r=e.normalize("NFD");const a=[[0,0]];let o=0,l=0,d=0,h=0,c=0,u=!1;return r=r.replace(n,(e,i,n,r,p,g,f,m,b,v)=>{if(v-=h,i){const e=Qi[i],t=e.length;for(let e=1;e<t;e++)a.push([v-d+e,d-e]);return d-=t-1,e}if(n){let e=on.get(n);e||(e=n.normalize("NFKC"),on.set(n,e));const t=e.length;for(let e=1;e<t;e++)a.push([v-d+e,d-e]);return d-=t-1,e}if(r)return u=!0,v+c===s[o]?.[1]?++o:(a.push([v-1-d+1,d-1]),d-=1,h+=1),a.push([v-d+1,d]),h+=1,c+=1,r.charAt(0);if(p){const e=p.endsWith("\n"),t=e?p.length-2:p.length;u=!0;let i=t;v+c===s[o]?.[1]&&(i-=s[o][0],++o);for(let e=1;e<=i;e++)a.push([v-1-d+e,d-e]);return d-=i,h+=i,e?(v+=t-1,a.push([v-d+1,1+d]),d+=1,h+=1,c+=1,p.slice(0,t)):p}if(g){const e=g.length-2;return a.push([v-d+e,1+d]),d+=1,h+=1,c+=1,g.slice(0,-2)}if(f){const e=f.length-1;return a.push([v-d+e,d]),h+=1,c+=1,f.slice(0,-1)}if(m)return a.push([v-d+1,d-1]),d-=1,h+=1,c+=1," ";if(v+c===t[l]?.[1]){const e=t[l][0]-1;++l;for(let t=1;t<=e;t++)a.push([v-(d-t),d-t]);d-=e,h+=e}return b}),a.push([r.length,d]),[r,a,u]}function cn(e,t,i){if(!e)return[t,i];const n=t,s=t+i-1;let r=x(e,e=>e[0]>=n);e[r][0]>n&&--r;let a=x(e,e=>e[0]>=s,r);e[a][0]>s&&--a;const o=n+e[r][1];return[o,s+e[a][1]+1-o]}class un{#Te=null;#ke=!0;#Ae=0;constructor({linkService:e,eventBus:t,updateMatchesCountOnProgress:i=!0}){this._linkService=e,this._eventBus=t,this.#ke=i,this.onIsPageVisible=null,this.#Se(),t._on("find",this.#De.bind(this)),t._on("findbarclose",this.#Be.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#Te}setDocument(e){this._pdfDocument&&this.#Se(),e&&(this._pdfDocument=e,this._firstPageCapability.resolve())}#De(e){if(!e)return;const t=this._pdfDocument,{type:i}=e;(null===this.#Te||this.#Ne(e))&&(this._dirtyMatch=!0),this.#Te=e,"highlightallchange"!==i&&this.#S(qi),this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||t&&this._pdfDocument!==t)return;this.#Oe();const e=!this._highlightMatches,n=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#Fe():"again"===i?(this.#Fe(),e&&this.#Te.highlightAll&&this.#Ve()):"highlightallchange"===i?(n?this.#Fe():this._highlightMatches=!0,this.#Ve()):this.#Fe():this._findTimeout=setTimeout(()=>{this.#Fe(),this._findTimeout=null},250)})}scrollMatchIntoView({element:e=null,selectedLeft:t=0,pageIndex:i=-1,matchIndex:n=-1}){if(!this._scrollMatches||!e)return;if(-1===n||n!==this._selected.matchIdx)return;if(-1===i||i!==this._selected.pageIdx)return;this._scrollMatches=!1;C(e,{top:-50,left:t+-400},!0)}#Se(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#Ae=0,this.#Te=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this._firstPageCapability=Promise.withResolvers()}get#Re(){const{query:e}=this.#Te;return"string"==typeof e?(e!==this._rawQuery&&(this._rawQuery=e,[this._normalizedQuery]=hn(e)),this._normalizedQuery):(e||[]).filter(e=>!!e).map(e=>hn(e)[0])}#Ne(e){const t=e.query,i=this.#Te.query,n=typeof t;if(n!==typeof i)return!0;if("string"===n){if(t!==i)return!0}else if(JSON.stringify(t)!==JSON.stringify(i))return!0;switch(e.type){case"again":const e=this._selected.pageIdx+1,t=this._linkService;return e>=1&&e<=t.pagesCount&&e!==t.page&&!(this.onIsPageVisible?.(e)??1);case"highlightallchange":return!1}return!0}#je(e,t,i){let n=e.slice(0,t).match(nn);if(n){const i=e.charCodeAt(t),s=n[1].charCodeAt(0);if(Wi(i)===Wi(s))return!1}if(n=e.slice(t+i).match(sn),n){const s=e.charCodeAt(t+i-1),r=n[1].charCodeAt(0);if(Wi(s)===Wi(r))return!1}return!0}#He(e,t,i,n){const s=this._pageMatches[i]=[],r=this._pageMatchesLength[i]=[];if(!e)return;const a=this._pageDiffs[i];let o;for(;null!==(o=e.exec(n));){if(t&&!this.#je(n,o.index,o[0].length))continue;const[e,i]=cn(a,o.index,o[0].length);i&&(s.push(e),r.push(i))}}#ze(e,t){const{matchDiacritics:i}=this.#Te;let n=!1;const s="[ ]*";return(e=e.replaceAll(tn,(e,s,r,a,o,l)=>s?`[ ]*\\${s}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||l:o?Ji.has(o.charCodeAt(0))?o:"":t?(n=!0,`${l}\\p{M}*`):l)).endsWith(s)&&(e=e.slice(0,e.length-4)),i&&t&&(Yi||=String.fromCharCode(...Ji),n=!0,e=`${e}(?=[${Yi}]|[^\\p{M}]|$)`),[n,e]}#Ue(e){let t=this.#Re;if(0===t.length)return;const{caseSensitive:i,entireWord:n}=this.#Te,s=this._pageContents[e],r=this._hasDiacritics[e];let a=!1;"string"==typeof t?[a,t]=this.#ze(t,r):t=t.sort().reverse().map(e=>{const[t,i]=this.#ze(e,r);return a||=t,`(${i})`}).join("|");t=t?new RegExp(t,`g${a?"u":""}${i?"":"i"}`):null,this.#He(t,n,e,s),this.#Te.highlightAll&&this.#$e(e),this._resumePageIdx===e&&(this._resumePageIdx=null,this.#We());const o=this._pageMatches[e].length;this._matchesCountTotal+=o,this.#ke?o>0&&this.#Ze():++this.#Ae===this._linkService.pagesCount&&this.#Ze()}#Oe(){if(this._extractTextPromises.length>0)return;let e=Promise.resolve();const t={disableNormalization:!0};for(let i=0,n=this._linkService.pagesCount;i<n;i++){const{promise:n,resolve:s}=Promise.withResolvers();this._extractTextPromises[i]=n,e=e.then(()=>this._pdfDocument.getPage(i+1).then(e=>e.getTextContent(t)).then(e=>{const t=[];for(const i of e.items)t.push(i.str),i.hasEOL&&t.push("\n");[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=hn(t.join("")),s()},e=>{console.error(`Unable to get text content for page ${i+1}`,e),this._pageContents[i]="",this._pageDiffs[i]=null,this._hasDiacritics[i]=!1,s()}))}}#$e(e){this._scrollMatches&&this._selected.pageIdx===e&&(this._linkService.page=e+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:e})}#Ve(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#Fe(){const e=this.#Te.findPrevious,t=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=t,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#Ae=0,this._matchesCountTotal=0,this.#Ve();for(let e=0;e<i;e++)this._pendingFindMatches.has(e)||(this._pendingFindMatches.add(e),this._extractTextPromises[e].then(()=>{this._pendingFindMatches.delete(e),this.#Ue(e)}))}if(0===this.#Re.length)return void this.#S(Xi);if(this._resumePageIdx)return;const n=this._offset;if(this._pagesToSearch=i,null!==n.matchIdx){const t=this._pageMatches[n.pageIdx].length;if(!e&&n.matchIdx+1<t||e&&n.matchIdx>0)return n.matchIdx=e?n.matchIdx-1:n.matchIdx+1,void this.#Xe(!0);this.#Ge(e)}this.#We()}#Ke(e){const t=this._offset,i=e.length,n=this.#Te.findPrevious;return i?(t.matchIdx=n?i-1:0,this.#Xe(!0),!0):(this.#Ge(n),!!(t.wrapped&&(t.matchIdx=null,this._pagesToSearch<0))&&(this.#Xe(!1),!0))}#We(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let e=null;do{const t=this._offset.pageIdx;if(e=this._pageMatches[t],!e){this._resumePageIdx=t;break}}while(!this.#Ke(e))}#Ge(e){const t=this._offset,i=this._linkService.pagesCount;t.pageIdx=e?t.pageIdx-1:t.pageIdx+1,t.matchIdx=null,this._pagesToSearch--,(t.pageIdx>=i||t.pageIdx<0)&&(t.pageIdx=e?i-1:0,t.wrapped=!0)}#Xe(e=!1){let t=Gi;const i=this._offset.wrapped;if(this._offset.wrapped=!1,e){const e=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,t=i?Ki:Xi,-1!==e&&e!==this._selected.pageIdx&&this.#$e(e)}this.#S(t,this.#Te.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#$e(this._selected.pageIdx))}#Be(e){const t=this._pdfDocument;this._firstPageCapability.promise.then(()=>{!this._pdfDocument||t&&this._pdfDocument!==t||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#S(Xi),this._highlightMatches=!1,this.#Ve())})}#qe(){const{pageIdx:e,matchIdx:t}=this._selected;let i=0,n=this._matchesCountTotal;if(-1!==t){for(let t=0;t<e;t++)i+=this._pageMatches[t]?.length||0;i+=t+1}return(i<1||i>n)&&(i=n=0),{current:i,total:n}}#Ze(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#qe()})}#S(e,t=!1){(this.#ke||this.#Ae===this._linkService.pagesCount&&e!==qi)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:e,previous:t,entireWord:this.#Te?.entireWord??null,matchesCount:this.#qe(),rawQuery:this.#Te?.query??null})}}class pn{#Qe=new ResizeObserver(this.#Je.bind(this));constructor(e,t){this.opened=!1,this.bar=e.bar,this.toggleButton=e.toggleButton,this.findField=e.findField,this.highlightAll=e.highlightAllCheckbox,this.caseSensitive=e.caseSensitiveCheckbox,this.matchDiacritics=e.matchDiacriticsCheckbox,this.entireWord=e.entireWordCheckbox,this.findMsg=e.findMsg,this.findResultsCount=e.findResultsCount,this.findPreviousButton=e.findPreviousButton,this.findNextButton=e.findNextButton,this.eventBus=t,this.toggleButton.addEventListener("click",()=>{this.toggle()}),this.findField.addEventListener("input",()=>{this.dispatchEvent("")}),this.bar.addEventListener("keydown",e=>{switch(e.keyCode){case 13:e.target===this.findField&&this.dispatchEvent("again",e.shiftKey);break;case 27:this.close()}}),this.findPreviousButton.addEventListener("click",()=>{this.dispatchEvent("again",!0)}),this.findNextButton.addEventListener("click",()=>{this.dispatchEvent("again",!1)}),this.highlightAll.addEventListener("click",()=>{this.dispatchEvent("highlightallchange")}),this.caseSensitive.addEventListener("click",()=>{this.dispatchEvent("casesensitivitychange")}),this.entireWord.addEventListener("click",()=>{this.dispatchEvent("entirewordchange")}),this.matchDiacritics.addEventListener("click",()=>{this.dispatchEvent("diacriticmatchingchange")})}reset(){this.updateUIState()}dispatchEvent(e,t=!1){this.eventBus.dispatch("find",{source:this,type:e,query:this.findField.value,caseSensitive:this.caseSensitive.checked,entireWord:this.entireWord.checked,highlightAll:this.highlightAll.checked,findPrevious:t,matchDiacritics:this.matchDiacritics.checked})}updateUIState(e,t,i){const{findField:n,findMsg:s}=this;let r="",a="";switch(e){case Xi:break;case qi:a="pending";break;case Gi:r="pdfjs-find-not-found",a="notFound";break;case Ki:r="pdfjs-find-reached-"+(t?"top":"bottom")}n.setAttribute("data-status",a),n.setAttribute("aria-invalid",e===Gi),s.setAttribute("data-status",a),r?s.setAttribute("data-l10n-id",r):(s.removeAttribute("data-l10n-id"),s.textContent=""),this.updateResultsCount(i)}updateResultsCount({current:e=0,total:t=0}={}){const{findResultsCount:i}=this;if(t>0){const n=1e3;i.setAttribute("data-l10n-id","pdfjs-find-match-count"+(t>n?"-limit":"")),i.setAttribute("data-l10n-args",JSON.stringify({limit:n,current:e,total:t}))}else i.removeAttribute("data-l10n-id"),i.textContent=""}open(){this.opened||(this.#Qe.observe(this.bar.parentNode),this.#Qe.observe(this.bar),this.opened=!0,z(this.toggleButton,!0,this.bar)),this.findField.select(),this.findField.focus()}close(){this.opened&&(this.#Qe.disconnect(),this.opened=!1,z(this.toggleButton,!1,this.bar),this.eventBus.dispatch("findbarclose",{source:this}))}toggle(){this.opened?this.close():this.open()}#Je(e){const{bar:t}=this;t.classList.remove("wrapContainers");t.clientHeight>t.firstElementChild.clientHeight&&t.classList.add("wrapContainers")}}function gn(){return document.location.hash}class fn{#Ye=null;constructor({linkService:e,eventBus:t}){this.linkService=e,this.eventBus=t,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",e=>{this._isPagesLoaded=!!e.pagesCount},{once:!0})})}initialize({fingerprint:e,resetHistory:t=!1,updateUrl:i=!1}){if(!e||"string"!=typeof e)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');this._initialized&&this.reset();const n=""!==this._fingerprint&&this._fingerprint!==e;this._fingerprint=e,this._updateUrl=!0===i,this._initialized=!0,this.#et();const s=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=gn(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#tt(s,!0)||t){const{hash:e,page:i,rotation:s}=this.#it(!0);return!e||n||t?void this.#nt(null,!0):void this.#nt({hash:e,page:i,rotation:s},!0)}const r=s.destination;this.#st(r,s.uid,!0),void 0!==r.rotation&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#rt(),this._initialized=!1,this.#at()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:e=null,explicitDest:t,pageNumber:i}){if(!this._initialized)return;if(e&&"string"!=typeof e)return void console.error(`PDFHistory.push: "${e}" is not a valid namedDest parameter.`);if(!Array.isArray(t))return void console.error(`PDFHistory.push: "${t}" is not a valid explicitDest parameter.`);if(!this.#ot(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const n=e||JSON.stringify(t);if(!n)return;let s=!1;if(this._destination&&(function(e,t){if("string"!=typeof e||"string"!=typeof t)return!1;if(e===t)return!0;if(E(e).get("nameddest")===t)return!0;return!1}(this._destination.hash,n)||function(e,t){function i(e,t){if(typeof e!=typeof t)return!1;if(Array.isArray(e)||Array.isArray(t))return!1;if(null!==e&&"object"==typeof e&&null!==t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(!i(e[n],t[n]))return!1;return!0}return e===t||Number.isNaN(e)&&Number.isNaN(t)}if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let n=0,s=e.length;n<s;n++)if(!i(e[n],t[n]))return!1;return!0}(this._destination.dest,t))){if(this._destination.page)return;s=!0}this._popStateInProgress&&!s||(this.#nt({dest:t,hash:n,page:i,rotation:this.linkService.rotation},s),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1})))}pushPage(e){this._initialized&&(this.#ot(e)?this._destination?.page!==e&&(this._popStateInProgress||(this.#nt({dest:null,hash:`page=${e}`,page:e,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1})))):console.error(`PDFHistory.pushPage: "${e}" is not a valid page number.`))}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&this.#lt()}back(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;this.#tt(e)&&e.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;this.#tt(e)&&e.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#nt(e,t=!1){const i=t||!this._destination,n={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:e};let s;if(this.#st(e,n.uid),this._updateUrl&&e?.hash){const t=document.location.href.split("#",1)[0];t.startsWith("file://")||(s=`${t}#${e.hash}`)}i?window.history.replaceState(n,"",s):window.history.pushState(n,"",s)}#lt(e=!1){if(!this._position)return;let t=this._position;if(e&&(t=Object.assign(Object.create(null),this._position),t.temporary=!0),!this._destination)return void this.#nt(t);if(this._destination.temporary)return void this.#nt(t,!0);if(this._destination.hash===t.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=t.first&&this._destination.page<=t.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this.#nt(t,i)}#ot(e){return Number.isInteger(e)&&e>0&&e<=this.linkService.pagesCount}#tt(e,t=!1){if(!e)return!1;if(e.fingerprint!==this._fingerprint){if(!t)return!1;{if("string"!=typeof e.fingerprint||e.fingerprint.length!==this._fingerprint.length)return!1;const[t]=performance.getEntriesByType("navigation");if("reload"!==t?.type)return!1}}return!(!Number.isInteger(e.uid)||e.uid<0)&&(null!==e.destination&&"object"==typeof e.destination)}#st(e,t,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&e?.temporary&&delete e.temporary,this._destination=e,this._uid=t,this._maxUid=Math.max(this._maxUid,t),this._numPositionUpdates=0}#it(e=!1){const t=unescape(gn()).substring(1),i=E(t),n=i.get("nameddest")||"";let s=0|i.get("page");return(!this.#ot(s)||e&&n.length>0)&&(s=null),{hash:t,page:s,rotation:this.linkService.rotation}}#dt({location:e}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:e.pdfOpenParams.substring(1),page:this.linkService.page,first:e.pageNumber,rotation:e.rotation},this._popStateInProgress||(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout(()=>{this._popStateInProgress||this.#lt(!0),this._updateViewareaTimeout=null},1e3))}#ht({state:e}){const t=gn(),i=this._currentHash!==t;if(this._currentHash=t,!e){this._uid++;const{hash:e,page:t,rotation:i}=this.#it();return void this.#nt({hash:e,page:t,rotation:i},!0)}if(!this.#tt(e))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,Ke({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--}));const n=e.destination;this.#st(n,e.uid,!0),D(n.rotation)&&(this.linkService.rotation=n.rotation),n.dest?this.linkService.goToDestination(n.dest):n.hash?this.linkService.setHash(n.hash):n.page&&(this.linkService.page=n.page),Promise.resolve().then(()=>{this._popStateInProgress=!1})}#rt(){this._destination&&!this._destination.temporary||this.#lt()}#et(){if(this.#Ye)return;this.#Ye=new AbortController;const{signal:e}=this.#Ye;this.eventBus._on("updateviewarea",this.#dt.bind(this),{signal:e}),window.addEventListener("popstate",this.#ht.bind(this),{signal:e}),window.addEventListener("pagehide",this.#rt.bind(this),{signal:e})}#at(){this.#Ye?.abort(),this.#Ye=null}}class mn extends Ii{constructor(e){super(e),this.eventBus._on("optionalcontentconfigchanged",e=>{this.#ct(e.promise)}),this.eventBus._on("resetlayers",()=>{this.#ct()}),this.eventBus._on("togglelayerstree",this._toggleAllTreeItems.bind(this))}reset(){super.reset(),this._optionalContentConfig=null,this._optionalContentHash=null}_dispatchEvent(e){this.eventBus.dispatch("layersloaded",{source:this,layersCount:e})}_bindLink(e,{groupId:t,input:i}){const n=()=>{this._optionalContentConfig.setVisibility(t,i.checked),this._optionalContentHash=this._optionalContentConfig.getHash(),this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(this._optionalContentConfig)})};e.onclick=t=>t.target===i?(n(),!0):t.target!==e||(i.checked=!i.checked,n(),!1)}async _setNestedName(e,{name:t=null}){"string"!=typeof t?(e.textContent=await this._l10n.get("pdfjs-additional-layers"),e.style.fontStyle="italic"):e.textContent=this._normalizeTextContent(t)}_addToggleButton(e,{name:t=null}){super._addToggleButton(e,null===t)}_toggleAllTreeItems(){this._optionalContentConfig&&super._toggleAllTreeItems()}render({optionalContentConfig:e,pdfDocument:t}){this._optionalContentConfig&&this.reset(),this._optionalContentConfig=e||null,this._pdfDocument=t||null;const i=e?.getOrder();if(!i)return void this._dispatchEvent(0);this._optionalContentHash=e.getHash();const n=document.createDocumentFragment(),s=[{parent:n,groups:i}];let r=0,a=!1;for(;s.length>0;){const t=s.shift();for(const i of t.groups){const n=document.createElement("div");n.className="treeItem";const o=document.createElement("a");if(n.append(o),"object"==typeof i){a=!0,this._addToggleButton(n,i),this._setNestedName(o,i);const e=document.createElement("div");e.className="treeItems",n.append(e),s.push({parent:e,groups:i.order})}else{const t=e.getGroup(i),n=document.createElement("input");this._bindLink(o,{groupId:i,input:n}),n.type="checkbox",n.checked=t.visible;const s=document.createElement("label");s.textContent=this._normalizeTextContent(t.name),s.append(n),o.append(s),r++}t.parent.append(n)}}this._finishRendering(n,r,a)}async#ct(e=null){if(!this._optionalContentConfig)return;const t=this._pdfDocument,i=await(e||t.getOptionalContentConfig({intent:"display"}));if(t===this._pdfDocument){if(e){if(i.getHash()===this._optionalContentHash)return}else this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(i)});this.render({optionalContentConfig:i,pdfDocument:this._pdfDocument})}}}class bn extends Ii{constructor(e){super(e),this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.eventBus._on("toggleoutlinetree",this._toggleAllTreeItems.bind(this)),this.eventBus._on("currentoutlineitem",this._currentOutlineItem.bind(this)),this.eventBus._on("pagechanging",e=>{this._currentPageNumber=e.pageNumber}),this.eventBus._on("pagesloaded",e=>{this._isPagesLoaded=!!e.pagesCount,this._currentOutlineItemCapability?.resolve(this._isPagesLoaded)}),this.eventBus._on("sidebarviewchanged",e=>{this._sidebarView=e.view})}reset(){super.reset(),this._outline=null,this._pageNumberToDestHashCapability=null,this._currentPageNumber=1,this._isPagesLoaded=null,this._currentOutlineItemCapability?.resolve(!1),this._currentOutlineItemCapability=null}_dispatchEvent(e){this._currentOutlineItemCapability=Promise.withResolvers(),0===e||this._pdfDocument?.loadingParams.disableAutoFetch?this._currentOutlineItemCapability.resolve(!1):null!==this._isPagesLoaded&&this._currentOutlineItemCapability.resolve(this._isPagesLoaded),this.eventBus.dispatch("outlineloaded",{source:this,outlineCount:e,currentOutlineItemPromise:this._currentOutlineItemCapability.promise})}_bindLink(e,{url:t,newWindow:i,action:n,attachment:s,dest:r,setOCGState:a}){const{linkService:o}=this;if(t)o.addLinkAttributes(e,t,i);else{if(n)return e.href=o.getAnchorUrl(""),void(e.onclick=()=>(o.executeNamedAction(n),!1));if(s)return e.href=o.getAnchorUrl(""),void(e.onclick=()=>(this.downloadManager.openOrDownloadData(s.content,s.filename),!1));if(a)return e.href=o.getAnchorUrl(""),void(e.onclick=()=>(o.executeSetOCGState(a),!1));e.href=o.getDestinationHash(r),e.onclick=e=>(this._updateCurrentTreeItem(e.target.parentNode),r&&o.goToDestination(r),!1)}}_setStyles(e,{bold:t,italic:i}){t&&(e.style.fontWeight="bold"),i&&(e.style.fontStyle="italic")}_addToggleButton(e,{count:t,items:i}){let n=!1;if(t<0){let e=i.length;if(e>0){const t=[...i];for(;t.length>0;){const{count:i,items:n}=t.shift();i>0&&n.length>0&&(e+=n.length,t.push(...n))}}Math.abs(t)===e&&(n=!0)}super._addToggleButton(e,n)}_toggleAllTreeItems(){this._outline&&super._toggleAllTreeItems()}render({outline:e,pdfDocument:t}){if(this._outline&&this.reset(),this._outline=e||null,this._pdfDocument=t||null,!e)return void this._dispatchEvent(0);const i=document.createDocumentFragment(),n=[{parent:i,items:e}];let s=0,r=!1;for(;n.length>0;){const e=n.shift();for(const t of e.items){const i=document.createElement("div");i.className="treeItem";const a=document.createElement("a");if(this._bindLink(a,t),this._setStyles(a,t),a.textContent=this._normalizeTextContent(t.title),i.append(a),t.items.length>0){r=!0,this._addToggleButton(i,t);const e=document.createElement("div");e.className="treeItems",i.append(e),n.push({parent:e,items:t.items})}e.parent.append(i),s++}}this._finishRendering(i,s,r)}async _currentOutlineItem(){if(!this._isPagesLoaded)throw new Error("_currentOutlineItem: All pages have not been loaded.");if(!this._outline||!this._pdfDocument)return;const e=await this._getPageNumberToDestHash(this._pdfDocument);if(e&&(this._updateCurrentTreeItem(null),this._sidebarView===c))for(let t=this._currentPageNumber;t>0;t--){const i=e.get(t);if(!i)continue;const n=this.container.querySelector(`a[href="${i}"]`);if(n){this._scrollToCurrentTreeItem(n.parentNode);break}}}async _getPageNumberToDestHash(e){if(this._pageNumberToDestHashCapability)return this._pageNumberToDestHashCapability.promise;this._pageNumberToDestHashCapability=Promise.withResolvers();const t=new Map,i=new Map,n=[{nesting:0,items:this._outline}];for(;n.length>0;){const s=n.shift(),r=s.nesting;for(const{dest:a,items:o}of s.items){let s,l;if("string"==typeof a){if(s=await e.getDestination(a),e!==this._pdfDocument)return null}else s=a;if(Array.isArray(s)){const[n]=s;if(n&&"object"==typeof n?l=e.cachedPageNumber(n):Number.isInteger(n)&&(l=n+1),Number.isInteger(l)&&(!t.has(l)||r>i.get(l))){const e=this.linkService.getDestinationHash(a);t.set(l,e),i.set(l,r)}}o.length>0&&n.push({nesting:r+1,items:o})}}return this._pageNumberToDestHashCapability.resolve(t.size>0?t:null),this._pageNumberToDestHashCapability.promise}}const vn="pdfPresentationMode",wn="pdfPresentationModeControls",yn=Math.PI/6;class Pn{#Te=s;#ut=null;#pt=null;#gt=null;constructor({container:e,pdfViewer:t,eventBus:i}){this.container=e,this.pdfViewer=t,this.eventBus=i,this.contextMenuOpen=!1,this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0,this.touchSwipeState=null}async request(){const{container:e,pdfViewer:t}=this;if(this.active||!t.pagesCount||!e.requestFullscreen)return!1;this.#ft(),this.#mt(a);const i=e.requestFullscreen();this.#ut={pageNumber:t.currentPageNumber,scaleValue:t.currentScaleValue,scrollMode:t.scrollMode,spreadMode:null,annotationEditorMode:null},t.spreadMode===v.NONE||t.pageViewsReady&&t.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),this.#ut.spreadMode=t.spreadMode),t.annotationEditorMode!==se.DISABLE&&(this.#ut.annotationEditorMode=t.annotationEditorMode);try{return await i,t.focus(),!0}catch{this.#bt(),this.#mt(r)}return!1}get active(){return this.#Te===a||this.#Te===o}#vt(e){if(!this.active)return;e.preventDefault();const t=function(e){const t=e.deltaMode;let i=A(e);return t===WheelEvent.DOM_DELTA_PIXEL?i/=900:t===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}(e),i=Date.now(),n=this.mouseScrollTimeStamp;if(!(i>n&&i-n<50)&&((this.mouseScrollDelta>0&&t<0||this.mouseScrollDelta<0&&t>0)&&this.#wt(),this.mouseScrollDelta+=t,Math.abs(this.mouseScrollDelta)>=.1)){const e=this.mouseScrollDelta;this.#wt();(e>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}}#mt(e){this.#Te=e,this.eventBus.dispatch("presentationmodechanged",{source:this,state:e})}#yt(){this.#mt(o),this.container.classList.add(vn),setTimeout(()=>{this.pdfViewer.scrollMode=b.PAGE,null!==this.#ut.spreadMode&&(this.pdfViewer.spreadMode=v.NONE),this.pdfViewer.currentPageNumber=this.#ut.pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==this.#ut.annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:se.NONE})},0),this.#Pt(),this.#_t(),this.contextMenuOpen=!1,document.getSelection().empty()}#Ct(){const e=this.pdfViewer.currentPageNumber;this.container.classList.remove(vn),setTimeout(()=>{this.#bt(),this.#mt(r),this.pdfViewer.scrollMode=this.#ut.scrollMode,null!==this.#ut.spreadMode&&(this.pdfViewer.spreadMode=this.#ut.spreadMode),this.pdfViewer.currentScaleValue=this.#ut.scaleValue,this.pdfViewer.currentPageNumber=e,null!==this.#ut.annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:this.#ut.annotationEditorMode}),this.#ut=null},0),this.#St(),this.#Et(),this.#wt(),this.contextMenuOpen=!1}#Lt(e){if(this.contextMenuOpen)return this.contextMenuOpen=!1,void e.preventDefault();0===e.button&&(e.target.href&&e.target.parentNode?.hasAttribute("data-internal-link")||(e.preventDefault(),e.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()))}#It(){this.contextMenuOpen=!0}#_t(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(wn),this.controlsTimeout=setTimeout(()=>{this.container.classList.remove(wn),delete this.controlsTimeout},3e3)}#Et(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(wn),delete this.controlsTimeout)}#wt(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0}#xt(e){if(this.active)if(e.touches.length>1)this.touchSwipeState=null;else switch(e.type){case"touchstart":this.touchSwipeState={startX:e.touches[0].pageX,startY:e.touches[0].pageY,endX:e.touches[0].pageX,endY:e.touches[0].pageY};break;case"touchmove":if(null===this.touchSwipeState)return;this.touchSwipeState.endX=e.touches[0].pageX,this.touchSwipeState.endY=e.touches[0].pageY,e.preventDefault();break;case"touchend":if(null===this.touchSwipeState)return;let t=0;const i=this.touchSwipeState.endX-this.touchSwipeState.startX,n=this.touchSwipeState.endY-this.touchSwipeState.startY,s=Math.abs(Math.atan2(n,i));Math.abs(i)>50&&(s<=yn||s>=Math.PI-yn)?t=i:Math.abs(n)>50&&Math.abs(s-Math.PI/2)<=yn&&(t=n),t>0?this.pdfViewer.previousPage():t<0&&this.pdfViewer.nextPage()}}#Pt(){if(this.#gt)return;this.#gt=new AbortController;const{signal:e}=this.#gt,t=this.#xt.bind(this);window.addEventListener("mousemove",this.#_t.bind(this),{signal:e}),window.addEventListener("mousedown",this.#Lt.bind(this),{signal:e}),window.addEventListener("wheel",this.#vt.bind(this),{passive:!1,signal:e}),window.addEventListener("keydown",this.#wt.bind(this),{signal:e}),window.addEventListener("contextmenu",this.#It.bind(this),{signal:e}),window.addEventListener("touchstart",t,{signal:e}),window.addEventListener("touchmove",t,{signal:e}),window.addEventListener("touchend",t,{signal:e})}#St(){this.#gt?.abort(),this.#gt=null}#ft(){this.#pt||(this.#pt=new AbortController,window.addEventListener("fullscreenchange",()=>{document.fullscreenElement?this.#yt():this.#Ct()},{signal:this.#pt.signal}))}#bt(){this.#pt?.abort(),this.#pt=null}}class _n{constructor({pdfPage:e,annotationStorage:t=null,linkService:i,xfaHtml:n=null}){this.pdfPage=e,this.annotationStorage=t,this.linkService=i,this.xfaHtml=n,this.div=null,this._cancelled=!1}async render(e,t="display"){if("print"===t){const i={viewport:e.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:t};return this.div=document.createElement("div"),i.div=this.div,Ze.render(i)}const i=await this.pdfPage.getXfa();if(this._cancelled||!i)return{textDivs:[]};const n={viewport:e.clone({dontFlip:!0}),div:this.div,xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:t};return this.div?Ze.update(n):(this.div=document.createElement("div"),n.div=this.div,Ze.render(n))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}let Cn=null,Sn=null,En=null,Ln={initialized:!1};class In{constructor({pdfDocument:e,pagesOverview:t,printContainer:i,printResolution:n,printAnnotationStoragePromise:s=null}){this.pdfDocument=e,this.pagesOverview=t,this.printContainer=i,this._printResolution=n||150,this._optionalContentConfigPromise=e.getOptionalContentConfig({intent:"print"}),this._printAnnotationStoragePromise=s||Promise.resolve(),this.currentPage=-1,this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const e=document.querySelector("body");e.setAttribute("data-pdfjsprinting",!0);const{width:t,height:i}=this.pagesOverview[0];this.pagesOverview.every(e=>e.width===t&&e.height===i)||console.warn("Not all pages have the same size. The printed result may be incorrect!"),this.pageStyleSheet=document.createElement("style"),this.pageStyleSheet.textContent=`@page { size: ${t}pt ${i}pt;}`,e.append(this.pageStyleSheet)}destroy(){if(Cn!==this)return;this.printContainer.textContent="";document.querySelector("body").removeAttribute("data-pdfjsprinting"),this.pageStyleSheet&&(this.pageStyleSheet.remove(),this.pageStyleSheet=null),this.scratchCanvas.width=this.scratchCanvas.height=0,this.scratchCanvas=null,Cn=null,Dn().then(function(){En.active===Sn&&En.close(Sn)})}renderPages(){if(this.pdfDocument.isPureXfa)return function(e,t){const i=t.allXfaHtml,n=new ee,s=Math.round(100*Ne.PDF_TO_CSS_UNITS)/100;for(const r of i.children){const i=document.createElement("div");i.className="xfaPrintedPage",e.append(i);const a=new _n({pdfPage:null,annotationStorage:t.annotationStorage,linkService:n,xfaHtml:r}),o=we(r,{scale:s});a.render(o,"print"),i.append(a.div)}}(this.printContainer,this.pdfDocument),Promise.resolve();const e=this.pagesOverview.length,t=(i,n)=>{if(this.throwIfInactive(),++this.currentPage>=e)return kn(e,e),void i();const s=this.currentPage;kn(s,e),function(e,t,i,n,s,r,a){const o=Cn.scratchCanvas,l=s/Ne.PDF;o.width=Math.floor(n.width*l),o.height=Math.floor(n.height*l);const d=o.getContext("2d");return d.save(),d.fillStyle="rgb(255, 255, 255)",d.fillRect(0,0,o.width,o.height),d.restore(),Promise.all([t.getPage(i),a]).then(function([e,t]){const i={canvasContext:d,transform:[l,0,0,l,0,0],viewport:e.getViewport({scale:1,rotation:n.rotation}),intent:"print",annotationMode:oe.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:t};return e.render(i).promise.catch(e=>{throw e instanceof Oe||console.error(e),e})})}(0,this.pdfDocument,s+1,this.pagesOverview[s],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function(){t(i,n)},n)};return new Promise(t)}useRenderedPage(){this.throwIfInactive();const e=document.createElement("img"),t=this.scratchCanvas;"toBlob"in t?t.toBlob(function(t){e.src=URL.createObjectURL(t)}):e.src=t.toDataURL();const i=document.createElement("div");return i.className="printedPage",i.append(e),this.printContainer.append(i),new Promise(function(t,i){e.onload=t,e.onerror=i})}performPrint(){return this.throwIfInactive(),new Promise(e=>{setTimeout(()=>{this.active?(xn.call(window),setTimeout(e,20)):e()},0)})}get active(){return this===Cn}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const xn=window.print;function Mn(e){const t=new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:"custom"});window.dispatchEvent(t)}function Tn(){Cn&&(Cn.destroy(),Mn("afterprint"))}function kn(e,t){Sn||=document.getElementById("printServiceDialog");const i=Math.round(100*e/t),n=Sn.querySelector("progress"),s=Sn.querySelector(".relative-progress");n.value=i,s.setAttribute("data-l10n-args",JSON.stringify({progress:i}))}if(window.print=function(){if(Cn)console.warn("Ignored window.print() because of a pending print job.");else{Dn().then(function(){Cn&&En.open(Sn)});try{Mn("beforeprint")}finally{if(!Cn)return console.error("Expected print service to be initialized."),void Dn().then(function(){En.active===Sn&&En.close(Sn)});const e=Cn;Cn.renderPages().then(function(){return e.performPrint()}).catch(function(){}).then(function(){e.active&&Tn()})}}},window.addEventListener("keydown",function(e){80!==e.keyCode||!e.ctrlKey&&!e.metaKey||e.altKey||e.shiftKey&&!window.chrome&&!window.opera||(window.print(),e.preventDefault(),e.stopImmediatePropagation())},!0),"onbeforeprint"in window){const e=function(e){"custom"!==e.detail&&e.stopImmediatePropagation()};window.addEventListener("beforeprint",e),window.addEventListener("afterprint",e)}let An;function Dn(){if(!An){if(En=Ln.overlayManager,!En)throw new Error("The overlay manager has not yet been initialized.");Sn||=document.getElementById("printServiceDialog"),An=En.register(Sn,!0),document.getElementById("printCancel").onclick=Tn,Sn.addEventListener("close",Tn)}return An}class Bn{static initGlobals(e){Ln=e}static get supportsPrinting(){return Re(this,"supportsPrinting",!0)}static createPrintService(e){if(Cn)throw new Error("The print service is created and active.");return Cn=new In(e)}}class Nn{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(e){this.pdfViewer=e}setThumbnailViewer(e){this.pdfThumbnailViewer=e}isHighestPriority(e){return this.highestPriorityPage===e.renderingId}renderHighestPriority(e){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(e)||this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(e,t,i,n=!1){const s=e.views,r=s.length;if(0===r)return null;for(let e=0;e<r;e++){const t=s[e].view;if(!this.isViewFinished(t))return t}const a=e.first.id,o=e.last.id;if(o-a+1>r){const n=e.ids;for(let e=1,s=o-a;e<s;e++){const s=i?a+e:o-e;if(n.has(s))continue;const r=t[s-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,d=t[l];return d&&!this.isViewFinished(d)||n&&(l+=i?1:-1,d=t[l],d&&!this.isViewFinished(d))?d:null}isViewFinished(e){return e.renderingState===n.FINISHED}renderView(e){switch(e.renderingState){case n.FINISHED:return!1;case n.PAUSED:this.highestPriorityPage=e.renderingId,e.resume();break;case n.RUNNING:this.highestPriorityPage=e.renderingId;break;case n.INITIAL:this.highestPriorityPage=e.renderingId,e.draw().finally(()=>{this.renderHighestPriority()}).catch(e=>{e instanceof Oe||console.error(`renderView: "${e}"`)})}return!0}}class On{#Mt=null;#Tt=null;#kt=null;#Ye=null;#A=null;#At=null;#Dt=null;#Bt=null;#Nt=!1;#Ot=null;#Ft=null;constructor({eventBus:e,externalServices:t=null,docProperties:i=null}){this.#A=e,this.#At=t,this.#kt=i}setViewer(e){this.#Bt=e}async setDocument(e){if(this.#Dt&&await this.#Vt(),this.#Dt=e,!e)return;const[t,i,n]=await Promise.all([e.getFieldObjects(),e.getCalculationOrderIds(),e.getJSActions()]);if(!t&&!n)return void await this.#Vt();if(e!==this.#Dt)return;try{this.#Ot=this.#Rt()}catch(e){return console.error(`setDocument: "${e.message}".`),void await this.#Vt()}const s=this.#A;this.#Ye=new AbortController;const{signal:r}=this.#Ye;s._on("updatefromsandbox",e=>{e?.source===window&&this.#jt(e.detail)},{signal:r}),s._on("dispatcheventinsandbox",e=>{this.#Ot?.dispatchEventInSandbox(e.detail)},{signal:r}),s._on("pagechanging",({pageNumber:e,previous:t})=>{e!==t&&(this.#Ht(t),this.#zt(e))},{signal:r}),s._on("pagerendered",({pageNumber:e})=>{this._pageOpenPending.has(e)&&e===this.#Bt.currentPageNumber&&this.#zt(e)},{signal:r}),s._on("pagesdestroy",async()=>{await this.#Ht(this.#Bt.currentPageNumber),await(this.#Ot?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#Mt?.resolve()},{signal:r});try{const r=await this.#kt(e);if(e!==this.#Dt)return;await this.#Ot.createSandbox({objects:t,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...r,actions:n}}),s.dispatch("sandboxcreated",{source:this})}catch(e){return console.error(`setDocument: "${e.message}".`),void await this.#Vt()}await(this.#Ot?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#zt(this.#Bt.currentPageNumber,!0),Promise.resolve().then(()=>{e===this.#Dt&&(this.#Nt=!0)})}async dispatchWillSave(){return this.#Ot?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Ot?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Ot){await(this.#Ft?.promise),this.#Ft=Promise.withResolvers();try{await this.#Ot.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(e){throw this.#Ft.resolve(),this.#Ft=null,e}await this.#Ft.promise}}async dispatchDidPrint(){return this.#Ot?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#Tt?.promise||null}get ready(){return this.#Nt}get _pageOpenPending(){return Re(this,"_pageOpenPending",new Set)}get _visitedPages(){return Re(this,"_visitedPages",new Map)}async#jt(e){const t=this.#Bt,i=t.isInPresentationMode||t.isChangingPresentationMode,{id:n,siblings:s,command:r,value:a}=e;if(!n){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":if(!i){const e=j(a);t.spreadMode=e.spreadMode}break;case"page-num":t.currentPageNumber=a+1;break;case"print":await t.pagesPromise,this.#A.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(t.currentScaleValue=a);break;case"SaveAs":this.#A.dispatch("download",{source:this});break;case"FirstPage":t.currentPageNumber=1;break;case"LastPage":t.currentPageNumber=t.pagesCount;break;case"NextPage":t.nextPage();break;case"PrevPage":t.previousPage();break;case"ZoomViewIn":i||t.increaseScale();break;case"ZoomViewOut":i||t.decreaseScale();break;case"WillPrintFinished":this.#Ft?.resolve(),this.#Ft=null}return}if(i&&e.focus)return;delete e.id,delete e.siblings;const o=s?[n,...s]:[n];for(const t of o){const i=document.querySelector(`[data-element-id="${t}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:e})):this.#Dt?.annotationStorage.setValue(t,e)}}async#zt(e,t=!1){const i=this.#Dt,s=this._visitedPages;if(t&&(this.#Mt=Promise.withResolvers()),!this.#Mt)return;const r=this.#Bt.getPageView(e-1);if(r?.renderingState!==n.FINISHED)return void this._pageOpenPending.add(e);this._pageOpenPending.delete(e);const a=(async()=>{const t=await(s.has(e)?null:r.pdfPage?.getJSActions());i===this.#Dt&&await(this.#Ot?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:e,actions:t}))})();s.set(e,a)}async#Ht(e){const t=this.#Dt,i=this._visitedPages;if(!this.#Mt)return;if(this._pageOpenPending.has(e))return;const n=i.get(e);n&&(i.set(e,null),await n,t===this.#Dt&&await(this.#Ot?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:e})))}#Rt(){if(this.#Tt=Promise.withResolvers(),this.#Ot)throw new Error("#initScripting: Scripting already exists.");return this.#At.createScripting()}async#Vt(){if(!this.#Ot)return this.#Dt=null,void this.#Tt?.resolve();this.#Mt&&(await Promise.race([this.#Mt.promise,new Promise(e=>{setTimeout(e,1e3)})]).catch(()=>{}),this.#Mt=null),this.#Dt=null;try{await this.#Ot.destroySandbox()}catch{}this.#Ft?.reject(new Error("Scripting destroyed.")),this.#Ft=null,this.#Ye?.abort(),this.#Ye=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Ot=null,this.#Nt=!1,this.#Tt?.resolve()}}const Fn="sidebarResizing",Vn="pdfSidebarNotification";class Rn{#b=!1;#Ut=this.#$t.bind(this);#Wt=this.#Zt.bind(this);#Xt=null;#Gt=null;constructor({elements:e,eventBus:t,l10n:i}){this.isOpen=!1,this.active=h,this.isInitialViewSet=!1,this.isInitialEventDispatched=!1,this.onToggled=null,this.onUpdateThumbnails=null,this.outerContainer=e.outerContainer,this.sidebarContainer=e.sidebarContainer,this.toggleButton=e.toggleButton,this.resizer=e.resizer,this.thumbnailButton=e.thumbnailButton,this.outlineButton=e.outlineButton,this.attachmentsButton=e.attachmentsButton,this.layersButton=e.layersButton,this.thumbnailView=e.thumbnailView,this.outlineView=e.outlineView,this.attachmentsView=e.attachmentsView,this.layersView=e.layersView,this._currentOutlineItemButton=e.currentOutlineItemButton,this.eventBus=t,this.#b="rtl"===i.getDirection(),this.#_e()}reset(){this.isInitialViewSet=!1,this.isInitialEventDispatched=!1,this.#Kt(!0),this.switchView(h),this.outlineButton.disabled=!1,this.attachmentsButton.disabled=!1,this.layersButton.disabled=!1,this._currentOutlineItemButton.disabled=!0}get visibleView(){return this.isOpen?this.active:d}setInitialView(e=d){this.isInitialViewSet||(this.isInitialViewSet=!0,e!==d&&e!==l?(this.switchView(e,!0),this.isInitialEventDispatched||this.#qt()):this.#qt())}switchView(e,t=!1){const i=e!==this.active;let n=!1;switch(e){case d:return void(this.isOpen&&this.close());case h:this.isOpen&&i&&(n=!0);break;case c:if(this.outlineButton.disabled)return;break;case u:if(this.attachmentsButton.disabled)return;break;case p:if(this.layersButton.disabled)return;break;default:return void console.error(`PDFSidebar.switchView: "${e}" is not a valid view.`)}this.active=e,H(this.thumbnailButton,e===h,this.thumbnailView),H(this.outlineButton,e===c,this.outlineView),H(this.attachmentsButton,e===u,this.attachmentsView),H(this.layersButton,e===p,this.layersView),!t||this.isOpen?(n&&(this.onUpdateThumbnails(),this.onToggled()),i&&this.#qt()):this.open()}open(){this.isOpen||(this.isOpen=!0,z(this.toggleButton,!0),this.outerContainer.classList.add("sidebarMoving","sidebarOpen"),this.active===h&&this.onUpdateThumbnails(),this.onToggled(),this.#qt(),this.#Kt())}close(e=null){this.isOpen&&(this.isOpen=!1,z(this.toggleButton,!1),this.outerContainer.classList.add("sidebarMoving"),this.outerContainer.classList.remove("sidebarOpen"),this.onToggled(),this.#qt(),e?.detail>0&&this.toggleButton.blur())}toggle(e=null){this.isOpen?this.close(e):this.open()}#qt(){this.isInitialViewSet&&(this.isInitialEventDispatched||=!0),this.eventBus.dispatch("sidebarviewchanged",{source:this,view:this.visibleView})}#Qt(){this.toggleButton.setAttribute("data-l10n-id","pdfjs-toggle-sidebar-notification-button"),this.isOpen||this.toggleButton.classList.add(Vn)}#Kt(e=!1){(this.isOpen||e)&&this.toggleButton.classList.remove(Vn),e&&this.toggleButton.setAttribute("data-l10n-id","pdfjs-toggle-sidebar-button")}#_e(){this.sidebarContainer.addEventListener("transitionend",e=>{e.target===this.sidebarContainer&&(this.outerContainer.classList.remove("sidebarMoving"),this.eventBus.dispatch("resize",{source:this}))}),this.toggleButton.addEventListener("click",e=>{this.toggle(e)}),this.thumbnailButton.addEventListener("click",()=>{this.switchView(h)}),this.outlineButton.addEventListener("click",()=>{this.switchView(c)}),this.outlineButton.addEventListener("dblclick",()=>{this.eventBus.dispatch("toggleoutlinetree",{source:this})}),this.attachmentsButton.addEventListener("click",()=>{this.switchView(u)}),this.layersButton.addEventListener("click",()=>{this.switchView(p)}),this.layersButton.addEventListener("dblclick",()=>{this.eventBus.dispatch("resetlayers",{source:this})}),this._currentOutlineItemButton.addEventListener("click",()=>{this.eventBus.dispatch("currentoutlineitem",{source:this})});const e=(e,t,i)=>{t.disabled=!e,e?this.#Qt():this.active===i&&this.switchView(h)};this.eventBus._on("outlineloaded",t=>{e(t.outlineCount,this.outlineButton,c),t.currentOutlineItemPromise.then(e=>{this.isInitialViewSet&&(this._currentOutlineItemButton.disabled=!e)})}),this.eventBus._on("attachmentsloaded",t=>{e(t.attachmentsCount,this.attachmentsButton,u)}),this.eventBus._on("layersloaded",t=>{e(t.layersCount,this.layersButton,p)}),this.eventBus._on("presentationmodechanged",e=>{e.state===r&&this.visibleView===h&&this.onUpdateThumbnails()}),this.resizer.addEventListener("mousedown",e=>{0===e.button&&(this.outerContainer.classList.add(Fn),window.addEventListener("mousemove",this.#Ut),window.addEventListener("mouseup",this.#Wt))}),this.eventBus._on("resize",e=>{if(e.source!==window)return;if(this.#Xt=null,!this.#Gt)return;if(!this.isOpen)return void this.#Jt(this.#Gt);this.outerContainer.classList.add(Fn);const t=this.#Jt(this.#Gt);Promise.resolve().then(()=>{this.outerContainer.classList.remove(Fn),t&&this.eventBus.dispatch("resize",{source:this})})})}get outerContainerWidth(){return this.#Xt||=this.outerContainer.clientWidth}#Jt(e=0){const t=Math.floor(this.outerContainerWidth/2);return e>t&&(e=t),e<200&&(e=200),e!==this.#Gt&&(this.#Gt=e,V.setProperty("--sidebar-width",`${e}px`),!0)}#$t(e){let t=e.clientX;this.#b&&(t=this.outerContainerWidth-t),this.#Jt(t)}#Zt(e){this.outerContainer.classList.remove(Fn),this.eventBus.dispatch("resize",{source:this}),window.removeEventListener("mousemove",this.#Ut),window.removeEventListener("mouseup",this.#Wt)}}class jn{static#Yt=null;static getCanvas(e,t){const i=this.#Yt||=document.createElement("canvas");i.width=e,i.height=t;const n=i.getContext("2d",{alpha:!1});return n.save(),n.fillStyle="rgb(255, 255, 255)",n.fillRect(0,0,e,t),n.restore(),[i,i.getContext("2d")]}static destroyCanvas(){const e=this.#Yt;e&&(e.width=0,e.height=0),this.#Yt=null}}class Hn{constructor({container:e,eventBus:t,id:i,defaultViewport:s,optionalContentConfigPromise:r,linkService:a,renderingQueue:o,pageColors:l,enableHWA:d}){this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.pdfPage=null,this.rotation=0,this.viewport=s,this.pdfPageRotate=s.rotation,this._optionalContentConfigPromise=r||null,this.pageColors=l||null,this.enableHWA=d||!1,this.eventBus=t,this.linkService=a,this.renderingQueue=o,this.renderTask=null,this.renderingState=n.INITIAL,this.resume=null;const h=document.createElement("a");h.href=a.getAnchorUrl("#page="+i),h.setAttribute("data-l10n-id","pdfjs-thumb-page-title"),h.setAttribute("data-l10n-args",this.#ei),h.onclick=function(){return a.goToPage(i),!1},this.anchor=h;const c=document.createElement("div");c.className="thumbnail",c.setAttribute("data-page-number",this.id),this.div=c,this.#ti();const u=document.createElement("div");u.className="thumbnailImage",this._placeholderImg=u,c.append(u),h.append(c),e.append(h)}#ti(){const{width:e,height:t}=this.viewport,i=e/t;this.canvasWidth=98,this.canvasHeight=this.canvasWidth/i|0,this.scale=this.canvasWidth/e;const{style:n}=this.div;n.setProperty("--thumbnail-width",`${this.canvasWidth}px`),n.setProperty("--thumbnail-height",`${this.canvasHeight}px`)}setPdfPage(e){this.pdfPage=e,this.pdfPageRotate=e.rotate;const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:1,rotation:t}),this.reset()}reset(){this.cancelRendering(),this.renderingState=n.INITIAL,this.div.removeAttribute("data-loaded"),this.image?.replaceWith(this._placeholderImg),this.#ti(),this.image&&(this.image.removeAttribute("src"),delete this.image)}update({rotation:e=null}){"number"==typeof e&&(this.rotation=e);const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:1,rotation:t}),this.reset()}cancelRendering(){this.renderTask&&(this.renderTask.cancel(),this.renderTask=null),this.resume=null}#ii(e=1,t=this.enableHWA){const i=document.createElement("canvas"),n=i.getContext("2d",{alpha:!1,willReadFrequently:!t}),s=new _;i.width=e*this.canvasWidth*s.sx|0,i.height=e*this.canvasHeight*s.sy|0;return{ctx:n,canvas:i,transform:s.scaled?[s.sx,0,0,s.sy,0,0]:null}}#ni(e){if(this.renderingState!==n.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const t=this.#si(e),i=document.createElement("img");i.className="thumbnailImage",i.setAttribute("data-l10n-id","pdfjs-thumb-page-canvas"),i.setAttribute("data-l10n-args",this.#ei),i.src=t.toDataURL(),this.image=i,this.div.setAttribute("data-loaded",!0),this._placeholderImg.replaceWith(i),t.width=0,t.height=0}async#ri(e,t,i=null){if(e===this.renderTask&&(this.renderTask=null),!(i instanceof Oe)&&(this.renderingState=n.FINISHED,this.#ni(t),i))throw i}async draw(){if(this.renderingState!==n.INITIAL)return void console.error("Must be in new state before drawing");const{pdfPage:e}=this;if(!e)throw this.renderingState=n.FINISHED,new Error("pdfPage is not loaded");this.renderingState=n.RUNNING;const{ctx:t,canvas:i,transform:s}=this.#ii(2),r={canvasContext:t,transform:s,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},a=this.renderTask=e.render(r);a.onContinue=e=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=n.PAUSED,void(this.resume=()=>{this.renderingState=n.RUNNING,e()});e()};const o=a.promise.then(()=>this.#ri(a,i),e=>this.#ri(a,i,e));return o.finally(()=>{i.width=0,i.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})}),o}setImage(e){if(this.renderingState!==n.INITIAL)return;const{thumbnailCanvas:t,pdfPage:i,scale:s}=e;t&&(this.pdfPage||this.setPdfPage(i),s<this.scale||(this.renderingState=n.FINISHED,this.#ni(t)))}#si(e){const{ctx:t,canvas:i}=this.#ii(1,!0);if(e.width<=2*i.width)return t.drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),i;let n=i.width<<3,s=i.height<<3;const[r,a]=jn.getCanvas(n,s);for(;n>e.width||s>e.height;)n>>=1,s>>=1;for(a.drawImage(e,0,0,e.width,e.height,0,0,n,s);n>2*i.width;)a.drawImage(r,0,0,n,s,0,0,n>>1,s>>1),n>>=1,s>>=1;return t.drawImage(r,0,0,n,s,0,0,i.width,i.height),i}get#ei(){return JSON.stringify({page:this.pageLabel??this.id})}setPageLabel(e){this.pageLabel="string"==typeof e?e:null,this.anchor.setAttribute("data-l10n-args",this.#ei),this.renderingState===n.FINISHED&&this.image?.setAttribute("data-l10n-args",this.#ei)}}const zn="selected";class Un{constructor({container:e,eventBus:t,linkService:i,renderingQueue:n,pageColors:s,abortSignal:r,enableHWA:a}){this.container=e,this.eventBus=t,this.linkService=i,this.renderingQueue=n,this.pageColors=s||null,this.enableHWA=a||!1,this.scroll=S(this.container,this.#ai.bind(this),r),this.#oi()}#ai(){this.renderingQueue.renderHighestPriority()}getThumbnail(e){return this._thumbnails[e]}#li(){return k({scrollEl:this.container,views:this._thumbnails})}scrollThumbnailIntoView(e){if(!this.pdfDocument)return;const t=this._thumbnails[e-1];if(!t)return void console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');if(e!==this._currentPageNumber){this._thumbnails[this._currentPageNumber-1].div.classList.remove(zn),t.div.classList.add(zn)}const{first:i,last:n,views:s}=this.#li();if(s.length>0){let r=!1;if(e<=i.id||e>=n.id)r=!0;else for(const{id:t,percent:i}of s)if(t===e){r=i<100;break}r&&C(t.div,{top:-19})}this._currentPageNumber=e}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!D(e))throw new Error("Invalid thumbnails rotation angle.");if(!this.pdfDocument)return;if(this._pagesRotation===e)return;this._pagesRotation=e;const t={rotation:e};for(const e of this._thumbnails)e.update(t)}cleanup(){for(const e of this._thumbnails)e.renderingState!==n.FINISHED&&e.reset();jn.destroyCanvas()}#oi(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""}setDocument(e){if(this.pdfDocument&&(this.#di(),this.#oi()),this.pdfDocument=e,!e)return;const t=e.getPage(1),i=e.getOptionalContentConfig({intent:"display"});t.then(t=>{const n=e.numPages,s=t.getViewport({scale:1});for(let e=1;e<=n;++e){const t=new Hn({container:this.container,eventBus:this.eventBus,id:e,defaultViewport:s.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,pageColors:this.pageColors,enableHWA:this.enableHWA});this._thumbnails.push(t)}this._thumbnails[0]?.setPdfPage(t);this._thumbnails[this._currentPageNumber-1].div.classList.add(zn)}).catch(e=>{console.error("Unable to initialize thumbnail viewer",e)})}#di(){for(const e of this._thumbnails)e.cancelRendering()}setPageLabels(e){if(this.pdfDocument){e?Array.isArray(e)&&this.pdfDocument.numPages===e.length?this._pageLabels=e:(this._pageLabels=null,console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let e=0,t=this._thumbnails.length;e<t;e++)this._thumbnails[e].setPageLabel(this._pageLabels?.[e]??null)}}async#hi(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);return e.pdfPage||e.setPdfPage(t),t}catch(e){return console.error("Unable to get page for thumb view",e),null}}#ci(e){return 1===e.first?.id||e.last?.id!==this._thumbnails.length&&this.scroll.down}forceRendering(){const e=this.#li(),t=this.#ci(e),i=this.renderingQueue.getHighestPriority(e,this._thumbnails,t);return!!i&&(this.#hi(i).then(()=>{this.renderingQueue.renderView(i)}),!0)}}class $n{#ui=null;#pi=null;#gi=null;#fi=null;#R;constructor(e){this.pdfPage=e.pdfPage,this.accessibilityManager=e.accessibilityManager,this.l10n=e.l10n,this.l10n||=new pi,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#R=e.uiManager,this.#ui=e.annotationLayer||null,this.#fi=e.textLayer||null,this.#pi=e.drawLayer||null,this.#gi=e.onAppend||null}async render(e,t="display"){if("display"!==t)return;if(this._cancelled)return;const i=e.clone({dontFlip:!0});if(this.div)return this.annotationEditorLayer.update({viewport:i}),void this.show();const n=this.div=document.createElement("div");n.className="annotationEditorLayer",n.hidden=!0,n.dir=this.#R.direction,this.#gi?.(n),this.annotationEditorLayer=new ie({uiManager:this.#R,div:n,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#ui,textLayer:this.#fi,drawLayer:this.#pi});const s={viewport:i,div:n,annotations:null,intent:t};this.annotationEditorLayer.render(s),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1)}}class Wn{#gi=null;#Ye=null;constructor({pdfPage:e,linkService:t,downloadManager:i,annotationStorage:n=null,imageResourcesPath:s="",renderForms:r=!0,enableScripting:a=!1,hasJSActionsPromise:o=null,fieldObjectsPromise:l=null,annotationCanvasMap:d=null,accessibilityManager:h=null,annotationEditorUIManager:c=null,onAppend:u=null}){this.pdfPage=e,this.linkService=t,this.downloadManager=i,this.imageResourcesPath=s,this.renderForms=r,this.annotationStorage=n,this.enableScripting=a,this._hasJSActionsPromise=o||Promise.resolve(!1),this._fieldObjectsPromise=l||Promise.resolve(null),this._annotationCanvasMap=d,this._accessibilityManager=h,this._annotationEditorUIManager=c,this.#gi=u,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=t.eventBus}async render(e,t="display"){if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:e.clone({dontFlip:!0})})}const[i,n,s]=await Promise.all([this.pdfPage.getAnnotations({intent:t}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const r=this.div=document.createElement("div");r.className="annotationLayer",this.#gi?.(r),0!==i.length?(this.annotationLayer=new ae({div:r,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:e.clone({dontFlip:!0})}),await this.annotationLayer.render({annotations:i,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,linkService:this.linkService,downloadManager:this.downloadManager,annotationStorage:this.annotationStorage,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:s}),this.linkService.isInPresentationMode&&this.#mi(o),this.#Ye||(this.#Ye=new AbortController,this._eventBus?._on("presentationmodechanged",e=>{this.#mi(e.state)},{signal:this.#Ye.signal}))):this.hide()}cancel(){this._cancelled=!0,this.#Ye?.abort(),this.#Ye=null}hide(){this.div&&(this.div.hidden=!0)}#mi(e){if(!this.div)return;let t=!1;switch(e){case o:t=!0;break;case r:break;default:return}for(const e of this.div.childNodes)e.hasAttribute("data-internal-link")||(e.inert=t)}}class Zn{#pi=null;constructor(e){this.pageIndex=e.pageIndex}async render(e="display"){"display"!==e||this.#pi||this._cancelled||(this.#pi=new pe({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#pi&&(this.#pi.destroy(),this.#pi=null)}setParent(e){this.#pi?.setParent(e)}getDrawLayer(){return this.#pi}}const Xn={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},Gn=/^H(\d+)$/;class Kn{#bi=void 0;get renderingDone(){return void 0!==this.#bi}render(e){if(void 0!==this.#bi)return this.#bi;const t=this.#vi(e);return t?.classList.add("structTree"),this.#bi=t}hide(){this.#bi&&!this.#bi.hidden&&(this.#bi.hidden=!0)}show(){this.#bi?.hidden&&(this.#bi.hidden=!1)}#wi(e,t){const{alt:i,id:n,lang:s}=e;void 0!==i&&t.setAttribute("aria-label",I(i)),void 0!==n&&t.setAttribute("aria-owns",n),void 0!==s&&t.setAttribute("lang",I(s,!0))}#vi(e){if(!e)return null;const t=document.createElement("span");if("role"in e){const{role:i}=e,n=i.match(Gn);n?(t.setAttribute("role","heading"),t.setAttribute("aria-level",n[1])):Xn[i]&&t.setAttribute("role",Xn[i])}if(this.#wi(e,t),e.children)if(1===e.children.length&&"id"in e.children[0])this.#wi(e.children[0],t);else for(const i of e.children)t.append(this.#vi(i));return t}}class qn{#yi=!1;#Pi=null;#_i=new Map;#Ci=new Map;setTextMapping(e){this.#Pi=e}static#Si(e,t){const i=e.getBoundingClientRect(),n=t.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===n.width&&0===n.height)return-1;const s=i.y,r=i.y+i.height,a=i.y+i.height/2,o=n.y,l=n.y+n.height,d=n.y+n.height/2;if(a<=o&&d>=r)return-1;if(d<=s&&a>=l)return 1;return i.x+i.width/2-(n.x+n.width/2)}enable(){if(this.#yi)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Pi)throw new Error("Text divs and strings have not been set.");if(this.#yi=!0,this.#Pi=this.#Pi.slice(),this.#Pi.sort(qn.#Si),this.#_i.size>0){const e=this.#Pi;for(const[t,i]of this.#_i){document.getElementById(t)?this.#Ei(t,e[i]):this.#_i.delete(t)}}for(const[e,t]of this.#Ci)this.addPointerInTextLayer(e,t);this.#Ci.clear()}disable(){this.#yi&&(this.#Ci.clear(),this.#Pi=null,this.#yi=!1)}removePointerInTextLayer(e){if(!this.#yi)return void this.#Ci.delete(e);const t=this.#Pi;if(!t||0===t.length)return;const{id:i}=e,n=this.#_i.get(i);if(void 0===n)return;const s=t[n];this.#_i.delete(i);let r=s.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter(e=>e!==i).join(" "),r?s.setAttribute("aria-owns",r):(s.removeAttribute("aria-owns"),s.setAttribute("role","presentation")))}#Ei(e,t){const i=t.getAttribute("aria-owns");i?.includes(e)||t.setAttribute("aria-owns",i?`${i} ${e}`:e),t.removeAttribute("role")}addPointerInTextLayer(e,t){const{id:i}=e;if(!i)return null;if(!this.#yi)return this.#Ci.set(e,t),null;t&&this.removePointerInTextLayer(e);const n=this.#Pi;if(!n||0===n.length)return null;const s=x(n,t=>qn.#Si(e,t)<0),r=Math.max(0,s-1),a=n[r];this.#Ei(i,a),this.#_i.set(i,r);const o=a.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(e,t,i,n){const s=this.addPointerInTextLayer(i,n);if(!e.hasChildNodes())return e.append(t),s;const r=Array.from(e.childNodes).filter(e=>e!==t);if(0===r.length)return s;const a=i||t,o=x(r,e=>qn.#Si(a,e)<0);return 0===o?r[0].before(t):r[o-1].after(t),s}}class Qn{#Ye=null;constructor({findController:e,eventBus:t,pageIndex:i}){this.findController=e,this.matches=[],this.eventBus=t,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(e,t){this.textDivs=e,this.textContentItemsStr=t}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0,this.#Ye||(this.#Ye=new AbortController,this.eventBus._on("updatetextlayermatches",e=>{e.pageIndex!==this.pageIdx&&-1!==e.pageIndex||this._updateMatches()},{signal:this.#Ye.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#Ye?.abort(),this.#Ye=null,this._updateMatches(!0))}_convertMatches(e,t){if(!e)return[];const{textContentItemsStr:i}=this;let n=0,s=0;const r=i.length-1,a=[];for(let o=0,l=e.length;o<l;o++){let l=e[o];for(;n!==r&&l>=s+i[n].length;)s+=i[n].length,n++;n===i.length&&console.error("Could not find a matching mapping");const d={begin:{divIdx:n,offset:l-s}};for(l+=t[o];n!==r&&l>s+i[n].length;)s+=i[n].length,n++;d.end={divIdx:n,offset:l-s},a.push(d)}return a}_renderMatches(e){if(0===e.length)return;const{findController:t,pageIdx:i}=this,{textContentItemsStr:n,textDivs:s}=this,r=i===t.selected.pageIdx,a=t.selected.matchIdx;let o=null;const l={divIdx:-1,offset:void 0};function d(e,t){const i=e.divIdx;return s[i].textContent="",h(i,0,e.offset,t)}function h(e,t,i,r){let a=s[e];if(a.nodeType===Node.TEXT_NODE){const t=document.createElement("span");a.before(t),t.append(a),s[e]=t,a=t}const o=n[e].substring(t,i),l=document.createTextNode(o);if(r){const e=document.createElement("span");return e.className=`${r} appended`,e.append(l),a.append(e),r.includes("selected")?e.offsetLeft:0}return a.append(l),0}let c=a,u=c+1;if(t.state.highlightAll)c=0,u=e.length;else if(!r)return;let p=-1,g=-1;for(let n=c;n<u;n++){const c=e[n],u=c.begin;if(u.divIdx===p&&u.offset===g)continue;p=u.divIdx,g=u.offset;const f=c.end,m=r&&n===a,b=m?" selected":"";let v=0;if(o&&u.divIdx===o.divIdx?h(o.divIdx,o.offset,u.offset):(null!==o&&h(o.divIdx,o.offset,l.offset),d(u)),u.divIdx===f.divIdx)v=h(u.divIdx,u.offset,f.offset,"highlight"+b);else{v=h(u.divIdx,u.offset,l.offset,"highlight begin"+b);for(let e=u.divIdx+1,t=f.divIdx;e<t;e++)s[e].className="highlight middle"+b;d(f,"highlight end"+b)}o=f,m&&t.scrollMatchIntoView({element:s[u.divIdx],selectedLeft:v,pageIndex:i,matchIndex:a})}o&&h(o.divIdx,o.offset,l.offset)}_updateMatches(e=!1){if(!this.enabled&&!e)return;const{findController:t,matches:i,pageIdx:n}=this,{textContentItemsStr:s,textDivs:r}=this;let a=-1;for(const e of i){for(let t=Math.max(a,e.begin.divIdx),i=e.end.divIdx;t<=i;t++){const e=r[t];e.textContent=s[t],e.className=""}a=e.end.divIdx+1}if(!t?.highlightMatches||e)return;const o=t.pageMatches[n]||null,l=t.pageMatchesLength[n]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class Jn{#Li=!1;#gi=null;#Ii=!1;#fi=null;static#xi=new Map;static#Mi=null;constructor({pdfPage:e,highlighter:t=null,accessibilityManager:i=null,enablePermissions:n=!1,onAppend:s=null}){this.pdfPage=e,this.highlighter=t,this.accessibilityManager=i,this.#Li=!0===n,this.#gi=s,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render(e,t=null){if(this.#Ii&&this.#fi)return this.#fi.update({viewport:e,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#fi=new je({textContentSource:this.pdfPage.streamTextContent(t||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:e});const{textDivs:i,textContentItemsStr:n}=this.#fi;this.highlighter?.setTextMapping(i,n),this.accessibilityManager?.setTextMapping(i),await this.#fi.render(),this.#Ii=!0;const s=document.createElement("div");s.className="endOfContent",this.div.append(s),this.#Ti(s),this.#gi?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#Ii&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#Ii&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#fi?.cancel(),this.#fi=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),Jn.#ki(this.div)}#Ti(e){const{div:t}=this;t.addEventListener("mousedown",t=>{e.classList.add("active")}),t.addEventListener("copy",e=>{if(!this.#Li){const t=document.getSelection();e.clipboardData.setData("text/plain",I(Ie(t.toString())))}e.preventDefault(),e.stopPropagation()}),Jn.#xi.set(t,e),Jn.#Ai()}static#ki(e){this.#xi.delete(e),0===this.#xi.size&&(this.#Mi?.abort(),this.#Mi=null)}static#Ai(){if(this.#Mi)return;this.#Mi=new AbortController;const{signal:e}=this.#Mi,t=(e,t)=>{t.append(e),e.style.width="",e.style.height="",e.classList.remove("active")};var i,n;document.addEventListener("pointerup",()=>{this.#xi.forEach(t)},{signal:e}),document.addEventListener("selectionchange",()=>{const e=document.getSelection();if(0===e.rangeCount)return void this.#xi.forEach(t);const s=new Set;for(let t=0;t<e.rangeCount;t++){const i=e.getRangeAt(t);for(const e of this.#xi.keys())!s.has(e)&&i.intersectsNode(e)&&s.add(e)}for(const[e,i]of this.#xi)s.has(e)?i.classList.add("active"):t(i,e);if(i??="none"===getComputedStyle(this.#xi.values().next().value).getPropertyValue("-moz-user-select"),i)return;const r=e.getRangeAt(0),a=n&&(0===r.compareBoundaryPoints(Range.END_TO_END,n)||0===r.compareBoundaryPoints(Range.START_TO_END,n));let o=a?r.startContainer:r.endContainer;o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);const l=o.parentElement.closest(".textLayer"),d=this.#xi.get(l);d&&(d.style.width=l.style.width,d.style.height=l.style.height,o.parentElement.insertBefore(d,a?o:o.nextSibling)),n=r.cloneRange()},{signal:e})}}const Yn=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class es{#Di=oe.ENABLE_FORMS;#Bi=!1;#Ni=!1;#Oi=null;#Fi=null;#Vi=null;#Ri=null;#ji=n.INITIAL;#Hi=f;#zi={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#Ui=new WeakMap;#$i=[null,null,null,null];constructor(e){const t=e.container,i=e.defaultViewport;this.id=e.id,this.renderingId="page"+this.id,this.#Oi=e.layerProperties||null,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=e.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=e.optionalContentConfigPromise||null,this.#Hi=e.textLayerMode??f,this.#Di=e.annotationMode??oe.ENABLE_FORMS,this.imageResourcesPath=e.imageResourcesPath||"",this.maxCanvasPixels=e.maxCanvasPixels??Q.get("maxCanvasPixels"),this.pageColors=e.pageColors||null,this.#Bi=e.enableHWA||!1,this.eventBus=e.eventBus,this.renderingQueue=e.renderingQueue,this.l10n=e.l10n,this.l10n||=new pi,this.renderTask=null,this.resume=null,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=t,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.zoomLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null;const n=document.createElement("div");if(n.className="page",n.setAttribute("data-page-number",this.id),n.setAttribute("role","region"),n.setAttribute("data-l10n-id","pdfjs-page-landmark"),n.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=n,this.#Wi(),t?.append(n),this._isStandalone){t?.style.setProperty("--scale-factor",this.scale*Ne.PDF_TO_CSS_UNITS);const{optionalContentConfigPromise:i}=e;i&&i.then(e=>{i===this._optionalContentConfigPromise&&(this.#zi.initialOptionalContent=e.hasInitialVisibility)}),e.l10n||this.l10n.translate(this.div)}}#Zi(e,t){const i=Yn.get(t),n=this.#$i[i];if(this.#$i[i]=e,n)n.replaceWith(e);else{for(let t=i-1;t>=0;t--){const i=this.#$i[t];if(i)return void i.after(e)}this.div.prepend(e)}}get renderingState(){return this.#ji}set renderingState(e){if(e!==this.#ji)switch(this.#ji=e,this.#Fi&&(clearTimeout(this.#Fi),this.#Fi=null),e){case n.PAUSED:this.div.classList.remove("loading");break;case n.RUNNING:this.div.classList.add("loadingIcon"),this.#Fi=setTimeout(()=>{this.div.classList.add("loading"),this.#Fi=null},0);break;case n.INITIAL:case n.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#Wi(){const{viewport:e}=this;if(this.pdfPage){if(this.#Vi===e.rotation)return;this.#Vi=e.rotation}Ve(this.div,e,!0,!1)}setPdfPage(e){!this._isStandalone||"CanvasText"!==this.pageColors?.foreground&&"Canvas"!==this.pageColors?.background||(this._container?.style.setProperty("--hcm-highlight-filter",e.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",e.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=e,this.pdfPageRotate=e.rotate;const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:this.scale*Ne.PDF_TO_CSS_UNITS,rotation:t}),this.#Wi(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}get _textHighlighter(){return Re(this,"_textHighlighter",new Qn({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#Oi.findController}))}#Xi(e,t){this.eventBus.dispatch(e,{source:this,pageNumber:this.id,error:t})}async#Gi(){let e=null;try{await this.annotationLayer.render(this.viewport,"display")}catch(t){console.error(`#renderAnnotationLayer: "${t}".`),e=t}finally{this.#Xi("annotationlayerrendered",e)}}async#Ki(){let e=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(t){console.error(`#renderAnnotationEditorLayer: "${t}".`),e=t}finally{this.#Xi("annotationeditorlayerrendered",e)}}async#qi(){try{await this.drawLayer.render("display")}catch(e){console.error(`#renderDrawLayer: "${e}".`)}}async#Qi(){let e=null;try{const e=await this.xfaLayer.render(this.viewport,"display");e?.textDivs&&this._textHighlighter&&this.#Ji(e.textDivs)}catch(t){console.error(`#renderXfaLayer: "${t}".`),e=t}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#Zi(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#Xi("xfalayerrendered",e)}}async#Yi(){if(!this.textLayer)return;let e=null;try{await this.textLayer.render(this.viewport)}catch(t){if(t instanceof te)return;console.error(`#renderTextLayer: "${t}".`),e=t}this.#Xi("textlayerrendered",e),this.#en()}async#en(){if(!this.textLayer)return;this.structTreeLayer||=new Kn;const e=await(this.structTreeLayer.renderingDone?null:this.pdfPage.getStructTree()),t=this.structTreeLayer?.render(e);t&&(this.l10n.pause(),this.canvas?.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#Ji(e){const t=await this.pdfPage.getTextContent(),i=[];for(const e of t.items)i.push(e.str);this._textHighlighter.setTextMapping(e,i),this._textHighlighter.enable()}_resetZoomLayer(e=!1){if(!this.zoomLayer)return;const t=this.zoomLayer.firstChild;this.#Ui.delete(t),t.width=0,t.height=0,e&&this.zoomLayer.remove(),this.zoomLayer=null}reset({keepZoomLayer:e=!1,keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:i=!1,keepXfaLayer:s=!1,keepTextLayer:r=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:i,keepXfaLayer:s,keepTextLayer:r}),this.renderingState=n.INITIAL;const a=this.div,o=a.childNodes,l=e&&this.zoomLayer||null,d=t&&this.annotationLayer?.div||null,h=i&&this.annotationEditorLayer?.div||null,c=s&&this.xfaLayer?.div||null,u=r&&this.textLayer?.div||null;for(let e=o.length-1;e>=0;e--){const t=o[e];switch(t){case l:case d:case h:case c:case u:continue}t.remove();const i=this.#$i.indexOf(t);i>=0&&(this.#$i[i]=null)}a.removeAttribute("data-loaded"),d&&this.annotationLayer.hide(),h&&this.annotationEditorLayer.hide(),c&&this.xfaLayer.hide(),u&&this.textLayer.hide(),this.structTreeLayer?.hide(),l||(this.canvas&&(this.#Ui.delete(this.canvas),this.canvas.width=0,this.canvas.height=0,delete this.canvas),this._resetZoomLayer())}update({scale:e=0,rotation:t=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=e||this.scale,"number"==typeof t&&(this.rotation=t),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then(e=>{i===this._optionalContentConfigPromise&&(this.#zi.initialOptionalContent=e.hasInitialVisibility)})),this.#zi.directDrawing=!0;const r=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*Ne.PDF_TO_CSS_UNITS,rotation:r}),this.#Wi(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let e=!1;if(this.#Ni)if(0===this.maxCanvasPixels)e=!0;else if(this.maxCanvasPixels>0){const{width:t,height:i}=this.viewport,{sx:n,sy:s}=this.outputScale;e=(Math.floor(t)*n|0)*(Math.floor(i)*s|0)>this.maxCanvasPixels}const t=s>=0&&s<1e3;if(t||e){if(t&&!e&&this.renderingState!==n.FINISHED&&(this.cancelRendering({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=n.FINISHED,this.#zi.directDrawing=!1),this.cssTransform({target:this.canvas,redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!t,hideTextLayer:t}),t)return;return void this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#Ri})}this.zoomLayer||this.canvas.hidden||(this.zoomLayer=this.canvas.parentNode,this.zoomLayer.style.position="absolute")}this.zoomLayer&&this.cssTransform({target:this.zoomLayer.firstChild}),this.reset({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0})}cancelRendering({keepAnnotationLayer:e=!1,keepAnnotationEditorLayer:t=!1,keepXfaLayer:i=!1,keepTextLayer:n=!1,cancelExtraDelay:s=0}={}){this.renderTask&&(this.renderTask.cancel(s),this.renderTask=null),this.resume=null,!this.textLayer||n&&this.textLayer.div||(this.textLayer.cancel(),this.textLayer=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),!this.annotationLayer||e&&this.annotationLayer.div||(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),!this.annotationEditorLayer||t&&this.annotationEditorLayer.div||(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),!this.xfaLayer||i&&this.xfaLayer.div||(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({target:e,redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:i=!1,redrawXfaLayer:n=!1,redrawTextLayer:s=!1,hideTextLayer:r=!1}){if(!e.hasAttribute("zooming")){e.setAttribute("zooming",!0);const{style:t}=e;t.width=t.height=""}const a=this.#Ui.get(e);if(this.viewport!==a){const t=this.viewport.rotation-a.rotation,i=Math.abs(t);let n=1,s=1;if(90===i||270===i){const{width:e,height:t}=this.viewport;n=t/e,s=e/t}e.style.transform=`rotate(${t}deg) scale(${n}, ${s})`}t&&this.annotationLayer&&this.#Gi(),i&&this.annotationEditorLayer&&(this.drawLayer&&this.#qi(),this.#Ki()),n&&this.xfaLayer&&this.#Qi(),this.textLayer&&(r?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#Yi())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(e,t){return this.viewport.convertToPdfPoint(e,t)}async#ri(e,t=null){if(e===this.renderTask&&(this.renderTask=null),t instanceof Oe)this.#Ri=null;else if(this.#Ri=t,this.renderingState=n.FINISHED,this._resetZoomLayer(!0),this.#zi.regularAnnotations=!e.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#Ri}),t)throw t}async draw(){this.renderingState!==n.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:e,l10n:t,pageColors:i,pdfPage:s,viewport:r}=this;if(!s)throw this.renderingState=n.FINISHED,new Error("pdfPage is not loaded");this.renderingState=n.RUNNING;const a=document.createElement("div");if(a.classList.add("canvasWrapper"),this.#Zi(a,"canvasWrapper"),this.textLayer||this.#Hi===g||s.isPureXfa||(this._accessibilityManager||=new qn,this.textLayer=new Jn({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#Hi===m,onAppend:e=>{this.l10n.pause(),this.#Zi(e,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#Di!==oe.DISABLE){const{annotationStorage:e,annotationEditorUIManager:t,downloadManager:i,enableScripting:n,fieldObjectsPromise:r,hasJSActionsPromise:a,linkService:o}=this.#Oi;this._annotationCanvasMap||=new Map,this.annotationLayer=new Wn({pdfPage:s,annotationStorage:e,imageResourcesPath:this.imageResourcesPath,renderForms:this.#Di===oe.ENABLE_FORMS,linkService:o,downloadManager:i,enableScripting:n,hasJSActionsPromise:a,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:t,onAppend:e=>{this.#Zi(e,"annotationLayer")}})}const{width:o,height:l}=r,d=document.createElement("canvas");d.setAttribute("role","presentation"),d.hidden=!0;const h=!(!i?.background||!i?.foreground);let c=e=>{h&&!e||(d.hidden=!1,c=null)};a.append(d),this.canvas=d;const u=d.getContext("2d",{alpha:!1,willReadFrequently:!this.#Bi}),p=this.outputScale=new _;if(0===this.maxCanvasPixels){const e=1/this.scale;p.sx*=e,p.sy*=e,this.#Ni=!0}else if(this.maxCanvasPixels>0){const e=o*l,t=Math.sqrt(this.maxCanvasPixels/e);p.sx>t||p.sy>t?(p.sx=t,p.sy=t,this.#Ni=!0):this.#Ni=!1}const f=M(p.sx),b=M(p.sy);d.width=T(o*p.sx,f[0]),d.height=T(l*p.sy,b[0]);const{style:v}=d;v.width=T(o,f[1])+"px",v.height=T(l,b[1])+"px",this.#Ui.set(d,r);const w={canvasContext:u,transform:p.scaled?[p.sx,0,0,p.sy,0,0]:null,viewport:r,annotationMode:this.#Di,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i},y=this.renderTask=s.render(w);y.onContinue=e=>{if(c?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=n.PAUSED,void(this.resume=()=>{this.renderingState=n.RUNNING,e()});e()};const P=y.promise.then(async()=>{c?.(!0),await this.#ri(y),this.#Yi(),this.annotationLayer&&await this.#Gi();const{annotationEditorUIManager:e}=this.#Oi;e&&(this.drawLayer||=new Zn({pageIndex:this.id}),await this.#qi(),this.drawLayer.setParent(a),this.annotationEditorLayer||(this.annotationEditorLayer=new $n({uiManager:e,pdfPage:s,l10n:t,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:e=>{this.#Zi(e,"annotationEditorLayer")}})),this.#Ki())},e=>(e instanceof Oe||c?.(!0),this.#ri(y,e)));if(s.isPureXfa){if(!this.xfaLayer){const{annotationStorage:e,linkService:t}=this.#Oi;this.xfaLayer=new _n({pdfPage:s,annotationStorage:e,linkService:t})}this.#Qi()}return e.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),P}setPageLabel(e){this.pageLabel="string"==typeof e?e:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:e,initialOptionalContent:t,regularAnnotations:i}=this.#zi;return e&&t&&i?this.canvas:null}}const ts=1e4,is=5e3,ns=250;function ss(e){return Object.values(se).includes(e)&&e!==se.DISABLE}class rs{#tn=new Set;#in=0;constructor(e){this.#in=e}push(e){const t=this.#tn;t.has(e)&&t.delete(e),t.add(e),t.size>this.#in&&this.#nn()}resize(e,t=null){this.#in=e;const i=this.#tn;if(t){const e=i.size;let n=1;for(const s of i)if(t.has(s.id)&&(i.delete(s),i.add(s)),++n>e)break}for(;i.size>this.#in;)this.#nn()}has(e){return this.#tn.has(e)}[Symbol.iterator](){return this.#tn.keys()}#nn(){const e=this.#tn.keys().next().value;e?.destroy(),this.#tn.delete(e)}}class as{#sn=null;#rn=null;#an=null;#on=se.NONE;#ln=null;#Di=oe.ENABLE_FORMS;#dn=null;#Bi=!1;#hn=!1;#Li=!1;#Ye=null;#cn=null;#un=!1;#pn=null;#gn=!1;#fn=0;#Qe=new ResizeObserver(this.#Je.bind(this));#mn=null;#bn=null;#Hi=f;constructor(e){const t="4.4.168";if(We!==t)throw new Error(`The API version "${We}" does not match the Viewer version "${t}".`);if(this.container=e.container,this.viewer=e.viewer||e.container.firstElementChild,"DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");this.#Qe.observe(this.container),this.eventBus=e.eventBus,this.linkService=e.linkService||new ee,this.downloadManager=e.downloadManager||null,this.findController=e.findController||null,this.#rn=e.altTextManager||null,this.findController&&(this.findController.onIsPageVisible=e=>this._getVisiblePages().ids.has(e)),this._scriptingManager=e.scriptingManager||null,this.#Hi=e.textLayerMode??f,this.#Di=e.annotationMode??oe.ENABLE_FORMS,this.#on=e.annotationEditorMode??se.NONE,this.#an=e.annotationEditorHighlightColors||null,this.#hn=!0===e.enableHighlightFloatingButton,this.imageResourcesPath=e.imageResourcesPath||"",this.enablePrintAutoRotate=e.enablePrintAutoRotate||!1,this.removePageBorders=e.removePageBorders||!1,this.maxCanvasPixels=e.maxCanvasPixels,this.l10n=e.l10n,this.l10n||=new pi,this.#Li=e.enablePermissions||!1,this.pageColors=e.pageColors||null,this.#cn=e.mlManager||null,this.#Bi=e.enableHWA||!1,this.defaultRenderingQueue=!e.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new Nn,this.renderingQueue.setViewer(this)):this.renderingQueue=e.renderingQueue;const{abortSignal:i}=e;i?.addEventListener("abort",()=>{this.#Qe.disconnect(),this.#Qe=null},{once:!0}),this.scroll=S(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=s,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#vn(),this.eventBus._on("thumbnailrendered",({pageNumber:e,pdfPage:t})=>{const i=this._pages[e-1];this.#sn.has(i)||t?.cleanup()}),e.l10n||this.l10n.translate(this.container)}get pagesCount(){return this._pages.length}getPageView(e){return this._pages[e]}getCachedPageViews(){return new Set(this.#sn)}get pageViewsReady(){return this._pages.every(e=>e?.pdfPage)}get renderForms(){return this.#Di===oe.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(e){if(!Number.isInteger(e))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(e,!0)||console.error(`currentPageNumber: "${e}" is not a valid page.`))}_setCurrentPageNumber(e,t=!1){if(this._currentPageNumber===e)return t&&this.#wn(),!0;if(!(0<e&&e<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=e,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:e,pageLabel:this._pageLabels?.[e-1]??null,previous:i}),t&&this.#wn(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(e){if(!this.pdfDocument)return;let t=0|e;if(this._pageLabels){const i=this._pageLabels.indexOf(e);i>=0&&(t=i+1)}this._setCurrentPageNumber(t,!0)||console.error(`currentPageLabel: "${e}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(e){if(isNaN(e))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#yn(e,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(e){this.pdfDocument&&this.#yn(e,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!D(e))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;if((e%=360)<0&&(e+=360),this._pagesRotation===e)return;this._pagesRotation=e;const t=this._currentPageNumber;this.refresh(!0,{rotation:e}),this._currentScaleValue&&this.#yn(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:e,pageNumber:t}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){const e=this;return Re(this,"_layerProperties",{get annotationEditorUIManager(){return e.#ln},get annotationStorage(){return e.pdfDocument?.annotationStorage},get downloadManager(){return e.downloadManager},get enableScripting(){return!!e._scriptingManager},get fieldObjectsPromise(){return e.pdfDocument?.getFieldObjects()},get findController(){return e.findController},get hasJSActionsPromise(){return e.pdfDocument?.hasJSActions()},get linkService(){return e.linkService}})}#Pn(e){const t={annotationEditorMode:this.#on,annotationMode:this.#Di,textLayerMode:this.#Hi};return e?(e.includes(Be.COPY)||this.#Hi!==f||(t.textLayerMode=m),e.includes(Be.MODIFY_CONTENTS)||(t.annotationEditorMode=se.DISABLE),e.includes(Be.MODIFY_ANNOTATIONS)||e.includes(Be.FILL_INTERACTIVE_FORMS)||this.#Di!==oe.ENABLE_FORMS||(t.annotationMode=oe.ENABLE),t):t}async#_n(e){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const t=Promise.withResolvers();function i(){"hidden"===document.visibilityState&&t.resolve()}document.addEventListener("visibilitychange",i,{signal:e}),await Promise.race([this._onePageRenderedCapability.promise,t.promise]),document.removeEventListener("visibilitychange",i)}async getAllText(){const e=[],t=[];for(let i=1,n=this.pdfDocument.numPages;i<=n;++i){if(this.#gn)return null;t.length=0;const n=await this.pdfDocument.getPage(i),{items:s}=await n.getTextContent();for(const e of s)e.str&&t.push(e.str),e.hasEOL&&t.push("\n");e.push(I(t.join("")))}return e.join("\n")}#Cn(e,t){const i=document.getSelection(),{focusNode:n,anchorNode:s}=i;if(s&&n&&i.containsNode(this.#pn)){if(this.#un||e===m)return t.preventDefault(),void t.stopPropagation();this.#un=!0;const{classList:i}=this.viewer;i.add("copyAll");const n=new AbortController;window.addEventListener("keydown",e=>this.#gn="Escape"===e.key,{signal:n.signal}),this.getAllText().then(async e=>{null!==e&&await navigator.clipboard.writeText(e)}).catch(e=>{console.warn(`Something goes wrong when extracting the text: ${e.message}`)}).finally(()=>{this.#un=!1,this.#gn=!1,n.abort(),i.remove("copyAll")}),t.preventDefault(),t.stopPropagation()}}setDocument(e){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#ln&&(this.#ln.destroy(),this.#ln=null)),this.pdfDocument=e,!e)return;const t=e.numPages,i=e.getPage(1),n=e.getOptionalContentConfig({intent:"display"}),s=this.#Li?e.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#Ye=new AbortController;const{signal:l}=this.#Ye;if(t>ts){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const e=this._scrollMode=b.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:e})}this._pagesCapability.promise.then(()=>{r.dispatch("pagesloaded",{source:this,pagesCount:t})},()=>{});r._on("pagerender",e=>{const t=this._pages[e.pageNumber-1];t&&this.#sn.push(t)},{signal:l});const d=e=>{e.cssTransform||(this._onePageRenderedCapability.resolve({timestamp:e.timestamp}),r._off("pagerendered",d))};r._on("pagerendered",d,{signal:l}),Promise.all([i,s]).then(([i,s])=>{if(e!==this.pdfDocument)return;this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=n;const{annotationEditorMode:d,annotationMode:h,textLayerMode:c}=this.#Pn(s);if(c!==g){const e=this.#pn=document.createElement("div");e.id="hiddenCopyElement",o.before(e)}if(d!==se.DISABLE){const t=d;e.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):ss(t)?(this.#ln=new re(this.container,o,this.#rn,r,e,a,this.#an,this.#hn,this.#cn),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#ln}),t!==se.NONE&&this.#ln.updateMode(t)):console.error(`Invalid AnnotationEditor mode: ${t}`)}const u=this._scrollMode===b.PAGE?null:o,p=this.currentScale,f=i.getViewport({scale:p*Ne.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",f.scale),"CanvasText"!==a?.foreground&&"Canvas"!==a?.background||(o.style.setProperty("--hcm-highlight-filter",e.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),o.style.setProperty("--hcm-highlight-selected-filter",e.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let e=1;e<=t;++e){const t=new es({container:u,eventBus:r,id:e,scale:p,defaultViewport:f.clone(),optionalContentConfigPromise:n,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:h,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#Bi});this._pages.push(t)}this._pages[0]?.setPdfPage(i),this._scrollMode===b.PAGE?this.#Sn():this._spreadMode!==v.NONE&&this._updateSpreadMode(),this.#_n(l).then(async()=>{if(e!==this.pdfDocument)return;if(this.findController?.setDocument(e),this._scriptingManager?.setDocument(e),this.#pn&&document.addEventListener("copy",this.#Cn.bind(this,c),{signal:l}),this.#ln&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#on}),e.loadingParams.disableAutoFetch||t>is)return void this._pagesCapability.resolve();let i=t-1;if(i<=0)this._pagesCapability.resolve();else for(let n=2;n<=t;++n){const t=e.getPage(n).then(e=>{const t=this._pages[n-1];t.pdfPage||t.setPdfPage(e),0===--i&&this._pagesCapability.resolve()},e=>{console.error(`Unable to get page ${n} to initialize viewer`,e),0===--i&&this._pagesCapability.resolve()});n%ns===0&&await t}}),r.dispatch("pagesinit",{source:this}),e.getMetadata().then(({info:t})=>{e===this.pdfDocument&&t.Language&&(o.lang=t.Language)}),this.defaultRenderingQueue&&this.update()}).catch(e=>{console.error("Unable to initialize viewer",e),this._pagesCapability.reject(e)})}setPageLabels(e){if(this.pdfDocument){e?Array.isArray(e)&&this.pdfDocument.numPages===e.length?this._pageLabels=e:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let e=0,t=this._pages.length;e<t;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#sn=new rs(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=b.VERTICAL,this._previousScrollMode=b.UNKNOWN,this._spreadMode=v.NONE,this.#mn={previousPageNumber:1,scrollDown:!0,pages:[]},this.#Ye?.abort(),this.#Ye=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#pn?.remove(),this.#pn=null}#Sn(){if(this._scrollMode!==b.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const e=this._currentPageNumber,t=this.#mn,i=this.viewer;if(i.textContent="",t.pages.length=0,this._spreadMode!==v.NONE||this.isInPresentationMode){const n=new Set,s=this._spreadMode-1;-1===s?n.add(e-1):e%2!==s?(n.add(e-1),n.add(e)):(n.add(e-2),n.add(e-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const e=document.createElement("div");e.className="dummyPage",r.append(e)}for(const e of n){const i=this._pages[e];i&&(r.append(i.div),t.pages.push(i))}i.append(r)}else{const n=this._pages[e-1];i.append(n.div),t.pages.push(n)}t.scrollDown=e>=t.previousPageNumber,t.previousPageNumber=e}_scrollUpdate(){0!==this.pagesCount&&this.update()}#En(e,t=null){const{div:i,id:n}=e;if(this._currentPageNumber!==n&&this._setCurrentPageNumber(n),this._scrollMode===b.PAGE&&(this.#Sn(),this.update()),!t&&!this.isInPresentationMode){const e=i.offsetLeft+i.clientLeft,n=e+i.clientWidth,{scrollLeft:s,clientWidth:r}=this.container;(this._scrollMode===b.HORIZONTAL||e<s||n>s+r)&&(t={left:0,top:0})}C(i,t),!this._currentScaleValue&&this._location&&(this._location=null)}#Ln(e){return e===this._currentScale||Math.abs(e-this._currentScale)<1e-15}#In(e,t,{noScroll:i=!1,preset:n=!1,drawingDelay:s=-1,origin:r=null}){if(this._currentScaleValue=t.toString(),this.#Ln(e))return void(n&&this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:t}));this.viewer.style.setProperty("--scale-factor",e*Ne.PDF_TO_CSS_UNITS);const a=s>=0&&s<1e3;this.refresh(!0,{scale:e,drawingDelay:a?s:-1}),a&&(this.#bn=setTimeout(()=>{this.#bn=null,this.refresh()},s));const o=this._currentScale;if(this._currentScale=e,!i){let t,i=this._currentPageNumber;if(!this._location||this.isInPresentationMode||this.isChangingPresentationMode||(i=this._location.pageNumber,t=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:i,destArray:t,allowNegativeOffset:!0}),Array.isArray(r)){const t=e/o-1,[i,n]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-n)*t,this.container.scrollTop+=(r[1]-i)*t}}this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:n?t:void 0}),this.defaultRenderingQueue&&this.update()}get#xn(){return this._spreadMode!==v.NONE&&this._scrollMode!==b.HORIZONTAL?2:1}#yn(e,t){let i=parseFloat(e);if(i>0)t.preset=!1,this.#In(i,e,t);else{const n=this._pages[this._currentPageNumber-1];if(!n)return;let s=40,r=5;this.isInPresentationMode?(s=r=4,this._spreadMode!==v.NONE&&(s*=2)):this.removePageBorders?s=r=0:this._scrollMode===b.HORIZONTAL&&([s,r]=[r,s]);const a=(this.container.clientWidth-s)/n.width*n.scale/this.#xn,o=(this.container.clientHeight-r)/n.height*n.scale;switch(e){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=o;break;case"page-fit":i=Math.min(a,o);break;case"auto":const t=O(n)?a:Math.min(o,a);i=Math.min(1.25,t);break;default:return void console.error(`#setScale: "${e}" is an unknown zoom value.`)}t.preset=!0,this.#In(i,e,t)}}#wn(){const e=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#yn(this._currentScaleValue,{noScroll:!0}),this.#En(e)}pageLabelToPageNumber(e){if(!this._pageLabels)return null;const t=this._pageLabels.indexOf(e);return t<0?null:t+1}scrollPageIntoView({pageNumber:e,destArray:t=null,allowNegativeOffset:n=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const r=Number.isInteger(e)&&this._pages[e-1];if(!r)return void console.error(`scrollPageIntoView: "${e}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!t)return void this._setCurrentPageNumber(e,!0);let a,o,l=0,d=0,h=0,c=0;const u=r.rotation%180!=0,p=(u?r.height:r.width)/r.scale/Ne.PDF_TO_CSS_UNITS,g=(u?r.width:r.height)/r.scale/Ne.PDF_TO_CSS_UNITS;let f=0;switch(t[1].name){case"XYZ":l=t[2],d=t[3],f=t[4],l=null!==l?l:0,d=null!==d?d:g;break;case"Fit":case"FitB":f="page-fit";break;case"FitH":case"FitBH":d=t[2],f="page-width",null===d&&this._location?(l=this._location.left,d=this._location.top):("number"!=typeof d||d<0)&&(d=g);break;case"FitV":case"FitBV":l=t[2],h=p,c=g,f="page-height";break;case"FitR":l=t[2],d=t[3],h=t[4]-l,c=t[5]-d;let e=40,i=5;this.removePageBorders&&(e=i=0),a=(this.container.clientWidth-e)/h/Ne.PDF_TO_CSS_UNITS,o=(this.container.clientHeight-i)/c/Ne.PDF_TO_CSS_UNITS,f=Math.min(Math.abs(a),Math.abs(o));break;default:return void console.error(`scrollPageIntoView: "${t[1].name}" is not a valid destination type.`)}if(s||(f&&f!==this._currentScale?this.currentScaleValue=f:0===this._currentScale&&(this.currentScaleValue=i)),"page-fit"===f&&!t[4])return void this.#En(r);const m=[r.viewport.convertToViewportPoint(l,d),r.viewport.convertToViewportPoint(l+h,d+c)];let b=Math.min(m[0][0],m[1][0]),v=Math.min(m[0][1],m[1][1]);n||(b=Math.max(b,0),v=Math.max(v,0)),this.#En(r,{left:b,top:v})}_updateLocation(e){const t=this._currentScale,i=this._currentScaleValue,n=parseFloat(i)===t?Math.round(1e4*t)/100:i,s=e.id,r=this._pages[s-1],a=this.container,o=r.getPagePoint(a.scrollLeft-e.x,a.scrollTop-e.y),l=Math.round(o[0]),d=Math.round(o[1]);let h=`#page=${s}`;this.isInPresentationMode||(h+=`&zoom=${n},${l},${d}`),this._location={pageNumber:s,scale:n,top:d,left:l,rotation:this._pagesRotation,pdfOpenParams:h}}update(){const e=this._getVisiblePages(),t=e.views,i=t.length;if(0===i)return;const n=Math.max(10,2*i+1);this.#sn.resize(n,e.ids),this.renderingQueue.renderHighestPriority(e);const s=this._spreadMode===v.NONE&&(this._scrollMode===b.PAGE||this._scrollMode===b.VERTICAL),r=this._currentPageNumber;let a=!1;for(const e of t){if(e.percent<100)break;if(e.id===r&&s){a=!0;break}}this._setCurrentPageNumber(a?r:t[0].id),this._updateLocation(e.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}containsElement(e){return this.container.contains(e)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===o}get isChangingPresentationMode(){return this.presentationModeState===a}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const e=this._scrollMode===b.PAGE?this.#mn.pages:this._pages,t=this._scrollMode===b.HORIZONTAL,i=t&&this._isContainerRtl;return k({scrollEl:this.container,views:e,sortByVisibility:!0,horizontal:t,rtl:i})}cleanup(){for(const e of this._pages)e.renderingState!==n.FINISHED&&e.reset()}_cancelRendering(){for(const e of this._pages)e.cancelRendering()}async#hi(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);return e.pdfPage||e.setPdfPage(t),t}catch(e){return console.error("Unable to get page for page view",e),null}}#ci(e){if(1===e.first?.id)return!0;if(e.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case b.PAGE:return this.#mn.scrollDown;case b.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(e){const t=e||this._getVisiblePages(),i=this.#ci(t),n=this._spreadMode!==v.NONE&&this._scrollMode!==b.HORIZONTAL,s=this.renderingQueue.getHighestPriority(t,this._pages,i,n);return!!s&&(this.#hi(s).then(()=>{this.renderingQueue.renderView(s)}),!0)}get hasEqualPageSizes(){const e=this._pages[0];for(let t=1,i=this._pages.length;t<i;++t){const i=this._pages[t];if(i.width!==e.width||i.height!==e.height)return!1}return!0}getPagesOverview(){let e;return this._pages.map(t=>{const i=t.pdfPage.getViewport({scale:1}),n=O(i);if(void 0===e)e=n;else if(this.enablePrintAutoRotate&&n!==e)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}})}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig({intent:"display"})):Promise.resolve(null)}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${e}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=e,this.refresh(!1,{optionalContentConfigPromise:e}),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:e}))}get scrollMode(){return this._scrollMode}set scrollMode(e){if(this._scrollMode!==e){if(!B(e))throw new Error(`Invalid scroll mode: ${e}`);this.pagesCount>ts||(this._previousScrollMode=this._scrollMode,this._scrollMode=e,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:e}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(e=null){const t=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",t===b.HORIZONTAL),i.classList.toggle("scrollWrapped",t===b.WRAPPED),this.pdfDocument&&e&&(t===b.PAGE?this.#Sn():this._previousScrollMode===b.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#yn(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(e,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(e){if(this._spreadMode!==e){if(!N(e))throw new Error(`Invalid spread mode: ${e}`);this._spreadMode=e,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:e}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(e=null){if(!this.pdfDocument)return;const t=this.viewer,i=this._pages;if(this._scrollMode===b.PAGE)this.#Sn();else if(t.textContent="",this._spreadMode===v.NONE)for(const e of this._pages)t.append(e.div);else{const e=this._spreadMode-1;let n=null;for(let s=0,r=i.length;s<r;++s)null===n?(n=document.createElement("div"),n.className="spread",t.append(n)):s%2===e&&(n=n.cloneNode(!1),t.append(n)),n.append(i[s].div)}e&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#yn(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(e,!0),this.update())}_getPageAdvance(e,t=!1){switch(this._scrollMode){case b.WRAPPED:{const{views:i}=this._getVisiblePages(),n=new Map;for(const{id:e,y:t,percent:s,widthPercent:r}of i){if(0===s||r<100)continue;let i=n.get(t);i||n.set(t,i||=[]),i.push(e)}for(const i of n.values()){const n=i.indexOf(e);if(-1===n)continue;const s=i.length;if(1===s)break;if(t)for(let t=n-1,s=0;t>=s;t--){const n=i[t],s=i[t+1]-1;if(n<s)return e-s}else for(let t=n+1,r=s;t<r;t++){const n=i[t],s=i[t-1]+1;if(n>s)return s-e}if(t){const t=i[0];if(t<e)return e-t+1}else{const t=i[s-1];if(t>e)return t-e+1}break}break}case b.HORIZONTAL:break;case b.PAGE:case b.VERTICAL:{if(this._spreadMode===v.NONE)break;const i=this._spreadMode-1;if(t&&e%2!==i)break;if(!t&&e%2===i)break;const{views:n}=this._getVisiblePages(),s=t?e-1:e+1;for(const{id:e,percent:t,widthPercent:i}of n)if(e===s){if(t>0&&100===i)return 2;break}break}}return 1}nextPage(){const e=this._currentPageNumber,t=this.pagesCount;if(e>=t)return!1;const i=this._getPageAdvance(e,!1)||1;return this.currentPageNumber=Math.min(e+i,t),!0}previousPage(){const e=this._currentPageNumber;if(e<=1)return!1;const t=this._getPageAdvance(e,!0)||1;return this.currentPageNumber=Math.max(e-t,1),!0}updateScale({drawingDelay:e,scaleFactor:t=null,steps:i=null,origin:n}){if(null===i&&null===t)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let s=this._currentScale;if(t>0&&1!==t)s=Math.round(s*t*100)/100;else if(i){const e=i>0?1.1:1/1.1,t=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{s=t(10*(s*e).toFixed(2))/10}while(--i>0)}s=Math.max(.1,Math.min(10,s)),this.#yn(s,{noScroll:!1,drawingDelay:e,origin:n})}increaseScale(e={}){this.updateScale({...e,steps:e.steps??1})}decreaseScale(e={}){this.updateScale({...e,steps:-(e.steps??1)})}#vn(e=this.container.clientHeight){e!==this.#fn&&(this.#fn=e,V.setProperty("--viewer-container-height",`${e}px`))}#Je(e){for(const t of e)if(t.target===this.container){this.#vn(Math.floor(t.borderBoxSize[0].blockSize)),this.#dn=null;break}}get containerTopLeft(){return this.#dn||=[this.container.offsetTop,this.container.offsetLeft]}get annotationEditorMode(){return this.#ln?this.#on:se.DISABLE}set annotationEditorMode({mode:e,editId:t=null,isFromKeyboard:i=!1}){if(!this.#ln)throw new Error("The AnnotationEditor is not enabled.");if(this.#on!==e){if(!ss(e))throw new Error(`Invalid AnnotationEditor mode: ${e}`);this.pdfDocument&&(this.#on=e,this.eventBus.dispatch("annotationeditormodechanged",{source:this,mode:e}),this.#ln.updateMode(e,t,i))}}set annotationEditorParams({type:e,value:t}){if(!this.#ln)throw new Error("The AnnotationEditor is not enabled.");this.#ln.updateParams(e,t)}refresh(e=!1,t=Object.create(null)){if(this.pdfDocument){for(const e of this._pages)e.update(t);null!==this.#bn&&(clearTimeout(this.#bn),this.#bn=null),e||this.update()}}}class os{#Mn;constructor(e,t){this.#Mn=e;const i=[{element:e.presentationModeButton,eventName:"presentationmode",close:!0},{element:e.printButton,eventName:"print",close:!0},{element:e.downloadButton,eventName:"download",close:!0},{element:e.viewBookmarkButton,eventName:null,close:!0},{element:e.firstPageButton,eventName:"firstpage",close:!0},{element:e.lastPageButton,eventName:"lastpage",close:!0},{element:e.pageRotateCwButton,eventName:"rotatecw",close:!1},{element:e.pageRotateCcwButton,eventName:"rotateccw",close:!1},{element:e.cursorSelectToolButton,eventName:"switchcursortool",eventDetails:{tool:w},close:!0},{element:e.cursorHandToolButton,eventName:"switchcursortool",eventDetails:{tool:y},close:!0},{element:e.scrollPageButton,eventName:"switchscrollmode",eventDetails:{mode:b.PAGE},close:!0},{element:e.scrollVerticalButton,eventName:"switchscrollmode",eventDetails:{mode:b.VERTICAL},close:!0},{element:e.scrollHorizontalButton,eventName:"switchscrollmode",eventDetails:{mode:b.HORIZONTAL},close:!0},{element:e.scrollWrappedButton,eventName:"switchscrollmode",eventDetails:{mode:b.WRAPPED},close:!0},{element:e.spreadNoneButton,eventName:"switchspreadmode",eventDetails:{mode:v.NONE},close:!0},{element:e.spreadOddButton,eventName:"switchspreadmode",eventDetails:{mode:v.ODD},close:!0},{element:e.spreadEvenButton,eventName:"switchspreadmode",eventDetails:{mode:v.EVEN},close:!0},{element:e.documentPropertiesButton,eventName:"documentproperties",close:!0}];i.push({element:e.openFileButton,eventName:"openfile",close:!0}),this.eventBus=t,this.opened=!1,this.#q(i),this.reset()}get isOpen(){return this.opened}setPageNumber(e){this.pageNumber=e,this.#S()}setPagesCount(e){this.pagesCount=e,this.#S()}reset(){this.pageNumber=0,this.pagesCount=0,this.#S(),this.eventBus.dispatch("switchcursortool",{source:this,reset:!0}),this.#Tn({mode:b.VERTICAL}),this.#kn({mode:v.NONE})}#S(){const{firstPageButton:e,lastPageButton:t,pageRotateCwButton:i,pageRotateCcwButton:n}=this.#Mn;e.disabled=this.pageNumber<=1,t.disabled=this.pageNumber>=this.pagesCount,i.disabled=0===this.pagesCount,n.disabled=0===this.pagesCount}#q(e){const{eventBus:t}=this,{toggleButton:i}=this.#Mn;i.addEventListener("click",this.toggle.bind(this));for(const{element:i,eventName:n,close:s,eventDetails:r}of e)i.addEventListener("click",e=>{null!==n&&t.dispatch(n,{source:this,...r}),s&&this.close(),t.dispatch("reporttelemetry",{source:this,details:{type:"buttons",data:{id:i.id}}})});t._on("cursortoolchanged",this.#An.bind(this)),t._on("scrollmodechanged",this.#Tn.bind(this)),t._on("spreadmodechanged",this.#kn.bind(this))}#An({tool:e}){const{cursorSelectToolButton:t,cursorHandToolButton:i}=this.#Mn;H(t,e===w),H(i,e===y)}#Tn({mode:e}){const{scrollPageButton:t,scrollVerticalButton:i,scrollHorizontalButton:n,scrollWrappedButton:s,spreadNoneButton:r,spreadOddButton:a,spreadEvenButton:o}=this.#Mn;H(t,e===b.PAGE),H(i,e===b.VERTICAL),H(n,e===b.HORIZONTAL),H(s,e===b.WRAPPED);const l=this.pagesCount>ts;t.disabled=l,i.disabled=l,n.disabled=l,s.disabled=l;const d=e===b.HORIZONTAL;r.disabled=d,a.disabled=d,o.disabled=d}#kn({mode:e}){const{spreadNoneButton:t,spreadOddButton:i,spreadEvenButton:n}=this.#Mn;H(t,e===v.NONE),H(i,e===v.ODD),H(n,e===v.EVEN)}open(){if(this.opened)return;this.opened=!0;const{toggleButton:e,toolbar:t}=this.#Mn;z(e,!0,t)}close(){if(!this.opened)return;this.opened=!1;const{toggleButton:e,toolbar:t}=this.#Mn;z(e,!1,t)}toggle(){this.opened?this.close():this.open()}}class ls{#Mn;constructor(e,t){this.#Mn=e,this.eventBus=t;const i=[{element:e.previous,eventName:"previouspage"},{element:e.next,eventName:"nextpage"},{element:e.zoomIn,eventName:"zoomin"},{element:e.zoomOut,eventName:"zoomout"},{element:e.print,eventName:"print"},{element:e.download,eventName:"download"},{element:e.editorFreeTextButton,eventName:"switchannotationeditormode",eventDetails:{get mode(){const{classList:t}=e.editorFreeTextButton;return t.contains("toggled")?se.NONE:se.FREETEXT}}},{element:e.editorHighlightButton,eventName:"switchannotationeditormode",eventDetails:{get mode(){const{classList:t}=e.editorHighlightButton;return t.contains("toggled")?se.NONE:se.HIGHLIGHT}}},{element:e.editorInkButton,eventName:"switchannotationeditormode",eventDetails:{get mode(){const{classList:t}=e.editorInkButton;return t.contains("toggled")?se.NONE:se.INK}}},{element:e.editorStampButton,eventName:"switchannotationeditormode",eventDetails:{get mode(){const{classList:t}=e.editorStampButton;return t.contains("toggled")?se.NONE:se.STAMP}}}];this.#q(i),e.editorHighlightColorPicker&&t._on("annotationeditoruimanager",({uiManager:t})=>{this.#Dn(t,e.editorHighlightColorPicker)},{once:!0}),t._on("showannotationeditorui",({mode:t})=>{if(t===se.HIGHLIGHT)e.editorHighlightButton.click()}),this.reset()}#Dn(e,t){const i=new he({uiManager:e});e.setMainHighlightColorPicker(i),t.append(i.renderMainDropdown())}setPageNumber(e,t){this.pageNumber=e,this.pageLabel=t,this.#S(!1)}setPagesCount(e,t){this.pagesCount=e,this.hasPageLabels=t,this.#S(!0)}setPageScale(e,t){this.pageScaleValue=(e||t).toString(),this.pageScale=t,this.#S(!1)}reset(){this.pageNumber=0,this.pageLabel=null,this.hasPageLabels=!1,this.pagesCount=0,this.pageScaleValue=i,this.pageScale=1,this.#S(!0),this.updateLoadingIndicatorState(),this.#Bn({mode:se.DISABLE})}#q(e){const{eventBus:t}=this,{pageNumber:i,scaleSelect:n}=this.#Mn,s=this;for(const{element:i,eventName:n,eventDetails:s}of e)i.addEventListener("click",e=>{null!==n&&t.dispatch(n,{source:this,...s,isFromKeyboard:0===e.detail})});i.addEventListener("click",function(){this.select()}),i.addEventListener("change",function(){t.dispatch("pagenumberchanged",{source:s,value:this.value})}),n.addEventListener("change",function(){"custom"!==this.value&&t.dispatch("scalechanged",{source:s,value:this.value})}),n.addEventListener("click",function({target:e}){this.value===s.pageScaleValue&&"OPTION"===e.tagName.toUpperCase()&&this.blur()}),n.oncontextmenu=Le,t._on("annotationeditormodechanged",this.#Bn.bind(this))}#Bn({mode:e}){const{editorFreeTextButton:t,editorFreeTextParamsToolbar:i,editorHighlightButton:n,editorHighlightParamsToolbar:s,editorInkButton:r,editorInkParamsToolbar:a,editorStampButton:o,editorStampParamsToolbar:l}=this.#Mn;H(t,e===se.FREETEXT,i),H(n,e===se.HIGHLIGHT,s),H(r,e===se.INK,a),H(o,e===se.STAMP,l);const d=e===se.DISABLE;t.disabled=d,n.disabled=d,r.disabled=d,o.disabled=d}#S(e=!1){const{pageNumber:t,pagesCount:i,pageScaleValue:n,pageScale:s}=this,r=this.#Mn;e&&(this.hasPageLabels?(r.pageNumber.type="text",r.numPages.setAttribute("data-l10n-id","pdfjs-page-of-pages")):(r.pageNumber.type="number",r.numPages.setAttribute("data-l10n-id","pdfjs-of-pages"),r.numPages.setAttribute("data-l10n-args",JSON.stringify({pagesCount:i}))),r.pageNumber.max=i),this.hasPageLabels?(r.pageNumber.value=this.pageLabel,r.numPages.setAttribute("data-l10n-args",JSON.stringify({pageNumber:t,pagesCount:i}))):r.pageNumber.value=t,r.previous.disabled=t<=1,r.next.disabled=t>=i,r.zoomOut.disabled=s<=.1,r.zoomIn.disabled=s>=10;let a=!1;for(const e of r.scaleSelect.options)e.value===n?(e.selected=!0,a=!0):e.selected=!1;a||(r.customScaleOption.selected=!0,r.customScaleOption.setAttribute("data-l10n-args",JSON.stringify({scale:Math.round(1e4*s)/100})))}updateLoadingIndicatorState(e=!1){const{pageNumber:t}=this.#Mn;t.classList.toggle("loading",e)}}class ds{constructor(e,t=20){this.fingerprint=e,this.cacheSize=t,this._initializedPromise=this._readFromStorage().then(e=>{const t=JSON.parse(e||"{}");let i=-1;if(Array.isArray(t.files)){for(;t.files.length>=this.cacheSize;)t.files.shift();for(let e=0,n=t.files.length;e<n;e++){if(t.files[e].fingerprint===this.fingerprint){i=e;break}}}else t.files=[];-1===i&&(i=t.files.push({fingerprint:this.fingerprint})-1),this.file=t.files[i],this.database=t})}async _writeToStorage(){const e=JSON.stringify(this.database);localStorage.setItem("pdfjs.history",e)}async _readFromStorage(){return localStorage.getItem("pdfjs.history")}async set(e,t){return await this._initializedPromise,this.file[e]=t,this._writeToStorage()}async setMultiple(e){await this._initializedPromise;for(const t in e)this.file[t]=e[t];return this._writeToStorage()}async get(e,t){await this._initializedPromise;const i=this.file[e];return void 0!==i?i:t}async getMultiple(e){await this._initializedPromise;const t=Object.create(null);for(const i in e){const n=this.file[i];t[i]=void 0!==n?n:e[i]}return t}}const hs=-1,cs=1,us={initialBookmark:document.location.hash.substring(1),_initializedCapability:{...Promise.withResolvers(),settled:!1},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:"",_allowedGlobalEventsPromise:null,_downloadUrl:"",_eventBusAbortController:null,_windowAbortController:null,_globalAbortController:new AbortController,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,_caretBrowsing:null,_isScrolling:!1,async initialize(e){let t,i;this.appConfig=e;try{await this.preferences.initializedPromise}catch(e){console.error(`initialize: "${e.message}".`)}switch(Q.get("pdfBugEnabled")&&await this._parseHashParams(),Q.get("viewerCssTheme")){case 1:i="is-light";break;case 2:i="is-dark"}i&&document.documentElement.classList.add(i),t=this.externalServices.createL10n(),this.l10n=await t,document.getElementsByTagName("html")[0].dir=this.l10n.getDirection(),this.l10n.translate(e.appContainer||document.documentElement),this.isViewerEmbedded&&Q.get("externalLinkTarget")===J.NONE&&Q.set("externalLinkTarget",J.TOP),await this._initializeViewerComponents(),this.bindEvents(),this.bindWindowEvents(),this._initializedCapability.settled=!0,this._initializedCapability.resolve()},async _parseHashParams(){const e=document.location.hash.substring(1);if(!e)return;const{mainContainer:t,viewerContainer:i}=this.appConfig,n=E(e),s=async()=>{if(this._PDFBug)return;const{PDFBug:e}=await import(Q.get("debuggerSrc"));this._PDFBug=e};if("true"===n.get("disableworker"))try{ye.workerSrc||=Q.get("workerSrc"),await import(De.workerSrc)}catch(e){console.error(`_parseHashParams: "${e.message}".`)}if(n.has("disablerange")&&Q.set("disableRange","true"===n.get("disablerange")),n.has("disablestream")&&Q.set("disableStream","true"===n.get("disablestream")),n.has("disableautofetch")&&Q.set("disableAutoFetch","true"===n.get("disableautofetch")),n.has("disablefontface")&&Q.set("disableFontFace","true"===n.get("disablefontface")),n.has("disablehistory")&&Q.set("disableHistory","true"===n.get("disablehistory")),n.has("verbosity")&&Q.set("verbosity",0|n.get("verbosity")),n.has("textlayer"))switch(n.get("textlayer")){case"off":Q.set("textLayerMode",g);break;case"visible":case"shadow":case"hover":i.classList.add(`textLayer-${n.get("textlayer")}`);try{await s(),this._PDFBug.loadCSS()}catch(e){console.error(`_parseHashParams: "${e.message}".`)}}if(n.has("pdfbug")){Q.setAll({pdfBug:!0,fontExtraProperties:!0});const e=n.get("pdfbug").split(",");try{await s(),this._PDFBug.init(t,e)}catch(e){console.error(`_parseHashParams: "${e.message}".`)}}n.has("locale")&&Q.set("locale",n.get("locale"))},async _initializeViewerComponents(){const{appConfig:e,externalServices:t,l10n:i}=this;let s;s=new qe,this.eventBus=s,this.overlayManager=new Si;const r=new Nn;r.onIdle=this._cleanup.bind(this),this.pdfRenderingQueue=r;const a=new Y({eventBus:s,externalLinkTarget:Q.get("externalLinkTarget"),externalLinkRel:Q.get("externalLinkRel"),ignoreDestinationZoom:Q.get("ignoreDestinationZoom")});this.pdfLinkService=a;const o=this.downloadManager=new Ci,l=new un({linkService:a,eventBus:s,updateMatchesCountOnProgress:!0});this.findController=l;const d=new On({eventBus:s,externalServices:t,docProperties:this._scriptingDocProperties.bind(this)});this.pdfScriptingManager=d;const h=e.mainContainer,c=e.viewerContainer,u=Q.get("annotationEditorMode"),p=Q.get("forcePageColors")||window.matchMedia("(forced-colors: active)").matches?{background:Q.get("pageColorsBackground"),foreground:Q.get("pageColorsForeground")}:null,g=e.altTextDialog?new vi(e.altTextDialog,h,this.overlayManager,s):null,f=Q.get("enableHWA"),m=new as({container:h,viewer:c,eventBus:s,renderingQueue:r,linkService:a,downloadManager:o,altTextManager:g,findController:l,scriptingManager:Q.get("enableScripting")&&d,l10n:i,textLayerMode:Q.get("textLayerMode"),annotationMode:Q.get("annotationMode"),annotationEditorMode:u,annotationEditorHighlightColors:Q.get("highlightEditorColors"),enableHighlightFloatingButton:Q.get("enableHighlightFloatingButton"),imageResourcesPath:Q.get("imageResourcesPath"),enablePrintAutoRotate:Q.get("enablePrintAutoRotate"),maxCanvasPixels:Q.get("maxCanvasPixels"),enablePermissions:Q.get("enablePermissions"),pageColors:p,mlManager:this.mlManager,abortSignal:this._globalAbortController.signal,enableHWA:f});if(this.pdfViewer=m,r.setViewer(m),a.setViewer(m),d.setViewer(m),e.sidebar?.thumbnailView&&(this.pdfThumbnailViewer=new Un({container:e.sidebar.thumbnailView,eventBus:s,renderingQueue:r,linkService:a,pageColors:p,abortSignal:this._globalAbortController.signal,enableHWA:f}),r.setThumbnailViewer(this.pdfThumbnailViewer)),this.isViewerEmbedded||Q.get("disableHistory")||(this.pdfHistory=new fn({linkService:a,eventBus:s}),a.setHistory(this.pdfHistory)),!this.supportsIntegratedFind&&e.findBar&&(this.findBar=new pn(e.findBar,s)),e.annotationEditorParams)if(u!==se.DISABLE){Q.get("enableStampEditor")&&e.toolbar?.editorStampButton?.classList.remove("hidden");const t=e.toolbar?.editorHighlightButton;t&&Q.get("enableHighlightEditor")&&(t.hidden=!1),this.annotationEditorParams=new wi(e.annotationEditorParams,s)}else for(const e of["editorModeButtons","editorModeSeparator"])document.getElementById(e)?.classList.add("hidden");e.documentProperties&&(this.pdfDocumentProperties=new Oi(e.documentProperties,this.overlayManager,s,i,()=>this._docFilename)),e.secondaryToolbar?.cursorHandToolButton&&(this.pdfCursorTools=new ki({container:h,eventBus:s,cursorToolOnLoad:Q.get("cursorToolOnLoad")})),e.toolbar&&(this.toolbar=new ls(e.toolbar,s)),e.secondaryToolbar&&(this.secondaryToolbar=new os(e.secondaryToolbar,s)),this.supportsFullscreen&&e.secondaryToolbar?.presentationModeButton&&(this.pdfPresentationMode=new Pn({container:h,pdfViewer:m,eventBus:s})),e.passwordOverlay&&(this.passwordPrompt=new Ei(e.passwordOverlay,this.overlayManager,this.isViewerEmbedded)),e.sidebar?.outlineView&&(this.pdfOutlineViewer=new bn({container:e.sidebar.outlineView,eventBus:s,l10n:i,linkService:a,downloadManager:o})),e.sidebar?.attachmentsView&&(this.pdfAttachmentViewer=new xi({container:e.sidebar.attachmentsView,eventBus:s,l10n:i,downloadManager:o})),e.sidebar?.layersView&&(this.pdfLayerViewer=new mn({container:e.sidebar.layersView,eventBus:s,l10n:i})),e.sidebar&&(this.pdfSidebar=new Rn({elements:e.sidebar,eventBus:s,l10n:i}),this.pdfSidebar.onToggled=this.forceRendering.bind(this),this.pdfSidebar.onUpdateThumbnails=()=>{for(const e of m.getCachedPageViews())e.renderingState===n.FINISHED&&this.pdfThumbnailViewer.getThumbnail(e.id-1)?.setImage(e);this.pdfThumbnailViewer.scrollThumbnailIntoView(m.currentPageNumber)})},async run(e){this.preferences=new fi,await this.initialize(e);const{appConfig:t,eventBus:i}=this;let n;n=E(document.location.search.substring(1)).get("file")??Q.get("defaultUrl"),ps(n);const s=this._openFileInput=document.createElement("input");s.id="fileInput",s.hidden=!0,s.type="file",s.value=null,document.body.append(s),s.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){for(const t of e.dataTransfer.items)if("application/pdf"===t.type)return e.dataTransfer.dropEffect="copy"===e.dataTransfer.effectAllowed?"copy":"move",e.preventDefault(),void e.stopPropagation()}),t.mainContainer.addEventListener("drop",function(e){"application/pdf"===e.dataTransfer.files?.[0].type&&(e.preventDefault(),e.stopPropagation(),i.dispatch("fileinputchange",{source:this,fileInput:e.dataTransfer}))}),Q.get("supportsDocumentFonts")||(Q.set("disableFontFace",!0),this.l10n.get("pdfjs-web-fonts-disabled").then(e=>{console.warn(e)})),this.supportsPrinting||(t.toolbar?.print?.classList.add("hidden"),t.secondaryToolbar?.printButton.classList.add("hidden")),this.supportsFullscreen||t.secondaryToolbar?.presentationModeButton.classList.add("hidden"),this.supportsIntegratedFind&&t.toolbar?.viewFind?.classList.add("hidden"),n?this.open({url:n}):this._hideViewBookmark()},get externalServices(){return Re(this,"externalServices",new mi)},get mlManager(){return Re(this,"mlManager",!0===Q.get("enableML")?new bi:null)},get initialized(){return this._initializedCapability.settled},get initializedPromise(){return this._initializedCapability.promise},updateZoom(e,t,i){this.pdfViewer.isInPresentationMode||this.pdfViewer.updateScale({drawingDelay:Q.get("defaultZoomDelay"),steps:e,scaleFactor:t,origin:i})},zoomIn(){this.updateZoom(1)},zoomOut(){this.updateZoom(-1)},zoomReset(){this.pdfViewer.isInPresentationMode||(this.pdfViewer.currentScaleValue=i)},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 Bn.supportsPrinting},get supportsFullscreen(){return Re(this,"supportsFullscreen",document.fullscreenEnabled)},get supportsPinchToZoom(){return Re(this,"supportsPinchToZoom",Q.get("supportsPinchToZoom"))},get supportsIntegratedFind(){return Re(this,"supportsIntegratedFind",Q.get("supportsIntegratedFind"))},get loadingBar(){const e=document.getElementById("loadingBar"),t=e?new R(e):null;return Re(this,"loadingBar",t)},get supportsMouseWheelZoomCtrlKey(){return Re(this,"supportsMouseWheelZoomCtrlKey",Q.get("supportsMouseWheelZoomCtrlKey"))},get supportsMouseWheelZoomMetaKey(){return Re(this,"supportsMouseWheelZoomMetaKey",Q.get("supportsMouseWheelZoomMetaKey"))},get supportsCaretBrowsingMode(){return Q.get("supportsCaretBrowsingMode")},moveCaret(e,t){this._caretBrowsing||=new Pi(this.appConfig.mainContainer,this.appConfig.viewerContainer,this.appConfig.toolbar?.container),this._caretBrowsing.moveCaret(e,t)},setTitleUsingUrl(e="",t=null){this.url=e,this.baseUrl=e.split("#",1)[0],t&&(this._downloadUrl=t===e?this.baseUrl:t.split("#",1)[0]),Ce(e)&&this._hideViewBookmark();let i=ve(e,"");if(!i)try{i=decodeURIComponent(be(e))||e}catch{i=e}this.setTitle(i)},setTitle(e=this._title){if(this._title=e,this.isViewerEmbedded)return;const t=this._hasAnnotationEditors&&!this.pdfRenderingQueue.printing;document.title=`${t?"* ":""}${e}`},get _docFilename(){return this._contentDispositionFilename||ve(this.url)},_hideViewBookmark(){const{secondaryToolbar:e}=this.appConfig;e?.viewBookmarkButton.classList.add("hidden"),e?.presentationModeButton.classList.contains("hidden")&&document.getElementById("viewBookmarkSeparator")?.classList.add("hidden")},async close(){if(this._unblockDocumentLoadEvent(),this._hideViewBookmark(),!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,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){this.pdfLoadingTask&&await this.close();const t=Q.getAll(X);Object.assign(ye,t),e.url&&this.setTitleUsingUrl(e.originalUrl||e.url,e.url);const i=Q.getAll(Z),n=me({...i,...e});return this.pdfLoadingTask=n,n.onPassword=(e,t)=>{this.isViewerEmbedded&&this._unblockDocumentLoadEvent(),this.pdfLinkService.externalLinkEnabled=!1,this.passwordPrompt.setUpdateCallback(e,t),this.passwordPrompt.open()},n.onProgress=({loaded:e,total:t})=>{this.progress(e/t)},n.promise.then(e=>{this.load(e)},e=>{if(n!==this.pdfLoadingTask)return;let t="pdfjs-loading-error";return e instanceof _e?t="pdfjs-invalid-file-error":e instanceof Ee?t="pdfjs-missing-file-error":e instanceof He&&(t="pdfjs-unexpected-response-error"),this._documentError(t,{message:e.message}).then(()=>{throw e})})},async download(e={}){let t;try{this.downloadComplete&&(t=await this.pdfDocument.getData())}catch{}this.downloadManager.download(t,this._downloadUrl,this._docFilename,e)},async save(e={}){if(!this._saveInProgress){this._saveInProgress=!0,await this.pdfScriptingManager.dispatchWillSave();try{const t=await this.pdfDocument.saveDocument();this.downloadManager.download(t,this._downloadUrl,this._docFilename,e)}catch(t){console.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",stats:this.pdfDocument?.annotationStorage.editorStats}})}},async downloadOrSave(e={}){const{classList:t}=this.appConfig.appContainer;t.add("wait"),await(this.pdfDocument?.annotationStorage.size>0?this.save(e):this.download(e)),t.remove("wait")},async _documentError(e,t=null){this._unblockDocumentLoadEvent();const i=await this._otherError(e||"pdfjs-loading-error",t);this.eventBus.dispatch("documenterror",{source:this,message:i,reason:t?.message??null})},async _otherError(e,t=null){const i=await this.l10n.get(e),n=[`PDF.js v${We||"?"} (build: ${le||"?"})`];return t&&(n.push(`Message: ${t.message}`),t.stack?n.push(`Stack: ${t.stack}`):(t.filename&&n.push(`File: ${t.filename}`),t.lineNumber&&n.push(`Line: ${t.lineNumber}`))),console.error(`${i}\n\n${n.join("\n")}`),i},progress(e){if(!this.loadingBar||this.downloadComplete)return;const t=Math.round(100*e);t<=this.loadingBar.percent||(this.loadingBar.percent=t,(this.pdfDocument?.loadingParams.disableAutoFetch??Q.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(()=>{}),n=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:o,pagesPromise:g}=r;this.pdfThumbnailViewer?.setDocument(e);const f=(this.store=new ds(e.fingerprints[0])).getMultiple({page:null,zoom:i,scrollLeft:"0",scrollTop:"0",rotation:null,sidebarView:l,scrollMode:b.UNKNOWN,spreadMode:v.UNKNOWN}).catch(()=>{});a.then(i=>{this.loadingBar?.setWidth(this.appConfig.viewerContainer),this._initializeAnnotationStorageCallbacks(e),Promise.all([F,f,t,n,s]).then(async([t,i,n,s,a])=>{const o=Q.get("viewOnLoad");this._initializePdfHistory({fingerprint:e.fingerprints[0],viewOnLoad:o,initialDest:a?.dest});const f=this.initialBookmark,m=Q.get("defaultZoomValue");let w=m?`zoom=${m}`:null,y=null,P=Q.get("sidebarViewOnLoad"),_=Q.get("scrollModeOnLoad"),C=Q.get("spreadModeOnLoad");if(i?.page&&o!==cs&&(w=`page=${i.page}&zoom=${m||i.zoom},${i.scrollLeft},${i.scrollTop}`,y=parseInt(i.rotation,10),P===l&&(P=0|i.sidebarView),_===b.UNKNOWN&&(_=0|i.scrollMode),C===v.UNKNOWN&&(C=0|i.spreadMode)),s&&P===l&&(P=function(e){switch(e){case"UseNone":return d;case"UseThumbs":return h;case"UseOutlines":return c;case"UseAttachments":return u;case"UseOC":return p}return d}(s)),n&&_===b.UNKNOWN&&C===v.UNKNOWN){C=j(n).spreadMode}this.setInitialView(w,{rotation:y,sidebarView:P,scrollMode:_,spreadMode:C}),this.eventBus.dispatch("documentinit",{source:this}),this.isViewerEmbedded||r.focus(),await Promise.race([g,new Promise(e=>{setTimeout(e,1e4)})]),(f||w)&&(r.hasEqualPageSizes||(this.initialBookmark=f,r.currentScaleValue=r.currentScaleValue,this.setInitialView(w)))}).catch(()=>{this.setInitialView()}).then(function(){r.update()})}),g.then(()=>{this._unblockDocumentLoadEvent(),this._initializeAutoPrint(e,s)},e=>{this._documentError("pdfjs-loading-error",{message:e.message})}),o.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){return(this.documentInfo||(await new Promise(e=>{this.eventBus._on("metadataloaded",e,{once:!0})}),e===this.pdfDocument))&&(this._contentLength||(await new Promise(e=>{this.eventBus._on("documentloaded",e,{once:!0})}),e===this.pdfDocument))?{...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}:null},async _initializeAutoPrint(e,t){const[i,n]=await Promise.all([t,this.pdfViewer.enableScripting?null:e.getJSActions()]);if(e!==this.pdfDocument)return;let s="Print"===i?.action;if(n){console.warn("Warning: JavaScript support is not enabled");for(const e in n){if(s)break;switch(e){case"WillClose":case"WillSave":case"DidSave":case"WillPrint":case"DidPrint":continue}s=n[e].some(e=>P.test(e))}}s&&this.triggerPrinting()},async _initializeMetadata(e){const{info:t,metadata:i,contentDispositionFilename:n,contentLength:s}=await e.getMetadata();if(e!==this.pdfDocument)return;this.documentInfo=t,this.metadata=i,this._contentDispositionFilename??=n,this._contentLength??=s,console.log(`PDF ${e.fingerprints[0]} [${t.PDFFormatVersion} ${(t.Producer||"-").trim()} / ${(t.Creator||"-").trim()}] (PDF.js: ${We||"?"} [${le||"?"}])`);let r=t.Title;const a=i?.get("dc:title");a&&("Untitled"===a||/[\uFFF0-\uFFFF]/g.test(a)||(r=a)),r?this.setTitle(`${r} - ${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?console.warn("Warning: XFA Foreground documents are not supported"):console.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||Q.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:o}=this;r.setPageLabels(t),a?.setPageLabels(t),o?.setPagesCount(i,!0),o?.setPageNumber(r.currentPageNumber,r.currentPageLabel)},_initializePdfHistory({fingerprint:e,viewOnLoad:t,initialDest:i=null}){this.pdfHistory&&(this.pdfHistory.initialize({fingerprint:e,resetHistory:t===cs,updateUrl:Q.get("historyUpdateUrl")}),this.pdfHistory.initialBookmark&&(this.initialBookmark=this.pdfHistory.initialBookmark,this.initialRotation=this.pdfHistory.initialRotation),i&&!this.initialBookmark&&t===hs&&(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",lr),this._annotationStorageModified=!0},t.onResetModified=()=>{window.removeEventListener("beforeunload",lr),delete this._annotationStorageModified},t.onAnnotationEditor=e=>{this._hasAnnotationEditors=!!e,this.setTitle()}},setInitialView(e,{rotation:t,sidebarView:n,scrollMode:s,spreadMode:r}={}){const a=e=>{D(e)&&(this.pdfViewer.pagesRotation=e)};this.isInitialViewSet=!0,this.pdfSidebar?.setInitialView(n),((e,t)=>{B(e)&&(this.pdfViewer.scrollMode=e),N(t)&&(this.pdfViewer.spreadMode=t)})(s,r),this.initialBookmark?(a(this.initialRotation),delete this.initialRotation,this.pdfLinkService.setHash(this.initialBookmark),this.initialBookmark=null):e&&(a(t),this.pdfLinkService.setHash(e)),this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber,this.pdfViewer.currentPageLabel),this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber),this.pdfViewer.currentScaleValue||(this.pdfViewer.currentScaleValue=i)},_cleanup(){this.pdfDocument&&(this.pdfViewer.cleanup(),this.pdfThumbnailViewer?.cleanup(),this.pdfDocument.cleanup(Q.get("fontExtraProperties")))},forceRendering(){this.pdfRenderingQueue.printing=!!this.printService,this.pdfRenderingQueue.isThumbnailViewEnabled=this.pdfSidebar?.visibleView===h,this.pdfRenderingQueue.renderHighestPriority()},beforePrint(){this._printAnnotationStoragePromise=this.pdfScriptingManager.dispatchWillPrint().catch(()=>{}).then(()=>this.pdfDocument?.annotationStorage.print),this.printService||(this.supportsPrinting?this.pdfViewer.pageViewsReady?(this.printService=Bn.createPrintService({pdfDocument:this.pdfDocument,pagesOverview:this.pdfViewer.getPagesOverview(),printContainer:this.appConfig.printContainer,printResolution:Q.get("printResolution"),printAnnotationStoragePromise:this._printAnnotationStoragePromise}),this.forceRendering(),this.setTitle(),this.printService.layout(),this._hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"print",stats:this.pdfDocument?.annotationStorage.editorStats}})):this.l10n.get("pdfjs-printing-not-ready").then(e=>{window.alert(e)}):this._otherError("pdfjs-printing-not-supported"))},afterPrint(){this._printAnnotationStoragePromise&&(this._printAnnotationStoragePromise.then(()=>{this.pdfScriptingManager.dispatchDidPrint()}),this._printAnnotationStoragePromise=null),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.print()},bindEvents(){if(this._eventBusAbortController)return;this._eventBusAbortController=new AbortController;const{eventBus:e,_eventBusAbortController:{signal:t}}=this;e._on("resize",Cs,{signal:t}),e._on("hashchange",Ss,{signal:t}),e._on("beforeprint",this.beforePrint.bind(this),{signal:t}),e._on("afterprint",this.afterPrint.bind(this),{signal:t}),e._on("pagerender",gs,{signal:t}),e._on("pagerendered",fs,{signal:t}),e._on("updateviewarea",ys,{signal:t}),e._on("pagechanging",Js,{signal:t}),e._on("scalechanging",qs,{signal:t}),e._on("rotationchanging",Qs,{signal:t}),e._on("sidebarviewchanged",ws,{signal:t}),e._on("pagemode",ms,{signal:t}),e._on("namedaction",bs,{signal:t}),e._on("presentationmodechanged",vs,{signal:t}),e._on("presentationmode",Is,{signal:t}),e._on("switchannotationeditormode",xs,{signal:t}),e._on("switchannotationeditorparams",Ms,{signal:t}),e._on("print",Ts,{signal:t}),e._on("download",ks,{signal:t}),e._on("firstpage",As,{signal:t}),e._on("lastpage",Ds,{signal:t}),e._on("nextpage",Bs,{signal:t}),e._on("previouspage",Ns,{signal:t}),e._on("zoomin",Os,{signal:t}),e._on("zoomout",Fs,{signal:t}),e._on("zoomreset",Vs,{signal:t}),e._on("pagenumberchanged",Rs,{signal:t}),e._on("scalechanged",js,{signal:t}),e._on("rotatecw",Hs,{signal:t}),e._on("rotateccw",zs,{signal:t}),e._on("optionalcontentconfig",Us,{signal:t}),e._on("switchscrollmode",$s,{signal:t}),e._on("scrollmodechanged",Ps,{signal:t}),e._on("switchspreadmode",Ws,{signal:t}),e._on("spreadmodechanged",_s,{signal:t}),e._on("documentproperties",Zs,{signal:t}),e._on("findfromurlhash",Xs,{signal:t}),e._on("updatefindmatchescount",Gs,{signal:t}),e._on("updatefindcontrolstate",Ks,{signal:t}),e._on("fileinputchange",Es,{signal:t}),e._on("openfile",Ls,{signal:t})},bindWindowEvents(){if(this._windowAbortController)return;this._windowAbortController=new AbortController;const{eventBus:e,appConfig:{mainContainer:t},_windowAbortController:{signal:i}}=this;if(function e(t=null){t&&us.pdfViewer.refresh(),window.matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`).addEventListener("change",e,{once:!0,signal:i})}(),window.addEventListener("visibilitychange",Ys,{signal:i}),window.addEventListener("wheel",tr,{passive:!1,signal:i}),window.addEventListener("touchstart",ir,{passive:!1,signal:i}),window.addEventListener("touchmove",nr,{passive:!1,signal:i}),window.addEventListener("touchend",sr,{passive:!1,signal:i}),window.addEventListener("click",rr,{signal:i}),window.addEventListener("keydown",or,{signal:i}),window.addEventListener("keyup",ar,{signal:i}),window.addEventListener("resize",()=>{e.dispatch("resize",{source:window})},{signal:i}),window.addEventListener("hashchange",()=>{e.dispatch("hashchange",{source:window,hash:document.location.hash.substring(1)})},{signal:i}),window.addEventListener("beforeprint",()=>{e.dispatch("beforeprint",{source:window})},{signal:i}),window.addEventListener("afterprint",()=>{e.dispatch("afterprint",{source:window})},{signal:i}),window.addEventListener("updatefromsandbox",t=>{e.dispatch("updatefromsandbox",{source:window,detail:t.detail})},{signal:i}),!("onscrollend"in document.documentElement))return;({scrollTop:this._lastScrollTop,scrollLeft:this._lastScrollLeft}=t);const n=()=>{({scrollTop:this._lastScrollTop,scrollLeft:this._lastScrollLeft}=t),this._isScrolling=!1,t.addEventListener("scroll",s,{passive:!0,signal:i}),t.removeEventListener("scrollend",n),t.removeEventListener("blur",n)},s=()=>{this._isCtrlKeyDown||this._lastScrollTop===t.scrollTop&&this._lastScrollLeft===t.scrollLeft||(t.removeEventListener("scroll",s,{passive:!0}),this._isScrolling=!0,t.addEventListener("scrollend",n,{signal:i}),t.addEventListener("blur",n,{signal:i}))};t.addEventListener("scroll",s,{passive:!0,signal:i})},unbindEvents(){this._eventBusAbortController?.abort(),this._eventBusAbortController=null},unbindWindowEvents(){this._windowAbortController?.abort(),this._windowAbortController=null},async testingClose(){this.unbindEvents(),this.unbindWindowEvents(),this._globalAbortController?.abort(),this._globalAbortController=null,this.findBar?.close(),await Promise.all([this.l10n?.destroy(),this.close()])},_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]);return this[t]-=i,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);return this[i]=t/n,n},_unblockDocumentLoadEvent(){document.blockUnblockOnload?.(!1),this._unblockDocumentLoadEvent=()=>{}},get scriptingReady(){return this.pdfScriptingManager.ready}};Bn.initGlobals(us);{const e=["null","http://mozilla.github.io","https://mozilla.github.io"];var ps=function(t){if(t)try{const i=new URL(window.location.href).origin||"null";if(e.includes(i))return;new URL(t,window.location.href).origin}catch(e){throw us._documentError("pdfjs-loading-error",{message:e.message}),e}}}function gs({pageNumber:e}){e===us.page&&us.toolbar?.updateLoadingIndicatorState(!0)}function fs({pageNumber:e,error:t}){if(e===us.page&&us.toolbar?.updateLoadingIndicatorState(!1),us.pdfSidebar?.visibleView===h){const t=us.pdfViewer.getPageView(e-1),i=us.pdfThumbnailViewer?.getThumbnail(e-1);t&&i?.setImage(t)}t&&us._otherError("pdfjs-rendering-error",t)}function ms({mode:e}){let t;switch(e){case"thumbs":t=h;break;case"bookmarks":case"outline":t=c;break;case"attachments":t=u;break;case"layers":t=p;break;case"none":t=d;break;default:return void console.error('Invalid "pagemode" hash parameter: '+e)}us.pdfSidebar?.switchView(t,!0)}function bs(e){switch(e.action){case"GoToPage":us.appConfig.toolbar?.pageNumber.select();break;case"Find":us.supportsIntegratedFind||us.findBar?.toggle();break;case"Print":us.triggerPrinting();break;case"SaveAs":us.downloadOrSave()}}function vs(e){us.pdfViewer.presentationModeState=e.state}function ws({view:e}){us.pdfRenderingQueue.isThumbnailViewEnabled=e===h,us.isInitialViewSet&&us.store?.set("sidebarView",e).catch(()=>{})}function ys({location:e}){if(us.isInitialViewSet&&us.store?.setMultiple({page:e.pageNumber,zoom:e.scale,scrollLeft:e.left,scrollTop:e.top,rotation:e.rotation}).catch(()=>{}),us.appConfig.secondaryToolbar){const t=us.pdfLinkService.getAnchorUrl(e.pdfOpenParams);us.appConfig.secondaryToolbar.viewBookmarkButton.href=t}}function Ps(e){us.isInitialViewSet&&!us.pdfViewer.isInPresentationMode&&us.store?.set("scrollMode",e.mode).catch(()=>{})}function _s(e){us.isInitialViewSet&&!us.pdfViewer.isInPresentationMode&&us.store?.set("spreadMode",e.mode).catch(()=>{})}function Cs(){const{pdfDocument:e,pdfViewer:t,pdfRenderingQueue:i}=us;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 Ss(e){const t=e.hash;t&&(us.isInitialViewSet?us.pdfHistory?.popStateInProgress||us.pdfLinkService.setHash(t):us.initialBookmark=t)}var Es=function(e){if(us.pdfViewer?.isInPresentationMode)return;const t=e.fileInput.files[0];us.open({url:URL.createObjectURL(t),originalUrl:t.name})},Ls=function(e){us._openFileInput?.click()};function Is(){us.requestPresentationMode()}function xs(e){us.pdfViewer.annotationEditorMode=e}function Ms(e){us.pdfViewer.annotationEditorParams=e}function Ts(){us.triggerPrinting()}function ks(){us.downloadOrSave()}function As(){us.page=1}function Ds(){us.page=us.pagesCount}function Bs(){us.pdfViewer.nextPage()}function Ns(){us.pdfViewer.previousPage()}function Os(){us.zoomIn()}function Fs(){us.zoomOut()}function Vs(){us.zoomReset()}function Rs(e){const t=us.pdfViewer;""!==e.value&&us.pdfLinkService.goToPage(e.value),e.value!==t.currentPageNumber.toString()&&e.value!==t.currentPageLabel&&us.toolbar?.setPageNumber(t.currentPageNumber,t.currentPageLabel)}function js(e){us.pdfViewer.currentScaleValue=e.value}function Hs(){us.rotatePages(90)}function zs(){us.rotatePages(-90)}function Us(e){us.pdfViewer.optionalContentConfigPromise=e.promise}function $s(e){us.pdfViewer.scrollMode=e.mode}function Ws(e){us.pdfViewer.spreadMode=e.mode}function Zs(){us.pdfDocumentProperties?.open()}function Xs(e){us.eventBus.dispatch("find",{source:e.source,type:"",query:e.query,caseSensitive:!1,entireWord:!1,highlightAll:!0,findPrevious:!1,matchDiacritics:!0})}function Gs({matchesCount:e}){us.supportsIntegratedFind?us.externalServices.updateFindMatchesCount(e):us.findBar?.updateResultsCount(e)}function Ks({state:e,previous:t,entireWord:i,matchesCount:n,rawQuery:s}){us.supportsIntegratedFind?us.externalServices.updateFindControlState({result:e,findPrevious:t,entireWord:i,matchesCount:n,rawQuery:s}):us.findBar?.updateUIState(e,t,n)}function qs(e){us.toolbar?.setPageScale(e.presetValue,e.scale),us.pdfViewer.update()}function Qs(e){us.pdfThumbnailViewer&&(us.pdfThumbnailViewer.pagesRotation=e.pagesRotation),us.forceRendering(),us.pdfViewer.currentPageNumber=e.pageNumber}function Js({pageNumber:e,pageLabel:t}){us.toolbar?.setPageNumber(e,t),us.secondaryToolbar?.setPageNumber(e),us.pdfSidebar?.visibleView===h&&us.pdfThumbnailViewer?.scrollThumbnailIntoView(e);const i=us.pdfViewer.getPageView(e-1);us.toolbar?.updateLoadingIndicatorState(i?.renderingState===n.RUNNING)}function Ys(e){"visible"===document.visibilityState&&function(){er&&clearTimeout(er);er=setTimeout(function(){er=null},1e3)}()}let er=null;function tr(e){const{pdfViewer:t,supportsMouseWheelZoomCtrlKey:i,supportsMouseWheelZoomMetaKey:n,supportsPinchToZoom:s}=us;if(t.isInPresentationMode)return;const r=e.deltaMode;let a=Math.exp(-e.deltaY/100);const o=e.ctrlKey&&!us._isCtrlKeyDown&&r===WheelEvent.DOM_DELTA_PIXEL&&0===e.deltaX&&(Math.abs(a-1)<.05||!1)&&0===e.deltaZ,l=[e.clientX,e.clientY];if(o||e.ctrlKey&&i||e.metaKey&&n){if(e.preventDefault(),us._isScrolling||er||"hidden"===document.visibilityState||us.overlayManager.active)return;if(o&&s)a=us._accumulateFactor(t.currentScale,a,"_wheelUnusedFactor"),us.updateZoom(null,a,l);else{const t=A(e);let i=0;if(r===WheelEvent.DOM_DELTA_LINE||r===WheelEvent.DOM_DELTA_PAGE)i=Math.abs(t)>=1?Math.sign(t):us._accumulateTicks(t,"_wheelUnusedTicks");else{const e=30;i=us._accumulateTicks(t/e,"_wheelUnusedTicks")}us.updateZoom(i,null,l)}}}function ir(e){if(us.pdfViewer.isInPresentationMode||e.touches.length<2)return;if(e.preventDefault(),2!==e.touches.length||us.overlayManager.active)return void(us._touchInfo=null);let[t,i]=e.touches;t.identifier>i.identifier&&([t,i]=[i,t]),us._touchInfo={touch0X:t.pageX,touch0Y:t.pageY,touch1X:i.pageX,touch1Y:i.pageY}}function nr(e){if(!us._touchInfo||2!==e.touches.length)return;const{pdfViewer:t,_touchInfo:i,supportsPinchToZoom:n}=us;let[s,r]=e.touches;s.identifier>r.identifier&&([s,r]=[r,s]);const{pageX:a,pageY:o}=s,{pageX:l,pageY:d}=r,{touch0X:h,touch0Y:c,touch1X:u,touch1Y:p}=i;if(Math.abs(h-a)<=1&&Math.abs(c-o)<=1&&Math.abs(u-l)<=1&&Math.abs(p-d)<=1)return;if(i.touch0X=a,i.touch0Y=o,i.touch1X=l,i.touch1Y=d,h===a&&c===o){const e=u-a,t=p-o,i=l-a,n=d-o,s=e*n-t*i;if(Math.abs(s)>.02*Math.hypot(e,t)*Math.hypot(i,n))return}else if(u===l&&p===d){const e=h-l,t=c-d,i=a-l,n=o-d,s=e*n-t*i;if(Math.abs(s)>.02*Math.hypot(e,t)*Math.hypot(i,n))return}else{if((a-h)*(l-u)+(o-c)*(d-p)>=0)return}e.preventDefault();const g=[(a+l)/2,(o+d)/2],f=Math.hypot(a-l,o-d)||1,m=Math.hypot(h-u,c-p)||1;if(n){const e=us._accumulateFactor(t.currentScale,f/m,"_touchUnusedFactor");us.updateZoom(null,e,g)}else{const e=30,t=us._accumulateTicks((f-m)/e,"_touchUnusedTicks");us.updateZoom(t,null,g)}}function sr(e){us._touchInfo&&(e.preventDefault(),us._touchInfo=null,us._touchUnusedTicks=0,us._touchUnusedFactor=1)}function rr(e){if(!us.secondaryToolbar?.isOpen)return;const t=us.appConfig;(us.pdfViewer.containsElement(e.target)||t.toolbar?.container.contains(e.target)&&e.target!==t.secondaryToolbar?.toggleButton)&&us.secondaryToolbar.close()}function ar(e){"Control"===e.key&&(us._isCtrlKeyDown=!1)}function or(e){if(us._isCtrlKeyDown="Control"===e.key,us.overlayManager.active)return;const{eventBus:t,pdfViewer:i}=us,n=i.isInPresentationMode;let s=!1,r=!1;const a=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(1===a||8===a||5===a||12===a)switch(e.keyCode){case 70:us.supportsIntegratedFind||e.shiftKey||(us.findBar?.open(),s=!0);break;case 71:if(!us.supportsIntegratedFind){const{state:e}=us.findController;if(e){const i={source:window,type:"again",findPrevious:5===a||12===a};t.dispatch("find",{...e,...i})}s=!0}break;case 61:case 107:case 187:case 171:us.zoomIn(),s=!0;break;case 173:case 109:case 189:us.zoomOut(),s=!0;break;case 48:case 96:n||(setTimeout(function(){us.zoomReset()}),s=!1);break;case 38:(n||us.page>1)&&(us.page=1,s=!0,r=!0);break;case 40:(n||us.page<us.pagesCount)&&(us.page=us.pagesCount,s=!0,r=!0)}if(1===a||8===a)switch(e.keyCode){case 83:t.dispatch("download",{source:window}),s=!0;break;case 79:t.dispatch("openfile",{source:window}),s=!0}if(3===a||10===a)switch(e.keyCode){case 80:us.requestPresentationMode(),s=!0,us.externalServices.reportTelemetry({type:"buttons",data:{id:"presentationModeKeyboard"}});break;case 71:us.appConfig.toolbar&&(us.appConfig.toolbar.pageNumber.select(),s=!0)}if(s)return r&&!n&&i.focus(),void e.preventDefault();const o=function(){let e=document,t=e.activeElement||e.querySelector(":focus");for(;t?.shadowRoot;)e=t.shadowRoot,t=e.activeElement||e.querySelector(":focus");return t}(),l=o?.tagName.toUpperCase();if("INPUT"!==l&&"TEXTAREA"!==l&&"SELECT"!==l&&("BUTTON"!==l||13!==e.keyCode&&32!==e.keyCode)&&!o?.isContentEditable||27===e.keyCode){if(0===a){let t=0,a=!1;switch(e.keyCode){case 38:if(us.supportsCaretBrowsingMode){us.moveCaret(!0,!1),s=!0;break}case 33:i.isVerticalScrollbarEnabled&&(a=!0),t=-1;break;case 8:n||(a=!0),t=-1;break;case 37:if(us.supportsCaretBrowsingMode)return;i.isHorizontalScrollbarEnabled&&(a=!0);case 75:case 80:t=-1;break;case 27:us.secondaryToolbar?.isOpen&&(us.secondaryToolbar.close(),s=!0),!us.supportsIntegratedFind&&us.findBar?.opened&&(us.findBar.close(),s=!0);break;case 40:if(us.supportsCaretBrowsingMode){us.moveCaret(!1,!1),s=!0;break}case 34:i.isVerticalScrollbarEnabled&&(a=!0),t=1;break;case 13:case 32:n||(a=!0),t=1;break;case 39:if(us.supportsCaretBrowsingMode)return;i.isHorizontalScrollbarEnabled&&(a=!0);case 74:case 78:t=1;break;case 36:(n||us.page>1)&&(us.page=1,s=!0,r=!0);break;case 35:(n||us.page<us.pagesCount)&&(us.page=us.pagesCount,s=!0,r=!0);break;case 83:us.pdfCursorTools?.switchTool(w);break;case 72:us.pdfCursorTools?.switchTool(y);break;case 82:us.rotatePages(90);break;case 115:us.pdfSidebar?.toggle()}0===t||a&&"page-fit"!==i.currentScaleValue||(t>0?i.nextPage():i.previousPage(),s=!0)}if(4===a)switch(e.keyCode){case 13:case 32:if(!n&&"page-fit"!==i.currentScaleValue)break;i.previousPage(),s=!0;break;case 38:us.moveCaret(!0,!0),s=!0;break;case 40:us.moveCaret(!1,!0),s=!0;break;case 82:us.rotatePages(-90)}s||n||(e.keyCode>=33&&e.keyCode<=40||32===e.keyCode&&"BUTTON"!==l)&&(r=!0),r&&!i.containsElement(o)&&i.focus(),s&&e.preventDefault()}}function lr(e){return e.preventDefault(),e.returnValue="",!1}const dr={LinkTarget:J,RenderingStates:n,ScrollMode:b,SpreadMode:v};function hr(){const e={appContainer:document.body,mainContainer:document.getElementById("viewerContainer"),viewerContainer:document.getElementById("viewer"),toolbar:{container:document.getElementById("toolbarViewer"),numPages:document.getElementById("numPages"),pageNumber:document.getElementById("pageNumber"),scaleSelect:document.getElementById("scaleSelect"),customScaleOption:document.getElementById("customScaleOption"),previous:document.getElementById("previous"),next:document.getElementById("next"),zoomIn:document.getElementById("zoomIn"),zoomOut:document.getElementById("zoomOut"),viewFind:document.getElementById("viewFind"),print:document.getElementById("print"),editorFreeTextButton:document.getElementById("editorFreeText"),editorFreeTextParamsToolbar:document.getElementById("editorFreeTextParamsToolbar"),editorHighlightButton:document.getElementById("editorHighlight"),editorHighlightParamsToolbar:document.getElementById("editorHighlightParamsToolbar"),editorHighlightColorPicker:document.getElementById("editorHighlightColorPicker"),editorInkButton:document.getElementById("editorInk"),editorInkParamsToolbar:document.getElementById("editorInkParamsToolbar"),editorStampButton:document.getElementById("editorStamp"),editorStampParamsToolbar:document.getElementById("editorStampParamsToolbar"),download:document.getElementById("download")},secondaryToolbar:{toolbar:document.getElementById("secondaryToolbar"),toggleButton:document.getElementById("secondaryToolbarToggle"),presentationModeButton:document.getElementById("presentationMode"),openFileButton:document.getElementById("secondaryOpenFile"),printButton:document.getElementById("secondaryPrint"),downloadButton:document.getElementById("secondaryDownload"),viewBookmarkButton:document.getElementById("viewBookmark"),firstPageButton:document.getElementById("firstPage"),lastPageButton:document.getElementById("lastPage"),pageRotateCwButton:document.getElementById("pageRotateCw"),pageRotateCcwButton:document.getElementById("pageRotateCcw"),cursorSelectToolButton:document.getElementById("cursorSelectTool"),cursorHandToolButton:document.getElementById("cursorHandTool"),scrollPageButton:document.getElementById("scrollPage"),scrollVerticalButton:document.getElementById("scrollVertical"),scrollHorizontalButton:document.getElementById("scrollHorizontal"),scrollWrappedButton:document.getElementById("scrollWrapped"),spreadNoneButton:document.getElementById("spreadNone"),spreadOddButton:document.getElementById("spreadOdd"),spreadEvenButton:document.getElementById("spreadEven"),documentPropertiesButton:document.getElementById("documentProperties")},sidebar:{outerContainer:document.getElementById("outerContainer"),sidebarContainer:document.getElementById("sidebarContainer"),toggleButton:document.getElementById("sidebarToggle"),resizer:document.getElementById("sidebarResizer"),thumbnailButton:document.getElementById("viewThumbnail"),outlineButton:document.getElementById("viewOutline"),attachmentsButton:document.getElementById("viewAttachments"),layersButton:document.getElementById("viewLayers"),thumbnailView:document.getElementById("thumbnailView"),outlineView:document.getElementById("outlineView"),attachmentsView:document.getElementById("attachmentsView"),layersView:document.getElementById("layersView"),currentOutlineItemButton:document.getElementById("currentOutlineItem")},findBar:{bar:document.getElementById("findbar"),toggleButton:document.getElementById("viewFind"),findField:document.getElementById("findInput"),highlightAllCheckbox:document.getElementById("findHighlightAll"),caseSensitiveCheckbox:document.getElementById("findMatchCase"),matchDiacriticsCheckbox:document.getElementById("findMatchDiacritics"),entireWordCheckbox:document.getElementById("findEntireWord"),findMsg:document.getElementById("findMsg"),findResultsCount:document.getElementById("findResultsCount"),findPreviousButton:document.getElementById("findPrevious"),findNextButton:document.getElementById("findNext")},passwordOverlay:{dialog:document.getElementById("passwordDialog"),label:document.getElementById("passwordText"),input:document.getElementById("password"),submitButton:document.getElementById("passwordSubmit"),cancelButton:document.getElementById("passwordCancel")},documentProperties:{dialog:document.getElementById("documentPropertiesDialog"),closeButton:document.getElementById("documentPropertiesClose"),fields:{fileName:document.getElementById("fileNameField"),fileSize:document.getElementById("fileSizeField"),title:document.getElementById("titleField"),author:document.getElementById("authorField"),subject:document.getElementById("subjectField"),keywords:document.getElementById("keywordsField"),creationDate:document.getElementById("creationDateField"),modificationDate:document.getElementById("modificationDateField"),creator:document.getElementById("creatorField"),producer:document.getElementById("producerField"),version:document.getElementById("versionField"),pageCount:document.getElementById("pageCountField"),pageSize:document.getElementById("pageSizeField"),linearized:document.getElementById("linearizedField")}},altTextDialog:{dialog:document.getElementById("altTextDialog"),optionDescription:document.getElementById("descriptionButton"),optionDecorative:document.getElementById("decorativeButton"),textarea:document.getElementById("descriptionTextarea"),cancelButton:document.getElementById("altTextCancel"),saveButton:document.getElementById("altTextSave")},annotationEditorParams:{editorFreeTextFontSize:document.getElementById("editorFreeTextFontSize"),editorFreeTextColor:document.getElementById("editorFreeTextColor"),editorInkColor:document.getElementById("editorInkColor"),editorInkThickness:document.getElementById("editorInkThickness"),editorInkOpacity:document.getElementById("editorInkOpacity"),editorStampAddImage:document.getElementById("editorStampAddImage"),editorFreeHighlightThickness:document.getElementById("editorFreeHighlightThickness"),editorHighlightShowAll:document.getElementById("editorHighlightShowAll")},printContainer:document.getElementById("printContainer")},t=new CustomEvent("webviewerloaded",{bubbles:!0,cancelable:!0,detail:{source:window}});try{parent.document.dispatchEvent(t)}catch(e){console.error(`webviewerloaded: ${e}`),document.dispatchEvent(t)}us.run(e)}window.PDFViewerApplication=us,window.PDFViewerApplicationConstants=dr,window.PDFViewerApplicationOptions=Q,document.blockUnblockOnload?.(!0),"interactive"===document.readyState||"complete"===document.readyState?hr():document.addEventListener("DOMContentLoaded",hr,!0);var cr=t.PDFViewerApplication,ur=t.PDFViewerApplicationConstants,pr=t.PDFViewerApplicationOptions;export{cr as PDFViewerApplication,ur as PDFViewerApplicationConstants,pr as PDFViewerApplicationOptions};