1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2285],{91100:(t,e,i)=>{let s;i.d(e,{EA:()=>iZ,YE:()=>i0});var a=i(77836),r=i(48287).Buffer,n={};n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o=globalThis.pdfjsLib={};n.d(o,{AbortException:()=>B,AnnotationEditorLayer:()=>iQ,AnnotationEditorParamsType:()=>g,AnnotationEditorType:()=>p,AnnotationEditorUIManager:()=>tI,AnnotationLayer:()=>iH,AnnotationMode:()=>u,CMapCompressionType:()=>_,ColorPicker:()=>iW,DOMSVGFactory:()=>tl,DrawLayer:()=>iJ,FeatureTest:()=>$,GlobalWorkerOptions:()=>eh,ImageKind:()=>b,InvalidPDFException:()=>D,MissingPDFException:()=>F,OPS:()=>w,Outliner:()=>i$,PDFDataRangeTransport:()=>e1,PDFDateString:()=>tA,PDFWorker:()=>e4,PasswordResponses:()=>x,PermissionFlag:()=>m,PixelsPerInch:()=>ti,RenderingCancelledException:()=>td,TextLayer:()=>eG,UnexpectedResponseException:()=>O,Util:()=>G,VerbosityLevel:()=>y,XfaLayer:()=>il,build:()=>is,createValidAbsoluteUrl:()=>k,fetchData:()=>tr,getDocument:()=>eJ,getFilenameFromUrl:()=>tp,getPdfFilenameFromUrl:()=>tg,getXfaPageViewport:()=>ty,isDataScheme:()=>tc,isPdfFile:()=>tu,noContextMenu:()=>tb,normalizeUnicode:()=>W,renderTextLayer:()=>eV,setLayerDimensions:()=>tE,shadow:()=>L,updateTextLayer:()=>eq,version:()=>ii});let l="object"==typeof a&&a+""=="[object process]"&&!a.versions.nw&&!(a.versions.electron&&a.type&&"browser"!==a.type),h=[1,0,0,1,0,0],d=[.001,0,0,.001,0,0],c={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},u={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},p={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},g={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},m={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},f={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},b={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},v={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,WIDGET:20},A={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},y={ERRORS:0,WARNINGS:1,INFOS:5},_={NONE:0,BINARY:1}
1,w={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},x={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},E=y.WARNINGS;function C(t){E>=y.INFOS&&console.log(`Info: ${t}`)}function S(t){E>=y.WARNINGS&&console.log(`Warning: ${t}`)}function T(t){throw Error(t)}function M(t,e){t||T(e)}function k(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var s;s=t,t=decodeURIComponent(escape(s))}catch{}}let a=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(a))return a}catch{}return null}function L(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}let P=function(){function t(e,i){this.constructor===t&&T("Cannot initialize BaseException."),this.message=e,this.name=i}return t.prototype=Error(),t.constructor=t,t}();class R extends P{constructor(t,e){super(t,"PasswordException"),this.code=e}}class I extends P{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class D extends P{constructor(t){super(t,"InvalidPDFException")}}class F extends P{constructor(t){super(t,"MissingPDFException")}}class O extends P{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class N extends P{constructor(t){super(t,"FormatError")}}class B extends P{constructor(t){super(t,"AbortException")}}function H(t){("object"!=typeof t||t?.length===void 0)&&T("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let s=0;s<e;s+=8192){let a=Math.min(s+8192,e),r=t.subarray(s,a);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function z(t){"string"!=typeof t&&T("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function U(t){let e=Object.create(null);for(let[i,s]of t)e[i]=s;return e}class ${static get isLittleEndian(){return L(this,"isLittleEndian",function(){let t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return L(this,"isEvalSupported",function(){try{return Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return L(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?L(this,"platform",{isMac:navigator.platform.includes("Mac")}):L(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return L(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let j=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class G{static makeHexColor(t,e,i){return`#${j[t]}${j[e]}${j[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){let i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){let i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),a=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],a[0],r[0]),Math.min(i[1],s[1],a[1],r[1]),Math.max(i[0],s[0],a[0],r[0]),Math.max(i[1],s[1],a[1],r[1])]}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){let e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],a=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],n=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-a*s))/2;return[Math.sqrt(n+o||1),Math.sqrt(n-o||1)]}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;let a=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return a>r?null:[i,a,s,r]}static #t(t,e,i,s,a,r,n,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*a+3*l*r)+3*c*n)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,s,a,r,n,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,s,a,r,n,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,a,r,n,o,(-h+p)/g,c),this.#t(t,e,i,s,a,r,n,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,a,r,n,o,l){return l?(l[0]=Math.min(l[0],t,n),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,n),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,n),Math.min(e,o),Math.max(t,n),Math.max(e,o)],this.#e(t,i,a,n,e,s,r,o,3*(-t+3*(i-a)+n),6*(t-2*i+a),3*(i-t),l),this.#e(t,i,a,n,e,s,r,o,3*(-e+3*(s-r)+o),6*(e-2*s+r),3*(s-e),l),l}}let V=null,q=null;function W(t){return V||(V=/([\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,q=new Map([["ï¬
","ſt"]])),t.replaceAll(V,(t,e,i)=>e?e.normalize("NFKC"):q.get(i))}let K="pdfjs_internal_id_",X={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class Y{constructor(){this.constructor===Y&&T("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,a){return"none"}destroy(t=!1){}}class Q{#i=!1;constructor({enableHWA:t=!1}={}){this.constructor===Q&&T("Cannot initialize BaseCanvasFactory."),this.#i=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#i})}}reset(t,e,i){if(!t.canvas)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){T("Abstract method `_createCanvas` called.")}}class J{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===J&&T("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":""),i=this.isCompressed?_.BINARY:_.NONE;return this._fetchData(e,i).catch(t=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){T("Abstract method `_fetchData` called.")}}class Z{constructor({baseUrl:t=null}){this.constructor===Z&&T("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetchData(e).catch(t=>{throw Error(`Unable to load font data at: ${e}`)})}_fetchData(t){T("Abstract method `_fetchData` called.")}}class tt{constructor(){this.constructor===tt&&T("Cannot initialize BaseSVGFactory.")}create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){T("Abstract method `_createSVG` called.")}}let te="http://www.w3.org/2000/svg";class ti{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class ts extends Y{#s;#a;#r;#n;#o;#l=0;constructor({docId:t,ownerDocument:e=globalThis.document}={}){super(),this.#r=t,this.#n=e}get #h(){return this.#s||=new Map}get #d(){return this.#o||=new Map}get #c(){if(!this.#a){let t=this.#n.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let i=this.#n.createElementNS(te,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#a=this.#n.createElementNS(te,"defs"),t.append(i),i.append(this.#a),this.#n.body.append(t)}return this.#a}#u(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,a=Array(256),r=Array(256),n=Array(256);for(let t=0;t<256;t++)a[t]=e[t]/255,r[t]=i[t]/255,n[t]=s[t]/255;return[a.join(","),r.join(","),n.join(",")]}addFilter(t){if(!t)return"none";let e=this.#h.get(t);if(e)return e;
1let[i,s,a]=this.#u(t),r=1===t.length?i:`${i}${s}${a}`;if(e=this.#h.get(r))return this.#h.set(t,e),e;let n=`g_${this.#r}_transfer_map_${this.#l++}`,o=`url(#${n})`;this.#h.set(t,o),this.#h.set(r,o);let l=this.#p(n);return this.#g(i,s,a,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",a=this.#d.get(s);if(a?.key===i||(a?(a.filter?.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},this.#d.set(s,a)),!t||!e))return a.url;let r=this.#m(t);t=G.makeHexColor(...r);let n=this.#m(e);if(e=G.makeHexColor(...n),this.#c.style.color="","#000000"===t&&"#ffffff"===e||t===e)return a.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#r}_hcm_filter`,d=a.filter=this.#p(h);this.#g(l,l,l,d),this.#f(d);let c=(t,e)=>{let i=r[t]/255,s=n[t]/255,a=Array(e+1);for(let t=0;t<=e;t++)a[t]=i+t/e*(s-i);return a.join(",")};return this.#g(c(0,5),c(1,5),c(2,5),d),a.url=`url(#${h})`,a.url}addAlphaFilter(t){let e=this.#h.get(t);if(e)return e;let[i]=this.#u([t]),s=`alpha_${i}`;if(e=this.#h.get(s))return this.#h.set(t,e),e;let a=`g_${this.#r}_alpha_map_${this.#l++}`,r=`url(#${a})`;this.#h.set(t,r),this.#h.set(s,r);let n=this.#p(a);return this.#b(i,n),r}addLuminosityFilter(t){let e,i,s=this.#h.get(t||"luminosity");if(s)return s;if(t?([e]=this.#u([t]),i=`luminosity_${e}`):i="luminosity",s=this.#h.get(i))return this.#h.set(t,s),s;let a=`g_${this.#r}_luminosity_map_${this.#l++}`,r=`url(#${a})`;this.#h.set(t,r),this.#h.set(i,r);let n=this.#p(a);return this.#v(n),t&&this.#b(e,n),r}addHighlightHCMFilter(t,e,i,s,a){let r=`${e}-${i}-${s}-${a}`,n=this.#d.get(t);if(n?.key===r||(n?(n.filter?.remove(),n.key=r,n.url="none",n.filter=null):(n={key:r,url:"none",filter:null},this.#d.set(t,n)),!e||!i))return n.url;let[o,l]=[e,i].map(this.#m.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,a].map(this.#m.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#c.style.color="";let p=(t,e,i)=>{let s=Array(256),a=(d-h)/i,r=t/255,n=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*a),i=r+t*n;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#r}_hcm_${t}_filter`,m=n.filter=this.#p(g);return this.#f(m),this.#g(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),n.url=`url(#${g})`,n.url}destroy(t=!1){t&&0!==this.#d.size||(this.#a&&(this.#a.parentNode.parentNode.remove(),this.#a=null),this.#s&&(this.#s.clear(),this.#s=null),this.#l=0)}#v(t){let e=this.#n.createElementNS(te,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#f(t){let e=this.#n.createElementNS(te,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#p(t){let e=this.#n.createElementNS(te,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#A(t,e,i){let s=this.#n.createElementNS(te,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#g(t,e,i,s){let a=this.#n.createElementNS(te,"feComponentTransfer");
1s.append(a),this.#A(a,"feFuncR",t),this.#A(a,"feFuncG",e),this.#A(a,"feFuncB",i)}#b(t,e){let i=this.#n.createElementNS(te,"feComponentTransfer");e.append(i),this.#A(i,"feFuncA",t)}#m(t){return this.#c.style.color=t,t_(getComputedStyle(this.#c).getPropertyValue("color"))}}class ta extends Q{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}async function tr(t,e="text"){if(tf(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let a=new XMLHttpRequest;a.open("GET",t,!0),a.responseType=e,a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(200===a.status||0===a.status){switch(e){case"arraybuffer":case"blob":case"json":i(a.response);return}i(a.responseText);return}s(Error(a.statusText))}},a.send(null)})}class tn extends J{_fetchData(t,e){return tr(t,this.isCompressed?"arraybuffer":"text").then(t=>({cMapData:t instanceof ArrayBuffer?new Uint8Array(t):z(t),compressionType:e}))}}class to extends Z{_fetchData(t){return tr(t,"arraybuffer").then(t=>new Uint8Array(t))}}class tl extends tt{_createSVG(t){return document.createElementNS(te,t)}}class th{constructor({viewBox:t,scale:e,rotation:i,offsetX:s=0,offsetY:a=0,dontFlip:r=!1}){let n,o,l,h,d,c,u,p;this.viewBox=t,this.scale=e,this.rotation=i,this.offsetX=s,this.offsetY=a;let g=(t[2]+t[0])/2,m=(t[3]+t[1])/2;switch((i%=360)<0&&(i+=360),i){case 180:n=-1,o=0,l=0,h=1;break;case 90:n=0,o=1,l=1,h=0;break;case 270:n=0,o=-1,l=-1,h=0;break;case 0:n=1,o=0,l=0,h=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(l=-l,h=-h),0===n?(d=Math.abs(m-t[1])*e+s,c=Math.abs(g-t[0])*e+a,u=(t[3]-t[1])*e,p=(t[2]-t[0])*e):(d=Math.abs(g-t[0])*e+s,c=Math.abs(m-t[1])*e+a,u=(t[2]-t[0])*e,p=(t[3]-t[1])*e),this.transform=[n*e,o*e,l*e,h*e,d-n*e*g-l*e*m,c-o*e*g-h*e*m],this.width=u,this.height=p}get rawDims(){let{viewBox:t}=this;return L(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:a=!1}={}){return new th({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:a})}convertToViewportPoint(t,e){return G.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){let e=G.applyTransform([t[0],t[1]],this.transform),i=G.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return G.applyInverseTransform([t,e],this.transform)}}class td extends P{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function tc(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function tu(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function tp(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function tg(t,e="document.pdf"){if("string"!=typeof t)return e;if(tc(t))return S('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t),a=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(a&&(a=a[0]).includes("%"))try{a=i.exec(decodeURIComponent(a))[0]}catch{}return a||e}class tm{started=Object.create(null);times=[];time(t){t in this.started&&S(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||S(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:t}of this.times)e=Math.max(t.length,e);for(let{name:i,start:s,end:a}of this.times)t.push(`${i.padEnd(e)} ${a-s}ms 2`);return t.join("")}}function tf(t,e){try{let{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function tb(t){t.preventDefault()}function tv(t){console.log("Deprecated API usage: "+t)}class tA{static toDateObject(t){if(!t||"string"!=typeof t)return null;let e=(s||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?")).exec(t);if(!e)return null;let i=parseInt(e[1],10),a=parseInt(e[2],10);a=a>=1&&a<=12?a-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let n=parseInt(e[4],10);n=n>=0&&n<=23?n:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;let h=e[7]||"Z",d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===h?(n+=d,o+=c):"+"===h&&(n-=d,o-=c),new Date(Date.UTC(i,a,r,n,o,l))}}function ty(t,{scale:e=1,rotation:i=0}){let{width:s,height:a}=t.attributes.style;return new th({viewBox:[0,0,parseInt(s),parseInt(a)],scale:e,rotation:i})}function t_(t){if(t.startsWith("#")){let e=parseInt(t.slice(1),16);return[(0xff0000&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(S(`Not a valid color format: "${t}"`),[0,0,0])}function tw(t){let{a:e,b:i,c:s,d:a,e:r,f:n}=t.getTransform();return[e,i,s,a,r,n]}function tx(t){let{a:e,b:i,c:s,d:a,e:r,f:n}=t.getTransform().invertSelf();return[e,i,s,a,r,n]}function tE(t,e,i=!1,s=!0){if(e instanceof th){let{pageWidth:s,pageHeight:a}=e.rawDims,{style:r}
2=t,n=$.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${a}px`,h=n?`round(${o}, 1px)`:`calc(${o})`,d=n?`round(${l}, 1px)`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}class tC{#y=null;#_=null;#w;#x=null;constructor(t){this.#w=t}render(){let t=this.#y=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#w._uiManager._signal;t.addEventListener("contextmenu",tb,{signal:e}),t.addEventListener("pointerdown",tC.#E,{signal:e});let i=this.#x=document.createElement("div");i.className="buttons",t.append(i);let s=this.#w.toolbarPosition;if(s){let{style:e}=t,i="ltr"===this.#w._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#C(),t}static #E(t){t.stopPropagation()}#S(t){this.#w._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#T(t){this.#w._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#M(t){let e=this.#w._uiManager._signal;t.addEventListener("focusin",this.#S.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#T.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",tb,{signal:e})}hide(){this.#y.classList.add("hidden"),this.#_?.hideDropdown()}show(){this.#y.classList.remove("hidden")}#C(){let t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#w.editorType}-button`),this.#M(t),t.addEventListener("click",t=>{this.#w._uiManager.delete()},{signal:this.#w._uiManager._signal}),this.#x.append(t)}get #k(){let t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#M(t),this.#x.prepend(t,this.#k)}addColorPicker(t){this.#_=t;let e=t.renderButton();this.#M(e),this.#x.prepend(e,this.#k)}remove(){this.#y.remove(),this.#_?.destroy(),this.#_=null}}class tS{#x=null;#y=null;#L;constructor(t){this.#L=t}#P(){let t=this.#y=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",tb,{signal:this.#L._signal});let e=this.#x=document.createElement("div");return e.className="buttons",t.append(e),this.#R(),t}#I(t,e){let i=0,s=0;for(let a of t){let t=a.y+a.height;if(t<i)continue;let r=a.x+(e?a.width:0);if(t>i){s=r,i=t;continue}e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){let[s,a]=this.#I(e,i),{style:r}=this.#y||=this.#P();t.append(this.#y),r.insetInlineEnd=`${100*s}%`,r.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#y.remove()}#R(){let t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let i=this.#L._signal;t.addEventListener("contextmenu",tb,{signal:i}),t.addEventListener("click",()=>{this.#L.highlightSelection("floating_button")},{signal:i}),this.#x.append(t)}}function tT(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class tM{#l=0;get id(){return`pdfjs_internal_editor_${this.#l++}`}}class tk{#D=(function(){if("undefined"!=typeof crypto&&"function"==typeof crypto?.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);if("undefined"!=typeof crypto&&"function"==typeof crypto?.getRandomValues)crypto.getRandomValues(t);else for(let e=0;e<32;e++)t[e]=Math.floor(255*Math.random());return H(t)})();#l=0;#h=null;static get _isSVGFittingCanvas(){let t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',L(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async #F(t,e){this.#h||=new Map;let i=this.#h.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#D}_${this.#l++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await tr(e,"blob")):t=i.file=e,"image/svg+xml"===t.type){let e=tk._isSVGFittingCanvas,s=new FileReader,a=new Image,r=new Promise((t,r)=>{a.onload=()=>
2{i.bitmap=a,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;a.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},a.onerror=s.onerror=r});s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){console.error(t),i=null}return this.#h.set(t,i),i&&this.#h.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:a}=t;return this.#F(`${e}_${i}_${s}_${a}`,t)}async getFromUrl(t){return this.#F(t,t)}async getFromId(t){this.#h||=new Map;let e=this.#h.get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){let e=this.#h.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#h||=new Map;let e=this.#h.get(t);e&&(e.refCounter-=1,0===e.refCounter&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#D}_`)}}class tL{#O=[];#N=!1;#B;#H=-1;constructor(t=128){this.#B=t}add({cmd:t,undo:e,post:i,mustExec:s,type:a=NaN,overwriteIfSameType:r=!1,keepUndo:n=!1}){if(s&&t(),this.#N)return;let o={cmd:t,undo:e,post:i,type:a};if(-1===this.#H){this.#O.length>0&&(this.#O.length=0),this.#H=0,this.#O.push(o);return}if(r&&this.#O[this.#H].type===a){n&&(o.undo=this.#O[this.#H].undo),this.#O[this.#H]=o;return}let l=this.#H+1;l===this.#B?this.#O.splice(0,1):(this.#H=l,l<this.#O.length&&this.#O.splice(l)),this.#O.push(o)}undo(){if(-1===this.#H)return;this.#N=!0;let{undo:t,post:e}=this.#O[this.#H];t(),e?.(),this.#N=!1,this.#H-=1}redo(){if(this.#H<this.#O.length-1){this.#H+=1,this.#N=!0;let{cmd:t,post:e}=this.#O[this.#H];t(),e?.(),this.#N=!1}}hasSomethingToUndo(){return -1!==this.#H}hasSomethingToRedo(){return this.#H<this.#O.length-1}destroy(){this.#O=null}}class tP{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=$.platform;for(let[i,s,a={}]of t)for(let t of i){let i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:a}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:a}),this.allKeys.add(t.split("+").at(-1)))}}#z(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let i=this.callbacks.get(this.#z(e));if(!i)return;let{callback:s,options:{bubbles:a=!1,args:r=[],checker:n=null}}=i;(!n||n(t,e))&&(s.bind(t,...r,e)(),a||(e.stopPropagation(),e.preventDefault()))}}class tR{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return!function(t){let e=document.createElement("span");for(let i of(e.style.visibility="hidden",document.body.append(e),t.keys())){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,t_(s))}e.remove()}(t),L(this,"_colors",t)}convert(t){let e=t_(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return tR._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?G.makeHexColor(...e):t}}class tI{#U=new AbortController;#$=null;#j=new Map;#G=new Map;#V=null;#q=null;#W=null;#K=new tL;#X=0;#Y=new Set;#Q=null;#J=null;#Z=new Set;#tt=!1;#te=null;#ti=null;#ts=null;#ta=!1;#tr=null;#tn=new tM;#to=!1;#tl=!1;#th=null;#td=null;#tc=null;#tu=p.NONE;#tp=new Set;#tg=null;#tm=null;#tf=null;#tb=this.blur.bind(this);#tv=this.focus.bind(this);#tA=this.copy.bind(this);#ty=this.cut.bind(this);#t_=this.paste.bind(this);#tw=this.keydown.bind(this);#tx=this.keyup.bind(this);#tE=this.onEditingAction.bind(this);#tC=this.onPageChanging.bind(this);#tS=this.onScaleChanging.bind(this);#tT=this.onRotationChanging.bind(this);#tM={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#tk=[0,0];#tL=null;#tP=null;#tR=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tI.prototype,e=t=>t.#tP.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>
2{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return L(this,"_keyboardManager",new tP([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tP.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tP.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:e}]]))}constructor(t,e,i,s,a,r,n,o,l){this._signal=this.#U.signal,this.#tP=t,this.#tR=e,this.#V=i,this._eventBus=s,this._eventBus._on("editingaction",this.#tE),this._eventBus._on("pagechanging",this.#tC),this._eventBus._on("scalechanging",this.#tS),this._eventBus._on("rotationchanging",this.#tT),this.#tI(),this.#tD(),this.#tF(),this.#q=a.annotationStorage,this.#te=a.filterFactory,this.#tm=r,this.#ts=n||null,this.#tt=o,this.#tc=l||null,this.viewParameters={realScale:ti.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){for(let t of(this.#U?.abort(),this.#U=null,this._signal=null,this._eventBus._off("editingaction",this.#tE),this._eventBus._off("pagechanging",this.#tC),this._eventBus._off("scalechanging",this.#tS),this._eventBus._off("rotationchanging",this.#tT),this.#G.values()))t.destroy();this.#G.clear(),this.#j.clear(),this.#Z.clear(),this.#$=null,this.#tp.clear(),this.#K.destroy(),this.#V?.destroy(),this.#tr?.hide(),this.#tr=null,this.#ti&&(clearTimeout(this.#ti),this.#ti=null),this.#tL&&(clearTimeout(this.#tL),this.#tL=null)}async mlGuess(t){return this.#tc?.guess(t)||null}get hasMLManager(){return!!this.#tc}get hcmFilter(){return L(this,"hcmFilter",this.#tm?this.#te.addHCMFilter(this.#tm.foreground,this.#tm.background):"none")}get direction(){return L(this,"direction",getComputedStyle(this.#tP).direction)}get highlightColors(){return L(this,"highlightColors",this.#ts?new Map(this.#ts.split(",").map(t=>t.split("=").map(t=>t.trim()))):null)}get highlightColorNames(){return L(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){this.#td=t}editAltText(t){this.#V?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#X=t-1}focusMainContainer(){this.#tP.focus()}findParent(t,e){for(let i of this.#G.values()){let{x:s,y:a,width:r,height:n}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=a&&e<=a+n)return i}return null}disableUserSelect(t=!1){this.#tR.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#Z.add(t)}removeShouldRescale(t){this.#Z.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*ti.PDF_TO_CSS_UNITS,this.#Z))e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tO({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){let e=document.getSelection();if(!e||e.isCollapsed)return;let{anchorNode:i,anchorOffset:s,focusNode:a,focusOffset:r}=e,n=e.toString(),o=this.#tO(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(l){for(let h of(e.empty(),this.#tu===p.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:p.HIGHLIGHT}
2),this.showAllEditors("highlight",!0,!0)),this.#G.values()))if(h.hasTextLayer(o)){h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:a,focusOffset:r,text:n});break}}}#tN(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tO(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#tr||=new tS(this),this.#tr.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#q||this.#q.has(t.id)||this.#q.setValue(t.id,t)}#tB(){let t=document.getSelection();if(!t||t.isCollapsed){this.#tg&&(this.#tr?.hide(),this.#tg=null,this.#tH({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e!==this.#tg){if(!this.#tO(t).closest(".textLayer")){this.#tg&&(this.#tr?.hide(),this.#tg=null,this.#tH({hasSelectedText:!1}));return}if(this.#tr?.hide(),this.#tg=e,this.#tH({hasSelectedText:!0}),(this.#tu===p.HIGHLIGHT||this.#tu===p.NONE)&&(this.#tu===p.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#ta=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this._signal,e=t=>{("pointerup"!==t.type||0===t.button)&&(window.removeEventListener("pointerup",e),window.removeEventListener("blur",e),"pointerup"===t.type&&this.#tz("main_toolbar"))};window.addEventListener("pointerup",e,{signal:t}),window.addEventListener("blur",e,{signal:t})}}}#tz(t=""){this.#tu===p.HIGHLIGHT?this.highlightSelection(t):this.#tt&&this.#tN()}#tI(){document.addEventListener("selectionchange",this.#tB.bind(this),{signal:this._signal})}#tU(){let t=this._signal;window.addEventListener("focus",this.#tv,{signal:t}),window.addEventListener("blur",this.#tb,{signal:t})}#t$(){window.removeEventListener("focus",this.#tv),window.removeEventListener("blur",this.#tb)}blur(){if(this.isShiftKeyDown=!1,this.#ta&&(this.#ta=!1,this.#tz("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#tp)if(e.div.contains(t)){this.#th=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#th)return;let[t,e]=this.#th;this.#th=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tF(){let t=this._signal;window.addEventListener("keydown",this.#tw,{signal:t}),window.addEventListener("keyup",this.#tx,{signal:t})}#tj(){window.removeEventListener("keydown",this.#tw),window.removeEventListener("keyup",this.#tx)}#tG(){let t=this._signal;document.addEventListener("copy",this.#tA,{signal:t}),document.addEventListener("cut",this.#ty,{signal:t}),document.addEventListener("paste",this.#t_,{signal:t})}#tV(){document.removeEventListener("copy",this.#tA),document.removeEventListener("cut",this.#ty),document.removeEventListener("paste",this.#t_)}#tD(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tF(),this.#tG()}removeEditListeners(){this.#tj(),this.#tV()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#J)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#J)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#$?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#tp){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#J)if(e.isHandlingMimeForPasting(t.type)){e.paste(t,this.currentLayer);return}let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){S(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=s.deserialize(e);if(!i)return;t.push(i)}this.addCommands({cmd:()=>{for(let e of t)this.#tq(e);this.#tW(t)}
2,undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){S(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#tu===p.NONE||this.isEditorHandlingKeyboard||tI._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#ta&&(this.#ta=!1,this.#tz("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#tH(t){Object.entries(t).some(([t,e])=>this.#tM[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#tM,t)}),this.#tu===p.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tK([[g.HIGHLIGHT_FREE,!0]]))}#tK(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tU(),this.#tG(),this.#tH({isEditing:this.#tu!==p.NONE,isEmpty:this.#tX(),hasSomethingToUndo:this.#K.hasSomethingToUndo(),hasSomethingToRedo:this.#K.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#t$(),this.#tV(),this.#tH({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#J)for(let e of(this.#J=t,this.#J))this.#tK(e.defaultPropertiesToUpdate)}getId(){return this.#tn.id}get currentLayer(){return this.#G.get(this.#X)}getLayer(t){return this.#G.get(t)}get currentPageIndex(){return this.#X}addLayer(t){this.#G.set(t.pageIndex,t),this.#to?t.enable():t.disable()}removeLayer(t){this.#G.delete(t.pageIndex)}updateMode(t,e=null,i=!1){if(this.#tu!==t){if(this.#tu=t,t===p.NONE){this.setEditingState(!1),this.#tY();return}for(let e of(this.setEditingState(!0),this.#tQ(),this.unselectAll(),this.#G.values()))e.updateMode(t);if(!e&&i){this.addNewEditorFromKeyboard();return}if(e){for(let t of this.#j.values())if(t.annotationElementId===e){this.setSelected(t),t.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#tu&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#J){switch(t){case g.CREATE:this.currentLayer.addNewEditor();return;case g.HIGHLIGHT_DEFAULT_COLOR:this.#td?.updateColor(e);break;case g.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#tf||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(let i of this.#tp)i.updateParams(t,e);for(let i of this.#J)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#j.values())i.editorType===t&&i.show(e);(this.#tf?.get(g.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tK([[g.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tl!==t)for(let e of(this.#tl=t,this.#G.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}#tQ(){if(!this.#to){for(let t of(this.#to=!0,this.#G.values()))t.enable();for(let t of this.#j.values())t.enable()}}#tY(){if(this.unselectAll(),this.#to){for(let t of(this.#to=!1,this.#G.values()))t.disable();for(let t of this.#j.values())t.disable()}}getEditors(t){let e=[];for(let i of this.#j.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#j.get(t)}addEditor(t){this.#j.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#ti&&clearTimeout(this.#ti),this.#ti=setTimeout(()=>{this.focusMainContainer(),this.#ti=null},0)),this.#j.delete(t.id),this.unselect(t),t.annotationElementId&&this.#Y.has(t.annotationElementId)||this.#q?.remove(t.id)}addDeletedAnnotationElement(t){this.#Y.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#Y.has(t)}removeDeletedAnnotationElement(t){this.#Y.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tq(t){let e=this.#G.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#$!==t&&(this.#$=t,t&&this.#tK(t.propertiesToUpdate))}get #tJ(){let t=null;for(t of this.#tp);return t}updateUI(t){this.#tJ===t&&this.#tK(t.propertiesToUpdate)}toggleSelected(t){if(this.#tp.has(t)){this.#tp.delete(t),t.unselect(),this.#tH({hasSelectedEditor:this.hasSelection});return}this.#tp.add(t),t.select(),this.#tK(t.propertiesToUpdate),this.#tH({hasSelectedEditor:!0})}setSelected(t){for(let e of this.#tp)e!==t&&e.unselect();this.#tp.clear(),this.#tp.add(t),t.select(),this.#tK(t.propertiesToUpdate),this.#tH({hasSelectedEditor:!0})}isSelected(t){return this.#tp.has(t)}get firstSelectedEditor(){return this.#tp.values().next().value}unselect(t){t.unselect(),this.#tp.delete(t),this.#tH({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#tp.size}get isEnterHandled(){return 1===this.#tp.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#K.undo(),this.#tH({hasSomethingToUndo:this.#K.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#tX()})}redo(){this.#K.redo(),this.#tH({hasSomethingToUndo:!0,hasSomethingToRedo:this.#K.hasSomethingToRedo(),isEmpty:this.#tX()})}addCommands(t){this.#K.add(t),this.#tH({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#tX()})}#tX(){if(0===this.#j.size)return!0;
2if(1===this.#j.size)for(let t of this.#j.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let t=[...this.#tp];this.addCommands({cmd:()=>{for(let e of t)e.remove()},undo:()=>{for(let e of t)this.#tq(e)},mustExec:!0})}commitOrRemove(){this.#$?.commitOrRemove()}hasSomethingToControl(){return this.#$||this.hasSelection}#tW(t){for(let t of this.#tp)t.unselect();for(let e of(this.#tp.clear(),t))e.isEmpty()||(this.#tp.add(e),e.select());this.#tH({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#tp)t.commit();this.#tW(this.#j.values())}unselectAll(){if((!this.#$||(this.#$.commitOrRemove(),this.#tu===p.NONE))&&this.hasSelection){for(let t of this.#tp)t.unselect();this.#tp.clear(),this.#tH({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#tk[0]+=t,this.#tk[1]+=e;let[s,a]=this.#tk,r=[...this.#tp];for(let i of(this.#tL&&clearTimeout(this.#tL),this.#tL=setTimeout(()=>{this.#tL=null,this.#tk[0]=this.#tk[1]=0,this.addCommands({cmd:()=>{for(let t of r)this.#j.has(t.id)&&t.translateInPage(s,a)},undo:()=>{for(let t of r)this.#j.has(t.id)&&t.translateInPage(-s,-a)},mustExec:!1})},1e3),r))i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#Q=new Map,this.#tp))this.#Q.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#Q)return!1;this.disableUserSelect(!1);let t=this.#Q;this.#Q=null;let e=!1;for(let[{x:i,y:s,pageIndex:a},r]of t)r.newX=i,r.newY=s,r.newPageIndex=a,e||=i!==r.savedX||s!==r.savedY||a!==r.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#j.has(t.id)){let a=this.#G.get(s);a?t._setParentAndPosition(a,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:a,newPageIndex:r}]of t)i(e,s,a,r)},undo:()=>{for(let[e,{savedX:s,savedY:a,savedPageIndex:r}]of t)i(e,s,a,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#Q)for(let i of this.#Q.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#tp.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#$===t}getActive(){return this.#$}getMode(){return this.#tu}get imageManager(){return L(this,"imageManager",new tk)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:s,y:a,width:r,height:n}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-a)/n,y:1-(t+i-s)/r,width:o/n,height:i/r});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-s)/r,y:1-(e+o-a)/n,width:i/r,height:o/n});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-a)/n,y:(t-s)/r,width:o/n,height:i/r});break;default:e=(t,e,i,o)=>({x:(t-s)/r,y:(e-a)/n,width:i/r,height:o/n})}let o=[];for(let t=0,s=i.rangeCount;t<s;t++){let s=i.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:i,width:a,height:r}of s.getClientRects())0!==a&&0!==r&&o.push(e(t,i,a,r))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#W||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#W?.delete(t)}renderAnnotationElement(t){let e=this.#W?.get(t.data.id);if(!e)return;let i=this.#q.getRawValue(e);i&&(this.#tu!==p.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}}class tD{#tZ="";#t0=!1;#t1=null;#t2=null;#t3=null;#t5=!1;#w=null;static _l10nPromise=null;constructor(t){this.#w=t}static initialize(t){tD._l10nPromise||=t}async render(){let t=this.#t1=document.createElement("button");t.className="altText";let e=await tD._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";let i=this.#w._uiManager._signal;t.addEventListener("contextmenu",tb,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#w._uiManager.editAltText(this.#w)};
2return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#t5=!0,s(e))},{signal:i}),await this.#t6(),t}finish(){this.#t1&&(this.#t1.focus({focusVisible:this.#t5}),this.#t5=!1)}isEmpty(){return!this.#tZ&&!this.#t0}get data(){return{altText:this.#tZ,decorative:this.#t0}}set data({altText:t,decorative:e}){(this.#tZ!==t||this.#t0!==e)&&(this.#tZ=t,this.#t0=e,this.#t6())}toggle(t=!1){this.#t1&&(!t&&this.#t3&&(clearTimeout(this.#t3),this.#t3=null),this.#t1.disabled=!t)}destroy(){this.#t1?.remove(),this.#t1=null,this.#t2=null}async #t6(){let t=this.#t1;if(!t)return;if(!this.#tZ&&!this.#t0){t.classList.remove("done"),this.#t2?.remove();return}t.classList.add("done"),tD._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(e=>{t.setAttribute("aria-label",e)});let e=this.#t2;if(!e){this.#t2=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");let i=e.id=`alt-text-tooltip-${this.#w.id}`;t.setAttribute("aria-describedby",i);let s=this.#w._uiManager._signal;s.addEventListener("abort",()=>{clearTimeout(this.#t3),this.#t3=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#t3=setTimeout(()=>{this.#t3=null,this.#t2.classList.add("show"),this.#w._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:s}),t.addEventListener("mouseleave",()=>{this.#t3&&(clearTimeout(this.#t3),this.#t3=null),this.#t2?.classList.remove("show")},{signal:s})}e.innerText=this.#t0?await tD._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#tZ,e.parentNode||t.append(e);let i=this.#w.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}class tF{#t4=null;#t8=null;#tZ=null;#t7=!1;#t9=!1;#et=null;#ee=null;#ei=this.focusin.bind(this);#es=this.focusout.bind(this);#ea=null;#er="";#en=!1;#eo=null;#el=!1;#eh=!1;#ed=!1;#ec=null;#eu=0;#ep=0;#eg=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#em=!1;#ef=tF._zIndex++;static _borderLineWidth=-1;static _colorManager=new tR;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=tF.prototype._resizeWithKeyboard,e=tI.TRANSLATE_SMALL,i=tI.TRANSLATE_BIG;return L(this,"_resizerKeyboardManager",new tP([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],tF.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===tF&&T("Cannot initialize AnnotationEditor."),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;let{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:a,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[a,r];let[n,o]=this.parentDimensions;this.x=t.x/n,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return L(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new tO({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e,i){if(tF._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(e=>[e,t.get(e.replaceAll(/([A-Z])/g,t=>`-${t.toLowerCase()}`))])),i?.strings)for(let e of i.strings)tF._l10nPromise.set(e,t.get(e));if(-1!==tF._borderLineWidth)return;let s=getComputedStyle(document.documentElement);tF._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){T("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#em}set _isDraggable(t){this.#em=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#ef}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#eb(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#en?this.#en=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let e=t.relatedTarget;!e?.closest(`#${this.id}`)&&(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){let[a,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/a,this.y=(e+s)/r,this.fixAndSetPosition()}#ev([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this.fixAndSetPosition()}translate(t,e){this.#ev(this.parentDimensions,t,e)}translateInPage(t,e){this.#eo||=[this.x,this.y],this.#ev(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#eo||=[this.x,this.y];let[i,s]=this.parentDimensions;if(this.x+=t/i,this.y+=e/s,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:r}=this,[n,o]=this.getBaseTranslation();a+=n,r+=o,this.div.style.left=`${(100*a).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#eo&&(this.#eo[0]!==this.x||this.#eo[1]!==this.y)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=tF,s=i/t,a=i/e;switch(this.rotation){case 90:return[-s,a];case 180:return[s,a];case 270:return[s,-a];default:return[-s,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let[e,i]=this.pageDimensions,{x:s,y:a,width:r,height:n}=this;if(r*=e,n*=i,s*=e,a*=i,this._mustFixPosition)switch(t){case 0:s=Math.max(0,Math.min(e-r,s)),a=Math.max(0,Math.min(i-n,a));break;case 90:s=Math.max(0,Math.min(e-n,s)),a=Math.min(i,Math.max(r,a));break;case 180:s=Math.min(e,Math.max(r,s)),a=Math.min(i,Math.max(n,a));break;case 270:s=Math.min(e,Math.max(n,s)),a=Math.max(0,Math.min(i-r,a))}this.x=s/=e,this.y=a/=i;let[o,l]=this.getBaseTranslation();s+=o,a+=l;let{style:h}=this.div;h.left=`${(100*s).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static #eA(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return tF.#eA(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return tF.#eA(t,e,360-this.parentRotation)}#ey(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,i]}=this,s=e*t,a=i*t;return $.isCSSRoundSupported?[Math.round(s),Math.round(a)]:[s,a]}setDims(t,e){let[i,s]=this.parentDimensions;this.div.style.width=`${(100*t/i).toFixed(2)}%`,this.#t9||(this.div.style.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){let{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),a=!this.#t9&&e.endsWith("%");if(s&&a)return;let[r,n]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#t9||a||(t.height=`${(100*parseFloat(e)/n).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#e_(){if(this.#et)return;this.#et=document.createElement("div"),this.#et.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#et.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#ew.bind(this,i),{signal:e}),t.addEventListener("contextmenu",tb,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#et)}#ew(t,e){e.preventDefault();let{isMac:i}=$.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#tZ?.toggle(!1);let s=this.#ex.bind(this,t),a=this._isDraggable;this._isDraggable=!1;let r=this._uiManager._signal,n={passive:!0,capture:!0,signal:r};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",s,n),window.addEventListener("contextmenu",tb,{signal:r});let o=this.x,l=this.y,h=this.width,d=this.height,c=this.parent.div.style.cursor,u=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let p=()=>{this.parent.togglePointerEvents(!0),this.#tZ?.toggle(!0),this._isDraggable=a,window.removeEventListener("pointerup",p),window.removeEventListener("blur",p),window.removeEventListener("pointermove",s,n),window.removeEventListener("contextmenu",tb),this.parent.div.style.cursor=c,this.div.style.cursor=u,this.#eE(o,l,h,d)};window.addEventListener("pointerup",p,{signal:r}),window.addEventListener("blur",p,{signal:r})}#eE(t,e,i,s){let a=this.x,r=this.y,n=this.width,o=this.height;(a!==t||r!==e||n!==i||o!==s)&&this.addCommands({cmd:()=>{this.width=n,this.height=o,this.x=a,this.y=r;let[t,e]=this.parentDimensions;this.setDims(t*n,e*o),this.fixAndSetPosition()},undo:()=>{this.width=i,this.height=s,this.x=t,this.y=e;let[a,r]=this.parentDimensions;this.setDims(a*i,r*s),this.fixAndSetPosition()},mustExec:!0})}#ex(t,e){let i,s,a,r;let[n,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=tF.MIN_SIZE/n,p=tF.MIN_SIZE/o,g=t=>Math.round(1e4*t)/1e4,m=this.#ey(this.rotation),f=(t,e)=>[m[0]*t+m[2]*e,m[1]*t+m[3]*e],b=this.#ey(360-this.rotation),v=!1,A=!1;switch(t){case"topLeft":v=!0,i=(t,e)=>
2[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":v=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":A=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":v=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":v=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":A=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let y=i(d,c),_=s(d,c),w=f(..._),x=g(l+w[0]),E=g(h+w[1]),C=1,S=1,[T,M]=this.screenToPageTranslation(e.movementX,e.movementY);if([T,M]=(a=T/n,r=M/o,[b[0]*a+b[2]*r,b[1]*a+b[3]*r]),v){let t=Math.hypot(d,c);C=S=Math.max(Math.min(Math.hypot(_[0]-y[0]-T,_[1]-y[1]-M)/t,1/d,1/c),u/d,p/c)}else A?C=Math.max(u,Math.min(1,Math.abs(_[0]-y[0]-T)))/d:S=Math.max(p,Math.min(1,Math.abs(_[1]-y[1]-M)))/c;let k=g(d*C),L=g(c*S),P=x-(w=f(...s(k,L)))[0],R=E-w[1];this.width=k,this.height=L,this.x=P,this.y=R,this.setDims(n*k,o*L),this.fixAndSetPosition()}altTextFinish(){this.#tZ?.finish()}async addEditToolbar(){return this.#ea||this.#eh||(this.#ea=new tC(this),this.div.append(this.#ea.render()),this.#tZ&&this.#ea.addAltTextButton(await this.#tZ.render())),this.#ea}removeEditToolbar(){this.#ea&&(this.#ea.remove(),this.#ea=null,this.#tZ?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#tZ||(tD.initialize(tF._l10nPromise),this.#tZ=new tD(this),this.#t4&&(this.#tZ.data=this.#t4,this.#t4=null),await this.addEditToolbar())}get altTextData(){return this.#tZ?.data}set altTextData(t){this.#tZ&&(this.#tZ.data=t)}hasAltText(){return!this.#tZ?.isEmpty()}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#t7?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();let t=this._uiManager._signal;this.div.addEventListener("focusin",this.#ei,{signal:t}),this.div.addEventListener("focusout",this.#es,{signal:t});let[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*i/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/i).toFixed(2)}%`);let[s,a]=this.getInitialTranslation();return this.translate(s,a),tT(this,this.div,["pointerdown"]),this.div}pointerdown(t){let{isMac:e}=$.platform;if(0!==t.button||t.ctrlKey&&e){t.preventDefault();return}if(this.#en=!0,this._isDraggable){this.#eC(t);return}this.#eS(t)}#eS(t){let{isMac:e}=$.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#eC(t){let e,i;let s=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let a=this._uiManager._signal;s&&(this.div.classList.add("moving"),e={passive:!0,capture:!0,signal:a},this.#eu=t.clientX,this.#ep=t.clientY,i=t=>{let{clientX:e,clientY:i}=t,[s,a]=this.screenToPageTranslation(e-this.#eu,i-this.#ep);this.#eu=e,this.#ep=i,this._uiManager.dragSelectedEditors(s,a)},window.addEventListener("pointermove",i,e));let r=()=>{window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),s&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,e)),this.#en=!1,this._uiManager.endDragSession()||this.#eS(t)};window.addEventListener("pointerup",r,{signal:a}),window.addEventListener("blur",r,{signal:a})}moveInDOM(){this.#ec&&clearTimeout(this.#ec),this.#ec=setTimeout(()=>{this.#ec=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition()}getRect(t,e,i=this.rotation){let s=this.parentScale,[a,r]=this.pageDimensions,[n,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*a,c=this.y*r,u=this.width*a,p=this.height*r;switch(i){case 0:return[d+l+n,r-c-h-p+o,d+l+u+n,r-c-h+o];case 90:return[d+h+n,r-c+l+o,d+h+p+n,r-c+l+u+o];case 180:return[d-l-u+n,r-c+h+o,d-l+n,r-c+h+p+o];case 270:return[d-h-p+n,r-c-l-u+o,d-h+n,r-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,a,r]=t,n=a-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,n,o];case 90:return[i,e-s,o,n];case 180:return[a,e-s,n,o];case 270:return[a,e-r,o,n];default:throw Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#eh=!0}disableEditMode(){this.#eh=!1}isInEditMode(){return this.#eh}shouldGetKeyboardEvents(){return this.#ed}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){let t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#ei,{signal:t}),this.div?.addEventListener("focusout",this.#es,{signal:t})}rotate(t){}serialize(t=!1,e=null){T("An editor must be serializable")}static deserialize(t,e,i){let s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#t4=t.accessibilityData;let[a,r]=s.pageDimensions,[n,o,l,h]=s.getRectInCurrentCoords(t.rect,r);
2return s.x=n/a,s.y=o/r,s.width=l/a,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.div.removeEventListener("focusin",this.#ei),this.div.removeEventListener("focusout",this.#es),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#ec&&(clearTimeout(this.#ec),this.#ec=null),this.#eb(),this.removeEditToolbar(),this.#eg){for(let t of this.#eg.values())clearTimeout(t);this.#eg=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#e_(),this.#et.classList.remove("hidden"),tT(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#ee={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#et.children;if(!this.#t8){this.#t8=Array.from(e);let t=this.#eT.bind(this),i=this.#eM.bind(this),s=this._uiManager._signal;for(let e of this.#t8){let a=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#ek.bind(this,a),{signal:s}),tF._l10nPromise.get(`pdfjs-editor-resizer-label-${a}`).then(t=>e.setAttribute("aria-label",t))}}let i=this.#t8[0],s=0;for(let t of e){if(t===i)break;s++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#t8.length/4);if(a!==s){if(a<s)for(let t=0;t<s-a;t++)this.#et.append(this.#et.firstChild);else if(a>s)for(let t=0;t<a-s;t++)this.#et.firstChild.before(this.#et.lastChild);let t=0;for(let i of e){let e=this.#t8[t++].getAttribute("data-resizer-name");tF._l10nPromise.get(`pdfjs-editor-resizer-label-${e}`).then(t=>i.setAttribute("aria-label",t))}}this.#eL(0),this.#ed=!0,this.#et.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#eT(t){tF._resizerKeyboardManager.exec(this,t)}#eM(t){this.#ed&&t.relatedTarget?.parentNode!==this.#et&&this.#eb()}#ek(t){this.#er=this.#ed?t:""}#eL(t){if(this.#t8)for(let e of this.#t8)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#ed&&this.#ex(this.#er,{movementX:t,movementY:e})}#eb(){if(this.#ed=!1,this.#eL(-1),this.#ee){let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#ee;this.#eE(t,e,i,s),this.#ee=null}}_stopResizingWithKeyboard(){this.#eb(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this.#ea){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#ea?.show()});return}this.#ea?.show()}unselect(){this.#et?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#ea?.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#el}set isEditing(t){this.#el=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#t9=!0;let{style:i}=this.div;i.aspectRatio=t/e,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#eg||=new Map;let{action:e}=t,i=this.#eg.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#eg.delete(e),0===this.#eg.size&&(this.#eg=null)},tF._telemetryTimeout),this.#eg.set(e,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#t7=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#t7=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstChild:e}=t.container;
2"DIV"===e.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class tO extends tF{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}class tN{constructor(t){this.h1=t?0xffffffff&t:0xc3d2e1f0,this.h2=t?0xffffffff&t:0xc3d2e1f0}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,a=t.length;s<a;s++){let a=t.charCodeAt(s);a<=255?e[i++]=a:(e[i++]=a>>>8,e[i++]=255&a)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,a=i-4*s,r=new Uint32Array(e.buffer,0,s),n=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<s;t++)1&t?(l^=n=0x1b873593*(n=(n=0xcc9e2d51*(n=r[t])&0xffff0000|11601*n&65535)<<15|n>>>17)&0xffff0000|13715*n&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(h^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=r[t])&0xffff0000|11601*o&65535)<<15|o>>>17)&0xffff0000|13715*o&65535,h=5*(h=h<<13|h>>>19)+0xe6546b64);switch(n=0,a){case 3:n^=e[4*s+2]<<16;case 2:n^=e[4*s+1]<<8;case 1:n^=e[4*s],n=0x1b873593*(n=(n=0xcc9e2d51*n&0xffff0000|11601*n&65535)<<15|n>>>17)&0xffff0000|13715*n&65535,1&s?l^=n:h^=n}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=0xff51afd7*e&0xffff0000|((e<<16|(t=0xed558ccd*t&0xffff0000|36045*t&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,t^=e>>>1,e=0xc4ceb9fe*e&0xffff0000|((e<<16|(t=0x1a85ec53*t&0xffff0000|60499*t&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let tB=Object.freeze({map:null,hash:"",transfer:void 0});class tH{#eP=!1;#eR=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let i=this.#eR.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#eR.get(t)}remove(t){if(this.#eR.delete(t),0===this.#eR.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let t of this.#eR.values())if(t instanceof tF)return;this.onAnnotationEditor(null)}}setValue(t,e){let i=this.#eR.get(t),s=!1;if(void 0!==i)for(let[t,a]of Object.entries(e))i[t]!==a&&(s=!0,i[t]=a);else s=!0,this.#eR.set(t,e);s&&this.#eI(),e instanceof tF&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#eR.has(t)}getAll(){return this.#eR.size>0?U(this.#eR):null}setAll(t){for(let[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#eR.size}#eI(){this.#eP||(this.#eP=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#eP&&(this.#eP=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new tz(this)}get serializable(){if(0===this.#eR.size)return tB;let t=new Map,e=new tN,i=[],s=Object.create(null),a=!1;for(let[i,r]of this.#eR){let n=r instanceof tF?r.serialize(!1,s):r;n&&(t.set(i,n),e.update(`${i}:${JSON.stringify(n)}`),a||=!!n.bitmap)}if(a)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:tB}get editorStats(){let t=null,e=new Map;for(let i of this.#eR.values()){if(!(i instanceof tF))continue;let s=i.telemetryFinalData;if(!s)continue;let{type:a}=s;e.has(a)||e.set(a,Object.getPrototypeOf(i).constructor),t||=Object.create(null);let r=t[a]||=new Map;for(let[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));let s=i.get(e)??0;i.set(e,s+1)}}for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}}class tz extends tH{#eD;constructor(t){super();let{map:e,hash:i,transfer:s}=t.serializable,a=structuredClone(e,s?{transfer:s}:null);this.#eD={map:a,hash:i,transfer:s}}get print(){T("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#eD}}class tU{#eF=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#eF.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}
2){if(!(!t||this.#eF.has(t.loadedName))){if(M(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:s,style:a}=t,r=new FontFace(i,s,a);this.addNativeFontFace(r);try{await r.load(),this.#eF.add(i),e?.(t)}catch{S(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}T("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw S(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return L(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return l?t=!0:"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)&&(t=!0),L(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(M(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return L(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let s,a;function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function n(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=r(c=n(c,976,d.length,d),16);for(s=0,a=d.length-3;s<a;s+=4)u=u-0x58585858+r(d,s)|0;s<d.length&&(u=u-0x58585858+r(d+"XXX",s)|0),c=n(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let m=this._document.createElement("div");for(let e of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++h>30){S("Load test font never loaded."),i();return}if(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){i();return}setTimeout(t.bind(null,e,i))}(d,()=>{m.remove(),e.complete()})}}class t${constructor(t,{disableFontFace:e=!1,inspectFont:i=null}){for(let e in this.compiledGlyphs=Object.create(null),t)this[e]=t[e];this.disableFontFace=!0===e,this._inspectFont=i}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){let t;if(!this.data||this.disableFontFace)return null;let e=H(this.data),i=`url(data:${this.mimetype};base64,${btoa(e)});`;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${i}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${i}}`;return this._inspectFont?.(this,i),t}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];try{i=t.get(this.loadedName+"_path_"+e)}catch(t){S(`getPathGenerator - ignoring character: "${t}".`)}if(!Array.isArray(i)||0===i.length)return this.compiledGlyphs[e]=function(t,e){};let s=[];for(let t=0,e=i.length;t<e;)switch(i[t++]){case X.BEZIER_CURVE_TO:{let[e,a,r,n,o,l]=i.slice(t,t+6);s.push(t=>t.bezierCurveTo(e,a,r,n,o,l)),t+=6}break;case X.MOVE_TO:{let[e,a]=i.slice(t,t+2);s.push(t=>t.moveTo(e,a)),t+=2}break;case X.LINE_TO:{let[e,a]=i.slice(t,t+2);s.push(t=>t.lineTo(e,a)),t+=2}break;case X.QUADRATIC_CURVE_TO:{let[e,a,r,n]=i.slice(t,t+4);s.push(t=>t.quadraticCurveTo(e,a,r,n)),t+=4}break;case X.RESTORE:s.push(t=>
2t.restore());break;case X.SAVE:s.push(t=>t.save());break;case X.SCALE:M(2===s.length,"Scale command is only valid at the third position.");break;case X.TRANSFORM:{let[e,a,r,n,o,l]=i.slice(t,t+6);s.push(t=>t.transform(e,a,r,n,o,l)),t+=6}break;case X.TRANSLATE:{let[e,a]=i.slice(t,t+2);s.push(t=>t.translate(e,a)),t+=2}}return this.compiledGlyphs[e]=function(t,e){s[0](t),s[1](t),t.scale(e,-e);for(let e=2,i=s.length;e<i;e++)s[e](t)}}}if(l){var tj=Promise.withResolvers(),tG=null;(async()=>{let t,e;let i=await import("fs");return new Map(Object.entries({fs:i,http:await import("http"),https:await import("https"),url:await import("url"),canvas:t,path2d:e}))})().then(t=>{tG=t,tj.resolve()},t=>{S(`loadPackages: ${t}`),tG=new Map,tj.resolve()})}class tV{static get promise(){return tj.promise}static get(t){return tG?.get(t)}}let tq=function(t){return tV.get("fs").promises.readFile(t).then(t=>new Uint8Array(t))};class tW extends Y{}class tK extends Q{_createCanvas(t,e){return tV.get("canvas").createCanvas(t,e)}}class tX extends J{_fetchData(t,e){return tq(t).then(t=>({cMapData:t,compressionType:e}))}}class tY extends Z{_fetchData(t){return tq(t)}}let tQ={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function tJ(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],a=new Path2D;a.rect(e[0],e[1],i,s),t.clip(a)}class tZ{constructor(){this.constructor===tZ&&T("Cannot initialize BaseShadingPattern.")}getPattern(){T("Abstract method `getPattern` called.")}}class t0 extends tZ{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;for(let i of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let a;if(s===tQ.STROKE||s===tQ.FILL){let r=e.current.getClippedPathBoundingBox(s,tw(t))||[0,0,0,0],n=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",n,o,!0),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=G.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),tJ(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),a=t.createPattern(l.canvas,"no-repeat");let d=new DOMMatrix(i);a.setTransform(d)}else tJ(t,this._bbox),a=this._createGradient(t);return a}}function t1(t,e,i,s,a,r,n,o){let l,h,d,c,u,p,g,m,f;let b=e.coords,v=e.colors,A=t.data,y=4*t.width;b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=r,r=n,n=l),b[s+1]>b[a+1]&&(l=s,s=a,a=l,l=n,n=o,o=l),b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=r,r=n,n=l);let _=(b[i]+e.offsetX)*e.scaleX,w=(b[i+1]+e.offsetY)*e.scaleY,x=(b[s]+e.offsetX)*e.scaleX,E=(b[s+1]+e.offsetY)*e.scaleY,C=(b[a]+e.offsetX)*e.scaleX,S=(b[a+1]+e.offsetY)*e.scaleY;if(w>=S)return;let T=v[r],M=v[r+1],k=v[r+2],L=v[n],P=v[n+1],R=v[n+2],I=v[o],D=v[o+1],F=v[o+2],O=Math.round(w),N=Math.round(S);for(let t=O;t<=N;t++){let e;if(t<E){let e=t<w?0:(w-t)/(w-E);h=_-(_-x)*e,d=T-(T-L)*e,c=M-(M-P)*e,u=k-(k-R)*e}else{let e;h=x-(x-C)*(e=t>S?1:E===S?0:(E-t)/(E-S)),d=L-(L-I)*e,c=P-(P-D)*e,u=R-(R-F)*e}p=_-(_-C)*(e=t<w?0:t>S?1:(w-t)/(w-S)),g=T-(T-I)*e,m=M-(M-D)*e,f=k-(k-F)*e;let i=Math.round(Math.min(h,p)),s=Math.round(Math.max(h,p)),a=y*t+4*i;for(let t=i;t<=s;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),A[a++]=d-(d-g)*e|0,A[a++]=c-(c-m)*e|0,A[a++]=u-(u-f)*e|0,A[a++]=255}}class t2 extends tZ{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),a=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,n=Math.ceil(this._bounds[3])-a,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(n*t[1]*1.1)),3e3),h=r/o,d=n/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-a,scaleX:1/h,scaleY:1/d}
2,u=o+4,p=l+4,g=i.getCanvas("mesh",u,p,!1),m=g.context,f=m.createImageData(o,l);if(e){let t=f.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(let t of this._figures)!function(t,e,i){let s,a;let r=e.coords,n=e.colors;switch(e.type){case"lattice":let o=e.verticesPerRow,l=Math.floor(r.length/o)-1,h=o-1;for(s=0;s<l;s++){let e=s*o;for(let s=0;s<h;s++,e++)t1(t,i,r[e],r[e+1],r[e+o],n[e],n[e+1],n[e+o]),t1(t,i,r[e+o+1],r[e+1],r[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(s=0,a=r.length;s<a;s+=3)t1(t,i,r[s],r[s+1],r[s+2],n[s],n[s+1],n[s+2]);break;default:throw Error("illegal figure")}}(f,t,c);return m.putImageData(f,2,2),{canvas:g.canvas,offsetX:s-2*h,offsetY:a-2*d,scaleX:h,scaleY:d}}getPattern(t,e,i,s){let a;if(tJ(t,this._bbox),s===tQ.SHADING)a=G.singularValueDecompose2dScale(tw(t));else if(a=G.singularValueDecompose2dScale(e.baseTransform),this.matrix){let t=G.singularValueDecompose2dScale(this.matrix);a=[a[0]*t[0],a[1]*t[1]]}let r=this._createMeshCanvas(a,s===tQ.SHADING?null:this._background,e.cachedCanvases);return s!==tQ.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class t3 extends tZ{getPattern(){return"hotpink"}}let t5={COLORED:1,UNCOLORED:2};class t6{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,a){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=a}createPatternCanvas(t){let e=this.operatorList,i=this.bbox,s=this.xstep,a=this.ystep,r=this.paintType,n=this.tilingType,o=this.color,l=this.canvasGraphicsFactory;C("TilingType: "+n);let h=i[0],d=i[1],c=i[2],u=i[3],p=G.singularValueDecompose2dScale(this.matrix),g=G.singularValueDecompose2dScale(this.baseTransform),m=[p[0]*g[0],p[1]*g[1]],f=this.getSizeAndScale(s,this.ctx.canvas.width,m[0]),b=this.getSizeAndScale(a,this.ctx.canvas.height,m[1]),v=t.cachedCanvases.getCanvas("pattern",f.size,b.size,!0),A=v.context,y=l.createCanvasGraphics(A);y.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(y,r,o);let _=h,w=d,x=c,E=u;return h<0&&(_=0,x+=Math.abs(h)),d<0&&(w=0,E+=Math.abs(d)),A.translate(-(f.scale*_),-(b.scale*w)),y.transform(f.scale,0,0,b.scale,0,0),A.save(),this.clipBbox(y,_,w,x,E),y.baseTransform=tw(y.ctx),y.executeOperatorList(e),y.endDrawing(),{canvas:v.canvas,scaleX:f.scale,scaleY:b.scale,offsetX:_,offsetY:w}}getSizeAndScale(t,e,i){t=Math.abs(t);let s=Math.max(t6.MAX_PATTERN_SIZE,e),a=Math.ceil(t*i);return a>=s?a=s:i=a/t,{scale:i,size:a}}clipBbox(t,e,i,s,a){let r=s-e,n=a-i;t.ctx.rect(e,i,r,n),t.current.updateRectMinMax(tw(t.ctx),[e,i,s,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,a=t.current;switch(e){case t5.COLORED:let r=this.ctx;s.fillStyle=r.fillStyle,s.strokeStyle=r.strokeStyle,a.fillColor=r.fillStyle,a.strokeColor=r.strokeStyle;break;case t5.UNCOLORED:let n=G.makeHexColor(i[0],i[1],i[2]);s.fillStyle=n,s.strokeStyle=n,a.fillColor=n,a.strokeColor=n;break;default:throw new N(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let a=i;s!==tQ.SHADING&&(a=G.transform(a,e.baseTransform),this.matrix&&(a=G.transform(a,this.matrix)));let r=this.createPatternCanvas(e),n=new DOMMatrix(a);n=(n=n.translate(r.offsetX,r.offsetY)).scale(1/r.scaleX,1/r.scaleY);let o=t.createPattern(r.canvas,"repeat");return o.setTransform(n),o}}class t4{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function t8(t,e,i,s,a,r,n,o,l,h){let[d,c,u,p,g,m]=tw(t);if(0===c&&0===u){let f=Math.round(n*d+g),b=Math.round(o*p+m),v=Math.abs(Math.round((n+l)*d+g)-f)||1,A=Math.abs(Math.round((o+h)*p+m)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),f,b),t.drawImage(e,i,s,a,r,0,0,v,A),t.setTransform(d,c,u,p,g,m),[v,A]}if(0===d&&0===p){let f=Math.round(o*u+g),b=Math.round(n*c+m),v=Math.abs(Math.round((o+h)*u+g)-f)||1,A=Math.abs(Math.round((n+l)*c+m)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,f,b),t.drawImage(e,i,s,a,r,0,0,A,v),t.setTransform(d,c,u,p,g,m),[A,v]}return t.drawImage(e,i,s,a,r,n,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class t7{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=h,this.textMatrixScale=1,this.fontMatrix=d,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=f.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=G.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){let i=G.applyTransform(e,t),s=G.applyTransform(e.slice(2),t),a=G.applyTransform([e[0],e[3]],t),r=G.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],a[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],a[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],a[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],a[1],r[1])}updateScalingPathMinMax(t,e){G.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,a,r,n,o,l,h){let d=G.bezierBoundingBox(e,i,s,a,r,n,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=tQ.FILL,e=null){let i=[this.minX,this.minY,this.maxX,this.maxY];if(t===tQ.STROKE){e||T("Stroke bounding box must include transform.");let t=G.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,a=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=a,i[2]+=s,i[3]+=a}return i}updateClipFromPath(){let t=G.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=tQ.FILL,e=null){return G.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function t9(t,e){let i,s,a,r;if("undefined"!=typeof ImageData&&e instanceof ImageData){t.putImageData(e,0,0);return}
2let n=e.height,o=e.width,l=n%16,h=(n-l)/16,d=0===l?h:h+1,c=t.createImageData(o,16),u=0,p,g=e.data,m=c.data;if(e.kind===b.GRAYSCALE_1BPP){let e=g.byteLength,r=new Uint32Array(m.buffer,0,m.byteLength>>2),n=r.length,f=o+7>>3,b=$.isLittleEndian?0xff000000:255;for(i=0;i<d;i++){for(s=0,a=i<h?16:l,p=0;s<a;s++){let t=e-u,i=0,s=t>f?o:8*t-7,a=-8&s,n=0,l=0;for(;i<a;i+=8)l=g[u++],r[p++]=128&l?0xffffffff:b,r[p++]=64&l?0xffffffff:b,r[p++]=32&l?0xffffffff:b,r[p++]=16&l?0xffffffff:b,r[p++]=8&l?0xffffffff:b,r[p++]=4&l?0xffffffff:b,r[p++]=2&l?0xffffffff:b,r[p++]=1&l?0xffffffff:b;for(;i<s;i++)0===n&&(l=g[u++],n=128),r[p++]=l&n?0xffffffff:b,n>>=1}for(;p<n;)r[p++]=0;t.putImageData(c,0,16*i)}}else if(e.kind===b.RGBA_32BPP){for(i=0,s=0,r=64*o;i<h;i++)m.set(g.subarray(u,u+r)),u+=r,t.putImageData(c,0,s),s+=16;i<d&&(r=o*l*4,m.set(g.subarray(u,u+r)),t.putImageData(c,0,s))}else if(e.kind===b.RGB_24BPP)for(i=0,r=o*(a=16);i<d;i++){for(i>=h&&(r=o*(a=l)),p=0,s=r;s--;)m[p++]=g[u++],m[p++]=g[u++],m[p++]=g[u++],m[p++]=255;t.putImageData(c,0,16*i)}else throw Error(`bad image kind: ${e.kind}`)}function et(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}let i=e.height,s=e.width,a=i%16,r=(i-a)/16,n=0===a?r:r+1,o=t.createImageData(s,16),l=0,h=e.data,d=o.data;for(let e=0;e<n;e++){let i=e<r?16:a;({srcPos:l}=function({src:t,srcPos:e=0,dest:i,width:s,height:a,nonBlackColor:r=0xffffffff,inverseDecode:n=!1}){let o=$.isLittleEndian?0xff000000:255,[l,h]=n?[r,o]:[o,r],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<a;s++){for(let s=e+d;e<s;e++){let s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;let s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function ee(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function ei(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!l){let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function es(t,e){if(e)return!0;let i=G.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);let s=Math.fround((globalThis.devicePixelRatio||1)*ti.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}let ea=["butt","round","square"],er=["miter","round","bevel"],en={},eo={};class el{constructor(t,e,i,s,a,{optionalContentConfig:r,markedContentStack:n=null},o,l){this.ctx=t,this.current=new t7(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=a,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=n||[],this.optionalContentConfig=r,this.cachedCanvases=new t4(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){let a=this.ctx.canvas.width,r=this.ctx.canvas.height,n=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,a,r),this.ctx.fillStyle=n,i){let t=this.cachedCanvases.getCanvas("transparent",a,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...tw(this.compositeCtx))}this.ctx.save(),ei(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=tw(this.ctx)}executeOperatorList(t,e,i,s){let a;let r=t.argsArray,n=t.fnArray,o=e||0,l=r.length;if(l===o)return o;let h=l-o>10&&"function"==typeof i,d=h?Date.now()+15:0,c=0,u=this.commonObjs,p=this.objs;for(;;){if(void 0!==s&&o===s.nextBreakPoint)return s.breakIt(o,i),o;if((a=n[o])!==w.dependency)this[a].apply(this,r[o]);else for(let t of r[o]){let e=t.startsWith("g_")?u:p;if(!e.has(t))return e.get(t,i),o}if(++o===l)return o;if(h&&++c>10){if(Date.now()>d)return i(),o;c=0}}}#eO(){for(;this.stateStack.length||this.inSMaskMode;
2)this.restore();this.ctx.restore(),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.transparentCanvas=null)}endDrawing(){for(let t of(this.#eO(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#eN()}#eN(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i,s;let a=t.width,r=t.height,n=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=a,h=r,d="prescale1";for(;n>2&&l>1||o>2&&h>1;){let e=l,a=h;n>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),n/=l/e),o>2&&h>1&&(a=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/a),(s=(i=this.cachedCanvases.getCanvas(d,e,a)).context).clearRect(0,0,e,a),s.drawImage(t,0,0,l,h,0,0,e,a),t=i.canvas,l=e,h=a,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){let e,i,s,a;let r=this.ctx,{width:n,height:o}=t,l=this.current.fillColor,h=this.current.patternFill,d=tw(r);if((t.bitmap||t.data)&&t.count>1){let a=t.bitmap||t.data.buffer;i=JSON.stringify(h?d:[d.slice(0,4),l]),(e=this._cachedBitmapsMap.get(a))||(e=new Map,this._cachedBitmapsMap.set(a,e));let r=e.get(i);if(r&&!h)return{canvas:r,offsetX:Math.round(Math.min(d[0],d[2])+d[4]),offsetY:Math.round(Math.min(d[1],d[3])+d[5])};s=r}s||et((a=this.cachedCanvases.getCanvas("maskCanvas",n,o)).context,t);let c=G.transform(d,[1/n,0,0,-1/o,0,0]);c=G.transform(c,[1,0,0,1,0,-o]);let[u,p,g,m]=G.getAxialAlignedBoundingBox([0,0,n,o],c),f=Math.round(g-u)||1,b=Math.round(m-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",f,b),A=v.context;A.translate(-u,-p),A.transform(...c),!s&&(s=(s=this._scaleImage(a.canvas,tx(A))).img,e&&h&&e.set(i,s)),A.imageSmoothingEnabled=es(tw(A),t.interpolate),t8(A,s,0,0,s.width,s.height,0,0,n,o),A.globalCompositeOperation="source-in";let y=G.transform(tx(A),[1,0,0,1,-u,-p]);return A.fillStyle=h?l.getPattern(r,this,y,tQ.FILL):l,A.fillRect(0,0,n,o),e&&!h&&(this.cachedCanvases.delete("fillCanvas"),e.set(i,v.canvas)),{canvas:v.canvas,offsetX:Math.round(u),offsetY:Math.round(p)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=ea[t]}setLineJoin(t){this.ctx.lineJoin=er[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){let i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;let a=this.ctx;a.setTransform(...tw(this.suspendedCtx)),ee(this.suspendedCtx,a),function(t,e){if(t._removeMirroring)throw Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()}
2,t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,a,r,n){e.transform(t,i,s,a,r,n),this.__originalTransform(t,i,s,a,r,n)},t.setTransform=function(t,i,s,a,r,n){e.setTransform(t,i,s,a,r,n),this.__originalSetTransform(t,i,s,a,r,n)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,a,r,n){e.bezierCurveTo(t,i,s,a,r,n),this.__originalBezierCurveTo(t,i,s,a,r,n)},t.rect=function(t,i,s,a){e.rect(t,i,s,a),this.__originalRect(t,i,s,a)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(a,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),ee(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),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(t,e,i,s){let a=s[0],r=s[1],n=s[2]-a,o=s[3]-r;0!==n&&0!==o&&(this.genericComposeSMask(e.context,i,n,o,e.subtype,e.backdrop,e.transferMap,a,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,a,r,n,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r){if(u<0||p<0||u+i>c.width||p+s>c.height){let t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(c,-u,-p),r.some(t=>0!==t)&&(e.globalCompositeOperation="destination-atop",e.fillStyle=G.makeHexColor(...r),e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over"),c=t.canvas,u=p=0}else if(r.some(t=>0!==t)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let e=new Path2D;e.rect(u,p,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=G.makeHexColor(...r),t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===a&&n?e.filter=this.filterFactory.addAlphaFilter(n):"Luminosity"===a&&(e.filter=this.filterFactory.addLuminosityFilter(n));let g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(ee(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),ee(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,a,r){this.ctx.transform(t,e,i,s,a,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){let s,a;let r=this.ctx,n=this.current,o=n.x,l=n.y,h=tw(r),d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],c=d?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case w.rectangle:o=e[u++],l=e[u++];let p=e[u++],g=e[u++],m=o+p,f=l+g;r.moveTo(o,l),0===p||0===g?r.lineTo(m,f):(r.lineTo(m,l),r.lineTo(m,f),r.lineTo(o,f)),d||n.updateRectMinMax(h,[o,l,m,f]),r.closePath();break;case w.moveTo:o=e[u++],l=e[u++],r.moveTo(o,l),d||n.updatePathMinMax(h,o,l);break;case w.lineTo:o=e[u++],l=e[u++],r.lineTo(o,l),d||n.updatePathMinMax(h,o,l);break;case w.curveTo:s=o,a=l,o=e[u+4],l=e[u+5],r.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),n.updateCurvePathMinMax(h,s,a,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case w.curveTo2:s=o,a=l,r.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,s,a,o,l,e[u],e[u+1],e[u+2],e[u+3],c),o=e[u+2],l=e[u+3],u+=4;break;case w.curveTo3:s=o,a=l,o=e[u+2],l=e[u+3],r.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,s,a,e[u],e[u+1],o,l,o,l,c),u+=4;break;case w.closePath:r.closePath()}d&&n.updateScalingPathMinMax(h,c),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){let e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,tx(e),tQ.STROKE),this.rescaleAndStroke(!1),e.restore(
2)):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){let e=this.ctx,i=this.current.fillColor,s=this.current.patternFill,a=!1;s&&(e.save(),e.fillStyle=i.getPattern(e,this,tx(e),tQ.FILL),a=!0);let r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),a&&e.restore(),t&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=en}eoClip(){this.pendingClip=eo}beginText(){this.current.textMatrix=h,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let t=this.pendingTextPaths,e=this.ctx;if(void 0===t){e.beginPath();return}for(let i of(e.save(),e.beginPath(),t))e.setTransform(...i.transform),e.translate(i.x,i.y),i.addToPath(e,i.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){let i=this.commonObjs.get(t),s=this.current;if(!i)throw Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||d,(0===s.fontMatrix[0]||0===s.fontMatrix[3])&&S("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;let a=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${a}", ${i.fallbackName}`,n="normal";i.black?n="900":i.bold&&(n="bold");let o=i.italic?"italic":"normal",l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${n} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,a,r){this.current.textMatrix=[t,e,i,s,a,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,i,s){let a;let r=this.ctx,n=this.current,o=n.font,l=n.textRenderingMode,h=n.fontSize/n.fontSizeScale,d=l&f.FILL_STROKE_MASK,c=!!(l&f.ADD_TO_PATH_FLAG),u=n.patternFill&&!o.missingFile;(o.disableFontFace||c||u)&&(a=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u?(r.save(),r.translate(e,i),r.beginPath(),a(r,h),s&&r.setTransform(...s),(d===f.FILL||d===f.FILL_STROKE)&&r.fill(),(d===f.STROKE||d===f.FILL_STROKE)&&r.stroke(),r.restore()):((d===f.FILL||d===f.FILL_STROKE)&&r.fillText(t,e,i),(d===f.STROKE||d===f.FILL_STROKE)&&r.strokeText(t,e,i)),c&&(this.pendingTextPaths||=[]).push({transform:tw(r),x:e,y:i,fontSize:h,addToPath:a})}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return L(this,"isFontSubpixelAAEnabled",i)}showText(t){let e;let i=this.current,s=i.font;if(s.isType3Font)return this.showType3Text(t);let a=i.fontSize;if(0===a)return;let r=this.ctx,n=i.fontSizeScale,o=i.charSpacing,l=i.wordSpacing,h=i.fontDirection,d=i.textHScale*h,c=t.length,u=s.vertical,p=u?1:-1,g=s.defaultVMetrics,m=a*i.fontMatrix[0],b=i.textRenderingMode===f.FILL&&!s.disableFontFace&&!i.patternFill;if(r.save(),r.transform(...i.textMatrix),r.translate(i.x,i.y+i.textRise),h>0?r.scale(d,-1):r.scale(d,1),i.patternFill){r.save();let t=i.fillColor.getPattern(r,this,tx(r),tQ.FILL);e=tw(r),r.restore(),r.fillStyle=t}let v=i.lineWidth,A=i.textMatrixScale;if(0===A||0===v){let t=i.textRenderingMode&f.FILL_STROKE_MASK;(t===f.STROKE||t===f.FILL_STROKE)&&(v=this.getSinglePixelWidth())}else v/=A;if(1!==n&&(r.scale(n,n),v/=n),r.lineWidth=v,s.isInvalidPDFjsFont){let e=[],s=0;for(let i of t)e.push(i.unicode),s+=i.width;
2r.fillText(e.join(""),0,0),i.x+=s*m*d,r.restore(),this.compose();return}let y=0,_;for(_=0;_<c;++_){let i,d;let c=t[_];if("number"==typeof c){y+=p*c*a/1e3;continue}let f=!1,v=(c.isSpace?l:0)+o,A=c.fontChar,w=c.accent,x=c.width;if(u){let t=c.vmetric||g,e=-(c.vmetric?t[1]:.5*x)*m,s=t[2]*m;x=t?-t[0]:x,i=e/n,d=(y+s)/n}else i=y/n,d=0;if(s.remeasure&&x>0){let t=1e3*r.measureText(A).width/a*n;if(x<t&&this.isFontSubpixelAAEnabled){let e=x/t;f=!0,r.save(),r.scale(e,1),i/=e}else x!==t&&(i+=(x-t)/2e3*a/n)}if(this.contentVisible&&(c.isInFont||s.missingFile)){if(b&&!w)r.fillText(A,i,d);else if(this.paintChar(A,i,d,e),w){let t=i+a*w.offset.x/n,s=d-a*w.offset.y/n;this.paintChar(w.fontChar,t,s,e)}}y+=u?x*m-v*h:x*m+v*h,f&&r.restore()}u?i.y-=y:i.x+=y*d,r.restore(),this.compose()}showType3Text(t){let e,i,s,a;let r=this.ctx,n=this.current,o=n.font,l=n.fontSize,h=n.fontDirection,c=o.vertical?1:-1,u=n.charSpacing,p=n.wordSpacing,g=n.textHScale*h,m=n.fontMatrix||d,b=t.length;if(n.textRenderingMode!==f.INVISIBLE&&0!==l){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,r.save(),r.transform(...n.textMatrix),r.translate(n.x,n.y),r.scale(g,h),e=0;e<b;++e){if("number"==typeof(i=t[e])){a=c*i*l/1e3,this.ctx.translate(a,0),n.x+=a*g;continue}let h=(i.isSpace?p:0)+u,d=o.charProcOperatorList[i.operatorListId];if(!d){S(`Type3 character "${i.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=i,this.save(),r.scale(l,l),r.transform(...m),this.executeOperatorList(d),this.restore()),s=G.applyTransform([i.width,0],m)[0]*l+h,r.translate(s,0),n.x+=s*g}r.restore(),this.processingType3=null}}setCharWidth(t,e){}
2setCharWidthAndBounds(t,e,i,s,a,r){this.ctx.rect(i,s,a-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){let i=t[1],s=this.baseTransform||tw(this.ctx);e=new t6(t,i,this.ctx,{createCanvasGraphics:t=>new el(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){let s=G.makeHexColor(t,e,i);this.ctx.strokeStyle=s,this.current.strokeColor=s}setFillRGBColor(t,e,i){let s=G.makeHexColor(t,e,i);this.ctx.fillStyle=s,this.current.fillColor=s,this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new t0(t);case"Mesh":return new t2(t);case"Dummy":return new t3}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;let e=this.ctx;this.save();let i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,tx(e),tQ.SHADING);let s=tx(e);if(s){let{width:t,height:i}=e.canvas,[a,r,n,o]=G.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(a,r,n-a,o-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){T("Should not call beginInlineImage")}beginImageData(){T("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=tw(this.ctx),e)){let t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(tw(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let e=this.ctx;t.isolated||C("TODO: Support non-isolated groups."),t.knockout&&S("Knockout groups not supported.");let i=tw(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw Error("Bounding box is required.");let s=G.getAxialAlignedBoundingBox(t.bbox,tw(e)),a=[0,0,e.canvas.width,e.canvas.height],r=Math.floor((s=G.intersect(s,a)||[0,0,0,0])[0]),n=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-r,1),l=Math.max(Math.ceil(s[3])-n,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);let d=this.cachedCanvases.getCanvas(h,o,l),c=d.context;c.translate(-r,-n),c.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:r,offsetY:n,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,n),e.save()),ee(e,c),this.ctx=c,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;let e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let t=tw(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);let i=G.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,a){if(this.#eO(),ei(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){let s=e[2]-e[0],r=e[3]-e[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r;let[a,n]=G.singularValueDecompose2dScale(tw(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(r*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);let{canvas:d,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(a,0,0,-n,0,r*n),ei(this.ctx)}else ei(this.ctx),this.ctx.rect(e[0],e[1],s,r),this.ctx.clip(),this.endPath()}
2this.current=new t7(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#eN(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;let e=t.count;(t=this.getObject(t.data,t)).count=e;let i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){let e,i,s;let{width:a,height:r}=t;if(a>1e3||r>1e3)return null;let n=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=a+1,l=new Uint8Array(o*(r+1)),h=a+7&-8,d=new Uint8Array(h*r),c=0;for(let e of t.data){let t=128;for(;t>0;)d[c++]=e&t?0:255,t>>=1}let u=0;for(0!==d[c=0]&&(l[0]=1,++u),i=1;i<a;i++)d[c]!==d[c+1]&&(l[i]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[i]=2,++u),e=1;e<r;e++){c=e*h,s=e*o,d[c-h]!==d[c]&&(l[s]=d[c]?1:8,++u);let t=(d[c]?4:0)+(d[c-h]?8:0);for(i=1;i<a;i++)n[t=(t>>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0)]&&(l[s+i]=n[t],++u),c++;if(d[c-h]!==d[c]&&(l[s+i]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(r-1),s=e*o,0!==d[c]&&(l[s]=8,++u),i=1;i<a;i++)d[c]!==d[c+1]&&(l[s+i]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[s+i]=4,++u),u>1e3)return null;let p=new Int32Array([0,o,-1,0,-o,0,0,0,1]),g=new Path2D;for(e=0;u&&e<=r;e++){let t=e*o,i=t+a;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%o,e);let s=t,r=l[t];do{let e=p[r];do t+=e;while(!l[t]);let i=l[t];5!==i&&10!==i?(r=i,l[t]=0):(r=i&51*r>>4,l[t]&=r>>2|r<<2),g.lineTo(t%o,t/o|0),!l[t]&&--u}while(s!==t);--e}return d=null,l=null,function(t){t.save(),t.scale(1/a,-1/r),t.translate(0,-r),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled)){s.compiled(i);return}let a=this._createMaskCanvas(t),r=a.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,a.offsetX,a.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,a,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);let n=this.ctx;n.save();let o=tw(n);n.transform(e,i,s,a,0,0);let l=this._createMaskCanvas(t);n.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=r.length;t<h;t+=2){let h=G.transform(o,[e,i,s,a,r[t],r[t+1]]),[d,c]=G.applyTransform([0,0],h);n.drawImage(l.canvas,d,c)}n.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;let e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(let a of t){let{data:t,width:r,height:n,transform:o}=a,l=this.cachedCanvases.getCanvas("maskCanvas",r,n),h=l.context;h.save(),et(h,this.getObject(t,a)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,tx(e),tQ.FILL):i,h.fillRect(0,0,r,n),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),t8(e,l.canvas,0,0,r,n,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;let e=this.getObject(t);if(!e){S("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;let a=this.getObject(t);if(!a){S("Dependent image isn't ready yet");return}let r=a.width,n=a.height,o=[];for(let t=0,a=s.length;t<a;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:n});this.paintInlineImageXObjectGroup(a,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;let{bitmap:e,width:i,height:s}=t,a=this.cachedCanvases.getCanvas("inlineImage",i,s),r=a.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",a.canvas}paintInlineImageXObject(t){let e;if(!this.contentVisible)return;let i=t.width,s=t.height,a=this.ctx;if(this.save(),!l){let{filter:t}=a;"none"!==t&&""!==t&&(a.filter="none")}if(a.scale(1/i,-1/s),t.bitmap)e=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)e=t;else{let a=this.cachedCanvases.getCanvas("inlineImage",i,s).context;t9(a,t),e=this.applyTransferMapsToCanvas(a)}let r=this._scaleImage(e,tx(a));a.imageSmoothingEnabled=es(tw(a),t.interpolate),t8(a,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,i,s),this.compose(),this.restore(
2)}paintInlineImageXObjectGroup(t,e){let i;if(!this.contentVisible)return;let s=this.ctx;if(t.bitmap)i=t.bitmap;else{let e=t.width,s=t.height,a=this.cachedCanvases.getCanvas("inlineImage",e,s).context;t9(a,t),i=this.applyTransferMapsToCanvas(a)}for(let t of e)s.save(),s.transform(...t.transform),s.scale(1,-1),t8(s,i,t.x,t.y,t.w,t.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){let e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);let i=this.ctx;this.pendingClip&&(e||(this.pendingClip===eo?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=tw(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let t,e;let{lineWidth:i}=this.current,{a:s,b:a,c:r,d:n}=this.ctx.getTransform();if(0===a&&0===r){let a=Math.abs(s),r=Math.abs(n);if(a===r){if(0===i)t=e=1/a;else{let s=a*i;t=e=s<1?1/s:1}}else if(0===i)t=1/a,e=1/r;else{let s=a*i,n=r*i;t=s<1?1/s:1,e=n<1?1/n:1}}else{let o=Math.abs(s*n-a*r),l=Math.hypot(s,a),h=Math.hypot(r,n);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t){let{ctx:e}=this,{lineWidth:i}=this.current,[s,a]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===a){e.stroke();return}let r=e.getLineDash();if(t&&e.save(),e.scale(s,a),r.length>0){let t=Math.max(s,a);e.setLineDash(r.map(e=>e/t)),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in w)void 0!==el.prototype[t]&&(el.prototype[w[t]]=el.prototype[t]);class eh{static #eB=null;static #eH="";static get workerPort(){return this.#eB}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#eB=t}static get workerSrc(){return this.#eH}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#eH=t}}let ed={DATA:1,ERROR:2},ec={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function eu(t){switch(t instanceof Error||"object"==typeof t&&null!==t||T('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new B(t.message);case"MissingPDFException":return new F(t.message);case"PasswordException":return new R(t.message,t.code);case"UnexpectedResponseException":return new O(t.message,t.status);case"UnknownErrorException":return new I(t.message,t.details);default:return new I(t.message,t.toString())}}class ep{constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=t=>{let e=t.data;if(e.targetName!==this.sourceName)return;if(e.stream){this.#ez(e);return}if(e.callback){let t=e.callbackId,i=this.callbackCapabilities[t];if(!i)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===ed.DATA)i.resolve(e.data);else if(e.callback===ed.ERROR)i.reject(eu(e.reason));else throw Error("Unexpected callback case");return}let s=this.actionHandler[e.action];if(!s)throw Error(`Unknown action from worker: ${e.action}`);
2if(e.callbackId){let t=this.sourceName,a=e.sourceName;new Promise(function(t){t(s(e.data))}).then(function(s){i.postMessage({sourceName:t,targetName:a,callback:ed.DATA,callbackId:e.callbackId,data:s})},function(s){i.postMessage({sourceName:t,targetName:a,callback:ed.ERROR,callbackId:e.callbackId,reason:eu(s)})});return}if(e.streamId){this.#eU(e);return}s(e.data)},i.addEventListener("message",this._onComObjOnMessage)}on(t,e){let i=this.actionHandler;if(i[t])throw Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){let s=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[s]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){a.reject(t)}return a.promise}sendWithStream(t,e,i,s){let a=this.streamId++,r=this.sourceName,n=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[a]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:n,action:t,streamId:a,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[a].pullCall=e,o.postMessage({sourceName:r,targetName:n,stream:ec.PULL,streamId:a,desiredSize:t.desiredSize}),e.promise},cancel:t=>{M(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[a].cancelCall=e,this.streamControllers[a].isClosed=!0,o.postMessage({sourceName:r,targetName:n,stream:ec.CANCEL,streamId:a,reason:eu(t)}),e.promise}},i)}#eU(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,a=this.comObj,r=this,n=this.actionHandler[t.action],o={enqueue(t,r=1,n){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:i,targetName:s,stream:ec.ENQUEUE,streamId:e,chunk:t},n)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:i,targetName:s,stream:ec.CLOSE,streamId:e}),delete r.streamSinks[e])},error(t){M(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:i,targetName:s,stream:ec.ERROR,streamId:e,reason:eu(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise(function(e){e(n(t.data,o))}).then(function(){a.postMessage({sourceName:i,targetName:s,stream:ec.START_COMPLETE,streamId:e,success:!0})},function(t){a.postMessage({sourceName:i,targetName:s,stream:ec.START_COMPLETE,streamId:e,reason:eu(t)})})}#ez(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,a=this.comObj,r=this.streamControllers[e],n=this.streamSinks[e];switch(t.stream){case ec.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(eu(t.reason));break;case ec.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(eu(t.reason));break;case ec.PULL:if(!n){a.postMessage({sourceName:i,targetName:s,stream:ec.PULL_COMPLETE,streamId:e,success:!0});break}n.desiredSize<=0&&t.desiredSize>0&&n.sinkCapability.resolve(),n.desiredSize=t.desiredSize,new Promise(function(t){t(n.onPull?.())}).then(function(){a.postMessage({sourceName:i,targetName:s,stream:ec.PULL_COMPLETE,streamId:e,success:!0})},function(t){a.postMessage({sourceName:i,targetName:s,stream:ec.PULL_COMPLETE,streamId:e,reason:eu(t)})});break;case ec.ENQUEUE:if(M(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case ec.CLOSE:if(M(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#e$(r,e);break;case ec.ERROR:M(r,"error should have stream controller"),r.controller.error(eu(t.reason)),this.#e$(r,e);break;case ec.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(eu(t.reason)),this.#e$(r,e);break;case ec.CANCEL:if(!n)break;new Promise(function(e){e(n.onCancel?.(eu(t.reason)))}).then(function(){a.postMessage({sourceName:i,targetName:s,stream:ec.CANCEL_COMPLETE,streamId:e,success:!0})},function(t){a.postMessage({sourceName:i,targetName:s,stream:ec.CANCEL_COMPLETE,streamId:e,reason:eu(t)})}),n.sinkCapability.reject(eu(t.reason)),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #e$(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class eg{#ej;#eG;constructor({parsedData:t,rawData:e}){this.#ej=t,this.#eG=e}getRaw(){return this.#eG}get(t){return this.#ej.get(t)??null}getAll(){return U(this.#ej)}has(t){return this.#ej.has(t)}}let em=Symbol("INTERNAL");class ef{#eV=!1;#eq=!1;#eW=!1;#eK=!0;constructor(t,{name:e,intent:i,usage:s}){this.#eV=!!(t&c.DISPLAY),this.#eq=!!(t&c.PRINT),this.name=e,this.intent=i,this.usage=s}get visible(){if(this.#eW)return this.#eK;if(!this.#eK)return!1;let{print:t,view:e}=this.usage;return this.#eV?e?.viewState!=="OFF":!this.#eq||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==em&&T("Internal method `_setVisible` called."),this.#eW=i,this.#eK=e}}class eb{#eX=null;#eY=new Map;#eQ=null;#eJ=null;constructor(t,e=c.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,null===t)return;for(let i of(this.name=t.name,this.creator=t.creator,this.#eJ=t.order,t.groups))this.#eY.set(i.id,new ef(e,i));if("OFF"===t.baseState)for(let t of this.#eY.values())t._setVisible(em,!1);for(let e of t.on)this.#eY.get(e)._setVisible(em,!0);for(let e of t.off)this.#eY.get(e)._setVisible(em,!1);this.#eQ=this.getHash()}#eZ(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e;let a=t[s];if(Array.isArray(a))e=this.#eZ(a);else{if(!this.#eY.has(a))return S(`Optional content group not found: ${a}`),!0;e=this.#eY.get(a).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#eY.size)return!0;
2if(!t)return C("Optional content group not defined."),!0;if("OCG"===t.type)return this.#eY.has(t.id)?this.#eY.get(t.id).visible:(S(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#eZ(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#eY.has(e)){S(`Optional content group not found: ${e}`);break}if(!this.#eY.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#eY.has(e))return S(`Optional content group not found: ${e}`),!0;if(!this.#eY.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(let e of t.ids){if(!this.#eY.has(e)){S(`Optional content group not found: ${e}`);break}if(this.#eY.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#eY.has(e))return S(`Optional content group not found: ${e}`),!0;if(this.#eY.get(e).visible)return!0}return!1}return S(`Unknown optional content policy ${t.policy}.`),!0}return S(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){let i=this.#eY.get(t);if(!i){S(`Optional content group not found: ${t}`);return}i._setVisible(em,!!e,!0),this.#eX=null}setOCGState({state:t,preserveRB:e}){let i;for(let e of t){switch(e){case"ON":case"OFF":case"Toggle":i=e;continue}let t=this.#eY.get(e);if(t)switch(i){case"ON":t._setVisible(em,!0);break;case"OFF":t._setVisible(em,!1);break;case"Toggle":t._setVisible(em,!t.visible)}}this.#eX=null}get hasInitialVisibility(){return null===this.#eQ||this.getHash()===this.#eQ}getOrder(){return this.#eY.size?this.#eJ?this.#eJ.slice():[...this.#eY.keys()]:null}getGroups(){return this.#eY.size>0?U(this.#eY):null}getGroup(t){return this.#eY.get(t)||null}getHash(){if(null!==this.#eX)return this.#eX;let t=new tN;for(let[e,i]of this.#eY)t.update(`${e}:${i.visible}`);return this.#eX=t.hexdigest()}}class ev{constructor(t,{disableRange:e=!1,disableStream:i=!1}){M(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:s,initialData:a,progressiveDone:r,contentDispositionFilename:n}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=n,a?.length>0){let t=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):M(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){M(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new eA(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new ey(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeReaders.slice(0)))e.cancel(t);this._pdfDataRangeTransport.abort()}}class eA{constructor(t,e,i=!1,s=null){for(let a of(this._stream=t,this._done=i||!1,this._filename=tu(s)?s:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=a.byteLength;
2this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class ey{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{for(let e of(this._requests.shift().resolve({value:t,done:!1}),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function e_({getResponseHeader:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let a={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t("Content-Length"),10);return Number.isInteger(r)&&(a.suggestedLength=r,r<=2*i||s||!e||"bytes"!==t("Accept-Ranges")||"identity"!==(t("Content-Encoding")||"identity")||(a.allowRangeRequests=!0)),a}function ew(t){let e=t("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){let t=n(i=i[1]);return r(t=l(t=o(t=unescape(t))))}if(i=function(t){let e;let i=[],a=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=a.exec(t));){let[,t,s,a]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[s,a]}let r=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=n(s),e&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t))return r(l(i));if(i=s("filename","i").exec(t)){let t=n(i=i[1]);return r(t=l(t))}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function a(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),a=z(i);i=s.decode(a),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=a("utf-8",t),e&&(t=a("iso-8859-1",t))),t}function n(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return -1===e?t:a(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return a(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return a(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(tu(t))return t}return null}function ex(t,e){return 404===t||0===t&&e.startsWith("file:")?new F('Missing PDF "'+e+'".'):new O(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function eE(t){return 200===t||206===t}function eC(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function eS(t){let e=new Headers;for(let i in t){let s=t[i];
2void 0!==s&&e.append(i,s)}return e}function eT(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(S(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class eM{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return M(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ek(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new eL(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class ek{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;let e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._headers=eS(this._stream.httpHeaders);let i=e.url;fetch(i,eC(this._headers,this._withCredentials,this._abortController)).then(t=>{if(!eE(t.status))throw ex(t.status,i);this._reader=t.body.getReader(),this._headersCapability.resolve();let e=e=>t.headers.get(e),{allowRangeRequests:s,suggestedLength:a}=e_({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s,this._contentLength=a||this._contentLength,this._filename=ew(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new B("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}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(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:eT(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class eL{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;let s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController,this._headers=eS(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${i-1}`);let a=s.url;fetch(a,eC(this._headers,this._withCredentials,this._abortController)).then(t=>{if(!eE(t.status))throw ex(t.status,a);this._readCapability.resolve(),this._reader=t.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:eT(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class eP{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,i){let s={begin:t,end:e};for(let t in i)s[t]=i[t];return this.request(s)}requestFull(t){return this.request(t)}request(t){let e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};for(let t in e.open("GET",this.url),e.withCredentials=this.withCredentials,this.httpHeaders){let i=this.httpHeaders[t];void 0!==i&&e.setRequestHeader(t,i)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(i){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){let i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){let i=this.pendingRequests[t];if(!i)return;let s=i.xhr;if(s.readyState>
2=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp){i.onError?.(s.status);return}let a=s.status||200;if(!(200===a&&206===i.expectedStatus)&&a!==i.expectedStatus){i.onError?.(s.status);return}let r=function(t){let e=t.response;return"string"!=typeof e?e:z(e).buffer}(s);if(206===a){let t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);i.onDone({begin:parseInt(e[1],10),chunk:r})}else r?i.onDone({begin:0,chunk:r}):i.onError?.(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class eR{constructor(t){this._source=t,this._manager=new eP(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return M(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new eI(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let i=new eD(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class eI{constructor(t,e){this._manager=t;let i={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(i),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t),i=t=>e.getResponseHeader(t),{allowRangeRequests:s,suggestedLength:a}=e_({getResponseHeader:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=ew(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(let e of(this._storedError=ex(t,this._url),this._headersReceivedCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let e of(this._done=!0,this._headersReceivedCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class eD{constructor(t,e,i){this._manager=t;let s={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,i,s),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;for(let t of(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){for(let e of(this._storedError=ex(t,this._url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest
2(this._requestId),this._close()}}let eF=/^file:\/\/\/[a-zA-Z]:\//;class eO{constructor(t){this.source=t,this.url=function(t){let e=tV.get("url"),i=e.parse(t);return"file:"===i.protocol||i.host?i:/^[a-z]:[/\\]/i.test(t)?e.parse(`file:///${t}`):(i.host||(i.protocol="file:"),i)}(t.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return M(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new e$(this):new ez(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=this.isFsUrl?new ej(this,t,e):new eU(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class eN{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;let e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new B("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class eB{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function eH(t,e){return{protocol:t.protocol,auth:t.auth,host:t.hostname,port:t.port,path:t.path,method:"GET",headers:e}}class ez extends eN{constructor(t){super(t);let e=e=>{if(404===e.statusCode){let t=new F(`Missing PDF "${this._url}".`);this._storedError=t,this._headersCapability.reject(t);return}this._headersCapability.resolve(),this._setReadableStream(e);let i=t=>this._readableStream.headers[t.toLowerCase()],{allowRangeRequests:s,suggestedLength:a}=e_({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s,this._contentLength=a||this._contentLength,this._filename=ew(i)};if(this._request=null,"http:"===this._url.protocol){let i=tV.get("http");this._request=i.request(eH(this._url,t.httpHeaders),e)}else{let i=tV.get("https");this._request=i.request(eH(this._url,t.httpHeaders),e)}this._request.on("error",t=>{this._storedError=t,this._headersCapability.reject(t)}),this._request.end()}}class eU extends eB{constructor(t,e,i){for(let e in super(t),this._httpHeaders={},t.httpHeaders){let i=t.httpHeaders[e];void 0!==i&&(this._httpHeaders[e]=i)}this._httpHeaders.Range=`bytes=${e}-${i-1}`;let s=t=>{if(404===t.statusCode){let t=new F(`Missing PDF "${this._url}".`);this._storedError=t;return}this._setReadableStream(t)};if(this._request=null,"http:"===this._url.protocol){let t=tV.get("http");this._request=t.request(eH(this._url,this._httpHeaders),s)}else{let t=tV.get("https");this._request=t.request(eH(this._url,this._httpHeaders),s)}this._request.on("error",t=>{this._storedError=t}),this._request.end()}}class e$ extends eN{constructor(t){super(t);let e=decodeURIComponent(this._url.path);eF.test(this._url.href)&&(e=e.replace(/^\//,""));let i=tV.get("fs");i.promises.lstat(e).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(e)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=new F(`Missing PDF "${e}".`)),this._storedError=t,this._headersCapability.reject(t)})}}class ej extends eB{constructor(t,e,i){super(t);let s=decodeURIComponent(this._url.path);eF.test(this._url.href)&&(s=s.replace(/^\//,""));let a=tV.get("fs");this._setReadableStream(a.createReadStream(s,{start:e,end:i-1}))}}class eG{#e0=Promise.withResolvers();#tP=null;#e1=!1;#e2=!!globalThis.FontInspector?.enabled;#e3=null;#e5=null;#e6=0;#e4=0;#e8=null;#e7=null;#e9=0;#it=0;#ie=Object.create(null);#ii=[];#is=null;#ia=[];#ir=new WeakMap;#io=null;static #il=new Map;static #ih=new Map;static #id=null;static #ic=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#is=t;else if("object"==typeof t)this.#is=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');this.#tP=this.#e7=e,this.#it=i.scale*(globalThis.devicePixelRatio||1),this.#e9=i.rotation,this.#e5={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};let{pageWidth:s,pageHeight:a,pageX:r,pageY:n}=i.rawDims;this.#io=[1,0,0,-1,-r,n+a],this.#e4=s,this.#e6=a,eG.#iu(),tE(e,i),this.#e0.promise.catch(()=>{}).then(()=>{eG.#ic.delete(this),this.#e5=null,this.#ie=null})}render(){let t=()=>{this.#e8.read().then(({value:e,done:i})=>{if(i){this.#e0.resolve();return}this.#e3??=e.lang,Object.assign(this.#ie,e.styles),this.#ip(e.items),t()},this.#e0.reject)};return this.#e8=this.#is.getReader(),eG.#ic.add(this),t(),this.#e0.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*(globalThis.devicePixelRatio||1),s=t.rotation;if(s!==this.#e9&&(e?.(),this.#e9=s,tE(this.#e7,{rotation:s})),i!==this.#it){e?.(),this.#it=i;let t={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:eG.#ig(this.#e3)};for(let e of this.#ia)t.properties=this.#ir.get(e),t.div=e,this.#im(t)}}cancel(){let t=new B("TextLayer task cancelled.");this.#e8?.cancel(t).catch(()=>{}),this.#e8=null,this.#e0.reject(t)}get textDivs(){return this.#ia}get textContentItemsStr(){return this.#ii}#ip(t){if(this.#e1)return;this.#e5.ctx??=eG.#ig(this.#e3);let e=this.#ia,i=this.#ii;for(let s of t){if(e.length>1e5){S("Ignoring additional textDivs for performance reasons."),this.#e1=!0;return}if(void 0===s.str){if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#tP;this.#tP=document.createElement("span"),this.#tP.classList.add("markedContent"),null!==s.id&&this.#tP.setAttribute("id",`${s.id}`),t.append(this.#tP)}else"endMarkedContent"===s.type&&(this.#tP=this.#tP.parentNode);continue}i.push(s.str),this.#ib(s)}}#ib(t){let e,i;let s=document.createElement("span"),a={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#ia.push(s);let r=G.transform(this.#io,t.transform),n=Math.atan2(r[1],r[0]),o=this.#ie[t.fontName];o.vertical&&(n+=Math.PI/2);let l=this.#e2&&o.fontSubstitution||o.fontFamily,h=Math.hypot(r[2],r[3]),d=h*eG.#iv(l,this.#e3);0===n?(e=r[4],i=r[5]-d):(e=r[4]+d*Math.sin(n),i=r[5]-d*Math.cos(n));let c="calc(var(--scale-factor)*",u=s.style;this.#tP===this.#e7?(u.left=`${(100*e/this.#e4).toFixed(2)}%`,u.top=`${(100*i/this.#e6).toFixed(2)}%`):(u.left=`${c}${e.toFixed(2)}px)`,u.top=`${c}${i.toFixed(2)}px)`),u.fontSize=`${c}${(eG.#id*h).toFixed(2)}px)`,u.fontFamily=l,a.fontSize=h,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,this.#e2&&(s.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==n&&(a.angle=180/Math.PI*n);let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(a.canvasWidth=o.vertical?t.height:t.width),this.#ir.set(s,a),this.#e5.div=s,this.#e5.properties=a,this.#im(this.#e5),a.hasText&&this.#tP.append(s),a.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tP.append(t)}}#im(t){let{div:e,properties:i,ctx:s,prevFontSize:a,prevFontFamily:r}=t,{style:n}=e,o="";if(eG.#id>1&&(o=`scale(${1/eG.#id})`),0!==i.canvasWidth&&i.hasText){let{fontFamily:l}=n,{canvasWidth:h,fontSize:d}=i;(a!==d||r!==l)&&(s.font=`${d*this.#it}px ${l}`,t.prevFontSize=d,t.prevFontFamily=l);let{width:c}=s.measureText(e.textContent);c>0&&(o=`scaleX(${h*this.#it/c}) ${o}`)}0!==i.angle&&(o=`rotate(${i.angle}deg) ${o}`),o.length>0&&(n.transform=o)}static cleanup(){if(!(this.#ic.size>0)){for(let{canvas:t}
2of(this.#il.clear(),this.#ih.values()))t.remove();this.#ih.clear()}}static #ig(t=null){let e=this.#ih.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#ih.set(t,e)}return e}static #iu(){if(null!==this.#id)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),this.#id=t.getBoundingClientRect().height,t.remove()}static #iv(t,e){let i=this.#il.get(t);if(i)return i;let s=this.#ig(e),a=s.font;s.canvas.width=s.canvas.height=30,s.font=`30px ${t}`;let r=s.measureText(""),n=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);if(n){let e=n/(n+o);return this.#il.set(t,e),s.canvas.width=s.canvas.height=0,s.font=a,e}s.strokeStyle="red",s.clearRect(0,0,30,30),s.strokeText("g",0,0);let l=s.getImageData(0,0,30,30).data;o=0;for(let t=l.length-1-3;t>=0;t-=4)if(l[t]>0){o=Math.ceil(t/4/30);break}s.clearRect(0,0,30,30),s.strokeText("A",0,30),l=s.getImageData(0,0,30,30).data,n=0;for(let t=0,e=l.length;t<e;t+=4)if(l[t]>0){n=30-Math.floor(t/4/30);break}s.canvas.width=s.canvas.height=0,s.font=a;let h=n?n/(n+o):.8;return this.#il.set(t,h),h}}function eV(){tv("`renderTextLayer`, please use `TextLayer` instead.");let{textContentSource:t,container:e,viewport:i,...s}=arguments[0],a=Object.keys(s);a.length>0&&S("Ignoring `renderTextLayer` parameters: "+a.join(", "));let r=new eG({textContentSource:t,container:e,viewport:i}),{textDivs:n,textContentItemsStr:o}=r;return{promise:r.render(),textDivs:n,textContentItemsStr:o}}function eq(){tv("`updateTextLayer`, please use `TextLayer` instead.")}class eW{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let s=null,a=i.name;if("#text"===a)s=i.value;else{if(!eW.shouldBuildText(a))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}let eK=l?tK:ta,eX=l?tX:tn,eY=l?tW:ts,eQ=l?tY:to;function eJ(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e=new e0,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(l&&"string"==typeof t)return t}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,a=t.data?function(t){if(l&&void 0!==r&&t instanceof r)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return z(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,n=t.httpHeaders||null,o=!0===t.withCredentials,h=t.password??null,d=t.range instanceof e1?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,u=t.worker instanceof e4?t.worker:null,p=t.verbosity,g="string"!=typeof t.docBaseUrl||tc(t.docBaseUrl)?null:t.docBaseUrl,m="string"==typeof t.cMapUrl?t.cMapUrl:null,f=!1!==t.cMapPacked,b=t.CMapReaderFactory||eX,v="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,A=t.StandardFontDataFactory||eQ,y=!0!==t.stopAtErrors,_=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,w=!1!==t.isEvalSupported,x="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!l,C=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,S="boolean"==typeof t.disableFontFace?t.disableFontFace:l,T=!0===t.fontExtraProperties,M=!0===t.enableXfa,k=t.ownerDocument||globalThis.document,L=!0===t.disableRange,P=!0===t.disableStream,R=!0===t.disableAutoFetch,I=!0===t.pdfBug,D=!0===t.enableHWA,F=d?d.length:t.length??NaN,O="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!l&&!S,N="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:b===tn&&A===to&&m&&v&&tf(m,document.baseURI)&&tf(v,document.baseURI),B=t.canvasFactory||new eK({ownerDocument:k,enableHWA:D}),H=t.filterFactory||new eY({docId:i,ownerDocument:k});Number.isInteger(p)&&(E=p);let U={canvasFactory:B,filterFactory:H};if(N||(U.cMapReaderFactory=new b({baseUrl:m,isCompressed:f}),U.standardFontDataFactory=new A({baseUrl:v})),!u){let t={verbosity:p,port:eh.workerPort};u=t.port?e4.fromPort(t):new e4(t),e._worker=u}let $={docId:i,apiVersion:"4.4.168",data:a,password:h,disableAutoFetch:R,rangeChunkSize:c,length:F,docBaseUrl:g,enableXfa:M,evaluatorOptions:{maxImageSize:_,disableFontFace:S,ignoreErrors:y,isEvalSupported:w,isOffscreenCanvasSupported:x,canvasMaxAreaInBytes:C,fontExtraProperties:T,useSystemFonts:O,cMapUrl:N?m:null,standardFontDataUrl:N?v:null}},j={disableFontFace:S,fontExtraProperties:T,ownerDocument:k,pdfBug:I,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:M}};return u.promise.then(function(){let t;if(e.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");
2let r=u.messageHandler.sendWithPromise("GetDocRequest",$,a?[a.buffer]:null);if(d)t=new ev(d,{disableRange:L,disableStream:P});else if(!a){var h;if(!s)throw Error("getDocument - no `url` parameter provided.");h={url:s,length:F,httpHeaders:n,withCredentials:o,rangeChunkSize:c,disableRange:L,disableStream:P},t=l?"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype&&tf(h.url)?new eM(h):new eO(h):tf(h.url)?new eM(h):new eR(h)}return r.then(s=>{if(e.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let a=new ep(i,s,u.port),r=new e8(a,e,t,j,U);e._transport=r,a.send("Ready",null)})}).catch(e._capability.reject),e}function eZ(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class e0{static #r=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${e0.#r++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class e1{constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(let i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(let i of this._progressListeners)i(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(let e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){T("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class e2{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return L(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}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()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class e3{#iA=null;#iy=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new tm:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new e9,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}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:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:a=!1}={}){return new th({viewBox:this.view,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:a})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}
2=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return L(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=u.ENABLE,transform:a=null,background:r=null,optionalContentConfigPromise:n=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null}){this._stats?.time("Overall");let d=this._transport.getRenderingIntent(i,s,h),{renderingIntent:p,cacheKey:g}=d;this.#iy=!1,this.#i_(),n||=this._transport.getOptionalContentConfig(p);let m=this._intentStates.get(g);m||(m=Object.create(null),this._intentStates.set(g,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);let f=!!(p&c.PRINT);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));let b=t=>{m.renderTasks.delete(v),(this._maybeCleanupAfterRender||f)&&(this.#iy=!0),this.#iw(!f),t?(v.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:Error(t)})):v.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},v=new ie({callback:b,params:{canvasContext:t,viewport:e,transform:a,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:l});(m.renderTasks||=new Set).add(v);let A=v.task;return Promise.all([m.displayReadyCapability.promise,n]).then(([t,e])=>{if(this.destroyed){b();return}if(this._stats?.time("Rendering"),!(e.renderingIntent&p))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");v.initializeGraphics({transparency:t,optionalContentConfig:e}),v.operatorListChanged()}).catch(b),A}getOperatorList({intent:t="display",annotationMode:e=u.ENABLE,printAnnotationStorage:i=null}={}){let s;let a=this._transport.getRenderingIntent(t,e,i,!0),r=this._intentStates.get(a.cacheKey);return r||(r=Object.create(null),this._intentStates.set(a.cacheKey,r)),r.opListReadCapability||((s=Object.create(null)).operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(s))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(s),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(a)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>eW.textContent(t));let e=this.streamTextContent(t);return new Promise(function(t,i){let s=e.getReader(),a={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){if(s){t(a);return}a.lang??=i.lang,Object.assign(a.styles,i.styles),a.items.push(...i.items),e()},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#iy=!1,this.#i_(),Promise.all(t)}cleanup(t=!1){this.#iy=!0;let e=this.#iw(!1);
2return t&&e&&(this._stats&&=new tm),e}#iw(t=!1){if(this.#i_(),!this.#iy||this.destroyed)return!1;if(t)return this.#iA=setTimeout(()=>{this.#iA=null,this.#iw(!1)},5e3),!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#iy=!1,!0}#i_(){this.#iA&&(clearTimeout(this.#iA),this.#iA=null)}_startRenderPage(t,e){let i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#iw(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i}){let{map:s,transfer:a}=i,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:s},a).getReader(),n=this._intentStates.get(e);n.streamReader=r;let o=()=>{r.read().then(({value:t,done:e})=>{if(e){n.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,n),o())},t=>{if(n.streamReader=null,!this._transport.destroyed){if(n.operatorList){for(let t of(n.operatorList.lastChunk=!0,n.renderTasks))t.operatorListChanged();this.#iw(!0)}if(n.displayReadyCapability)n.displayReadyCapability.reject(t);else if(n.opListReadCapability)n.opListReadCapability.reject(t);else throw t}})};o()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof td){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new B(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class e5{#ix=new Set;#iE=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#iE.then(()=>{for(let t of this.#ix)t.call(this,i)})}addEventListener(t,e){this.#ix.add(e)}removeEventListener(t,e){this.#ix.delete(e)}terminate(){this.#ix.clear()}}let e6={isWorkerDisabled:!1,fakeWorkerId:0};l&&(e6.isWorkerDisabled=!0,eh.workerSrc||="./pdf.worker.mjs"),e6.isSameOrigin=function(t,e){let i;try{if(!(i=new URL(t)).origin||"null"===i.origin)return!1}catch{return!1}let s=new URL(e,i);return i.origin===s.origin},e6.createCDNWrapper=function(t){let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};class e4{static #iC;constructor({name:t=null,port:e=null,verbosity:i=E}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(e4.#iC?.has(e))throw Error("Cannot use more than one PDFWorker per port.");(e4.#iC||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return l?Promise.all([tV.promise,this._readyCapability.promise]):this._readyCapability.promise}#iS(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new ep("main","worker",t),this._messageHandler.on("ready",function(){}),this.#iS()}_initialize(){if(e6.isWorkerDisabled||e4.#iT){this._setupFakeWorker();return}let{workerSrc:t}=e4;try{e6.isSameOrigin(window.location.href,t)||(t=e6.createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new ep("main","worker",e),s=()=>{a.abort(),i.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;e.addEventListener("error",()=>{this._webWorker||s()},{signal:a.signal}),i.on("test",t=>{if(a.abort(),this.destroyed||!t){s();return}this._messageHandler=i,this._port=e,this._webWorker=e,this.#iS()}),i.on("ready",t=>{if(a.abort(),this.destroyed){s();return}try{r()}catch{this._setupFakeWorker()}});let r=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};r();return}catch{C("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){e6.isWorkerDisabled||(S("Setting up fake worker."),e6.isWorkerDisabled=!0),e4._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(Error("Worker was destroyed"));return}let e=new e5;this._port=e;let i=`fake${e6.fakeWorkerId++}`,s=new ep(i+"_worker",i,e);t.setup(s,e),this._messageHandler=new ep(i,i+"_worker",e),this.#iS()}).catch(t=>{this._readyCapability.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),e4.#iC?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw Error("PDFWorker.fromPort - invalid method signature.");let e=this.#iC?.get(t.port);
2if(e){if(e._pendingDestroy)throw Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new e4(t)}static get workerSrc(){if(eh.workerSrc)return eh.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #iT(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return L(this,"_setupFakeWorkerGlobal",(async()=>this.#iT?this.#iT:(await import(this.workerSrc)).WorkerMessageHandler)())}}class e8{#iM=new Map;#ik=new Map;#iL=new Map;#iP=new Map;#iR=null;constructor(t,e,i,s,a){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new e9,this.fontLoader=new tU({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#iI(t,e=null){let i=this.#iM.get(t);if(i)return i;let s=this.messageHandler.sendWithPromise(t,e);return this.#iM.set(t,s),s}get annotationStorage(){return L(this,"annotationStorage",new tH)}getRenderingIntent(t,e=u.ENABLE,i=null,s=!1){let a=c.DISPLAY,r=tB;switch(t){case"any":a=c.ANY;break;case"display":break;case"print":a=c.PRINT;break;default:S(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case u.DISABLE:a+=c.ANNOTATIONS_DISABLE;break;case u.ENABLE:break;case u.ENABLE_FORMS:a+=c.ANNOTATIONS_FORMS;break;case u.ENABLE_STORAGE:r=((a+=c.ANNOTATIONS_STORAGE)&c.PRINT&&i instanceof tz?i:this.annotationStorage).serializable;break;default:S(`getRenderingIntent - invalid annotationMode: ${e}`)}return s&&(a+=c.OPLIST),{renderingIntent:a,cacheKey:`${a}_${r.hash}`,annotationStorageSerializable:r}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#iR?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#ik.values())t.push(e._destroy());this.#ik.clear(),this.#iL.clear(),this.#iP.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#iM.clear(),this.filterFactory.destroy(),eG.cleanup(),this._networkStream?.cancelAllRequests(new B("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{M(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){if(i){e.close();return}M(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t])}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",t=>{let i=Promise.withResolvers(),s=this._fullReader;return s.headersReady.then(()=>{s.isStreamingSupported&&s.isRangeSupported||(this._lastProgress&&e.onProgress?.(this._lastProgress),s.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),i.resolve({isStreamingSupported:s.isStreamingSupported,isRangeSupported:s.isRangeSupported,contentLength:s.contentLength})},i.reject),i.promise}),t.on("GetRangeReader",(t,e)=>{M(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let i=this._networkStream.getRangeReader(t.begin,t.end);if(!i){e.close();return}e.onPull=()=>{i.read().then(function({value:t,done:i}){if(i){e.close();return}M(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t])}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new e2(t,this))}),t.on("DocException",function(t){let i;switch(t.name){case"PasswordException":i=new R(t.message,t.code);break;case"InvalidPDFException":i=new D(t.message);break;case"MissingPDFException":i=new F(t.message);break;case"UnexpectedResponseException":i=new O(t.message,t.status);break;case"UnknownErrorException":i=new I(t.message,t.details);break;default:T("DocException - expected a valid Error.")}e._capability.reject(i)}
2),t.on("PasswordRequest",t=>{if(this.#iR=Promise.withResolvers(),e.onPassword)try{e.onPassword(t=>{t instanceof Error?this.#iR.reject(t):this.#iR.resolve({password:t})},t.code)}catch(t){this.#iR.reject(t)}else this.#iR.reject(new R(t.message,t.code));return this.#iR.promise}),t.on("DataLoaded",t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#ik.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":let{disableFontFace:a,fontExtraProperties:r,pdfBug:n}=this._params;if("error"in s){let t=s.error;S(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let o=new t$(s,{disableFontFace:a,inspectFont:n&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null});this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!r&&o.data&&(o.data=null),this.commonObjs.resolve(e,o)});break;case"CopyLocalImage":let{imageRef:l}=s;for(let t of(M(l,"The imageRef must be defined."),this.#ik.values()))for(let[,i]of t.objs)if(i?.ref===l){if(!i.dataLen)return null;return this.commonObjs.resolve(e,structuredClone(i)),i.dataLen}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let a=this.#ik.get(e);if(!a.objs.has(t)){if(0===a._intentStates.size){s?.bitmap?.close();return}switch(i){case"Image":a.objs.resolve(t,s),s?.dataLen>1e7&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBuiltInCMap",t=>this.destroyed?Promise.reject(Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(t):Promise.reject(Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",t=>this.destroyed?Promise.reject(Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(t):Promise.reject(Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&S("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.#iL.get(e);if(i)return i;let s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw Error("Transport destroyed");i.refStr&&this.#iP.set(i.refStr,t);let s=new e3(e,i,this,this._params.pdfBug);return this.#ik.set(e,s),s});return this.#iL.set(e,s),s}getPageIndex(t){return eZ(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#iI("GetFieldObjects")}hasJSActions(){return this.#iI("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}
2getPageLayout(){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)}getDocJSActions(){return this.#iI("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#iI("GetOptionalContentConfig").then(e=>new eb(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#iM.get(t);if(e)return e;let i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new eg(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#iM.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#ik.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#iM.clear(),this.filterFactory.destroy(!0),eG.cleanup()}}cachedPageNumber(t){if(!eZ(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#iP.get(e)??null}}let e7=Symbol("INITIAL_DATA");class e9{#iD=Object.create(null);#iF(t){return this.#iD[t]||={...Promise.withResolvers(),data:e7}}get(t,e=null){if(e){let i=this.#iF(t);return i.promise.then(()=>e(i.data)),null}let i=this.#iD[t];if(!i||i.data===e7)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#iD[t];return!!e&&e.data!==e7}resolve(t,e=null){let i=this.#iF(t);i.data=e,i.resolve()}clear(){for(let t in this.#iD){let{data:e}=this.#iD[t];e?.bitmap?.close()}this.#iD=Object.create(null)}*[Symbol.iterator](){for(let t in this.#iD){let{data:e}=this.#iD[t];e!==e7&&(yield[t,e])}}}class it{#iO=null;constructor(t){this.#iO=t,this.onContinue=null}get promise(){return this.#iO.capability.promise}cancel(t=0){this.#iO.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#iO.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#iO;return t.form||t.canvas&&e?.size>0}}class ie{#iN=null;static #iB=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:a,operatorList:r,pageIndex:n,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=n,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new it(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=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(ie.#iB.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ie.#iB.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:i,viewport:s,transform:a,background:r}=this.params;this.gfx=new el(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#iN&&(window.cancelAnimationFrame(this.#iN),this.#iN=null),ie.#iB.delete(this._canvas),this.callback(t||new td(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#iN=window.requestAnimationFrame(()=>{this.#iN=null,this._nextBound().catch(this._cancelBound)}
2):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){!this.cancelled&&(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),ie.#iB.delete(this._canvas),this.callback())))}}let ii="4.4.168",is="19fbc8998";function ia(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function ir(t){return Math.max(0,Math.min(255,255*t))}class io{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=ir(t),t,t]}static G_HTML([t]){let e=ia(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(ir)}static RGB_HTML(t){return`#${t.map(ia).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[ir(1-Math.min(1,t+s)),ir(1-Math.min(1,i+s)),ir(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let s=1-t,a=1-e,r=1-i,n=Math.min(s,a,r);return["CMYK",s,a,r,n]}}class il{static setupStorage(t,e,i,s,a){let r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===a)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===a)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===a)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==r.value)for(let e of(t.setAttribute("value",r.value),i.children))e.attributes.value===r.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,a=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:a})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:a}){let{attributes:r}=e,n=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===r.type&&(r.name=`${r.name}-${s}`),Object.entries(r)))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:n&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}n&&a.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,a=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:a,linkService:i});let n="richText"!==a,o=t.div;if(o.append(r),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}n&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);r.append(t),n&&eW.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,r]];for(;h.length>0;){let[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),r.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(r.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:a,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);n&&eW.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}let ih=new WeakSet;function id(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class ic{static create(t){switch(t.data.annotationType){case v.LINK:return new ip(t);case v.TEXT:return new ig(t);case v.WIDGET:switch(t.data.fieldType){case"Tx":return new ib(t);case"Btn":if(t.data.radioButton)return new iy(t);if(t.data.checkBox)return new iA(t);return new i_(t);case"Ch":return new iw(t);case"Sig":return new iv(t)}return new im(t);case v.POPUP:return new ix(t);case v.FREETEXT:return new iC(t);case v.LINE:return new iS(t);case v.SQUARE:return new iT(t);case v.CIRCLE:return new iM(t);case v.POLYLINE:return new ik(t);case v.CARET:return new iP(t);case v.INK:return new iR(t);case v.POLYGON:return new iL(t);case v.HIGHLIGHT:return new iI(t);case v.UNDERLINE:return new iD(t);case v.SQUIGGLY:return new iF(t);case v.STRIKEOUT:return new iO(t);case v.STAMP:return new iN(t);case v.FILEATTACHMENT:return new iB(t);default:return new iu(t)}}}class iu{#iH=null;#iz=!1;#iU=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get hasPopupData(){return iu._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#iH||={rect:this.data.rect.slice(0)};let{rect:e}=t;e&&this.#i$(e),this.#iU?.popup.updateEdited(t)}resetEdited(){this.#iH&&(this.#i$(this.#iH.rect),this.#iU?.popup.resetEdited(),this.#iH=null)}#i$(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:r,pageX:n,pageY:o}}}}=this;i?.splice(0,4,...t);let{width:l,height:h}=id(t);e.left=`${100*(t[0]-n)/a}%`,e.top=`${100*(r-t[3]+o)/r}%`,0===s?(e.width=`${100*l/a}%`,e.height=`${100*h/r}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof im||(a.tabIndex=1e3);let{style:r}=a;if(r.zIndex=this.parent.zIndex++,e.popupRef&&a.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(a.title=e.alternativeText),e.noRotate&&a.classList.add("norotate"),!e.rect||this instanceof ix){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,a),a}let{width:n,height:o}=id(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){let e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;r.borderRadius=e}else if(this instanceof iy){let t=`calc(${n}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case A.SOLID:r.borderStyle="solid";break;case A.DASHED:r.borderStyle="dashed";break;case A.BEVELED:S("Unimplemented border style: beveled");break;case A.INSET:S("Unimplemented border style: inset");break;case A.UNDERLINE:r.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#iz=!0,r.borderColor=G.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}let l=G.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;r.left=`${100*(l[0]-c)/h}%`,r.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;
2return e.hasOwnCanvas||0===p?(r.width=`${100*n/h}%`,r.height=`${100*o/d}%`):this.setRotation(p,a),a}setRotation(t,e=this.container){let i,s;if(!this.data.rect)return;let{pageWidth:a,pageHeight:r}=this.parent.viewport.rawDims,{width:n,height:o}=id(this.data.rect);t%180==0?(i=100*n/a,s=100*o/r):(i=100*o/a,s=100*n/r),e.style.width=`${i}%`,e.style.height=`${s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],a=s[0],r=s.slice(1);i.target.style[e]=io[`${a}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:io[`${a}_rgb`](r)})};return L(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail)){let a=t[s]||i[s];a?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,a]of Object.entries(e)){let r=i[s];r&&(r({detail:{[s]:a},target:t}),delete e[s])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,s,a,r]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,n,o,l]=e.subarray(2,6);if(a===t&&r===n&&i===o&&s===l)return}let{style:n}=this.container;if(this.#iz){let{borderColor:e,borderWidth:i}=n;n.borderWidth=0,t=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=a-i,l=r-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let s=2,a=e.length;s<a;s+=8){let a=e[s],n=e[s+1],d=e[s+2],c=e[s+3],p=h.createElement("rect"),g=(d-i)/o,m=(r-n)/l,f=(a-d)/o,b=(n-c)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#iz&&(t.push("</g></svg>')"),n.backgroundImage=t.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");let i=this.#iU=new ix({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(i.render())}render(){T("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:a,exportValues:r}of s){if(-1===t||a===e)continue;let s="string"==typeof r?r:null,n=document.querySelector(`[data-element-id="${a}"]`);if(n&&!ih.has(n)){S(`_getElementsByName - element not allowed: ${a}`);continue}i.push({id:a,exportValue:s,domElement:n})}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,a=s.getAttribute("data-element-id");a!==e&&ih.has(s)&&i.push({id:a,exportValue:t,domElement:s})}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(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class ip extends iu{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#ij(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#iG(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkA
2nnotation"),s&&this.container.append(i),this.container}#iV(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#iV()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#iV()}#ij(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#iV()}#iG(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#iV()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let a=i.get(s);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#iV()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#iV(),!this._fieldObjects){S('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:s,include:a}=e,r=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===a&&r.push(i)}else for(let t of Object.values(this._fieldObjects))r.push(...t);let n=this.annotationStorage,o=[];for(let t of r){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";n.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;n.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";n.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!ih.has(i)){S(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class ig extends iu{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class im extends iu{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return $.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,a){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:a(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:a(t)}})})}_setEventListeners(t,e,i,s){for(let[a,r]of i)("Action"===r||this.data.actions?.[r])&&(("Focus"===r||"Blur"===r)&&(e||={focused:!1}),this._setEventListener(t,e,a,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":G.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e;let{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,a=t.style,r=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=Math.round(t/(1.35*s))||1;e=Math.min(s,r(t/i/1.35))}else e=Math.min(s,r(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));a.fontSize=`calc(${e}
2px * var(--scale-factor))`,a.color=G.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(a.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class ib extends im{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){let a=this.annotationStorage;for(let r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),a.setValue(r.id,{[s]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),a=s.value||"",r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&a.length>r&&(a=a.slice(0,r));let n=s.formattedValue||this.data.textContent?.join("\n")||null;n&&this.data.comb&&(n=n.replaceAll(/\s+/g,""));let o={userValue:a,formattedValue:n,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=n??a,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type="text",i.setAttribute("value",n??a),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),ih.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=1e3,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let l=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:s}=i.detail,{target:a}=i;if(0===s){a.removeAttribute("maxLength");return}a.setAttribute("maxLength",s);let r=o.userValue;r&&!(r.length<=s)&&(r=r.slice(0,s),a.value=o.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let s=l;l=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:s}=t,{value:a,selectionStart:r,selectionEnd:n}=s,l=r,h=n;switch(t.inputType){case"deleteWordBackward":{let t=a.substring(0,r).match(/\w*[^\
2w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{let t=a.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===n&&(l-=1);break;case"deleteContentForward":r===n&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(l&&i.addEventListener("blur",l),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else(i=document.createElement("div")).textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class iv extends im{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class iA extends im{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let a=document.createElement("input");return ih.add(a),a.setAttribute("data-element-id",i),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=e.fieldName,s&&a.setAttribute("checked",!0),a.setAttribute("exportValue",e.exportValue),a.tabIndex=1e3,a.addEventListener("change",s=>{let{name:a,checked:r}=s.target;for(let s of this._getElementsByName(a,i)){let i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})}),a.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class iy extends im{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let a=document.createElement("input");if(ih.add(a),a.setAttribute("data-element-id",i),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,s&&a.setAttribute("checked",!0),a.tabIndex=1e3,a.addEventListener("change",e=>{let{name:s,checked:a}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:a})}),a.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;a.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let a=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=a&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}
2return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class i_ extends ip{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class iw extends im{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");ih.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=1e3;let a=this.data.combo&&this.data.options.length>0;for(let t of(!this.data.combo&&(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue;for(let t of s.options)t.selected=t.value===e}),this.data.options)){let e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),a=!1),s.append(e)}let r=null;if(a){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}let n=t=>{let e=t?"value":"textContent",{options:i,multiple:a}=s;return a?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},o=n(!1),l=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){r?.();let a=i.detail.value,l=new Set(Array.isArray(a)?a:[a]);for(let t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:n(!0)}),o=n(!1)},multipleSelection(t){s.multiple=!0},remove(i){let a=s.options,r=i.detail.remove;a[r].selected=!1,s.remove(r),a.length>0&&-1===Array.prototype.findIndex.call(a,t=>t.selected)&&(a[0].selected=!0),t.setValue(e,{value:n(!0),items:l(i)}),o=n(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=n(!1)},insert(i){let{index:a,displayValue:r,exportValue:h}=i.detail.insert,d=s.children[a],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:n(!0),items:l(i)}),o=n(!1)},items(i){let{items:a}=i.detail;for(;0!==s.length;)s.remove(0);for(let t of a){let{displayValue:e,exportValue:i}=t,a=document.createElement("option");a.textContent=e,a.value=i,s.append(a)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:n(!0),items:l(i)}),o=n(!1)},indices(i){let s=new Set(i.detail.indices);for(let t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:n(!0)}),o=n(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),s.addEventListener("input",i=>{let s=n(!0),a=n(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:a,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:n(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ix extends iu{constructor(t){let{data:e,elements:i}=t;super(t,{isRenderable:iu._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");let t=this.popup=new iE({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,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}),e=[];for(let i of this.elements)i.popup=t,e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(t=>`${K}${t}`).join(",")),this.container}}
2class iE{#iq=this.#iW.bind(this);#iK=this.#iX.bind(this);#iY=this.#iQ.bind(this);#iJ=this.#iZ.bind(this);#i0=null;#tP=null;#i1=null;#i2=null;#i3=null;#i5=null;#i6=null;#i4=!1;#i8=null;#H=null;#i7=null;#i9=null;#st=null;#iH=null;#se=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:a,contentsObj:r,richText:n,parent:o,rect:l,parentRect:h,open:d}){for(let d of(this.#tP=t,this.#st=s,this.#i1=r,this.#i9=n,this.#i5=o,this.#i0=e,this.#i7=l,this.#i6=h,this.#i3=i,this.#i2=tA.toDateObject(a),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),this.trigger))d.addEventListener("click",this.#iJ),d.addEventListener("mouseenter",this.#iY),d.addEventListener("mouseleave",this.#iK),d.classList.add("popupTriggerArea");for(let t of i)t.container?.addEventListener("keydown",this.#iq);this.#tP.hidden=!0,d&&this.#iZ()}render(){if(this.#i8)return;let t=this.#i8=document.createElement("div");if(t.className="popup",this.#i0){let e=t.style.outlineColor=G.makeHexColor(...this.#i0);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:t.style.backgroundColor=G.makeHexColor(...this.#i0.map(t=>Math.floor(.7*(255-t)+t)))}let e=document.createElement("span");e.className="header";let i=document.createElement("h1");if(e.append(i),{dir:i.dir,str:i.textContent}=this.#st,t.append(e),this.#i2){let t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),t.setAttribute("data-l10n-args",JSON.stringify({date:this.#i2.toLocaleDateString(),time:this.#i2.toLocaleTimeString()})),e.append(t)}let s=this.#si;if(s)il.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{let e=this._formatContents(this.#i1);t.append(e)}this.#tP.append(t)}get #si(){let t=this.#i9,e=this.#i1;return t?.str&&(!e?.str||e.str===t.str)&&this.#i9.html||null}get #ss(){return this.#si?.attributes?.style?.fontSize||0}get #sa(){return this.#si?.attributes?.style?.color||null}#sr(t){let e=[],i={style:{color:this.#sa,fontSize:this.#ss?`calc(${this.#ss}px * var(--scale-factor))`:""}};for(let s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}_formatContents({str:t,dir:e}){let i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;let s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){let a=s[t];i.append(document.createTextNode(a)),t<e-1&&i.append(document.createElement("br"))}return i}#iW(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||"Enter"!==t.key&&("Escape"!==t.key||!this.#i4)||this.#iZ()}updateEdited({rect:t,popupContent:e}){this.#iH||={contentsObj:this.#i1,richText:this.#i9},t&&(this.#H=null),e&&(this.#i9=this.#sr(e),this.#i1=null),this.#i8?.remove(),this.#i8=null}resetEdited(){this.#iH&&({contentsObj:this.#i1,richText:this.#i9}=this.#iH,this.#iH=null,this.#i8?.remove(),this.#i8=null,this.#H=null)}#sn(){if(null!==this.#H)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:a}}}=this.#i5,r=!!this.#i6,n=r?this.#i6:this.#i7;for(let t of this.#i3)if(!n||null!==G.intersect(t.data.rect,n)){n=t.data.rect,r=!0;break}let o=G.normalizeRect([n[0],t[3]-n[1]+t[1],n[2],t[3]-n[3]+t[1]]),l=r?n[2]-n[0]+5:0,h=o[0]+l,d=o[1];this.#H=[100*(h-s)/e,100*(d-a)/i];let{style:c}=this.#tP;c.left=`${this.#H[0]}%`,c.top=`${this.#H[1]}%`}#iZ(){this.#i4=!this.#i4,this.#i4?(this.#iQ(),this.#tP.addEventListener("click",this.#iJ),this.#tP.addEventListener("keydown",this.#iq)):(this.#iX(),this.#tP.removeEventListener("click",this.#iJ),this.#tP.removeEventListener("keydown",this.#iq))}#iQ(){this.#i8||this.render(),this.isVisible?this.#i4&&this.#tP.classList.add("focused"):(this.#sn(),this.#tP.hidden=!1,this.#tP.style.zIndex=parseInt(this.#tP.style.zIndex)+1e3)}#iX(){this.#tP.classList.remove("focused"),!this.#i4&&this.isVisible&&(this.#tP.hidden=!0,this.#tP.style.zIndex=parseInt(this.#tP.style.zIndex)-1e3)}forceHide(){this.#se=this.isVisible,this.#se&&(this.#tP.hidden=!0)}maybeShow(){this.#se&&(this.#i8||this.#iQ(),this.#se=!1,this.#tP.hidden=!1)}get isVisible(){return!1===this.#tP.hidden}}class iC extends iu{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=p.FREETEXT}
2render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class iS extends iu{#so=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let t=this.data,{width:e,height:i}=id(t.rect),s=this.svgFactory.create(e,i,!0),a=this.#so=this.svgFactory.createElement("svg:line");return a.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),a.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),a.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),a.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),a.setAttribute("stroke-width",t.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#so}addHighlightArea(){this.container.classList.add("highlightArea")}}class iT extends iu{#sl=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let t=this.data,{width:e,height:i}=id(t.rect),s=this.svgFactory.create(e,i,!0),a=t.borderStyle.width,r=this.#sl=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",a/2),r.setAttribute("y",a/2),r.setAttribute("width",e-a),r.setAttribute("height",i-a),r.setAttribute("stroke-width",a||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sl}addHighlightArea(){this.container.classList.add("highlightArea")}}class iM extends iu{#sh=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let t=this.data,{width:e,height:i}=id(t.rect),s=this.svgFactory.create(e,i,!0),a=t.borderStyle.width,r=this.#sh=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-a/2),r.setAttribute("ry",i/2-a/2),r.setAttribute("stroke-width",a||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sh}addHighlightArea(){this.container.classList.add("highlightArea")}}class ik extends iu{#sd=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;let{width:a,height:r}=id(t),n=this.svgFactory.create(a,r,!0),o=[];for(let i=0,s=e.length;i<s;i+=2){let s=e[i]-t[0],a=t[3]-e[i+1];o.push(`${s},${a}`)}o=o.join(" ");let l=this.#sd=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),n.append(l),this.container.append(n),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sd}addHighlightArea(){this.container.classList.add("highlightArea")}}class iL extends ik{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class iP extends iu{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class iR extends iu{#sc=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=p.INK}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,inkLists:e,borderStyle:i,popupRef:s}}=this,{width:a,height:r}=id(t),n=this.svgFactory.create(a,r,!0);for(let a of e){let e=[];for(let i=0,s=a.length;i<s;i+=2){let s=a[i]-t[0],r=t[3]-a[i+1];e.push(`${s},${r}`)}e=e.join(" ");let r=this.svgFactory.createElement(this.svgElementName);this.#sc.push(r),r.setAttribute("points",e),r.setAttribute("stroke-width",i.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),!s&&this.hasPopupData&&this._createPopup(),n.append(r)}return this.container.append(n),this.container}getElementsToTriggerPopup(){return this.#sc}addHighlightArea(){this.container.classList.add("highlightArea")}}class iI extends iu{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}
2class iD extends iu{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class iF extends iu{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class iO extends iu{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class iN extends iu{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class iB extends iu{#su=null;constructor(t){super(t,{isRenderable:!0});let{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#sp.bind(this)),this.#su=t;let{isMac:s}=$.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#sp()}),!i.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#su}addHighlightArea(){this.container.classList.add("highlightArea")}#sp(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class iH{#sg=null;#sm=null;#sf=new Map;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:a,viewport:r}){this.div=t,this.#sg=e,this.#sm=i,this.page=a,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}#sb(t,e){let i=t.firstChild||t;i.id=`${K}${e}`,this.div.append(t),this.#sg?.moveElementInDOM(this.div,t,i,!1)}async render(t){let{annotations:e}=t,i=this.div;tE(i,this.viewport);let s=new Map,a={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new tl,annotationStorage:t.annotationStorage||new tH,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=t.annotationType===v.POPUP;if(e){let e=s.get(t.id);if(!e)continue;a.elements=e}else{let{width:e,height:i}=id(t.rect);if(e<=0||i<=0)continue}a.data=t;let i=ic.create(a);if(!i.isRenderable)continue;if(!e&&t.popupRef){let e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}let r=i.render();t.hidden&&(r.style.visibility="hidden"),this.#sb(r,t.id),i.annotationEditorType>0&&(this.#sf.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#sv()}update({viewport:t}){let e=this.div;this.viewport=t,tE(e,{rotation:t.rotation}),this.#sv(),e.hidden=!1}#sv(){if(!this.#sm)return;let t=this.div;for(let[e,i]of this.#sm){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";let{firstChild:a}=s;a?"CANVAS"===a.nodeName?a.replaceWith(i):a.classList.contains("annotationContent")?a.after(i):a.before(i):s.append(i)}this.#sm.clear()}getEditableAnnotations(){return Array.from(this.#sf.values())}getEditableAnnotation(t){return this.#sf.get(t)}}let iz=/\r\n?|\n/g;class iU extends tF{#sA=this.editorDivBlur.bind(this);#sy=this.editorDivFocus.bind(this);#s_=this.editorDivInput.bind(this);#sw=this.editorDivKeydown.bind(this);#sx=this.editorDivPaste.bind(this);#i0;#sE="";#sC=`${this.id}-editor`;#ss;#sS=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=iU.prototype,e=t=>t.isEmpty(),i=tI.TRANSLATE_SMALL,s=tI.TRANSLATE_BIG;return L(this,"_keyboardManager",new tP([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=p.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#i0=t.color||iU._defaultColor||tF._defaultLineColor,this.#ss=t.fontSize||iU._defaultFontSize}static initialize(t,e){tF.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}
2static updateDefaultParams(t,e){switch(t){case g.FREETEXT_SIZE:iU._defaultFontSize=e;break;case g.FREETEXT_COLOR:iU._defaultColor=e}}updateParams(t,e){switch(t){case g.FREETEXT_SIZE:this.#sT(e);break;case g.FREETEXT_COLOR:this.#sM(e)}}static get defaultPropertiesToUpdate(){return[[g.FREETEXT_SIZE,iU._defaultFontSize],[g.FREETEXT_COLOR,iU._defaultColor||tF._defaultLineColor]]}get propertiesToUpdate(){return[[g.FREETEXT_SIZE,this.#ss],[g.FREETEXT_COLOR,this.#i0]]}#sT(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#ss)*this.parentScale),this.#ss=t,this.#sk()},i=this.#ss;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:g.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#sM(t){let e=t=>{this.#i0=this.editorDiv.style.color=t},i=this.#i0;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:g.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-iU._internalPadding*t,-(iU._internalPadding+this.#ss)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(p.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");let t=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#sw,{signal:t}),this.editorDiv.addEventListener("focus",this.#sy,{signal:t}),this.editorDiv.addEventListener("blur",this.#sA,{signal:t}),this.editorDiv.addEventListener("input",this.#s_,{signal:t}),this.editorDiv.addEventListener("paste",this.#sx,{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#sC),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#sw),this.editorDiv.removeEventListener("focus",this.#sy),this.editorDiv.removeEventListener("blur",this.#sA),this.editorDiv.removeEventListener("input",this.#s_),this.editorDiv.removeEventListener("paste",this.#sx),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#sL(){let t=[];for(let e of(this.editorDiv.normalize(),this.editorDiv.childNodes))t.push(iU.#sP(e));return t.join("\n")}#sk(){let t;let[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,a=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",a)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#sE,e=this.#sE=this.#sL().trimEnd();if(t===e)return;let i=t=>{if(this.#sE=t,!t){this.remove();return}this.#sR(),this._uiManager.rebuild(this),this.#sk()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#sk()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){iU._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){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)}render(){let t,e;if(this.div)return this.div;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#sC),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),tF._l10nPromise.get("pdfjs-free-text-default-content").then(t=>this.editorDiv?.setAttribute("default-content",t)),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#ss}px * var(--scale-factor))`,i.color=this.#i0,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),tT(this,this.div,["dblclick","keydown"]),this.width){let[i,s]=this.parentDimensions;
2if(this.annotationElementId){let a,r;let{position:n}=this.#sS,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:a=t+(n[0]-c)/h,r=e+this.height-(n[1]-u)/d;break;case 90:a=t+(n[0]-c)/h,r=e-(n[1]-u)/d,[o,l]=[l,-o];break;case 180:a=t-this.width+(n[0]-c)/h,r=e-(n[1]-u)/d,[o,l]=[-o,-l];break;case 270:a=t+(n[0]-c-this.height*d)/h,r=e+(n[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(a*i,r*s,o,l)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#sR(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #sP(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(iz,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=iU.#sI(e.getData("text")||"").replaceAll(iz,"\n");if(!s)return;let a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();let r=a.getRangeAt(0);
2if(!s.includes("\n")){r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),a.collapseToStart();return}let{startContainer:n,startOffset:o}=r,l=[],h=[];if(n.nodeType===Node.TEXT_NODE){let t=n.parentElement;if(h.push(n.nodeValue.slice(o).replaceAll(iz,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(iU.#sP(i))}}l.push(n.nodeValue.slice(0,o).replaceAll(iz,""))}else if(n===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(iU.#sP(i))}this.#sE=`${l.join("\n")}${s}${h.join("\n")}`,this.#sR();let d=new Range,c=l.reduce((t,e)=>t+e.length,0);for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}a.removeAllRanges(),a.addRange(d)}#sR(){if(this.editorDiv.replaceChildren(),this.#sE)for(let t of this.#sE.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#sD(){return this.#sE.replaceAll("\xa0"," ")}static #sI(t){return t.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}static deserialize(t,e,i){let s=null;if(t instanceof iC){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:a,rotation:r,id:n},textContent:o,textPosition:l,parent:{page:{pageNumber:h}}}=t;if(!o||0===o.length)return null;s=t={annotationType:p.FREETEXT,color:Array.from(i),fontSize:e,value:o.join("\n"),position:l,pageIndex:h-1,rect:a.slice(0),rotation:r,id:n,deleted:!1}}let a=super.deserialize(t,e,i);return a.#ss=t.fontSize,a.#i0=G.makeHexColor(...t.color),a.#sE=iU.#sI(t.value),a.annotationElementId=t.id||null,a.#sS=s,a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};let e=iU._internalPadding*this.parentScale,i=this.getRect(e,e),s=tF._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#i0),a={annotationType:p.FREETEXT,color:s,fontSize:this.#ss,value:this.#sD(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?a:this.annotationElementId&&!this.#sF(a)?null:(a.id=this.annotationElementId,a)}#sF(t){let{value:e,fontSize:i,color:s,pageIndex:a}=this.#sS;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==a}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(this.deleted)return e;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#ss}px * var(--scale-factor))`,i.color=this.#i0,e.replaceChildren(),this.#sE.split("\n"))){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}let s=iU._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#sE}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class i${#sO;#sN=[];#sB=[];constructor(t,e=0,i=0,s=!0){let a=1/0,r=-1/0,n=1/0,o=-1/0;for(let{x:i,y:s,width:l,height:h}of t){let t=1e-4*Math.floor((i-e)/1e-4),d=1e-4*Math.ceil((i+l+e)/1e-4),c=1e-4*Math.floor((s-e)/1e-4),u=1e-4*Math.ceil((s+h+e)/1e-4),p=[t,c,u,!0],g=[d,c,u,!1];this.#sN.push(p,g),a=Math.min(a,t),r=Math.max(r,d),n=Math.min(n,c),o=Math.max(o,u)}let l=r-a+2*i,h=o-n+2*i,d=a-i,c=n-i,u=this.#sN.at(s?-1:-2),p=[u[0],u[2]];for(let t of this.#sN){let[e,i,s]=t;t[0]=(e-d)/l,t[1]=(i-c)/h,t[2]=(s-c)/h}this.#sO={x:d,y:c,width:l,height:h,lastPoint:p}}getOutlines(){this.#sN.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#sN)e[3]?(t.push(...this.#sH(e)),this.#sz(e)):(this.#sU(e),t.push(...this.#sH(e)));return this.#s$(t)}#s$(t){let e;let i=[],s=new Set;for(let e of t){let[t,s,a]=e;i.push([t,s,e],[t,a,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],a=i[t+1][2];e.push(a),a.push(e),s.add(e),s.add(a)}let a=[];for(;s.size>0;){let t=s.values().next().value,[i,r,n,o,l]=t;s.delete(t);let h=i,d=r;for(e=[i,n],a.push(e);;){let t;if(s.has(o))t=o;else if(s.has(l))t=l;else break;s.delete(t),[i,r,n,o,l]=t,h!==i&&(e.push(h,d,i,d===r?r:n),h=i),d=d===r?n:r}e.push(h,d)}return new iG(a,this.#sO)}#sj(t){let e=this.#sB,i=0,s=e.length-1;for(;i<=s;){let a=i+s>>1,r=e[a][0];if(r===t)return a;r<t?i=a+1:s=a-1}return s+1}#sz([,t,e]){let i=this.#sj(t);this.#sB.splice(i,0,[t,e])}#sU([,t,e]){let i=this.#sj(t);for(let s=i;s<this.#sB.length;s++){let[i,a]=this.#sB[s];if(i!==t)break;
2if(i===t&&a===e){this.#sB.splice(s,1);return}}for(let s=i-1;s>=0;s--){let[i,a]=this.#sB[s];if(i!==t)break;if(i===t&&a===e){this.#sB.splice(s,1);return}}}#sH(t){let[e,i,s]=t,a=[[e,i,s]],r=this.#sj(s);for(let t=0;t<r;t++){let[i,s]=this.#sB[t];for(let t=0,r=a.length;t<r;t++){let[,n,o]=a[t];if(!(s<=n)&&!(o<=i)){if(n>=i){if(o>s)a[t][1]=s;else{if(1===r)return[];a.splice(t,1),t--,r--}continue}a[t][2]=i,o>s&&a.push([e,s,o])}}}return a}}class ij{toSVGPath(){throw Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw Error("Abstract getter `box` must be implemented.")}serialize(t,e){throw Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof iq}}class iG extends ij{#sO;#sG;constructor(t,e){super(),this.#sG=t,this.#sO=e}toSVGPath(){let t=[];for(let e of this.#sG){let[i,s]=e;t.push(`M${i} ${s}`);for(let a=2;a<e.length;a+=2){let r=e[a],n=e[a+1];r===i?(t.push(`V${n}`),s=n):n===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],a){let r=[],n=i-t,o=s-e;for(let e of this.#sG){let i=Array(e.length);for(let a=0;a<e.length;a+=2)i[a]=t+e[a]*n,i[a+1]=s-e[a+1]*o;r.push(i)}return r}get box(){return this.#sO}}class iV{#sO;#sV=[];#sq;#sW;#sK=[];#sX=new Float64Array(18);#sY;#sQ;#sJ;#sZ;#s0;#s1;#s2=[];static #s3=8;static #s5=2;static #s6=iV.#s3+iV.#s5;constructor({x:t,y:e},i,s,a,r,n=0){this.#sO=i,this.#s1=a*s,this.#sW=r,this.#sX.set([NaN,NaN,NaN,NaN,t,e],6),this.#sq=n,this.#sZ=iV.#s3*s,this.#sJ=iV.#s6*s,this.#s0=s,this.#s2.push(t,e)}get free(){return!0}isEmpty(){return isNaN(this.#sX[8])}#s4(){let t=this.#sX.subarray(4,6),e=this.#sX.subarray(16,18),[i,s,a,r]=this.#sO;return[(this.#sY+(t[0]-e[0])/2-i)/a,(this.#sQ+(t[1]-e[1])/2-s)/r,(this.#sY+(e[0]-t[0])/2-i)/a,(this.#sQ+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#sY=t,this.#sQ=e;let[i,s,a,r]=this.#sO,[n,o,l,h]=this.#sX.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#sJ)return!1;let p=u-this.#sZ,g=p/u,m=g*d,f=g*c,b=n,v=o;n=l,o=h,l+=m,h+=f,this.#s2?.push(t,e);let A=-f/p*this.#s1,y=m/p*this.#s1;return(this.#sX.set(this.#sX.subarray(2,8),0),this.#sX.set([l+A,h+y],4),this.#sX.set(this.#sX.subarray(14,18),12),this.#sX.set([l-A,h-y],16),isNaN(this.#sX[6]))?(0===this.#sK.length&&(this.#sX.set([n+A,o+y],2),this.#sK.push(NaN,NaN,NaN,NaN,(n+A-i)/a,(o+y-s)/r),this.#sX.set([n-A,o-y],14),this.#sV.push(NaN,NaN,NaN,NaN,(n-A-i)/a,(o-y-s)/r)),this.#sX.set([b,v,n,o,l,h],6),!this.isEmpty()):((this.#sX.set([b,v,n,o,l,h],6),Math.abs(Math.atan2(v-o,b-n)-Math.atan2(f,m))<Math.PI/2)?([n,o,l,h]=this.#sX.subarray(2,6),this.#sK.push(NaN,NaN,NaN,NaN,((n+l)/2-i)/a,((o+h)/2-s)/r),[n,o,b,v]=this.#sX.subarray(14,18),this.#sV.push(NaN,NaN,NaN,NaN,((b+n)/2-i)/a,((v+o)/2-s)/r)):([b,v,n,o,l,h]=this.#sX.subarray(0,6),this.#sK.push(((b+5*n)/6-i)/a,((v+5*o)/6-s)/r,((5*n+l)/6-i)/a,((5*o+h)/6-s)/r,((n+l)/2-i)/a,((o+h)/2-s)/r),[l,h,n,o,b,v]=this.#sX.subarray(12,18),this.#sV.push(((b+5*n)/6-i)/a,((v+5*o)/6-s)/r,((5*n+l)/6-i)/a,((5*o+h)/6-s)/r,((n+l)/2-i)/a,((o+h)/2-s)/r)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#sK,e=this.#sV,i=this.#sX.subarray(4,6),s=this.#sX.subarray(16,18),[a,r,n,o]=this.#sO,[l,h,d,c]=this.#s4();if(isNaN(this.#sX[6])&&!this.isEmpty())return`M${(this.#sX[2]-a)/n} ${(this.#sX[3]-r)/o} L${(this.#sX[4]-a)/n} ${(this.#sX[5]-r)/o} L${l} ${h} L${d} ${c} L${(this.#sX[16]-a)/n} ${(this.#sX[17]-r)/o} L${(this.#sX[14]-a)/n} ${(this.#sX[15]-r)/o} Z`;let u=[];u.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?u.push(`L${t[e+4]} ${t[e+5]}`):u.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);u.push(`L${(i[0]-a)/n} ${(i[1]-r)/o} L${l} ${h} L${d} ${c} L${(s[0]-a)/n} ${(s[1]-r)/o}`);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?u.push(`L${e[t+4]} ${e[t+5]}`):u.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return u.push(`L${e[4]} ${e[5]} Z`),u.join(" ")}getOutlines(){let t=this.#sK,e=this.#sV,i=this.#sX,s=i.subarray(4,6),a=i.subarray(16,18),[r,n,o,l]=this.#sO,h=new Float64Array((this.#s2?.length??0)+2);for(let t=0,e=h.length-2;t<e;t+=2)h[t]=(this.#s2[t]-r)/o,h[t+1]=(this.#s2[t+1]-n)/l;h[h.length-2]=(this.#sY-r)/o,h[h.length-1]=(this.#sQ-n)/l;let[d,c,u,p]=this.#s4();if(isNaN(i[6])&&!this.isEmpty()){let t=new Float64Array(36);return t.set([NaN,NaN,NaN,NaN,(i[2]-r)/o,(i[3]-n)/l,NaN,NaN,NaN,NaN,(i[4]-r)/o,(i[5]-n)/l,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,(i[16]-r)/o,(i[17]-n)/l,NaN,NaN,NaN,NaN,(i[14]-r)/o,(i[15]-n)/l],0),new iq(t,h,this.#sO,this.#s0,this.#sq,this.#sW)}let g=new Float64Array(this.#sK.length+24+this.#sV.length),m=t.length;for(let e=0;e<m;e+=2){if(isNaN(t[e])){g[e]=g[e+1]=NaN;continue}g[e]=t[e],g[e+1]=t[e+1]}g.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-n)/l,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,(a[0]-r)/o,(a[1]-n)/l],m),m+=24;for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){g[m]=g[m+1]=NaN,m+=2;continue}g[m]=e[t+i],g[m+1]=e[t+i+1],m+=2}return g.set([NaN,NaN,NaN,NaN,e[4],e[5]],m),new iq(g,h,this.#sO,this.#s0,this.#sq,this.#sW)}}class iq extends ij{#sO;#s8=null;#sq;#sW;#s2;#s0;#s7;constructor(t,e,i,s,a,r){super(),this.#s7=t,this.#s2=e,this.#sO=i,this.#s0=s,this.#sq=a,this.#sW=r,this.#s9(r);let{x:n,y:o,width:l,height:h}=this.#s8;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-n)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-n)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#s7[4]} ${this.#s7[5]}`];for(let e=6,i=this.#s7.length;e<i;e+=6){if(isNaN(this.#s7[e])){t.push(`L${this.#s7[e+4]} ${this.#s7[e+5]}`);continue}t.push(`C${this.#s7[e]} ${this.#s7[e+1]} ${this.#s7[e+2]} ${this.#s7[e+3]} ${this.#s7[e+4]} ${this.#s7[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],a){let r,n;let o=i-t,l=s-e;switch(a){case 0:r=this.#at(this.#s7,t,s,o,-l),n=this.#at(this.#s2,t,s,o,-l);break;case 90:r=this.#ae(this.#s7,t,e,o,l),n=this.#ae(this.#s2,t,e,o,l);break;
2case 180:r=this.#at(this.#s7,i,e,-o,l),n=this.#at(this.#s2,i,e,-o,l);break;case 270:r=this.#ae(this.#s7,i,s,-o,-l),n=this.#ae(this.#s2,i,s,-o,-l)}return{outline:Array.from(r),points:[Array.from(n)]}}#at(t,e,i,s,a){let r=new Float64Array(t.length);for(let n=0,o=t.length;n<o;n+=2)r[n]=e+t[n]*s,r[n+1]=i+t[n+1]*a;return r}#ae(t,e,i,s,a){let r=new Float64Array(t.length);for(let n=0,o=t.length;n<o;n+=2)r[n]=e+t[n+1]*s,r[n+1]=i+t[n]*a;return r}#s9(t){let e=this.#s7,i=e[4],s=e[5],a=i,r=s,n=i,o=s,l=i,h=s,d=t?Math.max:Math.min;for(let t=6,c=e.length;t<c;t+=6){if(isNaN(e[t]))a=Math.min(a,e[t+4]),r=Math.min(r,e[t+5]),n=Math.max(n,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=d(l,e[t+4]));else{let c=G.bezierBoundingBox(i,s,...e.slice(t,t+6));a=Math.min(a,c[0]),r=Math.min(r,c[1]),n=Math.max(n,c[2]),o=Math.max(o,c[3]),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))}i=e[t+4],s=e[t+5]}let c=a-this.#sq,u=r-this.#sq,p=n-a+2*this.#sq,g=o-r+2*this.#sq;this.#s8={x:c,y:u,width:p,height:g,lastPoint:[l,h]}}get box(){return this.#s8}getNewOutline(t,e){let{x:i,y:s,width:a,height:r}=this.#s8,[n,o,l,h]=this.#sO,d=a*l,c=r*h,u=i*l+n,p=s*h+o,g=new iV({x:this.#s2[0]*d+u,y:this.#s2[1]*c+p},this.#sO,this.#s0,t,this.#sW,e??this.#sq);for(let t=2;t<this.#s2.length;t+=2)g.add({x:this.#s2[t]*d+u,y:this.#s2[t+1]*c+p});return g.getOutlines()}}class iW{#iq=this.#iW.bind(this);#ai=this.#E.bind(this);#as=null;#aa=null;#ar;#an=null;#ao=!1;#al=!1;#w=null;#ah;#L=null;#ad;static get _keyboardManager(){return L(this,"_keyboardManager",new tP([[["Escape","mac+Escape"],iW.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],iW.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],iW.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],iW.prototype._moveToPrevious],[["Home","mac+Home"],iW.prototype._moveToBeginning],[["End","mac+End"],iW.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#al=!1,this.#ad=g.HIGHLIGHT_COLOR,this.#w=t):(this.#al=!0,this.#ad=g.HIGHLIGHT_DEFAULT_COLOR),this.#L=t?._uiManager||e,this.#ah=this.#L._eventBus,this.#ar=t?.color||this.#L?.highlightColors.values().next().value||"#FFFF98"}renderButton(){let t=this.#as=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);let e=this.#L._signal;t.addEventListener("click",this.#ac.bind(this),{signal:e}),t.addEventListener("keydown",this.#iq,{signal:e});let i=this.#aa=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#ar,t.append(i),t}renderMainDropdown(){let t=this.#an=this.#au();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#au(){let t=document.createElement("div"),e=this.#L._signal;for(let[i,s]of(t.addEventListener("contextmenu",tb,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#L.highlightColors)){let a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",s),a.title=i,a.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${i}`);let r=document.createElement("span");a.append(r),r.className="swatch",r.style.backgroundColor=s,a.setAttribute("aria-selected",s===this.#ar),a.addEventListener("click",this.#ap.bind(this,s),{signal:e}),t.append(a)}return t.addEventListener("keydown",this.#iq,{signal:e}),t}#ap(t,e){e.stopPropagation(),this.#ah.dispatch("switchannotationeditorparams",{source:this,type:this.#ad,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#as){this.#ac(t);return}let e=t.target.getAttribute("data-color");e&&this.#ap(e,t)}_moveToNext(t){if(!this.#ag){this.#ac(t);return}if(t.target===this.#as){this.#an.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#an?.firstChild||t.target===this.#as){this.#ag&&this._hideDropdownFromKeyboard();return}this.#ag||this.#ac(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#ag){this.#ac(t);return}this.#an.firstChild?.focus()}_moveToEnd(t){if(!this.#ag){this.#ac(t);return}this.#an.lastChild?.focus()}#iW(t){iW._keyboardManager.exec(this,t)}#ac(t){if(this.#ag){this.hideDropdown();return}if(this.#ao=0===t.detail,window.addEventListener("pointerdown",this.#ai,{signal:this.#L._signal}),this.#an){this.#an.classList.remove("hidden");return}let e=this.#an=this.#au();this.#as.append(e)}#E(t){this.#an?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#an?.classList.add("hidden"),window.removeEventListener("pointerdown",this.#ai)}get #ag(){return this.#an&&!this.#an.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#al){if(!this.#ag){this.#w?.unselect();return}this.hideDropdown(),this.#as.focus({preventScroll:!0,focusVisible:this.#ao})}}updateColor(t){if(this.#aa&&(this.#aa.style.backgroundColor=t),!this.#an)return;let e=this.#L.highlightColors.values();for(let i of this.#an.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#as?.remove(),this.#as=null,this.#aa=null,this.#an?.remove(),this.#an=null}}class iK extends tF{#am=null;#af=0;#ab;#av=null;#_=null;#aA=null;#ay=null;#a_=0;#aw=null;#ax=null;#l=null;#aE=!1;#tw=this.#aC.bind(this);#aS=null;#aT;#aM=null;#ak="";#s1;#aL="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=p.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=iK.prototype;return L(this,"_keyboardManager",new tP([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||iK._defaultColor,this.#s1=t.thickness||iK._defaultThickness,this.#aT=t.opacity||iK._defaultOpacity,this.#ab=t.boxes||null,this.#aL=t.methodOfCreation||"",this.#ak=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#aE=!0,this.#aP(t),this.#aR()):(this.#am=t.anchorNode,this.#af=t.anchorOffset,this.#ay=t.focusNode,this.#a_=t.focusOffset,this.#aI(),this.#aR(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#aE?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#s1,methodOfCreation:this.#aL}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#aI(){let t=new i$(this.#ab,.001);this.#ax=t.getOutlines(),{x:this.x,y:this.y,width:this.width,height:this.height}=this.#ax.box;let e=new i$(this.#ab,.0025,.001,"ltr"===this._uiManager.direction);this.#aA=e.getOutlines();let{lastPoint:i}=this.#aA.box;this.#aS=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#aP({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#ax=t,this.#aA=t.getNewOutline(this.#s1/2+1.5,.0025),e>=0)this.#l=e,this.#av=i,this.parent.drawLayer.finalizeLine(e,t),this.#aM=this.parent.drawLayer.highlightOutline(this.#aA);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#l,t),this.parent.drawLayer.updateBox(this.#l,iK.#aD(this.#ax.box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#aM,this.#aA),this.parent.drawLayer.updateBox(this.#aM,iK.#aD(this.#aA.box,e))}let{x:s,y:a,width:r,height:n}=t.box;switch(this.rotation){case 0:this.x=s,this.y=a,this.width=r,this.height=n;break;case 90:{let[t,e]=this.parentDimensions;this.x=a,this.y=1-s,this.width=r*e/t,this.height=n*t/e;break}case 180:this.x=1-s,this.y=1-a,this.width=r,this.height=n;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-a,this.y=s,this.width=r*e/t,this.height=n*t/e}}let{lastPoint:o}=this.#aA.box;this.#aS=[(o[0]-s)/r,(o[1]-a)/n]}static initialize(t,e){tF.initialize(t,e),iK._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case g.HIGHLIGHT_DEFAULT_COLOR:iK._defaultColor=e;break;case g.HIGHLIGHT_THICKNESS:iK._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#aS}updateParams(t,e){switch(t){case g.HIGHLIGHT_COLOR:this.#sM(e);break;case g.HIGHLIGHT_THICKNESS:this.#aF(e)}}static get defaultPropertiesToUpdate(){return[[g.HIGHLIGHT_DEFAULT_COLOR,iK._defaultColor],[g.HIGHLIGHT_THICKNESS,iK._defaultThickness]]}get propertiesToUpdate(){return[[g.HIGHLIGHT_COLOR,this.color||iK._defaultColor],[g.HIGHLIGHT_THICKNESS,this.#s1||iK._defaultThickness],[g.HIGHLIGHT_FREE,this.#aE]]}#sM(t){let e=t=>{this.color=t,this.parent?.drawLayer.changeColor(this.#l,t),this.#_?.updateColor(t)},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:g.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#aF(t){let e=this.#s1,i=t=>
2{this.#s1=t,this.#aO(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:g.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){let t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#_=new iW({editor:this}),t.addColorPicker(this.#_)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#aN())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#aN())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#aB(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#aR(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#aB():t&&(this.#aR(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#aO(t){if(!this.#aE)return;this.#aP({highlightOutlines:this.#ax.getNewOutline(t/2)}),this.fixAndSetPosition();let[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#aB(){null!==this.#l&&this.parent&&(this.parent.drawLayer.remove(this.#l),this.#l=null,this.parent.drawLayer.remove(this.#aM),this.#aM=null)}#aR(t=this.parent){null===this.#l&&({id:this.#l,clipPathId:this.#av}=t.drawLayer.highlight(this.#ax,this.color,this.#aT),this.#aM=t.drawLayer.highlightOutline(this.#aA),this.#aw&&(this.#aw.style.clipPath=this.#av))}static #aD({x:t,y:e,width:i,height:s},a){switch(a){case 90:return{x:1-e-s,y:t,width:s,height:i};case 180:return{x:1-t-i,y:1-e-s,width:i,height:s};case 270:return{x:e,y:1-t-i,width:s,height:i}}return{x:t,y:e,width:i,height:s}}rotate(t){let e;let{drawLayer:i}=this.parent;this.#aE?(t=(t-this.rotation+360)%360,e=iK.#aD(this.#ax.box,t)):e=iK.#aD(this,t),i.rotate(this.#l,t),i.rotate(this.#aM,t),i.updateBox(this.#l,e),i.updateBox(this.#aM,iK.#aD(this.#aA.box,t))}render(){if(this.div)return this.div;let t=super.render();this.#ak&&(t.setAttribute("aria-label",this.#ak),t.setAttribute("role","mark")),this.#aE?t.classList.add("free"):this.div.addEventListener("keydown",this.#tw,{signal:this._uiManager._signal});let e=this.#aw=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#av;let[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),tT(this,this.#aw,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(this.#aM,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#aM,"hovered")}#aC(t){iK._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#aH(!0);break;case 1:case 3:this.#aH(!1)}}#aH(t){if(!this.#am)return;let e=window.getSelection();t?e.setPosition(this.#am,this.#af):e.setPosition(this.#ay,this.#a_)}select(){super.select(),this.#aM&&(this.parent?.drawLayer.removeClass(this.#aM,"hovered"),this.parent?.drawLayer.addClass(this.#aM,"selected"))}unselect(){super.unselect(),this.#aM&&(this.parent?.drawLayer.removeClass(this.#aM,"selected"),this.#aE||this.#aH(!1))}get _mustFixPosition(){return!this.#aE}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(this.#l,t),this.parent.drawLayer.show(this.#aM,t))}#aN(){return this.#aE?this.rotation:0}#az(){if(this.#aE)return null;let[t,e]=this.pageDimensions,i=this.#ab,s=new Float32Array(8*i.length),a=0;for(let{x:r,y:n,width:o,height:l}of i){let i=r*t,h=(1-n-l)*e;s[a]=s[a+4]=i,s[a+1]=s[a+3]=h,s[a+2]=s[a+6]=i+o*t,s[a+5]=s[a+7]=h+l*e,a+=8}return s}#aU(t){return this.#ax.serialize(t,this.#aN())}static startHighlighting(t,e,{target:i,x:s,y:a}){let{x:r,y:n,width:o,height:l}=i.getBoundingClientRect(),h=e=>{this.#a$(t,e)},d=t._signal,c={capture:!0,passive:!1,signal:d},u=t=>{t.preventDefault(),t.stopPropagation()},p=e=>{i.removeEventListener("pointermove",h),window.removeEventListener("blur",p),window.removeEventListener("pointerup",p),window.removeEventListener("pointerdown",u,c),window.removeEventListener("contextmenu",tb),this.#aj(t,e)};window.addEventListener("blur",p,{signal:d}),window.addEventListener("pointerup",p,{signal:d}),window.addEventListener("pointerdown",u,c),window.addEventListener("contextmenu",tb,{signal:d}),i.addEventListener("pointermove",h,{signal:d}),this._freeHighlight=new iV({x:s,y:a},[r,n,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static #a$(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static #aj(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static deserialize(t,e,i){let s=super.deserialize(t,e,i),{rect:[a,r,n,o],color:l,quadPoints:h}=t;s.color=G.makeHexColor(...l),s.#aT=t.opacity;let[d,c]=s.pageDimensions;s.width=(n-a)/d,s.height=(o-r)/c;let u=s.#ab=[];for(let t=0;t<h.length;t+=8)u.push({x:(h[4]-n)/d,y:(o-(1-h[t+5]))/c,width:(h[t+2]-h[t])/d,height:(h[t+5]-h[t+1])/c});return s.#aI(),s}serialize(t=!1){if(this.isEmpty()||t)return null;let e=this.getRect(0,0),i=tF._colorManager.convert(this.color);return{annotationType:p.HIGHLIGHT,color:i,opacity:this.#aT,thickness:this.#s1,quadPoints:this.#az(),outlines:this.#aU(e),pageIndex:this.pageIndex,rect:e,rotation:this.#aN(),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}}class iX extends tF{#aG=0;#aV=0;#aq=this.canvasPointermove.bind(this);#aW=this.canvasPointerleave.bind(this);#aK=this.canvasPointerup.bind(this);#aX=this.canvasPointerdown.bind(this);#aY=null;#aQ=new Path2D;#aJ=!1;#aZ=!1;#a0=!1;#a1=null;#a2=0;#a3=0;#a5=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=p.INK;constructor(t){super({...t,name:"inkEditor"}),this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,e){tF.initialize(t,e)}static updateDefaultParams(t,e){switch(t){case g.INK_THICKNESS:iX._defaultThickness=e;break;case g.INK_COLOR:iX._defaultColor=e;break;case g.INK_OPACITY:iX._defaultOpacity=e/100}}updateParams(t,e){switch(t){case g.INK_THICKNESS:this.#aF(e);break;case g.INK_COLOR:this.#sM(e);break;case g.INK_OPACITY:this.#a6(e)}}static get defaultPropertiesToUpdate(){return[[g.INK_THICKNESS,iX._defaultThickness],[g.INK_COLOR,iX._defaultColor||tF._defaultLineColor],[g.INK_OPACITY,Math.round(100*iX._defaultOpacity)]]}get propertiesToUpdate(){return[[g.INK_THICKNESS,this.thickness||iX._defaultThickness],[g.INK_COLOR,this.color||iX._defaultColor||tF._defaultLineColor],[g.INK_OPACITY,Math.round(100*(this.opacity??iX._defaultOpacity))]]}#aF(t){let e=t=>{this.thickness=t,this.#a4()},i=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:g.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#sM(t){let e=t=>{this.color=t,this.#a8()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:g.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#a6(t){let e=t=>{this.opacity=t,this.#a8()};t/=100;let i=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:g.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(this.#a7(),this.#a9()),this.isAttachedToDOM||(this.parent.add(this),this.#rt()),this.#a4()))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#aY&&(clearTimeout(this.#aY),this.#aY=null),this.#a1?.disconnect(),this.#a1=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&null===t&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){let[t,e]=this.parentDimensions,i=this.width*t,s=this.height*e;this.setDimensions(i,s)}enableEditMode(){this.#aJ||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#aX,{signal:this._uiManager._signal}))}disableEditMode(){this.isInEditMode()&&null!==this.canvas&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#aX))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}
2#re(){let{parentRotation:t,parentDimensions:[e,i]}=this;switch(t){case 90:return[0,i,i,e];case 180:return[e,i,e,i];case 270:return[e,0,i,e];default:return[0,0,e,i]}}#ri(){let{ctx:t,color:e,opacity:i,thickness:s,parentScale:a,scaleFactor:r}=this;t.lineWidth=s*a/r,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${Math.round(Math.min(255,Math.max(1,255*i))).toString(16).padStart(2,"0")}`}#rs(t,e){let i=this._uiManager._signal;this.canvas.addEventListener("contextmenu",tb,{signal:i}),this.canvas.addEventListener("pointerleave",this.#aW,{signal:i}),this.canvas.addEventListener("pointermove",this.#aq,{signal:i}),this.canvas.addEventListener("pointerup",this.#aK,{signal:i}),this.canvas.removeEventListener("pointerdown",this.#aX),this.isEditing=!0,this.#a0||(this.#a0=!0,this.#rt(),this.thickness||=iX._defaultThickness,this.color||=iX._defaultColor||tF._defaultLineColor,this.opacity??=iX._defaultOpacity),this.currentPath.push([t,e]),this.#aZ=!1,this.#ri(),this.#a5=()=>{this.#ra(),this.#a5&&window.requestAnimationFrame(this.#a5)},window.requestAnimationFrame(this.#a5)}#rr(t,e){let[i,s]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===i&&e===s)return;let a=this.currentPath,r=this.#aQ;if(a.push([t,e]),this.#aZ=!0,a.length<=2){r.moveTo(...a[0]),r.lineTo(t,e);return}3===a.length&&(this.#aQ=r=new Path2D,r.moveTo(...a[0])),this.#rn(r,...a.at(-3),...a.at(-2),t,e)}#ro(){if(0===this.currentPath.length)return;let t=this.currentPath.at(-1);this.#aQ.lineTo(...t)}#rl(t,e){let i;if(this.#a5=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#rr(t,e),this.#ro(),1!==this.currentPath.length)i=this.#rh();else{let s=[t,e];i=[[s,s.slice(),s.slice(),s]]}let s=this.#aQ,a=this.currentPath;this.currentPath=[],this.#aQ=new Path2D,this.addCommands({cmd:()=>{this.allRawPaths.push(a),this.paths.push(i),this.bezierPath2D.push(s),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(this.#a7(),this.#a9()),this.#a4())},mustExec:!0})}#ra(){if(!this.#aZ)return;this.#aZ=!1,this.thickness,this.parentScale;let t=this.currentPath.slice(-3);t.map(t=>t[0]),t.map(t=>t[1]);let{ctx:e}=this;for(let t of(e.save(),e.clearRect(0,0,this.canvas.width,this.canvas.height),this.bezierPath2D))e.stroke(t);e.stroke(this.#aQ),e.restore()}#rn(t,e,i,s,a,r,n){let o=(e+s)/2,l=(i+a)/2,h=(s+r)/2,d=(a+n)/2;t.bezierCurveTo(o+2*(s-o)/3,l+2*(a-l)/3,h+2*(s-h)/3,d+2*(a-d)/3,h,d)}#rh(){let t;let e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];let i=[],[s,a]=e[0];for(t=1;t<e.length-2;t++){let[r,n]=e[t],[o,l]=e[t+1],h=(r+o)/2,d=(n+l)/2,c=[s+2*(r-s)/3,a+2*(n-a)/3],u=[h+2*(r-h)/3,d+2*(n-d)/3];i.push([[s,a],c,u,[h,d]]),[s,a]=[h,d]}let[r,n]=e[t],[o,l]=e[t+1],h=[s+2*(r-s)/3,a+2*(n-a)/3];return i.push([[s,a],h,[o+2*(r-o)/3,l+2*(n-l)/3],[o,l]]),i}#a8(){if(this.isEmpty()){this.#rd();return}this.#ri();let{canvas:t,ctx:e}=this;for(let i of(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),this.#rd(),this.bezierPath2D))e.stroke(i)}commit(){this.#aJ||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#aJ=!0,this.div.classList.add("disabled"),this.#a4(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){0===t.button&&this.isInEditMode()&&!this.#aJ&&(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),this.#rs(t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),this.#rr(t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),this.#rc(t)}canvasPointerleave(t){this.#rc(t)}#rc(t){this.canvas.removeEventListener("pointerleave",this.#aW),this.canvas.removeEventListener("pointermove",this.#aq),this.canvas.removeEventListener("pointerup",this.#aK),this.canvas.addEventListener("pointerdown",this.#aX,{signal:this._uiManager._signal}),this.#aY&&clearTimeout(this.#aY),this.#aY=setTimeout(()=>{this.#aY=null,this.canvas.removeEventListener("contextmenu",tb)},10),this.#rl(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackgroun
2d()}#a7(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#a9(){this.#a1=new ResizeObserver(t=>{let e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}),this.#a1.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#a1?.disconnect(),this.#a1=null},{once:!0})}get isResizable(){return!this.isEmpty()&&this.#aJ}render(){let t,e;if(this.div)return this.div;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");let[i,s,a,r]=this.#re();if(this.setAt(i,s,0,0),this.setDims(a,r),this.#a7(),this.width){let[i,s]=this.parentDimensions;this.setAspectRatio(this.width*i,this.height*s),this.setAt(t*i,e*s,this.width*i,this.height*s),this.#a0=!0,this.#rt(),this.setDims(this.width*i,this.height*s),this.#a8(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#a9(),this.div}#rt(){if(!this.#a0)return;let[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#rd()}setDimensions(t,e){let i=Math.round(t),s=Math.round(e);if(this.#a2===i&&this.#a3===s)return;
2this.#a2=i,this.#a3=s,this.canvas.style.visibility="hidden";let[a,r]=this.parentDimensions;this.width=t/a,this.height=e/r,this.fixAndSetPosition(),this.#aJ&&this.#ru(t,e),this.#rt(),this.#a8(),this.canvas.style.visibility="visible",this.fixDims()}#ru(t,e){let i=this.#rp(),s=(t-i)/this.#aV,a=(e-i)/this.#aG;this.scaleFactor=Math.min(s,a)}#rd(){let t=this.#rp()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static #rg(t){let e=new Path2D;for(let i=0,s=t.length;i<s;i++){let[s,a,r,n]=t[i];0===i&&e.moveTo(...s),e.bezierCurveTo(a[0],a[1],r[0],r[1],n[0],n[1])}return e}static #rm(t,e,i){let[s,a,r,n]=e;switch(i){case 0:for(let e=0,i=t.length;e<i;e+=2)t[e]+=s,t[e+1]=n-t[e+1];break;case 90:for(let e=0,i=t.length;e<i;e+=2){let i=t[e];t[e]=t[e+1]+s,t[e+1]=i+a}break;case 180:for(let e=0,i=t.length;e<i;e+=2)t[e]=r-t[e],t[e+1]+=a;break;case 270:for(let e=0,i=t.length;e<i;e+=2){let i=t[e];t[e]=r-t[e+1],t[e+1]=n-i}break;default:throw Error("Invalid rotation")}return t}static #rf(t,e,i){let[s,a,r,n]=e;switch(i){case 0:for(let e=0,i=t.length;e<i;e+=2)t[e]-=s,t[e+1]=n-t[e+1];break;case 90:for(let e=0,i=t.length;e<i;e+=2){let i=t[e];t[e]=t[e+1]-a,t[e+1]=i-s}break;case 180:for(let e=0,i=t.length;e<i;e+=2)t[e]=r-t[e],t[e+1]-=a;break;case 270:for(let e=0,i=t.length;e<i;e+=2){let i=t[e];t[e]=n-t[e+1],t[e+1]=r-i}break;default:throw Error("Invalid rotation")}return t}#rb(t,e,i,s){let a=[],r=this.thickness/2,n=t*e+r,o=t*i+r;for(let e of this.paths){let i=[],r=[];for(let s=0,a=e.length;s<a;s++){let[l,h,d,c]=e[s];if(l[0]===c[0]&&l[1]===c[1]&&1===a){let e=t*l[0]+n,s=t*l[1]+o;i.push(e,s),r.push(e,s);break}let u=t*l[0]+n,p=t*l[1]+o,g=t*h[0]+n,m=t*h[1]+o,f=t*d[0]+n,b=t*d[1]+o,v=t*c[0]+n,A=t*c[1]+o;0===s&&(i.push(u,p),r.push(u,p)),i.push(g,m,f,b,v,A),r.push(g,m),s===a-1&&r.push(v,A)}a.push({bezier:iX.#rm(i,s,this.rotation),points:iX.#rm(r,s,this.rotation)})}return a}#rv(){let t=1/0,e=-1/0,i=1/0,s=-1/0;for(let a of this.paths)for(let[r,n,o,l]of a){let a=G.bezierBoundingBox(...r,...n,...o,...l);t=Math.min(t,a[0]),i=Math.min(i,a[1]),e=Math.max(e,a[2]),s=Math.max(s,a[3])}return[t,i,e,s]}#rp(){return this.#aJ?Math.ceil(this.thickness*this.parentScale):0}#a4(t=!1){if(this.isEmpty())return;if(!this.#aJ){this.#a8();return}let e=this.#rv(),i=this.#rp();this.#aV=Math.max(tF.MIN_SIZE,e[2]-e[0]),this.#aG=Math.max(tF.MIN_SIZE,e[3]-e[1]);let s=Math.ceil(i+this.#aV*this.scaleFactor),a=Math.ceil(i+this.#aG*this.scaleFactor),[r,n]=this.parentDimensions;this.width=s/r,this.height=a/n,this.setAspectRatio(s,a);let o=this.translationX,l=this.translationY;this.translationX=-e[0],this.translationY=-e[1],this.#rt(),this.#a8(),this.#a2=s,this.#a3
2=a,this.setDims(s,a);let h=t?i/this.scaleFactor/2:0;this.translate(o-this.translationX-h,l-this.translationY-h)}static deserialize(t,e,i){if(t instanceof iR)return null;let s=super.deserialize(t,e,i);s.thickness=t.thickness,s.color=G.makeHexColor(...t.color),s.opacity=t.opacity;let[a,r]=s.pageDimensions,n=s.width*a,o=s.height*r,l=s.parentScale,h=t.thickness/2;s.#aJ=!0,s.#a2=Math.round(n),s.#a3=Math.round(o);let{paths:d,rect:c,rotation:u}=t;for(let{bezier:t}of d){t=iX.#rf(t,c,u);let e=[];s.paths.push(e);let i=l*(t[0]-h),a=l*(t[1]-h);for(let s=2,r=t.length;s<r;s+=6){let r=l*(t[s]-h),n=l*(t[s+1]-h),o=l*(t[s+2]-h),d=l*(t[s+3]-h),c=l*(t[s+4]-h),u=l*(t[s+5]-h);e.push([[i,a],[r,n],[o,d],[c,u]]),i=c,a=u}let r=this.#rg(e);s.bezierPath2D.push(r)}let p=s.#rv();return s.#aV=Math.max(tF.MIN_SIZE,p[2]-p[0]),s.#aG=Math.max(tF.MIN_SIZE,p[3]-p[1]),s.#ru(n,o),s}serialize(){if(this.isEmpty())return null;let t=this.getRect(0,0),e=tF._colorManager.convert(this.ctx.strokeStyle);return{annotationType:p.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:this.#rb(this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class iY extends tF{#rA=null;#ry=null;#r_=null;#rw=null;#rx=null;#rE="";#rC=null;#a1=null;#rS=null;#rT=!1;#rM=!1;static _type="stamp";static _editorType=p.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#rw=t.bitmapUrl,this.#rx=t.bitmapFile}static initialize(t,e){tF.initialize(t,e)}static get supportedTypes(){return L(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return L(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(p.STAMP,{bitmapFile:t.getAsFile()})}#rk(t,e=!1){if(!t){this.remove();return}this.#rA=t.bitmap,e||(this.#ry=t.id,this.#rT=t.isSvg),t.file&&(this.#rE=t.file.name),this.#a7()}#rL(){this.#r_=null,this._uiManager.enableWaiting(!1),this.#rC&&this.div.focus()}#rP(){if(this.#ry){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#ry).then(t=>this.#rk(t,!0)).finally(()=>this.#rL());return}if(this.#rw){let t=this.#rw;this.#rw=null,this._uiManager.enableWaiting(!0),this.#r_=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#rk(t)).finally(()=>this.#rL());return}if(this.#rx){let t=this.#rx;this.#rx=null,this._uiManager.enableWaiting(!0),this.#r_=this._uiManager.imageManager.getFromFile(t).then(t=>this.#rk(t)).finally(()=>this.#rL());return}let t=document.createElement("input");t.type="file",t.accept=iY.supportedTypesStr;let e=this._uiManager._signal;this.#r_=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this.#rk(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#rL()),t.click()}remove(){this.#ry&&(this.#rA=null,this._uiManager.imageManager.deleteId(this.#ry),this.#rC?.remove(),this.#rC=null,this.#a1?.disconnect(),this.#a1=null,this.#rS&&(clearTimeout(this.#rS),this.#rS=null)),super.remove()}rebuild(){if(!this.parent){this.#ry&&this.#rP();return}super.rebuild(),null!==this.div&&(this.#ry&&null===this.#rC&&this.#rP(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#r_||this.#rA||this.#rw||this.#rx||this.#ry)}get isResizable(){return!0}render(){let t,e;if(this.div)return this.div;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#rA?this.#a7():this.#rP(),this.width){let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this.div}#a7(){let{div:t}=this,{width:e,height:i}=this.#rA,[s,a]=this.pageDimensions;if(this.width)e=this.width*s,i=this.height*a;else if(e>.75*s||i>.75*a){let t=Math.min(.75*s/e,.75*a/i);e*=t,i*=t}let[r,n]=this.parentDimensions;this.setDims(e*r/s,i*n/a),this._uiManager.enableWaiting(!1);let o=this.#rC=document.createElement("canvas");t.append(o),t.hidden=!1,this.#rR(e,i),this.#a9(),this.#rM||(this.parent.addUndoableEditor(this),this.#rM=!0),this._reportTelemetry({action:"inserted_image"}),this.#rE&&o.setAttribute("aria-label",this.#rE)}#rI(t,e){let[i,s]=this.parentDimensions;this.width=t/i,this.height=e/s,this.setDims(t,e),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==this.#rS&&clearTimeout(this.#rS),this.#rS=setTimeout(()=>{this.#rS=null,this.#rR(t,e)},200)}#rD(t,e){let{width:i,height:s}=this.#rA,a=i,r=s,n=this.#rA;for(;a>2*t||r>2*e;){let i=a,s=r;a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));let o=new OffscreenCanvas(a,r);
2o.getContext("2d").drawImage(n,0,0,i,s,0,0,a,r),n=o.transferToImageBitmap()}return n}#rR(t,e){t=Math.ceil(t),e=Math.ceil(e);let i=this.#rC;if(!i||i.width===t&&i.height===e)return;i.width=t,i.height=e;let s=this.#rT?this.#rA:this.#rD(t,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){let i=new OffscreenCanvas(t,e).getContext("2d");i.drawImage(s,0,0,s.width,s.height,0,0,t,e),this._uiManager.mlGuess({service:"image-to-text",request:{data:i.getImageData(0,0,t,e).data,width:t,height:e,channels:4}}).then(t=>{let e=t?.output||"";this.parent&&e&&!this.hasAltText()&&(this.altTextData={altText:e,decorative:!1})})}let a=i.getContext("2d");a.filter=this._uiManager.hcmFilter,a.drawImage(s,0,0,s.width,s.height,0,0,t,e)}getImageForAltText(){return this.#rC}#rF(t){if(t){if(this.#rT){let t=this._uiManager.imageManager.getSvgUrl(this.#ry);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#rA,t.getContext("2d").drawImage(this.#rA,0,0),t.toDataURL()}if(this.#rT){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*ti.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*ti.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(i,s);return a.getContext("2d").drawImage(this.#rA,0,0,this.#rA.width,this.#rA.height,0,0,i,s),a.transferToImageBitmap()}return structuredClone(this.#rA)}#a9(){this._uiManager._signal&&(this.#a1=new ResizeObserver(t=>{let e=t[0].contentRect;e.width&&e.height&&this.#rI(e.width,e.height)}),this.#a1.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#a1?.disconnect(),this.#a1=null},{once:!0}))}static deserialize(t,e,i){if(t instanceof iN)return null;let s=super.deserialize(t,e,i),{rect:a,bitmapUrl:r,bitmapId:n,isSvg:o,accessibilityData:l}=t;n&&i.imageManager.isValidId(n)?s.#ry=n:s.#rw=r,s.#rT=o;let[h,d]=s.pageDimensions;return s.width=(a[2]-a[0])/h,s.height=(a[3]-a[1])/d,l&&(s.altTextData=l),s}serialize(t=!1,e=null){if(this.isEmpty())return null;let i={annotationType:p.STAMP,bitmapId:this.#ry,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#rT,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#rF(!0),i.accessibilityData=this.altTextData,i;let{decorative:s,altText:a}=this.altTextData;if(!s&&a&&(i.accessibilityData={type:"Figure",alt:a}),null===e)return i;e.stamps||=new Map;let r=this.#rT?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#ry)){if(this.#rT){let t=e.stamps.get(this.#ry);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#rF(!1))}}else e.stamps.set(this.#ry,{area:r,serialized:i}),i.bitmap=this.#rF(!1);return i}}class iQ{#sg;#rO=!1;#rN=null;#rB=null;#rH=null;#rz=null;#rU=null;#r$=new Map;#rj=!1;#rG=!1;#rV=!1;#rq=null;#L;static _initialized=!1;static #J=new Map([iU,iX,iY,iK].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,accessibilityManager:s,annotationLayer:a,drawLayer:r,textLayer:n,viewport:o,l10n:l}){let h=[...iQ.#J.values()];if(!iQ._initialized)for(let e of(iQ._initialized=!0,h))e.initialize(l,t);t.registerEditorTypes(h),this.#L=t,this.pageIndex=e,this.div=i,this.#sg=s,this.#rN=a,this.viewport=o,this.#rq=n,this.drawLayer=r,this.#L.addLayer(this)}get isEmpty(){return 0===this.#r$.size}get isInvisible(){return this.isEmpty&&this.#L.getMode()===p.NONE}updateToolbar(t){this.#L.updateToolbar(t)}updateMode(t=this.#L.getMode()){switch(this.#rW(),t){case p.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case p.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case p.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;for(let i of iQ.#J.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#rq?.div}addInkEditorIfNeeded(t){if(this.#L.getMode()===p.INK){if(!t){for(let t of this.#r$.values())if(t.isEmpty()){t.setInBackgroun
2d();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(t){this.#L.setEditingState(t)}addCommands(t){this.#L.addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#rN?.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let e of this.#r$.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#L.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(this.#rN)for(let e of this.#rN.getEditableAnnotations()){if(e.hide(),this.#L.isDeletedAnnotationElement(e.data.id)||t.has(e.data.id))continue;let i=this.deserialize(e);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){this.#rV=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,e=new Map;for(let i of this.#r$.values())if(i.disableEditing(),i.annotationElementId){if(null!==i.serialize()){t.set(i.annotationElementId,i);continue}e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()}if(this.#rN)for(let i of this.#rN.getEditableAnnotations()){let{id:s}=i.data;if(this.#L.isDeletedAnnotationElement(s))continue;let a=e.get(s);if(a){a.resetAnnotationElement(i),a.show(!1),i.show();continue}(a=t.get(s))&&(this.#L.addChangedExistingAnnotation(a),a.renderAnnotationElement(i),a.show(!1)),i.show()}this.#rW(),this.isEmpty&&(this.div.hidden=!0);let{classList:i}=this.div;for(let t of iQ.#J.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#rV=!1}getEditableAnnotation(t){return this.#rN?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#L.getActive()!==t&&this.#L.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1,this.#rq?.div&&!this.#rz&&(this.#rz=this.#rK.bind(this),this.#rq.div.addEventListener("pointerdown",this.#rz,{signal:this.#L._signal}),this.#rq.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#rq?.div&&this.#rz&&(this.#rq.div.removeEventListener("pointerdown",this.#rz),this.#rz=null,this.#rq.div.classList.remove("highlighting"))}#rK(t){if(this.#L.unselectAll(),t.target===this.#rq.div){let{isMac:e}=$.platform;0!==t.button||t.ctrlKey&&e||(this.#L.showAllEditors("highlight",!0,!0),this.#rq.div.classList.add("free"),iK.startHighlighting(this,"ltr"===this.#L.direction,t),this.#rq.div.addEventListener("pointerup",()=>{this.#rq.div.classList.remove("free")},{once:!0,signal:this.#L._signal}),t.preventDefault())}}enableClick(){if(this.#rH)return;let t=this.#L._signal;this.#rH=this.pointerdown.bind(this),this.#rB=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#rH,{signal:t}),this.div.addEventListener("pointerup",this.#rB,{signal:t})}disableClick(){this.#rH&&(this.div.removeEventListener("pointerdown",this.#rH),this.div.removeEventListener("pointerup",this.#rB),this.#rH=null,this.#rB=null)}attach(t){this.#r$.set(t.id,t);let{annotationElementId:e}=t;e&&this.#L.isDeletedAnnotationElement(e)&&this.#L.removeDeletedAnnotationElement(t)}detach(t){this.#r$.delete(t.id),this.#sg?.removePointerInTextLayer(t.contentDiv),!this.#rV&&t.annotationElementId&&this.#L.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#L.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#rG||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#L.addDeletedAnnotationElement(t.annotationElementId),tF.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#L.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#L.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#rU&&(t._focusEventsAllowed=!1,this.#rU=setTimeout(()=>{this.#rU=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#L._signal}),e.focus())},0)),t._structTreeParentId=this.#sg?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#L.getId()}get #rX(){return iQ.#J.get(this.#L.getMode())}get _signal(){return this.#L._signal}#rY(t){let e=this.#rX;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#rX?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#L.updateToolbar(t),this.#L.updateMode(t);let{offsetX:i,offsetY:s}=this.#rQ(),a=this.getNextId(),r=this.#rY({parent:this,id:a,x:i,y:s,uiManager:this.#L,isCentered:!0,...e});r&&this.add(r)}deserialize(t){return iQ.#J.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#L)||null}createAndAddNewEditor(t,e,i={}){let s=this.getNextId(),a=this.#rY({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#L,isCentered:e,...i});return a&&this.add(a),a}#rQ(){let{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),a=Math.max(0,t),r=Math.max(0,e),n=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),l=(a+n)/2-t,h=(r+o)/2-e,[d,c]=this.viewport.rotation%180==0?[l,h]:[h,l];return{offsetX:d,offsetY:c}}addNewEditor(){this.createAndAddNewEditor(this.#rQ(),!0)}setSelected(t){this.#L.setSelected(t)}toggleSelected(t){this.#L.toggleSelected(t)}isSelected(t){return this.#L.isSelected(t)}unselect(t){this.#L.unselect(t)}pointerup(t){let{isMac:e}=$.platform;if(0===t.button&&(!t.ctrlKey||!e)&&t.target===this.div&&this.#rj){if(this.#rj=!1,!this.#rO){this.#rO=!0;return}if(this.#L.getMode()===p.STAMP){this.#L.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#L.getMode()===p.HIGHLIGHT&&this.enableTextSelection(),this.#rj){this.#rj=!1;return}let{isMac:e}=$.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;this.#rj=!0;let i=this.#L.getActive();this.#rO=!i||i.isEmpty()}findNewParent(t,e,i){let s=this.#L.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}destroy(){for(let t of(this.#L.getActive()?.parent===this&&(this.#L.commitOrRemove(),this.#L.setA
2ctiveEditor(null)),this.#rU&&(clearTimeout(this.#rU),this.#rU=null),this.#r$.values()))this.#sg?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#r$.clear(),this.#L.removeLayer(this)}#rW(){for(let t of(this.#rG=!0,this.#r$.values()))t.isEmpty()&&t.remove();this.#rG=!1}render({viewport:t}){for(let e of(this.viewport=t,tE(this.div,t),this.#L.getEditors(this.pageIndex)))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#L.commitOrRemove(),this.#rW();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,tE(this.div,{rotation:i}),e!==i)for(let t of this.#r$.values())t.rotate(i);this.addInkEditorIfNeeded(!1)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#L.viewParameters.realScale}}class iJ{#i5=null;#l=0;#rJ=new Map;#rZ=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#i5){this.#i5=t;return}if(this.#i5!==t){if(this.#rJ.size>0)for(let e of this.#rJ.values())e.remove(),t.append(e);this.#i5=t}}static get _svgFactory(){return L(this,"_svgFactory",new tl)}static #r0(t,{x:e=0,y:i=0,width:s=1,height:a=1}={}){let{style:r}=t;r.top=`${100*i}%`,r.left=`${100*e}%`,r.width=`${100*s}%`,r.height=`${100*a}%`}#r1(t){let e=iJ._svgFactory.create(1,1,!0);return this.#i5.append(e),e.setAttribute("aria-hidden",!0),iJ.#r0(e,t),e}#r2(t,e){let i=iJ._svgFactory.createElement("clipPath");t.append(i);let s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let a=iJ._svgFactory.createElement("use");return i.append(a),a.setAttribute("href",`#${e}`),a.classList.add("clip"),s}highlight(t,e,i,s=!1){let a=this.#l++,r=this.#r1(t.box);r.classList.add("highlight"),t.free&&r.classList.add("free");let n=iJ._svgFactory.createElement("defs");r.append(n);let o=iJ._svgFactory.createElement("path");n.append(o);let l=`path_p${this.pageIndex}_${a}`;o.setAttribute("id",l),o.setAttribute("d",t.toSVGPath()),s&&this.#rZ.set(a,o);let h=this.#r2(n,l),d=iJ._svgFactory.createElement("use");return r.append(d),r.setAttribute("fill",e),r.setAttribute("fill-opacity",i),d.setAttribute("href",`#${l}`),this.#rJ.set(a,r),{id:a,clipPathId:`url(#${h})`}}highlightOutline(t){let e;let i=this.#l++,s=this.#r1(t.box);s.classList.add("highlightOutline");let a=iJ._svgFactory.createElement("defs");s.append(a);let r=iJ._svgFactory.createElement("path");a.append(r);let n=`path_p${this.pageIndex}_${i}`;if(r.setAttribute("id",n),r.setAttribute("d",t.toSVGPath()),r.setAttribute("vector-effect","non-scaling-stroke"),t.free){s.classList.add("free");let t=iJ._svgFactory.createElement("mask");a.append(t),e=`mask_p${this.pageIndex}_${i}`,t.setAttribute("id",e),t.setAttribute("maskUnits","objectBoundingBox");let r=iJ._svgFactory.createElement("rect");t.append(r),r.setAttribute("width","1"),r.setAttribute("height","1"),r.setAttribute("fill","white");let o=iJ._svgFactory.createElement("use");t.append(o),o.setAttribute("href",`#${n}`),o.setAttribute("stroke","none"),o.setAttribute("fill","black"),o.setAttribute("fill-rule","nonzero"),o.classList.add("mask")}let o=iJ._svgFactory.createElement("use");s.append(o),o.setAttribute("href",`#${n}`),e&&o.setAttribute("mask",`url(#${e})`);let l=o.cloneNode();return s.append(l),o.classList.add("mainOutline"),l.classList.add("secondaryOutline"),this.#rJ.set(i,s),i}finalizeLine(t,e){let i=this.#rZ.get(t);this.#rZ.delete(t),this.updateBox(t,e.box),i.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#rJ.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),this.#rZ.delete(t)}updatePath(t,e){this.#rZ.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){iJ.#r0(this.#rJ.get(t),e)}show(t,e){this.#rJ.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#rJ.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#rJ.get(t).setAttribute("fill",e)}changeOpacity(t,e){this.#rJ.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#rJ.get(t).classList.add(e)}removeClass(t,e){this.#rJ.get(t).classList.remove(e)}remove(t){null!==this.#i5&&(this.#rJ.get(t).remove(),this.#rJ.delete(t))}
2destroy(){for(let t of(this.#i5=null,this.#rJ.values()))t.remove();this.#rJ.clear()}}o.AbortException,o.AnnotationEditorLayer,o.AnnotationEditorParamsType,o.AnnotationEditorType,o.AnnotationEditorUIManager,o.AnnotationLayer,o.AnnotationMode,o.CMapCompressionType,o.ColorPicker,o.DOMSVGFactory,o.DrawLayer,o.FeatureTest;var iZ=o.GlobalWorkerOptions;o.ImageKind,o.InvalidPDFException,o.MissingPDFException,o.OPS,o.Outliner,o.PDFDataRangeTransport,o.PDFDateString,o.PDFWorker,o.PasswordResponses,o.PermissionFlag,o.PixelsPerInch,o.RenderingCancelledException,o.TextLayer,o.UnexpectedResponseException,o.Util,o.VerbosityLevel,o.XfaLayer,o.build,o.createValidAbsoluteUrl,o.fetchData;var i0=o.getDocument;o.getFilenameFromUrl,o.getPdfFilenameFromUrl,o.getXfaPageViewport,o.isDataScheme,o.isPdfFile,o.noContextMenu,o.normalizeUnicode,o.renderTextLayer,o.setLayerDimensions,o.shadow,o.updateTextLayer,o.version}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.