pdf-flipbook 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +193 -0
- package/dist/pdf-flipbook.css +304 -0
- package/dist/pdf-flipbook.esm.js +21508 -0
- package/dist/pdf-flipbook.esm.js.map +7 -0
- package/dist/pdf-flipbook.esm.min.js +42 -0
- package/dist/pdf-flipbook.esm.min.js.map +7 -0
- package/dist/pdf-flipbook.umd.js +21535 -0
- package/dist/pdf-flipbook.umd.js.map +7 -0
- package/package.json +42 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var Ut={};Ut.d=(l,t)=>{for(var e in t)Ut.o(t,e)&&!Ut.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})};Ut.o=(l,t)=>Object.prototype.hasOwnProperty.call(l,t);var R=globalThis.pdfjsLib={};Ut.d(R,{AbortException:()=>gt,AnnotationEditorLayer:()=>vi,AnnotationEditorParamsType:()=>F,AnnotationEditorType:()=>L,AnnotationEditorUIManager:()=>kt,AnnotationLayer:()=>ui,AnnotationMode:()=>At,ColorPicker:()=>Be,DOMSVGFactory:()=>Jt,DrawLayer:()=>Ei,FeatureTest:()=>Y,GlobalWorkerOptions:()=>St,ImageKind:()=>he,InvalidPDFException:()=>jt,MissingPDFException:()=>xt,OPS:()=>ct,OutputScale:()=>Xt,PDFDataRangeTransport:()=>Ce,PDFDateString:()=>ue,PDFWorker:()=>Dt,PasswordResponses:()=>ln,PermissionFlag:()=>on,PixelsPerInch:()=>wt,RenderingCancelledException:()=>Wt,TextLayer:()=>Kt,TouchManager:()=>ge,UnexpectedResponseException:()=>Ft,Util:()=>C,VerbosityLevel:()=>Ge,XfaLayer:()=>Pe,build:()=>Kn,createValidAbsoluteUrl:()=>un,fetchData:()=>Ve,getDocument:()=>Wn,getFilenameFromUrl:()=>yn,getPdfFilenameFromUrl:()=>wn,getXfaPageViewport:()=>vn,isDataScheme:()=>We,isPdfFile:()=>Ci,noContextMenu:()=>dt,normalizeUnicode:()=>bn,setLayerDimensions:()=>Ct,shadow:()=>I,stopEvent:()=>ot,version:()=>Yn});var Z=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Vi=[1,0,0,1,0,0],ss=[.001,0,0,.001,0,0],nn=1e7,le=1.35,rn=.35,er=rn/le,at={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},At={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},an="pdfjs_internal_editor_",L={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},F={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,DRAW_STEP:41},on={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Q={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},he={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},q={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};var Ot={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var Ge={ERRORS:0,WARNINGS:1,INFOS:5},ct={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},ln={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Ue=Ge.WARNINGS;function hn(l){Number.isInteger(l)&&(Ue=l)}function cn(){return Ue}function ze(l){Ue>=Ge.INFOS&&console.log(`Info: ${l}`)}function M(l){Ue>=Ge.WARNINGS&&console.log(`Warning: ${l}`)}function O(l){throw new Error(l)}function V(l,t){l||O(t)}function dn(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function un(l,t=null,e=null){if(!l)return null;try{if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=mn(l)}catch{}let s=t?new URL(l,t):new URL(l);if(dn(s))return s}catch{}return null}function I(l,t,e,s=!1){return Object.defineProperty(l,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}var vt=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}(),ce=class extends vt{constructor(t,e){super(t,"PasswordException"),this.code=e}},zt=class extends vt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},jt=class extends vt{constructor(t){super(t,"InvalidPDFException")}},xt=class extends vt{constructor(t){super(t,"MissingPDFException")}},Ft=class extends vt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}},is=class extends vt{constructor(t){super(t,"FormatError")}},gt=class extends vt{constructor(t){super(t,"AbortException")}};function Wi(l){(typeof l!="object"||l?.length===void 0)&&O("Invalid argument for bytesToString");let t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);let s=[];for(let i=0;i<t;i+=e){let n=Math.min(i+e,t),r=l.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function je(l){typeof l!="string"&&O("Invalid argument for stringToBytes");let t=l.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=l.charCodeAt(s)&255;return e}function fn(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function Si(l){let t=Object.create(null);for(let[e,s]of l)t[e]=s;return t}function pn(){let l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function gn(){try{return new Function(""),!0}catch{return!1}}var Y=class{static get isLittleEndian(){return I(this,"isLittleEndian",pn())}static get isEvalSupported(){return I(this,"isEvalSupported",gn())}static get isOffscreenCanvasSupported(){return I(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return I(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?I(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):I(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return I(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}},Qe=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0")),C=class{static makeHexColor(t,e,s){return`#${Qe[t]}${Qe[e]}${Qe[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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){let s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){let s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){let s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[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]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(s+r)/2,o=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,h=a+o||1,c=a-o||1;return[Math.sqrt(h),Math.sqrt(c)]}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 s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;let n=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 n>r?null:[s,n,i,r]}static#t(t,e,s,i,n,r,a,o,h,c){if(h<=0||h>=1)return;let d=1-h,u=h*h,f=u*h,p=d*(d*(d*t+3*h*e)+3*u*s)+f*i,g=d*(d*(d*n+3*h*r)+3*u*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,s,i,n,r,a,o,h,c,d,u){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/c,u);return}let f=c**2-4*d*h;if(f<0)return;let p=Math.sqrt(f),g=2*h;this.#t(t,e,s,i,n,r,a,o,(-c+p)/g,u),this.#t(t,e,s,i,n,r,a,o,(-c-p)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,h){return h?(h[0]=Math.min(h[0],t,a),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,a),h[3]=Math.max(h[3],e,o)):h=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),h),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),h),h}};function mn(l){return decodeURIComponent(escape(l))}var Je=null,Li=null;function bn(l){return Je||(Je=/([\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,Li=new Map([["\uFB05","\u017Ft"]])),l.replaceAll(Je,(t,e,s)=>e?e.normalize("NFKC"):Li.get(s))}function _n(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let l=new Uint8Array(32);return crypto.getRandomValues(l),Wi(l)}var xi="pdfjs_internal_id_";function An(l){return Uint8Array.prototype.toBase64?l.toBase64():btoa(Wi(l))}typeof Promise.try!="function"&&(Promise.try=function(l,...t){return new Promise(e=>{e(l(...t))})});var bt="http://www.w3.org/2000/svg",wt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Ve(l,t="text"){if(Gt(l,document.baseURI)){let e=await fetch(l);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{let i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}var Vt=class l{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;let o=(t[2]+t[0])/2,h=(t[3]+t[1])/2,c,d,u,f;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,b,m;c===0?(p=Math.abs(h-t[1])*s+n,g=Math.abs(o-t[0])*s+r,b=(t[3]-t[1])*s,m=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(h-t[1])*s+r,b=(t[2]-t[0])*s,m=(t[3]-t[1])*s),this.transform=[c*s,d*s,u*s,f*s,p-c*s*o-u*s*h,g-d*s*o-f*s*h],this.width=b,this.height=m}get rawDims(){let{userUnit:t,viewBox:e}=this,s=e.map(i=>i*t);return I(this,"rawDims",{pageWidth:s[2]-s[0],pageHeight:s[3]-s[1],pageX:s[0],pageY:s[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new l({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return C.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){let e=C.applyTransform([t[0],t[1]],this.transform),s=C.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return C.applyInverseTransform([t,e],this.transform)}},Wt=class extends vt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function We(l){let t=l.length,e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function Ci(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function yn(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function wn(l,t="document.pdf"){if(typeof l!="string")return t;if(We(l))return M('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(l),n=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(n&&(n=n[0],n.includes("%")))try{n=s.exec(decodeURIComponent(n))[0]}catch{}return n||t}var de=class{started=Object.create(null);times=[];time(t){t in this.started&&M(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||M(`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:s}of this.times)e=Math.max(s.length,e);for(let{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
|
|
2
|
+
`);return t.join("")}};function Gt(l,t){try{let{protocol:e}=t?new URL(l,t):new URL(l);return e==="http:"||e==="https:"}catch{return!1}}function dt(l){l.preventDefault()}function ot(l){l.preventDefault(),l.stopPropagation()}var ue=class{static#t;static toDateObject(t){if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let s=parseInt(e[1],10),i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let h=e[7]||"Z",c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(r+=c,a+=d):h==="+"&&(r-=c,a-=d),new Date(Date.UTC(s,i,n,r,a,o))}};function vn(l,{scale:t=1,rotation:e=0}){let{width:s,height:i}=l.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new Vt({viewBox:n,userUnit:1,scale:t,rotation:e})}function Ti(l){if(l.startsWith("#")){let t=parseInt(l.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(M(`Not a valid color format: "${l}"`),[0,0,0])}function En(l){let t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(let e of l.keys()){t.style.color=e;let s=window.getComputedStyle(t).color;l.set(e,Ti(s))}t.remove()}function G(l){let{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform();return[t,e,s,i,n,r]}function ft(l){let{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform().invertSelf();return[t,e,s,i,n,r]}function Ct(l,t,e=!1,s=!0){if(t instanceof Vt){let{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=l,a=Y.isCSSRoundSupported,o=`var(--scale-factor) * ${i}px`,h=`var(--scale-factor) * ${n}px`,c=a?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=a?`round(down, ${h}, var(--scale-round-y, 1px))`:`calc(${h})`;!e||t.rotation%180===0?(r.width=c,r.height=d):(r.width=d,r.height=c)}s&&l.setAttribute("data-main-rotation",t.rotation)}var Xt=class{constructor(){let t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},ns=class l{#t=null;#e=null;#s;#i=null;#r=null;static#n=null;constructor(t){this.#s=t,l.#n||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#s._uiManager._signal;t.addEventListener("contextmenu",dt,{signal:e}),t.addEventListener("pointerdown",l.#l,{signal:e});let s=this.#i=document.createElement("div");s.className="buttons",t.append(s);let i=this.#s.toolbarPosition;if(i){let{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),t}get div(){return this.#t}static#l(t){t.stopPropagation()}#o(t){this.#s._focusEventsAllowed=!1,ot(t)}#c(t){this.#s._focusEventsAllowed=!0,ot(t)}#h(t){let e=this.#s._uiManager._signal;t.addEventListener("focusin",this.#o.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",dt,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#r?.shown()}#u(){let{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",l.#n[t]),this.#h(s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),this.#i.append(s)}get#d(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#h(e),this.#i.prepend(e,this.#d),this.#r=t}addColorPicker(t){this.#e=t;let e=t.renderButton();this.#h(e),this.#i.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}},rs=class{#t=null;#e=null;#s;constructor(t){this.#s=t}#i(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",dt,{signal:this.#s._signal});let e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#n(),t}#r(t,e){let s=0,i=0;for(let n of t){let r=n.y+n.height;if(r<s)continue;let a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){let[i,n]=this.#r(e,s),{style:r}=this.#e||=this.#i();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#n(){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 s=this.#s._signal;t.addEventListener("contextmenu",dt,{signal:s}),t.addEventListener("click",()=>{this.#s.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}};function fe(l,t,e){for(let s of e)t.addEventListener(s,l[s].bind(l))}var as=class{#t=0;get id(){return`${an}${this.#t++}`}},os=class l{#t=_n();#e=0;#s=null;static get _isSVGFittingCanvas(){let t='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>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;let n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return I(this,"_isSVGFittingCanvas",n)}async#i(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await Ve(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){let n=l._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((h,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,h()},r.onload=async()=>{let d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){M(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){let{lastModified:e,name:s,size:i,type:n}=t;return this.#i(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){let s=await e;return this.#i(t,s)}async getFromId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s?.bitmap)return s.refCounter+=1,s;let i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){let e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;let{bitmap:s}=e;if(!e.url&&!e.file){let i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}},ls=class{#t=[];#e=!1;#s;#i=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;let o={cmd:t,undo:e,post:s,type:n};if(this.#i===-1){this.#t.length>0&&(this.#t.length=0),this.#i=0,this.#t.push(o);return}if(r&&this.#t[this.#i].type===n){a&&(o.undo=this.#t[this.#i].undo),this.#t[this.#i]=o;return}let h=this.#i+1;h===this.#s?this.#t.splice(0,1):(this.#i=h,h<this.#t.length&&this.#t.splice(h)),this.#t.push(o)}undo(){if(this.#i===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i!==-1){for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}}destroy(){this.#t=null}},Tt=class{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=Y.platform;for(let[s,i,n={}]of t)for(let r of s){let a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1)))}}#t(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 s=this.callbacks.get(this.#t(e));if(!s)return;let{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||ot(e))}},hs=class l{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return En(t),I(this,"_colors",t)}convert(t){let e=Ti(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return l._colorsMapping.get(s);return e}getHexCode(t){let e=this._colors.get(t);return e?C.makeHexColor(...e):t}},kt=class l{#t=new AbortController;#e=null;#s=new Map;#i=new Map;#r=null;#n=null;#l=null;#o=new ls;#c=null;#h=null;#u=0;#d=new Set;#f=null;#a=null;#p=new Set;_editorUndoBar=null;#m=!1;#g=!1;#b=!1;#y=null;#_=null;#w=null;#E=null;#x=!1;#T=null;#P=new as;#v=!1;#k=!1;#C=null;#L=null;#D=null;#N=null;#S=L.NONE;#A=new Set;#I=null;#G=null;#U=null;#z={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#O=[0,0];#F=null;#B=null;#j=null;#M=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=l.prototype,e=r=>r.#B.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){let{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return I(this,"_keyboardManager",new Tt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#B.contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#B.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,h,c,d,u,f){let p=this._signal=this.#t.signal;this.#B=t,this.#j=e,this.#r=s,this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:p}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),i._on("setpreference",this.onSetPreference.bind(this),{signal:p}),i._on("switchannotationeditorparams",g=>this.updateParams(g.type,g.value),{signal:p}),this.#et(),this.#rt(),this.#q(),this.#n=n.annotationStorage,this.#y=n.filterFactory,this.#G=r,this.#E=a||null,this.#m=o,this.#g=h,this.#b=c,this.#N=d||null,this.viewParameters={realScale:wt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=f!==!1}destroy(){this.#M?.resolve(),this.#M=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#i.values())t.destroy();this.#i.clear(),this.#s.clear(),this.#p.clear(),this.#e=null,this.#A.clear(),this.#o.destroy(),this.#r?.destroy(),this.#T?.hide(),this.#T=null,this.#_&&(clearTimeout(this.#_),this.#_=null),this.#F&&(clearTimeout(this.#F),this.#F=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#N}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return I(this,"hcmFilter",this.#G?this.#y.addHCMFilter(this.#G.foreground,this.#G.background):"none")}get direction(){return I(this,"direction",getComputedStyle(this.#B).direction)}get highlightColors(){return I(this,"highlightColors",this.#E?new Map(this.#E.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return I(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#h=t}setMainHighlightColorPicker(t){this.#D=t}editAltText(t,e=!1){this.#r?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#b=e;break}}onPageChanging({pageNumber:t}){this.#u=t-1}focusMainContainer(){this.#B.focus()}findParent(t,e){for(let s of this.#i.values()){let{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#j.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#p.add(t)}removeShouldRescale(t){this.#p.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*wt.PDF_TO_CSS_UNITS;for(let e of this.#p)e.onScaleChanging();this.#h?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#H({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#X(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let s of this.#i.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t=""){let e=document.getSelection();if(!e||e.isCollapsed)return;let{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),h=this.#H(e).closest(".textLayer"),c=this.getSelectionBoxes(h);if(!c)return;e.empty();let d=this.#X(h),u=this.#S===L.NONE,f=()=>{d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a}),u&&this.showAllEditors("highlight",!0,!0)};if(u){this.switchToMode(L.HIGHLIGHT,f);return}f()}#Z(){let t=document.getSelection();if(!t||t.isCollapsed)return;let s=this.#H(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#T||=new rs(this),this.#T.show(s,i,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#n&&!this.#n.has(t.id)&&this.#n.setValue(t.id,t)}#tt(){let t=document.getSelection();if(!t||t.isCollapsed){this.#I&&(this.#T?.hide(),this.#I=null,this.#R({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#I)return;let i=this.#H(t).closest(".textLayer");if(!i){this.#I&&(this.#T?.hide(),this.#I=null,this.#R({hasSelectedText:!1}));return}if(this.#T?.hide(),this.#I=e,this.#R({hasSelectedText:!0}),!(this.#S!==L.HIGHLIGHT&&this.#S!==L.NONE)&&(this.#S===L.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#x=this.isShiftKeyDown,!this.isShiftKeyDown)){let n=this.#S===L.HIGHLIGHT?this.#X(i):null;n?.toggleDrawing();let r=new AbortController,a=this.combinedSignal(r),o=h=>{h.type==="pointerup"&&h.button!==0||(r.abort(),n?.toggleDrawing(!0),h.type==="pointerup"&&this.#W("main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}}#W(t=""){this.#S===L.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#Z()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#st(){if(this.#w)return;this.#w=new AbortController;let t=this.combinedSignal(this.#w);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#it(){this.#w?.abort(),this.#w=null}blur(){if(this.isShiftKeyDown=!1,this.#x&&(this.#x=!1,this.#W("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#A)if(e.div.contains(t)){this.#L=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#L)return;let[t,e]=this.#L;this.#L=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#q(){if(this.#C)return;this.#C=new AbortController;let t=this.combinedSignal(this.#C);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#nt(){this.#C?.abort(),this.#C=null}#Y(){if(this.#c)return;this.#c=new AbortController;let t=this.combinedSignal(this.#c);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#K(){this.#c?.abort(),this.#c=null}#rt(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#q(),this.#Y()}removeEditListeners(){this.#nt(),this.#K()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let s of this.#a)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let s of this.#a)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let s of this.#A){let i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let n of e.items)for(let r of this.#a)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){M(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();let i=this.currentLayer;try{let n=[];for(let o of s){let h=await i.deserialize(o);if(!h)return;n.push(h)}let r=()=>{for(let o of n)this.#Q(o);this.#J(n)},a=()=>{for(let o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){M(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#S!==L.NONE&&!this.isEditorHandlingKeyboard&&l._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#x&&(this.#x=!1,this.#W("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#R(t){Object.entries(t).some(([s,i])=>this.#z[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#z,t)}),this.#S===L.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#$([[F.HIGHLIGHT_FREE,!0]]))}#$(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#st(),this.#Y(),this.#R({isEditing:this.#S!==L.NONE,isEmpty:this.#V(),hasSomethingToUndo:this.#o.hasSomethingToUndo(),hasSomethingToRedo:this.#o.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#it(),this.#K(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#a){this.#a=t;for(let e of this.#a)this.#$(e.defaultPropertiesToUpdate)}}getId(){return this.#P.id}get currentLayer(){return this.#i.get(this.#u)}getLayer(t){return this.#i.get(t)}get currentPageIndex(){return this.#u}addLayer(t){this.#i.set(t.pageIndex,t),this.#v?t.enable():t.disable()}removeLayer(t){this.#i.delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(this.#S!==t&&!(this.#M&&(await this.#M.promise,!this.#M))){if(this.#M=Promise.withResolvers(),this.#S=t,t===L.NONE){this.setEditingState(!1),this.#ot(),this._editorUndoBar?.hide(),this.#M.resolve();return}this.setEditingState(!0),await this.#at(),this.unselectAll();for(let i of this.#i.values())i.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),this.#M.resolve();return}for(let i of this.#s.values())i.annotationElementId===e?(this.setSelected(i),i.enterInEditMode()):i.unselect();this.#M.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#S&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#a){switch(t){case F.CREATE:this.currentLayer.addNewEditor();return;case F.HIGHLIGHT_DEFAULT_COLOR:this.#D?.updateColor(e);break;case F.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#U||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(let s of this.#A)s.updateParams(t,e);for(let s of this.#a)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(let n of this.#s.values())n.editorType===t&&n.show(e);(this.#U?.get(F.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#$([[F.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#k!==t){this.#k=t;for(let e of this.#i.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#at(){if(!this.#v){this.#v=!0;let t=[];for(let e of this.#i.values())t.push(e.enable());await Promise.all(t);for(let e of this.#s.values())e.enable()}}#ot(){if(this.unselectAll(),this.#v){this.#v=!1;for(let t of this.#i.values())t.disable();for(let t of this.#s.values())t.disable()}}getEditors(t){let e=[];for(let s of this.#s.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.focusMainContainer(),this.#_=null},0)),this.#s.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#n?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){let e=this.#i.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#$(t.propertiesToUpdate))}get#lt(){let t=null;for(t of this.#A);return t}updateUI(t){this.#lt===t&&this.#$(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#$(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#A.has(t)){this.#A.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#A.add(t),t.select(),this.#$(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){this.#h?.commitOrRemove();for(let e of this.#A)e!==t&&e.unselect();this.#A.clear(),this.#A.add(t),t.select(),this.#$(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#A.has(t)}get firstSelectedEditor(){return this.#A.values().next().value}unselect(t){t.unselect(),this.#A.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#A.size!==0}get isEnterHandled(){return this.#A.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#o.undo(),this.#R({hasSomethingToUndo:this.#o.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#V()}),this._editorUndoBar?.hide()}redo(){this.#o.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#o.hasSomethingToRedo(),isEmpty:this.#V()})}addCommands(t){this.#o.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#V()})}cleanUndoStack(t){this.#o.cleanType(t)}#V(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(let t of this.#s.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#A],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(let n of e)n.remove()},i=()=>{for(let n of e)this.#Q(n)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#J(t){for(let e of this.#A)e.unselect();this.#A.clear();for(let e of t)e.isEmpty()||(this.#A.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#A)t.commit();this.#J(this.#s.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#S!==L.NONE))&&!this.#h?.commitOrRemove()&&this.hasSelection){for(let t of this.#A)t.unselect();this.#A.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#O[0]+=t,this.#O[1]+=e;let[i,n]=this.#O,r=[...this.#A],a=1e3;this.#F&&clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#F=null,this.#O[0]=this.#O[1]=0,this.addCommands({cmd:()=>{for(let o of r)this.#s.has(o.id)&&o.translateInPage(i,n)},undo:()=>{for(let o of r)this.#s.has(o.id)&&o.translateInPage(-i,-n)},mustExec:!1})},a);for(let o of r)o.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let t of this.#A)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let t=this.#f;this.#f=null;let e=!1;for(let[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;let s=(i,n,r,a)=>{if(this.#s.has(i.id)){let o=this.#i.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(let[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(let[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(let s of this.#f.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){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()||this.#A.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#S}get imageManager(){return I(this,"imageManager",new os)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;let{x:s,y:i,width:n,height:r}=t.getBoundingClientRect(),a;switch(t.getAttribute("data-main-rotation")){case"90":a=(h,c,d,u)=>({x:(c-i)/r,y:1-(h+d-s)/n,width:u/r,height:d/n});break;case"180":a=(h,c,d,u)=>({x:1-(h+d-s)/n,y:1-(c+u-i)/r,width:d/n,height:u/r});break;case"270":a=(h,c,d,u)=>({x:1-(c+u-i)/r,y:(h-s)/n,width:u/r,height:d/n});break;default:a=(h,c,d,u)=>({x:(h-s)/n,y:(c-i)/r,width:d/n,height:u/r});break}let o=[];for(let h=0,c=e.rangeCount;h<c;h++){let d=e.getRangeAt(h);if(!d.collapsed)for(let{x:u,y:f,width:p,height:g}of d.getClientRects())p===0||g===0||o.push(a(u,f,p,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#l||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#l?.delete(t)}renderAnnotationElement(t){let e=this.#l?.get(t.data.id);if(!e)return;let s=this.#n.getRawValue(e);s&&(this.#S===L.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}},pe=class l{#t=null;#e=!1;#s=null;#i=null;#r=null;#n=null;#l=!1;#o=null;#c=null;#h=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#c=t,this.#d=t._uiManager.useNewAltTextFlow,l.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){l._l10n??=t}async render(){let t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#i=document.createElement("span");t.append(e),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",l.#f.missing),e.setAttribute("data-l10n-id",l.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let s=this.#c._uiManager._signal;t.addEventListener("contextmenu",dt,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});let i=n=>{n.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#a}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#l=!0,i(n))},{signal:s}),await this.#p(),t}get#a(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#s&&(this.#s.focus({focusVisible:this.#l}),this.#l=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}async setGuessedText(t){this.#t===null&&(this.#h=t,this.#u=await l._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#p())}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){let e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#c.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#h===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(this.#h=s,this.#u=i),!(this.#t===t&&this.#e===e)&&(n||(this.#t=t,this.#e=e),this.#p())}toggle(t=!1){this.#s&&(!t&&this.#n&&(clearTimeout(this.#n),this.#n=null),this.#s.disabled=!t)}shown(){this.#c._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#a}})}destroy(){this.#s?.remove(),this.#s=null,this.#i=null,this.#r=null,this.#o?.remove(),this.#o=null}async#p(){let t=this.#s;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",l.#f[this.#a]),this.#i?.setAttribute("data-l10n-id",l.#f[`${this.#a}-label`]),!this.#t){this.#r?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#r?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#r;if(!e){this.#r=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#c.id}`;let i=100,n=this.#c._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#n),this.#n=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#n=setTimeout(()=>{this.#n=null,this.#r.classList.add("show"),this.#c._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#n&&(clearTimeout(this.#n),this.#n=null),this.#r?.classList.remove("show")},{signal:n})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#c.getImageForAltText()?.setAttribute("aria-describedby",e.id)}},ge=class l{#t;#e=!1;#s=null;#i;#r;#n;#l;#o;#c=null;#h;#u=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#t=t,this.#s=s,this.#i=e,this.#r=i,this.#n=n,this.#l=r,this.#h=new AbortController,this.#o=AbortSignal.any([a,this.#h.signal]),t.addEventListener("touchstart",this.#d.bind(this),{passive:!1,signal:this.#o})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return I(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#d(t){if(this.#i?.()||t.touches.length<2)return;if(!this.#u){this.#u=new AbortController;let i=AbortSignal.any([this.#o,this.#u.signal]),n=this.#t,r={signal:i,passive:!1};n.addEventListener("touchmove",this.#f.bind(this),r),n.addEventListener("touchend",this.#a.bind(this),r),n.addEventListener("touchcancel",this.#a.bind(this),r),this.#r?.()}if(ot(t),t.touches.length!==2||this.#s?.()){this.#c=null;return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),this.#c={touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#f(t){if(!this.#c||t.touches.length!==2)return;let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);let{screenX:i,screenY:n}=e,{screenX:r,screenY:a}=s,o=this.#c,{touch0X:h,touch0Y:c,touch1X:d,touch1Y:u}=o,f=d-h,p=u-c,g=r-i,b=a-n,m=Math.hypot(g,b)||1,_=Math.hypot(f,p)||1;if(!this.#e&&Math.abs(_-m)<=l.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=i,o.touch0Y=n,o.touch1X=r,o.touch1Y=a,t.preventDefault(),!this.#e){this.#e=!0;return}let A=[(i+r)/2,(n+a)/2];this.#n?.(A,_,m)}#a(t){this.#u.abort(),this.#u=null,this.#l?.(),this.#c&&(t.preventDefault(),this.#c=null,this.#e=!1)}destroy(){this.#h?.abort(),this.#h=null}},U=class l{#t=null;#e=null;#s=null;#i=!1;#r=null;#n="";#l=!1;#o=null;#c=null;#h=null;#u=null;#d="";#f=!1;#a=null;#p=!1;#m=!1;#g=!1;#b=null;#y=0;#_=0;#w=null;#E=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#x=!1;#T=l._zIndex++;static _borderLineWidth=-1;static _colorManager=new hs;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=l.prototype._resizeWithKeyboard,e=kt.TRANSLATE_SMALL,s=kt.TRANSLATE_BIG;return I(this,"_resizerKeyboardManager",new Tt([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],l.prototype._stopResizingWithKeyboard]]))}constructor(t){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:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];let[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return I(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new cs({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){if(l._l10n??=t,l._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),l._borderLineWidth!==-1)return;let s=getComputedStyle(document.documentElement);l._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){O("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#x}set _isDraggable(t){this.#x=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/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#T}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#H(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.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,s,i){let[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}#P([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#P(this.parentDimensions,t,e)}translateInPage(t,e){this.#a||=[this.x,this.y,this.width,this.height],this.#P(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#a||=[this.x,this.y,this.width,this.height];let{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this,[o,h]=this.getBaseTranslation();r+=o,a+=h;let{style:c}=s;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#a&&(this.#a[0]!==this.x||this.#a[1]!==this.y)}get _hasBeenResized(){return!!this.#a&&(this.#a[2]!==this.width||this.#a[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:s}=l,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[s,i]}=this,{x:n,y:r,width:a,height:o}=this;if(a*=s,o*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(s-a,n)),r=Math.max(0,Math.min(i-o,r));break;case 90:n=Math.max(0,Math.min(s-o,n)),r=Math.min(i,Math.max(a,r));break;case 180:n=Math.min(s,Math.max(a,n)),r=Math.min(i,Math.max(o,r));break;case 270:n=Math.min(s,Math.max(o,n)),r=Math.max(0,Math.min(i-a,r));break}this.x=n/=s,this.y=r/=i;let[h,c]=this.getBaseTranslation();n+=h,r+=c,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#v(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return l.#v(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return l.#v(t,e,360-this.parentRotation)}#k(t){switch(t){case 90:{let[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,s]=this.pageDimensions;return[0,e/s,-s/e,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,s]}=this;return[e*t,s*t]}setDims(t,e){let[s,i]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/s).toFixed(2)}%`,this.#l||(n.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){let{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!this.#l&&e.endsWith("%");if(i&&n)return;let[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!this.#l&&!n&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#C(){if(this.#o)return;this.#o=document.createElement("div"),this.#o.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 s of t){let i=document.createElement("div");this.#o.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#L.bind(this,s),{signal:e}),i.addEventListener("contextmenu",dt,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#o)}#L(t,e){e.preventDefault();let{isMac:s}=Y.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,this.#c=[e.screenX,e.screenY];let n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#S.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",ot,{passive:!1,signal:r}),window.addEventListener("contextmenu",dt,{signal:r}),this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let h=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#N()};window.addEventListener("pointerup",h,{signal:r}),window.addEventListener("blur",h,{signal:r})}#D(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e;let[n,r]=this.parentDimensions;this.setDims(n*s,r*i),this.fixAndSetPosition(),this._onResized()}_onResized(){}#N(){if(!this.#h)return;let{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#h;this.#h=null;let n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:this.#D.bind(this,n,r,a,o),undo:this.#D.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#S(t,e){let[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,h=l.MIN_SIZE/s,c=l.MIN_SIZE/i,d=this.#k(this.rotation),u=(x,k)=>[d[0]*x+d[2]*k,d[1]*x+d[3]*k],f=this.#k(360-this.rotation),p=(x,k)=>[f[0]*x+f[2]*k,f[1]*x+f[3]*k],g,b,m=!1,_=!1;switch(t){case"topLeft":m=!0,g=(x,k)=>[0,0],b=(x,k)=>[x,k];break;case"topMiddle":g=(x,k)=>[x/2,0],b=(x,k)=>[x/2,k];break;case"topRight":m=!0,g=(x,k)=>[x,0],b=(x,k)=>[0,k];break;case"middleRight":_=!0,g=(x,k)=>[x,k/2],b=(x,k)=>[0,k/2];break;case"bottomRight":m=!0,g=(x,k)=>[x,k],b=(x,k)=>[0,0];break;case"bottomMiddle":g=(x,k)=>[x/2,k],b=(x,k)=>[x/2,0];break;case"bottomLeft":m=!0,g=(x,k)=>[0,k],b=(x,k)=>[x,0];break;case"middleLeft":_=!0,g=(x,k)=>[0,k/2],b=(x,k)=>[x,k/2];break}let A=g(a,o),y=b(a,o),w=u(...y),E=l._round(n+w[0]),v=l._round(r+w[1]),T=1,P=1,N,D;if(e.fromKeyboard)({deltaX:N,deltaY:D}=e);else{let{screenX:x,screenY:k}=e,[rt,ut]=this.#c;[N,D]=this.screenToPageTranslation(x-rt,k-ut),this.#c[0]=x,this.#c[1]=k}if([N,D]=p(N/s,D/i),m){let x=Math.hypot(a,o);T=P=Math.max(Math.min(Math.hypot(y[0]-A[0]-N,y[1]-A[1]-D)/x,1/a,1/o),h/a,c/o)}else _?T=Math.max(h,Math.min(1,Math.abs(y[0]-A[0]-N)))/a:P=Math.max(c,Math.min(1,Math.abs(y[1]-A[1]-D)))/o;let H=l._round(a*T),W=l._round(o*P);w=u(...b(H,W));let B=E-w[0],tt=v-w[1];this.#a||=[this.x,this.y,this.width,this.height],this.width=H,this.height=W,this.x=B,this.y=tt,this.setDims(s*H,i*W),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}async addEditToolbar(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new ns(this),this.div.append(this._editToolbar.render()),this.#s&&await this._editToolbar.addAltText(this.#s),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#s?.destroy())}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#s||(pe.initialize(l._l10n),this.#s=new pe(this),this.#t&&(this.#s.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}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.#i?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#O();let[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);let[s,i]=this.getInitialTranslation();return this.translate(s,i),fe(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#E||=new ge({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#A.bind(this),onPinching:this.#I.bind(this),onPinchEnd:this.#G.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#A(){this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#I(t,e,s){let n=.7*(s/e)+1-.7;if(n===1)return;let r=this.#k(this.rotation),a=(E,v)=>[r[0]*E+r[2]*v,r[1]*E+r[3]*v],[o,h]=this.parentDimensions,c=this.x,d=this.y,u=this.width,f=this.height,p=l.MIN_SIZE/o,g=l.MIN_SIZE/h;n=Math.max(Math.min(n,1/u,1/f),p/u,g/f);let b=l._round(u*n),m=l._round(f*n);if(b===u&&m===f)return;this.#a||=[c,d,u,f];let _=a(u/2,f/2),A=l._round(c+_[0]),y=l._round(d+_[1]),w=a(b/2,m/2);this.x=A-w[0],this.y=y-w[1],this.width=b,this.height=m,this.setDims(o*b,h*m),this.fixAndSetPosition(),this._onResizing()}#G(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#N()}pointerdown(t){let{isMac:e}=Y.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#z(t);return}this.#U(t)}get isSelected(){return this._uiManager.isSelected(this)}#U(t){let{isMac:e}=Y.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#z(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1,i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=h=>{i.abort(),this.#r=null,this.#f=!1,this._uiManager.endDragSession()||this.#U(h),s&&this._onStopDragging()};e&&(this.#y=t.clientX,this.#_=t.clientY,this.#r=t.pointerId,this.#n=t.pointerType,window.addEventListener("pointermove",h=>{s||(s=!0,this._onStartDragging());let{clientX:c,clientY:d,pointerId:u}=h;if(u!==this.#r){ot(h);return}let[f,p]=this.screenToPageTranslation(c-this.#y,d-this.#_);this.#y=c,this.#_=d,this._uiManager.dragSelectedEditors(f,p)},r),window.addEventListener("touchmove",ot,r),window.addEventListener("pointerdown",h=>{h.pointerType===this.#n&&(this.#E||h.isPrimary)&&a(h),ot(h)},r));let o=h=>{if(!this.#r||this.#r===h.pointerId){a(h);return}ot(h)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){let i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,h=t/i,c=e/i,d=this.x*n,u=this.y*r,f=this.width*n,p=this.height*r;switch(s){case 0:return[d+h+a,r-u-c-p+o,d+h+f+a,r-u-c+o];case 90:return[d+c+a,r-u+h+o,d+c+p+a,r-u+h+f+o];case 180:return[d-h-f+a,r-u+c+o,d-h+a,r-u+c+p+o];case 270:return[d-c-p+a,r-u-h-f+o,d-c+a,r-u-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}#O(){if(this.#u||!this.div)return;this.#u=new AbortController;let t=this._uiManager.combinedSignal(this.#u);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#O()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){O("An editor must be serializable")}static async deserialize(t,e,s){let i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,i.#t=t.accessibilityData;let[n,r]=i.pageDimensions,[a,o,h,c]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=h/n,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#u?.abort(),this.#u=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#H(),this.removeEditToolbar(),this.#w){for(let t of this.#w.values())clearTimeout(t);this.#w=null}this.parent=null,this.#E?.destroy(),this.#E=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#C(),this.#o.classList.remove("hidden"),fe(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#o.children;if(!this.#e){this.#e=Array.from(e);let r=this.#F.bind(this),a=this.#B.bind(this),o=this._uiManager._signal;for(let h of this.#e){let c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",r,{signal:o}),h.addEventListener("blur",a,{signal:o}),h.addEventListener("focus",this.#j.bind(this,c),{signal:o}),h.setAttribute("data-l10n-id",l._l10nResizer[c])}}let s=this.#e[0],i=0;for(let r of e){if(r===s)break;i++}let n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#o.append(this.#o.firstChild);else if(n>i)for(let a=0;a<n-i;a++)this.#o.firstChild.before(this.#o.lastChild);let r=0;for(let a of e){let h=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",l._l10nResizer[h])}}this.#M(0),this.#g=!0,this.#o.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#F(t){l._resizerKeyboardManager.exec(this,t)}#B(t){this.#g&&t.relatedTarget?.parentNode!==this.#o&&this.#H()}#j(t){this.#d=this.#g?t:""}#M(t){if(this.#e)for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#g&&this.#S(this.#d,{deltaX:t,deltaY:e,fromKeyboard:!0})}#H(){this.#g=!1,this.#M(-1),this.#N()}_stopResizingWithKeyboard(){this.#H(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#s?.toggleAltTextBadge(!1)}unselect(){this.#o?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#s?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#l=!0;let s=t/e,{style:i}=this.div;i.aspectRatio=s,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.#w||=new Map;let{action:s}=t,i=this.#w.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#w.delete(s),this.#w.size===0&&(this.#w=null)},l._telemetryTimeout),this.#w.set(s,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.#i=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#i=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){let s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}},cs=class extends U{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},Mi=3285377520,ht=4294901760,pt=65535,me=class{constructor(t){this.h1=t?t&4294967295:Mi,this.h2=t?t&4294967295:Mi}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,b=t.length;g<b;g++){let m=t.charCodeAt(g);m<=255?e[s++]=m:(e[s++]=m>>>8,e[s++]=m&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");let i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i),a=0,o=0,h=this.h1,c=this.h2,d=3432918353,u=461845907,f=d&pt,p=u&pt;for(let g=0;g<i;g++)g&1?(a=r[g],a=a*d&ht|a*f&pt,a=a<<15|a>>>17,a=a*u&ht|a*p&pt,h^=a,h=h<<13|h>>>19,h=h*5+3864292196):(o=r[g],o=o*d&ht|o*f&pt,o=o<<15|o>>>17,o=o*u&ht|o*p&pt,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&ht|a*f&pt,a=a<<15|a>>>17,a=a*u&ht|a*p&pt,i&1?h^=a:c^=a}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&ht|t*36045&pt,e=e*4283543511&ht|((e<<16|t>>>16)*2950163797&ht)>>>16,t^=e>>>1,t=t*444984403&ht|t*60499&pt,e=e*3301882366&ht|((e<<16|t>>>16)*3120437893&ht)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}},ds=Object.freeze({map:null,hash:"",transfer:void 0}),qt=class{#t=!1;#e=null;#s=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let s=this.#s.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#s.get(t)}remove(t){if(this.#s.delete(t),this.#s.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let e of this.#s.values())if(e instanceof U)return;this.onAnnotationEditor(null)}}setValue(t,e){let s=this.#s.get(t),i=!1;if(s!==void 0)for(let[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#s.set(t,e);i&&this.#i(),e instanceof U&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#s.has(t)}getAll(){return this.#s.size>0?Si(this.#s):null}setAll(t){for(let[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#s.size}#i(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new be(this)}get serializable(){if(this.#s.size===0)return ds;let t=new Map,e=new me,s=[],i=Object.create(null),n=!1;for(let[r,a]of this.#s){let o=a instanceof U?a.serialize(!1,i):a;o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(let r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:ds}get editorStats(){let t=null,e=new Map;for(let s of this.#s.values()){if(!(s instanceof U))continue;let i=s.telemetryFinalData;if(!i)continue;let{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);let r=t[n]||=new Map;for(let[a,o]of Object.entries(i)){if(a==="type")continue;let h=r.get(a);h||(h=new Map,r.set(a,h));let c=h.get(o)??0;h.set(o,c+1)}}for(let[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;let t=[];for(let e of this.#s.values())!(e instanceof U)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}},be=class extends qt{#t;constructor(t){super();let{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#t={map:n,hash:s,transfer:i}}get print(){O("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return I(this,"modifiedIds",{ids:new Set,hash:""})}},us=class{#t=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.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(V(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),this.#t.add(s),e?.(t)}catch{M(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}O("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 s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw M(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{let i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return I(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(Z||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),I(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(V(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){let n=s.shift();setTimeout(n.callback,0)}}let{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return I(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(y,w){return y.charCodeAt(w)<<24|y.charCodeAt(w+1)<<16|y.charCodeAt(w+2)<<8|y.charCodeAt(w+3)&255}function i(y,w,E,v){let T=y.substring(0,w),P=y.substring(w+E);return T+v+P}let n,r,a=this._document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d"),h=0;function c(y,w){if(++h>30){M("Load test font never loaded."),w();return}if(o.font="30px "+y,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0){w();return}setTimeout(c.bind(null,y,w))}let d=`lt${Date.now()}${this.loadTestFontId++}`,u=this._loadTestFont;u=i(u,976,d.length,d);let p=16,g=1482184792,b=s(u,p);for(n=0,r=d.length-3;n<r;n+=4)b=b-g+s(d,n)|0;n<d.length&&(b=b-g+s(d+"XXX",n)|0),u=i(u,p,4,fn(b));let m=`url(data:font/opentype;base64,${btoa(u)});`,_=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(_);let A=this._document.createElement("div");A.style.visibility="hidden",A.style.width=A.style.height="10px",A.style.position="absolute",A.style.top=A.style.left="0px";for(let y of[t.loadedName,d]){let w=this._document.createElement("span");w.textContent="Hi",w.style.fontFamily=y,A.append(w)}this._document.body.append(A),c(d,()=>{A.remove(),e.complete()})}},fs=class{constructor(t,{disableFontFace:e=!1,fontExtraProperties:s=!1,inspectFont:i=null}){this.compiledGlyphs=Object.create(null);for(let n in t)this[n]=t[n];this.disableFontFace=e===!0,this.fontExtraProperties=s===!0,this._inspectFont=i}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{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)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${An(this.data)});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e,i;try{i=t.get(s)}catch(r){M(`getPathGenerator - ignoring character: "${r}".`)}let n=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}},ne={DATA:1,ERROR:2},j={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Ii(){}function it(l){if(l instanceof gt||l instanceof jt||l instanceof xt||l instanceof ce||l instanceof Ft||l instanceof zt)return l;switch(l instanceof Error||typeof l=="object"&&l!==null||O('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new gt(l.message);case"InvalidPDFException":return new jt(l.message);case"MissingPDFException":return new xt(l.message);case"PasswordException":return new ce(l.message,l.code);case"UnexpectedResponseException":return new Ft(l.message,l.status);case"UnknownErrorException":return new zt(l.message,l.details)}return new zt(l.message,l.toString())}var Et=class{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,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),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#i(t);return}if(t.callback){let s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===ne.DATA)i.resolve(t.data);else if(t.callback===ne.ERROR)i.reject(it(t.reason));else throw new Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:s,targetName:i,callback:ne.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:s,targetName:i,callback:ne.ERROR,callbackId:t.callbackId,reason:it(r)})});return}if(t.streamId){this.#s(t);return}e(t.data)}on(t,e){let s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){let i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){let n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:h=>{let c=Promise.withResolvers();return this.streamControllers[n]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{let c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:j.PULL,streamId:n,desiredSize:h.desiredSize}),c.promise},cancel:h=>{V(h instanceof Error,"cancel must have a valid reason");let c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:j.CANCEL,streamId:n,reason:it(h)}),c.promise}},s)}#s(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(h,c=1,d){if(this.isCancelled)return;let u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:j.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:j.CLOSE,streamId:e}),delete r.streamSinks[e])},error(h){V(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:j.ERROR,streamId:e,reason:it(h)}))},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,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:j.START_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:j.START_COMPLETE,streamId:e,reason:it(h)})})}#i(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case j.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(it(t.reason));break;case j.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(it(t.reason));break;case j.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:j.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Ii).then(function(){n.postMessage({sourceName:s,targetName:i,stream:j.PULL_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:j.PULL_COMPLETE,streamId:e,reason:it(h)})});break;case j.ENQUEUE:if(V(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case j.CLOSE:if(V(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#r(r,e);break;case j.ERROR:V(r,"error should have stream controller"),r.controller.error(it(t.reason)),this.#r(r,e);break;case j.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(it(t.reason)),this.#r(r,e);break;case j.CANCEL:if(!a)break;let o=it(t.reason);Promise.try(a.onCancel||Ii,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:j.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:j.CANCEL_COMPLETE,streamId:e,reason:it(h)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#r(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}},_e=class{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");let s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){O("Abstract method `_createCanvas` called.")}},ps=class extends _e{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let s=this._document.createElement("canvas");return s.width=t,s.height=e,s}},Ae=class{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){O("Abstract method `_fetch` called.")}},ye=class extends Ae{async _fetch(t){let e=await Ve(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):je(e)}},we=class{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}},gs=class extends we{#t;#e;#s;#i;#r;#n;#l=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#i=t,this.#r=e}get#o(){return this.#e||=new Map}get#c(){return this.#n||=new Map}get#h(){if(!this.#s){let t=this.#r.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 s=this.#r.createElementNS(bt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#r.createElementNS(bt,"defs"),t.append(s),s.append(this.#s),this.#r.body.append(t)}return this.#s}#u(t){if(t.length===1){let o=t[0],h=new Array(256);for(let d=0;d<256;d++)h[d]=o[d]/255;let c=h.join(",");return[c,c,c]}let[e,s,i]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";let e=this.#r.URL;e!==this.#r.baseURI&&(We(e)?M('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=e.split("#",1)[0])}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;let[s,i,n]=this.#u(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;let a=`g_${this.#i}_transfer_map_${this.#l++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);let h=this.#p(a);return this.#g(s,i,n,h),o}addHCMFilter(t,e){let s=`${t}-${e}`,i="base",n=this.#c.get(i);if(n?.key===s||(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#c.set(i,n)),!t||!e))return n.url;let r=this.#y(t);t=C.makeHexColor(...r);let a=this.#y(e);if(e=C.makeHexColor(...a),this.#h.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return n.url;let o=new Array(256);for(let f=0;f<=255;f++){let p=f/255;o[f]=p<=.03928?p/12.92:((p+.055)/1.055)**2.4}let h=o.join(","),c=`g_${this.#i}_hcm_filter`,d=n.filter=this.#p(c);this.#g(h,h,h,d),this.#a(d);let u=(f,p)=>{let g=r[f]/255,b=a[f]/255,m=new Array(p+1);for(let _=0;_<=p;_++)m[_]=g+_/p*(b-g);return m.join(",")};return this.#g(u(0,5),u(1,5),u(2,5),d),n.url=this.#d(c),n.url}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;let[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#i}_alpha_map_${this.#l++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#p(n);return this.#b(s,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#u([t]),i=`luminosity_${s}`):i="luminosity",e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#i}_luminosity_map_${this.#l++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#p(n);return this.#f(a),t&&this.#b(s,a),r}addHighlightHCMFilter(t,e,s,i,n){let r=`${e}-${s}-${i}-${n}`,a=this.#c.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#c.set(t,a)),!e||!s))return a.url;let[o,h]=[e,s].map(this.#y.bind(this)),c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,f]=[i,n].map(this.#y.bind(this));d<c&&([c,d,u,f]=[d,c,f,u]),this.#h.style.color="";let p=(m,_,A)=>{let y=new Array(256),w=(d-c)/A,E=m/255,v=(_-m)/(255*A),T=0;for(let P=0;P<=A;P++){let N=Math.round(c+P*w),D=E+P*v;for(let H=T;H<=N;H++)y[H]=D;T=N+1}for(let P=T;P<256;P++)y[P]=y[T-1];return y.join(",")},g=`g_${this.#i}_hcm_${t}_filter`,b=a.filter=this.#p(g);return this.#a(b),this.#g(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),b),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#n?.size||(this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#n?.clear(),this.#n=null,this.#l=0)}#f(t){let e=this.#r.createElementNS(bt,"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)}#a(t){let e=this.#r.createElementNS(bt,"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.#r.createElementNS(bt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#m(t,e,s){let i=this.#r.createElementNS(bt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#g(t,e,s,i){let n=this.#r.createElementNS(bt,"feComponentTransfer");i.append(n),this.#m(n,"feFuncR",t),this.#m(n,"feFuncG",e),this.#m(n,"feFuncB",s)}#b(t,e){let s=this.#r.createElementNS(bt,"feComponentTransfer");e.append(s),this.#m(s,"feFuncA",t)}#y(t){return this.#h.style.color=t,Ti(getComputedStyle(this.#h).getPropertyValue("color"))}},ve=class{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){O("Abstract method `_fetch` called.")}},Ee=class extends ve{async _fetch(t){let e=await Ve(t,"arraybuffer");return new Uint8Array(e)}};Z&&M("Please use the `legacy` build in Node.js environments.");async function Xi(l){let e=await process.getBuiltinModule("fs").promises.readFile(l);return new Uint8Array(e)}var ms=class extends we{},bs=class extends _e{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}},_s=class extends Ae{async _fetch(t){return Xi(t)}},As=class extends ve{async _fetch(t){return Xi(t)}},J={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function ys(l,t){if(!t)return;let e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),l.clip(i)}var Yt=class{getPattern(){O("Abstract method `getPattern` called.")}},ws=class extends Yt{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===J.STROKE||i===J.FILL){let r=e.current.getClippedPathBoundingBox(i,G(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,h=e.cachedCanvases.getCanvas("pattern",a,o),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),s=C.transform(s,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),ys(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(h.canvas,"no-repeat");let d=new DOMMatrix(s);n.setTransform(d)}else ys(t,this._bbox),n=this._createGradient(t);return n}};function Ze(l,t,e,s,i,n,r,a){let o=t.coords,h=t.colors,c=l.data,d=l.width*4,u;o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u),o[s+1]>o[i+1]&&(u=s,s=i,i=u,u=r,r=a,a=u),o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u);let f=(o[e]+t.offsetX)*t.scaleX,p=(o[e+1]+t.offsetY)*t.scaleY,g=(o[s]+t.offsetX)*t.scaleX,b=(o[s+1]+t.offsetY)*t.scaleY,m=(o[i]+t.offsetX)*t.scaleX,_=(o[i+1]+t.offsetY)*t.scaleY;if(p>=_)return;let A=h[n],y=h[n+1],w=h[n+2],E=h[r],v=h[r+1],T=h[r+2],P=h[a],N=h[a+1],D=h[a+2],H=Math.round(p),W=Math.round(_),B,tt,x,k,rt,ut,mt,lt;for(let K=H;K<=W;K++){if(K<b){let $=K<p?0:(p-K)/(p-b);B=f-(f-g)*$,tt=A-(A-E)*$,x=y-(y-v)*$,k=w-(w-T)*$}else{let $;K>_?$=1:b===_?$=0:$=(b-K)/(b-_),B=g-(g-m)*$,tt=E-(E-P)*$,x=v-(v-N)*$,k=T-(T-D)*$}let X;K<p?X=0:K>_?X=1:X=(p-K)/(p-_),rt=f-(f-m)*X,ut=A-(A-P)*X,mt=y-(y-N)*X,lt=w-(w-D)*X;let Rt=Math.round(Math.min(B,rt)),Nt=Math.round(Math.max(B,rt)),et=d*K+Rt*4;for(let $=Rt;$<=Nt;$++)X=(B-$)/(B-rt),X<0?X=0:X>1&&(X=1),c[et++]=tt-(tt-ut)*X|0,c[et++]=x-(x-mt)*X|0,c[et++]=k-(k-lt)*X|0,c[et++]=255}}function Sn(l,t,e){let s=t.coords,i=t.colors,n,r;switch(t.type){case"lattice":let a=t.verticesPerRow,o=Math.floor(s.length/a)-1,h=a-1;for(n=0;n<o;n++){let c=n*a;for(let d=0;d<h;d++,c++)Ze(l,e,s[c],s[c+1],s[c+a],i[c],i[c+1],i[c+a]),Ze(l,e,s[c+a+1],s[c+1],s[c+a],i[c+a+1],i[c+1],i[c+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)Ze(l,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}var vs=class extends Yt{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,s){let a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,d=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),f=h/d,p=c/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/f,scaleY:1/p},b=d+2*2,m=u+2*2,_=s.getCanvas("mesh",b,m),A=_.context,y=A.createImageData(d,u);if(e){let E=y.data;for(let v=0,T=E.length;v<T;v+=4)E[v]=e[0],E[v+1]=e[1],E[v+2]=e[2],E[v+3]=255}for(let E of this._figures)Sn(y,E,g);return A.putImageData(y,2,2),{canvas:_.canvas,offsetX:a-2*f,offsetY:o-2*p,scaleX:f,scaleY:p}}getPattern(t,e,s,i){ys(t,this._bbox);let n;if(i===J.SHADING)n=C.singularValueDecompose2dScale(G(t));else if(n=C.singularValueDecompose2dScale(e.baseTransform),this.matrix){let a=C.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}let r=this._createMeshCanvas(n,i===J.SHADING?null:this._background,e.cachedCanvases);return i!==J.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")}},Es=class extends Yt{getPattern(){return"hotpink"}};function xn(l){switch(l[0]){case"RadialAxial":return new ws(l);case"Mesh":return new vs(l);case"Dummy":return new Es}throw new Error(`Unknown IR type: ${l[0]}`)}var Di={COLORED:1,UNCOLORED:2},Ss=class l{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i,n){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=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){let{bbox:e,operatorList:s,paintType:i,tilingType:n,color:r,canvasGraphicsFactory:a}=this,{xstep:o,ystep:h}=this;o=Math.abs(o),h=Math.abs(h),ze("TilingType: "+n);let c=e[0],d=e[1],u=e[2],f=e[3],p=u-c,g=f-d,b=C.singularValueDecompose2dScale(this.matrix),m=C.singularValueDecompose2dScale(this.baseTransform),_=b[0]*m[0],A=b[1]*m[1],y=p,w=g,E=!1,v=!1,T=Math.ceil(o*_),P=Math.ceil(h*A),N=Math.ceil(p*_),D=Math.ceil(g*A);T>=N?y=o:E=!0,P>=D?w=h:v=!0;let H=this.getSizeAndScale(y,this.ctx.canvas.width,_),W=this.getSizeAndScale(w,this.ctx.canvas.height,A),B=t.cachedCanvases.getCanvas("pattern",H.size,W.size),tt=B.context,x=a.createCanvasGraphics(tt);if(x.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(x,i,r),tt.translate(-H.scale*c,-W.scale*d),x.transform(H.scale,0,0,W.scale,0,0),tt.save(),this.clipBbox(x,c,d,u,f),x.baseTransform=G(x.ctx),x.executeOperatorList(s),x.endDrawing(),tt.restore(),E||v){let k=B.canvas;E&&(y=o),v&&(w=h);let rt=this.getSizeAndScale(y,this.ctx.canvas.width,_),ut=this.getSizeAndScale(w,this.ctx.canvas.height,A),mt=rt.size,lt=ut.size,K=t.cachedCanvases.getCanvas("pattern-workaround",mt,lt),X=K.context,Rt=E?Math.floor(p/o):0,Nt=v?Math.floor(g/h):0;for(let et=0;et<=Rt;et++)for(let $=0;$<=Nt;$++)X.drawImage(k,mt*et,lt*$,mt,lt,0,0,mt,lt);return{canvas:K.canvas,scaleX:rt.scale,scaleY:ut.scale,offsetX:c,offsetY:d}}return{canvas:B.canvas,scaleX:H.scale,scaleY:W.scale,offsetX:c,offsetY:d}}getSizeAndScale(t,e,s){let i=Math.max(l.MAX_PATTERN_SIZE,e),n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){let r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(G(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){let i=t.ctx,n=t.current;switch(e){case Di.COLORED:let r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case Di.UNCOLORED:let a=C.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new is(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==J.SHADING&&(n=C.transform(n,e.baseTransform),this.matrix&&(n=C.transform(n,this.matrix)));let r=this.createPatternCanvas(e),a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);let o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}};function Cn({src:l,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){let a=Y.isLittleEndian?4278190080:255,[o,h]=r?[n,a]:[a,n],c=s>>3,d=s&7,u=l.length;e=new Uint32Array(e.buffer);let f=0;for(let p=0;p<i;p++){for(let b=t+c;t<b;t++){let m=t<u?l[t]:255;e[f++]=m&128?h:o,e[f++]=m&64?h:o,e[f++]=m&32?h:o,e[f++]=m&16?h:o,e[f++]=m&8?h:o,e[f++]=m&4?h:o,e[f++]=m&2?h:o,e[f++]=m&1?h:o}if(d===0)continue;let g=t<u?l[t++]:255;for(let b=0;b<d;b++)e[f++]=g&1<<7-b?h:o}return{srcPos:t,destPos:f}}var Fi=16,Ni=100,Tn=15,Oi=10,Bi=1e3,nt=16;function kn(l,t){if(l._removeMirroring)throw new Error("Context is already forwarding operations.");l.__originalSave=l.save,l.__originalRestore=l.restore,l.__originalRotate=l.rotate,l.__originalScale=l.scale,l.__originalTranslate=l.translate,l.__originalTransform=l.transform,l.__originalSetTransform=l.setTransform,l.__originalResetTransform=l.resetTransform,l.__originalClip=l.clip,l.__originalMoveTo=l.moveTo,l.__originalLineTo=l.lineTo,l.__originalBezierCurveTo=l.bezierCurveTo,l.__originalRect=l.rect,l.__originalClosePath=l.closePath,l.__originalBeginPath=l.beginPath,l._removeMirroring=()=>{l.save=l.__originalSave,l.restore=l.__originalRestore,l.rotate=l.__originalRotate,l.scale=l.__originalScale,l.translate=l.__originalTranslate,l.transform=l.__originalTransform,l.setTransform=l.__originalSetTransform,l.resetTransform=l.__originalResetTransform,l.clip=l.__originalClip,l.moveTo=l.__originalMoveTo,l.lineTo=l.__originalLineTo,l.bezierCurveTo=l.__originalBezierCurveTo,l.rect=l.__originalRect,l.closePath=l.__originalClosePath,l.beginPath=l.__originalBeginPath,delete l._removeMirroring},l.save=function(){t.save(),this.__originalSave()},l.restore=function(){t.restore(),this.__originalRestore()},l.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},l.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},l.transform=function(s,i,n,r,a,o){t.transform(s,i,n,r,a,o),this.__originalTransform(s,i,n,r,a,o)},l.setTransform=function(s,i,n,r,a,o){t.setTransform(s,i,n,r,a,o),this.__originalSetTransform(s,i,n,r,a,o)},l.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},l.rotate=function(s){t.rotate(s),this.__originalRotate(s)},l.clip=function(s){t.clip(s),this.__originalClip(s)},l.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},l.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},l.bezierCurveTo=function(e,s,i,n,r,a){t.bezierCurveTo(e,s,i,n,r,a),this.__originalBezierCurveTo(e,s,i,n,r,a)},l.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},l.closePath=function(){t.closePath(),this.__originalClosePath()},l.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}var xs=class{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}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 re(l,t,e,s,i,n,r,a,o,h){let[c,d,u,f,p,g]=G(l);if(d===0&&u===0){let _=r*c+p,A=Math.round(_),y=a*f+g,w=Math.round(y),E=(r+o)*c+p,v=Math.abs(Math.round(E)-A)||1,T=(a+h)*f+g,P=Math.abs(Math.round(T)-w)||1;return l.setTransform(Math.sign(c),0,0,Math.sign(f),A,w),l.drawImage(t,e,s,i,n,0,0,v,P),l.setTransform(c,d,u,f,p,g),[v,P]}if(c===0&&f===0){let _=a*u+p,A=Math.round(_),y=r*d+g,w=Math.round(y),E=(a+h)*u+p,v=Math.abs(Math.round(E)-A)||1,T=(r+o)*d+g,P=Math.abs(Math.round(T)-w)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,A,w),l.drawImage(t,e,s,i,n,0,0,P,v),l.setTransform(c,d,u,f,p,g),[P,v]}l.drawImage(t,e,s,i,n,r,a,o,h);let b=Math.hypot(c,d),m=Math.hypot(u,f);return[b*o,m*h]}function Pn(l){let{width:t,height:e}=l;if(t>Bi||e>Bi)return null;let s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1,r=new Uint8Array(n*(e+1)),a,o,h,c=t+7&-8,d=new Uint8Array(c*e),u=0;for(let m of l.data){let _=128;for(;_>0;)d[u++]=m&_?0:255,_>>=1}let f=0;for(u=0,d[u]!==0&&(r[0]=1,++f),o=1;o<t;o++)d[u]!==d[u+1]&&(r[o]=d[u]?2:1,++f),u++;for(d[u]!==0&&(r[o]=2,++f),a=1;a<e;a++){u=a*c,h=a*n,d[u-c]!==d[u]&&(r[h]=d[u]?1:8,++f);let m=(d[u]?4:0)+(d[u-c]?8:0);for(o=1;o<t;o++)m=(m>>2)+(d[u+1]?4:0)+(d[u-c+1]?8:0),i[m]&&(r[h+o]=i[m],++f),u++;if(d[u-c]!==d[u]&&(r[h+o]=d[u]?2:4,++f),f>s)return null}for(u=c*(e-1),h=a*n,d[u]!==0&&(r[h]=8,++f),o=1;o<t;o++)d[u]!==d[u+1]&&(r[h+o]=d[u]?4:8,++f),u++;if(d[u]!==0&&(r[h+o]=4,++f),f>s)return null;let p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;f&&a<=e;a++){let m=a*n,_=m+t;for(;m<_&&!r[m];)m++;if(m===_)continue;g.moveTo(m%n,a);let A=m,y=r[m];do{let w=p[y];do m+=w;while(!r[m]);let E=r[m];E!==5&&E!==10?(y=E,r[m]=0):(y=E&51*y>>4,r[m]&=y>>2|y<<2),g.lineTo(m%n,m/n|0),r[m]||--f}while(A!==m);--a}return d=null,r=null,function(m){m.save(),m.scale(1/t,-1/e),m.translate(0,-e),m.fill(g),m.beginPath(),m.restore()}}var Se=class{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Vi,this.textMatrixScale=1,this.fontMatrix=ss,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=Q.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!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,s){[e,s]=C.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){let s=C.applyTransform(e,t),i=C.applyTransform(e.slice(2),t),n=C.applyTransform([e[0],e[3]],t),r=C.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){C.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,s,i,n,r,a,o,h,c){let d=C.bezierBoundingBox(e,s,i,n,r,a,o,h,c);c||this.updateRectMinMax(t,d)}getPathBoundingBox(t=J.FILL,e=null){let s=[this.minX,this.minY,this.maxX,this.maxY];if(t===J.STROKE){e||O("Stroke bounding box must include transform.");let i=C.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){let t=C.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=J.FILL,e=null){return C.intersect(this.clipBox,this.getPathBoundingBox(t,e))}};function Hi(l,t){if(t instanceof ImageData){l.putImageData(t,0,0);return}let e=t.height,s=t.width,i=e%nt,n=(e-i)/nt,r=i===0?n:n+1,a=l.createImageData(s,nt),o=0,h,c=t.data,d=a.data,u,f,p,g;if(t.kind===he.GRAYSCALE_1BPP){let b=c.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),_=m.length,A=s+7>>3,y=4294967295,w=Y.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(p=u<n?nt:i,h=0,f=0;f<p;f++){let E=b-o,v=0,T=E>A?s:E*8-7,P=T&-8,N=0,D=0;for(;v<P;v+=8)D=c[o++],m[h++]=D&128?y:w,m[h++]=D&64?y:w,m[h++]=D&32?y:w,m[h++]=D&16?y:w,m[h++]=D&8?y:w,m[h++]=D&4?y:w,m[h++]=D&2?y:w,m[h++]=D&1?y:w;for(;v<T;v++)N===0&&(D=c[o++],N=128),m[h++]=D&N?y:w,N>>=1}for(;h<_;)m[h++]=0;l.putImageData(a,0,u*nt)}}else if(t.kind===he.RGBA_32BPP){for(f=0,g=s*nt*4,u=0;u<n;u++)d.set(c.subarray(o,o+g)),o+=g,l.putImageData(a,0,f),f+=nt;u<r&&(g=s*i*4,d.set(c.subarray(o,o+g)),l.putImageData(a,0,f))}else if(t.kind===he.RGB_24BPP)for(p=nt,g=s*p,u=0;u<r;u++){for(u>=n&&(p=i,g=s*p),h=0,f=g;f--;)d[h++]=c[o++],d[h++]=c[o++],d[h++]=c[o++],d[h++]=255;l.putImageData(a,0,u*nt)}else throw new Error(`bad image kind: ${t.kind}`)}function $i(l,t){if(t.bitmap){l.drawImage(t.bitmap,0,0);return}let e=t.height,s=t.width,i=e%nt,n=(e-i)/nt,r=i===0?n:n+1,a=l.createImageData(s,nt),o=0,h=t.data,c=a.data;for(let d=0;d<r;d++){let u=d<n?nt:i;({srcPos:o}=Cn({src:h,srcPos:o,dest:c,width:s,height:u,nonBlackColor:0})),l.putImageData(a,0,d*nt)}}function Bt(l,t){let e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let s of e)l[s]!==void 0&&(t[s]=l[s]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function ae(l){if(l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0),!Z){let{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}}function Gi(l,t){if(t)return!0;let e=C.singularValueDecompose2dScale(l);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);let s=Math.fround((globalThis.devicePixelRatio||1)*wt.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}var Rn=["butt","round","square"],Ln=["miter","round","bevel"],Mn={},Ui={},It=class l{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,h){this.ctx=t,this.current=new Se(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=s,this.canvasFactory=i,this.filterFactory=n,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=a||[],this.optionalContentConfig=r,this.cachedCanvases=new xs(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){let n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){let o=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...G(this.compositeCtx))}this.ctx.save(),ae(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=G(this.ctx)}executeOperatorList(t,e,s,i){let n=t.argsArray,r=t.fnArray,a=e||0,o=n.length;if(o===a)return a;let h=o-a>Oi&&typeof s=="function",c=h?Date.now()+Tn:0,d=0,u=this.commonObjs,f=this.objs,p;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(p=r[a],p!==ct.dependency)this[p].apply(this,n[a]);else for(let g of n[a]){let b=g.startsWith("g_")?u:f;if(!b.has(g))return b.get(g,s),a}if(a++,a===o)return a;if(h&&++d>Oi){if(Date.now()>c)return s(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,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(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){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 s=t.width??t.displayWidth,i=t.height??t.displayHeight,n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=s,o=i,h="prescale1",c,d;for(;n>2&&a>1||r>2&&o>1;){let u=a,f=o;n>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/u),r>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,r/=o/f),c=this.cachedCanvases.getCanvas(h,u,f),d=c.context,d.clearRect(0,0,u,f),d.drawImage(t,0,0,a,o,0,0,u,f),t=c.canvas,a=u,o=f,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:o}}_createMaskCanvas(t){let e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=G(e),o,h,c,d;if((t.bitmap||t.data)&&t.count>1){let T=t.bitmap||t.data.buffer;h=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(T),o||(o=new Map,this._cachedBitmapsMap.set(T,o));let P=o.get(h);if(P&&!r){let N=Math.round(Math.min(a[0],a[2])+a[4]),D=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:P,offsetX:N,offsetY:D}}c=P}c||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),$i(d.context,t));let u=C.transform(a,[1/s,0,0,-1/i,0,0]);u=C.transform(u,[1,0,0,1,0,-i]);let[f,p,g,b]=C.getAxialAlignedBoundingBox([0,0,s,i],u),m=Math.round(g-f)||1,_=Math.round(b-p)||1,A=this.cachedCanvases.getCanvas("fillCanvas",m,_),y=A.context,w=f,E=p;y.translate(-w,-E),y.transform(...u),c||(c=this._scaleImage(d.canvas,ft(y)),c=c.img,o&&r&&o.set(h,c)),y.imageSmoothingEnabled=Gi(G(y),t.interpolate),re(y,c,0,0,c.width,c.height,0,0,s,i),y.globalCompositeOperation="source-in";let v=C.transform(ft(y),[1,0,0,1,-w,-E]);return y.fillStyle=r?n.getPattern(e,this,v,J.FILL):n,y.fillRect(0,0,s,i),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(h,A.canvas)),{canvas:A.canvas,offsetX:Math.round(w),offsetY:Math.round(E)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Rn[t]}setLineJoin(t){this.ctx.lineJoin=Ln[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){let s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}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 new Error("beginSMaskMode called while already in smask mode");let t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;let n=this.ctx;n.setTransform(...G(this.suspendedCtx)),Bt(this.suspendedCtx,n),kn(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Bt(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,s=this.suspendedCtx;this.composeSMask(s,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,s,i){let n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;a===0||o===0||(this.genericComposeSMask(e.context,s,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,o,h,c,d){let u=t.canvas,f=o-c,p=h-d;if(r){let b=C.makeHexColor(...r);if(f<0||p<0||f+s>u.width||p+i>u.height){let m=this.cachedCanvases.getCanvas("maskExtension",s,i),_=m.context;_.drawImage(u,-f,-p),_.globalCompositeOperation="destination-atop",_.fillStyle=b,_.fillRect(0,0,s,i),_.globalCompositeOperation="source-over",u=m.canvas,f=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let m=new Path2D;m.rect(f,p,s,i),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=b,t.fillRect(f,p,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));let g=new Path2D;g.rect(o,h,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(u,f,p,s,i,o,h,s,i),e.restore()}save(){this.inSMaskMode?(Bt(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Bt(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){let i=this.ctx,n=this.current,r=n.x,a=n.y,o,h,c=G(i),d=c[0]===0&&c[3]===0||c[1]===0&&c[2]===0,u=d?s.slice(0):null;for(let f=0,p=0,g=t.length;f<g;f++)switch(t[f]|0){case ct.rectangle:r=e[p++],a=e[p++];let b=e[p++],m=e[p++],_=r+b,A=a+m;i.moveTo(r,a),b===0||m===0?i.lineTo(_,A):(i.lineTo(_,a),i.lineTo(_,A),i.lineTo(r,A)),d||n.updateRectMinMax(c,[r,a,_,A]),i.closePath();break;case ct.moveTo:r=e[p++],a=e[p++],i.moveTo(r,a),d||n.updatePathMinMax(c,r,a);break;case ct.lineTo:r=e[p++],a=e[p++],i.lineTo(r,a),d||n.updatePathMinMax(c,r,a);break;case ct.curveTo:o=r,h=a,r=e[p+4],a=e[p+5],i.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],r,a),n.updateCurvePathMinMax(c,o,h,e[p],e[p+1],e[p+2],e[p+3],r,a,u),p+=6;break;case ct.curveTo2:o=r,h=a,i.bezierCurveTo(r,a,e[p],e[p+1],e[p+2],e[p+3]),n.updateCurvePathMinMax(c,o,h,r,a,e[p],e[p+1],e[p+2],e[p+3],u),r=e[p+2],a=e[p+3],p+=4;break;case ct.curveTo3:o=r,h=a,r=e[p+2],a=e[p+3],i.bezierCurveTo(e[p],e[p+1],r,a,r,a),n.updateCurvePathMinMax(c,o,h,e[p],e[p+1],r,a,r,a,u),p+=4;break;case ct.closePath:i.closePath();break}d&&n.updateScalingPathMinMax(c,u),n.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(t=!0){let e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,ft(e),J.STROKE),this.rescaleAndStroke(!1),e.restore()):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,s=this.current.fillColor,i=this.current.patternFill,n=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,ft(e),J.FILL),n=!0);let r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&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=Mn}eoClip(){this.pendingClip=Ui}beginText(){this.current.textMatrix=Vi,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(t===void 0){e.beginPath();return}let s=new Path2D,i=e.getTransform().invertSelf();for(let{transform:n,x:r,y:a,fontSize:o,path:h}of t)s.addPath(h,new DOMMatrix(n).preMultiplySelf(i).translate(r,a).scale(o,-o));e.clip(s),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 s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||ss,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&M("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;let n=s.loadedName||"sans-serif",r=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`,a="normal";s.black?a="900":s.bold&&(a="bold");let o=s.italic?"italic":"normal",h=e;e<Fi?h=Fi:e>Ni&&(h=Ni),this.current.fontSizeScale=e/h,this.ctx.font=`${o} ${a} ${h}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,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,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)}#s(t,e,s){let i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i}paintChar(t,e,s,i,n){let r=this.ctx,a=this.current,o=a.font,h=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,d=h&Q.FILL_STROKE_MASK,u=!!(h&Q.ADD_TO_PATH_FLAG),f=a.patternFill&&!o.missingFile,p=a.patternStroke&&!o.missingFile,g;if((o.disableFontFace||u||f||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||f||p){if(r.save(),r.translate(e,s),r.scale(c,-c),d===Q.FILL||d===Q.FILL_STROKE)if(i){let b=r.getTransform();r.setTransform(...i),r.fill(this.#s(g,b,i))}else r.fill(g);if(d===Q.STROKE||d===Q.FILL_STROKE)if(n){let b=r.getTransform();r.setTransform(...n),r.stroke(this.#s(g,b,n))}else r.lineWidth/=c,r.stroke(g);r.restore()}else(d===Q.FILL||d===Q.FILL_STROKE)&&r.fillText(t,e,s),(d===Q.STROKE||d===Q.FILL_STROKE)&&r.strokeText(t,e,s);u&&(this.pendingTextPaths||=[]).push({transform:G(r),x:e,y:s,fontSize:c,path:g})}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,s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return I(this,"isFontSubpixelAAEnabled",s)}showText(t){let e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);let i=e.fontSize;if(i===0)return;let n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,h=e.fontDirection,c=e.textHScale*h,d=t.length,u=s.vertical,f=u?1:-1,p=s.defaultVMetrics,g=i*e.fontMatrix[0],b=e.textRenderingMode===Q.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(c,-1):n.scale(c,1);let m,_;if(e.patternFill){n.save();let v=e.fillColor.getPattern(n,this,ft(n),J.FILL);m=G(n),n.restore(),n.fillStyle=v}if(e.patternStroke){n.save();let v=e.strokeColor.getPattern(n,this,ft(n),J.STROKE);_=G(n),n.restore(),n.strokeStyle=v}let A=e.lineWidth,y=e.textMatrixScale;if(y===0||A===0){let v=e.textRenderingMode&Q.FILL_STROKE_MASK;(v===Q.STROKE||v===Q.FILL_STROKE)&&(A=this.getSinglePixelWidth())}else A/=y;if(r!==1&&(n.scale(r,r),A/=r),n.lineWidth=A,s.isInvalidPDFjsFont){let v=[],T=0;for(let P of t)v.push(P.unicode),T+=P.width;n.fillText(v.join(""),0,0),e.x+=T*g*c,n.restore(),this.compose();return}let w=0,E;for(E=0;E<d;++E){let v=t[E];if(typeof v=="number"){w+=f*v*i/1e3;continue}let T=!1,P=(v.isSpace?o:0)+a,N=v.fontChar,D=v.accent,H,W,B=v.width;if(u){let x=v.vmetric||p,k=-(v.vmetric?x[1]:B*.5)*g,rt=x[2]*g;B=x?-x[0]:B,H=k/r,W=(w+rt)/r}else H=w/r,W=0;if(s.remeasure&&B>0){let x=n.measureText(N).width*1e3/i*r;if(B<x&&this.isFontSubpixelAAEnabled){let k=B/x;T=!0,n.save(),n.scale(k,1),H/=k}else B!==x&&(H+=(B-x)/2e3*i/r)}if(this.contentVisible&&(v.isInFont||s.missingFile)){if(b&&!D)n.fillText(N,H,W);else if(this.paintChar(N,H,W,m,_),D){let x=H+i*D.offset.x/r,k=W-i*D.offset.y/r;this.paintChar(D.fontChar,x,k,m,_)}}let tt=u?B*g-P*h:B*g+P*h;w+=tt,T&&n.restore()}u?e.y-=w:e.x+=w*c,n.restore(),this.compose()}showType3Text(t){let e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,o=s.charSpacing,h=s.wordSpacing,c=s.textHScale*r,d=s.fontMatrix||ss,u=t.length,f=s.textRenderingMode===Q.INVISIBLE,p,g,b,m;if(!(f||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(c,r),p=0;p<u;++p){if(g=t[p],typeof g=="number"){m=a*g*n/1e3,this.ctx.translate(m,0),s.x+=m*c;continue}let _=(g.isSpace?h:0)+o,A=i.charProcOperatorList[g.operatorListId];if(!A){M(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(A),this.restore()),b=C.applyTransform([g.width,0],d)[0]*n+_,e.translate(b,0),s.x+=b*c}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){let s=t[1],i=this.baseTransform||G(this.ctx),n={createCanvasGraphics:r=>new l(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ss(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=C.makeHexColor(t,e,s),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=C.makeHexColor(t,e,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=xn(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;let e=this.ctx;this.save();let s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,ft(e),J.SHADING);let i=ft(e);if(i){let{width:n,height:r}=e.canvas,[a,o,h,c]=C.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,o,h-a,c-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){O("Should not call beginInlineImage")}beginImageData(){O("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=G(this.ctx),e)){let s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(G(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||ze("TODO: Support non-isolated groups."),t.knockout&&M("Knockout groups not supported.");let s=G(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=C.getAxialAlignedBoundingBox(t.bbox,G(e)),n=[0,0,e.canvas.width,e.canvas.height];i=C.intersect(i,n)||[0,0,0,0];let r=Math.floor(i[0]),a=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-r,1),h=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,h]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);let d=this.cachedCanvases.getCanvas(c,o,h),u=d.context;u.translate(-r,-a),u.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:u,offsetX:r,offsetY:a,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,a),e.save()),Bt(e,u),this.ctx=u,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,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let i=G(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);let n=C.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(this.#t(),ae(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){let r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=r,e[3]=a;let[o,h]=C.singularValueDecompose2dScale(G(this.ctx)),{viewportScale:c}=this,d=Math.ceil(r*this.outputScaleX*c),u=Math.ceil(a*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);let{canvas:f,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,f),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(o,0,0,-h,0,a*h),ae(this.ctx)}else ae(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Se(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),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),t.count=e;let s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=Pn(t)),i.compiled)){i.compiled(s);return}let n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);let a=this.ctx;a.save();let o=G(a);a.transform(e,s,i,n,0,0);let h=this._createMaskCanvas(t);a.setTransform(1,0,0,1,h.offsetX-o[4],h.offsetY-o[5]);for(let c=0,d=r.length;c<d;c+=2){let u=C.transform(o,[e,s,i,n,r[c],r[c+1]]),[f,p]=C.applyTransform([0,0],u);a.drawImage(h.canvas,f,p)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;let e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(let n of t){let{data:r,width:a,height:o,transform:h}=n,c=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=c.context;d.save();let u=this.getObject(r,n);$i(d,u),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,ft(e),J.FILL):s,d.fillRect(0,0,a,o),d.restore(),e.save(),e.transform(...h),e.scale(1,-1),re(e,c.canvas,0,0,a,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;let e=this.getObject(t);if(!e){M("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;let n=this.getObject(t);if(!n){M("Dependent image isn't ready yet");return}let r=n.width,a=n.height,o=[];for(let h=0,c=i.length;h<c;h+=2)o.push({transform:[e,0,0,s,i[h],i[h+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;let{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;let e=t.width,s=t.height,i=this.ctx;if(this.save(),!Z){let{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}i.scale(1/e,-1/s);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{let o=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Hi(o,t),n=this.applyTransferMapsToCanvas(o)}let r=this._scaleImage(n,ft(i));i.imageSmoothingEnabled=Gi(G(i),t.interpolate),re(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;let s=this.ctx,i;if(t.bitmap)i=t.bitmap;else{let n=t.width,r=t.height,o=this.cachedCanvases.getCanvas("inlineImage",n,r).context;Hi(o,t),i=this.applyTransferMapsToCanvas(o)}for(let n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),re(s,i,n.x,n.y,n.w,n.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){t==="OC"?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 s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Ui?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=G(this.ctx);if(t[1]===0&&t[2]===0)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]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform(),r,a;if(s===0&&i===0){let o=Math.abs(e),h=Math.abs(n);if(o===h)if(t===0)r=a=1/o;else{let c=o*t;r=a=c<1?1/c:1}else if(t===0)r=1/o,a=1/h;else{let c=o*t,d=h*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{let o=Math.abs(e*n-s*i),h=Math.hypot(e,s),c=Math.hypot(i,n);if(t===0)r=c/o,a=h/o;else{let d=t*o;r=c>d?c/d:1,a=h>d?h/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){let{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}let r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){let a=Math.max(i,n);e.setLineDash(r.map(o=>o/a)),e.lineDashOffset/=a}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 l in ct)It.prototype[l]!==void 0&&(It.prototype[ct[l]]=It.prototype[l]);var St=class{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}},Cs=class{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return Si(this.#t)}has(t){return this.#t.has(t)}},Mt=Symbol("INTERNAL"),Ts=class{#t=!1;#e=!1;#s=!1;#i=!0;constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){this.#t=!!(t&at.DISPLAY),this.#e=!!(t&at.PRINT),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(this.#s)return this.#i;if(!this.#i)return!1;let{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Mt&&O("Internal method `_setVisible` called."),this.#s=s,this.#i=e}},ks=class{#t=null;#e=new Map;#s=null;#i=null;constructor(t,e=at.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#i=t.order;for(let s of t.groups)this.#e.set(s.id,new Ts(e,s));if(t.baseState==="OFF")for(let s of this.#e.values())s._setVisible(Mt,!1);for(let s of t.on)this.#e.get(s)._setVisible(Mt,!0);for(let s of t.off)this.#e.get(s)._setVisible(Mt,!1);this.#s=this.getHash()}}#r(t){let e=t.length;if(e<2)return!0;let s=t[0];for(let i=1;i<e;i++){let n=t[i],r;if(Array.isArray(n))r=this.#r(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return M(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return ze("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(M(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#r(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return M(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(let e of t.ids){if(!this.#e.has(e))return M(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(let e of t.ids){if(!this.#e.has(e))return M(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(let e of t.ids){if(!this.#e.has(e))return M(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return M(`Unknown optional content policy ${t.policy}.`),!0}return M(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){let i=this.#e.get(t);if(!i){M(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(let n of i.rbGroups)for(let r of n)r!==t&&this.#e.get(r)?._setVisible(Mt,!1,!0);i._setVisible(Mt,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(let i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}let n=this.#e.get(i);if(n)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#i?this.#i.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Si(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new me;for(let[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}},Ps=class{constructor(t,{disableRange:e=!1,disableStream:s=!1}){V(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){let o=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,h)=>{this._onReceiveData({begin:o,chunk:h})}),t.addProgressListener((o,h)=>{this._onProgress({loaded:o,total:h})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{let i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});V(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?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(){V(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new Rs(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new Ls(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}},Rs=class{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Ci(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(let n of this._queuedChunks)this._loaded+=n.byteLength;this._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){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}},Ls=class{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(let s of this._requests)s.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 e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};function In(l){let t=!0,e=s("filename\\*","i").exec(l);if(e){e=e[1];let c=a(e);return c=unescape(c),c=o(c),c=h(c),n(c)}if(e=r(l),e){let c=h(e);return n(c)}if(e=s("filename","i").exec(l),e){e=e[1];let c=a(e);return c=h(c),n(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{let u=new TextDecoder(c,{fatal:!0}),f=je(d);d=u.decode(f),t=!1}catch{}}return d}function n(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function r(c){let d=[],u,f=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=f.exec(c))!==null;){let[,g,b,m]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[b,m]}let p=[];for(let g=0;g<d.length&&g in d;++g){let[b,m]=d[g];m=a(m),b&&(m=unescape(m),g===0&&(m=o(m))),p.push(m)}return p.join("")}function a(c){if(c.startsWith('"')){let d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){let f=d[u].indexOf('"');f!==-1&&(d[u]=d[u].slice(0,f),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function o(c){let d=c.indexOf("'");if(d===-1)return c;let u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return i(u,p)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,b){return String.fromCharCode(parseInt(b,16))}),i(u,p);try{p=atob(p)}catch{}return i(u,p)})}return""}function qi(l,t){let e=new Headers;if(!l||!t||typeof t!="object")return e;for(let s in t){let i=t[s];i!==void 0&&e.append(s,i)}return e}function Xe(l){try{return new URL(l).origin}catch{}return null}function Yi({responseHeaders:l,isHttp:t,rangeChunkSize:e,disableRange:s}){let i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(l.get("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||l.get("Accept-Ranges")!=="bytes"||(l.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Ki(l){let t=l.get("Content-Disposition");if(t){let e=In(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ci(e))return e}return null}function qe(l,t){return l===404||l===0&&t.startsWith("file:")?new xt('Missing PDF "'+t+'".'):new Ft(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l)}function Qi(l){return l===200||l===206}function Ji(l,t,e){return{method:"GET",headers:l,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Zi(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(M(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}var xe=class{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=qi(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return V(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ms(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new Is(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Ms=class{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;let s=new Headers(t.headers),i=e.url;fetch(i,Ji(s,this._withCredentials,this._abortController)).then(n=>{if(t._responseOrigin=Xe(n.url),!Qi(n.status))throw qe(n.status,i);this._reader=n.body.getReader(),this._headersCapability.resolve();let r=n.headers,{allowRangeRequests:a,suggestedLength:o}=Yi({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=Ki(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new gt("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:Zi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},Is=class{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;let i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;let n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`);let r=i.url;fetch(r,Ji(n,this._withCredentials,this._abortController)).then(a=>{let o=Xe(a.url);if(o!==t._responseOrigin)throw new Error(`Expected range response-origin "${o}" to match "${t._responseOrigin}".`);if(!Qi(a.status))throw qe(a.status,r);this._readCapability.resolve(),this._reader=a.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:Zi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},ts=200,es=206;function Dn(l){let t=l.response;return typeof t!="string"?t:je(t).buffer}var Ds=class{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=qi(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(let[n,r]of this.headers)e.setRequestHeader(n,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=es):i.expectedStatus=ts,e.responseType="arraybuffer",V(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){let s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){let s=this.pendingRequests[t];if(!s)return;let i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError(i.status);return}let n=i.status||ts;if(!(n===ts&&s.expectedStatus===es)&&n!==s.expectedStatus){s.onError(i.status);return}let a=Dn(i);if(n===es){let o=i.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(o);h?s.onDone({begin:parseInt(h[1],10),chunk:a}):(M('Missing or invalid "Content-Range" header.'),s.onError(0))}else a?s.onDone({begin:0,chunk:a}):s.onError(i.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()}},Fs=class{constructor(t){this._source=t,this._manager=new Ds(t),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 V(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Ns(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let s=new Os(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Ns=class{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=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);this._manager._responseOrigin=Xe(e.responseURL);let s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(a=>{let[o,...h]=a.split(": ");return[o,h.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=Yi({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Ki(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=qe(t,this._url),this._headersCapability.reject(this._storedError);for(let e of 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._headersCapability.promise}async read(){if(await this._headersCapability.promise,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){this._done=!0,this._headersCapability.reject(t);for(let e of 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}},Os=class{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=Xe(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(let s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=qe(t,this._url);for(let e of 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(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},Fn=/^[a-z][a-z0-9\-+.]+:/i;function Nn(l){if(Fn.test(l))return new URL(l);let t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(l))}var Bs=class{constructor(t){this.source=t,this.url=Nn(t.url),V(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return V(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Hs(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new $s(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Hs=class{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();let s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new xt(`Missing PDF "${this._url}".`)),this._storedError=i,this._headersCapability.reject(i)})}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 t===null?(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",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new gt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}},$s=class{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let i=t.source;this._isStreamingSupported=!i.disableStream;let n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:s-1}))}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 t===null?(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",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}},On=1e5,st=30,Bn=.8,Kt=class l{#t=Promise.withResolvers();#e=null;#s=!1;#i=!!globalThis.FontInspector?.enabled;#r=null;#n=null;#l=0;#o=0;#c=null;#h=null;#u=0;#d=0;#f=Object.create(null);#a=[];#p=null;#m=[];#g=new WeakMap;#b=null;static#y=new Map;static#_=new Map;static#w=new WeakMap;static#E=null;static#x=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#p=t;else if(typeof t=="object")this.#p=new ReadableStream({start(o){o.enqueue(t),o.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#h=e,this.#d=s.scale*(globalThis.devicePixelRatio||1),this.#u=s.rotation,this.#n={div:null,properties:null,ctx:null};let{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;this.#b=[1,0,0,-1,-r,a+n],this.#o=i,this.#l=n,l.#L(),Ct(e,s),this.#t.promise.finally(()=>{l.#x.delete(this),this.#n=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=Y.platform;return I(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#c.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#r??=e.lang,Object.assign(this.#f,e.styles),this.#T(e.items),t()},this.#t.reject)};return this.#c=this.#p.getReader(),l.#x.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#u&&(e?.(),this.#u=i,Ct(this.#h,{rotation:i})),s!==this.#d){e?.(),this.#d=s;let n={div:null,properties:null,ctx:l.#k(this.#r)};for(let r of this.#m)n.properties=this.#g.get(r),n.div=r,this.#v(n)}}cancel(){let t=new gt("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#a}#T(t){if(this.#s)return;this.#n.ctx??=l.#k(this.#r);let e=this.#m,s=this.#a;for(let i of t){if(e.length>On){M("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){let n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id!==null&&this.#e.setAttribute("id",`${i.id}`),n.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(i.str),this.#P(i)}}#P(t){let e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);let i=C.transform(this.#b,t.transform),n=Math.atan2(i[1],i[0]),r=this.#f[t.fontName];r.vertical&&(n+=Math.PI/2);let a=this.#i&&r.fontSubstitution||r.fontFamily;a=l.fontFamilyMap.get(a)||a;let o=Math.hypot(i[2],i[3]),h=o*l.#D(a,this.#r),c,d;n===0?(c=i[4],d=i[5]-h):(c=i[4]+h*Math.sin(n),d=i[5]-h*Math.cos(n));let u="calc(var(--scale-factor)*",f=e.style;this.#e===this.#h?(f.left=`${(100*c/this.#o).toFixed(2)}%`,f.top=`${(100*d/this.#l).toFixed(2)}%`):(f.left=`${u}${c.toFixed(2)}px)`,f.top=`${u}${d.toFixed(2)}px)`),f.fontSize=`${u}${(l.#E*o).toFixed(2)}px)`,f.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#i&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){let g=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);g!==b&&Math.max(g,b)/Math.min(g,b)>1.5&&(p=!0)}if(p&&(s.canvasWidth=r.vertical?t.height:t.width),this.#g.set(e,s),this.#n.div=e,this.#n.properties=s,this.#v(this.#n),s.hasText&&this.#e.append(e),s.hasEOL){let g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#v(t){let{div:e,properties:s,ctx:i}=t,{style:n}=e,r="";if(l.#E>1&&(r=`scale(${1/l.#E})`),s.canvasWidth!==0&&s.hasText){let{fontFamily:a}=n,{canvasWidth:o,fontSize:h}=s;l.#C(i,h*this.#d,a);let{width:c}=i.measureText(e.textContent);c>0&&(r=`scaleX(${o*this.#d/c}) ${r}`)}s.angle!==0&&(r=`rotate(${s.angle}deg) ${r}`),r.length>0&&(n.transform=r)}static cleanup(){if(!(this.#x.size>0)){this.#y.clear();for(let{canvas:t}of this.#_.values())t.remove();this.#_.clear()}}static#k(t=null){let e=this.#_.get(t||="");if(!e){let s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#_.set(t,e),this.#w.set(e,{size:0,family:""})}return e}static#C(t,e,s){let i=this.#w.get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)}static#L(){if(this.#E!==null)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#E=t.getBoundingClientRect().height,t.remove()}static#D(t,e){let s=this.#y.get(t);if(s)return s;let i=this.#k(e);i.canvas.width=i.canvas.height=st,this.#C(i,st,t);let n=i.measureText(""),r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){let c=r/(r+a);return this.#y.set(t,c),i.canvas.width=i.canvas.height=0,c}i.strokeStyle="red",i.clearRect(0,0,st,st),i.strokeText("g",0,0);let o=i.getImageData(0,0,st,st).data;a=0;for(let c=o.length-1-3;c>=0;c-=4)if(o[c]>0){a=Math.ceil(c/4/st);break}i.clearRect(0,0,st,st),i.strokeText("A",0,st),o=i.getImageData(0,0,st,st).data,r=0;for(let c=0,d=o.length;c<d;c+=4)if(o[c]>0){r=st-Math.floor(c/4/st);break}i.canvas.width=i.canvas.height=0;let h=r?r/(r+a):Bn;return this.#y.set(t,h),h}},Qt=class l{static textContent(t){let e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null,a=n.name;if(a==="#text")r=n.value;else if(l.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(let o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}},Hn=65536,$n=100,Gn=5e3,Un=Z?bs:ps,zn=Z?_s:ye,jn=Z?ms:gs,Vn=Z?As:Ee;function Wn(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});let t=new Gs,{docId:e}=t,s=l.url?Xn(l.url):null,i=l.data?qn(l.data):null,n=l.httpHeaders||null,r=l.withCredentials===!0,a=l.password??null,o=l.range instanceof Ce?l.range:null,h=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:Hn,c=l.worker instanceof Dt?l.worker:null,d=l.verbosity,u=typeof l.docBaseUrl=="string"&&!We(l.docBaseUrl)?l.docBaseUrl:null,f=typeof l.cMapUrl=="string"?l.cMapUrl:null,p=l.cMapPacked!==!1,g=l.CMapReaderFactory||zn,b=typeof l.standardFontDataUrl=="string"?l.standardFontDataUrl:null,m=l.StandardFontDataFactory||Vn,_=l.stopAtErrors!==!0,A=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,y=l.isEvalSupported!==!1,w=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!Z,E=typeof l.isImageDecoderSupported=="boolean"?l.isImageDecoderSupported:!Z&&(Y.platform.isFirefox||!globalThis.chrome),v=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,T=typeof l.disableFontFace=="boolean"?l.disableFontFace:Z,P=l.fontExtraProperties===!0,N=l.enableXfa===!0,D=l.ownerDocument||globalThis.document,H=l.disableRange===!0,W=l.disableStream===!0,B=l.disableAutoFetch===!0,tt=l.pdfBug===!0,x=l.CanvasFactory||Un,k=l.FilterFactory||jn,rt=l.enableHWA===!0,ut=o?o.length:l.length??NaN,mt=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!Z&&!T,lt=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:g===ye&&m===Ee&&f&&b&&Gt(f,document.baseURI)&&Gt(b,document.baseURI),K=null;hn(d);let X={canvasFactory:new x({ownerDocument:D,enableHWA:rt}),filterFactory:new k({docId:e,ownerDocument:D}),cMapReaderFactory:lt?null:new g({baseUrl:f,isCompressed:p}),standardFontDataFactory:lt?null:new m({baseUrl:b})};if(!c){let et={verbosity:d,port:St.workerPort};c=et.port?Dt.fromPort(et):new Dt(et),t._worker=c}let Rt={docId:e,apiVersion:"4.10.38",data:i,password:a,disableAutoFetch:B,rangeChunkSize:h,length:ut,docBaseUrl:u,enableXfa:N,evaluatorOptions:{maxImageSize:A,disableFontFace:T,ignoreErrors:_,isEvalSupported:y,isOffscreenCanvasSupported:w,isImageDecoderSupported:E,canvasMaxAreaInBytes:v,fontExtraProperties:P,useSystemFonts:mt,cMapUrl:lt?f:null,standardFontDataUrl:lt?b:null}},Nt={disableFontFace:T,fontExtraProperties:P,ownerDocument:D,pdfBug:tt,styleElement:K,loadingParams:{disableAutoFetch:B,enableXfa:N}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");let et=c.messageHandler.sendWithPromise("GetDocRequest",Rt,i?[i.buffer]:null),$;if(o)$=new Ps(o,{disableRange:H,disableStream:W});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let Lt;if(Z)if(Gt(s)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Lt=xe}else Lt=Bs;else Lt=Gt(s)?xe:Fs;$=new Lt({url:s,length:ut,httpHeaders:n,withCredentials:r,rangeChunkSize:h,disableRange:H,disableStream:W})}return et.then(Lt=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");let Ri=new Et(e,Lt,c.port),sn=new Vs(Ri,t,$,Nt,X);t._transport=sn,Ri.send("Ready",null)})}).catch(t._capability.reject),t}function Xn(l){if(l instanceof URL)return l.href;try{return new URL(l,window.location).href}catch{if(Z&&typeof l=="string")return l}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function qn(l){if(Z&&typeof Buffer<"u"&&l instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength)return l;if(typeof l=="string")return je(l);if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)||typeof l=="object"&&!isNaN(l?.length))return new Uint8Array(l);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function zi(l){return typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0}var Gs=class l{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${l.#t++}`,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?.destroy(),this._worker=null}},Ce=class{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,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 s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(let s of this._progressListeners)s(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){O("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},Us=class{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return I(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()}},zs=class{#t=null;#e=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new de:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Te,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:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new Vt({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=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 I(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=At.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:d=!1}){this._stats?.time("Overall");let u=this._transport.getRenderingIntent(s,i,c,d),{renderingIntent:f,cacheKey:p}=u;this.#e=!1,this.#i(),a||=this._transport.getOptionalContentConfig(f);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);let b=!!(f&at.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));let m=y=>{g.renderTasks.delete(_),(this._maybeCleanupAfterRender||b)&&(this.#e=!0),this.#s(!b),y?(_.capability.reject(y),this._abortOperatorList({intentState:g,reason:y instanceof Error?y:new Error(y)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new Xs({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:h});(g.renderTasks||=new Set).add(_);let A=_.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([y,w])=>{if(this.destroyed){m();return}if(this._stats?.time("Rendering"),!(w.renderingIntent&f))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:y,optionalContentConfig:w}),_.operatorListChanged()}).catch(m),A}getOperatorList({intent:t="display",annotationMode:e=At.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){function n(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o))}let r=this._transport.getRenderingIntent(t,e,s,i,!0),a=this._intentStates.get(r.cacheKey);a||(a=Object.create(null),this._intentStates.set(r.cacheKey,a));let o;return a.opListReadCapability||(o=Object.create(null),o.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Qt.textContent(s));let e=this.streamTextContent(t);return new Promise(function(s,i){function n(){r.read().then(function({value:o,done:h}){if(h){s(a);return}a.lang??=o.lang,Object.assign(a.styles,o.styles),a.items.push(...o.items),n()},i)}let r=e.getReader(),a={items:[],styles:Object.create(null),lang:null};n()})}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:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#e=!1,this.#i(),Promise.all(t)}cleanup(t=!1){this.#e=!0;let e=this.#s(!1);return t&&e&&(this._stats&&=new de),e}#s(t=!1){if(this.#i(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#s(!1)},Gn),!1;for(let{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#i(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){let s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#s(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){let{map:n,transfer:r}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},r).getReader(),h=this._intentStates.get(e);h.streamReader=o;let c=()=>{o.read().then(({value:d,done:u})=>{if(u){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,h),c())},d=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(let u of h.renderTasks)u.operatorListChanged();this.#s(!0)}if(h.displayReadyCapability)h.displayReadyCapability.reject(d);else if(h.opListReadCapability)h.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Wt){let i=$n;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 gt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}},js=class{#t=new Map;#e=Promise.resolve();postMessage(t,e){let s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){let{signal:n}=s;if(n.aborted){M("LoopbackPort - cannot use an `aborted` signal.");return}let r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}},Dt=class l{static#t=0;static#e=!1;static#s;static{Z&&(this.#e=!0,St.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}let i=new URL(e,s);return s.origin===i.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:s=cn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(l.#s?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(l.#s||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#i(){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 Et("main","worker",t),this._messageHandler.on("ready",function(){}),this.#i()}_initialize(){if(l.#e||l.#r){this._setupFakeWorker();return}let{workerSrc:t}=l;try{l._isSameOrigin(window.location.href,t)||(t=l._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),s=new Et("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,this.#i()}),s.on("ready",a=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this._setupFakeWorker()}});let r=()=>{let a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{ze("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){l.#e||(M("Setting up fake worker."),l.#e=!0),l._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let e=new js;this._port=e;let s=`fake${l.#t++}`,i=new Et(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new Et(s,s+"_worker",e),this.#i()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,l.#s?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let e=this.#s?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new l(t)}static get workerSrc(){if(St.workerSrc)return St.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#r(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return I(this,"_setupFakeWorkerGlobal",(async()=>this.#r?this.#r:(await import(this.workerSrc)).WorkerMessageHandler)())}},Vs=class{#t=new Map;#e=new Map;#s=new Map;#i=new Map;#r=null;constructor(t,e,s,i,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Te,this.fontLoader=new us({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#n(t,e=null){let s=this.#t.get(t);if(s)return s;let i=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,i),i}get annotationStorage(){return I(this,"annotationStorage",new qt)}getRenderingIntent(t,e=At.ENABLE,s=null,i=!1,n=!1){let r=at.DISPLAY,a=ds;switch(t){case"any":r=at.ANY;break;case"display":break;case"print":r=at.PRINT;break;default:M(`getRenderingIntent - invalid intent: ${t}`)}let o=r&at.PRINT&&s instanceof be?s:this.annotationStorage;switch(e){case At.DISABLE:r+=at.ANNOTATIONS_DISABLE;break;case At.ENABLE:break;case At.ENABLE_FORMS:r+=at.ANNOTATIONS_FORMS;break;case At.ENABLE_STORAGE:r+=at.ANNOTATIONS_STORAGE,a=o.serializable;break;default:M(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(r+=at.IS_EDITING),n&&(r+=at.OPLIST);let{ids:h,hash:c}=o.modifiedIds,d=[r,a.hash,c];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r?.reject(new Error("Worker was destroyed during onPassword callback"));let t=[];for(let s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#s.clear(),this.#i.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.#t.clear(),this.filterFactory.destroy(),Kt.cleanup(),this._networkStream?.cancelAllRequests(new gt("Worker was terminated.")),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",(s,i)=>{V(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){i.close();return}V(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async s=>{await this._fullReader.headersReady;let{isStreamingSupported:i,isRangeSupported:n,contentLength:r}=this._fullReader;return(!i||!n)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=a=>{e.onProgress?.({loaded:a.loaded,total:a.total})}),{isStreamingSupported:i,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(s,i)=>{V(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}V(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Us(s,this))}),t.on("DocException",s=>{e._capability.reject(it(s))}),t.on("PasswordRequest",s=>{this.#r=Promise.withResolvers();try{if(!e.onPassword)throw it(s);let i=n=>{n instanceof Error?this.#r.reject(n):this.#r.resolve({password:n})};e.onPassword(i,s.code)}catch(i){this.#r.reject(i)}return this.#r.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":let{disableFontFace:r,fontExtraProperties:a,pdfBug:o}=this._params;if("error"in n){let u=n.error;M(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}let h=o&&globalThis.FontInspector?.enabled?(u,f)=>globalThis.FontInspector.fontAdded(u,f):null,c=new fs(n,{disableFontFace:r,fontExtraProperties:a,inspectFont:h});this.fontLoader.bind(c).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!a&&c.data&&(c.data=null),this.commonObjs.resolve(s,c)});break;case"CopyLocalImage":let{imageRef:d}=n;V(d,"The imageRef must be defined.");for(let u of this.#e.values())for(let[,f]of u.objs)if(f?.ref===d)return f.dataLen?(this.commonObjs.resolve(s,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;let a=this.#e.get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":a.objs.resolve(s,r),r?.dataLen>nn&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),t.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&M("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(new Error("Invalid page request."));let e=t-1,s=this.#s.get(e);if(s)return s;let i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#i.set(n.refStr,t);let r=new zs(e,n,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#s.set(e,i),i}getPageIndex(t){return zi(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#n("GetFieldObjects")}hasJSActions(){return this.#n("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#n("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.#n("GetOptionalContentConfig").then(e=>new ks(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#t.get(t);if(e)return e;let s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new Cs(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Kt.cleanup()}}cachedPageNumber(t){if(!zi(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#i.get(e)??null}},Ht=Symbol("INITIAL_DATA"),Te=class{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:Ht}}get(t,e=null){if(e){let i=this.#e(t);return i.promise.then(()=>e(i.data)),null}let s=this.#t[t];if(!s||s.data===Ht)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){let e=this.#t[t];return!!e&&e.data!==Ht}delete(t){let e=this.#t[t];return!e||e.data===Ht?!1:(delete this.#t[t],!0)}resolve(t,e=null){let s=this.#e(t);s.data=e,s.resolve()}clear(){for(let t in this.#t){let{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(let t in this.#t){let{data:e}=this.#t[t];e!==Ht&&(yield[t,e])}}},Ws=class{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}},Xs=class l{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Ws(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(l.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");l.#e.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:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new It(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,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.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),l.#e.delete(this._canvas),this.callback(t||new Wt(`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.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):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(),l.#e.delete(this._canvas),this.callback())))}},Yn="4.10.38",Kn="f9bea397f";function ji(l){return Math.floor(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}function $t(l){return Math.max(0,Math.min(255,255*l))}var ke=class{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}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=$t(t),[t,t,t]}static G_HTML([t]){let e=ji(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map($t)}static RGB_HTML(t){return`#${t.map(ji).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[$t(1-Math.min(1,t+i)),$t(1-Math.min(1,s+i)),$t(1-Math.min(1,e+i))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){let i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}},qs=class{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){O("Abstract method `_createSVG` called.")}},Jt=class extends qs{_createSVG(t){return document.createElementNS(bt,t)}},Pe=class{static setupStorage(t,e,s,i,n){let r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(let a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{let o=a.target.options,h=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){let{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(let[o,h]of Object.entries(r))if(h!=null)switch(o){case"class":h.length&&t.setAttribute(o,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,h)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){let e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});let a=n!=="richText",o=t.div;if(o.append(r),t.viewport){let d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");let h=[];if(i.children.length===0){if(i.value){let d=document.createTextNode(i.value);r.append(d),a&&Qt.shouldBuildText(i.name)&&h.push(d)}return{textDivs:h}}let c=[[i,-1,r]];for(;c.length>0;){let[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}let p=d.children[++c.at(-1)[1]];if(p===null)continue;let{name:g}=p;if(g==="#text"){let m=document.createTextNode(p.value);h.push(m),f.append(m);continue}let b=p?.attributes?.xmlns?document.createElementNS(p.attributes.xmlns,g):document.createElement(g);if(f.append(b),p.attributes&&this.setAttributes({html:b,element:p,storage:e,intent:n,linkService:s}),p.children?.length>0)c.push([p,-1,b]);else if(p.value){let m=document.createTextNode(p.value);a&&Qt.shouldBuildText(g)&&h.push(m),b.append(m)}}for(let d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}},ie=1e3,Qn=9,Pt=new WeakSet;function yt(l){return{width:l[2]-l[0],height:l[3]-l[1]}}var Ys=class{static create(t){switch(t.data.annotationType){case q.LINK:return new Re(t);case q.TEXT:return new Ks(t);case q.WIDGET:switch(t.data.fieldType){case"Tx":return new Qs(t);case"Btn":return t.data.radioButton?new Le(t):t.data.checkBox?new Zs(t):new ti(t);case"Ch":return new ei(t);case"Sig":return new Js(t)}return new _t(t);case q.POPUP:return new Zt(t);case q.FREETEXT:return new Me(t);case q.LINE:return new ii(t);case q.SQUARE:return new ni(t);case q.CIRCLE:return new ri(t);case q.POLYLINE:return new Ie(t);case q.CARET:return new oi(t);case q.INK:return new te(t);case q.POLYGON:return new ai(t);case q.HIGHLIGHT:return new De(t);case q.UNDERLINE:return new li(t);case q.SQUIGGLY:return new hi(t);case q.STRIKEOUT:return new ci(t);case q.STAMP:return new Fe(t);case q.FILEATTACHMENT:return new di(t);default:return new z(t)}}},z=class l{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!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(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return l._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};let{rect:e}=t;e&&this.#i(e),this.#s?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#i(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#i(t){let{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t);let{width:h,height:c}=yt(t);e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,i===0?(e.width=`${100*h/n}%`,e.height=`${100*c/r}%`):this.setRotation(i)}_createContainer(t){let{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof _t||(n.tabIndex=ie);let{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Zt){let{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}let{width:a,height:o}=yt(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;let g=e.borderStyle.horizontalCornerRadius,b=e.borderStyle.verticalCornerRadius;if(g>0||b>0){let _=`calc(${g}px * var(--scale-factor)) / calc(${b}px * var(--scale-factor))`;r.borderRadius=_}else if(this instanceof Le){let _=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=_}switch(e.borderStyle.style){case Ot.SOLID:r.borderStyle="solid";break;case Ot.DASHED:r.borderStyle="dashed";break;case Ot.BEVELED:M("Unimplemented border style: beveled");break;case Ot.INSET:M("Unimplemented border style: inset");break;case Ot.UNDERLINE:r.borderBottomStyle="solid";break;default:break}let m=e.borderColor||null;m?(this.#e=!0,r.borderColor=C.makeHexColor(m[0]|0,m[1]|0,m[2]|0)):r.borderWidth=0}let h=C.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:f}=i.rawDims;r.left=`${100*(h[0]-u)/c}%`,r.top=`${100*(h[1]-f)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||p===0?(r.width=`${100*a/c}%`,r.height=`${100*o/d}%`):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=yt(this.data.rect),a,o;t%180===0?(a=100*n/s,o=100*r/i):(a=100*r/s,o=100*n/i),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,s,i)=>{let n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=ke[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:ke[`${r}_rgb`](a)})};return I(this,"_commonActions",{display:e=>{let{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{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:e=>{let s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){let s=this._commonActions;for(let i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let s=this._commonActions;for(let[i,n]of Object.entries(e)){let r=s[i];if(r){let a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,s,i,n]=this.data.rect.map(g=>Math.fround(g));if(t.length===8){let[g,b,m,_]=t.subarray(2,6);if(i===g&&n===b&&e===m&&s===_)return}let{style:r}=this.container,a;if(this.#e){let{borderColor:g,borderWidth:b}=r;r.borderWidth=0,a=["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="${g}" stroke-width="${b}">`],this.container.classList.add("hasBorder")}let o=i-e,h=n-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);let u=c.createElement("defs");d.append(u);let f=c.createElement("clipPath"),p=`clippath_${this.data.id}`;f.setAttribute("id",p),f.setAttribute("clipPathUnits","objectBoundingBox"),u.append(f);for(let g=2,b=t.length;g<b;g+=8){let m=t[g],_=t[g+1],A=t[g+2],y=t[g+3],w=c.createElement("rect"),E=(A-e)/o,v=(n-_)/h,T=(m-A)/o,P=(_-y)/h;w.setAttribute("x",E),w.setAttribute("y",v),w.setAttribute("width",T),w.setAttribute("height",P),f.append(w),a?.push(`<rect vector-effect="non-scaling-stroke" x="${E}" y="${v}" width="${T}" height="${P}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{data:t}=this,e=this.#s=new Zt({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){O("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let s=[];if(this._fieldObjects){let i=this._fieldObjects[t];if(i)for(let{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;let o=typeof a=="string"?a:null,h=document.querySelector(`[data-element-id="${r}"]`);if(h&&!Pt.has(h)){M(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:h})}return s}for(let i of document.getElementsByName(t)){let{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&Pt.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}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")}_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})})}},Re=class extends z{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,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#s(s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),this.container}#t(){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.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let i of Object.keys(e.actions)){let n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){let s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){M('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();let{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){let c=new Set(n);for(let d of i){let u=this._fieldObjects[d]||[];for(let{id:f}of u)c.add(f)}for(let d of Object.values(this._fieldObjects))for(let u of d)c.has(u.id)===r&&a.push(u)}else for(let c of Object.values(this._fieldObjects))a.push(...c);let o=this.annotationStorage,h=[];for(let c of a){let{id:d}=c;switch(h.push(d),c.type){case"text":{let f=c.defaultValue||"";o.setValue(d,{value:f});break}case"checkbox":case"radiobutton":{let f=c.defaultValue===c.exportValues;o.setValue(d,{value:f});break}case"combobox":case"listbox":{let f=c.defaultValue||"";o.setValue(d,{value:f});break}default:continue}let u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!Pt.has(u)){M(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}},Ks=class extends z{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}},_t=class extends z{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Y.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){for(let[n,r]of s)(r==="Action"||this.data.actions?.[r])&&((r==="Focus"||r==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,n,r,i),r==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):r==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":C.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Qn,n=t.style,r,a=2,o=h=>Math.round(10*h)/10;if(this.data.multiLine){let h=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(h/(le*i))||1,d=h/c;r=Math.min(i,o(d/le))}else{let h=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,o(h/le))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=C.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}},Qs=class extends _t{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){let n=this.annotationStorage;for(let r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){let i=t.getValue(e,{value:this.data.fieldValue}),n=i.value||"",r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=i.formattedValue||this.data.textContent?.join(`
|
|
3
|
+
`)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=a??n,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",a??n),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Pt.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=ie,this._setRequired(s,this.data.required),r&&(s.maxLength=r),s.addEventListener("input",c=>{t.setValue(e,{value:c.target.value}),this.setPropertyOnSiblings(s,"value",c.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",c=>{let d=this.data.defaultFieldValue??"";s.value=o.userValue=d,o.formattedValue=null});let h=c=>{let{formattedValue:d}=o;d!=null&&(c.target.value=d),c.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",d=>{if(o.focused)return;let{target:u}=d;o.userValue&&(u.value=o.userValue),o.lastCommittedValue=u.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),s.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target);let u={value(f){o.userValue=f.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),f.target.value=o.userValue},formattedValue(f){let{formattedValue:p}=f.detail;o.formattedValue=p,p!=null&&f.target!==document.activeElement&&(f.target.value=p),t.setValue(e,{formattedValue:p})},selRange(f){f.target.setSelectionRange(...f.detail.selRange)},charLimit:f=>{let{charLimit:p}=f.detail,{target:g}=f;if(p===0){g.removeAttribute("maxLength");return}g.setAttribute("maxLength",p);let b=o.userValue;!b||b.length<=p||(b=b.slice(0,p),g.value=o.userValue=b,t.setValue(e,{value:b}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:1,selStart:g.selectionStart,selEnd:g.selectionEnd}}))}};this._dispatchEventFromSandbox(u,d)}),s.addEventListener("keydown",d=>{o.commitKey=1;let u=-1;if(d.key==="Escape"?u=0:d.key==="Enter"&&!this.data.multiLine?u=2:d.key==="Tab"&&(o.commitKey=3),u===-1)return;let{value:f}=d.target;o.lastCommittedValue!==f&&(o.lastCommittedValue=f,o.userValue=f,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,willCommit:!0,commitKey:u,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});let c=h;h=null,s.addEventListener("blur",d=>{if(!o.focused||!d.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{value:u}=d.target;o.userValue=u,o.lastCommittedValue!==u&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:u,willCommit:!0,commitKey:o.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),c(d)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",d=>{o.lastCommittedValue=null;let{data:u,target:f}=d,{value:p,selectionStart:g,selectionEnd:b}=f,m=g,_=b;switch(d.inputType){case"deleteWordBackward":{let A=p.substring(0,g).match(/\w*[^\w]*$/);A&&(m-=A[0].length);break}case"deleteWordForward":{let A=p.substring(g).match(/^[^\w]*\w*/);A&&(_+=A[0].length);break}case"deleteContentBackward":g===b&&(m-=1);break;case"deleteContentForward":g===b&&(_+=1);break}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,change:u||"",willCommit:!1,selStart:m,selEnd:_}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(h&&s.addEventListener("blur",h),this.data.comb){let d=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.letterSpacing=`calc(${d}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}},Js=class extends _t{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}},Zs=class extends _t{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,s=e.id,i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let n=document.createElement("input");return Pt.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=ie,n.addEventListener("change",r=>{let{name:a,checked:o}=r.target;for(let h of this._getElementsByName(a,s)){let c=o&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{let a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{let a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},Le=class extends _t{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,s=e.id,i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(let r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});let n=document.createElement("input");if(Pt.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=ie,n.addEventListener("change",r=>{let{name:a,checked:o}=r.target;for(let h of this._getElementsByName(a,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{let a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){let r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{let o={value:h=>{let c=r===h.detail.value;for(let d of this._getElementsByName(h.target.name)){let u=c&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},ti=class extends Re{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",s=>{this._dispatchEventFromSandbox({},s)})),t}},ei=class extends _t{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Pt.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=ie;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",c=>{let d=this.data.defaultFieldValue;for(let u of i.options)u.selected=u.value===d});for(let c of this.data.options){let d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,s.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){let c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),r=()=>{c.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}let a=c=>{let d=c?"value":"textContent",{options:u,multiple:f}=i;return f?Array.prototype.filter.call(u,p=>p.selected).map(p=>p[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]},o=a(!1),h=c=>{let d=c.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{let d={value(u){r?.();let f=u.detail.value,p=new Set(Array.isArray(f)?f:[f]);for(let g of i.options)g.selected=p.has(g.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(u){i.multiple=!0},remove(u){let f=i.options,p=u.detail.remove;f[p].selected=!1,i.remove(p),f.length>0&&Array.prototype.findIndex.call(f,b=>b.selected)===-1&&(f[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},clear(u){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(u){let{index:f,displayValue:p,exportValue:g}=u.detail.insert,b=i.children[f],m=document.createElement("option");m.textContent=p,m.value=g,b?b.before(m):i.append(m),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},items(u){let{items:f}=u.detail;for(;i.length!==0;)i.remove(0);for(let p of f){let{displayValue:g,exportValue:b}=p,m=document.createElement("option");m.textContent=g,m.value=b,i.append(m)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},indices(u){let f=new Set(u.detail.indices);for(let p of u.target.options)p.selected=f.has(p.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.addEventListener("input",c=>{let d=a(!0),u=a(!1);t.setValue(e,{value:d}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):i.addEventListener("input",function(c){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},Zt=class extends z{constructor(t){let{data:e,elements:s}=t;super(t,{isRenderable:z._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");let t=this.popup=new si({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 s of this.elements)s.popup=t,s.container.ariaHasPopup="dialog",e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${xi}${s}`).join(",")),this.container}},si=class{#t=this.#T.bind(this);#e=this.#C.bind(this);#s=this.#k.bind(this);#i=this.#v.bind(this);#r=null;#n=null;#l=null;#o=null;#c=null;#h=null;#u=null;#d=!1;#f=null;#a=null;#p=null;#m=null;#g=null;#b=null;#y=!1;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:h,parentRect:c,open:d}){this.#n=t,this.#g=i,this.#l=r,this.#m=a,this.#h=o,this.#r=e,this.#p=h,this.#u=c,this.#c=s,this.#o=ue.toDateObject(n),this.trigger=s.flatMap(u=>u.getElementsToTriggerPopup());for(let u of this.trigger)u.addEventListener("click",this.#i),u.addEventListener("mouseenter",this.#s),u.addEventListener("mouseleave",this.#e),u.classList.add("popupTriggerArea");for(let u of s)u.container?.addEventListener("keydown",this.#t);this.#n.hidden=!0,d&&this.#v()}render(){if(this.#f)return;let t=this.#f=document.createElement("div");if(t.className="popup",this.#r){let n=t.style.outlineColor=C.makeHexColor(...this.#r);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=C.makeHexColor(...this.#r.map(a=>Math.floor(.7*(255-a)+a)))}let e=document.createElement("span");e.className="header";let s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=this.#g,t.append(e),this.#o){let n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),n.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#o.valueOf()})),e.append(n)}let i=this.#_;if(i)Pe.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{let n=this._formatContents(this.#l);t.append(n)}this.#n.append(t)}get#_(){let t=this.#m,e=this.#l;return t?.str&&(!e?.str||e.str===t.str)&&this.#m.html||null}get#w(){return this.#_?.attributes?.style?.fontSize||0}get#E(){return this.#_?.attributes?.style?.color||null}#x(t){let e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#E,fontSize:this.#w?`calc(${this.#w}px * var(--scale-factor))`:""}};for(let n of t.split(`
|
|
4
|
+
`))e.push({name:"span",value:n,attributes:i});return s}_formatContents({str:t,dir:e}){let s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;let i=t.split(/(?:\r\n?|\n)/);for(let n=0,r=i.length;n<r;++n){let a=i[n];s.append(document.createTextNode(a)),n<r-1&&s.append(document.createElement("br"))}return s}#T(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#d)&&this.#v()}updateEdited({rect:t,popupContent:e}){this.#b||={contentsObj:this.#l,richText:this.#m},t&&(this.#a=null),e&&(this.#m=this.#x(e),this.#l=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#b&&({contentsObj:this.#l,richText:this.#m}=this.#b,this.#b=null,this.#f?.remove(),this.#f=null,this.#a=null)}#P(){if(this.#a!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#h,r=!!this.#u,a=r?this.#u:this.#p;for(let p of this.#c)if(!a||C.intersect(p.data.rect,a)!==null){a=p.data.rect,r=!0;break}let o=C.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),c=r?a[2]-a[0]+5:0,d=o[0]+c,u=o[1];this.#a=[100*(d-i)/e,100*(u-n)/s];let{style:f}=this.#n;f.left=`${this.#a[0]}%`,f.top=`${this.#a[1]}%`}#v(){this.#d=!this.#d,this.#d?(this.#k(),this.#n.addEventListener("click",this.#i),this.#n.addEventListener("keydown",this.#t)):(this.#C(),this.#n.removeEventListener("click",this.#i),this.#n.removeEventListener("keydown",this.#t))}#k(){this.#f||this.render(),this.isVisible?this.#d&&this.#n.classList.add("focused"):(this.#P(),this.#n.hidden=!1,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)+1e3)}#C(){this.#n.classList.remove("focused"),!(this.#d||!this.isVisible)&&(this.#n.hidden=!0,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)-1e3)}forceHide(){this.#y=this.isVisible,this.#y&&(this.#n.hidden=!0)}maybeShow(){this.#y&&(this.#f||this.#k(),this.#y=!1,this.#n.hidden=!1)}get isVisible(){return this.#n.hidden===!1}},Me=class extends z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=L.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},ii=class extends z{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let t=this.data,{width:e,height:s}=yt(t.rect),i=this.svgFactory.create(e,s,!0),n=this.#t=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ni=class extends z{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let t=this.data,{width:e,height:s}=yt(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ri=class extends z{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let t=this.data,{width:e,height:s}=yt(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Ie=class extends z{#t=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:s,popupRef:i}}=this;if(!e)return this.container;let{width:n,height:r}=yt(t),a=this.svgFactory.create(n,r,!0),o=[];for(let c=0,d=e.length;c<d;c+=2){let u=e[c]-t[0],f=t[3]-e[c+1];o.push(`${u},${f}`)}o=o.join(" ");let h=this.#t=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",o),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),a.append(h),this.container.append(a),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ai=class extends Ie{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},oi=class extends z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},te=class extends z{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?L.HIGHLIGHT:L.INK}#s(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#s(e,t),h=this.svgFactory.create(a,o,!0),c=this.#t=this.svgFactory.createElement("svg:g");h.append(c),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),c.setAttribute("stroke-miterlimit",10),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),c.setAttribute("transform",r);for(let d=0,u=s.length;d<u;d++){let f=this.svgFactory.createElement(this.svgElementName);this.#e.push(f),f.setAttribute("points",s[d].join(",")),c.append(f)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:s,rect:i}=t,n=this.#t;if(e>=0&&n.setAttribute("stroke-width",e||1),s)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",s[r].join(","));if(i){let{transform:r,width:a,height:o}=this.#s(this.data.rotation,i);n.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),n.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},De=class extends z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=L.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}},li=class extends z{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}},hi=class extends z{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}},ci=class extends z{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}},Fe=class extends z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=L.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},di=class extends z{#t=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(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;let{isMac:i}=Y.platform;return t.addEventListener("keydown",n=>{n.key==="Enter"&&(i?n.metaKey:n.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},ui=class{#t=null;#e=null;#s=new Map;#i=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r,structTreeLayer:a}){this.div=t,this.#t=e,this.#e=s,this.#i=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return this.#s.size>0}async#r(t,e){let s=t.firstChild||t,i=s.id=`${xi}${e}`,n=await this.#i?.getAriaAttributes(i);if(n)for(let[r,a]of n)s.setAttribute(r,a);this.div.append(t),this.#t?.moveElementInDOM(this.div,t,s,!1)}async render(t){let{annotations:e}=t,s=this.div;Ct(s,this.viewport);let i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Jt,annotationStorage:t.annotationStorage||new qt,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let r of e){if(r.noHTML)continue;let a=r.annotationType===q.POPUP;if(a){let c=i.get(r.id);if(!c)continue;n.elements=c}else{let{width:c,height:d}=yt(r.rect);if(c<=0||d<=0)continue}n.data=r;let o=Ys.create(n);if(!o.isRenderable)continue;if(!a&&r.popupRef){let c=i.get(r.popupRef);c?c.push(o):i.set(r.popupRef,[o])}let h=o.render();r.hidden&&(h.style.visibility="hidden"),await this.#r(h,r.id),o._isEditable&&(this.#s.set(o.data.id,o),this._annotationEditorUIManager?.renderAnnotationElement(o))}this.#n()}update({viewport:t}){let e=this.div;this.viewport=t,Ct(e,{rotation:t.rotation}),this.#n(),e.hidden=!1}#n(){if(!this.#e)return;let t=this.div;for(let[e,s]of this.#e){let i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";let{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#s.values())}getEditableAnnotation(t){return this.#s.get(t)}},oe=/\r\n?|\n/g,fi=class l extends U{#t;#e="";#s=`${this.id}-editor`;#i=null;#r;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=l.prototype,e=n=>n.isEmpty(),s=kt.TRANSLATE_SMALL,i=kt.TRANSLATE_BIG;return I(this,"_keyboardManager",new Tt([[["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:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=L.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||l._defaultColor||U._defaultLineColor,this.#r=t.fontSize||l._defaultFontSize}static initialize(t,e){U.initialize(t,e);let s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case F.FREETEXT_SIZE:l._defaultFontSize=e;break;case F.FREETEXT_COLOR:l._defaultColor=e;break}}updateParams(t,e){switch(t){case F.FREETEXT_SIZE:this.#n(e);break;case F.FREETEXT_COLOR:this.#l(e);break}}static get defaultPropertiesToUpdate(){return[[F.FREETEXT_SIZE,l._defaultFontSize],[F.FREETEXT_COLOR,l._defaultColor||U._defaultLineColor]]}get propertiesToUpdate(){return[[F.FREETEXT_SIZE,this.#r],[F.FREETEXT_COLOR,this.#t]]}#n(t){let e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--scale-factor))`,this.translate(0,-(i-this.#r)*this.parentScale),this.#r=i,this.#c()},s=this.#r;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(t){let e=i=>{this.#t=this.editorDiv.style.color=i},s=this.#t;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-l._internalPadding*t,-(l._internalPadding+this.#r)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(L.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#i=new AbortController;let t=this._uiManager.combinedSignal(this.#i);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{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.#s),this._isDraggable=!0,this.#i?.abort(),this.#i=null,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(t){this.width||(this.enableEditMode(),t&&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()}#o(){let t=[];this.editorDiv.normalize();let e=null;for(let s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"||(t.push(l.#h(s)),e=s);return t.join(`
|
|
5
|
+
`)}#c(){let[t,e]=this.parentDimensions,s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{let{currentLayer:i,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",i.div.append(this.div),s=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#e,e=this.#e=this.#o().trimEnd();if(t===e)return;let s=i=>{if(this.#e=i,!i){this.remove();return}this.#u(),this._uiManager.rebuild(this),this.#c()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#c()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){l._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(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#s),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#r}px * var(--scale-factor))`,s.color=this.#t,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),fe(this,this.div,["dblclick","keydown"]),this.width){let[i,n]=this.parentDimensions;if(this.annotationElementId){let{position:r}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[h,c]=this.pageDimensions,[d,u]=this.pageTranslation,f,p;switch(this.rotation){case 0:f=t+(r[0]-d)/h,p=e+this.height-(r[1]-u)/c;break;case 90:f=t+(r[0]-d)/h,p=e-(r[1]-u)/c,[a,o]=[o,-a];break;case 180:f=t-this.width+(r[0]-d)/h,p=e-(r[1]-u)/c,[a,o]=[-a,-o];break;case 270:f=t+(r[0]-d-this.height*c)/h,p=e+(r[1]-u-this.width*h)/c,[a,o]=[-o,a];break}this.setAt(f*i,p*n,a,o)}else this.setAt(t*i,e*n,this.width*i,this.height*n);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#h(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(oe,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();let i=l.#f(e.getData("text")||"").replaceAll(oe,`
|
|
6
|
+
`);if(!i)return;let n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();let r=n.getRangeAt(0);if(!i.includes(`
|
|
7
|
+
`)){r.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),n.collapseToStart();return}let{startContainer:a,startOffset:o}=r,h=[],c=[];if(a.nodeType===Node.TEXT_NODE){let f=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(oe,"")),f!==this.editorDiv){let p=h;for(let g of this.editorDiv.childNodes){if(g===f){p=c;continue}p.push(l.#h(g))}}h.push(a.nodeValue.slice(0,o).replaceAll(oe,""))}else if(a===this.editorDiv){let f=h,p=0;for(let g of this.editorDiv.childNodes)p++===o&&(f=c),f.push(l.#h(g))}this.#e=`${h.join(`
|
|
8
|
+
`)}${i}${c.join(`
|
|
9
|
+
`)}`,this.#u();let d=new Range,u=h.reduce((f,p)=>f+p.length,0);for(let{firstChild:f}of this.editorDiv.childNodes)if(f.nodeType===Node.TEXT_NODE){let p=f.nodeValue.length;if(u<=p){d.setStart(f,u),d.setEnd(f,u);break}u-=p}n.removeAllRanges(),n.addRange(d)}#u(){if(this.editorDiv.replaceChildren(),!!this.#e)for(let t of this.#e.split(`
|
|
10
|
+
`)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#d(){return this.#e.replaceAll("\xA0"," ")}static#f(t){return t.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,s){let i=null;if(t instanceof Me){let{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:h,id:c,popupRef:d},textContent:u,textPosition:f,parent:{page:{pageNumber:p}}}=t;if(!u||u.length===0)return null;i=t={annotationType:L.FREETEXT,color:Array.from(a),fontSize:r,value:u.join(`
|
|
11
|
+
`),position:f,pageIndex:p-1,rect:o.slice(0),rotation:h,id:c,deleted:!1,popupRef:d}}let n=await super.deserialize(t,e,s);return n.#r=t.fontSize,n.#t=C.makeHexColor(...t.color),n.#e=l.#f(t.value),n.annotationElementId=t.id||null,n._initialData=i,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=l._internalPadding*this.parentScale,s=this.getRect(e,e),i=U._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#t),n={annotationType:L.FREETEXT,color:i,fontSize:this.#r,value:this.#d(),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#a(n)?null:(n.id=this.annotationElementId,n)}#a(t){let{value:e,fontSize:s,color:i,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==i[a])||t.pageIndex!==n}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(this.deleted)return e;let{style:s}=e;s.fontSize=`calc(${this.#r}px * var(--scale-factor))`,s.color=this.#t,e.replaceChildren();for(let n of this.#e.split(`
|
|
12
|
+
`)){let r=document.createElement("div");r.append(n?document.createTextNode(n):document.createElement("br")),e.append(r)}let i=l._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#e}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}},S=class{static PRECISION=1e-4;toSVGPath(){O("Abstract method `toSVGPath` must be implemented.")}get box(){O("Abstract getter `box` must be implemented.")}serialize(t,e){O("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}static _rescaleAndSwap(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,i,n,r){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+r)/6,(s+n)/2,(i+r)/2]}},Ne=class l{#t;#e=[];#s;#i;#r=[];#n=new Float32Array(18);#l;#o;#c;#h;#u;#d;#f=[];static#a=8;static#p=2;static#m=l.#a+l.#p;constructor({x:t,y:e},s,i,n,r,a=0){this.#t=s,this.#d=n*i,this.#i=r,this.#n.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#h=l.#a*i,this.#c=l.#m*i,this.#u=i,this.#f.push(t,e)}isEmpty(){return isNaN(this.#n[8])}#g(){let t=this.#n.subarray(4,6),e=this.#n.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#l+(t[0]-e[0])/2-s)/n,(this.#o+(t[1]-e[1])/2-i)/r,(this.#l+(e[0]-t[0])/2-s)/n,(this.#o+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#l=t,this.#o=e;let[s,i,n,r]=this.#t,[a,o,h,c]=this.#n.subarray(8,12),d=t-h,u=e-c,f=Math.hypot(d,u);if(f<this.#c)return!1;let p=f-this.#h,g=p/f,b=g*d,m=g*u,_=a,A=o;a=h,o=c,h+=b,c+=m,this.#f?.push(t,e);let y=-m/p,w=b/p,E=y*this.#d,v=w*this.#d;return this.#n.set(this.#n.subarray(2,8),0),this.#n.set([h+E,c+v],4),this.#n.set(this.#n.subarray(14,18),12),this.#n.set([h-E,c-v],16),isNaN(this.#n[6])?(this.#r.length===0&&(this.#n.set([a+E,o+v],2),this.#r.push(NaN,NaN,NaN,NaN,(a+E-s)/n,(o+v-i)/r),this.#n.set([a-E,o-v],14),this.#e.push(NaN,NaN,NaN,NaN,(a-E-s)/n,(o-v-i)/r)),this.#n.set([_,A,a,o,h,c],6),!this.isEmpty()):(this.#n.set([_,A,a,o,h,c],6),Math.abs(Math.atan2(A-o,_-a)-Math.atan2(m,b))<Math.PI/2?([a,o,h,c]=this.#n.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((a+h)/2-s)/n,((o+c)/2-i)/r),[a,o,_,A]=this.#n.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((_+a)/2-s)/n,((A+o)/2-i)/r),!0):([_,A,a,o,h,c]=this.#n.subarray(0,6),this.#r.push(((_+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),[h,c,a,o,_,A]=this.#n.subarray(12,18),this.#e.push(((_+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";let t=this.#r,e=this.#e;if(isNaN(this.#n[6])&&!this.isEmpty())return this.#b();let s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#_(s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#y(s),s.join(" ")}#b(){let[t,e,s,i]=this.#t,[n,r,a,o]=this.#g();return`M${(this.#n[2]-t)/s} ${(this.#n[3]-e)/i} L${(this.#n[4]-t)/s} ${(this.#n[5]-e)/i} L${n} ${r} L${a} ${o} L${(this.#n[16]-t)/s} ${(this.#n[17]-e)/i} L${(this.#n[14]-t)/s} ${(this.#n[15]-e)/i} Z`}#y(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#_(t){let[e,s,i,n]=this.#t,r=this.#n.subarray(4,6),a=this.#n.subarray(16,18),[o,h,c,d]=this.#g();t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${o} ${h} L${c} ${d} L${(a[0]-e)/i} ${(a[1]-s)/n}`)}newFreeDrawOutline(t,e,s,i,n,r){return new Oe(t,e,s,i,n,r)}getOutlines(){let t=this.#r,e=this.#e,s=this.#n,[i,n,r,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let d=0,u=o.length-2;d<u;d+=2)o[d]=(this.#f[d]-i)/r,o[d+1]=(this.#f[d+1]-n)/a;if(o[o.length-2]=(this.#l-i)/r,o[o.length-1]=(this.#o-n)/a,isNaN(s[6])&&!this.isEmpty())return this.#w(o);let h=new Float32Array(this.#r.length+24+this.#e.length),c=t.length;for(let d=0;d<c;d+=2){if(isNaN(t[d])){h[d]=h[d+1]=NaN;continue}h[d]=t[d],h[d+1]=t[d+1]}c=this.#x(h,c);for(let d=e.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2){if(isNaN(e[d+u])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[d+u],h[c+1]=e[d+u+1],c+=2}return this.#E(h,c),this.newFreeDrawOutline(h,o,this.#t,this.#u,this.#s,this.#i)}#w(t){let e=this.#n,[s,i,n,r]=this.#t,[a,o,h,c]=this.#g(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(d,t,this.#t,this.#u,this.#s,this.#i)}#E(t,e){let s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#x(t,e){let s=this.#n.subarray(4,6),i=this.#n.subarray(16,18),[n,r,a,o]=this.#t,[h,c,d,u]=this.#g();return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o],e),e+=24}},Oe=class extends S{#t;#e=new Float32Array(4);#s;#i;#r;#n;#l;constructor(t,e,s,i,n,r){super(),this.#l=t,this.#r=e,this.#t=s,this.#n=i,this.#s=n,this.#i=r,this.lastPoint=[NaN,NaN],this.#o(r);let[a,o,h,c]=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/h,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/h,e[d+1]=(e[d+1]-o)/c}toSVGPath(){let t=[`M${this.#l[4]} ${this.#l[5]}`];for(let e=6,s=this.#l.length;e<s;e+=6){if(isNaN(this.#l[e])){t.push(`L${this.#l[e+4]} ${this.#l[e+5]}`);continue}t.push(`C${this.#l[e]} ${this.#l[e+1]} ${this.#l[e+2]} ${this.#l[e+3]} ${this.#l[e+4]} ${this.#l[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){let r=s-t,a=i-e,o,h;switch(n){case 0:o=S._rescale(this.#l,t,i,r,-a),h=S._rescale(this.#r,t,i,r,-a);break;case 90:o=S._rescaleAndSwap(this.#l,t,e,r,a),h=S._rescaleAndSwap(this.#r,t,e,r,a);break;case 180:o=S._rescale(this.#l,s,e,-r,a),h=S._rescale(this.#r,s,e,-r,a);break;case 270:o=S._rescaleAndSwap(this.#l,s,i,-r,-a),h=S._rescaleAndSwap(this.#r,s,i,-r,-a);break}return{outline:Array.from(o),points:[Array.from(h)]}}#o(t){let e=this.#l,s=e[4],i=e[5],n=s,r=i,a=s,o=i,h=s,c=i,d=t?Math.max:Math.min;for(let f=6,p=e.length;f<p;f+=6){if(isNaN(e[f]))n=Math.min(n,e[f+4]),r=Math.min(r,e[f+5]),a=Math.max(a,e[f+4]),o=Math.max(o,e[f+5]),c<e[f+5]?(h=e[f+4],c=e[f+5]):c===e[f+5]&&(h=d(h,e[f+4]));else{let g=C.bezierBoundingBox(s,i,...e.slice(f,f+6));n=Math.min(n,g[0]),r=Math.min(r,g[1]),a=Math.max(a,g[2]),o=Math.max(o,g[3]),c<g[3]?(h=g[2],c=g[3]):c===g[3]&&(h=d(h,g[2]))}s=e[f+4],i=e[f+5]}let u=this.#e;u[0]=n-this.#s,u[1]=r-this.#s,u[2]=a-n+2*this.#s,u[3]=o-r+2*this.#s,this.lastPoint=[h,c]}get box(){return this.#e}newOutliner(t,e,s,i,n,r=0){return new Ne(t,e,s,i,n,r)}getNewOutline(t,e){let[s,i,n,r]=this.#e,[a,o,h,c]=this.#t,d=n*h,u=r*c,f=s*h+a,p=i*c+o,g=this.newOutliner({x:this.#r[0]*d+f,y:this.#r[1]*u+p},this.#t,this.#n,t,this.#i,e??this.#s);for(let b=2;b<this.#r.length;b+=2)g.add({x:this.#r[b]*d+f,y:this.#r[b+1]*u+p});return g.getOutlines()}},ee=class{#t;#e;#s=[];#i=[];constructor(t,e=0,s=0,i=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0,c=10**-4;for(let{x:m,y:_,width:A,height:y}of t){let w=Math.floor((m-e)/c)*c,E=Math.ceil((m+A+e)/c)*c,v=Math.floor((_-e)/c)*c,T=Math.ceil((_+y+e)/c)*c,P=[w,v,T,!0],N=[E,v,T,!1];this.#s.push(P,N),n=Math.min(n,w),r=Math.max(r,E),a=Math.min(a,v),o=Math.max(o,T)}let d=r-n+2*s,u=o-a+2*s,f=n-s,p=a-s,g=this.#s.at(i?-1:-2),b=[g[0],g[2]];for(let m of this.#s){let[_,A,y]=m;m[0]=(_-f)/d,m[1]=(A-p)/u,m[2]=(y-p)/u}this.#t=new Float32Array([f,p,d,u]),this.#e=b}getOutlines(){this.#s.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);let t=[];for(let e of this.#s)e[3]?(t.push(...this.#c(e)),this.#l(e)):(this.#o(e),t.push(...this.#c(e)));return this.#r(t)}#r(t){let e=[],s=new Set;for(let r of t){let[a,o,h]=r;e.push([a,o,r],[a,h,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){let o=e[r][2],h=e[r+1][2];o.push(h),h.push(o),s.add(o),s.add(h)}let i=[],n;for(;s.size>0;){let r=s.values().next().value,[a,o,h,c,d]=r;s.delete(r);let u=a,f=o;for(n=[a,h],i.push(n);;){let p;if(s.has(c))p=c;else if(s.has(d))p=d;else break;s.delete(p),[a,o,h,c,d]=p,u!==a&&(n.push(u,f,a,f===o?o:h),u=a),f=f===o?h:o}n.push(u,f)}return new pi(i,this.#t,this.#e)}#n(t){let e=this.#i,s=0,i=e.length-1;for(;s<=i;){let n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1}#l([,t,e]){let s=this.#n(t);this.#i.splice(s,0,[t,e])}#o([,t,e]){let s=this.#n(t);for(let i=s;i<this.#i.length;i++){let[n,r]=this.#i[i];if(n!==t)break;if(n===t&&r===e){this.#i.splice(i,1);return}}for(let i=s-1;i>=0;i--){let[n,r]=this.#i[i];if(n!==t)break;if(n===t&&r===e){this.#i.splice(i,1);return}}}#c(t){let[e,s,i]=t,n=[[e,s,i]],r=this.#n(i);for(let a=0;a<r;a++){let[o,h]=this.#i[a];for(let c=0,d=n.length;c<d;c++){let[,u,f]=n[c];if(!(h<=u||f<=o)){if(u>=o){if(f>h)n[c][1]=h;else{if(d===1)return[];n.splice(c,1),c--,d--}continue}n[c][2]=o,f>h&&n.push([e,h,f])}}}return n}},pi=class extends S{#t;#e;constructor(t,e,s){super(),this.#e=t,this.#t=e,this.lastPoint=s}toSVGPath(){let t=[];for(let e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){let r=e[n],a=e[n+1];r===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${r}`),s=r)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){let r=[],a=s-t,o=i-e;for(let h of this.#e){let c=new Array(h.length);for(let d=0;d<h.length;d+=2)c[d]=t+h[d]*a,c[d+1]=i-h[d+1]*o;r.push(c)}return r}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}},se=class extends Ne{newFreeDrawOutline(t,e,s,i,n,r){return new gi(t,e,s,i,n,r)}},gi=class extends Oe{newOutliner(t,e,s,i,n,r=0){return new se(t,e,s,i,n,r)}},Be=class l{#t=null;#e=null;#s;#i=null;#r=!1;#n=!1;#l=null;#o;#c=null;#h=null;#u;static#d=null;static get _keyboardManager(){return I(this,"_keyboardManager",new Tt([[["Escape","mac+Escape"],l.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],l.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],l.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],l.prototype._moveToPrevious],[["Home","mac+Home"],l.prototype._moveToBeginning],[["End","mac+End"],l.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#n=!1,this.#u=F.HIGHLIGHT_COLOR,this.#l=t):(this.#n=!0,this.#u=F.HIGHLIGHT_DEFAULT_COLOR),this.#h=t?._uiManager||e,this.#o=this.#h._eventBus,this.#s=t?.color||this.#h?.highlightColors.values().next().value||"#FFFF98",l.#d||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#t=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.#h._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});let s=this.#e=document.createElement("span");return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=this.#s,t.append(s),t}renderMainDropdown(){let t=this.#i=this.#f();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#f(){let t=document.createElement("div"),e=this.#h._signal;t.addEventListener("contextmenu",dt,{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");for(let[s,i]of this.#h.highlightColors){let n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",l.#d[s]);let r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===this.#s),n.addEventListener("click",this.#a.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#a(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:this.#u,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}let e=t.target.getAttribute("data-color");e&&this.#a(e,t)}_moveToNext(t){if(!this.#b){this.#m(t);return}if(t.target===this.#t){this.#i.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstChild||t.target===this.#t){this.#b&&this._hideDropdownFromKeyboard();return}this.#b||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#b){this.#m(t);return}this.#i.firstChild?.focus()}_moveToEnd(t){if(!this.#b){this.#m(t);return}this.#i.lastChild?.focus()}#p(t){l._keyboardManager.exec(this,t)}#m(t){if(this.#b){this.hideDropdown();return}if(this.#r=t.detail===0,this.#c||(this.#c=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#h.combinedSignal(this.#c)})),this.#i){this.#i.classList.remove("hidden");return}let e=this.#i=this.#f();this.#t.append(e)}#g(t){this.#i?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),this.#c?.abort(),this.#c=null}get#b(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#n){if(!this.#b){this.#l?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#r})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#i)return;let e=this.#h.highlightColors.values();for(let s of this.#i.children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i?.remove(),this.#i=null}},He=class l extends U{#t=null;#e=0;#s;#i=null;#r=null;#n=null;#l=null;#o=0;#c=null;#h=null;#u=null;#d=!1;#f=null;#a;#p=null;#m="";#g;#b="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=L.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=l.prototype;return I(this,"_keyboardManager",new Tt([[["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||l._defaultColor,this.#g=t.thickness||l._defaultThickness,this.#a=t.opacity||l._defaultOpacity,this.#s=t.boxes||null,this.#b=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#d=!0,this.#_(t),this.#P()):this.#s&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#l=t.focusNode,this.#o=t.focusOffset,this.#y(),this.#P(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#b}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#y(){let t=new ee(this.#s,.001);this.#h=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#h.box;let e=new ee(this.#s,.0025,.001,this._uiManager.direction==="ltr");this.#n=e.getOutlines();let{lastPoint:s}=this.#n;this.#f=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#_({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#h=t;let i=1.5;if(this.#n=t.getNewOutline(this.#g/2+i,.0025),e>=0)this.#u=e,this.#i=s,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#n.box,path:{d:this.#n.toSVGPath()}},!0);else if(this.parent){let c=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:l.#v(this.#h.box,(c-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:l.#v(this.#n.box,c),path:{d:this.#n.toSVGPath()}})}let[n,r,a,o]=t.box;switch(this.rotation){case 0:this.x=n,this.y=r,this.width=a,this.height=o;break;case 90:{let[c,d]=this.parentDimensions;this.x=r,this.y=1-n,this.width=a*d/c,this.height=o*c/d;break}case 180:this.x=1-n,this.y=1-r,this.width=a,this.height=o;break;case 270:{let[c,d]=this.parentDimensions;this.x=1-r,this.y=n,this.width=a*d/c,this.height=o*c/d;break}}let{lastPoint:h}=this.#n;this.#f=[(h[0]-n)/a,(h[1]-r)/o]}static initialize(t,e){U.initialize(t,e),l._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case F.HIGHLIGHT_DEFAULT_COLOR:l._defaultColor=e;break;case F.HIGHLIGHT_THICKNESS:l._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#f}updateParams(t,e){switch(t){case F.HIGHLIGHT_COLOR:this.#w(e);break;case F.HIGHLIGHT_THICKNESS:this.#E(e);break}}static get defaultPropertiesToUpdate(){return[[F.HIGHLIGHT_DEFAULT_COLOR,l._defaultColor],[F.HIGHLIGHT_THICKNESS,l._defaultThickness]]}get propertiesToUpdate(){return[[F.HIGHLIGHT_COLOR,this.color||l._defaultColor],[F.HIGHLIGHT_THICKNESS,this.#g||l._defaultThickness],[F.HIGHLIGHT_FREE,this.#d]]}#w(t){let e=(n,r)=>{this.color=n,this.#a=r,this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:n,"fill-opacity":r}}),this.#r?.updateColor(n)},s=this.color,i=this.#a;this.addCommands({cmd:e.bind(this,t,l._defaultOpacity),undo:e.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#E(t){let e=this.#g,s=i=>{this.#g=i,this.#x(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.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.#r=new Be({editor:this}),t.addColorPicker(this.#r)),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.#L())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#L())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#T(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#P(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#T():t&&(this.#P(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#x(t){if(!this.#d)return;this.#_({highlightOutlines:this.#h.getNewOutline(t/2)}),this.fixAndSetPosition();let[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}#T(){this.#u===null||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#P(t=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#i}=t.drawLayer.draw({bbox:this.#h.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#a},rootClass:{highlight:!0,free:this.#d},path:{d:this.#h.toSVGPath()}},!1,!0),this.#p=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#n.box,path:{d:this.#n.toSVGPath()}},this.#d),this.#c&&(this.#c.style.clipPath=this.#i))}static#v([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}rotate(t){let{drawLayer:e}=this.parent,s;this.#d?(t=(t-this.rotation+360)%360,s=l.#v(this.#h.box,t)):s=l.#v([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#u,{bbox:s,root:{"data-main-rotation":t}}),e.updateProperties(this.#p,{bbox:l.#v(this.#n.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#m&&(t.setAttribute("aria-label",this.#m),t.setAttribute("role","mark")),this.#d?t.classList.add("free"):this.div.addEventListener("keydown",this.#k.bind(this),{signal:this._uiManager._signal});let e=this.#c=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#i;let[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),fe(this,this.#c,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#k(t){l._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#C(!0);break;case 1:case 3:this.#C(!1);break}}#C(t){if(!this.#t)return;let e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#l,this.#o)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#d||this.#C(!1))}get _mustFixPosition(){return!this.#d}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!t}}))}#L(){return this.#d?this.rotation:0}#D(){if(this.#d)return null;let[t,e]=this.pageDimensions,[s,i]=this.pageTranslation,n=this.#s,r=new Float32Array(n.length*8),a=0;for(let{x:o,y:h,width:c,height:d}of n){let u=o*t+s,f=(1-h)*e+i;r[a]=r[a+4]=u,r[a+1]=r[a+3]=f,r[a+2]=r[a+6]=u+c*t,r[a+5]=r[a+7]=f-d*e,a+=8}return r}#N(t){return this.#h.serialize(t,this.#L())}static startHighlighting(t,e,{target:s,x:i,y:n}){let{x:r,y:a,width:o,height:h}=s.getBoundingClientRect(),c=new AbortController,d=t.combinedSignal(c),u=f=>{c.abort(),this.#A(t,f)};window.addEventListener("blur",u,{signal:d}),window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("pointerdown",ot,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",dt,{signal:d}),s.addEventListener("pointermove",this.#S.bind(this,t),{signal:d}),this._freeHighlight=new se({x:i,y:n},[r,a,o,h],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#S(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#A(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(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 async deserialize(t,e,s){let i=null;if(t instanceof De){let{data:{quadPoints:p,rect:g,rotation:b,id:m,color:_,opacity:A,popupRef:y},parent:{page:{pageNumber:w}}}=t;i=t={annotationType:L.HIGHLIGHT,color:Array.from(_),opacity:A,quadPoints:p,boxes:null,pageIndex:w-1,rect:g.slice(0),rotation:b,id:m,deleted:!1,popupRef:y}}else if(t instanceof te){let{data:{inkLists:p,rect:g,rotation:b,id:m,color:_,borderStyle:{rawWidth:A},popupRef:y},parent:{page:{pageNumber:w}}}=t;i=t={annotationType:L.HIGHLIGHT,color:Array.from(_),thickness:A,inkLists:p,boxes:null,pageIndex:w-1,rect:g.slice(0),rotation:b,id:m,deleted:!1,popupRef:y}}let{color:n,quadPoints:r,inkLists:a,opacity:o}=t,h=await super.deserialize(t,e,s);h.color=C.makeHexColor(...n),h.#a=o||1,a&&(h.#g=t.thickness),h.annotationElementId=t.id||null,h._initialData=i;let[c,d]=h.pageDimensions,[u,f]=h.pageTranslation;if(r){let p=h.#s=[];for(let g=0;g<r.length;g+=8)p.push({x:(r[g]-u)/c,y:1-(r[g+1]-f)/d,width:(r[g+2]-r[g])/c,height:(r[g+1]-r[g+5])/d});h.#y(),h.#P(),h.rotate(h.rotation)}else if(a){h.#d=!0;let p=a[0],g={x:p[0]-u,y:d-(p[1]-f)},b=new se(g,[0,0,c,d],1,h.#g/2,!0,.001);for(let A=0,y=p.length;A<y;A+=2)g.x=p[A]-u,g.y=d-(p[A+1]-f),b.add(g);let{id:m,clipPathId:_}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:b.toSVGPath()}},!0,!0);h.#_({highlightOutlines:b.getOutlines(),highlightId:m,clipPathId:_}),h.#P()}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=this.getRect(0,0),s=U._colorManager.convert(this.color),i={annotationType:L.HIGHLIGHT,color:s,opacity:this.#a,thickness:this.#g,quadPoints:this.#D(),outlines:this.#N(e),pageIndex:this.pageIndex,rect:e,rotation:this.#L(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#I(i)?null:(i.id=this.annotationElementId,i)}#I(t){let{color:e}=this._initialData;return t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},mi=class{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,s]of Object.entries(t))this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){let t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){O("Not implemented")}},bi=class l extends U{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#s=null;static#i=null;static#r=null;static#n=NaN;static#l=null;static#o=null;static#c=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,t.drawOutlines&&(this.#h(t),this.#f())}#h({drawOutlines:t,drawId:e,drawingOptions:s}){this.#t=t,this._drawingOptions||=s,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#u(t,this.parent),this.#m(t.box)}#u(t,e){let{id:s}=e.drawLayer.draw(l._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s}static _mergeSVGProperties(t,e){let s=new Set(Object.keys(t));for(let[i,n]of Object.entries(e))s.has(i)?Object.assign(t[i],n):t[i]=n;return t}static getDefaultDrawingOptions(t){O("Not implemented")}static get typesMap(){O("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&(l.#s.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){let i=this._drawingOptions,n=i[e],r=a=>{i.updateProperty(e,a);let o=this.#t.updateProperty(e,a);o&&this.#m(o),this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties())};this.addCommands({cmd:r.bind(this,s),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,l._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#p()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,l._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#p()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,l._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#d(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#d()):t&&(this._uiManager.addShouldRescale(this),this.#f(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#d(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#u(this.#t,t)}}#a([t,e,s,i]){let{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#p(){let{x:t,y:e,width:s,height:i,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#m(t){if([this.x,this.y,this.width,this.height]=this.#a(t),this.div){this.fixAndSetPosition();let[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}this._onResized()}#g(){let{x:t,y:e,width:s,height:i,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((n*4+r)/90){case 1:return[1-e-i,t,i,s];case 2:return[1-t-s,1-e-i,s,i];case 3:return[e,1-t-s,i,s];case 4:return[t,e-s*(a/o),i*(o/a),s*(a/o)];case 5:return[1-e,t,s*(a/o),i*(o/a)];case 6:return[1-t-i*(o/a),1-e,i*(o/a),s*(a/o)];case 7:return[e-s*(a/o),1-t-i*(o/a),s*(a/o),i*(o/a)];case 8:return[t-s,e-i,s,i];case 9:return[1-e,t-s,i,s];case 10:return[1-t,1-e,s,i];case 11:return[e-i,1-t,i,s];case 12:return[t-i*(o/a),e,i*(o/a),s*(a/o)];case 13:return[1-e-s*(a/o),t-i*(o/a),s*(a/o),i*(o/a)];case 14:return[1-t,1-e-s*(a/o),i*(o/a),s*(a/o)];case 15:return[e,1-t,s*(a/o),i*(o/a)];default:return[t,e,s,i]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,l._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";let[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,s,i,n){O("Not implemented")}static startDrawing(t,e,s,i){let{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:h}=i;if(l.#l&&l.#l!==h)return;let{viewport:{rotation:c}}=t,{width:d,height:u}=n.getBoundingClientRect(),f=l.#i=new AbortController,p=t.combinedSignal(f);if(l.#n||=o,l.#l??=h,window.addEventListener("pointerup",g=>{l.#n===g.pointerId?this._endDraw(g):l.#o?.delete(g.pointerId)},{signal:p}),window.addEventListener("pointercancel",g=>{l.#n===g.pointerId?this._currentParent.endDrawingSession():l.#o?.delete(g.pointerId)},{signal:p}),window.addEventListener("pointerdown",g=>{l.#l===g.pointerType&&((l.#o||=new Set).add(g.pointerId),l.#s.isCancellable()&&(l.#s.removeLastElement(),l.#s.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",dt,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",g=>{g.timeStamp===l.#c&&ot(g)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),l.#s){t.drawLayer.updateProperties(this._currentDrawId,l.#s.startNew(r,a,d,u,c));return}e.updateUIForDefaultProperties(this),l.#s=this.createDrawerInstance(r,a,d,u,c),l.#r=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(l.#r.toSVGProperties(),l.#s.defaultSVGProperties),!0,!1)}static _drawMove(t){if(l.#c=-1,!l.#s)return;let{offsetX:e,offsetY:s,pointerId:i}=t;if(l.#n===i){if(l.#o?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,l.#s.add(e,s)),l.#c=t.timeStamp,ot(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,l.#s=null,l.#r=null,l.#l=null,l.#c=NaN),l.#i&&(l.#i.abort(),l.#i=null,l.#n=NaN,l.#o=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,l.#s.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let s=l.#s,i=this._currentDrawId,n=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:F.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(F.DRAW_STEP),!l.#s.isEmpty()){let{pageDimensions:[s,i],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:l.#s.getOutlines(s*n,i*n,n,this._INNER_MARGIN),drawingOptions:l.#r,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,n,r){O("Not implemented")}static async deserialize(t,e,s){let{rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,i,n,this._INNER_MARGIN,t),h=await super.deserialize(t,e,s);return h.createDrawingOptions(t),h.#h({drawOutlines:o}),h.#f(),h.onScaleChanging(),h.rotate(),h}serializeDraw(t){let[e,s]=this.pageTranslation,[i,n]=this.pageDimensions;return this.#t.serialize([e,s,i,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},_i=class{#t=new Float64Array(6);#e;#s;#i;#r;#n;#l="";#o=0;#c=new $e;#h;#u;constructor(t,e,s,i,n,r){this.#h=s,this.#u=i,this.#i=n,this.#r=r,[t,e]=this.#d(t,e);let a=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#n=[t,e],this.#s=[{line:a,points:this.#n}],this.#t.set(a,0)}updateProperty(t,e){t==="stroke-width"&&(this.#r=e)}#d(t,e){return S._normalizePoint(t,e,this.#h,this.#u,this.#i)}isEmpty(){return!this.#s||this.#s.length===0}isCancellable(){return this.#n.length<=10}add(t,e){[t,e]=this.#d(t,e);let[s,i,n,r]=this.#t.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#h*a,this.#u*o)<=2?null:(this.#n.push(t,e),isNaN(s)?(this.#t.set([n,r,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([s,i,n,r,t,e],0),this.#e.push(...S.createBezierPoints(s,i,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){let s=this.add(t,e);return s||(this.#n.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,n){this.#h=s,this.#u=i,this.#i=n,[t,e]=this.#d(t,e);let r=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#n=[t,e];let a=this.#s.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#s.push({line:r,points:this.#n}),this.#t.set(r,0),this.#o=0,this.toSVGPath(),null}getLastElement(){return this.#s.at(-1)}setLastElement(t){return this.#s?(this.#s.push(t),this.#e=t.line,this.#n=t.points,this.#o=0,{path:{d:this.toSVGPath()}}):this.#c.setLastElement(t)}removeLastElement(){if(!this.#s)return this.#c.removeLastElement();this.#s.pop(),this.#l="";for(let t=0,e=this.#s.length;t<e;t++){let{line:s,points:i}=this.#s[t];this.#e=s,this.#n=i,this.#o=0,this.toSVGPath()}return{path:{d:this.#l}}}toSVGPath(){let t=S.svgRound(this.#e[4]),e=S.svgRound(this.#e[5]);if(this.#n.length===2)return this.#l=`${this.#l} M ${t} ${e} Z`,this.#l;if(this.#n.length<=6){let i=this.#l.lastIndexOf("M");this.#l=`${this.#l.slice(0,i)} M ${t} ${e}`,this.#o=6}if(this.#n.length===4){let i=S.svgRound(this.#e[10]),n=S.svgRound(this.#e[11]);return this.#l=`${this.#l} L ${i} ${n}`,this.#o=12,this.#l}let s=[];this.#o===0&&(s.push(`M ${t} ${e}`),this.#o=6);for(let i=this.#o,n=this.#e.length;i<n;i+=6){let[r,a,o,h,c,d]=this.#e.slice(i,i+6).map(S.svgRound);s.push(`C${r} ${a} ${o} ${h} ${c} ${d}`)}return this.#l+=s.join(" "),this.#o=this.#e.length,this.#l}getOutlines(t,e,s,i){let n=this.#s.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#c.build(this.#s,t,e,s,this.#i,this.#r,i),this.#t=null,this.#e=null,this.#s=null,this.#l=null,this.#c}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}},$e=class l extends S{#t;#e=0;#s;#i;#r;#n;#l;#o;#c;build(t,e,s,i,n,r,a){this.#r=e,this.#n=s,this.#l=i,this.#o=n,this.#c=r,this.#s=a??0,this.#i=t,this.#d()}setLastElement(t){return this.#i.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#i.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#i){if(t.push(`M${S.svgRound(e[4])} ${S.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12){t.push(`L${S.svgRound(e[10])} ${S.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){let[n,r,a,o,h,c]=e.subarray(s,s+6).map(S.svgRound);t.push(`C${n} ${r} ${a} ${o} ${h} ${c}`)}}return t.join("")}serialize([t,e,s,i],n){let r=[],a=[],[o,h,c,d]=this.#u(),u,f,p,g,b,m,_,A,y;switch(this.#o){case 0:y=S._rescale,u=t,f=e+i,p=s,g=-i,b=t+o*s,m=e+(1-h-d)*i,_=t+(o+c)*s,A=e+(1-h)*i;break;case 90:y=S._rescaleAndSwap,u=t,f=e,p=s,g=i,b=t+h*s,m=e+o*i,_=t+(h+d)*s,A=e+(o+c)*i;break;case 180:y=S._rescale,u=t+s,f=e,p=-s,g=i,b=t+(1-o-c)*s,m=e+h*i,_=t+(1-o)*s,A=e+(h+d)*i;break;case 270:y=S._rescaleAndSwap,u=t+s,f=e+i,p=-s,g=-i,b=t+(1-h-d)*s,m=e+(1-o-c)*i,_=t+(1-h)*s,A=e+(1-o)*i;break}for(let{line:w,points:E}of this.#i)r.push(y(w,u,f,p,g,n?new Array(w.length):null)),a.push(y(E,u,f,p,g,n?new Array(E.length):null));return{lines:r,points:a,rect:[b,m,_,A]}}static deserialize(t,e,s,i,n,{paths:{lines:r,points:a},rotation:o,thickness:h}){let c=[],d,u,f,p,g;switch(o){case 0:g=S._rescale,d=-t/s,u=e/i+1,f=1/s,p=-1/i;break;case 90:g=S._rescaleAndSwap,d=-e/i,u=-t/s,f=1/i,p=1/s;break;case 180:g=S._rescale,d=t/s+1,u=-e/i,f=-1/s,p=1/i;break;case 270:g=S._rescaleAndSwap,d=e/i+1,u=t/s+1,f=-1/i,p=-1/s;break}if(!r){r=[];for(let m of a){let _=m.length;if(_===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1]]));continue}if(_===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1],NaN,NaN,NaN,NaN,m[2],m[3]]));continue}let A=new Float32Array(3*(_-2));r.push(A);let[y,w,E,v]=m.subarray(0,4);A.set([NaN,NaN,NaN,NaN,y,w],0);for(let T=4;T<_;T+=2){let P=m[T],N=m[T+1];A.set(S.createBezierPoints(y,w,E,v,P,N),(T-2)*3),[y,w,E,v]=[E,v,P,N]}}}for(let m=0,_=r.length;m<_;m++)c.push({line:g(r[m].map(A=>A??NaN),d,u,f,p),points:g(a[m].map(A=>A??NaN),d,u,f,p)});let b=new l;return b.build(c,s,i,1,o,h,n),b}#h(t=this.#c){let e=this.#s+t/2*this.#l;return this.#o%180===0?[e/this.#r,e/this.#n]:[e/this.#n,e/this.#r]}#u(){let[t,e,s,i]=this.#t,[n,r]=this.#h(0);return[t+n,e+r,s-2*n,i-2*r]}#d(){let t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:i}of this.#i){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6){let[h,c]=i.subarray(a,a+2);t[0]=Math.min(t[0],h),t[1]=Math.min(t[1],c),t[2]=Math.max(t[2],h),t[3]=Math.max(t[3],c)}continue}let n=i[4],r=i[5];for(let a=6,o=i.length;a<o;a+=6){let[h,c,d,u,f,p]=i.subarray(a,a+6);C.bezierBoundingBox(n,r,h,c,d,u,f,p,t),n=f,r=p}}let[e,s]=this.#h();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-s)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+s)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){let[e,s]=this.#h();this.#c=t;let[i,n]=this.#h(),[r,a]=[i-e,n-s],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],s){let[i,n]=this.#h();this.#r=t,this.#n=e,this.#l=s;let[r,a]=this.#h(),o=r-i,h=a-n,c=this.#t;return c[0]-=o,c[1]-=h,c[2]+=2*o,c[3]+=2*h,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(S.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${S.svgRound(t)} ${S.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,s=0,i=0,n=0,r=0,a=0,o=0;switch(this.#e){case 90:i=e/t,n=-t/e,a=t;break;case 180:s=-1,r=-1,a=t,o=e;break;case 270:i=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${n} ${r} ${S.svgRound(a)} ${S.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){let[n,r]=this.#h(),[a,o,h,c]=this.#t;if(Math.abs(h-n)<=S.PRECISION||Math.abs(c-r)<=S.PRECISION){let g=t+s/2-(a+h/2),b=e+i/2-(o+c/2);return{path:{"transform-origin":`${S.svgRound(t)} ${S.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${b})`}}}let d=(s-2*n)/(h-2*n),u=(i-2*r)/(c-2*r),f=h/s,p=c/i;return{path:{"transform-origin":`${S.svgRound(a)} ${S.svgRound(o)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${S.svgRound(n)} ${S.svgRound(r)}) scale(${d} ${u}) translate(${S.svgRound(-n)} ${S.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,s,i]){let[n,r]=this.#h(),a=this.#t,[o,h,c,d]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(c-n)<=S.PRECISION||Math.abs(d-r)<=S.PRECISION){let b=t+s/2-(o+c/2),m=e+i/2-(h+d/2);for(let{line:_,points:A}of this.#i)S._translate(_,b,m,_),S._translate(A,b,m,A);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${S.svgRound(t)} ${S.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let u=(s-2*n)/(c-2*n),f=(i-2*r)/(d-2*r),p=-u*(o+n)+t+n,g=-f*(h+r)+e+r;if(u!==1||f!==1||p!==0||g!==0)for(let{line:b,points:m}of this.#i)S._rescale(b,p,g,u,f,b),S._rescale(m,p,g,u,f,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${S.svgRound(t)} ${S.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){let[i,n]=s,r=this.#t,a=t-r[0],o=e-r[1];if(this.#r===i&&this.#n===n)for(let{line:h,points:c}of this.#i)S._translate(h,a,o,h),S._translate(c,a,o,c);else{let h=this.#r/i,c=this.#n/n;this.#r=i,this.#n=n;for(let{line:d,points:u}of this.#i)S._rescale(d,a,o,h,c,d),S._rescale(u,a,o,h,c,u);r[2]*=h,r[3]*=c}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${S.svgRound(t)} ${S.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${S.svgRound(t[0])} ${S.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}},Ai=class l extends mi{#t;constructor(t){super(),this.#t=t,super.updateProperties({fill:"none",stroke:U._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this.#t.realScale),super.updateSVGProperty(t,e)}clone(){let t=new l(this.#t);return t.updateAll(this),t}},yi=class l extends bi{static _type="ink";static _editorType=L.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){U.initialize(t,e),this._defaultDrawingOptions=new Ai(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return I(this,"typesMap",new Map([[F.INK_THICKNESS,"stroke-width"],[F.INK_COLOR,"stroke"],[F.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,n){return new _i(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,n,r){return $e.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=null;if(t instanceof te){let{data:{inkLists:r,rect:a,rotation:o,id:h,color:c,opacity:d,borderStyle:{rawWidth:u},popupRef:f},parent:{page:{pageNumber:p}}}=t;i=t={annotationType:L.INK,color:Array.from(c),thickness:u,opacity:d,paths:{points:r},boxes:null,pageIndex:p-1,rect:a.slice(0),rotation:o,id:h,deleted:!1,popupRef:f}}let n=await super.deserialize(t,e,s);return n.annotationElementId=t.id||null,n._initialData=i,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=l.getDefaultDrawingOptions({stroke:C.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:s,rect:i}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":a}}=this,o={annotationType:L.INK,color:U._colorManager.convert(n),opacity:r,thickness:a,paths:{lines:e,points:s},pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#t(o)?null:(o.id=this.annotationElementId,o)}#t(t){let{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==n}renderAnnotationElement(t){let{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e}),null}},wi=class l extends U{#t=null;#e=null;#s=null;#i=null;#r=null;#n="";#l=null;#o=null;#c=!1;#h=!1;static _type="stamp";static _editorType=L.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#i=t.bitmapUrl,this.#r=t.bitmapFile}static initialize(t,e){U.initialize(t,e)}static get supportedTypes(){return I(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return I(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(L.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#u(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#c=t.isSvg),t.file&&(this.#n=t.file.name),this.#a()}#d(){if(this.#s=null,this._uiManager.enableWaiting(!1),!!this.#l){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");let{data:i,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:n,height:r,channels:i.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#f(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#u(s,!0)).finally(()=>this.#d());return}if(this.#i){let s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#u(i)).finally(()=>this.#d());return}if(this.#r){let s=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then(i=>this.#u(i)).finally(()=>this.#d());return}let t=document.createElement("input");t.type="file",t.accept=l.supportedTypesStr;let e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#u(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#d()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#l?.remove(),this.#l=null,this.#o&&(clearTimeout(this.#o),this.#o=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#f();return}super.rebuild(),this.div!==null&&(this.#e&&this.#l===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#i||this.#r||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#a():this.#f(),this.width&&!this.annotationElementId){let[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#o!==null&&clearTimeout(this.#o);let t=200;this.#o=setTimeout(()=>{this.#o=null,this.#m()},t)}#a(){let{div:t}=this,{width:e,height:s}=this.#t,[i,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>r*i||s>r*n){let c=Math.min(r*i/e,r*n/s);e*=c,s*=c}let[a,o]=this.parentDimensions;this.setDims(e*a/i,s*o/n),this._uiManager.enableWaiting(!1);let h=this.#l=document.createElement("canvas");h.setAttribute("role","img"),this.addContainer(h),this.width=e/i,this.height=s/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#m(),this.#h||(this.parent.addUndoableEditor(this),this.#h=!0),this._reportTelemetry({action:"inserted_image"}),this.#n&&h.setAttribute("aria-label",this.#n)}copyCanvas(t,e,s=!1){t||(t=224);let{width:i,height:n}=this.#t,r=new Xt,a=this.#t,o=i,h=n,c=null;if(e){if(i>e||n>e){let E=Math.min(e/i,e/n);o=Math.floor(i*E),h=Math.floor(n*E)}c=document.createElement("canvas");let u=c.width=Math.ceil(o*r.sx),f=c.height=Math.ceil(h*r.sy);this.#c||(a=this.#p(u,f));let p=c.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",b="#cfcfd8";this._uiManager.hcmFilter!=="none"?b="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(g="#8f8f9d",b="#42414d");let m=15,_=m*r.sx,A=m*r.sy,y=new OffscreenCanvas(_*2,A*2),w=y.getContext("2d");w.fillStyle=g,w.fillRect(0,0,_*2,A*2),w.fillStyle=b,w.fillRect(0,0,_,A),w.fillRect(_,A,_,A),p.fillStyle=p.createPattern(y,"repeat"),p.fillRect(0,0,u,f),p.drawImage(a,0,0,a.width,a.height,0,0,u,f)}let d=null;if(s){let u,f;if(r.symmetric&&a.width<t&&a.height<t)u=a.width,f=a.height;else if(a=this.#t,i>t||n>t){let b=Math.min(t/i,t/n);u=Math.floor(i*b),f=Math.floor(n*b),this.#c||(a=this.#p(u,f))}let g=new OffscreenCanvas(u,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,f),d={width:u,height:f,data:g.getImageData(0,0,u,f).data}}return{canvas:c,width:o,height:h,imageData:d}}#p(t,e){let{width:s,height:i}=this.#t,n=s,r=i,a=this.#t;for(;n>2*t||r>2*e;){let o=n,h=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));let c=new OffscreenCanvas(n,r);c.getContext("2d").drawImage(a,0,0,o,h,0,0,n,r),a=c.transferToImageBitmap()}return a}#m(){let[t,e]=this.parentDimensions,{width:s,height:i}=this,n=new Xt,r=Math.ceil(s*t*n.sx),a=Math.ceil(i*e*n.sy),o=this.#l;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;let h=this.#c?this.#t:this.#p(r,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(h,0,0,h.width,h.height,0,0,r,a)}getImageForAltText(){return this.#l}#g(t){if(t){if(this.#c){let i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}let e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#c){let[e,s]=this.pageDimensions,i=Math.round(this.width*e*wt.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*wt.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let i=null;if(t instanceof Fe){let{data:{rect:p,rotation:g,id:b,structParent:m,popupRef:_},container:A,parent:{page:{pageNumber:y}}}=t,w=A.querySelector("canvas"),E=s.imageManager.getFromCanvas(A.id,w);w.remove();let v=(await e._structTree.getAriaAttributes(`${xi}${b}`))?.get("aria-label")||"";i=t={annotationType:L.STAMP,bitmapId:E.id,bitmap:E.bitmap,pageIndex:y-1,rect:p.slice(0),rotation:g,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:v},isSvg:!1,structParent:m,popupRef:_}}let n=await super.deserialize(t,e,s),{rect:r,bitmap:a,bitmapUrl:o,bitmapId:h,isSvg:c,accessibilityData:d}=t;h&&s.imageManager.isValidId(h)?(n.#e=h,a&&(n.#t=a)):n.#i=o,n.#c=c;let[u,f]=n.pageDimensions;return n.width=(r[2]-r[0])/u,n.height=(r[3]-r[1])/f,n.annotationElementId=t.id||null,d&&(n.altTextData=d),n._initialData=i,n.#h=!!i,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let s={annotationType:L.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#c,structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=this.#g(!0),s.accessibilityData=this.serializeAltText(!0),s;let{decorative:i,altText:n}=this.serializeAltText(!1);if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){let a=this.#b(s);if(a.isSame)return null;a.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1}if(s.id=this.annotationElementId,e===null)return s;e.stamps||=new Map;let r=this.#c?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#g(!1);else if(this.#c){let a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#g(!1))}return s}#b(t){let{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===s;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&i&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}},vi=class l{#t;#e=!1;#s=null;#i=null;#r=null;#n=new Map;#l=!1;#o=!1;#c=!1;#h=null;#u=null;#d=null;#f=null;#a;static _initialized=!1;static#p=new Map([fi,yi,wi,He].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:h,l10n:c}){let d=[...l.#p.values()];if(!l._initialized){l._initialized=!0;for(let u of d)u.initialize(c,t)}t.registerEditorTypes(d),this.#a=t,this.pageIndex=e,this.div=s,this.#t=n,this.#s=r,this.viewport=h,this.#d=o,this.drawLayer=a,this._structTree=i,this.#a.addLayer(this)}get isEmpty(){return this.#n.size===0}get isInvisible(){return this.isEmpty&&this.#a.getMode()===L.NONE}updateToolbar(t){this.#a.updateToolbar(t)}updateMode(t=this.#a.getMode()){switch(this.#_(),t){case L.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case L.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case L.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 s of l.#p.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#a.setEditingState(t)}addCommands(t){this.#a.addCommands(t)}cleanUndoStack(t){this.#a.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.div.classList.toggle("disabled",!t)}async enable(){this.#c=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let s of this.#n.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#a.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!this.#s){this.#c=!1;return}let e=this.#s.getEditableAnnotations();for(let s of e){if(s.hide(),this.#a.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;let i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}this.#c=!1}disable(){this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,e=new Map;for(let i of this.#n.values())if(i.disableEditing(),!!i.annotationElementId){if(i.serialize()!==null){t.set(i.annotationElementId,i);continue}else e.set(i.annotationElementId,i);this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()}if(this.#s){let i=this.#s.getEditableAnnotations();for(let n of i){let{id:r}=n.data;if(this.#a.isDeletedAnnotationElement(r))continue;let a=e.get(r);if(a){a.resetAnnotationElement(n),a.show(!1),n.show();continue}a=t.get(r),a&&(this.#a.addChangedExistingAnnotation(a),a.renderAnnotationElement(n)&&a.show(!1)),n.show()}}this.#_(),this.isEmpty&&(this.div.hidden=!0);let{classList:s}=this.div;for(let i of l.#p.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#o=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#a.getActive()!==t&&this.#a.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;let t=this.#a.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#m.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting"))}#m(t){this.#a.unselectAll();let{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#d.div.contains(e)){let{isMac:s}=Y.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#a.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),He.startHighlighting(this,this.#a.direction==="ltr",{target:this.#d.div,x:t.x,y:t.y}),this.#d.div.addEventListener("pointerup",()=>{this.#d.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#a._signal}),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;let t=this.#a.combinedSignal(this.#i);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#i?.abort(),this.#i=null}attach(t){this.#n.set(t.id,t);let{annotationElementId:e}=t;e&&this.#a.isDeletedAnnotationElement(e)&&this.#a.removeDeletedAnnotationElement(t)}detach(t){this.#n.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId&&this.#a.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#a.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#a.addDeletedAnnotationElement(t.annotationElementId),U.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.#a.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#c),this.#a.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#a._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){let e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return this.#a.getId()}get#g(){return l.#p.get(this.#a.getMode())}combinedSignal(t){return this.#a.combinedSignal(t)}#b(t){let e=this.#g;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#a.updateToolbar(t),this.#a.updateMode(t);let{offsetX:s,offsetY:i}=this.#y(),n=this.getNextId(),r=this.#b({parent:this,id:n,x:s,y:i,uiManager:this.#a,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await l.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#a)||null}createAndAddNewEditor(t,e,s={}){let i=this.getNextId(),n=this.#b({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#a,isCentered:e,...s});return n&&this.add(n),n}#y(){let{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),h=(n+a)/2-t,c=(r+o)/2-e,[d,u]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:u}}addNewEditor(){this.createAndAddNewEditor(this.#y(),!0)}setSelected(t){this.#a.setSelected(t)}toggleSelected(t){this.#a.toggleSelected(t)}unselect(t){this.#a.unselect(t)}pointerup(t){let{isMac:e}=Y.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#l&&(this.#l=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings))){if(!this.#e){this.#e=!0;return}if(this.#a.getMode()===L.STAMP){this.#a.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#a.getMode()===L.HIGHLIGHT&&this.enableTextSelection(),this.#l){this.#l=!1;return}let{isMac:e}=Y.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#l=!0,this.#g?.isDrawer){this.startDrawingSession(t);return}let s=this.#a.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#h){this.#g.startDrawing(this,this.#a,!1,t);return}this.#a.setCurrentDrawingSession(this),this.#h=new AbortController;let e=this.#a.combinedSignal(this.#h);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#u=null,this.commitOrRemove())},{signal:e}),this.#g.startDrawing(this,this.#a,!1,t)}pause(t){if(t){let{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#h?(this.#a.setCurrentDrawingSession(null),this.#h.abort(),this.#h=null,this.#u=null,this.#g.endDrawing(t)):null}findNewParent(t,e,s){let i=this.#a.findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return this.#h?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#h&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#a.getActive()?.parent===this&&(this.#a.commitOrRemove(),this.#a.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(let t of this.#n.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#n.clear(),this.#a.removeLayer(this)}#_(){for(let t of this.#n.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Ct(this.div,t);for(let e of this.#a.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#a.commitOrRemove(),this.#_();let e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Ct(this.div,{rotation:s}),e!==s)for(let i of this.#n.values())i.rotate(s)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#a.viewParameters.realScale}},Ei=class l{#t=null;#e=0;#s=new Map;#i=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#s.size>0)for(let e of this.#s.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return I(this,"_svgFactory",new Jt)}static#r(t,[e,s,i,n]){let{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`}#n(){let t=l._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#l(t,e){let s=l._svgFactory.createElement("clipPath");t.append(s);let i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");let n=l._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}#o(t,e){for(let[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)}draw(t,e=!1,s=!1){let i=this.#e++,n=this.#n(),r=l._svgFactory.createElement("defs");n.append(r);let a=l._svgFactory.createElement("path");r.append(a);let o=`path_p${this.pageIndex}_${i}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#i.set(i,a);let h=s?this.#l(r,o):null,c=l._svgFactory.createElement("use");return n.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#s.set(i,n),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){let s=this.#e++,i=this.#n(),n=l._svgFactory.createElement("defs");i.append(n);let r=l._svgFactory.createElement("path");n.append(r);let a=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){let d=l._svgFactory.createElement("mask");n.append(d),o=`mask_p${this.pageIndex}_${s}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");let u=l._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");let f=l._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}let h=l._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${a}`),o&&h.setAttribute("mask",`url(#${o})`);let c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#s.set(s,i),s}finalizeDraw(t,e){this.#i.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:s,bbox:i,rootClass:n,path:r}=e,a=typeof t=="number"?this.#s.get(t):t;if(a){if(s&&this.#o(a,s),i&&l.#r(a,i),n){let{classList:o}=a;for(let[h,c]of Object.entries(n))o.toggle(h,c)}if(r){let h=a.firstChild.firstChild;this.#o(h,r)}}}updateParent(t,e){if(e===this)return;let s=this.#s.get(t);s&&(e.#t.append(s),this.#s.delete(t),e.#s.set(t,s))}remove(t){this.#i.delete(t),this.#t!==null&&(this.#s.get(t).remove(),this.#s.delete(t))}destroy(){this.#t=null;for(let t of this.#s.values())t.remove();this.#s.clear(),this.#i.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:ee};var sr=R.AbortException,ir=R.AnnotationEditorLayer,nr=R.AnnotationEditorParamsType,rr=R.AnnotationEditorType,ar=R.AnnotationEditorUIManager,or=R.AnnotationLayer,lr=R.AnnotationMode,hr=R.ColorPicker,cr=R.DOMSVGFactory,dr=R.DrawLayer,ur=R.FeatureTest,ki=R.GlobalWorkerOptions,fr=R.ImageKind,pr=R.InvalidPDFException,gr=R.MissingPDFException,mr=R.OPS,br=R.OutputScale,_r=R.PDFDataRangeTransport,Ar=R.PDFDateString,yr=R.PDFWorker,wr=R.PasswordResponses,vr=R.PermissionFlag,Er=R.PixelsPerInch,Sr=R.RenderingCancelledException,xr=R.TextLayer,Cr=R.TouchManager,Tr=R.UnexpectedResponseException,kr=R.Util,Pr=R.VerbosityLevel,Rr=R.XfaLayer,Lr=R.build,Mr=R.createValidAbsoluteUrl,Ir=R.fetchData,tn=R.getDocument,Dr=R.getFilenameFromUrl,Fr=R.getPdfFilenameFromUrl,Nr=R.getXfaPageViewport,Or=R.isDataScheme,Br=R.isPdfFile,Hr=R.noContextMenu,$r=R.normalizeUnicode,Gr=R.setLayerDimensions,Ur=R.shadow,zr=R.stopEvent,en=R.version;typeof window<"u"&&(ki.workerSrc=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${en}/pdf.worker.min.mjs`);var Zn={flipDuration:700,shadowIntensity:.4,maxDpr:2,toolbar:!0,theme:"dark",preloadAhead:2,onFlip:null,onReady:null,onError:null},Ye=(l,t,e)=>Math.max(t,Math.min(e,l)),Pi=l=>l%2===0?l:l-1,tr=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,Ke=class{constructor(t,e,s={}){if(!e)throw new Error("[PdfFlipbook] pdfUrl is required");if(this._el=typeof t=="string"?document.querySelector(t):t,!this._el)throw new Error(`[PdfFlipbook] container not found: ${t}`);this._url=e,this._opts={...Zn,...s},this._pages=[],this._pdf=null,this._total=0,this._spread=0,this._flipping=!1,this._init()}static set workerSrc(t){ki.workerSrc=t}next(){this._flip(1)}prev(){this._flip(-1)}goTo(t){let e=Ye(t-1,0,this._total-1),s=Pi(e);if(s===this._spread)return;let i=s>this._spread?1:-1;this._animateFlip(i,s)}destroy(){this._el.innerHTML="",this._el.classList.remove("pfb",`pfb--${this._opts.theme}`),this._pages=[],window.removeEventListener("resize",this._onResize),window.removeEventListener("keydown",this._onKey)}async _init(){this._buildShell();try{await this._loadPdf(),this._bindEvents(),this._opts.onReady?.()}catch(t){console.error("[PdfFlipbook]",t),this._showError(t.message),this._opts.onError?.(t)}}_buildShell(){this._el.classList.add("pfb",`pfb--${this._opts.theme}`),this._el.innerHTML=`
|
|
13
|
+
<div class="pfb__stage">
|
|
14
|
+
<div class="pfb__book">
|
|
15
|
+
<div class="pfb__page pfb__page--left">
|
|
16
|
+
<div class="pfb__page-front"></div>
|
|
17
|
+
<div class="pfb__page-back"></div>
|
|
18
|
+
<div class="pfb__shadow pfb__shadow--left"></div>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="pfb__spine"></div>
|
|
21
|
+
<div class="pfb__page pfb__page--right">
|
|
22
|
+
<div class="pfb__page-front"></div>
|
|
23
|
+
<div class="pfb__page-back"></div>
|
|
24
|
+
<div class="pfb__shadow pfb__shadow--right"></div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<button class="pfb__btn pfb__btn--prev" aria-label="Previous page">←</button>
|
|
28
|
+
<button class="pfb__btn pfb__btn--next" aria-label="Next page">→</button>
|
|
29
|
+
<div class="pfb__loader">
|
|
30
|
+
<div class="pfb__spinner"></div>
|
|
31
|
+
<span class="pfb__loader-text">Loading PDF\u2026</span>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="pfb__error" hidden></div>
|
|
34
|
+
</div>
|
|
35
|
+
${this._opts.toolbar?`
|
|
36
|
+
<div class="pfb__toolbar">
|
|
37
|
+
<button class="pfb__tb-btn pfb__tb-prev" aria-label="Previous">←</button>
|
|
38
|
+
<span class="pfb__page-info"></span>
|
|
39
|
+
<button class="pfb__tb-btn pfb__tb-next" aria-label="Next">→</button>
|
|
40
|
+
</div>`:""}
|
|
41
|
+
`,this._stage=this._el.querySelector(".pfb__stage"),this._book=this._el.querySelector(".pfb__book"),this._loader=this._el.querySelector(".pfb__loader"),this._errorEl=this._el.querySelector(".pfb__error"),this._pageInfo=this._el.querySelector(".pfb__page-info"),this._leftFront=this._el.querySelector(".pfb__page--left .pfb__page-front"),this._leftBack=this._el.querySelector(".pfb__page--left .pfb__page-back"),this._leftShadow=this._el.querySelector(".pfb__shadow--left"),this._rightFront=this._el.querySelector(".pfb__page--right .pfb__page-front"),this._rightBack=this._el.querySelector(".pfb__page--right .pfb__page-back"),this._rightShadow=this._el.querySelector(".pfb__shadow--right")}async _loadPdf(){let t=tn({url:this._url,withCredentials:!1});this._pdf=await t.promise,this._total=this._pdf.numPages,await this._prerenderAll(),this._loader.hidden=!0,this._renderSpread(0,!1)}async _prerenderAll(){this._loaderText=this._el.querySelector(".pfb__loader-text");for(let t=1;t<=this._total;t++){let e=await this._renderPage(t);this._pages.push(e),this._loaderText&&(this._loaderText.textContent=`Loading ${t} / ${this._total}\u2026`)}}async _renderPage(t){let e=await this._pdf.getPage(t),s=Ye(window.devicePixelRatio||1,1,this._opts.maxDpr),r=900/e.getViewport({scale:1}).width,a=e.getViewport({scale:r*s}),o=document.createElement("canvas");o.width=a.width,o.height=a.height,o.style.width=`${a.width/s}px`,o.style.height=`${a.height/s}px`,o.dataset.pageNum=t;let h=o.getContext("2d");return await e.render({canvasContext:h,viewport:a}).promise,o}_renderSpread(t,e){this._spread=Ye(t,0,Pi(this._total-1)||0);let s=this._spread,i=this._spread+1;this._setFace(this._leftFront,s),this._setFace(this._rightFront,i),this._setFace(this._leftBack,null),this._setFace(this._rightBack,null),this._updateUI()}_setFace(t,e){if(t.innerHTML="",e===null||e>=this._total){t.classList.add("pfb__face--blank");return}t.classList.remove("pfb__face--blank");let s=this._pages[e];if(s){let i=s.cloneNode();i.getContext("2d").drawImage(s,0,0),t.appendChild(i)}}_flip(t){if(this._flipping)return;let e=this._spread+t*2;e<0||e>Pi(this._total-1)||this._animateFlip(t,e)}_animateFlip(t,e){if(this._flipping)return;this._flipping=!0;let{flipDuration:s,shadowIntensity:i,onFlip:n}=this._opts,r=this._spread,a=this._spread+1;n?.(r+1,e+1),t===1?(this._setFace(this._rightBack,e+1),this._setFace(this._leftBack,e)):(this._setFace(this._leftBack,e),this._setFace(this._rightBack,e+1));let o=t===1?this._el.querySelector(".pfb__page--right"):this._el.querySelector(".pfb__page--left"),h=t===1?this._rightShadow:this._leftShadow,c=0,d=t===1?-180:180,u=g=>g<.5?2*g*g:-1+(4-2*g)*g,f=null,p=g=>{f||(f=g);let b=g-f,m=Ye(b/s,0,1),_=u(m),A=c+(d-c)*_;o.style.transform=`rotateY(${A}deg)`;let y=Math.sin(m*Math.PI);h.style.opacity=y*i,m<1?requestAnimationFrame(p):(o.style.transform="",h.style.opacity=0,this._spread=e,this._flipping=!1,this._renderSpread(e,!1))};requestAnimationFrame(p)}_bindEvents(){let t=this._el.querySelectorAll(".pfb__btn--prev, .pfb__tb-prev"),e=this._el.querySelectorAll(".pfb__btn--next, .pfb__tb-next");t.forEach(s=>s.addEventListener("click",()=>this.prev())),e.forEach(s=>s.addEventListener("click",()=>this.next())),this._onKey=s=>{(s.key==="ArrowRight"||s.key==="ArrowDown")&&this.next(),(s.key==="ArrowLeft"||s.key==="ArrowUp")&&this.prev()},window.addEventListener("keydown",this._onKey),tr()&&this._bindSwipe(),this._onResize=()=>this._updateUI(),window.addEventListener("resize",this._onResize)}_bindSwipe(){let t=0;this._stage.addEventListener("touchstart",e=>{t=e.touches[0].clientX},{passive:!0}),this._stage.addEventListener("touchend",e=>{let s=e.changedTouches[0].clientX-t;Math.abs(s)>40&&(s<0?this.next():this.prev())},{passive:!0})}_updateUI(){if(!this._pageInfo)return;let t=this._spread+1,e=this._spread+2;e<=this._total?this._pageInfo.textContent=`${t} \u2013 ${e} / ${this._total}`:this._pageInfo.textContent=`${t} / ${this._total}`;let s=this._el.querySelectorAll(".pfb__btn--prev, .pfb__tb-prev"),i=this._el.querySelectorAll(".pfb__btn--next, .pfb__tb-next");s.forEach(n=>{n.disabled=this._spread===0}),i.forEach(n=>{n.disabled=this._spread+2>=this._total})}_showError(t){this._loader.hidden=!0,this._errorEl.hidden=!1,this._errorEl.textContent=`\u26A0\uFE0F Could not load PDF: ${t}`}};function jr(l,t,e){return new Ke(l,t,e)}var Vr=Ke;export{Ke as PdfFlipbook,jr as createFlipbook,Vr as default};
|
|
42
|
+
//# sourceMappingURL=pdf-flipbook.esm.min.js.map
|