UNPKG

ngx-extended-pdf-viewer

Version:

Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.

37 lines • 1.41 MB
/**
 * @licstart The following is the entire license notice for the
 * JavaScript code in this page
 *
 * Copyright 2024 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
 */
/**
 * pdfjsVersion = 6.5.1523
 * pdfjsBuild = e59504a82
 */
class ngx_console_NgxConsole{static log(e,t){ngx_console_NgxConsole.ngxConsoleFilter("log",e)&&(void 0!==t?console.log("%s",e,t):console.log(e))}static error(e,t){ngx_console_NgxConsole.ngxConsoleFilter("error",e)&&(void 0!==t?console.error("%s",e,t):console.error(e))}static warn(e,t){ngx_console_NgxConsole.ngxConsoleFilter("warn",e)&&(void 0!==t?console.warn("%s",e,t):console.warn(e))}static debug(e,t){ngx_console_NgxConsole.ngxConsoleFilter("debug",e)&&(void 0!==t?console.warn("%s",e,t):console.warn(e))}get ngxConsoleFilter(){return ngx_console_NgxConsole.ngxConsoleFilter}set ngxConsoleFilter(e){ngx_console_NgxConsole.ngxConsoleFilter=e}reset(){ngx_console_NgxConsole.ngxConsoleFilter=(e,t)=>!0}}!function _defineProperty(e,t,i){return(t=function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(ngx_console_NgxConsole,"ngxConsoleFilter",(e,t)=>!0);var e;function _assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const t=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),i=[1/0,1/0,-1/0,-1/0],a=new Float32Array(i),s=[.001,0,0,.001,0,0],r="http://www.w3.org/2000/svg",n=1,o=2,l=4,d=16,c=32,h=64,_=128,u=256,p={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},g="pdfjs_internal_id_",m="pdfjs_internal_editor_",f={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102,ERASER:103},v={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,ERASER_THICKNESS:25,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41,ERASER_STEP:42},P={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},w=0,F=1,y=2,b=3,S=3,C=4,x={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},k={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},E=1,A=2,G=3,B=4,M=5,I={ERRORS:0,WARNINGS:1,INFOS:5},T={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},D=0,L=1,R=2,O=3,N=4,W={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let j=I.WARNINGS;function setVerbosityLevel(e){Number.isInteger(e)&&(j=e)}function getVerbosityLevel(){return j}function info(e){j>=I.INFOS&&("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope||Window&&ngx_console_NgxConsole?ngx_console_NgxConsole.log(`Info: ${e}`):console.log(`Info: ${e}`))}function warn(e){j>=I.WARNINGS&&("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope||Window&&ngx_console_NgxConsole?ngx_console_NgxConsole.log(`Warning: ${e}`):console.log(`Warning: ${e}`))}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function createValidAbsoluteUrl(e,t=null,i=null){if(!e)return null;if(i&&"string"==typeof e){if(i.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(i.tryConvertEncoding)try{e=function stringToUTF8String(e){return decodeURIComponent(escape(e))}(e)}catch{}}const a=t?URL.parse(e,t):URL.parse(e);return function _isValidProtocol(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":case"capacitor":return!0;default:return!1}}(a)?a:null}function updateUrlHash(e,t,i=!1){const a=URL.parse(e);if(a){a.hash=t;return a.href}return i&&createValidAbsoluteUrl(e,"http://example.com")?e.split("#",1)[0]+""+(t?`#${t}`:""):""}function stripPath(e){return e.substring(e.lastIndexOf("/")+1)}function shadow(e,t,i,a=!1){Object.defineProperty(e,t,{value:i,enumerable:!a,configurable:!0,writable:!1});return i}const V=function BaseExceptionClosure(){function BaseException(e,t){this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class PasswordException extends V{constructor(e,t){super(e,"PasswordException");this.code=t}}class UnknownErrorException extends V{constructor(e,t){super(e,"UnknownErrorException");this.details=t}}class InvalidPDFException extends V{constructor(e){super(e,"InvalidPDFException")}}class ResponseException extends V{constructor(e,t,i){super(e,"ResponseException");this.status=t;this.missing=i}}class FormatError extends V{constructor(e){super(e,"FormatError")}}class AbortException extends V{constructor(e){super(e,"AbortException")}}function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,i=new Uint8Array(t);for(let a=0;a<t;++a)i[a]=255&e.charCodeAt(a);return i}class FeatureTest{static get isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return shadow(this,"isLittleEndian",1===new Uint32Array(e.buffer,0,1)[0])}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return shadow(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isVideoFrameSupported(){return shadow(this,"isVideoFrameSupported","undefined"!=typeof VideoFrame)}static get isFloat16ArraySupported(){return shadow(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return shadow(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:e,userAgent:t}=navigator;return shadow(this,"platform",{isAndroid:t.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:t.includes("Firefox")})}static get isCanvasFilterSupported(){let e;this.isOffscreenCanvasSupported?e=new OffscreenCanvas(1,1).getContext("2d"):"undefined"!=typeof document&&(e=document.createElement("canvas").getContext("2d"));return shadow(this,"isCanvasFilterSupported",void 0!==e?.filter)}static get isAlphaColorInputSupported(){if("undefined"==typeof document)return shadow(this,"isAlphaColorInputSupported",!1);const e=document.createElement("input");e.type="color";e.setAttribute("alpha","");e.value="#ff000080";return shadow(this,"isAlphaColorInputSupported","#ff0000"!==e.value)}static get isBackdropFilterSupported(){return shadow(this,"isBackdropFilterSupported","undefined"!=typeof CSS&&CSS.supports("backdrop-filter","blur(1px)"))}}class Util{static get hexNums(){return shadow(this,"hexNums",Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")))}static makeHexColor(e,t,i){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[i]}`}static get identity0to256Map(){return shadow(this,"identity0to256Map",Uint8Array.from({length:256},(e,t)=>t))}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,i=0){const a=e[i],s=e[i+1];e[i]=a*t[0]+s*t[2]+t[4];e[i+1]=a*t[1]+s*t[3]+t[5]}static applyTransformToBezier(e,t,i=0){const a=t[0],s=t[1],r=t[2],n=t[3],o=t[4],l=t[5];for(let t=0;t<6;t+=2){const d=e[i+t],c=e[i+t+1];e[i+t]=d*a+c*r+o;e[i+t+1]=d*s+c*n+l}}static applyInverseTransform(e,t){const i=e[0],a=e[1],s=t[0]*t[3]-t[1]*t[2];e[0]=(i*t[3]-a*t[2]+t[2]*t[5]-t[4]*t[3])/s;e[1]=(-i*t[1]+a*t[0]+t[4]*t[1]-t[5]*t[0])/s}static axialAlignedBoundingBox(e,t,i){const a=t[0],s=t[1],r=t[2],n=t[3],o=t[4],l=t[5],d=e[0],c=e[1],h=e[2],_=e[3];let u=a*d+o,p=u,g=a*h+o,m=g,f=n*c+l,v=f,P=n*_+l,w=P;if(0!==s||0!==r){const e=s*d,t=s*h,i=r*c,a=r*_;u+=i;m+=i;g+=a;p+=a;f+=e;w+=e;P+=t;v+=t}i[0]=Math.min(i[0],u,g,Math.min(p,m));i[1]=Math.min(i[1],f,P,Math.min(v,w));i[2]=Math.max(i[2],u,g,Math.max(p,m));i[3]=Math.max(i[3],f,P,Math.max(v,w))}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){const i=e[0],a=e[1],s=e[2],r=e[3],n=i**2+a**2,o=i*s+a*r,l=s**2+r**2,d=(n+l)/2,c=Math.sqrt(d**2-(n*l-o**2));t[0]=Math.sqrt(d+c||1);t[1]=Math.sqrt(d-c||1)}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){const i=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(i>a)return null;const s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),r=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>r?null:[i,s,a,r]}static pointBoundingBox(e,t,i){i[0]=Math.min(i[0],e);i[1]=Math.min(i[1],t);i[2]=Math.max(i[2],e);i[3]=Math.max(i[3],t)}static rectBoundingBox(e,t,i,a,s){s[0]=Math.min(s[0],e,i);s[1]=Math.min(s[1],t,a);s[2]=Math.max(s[2],e,i);s[3]=Math.max(s[3],t,a)}static bezierBoundingBox(e,t,i,a,s,r,n,o,l){l[0]=Math.min(l[0],e,n);l[1]=Math.min(l[1],t,o);l[2]=Math.max(l[2],e,n);l[3]=Math.max(l[3],t,o);_assertClassBrand(Util,this,_getExtremum).call(this,e,i,s,n,t,a,r,o,3*(3*(i-s)-e+n),6*(e-2*i+s),3*(i-e),l);_assertClassBrand(Util,this,_getExtremum).call(this,e,i,s,n,t,a,r,o,3*(3*(a-r)-t+o),6*(t-2*a+r),3*(a-t),l)}}e=Util;function _getExtremumOnCurve(e,t,i,a,s,r,n,o,l,d){if(l<=0||l>=1)return;const c=1-l,h=l*l,_=h*l,u=c*(c*(c*e+3*l*t)+3*h*i)+_*a,p=c*(c*(c*s+3*l*r)+3*h*n)+_*o;d[0]=Math.min(d[0],u);d[1]=Math.min(d[1],p);d[2]=Math.max(d[2],u);d[3]=Math.max(d[3],p)}function _getExtremum(t,i,a,s,r,n,o,l,d,c,h,_){if(Math.abs(d)<1e-12){Math.abs(c)>=1e-12&&_assertClassBrand(e,this,_getExtremumOnCurve).call(this,t,i,a,s,r,n,o,l,-h/c,_);return}const u=c**2-4*h*d;if(u<0)return;const p=Math.sqrt(u),g=2*d;_assertClassBrand(e,this,_getExtremumOnCurve).call(this,t,i,a,s,r,n,o,l,(-c+p)/g,_);_assertClassBrand(e,this,_getExtremumOnCurve).call(this,t,i,a,s,r,n,o,l,(-c-p)/g,_)}let U=null,z=null;function normalizeUnicode(e){if(!U){U=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;z=new Map([["ſt","ſt"]])}return e.replaceAll(U,(e,t,i)=>t?t.normalize("NFKC"):z.get(i))}function getUuid(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(32);crypto.getRandomValues(e);return function bytesToString(e){"object"==typeof e&&void 0!==e?.length||unreachable("Invalid argument for bytesToString");const t=e.length,i=8192;if(t<i)return String.fromCharCode.apply(null,e);const a=[];for(let s=0;s<t;s+=i){const r=Math.min(s+i,t),n=e.subarray(s,r);a.push(String.fromCharCode.apply(null,n))}return a.join("")}(e)}function ngxNextPageWideId(e){const t=globalThis.ngxPageWideIds??=Object.create(null);t[e]=(t[e]??-1)+1;return t[e]}const makeArr=()=>[],makeMap=()=>new Map,makeObj=()=>Object.create(null),makeSet=()=>new Set;"function"!=typeof Iterator.prototype.join&&(Iterator.prototype.join=function(e){return[...this].join(e)});function MathClamp(e,t,i){return Math.min(Math.max(e,t),i)}var H;function display_utils_defineProperty(e,t,i){return(t=function display_utils_toPropertyKey(e){var t=function display_utils_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class PixelsPerInch{}H=PixelsPerInch;display_utils_defineProperty(PixelsPerInch,"CSS",96);display_utils_defineProperty(PixelsPerInch,"PDF",72);display_utils_defineProperty(PixelsPerInch,"PDF_TO_CSS_UNITS",H.CSS/H.PDF);class RenderingCancelledException extends V{constructor(e,t=0){super(e,"RenderingCancelledException");this.extraDelay=t}}function getRGBA(e){if(e.startsWith("#")){const t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith("rgb(")){const[t,i,a]=e.slice(4,-1).split(",").map(e=>parseInt(e,10));return[t,i,a,1]}if(e.startsWith("rgba(")){const t=e.slice(5,-1).split(",");return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}const t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(255*parseFloat(t[1])),Math.round(255*parseFloat(t[2])),Math.round(255*parseFloat(t[3])),void 0!==t[4]&&"none"!==t[4]?parseFloat(t[4]):1]:null}function getRGB(e){const t=getRGBA(e);if(!t){warn(`Not a valid color format: "${e}"`);return[0,0,0]}return t.slice(0,3)}function getCurrentTransform(e){const{a:t,b:i,c:a,d:s,e:r,f:n}=e.getTransform();return[t,i,a,s,r,n]}function getCurrentTransformInverse(e){const{a:t,b:i,c:a,d:s,e:r,f:n}=e.getTransform().invertSelf();return[t,i,a,s,r,n]}class OutputScale{constructor(){const{pixelRatio:e}=OutputScale;this.sx=e;this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(e,t,i,a,s=-1){let r=1/0,n=1/0,o=1/0;(i=OutputScale.capPixels(i,s))>0&&(r=Math.sqrt(i/(e*t)));if(-1!==a){n=a/e;o=a/t}const l=Math.min(r,n,o);if(this.sx>l||this.sy>l){this.sx=l;this.sy=l;return!0}return!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,i):i}return e}}function applyOpacity(e,t){const i=255*(1-(t=MathClamp(t??1,0,1)));return e.map(e=>Math.round(e*t+i))}function RGBToHSL(e,t){const i=e[0]/255,a=e[1]/255,s=e[2]/255,r=Math.max(i,a,s),n=Math.min(i,a,s),o=(r+n)/2;if(r===n)t[0]=t[1]=0;else{const e=r-n;t[1]=o<.5?e/(r+n):e/(2-r-n);switch(r){case i:t[0]=60*((a-s)/e+(a<s?6:0));break;case a:t[0]=60*((s-i)/e+2);break;case s:t[0]=60*((i-a)/e+4)}}t[2]=o}function HSLToRGB(e,t){const i=e[0],a=e[1],s=e[2],r=(1-Math.abs(2*s-1))*a,n=r*(1-Math.abs(i/60%2-1)),o=s-r/2;switch(Math.floor(i/60)){case 0:t[0]=r+o;t[1]=n+o;t[2]=o;break;case 1:t[0]=n+o;t[1]=r+o;t[2]=o;break;case 2:t[0]=o;t[1]=r+o;t[2]=n+o;break;case 3:t[0]=o;t[1]=n+o;t[2]=r+o;break;case 4:t[0]=n+o;t[1]=o;t[2]=r+o;break;case 5:case 6:t[0]=r+o;t[1]=o;t[2]=n+o}}function computeLuminance(e){return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function contrastRatio(e,t,i){HSLToRGB(e,i);i.map(computeLuminance);const a=.2126*i[0]+.7152*i[1]+.0722*i[2];HSLToRGB(t,i);i.map(computeLuminance);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];return a>s?(a+.05)/(s+.05):(s+.05)/(a+.05)}const $=new Map;function findContrastColor(e,t){const i=e[0]+256*e[1]+65536*e[2]+16777216*t[0]+4294967296*t[1]+1099511627776*t[2];let a=$.get(i);if(a)return a;const s=new Float32Array(9),r=s.subarray(0,3),n=s.subarray(3,6);RGBToHSL(e,n);const o=s.subarray(6,9);RGBToHSL(t,o);const l=o[2]<.5,d=l?12:4.5;n[2]=l?Math.sqrt(n[2]):1-Math.sqrt(1-n[2]);if(contrastRatio(n,o,r)<d){let e,t;if(l){e=n[2];t=1}else{e=0;t=n[2]}const i=.005;for(;t-e>i;){const i=n[2]=(e+t)/2;l===contrastRatio(n,o,r)<d?e=i:t=i}n[2]=l?t:e}HSLToRGB(n,r);a=Util.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2]));$.set(i,a);return a}function makePathFromDrawOPS(e){const t=new Path2D;if(!e)return t;for(let i=0,a=e.length;i<a;)switch(e[i++]){case D:t.moveTo(e[i++],e[i++]);break;case L:t.lineTo(e[i++],e[i++]);break;case R:t.bezierCurveTo(e[i++],e[i++],e[i++],e[i++],e[i++],e[i++]);break;case O:t.quadraticCurveTo(e[i++],e[i++],e[i++],e[i++]);break;case N:t.closePath();break;default:warn(`Unrecognized drawing path operator: ${e[i-1]}`)}return t}class PageViewport{constructor({viewBox:e,userUnit:t,scale:i,rotation:a,offsetX:s=0,offsetY:r=0,dontFlip:n=!1}){this.viewBox=e;this.userUnit=t;this.scale=i;this.rotation=a;this.offsetX=s;this.offsetY=r;i*=t;const o=(e[2]+e[0])/2,l=(e[3]+e[1])/2;let d,c,h,_,u,p,g,m;(a%=360)<0&&(a+=360);switch(a){case 180:d=-1;c=0;h=0;_=1;break;case 90:d=0;c=1;h=1;_=0;break;case 270:d=0;c=-1;h=-1;_=0;break;case 0:d=1;c=0;h=0;_=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(n){h=-h;_=-_}if(0===d){u=Math.abs(l-e[1])*i+s;p=Math.abs(o-e[0])*i+r;g=(e[3]-e[1])*i;m=(e[2]-e[0])*i}else{u=Math.abs(o-e[0])*i+s;p=Math.abs(l-e[1])*i+r;g=(e[2]-e[0])*i;m=(e[3]-e[1])*i}this.transform=[d*i,c*i,h*i,_*i,u-d*i*o-h*i*l,p-c*i*o-_*i*l];this.width=g;this.height=m}get rawDims(){const e=this.viewBox;return shadow(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:i=this.offsetX,offsetY:a=this.offsetY,dontFlip:s=!1}={}){return new PageViewport({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:i,offsetY:a,dontFlip:s})}convertToViewportPoint(e,t){const i=[e,t];Util.applyTransform(i,this.transform);return i}convertToPdfPoint(e,t){const i=[e,t];Util.applyInverseTransform(i,this.transform);return i}}class XfaText{static textContent(e){const t=[],i={items:t,styles:Object.create(null)};!function walk(e){if(!e)return;let i=null;const a=e.name;if("#text"===a)i=e.value;else{if(!XfaText.shouldBuildText(a))return;e?.attributes?.textContent?i=e.attributes.textContent:e.value&&(i=e.value)}null!==i&&t.push({str:i});if(e.children)for(const t of e.children)walk(t)}(e);return i}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}function xfa_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const X=/url\(|image-set\(/i,K=/^on/i;class XfaLayer{static get _allowedHtmlElements(){return shadow(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return shadow(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return shadow(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return shadow(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return shadow(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(e,t,i,a,s,r){const n=r?.ngxFormSupport??window,o=n.getFormValueFromAngular(e);o.value&&a.setValue(t,Array.isArray(o.value)?{value:o.value[0]??null}:o);const l=a.getValue(t,{value:null}),d=o.value?o:l;n.registerXFAField(e,d,l);e.addEventListener("updateFromAngular",e=>a.setValue(t,{value:e.detail}));switch(i.name){case"textarea":null!==d.value&&(e.textContent=d.value);if("print"===s)break;e.addEventListener("input",i=>{n.updateAngularFormValue(e,{value:i.target.value});a.setValue(t,{value:i.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){d.value===i.attributes.xfaOn?e.setAttribute("checked",!0):e.removeAttribute("checked");if("print"===s)break;e.addEventListener("change",i=>{n.updateAngularFormValue(e,{value:i.target.checked?i.target.getAttribute("xfaOn"):i.target.getAttribute("xfaOff")});a.setValue(t,{value:i.target.checked?i.target.getAttribute("xfaOn"):i.target.getAttribute("xfaOff")})})}else{null!==d.value&&e.setAttribute("value",d.value);if("print"===s)break;e.addEventListener("input",i=>{n.updateAngularFormValue(e,{value:i.target.value});a.setValue(t,{value:i.target.value})})}break;case"select":if(null!==d.value){const t=Array.isArray(d.value)?d.value:[d.value];e.setAttribute("value",t[0]??"");for(const e of i.children)t.includes(e.attributes.value)?e.attributes.selected=!0:Object.hasOwn(e.attributes,"selected")&&delete e.attributes.selected}e.addEventListener("input",i=>{const s=i.target.options,r=-1===s.selectedIndex?"":s[s.selectedIndex].value,o=i.target.multiple?Array.from(i.target.selectedOptions,e=>e.value):r;n.updateAngularFormValue(e,{value:o});a.setValue(t,{value:r})})}}static setAttributes({html:e,element:t,storage:i=null,intent:a,linkService:s}){const{attributes:r}=t,n=e instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${a}`);for(const[t,i]of Object.entries(r))if(null!=i&&!K.test(t)&&("richText"!==a||this._allowedRichTextAttributes.has(t)))switch(t){case"class":i.length&&e.setAttribute(t,i.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",i);break;case"style":if("richText"===a){const t=this._allowedRichTextStyles;for(const[a,s]of Object.entries(i))t.has(a)&&!X.test(s)&&(e.style[a]=s)}else Object.assign(e.style,i);break;case"textContent":e.textContent=i;break;default:(!n||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,i)}const o=s?.ngxRadioGroupForm;"radio"===r.type&&o&&e.setAttribute("form",o);n&&s?.addLinkAttributes(e,r.href,r.newWindow);i&&r.dataId&&this.setupStorage(e,r.dataId,t,i,void 0,s)}static render(e){const t=e.annotationStorage,i=e.linkService,a=e.xfaHtml,s=e.intent||"display",r=xfa_layer_assertClassBrand(XfaLayer,this,_createElement).call(this,a.name,a.attributes?.xmlns,s)??document.createElement("div");a.attributes&&this.setAttributes({html:r,element:a,intent:s,linkService:i});const n="richText"!==s,o=e.div;o.append(r);if(e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;o.style.transform=t}n&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===a.children.length){if(a.value){const e=document.createTextNode(a.value);r.append(e);n&&XfaText.shouldBuildText(a.name)&&l.push(e)}return{textDivs:l}}const d=[[a,-1,r]];for(;d.length>0;){const[e,a,r]=d.at(-1);if(a+1===e.children.length){d.pop();continue}const o=e.children[++d.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const e=document.createTextNode(o.value);l.push(e);r.append(e);continue}const h=xfa_layer_assertClassBrand(XfaLayer,this,_createElement).call(this,c,o.attributes?.xmlns,s);if(h){r.append(h);o.attributes&&this.setAttributes({html:h,element:o,storage:t,intent:s,linkService:i});if(o.children?.length>0)d.push([o,-1,h]);else if(o.value){const e=document.createTextNode(o.value);n&&XfaText.shouldBuildText(c)&&l.push(e);h.append(e)}}}for(const e of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t;e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:i=0}){const{width:a,height:s}=e.attributes.style;return new PageViewport({viewBox:[0,0,parseInt(a,10),parseInt(s,10)],userUnit:1,scale:t,rotation:i})}}function _createElement(e,t,i){return"richText"===i?!t&&this._allowedRichTextElements.has(e)?document.createElement(e):null:t?t===r&&this._allowedSvgElements.has(e)?document.createElementNS(r,e):null:this._allowedHtmlElements.has(e)?document.createElement(e):null}function dom_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}async function fetchData(e,t="text"){if(isValidFetchUrl(e,document.baseURI)){const i=await fetch(e);if(!i.ok)throw new Error(i.statusText);switch(t){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise((i,a)=>{const s=new XMLHttpRequest;s.open("GET",e,!0);s.responseType="bytes"===t?"arraybuffer":t;s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE)if(200!==s.status&&0!==s.status)a(new Error(s.statusText));else{switch(t){case"bytes":i(new Uint8Array(s.response));return;case"blob":case"json":i(s.response);return}i(s.responseText)}};s.send(null)})}function isDataScheme(e){const t=e.length;let i=0;for(;i<t&&""===e[i].trim();)i++;return"data:"===e.substring(i,i+5).toLowerCase()}function isPdfFile(e){return"string"==typeof e&&/\.pdf$/i.test(e)}function getPdfFilenameFromUrl(e,t="document.pdf"){if(t&&"document.pdf"!==t)return t;if("string"!=typeof e)return t;if(isDataScheme(e)){warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');return t}const i=(e=>{try{return new URL(e)}catch{}try{return new URL(decodeURIComponent(e))}catch{}try{return new URL(e,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(e),"https://foo.bar")}catch{}return null})(e);if(!i)return t;const decode=e=>{try{let t=decodeURIComponent(e);if(t.includes("/")){t=stripPath(t);if(4===t.length&&a.test(t))return e}return t}catch{return e}},a=/\.pdf$/i,s=stripPath(i.pathname);if(a.test(s))return decode(s);if(i.searchParams.size>0){const getLast=e=>[...e].findLast(e=>a.test(e)),e=getLast(i.searchParams.values())??getLast(i.searchParams.keys());if(e)return decode(e)}if(i.hash){const{hash:e}=i;let t=-1;for(const{index:i}of e.matchAll(/\.pdf\b/gi))t=i;if(t>0){let i=t;for(;i>0&&!"/?#=".includes(e[i-1]);)i--;if(i<t)return decode(e.slice(i,t+4))}}return t}function isValidFetchUrl(e,t){const i=t?URL.parse(e,t):URL.parse(e);return/https?:|blob:|capacitor:/.test(i?.protocol??"")}function noContextMenu(e){e.preventDefault()}function stopEvent(e){e.preventDefault();e.stopPropagation()}class PDFDateString{static toDateObject(e){if(e instanceof Date)return e;if(!e||"string"!=typeof e)return null;dom_utils_assertClassBrand(PDFDateString,this,q)._||(q._=dom_utils_assertClassBrand(PDFDateString,this,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?")));const t=dom_utils_assertClassBrand(PDFDateString,this,q)._.exec(e);if(!t)return null;const i=parseInt(t[1],10);let a=parseInt(t[2],10);a=a>=1&&a<=12?a-1:0;let s=parseInt(t[3],10);s=s>=1&&s<=31?s:1;let r=parseInt(t[4],10);r=r>=0&&r<=23?r:0;let n=parseInt(t[5],10);n=n>=0&&n<=59?n:0;let o=parseInt(t[6],10);o=o>=0&&o<=59?o:0;const l=t[7]||"Z";let d=parseInt(t[8],10);d=d>=0&&d<=23?d:0;let c=parseInt(t[9],10)||0;c=c>=0&&c<=59?c:0;if("-"===l){r+=d;n+=c}else if("+"===l){r-=d;n-=c}return new Date(Date.UTC(i,a,s,r,n,o))}}var q={_:void 0};function setLayerDimensions(e,t,i=!1,a=!0){if(t instanceof PageViewport){const{pageWidth:a,pageHeight:s}=t.rawDims,{style:r}=e,n=`round(down, var(--total-scale-factor) * ${a}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${s}px, var(--scale-round-y))`;if(i&&t.rotation%180!=0){r.width=o;r.height=n}else{r.width=n;r.height=o}}a&&e.setAttribute("data-main-rotation",t.rotation)}const Y=new Set(["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"]);class ColorScheme{static get isDarkMode(){return shadow(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class CSSConstants{static get commentForegroundColor(){const e=document.createElement("ngx-extended-pdf-viewer");e.style.display="block";const t=document.createElement("span");t.classList.add("commentPopup","comment","sidebar");const{style:i}=t;i.width=i.height="0";i.display="none";i.color="var(--comment-fg-color)";e.append(t);document.body.append(e);const{color:a}=window.getComputedStyle(t);e.remove();return shadow(this,"commentForegroundColor",getRGB(a))}}function renderRichText({html:e,dir:t,className:i},a){const s=document.createDocumentFragment();if("string"==typeof e){const i=document.createElement("p");i.dir=t||"auto";const a=e.split(/\r\n?|\n/);for(let e=0,t=a.length;e<t;++e){const s=a[e];i.append(document.createTextNode(s));e<t-1&&i.append(document.createElement("br"))}s.append(i)}else XfaLayer.render({xfaHtml:e,div:s,intent:"richText"});s.firstElementChild.classList.add("richText",i);a.append(s)}function _classPrivateMethodInitSpec(e,t){_checkPrivateRedeclaration(e,t),t.add(e)}function _classPrivateFieldInitSpec(e,t,i){_checkPrivateRedeclaration(e,t),t.set(e,i)}function _checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateGetter(e,t,i){return i(toolbar_assertClassBrand(e,t))}function _classPrivateFieldGet(e,t){return e.get(toolbar_assertClassBrand(e,t))}function _classPrivateFieldSet(e,t,i){return e.set(toolbar_assertClassBrand(e,t),i),i}function toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Z=new WeakMap,Q=new WeakMap,J=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,ae=new WeakMap,se=new WeakMap,re=new WeakSet;class EditorToolbar{constructor(e){_classPrivateMethodInitSpec(this,re);_classPrivateFieldInitSpec(this,Z,null);_classPrivateFieldInitSpec(this,Q,null);_classPrivateFieldInitSpec(this,J,void 0);_classPrivateFieldInitSpec(this,ee,null);_classPrivateFieldInitSpec(this,te,null);_classPrivateFieldInitSpec(this,ie,null);_classPrivateFieldInitSpec(this,ae,null);_classPrivateFieldInitSpec(this,se,null);_classPrivateFieldSet(J,this,e);ne._||(ne._=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=_classPrivateFieldSet(Z,this,document.createElement("div"));e.classList.add("editToolbar","hidden");e.setAttribute("role","toolbar");const t=_classPrivateFieldGet(J,this)._uiManager._signal;if(t instanceof AbortSignal&&!t.aborted){e.addEventListener("contextmenu",noContextMenu,{signal:t});e.addEventListener("pointerdown",_pointerDown,{signal:t})}const i=_classPrivateFieldSet(ee,this,document.createElement("div"));i.className="buttons";e.append(i);const a=_classPrivateFieldGet(J,this).toolbarPosition;if(a){const{style:t}=e,i="ltr"===_classPrivateFieldGet(J,this)._uiManager.direction?1-a[0]:a[0];t.insetInlineEnd=100*i+"%";t.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return _classPrivateFieldGet(Z,this)}hide(){_classPrivateFieldGet(Z,this).classList.add("hidden");_classPrivateFieldGet(Q,this)?.hideDropdown()}show(){_classPrivateFieldGet(Z,this).classList.remove("hidden");_classPrivateFieldGet(te,this)?.shown();_classPrivateFieldGet(ie,this)?.shown()}addDeleteButton(){const{editorType:e,_uiManager:t}=_classPrivateFieldGet(J,this),i=document.createElement("button");i.classList.add("basic","deleteButton");i.tabIndex=0;i.setAttribute("data-l10n-id",ne._[e]);toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,i)&&i.addEventListener("click",e=>{t.delete()},{signal:t._signal});_classPrivateFieldGet(ee,this).append(i)}async addAltText(e){const t=await e.render();toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,t);_classPrivateFieldGet(ee,this).append(t,_classPrivateGetter(re,this,_get_divider));_classPrivateFieldSet(te,this,e)}addComment(e,t=null){if(_classPrivateFieldGet(ie,this))return;const i=e.renderForToolbar();if(!i)return;toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,i);const a=_classPrivateFieldSet(ae,this,_classPrivateGetter(re,this,_get_divider));if(t){_classPrivateFieldGet(ee,this).insertBefore(i,t);_classPrivateFieldGet(ee,this).insertBefore(a,t)}else _classPrivateFieldGet(ee,this).append(i,a);_classPrivateFieldSet(ie,this,e);e.toolbar=this}addColorPicker(e){if(_classPrivateFieldGet(Q,this))return;_classPrivateFieldSet(Q,this,e);const t=e.renderButton();toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,t);_classPrivateFieldGet(ee,this).append(t,_classPrivateGetter(re,this,_get_divider))}async addEditSignatureButton(e){const t=_classPrivateFieldSet(se,this,await e.renderEditButton(_classPrivateFieldGet(J,this)));if(t){toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,t);_classPrivateFieldGet(ee,this).append(t,_classPrivateGetter(re,this,_get_divider))}}removeButton(e){if("comment"===e){_classPrivateFieldGet(ie,this)?.removeToolbarCommentButton();_classPrivateFieldSet(ie,this,null);_classPrivateFieldGet(ae,this)?.remove();_classPrivateFieldSet(ae,this,null)}}async addButton(e,t){switch(e){case"colorPicker":t&&this.addColorPicker(t);break;case"altText":t&&await this.addAltText(t);break;case"editSignature":t&&await this.addEditSignatureButton(t);break;case"delete":this.addDeleteButton();break;case"comment":t&&this.addComment(t)}}async addButtonBefore(e,t,i){if(!t&&"comment"===e)return;const a=_classPrivateFieldGet(ee,this).querySelector(i);a&&"comment"===e&&this.addComment(t,a)}updateEditSignatureButton(e){_classPrivateFieldGet(se,this)&&(_classPrivateFieldGet(se,this).title=e)}remove(){_classPrivateFieldGet(Z,this).remove();_classPrivateFieldGet(Q,this)?.destroy();_classPrivateFieldSet(Q,this,null)}}function _pointerDown(e){e.stopPropagation()}function _focusIn(e){_classPrivateFieldGet(J,this)._focusEventsAllowed=!1;stopEvent(e)}function _focusOut(e){_classPrivateFieldGet(J,this)._focusEventsAllowed=!0;stopEvent(e)}function _addListenersToElement(e){const t=_classPrivateFieldGet(J,this)._uiManager._signal;if(!(t instanceof AbortSignal)||t.aborted)return!1;e.addEventListener("focusin",toolbar_assertClassBrand(re,this,_focusIn).bind(this),{capture:!0,signal:t});e.addEventListener("focusout",toolbar_assertClassBrand(re,this,_focusOut).bind(this),{capture:!0,signal:t});e.addEventListener("contextmenu",noContextMenu,{signal:t});return!0}function _get_divider(e){const t=document.createElement("div");t.className="divider";return t}var ne={_:null},oe=new WeakMap,le=new WeakMap,de=new WeakMap,ce=new WeakSet;class FloatingToolbar{constructor(e){_classPrivateMethodInitSpec(this,ce);_classPrivateFieldInitSpec(this,oe,null);_classPrivateFieldInitSpec(this,le,null);_classPrivateFieldInitSpec(this,de,void 0);_classPrivateFieldSet(de,this,e)}show(e,t,i){const[a,s]=toolbar_assertClassBrand(ce,this,_getLastPoint).call(this,t,i),{style:r}=_classPrivateFieldGet(le,this)||_classPrivateFieldSet(le,this,toolbar_assertClassBrand(ce,this,_render).call(this));e.append(_classPrivateFieldGet(le,this));r.insetInlineEnd=100*a+"%";r.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){_classPrivateFieldGet(le,this).remove()}}function _render(){const e=_classPrivateFieldSet(le,this,document.createElement("div"));e.className="editToolbar";e.setAttribute("role","toolbar");e.dir=_classPrivateFieldGet(de,this).direction;const t=_classPrivateFieldGet(de,this)._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener("contextmenu",noContextMenu,{signal:t});const i=_classPrivateFieldSet(oe,this,document.createElement("div"));i.className="buttons";e.append(i);_classPrivateFieldGet(de,this).hasCommentManager()&&toolbar_assertClassBrand(ce,this,_makeButton).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{_classPrivateFieldGet(de,this).commentSelection("floating_button")});toolbar_assertClassBrand(ce,this,_makeButton).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{_classPrivateFieldGet(de,this).highlightSelection("floating_button")});return e}function _getLastPoint(e,t){let i=0,a=0;for(const s of e){const e=s.y+s.height;if(e<i)continue;const r=s.x+(t?s.width:0);if(e>i){a=r;i=e}else t?r>a&&(a=r):r<a&&(a=r)}return[t?1-a:a,i]}function _makeButton(e,t,i,a){const s=document.createElement("button");s.classList.add("basic",e);s.tabIndex=0;s.setAttribute("data-l10n-id",t);const r=document.createElement("span");s.append(r);r.className="visuallyHidden";r.setAttribute("data-l10n-id",i);const n=_classPrivateFieldGet(de,this)._signal;if(n instanceof AbortSignal&&!n.aborted){s.addEventListener("contextmenu",noContextMenu,{signal:n});s.addEventListener("click",a,{signal:n})}_classPrivateFieldGet(oe,this).append(s)}const he=Object.freeze({internal:"58912017-f3ad-4506-bdd0-58916207bc49"});var _e,ue;function tools_defineProperty(e,t,i){return(t=function tools_toPropertyKey(e){var t=function tools_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function tools_classPrivateMethodInitSpec(e,t){tools_checkPrivateRedeclaration(e,t),t.add(e)}function tools_classPrivateFieldInitSpec(e,t,i){tools_checkPrivateRedeclaration(e,t),t.set(e,i)}function tools_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function tools_classPrivateFieldGet(e,t){return e.get(tools_assertClassBrand(e,t))}function tools_classPrivateFieldSet(e,t,i){return e.set(tools_assertClassBrand(e,t),i),i}function tools_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function bindEvents(e,t,i){for(const a of i)t.addEventListener(a,e[a].bind(e))}var pe=new WeakMap,ge=new WeakMap,me=new WeakMap,fe=new WeakMap,ve=new WeakMap,Pe=new WeakMap;class CurrentPointers{constructor(e){tools_classPrivateFieldInitSpec(this,pe,NaN);tools_classPrivateFieldInitSpec(this,ge,null);tools_classPrivateFieldInitSpec(this,me,NaN);tools_classPrivateFieldInitSpec(this,fe,null);tools_classPrivateFieldInitSpec(this,ve,null);tools_classPrivateFieldInitSpec(this,Pe,-1/0);window.addEventListener("pointerdown",({pointerType:e})=>{tools_classPrivateFieldSet(ve,this,e);tools_classPrivateFieldSet(Pe,this,performance.now())},{capture:!0,signal:e})}pickOwner(e,t){if(!e||t)return null;return performance.now()-tools_classPrivateFieldGet(Pe,this)<=we._?tools_classPrivateFieldGet(ve,this):null}claimFor(e){tools_classPrivateFieldSet(fe,this,e??null)}setPointerTypeIfUnset(e){tools_classPrivateFieldGet(fe,this)??tools_classPrivateFieldSet(fe,this,e)}initializeAndAddPointerId(e){(tools_classPrivateFieldGet(ge,this)||tools_classPrivateFieldSet(ge,this,new Set)).add(e)}setPointer(e,t){tools_classPrivateFieldGet(pe,this)||tools_classPrivateFieldSet(pe,this,t);tools_classPrivateFieldGet(fe,this)??tools_classPrivateFieldSet(fe,this,e)}setTimeStamp(e){tools_classPrivateFieldSet(me,this,e)}isSamePointerId(e){return tools_classPrivateFieldGet(pe,this)===e}isSamePointerIdOrRemove(e){if(tools_classPrivateFieldGet(pe,this)===e)return!0;tools_classPrivateFieldGet(ge,this)?.delete(e);return!1}isSamePointerType(e){return tools_classPrivateFieldGet(fe,this)===e}isInitializedAndDifferentPointerType(e){return null!==tools_classPrivateFieldGet(fe,this)&&!this.isSamePointerType(e)}isSameTimeStamp(e){return tools_classPrivateFieldGet(me,this)===e}isUsingMultiplePointers(){return tools_classPrivateFieldGet(ge,this)?.size>=1}clearPointerIds(){tools_classPrivateFieldSet(pe,this,NaN);tools_classPrivateFieldSet(ge,this,null)}clearTimeStamp(){tools_classPrivateFieldSet(me,this,NaN)}}var we={_:1e3},Fe=new WeakMap;class IdManager{constructor(){tools_classPrivateFieldInitSpec(this,Fe,0)}get id(){var e,t;return`${m}${tools_classPrivateFieldSet(Fe,this,(e=tools_classPrivateFieldGet(Fe,this),t=e++,e)),t}`}}var ye=new WeakMap,be=new WeakMap,Se=new WeakMap,Ce=new WeakSet;class ImageManager{constructor(){tools_classPrivateMethodInitSpec(this,Ce);tools_classPrivateFieldInitSpec(this,ye,getUuid());tools_classPrivateFieldInitSpec(this,be,0);tools_classPrivateFieldInitSpec(this,Se,null)}static get _isSVGFittingCanvas(){const e=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${r}"><rect width="1" height="1" style="fill:red;"/></svg>`,t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;return shadow(this,"_isSVGFittingCanvas",i.decode().then(()=>{t.drawImage(i,0,0,1,1,0,0,1,3);return 0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]}))}async getFromFile(e){const{lastModified:t,name:i,size:a,type:s}=e;return tools_assertClassBrand(Ce,this,_get).call(this,`${t}_${i}_${a}_${s}`,e)}async getFromUrl(e){return tools_assertClassBrand(Ce,this,_get).call(this,e,e)}async getFromBlob(e,t){const i=await t;return tools_assertClassBrand(Ce,this,_get).call(this,e,i)}async getFromId(e){tools_classPrivateFieldGet(Se,this)||tools_classPrivateFieldSet(Se,this,new Map);const t=tools_classPrivateFieldGet(Se,this).get(e);if(!t)return null;if(t.bitmap){t.refCounter+=1;return t}if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:e}=t;delete t.blobPromise;return this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){var i,a;tools_classPrivateFieldGet(Se,this)||tools_classPrivateFieldSet(Se,this,new Map);let s=tools_classPrivateFieldGet(Se,this).get(e);if(s?.bitmap){s.refCounter+=1;return s}const r=new OffscreenCanvas(t.width,t.height);r.getContext("2d").drawImage(t,0,0);s={bitmap:r.transferToImageBitmap(),id:`image_${tools_classPrivateFieldGet(ye,this)}_${tools_classPrivateFieldSet(be,this,(i=tools_classPrivateFieldGet(be,this),a=i++,i)),a}`,refCounter:1,isSvg:!1};tools_classPrivateFieldGet(Se,this).set(e,s);tools_classPrivateFieldGet(Se,this).set(s.id,s);return s}getSvgUrl(e){const t=tools_classPrivateFieldGet(Se,this).get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){tools_classPrivateFieldGet(Se,this)||tools_classPrivateFieldSet(Se,this,new Map);const t=tools_classPrivateFieldGet(Se,this).get(e);if(!t)return;t.refCounter-=1;if(0!==t.refCounter)return;const{bitmap:i}=t;if(!t.url&&!t.file){const e=new OffscreenCanvas(i.width,i.height);e.getContext("bitmaprenderer").transferFromImageBitmap(i);t.blobPromise=e.convertToBlob()}i.close?.();t.bitmap=null}isValidId(e){return e.startsWith(`image_${tools_classPrivateFieldGet(ye,this)}_`)}}_e=ImageManager;async function _get(e,t){tools_classPrivateFieldGet(Se,this)||tools_classPrivateFieldSet(Se,this,new Map);let i=tools_classPrivateFieldGet(Se,this).get(e);if(null===i)return null;if(i?.bitmap){i.refCounter+=1;return i}try{var a,s;i||={bitmap:null,id:`image_${tools_classPrivateFieldGet(ye,this)}_${tools_classPrivateFieldSet(be,this,(a=tools_classPrivateFieldGet(be,this),s=a++,a)),s}`,refCounter:0,isSvg:!1};let e;if("string"==typeof t){i.url=t;e=await fetchData(t,"blob")}else t instanceof File?e=i.file=t:t instanceof Blob&&(e=t);if("image/svg+xml"===e.type){const t=_e._isSVGFittingCanvas,a=new FileReader,s=new Image,r=new Promise((e,r)=>{s.onload=()=>{i.bitmap=s;i.isSvg=!0;e()};a.onload=async()=>{const e=i.svgUrl=a.result;s.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e};s.onerror=a.onerror=r});a.readAsDataURL(e);await r}else i.bitmap=await createImageBitmap(e);i.refCounter=1}catch(e){warn(e);i=null}tools_classPrivateFieldGet(Se,this).set(e,i);i&&tools_classPrivateFieldGet(Se,this).set(i.id,i);return i}var xe=new WeakMap,ke=new WeakMap,Ee=new WeakMap,Ae=new WeakMap;class CommandManager{constructor(e=128){tools_classPrivateFieldInitSpec(this,xe,[]);tools_classPrivateFieldInitSpec(this,ke,!1);tools_classPrivateFieldInitSpec(this,Ee,void 0);tools_classPrivateFieldInitSpec(this,Ae,-1);tools_classPrivateFieldSet(Ee,this,e)}add({cmd:e,undo:t,post:i,mustExec:a,type:s=NaN,overwriteIfSameType:r=!1,keepUndo:n=!1}){a&&e();if(tools_classPrivateFieldGet(ke,this))return;const o={cmd:e,undo:t,post:i,type:s};if(-1===tools_classPrivateFieldGet(Ae,this)){tools_classPrivateFieldGet(xe,this).length>0&&(tools_classPrivateFieldGet(xe,this).length=0);tools_classPrivateFieldSet(Ae,this,0);tools_classPrivateFieldGet(xe,this).push(o);return}if(r&&tools_classPrivateFieldGet(xe,this)[tools_classPrivateFieldGet(Ae,this)].type===s){n&&(o.undo=tools_classPrivateFieldGet(xe,this)[tools_classPrivateFieldGet(Ae,this)].undo);tools_classPrivateFieldGet(xe,this)[tools_classPrivateFieldGet(Ae,this)]=o;return}const l=tools_classPrivateFieldGet(Ae,this)+1;if(l===tools_classPrivateFieldGet(Ee,this))tools_classPrivateFieldGet(xe,this).splice(0,1);else{tools_classPrivateFieldSet(Ae,this,l);l<tools_classPrivateFieldGet(xe,this).length&&tools_classPrivateFieldGet(xe,this).splice(l)}tools_classPrivateFieldGet(xe,this).push(o)}undo(){if(-1===tools_classPrivateFieldGet(Ae,this))return;tools_classPrivateFieldSet(ke,this,!0);const{undo:e,post:t}=tools_classPrivateFieldGet(xe,this)[tools_classPrivateFieldGet(Ae,this)];e();t?.();tools_classPrivateFieldSet(ke,this,!1);tools_classPrivateFieldSet(Ae,this,tools_classPrivateFieldGet(Ae,this)-1)}redo(){if(tools_classPrivateFieldGet(Ae,this)<tools_classPrivateFieldGet(xe,this).length-1){tools_classPrivateFieldSet(Ae,this,tools_classPrivateFieldGet(Ae,this)+1);tools_classPrivateFieldSet(ke,this,!0);const{cmd:e,post:t}=tools_classPrivateFieldGet(xe,this)[tools_classPrivateFieldGet(Ae,this)];e();t?.();tools_classPrivateFieldSet(ke,this,!1)}}hasSomethingToUndo(){return-1!==tools_classPrivateFieldGet(Ae,this)}hasSomethingToRedo(){return tools_classPrivateFieldGet(Ae,this)<tools_classPrivateFieldGet(xe,this).length-1}cleanType(e){if(-1!==tools_classPrivateFieldGet(Ae,this)){for(let t=tools_classPrivateFieldGet(Ae,this);t>=0;t--)if(tools_classPrivateFieldGet(xe,this)[t].type!==e){tools_classPrivateFieldGet(xe,this).splice(t+1,tools_classPrivateFieldGet(Ae,this)-t);tools_classPrivateFieldSet(Ae,this,t);return}tools_classPrivateFieldGet(xe,this).length=0;tools_classPrivateFieldSet(Ae,this,-1)}}destroy(){tools_classPrivateFieldSet(xe,this,null)}reset(){tools_classPrivateFieldSet(xe,this,[]);tools_classPrivateFieldSet(Ae,this,-1);tools_classPrivateFieldSet(ke,this,!1)}}class KeyboardManager{constructor(e){this.callbacks=new Map;const{isMac:t}=FeatureTest.platform;for(const[i,a,s={}]of e){const e=i.some(e=>e.startsWith("mac+"));for(const r of i){let i=r;if(e){const e=r.startsWith("mac+");if(t!==e)continue;e&&(i=r.slice(4))}const[n,o]=_parseShortcut.call(KeyboardManager,i);null!==n&&this.callbacks.getOrInsertComputed(n,makeArr).push({callback:a,options:s,modifiers:o})}}}exec(e,t){let i=this.callbacks.get(t.key);if(!i){if(/^[a-z]$/i.test(t.key))return;const e=_codeToKey.call(KeyboardManager,t.code);if(null===e||e===t.key)return;i=this.callbacks.get(e);if(!i)return}const a=(t.altKey?KeyboardManager.ALT:0)|(t.ctrlKey?KeyboardManager.CTRL:0)|(t.metaKey?KeyboardManager.META:0)|(t.shiftKey?KeyboardManager.SHIFT:0),s=i.find(e=>e.modifiers===a);if(!s)return;const{callback:r,options:{bubbles:n=!1,args:o=[],checker:l=null}}=s;if(!l||l(e,t)){r.bind(e,...o,t)();n||stopEvent(t)}}}ue=KeyboardManager;function _parseShortcut(e){let t=null,i=0;for(let a of e.split("+")){a=a.trim();if(!a)continue;const s=a.toUpperCase(),r=ue[s];if(r)i|=r;else{if(null!==t){warn(`KeyboardManager: multiple keys in shortcut "${e}"`);break}t="SPACE"===s?" ":a}}null===t&&warn(`KeyboardManager: no key found in shortcut "${e}"`);return[t,i]}function _codeToKey(e){const t=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return t?t[1]?.toLowerCase()??t[2]:null}tools_defineProperty(KeyboardManager,"ALT",1);tools_defineProperty(KeyboardManager,"CTRL",2);tools_defineProperty(KeyboardManager,"META",4);tools_defineProperty(KeyboardManager,"SHIFT",8);class ColorManager{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);!function getColorValues(e){const t=document.createElement("span");t.style.visibility="hidden";t.style.colorScheme="only light";document.body.append(t);for(const i of e.keys()){t.style.color=i;const a=window.getComputedStyle(t).color;e.set(i,getRGB(a))}t.remove()}(e);return shadow(this,"_colors",e)}convert(e){const t=getRGB(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const[e,i]of this._colors)if(i.every((e,i)=>e===t[i]))return ColorManager._colorsMapping.get(e);return t}getHexCode(e){const t=this._colors.get(e);return t?Util.makeHexColor(...t):e}}tools_defineProperty(ColorManager,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));var Ge=new WeakMap,Be=new WeakMap,Me=new WeakMap,Ie=new WeakMap,Te=new WeakMap,De=new WeakMap,Le=new WeakMap,Re=new WeakMap,Oe=new WeakMap,Ne=new WeakMap,We=new WeakMap,je=new WeakMap,Ve=new WeakMap,Ue=new WeakMap,ze=new WeakMap,He=new WeakMap,$e=new WeakMap,Xe=new WeakMap,Ke=new WeakMap,qe=new WeakMap,Ye=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,Je=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,at=new WeakMap,st=new WeakMap,rt=new WeakMap,nt=new WeakMap,ot=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ht=new WeakMap,_t=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,ft=new WeakMap,vt=new WeakMap,Pt=new WeakMap,wt=new WeakMap,Ft=new WeakMap,yt=new WeakMap,bt=new WeakMap,St=new WeakMap,Ct=new WeakMap,xt=new WeakMap,kt=new WeakMap,Et=new WeakMap,At=new WeakSet;class AnnotationEditorUIManager{static get _keyboardManager(){const e=AnnotationEditorUIManager.prototype,arrowChecker=e=>tools_classPrivateFieldGet(Ct,e).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),textInputChecker=(e,{target:t})=>{if(t instanceof HTMLInputElement){const{type:e}=t;return"text"!==e&&"number"!==e}return!0},t=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return shadow(this,"_keyboardManager",new KeyboardManager([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:textInputChecker}],[["ctrl+z","mac+meta+z"],e.undo,{checker:textInputChecker}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:textInputChecker}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:textInputChecker}],[["Enter"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&tools_classPrivateFieldGet(Ct,e).contains(t)&&!e.isEnterHandled}],[["Space"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&tools_classPrivateFieldGet(Ct,e).contains(document.activeElement)}],[["Escape"],e.unselectAll],[["ArrowLeft"],e.translateSelectedEditors,{args:[-t,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:arrowChecker}],[["ArrowRight"],e.translateSelectedEditors,{args:[t,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:arrowChecker}],[["ArrowUp"],e.translateSelectedEditors,{args:[0,-t],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:arrowChecker}],[["ArrowDown"],e.translateSelectedEditors,{args:[0,t],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:arrowChecker}]]))}constructor(e,t,i,a,s,r,n,o,l,d,c,h,_,u,p,g,m){tools_classPrivateMethodInitSpec(this,At);tools_classPrivateFieldInitSpec(this,Ge,new AbortController);tools_classPrivateFieldInitSpec(this,Be,null);tools_classPrivateFieldInitSpec(this,Me,null);tools_classPrivateFieldInitSpec(this,Ie,new Map);tools_classPrivateFieldInitSpec(this,Te,new Map);tools_classPrivateFieldInitSpec(this,De,null);tools_classPrivateFieldInitSpec(this,Le,null);tools_classPrivateFieldInitSpec(this,Re,null);tools_classPrivateFieldInitSpec(this,Oe,null);tools_classPrivateFieldInitSpec(this,Ne,null);tools_classPrivateFieldInitSpec(this,We,new CommandManager);tools_classPrivateFieldInitSpec(this,je,null);tools_classPrivateFieldInitSpec(this,Ve,null);tools_classPrivateFieldInitSpec(this,Ue,null);tools_classPrivateFieldInitSpec(this,ze,0);tools_classPrivateFieldInitSpec(this,He,null);tools_classPrivateFieldInitSpec(this,$e,new Set);tools_classPrivateFieldInitSpec(this,Xe,null);tools_classPrivateFieldInitSpec(this,Ke,null);tools_classPrivateFieldInitSpec(this,qe,new Set);tools_defineProperty(this,"_editorUndoBar",null);tools_classPrivateFieldInitSpec(this,Ye,!1);tools_classPrivateFieldInitSpec(this,Ze,!1);tools_classPrivateFieldInitSpec(this,Qe,!1);tools_classPrivateFieldInitSpec(this,Je,null);tools_classPrivateFieldInitSpec(this,et,null);tools_classPrivateFieldInitSpec(this,tt,null);tools_classPrivateFieldInitSpec(this,it,null);tools_classPrivateFieldInitSpec(this,at,!1);tools_classPrivateFieldInitSpec(this,st,null);tools_classPrivateFieldInitSpec(this,rt,new IdManager);tools_classPrivateFieldInitSpec(this,nt,!1);tools_classPrivateFieldInitSpec(this,ot,!1);tools_classPrivateFieldInitSpec(this,lt,!1);tools_classPrivateFieldInitSpec(this,dt,null);tools_classPrivateFieldInitSpec(this,ct,null);tools_classPrivateFieldInitSpec(this,ht,null);tools_classPrivateFieldInitSpec(this,_t,null);tools_classPrivateFieldInitSpec(this,ut,null);tools_classPrivateFieldInitSpec(this,pt,f.NONE);tools_classPrivateFieldInitSpec(this,gt,!1);tools_classPrivateFieldInitSpec(this,mt,new Set);tools_classPrivateFieldInitSpec(this,ft,null);tools_classPrivateFieldInitSpec(this,vt,null);tools_classPrivateFieldInitSpec(this,Pt,null);tools_classPrivateFieldInitSpec(this,wt,null);tools_classPrivateFieldInitSpec(this,Ft,null);tools_classPrivateFieldInitSpec(this,yt,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});tools_classPrivateFieldInitSpec(this,bt,[0,0]);tools_classPrivateFieldInitSpec(this,St,null);tools_classPrivateFieldInitSpec(this,Ct,null);tools_classPrivateFieldInitSpec(this,xt,null);tools_classPrivateFieldInitSpec(this,kt,null);tools_classPrivateFieldInitSpec(this,Et,null);const v=this._signal=tools_classPrivateFieldGet(Ge,this).signal;tools_classPrivateFieldSet(Ct,this,e);tools_classPrivateFieldSet(xt,this,t);tools_classPrivateFieldSet(kt,this,i);tools_classPrivateFieldSet(Re,this,a);tools_classPrivateFieldSet(je,this,s);tools_classPrivateFieldSet(vt,this,r);tools_classPrivateFieldSet(Ft,this,o);this._eventBus=n;const P={signal:v,...he};n.on("editingaction",this.onEditingAction.bind(this),P);n.on("pagechanging",this.onPageChanging.bind(this),P);n.on("scalechanging",this.onScaleChanging.bind(this),P);n.on("rotationchanging",this.onRotationChanging.bind(this),P);n.on("setpreference",this.onSetPreference.bind(this),P);n.on("switchannotationeditorparams",e=>this.updateParams(e.type,e.value),P);window.addEventListener("pointerdown",()=>{tools_classPrivateFieldSet(ot,this,!0)},{capture:!0,signal:v});tools_classPrivateFieldSet(He,this,new CurrentPointers(v));window.addEventListener("pointerup",()=>{tools_classPrivateFieldSet(ot,this,!1)},{capture:!0,signal:v});window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:v});tools_assertClassBrand(At,this,_addSelectionListener).call(this);tools_assertClassBrand(At,this,_addDragAndDropListeners).call(this);tools_assertClassBrand(At,this,_addKeyboardManager).call(this);tools_classPrivateFieldSet(Oe,this,o.annotationStorage);tools_classPrivateFieldSet(Je,this,o.filterFactory);tools_classPrivateFieldSet(Pt,this,l);tools_classPrivateFieldSet(it,this,d||null);tools_classPrivateFieldSet(Ye,this,c);tools_classPrivateFieldSet(Ze,this,h);tools_classPrivateFieldSet(Qe,this,_);tools_classPrivateFieldSet(ut,this,u||null);this.viewParameters={realScale:PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0};this.isShiftKeyDown=!1;this._editorUndoBar=p||null;this._supportsPinchToZoom=!1!==g;this._keepToolbarInPage=!0===m;s?.setSidebarUiManager(this)}destroy(){tools_classPrivateFieldGet(Et,this)?.resolve();tools_classPrivateFieldSet(Et,this,null);tools_classPrivateFieldGet(Ge,this)?.abort();tools_classPrivateFieldSet(Ge,this,null);this._signal=null;for(const e of tools_classPrivateFieldGet(Te,this).values())e.destroy();tools_classPrivateFieldGet(Te,this).clear();tools_classPrivateFieldGet(Ie,this).clear();tools_classPrivateFieldGet(qe,this).clear();tools_classPrivateFieldGet(_t,this)?.clear();tools_classPrivateFieldSet(Be,this,null);tools_classPrivateFieldGet(mt,this).clear();tools_classPrivateFieldGet(We,this).destroy();tools_classPrivateFieldGet(Re,this)?.destroy();tools_classPrivateFieldGet(je,this)?.destroy();tools_classPrivateFieldGet(vt,this)?.destroy();tools_classPrivateFieldGet(st,this)?.hide();tools_classPrivateFieldSet(st,this,null);tools_classPrivateFieldGet(ht,this)?.destroy();tools_classPrivateFieldSet(ht,this,null);tools_classPrivateFieldSet(Me,this,null);if(tools_classPrivateFieldGet(et,this)){clearTimeout(tools_classPrivateFieldGet(et,this));tools_classPrivateFieldSet(et,this,null)}if(tools_classPrivateFieldGet(St,this)){clearTimeout(tools_classPrivateFieldGet(St,this));tools_classPrivateFieldSet(St,this,null)}this._editorUndoBar?.destroy();tools_classPrivateFieldSet(Ft,this,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return tools_classPrivateFieldGet(ut,this)}get useNewAltTextFlow(){return tools_classPrivateFieldGet(Ze,this)}get useNewAltTextWhenAddingImage(){return tools_classPrivateFieldGet(Qe,this)}get hcmFilter(){return shadow(this,"hcmFilter",tools_classPrivateFieldGet(Pt,this)?tools_classPrivateFieldGet(Je,this).addHCMFilter(tools_classPrivateFieldGet(Pt,this).foreground,tools_classPrivateFieldGet(Pt,this).background):"none")}get direction(){return shadow(this,"direction",getComputedStyle(tools_classPrivateFieldGet(Ct,this)).direction)}get _highlightColors(){return shadow(this,"_highlightColors",tools_classPrivateFieldGet(it,this)?new Map(tools_classPrivateFieldGet(it,this).split(",").map(e=>{(e=e.split("=").map(e=>e.trim()))[1]=e[1].toUpperCase();return e})):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return shadow(this,"highlightColors",null);const t=new Map,i=!!tools_classPrivateFieldGet(Pt,this);for(const[a,s]of e){const e=a.endsWith("_HCM");i&&e?t.set(a.replace("_HCM",""),s):i||e||t.set(a,s)}return shadow(this,"highlightColors",t)}get highlightColorNames(){return shadow(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){if(e){this.unselectAll();this.disableUserSelect(!0)}else this.disableUserSelect(!1);tools_classPrivateFieldSet(Ue,this,e)}setMainHighlightColorPicker(e){tools_classPrivateFieldSet(ht,this,e)}editAltText(e,t=!1){tools_classPrivateFieldGet(Re,this)?.editAltText(this,e,t)}hasCommentManager(){return!!tools_classPrivateFieldGet(je,this)}editComment(e,t,i,a){tools_classPrivateFieldGet(je,this)?.showDialog(this,e,t,i,a)}selectComment(e,t){const i=tools_classPrivateFieldGet(Te,this).get(e),a=i?.getEditorByUID(t);a?.toggleComment(!0,!0)}updateComment(e){tools_classPrivateFieldGet(je,this)?.updateComment(e.getData())}updatePopupColor(e){tools_classPrivateFieldGet(je,this)?.updatePopupColor(e)}removeComment(e){tools_classPrivateFieldGet(je,this)?.removeComments([e.uid])}deleteComment(e,t){const undo=()=>{e.comment=t};this.addCommands({cmd:()=>{this._editorUndoBar?.show(undo,"comment");this.toggleComment(null);e.comment=null},undo,mustExec:!0})}toggleComment(e,t,i=void 0){tools_classPrivateFieldGet(je,this)?.toggleCommentPopup(e,t,i)}makeCommentColor(e,t){return e&&tools_classPrivateFieldGet(je,this)?.makeCommentColor(e,t)||null}getCommentDialogElement(){return tools_classPrivateFieldGet(je,this)?.dialogElement||null}async waitForEditorsRendered(e){if(tools_classPrivateFieldGet(Te,this).has(e-1))return;const{resolve:t,promise:i}=Promise.withResolvers(),onEditorsRendered=i=>{if(i.pageNumber===e){this._eventBus.off("editorsrendered",onEditorsRendered);t()}};this._eventBus.on("editorsrendered",onEditorsRendered,he);await i}getSignature(e){tools_classPrivateFieldGet(vt,this)?.getSignature({uiManager:this,editor:e})}get signatureManager(){return tools_classPrivateFieldGet(vt,this)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal,...he});this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){if("enableNewAltTextWhenAddingImage"===e)tools_classPrivateFieldSet(Qe,this,t)}onPageChanging({pageNumber:e}){tools_classPrivateFieldSet(ze,this,e-1)}deletePage(e){for(const t of this.getEditors(e))t.remove();tools_classPrivateFieldGet(Te,this).delete(e);tools_classPrivateFieldGet(ze,this)===e&&tools_classPrivateFieldSet(ze,this,0)}focusMainContainer(){tools_classPrivateFieldGet(Ct,this).focus()}findParent(e,t){for(const i of tools_classPrivateFieldGet(Te,this).values()){const{x:a,y:s,width:r,height:n}=i.div.getBoundingClientRect();if(e>=a&&e<=a+r&&t>=s&&t<=s+n)return i}return null}disableUserSelect(e=!1){tools_classPrivateFieldGet(xt,this).classList.toggle("noUserSelect",e)}addShouldRescale(e){tools_classPrivateFieldGet(qe,this).add(e)}removeShouldRescale(e){tools_classPrivateFieldGet(qe,this).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove();this.viewParameters.realScale=e*PixelsPerInch.PDF_TO_CSS_UNITS;for(const e of tools_classPrivateFieldGet(qe,this))e.onScaleChanging();tools_classPrivateFieldGet(Ue,this)?.onScaleChanging()}onRotationWillChange(e){tools_classPrivateFieldGet(Ue,this)?.commitOrRemove();this.viewParameters.rotation=e}onRotationChanging({pagesRotation:e}){this.commitOrRemove();this.viewParameters.rotation=e}highlightSelection(e="",t=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:a,anchorOffset:s,focusNode:r,focusOffset:n}=i,o=i.toString(),l=tools_assertClassBrand(At,this,_getAnchorElementForSelection).call(this,i).closest(".textLayer"),d=this.getSelectionBoxes(l);if(!d)return;i.empty();const c=tools_assertClassBrand(At,this,_getLayerForTextLayer).call(this,l),h=tools_classPrivateFieldGet(pt,this)===f.NONE,callback=()=>{const i=c?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:d,anchorNode:a,anchorOffset:s,focusNode:r,focusOffset:n,text:o});h&&this.showAllEditors("highlight",!0,!0);t&&i?.editComment()};h?this.switchToMode(f.HIGHLIGHT,callback):callback()}commentSelection(e=""){this.highlightSelection(e,!0)}endCurrentEditing(){this.commitOrRemove();this.currentLayer?.endDrawingSession(!1)}getAndRemoveDataFromAnnotationStorage(e){if(!tools_classPrivateFieldGet(Oe,this))return null;const t=`${m}${e}`,i=tools_classPrivateFieldGet(Oe,this).getRawValue(t);i&&tools_classPrivateFieldGet(Oe,this).remove(t);return i}addToAnnotationStorage(e){e.isEmpty()||!tools_classPrivateFieldGet(Oe,this)||tools_classPrivateFieldGet(Oe,this).has(e.id)||tools_classPrivateFieldGet(Oe,this).setValue(e.id,e)}a11yAlert(e,t=null){const i=tools_classPrivateFieldGet(kt,this);if(i){i.setAttribute("data-l10n-id",e);t?i.setAttribute("data-l10n-args",JSON.stringify(t)):i.removeAttribute("data-l10n-args")}}blur(){this.isShiftKeyDown=!1;if(tools_classPrivateFieldGet(at,this)){tools_classPrivateFieldSet(at,this,!1);tools_assertClassBrand(At,this,_onSelectEnd).call(this,"main_toolbar")}if(!this.hasSelection)return;const{activeElement:e}=document;for(const t of tools_classPrivateFieldGet(mt,this))if(t.div.contains(e)){tools_classPrivateFieldSet(ct,this,[t,e]);t._focusEventsAllowed=!1;break}}focus(){if(!tools_classPrivateFieldGet(ct,this))return;const[e,t]=tools_classPrivateFieldGet(ct,this);tools_classPrivateFieldSet(ct,this,null);t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal});t.focus()}addEditListeners(){tools_assertClassBrand(At,this,_addKeyboardManager).call(this);this.setEditingState(!0)}removeEditListeners(){tools_assertClassBrand(At,this,_removeKeyboardManager).call(this);this.setEditingState(!1)}dragOver(e){if(tools_classPrivateFieldGet(Ke,this))for(const{type:t}of e.dataTransfer.items)for(const i of tools_classPrivateFieldGet(Ke,this))if(i.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy";e.preventDefault();return}}drop(e){if(tools_classPrivateFieldGet(Ke,this))for(const t of e.dataTransfer.items)for(const i of tools_classPrivateFieldGet(Ke,this))if(i.isHandlingMimeForPasting(t.type)){i.paste(t,this.currentLayer);e.preventDefault();return}}copy(e){e.preventDefault();tools_classPrivateFieldGet(Be,this)?.commitOrRemove();if(!this.hasSelection)return;const t=[];for(const e of tools_classPrivateFieldGet(mt,this)){const i=e.serialize(!0);i&&t.push(i)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e);this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;if(!tools_classPrivateFieldGet(Ke,this))return;for(const e of t.items)for(const t of tools_classPrivateFieldGet(Ke,this))if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}const i=t.getData("application/pdfjs");await this.addSerializedEditor(i)}async addSerializedEditor(e,t=!1,i=!1,a=!0,s=!0){if(!e)return;try{"string"==typeof e&&(e=JSON.parse(e))}catch(e){warn(`paste: "${e.message}".`);return}if(!Array.isArray(e))return;const r=tools_classPrivateFieldGet(pt,this);t&&r===f.NONE&&await this.updateMode(f.FREETEXT);this.unselectAll();tools_classPrivateFieldSet(gt,this,!0);try{const t=[];for(const s of e){const e=void 0===s.pageIndex,r=a||e,n=r?this.currentLayer:this.getLayer(s.pageIndex);if(!n){warn(`addSerializedEditor: the annotation editor layer for page ${r?tools_classPrivateFieldGet(ze,this):s.pageIndex} is not rendered yet. Wait for the "annotationeditorlayerrendered" event (not "annotationlayerrendered") before adding an annotation to that page.`);continue}const o=await n.deserialize(s);if(o){o.doNotMove=i;t.push(o)}else warn(`addSerializedEditor: could not restore the annotation of type ${s.annotationType}. Skipping it.`)}const cmd=()=>{for(const e of t)tools_assertClassBrand(At,this,_addEditorToLayer).call(this,e);s&&tools_assertClassBrand(At,this,_selectEditors).call(this,t)},undo=()=>{for(const e of t)e.remove()};this.addCommands({cmd,undo,mustExec:!0});for(const e of t)e._dispatchAddedEvent()}catch(e){warn(`paste: "${e.message}".`)}finally{tools_classPrivateFieldSet(gt,this,!1)}t&&r!==tools_classPrivateFieldGet(pt,this)&&await this.updateMode(r)}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0);tools_classPrivateFieldGet(pt,this)===f.NONE||this.isEditorHandlingKeyboard||AnnotationEditorUIManager._keyboardManager.exec(this,e)}keyup(e){if(this.isShiftKeyDown&&"Shift"===e.key){this.isShiftKeyDown=!1;if(tools_classPrivateFieldGet(at,this)){tools_classPrivateFieldSet(at,this,!1);tools_assertClassBrand(At,this,_onSelectEnd).call(this,"main_toolbar")}}}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}updatePageIndex(e,t){for(const i of tools_classPrivateFieldGet(Le,this).get(e)||[])i.pageIndex=t;const i=tools_classPrivateFieldGet(De,this).get(e);if(i){i.pageIndex=t;tools_classPrivateFieldGet(Te,this).set(t,i);tools_classPrivateFieldGet(nt,this)?i.enable():i.disable()}}startUpdatePages(){tools_classPrivateFieldSet(De,this,new Map(tools_classPrivateFieldGet(Te,this)));tools_classPrivateFieldGet(Te,this).clear();const e=tools_classPrivateFieldSet(Le,this,new Map),saveEditor=t=>{e.getOrInsertComputed(t.pageIndex,makeArr).push(t)};for(const e of tools_classPrivateFieldGet(Ie,this).values())saveEditor(e);for(const[e,t]of tools_classPrivateFieldGet(Oe,this))e.startsWith(m)&&!tools_classPrivateFieldGet(Ie,this).has(e)&&Number.isInteger(t?.pageIndex)&&saveEditor(t)}endUpdatePages(){tools_classPrivateFieldSet(De,this,null);tools_classPrivateFieldSet(Le,this,null)}clonePage(e,t){for(const i of this.getEditors(e)){const e=i.serialize(i.mode!==f.HIGHLIGHT);if(e){e.pageIndex=t;e.id=this.getId();e.isClone=!0;delete e.popupRef;tools_classPrivateFieldGet(Oe,this).setValue(e.id,e)}}}findClonesForPage(e){const t=[],{pageIndex:i}=e;for(const[a,s]of tools_classPrivateFieldGet(Oe,this))if(s.pageIndex===i&&s.isClone){tools_classPrivateFieldGet(Oe,this).remove(a);t.push(e.deserialize(s).then(t=>{if(t){t.isClone=!0;e.addOrRebuild(t)}}))}return Promise.all(t)}setEditingState(e){if(e){tools_assertClassBrand(At,this,_addFocusManager).call(this);tools_assertClassBrand(At,this,_addCopyPasteListeners).call(this);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{isEditing:tools_classPrivateFieldGet(pt,this)!==f.NONE,isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this),hasSomethingToUndo:tools_classPrivateFieldGet(We,this).hasSomethingToUndo(),hasSomethingToRedo:tools_classPrivateFieldGet(We,this).hasSomethingToRedo(),hasSelectedEditor:!1})}else{tools_assertClassBrand(At,this,_removeFocusManager).call(this);tools_assertClassBrand(At,this,_removeCopyPasteListeners).call(this);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{isEditing:!1});this.disableUserSelect(!1)}}registerEditorTypes(e){if(!tools_classPrivateFieldGet(Ke,this)){tools_classPrivateFieldSet(Ke,this,e);for(const e of tools_classPrivateFieldGet(Ke,this))tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.defaultPropertiesToUpdate)}}getId(){return tools_classPrivateFieldGet(rt,this).id}get currentLayer(){return tools_classPrivateFieldGet(Te,this).get(tools_classPrivateFieldGet(ze,this))}getLayer(e){return tools_classPrivateFieldGet(Te,this).get(e)}get isRestoringAnnotations(){return tools_classPrivateFieldGet(gt,this)}get currentPageIndex(){return tools_classPrivateFieldGet(ze,this)}get currentPointers(){return tools_classPrivateFieldGet(He,this)}addLayer(e){tools_classPrivateFieldGet(Te,this).set(e.pageIndex,e);tools_classPrivateFieldGet(nt,this)?e.enable():e.disable()}removeLayer(e){tools_classPrivateFieldGet(Te,this).delete(e.pageIndex)}async updateMode(e,t=null,i=!1,a=!1,s=!1,r=!1){if(tools_classPrivateFieldGet(pt,this)===e)return;const n=tools_classPrivateFieldGet(He,this).pickOwner(i,a);if(tools_classPrivateFieldGet(Et,this)){await tools_classPrivateFieldGet(Et,this).promise;if(!tools_classPrivateFieldGet(Et,this))return}tools_classPrivateFieldSet(Et,this,Promise.withResolvers());tools_classPrivateFieldGet(Ue,this)?.commitOrRemove();tools_classPrivateFieldGet(pt,this)===f.POPUP&&tools_classPrivateFieldGet(je,this)?.hideSidebar();tools_classPrivateFieldGet(je,this)?.destroyPopup();tools_classPrivateFieldSet(pt,this,e);tools_classPrivateFieldGet(He,this).claimFor(n);if(e!==f.NONE){for(const e of tools_classPrivateFieldGet(Ie,this).values())e.addStandaloneCommentButton();e===f.SIGNATURE&&await(tools_classPrivateFieldGet(vt,this)?.loadSignatures());this.setEditingState(!0);await tools_assertClassBrand(At,this,_enableAll).call(this);this.unselectAll();for(const t of tools_classPrivateFieldGet(Te,this).values())t.updateMode(e);if(e===f.POPUP){tools_classPrivateFieldGet(Me,this)||tools_classPrivateFieldSet(Me,this,await tools_classPrivateFieldGet(Ft,this).getAnnotationsByType(new Set(tools_classPrivateFieldGet(Ke,this).map(e=>e._editorType))));const e=new Set,t=[];for(const i of tools_classPrivateFieldGet(Ie,this).values()){const{annotationElementId:a,hasComment:s,deleted:r}=i;a&&e.add(a);s&&!r&&t.push(i.getData())}for(const i of tools_classPrivateFieldGet(Me,this)){const{id:a,popupRef:s,contentsObj:r}=i;s&&r?.str&&!e.has(a)&&!tools_classPrivateFieldGet($e,this).has(a)&&t.push(i)}tools_classPrivateFieldGet(je,this)?.showSidebar(t)}if(t){for(const e of tools_classPrivateFieldGet(Ie,this).values())if(e.uid===t){this.setSelected(e);r?e.editComment():s?e.enterInEditMode():e.focus()}else e.unselect();tools_classPrivateFieldGet(Et,this).resolve()}else{a&&this.addNewEditorFromKeyboard();tools_classPrivateFieldGet(Et,this).resolve()}}else{this.setEditingState(!1);tools_assertClassBrand(At,this,_disableAll).call(this);for(const e of tools_classPrivateFieldGet(Ie,this).values())e.hideStandaloneCommentButton();this._editorUndoBar?.hide();this.toggleComment(null);tools_classPrivateFieldGet(Et,this).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==tools_classPrivateFieldGet(pt,this)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,t){if(tools_classPrivateFieldGet(Ke,this)){switch(e){case v.CREATE:this.currentLayer.addNewEditor(t);return;case v.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}});(tools_classPrivateFieldGet(wt,this)||tools_classPrivateFieldSet(wt,this,new Map)).set(e,t);this.showAllEditors("highlight",t)}if(this.hasSelection){for(const i of tools_classPrivateFieldGet(mt,this))i.updateParams(e,t);if(e===v.HIGHLIGHT_COLOR||e===v.HIGHLIGHT_THICKNESS)for(const i of tools_classPrivateFieldGet(Ke,this))i.updateDefaultParams(e,t)}else for(const i of tools_classPrivateFieldGet(Ke,this))i.updateDefaultParams(e,t)}}showAllEditors(e,t,i=!1){for(const i of tools_classPrivateFieldGet(Ie,this).values())i.editorType===e&&i.show(t);(tools_classPrivateFieldGet(wt,this)?.get(v.HIGHLIGHT_SHOW_ALL)??!0)!==t&&tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,[[v.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(tools_classPrivateFieldGet(lt,this)!==e){tools_classPrivateFieldSet(lt,this,e);for(const t of tools_classPrivateFieldGet(Te,this).values()){e?t.disableClick():t.enableClick();t.div.classList.toggle("waiting",e)}}}*getEditors(e){for(const t of tools_classPrivateFieldGet(Ie,this).values())t.pageIndex===e&&(yield t)}getEditor(e){return tools_classPrivateFieldGet(Ie,this).get(e)}addEditor(e){tools_classPrivateFieldGet(Ie,this).set(e.id,e)}removeEditor(e){if(e.div.contains(document.activeElement)){tools_classPrivateFieldGet(et,this)&&clearTimeout(tools_classPrivateFieldGet(et,this));tools_classPrivateFieldSet(et,this,setTimeout(()=>{this.focusMainContainer();tools_classPrivateFieldSet(et,this,null)},0))}tools_classPrivateFieldGet(Ie,this).delete(e.id);e.annotationElementId&&tools_classPrivateFieldGet(_t,this)?.delete(e.annotationElementId);this.unselect(e);e.annotationElementId&&tools_classPrivateFieldGet($e,this).has(e.annotationElementId)||tools_classPrivateFieldGet(Oe,this)?.remove(e.id)}addDeletedAnnotationElement(e){tools_classPrivateFieldGet($e,this).add(e.annotationElementId);this.addChangedExistingAnnotation(e);e.deleted=!0}isDeletedAnnotationElement(e){return tools_classPrivateFieldGet($e,this).has(e)}removeDeletedAnnotationElement(e){tools_classPrivateFieldGet($e,this).delete(e.annotationElementId);this.removeChangedExistingAnnotation(e);e.deleted=!1}setActiveEditor(e){if(tools_classPrivateFieldGet(Be,this)!==e){tools_classPrivateFieldSet(Be,this,e);e&&tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate)}}updateUI(e){(function tools_classPrivateGetter(e,t,i){return i(tools_assertClassBrand(e,t))})(At,this,_get_lastSelectedEditor)===e&&tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(tools_classPrivateFieldGet(mt,this).has(e)){tools_classPrivateFieldGet(mt,this).delete(e);e.unselect();tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}else{tools_classPrivateFieldGet(mt,this).add(e);e.select();tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!0})}}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid});tools_classPrivateFieldGet(Ue,this)?.commitOrRemove();for(const t of tools_classPrivateFieldGet(mt,this))t!==e&&t.unselect();tools_classPrivateFieldGet(je,this)?.destroyPopup();tools_classPrivateFieldGet(mt,this).clear();tools_classPrivateFieldGet(mt,this).add(e);e.select();tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return tools_classPrivateFieldGet(mt,this).values().next().value}unselect(e){e.unselect();tools_classPrivateFieldGet(mt,this).delete(e);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==tools_classPrivateFieldGet(mt,this).size}get isEnterHandled(){return 1===tools_classPrivateFieldGet(mt,this).size&&this.firstSelectedEditor.isEnterHandled}undo(){tools_classPrivateFieldGet(We,this).undo();tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:tools_classPrivateFieldGet(We,this).hasSomethingToUndo(),hasSomethingToRedo:tools_classPrivateFieldGet(We,this).hasSomethingToRedo(),isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this)});this._editorUndoBar?.hide()}redo(){tools_classPrivateFieldGet(We,this).redo();tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:tools_classPrivateFieldGet(We,this).hasSomethingToUndo(),hasSomethingToRedo:tools_classPrivateFieldGet(We,this).hasSomethingToRedo(),isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this)})}addCommands(e){tools_classPrivateFieldGet(We,this).add(e);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this)})}cleanUndoStack(e){tools_classPrivateFieldGet(We,this).cleanType(e)}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const t=e?[e]:[...tools_classPrivateFieldGet(mt,this)],undo=()=>{for(const e of t)tools_assertClassBrand(At,this,_addEditorToLayer).call(this,e)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(undo,1===t.length?t[0].editorType:t.length);for(const e of t)e.remove()},undo,mustExec:!0})}commitOrRemove(){tools_classPrivateFieldGet(Be,this)?.commitOrRemove()}hasSomethingToControl(){return tools_classPrivateFieldGet(Be,this)||this.hasSelection}selectAll(){for(const e of tools_classPrivateFieldGet(mt,this))e.commit();tools_assertClassBrand(At,this,_selectEditors).call(this,tools_classPrivateFieldGet(Ie,this).values())}unselectAll(){if(tools_classPrivateFieldGet(Be,this)){tools_classPrivateFieldGet(Be,this).commitOrRemove();if(tools_classPrivateFieldGet(pt,this)!==f.NONE)return}if(!tools_classPrivateFieldGet(Ue,this)?.commitOrRemove()){tools_classPrivateFieldGet(je,this)?.destroyPopup();if(this.hasSelection){for(const e of tools_classPrivateFieldGet(mt,this))e.unselect();tools_classPrivateFieldGet(mt,this).clear();tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!1})}}}translateSelectedEditors(e,t,i=!1){i||this.commitOrRemove();if(!this.hasSelection)return;tools_classPrivateFieldGet(bt,this)[0]+=e;tools_classPrivateFieldGet(bt,this)[1]+=t;const[a,s]=tools_classPrivateFieldGet(bt,this),r=[...tools_classPrivateFieldGet(mt,this)];tools_classPrivateFieldGet(St,this)&&clearTimeout(tools_classPrivateFieldGet(St,this));tools_classPrivateFieldSet(St,this,setTimeout(()=>{tools_classPrivateFieldSet(St,this,null);tools_classPrivateFieldGet(bt,this)[0]=tools_classPrivateFieldGet(bt,this)[1]=0;this.addCommands({cmd:()=>{for(const e of r)if(tools_classPrivateFieldGet(Ie,this).has(e.id)){e.translateInPage(a,s);e.translationDone()}},undo:()=>{for(const e of r)if(tools_classPrivateFieldGet(Ie,this).has(e.id)){e.translateInPage(-a,-s);e.translationDone()}},mustExec:!1})},1e3));for(const i of r){i.translateInPage(e,t);i.translationDone()}}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0);tools_classPrivateFieldSet(Xe,this,new Map);for(const e of tools_classPrivateFieldGet(mt,this))tools_classPrivateFieldGet(Xe,this).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!tools_classPrivateFieldGet(Xe,this))return!1;this.disableUserSelect(!1);const e=tools_classPrivateFieldGet(Xe,this);tools_classPrivateFieldSet(Xe,this,null);let t=!1;for(const[{x:i,y:a,pageIndex:s},r]of e){r.newX=i;r.newY=a;r.newPageIndex=s;t||=i!==r.savedX||a!==r.savedY||s!==r.savedPageIndex}if(!t)return!1;const move=(e,t,i,a)=>{if(tools_classPrivateFieldGet(Ie,this).has(e.id)){const s=tools_classPrivateFieldGet(Te,this).get(a);if(s)e._setParentAndPosition(s,t,i);else{e.pageIndex=a;e.x=t;e.y=i}}};this.addCommands({cmd:()=>{for(const[t,{newX:i,newY:a,newPageIndex:s,savedX:r,savedY:n,savedPageIndex:o}]of e){move(t,i,a,s);this._eventBus?.dispatch("annotation-editor-event",{source:t,type:"moved",page:s+1,editorType:t.constructor.name,id:t.uid,previousValue:{x:r,y:n,page:o+1},value:{x:i,y:a,page:s+1}})}},undo:()=>{for(const[t,{savedX:i,savedY:a,savedPageIndex:s}]of e)move(t,i,a,s)},mustExec:!0});return!0}dragSelectedEditors(e,t){if(tools_classPrivateFieldGet(Xe,this))for(const i of tools_classPrivateFieldGet(Xe,this).keys())i.drag(e,t)}rebuild(e){if(null===e.parent){const t=this.getLayer(e.pageIndex);if(t){t.changeParent(e);t.addOrRebuild(e)}else{this.addEditor(e);this.addToAnnotationStorage(e);e.rebuild()}}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===tools_classPrivateFieldGet(mt,this).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return tools_classPrivateFieldGet(Be,this)===e}getActive(){return tools_classPrivateFieldGet(Be,this)}getMode(){return tools_classPrivateFieldGet(pt,this)}isEditingMode(){return tools_classPrivateFieldGet(pt,this)!==f.NONE}get imageManager(){return shadow(this,"imageManager",new ImageManager)}removeEditors(e=()=>!0){let t=!1;tools_classPrivateFieldGet(Ie,this).forEach(i=>{if(i?.serialize()&&e(i.serialize())){i.remove();t=!0}});if(t){tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:!1,hasSomethingToRedo:!1,isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this)});tools_classPrivateFieldGet(We,this).reset()}}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let i=0,a=t.rangeCount;i<a;i++)if(!e.contains(t.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:a,width:s,height:r}=e.getBoundingClientRect();let n;switch(e.getAttribute("data-main-rotation")){case"90":n=(e,t,n,o)=>({x:(t-a)/r,y:1-(e+n-i)/s,width:o/r,height:n/s});break;case"180":n=(e,t,n,o)=>({x:1-(e+n-i)/s,y:1-(t+o-a)/r,width:n/s,height:o/r});break;case"270":n=(e,t,n,o)=>({x:1-(t+o-a)/r,y:(e-i)/s,width:o/r,height:n/s});break;default:n=(e,t,n,o)=>({x:(e-i)/s,y:(t-a)/r,width:n/s,height:o/r})}const o=[];for(let e=0,i=t.rangeCount;e<i;e++){const i=t.getRangeAt(e);if(!i.collapsed)for(const{x:e,y:t,width:a,height:s}of i.getClientRects())0!==a&&0!==s&&o.push(n(e,t,a,s))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:e,id:t}){(tools_classPrivateFieldGet(Ne,this)||tools_classPrivateFieldSet(Ne,this,new Map)).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){tools_classPrivateFieldGet(Ne,this)?.delete(e)}renderAnnotationElement(e){const t=tools_classPrivateFieldGet(Ne,this)?.get(e.data.id);if(!t)return;const i=tools_classPrivateFieldGet(Oe,this).getRawValue(t);i&&(tools_classPrivateFieldGet(pt,this)!==f.NONE||i.hasBeenModified)&&i.renderAnnotationElement(e)}setMissingCanvas(e,t,i){const a=tools_classPrivateFieldGet(_t,this)?.get(e);if(a){a.setCanvas(t,i);tools_classPrivateFieldGet(_t,this).delete(e)}}addMissingCanvas(e,t){(tools_classPrivateFieldGet(_t,this)||tools_classPrivateFieldSet(_t,this,new Map)).set(e,t)}}function _getAnchorElementForSelection({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function _getLayerForTextLayer(e){const{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(const t of tools_classPrivateFieldGet(Te,this).values())if(t.hasTextLayer(e))return t;return null}function _displayFloatingToolbar(){const e=document.getSelection();if(!e||e.isCollapsed)return;const t=tools_assertClassBrand(At,this,_getAnchorElementForSelection).call(this,e).closest(".textLayer"),i=this.getSelectionBoxes(t);if(i){tools_classPrivateFieldGet(st,this)||tools_classPrivateFieldSet(st,this,new FloatingToolbar(this));tools_classPrivateFieldGet(st,this).show(t,i,"ltr"===this.direction)}}function _selectionChange(){const e=document.getSelection();if(!e||e.isCollapsed){if(tools_classPrivateFieldGet(ft,this)){tools_classPrivateFieldGet(st,this)?.hide();tools_classPrivateFieldSet(ft,this,null);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedText:!1})}return}const{anchorNode:t}=e;if(t===tools_classPrivateFieldGet(ft,this))return;const i=tools_assertClassBrand(At,this,_getAnchorElementForSelection).call(this,e).closest(".textLayer");if(i){tools_classPrivateFieldGet(st,this)?.hide();tools_classPrivateFieldSet(ft,this,t);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedText:!0});if(tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT||tools_classPrivateFieldGet(pt,this)===f.NONE){tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0);tools_classPrivateFieldSet(at,this,this.isShiftKeyDown);if(!this.isShiftKeyDown){const e=tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT?tools_assertClassBrand(At,this,_getLayerForTextLayer).call(this,i):null;e?.toggleDrawing();if(tools_classPrivateFieldGet(ot,this)){const t=new AbortController,i=this.combinedSignal(t),pointerup=i=>{if("pointerup"!==i.type||0===i.button){t.abort();e?.toggleDrawing(!0);"pointerup"===i.type&&tools_assertClassBrand(At,this,_onSelectEnd).call(this,"main_toolbar")}};window.addEventListener("pointerup",pointerup,{signal:i});window.addEventListener("blur",pointerup,{signal:i})}else{e?.toggleDrawing(!0);tools_assertClassBrand(At,this,_onSelectEnd).call(this,"main_toolbar")}}}}else if(tools_classPrivateFieldGet(ft,this)){tools_classPrivateFieldGet(st,this)?.hide();tools_classPrivateFieldSet(ft,this,null);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedText:!1})}}function _onSelectEnd(e=""){tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT?this.highlightSelection(e):tools_classPrivateFieldGet(Ye,this)&&tools_assertClassBrand(At,this,_displayFloatingToolbar).call(this)}function _addSelectionListener(){document.addEventListener("selectionchange",tools_assertClassBrand(At,this,_selectionChange).bind(this),{signal:this._signal})}function _addFocusManager(){if(tools_classPrivateFieldGet(tt,this))return;tools_classPrivateFieldSet(tt,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(tt,this));window.addEventListener("focus",this.focus.bind(this),{signal:e});window.addEventListener("blur",this.blur.bind(this),{signal:e})}function _removeFocusManager(){tools_classPrivateFieldGet(tt,this)?.abort();tools_classPrivateFieldSet(tt,this,null)}function _addKeyboardManager(){if(tools_classPrivateFieldGet(dt,this))return;tools_classPrivateFieldSet(dt,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(dt,this));window.addEventListener("keydown",this.keydown.bind(this),{signal:e});window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}function _removeKeyboardManager(){tools_classPrivateFieldGet(dt,this)?.abort();tools_classPrivateFieldSet(dt,this,null)}function _addCopyPasteListeners(){if(tools_classPrivateFieldGet(Ve,this))return;tools_classPrivateFieldSet(Ve,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(Ve,this));document.addEventListener("copy",this.copy.bind(this),{signal:e});document.addEventListener("cut",this.cut.bind(this),{signal:e});document.addEventListener("paste",this.paste.bind(this),{signal:e})}function _removeCopyPasteListeners(){tools_classPrivateFieldGet(Ve,this)?.abort();tools_classPrivateFieldSet(Ve,this,null)}function _addDragAndDropListeners(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e});document.addEventListener("drop",this.drop.bind(this),{signal:e})}function _dispatchUpdateStates(e){if(Object.entries(e).some(([e,t])=>tools_classPrivateFieldGet(yt,this)[e]!==t)){this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(tools_classPrivateFieldGet(yt,this),e)});tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT&&!1===e.hasSelectedEditor&&tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,[[v.HIGHLIGHT_FREE,!0]])}}function _dispatchUpdateUI(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}async function _enableAll(){if(!tools_classPrivateFieldGet(nt,this)){tools_classPrivateFieldSet(nt,this,!0);const e=[];for(const t of tools_classPrivateFieldGet(Te,this).values())e.push(t.enable());await Promise.all(e);for(const e of tools_classPrivateFieldGet(Ie,this).values())e.enable()}}function _disableAll(){this.unselectAll();if(tools_classPrivateFieldGet(nt,this)){tools_classPrivateFieldSet(nt,this,!1);for(const e of tools_classPrivateFieldGet(Te,this).values())e.disable();for(const e of tools_classPrivateFieldGet(Ie,this).values())e.disable()}}function _addEditorToLayer(e){const t=tools_classPrivateFieldGet(Te,this).get(e.pageIndex);if(t)t.addOrRebuild(e);else{this.addEditor(e);this.addToAnnotationStorage(e)}}function _get_lastSelectedEditor(e){let t=null;for(t of tools_classPrivateFieldGet(mt,e));return t}function _isEmpty(){if(0===tools_classPrivateFieldGet(Ie,this).size)return!0;if(1===tools_classPrivateFieldGet(Ie,this).size)for(const e of tools_classPrivateFieldGet(Ie,this).values())return e.isEmpty();return!1}function _selectEditors(e){for(const e of tools_classPrivateFieldGet(mt,this))e.unselect();tools_classPrivateFieldGet(mt,this).clear();for(const t of e)if(!t.isEmpty()){tools_classPrivateFieldGet(mt,this).add(t);t.select()}tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}tools_defineProperty(AnnotationEditorUIManager,"TRANSLATE_SMALL",1);tools_defineProperty(AnnotationEditorUIManager,"TRANSLATE_BIG",10);function alt_text_classPrivateFieldInitSpec(e,t,i){alt_text_checkPrivateRedeclaration(e,t),t.set(e,i)}function alt_text_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function alt_text_classPrivateGetter(e,t,i){return i(alt_text_assertClassBrand(e,t))}function alt_text_classPrivateFieldGet(e,t){return e.get(alt_text_assertClassBrand(e,t))}function alt_text_classPrivateFieldSet(e,t,i){return e.set(alt_text_assertClassBrand(e,t),i),i}function alt_text_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Gt=new WeakMap,Bt=new WeakMap,Mt=new WeakMap,It=new WeakMap,Tt=new WeakMap,Dt=new WeakMap,Lt=new WeakMap,Rt=new WeakMap,Ot=new WeakMap,Nt=new WeakMap,Wt=new WeakMap,jt=new WeakMap,Vt=new WeakSet;class AltText{constructor(e){!function alt_text_classPrivateMethodInitSpec(e,t){alt_text_checkPrivateRedeclaration(e,t),t.add(e)}(this,Vt);alt_text_classPrivateFieldInitSpec(this,Gt,null);alt_text_classPrivateFieldInitSpec(this,Bt,!1);alt_text_classPrivateFieldInitSpec(this,Mt,null);alt_text_classPrivateFieldInitSpec(this,It,null);alt_text_classPrivateFieldInitSpec(this,Tt,null);alt_text_classPrivateFieldInitSpec(this,Dt,null);alt_text_classPrivateFieldInitSpec(this,Lt,!1);alt_text_classPrivateFieldInitSpec(this,Rt,null);alt_text_classPrivateFieldInitSpec(this,Ot,null);alt_text_classPrivateFieldInitSpec(this,Nt,null);alt_text_classPrivateFieldInitSpec(this,Wt,null);alt_text_classPrivateFieldInitSpec(this,jt,!1);alt_text_classPrivateFieldSet(Ot,this,e);alt_text_classPrivateFieldSet(jt,this,e._uiManager.useNewAltTextFlow);Ut._||(Ut._=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){AltText._l10n??=e}async render(){const e=alt_text_classPrivateFieldSet(Mt,this,document.createElement("button"));e.className="altText";e.tabIndex="0";const t=alt_text_classPrivateFieldSet(It,this,document.createElement("span"));e.append(t);if(alt_text_classPrivateFieldGet(jt,this)){e.classList.add("new");e.setAttribute("data-l10n-id",Ut._.missing);t.setAttribute("data-l10n-id",Ut._["missing-label"])}else{e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button");t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label")}const i=alt_text_classPrivateFieldGet(Ot,this)._uiManager._signal;e.addEventListener("contextmenu",noContextMenu,{signal:i});e.addEventListener("pointerdown",e=>e.stopPropagation(),{signal:i});const onClick=e=>{e.preventDefault();alt_text_classPrivateFieldGet(Ot,this)._uiManager.editAltText(alt_text_classPrivateFieldGet(Ot,this));alt_text_classPrivateFieldGet(jt,this)&&alt_text_classPrivateFieldGet(Ot,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:alt_text_classPrivateGetter(Vt,this,_get_label)}})};e.addEventListener("click",onClick,{capture:!0,signal:i});e.addEventListener("keydown",t=>{if(t.target===e&&"Enter"===t.key){alt_text_classPrivateFieldSet(Lt,this,!0);onClick(t)}},{signal:i});await alt_text_assertClassBrand(Vt,this,_setState).call(this);return e}finish(){if(alt_text_classPrivateFieldGet(Mt,this)){alt_text_classPrivateFieldGet(Mt,this).focus({focusVisible:alt_text_classPrivateFieldGet(Lt,this)});alt_text_classPrivateFieldSet(Lt,this,!1)}}isEmpty(){return alt_text_classPrivateFieldGet(jt,this)?null===alt_text_classPrivateFieldGet(Gt,this):!alt_text_classPrivateFieldGet(Gt,this)&&!alt_text_classPrivateFieldGet(Bt,this)}hasData(){return alt_text_classPrivateFieldGet(jt,this)?null!==alt_text_classPrivateFieldGet(Gt,this)||!!alt_text_classPrivateFieldGet(Nt,this):this.isEmpty()}get guessedText(){return alt_text_classPrivateFieldGet(Nt,this)}async setGuessedText(e){if(null===alt_text_classPrivateFieldGet(Gt,this)){alt_text_classPrivateFieldSet(Nt,this,e);alt_text_classPrivateFieldSet(Wt,this,await AltText._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}));alt_text_assertClassBrand(Vt,this,_setState).call(this)}}toggleAltTextBadge(e=!1){if(alt_text_classPrivateFieldGet(jt,this)&&!alt_text_classPrivateFieldGet(Gt,this)){if(!alt_text_classPrivateFieldGet(Rt,this)){const e=alt_text_classPrivateFieldSet(Rt,this,document.createElement("div"));e.className="noAltTextBadge";alt_text_classPrivateFieldGet(Ot,this).div.append(e)}alt_text_classPrivateFieldGet(Rt,this).classList.toggle("hidden",!e)}else{alt_text_classPrivateFieldGet(Rt,this)?.remove();alt_text_classPrivateFieldSet(Rt,this,null)}}serialize(e){let t=alt_text_classPrivateFieldGet(Gt,this);e||alt_text_classPrivateFieldGet(Nt,this)!==t||(t=alt_text_classPrivateFieldGet(Wt,this));return{altText:t,decorative:alt_text_classPrivateFieldGet(Bt,this),guessedText:alt_text_classPrivateFieldGet(Nt,this),textWithDisclaimer:alt_text_classPrivateFieldGet(Wt,this)}}get data(){return{altText:alt_text_classPrivateFieldGet(Gt,this),decorative:alt_text_classPrivateFieldGet(Bt,this)}}set data({altText:e,decorative:t,guessedText:i,textWithDisclaimer:a,cancel:s=!1}){if(i){alt_text_classPrivateFieldSet(Nt,this,i);alt_text_classPrivateFieldSet(Wt,this,a)}if(alt_text_classPrivateFieldGet(Gt,this)!==e||alt_text_classPrivateFieldGet(Bt,this)!==t){if(!s){alt_text_classPrivateFieldSet(Gt,this,e);alt_text_classPrivateFieldSet(Bt,this,t)}alt_text_assertClassBrand(Vt,this,_setState).call(this)}}toggle(e=!1){if(alt_text_classPrivateFieldGet(Mt,this)){if(!e&&alt_text_classPrivateFieldGet(Dt,this)){clearTimeout(alt_text_classPrivateFieldGet(Dt,this));alt_text_classPrivateFieldSet(Dt,this,null)}alt_text_classPrivateFieldGet(Mt,this).disabled=!e}}shown(){alt_text_classPrivateFieldGet(Ot,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:alt_text_classPrivateGetter(Vt,this,_get_label)}})}destroy(){alt_text_classPrivateFieldGet(Mt,this)?.remove();alt_text_classPrivateFieldSet(Mt,this,null);alt_text_classPrivateFieldSet(It,this,null);alt_text_classPrivateFieldSet(Tt,this,null);alt_text_classPrivateFieldGet(Rt,this)?.remove();alt_text_classPrivateFieldSet(Rt,this,null)}}function _get_label(e){return(alt_text_classPrivateFieldGet(Gt,e)?"added":null===alt_text_classPrivateFieldGet(Gt,e)&&e.guessedText&&"review")||"missing"}async function _setState(){const e=alt_text_classPrivateFieldGet(Mt,this);if(!e)return;if(alt_text_classPrivateFieldGet(jt,this)){e.classList.toggle("done",!!alt_text_classPrivateFieldGet(Gt,this));e.setAttribute("data-l10n-id",Ut._[alt_text_classPrivateGetter(Vt,this,_get_label)]);alt_text_classPrivateFieldGet(It,this)?.setAttribute("data-l10n-id",Ut._[`${alt_text_classPrivateGetter(Vt,this,_get_label)}-label`]);if(!alt_text_classPrivateFieldGet(Gt,this)){alt_text_classPrivateFieldGet(Tt,this)?.remove();return}}else{if(!alt_text_classPrivateFieldGet(Gt,this)&&!alt_text_classPrivateFieldGet(Bt,this)){e.classList.remove("done");alt_text_classPrivateFieldGet(Tt,this)?.remove();return}e.classList.add("done");e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=alt_text_classPrivateFieldGet(Tt,this);if(!t){alt_text_classPrivateFieldSet(Tt,this,t=document.createElement("span"));t.className="tooltip";t.setAttribute("role","tooltip");t.id=`alt-text-tooltip-${alt_text_classPrivateFieldGet(Ot,this).id}`;const i=100,a=alt_text_classPrivateFieldGet(Ot,this)._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(alt_text_classPrivateFieldGet(Dt,this));alt_text_classPrivateFieldSet(Dt,this,null)},{once:!0});e.addEventListener("mouseenter",()=>{alt_text_classPrivateFieldSet(Dt,this,setTimeout(()=>{alt_text_classPrivateFieldSet(Dt,this,null);alt_text_classPrivateFieldGet(Tt,this).classList.add("show");alt_text_classPrivateFieldGet(Ot,this)._reportTelemetry({action:"alt_text_tooltip"})},i))},{signal:a});e.addEventListener("mouseleave",()=>{if(alt_text_classPrivateFieldGet(Dt,this)){clearTimeout(alt_text_classPrivateFieldGet(Dt,this));alt_text_classPrivateFieldSet(Dt,this,null)}alt_text_classPrivateFieldGet(Tt,this)?.classList.remove("show")},{signal:a})}if(alt_text_classPrivateFieldGet(Bt,this))t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip");else{t.removeAttribute("data-l10n-id");t.textContent=alt_text_classPrivateFieldGet(Gt,this)}t.parentNode||e.append(t);const i=alt_text_classPrivateFieldGet(Ot,this).getElementForAltText();i?.setAttribute("aria-describedby",t.id)}var Ut={_:null};!function alt_text_defineProperty(e,t,i){return(t=function alt_text_toPropertyKey(e){var t=function alt_text_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(AltText,"_l10n",null);function comment_classPrivateFieldInitSpec(e,t,i){comment_checkPrivateRedeclaration(e,t),t.set(e,i)}function comment_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function comment_classPrivateFieldGet(e,t){return e.get(comment_assertClassBrand(e,t))}function comment_classPrivateFieldSet(e,t,i){return e.set(comment_assertClassBrand(e,t),i),i}function comment_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var zt=new WeakMap,Ht=new WeakMap,$t=new WeakMap,Xt=new WeakMap,Kt=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,Jt=new WeakMap,ei=new WeakSet;class Comment{constructor(e){!function comment_classPrivateMethodInitSpec(e,t){comment_checkPrivateRedeclaration(e,t),t.add(e)}(this,ei);comment_classPrivateFieldInitSpec(this,zt,null);comment_classPrivateFieldInitSpec(this,Ht,null);comment_classPrivateFieldInitSpec(this,$t,!1);comment_classPrivateFieldInitSpec(this,Xt,null);comment_classPrivateFieldInitSpec(this,Kt,null);comment_classPrivateFieldInitSpec(this,qt,null);comment_classPrivateFieldInitSpec(this,Yt,null);comment_classPrivateFieldInitSpec(this,Zt,null);comment_classPrivateFieldInitSpec(this,Qt,!1);comment_classPrivateFieldInitSpec(this,Jt,null);comment_classPrivateFieldSet(Xt,this,e)}renderForToolbar(){const e=comment_classPrivateFieldSet(Ht,this,document.createElement("button"));e.className="comment";return comment_assertClassBrand(ei,this,comment_render).call(this,e,!1)}renderForStandalone(){const e=comment_classPrivateFieldSet(zt,this,document.createElement("button"));e.className="annotationCommentButton";const t=comment_classPrivateFieldGet(Xt,this).commentButtonPosition;if(t){const{style:i}=e;i.insetInlineEnd=`calc(${100*("ltr"===comment_classPrivateFieldGet(Xt,this)._uiManager.direction?1-t[0]:t[0])}% - var(--comment-button-dim))`;i.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;const a=comment_classPrivateFieldGet(Xt,this).commentButtonColor;a&&(i.backgroundColor=a)}return comment_assertClassBrand(ei,this,comment_render).call(this,e,!0)}focusButton(){setTimeout(()=>{(comment_classPrivateFieldGet(zt,this)??comment_classPrivateFieldGet(Ht,this))?.focus()},0)}onUpdatedColor(){if(!comment_classPrivateFieldGet(zt,this))return;const e=comment_classPrivateFieldGet(Xt,this).commentButtonColor;e&&(comment_classPrivateFieldGet(zt,this).style.backgroundColor=e);comment_classPrivateFieldGet(Xt,this)._uiManager.updatePopupColor(comment_classPrivateFieldGet(Xt,this))}get commentButtonWidth(){return(comment_classPrivateFieldGet(zt,this)?.getBoundingClientRect().width??0)/comment_classPrivateFieldGet(Xt,this).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(comment_classPrivateFieldGet(Jt,this))return comment_classPrivateFieldGet(Jt,this);if(!comment_classPrivateFieldGet(zt,this))return null;const{x:e,y:t,height:i}=comment_classPrivateFieldGet(zt,this).getBoundingClientRect(),{x:a,y:s,width:r,height:n}=comment_classPrivateFieldGet(Xt,this).parent.boundingClientRect;return[(e-a)/r,(t+i-s)/n]}set commentPopupPositionInLayer(e){comment_classPrivateFieldSet(Jt,this,e)}hasDefaultPopupPosition(){return null===comment_classPrivateFieldGet(Jt,this)}removeStandaloneCommentButton(){comment_classPrivateFieldGet(zt,this)?.remove();comment_classPrivateFieldSet(zt,this,null)}removeToolbarCommentButton(){comment_classPrivateFieldGet(Ht,this)?.remove();comment_classPrivateFieldSet(Ht,this,null)}setCommentButtonStates({selected:e,hasPopup:t}){if(comment_classPrivateFieldGet(zt,this)){comment_classPrivateFieldGet(zt,this).classList.toggle("selected",e);comment_classPrivateFieldGet(zt,this).ariaExpanded=t}}edit(e){const t=this.commentPopupPositionInLayer;let i,a;if(t)[i,a]=t;else{[i,a]=comment_classPrivateFieldGet(Xt,this).commentButtonPosition;const{width:e,height:t,x:s,y:r}=comment_classPrivateFieldGet(Xt,this);i=s+i*e;a=r+a*t}const s=comment_classPrivateFieldGet(Xt,this).parent.boundingClientRect,{x:r,y:n,width:o,height:l}=s;comment_classPrivateFieldGet(Xt,this)._uiManager.editComment(comment_classPrivateFieldGet(Xt,this),r+i*o,n+a*l,{...e,parentDimensions:s})}finish(){if(comment_classPrivateFieldGet(Ht,this)){comment_classPrivateFieldGet(Ht,this).focus({focusVisible:comment_classPrivateFieldGet($t,this)});comment_classPrivateFieldSet($t,this,!1)}}isDeleted(){return comment_classPrivateFieldGet(Qt,this)||""===comment_classPrivateFieldGet(Yt,this)}isEmpty(){return null===comment_classPrivateFieldGet(Yt,this)}hasBeenEdited(){return this.isDeleted()||comment_classPrivateFieldGet(Yt,this)!==comment_classPrivateFieldGet(Kt,this)}serialize(){return this.data}get data(){return{text:comment_classPrivateFieldGet(Yt,this),richText:comment_classPrivateFieldGet(qt,this),date:comment_classPrivateFieldGet(Zt,this),deleted:this.isDeleted()}}set data(e){e!==comment_classPrivateFieldGet(Yt,this)&&comment_classPrivateFieldSet(qt,this,null);if(null!==e){comment_classPrivateFieldSet(Yt,this,e);comment_classPrivateFieldSet(Zt,this,new Date);comment_classPrivateFieldSet(Qt,this,!1);comment_classPrivateFieldGet(Xt,this).eventBus?.dispatch("annotation-editor-event",{source:comment_classPrivateFieldGet(Xt,this),type:"commented",page:comment_classPrivateFieldGet(Xt,this).pageIndex+1,editorType:comment_classPrivateFieldGet(Xt,this).constructor.name,id:comment_classPrivateFieldGet(Xt,this).uid,value:comment_classPrivateFieldGet(Xt,this)})}else{comment_classPrivateFieldSet(Yt,this,"");comment_classPrivateFieldSet(Qt,this,!0);comment_classPrivateFieldGet(Xt,this).eventBus?.dispatch("annotation-editor-event",{source:comment_classPrivateFieldGet(Xt,this),type:"commentRemoved",page:comment_classPrivateFieldGet(Xt,this).pageIndex+1,editorType:comment_classPrivateFieldGet(Xt,this).constructor.name,id:comment_classPrivateFieldGet(Xt,this).uid,value:comment_classPrivateFieldGet(Xt,this)})}}restoreData({text:e,richText:t,date:i}){comment_classPrivateFieldSet(Yt,this,e);comment_classPrivateFieldSet(qt,this,t);comment_classPrivateFieldSet(Zt,this,i);comment_classPrivateFieldSet(Qt,this,!1)}setInitialText(e,t=null){comment_classPrivateFieldSet(Kt,this,e);this.data=e;comment_classPrivateFieldSet(Zt,this,null);comment_classPrivateFieldSet(qt,this,t)}setDate(e){const t=e&&new Date(e);!t||isNaN(t)?comment_classPrivateFieldSet(Zt,this,new Date):comment_classPrivateFieldSet(Zt,this,t)}shown(){}destroy(){comment_classPrivateFieldGet(Ht,this)?.remove();comment_classPrivateFieldSet(Ht,this,null);comment_classPrivateFieldGet(zt,this)?.remove();comment_classPrivateFieldSet(zt,this,null);comment_classPrivateFieldSet(Yt,this,"");comment_classPrivateFieldSet(qt,this,null);comment_classPrivateFieldSet(Zt,this,null);comment_classPrivateFieldSet(Xt,this,null);comment_classPrivateFieldSet($t,this,!1);comment_classPrivateFieldSet(Qt,this,!1)}}function comment_render(e,t){if(!comment_classPrivateFieldGet(Xt,this)._uiManager.hasCommentManager())return null;e.tabIndex="0";e.ariaHasPopup="dialog";if(t){e.ariaControls="commentPopup";e.setAttribute("data-l10n-id","pdfjs-show-comment-button")}else{e.ariaControlsElements=[comment_classPrivateFieldGet(Xt,this)._uiManager.getCommentDialogElement()];e.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button")}const i=comment_classPrivateFieldGet(Xt,this)._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return e;e.addEventListener("contextmenu",noContextMenu,{signal:i});if(t){e.addEventListener("focusin",e=>{comment_classPrivateFieldGet(Xt,this)._focusEventsAllowed=!1;stopEvent(e)},{capture:!0,signal:i});e.addEventListener("focusout",e=>{comment_classPrivateFieldGet(Xt,this)._focusEventsAllowed=!0;stopEvent(e)},{capture:!0,signal:i})}e.addEventListener("pointerdown",e=>e.stopPropagation(),{signal:i});const onClick=t=>{t.preventDefault();e===comment_classPrivateFieldGet(Ht,this)?this.edit():comment_classPrivateFieldGet(Xt,this).toggleComment(!0)};e.addEventListener("click",onClick,{capture:!0,signal:i});e.addEventListener("keydown",t=>{if(t.target===e&&"Enter"===t.key){comment_classPrivateFieldSet($t,this,!0);onClick(t)}},{signal:i});e.addEventListener("pointerenter",()=>{comment_classPrivateFieldGet(Xt,this).toggleComment(!1,!0)},{signal:i});e.addEventListener("pointerleave",()=>{comment_classPrivateFieldGet(Xt,this).toggleComment(!1,!1)},{signal:i});return e}function touch_manager_classPrivateFieldInitSpec(e,t,i){touch_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function touch_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function touch_manager_classPrivateFieldGet(e,t){return e.get(touch_manager_assertClassBrand(e,t))}function touch_manager_classPrivateFieldSet(e,t,i){return e.set(touch_manager_assertClassBrand(e,t),i),i}function touch_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function preventDefault(e){e.preventDefault()}const ti=1e-4;function stopTouchEvent(e){if(e.cancelable){stopEvent(e);return!0}e.stopPropagation();return!1}var ii,ai=new WeakMap,si=new WeakMap,ri=new WeakMap,ni=new WeakMap,oi=new WeakMap,li=new WeakMap,di=new WeakMap,ci=new WeakMap,hi=new WeakMap,_i=new WeakMap,ui=new WeakMap,pi=new WeakMap,gi=new WeakMap,mi=new WeakMap,fi=new WeakMap,vi=new WeakMap,Pi=new WeakSet;class TouchManager{constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:i=null,onPinchStart:a=null,onPinching:s=null,onPinchEnd:r=null,onPanning:n=null,signal:o}){!function touch_manager_classPrivateMethodInitSpec(e,t){touch_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,Pi);touch_manager_classPrivateFieldInitSpec(this,ai,void 0);touch_manager_classPrivateFieldInitSpec(this,si,!1);touch_manager_classPrivateFieldInitSpec(this,ri,null);touch_manager_classPrivateFieldInitSpec(this,ni,void 0);touch_manager_classPrivateFieldInitSpec(this,oi,void 0);touch_manager_classPrivateFieldInitSpec(this,li,void 0);touch_manager_classPrivateFieldInitSpec(this,di,void 0);touch_manager_classPrivateFieldInitSpec(this,ci,void 0);touch_manager_classPrivateFieldInitSpec(this,hi,!1);touch_manager_classPrivateFieldInitSpec(this,_i,null);touch_manager_classPrivateFieldInitSpec(this,ui,void 0);touch_manager_classPrivateFieldInitSpec(this,pi,new Set);touch_manager_classPrivateFieldInitSpec(this,gi,null);touch_manager_classPrivateFieldInitSpec(this,mi,void 0);touch_manager_classPrivateFieldInitSpec(this,fi,null);touch_manager_classPrivateFieldInitSpec(this,vi,0);touch_manager_classPrivateFieldSet(ai,this,e);touch_manager_classPrivateFieldSet(ri,this,i);touch_manager_classPrivateFieldSet(ni,this,t);touch_manager_classPrivateFieldSet(oi,this,a);touch_manager_classPrivateFieldSet(li,this,s);touch_manager_classPrivateFieldSet(di,this,r);touch_manager_classPrivateFieldSet(ci,this,n);touch_manager_classPrivateFieldSet(mi,this,new AbortController);touch_manager_classPrivateFieldSet(ui,this,AbortSignal.any([o,touch_manager_classPrivateFieldGet(mi,this).signal]));e.addEventListener("touchstart",touch_manager_assertClassBrand(Pi,this,_onTouchStart).bind(this),{passive:!1,signal:touch_manager_classPrivateFieldGet(ui,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/OutputScale.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/OutputScale.pixelRatio}destroy(){touch_manager_assertClassBrand(Pi,this,_endGesture).call(this);touch_manager_classPrivateFieldGet(pi,this).clear();touch_manager_classPrivateFieldGet(mi,this)?.abort();touch_manager_classPrivateFieldSet(mi,this,null);touch_manager_classPrivateFieldGet(_i,this)?.abort();touch_manager_classPrivateFieldSet(_i,this,null)}}function _onTouchStart(e){if(touch_manager_classPrivateFieldGet(ni,this)?.call(this))return;touch_manager_assertClassBrand(Pi,this,_pruneTouchIds).call(this,e);const t=touch_manager_classPrivateFieldGet(pi,this);for(const{identifier:i}of e.changedTouches)t.add(i);if(1!==t.size){if(!touch_manager_classPrivateFieldGet(fi,this)){touch_manager_classPrivateFieldSet(fi,this,new AbortController);const e=AbortSignal.any([touch_manager_classPrivateFieldGet(ui,this),touch_manager_classPrivateFieldGet(fi,this).signal]),t=touch_manager_classPrivateFieldGet(ai,this),i={signal:e,capture:!1,passive:!1};t.addEventListener("touchmove",touch_manager_assertClassBrand(Pi,this,_onTouchMove).bind(this),i);const a=touch_manager_assertClassBrand(Pi,this,_onTouchEnd).bind(this);t.addEventListener("touchend",a,i);t.addEventListener("touchcancel",a,i);i.capture=!0;t.addEventListener("pointerdown",stopEvent,i);t.addEventListener("pointermove",stopEvent,i);t.addEventListener("pointercancel",preventDefault,i);t.addEventListener("pointerup",preventDefault,i);touch_manager_classPrivateFieldGet(oi,this)?.call(this)}touch_manager_classPrivateFieldSet(hi,this,stopTouchEvent(e));touch_manager_assertClassBrand(Pi,this,_setTouchInfo).call(this,e)}else touch_manager_assertClassBrand(Pi,this,_armPointerDown).call(this)}function _armPointerDown(){if(touch_manager_classPrivateFieldGet(_i,this))return;const e=touch_manager_classPrivateFieldSet(_i,this,new AbortController),t=AbortSignal.any([touch_manager_classPrivateFieldGet(ui,this),e.signal]),i=touch_manager_classPrivateFieldGet(ai,this),a={capture:!0,signal:t,passive:!1},cancelPointerDown=e=>{if("touch"===e.pointerType){touch_manager_classPrivateFieldGet(_i,this)?.abort();touch_manager_classPrivateFieldSet(_i,this,null)}};i.addEventListener("pointerdown",e=>{if("touch"===e.pointerType){stopEvent(e);cancelPointerDown(e)}},a);i.addEventListener("pointerup",cancelPointerDown,a);i.addEventListener("pointercancel",cancelPointerDown,a)}function _pruneTouchIds(e){const t=touch_manager_classPrivateFieldGet(pi,this);if(0===t.size)return;const i=touch_manager_classPrivateFieldSet(pi,this,new Set);for(const{identifier:a}of e.touches)t.has(a)&&i.add(a)}function _getTrackedTouches(e){const t=touch_manager_classPrivateFieldGet(pi,this),i=[];for(const a of e.touches)t.has(a.identifier)&&i.push(a);return i}function _setTouchInfo(e){const t=touch_manager_assertClassBrand(Pi,this,_getTrackedTouches).call(this,e);if(2!==t.length||touch_manager_classPrivateFieldGet(ri,this)?.call(this)){touch_manager_classPrivateFieldSet(gi,this,null);return}const[i,a]=t;touch_manager_classPrivateFieldSet(gi,this,{touch0X:i.screenX,touch0Y:i.screenY,touch1X:a.screenX,touch1Y:a.screenY,panX:(i.clientX+a.clientX)/2,panY:(i.clientY+a.clientY)/2,screenPanX:(i.screenX+a.screenX)/2,screenPanY:(i.screenY+a.screenY)/2})}function _onTouchMove(e){if(!touch_manager_classPrivateFieldGet(gi,this))return;const t=touch_manager_assertClassBrand(Pi,this,_getTrackedTouches).call(this,e);if(2!==t.length)return;const i=touch_manager_classPrivateFieldGet(hi,this);touch_manager_classPrivateFieldSet(hi,this,stopTouchEvent(e));if(!touch_manager_classPrivateFieldGet(hi,this))return;if(!i){touch_manager_assertClassBrand(Pi,this,_setTouchInfo).call(this,e);return}const[a,s]=t,{screenX:r,screenY:n}=a,{screenX:o,screenY:l}=s,d=touch_manager_classPrivateFieldGet(gi,this),{touch0X:c,touch0Y:h,touch1X:_,touch1Y:u,panX:p,panY:g}=d,m=_-c,f=u-h,v=o-r,P=l-n,w=(a.clientX+s.clientX)/2,F=(a.clientY+s.clientY)/2;d.panX=w;d.panY=F;const y=w-p,b=F-g,S=(r+o)/2,C=(n+l)/2,x=Math.hypot(S-d.screenPanX,C-d.screenPanY);d.screenPanX=S;d.screenPanY=C;const k=Math.hypot(v,P),E=Math.hypot(m,f),A=touch_manager_classPrivateFieldGet(si,this)?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*x;if(k<ti||E<ti||Math.abs(E-k)<=A){(y||b)&&touch_manager_classPrivateFieldGet(ci,this)?.call(this,y,b);return}d.touch0X=r;d.touch0Y=n;d.touch1X=o;d.touch1Y=l;const G=Math.sign(k-E);if(touch_manager_classPrivateFieldGet(si,this)){if(touch_manager_classPrivateFieldGet(vi,this)){const e=touch_manager_classPrivateFieldGet(vi,this);touch_manager_classPrivateFieldSet(vi,this,0);if(G!==e&&Math.abs(k-E)<=2*x){touch_manager_classPrivateFieldSet(si,this,!1);(y||b)&&touch_manager_classPrivateFieldGet(ci,this)?.call(this,y,b);return}}touch_manager_classPrivateFieldGet(li,this)?.call(this,[p,g],E,k,y,b)}else{touch_manager_classPrivateFieldSet(si,this,!0);touch_manager_classPrivateFieldSet(vi,this,G);(y||b)&&touch_manager_classPrivateFieldGet(ci,this)?.call(this,y,b)}}function _onTouchEnd(e){touch_manager_assertClassBrand(Pi,this,_pruneTouchIds).call(this,e);if(touch_manager_classPrivateFieldGet(pi,this).size>=2){touch_manager_assertClassBrand(Pi,this,_setTouchInfo).call(this,e);return}const t=!!touch_manager_classPrivateFieldGet(gi,this);touch_manager_assertClassBrand(Pi,this,_endGesture).call(this);1===touch_manager_classPrivateFieldGet(pi,this).size&&touch_manager_assertClassBrand(Pi,this,_armPointerDown).call(this);t&&stopTouchEvent(e)}function _endGesture(){touch_manager_classPrivateFieldSet(gi,this,null);touch_manager_classPrivateFieldSet(si,this,!1);touch_manager_classPrivateFieldSet(vi,this,0);touch_manager_classPrivateFieldSet(hi,this,!1);if(touch_manager_classPrivateFieldGet(fi,this)){touch_manager_classPrivateFieldGet(fi,this).abort();touch_manager_classPrivateFieldSet(fi,this,null);touch_manager_classPrivateFieldGet(di,this)?.call(this)}}function editor_defineProperty(e,t,i){return(t=function editor_toPropertyKey(e){var t=function editor_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_classPrivateFieldInitSpec(e,t,i){editor_checkPrivateRedeclaration(e,t),t.set(e,i)}function editor_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function editor_classPrivateFieldSet(e,t,i){return e.set(editor_assertClassBrand(e,t),i),i}function editor_classPrivateFieldGet(e,t){return e.get(editor_assertClassBrand(e,t))}function editor_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var wi=new WeakMap,Fi=new WeakMap,yi=new WeakMap,bi=new WeakMap,Si=new WeakMap,Ci=new WeakMap,xi=new WeakMap,ki=new WeakMap,Ei=new WeakMap,Ai=new WeakMap,Gi=new WeakMap,Bi=new WeakMap,Mi=new WeakMap,Ii=new WeakMap,Ti=new WeakMap,Di=new WeakMap,Li=new WeakMap,Ri=new WeakMap,Oi=new WeakMap,Ni=new WeakMap,Wi=new WeakMap,ji=new WeakMap,Vi=new WeakMap,Ui=new WeakMap,zi=new WeakMap,Hi=new WeakMap,$i=new WeakMap,Xi=new WeakSet;class AnnotationEditor{static get _resizerKeyboardManager(){const e=AnnotationEditor.prototype._resizeWithKeyboard,t=AnnotationEditorUIManager.TRANSLATE_SMALL,i=AnnotationEditorUIManager.TRANSLATE_BIG;return shadow(this,"_resizerKeyboardManager",new KeyboardManager([[["ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-i,0]}],[["ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[i,0]}],[["ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-i]}],[["ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,i]}],[["Escape"],AnnotationEditor.prototype._stopResizingWithKeyboard]]))}constructor(e){!function editor_classPrivateMethodInitSpec(e,t){editor_checkPrivateRedeclaration(e,t),t.add(e)}(this,Xi);editor_classPrivateFieldInitSpec(this,wi,null);editor_classPrivateFieldInitSpec(this,Fi,null);editor_classPrivateFieldInitSpec(this,yi,null);editor_classPrivateFieldInitSpec(this,bi,null);editor_classPrivateFieldInitSpec(this,Si,null);editor_classPrivateFieldInitSpec(this,Ci,!1);editor_classPrivateFieldInitSpec(this,xi,null);editor_classPrivateFieldInitSpec(this,ki,"");editor_classPrivateFieldInitSpec(this,Ei,!1);editor_classPrivateFieldInitSpec(this,Ai,null);editor_classPrivateFieldInitSpec(this,Gi,null);editor_classPrivateFieldInitSpec(this,Bi,null);editor_classPrivateFieldInitSpec(this,Mi,null);editor_classPrivateFieldInitSpec(this,Ii,null);editor_classPrivateFieldInitSpec(this,Ti,"");editor_classPrivateFieldInitSpec(this,Di,!1);editor_classPrivateFieldInitSpec(this,Li,null);editor_classPrivateFieldInitSpec(this,Ri,!1);editor_classPrivateFieldInitSpec(this,Oi,!1);editor_classPrivateFieldInitSpec(this,Ni,!1);editor_classPrivateFieldInitSpec(this,Wi,null);editor_classPrivateFieldInitSpec(this,ji,0);editor_classPrivateFieldInitSpec(this,Vi,0);editor_classPrivateFieldInitSpec(this,Ui,null);editor_classPrivateFieldInitSpec(this,zi,null);editor_defineProperty(this,"isSelected",!1);editor_defineProperty(this,"_isCopy",!1);editor_defineProperty(this,"_editToolbar",null);editor_defineProperty(this,"_erasable",!1);editor_defineProperty(this,"_initialOptions",Object.create(null));editor_defineProperty(this,"_initialData",null);editor_defineProperty(this,"_isVisible",!0);editor_defineProperty(this,"_uiManager",null);editor_defineProperty(this,"_focusEventsAllowed",!0);editor_classPrivateFieldInitSpec(this,Hi,!1);editor_classPrivateFieldInitSpec(this,$i,AnnotationEditor._zIndex++);editor_defineProperty(this,"doNotMove",!1);editor_defineProperty(this,"customId",null);this.parent=e.parent;this.id=e.id;this.width=this.height=null;this.pageIndex=e.parent.pageIndex;this.name=e.name;this.div=null;this._uiManager=e.uiManager;this.annotationElementId=null;this._willKeepAspectRatio=!1;this._initialOptions.isCentered=e.isCentered;this._structTreeParentId=null;this.annotationElementId=e.annotationElementId||null;this.creationDate=e.creationDate||new Date;this.modificationDate=e.modificationDate||null;this.canAddComment=!0;const{rotation:t,rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:r}}=this.parent.viewport;this.rotation=t;this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360;this.pageDimensions=[i,a];this.pageTranslation=[s,r];const[n,o]=this.parentDimensions;this.x=e.x/n;this.y=e.y/o;this.isAttachedToDOM=!1;this.deleted=!1;this.eventBus=e.eventBus}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}get erasable(){return this._erasable}static get isDrawer(){return!1}static get _defaultLineColor(){return shadow(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new FakeEditor({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId;t.deleted=!0;t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){AnnotationEditor._l10n??=e;AnnotationEditor._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"});AnnotationEditor._l10nResizer??=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"});if(-1!==AnnotationEditor._borderLineWidth)return;const i=getComputedStyle(document.documentElement);AnnotationEditor._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){unreachable("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return editor_classPrivateFieldGet(Hi,this)}set _isDraggable(e){editor_classPrivateFieldSet(Hi,this,e);this.div?.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(2*e);this.y+=this.width*e/(2*t);break;case 180:this.x+=this.width/2;this.y+=this.height/2;break;case 270:this.x+=this.height*t/(2*e);this.y-=this.width*e/(2*t);break;default:this.x-=this.width/2;this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=editor_classPrivateFieldGet($i,this)}setParent(e){if(null!==e){this.pageIndex=e.pageIndex;this.pageDimensions=e.pageDimensions}else{editor_assertClassBrand(Xi,this,_stopResizing).call(this);editor_classPrivateFieldGet(Mi,this)?.remove();editor_classPrivateFieldSet(Mi,this,null)}this.parent=e}focusin(e){this._focusEventsAllowed&&(editor_classPrivateFieldGet(Di,this)?editor_classPrivateFieldSet(Di,this,!1):this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const t=e.relatedTarget;if(!t?.closest(`#${this.id}`)){e.preventDefault();this.parent?.isMultipleSelection||this.commitOrRemove()}}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){if(this.isInEditMode()){this.addToAnnotationStorage();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"commit",page:this.pageIndex+1,editorType:this.constructor.name,value:this,id:this.uid})}}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,i,a){const[s,r]=this.parentDimensions;[i,a]=this.screenToPageTranslation(i,a);this.doNotMove&&([i,a]=[0,0]);this.x=(e+i)/s;this.y=(t+a)/r;this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}const[i,a]=this.parentDimensions;this.setAt(e*i,t*a,this.width*i,this.height*a);this.doNotMove||this._onTranslated()}translate(e,t){editor_assertClassBrand(Xi,this,_translate).call(this,this.parentDimensions,e,t)}startErase(e){unreachable("Not implemented")}erase(e,t,i,a=e,s=t){unreachable("Not implemented")}renderErase(){unreachable("Not implemented")}endErase(){unreachable("Not implemented")}translateInPage(e,t){editor_classPrivateFieldGet(Li,this)||editor_classPrivateFieldSet(Li,this,[this.x,this.y,this.width,this.height]);editor_assertClassBrand(Xi,this,_translate).call(this,this.pageDimensions,e,t);this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){editor_classPrivateFieldGet(Li,this)||editor_classPrivateFieldSet(Li,this,[this.x,this.y,this.width,this.height]);const{div:i,parentDimensions:[a,s]}=this;this.x+=e/a;this.y+=t/s;if(this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:e,y:t}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,e,t)){this.x-=Math.floor(this.x);this.y-=Math.floor(this.y)}}let{x:r,y:n}=this;const[o,l]=this.getBaseTranslation();r+=o;n+=l;const{style:d}=i;d.left=`${(100*r).toFixed(2)}%`;d.top=`${(100*n).toFixed(2)}%`;this._onTranslating(r,n)}_onTranslating(e,t){}_onTranslated(e,t){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"moved",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:{x:e,y:t}})}_dispatchEditorEvent(e,t=null){const i={source:this,type:e,page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,...t};for(const e of Object.keys(i))void 0===i[e]&&delete i[e];this.eventBus?.dispatch("annotation-editor-event",i)}get addedEventValue(){return{}}_dispatchAddedEvent(){this._dispatchEditorEvent("added",{value:this.addedEventValue})}get _hasBeenMoved(){return!!editor_classPrivateFieldGet(Li,this)&&(editor_classPrivateFieldGet(Li,this)[0]!==this.x||editor_classPrivateFieldGet(Li,this)[1]!==this.y)}get _hasBeenResized(){return!!editor_classPrivateFieldGet(Li,this)&&(editor_classPrivateFieldGet(Li,this)[2]!==this.width||editor_classPrivateFieldGet(Li,this)[3]!==this.height)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:i}=AnnotationEditor,a=i/e,s=i/t;switch(this.rotation){case 90:return[-a,s];case 180:return[a,s];case 270:return[a,-s];default:return[-a,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:t},pageDimensions:[i,a]}=this;let{x:s,y:r,width:n,height:o}=this;n*=i;o*=a;s*=i;r*=a;let l=0,d=0;const c=this._uiManager._keepToolbarInPage&&this._editToolbar?.div;if(c?.offsetParent){const t=this.parentScale,h=c.offsetLeft+this.div.clientLeft,_=c.offsetTop+this.div.clientTop,u=Math.min(0,h)/t,p=Math.min(0,_)/t,g=n-u+Math.max(0,h+c.offsetWidth-this.div.offsetWidth)/t,m=o-p+Math.max(0,_+c.offsetHeight-this.div.offsetHeight)/t;if(g<=(e%180?a:i)){n=g;l=u}if(m<=(e%180?i:a)){o=m;d=p}[l,d]=_rotatePoint.call(AnnotationEditor,l,d,e);s+=l;r+=d}if(this._mustFixPosition)switch(e){case 0:s=MathClamp(s,0,i-n);r=MathClamp(r,0,a-o);break;case 90:s=MathClamp(s,0,i-o);r=MathClamp(r,n,a);break;case 180:s=MathClamp(s,n,i);r=MathClamp(r,o,a);break;case 270:s=MathClamp(s,o,i);r=MathClamp(r,0,a-n)}this.x=s=(s-l)/i;this.y=r=(r-d)/a;const[h,_]=this.getBaseTranslation();s+=h;r+=_;t.left=`${(100*s).toFixed(2)}%`;t.top=`${(100*r).toFixed(2)}%`;this.moveInDOM()}screenToPageTranslation(e,t){return _rotatePoint.call(AnnotationEditor,e,t,this.parentRotation)}pageTranslationToScreen(e,t){return _rotatePoint.call(AnnotationEditor,e,t,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,i]}=this;return[t*e,i*e]}setDims(){const{div:{style:e},width:t,height:i}=this;e.width=`${(100*t).toFixed(2)}%`;e.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(1e4*e)/1e4}_onResizing(){}altTextFinish(){editor_classPrivateFieldGet(yi,this)?.finish();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"altTextChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:editor_classPrivateFieldGet(yi,this)})}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||editor_classPrivateFieldGet(Oi,this))return this._editToolbar;this._editToolbar=new EditorToolbar(this);this.div.append(this._editToolbar.render());const{toolbarButtons:e}=this;if(e)for(const[t,i]of e)await this._editToolbar.addButton(t,i);this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton());this._editToolbar.addButton("delete");return this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove();this._editToolbar=null;editor_classPrivateFieldGet(yi,this)?.destroy()}addContainer(e){const t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!editor_classPrivateFieldGet(yi,this)){AltText.initialize(AnnotationEditor._l10n);editor_classPrivateFieldSet(yi,this,new AltText(this));if(editor_classPrivateFieldGet(wi,this)){editor_classPrivateFieldGet(yi,this).data=editor_classPrivateFieldGet(wi,this);editor_classPrivateFieldSet(wi,this,null)}}return editor_classPrivateFieldGet(yi,this)}get altTextData(){return editor_classPrivateFieldGet(yi,this)?.data}set altTextData(e){editor_classPrivateFieldGet(yi,this)&&(editor_classPrivateFieldGet(yi,this).data=e)}get guessedAltText(){return editor_classPrivateFieldGet(yi,this)?.guessedText}async setGuessedAltText(e){await(editor_classPrivateFieldGet(yi,this)?.setGuessedText(e))}serializeAltText(e){return editor_classPrivateFieldGet(yi,this)?.serialize(e)}hasAltText(){return!!editor_classPrivateFieldGet(yi,this)&&!editor_classPrivateFieldGet(yi,this).isEmpty()}hasAltTextData(){return editor_classPrivateFieldGet(yi,this)?.hasData()??!1}focusCommentButton(){editor_classPrivateFieldGet(bi,this)?.focusButton()}addCommentButton(){return this.canAddComment?editor_classPrivateFieldGet(bi,this)||editor_classPrivateFieldSet(bi,this,new Comment(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager())if(editor_classPrivateFieldGet(Si,this))this._uiManager.isEditingMode()&&editor_classPrivateFieldGet(Si,this).classList.remove("hidden");else if(this.hasComment){editor_classPrivateFieldSet(Si,this,editor_classPrivateFieldGet(bi,this).renderForStandalone());this.div.append(editor_classPrivateFieldGet(Si,this))}}removeStandaloneCommentButton(){editor_classPrivateFieldGet(bi,this).removeStandaloneCommentButton();editor_classPrivateFieldSet(Si,this,null)}hideStandaloneCommentButton(){editor_classPrivateFieldGet(Si,this)?.classList.add("hidden")}get comment(){if(!editor_classPrivateFieldGet(bi,this))return null;const{data:{richText:e,text:t,date:i,deleted:a}}=editor_classPrivateFieldGet(bi,this);return{text:t,richText:e,date:i,deleted:a,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){editor_classPrivateFieldGet(bi,this)||editor_classPrivateFieldSet(bi,this,new Comment(this));"object"==typeof e&&null!==e?editor_classPrivateFieldGet(bi,this).restoreData(e):editor_classPrivateFieldGet(bi,this).data=e;if(this.hasComment){this.removeCommentButtonFromToolbar();this.addStandaloneCommentButton();this._uiManager.updateComment(this)}else{this.addCommentButtonInToolbar();this.removeStandaloneCommentButton();this._uiManager.removeComment(this)}}setCommentData({comment:e,popupRef:t,richText:i,commentDate:a}){if(!t)return;editor_classPrivateFieldGet(bi,this)||editor_classPrivateFieldSet(bi,this,new Comment(this));editor_classPrivateFieldGet(bi,this).setInitialText(e,i);a&&editor_classPrivateFieldGet(bi,this).setDate(a);if(!this.annotationElementId)return;const s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return editor_classPrivateFieldGet(bi,this)?.hasBeenEdited()}get hasDeletedComment(){return editor_classPrivateFieldGet(bi,this)?.isDeleted()}get hasComment(){return!!editor_classPrivateFieldGet(bi,this)&&!editor_classPrivateFieldGet(bi,this).isEmpty()&&!editor_classPrivateFieldGet(bi,this).isDeleted()}async editComment(e){editor_classPrivateFieldGet(bi,this)||editor_classPrivateFieldSet(bi,this,new Comment(this));editor_classPrivateFieldGet(bi,this).edit(e)}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){editor_classPrivateFieldGet(bi,this).setSelectedButton(e)}addComment(e,t=!1){if(this.hasEditedComment||t&&this.hasComment){const t=180,i=100,[,,,a]=e.rect,[s]=this.pageDimensions,[r]=this.pageTranslation,n=r+s+1,o=a-i,l=n+t;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[n,o,l,a],date:this.comment.date?.toISOString()}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){editor_classPrivateFieldGet(bi,this).data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360);e.className=this.name;e.setAttribute("id",this.id);e.tabIndex=editor_classPrivateFieldGet(Ci,this)?-1:0;e.setAttribute("role","application");this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId);this._isVisible||e.classList.add("hidden");this.setInForeground();editor_assertClassBrand(Xi,this,_addFocusListeners).call(this);const[t,i]=this.parentDimensions;if(this.parentRotation%180!=0){e.style.maxWidth=`${(100*i/t).toFixed(2)}%`;e.style.maxHeight=`${(100*t/i).toFixed(2)}%`}const[a,s]=this.getInitialTranslation();this.translate(a,s);bindEvents(this,e,["keydown","pointerdown","dblclick"]);editor_assertClassBrand(Xi,this,_addTouchManager).call(this);this.addStandaloneCommentButton();this._uiManager._editorUndoBar?.hide();return e}pointerdown(e){const{isMac:t}=FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)e.preventDefault();else{editor_classPrivateFieldSet(Di,this,!0);this._isDraggable?editor_assertClassBrand(Xi,this,_setUpDragSession).call(this,e):editor_assertClassBrand(Xi,this,_selectOnPointerEvent).call(this,e)}}_onStartDragging(){}_onStopDragging(){}moveInDOM(){editor_classPrivateFieldGet(Wi,this)&&clearTimeout(editor_classPrivateFieldGet(Wi,this));editor_classPrivateFieldSet(Wi,this,setTimeout(()=>{editor_classPrivateFieldSet(Wi,this,null);this.parent?.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,i){e.changeParent(this);this.x=t;this.y=i;this.fixAndSetPosition();this._onTranslated()}getRect(e,t,i=this.rotation){const a=this.parentScale,[s,r]=this.pageDimensions,[n,o]=this.pageTranslation,l=e/a,d=t/a,c=this.x*s,h=this.y*r,_=this.width*s,u=this.height*r;switch(i){case 0:return[c+l+n,r-h-d-u+o,c+l+_+n,r-h-d+o];case 90:return[c+d+n,r-h+l+o,c+d+u+n,r-h+l+_+o];case 180:return[c-l-_+n,r-h+d+o,c-l+n,r-h+d+u+o];case 270:return[c-d-u+n,r-h-l-_+o,c-d+n,r-h-l+o];default:throw new Error("Invalid rotation")}}get normalizedPageRect(){const[e,t]=this.pageDimensions,[i,a]=this.pageTranslation,[s,r,n,o]=this.getRect(0,0),l=Math.min(s,n)-i,d=Math.max(s,n)-i,c=Math.min(r,o)-a,h=Math.max(r,o)-a;return{x:l/e,y:(t-h)/t,width:(d-l)/e,height:(h-c)/t}}getRectInCurrentCoords(e,t){const[i,a,s,r]=e,n=s-i,o=r-a;switch(this.rotation){case 0:return[i,t-r,n,o];case 90:return[i,t-a,o,n];case 180:return[s,t-a,n,o];case 270:return[s,t-r,o,n];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&AnnotationEditor._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){editor_classPrivateFieldGet(bi,this)?.onUpdatedColor()}getData(){const{comment:{text:e,color:t,date:i,opacity:a,deleted:s,richText:r},uid:n,pageIndex:o,creationDate:l,modificationDate:d}=this;return{id:n,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:e},creationDate:l,modificationDate:i||d,popupRef:!s,color:t,opacity:a}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){if(this.isInEditMode())return!1;this.parent.setEditingState(!1);editor_classPrivateFieldSet(Oi,this,!0);return!0}disableEditMode(){if(!this.isInEditMode())return!1;this.parent.setEditingState(!0);editor_classPrivateFieldSet(Oi,this,!1);return!0}isInEditMode(){return editor_classPrivateFieldGet(Oi,this)}shouldGetKeyboardEvents(){return editor_classPrivateFieldGet(Ni,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:t,bottom:i,right:a}=this.getClientDimensions(),{innerHeight:s,innerWidth:r}=window;return t<r&&a>0&&e<s&&i>0}rebuild(){editor_assertClassBrand(Xi,this,_addFocusListeners).call(this);editor_assertClassBrand(Xi,this,_addTouchManager).call(this)}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(e,t,i){const a=new this.prototype.constructor({parent:t,id:i.getId(),uiManager:i,annotationElementId:e.annotationElementId,eventBus:t.eventBus,creationDate:e.creationDate,modificationDate:e.modificationDate});a.rotation=e.rotation;editor_classPrivateFieldSet(wi,a,e.accessibilityData);a._isCopy=e.isCopy||!1;void 0!==e.customId&&null!==e.customId&&(a.customId=e.customId);const[s,r]=a.pageDimensions,[n,o,l,d]=a.getRectInCurrentCoords(e.rect,r);a.x=n/s;a.y=o/r;a.width=l/s;a.height=d/r;return a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){editor_classPrivateFieldGet(Ii,this)?.abort();editor_classPrivateFieldSet(Ii,this,null);this.isEmpty()||this.commit();editor_classPrivateFieldGet(zi,this)?.destroy();editor_classPrivateFieldSet(zi,this,null);this.parent?this.parent.remove(this):this._uiManager.removeEditor(this);this.hideCommentPopup();if(editor_classPrivateFieldGet(Wi,this)){clearTimeout(editor_classPrivateFieldGet(Wi,this));editor_classPrivateFieldSet(Wi,this,null)}editor_assertClassBrand(Xi,this,_stopResizing).call(this);this.removeEditToolbar();if(editor_classPrivateFieldGet(Ui,this)){for(const e of editor_classPrivateFieldGet(Ui,this).values())clearTimeout(e);editor_classPrivateFieldSet(Ui,this,null)}this.parent=null;this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"removed",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:this});editor_classPrivateFieldGet(Mi,this)?.remove();editor_classPrivateFieldSet(Mi,this,null)}get isResizable(){return!1}makeResizable(){if(this.isResizable){editor_assertClassBrand(Xi,this,_createResizers).call(this);editor_classPrivateFieldGet(Ai,this).classList.remove("hidden")}}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,t]}=this,[i,a,s,r]=this.getPDFRect();return[AnnotationEditor._round(i+(s-i)*e),AnnotationEditor._round(a+(r-a)*(1-t))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return editor_classPrivateFieldGet(bi,this).commentPopupPositionInLayer}set commentPopupPosition(e){editor_classPrivateFieldGet(bi,this).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return editor_classPrivateFieldGet(bi,this).hasDefaultPopupPosition()}get commentButtonWidth(){return editor_classPrivateFieldGet(bi,this).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){editor_classPrivateFieldGet(bi,this)?.setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this);editor_classPrivateFieldSet(Bi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const t=editor_classPrivateFieldGet(Ai,this).children;if(!editor_classPrivateFieldGet(Fi,this)){editor_classPrivateFieldSet(Fi,this,Array.from(t));const e=editor_assertClassBrand(Xi,this,_resizerKeydown).bind(this),i=editor_assertClassBrand(Xi,this,_resizerBlur).bind(this),a=this._uiManager._signal;for(const t of editor_classPrivateFieldGet(Fi,this)){const s=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton");t.addEventListener("keydown",e,{signal:a});t.addEventListener("blur",i,{signal:a});t.addEventListener("focus",editor_assertClassBrand(Xi,this,_resizerFocus).bind(this,s),{signal:a});t.setAttribute("data-l10n-id",AnnotationEditor._l10nResizer[s])}}const i=editor_classPrivateFieldGet(Fi,this)[0];let a=0;for(const e of t){if(e===i)break;a++}const s=(360-this.rotation+this.parentRotation)%360/90*(editor_classPrivateFieldGet(Fi,this).length/4);if(s!==a){if(s<a)for(let e=0;e<a-s;e++)editor_classPrivateFieldGet(Ai,this).append(editor_classPrivateFieldGet(Ai,this).firstElementChild);else if(s>a)for(let e=0;e<s-a;e++)editor_classPrivateFieldGet(Ai,this).firstElementChild.before(editor_classPrivateFieldGet(Ai,this).lastElementChild);let e=0;for(const i of t){const t=editor_classPrivateFieldGet(Fi,this)[e++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",AnnotationEditor._l10nResizer[t])}}editor_assertClassBrand(Xi,this,_setResizerTabIndex).call(this,0);editor_classPrivateFieldSet(Ni,this,!0);editor_classPrivateFieldGet(Ai,this).firstElementChild.focus({focusVisible:!0});e.preventDefault();e.stopImmediatePropagation()}_resizeWithKeyboard(e,t){editor_classPrivateFieldGet(Ni,this)&&editor_assertClassBrand(Xi,this,_resizerPointermove).call(this,editor_classPrivateFieldGet(Ti,this),{deltaX:e,deltaY:t,fromKeyboard:!0})}_stopResizingWithKeyboard(){editor_assertClassBrand(Xi,this,_stopResizing).call(this);this.div.focus()}select(){if(this.isSelected&&this._editToolbar)this._editToolbar.show();else{this.isSelected=!0;this.makeResizable();this.div?.classList.add("selectedEditor");if(this._editToolbar){editor_assertClassBrand(Xi,this,_showEditToolbar).call(this);editor_classPrivateFieldGet(yi,this)?.toggleAltTextBadge(!1)}else this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&editor_assertClassBrand(Xi,this,_showEditToolbar).call(this)})}}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){if(this.isSelected){this.isSelected=!1;editor_classPrivateFieldGet(Ai,this)?.classList.add("hidden");this.div?.classList.remove("selectedEditor");this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0});this._editToolbar?.hide();editor_classPrivateFieldGet(yi,this)?.toggleAltTextBadge(!0);this.hideCommentPopup()}}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){if(this.canChangeContent){this.enableEditMode();this.div.focus()}}dblclick(e){if("BUTTON"!==e.target.nodeName){this.enterInEditMode();this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid})}}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return editor_classPrivateFieldGet(Ri,this)}set isEditing(e){editor_classPrivateFieldSet(Ri,this,e);if(this.parent)if(e){this.parent.setSelected(this);this.parent.setActiveEditor(this)}else this.parent.setActiveEditor(null)}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){editor_classPrivateFieldGet(Ui,this)||editor_classPrivateFieldSet(Ui,this,new Map);const{action:t}=e;let i=editor_classPrivateFieldGet(Ui,this).get(t);i&&clearTimeout(i);i=setTimeout(()=>{this._reportTelemetry(e);editor_classPrivateFieldGet(Ui,this).delete(t);0===editor_classPrivateFieldGet(Ui,this).size&&editor_classPrivateFieldSet(Ui,this,null)},AnnotationEditor._telemetryTimeout);editor_classPrivateFieldGet(Ui,this).set(t,i);return}e.type||=this.editorType;this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e);this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0);editor_classPrivateFieldSet(Ci,this,!1)}disable(){this.div&&(this.div.tabIndex=-1);editor_classPrivateFieldSet(Ci,this,!0)}updateFakeAnnotationElement(e){if(editor_classPrivateFieldGet(Mi,this)||this.deleted)if(this.deleted){editor_classPrivateFieldGet(Mi,this).remove();editor_classPrivateFieldSet(Mi,this,null)}else(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&editor_classPrivateFieldGet(Mi,this).updateEdited({rect:this.getPDFRect(),popup:this.comment});else editor_classPrivateFieldSet(Mi,this,e.addFakeAnnotation(this))}renderAnnotationElement(e){if(this.deleted){e.hide();return null}let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){const e=t;t=document.createElement("div");t.classList.add("annotationContent",this.editorType);e.before(t)}}else{t=document.createElement("div");t.classList.add("annotationContent",this.editorType);e.container.prepend(t)}return t}resetAnnotationElement(e){const{firstElementChild:t}=e.container;"DIV"===t?.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}ii=AnnotationEditor;function _translate([e,t],i,a){[i,a]=this.screenToPageTranslation(i,a);this.x+=i/e;this.y+=a/t;this._onTranslating(this.x,this.y);this.fixAndSetPosition()}function _rotatePoint(e,t,i){switch(i){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}function _getRotationMatrix(e){switch(e){case 90:{const[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}function _createResizers(){if(editor_classPrivateFieldGet(Ai,this))return;editor_classPrivateFieldSet(Ai,this,document.createElement("div"));editor_classPrivateFieldGet(Ai,this).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const i of e){const e=document.createElement("div");editor_classPrivateFieldGet(Ai,this).append(e);e.classList.add("resizer",i);e.setAttribute("data-resizer-name",i);e.addEventListener("pointerdown",editor_assertClassBrand(Xi,this,_resizerPointerdown).bind(this,i),{signal:t});e.addEventListener("contextmenu",noContextMenu,{signal:t});e.tabIndex=-1}this.div.prepend(editor_classPrivateFieldGet(Ai,this))}function _resizerPointerdown(e,t){t.preventDefault();const{isMac:i}=FeatureTest.platform;if(0!==t.button||t.ctrlKey&&i)return;editor_classPrivateFieldGet(yi,this)?.toggle(!1);const a=this._isDraggable;this._isDraggable=!1;editor_classPrivateFieldSet(Gi,this,[t.screenX,t.screenY]);const s=new AbortController,r=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1);window.addEventListener("pointermove",editor_assertClassBrand(Xi,this,_resizerPointermove).bind(this,e),{passive:!0,capture:!0,signal:r});window.addEventListener("touchmove",stopEvent,{passive:!1,signal:r});window.addEventListener("contextmenu",noContextMenu,{signal:r});editor_classPrivateFieldSet(Bi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const pointerUpCallback=()=>{s.abort();this.parent.togglePointerEvents(!0);editor_classPrivateFieldGet(yi,this)?.toggle(!0);this._isDraggable=a;this.parent.div.style.cursor=n;this.div.style.cursor=o;editor_assertClassBrand(Xi,this,_addResizeToUndoStack).call(this)};window.addEventListener("pointerup",pointerUpCallback,{signal:r});window.addEventListener("blur",pointerUpCallback,{signal:r})}function _resize(e,t,i,a){this.width=i;this.height=a;this.x=e;this.y=t;this.setDims();this.fixAndSetPosition();this._onResized()}function _addResizeToUndoStack(){if(!editor_classPrivateFieldGet(Bi,this))return;const{savedX:e,savedY:t,savedWidth:i,savedHeight:a}=editor_classPrivateFieldGet(Bi,this);editor_classPrivateFieldSet(Bi,this,null);const s=this.x,r=this.y,n=this.width,o=this.height;if(s!==e||r!==t||n!==i||o!==a){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"sizeChanged",editorType:this.constructor.name,id:this.uid,page:this.pageIndex+1,value:{x:e,y:t,width:i,height:a}});this.addCommands({cmd:editor_assertClassBrand(Xi,this,_resize).bind(this,s,r,n,o),undo:editor_assertClassBrand(Xi,this,_resize).bind(this,e,t,i,a),mustExec:!0})}}function _resizerPointermove(e,t){const[i,a]=this.parentDimensions,s=this.x,r=this.y,n=this.width,o=this.height,l=ii.MIN_SIZE/i,d=ii.MIN_SIZE/a,c=editor_assertClassBrand(Xi,this,_getRotationMatrix).call(this,this.rotation),transf=(e,t)=>[c[0]*e+c[2]*t,c[1]*e+c[3]*t],h=editor_assertClassBrand(Xi,this,_getRotationMatrix).call(this,360-this.rotation);let _,u,p=!1,g=!1;switch(e){case"topLeft":p=!0;_=(e,t)=>[0,0];u=(e,t)=>[e,t];break;case"topMiddle":_=(e,t)=>[e/2,0];u=(e,t)=>[e/2,t];break;case"topRight":p=!0;_=(e,t)=>[e,0];u=(e,t)=>[0,t];break;case"middleRight":g=!0;_=(e,t)=>[e,t/2];u=(e,t)=>[0,t/2];break;case"bottomRight":p=!0;_=(e,t)=>[e,t];u=(e,t)=>[0,0];break;case"bottomMiddle":_=(e,t)=>[e/2,t];u=(e,t)=>[e/2,0];break;case"bottomLeft":p=!0;_=(e,t)=>[0,t];u=(e,t)=>[e,0];break;case"middleLeft":g=!0;_=(e,t)=>[0,t/2];u=(e,t)=>[e,t/2]}const m=_(n,o),f=u(n,o);let v=transf(...f);const P=ii._round(s+v[0]),w=ii._round(r+v[1]);let F,y,b=1,S=1;if(t.fromKeyboard)({deltaX:F,deltaY:y}=t);else{const{screenX:e,screenY:i}=t,[a,s]=editor_classPrivateFieldGet(Gi,this);[F,y]=this.screenToPageTranslation(e-a,i-s);editor_classPrivateFieldGet(Gi,this)[0]=e;editor_classPrivateFieldGet(Gi,this)[1]=i}[F,y]=(C=F/i,x=y/a,[h[0]*C+h[2]*x,h[1]*C+h[3]*x]);var C,x;if(p){const e=Math.hypot(n,o);b=S=Math.max(Math.min(Math.hypot(f[0]-m[0]-F,f[1]-m[1]-y)/e,1/n,1/o),l/n,d/o)}else g?b=MathClamp(Math.abs(f[0]-m[0]-F),l,1)/n:S=MathClamp(Math.abs(f[1]-m[1]-y),d,1)/o;const k=ii._round(n*b),E=ii._round(o*S);v=transf(...u(k,E));const A=P-v[0],G=w-v[1];editor_classPrivateFieldGet(Li,this)||editor_classPrivateFieldSet(Li,this,[this.x,this.y,this.width,this.height]);this.width=k;this.height=E;this.x=A;this.y=G;this.setDims();this.fixAndSetPosition();this._onResizing()}function _touchPinchStartCallback(){editor_classPrivateFieldSet(Bi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});editor_classPrivateFieldGet(yi,this)?.toggle(!1);this.parent.togglePointerEvents(!1)}function _touchPinchCallback(e,t,i){let a=i/t*.7+1-.7;if(1===a)return;const s=editor_assertClassBrand(Xi,this,_getRotationMatrix).call(this,this.rotation),transf=(e,t)=>[s[0]*e+s[2]*t,s[1]*e+s[3]*t],[r,n]=this.parentDimensions,o=this.x,l=this.y,d=this.width,c=this.height,h=ii.MIN_SIZE/r,_=ii.MIN_SIZE/n;a=Math.max(Math.min(a,1/d,1/c),h/d,_/c);const u=ii._round(d*a),p=ii._round(c*a);if(u===d&&p===c)return;editor_classPrivateFieldGet(Li,this)||editor_classPrivateFieldSet(Li,this,[o,l,d,c]);const g=transf(d/2,c/2),m=ii._round(o+g[0]),f=ii._round(l+g[1]),v=transf(u/2,p/2);this.x=m-v[0];this.y=f-v[1];this.width=u;this.height=p;this.setDims();this.fixAndSetPosition();this._onResizing()}function _touchPinchEndCallback(){editor_classPrivateFieldGet(yi,this)?.toggle(!0);this.parent.togglePointerEvents(!0);editor_assertClassBrand(Xi,this,_addResizeToUndoStack).call(this)}function _selectOnPointerEvent(e){const{isMac:t}=FeatureTest.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}function _setUpDragSession(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();let i=!1;const a=new AbortController,s=this._uiManager.combinedSignal(a),r={capture:!0,passive:!1,signal:s},cancelDrag=e=>{a.abort();editor_classPrivateFieldSet(xi,this,null);editor_classPrivateFieldSet(Di,this,!1);this._uiManager.endDragSession()||editor_assertClassBrand(Xi,this,_selectOnPointerEvent).call(this,e);i&&this._onStopDragging()};if(t){editor_classPrivateFieldSet(ji,this,e.clientX);editor_classPrivateFieldSet(Vi,this,e.clientY);editor_classPrivateFieldSet(xi,this,e.pointerId);editor_classPrivateFieldSet(ki,this,e.pointerType);window.addEventListener("pointermove",e=>{if(!i){i=!0;this._uiManager.toggleComment(this,!0,!1);this._onStartDragging()}const{clientX:t,clientY:a,pointerId:s}=e;if(s!==editor_classPrivateFieldGet(xi,this)){stopEvent(e);return}const[r,n]=this.screenToPageTranslation(t-editor_classPrivateFieldGet(ji,this),a-editor_classPrivateFieldGet(Vi,this));editor_classPrivateFieldSet(ji,this,t);editor_classPrivateFieldSet(Vi,this,a);this._uiManager.dragSelectedEditors(r,n);this.div.scrollIntoView({block:"nearest"})},r);window.addEventListener("touchmove",stopEvent,r);window.addEventListener("pointerdown",e=>{e.pointerType===editor_classPrivateFieldGet(ki,this)&&(editor_classPrivateFieldGet(zi,this)||e.isPrimary)&&cancelDrag(e);stopEvent(e)},r)}const pointerUpCallback=e=>{editor_classPrivateFieldGet(xi,this)&&editor_classPrivateFieldGet(xi,this)!==e.pointerId?stopEvent(e):cancelDrag(e)};window.addEventListener("pointerup",pointerUpCallback,{signal:s});window.addEventListener("blur",pointerUpCallback,{signal:s})}function _addFocusListeners(){if(editor_classPrivateFieldGet(Ii,this)||!this.div)return;editor_classPrivateFieldSet(Ii,this,new AbortController);const e=this._uiManager.combinedSignal(editor_classPrivateFieldGet(Ii,this));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e});this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}function _addTouchManager(){!editor_classPrivateFieldGet(zi,this)&&this.div&&this.isResizable&&this._uiManager._supportsPinchToZoom&&editor_classPrivateFieldSet(zi,this,new TouchManager({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:editor_assertClassBrand(Xi,this,_touchPinchStartCallback).bind(this),onPinching:editor_assertClassBrand(Xi,this,_touchPinchCallback).bind(this),onPinchEnd:editor_assertClassBrand(Xi,this,_touchPinchEndCallback).bind(this),signal:this._uiManager._signal}))}function _resizerKeydown(e){ii._resizerKeyboardManager.exec(this,e)}function _resizerBlur(e){editor_classPrivateFieldGet(Ni,this)&&e.relatedTarget?.parentNode!==editor_classPrivateFieldGet(Ai,this)&&editor_assertClassBrand(Xi,this,_stopResizing).call(this)}function _resizerFocus(e){editor_classPrivateFieldSet(Ti,this,editor_classPrivateFieldGet(Ni,this)?e:"")}function _setResizerTabIndex(e){if(editor_classPrivateFieldGet(Fi,this))for(const t of editor_classPrivateFieldGet(Fi,this))t.tabIndex=e}function _stopResizing(){editor_classPrivateFieldSet(Ni,this,!1);editor_assertClassBrand(Xi,this,_setResizerTabIndex).call(this,-1);editor_assertClassBrand(Xi,this,_addResizeToUndoStack).call(this)}function _showEditToolbar(){this._editToolbar?.show();if(this._uiManager._keepToolbarInPage){this.fixAndSetPosition();this._onTranslated()}}editor_defineProperty(AnnotationEditor,"_l10n",null);editor_defineProperty(AnnotationEditor,"_l10nAlert",null);editor_defineProperty(AnnotationEditor,"_l10nResizer",null);editor_defineProperty(AnnotationEditor,"_borderLineWidth",-1);editor_defineProperty(AnnotationEditor,"_colorManager",new ColorManager);editor_defineProperty(AnnotationEditor,"_zIndex",1);editor_defineProperty(AnnotationEditor,"_telemetryTimeout",1e3);class FakeEditor extends AnnotationEditor{constructor(e){super(e);this.annotationElementId=e.annotationElementId;this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ki=3285377520,qi=4294901760,Yi=65535;class MurmurHash3_64{constructor(e){this.h1=e?4294967295&e:Ki;this.h2=e?4294967295&e:Ki}update(e){let t,i;if("string"==typeof e){t=new Uint8Array(2*e.length);i=0;for(let a=0,s=e.length;a<s;a++){const s=e.charCodeAt(a);if(s<=255)t[i++]=s;else{t[i++]=s>>>8;t[i++]=255&s}}}else{if(!ArrayBuffer.isView(e))throw new Error("Invalid data format, must be a string or TypedArray.");t=e.slice();i=t.byteLength}const a=i>>2,s=i-4*a,r=new Uint32Array(t.buffer,0,a);let n=0,o=0,l=this.h1,d=this.h2;const c=3432918353,h=461845907,_=11601,u=13715;for(let e=0;e<a;e++)if(1&e){n=r[e];n=n*c&qi|n*_&Yi;n=n<<15|n>>>17;n=n*h&qi|n*u&Yi;l^=n;l=l<<13|l>>>19;l=5*l+3864292196}else{o=r[e];o=o*c&qi|o*_&Yi;o=o<<15|o>>>17;o=o*h&qi|o*u&Yi;d^=o;d=d<<13|d>>>19;d=5*d+3864292196}n=0;switch(s){case 3:n^=t[4*a+2]<<16;case 2:n^=t[4*a+1]<<8;case 1:n^=t[4*a];n=n*c&qi|n*_&Yi;n=n<<15|n>>>17;n=n*h&qi|n*u&Yi;1&a?l^=n:d^=n}this.h1=l;this.h2=d}hexdigest(){let e=this.h1,t=this.h2;e^=t>>>1;e=3981806797*e&qi|36045*e&Yi;t=4283543511*t&qi|(2950163797*(t<<16|e>>>16)&qi)>>>16;e^=t>>>1;e=444984403*e&qi|60499*e&Yi;t=3301882366*t&qi|(3120437893*(t<<16|e>>>16)&qi)>>>16;e^=t>>>1;return(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}function annotation_storage_defineProperty(e,t,i){return(t=function annotation_storage_toPropertyKey(e){var t=function annotation_storage_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function annotation_storage_classPrivateFieldInitSpec(e,t,i){annotation_storage_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_storage_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_storage_classPrivateFieldSet(e,t,i){return e.set(annotation_storage_assertClassBrand(e,t),i),i}function annotation_storage_classPrivateFieldGet(e,t){return e.get(annotation_storage_assertClassBrand(e,t))}function annotation_storage_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Zi=Object.freeze({map:null,hash:"",transfer:void 0});var Qi=new WeakMap,Ji=new WeakMap,ea=new WeakMap,ta=new WeakMap,ia=new WeakSet;class AnnotationStorage{constructor(){!function annotation_storage_classPrivateMethodInitSpec(e,t){annotation_storage_checkPrivateRedeclaration(e,t),t.add(e)}(this,ia);annotation_storage_classPrivateFieldInitSpec(this,Qi,!1);annotation_storage_classPrivateFieldInitSpec(this,Ji,null);annotation_storage_classPrivateFieldInitSpec(this,ea,null);annotation_storage_classPrivateFieldInitSpec(this,ta,new Map);annotation_storage_defineProperty(this,"onSetModified",null);annotation_storage_defineProperty(this,"onResetModified",null);annotation_storage_defineProperty(this,"onAnnotationEditor",null)}getValue(e,t){const i=annotation_storage_classPrivateFieldGet(ta,this).get(e);return void 0===i?t:Object.assign(t,i)}getRawValue(e){return annotation_storage_classPrivateFieldGet(ta,this).get(e)}remove(e){const t=annotation_storage_classPrivateFieldGet(ta,this).get(e);if(void 0!==t){t instanceof AnnotationEditor&&annotation_storage_classPrivateFieldGet(ea,this).delete(t.annotationElementId);annotation_storage_classPrivateFieldGet(ta,this).delete(e);0===annotation_storage_classPrivateFieldGet(ta,this).size&&this.resetModified();annotation_storage_classPrivateFieldGet(ta,this).values().some(e=>e instanceof AnnotationEditor)||this.onAnnotationEditor?.(null)}}setValue(e,t){const i=annotation_storage_classPrivateFieldGet(ta,this).get(e);let a=!1;if(void 0!==i){for(const[e,s]of Object.entries(t))if(i[e]!==s){a=!0;i[e]=s}}else{a=!0;annotation_storage_classPrivateFieldGet(ta,this).set(e,t)}a&&annotation_storage_assertClassBrand(ia,this,_setModified).call(this);if(t instanceof AnnotationEditor){(annotation_storage_classPrivateFieldGet(ea,this)||annotation_storage_classPrivateFieldSet(ea,this,new Map)).set(t.annotationElementId,t);this.onAnnotationEditor?.(t.constructor._type)}}has(e){return annotation_storage_classPrivateFieldGet(ta,this).has(e)}get size(){return annotation_storage_classPrivateFieldGet(ta,this).size}resetModified(){if(annotation_storage_classPrivateFieldGet(Qi,this)){annotation_storage_classPrivateFieldSet(Qi,this,!1);this.onResetModified?.()}}get print(){return new PrintAnnotationStorage(this)}get serializable(){if(0===annotation_storage_classPrivateFieldGet(ta,this).size)return Zi;const e=new Map,t=new MurmurHash3_64,i=[],a=Object.create(null);let s=!1;for(const[i,r]of annotation_storage_classPrivateFieldGet(ta,this)){const n=r instanceof AnnotationEditor?r.serialize(!1,a):r;if(r.page){r.pageIndex=r.page._pageIndex;delete r.page}if(n){e.set(i,n);t.update(`${i}:${JSON.stringify(n)}`);s||=!!n.bitmap}}if(s)for(const t of e.values())t.bitmap&&i.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:i}:Zi}get editorStats(){let e=null;const t=new Map;let i=0,a=0;for(const s of annotation_storage_classPrivateFieldGet(ta,this).values()){if(!(s instanceof AnnotationEditor)){s.popup&&(s.popup.deleted?a+=1:i+=1);continue}s.isCommentDeleted?a+=1:s.hasEditedComment&&(i+=1);const r=s.telemetryFinalData;if(!r)continue;const{type:n}=r;t.getOrInsertComputed(n,()=>Object.getPrototypeOf(s).constructor);e||=Object.create(null);const o=e[n]||=new Map;for(const[e,t]of Object.entries(r)){if("type"===e)continue;const i=o.getOrInsertComputed(e,makeMap);i.set(t,(i.get(t)??0)+1)}}if(a>0||i>0){e||=Object.create(null);e.comments={deleted:a,edited:i}}if(!e)return null;for(const[i,a]of t)e[i]=a.computeTelemetryFinalData(e[i]);return e}resetModifiedIds(){annotation_storage_classPrivateFieldSet(Ji,this,null)}updateEditor(e,t){const i=annotation_storage_classPrivateFieldGet(ea,this)?.get(e);if(i){i.updateFromAnnotationLayer(t);return!0}return!1}getEditor(e){return annotation_storage_classPrivateFieldGet(ea,this)?.get(e)||null}get modifiedIds(){if(annotation_storage_classPrivateFieldGet(Ji,this))return annotation_storage_classPrivateFieldGet(Ji,this);const e=[];if(annotation_storage_classPrivateFieldGet(ea,this))for(const t of annotation_storage_classPrivateFieldGet(ea,this).values())t.serialize()&&e.push(t.annotationElementId);let t="";if(e.length){const i=new MurmurHash3_64;i.update(e.join(","));t=i.hexdigest()}return annotation_storage_classPrivateFieldSet(Ji,this,{ids:new Set(e),hash:t})}[Symbol.iterator](){return annotation_storage_classPrivateFieldGet(ta,this).entries()}}function _setModified(){if(!annotation_storage_classPrivateFieldGet(Qi,this)){annotation_storage_classPrivateFieldSet(Qi,this,!0);this.onSetModified?.()}}var aa=new WeakMap;class PrintAnnotationStorage extends AnnotationStorage{constructor(e){super();annotation_storage_classPrivateFieldInitSpec(this,aa,Zi);const{serializable:t}=e;if(t===Zi)return;const{map:i,hash:a,transfer:s}=t,r=structuredClone(i,s?{transfer:s}:null);annotation_storage_classPrivateFieldSet(aa,this,{map:r,hash:a,transfer:[]})}get print(){unreachable("Should not call PrintAnnotationStorage.print")}get serializable(){return annotation_storage_classPrivateFieldGet(aa,this)}get modifiedIds(){return shadow(this,"modifiedIds",{ids:new Set,hash:""})}}function api_utils_defineProperty(e,t,i){return(t=function api_utils_toPropertyKey(e){var t=function api_utils_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function api_utils_classPrivateFieldInitSpec(e,t,i){(function api_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function api_utils_classPrivateFieldGet(e,t){return e.get(function api_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}function getFactoryUrlProp(e){if("string"!=typeof e)return null;if(e.endsWith("/"))return e;throw new Error(`Invalid factory url: "${e}" must include trailing slash.`)}const isRefProxy=e=>"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,sa=function _isValidExplicitDest(e,t,i){if(!Array.isArray(i)||i.length<2)return!1;const[a,s,...r]=i;if(!e(a)&&!Number.isInteger(a))return!1;if(!t(s))return!1;const n=r.length;let o=!0;switch(s.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return 0===n;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(4!==n)return!1;o=!1;break;default:return!1}for(const e of r)if(!("number"==typeof e||o&&null===e))return!1;return!0}.bind(null,isRefProxy,e=>"object"==typeof e&&"string"==typeof e?.name);function getWorkerSrc(e){if(!function isSameOrigin(e,t){const i=URL.parse(e);if(!i?.origin||"null"===i.origin)return!1;const a=new URL(t,i);return i.origin===a.origin}(window.location,e)){const t=`await import("${new URL(e,window.location).href}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return e}var ra=new WeakMap,na=new WeakMap;class LoopbackPort{constructor(){api_utils_classPrivateFieldInitSpec(this,ra,new Map);api_utils_classPrivateFieldInitSpec(this,na,Promise.resolve())}postMessage(e,t){const i={data:structuredClone(e,t?{transfer:t}:null)};api_utils_classPrivateFieldGet(na,this).then(()=>{for(const[e]of api_utils_classPrivateFieldGet(ra,this))e.call(this,i)})}addEventListener(e,t,i=null){let a=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted){warn("LoopbackPort - cannot use an `aborted` signal.");return}const onAbort=()=>this.removeEventListener(e,t);a=()=>s.removeEventListener("abort",onAbort);s.addEventListener("abort",onAbort)}api_utils_classPrivateFieldGet(ra,this).set(t,a)}removeEventListener(e,t){const i=api_utils_classPrivateFieldGet(ra,this).get(t);i?.();api_utils_classPrivateFieldGet(ra,this).delete(t)}terminate(){for(const[,e]of api_utils_classPrivateFieldGet(ra,this))e?.();api_utils_classPrivateFieldGet(ra,this).clear()}}var oa=new WeakMap;class StatTimer{constructor(){api_utils_classPrivateFieldInitSpec(this,oa,new Map);api_utils_defineProperty(this,"times",[])}time(e){api_utils_classPrivateFieldGet(oa,this).has(e)&&warn(`Timer is already running for ${e}`);api_utils_classPrivateFieldGet(oa,this).set(e,Date.now())}timeEnd(e){api_utils_classPrivateFieldGet(oa,this).has(e)||warn(`Timer has not been started for ${e}`);this.times.push({name:e,start:api_utils_classPrivateFieldGet(oa,this).get(e),end:Date.now()});api_utils_classPrivateFieldGet(oa,this).delete(e)}toString(){const e=Math.max(...this.times.map(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join("")}}function webgpu_classPrivateFieldInitSpec(e,t,i){webgpu_checkPrivateRedeclaration(e,t),t.set(e,i)}function webgpu_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function webgpu_classPrivateFieldGet(e,t){return e.get(webgpu_assertClassBrand(e,t))}function webgpu_classPrivateFieldSet(e,t,i){return e.set(webgpu_assertClassBrand(e,t),i),i}function webgpu_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var la=new WeakMap,da=new WeakMap,ca=new WeakMap,ha=new WeakMap,_a=new WeakSet;async function _initGPU(){if(!globalThis.navigator?.gpu)return!1;try{const e=await navigator.gpu.requestAdapter();if(!e)return!1;webgpu_classPrivateFieldSet(ha,this,navigator.gpu.getPreferredCanvasFormat());webgpu_classPrivateFieldSet(da,this,await e.requestDevice());return!0}catch{return!1}}const ua=new class WebGPU{constructor(){!function webgpu_classPrivateMethodInitSpec(e,t){webgpu_checkPrivateRedeclaration(e,t),t.add(e)}(this,_a);webgpu_classPrivateFieldInitSpec(this,la,null);webgpu_classPrivateFieldInitSpec(this,da,null);webgpu_classPrivateFieldInitSpec(this,ca,null);webgpu_classPrivateFieldInitSpec(this,ha,null)}init(){return webgpu_classPrivateFieldGet(la,this)||webgpu_classPrivateFieldSet(la,this,webgpu_assertClassBrand(_a,this,_initGPU).call(this))}get isReady(){return null!==webgpu_classPrivateFieldGet(da,this)}loadMeshShader(){if(!webgpu_classPrivateFieldGet(da,this)||webgpu_classPrivateFieldGet(ca,this))return;const e=webgpu_classPrivateFieldGet(da,this).createShaderModule({code:"\nstruct Uniforms {\n  offsetX      : f32,\n  offsetY      : f32,\n  scaleX       : f32,\n  scaleY       : f32,\n  paddedWidth  : f32,\n  paddedHeight : f32,\n  borderSize   : f32,\n  _pad         : f32,\n};\n\n@group(0) @binding(0) var<uniform> u : Uniforms;\n\nstruct VertexInput {\n  @location(0) position : vec2<f32>,\n  @location(1) color    : vec4<f32>,\n};\n\nstruct VertexOutput {\n  @builtin(position) position : vec4<f32>,\n  @location(0)       color    : vec3<f32>,\n};\n\n@vertex\nfn vs_main(in : VertexInput) -> VertexOutput {\n  var out : VertexOutput;\n  let cx = (in.position.x + u.offsetX) * u.scaleX;\n  let cy = (in.position.y + u.offsetY) * u.scaleY;\n  out.position = vec4<f32>(\n    ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,\n    1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,\n    0.0,\n    1.0\n  );\n  out.color = in.color.rgb;\n  return out;\n}\n\n@fragment\nfn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {\n  return vec4<f32>(in.color, 1.0);\n}\n"});webgpu_classPrivateFieldSet(ca,this,webgpu_classPrivateFieldGet(da,this).createRenderPipeline({layout:"auto",vertex:{module:e,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:e,entryPoint:"fs_main",targets:[{format:webgpu_classPrivateFieldGet(ha,this)}]},primitive:{topology:"triangle-list"}}))}draw(e,t,i,a,s,r,n,o){this.loadMeshShader();const l=webgpu_classPrivateFieldGet(da,this),{offsetX:d,offsetY:c,scaleX:h,scaleY:_}=a,u=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(u,0,e);const p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);const g=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(g,0,new Float32Array([d,c,h,_,r,n,o,0]));const m=l.createBindGroup({layout:webgpu_classPrivateFieldGet(ca,this).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),f=new OffscreenCanvas(r,n),v=f.getContext("webgpu");v.configure({device:l,format:webgpu_classPrivateFieldGet(ha,this),alphaMode:s?"opaque":"premultiplied"});const P=s?{r:s[0]/255,g:s[1]/255,b:s[2]/255,a:1}:{r:0,g:0,b:0,a:0},w=l.createCommandEncoder(),F=w.beginRenderPass({colorAttachments:[{view:v.getCurrentTexture().createView(),clearValue:P,loadOp:"clear",storeOp:"store"}]});if(i>0){F.setPipeline(webgpu_classPrivateFieldGet(ca,this));F.setBindGroup(0,m);F.setVertexBuffer(0,u);F.setVertexBuffer(1,p);F.draw(i)}F.end();l.queue.submit([w.finish()]);u.destroy();p.destroy();g.destroy();return f.transferToImageBitmap()}};function initGPU(){return ua.init()}function isGPUReady(){return ua.isReady}function message_handler_classPrivateFieldInitSpec(e,t,i){message_handler_checkPrivateRedeclaration(e,t),t.set(e,i)}function message_handler_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function message_handler_classPrivateFieldGet(e,t){return e.get(message_handler_assertClassBrand(e,t))}function message_handler_classPrivateFieldSet(e,t,i){return e.set(message_handler_assertClassBrand(e,t),i),i}function message_handler_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const pa=1,ga=2,ma=1,fa=2,va=3,Pa=4,wa=5,Fa=6,ya=7,ba=8;function onFn(){}function wrapReason(e){if(e instanceof AbortException||e instanceof InvalidPDFException||e instanceof PasswordException||e instanceof ResponseException||e instanceof UnknownErrorException)return e;if("object"!=typeof e||null===e)return new UnknownErrorException(String(e),String(e));switch(e.name){case"AbortException":return new AbortException(e.message);case"InvalidPDFException":return new InvalidPDFException(e.message);case"PasswordException":return new PasswordException(e.message,e.code);case"ResponseException":return new ResponseException(e.message,e.status,e.missing);case"UnknownErrorException":return new UnknownErrorException(e.message,e.details)}return new UnknownErrorException(e.message,e.toString())}var Sa=new WeakMap,Ca=new WeakMap,xa=new WeakMap,ka=new WeakMap,Ea=new WeakMap,Aa=new WeakMap,Ga=new WeakMap,Ba=new WeakMap,Ma=new WeakMap,Ia=new WeakMap,Ta=new WeakSet;class MessageHandler{constructor(e,t,i){!function message_handler_classPrivateMethodInitSpec(e,t){message_handler_checkPrivateRedeclaration(e,t),t.add(e)}(this,Ta);message_handler_classPrivateFieldInitSpec(this,Sa,new Map);message_handler_classPrivateFieldInitSpec(this,Ca,new Map);message_handler_classPrivateFieldInitSpec(this,xa,1);message_handler_classPrivateFieldInitSpec(this,ka,void 0);message_handler_classPrivateFieldInitSpec(this,Ea,new AbortController);message_handler_classPrivateFieldInitSpec(this,Aa,void 0);message_handler_classPrivateFieldInitSpec(this,Ga,new Map);message_handler_classPrivateFieldInitSpec(this,Ba,1);message_handler_classPrivateFieldInitSpec(this,Ma,new Map);message_handler_classPrivateFieldInitSpec(this,Ia,void 0);message_handler_classPrivateFieldSet(Aa,this,e);message_handler_classPrivateFieldSet(Ia,this,t);message_handler_classPrivateFieldSet(ka,this,i);i.addEventListener("message",message_handler_assertClassBrand(Ta,this,_onMessage).bind(this),{signal:message_handler_classPrivateFieldGet(Ea,this).signal})}on(e,t){const i=message_handler_classPrivateFieldGet(Sa,this);if(i.has(e))throw new Error(`There is already a "${e}" handler.`);i.set(e,t)}send(e,t,i){message_handler_classPrivateFieldGet(ka,this).postMessage({sourceName:message_handler_classPrivateFieldGet(Aa,this),targetName:message_handler_classPrivateFieldGet(Ia,this),action:e,data:t},i)}sendWithPromise(e,t,i){var a,s;const r=(message_handler_classPrivateFieldSet(xa,this,(a=message_handler_classPrivateFieldGet(xa,this),s=a++,a)),s),n=Promise.withResolvers();message_handler_classPrivateFieldGet(Ca,this).set(r,n);try{message_handler_classPrivateFieldGet(ka,this).postMessage({sourceName:message_handler_classPrivateFieldGet(Aa,this),targetName:message_handler_classPrivateFieldGet(Ia,this),action:e,callbackId:r,data:t},i)}catch(e){n.reject(e)}return n.promise}sendWithStream(e,t,i,a){var s,r;const n=(message_handler_classPrivateFieldSet(Ba,this,(s=message_handler_classPrivateFieldGet(Ba,this),r=s++,s)),r),o=message_handler_classPrivateFieldGet(Aa,this),l=message_handler_classPrivateFieldGet(Ia,this),d=message_handler_classPrivateFieldGet(ka,this);return new ReadableStream({start:i=>{const s=Promise.withResolvers();message_handler_classPrivateFieldGet(Ga,this).set(n,{controller:i,startCall:s,pullCall:null,cancelCall:null,isClosed:!1});d.postMessage({sourceName:o,targetName:l,action:e,streamId:n,data:t,desiredSize:i.desiredSize},a);return s.promise},pull:e=>{const t=Promise.withResolvers();message_handler_classPrivateFieldGet(Ga,this).get(n).pullCall=t;d.postMessage({sourceName:o,targetName:l,stream:Fa,streamId:n,desiredSize:e.desiredSize});return t.promise},cancel:e=>{assert(e instanceof Error,"cancel must have a valid reason");const t=Promise.withResolvers();message_handler_classPrivateFieldGet(Ga,this).get(n).cancelCall=t;message_handler_classPrivateFieldGet(Ga,this).get(n).isClosed=!0;d.postMessage({sourceName:o,targetName:l,stream:ma,streamId:n,reason:wrapReason(e)});return t.promise}},i)}destroy(){message_handler_classPrivateFieldGet(Ea,this)?.abort();message_handler_classPrivateFieldSet(Ea,this,null)}get destroyed(){return!message_handler_classPrivateFieldGet(Ea,this)}}function _onMessage({data:e}){if(e.targetName!==message_handler_classPrivateFieldGet(Aa,this))return;if(e.stream){message_handler_assertClassBrand(Ta,this,_processStreamMessage).call(this,e);return}if(e.callback){const{callbackId:t,callback:i}=e,a=message_handler_classPrivateFieldGet(Ca,this).get(t);if(!a)throw new Error(`Cannot resolve callback ${t}`);message_handler_classPrivateFieldGet(Ca,this).delete(t);if(i===pa)a.resolve(e.data);else{if(i!==ga)throw new Error("Unexpected callback case");a.reject(wrapReason(e.reason))}return}const t=message_handler_classPrivateFieldGet(Sa,this).get(e.action);if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const i=message_handler_classPrivateFieldGet(Aa,this),a=e.sourceName,s=message_handler_classPrivateFieldGet(ka,this);Promise.try(t,e.data).then(t=>{s.postMessage({sourceName:i,targetName:a,callback:pa,callbackId:e.callbackId,data:t})}).catch(t=>{s.postMessage({sourceName:i,targetName:a,callback:ga,callbackId:e.callbackId,reason:wrapReason(t)})});return}e.streamId?message_handler_assertClassBrand(Ta,this,_createStreamSink).call(this,e):t(e.data)}function _createStreamSink(e){const t=e.streamId,i=message_handler_classPrivateFieldGet(Aa,this),a=e.sourceName,s=message_handler_classPrivateFieldGet(ka,this),r=message_handler_classPrivateFieldGet(Ma,this),n=message_handler_classPrivateFieldGet(Sa,this).get(e.action),o={enqueue(e,r=1,n){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r;if(o>0&&this.desiredSize<=0){this.sinkCapability=Promise.withResolvers();this.ready=this.sinkCapability.promise}s.postMessage({sourceName:i,targetName:a,stream:Pa,streamId:t,chunk:e},n)},close(){if(!this.isCancelled){this.isCancelled=!0;s.postMessage({sourceName:i,targetName:a,stream:va,streamId:t});r.delete(t)}},error(e){if(!this.isCancelled){this.isCancelled=!0;s.postMessage({sourceName:i,targetName:a,stream:wa,streamId:t,reason:wrapReason(e)})}},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};o.sinkCapability.resolve();o.ready=o.sinkCapability.promise;r.set(t,o);Promise.try(n,e.data,o).then(()=>{s.postMessage({sourceName:i,targetName:a,stream:ba,streamId:t,success:!0})},e=>{s.postMessage({sourceName:i,targetName:a,stream:ba,streamId:t,reason:wrapReason(e)})})}function _processStreamMessage(e){const t=e.streamId,i=message_handler_classPrivateFieldGet(Aa,this),a=e.sourceName,s=message_handler_classPrivateFieldGet(ka,this),r=message_handler_classPrivateFieldGet(Ga,this).get(t),n=message_handler_classPrivateFieldGet(Ma,this).get(t);switch(e.stream){case ba:e.success?r.startCall.resolve():r.startCall.reject(wrapReason(e.reason));break;case ya:e.success?r.pullCall.resolve():r.pullCall.reject(wrapReason(e.reason));break;case Fa:if(!n){s.postMessage({sourceName:i,targetName:a,stream:ya,streamId:t,success:!0});break}n.desiredSize<=0&&e.desiredSize>0&&n.sinkCapability.resolve();n.desiredSize=e.desiredSize;Promise.try(n.onPull||onFn).then(()=>{s.postMessage({sourceName:i,targetName:a,stream:ya,streamId:t,success:!0})},e=>{s.postMessage({sourceName:i,targetName:a,stream:ya,streamId:t,reason:wrapReason(e)})});break;case Pa:assert(r,"enqueue should have stream controller");if(r.isClosed)break;r.controller.enqueue(e.chunk);break;case va:assert(r,"close should have stream controller");if(r.isClosed)break;r.isClosed=!0;r.controller.close();message_handler_assertClassBrand(Ta,this,_deleteStreamController).call(this,r,t);break;case wa:assert(r,"error should have stream controller");r.controller.error(wrapReason(e.reason));message_handler_assertClassBrand(Ta,this,_deleteStreamController).call(this,r,t);break;case fa:e.success?r.cancelCall.resolve():r.cancelCall.reject(wrapReason(e.reason));message_handler_assertClassBrand(Ta,this,_deleteStreamController).call(this,r,t);break;case ma:if(!n)break;const o=wrapReason(e.reason);Promise.try(n.onCancel||onFn,o).then(()=>{s.postMessage({sourceName:i,targetName:a,stream:fa,streamId:t,success:!0})},e=>{s.postMessage({sourceName:i,targetName:a,stream:fa,streamId:t,reason:wrapReason(e)})});n.sinkCapability.reject(o);n.isCancelled=!0;message_handler_classPrivateFieldGet(Ma,this).delete(t);break;default:throw new Error("Unexpected stream case")}}async function _deleteStreamController(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]);message_handler_classPrivateFieldGet(Ga,this).delete(t)}function binary_data_factory_classPrivateFieldInitSpec(e,t,i){(function binary_data_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function binary_data_factory_classPrivateFieldGet(e,t){return e.get(function binary_data_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}var Da=new WeakMap;class BaseBinaryDataFactory{constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:i=null}){binary_data_factory_classPrivateFieldInitSpec(this,Da,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=e;this.standardFontDataUrl=t;this.wasmUrl=i}async fetch({kind:e,filename:t}){switch(e){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:unreachable(`Not implemented: ${e}`)}const i=this[e];if(!i)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const a=`${i}${t}`;return this._fetch(a,e).catch(t=>{throw new Error(`Unable to load ${binary_data_factory_classPrivateFieldGet(Da,this)[e]} data at: ${a}`)})}async _fetch(e,t){unreachable("Abstract method `_fetch` called.")}}class DOMBinaryDataFactory extends BaseBinaryDataFactory{async _fetch(e,t){const i="cMapUrl"!==t||e.endsWith(".bcmap")?"bytes":"text",a=await fetchData(e,i);return a instanceof Uint8Array?a:stringToBytes(a)}}function canvas_factory_classPrivateFieldInitSpec(e,t,i){(function canvas_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function canvas_factory_classPrivateFieldGet(e,t){return e.get(canvas_factory_assertClassBrand(e,t))}function canvas_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var La=new WeakMap;class BaseCanvasFactory{constructor({enableHWA:e=!1}){canvas_factory_classPrivateFieldInitSpec(this,La,!1);!function canvas_factory_classPrivateFieldSet(e,t,i){return e.set(canvas_factory_assertClassBrand(e,t),i),i}(La,this,e)}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(e,t);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!canvas_factory_classPrivateFieldGet(La,this)})}}reset({canvas:e},t,i){if(!e)throw new Error("Canvas is not specified");if(t<=0||i<=0)throw new Error("Invalid canvas size");e.width=t;e.height=i}destroy(e){const{canvas:t}=e;if(!t)throw new Error("Canvas is not specified");t.width=t.height=0;e.canvas=null;e.context=null}getNoAlphaContext(e){return e.getContext("2d",{alpha:!1,willReadFrequently:!canvas_factory_classPrivateFieldGet(La,this)})}_createCanvas(e,t){unreachable("Abstract method `_createCanvas` called.")}}class BaseFilterFactory{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addKnockoutFilter(e=0){return"none"}addHighlightHCMFilter(e,t,i,a,s){return"none"}addSelectionHCMFilter(e,t){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(e=null){return null}destroy(e=!1){}}class NodeFilterFactory extends BaseFilterFactory{}class NodeCanvasFactory extends BaseCanvasFactory{_createCanvas(e,t){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}}class NodeBinaryDataFactory extends BaseBinaryDataFactory{async _fetch(e,t){return async function node_utils_fetchData(e){const t=process.getBuiltinModule("fs/promises"),i=await t.readFile(e);return new Uint8Array(i)}(e)}}function canvas_dependency_tracker_defineProperty(e,t,i){return(t=function canvas_dependency_tracker_toPropertyKey(e){var t=function canvas_dependency_tracker_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function canvas_dependency_tracker_classPrivateFieldInitSpec(e,t,i){canvas_dependency_tracker_checkPrivateRedeclaration(e,t),t.set(e,i)}function canvas_dependency_tracker_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function canvas_dependency_tracker_classPrivateFieldGet(e,t){return e.get(canvas_dependency_tracker_assertClassBrand(e,t))}function canvas_dependency_tracker_classPrivateFieldSet(e,t,i){return e.set(canvas_dependency_tracker_assertClassBrand(e,t),i),i}function canvas_dependency_tracker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Ra="__forcedDependency",{floor:Oa,ceil:Na}=Math;function expandBBox(e,t,i,a,s,r){e[4*t+0]=Math.min(e[4*t+0],i);e[4*t+1]=Math.min(e[4*t+1],a);e[4*t+2]=Math.max(e[4*t+2],s);e[4*t+3]=Math.max(e[4*t+3],r)}const Wa=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var ja=new WeakMap,Va=new WeakMap;class BBoxReader{constructor(e,t){canvas_dependency_tracker_classPrivateFieldInitSpec(this,ja,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Va,void 0);canvas_dependency_tracker_classPrivateFieldSet(ja,this,e);canvas_dependency_tracker_classPrivateFieldSet(Va,this,t)}static fromBuffer(e){return new BBoxReader(new Uint32Array(e),new Uint8ClampedArray(e))}get buffer(){return canvas_dependency_tracker_classPrivateFieldGet(ja,this).buffer}get length(){return canvas_dependency_tracker_classPrivateFieldGet(ja,this).length}isEmpty(e){return canvas_dependency_tracker_classPrivateFieldGet(ja,this)[e]===Wa}minX(e){return canvas_dependency_tracker_classPrivateFieldGet(Va,this)[4*e+0]/256}minY(e){return canvas_dependency_tracker_classPrivateFieldGet(Va,this)[4*e+1]/256}maxX(e){return(canvas_dependency_tracker_classPrivateFieldGet(Va,this)[4*e+2]+1)/256}maxY(e){return(canvas_dependency_tracker_classPrivateFieldGet(Va,this)[4*e+3]+1)/256}}const ensureDebugMetadata=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var Ua=new WeakMap,za=new WeakMap,Ha=new WeakMap,$a=new WeakMap,Xa=new WeakMap,Ka=new WeakMap,qa=new WeakMap,Ya=new WeakSet;class CanvasBBoxTracker{constructor(e,t){!function canvas_dependency_tracker_classPrivateMethodInitSpec(e,t){canvas_dependency_tracker_checkPrivateRedeclaration(e,t),t.add(e)}(this,Ya);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ua,[[1,0,0,1,0,0]]);canvas_dependency_tracker_classPrivateFieldInitSpec(this,za,[-1/0,-1/0,1/0,1/0]);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ha,new Float64Array(i));canvas_dependency_tracker_defineProperty(this,"_pendingBBoxIdx",-1);canvas_dependency_tracker_classPrivateFieldInitSpec(this,$a,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Xa,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ka,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,qa,void 0);canvas_dependency_tracker_defineProperty(this,"_savesStack",[]);canvas_dependency_tracker_defineProperty(this,"_markedContentStack",[]);canvas_dependency_tracker_classPrivateFieldSet($a,this,e.width);canvas_dependency_tracker_classPrivateFieldSet(Xa,this,e.height);canvas_dependency_tracker_assertClassBrand(Ya,this,_initializeBBoxes).call(this,t)}growOperationsCount(e){e>=canvas_dependency_tracker_classPrivateFieldGet(qa,this).length&&canvas_dependency_tracker_assertClassBrand(Ya,this,_initializeBBoxes).call(this,e,canvas_dependency_tracker_classPrivateFieldGet(qa,this))}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(za,this)}save(e){canvas_dependency_tracker_classPrivateFieldSet(za,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(za,this)});this._savesStack.push(e);return this}restore(e,t){const i=Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(za,this));if(null===i)return this;canvas_dependency_tracker_classPrivateFieldSet(za,this,i);const a=this._savesStack.pop();if(void 0!==a){t?.(a,e);canvas_dependency_tracker_classPrivateFieldGet(qa,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(qa,this)[a]}return this}recordOpenMarker(e){this._savesStack.push(e);return this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(e,t){const i=this._savesStack.pop();if(void 0!==i){t?.(i,e);canvas_dependency_tracker_classPrivateFieldGet(qa,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(qa,this)[i]}return this}beginMarkedContent(e){this._markedContentStack.push(e);return this}endMarkedContent(e,t){const i=this._markedContentStack.pop();if(void 0!==i){t?.(i,e);canvas_dependency_tracker_classPrivateFieldGet(qa,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(qa,this)[i]}return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(Ua,this).push(Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(Ua,this).at(-1),e.getTransform()));return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(Ua,this).length>1&&canvas_dependency_tracker_classPrivateFieldGet(Ua,this).pop();return this}resetBBox(e){if(this._pendingBBoxIdx!==e){this._pendingBBoxIdx=e;canvas_dependency_tracker_classPrivateFieldGet(Ha,this).set(i,0)}return this}recordClipBox(e,t,a,s,r,n){const o=Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(Ua,this).at(-1),t.getTransform()),l=i.slice();Util.axialAlignedBoundingBox([a,r,s,n],o,l);const d=Util.intersect(canvas_dependency_tracker_classPrivateFieldGet(za,this),l);if(d){canvas_dependency_tracker_classPrivateFieldGet(za,this)[0]=d[0];canvas_dependency_tracker_classPrivateFieldGet(za,this)[1]=d[1];canvas_dependency_tracker_classPrivateFieldGet(za,this)[2]=d[2];canvas_dependency_tracker_classPrivateFieldGet(za,this)[3]=d[3]}else{canvas_dependency_tracker_classPrivateFieldGet(za,this)[0]=canvas_dependency_tracker_classPrivateFieldGet(za,this)[1]=1/0;canvas_dependency_tracker_classPrivateFieldGet(za,this)[2]=canvas_dependency_tracker_classPrivateFieldGet(za,this)[3]=-1/0}return this}recordBBox(e,t,a,s,r,n){const o=canvas_dependency_tracker_classPrivateFieldGet(za,this);if(o[0]===1/0)return this;const l=Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(Ua,this).at(-1),t.getTransform());if(o[0]===-1/0){Util.axialAlignedBoundingBox([a,r,s,n],l,canvas_dependency_tracker_classPrivateFieldGet(Ha,this));return this}const d=i.slice();Util.axialAlignedBoundingBox([a,r,s,n],l,d);canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[0]=MathClamp(d[0],o[0],canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[1]=MathClamp(d[1],o[1],canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[2]=MathClamp(d[2],canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[2],o[2]);canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[3]=MathClamp(d[3],canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[3],o[3]);return this}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[0]=Math.max(0,canvas_dependency_tracker_classPrivateFieldGet(za,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[1]=Math.max(0,canvas_dependency_tracker_classPrivateFieldGet(za,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[2]=Math.min(canvas_dependency_tracker_classPrivateFieldGet($a,this),canvas_dependency_tracker_classPrivateFieldGet(za,this)[2]);canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[3]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(Xa,this),canvas_dependency_tracker_classPrivateFieldGet(za,this)[3]);return this}recordOperation(e,t=!1,i){if(this._pendingBBoxIdx!==e)return this;const a=Oa(256*canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[0]/canvas_dependency_tracker_classPrivateFieldGet($a,this)),s=Oa(256*canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[1]/canvas_dependency_tracker_classPrivateFieldGet(Xa,this)),r=Na(256*canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[2]/canvas_dependency_tracker_classPrivateFieldGet($a,this)),n=Na(256*canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[3]/canvas_dependency_tracker_classPrivateFieldGet(Xa,this));expandBBox(canvas_dependency_tracker_classPrivateFieldGet(Ka,this),e,a,s,r,n);if(i)for(const t of i)for(const i of t)i!==e&&expandBBox(canvas_dependency_tracker_classPrivateFieldGet(Ka,this),i,a,s,r,n);t||(this._pendingBBoxIdx=-1);return this}bboxToClipBoxDropOperation(e){if(this._pendingBBoxIdx===e){this._pendingBBoxIdx=-1;canvas_dependency_tracker_classPrivateFieldGet(za,this)[0]=Math.max(canvas_dependency_tracker_classPrivateFieldGet(za,this)[0],canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(za,this)[1]=Math.max(canvas_dependency_tracker_classPrivateFieldGet(za,this)[1],canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(za,this)[2]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(za,this)[2],canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[2]);canvas_dependency_tracker_classPrivateFieldGet(za,this)[3]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(za,this)[3],canvas_dependency_tracker_classPrivateFieldGet(Ha,this)[3])}return this}take(){return new BBoxReader(canvas_dependency_tracker_classPrivateFieldGet(qa,this),canvas_dependency_tracker_classPrivateFieldGet(Ka,this))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,i){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,i,a=1,s=0,r=0,n){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}}function _initializeBBoxes(e,t){const i=new ArrayBuffer(4*e);canvas_dependency_tracker_classPrivateFieldSet(Ka,this,new Uint8ClampedArray(i));canvas_dependency_tracker_classPrivateFieldSet(qa,this,new Uint32Array(i));if(t&&t.length>0){canvas_dependency_tracker_classPrivateFieldGet(qa,this).set(t);canvas_dependency_tracker_classPrivateFieldGet(qa,this).fill(Wa,t.length)}else canvas_dependency_tracker_classPrivateFieldGet(qa,this).fill(Wa)}var Za=new WeakMap,Qa=new WeakMap,Ja=new WeakMap,es=new WeakMap,ts=new WeakMap,is=new WeakMap,as=new WeakMap,ss=new WeakMap;class CanvasDependencyTracker{constructor(e,t=!1){canvas_dependency_tracker_classPrivateFieldInitSpec(this,Za,{__proto__:null});canvas_dependency_tracker_classPrivateFieldInitSpec(this,Qa,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Ra]:[]});canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ja,new Map);canvas_dependency_tracker_classPrivateFieldInitSpec(this,es,new Set);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ts,new Map);canvas_dependency_tracker_classPrivateFieldInitSpec(this,is,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,as,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ss,void 0);canvas_dependency_tracker_classPrivateFieldSet(ss,this,e);if(t){canvas_dependency_tracker_classPrivateFieldSet(is,this,new Map);canvas_dependency_tracker_classPrivateFieldSet(as,this,(e,t)=>{ensureDebugMetadata(canvas_dependency_tracker_classPrivateFieldGet(is,this),t).dependencies.add(e)})}}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(ss,this).clipBox}growOperationsCount(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).growOperationsCount(e)}save(e){canvas_dependency_tracker_classPrivateFieldSet(Za,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(Za,this)});canvas_dependency_tracker_classPrivateFieldSet(Qa,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(Qa,this),transform:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(Qa,this).transform},moveText:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(Qa,this).moveText},sameLineText:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(Qa,this).sameLineText},[Ra]:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(Qa,this)[Ra]}});canvas_dependency_tracker_classPrivateFieldGet(ss,this).save(e);return this}restore(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).restore(e,canvas_dependency_tracker_classPrivateFieldGet(as,this));const t=Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(Za,this));if(null===t)return this;canvas_dependency_tracker_classPrivateFieldSet(Za,this,t);canvas_dependency_tracker_classPrivateFieldSet(Qa,this,Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(Qa,this)));return this}recordOpenMarker(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).recordOpenMarker(e,canvas_dependency_tracker_classPrivateFieldGet(as,this));return this}getOpenMarker(){return canvas_dependency_tracker_classPrivateFieldGet(ss,this).getOpenMarker()}recordCloseMarker(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).recordCloseMarker(e,canvas_dependency_tracker_classPrivateFieldGet(as,this));return this}beginMarkedContent(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).beginMarkedContent(e);return this}endMarkedContent(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).endMarkedContent(e,canvas_dependency_tracker_classPrivateFieldGet(as,this));return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).pushBaseTransform(e);return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(ss,this).popBaseTransform();return this}recordSimpleData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Za,this)[e]=t;return this}recordIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Qa,this)[e].push(t);return this}resetIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Qa,this)[e].length=0;return this}recordNamedData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Ja,this).set(e,t);return this}recordSimpleDataFromNamed(e,t,i){canvas_dependency_tracker_classPrivateFieldGet(Za,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(Ja,this).get(t)??i}recordFutureForcedDependency(e,t){this.recordIncrementalData(Ra,t);return this}inheritSimpleDataAsFutureForcedDependencies(e){for(const t of e)t in canvas_dependency_tracker_classPrivateFieldGet(Za,this)&&this.recordFutureForcedDependency(t,canvas_dependency_tracker_classPrivateFieldGet(Za,this)[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of canvas_dependency_tracker_classPrivateFieldGet(es,this))this.recordFutureForcedDependency(Ra,e);return this}resetBBox(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).resetBBox(e);return this}recordClipBox(e,t,i,a,s,r){canvas_dependency_tracker_classPrivateFieldGet(ss,this).recordClipBox(e,t,i,a,s,r);return this}recordBBox(e,t,i,a,s,r){canvas_dependency_tracker_classPrivateFieldGet(ss,this).recordBBox(e,t,i,a,s,r);return this}recordCharacterBBox(e,t,i,a=1,s=0,r=0,n){const o=i.bbox;let l,d;if(o){l=o[2]!==o[0]&&o[3]!==o[1]&&canvas_dependency_tracker_classPrivateFieldGet(ts,this).get(i);if(!1!==l){d=[0,0,0,0];Util.axialAlignedBoundingBox(o,i.fontMatrix,d);1===a&&0===s&&0===r||function scaleCharBBox(e,t,i,a,s){let r;if(e){if(e<0){r=s[0];s[0]=s[2];s[2]=r}s[0]*=e;s[2]*=e;if(t<0){r=s[1];s[1]=s[3];s[3]=r}s[1]*=t;s[3]*=t}else s.fill(0);s[0]+=i;s[1]+=a;s[2]+=i;s[3]+=a}(a,-a,s,r,d);if(l)return this.recordBBox(e,t,d[0],d[2],d[1],d[3])}}if(!n)return this.recordFullPageBBox(e);const c=n();if(o&&d&&void 0===l){l=d[0]<=s-c.actualBoundingBoxLeft&&d[2]>=s+c.actualBoundingBoxRight&&d[1]<=r-c.actualBoundingBoxAscent&&d[3]>=r+c.actualBoundingBoxDescent;canvas_dependency_tracker_classPrivateFieldGet(ts,this).set(i,l);if(l)return this.recordBBox(e,t,d[0],d[2],d[1],d[3])}return this.recordBBox(e,t,s-c.actualBoundingBoxLeft,s+c.actualBoundingBoxRight,r-c.actualBoundingBoxAscent,r+c.actualBoundingBoxDescent)}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(ss,this).recordFullPageBBox(e);return this}getSimpleIndex(e){return canvas_dependency_tracker_classPrivateFieldGet(Za,this)[e]}recordDependencies(e,t){const i=canvas_dependency_tracker_classPrivateFieldGet(es,this),a=canvas_dependency_tracker_classPrivateFieldGet(Za,this),s=canvas_dependency_tracker_classPrivateFieldGet(Qa,this);for(const e of t)e in canvas_dependency_tracker_classPrivateFieldGet(Za,this)?i.add(a[e]):e in s&&s[e].forEach(i.add,i);return this}recordNamedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(Ja,this).has(t)&&canvas_dependency_tracker_classPrivateFieldGet(es,this).add(canvas_dependency_tracker_classPrivateFieldGet(Ja,this).get(t));return this}recordOperation(e,t=!1){this.recordDependencies(e,[Ra]);if(canvas_dependency_tracker_classPrivateFieldGet(is,this)){const t=ensureDebugMetadata(canvas_dependency_tracker_classPrivateFieldGet(is,this),e),{dependencies:i}=t;canvas_dependency_tracker_classPrivateFieldGet(es,this).forEach(i.add,i);canvas_dependency_tracker_classPrivateFieldGet(ss,this)._savesStack.forEach(i.add,i);canvas_dependency_tracker_classPrivateFieldGet(ss,this)._markedContentStack.forEach(i.add,i);i.delete(e);t.isRenderingOperation=!0}const i=!t&&e===canvas_dependency_tracker_classPrivateFieldGet(ss,this)._pendingBBoxIdx;canvas_dependency_tracker_classPrivateFieldGet(ss,this).recordOperation(e,t,[canvas_dependency_tracker_classPrivateFieldGet(es,this),canvas_dependency_tracker_classPrivateFieldGet(ss,this)._savesStack,canvas_dependency_tracker_classPrivateFieldGet(ss,this)._markedContentStack]);i&&canvas_dependency_tracker_classPrivateFieldGet(es,this).clear();return this}recordShowTextOperation(e,t=!1){const i=Array.from(canvas_dependency_tracker_classPrivateFieldGet(es,this));this.recordOperation(e,t);this.recordIncrementalData("sameLineText",e);for(const e of i)this.recordIncrementalData("sameLineText",e);return this}bboxToClipBoxDropOperation(e,t=!1){const i=!t&&e===canvas_dependency_tracker_classPrivateFieldGet(ss,this)._pendingBBoxIdx;canvas_dependency_tracker_classPrivateFieldGet(ss,this).bboxToClipBoxDropOperation(e);i&&canvas_dependency_tracker_classPrivateFieldGet(es,this).clear();return this}take(){canvas_dependency_tracker_classPrivateFieldGet(ts,this).clear();return canvas_dependency_tracker_classPrivateFieldGet(ss,this).take()}takeDebugMetadata(){return canvas_dependency_tracker_classPrivateFieldGet(is,this)}}var rs=new WeakMap,ns=new WeakMap,os=new WeakMap,ls=new WeakMap,ds=new WeakMap;class CanvasNestedDependencyTracker{constructor(e,t,i){canvas_dependency_tracker_classPrivateFieldInitSpec(this,rs,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ns,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,os,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ls,0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ds,0);if(e instanceof CanvasNestedDependencyTracker&&canvas_dependency_tracker_classPrivateFieldGet(os,e)===!!i)return e;canvas_dependency_tracker_classPrivateFieldSet(rs,this,e);canvas_dependency_tracker_classPrivateFieldSet(ns,this,t);canvas_dependency_tracker_classPrivateFieldSet(os,this,!!i)}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(rs,this).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(e){var t;canvas_dependency_tracker_classPrivateFieldSet(ds,this,(t=canvas_dependency_tracker_classPrivateFieldGet(ds,this),t++,t));canvas_dependency_tracker_classPrivateFieldGet(rs,this).save(canvas_dependency_tracker_classPrivateFieldGet(ns,this));return this}restore(e){if(canvas_dependency_tracker_classPrivateFieldGet(ds,this)>0){var t;canvas_dependency_tracker_classPrivateFieldGet(rs,this).restore(canvas_dependency_tracker_classPrivateFieldGet(ns,this));canvas_dependency_tracker_classPrivateFieldSet(ds,this,(t=canvas_dependency_tracker_classPrivateFieldGet(ds,this),t--,t))}return this}recordOpenMarker(e){var t;canvas_dependency_tracker_classPrivateFieldSet(ls,this,(t=canvas_dependency_tracker_classPrivateFieldGet(ls,this),t++,t));return this}getOpenMarker(){return canvas_dependency_tracker_classPrivateFieldGet(ls,this)>0?canvas_dependency_tracker_classPrivateFieldGet(ns,this):canvas_dependency_tracker_classPrivateFieldGet(rs,this).getOpenMarker()}recordCloseMarker(e){var t;canvas_dependency_tracker_classPrivateFieldSet(ls,this,(t=canvas_dependency_tracker_classPrivateFieldGet(ls,this),t--,t));return this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(rs,this).pushBaseTransform(e);return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(rs,this).popBaseTransform();return this}recordSimpleData(e,t){canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordSimpleData(e,canvas_dependency_tracker_classPrivateFieldGet(ns,this));return this}recordIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordIncrementalData(e,canvas_dependency_tracker_classPrivateFieldGet(ns,this));return this}resetIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(rs,this).resetIncrementalData(e,canvas_dependency_tracker_classPrivateFieldGet(ns,this));return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,i){canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordSimpleDataFromNamed(e,t,canvas_dependency_tracker_classPrivateFieldGet(ns,this));return this}recordFutureForcedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordFutureForcedDependency(e,canvas_dependency_tracker_classPrivateFieldGet(ns,this));return this}inheritSimpleDataAsFutureForcedDependencies(e){canvas_dependency_tracker_classPrivateFieldGet(rs,this).inheritSimpleDataAsFutureForcedDependencies(e);return this}inheritPendingDependenciesAsFutureForcedDependencies(){canvas_dependency_tracker_classPrivateFieldGet(rs,this).inheritPendingDependenciesAsFutureForcedDependencies();return this}resetBBox(e){canvas_dependency_tracker_classPrivateFieldGet(os,this)||canvas_dependency_tracker_classPrivateFieldGet(rs,this).resetBBox(canvas_dependency_tracker_classPrivateFieldGet(ns,this));return this}recordClipBox(e,t,i,a,s,r){canvas_dependency_tracker_classPrivateFieldGet(os,this)||canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordClipBox(canvas_dependency_tracker_classPrivateFieldGet(ns,this),t,i,a,s,r);return this}recordBBox(e,t,i,a,s,r){canvas_dependency_tracker_classPrivateFieldGet(os,this)||canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordBBox(canvas_dependency_tracker_classPrivateFieldGet(ns,this),t,i,a,s,r);return this}recordCharacterBBox(e,t,i,a,s,r,n){canvas_dependency_tracker_classPrivateFieldGet(os,this)||canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordCharacterBBox(canvas_dependency_tracker_classPrivateFieldGet(ns,this),t,i,a,s,r,n);return this}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(os,this)||canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordFullPageBBox(canvas_dependency_tracker_classPrivateFieldGet(ns,this));return this}getSimpleIndex(e){return canvas_dependency_tracker_classPrivateFieldGet(rs,this).getSimpleIndex(e)}recordDependencies(e,t){canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordDependencies(canvas_dependency_tracker_classPrivateFieldGet(ns,this),t);return this}recordNamedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordNamedDependency(canvas_dependency_tracker_classPrivateFieldGet(ns,this),t);return this}recordOperation(e){canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordOperation(canvas_dependency_tracker_classPrivateFieldGet(ns,this),!0);return this}recordShowTextOperation(e){canvas_dependency_tracker_classPrivateFieldGet(rs,this).recordShowTextOperation(canvas_dependency_tracker_classPrivateFieldGet(ns,this),!0);return this}bboxToClipBoxDropOperation(e){canvas_dependency_tracker_classPrivateFieldGet(os,this)||canvas_dependency_tracker_classPrivateFieldGet(rs,this).bboxToClipBoxDropOperation(canvas_dependency_tracker_classPrivateFieldGet(ns,this),!0);return this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const cs=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],hs=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],_s=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],us=["filter","fillColor","fillAlpha"],ps=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],gs=["transform"],ms=["transform","filter","fillColor"];var fs=new WeakMap,vs=new WeakMap,Ps=new WeakMap,ws=new WeakMap,Fs=new WeakMap;class CanvasImagesTracker{constructor(e){canvas_dependency_tracker_classPrivateFieldInitSpec(this,fs,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,vs,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ps,4);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ws,0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Fs,new ys._(6*canvas_dependency_tracker_classPrivateFieldGet(Ps,this)));canvas_dependency_tracker_classPrivateFieldSet(fs,this,e.width);canvas_dependency_tracker_classPrivateFieldSet(vs,this,e.height)}record(e,t,a,s){var r;if(canvas_dependency_tracker_classPrivateFieldGet(ws,this)===canvas_dependency_tracker_classPrivateFieldGet(Ps,this)){canvas_dependency_tracker_classPrivateFieldSet(Ps,this,2*canvas_dependency_tracker_classPrivateFieldGet(Ps,this));const e=new ys._(6*canvas_dependency_tracker_classPrivateFieldGet(Ps,this));e.set(canvas_dependency_tracker_classPrivateFieldGet(Fs,this));canvas_dependency_tracker_classPrivateFieldSet(Fs,this,e)}const n=getCurrentTransform(e);let o;if(s[0]!==1/0){const e=i.slice();Util.axialAlignedBoundingBox([0,-a,t,0],n,e);const r=Util.intersect(s,e);if(!r)return;const[l,d,c,h]=r;if(l!==e[0]||d!==e[1]||c!==e[2]||h!==e[3]){const e=Math.atan2(n[1],n[0]),t=Math.abs(Math.sin(e)),i=Math.abs(Math.cos(e));if(t<1e-6||i<1e-6||Math.abs(t-i)<1e-6)o=[l,d,l,h,c,d];else{const e=c-l,a=h-d,s=t*t,r=i*i,n=i*t,_=r-s,u=(a*r-e*n)/_;o=[l+(a*n-e*s)/_,d,l,d+u,c,h-u]}}}if(!o){o=[0,-a,0,0,t,-a];Util.applyTransform(o,n,0);Util.applyTransform(o,n,2);Util.applyTransform(o,n,4)}o[0]/=canvas_dependency_tracker_classPrivateFieldGet(fs,this);o[1]/=canvas_dependency_tracker_classPrivateFieldGet(vs,this);o[2]/=canvas_dependency_tracker_classPrivateFieldGet(fs,this);o[3]/=canvas_dependency_tracker_classPrivateFieldGet(vs,this);o[4]/=canvas_dependency_tracker_classPrivateFieldGet(fs,this);o[5]/=canvas_dependency_tracker_classPrivateFieldGet(vs,this);canvas_dependency_tracker_classPrivateFieldGet(Fs,this).set(o,6*canvas_dependency_tracker_classPrivateFieldGet(ws,this));canvas_dependency_tracker_classPrivateFieldSet(ws,this,(r=canvas_dependency_tracker_classPrivateFieldGet(ws,this),r++,r))}take(){return canvas_dependency_tracker_classPrivateFieldGet(Fs,this).subarray(0,6*canvas_dependency_tracker_classPrivateFieldGet(ws,this))}}var ys={_:FeatureTest.isFloat16ArraySupported?Float16Array:Float32Array};function convertBlackAndWhiteToRGBA({src:e,srcPos:t=0,dest:i,width:a,height:s,nonBlackColor:r=4294967295,inverseDecode:n=!1}){const o=FeatureTest.isLittleEndian?4278190080:255,[l,d]=n?[r,o]:[o,r],c=a>>3,h=7&a,_=l^d,u=e.length;i=new Uint32Array(i.buffer);let p=0;for(let a=0;a<s;++a){for(const a=t+c;t<a;++t,p+=8){const a=e[t];i[p]=l^-(a>>7&1)&_;i[p+1]=l^-(a>>6&1)&_;i[p+2]=l^-(a>>5&1)&_;i[p+3]=l^-(a>>4&1)&_;i[p+4]=l^-(a>>3&1)&_;i[p+5]=l^-(a>>2&1)&_;i[p+6]=l^-(a>>1&1)&_;i[p+7]=l^-(1&a)&_}if(0===h)continue;const a=t<u?e[t++]:255;for(let e=0;e<h;++e,++p)i[p]=l^-(a>>7-e&1)&_}return{srcPos:t,destPos:p}}function convertRGBToRGBA({src:e,srcPos:t=0,dest:i,destPos:a=0,width:s,height:r}){let n=0;const o=s*r*3,l=e.byteOffset+t,d=l%4==0?Math.floor(MathClamp(e.length-t,0,o)/4):0,c=d>0?new Uint32Array(e.buffer,l,d):null,h=FeatureTest.isLittleEndian?4278190080:255;if(FeatureTest.isLittleEndian){for(;n<d-2;n+=3,a+=4){const e=c[n],t=c[n+1],s=c[n+2];i[a]=e|h;i[a+1]=e>>>24|t<<8|h;i[a+2]=t>>>16|s<<16|h;i[a+3]=s>>>8|h}for(let s=t+4*n,r=t+o;s<r;s+=3)i[a++]=e[s]|e[s+1]<<8|e[s+2]<<16|h}else{for(;n<d-2;n+=3,a+=4){const e=c[n],t=c[n+1],s=c[n+2];i[a]=e|h;i[a+1]=e<<24|t>>>8|h;i[a+2]=t<<16|s>>>16|h;i[a+3]=s<<8|h}for(let s=t+4*n,r=t+o;s<r;s+=3)i[a++]=e[s]<<24|e[s+1]<<16|e[s+2]<<8|h}return{srcPos:t+o,destPos:a}}function pattern_helper_defineProperty(e,t,i){return(t=function pattern_helper_toPropertyKey(e){var t=function pattern_helper_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const bs="Fill",Ss="Stroke",Cs="Shading";function applyBoundingBox(e,t){if(!t)return;const i=t[2]-t[0],a=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],i,a);e.clip(s)}class BaseShadingPattern{constructor(){pattern_helper_defineProperty(this,"matrix",null)}isModifyingCurrentTransform(){return!1}getPattern(){unreachable("Abstract method `getPattern` called.")}}class RadialAxialShadingPattern extends BaseShadingPattern{constructor(e){super();this._type=e[1];this._bbox=e[2];this._colorStops=e[3];this._p0=e[4];this._p1=e[5];this._r0=e[6];this._r1=e[7]}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;const e=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return e+this._r1>this._r0&&e+this._r0>this._r1}_createGradient(e,t=null){let i,a=this._p0,s=this._p1;if(t){a=a.slice();s=s.slice();Util.applyTransform(a,t);Util.applyTransform(s,t)}if("axial"===this._type)i=e.createLinearGradient(a[0],a[1],s[0],s[1]);else if("radial"===this._type){let r=this._r0,n=this._r1;if(t){const e=new Float32Array(2);Util.singularValueDecompose2dScale(t,e);r*=e[0];n*=e[0]}i=e.createRadialGradient(a[0],a[1],r,s[0],s[1],n)}for(const e of this._colorStops)i.addColorStop(e[0],e[1]);return i}_createReversedGradient(e,t=null){let i=this._p1,a=this._p0;if(t){i=i.slice();a=a.slice();Util.applyTransform(i,t);Util.applyTransform(a,t)}let s=this._r1,r=this._r0;if(t){const e=new Float32Array(2);Util.singularValueDecompose2dScale(t,e);s*=e[0];r*=e[0]}const n=e.createRadialGradient(i[0],i[1],s,a[0],a[1],r),o=this._colorStops.map(([e,t])=>[1-e,t]).reverse();for(const[e,t]of o)n.addColorStop(e,t);return n}_createRasterPattern(e,t,i,a,s,r){const n=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=t.canvasFactory.create(n,o),d=l.context;d.clearRect(0,0,n,o);d.beginPath();d.rect(0,0,n,o);d.translate(-a[0],-a[1]);i=Util.transform(i,[1,0,0,1,a[0],a[1]]);d.transform(...s);applyBoundingBox(d,this._bbox);if(this.areConic()){d.fillStyle=this._createReversedGradient(d);d.fill()}d.fillStyle=this._createGradient(d);d.fill();r?.applyToCanvas(d);const c=e.createPattern(l.canvas,"no-repeat");t.canvasFactory.destroy(l);c.setTransform(new DOMMatrix(i));return c}getPattern(e,t,i,a){const s=t.current.transferMapsFallback;if(a===Ss||a===bs){if(this.isOriginBased()&&!s){let a=Util.transform(i,t.baseTransform);this.matrix&&(a=Util.transform(a,this.matrix));const s=.001,r=Math.hypot(a[0],a[1]),n=Math.hypot(a[2],a[3]),o=(a[0]*a[2]+a[1]*a[3])/(r*n);if(Math.abs(o)<s){if(!this.isRadial())return this._createGradient(e,a);if(Math.abs(r-n)<s)return this._createGradient(e,a)}}const r=t.current.getClippedPathBoundingBox(a,getCurrentTransform(e))||[0,0,0,0],n=this.matrix?Util.transform(t.baseTransform,this.matrix):t.baseTransform;return this._createRasterPattern(e,t,i,r,n,s)}if(s&&i)return this._createRasterPattern(e,t,i,t.current.clipBox,getCurrentTransform(e),s);if(this.areConic()){e.save();applyBoundingBox(e,this._bbox);e.fillStyle=this._createReversedGradient(e);e.fillRect(-1e10,-1e10,2e10,2e10);e.restore()}applyBoundingBox(e,this._bbox);return this._createGradient(e)}}function drawTriangle(e,t,i,a,s,r,n,o){const l=t.coords,d=t.colors,c=e.data,h=4*e.width;let _;if(l[2*i+1]>l[2*a+1]){_=i;i=a;a=_;_=r;r=n;n=_}if(l[2*a+1]>l[2*s+1]){_=a;a=s;s=_;_=n;n=o;o=_}if(l[2*i+1]>l[2*a+1]){_=i;i=a;a=_;_=r;r=n;n=_}const u=(l[2*i]+t.offsetX)*t.scaleX,p=(l[2*i+1]+t.offsetY)*t.scaleY,g=(l[2*a]+t.offsetX)*t.scaleX,m=(l[2*a+1]+t.offsetY)*t.scaleY,f=(l[2*s]+t.offsetX)*t.scaleX,v=(l[2*s+1]+t.offsetY)*t.scaleY;if(p>=v)return;const P=d[4*r],w=d[4*r+1],F=d[4*r+2],y=d[4*n],b=d[4*n+1],S=d[4*n+2],C=d[4*o],x=d[4*o+1],k=d[4*o+2],E=Math.round(p),A=Math.round(v);let G,B,M,I,T,D,L,R;for(let e=E;e<=A;e++){if(e<m){const t=e<p?0:(p-e)/(p-m);G=u-(u-g)*t;B=P-(P-y)*t;M=w-(w-b)*t;I=F-(F-S)*t}else{let t;t=e>v?1:m===v?0:(m-e)/(m-v);G=g-(g-f)*t;B=y-(y-C)*t;M=b-(b-x)*t;I=S-(S-k)*t}let t;t=e<p?0:e>v?1:(p-e)/(p-v);T=u-(u-f)*t;D=P-(P-C)*t;L=w-(w-x)*t;R=F-(F-k)*t;const i=Math.round(Math.min(G,T)),a=Math.round(Math.max(G,T));let s=h*e+4*i;for(let e=i;e<=a;e++){t=(G-e)/(G-T);t<0?t=0:t>1&&(t=1);c[s++]=B-(B-D)*t|0;c[s++]=M-(M-L)*t|0;c[s++]=I-(I-R)*t|0;c[s++]=255}}}class MeshShadingPattern extends BaseShadingPattern{constructor(e){super();this._posData=e[2];this._colData=e[3];this._vertexCount=e[4];this._bounds=e[5];this._bbox=e[6];this._background=e[7];!function loadMeshShader(){ua.loadMeshShader()}()}_createMeshCanvas(e,t,i,a=null){const s=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),n=Math.ceil(this._bounds[2])-s,o=Math.ceil(this._bounds[3])-r,l=Math.min(Math.ceil(Math.abs(n*e[0]*1.1)),3e3)||1,d=Math.min(Math.ceil(Math.abs(o*e[1]*1.1)),3e3)||1,c=n?n/l:1,h=o?o/d:1,_={coords:this._posData,colors:this._colData,offsetX:-s,offsetY:-r,scaleX:1/c,scaleY:1/h},u=l+4,p=d+4,g=i.create(u,p);if(isGPUReady()&&this._vertexCount>48)g.context.drawImage(function drawMeshWithGPU(e,t,i,a,s,r,n,o){return ua.draw(e,t,i,a,s,r,n,o)}(this._posData,this._colData,this._vertexCount,_,t,u,p,2),0,0);else{const e=g.context.createImageData(l,d);if(t){const i=e.data;for(let e=0,a=i.length;e<a;e+=4){i[e]=t[0];i[e+1]=t[1];i[e+2]=t[2];i[e+3]=255}}for(let t=0,i=this._vertexCount;t<i;t+=3)drawTriangle(e,_,t,t+1,t+2,t,t+1,t+2);g.context.putImageData(e,2,2)}a?.applyToCanvas(g.context);return{canvas:g.canvas,offsetX:s-2*c,offsetY:r-2*h,scaleX:c,scaleY:h}}isModifyingCurrentTransform(){return!0}getPattern(e,t,i,a){applyBoundingBox(e,this._bbox);const s=new Float32Array(2);if(a===Cs)Util.singularValueDecompose2dScale(getCurrentTransform(e),s);else if(this.matrix){Util.singularValueDecompose2dScale(this.matrix,s);const[e,i]=s;Util.singularValueDecompose2dScale(t.baseTransform,s);s[0]*=e;s[1]*=i}else Util.singularValueDecompose2dScale(t.baseTransform,s);const r=this._createMeshCanvas(s,a===Cs?null:this._background,t.canvasFactory,t.current.transferMapsFallback);if(a!==Cs){e.setTransform(...t.baseTransform);this.matrix&&e.transform(...this.matrix)}e.translate(r.offsetX,r.offsetY);e.scale(r.scaleX,r.scaleY);const n=e.createPattern(r.canvas,"no-repeat");t.canvasFactory.destroy(r);return n}}class DummyShadingPattern extends BaseShadingPattern{getPattern(){return"hotpink"}}const xs=1,ks=2;class TilingPattern{constructor(e,t,i,a){this.color=e[1];this.operatorList=e[2];this.matrix=e[3];this.bbox=e[4];this.xstep=e[5];this.ystep=e[6];this.paintType=e[7];this.tilingType=e[8];this.needsIsolation=e[9]??!0;this.ctx=t;this.canvasGraphicsFactory=i;this.baseTransform=a;this.patternBaseMatrix=this.matrix?Util.transform(a,this.matrix):a}canSkipPatternCanvas([e,t,i,a]){const[s,r,n,o]=this.bbox,l=Math.abs(this.xstep),d=Math.abs(this.ystep);if(e>l+1e-6||t>d+1e-6)return null;const c=Math.floor((i-n)/l)+1,h=Math.ceil((i+e-s)/l)-1,_=Math.floor((a-o)/d)+1,u=Math.ceil((a+t-r)/d)-1;return h<=c&&u<=_?[c,_]:null}updatePatternDims(e,t){const a=i.slice();Util.axialAlignedBoundingBox(e,Util.inverseTransform(this.patternBaseMatrix),a);t[0]=a[2]-a[0];t[1]=a[3]-a[1];t[2]=a[0];t[3]=a[1]}_renderTileCanvas(e,t,i,a){const[s,r,n,o]=this.bbox,l=e.canvasFactory.create(i.size,a.size),d=l.context,c=this.canvasGraphicsFactory.createCanvasGraphics(d,t);c.groupLevel=e.groupLevel;c.current.transferMapsFallback=e.current.transferMapsFallback;this.setFillAndStrokeStyleToContext(c,this.paintType,this.color);d.translate(-i.scale*s,-a.scale*r);c.transform(0,i.scale,0,0,a.scale,0,0);d.save();c.dependencyTracker?.save();this.clipBbox(c,s,r,n,o);c.baseTransform=getCurrentTransform(c.ctx);c.executeOperatorList(this.operatorList);c.endDrawing();c.dependencyTracker?.restore();d.restore();return l}_getCombinedScales(){const e=new Float32Array(2);Util.singularValueDecompose2dScale(this.matrix,e);const[t,i]=e;Util.singularValueDecompose2dScale(this.baseTransform,e);return[t*e[0],i*e[1]]}drawPattern(e,t,i=!1,[a,s],r){const[n,o,l,d]=this.bbox,c=e.dependencyTracker;c&&(e.dependencyTracker=new CanvasNestedDependencyTracker(c,r));try{e.save();i?e.ctx.clip(t,"evenodd"):e.ctx.clip(t);e.ctx.setTransform(...this.patternBaseMatrix);e.ctx.translate(a*this.xstep,s*this.ystep);if(this.needsIsolation||1!==e.ctx.globalAlpha||"source-over"!==e.ctx.globalCompositeOperation||e.inSMaskMode){const t=l-n,i=d-o,[a,s]=this._getCombinedScales(),c=this.getSizeAndScale(t,this.ctx.canvas.width,a),h=this.getSizeAndScale(i,this.ctx.canvas.height,s),_=this._renderTileCanvas(e,r,c,h);e.ctx.drawImage(_.canvas,n,o,t,i);e.canvasFactory.destroy(_)}else{e.resetGraphicsState();this.setFillAndStrokeStyleToContext(e,this.paintType,this.color);this.clipBbox(e,n,o,l,d);e.baseTransformStack.push(e.baseTransform);e.baseTransform=getCurrentTransform(e.ctx);e.executeOperatorList(this.operatorList);e.baseTransform=e.baseTransformStack.pop()}e.restore()}finally{c&&(e.dependencyTracker=c)}}createPatternCanvas(e,t){const[i,a,s,r]=this.bbox,n=s-i,o=r-a;let{xstep:l,ystep:d}=this;l=Math.abs(l);d=Math.abs(d);info("TilingType: "+this.tilingType);const[c,h]=this._getCombinedScales();let _=n,u=o,p=!1,g=!1;Math.ceil(l*c)>=Math.ceil(n*c)?_=l:p=!0;Math.ceil(d*h)>=Math.ceil(o*h)?u=d:g=!0;const m=this.getSizeAndScale(_,this.ctx.canvas.width,c),f=this.getSizeAndScale(u,this.ctx.canvas.height,h),v=this._renderTileCanvas(e,t,m,f);if(p||g){const t=v.canvas;p&&(_=l);g&&(u=d);const s=this.getSizeAndScale(_,this.ctx.canvas.width,c),r=this.getSizeAndScale(u,this.ctx.canvas.height,h),m=s.size,f=r.size,P=e.canvasFactory.create(m,f),w=P.context,F=p?Math.min(Math.floor(n/l),Math.ceil(t.width/m)):0,y=g?Math.min(Math.floor(o/d),Math.ceil(t.height/f)):0;let b=t,S=null;if(g){S=e.canvasFactory.create(t.width,f);const i=S.context;for(let e=y;e>=0;e--)i.drawImage(t,0,f*e,t.width,f,0,0,t.width,f);b=S.canvas}for(let e=F;e>=0;e--)w.drawImage(b,m*e,0,m,f,0,0,m,f);S&&e.canvasFactory.destroy(S);e.canvasFactory.destroy(v);return{canvas:P.canvas,canvasEntry:P,scaleX:s.scale,scaleY:r.scale,offsetX:i,offsetY:a}}return{canvas:v.canvas,canvasEntry:v,scaleX:m.scale,scaleY:f.scale,offsetX:i,offsetY:a}}getSizeAndScale(e,t,i){const a=Math.max(TilingPattern.MAX_PATTERN_SIZE,t);let s=Math.ceil(e*i);s>=a?s=a:i=s/e;return{scale:i,size:s}}clipBbox(e,t,i,a,s){const r=a-t,n=s-i,o=new Path2D;o.rect(t,i,r,n);Util.axialAlignedBoundingBox([t,i,a,s],getCurrentTransform(e.ctx),e.current.minMax);e.ctx.clip(o);e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,i){switch(t){case xs:i="#000000";break;case ks:break;default:throw new FormatError(`Unsupported paint type: ${t}`)}const{ctx:a,current:s}=e;s.patternFill=s.patternStroke=!1;a.fillStyle=a.strokeStyle=s.transferMapsFallback?.applyToColor(i)??i;s.fillColor=s.strokeColor=i}isModifyingCurrentTransform(){return!1}getPattern(e,t,i,a,s){const r=a!==Cs?Util.transform(i,this.patternBaseMatrix):i,n=this.createPatternCanvas(t,s);let o=new DOMMatrix(r);o=o.translate(n.offsetX,n.offsetY);o=o.scale(1/n.scaleX,1/n.scaleY);const l=e.createPattern(n.canvas,"repeat");t.canvasFactory.destroy(n.canvasEntry);l.setTransform(o);return l}}pattern_helper_defineProperty(TilingPattern,"MAX_PATTERN_SIZE",3e3);function canvas_classPrivateFieldInitSpec(e,t,i){canvas_checkPrivateRedeclaration(e,t),t.set(e,i)}function canvas_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function canvas_classPrivateFieldGet(e,t){return e.get(canvas_assertClassBrand(e,t))}function canvas_classPrivateFieldSet(e,t,i){return e.set(canvas_assertClassBrand(e,t),i),i}function canvas_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function canvas_defineProperty(e,t,i){return(t=function canvas_toPropertyKey(e){var t=function canvas_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Es=16,As=new Float32Array(2);function mirrorContextOperations(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");const i=new Map;for(const a of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const s=e[a];if("function"==typeof s&&"function"==typeof t[a]){i.set(a,s);e[a]=function(...e){t[a](...e);return s.apply(this,e)}}}e._removeMirroring=()=>{for(const[t,a]of i)e[t]=a;delete e._removeMirroring}}function drawImageAtIntegerCoords(e,t,i,a,s,r,n,o,l,d){const[c,h,_,u,p,g]=getCurrentTransform(e);if(0===h&&0===_){const m=n*c+p,f=Math.round(m),v=o*u+g,P=Math.round(v),w=(n+l)*c+p,F=Math.abs(Math.round(w)-f)||1,y=(o+d)*u+g,b=Math.abs(Math.round(y)-P)||1;e.setTransform(Math.sign(c),0,0,Math.sign(u),f,P);e.drawImage(t,i,a,s,r,0,0,F,b);e.setTransform(c,h,_,u,p,g);return[F,b]}if(0===c&&0===u){const m=o*_+p,f=Math.round(m),v=n*h+g,P=Math.round(v),w=(o+d)*_+p,F=Math.abs(Math.round(w)-f)||1,y=(n+l)*h+g,b=Math.abs(Math.round(y)-P)||1;e.setTransform(0,Math.sign(h),Math.sign(_),0,f,P);e.drawImage(t,i,a,s,r,0,0,b,F);e.setTransform(c,h,_,u,p,g);return[b,F]}e.drawImage(t,i,a,s,r,n,o,l,d);return[Math.hypot(c,h)*l,Math.hypot(_,u)*d]}class CanvasExtraState{constructor(e,t){canvas_defineProperty(this,"alphaIsShape",!1);canvas_defineProperty(this,"fontSize",0);canvas_defineProperty(this,"fontSizeScale",1);canvas_defineProperty(this,"textMatrix",null);canvas_defineProperty(this,"textMatrixScale",1);canvas_defineProperty(this,"fontMatrix",s);canvas_defineProperty(this,"leading",0);canvas_defineProperty(this,"x",0);canvas_defineProperty(this,"y",0);canvas_defineProperty(this,"lineX",0);canvas_defineProperty(this,"lineY",0);canvas_defineProperty(this,"charSpacing",0);canvas_defineProperty(this,"wordSpacing",0);canvas_defineProperty(this,"textHScale",1);canvas_defineProperty(this,"textRenderingMode",w);canvas_defineProperty(this,"textRise",0);canvas_defineProperty(this,"fillColor","#000000");canvas_defineProperty(this,"strokeColor","#000000");canvas_defineProperty(this,"tilingPatternDims",null);canvas_defineProperty(this,"patternFill",!1);canvas_defineProperty(this,"patternStroke",!1);canvas_defineProperty(this,"fillAlpha",1);canvas_defineProperty(this,"strokeAlpha",1);canvas_defineProperty(this,"lineWidth",1);canvas_defineProperty(this,"activeSMask",null);canvas_defineProperty(this,"transferMaps","none");canvas_defineProperty(this,"transferMapsFallback",null);canvas_defineProperty(this,"minMax",a.slice());this.clipBox=new Float32Array([0,0,e,t])}clone(){const e=Object.create(this);e.clipBox=this.clipBox.slice();e.minMax=this.minMax.slice();e.tilingPatternDims=this.tilingPatternDims?.slice();return e}getPathBoundingBox(e=bs,t=null){const i=this.minMax.slice();if(e===Ss){t||unreachable("Stroke bounding box must include transform.");Util.singularValueDecompose2dScale(t,As);const e=As[0]*this.lineWidth/2,a=As[1]*this.lineWidth/2;i[0]-=e;i[1]-=a;i[2]+=e;i[3]+=a}return i}updateClipFromPath(){const e=Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0);this.minMax.set(a,0)}getClippedPathBoundingBox(e=bs,t=null){return Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function putBinaryImageData(e,t){const{width:i,height:a,kind:s}=t,r=a%Es,n=(a-r)/Es,o=0===r?n:n+1,l=e.createImageData(i,Es);let d=0;const c=t.data,h=l.data;let _;if(s===x.GRAYSCALE_1BPP)for(_=0;_<o;_++){({srcPos:d}=convertBlackAndWhiteToRGBA({src:c,srcPos:d,dest:h,width:i,height:_<n?Es:r}));e.putImageData(l,0,_*Es)}else if(s===x.RGBA_32BPP){let t=0,a=i*Es*4;for(_=0;_<n;_++){h.set(c.subarray(d,d+a));d+=a;e.putImageData(l,0,t);t+=Es}if(_<o){a=i*r*4;h.set(c.subarray(d,d+a));e.putImageData(l,0,t)}}else{if(s!==x.RGB_24BPP)throw new Error(`bad image kind: ${s}`);for(_=0;_<o;_++){({srcPos:d}=convertRGBToRGBA({src:c,srcPos:d,dest:new Uint32Array(h.buffer),width:i,height:_<n?Es:r}));e.putImageData(l,0,_*Es)}}}function putBinaryImageMask(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}const{width:i,height:a}=t,s=a%Es,r=(a-s)/Es,n=0===s?r:r+1,o=e.createImageData(i,Es);let l=0;const d=t.data,c=o.data;for(let t=0;t<n;t++){({srcPos:l}=convertBlackAndWhiteToRGBA({src:d,srcPos:l,dest:c,width:i,height:t<r?Es:s,nonBlackColor:0}));e.putImageData(o,0,t*Es)}}function copyCtxState(e,t){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const a of i)void 0!==e[a]&&(t[a]=e[a]);if(void 0!==e.setLineDash){t.setLineDash(e.getLineDash());t.lineDashOffset=e.lineDashOffset}}function setAnnotationCanvasName(e,t){e.setAttribute?.("data-canvas-name",t);e._pdfjsCanvasName=t}function resetCtxToDefault(e){e.strokeStyle=e.fillStyle="#000000";e.fillRule="nonzero";e.globalAlpha=1;e.lineWidth=1;e.lineCap="butt";e.lineJoin="miter";e.miterLimit=10;e.globalCompositeOperation="source-over";e.font="10px sans-serif";if(void 0!==e.setLineDash){e.setLineDash([]);e.lineDashOffset=0}const{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}var Gs=new WeakMap;class TransferMapsFallback{constructor(e){canvas_classPrivateFieldInitSpec(this,Gs,void 0);const[t,i=t,a=t]=e,s=Util.identity0to256Map.slice();canvas_classPrivateFieldSet(Gs,this,[t||s,i||s,a||s])}applyToColor(e){if("string"!=typeof e||!e.startsWith("#"))return e;const[t,i,a]=getRGBA(e),[s,r,n]=canvas_classPrivateFieldGet(Gs,this);return Util.makeHexColor(s[t],r[i],n[a])}applyToImageData({data:e}){const[t,i,a]=canvas_classPrivateFieldGet(Gs,this);for(let s=0,r=e.length;s<r;s+=4){e[s]=t[e[s]];e[s+1]=i[e[s+1]];e[s+2]=a[e[s+2]]}}applyToCanvas(e){const{width:t,height:i}=e.canvas,a=e.getImageData(0,0,t,i);this.applyToImageData(a);e.putImageData(a,0,0)}}function getImageSmoothingEnabled(e,t,i){if(t)return!0;Util.singularValueDecompose2dScale(e,As);const a=Math.fround(i*PixelsPerInch.PDF_TO_CSS_UNITS);return As[0]<=a&&As[1]<=a}const Bs=["butt","round","square"],Ms=["miter","round","bevel"],Is={},Ts={};var Ds=new WeakMap,Ls=new WeakMap,Rs=new WeakMap,Os=new WeakMap,Ns=new WeakMap,Ws=new WeakMap,js=new WeakMap,Vs=new WeakMap,Us=new WeakMap,zs=new WeakMap,Hs=new WeakSet;class CanvasGraphics{constructor(e,t,i,a,s,{optionalContentConfig:r,markedContentStack:n=null,pixelRatio:o=OutputScale.pixelRatio},l,d,c,h){!function canvas_classPrivateMethodInitSpec(e,t){canvas_checkPrivateRedeclaration(e,t),t.add(e)}(this,Hs);canvas_classPrivateFieldInitSpec(this,Ds,0);canvas_classPrivateFieldInitSpec(this,Ls,0);canvas_classPrivateFieldInitSpec(this,Rs,null);canvas_classPrivateFieldInitSpec(this,Os,null);canvas_classPrivateFieldInitSpec(this,Ns,null);canvas_classPrivateFieldInitSpec(this,Ws,null);canvas_classPrivateFieldInitSpec(this,js,1);canvas_classPrivateFieldInitSpec(this,Vs,void 0);canvas_classPrivateFieldInitSpec(this,Us,null);canvas_classPrivateFieldInitSpec(this,zs,[]);this.ctx=e;this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.stateStack=[];this.pendingClip=null;this.pendingEOFill=!1;this.commonObjs=t;this.objs=i;this.canvasFactory=a;this.filterFactory=s;this.groupStack=[];this.baseTransform=null;this.baseTransformStack=[];this.groupLevel=0;this.smaskStack=[];this.tempSMask=null;this.smaskGroupCanvases=[];this.smaskPreparedEntry=null;this.smaskPreparedFor=null;this.smaskPreparedOffsetX=0;this.smaskPreparedOffsetY=0;this.smaskPreparedOOBAlpha=null;this.suspendedCtx=null;this.contentVisible=!0;this.markedContentStack=n||[];this.optionalContentConfig=r;this.pixelRatio=o;this.cachedPatterns=new Map;this.annotationCanvasMap=l;this.viewportScale=1;this.outputScaleX=1;this.outputScaleY=1;this.pageColors=d;this._cachedScaleForStroking=[-1,0];this._cachedBitmapsMap=new Map;this.dependencyTracker=c??null;this.imagesTracker=h??null}getObject(e,t,i=null){if("string"==typeof t){this.dependencyTracker?.recordNamedDependency(e,t);return t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t)}return i}beginDrawing({transform:e,viewport:t,transparency:i=!1,background:a=null}){const s=this.ctx.canvas.width,r=this.ctx.canvas.height,n=this.ctx.fillStyle;this.ctx.fillStyle=a||"#ffffff";this.ctx.fillRect(0,0,s,r);this.ctx.fillStyle=n;if(i){const e=this.transparentCanvasEntry=this.canvasFactory.create(s,r);this.compositeCtx=this.ctx;({canvas:this.transparentCanvas,context:this.ctx}=e);this.ctx.save();this.ctx.transform(...getCurrentTransform(this.compositeCtx))}this.ctx.save();resetCtxToDefault(this.ctx);if(e){this.ctx.transform(...e);this.outputScaleX=e[0];this.outputScaleY=e[3]}this.ctx.transform(...t.transform);this.viewportScale=t.scale;this.baseTransform=getCurrentTransform(this.ctx)}executeOperatorList(e,t,i,a,s,r){const n=e.argsArray,o=e.fnArray,l=this._pathCache;this._pathCache=e.pathCache??Xs._.getOrInsertComputed(e,makeMap);try{let l=t||0;const d=n.length;if(d===l)return l;const c=d-l>10&&"function"==typeof i,h=c?Date.now()+15:0;let _=0;const u=this.commonObjs,p=this.objs;let g,m;for(;;){if(void 0!==s){if(l===s.nextBreakPoint){s.breakIt(l,i);return l}if(s.shouldSkip(l)){if(++l===d)return l;continue}}if(!r||r(l,e)){g=o[l];m=n[l]??null;if(g!==T.dependency)null===m?this[g](l):this[g](l,...m);else for(const e of m){this.dependencyTracker?.recordNamedData(e,l);const t=e.startsWith("g_")?u:p;if(!t.has(e)){t.get(e,i,a);return l}}}l++;if(l===d)return l;if(c&&++_>10){if(Date.now()>h){i();return l}_=0}}}finally{this._pathCache=l}}endDrawing(){canvas_assertClassBrand(Hs,this,_restoreInitialState).call(this);for(const e of this.smaskGroupCanvases)this.canvasFactory.destroy(e);this.smaskGroupCanvases.length=0;this._clearPreparedSMask();this.tempSMask=null;this.smaskStack.length=0;for(const e of canvas_classPrivateFieldGet(zs,this))canvas_assertClassBrand(Hs,this,_destroyKnockoutPools).call(this,e);canvas_classPrivateFieldGet(zs,this).length=0;canvas_classPrivateFieldSet(Rs,this,null);canvas_classPrivateFieldSet(Os,this,null);canvas_classPrivateFieldSet(Ns,this,null);canvas_classPrivateFieldSet(Ws,this,null);canvas_classPrivateFieldSet(js,this,1);canvas_classPrivateFieldSet(Us,this,null);canvas_classPrivateFieldSet(Ls,this,0);canvas_classPrivateFieldSet(Ds,this,0);this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear();canvas_assertClassBrand(Hs,this,_drawFilter).call(this)}_scaleImage(e,t){const i=e.width??e.displayWidth,a=e.height??e.displayHeight,s=[];let r=Math.max(Math.hypot(t[0],t[1]),1),n=Math.max(Math.hypot(t[2],t[3]),1),o=i,l=a;for(;r>2&&o>1||n>2&&l>1;){let e=o,t=l;if(r>2&&o>1){e=Math.ceil(o/2);r/=o/e}if(n>2&&l>1){t=Math.ceil(l/2);n/=l/t}s.push({newWidth:e,newHeight:t});o=e;l=t}if(0===s.length)return{img:e,paintWidth:i,paintHeight:a,tmpCanvas:null};if(1===s.length){const{newWidth:t,newHeight:r}=s[0],n=this.canvasFactory.create(t,r);n.context.drawImage(e,0,0,i,a,0,0,t,r);return{img:n.canvas,paintWidth:t,paintHeight:r,tmpCanvas:n}}let d=this.canvasFactory.create(1,1),c=this.canvasFactory.create(1,1),h=i,_=a,u=e;for(const{newWidth:e,newHeight:t}of s){this.canvasFactory.reset(c,e,t);c.context.drawImage(u,0,0,h,_,0,0,e,t);[d,c]=[c,d];u=d.canvas;h=e;_=t}this.canvasFactory.destroy(c);return{img:d.canvas,paintWidth:h,paintHeight:_,tmpCanvas:d}}_createMaskCanvas(e,t){const i=this.ctx,{width:s,height:r}=t,n=this.current.patternFill,o=n?this.current.fillColor:i.fillStyle,l=getCurrentTransform(i);let d,c,h,_;if((t.bitmap||t.data)&&t.count>1){const i=t.bitmap||t.data.buffer;c=JSON.stringify(n?l:[l.slice(0,4),o]);d=this._cachedBitmapsMap.getOrInsertComputed(i,makeMap);const a=d.get(c);if(a&&!n){const t=Math.round(Math.min(l[0],l[2])+l[4]),i=Math.round(Math.min(l[1],l[3])+l[5]);this.dependencyTracker?.recordDependencies(e,ms);return{canvas:a,offsetX:t,offsetY:i}}h=a}if(!h){_=this.canvasFactory.create(s,r);putBinaryImageMask(_.context,t)}let u=Util.transform(l,[1/s,0,0,-1/r,0,0]);u=Util.transform(u,[1,0,0,1,0,-r]);const p=a.slice();Util.axialAlignedBoundingBox([0,0,s,r],u,p);const[g,m,f,v]=p,P=Math.round(f-g)||1,w=Math.round(v-m)||1,F=this.canvasFactory.create(P,w),y=F.context,b=g,S=m;y.translate(-b,-S);y.transform(...u);let C=null;if(!h){const e=this._scaleImage(_.canvas,getCurrentTransformInverse(y));h=e.img;C=e.tmpCanvas;if(h!==_.canvas){this.canvasFactory.destroy(_);_=null}if(d&&n){d.set(c,h);C=null;_=null}}y.imageSmoothingEnabled=getImageSmoothingEnabled(getCurrentTransform(y),t.interpolate,this.pixelRatio);drawImageAtIntegerCoords(y,h,0,0,h.width,h.height,0,0,s,r);C&&this.canvasFactory.destroy(C);_&&this.canvasFactory.destroy(_);y.globalCompositeOperation="source-in";const x=Util.transform(getCurrentTransformInverse(y),[1,0,0,1,-b,-S]);y.fillStyle=n?o.getPattern(i,this,x,bs,e):o;y.fillRect(0,0,s,r);d&&!n&&d.set(c,F.canvas);this.dependencyTracker?.recordDependencies(e,ms);return{canvas:F.canvas,canvasEntry:d&&!n?null:F,offsetX:Math.round(b),offsetY:Math.round(S)}}setLineWidth(e,t){this.dependencyTracker?.recordSimpleData("lineWidth",e);t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1);this.current.lineWidth=t;this.ctx.lineWidth=t}setLineCap(e,t){this.dependencyTracker?.recordSimpleData("lineCap",e);this.ctx.lineCap=Bs[t]}setLineJoin(e,t){this.dependencyTracker?.recordSimpleData("lineJoin",e);this.ctx.lineJoin=Ms[t]}setMiterLimit(e,t){this.dependencyTracker?.recordSimpleData("miterLimit",e);this.ctx.miterLimit=t}setDash(e,t,i){this.dependencyTracker?.recordSimpleData("dash",e);const a=this.ctx;if(void 0!==a.setLineDash){a.setLineDash(t);a.lineDashOffset=i}}setRenderingIntent(e,t){}setFlatness(e,t){}setGState(e,t){for(const[i,a]of t)switch(i){case"LW":this.setLineWidth(e,a);break;case"LC":this.setLineCap(e,a);break;case"LJ":this.setLineJoin(e,a);break;case"ML":this.setMiterLimit(e,a);break;case"D":this.setDash(e,a[0],a[1]);break;case"RI":this.setRenderingIntent(e,a);break;case"FL":this.setFlatness(e,a);break;case"Font":this.setFont(e,a[0],a[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",e);this.current.strokeAlpha=a;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",e);this.ctx.globalAlpha=this.current.fillAlpha=a;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",e);this.ctx.globalCompositeOperation=a;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",e);this.current.activeSMask=a?this.tempSMask:null;this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation);this.tempSMask=null;this.checkSMaskState(e);break;case"TR":{this.dependencyTracker?.recordSimpleData("filter",e);let t=this.filterFactory.addFilter(a);this.ctx.filter=t;let i=null;if(a&&("none"===t||!FeatureTest.isCanvasFilterSupported||"none"===this.ctx.filter||""===this.ctx.filter)){this.ctx.filter=t="none";i=new TransferMapsFallback(a)}this.current.transferMaps=t;if(i||this.current.transferMapsFallback){this.current.transferMapsFallback=i;this.current.patternFill||(this.ctx.fillStyle=canvas_assertClassBrand(Hs,this,_transferColor).call(this,this.current.fillColor));this.current.patternStroke||(this.ctx.strokeStyle=canvas_assertClassBrand(Hs,this,_transferColor).call(this,this.current.strokeColor))}break}}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){if(this.smaskPreparedEntry){this.canvasFactory.destroy(this.smaskPreparedEntry);this.smaskPreparedEntry=null}this.smaskPreparedFor=null;this.smaskPreparedOffsetX=0;this.smaskPreparedOffsetY=0;this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(e){if(e!==this.smaskPreparedFor){this._clearPreparedSMask();this._prepareSMaskCanvas(e)}}checkSMaskState(e){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode(e):!this.current.activeSMask&&t?this.endSMaskMode():this.current.activeSMask&&t&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(e){const{canvas:t,subtype:i,backdrop:a,transferMap:s}=e,r="Luminosity"===i||"Alpha"===i&&s;if(!(r||"Luminosity"===i&&a)){this.smaskPreparedFor=e;return}let n;if("Luminosity"===i&&a){const[e,t,i]=getRGBA(a),r=Math.round(.3*e+.59*t+.11*i);n=s?.[r]??r}else n=s?.[0]??0;const{width:o,height:l}=this.ctx.canvas,d=o*l<4*(t.width*t.height),c=r?{url:"Alpha"===i?this.filterFactory.addAlphaFilter(s):this.filterFactory.addLuminosityFilter(s),subtype:i,transferMap:s}:null,h="Luminosity"===i?a:null;let _,u,p;if(d){_=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,o,l,h,c);u=0;p=0}else{_=this._bakeSMaskCanvas(t,0,0,t.width,t.height,h,c);u=e.offsetX;p=e.offsetY}this.smaskPreparedEntry=_;this.smaskPreparedFor=e;this.smaskPreparedOffsetX=u;this.smaskPreparedOffsetY=p;this.smaskPreparedOOBAlpha=d||0===n?null:n}_bakeSMaskCanvas(e,t,i,a,s,r,n){r||n||unreachable("_bakeSMaskCanvas with neither backdrop nor filter");const o=this.canvasFactory.create(a,s),l=o.context;l.drawImage(e,t,i);if(r){l.globalCompositeOperation="destination-atop";l.fillStyle=r;l.fillRect(0,0,a,s)}if(!n)return o;const d=this.canvasFactory.create(a,s),c=d.context;c.filter=n.url;const h=FeatureTest.isCanvasFilterSupported&&"none"!==c.filter&&""!==c.filter;c.drawImage(o.canvas,0,0);FeatureTest.isCanvasFilterSupported&&(c.filter="none");if(!h){const e=c.getImageData(0,0,a,s),{data:t}=e,{transferMap:i}=n;if("Luminosity"===n.subtype)for(let e=0,a=t.length;e<a;e+=4){const a=.3*t[e]+.59*t[e+1]+.11*t[e+2]+.5|0;t[e]=t[e+1]=t[e+2]=0;t[e+3]=i?.[a]??a}else for(let e=3,a=t.length;e<a;e+=4)t[e]=i[t[e]];c.putImageData(e,0,0)}this.canvasFactory.destroy(o);return d}beginSMaskMode(e){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:t,height:i}=this.ctx.canvas,a=this.canvasFactory.create(t,i);this.smaskScratchCanvas=a;this.suspendedCtx=this.ctx;const s=this.ctx=a.context;s.setTransform(this.suspendedCtx.getTransform());copyCtxState(this.suspendedCtx,s);mirrorContextOperations(s,this.suspendedCtx);this._ensurePreparedSMask(this.current.activeSMask);this.setGState(e,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring();copyCtxState(this.ctx,this.suspendedCtx);this.ctx=this.suspendedCtx;this.suspendedCtx=null;this.canvasFactory.destroy(this.smaskScratchCanvas);this.smaskScratchCanvas=null;this._clearPreparedSMask()}compose(e){if(!this.current.activeSMask)return;e=e?[Math.floor(e[0]),Math.floor(e[1]),Math.ceil(e[2]),Math.ceil(e[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,i=this.suspendedCtx,a=canvas_classPrivateFieldGet(Ls,this)>0&&i===this.ctx;this.composeSMask(a?null:i,t,this.ctx,e);if(!a){this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height);this.ctx.restore()}}composeSMask(e,t,i,a){const s=a[0],r=a[1],n=a[2]-s,o=a[3]-r;if(0===n||0===o)return;const l=this.smaskPreparedEntry;if(l){let e=s,a=r,d=n,c=o;const h=this.smaskPreparedOOBAlpha,_=null!==h;if(_){e=Math.max(s,t.offsetX);a=Math.max(r,t.offsetY);d=Math.min(s+n,t.offsetX+t.canvas.width)-e;c=Math.min(r+o,t.offsetY+t.canvas.height)-a}if(d>0&&c>0){const t=e-this.smaskPreparedOffsetX,s=a-this.smaskPreparedOffsetY;i.save();i.globalAlpha=1;i.setTransform(1,0,0,1,0,0);const r=new Path2D;r.rect(e,a,d,c);i.clip(r);i.globalCompositeOperation="destination-in";i.drawImage(l.canvas,t,s,d,c,e,a,d,c);i.restore()}_&&h<255&&this._applySMaskOOBAlpha(i,s,r,n,o,e,a,e+d,a+c,h)}else this.genericComposeSMask(t,i,n,o,s,r);if(e){e.save();e.globalAlpha=1;e.globalCompositeOperation=t.blendMode||"source-over";e.setTransform(1,0,0,1,0,0);e.drawImage(i.canvas,s,r,n,o,s,r,n,o);e.restore()}}_applySMaskOOBAlpha(e,t,i,a,s,r,n,o,l,d){const c=r<o&&n<l;if(c&&r===t&&n===i&&o===t+a&&l===i+s)return;const h=new Path2D;h.rect(t,i,a,s);c&&h.rect(r,n,o-r,l-n);e.save();e.globalAlpha=d/255;e.setTransform(1,0,0,1,0,0);e.clip(h,"evenodd");e.globalCompositeOperation="destination-in";e.fillStyle="#000000";e.fillRect(t,i,a,s);e.restore()}genericComposeSMask(e,t,i,a,s,r){const{context:n,offsetX:o,offsetY:l}=e;t.save();t.globalAlpha=1;t.setTransform(1,0,0,1,0,0);const d=new Path2D;d.rect(s,r,i,a);t.clip(d);t.globalCompositeOperation="destination-in";t.drawImage(n.canvas,s-o,r-l,i,a,s,r,i,a);t.restore()}save(e){this.inSMaskMode&&copyCtxState(this.ctx,this.suspendedCtx);this.ctx.save();const t=this.current;this.stateStack.push(t);this.current=t.clone();this.dependencyTracker?.save(e)}restore(e){this.dependencyTracker?.restore(e);if(0!==this.stateStack.length){this.current=this.stateStack.pop();this.ctx.restore();if(this.inSMaskMode){copyCtxState(this.suspendedCtx,this.ctx);this.ctx.setTransform(this.suspendedCtx.getTransform())}this.checkSMaskState(e);this.pendingClip=null;this._cachedScaleForStroking[0]=-1}else this.inSMaskMode&&this.endSMaskMode()}resetGraphicsState(){const{clipBox:e,transferMaps:t,transferMapsFallback:i}=this.current,a=this.current=new CanvasExtraState(0,0);a.clipBox=e;a.transferMaps=t;a.transferMapsFallback=i;const s=this.ctx;s.lineWidth=1;s.lineCap="butt";s.lineJoin="miter";s.miterLimit=10;if(void 0!==s.setLineDash){s.setLineDash([]);s.lineDashOffset=0}this._cachedScaleForStroking[0]=-1}transform(e,t,i,a,s,r,n){this.dependencyTracker?.recordIncrementalData("transform",e);this.ctx.transform(t,i,a,s,r,n);this._cachedScaleForStroking[0]=-1}constructPath(e,t,i,a){let s=this._pathCache.get(e);if(!a){if(!s){s=new Path2D;this._pathCache.set(e,s)}t!==T.stroke&&t!==T.closeStroke&&(this.current.tilingPatternDims=null);this[t](e,s);return}if(null!==this.dependencyTracker){const i=t===T.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,a[0]-i,a[2]+i,a[1]-i,a[3]+i).recordDependencies(e,["transform"])}if(!s){s=makePathFromDrawOPS(i[0]);this._pathCache.set(e,s)}Util.axialAlignedBoundingBox(a,getCurrentTransform(this.ctx),this.current.minMax);const r=this.current.tilingPatternDims;if(r&&t!==T.stroke&&t!==T.closeStroke&&this.current.fillColor instanceof TilingPattern){const e=Util.intersect(this.current.clipBox,this.current.minMax);e?this.current.fillColor.updatePatternDims(e,r):this.current.tilingPatternDims=null}this[t](e,s);this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,t,i=!0){const a=i&&canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.strokeAlpha),s=this.ctx,r=this.current.strokeColor;s.globalAlpha=this.current.strokeAlpha;if(this.contentVisible)if("object"==typeof r&&r?.getPattern){const i=r.isModifyingCurrentTransform()?s.getTransform():null;s.save();s.strokeStyle=r.getPattern(s,this,getCurrentTransformInverse(s),Ss,e);if(i){const e=new Path2D;e.addPath(t,s.getTransform().invertSelf().multiplySelf(i));t=e}this.rescaleAndStroke(t,!1);s.restore()}else this.rescaleAndStroke(t,!0);this.dependencyTracker?.recordDependencies(e,cs);i&&this.consumePath(e,t,this.current.getClippedPathBoundingBox(Ss,getCurrentTransform(this.ctx)));s.globalAlpha=this.current.fillAlpha;canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,a)}closeStroke(e,t){this.stroke(e,t)}fill(e,t,i=!0){const a=i&&canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx,r=this.current.fillColor,n=this.current.patternFill;let o=!1;const l=this.current.getClippedPathBoundingBox();this.dependencyTracker?.recordDependencies(e,hs);if(n){const n=this.current.tilingPatternDims,d=n&&r.canSkipPatternCanvas(n);if(d){const{pendingClip:s,pendingEOFill:n}=this;this.pendingClip=null;this.pendingEOFill=!1;r.drawPattern(this,t,n,d,e);this.pendingClip=s;i&&this.consumePath(e,t,l);this.current.tilingPatternDims=null;canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,a);return}const c=r.isModifyingCurrentTransform()?s.getTransform():null;this.dependencyTracker?.save(e);s.save();s.fillStyle=r.getPattern(s,this,getCurrentTransformInverse(s),bs,e);if(c){const e=new Path2D;e.addPath(t,s.getTransform().invertSelf().multiplySelf(c));t=e}o=!0}if(this.contentVisible&&null!==l)if(this.pendingEOFill){s.fill(t,"evenodd");this.pendingEOFill=!1}else s.fill(t);if(o){s.restore();this.dependencyTracker?.restore(e)}i&&this.consumePath(e,t,l);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,a)}eoFill(e,t){this.pendingEOFill=!0;this.fill(e,t)}fillStroke(e,t){const i=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(e,t,!1);this.stroke(e,t,!1);this.consumePath(e,t);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,i)}eoFillStroke(e,t){this.pendingEOFill=!0;this.fillStroke(e,t)}closeFillStroke(e,t){this.fillStroke(e,t)}closeEOFillStroke(e,t){this.pendingEOFill=!0;this.fillStroke(e,t)}endPath(e,t){this.consumePath(e,t)}rawFillPath(e,t){const i=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha);this.ctx.fill(t);this.dependencyTracker?.recordDependencies(e,us).recordOperation(e);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,i)}clip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e);this.pendingClip=Is}eoClip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e);this.pendingClip=Ts}beginText(e){this.current.textMatrix=null;this.current.textMatrixScale=1;this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0;this.dependencyTracker?.recordOpenMarker(e).resetIncrementalData("sameLineText").resetIncrementalData("moveText",e)}endText(e){const t=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;void 0!==t&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",e);i.recordCloseMarker(e)}if(void 0!==t){const e=new Path2D,a=i.getTransform().invertSelf();for(const{transform:i,x:s,y:r,fontSize:n,path:o}of t)o&&e.addPath(o,new DOMMatrix(i).preMultiplySelf(a).translate(s,r).scale(n,-n));i.clip(e)}delete this.pendingTextPaths}setCharSpacing(e,t){this.dependencyTracker?.recordSimpleData("charSpacing",e);this.current.charSpacing=t}setWordSpacing(e,t){this.dependencyTracker?.recordSimpleData("wordSpacing",e);this.current.wordSpacing=t}setHScale(e,t){this.dependencyTracker?.recordSimpleData("hScale",e);this.current.textHScale=t/100}setLeading(e,t){this.dependencyTracker?.recordSimpleData("leading",e);this.current.leading=-t}setFont(e,t,i){this.dependencyTracker?.recordSimpleData("font",e).recordSimpleDataFromNamed("fontObj",t,e);const a=this.commonObjs.get(t),r=this.current;if(!a)throw new Error(`Can't find font for ${t}`);r.fontMatrix=a.fontMatrix||s;0!==r.fontMatrix[0]&&0!==r.fontMatrix[3]||warn("Invalid font matrix for font "+t);if(i<0){i=-i;r.fontDirection=-1}else r.fontDirection=1;this.current.font=a;this.current.fontSize=i;if(a.isType3Font)return;const n=a.loadedName||"sans-serif",o=a.systemFontInfo?.css||`"${n}", ${a.fallbackName}`;let l="normal";a.black?l="900":a.bold&&(l="bold");const d=a.italic?"italic":"normal",c=MathClamp(i,16,100);this.current.fontSizeScale=i/c;this.ctx.font=`${d} ${l} ${c}px ${o}`}setTextRenderingMode(e,t){this.dependencyTracker?.recordSimpleData("textRenderingMode",e);this.current.textRenderingMode=t}setTextRise(e,t){this.dependencyTracker?.recordSimpleData("textRise",e);this.current.textRise=t}moveText(e,t,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",e);this.current.x=this.current.lineX+=t;this.current.y=this.current.lineY+=i}setLeadingMoveText(e,t,i){this.setLeading(e,-i);this.moveText(e,t,i)}setTextMatrix(e,t){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",e);const{current:i}=this;i.textMatrix=t;i.textMatrixScale=Math.hypot(t[0],t[1]);i.x=i.lineX=0;i.y=i.lineY=0}nextLine(e){this.moveText(e,0,this.current.leading);this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??e)}paintChar(e,t,i,a,s,r){const n=this.ctx,o=this.current,l=o.font,d=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,h=d&S,_=!!(d&C),u=o.patternFill&&!l.missingFile,p=o.patternStroke&&!l.missingFile;let g;(l.disableFontFace||_||u||p)&&!l.missingFile&&(g=l.getPathGenerator(this.commonObjs,t));if(g&&(l.disableFontFace||u||p)){n.save();n.translate(i,a);n.scale(c,-c);this.dependencyTracker?.recordCharacterBBox(e,n,l);let t;if(h===w||h===y)if(s){t=n.getTransform();n.setTransform(...s);const e=canvas_assertClassBrand(Hs,this,_getScaledPath).call(this,g,t,s);n.fill(e)}else n.fill(g);if(h===F||h===y)if(r){t||=n.getTransform();n.setTransform(...r);const{a:e,b:i,c:a,d:s}=t,o=Util.inverseTransform(r),l=Util.transform([e,i,a,s,0,0],o);Util.singularValueDecompose2dScale(l,As);n.lineWidth*=Math.max(As[0],As[1])/c;n.stroke(canvas_assertClassBrand(Hs,this,_getScaledPath).call(this,g,t,r))}else{n.lineWidth/=c;n.stroke(g)}n.restore()}else{if(h===w||h===y){n.fillText(t,i,a);this.dependencyTracker?.recordCharacterBBox(e,n,l,c,i,a,()=>n.measureText(t))}if(h===F||h===y){this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(e,n,l,c,i,a,()=>n.measureText(t)).recordDependencies(e,cs);n.strokeText(t,i,a)}}if(_){(this.pendingTextPaths||=[]).push({transform:getCurrentTransform(n),x:i,y:a,fontSize:c,path:g});this.dependencyTracker?.recordCharacterBBox(e,n,l,c,i,a)}}get isFontSubpixelAAEnabled(){const e=this.canvasFactory.create(10,10),t=e.context;t.scale(1.5,1);t.fillText("I",0,10);const i=t.getImageData(0,0,10,10).data;this.canvasFactory.destroy(e);let a=!1;for(let e=3;e<i.length;e+=4)if(i[e]>0&&i[e]<255){a=!0;break}return shadow(this,"isFontSubpixelAAEnabled",a)}showText(e,t){if(this.dependencyTracker){this.dependencyTracker.recordDependencies(e,ps).resetBBox(e);this.current.textRenderingMode&C&&this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies()}const i=this.current,a=i.font;if(a.isType3Font){const a=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,i.fillAlpha);this.showType3Text(e,t);this.dependencyTracker?.recordShowTextOperation(e);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,a);return}const s=i.fontSize;if(0===s){this.dependencyTracker?.recordOperation(e);return}const r=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,i.fillAlpha),n=this.ctx,o=i.fontSizeScale,l=i.charSpacing,d=i.wordSpacing,c=i.fontDirection,h=i.textHScale*c,_=t.length,u=a.vertical,p=u?1:-1,g=s*i.fontMatrix[0],m=i.textRenderingMode===w&&!a.disableFontFace&&!i.patternFill;n.save();i.textMatrix&&n.transform(...i.textMatrix);n.translate(i.x,i.y+i.textRise);c>0?n.scale(h,-1):n.scale(h,1);let f,v;const P=i.textRenderingMode&S,b=P===w||P===y,x=P===F||P===y;let k=i.lineWidth;const E=i.textMatrixScale;0===E||0===k?x&&(k=this.getSinglePixelWidth()):k/=E;if(1!==o){n.scale(o,o);k/=o}n.lineWidth=k;b&&i.patternFill&&([n.fillStyle,f]=canvas_assertClassBrand(Hs,this,_getTextPattern).call(this,i.fillColor,bs,e));x&&i.patternStroke&&([n.strokeStyle,v]=canvas_assertClassBrand(Hs,this,_getTextPattern).call(this,i.strokeColor,Ss,e));if(a.isInvalidPDFjsFont){const a=[];let s=0;for(const e of t){a.push(e.unicode);s+=e.width}const o=a.join("");n.fillText(o,0,0);if(null!==this.dependencyTracker){const t=n.measureText(o);this.dependencyTracker.recordBBox(e,this.ctx,-t.actualBoundingBoxLeft,t.actualBoundingBoxRight,-t.actualBoundingBoxAscent,t.actualBoundingBoxDescent).recordShowTextOperation(e)}i.x+=s*g*h;n.restore();this.compose();canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,r);return}let A,G=0,B=null;for(A=0;A<_;++A){const r=t[A];if("number"==typeof r){G+=p*r*s/1e3;continue}let h=!1;const _=(r.isSpace?d:0)+l,P=r.fontChar,w=r.accent;let F,y,b,S=r.width;if(u){const e=r.vmetric,t=-e[1]*g,i=e[2]*g;S=-e[0];F=t/o;y=(G+i)/o;if(r.isRotated){b=n.measureText(P);const e=g/o,t=r.width/2*e,i=F+t;F=y-380*e-t;y=(b.actualBoundingBoxAscent-b.actualBoundingBoxDescent)/2-i;h=!0;n.save();n.rotate(Math.PI/2)}}else{F=G/o;y=0}const C=r.isRotated?r.width:S;let x=1;if((a.remeasure||r.isRotated)&&C>0){b??=n.measureText(P);const e=1e3*b.width/s*o;if(C<e&&this.isFontSubpixelAAEnabled){x=C/e;if(!h){h=!0;n.save()}n.scale(x,1);F/=x}else C!==e&&(F+=(C-e)/2e3*s/o)}if(h&&a.missingFile&&(f||v)){B||=new Map;[n.fillStyle,n.strokeStyle]=B.getOrInsertComputed(r.isRotated?-x:x,()=>[f?canvas_assertClassBrand(Hs,this,_getTextPattern).call(this,i.fillColor,bs,e)[0]:n.fillStyle,v?canvas_assertClassBrand(Hs,this,_getTextPattern).call(this,i.strokeColor,Ss,e)[0]:n.strokeStyle])}if(this.contentVisible&&(r.isInFont||a.missingFile))if(m&&!w){n.fillText(P,F,y);this.dependencyTracker?.recordCharacterBBox(e,n,b?{bbox:null}:a,s/o,F,y,()=>b??n.measureText(P))}else{this.paintChar(e,P,F,y,f,v);if(w){const t=F+s*w.offset.x/o,i=y-s*w.offset.y/o;this.paintChar(e,w.fontChar,t,i,f,v)}}G+=u?S*g-_*c:S*g+_*c;h&&n.restore()}u?i.y-=G:i.x+=G*h;n.restore();this.compose();this.dependencyTracker?.recordShowTextOperation(e);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,r)}showType3Text(e,t){const i=this.ctx,a=this.current,r=a.font,n=a.fontSize,o=a.fontDirection,l=r.vertical?1:-1,d=a.charSpacing,c=a.wordSpacing,h=a.textHScale*o,_=a.fontMatrix||s,u=t.length,p=a.textRenderingMode!==b;let g,m,f,v;if(0===n)return;this._cachedScaleForStroking[0]=-1;i.save();a.textMatrix&&i.transform(...a.textMatrix);i.translate(a.x,a.y+a.textRise);i.scale(h,o);const P=this.dependencyTracker;this.dependencyTracker=P?new CanvasNestedDependencyTracker(P,e):null;try{for(g=0;g<u;++g){m=t[g];if("number"==typeof m){v=l*m*n/1e3;this.ctx.translate(v,0);a.x+=v*h;continue}const e=(m.isSpace?c:0)+d,s=r.charProcOperatorList.get(m.operatorListId);if(s){if(this.contentVisible&&p){this.save();i.scale(n,n);i.transform(..._);this.executeOperatorList(s);this.restore()}}else warn(`Type3 character "${m.operatorListId}" is not available.`);f=m.width*_[0]*n+e*o;i.translate(f,0);a.x+=f*h}}finally{P&&(this.dependencyTracker=P)}i.restore()}setCharWidth(e,t,i){}setCharWidthAndBounds(e,t,i,a,s,r,n){const o=new Path2D;o.rect(a,s,r-a,n-s);this.ctx.clip(o);this.dependencyTracker?.recordBBox(e,this.ctx,a,r,s,n).recordClipBox(e,this.ctx,a,r,s,n);this.endPath(e)}getColorN_Pattern(e,t){let i;if("TilingPattern"===t[0]){const e=this.baseTransform||getCurrentTransform(this.ctx),a={createCanvasGraphics:(e,t)=>new CanvasGraphics(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack,pixelRatio:this.pixelRatio},void 0,void 0,this.dependencyTracker?new CanvasNestedDependencyTracker(this.dependencyTracker,t,!0):null)};i=new TilingPattern(t,this.ctx,a,e)}else i=this._getPattern(e,t[1],t[2]);return i}setStrokeColorN(e,...t){this.dependencyTracker?.recordSimpleData("strokeColor",e);this.current.strokeColor=this.getColorN_Pattern(e,t);this.current.patternStroke=!0}setFillColorN(e,...t){this.dependencyTracker?.recordSimpleData("fillColor",e);const i=this.current.fillColor=this.getColorN_Pattern(e,t);this.current.patternFill=!0;this.current.tilingPatternDims=i instanceof TilingPattern?[0,0,0,0]:null}setStrokeRGBColor(e,t){this.dependencyTracker?.recordSimpleData("strokeColor",e);this.current.strokeColor=t;this.ctx.strokeStyle=canvas_assertClassBrand(Hs,this,_transferColor).call(this,t);this.current.patternStroke=!1}setStrokeTransparent(e){this.dependencyTracker?.recordSimpleData("strokeColor",e);this.ctx.strokeStyle=this.current.strokeColor="transparent";this.current.patternStroke=!1}setFillRGBColor(e,t){this.dependencyTracker?.recordSimpleData("fillColor",e);this.current.fillColor=t;this.ctx.fillStyle=canvas_assertClassBrand(Hs,this,_transferColor).call(this,t);this.current.patternFill=!1;this.current.tilingPatternDims=null}setFillTransparent(e){this.dependencyTracker?.recordSimpleData("fillColor",e);this.ctx.fillStyle=this.current.fillColor="transparent";this.current.patternFill=!1;this.current.tilingPatternDims=null}_getPattern(e,t,i=null){const a=this.cachedPatterns.getOrInsertComputed(t,()=>function getShadingPattern(e){switch(e[0]){case"RadialAxial":return new RadialAxialShadingPattern(e);case"Mesh":return new MeshShadingPattern(e);case"Dummy":return new DummyShadingPattern}throw new Error(`Unknown IR type: ${e[0]}`)}(this.getObject(e,t)));i&&(a.matrix=i);return a}shadingFill(e,t){if(!this.contentVisible)return;const i=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx;this.save(e);const r=this._getPattern(e,t);s.fillStyle=r.getPattern(s,this,getCurrentTransformInverse(s),Cs,e);const n=getCurrentTransformInverse(s);if(n){const{width:e,height:t}=s.canvas,i=a.slice();Util.axialAlignedBoundingBox([0,0,e,t],n,i);const[r,o,l,d]=i;this.ctx.fillRect(r,o,l-r,d-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,gs).recordDependencies(e,hs).recordOperation(e);this.compose(this.current.getClippedPathBoundingBox());this.restore(e);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,i)}beginInlineImage(){unreachable("Should not call beginInlineImage")}beginImageData(){unreachable("Should not call beginImageData")}paintFormXObjectBegin(e,t,i){if(this.contentVisible){this.save(e);this.baseTransformStack.push(this.baseTransform);t&&this.transform(e,...t);this.baseTransform=getCurrentTransform(this.ctx);if(i){Util.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[t,a,s,r]=i,n=new Path2D;n.rect(t,a,s-t,r-a);this.ctx.clip(n);this.dependencyTracker?.recordClipBox(e,this.ctx,t,s,a,r);this.endPath(e)}}}paintFormXObjectEnd(e){if(this.contentVisible){this.restore(e);this.baseTransform=this.baseTransformStack.pop()}}beginGroup(e,t){if(!this.contentVisible)return;this.save(e);const{inSMaskMode:i}=this;if(i){this.endSMaskMode();this.current.activeSMask=null}const s=this.ctx;if(!(t.needsIsolation&&(t.isolated||t.hasSoftMask)||t.knockout||t.isGray||0!==canvas_classPrivateFieldGet(Ds,this)||1!==s.globalAlpha||"source-over"!==s.globalCompositeOperation||i)){if(t.bbox){let e=new Path2D;const[i,a,r,n]=t.bbox;e.rect(i,a,r-i,n-a);if(t.matrix){const i=new Path2D;i.addPath(e,new DOMMatrix(t.matrix));e=i}s.clip(e)}this.groupStack.push(null);canvas_classPrivateFieldGet(zs,this).push(null);this.groupLevel++;return}t.isolated||t.knockout||0!==canvas_classPrivateFieldGet(Ds,this)||info("TODO: Fully support non-isolated non-knockout groups.");const r=getCurrentTransform(s);t.matrix&&s.transform(...t.matrix);const n=[0,0,s.canvas.width,s.canvas.height];let o;if(t.bbox){o=a.slice();Util.axialAlignedBoundingBox(t.bbox,getCurrentTransform(s),o);o=Util.intersect(o,n)||[0,0,0,0]}else o=n;const l=Math.floor(o[0]),d=Math.floor(o[1]),c=Math.max(Math.ceil(o[2])-l,1),h=Math.max(Math.ceil(o[3])-d,1);this.current.startNewPathAndClipBox([0,0,c,h]);const _=this.canvasFactory.create(c,h);t.smask&&this.smaskGroupCanvases.push(_);const u=_.context,p=t.knockout&&!t.isolated?s:null,g=!t.isolated&&!t.knockout&&!t.smask&&t.needsIsolation&&canvas_classPrivateFieldGet(Ds,this)>0,m=t.knockout?this.canvasFactory.create(c,h):null,f=canvas_classPrivateFieldGet(Ds,this);if(t.knockout){var v;canvas_classPrivateFieldSet(Ds,this,(v=canvas_classPrivateFieldGet(Ds,this),v++,v))}else canvas_classPrivateFieldSet(Ds,this,0);u.translate(-l,-d);u.transform(...r);const P=!t.isolated&&!t.smask&&t.needsIsolation,w=P&&!i&&0===f&&!t.knockout&&!t.isGray&&t.hasSoftMask&&1===s.globalAlpha&&"source-over"===s.globalCompositeOperation&&"none"===this.current.transferMaps&&!this.current.transferMapsFallback;if(P&&(i||w)){u.save();u.setTransform(1,0,0,1,0,0);u.drawImage(s.canvas,-l,-d);u.restore()}if(t.bbox){let e=new Path2D;const[i,a,s,r]=t.bbox;e.rect(i,a,s-i,r-a);if(t.matrix){const i=new Path2D;i.addPath(e,new DOMMatrix(t.matrix));e=i}u.clip(e)}t.smask&&this.smaskStack.push({canvas:_.canvas,context:u,offsetX:l,offsetY:d,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null});if(!t.smask||this.dependencyTracker){s.setTransform(1,0,0,1,0,0);s.translate(l,d);s.save()}copyCtxState(s,u);this.ctx=u;this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s);this.setGState(e,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]);this.groupStack.push(s);canvas_classPrivateFieldGet(zs,this).push({backdropCtx:p,savedKnockoutLevel:f,offsetX:l,offsetY:d,hasInnerBackdrop:g,replaceBackdrop:w,knockoutMaskEntry:m,knockoutTempEntry:null,knockoutBackdropEntry:null});this.groupLevel++}endGroup(e,t){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,s=this.groupStack.pop(),r=canvas_classPrivateFieldGet(zs,this).pop();r&&canvas_classPrivateFieldSet(Ds,this,r.savedKnockoutLevel);if(null!==s){t.isGray&&canvas_assertClassBrand(Hs,this,_convertGroupToGray).call(this,i);this.ctx=s;this.ctx.imageSmoothingEnabled=!1;this.dependencyTracker?.popBaseTransform();if(t.smask){this.tempSMask=this.smaskStack.pop();this.restore(e);if(this.dependencyTracker){this.ctx.restore();this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())}canvas_assertClassBrand(Hs,this,_destroyKnockoutPools).call(this,r)}else{this.ctx.restore();const t=getCurrentTransform(this.ctx);this.restore(e);this.current.transferMapsFallback?.applyToCanvas(i);this.ctx.save();this.ctx.setTransform(...t);const n=a.slice();Util.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],t,n);const o=canvas_classPrivateFieldGet(zs,this).at(-1);if(canvas_classPrivateFieldGet(Ds,this)>0)if(r.hasInnerBackdrop){const{width:e,height:a}=i.canvas,n=this.canvasFactory.create(e,a),o=n.context;o.drawImage(s.canvas,r.offsetX,r.offsetY,e,a,0,0,e,a);o.globalCompositeOperation="source-over";o.drawImage(i.canvas,0,0);const l=canvas_assertClassBrand(Hs,this,_createKnockoutMaskCanvas).call(this,i.canvas);o.globalCompositeOperation="destination-in";o.drawImage(l.canvas,0,0);const d=this.ctx.globalCompositeOperation,c=this.ctx.globalAlpha,h=this.ctx.filter;this.ctx.save();this.ctx.setTransform(...t);this.ctx.globalAlpha=1;FeatureTest.isCanvasFilterSupported&&(this.ctx.filter="none");this.ctx.globalCompositeOperation="destination-out";this.ctx.drawImage(l.canvas,0,0);this.ctx.globalCompositeOperation=d;this.ctx.globalAlpha=c;FeatureTest.isCanvasFilterSupported&&(this.ctx.filter=h??"none");this.ctx.drawImage(n.canvas,0,0);this.ctx.restore();this.canvasFactory.destroy(l);this.canvasFactory.destroy(n)}else{const e=o?.backdropCtx??null;canvas_assertClassBrand(Hs,this,_compositeKnockoutSurface).call(this,this.ctx,i.canvas,{backdropCanvas:e?.canvas??null,destTransform:t,backdropOffset:e?[o.offsetX+r.offsetX,o.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(r.replaceBackdrop){const e=new Path2D;e.rect(0,0,i.canvas.width,i.canvas.height);this.ctx.clip(e);this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(i.canvas,0,0)}this.ctx.restore();this.canvasFactory.destroy({canvas:i.canvas,context:i});canvas_assertClassBrand(Hs,this,_destroyKnockoutPools).call(this,r);this.compose(n)}}else this.restore(e)}beginAnnotation(e,t,i,a,s,r,n){canvas_assertClassBrand(Hs,this,_restoreInitialState).call(this);resetCtxToDefault(this.ctx);this.ctx.save();this.save(e);this.baseTransform&&this.ctx.setTransform(...this.baseTransform);if(i){const s=i[2]-i[0],o=i[3]-i[1];if(r&&this.annotationCanvasMap){(a=a.slice())[4]-=i[0];a[5]-=i[1];Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx),As);const{viewportScale:e}=this,r=Math.ceil(s*this.outputScaleX*e),l=Math.ceil(o*this.outputScaleY*e);this.annotationCanvas=this.canvasFactory.create(r,l);const{canvas:d,context:c}=this.annotationCanvas;if(n){const e=this.annotationCanvasMap.getOrInsertComputed(t,makeArr);setAnnotationCanvasName(d,n);const i=e.findIndex(e=>function getAnnotationCanvasName(e){return e._pdfjsCanvasName??null}(e)===n);-1===i?e.push(d):e[i]=d}else this.annotationCanvasMap.set(t,d);this.annotationCanvas.savedCtx=this.ctx;this.ctx=c;this.ctx.save();this.ctx.setTransform(As[0],0,0,-As[1],0,o*As[1]);resetCtxToDefault(this.ctx)}else{resetCtxToDefault(this.ctx);this.endPath(e);const t=new Path2D;t.rect(i[0],i[1],s,o);this.ctx.clip(t)}}this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.baseTransformStack.push(this.baseTransform);this.transform(e,...a);this.transform(e,...s);this.baseTransform=getCurrentTransform(this.ctx)}endAnnotation(e){if(this.annotationCanvas){this.ctx.restore();canvas_assertClassBrand(Hs,this,_drawFilter).call(this);this.ctx=this.annotationCanvas.savedCtx;delete this.annotationCanvas.savedCtx;delete this.annotationCanvas}this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(e,t){if(!this.contentVisible)return;const i=t.count;(t=this.getObject(e,t.data,t)).count=i;const a=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx,r=this._createMaskCanvas(e,t),n=r.canvas;s.save();s.setTransform(1,0,0,1,0,0);s.drawImage(n,r.offsetX,r.offsetY);this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,r.offsetX,r.offsetX+n.width,r.offsetY,r.offsetY+n.height).recordOperation(e);s.restore();r.canvasEntry&&this.canvasFactory.destroy(r.canvasEntry);this.compose();canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,a)}paintImageMaskXObjectRepeat(e,t,i,a=0,s=0,r,n){if(!this.contentVisible)return;t=this.getObject(e,t.data,t);const o=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),l=this.ctx;l.save();const d=getCurrentTransform(l);l.transform(i,a,s,r,0,0);const c=this._createMaskCanvas(e,t);l.setTransform(1,0,0,1,c.offsetX-d[4],c.offsetY-d[5]);this.dependencyTracker?.resetBBox(e);for(let t=0,o=n.length;t<o;t+=2){const o=Util.transform(d,[i,a,s,r,n[t],n[t+1]]);l.drawImage(c.canvas,o[4],o[5]);this.dependencyTracker?.recordBBox(e,this.ctx,o[4],o[4]+c.canvas.width,o[5],o[5]+c.canvas.height)}l.restore();c.canvasEntry&&this.canvasFactory.destroy(c.canvasEntry);this.compose();this.dependencyTracker?.recordOperation(e);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,o)}paintImageMaskXObjectGroup(e,t){if(!this.contentVisible)return;const i=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),a=this.ctx,s=this.current.patternFill,r=s?this.current.fillColor:a.fillStyle;this.dependencyTracker?.resetBBox(e).recordDependencies(e,ms);for(const i of t){const{data:t,width:n,height:o,transform:l}=i,d=this.canvasFactory.create(n,o),c=d.context;c.save();putBinaryImageMask(c,this.getObject(e,t,i));c.globalCompositeOperation="source-in";c.fillStyle=s?r.getPattern(c,this,getCurrentTransformInverse(a),bs,e):r;c.fillRect(0,0,n,o);c.restore();a.save();a.transform(...l);a.scale(1,-1);drawImageAtIntegerCoords(a,d.canvas,0,0,n,o,0,-1,1,1);this.canvasFactory.destroy(d);this.dependencyTracker?.recordBBox(e,a,0,n,0,o);a.restore()}this.compose();this.dependencyTracker?.recordOperation(e);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,i)}paintImageXObject(e,t){if(!this.contentVisible)return;const i=this.getObject(e,t);i?this.paintInlineImageXObject(e,i):warn("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,i,a,s){if(!this.contentVisible)return;const r=this.getObject(e,t);if(!r){warn("Dependent image isn't ready yet");return}const n=r.width,o=r.height,l=[];for(let e=0,t=s.length;e<t;e+=2)l.push({transform:[i,0,0,a,s[e],s[e+1]],x:0,y:0,w:n,h:o});this.paintInlineImageXObjectGroup(e,r,l)}applyTransferMapsToCanvas(e){if("none"!==this.current.transferMaps){e.filter=this.current.transferMaps;e.drawImage(e.canvas,0,0);e.filter="none"}else this.current.transferMapsFallback?.applyToCanvas(e);return e.canvas}applyTransferMapsToBitmap(e){const{transferMaps:t,transferMapsFallback:i}=this.current;if("none"===t&&!i)return{img:e.bitmap,canvasEntry:null};const{bitmap:a,width:s,height:r}=e,n=this.canvasFactory.create(s,r),o=n.context;o.filter=t;o.drawImage(a,0,0);o.filter="none";i?.applyToCanvas(o);return{img:n.canvas,canvasEntry:n}}paintInlineImageXObject(e,t){if(!this.contentVisible)return;const i=t.width,a=t.height,s=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),r=this.ctx;this.save(e);const{filter:n}=r;"none"!==n&&""!==n&&(r.filter="none");r.scale(1/i,-1/a);let o,l=null;if(t.bitmap){const e=this.applyTransferMapsToBitmap(t);o=e.img;l=e.canvasEntry}else{const e=this.canvasFactory.create(i,a);putBinaryImageData(e.context,t);o=this.applyTransferMapsToCanvas(e.context);l=e}const d=this._scaleImage(o,getCurrentTransformInverse(r));r.imageSmoothingEnabled=getImageSmoothingEnabled(getCurrentTransform(r),t.interpolate,this.pixelRatio);if(this.dependencyTracker){this.dependencyTracker.resetBBox(e).recordBBox(e,r,0,i,-a,0).recordDependencies(e,_s).recordOperation(e);this.imagesTracker?.record(r,i,a,this.dependencyTracker.clipBox)}drawImageAtIntegerCoords(r,d.img,0,0,d.paintWidth,d.paintHeight,0,-a,i,a);d.tmpCanvas&&this.canvasFactory.destroy(d.tmpCanvas);l&&this.canvasFactory.destroy(l);this.compose();this.restore(e);canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,s)}paintInlineImageXObjectGroup(e,t,i){if(!this.contentVisible)return;const a=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx;let r,n=null;if(t.bitmap&&!this.current.transferMapsFallback)r=t.bitmap;else if(t.bitmap)({img:r,canvasEntry:n}=this.applyTransferMapsToBitmap(t));else{const e=t.width,i=t.height,a=this.canvasFactory.create(e,i);putBinaryImageData(a.context,t);r=this.applyTransferMapsToCanvas(a.context);n=a}this.dependencyTracker?.resetBBox(e);for(const t of i){s.save();s.transform(...t.transform);s.scale(1,-1);drawImageAtIntegerCoords(s,r,t.x,t.y,t.w,t.h,0,-1,1,1);this.dependencyTracker?.recordBBox(e,s,0,1,-1,0);s.restore()}n&&this.canvasFactory.destroy(n);this.dependencyTracker?.recordOperation(e);this.compose();canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,a)}paintSolidColorImageMask(e){if(!this.contentVisible)return;const t=canvas_assertClassBrand(Hs,this,_beginKnockoutElement).call(this,this.current.fillAlpha);this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,hs).recordOperation(e);this.ctx.fillRect(0,0,1,1);this.compose();canvas_assertClassBrand(Hs,this,_endKnockoutElement).call(this,t)}markPoint(e,t){}markPointProps(e,t,i){}beginMarkedContent(e,t){this.dependencyTracker?.beginMarkedContent(e);this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t,i){this.dependencyTracker?.beginMarkedContent(e);"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(e){this.dependencyTracker?.endMarkedContent(e);this.markedContentStack.pop();this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,t,i){const a=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath();this.pendingClip||this.compose(i);const s=this.ctx;if(this.pendingClip){a||(this.pendingClip===Ts?s.clip(t,"evenodd"):s.clip(t));this.pendingClip=null;this.dependencyTracker?.bboxToClipBoxDropOperation(e).recordFutureForcedDependency("clipPath",e)}else this.dependencyTracker?.recordOperation(e);this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){const e=getCurrentTransform(this.ctx);if(0===e[1]&&0===e[2])return 1/Math.min(Math.abs(e[0]),Math.abs(e[3]));const t=Math.abs(e[0]*e[3]-e[2]*e[1]),i=Math.hypot(e[0],e[2]),a=Math.hypot(e[1],e[3]);return Math.max(i,a)/t}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:e}=this.current,{a:t,b:i,c:a,d:s}=this.ctx.getTransform();let r,n;if(0===i&&0===a){const i=Math.abs(t),a=Math.abs(s);if(i===a)if(0===e)r=n=1/i;else{const t=i*e;r=n=t<1?1/t:1}else if(0===e){r=1/i;n=1/a}else{const t=i*e,s=a*e;r=t<1?1/t:1;n=s<1?1/s:1}}else{const o=Math.abs(t*s-i*a),l=Math.hypot(t,i),d=Math.hypot(a,s);if(0===e){r=d/o;n=l/o}else{const t=e*o;r=d>t?d/t:1;n=l>t?l/t:1}}this._cachedScaleForStroking[0]=r;this._cachedScaleForStroking[1]=n}return this._cachedScaleForStroking}rescaleAndStroke(e,t){const{ctx:i,current:{lineWidth:a}}=this,[s,r]=this.getScaleForStroking();if(s===r){i.lineWidth=(a||1)*s;i.stroke(e);return}const n=$s._??($s._=new DOMMatrix),o=i.getLineDash();t&&i.save();i.scale(s,r);n.a=1/s;n.d=1/r;const l=new Path2D;l.addPath(e,n);if(o.length>0){const e=Math.max(s,r);i.setLineDash(o.map(t=>t/e));i.lineDashOffset/=e}i.lineWidth=a||1;i.stroke(l);t&&i.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}function _restoreInitialState(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null;this.ctx.restore();if(this.transparentCanvas){this.ctx=this.compositeCtx;this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.drawImage(this.transparentCanvas,0,0);this.ctx.restore();this.canvasFactory.destroy(this.transparentCanvasEntry);this.transparentCanvas=null;this.transparentCanvasEntry=null}}function _drawFilter(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){const t=this.ctx.filter;this.ctx.filter=e;this.ctx.drawImage(this.ctx.canvas,0,0);this.ctx.filter=t}}}function _createKnockoutMaskCanvas(e,t=null,i=1){const{width:a,height:s}=e,r=t??this.canvasFactory.create(a,s),n=r.context,o=(i=Math.round(255*i)/255)<1;o&&void 0===canvas_classPrivateFieldGet(Vs,this)&&canvas_classPrivateFieldSet(Vs,this,FeatureTest.isCanvasFilterSupported?new Map:"none");let l="none";o&&canvas_classPrivateFieldGet(Vs,this)instanceof Map&&(l=canvas_classPrivateFieldGet(Vs,this).getOrInsertComputed(i,()=>this.filterFactory.addKnockoutFilter(i)));if(!o||"none"!==l){if(t){n.save();n.setTransform(1,0,0,1,0,0);n.clearRect(0,0,a,s);n.restore()}n.filter=l;n.drawImage(e,0,0);n.filter="none";return r}const d=e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,a,s),c=n.createImageData(a,s),h=d.data,_=c.data,u=i>0?1/i:1e6;for(let e=3,t=h.length;e<t;e+=4)_[e]=Math.min(Math.round(h[e]*u),255);n.putImageData(c,0,0);return r}function _getOrCreatePooledEntry(e,t,i,a){let s=e?.[t]??null;if(s&&(s.canvas.width!==i||s.canvas.height!==a)){this.canvasFactory.destroy(s);s=null}if(!s){s=this.canvasFactory.create(i,a);e&&(e[t]=s);return s}const r=s.context;r.save();r.setTransform(1,0,0,1,0,0);r.clearRect(0,0,i,a);r.restore();return s}function _compositeKnockoutSurface(e,t,i={}){const{backdropCanvas:a=null,destTransform:s=[1,0,0,1,0,0],backdropOffset:r=[0,0],reuseMaskEntry:n=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:d="none",knockoutAlpha:c=1}=i,{width:h,height:_}=t,u=canvas_assertClassBrand(Hs,this,_createKnockoutMaskCanvas).call(this,t,n,c),p=e.globalCompositeOperation;e.save();e.setTransform(...s);e.globalAlpha=1;FeatureTest.isCanvasFilterSupported&&(e.filter="none");e.globalCompositeOperation="destination-out";e.drawImage(u.canvas,0,0);if(a){const[t,i]=r,s=canvas_assertClassBrand(Hs,this,_getOrCreatePooledEntry).call(this,o,"knockoutBackdropEntry",h,_),n=s.context;n.drawImage(a,t,i,h,_,0,0,h,_);n.globalCompositeOperation="destination-in";n.drawImage(u.canvas,0,0);n.globalCompositeOperation="source-over";e.globalCompositeOperation="destination-over";e.drawImage(s.canvas,0,0);o||this.canvasFactory.destroy(s)}e.globalCompositeOperation=p;e.globalAlpha=l;FeatureTest.isCanvasFilterSupported&&(e.filter=d??"none");e.drawImage(t,0,0);e.restore();n||this.canvasFactory.destroy(u)}function _beginKnockoutElement(e=1){var t;if(0===canvas_classPrivateFieldGet(Ds,this)||canvas_classPrivateFieldGet(Ls,this)>0||!this.contentVisible)return!1;canvas_classPrivateFieldSet(Ls,this,(t=canvas_classPrivateFieldGet(Ls,this),t++,t));canvas_classPrivateFieldSet(js,this,e);const i=canvas_classPrivateFieldGet(zs,this).at(-1),{canvas:a}=this.ctx,s=canvas_assertClassBrand(Hs,this,_getOrCreatePooledEntry).call(this,i,"knockoutTempEntry",a.width,a.height);canvas_classPrivateFieldSet(Rs,this,s);const r=s.context;r.save();r.setTransform(this.ctx.getTransform());copyCtxState(this.ctx,r);canvas_classPrivateFieldSet(Ws,this,r.globalCompositeOperation);r.globalCompositeOperation="source-over";mirrorContextOperations(r,this.ctx);canvas_classPrivateFieldSet(Us,this,i);canvas_classPrivateFieldSet(Os,this,this.ctx);canvas_classPrivateFieldSet(Ns,this,this.suspendedCtx);this.ctx=r;this.inSMaskMode&&(this.suspendedCtx=r);return!0}function _endKnockoutElement(e){if(!e)return;const t=canvas_classPrivateFieldGet(Rs,this),i=canvas_classPrivateFieldGet(Os,this),a=canvas_classPrivateFieldGet(Ns,this),s=t.context;canvas_classPrivateFieldSet(Rs,this,null);canvas_classPrivateFieldSet(Os,this,null);canvas_classPrivateFieldSet(Ns,this,null);this.inSMaskMode&&this.suspendedCtx===s&&this.ctx!==s&&this.endSMaskMode();this.inSMaskMode&&(this.suspendedCtx=a);this.ctx._removeMirroring();this.ctx.globalCompositeOperation=canvas_classPrivateFieldGet(Ws,this);canvas_classPrivateFieldSet(Ws,this,null);copyCtxState(this.ctx,i);this.ctx=i;const r=canvas_classPrivateFieldGet(Us,this);canvas_classPrivateFieldSet(Us,this,null);const n=canvas_classPrivateFieldGet(js,this);canvas_classPrivateFieldSet(js,this,1);try{canvas_assertClassBrand(Hs,this,_compositeKnockoutSurface).call(this,a??i,t.canvas,{backdropCanvas:r?.backdropCtx?.canvas??null,backdropOffset:r?.backdropCtx?[r.offsetX,r.offsetY]:[0,0],reuseMaskEntry:r?.knockoutMaskEntry??null,poolMeta:r,knockoutAlpha:n})}finally{var o;s.restore();canvas_classPrivateFieldSet(Ls,this,(o=canvas_classPrivateFieldGet(Ls,this),o--,o));r||this.canvasFactory.destroy(t)}}function _getScaledPath(e,t,i){const a=new Path2D;a.addPath(e,new DOMMatrix(i).invertSelf().multiplySelf(t));return a}function _getTextPattern(e,t,i){const a=this.ctx;a.save();const s=e.getPattern(a,this,getCurrentTransformInverse(a),t,i),r=getCurrentTransform(a);a.restore();return[s,r]}function _transferColor(e){return this.current.transferMapsFallback?.applyToColor(e)??e}function _convertGroupToGray(e){const{canvas:t}=e,{width:i,height:a}=t;if(FeatureTest.isCanvasFilterSupported){e.save();e.setTransform(1,0,0,1,0,0);e.filter="grayscale(1)";e.globalAlpha=1;e.globalCompositeOperation="copy";e.drawImage(t,0,0);e.restore();return}const s=e.getImageData(0,0,i,a),{data:r}=s;for(let e=0,t=r.length;e<t;e+=4){const t=.2126*r[e]+.7152*r[e+1]+.0722*r[e+2]+.5|0;r[e]=r[e+1]=r[e+2]=t}e.putImageData(s,0,0)}function _destroyKnockoutPools(e){if(e){if(e.knockoutMaskEntry){this.canvasFactory.destroy(e.knockoutMaskEntry);e.knockoutMaskEntry=null}if(e.knockoutTempEntry){this.canvasFactory.destroy(e.knockoutTempEntry);e.knockoutTempEntry=null}if(e.knockoutBackdropEntry){this.canvasFactory.destroy(e.knockoutBackdropEntry);e.knockoutBackdropEntry=null}}}var $s={_:null},Xs={_:new WeakMap};for(const e in T)void 0!==CanvasGraphics.prototype[e]&&(CanvasGraphics.prototype[T[e]]=CanvasGraphics.prototype[e]);class DOMCanvasFactory extends BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t});this._document=e}_createCanvas(e,t){const i=this._document.createElement("canvas");i.width=e;i.height=t;return i}}function dom_filter_factory_classPrivateFieldInitSpec(e,t,i){dom_filter_factory_checkPrivateRedeclaration(e,t),t.set(e,i)}function dom_filter_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function dom_filter_factory_classPrivateGetter(e,t,i){return i(dom_filter_factory_assertClassBrand(e,t))}function dom_filter_factory_classPrivateFieldGet(e,t){return e.get(dom_filter_factory_assertClassBrand(e,t))}function dom_filter_factory_classPrivateFieldSet(e,t,i){return e.set(dom_filter_factory_assertClassBrand(e,t),i),i}function dom_filter_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Ks=new WeakMap,qs=new WeakMap,Ys=new WeakMap,Zs=new WeakMap,Qs=new WeakMap,Js=new WeakMap,er=new WeakMap,tr=new WeakSet;class DOMFilterFactory extends BaseFilterFactory{constructor({docId:e,ownerDocument:t=globalThis.document}){super();!function dom_filter_factory_classPrivateMethodInitSpec(e,t){dom_filter_factory_checkPrivateRedeclaration(e,t),t.add(e)}(this,tr);dom_filter_factory_classPrivateFieldInitSpec(this,Ks,void 0);dom_filter_factory_classPrivateFieldInitSpec(this,qs,void 0);dom_filter_factory_classPrivateFieldInitSpec(this,Ys,void 0);dom_filter_factory_classPrivateFieldInitSpec(this,Zs,void 0);dom_filter_factory_classPrivateFieldInitSpec(this,Qs,void 0);dom_filter_factory_classPrivateFieldInitSpec(this,Js,void 0);dom_filter_factory_classPrivateFieldInitSpec(this,er,0);dom_filter_factory_classPrivateFieldSet(Zs,this,e);dom_filter_factory_classPrivateFieldSet(Qs,this,t)}addFilter(e){var t,i;if(!e)return"none";let a=dom_filter_factory_classPrivateGetter(tr,this,_get_cache).get(e);if(a)return a;const[s,r,n]=dom_filter_factory_assertClassBrand(tr,this,_createTables).call(this,e),o=1===e.length?s:`${s}${r}${n}`;a=dom_filter_factory_classPrivateGetter(tr,this,_get_cache).get(o);if(a){dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(e,a);return a}const l=`g_${dom_filter_factory_classPrivateFieldGet(Zs,this)}_transfer_map_${dom_filter_factory_classPrivateFieldSet(er,this,(t=dom_filter_factory_classPrivateFieldGet(er,this),i=t++,t)),i}`,d=dom_filter_factory_assertClassBrand(tr,this,_createUrl).call(this,l);dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(e,d);dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(o,d);const c=dom_filter_factory_assertClassBrand(tr,this,_createFilter).call(this,l);dom_filter_factory_assertClassBrand(tr,this,_addTransferMapConversion).call(this,s,r,n,c);return d}addHCMFilter(e,t){const i=`${e}-${t}`,a="base";let s=dom_filter_factory_classPrivateGetter(tr,this,_get_hcmCache).get(a);if(s?.key===i)return s.url;if(s){s.filter?.remove();s.key=i;s.url="none";s.filter=null}else{s={key:i,url:"none",filter:null};dom_filter_factory_classPrivateGetter(tr,this,_get_hcmCache).set(a,s)}if(!e||!t)return s.url;const r=dom_filter_factory_assertClassBrand(tr,this,_getRGB).call(this,e);e=Util.makeHexColor(...r);const n=dom_filter_factory_assertClassBrand(tr,this,_getRGB).call(this,t);t=Util.makeHexColor(...n);dom_filter_factory_assertClassBrand(tr,this,_resetDefsColor).call(this);if("#000000"===e&&"#ffffff"===t||e===t)return s.url;const o=Array.from({length:256},(e,t)=>computeLuminance(t/255)).join(","),l=`g_${dom_filter_factory_classPrivateFieldGet(Zs,this)}_hcm_filter`,d=s.filter=dom_filter_factory_assertClassBrand(tr,this,_createFilter).call(this,l);dom_filter_factory_assertClassBrand(tr,this,_addTransferMapConversion).call(this,o,o,o,d);dom_filter_factory_assertClassBrand(tr,this,_addGrayConversion).call(this,d);const getSteps=(e,t)=>{const i=r[e]/255,a=n[e]/255,s=new Array(t+1);for(let e=0;e<=t;e++)s[e]=i+e/t*(a-i);return s.join(",")};dom_filter_factory_assertClassBrand(tr,this,_addTransferMapConversion).call(this,getSteps(0,5),getSteps(1,5),getSteps(2,5),d);s.url=dom_filter_factory_assertClassBrand(tr,this,_createUrl).call(this,l);return s.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter("selection",e,t,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){const t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return"none"!==t&&FeatureTest.platform.isFirefox?{"backdrop-filter":t,"background-color":"transparent"}:null}addAlphaFilter(e){var t,i;let a=dom_filter_factory_classPrivateGetter(tr,this,_get_cache).get(e);if(a)return a;const[s]=dom_filter_factory_assertClassBrand(tr,this,_createTables).call(this,[e]),r=`alpha_${s}`;a=dom_filter_factory_classPrivateGetter(tr,this,_get_cache).get(r);if(a){dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(e,a);return a}const n=`g_${dom_filter_factory_classPrivateFieldGet(Zs,this)}_alpha_map_${dom_filter_factory_classPrivateFieldSet(er,this,(t=dom_filter_factory_classPrivateFieldGet(er,this),i=t++,t)),i}`,o=dom_filter_factory_assertClassBrand(tr,this,_createUrl).call(this,n);dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(e,o);dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(r,o);const l=dom_filter_factory_assertClassBrand(tr,this,_createFilter).call(this,n);dom_filter_factory_assertClassBrand(tr,this,_addTransferMapAlphaConversion).call(this,s,l);return o}addLuminosityFilter(e){var t,i;let a,s,r=dom_filter_factory_classPrivateGetter(tr,this,_get_cache).get(e||"luminosity");if(r)return r;if(e){[a]=dom_filter_factory_assertClassBrand(tr,this,_createTables).call(this,[e]);s=`luminosity_${a}`}else s="luminosity";r=dom_filter_factory_classPrivateGetter(tr,this,_get_cache).get(s);if(r){dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(e,r);return r}const n=`g_${dom_filter_factory_classPrivateFieldGet(Zs,this)}_luminosity_map_${dom_filter_factory_classPrivateFieldSet(er,this,(t=dom_filter_factory_classPrivateFieldGet(er,this),i=t++,t)),i}`,o=dom_filter_factory_assertClassBrand(tr,this,_createUrl).call(this,n);dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(e,o);dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(s,o);const l=dom_filter_factory_assertClassBrand(tr,this,_createFilter).call(this,n);dom_filter_factory_assertClassBrand(tr,this,_addLuminosityConversion).call(this,l);e&&dom_filter_factory_assertClassBrand(tr,this,_addTransferMapAlphaConversion).call(this,a,l);return o}addKnockoutFilter(e=0){var t,i;const a=e>0?Math.min(1/e,1e6):1e6,s=`knockout_${a}`,n=dom_filter_factory_classPrivateGetter(tr,this,_get_cache).get(s);if(n)return n;const o=`g_${dom_filter_factory_classPrivateFieldGet(Zs,this)}_knockout_filter_${dom_filter_factory_classPrivateFieldSet(er,this,(t=dom_filter_factory_classPrivateFieldGet(er,this),i=t++,t)),i}`,l=dom_filter_factory_assertClassBrand(tr,this,_createUrl).call(this,o);dom_filter_factory_classPrivateGetter(tr,this,_get_cache).set(s,l);const d=dom_filter_factory_assertClassBrand(tr,this,_createFilter).call(this,o),c=dom_filter_factory_classPrivateFieldGet(Qs,this).createElementNS(r,"feComponentTransfer");d.append(c);const h=dom_filter_factory_classPrivateFieldGet(Qs,this).createElementNS(r,"feFuncA");h.setAttribute("type","linear");h.setAttribute("slope",`${a}`);h.setAttribute("intercept","0");c.append(h);return l}addHighlightHCMFilter(e,t,i,a,s){const r=`${t}-${i}-${a}-${s}`;let n=dom_filter_factory_classPrivateGetter(tr,this,_get_hcmCache).get(e);if(n?.key===r)return n.url;if(n){n.filter?.remove();n.key=r;n.url="none";n.filter=null}else{n={key:r,url:"none",filter:null};dom_filter_factory_classPrivateGetter(tr,this,_get_hcmCache).set(e,n)}if(!t||!i)return n.url;const[o,l]=[t,i].map(dom_filter_factory_assertClassBrand(tr,this,_getRGB).bind(this));let d=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[h,_]=[a,s].map(dom_filter_factory_assertClassBrand(tr,this,_getOpaqueTextColor).bind(this));c<d&&([d,c,h,_]=[c,d,_,h]);dom_filter_factory_assertClassBrand(tr,this,_resetDefsColor).call(this);const getSteps=(e,t,i)=>{const a=new Array(256),s=(c-d)/i,r=e/255,n=(t-e)/(255*i);let o=0;for(let e=0;e<=i;e++){const t=Math.round(d+e*s),i=r+e*n;for(let e=o;e<=t;e++)a[e]=i;o=t+1}for(let e=o;e<256;e++)a[e]=a[o-1];return a.join(",")},u=`g_${dom_filter_factory_classPrivateFieldGet(Zs,this)}_hcm_${e}_filter`,p=n.filter=dom_filter_factory_assertClassBrand(tr,this,_createFilter).call(this,u);dom_filter_factory_assertClassBrand(tr,this,_addGrayConversion).call(this,p);dom_filter_factory_assertClassBrand(tr,this,_addTransferMapConversion).call(this,getSteps(h[0],_[0],5),getSteps(h[1],_[1],5),getSteps(h[2],_[2],5),p);n.url=dom_filter_factory_assertClassBrand(tr,this,_createUrl).call(this,u);return n.url}destroy(e=!1){if(!e||!dom_filter_factory_classPrivateFieldGet(Js,this)?.size){dom_filter_factory_classPrivateFieldGet(Ys,this)?.parentNode.parentNode.remove();dom_filter_factory_classPrivateFieldSet(Ys,this,null);dom_filter_factory_classPrivateFieldGet(qs,this)?.clear();dom_filter_factory_classPrivateFieldSet(qs,this,null);dom_filter_factory_classPrivateFieldGet(Js,this)?.clear();dom_filter_factory_classPrivateFieldSet(Js,this,null);dom_filter_factory_classPrivateFieldSet(er,this,0)}}}function _get_cache(e){return dom_filter_factory_classPrivateFieldGet(qs,e)||dom_filter_factory_classPrivateFieldSet(qs,e,new Map)}function _get_hcmCache(e){return dom_filter_factory_classPrivateFieldGet(Js,e)||dom_filter_factory_classPrivateFieldSet(Js,e,new Map)}function _get_defs(e){if(!dom_filter_factory_classPrivateFieldGet(Ys,e)){const t=dom_filter_factory_classPrivateFieldGet(Qs,e).createElement("div"),{style:i}=t;i.colorScheme="only light";i.visibility="hidden";i.contain="strict";i.width=i.height=0;i.position="absolute";i.top=i.left=0;i.zIndex=-1;const a=dom_filter_factory_classPrivateFieldGet(Qs,e).createElementNS(r,"svg");a.setAttribute("width",0);a.setAttribute("height",0);dom_filter_factory_classPrivateFieldSet(Ys,e,dom_filter_factory_classPrivateFieldGet(Qs,e).createElementNS(r,"defs"));t.append(a);a.append(dom_filter_factory_classPrivateFieldGet(Ys,e));dom_filter_factory_classPrivateFieldGet(Qs,e).body.append(t)}return dom_filter_factory_classPrivateFieldGet(Ys,e)}function _createTables(e){const toTable=e=>e&&Array.from(e,e=>e/255).join(",");if(1===e.length){const t=toTable(e[0]);return[t,t,t]}const[t,i,a]=e;return[toTable(t),toTable(i),toTable(a)]}function _createUrl(e){if(void 0===dom_filter_factory_classPrivateFieldGet(Ks,this)){dom_filter_factory_classPrivateFieldSet(Ks,this,"");const e=dom_filter_factory_classPrivateFieldGet(Qs,this).URL;e!==dom_filter_factory_classPrivateFieldGet(Qs,this).baseURI&&(isDataScheme(e)?warn('#createUrl: ignore "data:"-URL for performance reasons.'):dom_filter_factory_classPrivateFieldSet(Ks,this,updateUrlHash(e,"")))}return`url(${dom_filter_factory_classPrivateFieldGet(Ks,this)}#${e})`}function _addLuminosityConversion(e){const t=dom_filter_factory_classPrivateFieldGet(Qs,this).createElementNS(r,"feColorMatrix");t.setAttribute("type","matrix");t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0");e.append(t)}function _addGrayConversion(e){const t=dom_filter_factory_classPrivateFieldGet(Qs,this).createElementNS(r,"feColorMatrix");t.setAttribute("type","matrix");t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0");e.append(t)}function _createFilter(e){const t=dom_filter_factory_classPrivateFieldGet(Qs,this).createElementNS(r,"filter");t.setAttribute("color-interpolation-filters","sRGB");t.setAttribute("id",e);dom_filter_factory_classPrivateGetter(tr,this,_get_defs).append(t);return t}function _appendFeFunc(e,t,i){if(!i)return;const a=dom_filter_factory_classPrivateFieldGet(Qs,this).createElementNS(r,t);a.setAttribute("type","discrete");a.setAttribute("tableValues",i);e.append(a)}function _addTransferMapConversion(e,t,i,a){const s=dom_filter_factory_classPrivateFieldGet(Qs,this).createElementNS(r,"feComponentTransfer");a.append(s);dom_filter_factory_assertClassBrand(tr,this,_appendFeFunc).call(this,s,"feFuncR",e);dom_filter_factory_assertClassBrand(tr,this,_appendFeFunc).call(this,s,"feFuncG",t);dom_filter_factory_assertClassBrand(tr,this,_appendFeFunc).call(this,s,"feFuncB",i)}function _addTransferMapAlphaConversion(e,t){const i=dom_filter_factory_classPrivateFieldGet(Qs,this).createElementNS(r,"feComponentTransfer");t.append(i);dom_filter_factory_assertClassBrand(tr,this,_appendFeFunc).call(this,i,"feFuncA",e)}function _getRGB(e){dom_filter_factory_classPrivateGetter(tr,this,_get_defs).style.color="CanvasText";dom_filter_factory_classPrivateGetter(tr,this,_get_defs).style.backgroundColor=e;return getRGB(getComputedStyle(dom_filter_factory_classPrivateGetter(tr,this,_get_defs)).getPropertyValue("background-color"))}function _getRGBA(e){dom_filter_factory_classPrivateGetter(tr,this,_get_defs).style.color="CanvasText";dom_filter_factory_classPrivateGetter(tr,this,_get_defs).style.backgroundColor=e;return getRGBA(getComputedStyle(dom_filter_factory_classPrivateGetter(tr,this,_get_defs)).getPropertyValue("background-color"))}function _resetDefsColor(){dom_filter_factory_classPrivateGetter(tr,this,_get_defs).style.color="";dom_filter_factory_classPrivateGetter(tr,this,_get_defs).style.backgroundColor=""}function _getOpaqueTextColor(e){const[t,i,a,s]=dom_filter_factory_assertClassBrand(tr,this,_getRGBA).call(this,e);if(1===s)return[t,i,a];const[r,n,o]=dom_filter_factory_assertClassBrand(tr,this,_getRGB).call(this,"Canvas");return[blend(t,r,s),blend(i,n,s),blend(a,o,s)]}function blend(e,t,i){return Math.round(i*e+(1-i)*t)}const ir=/\p{Cc}/u;function serializeFontFamily(e){if(function isCSSString(e){const t=e[0];if(e.length<2||'"'!==t&&"'"!==t||e.at(-1)!==t)return!1;const i=e.length-1;for(let a=1;a<i;a++){const s=e[a];if(s===t||ir.test(s))return!1;if("\\"===s&&(++a>=i||ir.test(e[a])))return!1}return!0}(e))return e;return`"${e.replaceAll(/["\\\p{Cc}]/gu,e=>'"'===e||"\\"===e?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}function font_loader_classPrivateFieldInitSpec(e,t,i){font_loader_checkPrivateRedeclaration(e,t),t.set(e,i)}function font_loader_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function font_loader_classPrivateFieldSet(e,t,i){return e.set(font_loader_assertClassBrand(e,t),i),i}function font_loader_classPrivateFieldGet(e,t){return e.get(font_loader_assertClassBrand(e,t))}function font_loader_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ar=new WeakMap,sr=new WeakMap,rr=new WeakMap,nr=new WeakSet;class FontLoader{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){!function font_loader_classPrivateMethodInitSpec(e,t){font_loader_checkPrivateRedeclaration(e,t),t.add(e)}(this,nr);font_loader_classPrivateFieldInitSpec(this,ar,new Set);font_loader_classPrivateFieldInitSpec(this,sr,new Set);font_loader_classPrivateFieldInitSpec(this,rr,null);this._document=e;this.styleElement=null;this.loadingRequests=[];this.loadTestFontId=0}addNativeFontFace(e){font_loader_classPrivateFieldGet(ar,this).add(e);this._document.fonts.add(e)}removeNativeFontFace(e){font_loader_classPrivateFieldGet(ar,this).delete(e);this._document.fonts.delete(e)}insertRule(e){const t=font_loader_assertClassBrand(nr,this,_getStyleSheet).call(this);t.insertRule(e,t.cssRules.length)}clear(){for(const e of font_loader_classPrivateFieldGet(ar,this))this._document.fonts.delete(e);font_loader_classPrivateFieldGet(ar,this).clear();font_loader_classPrivateFieldGet(sr,this).clear();if(font_loader_classPrivateFieldGet(rr,this)){const{adoptedStyleSheets:e}=this._document;e?.includes(font_loader_classPrivateFieldGet(rr,this))&&(this._document.adoptedStyleSheets=e.filter(e=>e!==font_loader_classPrivateFieldGet(rr,this)));font_loader_classPrivateFieldSet(rr,this,null)}this.styleElement?.remove();this.styleElement=null}async loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:i}){if(e&&!font_loader_classPrivateFieldGet(sr,this).has(e.loadedName)){assert(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set.");if(this.isFontLoadingAPISupported){const{loadedName:t,src:a,style:s}=e,r=new FontFace(t,a,s);this.addNativeFontFace(r);try{await r.load();font_loader_classPrivateFieldGet(sr,this).add(t);i?.(e)}catch{warn(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`);this.removeNativeFontFace(r)}return}unreachable("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;e.attached=!0;if(e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(i){warn(`Failed to load font '${t.family}': '${i}'.`);e.disableFontFace=!0;throw i}}return}const t=e.createFontFaceRule();if(t){this.insertRule(t);if(this.isSyncFontLoadingSupported)return;await font_loader_assertClassBrand(nr,this,_testFontLoaded).call(this,e)}}get isFontLoadingAPISupported(){return shadow(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return shadow(this,"isSyncFontLoadingSupported",t||FeatureTest.platform.isFirefox)}}function _getStyleSheet(){if(font_loader_classPrivateFieldGet(rr,this))return font_loader_classPrivateFieldGet(rr,this);const e=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&e){const{adoptedStyleSheets:t}=this._document;if(t){const i=new e;t.push(i);return font_loader_classPrivateFieldSet(rr,this,i)}}if(!this.styleElement){this.styleElement=this._document.createElement("style");this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)}return font_loader_classPrivateFieldSet(rr,this,this.styleElement.sheet)}function _testFontLoaded(e){const{loadingRequests:t}=this,{promise:i,resolve:a}=Promise.withResolvers(),s={done:!1,resolve:a};t.push(s);this._loadTestFont??=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");function int32(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function spliceString(e,t,i,a){return e.substring(0,t)+a+e.substring(t+i)}let r,n;const o=this._document.createElement("canvas");o.width=1;o.height=1;const l=o.getContext("2d");let d=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=spliceString(h,976,c.length,c);const _=1482184792;let u=int32(h,16);for(r=0,n=c.length-3;r<n;r+=4)u=u-_+int32(c,r)|0;r<c.length&&(u=u-_+int32(c+"XXX",r)|0);h=spliceString(h,16,4,function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}(u));const p=`@font-face {font-family:"${c}";src:${`url(data:font/opentype;base64,${btoa(h)});`}}`;this.insertRule(p);const g=this._document.createElement("div");g.style.visibility="hidden";g.style.width=g.style.height="10px";g.style.position="absolute";g.style.top=g.style.left="0px";for(const t of[e.loadedName,c]){const e=this._document.createElement("span");e.textContent="Hi";e.style.fontFamily=t;g.append(e)}this._document.body.append(g);!function isFontReady(e,t){if(++d>30){warn("Load test font never loaded.");t();return}l.font="30px "+e;l.fillText(".",0,20);l.getImageData(0,0,1,1).data[3]>0?t():setTimeout(isFontReady.bind(null,e,t))}(c,()=>{g.remove();!function completeRequest(){assert(!s.done,"completeRequest() cannot be called twice.");s.done=!0;for(;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.resolve,0)}}()});return i}var or=new WeakMap,lr=new WeakMap;class FontFaceObject{constructor(e,t=null,i,a){font_loader_classPrivateFieldInitSpec(this,or,new Map);font_loader_classPrivateFieldInitSpec(this,lr,void 0);font_loader_classPrivateFieldSet(lr,this,e);this._inspectFont=t;i&&(this.charProcOperatorList=i);a&&Object.assign(this,a)}createNativeFontFace(){const{data:e}=this;if(!e||this.disableFontFace)return null;let t;if(this.cssFontInfo){const i={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(i.style=`oblique ${this.cssFontInfo.italicAngle}deg`);t=new FontFace(serializeFontFamily(this.cssFontInfo.fontFamily),e,i)}else t=new FontFace(this.loadedName,e,{});this._inspectFont?.(this);return t}createFontFaceRule(){const{data:e}=this;if(!e||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${e.toBase64()});`;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`);i=`@font-face {font-family:${serializeFontFamily(this.cssFontInfo.fontFamily)};${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;this._inspectFont?.(this,t);return i}getPathGenerator(e,t){let i=font_loader_classPrivateFieldGet(or,this).get(t);if(i)return i;const a=`${this.loadedName}_path_${t}`;let s;try{s=e.get(a)}catch(e){warn(`getPathGenerator - ignoring character: "${e}".`)}i=makePathFromDrawOPS(s?.path);this.fontExtraProperties||e.delete(a);font_loader_classPrivateFieldGet(or,this).set(t,i);return i}get black(){return font_loader_classPrivateFieldGet(lr,this).black}get bold(){return font_loader_classPrivateFieldGet(lr,this).bold}get disableFontFace(){return font_loader_classPrivateFieldGet(lr,this).disableFontFace}set disableFontFace(e){shadow(this,"disableFontFace",!!e)}get fontExtraProperties(){return font_loader_classPrivateFieldGet(lr,this).fontExtraProperties}get isInvalidPDFjsFont(){return font_loader_classPrivateFieldGet(lr,this).isInvalidPDFjsFont}get isType3Font(){return font_loader_classPrivateFieldGet(lr,this).isType3Font}get italic(){return font_loader_classPrivateFieldGet(lr,this).italic}get missingFile(){return font_loader_classPrivateFieldGet(lr,this).missingFile}get remeasure(){return font_loader_classPrivateFieldGet(lr,this).remeasure}get vertical(){return font_loader_classPrivateFieldGet(lr,this).vertical}get bbox(){return font_loader_classPrivateFieldGet(lr,this).bbox}get fontMatrix(){return font_loader_classPrivateFieldGet(lr,this).fontMatrix}get fallbackName(){return font_loader_classPrivateFieldGet(lr,this).fallbackName}get loadedName(){return font_loader_classPrivateFieldGet(lr,this).loadedName}get mimetype(){return this.missingFile?null:"font/opentype"}get data(){return font_loader_classPrivateFieldGet(lr,this).data}clearData(){font_loader_classPrivateFieldGet(lr,this).clearData()}get cssFontInfo(){return font_loader_classPrivateFieldGet(lr,this).cssFontInfo}get systemFontInfo(){return font_loader_classPrivateFieldGet(lr,this).systemFontInfo}}function base_pdf_stream_defineProperty(e,t,i){return(t=function base_pdf_stream_toPropertyKey(e){var t=function base_pdf_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function base_pdf_stream_classPrivateFieldInitSpec(e,t,i){(function base_pdf_stream_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function base_pdf_stream_classPrivateFieldGet(e,t){return e.get(base_pdf_stream_assertClassBrand(e,t))}function base_pdf_stream_classPrivateFieldSet(e,t,i){return e.set(base_pdf_stream_assertClassBrand(e,t),i),i}function base_pdf_stream_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var dr=new WeakMap,cr=new WeakMap;class BasePDFStream{constructor(e,t,i){base_pdf_stream_classPrivateFieldInitSpec(this,dr,null);base_pdf_stream_classPrivateFieldInitSpec(this,cr,null);base_pdf_stream_defineProperty(this,"_fullReader",null);base_pdf_stream_defineProperty(this,"_rangeReaders",new Set);base_pdf_stream_defineProperty(this,"_source",null);this._source=e;base_pdf_stream_classPrivateFieldSet(dr,this,t);base_pdf_stream_classPrivateFieldSet(cr,this,i)}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){assert(!this._fullReader,"BasePDFStream.getFullReader can only be called once.");return this._fullReader=new(base_pdf_stream_classPrivateFieldGet(dr,this))(this)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=new(base_pdf_stream_classPrivateFieldGet(cr,this))(this,e,t);this._rangeReaders.add(i);return i}cancelAllRequests(e){this._fullReader?.cancel(e);for(const t of new Set(this._rangeReaders))t.cancel(e)}}class BasePDFStreamReader{constructor(e){base_pdf_stream_defineProperty(this,"onProgress",null);base_pdf_stream_defineProperty(this,"_contentLength",0);base_pdf_stream_defineProperty(this,"_filename",null);base_pdf_stream_defineProperty(this,"_headersCapability",Promise.withResolvers());base_pdf_stream_defineProperty(this,"_isRangeSupported",!1);base_pdf_stream_defineProperty(this,"_isStreamingSupported",!1);base_pdf_stream_defineProperty(this,"_loaded",0);base_pdf_stream_defineProperty(this,"_stream",null);this._stream=e}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){unreachable("Abstract method `read` called")}cancel(e){unreachable("Abstract method `cancel` called")}}class BasePDFStreamRangeReader{constructor(e,t,i){base_pdf_stream_defineProperty(this,"_stream",null);this._stream=e}async read(){unreachable("Abstract method `read` called")}cancel(e){unreachable("Abstract method `cancel` called")}}function createHeaders(e,t){const i=new Headers;if(!e||!t||"object"!=typeof t)return i;for(const e in t){const a=t[e];void 0!==a&&i.append(e,a)}return i}function getResponseOrigin(e){return URL.parse(e)?.origin??null}function validateRangeRequestCapabilities({responseHeaders:e,isHttp:t,rangeChunkSize:i,disableRange:a}){const s={contentLength:0,isRangeSupported:!1},r=parseInt(e.get("Content-Length"),10);if(!Number.isInteger(r))return s;s.contentLength=r;if(r<=2*i)return s;if(a||!t||"bytes"!==e.get("Accept-Ranges"))return s;"identity"===(e.get("Content-Encoding")||"identity")&&(s.isRangeSupported=!0);return s}function extractFilenameFromHeader(e){const t=e.get("Content-Disposition");if(t){let e=function getFilenameFromContentDispositionHeader(e){let t=!0,i=toParamRegExp("filename\\*","i").exec(e);if(i){i=i[1];let e=rfc2616unquote(i);e=unescape(e);e=rfc5987decode(e);e=rfc2047decode(e);return fixupEncoding(e)}i=function rfc2231getparam(e){const t=[];let i;const a=toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=a.exec(e));){let[,e,a,s]=i;e=parseInt(e,10);if(e in t){if(0===e)break}else t[e]=[a,s]}const s=[];for(let e=0;e<t.length&&e in t;++e){let[i,a]=t[e];a=rfc2616unquote(a);if(i){a=unescape(a);0===e&&(a=rfc5987decode(a))}s.push(a)}return s.join("")}(e);if(i)return fixupEncoding(rfc2047decode(i));i=toParamRegExp("filename","i").exec(e);if(i){i=i[1];let e=rfc2616unquote(i);e=rfc2047decode(e);return fixupEncoding(e)}function toParamRegExp(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function textdecode(e,i){if(e){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const a=new TextDecoder(e,{fatal:!0}),s=stringToBytes(i);i=a.decode(s);t=!1}catch{}}return i}function fixupEncoding(e){if(t&&/[\x80-\xff]/.test(e)){e=textdecode("utf-8",e);t&&(e=textdecode("iso-8859-1",e))}return e}function rfc2616unquote(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const i=t[e].indexOf('"');if(-1!==i){t[e]=t[e].slice(0,i);t.length=e+1}t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function rfc5987decode(e){const t=e.indexOf("'");return-1===t?e:textdecode(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function rfc2047decode(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(e,t,i,a){if("q"===i||"Q"===i)return textdecode(t,a=a.replaceAll("_"," ").replaceAll(/=([0-9a-f]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))));try{a=atob(a)}catch{}return textdecode(t,a)})}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(isPdfFile(e))return e}return null}function createResponseError(e,t){return new ResponseException(`Unexpected server response (${e}) while retrieving PDF "${t.href}".`,e,404===e||0===e&&"file:"===t.protocol)}function ensureResponseOrigin(e,t){if(e!==t)throw new Error(`Expected range response-origin "${e}" to match "${t}".`)}function fetch_stream_defineProperty(e,t,i){return(t=function fetch_stream_toPropertyKey(e){var t=function fetch_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function fetchUrl(e,t,i,a){return fetch(e,{method:"GET",headers:t,signal:a.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function ensureResponseStatus(e,t){if(200!==e&&206!==e)throw createResponseError(e,t)}function getArrayBuffer(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;throw new Error(`getArrayBuffer - unexpected data: ${e}`)}class PDFFetchStream extends BasePDFStream{constructor(e){super(e,PDFFetchStreamReader,PDFFetchStreamRangeReader);fetch_stream_defineProperty(this,"_responseOrigin",null);const{httpHeaders:t,url:i}=e;assert(/https?:|blob:|capacitor:/.test(i.protocol),"PDFFetchStream only supports http(s)://, blob:, and capacitor:// URLs.");this.headers=createHeaders(!0,t)}}class PDFFetchStreamReader extends BasePDFStreamReader{constructor(e){super(e);fetch_stream_defineProperty(this,"_abortController",new AbortController);fetch_stream_defineProperty(this,"_reader",null);const{disableRange:t,disableStream:i,rangeChunkSize:a,url:s,withCredentials:r}=e._source;this._isStreamingSupported=!i;const n=new Headers(e.headers);fetchUrl(s,n,r,this._abortController).then(i=>{e._responseOrigin=getResponseOrigin(i.url);ensureResponseStatus(i.status,s);this._reader=i.body.getReader();const r=i.headers,{contentLength:n,isRangeSupported:o}=validateRangeRequestCapabilities({responseHeaders:r,isHttp:!0,rangeChunkSize:a,disableRange:t});this._contentLength=n;this._isRangeSupported=o;this._filename=extractFilenameFromHeader(r);!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new AbortException("Streaming is disabled."));this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};this._loaded+=e.byteLength;this._callOnProgress();return{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e).catch(()=>{});this._abortController.abort()}}class PDFFetchStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);fetch_stream_defineProperty(this,"_abortController",new AbortController);fetch_stream_defineProperty(this,"_readCapability",Promise.withResolvers());fetch_stream_defineProperty(this,"_reader",null);const{url:a,withCredentials:s}=e._source,r=new Headers(e.headers);r.append("Range",`bytes=${t}-${i-1}`);fetchUrl(a,r,s,this._abortController).then(t=>{ensureResponseOrigin(getResponseOrigin(t.url),e._responseOrigin);ensureResponseStatus(t.status,a);this._reader=t.body.getReader();this._readCapability.resolve()}).catch(this._readCapability.reject);this._readCapability.promise.catch(()=>{})}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e).catch(()=>{});this._abortController.abort()}}function transport_stream_classPrivateFieldInitSpec(e,t,i){transport_stream_checkPrivateRedeclaration(e,t),t.set(e,i)}function transport_stream_classPrivateFieldGet(e,t){return e.get(transport_stream_assertClassBrand(e,t))}function transport_stream_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function transport_stream_defineProperty(e,t,i){return(t=function transport_stream_toPropertyKey(e){var t=function transport_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function transport_stream_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function transport_stream_getArrayBuffer(e){return e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function endRequests(){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}var hr=new WeakSet;class PDFDataTransportStream extends BasePDFStream{constructor(e){super(e,PDFDataTransportStreamReader,PDFDataTransportStreamRangeReader);!function transport_stream_classPrivateMethodInitSpec(e,t){transport_stream_checkPrivateRedeclaration(e,t),t.add(e)}(this,hr);transport_stream_defineProperty(this,"_progressiveDone",!1);transport_stream_defineProperty(this,"_queuedChunks",[]);const{pdfDataRangeTransport:t}=e,{initialData:i,progressiveDone:a}=t;if(i?.length>0){const e=transport_stream_getArrayBuffer(i);this._queuedChunks.push(e)}this._progressiveDone=a;t.transportReady(e=>{switch(e.type){case"range":case"progressiveRead":transport_stream_assertClassBrand(hr,this,_onReceiveData).call(this,e.begin,e.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone();this._progressiveDone=!0}})}getFullReader(){const e=super.getFullReader();this._queuedChunks=null;return e}getRangeReader(e,t){const i=super.getRangeReader(e,t);if(i){i.onDone=()=>this._rangeReaders.delete(i);this._source.pdfDataRangeTransport.requestDataRange(e,t)}return i}cancelAllRequests(e){super.cancelAllRequests(e);this._source.pdfDataRangeTransport.abort()}}function _onReceiveData(e,t){const i=transport_stream_getArrayBuffer(t);if(void 0===e)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const t=this._rangeReaders.keys().find(t=>t._begin===e);assert(t,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");t._enqueue(i)}}var _r=new WeakMap;class PDFDataTransportStreamReader extends BasePDFStreamReader{constructor(e){super(e);transport_stream_classPrivateFieldInitSpec(this,_r,endRequests.bind(this));transport_stream_defineProperty(this,"_done",!1);transport_stream_defineProperty(this,"_queuedChunks",null);transport_stream_defineProperty(this,"_requests",[]);const{pdfDataRangeTransport:t,disableRange:i,disableStream:a}=e._source,{length:s,contentDispositionFilename:r}=t;this._queuedChunks=e._queuedChunks||[];for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._done=e._progressiveDone;this._contentLength=s;this._isStreamingSupported=!a;this._isRangeSupported=!i;isPdfFile(r)&&(this._filename=r);this._headersCapability.resolve();const n=this._loaded;Promise.resolve().then(()=>{n>0&&this._loaded===n&&this._callOnProgress()})}_enqueue(e){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunks.push(e);this._loaded+=e.byteLength;this._callOnProgress()}}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;transport_stream_classPrivateFieldGet(_r,this).call(this)}progressiveDone(){this._done||=!0;0===this._queuedChunks.length&&transport_stream_classPrivateFieldGet(_r,this).call(this)}}var ur=new WeakMap;class PDFDataTransportStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);transport_stream_classPrivateFieldInitSpec(this,ur,endRequests.bind(this));transport_stream_defineProperty(this,"onDone",null);transport_stream_defineProperty(this,"_begin",-1);transport_stream_defineProperty(this,"_done",!1);transport_stream_defineProperty(this,"_queuedChunk",null);transport_stream_defineProperty(this,"_requests",[]);this._begin=t}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});transport_stream_classPrivateFieldGet(ur,this).call(this)}this._done=!0;this.onDone?.()}}async read(){if(this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;transport_stream_classPrivateFieldGet(ur,this).call(this);this.onDone?.()}}function network_classPrivateMethodInitSpec(e,t){network_checkPrivateRedeclaration(e,t),t.add(e)}function network_defineProperty(e,t,i){return(t=function network_toPropertyKey(e){var t=function network_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function network_classPrivateFieldInitSpec(e,t,i){network_checkPrivateRedeclaration(e,t),t.set(e,i)}function network_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function network_classPrivateFieldGet(e,t){return e.get(network_assertClassBrand(e,t))}function network_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var pr=new WeakMap,gr=new WeakSet;class PDFNetworkStream extends BasePDFStream{constructor(e){super(e,PDFNetworkStreamReader,PDFNetworkStreamRangeReader);network_classPrivateMethodInitSpec(this,gr);network_classPrivateFieldInitSpec(this,pr,new WeakMap);network_defineProperty(this,"_responseOrigin",null);const{httpHeaders:t,url:i}=e;this.url=i;this.isHttp=/https?:/.test(i.protocol);this.headers=createHeaders(this.isHttp,t)}_request(e){const t=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};network_classPrivateFieldGet(pr,this).set(t,i);t.open("GET",this.url);t.withCredentials=this._source.withCredentials;for(const[e,i]of this.headers)t.setRequestHeader(e,i);if(this.isHttp&&"begin"in e&&"end"in e){t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`);i.validateStatus=e=>206===e||200===e}else i.validateStatus=e=>200===e;t.responseType="arraybuffer";assert(e.onError,"Expected `onError` callback to be provided.");t.onerror=()=>e.onError(t.status);t.onreadystatechange=network_assertClassBrand(gr,this,_onStateChange).bind(this,t);t.onprogress=network_assertClassBrand(gr,this,_onProgress).bind(this,t);t.send(null);return t}_abortRequest(e){if(network_classPrivateFieldGet(pr,this).has(e)){network_classPrivateFieldGet(pr,this).delete(e);e.abort()}}getRangeReader(e,t){const i=super.getRangeReader(e,t);i&&(i.onClosed=()=>this._rangeReaders.delete(i));return i}}function _onProgress(e,t){const i=network_classPrivateFieldGet(pr,this).get(e);i?.onProgress?.(t)}function _onStateChange(e,t){const i=network_classPrivateFieldGet(pr,this).get(e);if(!i)return;if(e.readyState>=2&&i.onHeadersReceived){i.onHeadersReceived();delete i.onHeadersReceived}if(4!==e.readyState)return;if(!network_classPrivateFieldGet(pr,this).has(e))return;network_classPrivateFieldGet(pr,this).delete(e);if(0===e.status&&this.isHttp){i.onError(e.status);return}const a=e.status||200;if(!i.validateStatus(a)){i.onError(e.status);return}const s=function network_getArrayBuffer(e){return"string"!=typeof e?e:stringToBytes(e).buffer}(e.response);if(206===a){const t=e.getResponseHeader("Content-Range");if(/bytes \d+-\d+\/\d+/.test(t))i.onDone(s);else{warn('Missing or invalid "Content-Range" header.');i.onError(0)}}else s?i.onDone(s):i.onError(e.status)}var mr=new WeakMap,fr=new WeakSet;class PDFNetworkStreamReader extends BasePDFStreamReader{constructor(e){super(e);network_classPrivateMethodInitSpec(this,fr);network_classPrivateFieldInitSpec(this,mr,endRequests.bind(this));network_defineProperty(this,"_cachedChunks",[]);network_defineProperty(this,"_done",!1);network_defineProperty(this,"_requests",[]);network_defineProperty(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:network_assertClassBrand(fr,this,_onHeadersReceived).bind(this),onDone:network_assertClassBrand(fr,this,_onDone).bind(this),onError:network_assertClassBrand(fr,this,_onError).bind(this),onProgress:network_assertClassBrand(fr,this,_onProgress2).bind(this)})}async read(){await this._headersCapability.promise;if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;this._headersCapability.reject(e);network_classPrivateFieldGet(mr,this).call(this);this._stream._abortRequest(this._fullRequestXhr);this._fullRequestXhr=null}}function _onHeadersReceived(){const e=this._stream,{disableRange:t,rangeChunkSize:i}=e._source,a=this._fullRequestXhr;e._responseOrigin=getResponseOrigin(a.responseURL);const s=a.getAllResponseHeaders(),r=new Headers(s?function trimHeadersEnd(e){let t=e.length;for(;t>0&&" "!==e[t-1]&&/\s/.test(e[t-1]);)t--;return e.slice(0,t)}(s.trimStart()).split(/[\r\n]+/).map(e=>{const[t,...i]=e.split(": ");return[t,i.join(": ")]}):[]),{contentLength:n,isRangeSupported:o}=validateRangeRequestCapabilities({responseHeaders:r,isHttp:e.isHttp,rangeChunkSize:i,disableRange:t});this._contentLength=n;this._isRangeSupported=o;this._filename=extractFilenameFromHeader(r);this._isRangeSupported&&e._abortRequest(a);this._headersCapability.resolve()}function _onDone(e){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._cachedChunks.push(e);this._done=!0;0===this._cachedChunks.length&&network_classPrivateFieldGet(mr,this).call(this)}function _onError(e){this._storedError=createResponseError(e,this._stream.url);this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0;this._cachedChunks.length=0}function _onProgress2(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}var vr=new WeakMap,Pr=new WeakSet;class PDFNetworkStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);network_classPrivateMethodInitSpec(this,Pr);network_classPrivateFieldInitSpec(this,vr,endRequests.bind(this));network_defineProperty(this,"onClosed",null);network_defineProperty(this,"_done",!1);network_defineProperty(this,"_queuedChunk",null);network_defineProperty(this,"_requests",[]);network_defineProperty(this,"_storedError",null);this._requestXhr=e._request({begin:t,end:i,onHeadersReceived:network_assertClassBrand(Pr,this,_onHeadersReceived2).bind(this),onDone:network_assertClassBrand(Pr,this,_onDone2).bind(this),onError:network_assertClassBrand(Pr,this,_onError2).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;network_classPrivateFieldGet(vr,this).call(this);this._stream._abortRequest(this._requestXhr);this.onClosed?.()}}function _onHeadersReceived2(){const e=getResponseOrigin(this._requestXhr?.responseURL);try{ensureResponseOrigin(e,this._stream._responseOrigin)}catch(e){this._storedError=e;network_assertClassBrand(Pr,this,_onError2).call(this,0)}}function _onDone2(e){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;network_classPrivateFieldGet(vr,this).call(this);this.onClosed?.()}function _onError2(e){this._storedError??=createResponseError(e,this._stream.url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0;this._queuedChunk=null}function node_stream_defineProperty(e,t,i){return(t=function node_stream_toPropertyKey(e){var t=function node_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function getReadableStream(e,t=null){const i=process.getBuiltinModule("fs"),{Readable:a}=process.getBuiltinModule("stream"),s=i.createReadStream(e,t);return a.toWeb(s)}class PDFNodeStream extends BasePDFStream{constructor(e){super(e,PDFNodeStreamReader,PDFNodeStreamRangeReader);const{url:t}=e;assert("file:"===t.protocol,"PDFNodeStream only supports file:// URLs.")}}class PDFNodeStreamReader extends BasePDFStreamReader{constructor(e){super(e);node_stream_defineProperty(this,"_reader",null);const{disableRange:t,disableStream:i,rangeChunkSize:a,url:s}=e._source;this._isStreamingSupported=!i;process.getBuiltinModule("fs/promises").lstat(s).then(e=>{const i=getReadableStream(s);this._reader=i.getReader();const{size:r}=e;this._contentLength=r;this._isRangeSupported=!t&&r>2*a;!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new AbortException("Streaming is disabled."));this._headersCapability.resolve()}).catch(e=>{"ENOENT"===e.code&&(e=createResponseError(0,s));this._headersCapability.reject(e)})}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};this._loaded+=e.byteLength;this._callOnProgress();return{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e).catch(()=>{})}}class PDFNodeStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);node_stream_defineProperty(this,"_readCapability",Promise.withResolvers());node_stream_defineProperty(this,"_reader",null);const{url:a}=e._source;try{const e=getReadableStream(a,{start:t,end:i-1});this._reader=e.getReader();this._readCapability.resolve()}catch(e){this._readCapability.reject(e)}this._readCapability.promise.catch(()=>{})}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e).catch(()=>{})}}function worker_options_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class GlobalWorkerOptions{static get rendererPorts(){return worker_options_assertClassBrand(GlobalWorkerOptions,this,Fr)._}static set rendererPorts(e){if(!Array.isArray(e)||!e.every(e=>"undefined"!=typeof Worker&&e instanceof Worker))throw new Error("Invalid `rendererPorts` type.");Fr._=worker_options_assertClassBrand(GlobalWorkerOptions,this,e)}static get rendererSrc(){return worker_options_assertClassBrand(GlobalWorkerOptions,this,yr)._}static set rendererSrc(e){if("string"!=typeof e)throw new Error("Invalid `rendererSrc` type.");yr._=worker_options_assertClassBrand(GlobalWorkerOptions,this,e)}static get workerPort(){return worker_options_assertClassBrand(GlobalWorkerOptions,this,wr)._}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw new Error("Invalid `workerPort` type.");wr._=worker_options_assertClassBrand(GlobalWorkerOptions,this,e)}static get workerSrc(){return worker_options_assertClassBrand(GlobalWorkerOptions,this,br)._}static set workerSrc(e){if("string"!=typeof e)throw new Error("Invalid `workerSrc` type.");br._=worker_options_assertClassBrand(GlobalWorkerOptions,this,e)}}var wr={_:null},Fr={_:[]},yr={_:""},br={_:""};function metadata_classPrivateFieldInitSpec(e,t,i){(function metadata_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function metadata_classPrivateFieldGet(e,t){return e.get(metadata_assertClassBrand(e,t))}function metadata_classPrivateFieldSet(e,t,i){return e.set(metadata_assertClassBrand(e,t),i),i}function metadata_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Sr,Cr=new WeakMap,xr=new WeakMap;class Metadata{constructor({parsedData:e,rawData:t}){metadata_classPrivateFieldInitSpec(this,Cr,void 0);metadata_classPrivateFieldInitSpec(this,xr,void 0);metadata_classPrivateFieldSet(Cr,this,e);metadata_classPrivateFieldSet(xr,this,t)}getRaw(){return metadata_classPrivateFieldGet(xr,this)}get(e){return metadata_classPrivateFieldGet(Cr,this).get(e)??null}[Symbol.iterator](){return metadata_classPrivateFieldGet(Cr,this).entries()}}function obj_bin_transform_utils_defineProperty(e,t,i){return(t=function obj_bin_transform_utils_toPropertyKey(e){var t=function obj_bin_transform_utils_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class CSS_FONT_INFO{}obj_bin_transform_utils_defineProperty(CSS_FONT_INFO,"strings",["fontFamily","fontWeight","italicAngle"]);class SYSTEM_FONT_INFO{}obj_bin_transform_utils_defineProperty(SYSTEM_FONT_INFO,"strings",["css","loadedName","baseFontName","src"]);class FONT_INFO{}Sr=FONT_INFO;obj_bin_transform_utils_defineProperty(FONT_INFO,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]);obj_bin_transform_utils_defineProperty(FONT_INFO,"strings",["fallbackName","loadedName"]);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_BBOX",Math.ceil(2*Sr.bools.length/8));obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_FONT_MATRIX",Sr.OFFSET_BBOX+1+8);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_STRINGS",Sr.OFFSET_FONT_MATRIX+1+48);class PATTERN_INFO{}obj_bin_transform_utils_defineProperty(PATTERN_INFO,"KIND",0);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"HAS_BBOX",1);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"HAS_BACKGROUND",2);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"SHADING_TYPE",3);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_COORD",4);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_COLOR",8);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_STOP",12);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_FIGURES",16);class InfoUtils{static get decoder(){return shadow(this,"decoder",new TextDecoder)}static get encoder(){return shadow(this,"encoder",new TextEncoder)}}function obj_bin_transform_display_classPrivateMethodInitSpec(e,t){obj_bin_transform_display_checkPrivateRedeclaration(e,t),t.add(e)}function obj_bin_transform_display_classPrivateFieldInitSpec(e,t,i){obj_bin_transform_display_checkPrivateRedeclaration(e,t),t.set(e,i)}function obj_bin_transform_display_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function obj_bin_transform_display_classPrivateFieldGet(e,t){return e.get(obj_bin_transform_display_assertClassBrand(e,t))}function obj_bin_transform_display_classPrivateFieldSet(e,t,i){return e.set(obj_bin_transform_display_assertClassBrand(e,t),i),i}function obj_bin_transform_display_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function readString(e,t,i,a=0){const{decoder:s}=InfoUtils;for(let e=0;e<i;e++)a+=t.getUint32(a)+4;const r=t.getUint32(a);return s.decode(new Uint8Array(e,a+4,r))}var kr=new WeakMap,Er=new WeakMap,Ar=new WeakSet;class CssFontInfo{constructor(e){obj_bin_transform_display_classPrivateMethodInitSpec(this,Ar);obj_bin_transform_display_classPrivateFieldInitSpec(this,kr,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,Er,void 0);obj_bin_transform_display_classPrivateFieldSet(kr,this,e);obj_bin_transform_display_classPrivateFieldSet(Er,this,new DataView(e))}get fontFamily(){return shadow(this,"fontFamily",obj_bin_transform_display_assertClassBrand(Ar,this,_readString).call(this,0))}get fontWeight(){return shadow(this,"fontWeight",obj_bin_transform_display_assertClassBrand(Ar,this,_readString).call(this,1))}get italicAngle(){return shadow(this,"italicAngle",obj_bin_transform_display_assertClassBrand(Ar,this,_readString).call(this,2))}}function _readString(e){assert(e<CSS_FONT_INFO.strings.length,"Invalid string index");return readString(obj_bin_transform_display_classPrivateFieldGet(kr,this),obj_bin_transform_display_classPrivateFieldGet(Er,this),e)}var Gr=new WeakMap,Br=new WeakMap,Mr=new WeakSet;class SystemFontInfo{constructor(e){obj_bin_transform_display_classPrivateMethodInitSpec(this,Mr);obj_bin_transform_display_classPrivateFieldInitSpec(this,Gr,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,Br,void 0);obj_bin_transform_display_classPrivateFieldSet(Gr,this,e);obj_bin_transform_display_classPrivateFieldSet(Br,this,new DataView(e))}get css(){return shadow(this,"css",obj_bin_transform_display_assertClassBrand(Mr,this,_readString2).call(this,0))}get loadedName(){return shadow(this,"loadedName",obj_bin_transform_display_assertClassBrand(Mr,this,_readString2).call(this,1))}get baseFontName(){return shadow(this,"baseFontName",obj_bin_transform_display_assertClassBrand(Mr,this,_readString2).call(this,2))}get src(){return shadow(this,"src",obj_bin_transform_display_assertClassBrand(Mr,this,_readString2).call(this,3))}get style(){let e=0;e+=4+obj_bin_transform_display_classPrivateFieldGet(Br,this).getUint32(e);return shadow(this,"style",{style:readString(obj_bin_transform_display_classPrivateFieldGet(Gr,this),obj_bin_transform_display_classPrivateFieldGet(Br,this),0,e),weight:readString(obj_bin_transform_display_classPrivateFieldGet(Gr,this),obj_bin_transform_display_classPrivateFieldGet(Br,this),1,e)})}}function _readString2(e){assert(e<SYSTEM_FONT_INFO.strings.length,"Invalid string index");return readString(obj_bin_transform_display_classPrivateFieldGet(Gr,this),obj_bin_transform_display_classPrivateFieldGet(Br,this),e,4)}var Ir=new WeakMap,Tr=new WeakMap,Dr=new WeakSet;class FontInfo{constructor(e){obj_bin_transform_display_classPrivateMethodInitSpec(this,Dr);obj_bin_transform_display_classPrivateFieldInitSpec(this,Ir,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,Tr,void 0);obj_bin_transform_display_classPrivateFieldSet(Ir,this,e);obj_bin_transform_display_classPrivateFieldSet(Tr,this,new DataView(e))}get black(){return shadow(this,"black",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,0))}get bold(){return shadow(this,"bold",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,1))}get disableFontFace(){return shadow(this,"disableFontFace",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,2))}get fontExtraProperties(){return shadow(this,"fontExtraProperties",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,3))}get isInvalidPDFjsFont(){return shadow(this,"isInvalidPDFjsFont",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,4))}get isType3Font(){return shadow(this,"isType3Font",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,5))}get italic(){return shadow(this,"italic",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,6))}get missingFile(){return shadow(this,"missingFile",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,7))}get remeasure(){return shadow(this,"remeasure",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,8))}get vertical(){return shadow(this,"vertical",obj_bin_transform_display_assertClassBrand(Dr,this,_readBoolean).call(this,9))}get bbox(){return shadow(this,"bbox",obj_bin_transform_display_assertClassBrand(Dr,this,_readArray).call(this,FONT_INFO.OFFSET_BBOX,4,"getInt16",2))}get fontMatrix(){return shadow(this,"fontMatrix",obj_bin_transform_display_assertClassBrand(Dr,this,_readArray).call(this,FONT_INFO.OFFSET_FONT_MATRIX,6,"getFloat64",8))}get fallbackName(){return shadow(this,"fallbackName",obj_bin_transform_display_assertClassBrand(Dr,this,_readString3).call(this,0))}get loadedName(){return shadow(this,"loadedName",obj_bin_transform_display_assertClassBrand(Dr,this,_readString3).call(this,1))}get data(){const{offset:e,length:t}=obj_bin_transform_display_assertClassBrand(Dr,this,_getBufferOffset).call(this,2);return t?new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ir,this),e+4,t):void 0}clearData(){const{offset:e,length:t}=obj_bin_transform_display_assertClassBrand(Dr,this,_getBufferOffset).call(this,2);if(t){obj_bin_transform_display_classPrivateFieldGet(Tr,this).setUint32(e,0);obj_bin_transform_display_classPrivateFieldSet(Ir,this,new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ir,this),0,e+4).slice().buffer);obj_bin_transform_display_classPrivateFieldSet(Tr,this,new DataView(obj_bin_transform_display_classPrivateFieldGet(Ir,this)))}}get cssFontInfo(){const{offset:e,length:t}=obj_bin_transform_display_assertClassBrand(Dr,this,_getBufferOffset).call(this,1);let i=null;if(t){const a=new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ir,this),e+4,t).slice();i=new CssFontInfo(a.buffer)}return shadow(this,"cssFontInfo",i)}get systemFontInfo(){const{offset:e,length:t}=obj_bin_transform_display_assertClassBrand(Dr,this,_getBufferOffset).call(this,0);let i=null;if(t){const a=new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ir,this),e+4,t).slice();i=new SystemFontInfo(a.buffer)}return shadow(this,"systemFontInfo",i)}}function _readBoolean(e){assert(e<FONT_INFO.bools.length,"Invalid boolean index");const t=Math.floor(e/4),i=2*e%8,a=obj_bin_transform_display_classPrivateFieldGet(Tr,this).getUint8(t)>>i&3;return 0===a?void 0:2===a}function _readArray(e,t,i,a){const s=obj_bin_transform_display_classPrivateFieldGet(Tr,this).getUint8(e++);if(0===s)return;assert(s===t,"Invalid array length.");const r=new Array(s);for(let t=0;t<s;t++){r[t]=obj_bin_transform_display_classPrivateFieldGet(Tr,this)[i](e,!0);e+=a}return r}function _readString3(e){assert(e<FONT_INFO.strings.length,"Invalid string index");return readString(obj_bin_transform_display_classPrivateFieldGet(Ir,this),obj_bin_transform_display_classPrivateFieldGet(Tr,this),e,FONT_INFO.OFFSET_STRINGS+4)}function _getBufferOffset(e){let t=FONT_INFO.OFFSET_STRINGS;for(let i=0;i<=e;i++)t+=4+obj_bin_transform_display_classPrivateFieldGet(Tr,this).getUint32(t);return{offset:t,length:obj_bin_transform_display_classPrivateFieldGet(Tr,this).getUint32(t)}}class PatternInfo{constructor(e){this.buffer=e;this.view=new DataView(e);this.data=new Uint8Array(e)}getIR(){const e=this.view,t=this.data[PATTERN_INFO.KIND],a=!!this.data[PATTERN_INFO.HAS_BBOX],s=!!this.data[PATTERN_INFO.HAS_BACKGROUND],r=e.getUint32(PATTERN_INFO.N_COORD,!0),n=e.getUint32(PATTERN_INFO.N_COLOR,!0),o=e.getUint32(PATTERN_INFO.N_STOP,!0);let l=20;const d=new Float32Array(this.buffer,l,2*r);l+=8*r;const c=new Uint8Array(this.buffer,l,4*n);l+=4*n;const h=[];for(let t=0;t<o;++t){const t=e.getFloat32(l,!0);l+=4;const i=e.getUint32(l,!0);l+=4;h.push([t,`#${i.toString(16).padStart(6,"0")}`])}let _=null;if(a){_=[];for(let t=0;t<4;++t){_.push(e.getFloat32(l,!0));l+=4}}let u=null;if(s){u=new Uint8Array(this.buffer,l,3);l+=3}if(1===t)return["RadialAxial","axial",_,h,[d[0],d[1]],[d[2],d[3]],null,null];if(2===t)return["RadialAxial","radial",_,h,[d[0],d[1]],[d[3],d[4]],d[2],d[5]];if(3===t){const e=this.data[PATTERN_INFO.SHADING_TYPE];let t=null;if(d.length>0){t=i.slice();for(let e=0,i=d.length;e<i;e+=2)Util.pointBoundingBox(d[e],d[e+1],t)}return["Mesh",e,d,c,r,t,_,u]}throw new Error(`Unsupported pattern kind: ${t}`)}}var Lr=new WeakMap;class FontPathInfo{constructor(e){obj_bin_transform_display_classPrivateFieldInitSpec(this,Lr,void 0);obj_bin_transform_display_classPrivateFieldSet(Lr,this,e)}get path(){return FeatureTest.isFloat16ArraySupported?new Float16Array(obj_bin_transform_display_classPrivateFieldGet(Lr,this)):new Float32Array(obj_bin_transform_display_classPrivateFieldGet(Lr,this))}}function pdf_objects_classPrivateFieldInitSpec(e,t,i){(function pdf_objects_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function pdf_objects_classPrivateFieldGet(e,t){return e.get(function pdf_objects_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}const Rr=Symbol("INITIAL_DATA"),dataObj=()=>({...Promise.withResolvers(),data:Rr});var Or=new WeakMap;class PDFObjects{constructor(){pdf_objects_classPrivateFieldInitSpec(this,Or,new Map)}get(e,t=null,i=null){if(t){const a=pdf_objects_classPrivateFieldGet(Or,this).getOrInsertComputed(e,dataObj);a.promise.then(()=>t(a.data),i);return null}const a=pdf_objects_classPrivateFieldGet(Or,this).get(e);if(!a||a.data===Rr)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return a.data}has(e){const t=pdf_objects_classPrivateFieldGet(Or,this).get(e);return!!t&&t.data!==Rr}delete(e){const t=pdf_objects_classPrivateFieldGet(Or,this).get(e);if(!t||t.data===Rr)return!1;pdf_objects_classPrivateFieldGet(Or,this).delete(e);return!0}resolve(e,t=null){const i=pdf_objects_classPrivateFieldGet(Or,this).getOrInsertComputed(e,dataObj);if(i.data!==Rr)throw new Error(`Object already resolved ${e}.`);i.data=t;i.resolve()}reject(e,t){const i=pdf_objects_classPrivateFieldGet(Or,this).getOrInsertComputed(e,dataObj);if(i.data===Rr){i.promise.catch(()=>{});i.reject(t)}}clear(){for(const{data:e}of pdf_objects_classPrivateFieldGet(Or,this).values())e?.bitmap?.close();pdf_objects_classPrivateFieldGet(Or,this).clear()}*[Symbol.iterator](){for(const[e,{data:t}]of pdf_objects_classPrivateFieldGet(Or,this))t!==Rr&&(yield[e,t])}}class ObjectHandler{constructor({messageHandler:e,commonObjs:t,fontLoader:i,pageCache:a,pdfBug:s=!1,shouldCreatePageObjs:r=!1}){this.messageHandler=e;this.commonObjs=t;this.fontLoader=i;this.pageCache=a;this.pdfBug=s;this.shouldCreatePageObjs=r}resolveCommonObject(e,t,i){if("CopyLocalImage"===t){const{imageRef:t}=i;assert(t,"The imageRef must be defined.");for(const i of this.pageCache.values()){const a=i.objs||i;for(const[,i]of a){if(i?.ref!==t)continue;if(!i.dataLen)return null;const a=structuredClone(i);this.commonObjs.resolve(e,a);return i.dataLen}}return null}switch(t){case"Font":if("error"in i){const t=i.error;warn(`Error during font loading: ${t}`);this.commonObjs.resolve(e,t);break}const a=new FontInfo(i.buffer),s=this.pdfBug&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,r=new FontFaceObject(a,s,i.charProcOperatorList,i.extra);this.fontLoader.bind(r).catch(()=>this.messageHandler.sendWithPromise("FontFallback",{id:e}).catch(t=>{warn(`FontFallback failed for "${e}": ${t}`)})).finally(()=>{r.fontExtraProperties||r.clearData();this.commonObjs.resolve(e,r)});break;case"FontPath":this.commonObjs.resolve(e,new FontPathInfo(i));break;case"Image":this.commonObjs.resolve(e,i);break;case"Pattern":const n=new PatternInfo(i);this.commonObjs.resolve(e,n.getIR());break;default:throw new Error(`Got unknown common object type ${t}`)}return null}resolveObject(e,t,i,a){let s=this.pageCache.get(t);if(!s){if(!this.shouldCreatePageObjs)return!1;s=new PDFObjects;this.pageCache.set(t,s)}const r=s.objs||s;if(r.has(e))return!1;if(0===s._intentStates?.size){a?.bitmap?.close();return!1}switch(i){case"Image":case"Pattern":r.resolve(e,a);return!0;default:throw new Error(`Got unknown object type ${i}`)}}}function optional_content_config_defineProperty(e,t,i){return(t=function optional_content_config_toPropertyKey(e){var t=function optional_content_config_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function optional_content_config_classPrivateFieldInitSpec(e,t,i){optional_content_config_checkPrivateRedeclaration(e,t),t.set(e,i)}function optional_content_config_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function optional_content_config_classPrivateFieldGet(e,t){return e.get(optional_content_config_assertClassBrand(e,t))}function optional_content_config_classPrivateFieldSet(e,t,i){return e.set(optional_content_config_assertClassBrand(e,t),i),i}function optional_content_config_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Nr=Symbol("INTERNAL");var Wr=new WeakMap,jr=new WeakMap,Vr=new WeakMap,Ur=new WeakMap;class OptionalContentGroup{constructor(e,{name:t,intent:i,usage:a,rbGroups:s}){optional_content_config_classPrivateFieldInitSpec(this,Wr,!1);optional_content_config_classPrivateFieldInitSpec(this,jr,!1);optional_content_config_classPrivateFieldInitSpec(this,Vr,!1);optional_content_config_classPrivateFieldInitSpec(this,Ur,!0);optional_content_config_classPrivateFieldSet(Wr,this,!!(e&o));optional_content_config_classPrivateFieldSet(jr,this,!!(e&l));this.name=t;this.intent=i;this.usage=a;this.rbGroups=s}get visible(){if(optional_content_config_classPrivateFieldGet(Vr,this))return optional_content_config_classPrivateFieldGet(Ur,this);if(!optional_content_config_classPrivateFieldGet(Ur,this))return!1;const{print:e,view:t}=this.usage;return optional_content_config_classPrivateFieldGet(Wr,this)?"OFF"!==t?.viewState:!optional_content_config_classPrivateFieldGet(jr,this)||"OFF"!==e?.printState}_setVisible(e,t,i=!1){e!==Nr&&unreachable("Internal method `_setVisible` called.");optional_content_config_classPrivateFieldSet(Vr,this,i);optional_content_config_classPrivateFieldSet(Ur,this,t)}get serializable(){return{userSet:optional_content_config_classPrivateFieldGet(Vr,this),visible:optional_content_config_classPrivateFieldGet(Ur,this)}}}var zr=new WeakMap,Hr=new WeakMap,$r=new WeakMap,Xr=new WeakMap,Kr=new WeakMap,qr=new WeakSet;class OptionalContentConfig{constructor(e,t=o,i=null){!function optional_content_config_classPrivateMethodInitSpec(e,t){optional_content_config_checkPrivateRedeclaration(e,t),t.add(e)}(this,qr);optional_content_config_classPrivateFieldInitSpec(this,zr,null);optional_content_config_classPrivateFieldInitSpec(this,Hr,new Map);optional_content_config_classPrivateFieldInitSpec(this,$r,null);optional_content_config_classPrivateFieldInitSpec(this,Xr,null);optional_content_config_classPrivateFieldInitSpec(this,Kr,void 0);optional_content_config_defineProperty(this,"creator",null);optional_content_config_defineProperty(this,"name",null);optional_content_config_classPrivateFieldSet(Kr,this,e);this.renderingIntent=t;if(null!==e){this.name=e.name;this.creator=e.creator;optional_content_config_classPrivateFieldSet(Xr,this,e.order);for(const i of e.groups)optional_content_config_classPrivateFieldGet(Hr,this).set(i.id,new OptionalContentGroup(t,i));if(i){i.size!==optional_content_config_classPrivateFieldGet(Hr,this).size&&unreachable("Incorrect serialized groupState.");for(const[e,t]of i)optional_content_config_classPrivateFieldGet(Hr,this).get(e)._setVisible(Nr,t.visible,t.userSet)}else{if("OFF"===e.baseState)for(const e of optional_content_config_classPrivateFieldGet(Hr,this).values())e._setVisible(Nr,!1);for(const t of e.on)optional_content_config_classPrivateFieldGet(Hr,this).get(t)._setVisible(Nr,!0);for(const t of e.off)optional_content_config_classPrivateFieldGet(Hr,this).get(t)._setVisible(Nr,!1)}optional_content_config_classPrivateFieldSet($r,this,this.getHash())}}isVisible(e){if(0===optional_content_config_classPrivateFieldGet(Hr,this).size)return!0;if(!e){info("Optional content group not defined.");return!0}if("OCG"===e.type){if(!optional_content_config_classPrivateFieldGet(Hr,this).has(e.id)){warn(`Optional content group not found: ${e.id}`);return!0}return optional_content_config_classPrivateFieldGet(Hr,this).get(e.id).visible}if("OCMD"===e.type){if(e.expression)return optional_content_config_assertClassBrand(qr,this,_evaluateVisibilityExpression).call(this,e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(Hr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(optional_content_config_classPrivateFieldGet(Hr,this).get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(Hr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(!optional_content_config_classPrivateFieldGet(Hr,this).get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(Hr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(!optional_content_config_classPrivateFieldGet(Hr,this).get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(Hr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(optional_content_config_classPrivateFieldGet(Hr,this).get(t).visible)return!1}return!0}warn(`Unknown optional content policy ${e.policy}.`);return!0}warn(`Unknown group type ${e.type}.`);return!0}setVisibility(e,t=!0,i=!0){const a=optional_content_config_classPrivateFieldGet(Hr,this).get(e);if(a){if(i&&t&&a.rbGroups.length)for(const t of a.rbGroups)for(const i of t)i!==e&&optional_content_config_classPrivateFieldGet(Hr,this).get(i)?._setVisible(Nr,!1,!0);a._setVisible(Nr,!!t,!0);optional_content_config_classPrivateFieldSet(zr,this,null)}else warn(`Optional content group not found: ${e}`)}setOCGState({state:e,preserveRB:t}){let i;for(const a of e){switch(a){case"ON":case"OFF":case"Toggle":i=a;continue}const e=optional_content_config_classPrivateFieldGet(Hr,this).get(a);if(e)switch(i){case"ON":this.setVisibility(a,!0,t);break;case"OFF":this.setVisibility(a,!1,t);break;case"Toggle":this.setVisibility(a,!e.visible,t)}}optional_content_config_classPrivateFieldSet(zr,this,null)}get hasInitialVisibility(){return null===optional_content_config_classPrivateFieldGet($r,this)||this.getHash()===optional_content_config_classPrivateFieldGet($r,this)}getOrder(){return optional_content_config_classPrivateFieldGet(Hr,this).size?optional_content_config_classPrivateFieldGet(Xr,this)?optional_content_config_classPrivateFieldGet(Xr,this).slice():[...optional_content_config_classPrivateFieldGet(Hr,this).keys()]:null}getGroup(e){return optional_content_config_classPrivateFieldGet(Hr,this).get(e)||null}getHash(){if(null!==optional_content_config_classPrivateFieldGet(zr,this))return optional_content_config_classPrivateFieldGet(zr,this);const e=new MurmurHash3_64;for(const[t,i]of optional_content_config_classPrivateFieldGet(Hr,this))e.update(`${t}:${i.visible}`);return optional_content_config_classPrivateFieldSet(zr,this,e.hexdigest())}[Symbol.iterator](){return optional_content_config_classPrivateFieldGet(Hr,this).entries()}get serializable(){const e=new Map;for(const[t,i]of optional_content_config_classPrivateFieldGet(Hr,this))e.set(t,i.serializable);return{data:optional_content_config_classPrivateFieldGet(Kr,this),renderingIntent:this.renderingIntent,groupState:e}}static fromSerializable({data:e,renderingIntent:t,groupState:i}){return new OptionalContentConfig(e,t,i)}}function _evaluateVisibilityExpression(e){const t=e.length;if(t<2)return!0;const i=e[0];for(let a=1;a<t;a++){const t=e[a];let s;if(Array.isArray(t))s=optional_content_config_assertClassBrand(qr,this,_evaluateVisibilityExpression).call(this,t);else{if(!optional_content_config_classPrivateFieldGet(Hr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}s=optional_content_config_classPrivateFieldGet(Hr,this).get(t).visible}switch(i){case"And":if(!s)return!1;break;case"Or":if(s)return!0;break;case"Not":return!s;default:return!0}}return"And"===i}function pages_mapper_classPrivateFieldInitSpec(e,t,i){pages_mapper_checkPrivateRedeclaration(e,t),t.set(e,i)}function pages_mapper_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pages_mapper_classPrivateFieldSet(e,t,i){return e.set(pages_mapper_assertClassBrand(e,t),i),i}function pages_mapper_classPrivateFieldGet(e,t){return e.get(pages_mapper_assertClassBrand(e,t))}function pages_mapper_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Yr=new WeakMap,Zr=new WeakMap,Qr=new WeakMap,Jr=new WeakMap,en=new WeakMap,tn=new WeakMap,an=new WeakSet;class PagesMapper{constructor(){!function pages_mapper_classPrivateMethodInitSpec(e,t){pages_mapper_checkPrivateRedeclaration(e,t),t.add(e)}(this,an);pages_mapper_classPrivateFieldInitSpec(this,Yr,null);pages_mapper_classPrivateFieldInitSpec(this,Zr,null);pages_mapper_classPrivateFieldInitSpec(this,Qr,0);pages_mapper_classPrivateFieldInitSpec(this,Jr,0);pages_mapper_classPrivateFieldInitSpec(this,en,null);pages_mapper_classPrivateFieldInitSpec(this,tn,null)}get pagesNumber(){return pages_mapper_classPrivateFieldGet(Qr,this)}set pagesNumber(e){if(pages_mapper_classPrivateFieldGet(Qr,this)!==e){pages_mapper_classPrivateFieldSet(Qr,this,pages_mapper_classPrivateFieldSet(Jr,this,e));pages_mapper_classPrivateFieldSet(Yr,this,null);pages_mapper_classPrivateFieldSet(Zr,this,null)}}movePages(e,t,i){pages_mapper_assertClassBrand(an,this,_ensureInit).call(this);const a=pages_mapper_classPrivateFieldGet(Yr,this),s=t.length,r=new Uint32Array(s);let n=0;for(let e=0;e<s;e++){const s=t[e]-1;r[e]=a[s];s<i&&n++}const o=pages_mapper_classPrivateFieldGet(Qr,this),l=o-s,d=new Int32Array(o),c=MathClamp(i-n,0,l);for(let t=0,i=0;t<o;t++)if(!e.has(t+1)){a[i]=a[t];d[i++]=t+1}a.copyWithin(c+s,c,l);a.set(r,c);d.copyWithin(c+s,c,l);d.set(t,c);pages_mapper_classPrivateFieldSet(Zr,this,d);o===pages_mapper_classPrivateFieldGet(Jr,this)&&a.every((e,t)=>e===t+1)&&pages_mapper_classPrivateFieldSet(Yr,this,null)}deletePages(e){pages_mapper_assertClassBrand(an,this,_ensureInit).call(this);const t=pages_mapper_classPrivateFieldGet(Yr,this),i=pages_mapper_assertClassBrand(an,this,_buildIdToPageNumber).call(this);pages_mapper_classPrivateFieldSet(tn,this,{pageNumberToId:t.slice(),pagesNumber:pages_mapper_classPrivateFieldGet(Qr,this),prevPageNumbers:pages_mapper_classPrivateFieldGet(Zr,this).slice()});const a=pages_mapper_classPrivateFieldGet(Qr,this)-e.length;pages_mapper_classPrivateFieldSet(Qr,this,a);const s=pages_mapper_classPrivateFieldSet(Yr,this,new Uint32Array(a));pages_mapper_classPrivateFieldSet(Zr,this,new Int32Array(a));let r=0,n=0;for(const i of e){const e=i-1;if(e!==r){s.set(t.subarray(r,e),n);n+=e-r}r=e+1}r<t.length&&s.set(t.subarray(r),n);pages_mapper_assertClassBrand(an,this,_updatePrevPageNumbers).call(this,i,new Set(e))}cancelDelete(){if(pages_mapper_classPrivateFieldGet(tn,this)){pages_mapper_classPrivateFieldSet(Yr,this,pages_mapper_classPrivateFieldGet(tn,this).pageNumberToId);pages_mapper_classPrivateFieldSet(Qr,this,pages_mapper_classPrivateFieldGet(tn,this).pagesNumber);pages_mapper_classPrivateFieldSet(Zr,this,pages_mapper_classPrivateFieldGet(tn,this).prevPageNumbers);pages_mapper_classPrivateFieldSet(tn,this,null)}}cleanSavedData(){pages_mapper_classPrivateFieldSet(tn,this,null)}copyPages(e){pages_mapper_assertClassBrand(an,this,_ensureInit).call(this);pages_mapper_classPrivateFieldSet(en,this,{pageNumbers:e,pageIds:e.map(e=>pages_mapper_classPrivateFieldGet(Yr,this)[e-1])})}cancelCopy(){pages_mapper_classPrivateFieldSet(en,this,null)}pastePages(e){pages_mapper_assertClassBrand(an,this,_ensureInit).call(this);const t=pages_mapper_classPrivateFieldGet(Yr,this),i=pages_mapper_assertClassBrand(an,this,_buildIdToPageNumber).call(this),{pageNumbers:a,pageIds:s}=pages_mapper_classPrivateFieldGet(en,this),r=pages_mapper_classPrivateFieldGet(Qr,this)+a.length;pages_mapper_classPrivateFieldSet(Qr,this,r);const n=pages_mapper_classPrivateFieldSet(Yr,this,new Uint32Array(r));pages_mapper_classPrivateFieldSet(Zr,this,new Int32Array(r));n.set(t.subarray(0,e),0);n.set(s,e);n.set(t.subarray(e),e+a.length);pages_mapper_assertClassBrand(an,this,_updatePrevPageNumbers).call(this,i,null,e,a);pages_mapper_classPrivateFieldSet(en,this,null)}hasBeenAltered(){return null!==pages_mapper_classPrivateFieldGet(Yr,this)}getPageMappingForSaving(e=null,t=pages_mapper_assertClassBrand(an,this,_buildCopyLevels).call(this)){e??=pages_mapper_assertClassBrand(an,this,_buildIdToPageNumber).call(this);let i=0;for(const t of e.values())i=Math.max(i,t.length);const a=new Array(i);for(let e=0;e<i;e++)a[e]={document:null,pageIndices:[],includePages:[]};for(const[t,i]of e)for(let e=0,s=i.length;e<s;e++)a[e].includePages.push([t-1,i[e]-1]);for(const{includePages:e,pageIndices:t}of a){e.sort((e,t)=>e[0]-t[0]);for(let i=0,a=e.length;i<a;i++){t.push(e[i][1]);e[i]=e[i][0]}}return{pageInfos:a,copyLevels:t}}extractPages(e){e=Array.from(e).sort((e,t)=>e-t);const t=new Map;for(let i=0,a=e.length;i<a;i++){const a=this.getPageId(e[i]);t.getOrInsertComputed(a,makeArr).push(i+1)}return this.getPageMappingForSaving(t,pages_mapper_assertClassBrand(an,this,_buildCopyLevels).call(this,e))}getPrevPageNumber(e){return pages_mapper_classPrivateFieldGet(Zr,this)?.[e-1]??0}getPageNumber(e){if(!pages_mapper_classPrivateFieldGet(Yr,this))return e;const t=pages_mapper_classPrivateFieldGet(Yr,this);for(let i=0,a=pages_mapper_classPrivateFieldGet(Qr,this);i<a;i++)if(t[i]===e)return i+1;return 0}getPageId(e){return pages_mapper_classPrivateFieldGet(Yr,this)?.[e-1]??e}getMapping(){return pages_mapper_classPrivateFieldGet(Yr,this)?.subarray(0,this.pagesNumber)}}function _ensureInit(){if(pages_mapper_classPrivateFieldGet(Yr,this))return;const e=pages_mapper_classPrivateFieldGet(Qr,this),t=pages_mapper_classPrivateFieldSet(Yr,this,new Uint32Array(e));for(let i=0;i<e;i++)t[i]=i+1;pages_mapper_classPrivateFieldSet(Zr,this,new Int32Array(t))}function _buildIdToPageNumber(){const e=new Map,t=pages_mapper_classPrivateFieldGet(Yr,this);for(let i=0,a=pages_mapper_classPrivateFieldGet(Qr,this);i<a;i++){const a=t[i],s=e.get(a);s?s.push(i+1):e.set(a,[i+1])}return e}function _updatePrevPageNumbers(e,t=null,i=-1,a=null){const s=pages_mapper_classPrivateFieldGet(Zr,this),r=pages_mapper_classPrivateFieldGet(Yr,this),n=i+(a?.length??0),o=new Map;for(let l=0,d=pages_mapper_classPrivateFieldGet(Qr,this);l<d;l++){if(l>=i&&l<n){s[l]=-a[l-i];continue}const d=r[l],c=e.get(d);let h=o.get(d)||0;if(t&&c)for(;h<c.length&&t.has(c[h]);)h++;s[l]=c?.[h];o.set(d,h+1)}}function _buildCopyLevels(e=null){if(!pages_mapper_classPrivateFieldGet(Yr,this))return null;const t=new Int32Array(pages_mapper_classPrivateFieldGet(Qr,this)).fill(-1),i=new Map;if(e)for(const a of e){const e=this.getPageId(a),s=i.get(e)??0;i.set(e,s+1);t[a-1]=s}else for(let e=0,a=pages_mapper_classPrivateFieldGet(Qr,this);e<a;e++){const a=pages_mapper_classPrivateFieldGet(Yr,this)[e],s=i.get(a)??0;i.set(a,s+1);t[e]=s}return t}function renderer_worker_proxy_classPrivateMethodInitSpec(e,t){renderer_worker_proxy_checkPrivateRedeclaration(e,t),t.add(e)}function renderer_worker_proxy_defineProperty(e,t,i){return(t=function renderer_worker_proxy_toPropertyKey(e){var t=function renderer_worker_proxy_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function renderer_worker_proxy_classPrivateFieldInitSpec(e,t,i){renderer_worker_proxy_checkPrivateRedeclaration(e,t),t.set(e,i)}function renderer_worker_proxy_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function renderer_worker_proxy_classPrivateFieldGet(e,t){return e.get(renderer_worker_proxy_assertClassBrand(e,t))}function renderer_worker_proxy_classPrivateFieldSet(e,t,i){return e.set(renderer_worker_proxy_assertClassBrand(e,t),i),i}function renderer_worker_proxy_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function closeFrame({bitmap:e,annotationBitmaps:t}){e?.close();if(t)for(const[,,e]of t)e.close()}var sn=new WeakMap,rn=new WeakMap,nn=new WeakMap,on=new WeakMap,ln=new WeakMap,dn=new WeakMap,cn=new WeakMap,hn=new WeakMap,_n=new WeakMap,un=new WeakMap,pn=new WeakMap,gn=new WeakMap,mn=new WeakSet;class WorkerRenderTask{constructor({rendererWorker:e,renderTasks:t,canvas:i,canvasFactory:a,annotationCanvasMap:s,operatorListState:r,initParams:n,onFrame:o,onError:l}){renderer_worker_proxy_classPrivateMethodInitSpec(this,mn);renderer_worker_proxy_classPrivateFieldInitSpec(this,sn,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,rn,!1);renderer_worker_proxy_classPrivateFieldInitSpec(this,nn,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,on,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,ln,0);renderer_worker_proxy_classPrivateFieldInitSpec(this,dn,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,cn,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,hn,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,_n,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,un,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,pn,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,gn,void 0);renderer_worker_proxy_defineProperty(this,"imageCoordinates",null);renderer_worker_proxy_defineProperty(this,"recordedBBoxes",null);renderer_worker_proxy_classPrivateFieldSet(pn,this,e);renderer_worker_proxy_classPrivateFieldSet(gn,this,t);renderer_worker_proxy_classPrivateFieldSet(nn,this,i);renderer_worker_proxy_classPrivateFieldSet(on,this,a);renderer_worker_proxy_classPrivateFieldSet(sn,this,s);renderer_worker_proxy_classPrivateFieldSet(un,this,r);renderer_worker_proxy_classPrivateFieldSet(cn,this,n);renderer_worker_proxy_classPrivateFieldSet(dn,this,n.renderTaskId);renderer_worker_proxy_classPrivateFieldSet(_n,this,o);renderer_worker_proxy_classPrivateFieldSet(hn,this,l)}async initialize(e,t){try{await renderer_worker_proxy_classPrivateFieldGet(pn,this).promise}catch{return!1}if(!renderer_worker_proxy_classPrivateFieldGet(pn,this).messageHandler||renderer_worker_proxy_classPrivateFieldGet(rn,this))return!1;try{await renderer_worker_proxy_classPrivateFieldGet(pn,this).sendWithPromise("InitializeGraphics",{...renderer_worker_proxy_classPrivateFieldGet(cn,this),width:renderer_worker_proxy_classPrivateFieldGet(nn,this).width,height:renderer_worker_proxy_classPrivateFieldGet(nn,this).height,transparency:e,optionalContentConfig:t.serializable})}catch(e){renderer_worker_proxy_classPrivateFieldGet(rn,this)||warn(`Failed to initialize graphics in renderer worker: ${e.message}. Falling back to main-thread rendering.`);return!1}renderer_worker_proxy_classPrivateFieldGet(rn,this)||renderer_worker_proxy_classPrivateFieldGet(gn,this).set(renderer_worker_proxy_classPrivateFieldGet(dn,this),this);return!0}async executeOperatorList(e,t,i){const a=renderer_worker_proxy_classPrivateFieldGet(pn,this).messageHandler;if(!a)throw new Error("Renderer worker was destroyed during rendering.");const{lastChunk:s}=e,r=e.argsArray.length,n=renderer_worker_proxy_classPrivateFieldGet(un,this);if(n.sentLength<r){const t=n.sentLength;a.send("AppendOperatorList",{pageProxyId:renderer_worker_proxy_classPrivateFieldGet(cn,this).pageProxyId,operatorListId:n.id,fnArray:e.fnArray.slice(t,r),argsArray:e.argsArray.slice(t,r)});n.sentLength=r}let o=null;if(i&&renderer_worker_proxy_classPrivateFieldGet(ln,this)<r){const t=renderer_worker_proxy_classPrivateFieldGet(ln,this);o=new Uint8Array(r-t);for(let a=t;a<r;a++)o[a-t]=i(a,e)?1:0;renderer_worker_proxy_classPrivateFieldSet(ln,this,r)}const l=await renderer_worker_proxy_classPrivateFieldGet(pn,this).sendWithPromise("ExecuteOperatorList",{renderTaskId:renderer_worker_proxy_classPrivateFieldGet(dn,this),operatorListIdx:t,operatorListLength:r,operationsFilterMask:o,lastChunk:s}).catch(e=>{if(!renderer_worker_proxy_classPrivateFieldGet(rn,this))throw e;return{operatorListIdx:t,aborted:!0}});if(l.aborted&&!renderer_worker_proxy_classPrivateFieldGet(rn,this))throw new Error("Render task was aborted in the renderer worker.");if(s&&l.operatorListIdx===r){renderer_worker_proxy_classPrivateFieldGet(gn,this).delete(renderer_worker_proxy_classPrivateFieldGet(dn,this));const{recordedBBoxesBuffer:e,imageCoordinates:t}=l;e&&(this.recordedBBoxes=BBoxReader.fromBuffer(e));this.imageCoordinates=t??null}return l.operatorListIdx}cancel(){renderer_worker_proxy_classPrivateFieldSet(rn,this,!0);renderer_worker_proxy_classPrivateFieldGet(gn,this).delete(renderer_worker_proxy_classPrivateFieldGet(dn,this));renderer_worker_proxy_classPrivateFieldGet(pn,this).messageHandler?.send("CleanupRenderTask",{renderTaskId:renderer_worker_proxy_classPrivateFieldGet(dn,this)})}drawFrame(e){try{if(e.bitmap){renderer_worker_proxy_classPrivateFieldGet(on,this).getNoAlphaContext(renderer_worker_proxy_classPrivateFieldGet(nn,this)).drawImage(e.bitmap,0,0)}e.annotationBitmaps&&renderer_worker_proxy_assertClassBrand(mn,this,_drawAnnotationCanvases).call(this,e.annotationBitmaps)}catch(e){renderer_worker_proxy_classPrivateFieldGet(hn,this).call(this,e);return}finally{closeFrame(e)}renderer_worker_proxy_classPrivateFieldGet(_n,this).call(this)}}function _drawAnnotationCanvases(e){const t=renderer_worker_proxy_classPrivateFieldGet(sn,this),i=new Set;for(const[a,s,r]of e){const{canvas:e,context:n}=renderer_worker_proxy_classPrivateFieldGet(on,this).create(r.width,r.height);n.drawImage(r,0,0);if(s){setAnnotationCanvasName(e,s);if(i.has(a))t.get(a).push(e);else{i.add(a);t.set(a,[e])}}else t.set(a,e)}}var fn=new WeakMap,vn=new WeakMap,Pn=new WeakMap,wn=new WeakMap,Fn=new WeakMap,yn=new WeakMap,bn=new WeakMap,Sn=new WeakMap,Cn=new WeakMap,xn=new WeakMap,kn=new WeakMap,En=new WeakMap,An=new WeakMap,Gn=new WeakMap,Bn=new WeakMap,Mn=new WeakMap,In=new WeakSet;class RendererWorker{constructor({port:e=null,verbosity:t=getVerbosityLevel(),enableHWA:i=!1,enableWebGPU:a=!1,cspPolicyService:s=null}={}){renderer_worker_proxy_classPrivateMethodInitSpec(this,In);renderer_worker_proxy_classPrivateFieldInitSpec(this,fn,Promise.withResolvers());renderer_worker_proxy_classPrivateFieldInitSpec(this,vn,null);renderer_worker_proxy_classPrivateFieldInitSpec(this,Pn,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,wn,void 0);renderer_worker_proxy_classPrivateFieldInitSpec(this,Fn,null);renderer_worker_proxy_classPrivateFieldInitSpec(this,yn,0);renderer_worker_proxy_classPrivateFieldInitSpec(this,bn,new WeakMap);renderer_worker_proxy_classPrivateFieldInitSpec(this,Sn,[]);renderer_worker_proxy_classPrivateFieldInitSpec(this,Cn,new Set);renderer_worker_proxy_classPrivateFieldInitSpec(this,xn,null);renderer_worker_proxy_classPrivateFieldInitSpec(this,kn,null);renderer_worker_proxy_classPrivateFieldInitSpec(this,En,0);renderer_worker_proxy_classPrivateFieldInitSpec(this,An,new Map);renderer_worker_proxy_classPrivateFieldInitSpec(this,Gn,null);renderer_worker_proxy_classPrivateFieldInitSpec(this,Bn,null);renderer_worker_proxy_classPrivateFieldInitSpec(this,Mn,null);renderer_worker_proxy_defineProperty(this,"destroyed",!1);this.verbosity=t;renderer_worker_proxy_classPrivateFieldSet(Pn,this,i);renderer_worker_proxy_classPrivateFieldSet(wn,this,a);renderer_worker_proxy_classPrivateFieldSet(vn,this,s);e?renderer_worker_proxy_assertClassBrand(In,this,_initializeFromPort).call(this,e):renderer_worker_proxy_assertClassBrand(In,this,_initialize).call(this)}static get isAvailable(){return(!!GlobalWorkerOptions.rendererSrc||GlobalWorkerOptions.rendererPorts.length>0)&&"undefined"!=typeof Worker&&FeatureTest.isOffscreenCanvasSupported&&!!globalThis.document?.fonts}get promise(){return renderer_worker_proxy_classPrivateFieldGet(fn,this).promise}get messageHandler(){return renderer_worker_proxy_classPrivateFieldGet(Fn,this)}get port(){return renderer_worker_proxy_classPrivateFieldGet(xn,this)}destroy(){this.destroyed=!0;if(renderer_worker_proxy_classPrivateFieldGet(xn,this)){if(renderer_worker_proxy_classPrivateFieldGet(Fn,this)){renderer_worker_proxy_assertClassBrand(In,this,_closeStrayFrames).call(this,renderer_worker_proxy_classPrivateFieldGet(xn,this));renderer_worker_proxy_classPrivateFieldGet(Fn,this).send("Disconnect",null)}Ln._.delete(renderer_worker_proxy_classPrivateFieldGet(xn,this));renderer_worker_proxy_classPrivateFieldSet(xn,this,null)}renderer_worker_proxy_classPrivateFieldGet(Gn,this)?.call(this,"Worker was destroyed.");renderer_worker_proxy_classPrivateFieldGet(Mn,this)?.abort();renderer_worker_proxy_classPrivateFieldSet(Mn,this,null);renderer_worker_proxy_classPrivateFieldGet(Bn,this)?.terminate();renderer_worker_proxy_classPrivateFieldSet(Bn,this,null);renderer_worker_proxy_classPrivateFieldGet(Fn,this)?.destroy();renderer_worker_proxy_classPrivateFieldSet(Fn,this,null);for(const e of renderer_worker_proxy_classPrivateFieldGet(Cn,this))e(new Error("Renderer worker was destroyed."));renderer_worker_proxy_classPrivateFieldGet(Cn,this).clear()}static create({ports:e=[],...t}={}){const i=e.find(e=>!renderer_worker_proxy_assertClassBrand(RendererWorker,this,Ln)._.has(e))??null;!i&&e.length>0&&warn("RendererWorker.create - no unused `rendererPorts` available, falling back to `rendererSrc`.");return new RendererWorker({...t,port:i})}sendWithPromise(e,t){const i=renderer_worker_proxy_classPrivateFieldGet(Fn,this);if(!i)return Promise.reject(new Error("Renderer worker was destroyed."));const{promise:a,resolve:s,reject:r}=Promise.withResolvers();renderer_worker_proxy_classPrivateFieldGet(Cn,this).add(r);i.sendWithPromise(e,t).then(s,r);return a.finally(()=>{renderer_worker_proxy_classPrivateFieldGet(Cn,this).delete(r)})}sendCommonObj(e,t,i){renderer_worker_proxy_assertClassBrand(In,this,_sendObj).call(this,"commonobj",[e,t,i],e,null,"Font"===t)}sendObj(e,t,i,a){renderer_worker_proxy_assertClassBrand(In,this,_sendObj).call(this,"obj",[e,t,i,a],e,t)}cleanup(e){renderer_worker_proxy_assertClassBrand(In,this,_send).call(this,"Cleanup",{keepLoadedFonts:e})}cleanupPage(e){renderer_worker_proxy_assertClassBrand(In,this,_send).call(this,"cleanupPage",{pageProxyId:e})}createRenderTask({pageProxyId:e,operatorList:t,params:i,pageColors:a,canvasFactory:s,annotationCanvasMap:r,onFrame:n,onError:o}){var l,d;const{canvas:c,canvasContext:h,background:_}=i;if(!renderer_worker_proxy_classPrivateFieldGet(Fn,this)&&!renderer_worker_proxy_classPrivateFieldGet(Sn,this)||h||_&&"string"!=typeof _||a||i.recordForDebugger)return null;const u=renderer_worker_proxy_classPrivateFieldGet(bn,this).getOrInsertComputed(t,()=>{var e,t;return{id:(renderer_worker_proxy_classPrivateFieldSet(yn,this,(e=renderer_worker_proxy_classPrivateFieldGet(yn,this),t=e++,e)),t),sentLength:0}});return new WorkerRenderTask({rendererWorker:this,renderTasks:renderer_worker_proxy_classPrivateFieldGet(An,this),canvas:c,canvasFactory:s,annotationCanvasMap:r,operatorListState:u,initParams:{pageProxyId:e,operatorListId:u.id,renderTaskId:(renderer_worker_proxy_classPrivateFieldSet(En,this,(l=renderer_worker_proxy_classPrivateFieldGet(En,this),d=l++,l)),d),hasAnnotationCanvasMap:!!r,recordOperations:i.recordOperations,recordImages:i.recordImages,partialFrames:i.partialFrames,transform:i.transform,viewport:i.viewport,background:_,pixelRatio:OutputScale.pixelRatio},onFrame:n,onError:o})}}function _resolve(){renderer_worker_proxy_classPrivateFieldGet(Fn,this).on("RenderFrame",e=>{const t=renderer_worker_proxy_classPrivateFieldGet(An,this).get(e.renderTaskId);t?t.drawFrame(e):closeFrame(e)});renderer_worker_proxy_classPrivateFieldGet(fn,this).resolve();renderer_worker_proxy_classPrivateFieldGet(Fn,this).send("configure",{verbosity:this.verbosity,enableHWA:renderer_worker_proxy_classPrivateFieldGet(Pn,this),enableWebGPU:renderer_worker_proxy_classPrivateFieldGet(wn,this)});const e=renderer_worker_proxy_classPrivateFieldGet(Sn,this);renderer_worker_proxy_classPrivateFieldSet(Sn,this,null);for(const t of e)t()}function _reject(e){renderer_worker_proxy_classPrivateFieldSet(Sn,this,null);renderer_worker_proxy_classPrivateFieldGet(fn,this).reject(e)}function _initializeFromPort(e){var t,i;Ln._.add(e);renderer_worker_proxy_classPrivateFieldSet(xn,this,e);const a=(Dn._=(t=Dn._,i=t++,t),i),s=`main${a}`,r=`renderer${a}`;renderer_worker_proxy_classPrivateFieldSet(kn,this,{sourceName:s,targetName:r});const n=new MessageHandler("main","renderer",e);n.send("Connect",{sourceName:r,targetName:s});n.destroy();renderer_worker_proxy_assertClassBrand(In,this,_waitForReady).call(this,e,new MessageHandler(s,r,e),!0)}function _initialize(){try{const{rendererSrc:e}=GlobalWorkerOptions;if(!e)throw new Error('No "GlobalWorkerOptions.rendererSrc" specified.');const t=getWorkerSrc(e),i=new Worker(renderer_worker_proxy_classPrivateFieldGet(vn,this)?.generateTrustedURL(t)??t,{type:"module"});renderer_worker_proxy_assertClassBrand(In,this,_waitForReady).call(this,i,new MessageHandler("main","renderer",i),!1)}catch(e){renderer_worker_proxy_assertClassBrand(In,this,_reject).call(this,e)}}function _waitForReady(e,t,i){let a=null;const terminateEarly=r=>{renderer_worker_proxy_classPrivateFieldSet(Gn,this,null);clearTimeout(a);s.abort();t.destroy();i?renderer_worker_proxy_classPrivateFieldSet(xn,this,null):e.terminate();renderer_worker_proxy_assertClassBrand(In,this,_reject).call(this,new Error(`Renderer worker failed to initialize: "${r?.message??r}".`))};renderer_worker_proxy_classPrivateFieldSet(Gn,this,terminateEarly);const s=new AbortController,onError=(e,t)=>{if(renderer_worker_proxy_classPrivateFieldGet(Fn,this)){e.preventDefault();warn(`Renderer worker failed: "${t}". Falling back to main-thread rendering.`);this.destroy()}else terminateEarly(t)};e.addEventListener("error",e=>onError(e,e.error?.message??e.message),{signal:s.signal});e.addEventListener("messageerror",e=>onError(e,"Cannot deserialize a message."),{signal:s.signal});i&&(a=setTimeout(()=>terminateEarly("Connection timed out."),5e3));t.on("ready",r=>{if(!(r?.testObj instanceof Uint8Array)){terminateEarly("TypedArray transfer test failed.");return}const n="6.5.1523";if(n===r.workerVersion){renderer_worker_proxy_classPrivateFieldSet(Gn,this,null);clearTimeout(a);renderer_worker_proxy_classPrivateFieldSet(Fn,this,t);i||renderer_worker_proxy_classPrivateFieldSet(Bn,this,e);renderer_worker_proxy_classPrivateFieldSet(Mn,this,s);renderer_worker_proxy_assertClassBrand(In,this,_resolve).call(this)}else terminateEarly(`The API version "${n}" does not match the Worker version "${r.workerVersion}".`)})}function _closeStrayFrames(e){const{sourceName:t,targetName:i}=renderer_worker_proxy_classPrivateFieldGet(kn,this),a=new AbortController,s=setTimeout(()=>a.abort(),5e3);e.addEventListener("message",({data:e})=>{if(e?.targetName===t&&e.sourceName===i)if("RenderFrame"===e.action)closeFrame(e.data);else if("Disconnected"===e.action){clearTimeout(s);a.abort()}},{signal:a.signal})}function _send(e,t){renderer_worker_proxy_classPrivateFieldGet(Sn,this)?renderer_worker_proxy_classPrivateFieldGet(Sn,this).push(()=>renderer_worker_proxy_assertClassBrand(In,this,_send).call(this,e,t)):renderer_worker_proxy_classPrivateFieldGet(Fn,this)?.send(e,t)}function _sendObj(e,t,i,a,s=!1){try{if(renderer_worker_proxy_classPrivateFieldGet(Sn,this)){const r=s?structuredClone(t):t;renderer_worker_proxy_classPrivateFieldGet(Sn,this).push(()=>renderer_worker_proxy_assertClassBrand(In,this,_sendObj).call(this,e,r,i,a));return}renderer_worker_proxy_classPrivateFieldGet(Fn,this)?.send(e,t)}catch(t){warn(`RendererWorker - failed to send "${e}": ${t}`);renderer_worker_proxy_assertClassBrand(In,this,_send).call(this,"objFailed",{id:i,pageProxyId:a,reason:t.message})}}var Tn,Dn={_:0},Ln={_:new WeakSet};function text_layer_classPrivateFieldInitSpec(e,t,i){text_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_classPrivateFieldGet(e,t){return e.get(text_layer_assertClassBrand(e,t))}function text_layer_classPrivateFieldSet(e,t,i){return e.set(text_layer_assertClassBrand(e,t),i),i}function text_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Rn=new WeakMap,On=new WeakMap,Nn=new WeakMap,Wn=new WeakMap,jn=new WeakMap,Vn=new WeakMap,Un=new WeakMap,zn=new WeakMap,Hn=new WeakMap,$n=new WeakMap,Xn=new WeakMap,Kn=new WeakMap,qn=new WeakMap,Yn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,eo=new WeakMap,to=new WeakMap,io=new WeakSet;class TextLayer{constructor({textContentSource:e,images:t,container:i,viewport:a}){!function text_layer_classPrivateMethodInitSpec(e,t){text_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,io);text_layer_classPrivateFieldInitSpec(this,Rn,Promise.withResolvers());text_layer_classPrivateFieldInitSpec(this,On,null);text_layer_classPrivateFieldInitSpec(this,Nn,!1);text_layer_classPrivateFieldInitSpec(this,Wn,!!globalThis.FontInspector?.enabled);text_layer_classPrivateFieldInitSpec(this,jn,null);text_layer_classPrivateFieldInitSpec(this,Vn,null);text_layer_classPrivateFieldInitSpec(this,Un,null);text_layer_classPrivateFieldInitSpec(this,zn,0);text_layer_classPrivateFieldInitSpec(this,Hn,0);text_layer_classPrivateFieldInitSpec(this,$n,OutputScale.pixelRatio);text_layer_classPrivateFieldInitSpec(this,Xn,null);text_layer_classPrivateFieldInitSpec(this,Kn,null);text_layer_classPrivateFieldInitSpec(this,qn,0);text_layer_classPrivateFieldInitSpec(this,Yn,0);text_layer_classPrivateFieldInitSpec(this,Zn,Object.create(null));text_layer_classPrivateFieldInitSpec(this,Qn,[]);text_layer_classPrivateFieldInitSpec(this,Jn,null);text_layer_classPrivateFieldInitSpec(this,eo,[]);text_layer_classPrivateFieldInitSpec(this,to,null);if(e instanceof ReadableStream)text_layer_classPrivateFieldSet(Jn,this,e);else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');text_layer_classPrivateFieldSet(Jn,this,new ReadableStream({start(t){t.enqueue(e);t.close()}}))}text_layer_classPrivateFieldSet(On,this,text_layer_classPrivateFieldSet(Kn,this,i));text_layer_classPrivateFieldSet(jn,this,t);text_layer_classPrivateFieldSet(Yn,this,a.scale*text_layer_classPrivateFieldGet($n,this));text_layer_classPrivateFieldSet(qn,this,a.rotation);text_layer_classPrivateFieldSet(Un,this,{div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:r,pageX:n,pageY:o}=a.rawDims;text_layer_classPrivateFieldSet(to,this,[1,0,0,-1,-n,o+r]);text_layer_classPrivateFieldSet(Hn,this,s);text_layer_classPrivateFieldSet(zn,this,r);_ensureMinFontSizeComputed.call(TextLayer);i.style.setProperty("--min-font-size",oo._);setLayerDimensions(i,a);text_layer_classPrivateFieldGet(Rn,this).promise.finally(()=>{lo._.delete(this);text_layer_classPrivateFieldSet(Un,this,null);text_layer_classPrivateFieldSet(Zn,this,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=FeatureTest.platform;return shadow(this,"fontFamilyMap",new Map([["sans-serif",(e&&t?"Calibri, ":"")+"sans-serif"],["monospace",(e&&t?"Lucida Console, ":"")+"monospace"]]))}render(){text_layer_classPrivateFieldGet(jn,this)&&text_layer_classPrivateFieldGet(On,this).append(text_layer_classPrivateFieldGet(jn,this).render());const pump=()=>{text_layer_classPrivateFieldGet(Xn,this).read().then(({value:e,done:t})=>{if(t)text_layer_classPrivateFieldGet(Rn,this).resolve();else{text_layer_classPrivateFieldGet(Vn,this)??text_layer_classPrivateFieldSet(Vn,this,e.lang);Object.assign(text_layer_classPrivateFieldGet(Zn,this),e.styles);text_layer_assertClassBrand(io,this,_processItems).call(this,e.items);pump()}},text_layer_classPrivateFieldGet(Rn,this).reject)};text_layer_classPrivateFieldSet(Xn,this,text_layer_classPrivateFieldGet(Jn,this).getReader());lo._.add(this);pump();return text_layer_classPrivateFieldGet(Rn,this).promise}update({viewport:e}){const t=e.scale*OutputScale.pixelRatio,i=e.rotation;if(i!==text_layer_classPrivateFieldGet(qn,this)){text_layer_classPrivateFieldSet(qn,this,i);setLayerDimensions(text_layer_classPrivateFieldGet(Kn,this),{rotation:i})}if(t!==text_layer_classPrivateFieldGet(Yn,this)){text_layer_classPrivateFieldSet(Yn,this,t);text_layer_classPrivateFieldSet($n,this,OutputScale.pixelRatio)}}cancel(){const e=new AbortException("TextLayer task cancelled.");text_layer_classPrivateFieldGet(Xn,this)?.cancel(e).catch(()=>{});text_layer_classPrivateFieldSet(Xn,this,null);text_layer_classPrivateFieldGet(Rn,this).reject(e)}get textDivs(){return text_layer_classPrivateFieldGet(eo,this)}get textContentItemsStr(){return text_layer_classPrivateFieldGet(Qn,this)}static cleanup(){if(!(text_layer_assertClassBrand(TextLayer,this,lo)._.size>0)){text_layer_assertClassBrand(TextLayer,this,so)._.clear();for(const{canvas:e}of text_layer_assertClassBrand(TextLayer,this,ro)._.values())e.remove();text_layer_assertClassBrand(TextLayer,this,ro)._.clear()}}}Tn=TextLayer;function _processItems(e){if(text_layer_classPrivateFieldGet(Nn,this))return;text_layer_classPrivateFieldGet(Un,this).ctx??=_getCtx.call(Tn,text_layer_classPrivateFieldGet(Vn,this));const t=text_layer_classPrivateFieldGet(eo,this),i=text_layer_classPrivateFieldGet(Qn,this);for(const a of e){if(t.length>1e5){warn("Ignoring additional textDivs for performance reasons.");text_layer_classPrivateFieldSet(Nn,this,!0);return}if(void 0!==a.str){i.push(a.str);text_layer_assertClassBrand(io,this,_appendText).call(this,a)}else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){const e=text_layer_classPrivateFieldGet(On,this);text_layer_classPrivateFieldSet(On,this,document.createElement("span"));text_layer_classPrivateFieldGet(On,this).classList.add("markedContent");a.id&&text_layer_classPrivateFieldGet(On,this).setAttribute("id",a.id);"Artifact"===a.tag&&(text_layer_classPrivateFieldGet(On,this).ariaHidden=!0);e.append(text_layer_classPrivateFieldGet(On,this))}else"endMarkedContent"===a.type&&text_layer_classPrivateFieldSet(On,this,text_layer_classPrivateFieldGet(On,this).parentNode)}}function _appendText(e){const t=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};text_layer_classPrivateFieldGet(eo,this).push(t);const a=Util.transform(text_layer_classPrivateFieldGet(to,this),e.transform);let s=Math.atan2(a[1],a[0]);const r=text_layer_classPrivateFieldGet(Zn,this)[e.fontName];r.vertical&&(s+=Math.PI/2);let n=text_layer_classPrivateFieldGet(Wn,this)&&r.fontSubstitution||r.fontFamily;n=Tn.fontFamilyMap.get(n)||n;const o=Math.hypot(a[2],a[3]),l=o*_getAscent.call(Tn,n,r,text_layer_classPrivateFieldGet(Vn,this));let d,c;if(0===s){d=a[4];c=a[5]-l}else{d=a[4]+l*Math.sin(s);c=a[5]-l*Math.cos(s)}const h=t.style;h.left=`${(100*d/text_layer_classPrivateFieldGet(Hn,this)).toFixed(2)}%`;h.top=`${(100*c/text_layer_classPrivateFieldGet(zn,this)).toFixed(2)}%`;const _=Math.round(100*o)/100;h.setProperty("--font-height",`${_}px`);h.fontFamily=n;i.fontSize=_;t.setAttribute("role","presentation");t.textContent=e.str;t.dir=e.dir;text_layer_classPrivateFieldGet(Wn,this)&&(t.dataset.fontName=r.fontSubstitutionLoadedName||e.fontName);0!==s&&(i.angle=s*(180/Math.PI));let u=!1;if(e.str.length>1)u=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),i=Math.abs(e.transform[3]);t!==i&&Math.max(t,i)/Math.min(t,i)>1.5&&(u=!0)}u&&(i.canvasWidth=r.vertical?e.height:e.width);text_layer_classPrivateFieldGet(Un,this).div=t;text_layer_classPrivateFieldGet(Un,this).properties=i;text_layer_assertClassBrand(io,this,_layout).call(this,text_layer_classPrivateFieldGet(Un,this));i.hasText&&text_layer_classPrivateFieldGet(On,this).append(t);if(i.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation");text_layer_classPrivateFieldGet(On,this).append(e)}}function _layout(e){const{div:t,properties:i,ctx:a}=e,{style:s}=t,{canvasWidth:r,fontSize:n}=i;if(0!==r&&0!==n&&i.hasText){const{fontFamily:e}=s,i=text_layer_classPrivateFieldGet($n,this),o=_quantizeFontSize.call(Tn,n*text_layer_classPrivateFieldGet(Yn,this)/i)*i;_ensureCtxFont.call(Tn,a,o,e);try{const{width:e}=a.measureText(t.textContent);e>0&&(transform=`scaleX(${r*text_layer_classPrivateFieldGet(Yn,this)/e}) ${transform}`)}catch(e){}const{width:l}=a.measureText(t.textContent);l>0&&s.setProperty("--scale-x",r*o/(l*n))}0!==i.angle&&s.setProperty("--rotate",`${i.angle}deg`)}function _getCtx(e=null){let t=text_layer_assertClassBrand(Tn,this,ro)._.get(e||="");if(!t){const i=document.createElement("canvas");i.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal";i.lang=e;i.width=i.height=0;document.body.append(i);t=i.getContext("2d",{alpha:!1,willReadFrequently:!0});text_layer_assertClassBrand(Tn,this,ro)._.set(e,t);text_layer_assertClassBrand(Tn,this,no)._.set(t,{size:0,family:""})}return t}function _quantizeFontSize(e){e=Math.fround(e);const t=Math.fround(131073*e);return Math.fround(t-Math.fround(t-e))}function _ensureCtxFont(e,t,i){const a=text_layer_assertClassBrand(Tn,this,no)._.get(e);if(t!==a.size||i!==a.family){e.font=`${t}px ${i}`;a.size=t;a.family=i}}function _ensureMinFontSizeComputed(){if(null!==text_layer_assertClassBrand(Tn,this,oo)._)return;const e=document.createElement("div");e.style.opacity=0;e.style.lineHeight=1;e.style.fontSize="1px";e.style.position="absolute";e.textContent="X";document.body.append(e);oo._=text_layer_assertClassBrand(Tn,this,e.getBoundingClientRect().height);e.remove()}function _getAscent(e,t,i){const a=text_layer_assertClassBrand(Tn,this,so)._.get(e);if(a)return a;const s=text_layer_assertClassBrand(Tn,this,_getCtx).call(this,i);text_layer_assertClassBrand(Tn,this,_ensureCtxFont).call(this,s,30,e);const r=s.measureText(""),n=r?.fontBoundingBoxAscent,o=Math.abs(r?.fontBoundingBoxDescent);let l=.8;if(n)l=n/(n+o);else{FeatureTest.platform.isFirefox&&warn("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");t.ascent?l=t.ascent:t.descent&&(l=1+t.descent)}text_layer_assertClassBrand(Tn,this,so)._.set(e,l);return l}var ao,so={_:new Map},ro={_:new Map},no={_:new WeakMap},oo={_:null},lo={_:new Set};function app_options_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}{var co=new Map;const{maxTouchPoints:e,platform:t,userAgent:i}=navigator,a=/Android/.test(i);(/\b(?:iPad|iPhone|iPod)(?=;)/.test(i)||"MacIntel"===t&&e>1||a)&&co.set("maxCanvasPixels",5242880);a&&co.set("useSystemFonts",!1)}const ho=1,_o=2,uo=4,po=8,go=16,mo=128,fo={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},vo=new Map([["allowedGlobalEvents",{value:null,kind:ho}],["canvasMaxAreaInBytes",{value:-1,kind:ho+uo}],["isInAutomation",{value:!1,kind:ho}],["localeProperties",{value:{lang:navigator.language||"en-US"},kind:ho}],["maxCanvasDim",{value:32767,kind:ho+_o}],["nimbusDataStr",{value:"",kind:ho}],["supportsCaretBrowsingMode",{value:!1,kind:ho}],["supportsDocumentFonts",{value:!0,kind:ho}],["supportsDownloading",{value:!0,kind:ho}],["supportsIntegratedFind",{value:!1,kind:ho}],["supportsMouseWheelZoomCtrlKey",{value:!0,kind:ho}],["supportsMouseWheelZoomMetaKey",{value:!0,kind:ho}],["supportsPinchToZoom",{value:!0,kind:ho}],["supportsPrinting",{value:!0,kind:ho}],["toolbarDensity",{value:0,kind:ho+go}],["defaultCacheSize",{value:50,kind:_o}],["passwordPrompt",{value:null,kind:_o}],["enableDragAndDrop",{value:!0,kind:_o}],["pageViewMode",{value:"multiple",kind:_o}],["findController",{value:null,kind:_o}],["secondaryFindController",{value:null,kind:_o}],["maxZoom",{value:10,kind:_o}],["minZoom",{value:.1,kind:_o}],["pdfBackgroundColor",{value:"",kind:_o+mo}],["removePageBorders",{value:!1,kind:_o+mo}],["readingDirection",{value:"auto",kind:_o+mo}],["enablePageReordering",{value:!0,kind:_o+mo}],["altTextLearnMoreUrl",{value:"",kind:_o+mo}],["annotationEditorMode",{value:0,kind:_o+mo}],["annotationMode",{value:2,kind:_o+mo}],["capCanvasAreaFactor",{value:200,kind:_o+mo}],["commentLearnMoreUrl",{value:"",kind:_o+mo}],["cursorToolOnLoad",{value:0,kind:_o+mo}],["debuggerSrc",{value:"./debugger.mjs",kind:_o}],["defaultUrl",{value:"compressed.tracemonkey-pldi-09.pdf",kind:_o}],["defaultZoomDelay",{value:400,kind:_o+mo}],["defaultZoomValue",{value:"auto",kind:_o+mo}],["disableHistory",{value:!1,kind:_o}],["disablePageLabels",{value:!1,kind:_o+mo}],["disablePreferences",{value:!1,kind:_o}],["enableAltText",{value:!1,kind:_o+mo}],["enableAltTextModelDownload",{value:!0,kind:_o+mo+go}],["enableAutoLinking",{value:!0,kind:_o+mo}],["enableComment",{value:!1,kind:_o+mo}],["enableDetailCanvas",{value:!0,kind:_o}],["enableEraser",{value:!1,kind:_o+mo}],["enableGuessAltText",{value:!0,kind:_o+mo+go}],["enableHighlightFloatingButton",{value:!1,kind:_o+mo}],["enableMerge",{value:!1,kind:_o+mo}],["enableNewAltTextWhenAddingImage",{value:!0,kind:_o+mo}],["enableNewBadge",{value:!1,kind:_o+mo}],["enableNova",{value:!0,kind:_o+mo}],["enableOptimizedPartialRendering",{value:!1,kind:_o+mo}],["enablePermissions",{value:!1,kind:_o+mo}],["enablePrintAutoRotate",{value:!0,kind:_o+mo}],["enableScripting",{value:!1,kind:_o+mo}],["enableSelectionRendering",{value:!0,kind:_o+mo}],["enableSignatureEditor",{value:!1,kind:_o+mo}],["enableSignatureVerification",{value:!1,kind:_o+mo}],["enableSplitMerge",{value:!1,kind:_o+mo}],["enableUpdatedAddImage",{value:!1,kind:_o+mo}],["externalLinkRel",{value:"noopener noreferrer nofollow",kind:_o}],["externalLinkTarget",{value:0,kind:_o+mo}],["highlightEditorColors",{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F,yellow_HCM=#FFFFCC,green_HCM=#53FFBC,blue_HCM=#80EBFF,pink_HCM=#F6B8FF,red_HCM=#C50043",kind:_o+mo}],["historyUpdateUrl",{value:!1,kind:_o+mo}],["ignoreDestinationZoom",{value:!1,kind:_o+mo}],["imageResourcesPath",{value:"./images/",kind:_o}],["imagesRightClickMinSize",{value:-1,kind:_o+mo}],["maxCanvasPixels",{value:2**25,kind:_o}],["minDurationToUpdateCanvas",{value:500,kind:_o}],["forcePageColors",{value:!1,kind:_o+mo}],["pageColorsBackground",{value:"Canvas",kind:_o+mo}],["pageColorsForeground",{value:"CanvasText",kind:_o+mo}],["pdfBugEnabled",{value:!1,kind:_o+mo}],["postMessageAfterPrintCallback",{value:!1,kind:_o+mo}],["printResolution",{value:150,kind:_o}],["sandboxBundleSrc",{value:"../build/pdf.sandbox.mjs",kind:_o}],["sidebarViewOnLoad",{value:-1,kind:_o+mo}],["scrollModeOnLoad",{value:-1,kind:_o+mo}],["spreadModeOnLoad",{value:-1,kind:_o+mo}],["textLayerMode",{value:1,kind:_o+mo}],["viewerCssTheme",{value:0,kind:_o+mo}],["viewOnLoad",{value:0,kind:_o+mo}],["useWasm",{value:!0,kind:uo}],["cMapPacked",{value:!0,kind:uo}],["cMapUrl",{value:"../web/cmaps/",kind:uo}],["disableAutoFetch",{value:!1,kind:uo+mo}],["disableFontFace",{value:!1,kind:uo+mo}],["disableRange",{value:!1,kind:uo+mo}],["disableStream",{value:!1,kind:uo+mo}],["disableWorkerRendering",{value:!0,kind:uo+mo}],["docBaseUrl",{value:"",kind:uo}],["enableHWA",{value:!0,kind:uo+mo}],["enableWebGPU",{value:!0,kind:uo+mo}],["enableXfa",{value:!0,kind:uo+mo}],["fontExtraProperties",{value:!1,kind:uo}],["iccUrl",{value:"../web/iccs/",kind:uo}],["isOffscreenCanvasSupported",{value:!0,kind:uo}],["maxImageSize",{value:-1,kind:uo}],["pdfBug",{value:!1,kind:uo}],["standardFontDataUrl",{value:"../web/standard_fonts/",kind:uo}],["useSystemFonts",{value:void 0,kind:uo,type:fo.BOOLEAN+fo.UNDEFINED}],["verbosity",{value:1,kind:uo}],["wasmUrl",{value:"../web/wasm/",kind:uo}],["enableOpenActionJavaScript",{value:!1,kind:po}],["enableCatalogAAJavaScript",{value:!1,kind:po}],["rendererPorts",{value:[],kind:po}],["rendererSrc",{value:"../build/pdf.renderer.mjs",kind:po}],["workerPort",{value:null,kind:po}],["workerSrc",{value:"../build/pdf.worker.mjs",kind:po}]]);class AppOptions{static get(e){return app_options_assertClassBrand(AppOptions,this,wo)._.get(e)}static getAll(e=null,t=!1){const i=Object.create(null);for(const[a,s]of vo)(!e||e&s.kind)&&(i[a]=t?s.value:app_options_assertClassBrand(AppOptions,this,wo)._.get(a));return i}static set(e,t){this.setAll({[e]:t})}static setAll(e,t=!1){this._hasInvokedSet||=!0;let i;for(const a in e){if("positionPopupDialogsWithJavaScript"===a)continue;const s=vo.get(a);let r=e[a];if(s&&!(typeof r==typeof s.value||fo[(typeof r).toUpperCase()]&s.type)){"number"==typeof s?.value&&"string"==typeof r&&(Number.isNaN(Number(r))||(r=Number(r)));if(!(typeof r==typeof s.value||fo[(typeof r).toUpperCase()]&s.type||["maxZoom","minZoom","passwordPrompt","defaultZoomValue","findController","pdfBackgroundColor"].includes(a))){console.error("Invalid AppOptions value: "+a+" = "+r);continue}}const n=s?.kind;if(!t||n&ho||n&mo){this.eventBus&&n&go&&(i??=new Map).set(a,r);app_options_assertClassBrand(AppOptions,this,wo)._.set(a,r)}else console.error("Invalid AppOptions parameter: "+a+" = "+r)}i?.forEach((e,t)=>{this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})})}}ao=AppOptions;!function app_options_defineProperty(e,t,i){return(t=function app_options_toPropertyKey(e){var t=function app_options_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(AppOptions,"eventBus",void 0);var Po,wo={_:new Map};(()=>{for(const[e,t]of vo)app_options_assertClassBrand(ao,ao,wo)._.set(e,t.value);for(const[e,t]of co)app_options_assertClassBrand(ao,ao,wo)._.set(e,t);ao._hasInvokedSet=!1;ao._checkDisablePreferences=()=>{if(ao.get("disablePreferences"))return!0;ao._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.');return!1}})();function api_classPrivateGetter(e,t,i){return i(api_assertClassBrand(e,t))}function api_classPrivateMethodInitSpec(e,t){api_checkPrivateRedeclaration(e,t),t.add(e)}function api_classPrivateFieldInitSpec(e,t,i){api_checkPrivateRedeclaration(e,t),t.set(e,i)}function api_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function api_classPrivateFieldSet(e,t,i){return e.set(api_assertClassBrand(e,t),i),i}function api_classPrivateFieldGet(e,t){return e.get(api_assertClassBrand(e,t))}function api_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function api_defineProperty(e,t,i){return(t=function api_toPropertyKey(e){var t=function api_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function getDocument(e={}){const i=new PDFDocumentLoadingTask,{docId:a}=i,s=e.url?function getUrlProp(e,i){if(e instanceof URL)return e;if("string"==typeof e){if(t){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}if(i)return new URL(e,window.location.origin+i);const a=URL.parse(e,window.location);if(a)return a}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url,e.baseHref):null,r=e.data?function getDataProp(e){if(t&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return stringToBytes(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,n=e.httpHeaders||null,o=!0===e.withCredentials,l=e.password??null,d=e.range instanceof PDFDataRangeTransport?e.range:null,c=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:65536;let h=e.worker instanceof PDFWorker?e.worker:null;const _=e.verbosity,u="string"!=typeof e.docBaseUrl||isDataScheme(e.docBaseUrl)?null:e.docBaseUrl,p=getFactoryUrlProp("function"==typeof e.cMapUrl?e.cMapUrl():"string"==typeof e.cMapUrl?e.cMapUrl:null),g=!1!==e.cMapPacked,m=getFactoryUrlProp(e.iccUrl),f=getFactoryUrlProp("function"==typeof e.standardFontDataUrl?e.standardFontDataUrl():"string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null),v=getFactoryUrlProp(e.wasmUrl),P=!0!==e.stopAtErrors,w=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,F="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!t,y="boolean"==typeof e.isImageDecoderSupported?e.isImageDecoderSupported:!t,b=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,S="boolean"==typeof e.disableFontFace?e.disableFontFace:t,C=!0===e.fontExtraProperties,x=!0===e.enableXfa,k=e.ownerDocument||globalThis.document,E=!0===e.disableRange,A=!0===e.disableStream,G=!0===e.disableAutoFetch,B=!0===e.pdfBug,M=e.CanvasFactory||(t?NodeCanvasFactory:DOMCanvasFactory),I=e.FilterFactory||(t?NodeFilterFactory:DOMFilterFactory),T=e.BinaryDataFactory||(t?NodeBinaryDataFactory:DOMBinaryDataFactory),D=!0===e.enableHWA,L=!0===e.enableWebGPU;L&&initGPU();const R=!1!==e.useWasm,O=e.pagesMapper||new PagesMapper,N="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!t&&!S,W="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:!!(T===DOMBinaryDataFactory&&p&&g&&f&&v&&isValidFetchUrl(p,document.baseURI)&&isValidFetchUrl(f,document.baseURI)&&isValidFetchUrl(v,document.baseURI)),j=!0===e.disableWorkerRendering||!F||k!==globalThis.document||!RendererWorker.isAvailable;setVerbosityLevel(_);const V={canvasFactory:new M({ownerDocument:k,enableHWA:D}),filterFactory:new I({docId:a,ownerDocument:k}),binaryDataFactory:W?null:new T({cMapUrl:p,standardFontDataUrl:f,wasmUrl:v})};if(!h){const t={verbosity:_,port:GlobalWorkerOptions.workerPort,cspPolicyService:e.cspPolicyService};h=PDFWorker.create(t);i._worker=h}if(!j){const t=RendererWorker.create({verbosity:_,enableHWA:D,enableWebGPU:L,ports:GlobalWorkerOptions.rendererPorts,cspPolicyService:e.cspPolicyService});t.promise.catch(e=>{if(!t.destroyed){warn(`Renderer worker disabled: ${e.message}`);t.destroy()}});i._rendererWorker=t}const U={docId:a,apiVersion:"6.5.1523",data:r,password:l,disableAutoFetch:G,rangeChunkSize:c,docBaseUrl:u,enableXfa:x,enableOpenActionJavaScript:AppOptions.get("enableOpenActionJavaScript"),enableCatalogAAJavaScript:AppOptions.get("enableCatalogAAJavaScript"),evaluatorOptions:{maxImageSize:w,disableFontFace:S,ignoreErrors:P,isOffscreenCanvasSupported:F,isImageDecoderSupported:y,canvasMaxAreaInBytes:b,fontExtraProperties:C,useSystemFonts:N,useWasm:R,useWorkerFetch:W,cMapUrl:p,cMapPacked:g,iccUrl:m,standardFontDataUrl:f,wasmUrl:v}},z={ownerDocument:k,pdfBug:B,styleElement:null,rendererWorker:i._rendererWorker,enableWebGPU:L,loadingParams:{disableAutoFetch:G,enableXfa:x}};h.promise.then(function(){if(h.destroyed)throw new Error("Worker was destroyed");const e=h.messageHandler.sendWithPromise("GetDocRequest",U,r?[r.buffer]:null);let l;if(r);else if(d)l=new PDFDataTransportStream({pdfDataRangeTransport:d,disableRange:E,disableStream:A});else{if(!s)throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");{const e=function getNetworkStream(e){return isValidFetchUrl(e)?PDFFetchStream:t?PDFNodeStream:PDFNetworkStream}(s);l=new e({url:s,httpHeaders:n,withCredentials:o,rangeChunkSize:c,disableRange:E,disableStream:A})}}return e.then(e=>{if(h.destroyed)throw new Error("Worker was destroyed");const t=new MessageHandler(a,e,h.port),s=new WorkerTransport(t,i,l,z,V,O);i._transport=s;if(i.destroyed)throw new Error("Loading aborted");t.send("Ready",null)})}).catch(i._capability.reject).finally(i._setupCapability.resolve);return i}class PDFDocumentLoadingTask{constructor(){api_defineProperty(this,"_capability",Promise.withResolvers());api_defineProperty(this,"_setupCapability",Promise.withResolvers());api_defineProperty(this,"_transport",null);api_defineProperty(this,"_worker",null);api_defineProperty(this,"_rendererWorker",null);api_defineProperty(this,"docId",`d${ngxNextPageWideId("docId")}`);api_defineProperty(this,"destroyed",!1);api_defineProperty(this,"onPassword",null);api_defineProperty(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0);await this._setupCapability.promise;await(this._transport?.destroy())}catch(e){this._worker?.port&&delete this._worker._pendingDestroy;throw e}finally{this._rendererWorker?.destroy();this._rendererWorker=null}this._transport=null;this._worker?.destroy();this._worker=null}async getData(){return this._transport.getData()}}var Fo=new WeakMap,yo=new WeakMap;class PDFDataRangeTransport{constructor(e,t,i=!1,a=null){api_classPrivateFieldInitSpec(this,Fo,Promise.withResolvers());api_classPrivateFieldInitSpec(this,yo,null);this.length=e;this.initialData=t;this.progressiveDone=i;this.contentDispositionFilename=a}onDataRange(e,t){api_classPrivateFieldGet(yo,this).call(this,{type:"range",begin:e,chunk:t})}onDataProgressiveRead(e){api_classPrivateFieldGet(Fo,this).promise.then(()=>{api_classPrivateFieldGet(yo,this).call(this,{type:"progressiveRead",chunk:e})})}onDataProgressiveDone(){api_classPrivateFieldGet(Fo,this).promise.then(()=>{api_classPrivateFieldGet(yo,this).call(this,{type:"progressiveDone"})})}transportReady(e){api_classPrivateFieldSet(yo,this,e);api_classPrivateFieldGet(Fo,this).resolve()}requestDataRange(e,t){unreachable("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e;this._transport=t}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return shadow(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(e){return this._transport.getAttachmentContent(e)}getAnnotationsByType(e,t){return this._transport.getAnnotationsByType(e,t)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(e=null,t=null){return this._transport.saveDocument(e,t)}extractPages(e,t=null){return this._transport.extractPages(e,t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(e){return this._transport.getSignatureData(e)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var bo=new WeakMap,So=new WeakMap,Co=new WeakSet;class PDFPageProxy{constructor(e,t,i,a,s=!1){var r,n;api_classPrivateMethodInitSpec(this,Co);api_classPrivateFieldInitSpec(this,bo,!1);api_classPrivateFieldInitSpec(this,So,null);this._pageIndex=e;this._id=(xo._=(r=xo._,n=r++,r),n);this._pageInfo=t;this._transport=i;this._stats=s?new StatTimer:null;this._pdfBug=s;this.commonObjs=i.commonObjs;this.objs=new PDFObjects;this._intentStates=new Map;this.destroyed=!1;this.recordedBBoxes=null;api_classPrivateFieldSet(So,this,a);this.imageCoordinates=null}clone(e){const t=new PDFPageProxy(e,this._pageInfo,this._transport,api_classPrivateFieldGet(So,this),this._pdfBug);t.clonedFromIndex=this.clonedFromIndex??this._pageIndex;this._transport.updatePage(t);return t}get pageNumber(){return this._pageIndex+1}set pageNumber(e){this._pageIndex=e-1;this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:i=0,offsetY:a=0,dontFlip:s=!1}={}){return new PageViewport({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:i,offsetY:a,dontFlip:s})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return shadow(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,canvas:t=e.canvas,viewport:i,intent:a="display",annotationMode:s=p.ENABLE,transform:r=null,background:n=null,optionalContentConfigPromise:o=null,annotationCanvasMap:d=null,pageColors:c=null,printAnnotationStorage:h=null,isEditing:_=!1,recordImages:u=!1,recordOperations:g=!1,partialFrames:m=!1,operationsFilter:f=null}){this._stats?.time("Overall");const v=this._transport.getRenderingIntent(a,s,h,_),{renderingIntent:P,cacheKey:w}=v;api_classPrivateFieldSet(bo,this,!1);o||=this._transport.getOptionalContentConfig(P);const F=this._intentStates.getOrInsertComputed(w,makeObj);if(F.streamReaderCancelTimeout){clearTimeout(F.streamReaderCancelTimeout);F.streamReaderCancelTimeout=null}const y=!!(P&l);if(!F.displayReadyCapability){F.displayReadyCapability=Promise.withResolvers();F.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(v)}const b=!(!this._pdfBug||!globalThis.StepperManager?.enabled),S=!!t&&!this.recordedBBoxes&&(g||b),C=!!t&&!this.imageCoordinates&&u,complete=e=>{F.renderTasks.delete(x);if(S){const{recordedBBoxes:e}=x;if(e){x.stepper?.setOperatorBBoxes(e,x.debugMetadata);g&&(this.recordedBBoxes=e)}}C&&!e&&(this.imageCoordinates=x.imageCoordinates);y&&api_classPrivateFieldSet(bo,this,!0);api_assertClassBrand(Co,this,_tryCleanup).call(this);if(e){x.capability.reject(e);this._abortOperatorList({intentState:F,reason:e instanceof Error?e:new Error(e)})}else x.capability.resolve();if(this._stats){this._stats.timeEnd("Rendering");this._stats.timeEnd("Overall");globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats)}},x=new InternalRenderTask({callback:complete,params:{canvas:t,canvasContext:e,viewport:i,transform:r,background:n,recordOperations:S,recordImages:C,partialFrames:m,recordForDebugger:b},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:d,operatorList:F.operatorList,pageIndex:this._pageIndex,pageProxyId:this._id,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!y,pdfBug:this._pdfBug,pageColors:c,operationsFilter:f,rendererWorker:this._transport.rendererWorker,waitForGPU:()=>this._transport.waitForGPU()});(F.renderTasks||=new Set).add(x);const k=x.task;Promise.all([F.displayReadyCapability.promise,o]).then(async([e,t])=>{if(this.destroyed)complete();else{this._stats?.time("Rendering");if(!(t.renderingIntent&P))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");await x.initializeGraphics({transparency:e,optionalContentConfig:t});x.operatorListChanged()}}).catch(complete);return k}getOperatorList({intent:e="display",annotationMode:t=p.ENABLE,printAnnotationStorage:i=null,isEditing:a=!1}={}){const s=this._transport.getRenderingIntent(e,t,i,a,!0),r=this._intentStates.getOrInsertComputed(s.cacheKey,makeObj);let n;if(!r.opListReadCapability){n=Object.create(null);n.operatorListChanged=function operatorListChanged(){if(r.operatorList.lastChunk){r.opListReadCapability.resolve(r.operatorList);r.renderTasks.delete(n)}};r.opListReadCapability=Promise.withResolvers();(r.renderTasks||=new Set).add(n);r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(s)}return r.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:api_classPrivateFieldGet(So,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}async getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(e=>XfaText.textContent(e));const t=this.streamTextContent(e).getReader(),i={items:[],styles:Object.create(null),lang:null};for(;;){const{value:e,done:a}=await t.read();if(a)break;i.lang??=e.lang;Object.assign(i.styles,e.styles);i.items.push(...e.items)}return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values()){this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0});if(!t.opListReadCapability)for(const i of t.renderTasks){e.push(i.completed);i.cancel()}}this.objs.clear();this._transport.cleanupPage(this._id);api_classPrivateFieldSet(bo,this,!1);return Promise.all(e)}cleanup(e=!1){api_classPrivateFieldSet(bo,this,!0);const t=api_assertClassBrand(Co,this,_tryCleanup).call(this);e&&t&&(this._stats&&=new StatTimer);return t}_startRenderPage(e,t){const i=this._intentStates.get(t);if(i){this._stats?.timeEnd("Page Request");i.displayReadyCapability?.resolve(e)}}_renderPageChunk(e,t){for(let i=0,a=e.length;i<a;i++){t.operatorList.fnArray.push(e.fnArray[i]);t.operatorList.argsArray.push(e.argsArray[i])}t.operatorList.lastChunk=e.lastChunk;t.operatorList.separateAnnots=e.separateAnnots;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&api_assertClassBrand(Co,this,_tryCleanup).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:i,modifiedIds:a}){const{map:s,transfer:r}=i,n=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:api_classPrivateFieldGet(So,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,pageProxyId:this._id,intent:e,cacheKey:t,annotationStorage:s,modifiedIds:a},void 0,r).getReader(),o=this._intentStates.get(t);o.streamReader=n;const pump=()=>{n.read().then(({value:e,done:t})=>{if(t)o.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(e,o);pump()}},e=>{o.streamReader=null;if(!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const e of o.renderTasks)e.operatorListChanged();api_assertClassBrand(Co,this,_tryCleanup).call(this)}if(o.displayReadyCapability)o.displayReadyCapability.reject(e);else{if(!o.opListReadCapability)throw e;o.opListReadCapability.reject(e)}}})};pump()}_abortOperatorList({intentState:e,reason:t,force:i=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout){clearTimeout(e.streamReaderCancelTimeout);e.streamReaderCancelTimeout=null}if(!i){if(e.renderTasks.size>0)return;if(t instanceof RenderingCancelledException){let i=100;t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay);e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null;this._abortOperatorList({intentState:e,reason:t,force:!0})},i);return}}e.streamReader.cancel(new AbortException(t.message)).catch(()=>{});e.streamReader=null;if(!this._transport.destroyed){for(const[t,i]of this._intentStates)if(i===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}function _tryCleanup(){if(!api_classPrivateFieldGet(bo,this)||this.destroyed)return!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;this._intentStates.clear();this.objs.clear();this._transport.cleanupPage(this._id);api_classPrivateFieldSet(bo,this,!1);return!0}var xo={_:0},ko=new WeakMap,Eo=new WeakMap,Ao=new WeakMap,Go=new WeakMap,Bo=new WeakSet;class PDFWorker{constructor({name:e=null,port:t=null,verbosity:i=getVerbosityLevel(),cspPolicyService:a}={}){api_classPrivateMethodInitSpec(this,Bo);api_classPrivateFieldInitSpec(this,ko,Promise.withResolvers());api_classPrivateFieldInitSpec(this,Eo,null);api_classPrivateFieldInitSpec(this,Ao,null);api_classPrivateFieldInitSpec(this,Go,null);this.name=e;this.destroyed=!1;this.verbosity=i;if(t){if(To._.has(t))throw new Error("Cannot use more than one PDFWorker per port.");To._.set(t,this);api_assertClassBrand(Bo,this,api_initializeFromPort).call(this,t)}else this._initialize(a)}get promise(){return api_classPrivateFieldGet(ko,this).promise}get port(){return api_classPrivateFieldGet(Ao,this)}get messageHandler(){return api_classPrivateFieldGet(Eo,this)}_initialize(e){if(Io._||_get_mainThreadWorkerMessageHandler(PDFWorker)){api_assertClassBrand(Bo,this,_setupFakeWorker).call(this);return}const{workerSrc:t}=PDFWorker;try{const i=new Worker(e.generateTrustedURL(getWorkerSrc(t)),{type:"module"}),a=new MessageHandler("main","worker",i),terminateEarly=()=>{s.abort();a.destroy();i.terminate();this.destroyed?api_classPrivateFieldGet(ko,this).reject(new Error("Worker was destroyed")):api_assertClassBrand(Bo,this,_setupFakeWorker).call(this)},s=new AbortController;i.addEventListener("error",()=>{api_classPrivateFieldGet(Go,this)||terminateEarly()},{signal:s.signal});a.on("ready",e=>{s.abort();if(!this.destroyed&&e instanceof Uint8Array){api_classPrivateFieldSet(Eo,this,a);api_classPrivateFieldSet(Ao,this,i);api_classPrivateFieldSet(Go,this,i);api_assertClassBrand(Bo,this,api_resolve).call(this)}else terminateEarly()})}catch{info("The worker has been disabled.");api_assertClassBrand(Bo,this,_setupFakeWorker).call(this)}}destroy(){this.destroyed=!0;api_classPrivateFieldGet(Go,this)?.terminate();api_classPrivateFieldSet(Go,this,null);To._.delete(api_classPrivateFieldGet(Ao,this));api_classPrivateFieldSet(Ao,this,null);api_classPrivateFieldGet(Eo,this)?.destroy();api_classPrivateFieldSet(Eo,this,null)}static create(e){const t=api_assertClassBrand(PDFWorker,this,To)._.get(e?.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new PDFWorker(e)}static get workerSrc(){if(GlobalWorkerOptions.workerSrc)return GlobalWorkerOptions.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return shadow(this,"_setupFakeWorkerGlobal",(async()=>{if(api_classPrivateGetter(PDFWorker,this,_get_mainThreadWorkerMessageHandler))return api_classPrivateGetter(PDFWorker,this,_get_mainThreadWorkerMessageHandler);return(await(import(
/*webpackIgnore: true*/
/*@vite-ignore*/
this.workerSrc))).WorkerMessageHandler})())}}Po=PDFWorker;function api_resolve(){api_classPrivateFieldGet(ko,this).resolve();api_classPrivateFieldGet(Eo,this).send("configure",{verbosity:this.verbosity})}function api_initializeFromPort(e){api_classPrivateFieldSet(Ao,this,e);api_classPrivateFieldSet(Eo,this,new MessageHandler("main","worker",e));api_classPrivateFieldGet(Eo,this).on("ready",()=>{});api_assertClassBrand(Bo,this,api_resolve).call(this)}function _setupFakeWorker(){if(!Io._){warn("Setting up fake worker.");Io._=!0}Po._setupFakeWorkerGlobal.then(e=>{var t,i;if(this.destroyed){api_classPrivateFieldGet(ko,this).reject(new Error("Worker was destroyed"));return}const a=new LoopbackPort;api_classPrivateFieldSet(Ao,this,a);const s=`fake${Mo._=(t=Mo._,i=t++,t),i}`,r=new MessageHandler(s+"_worker",s,a);e.setup(r,a);api_classPrivateFieldSet(Eo,this,new MessageHandler(s,s+"_worker",a));api_assertClassBrand(Bo,this,api_resolve).call(this)}).catch(e=>{api_classPrivateFieldGet(ko,this).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}function _get_mainThreadWorkerMessageHandler(e){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}var Mo={_:0},Io={_:!1},To={_:new WeakMap};(()=>{if(t){Io._=api_assertClassBrand(Po,Po,!0);GlobalWorkerOptions.workerSrc||="./pdf.worker.mjs"}})();var Do=new WeakMap,Lo=new WeakMap,Ro=new WeakMap,Oo=new WeakMap,No=new WeakMap,Wo=new WeakMap,jo=new WeakMap,Vo=new WeakMap,Uo=new WeakMap,zo=new WeakSet;class WorkerTransport{constructor(e,t,i,a,s,r){api_classPrivateMethodInitSpec(this,zo);api_defineProperty(this,"downloadInfoCapability",Promise.withResolvers());api_classPrivateFieldInitSpec(this,Do,null);api_classPrivateFieldInitSpec(this,Lo,!1);api_classPrivateFieldInitSpec(this,Ro,new Map);api_classPrivateFieldInitSpec(this,Oo,null);api_classPrivateFieldInitSpec(this,No,new Map);api_classPrivateFieldInitSpec(this,Wo,new Map);api_classPrivateFieldInitSpec(this,jo,new Map);api_classPrivateFieldInitSpec(this,Vo,null);api_classPrivateFieldInitSpec(this,Uo,null);this.messageHandler=e;this.loadingTask=t;api_classPrivateFieldSet(Oo,this,i);this.commonObjs=new PDFObjects;this.fontLoader=new FontLoader({ownerDocument:a.ownerDocument,styleElement:a.styleElement});this.rendererWorker=a.rendererWorker;this.loadingParams=a.loadingParams;this._params=a;this.canvasFactory=s.canvasFactory;this.filterFactory=s.filterFactory;this.binaryDataFactory=s.binaryDataFactory;this.pagesMapper=r;this.destroyed=!1;this.destroyCapability=null;this.setupMessageHandler()}updatePage(e){api_classPrivateFieldGet(No,this).set(e._id,e);api_classPrivateFieldGet(Wo,this).set(e._pageIndex,Promise.resolve(e))}get annotationStorage(){return shadow(this,"annotationStorage",new AnnotationStorage)}getRenderingIntent(e,t=p.ENABLE,i=null,a=!1,s=!1){let r=o,g=Zi;switch(e){case"any":r=n;break;case"display":break;case"print":r=l;break;default:warn(`getRenderingIntent - invalid intent: ${e}`)}const m=r&l&&i instanceof PrintAnnotationStorage?i:this.annotationStorage;switch(t){case p.DISABLE:r+=h;break;case p.ENABLE:break;case p.ENABLE_FORMS:r+=d;break;case p.ENABLE_STORAGE:r+=c;g=m.serializable;break;default:warn(`getRenderingIntent - invalid annotationMode: ${t}`)}a&&(r+=_);s&&(r+=u);const{ids:f,hash:v}=m.modifiedIds;return{renderingIntent:r,cacheKey:[r,g.hash,v].join("_"),annotationStorageSerializable:g,modifiedIds:f}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0;this.destroyCapability=Promise.withResolvers();api_classPrivateFieldGet(Vo,this)?.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of api_classPrivateFieldGet(No,this).values())e.push(t._destroy());api_classPrivateFieldGet(No,this).clear();api_classPrivateFieldGet(Wo,this).clear();api_classPrivateFieldGet(jo,this).clear();Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);e.push(t);Promise.all(e).then(()=>{this.commonObjs.clear();this.fontLoader.clear();api_classPrivateFieldGet(Ro,this).clear();this.filterFactory.destroy();TextLayer.cleanup();api_classPrivateFieldGet(Oo,this)?.cancelAllRequests(new AbortException("Worker was terminated."));this.messageHandler?.destroy();this.messageHandler=null;this.rendererWorker=null;this.destroyCapability.resolve()},this.destroyCapability.reject);return this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(e,t)=>{assert(api_classPrivateFieldGet(Oo,this),"GetReader - no `BasePDFStream` instance available.");api_classPrivateFieldSet(Do,this,api_classPrivateFieldGet(Oo,this).getFullReader());api_classPrivateFieldGet(Do,this).onProgress=e=>api_assertClassBrand(zo,this,api_onProgress).call(this,e);t.onPull=()=>{api_classPrivateFieldGet(Do,this).read().then(function({value:e,done:i}){if(i)t.close();else{assert(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}}).catch(e=>{t.error(e)})};t.onCancel=e=>{api_classPrivateFieldGet(Do,this).cancel(e);t.ready.catch(e=>{if(!this.destroyed)throw e})}});e.on("ReaderHeadersReady",async e=>{await api_classPrivateFieldGet(Do,this).headersReady;const{isStreamingSupported:t,isRangeSupported:i,contentLength:a}=api_classPrivateFieldGet(Do,this);t&&i&&(api_classPrivateFieldGet(Do,this).onProgress=null);return{isStreamingSupported:t,isRangeSupported:i,contentLength:a}});e.on("GetRangeReader",(e,t)=>{assert(api_classPrivateFieldGet(Oo,this),"GetRangeReader - no `BasePDFStream` instance available.");const i=api_classPrivateFieldGet(Oo,this).getRangeReader(e.begin,e.end);if(i){t.onPull=()=>{i.read().then(function({value:e,done:i}){if(i)t.close();else{assert(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}}).catch(e=>{t.error(e)})};t.onCancel=e=>{i.cancel(e);t.ready.catch(e=>{if(!this.destroyed)throw e})}}else t.close()});e.on("GetDoc",({pdfInfo:e})=>{this.pagesMapper.pagesNumber=e.numPages;this._numPages=e.numPages;this._htmlForXfa=e.htmlForXfa;delete e.htmlForXfa;t._capability.resolve(new PDFDocumentProxy(e,this))});e.on("DocException",e=>{t._capability.reject(wrapReason(e))});e.on("PasswordRequest",e=>{api_classPrivateFieldSet(Vo,this,Promise.withResolvers());try{if(!t.onPassword)throw wrapReason(e);const updatePassword=e=>{e instanceof Error?api_classPrivateFieldGet(Vo,this).reject(e):api_classPrivateFieldGet(Vo,this).resolve({password:e})};t.onPassword(updatePassword,e.code)}catch(e){api_classPrivateFieldGet(Vo,this).reject(e)}return api_classPrivateFieldGet(Vo,this).promise});e.on("DataLoaded",e=>{api_assertClassBrand(zo,this,api_onProgress).call(this,{loaded:e.length,total:e.length});this.downloadInfoCapability.resolve(e)});e.on("StartRenderPage",e=>{if(this.destroyed)return;api_classPrivateFieldGet(No,this).get(e.pageProxyId)._startRenderPage(e.transparency,e.cacheKey)});const i=new ObjectHandler({messageHandler:e,commonObjs:this.commonObjs,fontLoader:this.fontLoader,pageCache:api_classPrivateFieldGet(No,this),pdfBug:this._params.pdfBug});this.rendererWorker?.promise.then(()=>{this.rendererWorker?.messageHandler?.on("FontFallback",t=>this.destroyed?null:e.sendWithPromise("FontFallback",t))},()=>{});e.on("commonobj",([e,t,a])=>{if(this.destroyed)return null;const{rendererWorker:s}=this;if("CopyLocalImage"===t){if(this.commonObjs.has(e))return null;const r=i.resolveCommonObject(e,t,a);r&&s?.sendCommonObj(e,"Image",this.commonObjs.get(e));return r}s?.sendCommonObj(e,t,a);if(!this.commonObjs.has(e)){i.resolveCommonObject(e,t,a);"Pattern"===t&&"Mesh"===this.commonObjs.get(e)[0]&&api_classPrivateFieldSet(Lo,this,!0)}return null});e.on("obj",([e,t,a,s])=>{if(!this.destroyed){"Pattern"===a&&"Mesh"===s[0]&&api_classPrivateFieldSet(Lo,this,!0);i.resolveObject(e,t,a,s)&&this.rendererWorker?.sendObj(e,t,a,s)}});e.on("DocProgress",e=>{this.destroyed||api_assertClassBrand(zo,this,api_onProgress).call(this,e)});e.on("FetchBinaryData",async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(e)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(e=null,t=null){this.annotationStorage.size<=0&&warn("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:i,transfer:a}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:i,supportsPrintToPDF:null!==api_classPrivateFieldGet(Uo,this),filename:api_classPrivateFieldGet(Do,this)?.filename??null,pageOrder:t},a).finally(()=>{api_classPrivateFieldSet(Uo,this,null);this.annotationStorage.resetModified()})}extractPages(e,t=null){const i={pageInfos:e};let a;const s=globalThis.ImageBitmap;if("function"==typeof s){const t=Array.isArray(e)?e:[e];for(const e of t)e?.image instanceof s&&(a||=[]).push(e.image)}if(this.annotationStorage.size>0){const e=this.annotationStorage.serializable;let{map:s}=e;e.transfer?.length&&(a?a.push(...e.transfer):a=e.transfer);const r=this.pagesMapper.getMapping();if(r){const e=new Map;for(const[i,a]of s){if(void 0!==a?.pageIndex&&a.pageIndex>=0&&a.pageIndex<r.length){const s=t?.[a.pageIndex]??0,n=r[a.pageIndex]-1;if(n!==a.pageIndex||0!==s){e.set(i,{...a,pageIndex:n,copyLevel:s});continue}}e.set(i,a)}s=e}i.annotationStorage=s}return this.messageHandler.sendWithPromise("ExtractPages",i,a).finally(()=>{this.annotationStorage.resetModified()})}waitForGPU(){return this._params.enableWebGPU&&api_classPrivateFieldGet(Lo,this)&&!isGPUReady()?initGPU():null}getPage(e){if(!Number.isInteger(e)||e<=0||e>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const t=e-1,i=this.pagesMapper.getPageId(e)-1,a=api_classPrivateFieldGet(Wo,this).get(t);if(a)return a;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(e=>{if(this.destroyed)throw new Error("Transport destroyed");e.refStr&&api_classPrivateFieldGet(jo,this).set(e.refStr,i);const a=new PDFPageProxy(t,e,this,this.pagesMapper,this._params.pdfBug);api_classPrivateFieldGet(No,this).set(a._id,a);return a});api_classPrivateFieldGet(Wo,this).set(t,s);return s}async getPageIndex(e){if(!isRefProxy(e))throw new Error("Invalid pageIndex request.");const t=await this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}),i=this.pagesMapper.getPageNumber(t+1);if(0===i)throw new Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(e+1)-1,intent:t})}getFieldObjects(){return api_assertClassBrand(zo,this,_cacheSimpleMethod).call(this,"GetFieldObjects")}getSignatures(){return api_assertClassBrand(zo,this,_cacheSimpleMethod).call(this,"GetSignatures")}getSignatureData(e){return this.messageHandler.sendWithPromise("GetSignatureData",e)}hasJSActions(){return api_assertClassBrand(zo,this,_cacheSimpleMethod).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(e){return this.messageHandler.sendWithPromise("GetAttachmentContent",e)}getAnnotationsByType(e,t){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:e,pageIndexesToSkip:t})}getDocJSActions(){return api_assertClassBrand(zo,this,_cacheSimpleMethod).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){const t="GetOptionalContentConfig";return api_classPrivateFieldGet(Ro,this).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).catch(e=>{warn(`${t}: "${e}".`);return null})).then(t=>new OptionalContentConfig(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata";return api_classPrivateFieldGet(Ro,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new Metadata(e[1]):null,contentDispositionFilename:api_classPrivateFieldGet(Do,this)?.filename??null,contentLength:api_classPrivateFieldGet(Do,this)?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of api_classPrivateFieldGet(No,this).values()){if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`)}this.commonObjs.clear();e||this.fontLoader.clear();this.rendererWorker?.cleanup(e);api_classPrivateFieldGet(Ro,this).clear();this.filterFactory.destroy(!0);TextLayer.cleanup()}}cleanupPage(e){this.destroyed||this.messageHandler.send("CleanupPage",{pageProxyId:e});this.rendererWorker?.cleanupPage(e)}cachedPageNumber(e){if(!isRefProxy(e))return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`,i=api_classPrivateFieldGet(jo,this).get(t);if(i>=0){const e=this.pagesMapper.getPageNumber(i+1);if(0!==e)return e}return null}}function _cacheSimpleMethod(e,t=null){return api_classPrivateFieldGet(Ro,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,t))}function api_onProgress({loaded:e,total:t}){this.loadingTask.onProgress?.({loaded:e,total:t,percent:t?MathClamp(Math.round(e/t*100),0,100):NaN})}class RenderTask{constructor(e){api_defineProperty(this,"_internalRenderTask",null);api_defineProperty(this,"onContinue",null);api_defineProperty(this,"onError",null);api_defineProperty(this,"onFrame",null);this._internalRenderTask=e}get promise(){return this._internalRenderTask.capability.promise}cancel(e=0){this._internalRenderTask.cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=this._internalRenderTask.operatorList;if(!e)return!1;const{annotationCanvasMap:t}=this._internalRenderTask;return e.form||e.canvas&&t?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}get isWorkerRendering(){return this._internalRenderTask.isWorkerRendering}}var Ho=new WeakMap,$o=new WeakMap,Xo=new WeakMap,Ko=new WeakMap,qo=new WeakMap;class InternalRenderTask{constructor({callback:e,params:t,objs:i,commonObjs:a,annotationCanvasMap:s,operatorList:r,pageIndex:n,pageProxyId:o,canvasFactory:l,filterFactory:d,useRequestAnimationFrame:c=!1,pdfBug:h=!1,pageColors:_=null,operationsFilter:u=null,rendererWorker:p=null,waitForGPU:g=null}){api_classPrivateFieldInitSpec(this,Ho,null);api_classPrivateFieldInitSpec(this,$o,null);api_classPrivateFieldInitSpec(this,Xo,null);api_classPrivateFieldInitSpec(this,Ko,null);api_classPrivateFieldInitSpec(this,qo,null);this.callback=e;this.params=t;this.objs=i;this.commonObjs=a;this.annotationCanvasMap=s;this.operatorListIdx=null;this.operatorList=r;this._pageIndex=n;this.canvasFactory=l;this.filterFactory=d;this._pdfBug=h;this.pageColors=_;this.running=!1;this.graphicsReadyCallback=null;this.graphicsReady=!1;this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window;this.cancelled=!1;this.capability=Promise.withResolvers();this.task=new RenderTask(this);this._cancelBound=this.cancel.bind(this);this._continueBound=this._continue.bind(this);this._scheduleNextBound=this._scheduleNext.bind(this);this._nextBound=this._next.bind(this);this._canvas=t.canvas;this._canvasContext=t.canvas?null:t.canvasContext;this._operationsFilter=u;api_classPrivateFieldSet(qo,this,g);api_classPrivateFieldSet(Ko,this,p?.createRenderTask({pageProxyId:o,operatorList:r,params:t,pageColors:_,canvasFactory:l,annotationCanvasMap:s,onFrame:()=>this.task.onFrame?.(),onError:e=>this.cancel(e)})??null)}get completed(){return this.capability.promise.catch(()=>{})}get isWorkerRendering(){return!!api_classPrivateFieldGet(Ko,this)}get imageCoordinates(){return api_classPrivateFieldGet(Ko,this)?api_classPrivateFieldGet(Ko,this).imageCoordinates:api_classPrivateFieldGet($o,this)?.take()}get recordedBBoxes(){return api_classPrivateFieldGet(Ko,this)?api_classPrivateFieldGet(Ko,this).recordedBBoxes:api_classPrivateFieldGet(Ho,this)?.take()}get debugMetadata(){return api_classPrivateFieldGet(Ho,this)?.takeDebugMetadata()??null}async initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(!this.cancelled){if(this._canvas){if(Yo._.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Yo._.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled){this.stepper=globalThis.StepperManager.create(this._pageIndex);this.stepper.init(this.operatorList);this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint()}if(api_classPrivateFieldGet(Ko,this)){const i=await api_classPrivateFieldGet(Ko,this).initialize(e,t);if(this.cancelled)return;i||api_classPrivateFieldSet(Ko,this,null)}if(!api_classPrivateFieldGet(Ko,this)){const{viewport:i,transform:a,background:s,recordOperations:r,recordImages:n,recordForDebugger:o}=this.params,l=this._canvasContext||this.canvasFactory.getNoAlphaContext(this._canvas),{dependencyTracker:d,imagesTracker:c}=function createCanvasTrackers(e,t,{recordOperations:i=!1,recordImages:a=!1,recordDebugMetadata:s=!1}){const r=i||a?new CanvasBBoxTracker(e,t):null;return{dependencyTracker:i?new CanvasDependencyTracker(r,s):r,imagesTracker:a?new CanvasImagesTracker(e):null}}(this._canvas,this.operatorList.fnArray.length,{recordOperations:r,recordImages:n,recordDebugMetadata:o});api_classPrivateFieldSet(Ho,this,d);api_classPrivateFieldSet($o,this,c);this.gfx=new CanvasGraphics(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors,d,c);this.gfx.beginDrawing({transform:a,viewport:i,transparency:e,background:s})}this.operatorListIdx=0;this.graphicsReady=!0;this.graphicsReadyCallback?.()}}cancel(e=null,t=0){this.running=!1;this.cancelled=!0;api_classPrivateFieldGet(Ko,this)?.cancel();this.gfx?.endDrawing();if(api_classPrivateFieldGet(Xo,this)){window.cancelAnimationFrame(api_classPrivateFieldGet(Xo,this));api_classPrivateFieldSet(Xo,this,null)}Yo._.delete(this._canvas);e||=new RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,t);this.callback(e);this.task.onError?.(e)}operatorListChanged(){if(this.graphicsReady){api_classPrivateFieldGet(Ho,this)?.growOperationsCount(this.operatorList.fnArray.length);this.stepper?.updateOperatorList(this.operatorList);this.running||this._continue()}else this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0;this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?api_classPrivateFieldSet(Xo,this,window.requestAnimationFrame(()=>{api_classPrivateFieldSet(Xo,this,null);this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(this.cancelled)return;if(!api_classPrivateFieldGet(Ko,this)){const e=api_classPrivateFieldGet(qo,this)?.call(this);if(e){await e;if(this.cancelled)return}}const{operatorList:e}=this,{lastChunk:t}=e;if(api_classPrivateFieldGet(Ko,this)){this.operatorListIdx=await api_classPrivateFieldGet(Ko,this).executeOperatorList(e,this.operatorListIdx,this._operationsFilter);if(this.cancelled)return;if(this.operatorListIdx!==e.argsArray.length||t!==e.lastChunk){this._continue();return}}else this.operatorListIdx=this.gfx.executeOperatorList(e,this.operatorListIdx,this._continueBound,null,this.stepper,this._operationsFilter);if(this.operatorListIdx===e.argsArray.length){this.running=!1;if(t){this.gfx?.endDrawing();Yo._.delete(this._canvas);this.callback()}}}}var Yo={_:new WeakSet};const Zo="6.5.1523",Qo="e59504a82";var Jo;function eraser_defineProperty(e,t,i){return(t=function eraser_toPropertyKey(e){var t=function eraser_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function eraser_classPrivateFieldInitSpec(e,t,i){eraser_checkPrivateRedeclaration(e,t),t.set(e,i)}function eraser_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function eraser_classPrivateFieldGet(e,t){return e.get(eraser_assertClassBrand(e,t))}function eraser_classPrivateFieldSet(e,t,i){return e.set(eraser_assertClassBrand(e,t),i),i}function eraser_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var el,tl=new WeakMap,il=new WeakMap,al=new WeakMap,sl=new WeakMap,rl=new WeakMap,nl=new WeakMap,ol=new WeakMap,ll=new WeakMap,dl=new WeakMap,cl=new WeakMap,hl=new WeakSet;class EraserEditor extends AnnotationEditor{constructor(e){super({...e,name:"eraserEditor"});!function eraser_classPrivateMethodInitSpec(e,t){eraser_checkPrivateRedeclaration(e,t),t.add(e)}(this,hl);eraser_classPrivateFieldInitSpec(this,tl,null);eraser_classPrivateFieldInitSpec(this,il,null);eraser_classPrivateFieldInitSpec(this,al,null);eraser_classPrivateFieldInitSpec(this,sl,0);eraser_classPrivateFieldInitSpec(this,rl,!1);eraser_classPrivateFieldInitSpec(this,nl,null);eraser_classPrivateFieldInitSpec(this,ol,[]);eraser_classPrivateFieldInitSpec(this,ll,[]);eraser_classPrivateFieldInitSpec(this,dl,null);eraser_classPrivateFieldInitSpec(this,cl,null);this.defaultL10nId="pdfjs-editor-eraser-editor";EraserEditor._thickness=e.thickness||EraserEditor._thickness||EraserEditor._defaultThickness}static initialize(e,t){AnnotationEditor.initialize(e,t)}static updateDefaultParams(e,t){if(e===v.ERASER_THICKNESS){EraserEditor._defaultThickness=t;EraserEditor._thickness=t}}static get defaultPropertiesToUpdate(){return[[v.ERASER_THICKNESS,EraserEditor._defaultThickness]]}render(){if(this.div)return this.div;const e=super.render();this.fixAndSetPosition();this.enableEditing();return e}fixAndSetPosition(){this.x=0;this.y=0;this.width=1;this.height=1;this.setDims();return super.fixAndSetPosition(0)}enableEditing(){super.enableEditing();this.div?.classList.toggle("disabled",!1);eraser_assertClassBrand(hl,this,_abortCursor).call(this);if(this.div&&this.parent){eraser_assertClassBrand(hl,this,_coverLayer).call(this);this.div.style.pointerEvents="auto";this.div.style.zIndex="1000";eraser_classPrivateFieldSet(al,this,document.createElement("div"));eraser_classPrivateFieldGet(al,this).className="eraserCursor";eraser_classPrivateFieldSet(sl,this,0);eraser_assertClassBrand(hl,this,_updateCursor).call(this);eraser_classPrivateFieldGet(al,this).style.display="none";this.div.append(eraser_classPrivateFieldGet(al,this));const e=eraser_classPrivateFieldSet(tl,this,new AbortController),t=this.parent.combinedSignal(e);this.div.addEventListener("pointermove",eraser_assertClassBrand(hl,this,_moveCursor).bind(this),{signal:t});this.div.addEventListener("pointerenter",eraser_assertClassBrand(hl,this,_displayCursor).bind(this),{signal:t});this.div.addEventListener("pointerleave",eraser_assertClassBrand(hl,this,_hideCursor).bind(this),{signal:t});this.div.addEventListener("pointerdown",eraser_assertClassBrand(hl,this,_startEraseSession).bind(this),{signal:t})}}disableEditing(){super.disableEditing();this.div?.classList.toggle("disabled",!0);eraser_assertClassBrand(hl,this,_cancelEraseSession).call(this);eraser_assertClassBrand(hl,this,_abortCursor).call(this)}remove(){eraser_assertClassBrand(hl,this,_cancelEraseSession).call(this);eraser_assertClassBrand(hl,this,_abortCursor).call(this);super.remove()}isEmpty(){return!0}pointerdown(e){}}Jo=EraserEditor;function _startEraseSession(e){if(e.button&&0!==e.button)return;const{pointerId:t,pointerType:i,target:a}=e,s=this._uiManager.currentPointers;if(s.isInitializedAndDifferentPointerType(i)){eraser_assertClassBrand(hl,this,_moveCursor).call(this,e);return}eraser_assertClassBrand(hl,this,_abortEraseSession).call(this);s.setPointer(i,t);eraser_classPrivateFieldSet(nl,this,this.parent.div.getBoundingClientRect());eraser_assertClassBrand(hl,this,_moveCursor).call(this,e);eraser_classPrivateFieldSet(ol,this,[]);for(const e of eraser_assertClassBrand(hl,this,_getErasableEditors).call(this)){const t=e.startErase(eraser_classPrivateFieldGet(nl,this));t&&eraser_classPrivateFieldGet(ol,this).push({editor:e,bbox:t})}const r=eraser_classPrivateFieldSet(il,this,new AbortController),n=this.parent.combinedSignal(r);window.addEventListener("pointerup",e=>{s.isSamePointerIdOrRemove(e.pointerId)&&eraser_assertClassBrand(hl,this,_endErase).call(this,e)},{signal:n});window.addEventListener("pointercancel",e=>{s.isSamePointerIdOrRemove(e.pointerId)&&eraser_assertClassBrand(hl,this,_endErase).call(this,e)},{signal:n});window.addEventListener("pointerdown",e=>{if(s.isSamePointerType(i)){s.initializeAndAddPointerId(e.pointerId);eraser_classPrivateFieldGet(rl,this)&&eraser_assertClassBrand(hl,this,_endErase).call(this,null)}},{capture:!0,passive:!1,signal:n});window.addEventListener("contextmenu",noContextMenu,{signal:n});a.addEventListener("pointermove",eraser_assertClassBrand(hl,this,_onPointerMove).bind(this),{signal:n});a.addEventListener("touchmove",e=>{s.isSameTimeStamp(e.timeStamp)&&stopEvent(e)},{signal:n});eraser_classPrivateFieldSet(rl,this,!0);eraser_assertClassBrand(hl,this,_queueSample).call(this,e.clientX,e.clientY);stopEvent(e)}function _onPointerMove(e){const t=this._uiManager.currentPointers;t.clearTimeStamp();if(!eraser_classPrivateFieldGet(rl,this))return;const{pointerId:i}=e;if(t.isSamePointerId(i))if(t.isUsingMultiplePointers())eraser_assertClassBrand(hl,this,_endErase).call(this,e);else{eraser_assertClassBrand(hl,this,_queueSample).call(this,e.clientX,e.clientY);t.setTimeStamp(e.timeStamp);stopEvent(e)}}function _endErase(e){e&&eraser_assertClassBrand(hl,this,_queueSample).call(this,e.clientX,e.clientY);eraser_assertClassBrand(hl,this,_flushSamples).call(this);eraser_assertClassBrand(hl,this,_commit).call(this);eraser_assertClassBrand(hl,this,_abortEraseSession).call(this)}function _queueSample(e,t){eraser_classPrivateFieldGet(ll,this).push(e-eraser_classPrivateFieldGet(nl,this).left,t-eraser_classPrivateFieldGet(nl,this).top);eraser_classPrivateFieldGet(cl,this)??eraser_classPrivateFieldSet(cl,this,window.requestAnimationFrame(()=>{eraser_classPrivateFieldSet(cl,this,null);eraser_assertClassBrand(hl,this,_flushSamples).call(this)}))}function _flushSamples(){if(null!==eraser_classPrivateFieldGet(cl,this)){window.cancelAnimationFrame(eraser_classPrivateFieldGet(cl,this));eraser_classPrivateFieldSet(cl,this,null)}const e=eraser_classPrivateFieldGet(ll,this);if(0===e.length)return;eraser_classPrivateFieldSet(ll,this,[]);const t=Jo._thickness/2;let[i,a]=eraser_classPrivateFieldGet(dl,this)??[e[0],e[1]];for(let s=0,r=e.length;s<r;s+=2){const r=e[s],n=e[s+1],o=Math.min(r,i)-t,l=Math.min(n,a)-t,d=Math.max(r,i)+t,c=Math.max(n,a)+t;for(const{editor:e,bbox:s}of eraser_classPrivateFieldGet(ol,this))d<s[0]||o>s[2]||c<s[1]||l>s[3]||e.erase(r,n,t,i,a);i=r;a=n}eraser_classPrivateFieldSet(dl,this,[i,a]);for(const{editor:e}of eraser_classPrivateFieldGet(ol,this))e.renderErase()}function _commit(){const e=[],t=[];for(const{editor:i}of eraser_classPrivateFieldGet(ol,this)){const{cmd:a,undo:s}=i.endErase();if(a&&s){e.push(a);t.push(s)}}0!==e.length&&this.parent.addCommands({cmd:()=>e.forEach(e=>e()),undo:()=>t.forEach(e=>e()),mustExec:!1,type:v.ERASER_STEP})}function _cancelEraseSession(){eraser_classPrivateFieldGet(rl,this)&&this.parent?eraser_assertClassBrand(hl,this,_endErase).call(this,null):eraser_assertClassBrand(hl,this,_abortEraseSession).call(this)}function _abortEraseSession(){const e=null!==eraser_classPrivateFieldGet(il,this);eraser_classPrivateFieldGet(il,this)?.abort();eraser_classPrivateFieldSet(il,this,null);if(null!==eraser_classPrivateFieldGet(cl,this)){window.cancelAnimationFrame(eraser_classPrivateFieldGet(cl,this));eraser_classPrivateFieldSet(cl,this,null)}eraser_classPrivateFieldSet(ll,this,[]);eraser_classPrivateFieldSet(dl,this,null);eraser_classPrivateFieldSet(nl,this,null);eraser_classPrivateFieldSet(ol,this,[]);if(e){const e=this._uiManager.currentPointers;e.clearPointerIds();e.clearTimeStamp()}eraser_classPrivateFieldSet(rl,this,!1)}function _abortCursor(){eraser_classPrivateFieldGet(tl,this)?.abort();eraser_classPrivateFieldSet(tl,this,null);if(eraser_classPrivateFieldGet(al,this)){eraser_classPrivateFieldGet(al,this).remove();eraser_classPrivateFieldSet(al,this,null)}if(this.div){this.div.style.pointerEvents="";this.div.style.zIndex=""}}function _coverLayer(){this.div.removeAttribute("data-editor-rotation");for(const[e,t]of[["left","0"],["top","0"],["width","100%"],["height","100%"],["max-width","none"],["max-height","none"]])this.div.style.setProperty(e,t,"important")}function _updateCursor(){const e=Jo._thickness;if(eraser_classPrivateFieldGet(al,this)&&eraser_classPrivateFieldGet(sl,this)!==e){eraser_classPrivateFieldSet(sl,this,e);eraser_classPrivateFieldGet(al,this).style.width=`${e}px`;eraser_classPrivateFieldGet(al,this).style.height=`${e}px`}}function _displayCursor(e){eraser_assertClassBrand(hl,this,_moveCursor).call(this,e)}function _moveCursor(e){if(!eraser_classPrivateFieldGet(al,this))return;if(this._uiManager.currentPointers.isInitializedAndDifferentPointerType(e.pointerType)){eraser_assertClassBrand(hl,this,_hideCursor).call(this);return}eraser_assertClassBrand(hl,this,_updateCursor).call(this);const t=eraser_classPrivateFieldGet(nl,this)??this.parent.div.getBoundingClientRect(),i=Jo._thickness/2,a=e.clientX-t.left,s=e.clientY-t.top;let r=a,n=s;switch(this.parentRotation){case 90:[r,n]=[s,t.width-a];break;case 180:[r,n]=[t.width-a,t.height-s];break;case 270:[r,n]=[t.height-s,a]}const o=r-i,l=n-i;eraser_classPrivateFieldGet(al,this).style.transform=`translate(${o}px, ${l}px)`;eraser_assertClassBrand(hl,this,_showCursor).call(this)}function _showCursor(){eraser_classPrivateFieldGet(al,this).style.display="block"}function _hideCursor(){eraser_classPrivateFieldGet(al,this).style.display="none"}function _getErasableEditors(){return(Array.from(this._uiManager.getEditors(this.pageIndex))||[]).filter(e=>e.erasable&&e?.parent?.div&&e?.div)}eraser_defineProperty(EraserEditor,"_defaultThickness",20);eraser_defineProperty(EraserEditor,"_thickness",void 0);eraser_defineProperty(EraserEditor,"_type","eraser");eraser_defineProperty(EraserEditor,"_editorType",f.ERASER);function color_picker_classPrivateFieldInitSpec(e,t,i){color_picker_checkPrivateRedeclaration(e,t),t.set(e,i)}function color_picker_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function color_picker_classPrivateGetter(e,t,i){return i(color_picker_assertClassBrand(e,t))}function color_picker_classPrivateFieldGet(e,t){return e.get(color_picker_assertClassBrand(e,t))}function color_picker_classPrivateFieldSet(e,t,i){return e.set(color_picker_assertClassBrand(e,t),i),i}function color_picker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var _l=new WeakMap,ul=new WeakMap,pl=new WeakMap,gl=new WeakMap,ml=new WeakMap,fl=new WeakMap,vl=new WeakMap,Pl=new WeakMap,wl=new WeakMap,Fl=new WeakMap,yl=new WeakSet;class ColorPicker{static get _keyboardManager(){return shadow(this,"_keyboardManager",new KeyboardManager([[["Escape"],ColorPicker.prototype._hideDropdownFromKeyboard],[["Space"],ColorPicker.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],ColorPicker.prototype._moveToNext],[["ArrowUp","ArrowLeft"],ColorPicker.prototype._moveToPrevious],[["Home"],ColorPicker.prototype._moveToBeginning],[["End"],ColorPicker.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){!function color_picker_classPrivateMethodInitSpec(e,t){color_picker_checkPrivateRedeclaration(e,t),t.add(e)}(this,yl);color_picker_classPrivateFieldInitSpec(this,_l,null);color_picker_classPrivateFieldInitSpec(this,ul,null);color_picker_classPrivateFieldInitSpec(this,pl,void 0);color_picker_classPrivateFieldInitSpec(this,gl,null);color_picker_classPrivateFieldInitSpec(this,ml,!1);color_picker_classPrivateFieldInitSpec(this,fl,!1);color_picker_classPrivateFieldInitSpec(this,vl,null);color_picker_classPrivateFieldInitSpec(this,Pl,void 0);color_picker_classPrivateFieldInitSpec(this,wl,null);color_picker_classPrivateFieldInitSpec(this,Fl,null);if(e){color_picker_classPrivateFieldSet(fl,this,!1);color_picker_classPrivateFieldSet(vl,this,e)}else color_picker_classPrivateFieldSet(fl,this,!0);color_picker_classPrivateFieldSet(Fl,this,e?._uiManager||t);color_picker_classPrivateFieldSet(Pl,this,color_picker_classPrivateFieldGet(Fl,this)._eventBus);color_picker_classPrivateFieldSet(pl,this,e?.color?.toUpperCase()||color_picker_classPrivateFieldGet(Fl,this)?.highlightColors.values().next().value||"#FFFF98");bl._||(bl._=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}renderButton(){const e=color_picker_classPrivateFieldSet(_l,this,document.createElement("button"));e.className="colorPicker";e.tabIndex="0";e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button");e.ariaHasPopup="true";color_picker_classPrivateFieldGet(vl,this)&&(e.ariaControls=`${color_picker_classPrivateFieldGet(vl,this).id}_colorpicker_dropdown`);const t=color_picker_classPrivateFieldGet(Fl,this)._signal;e.addEventListener("click",color_picker_assertClassBrand(yl,this,_openDropdown).bind(this),{signal:t});e.addEventListener("keydown",color_picker_assertClassBrand(yl,this,_keyDown).bind(this),{signal:t});const i=color_picker_classPrivateFieldSet(ul,this,document.createElement("span"));i.className="swatch";i.ariaHidden="true";i.style.backgroundColor=color_picker_classPrivateFieldGet(pl,this);e.append(i);return e}renderMainDropdown(){const e=color_picker_classPrivateFieldSet(gl,this,color_picker_assertClassBrand(yl,this,_getDropdownRoot).call(this));e.ariaOrientation="horizontal";e.ariaLabelledBy="highlightColorPickerLabel";return e}_colorSelectFromKeyboard(e){if(e.target===color_picker_classPrivateFieldGet(_l,this)){color_picker_assertClassBrand(yl,this,_openDropdown).call(this,e);return}const t=e.target.getAttribute("data-color");t&&color_picker_assertClassBrand(yl,this,_colorSelect).call(this,t,e)}_moveToNext(e){color_picker_classPrivateGetter(yl,this,_get_isDropdownVisible)?e.target!==color_picker_classPrivateFieldGet(_l,this)?e.target.nextSibling?.focus():color_picker_classPrivateFieldGet(gl,this).firstElementChild?.focus():color_picker_assertClassBrand(yl,this,_openDropdown).call(this,e)}_moveToPrevious(e){if(e.target!==color_picker_classPrivateFieldGet(gl,this)?.firstElementChild&&e.target!==color_picker_classPrivateFieldGet(_l,this)){color_picker_classPrivateGetter(yl,this,_get_isDropdownVisible)||color_picker_assertClassBrand(yl,this,_openDropdown).call(this,e);e.target.previousSibling?.focus()}else color_picker_classPrivateGetter(yl,this,_get_isDropdownVisible)&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){color_picker_classPrivateGetter(yl,this,_get_isDropdownVisible)?color_picker_classPrivateFieldGet(gl,this).firstElementChild?.focus():color_picker_assertClassBrand(yl,this,_openDropdown).call(this,e)}_moveToEnd(e){color_picker_classPrivateGetter(yl,this,_get_isDropdownVisible)?color_picker_classPrivateFieldGet(gl,this).lastElementChild?.focus():color_picker_assertClassBrand(yl,this,_openDropdown).call(this,e)}hideDropdown(){color_picker_classPrivateFieldGet(gl,this)?.classList.add("hidden");color_picker_classPrivateFieldGet(_l,this).ariaExpanded="false";color_picker_classPrivateFieldGet(wl,this)?.abort();color_picker_classPrivateFieldSet(wl,this,null)}_hideDropdownFromKeyboard(){if(!color_picker_classPrivateFieldGet(fl,this))if(color_picker_classPrivateGetter(yl,this,_get_isDropdownVisible)){this.hideDropdown();color_picker_classPrivateFieldGet(_l,this).focus({preventScroll:!0,focusVisible:color_picker_classPrivateFieldGet(ml,this)})}else color_picker_classPrivateFieldGet(vl,this)?.unselect()}update(e){color_picker_classPrivateFieldGet(ul,this)&&(color_picker_classPrivateFieldGet(ul,this).style.backgroundColor=e);if(!color_picker_classPrivateFieldGet(gl,this))return;const t=color_picker_classPrivateFieldGet(Fl,this).highlightColors.values();for(const i of color_picker_classPrivateFieldGet(gl,this).children)i.ariaSelected=t.next().value===e.toUpperCase()}destroy(){color_picker_classPrivateFieldGet(_l,this)?.remove();color_picker_classPrivateFieldSet(_l,this,null);color_picker_classPrivateFieldSet(ul,this,null);color_picker_classPrivateFieldGet(gl,this)?.remove();color_picker_classPrivateFieldSet(gl,this,null)}}el=ColorPicker;function _getDropdownRoot(){const e=document.createElement("div"),t=color_picker_classPrivateFieldGet(Fl,this)._signal;e.addEventListener("contextmenu",noContextMenu,{signal:t});e.className="dropdown";e.role="listbox";e.ariaMultiSelectable="false";e.ariaOrientation="vertical";e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");color_picker_classPrivateFieldGet(vl,this)&&(e.id=`${color_picker_classPrivateFieldGet(vl,this).id}_colorpicker_dropdown`);for(const[i,a]of color_picker_classPrivateFieldGet(Fl,this).highlightColors){const s=document.createElement("button");s.tabIndex="0";s.role="option";s.setAttribute("data-color",a);s.title=i;s.setAttribute("data-l10n-id",bl._[i]);const r=document.createElement("span");s.append(r);r.className="swatch";r.style.backgroundColor=a;s.ariaSelected=a===color_picker_classPrivateFieldGet(pl,this);s.addEventListener("click",color_picker_assertClassBrand(yl,this,_colorSelect).bind(this,a),{signal:t});e.append(s)}e.addEventListener("keydown",color_picker_assertClassBrand(yl,this,_keyDown).bind(this),{signal:t});return e}function _colorSelect(e,t){t.stopPropagation();color_picker_classPrivateFieldGet(Pl,this).dispatch("switchannotationeditorparams",{source:this,type:v.HIGHLIGHT_COLOR,value:e});this.update(e)}function _keyDown(e){el._keyboardManager.exec(this,e)}function _openDropdown(e){if(color_picker_classPrivateGetter(yl,this,_get_isDropdownVisible)){this.hideDropdown();return}color_picker_classPrivateFieldSet(ml,this,0===e.detail);if(!color_picker_classPrivateFieldGet(wl,this)){color_picker_classPrivateFieldSet(wl,this,new AbortController);window.addEventListener("pointerdown",color_picker_assertClassBrand(yl,this,color_picker_pointerDown).bind(this),{signal:color_picker_classPrivateFieldGet(Fl,this).combinedSignal(color_picker_classPrivateFieldGet(wl,this))})}color_picker_classPrivateFieldGet(_l,this).ariaExpanded="true";if(color_picker_classPrivateFieldGet(gl,this)){color_picker_classPrivateFieldGet(gl,this).classList.remove("hidden");return}const t=color_picker_classPrivateFieldSet(gl,this,color_picker_assertClassBrand(yl,this,_getDropdownRoot).call(this));color_picker_classPrivateFieldGet(_l,this).append(t)}function color_picker_pointerDown(e){color_picker_classPrivateFieldGet(gl,this)?.contains(e.target)||this.hideDropdown()}function _get_isDropdownVisible(e){return color_picker_classPrivateFieldGet(gl,e)&&!color_picker_classPrivateFieldGet(gl,e).classList.contains("hidden")}var bl={_:null},Sl=new WeakMap,Cl=new WeakMap,xl=new WeakMap,kl=new WeakMap;class BasicColorPicker{constructor(e){color_picker_classPrivateFieldInitSpec(this,Sl,null);color_picker_classPrivateFieldInitSpec(this,Cl,!1);color_picker_classPrivateFieldInitSpec(this,xl,null);color_picker_classPrivateFieldInitSpec(this,kl,null);color_picker_classPrivateFieldSet(xl,this,e);color_picker_classPrivateFieldSet(kl,this,e._uiManager);El._||(El._=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(color_picker_classPrivateFieldGet(Sl,this))return color_picker_classPrivateFieldGet(Sl,this);const{editorType:e,colorType:t,colorAndOpacityType:i,opacityType:a,color:s,opacity:r}=color_picker_classPrivateFieldGet(xl,this),n=color_picker_classPrivateFieldSet(Cl,this,FeatureTest.isAlphaColorInputSupported&&void 0!==a),o=color_picker_classPrivateFieldSet(Sl,this,document.createElement("input"));o.type="color";if(n){o.setAttribute("alpha","");const e=Util.hexNums[Math.round(255*(r??1))];o.value=(s||"#000000")+e}else o.value=s||"#000000";o.className="basicColorPicker";o.tabIndex=0;o.setAttribute("data-l10n-id",El._[e]);o.addEventListener("input",()=>{if(n){const e=getRGBA(o.value);if(!e)return;const[s,r,n,l]=e,d=Util.makeHexColor(s,r,n);if(void 0!==i)color_picker_classPrivateFieldGet(kl,this).updateParams(i,{color:d,opacity:l});else{color_picker_classPrivateFieldGet(kl,this).updateParams(t,d);color_picker_classPrivateFieldGet(kl,this).updateParams(a,l)}}else color_picker_classPrivateFieldGet(kl,this).updateParams(t,o.value)},{signal:color_picker_classPrivateFieldGet(kl,this)._signal});return o}update(e){if(color_picker_classPrivateFieldGet(Sl,this))if(color_picker_classPrivateFieldGet(Cl,this)){const t=Util.hexNums[Math.round(255*color_picker_classPrivateFieldGet(xl,this).opacity)];color_picker_classPrivateFieldGet(Sl,this).value=e+t}else color_picker_classPrivateFieldGet(Sl,this).value=e}updateOpacity(e){if(!color_picker_classPrivateFieldGet(Sl,this)||!color_picker_classPrivateFieldGet(Cl,this))return;const t=Util.hexNums[Math.round(255*e)];color_picker_classPrivateFieldGet(Sl,this).value=color_picker_classPrivateFieldGet(xl,this).color+t}destroy(){color_picker_classPrivateFieldGet(Sl,this)?.remove();color_picker_classPrivateFieldSet(Sl,this,null)}hideDropdown(){}}var El={_:null};function makeColorComp(e){return Math.floor(255*MathClamp(e,0,1)).toString(16).padStart(2,"0")}function scaleAndClamp(e){return 255*MathClamp(e,0,1)}class ColorConverters{static CMYK_G([e,t,i,a]){return["G",1-Math.min(1,.3*e+.59*i+.11*t+a)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=scaleAndClamp(e),e,e]}static G_HTML([e]){const t=makeColorComp(e);return`#${t}${t}${t}`}static RGB_G([e,t,i]){return["G",.3*e+.59*t+.11*i]}static RGB_rgb(e){return e.map(scaleAndClamp)}static RGB_HTML(e){return`#${e.map(makeColorComp).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,i,a]){return["RGB",1-Math.min(1,e+a),1-Math.min(1,i+a),1-Math.min(1,t+a)]}static CMYK_rgb([e,t,i,a]){return[scaleAndClamp(1-Math.min(1,e+a)),scaleAndClamp(1-Math.min(1,i+a)),scaleAndClamp(1-Math.min(1,t+a))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,i]){const a=1-e,s=1-t,r=1-i;return["CMYK",a,s,r,Math.min(a,s,r)]}}class BaseSVGFactory{create(e,t,i=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");a.setAttribute("version","1.1");if(!i){a.setAttribute("width",`${e}px`);a.setAttribute("height",`${t}px`)}a.setAttribute("preserveAspectRatio","none");a.setAttribute("viewBox",`0 0 ${e} ${t}`);return a}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){unreachable("Abstract method `_createSVG` called.")}}class DOMSVGFactory extends BaseSVGFactory{_createSVG(e){return document.createElementNS(r,e)}}function annotation_layer_defineProperty(e,t,i){return(t=function annotation_layer_toPropertyKey(e){var t=function annotation_layer_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function annotation_layer_classPrivateGetter(e,t,i){return i(annotation_layer_assertClassBrand(e,t))}function annotation_layer_classPrivateMethodInitSpec(e,t){annotation_layer_checkPrivateRedeclaration(e,t),t.add(e)}function annotation_layer_classPrivateFieldInitSpec(e,t,i){annotation_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_layer_classPrivateFieldSet(e,t,i){return e.set(annotation_layer_assertClassBrand(e,t),i),i}function annotation_layer_classPrivateFieldGet(e,t){return e.get(annotation_layer_assertClassBrand(e,t))}function annotation_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Al=new WeakSet,Gl=60*(new Date).getTimezoneOffset()*1e3;class AnnotationElementFactory{static create(e){switch(e.data.annotationType){case k.LINK:return new LinkAnnotationElement(e);case k.TEXT:return new TextAnnotationElement(e);case k.WIDGET:switch(e.data.fieldType){case"Tx":return new TextWidgetAnnotationElement(e);case"Btn":return e.data.radioButton?new RadioButtonWidgetAnnotationElement(e):e.data.checkBox?new CheckboxWidgetAnnotationElement(e):new PushButtonWidgetAnnotationElement(e);case"Ch":return new ChoiceWidgetAnnotationElement(e);case"Sig":return new SignatureWidgetAnnotationElement(e)}return new WidgetAnnotationElement(e);case k.POPUP:return new PopupAnnotationElement(e);case k.FREETEXT:return new FreeTextAnnotationElement(e);case k.LINE:return new LineAnnotationElement(e);case k.SQUARE:return new SquareAnnotationElement(e);case k.CIRCLE:return new CircleAnnotationElement(e);case k.POLYLINE:return new PolylineAnnotationElement(e);case k.CARET:return new CaretAnnotationElement(e);case k.INK:return new InkAnnotationElement(e);case k.POLYGON:return new PolygonAnnotationElement(e);case k.HIGHLIGHT:return new HighlightAnnotationElement(e);case k.UNDERLINE:return new UnderlineAnnotationElement(e);case k.SQUIGGLY:return new SquigglyAnnotationElement(e);case k.STRIKEOUT:return new StrikeOutAnnotationElement(e);case k.STAMP:return new StampAnnotationElement(e);case k.FILEATTACHMENT:return new FileAttachmentAnnotationElement(e);case k.RICHMEDIA:case k.SCREEN:case k.SOUND:return new MediaAnnotationElement(e);default:return new AnnotationElement(e)}}}var Bl=new WeakMap,Ml=new WeakMap,Il=new WeakMap,Tl=new WeakSet;class AnnotationElement{get _ngxForms(){return this.linkService?.ngxFormSupport??window}get _ngxViewerRoot(){return this.layer?.closest(".pdfViewer")??document}constructor(e,{isRenderable:t=!1,ignoreBorder:i=!1,createQuadrilaterals:a=!1}={}){annotation_layer_classPrivateMethodInitSpec(this,Tl);annotation_layer_classPrivateFieldInitSpec(this,Bl,null);annotation_layer_classPrivateFieldInitSpec(this,Ml,!1);annotation_layer_classPrivateFieldInitSpec(this,Il,null);this.isRenderable=t;this.data=e.data;this.layer=e.layer;this.linkService=e.linkService;this.downloadManager=e.downloadManager;this.imageResourcesPath=e.imageResourcesPath;this.renderForms=e.renderForms;this.annotationStorage=e.annotationStorage;this.enableComment=e.enableComment;this.enableAnnotationEditing=!1!==e.enableAnnotationEditing;this.enableScripting=e.enableScripting;this.hasJSActions=e.hasJSActions;this._fieldObjects=e.fieldObjects;this.parent=e.parent;this.hasOwnCommentButton=!1;t&&(this.contentElement=this.container=this._createContainer(i));a&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:t}){return!(!e?.str&&!t?.str)}static get _svgFactory(){return shadow(this,"_svgFactory",new DOMSVGFactory)}get _isEditable(){return this.enableAnnotationEditing&&this.data.isEditable}get hasPopupData(){return AnnotationElement._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:e}=this,t=this.annotationStorage?.getEditor(e.id);return t?t.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const e=this.annotationStorage?.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const{quadPoints:t,inkLists:i,rect:a}=this.data;let s=-1/0,r=-1/0;if(t?.length>=8){for(let e=0;e<t.length;e+=8)if(t[e+1]>r){r=t[e+1];s=t[e+2]}else t[e+1]===r&&(s=Math.max(s,t[e+2]));return[s,r]}if(i?.length>=1){for(const e of i)for(let t=0,i=e.length;t<i;t+=2)if(e[t+1]>r){r=e[t+1];s=e[t]}else e[t+1]===r&&(s=Math.max(s,e[t]));if(s!==1/0)return[s,r]}return a?[a[2],a[3]]:null}_normalizePoint(e){const{page:{view:t},viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:r}}}=this.parent;e[1]=t[3]-e[1]+t[1];e[0]=100*(e[0]-s)/i;e[1]=100*(e[1]-r)/a;return e}get commentText(){const{data:e}=this;return this.annotationStorage.getRawValue(`${m}${e.id}`)?.popup?.contents||e.contentsObj?.str||""}set commentText(e){const{data:t}=this,i={deleted:!e,contents:e||""};this.annotationStorage.updateEditor(t.id,{popup:i})||this.annotationStorage.setValue(`${m}${t.id}`,{id:t.id,annotationType:t.annotationType,page:this.parent.page,popup:i,popupRef:t.popupRef,modificationDate:new Date});e||this.removePopup()}removePopup(){(annotation_layer_classPrivateFieldGet(Il,this)?.popup||this.popup)?.remove();annotation_layer_classPrivateFieldSet(Il,this,this.popup=null)}updateEdited(e){if(!this.container)return;e.rect&&(annotation_layer_classPrivateFieldGet(Bl,this)||annotation_layer_classPrivateFieldSet(Bl,this,{rect:this.data.rect.slice(0)}));const{rect:t,popup:i}=e;t&&annotation_layer_assertClassBrand(Tl,this,_setRectEdited).call(this,t);let a=annotation_layer_classPrivateFieldGet(Il,this)?.popup||this.popup;if(!a&&i?.text){this._createPopup(i);a=annotation_layer_classPrivateFieldGet(Il,this).popup}if(a){a.updateEdited(e);if(i?.deleted){a.remove();annotation_layer_classPrivateFieldSet(Il,this,null);this.popup=null}}}resetEdited(){if(annotation_layer_classPrivateFieldGet(Bl,this)){annotation_layer_assertClassBrand(Tl,this,_setRectEdited).call(this,annotation_layer_classPrivateFieldGet(Bl,this).rect);annotation_layer_classPrivateFieldGet(Il,this)?.popup.resetEdited();annotation_layer_classPrivateFieldSet(Bl,this,null)}}_createContainer(e){const{data:t,parent:{page:i,viewport:a}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",t.id);this instanceof WidgetAnnotationElement||this instanceof LinkAnnotationElement||this instanceof MediaAnnotationElement||(s.tabIndex=0);const{style:r}=s;r.zIndex=this.parent.zIndex;this.parent.zIndex+=2;t.alternativeText&&(s.title=t.alternativeText);t.noRotate&&s.classList.add("norotate");if(!t.rect||this instanceof PopupAnnotationElement){const{rotation:e}=t;t.hasOwnCanvas||0===e||this.setRotation(e,s);return s}const{width:n,height:o}=this;if(!e&&t.borderStyle.width>0){r.borderWidth=`${t.borderStyle.width}px`;const e=t.borderStyle.horizontalCornerRadius,i=t.borderStyle.verticalCornerRadius;if(e>0||i>0){const t=`calc(${e}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;r.borderRadius=t}else if(this instanceof RadioButtonWidgetAnnotationElement){const e=`calc(${n}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;r.borderRadius=e}switch(t.borderStyle.style){case E:r.borderStyle="solid";break;case A:r.borderStyle="dashed";break;case G:warn("Unimplemented border style: beveled");break;case B:warn("Unimplemented border style: inset");break;case M:r.borderBottomStyle="solid"}const a=t.borderColor||null;if(a){annotation_layer_classPrivateFieldSet(Ml,this,!0);r.borderColor=Util.makeHexColor(...a)}else r.borderWidth=0}const l=Util.normalizeRect([t.rect[0],i.view[3]-t.rect[1]+i.view[1],t.rect[2],i.view[3]-t.rect[3]+i.view[1]]),{pageWidth:d,pageHeight:c,pageX:h,pageY:_}=a.rawDims;r.left=100*(l[0]-h)/d+"%";r.top=100*(l[1]-_)/c+"%";const{rotation:u}=t;if(t.hasOwnCanvas||0===u){r.width=100*n/d+"%";r.height=100*o/c+"%"}else this.setRotation(u,s);return s}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:a}=this.parent.viewport.rawDims;let{width:s,height:r}=this;e%180!=0&&([s,r]=[r,s]);t.style.width=100*s/i+"%";t.style.height=100*r/a+"%";t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const setColor=(e,t,i)=>{const a=i.detail[e],s=a[0],r=a.slice(1);i.target.style[t]=ColorConverters[`${s}_HTML`](r);this.annotationStorage.setValue(this.data.id,{[t]:ColorConverters[`${s}_rgb`](r)})};return shadow(this,"_commonActions",{display:e=>{const{display:t}=e.detail,i=t%2==1;this.container.style.visibility=i?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:t}=e.detail;this.container.style.visibility=t?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{setColor("bgColor","backgroundColor",e)},fillColor:e=>{setColor("fillColor","backgroundColor",e)},fgColor:e=>{setColor("fgColor","color",e)},textColor:e=>{setColor("textColor","color",e)},borderColor:e=>{setColor("borderColor","borderColor",e)},strokeColor:e=>{setColor("strokeColor","borderColor",e)},rotation:e=>{const t=e.detail.rotation;this.setRotation(t);this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){const i=this._commonActions;for(const a of Object.keys(t.detail)){const s=e[a]||i[a];s?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const i=this._commonActions;for(const[a,s]of Object.entries(t)){const r=i[a];if(r){r({detail:{[a]:s},target:e});delete t[a]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,i,a,s]=this.data.rect.map(Math.fround);if(8===e.length){const[r,n,o,l]=e.subarray(2,6);if(a===r&&s===n&&t===o&&i===l)return}const{style:n}=this.container;let o;if(annotation_layer_classPrivateFieldGet(Ml,this)){const{borderColor:e,borderWidth:t}=n;n.borderWidth=0;o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${r}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`];this.container.classList.add("hasBorder")}const l=a-t,d=s-i,c=AnnotationElement._svgFactory,h=c.createElement("svg");h.classList.add("quadrilateralsContainer");h.setAttribute("width",0);h.setAttribute("height",0);h.role="none";const _=c.createElement("defs");h.append(_);const u=c.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p);u.setAttribute("clipPathUnits","objectBoundingBox");_.append(u);for(let i=2,a=e.length;i<a;i+=8){const a=e[i],r=e[i+1],n=e[i+2],h=e[i+3],_=c.createElement("rect"),p=(n-t)/l,g=(s-r)/d,m=(a-n)/l,f=(r-h)/d;_.setAttribute("x",p);_.setAttribute("y",g);_.setAttribute("width",m);_.setAttribute("height",f);u.append(_);o?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${g}" width="${m}" height="${f}"/>`)}if(annotation_layer_classPrivateFieldGet(Ml,this)){o.push("</g></svg>')");n.backgroundImage=o.join("")}this.container.append(h);this.container.style.clipPath=`url(#${p})`}_createPopup(e=null){const{data:t}=this;let i,a;if(e){i={str:e.text};a=e.date}else{i=t.contentsObj;a=t.modificationDate}annotation_layer_classPrivateFieldSet(Il,this,new PopupAnnotationElement({data:{color:t.color,titleObj:t.titleObj,modificationDate:a,contentsObj:i,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(annotation_layer_classPrivateFieldGet(Il,this)||this.popup||this.data.popupRef)}get extraPopupElement(){return annotation_layer_classPrivateFieldGet(Il,this)}render(){unreachable("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const i=[];if(this._fieldObjects){const a=this._fieldObjects.get(e)||[];for(const{page:e,id:s,exportValues:r}of a){if(-1===e||s===t)continue;const a="string"==typeof r?r:null,n=this._ngxViewerRoot.querySelector(`[data-element-id="${s}"]`);!n||Al.has(n)?i.push({id:s,exportValue:a,domElement:n}):warn(`_getElementsByName - element not allowed: ${s}`)}return i}for(const a of this._ngxViewerRoot.querySelectorAll(`[name="${CSS.escape(e)}"]`)){const{exportValue:e}=a,s=a.getAttribute("data-element-id");s!==t&&Al.has(a)&&i.push({id:s,exportValue:e,domElement:a})}return i}show(){this.container&&(this.container.hidden=!1);this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0);this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t,mustEnterInEditMode:!0})})}updateOC(e){if(!this.data.oc||!e)return;e.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":Util.makeHexColor(...t)}}function _setRectEdited(e){const{container:{style:t},data:{rect:i,rotation:a},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:r,pageX:n,pageY:o}}}}=this;i?.splice(0,4,...e);t.left=100*(e[0]-n)/s+"%";t.top=100*(r-e[3]+o)/r+"%";if(0===a){t.width=100*(e[2]-e[0])/s+"%";t.height=100*(e[3]-e[1])/r+"%"}else this.setRotation(a)}class EditorAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.editor=e.editor}render(){this.container.className="editorAnnotation";return this.container}createOrUpdatePopup(){const{editor:e}=this;e.hasComment&&this._createPopup(e.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e;e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id);this.container.remove();this.container=null;this.removePopup()}}var Dl=new WeakSet;class LinkAnnotationElement extends AnnotationElement{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0});annotation_layer_classPrivateMethodInitSpec(this,Dl);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:t}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let a=!1;if(e.url){t.addLinkAttributes(i,e.url,e.newWindow);a=!0}else if(e.action){this._bindNamedAction(i,e.action,e.overlaidText);a=!0}else if(e.attachment){annotation_layer_assertClassBrand(Dl,this,_bindAttachment).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest);a=!0}else if(e.setOCGState){annotation_layer_assertClassBrand(Dl,this,_bindSetOCGState).call(this,i,e.setOCGState,e.overlaidText);a=!0}else if(e.dest){this._bindLink(i,e.dest,e.overlaidText);a=!0}else{if(e.actions&&(e.actions.has("Action")||e.actions.has("Mouse Up")||e.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions){this._bindJSAction(i,e);a=!0}if(e.resetForm){this._bindResetFormAction(i,e.resetForm);a=!0}else if(this.isTooltipOnly&&!a){this._bindLink(i,"");a=!0}}this.container.classList.add("linkAnnotation");if(a){this.contentElement=i;this.container.append(i)}return this.container}_bindLink(e,t,i=""){e.href=this.linkService.getDestinationHash(t);e.onclick=()=>{t&&this.linkService.goToDestination(t);return!1};(t||""===t)&&annotation_layer_assertClassBrand(Dl,this,_setInternalLink).call(this);i&&(e.title=i)}_bindNamedAction(e,t,i=""){e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeNamedAction(t);return!1};i&&(e.title=i);annotation_layer_assertClassBrand(Dl,this,_setInternalLink).call(this)}_bindJSAction(e,{actions:t,id:i,overlaidText:a}){e.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const a of t.keys()){const t=s.get(a);t&&(e[t]=()=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:a}});return!1})}a&&(e.title=a);e.onclick||=()=>!1;annotation_layer_assertClassBrand(Dl,this,_setInternalLink).call(this)}_bindResetFormAction(e,t){const i=e.onclick;i||(e.href=this.linkService.getAnchorUrl(""));annotation_layer_assertClassBrand(Dl,this,_setInternalLink).call(this);if(this._fieldObjects)e.onclick=()=>{i?.();const{fields:e,refs:a,include:s}=t,r=[];if(0!==e.length||0!==a.length){const t=new Set(a);for(const i of e){const e=this._fieldObjects.get(i)||[];for(const{id:i}of e)t.add(i)}const i=new Map;for(const e of this._fieldObjects.values())for(const{id:t,kidIds:a}of e)a&&i.set(t,a);for(const e of t)for(const a of i.get(e)||[])t.add(a);for(const e of this._fieldObjects.values())for(const i of e)t.has(i.id)===s&&r.push(i)}else for(const e of this._fieldObjects.values())r.push(...e);const n=this.annotationStorage,o=[];for(const e of r){const{id:t}=e;o.push(t);switch(e.type){case"text":{const i=e.defaultValue||"";n.setValue(t,{value:i});this._ngxForms.updateAngularFormValue(t,{value:i});break}case"checkbox":case"radiobutton":{const i=e.defaultValue===e.exportValues;n.setValue(t,{value:i});this._ngxForms.updateAngularFormValue(t,{value:i});break}case"combobox":case"listbox":{const i=e.defaultValue||"";n.setValue(t,{value:i});this._ngxForms.updateAngularFormValue(t,{value:i});break}default:continue}const i=this._ngxViewerRoot.querySelector(`[data-element-id="${t}"]`);i&&(Al.has(i)?i.dispatchEvent(new Event("resetform")):warn(`_bindResetFormAction - element not allowed: ${t}`))}this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}});return!1};else{warn('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.');i||(e.onclick=()=>!1)}}}function _setInternalLink(){this.container.setAttribute("data-internal-link","")}function _bindAttachment(e,t,i,a="",s=null){e.href=this.linkService.getAnchorUrl("");i.description?e.title=i.description:a&&(e.title=a);const openAttachment=async()=>{const e=await this.linkService.getAttachmentContent(t);e&&this.downloadManager?.openOrDownloadData(e,i.filename,s)};e.onclick=()=>{openAttachment();return!1};annotation_layer_assertClassBrand(Dl,this,_setInternalLink).call(this)}function _bindSetOCGState(e,t,i=""){e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeSetOCGState(t);return!1};i&&(e.title=i);annotation_layer_assertClassBrand(Dl,this,_setInternalLink).call(this)}class TextAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg";e.setAttribute("data-l10n-id","pdfjs-text-annotation-type");e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name}));if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.append(e);return this.container}}class WidgetAnnotationElement extends AnnotationElement{render(){return this.container}_getKeyModifier(e){return FeatureTest.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,i,a,s){i.includes("mouse")?e.addEventListener(i,e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:s(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(i,e=>{if("blur"===i){if(!t.focused)return;t.focused=!1}else if("focus"===i){if(t.focused)return;t.focused=!0}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:s(e)}})})}_setEventListeners(e,t,i,a){const{actions:s}=this.data;for(const[r,n]of i)if("Action"===n||s?.has(n)){"Focus"!==n&&"Blur"!==n||(t||={focused:!1});this._setEventListener(e,t,r,n,a);"Focus"!==n||s?.has("Blur")?"Blur"!==n||s?.has("Focus")||this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null)}}_setTextStyle(e){const t=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,a=this.data.defaultAppearanceData.fontSize||9,s=e.style;let r;const roundToOneDecimal=e=>Math.round(10*e)/10;if(this.data.multiLine){const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(1.35*a))||1);r=Math.min(a,roundToOneDecimal(t/1.35))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(a,roundToOneDecimal(e/1.35))}s.fontSize=`calc(${r}px * var(--total-scale-factor))`;s.color=Util.makeHexColor(...i);null===this.data.textAlignment||this.data.comb||(s.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required");e.setAttribute("aria-required",t)}}class TextWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,i,a){const s=this.annotationStorage;for(const r of this._getElementsByName(e.name,e.id)){r.domElement&&(r.domElement[t]=i);s.setValue(r.id,{[a]:i})}}render(){const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const a=this._ngxForms.getFormValueFromAngular(this.data.fieldName),s=e.getValue(t,{value:this.data.fieldValue}),r=a.value?a:s;if(a!==s){e.setValue(t,{value:a.value});r.formattedValue=a.value}let n=r.value||"";const o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&n.length>o&&(n=n.slice(0,o));let l=r.formattedValue||this.data.textContent?.join("\n")||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const d={userValue:n,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){i=document.createElement("textarea");i.textContent=l??n;this.data.doNotScroll&&(i.style.overflowY="hidden")}else{i=document.createElement("input");i.type=this.data.password?"password":"text";i.setAttribute("value",l??n);this.data.doNotScroll&&(i.style.overflowX="hidden")}if(this.data.hasOwnCanvas){this.container.classList.add("hasOwnCanvas");e.has(t)&&this.container.classList.add("sandboxModified")}Al.add(i);this.contentElement=i;i.setAttribute("data-element-id",t);i.disabled=this.data.readOnly;i.name=this.data.fieldName;i.tabIndex=0;const{datetimeFormat:c,datetimeType:h,timeStep:_}=this.data,u=!!h&&this.enableScripting;c&&(i.title=c);this._setRequired(i,this.data.required);o&&(i.maxLength=o);i.addEventListener("input",a=>{e.setValue(t,{value:a.target.value});this._ngxForms.updateAngularFormValue(t,{value:a.target.value});this.setPropertyOnSiblings(i,"value",a.target.value,"value");d.formattedValue=null});i.addEventListener("resetform",e=>{const t=this.data.defaultFieldValue??"";i.value=d.userValue=t;d.formattedValue=null});let blurListener=e=>{const{formattedValue:t}=d;null!=t&&(e.target.value=t);e.target.scrollLeft=0};this._ngxForms.registerAcroformField(t,i,r.value,void 0,this.data.fieldValue);i.addEventListener("updateFromAngular",i=>{d.formattedValue=null;e.setValue(t,{value:i.detail})});if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",e=>{if(d.focused)return;const{target:t}=e;if(u){t.type=h;_&&(t.step=_)}if(d.userValue){const e=d.userValue;if(u)if("time"===h){const i=new Date(e),a=[i.getHours(),i.getMinutes(),i.getSeconds()];t.value=a.map(e=>e.toString().padStart(2,"0")).join(":")}else t.value=new Date(e-Gl).toISOString().split("date"===h?"T":".",1)[0];else t.value=e}d.lastCommittedValue=t.value;d.commitKey=1;this.data.actions?.has("Focus")||(d.focused=!0)});i.addEventListener("updatefromsandbox",i=>{this.container.classList.add("sandboxModified");const a=this._ngxForms,s={value(i){d.userValue=i.detail.value??"";if(!u){e.setValue(t,{value:d.userValue.toString()});a.updateAngularFormValue(t,{value:d.userValue.toString()})}i.target.value=d.userValue},formattedValue(i){const{formattedValue:s}=i.detail;d.formattedValue=s;null!=s&&i.target!==document.activeElement&&(i.target.value=s);const r={formattedValue:s};u&&(r.value=s);e.setValue(t,r);a.updateAngularFormValue(t,{formattedValue:s})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:i=>{const{charLimit:a}=i.detail,{target:s}=i;if(0===a){s.removeAttribute("maxLength");return}s.setAttribute("maxLength",a);let r=d.userValue;if(r&&!(r.length<=a)){r=r.slice(0,a);s.value=d.userValue=r;e.setValue(t,{value:r});this._ngxForms.updateAngularFormValue(t,{value:r});this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}})}}};this._dispatchEventFromSandbox(s,i)});i.addEventListener("keydown",e=>{d.commitKey=1;let i=-1;"Escape"===e.key?i=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(d.commitKey=3):i=2;if(-1===i)return;const{value:a}=e.target;if(d.lastCommittedValue!==a){d.lastCommittedValue=a;d.userValue=a;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,willCommit:!0,commitKey:i,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})}});const a=blurListener;blurListener=null;i.addEventListener("blur",e=>{if(!d.focused)return;this.data.actions?.has("Blur")||(d.focused=!1);const{target:i}=e;let{value:s}=i;if(u){if(s&&"time"===h){const e=s.split(":").map(e=>parseInt(e,10));s=new Date(2e3,0,1,e[0],e[1],e[2]||0).valueOf();i.step=""}else{s.includes("T")||(s=`${s}T00:00`);s=new Date(s).valueOf()}i.type="text"}d.userValue=s;d.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,willCommit:!0,commitKey:d.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}});a(e)});this.data.actions?.has("Keystroke")&&i.addEventListener("beforeinput",e=>{d.lastCommittedValue=null;const{data:i,target:a}=e,{value:s,selectionStart:r,selectionEnd:n}=a;let o=r,l=n;switch(e.inputType){case"deleteWordBackward":{const e=/\w/;for(;o>0&&!e.test(s[o-1]);)o--;for(;o>0&&e.test(s[o-1]);)o--;break}case"deleteWordForward":{const e=s.substring(r).match(/^\W*\w*/);e&&(l+=e[0].length);break}case"deleteContentBackward":r===n&&(o-=1);break;case"deleteContentForward":r===n&&(l+=1)}e.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,change:i||"",willCommit:!1,selStart:o,selEnd:l}})});this._setEventListeners(i,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.value)}blurListener&&i.addEventListener("blur",blurListener);if(this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/o;i.classList.add("comb");i.style.setProperty("--comb-width",`calc(${e}px * var(--total-scale-factor))`);const t=this.data.textAlignment;if(1===t||2===t){const setCombOffset=()=>{const e=o-i.value.length;i.style.setProperty("--comb-offset",`${1===t?e>>1:e}`)};setCombOffset();for(const e of["input","blur","resetform","updatefromsandbox"])i.addEventListener(e,setCombOffset)}}}else{i=document.createElement("div");i.textContent=this.data.fieldValue;i.style.verticalAlign="middle";i.style.display="table-cell";this.data.hasOwnCanvas&&(i.hidden=!0)}this._setTextStyle(i);this._setBackgroundColor(i);this._setDefaultPropertiesFromJS(i);this.container.append(i);return this.container}}class SignatureWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,i=t.id,a=this._ngxForms.getFormValueFromAngular(this.data.fieldName),s=e.getValue(i,{value:t.exportValue===t.fieldValue}).value;let r;a.value&&(r=!0===a.value||a.value===t.exportValue);let n=void 0!==r?r:s,o=!1;if("string"==typeof n){n=n===t.exportValue;e.setValue(i,{value:n});o=!0}else if(void 0!==a?.value&&a.value!==s){n=!0===a.value||a.value===t.exportValue?t.exportValue:void 0;e.setValue(i,{value:n})}this.container.classList.add("buttonWidgetAnnotation","checkBox");const l=document.createElement("input");Al.add(l);l.setAttribute("data-element-id",i);l.disabled=t.readOnly;this._setRequired(l,this.data.required);l.type="checkbox";l.name=t.fieldName;n&&l.setAttribute("checked",!0);l.setAttribute("exportValue",t.exportValue);l.tabIndex=0;l.addEventListener("change",a=>{const{name:s,checked:r}=a.target;for(const a of this._getElementsByName(s,i)){const s=r&&a.exportValue===t.exportValue;a.domElement&&(a.domElement.checked=s);e.setValue(a.id,{value:s});this._ngxForms.updateAngularFormValue(i,{value:s})}e.setValue(i,{value:r});this._ngxForms.updateAngularFormValue(i,{value:r})});l.addEventListener("resetform",e=>{const i=t.defaultFieldValue||"Off";e.target.checked=i===t.exportValue});this._ngxForms.registerAcroformField(i,l,n?t.exportValue:void 0,void 0,this.data.fieldValue);l.addEventListener("updateFromAngular",t=>e.setValue(i,{value:t.detail}));o&&this._ngxForms.updateAngularFormValue(i,{value:n});if(this.enableScripting&&this.hasJSActions){l.addEventListener("updatefromsandbox",t=>{const a=this._ngxForms,s={value(t){t.target.checked="Off"!==t.detail.value;e.setValue(i,{value:t.target.checked});a.updateAngularFormValue(i,{value:t.target.value})}};this._dispatchEventFromSandbox(s,t)});this._setEventListeners(l,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)}this._setDefaultPropertiesFromJS(l);this.container.append(l);return this.container}}class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,i=t.id,a=this._ngxForms.getFormValueFromAngular(this.data.fieldName),s=null!==t.buttonValue&&t.fieldValue===t.buttonValue?t.buttonValue:void 0,r=e.getValue(i,{value:s}).value;let n=a.value??r;if("string"==typeof n||a!==r){n=n===t.buttonValue;e.setValue(i,{value:n})}else n&&this._ngxForms.updateAngularFormValue(i,{value:t.buttonValue});if(n)for(const a of this._getElementsByName(t.fieldName,i))e.setValue(a.id,{value:!1});const o=document.createElement("input");Al.add(o);o.setAttribute("data-element-id",i);o.disabled=t.readOnly;this._setRequired(o,this.data.required);o.type="radio";o.name=t.fieldName;const l=this.linkService?.ngxRadioGroupForm;l&&o.setAttribute("form",l);n&&o.setAttribute("checked",!0);o.tabIndex=0;o.addEventListener("change",t=>{const{name:a,checked:s}=t.target;for(const t of this._getElementsByName(a,i)){e.setValue(t.id,{value:!1});this._ngxForms.updateAngularFormValue(t.id,{value:!1})}e.setValue(i,{value:s});this._ngxForms.updateAngularFormValue(i,{value:s})});o.addEventListener("resetform",e=>{const i=t.defaultFieldValue;e.target.checked=null!=i&&i===t.buttonValue});this._ngxForms.registerAcroformField(i,o,n?t.buttonValue:void 0,t.buttonValue,this.data.fieldValue);o.addEventListener("updateFromAngular",t=>e.setValue(i,{value:t.detail}));if(this.enableScripting&&this.hasJSActions){const a=t.buttonValue;o.addEventListener("updatefromsandbox",t=>{const s={value:t=>{const s=a===t.detail.value;for(const a of this._getElementsByName(t.target.name)){const t=s&&a.id===i;a.domElement&&(a.domElement.checked=t);e.setValue(a.id,{value:t});this._ngxForms.updateAngularFormValue(i,{value:t})}}};this._dispatchEventFromSandbox(s,t)});this._setEventListeners(o,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)}this._setDefaultPropertiesFromJS(o);this.container.append(o);return this.container}}class PushButtonWidgetAnnotationElement extends LinkAnnotationElement{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;if(this.enableScripting&&this.hasJSActions&&t){this._setDefaultPropertiesFromJS(t);t.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({},e)})}return e}}class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,i=this._ngxForms.getFormValueFromAngular(this.data.fieldName),a=e.getValue(t,{value:this.data.fieldValue}),s=i.value?i:a;i!==a&&e.setValue(t,{value:i.value});const r=document.createElement("select");Al.add(r);r.setAttribute("data-element-id",t);r.disabled=this.data.readOnly;this._setRequired(r,this.data.required);r.name=this.data.fieldName;r.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;if(!this.data.combo){r.size=this.data.options.length;this.data.multiSelect&&(r.multiple=!0)}r.addEventListener("resetform",e=>{const t=this.data.defaultFieldValue;for(const e of r.options)e.selected=e.value===t});const fixDisplayValue=(e,t)=>{const i=t.replaceAll(" "," ");e.textContent=i;i!==t&&e.setAttribute("display-value",t)};for(const e of this.data.options){const t=document.createElement("option");fixDisplayValue(t,e.displayValue);t.value=e.exportValue;if(s.value.includes(e.exportValue)){t.setAttribute("selected",!0);n=!1}r.append(t)}let o=null;if(n){const e=document.createElement("option");e.value=" ";e.setAttribute("hidden",!0);e.setAttribute("selected",!0);r.prepend(e);o=()=>{e.remove();r.removeEventListener("input",o);o=null};r.addEventListener("input",o)}const getValue=e=>{const t=e?"value":"textContent",{options:i,multiple:a}=r;return a?Array.prototype.filter.call(i,e=>e.selected).map(e=>e[t]):-1===i.selectedIndex?null:i[i.selectedIndex][t]};let l=getValue(!1);const getItems=e=>{const t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.getAttribute("display-value")||e.textContent,exportValue:e.value}))};this._ngxForms.registerAcroformField(t,r,l,void 0,this.data.fieldValue);r.addEventListener("updateFromAngular",i=>e.setValue(t,{value:i.detail}));if(this.enableScripting&&this.hasJSActions){r.addEventListener("updatefromsandbox",i=>{const a=this._ngxForms,s={value(i){o?.();const s=i.detail.value,n=new Set(Array.isArray(s)?s:[s]);for(const e of r.options)e.selected=n.has(e.value);e.setValue(t,{value:getValue(!0)});l=getValue(!1);a.updateAngularFormValue(t,{value:l})},multipleSelection(e){r.multiple=!0},remove(i){const a=r.options,s=i.detail.remove;a[s].selected=!1;r.remove(s);if(a.length>0){-1===Array.prototype.findIndex.call(a,e=>e.selected)&&(a[0].selected=!0)}e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1)},clear(i){for(;0!==r.length;)r.remove(0);e.setValue(t,{value:null,items:[]});l=getValue(!1);a.updateAngularFormValue(t,{value:l})},insert(i){const{index:s,displayValue:n,exportValue:o}=i.detail.insert,d=r.children[s],c=document.createElement("option");fixDisplayValue(c,n);c.value=o;d?d.before(c):r.append(c);e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1);a.updateAngularFormValue(t,{value:l})},items(i){const{items:s}=i.detail;for(;0!==r.length;)r.remove(0);for(const e of s){const{displayValue:t,exportValue:i}=e,a=document.createElement("option");fixDisplayValue(a,t);a.value=i;r.append(a)}r.options.length>0&&(r.options[0].selected=!0);e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1);a.updateAngularFormValue(t,{value:l})},indices(i){const s=new Set(i.detail.indices);for(const e of i.target.options)e.selected=s.has(e.index);e.setValue(t,{value:getValue(!0)});l=getValue(!1);a.updateAngularFormValue(t,{value:l})},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(s,i)});r.addEventListener("input",i=>{const a=getValue(!0),s=getValue(!1);e.setValue(t,{value:a});this._ngxForms.updateAngularFormValue(t,{value:a});i.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:l,change:s,changeEx:a,willCommit:!1,commitKey:1,keyDown:!1}})});this._setEventListeners(r,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],e=>e.target.value)}else{const i=this._ngxForms;r.addEventListener("input",function(a){e.setValue(t,{value:getValue(!0)});i.updateAngularFormValue(t,{value:getValue(!0)})})}this.data.combo&&this._setTextStyle(r);this._setBackgroundColor(r);this._setDefaultPropertiesFromJS(r);this.container.append(r);return this.container}}var Ll=new WeakSet;class PopupAnnotationElement extends AnnotationElement{constructor(e){const{data:t,elements:i,parent:a}=e,s=!!a._commentManager;super(e,{isRenderable:!s&&AnnotationElement._hasPopupData(t)});annotation_layer_classPrivateMethodInitSpec(this,Ll);this.elements=i;if(s&&AnnotationElement._hasPopupData(t)){const e=this.popup=annotation_layer_assertClassBrand(Ll,this,_createPopup).call(this);for(const t of i)t.popup=e}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation");e.role="comment";const t=this.popup=annotation_layer_assertClassBrand(Ll,this,_createPopup).call(this),i=[];for(const e of this.elements){e.popup=t;e.container.ariaHasPopup="dialog";i.push(e.data.id);e.addHighlightArea()}this.container.setAttribute("aria-controls",i.map(e=>`${g}${e}`).join(","));return this.container}}function _createPopup(){return new PopupElement({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}var Rl=new WeakMap,Ol=new WeakMap,Nl=new WeakMap,Wl=new WeakMap,jl=new WeakMap,Vl=new WeakMap,Ul=new WeakMap,zl=new WeakMap,Hl=new WeakMap,$l=new WeakMap,Xl=new WeakMap,Kl=new WeakMap,ql=new WeakMap,Yl=new WeakMap,Zl=new WeakMap,Ql=new WeakMap,Jl=new WeakMap,ed=new WeakMap,td=new WeakMap,id=new WeakMap,ad=new WeakMap,sd=new WeakMap,rd=new WeakMap,nd=new WeakMap,od=new WeakMap,ld=new WeakMap,dd=new WeakSet;class PopupElement{constructor({container:e,color:t,elements:i,titleObj:a,modificationDate:s,contentsObj:r,richText:n,parent:o,rect:l,parentRect:d,open:c,commentManager:h=null}){annotation_layer_classPrivateMethodInitSpec(this,dd);annotation_layer_classPrivateFieldInitSpec(this,Rl,null);annotation_layer_classPrivateFieldInitSpec(this,Ol,annotation_layer_assertClassBrand(dd,this,annotation_layer_keyDown).bind(this));annotation_layer_classPrivateFieldInitSpec(this,Nl,annotation_layer_assertClassBrand(dd,this,_hide).bind(this));annotation_layer_classPrivateFieldInitSpec(this,Wl,annotation_layer_assertClassBrand(dd,this,_show).bind(this));annotation_layer_classPrivateFieldInitSpec(this,jl,annotation_layer_assertClassBrand(dd,this,_toggle).bind(this));annotation_layer_classPrivateFieldInitSpec(this,Vl,null);annotation_layer_classPrivateFieldInitSpec(this,Ul,null);annotation_layer_classPrivateFieldInitSpec(this,zl,null);annotation_layer_classPrivateFieldInitSpec(this,Hl,null);annotation_layer_classPrivateFieldInitSpec(this,$l,null);annotation_layer_classPrivateFieldInitSpec(this,Xl,null);annotation_layer_classPrivateFieldInitSpec(this,Kl,null);annotation_layer_classPrivateFieldInitSpec(this,ql,!1);annotation_layer_classPrivateFieldInitSpec(this,Yl,null);annotation_layer_classPrivateFieldInitSpec(this,Zl,null);annotation_layer_classPrivateFieldInitSpec(this,Ql,null);annotation_layer_classPrivateFieldInitSpec(this,Jl,null);annotation_layer_classPrivateFieldInitSpec(this,ed,null);annotation_layer_classPrivateFieldInitSpec(this,td,null);annotation_layer_classPrivateFieldInitSpec(this,id,null);annotation_layer_classPrivateFieldInitSpec(this,ad,null);annotation_layer_classPrivateFieldInitSpec(this,sd,null);annotation_layer_classPrivateFieldInitSpec(this,rd,null);annotation_layer_classPrivateFieldInitSpec(this,nd,!1);annotation_layer_classPrivateFieldInitSpec(this,od,null);annotation_layer_classPrivateFieldInitSpec(this,ld,null);annotation_layer_classPrivateFieldSet(Ul,this,e);annotation_layer_classPrivateFieldSet(sd,this,a);annotation_layer_classPrivateFieldSet(zl,this,r);annotation_layer_classPrivateFieldSet(ad,this,n);annotation_layer_classPrivateFieldSet(Xl,this,o);annotation_layer_classPrivateFieldSet(Vl,this,t);annotation_layer_classPrivateFieldSet(id,this,l);annotation_layer_classPrivateFieldSet(Kl,this,d);annotation_layer_classPrivateFieldSet($l,this,i);annotation_layer_classPrivateFieldSet(Rl,this,h);annotation_layer_classPrivateFieldSet(od,this,i[0]);annotation_layer_classPrivateFieldSet(Hl,this,PDFDateString.toDateObject(s));this.trigger=i.flatMap(e=>e.getElementsToTriggerPopup());if(!h){annotation_layer_assertClassBrand(dd,this,_addEventListeners).call(this);annotation_layer_classPrivateFieldGet(Ul,this).hidden=!0;c&&annotation_layer_assertClassBrand(dd,this,_toggle).call(this)}}renderCommentButton(){if(annotation_layer_classPrivateFieldGet(Jl,this)){annotation_layer_classPrivateFieldGet(Jl,this).parentNode||annotation_layer_classPrivateFieldGet(od,this).container.after(annotation_layer_classPrivateFieldGet(Jl,this));return}annotation_layer_classPrivateFieldGet(ed,this)||annotation_layer_assertClassBrand(dd,this,_setCommentButtonPosition).call(this);if(!annotation_layer_classPrivateFieldGet(ed,this))return;const{signal:e}=annotation_layer_classPrivateFieldSet(Zl,this,new AbortController),t=annotation_layer_classPrivateFieldGet(od,this).hasOwnCommentButton,togglePopup=()=>{annotation_layer_classPrivateFieldGet(Rl,this).toggleCommentPopup(this,!0,void 0,!t)},showPopup=()=>{annotation_layer_classPrivateFieldGet(Rl,this).toggleCommentPopup(this,!1,!0,!t)},hidePopup=()=>{annotation_layer_classPrivateFieldGet(Rl,this).toggleCommentPopup(this,!1,!1)};if(t){annotation_layer_classPrivateFieldSet(Jl,this,annotation_layer_classPrivateFieldGet(od,this).container);for(const t of this.trigger){t.ariaHasPopup="dialog";t.ariaControls="commentPopup";t.addEventListener("keydown",annotation_layer_classPrivateFieldGet(Ol,this),{signal:e});t.addEventListener("click",togglePopup,{signal:e});t.addEventListener("pointerenter",showPopup,{signal:e});t.addEventListener("pointerleave",hidePopup,{signal:e});t.classList.add("popupTriggerArea")}}else{const t=annotation_layer_classPrivateFieldSet(Jl,this,document.createElement("button"));t.className="annotationCommentButton";const i=annotation_layer_classPrivateFieldGet(od,this).container;t.style.zIndex=parseInt(i.style.zIndex,10)+1;t.tabIndex=0;t.ariaHasPopup="dialog";t.ariaControls="commentPopup";t.setAttribute("data-l10n-id","pdfjs-show-comment-button");annotation_layer_assertClassBrand(dd,this,_updateColor).call(this);annotation_layer_assertClassBrand(dd,this,_updateCommentButtonPosition).call(this);t.addEventListener("keydown",annotation_layer_classPrivateFieldGet(Ol,this),{signal:e});t.addEventListener("click",togglePopup,{signal:e});t.addEventListener("pointerenter",showPopup,{signal:e});t.addEventListener("pointerleave",hidePopup,{signal:e});i.after(t)}}get commentButtonColor(){const{color:e,opacity:t}=annotation_layer_classPrivateFieldGet(od,this).commentData;return e?annotation_layer_classPrivateFieldGet(Xl,this)._commentManager.makeCommentColor(e,t):null}focusCommentButton(){setTimeout(()=>{annotation_layer_classPrivateFieldGet(Jl,this)?.focus()},0)}getData(){const{richText:e,color:t,opacity:i,creationDate:a,modificationDate:s}=annotation_layer_classPrivateFieldGet(od,this).commentData;return{contentsObj:{str:this.comment},richText:e,color:t,opacity:i,creationDate:a,modificationDate:s}}get elementBeforePopup(){return annotation_layer_classPrivateFieldGet(Jl,this)}get comment(){annotation_layer_classPrivateFieldGet(ld,this)||annotation_layer_classPrivateFieldSet(ld,this,annotation_layer_classPrivateFieldGet(od,this).commentText);return annotation_layer_classPrivateFieldGet(ld,this)}set comment(e){e!==this.comment&&(annotation_layer_classPrivateFieldGet(od,this).commentText=annotation_layer_classPrivateFieldSet(ld,this,e))}focus(){annotation_layer_classPrivateFieldGet(od,this).container?.focus()}get parentBoundingClientRect(){return annotation_layer_classPrivateFieldGet(od,this).layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:t}){if(annotation_layer_classPrivateFieldGet(Jl,this)){annotation_layer_classPrivateFieldGet(Jl,this).classList.toggle("selected",e);annotation_layer_classPrivateFieldGet(Jl,this).ariaExpanded=t}}setSelectedCommentButton(e){annotation_layer_classPrivateFieldGet(Jl,this).classList.toggle("selected",e)}get commentPopupPosition(){if(annotation_layer_classPrivateFieldGet(td,this))return annotation_layer_classPrivateFieldGet(td,this);const{x:e,y:t,height:i}=annotation_layer_classPrivateFieldGet(Jl,this).getBoundingClientRect(),{x:a,y:s,width:r,height:n}=annotation_layer_classPrivateFieldGet(od,this).layer.getBoundingClientRect();return[(e-a)/r,(t+i-s)/n]}set commentPopupPosition(e){annotation_layer_classPrivateFieldSet(td,this,e)}hasDefaultPopupPosition(){return null===annotation_layer_classPrivateFieldGet(td,this)}get commentButtonPosition(){return annotation_layer_classPrivateFieldGet(ed,this)}get commentButtonWidth(){return annotation_layer_classPrivateFieldGet(Jl,this).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){const[t,i]=annotation_layer_classPrivateFieldGet(td,this)||this.commentButtonPosition.map(e=>e/100),a=this.parentBoundingClientRect,{x:s,y:r,width:n,height:o}=a;annotation_layer_classPrivateFieldGet(Rl,this).showDialog(null,this,s+t*n,r+i*o,{...e,parentDimensions:a})}render(){if(annotation_layer_classPrivateFieldGet(Yl,this))return;const e=annotation_layer_classPrivateFieldSet(Yl,this,document.createElement("div"));e.className="popup";if(annotation_layer_classPrivateFieldGet(Vl,this)){const t=e.style.outlineColor=Util.makeHexColor(...annotation_layer_classPrivateFieldGet(Vl,this));e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const t=document.createElement("span");t.className="header";if(annotation_layer_classPrivateFieldGet(sd,this)?.str){const e=document.createElement("span");e.className="title";t.append(e);({dir:e.dir,str:e.textContent}=annotation_layer_classPrivateFieldGet(sd,this))}e.append(t);if(annotation_layer_classPrivateFieldGet(Hl,this)){const e=document.createElement("time");e.className="popupDate";e.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string");e.setAttribute("data-l10n-args",JSON.stringify({dateObj:annotation_layer_classPrivateFieldGet(Hl,this).valueOf()}));e.dateTime=annotation_layer_classPrivateFieldGet(Hl,this).toISOString();t.append(e)}renderRichText({html:annotation_layer_classPrivateGetter(dd,this,_get_html)||annotation_layer_classPrivateFieldGet(zl,this).str,dir:annotation_layer_classPrivateFieldGet(zl,this)?.dir,className:"popupContent"},e);annotation_layer_classPrivateFieldGet(Ul,this).append(e)}updateEdited({rect:e,popup:t,deleted:i}){if(annotation_layer_classPrivateFieldGet(Rl,this)){if(i){this.remove();annotation_layer_classPrivateFieldSet(ld,this,null)}else if(t)if(t.deleted)this.remove();else{annotation_layer_assertClassBrand(dd,this,_updateColor).call(this);annotation_layer_classPrivateFieldSet(ld,this,t.text)}if(e){annotation_layer_classPrivateFieldSet(ed,this,null);annotation_layer_assertClassBrand(dd,this,_setCommentButtonPosition).call(this);annotation_layer_assertClassBrand(dd,this,_updateCommentButtonPosition).call(this)}}else if(i||t?.deleted)this.remove();else{annotation_layer_assertClassBrand(dd,this,_addEventListeners).call(this);annotation_layer_classPrivateFieldGet(rd,this)||annotation_layer_classPrivateFieldSet(rd,this,{contentsObj:annotation_layer_classPrivateFieldGet(zl,this),richText:annotation_layer_classPrivateFieldGet(ad,this)});e&&annotation_layer_classPrivateFieldSet(Ql,this,null);if(t&&t.text){annotation_layer_classPrivateFieldSet(ad,this,annotation_layer_assertClassBrand(dd,this,_makePopupContent).call(this,t.text));annotation_layer_classPrivateFieldSet(Hl,this,PDFDateString.toDateObject(t.date));annotation_layer_classPrivateFieldSet(zl,this,null)}annotation_layer_classPrivateFieldGet(Yl,this)?.remove();annotation_layer_classPrivateFieldSet(Yl,this,null)}}resetEdited(){if(annotation_layer_classPrivateFieldGet(rd,this)){({contentsObj:_toSetter(annotation_layer_classPrivateFieldSet,[zl,this])._,richText:_toSetter(annotation_layer_classPrivateFieldSet,[ad,this])._}=annotation_layer_classPrivateFieldGet(rd,this));annotation_layer_classPrivateFieldSet(rd,this,null);annotation_layer_classPrivateFieldGet(Yl,this)?.remove();annotation_layer_classPrivateFieldSet(Yl,this,null);annotation_layer_classPrivateFieldSet(Ql,this,null)}}remove(){annotation_layer_classPrivateFieldGet(Zl,this)?.abort();annotation_layer_classPrivateFieldSet(Zl,this,null);annotation_layer_classPrivateFieldGet(Yl,this)?.remove();annotation_layer_classPrivateFieldSet(Yl,this,null);annotation_layer_classPrivateFieldSet(nd,this,!1);annotation_layer_classPrivateFieldSet(ql,this,!1);annotation_layer_classPrivateFieldGet(Jl,this)?.remove();annotation_layer_classPrivateFieldSet(Jl,this,null);if(this.trigger)for(const e of this.trigger)e.classList.remove("popupTriggerArea")}forceHide(){annotation_layer_classPrivateFieldSet(nd,this,this.isVisible);annotation_layer_classPrivateFieldGet(nd,this)&&(annotation_layer_classPrivateFieldGet(Ul,this).hidden=!0)}maybeShow(){if(!annotation_layer_classPrivateFieldGet(Rl,this)){annotation_layer_assertClassBrand(dd,this,_addEventListeners).call(this);if(annotation_layer_classPrivateFieldGet(nd,this)){annotation_layer_classPrivateFieldGet(Yl,this)||annotation_layer_assertClassBrand(dd,this,_show).call(this);annotation_layer_classPrivateFieldSet(nd,this,!1);annotation_layer_classPrivateFieldGet(Ul,this).hidden=!1}}}get isVisible(){return!annotation_layer_classPrivateFieldGet(Rl,this)&&!1===annotation_layer_classPrivateFieldGet(Ul,this).hidden}}function _addEventListeners(){if(annotation_layer_classPrivateFieldGet(Zl,this))return;annotation_layer_classPrivateFieldSet(Zl,this,new AbortController);const{signal:e}=annotation_layer_classPrivateFieldGet(Zl,this);for(const t of this.trigger){t.addEventListener("click",annotation_layer_classPrivateFieldGet(jl,this),{signal:e});t.addEventListener("pointerenter",annotation_layer_classPrivateFieldGet(Wl,this),{signal:e});t.addEventListener("pointerleave",annotation_layer_classPrivateFieldGet(Nl,this),{signal:e});t.classList.add("popupTriggerArea")}for(const t of annotation_layer_classPrivateFieldGet($l,this))t.container?.addEventListener("keydown",annotation_layer_classPrivateFieldGet(Ol,this),{signal:e})}function _setCommentButtonPosition(){const e=annotation_layer_classPrivateFieldGet($l,this).find(e=>e.hasCommentButton);e&&annotation_layer_classPrivateFieldSet(ed,this,e._normalizePoint(e.commentButtonPosition))}function _updateCommentButtonPosition(){if(annotation_layer_classPrivateFieldGet(od,this).extraPopupElement&&!annotation_layer_classPrivateFieldGet(od,this).editor)return;annotation_layer_classPrivateFieldGet(Jl,this)||this.renderCommentButton();const[e,t]=annotation_layer_classPrivateFieldGet(ed,this),{style:i}=annotation_layer_classPrivateFieldGet(Jl,this);i.left=`calc(${e}%)`;i.top=`calc(${t}% - var(--comment-button-dim))`}function _updateColor(){if(!annotation_layer_classPrivateFieldGet(od,this).extraPopupElement){annotation_layer_classPrivateFieldGet(Jl,this)||this.renderCommentButton();annotation_layer_classPrivateFieldGet(Jl,this).style.backgroundColor=this.commentButtonColor||""}}function _get_html(e){const t=annotation_layer_classPrivateFieldGet(ad,e),i=annotation_layer_classPrivateFieldGet(zl,e);return!t?.str||i?.str&&i.str!==t.str?null:annotation_layer_classPrivateFieldGet(ad,e).html||null}function _get_fontSize(e){return annotation_layer_classPrivateGetter(dd,e,_get_html)?.attributes?.style?.fontSize||0}function _get_fontColor(e){return annotation_layer_classPrivateGetter(dd,e,_get_html)?.attributes?.style?.color||null}function _makePopupContent(e){const t=[],i={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},a={style:{color:annotation_layer_classPrivateGetter(dd,this,_get_fontColor),fontSize:annotation_layer_classPrivateGetter(dd,this,_get_fontSize)?`calc(${annotation_layer_classPrivateGetter(dd,this,_get_fontSize)}px * var(--total-scale-factor))`:""}};for(const i of e.split("\n"))t.push({name:"span",value:i,attributes:a});return i}function annotation_layer_keyDown(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||("Enter"===e.key||"Escape"===e.key&&annotation_layer_classPrivateFieldGet(ql,this))&&annotation_layer_assertClassBrand(dd,this,_toggle).call(this)}function _setPosition(){if(null!==annotation_layer_classPrivateFieldGet(Ql,this))return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:i,pageX:a,pageY:s}}}=annotation_layer_classPrivateFieldGet(Xl,this);let r=!!annotation_layer_classPrivateFieldGet(Kl,this),n=annotation_layer_classPrivateFieldGet(r?Kl:id,this);for(const e of annotation_layer_classPrivateFieldGet($l,this))if(!n||null!==Util.intersect(e.data.rect,n)){n=e.data.rect;r=!0;break}const o=Util.normalizeRect([n[0],e[3]-n[1]+e[1],n[2],e[3]-n[3]+e[1]]),l=r?n[2]-n[0]+5:0,d=o[0]+l,c=o[1];annotation_layer_classPrivateFieldSet(Ql,this,[100*(d-a)/t,100*(c-s)/i]);const{style:h}=annotation_layer_classPrivateFieldGet(Ul,this);h.left=`${annotation_layer_classPrivateFieldGet(Ql,this)[0]}%`;h.top=`${annotation_layer_classPrivateFieldGet(Ql,this)[1]}%`}function _toggle(){if(annotation_layer_classPrivateFieldGet(Rl,this))annotation_layer_classPrivateFieldGet(Rl,this).toggleCommentPopup(this,!1);else{annotation_layer_classPrivateFieldSet(ql,this,!annotation_layer_classPrivateFieldGet(ql,this));if(annotation_layer_classPrivateFieldGet(ql,this)){annotation_layer_assertClassBrand(dd,this,_show).call(this);annotation_layer_classPrivateFieldGet(Ul,this).addEventListener("click",annotation_layer_classPrivateFieldGet(jl,this));annotation_layer_classPrivateFieldGet(Ul,this).addEventListener("keydown",annotation_layer_classPrivateFieldGet(Ol,this))}else{annotation_layer_assertClassBrand(dd,this,_hide).call(this);annotation_layer_classPrivateFieldGet(Ul,this).removeEventListener("click",annotation_layer_classPrivateFieldGet(jl,this));annotation_layer_classPrivateFieldGet(Ul,this).removeEventListener("keydown",annotation_layer_classPrivateFieldGet(Ol,this))}}}function _show(){annotation_layer_classPrivateFieldGet(Yl,this)||this.render();if(this.isVisible)annotation_layer_classPrivateFieldGet(ql,this)&&annotation_layer_classPrivateFieldGet(Ul,this).classList.add("focused");else{annotation_layer_assertClassBrand(dd,this,_setPosition).call(this);annotation_layer_classPrivateFieldGet(Ul,this).hidden=!1;annotation_layer_classPrivateFieldGet(Ul,this).style.zIndex=parseInt(annotation_layer_classPrivateFieldGet(Ul,this).style.zIndex,10)+1e3;const e=annotation_layer_classPrivateFieldGet(Ul,this).closest(".page");e&&(e.style.overflow="visible")}}function _hide(){annotation_layer_classPrivateFieldGet(Ul,this).classList.remove("focused");if(annotation_layer_classPrivateFieldGet(ql,this)||!this.isVisible)return;annotation_layer_classPrivateFieldGet(Ul,this).hidden=!0;annotation_layer_classPrivateFieldGet(Ul,this).style.zIndex=parseInt(annotation_layer_classPrivateFieldGet(Ul,this).style.zIndex,10)-1e3;const e=annotation_layer_classPrivateFieldGet(Ul,this).closest(".page");e&&(e.style.overflow="")}class FreeTextAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.textContent=e.data.textContent;this.textPosition=e.data.textPosition;this.annotationEditorType=f.FREETEXT}render(){this.container.classList.add("freeTextAnnotation");if(this.textContent){const e=this.contentElement=document.createElement("div");e.classList.add("annotationTextContent");e.setAttribute("role","comment");for(const t of this.textContent){const i=document.createElement("span");i.textContent=t;e.append(i)}this.container.append(e)}if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this._editOnDoubleClick();return this.container}}var cd=new WeakMap;class LineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,cd,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:t,height:i}=this,a=AnnotationElement._svgFactory,s=a.create(t,i,!0),r=annotation_layer_classPrivateFieldSet(cd,this,a.createElement("svg:line"));r.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]);r.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]);r.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]);r.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]);r.setAttribute("stroke-width",e.borderStyle.width||1);r.setAttribute("stroke","transparent");r.setAttribute("fill","transparent");s.append(r);this.container.append(s);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(cd,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var hd=new WeakMap;class SquareAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,hd,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:t,height:i}=this,a=AnnotationElement._svgFactory,s=a.create(t,i,!0),r=e.borderStyle.width,n=annotation_layer_classPrivateFieldSet(hd,this,a.createElement("svg:rect"));n.setAttribute("x",r/2);n.setAttribute("y",r/2);n.setAttribute("width",t-r);n.setAttribute("height",i-r);n.setAttribute("stroke-width",r||1);n.setAttribute("stroke","transparent");n.setAttribute("fill","transparent");s.append(n);this.container.append(s);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(hd,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var _d=new WeakMap;class CircleAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,_d,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:t,height:i}=this,a=AnnotationElement._svgFactory,s=a.create(t,i,!0),r=e.borderStyle.width,n=annotation_layer_classPrivateFieldSet(_d,this,a.createElement("svg:ellipse"));n.setAttribute("cx",t/2);n.setAttribute("cy",i/2);n.setAttribute("rx",t/2-r/2);n.setAttribute("ry",i/2-r/2);n.setAttribute("stroke-width",r||1);n.setAttribute("stroke","transparent");n.setAttribute("fill","transparent");s.append(n);this.container.append(s);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(_d,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var ud=new WeakMap;class PolylineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,ud,null);this.containerClassName="polylineAnnotation";this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:t,borderStyle:i,popupRef:a},width:s,height:r}=this;if(!t)return this.container;const n=AnnotationElement._svgFactory,o=n.create(s,r,!0);let l=[];for(let i=0,a=t.length;i<a;i+=2){const a=t[i]-e[0],s=e[3]-t[i+1];l.push(`${a},${s}`)}l=l.join(" ");const d=annotation_layer_classPrivateFieldSet(ud,this,n.createElement(this.svgElementName));d.setAttribute("points",l);d.setAttribute("stroke-width",i.width||1);d.setAttribute("stroke","transparent");d.setAttribute("fill","transparent");o.append(d);this.container.append(o);if(!a&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(ud,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}class PolygonAnnotationElement extends PolylineAnnotationElement{constructor(e){super(e);this.containerClassName="polygonAnnotation";this.svgElementName="svg:polygon"}}class CaretAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("caretAnnotation");if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}}var pd=new WeakMap,gd=new WeakMap,md=new WeakSet;class InkAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateMethodInitSpec(this,md);annotation_layer_classPrivateFieldInitSpec(this,pd,null);annotation_layer_classPrivateFieldInitSpec(this,gd,[]);this.containerClassName="inkAnnotation";this.svgElementName="svg:polyline";this.annotationEditorType="InkHighlight"===this.data.it?f.HIGHLIGHT:f.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:t,inkLists:i,borderStyle:a,popupRef:s}}=this,{transform:r,width:n,height:o}=annotation_layer_assertClassBrand(md,this,_getTransform).call(this,t,e),l=AnnotationElement._svgFactory,d=l.create(n,o,!0),c=annotation_layer_classPrivateFieldSet(pd,this,l.createElement("svg:g"));d.append(c);c.setAttribute("stroke-width",a.width||1);c.setAttribute("stroke-linecap","round");c.setAttribute("stroke-linejoin","round");c.setAttribute("stroke-miterlimit",10);c.setAttribute("stroke","transparent");c.setAttribute("fill","transparent");c.setAttribute("transform",r);for(const e of i){const t=l.createElement(this.svgElementName);annotation_layer_classPrivateFieldGet(gd,this).push(t);t.setAttribute("points",e.join(","));c.append(t)}if(!s&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.append(d);this._editOnDoubleClick();return this.container}updateEdited(e){super.updateEdited(e);const{thickness:t,points:i,rect:a}=e,s=annotation_layer_classPrivateFieldGet(pd,this);t>=0&&s.setAttribute("stroke-width",t||1);if(i)for(let e=0,t=annotation_layer_classPrivateFieldGet(gd,this).length;e<t;e++)annotation_layer_classPrivateFieldGet(gd,this)[e].setAttribute("points",i[e].join(","));if(a){const{transform:e,width:t,height:i}=annotation_layer_assertClassBrand(md,this,_getTransform).call(this,this.data.rotation,a);s.parentElement.setAttribute("viewBox",`0 0 ${t} ${i}`);s.setAttribute("transform",e)}}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(gd,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function _getTransform(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}class HighlightAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=f.HIGHLIGHT}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("highlightAnnotation");this._editOnDoubleClick();if(e){const t=document.createElement("mark");t.classList.add("overlaidText");t.textContent=e;this.container.append(t)}return this.container}}class UnderlineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("underlineAnnotation");if(e){const t=document.createElement("u");t.classList.add("overlaidText");t.textContent=e;this.container.append(t)}return this.container}}class SquigglyAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("squigglyAnnotation");if(e){const t=document.createElement("u");t.classList.add("overlaidText");t.textContent=e;this.container.append(t)}return this.container}}class StrikeOutAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("strikeoutAnnotation");if(e){const t=document.createElement("s");t.classList.add("overlaidText");t.textContent=e;this.container.append(t)}return this.container}}class StampAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=f.STAMP}render(){this.container.classList.add("stampAnnotation");this.container.setAttribute("role","img");if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this._editOnDoubleClick();return this.container}}var fd=new WeakMap,vd=new WeakSet;class FileAttachmentAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0});annotation_layer_classPrivateMethodInitSpec(this,vd);annotation_layer_classPrivateFieldInitSpec(this,fd,null);const{fileId:t,file:i}=this.data;this.filename=i.filename;this.content=i.content;this.fileId=t;this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:t}=this;let i;if(t.hasAppearance||0===t.fillAlpha)i=document.createElement("div");else{i=document.createElement("img");i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`;t.fillAlpha&&t.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*t.fillAlpha)}%);`)}i.addEventListener("dblclick",annotation_layer_assertClassBrand(vd,this,_download).bind(this));annotation_layer_classPrivateFieldSet(fd,this,i);const{isMac:a}=FeatureTest.platform;e.addEventListener("keydown",e=>{"Enter"===e.key&&(a?e.metaKey:e.ctrlKey)&&annotation_layer_assertClassBrand(vd,this,_download).call(this)});if(!t.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}else i.classList.add("popupTriggerArea");e.append(i);return e}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(fd,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}async function _download(){const{fileId:e,filename:t,content:i}=this,a=await this.linkService.getAttachmentContent(e)||i;a&&this.downloadManager?.openOrDownloadData(a,t)}var Pd=new WeakMap,wd=new WeakMap,Fd=new WeakMap,yd=new WeakSet;class MediaAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!!e.data.richMedia});annotation_layer_classPrivateMethodInitSpec(this,yd);annotation_layer_classPrivateFieldInitSpec(this,Pd,new AbortController);annotation_layer_classPrivateFieldInitSpec(this,wd,null);annotation_layer_classPrivateFieldInitSpec(this,Fd,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:e}=this.data.richMedia,t=document.createElement("button");t.className="mediaPlayButton";t.type="button";t.title=t.ariaLabel=e;t.addEventListener("click",()=>annotation_layer_assertClassBrand(yd,this,_load).call(this,t),{signal:annotation_layer_classPrivateFieldGet(Pd,this).signal});this.container.append(t);return this.container}destroy(){annotation_layer_classPrivateFieldGet(Pd,this).abort();if(annotation_layer_classPrivateFieldGet(Fd,this)){annotation_layer_classPrivateFieldGet(Fd,this).pause();annotation_layer_classPrivateFieldGet(Fd,this).removeAttribute("src");annotation_layer_classPrivateFieldGet(Fd,this).load();annotation_layer_classPrivateFieldSet(Fd,this,null)}annotation_layer_assertClassBrand(yd,this,_revokeContentUrl).call(this)}}async function _load(e){const{fileId:t,filename:i,contentType:a}=this.data.richMedia;e.disabled=!0;let s;try{s=await this.linkService.getAttachmentContent(t)}catch{return}finally{e.disabled=!1}if(!s||!e.isConnected)return;const{signal:r}=annotation_layer_classPrivateFieldGet(Pd,this),n=new Blob([s],{type:a});if(!/^(?:video|audio)\//.test(n.type))return;const o=URL.createObjectURL(n);annotation_layer_classPrivateFieldSet(wd,this,o);const l=n.type.startsWith("audio/"),d=document.createElement(l?"audio":"video");annotation_layer_classPrivateFieldSet(Fd,this,d);d.className="mediaContent";this._setBackgroundColor(d);d.src=o;d.title=i;d.controls=!0;d.autoplay=!0;d.tabIndex=0;if(l){let e=!1,t=!1;const updateControls=()=>{d.controls=e||t};this.container.addEventListener("pointerenter",()=>{e=!0;updateControls()},{signal:r});this.container.addEventListener("pointerleave",()=>{e=!1;updateControls()},{signal:r});this.container.addEventListener("focusin",()=>{t=!0;updateControls()},{signal:r});this.container.addEventListener("focusout",()=>{t=!1;updateControls()},{signal:r})}d.addEventListener("emptied",()=>annotation_layer_assertClassBrand(yd,this,_revokeContentUrl).call(this,o),{once:!0,signal:r});e.replaceWith(d);d.play().catch(()=>{})}function _revokeContentUrl(e=annotation_layer_classPrivateFieldGet(wd,this)){if(e&&e===annotation_layer_classPrivateFieldGet(wd,this)){URL.revokeObjectURL(e);annotation_layer_classPrivateFieldSet(wd,this,null)}}var bd,Sd=new WeakMap,Cd=new WeakMap,xd=new WeakMap,kd=new WeakMap,Ed=new WeakMap,Ad=new WeakMap,Gd=new WeakMap,Bd=new WeakMap,Md=new WeakSet;class AnnotationLayer{constructor({div:e,accessibilityManager:t,annotationCanvasMap:i,annotationEditorUIManager:a,page:s,viewport:r,structTreeLayer:n,commentManager:o,linkService:l,annotationStorage:d}){annotation_layer_classPrivateMethodInitSpec(this,Md);annotation_layer_classPrivateFieldInitSpec(this,Sd,null);annotation_layer_classPrivateFieldInitSpec(this,Cd,null);annotation_layer_classPrivateFieldInitSpec(this,xd,null);annotation_layer_classPrivateFieldInitSpec(this,kd,new Map);annotation_layer_classPrivateFieldInitSpec(this,Ed,null);annotation_layer_classPrivateFieldInitSpec(this,Ad,null);annotation_layer_classPrivateFieldInitSpec(this,Gd,[]);annotation_layer_classPrivateFieldInitSpec(this,Bd,!1);annotation_layer_defineProperty(this,"zIndex",0);this.div=e;annotation_layer_classPrivateFieldSet(Sd,this,t);annotation_layer_classPrivateFieldSet(Cd,this,i);annotation_layer_classPrivateFieldSet(Ed,this,n||null);annotation_layer_classPrivateFieldSet(Ad,this,l||null);annotation_layer_classPrivateFieldSet(xd,this,d||new AnnotationStorage);this.page=s;this.viewport=r;this._annotationEditorUIManager=a;this._commentManager=o||null}hasEditableAnnotations(){return annotation_layer_classPrivateFieldGet(kd,this).size>0}async render(e){const{annotations:t,optionalContentConfig:i}=e,a=this.div;setLayerDimensions(a,this.viewport);const s=new Map,r=[],n={data:null,layer:a,linkService:annotation_layer_classPrivateFieldGet(Ad,this),downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,annotationStorage:annotation_layer_classPrivateFieldGet(xd,this),enableComment:!0===e.enableComment,enableAnnotationEditing:!1!==e.enableAnnotationEditing,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const e of t){if(e.noHTML)continue;const t=e.annotationType===k.POPUP;if(t){const t=s.get(e.id);if(!t)continue;if(!this._commentManager){r.push(e);continue}n.elements=t}else if(e.rect[2]===e.rect[0]||e.rect[3]===e.rect[1])continue;n.data=e;const a=AnnotationElementFactory.create(n);if(!a.isRenderable)continue;if(!t){annotation_layer_classPrivateFieldGet(Gd,this).push(a);e.popupRef&&s.getOrInsertComputed(e.popupRef,makeArr).push(a)}const o=a.render();e.hidden&&(o.style.visibility="hidden");a.updateOC(i);if(a._isEditable){annotation_layer_classPrivateFieldGet(kd,this).set(a.data.id,a);this._annotationEditorUIManager?.renderAnnotationElement(a)}}await annotation_layer_assertClassBrand(Md,this,_addElementsToDOM).call(this);for(const e of r){const t=n.elements=s.get(e.id);n.data=e;const i=AnnotationElementFactory.create(n);if(!i.isRenderable)continue;const a=i.render();i.contentElement.id=`${g}${e.id}`;e.hidden&&(a.style.visibility="hidden");t.at(-1).container.after(a)}annotation_layer_assertClassBrand(Md,this,_setAnnotationCanvasMap).call(this)}async addLinkAnnotations(e){const t={data:null,layer:this.div,linkService:annotation_layer_classPrivateFieldGet(Ad,this),parent:this};for(const i of e){i.borderStyle||=AnnotationLayer._defaultBorderStyle;t.data=i;const e=AnnotationElementFactory.create(t);if(e.isRenderable){e.render();e.contentElement.id=`${g}${i.id}`;annotation_layer_classPrivateFieldGet(Gd,this).push(e)}}await annotation_layer_assertClassBrand(Md,this,_addElementsToDOM).call(this)}update({viewport:e,optionalContentConfig:t}){const i=this.div;this.viewport=e;setLayerDimensions(i,{rotation:e.rotation});for(const e of annotation_layer_classPrivateFieldGet(Gd,this))e.updateOC(t);annotation_layer_assertClassBrand(Md,this,_setAnnotationCanvasMap).call(this);i.hidden=!1}destroy(){for(const e of annotation_layer_classPrivateFieldGet(Gd,this)){e.destroy?.();annotation_layer_classPrivateFieldGet(Sd,this)?.removePointerInTextLayer(e.contentElement)}annotation_layer_classPrivateFieldGet(Gd,this).length=0;annotation_layer_classPrivateFieldGet(kd,this).clear();this.div.replaceChildren()}refreshCanvases(){annotation_layer_assertClassBrand(Md,this,_setAnnotationCanvasMap).call(this)}getEditableAnnotations(){return annotation_layer_classPrivateFieldGet(kd,this).values()}getEditableAnnotation(e){return annotation_layer_classPrivateFieldGet(kd,this).get(e)}addFakeAnnotation(e){const{div:t}=this,{id:i,rotation:a}=e,s=new EditorAnnotationElement({data:{id:i,rect:e.getPDFRect(),rotation:a},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:annotation_layer_classPrivateFieldGet(Ad,this),annotationStorage:annotation_layer_classPrivateFieldGet(xd,this)});s.render();s.contentElement.id=`${g}${i}`;s.createOrUpdatePopup();annotation_layer_classPrivateFieldGet(Gd,this).push(s);return s}removeAnnotation(e){const t=annotation_layer_classPrivateFieldGet(Gd,this).findIndex(t=>t.data.id===e);if(t<0)return;const[i]=annotation_layer_classPrivateFieldGet(Gd,this).splice(t,1);annotation_layer_classPrivateFieldGet(Sd,this)?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(e){if(0!==e.length){for(const t of e)t.updateFakeAnnotationElement(this);annotation_layer_assertClassBrand(Md,this,_addElementsToDOM).call(this)}}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}static get _defaultBorderStyle(){return shadow(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:E,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}async function _addElementsToDOM(){if(0===annotation_layer_classPrivateFieldGet(Gd,this).length)return;this.div.replaceChildren();const e=[];if(!annotation_layer_classPrivateFieldGet(Bd,this)){annotation_layer_classPrivateFieldSet(Bd,this,!0);for(const{contentElement:t,data:{hidden:i,id:a,oc:s}}of annotation_layer_classPrivateFieldGet(Gd,this)){const r=t.id=`${g}${a}`,n="a"===t.localName&&!i&&!s;e.push(annotation_layer_classPrivateFieldGet(Ed,this)?.getAriaAttributes(r,{enableLinkOwnership:n}).then(e=>{if(e)for(const[i,a]of e)t.setAttribute(i,a)}))}}annotation_layer_classPrivateFieldGet(Gd,this).sort(({data:{rect:[e,t,i,a]}},{data:{rect:[s,r,n,o]}})=>{if(e===i&&t===a)return 1;if(s===n&&r===o)return-1;const l=(t+a)/2,d=(r+o)/2;if(l>=o&&d<=t)return-1;if(d>=a&&l<=r)return 1;return(e+i)/2-(s+n)/2});const t=document.createDocumentFragment();for(const e of annotation_layer_classPrivateFieldGet(Gd,this)){t.append(e.container);this._commentManager?(e.extraPopupElement?.popup||e.popup)?.renderCommentButton():e.extraPopupElement&&t.append(e.extraPopupElement.render())}this.div.append(t);await Promise.all(e);if(annotation_layer_classPrivateFieldGet(Sd,this)){const e=await(annotation_layer_classPrivateFieldGet(Ed,this)?.getAnnotationIds());for(const{contentElement:t}of annotation_layer_classPrivateFieldGet(Gd,this))e?.has(t.id)||annotation_layer_classPrivateFieldGet(Sd,this).addPointerInTextLayer(t,!1)}}function _setAnnotationCanvasMap(){if(!annotation_layer_classPrivateFieldGet(Cd,this))return;const e=this.div;for(const[t,i]of annotation_layer_classPrivateFieldGet(Cd,this)){const a=e.querySelector(`[data-annotation-id="${t}"]`);if(!a)continue;if(Array.isArray(i))for(const e of i){e.className="annotationContent";e.ariaHidden=!0}else{i.className="annotationContent";i.ariaHidden=!0}const s=[];for(const e of a.children)"CANVAS"===e.nodeName&&s.push(e);for(const e of s)e.remove();const r=Array.isArray(i)?i[0]:i,{firstChild:n}=a;n?n.classList.contains("annotationContent")?n.after(r):n.before(r):a.append(r);if(Array.isArray(i)){let e=r;for(let t=1,a=i.length;t<a;t++){e.after(i[t]);e=i[t]}}annotation_layer_classPrivateFieldGet(Cd,this).delete(t);const o=annotation_layer_classPrivateFieldGet(kd,this).get(t);if(o)if(o._hasNoCanvas){this._annotationEditorUIManager?.setMissingCanvas(t,a.id,i);o._hasNoCanvas=!1}else o.canvas=i}}function freetext_defineProperty(e,t,i){return(t=function freetext_toPropertyKey(e){var t=function freetext_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function freetext_classPrivateFieldInitSpec(e,t,i){freetext_checkPrivateRedeclaration(e,t),t.set(e,i)}function freetext_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function freetext_classPrivateFieldGet(e,t){return e.get(freetext_assertClassBrand(e,t))}function freetext_classPrivateFieldSet(e,t,i){return e.set(freetext_assertClassBrand(e,t),i),i}function freetext_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Id=/\r\n?|\n/g;var Td,Dd=new WeakMap,Ld=new WeakMap,Rd=new WeakMap,Od=new WeakMap,Nd=new WeakSet;class FreeTextEditor extends AnnotationEditor{static get _keyboardManager(){const e=FreeTextEditor.prototype,arrowChecker=e=>e.isEmpty(),t=AnnotationEditorUIManager.TRANSLATE_SMALL,i=AnnotationEditorUIManager.TRANSLATE_BIG;return shadow(this,"_keyboardManager",new KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],e.commitOrRemove],[["Escape"],e.commitOrRemove],[["ArrowLeft"],e._translateEmpty,{args:[-t,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:arrowChecker}],[["ArrowRight"],e._translateEmpty,{args:[t,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:arrowChecker}],[["ArrowUp"],e._translateEmpty,{args:[0,-t],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:arrowChecker}],[["ArrowDown"],e._translateEmpty,{args:[0,t],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:arrowChecker}]]))}constructor(e){super({...e,name:"freeTextEditor"});!function freetext_classPrivateMethodInitSpec(e,t){freetext_checkPrivateRedeclaration(e,t),t.add(e)}(this,Nd);freetext_classPrivateFieldInitSpec(this,Dd,"");freetext_classPrivateFieldInitSpec(this,Ld,`${this.id}-editor`);freetext_classPrivateFieldInitSpec(this,Rd,null);freetext_classPrivateFieldInitSpec(this,Od,void 0);freetext_defineProperty(this,"_colorPicker",null);this.color=e.color||FreeTextEditor._defaultColor||AnnotationEditor._defaultLineColor;freetext_classPrivateFieldSet(Od,this,e.fontSize||FreeTextEditor._defaultFontSize);this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.freetext);this.canAddComment=!1}static initialize(e,t){AnnotationEditor.initialize(e,t);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case v.FREETEXT_SIZE:FreeTextEditor._defaultFontSize=t;break;case v.FREETEXT_COLOR:FreeTextEditor._defaultColor=t}}updateParams(e,t){switch(e){case v.FREETEXT_SIZE:freetext_assertClassBrand(Nd,this,_updateFontSize).call(this,t);break;case v.FREETEXT_COLOR:freetext_assertClassBrand(Nd,this,freetext_updateColor).call(this,t)}}static get defaultPropertiesToUpdate(){return[[v.FREETEXT_SIZE,FreeTextEditor._defaultFontSize],[v.FREETEXT_COLOR,FreeTextEditor._defaultColor||AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[v.FREETEXT_SIZE,freetext_classPrivateFieldGet(Od,this)],[v.FREETEXT_COLOR,this.color]]}get toolbarButtons(){this._colorPicker||=new BasicColorPicker(this);return[["colorPicker",this._colorPicker]]}get colorType(){return v.FREETEXT_COLOR}onUpdatedColor(){this.editorDiv.style.color=this.color;this._colorPicker?.update(this.color);super.onUpdatedColor()}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){const e=this.parentScale;return[-FreeTextEditor._internalPadding*e,-(FreeTextEditor._internalPadding+freetext_classPrivateFieldGet(Od,this))*e]}rebuild(){if(this.parent){super.rebuild();null!==this.div&&(this.isAttachedToDOM||this.parent.add(this))}}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled");this.editorDiv.contentEditable=!0;this._isDraggable=!1;this.div.removeAttribute("aria-activedescendant");freetext_classPrivateFieldSet(Rd,this,new AbortController);const e=this._uiManager.combinedSignal(freetext_classPrivateFieldGet(Rd,this));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e});this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e});this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e});this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e});this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e});return!0}disableEditMode(){if(!super.disableEditMode())return!1;this.overlayDiv.classList.add("enabled");this.editorDiv.contentEditable=!1;this.div.setAttribute("aria-activedescendant",freetext_classPrivateFieldGet(Ld,this));this._isDraggable=!0;freetext_classPrivateFieldGet(Rd,this)?.abort();freetext_classPrivateFieldSet(Rd,this,null);this.div.focus({preventScroll:!0});this.isEditing=!1;this.parent.div.classList.add("freetextEditing");return!0}focusin(e){if(this._focusEventsAllowed){super.focusin(e);e.target!==this.editorDiv&&this.editorDiv.focus()}}onceAdded(e){if(!this.width){this.enableEditMode();e&&this.editorDiv.focus();this._initialOptions?.isCentered&&this.center();this._initialOptions=null}}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1;if(this.parent){this.parent.setEditingState(!0);this.parent.div.classList.add("freetextEditing")}super.remove()}commit(){if(!this.isInEditMode())return;super.commit();this.disableEditMode();const e=freetext_classPrivateFieldGet(Dd,this),t=freetext_classPrivateFieldSet(Dd,this,freetext_assertClassBrand(Nd,this,_extractText).call(this).trimEnd());if(e===t)return;const setText=e=>{freetext_classPrivateFieldSet(Dd,this,e);if(e){freetext_assertClassBrand(Nd,this,_setContent).call(this);this._uiManager.rebuild(this);freetext_assertClassBrand(Nd,this,_setEditorDimensions).call(this)}else this.remove()};this.addCommands({cmd:()=>{setText(t)},undo:()=>{setText(e)},mustExec:!1});freetext_assertClassBrand(Nd,this,_setEditorDimensions).call(this);this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"textChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:t,previousValue:e})}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode();this.editorDiv.focus()}keydown(e){if(e.target===this.div&&"Enter"===e.key){this.enterInEditMode();e.preventDefault()}}editorDivKeydown(e){FreeTextEditor._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment");this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox");this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy||this.annotationElementId){e=this.x;t=this.y}super.render();this.editorDiv=document.createElement("div");this.editorDiv.className="internal";this.editorDiv.setAttribute("id",freetext_classPrivateFieldGet(Ld,this));this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2");this.editorDiv.setAttribute("data-l10n-attrs","default-content");this.enableEditing();this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;i.fontSize=`calc(${freetext_classPrivateFieldGet(Od,this)}px * var(--total-scale-factor))`;i.color=this.color;this.div.append(this.editorDiv);this.overlayDiv=document.createElement("div");this.overlayDiv.classList.add("overlay","enabled");this.div.append(this.overlayDiv);if(this._isCopy||this.annotationElementId){const[i,a]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this._initialData;let[r,n]=this.getInitialTranslation();[r,n]=this.pageTranslationToScreen(r,n);const[o,l]=this.pageDimensions,[d,c]=this.pageTranslation;let h,_;switch(this.rotation){case 0:h=e+(s[0]-d)/o;_=t+this.height-(s[1]-c)/l;break;case 90:h=e+(s[0]-d)/o;_=t-(s[1]-c)/l;[r,n]=[n,-r];break;case 180:h=e-this.width+(s[0]-d)/o;_=t-(s[1]-c)/l;[r,n]=[-r,-n];break;case 270:h=e+(s[0]-d-this.height*l)/o;_=t+(s[1]-c-this.width*o)/l;[r,n]=[-n,r]}this.setAt(h*i,_*a,r,n)}else this._moveAfterPaste(e,t);freetext_assertClassBrand(Nd,this,_setContent).call(this);this._isDraggable=!0;this.editorDiv.contentEditable=!1}else{this._isDraggable=!1;this.editorDiv.contentEditable=!0}return this.div}editorDivPaste(e){const t=e.clipboardData||window.clipboardData,{types:i}=t;if(1===i.length&&"text/plain"===i[0])return;e.preventDefault();const a=_deserializeContent.call(FreeTextEditor,t.getData("text")||"").replaceAll(Id,"\n");if(!a)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize();s.deleteFromDocument();const r=s.getRangeAt(0);if(!a.includes("\n")){r.insertNode(document.createTextNode(a));this.editorDiv.normalize();s.collapseToStart();return}const{startContainer:n,startOffset:o}=r,l=[],d=[];if(n.nodeType===Node.TEXT_NODE){const e=n.parentElement;d.push(n.nodeValue.slice(o).replaceAll(Id,""));if(e!==this.editorDiv){let t=l;for(const i of this.editorDiv.childNodes)i!==e?t.push(_getNodeContent.call(FreeTextEditor,i)):t=d}l.push(n.nodeValue.slice(0,o).replaceAll(Id,""))}else if(n===this.editorDiv){let e=l,t=0;for(const i of this.editorDiv.childNodes){t++===o&&(e=d);e.push(_getNodeContent.call(FreeTextEditor,i))}}freetext_classPrivateFieldSet(Dd,this,`${l.join("\n")}${a}${d.join("\n")}`);freetext_assertClassBrand(Nd,this,_setContent).call(this);const c=new Range;let h=Math.sumPrecise(l.map(e=>e.length));for(const{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue.length;if(h<=t){c.setStart(e,h);c.setEnd(e,h);break}h-=t}s.removeAllRanges();s.addRange(c)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=FreeTextEditor._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,t,i){let a=null;if(e instanceof FreeTextAnnotationElement){const{data:{defaultAppearanceData:{fontSize:t,fontColor:i},rect:s,rotation:r,id:n,popupRef:o,richText:l,contentsObj:d,creationDate:c,modificationDate:h},textContent:_,textPosition:u,parent:{page:{pageNumber:p}}}=e;if(!_?.length)return null;a=e={annotationType:f.FREETEXT,color:Array.from(i),fontSize:t,value:_.join("\n"),position:u,pageIndex:p-1,rect:s.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:o,comment:d?.str||null,richText:l,creationDate:c,modificationDate:h}}else{const{popup:t,popupRef:i}=e;a=e={...e,popupRef:i||!(!t||!t.contents||t.deleted)||null,comment:!t?.deleted&&t?.contents||null,commentDate:!t?.deleted&&t?.date||null}}const s=await super.deserialize(e,t,i);freetext_classPrivateFieldSet(Od,s,e.fontSize);s.color=Util.makeHexColor(...e.color);freetext_classPrivateFieldSet(Dd,s,_deserializeContent.call(FreeTextEditor,e.value));s._initialData=a;e.comment&&s.setCommentData(e);return s}serialize(e=!1,t=null,i=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a=AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(e,t),{color:a,fontSize:freetext_classPrivateFieldGet(Od,this),value:freetext_assertClassBrand(Nd,this,_serializeContent).call(this)});this.addComment(s,this._isCopy);if(e){i&&(s.id=this.uid);s.isCopy=!0;return s}if(this.annotationElementId&&!freetext_assertClassBrand(Nd,this,_hasElementChanged).call(this,s))return null;s.id=this.uid;return s}renderAnnotationElement(e){const t=super.renderAnnotationElement(e);if(!t)return null;const{style:i}=t;i.fontSize=`calc(${freetext_classPrivateFieldGet(Od,this)}px * var(--total-scale-factor))`;i.color=this.color;t.replaceChildren();for(const e of freetext_classPrivateFieldGet(Dd,this).split("\n")){const i=document.createElement("div");i.append(e?document.createTextNode(e):document.createElement("br"));t.append(i)}e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:freetext_classPrivateFieldGet(Dd,this)}});return t}resetAnnotationElement(e){super.resetAnnotationElement(e);e.resetEdited()}}bd=FreeTextEditor;function _updateFontSize(e){const setFontsize=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--total-scale-factor))`;this.translate(0,-(e-freetext_classPrivateFieldGet(Od,this))*this.parentScale);freetext_classPrivateFieldSet(Od,this,e);freetext_assertClassBrand(Nd,this,_setEditorDimensions).call(this)},t=freetext_classPrivateFieldGet(Od,this);this.addCommands({cmd:setFontsize.bind(this,e),undo:setFontsize.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"fontSizeChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:e,previousValue:freetext_classPrivateFieldGet(Od,this)})}function freetext_updateColor(e){const setColor=e=>{this.color=e;this.onUpdatedColor()},t=this.color;this.addCommands({cmd:setColor.bind(this,e),undo:setColor.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"colorChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:e,previousValue:t})}function _extractText(){const e=[];this.editorDiv.normalize();let t=null;for(const i of this.editorDiv.childNodes)if(t?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName){e.push(_getNodeContent.call(bd,i));t=i}return e.join("\n")}function _setEditorDimensions(){const[e,t]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:e,div:t}=this,a=t.style.display,s=t.classList.contains("hidden");t.classList.remove("hidden");t.style.display="hidden";e.div.append(this.div);i=t.getBoundingClientRect();t.remove();t.style.display=a;t.classList.toggle("hidden",s)}if(this.rotation%180==this.parentRotation%180){this.width=i.width/e;this.height=i.height/t}else{this.width=i.height/e;this.height=i.width/t}this.fixAndSetPosition()}function _getNodeContent(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Id,"")}function _setContent(){this.editorDiv.replaceChildren();if(freetext_classPrivateFieldGet(Dd,this))for(const e of freetext_classPrivateFieldGet(Dd,this).split("\n")){const t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br"));this.editorDiv.append(t)}}function _serializeContent(){return freetext_classPrivateFieldGet(Dd,this).replaceAll(" "," ")}function _deserializeContent(e){return e.replaceAll(" "," ")}function _hasElementChanged(e){const{value:t,fontSize:i,color:a,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==t||e.fontSize!==i||e.color.some((e,t)=>e!==a[t])||e.pageIndex!==s}freetext_defineProperty(FreeTextEditor,"_freeTextDefaultContent","");freetext_defineProperty(FreeTextEditor,"_internalPadding",0);freetext_defineProperty(FreeTextEditor,"_defaultColor",null);freetext_defineProperty(FreeTextEditor,"_defaultFontSize",10);freetext_defineProperty(FreeTextEditor,"_type","freetext");freetext_defineProperty(FreeTextEditor,"_editorType",f.FREETEXT);function draw_defineProperty(e,t,i){return(t=function draw_toPropertyKey(e){var t=function draw_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function draw_classPrivateGetter(e,t,i){return i(draw_assertClassBrand(e,t))}function draw_classPrivateFieldInitSpec(e,t,i){draw_checkPrivateRedeclaration(e,t),t.set(e,i)}function draw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function draw_classPrivateFieldSet(e,t,i){return e.set(draw_assertClassBrand(e,t),i),i}function draw_classPrivateFieldGet(e,t){return e.get(draw_assertClassBrand(e,t))}function draw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Wd=new WeakMap;class DrawingOptions{constructor(){draw_classPrivateFieldInitSpec(this,Wd,Object.create(null))}updateProperty(e,t){this[e]=t;this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,i]of Object.entries(e))t.startsWith("_")||this.updateProperty(t,i)}updateSVGProperty(e,t){draw_classPrivateFieldGet(Wd,this)[e]=t}toSVGProperties(){const e=draw_classPrivateFieldGet(Wd,this);draw_classPrivateFieldSet(Wd,this,Object.create(null));return{root:e}}reset(){draw_classPrivateFieldSet(Wd,this,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){unreachable("Not implemented")}}var jd=new WeakMap,Vd=new WeakMap,Ud=new WeakSet;class DrawingEditor extends AnnotationEditor{constructor(e){super(e);!function draw_classPrivateMethodInitSpec(e,t){draw_checkPrivateRedeclaration(e,t),t.add(e)}(this,Ud);draw_classPrivateFieldInitSpec(this,jd,null);draw_classPrivateFieldInitSpec(this,Vd,void 0);draw_defineProperty(this,"_clipPathId",null);draw_defineProperty(this,"_colorPicker",null);draw_defineProperty(this,"_drawId",null);draw_defineProperty(this,"_drawOutlines",null);draw_defineProperty(this,"_focusDrawId",null);draw_classPrivateFieldSet(Vd,this,e.mustBeCommitted||!1);this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color);super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(e){if(e.drawOutlines){draw_assertClassBrand(Ud,this,_createDrawOutlines).call(this,e);draw_assertClassBrand(Ud,this,_addToDrawLayer).call(this)}}static _mergeSVGProperties(e,t){const i=new Set(Object.keys(e));for(const[a,s]of Object.entries(t))i.has(a)?Object.assign(e[a],s):e[a]=s;return e}static getDefaultDrawingOptions(e){unreachable("Not implemented")}static get typesMap(){unreachable("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}static updateDefaultParams(e,t){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,t);if(this._currentParent){zd._.updateProperty(i,t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}updateParams(e,t){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,t)}static get defaultPropertiesToUpdate(){const e=[],t=this._defaultDrawingOptions;for(const[i,a]of this.typesMap)e.push([i,t[a]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:t}=this;for(const[i,a]of this.constructor.typesMap)e.push([i,t[a]]);return e}_updateProperty(e,t,i){const a=this._drawingOptions,s=a[t],setter=s=>{a.updateProperty(t,s);const r=this._drawOutlines.updateProperty(t,s);r&&draw_assertClassBrand(Ud,this,_updateBbox).call(this,r);this.parent?.drawLayer.updateProperties(this._drawId,a.toSVGProperties());this._dispatchDrawPropertyEvent(t,i);e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:setter.bind(this,i),undo:setter.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t,i=this.colorAndOpacityType){const a=this.constructor.typesMap.get(this.colorType),s=this._opacityName,r=this._drawingOptions,n=r[a],o=r[s],setter=(e,t)=>{r.updateProperty(a,e);r.updateProperty(s,t);this._drawOutlines.updateProperty(a,e);this._drawOutlines.updateProperty(s,t);this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties());this.onUpdatedColor();this.onUpdatedOpacity()};this.addCommands({cmd:setter.bind(this,e,t),undo:setter.bind(this,n,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(draw_assertClassBrand(Ud,this,_convertToDrawSpace).call(this)),{bbox:draw_assertClassBrand(Ud,this,_rotateBox).call(this)}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(draw_assertClassBrand(Ud,this,_convertToDrawSpace).call(this)),{bbox:draw_assertClassBrand(Ud,this,_rotateBox).call(this)}));draw_assertClassBrand(Ud,this,_updateFocusOutline).call(this)}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:draw_assertClassBrand(Ud,this,_rotateBox).call(this)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(draw_assertClassBrand(Ud,this,_convertToDrawSpace).call(this),this.parentDimensions),{bbox:draw_assertClassBrand(Ud,this,_rotateBox).call(this)}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}get _mustBeDisabledOnCommit(){return!0}commit(){super.commit();if(this._mustBeDisabledOnCommit){this.disableEditMode();this.disableEditing()}}disableEditing(){super.disableEditing();this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing();this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||null===this._drawId||this._uiManager.isRestoringAnnotations||this.parent.addUndoableEditor(this);this._isDraggable=!0;if(draw_classPrivateFieldGet(Vd,this)){draw_classPrivateFieldSet(Vd,this,!1);this.commit();this.parent.setSelected(this);e&&this.isOnScreen&&this.div.focus()}}remove(){this._uiManager.removeShouldRescale(this);draw_assertClassBrand(Ud,this,_cleanDrawLayer).call(this);super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){draw_assertClassBrand(Ud,this,_addToDrawLayer).call(this);draw_assertClassBrand(Ud,this,_updateBbox).call(this,this._drawOutlines.box);this.rotate();this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e){this._uiManager.removeShouldRescale(this);draw_assertClassBrand(Ud,this,_cleanDrawLayer).call(this)}else if(e){this._uiManager.addShouldRescale(this);draw_assertClassBrand(Ud,this,_addToDrawLayer).call(this,e);t=!this.parent&&this.div?.classList.contains("selectedEditor")}super.setParent(e);draw_assertClassBrand(Ud,this,_updateVisibility).call(this);t&&this.select()}rotate(e=this.parentRotation){if(!this.parent||null===this._drawId)return;const t=(e-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties({bbox:draw_assertClassBrand(Ud,this,_rotateBox).call(this,e)},this._drawOutlines.updateRotation(t)));draw_assertClassBrand(Ud,this,_updateFocusOutline).call(this,t)}show(e=this._isVisible){super.show(e);draw_assertClassBrand(Ud,this,_updateVisibility).call(this)}select(){super.select();draw_assertClassBrand(Ud,this,_toggleFocusOutlineClass).call(this,{hovered:!1,selected:!0})}unselect(){super.unselect();draw_assertClassBrand(Ud,this,_toggleFocusOutlineClass).call(this,{selected:!1})}pointerover(){this.isSelected||draw_assertClassBrand(Ud,this,_toggleFocusOutlineClass).call(this,{hovered:!0})}pointerleave(){this.isSelected||draw_assertClassBrand(Ud,this,_toggleFocusOutlineClass).call(this,{hovered:!1})}onScaleChanging(){if(!this.parent)return;const e=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);e&&draw_assertClassBrand(Ud,this,_updateBbox).call(this,e)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}const i=super.render();this.constructor._hasDrawClass&&i.classList.add("draw");const a=draw_classPrivateFieldSet(jd,this,document.createElement("div"));i.append(a);a.setAttribute("aria-hidden","true");a.className="internal";this._clipPathId&&(a.style.clipPath=this._clipPathId);bindEvents(this,a,["pointerover","pointerleave"]);this.setDims();this._uiManager.addShouldRescale(this);this.disableEditing();this._isCopy&&this._moveAfterPaste(e,t);return i}static createDrawerInstance(e){unreachable("Not implemented")}static _getDrawingTarget(e,{target:t}){return t}static _getPointerCoords({offsetX:e,offsetY:t,clientX:i,clientY:a},s=null){if(!s)return[e,t];let r=i-s.clientX,n=a-s.clientY;switch(this._currentParent.viewport.rotation){case 90:[r,n]=[n,-r];break;case 180:[r,n]=[-r,-n];break;case 270:[r,n]=[-n,r]}return[s.offsetX+r,s.offsetY+n]}static _addDrawingListeners(e,t){}static _endDrawingSession(e=!1){return this._currentParent.endDrawingSession(e)}static startDrawing(e,t,i,a){const{pointerId:s,pointerType:r}=a,n=t.currentPointers;if(n.isInitializedAndDifferentPointerType(r))return;Kd._=n;const o=this._getDrawingTarget(e,a),[l,d]=this._getPointerCoords(a),{viewport:{rotation:c}}=e,{x:h,y:_,width:u,height:p}=o.getBoundingClientRect();Hd._?.abort();const g=Hd._=new AbortController,m=e.combinedSignal(g);n.setPointer(r,s);window.addEventListener("pointerup",e=>{n.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:m});window.addEventListener("pointercancel",e=>{n.isSamePointerIdOrRemove(e.pointerId)&&this._endDrawingSession()},{signal:m});window.addEventListener("pointerdown",e=>{if(n.isSamePointerType(e.pointerType)){n.initializeAndAddPointerId(e.pointerId);if(zd._&&zd._.isCancellable()){zd._.removeLastElement();zd._.isEmpty()?this._endDrawingSession(!0):this._endDraw(null)}}},{capture:!0,passive:!1,signal:m});window.addEventListener("contextmenu",noContextMenu,{signal:m});o.addEventListener("pointermove",this._drawMove.bind(this),{signal:m});o.addEventListener("touchmove",e=>{n.isSameTimeStamp(e.timeStamp)&&stopEvent(e)},{signal:m});this._addDrawingListeners(o,m);e.toggleDrawing();this._dispatchDrawingEvent("drawingStarted");t._editorUndoBar?.hide();if(zd._){e.drawLayer.updateProperties(this._currentDrawId,zd._.startNew(l,d,u,p,c,a.timeStamp));return}t.updateUIForDefaultProperties(this);zd._=this.createDrawerInstance({x:l,y:d,box:[h,_,u,p],rotation:c,parent:e,isLTR:i,timeStamp:a.timeStamp});$d._=this.getDefaultDrawingOptions();this._currentParent=e;const{id:f,clipPathId:v}=e.drawLayer.draw(this._mergeSVGProperties($d._.toSVGProperties(),zd._.defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=f;Xd._=this._hasClipPath?v:null}static _drawMove(e){const t=Kd._;if(!zd._||!t)return;if(!t.isSamePointerId(e.pointerId))return;if(t.isUsingMultiplePointers()){this._endDraw(e);return}let i;const a=e.getCoalescedEvents?.();if(a?.length){const t=[],s=[];for(const i of a){t.push(...this._getPointerCoords(i,e));s.push(i.timeStamp)}i=zd._.addPoints(t,s)}else i=zd._.add(...this._getPointerCoords(e),e.timeStamp);this._currentParent.drawLayer.updateProperties(this._currentDrawId,i);t.setTimeStamp(e.timeStamp);stopEvent(e)}static _cleanup(e){if(e){this._currentDrawId=-1;this._currentParent=null;zd._=null;$d._=null;Xd._=null;Kd._?.clearTimeStamp()}if(Hd._){Hd._.abort();Hd._=null;Kd._?.clearPointerIds()}e&&(Kd._=null)}static _endDraw(e){const t=this._currentParent;if(t){t.toggleDrawing(!0);this._dispatchDrawingEvent("drawingStopped");this._cleanup(!1);t.drawLayer.updateProperties(this._currentDrawId,e?.target===t.div?zd._.end(...this._getPointerCoords(e),e.timeStamp):zd._.end());this._dispatchBezierPathChangedEvent();if(this.supportMultipleDrawings){const e=zd._,i=this._currentDrawId,a=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(i,e.setLastElement(a))},undo:()=>{t.drawLayer.updateProperties(i,e.removeLastElement())},mustExec:!1,type:v.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const t=this._currentParent;if(!t)return null;t.toggleDrawing(!0);t.cleanUndoStack(v.DRAW_STEP);if(!zd._.isEmpty()){const{pageDimensions:[i,a],scale:s}=t,r=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:Xd._,drawOutlines:zd._.getOutlines(i*s,a*s,s,this._INNER_MARGIN),drawingOptions:$d._,mustBeCommitted:!e});this._cleanup(!0);return r}t.drawLayer.remove(this._currentDrawId);this._cleanup(!0);return null}createDrawingOptions(e){}static deserializeDraw(e,t,i,a,s,r,n){unreachable("Not implemented")}static async deserialize(e,t,i){const{rawDims:{pageWidth:a,pageHeight:s,pageX:r,pageY:n}}=t.viewport,o=this.deserializeDraw(r,n,a,s,this._INNER_MARGIN,e,i),l=await super.deserialize(e,t,i);l.createDrawingOptions(e);draw_assertClassBrand(Ud,l,_createDrawOutlines).call(l,{drawOutlines:o});draw_assertClassBrand(Ud,l,_addToDrawLayer).call(l);l.onScaleChanging();l.rotate();return l}serializeDraw(e){const[t,i]=this.pageTranslation,[a,s]=this.pageDimensions;return this._drawOutlines.serialize([t,i,a,s],e)}renderAnnotationElement(e){e.updateEdited({rect:this.getPDFRect()});return null}static canCreateNewEmptyEditor(){return!1}_dispatchDrawPropertyEvent(e,t){const i={stroke:"colorChanged","stroke-width":"thicknessChanged","stroke-opacity":"opacityChanged"}[e];i&&this._dispatchEditorEvent(i,{value:t})}static _dispatchDrawingEvent(e){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:e,editorType:this.name})}static _dispatchBezierPathChangedEvent(){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"bezierPathChanged",page:this._currentParent?this._currentParent.pageIndex+1:NaN,editorType:this.name})}}Td=DrawingEditor;function _createDrawOutlines({drawOutlines:e,drawId:t,drawingOptions:i,clipPathId:a}){this._drawOutlines=e;this._drawingOptions||=i;this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert[this.editorType]);if(t>=0){this._drawId=t;this._clipPathId=a??null;this.parent.drawLayer.finalizeDraw(t,e.defaultProperties);draw_assertClassBrand(Ud,this,_createFocusOutline).call(this,this.parent)}else this._drawId=draw_assertClassBrand(Ud,this,_createDrawing).call(this,e,this.parent);draw_assertClassBrand(Ud,this,_updateBbox).call(this,e.box)}function _createDrawing(e,t){const{id:i,clipPathId:a}=t.drawLayer.draw(Td._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,this.constructor._hasClipPath);this.constructor._hasClipPath&&(this._clipPathId=a);draw_assertClassBrand(Ud,this,_createFocusOutline).call(this,t);return i}function _createFocusOutline(e){const t=this._drawOutlines.getFocusSVGProperties(draw_classPrivateGetter(Ud,this,_get_rotationAngle));t&&(this._focusDrawId=e.drawLayer.drawOutline(t,this._drawOutlines.focusMustRemoveSelfIntersections))}function _updateFocusOutline(e=draw_classPrivateGetter(Ud,this,_get_rotationAngle)){null!==this._focusDrawId&&this.parent?.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(e))}function _toggleFocusOutlineClass(e){null!==this._focusDrawId&&this.parent?.drawLayer.updateProperties(this._focusDrawId,{rootClass:e})}function _updateVisibility(){const{parent:e,_drawId:t,_focusDrawId:i,_isVisible:a}=this;if(!e||null===t)return;const s={hidden:!a};e.drawLayer.updateProperties(t,{rootClass:s});null!==i&&e.drawLayer.updateProperties(i,{rootClass:s})}function _get_rotationAngle(e){return(e.parentRotation-e._drawRotation+360)%360}function _cleanDrawLayer(){if(null===this._drawId||!this.parent)return;const{drawLayer:e}=this.parent;e.remove(this._drawId);this._drawId=null;if(null!==this._focusDrawId){e.remove(this._focusDrawId);this._focusDrawId=null}this._drawingOptions.reset()}function _addToDrawLayer(e=this.parent){if(null===this._drawId||this.parent!==e){if(null!==this._drawId){const{drawLayer:t}=this.parent;t.updateParent(this._drawId,e.drawLayer);null!==this._focusDrawId&&t.updateParent(this._focusDrawId,e.drawLayer);return}this._drawingOptions.updateAll();this._drawId=draw_assertClassBrand(Ud,this,_createDrawing).call(this,this._drawOutlines,e);this._clipPathId&&draw_classPrivateFieldGet(jd,this)&&(draw_classPrivateFieldGet(jd,this).style.clipPath=this._clipPathId)}}function _convertToParentSpace([e,t,i,a]){const{parentDimensions:[s,r],_drawRotation:n}=this;switch(n){case 90:return[t,1-e,i*(r/s),a*(s/r)];case 180:return[1-e,1-t,i,a];case 270:return[1-t,e,i*(r/s),a*(s/r)];default:return[e,t,i,a]}}function _convertToDrawSpace(){const{x:e,y:t,width:i,height:a,parentDimensions:[s,r],_drawRotation:n}=this;switch(n){case 90:return[1-t,e,i*(s/r),a*(r/s)];case 180:return[1-e,1-t,i,a];case 270:return[t,1-e,i*(s/r),a*(r/s)];default:return[e,t,i,a]}}function _updateBbox(e){[this.x,this.y,this.width,this.height]=draw_assertClassBrand(Ud,this,_convertToParentSpace).call(this,e);if(this.div){this.fixAndSetPosition();this.setDims()}this._onResized()}function _rotateBox(e=this.parentRotation){const{x:t,y:i,width:a,height:s,_drawRotation:r,parentDimensions:[n,o]}=this;switch((4*r+e)/90){case 1:return[1-i-s,t,s,a];case 2:return[1-t-a,1-i-s,a,s];case 3:return[i,1-t-a,s,a];case 4:return[t,i-a*(n/o),s*(o/n),a*(n/o)];case 5:return[1-i,t,a*(n/o),s*(o/n)];case 6:return[1-t-s*(o/n),1-i,s*(o/n),a*(n/o)];case 7:return[i-a*(n/o),1-t-s*(o/n),a*(n/o),s*(o/n)];case 8:return[t-a,i-s,a,s];case 9:return[1-i,t-a,s,a];case 10:return[1-t,1-i,a,s];case 11:return[i-s,1-t,s,a];case 12:return[t-s*(o/n),i,s*(o/n),a*(n/o)];case 13:return[1-i-a*(n/o),t-s*(o/n),a*(n/o),s*(o/n)];case 14:return[1-t,1-i-a*(n/o),s*(o/n),a*(n/o)];case 15:return[i,1-t,a*(n/o),s*(o/n)];default:return[t,i,a,s]}}draw_defineProperty(DrawingEditor,"_currentDrawId",-1);draw_defineProperty(DrawingEditor,"_currentParent",null);var zd={_:null},Hd={_:null},$d={_:null},Xd={_:null},Kd={_:null};draw_defineProperty(DrawingEditor,"_INNER_MARGIN",3);function outline_defineProperty(e,t,i){return(t=function outline_toPropertyKey(e){var t=function outline_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Outline{constructor(){outline_defineProperty(this,"focusOutline",null)}toSVGPath(){unreachable("Abstract method `toSVGPath` must be implemented.")}get box(){unreachable("Abstract getter `box` must be implemented.")}serialize(e,t){unreachable("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){unreachable("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(e){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(e,t){return null}updateParentDimensions(e,t){return null}serializeQuadPoints(e,t){return null}updateRotation(e){return{}}getPathResizingSVGProperties(e){return{}}getPathResizedSVGProperties(e){return{}}getPathTranslatedSVGProperties(e,t){return{}}static _rotateBox([e,t,i,a],s){switch(s){case 90:return[1-t-a,e,a,i];case 180:return[1-e-i,1-t-a,i,a];case 270:return[t,1-e-i,a,i]}return[e,t,i,a]}static _rescale(e,t,i,a,s,r){r||=new Float32Array(e.length);for(let n=0,o=e.length;n<o;n+=2){r[n]=t+e[n]*a;r[n+1]=i+e[n+1]*s}return r}static _rescaleAndSwap(e,t,i,a,s,r){r||=new Float32Array(e.length);for(let n=0,o=e.length;n<o;n+=2){r[n]=t+e[n+1]*a;r[n+1]=i+e[n]*s}return r}static _translate(e,t,i,a){a||=new Float32Array(e.length);for(let s=0,r=e.length;s<r;s+=2){a[s]=t+e[s];a[s+1]=i+e[s+1]}return a}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,i,a,s,r=[]){switch(s){case 90:r[0]=1-t/i;r[1]=e/a;break;case 180:r[0]=1-e/i;r[1]=1-t/a;break;case 270:r[0]=t/i;r[1]=1-e/a;break;default:r[0]=e/i;r[1]=t/a}return r}static createBezierPoints(e,t,i,a,s,r,n=[]){n.push((e+5*i)/6,(t+5*a)/6,(5*i+s)/6,(5*a+r)/6,(i+s)/2,(a+r)/2);return n}}outline_defineProperty(Outline,"PRECISION",1e-4);function freedraw_classPrivateMethodInitSpec(e,t){freedraw_checkPrivateRedeclaration(e,t),t.add(e)}function freedraw_classPrivateFieldInitSpec(e,t,i){freedraw_checkPrivateRedeclaration(e,t),t.set(e,i)}function freedraw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function freedraw_classPrivateFieldGet(e,t){return e.get(freedraw_assertClassBrand(e,t))}function freedraw_classPrivateFieldSet(e,t,i){return e.set(freedraw_assertClassBrand(e,t),i),i}function freedraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var qd=new WeakMap,Yd=new WeakMap,Zd=new WeakMap,Qd=new WeakMap,Jd=new WeakMap,ec=new WeakMap,tc=new WeakMap,ic=new WeakMap,ac=new WeakMap,sc=new WeakMap,rc=new WeakMap,nc=new WeakMap,oc=new WeakMap,lc=new WeakSet;class FreeDrawOutliner{constructor(e,t,i,a,s,r,n=0){freedraw_classPrivateMethodInitSpec(this,lc);freedraw_classPrivateFieldInitSpec(this,qd,void 0);freedraw_classPrivateFieldInitSpec(this,Yd,[]);freedraw_classPrivateFieldInitSpec(this,Zd,void 0);freedraw_classPrivateFieldInitSpec(this,Qd,void 0);freedraw_classPrivateFieldInitSpec(this,Jd,[]);freedraw_classPrivateFieldInitSpec(this,ec,new Float32Array(18));freedraw_classPrivateFieldInitSpec(this,tc,void 0);freedraw_classPrivateFieldInitSpec(this,ic,void 0);freedraw_classPrivateFieldInitSpec(this,ac,void 0);freedraw_classPrivateFieldInitSpec(this,sc,void 0);freedraw_classPrivateFieldInitSpec(this,rc,void 0);freedraw_classPrivateFieldInitSpec(this,nc,void 0);freedraw_classPrivateFieldInitSpec(this,oc,[]);freedraw_classPrivateFieldSet(qd,this,i);freedraw_classPrivateFieldSet(nc,this,s*a);freedraw_classPrivateFieldSet(Qd,this,r);freedraw_classPrivateFieldGet(ec,this).set([NaN,NaN,NaN,NaN,e,t],6);freedraw_classPrivateFieldSet(Zd,this,n);freedraw_classPrivateFieldSet(sc,this,dc._*a);freedraw_classPrivateFieldSet(ac,this,cc._*a);freedraw_classPrivateFieldSet(rc,this,a);freedraw_classPrivateFieldGet(oc,this).push(e,t)}isEmpty(){return isNaN(freedraw_classPrivateFieldGet(ec,this)[8])}isCancellable(){return freedraw_classPrivateFieldGet(oc,this).length<=10}removeLastElement(){freedraw_classPrivateFieldGet(ec,this).fill(NaN);freedraw_classPrivateFieldGet(Jd,this).length=freedraw_classPrivateFieldGet(Yd,this).length=freedraw_classPrivateFieldGet(oc,this).length=0;return{path:{d:""}}}add(e,t){freedraw_classPrivateFieldSet(tc,this,e);freedraw_classPrivateFieldSet(ic,this,t);const[i,a,s,r]=freedraw_classPrivateFieldGet(qd,this);let[n,o,l,d]=freedraw_classPrivateFieldGet(ec,this).subarray(8,12);const c=e-l,h=t-d,_=Math.hypot(c,h);if(_<freedraw_classPrivateFieldGet(ac,this))return!1;const u=_-freedraw_classPrivateFieldGet(sc,this),p=u/_,g=p*c,m=p*h;let f=n,v=o;n=l;o=d;l+=g;d+=m;freedraw_classPrivateFieldGet(oc,this)?.push(e,t);const P=g/u,w=-m/u*freedraw_classPrivateFieldGet(nc,this),F=P*freedraw_classPrivateFieldGet(nc,this);freedraw_classPrivateFieldGet(ec,this).set(freedraw_classPrivateFieldGet(ec,this).subarray(2,8),0);freedraw_classPrivateFieldGet(ec,this).set([l+w,d+F],4);freedraw_classPrivateFieldGet(ec,this).set(freedraw_classPrivateFieldGet(ec,this).subarray(14,18),12);freedraw_classPrivateFieldGet(ec,this).set([l-w,d-F],16);if(isNaN(freedraw_classPrivateFieldGet(ec,this)[6])){if(0===freedraw_classPrivateFieldGet(Jd,this).length){freedraw_classPrivateFieldGet(ec,this).set([n+w,o+F],2);freedraw_classPrivateFieldGet(Jd,this).push(NaN,NaN,NaN,NaN,(n+w-i)/s,(o+F-a)/r);freedraw_classPrivateFieldGet(ec,this).set([n-w,o-F],14);freedraw_classPrivateFieldGet(Yd,this).push(NaN,NaN,NaN,NaN,(n-w-i)/s,(o-F-a)/r)}freedraw_classPrivateFieldGet(ec,this).set([f,v,n,o,l,d],6);return!this.isEmpty()}freedraw_classPrivateFieldGet(ec,this).set([f,v,n,o,l,d],6);if(Math.abs(Math.atan2(v-o,f-n)-Math.atan2(m,g))<Math.PI/2){[n,o,l,d]=freedraw_classPrivateFieldGet(ec,this).subarray(2,6);freedraw_classPrivateFieldGet(Jd,this).push(NaN,NaN,NaN,NaN,((n+l)/2-i)/s,((o+d)/2-a)/r);[n,o,f,v]=freedraw_classPrivateFieldGet(ec,this).subarray(14,18);freedraw_classPrivateFieldGet(Yd,this).push(NaN,NaN,NaN,NaN,((f+n)/2-i)/s,((v+o)/2-a)/r);return!0}[f,v,n,o,l,d]=freedraw_classPrivateFieldGet(ec,this).subarray(0,6);freedraw_classPrivateFieldGet(Jd,this).push(((f+5*n)/6-i)/s,((v+5*o)/6-a)/r,((5*n+l)/6-i)/s,((5*o+d)/6-a)/r,((n+l)/2-i)/s,((o+d)/2-a)/r);[l,d,n,o,f,v]=freedraw_classPrivateFieldGet(ec,this).subarray(12,18);freedraw_classPrivateFieldGet(Yd,this).push(((f+5*n)/6-i)/s,((v+5*o)/6-a)/r,((5*n+l)/6-i)/s,((5*o+d)/6-a)/r,((n+l)/2-i)/s,((o+d)/2-a)/r);return!0}toSVGPath(){if(this.isEmpty())return"";const e=freedraw_classPrivateFieldGet(Jd,this),t=freedraw_classPrivateFieldGet(Yd,this);if(isNaN(freedraw_classPrivateFieldGet(ec,this)[6])&&!this.isEmpty())return freedraw_assertClassBrand(lc,this,_toSVGPathTwoPoints).call(this);const i=[];i.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);freedraw_assertClassBrand(lc,this,_toSVGPathEnd).call(this,i);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);freedraw_assertClassBrand(lc,this,_toSVGPathStart).call(this,i);return i.join(" ")}newFreeDrawOutline(e,t,i,a,s,r){return new FreeDrawOutline(e,t,i,a,s,r)}getOutlines(){const e=freedraw_classPrivateFieldGet(Jd,this),t=freedraw_classPrivateFieldGet(Yd,this),i=freedraw_classPrivateFieldGet(ec,this),[a,s,r,n]=freedraw_classPrivateFieldGet(qd,this),o=new Float32Array((freedraw_classPrivateFieldGet(oc,this)?.length??0)+2);for(let e=0,t=o.length-2;e<t;e+=2){o[e]=(freedraw_classPrivateFieldGet(oc,this)[e]-a)/r;o[e+1]=(freedraw_classPrivateFieldGet(oc,this)[e+1]-s)/n}o[o.length-2]=(freedraw_classPrivateFieldGet(tc,this)-a)/r;o[o.length-1]=(freedraw_classPrivateFieldGet(ic,this)-s)/n;if(isNaN(i[6])&&!this.isEmpty())return freedraw_assertClassBrand(lc,this,_getOutlineTwoPoints).call(this,o);const l=new Float32Array(freedraw_classPrivateFieldGet(Jd,this).length+24+freedraw_classPrivateFieldGet(Yd,this).length);let d=e.length;for(let t=0;t<d;t+=2)if(isNaN(e[t]))l[t]=l[t+1]=NaN;else{l[t]=e[t];l[t+1]=e[t+1]}d=freedraw_assertClassBrand(lc,this,_getOutlineEnd).call(this,l,d);for(let e=t.length-6;e>=6;e-=6)for(let i=0;i<6;i+=2)if(isNaN(t[e+i])){l[d]=l[d+1]=NaN;d+=2}else{l[d]=t[e+i];l[d+1]=t[e+i+1];d+=2}freedraw_assertClassBrand(lc,this,_getOutlineStart).call(this,l,d);return this.newFreeDrawOutline(l,o,freedraw_classPrivateFieldGet(qd,this),freedraw_classPrivateFieldGet(rc,this),freedraw_classPrivateFieldGet(Zd,this),freedraw_classPrivateFieldGet(Qd,this))}}function _getLastCoords(){const e=freedraw_classPrivateFieldGet(ec,this).subarray(4,6),t=freedraw_classPrivateFieldGet(ec,this).subarray(16,18),[i,a,s,r]=freedraw_classPrivateFieldGet(qd,this);return[(freedraw_classPrivateFieldGet(tc,this)+(e[0]-t[0])/2-i)/s,(freedraw_classPrivateFieldGet(ic,this)+(e[1]-t[1])/2-a)/r,(freedraw_classPrivateFieldGet(tc,this)+(t[0]-e[0])/2-i)/s,(freedraw_classPrivateFieldGet(ic,this)+(t[1]-e[1])/2-a)/r]}function _toSVGPathTwoPoints(){const[e,t,i,a]=freedraw_classPrivateFieldGet(qd,this),[s,r,n,o]=freedraw_assertClassBrand(lc,this,_getLastCoords).call(this);return`M${(freedraw_classPrivateFieldGet(ec,this)[2]-e)/i} ${(freedraw_classPrivateFieldGet(ec,this)[3]-t)/a} L${(freedraw_classPrivateFieldGet(ec,this)[4]-e)/i} ${(freedraw_classPrivateFieldGet(ec,this)[5]-t)/a} L${s} ${r} L${n} ${o} L${(freedraw_classPrivateFieldGet(ec,this)[16]-e)/i} ${(freedraw_classPrivateFieldGet(ec,this)[17]-t)/a} L${(freedraw_classPrivateFieldGet(ec,this)[14]-e)/i} ${(freedraw_classPrivateFieldGet(ec,this)[15]-t)/a} Z`}function _toSVGPathStart(e){const t=freedraw_classPrivateFieldGet(Yd,this);e.push(`L${t[4]} ${t[5]} Z`)}function _toSVGPathEnd(e){const[t,i,a,s]=freedraw_classPrivateFieldGet(qd,this),r=freedraw_classPrivateFieldGet(ec,this).subarray(4,6),n=freedraw_classPrivateFieldGet(ec,this).subarray(16,18),[o,l,d,c]=freedraw_assertClassBrand(lc,this,_getLastCoords).call(this);e.push(`L${(r[0]-t)/a} ${(r[1]-i)/s} L${o} ${l} L${d} ${c} L${(n[0]-t)/a} ${(n[1]-i)/s}`)}function _getOutlineTwoPoints(e){const t=freedraw_classPrivateFieldGet(ec,this),[i,a,s,r]=freedraw_classPrivateFieldGet(qd,this),[n,o,l,d]=freedraw_assertClassBrand(lc,this,_getLastCoords).call(this),c=new Float32Array(36);c.set([NaN,NaN,NaN,NaN,(t[2]-i)/s,(t[3]-a)/r,NaN,NaN,NaN,NaN,(t[4]-i)/s,(t[5]-a)/r,NaN,NaN,NaN,NaN,n,o,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,(t[16]-i)/s,(t[17]-a)/r,NaN,NaN,NaN,NaN,(t[14]-i)/s,(t[15]-a)/r],0);return this.newFreeDrawOutline(c,e,freedraw_classPrivateFieldGet(qd,this),freedraw_classPrivateFieldGet(rc,this),freedraw_classPrivateFieldGet(Zd,this),freedraw_classPrivateFieldGet(Qd,this))}function _getOutlineStart(e,t){const i=freedraw_classPrivateFieldGet(Yd,this);e.set([NaN,NaN,NaN,NaN,i[4],i[5]],t);return t+6}function _getOutlineEnd(e,t){const i=freedraw_classPrivateFieldGet(ec,this).subarray(4,6),a=freedraw_classPrivateFieldGet(ec,this).subarray(16,18),[s,r,n,o]=freedraw_classPrivateFieldGet(qd,this),[l,d,c,h]=freedraw_assertClassBrand(lc,this,_getLastCoords).call(this);e.set([NaN,NaN,NaN,NaN,(i[0]-s)/n,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(a[0]-s)/n,(a[1]-r)/o],t);return t+24}var dc={_:8},cc={_:dc._+2},hc=new WeakMap,_c=new WeakMap,uc=new WeakMap,pc=new WeakMap,gc=new WeakMap,mc=new WeakMap,fc=new WeakMap,vc=new WeakSet;class FreeDrawOutline extends Outline{constructor(e,t,i,a,s,r){super();freedraw_classPrivateMethodInitSpec(this,vc);freedraw_classPrivateFieldInitSpec(this,hc,void 0);freedraw_classPrivateFieldInitSpec(this,_c,new Float32Array(4));freedraw_classPrivateFieldInitSpec(this,uc,void 0);freedraw_classPrivateFieldInitSpec(this,pc,void 0);freedraw_classPrivateFieldInitSpec(this,gc,void 0);freedraw_classPrivateFieldInitSpec(this,mc,void 0);freedraw_classPrivateFieldInitSpec(this,fc,void 0);freedraw_classPrivateFieldSet(fc,this,e);freedraw_classPrivateFieldSet(gc,this,t);freedraw_classPrivateFieldSet(hc,this,i);freedraw_classPrivateFieldSet(mc,this,a);freedraw_classPrivateFieldSet(uc,this,s);freedraw_classPrivateFieldSet(pc,this,r);this.firstPoint=[NaN,NaN];this.lastPoint=[NaN,NaN];freedraw_assertClassBrand(vc,this,_computeMinMax).call(this,r);const[n,o,l,d]=freedraw_classPrivateFieldGet(_c,this);for(let t=0,i=e.length;t<i;t+=2){e[t]=(e[t]-n)/l;e[t+1]=(e[t+1]-o)/d}for(let e=0,i=t.length;e<i;e+=2){t[e]=(t[e]-n)/l;t[e+1]=(t[e+1]-o)/d}}toSVGPath(){const e=[`M${freedraw_classPrivateFieldGet(fc,this)[4]} ${freedraw_classPrivateFieldGet(fc,this)[5]}`];for(let t=6,i=freedraw_classPrivateFieldGet(fc,this).length;t<i;t+=6)isNaN(freedraw_classPrivateFieldGet(fc,this)[t])?e.push(`L${freedraw_classPrivateFieldGet(fc,this)[t+4]} ${freedraw_classPrivateFieldGet(fc,this)[t+5]}`):e.push(`C${freedraw_classPrivateFieldGet(fc,this)[t]} ${freedraw_classPrivateFieldGet(fc,this)[t+1]} ${freedraw_classPrivateFieldGet(fc,this)[t+2]} ${freedraw_classPrivateFieldGet(fc,this)[t+3]} ${freedraw_classPrivateFieldGet(fc,this)[t+4]} ${freedraw_classPrivateFieldGet(fc,this)[t+5]}`);e.push("Z");return e.join(" ")}serialize([e,t,i,a],s){const r=i-e,n=a-t;let o,l;switch(s){case 0:o=Outline._rescale(freedraw_classPrivateFieldGet(fc,this),e,a,r,-n);l=Outline._rescale(freedraw_classPrivateFieldGet(gc,this),e,a,r,-n);break;case 90:o=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(fc,this),e,t,r,n);l=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(gc,this),e,t,r,n);break;case 180:o=Outline._rescale(freedraw_classPrivateFieldGet(fc,this),i,t,-r,n);l=Outline._rescale(freedraw_classPrivateFieldGet(gc,this),i,t,-r,n);break;case 270:o=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(fc,this),i,a,-r,-n);l=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(gc,this),i,a,-r,-n)}return{outline:Array.from(o),points:[Array.from(l)]}}get box(){return freedraw_classPrivateFieldGet(_c,this)}newOutliner(e,t,i,a,s,r,n=0){return new FreeDrawOutliner(e,t,i,a,s,r,n)}updateThickness(e){const t=this.getNewOutline(e);freedraw_classPrivateFieldSet(fc,this,freedraw_classPrivateFieldGet(fc,t));freedraw_classPrivateFieldSet(gc,this,freedraw_classPrivateFieldGet(gc,t));freedraw_classPrivateFieldGet(_c,this).set(freedraw_classPrivateFieldGet(_c,t));this.firstPoint=t.firstPoint;this.lastPoint=t.lastPoint;return freedraw_classPrivateFieldGet(_c,this)}getNewOutline(e,t){const[i,a,s,r]=freedraw_classPrivateFieldGet(_c,this),[n,o,l,d]=freedraw_classPrivateFieldGet(hc,this),c=s*l,h=r*d,_=i*l+n,u=a*d+o,p=freedraw_classPrivateFieldGet(gc,this),g=this.newOutliner(p[0]*c+_,p[1]*h+u,freedraw_classPrivateFieldGet(hc,this),freedraw_classPrivateFieldGet(mc,this),e,freedraw_classPrivateFieldGet(pc,this),t??freedraw_classPrivateFieldGet(uc,this));for(let e=2,t=p.length;e<t;e+=2)g.add(p[e]*c+_,p[e+1]*h+u);return g.getOutlines()}}function _computeMinMax(e){const t=freedraw_classPrivateFieldGet(fc,this);let a=t[4],s=t[5];const r=[a,s,a,s];let n=a,o=s,l=a,d=s;const c=e?Math.max:Math.min,h=new Float32Array(4);for(let e=6,_=t.length;e<_;e+=6){const _=t[e+4],u=t[e+5];if(isNaN(t[e])){Util.pointBoundingBox(_,u,r);if(o>u){n=_;o=u}else o===u&&(n=c(n,_));if(d<u){l=_;d=u}else d===u&&(l=c(l,_))}else{h.set(i,0);Util.bezierBoundingBox(a,s,...t.slice(e,e+6),h);Util.rectBoundingBox(...h,r);if(o>h[1]){n=h[0];o=h[1]}else o===h[1]&&(n=c(n,h[0]));if(d<h[3]){l=h[2];d=h[3]}else d===h[3]&&(l=c(l,h[2]))}a=_;s=u}const _=freedraw_classPrivateFieldGet(_c,this);_[0]=r[0]-freedraw_classPrivateFieldGet(uc,this);_[1]=r[1]-freedraw_classPrivateFieldGet(uc,this);_[2]=r[2]-r[0]+2*freedraw_classPrivateFieldGet(uc,this);_[3]=r[3]-r[1]+2*freedraw_classPrivateFieldGet(uc,this);this.firstPoint=[n,o];this.lastPoint=[l,d]}function highlight_classPrivateFieldInitSpec(e,t,i){highlight_checkPrivateRedeclaration(e,t),t.set(e,i)}function highlight_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function highlight_classPrivateFieldSet(e,t,i){return e.set(highlight_assertClassBrand(e,t),i),i}function highlight_classPrivateFieldGet(e,t){return e.get(highlight_assertClassBrand(e,t))}function highlight_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function getHighlightSVGProperties(e){return{bbox:e.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:e.isFree},path:{d:e.toSVGPath()}}}function getHighlightFocusSVGProperties(e,t){const{focusOutline:i}=e;return{bbox:Outline._rotateBox(i.box,t),root:{"data-main-rotation":t},rootClass:{highlightOutline:!0,free:e.isFree},path:{d:i.toSVGPath()}}}var Pc=new WeakMap,wc=new WeakMap,Fc=new WeakMap,yc=new WeakMap,bc=new WeakMap,Sc=new WeakSet;class HighlightOutliner{constructor(e,t=0,a=0,s=!0){!function highlight_classPrivateMethodInitSpec(e,t){highlight_checkPrivateRedeclaration(e,t),t.add(e)}(this,Sc);highlight_classPrivateFieldInitSpec(this,Pc,void 0);highlight_classPrivateFieldInitSpec(this,wc,void 0);highlight_classPrivateFieldInitSpec(this,Fc,void 0);highlight_classPrivateFieldInitSpec(this,yc,[]);highlight_classPrivateFieldInitSpec(this,bc,[]);const r=i.slice(),n=10**-4;for(const{x:i,y:a,width:s,height:o}of e){const e=Math.floor((i-t)/n)*n,l=Math.ceil((i+s+t)/n)*n,d=Math.floor((a-t)/n)*n,c=Math.ceil((a+o+t)/n)*n,h=[e,d,c,!0],_=[l,d,c,!1];highlight_classPrivateFieldGet(yc,this).push(h,_);Util.rectBoundingBox(e,d,l,c,r)}const o=r[2]-r[0]+2*a,l=r[3]-r[1]+2*a,d=r[0]-a,c=r[1]-a;let h=s?-1/0:1/0,_=1/0;const u=highlight_classPrivateFieldGet(yc,this).at(s?-1:-2),p=[u[0],u[2]];for(const e of highlight_classPrivateFieldGet(yc,this)){const[t,i,a,r]=e;if(!r&&s)if(i<_){_=i;h=t}else i===_&&(h=Math.max(h,t));else if(r&&!s)if(i<_){_=i;h=t}else i===_&&(h=Math.min(h,t));e[0]=(t-d)/o;e[1]=(i-c)/l;e[2]=(a-c)/l}highlight_classPrivateFieldSet(Pc,this,new Float32Array([d,c,o,l]));highlight_classPrivateFieldSet(wc,this,[h,_]);highlight_classPrivateFieldSet(Fc,this,p)}getOutlines(){highlight_classPrivateFieldGet(yc,this).sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);const e=[];for(const t of highlight_classPrivateFieldGet(yc,this))if(t[3]){e.push(...highlight_assertClassBrand(Sc,this,_breakEdge).call(this,t));highlight_assertClassBrand(Sc,this,_insert).call(this,t)}else{highlight_assertClassBrand(Sc,this,_remove).call(this,t);e.push(...highlight_assertClassBrand(Sc,this,_breakEdge).call(this,t))}return highlight_assertClassBrand(Sc,this,_getOutlines).call(this,e)}}function _getOutlines(e){const t=[],i=new Set;for(const i of e){const[e,a,s]=i;t.push([e,a,i],[e,s,i])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,a=t.length;e<a;e+=2){const a=t[e][2],s=t[e+1][2];a.push(s);s.push(a);i.add(a);i.add(s)}const a=[];for(;i.size>0;){const e=i.values().next().value;let[t,s,r,n,o]=e;i.delete(e);let l=t,d=s;const c=[t,r];a.push(c);for(;;){let e;if(i.has(n))e=n;else{if(!i.has(o))break;e=o}i.delete(e);[t,s,r,n,o]=e;if(l!==t){c.push(l,d,t,d===s?s:r);l=t}d=d===s?r:s}c.push(l,d)}return new HighlightOutline(a,highlight_classPrivateFieldGet(Pc,this),highlight_classPrivateFieldGet(wc,this),highlight_classPrivateFieldGet(Fc,this))}function _binarySearch(e){const t=highlight_classPrivateFieldGet(bc,this);let i=0,a=t.length-1;for(;i<=a;){const s=i+a>>1,r=t[s][0];if(r===e)return s;r<e?i=s+1:a=s-1}return a+1}function _insert([,e,t]){const i=highlight_assertClassBrand(Sc,this,_binarySearch).call(this,e);highlight_classPrivateFieldGet(bc,this).splice(i,0,[e,t])}function _remove([,e,t]){const i=highlight_assertClassBrand(Sc,this,_binarySearch).call(this,e);for(let a=i;a<highlight_classPrivateFieldGet(bc,this).length;a++){const[i,s]=highlight_classPrivateFieldGet(bc,this)[a];if(i!==e)break;if(i===e&&s===t){highlight_classPrivateFieldGet(bc,this).splice(a,1);return}}for(let a=i-1;a>=0;a--){const[i,s]=highlight_classPrivateFieldGet(bc,this)[a];if(i!==e)break;if(i===e&&s===t){highlight_classPrivateFieldGet(bc,this).splice(a,1);return}}}function _breakEdge(e){const[t,i,a]=e,s=[[t,i,a]],r=highlight_assertClassBrand(Sc,this,_binarySearch).call(this,a);for(let e=0;e<r;e++){const[i,a]=highlight_classPrivateFieldGet(bc,this)[e];for(let e=0,r=s.length;e<r;e++){const[,n,o]=s[e];if(!(a<=n||o<=i))if(n>=i)if(o>a)s[e][1]=a;else{if(1===r)return[];s.splice(e,1);e--;r--}else{s[e][2]=i;o>a&&s.push([t,a,o])}}}return s}var Cc=new WeakMap,xc=new WeakMap,kc=new WeakMap;class HighlightOutline extends Outline{constructor(e,t,i,a){super();highlight_classPrivateFieldInitSpec(this,Cc,void 0);highlight_classPrivateFieldInitSpec(this,xc,null);highlight_classPrivateFieldInitSpec(this,kc,void 0);highlight_classPrivateFieldSet(kc,this,e);highlight_classPrivateFieldSet(Cc,this,t);this.firstPoint=i;this.lastPoint=a}static build(e,t){const i=new HighlightOutliner(e,.001).getOutlines();highlight_classPrivateFieldSet(xc,i,e);i.focusOutline=new HighlightOutliner(e,.0025,.001,t).getOutlines();return i}get isFree(){return!1}get defaultSVGProperties(){return getHighlightSVGProperties(this)}getFocusSVGProperties(e){return getHighlightFocusSVGProperties(this,e)}updateRotation(e){return{root:{"data-main-rotation":e}}}serializeQuadPoints([e,t],[i,a]){const s=highlight_classPrivateFieldGet(xc,this),r=new Float32Array(8*s.length);let n=0;for(const{x:o,y:l,width:d,height:c}of s){const s=o*i+e,h=(1-l)*a+t;r[n]=r[n+4]=s;r[n+1]=r[n+3]=h;r[n+2]=r[n+6]=s+d*i;r[n+5]=r[n+7]=h-c*a;n+=8}return r}toSVGPath(){const e=[];for(const t of highlight_classPrivateFieldGet(kc,this)){let[i,a]=t;e.push(`M${i} ${a}`);for(let s=2;s<t.length;s+=2){const r=t[s],n=t[s+1];if(r===i){e.push(`V${n}`);a=n}else if(n===a){e.push(`H${r}`);i=r}}e.push("Z")}return e.join(" ")}serialize([e,t,i,a],s){const r=[],n=i-e,o=a-t;for(const t of highlight_classPrivateFieldGet(kc,this)){const i=new Array(t.length);for(let s=0;s<t.length;s+=2){i[s]=e+t[s]*n;i[s+1]=a-t[s+1]*o}r.push(i)}return r}get box(){return highlight_classPrivateFieldGet(Cc,this)}}class FreeHighlightOutliner extends FreeDrawOutliner{newFreeDrawOutline(e,t,i,a,s,r){return new FreeHighlightOutline(e,t,i,a,s,r)}}var Ec=new WeakMap,Ac=new WeakMap;class FreeHighlightDrawer{constructor(e,t,i,a,s,r,n){highlight_classPrivateFieldInitSpec(this,Ec,void 0);highlight_classPrivateFieldInitSpec(this,Ac,void 0);highlight_classPrivateFieldSet(Ec,this,new FreeHighlightOutliner(e,t,i,a,s,r,n));highlight_classPrivateFieldSet(Ac,this,s)}add(e,t){return highlight_classPrivateFieldGet(Ec,this).add(e,t)?{path:{d:highlight_classPrivateFieldGet(Ec,this).toSVGPath()}}:null}addPoints(e){let t=!1;for(let i=0,a=e.length;i<a;i+=2)t=highlight_classPrivateFieldGet(Ec,this).add(e[i],e[i+1])||t;return t?{path:{d:highlight_classPrivateFieldGet(Ec,this).toSVGPath()}}:null}end(e,t){return void 0===e?null:this.add(e,t)}isEmpty(){return highlight_classPrivateFieldGet(Ec,this).isEmpty()}isCancellable(){return highlight_classPrivateFieldGet(Ec,this).isCancellable()}removeLastElement(){return highlight_classPrivateFieldGet(Ec,this).removeLastElement()}updateProperty(e,t){return null}getOutlines(){const e=highlight_classPrivateFieldGet(Ec,this).getOutlines();e.buildFocusOutline(2*highlight_classPrivateFieldGet(Ac,this));return e}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:highlight_classPrivateFieldGet(Ec,this).toSVGPath()}}}}class FreeHighlightOutline extends FreeDrawOutline{newOutliner(e,t,i,a,s,r,n=0){return new FreeHighlightOutliner(e,t,i,a,s,r,n)}get isFree(){return!0}buildFocusOutline(e){this.focusOutline=this.getNewOutline(e/2+Bc._,.0025)}get defaultSVGProperties(){return getHighlightSVGProperties(this)}getFocusSVGProperties(e){return getHighlightFocusSVGProperties(this,e)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(e){return{root:{"data-main-rotation":e}}}updateProperty(e,t){if("thickness"!==e)return null;const i=this.updateThickness(t/2);this.buildFocusOutline(t);return i}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}}var Gc,Bc={_:1.5};function segmentInCircle(e,t,i,a,s,r,n){const o=i-e,l=a-t,d=e-s,c=t-r,h=o*o+l*l,_=d*d+c*c-n;if(0===h)return _<=0?[0,1]:null;const u=2*(d*o+c*l),p=u*u-4*h*_;if(p<0)return null;const g=Math.sqrt(p),m=(-u-g)/(2*h),f=(-u+g)/(2*h);return f<0||m>1?null:[m,f]}function sweepCircleOverPaths(e,t,i,a,s=t,r=i){let n=!1;!function forEachSweepSample(e,t,i,a,s,r){const n=e-a,o=t-s,l=Math.max(i/2,1),d=Math.max(1,Math.ceil(Math.hypot(n,o)/l));for(let e=1;e<=d;e++){const t=e/d;r(a+n*t,s+o*t)}}(t,i,a,s,r,(t,i)=>{const s=function clipPathsWithCircle(e,t,i,a){const s=a*a,r=[];let n=!1;for(const a of e){const e=a.length;if(2===e){const e=a[0]-t,o=a[1]-i;e*e+o*o<=s?n=!0:r.push(a);continue}let o=null;const flush=()=>{o&&o.length>=4&&r.push(new Float32Array(o));o=null};let l=a[0],d=a[1];for(let r=2;r<e;r+=2){const e=a[r],c=a[r+1],h=segmentInCircle(l,d,e,c,t,i,s);if(h){n=!0;const[t,i]=h;if(t>0){o??=[l,d];o.push(l+(e-l)*t,d+(c-d)*t)}flush();i<1&&(o=[l+(e-l)*i,d+(c-d)*i,e,c])}else{o??=[l,d];o.push(e,c)}l=e;d=c}flush()}return{paths:n?r:e,modified:n}}(e,t,i,a);e=s.paths;n||=s.modified});return{paths:e,modified:n}}function getPathsBBox(e,t=0){let i=1/0,a=1/0,s=-1/0,r=-1/0;for(const t of e)for(let e=0,n=t.length;e<n;e+=2){i=Math.min(i,t[e]);a=Math.min(a,t[e+1]);s=Math.max(s,t[e]);r=Math.max(r,t[e+1])}return i===1/0?null:[i-t,a-t,s+t,r+t]}function makeLayerTransform(e,{width:t,height:i},[a,s],[r,n]){switch((e||0)%360){case 90:return{toLayer:(e,o)=>[(o-s)/n*t,(e-a)/r*i],toPage:(e,o)=>[a+o/i*r,s+e/t*n]};case 180:return{toLayer:(e,o)=>[(1-(e-a)/r)*t,(o-s)/n*i],toPage:(e,o)=>[a+(1-e/t)*r,s+o/i*n]};case 270:return{toLayer:(e,o)=>[(1-(o-s)/n)*t,(1-(e-a)/r)*i],toPage:(e,o)=>[a+(1-o/i)*r,s+(1-e/t)*n]};default:return{toLayer:(e,o)=>[(e-a)/r*t,(1-(o-s)/n)*i],toPage:(e,o)=>[a+e/t*r,s+(1-o/i)*n]}}}function highlight_defineProperty(e,t,i){return(t=function highlight_toPropertyKey(e){var t=function highlight_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_highlight_classPrivateFieldInitSpec(e,t,i){editor_highlight_checkPrivateRedeclaration(e,t),t.set(e,i)}function editor_highlight_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function editor_highlight_classPrivateFieldGet(e,t){return e.get(editor_highlight_assertClassBrand(e,t))}function editor_highlight_classPrivateFieldSet(e,t,i){return e.set(editor_highlight_assertClassBrand(e,t),i),i}function editor_highlight_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class HighlightDrawingOptions extends DrawingOptions{constructor(e=null){super();super.updateProperties(e)}updateSVGProperty(e,t){"thickness"!==e&&super.updateSVGProperty(e,t)}clone(){const e=new HighlightDrawingOptions;e.updateAll(this);return e}}var Mc=new WeakMap,Ic=new WeakMap,Tc=new WeakMap,Dc=new WeakMap,Lc=new WeakMap,Rc=new WeakMap,Oc=new WeakMap,Nc=new WeakMap,Wc=new WeakMap,jc=new WeakSet;class HighlightEditor extends DrawingEditor{static get _keyboardManager(){const e=HighlightEditor.prototype;return shadow(this,"_keyboardManager",new KeyboardManager([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"});!function editor_highlight_classPrivateMethodInitSpec(e,t){editor_highlight_checkPrivateRedeclaration(e,t),t.add(e)}(this,jc);editor_highlight_classPrivateFieldInitSpec(this,Mc,null);editor_highlight_classPrivateFieldInitSpec(this,Ic,0);editor_highlight_classPrivateFieldInitSpec(this,Tc,null);editor_highlight_classPrivateFieldInitSpec(this,Dc,0);editor_highlight_classPrivateFieldInitSpec(this,Lc,"");editor_highlight_classPrivateFieldInitSpec(this,Rc,"");editor_highlight_classPrivateFieldInitSpec(this,Oc,null);editor_highlight_classPrivateFieldInitSpec(this,Nc,!1);editor_highlight_classPrivateFieldInitSpec(this,Wc,!1);editor_highlight_classPrivateFieldSet(Mc,this,e.anchorNode||null);editor_highlight_classPrivateFieldSet(Ic,this,e.anchorOffset||0);editor_highlight_classPrivateFieldSet(Tc,this,e.focusNode||null);editor_highlight_classPrivateFieldSet(Dc,this,e.focusOffset||0);editor_highlight_classPrivateFieldSet(Lc,this,e.methodOfCreation||(this._drawOutlines?.isFree?"main_toolbar":""));editor_highlight_classPrivateFieldSet(Rc,this,e.text||"");this._isDraggable=!1;this.defaultL10nId="pdfjs-editor-highlight-editor";editor_highlight_classPrivateFieldSet(Nc,this,!!e.isErasePiece);this.rotate();this._uiManager?.isRestoringAnnotations||this._dispatchAddedEvent()}static initialize(e,t){AnnotationEditor.initialize(e,t);this._defaultDrawingOptions||=new HighlightDrawingOptions({fill:t.highlightColors?.values().next().value||"#fff066","fill-opacity":HighlightEditor._DEFAULT_OPACITY,thickness:HighlightEditor._DEFAULT_THICKNESS})}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get typesMap(){return shadow(this,"typesMap",new Map([[v.HIGHLIGHT_COLOR,"fill"],[v.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(e){const{boxes:t,drawOutlines:i}=e;if(t||i){this._drawingOptions||=e.drawingOptions||HighlightEditor.getDefaultDrawingOptions();t&&(e={...e,drawOutlines:HighlightOutline.build(t,"ltr"===this._uiManager.direction)});super._addOutlines(e)}}get colorType(){return v.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){return this._drawOutlines?.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){return!this._drawOutlines?.isFree}get addedEventValue(){return{color:this.color,thickness:this._drawingOptions?.thickness,isFreeHighlight:!!this._drawOutlines?.isFree,text:editor_highlight_classPrivateFieldGet(Rc,this)}}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:editor_highlight_classPrivateFieldGet(Lc,this)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}translateInPage(e,t){}get toolbarPosition(){return editor_highlight_assertClassBrand(jc,this,_relativeToBox).call(this,this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return editor_highlight_assertClassBrand(jc,this,_relativeToBox).call(this,this._drawOutlines.firstPoint)}updateParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:{const i=this.color;this._updateColorAndOpacity(t,HighlightEditor._DEFAULT_OPACITY,e);this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0);this._dispatchEditorEvent("colorChanged",{value:t,previousValue:i});break}case v.HIGHLIGHT_THICKNESS:{const i=this._drawingOptions?.thickness;super.updateParams(e,t);this._reportTelemetry({action:"thickness_changed",thickness:t},!0);this._dispatchEditorEvent("thicknessChanged",{value:t,previousValue:i});break}}}get propertiesToUpdate(){const e=super.propertiesToUpdate;e.push([v.HIGHLIGHT_FREE,this._drawOutlines.isFree]);return e}get toolbarButtons(){if(this._uiManager.highlightColors){this._colorPicker=new ColorPicker({editor:this});return[["colorPicker",this._colorPicker]]}return super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(e,t){return super.getRect(e,t,this._drawRotation)}onceAdded(e){if(!editor_highlight_classPrivateFieldGet(Nc,this)){if(editor_highlight_classPrivateFieldGet(Wc,this)){editor_highlight_classPrivateFieldSet(Wc,this,!1);e=!1}this.annotationElementId||this._uiManager.isRestoringAnnotations||this.parent.addUndoableEditor(this);e&&this.div.focus()}}remove(){this._reportTelemetry({action:"deleted"});super.remove()}get erasable(){return!!this._drawOutlines?.isFree}startErase(e){if(!this._drawOutlines?.isFree)return null;const t=this.getRect(0,0),i=this.parent.viewport.rotation,{points:a}=this._drawOutlines.serialize(t,0),s=makeLayerTransform(i,e,this.pageTranslation,this.pageDimensions),r=[];for(const e of a){const t=e.length;if(t<2)continue;const i=new Float32Array(t);for(let a=0;a<t;a+=2){const[t,r]=s.toLayer(e[a],e[a+1]);i[a]=t;i[a+1]=r}r.push(i)}if(0===r.length)return null;const n=this._drawingOptions.thickness/2*this.parentScale;editor_highlight_classPrivateFieldSet(Oc,this,{paths:r,layerW:e.width,layerH:e.height,strokeRadius:n,modified:!1,dirty:!1});return getPathsBBox(r,n)}erase(e,t,i,a=e,s=t){const r=editor_highlight_classPrivateFieldGet(Oc,this);if(!r)return;const{paths:n,modified:o}=sweepCircleOverPaths(r.paths,e,t,i+r.strokeRadius,a,s);if(o){r.paths=n;r.modified=!0;r.dirty=!0}}renderErase(){const e=editor_highlight_classPrivateFieldGet(Oc,this);if(!e?.dirty||!this.parent)return;e.dirty=!1;const t=editor_highlight_assertClassBrand(jc,this,_buildEraseOutliners).call(this,e).map(e=>e.toSVGPath()).join(" ");this.parent.drawLayer.updateProperties(this._drawId,{bbox:[0,0,1,1],root:{"data-main-rotation":0},path:{d:t}})}endErase(){const e=editor_highlight_classPrivateFieldGet(Oc,this);editor_highlight_classPrivateFieldSet(Oc,this,null);if(!e?.modified)return{};const t=this.parent,i=editor_highlight_assertClassBrand(jc,this,_buildEraseOutliners).call(this,e).map(e=>editor_highlight_assertClassBrand(jc,this,_finalizeEraseOutline).call(this,e));let a=null;const cmd=()=>{this.remove();if(a)for(const e of a)this._uiManager.rebuild(e);else a=i.map(e=>editor_highlight_assertClassBrand(jc,this,_spawnPiece).call(this,t,e))};cmd();return{cmd,undo:()=>{if(a)for(const e of a)e.remove();editor_highlight_classPrivateFieldSet(Wc,this,!0);t.addOrRebuild(this)}}}render(){if(this.div)return this.div;const e=super.render();if(editor_highlight_classPrivateFieldGet(Rc,this)){e.setAttribute("aria-label",editor_highlight_classPrivateFieldGet(Rc,this));e.setAttribute("role","mark")}this._drawOutlines.isFree?e.classList.add("free"):e.addEventListener("keydown",editor_highlight_assertClassBrand(jc,this,_keydown).bind(this),{signal:this._uiManager._signal});this.enableEditing();return e}_moveCaret(e){this.parent.unselect(this);switch(e){case 0:case 2:editor_highlight_assertClassBrand(jc,this,_setCaret).call(this,!0);break;case 1:case 3:editor_highlight_assertClassBrand(jc,this,_setCaret).call(this,!1)}}unselect(){super.unselect();this._drawOutlines.isFree||editor_highlight_assertClassBrand(jc,this,_setCaret).call(this,!1)}static createDrawerInstance({x:e,y:t,box:i,parent:a,isLTR:s}){return new FreeHighlightDrawer(e,t,i,a.scale,this._defaultDrawingOptions.thickness/2,s,.001)}static _getDrawingTarget(e,{target:t}){return t.closest(".textLayer")}static _getPointerCoords({x:e,y:t}){return[e,t]}static _addDrawingListeners(e,t){e.classList.add("free");t.addEventListener("abort",()=>e.classList.remove("free"),{once:!0});window.addEventListener("blur",()=>this._endDraw(null),{signal:t});window.addEventListener("pointerdown",stopEvent,{capture:!0,passive:!1,signal:t})}static _endDrawingSession(e=!1){return this.endDrawing(e)}createDrawingOptions({color:e,opacity:t,thickness:i}){const{_defaultDrawingOptions:a,_DEFAULT_OPACITY:s}=HighlightEditor;this._drawingOptions=HighlightEditor.getDefaultDrawingOptions({fill:Util.makeHexColor(...e),"fill-opacity":t||s,thickness:i||a.thickness})}static deserializeDraw(e,t,i,a,s,r,n){const{quadPoints:o}=r;if(o){const s=[];for(let r=0,n=o.length;r<n;r+=8)s.push({x:(o[r]-e)/i,y:1-(o[r+1]-t)/a,width:(o[r+2]-o[r])/i,height:(o[r+1]-o[r+5])/a});return HighlightOutline.build(s,"ltr"===n.direction)}const l=r.thickness||this._defaultDrawingOptions.thickness,d=(r.inkLists||r.outlines.points)[0],c=new FreeHighlightOutliner(d[0]-e,a-(d[1]-t),[0,0,i,a],1,l/2,!0,.001);for(let i=0,s=d.length;i<s;i+=2)c.add(d[i]-e,a-(d[i+1]-t));const h=c.getOutlines();h.buildFocusOutline(l);return h}static async deserialize(e,t,i){let a=null;if(e instanceof HighlightAnnotationElement){const{data:{quadPoints:t,rect:i,rotation:s,id:r,color:n,opacity:o,popupRef:l,richText:d,contentsObj:c,creationDate:h,modificationDate:_},parent:{page:{pageNumber:u}}}=e;a=e={annotationType:f.HIGHLIGHT,color:Array.from(n),opacity:o,quadPoints:t,pageIndex:u-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:l,richText:d,comment:c?.str||null,creationDate:h,modificationDate:_}}else if(e.annotationType&&e.annotationType===f.HIGHLIGHT){let t,{quadPoints:i,outlines:s,rect:r,rotation:n,id:o,color:l,opacity:d,popup:c,popupRef:h,pageIndex:_,thickness:u}=e;i&&(Array.isArray(i)||(i=Object.values(i)));if(!i&&s){if(Array.isArray(s))t=s.map(e=>e);else{if("object"!=typeof s||!s.points){console.error("Unexpected outlines format");return null}t=[s.points.flat()]}u=u||e.thickness||1}a=e={annotationType:f.HIGHLIGHT,color:Array.from(l),opacity:d,quadPoints:i,inkLists:t,thickness:u,boxes:null,pageIndex:_,rect:r.slice(0),rotation:n,id:o,deleted:!1,isCopy:e.isCopy,customId:e.customId,popupRef:h||!(!c||!c.contents||c.deleted)||null,comment:!c?.deleted&&c?.contents||null,commentDate:!c?.deleted&&c?.date||null}}else if(e instanceof InkAnnotationElement){const{data:{inkLists:t,rect:i,rotation:s,id:r,color:n,borderStyle:{rawWidth:o},popupRef:l,richText:d,contentsObj:c,creationDate:h,modificationDate:_},parent:{page:{pageNumber:u}}}=e;a=e={annotationType:f.HIGHLIGHT,color:Array.from(n),thickness:o,inkLists:t,pageIndex:u-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:l,richText:d,comment:c?.str||null,creationDate:h,modificationDate:_}}const s=await super.deserialize(e,t,i);s._initialData=a;e.comment&&s.setCommentData(e);return s}serialize(e=!1,t=null,i=!1){if(this.isEmpty()||e&&!i)return null;if(this.deleted)return this.serializeDeleted();const a=super.serialize(e,t);Object.assign(a,{color:AnnotationEditor._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(a.rect,this._drawRotation)});this.addComment(a,this._isCopy);if(e&&i){a.id=this.uid;a.isCopy=!0;return a}if(this.annotationElementId&&!editor_highlight_assertClassBrand(jc,this,highlight_hasElementChanged).call(this,a))return null;a.id=this.uid;return a}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}Gc=HighlightEditor;function _relativeToBox([e,t]){const[i,a,s,r]=this._drawOutlines.box;return[(e-i)/s,(t-a)/r]}function _buildEraseOutliners({paths:e,layerW:t,layerH:i}){const a=[0,0,t,i],s=this._drawingOptions.thickness/2,r="ltr"===this._uiManager.direction,n=this.parentScale,o=[];for(const t of e){if(t.length<4)continue;const e=new FreeHighlightOutliner(t[0],t[1],a,n,s,r,.001);for(let i=2,a=t.length;i<a;i+=2)e.add(t[i],t[i+1]);e.isEmpty()||o.push(e)}return o}function _finalizeEraseOutline(e){const t=e.getOutlines();t.buildFocusOutline(this._drawingOptions.thickness);return t}function _spawnPiece(e,t){const i=new Gc({parent:e,id:this._uiManager.getId(),uiManager:this._uiManager,eventBus:this.eventBus,x:0,y:0,isCentered:!1,drawOutlines:t,drawingOptions:this._drawingOptions.clone(),isErasePiece:!0});e.add(i);return i}function _keydown(e){Gc._keyboardManager.exec(this,e)}function _setCaret(e){if(!editor_highlight_classPrivateFieldGet(Mc,this))return;const t=window.getSelection();e?t.setPosition(editor_highlight_classPrivateFieldGet(Mc,this),editor_highlight_classPrivateFieldGet(Ic,this)):t.setPosition(editor_highlight_classPrivateFieldGet(Tc,this),editor_highlight_classPrivateFieldGet(Dc,this))}function highlight_hasElementChanged(e){const{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,i)=>e!==t[i])}highlight_defineProperty(HighlightEditor,"_DEFAULT_OPACITY",1);highlight_defineProperty(HighlightEditor,"_DEFAULT_THICKNESS",12);highlight_defineProperty(HighlightEditor,"_defaultDrawingOptions",null);highlight_defineProperty(HighlightEditor,"_type","highlight");highlight_defineProperty(HighlightEditor,"_editorType",f.HIGHLIGHT);function input_smoother_classPrivateFieldInitSpec(e,t,i){input_smoother_checkPrivateRedeclaration(e,t),t.set(e,i)}function input_smoother_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function input_smoother_classPrivateFieldGet(e,t){return e.get(input_smoother_assertClassBrand(e,t))}function input_smoother_classPrivateFieldSet(e,t,i){return e.set(input_smoother_assertClassBrand(e,t),i),i}function input_smoother_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Vc=new WeakMap,Uc=new WeakMap,zc=new WeakMap,Hc=new WeakSet;class InputSmoother{constructor(e,t,i){!function input_smoother_classPrivateMethodInitSpec(e,t){input_smoother_checkPrivateRedeclaration(e,t),t.add(e)}(this,Hc);input_smoother_classPrivateFieldInitSpec(this,Vc,void 0);input_smoother_classPrivateFieldInitSpec(this,Uc,void 0);input_smoother_classPrivateFieldInitSpec(this,zc,void 0);input_smoother_classPrivateFieldSet(Vc,this,[e,t,i]);input_smoother_classPrivateFieldSet(Uc,this,input_smoother_classPrivateFieldSet(zc,this,i))}add(e,t,i){const a=input_smoother_classPrivateFieldGet(Vc,this),s=a.at(-1);i=i>s?i:s+qc._;a.push(e,t,i);const r=input_smoother_assertClassBrand(Hc,this,_smooth).call(this,i-$c._,!0),n=input_smoother_assertClassBrand(Hc,this,_getSampleIndex).call(this,input_smoother_classPrivateFieldGet(zc,this)-$c._);if(n>=a.length/2){a.copyWithin(0,n);a.length-=n}return r}get pendingPoints(){return input_smoother_assertClassBrand(Hc,this,_smooth).call(this,1/0,!1)}end(){return input_smoother_assertClassBrand(Hc,this,_smooth).call(this,1/0,!0)}}function _smooth(e,t){const i=input_smoother_classPrivateFieldGet(Vc,this),a=input_smoother_classPrivateFieldGet(Uc,this),s=i.at(-1),r=[],n=input_smoother_classPrivateFieldGet(zc,this);for(let o=input_smoother_assertClassBrand(Hc,this,_getSampleIndex).call(this,n)+3;o<i.length;o+=3){const l=i[o-1],d=i[o+2]-l,c=Math.min(Math.ceil(d/Xc._),Kc._);for(let h=1;h<=c;h++){const _=h===c?i[o+2]:l+d*h/c;if(_<=n)continue;if(_>e)return r;const u=Math.min($c._,_-a,s-_);input_smoother_assertClassBrand(Hc,this,_average).call(this,_-u,_+u,r);t&&input_smoother_classPrivateFieldSet(zc,this,_)}}return r}function _getSampleIndex(e){const t=input_smoother_classPrivateFieldGet(Vc,this);let i=0,a=t.length/3-1;for(;i<a;){const s=i+a+1>>1;t[3*s+2]<=e?i=s:a=s-1}return 3*i}function _average(e,t,i){const a=input_smoother_classPrivateFieldGet(Vc,this),s=input_smoother_assertClassBrand(Hc,this,_getSampleIndex).call(this,e);let r=0,n=0,o=0;for(let i=s;i<a.length-3&&a[i+2]<t;i+=3){const s=a[i],l=a[i+1],d=a[i+2],c=a[i+5],h=Math.max(d,e),_=Math.min(c,t);if(_<=h)continue;const u=_-h,p=(h+_-2*d)/(c-d);r+=u*(s+p*(a[i+3]-s)/2);n+=u*(l+p*(a[i+4]-l)/2);o+=u}0===o?i.push(a[s],a[s+1]):i.push(r/o,n/o)}var $c={_:10},Xc={_:1e3/180},Kc={_:100},qc={_:.001};function inkdraw_classPrivateMethodInitSpec(e,t){inkdraw_checkPrivateRedeclaration(e,t),t.add(e)}function inkdraw_classPrivateFieldInitSpec(e,t,i){inkdraw_checkPrivateRedeclaration(e,t),t.set(e,i)}function inkdraw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function inkdraw_classPrivateFieldGet(e,t){return e.get(inkdraw_assertClassBrand(e,t))}function inkdraw_classPrivateFieldSet(e,t,i){return e.set(inkdraw_assertClassBrand(e,t),i),i}function inkdraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function svgPoint(e,t){return`${Outline.svgRound(e[t])} ${Outline.svgRound(e[t+1])}`}function pushCurves(e,t,i){for(let a=i,s=t.length;a<s;a+=6)e.push(`C${svgPoint(t,a)} ${svgPoint(t,a+2)} ${svgPoint(t,a+4)}`)}function lineToSVGPath(e){const t=`M${svgPoint(e,4)}`;if(6===e.length)return`${t}Z`;if(12===e.length&&isNaN(e[6]))return`${t}L${svgPoint(e,10)}`;const i=[t];pushCurves(i,e,6);return i.join("")}var Yc=new WeakMap,Zc=new WeakMap,Qc=new WeakMap,Jc=new WeakMap,eh=new WeakMap,th=new WeakMap,ih=new WeakMap,ah=new WeakMap,sh=new WeakMap,rh=new WeakMap,nh=new WeakMap,oh=new WeakMap,lh=new WeakMap,dh=new WeakMap,ch=new WeakMap,hh=new WeakSet;class InkDrawOutliner{constructor(e,t,i,a,s,r,n){inkdraw_classPrivateMethodInitSpec(this,hh);inkdraw_classPrivateFieldInitSpec(this,Yc,new Float64Array(6));inkdraw_classPrivateFieldInitSpec(this,Zc,new Float64Array(2));inkdraw_classPrivateFieldInitSpec(this,Qc,void 0);inkdraw_classPrivateFieldInitSpec(this,Jc,void 0);inkdraw_classPrivateFieldInitSpec(this,eh,void 0);inkdraw_classPrivateFieldInitSpec(this,th,null);inkdraw_classPrivateFieldInitSpec(this,ih,void 0);inkdraw_classPrivateFieldInitSpec(this,ah,void 0);inkdraw_classPrivateFieldInitSpec(this,sh,1);inkdraw_classPrivateFieldInitSpec(this,rh,new Float64Array(2));inkdraw_classPrivateFieldInitSpec(this,nh,"");inkdraw_classPrivateFieldInitSpec(this,oh,0);inkdraw_classPrivateFieldInitSpec(this,lh,new InkDrawOutline);inkdraw_classPrivateFieldInitSpec(this,dh,void 0);inkdraw_classPrivateFieldInitSpec(this,ch,void 0);inkdraw_classPrivateFieldSet(dh,this,i);inkdraw_classPrivateFieldSet(ch,this,a);inkdraw_classPrivateFieldSet(eh,this,s);inkdraw_classPrivateFieldSet(ih,this,r);inkdraw_classPrivateFieldSet(Jc,this,[]);inkdraw_assertClassBrand(hh,this,_startLine).call(this,e,t,n)}updateProperty(e,t){"stroke-width"===e&&inkdraw_classPrivateFieldSet(ih,this,t)}isEmpty(){return!inkdraw_classPrivateFieldGet(Jc,this)?.length}isCancellable(){return inkdraw_classPrivateFieldGet(sh,this)<=5}add(e,t,i){inkdraw_assertClassBrand(hh,this,_addSample).call(this,e,t,i);return{path:{d:inkdraw_assertClassBrand(hh,this,_toSVGPathWithTip).call(this)}}}addPoints(e,t){for(let i=0,a=e.length;i<a;i+=2)inkdraw_assertClassBrand(hh,this,_addSample).call(this,e[i],e[i+1],t?.[i/2]);return{path:{d:inkdraw_assertClassBrand(hh,this,_toSVGPathWithTip).call(this)}}}end(e,t,i){inkdraw_classPrivateFieldGet(Qc,this)&&void 0!==e&&inkdraw_assertClassBrand(hh,this,_addSample).call(this,e,t,i);inkdraw_assertClassBrand(hh,this,_endLine).call(this);return{path:{d:inkdraw_classPrivateFieldGet(nh,this)}}}startNew(e,t,i,a,s,r){inkdraw_classPrivateFieldSet(dh,this,i);inkdraw_classPrivateFieldSet(ch,this,a);inkdraw_classPrivateFieldSet(eh,this,s);const n=inkdraw_classPrivateFieldGet(Jc,this).at(-1);if(n){n.line=new Float32Array(n.line);n.points=new Float32Array(n.points)}inkdraw_assertClassBrand(hh,this,_startLine).call(this,e,t,r);return null}getLastElement(){return inkdraw_classPrivateFieldGet(Jc,this).at(-1)}setLastElement(e){if(!inkdraw_classPrivateFieldGet(Jc,this))return inkdraw_classPrivateFieldGet(lh,this).setLastElement(e);inkdraw_classPrivateFieldGet(Jc,this).push(e);inkdraw_classPrivateFieldSet(nh,this,inkdraw_classPrivateFieldGet(nh,this)+lineToSVGPath(e.line));return{path:{d:inkdraw_classPrivateFieldGet(nh,this)}}}removeLastElement(){if(!inkdraw_classPrivateFieldGet(Jc,this))return inkdraw_classPrivateFieldGet(lh,this).removeLastElement();inkdraw_classPrivateFieldSet(Qc,this,inkdraw_classPrivateFieldSet(ah,this,inkdraw_classPrivateFieldSet(th,this,null)));inkdraw_classPrivateFieldGet(Jc,this).pop();inkdraw_classPrivateFieldSet(nh,this,inkdraw_classPrivateFieldGet(Jc,this).map(({line:e})=>lineToSVGPath(e)).join(""));return{path:{d:inkdraw_classPrivateFieldGet(nh,this)}}}getOutlines(e,t,i,a){inkdraw_assertClassBrand(hh,this,_endLine).call(this);const s=inkdraw_classPrivateFieldGet(Jc,this).at(-1);s.line=new Float32Array(s.line);s.points=new Float32Array(s.points);inkdraw_classPrivateFieldGet(lh,this).build(inkdraw_classPrivateFieldGet(Jc,this),e,t,i,inkdraw_classPrivateFieldGet(eh,this),inkdraw_classPrivateFieldGet(ih,this),a);inkdraw_classPrivateFieldSet(Yc,this,null);inkdraw_classPrivateFieldSet(Qc,this,null);inkdraw_classPrivateFieldSet(Jc,this,null);inkdraw_classPrivateFieldSet(nh,this,null);return inkdraw_classPrivateFieldGet(lh,this)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}function _startLine(e,t,i){[e,t]=inkdraw_assertClassBrand(hh,this,_normalizeToTip).call(this,e,t);const a=inkdraw_classPrivateFieldSet(Qc,this,[NaN,NaN,NaN,NaN,e,t]);inkdraw_classPrivateFieldSet(ah,this,[e,t]);inkdraw_classPrivateFieldGet(Jc,this).push({line:a,points:inkdraw_classPrivateFieldGet(ah,this)});inkdraw_classPrivateFieldGet(Yc,this).set(a,0);inkdraw_classPrivateFieldSet(oh,this,0);inkdraw_classPrivateFieldSet(sh,this,1);inkdraw_classPrivateFieldGet(rh,this).set(inkdraw_classPrivateFieldGet(Zc,this));inkdraw_classPrivateFieldSet(th,this,void 0===i?null:new InputSmoother(e,t,i))}function _normalizeToTip(e,t){return Outline._normalizePoint(e,t,inkdraw_classPrivateFieldGet(dh,this),inkdraw_classPrivateFieldGet(ch,this),inkdraw_classPrivateFieldGet(eh,this),inkdraw_classPrivateFieldGet(Zc,this))}function _addSample(e,t,i){[e,t]=inkdraw_assertClassBrand(hh,this,_normalizeToTip).call(this,e,t);const[a,s]=inkdraw_classPrivateFieldGet(rh,this);if(!inkdraw_assertClassBrand(hh,this,_isTooClose).call(this,e,t,a,s)){var r;inkdraw_classPrivateFieldSet(sh,this,(r=inkdraw_classPrivateFieldGet(sh,this),r++,r));inkdraw_classPrivateFieldGet(rh,this).set(inkdraw_classPrivateFieldGet(Zc,this))}inkdraw_classPrivateFieldGet(th,this)?inkdraw_assertClassBrand(hh,this,_addSmoothedPoints).call(this,inkdraw_classPrivateFieldGet(th,this).add(e,t,i)):inkdraw_assertClassBrand(hh,this,_addPoint).call(this,e,t)}function _isTooClose(e,t,i,a){return Math.hypot(inkdraw_classPrivateFieldGet(dh,this)*(e-i),inkdraw_classPrivateFieldGet(ch,this)*(t-a))<=2}function _addSmoothedPoints(e){for(let t=0,i=e.length;t<i;t+=2)inkdraw_assertClassBrand(hh,this,_addPoint).call(this,e[t],e[t+1])}function _addPoint(e,t){const[,,i,a,s,r]=inkdraw_classPrivateFieldGet(Yc,this);if(!inkdraw_assertClassBrand(hh,this,_isTooClose).call(this,e,t,s,r)){inkdraw_classPrivateFieldGet(ah,this).push(e,t);if(isNaN(i))inkdraw_classPrivateFieldGet(Qc,this).push(NaN,NaN,NaN,NaN,e,t);else{isNaN(inkdraw_classPrivateFieldGet(Yc,this)[0])&&inkdraw_classPrivateFieldGet(Qc,this).splice(6,6);Outline.createBezierPoints(i,a,s,r,e,t,inkdraw_classPrivateFieldGet(Qc,this))}inkdraw_classPrivateFieldGet(Yc,this).copyWithin(0,2);inkdraw_classPrivateFieldGet(Yc,this)[4]=e;inkdraw_classPrivateFieldGet(Yc,this)[5]=t}}function _updatePath(){const e=inkdraw_classPrivateFieldGet(Qc,this);if(inkdraw_classPrivateFieldGet(ah,this).length<6||inkdraw_classPrivateFieldGet(oh,this)===e.length)return;const t=[inkdraw_classPrivateFieldGet(nh,this)];if(0===inkdraw_classPrivateFieldGet(oh,this)){t.push(`M${svgPoint(e,4)}`);inkdraw_classPrivateFieldSet(oh,this,6)}pushCurves(t,e,inkdraw_classPrivateFieldGet(oh,this));inkdraw_classPrivateFieldSet(nh,this,t.join(""));inkdraw_classPrivateFieldSet(oh,this,e.length)}function _endLine(){if(inkdraw_classPrivateFieldGet(Qc,this)){if(inkdraw_classPrivateFieldGet(th,this)){inkdraw_assertClassBrand(hh,this,_addSmoothedPoints).call(this,inkdraw_classPrivateFieldGet(th,this).end());inkdraw_classPrivateFieldSet(th,this,null)}if(inkdraw_classPrivateFieldGet(ah,this).length<6)inkdraw_classPrivateFieldSet(nh,this,inkdraw_classPrivateFieldGet(nh,this)+lineToSVGPath(inkdraw_classPrivateFieldGet(Qc,this)));else{const[,,e,t,i,a]=inkdraw_classPrivateFieldGet(Yc,this);Outline.createBezierPoints(e,t,i,a,i,a,inkdraw_classPrivateFieldGet(Qc,this));inkdraw_assertClassBrand(hh,this,_updatePath).call(this)}inkdraw_classPrivateFieldSet(Qc,this,inkdraw_classPrivateFieldSet(ah,this,null))}}function _toSVGPathWithTip(){inkdraw_assertClassBrand(hh,this,_updatePath).call(this);const e=[inkdraw_classPrivateFieldGet(nh,this)];if(0===inkdraw_classPrivateFieldGet(oh,this)){e.push(`M${svgPoint(inkdraw_classPrivateFieldGet(Qc,this),4)}`);4===inkdraw_classPrivateFieldGet(ah,this).length&&e.push(`L${svgPoint(inkdraw_classPrivateFieldGet(Qc,this),10)}`)}let t=inkdraw_classPrivateFieldGet(th,this)?.pendingPoints;t?.length||(t=inkdraw_classPrivateFieldGet(Zc,this));for(let i=0,a=t.length;i<a;i+=2)e.push(`L${svgPoint(t,i)}`);return e.join("")}var _h,uh=new WeakMap,ph=new WeakMap,gh=new WeakMap,mh=new WeakMap,fh=new WeakMap,vh=new WeakMap,Ph=new WeakMap,wh=new WeakMap,Fh=new WeakMap,yh=new WeakSet;class InkDrawOutline extends Outline{constructor(...e){super(...e);inkdraw_classPrivateMethodInitSpec(this,yh);inkdraw_classPrivateFieldInitSpec(this,uh,void 0);inkdraw_classPrivateFieldInitSpec(this,ph,0);inkdraw_classPrivateFieldInitSpec(this,gh,void 0);inkdraw_classPrivateFieldInitSpec(this,mh,void 0);inkdraw_classPrivateFieldInitSpec(this,fh,void 0);inkdraw_classPrivateFieldInitSpec(this,vh,void 0);inkdraw_classPrivateFieldInitSpec(this,Ph,void 0);inkdraw_classPrivateFieldInitSpec(this,wh,void 0);inkdraw_classPrivateFieldInitSpec(this,Fh,void 0)}build(e,t,i,a,s,r,n){inkdraw_classPrivateFieldSet(fh,this,t);inkdraw_classPrivateFieldSet(vh,this,i);inkdraw_classPrivateFieldSet(Ph,this,a);inkdraw_classPrivateFieldSet(wh,this,s);inkdraw_classPrivateFieldSet(Fh,this,r);inkdraw_classPrivateFieldSet(gh,this,n??0);inkdraw_classPrivateFieldSet(mh,this,e);inkdraw_assertClassBrand(yh,this,_computeBbox).call(this)}get thickness(){return inkdraw_classPrivateFieldGet(Fh,this)}setLastElement(e){inkdraw_classPrivateFieldGet(mh,this).push(e);return{path:{d:this.toSVGPath()}}}removeLastElement(){inkdraw_classPrivateFieldGet(mh,this).pop();return{path:{d:this.toSVGPath()}}}toSVGPath(){return inkdraw_classPrivateFieldGet(mh,this).map(({line:e})=>lineToSVGPath(e)).join("")}serialize([e,t,i,a],s){const r=[],n=[],[o,l,d,c]=inkdraw_assertClassBrand(yh,this,_getBBoxWithNoMargin).call(this);let h,_,u,p,g,m,f,v,P;switch(inkdraw_classPrivateFieldGet(wh,this)){case 0:P=Outline._rescale;h=e;_=t+a;u=i;p=-a;g=e+o*i;m=t+(1-l-c)*a;f=e+(o+d)*i;v=t+(1-l)*a;break;case 90:P=Outline._rescaleAndSwap;h=e;_=t;u=i;p=a;g=e+l*i;m=t+o*a;f=e+(l+c)*i;v=t+(o+d)*a;break;case 180:P=Outline._rescale;h=e+i;_=t;u=-i;p=a;g=e+(1-o-d)*i;m=t+l*a;f=e+(1-o)*i;v=t+(l+c)*a;break;case 270:P=Outline._rescaleAndSwap;h=e+i;_=t+a;u=-i;p=-a;g=e+(1-l-c)*i;m=t+(1-o-d)*a;f=e+(1-l)*i;v=t+(1-o)*a}for(const{line:e,points:t}of inkdraw_classPrivateFieldGet(mh,this)){r.push(P(e,h,_,u,p,s?new Array(e.length):null));n.push(P(t,h,_,u,p,s?new Array(t.length):null))}return{lines:r,points:n,rect:[g,m,f,v]}}static deserialize(e,t,i,a,s,{paths:{lines:r,points:n},rotation:o,thickness:l}){const d=[];let c,h,_,u,p;switch(o){case 0:p=Outline._rescale;c=-e/i;h=t/a+1;_=1/i;u=-1/a;break;case 90:p=Outline._rescaleAndSwap;c=-t/a;h=-e/i;_=1/a;u=1/i;break;case 180:p=Outline._rescale;c=e/i+1;h=-t/a;_=-1/i;u=1/a;break;case 270:p=Outline._rescaleAndSwap;c=t/a+1;h=e/i+1;_=-1/a;u=-1/i}if(!r){r=[];for(const e of n){const t=e.length;if(2===t){r.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(4===t){r.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}const i=new Float32Array(3*t);r.push(i);let[a,s,n,o]=e.subarray(0,4);i.set([NaN,NaN,NaN,NaN,a,s],0);for(let r=4;r<=t;r+=2){const l=Math.min(r,t-2),d=e[l],c=e[l+1];i.set(Outline.createBezierPoints(a,s,n,o,d,c),3*(r-2));[a,s,n,o]=[n,o,d,c]}}}for(let e=0,t=r.length;e<t;e++)d.push({line:p(r[e].map(e=>e??NaN),c,h,_,u),points:p(n[e].map(e=>e??NaN),c,h,_,u)});const g=new this.prototype.constructor;g.build(d,i,a,1,o,l,s);return g}get box(){return inkdraw_classPrivateFieldGet(uh,this)}updateProperty(e,t){return"stroke-width"===e?inkdraw_assertClassBrand(yh,this,_updateThickness).call(this,t):null}updateParentDimensions([e,t],i){const[a,s]=inkdraw_assertClassBrand(yh,this,_getMarginComponents).call(this);inkdraw_classPrivateFieldSet(fh,this,e);inkdraw_classPrivateFieldSet(vh,this,t);inkdraw_classPrivateFieldSet(Ph,this,i);const[r,n]=inkdraw_assertClassBrand(yh,this,_getMarginComponents).call(this),o=r-a,l=n-s,d=inkdraw_classPrivateFieldGet(uh,this);d[0]-=o;d[1]-=l;d[2]+=2*o;d[3]+=2*l;return d}updateRotation(e){inkdraw_classPrivateFieldSet(ph,this,e);return{path:{transform:this.rotationTransform}}}get viewBox(){return inkdraw_classPrivateFieldGet(uh,this).map(Outline.svgRound).join(" ")}get defaultProperties(){const[e,t]=inkdraw_classPrivateFieldGet(uh,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`}}}get rotationTransform(){const[,,e,t]=inkdraw_classPrivateFieldGet(uh,this);let i=0,a=0,s=0,r=0,n=0,o=0;switch(inkdraw_classPrivateFieldGet(ph,this)){case 90:a=t/e;s=-e/t;n=e;break;case 180:i=-1;r=-1;n=e;o=t;break;case 270:a=-t/e;s=e/t;o=t;break;default:return""}return`matrix(${i} ${a} ${s} ${r} ${Outline.svgRound(n)} ${Outline.svgRound(o)})`}getPathResizingSVGProperties([e,t,i,a]){const[s,r]=inkdraw_assertClassBrand(yh,this,_getMarginComponents).call(this),[n,o,l,d]=inkdraw_classPrivateFieldGet(uh,this);if(Math.abs(l-s)<=Outline.PRECISION||Math.abs(d-r)<=Outline.PRECISION){const s=e+i/2-(n+l/2),r=t+a/2-(o+d/2);return{path:{"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`,transform:`${this.rotationTransform} translate(${s} ${r})`}}}const c=(i-2*s)/(l-2*s),h=(a-2*r)/(d-2*r),_=l/i,u=d/a;return{path:{"transform-origin":`${Outline.svgRound(n)} ${Outline.svgRound(o)}`,transform:`${this.rotationTransform} scale(${_} ${u}) translate(${Outline.svgRound(s)} ${Outline.svgRound(r)}) scale(${c} ${h}) translate(${Outline.svgRound(-s)} ${Outline.svgRound(-r)})`}}}getPathResizedSVGProperties([e,t,i,a]){const[s,r]=inkdraw_assertClassBrand(yh,this,_getMarginComponents).call(this),n=inkdraw_classPrivateFieldGet(uh,this),[o,l,d,c]=n;n[0]=e;n[1]=t;n[2]=i;n[3]=a;if(Math.abs(d-s)<=Outline.PRECISION||Math.abs(c-r)<=Outline.PRECISION){const s=e+i/2-(o+d/2),r=t+a/2-(l+c/2);for(const{line:e,points:t}of inkdraw_classPrivateFieldGet(mh,this)){Outline._translate(e,s,r,e);Outline._translate(t,s,r,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const h=(i-2*s)/(d-2*s),_=(a-2*r)/(c-2*r),u=-h*(o+s)+e+s,p=-_*(l+r)+t+r;if(1!==h||1!==_||0!==u||0!==p)for(const{line:e,points:t}of inkdraw_classPrivateFieldGet(mh,this)){Outline._rescale(e,u,p,h,_,e);Outline._rescale(t,u,p,h,_,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],i){const[a,s]=i,r=inkdraw_classPrivateFieldGet(uh,this),n=e-r[0],o=t-r[1];if(inkdraw_classPrivateFieldGet(fh,this)===a&&inkdraw_classPrivateFieldGet(vh,this)===s)for(const{line:e,points:t}of inkdraw_classPrivateFieldGet(mh,this)){Outline._translate(e,n,o,e);Outline._translate(t,n,o,t)}else{const e=inkdraw_classPrivateFieldGet(fh,this)/a,t=inkdraw_classPrivateFieldGet(vh,this)/s;inkdraw_classPrivateFieldSet(fh,this,a);inkdraw_classPrivateFieldSet(vh,this,s);for(const{line:i,points:a}of inkdraw_classPrivateFieldGet(mh,this)){Outline._rescale(i,n,o,e,t,i);Outline._rescale(a,n,o,e,t,a)}r[2]*=e;r[3]*=t}r[0]=e;r[1]=t;return{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`}}}get defaultSVGProperties(){const e=inkdraw_classPrivateFieldGet(uh,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Outline.svgRound(e[0])} ${Outline.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}function _getMarginComponents(e=inkdraw_classPrivateFieldGet(Fh,this)){const t=inkdraw_classPrivateFieldGet(gh,this)+e/2*inkdraw_classPrivateFieldGet(Ph,this);return inkdraw_classPrivateFieldGet(wh,this)%180==0?[t/inkdraw_classPrivateFieldGet(fh,this),t/inkdraw_classPrivateFieldGet(vh,this)]:[t/inkdraw_classPrivateFieldGet(vh,this),t/inkdraw_classPrivateFieldGet(fh,this)]}function _getBBoxWithNoMargin(){const[e,t,i,a]=inkdraw_classPrivateFieldGet(uh,this),[s,r]=inkdraw_assertClassBrand(yh,this,_getMarginComponents).call(this,0);return[e+s,t+r,i-2*s,a-2*r]}function _computeBbox(){const e=inkdraw_classPrivateFieldSet(uh,this,a.slice());for(const{line:t}of inkdraw_classPrivateFieldGet(mh,this)){if(t.length<=12){for(let i=4,a=t.length;i<a;i+=6)Util.pointBoundingBox(t[i],t[i+1],e);continue}let i=t[4],a=t[5];for(let s=6,r=t.length;s<r;s+=6){const[r,n,o,l,d,c]=t.subarray(s,s+6);Util.bezierBoundingBox(i,a,r,n,o,l,d,c,e);i=d;a=c}}const[t,i]=inkdraw_assertClassBrand(yh,this,_getMarginComponents).call(this);e[0]=MathClamp(e[0]-t,0,1);e[1]=MathClamp(e[1]-i,0,1);e[2]=MathClamp(e[2]+t,0,1);e[3]=MathClamp(e[3]+i,0,1);e[2]-=e[0];e[3]-=e[1]}function _updateThickness(e){const[t,i]=inkdraw_assertClassBrand(yh,this,_getMarginComponents).call(this);inkdraw_classPrivateFieldSet(Fh,this,e);const[a,s]=inkdraw_assertClassBrand(yh,this,_getMarginComponents).call(this),[r,n]=[a-t,s-i],o=inkdraw_classPrivateFieldGet(uh,this);o[0]-=r;o[1]-=n;o[2]+=2*r;o[3]+=2*n;return o}function ink_defineProperty(e,t,i){return(t=function ink_toPropertyKey(e){var t=function ink_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function ink_classPrivateFieldInitSpec(e,t,i){ink_checkPrivateRedeclaration(e,t),t.set(e,i)}function ink_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ink_classPrivateFieldSet(e,t,i){return e.set(ink_assertClassBrand(e,t),i),i}function ink_classPrivateFieldGet(e,t){return e.get(ink_assertClassBrand(e,t))}function ink_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class InkDrawingOptions extends DrawingOptions{constructor(e){super();this._viewParameters=e;super.updateProperties({fill:"none",stroke:AnnotationEditor._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){if("stroke-width"===e){t??=this["stroke-width"];t*=this._viewParameters.realScale}super.updateSVGProperty(e,t)}clone(){const e=new InkDrawingOptions(this._viewParameters);e.updateAll(this);return e}}var bh,Sh=new WeakMap,Ch=new WeakMap,xh=new WeakSet;class InkEditor extends DrawingEditor{constructor(e){super({...e,name:"inkEditor"});!function ink_classPrivateMethodInitSpec(e,t){ink_checkPrivateRedeclaration(e,t),t.add(e)}(this,xh);ink_classPrivateFieldInitSpec(this,Sh,null);ink_classPrivateFieldInitSpec(this,Ch,!1);this._erasable=!0;this._willKeepAspectRatio=!0;this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,t){AnnotationEditor.initialize(e,t);this._defaultDrawingOptions=new InkDrawingOptions(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!0}static get typesMap(){return shadow(this,"typesMap",new Map([[v.INK_THICKNESS,"stroke-width"],[v.INK_COLOR,"stroke"],[v.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:e,y:t,box:[,,i,a],rotation:s,timeStamp:r}){return new InkDrawOutliner(e,t,i,a,s,this._defaultDrawingOptions["stroke-width"],r)}static deserializeDraw(e,t,i,a,s,r){return InkDrawOutline.deserialize(e,t,i,a,s,r)}static async deserialize(e,t,i){let a=null;if(e instanceof InkAnnotationElement){const{data:{inkLists:t,rect:i,rotation:s,id:r,color:n,opacity:o,borderStyle:{rawWidth:l},popupRef:d,richText:c,contentsObj:h,creationDate:_,modificationDate:u},parent:{page:{pageNumber:p}}}=e;a=e={annotationType:f.INK,color:Array.from(n),thickness:l,opacity:o,paths:{points:t},boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:d,richText:c,comment:h?.str||null,creationDate:_,modificationDate:u}}else{const{popup:t,popupRef:i}=e;a=e={...e,popupRef:i||!(!t||!t.contents||t.deleted)||null,comment:!t?.deleted&&t?.contents||null,commentDate:!t?.deleted&&t?.date||null}}const s=await super.deserialize(e,t,i);s._initialData=a;e.comment&&s.setCommentData(e);return s}get toolbarButtons(){this._colorPicker||=new BasicColorPicker(this);return[["colorPicker",this._colorPicker]]}get colorType(){return v.INK_COLOR}get colorAndOpacityType(){return v.INK_COLOR_AND_OPACITY}get opacityType(){return v.INK_OPACITY}updateParams(e,t){e!==v.INK_COLOR_AND_OPACITY?super.updateParams(e,t):this._updateColorAndOpacity(t.color,t.opacity)}static updateDefaultParams(e,t){if(e!==v.INK_COLOR_AND_OPACITY)super.updateDefaultParams(e,t);else{super.updateDefaultParams(v.INK_COLOR,t.color);super.updateDefaultParams(v.INK_OPACITY,t.opacity)}}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:t,parent:i}=this;t.updateSVGProperty("stroke-width");i.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;if(e){super.onScaleChangingWhenDrawing();this._defaultDrawingOptions.updateSVGProperty("stroke-width");e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}createDrawingOptions({color:e,thickness:t,opacity:i}){this._drawingOptions=InkEditor.getDefaultDrawingOptions({stroke:Util.makeHexColor(...e),"stroke-width":t,"stroke-opacity":i})}serialize(e=!1,t=null,i=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:a,points:s}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":n,"stroke-width":o}}=this,l=Object.assign(super.serialize(e,t),{color:AnnotationEditor._colorManager.convert(r),opacity:n,thickness:o,paths:{lines:a,points:s}});this.addComment(l,this._isCopy);if(e){i&&(l.id=this.uid);l.isCopy=!0;return l}if(this.annotationElementId&&!ink_assertClassBrand(xh,this,ink_hasElementChanged).call(this,l))return null;l.id=this.uid;return l}renderAnnotationElement(e){if(this.deleted){e.hide();return null}const{points:t,rect:i}=this.serializeDraw(!1);e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:t,popup:this.comment});return null}startErase(e){const{points:t}=this.serializeDraw(!1),i=ink_assertClassBrand(xh,this,_getLayerTransform).call(this,e),a=[];for(const e of t){const t=e.length;if(t<2)continue;const s=new Float32Array(t);for(let a=0;a<t;a+=2){const[t,r]=i.toLayer(e[a],e[a+1]);s[a]=t;s[a+1]=r}a.push(s)}if(0===a.length)return null;const s=this._drawingOptions["stroke-width"]*this.parentScale/2;ink_classPrivateFieldSet(Sh,this,{paths:a,transform:i,strokeRadius:s,modified:!1,dirty:!1});return getPathsBBox(a,s)}erase(e,t,i,a=e,s=t){const r=ink_classPrivateFieldGet(Sh,this);if(!r)return;const{paths:n,modified:o}=sweepCircleOverPaths(r.paths,e,t,i+r.strokeRadius,a,s);if(o){r.paths=n;r.modified=!0;r.dirty=!0}}renderErase(){const e=ink_classPrivateFieldGet(Sh,this);if(e?.dirty&&this.parent){e.dirty=!1;this.parent.drawLayer.updateProperties(this._drawId,{path:{d:0===e.paths.length?"":ink_assertClassBrand(xh,this,_buildOutline).call(this,e).toSVGPath()}})}}endErase(){const e=ink_classPrivateFieldGet(Sh,this);ink_classPrivateFieldSet(Sh,this,null);if(!e?.modified)return{};const t=this._drawOutlines,i=this._drawingOptions,a=ink_classPrivateFieldGet(Ch,this);if(0===e.paths.length){const e=this.parent;this.remove();return{cmd:()=>this.remove(),undo:()=>{e.addOrRebuild(this)}}}const s=ink_assertClassBrand(xh,this,_buildOutline).call(this,e),cmd=()=>{ink_classPrivateFieldSet(Ch,this,!0);this._addOutlines({drawOutlines:s,drawId:this._drawId,drawingOptions:i});this.rotate()};cmd();return{cmd,undo:()=>{ink_classPrivateFieldSet(Ch,this,a);this._addOutlines({drawOutlines:t,drawId:this._drawId,drawingOptions:i});this.rotate()}}}}_h=InkEditor;function ink_hasElementChanged(e){const{color:t,thickness:i,opacity:a,pageIndex:s}=this._initialData;return ink_classPrivateFieldGet(Ch,this)||this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,i)=>e!==t[i])||e.thickness!==i||e.opacity!==a||e.pageIndex!==s}function _buildOutline({paths:e,transform:t}){const{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:r}}}=this.parent,n=e.map(e=>{const i=new Float32Array(e.length);for(let a=0,s=e.length;a<s;a+=2){const[s,r]=t.toPage(e[a],e[a+1]);i[a]=s;i[a+1]=r}return i});return _h.deserializeDraw(s,r,i,a,_h._INNER_MARGIN,{paths:{points:n},rotation:this.rotation,thickness:this._drawingOptions["stroke-width"]})}function _getLayerTransform(e){return makeLayerTransform(this.parent.viewport.rotation,e,this.pageTranslation,this.pageDimensions)}ink_defineProperty(InkEditor,"_type","ink");ink_defineProperty(InkEditor,"_editorType",f.INK);ink_defineProperty(InkEditor,"_defaultDrawingOptions",null);class ContourDrawOutline extends InkDrawOutline{toSVGPath(){let e=super.toSVGPath();e.endsWith("Z")||(e+="Z");return e}}function signaturedraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class SignatureExtractor{static extractContoursFromText(e,{fontFamily:t,fontStyle:i,fontWeight:a},s,r,n,o){let l=new OffscreenCanvas(1,1),d=l.getContext("2d",{alpha:!1});const c=d.font=`${i} ${a} 200px ${t}`,{actualBoundingBoxLeft:h,actualBoundingBoxRight:_,actualBoundingBoxAscent:u,actualBoundingBoxDescent:p,fontBoundingBoxAscent:g,fontBoundingBoxDescent:m,width:f}=d.measureText(e),v=1.5,P=Math.ceil(Math.max(Math.abs(h)+Math.abs(_)||0,f)*v),w=Math.ceil(Math.max(Math.abs(u)+Math.abs(p)||200,Math.abs(g)+Math.abs(m)||200)*v);l=new OffscreenCanvas(P,w);d=l.getContext("2d",{alpha:!0,willReadFrequently:!0});d.font=c;d.filter="grayscale(1)";d.fillStyle="white";d.fillRect(0,0,P,w);d.fillStyle="black";d.fillText(e,.5*P/2,1.5*w/2);const F=signaturedraw_assertClassBrand(SignatureExtractor,this,_toUint).call(this,d.getImageData(0,0,P,w).data),y=signaturedraw_assertClassBrand(SignatureExtractor,this,_getHistogram).call(this,F),b=signaturedraw_assertClassBrand(SignatureExtractor,this,_guessThreshold).call(this,y),S=signaturedraw_assertClassBrand(SignatureExtractor,this,_findContours).call(this,F,P,w,b);return this.processDrawnLines({lines:{curves:S,width:P,height:w},pageWidth:s,pageHeight:r,rotation:n,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(e,t,i,a,s){const[r,n,o]=signaturedraw_assertClassBrand(SignatureExtractor,this,_getGrayPixels).call(this,e),[l,d]=signaturedraw_assertClassBrand(SignatureExtractor,this,_bilateralFilter).call(this,r,n,o,Math.hypot(n,o)*signaturedraw_assertClassBrand(SignatureExtractor,this,kh)._.sigmaSFactor,signaturedraw_assertClassBrand(SignatureExtractor,this,kh)._.sigmaR,signaturedraw_assertClassBrand(SignatureExtractor,this,kh)._.kernelSize),c=signaturedraw_assertClassBrand(SignatureExtractor,this,_guessThreshold).call(this,d),h=signaturedraw_assertClassBrand(SignatureExtractor,this,_findContours).call(this,l,n,o,c);return this.processDrawnLines({lines:{curves:h,width:n,height:o},pageWidth:t,pageHeight:i,rotation:a,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:i,rotation:a,innerMargin:s,mustSmooth:r,areContours:n}){a%180!=0&&([t,i]=[i,t]);const{curves:o,width:l,height:d}=e,c=e.thickness??0,h=[],_=Math.min(t/l,i/d),u=_/t,p=_/i,g=[];for(const{points:e}of o){const t=r?signaturedraw_assertClassBrand(SignatureExtractor,this,_douglasPeucker).call(this,e):e;if(!t)continue;g.push(t);const i=t.length,a=new Float32Array(i),s=new Float32Array(3*(2===i?2:i-2));h.push({line:s,points:a});if(2===i){a[0]=t[0]*u;a[1]=t[1]*p;s.set([NaN,NaN,NaN,NaN,a[0],a[1]],0);continue}let[n,o,l,d]=t;n*=u;o*=p;l*=u;d*=p;a.set([n,o,l,d],0);s.set([NaN,NaN,NaN,NaN,n,o],0);for(let e=4;e<i;e+=2){const i=a[e]=t[e]*u,r=a[e+1]=t[e+1]*p;s.set(Outline.createBezierPoints(n,o,l,d,i,r),3*(e-2));[n,o,l,d]=[l,d,i,r]}}if(0===h.length)return null;const m=n?new ContourDrawOutline:new InkDrawOutline;m.build(h,t,i,1,a,n?0:c,s);return{outline:m,newCurves:g,areContours:n,thickness:c,width:l,height:d}}static async compressSignature({outlines:e,areContours:t,thickness:i,width:a,height:s}){let r,n=1/0,o=-1/0,l=0;for(const t of e){l+=t.length;for(let e=2,i=t.length;e<i;e++){const i=t[e]-t[e-2];n=Math.min(n,i);o=Math.max(o,i)}}r=n>=-128&&o<=127?Int8Array:n>=-32768&&o<=32767?Int16Array:Int32Array;const d=e.length,c=8+3*d,h=new Uint32Array(c);let _=0;h[_++]=c*Uint32Array.BYTES_PER_ELEMENT+(l-2*d)*r.BYTES_PER_ELEMENT;h[_++]=0;h[_++]=a;h[_++]=s;h[_++]=t?0:1;h[_++]=Math.max(0,Math.floor(i??0));h[_++]=d;h[_++]=r.BYTES_PER_ELEMENT;for(const t of e){h[_++]=t.length-2;h[_++]=t[0];h[_++]=t[1]}const u=new CompressionStream("deflate-raw"),p=u.writable.getWriter();await p.ready;p.write(h);const g=r.prototype.constructor;for(const t of e){const e=new g(t.length-2);for(let i=2,a=t.length;i<a;i++)e[i-2]=t[i]-t[i-2];p.write(e)}p.close();return(await new Response(u.readable).bytes()).toBase64()}static async decompressSignature(e){try{const t=Uint8Array.fromBase64(e),{readable:i,writable:a}=new DecompressionStream("deflate-raw"),s=a.getWriter();await s.ready;s.write(t).then(async()=>{await s.ready;await s.close()}).catch(()=>{});let r=null,n=0;for await(const e of i){r||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]);r.set(e,n);n+=e.length}const o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(0!==l)throw new Error(`Invalid version: ${l}`);const d=o[2],c=o[3],h=0===o[4],_=o[5],u=o[6],p=o[7],g=[],m=(8+3*u)*Uint32Array.BYTES_PER_ELEMENT;let f;switch(p){case Int8Array.BYTES_PER_ELEMENT:f=new Int8Array(r.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:f=new Int16Array(r.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:f=new Int32Array(r.buffer,m)}n=0;for(let e=0;e<u;e++){const t=o[3*e+8],i=new Float32Array(t+2);g.push(i);for(let t=0;t<2;t++)i[t]=o[3*e+8+t+1];for(let e=0;e<t;e++)i[e+2]=i[e]+f[n++]}return{areContours:h,thickness:_,outlines:g,width:d,height:c}}catch(e){warn(`decompressSignature: ${e}`);return null}}}bh=SignatureExtractor;function _neighborIndexToId(e,t,i,a){a-=t;return 0===(i-=e)?a>0?0:4:1===i?a+6:2-a}function _clockwiseNonZero(e,t,i,a,s,r,n){const o=signaturedraw_assertClassBrand(bh,this,_neighborIndexToId).call(this,i,a,s,r);for(let s=0;s<8;s++){const r=(-s+o-n+16)%8;if(0!==e[(i+signaturedraw_assertClassBrand(bh,this,Eh)._[2*r])*t+(a+signaturedraw_assertClassBrand(bh,this,Eh)._[2*r+1])])return r}return-1}function _counterClockwiseNonZero(e,t,i,a,s,r,n){const o=signaturedraw_assertClassBrand(bh,this,_neighborIndexToId).call(this,i,a,s,r);for(let s=0;s<8;s++){const r=(s+o+n+16)%8;if(0!==e[(i+signaturedraw_assertClassBrand(bh,this,Eh)._[2*r])*t+(a+signaturedraw_assertClassBrand(bh,this,Eh)._[2*r+1])])return r}return-1}function _findContours(e,t,i,a){const s=e.length,r=new Int32Array(s);for(let t=0;t<s;t++)r[t]=e[t]<=a?1:0;for(let e=1;e<i-1;e++)r[e*t]=r[e*t+t-1]=0;for(let e=0;e<t;e++)r[e]=r[t*i-1-e]=0;let n,o=1;const l=[];for(let e=1;e<i-1;e++){n=1;for(let i=1;i<t-1;i++){const a=e*t+i,s=r[a];if(0===s)continue;let d=e,c=i;if(1===s&&0===r[a-1]){o+=1;c-=1}else{if(!(s>=1&&0===r[a+1])){1!==s&&(n=Math.abs(s));continue}o+=1;c+=1;s>1&&(n=s)}const h=[i,e],_=c===i+1,u={isHole:_,points:h,id:o,parent:0};l.push(u);let p;for(const e of l)if(e.id===n){p=e;break}p?p.isHole?u.parent=_?p.parent:n:u.parent=_?n:p.parent:u.parent=_?n:0;const g=signaturedraw_assertClassBrand(bh,this,_clockwiseNonZero).call(this,r,t,e,i,d,c,0);if(-1===g){r[a]=-o;1!==r[a]&&(n=Math.abs(r[a]));continue}let m=signaturedraw_assertClassBrand(bh,this,Eh)._[2*g],f=signaturedraw_assertClassBrand(bh,this,Eh)._[2*g+1];const v=e+m,P=i+f;d=v;c=P;let w=e,F=i;for(;;){const s=signaturedraw_assertClassBrand(bh,this,_counterClockwiseNonZero).call(this,r,t,w,F,d,c,1);m=signaturedraw_assertClassBrand(bh,this,Eh)._[2*s];f=signaturedraw_assertClassBrand(bh,this,Eh)._[2*s+1];const l=w+m,_=F+f;h.push(_,l);const u=w*t+F;0===r[u+1]?r[u]=-o:1===r[u]&&(r[u]=o);if(l===e&&_===i&&w===v&&F===P){1!==r[a]&&(n=Math.abs(r[a]));break}d=w;c=F;w=l;F=_}}}return l}function _douglasPeuckerHelper(e,t,i,a){if(i-t<=4){for(let s=t;s<i-2;s+=2)a.push(e[s],e[s+1]);return}const s=e[t],r=e[t+1],n=e[i-4]-s,o=e[i-3]-r,l=Math.hypot(n,o),d=n/l,c=o/l,h=d*r-c*s,_=o/n,u=1/l,p=Math.atan(_),g=Math.cos(p),m=Math.sin(p),f=u*(Math.abs(g)+Math.abs(m)),v=u*(1-f+f**2),P=Math.max(Math.atan(Math.abs(m+g)*v),Math.atan(Math.abs(m-g)*v));let w=0,F=t;for(let a=t+2;a<i-2;a+=2){const t=Math.abs(h-d*e[a+1]+c*e[a]);if(t>w){F=a;w=t}}if(w>(l*P)**2){signaturedraw_assertClassBrand(bh,this,_douglasPeuckerHelper).call(this,e,t,F+2,a);signaturedraw_assertClassBrand(bh,this,_douglasPeuckerHelper).call(this,e,F,i,a)}else a.push(s,r)}function _douglasPeucker(e){const t=[],i=e.length;signaturedraw_assertClassBrand(bh,this,_douglasPeuckerHelper).call(this,e,0,i,t);t.push(e[i-2],e[i-1]);return t.length<=4?null:t}function _bilateralFilter(e,t,i,a,s,r){const n=new Float32Array(r**2),o=-2*a**2,l=r>>1;for(let e=0;e<r;e++){const t=(e-l)**2;for(let i=0;i<r;i++)n[e*r+i]=Math.exp((t+(i-l)**2)/o)}const d=new Float32Array(256),c=-2*s**2;for(let e=0;e<256;e++)d[e]=Math.exp(e**2/c);const h=e.length,_=new Uint8Array(h),u=new Uint32Array(256);for(let a=0;a<i;a++)for(let s=0;s<t;s++){const o=a*t+s,c=e[o];let h=0,p=0;for(let o=0;o<r;o++){const _=a+o-l;if(!(_<0||_>=i))for(let i=0;i<r;i++){const a=s+i-l;if(a<0||a>=t)continue;const u=e[_*t+a],g=n[o*r+i]*d[Math.abs(u-c)];h+=u*g;p+=g}}u[_[o]=Math.round(h/p)]++}return[_,u]}function _getHistogram(e){const t=new Uint32Array(256);for(const i of e)t[i]++;return t}function _toUint(e){const t=e.length,i=new Uint8ClampedArray(t>>2);let a=-1/0,s=1/0;for(let t=0,r=i.length;t<r;t++){const r=i[t]=e[t<<2];a=Math.max(a,r);s=Math.min(s,r)}const r=255/(a-s);for(let e=0,t=i.length;e<t;e++)i[e]=(i[e]-s)*r;return i}function _guessThreshold(e){let t,i=-1/0,a=-1/0;const s=e.findIndex(e=>0!==e);let r=s,n=s;for(t=s;t<256;t++){const s=e[t];if(s>i){if(t-r>a){a=t-r;n=t-1}i=s;r=t}}for(t=n-1;t>=0&&!(e[t]>e[t+1]);t--);return t}function _getGrayPixels(e){const t=e,{width:i,height:a}=e,{maxDim:s}=signaturedraw_assertClassBrand(bh,this,kh)._;let r=i,n=a;if(i>s||a>s){let o=i,l=a,d=Math.log2(Math.max(i,a)/s);const c=Math.floor(d);d=d===c?c-1:c;for(let i=0;i<d;i++){r=Math.ceil(o/2);n=Math.ceil(l/2);const i=new OffscreenCanvas(r,n);i.getContext("2d").drawImage(e,0,0,o,l,0,0,r,n);o=r;l=n;e!==t&&e.close();e=i.transferToImageBitmap()}const h=Math.min(s/r,s/n);r=Math.round(r*h);n=Math.round(n*h)}const o=new OffscreenCanvas(r,n).getContext("2d",{willReadFrequently:!0});o.fillStyle="white";o.fillRect(0,0,r,n);o.filter="grayscale(1)";o.drawImage(e,0,0,e.width,e.height,0,0,r,n);const l=o.getImageData(0,0,r,n).data;return[signaturedraw_assertClassBrand(bh,this,_toUint).call(this,l),r,n]}var kh={_:{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}},Eh={_:new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1])};function signature_defineProperty(e,t,i){return(t=function signature_toPropertyKey(e){var t=function signature_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function signature_classPrivateFieldInitSpec(e,t,i){(function signature_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function signature_classPrivateFieldGet(e,t){return e.get(signature_assertClassBrand(e,t))}function signature_classPrivateFieldSet(e,t,i){return e.set(signature_assertClassBrand(e,t),i),i}function signature_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class SignatureOptions extends DrawingOptions{constructor(){super();super.updateProperties({fill:AnnotationEditor._defaultLineColor,"stroke-width":0})}clone(){const e=new SignatureOptions;e.updateAll(this);return e}}class DrawnSignatureOptions extends InkDrawingOptions{constructor(e){super(e);super.updateProperties({stroke:AnnotationEditor._defaultLineColor,"stroke-width":1})}clone(){const e=new DrawnSignatureOptions(this._viewParameters);e.updateAll(this);return e}}var Ah=new WeakMap,Gh=new WeakMap,Bh=new WeakMap,Mh=new WeakMap,Ih=new WeakMap;class SignatureEditor extends DrawingEditor{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});signature_classPrivateFieldInitSpec(this,Ah,!1);signature_classPrivateFieldInitSpec(this,Gh,null);signature_classPrivateFieldInitSpec(this,Bh,null);signature_classPrivateFieldInitSpec(this,Mh,null);signature_classPrivateFieldInitSpec(this,Ih,!1);this._willKeepAspectRatio=!0;signature_classPrivateFieldSet(Bh,this,e.signatureData||null);signature_classPrivateFieldSet(Gh,this,null);this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,t){AnnotationEditor.initialize(e,t);this._defaultDrawingOptions=new SignatureOptions;this._defaultDrawnSignatureOptions=new DrawnSignatureOptions(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!1}static get typesMap(){return shadow(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!signature_classPrivateFieldGet(Gh,this)}}static computeTelemetryFinalData(e){const t=e.get("hasDescription");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}get isResizable(){return!0}onceAdded(e){signature_classPrivateFieldSet(Ih,this,null===this._drawId);super.onceAdded(e)}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,t;const{_isCopy:i}=this;if(i){this._isCopy=!1;e=this.x;t=this.y}super.render();if(null===this._drawId)if(signature_classPrivateFieldGet(Bh,this)){const{lines:e,mustSmooth:t,areContours:i,description:a,uuid:s,heightInPage:r}=signature_classPrivateFieldGet(Bh,this),{rawDims:{pageWidth:n,pageHeight:o},rotation:l}=this.parent.viewport,d=SignatureExtractor.processDrawnLines({lines:e,pageWidth:n,pageHeight:o,rotation:l,innerMargin:SignatureEditor._INNER_MARGIN,mustSmooth:t,areContours:i});this.addSignature(d,r,a,s)}else{this.div.setAttribute("data-l10n-args",JSON.stringify({description:""}));this.div.hidden=!0;this._uiManager.getSignature(this)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:signature_classPrivateFieldGet(Gh,this)||""}));if(i){this._isCopy=!0;this._moveAfterPaste(e,t)}return this.div}setUuid(e){signature_classPrivateFieldSet(Mh,this,e);this.addEditToolbar()}getUuid(){return signature_classPrivateFieldGet(Mh,this)}get description(){return signature_classPrivateFieldGet(Gh,this)}set description(e){signature_classPrivateFieldSet(Gh,this,e);if(this.div){this.div.setAttribute("data-l10n-args",JSON.stringify({description:e}));super.addEditToolbar().then(t=>{t?.updateEditSignatureButton(e)})}}getSignaturePreview(){const{newCurves:e,areContours:t,thickness:i,width:a,height:s}=signature_classPrivateFieldGet(Bh,this),r=Math.max(a,s);return{areContours:t,outline:SignatureExtractor.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:i,width:a,height:s},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,t,i,a){const{x:s,y:r}=this,{outline:n}=signature_classPrivateFieldSet(Bh,this,e);signature_classPrivateFieldSet(Ah,this,n instanceof ContourDrawOutline);this.description=i;let o;if(signature_classPrivateFieldGet(Ah,this))o=SignatureEditor.getDefaultDrawingOptions();else{o=SignatureEditor._defaultDrawnSignatureOptions.clone();o.updateProperties({"stroke-width":n.thickness})}this._addOutlines({drawOutlines:n,drawingOptions:o});const[,l]=this.pageDimensions;let d=t/l;d=d>=1?.5:d;this.width*=d/this.height;if(this.width>=1){d*=.9/this.width;this.width=.9}this.height=d;this.setDims();this.x=s;this.y=r;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(a);this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!a,hasDescription:!!i}});this.div.hidden=!1;if(signature_classPrivateFieldGet(Ih,this)){signature_classPrivateFieldSet(Ih,this,!1);this.parent.addUndoableEditor(this)}this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"signatureAdded",page:this.pageIndex+1,editorType:this.constructor.name,id:this.uid,value:this,description:i})}getFromImage(e){const{rawDims:{pageWidth:t,pageHeight:i},rotation:a}=this.parent.viewport;return SignatureExtractor.process(e,t,i,a,SignatureEditor._INNER_MARGIN)}getFromText(e,t){const{rawDims:{pageWidth:i,pageHeight:a},rotation:s}=this.parent.viewport;return SignatureExtractor.extractContoursFromText(e,t,i,a,s,SignatureEditor._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:t,pageHeight:i},rotation:a}=this.parent.viewport;return SignatureExtractor.processDrawnLines({lines:e,pageWidth:t,pageHeight:i,rotation:a,innerMargin:SignatureEditor._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:t}){if(e)this._drawingOptions=SignatureEditor.getDefaultDrawingOptions();else{this._drawingOptions=SignatureEditor._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":t})}}serialize(e=!1,t=null,i=!1){if(this.isEmpty())return null;const{lines:a,points:s}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,n=Object.assign(super.serialize(e,t),{isSignature:!0,areContours:signature_classPrivateFieldGet(Ah,this),color:[0,0,0],thickness:signature_classPrivateFieldGet(Ah,this)?0:r});this.addComment(n,this._isCopy);if(e){n.paths={lines:a,points:s};n.uuid=signature_classPrivateFieldGet(Mh,this);n.isCopy=!0}else{n.lines=a;i&&(n.id=this.uid)}signature_classPrivateFieldGet(Gh,this)&&(n.accessibilityData={type:"Figure",alt:signature_classPrivateFieldGet(Gh,this)});return n}static deserializeDraw(e,t,i,a,s,r){return r.areContours?ContourDrawOutline.deserialize(e,t,i,a,s,r):InkDrawOutline.deserialize(e,t,i,a,s,r)}static async deserialize(e,t,i){const a=await super.deserialize(e,t,i);signature_classPrivateFieldSet(Ah,a,e.areContours);a.description=e.accessibilityData?.alt||"";signature_classPrivateFieldSet(Mh,a,e.uuid);return a}}signature_defineProperty(SignatureEditor,"_type","signature");signature_defineProperty(SignatureEditor,"_editorType",f.SIGNATURE);signature_defineProperty(SignatureEditor,"_defaultDrawingOptions",null);function stamp_defineProperty(e,t,i){return(t=function stamp_toPropertyKey(e){var t=function stamp_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function stamp_classPrivateFieldInitSpec(e,t,i){stamp_checkPrivateRedeclaration(e,t),t.set(e,i)}function stamp_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function stamp_classPrivateFieldGet(e,t){return e.get(stamp_assertClassBrand(e,t))}function stamp_classPrivateFieldSet(e,t,i){return e.set(stamp_assertClassBrand(e,t),i),i}function stamp_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Th=new WeakMap,Dh=new WeakMap,Lh=new WeakMap,Rh=new WeakMap,Oh=new WeakMap,Nh=new WeakMap,Wh=new WeakMap,jh=new WeakMap,Vh=new WeakMap,Uh=new WeakMap,zh=new WeakMap,Hh=new WeakSet;class StampEditor extends AnnotationEditor{constructor(e){super({...e,name:"stampEditor"});!function stamp_classPrivateMethodInitSpec(e,t){stamp_checkPrivateRedeclaration(e,t),t.add(e)}(this,Hh);stamp_classPrivateFieldInitSpec(this,Th,null);stamp_classPrivateFieldInitSpec(this,Dh,null);stamp_classPrivateFieldInitSpec(this,Lh,null);stamp_classPrivateFieldInitSpec(this,Rh,null);stamp_classPrivateFieldInitSpec(this,Oh,null);stamp_classPrivateFieldInitSpec(this,Nh,"");stamp_classPrivateFieldInitSpec(this,Wh,null);stamp_classPrivateFieldInitSpec(this,jh,!1);stamp_classPrivateFieldInitSpec(this,Vh,null);stamp_classPrivateFieldInitSpec(this,Uh,!1);stamp_classPrivateFieldInitSpec(this,zh,!1);stamp_classPrivateFieldSet(Rh,this,e.bitmapUrl);stamp_classPrivateFieldSet(Oh,this,e.bitmapFile);this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,t){AnnotationEditor.initialize(e,t)}static isHandlingMimeForPasting(e){return Y.has(e)}static paste(e,t){t.pasteEditor({mode:f.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){const t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:a,width:s,height:r}=e||this.copyCanvas(null,null,!0).imageData,n=await i.guess({name:"altText",request:{data:a,width:s,height:r,channels:a.length/(s*r)}});if(!n)throw new Error("No response from the AI service.");if(n.error)throw new Error("Error from the AI service.");if(n.cancel)return null;if(!n.output)throw new Error("No valid response from the AI service.");const o=n.output;await this.setGuessedAltText(o);t&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1});return o}remove(){if(stamp_classPrivateFieldGet(Dh,this)){stamp_classPrivateFieldSet(Th,this,null);this._uiManager.imageManager.deleteId(stamp_classPrivateFieldGet(Dh,this));stamp_classPrivateFieldGet(Wh,this)?.remove();stamp_classPrivateFieldSet(Wh,this,null);if(stamp_classPrivateFieldGet(Vh,this)){clearTimeout(stamp_classPrivateFieldGet(Vh,this));stamp_classPrivateFieldSet(Vh,this,null)}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){stamp_classPrivateFieldGet(Dh,this)&&null===stamp_classPrivateFieldGet(Wh,this)&&stamp_assertClassBrand(Hh,this,_getBitmap).call(this);this.isAttachedToDOM||this.parent.add(this)}}else stamp_classPrivateFieldGet(Dh,this)&&stamp_assertClassBrand(Hh,this,_getBitmap).call(this)}onceAdded(e){this._isDraggable=!0;e&&this.div.focus()}isEmpty(){return!(stamp_classPrivateFieldGet(Lh,this)||stamp_classPrivateFieldGet(Th,this)||stamp_classPrivateFieldGet(Rh,this)||stamp_classPrivateFieldGet(Oh,this)||stamp_classPrivateFieldGet(Dh,this)||stamp_classPrivateFieldGet(jh,this))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}super.render();this.div.hidden=!0;this.createAltText();stamp_classPrivateFieldGet(jh,this)||(stamp_classPrivateFieldGet(Th,this)?stamp_assertClassBrand(Hh,this,_createCanvas).call(this):stamp_assertClassBrand(Hh,this,_getBitmap).call(this));this._isCopy&&this._moveAfterPaste(e,t);this._uiManager.addShouldRescale(this);return this.div}setCanvas(e,t){const{id:i,bitmap:a}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove();if(i&&this._uiManager.imageManager.isValidId(i)){stamp_classPrivateFieldSet(Dh,this,i);a&&stamp_classPrivateFieldSet(Th,this,a);stamp_classPrivateFieldSet(jh,this,!1);stamp_assertClassBrand(Hh,this,_createCanvas).call(this)}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==stamp_classPrivateFieldGet(Vh,this)&&clearTimeout(stamp_classPrivateFieldGet(Vh,this));stamp_classPrivateFieldSet(Vh,this,setTimeout(()=>{stamp_classPrivateFieldSet(Vh,this,null);stamp_assertClassBrand(Hh,this,_drawBitmap).call(this)},200))}copyCanvas(e,t,i=!1){e||=224;const{width:a,height:s}=stamp_classPrivateFieldGet(Th,this),r=new OutputScale;let n=stamp_classPrivateFieldGet(Th,this),o=a,l=s,d=null;if(t){if(a>t||s>t){const e=Math.min(t/a,t/s);o=Math.floor(a*e);l=Math.floor(s*e)}d=document.createElement("canvas");const e=d.width=Math.ceil(o*r.sx),i=d.height=Math.ceil(l*r.sy);stamp_classPrivateFieldGet(Uh,this)||(n=stamp_assertClassBrand(Hh,this,_scaleBitmap).call(this,e,i));const c=d.getContext("2d");c.filter=this._uiManager.hcmFilter;let h="white",_="#cfcfd8";if("none"!==this._uiManager.hcmFilter)_="black";else if(ColorScheme.isDarkMode){h="#8f8f9d";_="#42414d"}const u=15,p=u*r.sx,g=u*r.sy,m=new OffscreenCanvas(2*p,2*g),f=m.getContext("2d");f.fillStyle=h;f.fillRect(0,0,2*p,2*g);f.fillStyle=_;f.fillRect(0,0,p,g);f.fillRect(p,g,p,g);c.fillStyle=c.createPattern(m,"repeat");c.fillRect(0,0,e,i);c.drawImage(n,0,0,n.width,n.height,0,0,e,i)}let c=null;if(i){let t,i;if(r.symmetric&&n.width<e&&n.height<e){t=n.width;i=n.height}else{n=stamp_classPrivateFieldGet(Th,this);if(a>e||s>e){const r=Math.min(e/a,e/s);t=Math.floor(a*r);i=Math.floor(s*r);stamp_classPrivateFieldGet(Uh,this)||(n=stamp_assertClassBrand(Hh,this,_scaleBitmap).call(this,t,i))}}const o=new OffscreenCanvas(t,i).getContext("2d",{willReadFrequently:!0});o.drawImage(n,0,0,n.width,n.height,0,0,t,i);c={width:t,height:i,data:o.getImageData(0,0,t,i).data}}return{canvas:d,width:o,height:l,imageData:c}}static async deserialize(e,t,i){let a=null,s=!1;if(e instanceof StampAnnotationElement){const{data:{rect:r,rotation:n,id:o,structParent:l,popupRef:d,richText:c,contentsObj:h,creationDate:_,modificationDate:u},container:p,parent:{page:{pageNumber:m}},canvas:v}=e;let P,w;if(v){delete e.canvas;({id:P,bitmap:w}=i.imageManager.getFromCanvas(p.id,v));v.remove()}else{s=!0;e._hasNoCanvas=!0}const F=(await t._structTree.getAriaAttributes(`${g}${o}`))?.get("aria-label")||"";a=e={annotationType:f.STAMP,bitmapId:P,bitmap:w,pageIndex:m-1,rect:r.slice(0),rotation:n,annotationElementId:o,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:F},isSvg:!1,structParent:l,popupRef:d,richText:c,comment:h?.str||null,creationDate:_,modificationDate:u}}else{const{popup:t,popupRef:i}=e;a=e={...e,popupRef:i||!(!t||!t.contents||t.deleted)||null,comment:!t?.deleted&&t?.contents||null,commentDate:!t?.deleted&&t?.date||null}}const r=await super.deserialize(e,t,i),{rect:n,bitmap:o,bitmapUrl:l,bitmapId:d,isSvg:c,accessibilityData:h}=e;if(s){i.addMissingCanvas(e.id,r);stamp_classPrivateFieldSet(jh,r,!0)}else if(d&&i.imageManager.isValidId(d)){stamp_classPrivateFieldSet(Dh,r,d);o&&stamp_classPrivateFieldSet(Th,r,o)}else stamp_classPrivateFieldSet(Rh,r,l);stamp_classPrivateFieldSet(Uh,r,c);const[_,u]=r.pageDimensions;r.width=(n[2]-n[0])/_;r.height=(n[3]-n[1])/u;h&&(r.altTextData=h);r._initialData=a;e.comment&&r.setCommentData(e);stamp_classPrivateFieldSet(zh,r,!!a);return r}serialize(e=!1,t=null,i=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a=Object.assign(super.serialize(e,t),{bitmapId:stamp_classPrivateFieldGet(Dh,this),isSvg:stamp_classPrivateFieldGet(Uh,this)});this.addComment(a,this._isCopy);if(e){a.bitmapUrl=stamp_assertClassBrand(Hh,this,_serializeBitmap).call(this,!0);a.accessibilityData=this.serializeAltText(!0);i&&(a.id=this.uid);a.isCopy=!0;return a}const{decorative:s,altText:r}=this.serializeAltText(!1);!s&&r&&(a.accessibilityData={type:"Figure",alt:r});if(this.annotationElementId){const e=stamp_assertClassBrand(Hh,this,stamp_hasElementChanged).call(this,a);if(e.isSame)return null;if(e.isSameAltText)delete a.accessibilityData;else{const e=this._initialData.structParent??-1;a.accessibilityData?a.accessibilityData.structParent=e:e>=0&&(a.accessibilityData={type:"Figure",alt:"",structParent:e})}a.id=this.uid;delete a.bitmapId;return a}if(null===t)return a;t.stamps||=new Map;const n=stamp_classPrivateFieldGet(Uh,this)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(t.stamps.has(stamp_classPrivateFieldGet(Dh,this))){if(stamp_classPrivateFieldGet(Uh,this)){const e=t.stamps.get(stamp_classPrivateFieldGet(Dh,this));if(n>e.area){e.area=n;e.serialized.bitmap.close();e.serialized.bitmap=stamp_assertClassBrand(Hh,this,_serializeBitmap).call(this,!1)}}}else{t.stamps.set(stamp_classPrivateFieldGet(Dh,this),{area:n,serialized:a});a.bitmap=stamp_assertClassBrand(Hh,this,_serializeBitmap).call(this,!1)}return a}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}function _getBitmapFetched(e,t=!1){if(e){stamp_classPrivateFieldSet(Th,this,e.bitmap);if(!t){stamp_classPrivateFieldSet(Dh,this,e.id);stamp_classPrivateFieldSet(Uh,this,e.isSvg)}e.file&&stamp_classPrivateFieldSet(Nh,this,e.file.name);stamp_assertClassBrand(Hh,this,_createCanvas).call(this)}else this.remove()}function _getBitmapDone(){stamp_classPrivateFieldSet(Lh,this,null);this._uiManager.enableWaiting(!1);if(stamp_classPrivateFieldGet(Wh,this))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&stamp_classPrivateFieldGet(Th,this))this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&stamp_classPrivateFieldGet(Th,this)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}function _getBitmap(){if(stamp_classPrivateFieldGet(Dh,this)){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(stamp_classPrivateFieldGet(Dh,this)).then(e=>stamp_assertClassBrand(Hh,this,_getBitmapFetched).call(this,e,!0)).finally(()=>stamp_assertClassBrand(Hh,this,_getBitmapDone).call(this));return}if(stamp_classPrivateFieldGet(Rh,this)){const e=stamp_classPrivateFieldGet(Rh,this);stamp_classPrivateFieldSet(Rh,this,null);this._uiManager.enableWaiting(!0);stamp_classPrivateFieldSet(Lh,this,this._uiManager.imageManager.getFromUrl(e).then(e=>stamp_assertClassBrand(Hh,this,_getBitmapFetched).call(this,e)).finally(()=>stamp_assertClassBrand(Hh,this,_getBitmapDone).call(this)));return}if(stamp_classPrivateFieldGet(Oh,this)){const e=stamp_classPrivateFieldGet(Oh,this);stamp_classPrivateFieldSet(Oh,this,null);this._uiManager.enableWaiting(!0);stamp_classPrivateFieldSet(Lh,this,this._uiManager.imageManager.getFromFile(e).then(e=>stamp_assertClassBrand(Hh,this,_getBitmapFetched).call(this,e)).finally(()=>stamp_assertClassBrand(Hh,this,_getBitmapDone).call(this)));return}const e=document.createElement("input");e.type="file";e.accept=Y.keys().join(",");const t=this._uiManager._signal;stamp_classPrivateFieldSet(Lh,this,new Promise(i=>{e.addEventListener("change",async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);const t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});stamp_assertClassBrand(Hh,this,_getBitmapFetched).call(this,t)}else this.remove();i()},{signal:t});e.addEventListener("cancel",()=>{this.remove();i()},{signal:t})}).finally(()=>stamp_assertClassBrand(Hh,this,_getBitmapDone).call(this)));e.click()}function _createCanvas(){const{div:e}=this;let{width:t,height:i}=stamp_classPrivateFieldGet(Th,this);const[a,s]=this.pageDimensions,r=.75;if(this.width){t=this.width*a;i=this.height*s}else if(t>r*a||i>r*s){const e=Math.min(r*a/t,r*s/i);t*=e;i*=e}this._uiManager.enableWaiting(!1);const n=stamp_classPrivateFieldSet(Wh,this,document.createElement("canvas"));n.setAttribute("role","img");this.addContainer(n);this.width=t/a;this.height=i/s;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1);stamp_assertClassBrand(Hh,this,_drawBitmap).call(this);if(!stamp_classPrivateFieldGet(zh,this)){this.parent.addUndoableEditor(this);stamp_classPrivateFieldSet(zh,this,!0)}this._reportTelemetry({action:"inserted_image"});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"imageAdded",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:n,width:t,height:i,fileName:stamp_classPrivateFieldGet(Nh,this)});stamp_classPrivateFieldGet(Nh,this)&&this.div.setAttribute("aria-description",stamp_classPrivateFieldGet(Nh,this));this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.stamp)}function _scaleBitmap(e,t){const{width:i,height:a}=stamp_classPrivateFieldGet(Th,this);let s=i,r=a,n=stamp_classPrivateFieldGet(Th,this);for(;s>2*e||r>2*t;){const i=s,a=r;s>2*e&&(s=Math.ceil(s/2));r>2*t&&(r=Math.ceil(r/2));const o=new OffscreenCanvas(s,r);o.getContext("2d").drawImage(n,0,0,i,a,0,0,s,r);n=o.transferToImageBitmap()}return n}function _drawBitmap(){const[e,t]=this.parentDimensions,{width:i,height:a}=this,s=new OutputScale,r=Math.ceil(i*e*s.sx),n=Math.ceil(a*t*s.sy),o=stamp_classPrivateFieldGet(Wh,this);if(!o||o.width===r&&o.height===n)return;o.width=r;o.height=n;const l=stamp_classPrivateFieldGet(Uh,this)?stamp_classPrivateFieldGet(Th,this):stamp_assertClassBrand(Hh,this,_scaleBitmap).call(this,r,n),d=o.getContext("2d");d.filter=this._uiManager.hcmFilter;d.drawImage(l,0,0,l.width,l.height,0,0,r,n)}function _serializeBitmap(e){if(e){if(stamp_classPrivateFieldGet(Uh,this)){const e=this._uiManager.imageManager.getSvgUrl(stamp_classPrivateFieldGet(Dh,this));if(e)return e}const e=document.createElement("canvas");({width:e.width,height:e.height}=stamp_classPrivateFieldGet(Th,this));e.getContext("2d").drawImage(stamp_classPrivateFieldGet(Th,this),0,0);return e.toDataURL()}if(stamp_classPrivateFieldGet(Uh,this)){const[e,t]=this.pageDimensions,i=Math.round(this.width*e*PixelsPerInch.PDF_TO_CSS_UNITS),a=Math.round(this.height*t*PixelsPerInch.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(i,a);s.getContext("2d").drawImage(stamp_classPrivateFieldGet(Th,this),0,0,stamp_classPrivateFieldGet(Th,this).width,stamp_classPrivateFieldGet(Th,this).height,0,0,i,a);return s.transferToImageBitmap()}return structuredClone(stamp_classPrivateFieldGet(Th,this))}function stamp_hasElementChanged(e){const{pageIndex:t,accessibilityData:{altText:i}}=this._initialData,a=e.pageIndex===t,s=(e.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&a&&s,isSameAltText:s}}stamp_defineProperty(StampEditor,"_type","stamp");stamp_defineProperty(StampEditor,"_editorType",f.STAMP);function annotation_editor_layer_classPrivateFieldInitSpec(e,t,i){annotation_editor_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_editor_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_editor_layer_classPrivateGetter(e,t,i){return i(annotation_editor_layer_assertClassBrand(e,t))}function annotation_editor_layer_classPrivateFieldGet(e,t){return e.get(annotation_editor_layer_assertClassBrand(e,t))}function annotation_editor_layer_classPrivateFieldSet(e,t,i){return e.set(annotation_editor_layer_assertClassBrand(e,t),i),i}function annotation_editor_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var $h=new WeakMap,Xh=new WeakMap,Kh=new WeakMap,qh=new WeakMap,Yh=new WeakMap,Zh=new WeakMap,Qh=new WeakMap,Jh=new WeakMap,e_=new WeakMap,t_=new WeakMap,i_=new WeakMap,a_=new WeakMap,s_=new WeakMap,r_=new WeakMap,n_=new WeakMap,o_=new WeakMap,l_=new WeakMap,d_=new WeakSet;class AnnotationEditorLayer{constructor({uiManager:e,pageIndex:t,div:i,structTreeLayer:a,accessibilityManager:s,annotationLayer:r,drawLayer:n,textLayer:o,viewport:l,l10n:d,eventBus:c}){!function annotation_editor_layer_classPrivateMethodInitSpec(e,t){annotation_editor_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,d_);annotation_editor_layer_classPrivateFieldInitSpec(this,$h,void 0);annotation_editor_layer_classPrivateFieldInitSpec(this,Xh,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,Kh,null);annotation_editor_layer_classPrivateFieldInitSpec(this,qh,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Yh,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Zh,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,Qh,new Map);annotation_editor_layer_classPrivateFieldInitSpec(this,Jh,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,e_,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,t_,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,i_,null);annotation_editor_layer_classPrivateFieldInitSpec(this,a_,null);annotation_editor_layer_classPrivateFieldInitSpec(this,s_,null);annotation_editor_layer_classPrivateFieldInitSpec(this,r_,null);annotation_editor_layer_classPrivateFieldInitSpec(this,n_,null);annotation_editor_layer_classPrivateFieldInitSpec(this,o_,-1);annotation_editor_layer_classPrivateFieldInitSpec(this,l_,void 0);const h=[...h_._.values()];if(!AnnotationEditorLayer._initialized){AnnotationEditorLayer._initialized=!0;for(const t of h){t.eventBus=c;t.initialize(d,e)}}e.registerEditorTypes(h);annotation_editor_layer_classPrivateFieldSet(l_,this,e);this.pageIndex=t;this.div=i;annotation_editor_layer_classPrivateFieldSet($h,this,s);annotation_editor_layer_classPrivateFieldSet(Kh,this,r);this.viewport=l;annotation_editor_layer_classPrivateFieldSet(s_,this,o);this.drawLayer=n;this._structTree=a;annotation_editor_layer_classPrivateFieldGet(l_,this).addLayer(this);this.eventBus=c}get isEmpty(){return 0===annotation_editor_layer_classPrivateFieldGet(Qh,this).size}get isInvisible(){return this.isEmpty&&annotation_editor_layer_classPrivateFieldGet(l_,this).getMode()===f.NONE}updateToolbar(e){annotation_editor_layer_classPrivateFieldGet(l_,this).updateToolbar(e)}updateMode(e=annotation_editor_layer_classPrivateFieldGet(l_,this).getMode()){annotation_editor_layer_assertClassBrand(d_,this,_cleanup).call(this);annotation_editor_layer_classPrivateFieldGet(Zh,this)&&annotation_editor_layer_assertClassBrand(d_,this,_toggleEditorPointerEvents).call(this,!0);switch(e){case f.NONE:this.div.classList.toggle("nonEditing",!0);this.disableTextSelection();this.togglePointerEvents(!1);this.toggleAnnotationLayerPointerEvents(!0);this.disableClick();return;case f.ERASER:annotation_editor_layer_assertClassBrand(d_,this,_toggleEditorPointerEvents).call(this,!1);this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick();this.addNewEditor({});break;case f.INK:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick();break;case f.HIGHLIGHT:this.enableTextSelection();this.togglePointerEvents(!1);this.disableClick();break;default:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;t.toggle("nonEditing",!1);if(e===f.POPUP)t.toggle("commentEditing",!0);else{t.toggle("commentEditing",!1);for(const i of h_._.values())t.toggle(`${i._type}Editing`,e===i._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===annotation_editor_layer_classPrivateFieldGet(s_,this)?.div}setEditingState(e){annotation_editor_layer_classPrivateFieldGet(l_,this).setEditingState(e)}addCommands(e){annotation_editor_layer_classPrivateFieldGet(l_,this).addCommands(e)}cleanUndoStack(e){annotation_editor_layer_classPrivateFieldGet(l_,this).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){annotation_editor_layer_classPrivateFieldGet(Kh,this)?.togglePointerEvents(e)}async enable(){annotation_editor_layer_classPrivateFieldSet(t_,this,!0);this.div.tabIndex=0;this.togglePointerEvents(!0);this.div.classList.toggle("nonEditing",!1);annotation_editor_layer_classPrivateFieldGet(n_,this)?.abort();annotation_editor_layer_classPrivateFieldSet(n_,this,null);const e=new Set;for(const t of annotation_editor_layer_classPrivateGetter(d_,this,_get_allEditorsIterator)){t.enableEditing();t.show(!0);if(t.annotationElementId){annotation_editor_layer_classPrivateFieldGet(l_,this).removeChangedExistingAnnotation(t);e.add(t.annotationElementId)}}const t=annotation_editor_layer_classPrivateFieldGet(Kh,this);if(t)for(const i of t.getEditableAnnotations()){i.hide();if(annotation_editor_layer_classPrivateFieldGet(l_,this).isDeletedAnnotationElement(i.data.id)||e.has(i.data.id))continue;const t=await this.deserialize(i);if(t){this.addOrRebuild(t);t.enableEditing()}}annotation_editor_layer_classPrivateFieldSet(t_,this,!1);annotation_editor_layer_classPrivateFieldGet(l_,this)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){annotation_editor_layer_classPrivateFieldSet(e_,this,!0);this.div.tabIndex=-1;this.togglePointerEvents(!1);this.div.classList.toggle("nonEditing",!0);if(annotation_editor_layer_classPrivateFieldGet(s_,this)&&!annotation_editor_layer_classPrivateFieldGet(n_,this)){annotation_editor_layer_classPrivateFieldSet(n_,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(l_,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(n_,this));annotation_editor_layer_classPrivateFieldGet(s_,this).div.addEventListener("pointerdown",e=>{const{clientX:t,clientY:i,timeStamp:a}=e;if(a-annotation_editor_layer_classPrivateFieldGet(o_,this)>500){annotation_editor_layer_classPrivateFieldSet(o_,this,a);return}annotation_editor_layer_classPrivateFieldSet(o_,this,-1);const{classList:s}=this.div;s.toggle("getElements",!0);const r=document.elementsFromPoint(t,i);s.toggle("getElements",!1);if(!this.div.contains(r[0]))return;let n;const o=new RegExp(`^${m}[0-9]+$`);for(const e of r)if(o.test(e.id)){n=e.id;break}if(!n)return;const l=annotation_editor_layer_classPrivateFieldGet(Qh,this).get(n);if(null===l?.annotationElementId){stopEvent(e);l.dblclick(e)}},{signal:e,capture:!0})}const e=annotation_editor_layer_classPrivateFieldGet(Kh,this),t=[];if(e){const i=new Map,a=new Map;for(const e of annotation_editor_layer_classPrivateGetter(d_,this,_get_allEditorsIterator)){e.disableEditing();if(e.annotationElementId)if(null===e.serialize()){a.set(e.annotationElementId,e);this.getEditableAnnotation(e.annotationElementId)?.show();e.remove()}else i.set(e.annotationElementId,e);else t.push(e)}for(const t of e.getEditableAnnotations()){const{id:e}=t.data;if(annotation_editor_layer_classPrivateFieldGet(l_,this).isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let s=a.get(e);if(s){s.resetAnnotationElement(t);s.show(!1);t.show()}else{s=i.get(e);if(s){annotation_editor_layer_classPrivateFieldGet(l_,this).addChangedExistingAnnotation(s);s.renderAnnotationElement(t)&&s.show(!1)}t.show()}}}annotation_editor_layer_assertClassBrand(d_,this,_cleanup).call(this);this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const e of h_._.values())i.remove(`${e._type}Editing`);this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(!0);e?.updateFakeAnnotations(t);annotation_editor_layer_classPrivateFieldSet(e_,this,!1)}getEditableAnnotation(e){return annotation_editor_layer_classPrivateFieldGet(Kh,this)?.getEditableAnnotation(e)||null}setActiveEditor(e){annotation_editor_layer_classPrivateFieldGet(l_,this).getActive()!==e&&annotation_editor_layer_classPrivateFieldGet(l_,this).setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1;if(annotation_editor_layer_classPrivateFieldGet(s_,this)?.div&&!annotation_editor_layer_classPrivateFieldGet(r_,this)){annotation_editor_layer_classPrivateFieldSet(r_,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(l_,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(r_,this));annotation_editor_layer_classPrivateFieldGet(s_,this).div.addEventListener("pointerdown",annotation_editor_layer_assertClassBrand(d_,this,_textLayerPointerDown).bind(this),{signal:e});annotation_editor_layer_classPrivateFieldGet(s_,this).div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0;if(annotation_editor_layer_classPrivateFieldGet(s_,this)?.div&&annotation_editor_layer_classPrivateFieldGet(r_,this)){annotation_editor_layer_classPrivateFieldGet(r_,this).abort();annotation_editor_layer_classPrivateFieldSet(r_,this,null);annotation_editor_layer_classPrivateFieldGet(s_,this).div.classList.remove("highlighting")}}enableClick(){if(annotation_editor_layer_classPrivateFieldGet(qh,this))return;annotation_editor_layer_classPrivateFieldSet(qh,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(l_,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(qh,this));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e});this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){annotation_editor_layer_classPrivateFieldGet(qh,this)?.abort();annotation_editor_layer_classPrivateFieldSet(qh,this,null)}attach(e){annotation_editor_layer_classPrivateFieldGet(Qh,this).set(e.id,e);const{annotationElementId:t}=e;t&&annotation_editor_layer_classPrivateFieldGet(l_,this).isDeletedAnnotationElement(t)&&annotation_editor_layer_classPrivateFieldGet(l_,this).removeDeletedAnnotationElement(e)}detach(e){annotation_editor_layer_classPrivateFieldGet(Qh,this).delete(e.id);annotation_editor_layer_classPrivateFieldGet($h,this)?.removePointerInTextLayer(e.contentDiv);!annotation_editor_layer_classPrivateFieldGet(e_,this)&&e.annotationElementId&&annotation_editor_layer_classPrivateFieldGet(l_,this).addDeletedAnnotationElement(e)}remove(e){this.detach(e);annotation_editor_layer_classPrivateFieldGet(l_,this).removeEditor(e);e.div.remove();e.isAttachedToDOM=!1}changeParent(e){if(e.parent!==this){if(e.parent&&e.annotationElementId){annotation_editor_layer_classPrivateFieldGet(l_,this).addDeletedAnnotationElement(e);AnnotationEditor.deleteAnnotationElement(e);e.annotationElementId=null}this.attach(e);e.parent?.detach(e);e.setParent(this);if(e.div&&e.isAttachedToDOM){e.div.remove();this.div.append(e.div)}}}add(e){if(e.parent!==this||!e.isAttachedToDOM){this.changeParent(e);annotation_editor_layer_classPrivateFieldGet(l_,this).addEditor(e);this.attach(e);if(!e.isAttachedToDOM){const t=e.render();this.div.append(t);e.isAttachedToDOM=!0}annotation_editor_layer_classPrivateFieldGet(Zh,this)&&"eraser"!==e.editorType&&annotation_editor_layer_assertClassBrand(d_,this,_setEditorPointerEvents).call(this,e,"none");e.fixAndSetPosition();e.onceAdded(!annotation_editor_layer_classPrivateFieldGet(t_,this)&&!annotation_editor_layer_classPrivateFieldGet(l_,this).isRestoringAnnotations);annotation_editor_layer_classPrivateFieldGet(l_,this).addToAnnotationStorage(e);e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:t}=document;if(e.div.contains(t)&&!annotation_editor_layer_classPrivateFieldGet(Yh,this)){e._focusEventsAllowed=!1;annotation_editor_layer_classPrivateFieldSet(Yh,this,setTimeout(()=>{annotation_editor_layer_classPrivateFieldSet(Yh,this,null);if(e.div.contains(document.activeElement))e._focusEventsAllowed=!0;else{e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:annotation_editor_layer_classPrivateFieldGet(l_,this)._signal});t.focus()}},0))}e._structTreeParentId=annotation_editor_layer_classPrivateFieldGet($h,this)?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){if(e.needsToBeRebuilt()){e.parent||=this;e.rebuild();e.show()}else this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(const t of annotation_editor_layer_classPrivateFieldGet(Qh,this).values())if(t.uid===e)return t;return null}combinedSignal(e){return annotation_editor_layer_classPrivateFieldGet(l_,this).combinedSignal(e)}canCreateNewEmptyEditor(){return annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType)?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e);await annotation_editor_layer_classPrivateFieldGet(l_,this).updateMode(e.mode);const{offsetX:i,offsetY:a}=annotation_editor_layer_assertClassBrand(d_,this,_getCenterPoint).call(this),s=annotation_editor_layer_classPrivateFieldGet(l_,this).getId(),r=annotation_editor_layer_assertClassBrand(d_,this,_createNewEditor).call(this,{parent:this,id:s,x:i,y:a,uiManager:annotation_editor_layer_classPrivateFieldGet(l_,this),isCentered:!0,...t});r&&this.add(r)}async deserialize(e){return await(h_._.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,annotation_editor_layer_classPrivateFieldGet(l_,this)))||null}createAndAddNewEditor(e,t,i={}){const a=annotation_editor_layer_classPrivateFieldGet(l_,this).getId(),s=annotation_editor_layer_assertClassBrand(d_,this,_createNewEditor).call(this,{parent:this,id:a,x:e.offsetX,y:e.offsetY,uiManager:annotation_editor_layer_classPrivateFieldGet(l_,this),isCentered:t,eventBus:this.eventBus,...i});s&&this.add(s);return s}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(e={}){this.createAndAddNewEditor(annotation_editor_layer_assertClassBrand(d_,this,_getCenterPoint).call(this),!0,e)}setSelected(e){annotation_editor_layer_classPrivateFieldGet(l_,this).setSelected(e)}toggleSelected(e){annotation_editor_layer_classPrivateFieldGet(l_,this).toggleSelected(e)}unselect(e){annotation_editor_layer_classPrivateFieldGet(l_,this).unselect(e)}pointerup(e){const{isMac:t}=FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(!annotation_editor_layer_classPrivateFieldGet(Jh,this))return;annotation_editor_layer_classPrivateFieldSet(Jh,this,!1);if(annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType)?.isDrawer&&annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType).supportMultipleDrawings)return;if(!annotation_editor_layer_classPrivateFieldGet(Xh,this)){annotation_editor_layer_classPrivateFieldSet(Xh,this,!0);return}const i=annotation_editor_layer_classPrivateFieldGet(l_,this).getMode();i!==f.STAMP&&i!==f.POPUP&&i!==f.SIGNATURE?this.createAndAddNewEditor(e,!1):annotation_editor_layer_classPrivateFieldGet(l_,this).unselectAll()}pointerdown(e){const{pointerType:t}=e,i=annotation_editor_layer_classPrivateFieldGet(l_,this).currentPointers;if(annotation_editor_layer_classPrivateFieldGet(l_,this).getMode()===f.HIGHLIGHT){if(i.isInitializedAndDifferentPointerType(t))return;i.setPointerTypeIfUnset(t);this.enableTextSelection()}else if(annotation_editor_layer_classPrivateFieldGet(l_,this).getMode()===f.INK&&i.isInitializedAndDifferentPointerType(t))return;if(annotation_editor_layer_classPrivateFieldGet(Jh,this)){annotation_editor_layer_classPrivateFieldSet(Jh,this,!1);return}const{isMac:a}=FeatureTest.platform;if(0!==e.button||e.ctrlKey&&a)return;if(e.target!==this.div)return;annotation_editor_layer_classPrivateFieldSet(Jh,this,!0);if(annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType)?.isDrawer){this.startDrawingSession(e);return}const s=annotation_editor_layer_classPrivateFieldGet(l_,this).getActive();annotation_editor_layer_classPrivateFieldSet(Xh,this,!s||s.isEmpty())}startDrawingSession(e){this.div.focus({preventScroll:!0});if(annotation_editor_layer_classPrivateFieldGet(i_,this)){annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType).startDrawing(this,annotation_editor_layer_classPrivateFieldGet(l_,this),!1,e);return}annotation_editor_layer_classPrivateFieldGet(l_,this).setCurrentDrawingSession(this);annotation_editor_layer_classPrivateFieldSet(i_,this,new AbortController);const t=annotation_editor_layer_classPrivateFieldGet(l_,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(i_,this));this.div.addEventListener("blur",({relatedTarget:e})=>{if(e&&!this.div.contains(e)){annotation_editor_layer_classPrivateFieldSet(a_,this,null);this.commitOrRemove()}},{signal:t});annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType).startDrawing(this,annotation_editor_layer_classPrivateFieldGet(l_,this),!1,e)}pause(e){if(e){const{activeElement:e}=document;this.div.contains(e)&&annotation_editor_layer_classPrivateFieldSet(a_,this,e);return}annotation_editor_layer_classPrivateFieldGet(a_,this)&&setTimeout(()=>{annotation_editor_layer_classPrivateFieldGet(a_,this)?.focus();annotation_editor_layer_classPrivateFieldSet(a_,this,null)},0)}endDrawingSession(e=!1){if(!annotation_editor_layer_classPrivateFieldGet(i_,this))return null;annotation_editor_layer_classPrivateFieldGet(l_,this).setCurrentDrawingSession(null);annotation_editor_layer_classPrivateFieldGet(i_,this).abort();annotation_editor_layer_classPrivateFieldSet(i_,this,null);annotation_editor_layer_classPrivateFieldSet(a_,this,null);return annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType).endDrawing(e)}findNewParent(e,t,i){const a=annotation_editor_layer_classPrivateFieldGet(l_,this).findParent(t,i);if(null===a||a===this)return!1;a.changeParent(e);return!0}commitOrRemove(){if(annotation_editor_layer_classPrivateFieldGet(i_,this)){this.endDrawingSession();return!0}return!1}onScaleChanging(){annotation_editor_layer_classPrivateFieldGet(i_,this)&&annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType).onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove();if(annotation_editor_layer_classPrivateFieldGet(l_,this).getActive()?.parent===this){annotation_editor_layer_classPrivateFieldGet(l_,this).commitOrRemove();annotation_editor_layer_classPrivateFieldGet(l_,this).setActiveEditor(null)}if(annotation_editor_layer_classPrivateFieldGet(Yh,this)){clearTimeout(annotation_editor_layer_classPrivateFieldGet(Yh,this));annotation_editor_layer_classPrivateFieldSet(Yh,this,null)}for(const e of annotation_editor_layer_classPrivateFieldGet(Qh,this).values()){annotation_editor_layer_classPrivateFieldGet($h,this)?.removePointerInTextLayer(e.contentDiv);e.setParent(null);e.isAttachedToDOM=!1;e.div.remove()}this.div=null;annotation_editor_layer_classPrivateFieldGet(Qh,this).clear();annotation_editor_layer_classPrivateFieldGet(l_,this).removeLayer(this)}async render({viewport:e}){this.viewport=e;setLayerDimensions(this.div,e);for(const e of annotation_editor_layer_classPrivateFieldGet(l_,this).getEditors(this.pageIndex)){this.add(e);e.rebuild()}await annotation_editor_layer_classPrivateFieldGet(l_,this).findClonesForPage(this);this.div.hidden=this.isEmpty;this.updateMode()}update({viewport:e}){annotation_editor_layer_classPrivateFieldGet(l_,this).commitOrRemove();annotation_editor_layer_assertClassBrand(d_,this,_cleanup).call(this);const t=this.viewport.rotation,i=e.rotation;this.viewport=e;setLayerDimensions(this.div,{rotation:i});if(t!==i)for(const e of annotation_editor_layer_classPrivateFieldGet(Qh,this).values())e.rotate(i);annotation_editor_layer_classPrivateFieldGet(l_,this).getMode()!==f.ERASER||this.div.hidden||this.addNewEditor({})}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return annotation_editor_layer_classPrivateFieldGet(l_,this).viewParameters.realScale}}function _get_allEditorsIterator(e){return 0!==annotation_editor_layer_classPrivateFieldGet(Qh,e).size?annotation_editor_layer_classPrivateFieldGet(Qh,e).values():annotation_editor_layer_classPrivateFieldGet(l_,e).getEditors(e.pageIndex)}function _toggleEditorPointerEvents(e=!1){annotation_editor_layer_classPrivateFieldSet(Zh,this,!e);const t=e?"":"none";for(const e of annotation_editor_layer_classPrivateFieldGet(Qh,this).values())annotation_editor_layer_assertClassBrand(d_,this,_setEditorPointerEvents).call(this,e,t)}function _setEditorPointerEvents(e,t){e.div.style.pointerEvents=t;for(const i of e.div.children)"internal"===i.className&&(i.style.pointerEvents=t)}function _textLayerPointerDown(e){annotation_editor_layer_classPrivateFieldGet(l_,this).unselectAll();const{target:t}=e;if(t===annotation_editor_layer_classPrivateFieldGet(s_,this).div||("img"===t.getAttribute("role")||t.classList.contains("endOfContent")||t.classList.contains("textLayerImages")||t.classList.contains("textLayerImagePlaceholder"))&&annotation_editor_layer_classPrivateFieldGet(s_,this).div.contains(t)){const{isMac:t}=FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)return;annotation_editor_layer_classPrivateFieldGet(l_,this).showAllEditors("highlight",!0,!0);HighlightEditor.startDrawing(this,annotation_editor_layer_classPrivateFieldGet(l_,this),"ltr"===annotation_editor_layer_classPrivateFieldGet(l_,this).direction,e);e.preventDefault()}}function _get_currentEditorType(e){return h_._.get(annotation_editor_layer_classPrivateFieldGet(l_,e).getMode())}function _createNewEditor(e){const t=annotation_editor_layer_classPrivateGetter(d_,this,_get_currentEditorType);return t?new t.prototype.constructor(e):null}function _getCenterPoint(){const{x:e,y:t,width:i,height:a}=this.boundingClientRect,s=Math.max(0,e),r=Math.max(0,t),n=(s+Math.min(window.innerWidth,e+i))/2-e,o=(r+Math.min(window.innerHeight,t+a))/2-t,[l,d]=this.viewport.rotation%180==0?[n,o]:[o,n];return{offsetX:l,offsetY:d}}function _cleanup(){for(const e of annotation_editor_layer_classPrivateFieldGet(Qh,this).values())e.isEmpty()&&e.remove()}!function annotation_editor_layer_defineProperty(e,t,i){return(t=function annotation_editor_layer_toPropertyKey(e){var t=function annotation_editor_layer_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(AnnotationEditorLayer,"_initialized",!1);var c_,h_={_:new Map([EraserEditor,FreeTextEditor,InkEditor,StampEditor,HighlightEditor,SignatureEditor].map(e=>[e._editorType,e]))};function draw_layer_classPrivateFieldInitSpec(e,t,i){draw_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function draw_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function draw_layer_classPrivateFieldGet(e,t){return e.get(draw_layer_assertClassBrand(e,t))}function draw_layer_classPrivateFieldSet(e,t,i){return e.set(draw_layer_assertClassBrand(e,t),i),i}function draw_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function compareTextLayers(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function getTextLayer(e){return e?e.nodeType===Node.ELEMENT_NODE?e.closest(".textLayer"):e.parentElement?.closest(".textLayer")||null:null}function isPointBefore(e,t,i,a){if(e===i)return t<=a;const s=e.compareDocumentPosition(i);return!!(s&Node.DOCUMENT_POSITION_FOLLOWING)||!(s&Node.DOCUMENT_POSITION_PRECEDING)&&null}function normalizeEdgeBoundary(e,t,i){if(e.nodeType!==Node.ELEMENT_NODE||!e.classList.contains("textLayer")||t!==e.childNodes.length)return{container:e,offset:t};let a=e.lastChild;a?.nodeType===Node.ELEMENT_NODE&&a.classList.contains("endOfContent")&&(a=a.previousSibling);return a&&i.contains(a)?a.nodeType===Node.TEXT_NODE?{container:a,offset:a.textContent.length}:{container:a,offset:a.childNodes.length}:null}var __=new WeakMap,u_=new WeakMap,p_=new WeakMap,g_=new WeakMap,m_=new WeakMap,f_=new WeakMap,v_=new WeakMap,P_=new WeakSet;class DrawLayer{constructor({filterFactory:e=null,pageColors:t=null,pageIndex:i,textLayer:a=null}){!function draw_layer_classPrivateMethodInitSpec(e,t){draw_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,P_);draw_layer_classPrivateFieldInitSpec(this,__,null);draw_layer_classPrivateFieldInitSpec(this,u_,new Map);draw_layer_classPrivateFieldInitSpec(this,p_,null);draw_layer_classPrivateFieldInitSpec(this,g_,null);draw_layer_classPrivateFieldInitSpec(this,m_,null);draw_layer_classPrivateFieldInitSpec(this,f_,null);draw_layer_classPrivateFieldInitSpec(this,v_,new Map);this.pageIndex=i;draw_layer_classPrivateFieldSet(g_,this,e);draw_layer_classPrivateFieldSet(m_,this,t);if(a){const e=S_._.get(a);if(e?.selectionDiv){e.selectionDiv.remove();F_._.delete(e.selectionDiv)}S_._.set(a,{drawLayer:this});b_._.add(a);draw_layer_classPrivateFieldSet(p_,this,a);draw_layer_classPrivateFieldSet(f_,this,new MutationObserver(e=>{if(draw_layer_classPrivateFieldGet(__,this)&&draw_layer_classPrivateFieldGet(p_,this)?.isConnected&&_hasSelection.call(DrawLayer))for(const{addedNodes:t}of e)for(const e of t)if(e.nodeType===Node.ELEMENT_NODE&&e.classList.contains("endOfContent")){draw_layer_selectionChange.call(DrawLayer);return}}));draw_layer_classPrivateFieldGet(f_,this).observe(a,{childList:!0});if(null===w_._){w_._=new AbortController;const{signal:e}=w_._;document.addEventListener("selectionchange",draw_layer_selectionChange.bind(DrawLayer),{signal:e});document.addEventListener("pointerdown",()=>{y_._=!0},{signal:e});document.addEventListener("pointerup",()=>{y_._=!1},{signal:e});window.addEventListener("blur",()=>{y_._=!1},{signal:e})}}}setParent(e){if(draw_layer_classPrivateFieldGet(__,this)){if(draw_layer_classPrivateFieldGet(__,this)!==e){if(draw_layer_classPrivateFieldGet(u_,this).size>0)for(const t of draw_layer_classPrivateFieldGet(u_,this).values()){t.remove();e.append(t)}draw_layer_classPrivateFieldSet(__,this,e)}}else{draw_layer_classPrivateFieldSet(__,this,e);draw_layer_classPrivateFieldGet(p_,this)?.isConnected&&_hasSelection.call(DrawLayer)&&draw_layer_selectionChange.call(DrawLayer)}}static get _svgFactory(){return shadow(this,"_svgFactory",new DOMSVGFactory)}draw(e,t=!1,i=!1){const a=ngxNextPageWideId("drawLayer"),s=draw_layer_assertClassBrand(P_,this,_createSVG).call(this),r=DrawLayer._svgFactory.createElement("defs");s.append(r);const n=DrawLayer._svgFactory.createElement("path");r.append(n);const o=`path_${a}`;n.setAttribute("id",o);n.setAttribute("vector-effect","non-scaling-stroke");t&&draw_layer_classPrivateFieldGet(v_,this).set(a,n);const l=i?draw_layer_assertClassBrand(P_,this,_createClipPath).call(this,r,o):null,d=DrawLayer._svgFactory.createElement("use");s.append(d);d.setAttribute("href",`#${o}`);this.updateProperties(s,e);draw_layer_classPrivateFieldGet(u_,this).set(a,s);return{id:a,clipPathId:`url(#${l})`}}drawOutline(e,t){const i=ngxNextPageWideId("drawLayer"),a=draw_layer_assertClassBrand(P_,this,_createSVG).call(this),s=DrawLayer._svgFactory.createElement("defs");a.append(s);const r=DrawLayer._svgFactory.createElement("path");s.append(r);const n=`path_${i}`;r.setAttribute("id",n);r.setAttribute("vector-effect","non-scaling-stroke");let o;if(t){const e=DrawLayer._svgFactory.createElement("mask");s.append(e);o=`mask_${i}`;e.setAttribute("id",o);e.setAttribute("maskUnits","objectBoundingBox");const t=DrawLayer._svgFactory.createElement("rect");e.append(t);t.setAttribute("width","1");t.setAttribute("height","1");t.setAttribute("fill","white");const a=DrawLayer._svgFactory.createElement("use");e.append(a);a.setAttribute("href",`#${n}`);a.setAttribute("stroke","none");a.setAttribute("fill","black");a.setAttribute("fill-rule","nonzero");a.classList.add("mask")}const l=DrawLayer._svgFactory.createElement("use");a.append(l);l.setAttribute("href",`#${n}`);o&&l.setAttribute("mask",`url(#${o})`);const d=l.cloneNode();a.append(d);l.classList.add("mainOutline");d.classList.add("secondaryOutline");this.updateProperties(a,e);draw_layer_classPrivateFieldGet(u_,this).set(i,a);return i}finalizeDraw(e,t){draw_layer_classPrivateFieldGet(v_,this).delete(e);this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;const{root:i,bbox:a,rootClass:s,path:r}=t,n="number"==typeof e?draw_layer_classPrivateFieldGet(u_,this).get(e):e;if(n){i&&draw_layer_assertClassBrand(P_,this,_updateProperties).call(this,n,i);a&&_setBox.call(DrawLayer,n,a);if(s){const{classList:e}=n;for(const[t,i]of Object.entries(s))e.toggle(t,i)}if(r){const e=n.firstElementChild.firstElementChild;draw_layer_assertClassBrand(P_,this,_updateProperties).call(this,e,r)}}}updateParent(e,t){if(t===this)return;const i=draw_layer_classPrivateFieldGet(u_,this).get(e);if(i){draw_layer_classPrivateFieldGet(__,t).append(i);draw_layer_classPrivateFieldGet(u_,this).delete(e);draw_layer_classPrivateFieldGet(u_,t).set(e,i)}}remove(e){draw_layer_classPrivateFieldGet(v_,this).delete(e);if(null!==draw_layer_classPrivateFieldGet(__,this)){draw_layer_classPrivateFieldGet(u_,this).get(e).remove();draw_layer_classPrivateFieldGet(u_,this).delete(e)}}destroy(){draw_layer_classPrivateFieldSet(__,this,null);for(const e of draw_layer_classPrivateFieldGet(u_,this).values())e.remove();draw_layer_classPrivateFieldGet(u_,this).clear();draw_layer_classPrivateFieldGet(v_,this).clear();draw_layer_classPrivateFieldGet(f_,this)?.disconnect();draw_layer_classPrivateFieldSet(f_,this,null);if(draw_layer_classPrivateFieldGet(p_,this)){const e=S_._.get(draw_layer_classPrivateFieldGet(p_,this));if(e?.drawLayer===this){_cleanupTextLayerSelection.call(DrawLayer,draw_layer_classPrivateFieldGet(p_,this));S_._.delete(draw_layer_classPrivateFieldGet(p_,this));b_._.delete(draw_layer_classPrivateFieldGet(p_,this));if(0===b_._.size){w_._?.abort();w_._=null;y_._=!1}}draw_layer_classPrivateFieldSet(p_,this,null)}}}c_=DrawLayer;function _cleanupTextLayerSelection(e){const t=draw_layer_assertClassBrand(c_,this,S_)._.get(e);if(t?.selectionDiv){t.selectionDiv.remove();draw_layer_assertClassBrand(c_,this,F_)._.delete(t.selectionDiv);t.selectionDiv=null;t.path=null}}function _hasSelection(){const e=document.getSelection();return!!e&&!e.isCollapsed}function _getOrderedTextLayers(){return draw_layer_assertClassBrand(c_,this,b_)._.keys().filter(e=>e.isConnected).toArray().sort(compareTextLayers)}function draw_layer_selectionChange(){const e=document.getSelection();if(!e||e.isCollapsed){for(const e of draw_layer_assertClassBrand(c_,this,F_)._)e.remove();draw_layer_assertClassBrand(c_,this,F_)._.clear();return}const t=new WeakMap,i=draw_layer_assertClassBrand(c_,this,_getOrderedTextLayers).call(this),a=[];for(let t=0,s=e.rangeCount;t<s;t++){const s=e.getRangeAt(t);if(s.collapsed)continue;let{startContainer:r,startOffset:n,endContainer:o,endOffset:l}=s,d=getTextLayer(r),c=getTextLayer(o);const h=null===d,_=null===c;if(draw_layer_assertClassBrand(c_,this,y_)._&&h!==_)return;if(1===e.rangeCount){const{anchorNode:t,anchorOffset:i,focusNode:a,focusOffset:s}=e,h=getTextLayer(t),_=getTextLayer(a),u=isPointBefore(t,i,a,s);if(h&&_&&null!==u)if(u){r=t;n=i;d=h;o=a;l=s;c=_}else{r=a;n=s;d=_;o=t;l=i;c=h}}const u=i.filter(e=>s.intersectsNode(e));if(0===u.length)continue;let p=!1;if(!d){d=u[0];r=d;n=0;p=!0}if(!c){c=u.at(-1);o=c;l=c.childNodes.length;p=!0}if(o.nodeType===Node.ELEMENT_NODE)if(o.classList.contains("endOfContent")){const e=o.previousSibling;if(!e)continue;o=e;l=e.nodeType===Node.TEXT_NODE?e.textContent.length:e.childNodes.length}else if(o.classList.contains("textLayer")&&o.childNodes.length===l){const e=normalizeEdgeBoundary(o,l,c);if(!e)continue;o=e.container;l=e.offset}if(r.nodeType===Node.ELEMENT_NODE){const e=normalizeEdgeBoundary(r,n,d);if(!e)continue;r=e.container;n=e.offset}if(d!==c||p||!u.includes(d))for(const e of u){const t=e.firstChild;if(!t)continue;const i=document.createRange();e===d?i.setStart(r,n):i.setStartBefore(t);if(e===c)i.setEnd(o,l);else{const t=e.lastChild;if(!t)continue;if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains("endOfContent")){const e=t.previousSibling;if(!e)continue;i.setEndAfter(e)}else i.setEndAfter(t)}i.collapsed||a.push([i,e])}else a.push([s,d])}const s=new Set(a.map(e=>e[1]));for(const e of draw_layer_assertClassBrand(c_,this,b_)._)s.has(e)||draw_layer_assertClassBrand(c_,this,_cleanupTextLayerSelection).call(this,e);for(const[e,i]of a){const a=S_._.get(i);if(!a)continue;let s=t.get(i);if(!s){const e=i.getBoundingClientRect();s=(t,i,a,s)=>({x:(t-e.x)/e.width,y:(i-e.y)/e.height,width:a/e.width,height:s/e.height});t.set(i,s)}const r=[];for(let{x:t,y:i,width:a,height:n}of e.getClientRects())if(0!==a&&0!==n){({x:t,y:i,width:a,height:n}=s(t,i,a,n));1===a&&1===n||r.push(`M${t} ${i} h${a} v${n} h-${a} Z`)}if(0===r.length)continue;const n=a.drawLayer;let o=a.selectionDiv,l=a.path;if(!o){const e=`clip_selection_${ngxNextPageWideId("drawLayerSelection")}`;o=document.createElement("div");o.className="selection";o.style.clipPath=`url(#${e})`;const t=draw_layer_classPrivateFieldGet(g_,n)?.createSelectionStyle(draw_layer_classPrivateFieldGet(m_,n));if(t)for(const[e,i]of Object.entries(t))o.style.setProperty(e,i);const i=c_._svgFactory.create(1,1,!0);i.setAttribute("aria-hidden","true");i.setAttribute("width","100%");i.setAttribute("height","100%");const s=c_._svgFactory.createElement("clipPath");s.setAttribute("id",e);s.setAttribute("clipPathUnits","objectBoundingBox");l=c_._svgFactory.createElement("path");s.append(l);i.append(s);o.append(i);a.path=l;a.selectionDiv=o}if(draw_layer_classPrivateFieldGet(__,n)&&o.parentNode!==draw_layer_classPrivateFieldGet(__,n)){draw_layer_classPrivateFieldGet(__,n).append(o);draw_layer_assertClassBrand(c_,this,F_)._.add(o)}l.setAttribute("d",r.join(" "))}}function _setBox(e,[t,i,a,s]){const{style:r}=e;r.top=100*i+"%";r.left=100*t+"%";r.width=100*a+"%";r.height=100*s+"%"}function _createSVG(){const e=c_._svgFactory.create(1,1,!0);draw_layer_classPrivateFieldGet(__,this).append(e);e.setAttribute("aria-hidden","true");return e}function _createClipPath(e,t){const i=c_._svgFactory.createElement("clipPath");e.append(i);const a=`clip_${t}`;i.setAttribute("id",a);i.setAttribute("clipPathUnits","objectBoundingBox");const s=c_._svgFactory.createElement("use");i.append(s);s.setAttribute("href",`#${t}`);s.classList.add("clip");return a}function _updateProperties(e,t){for(const[i,a]of Object.entries(t))null===a?e.removeAttribute(i):e.setAttribute(i,a)}var w_={_:null},F_={_:new Set},y_={_:!1},b_={_:new Set},S_={_:new WeakMap};function text_layer_images_classPrivateFieldInitSpec(e,t,i){text_layer_images_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_images_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_images_classPrivateFieldGet(e,t){return e.get(text_layer_images_assertClassBrand(e,t))}function text_layer_images_classPrivateFieldSet(e,t,i){return e.set(text_layer_images_assertClassBrand(e,t),i),i}function text_layer_images_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function percentage(e){return`${(100*e).toFixed(2)}%`}var C_=new WeakMap,x_=new WeakMap,k_=new WeakMap,E_=new WeakMap,A_=new WeakMap,G_=new WeakMap,B_=new WeakSet;class TextLayerImages{constructor(e,t,i,a){!function text_layer_images_classPrivateMethodInitSpec(e,t){text_layer_images_checkPrivateRedeclaration(e,t),t.add(e)}(this,B_);text_layer_images_classPrivateFieldInitSpec(this,C_,[]);text_layer_images_classPrivateFieldInitSpec(this,x_,new Map);text_layer_images_classPrivateFieldInitSpec(this,k_,null);text_layer_images_classPrivateFieldInitSpec(this,E_,0);text_layer_images_classPrivateFieldInitSpec(this,A_,0);text_layer_images_classPrivateFieldInitSpec(this,G_,0);text_layer_images_classPrivateFieldSet(E_,this,e);text_layer_images_classPrivateFieldSet(C_,this,t);text_layer_images_classPrivateFieldSet(A_,this,i.rawDims.pageWidth);text_layer_images_classPrivateFieldSet(G_,this,i.rawDims.pageHeight);text_layer_images_classPrivateFieldSet(k_,this,a)}render(){const e=document.createElement("div");e.className="textLayerImages";for(let t=0;t<text_layer_images_classPrivateFieldGet(C_,this).length;t+=6){const i=text_layer_images_assertClassBrand(B_,this,_createImagePlaceholder).call(this,text_layer_images_classPrivateFieldGet(C_,this).subarray(t,t+6));i&&e.append(i)}e.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const t=e.target,i=text_layer_images_classPrivateFieldGet(x_,this).get(t);if(!i)return;const a=M_._?.deref();if(a===t)return;if(a){a.width=0;a.height=0}M_._=new WeakRef(t);const{inverseTransform:s,x1:r,y1:n,width:o,height:l}=i,d=text_layer_images_classPrivateFieldGet(k_,this).call(this),c=Math.ceil(r*d.width),h=Math.ceil(n*d.height),_=Math.floor((r+o/text_layer_images_classPrivateFieldGet(A_,this))*d.width),u=Math.floor((n+l/text_layer_images_classPrivateFieldGet(G_,this))*d.height);t.width=_-c;t.height=u-h;const p=t.getContext("2d");p.setTransform(...s);p.translate(-c,-h);p.drawImage(d,0,0)});return e}}function _createImagePlaceholder([e,t,i,a,s,r]){const n=Math.hypot((s-e)*text_layer_images_classPrivateFieldGet(A_,this),(r-t)*text_layer_images_classPrivateFieldGet(G_,this)),o=Math.hypot((i-e)*text_layer_images_classPrivateFieldGet(A_,this),(a-t)*text_layer_images_classPrivateFieldGet(G_,this));if(n<text_layer_images_classPrivateFieldGet(E_,this)||o<text_layer_images_classPrivateFieldGet(E_,this))return null;const l=[(s-e)*text_layer_images_classPrivateFieldGet(A_,this)/n,(r-t)*text_layer_images_classPrivateFieldGet(G_,this)/n,(i-e)*text_layer_images_classPrivateFieldGet(A_,this)/o,(a-t)*text_layer_images_classPrivateFieldGet(G_,this)/o,0,0],d=Util.inverseTransform(l),c=document.createElement("canvas");c.className="textLayerImagePlaceholder";c.width=0;c.height=0;Object.assign(c.style,{opacity:0,position:"absolute",left:percentage(e),top:percentage(t),width:percentage(n/text_layer_images_classPrivateFieldGet(A_,this)),height:percentage(o/text_layer_images_classPrivateFieldGet(G_,this)),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`});text_layer_images_classPrivateFieldGet(x_,this).set(c,{inverseTransform:d,width:n,height:o,x1:e,y1:t});return c}var M_={_:null};globalThis._pdfjsTestingUtils={HighlightOutliner};globalThis.pdfjsLib={AbortException,AnnotationEditorLayer,AnnotationEditorParamsType:v,AnnotationEditorType:f,AnnotationEditorUIManager,AnnotationLayer,AnnotationMode:p,AnnotationType:k,applyOpacity,build:Qo,ColorPicker,createValidAbsoluteUrl,CSSConstants,DOMSVGFactory,DrawLayer,FeatureTest,fetchData,findContrastColor,getDocument,getFilenameFromUrl:function getFilenameFromUrl(e){[e]=e.split(/[#?]/,1);return stripPath(e)},getPdfFilenameFromUrl,getRGB,getRGBA,getUuid,GlobalWorkerOptions,ImageKind:x,InvalidPDFException,isDataScheme,isPdfFile,isValidExplicitDest:sa,makeArr,makeMap,makeObj,makeSet,MathClamp,noContextMenu,normalizeUnicode,OPS:T,OutputScale,PasswordException,PasswordResponses:W,PDFDataRangeTransport,PDFDateString,PDFWorker,PermissionFlag:P,PixelsPerInch,RenderingCancelledException,renderRichText,ResponseException,setLayerDimensions,shadow,SignatureExtractor,stopEvent,SupportedImageMimeTypes:Y,TextLayer,TextLayerImages,TouchManager,updateUrlHash,Util,VerbosityLevel:I,version:Zo,XfaLayer};function ui_utils_classPrivateFieldInitSpec(e,t,i){(function ui_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function ui_utils_classPrivateFieldGet(e,t){return e.get(ui_utils_assertClassBrand(e,t))}function ui_utils_classPrivateFieldSet(e,t,i){return e.set(ui_utils_assertClassBrand(e,t),i),i}function ui_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const I_=0,T_=1,D_=2,L_=3,R_=-1,O_=0,N_=1,W_=2,j_=3,V_=4,U_=0,z_=1,H_=2,$_={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},X_={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2},K_=0,q_=1,Y_=-3,Z_=/\bprint\s*\(/;let Q_=null;function cancelPendingHiddenScroll(){if(Q_){for(const e of Q_.observers)e.disconnect();clearInterval(Q_.pollInterval);clearTimeout(Q_.watchdog);Q_=null}}function scrollIntoView(e,t,i=!1,a=!1,s=null){if(e.classList.contains("stf__item")||e.parentElement?.classList.contains("stf__item")||e.parentElement?.parentElement?.classList.contains("stf__item"))return;if(a){setTimeout(()=>{let i=e.parentElement;for(;i&&i!==document.body&&i!==document.documentElement;){const a=getComputedStyle(i).overflowY;if(("auto"===a||"scroll"===a)&&i.scrollHeight>i.clientHeight){const a=e.getBoundingClientRect(),s=i.getBoundingClientRect();let r=i.scrollTop+(a.top-s.top),n=i.scrollLeft+(a.left-s.left);if(t){void 0!==t.top&&(r+=t.top);void 0!==t.left&&(n+=t.left)}i.scrollTop=r;void 0!==t?.left&&(i.scrollLeft=n);return}i=i.parentElement}const a=e.getBoundingClientRect();let s=window.scrollY+a.top;void 0!==t?.top&&(s+=t.top);window.scrollTo(window.scrollX,s)},0);return}let r=e.offsetParent;if(!r){cancelPendingHiddenScroll();if(!e.isConnected){ngx_console_NgxConsole.warn("offsetParent is not set -- cannot scroll viewer (element is not attached)");return}ngx_console_NgxConsole.warn("offsetParent is not set -- scroll deferred until viewer becomes visible");let s=t,r=i,n=a;const tryReplay=()=>{if(!e.isConnected){cancelPendingHiddenScroll();return}if(!e.offsetParent)return;const t=s,i=r,a=n;s=null;r=null;n=null;cancelPendingHiddenScroll();requestAnimationFrame(()=>{requestAnimationFrame(()=>{scrollIntoView(e,t,i,a)})})},o=[];if("undefined"!=typeof ResizeObserver){const t=new ResizeObserver(tryReplay);t.observe(e);o.push(t)}if("undefined"!=typeof IntersectionObserver){const t=new IntersectionObserver(tryReplay,{rootMargin:"99999px"});t.observe(e);o.push(t)}const l=setInterval(tryReplay,250),d=setTimeout(()=>{s=null;r=null;n=null;cancelPendingHiddenScroll()},1e4);Q_={observers:o,pollInterval:l,watchdog:d};return}let n=e.offsetTop+e.clientTop,o=e.offsetLeft+e.clientLeft;for(;r.clientHeight===r.scrollHeight&&r.clientWidth===r.scrollWidth;){n+=r.offsetTop;o+=r.offsetLeft;r=r.offsetParent;if(!r)return}if("viewer"===r.id&&r.offsetParent){const e=r.offsetParent,t=getComputedStyle(e);if([t.overflowX,t.overflowY].some(e=>"auto"===e||"scroll"===e||"hidden"===e)){n+=r.offsetTop;o+=r.offsetLeft;r=e}}if(t){void 0!==t.top&&(n+=t.top);if(void 0!==t.left){o+=t.left;s||(r.scrollLeft=o)}}else if(function isDivInViewport(e,t){const i=e.getBoundingClientRect(),a=i.top>=0&&i.left>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&i.right<=(window.innerWidth||document.documentElement.clientWidth);if(!a||!t)return a;const s=t.getBoundingClientRect(),r=s.top+t.clientTop,n=s.left+t.clientLeft;return i.top>=r&&i.left>=n&&i.bottom<=r+t.clientHeight&&i.right<=n+t.clientWidth}(e,r))return;s?s(r,void 0!==t?.left?o:r.scrollLeft,n):r.scrollTop=n}function watchScroll(e,t,i=void 0){function onRAF(){s=null;const i=e.scrollLeft,r=a.lastX;i!==r&&(a.right=i>r);a.lastX=i;const n=e.scrollTop,o=a.lastY;n!==o&&(a.down=n>o);a.lastY=n;t(a)}const a={right:!0,down:!0,lastX:e.scrollLeft,lastY:e.scrollTop};let s=null;e.addEventListener("scroll",()=>{s??=window.requestAnimationFrame(onRAF)},{useCapture:!0,signal:i});i?.addEventListener("abort",()=>window.cancelAnimationFrame(s),{once:!0});return a}function parseQueryString(e){const t=new Map;for(const[i,a]of new URLSearchParams(e))t.set(i.toLowerCase(),a);return t}const J_=/[\x00-\x1F]/g;function removeNullCharacters(e,t=!1){return J_.test(e)?t?e.replaceAll(J_,e=>"\0"===e?"":" "):e.replaceAll("\0",""):e}function binarySearchFirstItem(e,t,i=0){let a=i,s=e.length-1;if(s<0||!t(e[s]))return e.length;if(t(e[a]))return a;for(;a<s;){const i=a+s>>1;t(e[i])?s=i:a=i+1}return a}function approximateFraction(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 a=0,s=1,r=1,n=1;for(;;){const e=a+r,t=s+n;if(t>8)break;if(i<=e/t){r=e;n=t}else{a=e;s=t}}return i-a/s<r/n-i?i===e?[a,s]:[s,a]:i===e?[r,n]:[n,r]}function floorToDivide(e,t){return e-e%t}function visibleSort(e,t){const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id}function getVisibleElements({scrollEl:e,views:t,sortByVisibility:i=!1,horizontal:a=!1,rtl:s=!1}){const r=e.scrollTop,n=r+e.clientHeight,o=e.scrollLeft,l=o+e.clientWidth;const d=[],c=new Set,h=t.length;let _=binarySearchFirstItem(t,a?function isElementNextAfterViewHorizontally(e){const t=e.div,i=t.offsetLeft+t.clientLeft,a=i+t.clientWidth;return s?i<l:a>o}:function isElementBottomAfterViewTop(e){const t=e.div;return t.offsetTop+t.clientTop+t.clientHeight>r});_>0&&_<h&&!a&&(_=function backtrackBeforeAllVisibleElements(e,t,i){if(e<2)return e;let a=t[e].div,s=a.offsetTop+a.clientTop;if(s>=i){a=t[e-1].div;s=a.offsetTop+a.clientTop}for(let i=e-2;i>=0;--i){a=t[i].div;if(a.offsetTop+a.clientTop+a.clientHeight<=s)break;e=i}return e}(_,t,r));let u=a?l:-1;for(let e=_;e<h;e++){const i=t[e],s=i.div,h=s.offsetLeft+s.clientLeft,_=s.offsetTop+s.clientTop,p=s.clientWidth,g=s.clientHeight,m=h+p,f=_+g;if(-1===u)f>=n&&(u=f);else if((a?h:_)>u)break;if(f<=r||_>=n||m<=o||h>=l)continue;const v=Math.max(0,r-_),P=Math.max(0,o-h),w=v+Math.max(0,f-n),F=P+Math.max(0,m-l),y=(p-F)/p,b=(g-w)/g*y*100|0;d.push({id:i.id,x:h,y:_,visibleArea:100===b?null:{minX:P,minY:v,maxX:Math.min(m,l)-h,maxY:Math.min(f,n)-_},view:i,percent:b,widthPercent:100*y|0,hiddenHeight:w,hiddenWidth:F});c.add(i.id)}const p=d[0],g=d.at(-1);i&&d.sort(visibleSort);return{first:p,last:g,views:d,ids:c}}function normalizeWheelEventDirection(e){let t=Math.hypot(e.deltaX,e.deltaY);const i=Math.atan2(e.deltaY,e.deltaX);-.25*Math.PI<i&&i<.75*Math.PI&&(t=-t);return t}function isValidRotation(e){return Number.isInteger(e)&&e%90==0}function isValidScrollMode(e){return Number.isInteger(e)&&Object.values($_).includes(e)&&e!==$_.UNKNOWN}function isValidSpreadMode(e){return Number.isInteger(e)&&Object.values(X_).includes(e)&&e!==X_.UNKNOWN}function isPortraitOrientation(e){return e.width<=e.height}const eu=new Promise(function(e){window.requestAnimationFrame(e)});function getDocStyle(e){return(e?.closest(".html")??document.documentElement).style}var tu=new WeakMap,iu=new WeakMap,au=new WeakMap,su=new WeakMap,ru=new WeakMap;class ProgressBar{constructor(e){ui_utils_classPrivateFieldInitSpec(this,tu,null);ui_utils_classPrivateFieldInitSpec(this,iu,null);ui_utils_classPrivateFieldInitSpec(this,au,0);ui_utils_classPrivateFieldInitSpec(this,su,null);ui_utils_classPrivateFieldInitSpec(this,ru,!0);ui_utils_classPrivateFieldSet(tu,this,e.classList);ui_utils_classPrivateFieldSet(su,this,e.style)}get percent(){return ui_utils_classPrivateFieldGet(au,this)}set percent(e){ui_utils_classPrivateFieldSet(au,this,e);if(isNaN(e))ui_utils_classPrivateFieldGet(tu,this).add("indeterminate");else{ui_utils_classPrivateFieldGet(tu,this).remove("indeterminate");ui_utils_classPrivateFieldGet(su,this).setProperty("--progressBar-percent",`${ui_utils_classPrivateFieldGet(au,this)}%`)}}setWidth(e){if(!e)return;const t=e.parentNode.offsetWidth-e.offsetWidth;t>0&&ui_utils_classPrivateFieldGet(su,this).setProperty("--progressBar-end-offset",`${t}px`)}setDisableAutoFetch(e=5e3){if(100!==ui_utils_classPrivateFieldGet(au,this)&&!isNaN(ui_utils_classPrivateFieldGet(au,this))){ui_utils_classPrivateFieldGet(iu,this)&&clearTimeout(ui_utils_classPrivateFieldGet(iu,this));this.show();ui_utils_classPrivateFieldSet(iu,this,setTimeout(()=>{ui_utils_classPrivateFieldSet(iu,this,null);this.hide()},e))}}hide(){if(ui_utils_classPrivateFieldGet(ru,this)){ui_utils_classPrivateFieldSet(ru,this,!1);ui_utils_classPrivateFieldGet(tu,this).add("hidden")}}show(){if(!ui_utils_classPrivateFieldGet(ru,this)){ui_utils_classPrivateFieldSet(ru,this,!0);ui_utils_classPrivateFieldGet(tu,this).remove("hidden")}}}function getActiveOrFocusedElement(){let e=document,t=e.activeElement||e.querySelector(":focus");for(;t?.shadowRoot;){e=t.shadowRoot;t=e.activeElement||e.querySelector(":focus")}return t}function apiPageLayoutToViewerModes(e){let t=$_.VERTICAL,i=X_.NONE;switch(e){case"SinglePage":t=$_.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=$_.PAGE;case"TwoColumnLeft":i=X_.ODD;break;case"TwoPageRight":t=$_.PAGE;case"TwoColumnRight":i=X_.EVEN}return{scrollMode:t,spreadMode:i}}function toggleCheckedBtn(e,t,i=null){e.classList.toggle("toggled",t);e.setAttribute(e.hasAttribute("aria-pressed")?"aria-pressed":"aria-checked",t);i?.classList.toggle("hidden",!t)}function toggleSelectedBtn(e,t,i=null){e.classList.toggle("selected",t);e.setAttribute(e.hasAttribute("aria-pressed")?"aria-pressed":"aria-selected",t);i?.classList.toggle("hidden",!t)}function toggleExpandedBtn(e,t,i=null){e?.classList.toggle("toggled",t);e?.setAttribute("aria-expanded",t);i?.classList.toggle("hidden",!t);if(i&&!i.classList.contains("hidden")){const t=e.getBoundingClientRect(),a=e.closest("#toolbarViewer");if(a){const e=a.getBoundingClientRect().right-t.right;i.style.removeProperty("inset-inline-end");i.style.setProperty("inset-inline-end",e+"px")}}}const nu=function(){const e=document.createElement("div");e.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)";return"calc(1320px)"===e.style.width?Math.fround:e=>e}();const ou="58912017-f3ad-4506-bdd0-58916207bc49",lu=Object.freeze({internal:ou});function pdf_link_service_defineProperty(e,t,i){return(t=function pdf_link_service_toPropertyKey(e){var t=function pdf_link_service_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const du={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class PDFLinkService{constructor({eventBus:e,externalLinkTarget:t=null,externalLinkRel:i=null,ignoreDestinationZoom:a=!1}={}){pdf_link_service_defineProperty(this,"externalLinkEnabled",!0);this.eventBus=e;this.externalLinkTarget=t;this.externalLinkRel=i;this._ignoreDestinationZoom=a;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?.pagesMapper.pagesNumber||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,a;if("string"==typeof e){t=e;i=await this.pdfDocument.getDestination(e)}else{t=null;i=await e}if(!Array.isArray(i)){console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${e}".`);return}const[s]=i;if(s&&"object"==typeof s){a=this.pdfDocument.cachedPageNumber(s);if(!a)try{a=await this.pdfDocument.getPageIndex(s)+1}catch{ngx_console_NgxConsole.error(`goToDestination: "${s}" is not a valid page reference, for dest="${e}".`);return}}else Number.isInteger(s)&&(a=s+1);if(!a||a<1||a>this.pagesCount){ngx_console_NgxConsole.error(`goToDestination: "${a}" is not a valid page number, for dest="${e}".`);return}if(this.pdfHistory){this.pdfHistory.pushCurrentPosition();this.pdfHistory.push({namedDest:t,explicitDest:i,pageNumber:a})}if("book"===this.pdfViewer.pageViewMode&&this.pdfViewer.pageFlip){this.pdfViewer.ensureAdjacentPagesAreLoaded();this.pdfViewer.pageFlip.flip(a-1)}else this.pdfViewer.scrollPageIntoView({pageNumber:a,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom});const r=new AbortController;this.eventBus.on("textlayerrendered",e=>{if(e.pageNumber===a){e.source.textLayer.div.focus();r.abort()}},{signal:r.signal,...lu})}goToPage(e){if(!this.pdfDocument)return;const t="string"==typeof e&&this.pdfViewer.pageLabelToPageNumber(e)||0|e;if(!(Number.isInteger(t)&&t>0&&t<=this.pagesCount)){ngx_console_NgxConsole.error(`PDFLinkService.goToPage: "${e}" is not a valid page.`);return}if(this.pdfHistory){this.pdfHistory.pushCurrentPosition();this.pdfHistory.pushPage(t)}const i=this.pdfViewer.currentPageNumber;this.pdfViewer.scrollPageIntoView({pageNumber:t});if("book"===this.pdfViewer.pageViewMode&&this.pdfViewer.pageFlip&&i!==t){Math.abs(i-t)<=2?this.pdfViewer.pageFlip.flip(t-1):this.pdfViewer.pageFlip.turnToPage(t-1);this.pdfViewer.ensureAdjacentPagesAreLoaded()}}goToXY(e,t,i,a={}){this.pdfViewer.scrollPageIntoView({pageNumber:e,destArray:[null,{name:"XYZ"},t,i],ignoreDestinationZoom:!0,...a})}async getAttachmentContent(e){try{return await(this.pdfDocument?.getAttachmentContent(e))}catch(e){e instanceof PasswordException||console.warn(`Unable to load attachment content: ${e}`)}return null}addLinkAttributes(e,t,i=!1){if(!t||"string"!=typeof t)throw new Error('A valid "url" parameter must provided.');const a=i?du.BLANK:this.externalLinkTarget,s=this.externalLinkRel;let r=t;const n=URL.parse(t);if(n?.username||n?.password){n.username=n.password="";r=n.href}if(this.externalLinkEnabled){e.href=t;e.title=r}else{e.href="";e.title=`Disabled: ${r}`;e.onclick=()=>!1}let o="";switch(a){case du.NONE:break;case du.SELF:o="_self";break;case du.BLANK:o="_blank";break;case du.PARENT:o="_parent";break;case du.TOP:o="_top"}e.target=o;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 a=parseQueryString(e);if(a.has("search")){const e=a.get("search").replaceAll('"',""),t="true"===a.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:t?e:e.match(/\S+/g)})}a.has("page")&&(t=0|a.get("page")||1);if(a.has("zoom")){const e=a.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?ngx_console_NgxConsole.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:t},0|e[1],0|e[2],0|e[3],0|e[4]]:ngx_console_NgxConsole.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]}i?this.pdfViewer.scrollPageIntoView({pageNumber:t||this.page,destArray:i,allowNegativeOffset:!0}):t&&(this.page=t);a.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:a.get("pagemode")});a.has("nameddest")&&this.goToDestination(a.get("nameddest"));return}i=unescape(e);try{i=JSON.parse(i);Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||sa(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;if(t===this.pdfDocument){i.setOCGState(e);this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i)}}}class SimpleLinkService extends PDFLinkService{setDocument(e,t=null){}}function event_utils_classPrivateFieldInitSpec(e,t,i){(function event_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function event_utils_classPrivateFieldGet(e,t){return e.get(event_utils_assertClassBrand(e,t))}function event_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const cu="event",hu="timeout";async function waitOnEventOrTimeout({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:a,resolve:s}=Promise.withResolvers(),r=new AbortController;function handler(e){r.abort();clearTimeout(l);s(e)}const n=e instanceof EventBus?"on":"addEventListener",o=e instanceof EventBus?{signal:r.signal,...lu}:{signal:r.signal};e[n](t,handler.bind(null,cu),o);const l=setTimeout(handler.bind(null,hu),i);return a}var _u=new WeakMap;class EventBus{constructor(){event_utils_classPrivateFieldInitSpec(this,_u,new Map);Object.seal(this)}_on(e,t,i=null){this.on(e,t,{...i||{},internal:ou})}_off(e,t,i=null){this.off(e,t,i)}on(e,t,i=null){let a=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted){console.error("Cannot use an `aborted` signal.");return}const onAbort=()=>this.off(e,t);a=()=>s.removeEventListener("abort",onAbort);s.addEventListener("abort",onAbort)}event_utils_classPrivateFieldGet(_u,this).getOrInsertComputed(e,makeSet).add({listener:t,internal:i?.internal===ou,once:!0===i?.once,rmAbort:a})}off(e,t,i=null){const a=event_utils_classPrivateFieldGet(_u,this).get(e),s=a?.keys().find(e=>e.listener===t);if(s){s.rmAbort?.();a.delete(s)}}dispatch(e,t){const i=event_utils_classPrivateFieldGet(_u,this).get(e);if(!i?.size)return;let a;for(const{listener:s,internal:r,once:n}of new Set(i)){n&&this.off(e,s);r?s(t):(a??=[]).push(s)}if(a)for(const e of a)e(t)}destroy(){let e;for(e in event_utils_classPrivateFieldGet(_u,this))event_utils_classPrivateFieldGet(_u,this)[e].length=0}}function external_services_defineProperty(e,t,i){return(t=function external_services_toPropertyKey(e){var t=function external_services_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class BaseExternalServices{constructor(){external_services_defineProperty(this,"printToPDF",null)}updateFindControlState(e){}updateFindMatchesCount(e){}initPassiveLoading(){}reportTelemetry(e){}reportText(e){}async createL10n(){throw new Error("Not implemented: createL10n")}createScripting(){throw new Error("Not implemented: createScripting")}createSignatureStorage(){throw new Error("Not implemented: createSignatureStorage")}createSignatureVerifier(){return null}updateEditorStates(e){throw new Error("Not implemented: updateEditorStates")}dispatchGlobalEvent(e){}}function preferences_classPrivateFieldInitSpec(e,t,i){(function preferences_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function preferences_classPrivateFieldGet(e,t){return e.get(preferences_assertClassBrand(e,t))}function preferences_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var uu=new WeakMap,pu=new WeakMap;class BasePreferences{constructor(){preferences_classPrivateFieldInitSpec(this,uu,Object.freeze(AppOptions.getAll(mo,!0)));preferences_classPrivateFieldInitSpec(this,pu,null);!function preferences_classPrivateFieldSet(e,t,i){return e.set(preferences_assertClassBrand(e,t),i),i}(pu,this,this._readFromStorage(preferences_classPrivateFieldGet(uu,this)).then(({browserPrefs:e,prefs:t})=>{AppOptions._checkDisablePreferences()||AppOptions.setAll({...e,...t},!0)}))}async _writeToStorage(e){throw new Error("Not implemented: _writeToStorage")}async _readFromStorage(e){throw new Error("Not implemented: _readFromStorage")}async reset(){await preferences_classPrivateFieldGet(pu,this);AppOptions.setAll(preferences_classPrivateFieldGet(uu,this),!0);await this._writeToStorage(preferences_classPrivateFieldGet(uu,this))}async set(e,t){await preferences_classPrivateFieldGet(pu,this);AppOptions.setAll({[e]:t},!0);await this._writeToStorage(AppOptions.getAll(mo))}async get(e){await preferences_classPrivateFieldGet(pu,this);return AppOptions.get(e)}get defaults(){return preferences_classPrivateFieldGet(uu,this)}get initializedPromise(){return preferences_classPrivateFieldGet(pu,this)}}class FluentType{constructor(e){this.value=e}valueOf(){return this.value}}class FluentNone extends FluentType{constructor(e="???"){super(e)}toString(e){return`{${this.value}}`}}class FluentNumber extends FluentType{constructor(e,t={}){super(e);this.opts=t}toString(e){if(e)try{return e.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(t){e.reportError(t)}return this.value.toString(10)}}class FluentDateTime extends FluentType{static supportsValue(e){if("number"==typeof e)return!0;if(e instanceof Date)return!0;if(e instanceof FluentType)return FluentDateTime.supportsValue(e.valueOf());if("Temporal"in globalThis){const t=globalThis.Temporal;if(e instanceof t.Instant||e instanceof t.PlainDateTime||e instanceof t.PlainDate||e instanceof t.PlainMonthDay||e instanceof t.PlainTime||e instanceof t.PlainYearMonth)return!0}return!1}constructor(e,t={}){if(e instanceof FluentDateTime){t={...e.opts,...t};e=e.value}else e instanceof FluentType&&(e=e.valueOf());"object"==typeof e&&"calendarId"in e&&void 0===t.calendar&&(t={...t,calendar:e.calendarId});super(e);this.opts=t}[Symbol.toPrimitive](e){return"string"===e?this.toString():this.toNumber()}toNumber(){const e=this.value;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("epochMilliseconds"in e)return e.epochMilliseconds;if("toZonedDateTime"in e)return e.toZonedDateTime("UTC").epochMilliseconds;throw new TypeError("Unwrapping a non-number value as a number")}toString(e){if(e)try{return e.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(t){e.reportError(t)}return"number"==typeof this.value||this.value instanceof Date?new Date(this.value).toISOString():this.value.toString()}}function match(e,t,i){if(i===t)return!0;if(i instanceof FluentNumber&&t instanceof FluentNumber&&i.value===t.value)return!0;if(t instanceof FluentNumber&&"string"==typeof i){if(i===e.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value))return!0}return!1}function getDefault(e,t,i){if(t[i])return resolvePattern(e,t[i].value);e.reportError(new RangeError("No default"));return new FluentNone}function getArguments(e,t){const i=[],a=Object.create(null);for(const s of t)"narg"===s.type?a[s.name]=resolveExpression(e,s.value):i.push(resolveExpression(e,s));return{positional:i,named:a}}function resolveExpression(e,t){switch(t.type){case"str":return t.value;case"num":return new FluentNumber(t.value,{minimumFractionDigits:t.precision});case"var":return function resolveVariableReference(e,{name:t}){let i;if(e.params){if(!Object.prototype.hasOwnProperty.call(e.params,t))return new FluentNone(`$${t}`);i=e.params[t]}else{if(!e.args||!Object.prototype.hasOwnProperty.call(e.args,t)){e.reportError(new ReferenceError(`Unknown variable: $${t}`));return new FluentNone(`$${t}`)}i=e.args[t]}if(i instanceof FluentType)return i;switch(typeof i){case"string":return i;case"number":return new FluentNumber(i);case"object":if(FluentDateTime.supportsValue(i))return new FluentDateTime(i);default:e.reportError(new TypeError(`Variable type not supported: $${t}, ${typeof i}`));return new FluentNone(`$${t}`)}}(e,t);case"mesg":return function resolveMessageReference(e,{name:t,attr:i}){const a=e.bundle._messages.get(t);if(!a){e.reportError(new ReferenceError(`Unknown message: ${t}`));return new FluentNone(t)}if(i){const s=a.attributes[i];if(s)return resolvePattern(e,s);e.reportError(new ReferenceError(`Unknown attribute: ${i}`));return new FluentNone(`${t}.${i}`)}if(a.value)return resolvePattern(e,a.value);e.reportError(new ReferenceError(`No value: ${t}`));return new FluentNone(t)}(e,t);case"term":return function resolveTermReference(e,{name:t,attr:i,args:a}){const s=`-${t}`,r=e.bundle._terms.get(s);if(!r){e.reportError(new ReferenceError(`Unknown term: ${s}`));return new FluentNone(s)}if(i){const t=r.attributes[i];if(t){e.params=getArguments(e,a).named;const i=resolvePattern(e,t);e.params=null;return i}e.reportError(new ReferenceError(`Unknown attribute: ${i}`));return new FluentNone(`${s}.${i}`)}e.params=getArguments(e,a).named;const n=resolvePattern(e,r.value);e.params=null;return n}(e,t);case"func":return function resolveFunctionReference(e,{name:t,args:i}){let a=e.bundle._functions[t];if(!a){e.reportError(new ReferenceError(`Unknown function: ${t}()`));return new FluentNone(`${t}()`)}if("function"!=typeof a){e.reportError(new TypeError(`Function ${t}() is not callable`));return new FluentNone(`${t}()`)}try{let t=getArguments(e,i);return a(t.positional,t.named)}catch(i){e.reportError(i);return new FluentNone(`${t}()`)}}(e,t);case"select":return function resolveSelectExpression(e,{selector:t,variants:i,star:a}){let s=resolveExpression(e,t);if(s instanceof FluentNone)return getDefault(e,i,a);for(const t of i){if(match(e,s,resolveExpression(e,t.key)))return resolvePattern(e,t.value)}return getDefault(e,i,a)}(e,t);default:return new FluentNone}}function resolveComplexPattern(e,t){if(e.dirty.has(t)){e.reportError(new RangeError("Cyclic reference"));return new FluentNone}e.dirty.add(t);const i=[],a=e.bundle._useIsolating&&t.length>1;for(const s of t)if("string"!=typeof s){e.placeables++;if(e.placeables>100){e.dirty.delete(t);throw new RangeError(`Too many placeables expanded: ${e.placeables}, max allowed is 100`)}a&&i.push("⁨");i.push(resolveExpression(e,s).toString(e));a&&i.push("⁩")}else i.push(e.bundle._transform(s));e.dirty.delete(t);return i.join("")}function resolvePattern(e,t){return"string"==typeof t?e.bundle._transform(t):resolveComplexPattern(e,t)}class Scope{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);if(!i){i={};this.bundle._intls.set(e,i)}let a=JSON.stringify(t);i[a]||(i[a]=new e(this.bundle.locales,t));return i[a]}}function values(e,t){const i=Object.create(null);for(const[a,s]of Object.entries(e))t.includes(a)&&(i[a]=s.valueOf());return i}const gu=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function NUMBER(e,t){let i=e[0];if(i instanceof FluentNone)return new FluentNone(`NUMBER(${i.valueOf()})`);if(i instanceof FluentNumber)return new FluentNumber(i.valueOf(),{...i.opts,...values(t,gu)});if(i instanceof FluentDateTime)return new FluentNumber(i.toNumber(),{...values(t,gu)});throw new TypeError("Invalid argument to NUMBER")}const mu=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function DATETIME(e,t){let i=e[0];if(i instanceof FluentNone)return new FluentNone(`DATETIME(${i.valueOf()})`);if(i instanceof FluentDateTime||i instanceof FluentNumber)return new FluentDateTime(i,values(t,mu));throw new TypeError("Invalid argument to DATETIME")}const fu=new Map;class FluentBundle{constructor(e,{functions:t,useIsolating:i=!0,transform:a=e=>e}={}){this._terms=new Map;this._messages=new Map;this.locales=Array.isArray(e)?e:[e];this._functions={NUMBER,DATETIME,...t};this._useIsolating=i;this._transform=a;this._intls=function getMemoizerForLocale(e){const t=Array.isArray(e)?e.join(" "):e;let i=fu.get(t);if(void 0===i){i=new Map;fu.set(t,i)}return 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 a=0;a<e.body.length;a++){let s=e.body[a];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 a=new Scope(this,i,t);try{return resolveComplexPattern(a,e).toString(a)}catch(e){if(a.errors&&e instanceof Error){a.errors.push(e);return(new FluentNone).toString(a)}throw e}}}const vu=/^(-?[a-zA-Z][\w-]*) *= */gm,Pu=/\.([a-zA-Z][\w-]*) *= */y,wu=/\*?\[/y,Fu=/(-?[0-9]+(?:\.([0-9]+))?)/y,yu=/([a-zA-Z][\w-]*)/y,bu=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Su=/^[A-Z][A-Z0-9_-]*$/,Cu=/([^{}\n\r]+)/y,xu=/([^\\"\n\r]*)/y,ku=/\\([\\"])/y,Eu=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,Au=/^\n+/,Gu=/ +$/,Bu=/ *\r?\n/g,Mu=/( *)$/,Iu=/{\s*/y,Tu=/\s*}/y,Du=/\[\s*/y,Lu=/\s*] */y,Ru=/\s*\(\s*/y,Ou=/\s*->\s*/y,Nu=/\s*:\s*/y,Wu=/\s*,?\s*/y,ju=/\s+/y;class FluentResource{constructor(e){this.body=[];vu.lastIndex=0;let t=0;for(;;){let i=vu.exec(e);if(null===i)break;t=vu.lastIndex;try{this.body.push(parseMessage(i[1]))}catch(e){if(e instanceof SyntaxError)continue;throw e}}function test(i){i.lastIndex=t;return i.test(e)}function consumeChar(i,a){if(e[t]===i){t++;return!0}if(a)throw new a(`Expected ${i}`);return!1}function consumeToken(e,i){if(test(e)){t=e.lastIndex;return!0}if(i)throw new i(`Expected ${e.toString()}`);return!1}function match(i){i.lastIndex=t;let a=i.exec(e);if(null===a)throw new SyntaxError(`Expected ${i.toString()}`);t=i.lastIndex;return a}function match1(e){return match(e)[1]}function parseMessage(e){let t=parsePattern(),i=function parseAttributes(){let e=Object.create(null);for(;test(Pu);){let t=match1(Pu),i=parsePattern();if(null===i)throw new SyntaxError("Expected attribute value");e[t]=i}return e}();if(null===t&&0===Object.keys(i).length)throw new SyntaxError("Expected message value or attributes");return{id:e,value:t,attributes:i}}function parsePattern(){let i;test(Cu)&&(i=match1(Cu));if("{"===e[t]||"}"===e[t])return parsePatternElements(i?[i]:[],1/0);let a=parseIndent();if(a){if(i)return parsePatternElements([i,a],a.length);a.value=trim(a.value,Au);return parsePatternElements([a],a.length)}return i?trim(i,Gu):null}function parsePatternElements(i=[],a){for(;;){if(test(Cu)){i.push(match1(Cu));continue}if("{"===e[t]){i.push(parsePlaceable());continue}if("}"===e[t])throw new SyntaxError("Unbalanced closing brace");let s=parseIndent();if(!s)break;i.push(s);a=Math.min(a,s.length)}let s=i.length-1,r=i[s];"string"==typeof r&&(i[s]=trim(r,Gu));let n=[];for(let e of i){e instanceof Indent&&(e=e.value.slice(0,e.value.length-a));e&&n.push(e)}return n}function parsePlaceable(){consumeToken(Iu,SyntaxError);let e=parseInlineExpression();if(consumeToken(Tu))return e;if(consumeToken(Ou)){let t=function parseVariants(){let e,t=[],i=0;for(;test(wu);){consumeChar("*")&&(e=i);let a=parseVariantKey(),s=parsePattern();if(null===s)throw new SyntaxError("Expected variant value");t[i++]={key:a,value:s}}if(0===i)return null;if(void 0===e)throw new SyntaxError("Expected default variant");return{variants:t,star:e}}();consumeToken(Tu,SyntaxError);return{type:"select",selector:e,...t}}throw new SyntaxError("Unclosed placeable")}function parseInlineExpression(){if("{"===e[t])return parsePlaceable();if(test(bu)){let[,i,a,s=null]=match(bu);if("$"===i)return{type:"var",name:a};if(consumeToken(Ru)){let r=function parseArguments(){let i=[];for(;;){switch(e[t]){case")":t++;return i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(parseArgument());consumeToken(Wu)}}();if("-"===i)return{type:"term",name:a,attr:s,args:r};if(Su.test(a))return{type:"func",name:a,args:r};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:a,attr:s,args:[]}:{type:"mesg",name:a,attr:s}}return parseLiteral()}function parseArgument(){let e=parseInlineExpression();return"mesg"!==e.type?e:consumeToken(Nu)?{type:"narg",name:e.name,value:parseLiteral()}:e}function parseVariantKey(){consumeToken(Du,SyntaxError);let e;e=test(Fu)?parseNumberLiteral():{type:"str",value:match1(yu)};consumeToken(Lu,SyntaxError);return e}function parseLiteral(){if(test(Fu))return parseNumberLiteral();if('"'===e[t])return function parseStringLiteral(){consumeChar('"',SyntaxError);let i="";for(;;){i+=match1(xu);if("\\"!==e[t]){if(consumeChar('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=parseEscapeSequence()}}();throw new SyntaxError("Invalid expression")}function parseNumberLiteral(){let[,e,t=""]=match(Fu),i=t.length;return{type:"num",value:parseFloat(e),precision:i}}function parseEscapeSequence(){if(test(ku))return match1(ku);if(test(Eu)){let[,e,t]=match(Eu),i=parseInt(e||t,16);return i<=55295||57344<=i?String.fromCodePoint(i):"�"}throw new SyntaxError("Unknown escape sequence")}function parseIndent(){let i=t;consumeToken(ju);switch(e[t]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return makeIndent(e.slice(i,t))}return" "===e[t-1]&&makeIndent(e.slice(i,t))}function trim(e,t){return e.replace(t,"")}function makeIndent(e){let t=e.replace(Bu,"\n"),i=Mu.exec(e)[1].length;return new Indent(t,i)}}}class Indent{constructor(e,t){this.value=e;this.length=t}}const Vu=/<|&#?\w+;/,Uu={"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"]},zu={"http://www.w3.org/1999/xhtml":{global:["title","aria-description","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 translateElement(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(Vu.test(i)){const t=e.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");t.innerHTML=i;!function overlayChildNodes(e,t){for(const i of e.childNodes)if(i.nodeType!==i.TEXT_NODE){if(i.hasAttribute("data-l10n-name")){const a=getNodeForNamedElement(t,i);e.replaceChild(a,i);continue}if(isElementAllowed(i)){const t=createSanitizedElement(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(createTextNodeFromTextContent(i),i)}t.textContent="";t.appendChild(e)}(t.content,e)}else e.textContent=i;overlayAttributes(t,e)}function hasAttribute(e,t){if(!e)return!1;for(let i of e)if(i.name===t)return!0;return!1}function overlayAttributes(e,t){const i=t.hasAttribute("data-l10n-attrs")?t.getAttribute("data-l10n-attrs").split(",").map(e=>e.trim()):null;for(const a of Array.from(t.attributes))isAttrNameLocalizable(a.name,t,i)&&!hasAttribute(e.attributes,a.name)&&t.removeAttribute(a.name);if(e.attributes)for(const a of Array.from(e.attributes))isAttrNameLocalizable(a.name,t,i)&&t.getAttribute(a.name)!==a.value&&t.setAttribute(a.name,a.value)}function getNodeForNamedElement(e,t){const i=t.getAttribute("data-l10n-name"),a=e.querySelector(`[data-l10n-name="${i}"]`);if(!a){console.warn(`An element named "${i}" wasn't found in the source.`);return createTextNodeFromTextContent(t)}if(a.localName!==t.localName){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 (${a.localName}).`);return createTextNodeFromTextContent(t)}e.removeChild(a);return shallowPopulateUsing(t,a.cloneNode(!1))}function createSanitizedElement(e){const t=e.ownerDocument.createElement(e.localName);return shallowPopulateUsing(e,t)}function createTextNodeFromTextContent(e){return e.ownerDocument.createTextNode(e.textContent)}function isElementAllowed(e){const t=Uu[e.namespaceURI];return t&&t.includes(e.localName)}function isAttrNameLocalizable(e,t,i=null){if(i&&i.includes(e))return!0;const a=zu[t.namespaceURI];if(!a)return!1;const s=e.toLowerCase(),r=t.localName;if(a.global.includes(s))return!0;if(!a[r])return!1;if(a[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 shallowPopulateUsing(e,t){t.textContent=e.textContent;overlayAttributes(e,t);return t}class CachedIterable extends Array{static from(e){return e instanceof this?e:new this(e)}}Symbol.iterator;class CachedAsyncIterable extends CachedIterable{constructor(e){super();if(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{async next(){e.length<=t&&e.push(e.iterator.next());return 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 Localization{constructor(e=[],t){this.resourceIds=e;this.generateBundles=t;this.onChange(!0)}addResourceIds(e,t=!1){this.resourceIds.push(...e);this.onChange(t);return this.resourceIds.length}removeResourceIds(e){this.resourceIds=this.resourceIds.filter(t=>!e.includes(t));this.onChange();return this.resourceIds.length}async formatWithFallback(e,t){const i=[];let a=!1;for await(const s of this.bundles){a=!0;const r=keysFromBundle(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}`)}}a||"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)}.`);return i}formatMessages(e){return this.formatWithFallback(e,messageFromBundle)}formatValues(e){return this.formatWithFallback(e,valueFromBundle)}async formatValue(e,t){const[i]=await this.formatValues([{id:e,args:t}]);return i}handleEvent(){this.onChange()}onChange(e=!1){this.bundles=CachedAsyncIterable.from(this.generateBundles(this.resourceIds));e&&this.bundles.touchNext(2)}}function valueFromBundle(e,t,i,a){return i.value?e.formatPattern(i.value,a,t):null}function messageFromBundle(e,t,i,a){const s={value:null,attributes:null};i.value&&(s.value=e.formatPattern(i.value,a,t));let r=Object.keys(i.attributes);if(r.length>0){s.attributes=new Array(r.length);for(let[n,o]of r.entries()){let r=e.formatPattern(i.attributes[o],a,t);s.attributes[n]={name:o,value:r}}}return s}function keysFromBundle(e,t,i,a){const s=[],r=new Set;i.forEach(({id:i,args:n},o)=>{if(void 0!==a[o])return;let l=t.getMessage(i);if(l){s.length=0;a[o]=e(t,s,l,n);if(s.length>0&&"undefined"!=typeof console){const e=t.locales[0],a=s.join(", ");console.warn(`[fluent][resolver] errors in ${e}/${i}: ${a}.`)}}else r.add(i)});return r}const Hu="data-l10n-id",$u="data-l10n-args",Xu=`[${Hu}]`;class DOMLocalization extends Localization{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:[Hu,$u]}}onChange(e=!1){super.onChange(e);this.roots&&this.translateRoots()}setAttributes(e,t,i){e.setAttribute(Hu,t);i?e.setAttribute($u,JSON.stringify(i)):e.removeAttribute($u);return e}getAttributes(e){return{id:e.getAttribute(Hu),args:JSON.parse(e.getAttribute($u)||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){this.roots.delete(e);this.pauseObserving();if(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();return!0}this.resumeObserving();return!1}translateRoots(){const e=Array.from(this.roots);return Promise.all(e.map(e=>this.translateFragment(e)))}pauseObserving(){if(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(Hu)&&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]&&translateElement(e[i],t[i]);this.resumeObserving()}getTranslatables(e){const t=Array.from(e.querySelectorAll(Xu));"function"==typeof e.hasAttribute&&e.hasAttribute(Hu)&&t.push(e);return t}getKeysForElement(e){return{id:e.getAttribute(Hu),args:JSON.parse(e.getAttribute($u)||null)}}}function l10n_classPrivateFieldInitSpec(e,t,i){(function l10n_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function l10n_classPrivateFieldGet(e,t){return e.get(l10n_assertClassBrand(e,t))}function l10n_classPrivateFieldSet(e,t,i){return e.set(l10n_assertClassBrand(e,t),i),i}function l10n_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Ku=new WeakMap,qu=new WeakMap,Yu=new WeakMap,Zu=new WeakMap;class L10n{constructor({lang:e,isRTL:t},i=null){l10n_classPrivateFieldInitSpec(this,Ku,void 0);l10n_classPrivateFieldInitSpec(this,qu,void 0);l10n_classPrivateFieldInitSpec(this,Yu,void 0);l10n_classPrivateFieldInitSpec(this,Zu,void 0);l10n_classPrivateFieldSet(Yu,this,_fixupLangCode.call(L10n,e));l10n_classPrivateFieldSet(Zu,this,i);l10n_classPrivateFieldSet(Ku,this,t??_isRTL.call(L10n,l10n_classPrivateFieldGet(Yu,this))?"rtl":"ltr")}_setL10n(e){l10n_classPrivateFieldSet(Zu,this,e)}getLanguage(){return l10n_classPrivateFieldGet(Yu,this)}getDirection(){return l10n_classPrivateFieldGet(Ku,this)}async get(e,t=null){if(Array.isArray(e)){e=e.map(e=>({id:e}));return(await l10n_classPrivateFieldGet(Zu,this).formatMessages(e)).map(e=>e.value)}const i=await l10n_classPrivateFieldGet(Zu,this).formatMessages([{id:e,args:t}]);return i[0]?.value}async translate(e){(l10n_classPrivateFieldGet(qu,this)||l10n_classPrivateFieldSet(qu,this,new Set)).add(e);try{l10n_classPrivateFieldGet(Zu,this).connectRoot(e)}catch{}await l10n_classPrivateFieldGet(Zu,this).translateRoots()}async translateOnce(e){try{await l10n_classPrivateFieldGet(Zu,this).translateElements([e])}catch(e){console.error("translateOnce:",e)}}async destroy(){if(l10n_classPrivateFieldGet(qu,this)){for(const e of l10n_classPrivateFieldGet(qu,this))l10n_classPrivateFieldGet(Zu,this).disconnectRoot(e);l10n_classPrivateFieldGet(qu,this).clear();l10n_classPrivateFieldSet(qu,this,null)}l10n_classPrivateFieldGet(Zu,this).pauseObserving()}pause(){l10n_classPrivateFieldGet(Zu,this).pauseObserving()}resume(){l10n_classPrivateFieldGet(Zu,this).resumeObserving()}}function _fixupLangCode(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}function _isRTL(e){const t=e.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(t)}var Qu;function genericl10n_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function PLATFORM(){const{isAndroid:e,isLinux:t,isMac:i,isWindows:a}=FeatureTest.platform;return t?"linux":a?"windows":i?"macos":e?"android":"other"}function createBundle(e,t){const i=new FluentResource(t),a=new FluentBundle(e,{functions:{PLATFORM}}),s=a.addResource(i);s.length&&console.error("L10n errors",s);return a}class genericl10n_GenericL10n extends L10n{constructor(e){super({lang:e});const t=e?_generateBundles.bind(genericl10n_GenericL10n,"en-us",this.getLanguage()):_generateBundlesFallback.bind(genericl10n_GenericL10n,this.getLanguage());this._setL10n(new DOMLocalization([],t))}}Qu=genericl10n_GenericL10n;async function*_generateBundles(e,t){const{baseURL:i,paths:a}=await genericl10n_assertClassBrand(Qu,this,_getPaths).call(this),s=[t];if(e!==t){const i=t.split("-",1)[0];i!==t&&s.push(i);s.push(e)}const r=s.map(e=>[e,genericl10n_assertClassBrand(Qu,this,_createBundle).call(this,e,i,a)]);for(const[e,t]of r){const i=await t;i?yield i:"en-us"===e&&(yield genericl10n_assertClassBrand(Qu,this,_createBundleFallback).call(this,e))}}async function _createBundle(e,t,i){const a=i[e];if(!a)return null;const s=new URL(a,t);return createBundle(e,await fetchData(s,"text"))}async function _getPaths(){try{const{href:e}=document.querySelector('link[type="application/l10n"]'),t=await fetchData(e,"json");return{baseURL:e.substring(0,e.lastIndexOf("/")+1)||"./",paths:t}}catch{}return{baseURL:"./",paths:Object.create(null)}}async function*_generateBundlesFallback(e){yield genericl10n_assertClassBrand(Qu,this,_createBundleFallback).call(this,e)}async function _createBundleFallback(e){return createBundle(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-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $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-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\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-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-title1 =\n    .title = Page { $page } of { $total }\npdfjs-thumb-page-canvas =\n    .aria-label = Thumbnail of Page { $page }\npdfjs-thumb-page-checkbox1 =\n    .title = Select 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-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\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-color-picker-free-text-input =\n    .title = Change text color\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n    .title = Draw\npdfjs-editor-color-picker-ink-input =\n    .title = Change drawing color\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-eraser-button =\n    .title = Erase\npdfjs-editor-eraser-button-label = Erase\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-comment-floating-button =\n    .title = Comment\n    .aria-label = Comment\npdfjs-comment-floating-button-label = Comment\npdfjs-editor-comment-button =\n    .title = Comment\n    .aria-label = Comment\npdfjs-editor-comment-button-label = Comment\npdfjs-editor-signature-button =\n    .title = Add signature\npdfjs-editor-signature-button-label = Add signature\npdfjs-editor-highlight-editor =\n    .aria-label = Highlight editor\npdfjs-editor-ink-editor =\n    .aria-label = Drawing editor\npdfjs-editor-eraser-editor =\n    .aria-label = Eraser\npdfjs-editor-signature-editor1 =\n    .aria-description = Signature editor: { $description }\npdfjs-editor-stamp-editor =\n    .aria-label = Image editor\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-remove-signature-button =\n    .title = Remove signature\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-editor-add-signature-container =\n    .aria-label = Signature controls and saved signatures\npdfjs-editor-signature-add-signature-button =\n    .title = Add new signature\npdfjs-editor-signature-add-signature-button-label = Add new signature\npdfjs-editor-add-saved-signature-button =\n    .title = Saved signature: { $description }\npdfjs-free-text2 =\n    .aria-label = Text Editor\n    .default-content = Start typing…\npdfjs-editor-comments-sidebar-title =\n    { $count ->\n        [one] Comment\n       *[other] Comments\n    }\npdfjs-editor-comments-sidebar-close-button =\n    .title = Close the sidebar\n    .aria-label = Close the sidebar\npdfjs-editor-comments-sidebar-close-button-label = Close the sidebar\npdfjs-editor-comments-sidebar-no-comments1 = See something noteworthy? Highlight it and leave a comment.\npdfjs-editor-comments-sidebar-no-comments-link = Learn more\npdfjs-editor-alt-text-button =\n    .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n    .aria-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-top-left =\n    .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n    .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n    .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n    .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n    .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n    .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n    .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n    .aria-label = 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\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n    .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n    .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n    .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n    .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n    .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n    .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-highlight-added-alert = Highlight added\npdfjs-editor-freetext-added-alert = Text added\npdfjs-editor-ink-added-alert = Drawing added\npdfjs-editor-stamp-added-alert = Image added\npdfjs-editor-signature-added-alert = Signature added\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-signature = Signature removed\npdfjs-editor-undo-bar-message-comment = Comment removed\npdfjs-editor-undo-bar-message-multiple =\n    { $count ->\n        [one] { $count } annotation removed\n       *[other] { $count } annotations removed\n    }\npdfjs-editor-undo-bar-undo-button =\n    .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n    .title = Close\npdfjs-editor-undo-bar-close-button-label = Close\npdfjs-editor-undo-button =\n    .title = Undo\npdfjs-editor-undo-button-label = Undo\npdfjs-editor-redo-button =\n    .title = Redo\npdfjs-editor-redo-button-label = Redo\npdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use.\npdfjs-editor-add-signature-dialog-title = Add a signature\npdfjs-editor-add-signature-type-button = Type\n    .title = Type\npdfjs-editor-add-signature-draw-button = Draw\n    .title = Draw\npdfjs-editor-add-signature-image-button = Image\n    .title = Image\npdfjs-editor-add-signature-type-input =\n    .aria-label = Type your signature\n    .placeholder = Type your signature\npdfjs-editor-add-signature-draw-placeholder = Draw your signature\npdfjs-editor-add-signature-draw-thickness-range-label = Thickness\npdfjs-editor-add-signature-draw-thickness-range =\n    .title = Drawing thickness: { $thickness }\npdfjs-editor-add-signature-image-placeholder = Drag a file here to upload\npdfjs-editor-add-signature-image-browse-link =\n    { PLATFORM() ->\n        [macos] Or choose image files\n       *[other] Or browse image files\n    }\npdfjs-editor-add-signature-description-label = Description (alt text)\npdfjs-editor-add-signature-description-input =\n    .title = Description (alt text)\npdfjs-editor-add-signature-description-default-when-drawing = Signature\npdfjs-editor-add-signature-clear-button-label = Clear signature\npdfjs-editor-add-signature-clear-button =\n    .title = Clear signature\npdfjs-editor-add-signature-save-checkbox = Save signature\npdfjs-editor-add-signature-save-warning-message = You’ve reached the limit of 5 saved signatures. Remove one to save more.\npdfjs-editor-add-signature-image-upload-error-title = Couldn’t upload image\npdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image.\npdfjs-editor-add-signature-image-no-data-error-title = Can’t convert this image into a signature\npdfjs-editor-add-signature-image-no-data-error-description = Please try uploading a different image.\npdfjs-editor-add-signature-error-close-button = Close\npdfjs-editor-add-signature-cancel-button = Cancel\npdfjs-editor-add-signature-add-button = Add\npdfjs-editor-delete-signature-button1 =\n    .title = Remove saved signature\npdfjs-editor-delete-signature-button-label1 = Remove saved signature\npdfjs-editor-add-signature-edit-button-label = Edit description\npdfjs-editor-edit-signature-dialog-title = Edit description\npdfjs-editor-edit-signature-update-button = Update\npdfjs-show-comment-button =\n    .title = Show comment\npdfjs-editor-edit-comment-popup-button-label = Edit comment\npdfjs-editor-edit-comment-popup-button =\n    .title = Edit comment\npdfjs-editor-delete-comment-popup-button-label = Remove comment\npdfjs-editor-delete-comment-popup-button =\n    .title = Remove comment\npdfjs-editor-edit-comment-dialog-title-when-editing = Edit comment\npdfjs-editor-edit-comment-dialog-save-button-when-editing = Update\npdfjs-editor-edit-comment-dialog-title-when-adding = Add comment\npdfjs-editor-edit-comment-dialog-save-button-when-adding = Add\npdfjs-editor-edit-comment-dialog-text-input =\n    .placeholder = Start typing…\npdfjs-editor-edit-comment-dialog-cancel-button = Cancel\npdfjs-editor-add-comment-button =\n    .title = Add comment\npdfjs-toggle-views-manager-button1 =\n    .title = Manage pages\npdfjs-toggle-views-manager-notification-button =\n    .title = Toggle Sidebar (document contains thumbnails/outline/attachments/layers)\npdfjs-toggle-views-manager-button1-label = Manage pages\npdfjs-views-manager-sidebar =\n    .aria-label = Sidebar\npdfjs-views-manager-sidebar-resizer =\n    .aria-label = Sidebar resizer\npdfjs-views-manager-view-selector-button =\n    .title = Views\npdfjs-views-manager-view-selector-button-label = Views\npdfjs-views-manager-pages-title = Pages\npdfjs-views-manager-outlines-title1 = Document outline\n    .title = Document outline (double-click to expand/collapse all items)\npdfjs-views-manager-attachments-title = Attachments\npdfjs-views-manager-layers-title1 = Layers\n    .title = Layers (double-click to reset all layers to the default state)\npdfjs-views-manager-pages-option-label = Pages\npdfjs-views-manager-outlines-option-label = Document outline\npdfjs-views-manager-attachments-option-label = Attachments\npdfjs-views-manager-layers-option-label = Layers\npdfjs-views-manager-add-file-button =\n    .title = Add file\npdfjs-views-manager-add-file-button-label = Add file\npdfjs-views-manager-pages-status-action-label =\n    { $count ->\n        [one] { $count } selected\n        *[other] { $count } selected\n    }\npdfjs-views-manager-pages-status-none-action-label = Select pages\npdfjs-views-manager-pages-status-action-button-label = Manage\npdfjs-views-manager-pages-status-copy-button-label = Copy\npdfjs-views-manager-pages-status-cut-button-label = Cut\npdfjs-views-manager-pages-status-delete-button-label = Delete\npdfjs-views-manager-pages-status-export-selected-button-label = Export selected…\npdfjs-views-manager-status-undo-cut-label =\n    { $count ->\n        [one] 1 page cut\n        *[other] { $count } pages cut\n    }\npdfjs-views-manager-pages-status-undo-copy-label =\n    { $count ->\n        [one] 1 page copied\n        *[other] { $count } pages copied\n    }\npdfjs-views-manager-pages-status-undo-delete-label =\n    { $count ->\n        [one] 1 page deleted\n        *[other] { $count } pages deleted\n    }\npdfjs-views-manager-status-undo-button-label = Undo\npdfjs-views-manager-status-done-button-label = Done\npdfjs-views-manager-status-close-button =\n    .title = Close\npdfjs-views-manager-status-close-button-label = Close\npdfjs-views-manager-paste-button-label = Paste\npdfjs-views-manager-paste-button-before =\n    .title = Paste before the first page\npdfjs-views-manager-paste-button-after =\n    .title = Paste after page { $page }\npdfjs-new-badge-content = NEW\npdfjs-views-manager-waiting-for-file = Uploading file…\npdfjs-digital-signature-properties-button =\n    .title = Digital signature properties\n    .aria-label = Digital signature properties\npdfjs-digital-signature-properties-button-label = Digital signature properties\npdfjs-digital-signature-properties-banner-verified = Document was signed with a valid digital signature\npdfjs-digital-signature-properties-banner-unknown =\n    { $count ->\n        [one] Document signed but { $count } digital signature could not be verified\n       *[other] Document signed but { $count } digital signatures could not be verified\n    }\npdfjs-digital-signature-properties-banner-untrusted =\n    { $count ->\n        [one] Document signed with { $count } certificate that is not trusted\n       *[other] Document signed with { $count } certificates that are not trusted\n    }\npdfjs-digital-signature-properties-banner-expired =\n    { $count ->\n        [one] Document signed with { $count } expired certificate\n       *[other] Document signed with { $count } expired certificates\n    }\npdfjs-digital-signature-properties-banner-invalid =\n    { $count ->\n        [one] Document has { $count } invalid digital signature\n       *[other] Document has { $count } invalid digital signatures\n    }\npdfjs-digital-signature-properties-banner-revoked =\n    { $count ->\n        [one] Document signed with { $count } revoked certificate\n       *[other] Document signed with { $count } revoked certificates\n    }\npdfjs-digital-signature-properties-status-verified = Status: Signature verified\npdfjs-digital-signature-properties-status-invalid = Status: Signature invalid\npdfjs-digital-signature-properties-status-unknown = Status: Unable to verify (unsupported)\npdfjs-digital-signature-properties-certificate-trusted = Certificate: Trusted ({ $issuer })\npdfjs-digital-signature-properties-certificate-unknown = Certificate: Unavailable\npdfjs-digital-signature-properties-certificate-untrusted = Certificate: Untrusted\npdfjs-digital-signature-properties-certificate-untrusted-unknown-issuer = Certificate: Unknown issuer ({ $issuer })\npdfjs-digital-signature-properties-certificate-untrusted-self-signed = Certificate: Self-signed ({ $issuer })\npdfjs-digital-signature-properties-certificate-untrusted-untrusted-issuer = Certificate: Untrusted issuer ({ $issuer })\npdfjs-digital-signature-properties-certificate-expired = Certificate: Expired\npdfjs-digital-signature-properties-certificate-expired-with-date = Certificate: Expired ({ DATETIME($dateObj, dateStyle: "medium") })\npdfjs-digital-signature-properties-certificate-revoked = Certificate: Revoked\npdfjs-digital-signature-properties-view-certificate = View certificate\npdfjs-digital-signature-properties-reason = Reason: { $reason }\npdfjs-digital-signature-properties-timestamp = Timestamp: { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-digital-signature-properties-sub-signatures =\n    { $count ->\n        [one] Sub-signature ({ $count })\n       *[other] Sub-signatures ({ $count })\n    }')}class GenericScripting{constructor(e,t){"Function"===e?.constructor?.name&&(e=e());this._ready=new Promise((i,a)=>{import(
/*webpackIgnore: true*/
/*@vite-ignore*/
e).then(e=>e.QuickJSSandbox(new URL(t,location.href).href)).then(e=>{this.ngxSandbox=e;i(e)}).catch(a)})}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()}}function generic_signature_storage_classPrivateFieldInitSpec(e,t,i){generic_signature_storage_checkPrivateRedeclaration(e,t),t.set(e,i)}function generic_signature_storage_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function generic_signature_storage_classPrivateFieldGet(e,t){return e.get(generic_signature_storage_assertClassBrand(e,t))}function generic_signature_storage_classPrivateFieldSet(e,t,i){return e.set(generic_signature_storage_assertClassBrand(e,t),i),i}function generic_signature_storage_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Ju="pdfjs.signature";var ep=new WeakMap,tp=new WeakMap,ip=new WeakMap,ap=new WeakSet;class SignatureStorage{constructor(e,t){!function generic_signature_storage_classPrivateMethodInitSpec(e,t){generic_signature_storage_checkPrivateRedeclaration(e,t),t.add(e)}(this,ap);generic_signature_storage_classPrivateFieldInitSpec(this,ep,void 0);generic_signature_storage_classPrivateFieldInitSpec(this,tp,null);generic_signature_storage_classPrivateFieldInitSpec(this,ip,null);generic_signature_storage_classPrivateFieldSet(ep,this,e);generic_signature_storage_classPrivateFieldSet(ip,this,t)}async getAll(){if(generic_signature_storage_classPrivateFieldGet(ip,this)){window.addEventListener("storage",({key:e})=>{if(e===Ju){generic_signature_storage_classPrivateFieldSet(tp,this,null);generic_signature_storage_classPrivateFieldGet(ep,this)?.dispatch("storedsignatureschanged",{source:this})}},{signal:generic_signature_storage_classPrivateFieldGet(ip,this)});generic_signature_storage_classPrivateFieldSet(ip,this,null)}if(!generic_signature_storage_classPrivateFieldGet(tp,this)){generic_signature_storage_classPrivateFieldSet(tp,this,new Map);const e=localStorage.getItem(Ju);if(e)for(const[t,i]of Object.entries(JSON.parse(e)))generic_signature_storage_classPrivateFieldGet(tp,this).set(t,i)}return generic_signature_storage_classPrivateFieldGet(tp,this)}async isFull(){return 5===await this.size()}async size(){return(await this.getAll()).size}async create(e){if(await this.isFull())return null;const t=getUuid();generic_signature_storage_classPrivateFieldGet(tp,this).set(t,e);generic_signature_storage_assertClassBrand(ap,this,_save).call(this);return t}async delete(e){const t=await this.getAll();if(!t.has(e))return!1;t.delete(e);generic_signature_storage_assertClassBrand(ap,this,_save).call(this);return!0}}function _save(){localStorage.setItem(Ju,JSON.stringify(Object.fromEntries(generic_signature_storage_classPrivateFieldGet(tp,this))))}class ExternalServices extends BaseExternalServices{constructor(){super()}async createL10n(){return new genericl10n_GenericL10n(AppOptions.get("localeProperties")?.lang)}createScripting(){return new GenericScripting(AppOptions.get("sandboxBundleSrc"),AppOptions.get("wasmUrl"))}createSignatureStorage(e,t){return new SignatureStorage(e,t)}createSignatureVerifier(){return null}}0;function new_alt_text_manager_classPrivateMethodInitSpec(e,t){new_alt_text_manager_checkPrivateRedeclaration(e,t),t.add(e)}function new_alt_text_manager_classPrivateFieldInitSpec(e,t,i){new_alt_text_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function new_alt_text_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function new_alt_text_manager_toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function new_alt_text_manager_classPrivateFieldGet(e,t){return e.get(new_alt_text_manager_assertClassBrand(e,t))}function new_alt_text_manager_classPrivateFieldSet(e,t,i){return e.set(new_alt_text_manager_assertClassBrand(e,t),i),i}function new_alt_text_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var sp=new WeakMap,rp=new WeakMap,np=new WeakMap,op=new WeakMap,lp=new WeakMap,dp=new WeakMap,cp=new WeakMap,hp=new WeakMap,_p=new WeakMap,up=new WeakMap,pp=new WeakMap,gp=new WeakMap,mp=new WeakMap,fp=new WeakMap,vp=new WeakMap,Pp=new WeakMap,wp=new WeakMap,Fp=new WeakMap,yp=new WeakMap,bp=new WeakMap,Sp=new WeakMap,Cp=new WeakMap,xp=new WeakMap,kp=new WeakMap,Ep=new WeakMap,Ap=new WeakSet;class NewAltTextManager{constructor({descriptionContainer:e,dialog:t,imagePreview:i,cancelButton:a,disclaimer:s,notNowButton:r,saveButton:n,textarea:o,learnMore:l,errorCloseButton:d,createAutomaticallyButton:c,downloadModel:h,downloadModelDescription:_,title:u},p,g){new_alt_text_manager_classPrivateMethodInitSpec(this,Ap);new_alt_text_manager_classPrivateFieldInitSpec(this,sp,new_alt_text_manager_assertClassBrand(Ap,this,_cancel).bind(this));new_alt_text_manager_classPrivateFieldInitSpec(this,rp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,np,null);new_alt_text_manager_classPrivateFieldInitSpec(this,op,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,lp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,dp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,cp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,hp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,_p,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,up,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,pp,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,gp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,mp,null);new_alt_text_manager_classPrivateFieldInitSpec(this,fp,null);new_alt_text_manager_classPrivateFieldInitSpec(this,vp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Pp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,wp,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,Fp,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,yp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,bp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Sp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Cp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,xp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,kp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Ep,null);new_alt_text_manager_classPrivateFieldSet(op,this,a);new_alt_text_manager_classPrivateFieldSet(rp,this,c);new_alt_text_manager_classPrivateFieldSet(lp,this,e);new_alt_text_manager_classPrivateFieldSet(dp,this,t);new_alt_text_manager_classPrivateFieldSet(cp,this,s);new_alt_text_manager_classPrivateFieldSet(bp,this,r);new_alt_text_manager_classPrivateFieldSet(vp,this,i);new_alt_text_manager_classPrivateFieldSet(Cp,this,o);new_alt_text_manager_classPrivateFieldSet(yp,this,l);new_alt_text_manager_classPrivateFieldSet(xp,this,u);new_alt_text_manager_classPrivateFieldSet(hp,this,h);new_alt_text_manager_classPrivateFieldSet(_p,this,_);new_alt_text_manager_classPrivateFieldSet(Sp,this,p);new_alt_text_manager_classPrivateFieldSet(up,this,g);t.addEventListener("close",new_alt_text_manager_assertClassBrand(Ap,this,_close).bind(this));t.addEventListener("contextmenu",e=>{e.target!==new_alt_text_manager_classPrivateFieldGet(Cp,this)&&e.preventDefault()});a.addEventListener("click",new_alt_text_manager_classPrivateFieldGet(sp,this));r.addEventListener("click",new_alt_text_manager_classPrivateFieldGet(sp,this));n.addEventListener("click",new_alt_text_manager_assertClassBrand(Ap,this,new_alt_text_manager_save).bind(this));d.addEventListener("click",()=>{new_alt_text_manager_assertClassBrand(Ap,this,_toggleError).call(this,!1)});c.addEventListener("click",async()=>{const e="true"!==c.getAttribute("aria-pressed");new_alt_text_manager_classPrivateFieldGet(np,this)._reportTelemetry({action:"pdfjs.image.alt_text.ai_generation_check",data:{status:e}});if(new_alt_text_manager_classPrivateFieldGet(kp,this)){const t=await new_alt_text_manager_classPrivateFieldGet(kp,this).mlManager.isEnabledFor("altText");new_alt_text_manager_classPrivateFieldGet(rp,this).disabled=!0;if(e&&!t){new_alt_text_manager_classPrivateFieldGet(Cp,this).value="";new_alt_text_manager_assertClassBrand(Ap,this,_setProgress).call(this);new_alt_text_manager_classPrivateFieldGet(kp,this).setPreference("enableGuessAltText",!0);await new_alt_text_manager_classPrivateFieldGet(kp,this).mlManager.downloadModel("altText");new_alt_text_manager_assertClassBrand(Ap,this,_setPref).call(this,"enableAltTextModelDownload",!0)}else if(!e&&t){new_alt_text_manager_classPrivateFieldGet(kp,this).setPreference("enableGuessAltText",!1);await new_alt_text_manager_classPrivateFieldGet(kp,this).mlManager.deleteModel("altText");new_alt_text_manager_assertClassBrand(Ap,this,_setPref).call(this,"enableAltTextModelDownload",!1)}new_alt_text_manager_classPrivateFieldGet(rp,this).disabled=!1;await new_alt_text_manager_classPrivateFieldGet(kp,this).mlManager.toggleService("altText",e)}new_alt_text_manager_assertClassBrand(Ap,this,_toggleGuessAltText).call(this,e,!1)});o.addEventListener("focus",()=>{new_alt_text_manager_classPrivateFieldSet(Fp,this,new_alt_text_manager_classPrivateFieldGet(wp,this));new_alt_text_manager_assertClassBrand(Ap,this,_toggleLoading).call(this,!1);new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this)});o.addEventListener("blur",()=>{o.value||new_alt_text_manager_assertClassBrand(Ap,this,_toggleLoading).call(this,new_alt_text_manager_classPrivateFieldGet(Fp,this));new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this)});o.addEventListener("input",()=>{new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this)});o.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||n.disabled||new_alt_text_manager_assertClassBrand(Ap,this,new_alt_text_manager_save).call(this)});g.on("enableguessalttext",({value:e})=>{new_alt_text_manager_assertClassBrand(Ap,this,_toggleGuessAltText).call(this,e,!1)},lu);new_alt_text_manager_classPrivateFieldGet(Sp,this).register(t);new_alt_text_manager_classPrivateFieldGet(yp,this).addEventListener("click",()=>{new_alt_text_manager_classPrivateFieldGet(np,this)._reportTelemetry({action:"pdfjs.image.alt_text.info",data:{topic:"alt_text"}})})}async editAltText(e,t,i){if(new_alt_text_manager_classPrivateFieldGet(np,this)||!t)return;if(i&&t.hasAltTextData()){t.altTextFinish();return}new_alt_text_manager_classPrivateFieldSet(pp,this,i);const{mlManager:a}=e,s=!!a;new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this);a&&!a.isReady("altText")?a.hasProgress?new_alt_text_manager_assertClassBrand(Ap,this,_setProgress).call(this):new_alt_text_manager_classPrivateFieldGet(rp,this).setAttribute("aria-pressed",!1):new_alt_text_manager_classPrivateFieldGet(hp,this).classList.toggle("hidden",!0);const r=a?.isEnabledFor("altText");new_alt_text_manager_classPrivateFieldSet(np,this,t);new_alt_text_manager_classPrivateFieldSet(kp,this,e);new_alt_text_manager_classPrivateFieldGet(kp,this).removeEditListeners();({altText:new_alt_text_manager_toSetter(new_alt_text_manager_classPrivateFieldSet,[Ep,this])._}=t.altTextData);new_alt_text_manager_classPrivateFieldGet(Cp,this).value=new_alt_text_manager_classPrivateFieldGet(Ep,this)??"";let n,o,l;if(a){({canvas:n,width:o,height:l,imageData:new_alt_text_manager_toSetter(new_alt_text_manager_classPrivateFieldSet,[Pp,this])._}=t.copyCanvas(224,180,!0));s&&new_alt_text_manager_assertClassBrand(Ap,this,_toggleGuessAltText).call(this,await r,!0)}else({canvas:n,width:o,height:l}=t.copyCanvas(224,180,!1));n.setAttribute("role","presentation");const{style:d}=n;d.width=`${o}px`;d.height=`${l}px`;new_alt_text_manager_classPrivateFieldGet(vp,this).append(n);new_alt_text_manager_assertClassBrand(Ap,this,_toggleNotNow).call(this);new_alt_text_manager_assertClassBrand(Ap,this,_toggleAI).call(this,s);new_alt_text_manager_assertClassBrand(Ap,this,_toggleError).call(this,!1);try{await new_alt_text_manager_classPrivateFieldGet(Sp,this).open(new_alt_text_manager_classPrivateFieldGet(dp,this))}catch(e){new_alt_text_manager_assertClassBrand(Ap,this,_close).call(this);throw e}}destroy(){new_alt_text_manager_classPrivateFieldSet(kp,this,null);new_alt_text_manager_assertClassBrand(Ap,this,_finish).call(this)}}function _setPref(e,t){new_alt_text_manager_classPrivateFieldGet(up,this).dispatch("setpreference",{source:this,name:e,value:t})}function _toggleLoading(e){if(new_alt_text_manager_classPrivateFieldGet(kp,this)&&new_alt_text_manager_classPrivateFieldGet(wp,this)!==e){new_alt_text_manager_classPrivateFieldSet(wp,this,e);new_alt_text_manager_classPrivateFieldGet(lp,this).classList.toggle("loading",e)}}function _toggleError(e){new_alt_text_manager_classPrivateFieldGet(kp,this)&&new_alt_text_manager_classPrivateFieldGet(dp,this).classList.toggle("error",e)}async function _toggleGuessAltText(e,t){if(new_alt_text_manager_classPrivateFieldGet(kp,this)){new_alt_text_manager_classPrivateFieldGet(dp,this).classList.toggle("aiDisabled",!e);new_alt_text_manager_classPrivateFieldGet(rp,this).setAttribute("aria-pressed",e);if(e){const{altTextLearnMoreUrl:e}=new_alt_text_manager_classPrivateFieldGet(kp,this).mlManager;e&&(new_alt_text_manager_classPrivateFieldGet(yp,this).href=e);new_alt_text_manager_assertClassBrand(Ap,this,_mlGuessAltText).call(this,t)}else{new_alt_text_manager_assertClassBrand(Ap,this,_toggleLoading).call(this,!1);new_alt_text_manager_classPrivateFieldSet(wp,this,!1);new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this)}}}function _toggleNotNow(){new_alt_text_manager_classPrivateFieldGet(bp,this).classList.toggle("hidden",!new_alt_text_manager_classPrivateFieldGet(pp,this));new_alt_text_manager_classPrivateFieldGet(op,this).classList.toggle("hidden",new_alt_text_manager_classPrivateFieldGet(pp,this))}function _toggleAI(e){if(new_alt_text_manager_classPrivateFieldGet(kp,this)&&new_alt_text_manager_classPrivateFieldGet(mp,this)!==e){new_alt_text_manager_classPrivateFieldSet(mp,this,e);new_alt_text_manager_classPrivateFieldGet(dp,this).classList.toggle("noAi",!e);new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this)}}function _toggleTitleAndDisclaimer(){const e=new_alt_text_manager_classPrivateFieldGet(wp,this)||new_alt_text_manager_classPrivateFieldGet(gp,this)&&new_alt_text_manager_classPrivateFieldGet(gp,this)===new_alt_text_manager_classPrivateFieldGet(Cp,this).value;new_alt_text_manager_classPrivateFieldGet(cp,this).hidden=!e;const t=new_alt_text_manager_classPrivateFieldGet(wp,this)||!!new_alt_text_manager_classPrivateFieldGet(Cp,this).value;if(new_alt_text_manager_classPrivateFieldGet(fp,this)!==t){new_alt_text_manager_classPrivateFieldSet(fp,this,t);new_alt_text_manager_classPrivateFieldGet(xp,this).setAttribute("data-l10n-id",t?"pdfjs-editor-new-alt-text-dialog-edit-label":"pdfjs-editor-new-alt-text-dialog-add-label")}}async function _mlGuessAltText(e){if(new_alt_text_manager_classPrivateFieldGet(wp,this))return;if(new_alt_text_manager_classPrivateFieldGet(Cp,this).value)return;if(e&&null!==new_alt_text_manager_classPrivateFieldGet(Ep,this))return;new_alt_text_manager_classPrivateFieldSet(gp,this,new_alt_text_manager_classPrivateFieldGet(np,this).guessedAltText);if(null===new_alt_text_manager_classPrivateFieldGet(Ep,this)&&new_alt_text_manager_classPrivateFieldGet(gp,this)){new_alt_text_manager_assertClassBrand(Ap,this,_addAltText).call(this,new_alt_text_manager_classPrivateFieldGet(gp,this));return}new_alt_text_manager_assertClassBrand(Ap,this,_toggleLoading).call(this,!0);new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this);let t=!1;try{const e=await new_alt_text_manager_classPrivateFieldGet(np,this).mlGuessAltText(new_alt_text_manager_classPrivateFieldGet(Pp,this),!1);if(e){new_alt_text_manager_classPrivateFieldSet(gp,this,e);new_alt_text_manager_classPrivateFieldSet(Fp,this,new_alt_text_manager_classPrivateFieldGet(wp,this));new_alt_text_manager_classPrivateFieldGet(wp,this)&&new_alt_text_manager_assertClassBrand(Ap,this,_addAltText).call(this,e)}}catch(e){console.error(e);t=!0}new_alt_text_manager_assertClassBrand(Ap,this,_toggleLoading).call(this,!1);new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this);t&&new_alt_text_manager_classPrivateFieldGet(kp,this)&&new_alt_text_manager_assertClassBrand(Ap,this,_toggleError).call(this,!0)}function _addAltText(e){if(new_alt_text_manager_classPrivateFieldGet(kp,this)&&!new_alt_text_manager_classPrivateFieldGet(Cp,this).value){new_alt_text_manager_classPrivateFieldGet(Cp,this).value=e;new_alt_text_manager_assertClassBrand(Ap,this,_toggleTitleAndDisclaimer).call(this)}}function _setProgress(){new_alt_text_manager_classPrivateFieldGet(hp,this).classList.toggle("hidden",!1);const callback=async({detail:{finished:e,total:t,totalLoaded:i}})=>{const a=1e6;i=Math.min(.99*t,i);const s=new_alt_text_manager_classPrivateFieldGet(_p,this).ariaValueMax=Math.round(t/a),r=new_alt_text_manager_classPrivateFieldGet(_p,this).ariaValueNow=Math.round(i/a);new_alt_text_manager_classPrivateFieldGet(_p,this).setAttribute("data-l10n-args",JSON.stringify({totalSize:s,downloadedSize:r}));if(!e)return;new_alt_text_manager_classPrivateFieldGet(up,this).off("loadaiengineprogress",callback);new_alt_text_manager_classPrivateFieldGet(hp,this).classList.toggle("hidden",!0);new_alt_text_manager_assertClassBrand(Ap,this,_toggleAI).call(this,!0);if(!new_alt_text_manager_classPrivateFieldGet(kp,this))return;const{mlManager:n}=new_alt_text_manager_classPrivateFieldGet(kp,this);n.toggleService("altText",!0);new_alt_text_manager_assertClassBrand(Ap,this,_toggleGuessAltText).call(this,await n.isEnabledFor("altText"),!0)};new_alt_text_manager_classPrivateFieldGet(up,this).on("loadaiengineprogress",callback,lu)}function _cancel(){new_alt_text_manager_classPrivateFieldGet(np,this).altTextData={cancel:!0};const e=new_alt_text_manager_classPrivateFieldGet(Cp,this).value.trim();new_alt_text_manager_classPrivateFieldGet(np,this)._reportTelemetry({action:"pdfjs.image.alt_text.dismiss",data:{alt_text_type:e?"present":"empty",flow:new_alt_text_manager_classPrivateFieldGet(pp,this)?"image_add":"alt_text_edit"}});new_alt_text_manager_classPrivateFieldGet(np,this)._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!0,alt_text_type:"skipped"}});new_alt_text_manager_assertClassBrand(Ap,this,_finish).call(this)}function _finish(){new_alt_text_manager_classPrivateFieldGet(Sp,this).closeIfActive(new_alt_text_manager_classPrivateFieldGet(dp,this))}function _close(){const e=new_alt_text_manager_classPrivateFieldGet(vp,this).firstElementChild;e.remove();e.width=e.height=0;new_alt_text_manager_classPrivateFieldSet(Pp,this,null);new_alt_text_manager_assertClassBrand(Ap,this,_toggleLoading).call(this,!1);new_alt_text_manager_classPrivateFieldGet(kp,this)?.addEditListeners();new_alt_text_manager_classPrivateFieldGet(np,this).altTextFinish();new_alt_text_manager_classPrivateFieldGet(kp,this)?.setSelected(new_alt_text_manager_classPrivateFieldGet(np,this));new_alt_text_manager_classPrivateFieldSet(np,this,null);new_alt_text_manager_classPrivateFieldSet(kp,this,null)}function _extractWords(e){return new Set(e.toLowerCase().split(/[^\p{L}\p{N}]+/gu).filter(Boolean))}function new_alt_text_manager_save(){const e=new_alt_text_manager_classPrivateFieldGet(Cp,this).value.trim();new_alt_text_manager_classPrivateFieldGet(np,this).altTextData={altText:e,decorative:!1};new_alt_text_manager_classPrivateFieldGet(np,this).altTextData.guessedAltText=new_alt_text_manager_classPrivateFieldGet(gp,this);if(new_alt_text_manager_classPrivateFieldGet(gp,this)&&new_alt_text_manager_classPrivateFieldGet(gp,this)!==e){const t=new_alt_text_manager_assertClassBrand(Ap,this,_extractWords).call(this,new_alt_text_manager_classPrivateFieldGet(gp,this)),i=new_alt_text_manager_assertClassBrand(Ap,this,_extractWords).call(this,e);new_alt_text_manager_classPrivateFieldGet(np,this)._reportTelemetry({action:"pdfjs.image.alt_text.user_edit",data:{total_words:t.size,words_removed:t.difference(i).size,words_added:i.difference(t).size}})}new_alt_text_manager_classPrivateFieldGet(np,this)._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!0,alt_text_type:e?"present":"empty"}});new_alt_text_manager_classPrivateFieldGet(np,this)._reportTelemetry({action:"pdfjs.image.alt_text.save",data:{alt_text_type:e?"present":"empty",flow:new_alt_text_manager_classPrivateFieldGet(pp,this)?"image_add":"alt_text_edit"}});new_alt_text_manager_assertClassBrand(Ap,this,_finish).call(this)}var Gp=new WeakMap,Bp=new WeakMap,Mp=new WeakMap,Ip=new WeakMap,Tp=new WeakMap,Dp=new WeakMap,Lp=new WeakSet;class ImageAltTextSettings{constructor({dialog:e,createModelButton:t,learnMore:i,closeButton:a,showAltTextDialogButton:s},r,n,o){new_alt_text_manager_classPrivateMethodInitSpec(this,Lp);new_alt_text_manager_classPrivateFieldInitSpec(this,Gp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Bp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Mp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Ip,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Tp,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Dp,void 0);new_alt_text_manager_classPrivateFieldSet(Bp,this,e);new_alt_text_manager_classPrivateFieldSet(Gp,this,t);new_alt_text_manager_classPrivateFieldSet(Dp,this,s);new_alt_text_manager_classPrivateFieldSet(Tp,this,r);new_alt_text_manager_classPrivateFieldSet(Mp,this,n);new_alt_text_manager_classPrivateFieldSet(Ip,this,o);const{altTextLearnMoreUrl:l}=o;l&&(i.href=l);e.addEventListener("contextmenu",noContextMenu);t.addEventListener("click",async e=>{const t=new_alt_text_manager_assertClassBrand(Lp,this,_togglePref).call(this,"enableGuessAltText",e);await(t?new_alt_text_manager_assertClassBrand(Lp,this,new_alt_text_manager_download).call(this,!0):new_alt_text_manager_assertClassBrand(Lp,this,_delete).call(this,!0));await o.toggleService("altText",t);new_alt_text_manager_assertClassBrand(Lp,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_ai_generation_check",data:{status:t}})});s.addEventListener("click",e=>{const t=new_alt_text_manager_assertClassBrand(Lp,this,_togglePref).call(this,"enableNewAltTextWhenAddingImage",e);new_alt_text_manager_assertClassBrand(Lp,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_edit_alt_text_check",data:{status:t}})});a.addEventListener("click",new_alt_text_manager_assertClassBrand(Lp,this,_finish2).bind(this));i.addEventListener("click",()=>{new_alt_text_manager_assertClassBrand(Lp,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.info",data:{topic:"ai_generation"}})});n.on("enablealttextmodeldownload",({value:e})=>{e?new_alt_text_manager_assertClassBrand(Lp,this,new_alt_text_manager_download).call(this,!1):new_alt_text_manager_assertClassBrand(Lp,this,_delete).call(this,!1)},lu);new_alt_text_manager_classPrivateFieldGet(Tp,this).register(e)}async open({enableGuessAltText:e,enableNewAltTextWhenAddingImage:t}){const{enableAltTextModelDownload:i}=new_alt_text_manager_classPrivateFieldGet(Ip,this);new_alt_text_manager_classPrivateFieldGet(Gp,this).setAttribute("aria-pressed",i&&e);new_alt_text_manager_classPrivateFieldGet(Dp,this).setAttribute("aria-pressed",t);await new_alt_text_manager_classPrivateFieldGet(Tp,this).open(new_alt_text_manager_classPrivateFieldGet(Bp,this));new_alt_text_manager_assertClassBrand(Lp,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_displayed"})}}function _reportTelemetry(e){new_alt_text_manager_classPrivateFieldGet(Mp,this).dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}async function new_alt_text_manager_download(e=!1){if(e){await new_alt_text_manager_classPrivateFieldGet(Ip,this).downloadModel("altText");new_alt_text_manager_assertClassBrand(Lp,this,_setPref2).call(this,"enableGuessAltText",!0);new_alt_text_manager_classPrivateFieldGet(Ip,this).toggleService("altText",!0);new_alt_text_manager_assertClassBrand(Lp,this,_setPref2).call(this,"enableAltTextModelDownload",!0)}}async function _delete(e=!1){if(e){await new_alt_text_manager_classPrivateFieldGet(Ip,this).deleteModel("altText");new_alt_text_manager_assertClassBrand(Lp,this,_setPref2).call(this,"enableGuessAltText",!1);new_alt_text_manager_assertClassBrand(Lp,this,_setPref2).call(this,"enableAltTextModelDownload",!1)}new_alt_text_manager_classPrivateFieldGet(Gp,this).setAttribute("aria-pressed",!1)}function _togglePref(e,{target:t}){const i="true"!==t.getAttribute("aria-pressed");new_alt_text_manager_assertClassBrand(Lp,this,_setPref2).call(this,e,i);t.setAttribute("aria-pressed",i);return i}function _setPref2(e,t){new_alt_text_manager_classPrivateFieldGet(Mp,this).dispatch("setpreference",{source:this,name:e,value:t})}function _finish2(){new_alt_text_manager_classPrivateFieldGet(Tp,this).closeIfActive(new_alt_text_manager_classPrivateFieldGet(Bp,this))}function alt_text_manager_classPrivateFieldInitSpec(e,t,i){alt_text_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function alt_text_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function alt_text_manager_classPrivateFieldGet(e,t){return e.get(alt_text_manager_assertClassBrand(e,t))}function alt_text_manager_classPrivateFieldSet(e,t,i){return e.set(alt_text_manager_assertClassBrand(e,t),i),i}function alt_text_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Rp=new WeakMap,Op=new WeakMap,Np=new WeakMap,Wp=new WeakMap,jp=new WeakMap,Vp=new WeakMap,Up=new WeakMap,zp=new WeakMap,Hp=new WeakMap,$p=new WeakMap,Xp=new WeakMap,Kp=new WeakMap,qp=new WeakMap,Yp=new WeakMap,Zp=new WeakMap,Qp=new WeakMap,Jp=new WeakMap,eg=new WeakMap,tg=new WeakSet;class AltTextManager{constructor({dialog:e,optionDescription:t,optionDecorative:i,textarea:a,cancelButton:s,saveButton:r},n,o,l){!function alt_text_manager_classPrivateMethodInitSpec(e,t){alt_text_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,tg);alt_text_manager_classPrivateFieldInitSpec(this,Rp,null);alt_text_manager_classPrivateFieldInitSpec(this,Op,null);alt_text_manager_classPrivateFieldInitSpec(this,Np,void 0);alt_text_manager_classPrivateFieldInitSpec(this,Wp,void 0);alt_text_manager_classPrivateFieldInitSpec(this,jp,void 0);alt_text_manager_classPrivateFieldInitSpec(this,Vp,!1);alt_text_manager_classPrivateFieldInitSpec(this,Up,void 0);alt_text_manager_classPrivateFieldInitSpec(this,zp,void 0);alt_text_manager_classPrivateFieldInitSpec(this,Hp,void 0);alt_text_manager_classPrivateFieldInitSpec(this,$p,void 0);alt_text_manager_classPrivateFieldInitSpec(this,Xp,void 0);alt_text_manager_classPrivateFieldInitSpec(this,Kp,void 0);alt_text_manager_classPrivateFieldInitSpec(this,qp,null);alt_text_manager_classPrivateFieldInitSpec(this,Yp,null);alt_text_manager_classPrivateFieldInitSpec(this,Zp,null);alt_text_manager_classPrivateFieldInitSpec(this,Qp,null);alt_text_manager_classPrivateFieldInitSpec(this,Jp,void 0);alt_text_manager_classPrivateFieldInitSpec(this,eg,null);alt_text_manager_classPrivateFieldSet(Wp,this,e);alt_text_manager_classPrivateFieldSet(Up,this,t);alt_text_manager_classPrivateFieldSet(zp,this,i);alt_text_manager_classPrivateFieldSet(Xp,this,a);alt_text_manager_classPrivateFieldSet(Np,this,s);alt_text_manager_classPrivateFieldSet($p,this,r);alt_text_manager_classPrivateFieldSet(Hp,this,o);alt_text_manager_classPrivateFieldSet(jp,this,l);alt_text_manager_classPrivateFieldSet(Jp,this,n);const d=alt_text_manager_assertClassBrand(tg,this,_updateUIState).bind(this);e.addEventListener("close",alt_text_manager_assertClassBrand(tg,this,alt_text_manager_close).bind(this));e.addEventListener("contextmenu",e=>{e.target!==alt_text_manager_classPrivateFieldGet(Xp,this)&&e.preventDefault()});s.addEventListener("click",alt_text_manager_assertClassBrand(tg,this,alt_text_manager_finish).bind(this));r.addEventListener("click",alt_text_manager_assertClassBrand(tg,this,alt_text_manager_save).bind(this));t.addEventListener("change",d);i.addEventListener("change",d);a.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||r.disabled||alt_text_manager_assertClassBrand(tg,this,alt_text_manager_save).call(this)});alt_text_manager_classPrivateFieldGet(Hp,this).register(e)}async editAltText(e,t){if(alt_text_manager_classPrivateFieldGet(Op,this)||!t)return;alt_text_manager_assertClassBrand(tg,this,_createSVGElement).call(this);alt_text_manager_classPrivateFieldSet(Vp,this,!1);alt_text_manager_classPrivateFieldSet(Rp,this,new AbortController);const i={signal:alt_text_manager_classPrivateFieldGet(Rp,this).signal},a=alt_text_manager_assertClassBrand(tg,this,_onClick).bind(this);for(const e of[alt_text_manager_classPrivateFieldGet(Up,this),alt_text_manager_classPrivateFieldGet(zp,this),alt_text_manager_classPrivateFieldGet(Xp,this),alt_text_manager_classPrivateFieldGet($p,this),alt_text_manager_classPrivateFieldGet(Np,this)])e.addEventListener("click",a,i);const{altText:s,decorative:r}=t.altTextData;if(!0===r){alt_text_manager_classPrivateFieldGet(zp,this).checked=!0;alt_text_manager_classPrivateFieldGet(Up,this).checked=!1}else{alt_text_manager_classPrivateFieldGet(zp,this).checked=!1;alt_text_manager_classPrivateFieldGet(Up,this).checked=!0}alt_text_manager_classPrivateFieldSet(qp,this,alt_text_manager_classPrivateFieldGet(Xp,this).value=s?.trim()||"");alt_text_manager_assertClassBrand(tg,this,_updateUIState).call(this);alt_text_manager_classPrivateFieldSet(Op,this,t);alt_text_manager_classPrivateFieldSet(Kp,this,e);alt_text_manager_classPrivateFieldGet(Kp,this).removeEditListeners();alt_text_manager_classPrivateFieldSet(Yp,this,new AbortController);alt_text_manager_classPrivateFieldGet(jp,this).on("resize",alt_text_manager_assertClassBrand(tg,this,alt_text_manager_setPosition).bind(this),{signal:alt_text_manager_classPrivateFieldGet(Yp,this).signal,...lu});try{await alt_text_manager_classPrivateFieldGet(Hp,this).open(alt_text_manager_classPrivateFieldGet(Wp,this));alt_text_manager_assertClassBrand(tg,this,alt_text_manager_setPosition).call(this)}catch(e){alt_text_manager_assertClassBrand(tg,this,alt_text_manager_close).call(this);throw e}}destroy(){alt_text_manager_classPrivateFieldSet(Kp,this,null);alt_text_manager_assertClassBrand(tg,this,alt_text_manager_finish).call(this);alt_text_manager_classPrivateFieldGet(Zp,this)?.remove();alt_text_manager_classPrivateFieldSet(Zp,this,alt_text_manager_classPrivateFieldSet(Qp,this,null))}}function _createSVGElement(){if(alt_text_manager_classPrivateFieldGet(Zp,this))return;const e=new DOMSVGFactory,t=alt_text_manager_classPrivateFieldSet(Zp,this,e.createElement("svg"));t.setAttribute("width","0");t.setAttribute("height","0");const i=e.createElement("defs");t.append(i);const a=e.createElement("mask");i.append(a);a.setAttribute("id","alttext-manager-mask");a.setAttribute("maskContentUnits","objectBoundingBox");let s=e.createElement("rect");a.append(s);s.setAttribute("fill","white");s.setAttribute("width","1");s.setAttribute("height","1");s.setAttribute("x","0");s.setAttribute("y","0");s=alt_text_manager_classPrivateFieldSet(Qp,this,e.createElement("rect"));a.append(s);s.setAttribute("fill","black");alt_text_manager_classPrivateFieldGet(Wp,this).append(t)}function alt_text_manager_setPosition(){if(!alt_text_manager_classPrivateFieldGet(Op,this))return;const e=alt_text_manager_classPrivateFieldGet(Wp,this),{style:t}=e,{x:i,y:a,width:s,height:r}=alt_text_manager_classPrivateFieldGet(Jp,this).getBoundingClientRect(),{innerWidth:n,innerHeight:o}=window,{width:l,height:d}=e.getBoundingClientRect(),{x:c,y:h,width:_,height:u}=alt_text_manager_classPrivateFieldGet(Op,this).getClientDimensions(),p=10,g="ltr"===alt_text_manager_classPrivateFieldGet(Kp,this).direction,m=Math.max(c,i),f=Math.min(c+_,i+s),v=Math.max(h,a),P=Math.min(h+u,a+r);alt_text_manager_classPrivateFieldGet(Qp,this).setAttribute("width",""+(f-m)/n);alt_text_manager_classPrivateFieldGet(Qp,this).setAttribute("height",""+(P-v)/o);alt_text_manager_classPrivateFieldGet(Qp,this).setAttribute("x",""+m/n);alt_text_manager_classPrivateFieldGet(Qp,this).setAttribute("y",""+v/o);let w=null,F=Math.max(h,0);F+=Math.min(o-(F+d),0);g?c+_+p+l<n?w=c+_+p:c>l+p&&(w=c-l-p):c>l+p?w=c-l-p:c+_+p+l<n&&(w=c+_+p);if(null===w){F=null;w=Math.max(c,0);w+=Math.min(n-(w+l),0);h>d+p?F=h-d-p:h+u+p+d<o&&(F=h+u+p)}if(null!==F){e.classList.add("positioned");g?t.left=`${w}px`:t.right=n-w-l+"px";t.top=`${F}px`}else{e.classList.remove("positioned");t.left="";t.top=""}}function alt_text_manager_finish(){alt_text_manager_classPrivateFieldGet(Hp,this).closeIfActive(alt_text_manager_classPrivateFieldGet(Wp,this))}function alt_text_manager_close(){alt_text_manager_classPrivateFieldGet(Op,this)._reportTelemetry(alt_text_manager_classPrivateFieldGet(eg,this)||{action:"alt_text_cancel",alt_text_keyboard:!alt_text_manager_classPrivateFieldGet(Vp,this)});alt_text_manager_classPrivateFieldSet(eg,this,null);alt_text_manager_assertClassBrand(tg,this,_removeOnClickListeners).call(this);alt_text_manager_classPrivateFieldGet(Kp,this)?.addEditListeners();alt_text_manager_classPrivateFieldGet(Yp,this)?.abort();alt_text_manager_classPrivateFieldSet(Yp,this,null);alt_text_manager_classPrivateFieldGet(Op,this).altTextFinish();alt_text_manager_classPrivateFieldSet(Op,this,null);alt_text_manager_classPrivateFieldSet(Kp,this,null)}function _updateUIState(){alt_text_manager_classPrivateFieldGet(Xp,this).disabled=alt_text_manager_classPrivateFieldGet(zp,this).checked}function alt_text_manager_save(){const e=alt_text_manager_classPrivateFieldGet(Xp,this).value.trim(),t=alt_text_manager_classPrivateFieldGet(zp,this).checked;alt_text_manager_classPrivateFieldGet(Op,this).altTextData={altText:e,decorative:t};alt_text_manager_classPrivateFieldSet(eg,this,{action:"alt_text_save",alt_text_description:!!e,alt_text_edit:!!alt_text_manager_classPrivateFieldGet(qp,this)&&alt_text_manager_classPrivateFieldGet(qp,this)!==e,alt_text_decorative:t,alt_text_keyboard:!alt_text_manager_classPrivateFieldGet(Vp,this)});alt_text_manager_assertClassBrand(tg,this,alt_text_manager_finish).call(this)}function _onClick(e){if(0!==e.detail){alt_text_manager_classPrivateFieldSet(Vp,this,!0);alt_text_manager_assertClassBrand(tg,this,_removeOnClickListeners).call(this)}}function _removeOnClickListeners(){alt_text_manager_classPrivateFieldGet(Rp,this)?.abort();alt_text_manager_classPrivateFieldSet(Rp,this,null)}function annotation_editor_params_classPrivateMethodInitSpec(e,t){(function annotation_editor_params_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}var ig,ag=new WeakSet;class AnnotationEditorParams{constructor(e,t){annotation_editor_params_classPrivateMethodInitSpec(this,ag);this.eventBus=t;(function annotation_editor_params_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")})(ag,this,_bindListeners).call(this,e)}}function _bindListeners({editorFreeTextFontSize:e,editorFreeTextColor:t,editorInkColor:i,editorInkThickness:a,editorInkOpacity:s,editorEraserThickness:r,editorStampAddImage:n,editorFreeHighlightThickness:o,editorHighlightShowAll:l,editorSignatureAddSignature:d}){const{eventBus:c}=this,dispatchEvent=(e,t)=>{c.dispatch("switchannotationeditorparams",{source:this,type:v[e],value:t})};e.addEventListener("input",function(){dispatchEvent("FREETEXT_SIZE",this.valueAsNumber)});t.addEventListener("input",function(){dispatchEvent("FREETEXT_COLOR",this.value)});let h,_;if(FeatureTest.isAlphaColorInputSupported){i.setAttribute("alpha","");s.closest(".editorParamsSetter")?.remove();let e="#000000",t=1;i.addEventListener("input",function(){const i=getRGBA(this.value);if(!i)return;const[a,s,r,n]=i,o=Util.makeHexColor(a,s,r);e=o;t=n;dispatchEvent("INK_COLOR_AND_OPACITY",{color:o,opacity:n})});h=a=>{e=a;const s=Util.hexNums[Math.round(255*t)];i.value=e+s};_=a=>{t=a;const s=Util.hexNums[Math.round(255*t)];i.value=e+s}}else{i.addEventListener("input",function(){dispatchEvent("INK_COLOR",this.value)});s.addEventListener("input",function(){dispatchEvent("INK_OPACITY",this.valueAsNumber)});h=e=>{i.value=e};_=e=>{s.value=e}}a.addEventListener("input",function(){dispatchEvent("INK_THICKNESS",this.valueAsNumber)});r?.addEventListener("input",function(){dispatchEvent("ERASER_THICKNESS",this.valueAsNumber)});n.addEventListener("click",()=>{c.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{action:"pdfjs.image.add_image_click"}}});dispatchEvent("CREATE")});o.addEventListener("input",function(){dispatchEvent("HIGHLIGHT_THICKNESS",this.valueAsNumber)});l.addEventListener("click",function(){const e="true"===this.getAttribute("aria-pressed");this.setAttribute("aria-pressed",!e);dispatchEvent("HIGHLIGHT_SHOW_ALL",!e)});d?.addEventListener("click",()=>{dispatchEvent("CREATE")});c.on("annotationeditorparamschanged",i=>{for(const[s,n]of i.details)switch(s){case v.FREETEXT_SIZE:e.value=n;break;case v.FREETEXT_COLOR:t.value=n;break;case v.INK_COLOR:h(n);break;case v.INK_THICKNESS:a.value=n;break;case v.INK_OPACITY:_(n);break;case v.ERASER_THICKNESS:r&&(r.value=n);break;case v.HIGHLIGHT_COLOR:c.dispatch("mainhighlightcolorpickerupdatecolor",{source:this,value:n});break;case v.HIGHLIGHT_THICKNESS:o.value=n;break;case v.HIGHLIGHT_FREE:o.disabled=!n;break;case v.HIGHLIGHT_SHOW_ALL:l.setAttribute("aria-pressed",n)}},lu)}function caret_browsing_classPrivateFieldInitSpec(e,t,i){caret_browsing_checkPrivateRedeclaration(e,t),t.set(e,i)}function caret_browsing_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function caret_browsing_classPrivateFieldGet(e,t){return e.get(caret_browsing_assertClassBrand(e,t))}function caret_browsing_classPrivateFieldSet(e,t,i){return e.set(caret_browsing_assertClassBrand(e,t),i),i}function caret_browsing_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const sg=.1;var rg=new WeakMap,ng=new WeakMap,og=new WeakMap,lg=new WeakSet;class CaretBrowsingMode{constructor(e,t,i,a){!function caret_browsing_classPrivateMethodInitSpec(e,t){caret_browsing_checkPrivateRedeclaration(e,t),t.add(e)}(this,lg);caret_browsing_classPrivateFieldInitSpec(this,rg,void 0);caret_browsing_classPrivateFieldInitSpec(this,ng,0);caret_browsing_classPrivateFieldInitSpec(this,og,void 0);caret_browsing_classPrivateFieldSet(rg,this,t);caret_browsing_classPrivateFieldSet(og,this,i);if(!a)return;caret_browsing_classPrivateFieldSet(ng,this,a.getBoundingClientRect().height);const s=new ResizeObserver(e=>{for(const t of e)if(t.target===a){caret_browsing_classPrivateFieldSet(ng,this,Math.floor(t.borderBoxSize[0].blockSize));break}});s.observe(a);e.addEventListener("abort",()=>s.disconnect(),{once:!0})}moveCaret(e,t){const i=document.getSelection();if(0===i.rangeCount)return;const{focusNode:a}=i,s=a.nodeType!==Node.ELEMENT_NODE?a.parentElement:a,r=s.closest(".textLayer");if(!r)return;const n=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);n.currentNode=a;const o=s.getBoundingClientRect();let l=null;const d=(e?n.previousSibling:n.nextSibling).bind(n);for(;d();){const e=n.currentNode.parentElement;if(!caret_browsing_assertClassBrand(lg,this,_isOnSameLine).call(this,o,e.getBoundingClientRect())){l=e;break}}if(!l){const s=caret_browsing_assertClassBrand(lg,this,_getNodeOnNextPage).call(this,r,e);if(!s)return;if(t){const t=(e?n.firstChild():n.lastChild())||a;i.extend(t,e?0:t.length);const r=document.createRange();r.setStart(s,e?s.length:0);r.setEnd(s,e?s.length:0);i.addRange(r);return}const[o]=caret_browsing_assertClassBrand(lg,this,_getCaretPosition).call(this,i,e),{parentElement:l}=s;caret_browsing_assertClassBrand(lg,this,_setCaretPosition).call(this,t,i,l,l.getBoundingClientRect(),o);return}const[c,h]=caret_browsing_assertClassBrand(lg,this,_getCaretPosition).call(this,i,e),_=l.getBoundingClientRect();if(caret_browsing_assertClassBrand(lg,this,_isUnderOver).call(this,_,c,h,e))caret_browsing_assertClassBrand(lg,this,_setCaretPosition).call(this,t,i,l,_,c);else{for(;d();){const a=n.currentNode.parentElement,s=a.getBoundingClientRect();if(!caret_browsing_assertClassBrand(lg,this,_isOnSameLine).call(this,_,s))break;if(caret_browsing_assertClassBrand(lg,this,_isUnderOver).call(this,s,c,h,e)){caret_browsing_assertClassBrand(lg,this,_setCaretPosition).call(this,t,i,a,s,c);return}}caret_browsing_assertClassBrand(lg,this,_setCaretPosition).call(this,t,i,l,_,c)}}}ig=CaretBrowsingMode;function _isOnSameLine(e,t){const i=e.y,a=e.bottom,s=e.y+e.height/2,r=t.y,n=t.bottom,o=t.y+t.height/2;return i<=o&&o<=a||r<=s&&s<=n}function _isUnderOver(e,t,i,a){const s=e.y+e.height/2;return(a?i>=s:i<=s)&&e.x-sg<=t&&t<=e.right+sg}function _isVisible(e){return e.top>=caret_browsing_classPrivateFieldGet(ng,this)&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function _getCaretPosition(e,t){const{focusNode:i,focusOffset:a}=e,s=document.createRange();s.setStart(i,a);s.setEnd(i,a);const r=s.getBoundingClientRect();return[r.x,t?r.top:r.bottom]}function _caretPositionFromPoint(e,t){if(!document.caretPositionFromPoint){const{startContainer:i,startOffset:a}=document.caretRangeFromPoint(e,t);return{offsetNode:i,offset:a}}return document.caretPositionFromPoint(e,t)}function _setCaretPositionHelper(e,t,i,a,s){s||=a.getBoundingClientRect();if(t<=s.x+sg){i?e.extend(a.firstChild,0):e.setPosition(a.firstChild,0);return}if(s.right-sg<=t){const{lastChild:t}=a;i?e.extend(t,t.length):e.setPosition(t,t.length);return}const r=s.y+s.height/2;let n=_caretPositionFromPoint.call(ig,t,r),o=n.offsetNode?.parentElement;if(o&&o!==a){const e=document.elementsFromPoint(t,r),i=[];for(const t of e){if(t===a)break;const{style:e}=t;i.push([t,e.visibility]);e.visibility="hidden"}n=_caretPositionFromPoint.call(ig,t,r);o=n.offsetNode?.parentElement;for(const[e,t]of i)e.style.visibility=t}o===a?i?e.extend(n.offsetNode,n.offset):e.setPosition(n.offsetNode,n.offset):i?e.extend(a.firstChild,0):e.setPosition(a.firstChild,0)}function _setCaretPosition(e,t,i,a,s){if(caret_browsing_assertClassBrand(lg,this,_isVisible).call(this,a))caret_browsing_assertClassBrand(lg,this,_setCaretPositionHelper).call(this,t,s,e,i,a);else{caret_browsing_classPrivateFieldGet(rg,this).addEventListener("scrollend",caret_browsing_assertClassBrand(lg,this,_setCaretPositionHelper).bind(this,t,s,e,i,null),{once:!0});i.scrollIntoView()}}function _getNodeOnNextPage(e,t){for(;;){const i=e.closest(".page"),a=parseInt(i.getAttribute("data-page-number"),10),s=t?a-1:a+1;if(!(e=caret_browsing_classPrivateFieldGet(og,this).querySelector(`.page[data-page-number="${s}"] .textLayer`)))return null;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=t?r.lastChild():r.firstChild();if(n)return n}}function sidebar_classPrivateFieldInitSpec(e,t,i){sidebar_checkPrivateRedeclaration(e,t),t.set(e,i)}function sidebar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function sidebar_classPrivateFieldGet(e,t){return e.get(sidebar_assertClassBrand(e,t))}function sidebar_classPrivateFieldSet(e,t,i){return e.set(sidebar_assertClassBrand(e,t),i),i}function sidebar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var dg=new WeakMap,cg=new WeakMap,hg=new WeakMap,_g=new WeakMap,ug=new WeakMap,pg=new WeakMap,gg=new WeakMap,mg=new WeakMap,fg=new WeakMap,vg=new WeakSet;class Sidebar{constructor({sidebar:e,resizer:t,toggleButton:i},a,s,r){!function sidebar_classPrivateMethodInitSpec(e,t){sidebar_checkPrivateRedeclaration(e,t),t.add(e)}(this,vg);sidebar_classPrivateFieldInitSpec(this,dg,0);sidebar_classPrivateFieldInitSpec(this,cg,0);sidebar_classPrivateFieldInitSpec(this,hg,void 0);sidebar_classPrivateFieldInitSpec(this,_g,null);sidebar_classPrivateFieldInitSpec(this,ug,void 0);sidebar_classPrivateFieldInitSpec(this,pg,void 0);sidebar_classPrivateFieldInitSpec(this,gg,!1);sidebar_classPrivateFieldInitSpec(this,mg,void 0);sidebar_classPrivateFieldInitSpec(this,fg,0);if(!e){console.warn("[Sidebar] sidebar element is null, skipping initialization");this._sidebar=null;return}this._sidebar=e;sidebar_classPrivateFieldSet(hg,this,a===s?-1:1);sidebar_classPrivateFieldSet(ug,this,t);sidebar_classPrivateFieldSet(pg,this,s);const n=window.getComputedStyle(e);sidebar_classPrivateFieldSet(dg,this,sidebar_classPrivateFieldSet(cg,this,parseFloat(n.getPropertyValue("--sidebar-width"))));t.ariaValueMin=parseFloat(n.getPropertyValue("--sidebar-min-width"))||0;t.ariaValueMax=parseFloat(n.getPropertyValue("--sidebar-max-width"))||1/0;t.ariaValueNow=sidebar_classPrivateFieldGet(cg,this);sidebar_assertClassBrand(vg,this,_makeSidebarResizable).call(this);this._isOpen=!1;e.hidden=!0;r?.addEventListener("abort",this.destroy.bind(this),{once:!0});sidebar_classPrivateFieldSet(mg,this,new ResizeObserver(([{borderBoxSize:[{inlineSize:e}]}])=>{isNaN(sidebar_classPrivateFieldGet(fg,this))||sidebar_classPrivateFieldSet(fg,this,sidebar_classPrivateFieldGet(fg,this)+sidebar_classPrivateFieldGet(hg,this)*(e-sidebar_classPrivateFieldGet(cg,this)));sidebar_assertClassBrand(vg,this,_setWidth).call(this,e)}));sidebar_classPrivateFieldGet(mg,this).observe(e)}get width(){return sidebar_classPrivateFieldGet(cg,this)}set width(e){this._sidebar&&(this._sidebar.style.width=`${e}px`)}onStartResizing(){}onStopResizing(){}onResizing(e){}toggle(e=!this._isOpen){this._sidebar&&(this._sidebar.hidden=!(this._isOpen=e))}destroy(){sidebar_classPrivateFieldGet(mg,this)?.disconnect();sidebar_classPrivateFieldSet(mg,this,null)}}function _makeSidebarResizable(){if(!this._sidebar)return;const e=this._sidebar.style;let t;const cancelResize=()=>{sidebar_classPrivateFieldSet(_g,this,null);this._sidebar.classList.remove("resizing");t?.abort();t=null;sidebar_classPrivateFieldSet(gg,this,!1);this.onStopResizing();sidebar_classPrivateFieldSet(fg,this,NaN)};sidebar_classPrivateFieldGet(ug,this).addEventListener("pointerdown",i=>{if(t){cancelResize();return}this.onStartResizing();const{clientX:a}=i;stopEvent(i);sidebar_classPrivateFieldSet(fg,this,a);t=new AbortController;const{signal:s}=t,r=this._sidebar;r.classList.add("resizing");r.parentElement.style.minWidth=0;window.addEventListener("contextmenu",noContextMenu,{signal:s});window.addEventListener("pointermove",i=>{if(t&&!(Math.abs(i.clientX-sidebar_classPrivateFieldGet(fg,this))<1)){stopEvent(i);e.width=`${Math.round(sidebar_classPrivateFieldGet(cg,this)+sidebar_classPrivateFieldGet(hg,this)*(i.clientX-sidebar_classPrivateFieldGet(fg,this)))}px`}},{signal:s,capture:!0});window.addEventListener("blur",cancelResize,{signal:s});window.addEventListener("pointerup",e=>{if(t){cancelResize();stopEvent(e)}},{signal:s})});sidebar_classPrivateFieldGet(ug,this).addEventListener("keydown",t=>{const{key:i}=t,a="ArrowLeft"===i;if(a||"ArrowRight"===i){if(!sidebar_classPrivateFieldGet(gg,this)){this._sidebar.classList.add("resizing");sidebar_classPrivateFieldSet(gg,this,!0);this.onStartResizing()}const i=(t.ctrlKey||t.metaKey?10:1)*(a?-1:1);clearTimeout(sidebar_classPrivateFieldGet(_g,this));sidebar_classPrivateFieldSet(_g,this,setTimeout(cancelResize,400));e.width=`${Math.round(sidebar_classPrivateFieldGet(cg,this)+sidebar_classPrivateFieldGet(hg,this)*i)}px`;stopEvent(t)}})}function _setWidth(e){sidebar_classPrivateFieldSet(cg,this,e);sidebar_classPrivateFieldGet(ug,this).ariaValueNow=Math.round(e);sidebar_classPrivateFieldGet(pg,this)&&this._sidebar?.parentElement&&(this._sidebar.parentElement.style.insetInlineStart=`${(sidebar_classPrivateFieldGet(dg,this)-e).toFixed(3)}px`);this.onResizing(e)}function comment_manager_classPrivateMethodInitSpec(e,t){comment_manager_checkPrivateRedeclaration(e,t),t.add(e)}function comment_manager_classPrivateFieldInitSpec(e,t,i){comment_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function comment_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function comment_manager_classPrivateFieldGet(e,t){return e.get(comment_manager_assertClassBrand(e,t))}function comment_manager_classPrivateFieldSet(e,t,i){return e.set(comment_manager_assertClassBrand(e,t),i),i}function comment_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Pg=new WeakMap,wg=new WeakMap,Fg=new WeakMap;class CommentManager{constructor(e,t,i,a,s,r,n,o){comment_manager_classPrivateFieldInitSpec(this,Pg,void 0);comment_manager_classPrivateFieldInitSpec(this,wg,void 0);comment_manager_classPrivateFieldInitSpec(this,Fg,void 0);const l=new Intl.DateTimeFormat(void 0,{dateStyle:"long"});this.dialogElement=e.dialog;comment_manager_classPrivateFieldSet(Pg,this,new CommentDialog(e,s,i,r));comment_manager_classPrivateFieldSet(wg,this,new CommentPopup(i,l,r,this.dialogElement));comment_manager_classPrivateFieldSet(Fg,this,new CommentSidebar(t,i,a,comment_manager_classPrivateFieldGet(wg,this),l,r,o));comment_manager_classPrivateFieldGet(wg,this).sidebar=comment_manager_classPrivateFieldGet(Fg,this);yg._=n}setSidebarUiManager(e){comment_manager_classPrivateFieldGet(Fg,this).setUIManager(e)}showSidebar(e){comment_manager_classPrivateFieldGet(Fg,this).show(e)}hideSidebar(){comment_manager_classPrivateFieldGet(Fg,this).hide()}removeComments(e){comment_manager_classPrivateFieldGet(Fg,this).removeComments(e)}selectComment(e){comment_manager_classPrivateFieldGet(Fg,this).selectComment(null,e)}addComment(e){comment_manager_classPrivateFieldGet(Fg,this).addComment(e)}updateComment(e){comment_manager_classPrivateFieldGet(Fg,this).updateComment(e)}toggleCommentPopup(e,t,i,a){t&&this.selectComment(e.uid);comment_manager_classPrivateFieldGet(wg,this).toggle(e,t,i,a)}destroyPopup(){comment_manager_classPrivateFieldGet(wg,this).destroy()}updatePopupColor(e){comment_manager_classPrivateFieldGet(wg,this).updateColor(e)}showDialog(e,t,i,a,s){return comment_manager_classPrivateFieldGet(Pg,this).open(e,t,i,a,s)}makeCommentColor(e,t){return CommentManager._makeCommentColor(e,t)}static _makeCommentColor(e,t){return comment_manager_assertClassBrand(CommentManager,this,yg)._?null:findContrastColor(applyOpacity(e,t??1),CSSConstants.commentForegroundColor)}destroy(){comment_manager_classPrivateFieldGet(Pg,this).destroy();comment_manager_classPrivateFieldGet(Fg,this).hide();comment_manager_classPrivateFieldGet(wg,this).destroy()}}var yg={_:null},bg=new WeakMap,Sg=new WeakMap,Cg=new WeakMap,xg=new WeakMap,kg=new WeakMap,Eg=new WeakMap,Ag=new WeakMap,Gg=new WeakMap,Bg=new WeakMap,Mg=new WeakMap,Ig=new WeakMap,Tg=new WeakMap,Dg=new WeakMap,Lg=new WeakMap,Rg=new WeakMap,Og=new WeakSet;class CommentSidebar extends Sidebar{constructor({learnMoreUrl:e,sidebar:t,sidebarResizer:i,commentsList:a,commentCount:s,sidebarTitle:r,closeButton:n,commentToolbarButton:o},l,d,c,h,_,u){super({sidebar:t,resizer:i,toggleButton:o},_,!0,u);comment_manager_classPrivateMethodInitSpec(this,Og);comment_manager_classPrivateFieldInitSpec(this,bg,null);comment_manager_classPrivateFieldInitSpec(this,Sg,void 0);comment_manager_classPrivateFieldInitSpec(this,Cg,comment_manager_assertClassBrand(Og,this,_commentClick).bind(this));comment_manager_classPrivateFieldInitSpec(this,xg,comment_manager_assertClassBrand(Og,this,_commentKeydown).bind(this));comment_manager_classPrivateFieldInitSpec(this,kg,void 0);comment_manager_classPrivateFieldInitSpec(this,Eg,void 0);comment_manager_classPrivateFieldInitSpec(this,Ag,void 0);comment_manager_classPrivateFieldInitSpec(this,Gg,void 0);comment_manager_classPrivateFieldInitSpec(this,Bg,void 0);comment_manager_classPrivateFieldInitSpec(this,Mg,void 0);comment_manager_classPrivateFieldInitSpec(this,Ig,void 0);comment_manager_classPrivateFieldInitSpec(this,Tg,void 0);comment_manager_classPrivateFieldInitSpec(this,Dg,null);comment_manager_classPrivateFieldInitSpec(this,Lg,null);comment_manager_classPrivateFieldInitSpec(this,Rg,null);if(!t)return;comment_manager_classPrivateFieldSet(Bg,this,r);comment_manager_classPrivateFieldSet(Eg,this,a);comment_manager_classPrivateFieldSet(Ag,this,s);comment_manager_classPrivateFieldSet(Mg,this,e);comment_manager_classPrivateFieldSet(Ig,this,d);comment_manager_classPrivateFieldSet(kg,this,n);comment_manager_classPrivateFieldSet(Tg,this,c);comment_manager_classPrivateFieldSet(Gg,this,h);comment_manager_classPrivateFieldSet(Sg,this,l);n.addEventListener("click",()=>{l.dispatch("switchannotationeditormode",{source:this,mode:f.NONE})});const keyDownCallback=e=>{if("ArrowDown"===e.key||"Home"===e.key||"F6"===e.key){comment_manager_classPrivateFieldGet(Eg,this).firstElementChild.focus();stopEvent(e)}else if("ArrowUp"===e.key||"End"===e.key){comment_manager_classPrivateFieldGet(Eg,this).lastElementChild.focus();stopEvent(e)}};o?.addEventListener("keydown",keyDownCallback);t.addEventListener("keydown",keyDownCallback)}setUIManager(e){comment_manager_classPrivateFieldSet(Rg,this,e)}show(e){comment_manager_classPrivateFieldSet(Dg,this,new WeakMap);comment_manager_classPrivateFieldSet(Lg,this,new Map);comment_manager_classPrivateFieldSet(bg,this,e);e.sort(comment_manager_assertClassBrand(Og,this,_sortComments).bind(this));if(0!==e.length){const t=document.createDocumentFragment();for(const i of e)t.append(comment_manager_assertClassBrand(Og,this,_createCommentElement).call(this,i));comment_manager_assertClassBrand(Og,this,_setCommentsCount).call(this,t);comment_manager_classPrivateFieldGet(Eg,this).append(t)}else comment_manager_assertClassBrand(Og,this,_setCommentsCount).call(this);this._sidebar.hidden=!1;comment_manager_classPrivateFieldGet(Sg,this).dispatch("reporttelemetry",{source:this,details:{type:"commentSidebar",data:{numberOfAnnotations:e.length}}})}hide(){this._sidebar.hidden=!0;comment_manager_classPrivateFieldGet(Eg,this).replaceChildren();comment_manager_classPrivateFieldSet(Dg,this,null);comment_manager_classPrivateFieldSet(Lg,this,null);comment_manager_classPrivateFieldSet(bg,this,null)}removeComments(e){if(0!==e.length&&comment_manager_classPrivateFieldGet(Lg,this))if(new Set(comment_manager_classPrivateFieldGet(Lg,this).keys()).isSubsetOf(new Set(e)))comment_manager_assertClassBrand(Og,this,_removeAll).call(this);else for(const t of e)comment_manager_assertClassBrand(Og,this,_removeComment).call(this,t)}focusComment(e){const t=comment_manager_classPrivateFieldGet(Lg,this).get(e);if(t){this._sidebar.scrollTop=t.offsetTop-this._sidebar.offsetTop;for(const e of comment_manager_classPrivateFieldGet(Eg,this).children)e.classList.toggle("selected",e===t)}}updateComment(e){if(!comment_manager_classPrivateFieldGet(Lg,this))return;const{id:t,creationDate:i,modificationDate:a,richText:s,contentsObj:r,popupRef:n}=e;n&&(s||r?.str)||comment_manager_assertClassBrand(Og,this,_removeComment).call(this,t);const o=comment_manager_classPrivateFieldGet(Lg,this).get(t);if(!o)return;const l=comment_manager_classPrivateFieldGet(Dg,this).get(o);let d=binarySearchFirstItem(comment_manager_classPrivateFieldGet(bg,this),e=>comment_manager_assertClassBrand(Og,this,_sortComments).call(this,e,l)>=0);if(!(d>=comment_manager_classPrivateFieldGet(bg,this).length)){comment_manager_assertClassBrand(Og,this,_setDate).call(this,o.firstElementChild,a||i);comment_manager_assertClassBrand(Og,this,_setText).call(this,o.lastElementChild,s,r);comment_manager_classPrivateFieldGet(bg,this).splice(d,1);d=binarySearchFirstItem(comment_manager_classPrivateFieldGet(bg,this),t=>comment_manager_assertClassBrand(Og,this,_sortComments).call(this,t,e)>=0);comment_manager_classPrivateFieldGet(bg,this).splice(d,0,e);d>=comment_manager_classPrivateFieldGet(Eg,this).children.length?comment_manager_classPrivateFieldGet(Eg,this).append(o):comment_manager_classPrivateFieldGet(Eg,this).insertBefore(o,comment_manager_classPrivateFieldGet(Eg,this).children[d])}}selectComment(e,t=null){if(!comment_manager_classPrivateFieldGet(Lg,this))return;const i=!e;e||=comment_manager_classPrivateFieldGet(Lg,this).get(t);for(const t of comment_manager_classPrivateFieldGet(Eg,this).children)t.classList.toggle("selected",t===e);i&&e?.scrollIntoView({behavior:"instant",block:"center"})}addComment(e){if(comment_manager_classPrivateFieldGet(Lg,this)?.has(e.id))return;const{popupRef:t,contentsObj:i}=e;if(!t||!i?.str)return;const a=comment_manager_assertClassBrand(Og,this,_createCommentElement).call(this,e);if(0===comment_manager_classPrivateFieldGet(bg,this).length){comment_manager_classPrivateFieldGet(Eg,this).replaceChildren(a);comment_manager_classPrivateFieldGet(bg,this).push(e);comment_manager_assertClassBrand(Og,this,_setCommentsCount).call(this);return}const s=binarySearchFirstItem(comment_manager_classPrivateFieldGet(bg,this),t=>comment_manager_assertClassBrand(Og,this,_sortComments).call(this,t,e)>=0);comment_manager_classPrivateFieldGet(bg,this).splice(s,0,e);s>=comment_manager_classPrivateFieldGet(Eg,this).children.length?comment_manager_classPrivateFieldGet(Eg,this).append(a):comment_manager_classPrivateFieldGet(Eg,this).insertBefore(a,comment_manager_classPrivateFieldGet(Eg,this).children[s]);comment_manager_assertClassBrand(Og,this,_setCommentsCount).call(this)}}function _removeComment(e){const t=comment_manager_classPrivateFieldGet(Lg,this)?.get(e);if(!t)return;const i=comment_manager_classPrivateFieldGet(Dg,this).get(t),a=binarySearchFirstItem(comment_manager_classPrivateFieldGet(bg,this),e=>comment_manager_assertClassBrand(Og,this,_sortComments).call(this,e,i)>=0);if(!(a>=comment_manager_classPrivateFieldGet(bg,this).length)){comment_manager_classPrivateFieldGet(bg,this).splice(a,1);t.remove();comment_manager_classPrivateFieldGet(Lg,this).delete(e);comment_manager_assertClassBrand(Og,this,_setCommentsCount).call(this)}}function _removeAll(){comment_manager_classPrivateFieldGet(Eg,this).replaceChildren();comment_manager_classPrivateFieldSet(Dg,this,new WeakMap);comment_manager_classPrivateFieldGet(Lg,this).clear();comment_manager_classPrivateFieldGet(bg,this).length=0;comment_manager_assertClassBrand(Og,this,_setCommentsCount).call(this)}function _setCommentsCount(e=comment_manager_classPrivateFieldGet(Eg,this)){const t=comment_manager_classPrivateFieldGet(Lg,this).size;comment_manager_classPrivateFieldGet(Bg,this).setAttribute("data-l10n-args",JSON.stringify({count:t}));comment_manager_classPrivateFieldGet(Ag,this).textContent=t;0===t&&e.append(comment_manager_assertClassBrand(Og,this,_createZeroCommentElement).call(this))}function _createZeroCommentElement(){const e=document.createElement("li");e.classList.add("sidebarComment","noComments");const t=document.createElement("div");t.className="sidebarCommentText";t.setAttribute("data-l10n-id","pdfjs-editor-comments-sidebar-no-comments1");e.append(t);if(comment_manager_classPrivateFieldGet(Mg,this)){const t=document.createElement("a");t.setAttribute("data-l10n-id","pdfjs-editor-comments-sidebar-no-comments-link");t.href=comment_manager_classPrivateFieldGet(Mg,this);t.target="_blank";t.rel="noopener noreferrer";e.append(t)}return e}function _setDate(e,t){t=PDFDateString.toDateObject(t);e.dateTime=t.toISOString();e.textContent=comment_manager_classPrivateFieldGet(Gg,this).format(t)}function _setText(e,t,i){e.replaceChildren();renderRichText({html:!t?.str||i?.str&&t.str!==i.str?i?.str:t.html,dir:i?.dir||"auto",className:"richText"},e)}function _createCommentElement(e){const{id:t,creationDate:i,modificationDate:a,richText:s,contentsObj:r,color:n,opacity:o}=e,l=document.createElement("li");l.role="button";l.className="sidebarComment";l.tabIndex=-1;l.style.backgroundColor=n&&CommentManager._makeCommentColor(n,o)||"";const d=document.createElement("time");comment_manager_assertClassBrand(Og,this,_setDate).call(this,d,a||i);const c=document.createElement("div");c.className="sidebarCommentText";comment_manager_assertClassBrand(Og,this,_setText).call(this,c,s,r);l.append(d,c);l.addEventListener("click",comment_manager_classPrivateFieldGet(Cg,this));l.addEventListener("keydown",comment_manager_classPrivateFieldGet(xg,this));comment_manager_classPrivateFieldGet(Dg,this).set(l,e);comment_manager_classPrivateFieldGet(Lg,this).set(t,l);return l}async function _commentClick({currentTarget:e}){if(e.classList.contains("selected")){e.classList.remove("selected");comment_manager_classPrivateFieldGet(Tg,this)._hide();return}const t=comment_manager_classPrivateFieldGet(Dg,this).get(e);if(!t)return;comment_manager_classPrivateFieldGet(Tg,this)._hide();const{id:i,pageIndex:a,rect:s}=t,r=a+1,n=comment_manager_classPrivateFieldGet(Rg,this)?.waitForEditorsRendered(r);comment_manager_classPrivateFieldGet(Ig,this)?.goToXY(r,s[0],s[3],{center:"both"});this.selectComment(e);await n;comment_manager_classPrivateFieldGet(Rg,this)?.selectComment(a,i)}function _commentKeydown(e){const{key:t,currentTarget:i}=e;switch(t){case"ArrowDown":(i.nextElementSibling||comment_manager_classPrivateFieldGet(Eg,this).firstElementChild).focus();stopEvent(e);break;case"ArrowUp":(i.previousElementSibling||comment_manager_classPrivateFieldGet(Eg,this).lastElementChild).focus();stopEvent(e);break;case"Home":comment_manager_classPrivateFieldGet(Eg,this).firstElementChild.focus();stopEvent(e);break;case"End":comment_manager_classPrivateFieldGet(Eg,this).lastElementChild.focus();stopEvent(e);break;case"Enter":case" ":comment_manager_assertClassBrand(Og,this,_commentClick).call(this,e);stopEvent(e);break;case"ShiftTab":comment_manager_classPrivateFieldGet(kg,this).focus();stopEvent(e)}}function _sortComments(e,t){const i=PDFDateString.toDateObject(e.modificationDate||e.creationDate),a=PDFDateString.toDateObject(t.modificationDate||t.creationDate);return i!==a?null!==i&&null!==a?a-i:null!==i?-1:1:e.pageIndex!==t.pageIndex?e.pageIndex-t.pageIndex:e.rect[3]!==t.rect[3]?t.rect[3]-e.rect[3]:e.rect[0]!==t.rect[0]?e.rect[0]-t.rect[0]:e.rect[1]!==t.rect[1]?t.rect[1]-e.rect[1]:e.rect[2]!==t.rect[2]?e.rect[2]-t.rect[2]:e.id.localeCompare(t.id)}var Ng=new WeakMap,Wg=new WeakMap,jg=new WeakMap,Vg=new WeakMap,Ug=new WeakMap,zg=new WeakMap,Hg=new WeakMap,$g=new WeakMap,Xg=new WeakMap,Kg=new WeakMap,qg=new WeakMap,Yg=new WeakMap,Zg=new WeakMap,Qg=new WeakMap,Jg=new WeakMap,em=new WeakMap,tm=new WeakSet;class CommentDialog{constructor({dialog:e,toolbar:t,title:i,textInput:a,cancelButton:s,saveButton:r},n,o,l){comment_manager_classPrivateMethodInitSpec(this,tm);comment_manager_classPrivateFieldInitSpec(this,Ng,void 0);comment_manager_classPrivateFieldInitSpec(this,Wg,void 0);comment_manager_classPrivateFieldInitSpec(this,jg,void 0);comment_manager_classPrivateFieldInitSpec(this,Vg,"");comment_manager_classPrivateFieldInitSpec(this,Ug,"");comment_manager_classPrivateFieldInitSpec(this,zg,void 0);comment_manager_classPrivateFieldInitSpec(this,Hg,void 0);comment_manager_classPrivateFieldInitSpec(this,$g,void 0);comment_manager_classPrivateFieldInitSpec(this,Xg,void 0);comment_manager_classPrivateFieldInitSpec(this,Kg,void 0);comment_manager_classPrivateFieldInitSpec(this,qg,0);comment_manager_classPrivateFieldInitSpec(this,Yg,0);comment_manager_classPrivateFieldInitSpec(this,Zg,0);comment_manager_classPrivateFieldInitSpec(this,Qg,0);comment_manager_classPrivateFieldInitSpec(this,Jg,void 0);comment_manager_classPrivateFieldInitSpec(this,em,void 0);comment_manager_classPrivateFieldSet(Ng,this,e);comment_manager_classPrivateFieldSet(zg,this,a);comment_manager_classPrivateFieldSet(jg,this,n);comment_manager_classPrivateFieldSet(em,this,o);comment_manager_classPrivateFieldSet($g,this,r);comment_manager_classPrivateFieldSet(Xg,this,r.firstElementChild);comment_manager_classPrivateFieldSet(Hg,this,i);comment_manager_classPrivateFieldSet(Jg,this,l);const d=comment_manager_assertClassBrand(tm,this,comment_manager_finish).bind(this);e.addEventListener("close",d);e.addEventListener("contextmenu",e=>{e.target!==comment_manager_classPrivateFieldGet(zg,this)&&e.preventDefault()});s.addEventListener("click",d);r.addEventListener("click",comment_manager_assertClassBrand(tm,this,comment_manager_save).bind(this));a.addEventListener("input",()=>{r.disabled=a.value===comment_manager_classPrivateFieldGet(Vg,this)});a.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||r.disabled||comment_manager_assertClassBrand(tm,this,comment_manager_save).call(this)});let c;const cancelDrag=()=>{e.classList.remove("dragging");c?.abort();c=null};t.addEventListener("pointerdown",t=>{if(c){cancelDrag();return}const{clientX:i,clientY:a}=t;stopEvent(t);comment_manager_classPrivateFieldSet(qg,this,i);comment_manager_classPrivateFieldSet(Yg,this,a);c=new AbortController;const{signal:s}=c,{innerHeight:r,innerWidth:n}=window;e.classList.add("dragging");window.addEventListener("pointermove",e=>{if(!c)return;const{clientX:t,clientY:i}=e;comment_manager_assertClassBrand(tm,this,comment_manager_setPosition).call(this,comment_manager_classPrivateFieldGet(Zg,this)+(t-comment_manager_classPrivateFieldGet(qg,this))/n,comment_manager_classPrivateFieldGet(Qg,this)+(i-comment_manager_classPrivateFieldGet(Yg,this))/r);comment_manager_classPrivateFieldSet(qg,this,t);comment_manager_classPrivateFieldSet(Yg,this,i);stopEvent(e)},{signal:s});window.addEventListener("blur",cancelDrag,{signal:s});window.addEventListener("pointerup",e=>{if(c){cancelDrag();stopEvent(e)}},{signal:s})});n.register(e)}async open(e,t,i,a,s){if(t){comment_manager_classPrivateFieldSet(Kg,this,e);comment_manager_classPrivateFieldSet(Wg,this,t)}const{contentsObj:{str:r},color:n,opacity:o}=t.getData(),{style:l}=comment_manager_classPrivateFieldGet(Ng,this);if(n){l.backgroundColor=CommentManager._makeCommentColor(n,o);l.borderColor=Util.makeHexColor(...n)}else l.backgroundColor=l.borderColor="";comment_manager_classPrivateFieldSet(Ug,this,r||"");const d=comment_manager_classPrivateFieldGet(zg,this);d.value=comment_manager_classPrivateFieldSet(Vg,this,comment_manager_classPrivateFieldGet(Ug,this));if(r){comment_manager_classPrivateFieldGet(Hg,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-title-when-editing");comment_manager_classPrivateFieldGet(Xg,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-save-button-when-editing")}else{comment_manager_classPrivateFieldGet(Hg,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-title-when-adding");comment_manager_classPrivateFieldGet(Xg,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-save-button-when-adding")}s?.height&&(d.style.height=`${s.height}px`);comment_manager_classPrivateFieldGet(Kg,this)?.removeEditListeners();comment_manager_classPrivateFieldGet($g,this).disabled=!0;const c=s?.parentDimensions,{innerHeight:h,innerWidth:_}=window;if(t.hasDefaultPopupPosition()){const{dialogWidth:e,dialogHeight:t}=this._dialogDimensions;if(c)if(comment_manager_classPrivateFieldGet(Jg,this)&&i+e>Math.min(c.x+c.width,_)){i-=e-comment_manager_classPrivateFieldGet(Wg,this).commentButtonWidth*c.width}else if(!comment_manager_classPrivateFieldGet(Jg,this)){const t=comment_manager_classPrivateFieldGet(Wg,this).commentButtonWidth*c.width;i-e<Math.max(0,c.x)?i=Math.max(0,i):i-=e-t}const r=Math.max(t,s?.height||0);a+r>h&&(a=h-r);a<0&&(a=0)}i=MathClamp(i/_,0,1);a=MathClamp(a/h,0,1);comment_manager_assertClassBrand(tm,this,comment_manager_setPosition).call(this,i,a);await comment_manager_classPrivateFieldGet(jg,this).open(comment_manager_classPrivateFieldGet(Ng,this));d.focus()}get _dialogDimensions(){const e=comment_manager_classPrivateFieldGet(Ng,this),{style:t}=e;t.opacity="0";t.display="block";const{width:i,height:a}=e.getBoundingClientRect();t.opacity=t.display="";return shadow(this,"_dialogDimensions",{dialogWidth:i,dialogHeight:a})}destroy(){comment_manager_classPrivateFieldSet(Kg,this,null);comment_manager_classPrivateFieldSet(Wg,this,null);comment_manager_assertClassBrand(tm,this,comment_manager_finish).call(this)}}async function comment_manager_save(){comment_manager_classPrivateFieldGet(Wg,this).comment=comment_manager_classPrivateFieldGet(zg,this).value;comment_manager_assertClassBrand(tm,this,comment_manager_finish).call(this)}function comment_manager_setPosition(e,t){comment_manager_classPrivateFieldSet(Zg,this,e);comment_manager_classPrivateFieldSet(Qg,this,t);const{style:i}=comment_manager_classPrivateFieldGet(Ng,this);i.left=100*e+"%";i.top=100*t+"%"}function comment_manager_finish(){if(!comment_manager_classPrivateFieldGet(Wg,this))return;const e=comment_manager_classPrivateFieldGet(zg,this).value!==comment_manager_classPrivateFieldGet(Ug,this);comment_manager_classPrivateFieldGet(em,this).dispatch("reporttelemetry",{source:this,details:{type:"comment",data:{edited:e}}});e&&comment_manager_classPrivateFieldGet(em,this)?.dispatch("annotation-editor-event",{source:this,type:comment_manager_classPrivateFieldGet(zg,this).value?"commented":"commentRemoved",page:comment_manager_classPrivateFieldGet(Wg,this).pageIndex+1,id:comment_manager_classPrivateFieldGet(Wg,this).uid,editorType:comment_manager_classPrivateFieldGet(Wg,this).constructor.name,value:comment_manager_classPrivateFieldGet(Wg,this)});comment_manager_classPrivateFieldGet(Wg,this)?.focusCommentButton();comment_manager_classPrivateFieldSet(Wg,this,null);comment_manager_classPrivateFieldGet(zg,this).value=comment_manager_classPrivateFieldSet(Vg,this,comment_manager_classPrivateFieldSet(Ug,this,""));comment_manager_classPrivateFieldGet(jg,this).closeIfActive(comment_manager_classPrivateFieldGet(Ng,this));comment_manager_classPrivateFieldGet(zg,this).style.height="";comment_manager_classPrivateFieldGet(Kg,this)?.addEditListeners();comment_manager_classPrivateFieldSet(Kg,this,null)}var im=new WeakMap,am=new WeakMap,sm=new WeakMap,rm=new WeakMap,nm=new WeakMap,om=new WeakMap,lm=new WeakMap,dm=new WeakMap,cm=new WeakMap,hm=new WeakMap,_m=new WeakMap,um=new WeakMap,pm=new WeakMap,gm=new WeakMap,mm=new WeakMap,fm=new WeakMap,vm=new WeakSet;class CommentPopup{constructor(e,t,i,a){comment_manager_classPrivateMethodInitSpec(this,vm);comment_manager_classPrivateFieldInitSpec(this,im,null);comment_manager_classPrivateFieldInitSpec(this,am,void 0);comment_manager_classPrivateFieldInitSpec(this,sm,void 0);comment_manager_classPrivateFieldInitSpec(this,rm,void 0);comment_manager_classPrivateFieldInitSpec(this,nm,null);comment_manager_classPrivateFieldInitSpec(this,om,void 0);comment_manager_classPrivateFieldInitSpec(this,lm,null);comment_manager_classPrivateFieldInitSpec(this,dm,null);comment_manager_classPrivateFieldInitSpec(this,cm,null);comment_manager_classPrivateFieldInitSpec(this,hm,0);comment_manager_classPrivateFieldInitSpec(this,_m,0);comment_manager_classPrivateFieldInitSpec(this,um,0);comment_manager_classPrivateFieldInitSpec(this,pm,0);comment_manager_classPrivateFieldInitSpec(this,gm,null);comment_manager_classPrivateFieldInitSpec(this,mm,!1);comment_manager_classPrivateFieldInitSpec(this,fm,!1);comment_manager_classPrivateFieldSet(am,this,e);comment_manager_classPrivateFieldSet(rm,this,t);comment_manager_classPrivateFieldSet(om,this,i);comment_manager_classPrivateFieldSet(sm,this,a);this.sidebar=null}get _popupWidth(){const e=document.createElement("ngx-extended-pdf-viewer");e.style.opacity="0";e.style.display="block";const t=document.createElement("div");t.classList.add("zoom");e.append(t);const i=comment_manager_assertClassBrand(vm,this,comment_manager_createPopup).call(this);i.style.display="block";t.append(i);document.body.append(e);const a=i.getBoundingClientRect().width;i.remove();e.remove();i.style.display="";return shadow(this,"_popupWidth",a)}updateColor(e){if(comment_manager_classPrivateFieldGet(nm,this)!==e||!comment_manager_classPrivateFieldGet(fm,this))return;const{color:t,opacity:i}=e.getData();comment_manager_classPrivateFieldGet(lm,this).style.backgroundColor=t&&CommentManager._makeCommentColor(t,i)||""}_hide(e){const t=comment_manager_assertClassBrand(vm,this,comment_manager_createPopup).call(this);t.classList.toggle("hidden",!0);t.classList.toggle("selected",!1);(e||comment_manager_classPrivateFieldGet(nm,this))?.setCommentButtonStates({selected:!1,hasPopup:!1});comment_manager_classPrivateFieldSet(nm,this,null);comment_manager_classPrivateFieldSet(mm,this,!1);comment_manager_classPrivateFieldSet(fm,this,!1);comment_manager_classPrivateFieldGet(dm,this).replaceChildren();this.sidebar.selectComment(null)}toggle(e,t,i=void 0,a=!0){if(!e){this.destroy();return}if(t)i??=comment_manager_classPrivateFieldGet(nm,this)!==e||(!comment_manager_classPrivateFieldGet(mm,this)||!comment_manager_classPrivateFieldGet(fm,this));else{if(comment_manager_classPrivateFieldGet(mm,this))return;i??=!comment_manager_classPrivateFieldGet(fm,this)}if(!i){this._hide(e);return}comment_manager_classPrivateFieldSet(fm,this,!0);comment_manager_classPrivateFieldGet(nm,this)!==e&&comment_manager_classPrivateFieldGet(nm,this)?.setCommentButtonStates({selected:!1,hasPopup:!1});const s=comment_manager_assertClassBrand(vm,this,comment_manager_createPopup).call(this);comment_manager_classPrivateFieldGet(im,this).classList.toggle("hidden",!a);s.classList.toggle("hidden",!1);s.classList.toggle("selected",t);comment_manager_classPrivateFieldSet(mm,this,t);comment_manager_classPrivateFieldSet(nm,this,e);e.setCommentButtonStates({selected:t,hasPopup:!0});const{contentsObj:r,richText:n,creationDate:o,modificationDate:l,color:d,opacity:c}=e.getData();s.style.backgroundColor=d&&CommentManager._makeCommentColor(d,c)||"";comment_manager_classPrivateFieldGet(dm,this).replaceChildren();const h=!n?.str||r?.str&&n.str!==r.str?r?.str:n.html;h&&renderRichText({html:h,dir:r?.dir||"auto",className:"richText"},comment_manager_classPrivateFieldGet(dm,this));comment_manager_classPrivateFieldGet(cm,this).textContent=comment_manager_classPrivateFieldGet(rm,this).format(PDFDateString.toDateObject(l||o));comment_manager_assertClassBrand(vm,this,_setPosition2).call(this,...e.commentPopupPosition,e.hasDefaultPopupPosition());e.elementBeforePopup.after(s);s.addEventListener("focus",({relatedTarget:e})=>{comment_manager_classPrivateFieldSet(gm,this,e)},{once:!0});t&&setTimeout(()=>s.focus(),0)}destroy(){this._hide();comment_manager_classPrivateFieldGet(lm,this)?.remove();comment_manager_classPrivateFieldSet(lm,this,comment_manager_classPrivateFieldSet(dm,this,comment_manager_classPrivateFieldSet(cm,this,null)));comment_manager_classPrivateFieldSet(hm,this,comment_manager_classPrivateFieldSet(_m,this,1/0));comment_manager_classPrivateFieldSet(um,this,comment_manager_classPrivateFieldSet(pm,this,0));comment_manager_classPrivateFieldSet(gm,this,null)}}function comment_manager_createPopup(){if(comment_manager_classPrivateFieldGet(lm,this))return comment_manager_classPrivateFieldGet(lm,this);const e=comment_manager_classPrivateFieldSet(lm,this,document.createElement("div"));e.className="commentPopup";e.id="commentPopup";e.tabIndex=-1;e.role="dialog";e.ariaModal="false";e.addEventListener("contextmenu",noContextMenu);e.addEventListener("keydown",e=>{if("Escape"===e.key){this.toggle(comment_manager_classPrivateFieldGet(nm,this),!0,!1);comment_manager_classPrivateFieldGet(gm,this)?.focus();stopEvent(e)}});e.addEventListener("click",()=>{e.focus()});const t=document.createElement("div");t.className="commentPopupTop";const i=comment_manager_classPrivateFieldSet(cm,this,document.createElement("time"));i.className="commentPopupTime";const a=comment_manager_classPrivateFieldSet(im,this,document.createElement("div"));a.className="commentPopupButtons";const s=document.createElement("button");s.classList.add("commentPopupEdit","toolbarButton");s.tabIndex=0;s.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-popup-button");s.ariaHasPopup="dialog";s.ariaControlsElements=[comment_manager_classPrivateFieldGet(sm,this)];const r=document.createElement("span");r.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-popup-button-label");s.append(r);s.addEventListener("click",()=>{const e=comment_manager_classPrivateFieldGet(nm,this),t=parseFloat(getComputedStyle(comment_manager_classPrivateFieldGet(dm,this)).height);this.toggle(e,!0,!1);e.editComment({height:t})});s.addEventListener("contextmenu",noContextMenu);const n=document.createElement("button");n.classList.add("commentPopupDelete","toolbarButton");n.tabIndex=0;n.setAttribute("data-l10n-id","pdfjs-editor-delete-comment-popup-button");const o=document.createElement("span");o.setAttribute("data-l10n-id","pdfjs-editor-delete-comment-popup-button-label");n.append(o);n.addEventListener("click",()=>{comment_manager_classPrivateFieldGet(am,this).dispatch("reporttelemetry",{source:this,details:{type:"comment",data:{deleted:!0}}});const e=comment_manager_classPrivateFieldGet(nm,this),t=e.comment;comment_manager_classPrivateFieldGet(am,this)?.dispatch("annotation-editor-event",{source:this,type:"commentRemoved",page:e.pageIndex+1,id:e.uid,editorType:e.constructor.name,value:e});this.destroy();t?.text?e._uiManager.deleteComment(e,t):e.comment=null;e.focus()});n.addEventListener("contextmenu",noContextMenu);a.append(s,n);t.append(i,a);const l=document.createElement("hr"),d=comment_manager_classPrivateFieldSet(dm,this,document.createElement("div"));d.className="commentPopupText";e.append(t,l,d);let c;const cancelDrag=()=>{e.classList.remove("dragging");c?.abort();c=null};t.addEventListener("pointerdown",t=>{if(c){cancelDrag();return}const{target:i,clientX:s,clientY:r}=t;if(a.contains(i))return;stopEvent(t);const{width:n,height:o}=comment_manager_classPrivateFieldGet(nm,this).parentBoundingClientRect;comment_manager_classPrivateFieldSet(hm,this,s);comment_manager_classPrivateFieldSet(_m,this,r);c=new AbortController;const{signal:l}=c;e.classList.add("dragging");window.addEventListener("pointermove",e=>{if(!c)return;const{clientX:t,clientY:i}=e;comment_manager_assertClassBrand(vm,this,_setPosition2).call(this,comment_manager_classPrivateFieldGet(um,this)+(t-comment_manager_classPrivateFieldGet(hm,this))/n,comment_manager_classPrivateFieldGet(pm,this)+(i-comment_manager_classPrivateFieldGet(_m,this))/o,!1);comment_manager_classPrivateFieldSet(hm,this,t);comment_manager_classPrivateFieldSet(_m,this,i);stopEvent(e)},{signal:l});window.addEventListener("blur",cancelDrag,{signal:l});window.addEventListener("pointerup",e=>{if(c){cancelDrag();stopEvent(e)}},{signal:l})});return e}function _setPosition2(e,t,i){if(i){const t=comment_manager_classPrivateFieldGet(nm,this).parentBoundingClientRect,i=this._popupWidth/t.width;if(comment_manager_classPrivateFieldGet(om,this)&&e+i>1||!comment_manager_classPrivateFieldGet(om,this)&&e-i>=0){e-=i-comment_manager_classPrivateFieldGet(nm,this).commentButtonWidth}const a=.02;e=comment_manager_classPrivateFieldGet(om,this)?Math.max(e,-t.x/t.width+a):Math.min(e,(window.innerWidth-t.x)/t.width-i-a)}else comment_manager_classPrivateFieldGet(nm,this).commentPopupPosition=[e,t];comment_manager_classPrivateFieldSet(um,this,e);comment_manager_classPrivateFieldSet(pm,this,t);const{style:a}=comment_manager_classPrivateFieldGet(lm,this);a.left=100*e+"%";a.top=100*t+"%"}function base_download_manager_classPrivateFieldInitSpec(e,t,i){(function base_download_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function base_download_manager_classPrivateFieldGet(e,t){return e.get(function base_download_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}var Pm=new WeakMap;class BaseDownloadManager{constructor(){base_download_manager_classPrivateFieldInitSpec(this,Pm,new WeakMap)}_triggerDownload(e,t,i,a=!1,s=!1){throw new Error("Not implemented: _triggerDownload")}_getOpenDataUrl(e,t,i=null){throw new Error("Not implemented: _getOpenDataUrl")}downloadData(e,t,i){const a=URL.createObjectURL(new Blob([e],{type:i}));this._triggerDownload(a,a,t,!0)}openOrDownloadData(e,t,i=null){const a=isPdfFile(t),s=a?"application/pdf":"";if(a){const a=base_download_manager_classPrivateFieldGet(Pm,this).getOrInsertComputed(e,()=>URL.createObjectURL(new Blob([e],{type:s})));try{const e=this._getOpenDataUrl(a,t,i);window.open(e);return!0}catch(t){console.error("openOrDownloadData:",t);URL.revokeObjectURL(a);base_download_manager_classPrivateFieldGet(Pm,this).delete(e)}}this.downloadData(e,t,s);return!1}download(e,t,i,a=!1){const s=e?URL.createObjectURL(new Blob([e],{type:"application/pdf"})):null;this._triggerDownload(s,t,i,!1,a)}}class DownloadManager extends BaseDownloadManager{_triggerDownload(e,t,i,a=!1){if(!e&&!a){if(!createValidAbsoluteUrl(t,"http://example.com"))throw new Error(`_triggerDownload - not a valid URL: ${t}`);e=t+"#pdfjs.action=download"}const s=document.createElement("a");s.href=e;s.target="_parent";"download"in s&&(s.download=i);(document.body||document.documentElement).append(s);s.click();s.remove()}_getOpenDataUrl(e,t,i=null){return e}}function editor_undo_bar_defineProperty(e,t,i){return(t=function editor_undo_bar_toPropertyKey(e){var t=function editor_undo_bar_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_undo_bar_classPrivateFieldInitSpec(e,t,i){(function editor_undo_bar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function editor_undo_bar_classPrivateFieldGet(e,t){return e.get(editor_undo_bar_assertClassBrand(e,t))}function editor_undo_bar_classPrivateFieldSet(e,t,i){return e.set(editor_undo_bar_assertClassBrand(e,t),i),i}function editor_undo_bar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var wm=new WeakMap,Fm=new WeakMap,ym=new WeakMap,bm=new WeakMap,Sm=new WeakMap,Cm=new WeakMap,xm=new WeakMap,km=new WeakMap;class EditorUndoBar{constructor({container:e,message:t,undoButton:i,closeButton:a},s){editor_undo_bar_classPrivateFieldInitSpec(this,wm,null);editor_undo_bar_classPrivateFieldInitSpec(this,Fm,void 0);editor_undo_bar_classPrivateFieldInitSpec(this,ym,null);editor_undo_bar_classPrivateFieldInitSpec(this,bm,null);editor_undo_bar_classPrivateFieldInitSpec(this,Sm,null);editor_undo_bar_defineProperty(this,"isOpen",!1);editor_undo_bar_classPrivateFieldInitSpec(this,Cm,void 0);editor_undo_bar_classPrivateFieldInitSpec(this,xm,null);editor_undo_bar_classPrivateFieldInitSpec(this,km,void 0);editor_undo_bar_classPrivateFieldSet(Fm,this,e);editor_undo_bar_classPrivateFieldSet(Cm,this,t);editor_undo_bar_classPrivateFieldSet(km,this,i);editor_undo_bar_classPrivateFieldSet(wm,this,a);editor_undo_bar_classPrivateFieldSet(ym,this,s)}destroy(){editor_undo_bar_classPrivateFieldGet(Sm,this)?.abort();editor_undo_bar_classPrivateFieldSet(Sm,this,null);this.hide()}show(e,t){if(!editor_undo_bar_classPrivateFieldGet(Sm,this)){editor_undo_bar_classPrivateFieldSet(Sm,this,new AbortController);const e={signal:editor_undo_bar_classPrivateFieldGet(Sm,this).signal},t={signal:editor_undo_bar_classPrivateFieldGet(Sm,this).signal,...lu},i=this.hide.bind(this);editor_undo_bar_classPrivateFieldGet(Fm,this).addEventListener("contextmenu",noContextMenu,e);editor_undo_bar_classPrivateFieldGet(wm,this).addEventListener("click",i,e);editor_undo_bar_classPrivateFieldGet(ym,this).on("beforeprint",i,t);editor_undo_bar_classPrivateFieldGet(ym,this).on("download",i,t)}this.hide();if("string"==typeof t)editor_undo_bar_classPrivateFieldGet(Cm,this).setAttribute("data-l10n-id",Em._[t]);else{editor_undo_bar_classPrivateFieldGet(Cm,this).setAttribute("data-l10n-id",Em._._multiple);editor_undo_bar_classPrivateFieldGet(Cm,this).setAttribute("data-l10n-args",JSON.stringify({count:t}))}this.isOpen=!0;editor_undo_bar_classPrivateFieldGet(Fm,this).hidden=!1;editor_undo_bar_classPrivateFieldSet(xm,this,new AbortController);editor_undo_bar_classPrivateFieldGet(km,this).addEventListener("click",()=>{e();this.hide()},{signal:editor_undo_bar_classPrivateFieldGet(xm,this).signal});editor_undo_bar_classPrivateFieldSet(bm,this,setTimeout(()=>{editor_undo_bar_classPrivateFieldGet(Fm,this).contains(document.activeElement)||editor_undo_bar_classPrivateFieldGet(Fm,this).focus();editor_undo_bar_classPrivateFieldSet(bm,this,null)},100))}hide(){if(this.isOpen){this.isOpen=!1;editor_undo_bar_classPrivateFieldGet(Fm,this).hidden=!0;editor_undo_bar_classPrivateFieldGet(xm,this)?.abort();editor_undo_bar_classPrivateFieldSet(xm,this,null);if(editor_undo_bar_classPrivateFieldGet(bm,this)){clearTimeout(editor_undo_bar_classPrivateFieldGet(bm,this));editor_undo_bar_classPrivateFieldSet(bm,this,null)}}}}var Em={_:Object.freeze({highlight:"pdfjs-editor-undo-bar-message-highlight",freetext:"pdfjs-editor-undo-bar-message-freetext",stamp:"pdfjs-editor-undo-bar-message-stamp",ink:"pdfjs-editor-undo-bar-message-ink",signature:"pdfjs-editor-undo-bar-message-signature",comment:"pdfjs-editor-undo-bar-message-comment",_multiple:"pdfjs-editor-undo-bar-message-multiple"})};function overlay_manager_classPrivateFieldInitSpec(e,t,i){(function overlay_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function overlay_manager_classPrivateFieldSet(e,t,i){return e.set(overlay_manager_assertClassBrand(e,t),i),i}function overlay_manager_classPrivateFieldGet(e,t){return e.get(overlay_manager_assertClassBrand(e,t))}function overlay_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Am=new WeakMap,Gm=new WeakMap;class OverlayManager{constructor(){overlay_manager_classPrivateFieldInitSpec(this,Am,new WeakMap);overlay_manager_classPrivateFieldInitSpec(this,Gm,null)}get active(){return overlay_manager_classPrivateFieldGet(Gm,this)}async register(e,t=!1){if("object"!=typeof e)throw new Error("Not enough parameters.");if(overlay_manager_classPrivateFieldGet(Am,this).has(e))throw new Error("The overlay is already registered.");overlay_manager_classPrivateFieldGet(Am,this).set(e,{canForceClose:t});e.addEventListener("cancel",({target:e})=>{overlay_manager_classPrivateFieldGet(Gm,this)===e&&overlay_manager_classPrivateFieldSet(Gm,this,null)})}unregister(e){if(!overlay_manager_classPrivateFieldGet(Am,this).has(e))throw new Error("The overlay does not exist.");overlay_manager_classPrivateFieldGet(Am,this).delete(e)}async open(e){if(!overlay_manager_classPrivateFieldGet(Am,this).has(e))throw new Error("The overlay does not exist.");if(overlay_manager_classPrivateFieldGet(Gm,this)){if(overlay_manager_classPrivateFieldGet(Gm,this)===e)throw new Error("The overlay is already active.");if(!overlay_manager_classPrivateFieldGet(Am,this).get(e).canForceClose)throw new Error("Another overlay is currently active.");await this.close()}overlay_manager_classPrivateFieldSet(Gm,this,e);e.showModal();e.classList.remove("hidden")}async close(e=overlay_manager_classPrivateFieldGet(Gm,this),t=!1){if(!overlay_manager_classPrivateFieldGet(Am,this).has(e)){if(t)return;throw new Error("The overlay does not exist.")}if(!overlay_manager_classPrivateFieldGet(Gm,this)){if(t)return;throw new Error("The overlay is currently not active.")}if(overlay_manager_classPrivateFieldGet(Gm,this)!==e){if(t)return;throw new Error("Another overlay is currently active.")}e.close();overlay_manager_classPrivateFieldSet(Gm,this,null)}async closeIfActive(e){overlay_manager_classPrivateFieldGet(Gm,this)===e&&await this.close(e)}}function password_prompt_classPrivateFieldInitSpec(e,t,i){password_prompt_checkPrivateRedeclaration(e,t),t.set(e,i)}function password_prompt_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function password_prompt_classPrivateFieldSet(e,t,i){return e.set(password_prompt_assertClassBrand(e,t),i),i}function password_prompt_classPrivateFieldGet(e,t){return e.get(password_prompt_assertClassBrand(e,t))}function password_prompt_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Bm=new WeakMap,Mm=new WeakMap,Im=new WeakMap,Tm=new WeakSet;class PasswordPrompt{constructor(e,t,i=!1){!function password_prompt_classPrivateMethodInitSpec(e,t){password_prompt_checkPrivateRedeclaration(e,t),t.add(e)}(this,Tm);password_prompt_classPrivateFieldInitSpec(this,Bm,null);password_prompt_classPrivateFieldInitSpec(this,Mm,null);password_prompt_classPrivateFieldInitSpec(this,Im,null);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",password_prompt_assertClassBrand(Tm,this,_verify).bind(this));this.cancelButton.addEventListener("click",this.close.bind(this));this.input.addEventListener("keydown",e=>{if(13===e.keyCode){password_prompt_assertClassBrand(Tm,this,_verify).call(this);e.preventDefault()}});this.overlayManager.register(this.dialog,!0);this.dialog.addEventListener("close",password_prompt_assertClassBrand(Tm,this,password_prompt_cancel).bind(this))}async open(){await(password_prompt_classPrivateFieldGet(Bm,this)?.promise);password_prompt_classPrivateFieldSet(Bm,this,Promise.withResolvers());try{await this.overlayManager.open(this.dialog);this.input.type="password";this.input.focus()}catch(e){password_prompt_classPrivateFieldGet(Bm,this).resolve();throw e}const e=password_prompt_classPrivateFieldGet(Im,this)===W.INCORRECT_PASSWORD;this._isViewerEmbedded&&!e||this.input.focus();this.label.setAttribute("data-l10n-id",e?"pdfjs-password-invalid":"pdfjs-password-label")}async close(){this.overlayManager.closeIfActive(this.dialog);this.input.value="";this.input.type="text"}async setUpdateCallback(e,t){password_prompt_classPrivateFieldGet(Bm,this)&&await password_prompt_classPrivateFieldGet(Bm,this).promise;password_prompt_classPrivateFieldSet(Mm,this,e);password_prompt_classPrivateFieldSet(Im,this,t)}}function _verify(){const e=this.input.value;e?.length>0&&password_prompt_assertClassBrand(Tm,this,_invokeCallback).call(this,e)}function password_prompt_cancel(){password_prompt_assertClassBrand(Tm,this,_invokeCallback).call(this,new Error("PasswordPrompt cancelled."));password_prompt_classPrivateFieldGet(Bm,this).resolve()}function _invokeCallback(e){if(password_prompt_classPrivateFieldGet(Mm,this)){this.close();this.input.value="";password_prompt_classPrivateFieldGet(Mm,this).call(this,e);password_prompt_classPrivateFieldSet(Mm,this,null)}}const Dm="selected";class BaseTreeViewer{constructor(e){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.replaceChildren();this.container.classList.remove("withNesting")}_dispatchEvent(e){throw new Error("Not implemented: _dispatchEvent")}_bindLink(e,t){throw new Error("Not implemented: _bindLink")}_normalizeTextContent(e){return removeNullCharacters(e,!0)||"–"}_addToggleButton(e,t=!1){const i=document.createElement("div");i.className="treeItemToggler";t&&i.classList.add("treeItemsHidden");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){if(i){this.container.classList.add("withNesting");this._lastToggleIsShow=!e.querySelector(".treeItemsHidden");this.container.addEventListener("click",e=>{const{target:t}=e;if(t.classList.contains("treeItemToggler")){stopEvent(e);t.classList.toggle("treeItemsHidden");if(e.shiftKey){const e=!t.classList.contains("treeItemsHidden");this._toggleTreeItem(t.parentNode,e)}}})}this._l10n.pause();this.container.append(e);this._l10n.resume();this._dispatchEvent(t)}render(e){throw new Error("Not implemented: render")}_updateCurrentTreeItem(e=null){if(this._currentTreeItem){this._currentTreeItem.classList.remove(Dm);this._currentTreeItem=null}if(e){e.classList.add(Dm);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);e.scrollIntoView({behavior:"instant",block:"center",inline:"center",container:"nearest"})}}function pdf_attachment_viewer_classPrivateMethodInitSpec(e,t){(function pdf_attachment_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}var Lm=new WeakSet;class PDFAttachmentViewer extends BaseTreeViewer{constructor(e){super(e);pdf_attachment_viewer_classPrivateMethodInitSpec(this,Lm);this.downloadManager=e.downloadManager;this.linkService=e.linkService;this.eventBus.on("fileattachmentannotation",function pdf_attachment_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(Lm,this,_appendAttachment).bind(this),lu)}reset(e=!1){super.reset();this._attachments=null;e||(this._renderedCapability=Promise.withResolvers());this._pendingDispatchEvent=!1}async _dispatchEvent(e){this._renderedCapability.resolve();if(0===e&&!this._pendingDispatchEvent){this._pendingDispatchEvent=!0;await waitOnEventOrTimeout({target:this.eventBus,name:"annotationlayerrendered",delay:1e3});if(!this._pendingDispatchEvent)return}this._pendingDispatchEvent=!1;this.eventBus.dispatch("attachmentsloaded",{source:this,attachmentsCount:e})}_bindLink(e,{attachmentId:t,content:i,description:a,filename:s}){a&&(e.title=a);const openAttachment=async()=>{const e=t?await this.linkService.getAttachmentContent(t):i;e&&this.downloadManager?.openOrDownloadData(e,s)};e.onclick=()=>{openAttachment();return!1}}render({attachments:e,keepRenderedCapability:t=!1}){this._attachments&&this.reset(t);this._attachments=e||null;if(!e){this._dispatchEvent(0);return}const i=document.createDocumentFragment(),a=document.createElement("ul");i.append(a);let s=0;for(const[t,i]of e){const e=document.createElement("li");a.append(e);const r=document.createElement("a");e.append(r);this._bindLink(r,{...i,attachmentId:i.attachmentId??t});r.textContent=this._normalizeTextContent(i.filename);s++}this._finishRendering(i,s)}}function _appendAttachment(e){const t=this._renderedCapability.promise;t.then(()=>{if(t!==this._renderedCapability.promise)return;const i=new Map(this._attachments);if(!i.has(e.filename)){i.set(e.filename,e);this.render({attachments:i,keepRenderedCapability:!0})}})}function grab_to_pan_classPrivateFieldInitSpec(e,t,i){grab_to_pan_checkPrivateRedeclaration(e,t),t.set(e,i)}function grab_to_pan_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function grab_to_pan_classPrivateFieldSet(e,t,i){return e.set(grab_to_pan_assertClassBrand(e,t),i),i}function grab_to_pan_classPrivateFieldGet(e,t){return e.get(grab_to_pan_assertClassBrand(e,t))}function grab_to_pan_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Rm="grab-to-pan-grab";var Om=new WeakMap,Nm=new WeakMap,Wm=new WeakMap,jm=new WeakMap,Vm=new WeakSet;class GrabToPan{constructor({element:e}){!function grab_to_pan_classPrivateMethodInitSpec(e,t){grab_to_pan_checkPrivateRedeclaration(e,t),t.add(e)}(this,Vm);grab_to_pan_classPrivateFieldInitSpec(this,Om,null);grab_to_pan_classPrivateFieldInitSpec(this,Nm,null);grab_to_pan_classPrivateFieldInitSpec(this,Wm,null);grab_to_pan_classPrivateFieldInitSpec(this,jm,!1);this.element=e;this.document=e.ownerDocument;(this.overlay=document.createElement("div")).className="grab-to-pan-grabbing"}activate(){if(!grab_to_pan_classPrivateFieldGet(Om,this)){grab_to_pan_classPrivateFieldSet(Om,this,new AbortController);this.element.addEventListener("mousedown",grab_to_pan_assertClassBrand(Vm,this,_onMouseDown).bind(this),{capture:!0,signal:grab_to_pan_classPrivateFieldGet(Om,this).signal});this.element.classList.add(Rm)}}deactivate(){if(grab_to_pan_classPrivateFieldGet(Om,this)){grab_to_pan_classPrivateFieldGet(Om,this).abort();grab_to_pan_classPrivateFieldSet(Om,this,null);grab_to_pan_assertClassBrand(Vm,this,_endPan).call(this);this.element.classList.remove(Rm)}}ignoreTarget(e){return e.matches("a[href], a[href] *, input, textarea, button, button *, select, option")}}function _onMouseDown(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;if(isOverPerfectScrollbar(this.clientXStart,this.clientYStart,"ps__rail-x"))return;if(isOverPerfectScrollbar(this.clientXStart,this.clientYStart,"ps__rail-y"))return;grab_to_pan_classPrivateFieldSet(jm,this,!1);grab_to_pan_classPrivateFieldSet(Nm,this,new AbortController);const t=grab_to_pan_assertClassBrand(Vm,this,_endPan).bind(this),i={capture:!0,signal:grab_to_pan_classPrivateFieldGet(Nm,this).signal};this.document.addEventListener("mousemove",grab_to_pan_assertClassBrand(Vm,this,_onMouseMove).bind(this),i);this.document.addEventListener("mouseup",t,i);grab_to_pan_classPrivateFieldSet(Wm,this,new AbortController);this.element.addEventListener("scroll",t,{capture:!0,signal:grab_to_pan_classPrivateFieldGet(Wm,this).signal});stopEvent(e);const a=document.activeElement;a&&!a.contains(e.target)&&a.blur()}function _onMouseMove(e){grab_to_pan_classPrivateFieldGet(Wm,this)?.abort();grab_to_pan_classPrivateFieldSet(Wm,this,null);if(!(1&e.buttons)){grab_to_pan_assertClassBrand(Vm,this,_endPan).call(this);return}const t=e.clientX-this.clientXStart,i=e.clientY-this.clientYStart;Math.hypot(t,i)>5&&grab_to_pan_classPrivateFieldSet(jm,this,!0);this.element.scrollTo({top:this.scrollTopStart-i,left:this.scrollLeftStart-t,behavior:"instant"});this.overlay.parentNode||document.body.append(this.overlay)}function _endPan(){grab_to_pan_classPrivateFieldGet(Nm,this)?.abort();grab_to_pan_classPrivateFieldSet(Nm,this,null);grab_to_pan_classPrivateFieldGet(Wm,this)?.abort();grab_to_pan_classPrivateFieldSet(Wm,this,null);this.overlay.remove();if(grab_to_pan_classPrivateFieldGet(jm,this)){grab_to_pan_classPrivateFieldSet(jm,this,!1);const e=new AbortController;window.addEventListener("click",e=>stopEvent(e),{capture:!0,once:!0,signal:e.signal});setTimeout(()=>e.abort(),0)}}function isOverPerfectScrollbar(e,t,i){const a=document.getElementsByClassName(i);if(a&&1===a.length){var{top:s,right:r,bottom:n,left:o}=a[0].getBoundingClientRect();if(t>=s&&t<=n&&e<=r&&e>=o)return!0}return!1}function pdf_cursor_tools_classPrivateFieldInitSpec(e,t,i){pdf_cursor_tools_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_cursor_tools_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_cursor_tools_classPrivateFieldSet(e,t,i){return e.set(pdf_cursor_tools_assertClassBrand(e,t),i),i}function pdf_cursor_tools_classPrivateFieldGet(e,t){return e.get(pdf_cursor_tools_assertClassBrand(e,t))}function pdf_cursor_tools_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Um=new WeakMap,zm=new WeakMap,Hm=new WeakSet;class PDFCursorTools{constructor({container:e,eventBus:t,cursorToolOnLoad:i=K_}){!function pdf_cursor_tools_classPrivateMethodInitSpec(e,t){pdf_cursor_tools_checkPrivateRedeclaration(e,t),t.add(e)}(this,Hm);pdf_cursor_tools_classPrivateFieldInitSpec(this,Um,K_);pdf_cursor_tools_classPrivateFieldInitSpec(this,zm,null);this.container=e;this.eventBus=t;pdf_cursor_tools_assertClassBrand(Hm,this,pdf_cursor_tools_addEventListeners).call(this);Promise.resolve().then(()=>{this.switchTool(i)})}get activeTool(){return pdf_cursor_tools_classPrivateFieldGet(Um,this)}switchTool(e){null===pdf_cursor_tools_classPrivateFieldGet(zm,this)&&pdf_cursor_tools_assertClassBrand(Hm,this,_switchTool).call(this,e)}get _handTool(){return shadow(this,"_handTool",new GrabToPan({element:this.container}))}}function _switchTool(e,t=!1){if(e===pdf_cursor_tools_classPrivateFieldGet(Um,this)){null!==pdf_cursor_tools_classPrivateFieldGet(zm,this)&&this.eventBus.dispatch("cursortoolchanged",{source:this,tool:e,disabled:t});return}const disableActiveTool=()=>{switch(pdf_cursor_tools_classPrivateFieldGet(Um,this)){case K_:break;case q_:this._handTool.deactivate()}};switch(e){case K_:disableActiveTool();break;case q_:disableActiveTool();this._handTool.activate();break;case Y_:disableActiveTool();break;default:ngx_console_NgxConsole.error(`switchTool: "${e}" is an unsupported value.`);return}pdf_cursor_tools_classPrivateFieldSet(Um,this,e);this.eventBus.dispatch("cursortoolchanged",{source:this,tool:e,disabled:t})}function pdf_cursor_tools_addEventListeners(){const{eventBus:e}=this;e.on("switchcursortool",e=>{if(e.reset){if(null!==pdf_cursor_tools_classPrivateFieldGet(zm,this)){t=f.NONE;i=T_;enableActive()}}else this.switchTool(e.tool)},lu);let t=f.NONE,i=T_;const disableActive=()=>{pdf_cursor_tools_classPrivateFieldGet(zm,this)??pdf_cursor_tools_classPrivateFieldSet(zm,this,pdf_cursor_tools_classPrivateFieldGet(Um,this));pdf_cursor_tools_assertClassBrand(Hm,this,_switchTool).call(this,K_,!0)},enableActive=()=>{if(null!==pdf_cursor_tools_classPrivateFieldGet(zm,this)&&t===f.NONE&&i===T_){pdf_cursor_tools_assertClassBrand(Hm,this,_switchTool).call(this,pdf_cursor_tools_classPrivateFieldGet(zm,this));pdf_cursor_tools_classPrivateFieldSet(zm,this,null)}};e.on("annotationeditormodechanged",({mode:e})=>{t=e;e===f.NONE?enableActive():disableActive()},lu);e.on("presentationmodechanged",({state:e})=>{i=e;e===T_?enableActive():e===L_&&disableActive()},lu)}function pdf_document_properties_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_document_properties_classPrivateFieldSet(e,t,i){return e.set(pdf_document_properties_assertClassBrand(e,t),i),i}function pdf_document_properties_classPrivateFieldGet(e,t){return e.get(pdf_document_properties_assertClassBrand(e,t))}function pdf_document_properties_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const $m=["en-us","en-lr","my"],Xm={"8.5x11":"pdfjs-document-properties-page-size-name-letter","8.5x14":"pdfjs-document-properties-page-size-name-legal"},Km={"297x420":"pdfjs-document-properties-page-size-name-a-three","210x297":"pdfjs-document-properties-page-size-name-a-four"};function getPageName(e,t,i){return i[`${t?e.width:e.height}x${t?e.height:e.width}`]}var qm=new WeakMap,Ym=new WeakSet;class PDFDocumentProperties{constructor({dialog:e,fields:t,closeButton:i},a,s,r,n,o){!function pdf_document_properties_classPrivateMethodInitSpec(e,t){pdf_document_properties_checkPrivateRedeclaration(e,t),t.add(e)}(this,Ym);!function pdf_document_properties_classPrivateFieldInitSpec(e,t,i){pdf_document_properties_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,qm,null);this.dialog=e;this.fields=t;this.overlayManager=a;this.l10n=r;this._fileNameLookup=n;this.eventBus=s;this._titleLookup=o;pdf_document_properties_assertClassBrand(Ym,this,_reset).call(this);i.addEventListener("click",this.close.bind(this));this.overlayManager.register(this.dialog);this.dialog.addEventListener("close",()=>{this.eventBus.dispatch("propertiesdialogclose",this)});s.on("pagechanging",e=>{this._currentPageNumber=e.pageNumber},lu);s.on("rotationchanging",e=>{this._pagesRotation=e.pagesRotation},lu)}async open(){await Promise.all([this.overlayManager.open(this.dialog),this._dataAvailableCapability.promise]);this.eventBus.dispatch("propertiesdialogopen",this);const e=this._currentPageNumber,t=this._pagesRotation;if(pdf_document_properties_classPrivateFieldGet(qm,this)&&e===pdf_document_properties_classPrivateFieldGet(qm,this)._currentPageNumber&&t===pdf_document_properties_classPrivateFieldGet(qm,this)._pagesRotation){pdf_document_properties_assertClassBrand(Ym,this,_updateUI).call(this);return}const[{info:i,metadata:a,contentLength:s},r]=await Promise.all([this.pdfDocument.getMetadata(),this.pdfDocument.getPage(e).then(e=>pdf_document_properties_assertClassBrand(Ym,this,_parsePageSize).call(this,e,t),t=>{console.error(`PDFDocumentProperties - unable to get page ${e}.`,t)})]);pdf_document_properties_classPrivateFieldSet(qm,this,Object.freeze({fileName:this._fileNameLookup(),fileSize:pdf_document_properties_assertClassBrand(Ym,this,_parseFileSize).call(this,s),title:this._titleLookup(),author:a?.get("dc:creator")?.join("\n")||i.Author,subject:a?.get("dc:subject")?.join("\n")||i.Subject,keywords:a?.get("pdf:keywords")||i.Keywords,creationDate:pdf_document_properties_assertClassBrand(Ym,this,_parseDate).call(this,a?.get("xmp:createdate"),i.CreationDate),modificationDate:pdf_document_properties_assertClassBrand(Ym,this,_parseDate).call(this,a?.get("xmp:modifydate"),i.ModDate),creator:a?.get("xmp:creatortool")||i.Creator,producer:a?.get("pdf:producer")||i.Producer,version:i.PDFFormatVersion,pageCount:this.pdfDocument.numPages,pageSize:r,linearized:pdf_document_properties_assertClassBrand(Ym,this,_parseLinearization).call(this,i.IsLinearized),_currentPageNumber:e,_pagesRotation:t}));pdf_document_properties_assertClassBrand(Ym,this,_updateUI).call(this);const{length:n}=await this.pdfDocument.getDownloadInfo();if(s===n)return;const o=Object.assign(Object.create(null),pdf_document_properties_classPrivateFieldGet(qm,this));o.fileSize=pdf_document_properties_assertClassBrand(Ym,this,_parseFileSize).call(this,n);pdf_document_properties_classPrivateFieldSet(qm,this,Object.freeze(o));pdf_document_properties_assertClassBrand(Ym,this,_updateUI).call(this)}async close(){this.overlayManager.close(this.dialog,!0)}setDocument(e){if(this.pdfDocument){pdf_document_properties_assertClassBrand(Ym,this,_reset).call(this);pdf_document_properties_assertClassBrand(Ym,this,_updateUI).call(this)}if(e){this.pdfDocument=e;this._dataAvailableCapability.resolve()}}}function _reset(){this.pdfDocument=null;pdf_document_properties_classPrivateFieldSet(qm,this,null);this._dataAvailableCapability=Promise.withResolvers();this._currentPageNumber=1;this._pagesRotation=0}function _updateUI(){if(!pdf_document_properties_classPrivateFieldGet(qm,this)||this.overlayManager.active===this.dialog)for(const e in this.fields){const t=this.fields[e],i=pdf_document_properties_classPrivateFieldGet(qm,this)?.[e];if(i?.id){t.setAttribute("data-l10n-id",i.id);i.args&&t.setAttribute("data-l10n-args",JSON.stringify(i.args))}else{t.removeAttribute("data-l10n-id");t.removeAttribute("data-l10n-args");t.textContent=i||0===i?i:"-"}}}function _parseFileSize(e=0){const t=e/1024,i=t/1024;return t?{id:i>=1?"pdfjs-document-properties-size-mb":"pdfjs-document-properties-size-kb",args:{mb:i,kb:t,b:e}}:void 0}async function _parsePageSize(e,t){let i=function getPageSizeInches({view:e,userUnit:t,rotate:i}){const[a,s,r,n]=e,o=i%180!=0,l=(r-a)/72*t,d=(n-s)/72*t;return{width:o?d:l,height:o?l:d}}(e);t%180!=0&&(i={width:i.height,height:i.width});const a=isPortraitOrientation(i),s=$m.includes(this.l10n.getLanguage());let r={width:Math.round(100*i.width)/100,height:Math.round(100*i.height)/100},n={width:Math.round(25.4*i.width*10)/10,height:Math.round(25.4*i.height*10)/10},o=getPageName(r,a,Xm)||getPageName(n,a,Km);if(!(o||Number.isInteger(n.width)&&Number.isInteger(n.height))){const e={width:25.4*i.width,height:25.4*i.height},t={width:Math.round(n.width),height:Math.round(n.height)};if(Math.abs(e.width-t.width)<.1&&Math.abs(e.height-t.height)<.1){o=getPageName(t,a,Km);if(o){r={width:Math.round(t.width/25.4*100)/100,height:Math.round(t.height/25.4*100)/100};n=t}}}const{width:l,height:d}=s?r:n,c=[s?"pdfjs-document-properties-page-size-unit-inches":"pdfjs-document-properties-page-size-unit-millimeters",a?"pdfjs-document-properties-page-size-orientation-portrait":"pdfjs-document-properties-page-size-orientation-landscape"];o&&c.push(o);const[h,_,u]=await this.l10n.get(c);return{id:u?"pdfjs-document-properties-page-size-dimension-name-string":"pdfjs-document-properties-page-size-dimension-string",args:{width:l,height:d,unit:h,name:u,orientation:_}}}function _parseDate(e,t){const i=Date.parse(e)||PDFDateString.toDateObject(t);return i?{id:"pdfjs-document-properties-date-time-string",args:{dateObj:i.valueOf()}}:void 0}function _parseLinearization(e){return{id:e?"pdfjs-document-properties-linearized-yes":"pdfjs-document-properties-linearized-no"}}let Zm,Qm=null,Jm=null;function isWordBreakAt(e,t){Jm||=new Intl.Segmenter(void 0,{granularity:"grapheme"});const i=Jm.segment(e),a=i.containing(t);if(a.index!==t)return!1;Qm||=new Intl.Segmenter(void 0,{granularity:"word"});const s=i.containing(t-1).segment;return Qm.segment(s+a.segment).containing(s.length).index===s.length}function isEntireWord(e,t,i){const a=t+i;return(0===t||isWordBreakAt(e,t))&&(a===e.length||isWordBreakAt(e,a))}function pdf_find_controller_classPrivateFieldInitSpec(e,t,i){pdf_find_controller_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_find_controller_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_find_controller_classPrivateGetter(e,t,i){return i(pdf_find_controller_assertClassBrand(e,t))}function pdf_find_controller_classPrivateFieldGet(e,t){return e.get(pdf_find_controller_assertClassBrand(e,t))}function pdf_find_controller_classPrivateFieldSet(e,t,i){return e.set(pdf_find_controller_assertClassBrand(e,t),i),i}function pdf_find_controller_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const ef=0,tf=1,af=2,sf=3,rf=new Map([["‐","-"],["‘","'"],["’","'"],["‚","'"],["‛","'"],["“",'"'],["”",'"'],["„",'"'],["‟",'"'],["¼","1/4"],["½","1/2"],["¾","3/4"]]),nf=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 of;const lf=/\p{M}+/gu,df=/([+^$|])|(\p{P}+)|(\s+)|(\p{M})|(\p{L})/gu,cf=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,hf=new Map,_f=new Map;let uf=null,pf=null;function normalize(e,t={}){const i=[];let a;for(;null!==(a=cf.exec(e));){let{index:e}=a;for(const t of a[0]){let a=hf.get(t);if(!a){a=t.normalize("NFD").length;hf.set(t,a)}i.push([a,e++])}}const s=i.length>0,r=t.ignoreDashEOL??!1;let n;if(!s&&uf)n=uf;else if(s&&pf)n=pf;else{const e=rf.keys().join(""),t=function getNormalizeWithNFKC(){if(!Zm){const e=[],t=[],flushRange=()=>{if(2!==t.length)return;const[i,a]=t,s=String.fromCharCode(i);e.push(i===a?s:`${s}-${String.fromCharCode(a)}`)},i=/^\p{M}$/u;for(let e=0;e<65536;e++){if(e>=55296&&e<=57343)continue;const a=String.fromCharCode(e);if(a.normalize("NFKC")!==a&&!i.test(a))if(2===t.length&&t[1]+1===e)t[1]=e;else{flushRange();t[0]=t[1]=e}}flushRange();const a=e.join("");if(Zm){if(a!==Zm){for(let e=1;e<a.length;e++)if(a[e]!==Zm[e]){console.log(`Difference at index ${e}: U+${a.charCodeAt(e).toString(16).toUpperCase().padStart(4,"0")}!== U+${Zm.charCodeAt(e).toString(16).toUpperCase().padStart(4,"0")}`);break}throw new Error("getNormalizeWithNFKC - update the `NormalizeWithNFKC` string.")}}else Zm=a}return Zm}();n=new RegExp([`[${e}]`,`[${t}]`,`${"(?:゙|゚)"}\\n`,"\\p{M}+(?:-\\n)?",`${"\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})"}`,"\\S-\\n",`${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n`,"\\n",s?"[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]":"\\u0000"].map(e=>`(${e})`).join("|"),"gmu");s?pf=n:uf=n}const o=[];for(;null!==(a=lf.exec(e));)o.push([a[0].length,a.index]);let l=e.normalize("NFD");const d=[0,0];let c=0,h=0,_=0,u=0,p=0,g=!1;l=l.replace(n,(e,t,a,s,n,l,m,f,v,P,w)=>{w-=u;if(t){const e=rf.get(t),i=e.length;for(let e=1;e<i;e++)d.push(w-_+e,_-e);_-=i-1;return e}if(a){const e=_f.getOrInsertComputed(a,()=>a.normalize("NFKC")),t=e.length;for(let e=1;e<t;e++)d.push(w-_+e,_-e);_-=t-1;return e}if(s){g=!0;if(w+p===o[c]?.[1])++c;else{d.push(w-1-_+1,_-1);_-=1;u+=1}d.push(w-_+1,_);u+=1;p+=1;return s.charAt(0)}if(n){const e=n.endsWith("\n"),t=e?n.length-2:n.length;g=!0;let i=t;if(w+p===o[c]?.[1]){i-=o[c][0];++c}for(let e=1;e<=i;e++)d.push(w-1-_+e,_-e);_-=i;u+=i;if(e){w+=t-1;d.push(w-_+1,1+_);_+=1;u+=1;p+=1;return n.slice(0,t)}return n}if(l){if(r){u+=1;p+=1;return l.slice(0,-1)}const e=l.length-2;d.push(w-_+e,1+_);_+=1;u+=1;p+=1;return l.slice(0,-2)}if(m){u+=1;p+=1;return m.slice(0,-1)}if(f){const e=f.length-1;d.push(w-_+e,_);u+=1;p+=1;return f.slice(0,-1)}if(v){d.push(w-_+1,_-1);_-=1;u+=1;p+=1;return" "}if(w+p===i[h]?.[1]){const e=i[h][0]-1;++h;for(let t=1;t<=e;t++)d.push(w-(_-t),_-t);_-=e;u+=e}return P});d.push(l.length,_);const m=new Uint32Array(d.length>>1),f=new Int32Array(d.length>>1);for(let e=0,t=d.length;e<t;e+=2){m[e>>1]=d[e];f[e>>1]=d[e+1]}return[l,[m,f],g]}function getOriginalIndex(e,t,i){if(!e)return[t,i];const[a,s]=e,r=t,n=t+i-1;let o=binarySearchFirstItem(a,e=>e>=r);a[o]>r&&--o;let l=binarySearchFirstItem(a,e=>e>=n,o);a[l]>n&&--l;const d=r+s[o];return[d,n+s[l]+1-d]}var gf=new WeakMap,mf=new WeakMap,ff=new WeakMap,vf=new WeakMap,Pf=new WeakMap,wf=new WeakMap,Ff=new WeakSet;class PDFFindController{constructor({linkService:e,eventBus:t,delay:i=250,updateMatchesCountOnProgress:a=!0,pageViewMode:s,listenToEventBus:r}){!function pdf_find_controller_classPrivateMethodInitSpec(e,t){pdf_find_controller_checkPrivateRedeclaration(e,t),t.add(e)}(this,Ff);pdf_find_controller_classPrivateFieldInitSpec(this,gf,null);pdf_find_controller_classPrivateFieldInitSpec(this,mf,!0);pdf_find_controller_classPrivateFieldInitSpec(this,ff,0);pdf_find_controller_classPrivateFieldInitSpec(this,vf,0);pdf_find_controller_classPrivateFieldInitSpec(this,Pf,null);pdf_find_controller_classPrivateFieldInitSpec(this,wf,null);this._linkService=e;this._eventBus=t;pdf_find_controller_classPrivateFieldSet(mf,this,a);this._pageViewMode=s;pdf_find_controller_classPrivateFieldSet(ff,this,i);this.onIsPageVisible=null;pdf_find_controller_assertClassBrand(Ff,this,pdf_find_controller_reset).call(this);this._eventBus.on("pageviewmodechanged",({pageViewMode:e})=>{this._pageViewMode=e});if(r){t.on("find",pdf_find_controller_assertClassBrand(Ff,this,_onFind).bind(this),lu);t.on("findbarclose",pdf_find_controller_assertClassBrand(Ff,this,_onFindBarClose).bind(this),lu);t.on("pagesedited",pdf_find_controller_assertClassBrand(Ff,this,_onPagesEdited).bind(this),lu)}}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get pageMatchesColor(){return this._pageMatchesColor}get selected(){return this._selected}get state(){return pdf_find_controller_classPrivateFieldGet(gf,this)}setDocument(e){this._pdfDocument&&pdf_find_controller_assertClassBrand(Ff,this,pdf_find_controller_reset).call(this);if(e){this._pdfDocument=e;this._firstPageCapability.resolve()}}ngxFind(e){const t=[];this._findResultResolvers=[];for(let e=0,i=this._linkService.pagesCount;e<i;e++){const{promise:i,resolve:a}=Promise.withResolvers();t[e]=i;this._findResultResolvers[e]=a}pdf_find_controller_assertClassBrand(Ff,this,_onFind).call(this,e);return t}ngxFindNext(){const e={...pdf_find_controller_classPrivateFieldGet(gf,this),type:"again",findPrevious:!1};pdf_find_controller_assertClassBrand(Ff,this,_onFind).call(this,e)}ngxFindPrevious(){const e={...pdf_find_controller_classPrivateFieldGet(gf,this),type:"again",findPrevious:!0};pdf_find_controller_assertClassBrand(Ff,this,_onFind).call(this,e)}scrollMatchIntoView({element:e=null,pageIndex:t=-1,matchIndex:i=-1}){if(!pdf_find_controller_classPrivateFieldGet(gf,this)?.dontScrollIntoView&&this._scrollMatches&&e){this._scrollMatches=!1;"infinite-scroll"===this._pageViewMode?scrollIntoView(e,{top:-50,left:0},!0,!0):e.scrollIntoView({block:"start",inline:"center"})}}_convertToRegExpString(e,t){const{matchDiacritics:i}=pdf_find_controller_classPrivateFieldGet(gf,this);let a=!1;const addExtraWhitespaces=(t,i)=>t===e?i:e.startsWith(t)?`${i}[ ]*`:e.endsWith(t)?`[ ]*${i}`:`[ ]*${i}[ ]*`;if(!(e=e.replaceAll(df,(e,s,r,n,o,l)=>{if(s)return addExtraWhitespaces(s,RegExp.escape(s));if(r)return addExtraWhitespaces(r,RegExp.escape(r));if(n)return"[ ]+";if(i)return o||l;if(o)return nf.has(o.charCodeAt(0))?o:"";if(t){a=!0;return`${l}\\p{M}*`}return l})))return[!1,""];const s="[ ]*";e.endsWith(s)&&(e=e.slice(0,e.length-4));(e=e.replaceAll(/(?:\[ \][*+]){2,}/g,e=>`[ ]{${e.split("+").length-1},}`)).startsWith("[ ]")&&(e=`(?:(?<![ ])|(?![ ]{2}))${e}`);if(i&&t){of||=String.fromCharCode(...nf);a=!0;e=`${e}(?=[${of}]|[^\\p{M}]|$)`}return[a,e]}_calculateMatch(e){var t;if(!pdf_find_controller_classPrivateFieldGet(gf,this))return;const i=pdf_find_controller_classPrivateGetter(Ff,this,_get_query);if(0===i.length)return;const a=this._pageContents[e],s=this.match(i,a,e),r=this._pageMatches[e]=[],n=this._pageMatchesLength[e]=[],o=this._pageMatchesColor[e]=[],l=this._pageDiffs[e];s?.forEach(({index:e,length:t,color:i})=>{const[a,s]=getOriginalIndex(l,e,t);if(s){r.push(a);n.push(s);o.push(i||0)}});pdf_find_controller_classPrivateFieldGet(gf,this).highlightAll&&pdf_find_controller_assertClassBrand(Ff,this,_updatePage).call(this,e);if(this._resumePageIdx===e){this._resumePageIdx=null;pdf_find_controller_assertClassBrand(Ff,this,_nextPageMatch).call(this)}const d=r.length;this._matchesCountTotal+=d;pdf_find_controller_classPrivateFieldGet(mf,this)?d>0&&pdf_find_controller_assertClassBrand(Ff,this,_updateUIResultsCount).call(this,e):pdf_find_controller_classPrivateFieldSet(vf,this,(t=pdf_find_controller_classPrivateFieldGet(vf,this),++t))===this._linkService.pagesCount&&pdf_find_controller_assertClassBrand(Ff,this,_updateUIResultsCount).call(this,e)}match(e,t,i){const a=this._hasDiacritics[i];let s=!1;const{caseSensitive:r,findMultiple:n,matchRegExp:o}=pdf_find_controller_classPrivateFieldGet(gf,this);n&&"string"==typeof e&&(e=e.trim().split(/\s+/));let l=null;if(o&&"string"==typeof e){e=new RegExp(e,r?"g":"gi");s=a}else if("string"==typeof e)[s,e]=this._convertToRegExpString(e,a);else{const t=[...e];e=e.sort().reverse().map(e=>{const[t,i]=this._convertToRegExpString(e,a);s||=t;return i&&`(${i})`}).filter(Boolean).join("|");l=[...t].sort().reverse().map(e=>t.indexOf(e))}if(!e)return;const{entireWord:d}=pdf_find_controller_classPrivateFieldGet(gf,this);e=new RegExp(e,`g${s?"u":""}${r?"":"i"}`);const c=[];let h;for(;null!==(h=e.exec(t));){if(d&&!isEntireWord(t,h.index,h[0].length))continue;let e=0;if(l)for(let t=1;t<h.length;t++)if(void 0!==h[t]){e=l[t-1]%5;break}c.push({index:h.index,length:h[0].length,color:e})}return c}}function _onFind(e){if(!e)return;const t=this._pdfDocument,{type:i}=e;(null===pdf_find_controller_classPrivateFieldGet(gf,this)||pdf_find_controller_assertClassBrand(Ff,this,_shouldDirtyMatch).call(this,e))&&(this._dirtyMatch=!0);pdf_find_controller_classPrivateFieldSet(gf,this,e);if("highlightallchange"!==i)pdf_find_controller_assertClassBrand(Ff,this,pdf_find_controller_updateUIState).call(this,sf);else{const e=this._pageMatches.some(e=>e.length>0),t=!this.state?.query||e;pdf_find_controller_assertClassBrand(Ff,this,pdf_find_controller_updateUIState).call(this,t?ef:tf)}this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||t&&this._pdfDocument!==t)return;pdf_find_controller_assertClassBrand(Ff,this,pdf_find_controller_extractText).call(this);const e=!this._highlightMatches,a=!!this._findTimeout;if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}if(i)if(this._dirtyMatch)pdf_find_controller_assertClassBrand(Ff,this,_nextMatch).call(this);else if("again"===i){pdf_find_controller_assertClassBrand(Ff,this,_nextMatch).call(this);e&&pdf_find_controller_classPrivateFieldGet(gf,this).highlightAll&&pdf_find_controller_assertClassBrand(Ff,this,_updateAllPages).call(this)}else if("highlightallchange"===i){a?pdf_find_controller_assertClassBrand(Ff,this,_nextMatch).call(this):this._highlightMatches=!0;pdf_find_controller_assertClassBrand(Ff,this,_updateAllPages).call(this)}else pdf_find_controller_assertClassBrand(Ff,this,_nextMatch).call(this);else this._findTimeout=setTimeout(()=>{pdf_find_controller_assertClassBrand(Ff,this,_nextMatch).call(this);this._findTimeout=null},pdf_find_controller_classPrivateFieldGet(ff,this))})}function pdf_find_controller_reset(){this._highlightMatches=!1;this._scrollMatches=!1;this._pdfDocument=null;this._pageMatches=[];this._pageMatchesLength=[];this._pageMatchesColor=[];pdf_find_controller_classPrivateFieldSet(vf,this,0);pdf_find_controller_classPrivateFieldSet(gf,this,null);this._selected={pageIdx:-1,matchIdx:-1};this._offset={pageIdx:null,matchIdx:null,wrapped:!1};this._extractTextPromises=[];this._findResultResolvers=[];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;pdf_find_controller_classPrivateFieldSet(Pf,this,null);this._firstPageCapability=Promise.withResolvers()}function _get_query(e){const{query:t}=pdf_find_controller_classPrivateFieldGet(gf,e);if("string"==typeof t){if(t!==e._rawQuery){e._rawQuery=t;[e._normalizedQuery]=normalize(t)}return e._normalizedQuery}return(t||[]).filter(Boolean).map(e=>normalize(e)[0])}function _shouldDirtyMatch(e){const t=e.query,i=pdf_find_controller_classPrivateFieldGet(gf,this).query,a=typeof t;if(a!==typeof i)return!0;if("string"===a){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)??!0);case"highlightallchange":return!1}return!0}function pdf_find_controller_extractText(){if(this._extractTextPromises.length>0)return;let e=Promise.resolve();const t={disableNormalization:!0},i=this._pdfDocument;for(let a=0,s=this._linkService.pagesCount;a<s;a++){const{promise:s,resolve:r}=Promise.withResolvers();this._extractTextPromises[a]=s;e=e.then(async()=>{if(i===this._pdfDocument){try{const e=await i.getPage(a+1),s=await e.getTextContent(t);if(i!==this._pdfDocument){r();return}const n=[];for(const e of s.items){n.push(e.str);e.hasEOL&&n.push("\n")}[this._pageContents[a],this._pageDiffs[a],this._hasDiacritics[a]]=normalize(n.join(""))}catch(e){if(i!==this._pdfDocument){r();return}ngx_console_NgxConsole.error(`Unable to get text content for page ${a+1}`,e);[this._pageContents[a],this._pageDiffs[a],this._hasDiacritics[a]]=["",null,!1]}r()}else r()})}}function _updatePage(e){this._scrollMatches&&this._selected.pageIdx===e&&(this.state.dontScrollIntoView||(this._linkService.page=e+1));this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:e})}function _updateAllPages(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}function _nextMatch(){const e=pdf_find_controller_classPrivateFieldGet(gf,this).findPrevious,t=this._linkService.page-1,i=this._linkService.pagesCount;this._highlightMatches=!0;if(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;pdf_find_controller_classPrivateFieldSet(vf,this,0);this._matchesCountTotal=0;pdf_find_controller_assertClassBrand(Ff,this,_updateAllPages).call(this);for(let e=0;e<i;e++)if(!this._pendingFindMatches.has(e)){this._pendingFindMatches.add(e);this._extractTextPromises[e].then(()=>{this._pendingFindMatches.delete(e);this._calculateMatch(e)})}}if(0===pdf_find_controller_classPrivateGetter(Ff,this,_get_query).length){pdf_find_controller_assertClassBrand(Ff,this,pdf_find_controller_updateUIState).call(this,ef);return}if(this._resumePageIdx)return;const a=this._offset;this._pagesToSearch=i;if(null!==a.matchIdx){const t=this._pageMatches[a.pageIdx].length;if(!e&&a.matchIdx+1<t||e&&a.matchIdx>0){a.matchIdx=e?a.matchIdx-1:a.matchIdx+1;pdf_find_controller_assertClassBrand(Ff,this,_updateMatch).call(this,!0);return}pdf_find_controller_assertClassBrand(Ff,this,_advanceOffsetPage).call(this,e)}pdf_find_controller_assertClassBrand(Ff,this,_nextPageMatch).call(this)}function _matchesReady(e){const t=this._offset,i=e.length,a=pdf_find_controller_classPrivateFieldGet(gf,this).findPrevious;if(i){t.matchIdx=a?i-1:0;pdf_find_controller_assertClassBrand(Ff,this,_updateMatch).call(this,!0);return!0}pdf_find_controller_assertClassBrand(Ff,this,_advanceOffsetPage).call(this,a);if(t.wrapped){t.matchIdx=null;if(this._pagesToSearch<0){pdf_find_controller_assertClassBrand(Ff,this,_updateMatch).call(this,!1);return!0}}return!1}function _nextPageMatch(){null!==this._resumePageIdx&&ngx_console_NgxConsole.error("There can only be one pending page.");let e=null;do{const t=this._offset.pageIdx;e=this._pageMatches[t];if(!e){this._resumePageIdx=t;break}}while(!pdf_find_controller_assertClassBrand(Ff,this,_matchesReady).call(this,e))}function _advanceOffsetPage(e){const t=this._offset,i=this._linkService.pagesCount;t.pageIdx=e?t.pageIdx-1:t.pageIdx+1;t.matchIdx=null;this._pagesToSearch--;if(t.pageIdx>=i||t.pageIdx<0){t.pageIdx=e?i-1:0;t.wrapped=!0}}function _updateMatch(e=!1){let t=tf;const i=this._offset.wrapped;this._offset.wrapped=!1;if(e){const e=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx;this._selected.matchIdx=this._offset.matchIdx;t=i?af:ef;-1!==e&&e!==this._selected.pageIdx&&pdf_find_controller_assertClassBrand(Ff,this,_updatePage).call(this,e)}pdf_find_controller_assertClassBrand(Ff,this,pdf_find_controller_updateUIState).call(this,t,pdf_find_controller_classPrivateFieldGet(gf,this).findPrevious);if(-1!==this._selected.pageIdx){this._scrollMatches=!0;pdf_find_controller_assertClassBrand(Ff,this,_updatePage).call(this,this._selected.pageIdx)}}function _onPagesEdited({pagesMapper:e,type:t,pageNumbers:i}){if(0===this._extractTextPromises.length)return;if("copy"===t){const e=new Map,t=new Map,a=new Map,s=new Map;for(const r of i){e.set(r,this._extractTextPromises[r-1]);t.set(r,this._pageContents[r-1]);a.set(r,this._pageDiffs[r-1]);s.set(r,this._hasDiacritics[r-1])}pdf_find_controller_classPrivateFieldSet(Pf,this,{promises:e,contents:t,diffs:a,diacritics:s});return}if("cancelCopy"===t){pdf_find_controller_classPrivateFieldSet(Pf,this,null);return}"delete"===t&&pdf_find_controller_classPrivateFieldSet(wf,this,{promises:this._extractTextPromises,contents:this._pageContents,diffs:this._pageDiffs,diacritics:this._hasDiacritics});if("cancelDelete"===t){this._extractTextPromises=pdf_find_controller_classPrivateFieldGet(wf,this).promises;this._pageContents=pdf_find_controller_classPrivateFieldGet(wf,this).contents;this._pageDiffs=pdf_find_controller_classPrivateFieldGet(wf,this).diffs;this._hasDiacritics=pdf_find_controller_classPrivateFieldGet(wf,this).diacritics;return}if("cleanSavedData"===t){pdf_find_controller_classPrivateFieldSet(wf,this,null);return}if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}this._resumePageIdx=null;this._dirtyMatch=!0;const a=this._extractTextPromises,s=this._pageContents,r=this._pageDiffs,n=this._hasDiacritics,o=this._extractTextPromises=[],l=this._pageContents=[],d=this._pageDiffs=[],c=this._hasDiacritics=[];for(let t=1,i=e.pagesNumber;t<=i;t++){const i=e.getPrevPageNumber(t);if(i<0){const e=-i;o.push(pdf_find_controller_classPrivateFieldGet(Pf,this)?.promises.get(e)||Promise.resolve());l.push(pdf_find_controller_classPrivateFieldGet(Pf,this)?.contents.get(e)??"");d.push(pdf_find_controller_classPrivateFieldGet(Pf,this)?.diffs.get(e)??null);c.push(pdf_find_controller_classPrivateFieldGet(Pf,this)?.diacritics.get(e)??!1);continue}o.push(a[i-1]||Promise.resolve());l.push(s[i-1]??"");d.push(r[i-1]??null);c.push(n[i-1]??!1)}pdf_find_controller_classPrivateFieldGet(gf,this)&&pdf_find_controller_assertClassBrand(Ff,this,_nextMatch).call(this)}function _onFindBarClose(e){const t=this._pdfDocument;this._firstPageCapability.promise.then(()=>{if(this._pdfDocument&&(!t||this._pdfDocument===t)){if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}if(this._resumePageIdx){this._resumePageIdx=null;this._dirtyMatch=!0}pdf_find_controller_assertClassBrand(Ff,this,pdf_find_controller_updateUIState).call(this,ef);this._highlightMatches=!1;pdf_find_controller_assertClassBrand(Ff,this,_updateAllPages).call(this)}})}function _requestMatchesCount(){const{pageIdx:e,matchIdx:t}=this._selected;let i=0,a=this._matchesCountTotal;if(-1!==t){for(let t=0;t<e;t++)i+=this._pageMatches[t]?.length||0;i+=t+1}(i<1||i>a)&&(i=a=0);return{current:i,total:a}}function _updateUIResultsCount(e){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:pdf_find_controller_assertClassBrand(Ff,this,_requestMatchesCount).call(this)});const t=this._pageMatches[e].length;if(this._findResultResolvers&&this._findResultResolvers[e]){this._findResultResolvers[e](t);this._findResultResolvers[e]=null}}function pdf_find_controller_updateUIState(e,t=!1){(pdf_find_controller_classPrivateFieldGet(mf,this)||pdf_find_controller_classPrivateFieldGet(vf,this)===this._linkService.pagesCount&&e!==sf)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:e,previous:t,entireWord:pdf_find_controller_classPrivateFieldGet(gf,this)?.entireWord??null,matchesCount:pdf_find_controller_assertClassBrand(Ff,this,_requestMatchesCount).call(this),rawQuery:pdf_find_controller_classPrivateFieldGet(gf,this)?.query??null})}function pdf_find_bar_defineProperty(e,t,i){return(t=function pdf_find_bar_toPropertyKey(e){var t=function pdf_find_bar_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_find_bar_classPrivateFieldInitSpec(e,t,i){pdf_find_bar_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_find_bar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_find_bar_classPrivateFieldGet(e,t){return e.get(pdf_find_bar_assertClassBrand(e,t))}function pdf_find_bar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var yf=new WeakMap,bf=new WeakMap,Sf=new WeakSet;class PDFFindBar{constructor(e,t,i){!function pdf_find_bar_classPrivateMethodInitSpec(e,t){pdf_find_bar_checkPrivateRedeclaration(e,t),t.add(e)}(this,Sf);pdf_find_bar_classPrivateFieldInitSpec(this,yf,void 0);pdf_find_bar_classPrivateFieldInitSpec(this,bf,new ResizeObserver(pdf_find_bar_assertClassBrand(Sf,this,_resizeObserverCallback).bind(this)));pdf_find_bar_defineProperty(this,"opened",!1);this.bar=e.bar;this.toggleButton=e.toggleButton;this.findField=e.findField;this.highlightAll=e.highlightAllCheckbox;this.currentPage=e.findCurrentPageCheckbox;this.pageRange=e.findPageRangeField;this.caseSensitive=e.caseSensitiveCheckbox;this.findMultipleCheckbox=e.findMultipleCheckbox;this.matchRegExpCheckbox=e.matchRegExpCheckbox;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=i;!function pdf_find_bar_classPrivateFieldSet(e,t,i){return e.set(pdf_find_bar_assertClassBrand(e,t),i),i}(yf,this,t);i._on("closeopenpopovers",({source:e})=>{e!==this&&this.close()});const a=new Map(Array.from([[this.highlightAll,"highlightallchange"],[this.caseSensitive,"casesensitivitychange"],[this.entireWord,"entirewordchange"],[this.matchDiacritics,"diacriticmatchingchange"],[this.findMultipleCheckbox,"findmultiplechange"]]).filter(([e])=>e&&e instanceof Element));this.toggleButton&&(function isInsideNgxExtendedPdfViewer(e){let t=e;for(;t;){if("ngx-extended-pdf-viewer"===t.tagName.toLowerCase())return!0;t=t.parentElement}return!1}(this.toggleButton)||this.toggleButton.addEventListener("click",()=>{this.toggle()}));this.findField.addEventListener("input",()=>{this.dispatchEvent("")});this.findField.parentElement.addEventListener("keydown",e=>{const{keyCode:t}=e;13!==t&&27!==t&&e.stopPropagation();e.metaKey&&"ArrowDown"===e.key&&e.preventDefault();e.metaKey&&"ArrowUp"===e.key&&e.preventDefault()});this.bar.addEventListener("keydown",e=>{const{keyCode:t,shiftKey:i,target:s}=e;switch(t){case 13:if(s===this.findField)this.dispatchEvent("again",i);else if(a.has(s)){s.checked=!s.checked;this.dispatchEvent(a.get(s))}break;case 27:this.close();e.stopPropagation()}});this.findPreviousButton.addEventListener("click",()=>{this.dispatchEvent("again",!0)});this.findNextButton.addEventListener("click",()=>{this.dispatchEvent("again",!1)});for(const[e,t]of a)e.addEventListener("click",()=>{this.dispatchEvent(t)});this.matchRegExpCheckbox?.addEventListener("click",()=>{if(this.matchRegExpCheckbox.checked){this.findMultipleCheckbox.checked=!1;this.findMultipleCheckbox.disabled=!0;this.matchDiacritics.checked=!1;this.matchDiacritics.disabled=!0;this.entireWord.checked=!1;this.entireWord.disabled=!0}else{this.findMultipleCheckbox.disabled=!1;this.matchDiacritics.disabled=!1;this.entireWord.disabled=!1}this.dispatchEvent("findregexpchange")})}reset(){this.updateUIState()}dispatchEvent(e,t=!1){this.eventBus.dispatch("find",{source:this,type:e,query:this.findField.value,caseSensitive:this.caseSensitive.checked,findMultiple:this.findMultipleCheckbox?.checked,matchRegExp:this.matchRegExpCheckbox?.checked,entireWord:this.entireWord.checked,highlightAll:this.highlightAll.checked,findPrevious:t,matchDiacritics:this.matchDiacritics.checked})}updateUIState(e,t,i){const{findField:a,findMsg:s}=this;let r="",n="";switch(e){case ef:break;case sf:n="pending";break;case tf:r="pdfjs-find-not-found";n="notFound";break;case af:r=t?"pdfjs-find-reached-top":"pdfjs-find-reached-bottom"}a.setAttribute("data-status",n);a.setAttribute("aria-invalid",e===tf);s.setAttribute("data-status",n);if(r)s.setAttribute("data-l10n-id",r);else{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 a=1e3;i.setAttribute("data-l10n-id",t>a?"pdfjs-find-match-count-limit":"pdfjs-find-match-count");i.setAttribute("data-l10n-args",JSON.stringify({limit:a,current:e,total:t}))}else{i.removeAttribute("data-l10n-id");i.textContent=""}}open(){this.eventBus.dispatch("closeopenpopovers",{source:this});if(!this.opened){pdf_find_bar_classPrivateFieldGet(bf,this).observe(pdf_find_bar_classPrivateFieldGet(yf,this));pdf_find_bar_classPrivateFieldGet(bf,this).observe(this.bar);this.opened=!0;toggleExpandedBtn(this.toggleButton,!0,this.bar)}if(this.findField){"function"==typeof this.findField.select&&this.findField.select();"function"==typeof this.findField.focus&&this.findField.focus()}this.dispatchEvent("");this.eventBus.dispatch("findbaropen",{source:this})}close(){if(this.opened){pdf_find_bar_classPrivateFieldGet(bf,this).disconnect();this.opened=!1;toggleExpandedBtn(this.toggleButton,!1,this.bar);this.eventBus.dispatch("findbarclose",{source:this})}}toggle(){this.opened?this.close():this.open()}}function _resizeObserverCallback(){const{bar:e}=this;e.classList.remove("wrapContainers");e.clientHeight>e.firstElementChild.clientHeight&&e.classList.add("wrapContainers")}function pdf_history_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_history_classPrivateFieldSet(e,t,i){return e.set(pdf_history_assertClassBrand(e,t),i),i}function pdf_history_classPrivateFieldGet(e,t){return e.get(pdf_history_assertClassBrand(e,t))}function pdf_history_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function getCurrentHash(){return document.location.hash}var Cf=new WeakMap,xf=new WeakSet;class PDFHistory{constructor({linkService:e,eventBus:t}){!function pdf_history_classPrivateMethodInitSpec(e,t){pdf_history_checkPrivateRedeclaration(e,t),t.add(e)}(this,xf);!function pdf_history_classPrivateFieldInitSpec(e,t,i){pdf_history_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,Cf,null);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,...lu})},lu)}initialize({fingerprint:e,resetHistory:t=!1,updateUrl:i=!1}){if(!e||"string"!=typeof e){ngx_console_NgxConsole.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');return}this._initialized&&this.reset();const a=""!==this._fingerprint&&this._fingerprint!==e;this._fingerprint=e;this._updateUrl=!0===i;this._initialized=!0;pdf_history_assertClassBrand(xf,this,_bindEvents).call(this);const s=window.history.state;this._popStateInProgress=!1;this._blockHashChange=0;this._currentHash=getCurrentHash();this._numPositionUpdates=0;this._uid=this._maxUid=0;this._destination=null;this._position=null;if(!pdf_history_assertClassBrand(xf,this,_isValidState).call(this,s,!0)||t){const{hash:e,page:i,rotation:s}=pdf_history_assertClassBrand(xf,this,_parseCurrentHash).call(this,!0);if(!e||a||t){pdf_history_assertClassBrand(xf,this,_pushOrReplaceState).call(this,null,!0);return}pdf_history_assertClassBrand(xf,this,_pushOrReplaceState).call(this,{hash:e,page:i,rotation:s},!0);return}const r=s.destination;pdf_history_assertClassBrand(xf,this,_updateInternalState).call(this,r,s.uid,!0);void 0!==r.rotation&&(this._initialRotation=r.rotation);if(r.dest){this._initialBookmark=JSON.stringify(r.dest);this._destination.page=null}else r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){if(this._initialized){pdf_history_assertClassBrand(xf,this,_pageHide).call(this);this._initialized=!1;pdf_history_assertClassBrand(xf,this,_unbindEvents).call(this)}if(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){ngx_console_NgxConsole.error(`PDFHistory.push: "${e}" is not a valid namedDest parameter.`);return}if(!Array.isArray(t)){ngx_console_NgxConsole.error(`PDFHistory.push: "${t}" is not a valid explicitDest parameter.`);return}if(!pdf_history_assertClassBrand(xf,this,_isValidPage).call(this,i)&&(null!==i||this._destination)){ngx_console_NgxConsole.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);return}const a=e||JSON.stringify(t);if(!a)return;let s=!1;if(this._destination&&(function isDestHashesEqual(e,t){if("string"!=typeof e||"string"!=typeof t)return!1;if(e===t)return!0;if(parseQueryString(e).get("nameddest")===t)return!0;return!1}(this._destination.hash,a)||function isDestArraysEqual(e,t){function isEntryEqual(e,t){if(typeof e!=typeof t||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 i in e)if(!isEntryEqual(e[i],t[i]))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 i=0,a=e.length;i<a;i++)if(!isEntryEqual(e[i],t[i]))return!1;return!0}(this._destination.dest,t))){if(this._destination.page)return;s=!0}if(!this._popStateInProgress||s){pdf_history_assertClassBrand(xf,this,_pushOrReplaceState).call(this,{dest:t,hash:a,page:i,rotation:this.linkService.rotation},s);if(!this._popStateInProgress){this._popStateInProgress=!0;Promise.resolve().then(()=>{this._popStateInProgress=!1})}}}pushPage(e){if(this._initialized)if(pdf_history_assertClassBrand(xf,this,_isValidPage).call(this,e)){if(this._destination?.page!==e&&!this._popStateInProgress){pdf_history_assertClassBrand(xf,this,_pushOrReplaceState).call(this,{dest:null,hash:`page=${e}`,page:e,rotation:this.linkService.rotation});if(!this._popStateInProgress){this._popStateInProgress=!0;Promise.resolve().then(()=>{this._popStateInProgress=!1})}}}else ngx_console_NgxConsole.error(`PDFHistory.pushPage: "${e}" is not a valid page number.`)}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&pdf_history_assertClassBrand(xf,this,_tryPushCurrentPosition).call(this)}back(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;pdf_history_assertClassBrand(xf,this,_isValidState).call(this,e)&&e.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;pdf_history_assertClassBrand(xf,this,_isValidState).call(this,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}}function _pushOrReplaceState(e,t=!1){const i=t||!this._destination,a={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:e};pdf_history_assertClassBrand(xf,this,_updateInternalState).call(this,e,a.uid);let s;if(this._updateUrl&&e?.hash){const{href:t,protocol:i}=document.location;"file:"!==i&&(s=updateUrlHash(t,e.hash))}i?window.history.replaceState(a,"",s):window.history.pushState(a,"",s)}function _tryPushCurrentPosition(e=!1){if(!this._position)return;let t=this._position;if(e){t=Object.assign(Object.create(null),this._position);t.temporary=!0}if(!this._destination){pdf_history_assertClassBrand(xf,this,_pushOrReplaceState).call(this,t);return}if(this._destination.temporary){pdf_history_assertClassBrand(xf,this,_pushOrReplaceState).call(this,t,!0);return}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}pdf_history_assertClassBrand(xf,this,_pushOrReplaceState).call(this,t,i)}function _isValidPage(e){return Number.isInteger(e)&&e>0&&e<=this.linkService.pagesCount}function _isValidState(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)}function _updateInternalState(e,t,i=!1){if(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}function _parseCurrentHash(e=!1){const t=unescape(getCurrentHash()).substring(1),i=parseQueryString(t),a=i.get("nameddest")||"";let s=0|i.get("page");(!pdf_history_assertClassBrand(xf,this,_isValidPage).call(this,s)||e&&a.length>0)&&(s=null);return{hash:t,page:s,rotation:this.linkService.rotation}}function _updateViewarea({location:e}){if(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};if(!this._popStateInProgress){this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++;this._updateViewareaTimeout=setTimeout(()=>{this._popStateInProgress||pdf_history_assertClassBrand(xf,this,_tryPushCurrentPosition).call(this,!0);this._updateViewareaTimeout=null},1e3)}}function _popState({state:e}){const t=getCurrentHash(),i=this._currentHash!==t;this._currentHash=t;if(!e){this._uid++;const{hash:e,page:t,rotation:i}=pdf_history_assertClassBrand(xf,this,_parseCurrentHash).call(this);pdf_history_assertClassBrand(xf,this,_pushOrReplaceState).call(this,{hash:e,page:t,rotation:i},!0);return}if(!pdf_history_assertClassBrand(xf,this,_isValidState).call(this,e))return;this._popStateInProgress=!0;if(i){this._blockHashChange++;waitOnEventOrTimeout({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--})}const a=e.destination;pdf_history_assertClassBrand(xf,this,_updateInternalState).call(this,a,e.uid,!0);isValidRotation(a.rotation)&&(this.linkService.rotation=a.rotation);a.dest?this.linkService.goToDestination(a.dest):a.hash?this.linkService.setHash&&this.linkService.setHash(a.hash):a.page&&(this.linkService.page=a.page);Promise.resolve().then(()=>{this._popStateInProgress=!1})}function _pageHide(){this._destination&&!this._destination.temporary||pdf_history_assertClassBrand(xf,this,_tryPushCurrentPosition).call(this)}function _bindEvents(){if(pdf_history_classPrivateFieldGet(Cf,this))return;pdf_history_classPrivateFieldSet(Cf,this,new AbortController);const{signal:e}=pdf_history_classPrivateFieldGet(Cf,this);this.eventBus.on("updateviewarea",pdf_history_assertClassBrand(xf,this,_updateViewarea).bind(this),{signal:e,...lu});window.addEventListener("popstate",pdf_history_assertClassBrand(xf,this,_popState).bind(this),{signal:e});window.addEventListener("pagehide",pdf_history_assertClassBrand(xf,this,_pageHide).bind(this),{signal:e})}function _unbindEvents(){pdf_history_classPrivateFieldGet(Cf,this)?.abort();pdf_history_classPrivateFieldSet(Cf,this,null)}function pdf_layer_viewer_classPrivateMethodInitSpec(e,t){(function pdf_layer_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function pdf_layer_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var kf=new WeakSet;class PDFLayerViewer extends BaseTreeViewer{constructor(e){super(e);pdf_layer_viewer_classPrivateMethodInitSpec(this,kf);const{eventBus:t}=this;t.on("optionalcontentconfigchanged",e=>{pdf_layer_viewer_assertClassBrand(kf,this,_updateLayers).call(this,e.promise)},lu);t.on("resetlayers",()=>{pdf_layer_viewer_assertClassBrand(kf,this,_updateLayers).call(this)},lu);t.on("togglelayerstree",this._toggleAllTreeItems.bind(this),lu)}reset(){super.reset();this._optionalContentConfig=null;this._optionalContentVisibility?.clear();this._optionalContentVisibility=null}_dispatchEvent(e){this.eventBus.dispatch("layersloaded",{source:this,layersCount:e})}_bindLink(e,{groupId:t,input:i}){const setVisibility=()=>{const e=i.checked;this._optionalContentConfig.setVisibility(t,e);const a=this._optionalContentVisibility.get(t);a&&(a.visible=e);this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(this._optionalContentConfig)})};e.onclick=t=>{if(t.target===i){setVisibility();return!0}if(t.target!==e)return!0;i.checked=!i.checked;setVisibility();return!1}}_setNestedName(e,{name:t=null}){if("string"!=typeof t){e.setAttribute("data-l10n-id","pdfjs-additional-layers");e.style.fontStyle="italic";this._l10n.translateOnce(e)}else 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){this._dispatchEvent(0);return}this._optionalContentVisibility=new Map;const a=document.createDocumentFragment(),s=[{parent:a,groups:i}];let r=0,n=!1;for(;s.length>0;){const t=s.shift();for(const i of t.groups){const a=document.createElement("div");a.className="treeItem";const o=document.createElement("a");a.append(o);if("object"==typeof i){n=!0;this._addToggleButton(a,i);this._setNestedName(o,i);const e=document.createElement("div");e.className="treeItems";a.append(e);s.push({parent:e,groups:i.order})}else{const t=e.getGroup(i),a=document.createElement("label"),s=document.createElement("input");a.append(s,document.createTextNode(this._normalizeTextContent(t.name)));this._bindLink(o,{groupId:i,input:s});s.type="checkbox";s.checked=t.visible;this._optionalContentVisibility.set(i,{input:s,visible:s.checked});o.append(a);r++}t.parent.append(a)}}this._finishRendering(a,r,n)}}async function _updateLayers(e=null){if(!this._optionalContentConfig)return;const t=this._pdfDocument,i=await(e||t.getOptionalContentConfig({intent:"display"}));if(t===this._pdfDocument)if(e)for(const[e,t]of this._optionalContentVisibility){const a=i.getGroup(e);a&&t.visible!==a.visible&&(t.input.checked=t.visible=!t.visible)}else{this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(i)});this.render({optionalContentConfig:i,pdfDocument:this._pdfDocument})}}class PDFOutlineViewer extends BaseTreeViewer{constructor(e){super(e);this.linkService=e.linkService;this.downloadManager=e.downloadManager;const{eventBus:t}=this;t.on("toggleoutlinetree",this._toggleAllTreeItems.bind(this),lu);t.on("currentoutlineitem",this._currentOutlineItem.bind(this),lu);t.on("pagechanging",e=>{this._currentPageNumber=e.pageNumber},lu);t.on("pagesloaded",e=>{this._isPagesLoaded=!!e.pagesCount;this._currentOutlineItemCapability?.resolve(this._isPagesLoaded)},lu);t.on("sidebarviewchanged",e=>{this._sidebarView=e.view},lu)}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:a,attachmentId:s,attachment:r,dest:n,setOCGState:o}){const{linkService:l}=this;if(t)l.addLinkAttributes(e,t,i);else if(a){e.href=l.getAnchorUrl("");e.onclick=()=>{l.executeNamedAction(a);return!1}}else{if(s&&r){e.href=l.getAnchorUrl("");const openAttachment=async()=>{const e=await l.getAttachmentContent(s);e&&this.downloadManager?.openOrDownloadData(e,r.filename)};e.onclick=()=>{openAttachment();return!1};return}if(o){e.href=l.getAnchorUrl("");e.onclick=()=>{l.executeSetOCGState(o);return!1}}else{e.href=l.getDestinationHash(n);e.onclick=e=>{this._updateCurrentTreeItem(e.target.parentNode);n&&l.goToDestination(n);return!1}}}}_setStyles(e,{bold:t,italic:i}){t&&(e.style.fontWeight="bold");i&&(e.style.fontStyle="italic")}_addToggleButton(e,{count:t,items:i}){let a=!1;if(t<0){let e=i.length;if(e>0){const t=[...i];for(;t.length>0;){const{count:i,items:a}=t.shift();if(i>0&&a.length>0){e+=a.length;t.push(...a)}}}Math.abs(t)===e&&(a=!0)}super._addToggleButton(e,a)}_toggleAllTreeItems(){this._outline&&super._toggleAllTreeItems()}render({outline:e,pdfDocument:t}){this._outline&&this.reset();this._outline=e||null;this._pdfDocument=t||null;if(!e){this._dispatchEvent(0);return}const i=document.createDocumentFragment(),a=[{parent:i,items:e}];let s=0,r=!1;for(;a.length>0;){const e=a.shift();for(const t of e.items){const i=document.createElement("div");i.className="treeItem";const n=document.createElement("a");this._bindLink(n,t);this._setStyles(n,t);n.textContent=this._normalizeTextContent(t.title);i.append(n);if(t.items.length>0){r=!0;this._addToggleButton(i,t);const e=document.createElement("div");e.className="treeItems";i.append(e);a.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);if(this._sidebarView===W_)for(let t=this._currentPageNumber;t>0;t--){const i=e.get(t);if(!i)continue;const a=this.container.querySelector(`a[href="${i}"]`);if(a){this._scrollToCurrentTreeItem(a.parentNode);break}}}}async _getPageNumberToDestHash(e){if(this._pageNumberToDestHashCapability)return this._pageNumberToDestHashCapability.promise;this._pageNumberToDestHashCapability=Promise.withResolvers();const t=new Map,i=new Map,a=[{nesting:0,items:this._outline}];for(;a.length>0;){const s=a.shift(),r=s.nesting;for(const{dest:n,items:o}of s.items){let s,l;if("string"==typeof n){s=await e.getDestination(n);if(e!==this._pdfDocument)return null}else s=n;if(Array.isArray(s)){const[a]=s;a&&"object"==typeof a?l=e.cachedPageNumber(a):Number.isInteger(a)&&(l=a+1);if(Number.isInteger(l)&&(!t.has(l)||r>i.get(l))){const e=this.linkService.getDestinationHash(n);t.set(l,e);i.set(l,r)}}o.length>0&&a.push({nesting:r+1,items:o})}}this._pageNumberToDestHashCapability.resolve(t.size>0?t:null);return this._pageNumberToDestHashCapability.promise}}function pdf_presentation_mode_classPrivateFieldInitSpec(e,t,i){pdf_presentation_mode_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_presentation_mode_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_presentation_mode_classPrivateFieldGet(e,t){return e.get(pdf_presentation_mode_assertClassBrand(e,t))}function pdf_presentation_mode_classPrivateFieldSet(e,t,i){return e.set(pdf_presentation_mode_assertClassBrand(e,t),i),i}function pdf_presentation_mode_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Ef="pdfPresentationMode",Af="pdfPresentationModeControls",Gf=Math.PI/6;var Bf=new WeakMap,Mf=new WeakMap,If=new WeakMap,Tf=new WeakMap,Df=new WeakSet;class PDFPresentationMode{constructor({container:e,pdfViewer:t,eventBus:i}){!function pdf_presentation_mode_classPrivateMethodInitSpec(e,t){pdf_presentation_mode_checkPrivateRedeclaration(e,t),t.add(e)}(this,Df);pdf_presentation_mode_classPrivateFieldInitSpec(this,Bf,I_);pdf_presentation_mode_classPrivateFieldInitSpec(this,Mf,null);pdf_presentation_mode_classPrivateFieldInitSpec(this,If,null);pdf_presentation_mode_classPrivateFieldInitSpec(this,Tf,null);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;pdf_presentation_mode_assertClassBrand(Df,this,_addFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(Df,this,_notifyStateChange).call(this,D_);const i=e.requestFullscreen();pdf_presentation_mode_classPrivateFieldSet(Mf,this,{pageNumber:t.currentPageNumber,scaleValue:t.currentScaleValue,scrollMode:t.scrollMode,spreadMode:null,annotationEditorMode:null});if(!(t.spreadMode===X_.NONE||t.pageViewsReady&&t.hasEqualPageSizes)){ngx_console_NgxConsole.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes.");pdf_presentation_mode_classPrivateFieldGet(Mf,this).spreadMode=t.spreadMode}t.annotationEditorMode!==f.DISABLE&&(pdf_presentation_mode_classPrivateFieldGet(Mf,this).annotationEditorMode=t.annotationEditorMode);try{await i;t.focus();return!0}catch{pdf_presentation_mode_assertClassBrand(Df,this,_removeFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(Df,this,_notifyStateChange).call(this,T_)}return!1}get active(){return pdf_presentation_mode_classPrivateFieldGet(Bf,this)===D_||pdf_presentation_mode_classPrivateFieldGet(Bf,this)===L_}get _ngxViewerRoot(){return this.container.closest("ngx-extended-pdf-viewer")??document}_prepareFullscreenMode(){const e=this._ngxViewerRoot,t=e.getElementsByClassName("zoom")[0].parentElement,i=t.parentElement;this.ngxContainer=i;for(let e=0;e<i.childElementCount;e++)i.children.item(e)===t&&(this.ngxContainerIndex=e);i.removeChild(t);document.body.append(t);const a=document.body.children;for(let e=0;e<a.length;e++){const i=a.item(e);i!==t&&i instanceof HTMLElement&&i.classList.add("hidden-by-fullscreen")}e.querySelector("#sidebarContainer").classList.add("hidden-by-fullscreen");e.getElementsByClassName("toolbar")[0].classList.add("hidden-by-fullscreen")}_tidyUpFullscreenMode(){if(this.ngxContainer){const e=this._ngxViewerRoot,t=e.getElementsByClassName("zoom")[0].parentElement;document.body.removeChild(t);this.ngxContainerIndex>=this.ngxContainer.childElementCount?this.ngxContainer.append(t):this.ngxContainer.insertBefore(t,this.ngxContainer.children.item(this.ngxContainerIndex));this.ngxContainer=void 0;const i=document.body.children;for(let e=0;e<i.length;e++){const a=i.item(e);a!==t&&a instanceof HTMLElement&&a.classList.contains("hidden-by-fullscreen")&&a.classList.remove("hidden-by-fullscreen")}e.querySelector("#sidebarContainer").classList.remove("hidden-by-fullscreen");e.getElementsByClassName("toolbar")[0].classList.remove("hidden-by-fullscreen")}}}function _mouseWheel(e){if(!this.active||e.target.closest?.(".mediaAnnotation"))return;e.preventDefault();const t=function normalizeWheelEventDelta(e){const t=e.deltaMode;let i=normalizeWheelEventDirection(e);t===WheelEvent.DOM_DELTA_PIXEL?i/=900:t===WheelEvent.DOM_DELTA_LINE&&(i/=30);return i}(e),i=Date.now(),a=this.mouseScrollTimeStamp;if(!(i>a&&i-a<50)){(this.mouseScrollDelta>0&&t<0||this.mouseScrollDelta<0&&t>0)&&pdf_presentation_mode_assertClassBrand(Df,this,_resetMouseScrollState).call(this);this.mouseScrollDelta+=t;if(Math.abs(this.mouseScrollDelta)>=.1){const e=this.mouseScrollDelta;pdf_presentation_mode_assertClassBrand(Df,this,_resetMouseScrollState).call(this);(e>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}}}function _notifyStateChange(e){pdf_presentation_mode_classPrivateFieldSet(Bf,this,e);this.eventBus.dispatch("presentationmodechanged",{source:this,state:e})}function _enter(){pdf_presentation_mode_assertClassBrand(Df,this,_notifyStateChange).call(this,L_);this.container.classList.add(Ef);setTimeout(()=>{this.pdfViewer.scrollMode=$_.PAGE;null!==pdf_presentation_mode_classPrivateFieldGet(Mf,this).spreadMode&&(this.pdfViewer.spreadMode=X_.NONE);this.pdfViewer.currentPageNumber=pdf_presentation_mode_classPrivateFieldGet(Mf,this).pageNumber;this.pdfViewer.currentScaleValue="page-fit";null!==pdf_presentation_mode_classPrivateFieldGet(Mf,this).annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:f.NONE})},0);pdf_presentation_mode_assertClassBrand(Df,this,_addWindowListeners).call(this);pdf_presentation_mode_assertClassBrand(Df,this,_showControls).call(this);this.contextMenuOpen=!1;document.getSelection().empty()}function _exit(){const e=this.pdfViewer.currentPageNumber;this.container.classList.remove(Ef);setTimeout(()=>{pdf_presentation_mode_assertClassBrand(Df,this,_removeFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(Df,this,_notifyStateChange).call(this,T_);this.pdfViewer.scrollMode=pdf_presentation_mode_classPrivateFieldGet(Mf,this).scrollMode;null!==pdf_presentation_mode_classPrivateFieldGet(Mf,this).spreadMode&&(this.pdfViewer.spreadMode=pdf_presentation_mode_classPrivateFieldGet(Mf,this).spreadMode);this.pdfViewer.currentScaleValue=pdf_presentation_mode_classPrivateFieldGet(Mf,this).scaleValue;this.pdfViewer.currentPageNumber=e;null!==pdf_presentation_mode_classPrivateFieldGet(Mf,this).annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:pdf_presentation_mode_classPrivateFieldGet(Mf,this).annotationEditorMode});pdf_presentation_mode_classPrivateFieldSet(Mf,this,null)},0);pdf_presentation_mode_assertClassBrand(Df,this,_removeWindowListeners).call(this);pdf_presentation_mode_assertClassBrand(Df,this,_hideControls).call(this);pdf_presentation_mode_assertClassBrand(Df,this,_resetMouseScrollState).call(this);this.contextMenuOpen=!1}function _mouseDown(e){if(this.contextMenuOpen){this.contextMenuOpen=!1;e.preventDefault()}else if(0===e.button&&!(e.target.href&&e.target.parentNode?.hasAttribute("data-internal-link")||e.target.closest?.(".mediaAnnotation"))){e.preventDefault();e.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()}}function _contextMenu(){this.contextMenuOpen=!0}function _showControls(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(Af);this.controlsTimeout=setTimeout(()=>{this.container.classList.remove(Af);delete this.controlsTimeout},3e3)}function _hideControls(){if(this.controlsTimeout){clearTimeout(this.controlsTimeout);this.container.classList.remove(Af);delete this.controlsTimeout}}function _resetMouseScrollState(){this.mouseScrollTimeStamp=0;this.mouseScrollDelta=0}function _touchSwipe(e){if(this.active)if(e.target.closest?.(".mediaAnnotation"))this.touchSwipeState=null;else 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,a=this.touchSwipeState.endY-this.touchSwipeState.startY,s=Math.abs(Math.atan2(a,i));Math.abs(i)>50&&(s<=Gf||s>=Math.PI-Gf)?t=i:Math.abs(a)>50&&Math.abs(s-Math.PI/2)<=Gf&&(t=a);t>0?this.pdfViewer.previousPage():t<0&&this.pdfViewer.nextPage()}}function _addWindowListeners(){if(pdf_presentation_mode_classPrivateFieldGet(Tf,this))return;pdf_presentation_mode_classPrivateFieldSet(Tf,this,new AbortController);const{signal:e}=pdf_presentation_mode_classPrivateFieldGet(Tf,this),t=pdf_presentation_mode_assertClassBrand(Df,this,_touchSwipe).bind(this);window.addEventListener("mousemove",pdf_presentation_mode_assertClassBrand(Df,this,_showControls).bind(this),{signal:e});window.addEventListener("mousedown",pdf_presentation_mode_assertClassBrand(Df,this,_mouseDown).bind(this),{signal:e});window.addEventListener("wheel",pdf_presentation_mode_assertClassBrand(Df,this,_mouseWheel).bind(this),{passive:!1,signal:e});window.addEventListener("keydown",pdf_presentation_mode_assertClassBrand(Df,this,_resetMouseScrollState).bind(this),{signal:e});window.addEventListener("contextmenu",pdf_presentation_mode_assertClassBrand(Df,this,_contextMenu).bind(this),{signal:e});window.addEventListener("touchstart",t,{signal:e});window.addEventListener("touchmove",t,{signal:e});window.addEventListener("touchend",t,{signal:e})}function _removeWindowListeners(){pdf_presentation_mode_classPrivateFieldGet(Tf,this)?.abort();pdf_presentation_mode_classPrivateFieldSet(Tf,this,null)}function _addFullscreenChangeListeners(){if(!pdf_presentation_mode_classPrivateFieldGet(If,this)){pdf_presentation_mode_classPrivateFieldSet(If,this,new AbortController);window.addEventListener("fullscreenchange",()=>{document.fullscreenElement?pdf_presentation_mode_assertClassBrand(Df,this,_enter).call(this):pdf_presentation_mode_assertClassBrand(Df,this,_exit).call(this)},{signal:pdf_presentation_mode_classPrivateFieldGet(If,this).signal})}}function _removeFullscreenChangeListeners(){pdf_presentation_mode_classPrivateFieldGet(If,this)?.abort();pdf_presentation_mode_classPrivateFieldSet(If,this,null)}function xfa_layer_builder_defineProperty(e,t,i){return(t=function xfa_layer_builder_toPropertyKey(e){var t=function xfa_layer_builder_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function xfa_layer_builder_classPrivateFieldInitSpec(e,t,i){(function xfa_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function xfa_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Lf=new WeakMap;class XfaLayerBuilder{constructor({pdfPage:e,annotationStorage:t=null,linkService:i,xfaHtml:a=null}){xfa_layer_builder_classPrivateFieldInitSpec(this,Lf,!1);xfa_layer_builder_defineProperty(this,"div",null);this.pdfPage=e;this.annotationStorage=t;this.linkService=i;this.xfaHtml=a}async render({viewport:e,intent:t="display"}){let i;if("print"===t)i=this.xfaHtml;else{i=await this.pdfPage.getXfa();if(function xfa_layer_builder_classPrivateFieldGet(e,t){return e.get(xfa_layer_builder_assertClassBrand(e,t))}(Lf,this)||!i)return{textDivs:[]}}const a=!!this.div,s={viewport:e.clone({dontFlip:!0}),div:this.div??=document.createElement("div"),xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:t};return a?XfaLayer.update(s):XfaLayer.render(s)}cancel(){!function xfa_layer_builder_classPrivateFieldSet(e,t,i){return e.set(xfa_layer_builder_assertClassBrand(e,t),i),i}(Lf,this,!0)}hide(){this.div&&(this.div.hidden=!0)}}class BasePrintServiceFactory{static initGlobals(e){}static get supportsPrinting(){throw new Error("Not implemented: supportsPrinting")}static createPrintService(e){throw new Error("Not implemented: createPrintService")}}function canvasTest(e){const t=e.sizes.shift(),i=Math.max(Math.ceil(t[0]),1),a=Math.max(Math.ceil(t[1]),1),s=[i-1,a-1,1,1],r=performance.now(),n="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let o,l;if(n){o=new OffscreenCanvas(1,1);l=new OffscreenCanvas(i,a)}else{o=document.createElement("canvas");o.width=1;o.height=1;l=document.createElement("canvas");l.width=i;l.height=a}const d=o.getContext("2d"),c=l.getContext("2d");if(c){c.fillRect.apply(c,s);d.drawImage(l,i-1,a-1,1,1,0,0,1,1)}const h=d&&0!==d.getImageData(0,0,1,1).data[3],_=parseInt(performance.now()-r);[o,l].forEach(e=>{e.height=0;e.width=0});if(n){postMessage({width:i,height:a,testTime:_,isTestPass:h});!h&&e.sizes.length&&setTimeout(()=>{canvasTest(e)},0)}else if(h)e.onSuccess({width:i,height:a,testTime:_});else{e.onError({width:i,height:a,testTime:_});e.sizes.length&&setTimeout(()=>{canvasTest(e)},0)}return h}const Rf={area:[16384,14188,11402,11180,10836,8192,4096,1],height:[8388607,65535,32767,16384,8192,4096,1],width:[4194303,65535,32767,16384,8192,4096,1]},Of={max:null,min:1,sizes:[],step:1024,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},Nf={};function createSizesArray(e){const t=e.width===e.height,i=1===e.height,a=1===e.width,s=[];if(e.width&&e.height){const r=e.min||Of.min,n=e.step||Of.step;let o=Math.max(e.width,e.height);for(;o>=r;){const e=t||i?o:1,r=t||a?o:1;s.push([e,r]);o-=n}}else e.sizes.forEach(e=>{const r=t||i?e:1,n=t||a?e:1;s.push([r,n])});return s}function handleMethod(e){const t="undefined"!=typeof window,i=t&&"Promise"in window,a=t&&"HTMLCanvasElement"in window,s=t&&"OffscreenCanvas"in window,r=URL.createObjectURL(new Blob([])).slice(-36),n=performance.now(),{onError:o,onSuccess:l,...d}=e,getTotalTime=()=>parseInt(performance.now()-n);let c=null;if(!a)return!1;if(e.useWorker&&s){const e=`\n            var canvasTest = ${canvasTest.toString()};\n            onmessage = function(e) {\n                canvasTest(e.data);\n            };\n        `,t=new Blob([e],{type:"application/javascript"}),i=URL.createObjectURL(t);c=new Worker(i);URL.revokeObjectURL(i);c.onmessage=function(e){const{width:t,height:i,testTime:a,isTestPass:s}=e.data,n={width:t,height:i,testTime:a,totalTime:getTotalTime()};if(s){Nf[r].onSuccess(n);delete Nf[r]}else Nf[r].onError(n)}}if(i)return new Promise(t=>{const i={...e,onError(i){let{width:a,height:s,testTime:r}=i;const n={width:a,height:s,testTime:r,totalTime:getTotalTime()};let l;if(0===e.sizes.length)l=!0;else{const[[t,i]]=e.sizes.slice(-1);l=a===t&&s===i}o(n);l&&t({...n,success:!1})},onSuccess(e){let{width:i,height:a,testTime:s}=e;const r={width:i,height:a,testTime:s,totalTime:getTotalTime()};l(r);t({...r,success:!0})}};if(c){const{onError:e,onSuccess:t}=i;Nf[r]={onError:e,onSuccess:t};c.postMessage(d)}else canvasTest(i)});if(!c)return canvasTest(e);Nf[r]={onError:o,onSuccess:l};c.postMessage(d)}const Wf={maxArea(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:e.max,height:e.max,min:e.min,step:e.step,sizes:[...Rf.area]});return handleMethod({...Of,...e,sizes:t})},maxHeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:1,height:e.max,min:e.min,step:e.step,sizes:[...Rf.height]});return handleMethod({...Of,...e,sizes:t})},maxWidth(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:e.max,height:1,min:e.min,step:e.step,sizes:[...Rf.width]});return handleMethod({...Of,...e,sizes:t})},test(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={...Of,...e};t.sizes=[...t.sizes];t.width&&t.height&&(t.sizes=[[t.width,t.height]]);return handleMethod(t)}};function max_canvas_size_defineProperty(e,t,i){return(t=function max_canvas_size_toPropertyKey(e){var t=function max_canvas_size_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class MaxCanvasSize{static async determineMaxArea(){const{success:e,width:t,height:i}=await Wf.maxArea({useWorker:!0});if(!e){MaxCanvasSize.maxWidth=4096;MaxCanvasSize.maxArea=16777216;return 4096}MaxCanvasSize.maxArea=t*i;return MaxCanvasSize.maxArea}static async determineMaxWidth(){const{width:e}=await Wf.maxWidth({useWorker:!0});MaxCanvasSize.maxWidth=e;return MaxCanvasSize.maxWidth}static async determineMaxHeight(){const{height:e}=await Wf.maxHeight({useWorker:!0});MaxCanvasSize.maxHeight=e;return MaxCanvasSize.maxHeight}static async determineMaxDimensions(){if(MaxCanvasSize.maxWidth)return MaxCanvasSize.maxWidth;await this.determineMaxArea();await this.determineMaxHeight();await this.determineMaxWidth();return MaxCanvasSize.maxWidth}static async reduceToMaxCanvasSize(e,t){let i=1;if(e>=4096||t>=4096){await this.determineMaxDimensions();i=Math.max(e/MaxCanvasSize.maxWidth,t/MaxCanvasSize.maxHeight,Math.sqrt(e*t/MaxCanvasSize.maxArea));i>1&&(i=Math.ceil(1+100*i)/100)}return i}}max_canvas_size_defineProperty(MaxCanvasSize,"maxWidth",null);max_canvas_size_defineProperty(MaxCanvasSize,"maxHeight",null);max_canvas_size_defineProperty(MaxCanvasSize,"maxArea",null);let jf=null,Vf=null,Uf=null,zf={initialized:!1};class PDFPrintService{constructor({pdfDocument:e,pagesOverview:t,printResolution:i,printAnnotationStoragePromise:a=null,eventBus:s,cspPolicyService:r,pageOrder:n=null},o,l){this.pdfDocument=e;this.pagesOverview=t;this._printResolution=i||150;this.pageOrder=n||Array.from({length:e.numPages},(e,t)=>t+1);this._optionalContentConfigPromise=e.getOptionalContentConfig({intent:"print"});this._printAnnotationStoragePromise=a||Promise.resolve();this.currentPage=-1;this.scratchCanvas=document.createElement("canvas");this.eventBus=s;this.filteredPageCount=l;this.isInPDFPrintRange=o;this.cspPolicyService=r;this._blobUrls=[]}layout(){this.throwIfInactive();const e=document.querySelector("body");e.setAttribute("data-pdfjsprinting",!0);document.querySelector("html").setAttribute("data-pdfjsprinting",!0);const{width:t,height:i}=this.pagesOverview[0];this.pagesOverview.every(e=>e.width===t&&e.height===i)||ngx_console_NgxConsole.warn("Not all pages have the same size. The printed result may be incorrect!");this.pageStyleSheet=document.createElement("style");const a=`@page { size: ${t}pt ${i}pt;}`;this.cspPolicyService?this.cspPolicyService.addTrustedCSS(this.pageStyleSheet,a):this.pageStyleSheet.textContent=a;e.append(this.pageStyleSheet)}destroy(){if(jf!==this)return;this.printContainer.remove();this.printContainer=null;document.querySelector("body").removeAttribute("data-pdfjsprinting");document.querySelector("html").removeAttribute("data-pdfjsprinting");if(this.pageStyleSheet){this.pageStyleSheet.remove();this.pageStyleSheet=null}if(this._blobURLs){for(const e of this._blobURLs)URL.revokeObjectURL(e);this._blobURLs=null}this.scratchCanvas.width=this.scratchCanvas.height=0;this.scratchCanvas=null;for(const e of this._blobUrls)URL.revokeObjectURL(e);this._blobUrls=[];jf=null;ensureOverlay().then(function(){Uf.closeIfActive(Vf);Uf.unregister(Vf);$f=void 0})}renderPages(){if(this.pdfDocument.isPureXfa){!function getXfaHtmlForPrinting(e,t){const i=t.allXfaHtml,a=new SimpleLinkService,s=Math.round(100*PixelsPerInch.PDF_TO_CSS_UNITS)/100;for(const r of i.children){const i=document.createElement("div");i.className="xfaPrintedPage";e.append(i);const n=new XfaLayerBuilder({pdfPage:null,annotationStorage:t.annotationStorage,linkService:a,xfaHtml:r}),o=XfaLayer.getPageViewport(r,{scale:s});n.render({viewport:o,intent:"print"});i.append(n.div)}}(this.printContainer,this.pdfDocument);return Promise.resolve()}const e=this.pagesOverview.length,renderNextPage=(t,i)=>{this.throwIfInactive();for(;;){++this.currentPage;if(this.currentPage>=e)break;if(!this.isInPDFPrintRange||this.isInPDFPrintRange(this.currentPage))break}if(this.currentPage>=e){renderProgress(this.filteredPageCount??e,this.filteredPageCount??e,this.eventBus);t();return}const a=this.currentPage;renderProgress(a,this.filteredPageCount??e,this.eventBus);(async function renderPage(e,t,i,a,s,r,n){const o=jf.scratchCanvas;let l=s/PixelsPerInch.PDF;const d=Math.floor(a.width*l),c=Math.floor(a.height*l),h=await MaxCanvasSize.reduceToMaxCanvasSize(d,c);if(h>1){const e=Math.round(100*(h-1));l=Math.ceil(.95*l/h);warn(`Page ${i}: Reduced the maximum resolution by ${e}% because the browser can't render larger canvases. The resolution is now ${l*PixelsPerInch.PDF} DPI.`)}o.width=Math.floor(a.width*l);o.height=Math.floor(a.height*l);const _=o.getContext("2d");_.save();_.fillStyle="rgb(255, 255, 255)";_.fillRect(0,0,o.width,o.height);_.restore();return Promise.all([t.getPage(i),n]).then(function([e,t]){const i={canvas:o,transform:[l,0,0,l,0,0],viewport:e.getViewport({scale:1,rotation:a.rotation}),intent:"print",annotationMode:p.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:t};return e.render(i).promise.catch(e=>{e instanceof RenderingCancelledException||ngx_console_NgxConsole.error(e);throw e})})})(0,this.pdfDocument,this.pageOrder[a],this.pagesOverview[a],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function(){renderNextPage(t,i)},i)};return new Promise(renderNextPage)}useRenderedPage(){this.throwIfInactive();const e=document.createElement("img"),{promise:t,resolve:i,reject:a}=Promise.withResolvers();e.onload=i;e.onerror=()=>{ngx_console_NgxConsole.error("Failed to load printed page image via blob URL, falling back to data URL.");try{e.onerror=()=>{ngx_console_NgxConsole.error("Print failed: could not load page image even with data URL fallback.");a(new Error("Failed to load printed page image."))};e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: toDataURL fallback also failed.",e);a(e)}};try{this.scratchCanvas.toBlob(t=>{if(!t){ngx_console_NgxConsole.warn("Print: toBlob returned null, falling back to data URL.");try{e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: both toBlob and toDataURL failed.",e);a(e)}return}const i=URL.createObjectURL(t);this._blobUrls.push(i);e.src=i})}catch(t){ngx_console_NgxConsole.warn("Print: toBlob threw, falling back to data URL.",t);try{e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: both toBlob and toDataURL failed.",e);a(e)}}const s=document.createElement("div");s.className="printedPage";s.append(e);this.printContainer.append(s);t.catch(()=>{});return t}performPrint(){this.throwIfInactive();return new Promise(e=>{setTimeout(()=>{if(!this.active){e();return}Hf.call(window);const t=navigator.platform&&["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,i=/Android/i.test(navigator.userAgent);setTimeout(e,t||i?1500:100)},0)})}get active(){return this===jf}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const Hf=globalThis.ngxNativePrint??=window.print;function getPrintElement(e){return"function"==typeof zf._getViewerElementById?zf._getViewerElementById(e):document.getElementById(e)}function dispatchEvent(e){const t=new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:"custom"});t.ngxPrintingApp=zf;window.dispatchEvent(t)}function abort(){if(jf){jf.destroy();dispatchEvent("afterprint")}}function renderProgress(e,t,i){Vf=getPrintElement("printServiceDialog");const a=Math.round(100*e/t),s=Vf.querySelector("progress"),r=Vf.querySelector(".relative-progress");s.value=a;r.setAttribute("data-l10n-args",JSON.stringify({progress:a}));i.dispatch("progress",{source:this,type:"print",total:t,page:e,percent:100*e/t})}window.addEventListener("keydown",function(e){if(80===e.keyCode&&(e.ctrlKey||e.metaKey)&&!e.altKey&&(!e.shiftKey||window.chrome||window.opera)){window.print();e.preventDefault();e.stopImmediatePropagation()}},!0);if("onbeforeprint"in window){const stopPropagationIfNeeded=function(e){"custom"!==e.detail&&e.stopImmediatePropagation()};window.addEventListener("beforeprint",stopPropagationIfNeeded);window.addEventListener("afterprint",stopPropagationIfNeeded)}let $f;function ensureOverlay(){if(!$f){Uf=zf.overlayManager;if(!Uf)throw new Error("The overlay manager has not yet been initialized.");Vf=getPrintElement("printServiceDialog");$f=Uf.register(Vf,!0);getPrintElement("printCancel").onclick=abort;Vf.addEventListener("close",abort)}return $f}class PDFPrintServiceFactory extends BasePrintServiceFactory{static initGlobals(e){zf=e}static get supportsPrinting(){return shadow(this,"supportsPrinting",!0)}static createPrintService(e){if(jf)throw new Error("The print service is created and active.");PDFPrintServiceFactory.enablePrint||ngx_console_NgxConsole.debug("The print service is disabled.");return jf=new PDFPrintService(e,PDFPrintServiceFactory.isInPDFPrintRange,PDFPrintServiceFactory.filteredPageCount)}}function renderable_view_defineProperty(e,t,i){return(t=function renderable_view_toPropertyKey(e){var t=function renderable_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Xf={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3};class RenderableView{constructor(){renderable_view_defineProperty(this,"renderingId","");renderable_view_defineProperty(this,"renderTask",null);renderable_view_defineProperty(this,"resume",null)}get renderingState(){throw new Error("Abstract getter `renderingState` accessed")}set renderingState(e){throw new Error("Abstract setter `renderingState` accessed")}async draw(){throw new Error("Not implemented: draw")}}function pdf_rendering_queue_defineProperty(e,t,i){return(t=function pdf_rendering_queue_toPropertyKey(e){var t=function pdf_rendering_queue_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_rendering_queue_classPrivateFieldInitSpec(e,t,i){(function pdf_rendering_queue_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function pdf_rendering_queue_classPrivateFieldSet(e,t,i){return e.set(pdf_rendering_queue_assertClassBrand(e,t),i),i}function pdf_rendering_queue_classPrivateFieldGet(e,t){return e.get(pdf_rendering_queue_assertClassBrand(e,t))}function pdf_rendering_queue_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Kf=new WeakMap,qf=new WeakMap,Yf=new WeakMap,Zf=new WeakMap;class PDFRenderingQueue{constructor(){pdf_rendering_queue_classPrivateFieldInitSpec(this,Kf,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,qf,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,Yf,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,Zf,null);pdf_rendering_queue_defineProperty(this,"isThumbnailViewEnabled",!1);pdf_rendering_queue_defineProperty(this,"onIdle",null);pdf_rendering_queue_defineProperty(this,"printing",!1);Object.defineProperty(this,"hasViewer",{value:()=>!!pdf_rendering_queue_classPrivateFieldGet(Zf,this)})}setViewer(e){pdf_rendering_queue_classPrivateFieldSet(Zf,this,e)}setThumbnailViewer(e){pdf_rendering_queue_classPrivateFieldSet(Yf,this,e)}isHighestPriority(e){return pdf_rendering_queue_classPrivateFieldGet(Kf,this)===e.renderingId}renderHighestPriority(e){if(pdf_rendering_queue_classPrivateFieldGet(qf,this)){clearTimeout(pdf_rendering_queue_classPrivateFieldGet(qf,this));pdf_rendering_queue_classPrivateFieldSet(qf,this,null)}pdf_rendering_queue_classPrivateFieldGet(Zf,this).forceRendering(e)||this.isThumbnailViewEnabled&&pdf_rendering_queue_classPrivateFieldGet(Yf,this)?.forceRendering()||this.printing||this.onIdle&&pdf_rendering_queue_classPrivateFieldSet(qf,this,setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(e,t,i,a=!1,s=!1){const r=e.views,n=r.length;if(0===n)return null;for(let e=0;e<n;e++){const t=r[e].view;if(!this.isViewFinished(t))return t}if(!s)for(let e=0;e<n;e++){const{detailView:t}=r[e].view;if(t&&!this.isViewFinished(t))return t}const o=e.first.id,l=e.last.id;if(l-o+1>n){const a=e.ids;for(let e=1,s=l-o;e<s;e++){const s=i?o+e:l-e;if(a.has(s))continue;const r=t[s-1];if(!this.isViewFinished(r))return r}}let d=i?l:o-2,c=t[d];if(c&&!this.isViewFinished(c))return c;if(a){d+=i?1:-1;c=t[d];if(c&&!this.isViewFinished(c))return c}return null}isViewFinished(e){return e.renderingState===Xf.FINISHED}renderView(e){switch(e.renderingState){case Xf.FINISHED:return!1;case Xf.PAUSED:pdf_rendering_queue_classPrivateFieldSet(Kf,this,e.renderingId);e.resume();break;case Xf.RUNNING:pdf_rendering_queue_classPrivateFieldSet(Kf,this,e.renderingId);break;case Xf.INITIAL:pdf_rendering_queue_classPrivateFieldSet(Kf,this,e.renderingId);e.draw().finally(()=>{this.renderHighestPriority()}).catch(e=>{e instanceof RenderingCancelledException||ngx_console_NgxConsole.error("renderView:",e)})}return!0}}function pdf_scripting_manager_classPrivateFieldInitSpec(e,t,i){pdf_scripting_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_scripting_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_scripting_manager_classPrivateFieldGet(e,t){return e.get(pdf_scripting_manager_assertClassBrand(e,t))}function pdf_scripting_manager_classPrivateFieldSet(e,t,i){return e.set(pdf_scripting_manager_assertClassBrand(e,t),i),i}function pdf_scripting_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Qf=new WeakMap,Jf=new WeakMap,ev=new WeakMap,tv=new WeakMap,iv=new WeakMap,av=new WeakMap,sv=new WeakMap,rv=new WeakMap,nv=new WeakMap,ov=new WeakMap,lv=new WeakMap,dv=new WeakMap,cv=new WeakMap,hv=new WeakSet;class PDFScriptingManager{constructor({eventBus:e,externalServices:t=null,docProperties:i=null}){!function pdf_scripting_manager_classPrivateMethodInitSpec(e,t){pdf_scripting_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,hv);pdf_scripting_manager_classPrivateFieldInitSpec(this,Qf,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Jf,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,ev,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,tv,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,iv,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,av,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,sv,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,rv,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,nv,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,ov,!1);pdf_scripting_manager_classPrivateFieldInitSpec(this,lv,!1);pdf_scripting_manager_classPrivateFieldInitSpec(this,dv,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,cv,new Map);pdf_scripting_manager_classPrivateFieldSet(iv,this,e);pdf_scripting_manager_classPrivateFieldSet(av,this,t);pdf_scripting_manager_classPrivateFieldSet(ev,this,i)}setViewer(e){pdf_scripting_manager_classPrivateFieldSet(nv,this,e)}async setDocument(e){pdf_scripting_manager_classPrivateFieldGet(rv,this)&&await pdf_scripting_manager_assertClassBrand(hv,this,_destroyScripting).call(this);pdf_scripting_manager_classPrivateFieldSet(rv,this,e);if(!e)return;const[t,i,a]=await Promise.all([e.getFieldObjects(),e.getCalculationOrderIds(),e.getJSActions()]);if(!t&&!a){await pdf_scripting_manager_assertClassBrand(hv,this,_destroyScripting).call(this);return}if(e!==pdf_scripting_manager_classPrivateFieldGet(rv,this))return;if(t){pdf_scripting_manager_classPrivateFieldSet(sv,this,new Set);for(const e of t.values())for(const{id:t}of e)pdf_scripting_manager_classPrivateFieldGet(sv,this).add(t)}try{pdf_scripting_manager_classPrivateFieldSet(dv,this,pdf_scripting_manager_assertClassBrand(hv,this,_initScripting).call(this))}catch(e){ngx_console_NgxConsole.error("setDocument:",e);await pdf_scripting_manager_assertClassBrand(hv,this,_destroyScripting).call(this);return}const s=pdf_scripting_manager_classPrivateFieldGet(iv,this);pdf_scripting_manager_classPrivateFieldSet(tv,this,new AbortController);const r={signal:pdf_scripting_manager_classPrivateFieldGet(tv,this).signal,...lu};s.on("updatefromsandbox",e=>{const t=!e?.ngxSandbox||e.ngxSandbox===pdf_scripting_manager_classPrivateFieldGet(dv,this)?.ngxSandbox;e?.source===window&&t&&pdf_scripting_manager_assertClassBrand(hv,this,_updateFromSandbox).call(this,e.detail)},r);s.on("dispatcheventinsandbox",e=>{pdf_scripting_manager_classPrivateFieldGet(dv,this)?.dispatchEventInSandbox(e.detail)},r);s.on("pagechanging",({pageNumber:e,previous:t})=>{if(e!==t){pdf_scripting_manager_assertClassBrand(hv,this,_dispatchPageClose).call(this,t);pdf_scripting_manager_assertClassBrand(hv,this,_dispatchPageOpen).call(this,e)}},r);s.on("pagerendered",({pageNumber:e})=>{this._pageOpenPending.has(e)&&e===pdf_scripting_manager_classPrivateFieldGet(nv,this).currentPageNumber&&pdf_scripting_manager_assertClassBrand(hv,this,_dispatchPageOpen).call(this,e)},r);s.on("pagesdestroy",async()=>{await pdf_scripting_manager_assertClassBrand(hv,this,_dispatchPageClose).call(this,pdf_scripting_manager_classPrivateFieldGet(nv,this).currentPageNumber);await(pdf_scripting_manager_classPrivateFieldGet(dv,this)?.dispatchEventInSandbox({id:"doc",name:"WillClose"}));pdf_scripting_manager_classPrivateFieldGet(Qf,this)?.resolve()},r);try{const r=await pdf_scripting_manager_classPrivateFieldGet(ev,this).call(this,e);if(e!==pdf_scripting_manager_classPrivateFieldGet(rv,this))return;await pdf_scripting_manager_classPrivateFieldGet(dv,this).createSandbox({objects:t,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...r,actions:a}});e===pdf_scripting_manager_classPrivateFieldGet(rv,this)&&pdf_scripting_manager_classPrivateFieldSet(lv,this,!0);s.dispatch("sandboxcreated",{source:this})}catch(e){ngx_console_NgxConsole.error("setDocument:",e);await pdf_scripting_manager_assertClassBrand(hv,this,_destroyScripting).call(this);return}await(pdf_scripting_manager_classPrivateFieldGet(dv,this)?.dispatchEventInSandbox({id:"doc",name:"Open"}));await pdf_scripting_manager_assertClassBrand(hv,this,_dispatchPageOpen).call(this,pdf_scripting_manager_classPrivateFieldGet(nv,this).currentPageNumber,!0);Promise.resolve().then(()=>{e===pdf_scripting_manager_classPrivateFieldGet(rv,this)&&pdf_scripting_manager_classPrivateFieldSet(ov,this,!0)})}async dispatchWillSave(){return pdf_scripting_manager_assertClassBrand(hv,this,_dispatchDocEventAndWait).call(this,"WillSave")}async dispatchDidSave(){return pdf_scripting_manager_classPrivateFieldGet(dv,this)?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){return pdf_scripting_manager_assertClassBrand(hv,this,_dispatchDocEventAndWait).call(this,"WillPrint")}async dispatchDidPrint(){return pdf_scripting_manager_classPrivateFieldGet(dv,this)?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return pdf_scripting_manager_classPrivateFieldGet(Jf,this)?.promise||null}get ready(){return pdf_scripting_manager_classPrivateFieldGet(ov,this)}get _pageOpenPending(){return shadow(this,"_pageOpenPending",new Set)}get _visitedPages(){return shadow(this,"_visitedPages",new Map)}}async function _dispatchDocEventAndWait(e){if(!pdf_scripting_manager_classPrivateFieldGet(dv,this)||!pdf_scripting_manager_classPrivateFieldGet(lv,this))return;const t=Promise.withResolvers(),i=pdf_scripting_manager_classPrivateFieldGet(cv,this).getOrInsertComputed(e,makeArr);i.push(t);try{await pdf_scripting_manager_classPrivateFieldGet(dv,this).dispatchEventInSandbox({id:"doc",name:e})}catch(e){const a=i.indexOf(t);a>=0&&i.splice(a,1);throw e}await t.promise}async function _updateFromSandbox(e){const t=pdf_scripting_manager_classPrivateFieldGet(nv,this),i=t.isInPresentationMode||t.isChangingPresentationMode,{id:a,siblings:s,command:r,value:n}=e;if(!a){switch(r){case"clear":ngx_console_NgxConsole.clear();break;case"error":ngx_console_NgxConsole.error(n);break;case"layout":if(!i){const e=apiPageLayoutToViewerModes(n);t.spreadMode=e.spreadMode}break;case"page-num":t.currentPageNumber=n+1;break;case"print":await t.pagesPromise;pdf_scripting_manager_classPrivateFieldGet(iv,this).dispatch("print",{source:this});break;case"println":ngx_console_NgxConsole.log(n);break;case"zoom":i||(t.currentScaleValue=n);break;case"SaveAs":pdf_scripting_manager_classPrivateFieldGet(iv,this).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":case"WillSaveFinished":{const e=r.slice(0,-8);pdf_scripting_manager_classPrivateFieldGet(cv,this).get(e)?.shift()?.resolve();break}}return}if(i&&e.focus)return;delete e.id;delete e.siblings;const o=s?[a,...s]:[a];for(const t of o){if(!pdf_scripting_manager_classPrivateFieldGet(sv,this)?.has(t))continue;const i=(pdf_scripting_manager_classPrivateFieldGet(nv,this)?.viewer??document).querySelector(`[data-element-id="${t}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:e})):pdf_scripting_manager_classPrivateFieldGet(rv,this)?.annotationStorage.setValue(t,e)}}async function _dispatchPageOpen(e,t=!1){const i=pdf_scripting_manager_classPrivateFieldGet(rv,this),a=this._visitedPages;t&&pdf_scripting_manager_classPrivateFieldSet(Qf,this,Promise.withResolvers());if(!pdf_scripting_manager_classPrivateFieldGet(Qf,this))return;const s=pdf_scripting_manager_classPrivateFieldGet(nv,this).getPageView(e-1);if(s?.renderingState!==Xf.FINISHED){this._pageOpenPending.add(e);return}this._pageOpenPending.delete(e);const r=(async()=>{const t=await(a.has(e)?null:s.pdfPage?.getJSActions());i===pdf_scripting_manager_classPrivateFieldGet(rv,this)&&await(pdf_scripting_manager_classPrivateFieldGet(dv,this)?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:e,actions:t}))})();a.set(e,r)}async function _dispatchPageClose(e){const t=pdf_scripting_manager_classPrivateFieldGet(rv,this),i=this._visitedPages;if(!pdf_scripting_manager_classPrivateFieldGet(Qf,this))return;if(this._pageOpenPending.has(e))return;const a=i.get(e);if(a){i.set(e,null);await a;t===pdf_scripting_manager_classPrivateFieldGet(rv,this)&&await(pdf_scripting_manager_classPrivateFieldGet(dv,this)?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:e}))}}function _initScripting(){pdf_scripting_manager_classPrivateFieldSet(Jf,this,Promise.withResolvers());if(pdf_scripting_manager_classPrivateFieldGet(dv,this))throw new Error("#initScripting: Scripting already exists.");return pdf_scripting_manager_classPrivateFieldGet(av,this).createScripting()}async function _destroyScripting(){pdf_scripting_manager_classPrivateFieldSet(sv,this,null);pdf_scripting_manager_classPrivateFieldSet(lv,this,!1);if(pdf_scripting_manager_classPrivateFieldGet(dv,this)){if(pdf_scripting_manager_classPrivateFieldGet(Qf,this)){await Promise.race([pdf_scripting_manager_classPrivateFieldGet(Qf,this).promise,new Promise(e=>{setTimeout(e,1e3)})]).catch(()=>{});pdf_scripting_manager_classPrivateFieldSet(Qf,this,null)}pdf_scripting_manager_classPrivateFieldSet(rv,this,null);try{await pdf_scripting_manager_classPrivateFieldGet(dv,this).destroySandbox()}catch{}for(const e of pdf_scripting_manager_classPrivateFieldGet(cv,this).values())for(const t of e)t.reject(new Error("Scripting destroyed."));pdf_scripting_manager_classPrivateFieldGet(cv,this).clear();pdf_scripting_manager_classPrivateFieldGet(tv,this)?.abort();pdf_scripting_manager_classPrivateFieldSet(tv,this,null);this._pageOpenPending.clear();this._visitedPages.clear();pdf_scripting_manager_classPrivateFieldSet(dv,this,null);pdf_scripting_manager_classPrivateFieldSet(ov,this,!1);pdf_scripting_manager_classPrivateFieldGet(Jf,this)?.resolve()}else{pdf_scripting_manager_classPrivateFieldSet(rv,this,null);pdf_scripting_manager_classPrivateFieldGet(Jf,this)?.resolve()}}function menu_classPrivateFieldInitSpec(e,t,i){menu_checkPrivateRedeclaration(e,t),t.set(e,i)}function menu_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function menu_classPrivateFieldGet(e,t){return e.get(menu_assertClassBrand(e,t))}function menu_classPrivateFieldSet(e,t,i){return e.set(menu_assertClassBrand(e,t),i),i}function menu_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var _v=new WeakMap,uv=new WeakMap,pv=new WeakMap,gv=new WeakMap,mv=new WeakMap,fv=new WeakMap,vv=new WeakMap,Pv=new WeakSet;class Menu{constructor(e,t,i){!function menu_classPrivateMethodInitSpec(e,t){menu_checkPrivateRedeclaration(e,t),t.add(e)}(this,Pv);menu_classPrivateFieldInitSpec(this,_v,void 0);menu_classPrivateFieldInitSpec(this,uv,void 0);menu_classPrivateFieldInitSpec(this,pv,void 0);menu_classPrivateFieldInitSpec(this,gv,null);menu_classPrivateFieldInitSpec(this,mv,new AbortController);menu_classPrivateFieldInitSpec(this,fv,-1);menu_classPrivateFieldInitSpec(this,vv,menu_assertClassBrand(Pv,this,_onFocusOut).bind(this));menu_classPrivateFieldSet(uv,this,e);menu_classPrivateFieldSet(_v,this,t);menu_classPrivateFieldSet(pv,this,Array.isArray(i)?i:[...menu_classPrivateFieldGet(uv,this).querySelectorAll("button")]);menu_assertClassBrand(Pv,this,_setUpMenu).call(this)}destroy(){menu_assertClassBrand(Pv,this,_closeMenu).call(this);menu_classPrivateFieldGet(mv,this)?.abort();menu_classPrivateFieldSet(mv,this,null)}}function _closeMenu(){if(!menu_classPrivateFieldGet(gv,this))return;const e=menu_classPrivateFieldGet(uv,this);menu_classPrivateFieldGet(_v,this).ariaExpanded="false";menu_classPrivateFieldGet(gv,this).abort();menu_classPrivateFieldSet(gv,this,null);e.contains(document.activeElement)&&setTimeout(()=>{e.contains(document.activeElement)||menu_classPrivateFieldGet(_v,this).focus()},0);menu_classPrivateFieldSet(fv,this,-1)}function _openMenu(){if(menu_classPrivateFieldGet(gv,this))return;const e=menu_classPrivateFieldGet(uv,this);menu_classPrivateFieldGet(_v,this).ariaExpanded="true";menu_classPrivateFieldSet(gv,this,new AbortController);const t=AbortSignal.any([menu_classPrivateFieldGet(mv,this).signal,menu_classPrivateFieldGet(gv,this).signal]);window.addEventListener("pointerdown",({target:t})=>{menu_classPrivateFieldGet(_v,this).contains(t)||e.contains(t)||menu_assertClassBrand(Pv,this,_closeMenu).call(this)},{signal:t});const i=menu_assertClassBrand(Pv,this,_closeMenu).bind(this);window.addEventListener("blur",i,{signal:t});e.addEventListener("focusout",menu_classPrivateFieldGet(vv,this),{signal:t})}function _onFocusOut({relatedTarget:e}){menu_classPrivateFieldGet(_v,this).contains(e)||menu_classPrivateFieldGet(uv,this).contains(e)||menu_assertClassBrand(Pv,this,_closeMenu).call(this)}function _setUpMenu(){menu_classPrivateFieldGet(_v,this).addEventListener("click",e=>{menu_classPrivateFieldGet(gv,this)?menu_assertClassBrand(Pv,this,_closeMenu).call(this):menu_assertClassBrand(Pv,this,_openMenu).call(this)});menu_classPrivateFieldGet(_v,this).addEventListener("focusout",menu_classPrivateFieldGet(vv,this));const{signal:e}=menu_classPrivateFieldGet(mv,this);menu_classPrivateFieldGet(uv,this).addEventListener("keydown",e=>{switch(e.key){case"Escape":menu_assertClassBrand(Pv,this,_closeMenu).call(this);stopEvent(e);break;case"ArrowDown":menu_assertClassBrand(Pv,this,_goToNextItem).call(this,e.target,!0);stopEvent(e);break;case"ArrowUp":menu_assertClassBrand(Pv,this,_goToNextItem).call(this,e.target,!1);stopEvent(e);break;case"Home":menu_assertClassBrand(Pv,this,_goToFirstLast).call(this,!1);stopEvent(e);break;case"End":menu_assertClassBrand(Pv,this,_goToFirstLast).call(this,!0);stopEvent(e);break;default:const{key:t}=e;if(!/^\p{L}$/u.test(t))break;const i=t.toLocaleLowerCase();menu_assertClassBrand(Pv,this,_goToNextItem).call(this,e.target,!0,e=>e.textContent.trim().toLowerCase().startsWith(i));stopEvent(e)}},{signal:e,capture:!0});menu_classPrivateFieldGet(uv,this).addEventListener("contextmenu",noContextMenu,{signal:e});menu_classPrivateFieldGet(uv,this).addEventListener("click",menu_assertClassBrand(Pv,this,_closeMenu).bind(this),{signal:e,capture:!0});menu_classPrivateFieldGet(_v,this).addEventListener("keydown",e=>{switch(e.key){case" ":case"Enter":case"ArrowDown":case"Home":stopEvent(e);menu_classPrivateFieldGet(gv,this)||menu_assertClassBrand(Pv,this,_openMenu).call(this);menu_assertClassBrand(Pv,this,_goToFirstLast).call(this,!1);break;case"ArrowUp":case"End":stopEvent(e);menu_classPrivateFieldGet(gv,this)||menu_assertClassBrand(Pv,this,_openMenu).call(this);menu_assertClassBrand(Pv,this,_goToFirstLast).call(this,!0);break;case"Escape":menu_assertClassBrand(Pv,this,_closeMenu).call(this);stopEvent(e)}},{signal:e})}function _goToNextItem(e,t,i=()=>!0){const a=-1===menu_classPrivateFieldGet(fv,this)?menu_classPrivateFieldGet(pv,this).indexOf(e):menu_classPrivateFieldGet(fv,this),s=menu_classPrivateFieldGet(pv,this).length,r=t?1:s-1;for(let e=(a+r)%s;e!==a;e=(e+r)%s){const t=menu_classPrivateFieldGet(pv,this)[e];if(!t.disabled&&!t.classList.contains("hidden")&&i(t)){t.focus();menu_classPrivateFieldSet(fv,this,e);break}}}function _goToFirstLast(e=!1){const t=menu_classPrivateFieldGet(pv,this)[e?"findLastIndex":"findIndex"](e=>!e.disabled&&!e.classList.contains("hidden"));if(t>=0){menu_classPrivateFieldGet(pv,this)[t].focus();menu_classPrivateFieldSet(fv,this,t)}}function pdf_thumbnail_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_thumbnail_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}let wv=0;var Fv,yv=new WeakMap,bv=new WeakSet;class PDFThumbnailView extends RenderableView{constructor({container:e,eventBus:t,id:i,defaultViewport:a,optionalContentConfigPromise:s,linkService:r,renderingQueue:n,maxCanvasPixels:o,maxCanvasDim:l,pageColors:d,enableSplitMerge:c=!1,enablePageReordering:h=!1}){super();!function pdf_thumbnail_view_classPrivateMethodInitSpec(e,t){pdf_thumbnail_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,bv);!function pdf_thumbnail_view_classPrivateFieldInitSpec(e,t,i){pdf_thumbnail_view_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,yv,Xf.INITIAL);this.id=i;this.renderingId=`thumbnail${i}`;this.pageLabel=null;this.pdfPage=null;this.rotation=0;this.viewport=a;this.pdfPageRotate=a.rotation;this._optionalContentConfigPromise=s||null;this.maxCanvasPixels=o??AppOptions.get("maxCanvasPixels");this.maxCanvasDim=l||AppOptions.get("maxCanvasDim");this.pageColors=d||null;this.eventBus=t;this.linkService=r;this.renderingQueue=n;this.placeholder=null;t.dispatch("rendercustomthumbnail",{pdfThumbnailView:this,linkService:r,id:i,container:e,thumbPageTitlePromiseOrPageL10nArgs:pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this,!0)});const _=e.querySelector(`.${this.renderingId}`);if(_){this.div=_;this.imageContainer=this.div.querySelector(".thumbnailImageContainer")||this.div;this.image=this.div.querySelector(".thumbnailImage")||this.imageContainer.querySelector("img");this.checkbox=this.div.querySelector("input[type='checkbox']");if(this.image){if(c&&!this.checkbox){const e=this.checkbox=document.createElement("input");e.type="checkbox";e.tabIndex=-1;e.setAttribute("data-l10n-id","pdfjs-thumb-page-checkbox1");e.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this));this.div.append(e);this.pasteButton=null}}else pdf_thumbnail_view_assertClassBrand(bv,this,_createStandardThumbnail).call(this,e,i,c,h)}else pdf_thumbnail_view_assertClassBrand(bv,this,_createStandardThumbnail).call(this,e,i,c);_&&pdf_thumbnail_view_assertClassBrand(bv,this,_updateDims).call(this);if(h&&this.div){this.div.addEventListener("dragstart",this._dragStartHandler.bind(this));this.div.addEventListener("dragover",this._dragOverHandler.bind(this));this.div.addEventListener("drop",this._dropHandler.bind(this));this.div.addEventListener("mousedown",this._mouseDownHandler.bind(this))}}clone(e,t){const i=new PDFThumbnailView({container:e,id:t,eventBus:this.eventBus,defaultViewport:this.viewport,optionalContentConfigPromise:this._optionalContentConfigPromise,linkService:this.linkService,renderingQueue:this.renderingQueue,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,enableSplitMerge:!!this.checkbox}),{imageContainer:a}=this;if(!a.classList.contains("missingThumbnailImage")){i.image.replaceWith(this.image.cloneNode(!0));i.imageContainer.classList.remove("missingThumbnailImage")}return i}addPasteButton(e){if(this.pasteButton)return;const t=this.pasteButton=document.createElement("button");t.classList.add("thumbnailPasteButton","viewsManagerButton");t.tabIndex=0;t.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-after");t.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this));const i=document.createElement("span");i.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-label");t.append(i);t.addEventListener("click",()=>{e(this.id)});if(1===this.id){const i=this.prevPasteButton=t.cloneNode(!0);i.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-before");i.addEventListener("click",()=>{e(0)});this.imageContainer.before(i)}this.imageContainer.after(t)}removePasteButton(){this.pasteButton?.remove();this.pasteButton=null;this.prevPasteButton?.remove();this.prevPasteButton=null}toggleSelected(e){this.checkbox&&(this.checkbox.checked=e)}_dragStartHandler(e){e.dataTransfer.setData("text/plain",this.id.toString())}_dragOverHandler(e){e.preventDefault();e.dataTransfer.dropEffect="move";const t=e.currentTarget,i=t.getBoundingClientRect();this._removeDottedLine();i.top<wv&&i.bottom>wv||this._showDottedLine(t,i.height,wv>e.clientY)}_dropHandler(e){e.preventDefault();e.stopPropagation();const t=parseInt(e.dataTransfer.getData("text/plain"),10),i=this.id;this._removeDottedLine();t!==i&&this._movePage(t,i)}_mouseDownHandler(e){wv=e.clientY}_showDottedLine(e,t,i){const a=document.createElement("div");a.className="dotted-line";i?a.style.setProperty("--dotted-line-margin-x",-t+"px"):a.style.setProperty("--dotted-line-margin-x","6px");e.appendChild(a)}_removeDottedLine(){const e=document.querySelector(".dotted-line");e&&e.parentNode.removeChild(e)}_movePage(e,t){const i=this.div.parentNode,a=i.children[e-1],s=i.children[t-1];a&&s&&wb.movePage(e,t)}updateId(e){this.id=e;this.renderingId=`thumbnail${e}`;this.div.setAttribute("page-number",e);this.imageContainer.setAttribute("page-number",e);this.setPageLabel(this.pageLabel)}get renderingState(){return function pdf_thumbnail_view_classPrivateFieldGet(e,t){return e.get(pdf_thumbnail_view_assertClassBrand(e,t))}(yv,this)}set renderingState(e){!function pdf_thumbnail_view_classPrivateFieldSet(e,t,i){return e.set(pdf_thumbnail_view_assertClassBrand(e,t),i),i}(yv,this,e)}setPdfPage(e){if(!e)return;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=Xf.INITIAL;pdf_thumbnail_view_assertClassBrand(bv,this,_updateDims).call(this);const{image:e,imageContainer:t}=this,i=e.src;if(i){URL.revokeObjectURL(i);e.src="";t.removeAttribute("data-l10n-id");t.removeAttribute("data-l10n-args");t.classList.add("missingThumbnailImage")}}destroy(){this.reset();this.toggleCurrent(!1);this.div.remove()}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()}toggleCurrent(e){const{imageContainer:t}=this;if(e){t.ariaCurrent="page";t.tabIndex=0;this.checkbox&&(this.checkbox.tabIndex=0)}else{t.ariaCurrent=!1;t.tabIndex=-1;this.checkbox&&(this.checkbox.tabIndex=-1)}}cancelRendering(){if(this.renderTask){this.renderTask.cancel();this.renderTask=null}this.resume=null}async draw(){if(this.renderingState!==Xf.INITIAL){ngx_console_NgxConsole.error("Must be in new state before drawing");return}const{pageColors:e,pdfPage:t}=this;if(!t){this.renderingState=Xf.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Xf.RUNNING;const{canvas:i,transform:a}=pdf_thumbnail_view_assertClassBrand(bv,this,_getPageDrawContext).call(this,2),s={canvas:i,transform:a,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:e},r=this.renderTask=t.render(s);r.onContinue=e=>{if(this.renderingQueue.isHighestPriority(this))e();else{this.renderingState=Xf.PAUSED;this.resume=()=>{this.renderingState=Xf.RUNNING;e()}}};let n=null;try{await r.promise}catch(e){if(e instanceof RenderingCancelledException)return;n=e}finally{r===this.renderTask&&(this.renderTask=null)}this.renderingState=Xf.FINISHED;await pdf_thumbnail_view_assertClassBrand(bv,this,_convertCanvasToImage).call(this,i);this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:t});if(n)throw n}setImage(e){if(this.renderingState!==Xf.INITIAL)return;const{thumbnailCanvas:t,pdfPage:i,scale:a}=e;if(t){this.pdfPage||this.setPdfPage(i);if(!(a<this.scale)){this.renderingState=Xf.FINISHED;pdf_thumbnail_view_assertClassBrand(bv,this,_convertCanvasToImage).call(this,t)}}}setPageLabel(e){this.pageLabel="string"==typeof e?e:null;this.imageContainer.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this,!0));this.image.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this));this.checkbox?.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this))}}function _createStandardThumbnail(e,t,i,a=!1){const s=this.div=document.createElement("div");s.className="thumbnail";s.setAttribute("page-number",t);const r=this.imageContainer=document.createElement("div");s.append(r);r.classList.add("thumbnailImageContainer","missingThumbnailImage");r.role="button";r.tabIndex=-1;r.draggable=!1;r.setAttribute("page-number",t);r.setAttribute("data-l10n-id","pdfjs-thumb-page-title1");r.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this,!0));const n=this.image=document.createElement("img");r.append(n);a&&(r.draggable=!0);if(i){const e=this.checkbox=document.createElement("input");e.type="checkbox";e.tabIndex=-1;e.setAttribute("data-l10n-id","pdfjs-thumb-page-checkbox1");e.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this));s.append(e);this.pasteButton=null}pdf_thumbnail_view_assertClassBrand(bv,this,_updateDims).call(this);e.append(s)}function _updateDims(){const{width:e,height:t}=this.viewport,i=e/t,a=this.canvasWidth=126,s=this.canvasHeight=a/i|0;this.scale=a/e;this.imageContainer.style.height=`${s}px`}function _getPageDrawContext(e=1){const t=new OutputScale,i=e*this.canvasWidth,a=e*this.canvasHeight;t.limitCanvas(i,a,this.maxCanvasPixels,this.maxCanvasDim);const s=document.createElement("canvas");s.width=i*t.sx|0;s.height=a*t.sy|0;return{canvas:s,transform:t.scaled?[t.sx,0,0,t.sy,0,0]:null}}async function _convertCanvasToImage(e){if(this.renderingState!==Xf.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const t=pdf_thumbnail_view_assertClassBrand(bv,this,_reduceImage).call(this,e),{imageContainer:i,image:a}=this,{promise:s,resolve:r}=Promise.withResolvers();t.toBlob(r);const n=await s;a.src=URL.createObjectURL(n);a.setAttribute("data-l10n-id","pdfjs-thumb-page-canvas");a.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(bv,this,_getPageL10nArgs).call(this));i.classList.remove("missingThumbnailImage")}function _getReducedImageDims(e){const t=e.width<<3,i=e.height<<3,a=new OutputScale;a.sx=a.sy=1;a.limitCanvas(t,i,this.maxCanvasPixels,this.maxCanvasDim);return[t*a.sx|0,i*a.sy|0]}function _reduceImage(e){const{canvas:t}=pdf_thumbnail_view_assertClassBrand(bv,this,_getPageDrawContext).call(this,1),i=t.getContext("2d",{alpha:!1,willReadFrequently:!1});if(e.width<=2*t.width){i.drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height);return t}let[a,s]=pdf_thumbnail_view_assertClassBrand(bv,this,_getReducedImageDims).call(this,t);const[r,n]=function getTempCanvas(e,t){const i=new OffscreenCanvas(e,t),a=i.getContext("2d",{alpha:!1});a.save();a.fillStyle="rgb(255, 255, 255)";a.fillRect(0,0,e,t);a.restore();return[i,a]}(a,s);for(;a>e.width||s>e.height;){a>>=1;s>>=1}n.drawImage(e,0,0,e.width,e.height,0,0,a,s);for(;a>2*t.width;){n.drawImage(r,0,0,a,s,0,0,a>>1,s>>1);a>>=1;s>>=1}i.drawImage(r,0,0,a,s,0,0,t.width,t.height);return t}function _getPageL10nArgs(e=!1){return JSON.stringify({page:this.pageLabel??this.id,total:e?this.linkService.pagesCount:void 0})}function pdf_thumbnail_viewer_classPrivateFieldInitSpec(e,t,i){pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_thumbnail_viewer_toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function pdf_thumbnail_viewer_classPrivateFieldGet(e,t){return e.get(pdf_thumbnail_viewer_assertClassBrand(e,t))}function pdf_thumbnail_viewer_classPrivateFieldSet(e,t,i){return e.set(pdf_thumbnail_viewer_assertClassBrand(e,t),i),i}function pdf_thumbnail_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Sv={behavior:"instant",block:"nearest",inline:"nearest",container:"nearest"};var Cv=new WeakMap,xv=new WeakMap,kv=new WeakMap,Ev=new WeakMap,Av=new WeakMap,Gv=new WeakMap,Bv=new WeakMap,Mv=new WeakMap,Iv=new WeakMap,Tv=new WeakMap,Dv=new WeakMap,Lv=new WeakMap,Rv=new WeakMap,Ov=new WeakMap,Nv=new WeakMap,Wv=new WeakMap,jv=new WeakMap,Vv=new WeakMap,Uv=new WeakMap,zv=new WeakMap,Hv=new WeakMap,$v=new WeakMap,Xv=new WeakMap,Kv=new WeakMap,qv=new WeakMap,Yv=new WeakMap,Zv=new WeakMap,Qv=new WeakMap,Jv=new WeakMap,eP=new WeakMap,tP=new WeakMap,iP=new WeakMap,aP=new WeakMap,sP=new WeakMap,rP=new WeakMap,nP=new WeakMap,oP=new WeakMap,lP=new WeakMap,dP=new WeakMap,cP=new WeakMap,hP=new WeakMap,_P=new WeakMap,uP=new WeakMap,pP=new WeakMap,gP=new WeakMap,mP=new WeakMap,fP=new WeakMap,vP=new WeakSet;class PDFThumbnailViewer{constructor({container:e,eventBus:t,linkService:i,renderingQueue:a,l10n:s,maxCanvasPixels:r,maxCanvasDim:n,pageColors:o,abortSignal:l,enableMerge:d,enableSplitMerge:c,enablePageReordering:h,enableNewBadge:_,statusBar:u,undoBar:p,waitingBar:g,manageMenu:m,addFileComponent:f}){!function pdf_thumbnail_viewer_classPrivateMethodInitSpec(e,t){pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t),t.add(e)}(this,vP);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Cv,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,xv,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,kv,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Ev,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Av,void 0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Gv,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Bv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Mv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Iv,NaN);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Tv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Dv,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Lv,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Rv,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Ov,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Nv,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Wv,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,jv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Vv,NaN);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Uv,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,zv,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Hv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,$v,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Xv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Kv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,qv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Yv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Zv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Qv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Jv,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,eP,pdf_thumbnail_viewer_assertClassBrand(vP,this,_pastePages).bind(this));pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,tP,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,iP,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,aP,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,sP,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,rP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,nP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,oP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,lP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,dP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,cP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,hP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,_P,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,uP,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,pP,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,gP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,mP,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,fP,0);this.scrollableContainer=e.parentElement;this.container=e;this.eventBus=t;this.linkService=i;this.renderingQueue=a;pdf_thumbnail_viewer_classPrivateFieldSet(mP,this,s);this.maxCanvasPixels=r;this.maxCanvasDim=n;this.pageColors=o||null;pdf_thumbnail_viewer_classPrivateFieldSet(Av,this,l);pdf_thumbnail_viewer_classPrivateFieldSet(Cv,this,d||!1);pdf_thumbnail_viewer_classPrivateFieldSet(xv,this,c||!1);pdf_thumbnail_viewer_classPrivateFieldSet(kv,this,h||!1);pdf_thumbnail_viewer_classPrivateFieldSet(rP,this,u?.viewsManagerStatusActionLabel||null);pdf_thumbnail_viewer_classPrivateFieldSet(oP,this,u?.viewsManagerStatusActionDeselectButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(nP,this,u?.viewsManagerStatusAction||null);pdf_thumbnail_viewer_classPrivateFieldSet(lP,this,p?.viewsManagerStatusUndo||null);pdf_thumbnail_viewer_classPrivateFieldSet(dP,this,p?.viewsManagerStatusUndoLabel||null);pdf_thumbnail_viewer_classPrivateFieldSet(cP,this,p?.viewsManagerStatusUndoButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(hP,this,p?.viewsManagerStatusUndoCloseButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(_P,this,g||null);if(pdf_thumbnail_viewer_classPrivateFieldGet(xv,this)&&m){const{button:e,menu:i,copy:a,cut:s,delete:r,exportSelected:n}=m;if(_){const t=document.createElement("span");t.setAttribute("data-l10n-id","pdfjs-new-badge-content");t.classList.add("newBadge");e.parentElement.before(t);pdf_thumbnail_viewer_classPrivateFieldSet(gP,this,t)}t.on("pagesloaded",()=>{e.disabled=!1},{once:!0,...lu});this._manageMenu=new Menu(i,e,[a,s,r,n]);pdf_thumbnail_viewer_classPrivateFieldSet($v,this,n);n.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(vP,this,_saveExtractedPages).bind(this));pdf_thumbnail_viewer_classPrivateFieldSet(Xv,this,r);r.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(vP,this,_deletePages).bind(this,"delete"));pdf_thumbnail_viewer_classPrivateFieldSet(Kv,this,a);a.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(vP,this,_copyPages).bind(this));pdf_thumbnail_viewer_classPrivateFieldSet(qv,this,s);s.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(vP,this,_cutPages).bind(this));pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleMenuEntries).call(this,!1);e.disabled=!0;t.on("editingaction",({name:e})=>{switch(e){case"copyPage":pdf_thumbnail_viewer_assertClassBrand(vP,this,_copyPages).call(this);break;case"cutPage":pdf_thumbnail_viewer_assertClassBrand(vP,this,_cutPages).call(this);break;case"deletePage":pdf_thumbnail_viewer_assertClassBrand(vP,this,_deletePages).call(this,"delete");break;case"savePage":pdf_thumbnail_viewer_assertClassBrand(vP,this,_saveExtractedPages).call(this)}},lu);this.container.addEventListener("contextmenu",e=>{t.dispatch("editingstateschanged",{source:this,details:{thumbnailId:parseInt(e.target.closest(".thumbnailImageContainer")?.parentElement.getAttribute("page-number"),10)??-1,hasSelectedPages:!!pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)?.size,canDeletePages:pdf_thumbnail_viewer_assertClassBrand(vP,this,_canDelete).call(this)}})},{signal:l,passive:!0});pdf_thumbnail_viewer_classPrivateFieldGet(cP,this)?.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(vP,this,_undo).bind(this));pdf_thumbnail_viewer_classPrivateFieldGet(hP,this)?.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(vP,this,_dismissUndo).bind(this,!0));pdf_thumbnail_viewer_classPrivateFieldGet(oP,this)?.addEventListener("click",()=>{pdf_thumbnail_viewer_assertClassBrand(vP,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,"select")});pdf_thumbnail_viewer_classPrivateFieldGet(oP,this).classList.toggle("hidden",!0)}else m&&(m.button.hidden=!0);if(pdf_thumbnail_viewer_classPrivateFieldGet(Cv,this)&&f?.button&&f.picker){const{picker:e,button:t}=f;e.addEventListener("change",()=>{const t=Array.from(e.files??[]);t.length&&pdf_thumbnail_viewer_assertClassBrand(vP,this,_mergeFiles).call(this,t,this._currentPageNumber-1)});t.addEventListener("click",()=>{e.click()});pdf_thumbnail_viewer_classPrivateFieldGet(_P,this)?.closeButton?.addEventListener("click",()=>{pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleBar).call(this,"status");e.value=""})}this.scroll=watchScroll(this.scrollableContainer,pdf_thumbnail_viewer_assertClassBrand(vP,this,_scrollUpdated).bind(this),l);pdf_thumbnail_viewer_assertClassBrand(vP,this,_resetView).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_addEventListeners).call(this)}getThumbnail(e){return this._thumbnails[e]}scrollThumbnailIntoView(e){if(!this.pdfDocument)return;const t=this._thumbnails[e-1];if(!t){ngx_console_NgxConsole.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');return}if(e!==this._currentPageNumber){pdf_thumbnail_viewer_assertClassBrand(vP,this,_resetCurrentThumbnail).call(this,e);t.toggleCurrent(!0)}const{first:i,last:a,views:s}=pdf_thumbnail_viewer_assertClassBrand(vP,this,_getVisibleThumbs).call(this);if(s.length>0){let r=!1;if(e<=i.id||e>=a.id)r=!0;else for(const{id:t,percent:i}of s)if(t===e){r=i<100;break}r&&t.div.scrollIntoView(Sv)}this._currentPageNumber=e}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!isValidRotation(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)}swapThumbnails(e,t){let i=this._thumbnails[e].pdfPage;this._thumbnails[e].setPdfPage(this._thumbnails[t].pdfPage);this._thumbnails[t].setPdfPage(i)}cleanup(){for(const e of this._thumbnails)e.renderingState!==Xf.FINISHED&&e.reset()}setDocument(e){this.initialized=!1;if(this.pdfDocument){pdf_thumbnail_viewer_assertClassBrand(vP,this,_cancelRendering).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_resetView).call(this)}this.pdfDocument=e;if(!e)return;pdf_thumbnail_viewer_classPrivateFieldSet(Hv,this,e.pagesMapper);const t=e.getPage(1),i=e.getOptionalContentConfig({intent:"display"});t.then(t=>{const a=e.numPages,s=t.getViewport({scale:1}),r=document.createDocumentFragment();for(let e=1;e<=a;++e){const t=new PDFThumbnailView({container:r,eventBus:this.eventBus,id:e,defaultViewport:s.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,eventBus:this.eventBus,enableSplitMerge:pdf_thumbnail_viewer_classPrivateFieldGet(xv,this),enablePageReordering:pdf_thumbnail_viewer_classPrivateFieldGet(kv,this)});this._thumbnails.push(t)}this._thumbnails[0]?.setPdfPage(t);this._thumbnails[this._currentPageNumber-1].toggleCurrent(!0);this.container.append(r);this.eventBus.dispatch("thumbnailsloaded",{source:this})}).catch(e=>{ngx_console_NgxConsole.error("Unable to initialize thumbnail viewer",e)})}setPageLabels(e){if(this.pdfDocument){if(e)if(Array.isArray(e)&&this.pdfDocument.numPages===e.length)this._pageLabels=e;else{this._pageLabels=null;ngx_console_NgxConsole.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")}else this._pageLabels=null;for(let e=0,t=this._thumbnails.length;e<t;e++)this._thumbnails[e].setPageLabel(this._pageLabels?.[e]??null)}}forceRendering(){const e=pdf_thumbnail_viewer_assertClassBrand(vP,this,_getVisibleThumbs).call(this),t=pdf_thumbnail_viewer_assertClassBrand(vP,this,_getScrollAhead).call(this,e),i=this.renderingQueue.getHighestPriority(e,this._thumbnails,t,!1,!0);if(i){pdf_thumbnail_viewer_assertClassBrand(vP,this,_ensurePdfPageLoaded).call(this,i).then(()=>{this.renderingQueue.renderView(i)});return!0}return!1}hasStructuralChanges(){return pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this)?.hasBeenAltered()||!1}getStructuralChanges(){return pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this)?.getPageMappingForSaving()||null}stopRendering(){pdf_thumbnail_viewer_assertClassBrand(vP,this,_cancelRendering).call(this)}}Fv=PDFThumbnailViewer;function _scrollUpdated(){this.renderingQueue.renderHighestPriority()}async function _mergeFiles(e,t){pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleBar).call(this,"waiting","pdfjs-views-manager-waiting-for-file");const i=[];for(const a of e){const e=a.type?.startsWith("image/");if(!e&&"application/pdf"!==a.type){if("%PDF-"!==await a.slice(0,5).text())continue}if(e){let e;try{e=await _fileToImageBitmap.call(Fv,a)}catch{continue}i.push({image:e,insertAfter:t})}else i.push({document:await a.bytes(),insertAfter:t})}if(0===i.length){pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleBar).call(this,"status");return}const a=pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this).pagesNumber,s=this.hasStructuralChanges()?this.getStructuralChanges():{pageInfos:[{document:null}],copyLevels:null};s.pageInfos.push(...i);this.eventBus.on("pagesloaded",()=>{pdf_thumbnail_viewer_classPrivateFieldSet(Tv,this,null);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateMenuEntries).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleBar).call(this,"status");const e=pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this).pagesNumber-a;for(let i=t+1,a=t+1+e;i<a;i++){this._thumbnails[i].checkbox&&(this._thumbnails[i].checkbox.checked=!0);pdf_thumbnail_viewer_assertClassBrand(vP,this,_selectPage).call(this,i+1,!0)}e&&pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateCurrentPage).call(this,t+2,!0)},{once:!0,...lu});pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"merge"});this.eventBus.dispatch("saveandload",{source:this,data:s})}function _getVisibleThumbs(){return getVisibleElements({scrollEl:this.scrollableContainer,views:this._thumbnails})}function _resetCurrentThumbnail(e){if(!this.pdfDocument)return;const t=this._thumbnails[this._currentPageNumber-1];t?.toggleCurrent(!1);this._currentPageNumber=e}function _resetView(){this._thumbnails=[];this._currentPageNumber=1;this._pageLabels=null;this._pagesRotation=0;this.container.textContent=""}function _cancelRendering(){for(const e of this._thumbnails)e.cancelRendering()}async function _ensurePdfPageLoaded(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);e.pdfPage||e.setPdfPage(t);return t}catch(e){ngx_console_NgxConsole.error("Unable to get page for thumb view",e);return null}}function _getScrollAhead(e){return 1===e.first?.id||e.last?.id!==this._thumbnails.length&&this.scroll.down}function _getScaleFactor(e){return PP._||(PP._=parseFloat(getComputedStyle(e).getPropertyValue("--thumbnail-dragging-scale")))}function _fitImageDimensions(e,t,{minSide:i=0,maxSide:a}){const s=Math.max(e,t);let r=1;i>0&&s<i?r=i/s:s>a&&(r=a/s);return 1===r?{width:e,height:t}:{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}async function _fileToImageBitmap(e){const t=1024;if("image/svg+xml"!==e.type){const t=await createImageBitmap(e),{width:i,height:a}=_fitImageDimensions.call(Fv,t.width,t.height,{maxSide:4096});if(i===t.width&&a===t.height)return t;const s=new OffscreenCanvas(i,a);s.getContext("2d").drawImage(t,0,0,i,a);t.close();return s.transferToImageBitmap()}const i=URL.createObjectURL(e);try{const e=new Image;e.src=i;await e.decode();const{width:a,height:s}=_fitImageDimensions.call(Fv,e.naturalWidth||t,e.naturalHeight||t,{minSide:t,maxSide:4096}),r=new OffscreenCanvas(a,s);r.getContext("2d").drawImage(e,0,0,a,s);return r.transferToImageBitmap()}finally{URL.revokeObjectURL(i)}}function _updateThumbnails(e){pdf_thumbnail_viewer_assertClassBrand(vP,this,_resetCurrentThumbnail).call(this,0);let t=0;const i=pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this),a=pdf_thumbnail_viewer_classPrivateFieldSet(Zv,this,this._thumbnails),s=this._thumbnails=[],r=document.createDocumentFragment(),n=pdf_thumbnail_viewer_classPrivateFieldGet(tP,this);for(let o=1,l=i.pagesNumber;o<=l;o++){const l=i.getPrevPageNumber(o);if(l<0){let e=pdf_thumbnail_viewer_classPrivateFieldGet(Yv,this).get(-l);e.checkbox&&(e.checkbox.checked=!1);if(n){e.updateId(o);r.append(e.div)}else e=e.clone(r,o);s.push(e);continue}l===e&&(t=o);const d=a[l-1];s.push(d);d.updateId(o);d.checkbox&&(d.checkbox.checked=!1);r.append(d.div)}this.container.replaceChildren(r);return t}function _onStartDragging(e){pdf_thumbnail_viewer_classPrivateFieldSet(zv,this,this.scrollableContainer.scrollTop);pdf_thumbnail_viewer_classPrivateFieldSet(Uv,this,pdf_thumbnail_viewer_classPrivateFieldGet(zv,this)+this.scrollableContainer.clientHeight);pdf_thumbnail_viewer_classPrivateFieldSet(Ev,this,new AbortController);this.container.classList.add("isDragging");pdf_thumbnail_viewer_classPrivateFieldGet(gP,this)?.classList.add("hidden");const t=parseInt(e.getAttribute("page-number"),10);pdf_thumbnail_viewer_classPrivateFieldSet(Iv,this,t-1);if(!pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)?.has(t)){pdf_thumbnail_viewer_classPrivateFieldSet(Vv,this,t);pdf_thumbnail_viewer_assertClassBrand(vP,this,_selectPage).call(this,t,!0)}for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)){const i=this._thumbnails[e-1],a=i.placeholder=document.createElement("div");a.classList.add("thumbnailImageContainer","placeholder");const{div:s,imageContainer:r}=i;s.classList.add("isDragging");a.style.height=getComputedStyle(r).height;r.after(a);if(e!==t){r.classList.add("hidden");continue}if(1===pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this).size){r.classList.add("draggingThumbnail");pdf_thumbnail_viewer_classPrivateFieldSet(Bv,this,r);continue}const n=pdf_thumbnail_viewer_classPrivateFieldSet(Bv,this,document.createElement("div"));n.classList.add("draggingThumbnail","thumbnailImageContainer","multiple");n.style.height=getComputedStyle(r).height;r.replaceWith(n);r.classList.remove("thumbnailImageContainer");n.append(r);n.setAttribute("data-multiple-count",pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this).size)}}function _onStopDragging(e=!1){const t=pdf_thumbnail_viewer_classPrivateFieldGet(Bv,this);pdf_thumbnail_viewer_classPrivateFieldSet(Bv,this,null);const i=pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this);pdf_thumbnail_viewer_classPrivateFieldSet(Iv,this,NaN);pdf_thumbnail_viewer_classPrivateFieldGet(jv,this)?.remove();pdf_thumbnail_viewer_classPrivateFieldSet(jv,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(Ev,this).abort();pdf_thumbnail_viewer_classPrivateFieldSet(Ev,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(gP,this)?.classList.remove("hidden");this.container.classList.remove("isDragging");for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)){const t=this._thumbnails[e-1],{div:i,placeholder:a,imageContainer:s}=t;a.remove();s.classList.remove("draggingThumbnail","hidden");i.classList.remove("isDragging")}if(t.classList.contains("multiple")){const e=t.firstElementChild;t.replaceWith(e);e.classList.add("thumbnailImageContainer")}else t.style.translate="";const a=pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this);if(!isNaN(i)&&e&&(1!==a.size||!a.has(i+1)&&!a.has(i+2))){this._thumbnails[this._currentPageNumber-1]?.toggleCurrent(!1);this._currentPageNumber=-1;const e=i+1,t=Array.from(a).sort((e,t)=>e-t),s=pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this),r=isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(Vv,this))?t[0]:pdf_thumbnail_viewer_classPrivateFieldGet(Vv,this);s.movePages(a,t,e);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateCurrentPage).call(this,pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateThumbnails).call(this,r));pdf_thumbnail_viewer_classPrivateFieldSet(Mv,this,null);a.clear();pdf_thumbnail_viewer_classPrivateFieldSet(Vv,this,NaN);pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,"select");pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"move"});this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:s,type:"move"})}if(!isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(Vv,this))){pdf_thumbnail_viewer_assertClassBrand(vP,this,_selectPage).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(Vv,this),!1);pdf_thumbnail_viewer_classPrivateFieldSet(Vv,this,NaN)}}function _clearSelection(){for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this))this._thumbnails[e-1].toggleSelected(!1);pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this).clear()}function _updateCurrentPage(e,t=!1){setTimeout(()=>{this.forceRendering();const i=e||1;this.linkService.goToPage(i);const a=this._thumbnails[i-1];!t&&this.container.contains(document.activeElement)||a.imageContainer.focus()},0)}function _undo(){pdf_thumbnail_viewer_assertClassBrand(vP,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,"select");if(pdf_thumbnail_viewer_classPrivateFieldGet(Yv,this)){pdf_thumbnail_viewer_classPrivateFieldSet(Yv,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this).cancelCopy();pdf_thumbnail_viewer_assertClassBrand(vP,this,_togglePasteMode).call(this,!1);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this),type:"cancelCopy"})}pdf_thumbnail_viewer_classPrivateFieldSet(tP,this,!1);if(pdf_thumbnail_viewer_classPrivateFieldGet(Zv,this)){const e=this._thumbnails[this._currentPageNumber-1];e?.toggleCurrent(!1);const t=document.createDocumentFragment();for(let e=1,i=pdf_thumbnail_viewer_classPrivateFieldGet(Zv,this).length;e<=i;e++){const i=pdf_thumbnail_viewer_classPrivateFieldGet(Zv,this)[e-1];i.updateId(e);i.checkbox&&(i.checkbox.checked=!1);t.append(i.div)}this.container.replaceChildren(t);this._thumbnails=pdf_thumbnail_viewer_classPrivateFieldGet(Zv,this);pdf_thumbnail_viewer_classPrivateFieldSet(Zv,this,null);const i=e?this._thumbnails.indexOf(e):-1;this._currentPageNumber=i+1;e?.toggleCurrent(-1!==i);pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this).cancelDelete();this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this),type:"cancelDelete"})}}function _dismissUndo(e){pdf_thumbnail_viewer_classPrivateFieldSet(Yv,this,null);if(pdf_thumbnail_viewer_classPrivateFieldGet(Qv,this)){if(pdf_thumbnail_viewer_classPrivateFieldGet(Zv,this)){for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(Qv,this))pdf_thumbnail_viewer_classPrivateFieldGet(Zv,this)[e-1].destroy();pdf_thumbnail_viewer_classPrivateFieldSet(Zv,this,null)}pdf_thumbnail_viewer_classPrivateFieldSet(Qv,this,null)}pdf_thumbnail_viewer_classPrivateFieldSet(tP,this,!1);e&&pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,"select");pdf_thumbnail_viewer_assertClassBrand(vP,this,_togglePasteMode).call(this,!1);pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this).cleanSavedData();this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this),type:"cleanSavedData"})}function _canDelete(){const e=pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)?.size||0;return e>0&&e<this._thumbnails.length}function _toggleBar(e,t,i){var a;const s=pdf_thumbnail_viewer_classPrivateFieldSet(fP,this,(a=pdf_thumbnail_viewer_classPrivateFieldGet(fP,this),++a));pdf_thumbnail_viewer_classPrivateFieldSet(pP,this,"undo"===e);switch(e){case"waiting":pdf_thumbnail_viewer_classPrivateFieldGet(_P,this).label.setAttribute("data-l10n-id",t);break;case"undo":pdf_thumbnail_viewer_classPrivateFieldGet(dP,this).setAttribute("data-l10n-id",t);i&&pdf_thumbnail_viewer_classPrivateFieldGet(dP,this).setAttribute("data-l10n-args",JSON.stringify(i));break;case"status":{const a=pdf_thumbnail_viewer_classPrivateFieldGet(rP,this);t||=a.getAttribute("data-l10n-id");pdf_thumbnail_viewer_classPrivateFieldGet(mP,this).get(t,i).then(r=>{if(s===pdf_thumbnail_viewer_classPrivateFieldGet(fP,this)){pdf_thumbnail_viewer_classPrivateFieldGet(mP,this).pause();a.setAttribute("data-l10n-id",t);i?a.setAttribute("data-l10n-args",JSON.stringify(i)):a.removeAttribute("data-l10n-args");a.textContent=r;pdf_thumbnail_viewer_classPrivateFieldGet(mP,this).resume();pdf_thumbnail_viewer_assertClassBrand(vP,this,_showBar).call(this,e,!!i)}});return}}pdf_thumbnail_viewer_assertClassBrand(vP,this,_showBar).call(this,e)}function _showBar(e,t=!1){pdf_thumbnail_viewer_classPrivateFieldGet(nP,this).classList.toggle("hidden","status"!==e);pdf_thumbnail_viewer_classPrivateFieldGet(_P,this).container.classList.toggle("hidden","waiting"!==e);pdf_thumbnail_viewer_classPrivateFieldGet(lP,this).classList.toggle("hidden","undo"!==e);if("status"===e){pdf_thumbnail_viewer_classPrivateFieldGet(gP,this)?.classList.toggle("hidden",t);pdf_thumbnail_viewer_classPrivateFieldGet(oP,this).classList.toggle("hidden",!t)}}function _togglePasteMode(e){pdf_thumbnail_viewer_classPrivateFieldSet(uP,this,e);if(e){this.container.classList.add("pasteMode");for(const e of this._thumbnails)e.addPasteButton(pdf_thumbnail_viewer_classPrivateFieldGet(eP,this))}else{this.container.classList.remove("pasteMode");for(const e of this._thumbnails)e.removePasteButton()}}function pdf_thumbnail_viewer_reportTelemetry(e){this.eventBus.dispatch("reporttelemetry",{source:this,details:{type:"pageOrganization",data:e}})}function _saveExtractedPages(){pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"exportSelected"});this.eventBus.dispatch("saveextractedpages",{source:this,data:pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this).extractPages(pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this))});pdf_thumbnail_viewer_assertClassBrand(vP,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,"select")}function _copyPages(e=!0){if(!pdf_thumbnail_viewer_classPrivateFieldGet(tP,this)){pdf_thumbnail_viewer_classPrivateFieldSet(Zv,this,null);pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"copy"})}pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(tP,this)?"cut":"copy");const t=pdf_thumbnail_viewer_classPrivateFieldSet(Jv,this,Uint32Array.from(pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)).sort((e,t)=>e-t)),i=pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this);i.copyPages(t);pdf_thumbnail_viewer_classPrivateFieldSet(Yv,this,new Map);for(const e of t)pdf_thumbnail_viewer_classPrivateFieldGet(Yv,this).set(e,this._thumbnails[e-1]);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:i,pageNumbers:t,type:"copy"});e&&pdf_thumbnail_viewer_assertClassBrand(vP,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_togglePasteMode).call(this,!0);pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleMenuEntries).call(this,!1)}function _cutPages(){if(pdf_thumbnail_viewer_assertClassBrand(vP,this,_canDelete).call(this)){pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"cut"});pdf_thumbnail_viewer_classPrivateFieldSet(tP,this,!0);pdf_thumbnail_viewer_assertClassBrand(vP,this,_copyPages).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(vP,this,_deletePages).call(this,"cut")}}function _pastePages(e){pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"paste"});const t=pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this),i=pdf_thumbnail_viewer_classPrivateFieldGet(Jv,this).includes(this._currentPageNumber)?0:this._currentPageNumber;t.pastePages(e);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateThumbnails).call(this,i);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateCurrentPage).call(this,e+1,!0);pdf_thumbnail_viewer_classPrivateFieldSet(Mv,this,null);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:t,hasBeenCut:pdf_thumbnail_viewer_classPrivateFieldGet(tP,this),type:"paste"});pdf_thumbnail_viewer_classPrivateFieldSet(Yv,this,null);pdf_thumbnail_viewer_classPrivateFieldSet(tP,this,!1);pdf_thumbnail_viewer_assertClassBrand(vP,this,_togglePasteMode).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,"select")}function _deletePages(e="delete"){if(!pdf_thumbnail_viewer_assertClassBrand(vP,this,_canDelete).call(this))return;const t=pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this);if("delete"===e){pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"delete"});pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,"delete")}const i=pdf_thumbnail_viewer_classPrivateFieldGet(Hv,this),a=t.has(this._currentPageNumber)?0:this._currentPageNumber,s=pdf_thumbnail_viewer_classPrivateFieldSet(Qv,this,Uint32Array.from(t).sort((e,t)=>e-t));i.deletePages(s);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateCurrentPage).call(this,pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateThumbnails).call(this,a));pdf_thumbnail_viewer_classPrivateFieldSet(Mv,this,null);t.clear();pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateMenuEntries).call(this);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:i,pageNumbers:s,type:e})}function _updateMenuEntries(){if(!pdf_thumbnail_viewer_classPrivateFieldGet($v,this))return;const e=pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)?.size||0;pdf_thumbnail_viewer_classPrivateFieldGet($v,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(Kv,this).disabled=!e;pdf_thumbnail_viewer_classPrivateFieldGet(Xv,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(qv,this).disabled=!pdf_thumbnail_viewer_assertClassBrand(vP,this,_canDelete).call(this)}function _toggleMenuEntries(e){pdf_thumbnail_viewer_classPrivateFieldGet($v,this)&&(pdf_thumbnail_viewer_classPrivateFieldGet($v,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(Xv,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(Kv,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(qv,this).disabled=!e)}function _updateStatus(e){if(!pdf_thumbnail_viewer_classPrivateFieldGet(nP,this)||!pdf_thumbnail_viewer_classPrivateFieldGet(lP,this))return;const t=pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)?.size||0;if("select"===e){pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleBar).call(this,"status",t?"pdfjs-views-manager-pages-status-action-label":"pdfjs-views-manager-pages-status-none-action-label",t?{count:t}:null);return}let i;switch(e){case"copy":i="pdfjs-views-manager-pages-status-undo-copy-label";break;case"cut":i="pdfjs-views-manager-status-undo-cut-label";break;case"delete":i="pdfjs-views-manager-pages-status-undo-delete-label"}pdf_thumbnail_viewer_assertClassBrand(vP,this,_toggleBar).call(this,"undo",i,{count:t});const a="copy"===e;pdf_thumbnail_viewer_classPrivateFieldGet(cP,this).firstElementChild.setAttribute("data-l10n-id",a?"pdfjs-views-manager-status-done-button-label":"pdfjs-views-manager-status-undo-button-label");pdf_thumbnail_viewer_classPrivateFieldGet(hP,this).classList.toggle("hidden",a)}function _moveDraggedContainer(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(iP,this)&&(e=0);(pdf_thumbnail_viewer_classPrivateFieldGet(Dv,this)+e<0||pdf_thumbnail_viewer_classPrivateFieldGet(Dv,this)+pdf_thumbnail_viewer_classPrivateFieldGet(Rv,this)+e>pdf_thumbnail_viewer_classPrivateFieldGet(aP,this))&&(e=0);(pdf_thumbnail_viewer_classPrivateFieldGet(Lv,this)+t<0||pdf_thumbnail_viewer_classPrivateFieldGet(Lv,this)+pdf_thumbnail_viewer_classPrivateFieldGet(Ov,this)+t>pdf_thumbnail_viewer_classPrivateFieldGet(sP,this))&&(t=0);pdf_thumbnail_viewer_classPrivateFieldSet(Dv,this,pdf_thumbnail_viewer_classPrivateFieldGet(Dv,this)+e);pdf_thumbnail_viewer_classPrivateFieldSet(Lv,this,pdf_thumbnail_viewer_classPrivateFieldGet(Lv,this)+t);pdf_thumbnail_viewer_classPrivateFieldSet(Nv,this,pdf_thumbnail_viewer_classPrivateFieldGet(Nv,this)+e);pdf_thumbnail_viewer_classPrivateFieldSet(Wv,this,pdf_thumbnail_viewer_classPrivateFieldGet(Wv,this)+t);pdf_thumbnail_viewer_classPrivateFieldGet(Bv,this).style.translate=`${pdf_thumbnail_viewer_classPrivateFieldGet(Nv,this)}px ${pdf_thumbnail_viewer_classPrivateFieldGet(Wv,this)}px`;pdf_thumbnail_viewer_classPrivateFieldGet(Lv,this)+pdf_thumbnail_viewer_classPrivateFieldGet(Ov,this)>pdf_thumbnail_viewer_classPrivateFieldGet(Uv,this)?this.scrollableContainer.scrollTop=Math.min(this.scrollableContainer.scrollTop+20,pdf_thumbnail_viewer_classPrivateFieldGet(sP,this)):pdf_thumbnail_viewer_classPrivateFieldGet(Lv,this)<pdf_thumbnail_viewer_classPrivateFieldGet(zv,this)&&(this.scrollableContainer.scrollTop=Math.max(this.scrollableContainer.scrollTop-20,0));const i=pdf_thumbnail_viewer_assertClassBrand(vP,this,_findClosestThumbnail).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(Dv,this)+pdf_thumbnail_viewer_classPrivateFieldGet(Rv,this)/2,pdf_thumbnail_viewer_classPrivateFieldGet(Lv,this)+pdf_thumbnail_viewer_classPrivateFieldGet(Ov,this)/2);pdf_thumbnail_viewer_assertClassBrand(vP,this,_positionDragMarker).call(this,i)}function _positionDragMarker(e){if(!e)return;let t=pdf_thumbnail_viewer_classPrivateFieldGet(jv,this);if(!t){t=pdf_thumbnail_viewer_classPrivateFieldSet(jv,this,document.createElement("div"));t.className="dragMarker";this.container.firstChild.before(t)}const[i,a]=e,s=t.style,{bbox:r,x:n}=pdf_thumbnail_viewer_classPrivateFieldGet(Mv,this);let o,l,d,c;if(i<0)if(1===n.length){l=r[1]-15;o=r[0];d=r[2]}else{l=r[1];o=r[0]-15;c=r[3]}else if(1===n.length){l=r[4*i+1]+r[4*i+3]+a;o=r[4*i];d=r[4*i+2]}else{l=r[4*i+1];o=r[4*i]+r[4*i+2]+a;c=r[4*i+3]}s.translate=`${o}px ${l}px`;s.width=d?`${d}px`:"";s.height=c?`${c}px`:""}function _computeThumbnailsPosition(){const e=[],t=[],i=[],a=new Float32Array(4*this._thumbnails.length);let s,r,n,o,l=-1/0,d=-1/0,c=-1;for(let o=0,h=this._thumbnails.length;o<h;o++){const{div:_}=this._thumbnails[o],{offsetTop:u,offsetLeft:p,offsetWidth:g,offsetHeight:m}=_;if(0===g)return;a[4*o]=p;a[4*o+1]=u;a[4*o+2]=g;a[4*o+3]=m;if(p>l){l=p+g/2;s??=l+g;e.push(l)}if(u>d){-1===c&&e.length>1&&(c=h%e.length);d=u+m/2;n??=d+m;t.push(d)}if(c>0&&o>=h-c){const e=p+g/2;i.push(e);r??=e+g}}o=e.length>1?(e[1]-s)/2:t.length>1?(t[1]-n)/2:15;pdf_thumbnail_viewer_classPrivateFieldSet(Mv,this,{x:e,y:t,lastX:i,space:o,lastSpace:i.length?(i.at(-1)-r)/2:o,bbox:a});pdf_thumbnail_viewer_classPrivateFieldSet(iP,this,1===e.length);({clientWidth:pdf_thumbnail_viewer_toSetter(pdf_thumbnail_viewer_classPrivateFieldSet,[aP,this])._,scrollHeight:pdf_thumbnail_viewer_toSetter(pdf_thumbnail_viewer_classPrivateFieldSet,[sP,this])._}=this.scrollableContainer)}function pdf_thumbnail_viewer_addEventListeners(){this.eventBus.on("resize",({source:e})=>{e.thumbnailsView===this.container&&pdf_thumbnail_viewer_assertClassBrand(vP,this,_computeThumbnailsPosition).call(this)},lu);this.container.addEventListener("keydown",e=>{const{target:t}=e,i=t instanceof HTMLInputElement&&"checkbox"===t.type;switch(e.key){case"ArrowLeft":pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!1,!0,i);stopEvent(e);break;case"ArrowRight":pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!0,!0,i);stopEvent(e);break;case"ArrowDown":pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!0,!1,i);stopEvent(e);break;case"ArrowUp":pdf_thumbnail_viewer_assertClassBrand(vP,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!1,!1,i);stopEvent(e);break;case"Home":pdf_thumbnail_viewer_assertClassBrand(vP,this,_focusThumbnailElement).call(this,this._thumbnails[0],i);stopEvent(e);break;case"End":pdf_thumbnail_viewer_assertClassBrand(vP,this,_focusThumbnailElement).call(this,this._thumbnails.at(-1),i);stopEvent(e);break;case"Enter":case" ":i||pdf_thumbnail_viewer_assertClassBrand(vP,this,_goToPage).call(this,e);break;case"c":if(pdf_thumbnail_viewer_classPrivateFieldGet(xv,this)&&(e.ctrlKey||e.metaKey)&&pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)?.size){pdf_thumbnail_viewer_assertClassBrand(vP,this,_copyPages).call(this);stopEvent(e)}break;case"x":if(pdf_thumbnail_viewer_classPrivateFieldGet(xv,this)&&(e.ctrlKey||e.metaKey)&&pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)?.size){pdf_thumbnail_viewer_assertClassBrand(vP,this,_cutPages).call(this);stopEvent(e)}break;case"Delete":case"Backspace":if(pdf_thumbnail_viewer_classPrivateFieldGet(xv,this)&&!pdf_thumbnail_viewer_classPrivateFieldGet(uP,this)&&pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)?.size){pdf_thumbnail_viewer_assertClassBrand(vP,this,_deletePages).call(this);stopEvent(e)}}});this.container.addEventListener("click",e=>{const{target:t}=e;if(t instanceof HTMLInputElement){const e=parseInt(t.parentElement.getAttribute("page-number"),10);pdf_thumbnail_viewer_assertClassBrand(vP,this,_selectPage).call(this,e,t.checked);return}pdf_thumbnail_viewer_assertClassBrand(vP,this,_goToPage).call(this,e)});pdf_thumbnail_viewer_assertClassBrand(vP,this,_addDragListeners).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_addExternalFileDropListeners).call(this)}function _selectPage(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(pP,this)&&pdf_thumbnail_viewer_assertClassBrand(vP,this,_dismissUndo).call(this,!1);const i=pdf_thumbnail_viewer_classPrivateFieldGet(Tv,this)??pdf_thumbnail_viewer_classPrivateFieldSet(Tv,this,new Set);t?i.add(e):i.delete(e);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateMenuEntries).call(this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_updateStatus).call(this,"select")}function _addDragListeners(){(pdf_thumbnail_viewer_classPrivateFieldGet(xv,this)||pdf_thumbnail_viewer_classPrivateFieldGet(kv,this))&&this.container.addEventListener("pointerdown",e=>{const{target:t,clientX:i,clientY:a,pointerId:s}=e;if(0!==e.button||pdf_thumbnail_viewer_classPrivateFieldGet(uP,this)||1===this._thumbnails.length||!isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this))||!t.classList.contains("thumbnailImageContainer"))return;const r=t.parentElement,n=new AbortController,{signal:o}=n;let l=i,d=a,c=this.scrollableContainer.scrollTop;const h=_getScaleFactor.call(Fv,t);pdf_thumbnail_viewer_classPrivateFieldSet(Wv,this,((h-1)*e.layerY+t.offsetTop)/h);pdf_thumbnail_viewer_classPrivateFieldGet(iP,this)?pdf_thumbnail_viewer_classPrivateFieldSet(Nv,this,t.offsetLeft+.5*(h-1)*t.offsetWidth/h):pdf_thumbnail_viewer_classPrivateFieldSet(Nv,this,((h-1)*e.layerX+t.offsetLeft)/h);pdf_thumbnail_viewer_classPrivateFieldSet(Dv,this,r.offsetLeft+pdf_thumbnail_viewer_classPrivateFieldGet(Nv,this));pdf_thumbnail_viewer_classPrivateFieldSet(Lv,this,r.offsetTop+pdf_thumbnail_viewer_classPrivateFieldGet(Wv,this));pdf_thumbnail_viewer_classPrivateFieldSet(Rv,this,t.offsetWidth/h);pdf_thumbnail_viewer_classPrivateFieldSet(Ov,this,t.offsetHeight/h);this.container.addEventListener("pointermove",e=>{const{clientX:t,clientY:o,pointerId:h}=e;if(isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this))){if(h!==s||Math.abs(t-i)<=5&&Math.abs(o-a)<=5)return;pdf_thumbnail_viewer_assertClassBrand(vP,this,_onStartDragging).call(this,r);const stopDragging=(e,t=!1)=>{pdf_thumbnail_viewer_assertClassBrand(vP,this,_onStopDragging).call(this,t);n.abort()},{signal:e}=pdf_thumbnail_viewer_classPrivateFieldGet(Ev,this);window.addEventListener("touchmove",stopEvent,{passive:!1,signal:e});window.addEventListener("contextmenu",noContextMenu,{signal:e});this.scrollableContainer.addEventListener("scrollend",()=>{const{scrollableContainer:{clientHeight:e,scrollTop:t}}=this;pdf_thumbnail_viewer_classPrivateFieldSet(zv,this,t);pdf_thumbnail_viewer_classPrivateFieldSet(Uv,this,t+e);const i=t-c;c=t;pdf_thumbnail_viewer_assertClassBrand(vP,this,_moveDraggedContainer).call(this,0,i)},{passive:!0,signal:e});window.addEventListener("pointerup",t=>{if(t.pointerId===s){window.addEventListener("click",stopEvent,{capture:!0,once:!0,signal:e});stopEvent(t);stopDragging(t,!0)}},{signal:e});window.addEventListener("blur",stopDragging,{signal:e});window.addEventListener("pointercancel",stopDragging,{signal:e});window.addEventListener("wheel",stopEvent,{passive:!1,signal:e});window.addEventListener("keydown",e=>{"Escape"!==e.key||isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this))||stopDragging(e)},{signal:e})}const _=t-l,u=o-d;l=t;d=o;pdf_thumbnail_viewer_assertClassBrand(vP,this,_moveDraggedContainer).call(this,_,u)},{passive:!0,signal:o});window.addEventListener("pointerup",({pointerId:e})=>{e===s&&n.abort()},{signal:o});window.addEventListener("dragstart",stopEvent,{capture:!0,signal:o})})}function _addExternalFileDropListeners(){if(!pdf_thumbnail_viewer_classPrivateFieldGet(Cv,this))return;const e=this.container,t=pdf_thumbnail_viewer_classPrivateFieldGet(Av,this);e.addEventListener("dragenter",e=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(Gv,this)&&isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this))&&this._thumbnails.length&&(e=>{if(!e)return!1;for(const t of e.items)if("file"===t.kind&&("application/pdf"===t.type||t.type.startsWith("image/")))return!0;return!1})(e.dataTransfer)){e.preventDefault();e.stopPropagation();e.dataTransfer.dropEffect="copy";pdf_thumbnail_viewer_classPrivateFieldSet(Gv,this,!0);this.container.classList.add("isDraggingFile");pdf_thumbnail_viewer_classPrivateFieldSet(Mv,this,null);pdf_thumbnail_viewer_assertClassBrand(vP,this,_computeThumbnailsPosition).call(this);pdf_thumbnail_viewer_classPrivateFieldSet(Iv,this,NaN)}},{signal:t});e.addEventListener("dragover",t=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(Gv,this))return;t.preventDefault();t.stopPropagation();t.dataTransfer.dropEffect="copy";if(!pdf_thumbnail_viewer_classPrivateFieldGet(Mv,this))return;const i=e.getBoundingClientRect(),a=t.clientX-i.left,s=t.clientY-i.top,r=pdf_thumbnail_viewer_assertClassBrand(vP,this,_findClosestThumbnail).call(this,a,s);pdf_thumbnail_viewer_assertClassBrand(vP,this,_positionDragMarker).call(this,r)},{signal:t});e.addEventListener("dragleave",t=>{pdf_thumbnail_viewer_classPrivateFieldGet(Gv,this)&&(t.relatedTarget&&e.contains(t.relatedTarget)||(({clientX:t,clientY:i})=>{const{left:a,right:s,top:r,bottom:n}=e.getBoundingClientRect();return t>=a&&t<s&&i>=r&&i<n})(t)||pdf_thumbnail_viewer_assertClassBrand(vP,this,_endExternalFileDrag).call(this))},{signal:t});e.addEventListener("drop",t=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(Gv,this))return;t.preventDefault();t.stopPropagation();const i=Array.from(t.dataTransfer.files??[]);if(isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this))&&pdf_thumbnail_viewer_classPrivateFieldGet(Mv,this)){const i=e.getBoundingClientRect();pdf_thumbnail_viewer_assertClassBrand(vP,this,_findClosestThumbnail).call(this,t.clientX-i.left,t.clientY-i.top)}const a=isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this))?-1:pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this);pdf_thumbnail_viewer_assertClassBrand(vP,this,_endExternalFileDrag).call(this);i.length&&pdf_thumbnail_viewer_assertClassBrand(vP,this,_mergeFiles).call(this,i,a)},{signal:t})}function _endExternalFileDrag(){pdf_thumbnail_viewer_classPrivateFieldSet(Gv,this,!1);this.container.classList.remove("isDraggingFile");pdf_thumbnail_viewer_classPrivateFieldGet(jv,this)?.remove();pdf_thumbnail_viewer_classPrivateFieldSet(jv,this,null);pdf_thumbnail_viewer_classPrivateFieldSet(Iv,this,NaN)}function _goToPage(e){const t=e.target.closest(".thumbnailImageContainer");if(t){const i=parseInt(t.getAttribute("page-number"),10);this.linkService.goToPage(i);stopEvent(e)}}function _focusThumbnailElement(e,t){t&&e.checkbox?e.checkbox.focus():e.imageContainer.focus()}function pdf_thumbnail_viewer_goToNextItem(e,t,i,a=!1){let s=parseInt(e.parentElement.getAttribute("page-number"),10);isNaN(s)&&(s=this._currentPageNumber);const r=t?1:-1;let n;if(i){const e=MathClamp(s+r,1,this._thumbnails.length+1);n=this._thumbnails[e-1]}else{const e=this._thumbnails[s-1],{x:t,y:i}=e.div.getBoundingClientRect();let a;for(let e=s-1+r;e>=0&&e<this._thumbnails.length;e+=r){const s=this._thumbnails[e],{x:r,y:o}=s.div.getBoundingClientRect();a||o===i||(a=s);if(r===t){n=s;break}}n??=a}n&&pdf_thumbnail_viewer_assertClassBrand(vP,this,_focusThumbnailElement).call(this,n,a)}function _findClosestThumbnail(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(Mv,this)||pdf_thumbnail_viewer_assertClassBrand(vP,this,_computeThumbnailsPosition).call(this);const{x:i,y:a,lastX:s,space:r,lastSpace:n}=pdf_thumbnail_viewer_classPrivateFieldGet(Mv,this),o=pdf_thumbnail_viewer_classPrivateFieldGet(Iv,this);let l,d=o%i.length,c=Math.floor(o/i.length),h=c===a.length-1?s:i;if(a[c]<=t&&t<(a[c+1]??1/0)&&h[d]<=e&&e<(h[d+1]??1/0))return null;c=binarySearchFirstItem(a,e=>t<e);if(pdf_thumbnail_viewer_classPrivateFieldGet(iP,this))l=c-1;else{if(c===a.length)c=a.length-1;else{c=Math.abs(a[c-1]-t)<Math.abs(a[c]-t)?c-1:c}h=c===a.length-1&&s.length>0?s:i;d=binarySearchFirstItem(h,t=>e<t)-1;if(c<0){d<=0&&(d=-1);c=0}l=MathClamp(c*i.length+d,-1,this._thumbnails.length-1)}if(l===o)return null;pdf_thumbnail_viewer_classPrivateFieldSet(Iv,this,l);return[l,c===a.length-1&&s.length>0&&d>=0?n:r]}var PP={_:0};class Page{constructor(e,t){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0};this.createdDensity=t;this.nowDrawingDensity=this.createdDensity;this.render=e}setDensity(e){this.createdDensity=e;this.nowDrawingDensity=e}setDrawingDensity(e){this.nowDrawingDensity=e}setPosition(e){this.state.position=e}setAngle(e){this.state.angle=e}setArea(e){this.state.area=e}setHardDrawingAngle(e){this.state.hardDrawingAngle=e}setHardAngle(e){this.state.hardAngle=e;this.state.hardDrawingAngle=e}setOrientation(e){this.orientation=e}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class PageCollection{constructor(e,t){this.pages=[];this.currentPageIndex=0;this.currentSpreadIndex=0;this.landscapeSpread=[];this.portraitSpread=[];this.render=t;this.app=e;this.currentPageIndex=0;this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[];this.portraitSpread=[];for(let e=0;e<this.pages.length;e++)this.portraitSpread.push([e]);let e=0;if(this.isShowCover){this.pages[0].setDensity("hard");this.landscapeSpread.push([e]);e++}for(let t=e;t<this.pages.length;t+=2)if(t<this.pages.length-1)this.landscapeSpread.push([t,t+1]);else{this.landscapeSpread.push([t]);this.pages[t].setDensity("hard")}}getSpread(){return"landscape"===this.render.getOrientation()?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(e){const t=this.getSpread();for(let i=0;i<t.length;i++)if(e===t[i][0]||e===t[i][1])return i;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(e){if(e>=0&&e<this.pages.length)return this.pages[e];throw new Error("Invalid page number")}nextBy(e){const t=this.pages.indexOf(e);return t<this.pages.length-1?this.pages[t+1]:null}prevBy(e){const t=this.pages.indexOf(e);return t>0?this.pages[t-1]:null}getFlippingPage(e){const t=this.currentSpreadIndex;if("portrait"===this.render.getOrientation())return 0===e?this.pages[t].newTemporaryCopy():this.pages[t-1];{const i=0===e?this.getSpread()[t+1]:this.getSpread()[t-1];return 1===i.length||0===e?this.pages[i[0]]:this.pages[i[1]]}}getBottomPage(e){const t=this.currentSpreadIndex;if("portrait"===this.render.getOrientation())return 0===e?this.pages[t+1]:this.pages[t-1];{const i=0===e?this.getSpread()[t+1]:this.getSpread()[t-1];return 1===i.length?this.pages[i[0]]:0===e?this.pages[i[1]]:this.pages[i[0]]}}showNext(){if(this.currentSpreadIndex<this.getSpread().length){this.currentSpreadIndex++;this.showSpread()}}showPrev(){if(this.currentSpreadIndex>0){this.currentSpreadIndex--;this.showSpread()}}getCurrentPageIndex(){return this.currentPageIndex}show(e=null){null===e&&(e=this.currentPageIndex);if(e<0||e>=this.pages.length)return;const t=this.getSpreadIndexByPage(e);if(null!==t){this.currentSpreadIndex=t;this.showSpread()}}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(e){if(!(e>=0&&e<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=e}showSpread(){const e=this.getSpread()[this.currentSpreadIndex];if(2===e.length){this.render.setLeftPage(this.pages[e[0]]);this.render.setRightPage(this.pages[e[1]])}else if("landscape"===this.render.getOrientation())if(e[0]===this.pages.length-1){this.render.setLeftPage(this.pages[e[0]]);this.render.setRightPage(null)}else{this.render.setLeftPage(null);this.render.setRightPage(this.pages[e[0]])}else{this.render.setLeftPage(null);this.render.setRightPage(this.pages[e[0]])}this.currentPageIndex=e[0];this.app.updatePageIndex(this.currentPageIndex)}}class Helper{static GetDistanceBetweenTwoPoint(e,t){return null===e||null===t?1/0:Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static GetSegmentLength(e){return Helper.GetDistanceBetweenTwoPoint(e[0],e[1])}static GetAngleBetweenTwoLine(e,t){const i=e[0].y-e[1].y,a=t[0].y-t[1].y,s=e[1].x-e[0].x,r=t[1].x-t[0].x;return Math.acos((i*a+s*r)/(Math.sqrt(i*i+s*s)*Math.sqrt(a*a+r*r)))}static PointInRect(e,t){return null===t?null:t.x>=e.left&&t.x<=e.width+e.left&&t.y>=e.top&&t.y<=e.top+e.height?t:null}static GetRotatedPoint(e,t,i){return{x:e.x*Math.cos(i)+e.y*Math.sin(i)+t.x,y:e.y*Math.cos(i)-e.x*Math.sin(i)+t.y}}static LimitPointToCircle(e,t,i){if(Helper.GetDistanceBetweenTwoPoint(e,i)<=t)return i;const a=e.x,s=e.y,r=i.x,n=i.y;let o=Math.sqrt(Math.pow(t,2)*Math.pow(a-r,2)/(Math.pow(a-r,2)+Math.pow(s-n,2)))+a;i.x<0&&(o*=-1);let l=(o-a)*(s-n)/(a-r)+s;a-r+s===0&&(l=t);return{x:o,y:l}}static GetIntersectBetweenTwoSegment(e,t,i){return Helper.PointInRect(e,Helper.GetIntersectBeetwenTwoLine(t,i))}static GetIntersectBeetwenTwoLine(e,t){const i=e[0].y-e[1].y,a=t[0].y-t[1].y,s=e[1].x-e[0].x,r=t[1].x-t[0].x,n=e[0].x*e[1].y-e[1].x*e[0].y,o=t[0].x*t[1].y-t[1].x*t[0].y,l=i*o-a*n,d=s*o-r*n,c=-(n*r-o*s)/(i*r-a*s),h=-(i*o-a*n)/(i*r-a*s);if(isFinite(c)&&isFinite(h))return{x:c,y:h};if(Math.abs(l-d)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(e,t){const i=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y),s=Math.max(i,a),r=[e];function getCord(e,t,i,a,s){return t>e?e+s*(i/a):t<e?e-s*(i/a):e}for(let n=1;n<=s;n+=1)r.push({x:getCord(e.x,t.x,i,s,n),y:getCord(e.y,t.y,a,s,n)});return r}}class HTMLPage extends Page{constructor(e,t,i){super(e,i);this.copiedElement=null;this.temporaryCopy=null;this.isLoad=!1;this.element=t;this.element.classList.add("stf__item");this.element.classList.add("--"+i)}newTemporaryCopy(){if("hard"===this.nowDrawingDensity)return this;if(null===this.temporaryCopy){this.copiedElement=this.element.cloneNode(!0);this.element.parentElement.appendChild(this.copiedElement);this.temporaryCopy=new HTMLPage(this.render,this.copiedElement,this.nowDrawingDensity)}return this.getTemporaryCopy()}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){if(null!==this.temporaryCopy){this.copiedElement.remove();this.copiedElement=null;this.temporaryCopy=null}}draw(e){const t=e||this.nowDrawingDensity,i=this.render.convertToGlobal(this.state.position),a=this.render.getRect().pageWidth,s=this.render.getRect().height;this.element.classList.remove("--simple");const r=`\n            position: absolute;\n            display: block;\n            z-index: ${this.element.style.zIndex};\n            left: 0;\n            top: 0;\n            width: ${a}px;\n            height: ${s}px;\n        `;"hard"===t?this.drawHard(r):this.drawSoft(i,r)}drawHard(e=""){const t=this.render.getRect().left+this.render.getRect().width/2,i=this.state.hardDrawingAngle,a=e+"\n                backface-visibility: hidden;\n                -webkit-backface-visibility: hidden;\n                clip-path: none;\n                -webkit-clip-path: none;\n            "+(0===this.orientation?`transform-origin: ${this.render.getRect().pageWidth}px 0;\n                   transform: translate3d(0, 0, 0) rotateY(${i}deg);`:`transform-origin: 0 0;\n                   transform: translate3d(${t}px, 0, 0) rotateY(${i}deg);`);this.element.style.cssText=a}drawSoft(e,t=""){let i="polygon( ";for(const e of this.state.area)if(null!==e){let t=1===this.render.getDirection()?{x:-e.x+this.state.position.x,y:e.y-this.state.position.y}:{x:e.x-this.state.position.x,y:e.y-this.state.position.y};t=Helper.GetRotatedPoint(t,{x:0,y:0},this.state.angle);i+=t.x+"px "+t.y+"px, "}i=i.slice(0,-2);i+=")";const a=t+`transform-origin: 0 0; clip-path: ${i}; -webkit-clip-path: ${i};`+(this.render.isSafari()&&0===this.state.angle?`transform: translate(${e.x}px, ${e.y}px);`:`transform: translate3d(${e.x}px, ${e.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=a}simpleDraw(e){const t=this.render.getRect(),i=t.pageWidth,a=t.height,s=1===e?t.left+t.pageWidth:t.left,r=t.top;this.element.classList.add("--simple");this.element.style.cssText=`\n            position: absolute;\n            display: block;\n            height: ${a}px;\n            left: ${s}px;\n            top: ${r}px;\n            width: ${i}px;\n            z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(e){super.setOrientation(e);this.element.classList.remove("--left","--right");this.element.classList.add(1===e?"--right":"--left")}setDrawingDensity(e){this.element.classList.remove("--soft","--hard");this.element.classList.add("--"+e);super.setDrawingDensity(e)}}class HTMLPageCollection extends PageCollection{constructor(e,t,i,a){super(e,t);this.element=i;this.pagesElement=a}load(){for(const e of this.pagesElement){const t=new HTMLPage(this.render,e,"hard"===e.dataset.density?"hard":"soft");t.load();this.pages.push(t)}this.createSpread()}}class FlipCalculation{constructor(e,t,i,a){this.direction=e;this.corner=t;this.topIntersectPoint=null;this.sideIntersectPoint=null;this.bottomIntersectPoint=null;this.pageWidth=parseInt(i,10);this.pageHeight=parseInt(a,10)}calc(e){try{this.position=this.calcAngleAndPosition(e);this.calculateIntersectPoint(this.position);return!0}catch(e){return!1}}getFlippingClipArea(){const e=[];let t=!1;e.push(this.rect.topLeft);e.push(this.topIntersectPoint);if(null===this.sideIntersectPoint)t=!0;else{e.push(this.sideIntersectPoint);null===this.bottomIntersectPoint&&(t=!1)}e.push(this.bottomIntersectPoint);(t||"bottom"===this.corner)&&e.push(this.rect.bottomLeft);return e}getBottomClipArea(){const e=[];e.push(this.topIntersectPoint);if("top"===this.corner)e.push({x:this.pageWidth,y:0});else{null!==this.topIntersectPoint&&e.push({x:this.pageWidth,y:0});e.push({x:this.pageWidth,y:this.pageHeight})}null!==this.sideIntersectPoint?Helper.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&e.push(this.sideIntersectPoint):"top"===this.corner&&e.push({x:this.pageWidth,y:this.pageHeight});e.push(this.bottomIntersectPoint);e.push(this.topIntersectPoint);return e}getAngle(){return 0===this.direction?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return 0===this.direction?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return 1===this.direction?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return"top"===this.corner?this.topIntersectPoint:null!==this.sideIntersectPoint?this.sideIntersectPoint:this.topIntersectPoint}getShadowAngle(){const e=Helper.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return 0===this.direction?e:Math.PI-e}calcAngleAndPosition(e){let t=e;this.updateAngleAndGeometry(t);t="top"===this.corner?this.checkPositionAtCenterLine(t,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(t,{x:0,y:this.pageHeight},{x:0,y:0});if(Math.abs(t.x-this.pageWidth)<1&&Math.abs(t.y)<1)throw new Error("Point is too small");return t}updateAngleAndGeometry(e){this.angle=this.calculateAngle(e);this.rect=this.getPageRect(e)}calculateAngle(e){const t=this.pageWidth-e.x+1,i="bottom"===this.corner?this.pageHeight-e.y:e.y;let a=2*Math.acos(t/Math.sqrt(i*i+t*t));i<0&&(a=-a);const s=Math.PI-a;if(!isFinite(a)||s>=0&&s<.003)throw new Error("The G point is too small");"bottom"===this.corner&&(a=-a);return a}getPageRect(e){return"top"===this.corner?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],e):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],e)}getRectFromBasePoint(e,t){return{topLeft:this.getRotatedPoint(e[0],t),topRight:this.getRotatedPoint(e[1],t),bottomLeft:this.getRotatedPoint(e[2],t),bottomRight:this.getRotatedPoint(e[3],t)}}getRotatedPoint(e,t){return{x:e.x*Math.cos(this.angle)+e.y*Math.sin(this.angle)+t.x,y:e.y*Math.cos(this.angle)-e.x*Math.sin(this.angle)+t.y}}calculateIntersectPoint(e){const t={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};if("top"===this.corner){this.topIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]);this.sideIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]);this.bottomIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])}else{this.topIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]);this.sideIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]);this.bottomIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])}}checkPositionAtCenterLine(e,t,i){let a=e;const s=Helper.LimitPointToCircle(t,this.pageWidth,a);if(a!==s){a=s;this.updateAngleAndGeometry(a)}const r=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let n=this.rect.bottomRight,o=this.rect.topLeft;if("bottom"===this.corner){n=this.rect.topRight;o=this.rect.bottomLeft}if(n.x<=0){const e=Helper.LimitPointToCircle(i,r,o);if(e!==a){a=e;this.updateAngleAndGeometry(a)}}return a}getSegmentToShadowLine(){const e=this.getShadowStartPoint();return[e,e!==this.sideIntersectPoint&&null!==this.sideIntersectPoint?this.sideIntersectPoint:this.bottomIntersectPoint]}}class Flip{constructor(e,t){this.flippingPage=null;this.bottomPage=null;this.calc=null;this.state="read";this.render=e;this.app=t}fold(e){this.setState("user_fold");null===this.calc&&this.start(e);this.do(this.render.convertToPage(e))}flip(e){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(e))return;null!==this.calc&&this.render.finishAnimation();if(!this.start(e))return;const t=this.getBoundsRect();this.setState("flipping");const i=t.height/10,a="bottom"===this.calc.getCorner()?t.height-i:i,s="bottom"===this.calc.getCorner()?t.height:0;this.calc.calc({x:t.pageWidth-i,y:a});this.animateFlippingTo({x:t.pageWidth-i,y:a},{x:-t.pageWidth,y:s},!0)}start(e){this.reset();const t=this.render.convertToBook(e),i=this.getBoundsRect(),a=this.getDirectionByPoint(t),s=t.y>=i.height/2?"bottom":"top";if(!this.checkDirection(a))return!1;try{this.flippingPage=this.app.getPageCollection().getFlippingPage(a);this.bottomPage=this.app.getPageCollection().getBottomPage(a);if("landscape"===this.render.getOrientation())if(1===a){const e=this.app.getPageCollection().nextBy(this.flippingPage);if(null!==e&&this.flippingPage.getDensity()!==e.getDensity()){this.flippingPage.setDrawingDensity("hard");e.setDrawingDensity("hard")}}else{const e=this.app.getPageCollection().prevBy(this.flippingPage);if(null!==e&&this.flippingPage.getDensity()!==e.getDensity()){this.flippingPage.setDrawingDensity("hard");e.setDrawingDensity("hard")}}this.render.setDirection(a);this.calc=new FlipCalculation(a,s,i.pageWidth.toString(10),i.height.toString(10));return!0}catch(e){return!1}}do(e){if(null!==this.calc&&this.calc.calc(e)){const e=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea());this.bottomPage.setPosition(this.calc.getBottomPagePosition());this.bottomPage.setAngle(0);this.bottomPage.setHardAngle(0);this.flippingPage.setArea(this.calc.getFlippingClipArea());this.flippingPage.setPosition(this.calc.getActiveCorner());this.flippingPage.setAngle(this.calc.getAngle());0===this.calc.getDirection()?this.flippingPage.setHardAngle(90*(200-2*e)/100):this.flippingPage.setHardAngle(-90*(200-2*e)/100);this.render.setPageRect(this.calc.getRect());this.render.setBottomPage(this.bottomPage);this.render.setFlippingPage(this.flippingPage);this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),e,this.calc.getDirection())}}flipToPage(e,t){const i=this.app.getPageCollection().getCurrentSpreadIndex(),a=this.app.getPageCollection().getSpreadIndexByPage(e);try{if(a>i){this.app.getPageCollection().setCurrentSpreadIndex(a-1);this.flipNext(t)}if(a<i){this.app.getPageCollection().setCurrentSpreadIndex(a+1);this.flipPrev(t)}}catch(e){}}flipNext(e){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:"top"===e?1:this.render.getRect().height-2})}flipPrev(e){this.flip({x:10,y:"top"===e?1:this.render.getRect().height-2})}stopMove(){if(null===this.calc)return;const e=this.calc.getPosition(),t=this.getBoundsRect(),i="bottom"===this.calc.getCorner()?t.height:0;e.x<=0?this.animateFlippingTo(e,{x:-t.pageWidth,y:i},!0):this.animateFlippingTo(e,{x:t.pageWidth,y:i},!1)}showCorner(e){if(!this.checkState("read","fold_corner"))return;const t=this.getBoundsRect(),i=t.pageWidth;if(this.isPointOnCorners(e))if(null===this.calc){if(!this.start(e))return;this.setState("fold_corner");this.calc.calc({x:i-1,y:1});const a=50,s="bottom"===this.calc.getCorner()?t.height-1:1,r="bottom"===this.calc.getCorner()?t.height-a:a;this.animateFlippingTo({x:i-1,y:s},{x:i-a,y:r},!1,!1)}else this.do(this.render.convertToPage(e));else{this.setState("read");this.render.finishAnimation();this.stopMove()}}animateFlippingTo(e,t,i,a=!0){const s=Helper.GetCordsFromTwoPoint(e,t),r=[];for(const e of s)r.push(()=>this.do(e));const n=this.getAnimationDuration(s.length);this.render.startAnimation(r,n,()=>{if(this.calc){i&&(1===this.calc.getDirection()?this.app.turnToPrevPage():this.app.turnToNextPage());if(a){this.render.setBottomPage(null);this.render.setFlippingPage(null);this.render.clearShadow();this.setState("read");this.reset()}}})}getCalculation(){return this.calc}getState(){return this.state}setState(e){if(this.state!==e){this.app.updateState(e);this.state=e}}getDirectionByPoint(e){const t=this.getBoundsRect();if("portrait"===this.render.getOrientation()){if(e.x-t.pageWidth<=t.width/5)return 1}else if(e.x<t.width/2)return 1;return 0}getAnimationDuration(e){const t=this.app.getSettings().flippingTime;return e>=1e3?t:e/1e3*t}checkDirection(e){return 0===e?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null;this.flippingPage=null;this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(...e){for(const t of e)if(this.state===t)return!0;return!1}isPointOnCorners(e){const t=this.getBoundsRect(),i=t.pageWidth,a=Math.sqrt(Math.pow(i,2)+Math.pow(t.height,2))/5,s=this.render.convertToBook(e);return s.x>0&&s.y>0&&s.x<t.width&&s.y<t.height&&(s.x<a||s.x>t.width-a)&&(s.y<a||s.y>t.height-a)}}class Render{constructor(e,t){this.leftPage=null;this.rightPage=null;this.flippingPage=null;this.bottomPage=null;this.direction=null;this.orientation=null;this.shadow=null;this.animation=null;this.pageRect=null;this.boundsRect=null;this.timer=0;this.safari=!1;this.setting=t;this.app=e;const i=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=null!==i.exec(window.navigator.userAgent)}render(e){if(null!==this.animation){const t=Math.round((e-this.animation.startedAt)/this.animation.durationFrame);if(t<this.animation.frames.length)this.animation.frames[t]();else{this.animation.onAnimateEnd();this.animation=null}}this.timer=e;this.drawFrame()}start(){this.update();const loop=e=>{this.render(e);requestAnimationFrame(loop)};requestAnimationFrame(loop)}startAnimation(e,t,i){this.finishAnimation();this.animation={frames:e,duration:t,durationFrame:t/e.length,onAnimateEnd:i,startedAt:this.timer}}finishAnimation(){if(null!==this.animation){this.animation.frames[this.animation.frames.length-1]();null!==this.animation.onAnimateEnd&&this.animation.onAnimateEnd()}this.animation=null}update(){this.boundsRect=null;const e=this.calculateBoundsRect();if(this.orientation!==e){this.orientation=e;this.app.updateOrientation(e)}}calculateBoundsRect(){let e="landscape";const t=this.getBlockWidth(),i=t/2,a=this.getBlockHeight()/2,s=this.setting.width/this.setting.height;let r=this.setting.width,n=this.setting.height,o=i-r;if("stretch"===this.setting.size){t<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(e="portrait");r="portrait"===e?this.getBlockWidth():this.getBlockWidth()/2;r>this.setting.maxWidth&&(r=this.setting.maxWidth);n=r/s;if(n>this.getBlockHeight()){n=this.getBlockHeight();r=n*s}o="portrait"===e?i-r/2-r:i-r}else if(t<2*r&&this.app.getSettings().usePortrait){e="portrait";o=i-r/2-r}this.boundsRect={left:o,top:a-n/2,width:2*r,height:n,pageWidth:r};return e}setShadowData(e,t,i,a){if(!this.app.getSettings().drawShadow)return;const s=100*this.getSettings().maxShadowOpacity;this.shadow={pos:e,angle:t,width:3*this.getRect().pageWidth/4*i/100,opacity:(100-i)*s/100/100,direction:a,progress:2*i}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){null===this.boundsRect&&this.calculateBoundsRect();return this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(e){this.pageRect=e}setDirection(e){this.direction=e}setRightPage(e){null!==e&&e.setOrientation(1);this.rightPage=e}setLeftPage(e){null!==e&&e.setOrientation(0);this.leftPage=e}setBottomPage(e){null!==e&&e.setOrientation(1===this.direction?0:1);this.bottomPage=e}setFlippingPage(e){null!==e&&e.setOrientation(0===this.direction&&"portrait"!==this.orientation?0:1);this.flippingPage=e}convertToBook(e){const t=this.getRect();return{x:e.x-t.left,y:e.y-t.top}}isSafari(){return this.safari}convertToPage(e,t){t||(t=this.direction);const i=this.getRect();return{x:0===t?e.x-i.left-i.width/2:i.width/2-e.x+i.left,y:e.y-i.top}}convertToGlobal(e,t){t||(t=this.direction);if(null==e)return null;const i=this.getRect();return{x:0===t?e.x+i.left+i.width/2:i.width/2-e.x+i.left,y:e.y+i.top}}convertRectToGlobal(e,t){t||(t=this.direction);return{topLeft:this.convertToGlobal(e.topLeft,t),topRight:this.convertToGlobal(e.topRight,t),bottomLeft:this.convertToGlobal(e.bottomLeft,t),bottomRight:this.convertToGlobal(e.bottomRight,t)}}}class UI{constructor(e,t,i){this.cspPolicyService=t.cspPolicyService;this.touchPoint=null;this.swipeTimeout=250;this.onResize=()=>{this.update()};this.onMouseDown=e=>{this._pressSeen=!0;if(this.checkTarget(e.target)){if(!this.app.getSettings().enableFlipByDrag){this._clickStartPos=this.getMousePos(e.clientX,e.clientY);this._clickStartClientX=e.clientX;this._clickStartClientY=e.clientY;return}const t=this.getMousePos(e.clientX,e.clientY);this.app.startUserTouch(t);e.preventDefault()}};this.onTouchStart=e=>{if(this.checkTarget(e.target)){if(!this.app.getSettings().enableFlipByDrag)return;if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);this.touchPoint={point:i,time:Date.now()};setTimeout(()=>{null!==this.touchPoint&&this.app.startUserTouch(i)},this.swipeTimeout);this.app.getSettings().mobileScrollSupport||e.preventDefault()}}};this.onMouseUp=e=>{if(this._clickStartPos){const t=e.clientX-this._clickStartClientX,i=e.clientY-this._clickStartClientY;if(t*t+i*i<25){const e=this._clickStartPos;this.app.startUserTouch(e);this.app.userStop(e)}this._clickStartPos=null;return}const t=this.getMousePos(e.clientX,e.clientY);this.app.userStop(t)};this.onAnyMouseDown=()=>{this._pressSeen=!1};this.onClick=e=>{const t=this._pressSeen;this._pressSeen=!1;if(t||0!==e.button||!this.checkTarget(e.target))return;const i=this.getMousePos(e.clientX,e.clientY);this.app.startUserTouch(i);this.app.userStop(i)};this.onMouseMove=e=>{if(!this.app.getSettings().enableFlipByDrag)return;const t=this.getMousePos(e.clientX,e.clientY);this.app.userMove(t,!1)};this.onTouchMove=e=>{if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);if(this.app.getSettings().mobileScrollSupport){null!==this.touchPoint&&(Math.abs(this.touchPoint.point.x-i.x)>10||"read"!==this.app.getState())&&e.cancelable&&this.app.userMove(i,!0);"read"!==this.app.getState()&&e.preventDefault()}else this.app.userMove(i,!0)}};this.onTouchEnd=e=>{if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);let a=!1;if(null!==this.touchPoint){const e=i.x-this.touchPoint.point.x,t=Math.abs(i.y-this.touchPoint.point.y);if(Math.abs(e)>this.swipeDistance&&t<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout){e>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom");a=!0}this.touchPoint=null}this.app.userStop(i,a)}};this.parentElement=e;e.classList.add("stf__parent");e.classList.toggle("--rtl",!!i.rtl);const a=this.cspPolicyService.createTrustedHTML('<div class="stf__wrapper"></div>');e.insertAdjacentHTML("afterbegin",a);this.wrapper=e.querySelector(".stf__wrapper");this.app=t;const s=this.app.getSettings().usePortrait?1:2;e.style.minWidth=i.minWidth*s+"px";e.style.minHeight=i.minHeight+"px";if("fixed"===i.size){e.style.minWidth=i.width*s+"px";e.style.minHeight=i.height+"px"}if(i.autoSize){e.style.width="100%";e.style.maxWidth=2*i.maxWidth+"px"}e.style.display="block";window.addEventListener("resize",this.onResize,!1);this.swipeDistance=i.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers();this.distElement.remove();this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(e){this.wrapper.classList.remove("--portrait","--landscape");if("portrait"===e){this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%");this.wrapper.classList.add("--portrait")}else{this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%");this.wrapper.classList.add("--landscape")}this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize);this.distElement.removeEventListener("mousedown",this.onMouseDown);this.distElement.removeEventListener("click",this.onClick);window.removeEventListener("mousedown",this.onAnyMouseDown,!0);this.distElement.removeEventListener("touchstart",this.onTouchStart);window.removeEventListener("mousemove",this.onMouseMove);window.removeEventListener("touchmove",this.onTouchMove);window.removeEventListener("mouseup",this.onMouseUp);window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1);if(this.app.getSettings().useMouseEvents){this.distElement.addEventListener("mousedown",this.onMouseDown);this.distElement.addEventListener("click",this.onClick);window.addEventListener("mousedown",this.onAnyMouseDown,!0);this.distElement.addEventListener("touchstart",this.onTouchStart);window.addEventListener("mousemove",this.onMouseMove);window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport});window.addEventListener("mouseup",this.onMouseUp);window.addEventListener("touchend",this.onTouchEnd)}}getMousePos(e,t){const i=this.distElement.getBoundingClientRect();return this.app.getSettings().rtl?{x:i.right-e,y:t-i.top}:{x:e-i.left,y:t-i.top}}checkTarget(e){return!this.app.getSettings().clickEventForward||!["a","button"].includes(e.tagName.toLowerCase())}}class HTMLUI extends UI{constructor(e,t,i,a,s){super(e,t,i);this.cspPolicyService=s;const r=this.cspPolicyService.createTrustedHTML('<div class="stf__block"></div>');this.wrapper.insertAdjacentHTML("afterbegin",r);this.distElement=e.querySelector(".stf__block");this.items=a;for(const e of a)this.distElement.appendChild(e);this.setHandlers()}clear(){for(const e of this.items)this.parentElement.appendChild(e)}updateItems(e){this.removeHandlers();this.distElement.innerHTML="";for(const t of e)this.distElement.appendChild(t);this.items=e;this.setHandlers()}update(){this.app.getRender().update()}}class EventObject{constructor(){this.events=new Map}on(e,t){this.events.has(e)?this.events.get(e).push(t):this.events.set(e,[t]);return this}off(e){this.events.delete(e)}trigger(e,t,i=null){if(this.events.has(e))for(const a of this.events.get(e))a({data:i,object:t})}}class HTMLRender extends Render{constructor(e,t,i){super(e,t);this.outerShadow=null;this.innerShadow=null;this.hardShadow=null;this.hardInnerShadow=null;this.element=i;this.createShadows()}createShadows(){const e=this.app.cspPolicyService.createTrustedHTML('<div class="stf__outerShadow"></div>\n             <div class="stf__innerShadow"></div>\n             <div class="stf__hardShadow"></div>\n             <div class="stf__hardInnerShadow"></div>');this.element.insertAdjacentHTML("beforeend",e);this.outerShadow=this.element.querySelector(".stf__outerShadow");this.innerShadow=this.element.querySelector(".stf__innerShadow");this.hardShadow=this.element.querySelector(".stf__hardShadow");this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow();this.outerShadow.style.cssText="display: none";this.innerShadow.style.cssText="display: none";this.hardShadow.style.cssText="display: none";this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const e=this.getRect(),t=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let i=(100-t)*(2.5*e.pageWidth)/100+20;i>e.pageWidth&&(i=e.pageWidth);let a=`\n            display: block;\n            z-index: ${(this.getSettings().startZIndex+5).toString(10)};\n            width: ${i}px;\n            height: ${e.height}px;\n            background: linear-gradient(to right,\n                rgba(0, 0, 0, ${this.shadow.opacity*t/100}) 5%,\n                rgba(0, 0, 0, 0) 100%);\n            left: ${e.left+e.width/2}px;\n            transform-origin: 0 0;\n        `;a+=0===this.getDirection()&&this.shadow.progress>100||1===this.getDirection()&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0);":"transform: translate3d(0, 0, 0) rotateY(180deg);";this.hardInnerShadow.style.cssText=a}drawHardOuterShadow(){const e=this.getRect();let t=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*e.pageWidth)/100+20;t>e.pageWidth&&(t=e.pageWidth);let i=`\n            display: block;\n            z-index: ${(this.getSettings().startZIndex+4).toString(10)};\n            width: ${t}px;\n            height: ${e.height}px;\n            background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);\n            left: ${e.left+e.width/2}px;\n            transform-origin: 0 0;\n        `;i+=0===this.getDirection()&&this.shadow.progress>100||1===this.getDirection()&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);";this.hardShadow.style.cssText=i}drawInnerShadow(){const e=this.getRect(),t=3*this.shadow.width/4,i=0===this.getDirection()?t:0,a=0===this.getDirection()?"to left":"to right",s=this.convertToGlobal(this.shadow.pos),r=this.shadow.angle+3*Math.PI/2,n=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let o="polygon( ";for(const e of n){let t=1===this.getDirection()?{x:-e.x+this.shadow.pos.x,y:e.y-this.shadow.pos.y}:{x:e.x-this.shadow.pos.x,y:e.y-this.shadow.pos.y};t=Helper.GetRotatedPoint(t,{x:i,y:100},r);o+=t.x+"px "+t.y+"px, "}o=o.slice(0,-2);o+=")";const l=`\n            display: block;\n            z-index: ${(this.getSettings().startZIndex+10).toString(10)};\n            width: ${t}px;\n            height: ${2*e.height}px;\n            background: linear-gradient(${a},\n                rgba(0, 0, 0, ${this.shadow.opacity}) 5%,\n                rgba(0, 0, 0, 0.05) 15%,\n                rgba(0, 0, 0, ${this.shadow.opacity}) 35%,\n                rgba(0, 0, 0, 0) 100%);\n            transform-origin: ${i}px 100px;\n            transform: translate3d(${s.x-i}px, ${s.y-100}px, 0) rotate(${r}rad);\n            clip-path: ${o};\n            -webkit-clip-path: ${o};\n        `;this.innerShadow.style.cssText=l}drawOuterShadow(){const e=this.getRect(),t=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),i=this.shadow.angle+3*Math.PI/2,a=1===this.getDirection()?this.shadow.width:0,s=0===this.getDirection()?"to right":"to left",r=[{x:0,y:0},{x:e.pageWidth,y:0},{x:e.pageWidth,y:e.height},{x:0,y:e.height}];let n="polygon( ";for(const e of r)if(null!==e){let t=1===this.getDirection()?{x:-e.x+this.shadow.pos.x,y:e.y-this.shadow.pos.y}:{x:e.x-this.shadow.pos.x,y:e.y-this.shadow.pos.y};t=Helper.GetRotatedPoint(t,{x:a,y:100},i);n+=t.x+"px "+t.y+"px, "}n=n.slice(0,-2);n+=")";const o=`\n            display: block;\n            z-index: ${(this.getSettings().startZIndex+10).toString(10)};\n            width: ${this.shadow.width}px;\n            height: ${2*e.height}px;\n            background: linear-gradient(${s}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));\n            transform-origin: ${a}px 100px;\n            transform: translate3d(${t.x-a}px, ${t.y-100}px, 0) rotate(${i}rad);\n            clip-path: ${n};\n            -webkit-clip-path: ${n};\n        `;this.outerShadow.style.cssText=o}drawLeftPage(){if("portrait"!==this.orientation&&null!==this.leftPage)if(1===this.direction&&null!==this.flippingPage&&"hard"===this.flippingPage.getDrawingDensity()){if(this.flippingPage.getHardAngle()<-90){this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle());this.leftPage.draw(this.flippingPage.getDrawingDensity())}else this.leftPage.getElement().style.display="none"}else this.leftPage.simpleDraw(0)}drawRightPage(){if(null!==this.rightPage)if(0===this.direction&&null!==this.flippingPage&&"hard"===this.flippingPage.getDrawingDensity()){if(this.flippingPage.getHardAngle()>90){this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle());this.rightPage.draw(this.flippingPage.getDrawingDensity())}else this.rightPage.getElement().style.display="none"}else this.rightPage.simpleDraw(1)}drawBottomPage(){if(null===this.bottomPage)return;const e=null!=this.flippingPage?this.flippingPage.getDrawingDensity():null;if("portrait"!==this.orientation||1!==this.direction){this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10);this.bottomPage.draw(e)}}drawFrame(){if(null!==this.flippingPage){if(this.flippingPage.getHardAngle()===this.lastAngle)return;this.lastAngle=this.flippingPage.getHardAngle()}else this.lastAngle=-1234;this.clear();this.drawLeftPage();this.drawRightPage();this.drawBottomPage();if(null!=this.flippingPage){if(this.flippingPage.state.hardDrawingAngle<=90){this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.flippingPage.draw()}else this.flippingPage.getElement().style.display="none"}if(null!=this.shadow&&null!==this.flippingPage)if("soft"===this.flippingPage.getDrawingDensity()){this.drawOuterShadow();this.drawInnerShadow()}else{this.drawHardOuterShadow();this.drawHardInnerShadow()}}clear(){for(const e of this.app.getPageCollection().getPages()){if(e!==this.leftPage&&e!==this.rightPage&&e!==this.flippingPage&&e!==this.bottomPage){const t=e.getElement().style;"none"!==t.display&&(t.cssText="display: none")}e.getTemporaryCopy()!==this.flippingPage&&e.hideTemporaryCopy()}}update(){super.update();null!==this.rightPage&&this.rightPage.setOrientation(1);null!==this.leftPage&&this.leftPage.setOrientation(0)}}class Settings{constructor(){this._default={startPage:0,size:"fixed",width:0,height:0,minWidth:0,maxWidth:0,minHeight:0,maxHeight:0,drawShadow:!0,flippingTime:1e3,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:1,showCover:!1,mobileScrollSupport:!0,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,showPageCorners:!0,disableFlipByClick:!1,enableFlipByDrag:!0,rtl:!1}}getSettings(e){const t=this._default;Object.assign(t,e);if("stretch"!==t.size&&"fixed"!==t.size)throw new Error('Invalid size type. Available only "fixed" and "stretch" value');if(t.width<=0||t.height<=0)throw new Error("Invalid width or height");if(t.flippingTime<=0)throw new Error("Invalid flipping time");if("stretch"===t.size){t.minWidth<=0&&(t.minWidth=100);t.maxWidth<t.minWidth&&(t.maxWidth=2e3);t.minHeight<=0&&(t.minHeight=100);t.maxHeight<t.minHeight&&(t.maxHeight=2e3)}else{t.minWidth=t.width;t.maxWidth=t.width;t.minHeight=t.height;t.maxHeight=t.height}return t}}class PageFlip extends EventObject{constructor(e,t,i){super();this.isUserTouch=!1;this.isUserMove=!1;this.setting=null;this.pages=null;this.setting=(new Settings).getSettings(t);this.block=e;this.cspPolicyService=i}destroy(){this.ui.destroy();this.render=void 0}update(){this.render.update();this.pages.show()}setRtl(e){this.setting.rtl=e;this.block.classList.toggle("--rtl",e)}loadFromHTML(e){this.ui=new HTMLUI(this.block,this,this.setting,e,this.cspPolicyService);this.render=new HTMLRender(this,this.setting,this.ui.getDistElement());this.flipController=new Flip(this.render,this);this.pages=new HTMLPageCollection(this,this.render,this.ui.getDistElement(),e);this.pages.load();this.render.start();this.pages.show(this.setting.startPage);setTimeout(()=>{this.ui.update();this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}updateFromHtml(e){const t=this.pages.getCurrentPageIndex();this.pages.destroy();this.pages=new HTMLPageCollection(this,this.render,this.ui.getDistElement(),e);this.pages.load();this.ui.updateItems(e);this.render.reload();this.pages.show(t);this.trigger("update",this,{page:t,mode:this.render.getOrientation()})}clear(){this.pages.destroy();this.ui.clear()}turnToPrevPage(){this.pages.showPrev()}turnToNextPage(){this.pages.showNext()}turnToPage(e){this.pages.show(e)}flipNext(e="top"){this.flipController.flipNext(e)}flipPrev(e="top"){this.flipController.flipPrev(e)}flip(e,t="top"){this.flipController.flipToPage(e,t)}updateState(e){this.trigger("changeState",this,e)}updatePageIndex(e){this.trigger("flip",this,e)}updateOrientation(e){this.ui.setOrientationStyle(e);this.update();this.trigger("changeOrientation",this,e)}getPageCount(){return this.pages.getPageCount()}getCurrentPageIndex(){return this.pages.getCurrentPageIndex()}getPage(e){return this.pages.getPage(e)}getRender(){return this.render}getFlipController(){return this.flipController}getOrientation(){return this.render.getOrientation()}getBoundsRect(){return this.render.getRect()}getSettings(){return this.setting}getUI(){return this.ui}getState(){return this.flipController.getState()}getPageCollection(){return this.pages}startUserTouch(e){this.mousePosition=e;this.isUserTouch=!0;this.isUserMove=!1}userMove(e,t){if(this.isUserTouch||t||!this.setting.showPageCorners){if(this.isUserTouch&&Helper.GetDistanceBetweenTwoPoint(this.mousePosition,e)>5){this.isUserMove=!0;this.flipController.fold(e)}}else this.flipController.showCorner(e)}userStop(e,t=!1){if(this.isUserTouch){this.isUserTouch=!1;t||(this.isUserMove?this.flipController.stopMove():this.flipController.flip(e))}}}function annotation_editor_layer_builder_classPrivateFieldInitSpec(e,t,i){(function annotation_editor_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function annotation_editor_layer_builder_classPrivateFieldGet(e,t){return e.get(annotation_editor_layer_builder_assertClassBrand(e,t))}function annotation_editor_layer_builder_classPrivateFieldSet(e,t,i){return e.set(annotation_editor_layer_builder_assertClassBrand(e,t),i),i}function annotation_editor_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var wP=new WeakMap,FP=new WeakMap,yP=new WeakMap,bP=new WeakMap,SP=new WeakMap,CP=new WeakMap;class AnnotationEditorLayerBuilder{constructor(e){annotation_editor_layer_builder_classPrivateFieldInitSpec(this,wP,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,FP,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,yP,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,bP,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,SP,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,CP,void 0);this.pageIndex=e.pageIndex;this.accessibilityManager=e.accessibilityManager;this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;this.annotationEditorLayer=null;this.div=null;this._cancelled=!1;annotation_editor_layer_builder_classPrivateFieldSet(CP,this,e.uiManager);annotation_editor_layer_builder_classPrivateFieldSet(wP,this,e.annotationLayer||null);annotation_editor_layer_builder_classPrivateFieldSet(SP,this,e.textLayer||null);annotation_editor_layer_builder_classPrivateFieldSet(FP,this,e.drawLayer||null);annotation_editor_layer_builder_classPrivateFieldSet(yP,this,e.onAppend||null);this.eventBus=e.eventBus;annotation_editor_layer_builder_classPrivateFieldSet(bP,this,e.structTreeLayer||null)}updatePageIndex(e){this.pageIndex=e;this.annotationEditorLayer?.updatePageIndex(e)}async render({viewport:e,intent:t="display"}){if("display"!==t||this._cancelled)return;const i=e.clone({dontFlip:!0});if(this.div){this.annotationEditorLayer.update({viewport:i});this.show();return}const a=this.div=document.createElement("div");a.className="annotationEditorLayer";a.hidden=!0;a.dir=annotation_editor_layer_builder_classPrivateFieldGet(CP,this).direction;annotation_editor_layer_builder_classPrivateFieldGet(yP,this)?.call(this,a);this.annotationEditorLayer=new AnnotationEditorLayer({uiManager:annotation_editor_layer_builder_classPrivateFieldGet(CP,this),div:a,structTreeLayer:annotation_editor_layer_builder_classPrivateFieldGet(bP,this),accessibilityManager:this.accessibilityManager,pageIndex:this.pageIndex,l10n:this.l10n,viewport:i,annotationLayer:annotation_editor_layer_builder_classPrivateFieldGet(wP,this),textLayer:annotation_editor_layer_builder_classPrivateFieldGet(SP,this),drawLayer:annotation_editor_layer_builder_classPrivateFieldGet(FP,this),eventBus:this.eventBus});const s={viewport:i,div:a,annotations:null,intent:t};await this.annotationEditorLayer.render(s);this.show()}update(e){this.div&&this.annotationEditorLayer.update({viewport:e.clone({dontFlip:!0})})}cancel(){this._cancelled=!0;this.div&&this.annotationEditorLayer?.destroy()}hide(){if(this.div&&this.annotationEditorLayer){this.annotationEditorLayer.pause(!0);this.div.hidden=!0}}show(){if(this.div&&this.annotationEditorLayer&&!this.annotationEditorLayer.isInvisible){this.div.hidden=!1;this.annotationEditorLayer.pause(!1)}}}function annotation_layer_builder_classPrivateFieldInitSpec(e,t,i){annotation_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_layer_builder_classPrivateFieldGet(e,t){return e.get(annotation_layer_builder_assertClassBrand(e,t))}function annotation_layer_builder_classPrivateFieldSet(e,t,i){return e.set(annotation_layer_builder_assertClassBrand(e,t),i),i}function annotation_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var xP=new WeakMap,kP=new WeakMap,EP=new WeakMap,AP=new WeakMap,GP=new WeakMap,BP=new WeakSet;class AnnotationLayerBuilder{constructor({pdfPage:e,linkService:t,downloadManager:i,annotationStorage:a=null,imageResourcesPath:s="",renderForms:r=!0,enableComment:n=!1,commentManager:o=null,enableScripting:l=!1,hasJSActionsPromise:d=null,fieldObjectsPromise:c=null,annotationCanvasMap:h=null,accessibilityManager:_=null,annotationEditorUIManager:u=null,onAppend:p=null}){!function annotation_layer_builder_classPrivateMethodInitSpec(e,t){annotation_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,BP);annotation_layer_builder_classPrivateFieldInitSpec(this,xP,null);annotation_layer_builder_classPrivateFieldInitSpec(this,kP,null);annotation_layer_builder_classPrivateFieldInitSpec(this,EP,null);annotation_layer_builder_classPrivateFieldInitSpec(this,AP,null);annotation_layer_builder_classPrivateFieldInitSpec(this,GP,!1);this.pdfPage=e;this.linkService=t;this.downloadManager=i;this.imageResourcesPath=s;this.renderForms=r;this.annotationStorage=a;this.enableComment=n;annotation_layer_builder_classPrivateFieldSet(kP,this,o);this.enableScripting=l;this._hasJSActionsPromise=d||Promise.resolve(!1);this._fieldObjectsPromise=c||Promise.resolve(null);this._annotationCanvasMap=h;this._accessibilityManager=_;this._annotationEditorUIManager=u;annotation_layer_builder_classPrivateFieldSet(EP,this,p);this.annotationLayer=null;this.div=null;this._cancelled=!1;this._eventBus=t.eventBus}async render({viewport:e,intent:t="display",structTreeLayer:i=null,optionalContentConfigPromise:a=null}){if(this.div){const t=await a;if(this._cancelled||!this.annotationLayer)return;this.annotationLayer.update({viewport:e.clone({dontFlip:!0}),optionalContentConfig:t});return}const[s,r,n,o]=await Promise.all([this.pdfPage.getAnnotations({intent:t}),this._hasJSActionsPromise,this._fieldObjectsPromise,a]);if(this._cancelled)return;const l=this.div=document.createElement("div");l.className="annotationLayer";annotation_layer_builder_classPrivateFieldGet(EP,this)?.call(this,l);this.annotationLayer=new AnnotationLayer({div:l,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,annotationStorage:this.annotationStorage,page:this.pdfPage,viewport:e.clone({dontFlip:!0}),structTreeLayer:i,commentManager:annotation_layer_builder_classPrivateFieldGet(kP,this),linkService:this.linkService});if(0!==s.length){await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,downloadManager:this.downloadManager,enableComment:this.enableComment,enableAnnotationEditing:!0,enableScripting:this.enableScripting,hasJSActions:r,fieldObjects:n,optionalContentConfig:o});annotation_layer_builder_classPrivateFieldSet(xP,this,s);this.linkService.isInPresentationMode&&annotation_layer_builder_assertClassBrand(BP,this,_updatePresentationModeState).call(this,L_);if(!annotation_layer_builder_classPrivateFieldGet(AP,this)){annotation_layer_builder_classPrivateFieldSet(AP,this,new AbortController);this._eventBus?.on("presentationmodechanged",e=>{annotation_layer_builder_assertClassBrand(BP,this,_updatePresentationModeState).call(this,e.state)},{signal:annotation_layer_builder_classPrivateFieldGet(AP,this).signal,...lu})}}else{annotation_layer_builder_classPrivateFieldSet(xP,this,s);setLayerDimensions(this.div,e)}}cancel(){this._cancelled=!0;annotation_layer_builder_classPrivateFieldGet(AP,this)?.abort();annotation_layer_builder_classPrivateFieldSet(AP,this,null);this.annotationLayer?.destroy()}refreshCanvases(){this.annotationLayer?.refreshCanvases()}hide(){this.div&&(document.querySelector("[data-pdfjsprinting=true]")||(this.div.hidden=!0))}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}async injectLinkAnnotations(e){if(null===annotation_layer_builder_classPrivateFieldGet(xP,this)||this._cancelled||annotation_layer_builder_classPrivateFieldGet(GP,this))return;annotation_layer_builder_classPrivateFieldSet(GP,this,!0);if(!e.length)return;let t;if(annotation_layer_builder_classPrivateFieldGet(xP,this).length){t=annotation_layer_builder_assertClassBrand(BP,this,_checkInferredLinks).call(this,e);if(!t.length)return}else t=e;await this.annotationLayer.addLinkAnnotations(t)}get linksInjected(){return annotation_layer_builder_classPrivateFieldGet(GP,this)}}function _updatePresentationModeState(e){if(!this.div)return;let t=!1;switch(e){case L_:t=!0;break;case T_:break;default:return}for(const e of this.div.childNodes)e.hasAttribute("data-internal-link")||e.classList.contains("mediaAnnotation")||(e.inert=t)}function _checkInferredLinks(e){function annotationRects(e){if(!e.quadPoints)return[e.rect];const t=[];for(let i=2,a=e.quadPoints.length;i<a;i+=8){const a=e.quadPoints[i],s=e.quadPoints[i+1],r=e.quadPoints[i+2],n=e.quadPoints[i+3];t.push([r,n,a,s])}return t}function intersectAnnotations(e,t){const i=[],a=annotationRects(e),s=annotationRects(t);for(const e of a)for(const t of s){const a=Util.intersect(e,t);a&&i.push(a)}return i}function areaRects(e){let t=0;for(const i of e)t+=Math.abs((i[2]-i[0])*(i[3]-i[1]));return t}return e.filter(e=>{let t;for(const i of annotation_layer_builder_classPrivateFieldGet(xP,this)){if(i.annotationType!==k.LINK)continue;const a=intersectAnnotations(i,e);if(0!==a.length){t??=areaRects(annotationRects(e));if(areaRects(a)/t>.5)return!1}}return!0})}function autolinker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function DOMRectToPDF({width:e,height:t,left:i,top:a},s){if(0===e||0===t)return null;const r=s.textLayer.div.getBoundingClientRect(),n=s.getPagePoint(i-r.left,a-r.top),o=s.getPagePoint(i-r.left+e,a-r.top+t);return Util.normalizeRect([n[0],n[1],o[0],o[1]])}function calculateLinkPosition(e,t){const i=e.getClientRects();if(1===i.length)return{rect:DOMRectToPDF(i[0],t)};const a=[1/0,1/0,-1/0,-1/0],s=[];let r=0;for(const e of i){const i=DOMRectToPDF(e,t);if(null!==i){s[r]=s[r+4]=i[0];s[r+1]=s[r+3]=i[3];s[r+2]=s[r+6]=i[2];s[r+5]=s[r+7]=i[1];Util.rectBoundingBox(...i,a);r+=8}}return{quadPoints:s,rect:a}}function textPosition(e,t){let i=e;do{if(i.nodeType===Node.TEXT_NODE){const e=i.textContent.length;if(t<=e)return[i,t];t-=e}else if(i.firstChild){i=i.firstChild;continue}for(;!i.nextSibling&&i!==e;)i=i.parentNode;i!==e&&(i=i.nextSibling)}while(i!==e);throw new Error("Offset is bigger than container's contents length.")}class Autolinker{static findLinks(e){autolinker_assertClassBrand(Autolinker,this,IP)._??(IP._=autolinker_assertClassBrand(Autolinker,this,/\b(?:https?:\/\/|mailto:|www\.)(?:[\0-\x08\x0E-\x1F\$\+0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]|\/|[\0-\x08\x0E-\x1F!-Z\\\^-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uFEFE\uFF00-\u{10FFFF}]+[\0-\x08\x0E-\x1F\$\+0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}])+|(?=\p{L})[\0-\x08\x0E-\x1F!-'\*-;=\?A-Z\\\^-z\|~-\x9F\xA1-\u0F39\u0F3E-\u167F\u1681-\u169A\u169D-\u1FFF\u200B-\u2019\u201B-\u201D\u201F-\u2027\u202A-\u202E\u2030-\u2044\u2047-\u205E\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2E21\u2E2A-\u2E41\u2E43-\u2E54\u2E5D-\u2FFF\u3001-\u3007\u3012\u3013\u301C\u3020-\uFD3D\uFD40-\uFE16\uFE19-\uFE34\uFE45\uFE46\uFE49-\uFE58\uFE5F-\uFEFE\uFF00-\uFF07\uFF0A-\uFF3A\uFF3C\uFF3E-\uFF5A\uFF5C\uFF5E\uFF61\uFF64-\u{10FFFF}]{1,64}@([\0-\x08\x0E-\x1F\$\+\x2D0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]{1,63}(?:\.[\0-\x08\x0E-\x1F\$\+\x2D0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]{1,63})+)/gu));const[t,i]=normalize(e,{ignoreDashEOL:!0}),a=t.matchAll(autolinker_assertClassBrand(Autolinker,this,IP)._),s=[];for(const e of a){const[t,a]=e;let r;if(t.startsWith("www.")||t.startsWith("http://")||t.startsWith("https://"))r=t;else if(a){const e=URL.parse(`http://${a}`)?.hostname;if(!e)continue;autolinker_assertClassBrand(Autolinker,this,TP)._??(TP._=autolinker_assertClassBrand(Autolinker,this,/\.\d+$/));if(autolinker_assertClassBrand(Autolinker,this,TP)._.test(e))continue}r??=t.startsWith("mailto:")?t:`mailto:${t}`;const n=createValidAbsoluteUrl(r,null,{addDefaultProtocol:!0});if(n){const[a,r]=getOriginalIndex(i,e.index,t.length);s.push({url:n.href,index:a,length:r})}}return s}static processLinks(e){const t=e._textHighlighter,i=t.textContentItemsStr.join("\n");if(!i)return[];const a=this.findLinks(i);if(!a.length)return[];const s=t._convertMatches(a.map(({index:e})=>e),a.map(({length:e})=>e)),{textDivs:r}=t,n=new Range;return a.map(({url:t},i)=>{var a,o;const{begin:l,end:d}=s[i];n.setStart(...textPosition(r[l.divIdx],l.offset));n.setEnd(...textPosition(r[d.divIdx],d.offset));return{id:`inferred_link_${MP._=autolinker_assertClassBrand(Autolinker,this,(a=autolinker_assertClassBrand(Autolinker,this,MP)._,o=a++,a)),o}`,unsafeUrl:t,url:t,annotationType:k.LINK,rotation:0,...calculateLinkPosition(n,e),borderStyle:null}})}}var MP={_:0},IP={_:void 0},TP={_:void 0};function base_pdf_page_view_defineProperty(e,t,i){return(t=function base_pdf_page_view_toPropertyKey(e){var t=function base_pdf_page_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function base_pdf_page_view_classPrivateFieldInitSpec(e,t,i){base_pdf_page_view_checkPrivateRedeclaration(e,t),t.set(e,i)}function base_pdf_page_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function base_pdf_page_view_classPrivateFieldSet(e,t,i){return e.set(base_pdf_page_view_assertClassBrand(e,t),i),i}function base_pdf_page_view_classPrivateFieldGet(e,t){return e.get(base_pdf_page_view_assertClassBrand(e,t))}function base_pdf_page_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var DP=new WeakMap,LP=new WeakMap,RP=new WeakMap,OP=new WeakMap,NP=new WeakMap,WP=new WeakMap,jP=new WeakMap,VP=new WeakSet;class BasePDFPageView extends RenderableView{constructor(e){super();!function base_pdf_page_view_classPrivateMethodInitSpec(e,t){base_pdf_page_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,VP);base_pdf_page_view_classPrivateFieldInitSpec(this,DP,null);base_pdf_page_view_classPrivateFieldInitSpec(this,LP,null);base_pdf_page_view_classPrivateFieldInitSpec(this,RP,Xf.INITIAL);base_pdf_page_view_classPrivateFieldInitSpec(this,OP,null);base_pdf_page_view_classPrivateFieldInitSpec(this,NP,0);base_pdf_page_view_classPrivateFieldInitSpec(this,WP,null);base_pdf_page_view_defineProperty(this,"canvas",null);base_pdf_page_view_defineProperty(this,"div",null);base_pdf_page_view_defineProperty(this,"enableOptimizedPartialRendering",!1);base_pdf_page_view_defineProperty(this,"enableSelectionRendering",!0);base_pdf_page_view_defineProperty(this,"imagesRightClickMinSize",-1);base_pdf_page_view_defineProperty(this,"eventBus",null);base_pdf_page_view_defineProperty(this,"id",null);base_pdf_page_view_defineProperty(this,"imageCoordinates",null);base_pdf_page_view_defineProperty(this,"pageColors",null);base_pdf_page_view_defineProperty(this,"recordedBBoxes",null);base_pdf_page_view_defineProperty(this,"renderingQueue",null);base_pdf_page_view_classPrivateFieldInitSpec(this,jP,e=>{this.renderTask?.isWorkerRendering||base_pdf_page_view_classPrivateFieldGet(OP,this)?.call(this,!1);if(!this.renderingQueue||this.renderingQueue.isHighestPriority(this))e();else{this.renderingState=Xf.PAUSED;this.resume=()=>{this.renderingState=Xf.RUNNING;e()}}});this.eventBus=e.eventBus;this.id=e.id;this.pageColors=e.pageColors||null;this.renderingQueue=e.renderingQueue;this.enableOptimizedPartialRendering=e.enableOptimizedPartialRendering??!1;this.enableSelectionRendering=!1!==e.enableSelectionRendering&&FeatureTest.isBackdropFilterSupported;this.imagesRightClickMinSize=e.imagesRightClickMinSize??-1;this.minDurationToUpdateCanvas=e.minDurationToUpdateCanvas??500}get renderingState(){return base_pdf_page_view_classPrivateFieldGet(RP,this)}set renderingState(e){if(e!==base_pdf_page_view_classPrivateFieldGet(RP,this)){base_pdf_page_view_classPrivateFieldSet(RP,this,e);if(base_pdf_page_view_classPrivateFieldGet(DP,this)){clearTimeout(base_pdf_page_view_classPrivateFieldGet(DP,this));base_pdf_page_view_classPrivateFieldSet(DP,this,null)}switch(e){case Xf.PAUSED:this.div.classList.remove("loading");base_pdf_page_view_classPrivateFieldSet(NP,this,0);this.renderTask?.isWorkerRendering||base_pdf_page_view_classPrivateFieldGet(OP,this)?.call(this,!1);break;case Xf.RUNNING:this.div.classList.add("loadingIcon");base_pdf_page_view_classPrivateFieldSet(DP,this,setTimeout(()=>{this.div.classList.add("loading");base_pdf_page_view_classPrivateFieldSet(DP,this,null)},0));base_pdf_page_view_classPrivateFieldSet(NP,this,Date.now());break;case Xf.INITIAL:case Xf.FINISHED:this.div.classList.remove("loadingIcon","loading");base_pdf_page_view_classPrivateFieldSet(NP,this,0)}}}_createCanvas(e,t=!1){const{pageColors:i}=this,a=!(!i?.background||!i?.foreground),s=this.canvas,r=!s&&!a&&!t;let n=this.canvas=document.createElement("canvas");base_pdf_page_view_classPrivateFieldSet(OP,this,t=>{if(r){let i=base_pdf_page_view_classPrivateFieldGet(WP,this);if(!t&&this.minDurationToUpdateCanvas>0&&!this.renderTask?.isWorkerRendering){if(Date.now()-base_pdf_page_view_classPrivateFieldGet(NP,this)<this.minDurationToUpdateCanvas)return;if(!i){i=base_pdf_page_view_classPrivateFieldSet(WP,this,n);n=this.canvas=n.cloneNode(!1);e(n)}}if(i){n.getContext("2d",{alpha:!1}).drawImage(i,0,0);t?base_pdf_page_view_assertClassBrand(VP,this,_resetTempCanvas).call(this):base_pdf_page_view_classPrivateFieldSet(NP,this,Date.now());return}e(n);base_pdf_page_view_classPrivateFieldSet(OP,this,null);return}if(t)if(s){s.parentNode?s.replaceWith(n):e(n);s.width=s.height=0}else e(n)});return{canvas:n,prevCanvas:s}}_resetCanvas(){const{canvas:e}=this;if(e){e.remove();e.width=e.height=0;this.canvas=null;base_pdf_page_view_assertClassBrand(VP,this,_resetTempCanvas).call(this)}}async _drawCanvas(e,t,i){const a=this.renderTask=this.pdfPage.render(e);a.onContinue=base_pdf_page_view_classPrivateFieldGet(jP,this);a.onFrame=()=>base_pdf_page_view_classPrivateFieldGet(OP,this)?.call(this,!1);a.onError=e=>{if(e instanceof RenderingCancelledException){t();base_pdf_page_view_classPrivateFieldSet(LP,this,null)}};let s=null;try{await a.promise;base_pdf_page_view_classPrivateFieldGet(OP,this)?.call(this,!0)}catch(e){if(e instanceof RenderingCancelledException)return;s=e;base_pdf_page_view_classPrivateFieldGet(OP,this)?.call(this,!0)}finally{base_pdf_page_view_classPrivateFieldSet(LP,this,s);if(a===this.renderTask){this.renderTask=null;this.enableOptimizedPartialRendering&&(this.recordedBBoxes??=a.recordedBBoxes);-1!==this.imagesRightClickMinSize&&(this.imageCoordinates??=this.pdfPage.imageCoordinates)}}this.renderingState=Xf.FINISHED;i(a);if(s)throw s}cancelRendering({cancelExtraDelay:e=0}={}){if(this.renderTask){this.renderTask.cancel(e);this.renderTask=null}this.resume=null}dispatchPageRender(){this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id})}dispatchPageRendered(e,t){this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:e,isDetailView:t,timestamp:performance.now(),error:base_pdf_page_view_classPrivateFieldGet(LP,this)})}}function _resetTempCanvas(){if(base_pdf_page_view_classPrivateFieldGet(WP,this)){base_pdf_page_view_classPrivateFieldGet(WP,this).width=base_pdf_page_view_classPrivateFieldGet(WP,this).height=0;base_pdf_page_view_classPrivateFieldSet(WP,this,null)}}function draw_layer_builder_classPrivateFieldInitSpec(e,t,i){(function draw_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function draw_layer_builder_classPrivateFieldSet(e,t,i){return e.set(draw_layer_builder_assertClassBrand(e,t),i),i}function draw_layer_builder_classPrivateFieldGet(e,t){return e.get(draw_layer_builder_assertClassBrand(e,t))}function draw_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var UP=new WeakMap;class DrawLayerBuilder{constructor(e){draw_layer_builder_classPrivateFieldInitSpec(this,UP,null);this.pageIndex=e.pageIndex;this.textLayer=e.textLayer||null;this.filterFactory=e.filterFactory||null;this.pageColors=e.pageColors||null}async render({intent:e="display"}){"display"!==e||draw_layer_builder_classPrivateFieldGet(UP,this)||this._cancelled||draw_layer_builder_classPrivateFieldSet(UP,this,new DrawLayer({pageIndex:this.pageIndex,textLayer:this.textLayer,filterFactory:this.filterFactory,pageColors:this.pageColors}))}cancel(){this._cancelled=!0;draw_layer_builder_classPrivateFieldGet(UP,this)?.destroy();draw_layer_builder_classPrivateFieldSet(UP,this,null)}setParent(e){draw_layer_builder_classPrivateFieldGet(UP,this)?.setParent(e)}getDrawLayer(){return draw_layer_builder_classPrivateFieldGet(UP,this)}}function pdf_page_detail_view_defineProperty(e,t,i){return(t=function pdf_page_detail_view_toPropertyKey(e){var t=function pdf_page_detail_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_page_detail_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_page_detail_view_classPrivateFieldGet(e,t){return e.get(pdf_page_detail_view_assertClassBrand(e,t))}function pdf_page_detail_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var zP=new WeakMap,HP=new WeakSet;class PDFPageDetailView extends BasePDFPageView{constructor({pageView:e}){super(e);!function pdf_page_detail_view_classPrivateMethodInitSpec(e,t){pdf_page_detail_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,HP);!function pdf_page_detail_view_classPrivateFieldInitSpec(e,t,i){pdf_page_detail_view_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,zP,null);pdf_page_detail_view_defineProperty(this,"renderingCancelled",!1);this.pageView=e;this.renderingId="detail"+this.id;this.div=e.div}setPdfPage(e){this.pageView.setPdfPage(e)}get pdfPage(){return this.pageView.pdfPage}get renderingState(){return super.renderingState}set renderingState(e){this.renderingCancelled=!1;super.renderingState=e}reset({keepCanvas:e=!1}={}){const t=this.renderingCancelled||this.renderingState===Xf.RUNNING||this.renderingState===Xf.PAUSED;this.cancelRendering();this.renderingState=Xf.INITIAL;this.renderingCancelled=t;e||this._resetCanvas()}update({visibleArea:e=null,underlyingViewUpdated:t=!1}={}){if(t){this.cancelRendering();this.renderingState=Xf.INITIAL;return}if(!pdf_page_detail_view_assertClassBrand(HP,this,_shouldRenderDifferentArea).call(this,e))return;const{viewport:i,maxCanvasPixels:a,capCanvasAreaFactor:s}=this.pageView,r=e.maxX-e.minX,n=e.maxY-e.minY,o=r*n*OutputScale.pixelRatio**2,l=(Math.sqrt(OutputScale.capPixels(a,s)/o)-1)/2;let d=Math.min(1,l);d<0&&(d=0);const c=r*d,h=n*d,_=Math.max(0,e.minX-c),u=Math.min(i.width,e.maxX+c),p=Math.max(0,e.minY-h),g=Math.min(i.height,e.maxY+h);!function pdf_page_detail_view_classPrivateFieldSet(e,t,i){return e.set(pdf_page_detail_view_assertClassBrand(e,t),i),i}(zP,this,{minX:_,minY:p,width:u-_,height:g-p,scale:i.scale});this.reset({keepCanvas:!0})}_getRenderingContext(e,t){const i=this.pageView._getRenderingContext(e,t,!1),a=this.pdfPage.recordedBBoxes;if(!a||!this.enableOptimizedPartialRendering)return i;const{viewport:{width:s,height:r}}=this.pageView,{width:n,height:o,minX:l,minY:d}=pdf_page_detail_view_classPrivateFieldGet(zP,this),c=l/s,h=d/r,_=(l+n)/s,u=(d+o)/r;return{...i,operationsFilter:e=>!a.isEmpty(e)&&(a.minX(e)<=_&&a.maxX(e)>=c&&a.minY(e)<=u&&a.maxY(e)>=h)}}async draw(){if(this.pageView.detailView!==this)return;const e=this.pageView.renderingState===Xf.FINISHED||this.renderingState===Xf.FINISHED;if(this.renderingState!==Xf.INITIAL){NgxConsole.error("Must be in new state before drawing");this.reset()}const{div:t,pdfPage:i,viewport:a}=this.pageView;if(!i){this.renderingState=Xf.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Xf.RUNNING;const s=this.pageView._ensureCanvasWrapper(),{canvas:r,prevCanvas:n}=this._createCanvas(e=>{"CANVAS"===s.firstElementChild?.tagName?s.firstElementChild.after(e):s.prepend(e)},e);r.ariaHidden=!0;this.enableOptimizedPartialRendering&&(r.className="detailView");const{width:o,height:l}=a,d=pdf_page_detail_view_classPrivateFieldGet(zP,this),{pixelRatio:c}=OutputScale,h=[c,0,0,c,-d.minX*c,-d.minY*c];r.width=d.width*c;r.height=d.height*c;const{style:_}=r;_.width=100*d.width/o+"%";_.height=100*d.height/l+"%";_.top=100*d.minY/l+"%";_.left=100*d.minX/o+"%";const u=this._drawCanvas(this._getRenderingContext(r,h),()=>{this._resetCanvas();this.canvas=n},()=>{this.pageView._refreshAnnotationLayer();this.dispatchPageRendered(!1,!0)});t.setAttribute("data-loaded",!0);this.dispatchPageRender();return u}}function _shouldRenderDifferentArea(e){if(!pdf_page_detail_view_classPrivateFieldGet(zP,this))return!0;const t=pdf_page_detail_view_classPrivateFieldGet(zP,this).minX,i=pdf_page_detail_view_classPrivateFieldGet(zP,this).minY,a=pdf_page_detail_view_classPrivateFieldGet(zP,this).width+t,s=pdf_page_detail_view_classPrivateFieldGet(zP,this).height+i;if(e.minX<t||e.minY<i||e.maxX>a||e.maxY>s)return!0;const{width:r,height:n,scale:o}=this.pageView.viewport;if(pdf_page_detail_view_classPrivateFieldGet(zP,this).scale!==o)return!0;const l=e.minX-t,d=a-e.maxX,c=e.minY-i,h=s-e.maxY;return t>0&&d/l>3||a<r&&l/d>3||i>0&&h/c>3||s<n&&c/h>3}function struct_tree_layer_builder_classPrivateFieldInitSpec(e,t,i){struct_tree_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function struct_tree_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function struct_tree_layer_builder_classPrivateFieldGet(e,t){return e.get(struct_tree_layer_builder_assertClassBrand(e,t))}function struct_tree_layer_builder_classPrivateFieldSet(e,t,i){return e.set(struct_tree_layer_builder_assertClassBrand(e,t),i),i}function struct_tree_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const $P={Document:null,DocumentFragment:null,Part:"group",Art:"article",Sect:"group",Div:"group",BlockQuote:"blockquote",Aside:"note",NonStruct:"none",P:"paragraph",H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:"emphasis",Strong:"strong",Note:"note",Code:"code",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:"rowgroup",TBody:"rowgroup",TFoot:"rowgroup",Caption:"caption",Figure:"figure",Formula:null,Artifact:null},XP=new Set(["caption","code","emphasis","generic","none","paragraph","strong"]),KP=new Set(["math","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics"]),qP="http://www.w3.org/1998/Math/MathML";class MathMLSanitizer{static get sanitizer(){return shadow(this,"sanitizer",FeatureTest.isSanitizerSupported?new Sanitizer({elements:Array.from(KP.keys(),e=>({name:e,namespace:qP})),replaceWithChildrenElements:[{name:"maction",namespace:qP}],attributes:["dir","displaystyle","mathbackground","mathcolor","mathsize","scriptlevel","encoding","display","linethickness","intent","arg","form","fence","separator","lspace","rspace","stretchy","symmetric","maxsize","minsize","largeop","movablelimits","width","height","depth","voffset","accent","accentunder","columnspan","rowspan"],comments:!1}):null)}}const YP=/^H(\d+)$/;var ZP=new WeakMap,QP=new WeakMap,JP=new WeakMap,ew=new WeakMap,tw=new WeakMap,iw=new WeakMap,aw=new WeakMap,sw=new WeakMap,rw=new WeakMap,nw=new WeakMap,ow=new WeakMap,lw=new WeakMap,dw=new WeakMap,cw=new WeakMap,hw=new WeakSet;class StructTreeLayerBuilder{constructor(e,t){!function struct_tree_layer_builder_classPrivateMethodInitSpec(e,t){struct_tree_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,hw);struct_tree_layer_builder_classPrivateFieldInitSpec(this,ZP,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,QP,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,JP,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,ew,new Set);struct_tree_layer_builder_classPrivateFieldInitSpec(this,tw,new Map);struct_tree_layer_builder_classPrivateFieldInitSpec(this,iw,new Map);struct_tree_layer_builder_classPrivateFieldInitSpec(this,aw,0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,sw,`pdfjs_internal_struct_${getUuid()}_`);struct_tree_layer_builder_classPrivateFieldInitSpec(this,rw,new Map);struct_tree_layer_builder_classPrivateFieldInitSpec(this,nw,new Map);struct_tree_layer_builder_classPrivateFieldInitSpec(this,ow,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,lw,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,dw,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,cw,null);struct_tree_layer_builder_classPrivateFieldSet(ZP,this,e.getStructTree());struct_tree_layer_builder_classPrivateFieldSet(ow,this,t)}async render(){if(struct_tree_layer_builder_classPrivateFieldGet(JP,this))return struct_tree_layer_builder_classPrivateFieldGet(JP,this);const{promise:e,resolve:t,reject:i}=Promise.withResolvers();struct_tree_layer_builder_classPrivateFieldSet(JP,this,e);try{const e=await struct_tree_layer_builder_classPrivateFieldGet(ZP,this);struct_tree_layer_builder_assertClassBrand(hw,this,_collectStructElements).call(this,e);struct_tree_layer_builder_assertClassBrand(hw,this,_collectAnnotations).call(this,e);struct_tree_layer_builder_classPrivateFieldSet(QP,this,struct_tree_layer_builder_assertClassBrand(hw,this,_walk).call(this,e))}catch(e){i(e)}struct_tree_layer_builder_classPrivateFieldSet(ZP,this,null);struct_tree_layer_builder_classPrivateFieldGet(QP,this)?.classList.add("structTree");t(struct_tree_layer_builder_classPrivateFieldGet(QP,this));return e}async getAriaAttributes(e,{enableLinkOwnership:t=!1}={}){try{await this.render();const i=struct_tree_layer_builder_classPrivateFieldGet(iw,this).get(e);if(i&&t){const{element:t,ids:a}=i;t.removeAttribute("role");a.length>0&&struct_tree_layer_builder_classPrivateFieldGet(tw,this).getOrInsertComputed(e,makeMap).set("aria-owns",a.join(" "));struct_tree_layer_builder_classPrivateFieldGet(iw,this).delete(e)}return struct_tree_layer_builder_classPrivateFieldGet(tw,this).get(e)}catch{}return null}async getAnnotationIds(){try{await this.render();return struct_tree_layer_builder_classPrivateFieldGet(ew,this)}catch{}return null}hide(){struct_tree_layer_builder_classPrivateFieldGet(QP,this)&&!struct_tree_layer_builder_classPrivateFieldGet(QP,this).hidden&&(struct_tree_layer_builder_classPrivateFieldGet(QP,this).hidden=!0)}show(){struct_tree_layer_builder_classPrivateFieldGet(QP,this)?.hidden&&(struct_tree_layer_builder_classPrivateFieldGet(QP,this).hidden=!1)}updateTextLayer(e=null){const getElementById=t=>e?e.querySelector(`[id="${CSS.escape(t)}"]`):document.getElementById(t);if(struct_tree_layer_builder_classPrivateFieldGet(lw,this)){for(const[e,t]of struct_tree_layer_builder_classPrivateFieldGet(lw,this))getElementById(e)?.append(t);struct_tree_layer_builder_classPrivateFieldGet(lw,this).clear();struct_tree_layer_builder_classPrivateFieldSet(lw,this,null)}if(struct_tree_layer_builder_classPrivateFieldGet(dw,this)){for(const e of struct_tree_layer_builder_classPrivateFieldGet(dw,this)){const t=getElementById(e);t&&(t.ariaHidden=!0)}struct_tree_layer_builder_classPrivateFieldGet(dw,this).length=0;struct_tree_layer_builder_classPrivateFieldSet(dw,this,null)}if(struct_tree_layer_builder_classPrivateFieldGet(cw,this)){for(let e=0,t=struct_tree_layer_builder_classPrivateFieldGet(cw,this).length;e<t;e+=2){const t=struct_tree_layer_builder_classPrivateFieldGet(cw,this)[e],i=struct_tree_layer_builder_classPrivateFieldGet(cw,this)[e+1];let a="";for(const e of i){const t=getElementById(e);if(t){a+=t.textContent.trim()||"";t.ariaHidden="true"}}a&&(t.textContent=a)}struct_tree_layer_builder_classPrivateFieldGet(cw,this).length=0;struct_tree_layer_builder_classPrivateFieldSet(cw,this,null)}}}function _collectStructElements(e){if(e){e.structId&&struct_tree_layer_builder_classPrivateFieldGet(nw,this).getOrInsert(e.structId,e);for(const t of e.children||[])struct_tree_layer_builder_assertClassBrand(hw,this,_collectStructElements).call(this,t)}}function _collectAnnotations(e){if(e)if("annotation"!==e.type)for(const t of e.children||[])struct_tree_layer_builder_assertClassBrand(hw,this,_collectAnnotations).call(this,t);else struct_tree_layer_builder_classPrivateFieldGet(ew,this).add(e.id)}function _getStructElementId(e){return struct_tree_layer_builder_classPrivateFieldGet(rw,this).getOrInsertComputed(e,()=>`${struct_tree_layer_builder_classPrivateFieldGet(sw,this)}${struct_tree_layer_builder_classPrivateFieldGet(rw,this).size}`)}function _getHeaderIds(e){const t=[],i=new Set,a=e.toReversed();for(;a.length>0;){const e=a.pop();if(i.has(e))continue;i.add(e);const s=struct_tree_layer_builder_classPrivateFieldGet(nw,this).get(e);if("TH"===s?.role){t.push(struct_tree_layer_builder_assertClassBrand(hw,this,_getStructElementId).call(this,e));if(s.headers)for(let e=s.headers.length-1;e>=0;e--)a.push(s.headers[e])}}return t}function _setAttributes(e,t){const{alt:i,colSpan:a,headers:s,id:r,lang:n,rowSpan:o,short:l,structId:d,summary:c}=e;if(void 0!==i){let a=!1;const s=removeNullCharacters(i);for(const t of e.children)if("annotation"===t.type){struct_tree_layer_builder_classPrivateFieldGet(tw,this).getOrInsertComputed(t.id,makeMap).set("aria-label",s);a=!0}const r=t.getAttribute("role")||("span"===t.localName?"generic":null);a||"none"===r||t.setAttribute(XP.has(r)?"aria-description":"aria-label",s)}void 0!==r&&t.setAttribute("aria-owns",r);if(void 0!==d&&struct_tree_layer_builder_classPrivateFieldGet(nw,this).get(d)===e){const e=struct_tree_layer_builder_assertClassBrand(hw,this,_getStructElementId).call(this,d);if(void 0!==l){const i=document.createElement("span");i.setAttribute("id",e);i.setAttribute("aria-hidden","true");i.textContent=removeNullCharacters(l);t.append(i)}else t.setAttribute("id",e)}void 0!==n&&t.setAttribute("lang",removeNullCharacters(n,!0));void 0!==o&&t.setAttribute("aria-rowspan",o);void 0!==a&&t.setAttribute("aria-colspan",a);if(s?.length>0){const e=struct_tree_layer_builder_assertClassBrand(hw,this,_getHeaderIds).call(this,s);e.length>0&&t.setAttribute("aria-describedby",e.join(" "))}void 0!==c&&t.setAttribute("aria-description",removeNullCharacters(c))}function _addImageInTextLayer(e,t){const{alt:i,bbox:a,children:s}=e,r=s?.[0];if(!struct_tree_layer_builder_classPrivateFieldGet(ow,this)||!i||!a||"content"!==r?.type)return!1;const{id:n}=r;if(!n)return!1;t.setAttribute("aria-owns",n);const o=document.createElement("span");(struct_tree_layer_builder_classPrivateFieldGet(lw,this)||struct_tree_layer_builder_classPrivateFieldSet(lw,this,new Map)).set(n,o);o.setAttribute("role","img");o.setAttribute("aria-label",removeNullCharacters(i));const{pageHeight:l,pageX:d,pageY:c}=struct_tree_layer_builder_classPrivateFieldGet(ow,this),h="calc(var(--total-scale-factor) *",{style:_}=o;_.width=`${h}${a[2]-a[0]}px)`;_.height=`${h}${a[3]-a[1]}px)`;_.left=`${h}${a[0]-d}px)`;_.top=`${h}${l-a[3]+c}px)`;return!0}function _collectIds(e,t){if(e){"id"in e&&t.push(e.id);for(const i of e.children||[])struct_tree_layer_builder_assertClassBrand(hw,this,_collectIds).call(this,i,t)}}function _walk(e,t=[]){if(!e)return null;let i,a=!0;if("role"in e){const{role:s}=e;if(KP.has(s)){i=document.createElementNS(qP,s);const t=[];(struct_tree_layer_builder_classPrivateFieldGet(cw,this)||struct_tree_layer_builder_classPrivateFieldSet(cw,this,[])).push(i,t);for(const{type:i,id:a}of e.children||[])"content"===i&&a&&t.push(a)}else i=document.createElement("span");const r=s.match(YP);if(r){i.setAttribute("role","heading");i.setAttribute("aria-level",r[1])}else if($P[s]){let a=$P[s];if("TH"===s)"Row"===e.scope?a="rowheader":"Column"===e.scope?a="columnheader":"TR"===t.at(-1)?.role&&"TBody"===t.at(-2)?.role&&(a="rowheader");else if("Caption"===s){const e=t.at(-1)?.role;"Table"!==e&&"Figure"!==e&&(a=null)}a&&i.setAttribute("role",a)}if("Figure"===s&&struct_tree_layer_builder_assertClassBrand(hw,this,_addImageInTextLayer).call(this,e,i))return i;if("Formula"===s){if(e.mathML&&MathMLSanitizer.sanitizer){a=!1;i.setHTML(e.mathML,{sanitizer:MathMLSanitizer.sanitizer});struct_tree_layer_builder_assertClassBrand(hw,this,_collectIds).call(this,e,struct_tree_layer_builder_classPrivateFieldGet(dw,this)||struct_tree_layer_builder_classPrivateFieldSet(dw,this,[]));delete e.alt}if(!e.mathML&&1===e.children.length&&"math"!==e.children[0].role){i=document.createElementNS(qP,"math");delete e.alt}}}i||=document.createElement("span");struct_tree_layer_builder_assertClassBrand(hw,this,_setAttributes).call(this,e,i);if(e.children)if(1===e.children.length&&!("role"in e.children[0])&&"id"in e.children[0]&&"none"!==i.getAttribute("role"))struct_tree_layer_builder_assertClassBrand(hw,this,_setAttributes).call(this,e.children[0],i);else if(a){t.push(e);for(const a of e.children)i.append(struct_tree_layer_builder_assertClassBrand(hw,this,_walk).call(this,a,t));t.pop()}if("Link"===e.role){const t=e.children?.filter(e=>"annotation"===e.type);if(1===t?.length){const e=t[0],a=[];for(const t of i.children){var s,r;if(t.getAttribute("aria-owns")!==e.id){t.id||=`${struct_tree_layer_builder_classPrivateFieldGet(sw,this)}link_${struct_tree_layer_builder_classPrivateFieldSet(aw,this,(s=struct_tree_layer_builder_classPrivateFieldGet(aw,this),r=s++,s)),r}`;a.push(t.id)}}struct_tree_layer_builder_classPrivateFieldGet(iw,this).set(e.id,{element:i,ids:a})}}return i}function text_accessibility_classPrivateFieldInitSpec(e,t,i){text_accessibility_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_accessibility_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_accessibility_classPrivateFieldGet(e,t){return e.get(text_accessibility_assertClassBrand(e,t))}function text_accessibility_classPrivateFieldSet(e,t,i){return e.set(text_accessibility_assertClassBrand(e,t),i),i}function text_accessibility_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var _w=new WeakMap,uw=new WeakMap,pw=new WeakMap,gw=new WeakMap,mw=new WeakSet;class TextAccessibilityManager{constructor(){!function text_accessibility_classPrivateMethodInitSpec(e,t){text_accessibility_checkPrivateRedeclaration(e,t),t.add(e)}(this,mw);text_accessibility_classPrivateFieldInitSpec(this,_w,!1);text_accessibility_classPrivateFieldInitSpec(this,uw,null);text_accessibility_classPrivateFieldInitSpec(this,pw,new Map);text_accessibility_classPrivateFieldInitSpec(this,gw,new Map)}setTextMapping(e){text_accessibility_classPrivateFieldSet(uw,this,e)}enable(){if(text_accessibility_classPrivateFieldGet(_w,this))throw new Error("TextAccessibilityManager is already enabled.");if(!text_accessibility_classPrivateFieldGet(uw,this))throw new Error("Text divs and strings have not been set.");text_accessibility_classPrivateFieldSet(_w,this,!0);text_accessibility_classPrivateFieldSet(uw,this,text_accessibility_classPrivateFieldGet(uw,this).slice());text_accessibility_classPrivateFieldGet(uw,this).sort(_compareElementPositions);if(text_accessibility_classPrivateFieldGet(pw,this).size>0){const e=text_accessibility_classPrivateFieldGet(uw,this),t=e[0]?.closest(".pdfViewer");for(const[i,a]of text_accessibility_classPrivateFieldGet(pw,this)){(t?t.querySelector(`[id="${CSS.escape(i)}"]`):document.getElementById(i))?text_accessibility_assertClassBrand(mw,this,_addIdToAriaOwns).call(this,i,e[a]):text_accessibility_classPrivateFieldGet(pw,this).delete(i)}}for(const[e,t]of text_accessibility_classPrivateFieldGet(gw,this))this.addPointerInTextLayer(e,t);text_accessibility_classPrivateFieldGet(gw,this).clear()}disable(){if(text_accessibility_classPrivateFieldGet(_w,this)){text_accessibility_classPrivateFieldGet(gw,this).clear();text_accessibility_classPrivateFieldSet(uw,this,null);text_accessibility_classPrivateFieldSet(_w,this,!1)}}removePointerInTextLayer(e){if(!text_accessibility_classPrivateFieldGet(_w,this)){text_accessibility_classPrivateFieldGet(gw,this).delete(e);return}const t=text_accessibility_classPrivateFieldGet(uw,this);if(!t?.length)return;const{id:i}=e,a=text_accessibility_classPrivateFieldGet(pw,this).get(i);if(void 0===a)return;const s=t[a];text_accessibility_classPrivateFieldGet(pw,this).delete(i);let r=s.getAttribute("aria-owns");if(r?.includes(i)){r=r.split(" ").filter(e=>e!==i).join(" ");if(r)s.setAttribute("aria-owns",r);else{s.removeAttribute("aria-owns");s.setAttribute("role","presentation")}}}addPointerInTextLayer(e,t){const{id:i}=e;if(!i)return null;if(!text_accessibility_classPrivateFieldGet(_w,this)){text_accessibility_classPrivateFieldGet(gw,this).set(e,t);return null}t&&this.removePointerInTextLayer(e);const a=text_accessibility_classPrivateFieldGet(uw,this);if(!a?.length)return null;const s=binarySearchFirstItem(a,t=>_compareElementPositions.call(TextAccessibilityManager,e,t)<0),r=Math.max(0,s-1),n=a[r];text_accessibility_assertClassBrand(mw,this,_addIdToAriaOwns).call(this,i,n);text_accessibility_classPrivateFieldGet(pw,this).set(i,r);const o=n.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(e,t,i,a){const s=this.addPointerInTextLayer(i,a);if(!e.hasChildNodes()){e.append(t);return s}const r=Array.from(e.childNodes).filter(e=>e!==t);if(0===r.length)return s;const n=binarySearchFirstItem(r,e=>_compareElementPositions.call(TextAccessibilityManager,t,e)<0);0===n?r[0].before(t):r[n-1].after(t);return s}}function _compareElementPositions(e,t){const i=e.getBoundingClientRect(),a=t.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===a.width&&0===a.height)return-1;const s=i.y,r=i.y+i.height,n=i.y+i.height/2,o=a.y,l=a.y+a.height,d=a.y+a.height/2;if(n<=o&&d>=r)return-1;if(d<=s&&n>=l)return 1;return i.x+i.width/2-(a.x+a.width/2)}function _addIdToAriaOwns(e,t){const i=t.getAttribute("aria-owns");i?.includes(e)||t.setAttribute("aria-owns",i?`${i} ${e}`:e);t.removeAttribute("role")}function text_highlighter_classPrivateFieldInitSpec(e,t,i){(function text_highlighter_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function text_highlighter_classPrivateFieldSet(e,t,i){return e.set(text_highlighter_assertClassBrand(e,t),i),i}function text_highlighter_classPrivateFieldGet(e,t){return e.get(text_highlighter_assertClassBrand(e,t))}function text_highlighter_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var fw,vw=new WeakMap;class TextHighlighter{constructor({findController:e,customFindController:t,eventBus:i,pageIndex:a}){text_highlighter_classPrivateFieldInitSpec(this,vw,null);this.findController=e;this.customFindController=t;this.matches=[];this.eventBus=i;this.pageIdx=a;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){this.enabled=!0;if(!text_highlighter_classPrivateFieldGet(vw,this)){text_highlighter_classPrivateFieldSet(vw,this,new AbortController);this.eventBus.on("updatetextlayermatches",e=>{e.pageIndex!==this.pageIdx&&-1!==e.pageIndex||this._updateMatches()},{signal:text_highlighter_classPrivateFieldGet(vw,this).signal,...lu})}this._updateMatches()}}disable(){if(this.enabled){this.enabled=!1;text_highlighter_classPrivateFieldGet(vw,this)?.abort();text_highlighter_classPrivateFieldSet(vw,this,null);this._updateMatches(!0)}}_convertMatches(e,t,i="highlight",a=!1,s=!1,r=-1,n=null){if(!e)return[];const{textContentItemsStr:o}=this;let l=0,d=0;const c=o.length-1,h=[];for(let _=0,u=e.length;_<u;_++){let u=e[_];for(;l!==c&&u>=d+o[l].length;){d+=o[l].length;l++}l===o.length&&ngx_console_NgxConsole.error("Could not find a matching mapping");const p={begin:{divIdx:l,offset:u-d},cssClass:i+(n?` color${n[_]}`:""),highlightAll:a,selected:s&&_===r};u+=t[_];for(;l!==c&&u>d+o[l].length;){d+=o[l].length;l++}p.end={divIdx:l,offset:u-d};h.push(p)}return h}_renderMatches(e,t){if(0===e.length)return;const{pageIdx:i}=this,{textContentItemsStr:a,textDivs:s}=this;let r=null;const n={divIdx:-1,offset:void 0};function beginText(e,t){const i=e.divIdx;s[i].textContent="";return appendTextToDiv(i,0,e.offset,t)}function appendTextToDiv(e,t,i,r){let n=s[e];if(n.nodeType===Node.TEXT_NODE){const t=document.createElement("span");n.before(t);t.append(n);s[e]=t;n=t}const o=a[e].substring(t,i),l=document.createTextNode(o);if(r){const e=document.createElement("span");e.className=`${r} appended`;e.append(l);n.append(e);return r.includes("selected")?e:null}n.append(l);return 0}let o=-1,l=-1;for(let a=0;a<e.length;a++){const d=e[a];if(!d.selected&&!d.highlightAll)continue;const c=d.begin;if(c.divIdx===o&&c.offset===l)continue;o=c.divIdx;l=c.offset;const h=d.end,_=d.selected?" selected":"";let u=null;if(r&&c.divIdx===r.divIdx)appendTextToDiv(r.divIdx,r.offset,c.offset);else{null!==r&&appendTextToDiv(r.divIdx,r.offset,n.offset);beginText(c)}if(c.divIdx===h.divIdx)u=appendTextToDiv(c.divIdx,c.offset,h.offset,d.cssClass+_);else{u=appendTextToDiv(c.divIdx,c.offset,n.offset,d.cssClass+" begin"+_);for(let e=c.divIdx+1,t=h.divIdx;e<t;e++)s[e].className=d.cssClass+" middle"+_;beginText(h,d.cssClass+" end"+_)}r=h;d.selected&&t.scrollMatchIntoView({element:u,pageIndex:i,matchIndex:a});if(this.textDivs.length>0){const e=this.textDivs[0].closest(".textLayer").querySelectorAll(`.${d.cssClass}`);this.eventBus.dispatch("renderedtextlayerhighlights",{pageIndex:i,highlights:e})}}r&&appendTextToDiv(r.divIdx,r.offset,n.offset)}_updateMatches(e=!1){if(!this.enabled&&!e)return;const{findController:t,customFindController:i,matches:a,pageIdx:s}=this,{textContentItemsStr:r,textDivs:n}=this;let o=-1;for(const e of a){for(let t=Math.max(o,e.begin.divIdx),i=e.end.divIdx;t<=i;t++){const e=n[t];e.textContent=r[t];e.className=""}o=e.end.divIdx+1}if(e)return;const l=i.pageMatches[s]||null,d=i.pageMatchesLength[s]||null,c=i.pageMatchesColor?.[s]||null,h=t.pageMatches[s]||null,_=this._convertMatches(l,d,"customHighlight",i.state?.highlightAll,s===i.selected.pageIdx,i.selected.matchIdx,c);this.matches=[..._];t?.highlightMatches&&!e||e||this._renderMatches(this.matches,this.customFindController);const u=t.pageMatchesLength[s]||null,p=t.pageMatchesColor?.[s]||null,g=this._convertMatches(h,u,"highlight",t.state?.highlightAll,s===t.selected.pageIdx,t.selected.matchIdx,p);this.matches.push(...g);this.matches.sort((e,t)=>{const i=e.begin.divIdx-t.begin.divIdx;return 0===i?e.begin.offset-t.begin.offset:i});this._renderMatches(this.matches,this.findController)}}function text_layer_builder_classPrivateFieldInitSpec(e,t,i){text_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_builder_classPrivateFieldGet(e,t){return e.get(text_layer_builder_assertClassBrand(e,t))}function text_layer_builder_classPrivateFieldSet(e,t,i){return e.set(text_layer_builder_assertClassBrand(e,t),i),i}function text_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Pw=new WeakMap,ww=new WeakMap,Fw=new WeakMap,yw=new WeakMap,bw=new WeakMap,Sw=new WeakSet;class TextLayerBuilder{constructor({pdfPage:e,highlighter:t=null,accessibilityManager:i=null,enablePermissions:a=!1,onAppend:s=null,abortSignal:r=null}){!function text_layer_builder_classPrivateMethodInitSpec(e,t){text_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,Sw);text_layer_builder_classPrivateFieldInitSpec(this,Pw,null);text_layer_builder_classPrivateFieldInitSpec(this,ww,!1);text_layer_builder_classPrivateFieldInitSpec(this,Fw,null);text_layer_builder_classPrivateFieldInitSpec(this,yw,!1);text_layer_builder_classPrivateFieldInitSpec(this,bw,null);this.pdfPage=e;this.highlighter=t;this.accessibilityManager=i;text_layer_builder_classPrivateFieldSet(ww,this,!0===a);text_layer_builder_classPrivateFieldSet(Fw,this,s);text_layer_builder_classPrivateFieldSet(Pw,this,r);this.div=document.createElement("div");this.div.tabIndex=0;this.div.className="textLayer"}async render({viewport:e,images:t,textContentParams:i=null}){if(text_layer_builder_classPrivateFieldGet(yw,this)&&text_layer_builder_classPrivateFieldGet(bw,this)){text_layer_builder_classPrivateFieldGet(bw,this).update({viewport:e});this.show();return}this.cancel();text_layer_builder_classPrivateFieldSet(bw,this,new TextLayer({textContentSource:this.pdfPage.streamTextContent(i||{includeMarkedContent:!0,disableNormalization:!0}),images:t,container:this.div,viewport:e}));const{textDivs:a,textContentItemsStr:s}=text_layer_builder_classPrivateFieldGet(bw,this);this.highlighter?.setTextMapping(a,s);this.accessibilityManager?.setTextMapping(a);await text_layer_builder_classPrivateFieldGet(bw,this).render();text_layer_builder_classPrivateFieldSet(yw,this,!0);const r=document.createElement("div");r.className="endOfContent";this.div.append(r);text_layer_builder_assertClassBrand(Sw,this,_bindMouse).call(this,r);text_layer_builder_classPrivateFieldGet(Fw,this)?.call(this,this.div);this.highlighter?.enable();this.accessibilityManager?.enable()}hide(){if(!this.div.hidden&&text_layer_builder_classPrivateFieldGet(yw,this)){this.highlighter?.disable();this.div.hidden=!0}}show(){if(this.div.hidden&&text_layer_builder_classPrivateFieldGet(yw,this)){this.div.hidden=!1;this.highlighter?.enable()}}cancel(){text_layer_builder_classPrivateFieldGet(bw,this)?.cancel();text_layer_builder_classPrivateFieldSet(bw,this,null);text_layer_builder_classPrivateFieldSet(yw,this,!1);this.div.replaceChildren();this.highlighter?.disable();this.accessibilityManager?.disable();_removeGlobalSelectionListener.call(TextLayerBuilder,this.div)}}fw=TextLayerBuilder;function _bindMouse(e){const{div:t}=this,i=text_layer_builder_classPrivateFieldGet(Pw,this),a=i?{signal:i}:null;t.addEventListener("mousedown",()=>{t.classList.add("selecting")},a);t.addEventListener("copy",e=>{if(!text_layer_builder_classPrivateFieldGet(ww,this)){const t=document.getSelection();e.clipboardData.setData("text/plain",removeNullCharacters(normalizeUnicode(t.toString())))}stopEvent(e)},a);Cw._.set(t,e);_enableGlobalSelectionListener.call(fw,i)}function _removeGlobalSelectionListener(e){text_layer_builder_assertClassBrand(fw,this,Cw)._.delete(e);if(0===text_layer_builder_assertClassBrand(fw,this,Cw)._.size){text_layer_builder_assertClassBrand(fw,this,xw)._?.abort();xw._=text_layer_builder_assertClassBrand(fw,this,null)}}function _enableGlobalSelectionListener(e){if(text_layer_builder_assertClassBrand(fw,this,xw)._)return;xw._=text_layer_builder_assertClassBrand(fw,this,new AbortController);const t=e?AbortSignal.any([text_layer_builder_assertClassBrand(fw,this,xw)._.signal,e]):text_layer_builder_assertClassBrand(fw,this,xw)._.signal,reset=(e,t)=>{t.append(e);e.style.width="";e.style.height="";t.classList.remove("selecting")};let i=!1;document.addEventListener("pointerdown",()=>{i=!0},{signal:t});document.addEventListener("pointerup",()=>{i=!1;text_layer_builder_assertClassBrand(fw,this,Cw)._.forEach(reset)},{signal:t});window.addEventListener("blur",()=>{i=!1;text_layer_builder_assertClassBrand(fw,this,Cw)._.forEach(reset)},{signal:t});document.addEventListener("keyup",()=>{i||text_layer_builder_assertClassBrand(fw,this,Cw)._.forEach(reset)},{signal:t});var a,s;document.addEventListener("selectionchange",()=>{const e=document.getSelection();if(0===e.rangeCount){text_layer_builder_assertClassBrand(fw,this,Cw)._.forEach(reset);return}if(0===text_layer_builder_assertClassBrand(fw,this,Cw)._.size)return;const t=new Set;for(let a=0;a<e.rangeCount;a++){const s=e.getRangeAt(a);if(!s.collapsed||i)for(const e of text_layer_builder_assertClassBrand(fw,this,Cw)._.keys())!t.has(e)&&s.intersectsNode(e)&&t.add(e)}for(const[e,i]of text_layer_builder_assertClassBrand(fw,this,Cw)._)t.has(e)?e.classList.add("selecting"):reset(i,e);if(void 0===a&&!(a="none"===getComputedStyle(text_layer_builder_assertClassBrand(fw,this,Cw)._.values().next().value).getPropertyValue("-moz-user-select"))){const e=navigator.userAgentData?navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e)?.version:/\bChrome\/(\d+)\b/.exec(navigator.userAgent)?.[1];a=!!e&&parseInt(e,10)>=148}if(a)return;const r=e.getRangeAt(0),n=s&&(0===r.compareBoundaryPoints(Range.END_TO_END,s)||0===r.compareBoundaryPoints(Range.START_TO_END,s));let o=n?r.startContainer:r.endContainer;o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);o.classList?.contains("highlight")&&(o=o.parentNode);if(!n&&0===r.endOffset)do{for(;!o.previousSibling;)o=o.parentNode;o=o.previousSibling}while(!o.childNodes.length);const l=o.parentElement?.closest(".textLayer"),d=text_layer_builder_assertClassBrand(fw,this,Cw)._.get(l);if(d){d.style.width=l.style.width;d.style.height=l.style.height;d.style.userSelect="text";o.parentElement.insertBefore(d,n?o:o.nextSibling)}s=r.cloneRange()},{signal:t})}var Cw={_:new Map},xw={_:null};function pdf_page_view_classPrivateFieldInitSpec(e,t,i){pdf_page_view_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_page_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_page_view_classPrivateFieldGet(e,t){return e.get(pdf_page_view_assertClassBrand(e,t))}function pdf_page_view_classPrivateFieldSet(e,t,i){return e.set(pdf_page_view_assertClassBrand(e,t),i),i}function pdf_page_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const kw=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);var Ew=new WeakMap,Aw=new WeakMap,Gw=new WeakMap,Bw=new WeakMap,Mw=new WeakMap,Iw=new WeakMap,Tw=new WeakMap,Dw=new WeakMap,Lw=new WeakMap,Rw=new WeakMap,Ow=new WeakMap,Nw=new WeakMap,Ww=new WeakMap,jw=new WeakMap,Vw=new WeakMap,Uw=new WeakMap,zw=new WeakMap,Hw=new WeakSet;class PDFPageView extends BasePDFPageView{constructor(e){super(e);!function pdf_page_view_classPrivateMethodInitSpec(e,t){pdf_page_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,Hw);pdf_page_view_classPrivateFieldInitSpec(this,Ew,null);pdf_page_view_classPrivateFieldInitSpec(this,Aw,p.ENABLE_FORMS);pdf_page_view_classPrivateFieldInitSpec(this,Gw,null);pdf_page_view_classPrivateFieldInitSpec(this,Bw,null);pdf_page_view_classPrivateFieldInitSpec(this,Mw,!0);pdf_page_view_classPrivateFieldInitSpec(this,Iw,!1);pdf_page_view_classPrivateFieldInitSpec(this,Tw,!1);pdf_page_view_classPrivateFieldInitSpec(this,Dw,null);pdf_page_view_classPrivateFieldInitSpec(this,Lw,!1);pdf_page_view_classPrivateFieldInitSpec(this,Rw,null);pdf_page_view_classPrivateFieldInitSpec(this,Ow,null);pdf_page_view_classPrivateFieldInitSpec(this,Nw,1);pdf_page_view_classPrivateFieldInitSpec(this,Ww,1);pdf_page_view_classPrivateFieldInitSpec(this,jw,z_);pdf_page_view_classPrivateFieldInitSpec(this,Vw,1);pdf_page_view_classPrivateFieldInitSpec(this,Uw,{directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0});pdf_page_view_classPrivateFieldInitSpec(this,zw,[null,null,null,null]);const{container:t,defaultViewport:i}=e;this.renderingId="page"+this.id;pdf_page_view_classPrivateFieldSet(Dw,this,e.layerProperties||null);pdf_page_view_classPrivateFieldSet(Ew,this,e.abortSignal||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;pdf_page_view_classPrivateFieldSet(jw,this,e.textLayerMode??z_);pdf_page_view_classPrivateFieldSet(Aw,this,e.annotationMode??p.ENABLE_FORMS);this.imageResourcesPath=e.imageResourcesPath||"";this.enableDetailCanvas=e.enableDetailCanvas??!0;this.maxCanvasPixels=e.maxCanvasPixels??AppOptions.get("maxCanvasPixels");this.maxCanvasDim=e.maxCanvasDim||AppOptions.get("maxCanvasDim");this.capCanvasAreaFactor=e.capCanvasAreaFactor??AppOptions.get("capCanvasAreaFactor");pdf_page_view_classPrivateFieldSet(Mw,this,!1!==e.enableAutoLinking);pdf_page_view_classPrivateFieldSet(Bw,this,e.commentManager||null);this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;this._isStandalone=!this.renderingQueue?.hasViewer();this._container=t;this._annotationCanvasMap=null;this.annotationLayer=null;this.annotationEditorLayer=null;this.textLayer=null;this.xfaLayer=null;this.structTreeLayer=null;this.drawLayer=null;this.detailView=null;const a=document.createElement("div");a.className="page";a.setAttribute("data-page-number",this.id);a.setAttribute("role","region");a.setAttribute("data-l10n-id","pdfjs-page-landmark");a.setAttribute("data-l10n-args",JSON.stringify({page:this.id}));this.div=a;pdf_page_view_assertClassBrand(Hw,this,_setDimensions).call(this);t?.append(a);if(this._isStandalone){t?.style.setProperty("--scale-factor",this.scale*PixelsPerInch.PDF_TO_CSS_UNITS);this.pageColors?.background&&t?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:i}=e;i&&i.then(e=>{i===this._optionalContentConfigPromise&&(pdf_page_view_classPrivateFieldGet(Uw,this).initialOptionalContent=e.hasInitialVisibility)});e.l10n||this.l10n.translate(this.div)}}clone(e){const t=new PDFPageView({container:null,eventBus:this.eventBus,pagesColors:this.pageColors,renderingQueue:this.renderingQueue,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,minDurationToUpdateCanvas:this.minDurationToUpdateCanvas,defaultViewport:this.viewport,id:e,layerProperties:pdf_page_view_classPrivateFieldGet(Dw,this),abortSignal:pdf_page_view_classPrivateFieldGet(Ew,this),scale:this.scale,optionalContentConfigPromise:this._optionalContentConfigPromise,textLayerMode:pdf_page_view_classPrivateFieldGet(jw,this),annotationMode:pdf_page_view_classPrivateFieldGet(Aw,this),imageResourcesPath:this.imageResourcesPath,enableDetailCanvas:this.enableDetailCanvas,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableAutoLinking:pdf_page_view_classPrivateFieldGet(Mw,this),commentManager:pdf_page_view_classPrivateFieldGet(Bw,this),l10n:this.l10n});t.setPdfPage(this.pdfPage.clone(e-1));return t}updatePageNumber(e){const t=this.id;if(t!==e){this.id=e;this.renderingId=`page${e}`;this.pdfPage&&(this.pdfPage.pageNumber=e);this.setPageLabel(this.pageLabel);const{div:t}=this;t.setAttribute("data-page-number",e);t.setAttribute("data-l10n-args",JSON.stringify({page:e}));this._textHighlighter.pageIdx=e-1}pdf_page_view_classPrivateFieldGet(Dw,this).annotationEditorUIManager?.updatePageIndex(t-1,e-1)}setPdfPage(e){if(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*PixelsPerInch.PDF_TO_CSS_UNITS,rotation:t});pdf_page_view_assertClassBrand(Hw,this,_setDimensions).call(this);this.reset()}destroy(){this.reset();this.pdfPage?.cleanup()}deleteMe(e){if(e)this.div.remove();else{this.destroy();pdf_page_view_classPrivateFieldGet(Dw,this).annotationEditorUIManager?.deletePage(this.id)}}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return shadow(this,"_textHighlighter",new TextHighlighter({pageIndex:this.id-1,eventBus:this.eventBus,findController:pdf_page_view_classPrivateFieldGet(Dw,this).findController,customFindController:pdf_page_view_classPrivateFieldGet(Dw,this).customFindController}))}_refreshAnnotationLayer(){this._annotationCanvasMap?.size&&this.annotationLayer?.refreshCanvases()}_resetCanvas(){super._resetCanvas();pdf_page_view_classPrivateFieldSet(Rw,this,null)}reset({keepAnnotationLayer:e=!1,keepAnnotationEditorLayer:t=!1,keepXfaLayer:i=!1,keepTextLayer:a=!1,keepCanvasWrapper:s=!1,preserveDetailViewState:r=!1}={}){const n=this.pdfPage?._pdfBug??!1;this.cancelRendering({keepAnnotationLayer:e,keepAnnotationEditorLayer:t,keepXfaLayer:i,keepTextLayer:a});this.renderingState=Xf.INITIAL;const o=this.div,l=o.childNodes,d=e&&this.annotationLayer?.div||null,c=t&&this.annotationEditorLayer?.div||null,h=i&&this.xfaLayer?.div||null,_=a&&this.textLayer?.div||null,u=s&&pdf_page_view_classPrivateFieldGet(Gw,this)||null;for(let e=l.length-1;e>=0;e--){const t=l[e];switch(t){case d:case c:case h:case _:case u:continue}if(n&&t.classList.contains("pdfBugGroupsLayer"))continue;t.remove();const i=pdf_page_view_classPrivateFieldGet(zw,this).indexOf(t);i>=0&&(pdf_page_view_classPrivateFieldGet(zw,this)[i]=null)}o.removeAttribute("data-loaded");d&&this.annotationLayer.hide();c&&this.annotationEditorLayer.hide();h&&this.xfaLayer.hide();_&&this.textLayer.hide();this.structTreeLayer?.hide();if(!s&&pdf_page_view_classPrivateFieldGet(Gw,this)){pdf_page_view_classPrivateFieldSet(Gw,this,null);this._resetCanvas()}if(!r){this.detailView?.reset({keepCanvas:s});s||(this.detailView=null)}}toggleEditingMode(e){pdf_page_view_classPrivateFieldSet(Tw,this,e);this.hasEditableAnnotations()&&this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}updateVisibleArea(e){if(this.enableDetailCanvas)if(pdf_page_view_classPrivateFieldGet(Lw,this)&&this.maxCanvasPixels>0&&e){this.detailView??=new PDFPageDetailView({pageView:this,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,imagesRightClickMinSize:-1});this.detailView.update({visibleArea:e})}else if(this.detailView){this.detailView.reset();this.detailView=null}}update({scale:e=0,rotation:t=null,optionalContentConfigPromise:i=null,drawingDelay:a=-1}){this.scale=e||this.scale;"number"==typeof t&&(this.rotation=t);const s=a>=0&&a<1e3;if(s&&!this.canvas)return;if(i instanceof Promise){this._optionalContentConfigPromise=i;i.then(e=>{i===this._optionalContentConfigPromise&&(pdf_page_view_classPrivateFieldGet(Uw,this).initialOptionalContent=e.hasInitialVisibility)})}pdf_page_view_classPrivateFieldGet(Uw,this).directDrawing=!0;const r=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:this.scale*PixelsPerInch.PDF_TO_CSS_UNITS,rotation:r});pdf_page_view_assertClassBrand(Hw,this,_setDimensions).call(this);this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale);pdf_page_view_assertClassBrand(Hw,this,_computeScale).call(this);if(this.canvas){const e=pdf_page_view_classPrivateFieldGet(Iw,this)&&pdf_page_view_classPrivateFieldGet(Lw,this);if(s||e){if(s&&!e&&this.renderingState!==Xf.FINISHED){this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:a});this.renderingState=Xf.FINISHED;pdf_page_view_classPrivateFieldGet(Uw,this).directDrawing=!1}this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!s,hideTextLayer:s});if(!s){this.detailView?.update({underlyingViewUpdated:!0});this.dispatchPageRendered(!0,!1)}return}}this.cssTransform({});this.annotationEditorLayer?.update(this.viewport);this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0,preserveDetailViewState:!0});this.detailView?.update({underlyingViewUpdated:!0})}cancelRendering({keepAnnotationLayer:e=!1,keepAnnotationEditorLayer:t=!1,keepXfaLayer:i=!1,keepTextLayer:a=!1,cancelExtraDelay:s=0}={}){super.cancelRendering({cancelExtraDelay:s});if(this.textLayer&&(!a||!this.textLayer.div)){this.textLayer.cancel();this.textLayer=null}if(this.annotationLayer&&(!e||!this.annotationLayer.div)){this.annotationLayer.cancel();this.annotationLayer=null;this._annotationCanvasMap=null}this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null);if(this.annotationEditorLayer&&(!t||!this.annotationEditorLayer.div||!this.textLayer)){if(this.drawLayer){this.drawLayer.cancel();this.drawLayer=null}this.annotationEditorLayer.cancel();this.annotationEditorLayer=null}if(this.drawLayer&&!this.textLayer){this.drawLayer.cancel();this.drawLayer=null}if(this.xfaLayer&&(!i||!this.xfaLayer.div)){this.xfaLayer.cancel();this.xfaLayer=null;this._textHighlighter?.disable()}}cssTransform({redrawAnnotationLayer:e=!1,redrawAnnotationEditorLayer:t=!1,redrawXfaLayer:i=!1,redrawTextLayer:a=!1,hideTextLayer:s=!1}){const{canvas:r}=this;if(!r)return;const n=pdf_page_view_classPrivateFieldGet(Rw,this);if(this.viewport!==n){const e=(360+this.viewport.rotation-n.rotation)%360;if(90===e||270===e){const{width:t,height:i}=this.viewport,a=i/t,s=t/i;r.style.transform=`rotate(${e}deg) scale(${a},${s})`}else r.style.transform=0===e?"":`rotate(${e}deg)`}e&&this.annotationLayer&&pdf_page_view_assertClassBrand(Hw,this,_renderAnnotationLayer).call(this);if(t&&this.annotationEditorLayer){this.drawLayer&&pdf_page_view_assertClassBrand(Hw,this,_renderDrawLayer).call(this);pdf_page_view_assertClassBrand(Hw,this,_renderAnnotationEditorLayer).call(this)}i&&this.xfaLayer&&pdf_page_view_assertClassBrand(Hw,this,_renderXfaLayer).call(this);if(this.textLayer)if(s){this.textLayer.hide();this.structTreeLayer?.hide()}else a&&pdf_page_view_assertClassBrand(Hw,this,_renderTextLayer).call(this)}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(e,t){return this.viewport.convertToPdfPoint(e,t)}_ensureCanvasWrapper(){let e=pdf_page_view_classPrivateFieldGet(Gw,this);if(!e){e=pdf_page_view_classPrivateFieldSet(Gw,this,document.createElement("div"));e.classList.add("canvasWrapper");pdf_page_view_assertClassBrand(Hw,this,_addLayer).call(this,e,"canvasWrapper")}return e}_getRenderingContext(e,t,i,a){const s=AppOptions.get("pdfBackgroundColor");return{canvas:e,transform:t,viewport:this.viewport,annotationMode:pdf_page_view_classPrivateFieldGet(Aw,this),optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:this.pageColors,isEditing:pdf_page_view_classPrivateFieldGet(Tw,this),background:s||null,recordOperations:i,recordImages:a,partialFrames:!0}}async draw(){if(this.renderingState!==Xf.INITIAL){ngx_console_NgxConsole.error("Must be in new state before drawing");this.reset()}const{div:e,l10n:t,pdfPage:i,viewport:a}=this;if(!i){this.renderingState=Xf.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Xf.RUNNING;const s=this._ensureCanvasWrapper();if(!this.textLayer&&pdf_page_view_classPrivateFieldGet(jw,this)!==U_&&!i.isPureXfa){this._accessibilityManager||=new TextAccessibilityManager;this.textLayer=new TextLayerBuilder({pdfPage:i,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:pdf_page_view_classPrivateFieldGet(jw,this)===H_,onAppend:e=>{this.l10n.pause();pdf_page_view_assertClassBrand(Hw,this,_addLayer).call(this,e,"textLayer");this.l10n.resume()},abortSignal:pdf_page_view_classPrivateFieldGet(Ew,this)});this.enableSelectionRendering&&this.textLayer.div.classList.add("selectionRendering")}if(!this.annotationLayer&&pdf_page_view_classPrivateFieldGet(Aw,this)!==p.DISABLE){const{annotationStorage:e,annotationEditorUIManager:t,downloadManager:a,enableComment:s,enableScripting:r,fieldObjectsPromise:n,hasJSActionsPromise:o,linkService:l}=pdf_page_view_classPrivateFieldGet(Dw,this);this._annotationCanvasMap||=new Map;this.annotationLayer=new AnnotationLayerBuilder({pdfPage:i,annotationStorage:e,imageResourcesPath:this.imageResourcesPath,renderForms:pdf_page_view_classPrivateFieldGet(Aw,this)===p.ENABLE_FORMS,linkService:l,downloadManager:a,enableComment:s,enableScripting:r,hasJSActionsPromise:o,fieldObjectsPromise:n,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:t,commentManager:pdf_page_view_classPrivateFieldGet(Bw,this),onAppend:e=>{pdf_page_view_assertClassBrand(Hw,this,_addLayer).call(this,e,"annotationLayer")}})}const{width:r,height:n}=a;pdf_page_view_classPrivateFieldSet(Rw,this,a);const{canvas:o,prevCanvas:l}=this._createCanvas(e=>{s.prepend(e)});o.setAttribute("role","presentation");this.outputScale||pdf_page_view_assertClassBrand(Hw,this,_computeScale).call(this);const{outputScale:d}=this;pdf_page_view_classPrivateFieldSet(Iw,this,pdf_page_view_classPrivateFieldGet(Lw,this));const c=approximateFraction(d.sx),h=approximateFraction(d.sy);let _=floorToDivide(r*d.sx,c[0]),u=floorToDivide(n*d.sy,h[0]);const g=await MaxCanvasSize.reduceToMaxCanvasSize(_,u);if(g>1){_/=g;_*=.95;u/=g;u*=.95;const e=Math.round(100*(g/.95-1));warn(`Page ${this.id}: Reduced the maximum resolution by ${e}% because the browser can't render larger canvases.`)}o.width=_;o.height=u;const m=floorToDivide(nu(r),c[1]),f=floorToDivide(nu(n),h[1]);d.sx=_/m;d.sy=u/f;if(pdf_page_view_classPrivateFieldGet(Nw,this)!==c[1]){e.style.setProperty("--scale-round-x",`${c[1]}px`);pdf_page_view_classPrivateFieldSet(Nw,this,c[1])}if(pdf_page_view_classPrivateFieldGet(Ww,this)!==h[1]){e.style.setProperty("--scale-round-y",`${h[1]}px`);pdf_page_view_classPrivateFieldSet(Ww,this,h[1])}const v=this.enableOptimizedPartialRendering&&pdf_page_view_classPrivateFieldGet(Iw,this)&&!this.recordedBBoxes,P=-1!==this.imagesRightClickMinSize&&!this.imageCoordinates,w=d.scaled?[d.sx,0,0,d.sy,0,0]:null,F=o,y=this._drawCanvas(this._getRenderingContext(o,w,v,P),()=>{if(l){l.remove();l.width=l.height=0}this.canvas===F&&this._resetCanvas()},e=>{pdf_page_view_classPrivateFieldGet(Uw,this).regularAnnotations=!e.separateAnnots;this.dispatchPageRendered(!1,!1)}).then(async()=>{if(this.renderingState!==Xf.FINISHED)return;this.structTreeLayer||=new StructTreeLayerBuilder(i,a.rawDims);const e=this.textLayer?pdf_page_view_assertClassBrand(Hw,this,_renderTextLayer).call(this):null;this.annotationLayer&&await pdf_page_view_assertClassBrand(Hw,this,_renderAnnotationLayer).call(this,e);this.drawLayer||=new DrawLayerBuilder({pageIndex:this.id,textLayer:this.enableSelectionRendering?this.textLayer?.div:null,filterFactory:this.pdfPage?.filterFactory,pageColors:this.pageColors});await pdf_page_view_assertClassBrand(Hw,this,_renderDrawLayer).call(this);this.drawLayer.setParent(s);const{annotationEditorUIManager:r}=pdf_page_view_classPrivateFieldGet(Dw,this);if(r&&(this.annotationLayer||pdf_page_view_classPrivateFieldGet(Aw,this)===p.DISABLE)){this.annotationEditorLayer||=new AnnotationEditorLayerBuilder({uiManager:r,pageIndex:this.id-1,l10n:t,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:e=>{pdf_page_view_assertClassBrand(Hw,this,_addLayer).call(this,e,"annotationEditorLayer")},eventBus:this.eventBus});pdf_page_view_assertClassBrand(Hw,this,_renderAnnotationEditorLayer).call(this)}});if(i.isPureXfa){if(!this.xfaLayer){const{annotationStorage:e,linkService:t}=pdf_page_view_classPrivateFieldGet(Dw,this);this.xfaLayer=new XfaLayerBuilder({pdfPage:i,annotationStorage:e,linkService:t})}pdf_page_view_assertClassBrand(Hw,this,_renderXfaLayer).call(this)}e.setAttribute("data-loaded",!0);this.dispatchPageRender();return y}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}=pdf_page_view_classPrivateFieldGet(Uw,this);return e&&t&&i?this.canvas:null}}function _addLayer(e,t){const i=kw.get(t),a=pdf_page_view_classPrivateFieldGet(zw,this)[i];pdf_page_view_classPrivateFieldGet(zw,this)[i]=e;if(a)a.replaceWith(e);else{for(let t=i-1;t>=0;t--){const i=pdf_page_view_classPrivateFieldGet(zw,this)[t];if(i){i.after(e);return}}this.div.prepend(e)}}function _setDimensions(){const{div:e,viewport:t}=this;if(t.userUnit!==pdf_page_view_classPrivateFieldGet(Vw,this)){1!==t.userUnit?e.style.setProperty("--user-unit",t.userUnit):e.style.removeProperty("--user-unit");pdf_page_view_classPrivateFieldSet(Vw,this,t.userUnit)}if(this.pdfPage){if(pdf_page_view_classPrivateFieldGet(Ow,this)===t.rotation)return;pdf_page_view_classPrivateFieldSet(Ow,this,t.rotation)}setLayerDimensions(e,t,!0,!1)}function _dispatchLayerRendered(e,t,i){this.eventBus.dispatch(e,{source:this,pageNumber:this.id,error:t,layer:i})}async function _renderAnnotationLayer(e=null){const{annotationLayer:t,textLayer:i}=this;let a=null;try{await this.annotationLayer.render({viewport:this.viewport,intent:"display",structTreeLayer:this.structTreeLayer,optionalContentConfigPromise:this._optionalContentConfigPromise})}catch(e){ngx_console_NgxConsole.error("#renderAnnotationLayer:",e);a=e}finally{pdf_page_view_assertClassBrand(Hw,this,_dispatchLayerRendered).call(this,"annotationlayerrendered",a,this.annotationLayer)}pdf_page_view_classPrivateFieldGet(Mw,this)&&e&&!t.linksInjected&&pdf_page_view_assertClassBrand(Hw,this,_injectLinkAnnotations).call(this,e,t,i)}async function _renderAnnotationEditorLayer(){let e=null;try{await this.annotationEditorLayer.render({viewport:this.viewport,intent:"display"})}catch(t){ngx_console_NgxConsole.error("#renderAnnotationEditorLayer:",t);e=t}finally{pdf_page_view_assertClassBrand(Hw,this,_dispatchLayerRendered).call(this,"annotationeditorlayerrendered",e,this.annotationEditorLayer)}}async function _renderDrawLayer(){try{await this.drawLayer.render({intent:"display"})}catch(e){ngx_console_NgxConsole.error("#renderDrawLayer:",e)}}async function _renderXfaLayer(){let e=null;try{const e=await this.xfaLayer.render({viewport:this.viewport,intent:"display"});e?.textDivs&&this._textHighlighter&&pdf_page_view_assertClassBrand(Hw,this,_buildXfaTextContentItems).call(this,e.textDivs)}catch(t){ngx_console_NgxConsole.error("#renderXfaLayer:",t);e=t}finally{if(this.xfaLayer?.div){this.l10n.pause();pdf_page_view_assertClassBrand(Hw,this,_addLayer).call(this,this.xfaLayer.div,"xfaLayer");this.l10n.resume()}pdf_page_view_assertClassBrand(Hw,this,_dispatchLayerRendered).call(this,"xfalayerrendered",e,this.xfaLayer)}}async function _renderTextLayer(){let e=null;try{await this.textLayer.render({viewport:this.viewport,images:this.imageCoordinates?new TextLayerImages(this.imagesRightClickMinSize,this.imageCoordinates,this.viewport,()=>this.canvas):null})}catch(t){if(t instanceof AbortException)return!0;ngx_console_NgxConsole.error("#renderTextLayer:",t);e=t}pdf_page_view_assertClassBrand(Hw,this,_dispatchLayerRendered).call(this,"textlayerrendered",e,this.textLayer);pdf_page_view_assertClassBrand(Hw,this,_renderStructTreeLayer).call(this);return!1}async function _renderStructTreeLayer(){const e=await(this.structTreeLayer?.render());if(e){this.l10n.pause();this.structTreeLayer?.updateTextLayer(this.div);this.canvas&&e.parentNode!==this.canvas&&this.canvas.append(e);this.l10n.resume()}this.structTreeLayer?.show()}async function _buildXfaTextContentItems(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()}async function _injectLinkAnnotations(e,t,i){let a=null;try{if(await e||t!==this.annotationLayer||i!==this.textLayer||t.linksInjected)return;await t.injectLinkAnnotations(Autolinker.processLinks(this))}catch(e){ngx_console_NgxConsole.error("#injectLinkAnnotations:",e);a=e}pdf_page_view_assertClassBrand(Hw,this,_dispatchLayerRendered).call(this,"linkannotationsadded",a)}function _computeScale(){const{width:e,height:t}=this.viewport,i=this.outputScale=new OutputScale;if(0===this.maxCanvasPixels){const e=1/this.scale;i.sx*=e;i.sy*=e;pdf_page_view_classPrivateFieldSet(Lw,this,!0)}else{pdf_page_view_classPrivateFieldSet(Lw,this,i.limitCanvas(e,t,this.maxCanvasPixels,this.maxCanvasDim,this.capCanvasAreaFactor));if(pdf_page_view_classPrivateFieldGet(Lw,this)&&this.enableDetailCanvas){const e=this.enableOptimizedPartialRendering?4:2;i.sx/=e;i.sy/=e}}}function pdf_viewer_defineProperty(e,t,i){return(t=function pdf_viewer_toPropertyKey(e){var t=function pdf_viewer_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i;if("undefined"!=typeof Symbol&&void 0!==(i=e[Symbol.toPrimitive])){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_viewer_classPrivateGetter(e,t,i){return i(pdf_viewer_assertClassBrand(e,t))}function pdf_viewer_classPrivateMethodInitSpec(e,t){pdf_viewer_checkPrivateRedeclaration(e,t),t.add(e)}function pdf_viewer_classPrivateFieldInitSpec(e,t,i){pdf_viewer_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_viewer_classPrivateFieldGet(e,t){return e.get(pdf_viewer_assertClassBrand(e,t))}function pdf_viewer_classPrivateFieldSet(e,t,i){return e.set(pdf_viewer_assertClassBrand(e,t),i),i}function pdf_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const $w=1e4,Xw=5e3,Kw=250;function isValidAnnotationEditorMode(e){return Object.values(f).includes(e)&&e!==f.DISABLE}var qw=new WeakMap,Yw=new WeakMap,Zw=new WeakSet;class PDFPageViewBuffer{constructor(e){pdf_viewer_classPrivateMethodInitSpec(this,Zw);pdf_viewer_classPrivateFieldInitSpec(this,qw,new Set);pdf_viewer_classPrivateFieldInitSpec(this,Yw,0);pdf_viewer_classPrivateFieldSet(Yw,this,e)}push(e){const t=pdf_viewer_classPrivateFieldGet(qw,this);t.has(e)&&t.delete(e);t.add(e);t.size>pdf_viewer_classPrivateFieldGet(Yw,this)&&pdf_viewer_assertClassBrand(Zw,this,_destroyFirstView).call(this)}resize(e,t=null){pdf_viewer_classPrivateFieldSet(Yw,this,e);const i=pdf_viewer_classPrivateFieldGet(qw,this);if(t){const e=i.size;let a=1;for(const s of i){if(t.has(s.id)){i.delete(s);i.add(s)}if(++a>e)break}}for(;i.size>pdf_viewer_classPrivateFieldGet(Yw,this);)pdf_viewer_assertClassBrand(Zw,this,_destroyFirstView).call(this)}has(e){return pdf_viewer_classPrivateFieldGet(qw,this).has(e)}[Symbol.iterator](){return pdf_viewer_classPrivateFieldGet(qw,this).keys()}}function _destroyFirstView(){const e=pdf_viewer_classPrivateFieldGet(qw,this).keys().next().value;e?.destroy();pdf_viewer_classPrivateFieldGet(qw,this).delete(e)}var Qw=new WeakMap,Jw=new WeakMap,eF=new WeakMap,tF=new WeakMap,iF=new WeakMap,aF=new WeakMap,sF=new WeakMap,rF=new WeakMap,nF=new WeakMap,oF=new WeakMap,lF=new WeakMap,dF=new WeakMap,cF=new WeakMap,hF=new WeakMap,_F=new WeakMap,uF=new WeakMap,pF=new WeakMap,gF=new WeakMap,mF=new WeakMap,fF=new WeakMap,vF=new WeakMap,PF=new WeakMap,wF=new WeakMap,FF=new WeakMap,yF=new WeakMap,bF=new WeakMap,SF=new WeakMap,CF=new WeakMap,xF=new WeakMap,kF=new WeakMap,EF=new WeakMap,AF=new WeakMap,GF=new WeakMap,BF=new WeakMap,MF=new WeakMap,IF=new WeakMap,TF=new WeakMap,DF=new WeakMap,LF=new WeakMap,RF=new WeakMap,OF=new WeakMap,NF=new WeakMap,WF=new WeakMap,jF=new WeakMap,VF=new WeakMap,UF=new WeakMap,zF=new WeakMap,HF=new WeakMap,$F=new WeakMap,XF=new WeakSet,KF=new WeakMap;class PDFViewer{constructor(e){pdf_viewer_classPrivateMethodInitSpec(this,XF);pdf_viewer_classPrivateFieldInitSpec(this,Qw,null);pdf_viewer_classPrivateFieldInitSpec(this,Jw,null);pdf_viewer_classPrivateFieldInitSpec(this,eF,null);pdf_viewer_classPrivateFieldInitSpec(this,tF,f.NONE);pdf_viewer_classPrivateFieldInitSpec(this,iF,null);pdf_viewer_classPrivateFieldInitSpec(this,aF,p.ENABLE_FORMS);pdf_viewer_classPrivateFieldInitSpec(this,sF,null);pdf_viewer_classPrivateFieldInitSpec(this,rF,null);pdf_viewer_classPrivateFieldInitSpec(this,nF,null);pdf_viewer_classPrivateFieldInitSpec(this,oF,!1);pdf_viewer_classPrivateFieldInitSpec(this,lF,!1);pdf_viewer_classPrivateFieldInitSpec(this,dF,!1);pdf_viewer_classPrivateFieldInitSpec(this,cF,!1);pdf_viewer_classPrivateFieldInitSpec(this,hF,!1);pdf_viewer_classPrivateFieldInitSpec(this,_F,!0);pdf_viewer_classPrivateFieldInitSpec(this,uF,null);pdf_viewer_classPrivateFieldInitSpec(this,pF,null);pdf_viewer_classPrivateFieldInitSpec(this,gF,0);pdf_viewer_classPrivateFieldInitSpec(this,mF,null);pdf_viewer_classPrivateFieldInitSpec(this,fF,[NaN,NaN]);pdf_viewer_classPrivateFieldInitSpec(this,vF,!0);pdf_viewer_classPrivateFieldInitSpec(this,PF,null);pdf_viewer_classPrivateFieldInitSpec(this,wF,!1);pdf_viewer_classPrivateFieldInitSpec(this,FF,null);pdf_viewer_classPrivateFieldInitSpec(this,yF,null);pdf_viewer_classPrivateFieldInitSpec(this,bF,!1);pdf_viewer_classPrivateFieldInitSpec(this,SF,null);pdf_viewer_classPrivateFieldInitSpec(this,CF,0);pdf_viewer_classPrivateFieldInitSpec(this,xF,new ResizeObserver(pdf_viewer_assertClassBrand(XF,this,pdf_viewer_resizeObserverCallback).bind(this)));pdf_viewer_classPrivateFieldInitSpec(this,kF,null);pdf_viewer_classPrivateFieldInitSpec(this,EF,null);pdf_viewer_classPrivateFieldInitSpec(this,AF,!1);pdf_viewer_classPrivateFieldInitSpec(this,GF,null);pdf_viewer_defineProperty(this,"touchPinchScrollLock",!0);pdf_viewer_classPrivateFieldInitSpec(this,BF,null);pdf_viewer_defineProperty(this,"singleScrollDuringPinch",!1);pdf_viewer_classPrivateFieldInitSpec(this,MF,null);pdf_viewer_classPrivateFieldInitSpec(this,IF,null);pdf_viewer_classPrivateFieldInitSpec(this,TF,null);pdf_viewer_classPrivateFieldInitSpec(this,DF,null);pdf_viewer_classPrivateFieldInitSpec(this,LF,!0);pdf_viewer_classPrivateFieldInitSpec(this,RF,z_);pdf_viewer_classPrivateFieldInitSpec(this,OF,void 0);pdf_viewer_classPrivateFieldInitSpec(this,NF,0);pdf_viewer_classPrivateFieldInitSpec(this,WF,"multiple");pdf_viewer_classPrivateFieldInitSpec(this,jF,25);pdf_viewer_classPrivateFieldInitSpec(this,VF,.1);pdf_viewer_classPrivateFieldInitSpec(this,UF,null);pdf_viewer_classPrivateFieldInitSpec(this,zF,null);pdf_viewer_classPrivateFieldInitSpec(this,HF,null);pdf_viewer_classPrivateFieldInitSpec(this,$F,null);pdf_viewer_classPrivateFieldInitSpec(this,KF,!1);0;this.container=e.container;this.viewer=e.viewer||e.container.firstElementChild;pdf_viewer_classPrivateFieldSet(UF,this,e.viewerAlert||null);this.eventBus=e.eventBus;this.pageViewMode=e.pageViewMode||"multiple";this.defaultCacheSize=e.defaultCacheSize;pdf_viewer_classPrivateFieldSet(jF,this,e.maxZoom);pdf_viewer_classPrivateFieldSet(VF,this,e.minZoom);if("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.");pdf_viewer_classPrivateFieldGet(xF,this).observe(this.container);this.linkService=e.linkService||new SimpleLinkService;this.downloadManager=e.downloadManager||null;this.findController=e.findController||null;this.customFindController=e.customFindController||null;pdf_viewer_classPrivateFieldSet(Jw,this,e.altTextManager||null);pdf_viewer_classPrivateFieldSet(sF,this,e.commentManager||null);pdf_viewer_classPrivateFieldSet(DF,this,e.signatureManager||null);pdf_viewer_classPrivateFieldSet(nF,this,e.editorUndoBar||null);this.findController&&(this.findController.onIsPageVisible=e=>this._getVisiblePages().ids.has(e));this._scriptingManager=e.scriptingManager||null;pdf_viewer_classPrivateFieldSet(RF,this,e.textLayerMode??z_);pdf_viewer_classPrivateFieldSet(aF,this,e.annotationMode??p.ENABLE_FORMS);pdf_viewer_classPrivateFieldSet(tF,this,e.annotationEditorMode??f.NONE);pdf_viewer_classPrivateFieldSet(eF,this,e.annotationEditorHighlightColors||null);pdf_viewer_classPrivateFieldSet(oF,this,!0===e.enableHighlightFloatingButton);pdf_viewer_classPrivateFieldSet(cF,this,!0===e.enableUpdatedAddImage);pdf_viewer_classPrivateFieldSet(hF,this,!0===e.enableNewAltTextWhenAddingImage);this.imageResourcesPath=e.imageResourcesPath||"";this.enablePrintAutoRotate=e.enablePrintAutoRotate||!1;this.removePageBorders=e.removePageBorders||!1;this.maxCanvasPixels=e.maxCanvasPixels;this.maxCanvasDim=e.maxCanvasDim;this.capCanvasAreaFactor=e.capCanvasAreaFactor;this.enableDetailCanvas=e.enableDetailCanvas??!0;this.enableOptimizedPartialRendering=e.enableOptimizedPartialRendering??!1;this.enableSelectionRendering=!1!==e.enableSelectionRendering;this.imagesRightClickMinSize=e.imagesRightClickMinSize??-1;this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;pdf_viewer_classPrivateFieldSet(dF,this,e.enablePermissions||!1);this.pageColors=e.pageColors||null;pdf_viewer_classPrivateFieldSet(mF,this,e.mlManager||null);pdf_viewer_classPrivateFieldSet(LF,this,!1!==e.supportsPinchToZoom);pdf_viewer_classPrivateFieldSet(_F,this,!1!==e.enableAutoLinking);pdf_viewer_classPrivateFieldSet(gF,this,e.minDurationToUpdateCanvas??500);this._enableFlipByDrag=!0;this._showPageCorners=!0;this.defaultRenderingQueue=!e.renderingQueue;if(this.defaultRenderingQueue){this.renderingQueue=new PDFRenderingQueue;this.renderingQueue.setViewer(this)}else this.renderingQueue=e.renderingQueue;const{abortSignal:t}=e;pdf_viewer_classPrivateFieldSet(uF,this,t||null);t?.addEventListener("abort",()=>{pdf_viewer_classPrivateFieldGet(xF,this).disconnect();pdf_viewer_classPrivateFieldSet(xF,this,null)},{once:!0});this.scroll=watchScroll(this.container,this._scrollUpdate.bind(this),t);this.presentationModeState=I_;this._resetView();this.removePageBorders&&this.viewer.classList.add("removePageBorders");pdf_viewer_assertClassBrand(XF,this,_updateContainerHeightCss).call(this);this.eventBus.on("thumbnailrendered",({pageNumber:e,pdfPage:t})=>{const i=this._pages[e-1];pdf_viewer_classPrivateFieldGet(Qw,this).has(i)||t?.cleanup()},lu);e.l10n||this.l10n.translate(this.container);this.cspPolicyService=e.cspPolicyService}get maxZoom(){return pdf_viewer_classPrivateFieldGet(jF,this)}set maxZoom(e){pdf_viewer_classPrivateFieldSet(jF,this,e)}get minZoom(){return pdf_viewer_classPrivateFieldGet(VF,this)}set minZoom(e){pdf_viewer_classPrivateFieldSet(VF,this,e)}setTextLayerMode(e){pdf_viewer_classPrivateFieldSet(RF,this,e)}get pageViewMode(){return pdf_viewer_classPrivateFieldGet(WF,this)}set pageViewMode(e){if(pdf_viewer_classPrivateFieldGet(WF,this)!==e){const t=this._currentPageNumber;pdf_viewer_classPrivateFieldSet(WF,this,e);pdf_viewer_classPrivateFieldSet(OF,this,void 0);"infinite-scroll"===e&&pdf_viewer_assertClassBrand(XF,this,_initOuterScrollListener).call(this);this.eventBus.dispatch("pageviewmodechanged",{source:this,pageViewMode:e});if("infinite-scroll"===e&&t>1){pdf_viewer_classPrivateFieldSet(NF,this,Date.now());setTimeout(()=>{pdf_viewer_classPrivateFieldSet(NF,this,Date.now());pdf_viewer_assertClassBrand(XF,this,_scrollIntoView).call(this,this._pages[t-1])},200)}}}get printingAllowed(){return pdf_viewer_classPrivateFieldGet(vF,this)}get pagesCount(){return this._pages.length}getPageView(e){return this._pages[e]}swapPages(e,t){const i=this._pages[e].pdfPage,a=this._pages[t].pdfPage;this._pages[e].setPdfPage(a);this._pages[t].setPdfPage(i);this.refresh()}getCachedPageViews(){return new Set(pdf_viewer_classPrivateFieldGet(Qw,this))}get pageViewsReady(){return this._pages.every(e=>e?.pdfPage)}clearSelection(){const e=document.getSelection();if(e&&!e.isCollapsed)for(let t=0,i=e.rangeCount;t<i;t++)if(e.getRangeAt(t).intersectsNode(this.viewer)){e.removeAllRanges?.();e.empty?.();return}}get renderForms(){return pdf_viewer_classPrivateFieldGet(aF,this)===p.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.");if(!this.pdfDocument)return;const t=this._currentPageNumber!==e,i=t&&Math.abs(this._currentPageNumber-e)<=2;this._currentPageNumber!==e&&this.clearSelection();this._setCurrentPageNumber(e,!0)||ngx_console_NgxConsole.error(`currentPageNumber: "${e}" is not a valid page.`);if(this.pageFlip&&t){i?this.pageFlip.flip(e-1):this.pageFlip.turnToPage(e-1);this.ensureAdjacentPagesAreLoaded()}}hidePagesDependingOnpageViewMode(){"book"===this.pageViewMode&&(this.pageFlip||setTimeout(()=>{if(!this.pageFlip){const e=this._pages[0].div,t=e.parentElement,i=t.parentElement;i.style.overflow="hidden";i.style.marginLeft="auto";i.style.marginRight="auto";this.pageFlip=new PageFlip(t,{width:e.clientWidth,height:e.clientHeight,showCover:!0,size:"fixed",flippingTime:globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches?1:1e3,enableFlipByDrag:this._enableFlipByDrag,showPageCorners:this._showPageCorners,startPage:Math.max(0,this._currentPageNumber-1),rtl:pdf_viewer_assertClassBrand(XF,this,_isBookRightToLeft).call(this)},this.cspPolicyService);pdf_viewer_assertClassBrand(XF,this,_fitBookIntoContainer).call(this,e.clientWidth);this.pageFlip.loadFromHTML(this.container.querySelectorAll(".page"));this.pageFlip.on("flip",e=>{this._currentPageNumber!==e.data+1&&this._setCurrentPageNumber(e.data+1,!1)})}},100))}updateBookReadingDirection(){this.pageFlip?.setRtl(pdf_viewer_assertClassBrand(XF,this,_isBookRightToLeft).call(this))}async _setCurrentPageNumber(e,t=!1){if(this._currentPageNumber===e){t&&pdf_viewer_assertClassBrand(XF,this,_resetCurrentPageView).call(this);return!0}if(!(0<e&&e<=this.pagesCount))return!1;const i=this._currentPageNumber;this._currentPageNumber=e;this.hidePagesDependingOnpageViewMode();if("book"===this.pageViewMode||"infinite-scroll"===this.pageViewMode){const e=this._pages[this.currentPageNumber-1];if(e.div.parentElement.classList.contains("spread"))e.div.parentElement.childNodes.forEach(async e=>{const t=Number(e.getAttribute("data-page-number")),i=this._pages[t-1];await pdf_viewer_assertClassBrand(XF,this,pdf_viewer_ensurePdfPageLoaded).call(this,i);this.renderingQueue.renderView(i);e.style.display="inline-block"});else{await pdf_viewer_assertClassBrand(XF,this,pdf_viewer_ensurePdfPageLoaded).call(this,e);this.renderingQueue.renderView(e);"book"===pdf_viewer_classPrivateFieldGet(WF,this)&&this.ensureAdjacentPagesAreLoaded()}}this.eventBus.dispatch("pagechanging",{source:this,pageNumber:e,pageLabel:this._pageLabels?.[e-1]??null,previous:i});t&&pdf_viewer_assertClassBrand(XF,this,_resetCurrentPageView).call(this);return!0}addPageToRenderQueue(e=0){if(e>=0&&e<=this._pages.length-1){const t=this._pages[e];if(t.renderingState===Xf.INITIAL){pdf_viewer_assertClassBrand(XF,this,pdf_viewer_ensurePdfPageLoaded).call(this,t).then(()=>{this.renderingQueue.renderView(t)});return!0}}return!1}async ensureAdjacentPagesAreLoaded(){const e=[0,1,-1,2,-2,-3];let t=0;this.currentPageNumber%2==1&&(t=-1);let i=!1;for(const a of e){const e=this.currentPageNumber+a+t;if(e>=0&&e<this._pages.length)try{const t=this._pages[e];await pdf_viewer_assertClassBrand(XF,this,pdf_viewer_ensurePdfPageLoaded).call(this,t);if(this._pages.some(e=>e.renderingState===Xf.RUNNING||e.renderingState===Xf.PAUSED)||i){const loader=()=>this.adjacentPagesRenderer(loader,e);this.eventBus._on("pagerendered",loader);this.eventBus._on("thumbnailRendered",loader)}else i=this.adjacentPagesRenderer(null,e)}catch(t){ngx_console_NgxConsole.log("Exception during pre-rendering page %s",e,t)}}}adjacentPagesRenderer(e,t){if(this._pages.find(e=>e.renderingState===Xf.RUNNING))return!0;const i=this._pages.find(e=>e.renderingState===Xf.PAUSED);if(i){this.renderingQueue.renderView(i);return!0}if(e){this.eventBus._off("pagerendered",e);this.eventBus._off("thumbnailRendered",e)}if(t>=0&&t<this._pages.length){const e=this._pages[t];if(e.renderingState===Xf.INITIAL){this.renderingQueue.renderView(e);return!0}}return!1}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._currentPageNumber!==t&&this.clearSelection();this._setCurrentPageNumber(t,!0)||ngx_console_NgxConsole.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&&pdf_viewer_assertClassBrand(XF,this,_setScale).call(this,e,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(e){this.pdfDocument&&pdf_viewer_assertClassBrand(XF,this,_setScale).call(this,e,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!isValidRotation(e))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;(e%=360)<0&&(e+=360);if(this._pagesRotation===e)return;this.clearSelection();pdf_viewer_classPrivateFieldGet(iF,this)?.onRotationWillChange(e);this._pagesRotation=e;const t=this._currentPageNumber;this.refresh(!0,{rotation:e});this._currentScaleValue&&pdf_viewer_assertClassBrand(XF,this,_setScale).call(this,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 shadow(this,"_layerProperties",{get annotationEditorUIManager(){return pdf_viewer_classPrivateFieldGet(iF,e)},get annotationStorage(){return e.pdfDocument?.annotationStorage},get downloadManager(){return e.downloadManager},get enableComment(){return!!pdf_viewer_classPrivateFieldGet(sF,e)},get enableScripting(){return!!e._scriptingManager},get fieldObjectsPromise(){return e.pdfDocument?.getFieldObjects()},get findController(){return e.findController},get customFindController(){return e.customFindController},get hasJSActionsPromise(){return e.pdfDocument?.hasJSActions()},get linkService(){return e.linkService}})}async getAllText(e=null){const t=[],i=[];for(let a=1,s=this.pdfDocument.numPages;a<=s;++a){if(e?.aborted)return null;i.length=0;const s=await this.pdfDocument.getPage(a),{items:r}=await s.getTextContent();for(const e of r){e.str&&i.push(e.str);e.hasEOL&&i.push("\n")}t.push(removeNullCharacters(i.join("")))}return t.join("\n")}setDocument(e){if(this.pdfDocument){this.eventBus.dispatch("pagesdestroy",{source:this});this._cancelRendering();this._resetView();this.findController?.setDocument(null);this.customFindController?.setDocument(null);this._scriptingManager?.setDocument(null);pdf_viewer_classPrivateFieldGet(iF,this)?.destroy();pdf_viewer_classPrivateFieldSet(iF,this,null);pdf_viewer_classPrivateFieldGet(tF,this)!==f.DISABLE&&pdf_viewer_classPrivateFieldSet(tF,this,f.NONE);pdf_viewer_classPrivateFieldSet(vF,this,!0)}this.pdfDocument=e;if(!e)return;const t=e.numPages,i=e.getPage(1),a=e.getOptionalContentConfig({intent:"display"}),s=pdf_viewer_classPrivateFieldGet(dF,this)?e.getPermissions().catch(e=>{console.error("getPermissions",e)}):Promise.resolve(),{eventBus:r,pageColors:n,viewer:o}=this;pdf_viewer_classPrivateFieldSet(pF,this,new AbortController);const{signal:l}=pdf_viewer_classPrivateFieldGet(pF,this),d={signal:l,...lu};if(t>$w){ngx_console_NgxConsole.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const e=this._scrollMode=$_.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&&pdf_viewer_classPrivateFieldGet(Qw,this).push(t)},d);const onAfterDraw=e=>{if(!e.cssTransform&&!e.isDetailView){this._onePageRenderedCapability.resolve({timestamp:e.timestamp});r.off("pagerendered",onAfterDraw)}};r.on("pagerendered",onAfterDraw,d);Promise.all([i,s]).then(([i,s])=>{if(e!==this.pdfDocument)return;this._firstPageCapability.resolve(i);this._optionalContentConfigPromise=a;const{annotationEditorMode:d,annotationMode:c,textLayerMode:h}=pdf_viewer_assertClassBrand(XF,this,_initializePermissions).call(this,s);if(h!==U_){const e=pdf_viewer_classPrivateFieldSet(SF,this,document.createElement("div"));e.id="hiddenCopyElement";e.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none";o.before(e)}if(d!==f.DISABLE){const t=d;if(e.isPureXfa)ngx_console_NgxConsole.warn("Warning: XFA-editing is not implemented.");else if(isValidAnnotationEditorMode(t)){pdf_viewer_classPrivateFieldSet(iF,this,new AnnotationEditorUIManager(this.container,o,pdf_viewer_classPrivateFieldGet(UF,this),pdf_viewer_classPrivateFieldGet(Jw,this),pdf_viewer_classPrivateFieldGet(sF,this),pdf_viewer_classPrivateFieldGet(DF,this),r,e,n,pdf_viewer_classPrivateFieldGet(eF,this),pdf_viewer_classPrivateFieldGet(oF,this),pdf_viewer_classPrivateFieldGet(cF,this),pdf_viewer_classPrivateFieldGet(hF,this),pdf_viewer_classPrivateFieldGet(mF,this),pdf_viewer_classPrivateFieldGet(nF,this),pdf_viewer_classPrivateFieldGet(LF,this),!1));r.dispatch("annotationeditoruimanager",{source:this,uiManager:pdf_viewer_classPrivateFieldGet(iF,this)});if(t!==f.NONE){pdf_viewer_assertClassBrand(XF,this,_preloadEditingData).call(this,t);pdf_viewer_classPrivateFieldGet(iF,this).updateMode(t)}}else ngx_console_NgxConsole.error(`Invalid AnnotationEditor mode: ${t}`)}const _=this._scrollMode===$_.PAGE?null:o,u=this.currentScale,p=i.getViewport({scale:u*PixelsPerInch.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",p.scale);n?.background&&o.style.setProperty("--page-bg-color",n.background);if("CanvasText"===n?.foreground||"Canvas"===n?.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 PDFPageView({container:_,eventBus:r,id:e,scale:u,defaultViewport:p.clone(),optionalContentConfigPromise:a,renderingQueue:this.renderingQueue,textLayerMode:h,annotationMode:c,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,enableSelectionRendering:this.enableSelectionRendering,imagesRightClickMinSize:this.imagesRightClickMinSize,pageColors:n,l10n:this.l10n,layerProperties:this._layerProperties,enableAutoLinking:pdf_viewer_classPrivateFieldGet(_F,this),minDurationToUpdateCanvas:pdf_viewer_classPrivateFieldGet(gF,this),commentManager:pdf_viewer_classPrivateFieldGet(sF,this),abortSignal:pdf_viewer_classPrivateFieldGet(uF,this)});this._pages.push(t)}this._pages[0]?.setPdfPage(i);this._scrollMode===$_.PAGE?pdf_viewer_assertClassBrand(XF,this,_ensurePageViewVisible).call(this):this._spreadMode!==X_.NONE&&this._updateSpreadMode();r.on("annotationeditorlayerrendered",e=>{pdf_viewer_classPrivateFieldGet(iF,this)&&r.dispatch("annotationeditormodechanged",{source:this,mode:pdf_viewer_classPrivateFieldGet(tF,this)})},{once:!0,signal:l,...lu});pdf_viewer_assertClassBrand(XF,this,_onePageRenderedOrForceFetch).call(this,l).then(async()=>{if(e!==this.pdfDocument)return;this.findController?.setDocument(e);this.customFindController?.setDocument(e);this._scriptingManager?.setDocument(e);pdf_viewer_classPrivateFieldGet(SF,this)&&document.addEventListener("copy",pdf_viewer_assertClassBrand(XF,this,_copyCallback).bind(this,h),{signal:l});if(e.loadingParams.disableAutoFetch||t>Xw){this._pagesCapability.resolve();return}let i=t-1;if(i<=0)this._pagesCapability.resolve();else{"book"===pdf_viewer_classPrivateFieldGet(WF,this)&&await this.ensureAdjacentPagesAreLoaded();for(let a=2;a<=t;++a){const t=e.getPage(a).then(e=>{const t=this._pages[a-1];t.pdfPage||t.setPdfPage(e);0===--i&&this._pagesCapability.resolve()},e=>{ngx_console_NgxConsole.error(`Unable to get page ${a} to initialize viewer`,e);0===--i&&this._pagesCapability.resolve()});a%Kw===0&&await t}}});this.hidePagesDependingOnpageViewMode();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=>{ngx_console_NgxConsole.error("Unable to initialize viewer",e);this._pagesCapability.reject(e)})}onPagesEdited({pagesMapper:e,type:t,hasBeenCut:i,pageNumbers:a}){if("copy"===t){pdf_viewer_classPrivateFieldSet(zF,this,new Map);for(const e of a)pdf_viewer_classPrivateFieldGet(zF,this).set(e,this._pages[e-1]);return}if("cancelCopy"===t){pdf_viewer_classPrivateFieldSet(zF,this,null);return}if("cut"===t||"delete"===t){pdf_viewer_classPrivateFieldSet(HF,this,this._pages);pdf_viewer_classPrivateFieldSet($F,this,a)}if("cancelDelete"===t){pdf_viewer_classPrivateFieldSet($F,this,null);if(!pdf_viewer_classPrivateFieldGet(HF,this))return;const e=this._scrollMode===$_.PAGE?null:this.viewer;if(e){pdf_viewer_classPrivateFieldGet(iF,this)?.startUpdatePages();const t=document.createDocumentFragment();for(let e=0,i=pdf_viewer_classPrivateFieldGet(HF,this).length;e<i;e++){const i=pdf_viewer_classPrivateFieldGet(HF,this)[e];i.updatePageNumber(e+1);t.append(i.div)}e.replaceChildren(t);pdf_viewer_classPrivateFieldGet(iF,this)?.endUpdatePages()}this._pages=pdf_viewer_classPrivateFieldGet(HF,this);pdf_viewer_classPrivateFieldSet(HF,this,null);return}if("cleanSavedData"===t){if(pdf_viewer_classPrivateFieldGet($F,this)){if(pdf_viewer_classPrivateFieldGet(HF,this)){for(const e of pdf_viewer_classPrivateFieldGet($F,this))pdf_viewer_classPrivateFieldGet(HF,this)[e-1].deleteMe();pdf_viewer_classPrivateFieldSet(HF,this,null)}pdf_viewer_classPrivateFieldSet($F,this,null)}return}this._currentPageNumber=0;const s=this._pages,r=this._pages=[];pdf_viewer_classPrivateFieldGet(iF,this)?.startUpdatePages();for(let t=1,a=e.pagesNumber;t<=a;t++){const a=e.getPrevPageNumber(t);if(a<0){let e=pdf_viewer_classPrivateFieldGet(zF,this).get(-a);if(i)e.updatePageNumber(t);else{pdf_viewer_classPrivateFieldGet(iF,this)?.clonePage(-a-1,t-1);e=e.clone(t)}r.push(e);continue}const n=s[a-1];r.push(n);n.updatePageNumber(t)}pdf_viewer_classPrivateFieldGet(iF,this)?.endUpdatePages();"paste"===t&&pdf_viewer_classPrivateFieldSet(zF,this,null);const n=this._scrollMode===$_.PAGE?null:this.viewer;if(n){const e=document.createDocumentFragment();for(const{div:t}of r)e.append(t);n.replaceChildren(e)}setTimeout(()=>{this.forceRendering()})}setPageLabels(e){if(this.pdfDocument){if(e)if(Array.isArray(e)&&this.pdfDocument.numPages===e.length)this._pageLabels=e;else{this._pageLabels=null;ngx_console_NgxConsole.error("setPageLabels: Invalid page labels.")}else this._pageLabels=null;for(let e=0,t=this._pages.length;e<t;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){pdf_viewer_classPrivateFieldSet(MF,this,null);pdf_viewer_classPrivateFieldSet(IF,this,null);pdf_viewer_classPrivateFieldSet(TF,this,null);this._pages=[];this._currentPageNumber=1;this._currentScale=0;this._currentScaleValue=null;this._pageLabels=null;const e=this.defaultCacheSize||10;pdf_viewer_classPrivateFieldSet(Qw,this,new PDFPageViewBuffer(e));this._location=null;this._pagesRotation=0;this._optionalContentConfigPromise=null;this._firstPageCapability=Promise.withResolvers();this._onePageRenderedCapability=Promise.withResolvers();this._pagesCapability=Promise.withResolvers();this._scrollMode=$_.VERTICAL;this._previousScrollMode=$_.UNKNOWN;this._spreadMode=X_.NONE;pdf_viewer_classPrivateFieldSet(kF,this,{previousPageNumber:1,scrollDown:!0,pages:[]});pdf_viewer_classPrivateFieldGet(pF,this)?.abort();pdf_viewer_classPrivateFieldSet(pF,this,null);this.viewer.textContent="";this._updateScrollMode();this.viewer.removeAttribute("lang");pdf_viewer_classPrivateFieldGet(SF,this)?.remove();pdf_viewer_classPrivateFieldSet(SF,this,null);pdf_viewer_assertClassBrand(XF,this,_cleanupTimeouts).call(this);pdf_viewer_assertClassBrand(XF,this,_cleanupSwitchAnnotationEditorMode).call(this)}_scrollUpdate(){if(0!==this.pagesCount){pdf_viewer_classPrivateFieldGet(PF,this)&&clearTimeout(pdf_viewer_classPrivateFieldGet(PF,this));pdf_viewer_classPrivateFieldSet(PF,this,setTimeout(()=>{pdf_viewer_classPrivateFieldSet(PF,this,null);this.update()},100));"infinite-scroll"===this.pageViewMode?this.update(!0):this.update()}}scrollPagePosIntoView(e,t){const i=this._pages[e-1].div;if(t){const a={...t};if("string"==typeof a.top&&a.top.endsWith("%")){const e=Number(a.top.replace("%","")),t=this.viewer.querySelector(".page")?.clientHeight;let s=i.clientHeight??t;const r=this.viewer.parentElement.clientHeight;s=Math.max(0,s-r);a.top=e*s/100}if("string"==typeof a.left&&a.left.endsWith("%")){const e=Number(a.left.replace("%","")),t=this.viewer.querySelector(".page")?.clientWidth,s=i.clientWidth??t;a.left=e*s/100}pdf_viewer_assertClassBrand(XF,this,_scrollIntoView).call(this,{div:i,id:e},a)}else pdf_viewer_assertClassBrand(XF,this,_scrollIntoView).call(this,{div:i,id:e})}panBy(e,t){const[i,a]=pdf_viewer_assertClassBrand(XF,this,_scrollBy).call(this,e,t);if(pdf_viewer_classPrivateFieldGet(IF,this)){pdf_viewer_classPrivateFieldGet(IF,this)[0]+=i;pdf_viewer_classPrivateFieldGet(IF,this)[1]+=a}}setTouchPinching(e){if(e&&this.touchPinchScrollLock&&"infinite-scroll"!==this.pageViewMode&&!pdf_viewer_classPrivateFieldGet(GF,this)){const{style:e}=this.container;pdf_viewer_classPrivateFieldSet(GF,this,["overflow","overflow-x","overflow-y"].map(t=>({property:t,value:e.getPropertyValue(t),priority:e.getPropertyPriority(t)})));e.setProperty("overflow","hidden","important")}else if(!e&&pdf_viewer_classPrivateFieldGet(GF,this)){const{style:e}=this.container;for(const{property:t}of pdf_viewer_classPrivateFieldGet(GF,this))e.removeProperty(t);for(const{property:t,value:i,priority:a}of pdf_viewer_classPrivateFieldGet(GF,this))i&&e.setProperty(t,i,a);pdf_viewer_classPrivateFieldSet(GF,this,null)}pdf_viewer_classPrivateFieldSet(AF,this,e);!e&&pdf_viewer_classPrivateFieldGet(BF,this)&&null===pdf_viewer_classPrivateFieldGet(EF,this)&&pdf_viewer_classPrivateFieldSet(EF,this,setTimeout(()=>pdf_viewer_assertClassBrand(XF,this,_finishDeferredScaleUpdate).call(this),0))}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:i=!1,ignoreDestinationZoom:a=!1,center:s=null,onScroll:r=null,preserveCurrentPage:n=!1}){if(!this.pdfDocument)return;const o=Number.isInteger(e)&&this._pages[e-1];if(!o){ngx_console_NgxConsole.error(`scrollPageIntoView: "${e}" is not a valid pageNumber parameter.`);return}if(this.isInPresentationMode||!t){this._setCurrentPageNumber(e,!0);return}let l,d,c=0,h=0,_=0,u=0;const p=o.rotation%180!=0,g=(p?o.height:o.width)/o.scale/PixelsPerInch.PDF_TO_CSS_UNITS,m=(p?o.width:o.height)/o.scale/PixelsPerInch.PDF_TO_CSS_UNITS;let f=0;switch(t[1].name){case"XYZ":c=t[2];h=t[3];f=t[4];c=null!==c?c:0;h=null!==h?h:m;break;case"Fit":case"FitB":f="page-fit";break;case"FitH":case"FitBH":h=t[2];f="page-width";if(null===h&&this._location){c=this._location.left;h=this._location.top}else("number"!=typeof h||h<0)&&(h=m);break;case"FitV":case"FitBV":c=t[2];_=g;u=m;f="page-height";break;case"FitR":c=t[2];h=t[3];_=t[4]-c;u=t[5]-h;let e=40,i=5;this.removePageBorders&&(e=i=0);l=(this.container.clientWidth-e)/_/PixelsPerInch.PDF_TO_CSS_UNITS;d=(this.container.clientHeight-i)/u/PixelsPerInch.PDF_TO_CSS_UNITS;f=Math.min(Math.abs(l),Math.abs(d));break;default:ngx_console_NgxConsole.error(`scrollPageIntoView: "${t[1].name}" is not a valid destination type.`);return}a||(f&&f!==this._currentScale?this.currentScaleValue=f:0===this._currentScale&&(this.currentScaleValue="auto"));n||pdf_viewer_assertClassBrand(XF,this,pdf_viewer_ensurePdfPageLoaded).call(this,o).then(()=>{this.renderingQueue.renderView(o);"single"===this.pageViewMode&&this.currentPageNumber!==e&&(this.currentPageNumber=e)});if("page-fit"===f&&!t[4]){pdf_viewer_assertClassBrand(XF,this,_scrollIntoView).call(this,o,null,r,n);return}const v=[o.viewport.convertToViewportPoint(c,h),o.viewport.convertToViewportPoint(c+_,h+u)];let P=Math.min(v[0][0],v[1][0]),w=Math.min(v[0][1],v[1][1]);if(s){"both"!==s&&"vertical"!==s||(w-=(this.container.clientHeight-Math.abs(v[1][1]-v[0][1]))/2);"both"!==s&&"horizontal"!==s||(P-=(this.container.clientWidth-Math.abs(v[1][0]-v[0][0]))/2)}else if(!i){P=Math.max(P,0);w=Math.max(w,0)}pdf_viewer_assertClassBrand(XF,this,_scrollIntoView).call(this,o,{left:P,top:w},r,n)}_updateLocation(e){pdf_viewer_classPrivateFieldSet(wF,this,!1);const t=this._currentScale,i=this._currentScaleValue,a=parseFloat(i)===t?Math.round(1e4*t)/100:i,s=e.id,r=this._pages[s-1],n=this.container;let o,l;if("infinite-scroll"===this.pageViewMode){const e=n.getBoundingClientRect();pdf_viewer_classPrivateFieldGet(OF,this)||pdf_viewer_classPrivateFieldSet(OF,this,pdf_viewer_assertClassBrand(XF,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(OF,this);if(t){const i=t.getBoundingClientRect();o=i.left-e.left;l=i.top-e.top}else{o=-e.left;l=-e.top}}else{o=n.scrollLeft;l=n.scrollTop}const d=r.getPagePoint(o-e.x,l-e.y),[c,h]=d;let _=`#page=${s}`;this.isInPresentationMode||(_+=`&zoom=${a},${Math.round(c)},${Math.round(h)}`);this._location={pageNumber:s,scale:a,top:h,left:c,rotation:this._pagesRotation,pdfOpenParams:_}}update(e=!1){this.scrollMode===$_.PAGE?this.viewer.classList.add("singlePageView"):this.viewer.classList.remove("singlePageView");const t=this._getVisiblePages(),i=t.views,a=i.length;if(0===a)return;const s=this.defaultCacheSize||10,r=Math.max(s,2*a+1);pdf_viewer_classPrivateFieldGet(Qw,this).resize(r,t.ids);for(const{view:e,visibleArea:t}of i)e.updateVisibleArea(t);for(const e of pdf_viewer_classPrivateFieldGet(Qw,this))t.ids.has(e.id)||e.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===X_.NONE&&(this._scrollMode===$_.PAGE||this._scrollMode===$_.VERTICAL),o=this._currentPageNumber,l=n&&i.some(e=>e.id===o&&(100===e.percent||e.hiddenHeight<=1&&e.hiddenWidth<=1)),d="infinite-scroll"===this.pageViewMode&&Date.now()-pdf_viewer_classPrivateFieldGet(NF,this)<500,c="book"===this.pageViewMode;this.scrollMode===$_.PAGE||e||d||c||this._setCurrentPageNumber(l?this._currentPageNumber:i[0].id);this._updateLocation(t.first);this.eventBus.dispatch("updateviewarea",{source:this,location:this._location});this.hidePagesDependingOnpageViewMode()}async updateBookModeScale(e){if("book"===this.pageViewMode&&this.pageFlip&&e.scale&&e.scale!==e.previousScale){const t=this._pages[0];if(t.pdfPage){const e=t.width,i=t.height,a=t.div.parentElement;a.style.width=`${pdf_viewer_assertClassBrand(XF,this,_bookWidth).call(this,e)}px`;a.style.height=`${i}px`;pdf_viewer_assertClassBrand(XF,this,_fitBookIntoContainer).call(this,e);this.pageFlip.render.setting.width=e;this.pageFlip.render.setting.height=i;this.pageFlip.render.update()}let i=40,a=5;this.removePageBorders&&(i=a=0);const s=(pdf_viewer_classPrivateGetter(XF,this,_get_availableWidth)-i)/t.width*t.scale/2,r=(this.container.clientHeight-a)/t.height*t.scale,n=Math.min(s,r),o=e.scale>n+.01;this._enableFlipByDrag&&(this.pageFlip.setting.enableFlipByDrag=!o);if(pdf_viewer_classPrivateFieldGet(lF,this)!==o){pdf_viewer_classPrivateFieldSet(lF,this,o);this.eventBus.dispatch("bookzoomchanged",{source:this,zoomedIn:o})}}}set enableFlipByDrag(e){this._enableFlipByDrag=e;this.pageFlip&&(this.pageFlip.setting.enableFlipByDrag=e)}get enableFlipByDrag(){return this._enableFlipByDrag}get showPageCorners(){return this._showPageCorners}set showPageCorners(e){this._showPageCorners=e;this.pageFlip&&(this.pageFlip.setting.showPageCorners=e)}containsElement(e){return this.container.contains(e)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===L_}get isChangingPresentationMode(){return this.presentationModeState===D_}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===$_.PAGE?pdf_viewer_classPrivateFieldGet(kF,this).pages:this._pages,t=this._scrollMode===$_.HORIZONTAL,i=t&&this._isContainerRtl;return this._isContainerRtl&&(t||this._scrollMode===$_.WRAPPED)?this._getVisiblePagesRtl(e):"infinite-scroll"===this.pageViewMode?pdf_viewer_assertClassBrand(XF,this,_getVisiblePagesInfiniteScroll).call(this,e):getVisibleElements({scrollEl:this.container,views:e,sortByVisibility:!0,horizontal:t,rtl:i})}_getVisiblePagesRtl(e){const t=this.container.getBoundingClientRect(),i=[],a=new Set;for(const s of e){const e=s.div.getBoundingClientRect(),r=Math.max(e.left,t.left),n=Math.min(e.right,t.right),o=Math.max(e.top,t.top),l=Math.min(e.bottom,t.bottom),d=Math.max(0,n-r),c=Math.max(0,l-o);if(0===d||0===c)continue;const h=d/e.width,_=h*(c/e.height)*100|0;i.push({id:s.id,x:e.left-t.left,y:e.top-t.top,view:s,percent:_,widthPercent:100*h|0});a.add(s.id)}i.sort((e,t)=>t.x-e.x);return{first:i[0],last:i.at(-1),views:i,ids:a}}cleanup(){for(const e of this._pages)e.renderingState!==Xf.FINISHED&&e.reset()}_cancelRendering(){for(const e of this._pages)e.cancelRendering()}forceRendering(e){const t=e||this._getVisiblePages(),i=pdf_viewer_assertClassBrand(XF,this,pdf_viewer_getScrollAhead).call(this,t),a=this._spreadMode!==X_.NONE&&this._scrollMode!==$_.HORIZONTAL,s=null!==pdf_viewer_classPrivateFieldGet(BF,this)||null!==pdf_viewer_classPrivateFieldGet(PF,this)&&t.views.some(e=>e.detailView?.renderingCancelled),r=this.renderingQueue.getHighestPriority(t,this._pages,i,a,s);if(r){pdf_viewer_assertClassBrand(XF,this,pdf_viewer_ensurePdfPageLoaded).call(this,r).then(()=>{this.renderingQueue.renderView(r)});return!0}return!1}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}),a=isPortraitOrientation(i);if(void 0===e)e=a;else if(this.enablePrintAutoRotate&&a!==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(){if(!this.pdfDocument)return Promise.resolve(null);if(!this._optionalContentConfigPromise){ngx_console_NgxConsole.error("optionalContentConfigPromise: Not initialized yet.");return this.pdfDocument.getOptionalContentConfig({intent:"display"})}return this._optionalContentConfigPromise}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${e}`);if(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(!isValidScrollMode(e))throw new Error(`Invalid scroll mode: ${e}`);if(!(this.pagesCount>$w)){this._previousScrollMode=this._scrollMode;this.clearSelection();this._scrollMode=e;this.eventBus.dispatch("scrollmodechanged",{source:this,mode:e});if(e===$_.PAGE&&"infinite-scroll"===pdf_viewer_classPrivateFieldGet(WF,this)){pdf_viewer_classPrivateFieldSet(WF,this,"single");this.hidePagesDependingOnpageViewMode();queueMicrotask(()=>{this.eventBus.dispatch("pageviewmodechanged",{source:this,mode:pdf_viewer_classPrivateFieldGet(WF,this)})})}this._updateScrollMode(this._currentPageNumber)}}}_updateScrollMode(e=null){const t=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",t===$_.HORIZONTAL);i.classList.toggle("scrollWrapped",t===$_.WRAPPED);if(this.pdfDocument&&e){t===$_.PAGE?pdf_viewer_assertClassBrand(XF,this,_ensurePageViewVisible).call(this):this._previousScrollMode===$_.PAGE&&this._updateSpreadMode();this._currentScaleValue&&isNaN(this._currentScaleValue)&&pdf_viewer_assertClassBrand(XF,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});this._setCurrentPageNumber(e,!0);this.update()}}get spreadMode(){return this._spreadMode}set spreadMode(e){if(this._spreadMode!==e){if(!isValidSpreadMode(e))throw new Error(`Invalid spread mode: ${e}`);this.clearSelection();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===$_.PAGE)pdf_viewer_assertClassBrand(XF,this,_ensurePageViewVisible).call(this);else{this.l10n.pause();t.textContent="";if(this._spreadMode===X_.NONE)for(const e of this._pages)t.append(e.div);else{const e=this._spreadMode-1;let a=null;for(let s=0,r=i.length;s<r;++s){if(null===a){a=document.createElement("div");a.className="spread";t.append(a)}else if(s%2===e){a=a.cloneNode(!1);t.append(a)}a.append(i[s].div)}}this.l10n.resume()}this.hidePagesDependingOnpageViewMode();if(e){this._currentScaleValue&&isNaN(this._currentScaleValue)&&pdf_viewer_assertClassBrand(XF,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});this._setCurrentPageNumber(e,!0);this.update()}}nextPage(){const e=this._currentPageNumber,t=this.pagesCount;if(e>=t)return!1;const i=pdf_viewer_assertClassBrand(XF,this,_getPageAdvance).call(this,e,!1)||1;this.currentPageNumber=Math.min(e+i,t);return!0}previousPage(){const e=this._currentPageNumber;if(e<=1)return!1;const t=pdf_viewer_assertClassBrand(XF,this,_getPageAdvance).call(this,e,!0)||1;this.currentPageNumber=Math.max(e-t,1);return!0}updateScale({drawingDelay:e,scaleFactor:t=null,steps:i=null,origin:a,pan:s=null}){if(null===i&&null===t)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let r=this._currentScale;if(t>0&&1!==t)r=Math.round(r*t*1e3)/1e3;else if(i){const e=i>0?1.1:1/1.1,t=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{r=t(10*(r*e).toFixed(2))/10}while(--i>0)}r=MathClamp(r,Number(this.minZoom)??.1,Number(this.maxZoom)??25);pdf_viewer_assertClassBrand(XF,this,_setScale).call(this,r,{noScroll:!1,drawingDelay:e,origin:a,pan:s})}increaseScale(e={}){this.updateScale({...e,steps:e.steps??1})}decreaseScale(e={}){this.updateScale({...e,steps:-(e.steps??1)})}get containerTopLeft(){return pdf_viewer_classPrivateFieldGet(rF,this)||pdf_viewer_classPrivateFieldSet(rF,this,[this.container.offsetTop,this.container.offsetLeft])}get annotationEditorMode(){return pdf_viewer_classPrivateFieldGet(iF,this)?pdf_viewer_classPrivateFieldGet(tF,this):f.DISABLE}set annotationEditorMode({mode:e,editId:t=null,isFromKeyboard:i=!1,mustEnterInEditMode:a=!1,editComment:s=!1}){if(!pdf_viewer_classPrivateFieldGet(iF,this))throw new Error("The AnnotationEditor is not enabled.");if(pdf_viewer_classPrivateFieldGet(tF,this)===e)return;if(!isValidAnnotationEditorMode(e))throw new Error(`Invalid AnnotationEditor mode: ${e}`);if(!this.pdfDocument)return;pdf_viewer_assertClassBrand(XF,this,_preloadEditingData).call(this,e);const{eventBus:r,pdfDocument:n}=this,updater=async()=>{pdf_viewer_assertClassBrand(XF,this,_cleanupSwitchAnnotationEditorMode).call(this);pdf_viewer_classPrivateFieldSet(tF,this,e);await pdf_viewer_classPrivateFieldGet(iF,this).updateMode(e,t,!0,i,a,s);e===pdf_viewer_classPrivateFieldGet(tF,this)&&n===this.pdfDocument&&r.dispatch("annotationeditormodechanged",{source:this,mode:e})};if(e===f.NONE||pdf_viewer_classPrivateFieldGet(tF,this)===f.NONE){const t=e!==f.NONE;t||this.pdfDocument.annotationStorage.resetModifiedIds();this.cleanup();for(const e of this._pages)e.toggleEditingMode(t);const i=pdf_viewer_assertClassBrand(XF,this,_switchToEditAnnotationMode).call(this);if(t&&i){pdf_viewer_assertClassBrand(XF,this,_cleanupSwitchAnnotationEditorMode).call(this);pdf_viewer_classPrivateFieldSet(FF,this,new AbortController);const e=AbortSignal.any([pdf_viewer_classPrivateFieldGet(pF,this).signal,pdf_viewer_classPrivateFieldGet(FF,this).signal]);r.on("pagerendered",({pageNumber:e})=>{i.delete(e);0===i.size&&pdf_viewer_classPrivateFieldSet(yF,this,setTimeout(updater,0))},{signal:e,...lu});return}}updater()}refresh(e=!1,t=Object.create(null)){if(this.pdfDocument){for(const e of this._pages)e.update(t);pdf_viewer_assertClassBrand(XF,this,_cleanupTimeouts).call(this);e||this.update()}}getSerializedAnnotations(){const e=this.pdfDocument.annotationStorage;if(0===e.size)return null;const t=[];for(const[i,a]of e)if(a&&"function"==typeof a.serialize){const e=a.serialize(!0,null,!0);e&&void 0!==a.customId&&null!==a.customId&&(e.customId=a.customId);e&&void 0!==e.annotationType&&t.push(e)}return t.length>0?t:null}async addEditorAnnotation(e){try{"string"==typeof e&&(e=JSON.parse(e))}catch(e){ngx_console_NgxConsole.error(`Please pass a JSON string or an Array of JSON objects to addEditorAnnotation: "${e.message}".`);return}Array.isArray(e)||(e=[e]);const convertArrayLikeObjectToArray=e=>{if(!e||"object"!=typeof e||Array.isArray(e))return e;const t=Object.keys(e);if(t.length>0&&t.every(e=>/^\d+$/.test(e))){const i=[];for(let a=0;a<t.length;a++)i[a]=e[a];return i}return e};let t=!1;e?.forEach(e=>{e.isCopy=!0;if(15!==e.annotationType){const{rect:t}=e;Array.isArray(t)&&4===t.length&&!t.some(e=>!Number.isFinite(e))||ngx_console_NgxConsole.warn(`addEditorAnnotation(): the annotation of type ${e.annotationType} on page ${(e.pageIndex??0)+1} has no usable rect - it is ${JSON.stringify(t)}, but it needs four numbers ([left, bottom, right, top]). Expect it in the wrong place, or nowhere at all. (Drawings don't need a rect - they sit where their points are - but every other annotation does.)`)}if(15===e.annotationType&&e.paths){if(e.paths.lines){const i=e.paths.lines.map(convertArrayLikeObjectToArray);if(i.some((t,i)=>t!==e.paths.lines[i])){t=!0;e.paths.lines=i}}if(e.paths.points){const i=e.paths.points.map(convertArrayLikeObjectToArray);if(i.some((t,i)=>t!==e.paths.points[i])){t=!0;e.paths.points=i}}}});t&&ngx_console_NgxConsole.warn("Detected and converted legacy ink annotation format (object-with-numeric-keys) to arrays. This format was used in ngx-extended-pdf-viewer versions 22.x - 25.5.x. Please re-export or convert your annotations to use the correct format. The objects with numeric keys were always meant to be arrays.");await pdf_viewer_classPrivateFieldGet(iF,this).addSerializedEditor(e,!0,!0,!1,!1)}removeEditorAnnotations(e=()=>!0){pdf_viewer_classPrivateFieldGet(iF,this).removeEditors(e)}destroyBookMode(){if(this.pageFlip){this.pageFlip.destroy();this.pageFlip=null}pdf_viewer_classPrivateFieldSet(lF,this,!1)}stopRendering(){this._cancelRendering()}}function _findAncestorWithScrollbar(e){let t=e?.parentElement;for(;t;){if(t===document.body||t===document.documentElement)return null;const e=getComputedStyle(t).overflowY;if(("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function _initOuterScrollListener(){if(!pdf_viewer_classPrivateFieldGet(KF,this)){pdf_viewer_classPrivateFieldSet(KF,this,!0);document.addEventListener("scroll",e=>{const t=e.target;(t===document||t===document.documentElement||t===document.body||t?.contains?.(this.container))&&this._scrollUpdate()},{capture:!0});window.addEventListener("scroll",()=>this._scrollUpdate())}}function _isBookRightToLeft(){const{classList:e}=this.viewer;return e.contains("readingDirection-rtl")||!e.contains("readingDirection-ltr")&&"rtl"===getComputedStyle(this.viewer).direction}function _setPrintingAllowed(e){pdf_viewer_classPrivateFieldSet(vF,this,e);this.eventBus.dispatch("printingallowed",{source:this,isAllowed:e})}function _initializePermissions(e){const t={annotationEditorMode:pdf_viewer_classPrivateFieldGet(tF,this),annotationMode:pdf_viewer_classPrivateFieldGet(aF,this),textLayerMode:pdf_viewer_classPrivateFieldGet(RF,this)};if(!e){pdf_viewer_assertClassBrand(XF,this,_setPrintingAllowed).call(this,!0);return t}pdf_viewer_assertClassBrand(XF,this,_setPrintingAllowed).call(this,e.has(P.PRINT_HIGH_QUALITY)||e.has(P.PRINT));e.has(P.COPY)||pdf_viewer_classPrivateFieldGet(RF,this)!==z_||(t.textLayerMode=H_);e.has(P.MODIFY_CONTENTS)||(t.annotationEditorMode=f.DISABLE);e.has(P.MODIFY_ANNOTATIONS)||e.has(P.FILL_INTERACTIVE_FORMS)||pdf_viewer_classPrivateFieldGet(aF,this)!==p.ENABLE_FORMS||(t.annotationMode=p.ENABLE);return t}async function _onePageRenderedOrForceFetch(e){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const t=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&t.resolve()},{signal:AbortSignal.any([e,i.signal])});await Promise.race([this._onePageRenderedCapability.promise,t.promise]);i.abort()}function _copyCallback(e,t){const i=document.getSelection(),{focusNode:a,anchorNode:s}=i;if(s&&a&&i.containsNode(pdf_viewer_classPrivateFieldGet(SF,this))){if(pdf_viewer_classPrivateFieldGet(bF,this)||e===H_){stopEvent(t);return}pdf_viewer_classPrivateFieldSet(bF,this,!0);const{classList:i}=this.viewer;i.add("copyAll");const a=new AbortController,s=new AbortController;window.addEventListener("keydown",e=>{"Escape"===e.key&&s.abort()},{signal:a.signal});this.getAllText(s.signal).then(async e=>{null!==e&&await navigator.clipboard.writeText(e)}).catch(e=>{ngx_console_NgxConsole.warn(`Something goes wrong when extracting the text: ${e.message}`)}).finally(()=>{pdf_viewer_classPrivateFieldSet(bF,this,!1);a.abort();i.remove("copyAll")});stopEvent(t)}}function _ensurePageViewVisible(){if(this._scrollMode!==$_.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const e=this._currentPageNumber,t=pdf_viewer_classPrivateFieldGet(kF,this),i=this.viewer;this.l10n.pause();i.textContent="";t.pages.length=0;if(this._spreadMode!==X_.NONE||this.isInPresentationMode){const a=new Set,s=this._spreadMode-1;if(-1===s)a.add(e-1);else if(e%2!==s){a.add(e-1);a.add(e)}else{a.add(e-2);a.add(e-1)}const r=document.createElement("div");r.className="spread";if(this.isInPresentationMode){const e=document.createElement("div");e.className="dummyPage";r.append(e)}for(const e of a){const i=this._pages[e];if(i){r.append(i.div);t.pages.push(i)}}i.append(r)}else{const a=this._pages[e-1];i.append(a.div);t.pages.push(a)}this.l10n.resume();t.scrollDown=e>=t.previousPageNumber;t.previousPageNumber=e}function _scrollIntoView(e,t=null,i=null,a=!1){if(!e)return;"infinite-scroll"===this.pageViewMode&&pdf_viewer_classPrivateFieldSet(NF,this,Date.now());const{div:s,id:r}=e;a||this._currentPageNumber===r||this._setCurrentPageNumber(r);if(this._scrollMode===$_.PAGE){pdf_viewer_assertClassBrand(XF,this,_ensurePageViewVisible).call(this);this.update()}if(!t&&!this.isInPresentationMode){const e=s.offsetLeft+s.clientLeft,i=e+s.clientWidth,{scrollLeft:a,clientWidth:r}=this.container;(this._scrollMode===$_.HORIZONTAL||e<a||i>a+r)&&(t={left:0,top:0})}!this._isContainerRtl||this._scrollMode!==$_.HORIZONTAL&&this._scrollMode!==$_.WRAPPED?scrollIntoView(s,t,!1,"infinite-scroll"===this.pageViewMode,i):s.scrollIntoView({block:"nearest",inline:"end"});!this._currentScaleValue&&this._location&&(this._location=null)}function _isSameScale(e){return e===this._currentScale||Math.abs(e-this._currentScale)<1e-15}function _finishDeferredScaleUpdate(){pdf_viewer_classPrivateFieldSet(EF,this,null);if(pdf_viewer_classPrivateFieldGet(AF,this))return;const e=pdf_viewer_classPrivateFieldGet(BF,this);pdf_viewer_classPrivateFieldSet(BF,this,null);e?.()}function _scrollBy(e,t,i=null){const{container:a}=this,s=pdf_viewer_classPrivateFieldGet(fF,this),{scrollLeft:r,scrollTop:n}=i??a,o=(Math.abs(r-s[0])<1?s[0]:r)-e,l=(Math.abs(n-s[1])<1?s[1]:n)-t;s[0]=o;s[1]=l;a.scrollLeft=o;a.scrollTop=l;pdf_viewer_classPrivateFieldSet(wF,this,!0);const d=a.scrollLeft-o,c=a.scrollTop-l;return[Math.abs(d)<1?e:e-d,Math.abs(c)<1?t:t-c]}function _refreshLocation(){if(!pdf_viewer_classPrivateFieldGet(wF,this))return;const{first:e}=this._getVisiblePages();e&&this._updateLocation(e)}function _setScaleUpdatePages(e,t,{noScroll:i=!1,preset:a=!1,drawingDelay:s=-1,origin:r=null,pan:n=null}){const o=isNaN(Number(this.currentScale))?void 0:Number(this.currentScale),l=this.currentScaleValue;this.clearSelection();this._currentScaleValue=t.toString();if(pdf_viewer_assertClassBrand(XF,this,_isSameScale).call(this,e)){n&&!i&&this.panBy(n[0],n[1]);a&&this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:t,previousScale:o,previousPresetValue:l,noScroll:i});return}const d=s>=0&&s<1e3;i||pdf_viewer_assertClassBrand(XF,this,_refreshLocation).call(this);this.viewer.style.setProperty("--scale-factor",e*PixelsPerInch.PDF_TO_CSS_UNITS);this.refresh(!0,{scale:e,drawingDelay:d?s:-1});if(d){if(!pdf_viewer_classPrivateFieldGet(MF,this)&&this._location){pdf_viewer_classPrivateFieldSet(MF,this,{...this._location});pdf_viewer_classPrivateFieldSet(IF,this,[0,0])}Array.isArray(r)&&pdf_viewer_classPrivateFieldSet(TF,this,[r[0]+(n?.[0]??0),r[1]+(n?.[1]??0)]);null!==pdf_viewer_classPrivateFieldGet(EF,this)&&clearTimeout(pdf_viewer_classPrivateFieldGet(EF,this));pdf_viewer_classPrivateFieldSet(BF,this,()=>{pdf_viewer_classPrivateFieldSet(MF,this,null);pdf_viewer_classPrivateFieldSet(IF,this,null);const e=Math.round(100*this._currentScale)/100,t=pdf_viewer_classPrivateFieldGet(TF,this);pdf_viewer_classPrivateFieldSet(TF,this,null);e===this._currentScale?this.refresh():pdf_viewer_assertClassBrand(XF,this,_setScale).call(this,e,{noScroll:!1,drawingDelay:-1,origin:t})});pdf_viewer_classPrivateFieldSet(EF,this,setTimeout(()=>pdf_viewer_assertClassBrand(XF,this,_finishDeferredScaleUpdate).call(this),s))}this._currentScale=e;if(!i)if("infinite-scroll"===this.pageViewMode){pdf_viewer_classPrivateFieldGet(OF,this)||pdf_viewer_classPrivateFieldSet(OF,this,pdf_viewer_assertClassBrand(XF,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(OF,this),i=e/o;if(t){const e=this.container.getBoundingClientRect();if(Array.isArray(r)){t.scrollTop+=(i-1)*(r[1]-e.top);t.scrollLeft+=(i-1)*(r[0]-e.left)}else{const a=t.getBoundingClientRect();t.scrollTop+=(i-1)*(a.top-e.top);t.scrollLeft+=(i-1)*(a.left-e.left)}}else{const e=this.container.getBoundingClientRect();if(Array.isArray(r)){const t=i-1;window.scrollBy(t*(r[0]-e.left),t*(r[1]-e.top))}else{const t=i-1;window.scrollBy(t*(0-e.left),t*(0-e.top))}}if(n)if(t){t.scrollLeft-=n[0];t.scrollTop-=n[1]}else window.scrollBy(-n[0],-n[1])}else{const t=this.container,i=pdf_viewer_classPrivateFieldGet(MF,this)||this._location;let a,s=this._currentPageNumber;if(i&&!this.isInPresentationMode&&!this.isChangingPresentationMode&&"book"!==this.pageViewMode){s=i.pageNumber;a=[null,{name:"XYZ"},i.left,i.top,null]}let l=null;const c=this.singleScrollDuringPinch&&d&&a&&"multiple"===this.pageViewMode&&this._scrollMode===$_.VERTICAL&&!this._isContainerRtl?(e,i,a)=>{if(e===t)l={scrollLeft:MathClamp(i,0,t.scrollWidth-t.clientWidth),scrollTop:MathClamp(a,0,t.scrollHeight-t.clientHeight)};else{e.scrollLeft=i;e.scrollTop=a}}:null;this.scrollPageIntoView({pageNumber:s,destArray:a,allowNegativeOffset:!0,onScroll:c,preserveCurrentPage:!!a&&"multiple"===this.pageViewMode&&this._scrollMode!==$_.PAGE});const h=i===pdf_viewer_classPrivateFieldGet(MF,this)?pdf_viewer_classPrivateFieldGet(IF,this):null,[_,u]=h??[0,0];let p=_+(n?.[0]??0),g=u+(n?.[1]??0);if((Array.isArray(r)||h)&&o>0){let i=0,a=0;if(Array.isArray(r)){const e=t.getBoundingClientRect();i=r[0]-e.left;a=r[1]-e.top}const s=e/o;p+=i+s*(_-i)-_;g+=a+s*(u-a)-u}if(p||g||l){pdf_viewer_classPrivateFieldGet(fF,this)[0]=pdf_viewer_classPrivateFieldGet(fF,this)[1]=NaN;[p,g]=pdf_viewer_assertClassBrand(XF,this,_scrollBy).call(this,p,g,l)}if(h){h[0]=p;h[1]=g}}this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:a?t:void 0,previousScale:o,previousPresetValue:l,noScroll:i});this.defaultRenderingQueue&&this.update()}function _get_pageWidthScaleFactor(e){return e._spreadMode!==X_.NONE&&e._scrollMode!==$_.HORIZONTAL?2:1}function _setScale(e,t){e||(e="auto");this.maxZoom&&this.maxZoom===this.minZoom&&(e=this.maxZoom);let i=parseFloat(e);if(this._currentScale!==i)if(i>0){t.preset=!1;pdf_viewer_assertClassBrand(XF,this,_setScaleUpdatePages).call(this,i,e,t)}else{const a=this._pages[this._currentPageNumber-1];if(!a)return;let s=40,r=5;if(this.isInPresentationMode){s=r=4;this._spreadMode!==X_.NONE&&(s*=2)}else this.removePageBorders?s=r=0:this._scrollMode===$_.HORIZONTAL&&([s,r]=[r,s]);let n=(pdf_viewer_classPrivateGetter(XF,this,_get_availableWidth)-s)/a.width*a.scale/pdf_viewer_classPrivateGetter(XF,this,_get_pageWidthScaleFactor);"book"===this.pageViewMode&&(n/=2);const o=(this.container.clientHeight-r)/a.height*a.scale;switch(e){case"page-actual":i=1;break;case"page-width":i=n;break;case"page-height":i=o;break;case"page-fit":i=Math.min(n,o);break;case"auto":const t=isPortraitOrientation(a)?n:Math.min(o,n);i=Math.min(1.25,t);break;default:ngx_console_NgxConsole.error(`#setScale: "${e}" is an unknown zoom value.`);return}t.preset=!0;pdf_viewer_assertClassBrand(XF,this,_setScaleUpdatePages).call(this,i,e,t)}else t.pan&&!t.noScroll&&this.panBy(t.pan[0],t.pan[1])}function _resetCurrentPageView(){const e=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&pdf_viewer_assertClassBrand(XF,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});pdf_viewer_assertClassBrand(XF,this,_scrollIntoView).call(this,e)}function _bookWidth(e){return 2*e+(this.removePageBorders?1:40)}function _fitBookIntoContainer(e){const t=pdf_viewer_assertClassBrand(XF,this,_bookWidth).call(this,e),i=Math.min(t,pdf_viewer_classPrivateGetter(XF,this,_get_availableWidth)),{transition:a}=this.container.style;this.container.style.transition="none";this.container.style.width=`${i}px`;this.container.getBoundingClientRect();this.container.style.transition=a;this.viewer.style.minWidth=`${t}px`;this.viewer.style.maxWidth=`${t}px`;this.container.scrollLeft=(t-i)/2}function _get_availableWidth(e){return"book"===e.pageViewMode&&e.container.parentElement?e.container.parentElement.clientWidth:e.container.clientWidth}function _switchToEditAnnotationMode(){const e=this._getVisiblePages(),t=[],{ids:i,views:a}=e;for(const e of a){const{view:a}=e;a.hasEditableAnnotations()?t.push(e):i.delete(a.id)}if(0===t.length)return null;this.renderingQueue.renderHighestPriority({first:t[0],last:t.at(-1),views:t,ids:i});return i}function _getVisiblePagesInfiniteScroll(e){pdf_viewer_classPrivateFieldGet(OF,this)||pdf_viewer_classPrivateFieldSet(OF,this,pdf_viewer_assertClassBrand(XF,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(OF,this);let i;i=t?t.getBoundingClientRect():{top:0,left:0,bottom:window.innerHeight,right:window.innerWidth};const a=[],s=new Set;for(const t of e){const e=t.div,r=e.getBoundingClientRect(),n=Math.max(r.left,i.left),o=Math.min(r.right,i.right),l=Math.max(r.top,i.top),d=Math.min(r.bottom,i.bottom),c=Math.max(0,o-n),h=Math.max(0,d-l);if(0===c||0===h)continue;const _=c/r.width,u=_*(h/r.height)*100|0,p=Math.max(0,i.left-r.left),g=Math.max(0,i.top-r.top),m=Math.min(r.width,i.right-r.left),f=Math.min(r.height,i.bottom-r.top);a.push({id:t.id,x:e.offsetLeft+e.clientLeft,y:e.offsetTop+e.clientTop,visibleArea:100===u?null:{minX:p,minY:g,maxX:m,maxY:f},view:t,percent:u,widthPercent:100*_|0,hiddenHeight:r.height-h,hiddenWidth:r.width-c});s.add(t.id)}a.sort((e,t)=>{const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id});return{first:a[0],last:a.at(-1),views:a,ids:s}}async function pdf_viewer_ensurePdfPageLoaded(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);e.pdfPage||e.setPdfPage(t);return t}catch(e){ngx_console_NgxConsole.error("Unable to get page for page view",e);return null}}function pdf_viewer_getScrollAhead(e){if(1===e.first?.id)return!0;if(e.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case $_.PAGE:return pdf_viewer_classPrivateFieldGet(kF,this).scrollDown;case $_.HORIZONTAL:return this.scroll.right}return this.scroll.down}function _getPageAdvance(e,t=!1){if("book"===this.pageViewMode)return 2;switch(this._scrollMode){case $_.WRAPPED:{const{views:i}=this._getVisiblePages(),a=new Map;for(const{id:e,y:t,percent:s,widthPercent:r}of i)0===s||r<100||a.getOrInsertComputed(t,makeArr).push(e);for(const i of a.values()){const a=i.indexOf(e);if(-1===a)continue;const s=i.length;if(1===s)break;if(t)for(let t=a-1,s=0;t>=s;t--){const a=i[t],s=i[t+1]-1;if(a<s)return e-s}else for(let t=a+1;t<s;t++){const a=i[t],s=i[t-1]+1;if(a>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 $_.HORIZONTAL:break;case $_.PAGE:case $_.VERTICAL:{if(this._spreadMode===X_.NONE)break;const i=this._spreadMode-1;if(t&&e%2!==i)break;if(!t&&e%2===i)break;const{views:a}=this._getVisiblePages(),s=t?e-1:e+1;for(const{id:e,percent:t,widthPercent:i}of a)if(e===s){if(t>0&&100===i)return 2;break}break}}return 1}function _updateContainerHeightCss(e=this.container.clientHeight){if(e!==pdf_viewer_classPrivateFieldGet(CF,this)){pdf_viewer_classPrivateFieldSet(CF,this,e);getDocStyle(this.container).setProperty("--viewer-container-height",`${e}px`)}}function pdf_viewer_resizeObserverCallback(e){for(const t of e)if(t.target===this.container){pdf_viewer_assertClassBrand(XF,this,_updateContainerHeightCss).call(this,Math.floor(t.borderBoxSize[0].blockSize));pdf_viewer_classPrivateFieldSet(rF,this,null);break}}function _cleanupTimeouts(){pdf_viewer_classPrivateFieldSet(BF,this,null);if(null!==pdf_viewer_classPrivateFieldGet(EF,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(EF,this));pdf_viewer_classPrivateFieldSet(EF,this,null)}if(null!==pdf_viewer_classPrivateFieldGet(PF,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(PF,this));pdf_viewer_classPrivateFieldSet(PF,this,null)}}function _cleanupSwitchAnnotationEditorMode(){pdf_viewer_classPrivateFieldGet(FF,this)?.abort();pdf_viewer_classPrivateFieldSet(FF,this,null);if(null!==pdf_viewer_classPrivateFieldGet(yF,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(yF,this));pdf_viewer_classPrivateFieldSet(yF,this,null)}}function _preloadEditingData(e){switch(e){case f.STAMP:pdf_viewer_classPrivateFieldGet(mF,this)?.loadModel("altText");break;case f.SIGNATURE:pdf_viewer_classPrivateFieldGet(DF,this)?.loadSignatures()}}function secondary_toolbar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function secondary_toolbar_classPrivateFieldGet(e,t){return e.get(secondary_toolbar_assertClassBrand(e,t))}function secondary_toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var qF=new WeakMap,YF=new WeakSet;class SecondaryToolbar{constructor(e,t){!function secondary_toolbar_classPrivateMethodInitSpec(e,t){secondary_toolbar_checkPrivateRedeclaration(e,t),t.add(e)}(this,YF);!function secondary_toolbar_classPrivateFieldInitSpec(e,t,i){secondary_toolbar_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,qF,void 0);!function secondary_toolbar_classPrivateFieldSet(e,t,i){return e.set(secondary_toolbar_assertClassBrand(e,t),i),i}(qF,this,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:K_},close:!0},{element:e.cursorHandToolButton,eventName:"switchcursortool",eventDetails:{tool:q_},close:!0},{element:e.scrollPageButton,eventName:"switchscrollmode",eventDetails:{mode:$_.PAGE},close:!0},{element:e.scrollVerticalButton,eventName:"switchscrollmode",eventDetails:{mode:$_.VERTICAL},close:!0},{element:e.scrollHorizontalButton,eventName:"switchscrollmode",eventDetails:{mode:$_.HORIZONTAL},close:!0},{element:e.scrollWrappedButton,eventName:"switchscrollmode",eventDetails:{mode:$_.WRAPPED},close:!0},{element:e.spreadNoneButton,eventName:"switchspreadmode",eventDetails:{mode:X_.NONE},close:!0},{element:e.spreadOddButton,eventName:"switchspreadmode",eventDetails:{mode:X_.ODD},close:!0},{element:e.spreadEvenButton,eventName:"switchspreadmode",eventDetails:{mode:X_.EVEN},close:!0},{element:e.imageAltTextSettingsButton,eventName:"imagealttextsettings",close:!0},{element:e.documentPropertiesButton,eventName:"documentproperties",close:!0}];i.push({element:e.openFileButton,eventName:"openfile",close:!0});this.eventBus=t;this.opened=!1;secondary_toolbar_assertClassBrand(YF,this,secondary_toolbar_bindListeners).call(this,i);this.reset()}get isOpen(){return this.opened}setPageNumber(e){this.pageNumber=e;secondary_toolbar_assertClassBrand(YF,this,secondary_toolbar_updateUIState).call(this)}setPagesCount(e){this.pagesCount=e;secondary_toolbar_assertClassBrand(YF,this,secondary_toolbar_updateUIState).call(this)}reset(){this.pageNumber=0;this.pagesCount=0;secondary_toolbar_assertClassBrand(YF,this,secondary_toolbar_updateUIState).call(this);this.eventBus.dispatch("switchcursortool",{source:this,reset:!0});secondary_toolbar_assertClassBrand(YF,this,_scrollModeChanged).call(this,{mode:$_.VERTICAL});secondary_toolbar_assertClassBrand(YF,this,_spreadModeChanged).call(this,{mode:X_.NONE})}open(){if(this.opened)return;this.eventBus.dispatch("closeopenpopovers",{source:this});this.opened=!0;const{toggleButton:e,toolbar:t}=secondary_toolbar_classPrivateFieldGet(qF,this);toggleExpandedBtn(e,!0,t)}close(){if(!this.opened)return;this.opened=!1;const{toggleButton:e,toolbar:t}=secondary_toolbar_classPrivateFieldGet(qF,this);toggleExpandedBtn(e,!1,t)}toggle(){this.opened?this.close():this.open()}}function secondary_toolbar_updateUIState(){const{firstPageButton:e,lastPageButton:t,pageRotateCwButton:i,pageRotateCcwButton:a}=secondary_toolbar_classPrivateFieldGet(qF,this);e.disabled=this.pageNumber<=1;t.disabled=this.pageNumber>=this.pagesCount;i.disabled=0===this.pagesCount;a.disabled=0===this.pagesCount}function secondary_toolbar_bindListeners(e){const{eventBus:t}=this,{toggleButton:i}=secondary_toolbar_classPrivateFieldGet(qF,this);i.addEventListener("click",this.toggle.bind(this));for(const{element:i,eventName:a,close:s,eventDetails:r}of e)i&&i.addEventListener("click",e=>{null!==a&&t.dispatch(a,{source:this,...r});s&&this.close();t.dispatch("reporttelemetry",{source:this,details:{type:"buttons",data:{id:i.id}}})});t._on("cursortoolchanged",secondary_toolbar_assertClassBrand(YF,this,_cursorToolChanged).bind(this));t._on("scrollmodechanged",secondary_toolbar_assertClassBrand(YF,this,_scrollModeChanged).bind(this));t._on("spreadmodechanged",secondary_toolbar_assertClassBrand(YF,this,_spreadModeChanged).bind(this));t._on("closeopenpopovers",({source:e})=>{e!==this&&this.close()})}function _cursorToolChanged({tool:e,disabled:t}){const{cursorSelectToolButton:i,cursorHandToolButton:a}=secondary_toolbar_classPrivateFieldGet(qF,this);toggleCheckedBtn(i,e===K_);toggleCheckedBtn(a,e===q_);i.disabled=t;a.disabled=t}function _scrollModeChanged({mode:e}){const{scrollPageButton:t,scrollVerticalButton:i,scrollHorizontalButton:a,scrollWrappedButton:s,spreadNoneButton:r,spreadOddButton:n,spreadEvenButton:o}=secondary_toolbar_classPrivateFieldGet(qF,this);toggleCheckedBtn(t,e===$_.PAGE);toggleCheckedBtn(i,e===$_.VERTICAL);toggleCheckedBtn(a,e===$_.HORIZONTAL);toggleCheckedBtn(s,e===$_.WRAPPED);const l=this.pagesCount>$w;t.disabled=l;i.disabled=l;a.disabled=l;s.disabled=l;const d=e===$_.HORIZONTAL;r.disabled=d;n.disabled=d;o.disabled=d}function _spreadModeChanged({mode:e}){const{spreadNoneButton:t,spreadOddButton:i,spreadEvenButton:a}=secondary_toolbar_classPrivateFieldGet(qF,this);toggleCheckedBtn(t,e===X_.NONE);toggleCheckedBtn(i,e===X_.ODD);toggleCheckedBtn(a,e===X_.EVEN)}function signature_manager_classPrivateMethodInitSpec(e,t){signature_manager_checkPrivateRedeclaration(e,t),t.add(e)}function signature_manager_classPrivateFieldInitSpec(e,t,i){signature_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function signature_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function signature_manager_classPrivateFieldGet(e,t){return e.get(signature_manager_assertClassBrand(e,t))}function signature_manager_classPrivateFieldSet(e,t,i){return e.set(signature_manager_assertClassBrand(e,t),i),i}function signature_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ZF=new WeakMap,QF=new WeakMap,JF=new WeakMap,ey=new WeakMap,ty=new WeakMap,iy=new WeakMap,ay=new WeakMap,sy=new WeakMap,ry=new WeakMap,ny=new WeakMap,oy=new WeakMap,ly=new WeakMap,dy=new WeakMap,cy=new WeakMap,hy=new WeakMap,_y=new WeakMap,uy=new WeakMap,py=new WeakMap,gy=new WeakMap,my=new WeakMap,fy=new WeakMap,vy=new WeakMap,Py=new WeakMap,wy=new WeakMap,Fy=new WeakMap,yy=new WeakMap,by=new WeakMap,Sy=new WeakMap,Cy=new WeakMap,xy=new WeakMap,ky=new WeakMap,Ey=new WeakMap,Ay=new WeakMap,Gy=new WeakMap,By=new WeakMap,My=new WeakMap,Iy=new WeakMap,Ty=new WeakMap,Dy=new WeakMap,Ly=new WeakSet;class SignatureManager{constructor({dialog:e,panels:t,typeButton:i,typeInput:a,drawButton:s,drawPlaceholder:r,drawSVG:n,drawThickness:o,imageButton:l,imageSVG:d,imagePlaceholder:c,imagePicker:h,imagePickerLink:_,description:u,clearButton:p,cancelButton:g,addButton:m,errorCloseButton:f,errorBar:v,errorTitle:P,errorDescription:w,saveCheckbox:F,saveContainer:y},b,S,C,x,k,E){signature_manager_classPrivateMethodInitSpec(this,Ly);signature_manager_classPrivateFieldInitSpec(this,ZF,void 0);signature_manager_classPrivateFieldInitSpec(this,QF,null);signature_manager_classPrivateFieldInitSpec(this,JF,void 0);signature_manager_classPrivateFieldInitSpec(this,ey,void 0);signature_manager_classPrivateFieldInitSpec(this,ty,void 0);signature_manager_classPrivateFieldInitSpec(this,iy,void 0);signature_manager_classPrivateFieldInitSpec(this,ay,void 0);signature_manager_classPrivateFieldInitSpec(this,sy,null);signature_manager_classPrivateFieldInitSpec(this,ry,void 0);signature_manager_classPrivateFieldInitSpec(this,ny,null);signature_manager_classPrivateFieldInitSpec(this,oy,"");signature_manager_classPrivateFieldInitSpec(this,ly,null);signature_manager_classPrivateFieldInitSpec(this,dy,void 0);signature_manager_classPrivateFieldInitSpec(this,cy,void 0);signature_manager_classPrivateFieldInitSpec(this,hy,void 0);signature_manager_classPrivateFieldInitSpec(this,_y,void 0);signature_manager_classPrivateFieldInitSpec(this,uy,void 0);signature_manager_classPrivateFieldInitSpec(this,py,null);signature_manager_classPrivateFieldInitSpec(this,gy,null);signature_manager_classPrivateFieldInitSpec(this,my,void 0);signature_manager_classPrivateFieldInitSpec(this,fy,void 0);signature_manager_classPrivateFieldInitSpec(this,vy,void 0);signature_manager_classPrivateFieldInitSpec(this,Py,void 0);signature_manager_classPrivateFieldInitSpec(this,wy,void 0);signature_manager_classPrivateFieldInitSpec(this,Fy,void 0);signature_manager_classPrivateFieldInitSpec(this,yy,void 0);signature_manager_classPrivateFieldInitSpec(this,by,void 0);signature_manager_classPrivateFieldInitSpec(this,Sy,null);signature_manager_classPrivateFieldInitSpec(this,Cy,void 0);signature_manager_classPrivateFieldInitSpec(this,xy,null);signature_manager_classPrivateFieldInitSpec(this,ky,null);signature_manager_classPrivateFieldInitSpec(this,Ey,!1);signature_manager_classPrivateFieldInitSpec(this,Ay,void 0);signature_manager_classPrivateFieldInitSpec(this,Gy,!1);signature_manager_classPrivateFieldInitSpec(this,By,void 0);signature_manager_classPrivateFieldInitSpec(this,My,void 0);signature_manager_classPrivateFieldInitSpec(this,Iy,void 0);signature_manager_classPrivateFieldInitSpec(this,Ty,void 0);signature_manager_classPrivateFieldInitSpec(this,Dy,null);signature_manager_classPrivateFieldSet(ZF,this,m);signature_manager_classPrivateFieldSet(JF,this,p);signature_manager_classPrivateFieldSet(ey,this,u.lastElementChild);signature_manager_classPrivateFieldSet(iy,this,u.firstElementChild);signature_manager_classPrivateFieldSet(ay,this,e);signature_manager_classPrivateFieldSet(dy,this,n);signature_manager_classPrivateFieldSet(ry,this,r);signature_manager_classPrivateFieldSet(cy,this,o);signature_manager_classPrivateFieldSet(hy,this,v);signature_manager_classPrivateFieldSet(uy,this,P);signature_manager_classPrivateFieldSet(_y,this,w);signature_manager_classPrivateFieldSet(Py,this,d);signature_manager_classPrivateFieldSet(vy,this,c);signature_manager_classPrivateFieldSet(my,this,h);signature_manager_classPrivateFieldSet(fy,this,_);signature_manager_classPrivateFieldSet(My,this,C);signature_manager_classPrivateFieldSet(wy,this,F);signature_manager_classPrivateFieldSet(Fy,this,y);signature_manager_classPrivateFieldSet(by,this,S);signature_manager_classPrivateFieldSet(Cy,this,a);signature_manager_classPrivateFieldSet(By,this,x);signature_manager_classPrivateFieldSet(Ty,this,k);signature_manager_classPrivateFieldSet(Ay,this,E);signature_manager_classPrivateFieldSet(Iy,this,new EditDescriptionDialog(b,C));Ry._||(Ry._=Object.freeze({signature:"pdfjs-editor-add-signature-description-default-when-drawing",errorUploadTitle:"pdfjs-editor-add-signature-image-upload-error-title",errorUploadDescription:"pdfjs-editor-add-signature-image-upload-error-description",errorNoDataTitle:"pdfjs-editor-add-signature-image-no-data-error-title",errorNoDataDescription:"pdfjs-editor-add-signature-image-no-data-error-description"}));e.addEventListener("close",signature_manager_assertClassBrand(Ly,this,signature_manager_close).bind(this));e.addEventListener("contextmenu",e=>{const{target:t}=e;t!==signature_manager_classPrivateFieldGet(Cy,this)&&t!==signature_manager_classPrivateFieldGet(iy,this)&&e.preventDefault()});e.addEventListener("drop",e=>{stopEvent(e)});g.addEventListener("click",signature_manager_assertClassBrand(Ly,this,signature_manager_cancel).bind(this));m.addEventListener("click",signature_manager_assertClassBrand(Ly,this,_add).bind(this));p.addEventListener("click",()=>{signature_manager_assertClassBrand(Ly,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.clear",data:{type:signature_manager_classPrivateFieldGet(xy,this)}});signature_manager_assertClassBrand(Ly,this,_initTab).call(this,null)},{passive:!0});signature_manager_classPrivateFieldGet(iy,this).addEventListener("input",()=>{signature_manager_classPrivateFieldGet(ey,this).disabled=""===signature_manager_classPrivateFieldGet(iy,this).value},{passive:!0});signature_manager_classPrivateFieldGet(ey,this).addEventListener("click",()=>{signature_manager_classPrivateFieldGet(iy,this).value="";signature_manager_classPrivateFieldGet(ey,this).disabled=!0},{passive:!0});f.addEventListener("click",()=>{v.hidden=!0},{passive:!0});signature_manager_assertClassBrand(Ly,this,_initTabButtons).call(this,i,s,l,t);h.accept=Y.keys().join(",");E.on("storedsignatureschanged",signature_manager_assertClassBrand(Ly,this,_signaturesChanged).bind(this),lu);C.register(e)}getSignature(e){return this.open(e)}async loadSignatures(e=!1){if(!signature_manager_classPrivateFieldGet(by,this)||!e&&signature_manager_classPrivateFieldGet(by,this).previousElementSibling||!signature_manager_classPrivateFieldGet(Ty,this))return;if(!signature_manager_classPrivateFieldGet(Sy,this)){signature_manager_classPrivateFieldSet(Sy,this,signature_manager_classPrivateFieldGet(Ty,this).getAll().then(async e=>[e,await Promise.all(Array.from(e.values(),({signatureData:e})=>SignatureExtractor.decompressSignature(e)))]));if(!e)return}const[t,i]=await signature_manager_classPrivateFieldGet(Sy,this);signature_manager_classPrivateFieldSet(Sy,this,null);let a=0;for(const[e,{description:s}]of t){const t=i[a++];if(t){t.curves=t.outlines.map(e=>({points:e}));delete t.outlines;signature_manager_assertClassBrand(Ly,this,_addToolbarButton).call(this,t,e,s)}}}async renderEditButton(e){const t=document.createElement("button");t.classList.add("altText","editDescription");t.tabIndex=0;e.description&&(t.title=e.description);const i=document.createElement("span");t.append(i);i.setAttribute("data-l10n-id","pdfjs-editor-add-signature-edit-button-label");t.addEventListener("click",()=>{signature_manager_classPrivateFieldGet(Iy,this).open(e)},{passive:!0});return t}async open({uiManager:e,editor:t}){signature_manager_classPrivateFieldGet(QF,this)||signature_manager_classPrivateFieldSet(QF,this,new Map(signature_manager_classPrivateFieldGet(yy,this).keys().map(e=>[e,{value:"",default:""}])));signature_manager_classPrivateFieldSet(Dy,this,e);signature_manager_classPrivateFieldSet(ty,this,t);signature_manager_classPrivateFieldGet(Dy,this).removeEditListeners();const i=signature_manager_classPrivateFieldSet(Gy,this,await signature_manager_classPrivateFieldGet(Ty,this).isFull());signature_manager_classPrivateFieldGet(Fy,this).classList.toggle("fullStorage",i);signature_manager_classPrivateFieldGet(wy,this).checked=!i;await signature_manager_classPrivateFieldGet(My,this).open(signature_manager_classPrivateFieldGet(ay,this));const a=signature_manager_classPrivateFieldGet(yy,this).get("type");a.focus();a.click()}destroy(){signature_manager_classPrivateFieldSet(Dy,this,null);signature_manager_assertClassBrand(Ly,this,signature_manager_finish).call(this)}}function _initTabButtons(e,t,i,a){const s=signature_manager_classPrivateFieldSet(yy,this,new Map([["type",e],["draw",t],["image",i]])),tabCallback=e=>{for(const[t,i]of s)if(i===e.target){i.setAttribute("aria-selected",!0);i.setAttribute("tabindex",0);a.setAttribute("data-selected",t);signature_manager_assertClassBrand(Ly,this,_initTab).call(this,t)}else{i.setAttribute("aria-selected",!1);i.setAttribute("tabindex",-1)}},r=Array.from(s.values());for(let e=0,t=r.length;e<t;e++){const t=r[e];t.addEventListener("click",tabCallback,{passive:!0});t.addEventListener("keydown",({key:t})=>{"ArrowLeft"!==t&&"ArrowRight"!==t||r[e+("ArrowLeft"===t?-1:1)]?.focus()},{passive:!0})}}function _resetCommon(){signature_manager_classPrivateFieldSet(Ey,this,!1);signature_manager_classPrivateFieldGet(iy,this).value="";signature_manager_classPrivateFieldGet(xy,this)&&(signature_manager_classPrivateFieldGet(QF,this).get(signature_manager_classPrivateFieldGet(xy,this)).value="")}function _resetTab(e){switch(e){case"type":signature_manager_classPrivateFieldGet(Cy,this).value="";break;case"draw":signature_manager_classPrivateFieldSet(sy,this,null);signature_manager_classPrivateFieldSet(ly,this,null);signature_manager_classPrivateFieldSet(oy,this,"");signature_manager_classPrivateFieldGet(ny,this)?.remove();signature_manager_classPrivateFieldSet(ny,this,null);signature_manager_classPrivateFieldGet(ry,this).hidden=!1;signature_manager_classPrivateFieldGet(cy,this).value=1;break;case"image":signature_manager_classPrivateFieldGet(vy,this).hidden=!1;signature_manager_classPrivateFieldGet(gy,this)?.remove();signature_manager_classPrivateFieldSet(gy,this,null)}}function _initTab(e){if(e&&signature_manager_classPrivateFieldGet(xy,this)===e)return;signature_manager_classPrivateFieldGet(xy,this)&&(signature_manager_classPrivateFieldGet(QF,this).get(signature_manager_classPrivateFieldGet(xy,this)).value=signature_manager_classPrivateFieldGet(iy,this).value);e&&signature_manager_classPrivateFieldSet(xy,this,e);signature_manager_classPrivateFieldGet(hy,this).hidden=!0;const t=!e;t?signature_manager_assertClassBrand(Ly,this,_resetCommon).call(this):signature_manager_classPrivateFieldGet(iy,this).value=signature_manager_classPrivateFieldGet(QF,this).get(signature_manager_classPrivateFieldGet(xy,this)).value;signature_manager_classPrivateFieldGet(ey,this).disabled=""===signature_manager_classPrivateFieldGet(iy,this).value;signature_manager_classPrivateFieldGet(ky,this)?.abort();signature_manager_classPrivateFieldSet(ky,this,new AbortController);switch(signature_manager_classPrivateFieldGet(xy,this)){case"type":signature_manager_assertClassBrand(Ly,this,_initTypeTab).call(this,t);break;case"draw":signature_manager_assertClassBrand(Ly,this,_initDrawTab).call(this,t);break;case"image":signature_manager_assertClassBrand(Ly,this,_initImageTab).call(this,t)}}function _disableButtons(e){e&&signature_manager_classPrivateFieldGet(Gy,this)||(signature_manager_classPrivateFieldGet(wy,this).disabled=!e);signature_manager_classPrivateFieldGet(JF,this).disabled=signature_manager_classPrivateFieldGet(ZF,this).disabled=signature_manager_classPrivateFieldGet(iy,this).disabled=!e}function _initTypeTab(e){e&&signature_manager_assertClassBrand(Ly,this,_resetTab).call(this,"type");signature_manager_assertClassBrand(Ly,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(Cy,this).value);const{signal:t}=signature_manager_classPrivateFieldGet(ky,this),i={passive:!0,signal:t};signature_manager_classPrivateFieldGet(Cy,this).addEventListener("input",()=>{const{value:e}=signature_manager_classPrivateFieldGet(Cy,this);if(!signature_manager_classPrivateFieldGet(Ey,this)){signature_manager_classPrivateFieldGet(QF,this).get("type").default=signature_manager_classPrivateFieldGet(iy,this).value=e;signature_manager_classPrivateFieldGet(ey,this).disabled=""===e}signature_manager_assertClassBrand(Ly,this,_disableButtons).call(this,e)},i);signature_manager_classPrivateFieldGet(iy,this).addEventListener("input",()=>{signature_manager_classPrivateFieldSet(Ey,this,signature_manager_classPrivateFieldGet(Cy,this).value!==signature_manager_classPrivateFieldGet(iy,this).value)},i)}function _initDrawTab(e){e&&signature_manager_assertClassBrand(Ly,this,_resetTab).call(this,"draw");signature_manager_assertClassBrand(Ly,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(ny,this));const{signal:t}=signature_manager_classPrivateFieldGet(ky,this),i={signal:t};let a=NaN;const drawCallback=e=>{const{pointerId:s}=e;if(!isNaN(a)&&a!==s)return;a=s;e.preventDefault();signature_manager_classPrivateFieldGet(dy,this).setPointerCapture(s);const{width:r,height:n}=signature_manager_classPrivateFieldGet(dy,this).getBoundingClientRect();let{offsetX:o,offsetY:l}=e;o=Math.round(o);l=Math.round(l);e.target===signature_manager_classPrivateFieldGet(ry,this)&&(signature_manager_classPrivateFieldGet(ry,this).hidden=!0);if(!signature_manager_classPrivateFieldGet(sy,this)){signature_manager_classPrivateFieldSet(sy,this,{width:r,height:n,thickness:parseInt(signature_manager_classPrivateFieldGet(cy,this).value,10),curves:[]});signature_manager_assertClassBrand(Ly,this,_disableButtons).call(this,!0);const e=new DOMSVGFactory,t=signature_manager_classPrivateFieldSet(ny,this,e.createElement("path"));t.setAttribute("stroke-width",signature_manager_classPrivateFieldGet(cy,this).value);signature_manager_classPrivateFieldGet(dy,this).append(t);signature_manager_classPrivateFieldGet(dy,this).addEventListener("pointerdown",drawCallback,i);signature_manager_classPrivateFieldGet(ry,this).removeEventListener("pointerdown",drawCallback);""===signature_manager_classPrivateFieldGet(iy,this).value&&signature_manager_classPrivateFieldGet(By,this).get(Ry._.signature).then(e=>{signature_manager_classPrivateFieldGet(QF,this).get("draw").default=e;signature_manager_classPrivateFieldGet(iy,this).value||=e;signature_manager_classPrivateFieldGet(ey,this).disabled=""===signature_manager_classPrivateFieldGet(iy,this).value})}signature_manager_classPrivateFieldSet(ly,this,[o,l]);signature_manager_classPrivateFieldGet(sy,this).curves.push({points:signature_manager_classPrivateFieldGet(ly,this)});signature_manager_classPrivateFieldSet(oy,this,signature_manager_classPrivateFieldGet(oy,this)+`M ${o} ${l}`);signature_manager_classPrivateFieldGet(ny,this).setAttribute("d",signature_manager_classPrivateFieldGet(oy,this));const d=new AbortController,c={signal:AbortSignal.any([t,d.signal])};signature_manager_classPrivateFieldGet(dy,this).addEventListener("contextmenu",noContextMenu,c);signature_manager_classPrivateFieldGet(dy,this).addEventListener("pointermove",e=>{e.preventDefault();let{offsetX:t,offsetY:i}=e;t=Math.round(t);i=Math.round(i);const a=signature_manager_classPrivateFieldGet(ly,this);if(!(t<0||i<0||t>r||i>n||t===a.at(-2)&&i===a.at(-1))){if(a.length>=4){const[e,s,r,n]=a.slice(-4);signature_manager_classPrivateFieldSet(oy,this,signature_manager_classPrivateFieldGet(oy,this)+`C${(e+5*r)/6} ${(s+5*n)/6} ${(5*r+t)/6} ${(5*n+i)/6} ${(r+t)/2} ${(n+i)/2}`)}else signature_manager_classPrivateFieldSet(oy,this,signature_manager_classPrivateFieldGet(oy,this)+`L${t} ${i}`);a.push(t,i);signature_manager_classPrivateFieldGet(ny,this).setAttribute("d",signature_manager_classPrivateFieldGet(oy,this))}},c);signature_manager_classPrivateFieldGet(dy,this).addEventListener("pointerup",e=>{const{pointerId:t}=e;if(isNaN(a)||a===t){a=NaN;e.preventDefault();signature_manager_classPrivateFieldGet(dy,this).releasePointerCapture(t);d.abort();if(2===signature_manager_classPrivateFieldGet(ly,this).length){signature_manager_classPrivateFieldSet(oy,this,signature_manager_classPrivateFieldGet(oy,this)+`L${signature_manager_classPrivateFieldGet(ly,this)[0]} ${signature_manager_classPrivateFieldGet(ly,this)[1]}`);signature_manager_classPrivateFieldGet(ny,this).setAttribute("d",signature_manager_classPrivateFieldGet(oy,this))}}},c)};signature_manager_classPrivateFieldGet(sy,this)?signature_manager_classPrivateFieldGet(dy,this).addEventListener("pointerdown",drawCallback,i):signature_manager_classPrivateFieldGet(ry,this).addEventListener("pointerdown",drawCallback,i);signature_manager_classPrivateFieldGet(cy,this).addEventListener("input",()=>{const{value:e}=signature_manager_classPrivateFieldGet(cy,this);signature_manager_classPrivateFieldGet(cy,this).setAttribute("data-l10n-args",JSON.stringify({thickness:e}));if(signature_manager_classPrivateFieldGet(sy,this)){signature_manager_classPrivateFieldGet(ny,this).setAttribute("stroke-width",e);signature_manager_classPrivateFieldGet(sy,this).thickness=e}},i)}function _showError(e){signature_manager_classPrivateFieldGet(uy,this).setAttribute("data-l10n-id",Ry._[`error${e}Title`]);signature_manager_classPrivateFieldGet(_y,this).setAttribute("data-l10n-id",Ry._[`error${e}Description`]);signature_manager_classPrivateFieldGet(hy,this).hidden=!1}function _initImageTab(e){e&&signature_manager_assertClassBrand(Ly,this,_resetTab).call(this,"image");signature_manager_assertClassBrand(Ly,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(gy,this));const{signal:t}=signature_manager_classPrivateFieldGet(ky,this),i={signal:t},a={passive:!0,signal:t};signature_manager_classPrivateFieldGet(fy,this).addEventListener("keydown",e=>{const{key:t}=e;if("Enter"===t||" "===t){stopEvent(e);signature_manager_classPrivateFieldGet(my,this).click()}},i);signature_manager_classPrivateFieldGet(my,this).addEventListener("click",()=>{signature_manager_classPrivateFieldGet(ay,this).classList.toggle("waiting",!0)},a);signature_manager_classPrivateFieldGet(my,this).addEventListener("change",async()=>{const e=signature_manager_classPrivateFieldGet(my,this).files?.[0];if(e&&Y.has(e.type))await signature_manager_assertClassBrand(Ly,this,_extractSignature).call(this,e);else{signature_manager_assertClassBrand(Ly,this,_showError).call(this,"Upload");signature_manager_classPrivateFieldGet(ay,this).classList.toggle("waiting",!1)}},a);signature_manager_classPrivateFieldGet(my,this).addEventListener("cancel",()=>{signature_manager_classPrivateFieldGet(ay,this).classList.toggle("waiting",!1)},a);signature_manager_classPrivateFieldGet(vy,this).addEventListener("dragover",e=>{const{dataTransfer:t}=e;for(const{type:i}of t.items)if(Y.has(i)){t.dropEffect="copy"===t.effectAllowed?"copy":"move";stopEvent(e);return}t.dropEffect="none"},i);signature_manager_classPrivateFieldGet(vy,this).addEventListener("drop",e=>{const{dataTransfer:{files:t}}=e;if(t?.length){for(const e of t)if(Y.has(e.type)){signature_manager_assertClassBrand(Ly,this,_extractSignature).call(this,e);break}stopEvent(e);signature_manager_classPrivateFieldGet(ay,this).classList.toggle("waiting",!0)}},i)}async function _extractSignature(e){let t;try{t=await signature_manager_classPrivateFieldGet(Dy,this).imageManager.getFromFile(e)}catch(e){ngx_console_NgxConsole.error("SignatureManager.#extractSignature.",e)}if(!t){signature_manager_assertClassBrand(Ly,this,_showError).call(this,"Upload");signature_manager_classPrivateFieldGet(ay,this).classList.toggle("waiting",!1);return}const i=signature_manager_classPrivateFieldSet(py,this,signature_manager_classPrivateFieldGet(ty,this).getFromImage(t.bitmap));if(!i){signature_manager_assertClassBrand(Ly,this,_showError).call(this,"NoData");signature_manager_classPrivateFieldGet(ay,this).classList.toggle("waiting",!1);return}const{outline:a}=i;signature_manager_classPrivateFieldGet(vy,this).hidden=!0;signature_manager_assertClassBrand(Ly,this,_disableButtons).call(this,!0);const s=new DOMSVGFactory,r=signature_manager_classPrivateFieldSet(gy,this,s.createElement("path"));signature_manager_classPrivateFieldGet(Py,this).setAttribute("viewBox",a.viewBox);signature_manager_classPrivateFieldGet(Py,this).setAttribute("preserveAspectRatio","xMidYMid meet");signature_manager_classPrivateFieldGet(Py,this).append(r);r.setAttribute("d",a.toSVGPath());signature_manager_classPrivateFieldGet(QF,this).get("image").default=e.name;if(""===signature_manager_classPrivateFieldGet(iy,this).value){signature_manager_classPrivateFieldGet(iy,this).value=e.name||"";signature_manager_classPrivateFieldGet(ey,this).disabled=""===signature_manager_classPrivateFieldGet(iy,this).value}signature_manager_classPrivateFieldGet(ay,this).classList.toggle("waiting",!1)}function _getOutlineForType(){return signature_manager_classPrivateFieldGet(ty,this).getFromText(signature_manager_classPrivateFieldGet(Cy,this).value,window.getComputedStyle(signature_manager_classPrivateFieldGet(Cy,this)))}function _getOutlineForDraw(){const{width:e,height:t}=signature_manager_classPrivateFieldGet(dy,this).getBoundingClientRect();return signature_manager_classPrivateFieldGet(ty,this).getDrawnSignature(signature_manager_classPrivateFieldGet(sy,this),e,t)}function signature_manager_reportTelemetry(e){signature_manager_classPrivateFieldGet(Ay,this).dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}function _addToolbarButton(e,t,i){const{curves:a,areContours:s,thickness:r,width:n,height:o}=e,l=Math.max(n,o),d=SignatureExtractor.processDrawnLines({lines:{curves:a,thickness:r,width:n,height:o},pageWidth:l,pageHeight:l,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});if(!d)return;const{outline:c}=d,h=new DOMSVGFactory,_=document.createElement("div"),u=document.createElement("button");u.addEventListener("click",()=>{signature_manager_classPrivateFieldGet(Ay,this).dispatch("switchannotationeditorparams",{source:this,type:v.CREATE,value:{signatureData:{lines:{curves:a,thickness:r,width:n,height:o},mustSmooth:!1,areContours:s,description:i,uuid:t,heightInPage:40}}})});_.append(u);_.classList.add("toolbarAddSignatureButtonContainer");const p=h.create(1,1,!0);u.append(p);const g=document.createElement("span");g.ariaHidden=!0;u.append(g);u.classList.add("toolbarAddSignatureButton");u.type="button";g.textContent=i;u.setAttribute("data-l10n-id","pdfjs-editor-add-saved-signature-button");u.setAttribute("data-l10n-args",JSON.stringify({description:i}));u.tabIndex=0;const m=h.createElement("path");p.append(m);p.setAttribute("viewBox",c.viewBox);p.setAttribute("preserveAspectRatio","xMidYMid meet");s&&m.classList.add("contours");m.setAttribute("d",c.toSVGPath());const f=document.createElement("button");_.append(f);f.classList.add("toolbarButton","deleteButton");f.setAttribute("data-l10n-id","pdfjs-editor-delete-signature-button1");f.type="button";f.tabIndex=0;f.addEventListener("click",async()=>{if(await signature_manager_classPrivateFieldGet(Ty,this).delete(t)){_.remove();signature_manager_assertClassBrand(Ly,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.delete_saved",data:{savedCount:await signature_manager_classPrivateFieldGet(Ty,this).size()}})}});const P=document.createElement("span");f.append(P);P.setAttribute("data-l10n-id","pdfjs-editor-delete-signature-button-label1");signature_manager_classPrivateFieldGet(by,this).before(_)}async function _signaturesChanged(){const e=signature_manager_classPrivateFieldGet(by,this).parentElement;for(;e.firstElementChild!==signature_manager_classPrivateFieldGet(by,this);)e.firstElementChild.remove();signature_manager_classPrivateFieldSet(Sy,this,null);await this.loadSignatures(!0)}function signature_manager_cancel(){signature_manager_assertClassBrand(Ly,this,signature_manager_finish).call(this)}function signature_manager_finish(){signature_manager_classPrivateFieldGet(My,this).closeIfActive(signature_manager_classPrivateFieldGet(ay,this))}function signature_manager_close(){null===signature_manager_classPrivateFieldGet(ty,this)._drawId&&signature_manager_classPrivateFieldGet(ty,this).remove();signature_manager_classPrivateFieldGet(Dy,this)?.addEditListeners();signature_manager_classPrivateFieldGet(ky,this)?.abort();signature_manager_classPrivateFieldSet(ky,this,null);signature_manager_classPrivateFieldSet(Dy,this,null);signature_manager_classPrivateFieldSet(ty,this,null);signature_manager_assertClassBrand(Ly,this,_resetCommon).call(this);for(const[e]of signature_manager_classPrivateFieldGet(yy,this))signature_manager_assertClassBrand(Ly,this,_resetTab).call(this,e);signature_manager_assertClassBrand(Ly,this,_disableButtons).call(this,!1);signature_manager_classPrivateFieldSet(xy,this,null);signature_manager_classPrivateFieldSet(QF,this,null)}async function _add(){let e;const t=signature_manager_classPrivateFieldGet(xy,this);switch(t){case"type":e=signature_manager_assertClassBrand(Ly,this,_getOutlineForType).call(this);break;case"draw":e=signature_manager_assertClassBrand(Ly,this,_getOutlineForDraw).call(this);break;case"image":e=signature_manager_classPrivateFieldGet(py,this)}let i=null;const a=signature_manager_classPrivateFieldGet(iy,this).value;if(signature_manager_classPrivateFieldGet(wy,this).checked){const{newCurves:t,areContours:s,thickness:r,width:n,height:o}=e,l=await SignatureExtractor.compressSignature({outlines:t,areContours:s,thickness:r,width:n,height:o});i=await signature_manager_classPrivateFieldGet(Ty,this).create({description:a,signatureData:l});i?signature_manager_assertClassBrand(Ly,this,_addToolbarButton).call(this,{curves:t.map(e=>({points:e})),areContours:s,thickness:r,width:n,height:o},i,a):ngx_console_NgxConsole.warn("SignatureManager.add: cannot save the signature.")}const s=signature_manager_classPrivateFieldGet(QF,this).get(t);signature_manager_assertClassBrand(Ly,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.created",data:{type:t,saved:!!i,savedCount:await signature_manager_classPrivateFieldGet(Ty,this).size(),descriptionChanged:a!==s.default}});signature_manager_classPrivateFieldGet(ty,this).addSignature(e,40,signature_manager_classPrivateFieldGet(iy,this).value,i);signature_manager_assertClassBrand(Ly,this,signature_manager_finish).call(this)}var Ry={_:null},Oy=new WeakMap,Ny=new WeakMap,Wy=new WeakMap,jy=new WeakMap,Vy=new WeakMap,Uy=new WeakMap,zy=new WeakMap,Hy=new WeakSet;class EditDescriptionDialog{constructor({dialog:e,description:t,cancelButton:i,updateButton:a,editSignatureView:s},r){signature_manager_classPrivateMethodInitSpec(this,Hy);signature_manager_classPrivateFieldInitSpec(this,Oy,void 0);signature_manager_classPrivateFieldInitSpec(this,Ny,void 0);signature_manager_classPrivateFieldInitSpec(this,Wy,void 0);signature_manager_classPrivateFieldInitSpec(this,jy,void 0);signature_manager_classPrivateFieldInitSpec(this,Vy,void 0);signature_manager_classPrivateFieldInitSpec(this,Uy,void 0);signature_manager_classPrivateFieldInitSpec(this,zy,void 0);const n=signature_manager_classPrivateFieldSet(Wy,this,t.firstElementChild);signature_manager_classPrivateFieldSet(Uy,this,s);signature_manager_classPrivateFieldSet(jy,this,e);signature_manager_classPrivateFieldSet(Vy,this,r);e.addEventListener("close",signature_manager_assertClassBrand(Hy,this,_close2).bind(this));e.addEventListener("contextmenu",e=>{e.target!==signature_manager_classPrivateFieldGet(Wy,this)&&e.preventDefault()});i.addEventListener("click",signature_manager_assertClassBrand(Hy,this,_cancel2).bind(this));a.addEventListener("click",signature_manager_assertClassBrand(Hy,this,_update).bind(this));const o=t.lastElementChild;o.addEventListener("click",()=>{n.value="";o.disabled=!0;a.disabled=""===signature_manager_classPrivateFieldGet(Ny,this)});n.addEventListener("input",()=>{const{value:e}=n;o.disabled=""===e;a.disabled=e===signature_manager_classPrivateFieldGet(Ny,this);s.setAttribute("aria-label",e)},{passive:!0});r.register(e)}async open(e){signature_manager_classPrivateFieldSet(zy,this,e._uiManager);signature_manager_classPrivateFieldSet(Oy,this,e);signature_manager_classPrivateFieldSet(Ny,this,signature_manager_classPrivateFieldGet(Wy,this).value=e.description);signature_manager_classPrivateFieldGet(Wy,this).dispatchEvent(new Event("input"));signature_manager_classPrivateFieldGet(zy,this).removeEditListeners();const{areContours:t,outline:i}=e.getSignaturePreview(),a=(new DOMSVGFactory).createElement("path");signature_manager_classPrivateFieldGet(Uy,this).append(a);signature_manager_classPrivateFieldGet(Uy,this).setAttribute("viewBox",i.viewBox);a.setAttribute("d",i.toSVGPath());t&&a.classList.add("contours");await signature_manager_classPrivateFieldGet(Vy,this).open(signature_manager_classPrivateFieldGet(jy,this))}}async function _update(){signature_manager_classPrivateFieldGet(Oy,this)._reportTelemetry({action:"pdfjs.signature.edit_description",data:{hasBeenChanged:!0}});signature_manager_classPrivateFieldGet(Oy,this).description=signature_manager_classPrivateFieldGet(Wy,this).value;signature_manager_assertClassBrand(Hy,this,signature_manager_finish2).call(this)}function _cancel2(){signature_manager_classPrivateFieldGet(Oy,this)._reportTelemetry({action:"pdfjs.signature.edit_description",data:{hasBeenChanged:!1}});signature_manager_assertClassBrand(Hy,this,signature_manager_finish2).call(this)}function signature_manager_finish2(){signature_manager_classPrivateFieldGet(Vy,this).closeIfActive(signature_manager_classPrivateFieldGet(jy,this))}function _close2(){signature_manager_classPrivateFieldGet(zy,this)?.addEditListeners();signature_manager_classPrivateFieldSet(zy,this,null);signature_manager_classPrivateFieldSet(Oy,this,null);signature_manager_classPrivateFieldGet(Uy,this).firstElementChild.remove()}function digital_signature_properties_manager_classPrivateFieldInitSpec(e,t,i){digital_signature_properties_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function digital_signature_properties_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function digital_signature_properties_manager_classPrivateGetter(e,t,i){return i(digital_signature_properties_manager_assertClassBrand(e,t))}function digital_signature_properties_manager_classPrivateFieldGet(e,t){return e.get(digital_signature_properties_manager_assertClassBrand(e,t))}function digital_signature_properties_manager_classPrivateFieldSet(e,t,i){return e.set(digital_signature_properties_manager_assertClassBrand(e,t),i),i}function digital_signature_properties_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const $y="pdfjs-digital-signature-properties-status-verified",Xy={verified:{priority:0,severity:"verified",bannerId:"pdfjs-digital-signature-properties-banner-verified",statusId:$y},unknown:{priority:1,severity:"error",bannerId:"pdfjs-digital-signature-properties-banner-unknown",statusId:"pdfjs-digital-signature-properties-status-unknown"},untrusted:{priority:2,severity:"warn",bannerId:"pdfjs-digital-signature-properties-banner-untrusted",statusId:$y},expired:{priority:3,severity:"warn",bannerId:"pdfjs-digital-signature-properties-banner-expired",statusId:$y},revoked:{priority:4,severity:"error",bannerId:"pdfjs-digital-signature-properties-banner-revoked",statusId:$y},invalid:{priority:5,severity:"error",bannerId:"pdfjs-digital-signature-properties-banner-invalid",statusId:"pdfjs-digital-signature-properties-status-invalid"}},Ky={trusted:"pdfjs-digital-signature-properties-certificate-trusted",unknown:"pdfjs-digital-signature-properties-certificate-unknown",untrusted:"pdfjs-digital-signature-properties-certificate-untrusted",expired:"pdfjs-digital-signature-properties-certificate-expired",revoked:"pdfjs-digital-signature-properties-certificate-revoked"};var qy=new WeakMap,Yy=new WeakMap,Zy=new WeakMap,Qy=new WeakMap,Jy=new WeakMap,eb=new WeakMap,tb=new WeakMap,ib=new WeakMap,ab=new WeakMap,sb=new WeakMap,rb=new WeakSet;class SignaturePropertiesManager{constructor({appConfig:e,verifier:t,eventBus:i}){!function digital_signature_properties_manager_classPrivateMethodInitSpec(e,t){digital_signature_properties_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,rb);digital_signature_properties_manager_classPrivateFieldInitSpec(this,qy,void 0);digital_signature_properties_manager_classPrivateFieldInitSpec(this,Yy,void 0);digital_signature_properties_manager_classPrivateFieldInitSpec(this,Zy,void 0);digital_signature_properties_manager_classPrivateFieldInitSpec(this,Qy,[]);digital_signature_properties_manager_classPrivateFieldInitSpec(this,Jy,new Map);digital_signature_properties_manager_classPrivateFieldInitSpec(this,eb,new Set);digital_signature_properties_manager_classPrivateFieldInitSpec(this,tb,!1);digital_signature_properties_manager_classPrivateFieldInitSpec(this,ib,!1);digital_signature_properties_manager_classPrivateFieldInitSpec(this,ab,!1);digital_signature_properties_manager_classPrivateFieldInitSpec(this,sb,null);digital_signature_properties_manager_classPrivateFieldSet(qy,this,e);digital_signature_properties_manager_classPrivateFieldSet(Yy,this,t);digital_signature_properties_manager_classPrivateFieldSet(Zy,this,i);const a=e.signaturePropertiesButton;for(let e=0;e<3;e++){const e=document.createElement("span");e.className="loadingDot";a.append(e)}a.addEventListener("click",()=>{digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_toggle).call(this)})}get isOpen(){return digital_signature_properties_manager_classPrivateFieldGet(tb,this)}close(){digital_signature_properties_manager_classPrivateFieldGet(tb,this)&&digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_close).call(this)}shouldCloseOnClick(e){return!!digital_signature_properties_manager_classPrivateFieldGet(tb,this)&&!(digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesButton.contains(e)||digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesPanel.contains(e))}async setDocument(e){if(digital_signature_properties_manager_classPrivateFieldGet(sb,this)){digital_signature_properties_manager_classPrivateFieldSet(Qy,this,[]);digital_signature_properties_manager_classPrivateFieldGet(Jy,this).clear();digital_signature_properties_manager_classPrivateFieldGet(eb,this).clear();digital_signature_properties_manager_classPrivateFieldSet(ab,this,!1);digital_signature_properties_manager_assertClassBrand(rb,this,_hideButton).call(this);digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_close).call(this);digital_signature_properties_manager_assertClassBrand(rb,this,_updateButtonState).call(this)}digital_signature_properties_manager_classPrivateFieldSet(sb,this,e);if(!e)return;digital_signature_properties_manager_classPrivateFieldSet(ib,this,!0);digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_render).call(this);let t;try{t=await e.getSignatures()}catch(e){console.warn("getSignatures failed:",e)}if(e===digital_signature_properties_manager_classPrivateFieldGet(sb,this)){digital_signature_properties_manager_classPrivateFieldSet(Qy,this,t||[]);digital_signature_properties_manager_classPrivateFieldSet(ib,this,!1);if(0!==digital_signature_properties_manager_classPrivateFieldGet(Qy,this).length){digital_signature_properties_manager_assertClassBrand(rb,this,_showButton).call(this);for(const e of digital_signature_properties_manager_classPrivateFieldGet(Qy,this))digital_signature_properties_manager_classPrivateFieldGet(Jy,this).set(e.id,{status:"unknown",errorCode:null,message:null,certificate:null,documentModifiedAfterSigning:!e.coversWholeDocument,modificationsAfterSignature:e.modificationsAfterSignature});digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_render).call(this);digital_signature_properties_manager_assertClassBrand(rb,this,_updateButtonState).call(this);for(const t of digital_signature_properties_manager_classPrivateFieldGet(Qy,this))digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_verify).call(this,t,e)}else digital_signature_properties_manager_assertClassBrand(rb,this,_hideButton).call(this)}}}function _showButton(){const e=digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesButton.parentElement;e&&(e.hidden=!1);const t=digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesSeparator;t&&(t.hidden=!1)}function _hideButton(){const e=digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesButton.parentElement;e&&(e.hidden=!0);const t=digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesSeparator;t&&(t.hidden=!0)}function digital_signature_properties_manager_toggle(){digital_signature_properties_manager_classPrivateFieldGet(tb,this)?digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_close).call(this):digital_signature_properties_manager_assertClassBrand(rb,this,_open).call(this)}function _open(){digital_signature_properties_manager_classPrivateFieldSet(tb,this,!0);digital_signature_properties_manager_classPrivateFieldGet(Zy,this)?.dispatch("switchannotationeditormode",{source:this,mode:f.NONE});digital_signature_properties_manager_classPrivateFieldGet(Zy,this)?.dispatch("findbarclose",{source:this});digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesPanel.classList.remove("hidden");digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesButton.setAttribute("aria-expanded","true");digital_signature_properties_manager_classPrivateFieldGet(ab,this)&&digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_render).call(this)}function digital_signature_properties_manager_close(){digital_signature_properties_manager_classPrivateFieldSet(tb,this,!1);digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesPanel.classList.add("hidden");digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesButton.setAttribute("aria-expanded","false")}function _get_worst(e){let t="verified";for(const i of digital_signature_properties_manager_classPrivateFieldGet(Jy,e).values())i?.status&&Xy[i.status].priority>Xy[t].priority&&(t=i.status);return t}function _get_bannerState(e){if(0===digital_signature_properties_manager_classPrivateFieldGet(Jy,e).size)return{worst:"unknown",severity:"error",count:0};const t=digital_signature_properties_manager_classPrivateGetter(rb,e,_get_worst);let i=0;for(const a of digital_signature_properties_manager_classPrivateFieldGet(Jy,e).values())a?.status===t&&i++;return{worst:t,severity:Xy[t].severity,count:i}}function digital_signature_properties_manager_render(){if(!digital_signature_properties_manager_classPrivateFieldGet(tb,this)){digital_signature_properties_manager_classPrivateFieldSet(ab,this,!0);return}digital_signature_properties_manager_classPrivateFieldSet(ab,this,!1);const e=digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesList,t=digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesBanner,i=document.createDocumentFragment();if(digital_signature_properties_manager_classPrivateFieldGet(ib,this)){t.hidden=!0;e.replaceChildren();return}const{worst:a,severity:s,count:r}=digital_signature_properties_manager_classPrivateGetter(rb,this,_get_bannerState);t.replaceChildren();t.hidden=!1;t.className=`sigBanner ${s}`;t.setAttribute("data-l10n-id",Xy[a].bannerId);t.setAttribute("data-l10n-args",JSON.stringify({count:r}));const n=new Map,o=[];for(const e of digital_signature_properties_manager_classPrivateFieldGet(Qy,this))e.parentId?n.getOrInsertComputed(e.parentId,makeArr).push(e):o.push(e);const l="verified"===s;for(const e of o)i.append(digital_signature_properties_manager_assertClassBrand(rb,this,_renderCard).call(this,e,n,0,l));e.replaceChildren(i)}function _renderCard(e,t,i,a){const s=t.get(e.id)||[],r=document.createElement("li");r.classList.add("sigCard");0===i&&a&&r.classList.add("sigCard--top-allfine");const n=digital_signature_properties_manager_classPrivateFieldGet(Jy,this).get(e.id),o=n?.certificate?.subjectCN;if(o){const e=document.createElement("div");e.className="signer";e.textContent=o;r.append(e)}const l=document.createElement("div");l.classList.add("row",`status--${n.status}`);const d=document.createElement("span");d.setAttribute("data-l10n-id",Xy[n.status].statusId);l.append(d);r.append(l);if("invalid"===n.status&&n.message){const e=document.createElement("div");e.className="detail";e.setAttribute("data-l10n-id","pdfjs-digital-signature-properties-reason");e.setAttribute("data-l10n-args",JSON.stringify({reason:n.message}));r.append(e)}const c=n.certificate;let h="unknown";if(c)switch(n.status){case"verified":h="trusted";break;case"expired":h="expired";break;case"revoked":h="revoked";break;case"untrusted":h="untrusted";break;default:h="unknown"}if("invalid"!==n.status){const e=document.createElement("div");e.classList.add("row",`cert--${h}`);const t=document.createElement("span");let i=Ky[h],a=null;if(c?.issuerCN&&"trusted"===h)a={issuer:c.issuerCN};else if("expired"===h){const e=function expirationDateForCert(e){if(!e)return null;const t=Date.now(),i=Array.isArray(e.chain)&&e.chain.length?e.chain:[e];for(const e of i){if("string"!=typeof e?.notAfter||!e.notAfter)continue;const i=new Date(e.notAfter),a=i.getTime();if(Number.isFinite(a)&&a<t)return i}return null}(c);if(e){i="pdfjs-digital-signature-properties-certificate-expired-with-date";a={dateObj:e.valueOf()}}}else if("untrusted"===h){const e=function untrustedCertLabel(e,t){const i=(e||"").toUpperCase(),a=t?{issuer:t}:null;return i.includes("UNKNOWN_ISSUER")&&a?{id:"pdfjs-digital-signature-properties-certificate-untrusted-unknown-issuer",args:a}:i.includes("SELF_SIGNED")&&a?{id:"pdfjs-digital-signature-properties-certificate-untrusted-self-signed",args:a}:i.includes("UNTRUSTED_ISSUER")&&a?{id:"pdfjs-digital-signature-properties-certificate-untrusted-untrusted-issuer",args:a}:{id:"pdfjs-digital-signature-properties-certificate-untrusted",args:null}}(n.errorCode,c?.issuerCN);i=e.id;a=e.args}t.setAttribute("data-l10n-id",i);a&&t.setAttribute("data-l10n-args",JSON.stringify(a));e.append(t);r.append(e)}if("untrusted"===n.status&&n.message){const e=document.createElement("div");e.className="detail";e.textContent=n.message;r.append(e)}if("expired"===n.status&&n.message){const e=document.createElement("div");e.className="detail";e.textContent=n.message;r.append(e)}const _=PDFDateString.toDateObject(e.signingTime);if(_){const e=document.createElement("div");e.className="detail";e.setAttribute("data-l10n-id","pdfjs-digital-signature-properties-timestamp");e.setAttribute("data-l10n-args",JSON.stringify({dateObj:_.valueOf()}));r.append(e)}if(c&&"function"==typeof digital_signature_properties_manager_classPrivateFieldGet(Yy,this)?.viewCertificate){const e=document.createElement("button");e.className="viewCert";e.type="button";e.setAttribute("data-l10n-id","pdfjs-digital-signature-properties-view-certificate");e.addEventListener("click",e=>{e.stopPropagation();digital_signature_properties_manager_classPrivateFieldGet(Yy,this).viewCertificate(c)});r.append(e)}if(s.length>0){const n=document.createElement("ul");n.classList.add("signaturePropertiesList","nested");for(const e of s)n.append(digital_signature_properties_manager_assertClassBrand(rb,this,_renderCard).call(this,e,t,i+1,a));if(0===i){const i=document.createElement("details");i.className="subSignatures";i.open=!0;const a=document.createElement("summary");a.setAttribute("data-l10n-id","pdfjs-digital-signature-properties-sub-signatures");a.setAttribute("data-l10n-args",JSON.stringify({count:digital_signature_properties_manager_assertClassBrand(rb,this,_countDescendants).call(this,e.id,t)}));i.append(a);i.append(n);r.append(i)}else r.append(n)}return r}function _countDescendants(e,t){const i=t.get(e);if(!i)return 0;let a=i.length;for(const e of i)a+=digital_signature_properties_manager_assertClassBrand(rb,this,_countDescendants).call(this,e.id,t);return a}async function digital_signature_properties_manager_verify(e,t){if(!digital_signature_properties_manager_classPrivateFieldGet(Yy,this)||digital_signature_properties_manager_classPrivateFieldGet(eb,this).has(e.id))return;digital_signature_properties_manager_classPrivateFieldGet(eb,this).add(e.id);digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_render).call(this);let i;try{const a=await t.getSignatureData(e.id);if(t!==digital_signature_properties_manager_classPrivateFieldGet(sb,this))return;if(!a)throw new Error("missing signature data");i=await digital_signature_properties_manager_classPrivateFieldGet(Yy,this).verify({...e,...a})}catch(t){console.warn("signature verify failed:",t);i={status:"unknown",errorCode:"BRIDGE_ERROR",message:t?.message??null,certificate:null,documentModifiedAfterSigning:!e.coversWholeDocument,modificationsAfterSignature:e.modificationsAfterSignature}}digital_signature_properties_manager_classPrivateFieldGet(eb,this).delete(e.id);if(t===digital_signature_properties_manager_classPrivateFieldGet(sb,this)){digital_signature_properties_manager_classPrivateFieldGet(Jy,this).set(e.id,i);digital_signature_properties_manager_assertClassBrand(rb,this,digital_signature_properties_manager_render).call(this);digital_signature_properties_manager_assertClassBrand(rb,this,_updateButtonState).call(this)}}function _updateButtonState(){const e=digital_signature_properties_manager_classPrivateFieldGet(qy,this).signaturePropertiesButton;e.classList.remove("state-loading","state-verified","state-warn","state-error");if(0!==digital_signature_properties_manager_classPrivateFieldGet(Qy,this).length)if(digital_signature_properties_manager_classPrivateFieldGet(eb,this).size>0)e.classList.add("state-loading");else switch(digital_signature_properties_manager_classPrivateGetter(rb,this,_get_worst)){case"invalid":case"revoked":case"unknown":e.classList.add("state-error");break;case"expired":case"untrusted":e.classList.add("state-warn");break;default:e.classList.add("state-verified")}}function toolbar_classPrivateFieldInitSpec(e,t,i){toolbar_checkPrivateRedeclaration(e,t),t.set(e,i)}function toolbar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function toolbar_classPrivateFieldGet(e,t){return e.get(web_toolbar_assertClassBrand(e,t))}function toolbar_classPrivateFieldSet(e,t,i){return e.set(web_toolbar_assertClassBrand(e,t),i),i}function web_toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var nb=new WeakMap,ob=new WeakMap,lb=new WeakMap,db=new WeakMap,cb=new WeakMap,hb=new WeakMap,_b=new WeakSet;class Toolbar{constructor(e,t,i,a,s,r=0){!function toolbar_classPrivateMethodInitSpec(e,t){toolbar_checkPrivateRedeclaration(e,t),t.add(e)}(this,_b);toolbar_classPrivateFieldInitSpec(this,nb,null);toolbar_classPrivateFieldInitSpec(this,ob,!1);toolbar_classPrivateFieldInitSpec(this,lb,void 0);toolbar_classPrivateFieldInitSpec(this,db,"auto");toolbar_classPrivateFieldInitSpec(this,cb,25);toolbar_classPrivateFieldInitSpec(this,hb,.1);toolbar_classPrivateFieldSet(lb,this,e);toolbar_classPrivateFieldSet(db,this,i);toolbar_classPrivateFieldSet(cb,this,s);toolbar_classPrivateFieldSet(hb,this,a);this.eventBus=t;const n=[{element:e.previous,eventName:"previouspage"},{element:e.next,eventName:"nextpage"},{element:e.print,eventName:"print"},{element:e.presentationModeButton,eventName:"presentationmode"},{element:e.download,eventName:"download"},{element:e.movePageUp,eventName:"movePageUp"},{element:e.movePageDown,eventName:"movePageDown"},{element:e.undo,eventName:"editingaction",eventDetails:{name:"undo"}},{element:e.redo,eventName:"editingaction",eventDetails:{name:"redo"}}];if(e.bindEditorButtons)for(const[t,i]of[[e.editorCommentButton,f.POPUP],[e.editorEraserButton,f.ERASER],[e.editorFreeTextButton,f.FREETEXT],[e.editorHighlightButton,f.HIGHLIGHT],[e.editorInkButton,f.INK],[e.editorStampButton,f.STAMP],[e.editorSignatureButton,f.SIGNATURE]])t&&n.push({element:t,eventName:"switchannotationeditormode",eventDetails:{get mode(){return t.classList.contains("toggled")?f.NONE:i}}});web_toolbar_assertClassBrand(_b,this,toolbar_bindListeners).call(this,n);web_toolbar_assertClassBrand(_b,this,_updateToolbarDensity).call(this,{value:r});this.reset()}get maxZoom(){return toolbar_classPrivateFieldGet(cb,this)}set maxZoom(e){toolbar_classPrivateFieldSet(cb,this,e)}get minZoom(){return toolbar_classPrivateFieldGet(hb,this)}set minZoom(e){toolbar_classPrivateFieldSet(hb,this,e)}setPageNumber(e,t){this.pageNumber=e;this.pageLabel=t;web_toolbar_assertClassBrand(_b,this,toolbar_updateUIState).call(this,!1)}setPagesCount(e,t){this.pagesCount=e;this.hasPageLabels=t;web_toolbar_assertClassBrand(_b,this,toolbar_updateUIState).call(this,!0)}setPageScale(e,t){this.pageScaleValue=(e||t).toString();this.pageScale=t;web_toolbar_assertClassBrand(_b,this,toolbar_updateUIState).call(this,!1)}reset(){toolbar_classPrivateFieldSet(nb,this,null);toolbar_classPrivateFieldSet(ob,this,!1);this.pageNumber=0;this.pageLabel=null;this.hasPageLabels=!1;this.pagesCount=0;const e=toolbar_classPrivateFieldGet(db,this)||"auto";this.pageScaleValue=e;Number(e)&&(this.pageScale=Number(e));web_toolbar_assertClassBrand(_b,this,toolbar_updateUIState).call(this,!0);this.updateLoadingIndicatorState();web_toolbar_assertClassBrand(_b,this,_editorModeChanged).call(this,{mode:f.DISABLE});web_toolbar_assertClassBrand(_b,this,_editingStatesChanged).call(this,{details:{hasSomethingToUndo:!1,hasSomethingToRedo:!1}})}updateLoadingIndicatorState(e=!1){const{pageNumber:t}=toolbar_classPrivateFieldGet(lb,this);t.classList.toggle("loading",e)}}function _updateToolbarDensity({value:e}){let t="normal";switch(e){case 1:t="compact";break;case 2:t="touch"}document.documentElement.setAttribute("data-toolbar-density",t)}function toolbar_bindListeners(e){const{eventBus:t}=this,{editorHighlightColorPicker:i,editorHighlightButton:a,pageNumber:s,scaleSelect:r}=toolbar_classPrivateFieldGet(lb,this),n=this;for(const{element:i,eventName:a,eventDetails:s,telemetry:r}of e)i&&i.addEventListener("click",e=>{null!==a&&t.dispatch(a,{source:this,...s,isFromKeyboard:0===e.detail});r&&t.dispatch("reporttelemetry",{source:this,details:r})});s.addEventListener("click",function(){this.select()});s.addEventListener("input",()=>{toolbar_classPrivateFieldSet(ob,this,!0)});s.addEventListener("blur",()=>{if(toolbar_classPrivateFieldGet(ob,this)){toolbar_classPrivateFieldSet(ob,this,!1);web_toolbar_assertClassBrand(_b,this,toolbar_updateUIState).call(this,!1)}});s.addEventListener("change",function(){toolbar_classPrivateFieldSet(ob,n,!1);t.dispatch("pagenumberchanged",{source:n,value:this.value})});t.on("pagesedited",({pagesMapper:e})=>{const t=e.pagesNumber;t!==this.pagesCount&&this.setPagesCount(t,this.hasPageLabels)},lu);r.addEventListener("change",function(){"custom"!==this.value&&t.dispatch("scalechanged",{source:n,value:this.value})});r.addEventListener("click",function({target:e}){this.value===n.pageScaleValue&&"OPTION"===e.tagName.toUpperCase()&&this.blur()});r.oncontextmenu=noContextMenu;t.on("annotationeditormodechanged",web_toolbar_assertClassBrand(_b,this,_editorModeChanged).bind(this),lu);t.on("editingstateschanged",web_toolbar_assertClassBrand(_b,this,_editingStatesChanged).bind(this),lu);t.on("showannotationeditorui",({mode:e})=>{if(e===f.HIGHLIGHT)a.click()},lu);t.on("toolbardensity",web_toolbar_assertClassBrand(_b,this,_updateToolbarDensity).bind(this),lu);t._on("closeopenpopovers",({source:e})=>{e!==this&&t.dispatch("switchannotationeditormode",{source:this,mode:f.NONE})});t._on("showannotationeditorui",({mode:e})=>{if(e===f.HIGHLIGHT)a.click()});t._on("spreadmodechanged",()=>{web_toolbar_assertClassBrand(_b,this,toolbar_updateUIState).call(this,!1)});t._on("scrollmodechanged",()=>{web_toolbar_assertClassBrand(_b,this,toolbar_updateUIState).call(this,!1)});if(i){t.on("annotationeditoruimanager",({uiManager:e})=>{const t=toolbar_classPrivateFieldSet(nb,this,new ColorPicker({uiManager:e}));e.setMainHighlightColorPicker(t);i.append(t.renderMainDropdown())},lu);t.on("mainhighlightcolorpickerupdatecolor",({value:e})=>{toolbar_classPrivateFieldGet(nb,this)?.update(e)},lu)}}function _editorModeChanged({mode:e}){e!==f.NONE&&e!==f.DISABLE&&this.eventBus.dispatch("closeopenpopovers",{source:this});const{editorCommentButton:t,editorCommentParamsToolbar:i,editorEraserButton:a,editorEraserParamsToolbar:s,editorFreeTextButton:r,editorFreeTextParamsToolbar:n,editorHighlightButton:o,editorHighlightParamsToolbar:l,editorInkButton:d,editorInkParamsToolbar:c,editorStampButton:h,editorStampParamsToolbar:_,editorSignatureButton:u,editorSignatureParamsToolbar:p}=toolbar_classPrivateFieldGet(lb,this);toggleExpandedBtn(t,e===f.POPUP,i);toggleExpandedBtn(r,e===f.FREETEXT,n);toggleExpandedBtn(o,e===f.HIGHLIGHT,l);toggleExpandedBtn(d,e===f.INK,c);a&&toggleExpandedBtn(a,e===f.ERASER,s);toggleExpandedBtn(h,e===f.STAMP,_);toggleExpandedBtn(u,e===f.SIGNATURE,p);const g=e===f.DISABLE;t&&(t.disabled=g);r&&(r.disabled=g);o&&(o.disabled=g);d&&(d.disabled=g);a&&(a.disabled=g);h&&(h.disabled=g);u&&(u.disabled=g)}function _editingStatesChanged({details:e}){const{undo:t,redo:i}=toolbar_classPrivateFieldGet(lb,this),a=e.isEditing??!1;t&&"hasSomethingToUndo"in e&&(t.disabled=!(a&&e.hasSomethingToUndo));i&&"hasSomethingToRedo"in e&&(i.disabled=!(a&&e.hasSomethingToRedo))}function toolbar_updateUIState(e=!1){const{pageNumber:t,pagesCount:i,pageScaleValue:a,pageScale:s}=this,r=toolbar_classPrivateFieldGet(lb,this);if(e){if(this.hasPageLabels){r.pageNumber.type="text";r.numPages.setAttribute("data-l10n-id","pdfjs-page-of-pages")}else{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}if(this.hasPageLabels){toolbar_classPrivateFieldGet(ob,this)||(r.pageNumber.value=this.pageLabel);r.numPages.setAttribute("data-l10n-args",JSON.stringify({pageNumber:t,pagesCount:i}))}else toolbar_classPrivateFieldGet(ob,this)||(r.pageNumber.value=t);r.previous.disabled=t<=1;r.next.disabled=t>=i;const n=Number(this.minZoom)??.1,o=Number(this.maxZoom)??25;r.zoomOut&&(r.zoomOut.disabled=s<=n);r.zoomIn&&(r.zoomIn.disabled=s>=o);let l=!1;if(r.scaleSelect.options)for(const e of r.scaleSelect.options){const t=parseFloat(e.value),i=parseFloat(a);if(!isNaN(t)&&!isNaN(i)&&Math.abs(t-i)<1e-4||e.value===a){e.selected=!0;l=!0}else e.selected=!1}l||(r.customScaleOption.selected=!0);const d="number"!=typeof s||Number.isNaN(s)?0:Math.round(1e4*s)/100;r.customScaleOption.setAttribute("data-l10n-args",JSON.stringify({scale:d}));this.eventBus.dispatch("updateuistate",{source:this,widget:"Toolbar",pageNumber:t,pagesCount:i,pageScaleValue:a,pageScale:s})}class ViewHistory{constructor(e,t=20){this._initializedPromise=this._readFromStorage().then(i=>{const a=JSON.parse(i||"{}");let s=-1;if(Array.isArray(a.files)){for(;a.files.length>=t;)a.files.shift();s=a.files.findIndex(t=>t.fingerprint===e)}else a.files=[];-1===s&&(s=a.files.push({fingerprint:e})-1);this.file=a.files[s];this.database=a})}async _writeToStorage(){if(AppOptions.get("disableHistory"))return;const e=JSON.stringify(this.database);try{localStorage.setItem("pdfjs.history",e)}catch(e){}}async _readFromStorage(){if(!AppOptions.get("disableHistory"))try{return localStorage.getItem("pdfjs.history")}catch(e){return}}async setMultiple(e){await this._initializedPromise;for(const t in e)this.file[t]=e[t];return this._writeToStorage()}async getMultiple(e){await this._initializedPromise;const t=Object.create(null);for(const i in e){const a=this.file[i];t[i]=void 0!==a?a:e[i]}return t}}function views_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function views_manager_classPrivateFieldGet(e,t){return e.get(views_manager_assertClassBrand(e,t))}function views_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const ub="viewsManagerResizing",pb="pdfSidebarNotification";var gb=new WeakMap,mb=new WeakSet;class ViewsManager extends Sidebar{constructor({elements:{outerContainer:e,sidebarContainer:t,toggleButton:i,resizer:a,thumbnailButton:s,outlineButton:r,attachmentsButton:n,layersButton:o,thumbnailsView:l,outlinesView:d,attachmentsView:c,layersView:h,viewsManagerAddFile:{button:_},viewsManagerCurrentOutlineButton:u,viewsManagerSelectorButton:p,viewsManagerSelectorOptions:g,viewsManagerHeaderLabel:m,viewsManagerStatus:f},eventBus:v,l10n:P,enableMerge:w=!1,enableSplitMerge:F=!1,globalAbortSignal:y}){super({sidebar:t,resizer:a,toggleButton:i},"ltr"===P.getDirection(),!1,y);!function views_manager_classPrivateMethodInitSpec(e,t){views_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,mb);!function views_manager_classPrivateFieldInitSpec(e,t,i){views_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,gb,!window.matchMedia("(prefers-reduced-motion: reduce)").matches);this.isOpen=!1;this.active=N_;this.isInitialViewSet=!1;this.isInitialEventDispatched=!1;this.onToggled=null;this.onUpdateThumbnails=null;this.outerContainer=e;this.sidebarContainer=t;this.toggleButton=i;this.resizer=a;this.thumbnailButton=s;this.outlineButton=r;this.attachmentsButton=n;this.layersButton=o;this.thumbnailsView=l;this.outlinesView=d;this.attachmentsView=c;this.layersView=h;this.viewsManagerAddFileButton=_;this.viewsManagerCurrentOutlineButton=u;this.viewsManagerHeaderLabel=m;this.viewsManagerStatus=f;this.eventBus=v;!F&&f&&(f.hidden=!0);this._enableSplitMerge=F;this._enableMerge=w;w||(_.hidden=!0);this.menu=g&&p?new Menu(g,p,[s,r,n,o]):null;fb._||(fb._=Object.freeze({pagesTitle:"pdfjs-views-manager-pages-title",outlinesTitle:"pdfjs-views-manager-outlines-title1",attachmentsTitle:"pdfjs-views-manager-attachments-title",layersTitle:"pdfjs-views-manager-layers-title1",notificationButton:"pdfjs-toggle-views-manager-notification-button",toggleButton:"pdfjs-toggle-views-manager-button1"}));views_manager_assertClassBrand(mb,this,views_manager_addEventListeners).call(this)}reset(){this.isInitialViewSet=!1;this.isInitialEventDispatched=!1;views_manager_assertClassBrand(mb,this,_hideUINotification).call(this,!0);this.switchView(N_);this.outlineButton.disabled=this.attachmentsButton.disabled=this.layersButton.disabled=!1;this.outlineButton.hidden=!1;this.attachmentsButton.hidden=!1;this.layersButton.hidden=!1;this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.disabled=!0)}get visibleView(){return this.isOpen?this.active:O_}setInitialView(e=O_){if(!this.isInitialViewSet){this.isInitialViewSet=!0;if(e!==O_&&e!==R_){this.switchView(e,!0);this.isInitialEventDispatched||views_manager_assertClassBrand(mb,this,_dispatchEvent).call(this)}else views_manager_assertClassBrand(mb,this,_dispatchEvent).call(this)}}switchView(e,t=!1){const i=e!==this.active;let a=!1,s=null;switch(e){case O_:this.isOpen&&this.close();return;case N_:s="pagesTitle";this.isOpen&&i&&(a=!0);break;case W_:s="outlinesTitle";if(this.outlineButton.disabled)return;break;case j_:s="attachmentsTitle";if(this.attachmentsButton.disabled)return;break;case V_:s="layersTitle";if(this.layersButton.disabled)return;break;default:ngx_console_NgxConsole.error(`PDFSidebar.switchView: "${e}" is not a valid view.`);return}this._enableSplitMerge&&this.viewsManagerStatus&&(this.viewsManagerStatus.hidden=e!==N_);this.viewsManagerAddFileButton&&(this.viewsManagerAddFileButton.hidden=!this._enableMerge||e!==N_);this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.hidden=e!==W_);this.viewsManagerHeaderLabel&&this.viewsManagerHeaderLabel.setAttribute("data-l10n-id",fb._[s]||"");this.active=e;toggleSelectedBtn(this.thumbnailButton,e===N_,this.thumbnailsView);toggleSelectedBtn(this.outlineButton,e===W_,this.outlinesView);toggleSelectedBtn(this.attachmentsButton,e===j_,this.attachmentsView);toggleSelectedBtn(this.layersButton,e===V_,this.layersView);if(!t||this.isOpen){if(a){this.onUpdateThumbnails();this.onToggled()}i&&views_manager_assertClassBrand(mb,this,_dispatchEvent).call(this)}else this.open()}open(){if(!this.isOpen&&this._sidebar){this.isOpen=!0;this.onResizing(this.width);this._sidebar.hidden=!1;toggleExpandedBtn(this.toggleButton,!0);this.switchView(this.active);if(views_manager_classPrivateFieldGet(gb,this))queueMicrotask(()=>{this.outerContainer.classList.add("viewsManagerMoving","viewsManagerOpen")});else{this.outerContainer.classList.add("viewsManagerOpen");this.eventBus.dispatch("resize",{source:this,sidebarToggle:!0})}this.active===N_&&this.onUpdateThumbnails();this.onToggled();views_manager_assertClassBrand(mb,this,_dispatchEvent).call(this);views_manager_assertClassBrand(mb,this,_hideUINotification).call(this)}}close(e=null){if(this.isOpen&&this._sidebar){this.isOpen=!1;this._sidebar.hidden=!0;toggleExpandedBtn(this.toggleButton,!1);this.outerContainer.classList.add("viewsManagerMoving");this.outerContainer.classList.remove("viewsManagerOpen");this.onToggled();views_manager_assertClassBrand(mb,this,_dispatchEvent).call(this);this.eventBus.dispatch("resize",{source:this,sidebarToggle:!0});e?.detail>0&&this.toggleButton.blur()}}toggle(e=null){super.toggle();this.isOpen?this.close(e):this.open()}onStartResizing(){this.outerContainer.classList.add(ub)}onStopResizing(){this.eventBus.dispatch("resize",{source:this});this.outerContainer.classList.remove(ub)}onResizing(e){getDocStyle(this.outerContainer).setProperty("--viewsManager-width",`${e}px`)}}function _dispatchEvent(){this.isInitialViewSet&&(this.isInitialEventDispatched||=!0);this.eventBus.dispatch("sidebarviewchanged",{source:this,view:this.visibleView})}function _showUINotification(){this.toggleButton.setAttribute("data-l10n-id",fb._.notificationButton);this.isOpen||this.toggleButton.classList.add(pb)}function _hideUINotification(e=!1){(this.isOpen||e)&&this.toggleButton.classList.remove(pb);e&&this.toggleButton.setAttribute("data-l10n-id",fb._.toggleButton)}function views_manager_addEventListeners(){const{eventBus:e,outerContainer:t}=this;views_manager_classPrivateFieldGet(gb,this)&&this.sidebarContainer&&this.sidebarContainer.addEventListener("transitionend",i=>{if(i.target===this.sidebarContainer){t.classList.remove("viewsManagerMoving");e.dispatch("resize",{source:this,sidebarToggle:!0})}});this.viewsManagerHeaderLabel?.addEventListener("dblclick",t=>{this.active!==W_?this.active===V_&&e.dispatch("resetlayers",{source:this}):e.dispatch("toggleoutlinetree",{source:this})});this.thumbnailButton?.addEventListener("click",()=>{this.switchView(N_)});this.outlineButton?.addEventListener("click",()=>{this.switchView(W_)});this.attachmentsButton?.addEventListener("click",()=>{this.switchView(j_)});this.layersButton?.addEventListener("click",()=>{this.switchView(V_)});this.viewsManagerCurrentOutlineButton?.addEventListener("click",()=>{e.dispatch("currentoutlineitem",{source:this})});const onTreeLoaded=(e,t,i)=>{t.disabled=!e;t.hidden=!e;e?views_manager_assertClassBrand(mb,this,_showUINotification).call(this):this.active===i&&this.switchView(N_)};e.on("outlineloaded",e=>{onTreeLoaded(e.outlineCount,this.outlineButton,W_);e.currentOutlineItemPromise.then(e=>{this.isInitialViewSet&&this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.disabled=!e)})},lu);e.on("attachmentsloaded",e=>{onTreeLoaded(e.attachmentsCount,this.attachmentsButton,j_)},lu);e.on("layersloaded",e=>{onTreeLoaded(e.layersCount,this.layersButton,V_)},lu);e.on("presentationmodechanged",e=>{e.state===T_&&this.visibleView===N_&&this.onUpdateThumbnails()},lu)}var fb={_:null};const vb=-1,Pb=1,wb={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,pdfTextExtractor:null,pdfHistory:null,viewsManager:null,pdfOutlineViewer:null,pdfAttachmentViewer:null,pdfLayerViewer:null,pdfCursorTools:null,pdfScriptingManager:null,pdfWorker:null,store:null,downloadManager:null,overlayManager:null,preferences:new class Preferences extends BasePreferences{async _writeToStorage(e){try{localStorage.setItem("pdfjs.preferences",JSON.stringify(e))}catch(e){}}async _readFromStorage(e){try{return{prefs:JSON.parse(localStorage.getItem("pdfjs.preferences"))}}catch(e){return{}}}},toolbar:null,secondaryToolbar:null,eventBus:null,l10n:null,annotationEditorParams:null,signaturePropertiesManager:null,imageAltTextSettings:null,isInitialViewSet:!1,isViewerEmbedded:window.parent!==window,url:"",baseUrl:"",mlManager:null,_downloadUrl:"",_isMergedDocument:!1,_eventBusAC:null,_windowAC:null,_globalAbortController:new AbortController,documentInfo:null,metadata:null,_contentDispositionFilename:null,_contentLength:null,_saveInProgress:!1,_wheelUnusedTicks:0,_wheelUnusedFactor:1,_touchManager:null,_touchUnusedTicks:0,_touchUnusedFactor:1,_PDFBug:null,_hasAnnotationEditors:!1,_title:document.title,_printAnnotationStoragePromise:null,_isCtrlKeyDown:!1,_caretBrowsing:null,_isScrolling:!1,editorUndoBar:null,pageOrder:null,_printPermissionPromise:null,async initialize(e){this.appConfig=e;this.cspPolicyService=e.cspPolicyService;try{await this.preferences.initializedPromise}catch(e){ngx_console_NgxConsole.error("initialize:",e)}AppOptions.get("pdfBugEnabled")&&await this._parseHashParams();let t;switch(AppOptions.get("viewerCssTheme")){case 1:t="light";break;case 2:t="dark"}t&&getDocStyle(e.appContainer).setProperty("color-scheme",t);this.l10n=await this.externalServices.createL10n();(e.appContainer||document.documentElement).dir=this.l10n.getDirection();this.l10n.translate(e.appContainer||document.documentElement);this.isViewerEmbedded&&AppOptions.get("externalLinkTarget")===du.NONE&&AppOptions.set("externalLinkTarget",du.TOP);await this._initializeViewerComponents();this.bindEvents();this.bindWindowEvents();this._initializedCapability.settled=!0;this._initializedCapability.resolve();this.initializeLoadingBar()},async _parseHashParams(){const e=document.location.hash.substring(1);if(!e)return;const{mainContainer:t,viewerContainer:i}=this.appConfig,a=parseQueryString(e),loadPDFBug=async()=>{if(this._PDFBug)return;const{PDFBug:e}=await(import(
/*webpackIgnore: true*/
/*@vite-ignore*/
AppOptions.get("debuggerSrc")));this._PDFBug=e};if("true"===a.get("disableworker"))try{GlobalWorkerOptions.workerSrc||=AppOptions.get("workerSrc");await(import(
/*webpackIgnore: true*/
/*@vite-ignore*/
PDFWorker.workerSrc));AppOptions.set("workerPort",null)}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}if(a.has("textlayer"))switch(a.get("textlayer")){case"off":AppOptions.set("textLayerMode",U_);break;case"visible":case"shadow":case"hover":i.classList.add(`textLayer-${a.get("textlayer")}`);try{await loadPDFBug();this._PDFBug.loadCSS()}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}}if(a.has("pdfbug")){const e=a.get("pdfbug").split(",");try{await loadPDFBug();this._PDFBug.init(t,e)}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}const i={pdfBug:!0,fontExtraProperties:!0};globalThis.StepperManager?.enabled&&(i.minDurationToUpdateCanvas=0);AppOptions.setAll(i)}a.has("locale")&&AppOptions.set("localeProperties",{lang:a.get("locale")});const s={disableAutoFetch:e=>"true"===e,disableFontFace:e=>"true"===e,disableHistory:e=>"true"===e,disableRange:e=>"true"===e,disableStream:e=>"true"===e,verbosity:e=>0|e};for(const e in s){const t=s[e],i=e.toLowerCase();a.has(i)&&AppOptions.set(e,t(a.get(i)))}},async _initializeViewerComponents(){const{appConfig:e,externalServices:t,l10n:i,mlManager:a}=this,s=this._globalAbortController.signal,r=new EventBus;this.eventBus=AppOptions.eventBus=r;a?.setEventBus(r,s);const n=this.overlayManager=new OverlayManager,o=this.pdfRenderingQueue=new PDFRenderingQueue;o.onIdle=this._cleanup.bind(this);const l=this.pdfLinkService=new PDFLinkService({eventBus:r,externalLinkTarget:AppOptions.get("externalLinkTarget"),externalLinkRel:AppOptions.get("externalLinkRel"),ignoreDestinationZoom:AppOptions.get("ignoreDestinationZoom")}),d=AppOptions.get("supportsDownloading"),c=this.downloadManager=d?new DownloadManager:null;e.secondaryToolbar?.downloadButton&&(e.secondaryToolbar.downloadButton.hidden=!d);e.toolbar?.download&&(e.toolbar.download.hidden=!d);let h=PDFFindController;AppOptions.get("findController")&&(h=AppOptions.get("findController"));const _=new h({linkService:l,eventBus:r,pageViewMode:AppOptions.get("pageViewMode"),updateMatchesCountOnProgress:!0,listenToEventBus:!1});this.customFindController=_;const u=new h({linkService:l,eventBus:r,pageViewMode:AppOptions.get("pageViewMode"),updateMatchesCountOnProgress:!0,listenToEventBus:!0});this.findController=u;const p=this.pdfScriptingManager=new PDFScriptingManager({eventBus:r,externalServices:t,docProperties:this._scriptingDocProperties.bind(this)}),g=e.mainContainer,m=e.viewerContainer,v=AppOptions.get("annotationEditorMode"),P=AppOptions.get("forcePageColors")||window.matchMedia("(forced-colors: active)").matches,w=P?{background:AppOptions.get("pageColorsBackground"),foreground:AppOptions.get("pageColorsForeground")}:null,F=AppOptions.get("enableMerge"),y=AppOptions.get("enableSplitMerge");let b;b=AppOptions.get("enableUpdatedAddImage")?e.newAltTextDialog?new NewAltTextManager(e.newAltTextDialog,n,r):null:e.altTextDialog?new AltTextManager(e.altTextDialog,g,n,r):null;e.editorUndoBar&&(this.editorUndoBar=new EditorUndoBar(e.editorUndoBar,r));let S=null;AppOptions.get("enableSignatureEditor")&&e.addSignatureDialog&&(S=new SignatureManager(e.addSignatureDialog,e.editSignatureDialog,e.annotationEditorParams?.editorSignatureAddSignature||null,n,i,t.createSignatureStorage(r,s),r));const C=AppOptions.get("enableComment")&&e.editCommentDialog?new CommentManager(e.editCommentDialog,{learnMoreUrl:AppOptions.get("commentLearnMoreUrl"),sidebar:e.annotationEditorParams?.editorCommentsSidebar||null,sidebarResizer:e.annotationEditorParams?.editorCommentsSidebarResizer||null,commentsList:e.annotationEditorParams?.editorCommentsSidebarList||null,commentCount:e.annotationEditorParams?.editorCommentsSidebarCount||null,sidebarTitle:e.annotationEditorParams?.editorCommentsSidebarTitle||null,closeButton:e.annotationEditorParams?.editorCommentsSidebarCloseButton||null,commentToolbarButton:e.toolbar?.editorCommentButton||null},r,l,n,"ltr"===i.getDirection(),P,s):null,x=AppOptions.get("maxCanvasPixels"),k=AppOptions.get("maxCanvasDim"),E=AppOptions.get("capCanvasAreaFactor"),A=this.pdfViewer=new PDFViewer({container:g,viewer:m,viewerAlert:e.viewerAlert,eventBus:r,renderingQueue:o,linkService:l,downloadManager:c,altTextManager:b,commentManager:C,signatureManager:S,editorUndoBar:this.editorUndoBar,findController:u,customFindController:_,scriptingManager:AppOptions.get("enableScripting")&&p,l10n:i,textLayerMode:AppOptions.get("textLayerMode"),annotationMode:AppOptions.get("annotationMode"),annotationEditorMode:v,annotationEditorHighlightColors:AppOptions.get("highlightEditorColors"),enableHighlightFloatingButton:AppOptions.get("enableHighlightFloatingButton"),enableUpdatedAddImage:AppOptions.get("enableUpdatedAddImage"),enableNewAltTextWhenAddingImage:AppOptions.get("enableNewAltTextWhenAddingImage"),imageResourcesPath:AppOptions.get("imageResourcesPath"),removePageBorders:AppOptions.get("removePageBorders"),enablePrintAutoRotate:AppOptions.get("enablePrintAutoRotate"),maxCanvasPixels:x,maxCanvasDim:k,capCanvasAreaFactor:E,enableDetailCanvas:AppOptions.get("enableDetailCanvas"),pageViewMode:AppOptions.get("pageViewMode"),enablePermissions:AppOptions.get("enablePermissions"),enableOptimizedPartialRendering:AppOptions.get("enableOptimizedPartialRendering"),enableSelectionRendering:AppOptions.get("enableSelectionRendering"),imagesRightClickMinSize:AppOptions.get("imagesRightClickMinSize"),pageColors:w,mlManager:a,abortSignal:s,defaultCacheSize:AppOptions.get("defaultCacheSize"),minZoom:AppOptions.get("minZoom"),maxZoom:AppOptions.get("maxZoom"),cspPolicyService:this.cspPolicyService,supportsPinchToZoom:this.supportsPinchToZoom,enableAutoLinking:AppOptions.get("enableAutoLinking"),minDurationToUpdateCanvas:AppOptions.get("minDurationToUpdateCanvas")});o.setViewer(A);l.setViewer(A);p.setViewer(A);if(e.viewsManager?.thumbnailsView){const{viewsManager:t}=e;this.pdfThumbnailViewer=new PDFThumbnailViewer({container:t.thumbnailsView,eventBus:r,renderingQueue:o,linkService:l,l10n:i,maxCanvasPixels:x,maxCanvasDim:k,pageColors:w,abortSignal:s,enableSplitMerge:y,enableMerge:F,enablePageReordering:AppOptions.get("enablePageReordering"),enableNewBadge:AppOptions.get("enableNewBadge"),statusBar:t.viewsManagerStatusBar,undoBar:t.viewsManagerUndoBar,manageMenu:t.manageMenu,waitingBar:t.viewsManagerWaitingBar,addFileComponent:t.viewsManagerAddFile});o.setThumbnailViewer(this.pdfThumbnailViewer)}if(!this.isViewerEmbedded&&!AppOptions.get("disableHistory")){this.pdfHistory=new PDFHistory({linkService:l,eventBus:r});l.setHistory(this.pdfHistory)}!this.supportsIntegratedFind&&e.findBar&&(this.findBar=new PDFFindBar(e.findBar,e.principalContainer,r));if(e.annotationEditorParams)if(v!==f.DISABLE){const t=e.toolbar?.editorSignatureButton;t&&AppOptions.get("enableSignatureEditor")&&(t.parentElement.hidden=!1);const i=e.toolbar?.editorEraserButton;i&&AppOptions.get("enableEraser")&&(i.parentElement.hidden=!1);const a=this._getViewerElementById("movePageUp"),s=this._getViewerElementById("movePageDown");if(a&&s)if(AppOptions.get("enablePageReordering")){a.hidden=!1;s.hidden=!1}else{a.hidden=!0;s.hidden=!0}const n=e.toolbar?.editorCommentButton;n&&AppOptions.get("enableComment")&&(n.parentElement.hidden=!1);this.annotationEditorParams=new AnnotationEditorParams(e.annotationEditorParams,r)}else for(const e of["editorModeButtons","editorModeSeparator"])this._getViewerElementById(e)?.classList.add("hidden");a&&e.secondaryToolbar?.imageAltTextSettingsButton&&(this.imageAltTextSettings=new ImageAltTextSettings(e.altTextSettingsDialog,n,r,a));e.documentProperties&&(this.pdfDocumentProperties=new PDFDocumentProperties(e.documentProperties,n,r,i,()=>this._docFilename,()=>this._docTitle));e.secondaryToolbar?.cursorHandToolButton&&(this.pdfCursorTools=new PDFCursorTools({container:g,eventBus:r,cursorToolOnLoad:AppOptions.get("cursorToolOnLoad")}));e.toolbar&&(this.toolbar=new Toolbar(e.toolbar,r,AppOptions.get("defaultZoomValue"),AppOptions.get("minZoom"),AppOptions.get("maxZoom"),AppOptions.get("toolbarDensity")));if(e.secondaryToolbar){if(AppOptions.get("enableAltText")&&this.imageAltTextSettings){e.secondaryToolbar.imageAltTextSettingsButton?.classList.remove("hidden");e.secondaryToolbar.imageAltTextSettingsSeparator?.classList.remove("hidden")}this.secondaryToolbar=new SecondaryToolbar(e.secondaryToolbar,r)}this.supportsFullscreen&&(e.toolbar?.presentationModeButton||e.secondaryToolbar?.presentationModeButton)&&(this.pdfPresentationMode=new PDFPresentationMode({container:g,pdfViewer:A,eventBus:r}));const G=AppOptions.get("passwordPrompt");G?this.passwordPrompt=G:e.passwordOverlay&&(this.passwordPrompt=new PasswordPrompt(e.passwordOverlay,n,this.isViewerEmbedded));e.viewsManager?.outlinesView&&(this.pdfOutlineViewer=new PDFOutlineViewer({container:e.viewsManager.outlinesView,eventBus:r,l10n:i,linkService:l,downloadManager:c}));e.viewsManager?.attachmentsView&&(this.pdfAttachmentViewer=new PDFAttachmentViewer({container:e.viewsManager.attachmentsView,eventBus:r,l10n:i,downloadManager:c,linkService:l}));e.viewsManager?.layersView&&(this.pdfLayerViewer=new PDFLayerViewer({container:e.viewsManager.layersView,eventBus:r,l10n:i}));if(e.viewsManager){this.viewsManager=new ViewsManager({elements:e.viewsManager,eventBus:r,l10n:i,enableMerge:F,enableSplitMerge:y,globalAbortSignal:s});this.viewsManager.onToggled=this.forceRendering.bind(this);this.viewsManager.onUpdateThumbnails=()=>{for(const e of A.getCachedPageViews())e.renderingState===Xf.FINISHED&&this.pdfThumbnailViewer.getThumbnail(e.id-1)?.setImage(e);this.pdfThumbnailViewer.scrollThumbnailIntoView(A.currentPageNumber)}}},async run(e){await this.initialize(e);const{appConfig:t,eventBus:i}=this;let a;a=parseQueryString(document.location.search.substring(1)).get("file")??AppOptions.get("defaultUrl");a=URL.parse(a)?.href??a.replaceAll("#","%23");validateFileURL(a);const s=this._openFileInput=document.createElement("input");s.id="fileInput";s.className="ngx-extended-pdf-viewer-file-input";s.hidden=!0;s.type="file";s.value=null;s.accept=".pdf,application/pdf";document.body.append(s);s.addEventListener("change",function(e){const{files:t}=e.target;t?.length&&i.dispatch("fileinputchange",{source:this,fileInput:e.target})});t.mainContainer.addEventListener("dragover",function(e){if(AppOptions.get("enableDragAndDrop")){if(!e.dataTransfer?.items)return;for(const t of e.dataTransfer.items)if("application/pdf"===t.type){e.dataTransfer.dropEffect="copy"===e.dataTransfer.effectAllowed?"copy":"move";stopEvent(e);return}}});t.mainContainer.addEventListener("drop",function(e){if(AppOptions.get("enableDragAndDrop")){const t=e.dataTransfer?.files;if(!t||0===t.length||"application/pdf"!==t[0].type)return;stopEvent(e);i.dispatch("fileinputchange",{source:this,fileInput:e.dataTransfer,dropEvent:e})}});if(!AppOptions.get("supportsDocumentFonts")){AppOptions.set("disableFontFace",!0);this.l10n.get("pdfjs-web-fonts-disabled").then(e=>{ngx_console_NgxConsole.warn(e)})}const togglePrintingButtons=e=>{t.toolbar?.print?.classList.toggle("hidden",!e);t.secondaryToolbar?.printButton?.classList.toggle("hidden",!e)};this.supportsPrinting?i.on("printingallowed",({isAllowed:e})=>togglePrintingButtons(e),lu):togglePrintingButtons(!1);if(!this.supportsFullscreen){t.toolbar.presentationModeButton.classList.add("hidden");t.secondaryToolbar?.presentationModeButton?.classList.add("hidden")}this.supportsIntegratedFind&&t.findBar?.toggleButton?.classList.add("hidden");a?this.open({url:a}):this._hideViewBookmark();const r=new CustomEvent("webviewerinitialized",{bubbles:!0,cancelable:!0,detail:{source:window,PDFViewerApplication:this}});document.dispatchEvent(r)},get externalServices(){return shadow(this,"externalServices",new ExternalServices)},get initialized(){return this._initializedCapability.settled},get initializedPromise(){return this._initializedCapability.promise},updateZoom(e,t,i,a=null){this.pdfViewer.isInPresentationMode||this.pdfViewer.updateScale({drawingDelay:AppOptions.get("defaultZoomDelay"),steps:e,scaleFactor:t,origin:i,pan:a})},zoomIn(){this.updateZoom(1)},zoomOut(){this.updateZoom(-1)},zoomReset(){this.pdfViewer.isInPresentationMode||(this.pdfViewer.currentScaleValue="auto")},touchPinchCallback(e,t,i,a,s){const r=[a,s];if(this.supportsPinchToZoom){const a=this._accumulateFactor(this.pdfViewer.currentScale,i/t,"_touchUnusedFactor");this.updateZoom(null,a,e,r)}else{const a=30,s=this._accumulateTicks((i-t)/a,"_touchUnusedTicks");this.updateZoom(s,null,e,r)}},touchPanCallback(e,t){const{pdfViewer:i}=this;this.pdfDocument&&!i.isInPresentationMode&&i.panBy(e,t)},touchPinchEndCallback(){this._touchUnusedTicks=0;this._touchUnusedFactor=1;this.pdfViewer?.setTouchPinching(!1)},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 shadow(this,"supportsPrinting",AppOptions.get("supportsPrinting")&&PDFPrintServiceFactory.supportsPrinting)},get supportsFullscreen(){return shadow(this,"supportsFullscreen",document.fullscreenEnabled)},get supportsPinchToZoom(){return shadow(this,"supportsPinchToZoom",AppOptions.get("supportsPinchToZoom"))},get supportsIntegratedFind(){return shadow(this,"supportsIntegratedFind",AppOptions.get("supportsIntegratedFind"))},_getViewerElementById(e){const t=this.appConfig?.appContainer;return t?t.querySelector(`#${e}`):document.getElementById(e)},initializeLoadingBar(){const e=this._getViewerElementById("loadingBar"),t=e?new ProgressBar(e):null;t?.hide();return shadow(this,"loadingBar",t)},get supportsMouseWheelZoomCtrlKey(){return shadow(this,"supportsMouseWheelZoomCtrlKey",AppOptions.get("supportsMouseWheelZoomCtrlKey"))},get supportsMouseWheelZoomMetaKey(){return shadow(this,"supportsMouseWheelZoomMetaKey",AppOptions.get("supportsMouseWheelZoomMetaKey"))},get supportsCaretBrowsingMode(){return AppOptions.get("supportsCaretBrowsingMode")},moveCaret(e,t){this._caretBrowsing||=new CaretBrowsingMode(this._globalAbortController.signal,this.appConfig.mainContainer,this.appConfig.viewerContainer,this.appConfig.toolbar?.container);this._caretBrowsing.moveCaret(e,t)},setTitleUsingUrl(e="",t=null){},setTitle(e=this._title){this._title=e;if(this.isViewerEmbedded)return;const t=this._hasChanges()&&!this.pdfRenderingQueue.printing;document.title=`${t?"* ":""}${e}`},get _docFilename(){return this._contentDispositionFilename||getPdfFilenameFromUrl(this.url,wb.appConfig.filenameForDownload)},get _docTitle(){const{documentInfo:e,metadata:t}=this,i=t?.get("dc:title");return i&&"Untitled"!==i&&!/[\uFFF0-\uFFFF]/.test(i)?i:e.Title},_hideViewBookmark(){if(!this.appConfig)return;const{secondaryToolbar:e}=this.appConfig;e?.viewBookmarkButton.classList.add("hidden");e?.presentationModeButton?.classList.contains("hidden")&&this._getViewerElementById("viewBookmarkSeparator")?.classList.add("hidden")},async close(){this._unblockDocumentLoadEvent();this._hideViewBookmark();if(!this.pdfLoadingTask)return;if(this._hasChanges()&&this._hasRealAnnotationChanges())try{await this.downloadOrSave()}catch{}const e=[];e.push(this.pdfLoadingTask.destroy());this.pdfLoadingTask=null;if(this.pdfDocument){this.pdfDocument=null;this.pdfThumbnailViewer?.setDocument(null);this.pdfViewer.setDocument(null);this.pdfLinkService.setDocument(null);this.pdfDocumentProperties?.setDocument(null);this.signaturePropertiesManager?.setDocument(null)}this.pdfLinkService.externalLinkEnabled=!0;this.store=null;this.isInitialViewSet=!1;this.url="";this.baseUrl="";this._downloadUrl="";this._isMergedDocument=!1;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.viewsManager?.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.pdfViewer?.destroyBookMode();this.pdfLoadingTask&&await this.close();const t=AppOptions.getAll(po);t.cspPolicyService=e.cspPolicyService;if(e.workerSrc&&e.workerSrc!==t.workerSrc){t.workerSrc=e.workerSrc;this.pdfWorker=null}Object.assign(GlobalWorkerOptions,t);t.port=t.port??GlobalWorkerOptions.workerPort;t.cspPolicyService=this.cspPolicyService;null===this.pdfWorker&&(this.pdfWorker=t.port?PDFWorker.fromPort(t):new PDFWorker(t));e.data&&isPdfFile(e.filename)?this._contentDispositionFilename=e.filename:e.url&&this.setTitleUsingUrl(e.originalUrl||e.url,e.url);const i=getDocument({...AppOptions.getAll(uo),...e,worker:this.pdfWorker,cspPolicyService:e.cspPolicyService});this.pdfLoadingTask=i;i.onPassword=(e,t)=>{this.isViewerEmbedded&&this._unblockDocumentLoadEvent();this.pdfLinkService.externalLinkEnabled=!1;this.passwordPrompt.setUpdateCallback(e,t);this.passwordPrompt.open()};i.onProgress=e=>{this.progress(e.percent);this.eventBus?.dispatch("progress",{source:this,type:"load",total:e.total,loaded:e.loaded,percent:e.percent})};const a=this.serviceWorkerOptions.showUnverifiedSignatures;return i.promise.then(e=>{e._transport.messageHandler.send("showUnverifiedSignatures",a);this.load(e)},e=>{if(i!==this.pdfLoadingTask)return;this.loadingBar&&(this.loadingBar.percent||=0);let t="pdfjs-loading-error";e instanceof InvalidPDFException?t="pdfjs-invalid-file-error":e instanceof ResponseException&&(t=e.missing?"pdfjs-missing-file-error":"pdfjs-unexpected-response-error");wb.onError&&wb.onError(e);return this._documentError(t,{message:e.message}).then(()=>{throw e})})},async download(){if(!this.downloadManager)return;let e;try{e=await(this.pdfDocument?this.pdfDocument.getData():this.pdfLoadingTask.getData())}catch{}this.downloadManager.download(e,this._downloadUrl,this._docFilename,this._isMergedDocument)},async save(e=null){if(!this.downloadManager)return;if(this._saveInProgress)return;this._saveInProgress=!0;const{pdfDocument:t}=this;try{await this.pdfScriptingManager.dispatchWillSave();const i=await t.saveDocument(this.externalServices.printToPDF,e);this.downloadManager.download(i,this._downloadUrl,this._docFilename,!0)}catch(e){ngx_console_NgxConsole.error("Error when saving the document:",e);t===this.pdfDocument&&await this.download()}finally{try{t===this.pdfDocument&&await this.pdfScriptingManager.dispatchDidSave()}finally{this._saveInProgress=!1}}const i=this.pdfDocument?.annotationStorage.editorStats;i&&this.externalServices.reportTelemetry({type:"editing",data:{type:"save",stats:i}})},async downloadOrSave(){if(!this.downloadManager)return;this.pdfViewer._layerProperties.annotationEditorUIManager?.endCurrentEditing();const{classList:e}=this.appConfig.appContainer;e.add("wait");try{if(this.pdfThumbnailViewer?.hasStructuralChanges()){this.externalServices.reportTelemetry({type:"pageOrganization",data:{action:"save"}});await this.onSavePages({data:this.pdfThumbnailViewer.getStructuralChanges()})}else{const e=this.pdfDocument?.annotationStorage.size>0||!this.pageOrder.every((e,t,i)=>0===t||e>=i[t-1]);await(e?this.save(this.pageOrder):this.download())}delete this._mergedDocumentNeedsSaving}finally{this.setTitle();e.remove("wait")}},movePageUp(e){if(!(e.source.pageNumber<=1)){this.pdfViewer.swapPages(e.source.pageNumber-1,e.source.pageNumber-2);this.pdfThumbnailViewer.swapThumbnails(e.source.pageNumber-1,e.source.pageNumber-2);this.page=e.source.pageNumber-1;[this.pageOrder[e.source.pageNumber-2],this.pageOrder[e.source.pageNumber-1]]=[this.pageOrder[e.source.pageNumber-1],this.pageOrder[e.source.pageNumber-2]]}},movePageDown(e){if(e.source.pageNumber!==this.pdfDocument.numPages){this.pdfViewer.swapPages(e.source.pageNumber-1,e.source.pageNumber);this.pdfThumbnailViewer.swapThumbnails(e.source.pageNumber-1,e.source.pageNumber);this.page=e.source.pageNumber+1;[this.pageOrder[e.source.pageNumber-1],this.pageOrder[e.source.pageNumber]]=[this.pageOrder[e.source.pageNumber],this.pageOrder[e.source.pageNumber-1]]}},movePage(e,t){if(e<1||e>this.pdfDocument.numPages||t<1||t>this.pdfDocument.numPages)return;const i=e-1,a=t-1;if(i<a)for(let e=i;e<a;e++){this.pdfViewer.swapPages(e,e+1);this.pdfThumbnailViewer.swapThumbnails(e,e+1);[this.pageOrder[e],this.pageOrder[e+1]]=[this.pageOrder[e+1],this.pageOrder[e]]}else if(i>a)for(let e=i;e>a;e--){this.pdfViewer.swapPages(e,e-1);this.pdfThumbnailViewer.swapThumbnails(e,e-1);[this.pageOrder[e],this.pageOrder[e-1]]=[this.pageOrder[e-1],this.pageOrder[e]]}this.page=t},async _exportWithAnnotations(){if(this._saveInProgress)throw new Error("Already downloading");this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();try{this._ensureDownloadComplete();const e=await this.pdfDocument.saveDocument();return new Blob([e],{type:"application/pdf"})}catch(e){throw new Error(`Error when saving the document: ${e.message}`)}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}},_ensureDownloadComplete(){if(!this.pdfDocument)throw new Error("PDF document not downloaded.")},async _exportWithoutAnnotations(){try{this._ensureDownloadComplete();const e=await this.pdfDocument.getData();return new Blob([e],{type:"application/pdf"})}catch(e){throw new Error(`Error when saving the document: ${e.message}`)}},async export(){return this.pdfDocument?.annotationStorage.size>0?this._exportWithAnnotations():this._exportWithoutAnnotations()},openInExternalApp(){this.downloadOrSave({openInExternalApp:!0})},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),a=[`PDF.js v${Zo||"?"} (build: ${Qo||"?"})`];if(t){a.push(`Message: ${t.message}`);if(t.stack)a.push(`Stack: ${t.stack}`);else{t.filename&&a.push(`File: ${t.filename}`);t.lineNumber&&a.push(`Line: ${t.lineNumber}`)}}ngx_console_NgxConsole.error(`${i}\n\n${a.join("\n")}`);return i},progress(e){if(this.loadingBar&&!(e<=this.loadingBar.percent)){this.loadingBar.percent=e;(this.pdfDocument?.loadingParams.disableAutoFetch??AppOptions.get("disableAutoFetch"))&&this.loadingBar.setDisableAutoFetch()}},load(e){this.pdfDocument=e;this._printPermissionPromise=new Promise(e=>{this.eventBus.on("printingallowed",({isAllowed:t})=>{e(t)},{once:!0,...lu})});e.getDownloadInfo().then(({length:e})=>{this._contentLength=e;this.loadingBar?.hide();r.then(()=>{this.eventBus?.dispatch("documentloaded",{source:this})})});const t=e.getPageLayout().catch(()=>{}),i=e.getPageMode().catch(()=>{}),a=e.getOpenAction().catch(()=>{});this.toolbar?.setPagesCount(e.numPages,!1);this.secondaryToolbar?.setPagesCount(e.numPages);this.pdfLinkService.setDocument(e);this.pdfDocumentProperties?.setDocument(e);const s=this.pdfViewer;s.setDocument(e);const{firstPagePromise:r,onePageRendered:n,pagesPromise:o}=s;this.pdfThumbnailViewer?.setDocument(e);const l=(this.store=new ViewHistory(e.fingerprints[0])).getMultiple({page:null,zoom:"auto",scrollLeft:"0",scrollTop:"0",rotation:null,sidebarView:R_,scrollMode:$_.UNKNOWN,spreadMode:X_.UNKNOWN}).catch(()=>{});r.then(r=>{this.loadingBar?.setWidth(this.appConfig.viewerContainer);this._initializeAnnotationStorageCallbacks(e);Promise.all([eu,l,t,i,a]).then(async([t,i,a,r,n])=>{const l=AppOptions.get("viewOnLoad");this._initializePdfHistory({fingerprint:e.fingerprints[0],viewOnLoad:l,initialDest:n?.get("dest")});const d=this.initialBookmark;let c=AppOptions.get("defaultZoomValue");if(!c||""===c)try{({zoom:c}=await this.store.getMultiple({zoom:void 0}));"string"==typeof c&&(c=c?.replace("%",""));isNaN(Number(c))||(c=Number(c)/100)}catch(e){}!s.currentScaleValue&&c&&""!==c&&(s.currentScaleValue=c);let h=c?`zoom=${c}`:null,_=null,u=AppOptions.get("sidebarViewOnLoad"),p=AppOptions.get("scrollModeOnLoad"),g=AppOptions.get("spreadModeOnLoad");this.eventBus&&this.eventBus.dispatch("storedvaluesavailable",{source:this,fingerprint:e.fingerprints[0],storedZoom:i?.zoom,storedPage:i?.page,defaultZoom:AppOptions.get("defaultZoomValue")});if(i?.page&&l!==Pb){h=`page=${i.page}&zoom=${c||i.zoom},${i.scrollLeft},${i.scrollTop}`;_=parseInt(i.rotation,10);u===R_&&(u=0|i.sidebarView);p===$_.UNKNOWN&&(p=0|i.scrollMode);g===X_.UNKNOWN&&(g=0|i.spreadMode)}r&&u===R_&&(u=function apiPageModeToSidebarView(e){switch(e){case"UseNone":return O_;case"UseThumbs":return N_;case"UseOutlines":return W_;case"UseAttachments":return j_;case"UseOC":return V_}return O_}(r));if(a&&p===$_.UNKNOWN&&g===X_.UNKNOWN){g=apiPageLayoutToViewerModes(a).spreadMode}this.setInitialView(h,{rotation:_,sidebarView:u,scrollMode:p,spreadMode:g});this.eventBus.dispatch("documentinit",{source:this});await Promise.race([o,new Promise(e=>{setTimeout(e,10)})]);if((d||h)&&!s.hasEqualPageSizes){this.initialBookmark=d;s.currentScaleValue=s.currentScaleValue;this.setInitialView(h)}}).catch(()=>{this.setInitialView()}).then(function(){s.update()})});o.then(()=>{this._unblockDocumentLoadEvent();this._initializeAutoPrint(e,a)},e=>{wb.onError&&wb.onError(e);this._documentError("pdfjs-loading-error",{message:e.message})});n.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})},t=>{if(e===this.pdfDocument){console.error("getOutline",t);this.pdfOutlineViewer.render({outline:null,pdfDocument:e})}});this.pdfAttachmentViewer&&e.getAttachments().then(t=>{e===this.pdfDocument&&this.pdfAttachmentViewer.render({attachments:t})},t=>{if(e===this.pdfDocument){console.error("getAttachments",t);this.pdfAttachmentViewer.render({attachments:null})}});this.pdfLayerViewer&&s.optionalContentConfigPromise.then(t=>{e===this.pdfDocument&&this.pdfLayerViewer.render({optionalContentConfig:t,pdfDocument:e})})});this._initializePageLabels(e);this._initializeMetadata(e);this._initializePageOrder(e)},async _scriptingDocProperties(e){if(!this.documentInfo){await new Promise(e=>{this.eventBus.on("metadataloaded",e,{once:!0,...lu})});if(e!==this.pdfDocument)return null}if(!this._contentLength){await new Promise(e=>{this.eventBus.on("documentloaded",e,{once:!0,...lu})});if(e!==this.pdfDocument)return null}return{...this.documentInfo,baseURL:this.baseUrl,filesize:this._contentLength,filename:this._docFilename,metadata:this.metadata?.getRaw(),authors:this.metadata?.get("dc:creator"),numPages:this.pagesCount,URL:this.url}},async _initializeAutoPrint(e,t){const[i,a]=await Promise.all([t,this.pdfViewer.enableScripting?null:e.getJSActions()]);if(e!==this.pdfDocument)return;let s="Print"===i?.get("action");if(a){ngx_console_NgxConsole.warn("Warning: JavaScript support is not enabled");for(const[e,t]of a){if(s)break;switch(e){case"WillClose":case"WillSave":case"DidSave":case"WillPrint":case"DidPrint":continue}s=t.some(e=>Z_.test(e))}}s&&this.triggerPrinting()},async _initializeMetadata(e){const{info:t,metadata:i,contentDispositionFilename:a,contentLength:s,hasStructTree:r}=await e.getMetadata();if(e!==this.pdfDocument)return;this.externalServices.reportTelemetry({type:"taggedPDF",data:r});this.documentInfo=t;this.metadata=i;this._contentDispositionFilename??=a;this._contentLength??=s;AppOptions?.get("verbosity")>0&&ngx_console_NgxConsole.log(`PDF ${e.fingerprints[0]} [${t.PDFFormatVersion} ${(i?.get("pdf:producer")||t.Producer||"-").trim()} / ${(i?.get("xmp:creatortool")||t.Creator||"-").trim()}] (PDF.js: ${Zo||"?"} [${Qo||"?"}])  modified by ngx-extended-pdf-viewer 32.0.0`);const n=this._docTitle;n?this.setTitle(`${n} - ${this._contentDispositionFilename||this._title}`):this._contentDispositionFilename&&this.setTitle(this._contentDispositionFilename);!t.IsXFAPresent||t.IsAcroFormPresent||e.isPureXfa?!t.IsAcroFormPresent&&!t.IsXFAPresent||this.pdfViewer.renderForms||ngx_console_NgxConsole.warn("Warning: Interactive form support is not enabled"):e.loadingParams.enableXfa?ngx_console_NgxConsole.warn("Warning: XFA Foreground documents are not supported"):ngx_console_NgxConsole.warn("Warning: XFA support is not enabled");if(t.IsSignaturesPresent){this._maybeInitSignatureProperties(e)||ngx_console_NgxConsole.warn("Warning: Digital signatures validation is not supported")}this.eventBus.dispatch("metadataloaded",{source:this})},async _initializePageOrder(e){e===this.pdfDocument&&(this.pageOrder=Array.from({length:this.pdfDocument.numPages},(e,t)=>t+1))},_maybeInitSignatureProperties(e){if(!AppOptions.get("enableSignatureVerification"))return!1;const t=this.externalServices.createSignatureVerifier();if(!t)return!1;if(e!==this.pdfDocument)return!0;this.signaturePropertiesManager??=new SignaturePropertiesManager({appConfig:this.appConfig.toolbar,verifier:t,eventBus:this.eventBus});this.signaturePropertiesManager.setDocument(e);return!0},async _initializePageLabels(e){const t=await e.getPageLabels();if(e!==this.pdfDocument)return;if(!t||AppOptions.get("disablePageLabels"))return;const i=t.length;let a=0,s=0;for(let e=0;e<i;e++){const i=t[e];if(i===(e+1).toString())a++;else{if(""!==i)break;s++}}if(a>=i||s>=i)return;const{pdfViewer:r,pdfThumbnailViewer:n,toolbar:o}=this;r.setPageLabels(t);n?.setPageLabels(t);o?.setPagesCount(i,!0);o?.setPageNumber(r.currentPageNumber,r.currentPageLabel)},_initializePdfHistory({fingerprint:e,viewOnLoad:t,initialDest:i=null}){if(this.pdfHistory){this.pdfHistory.initialize({fingerprint:e,resetHistory:t===Pb||!!this._mergedDocumentNeedsSaving,updateUrl:AppOptions.get("historyUpdateUrl")});if(this.pdfHistory.initialBookmark){this.initialBookmark=this.pdfHistory.initialBookmark;this.initialRotation=this.pdfHistory.initialRotation}if(i&&!this.initialBookmark&&t===vb){this.initialBookmark=JSON.stringify(i);this.pdfHistory.push({explicitDest:i,pageNumber:null})}}},_hasChanges(){return this.pdfDocument?.annotationStorage.size>0||this.pdfThumbnailViewer?.hasStructuralChanges()||!0===this._mergedDocumentNeedsSaving},_initialAnnotationValues:null,_initializeAnnotationStorageCallbacks(e){if(e!==this.pdfDocument)return;const{annotationStorage:t}=e;t.onSetModified=()=>{this._annotationStorageModified=!0};t.onResetModified=()=>{delete this._annotationStorageModified;this._initialAnnotationValues=null};t.onAnnotationEditor=e=>{this._hasAnnotationEditors=!!e;this.setTitle()};this.eventBus._on("pagesloaded",()=>{setTimeout(()=>{this._captureInitialAnnotationValues()},200)})},_captureInitialAnnotationValues(){if(!this.pdfDocument?.annotationStorage)return;const e=this.pdfDocument.annotationStorage;this._initialAnnotationValues=new Map;for(const[t,i]of e)this._initialAnnotationValues.set(t,JSON.parse(JSON.stringify(i)))},setInitialAnnotationValues(){if(!this.pdfDocument?.annotationStorage)return;this._initialAnnotationValues=new Map;const e=this.pdfDocument.annotationStorage;for(const[t,i]of e)this._initialAnnotationValues.set(t,JSON.parse(JSON.stringify(i)))},_hasRealAnnotationChanges(){if(!this.pdfDocument?.annotationStorage||!this._initialAnnotationValues)return this._annotationStorageModified;const e=this.pdfDocument.annotationStorage,t=new Map;for(const[i,a]of e)t.set(i,a);if(t.size!==this._initialAnnotationValues.size)return!0;for(const[e,i]of t){const t=this._initialAnnotationValues.get(e);if(!t)return!0;if(JSON.stringify(i)!==JSON.stringify(t))return!0}for(const e of this._initialAnnotationValues.keys())if(!t.has(e))return!0;return!1},setInitialView(e,{rotation:t,sidebarView:i,scrollMode:a,spreadMode:s}={}){const setRotation=e=>{isValidRotation(e)&&(this.pdfViewer.pagesRotation=e)};this.isInitialViewSet=!0;this.viewsManager?.setInitialView(i);((e,t)=>{isValidScrollMode(e)&&(this.pdfViewer.scrollMode=e);isValidSpreadMode(t)&&(this.pdfViewer.spreadMode=t)})(a,s);if(this.initialBookmark){setRotation(this.initialRotation);delete this.initialRotation;this.pdfLinkService.setHash&&this.pdfLinkService.setHash(this.initialBookmark);this.initialBookmark=null}else if(e){setRotation(t);this.pdfLinkService.setHash&&this.pdfLinkService.setHash(e)}this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber,this.pdfViewer.currentPageLabel);this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);if(!this.pdfViewer.currentScaleValue){const e=AppOptions?.get("defaultZoomValue");e&&(this.pdfViewer.currentScaleValue=e)}},_cleanup(){if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}if(this.pdfDocument){this.pdfViewer.cleanup();this.pdfThumbnailViewer?.cleanup();this.pdfDocument.cleanup(AppOptions.get("fontExtraProperties"))}},forceRendering(){this.pdfRenderingQueue.printing=!!this.printService;this.pdfRenderingQueue.isThumbnailViewEnabled=this.viewsManager?.visibleView===N_;this.pdfRenderingQueue.renderHighestPriority()},beforePrint(){this._printAnnotationStoragePromise=this.pdfScriptingManager.dispatchWillPrint().catch(()=>{}).then(()=>this.pdfDocument?.annotationStorage.print);if(!this.printService)if(this.supportsPrinting&&this.pdfViewer.printingAllowed)if(this.pdfViewer.pageViewsReady){this.printService=PDFPrintServiceFactory.createPrintService({pdfDocument:this.pdfDocument,pagesOverview:this.pdfViewer.getPagesOverview(),printResolution:AppOptions.get("printResolution"),printAnnotationStoragePromise:this._printAnnotationStoragePromise,pageOrder:this.pageOrder,eventBus:this.pdfViewer.eventBus,cspPolicyService:this.cspPolicyService});this.forceRendering();this.setTitle();this.printService.layout();this._hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"print",stats:this.pdfDocument?.annotationStorage.editorStats}})}else this.l10n.get("pdfjs-printing-not-ready").then(e=>{window.alert(e)});else this._otherError("pdfjs-printing-not-supported")},afterPrint(){if(this._printAnnotationStoragePromise){this._printAnnotationStoragePromise.then(()=>{this.pdfScriptingManager.dispatchDidPrint()});this._printAnnotationStoragePromise=null}if(this.printService){this.printService.destroy();this.printService=null;this.pdfDocument?.annotationStorage.resetModified()}this.forceRendering();this.setTitle()},rotatePages(e){this.pdfViewer.pagesRotation+=e},requestPresentationMode(){this.pdfPresentationMode?.request()},async triggerPrinting(){this.supportsPrinting&&await this._printPermissionPromise&&this.printPdf()},bindEvents(){if(this._eventBusAC)return;const e={signal:(this._eventBusAC=new AbortController).signal,...lu},{eventBus:t,externalServices:i,pdfDocumentProperties:a,pdfViewer:s,preferences:r}=this;t.on("resize",onResize.bind(this),e);t.on("hashchange",onHashchange.bind(this),e);t.on("beforeprint",this.beforePrint.bind(this),e);t.on("afterprint",this.afterPrint.bind(this),e);t.on("pagerender",onPageRender.bind(this),e);t.on("pagerendered",onPageRendered.bind(this),e);t.on("updateviewarea",onUpdateViewarea.bind(this),e);t.on("pagechanging",onPageChanging.bind(this),e);t.on("scalechanging",onScaleChanging.bind(this),e);t.on("rotationchanging",onRotationChanging.bind(this),e);t.on("sidebarviewchanged",onSidebarViewChanged.bind(this),e);t.on("pagemode",onPageMode.bind(this),e);t.on("namedaction",onNamedAction.bind(this),e);t.on("toggleSidebar",function({visible:e}){this.viewsManager&&(e?this.viewsManager.open():this.viewsManager.close())}.bind(this),e);t.on("presentationmodechanged",e=>s.presentationModeState=e.state,e);t.on("presentationmode",this.requestPresentationMode.bind(this),e);t.on("switchannotationeditormode",e=>s.annotationEditorMode=e,e);t.on("print",this.triggerPrinting.bind(this),e);t.on("download",this.downloadOrSave.bind(this),e);t.on("movePageUp",this.movePageUp.bind(this),e);t.on("movePageDown",this.movePageDown.bind(this),e);t.on("firstpage",()=>this.page=1,e);t.on("lastpage",()=>this.page=this.pagesCount,e);t.on("nextpage",()=>s.nextPage(),e);t.on("previouspage",()=>s.previousPage(),e);t.on("zoomin",this.zoomIn.bind(this),e);t.on("zoomout",this.zoomOut.bind(this),e);t.on("zoomreset",this.zoomReset.bind(this),e);t.on("pagenumberchanged",onPageNumberChanged.bind(this),e);t.on("scalechanged",e=>s.currentScaleValue=e.value,e);t.on("rotatecw",this.rotatePages.bind(this,90),e);t.on("rotateccw",this.rotatePages.bind(this,-90),e);t.on("optionalcontentconfig",e=>s.optionalContentConfigPromise=e.promise,e);t.on("switchscrollmode",e=>s.scrollMode=e.mode,e);t.on("scrollmodechanged",onViewerModesChanged.bind(this,"scrollMode"),e);t.on("switchspreadmode",e=>s.spreadMode=e.mode,e);t.on("spreadmodechanged",onViewerModesChanged.bind(this,"spreadMode"),e);t.on("imagealttextsettings",onImageAltTextSettings.bind(this),e);t.on("documentproperties",()=>a?.open(),e);t.on("findfromurlhash",onFindFromUrlHash.bind(this),e);t.on("updatefindmatchescount",onUpdateFindMatchesCount.bind(this),e);t.on("updatefindcontrolstate",onUpdateFindControlState.bind(this),e);t.on("fileinputchange",onFileInputChange.bind(this),e);t.on("openfile",onOpenFile.bind(this),e);t.on("pagesedited",this.onPagesEdited.bind(this),e);t.on("saveextractedpages",this.onSavePages.bind(this),e);t.on("saveandload",this.onSaveAndLoad.bind(this),e)},bindWindowEvents(){if(this._windowAC)return;this._windowAC=new AbortController;const{eventBus:e,appConfig:{mainContainer:t},pdfViewer:i,_windowAC:{signal:a}}=this;this._touchManager=new TouchManager({container:window,isPinchingDisabled:()=>i.isInPresentationMode,isPinchingStopped:()=>this.overlayManager?.active,onPinchStart:()=>i.setTouchPinching(!0),onPinching:this.touchPinchCallback.bind(this),onPinchEnd:this.touchPinchEndCallback.bind(this),onPanning:this.touchPanCallback.bind(this),signal:a});!function addWindowResolutionChange(e=null){e&&i.refresh();window.matchMedia(`(resolution: ${OutputScale.pixelRatio}dppx)`).addEventListener("change",addWindowResolutionChange,{once:!0,signal:a})}();const s=this._getViewerElementById("viewerContainer");s?.addEventListener("wheel",onWheel.bind(this),{passive:!1,signal:a});window.addEventListener("click",onClick.bind(this),{signal:a});window.addEventListener("keydown",onKeyDown.bind(this),{signal:a});window.addEventListener("keyup",onKeyUp.bind(this),{signal:a});if(s){let i,a=t.clientWidth,s=t.clientHeight;this.resizeObserver=new ResizeObserver(r=>{const n=t.clientWidth,o=t.clientHeight;if(n!==a||o!==s){clearTimeout(i);i=setTimeout(()=>{t.offsetParent&&e.dispatch("resize",{source:t})},50);a=n;s=o}});this.resizeObserver.observe(t)}else window.addEventListener("resize",()=>e.dispatch("resize",{source:window}),{signal:a});window.addEventListener("hashchange",()=>{e.dispatch("hashchange",{source:window,hash:document.location.hash.substring(1)})},{signal:a});const isOwnPrintEvent=e=>!e.ngxPrintingApp||e.ngxPrintingApp===this;window.addEventListener("beforeprint",t=>isOwnPrintEvent(t)&&e.dispatch("beforeprint",{source:window}),{signal:a});window.addEventListener("afterprint",t=>isOwnPrintEvent(t)&&e.dispatch("afterprint",{source:window}),{signal:a});window.addEventListener("updatefromsandbox",t=>{e.dispatch("updatefromsandbox",{source:window,detail:t.detail,ngxSandbox:t.ngxSandbox})},{signal:a});window.addEventListener("beforeunload",onBeforeUnload.bind(this),{signal:a});if(!("onscrollend"in document.documentElement))return;({scrollTop:this._lastScrollTop,scrollLeft:this._lastScrollLeft}=t);let r,n;const scrollend=()=>{({scrollTop:this._lastScrollTop,scrollLeft:this._lastScrollLeft}=t);clearTimeout(r);if(this._isScrolling){n.abort();n=null;this._isScrolling=!1}};t.addEventListener("scroll",()=>{if(!this._isCtrlKeyDown&&(this._lastScrollTop!==t.scrollTop||this._lastScrollLeft!==t.scrollLeft)){if(!this._isScrolling){n=new AbortController;const e=AbortSignal.any([n.signal,a]);t.addEventListener("scrollend",scrollend,{signal:e});t.addEventListener("blur",scrollend,{signal:e});this._isScrolling=!0}clearTimeout(r);r=setTimeout(scrollend,100)}},{passive:!0,signal:a})},unbindEvents(){this._eventBusAC?.abort();this._eventBusAC=null},unbindWindowEvents(){this._touchManager?.destroy();this._windowAC?.abort();this._windowAC=null;this._touchManager=null},async testingClose(){this.unbindEvents();this.unbindWindowEvents();this._globalAbortController?.abort();this._globalAbortController=null;this.findBar?.close();await Promise.all([this.l10n?.destroy(),this.close()])},onPagesEdited(e){this.pdfViewer.onPagesEdited(e)},async onSavePages({data:{pageInfos:e,copyLevels:t}}){if(!this.downloadManager||!this.pdfDocument)return;const i=await this.pdfDocument.extractPages(e,t);i?this.downloadManager.download(i,this._downloadUrl,this._docFilename,!0):console.error("Something wrong happened when saving the edited PDF.\nPlease file a bug.")},async onSaveAndLoad({data:{pageInfos:e,copyLevels:t}}){if(!this.pdfDocument)return;const i=await this.pdfDocument.extractPages(e,t);if(!i){console.error("Something wrong happened when saving the edited PDF.\nPlease file a bug.");return}this._mergedDocumentNeedsSaving=!0;const a=this._downloadUrl;await this.open({data:i,filename:this._docFilename});this._downloadUrl=a;this._isMergedDocument=!0},_accumulateTicks(e,t){(this[t]>0&&e<0||this[t]<0&&e>0)&&(this[t]=0);this[t]+=e;const i=Math.trunc(this[t]);this[t]-=i;return i},_accumulateFactor(e,t,i){if(1===t)return 1;const a=MathClamp(e*t*this[i],this.pdfViewer?.minZoom??.1,this.pdfViewer?.maxZoom??25),s=Math.floor(1e3*a)/1e3;this[i]=a/s;return s/e},_unblockDocumentLoadEvent(){document.blockUnblockOnload?.(!1);this._unblockDocumentLoadEvent=()=>{}},get scriptingReady(){return this.pdfScriptingManager.ready}};PDFPrintServiceFactory.initGlobals(wb);{const e=new Set(["null","http://mozilla.github.io","https://mozilla.github.io"]);var validateFileURL=function(t){if(!t)return;const i=URL.parse(window.location)?.origin||"null";if(e.has(i))return;const a=URL.parse(t,window.location)?.origin;if(a===i)return;const s=new Error("file origin does not match viewer's");wb._documentError("pdfjs-loading-error",{message:s.message});wb.onError&&wb.onError(s);throw s},onFileInputChange=function(e){if(this.pdfViewer?.isInPresentationMode)return;const t=e.fileInput.files[0];this.open({url:URL.createObjectURL(t),originalUrl:encodeURIComponent(t.name)})},onOpenFile=function(e){this._openFileInput?.click()}}function onPageRender({pageNumber:e}){e===this.page&&this.toolbar?.updateLoadingIndicatorState(!0)}function onPageRendered({pageNumber:e,isDetailView:t,error:i}){e===this.page&&this.toolbar?.updateLoadingIndicatorState(!1);if(!t&&this.viewsManager?.visibleView===N_){const t=this.pdfViewer.getPageView(e-1),i=this.pdfThumbnailViewer?.getThumbnail(e-1);t&&i?.setImage(t)}i&&this._otherError("pdfjs-rendering-error",i)}function onPageMode({mode:e}){let t;switch(e){case"thumbs":t=N_;break;case"bookmarks":case"outline":t=W_;break;case"attachments":t=j_;break;case"layers":t=V_;break;case"none":t=O_;break;default:ngx_console_NgxConsole.error('Invalid "pagemode" hash parameter: '+e);return}this.viewsManager?.switchView(t,!0)}function onNamedAction(e){switch(e.action){case"GoToPage":this.appConfig.toolbar?.pageNumber.select();break;case"Find":this.supportsIntegratedFind||this.findBar?.toggle();break;case"Print":this.triggerPrinting();break;case"SaveAs":this.downloadOrSave()}}function onSidebarViewChanged({view:e}){this.pdfRenderingQueue.isThumbnailViewEnabled=e===N_;this.isInitialViewSet&&this.store?.setMultiple({sidebarView:e}).catch(()=>{})}function onUpdateViewarea({location:e}){if(this.isInitialViewSet){const t={};void 0===e.pageNumber&&null===e.pageNumber||(t.page=e.pageNumber);e.scale&&(t.zoom=e.scale);e.left&&(t.scrollLeft=e.left);e.top&&(t.scrollTop=e.top);void 0===e.rotation&&null===e.rotation||(t.rotation=e.rotation);wb.store?.setMultiple(t).catch(()=>{})}this.appConfig.secondaryToolbar&&(this.appConfig.secondaryToolbar.viewBookmarkButton.href=this.pdfLinkService.getAnchorUrl(e.pdfOpenParams))}function onViewerModesChanged(e,t){this.isInitialViewSet&&!this.pdfViewer.isInPresentationMode&&this.store?.setMultiple({[e]:t.mode}).catch(()=>{})}function onResize(e){const{pdfDocument:t,pdfViewer:i,pdfRenderingQueue:a}=this;if(a.printing&&window.matchMedia("print").matches)return;if(!t)return;const s=e?.sidebarToggle?i.currentPageNumber:0,r=i.currentScaleValue;"auto"!==r&&"page-fit"!==r&&"page-width"!==r||(i.currentScaleValue=r);i.update();s&&i.currentPageNumber!==s&&(i.currentPageNumber=s)}function onHashchange(e){const t=e.hash;t&&(this.isInitialViewSet?this.pdfHistory?.popStateInProgress||this.pdfLinkService.setHash&&this.pdfLinkService.setHash(t):this.initialBookmark=t)}function onPageNumberChanged(e){const{pdfViewer:t}=this;""!==e.value&&this.pdfLinkService.goToPage(e.value);e.value!==t.currentPageNumber.toString()&&e.value!==t.currentPageLabel&&this.toolbar?.setPageNumber(t.currentPageNumber,t.currentPageLabel)}function onImageAltTextSettings(){this.imageAltTextSettings?.open({enableGuessAltText:AppOptions.get("enableGuessAltText"),enableNewAltTextWhenAddingImage:AppOptions.get("enableNewAltTextWhenAddingImage")})}function onFindFromUrlHash(e){this.eventBus.dispatch("find",{source:e.source,type:"",query:e.query,caseSensitive:!1,entireWord:!1,highlightAll:!0,findPrevious:!1,matchDiacritics:!0})}function onUpdateFindMatchesCount({matchesCount:e}){this.supportsIntegratedFind?this.externalServices.updateFindMatchesCount(e):this.findBar?.updateResultsCount(e)}function onUpdateFindControlState({state:e,previous:t,entireWord:i,matchesCount:a,rawQuery:s}){this.supportsIntegratedFind?this.externalServices.updateFindControlState({result:e,findPrevious:t,entireWord:i,matchesCount:a,rawQuery:s}):this.findBar?.updateUIState(e,t,a)}function onScaleChanging(e){this.toolbar?.setPageScale(e.presetValue,e.scale);this.pdfViewer.update(e.noScroll);this.pdfViewer.updateBookModeScale(e);const{scrollTop:t,scrollLeft:i}=this.pdfViewer.container;this._lastScrollTop=t;this._lastScrollLeft=i}function onRotationChanging(e){this.pdfThumbnailViewer&&(this.pdfThumbnailViewer.pagesRotation=e.pagesRotation);this.forceRendering();this.pdfViewer.currentPageNumber=e.pageNumber}function onPageChanging({pageNumber:e,pageLabel:t}){this.toolbar?.setPageNumber(e,t);this.secondaryToolbar?.setPageNumber(e);this.viewsManager?.visibleView===N_&&this.pdfThumbnailViewer?.scrollThumbnailIntoView(e);const i=this.pdfViewer.getPageView(e-1);this.toolbar?.updateLoadingIndicatorState(i?.renderingState===Xf.RUNNING);const a=this._getViewerElementById("pageNumber");if(a){const e=new CustomEvent("page-change");a.dispatchEvent(e)}}function onWheel(e){const t=this._getViewerElementById("viewerContainer");if(!t)return;if(t.parentNode.querySelector(":hover")!==t)return;const{pdfViewer:i,supportsMouseWheelZoomCtrlKey:a,supportsMouseWheelZoomMetaKey:s,supportsPinchToZoom:r}=this;if(i.isInPresentationMode)return;const n=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(wb?.isKeyIgnored&&wb.isKeyIgnored(n,"WHEEL"))return;const o=e.deltaMode;let l=Math.exp(-e.deltaY/100);const d=e.ctrlKey&&!this._isCtrlKeyDown&&o===WheelEvent.DOM_DELTA_PIXEL&&0===e.deltaX&&(Math.abs(l-1)<.05||!1)&&0===e.deltaZ,c=[e.clientX,e.clientY];if(d||e.ctrlKey&&a||e.metaKey&&s){e.preventDefault();if(this._isScrolling||"hidden"===document.visibilityState||this.overlayManager.active)return;if(d&&r){l=this._accumulateFactor(i.currentScale,l,"_wheelUnusedFactor");this.updateZoom(null,l,c)}else{const t=normalizeWheelEventDirection(e);let i=0;if(o===WheelEvent.DOM_DELTA_LINE||o===WheelEvent.DOM_DELTA_PAGE)i=Math.abs(t)>=1?Math.sign(t):this._accumulateTicks(t,"_wheelUnusedTicks");else{const e=30;i=this._accumulateTicks(t/e,"_wheelUnusedTicks")}this.updateZoom(i,null,c)}}}function closeSecondaryToolbar({target:e}){if(!this.secondaryToolbar?.isOpen)return;const{toolbar:t,secondaryToolbar:i}=this.appConfig;if(this.pdfViewer.containsElement(e)||t?.container.contains(e)&&!i?.toolbar.contains(e)&&!i?.toggleButton.contains(e)){if(e&&e.parentElement===i.toggleButton)return;if(e&&e.parentElement&&e.parentElement.parentElement===i.toggleButton)return;this.secondaryToolbar.close()}}function closeEditorUndoBar(e){this.editorUndoBar?.isOpen&&this.appConfig.secondaryToolbar?.toolbar.contains(e.target)&&this.editorUndoBar.hide()}function closeSignatureProperties({target:e}){this.signaturePropertiesManager?.shouldCloseOnClick(e)&&this.signaturePropertiesManager.close()}function onBeforeUnload(e){if(this._hasChanges()){e.preventDefault();e.returnValue="";return!1}return!0}function onClick(e){closeSecondaryToolbar.call(this,e);closeEditorUndoBar.call(this,e);closeSignatureProperties.call(this,e)}function onKeyUp(e){"Control"===e.key&&(this._isCtrlKeyDown=!1)}function onKeyDown(e){if(!function isKeyForThisViewer(e,t){const i=e.appConfig?.appContainer?.closest("ngx-extended-pdf-viewer");if(!i)return!0;const a=t.target instanceof Element?t.target.closest("ngx-extended-pdf-viewer"):null;return a?a===i:i.hasAttribute("data-ngx-active-viewer")||!document.querySelector("ngx-extended-pdf-viewer[data-ngx-active-viewer]")}(this,e))return;this._isCtrlKeyDown="Control"===e.key;this.editorUndoBar?.isOpen&&9!==e.keyCode&&16!==e.keyCode&&(13!==e.keyCode&&32!==e.keyCode||getActiveOrFocusedElement()!==this.appConfig.editorUndoBar.undoButton)&&this.editorUndoBar.hide();if(this.overlayManager.active)return;const{eventBus:t,pdfViewer:i}=this,a=i.isInPresentationMode;let s=!1,r=!1;const n=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(wb.ngxKeyboardManager&&wb.ngxKeyboardManager.isKeyIgnored.bind(wb.ngxKeyboardManager)(n,e.keyCode))return;if(1===n||8===n||5===n||12===n)switch(e.keyCode){case 70:if(!this.supportsIntegratedFind&&!e.shiftKey){if(AppOptions.get("textLayerMode")!==U_){let e=!1;const t=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#primaryViewFind");t&&(e||=!t?.classList.contains("dummy-component"));const i=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#secondaryToolbarToggle");if(!i.hidden){const t=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#secondaryViewFind");t&&(e||=!t?.classList.contains("dummy-component"))}e&&this.findBar?.open()}s=!0}break;case 71:if(!this.supportsIntegratedFind){const{state:e}=this.findController;if(e){const i={source:window,type:"again",findPrevious:5===n||12===n};t.dispatch("find",{...e,...i})}s=!0}break;case 61:case 107:case 187:case 171:this.zoomIn();s=!0;break;case 173:case 109:case 189:this.zoomOut();s=!0;break;case 48:case 96:if(!a){setTimeout(()=>{this.zoomReset()});s=!1}break;case 38:if(a||this.page>1){this.page=1;s=!0;r=!0}break;case 40:if(a||this.page<this.pagesCount){this.page=this.pagesCount;s=!0;r=!0}}if(1===n||8===n)switch(e.keyCode){case 83:t.dispatch("download",{source:window});s=!0;break;case 79:t.dispatch("openfile",{source:window});s=!0}if(3===n||10===n)switch(e.keyCode){case 80:this.requestPresentationMode();s=!0;this.externalServices.reportTelemetry({type:"buttons",data:{id:"presentationModeKeyboard"}});break;case 71:if(this.appConfig.toolbar){this.appConfig.toolbar.pageNumber.select();s=!0}}if(s){r&&!a&&i.focus();e.preventDefault();return}const o=getActiveOrFocusedElement(),l=o?.tagName.toUpperCase();if(!("INPUT"===l||"TEXTAREA"===l||"SELECT"===l||"BUTTON"===l&&32===e.keyCode||o?.isContentEditable)||27===e.keyCode){if(0===n){let t=0,n=!1;switch(e.keyCode){case 38:if(this.supportsCaretBrowsingMode){this.moveCaret(!0,!1);s=!0;break}case 33:i.isVerticalScrollbarEnabled&&(n=!0);t=-1;break;case 8:a||(n=!0);t=-1;break;case 37:if(this.supportsCaretBrowsingMode)return;i.isHorizontalScrollbarEnabled&&(n=!0);case 75:case 80:t=-1;break;case 27:if(this.secondaryToolbar?.isOpen){this.secondaryToolbar.close();s=!0}if(this.signaturePropertiesManager?.isOpen){this.signaturePropertiesManager.close();s=!0}if(!this.supportsIntegratedFind&&this.findBar?.opened){this.findBar.close();s=!0}if(!s){if([this._getViewerElementById("editorHighlightParamsToolbar"),this._getViewerElementById("editorFreeTextParamsToolbar"),this._getViewerElementById("editorInkParamsToolbar"),this._getViewerElementById("editorStampParamsToolbar"),this._getViewerElementById("editorCommentParamsToolbar"),this._getViewerElementById("editorSignatureParamsToolbar")].find(e=>e&&!e.classList.contains("hidden"))){this.eventBus.dispatch("switchannotationeditormode",{source:this,mode:f.NONE});s=!0}}break;case 40:if(this.supportsCaretBrowsingMode){this.moveCaret(!1,!1);s=!0;break}case 34:i.isVerticalScrollbarEnabled&&(n=!0);t=1;break;case 32:a||(n=!0);t=1;break;case 39:if(this.supportsCaretBrowsingMode)return;i.isHorizontalScrollbarEnabled&&(n=!0);case 74:case 78:t=1;break;case 36:if(a||this.page>1){this.page=1;s=!0;r=!0}break;case 35:if(a||this.page<this.pagesCount){this.page=this.pagesCount;s=!0;r=!0}break;case 83:this.pdfCursorTools?.switchTool(K_);break;case 72:this.pdfCursorTools?.switchTool(q_);break;case 82:this.rotatePages(90);break;case 115:this.viewsManager?.toggle()}0!==t&&"rtl"===AppOptions.get("readingDirection")&&(t=-t);if(0!==t&&(!n||"page-fit"===i.currentScaleValue)){const{mainContainer:e}=this.appConfig;(function viewerIsAllowedToCaptureKeyEvent(e){let t=document.activeElement;const i=e.closest("ngx-extended-pdf-viewer");for(;t&&t!==document.body;){if(t===i)return!0;if(-1!==t.tabIndex)return!1;t=t.parentElement}return!0})(e)&&(t>0?i.nextPage():i.previousPage());s=!0}}if(4===n)switch(e.keyCode){case 32:if(!a&&"page-fit"!==i.currentScaleValue)break;i.previousPage();s=!0;break;case 38:this.moveCaret(!0,!0);s=!0;break;case 40:this.moveCaret(!1,!0);s=!0;break;case 82:this.rotatePages(-90)}r&&!i.containsElement(o)&&i.focus();s&&e.preventDefault()}}wb.printPdf=function printPdf(){if(this.enablePrint)if(jf)ngx_console_NgxConsole.warn("Ignored this.printPDF() because of a pending print job.");else{ensureOverlay().then(function(){jf&&Uf.open(Vf)});try{dispatchEvent("beforeprint")}finally{if(jf){const e=jf,t=document.createElement("div");t.id="printContainer";document.body.append(t);e.printContainer=t;jf.renderPages().then(function(){const t=getPrintElement("printServiceDialog");t&&t.classList.add("hidden");return e.performPrint()}).catch(()=>{}).then(()=>{e.active&&abort()})}else{ngx_console_NgxConsole.error("Expected print service to be initialized.");ensureOverlay().then(function(){Uf.closeIfActive(Vf)})}}}};wb.PDFPrintServiceFactory=PDFPrintServiceFactory;wb.ngxConsole=new ngx_console_NgxConsole;wb.serviceWorkerOptions={showUnverifiedSignatures:!1};const Fb={LinkTarget:du,RenderingStates:Xf,ScrollMode:$_,SpreadMode:X_};HTMLCollection.prototype[Symbol.iterator]||(HTMLCollection.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator]);"function"!=typeof window.CustomEvent&&(window.CustomEvent=function CustomEvent(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};const i=document.createEvent("CustomEvent");i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail);return i});function scopedDocument(e){return e?{body:document.body,getElementById:t=>e.querySelector(`#${CSS.escape(t)}`),getElementsByClassName:t=>e.getElementsByClassName(t)}:document}function webViewerLoad(e,{bindEditorButtons:t=!1,root:i}={}){const a=function getViewerConfiguration(e){const t=scopedDocument(e);return{appContainer:t.getElementsByClassName("body")[0]??t.body,principalContainer:t.getElementById("mainContainer"),mainContainer:t.getElementById("viewerContainer"),viewerContainer:t.getElementById("viewer"),viewerAlert:t.getElementById("viewer-alert"),toolbar:{container:t.getElementById("toolbarContainer"),numPages:t.getElementById("numPages"),pageNumber:t.getElementById("pageNumber"),scaleSelect:t.getElementById("scaleSelect"),customScaleOption:t.getElementById("customScaleOption"),previous:t.getElementById("previous"),next:t.getElementById("next"),zoomIn:t.getElementById("primaryZoomIn")??t.getElementById("zoomInButton"),zoomOut:t.getElementById("primaryZoomOut")??t.getElementById("zoomOutButton"),print:t.getElementById("printButton"),undo:t.getElementById("undoButton"),redo:t.getElementById("redoButton"),editorCommentButton:t.getElementById("editorCommentButton"),editorCommentParamsToolbar:t.getElementById("editorCommentParamsToolbar"),editorFreeTextButton:t.getElementById("primaryEditorFreeText")??t.getElementById("editorFreeTextButton"),editorFreeTextParamsToolbar:t.getElementById("editorFreeTextParamsToolbar"),editorHighlightButton:t.getElementById("primaryEditorHighlight")??t.getElementById("editorHighlightButton"),editorHighlightParamsToolbar:t.getElementById("editorHighlightParamsToolbar"),editorHighlightColorPicker:t.getElementById("editorHighlightColorPicker"),editorInkButton:t.getElementById("primaryEditorInk")??t.getElementById("editorInkButton"),editorInkParamsToolbar:t.getElementById("editorInkParamsToolbar"),editorEraserButton:t.getElementById("primaryEditorEraser")??t.getElementById("editorEraserButton"),editorEraserParamsToolbar:t.getElementById("editorEraserParamsToolbar"),editorStampButton:t.getElementById("primaryEditorStamp")??t.getElementById("editorStampButton"),presentationModeButton:t.getElementById("presentationMode"),editorStampParamsToolbar:t.getElementById("editorStampParamsToolbar"),editorSignatureButton:t.getElementById("primaryEditorSignatureButton")??t.getElementById("editorSignatureButton"),editorSignatureParamsToolbar:t.getElementById("editorSignatureParamsToolbar"),signaturePropertiesButton:t.getElementById("signaturePropertiesButton"),signaturePropertiesPanel:t.getElementById("signaturePropertiesPanel"),signaturePropertiesContainer:t.getElementById("signaturePropertiesContainer"),signaturePropertiesBanner:t.getElementById("signaturePropertiesBanner"),signaturePropertiesList:t.getElementById("signaturePropertiesList"),signaturePropertiesSeparator:t.getElementById("signaturePropertiesSeparator"),download:t.getElementById("downloadButton"),movePageUp:t.getElementById("movePageUpButton"),movePageDown:t.getElementById("movePageDownButton")},secondaryToolbar:{toolbar:t.getElementById("secondaryToolbar"),toggleButton:t.getElementById("secondaryToolbarToggle"),presentationModeButton:t.getElementById("secondaryPresentationMode"),openFileButton:t.getElementById("secondaryOpenFile"),printButton:t.getElementById("secondaryPrintButton"),downloadButton:t.getElementById("secondaryDownload"),viewBookmarkButton:t.getElementById("viewBookmark"),firstPageButton:t.getElementById("firstPage"),lastPageButton:t.getElementById("lastPage"),pageRotateCwButton:t.getElementById("pageRotateCw"),pageRotateCcwButton:t.getElementById("pageRotateCcw"),cursorSelectToolButton:t.getElementById("cursorSelectTool"),cursorHandToolButton:t.getElementById("cursorHandTool"),scrollPageButton:t.getElementById("scrollPage"),scrollVerticalButton:t.getElementById("scrollVertical"),scrollHorizontalButton:t.getElementById("scrollHorizontal"),scrollWrappedButton:t.getElementById("scrollWrapped"),spreadNoneButton:t.getElementById("spreadNone"),spreadOddButton:t.getElementById("spreadOdd"),spreadEvenButton:t.getElementById("spreadEven"),imageAltTextSettingsButton:t.getElementById("imageAltTextSettings"),imageAltTextSettingsSeparator:t.getElementById("imageAltTextSettingsSeparator"),documentPropertiesButton:globalThis.STANDALONE_VIEWER?t.getElementById("documentProperties"):null},viewsManager:{outerContainer:t.getElementById("outerContainer"),toggleButton:t.getElementById("viewsManagerToggleButton")??t.getElementById("primarySidebarToggle")??t.getElementById("sidebarToggleButton"),sidebarContainer:t.getElementById("viewsManager")??t.getElementById("sidebarContainer"),resizer:t.getElementById("viewsManagerResizer")??t.getElementById("sidebarResizer"),thumbnailButton:t.getElementById("thumbnailsViewMenu")??t.getElementById("viewThumbnail"),outlineButton:t.getElementById("outlinesViewMenu")??t.getElementById("viewOutline"),attachmentsButton:t.getElementById("attachmentsViewMenu")??t.getElementById("viewAttachments"),layersButton:t.getElementById("layersViewMenu")??t.getElementById("viewLayers"),viewsManagerSelectorButton:t.getElementById("viewsManagerSelectorButton"),viewsManagerSelectorOptions:t.getElementById("viewsManagerSelectorOptions"),thumbnailsView:t.getElementById("thumbnailsView")??t.getElementById("thumbnailView"),outlinesView:t.getElementById("outlinesView")??t.getElementById("outlineView"),attachmentsView:t.getElementById("attachmentsView"),layersView:t.getElementById("layersView"),viewsManagerAddFile:{button:t.getElementById("viewsManagerAddFileButton"),picker:t.getElementById("viewsManagerAddFilePicker")},viewsManagerCurrentOutlineButton:t.getElementById("viewsManagerCurrentOutlineButton")??t.getElementById("currentOutlineItem"),viewsManagerHeaderLabel:t.getElementById("viewsManagerHeaderLabel"),viewsManagerStatus:t.getElementById("viewsManagerStatus"),viewsManagerStatusBar:{viewsManagerStatusAction:t.getElementById("viewsManagerStatusAction"),viewsManagerStatusActionDeselectButton:t.getElementById("viewsManagerStatusActionDeselectButton"),viewsManagerStatusActionLabel:t.getElementById("viewsManagerStatusActionLabel")},viewsManagerUndoBar:{viewsManagerStatusUndo:t.getElementById("viewsManagerStatusUndo"),viewsManagerStatusUndoLabel:t.getElementById("viewsManagerStatusUndoLabel"),viewsManagerStatusUndoButton:t.getElementById("viewsManagerStatusUndoButton"),viewsManagerStatusUndoCloseButton:t.getElementById("viewsManagerStatusUndoCloseButton")},viewsManagerWaitingBar:{container:t.getElementById("viewsManagerStatusWaiting"),closeButton:t.getElementById("viewsManagerStatusWaitingCloseButton"),label:t.getElementById("viewsManagerStatusWaitingLabel")},manageMenu:{button:t.getElementById("viewsManagerStatusActionButton"),menu:t.getElementById("viewsManagerStatusActionOptions"),copy:t.getElementById("viewsManagerStatusActionCopy"),cut:t.getElementById("viewsManagerStatusActionCut"),delete:t.getElementById("viewsManagerStatusActionDelete"),exportSelected:t.getElementById("viewsManagerStatusActionExport")}},findBar:{bar:t.getElementById("findbar"),toggleButton:t.getElementById("primaryViewFind")??t.getElementById("viewFindButton"),findField:t.getElementById("findInput"),highlightAllCheckbox:t.getElementById("findHighlightAll"),caseSensitiveCheckbox:t.getElementById("findMatchCase"),findMultipleCheckbox:t.getElementById("findMultiple"),matchRegExpCheckbox:t.getElementById("matchRegExp"),matchDiacriticsCheckbox:t.getElementById("findMatchDiacritics"),entireWordCheckbox:t.getElementById("findEntireWord"),findMsg:t.getElementById("findMsg"),findResultsCount:t.getElementById("findResultsCount"),findPreviousButton:t.getElementById("findPreviousButton")??t.getElementById("findPrevious"),findNextButton:t.getElementById("findNextButton")??t.getElementById("findNext")},passwordOverlay:{dialog:t.getElementById("passwordDialog"),label:t.getElementById("passwordText"),input:t.getElementById("password"),submitButton:t.getElementById("passwordSubmit"),cancelButton:t.getElementById("passwordCancel")},documentProperties:{dialog:t.getElementById("documentPropertiesDialog"),closeButton:t.getElementById("documentPropertiesClose"),fields:{fileName:t.getElementById("fileNameField"),fileSize:t.getElementById("fileSizeField"),title:t.getElementById("titleField"),author:t.getElementById("authorField"),subject:t.getElementById("subjectField"),keywords:t.getElementById("keywordsField"),creationDate:t.getElementById("creationDateField"),modificationDate:t.getElementById("modificationDateField"),creator:t.getElementById("creatorField"),producer:t.getElementById("producerField"),version:t.getElementById("versionField"),pageCount:t.getElementById("pageCountField"),pageSize:t.getElementById("pageSizeField"),linearized:t.getElementById("linearizedField")}},altTextDialog:{dialog:t.getElementById("altTextDialog"),optionDescription:t.getElementById("descriptionButton"),optionDecorative:t.getElementById("decorativeButton"),textarea:t.getElementById("descriptionTextarea"),cancelButton:t.getElementById("altTextCancel"),saveButton:t.getElementById("altTextSave")},newAltTextDialog:{dialog:t.getElementById("newAltTextDialog"),title:t.getElementById("newAltTextTitle"),descriptionContainer:t.getElementById("newAltTextDescriptionContainer"),textarea:t.getElementById("newAltTextDescriptionTextarea"),disclaimer:t.getElementById("newAltTextDisclaimer"),learnMore:t.getElementById("newAltTextLearnMore"),imagePreview:t.getElementById("newAltTextImagePreview"),createAutomatically:t.getElementById("newAltTextCreateAutomatically"),createAutomaticallyButton:t.getElementById("newAltTextCreateAutomaticallyButton"),downloadModel:t.getElementById("newAltTextDownloadModel"),downloadModelDescription:t.getElementById("newAltTextDownloadModelDescription"),error:t.getElementById("newAltTextError"),errorCloseButton:t.getElementById("newAltTextCloseButton"),cancelButton:t.getElementById("newAltTextCancel"),notNowButton:t.getElementById("newAltTextNotNow"),saveButton:t.getElementById("newAltTextSave")},altTextSettingsDialog:{dialog:t.getElementById("altTextSettingsDialog"),createModelButton:t.getElementById("createModelButton"),learnMore:t.getElementById("altTextSettingsLearnMore"),showAltTextDialogButton:t.getElementById("showAltTextDialogButton"),altTextSettingsCloseButton:t.getElementById("altTextSettingsCloseButton"),closeButton:t.getElementById("altTextSettingsCloseButton")},addSignatureDialog:{dialog:t.getElementById("addSignatureDialog"),panels:t.getElementById("addSignatureActionContainer"),typeButton:t.getElementById("addSignatureTypeButton"),typeInput:t.getElementById("addSignatureTypeInput"),drawButton:t.getElementById("addSignatureDrawButton"),drawSVG:t.getElementById("addSignatureDraw"),drawPlaceholder:t.getElementById("addSignatureDrawPlaceholder"),drawThickness:t.getElementById("addSignatureDrawThickness"),imageButton:t.getElementById("addSignatureImageButton"),imageSVG:t.getElementById("addSignatureImage"),imagePlaceholder:t.getElementById("addSignatureImagePlaceholder"),imagePicker:t.getElementById("addSignatureFilePicker"),imagePickerLink:t.getElementById("addSignatureImageBrowse"),description:t.getElementById("addSignatureDescription"),clearButton:t.getElementById("clearSignatureButton"),saveContainer:t.getElementById("addSignatureSaveContainer"),saveCheckbox:t.getElementById("addSignatureSaveCheckbox"),errorBar:t.getElementById("addSignatureError"),errorTitle:t.getElementById("addSignatureErrorTitle"),errorDescription:t.getElementById("addSignatureErrorDescription"),errorCloseButton:t.getElementById("addSignatureErrorCloseButton"),cancelButton:t.getElementById("addSignatureCancelButton"),addButton:t.getElementById("addSignatureAddButton")},editSignatureDialog:{dialog:t.getElementById("editSignatureDescriptionDialog"),description:t.getElementById("editSignatureDescription"),editSignatureView:t.getElementById("editSignatureView"),cancelButton:t.getElementById("editSignatureCancelButton"),updateButton:t.getElementById("editSignatureUpdateButton")},annotationEditorParams:{editorCommentsSidebar:t.getElementById("editorCommentsSidebar"),editorCommentsSidebarCount:t.getElementById("editorCommentsSidebarCount"),editorCommentsSidebarTitle:t.getElementById("editorCommentsSidebarTitle"),editorCommentsSidebarCloseButton:t.getElementById("editorCommentsSidebarCloseButton"),editorCommentsSidebarList:t.getElementById("editorCommentsSidebarList"),editorCommentsSidebarResizer:t.getElementById("editorCommentsSidebarResizer"),editorFreeTextFontSize:t.getElementById("editorFreeTextFontSize"),editorFreeTextColor:t.getElementById("editorFreeTextColor"),editorInkColor:t.getElementById("editorInkColor"),editorInkThickness:t.getElementById("editorInkThickness"),editorInkOpacity:t.getElementById("editorInkOpacity"),editorEraserThickness:t.getElementById("editorEraserThickness"),editorStampAddImage:t.getElementById("editorStampAddImage"),editorSignatureAddSignature:t.getElementById("editorSignatureAddSignature"),editorFreeHighlightThickness:t.getElementById("editorFreeHighlightThickness"),editorHighlightShowAll:t.getElementById("editorHighlightShowAll")},editorUndoBar:{container:t.getElementById("editorUndoBar"),message:t.getElementById("editorUndoBarMessage"),undoButton:t.getElementById("editorUndoBarUndoButton"),closeButton:t.getElementById("editorUndoBarCloseButton")},editCommentDialog:{dialog:t.getElementById("commentManagerDialog"),toolbar:t.getElementById("commentManagerToolbar"),title:t.getElementById("commentManagerTitle"),textInput:t.getElementById("commentManagerTextInput"),cancelButton:t.getElementById("commentManagerCancelButton"),saveButton:t.getElementById("commentManagerSaveButton")}}}(i);a.toolbar.bindEditorButtons=t;const s=new CustomEvent("webviewerloaded",{bubbles:!0,cancelable:!0,detail:{source:window}});document.dispatchEvent(s);a.cspPolicyService=e;wb.run(a)}document.blockUnblockOnload?.(!0);if(globalThis.STANDALONE_VIEWER){const loadStandaloneViewer=()=>webViewerLoad(void 0,{bindEditorButtons:!0});"interactive"===document.readyState||"complete"===document.readyState?loadStandaloneViewer():document.addEventListener("DOMContentLoaded",loadStandaloneViewer,!0)}const yb=new CustomEvent("ngxViewerFileHasBeenLoaded",{detail:{PDFViewerApplication:wb,PDFViewerApplicationConstants:Fb,PDFViewerApplicationOptions:AppOptions,webViewerLoad}});document.dispatchEvent(yb);export{wb as PDFViewerApplication,Fb as PDFViewerApplicationConstants,AppOptions as PDFViewerApplicationOptions,webViewerLoad};