@turinhub/atomix-common-ui 0.1.2 → 0.2.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.
@@ -0,0 +1,13 @@
1
+ "use strict";var Ip=Object.defineProperty;var Ed=h=>{throw TypeError(h)};var Fp=(h,t,e)=>t in h?Ip(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e;var z=(h,t,e)=>Fp(h,typeof t!="symbol"?t+"":t,e),Ph=(h,t,e)=>t.has(h)||Ed("Cannot "+e);var r=(h,t,e)=>(Ph(h,t,"read from private field"),e?e.call(h):t.get(h)),b=(h,t,e)=>t.has(h)?Ed("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(h):t.set(h,e),p=(h,t,e,s)=>(Ph(h,t,"write to private field"),s?s.call(h,e):t.set(h,e),e),m=(h,t,e)=>(Ph(h,t,"access private method"),e);var oe=(h,t,e,s)=>({set _(i){p(h,t,i,e)},get _(){return r(h,t,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const st=require("./index-DocNZVXn.cjs"),F=require("react"),ba=require("clsx");function Dp(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var za={};za.d=(h,t)=>{for(var e in t)za.o(t,e)&&!za.o(h,e)&&Object.defineProperty(h,e,{enumerable:!0,get:t[e]})};za.o=(h,t)=>Object.prototype.hasOwnProperty.call(h,t);var $=globalThis.pdfjsLib={};za.d($,{AbortException:()=>sr,AnnotationEditorLayer:()=>Kc,AnnotationEditorParamsType:()=>G,AnnotationEditorType:()=>X,AnnotationEditorUIManager:()=>Kn,AnnotationLayer:()=>Im,AnnotationMode:()=>ui,ColorPicker:()=>Zl,DOMSVGFactory:()=>bd,DrawLayer:()=>td,FeatureTest:()=>de,GlobalWorkerOptions:()=>ni,ImageKind:()=>vl,InvalidPDFException:()=>su,MissingPDFException:()=>er,OPS:()=>qe,OutputScale:()=>Gh,PDFDataRangeTransport:()=>Ju,PDFDateString:()=>cd,PDFWorker:()=>mr,PasswordResponses:()=>jp,PermissionFlag:()=>Hp,PixelsPerInch:()=>Bi,RenderingCancelledException:()=>ld,TextLayer:()=>bc,UnexpectedResponseException:()=>_h,Util:()=>N,VerbosityLevel:()=>Ah,XfaLayer:()=>tf,build:()=>fm,createValidAbsoluteUrl:()=>Gp,fetchData:()=>Eh,getDocument:()=>nm,getFilenameFromUrl:()=>Jp,getPdfFilenameFromUrl:()=>Zp,getXfaPageViewport:()=>tg,isDataScheme:()=>Sh,isPdfFile:()=>hd,noContextMenu:()=>Ge,normalizeUnicode:()=>Yp,setLayerDimensions:()=>Yn,shadow:()=>tt,version:()=>um});const re=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),eu=[1,0,0,1,0,0],jh=[.001,0,0,.001,0,0],Op=1e7,kh=1.35,Le={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ui={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Np="pdfjs_internal_editor_",X={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},G={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},Hp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Zt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},vl={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Lt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},Ea={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Ah={ERRORS:0,WARNINGS:1,INFOS:5},qe={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},jp={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let yh=Ah.WARNINGS;function Bp(h){Number.isInteger(h)&&(yh=h)}function Up(){return yh}function vh(h){yh>=Ah.INFOS&&console.log(`Info: ${h}`)}function K(h){yh>=Ah.WARNINGS&&console.log(`Warning: ${h}`)}function pt(h){throw new Error(h)}function Dt(h,t){h||pt(t)}function zp(h){switch(h==null?void 0:h.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Gp(h,t=null,e=null){if(!h)return null;try{if(e&&typeof h=="string"){if(e.addDefaultProtocol&&h.startsWith("www.")){const i=h.match(/\./g);(i==null?void 0:i.length)>=2&&(h=`http://${h}`)}if(e.tryConvertEncoding)try{h=Xp(h)}catch{}}const s=t?new URL(h,t):new URL(h);if(zp(s))return s}catch{}return null}function tt(h,t,e,s=!1){return Object.defineProperty(h,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Wi=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Bh extends Wi{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Uh extends Wi{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class su extends Wi{constructor(t){super(t,"InvalidPDFException")}}class er extends Wi{constructor(t){super(t,"MissingPDFException")}}class _h extends Wi{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class $p extends Wi{constructor(t){super(t,"FormatError")}}class sr extends Wi{constructor(t){super(t,"AbortException")}}function iu(h){(typeof h!="object"||(h==null?void 0:h.length)===void 0)&&pt("Invalid argument for bytesToString");const t=h.length,e=8192;if(t<e)return String.fromCharCode.apply(null,h);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),a=h.subarray(i,n);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function wh(h){typeof h!="string"&&pt("Invalid argument for stringToBytes");const t=h.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=h.charCodeAt(s)&255;return e}function Wp(h){return String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,h&255)}function ad(h){const t=Object.create(null);for(const[e,s]of h)t[e]=s;return t}function Vp(){const h=new Uint8Array(4);return h[0]=1,new Uint32Array(h.buffer,0,1)[0]===1}function qp(){try{return new Function(""),!0}catch{return!1}}class de{static get isLittleEndian(){return tt(this,"isLittleEndian",Vp())}static get isEvalSupported(){return tt(this,"isEvalSupported",qp())}static get isOffscreenCanvasSupported(){return tt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?tt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):tt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return tt(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Lh=Array.from(Array(256).keys(),h=>h.toString(16).padStart(2,"0"));var ai,_l,zh;class N{static makeHexColor(t,e,s){return`#${Lh[t]}${Lh[e]}${Lh[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){const 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){const 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){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],a[0]),Math.min(s[1],i[1],n[1],a[1]),Math.max(s[0],i[0],n[0],a[0]),Math.max(s[1],i[1],n[1],a[1])]}static inverseTransform(t){const 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){const 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],a=t[2]*e[1]+t[3]*e[3],o=(s+a)/2,l=Math.sqrt((s+a)**2-4*(s*a-n*i))/2,c=o+l||1,d=o-l||1;return[Math.sqrt(c),Math.sqrt(d)]}static normalizeRect(t){const 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){const 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;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[s,n,i,a]}static bezierBoundingBox(t,e,s,i,n,a,o,l,c){return c?(c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l)):c=[Math.min(t,o),Math.min(e,l),Math.max(t,o),Math.max(e,l)],m(this,ai,zh).call(this,t,s,n,o,e,i,a,l,3*(-t+3*(s-n)+o),6*(t-2*s+n),3*(s-t),c),m(this,ai,zh).call(this,t,s,n,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),c),c}}ai=new WeakSet,_l=function(t,e,s,i,n,a,o,l,c,d){if(c<=0||c>=1)return;const u=1-c,f=c*c,g=f*c,A=u*(u*(u*t+3*c*e)+3*f*s)+g*i,y=u*(u*(u*n+3*c*a)+3*f*o)+g*l;d[0]=Math.min(d[0],A),d[1]=Math.min(d[1],y),d[2]=Math.max(d[2],A),d[3]=Math.max(d[3],y)},zh=function(t,e,s,i,n,a,o,l,c,d,u,f){if(Math.abs(c)<1e-12){Math.abs(d)>=1e-12&&m(this,ai,_l).call(this,t,e,s,i,n,a,o,l,-u/d,f);return}const g=d**2-4*u*c;if(g<0)return;const A=Math.sqrt(g),y=2*c;m(this,ai,_l).call(this,t,e,s,i,n,a,o,l,(-d+A)/y,f),m(this,ai,_l).call(this,t,e,s,i,n,a,o,l,(-d-A)/y,f)},b(N,ai);function Xp(h){return decodeURIComponent(escape(h))}let Mh=null,Sd=null;function Yp(h){return Mh||(Mh=/([\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,Sd=new Map([["ſt","ſt"]])),h.replaceAll(Mh,(t,e,s)=>e?e.normalize("NFKC"):Sd.get(s))}function Kp(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const h=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(h);else for(let t=0;t<32;t++)h[t]=Math.floor(Math.random()*255);return iu(h)}const od="pdfjs_internal_id_",Ps={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};function Qp(h){return Uint8Array.prototype.toBase64?h.toBase64():btoa(iu(h))}const Ls="http://www.w3.org/2000/svg",Ki=class Ki{};z(Ki,"CSS",96),z(Ki,"PDF",72),z(Ki,"PDF_TO_CSS_UNITS",Ki.CSS/Ki.PDF);let Bi=Ki;async function Eh(h,t="text"){if(Ca(h,document.baseURI)){const e=await fetch(h);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)=>{const i=new XMLHttpRequest;i.open("GET",h,!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)})}class ll{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,d,u,f;switch(s%=360,s<0&&(s+=360),s){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 g,A,y,_;c===0?(g=Math.abs(l-t[1])*e+i,A=Math.abs(o-t[0])*e+n,y=(t[3]-t[1])*e,_=(t[2]-t[0])*e):(g=Math.abs(o-t[0])*e+i,A=Math.abs(l-t[1])*e+n,y=(t[2]-t[0])*e,_=(t[3]-t[1])*e),this.transform=[c*e,d*e,u*e,f*e,g-c*e*o-u*e*l,A-d*e*o-f*e*l],this.width=y,this.height=_}get rawDims(){const{viewBox:t}=this;return tt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new ll({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return N.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=N.applyTransform([t[0],t[1]],this.transform),s=N.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return N.applyInverseTransform([t,e],this.transform)}}class ld extends Wi{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Sh(h){const t=h.length;let e=0;for(;e<t&&h[e].trim()==="";)e++;return h.substring(e,e+5).toLowerCase()==="data:"}function hd(h){return typeof h=="string"&&/\.pdf$/i.test(h)}function Jp(h){return[h]=h.split(/[#?]/,1),h.substring(h.lastIndexOf("/")+1)}function Zp(h,t="document.pdf"){if(typeof h!="string")return t;if(Sh(h))return K('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(h);let 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}class xd{constructor(){z(this,"started",Object.create(null));z(this,"times",[])}time(t){t in this.started&&K(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||K(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
2
+ `);return t.join("")}}function Ca(h,t){try{const{protocol:e}=t?new URL(h,t):new URL(h);return e==="http:"||e==="https:"}catch{return!1}}function Ge(h){h.preventDefault()}function Cd(h){console.log("Deprecated API usage: "+h)}var Va;class cd{static toDateObject(t){if(!t||typeof t!="string")return null;r(this,Va)||p(this,Va,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=r(this,Va).exec(t);if(!e)return null;const s=parseInt(e[1],10);let 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 a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const c=e[7]||"Z";let d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,c==="-"?(a+=d,o+=u):c==="+"&&(a-=d,o-=u),new Date(Date.UTC(s,i,n,a,o,l))}}Va=new WeakMap,b(cd,Va);function tg(h,{scale:t=1,rotation:e=0}){const{width:s,height:i}=h.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new ll({viewBox:n,scale:t,rotation:e})}function dd(h){if(h.startsWith("#")){const t=parseInt(h.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return h.startsWith("rgb(")?h.slice(4,-1).split(",").map(t=>parseInt(t)):h.startsWith("rgba(")?h.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(K(`Not a valid color format: "${h}"`),[0,0,0])}function eg(h){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of h.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;h.set(e,dd(s))}t.remove()}function vt(h){const{a:t,b:e,c:s,d:i,e:n,f:a}=h.getTransform();return[t,e,s,i,n,a]}function ks(h){const{a:t,b:e,c:s,d:i,e:n,f:a}=h.getTransform().invertSelf();return[t,e,s,i,n,a]}function Yn(h,t,e=!1,s=!0){if(t instanceof ll){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:a}=h,o=de.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${n}px`,d=o?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,u=o?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!e||t.rotation%180===0?(a.width=d,a.height=u):(a.width=u,a.height=d)}s&&h.setAttribute("data-main-rotation",t.rotation)}class Gh{constructor(){const 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}}var fi,Ji,Xe,Zi,qa,Xa,eh,nu,ue,ru,au,wl,ou,Wh;const Ms=class Ms{constructor(t){b(this,ue);b(this,fi,null);b(this,Ji,null);b(this,Xe);b(this,Zi,null);b(this,qa,null);p(this,Xe,t),r(Ms,Xa)||p(Ms,Xa,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(){const t=p(this,fi,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=r(this,Xe)._uiManager._signal;t.addEventListener("contextmenu",Ge,{signal:e}),t.addEventListener("pointerdown",m(Ms,eh,nu),{signal:e});const s=p(this,Zi,document.createElement("div"));s.className="buttons",t.append(s);const i=r(this,Xe).toolbarPosition;if(i){const{style:n}=t,a=r(this,Xe)._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*a}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return m(this,ue,ou).call(this),t}get div(){return r(this,fi)}hide(){var t;r(this,fi).classList.add("hidden"),(t=r(this,Ji))==null||t.hideDropdown()}show(){var t;r(this,fi).classList.remove("hidden"),(t=r(this,qa))==null||t.shown()}async addAltText(t){const e=await t.render();m(this,ue,wl).call(this,e),r(this,Zi).prepend(e,r(this,ue,Wh)),p(this,qa,t)}addColorPicker(t){p(this,Ji,t);const e=t.renderButton();m(this,ue,wl).call(this,e),r(this,Zi).prepend(e,r(this,ue,Wh))}remove(){var t;r(this,fi).remove(),(t=r(this,Ji))==null||t.destroy(),p(this,Ji,null)}};fi=new WeakMap,Ji=new WeakMap,Xe=new WeakMap,Zi=new WeakMap,qa=new WeakMap,Xa=new WeakMap,eh=new WeakSet,nu=function(t){t.stopPropagation()},ue=new WeakSet,ru=function(t){r(this,Xe)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},au=function(t){r(this,Xe)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},wl=function(t){const e=r(this,Xe)._uiManager._signal;t.addEventListener("focusin",m(this,ue,ru).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",m(this,ue,au).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ge,{signal:e})},ou=function(){const{editorType:t,_uiManager:e}=r(this,Xe),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",r(Ms,Xa)[t]),m(this,ue,wl).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),r(this,Zi).append(s)},Wh=function(){const t=document.createElement("div");return t.className="divider",t},b(Ms,eh),b(Ms,Xa,null);let $h=Ms;var Ya,tn,en,Gi,lu,hu,cu;class sg{constructor(t){b(this,Gi);b(this,Ya,null);b(this,tn,null);b(this,en);p(this,en,t)}show(t,e,s){const[i,n]=m(this,Gi,hu).call(this,e,s),{style:a}=r(this,tn)||p(this,tn,m(this,Gi,lu).call(this));t.append(r(this,tn)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){r(this,tn).remove()}}Ya=new WeakMap,tn=new WeakMap,en=new WeakMap,Gi=new WeakSet,lu=function(){const t=p(this,tn,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ge,{signal:r(this,en)._signal});const e=p(this,Ya,document.createElement("div"));return e.className="buttons",t.append(e),m(this,Gi,cu).call(this),t},hu=function(t,e){let s=0,i=0;for(const n of t){const a=n.y+n.height;if(a<s)continue;const o=n.x+(e?n.width:0);if(a>s){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},cu=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=r(this,en)._signal;t.addEventListener("contextmenu",Ge,{signal:s}),t.addEventListener("click",()=>{r(this,en).highlightSelection("floating_button")},{signal:s}),r(this,Ya).append(t)};function Kl(h,t,e){for(const s of e)t.addEventListener(s,h[s].bind(h))}function ig(h){return Math.round(Math.min(255,Math.max(1,255*h))).toString(16).padStart(2,"0")}var sh;class ng{constructor(){b(this,sh,0)}get id(){return`${Np}${oe(this,sh)._++}`}}sh=new WeakMap;var yr,Ka,ee,vr,El;const vd=class vd{constructor(){b(this,vr);b(this,yr,Kp());b(this,Ka,0);b(this,ee,null)}static get _isSVGFittingCanvas(){const 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;const 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 tt(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return m(this,vr,El).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return m(this,vr,El).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,vr,El).call(this,t,s)}async getFromId(t){r(this,ee)||p(this,ee,new Map);const e=r(this,ee).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){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){r(this,ee)||p(this,ee,new Map);let s=r(this,ee).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${r(this,yr)}_${oe(this,Ka)._++}`,refCounter:1,isSvg:!1},r(this,ee).set(t,s),r(this,ee).set(s.id,s),s}getSvgUrl(t){const e=r(this,ee).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;r(this,ee)||p(this,ee,new Map);const e=r(this,ee).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(s.width,s.height);n.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=n.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${r(this,yr)}_`)}};yr=new WeakMap,Ka=new WeakMap,ee=new WeakMap,vr=new WeakSet,El=async function(t,e){r(this,ee)||p(this,ee,new Map);let s=r(this,ee).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${r(this,yr)}_${oe(this,Ka)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Eh(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=vd._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((c,d)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,c()},a.onload=async()=>{const u=s.svgUrl=a.result;o.src=await n?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=d});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return r(this,ee).set(t,s),s&&r(this,ee).set(s.id,s),s};let Vh=vd;var jt,pi,Qa,Bt;class rg{constructor(t=128){b(this,jt,[]);b(this,pi,!1);b(this,Qa);b(this,Bt,-1);p(this,Qa,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),r(this,pi))return;const l={cmd:t,undo:e,post:s,type:n};if(r(this,Bt)===-1){r(this,jt).length>0&&(r(this,jt).length=0),p(this,Bt,0),r(this,jt).push(l);return}if(a&&r(this,jt)[r(this,Bt)].type===n){o&&(l.undo=r(this,jt)[r(this,Bt)].undo),r(this,jt)[r(this,Bt)]=l;return}const c=r(this,Bt)+1;c===r(this,Qa)?r(this,jt).splice(0,1):(p(this,Bt,c),c<r(this,jt).length&&r(this,jt).splice(c)),r(this,jt).push(l)}undo(){if(r(this,Bt)===-1)return;p(this,pi,!0);const{undo:t,post:e}=r(this,jt)[r(this,Bt)];t(),e==null||e(),p(this,pi,!1),p(this,Bt,r(this,Bt)-1)}redo(){if(r(this,Bt)<r(this,jt).length-1){p(this,Bt,r(this,Bt)+1),p(this,pi,!0);const{cmd:t,post:e}=r(this,jt)[r(this,Bt)];t(),e==null||e(),p(this,pi,!1)}}hasSomethingToUndo(){return r(this,Bt)!==-1}hasSomethingToRedo(){return r(this,Bt)<r(this,jt).length-1}destroy(){p(this,jt,null)}}jt=new WeakMap,pi=new WeakMap,Qa=new WeakMap,Bt=new WeakMap;var ih,du;class hl{constructor(t){b(this,ih);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=de.platform;for(const[s,i,n={}]of t)for(const a of s){const o=a.startsWith("mac+");e&&o?(this.callbacks.set(a.slice(4),{callback:i,options:n}),this.allKeys.add(a.split("+").at(-1))):!e&&!o&&(this.callbacks.set(a,{callback:i,options:n}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(m(this,ih,du).call(this,e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:a=[],checker:o=null}}=s;o&&!o(t,e)||(i.bind(t,...a,e)(),n||(e.stopPropagation(),e.preventDefault()))}}ih=new WeakSet,du=function(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);const e=this.buffer.join("+");return this.buffer.length=0,e};const nh=class nh{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return eg(t),tt(this,"_colors",t)}convert(t){const e=dd(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,a)=>n===e[a]))return nh._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?N.makeHexColor(...e):t}};z(nh,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let qh=nh;var _r,Ee,Mt,Wt,wr,Fs,Er,Ye,gi,Sr,sn,ds,Ke,nn,Ja,Za,xr,to,us,mi,Cr,bi,fs,rh,Ai,eo,yi,rn,so,io,Ut,at,Ds,an,no,ro,vi,ps,Os,ao,De,k,Sl,Xh,uu,fu,xl,pu,gu,mu,Yh,bu,Kh,Qh,Au,le,ci,yu,vu,Jh,_u,Ta,Zh;const pr=class pr{constructor(t,e,s,i,n,a,o,l,c,d,u){b(this,k);b(this,_r,new AbortController);b(this,Ee,null);b(this,Mt,new Map);b(this,Wt,new Map);b(this,wr,null);b(this,Fs,null);b(this,Er,null);b(this,Ye,new rg);b(this,gi,null);b(this,Sr,0);b(this,sn,new Set);b(this,ds,null);b(this,Ke,null);b(this,nn,new Set);b(this,Ja,!1);b(this,Za,!1);b(this,xr,!1);b(this,to,null);b(this,us,null);b(this,mi,null);b(this,Cr,null);b(this,bi,!1);b(this,fs,null);b(this,rh,new ng);b(this,Ai,!1);b(this,eo,!1);b(this,yi,null);b(this,rn,null);b(this,so,null);b(this,io,null);b(this,Ut,X.NONE);b(this,at,new Set);b(this,Ds,null);b(this,an,null);b(this,no,null);b(this,ro,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});b(this,vi,[0,0]);b(this,ps,null);b(this,Os,null);b(this,ao,null);b(this,De,null);const f=this._signal=r(this,_r).signal;p(this,Os,t),p(this,ao,e),p(this,wr,s),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:f}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),i._on("setpreference",this.onSetPreference.bind(this),{signal:f}),i._on("switchannotationeditorparams",g=>this.updateParams(g.type,g.value),{signal:f}),m(this,k,pu).call(this),m(this,k,Au).call(this),m(this,k,Yh).call(this),p(this,Fs,n.annotationStorage),p(this,to,n.filterFactory),p(this,an,a),p(this,Cr,o||null),p(this,Ja,l),p(this,Za,c),p(this,xr,d),p(this,io,u||null),this.viewParameters={realScale:Bi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=pr.prototype,e=a=>r(a,Os).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return tt(this,"_keyboardManager",new hl([[["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:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,Os).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,Os).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}]]))}destroy(){var t,e,s,i;(t=r(this,De))==null||t.resolve(),p(this,De,null),(e=r(this,_r))==null||e.abort(),p(this,_r,null),this._signal=null;for(const n of r(this,Wt).values())n.destroy();r(this,Wt).clear(),r(this,Mt).clear(),r(this,nn).clear(),p(this,Ee,null),r(this,at).clear(),r(this,Ye).destroy(),(s=r(this,wr))==null||s.destroy(),(i=r(this,fs))==null||i.hide(),p(this,fs,null),r(this,us)&&(clearTimeout(r(this,us)),p(this,us,null)),r(this,ps)&&(clearTimeout(r(this,ps)),p(this,ps,null))}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return r(this,io)}get useNewAltTextFlow(){return r(this,Za)}get useNewAltTextWhenAddingImage(){return r(this,xr)}get hcmFilter(){return tt(this,"hcmFilter",r(this,an)?r(this,to).addHCMFilter(r(this,an).foreground,r(this,an).background):"none")}get direction(){return tt(this,"direction",getComputedStyle(r(this,Os)).direction)}get highlightColors(){return tt(this,"highlightColors",r(this,Cr)?new Map(r(this,Cr).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return tt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){p(this,so,t)}editAltText(t,e=!1){var s;(s=r(this,wr))==null||s.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":p(this,xr,e);break}}onPageChanging({pageNumber:t}){p(this,Sr,t-1)}focusMainContainer(){r(this,Os).focus()}findParent(t,e){for(const s of r(this,Wt).values()){const{x:i,y:n,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=n&&e<=n+o)return s}return null}disableUserSelect(t=!1){r(this,ao).classList.toggle("noUserSelect",t)}addShouldRescale(t){r(this,nn).add(t)}removeShouldRescale(t){r(this,nn).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Bi.PDF_TO_CSS_UNITS;for(const e of r(this,nn))e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a}=e,o=e.toString(),c=m(this,k,Sl).call(this,e).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;e.empty();const u=m(this,k,Xh).call(this,c),f=r(this,Ut)===X.NONE,g=()=>{u==null||u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a,text:o}),f&&this.showAllEditors("highlight",!0,!0)};if(f){this.switchToMode(X.HIGHLIGHT,g);return}g()}addToAnnotationStorage(t){!t.isEmpty()&&r(this,Fs)&&!r(this,Fs).has(t.id)&&r(this,Fs).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,r(this,bi)&&(p(this,bi,!1),m(this,k,xl).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of r(this,at))if(e.div.contains(t)){p(this,rn,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!r(this,rn))return;const[t,e]=r(this,rn);p(this,rn,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,k,Yh).call(this),m(this,k,Kh).call(this)}removeEditListeners(){m(this,k,bu).call(this),m(this,k,Qh).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of r(this,Ke))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of r(this,Ke))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=r(this,Ee))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of r(this,at)){const n=i.serialize(!0);n&&e.push(n)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const a of r(this,Ke))if(a.isHandlingMimeForPasting(n.type)){a.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){K(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const l of s){const c=await i.deserialize(l);if(!c)return;n.push(c)}const a=()=>{for(const l of n)m(this,k,Jh).call(this,l);m(this,k,Zh).call(this,n)},o=()=>{for(const l of n)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(n){K(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),r(this,Ut)!==X.NONE&&!this.isEditorHandlingKeyboard&&pr._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,r(this,bi)&&(p(this,bi,!1),m(this,k,xl).call(this,"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}}setEditingState(t){t?(m(this,k,gu).call(this),m(this,k,Kh).call(this),m(this,k,le).call(this,{isEditing:r(this,Ut)!==X.NONE,isEmpty:m(this,k,Ta).call(this),hasSomethingToUndo:r(this,Ye).hasSomethingToUndo(),hasSomethingToRedo:r(this,Ye).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,k,mu).call(this),m(this,k,Qh).call(this),m(this,k,le).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!r(this,Ke)){p(this,Ke,t);for(const e of r(this,Ke))m(this,k,ci).call(this,e.defaultPropertiesToUpdate)}}getId(){return r(this,rh).id}get currentLayer(){return r(this,Wt).get(r(this,Sr))}getLayer(t){return r(this,Wt).get(t)}get currentPageIndex(){return r(this,Sr)}addLayer(t){r(this,Wt).set(t.pageIndex,t),r(this,Ai)?t.enable():t.disable()}removeLayer(t){r(this,Wt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(r(this,Ut)!==t&&!(r(this,De)&&(await r(this,De).promise,!r(this,De)))){if(p(this,De,Promise.withResolvers()),p(this,Ut,t),t===X.NONE){this.setEditingState(!1),m(this,k,vu).call(this),r(this,De).resolve();return}this.setEditingState(!0),await m(this,k,yu).call(this),this.unselectAll();for(const i of r(this,Wt).values())i.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),r(this,De).resolve();return}for(const i of r(this,Mt).values())i.annotationElementId===e?(this.setSelected(i),i.enterInEditMode()):i.unselect();r(this,De).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==r(this,Ut)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(r(this,Ke)){switch(t){case G.CREATE:this.currentLayer.addNewEditor();return;case G.HIGHLIGHT_DEFAULT_COLOR:(s=r(this,so))==null||s.updateColor(e);break;case G.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(r(this,no)||p(this,no,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of r(this,at))i.updateParams(t,e);for(const i of r(this,Ke))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const a of r(this,Mt).values())a.editorType===t&&a.show(e);(((n=r(this,no))==null?void 0:n.get(G.HIGHLIGHT_SHOW_ALL))??!0)!==e&&m(this,k,ci).call(this,[[G.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(r(this,eo)!==t){p(this,eo,t);for(const e of r(this,Wt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of r(this,Mt).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return r(this,Mt).get(t)}addEditor(t){r(this,Mt).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(r(this,us)&&clearTimeout(r(this,us)),p(this,us,setTimeout(()=>{this.focusMainContainer(),p(this,us,null)},0))),r(this,Mt).delete(t.id),this.unselect(t),(!t.annotationElementId||!r(this,sn).has(t.annotationElementId))&&((e=r(this,Fs))==null||e.remove(t.id))}addDeletedAnnotationElement(t){r(this,sn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return r(this,sn).has(t)}removeDeletedAnnotationElement(t){r(this,sn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){r(this,Ee)!==t&&(p(this,Ee,t),t&&m(this,k,ci).call(this,t.propertiesToUpdate))}updateUI(t){r(this,k,_u)===t&&m(this,k,ci).call(this,t.propertiesToUpdate)}toggleSelected(t){if(r(this,at).has(t)){r(this,at).delete(t),t.unselect(),m(this,k,le).call(this,{hasSelectedEditor:this.hasSelection});return}r(this,at).add(t),t.select(),m(this,k,ci).call(this,t.propertiesToUpdate),m(this,k,le).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of r(this,at))e!==t&&e.unselect();r(this,at).clear(),r(this,at).add(t),t.select(),m(this,k,ci).call(this,t.propertiesToUpdate),m(this,k,le).call(this,{hasSelectedEditor:!0})}isSelected(t){return r(this,at).has(t)}get firstSelectedEditor(){return r(this,at).values().next().value}unselect(t){t.unselect(),r(this,at).delete(t),m(this,k,le).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return r(this,at).size!==0}get isEnterHandled(){return r(this,at).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){r(this,Ye).undo(),m(this,k,le).call(this,{hasSomethingToUndo:r(this,Ye).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,k,Ta).call(this)})}redo(){r(this,Ye).redo(),m(this,k,le).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:r(this,Ye).hasSomethingToRedo(),isEmpty:m(this,k,Ta).call(this)})}addCommands(t){r(this,Ye).add(t),m(this,k,le).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,k,Ta).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...r(this,at)],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)m(this,k,Jh).call(this,i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){var t;(t=r(this,Ee))==null||t.commitOrRemove()}hasSomethingToControl(){return r(this,Ee)||this.hasSelection}selectAll(){for(const t of r(this,at))t.commit();m(this,k,Zh).call(this,r(this,Mt).values())}unselectAll(){if(!(r(this,Ee)&&(r(this,Ee).commitOrRemove(),r(this,Ut)!==X.NONE))&&this.hasSelection){for(const t of r(this,at))t.unselect();r(this,at).clear(),m(this,k,le).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;r(this,vi)[0]+=t,r(this,vi)[1]+=e;const[i,n]=r(this,vi),a=[...r(this,at)],o=1e3;r(this,ps)&&clearTimeout(r(this,ps)),p(this,ps,setTimeout(()=>{p(this,ps,null),r(this,vi)[0]=r(this,vi)[1]=0,this.addCommands({cmd:()=>{for(const l of a)r(this,Mt).has(l.id)&&l.translateInPage(i,n)},undo:()=>{for(const l of a)r(this,Mt).has(l.id)&&l.translateInPage(-i,-n)},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,ds,new Map);for(const t of r(this,at))r(this,ds).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!r(this,ds))return!1;this.disableUserSelect(!1);const t=r(this,ds);p(this,ds,null);let e=!1;for(const[{x:i,y:n,pageIndex:a},o]of t)o.newX=i,o.newY=n,o.newPageIndex=a,e||(e=i!==o.savedX||n!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,n,a,o)=>{if(r(this,Mt).has(i.id)){const l=r(this,Wt).get(o);l?i._setParentAndPosition(l,n,a):(i.pageIndex=o,i.x=n,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:a,newPageIndex:o}]of t)s(i,n,a,o)},undo:()=>{for(const[i,{savedX:n,savedY:a,savedPageIndex:o}]of t)s(i,n,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(r(this,ds))for(const s of r(this,ds).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const 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(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||r(this,at).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return r(this,Ee)===t}getActive(){return r(this,Ee)}getMode(){return r(this,Ut)}get imageManager(){return tt(this,"imageManager",new Vh)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,d=e.rangeCount;c<d;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(c,d,u,f)=>({x:(d-i)/a,y:1-(c+u-s)/n,width:f/a,height:u/n});break;case"180":o=(c,d,u,f)=>({x:1-(c+u-s)/n,y:1-(d+f-i)/a,width:u/n,height:f/a});break;case"270":o=(c,d,u,f)=>({x:1-(d+f-i)/a,y:(c-s)/n,width:f/a,height:u/n});break;default:o=(c,d,u,f)=>({x:(c-s)/n,y:(d-i)/a,width:u/n,height:f/a});break}const l=[];for(let c=0,d=e.rangeCount;c<d;c++){const u=e.getRangeAt(c);if(!u.collapsed)for(const{x:f,y:g,width:A,height:y}of u.getClientRects())A===0||y===0||l.push(o(f,g,A,y))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(r(this,Er)||p(this,Er,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=r(this,Er))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=r(this,Er))==null?void 0:i.get(t.data.id);if(!e)return;const s=r(this,Fs).getRawValue(e);s&&(r(this,Ut)===X.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}};_r=new WeakMap,Ee=new WeakMap,Mt=new WeakMap,Wt=new WeakMap,wr=new WeakMap,Fs=new WeakMap,Er=new WeakMap,Ye=new WeakMap,gi=new WeakMap,Sr=new WeakMap,sn=new WeakMap,ds=new WeakMap,Ke=new WeakMap,nn=new WeakMap,Ja=new WeakMap,Za=new WeakMap,xr=new WeakMap,to=new WeakMap,us=new WeakMap,mi=new WeakMap,Cr=new WeakMap,bi=new WeakMap,fs=new WeakMap,rh=new WeakMap,Ai=new WeakMap,eo=new WeakMap,yi=new WeakMap,rn=new WeakMap,so=new WeakMap,io=new WeakMap,Ut=new WeakMap,at=new WeakMap,Ds=new WeakMap,an=new WeakMap,no=new WeakMap,ro=new WeakMap,vi=new WeakMap,ps=new WeakMap,Os=new WeakMap,ao=new WeakMap,De=new WeakMap,k=new WeakSet,Sl=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Xh=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of r(this,Wt).values())if(s.hasTextLayer(t))return s;return null},uu=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=m(this,k,Sl).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(r(this,fs)||p(this,fs,new sg(this)),r(this,fs).show(s,i,this.direction==="ltr"))},fu=function(){var n,a,o;const t=document.getSelection();if(!t||t.isCollapsed){r(this,Ds)&&((n=r(this,fs))==null||n.hide(),p(this,Ds,null),m(this,k,le).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===r(this,Ds))return;const i=m(this,k,Sl).call(this,t).closest(".textLayer");if(!i){r(this,Ds)&&((a=r(this,fs))==null||a.hide(),p(this,Ds,null),m(this,k,le).call(this,{hasSelectedText:!1}));return}if((o=r(this,fs))==null||o.hide(),p(this,Ds,e),m(this,k,le).call(this,{hasSelectedText:!0}),!(r(this,Ut)!==X.HIGHLIGHT&&r(this,Ut)!==X.NONE)&&(r(this,Ut)===X.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,bi,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=r(this,Ut)===X.HIGHLIGHT?m(this,k,Xh).call(this,i):null;l==null||l.toggleDrawing();const c=new AbortController,d=this.combinedSignal(c),u=f=>{f.type==="pointerup"&&f.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&m(this,k,xl).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("blur",u,{signal:d})}},xl=function(t=""){r(this,Ut)===X.HIGHLIGHT?this.highlightSelection(t):r(this,Ja)&&m(this,k,uu).call(this)},pu=function(){document.addEventListener("selectionchange",m(this,k,fu).bind(this),{signal:this._signal})},gu=function(){if(r(this,mi))return;p(this,mi,new AbortController);const t=this.combinedSignal(r(this,mi));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},mu=function(){var t;(t=r(this,mi))==null||t.abort(),p(this,mi,null)},Yh=function(){if(r(this,yi))return;p(this,yi,new AbortController);const t=this.combinedSignal(r(this,yi));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},bu=function(){var t;(t=r(this,yi))==null||t.abort(),p(this,yi,null)},Kh=function(){if(r(this,gi))return;p(this,gi,new AbortController);const t=this.combinedSignal(r(this,gi));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})},Qh=function(){var t;(t=r(this,gi))==null||t.abort(),p(this,gi,null)},Au=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},le=function(t){Object.entries(t).some(([s,i])=>r(this,ro)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(r(this,ro),t)}),r(this,Ut)===X.HIGHLIGHT&&t.hasSelectedEditor===!1&&m(this,k,ci).call(this,[[G.HIGHLIGHT_FREE,!0]]))},ci=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},yu=async function(){if(!r(this,Ai)){p(this,Ai,!0);const t=[];for(const e of r(this,Wt).values())t.push(e.enable());await Promise.all(t);for(const e of r(this,Mt).values())e.enable()}},vu=function(){if(this.unselectAll(),r(this,Ai)){p(this,Ai,!1);for(const t of r(this,Wt).values())t.disable();for(const t of r(this,Mt).values())t.disable()}},Jh=function(t){const e=r(this,Wt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},_u=function(){let t=null;for(t of r(this,at));return t},Ta=function(){if(r(this,Mt).size===0)return!0;if(r(this,Mt).size===1)for(const t of r(this,Mt).values())return t.isEmpty();return!1},Zh=function(t){for(const e of r(this,at))e.unselect();r(this,at).clear();for(const e of t)e.isEmpty()||(r(this,at).add(e),e.select());m(this,k,le).call(this,{hasSelectedEditor:this.hasSelection})},z(pr,"TRANSLATE_SMALL",1),z(pr,"TRANSLATE_BIG",10);let Kn=pr;var zt,gs,Qe,Tr,ms,Se,Rr,bs,be,Ns,on,As,_i,os,Ra,Cl;const he=class he{constructor(t){b(this,os);b(this,zt,null);b(this,gs,!1);b(this,Qe,null);b(this,Tr,null);b(this,ms,null);b(this,Se,null);b(this,Rr,!1);b(this,bs,null);b(this,be,null);b(this,Ns,null);b(this,on,null);b(this,As,!1);p(this,be,t),p(this,As,t._uiManager.useNewAltTextFlow),r(he,_i)||p(he,_i,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){he._l10n??(he._l10n=t)}async render(){const t=p(this,Qe,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,Tr,document.createElement("span"));t.append(e),r(this,As)?(t.classList.add("new"),t.setAttribute("data-l10n-id",r(he,_i).missing),e.setAttribute("data-l10n-id",r(he,_i)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=r(this,be)._uiManager._signal;t.addEventListener("contextmenu",Ge,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),r(this,be)._uiManager.editAltText(r(this,be)),r(this,As)&&r(this,be)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:r(this,os,Ra)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(p(this,Rr,!0),i(n))},{signal:s}),await m(this,os,Cl).call(this),t}finish(){r(this,Qe)&&(r(this,Qe).focus({focusVisible:r(this,Rr)}),p(this,Rr,!1))}isEmpty(){return r(this,As)?r(this,zt)===null:!r(this,zt)&&!r(this,gs)}hasData(){return r(this,As)?r(this,zt)!==null||!!r(this,Ns):this.isEmpty()}get guessedText(){return r(this,Ns)}async setGuessedText(t){r(this,zt)===null&&(p(this,Ns,t),p(this,on,await he._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,os,Cl).call(this))}toggleAltTextBadge(t=!1){var e;if(!r(this,As)||r(this,zt)){(e=r(this,bs))==null||e.remove(),p(this,bs,null);return}if(!r(this,bs)){const s=p(this,bs,document.createElement("div"));s.className="noAltTextBadge",r(this,be).div.append(s)}r(this,bs).classList.toggle("hidden",!t)}serialize(t){let e=r(this,zt);return!t&&r(this,Ns)===e&&(e=r(this,on)),{altText:e,decorative:r(this,gs),guessedText:r(this,Ns),textWithDisclaimer:r(this,on)}}get data(){return{altText:r(this,zt),decorative:r(this,gs)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(p(this,Ns,s),p(this,on,i)),!(r(this,zt)===t&&r(this,gs)===e)&&(n||(p(this,zt,t),p(this,gs,e)),m(this,os,Cl).call(this))}toggle(t=!1){r(this,Qe)&&(!t&&r(this,Se)&&(clearTimeout(r(this,Se)),p(this,Se,null)),r(this,Qe).disabled=!t)}shown(){r(this,be)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:r(this,os,Ra)}})}destroy(){var t,e;(t=r(this,Qe))==null||t.remove(),p(this,Qe,null),p(this,Tr,null),p(this,ms,null),(e=r(this,bs))==null||e.remove(),p(this,bs,null)}};zt=new WeakMap,gs=new WeakMap,Qe=new WeakMap,Tr=new WeakMap,ms=new WeakMap,Se=new WeakMap,Rr=new WeakMap,bs=new WeakMap,be=new WeakMap,Ns=new WeakMap,on=new WeakMap,As=new WeakMap,_i=new WeakMap,os=new WeakSet,Ra=function(){return r(this,zt)&&"added"||r(this,zt)===null&&this.guessedText&&"review"||"missing"},Cl=async function(){var i,n,a;const t=r(this,Qe);if(!t)return;if(r(this,As)){if(t.classList.toggle("done",!!r(this,zt)),t.setAttribute("data-l10n-id",r(he,_i)[r(this,os,Ra)]),(i=r(this,Tr))==null||i.setAttribute("data-l10n-id",r(he,_i)[`${r(this,os,Ra)}-label`]),!r(this,zt)){(n=r(this,ms))==null||n.remove();return}}else{if(!r(this,zt)&&!r(this,gs)){t.classList.remove("done"),(a=r(this,ms))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=r(this,ms);if(!e){p(this,ms,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${r(this,be).id}`;const o=100,l=r(this,be)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(r(this,Se)),p(this,Se,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,Se,setTimeout(()=>{p(this,Se,null),r(this,ms).classList.add("show"),r(this,be)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;r(this,Se)&&(clearTimeout(r(this,Se)),p(this,Se,null)),(c=r(this,ms))==null||c.classList.remove("show")},{signal:l})}r(this,gs)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=r(this,zt)),e.parentNode||t.append(e);const s=r(this,be).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},b(he,_i,null),z(he,"_l10n",null);let Ql=he;var ln,Je,At,Pr,hn,Vt,cn,wi,oo,dn,Ei,lo,un,Hs,ys,kr,Lr,Oe,ho,ah,Y,tc,co,ec,sc,wu,Eu,ic,nc,rc,Su,ac,xu,Cu,Tu,oc,Pa;const rt=class rt{constructor(t){b(this,Y);b(this,ln,null);b(this,Je,null);b(this,At,null);b(this,Pr,!1);b(this,hn,!1);b(this,Vt,null);b(this,cn,null);b(this,wi,null);b(this,oo,"");b(this,dn,!1);b(this,Ei,null);b(this,lo,!1);b(this,un,!1);b(this,Hs,!1);b(this,ys,null);b(this,kr,0);b(this,Lr,0);b(this,Oe,null);z(this,"_editToolbar",null);z(this,"_initialOptions",Object.create(null));z(this,"_initialData",null);z(this,"_isVisible",!0);z(this,"_uiManager",null);z(this,"_focusEventsAllowed",!0);b(this,ho,!1);b(this,ah,rt._zIndex++);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;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=rt.prototype._resizeWithKeyboard,e=Kn.TRANSLATE_SMALL,s=Kn.TRANSLATE_BIG;return tt(this,"_resizerKeyboardManager",new hl([[["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"],rt.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return tt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new ag({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(rt._l10n??(rt._l10n=t),rt._l10nResizer||(rt._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"})),rt._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);rt._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){pt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return r(this,ho)}set _isDraggable(t){var e;p(this,ho,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[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=r(this,ah)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):m(this,Y,Pa).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(r(this,dn)?p(this,dn,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/a,this.fixAndSetPosition()}translate(t,e){m(this,Y,tc).call(this,this.parentDimensions,t,e)}translateInPage(t,e){r(this,Ei)||p(this,Ei,[this.x,this.y]),m(this,Y,tc).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){r(this,Ei)||p(this,Ei,[this.x,this.y]);const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:c,y:d}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,d)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[o,l]=this.getBaseTranslation();n+=o,a+=l,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!r(this,Ei)&&(r(this,Ei)[0]!==this.x||r(this,Ei)[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=rt,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){const[e,s]=this.pageDimensions;let{x:i,y:n,width:a,height:o}=this;if(a*=e,o*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-a,i)),n=Math.max(0,Math.min(s-o,n));break;case 90:i=Math.max(0,Math.min(e-o,i)),n=Math.min(s,Math.max(a,n));break;case 180:i=Math.min(e,Math.max(a,i)),n=Math.min(s,Math.max(o,n));break;case 270:i=Math.min(e,Math.max(o,i)),n=Math.max(0,Math.min(s-a,n));break}this.x=i/=e,this.y=n/=s;const[l,c]=this.getBaseTranslation();i+=l,n+=c;const{style:d}=this.div;d.left=`${(100*i).toFixed(2)}%`,d.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return m(s=rt,co,ec).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=rt,co,ec).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,r(this,hn)||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!r(this,hn)&&e.endsWith("%");if(i&&n)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!r(this,hn)&&!n&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=r(this,At))==null||t.finish()}async addEditToolbar(){return this._editToolbar||r(this,un)?this._editToolbar:(this._editToolbar=new $h(this),this.div.append(this._editToolbar.render()),r(this,At)&&await this._editToolbar.addAltText(r(this,At)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=r(this,At))==null||t.destroy())}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){r(this,At)||(Ql.initialize(rt._l10n),p(this,At,new Ql(this)),r(this,ln)&&(r(this,At).data=r(this,ln),p(this,ln,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=r(this,At))==null?void 0:t.data}set altTextData(t){r(this,At)&&(r(this,At).data=t)}get guessedAltText(){var t;return(t=r(this,At))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=r(this,At))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=r(this,At))==null?void 0:e.serialize(t)}hasAltText(){return!!r(this,At)&&!r(this,At).isEmpty()}hasAltTextData(){var t;return((t=r(this,At))==null?void 0:t.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=r(this,Pr)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),m(this,Y,ac).call(this);const[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)}%`);const[s,i]=this.getInitialTranslation();return this.translate(s,i),Kl(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=de.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,dn,!0),this._isDraggable){m(this,Y,Su).call(this,t);return}m(this,Y,rc).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){r(this,ys)&&clearTimeout(r(this,ys)),p(this,ys,setTimeout(()=>{var t;p(this,ys,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,a]=this.pageDimensions,[o,l]=this.pageTranslation,c=t/i,d=e/i,u=this.x*n,f=this.y*a,g=this.width*n,A=this.height*a;switch(s){case 0:return[u+c+o,a-f-d-A+l,u+c+g+o,a-f-d+l];case 90:return[u+d+o,a-f+c+l,u+d+A+o,a-f+c+g+l];case 180:return[u-c-g+o,a-f+d+l,u-c+o,a-f+d+A+l];case 270:return[u-d-A+o,a-f-c-g+l,u-d+o,a-f-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,o=n-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[n,e-i,o,l];case 270:return[n,e-a,l,o];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){p(this,un,!0)}disableEditMode(){p(this,un,!1)}isInEditMode(){return r(this,un)}shouldGetKeyboardEvents(){return r(this,Hs)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){m(this,Y,ac).call(this)}rotate(t){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){pt("An editor must be serializable")}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,p(i,ln,t.accessibilityData);const[n,a]=i.pageDimensions,[o,l,c,d]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/n,i.y=l/a,i.width=c/n,i.height=d/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t;if((t=r(this,wi))==null||t.abort(),p(this,wi,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),r(this,ys)&&(clearTimeout(r(this,ys)),p(this,ys,null)),m(this,Y,Pa).call(this),this.removeEditToolbar(),r(this,Oe)){for(const e of r(this,Oe).values())clearTimeout(e);p(this,Oe,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,Y,wu).call(this),r(this,Vt).classList.remove("hidden"),Kl(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),p(this,cn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=r(this,Vt).children;if(!r(this,Je)){p(this,Je,Array.from(e));const a=m(this,Y,xu).bind(this),o=m(this,Y,Cu).bind(this),l=this._uiManager._signal;for(const c of r(this,Je)){const d=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",a,{signal:l}),c.addEventListener("blur",o,{signal:l}),c.addEventListener("focus",m(this,Y,Tu).bind(this,d),{signal:l}),c.setAttribute("data-l10n-id",rt._l10nResizer[d])}}const s=r(this,Je)[0];let i=0;for(const a of e){if(a===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(r(this,Je).length/4);if(n!==i){if(n<i)for(let o=0;o<i-n;o++)r(this,Vt).append(r(this,Vt).firstChild);else if(n>i)for(let o=0;o<n-i;o++)r(this,Vt).firstChild.before(r(this,Vt).lastChild);let a=0;for(const o of e){const c=r(this,Je)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",rt._l10nResizer[c])}}m(this,Y,oc).call(this,0),p(this,Hs,!0),r(this,Vt).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){r(this,Hs)&&m(this,Y,nc).call(this,r(this,oo),{movementX:t,movementY:e})}_stopResizingWithKeyboard(){m(this,Y,Pa).call(this),this.div.focus()}select(){var t,e,s;if(this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,n;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((n=this._editToolbar)==null||n.show())});return}(e=this._editToolbar)==null||e.show(),(s=r(this,At))==null||s.toggleAltTextBadge(!1)}unselect(){var t,e,s,i,n;(t=r(this,Vt))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(n=r(this,At))==null||n.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return r(this,lo)}set isEditing(t){p(this,lo,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,hn,!0);const 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){r(this,Oe)||p(this,Oe,new Map);const{action:s}=t;let i=r(this,Oe).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),r(this,Oe).delete(s),r(this,Oe).size===0&&p(this,Oe,null)},rt._telemetryTimeout),r(this,Oe).set(s,i);return}t.type||(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),p(this,Pr,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,Pr,!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"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};ln=new WeakMap,Je=new WeakMap,At=new WeakMap,Pr=new WeakMap,hn=new WeakMap,Vt=new WeakMap,cn=new WeakMap,wi=new WeakMap,oo=new WeakMap,dn=new WeakMap,Ei=new WeakMap,lo=new WeakMap,un=new WeakMap,Hs=new WeakMap,ys=new WeakMap,kr=new WeakMap,Lr=new WeakMap,Oe=new WeakMap,ho=new WeakMap,ah=new WeakMap,Y=new WeakSet,tc=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()},co=new WeakSet,ec=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},sc=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},wu=function(){if(r(this,Vt))return;p(this,Vt,document.createElement("div")),r(this,Vt).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");r(this,Vt).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",m(this,Y,Eu).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ge,{signal:e}),i.tabIndex=-1}this.div.prepend(r(this,Vt))},Eu=function(t,e){var A;e.preventDefault();const{isMac:s}=de.platform;if(e.button!==0||e.ctrlKey&&s)return;(A=r(this,At))==null||A.toggle(!1);const i=this._isDraggable;this._isDraggable=!1;const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",m(this,Y,nc).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("contextmenu",Ge,{signal:a});const o=this.x,l=this.y,c=this.width,d=this.height,u=this.parent.div.style.cursor,f=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const g=()=>{var y;n.abort(),this.parent.togglePointerEvents(!0),(y=r(this,At))==null||y.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=u,this.div.style.cursor=f,m(this,Y,ic).call(this,o,l,c,d)};window.addEventListener("pointerup",g,{signal:a}),window.addEventListener("blur",g,{signal:a})},ic=function(t,e,s,i){const n=this.x,a=this.y,o=this.width,l=this.height;n===t&&a===e&&o===s&&l===i||this.addCommands({cmd:()=>{this.width=o,this.height=l,this.x=n,this.y=a;const[c,d]=this.parentDimensions;this.setDims(c*o,d*l),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[c,d]=this.parentDimensions;this.setDims(c*s,d*i),this.fixAndSetPosition()},mustExec:!0})},nc=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,o=this.width,l=this.height,c=rt.MIN_SIZE/s,d=rt.MIN_SIZE/i,u=D=>Math.round(D*1e4)/1e4,f=m(this,Y,sc).call(this,this.rotation),g=(D,j)=>[f[0]*D+f[2]*j,f[1]*D+f[3]*j],A=m(this,Y,sc).call(this,360-this.rotation),y=(D,j)=>[A[0]*D+A[2]*j,A[1]*D+A[3]*j];let _,v,w=!1,E=!1;switch(t){case"topLeft":w=!0,_=(D,j)=>[0,0],v=(D,j)=>[D,j];break;case"topMiddle":_=(D,j)=>[D/2,0],v=(D,j)=>[D/2,j];break;case"topRight":w=!0,_=(D,j)=>[D,0],v=(D,j)=>[0,j];break;case"middleRight":E=!0,_=(D,j)=>[D,j/2],v=(D,j)=>[0,j/2];break;case"bottomRight":w=!0,_=(D,j)=>[D,j],v=(D,j)=>[0,0];break;case"bottomMiddle":_=(D,j)=>[D/2,j],v=(D,j)=>[D/2,0];break;case"bottomLeft":w=!0,_=(D,j)=>[0,j],v=(D,j)=>[D,0];break;case"middleLeft":E=!0,_=(D,j)=>[0,j/2],v=(D,j)=>[D,j/2];break}const S=_(o,l),C=v(o,l);let x=g(...C);const T=u(n+x[0]),R=u(a+x[1]);let L=1,O=1,[I,J]=this.screenToPageTranslation(e.movementX,e.movementY);if([I,J]=y(I/s,J/i),w){const D=Math.hypot(o,l);L=O=Math.max(Math.min(Math.hypot(C[0]-S[0]-I,C[1]-S[1]-J)/D,1/o,1/l),c/o,d/l)}else E?L=Math.max(c,Math.min(1,Math.abs(C[0]-S[0]-I)))/o:O=Math.max(d,Math.min(1,Math.abs(C[1]-S[1]-J)))/l;const U=u(o*L),B=u(l*O);x=g(...v(U,B));const q=T-x[0],W=R-x[1];this.width=U,this.height=B,this.x=q,this.y=W,this.setDims(s*U,i*B),this.fixAndSetPosition()},rc=function(t){const{isMac:e}=de.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Su=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();const s=new AbortController,i=this._uiManager.combinedSignal(s);if(e){this.div.classList.add("moving"),p(this,kr,t.clientX),p(this,Lr,t.clientY);const a=o=>{const{clientX:l,clientY:c}=o,[d,u]=this.screenToPageTranslation(l-r(this,kr),c-r(this,Lr));p(this,kr,l),p(this,Lr,c),this._uiManager.dragSelectedEditors(d,u)};window.addEventListener("pointermove",a,{passive:!0,capture:!0,signal:i})}const n=()=>{s.abort(),e&&this.div.classList.remove("moving"),p(this,dn,!1),this._uiManager.endDragSession()||m(this,Y,rc).call(this,t)};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})},ac=function(){if(r(this,wi)||!this.div)return;p(this,wi,new AbortController);const t=this._uiManager.combinedSignal(r(this,wi));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},xu=function(t){rt._resizerKeyboardManager.exec(this,t)},Cu=function(t){var e;r(this,Hs)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==r(this,Vt)&&m(this,Y,Pa).call(this)},Tu=function(t){p(this,oo,r(this,Hs)?t:"")},oc=function(t){if(r(this,Je))for(const e of r(this,Je))e.tabIndex=t},Pa=function(){if(p(this,Hs,!1),m(this,Y,oc).call(this,-1),r(this,cn)){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=r(this,cn);m(this,Y,ic).call(this,t,e,s,i),p(this,cn,null)}},b(rt,co),z(rt,"_l10n",null),z(rt,"_l10nResizer",null),z(rt,"_borderLineWidth",-1),z(rt,"_colorManager",new qh),z(rt,"_zIndex",1),z(rt,"_telemetryTimeout",1e3);let lt=rt;class ag extends lt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Td=3285377520,Fe=4294901760,hs=65535;class Ru{constructor(t){this.h1=t?t&4294967295:Td,this.h2=t?t&4294967295:Td}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let y=0,_=t.length;y<_;y++){const v=t.charCodeAt(y);v<=255?e[s++]=v:(e[s++]=v>>>8,e[s++]=v&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.");const i=s>>2,n=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,c=this.h1,d=this.h2;const u=3432918353,f=461845907,g=u&hs,A=f&hs;for(let y=0;y<i;y++)y&1?(o=a[y],o=o*u&Fe|o*g&hs,o=o<<15|o>>>17,o=o*f&Fe|o*A&hs,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[y],l=l*u&Fe|l*g&hs,l=l<<15|l>>>17,l=l*f&Fe|l*A&hs,d^=l,d=d<<13|d>>>19,d=d*5+3864292196);switch(o=0,n){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*u&Fe|o*g&hs,o=o<<15|o>>>17,o=o*f&Fe|o*A&hs,i&1?c^=o:d^=o}this.h1=c,this.h2=d}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Fe|t*36045&hs,e=e*4283543511&Fe|((e<<16|t>>>16)*2950163797&Fe)>>>16,t^=e>>>1,t=t*444984403&Fe|t*60499&hs,e=e*3301882366&Fe|((e<<16|t>>>16)*3120437893&Fe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const lc=Object.freeze({map:null,hash:"",transfer:void 0});var fn,pn,Gt,oh,Pu;class ud{constructor(){b(this,oh);b(this,fn,!1);b(this,pn,null);b(this,Gt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=r(this,Gt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return r(this,Gt).get(t)}remove(t){if(r(this,Gt).delete(t),r(this,Gt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of r(this,Gt).values())if(e instanceof lt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=r(this,Gt).get(t);let i=!1;if(s!==void 0)for(const[n,a]of Object.entries(e))s[n]!==a&&(i=!0,s[n]=a);else i=!0,r(this,Gt).set(t,e);i&&m(this,oh,Pu).call(this),e instanceof lt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return r(this,Gt).has(t)}getAll(){return r(this,Gt).size>0?ad(r(this,Gt)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return r(this,Gt).size}resetModified(){r(this,fn)&&(p(this,fn,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new ku(this)}get serializable(){if(r(this,Gt).size===0)return lc;const t=new Map,e=new Ru,s=[],i=Object.create(null);let n=!1;for(const[a,o]of r(this,Gt)){const l=o instanceof lt?o.serialize(!1,i):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),n||(n=!!l.bitmap))}if(n)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:lc}get editorStats(){let t=null;const e=new Map;for(const s of r(this,Gt).values()){if(!(s instanceof lt))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const a=t[n]||(t[n]=new Map);for(const[o,l]of Object.entries(i)){if(o==="type")continue;let c=a.get(o);c||(c=new Map,a.set(o,c));const d=c.get(l)??0;c.set(l,d+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){p(this,pn,null)}get modifiedIds(){if(r(this,pn))return r(this,pn);const t=[];for(const e of r(this,Gt).values())!(e instanceof lt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return p(this,pn,{ids:new Set(t),hash:t.join(",")})}}fn=new WeakMap,pn=new WeakMap,Gt=new WeakMap,oh=new WeakSet,Pu=function(){r(this,fn)||(p(this,fn,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var uo;class ku extends ud{constructor(e){super();b(this,uo);const{map:s,hash:i,transfer:n}=e.serializable,a=structuredClone(s,n?{transfer:n}:null);p(this,uo,{map:a,hash:i,transfer:n})}get print(){pt("Should not call PrintAnnotationStorage.print")}get serializable(){return r(this,uo)}get modifiedIds(){return tt(this,"modifiedIds",{ids:new Set,hash:""})}}uo=new WeakMap;var Mr;class og{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){b(this,Mr,new Set);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));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),r(this,Mr).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||r(this,Mr).has(t.loadedName))){if(Dt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,a=new FontFace(s,i,n);this.addNativeFontFace(a);try{await a.load(),r(this,Mr).add(s),e==null||e(t)}catch{K(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}pt("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){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw K(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return tt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(re||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),tt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(Dt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return tt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(S,C){return S.charCodeAt(C)<<24|S.charCodeAt(C+1)<<16|S.charCodeAt(C+2)<<8|S.charCodeAt(C+3)&255}function i(S,C,x,T){const R=S.substring(0,C),L=S.substring(C+x);return R+T+L}let n,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let c=0;function d(S,C){if(++c>30){K("Load test font never loaded."),C();return}if(l.font="30px "+S,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(d.bind(null,S,C))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,u.length,u);const A=16,y=1482184792;let _=s(f,A);for(n=0,a=u.length-3;n<a;n+=4)_=_-y+s(u,n)|0;n<u.length&&(_=_-y+s(u+"XXX",n)|0),f=i(f,A,4,Wp(_));const v=`url(data:font/opentype;base64,${btoa(f)});`,w=`@font-face {font-family:"${u}";src:${v}}`;this.insertRule(w);const E=this._document.createElement("div");E.style.visibility="hidden",E.style.width=E.style.height="10px",E.style.position="absolute",E.style.top=E.style.left="0px";for(const S of[t.loadedName,u]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=S,E.append(C)}this._document.body.append(E),d(u,()=>{E.remove(),e.complete()})}}Mr=new WeakMap;class lg{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Qp(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){K(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,a){};const i=[];for(let n=0,a=s.length;n<a;)switch(s[n++]){case Ps.BEZIER_CURVE_TO:{const[o,l,c,d,u,f]=s.slice(n,n+6);i.push(g=>g.bezierCurveTo(o,l,c,d,u,f)),n+=6}break;case Ps.MOVE_TO:{const[o,l]=s.slice(n,n+2);i.push(c=>c.moveTo(o,l)),n+=2}break;case Ps.LINE_TO:{const[o,l]=s.slice(n,n+2);i.push(c=>c.lineTo(o,l)),n+=2}break;case Ps.QUADRATIC_CURVE_TO:{const[o,l,c,d]=s.slice(n,n+4);i.push(u=>u.quadraticCurveTo(o,l,c,d)),n+=4}break;case Ps.RESTORE:i.push(o=>o.restore());break;case Ps.SAVE:i.push(o=>o.save());break;case Ps.SCALE:Dt(i.length===2,"Scale command is only valid at the third position.");break;case Ps.TRANSFORM:{const[o,l,c,d,u,f]=s.slice(n,n+6);i.push(g=>g.transform(o,l,c,d,u,f)),n+=6}break;case Ps.TRANSLATE:{const[o,l]=s.slice(n,n+2);i.push(c=>c.translate(o,l)),n+=2}break}return this.compiledGlyphs[e]=function(a,o){i[0](a),i[1](a),a.scale(o,-o);for(let l=2,c=i.length;l<c;l++)i[l](a)}}}var fo;class Lu{constructor({enableHWA:t=!1}){b(this,fo,!1);p(this,fo,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!r(this,fo)})}}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){pt("Abstract method `_createCanvas` called.")}}fo=new WeakMap;class hg extends Lu{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Mu{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.");const 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){pt("Abstract method `_fetch` called.")}}class Iu extends Mu{async _fetch(t){const e=await Eh(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):wh(e)}}class Fu{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){}}var gn,mn,vs,js,se,lh,bn,M,te,ar,or,Tl,lr,Du,hc,hr,ka,La,cc,Ma;class cg extends Fu{constructor({docId:e,ownerDocument:s=globalThis.document}){super();b(this,M);b(this,gn);b(this,mn);b(this,vs);b(this,js);b(this,se);b(this,lh);b(this,bn,0);p(this,js,e),p(this,se,s)}addFilter(e){if(!e)return"none";let s=r(this,M,te).get(e);if(s)return s;const[i,n,a]=m(this,M,Tl).call(this,e),o=e.length===1?i:`${i}${n}${a}`;if(s=r(this,M,te).get(o),s)return r(this,M,te).set(e,s),s;const l=`g_${r(this,js)}_transfer_map_${oe(this,bn)._++}`,c=m(this,M,lr).call(this,l);r(this,M,te).set(e,c),r(this,M,te).set(o,c);const d=m(this,M,hr).call(this,l);return m(this,M,La).call(this,i,n,a,d),c}addHCMFilter(e,s){var A;const i=`${e}-${s}`,n="base";let a=r(this,M,ar).get(n);if((a==null?void 0:a.key)===i||(a?((A=a.filter)==null||A.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},r(this,M,ar).set(n,a)),!e||!s))return a.url;const o=m(this,M,Ma).call(this,e);e=N.makeHexColor(...o);const l=m(this,M,Ma).call(this,s);if(s=N.makeHexColor(...l),r(this,M,or).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=new Array(256);for(let y=0;y<=255;y++){const _=y/255;c[y]=_<=.03928?_/12.92:((_+.055)/1.055)**2.4}const d=c.join(","),u=`g_${r(this,js)}_hcm_filter`,f=a.filter=m(this,M,hr).call(this,u);m(this,M,La).call(this,d,d,d,f),m(this,M,hc).call(this,f);const g=(y,_)=>{const v=o[y]/255,w=l[y]/255,E=new Array(_+1);for(let S=0;S<=_;S++)E[S]=v+S/_*(w-v);return E.join(",")};return m(this,M,La).call(this,g(0,5),g(1,5),g(2,5),f),a.url=m(this,M,lr).call(this,u),a.url}addAlphaFilter(e){let s=r(this,M,te).get(e);if(s)return s;const[i]=m(this,M,Tl).call(this,[e]),n=`alpha_${i}`;if(s=r(this,M,te).get(n),s)return r(this,M,te).set(e,s),s;const a=`g_${r(this,js)}_alpha_map_${oe(this,bn)._++}`,o=m(this,M,lr).call(this,a);r(this,M,te).set(e,o),r(this,M,te).set(n,o);const l=m(this,M,hr).call(this,a);return m(this,M,cc).call(this,i,l),o}addLuminosityFilter(e){let s=r(this,M,te).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=m(this,M,Tl).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=r(this,M,te).get(n),s)return r(this,M,te).set(e,s),s;const a=`g_${r(this,js)}_luminosity_map_${oe(this,bn)._++}`,o=m(this,M,lr).call(this,a);r(this,M,te).set(e,o),r(this,M,te).set(n,o);const l=m(this,M,hr).call(this,a);return m(this,M,Du).call(this,l),e&&m(this,M,cc).call(this,i,l),o}addHighlightHCMFilter(e,s,i,n,a){var w;const o=`${s}-${i}-${n}-${a}`;let l=r(this,M,ar).get(e);if((l==null?void 0:l.key)===o||(l?((w=l.filter)==null||w.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},r(this,M,ar).set(e,l)),!s||!i))return l.url;const[c,d]=[s,i].map(m(this,M,Ma).bind(this));let u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[g,A]=[n,a].map(m(this,M,Ma).bind(this));f<u&&([u,f,g,A]=[f,u,A,g]),r(this,M,or).style.color="";const y=(E,S,C)=>{const x=new Array(256),T=(f-u)/C,R=E/255,L=(S-E)/(255*C);let O=0;for(let I=0;I<=C;I++){const J=Math.round(u+I*T),U=R+I*L;for(let B=O;B<=J;B++)x[B]=U;O=J+1}for(let I=O;I<256;I++)x[I]=x[O-1];return x.join(",")},_=`g_${r(this,js)}_hcm_${e}_filter`,v=l.filter=m(this,M,hr).call(this,_);return m(this,M,hc).call(this,v),m(this,M,La).call(this,y(g[0],A[0],5),y(g[1],A[1],5),y(g[2],A[2],5),v),l.url=m(this,M,lr).call(this,_),l.url}destroy(e=!1){e&&r(this,M,ar).size!==0||(r(this,vs)&&(r(this,vs).parentNode.parentNode.remove(),p(this,vs,null)),r(this,mn)&&(r(this,mn).clear(),p(this,mn,null)),p(this,bn,0))}}gn=new WeakMap,mn=new WeakMap,vs=new WeakMap,js=new WeakMap,se=new WeakMap,lh=new WeakMap,bn=new WeakMap,M=new WeakSet,te=function(){return r(this,mn)||p(this,mn,new Map)},ar=function(){return r(this,lh)||p(this,lh,new Map)},or=function(){if(!r(this,vs)){const e=r(this,se).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=r(this,se).createElementNS(Ls,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,vs,r(this,se).createElementNS(Ls,"defs")),e.append(i),i.append(r(this,vs)),r(this,se).body.append(e)}return r(this,vs)},Tl=function(e){if(e.length===1){const c=e[0],d=new Array(256);for(let f=0;f<256;f++)d[f]=c[f]/255;const u=d.join(",");return[u,u,u]}const[s,i,n]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let c=0;c<256;c++)a[c]=s[c]/255,o[c]=i[c]/255,l[c]=n[c]/255;return[a.join(","),o.join(","),l.join(",")]},lr=function(e){if(r(this,gn)===void 0){p(this,gn,"");const s=r(this,se).URL;s!==r(this,se).baseURI&&(Sh(s)?K('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,gn,s.split("#",1)[0]))}return`url(${r(this,gn)}#${e})`},Du=function(e){const s=r(this,se).createElementNS(Ls,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(s)},hc=function(e){const s=r(this,se).createElementNS(Ls,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(s)},hr=function(e){const s=r(this,se).createElementNS(Ls,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),r(this,M,or).append(s),s},ka=function(e,s,i){const n=r(this,se).createElementNS(Ls,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},La=function(e,s,i,n){const a=r(this,se).createElementNS(Ls,"feComponentTransfer");n.append(a),m(this,M,ka).call(this,a,"feFuncR",e),m(this,M,ka).call(this,a,"feFuncG",s),m(this,M,ka).call(this,a,"feFuncB",i)},cc=function(e,s){const i=r(this,se).createElementNS(Ls,"feComponentTransfer");s.append(i),m(this,M,ka).call(this,i,"feFuncA",e)},Ma=function(e){return r(this,M,or).style.color=e,dd(getComputedStyle(r(this,M,or)).getPropertyValue("color"))};class Ou{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.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){pt("Abstract method `_fetch` called.")}}class Nu extends Ou{async _fetch(t){const e=await Eh(t,"arraybuffer");return new Uint8Array(e)}}if(re){var dc=Promise.withResolvers(),Ga=null;(async()=>{const t=await Promise.resolve().then(()=>require("./__vite-browser-external-BcPniuRQ.cjs")),e=await Promise.resolve().then(()=>require("./__vite-browser-external-BcPniuRQ.cjs")),s=await Promise.resolve().then(()=>require("./__vite-browser-external-BcPniuRQ.cjs")),i=await Promise.resolve().then(()=>require("./__vite-browser-external-BcPniuRQ.cjs"));let n,a;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:a}))})().then(t=>{Ga=t,dc.resolve()},t=>{K(`loadPackages: ${t}`),Ga=new Map,dc.resolve()})}class Ui{static get promise(){return dc.promise}static get(t){return Ga==null?void 0:Ga.get(t)}}async function Hu(h){const e=await Ui.get("fs").promises.readFile(h);return new Uint8Array(e)}class dg extends Fu{}class ug extends Lu{_createCanvas(t,e){return Ui.get("canvas").createCanvas(t,e)}}class fg extends Mu{async _fetch(t){return Hu(t)}}class pg extends Ou{async _fetch(t){return Hu(t)}}const ce={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function uc(h,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),h.clip(i)}class fd{getPattern(){pt("Abstract method `getPattern` called.")}}class gg extends fd{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(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===ce.STROKE||i===ce.FILL){const a=e.current.getClippedPathBoundingBox(i,vt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,c=e.cachedCanvases.getCanvas("pattern",o,l),d=c.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-a[0],-a[1]),s=N.transform(s,[1,0,0,1,a[0],a[1]]),d.transform(...e.baseTransform),this.matrix&&d.transform(...this.matrix),uc(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),n=t.createPattern(c.canvas,"no-repeat");const u=new DOMMatrix(s);n.setTransform(u)}else uc(t,this._bbox),n=this._createGradient(t);return n}}function Ih(h,t,e,s,i,n,a,o){const l=t.coords,c=t.colors,d=h.data,u=h.width*4;let f;l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=n,n=a,a=f),l[s+1]>l[i+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=n,n=a,a=f);const g=(l[e]+t.offsetX)*t.scaleX,A=(l[e+1]+t.offsetY)*t.scaleY,y=(l[s]+t.offsetX)*t.scaleX,_=(l[s+1]+t.offsetY)*t.scaleY,v=(l[i]+t.offsetX)*t.scaleX,w=(l[i+1]+t.offsetY)*t.scaleY;if(A>=w)return;const E=c[n],S=c[n+1],C=c[n+2],x=c[a],T=c[a+1],R=c[a+2],L=c[o],O=c[o+1],I=c[o+2],J=Math.round(A),U=Math.round(w);let B,q,W,D,j,Kt,ae,Qt;for(let _t=J;_t<=U;_t++){if(_t<_){const nt=_t<A?0:(A-_t)/(A-_);B=g-(g-y)*nt,q=E-(E-x)*nt,W=S-(S-T)*nt,D=C-(C-R)*nt}else{let nt;_t>w?nt=1:_===w?nt=0:nt=(_-_t)/(_-w),B=y-(y-v)*nt,q=x-(x-L)*nt,W=T-(T-O)*nt,D=R-(R-I)*nt}let ft;_t<A?ft=0:_t>w?ft=1:ft=(A-_t)/(A-w),j=g-(g-v)*ft,Kt=E-(E-L)*ft,ae=S-(S-O)*ft,Qt=C-(C-I)*ft;const pe=Math.round(Math.min(B,j)),$e=Math.round(Math.max(B,j));let St=u*_t+pe*4;for(let nt=pe;nt<=$e;nt++)ft=(B-nt)/(B-j),ft<0?ft=0:ft>1&&(ft=1),d[St++]=q-(q-Kt)*ft|0,d[St++]=W-(W-ae)*ft|0,d[St++]=D-(D-Qt)*ft|0,d[St++]=255}}function mg(h,t,e){const s=t.coords,i=t.colors;let n,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,c=o-1;for(n=0;n<l;n++){let d=n*o;for(let u=0;u<c;u++,d++)Ih(h,e,s[d],s[d+1],s[d+o],i[d],i[d+1],i[d+o]),Ih(h,e,s[d+o+1],s[d+1],s[d+o],i[d+o+1],i[d+1],i[d+o])}break;case"triangles":for(n=0,a=s.length;n<a;n+=3)Ih(h,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class bg extends fd{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){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,d=Math.ceil(this._bounds[3])-l,u=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(d*t[1]*1.1)),3e3),g=c/u,A=d/f,y={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/A},_=u+4,v=f+4,w=s.getCanvas("mesh",_,v),E=w.context,S=E.createImageData(u,f);if(e){const x=S.data;for(let T=0,R=x.length;T<R;T+=4)x[T]=e[0],x[T+1]=e[1],x[T+2]=e[2],x[T+3]=255}for(const x of this._figures)mg(S,x,y);return E.putImageData(S,2,2),{canvas:w.canvas,offsetX:o-2*g,offsetY:l-2*A,scaleX:g,scaleY:A}}getPattern(t,e,s,i){uc(t,this._bbox);let n;if(i===ce.SHADING)n=N.singularValueDecompose2dScale(vt(t));else if(n=N.singularValueDecompose2dScale(e.baseTransform),this.matrix){const o=N.singularValueDecompose2dScale(this.matrix);n=[n[0]*o[0],n[1]*o[1]]}const a=this._createMeshCanvas(n,i===ce.SHADING?null:this._background,e.cachedCanvases);return i!==ce.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class Ag extends fd{getPattern(){return"hotpink"}}function yg(h){switch(h[0]){case"RadialAxial":return new gg(h);case"Mesh":return new bg(h);case"Dummy":return new Ag}throw new Error(`Unknown IR type: ${h[0]}`)}const Rd={COLORED:1,UNCOLORED:2},hh=class hh{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){const{bbox:e,operatorList:s,paintType:i,tilingType:n,color:a,canvasGraphicsFactory:o}=this;let{xstep:l,ystep:c}=this;l=Math.abs(l),c=Math.abs(c),vh("TilingType: "+n);const d=e[0],u=e[1],f=e[2],g=e[3],A=f-d,y=g-u,_=N.singularValueDecompose2dScale(this.matrix),v=N.singularValueDecompose2dScale(this.baseTransform),w=_[0]*v[0],E=_[1]*v[1];let S=A,C=y,x=!1,T=!1;const R=Math.ceil(l*w),L=Math.ceil(c*E),O=Math.ceil(A*w),I=Math.ceil(y*E);R>=O?S=l:x=!0,L>=I?C=c:T=!0;const J=this.getSizeAndScale(S,this.ctx.canvas.width,w),U=this.getSizeAndScale(C,this.ctx.canvas.height,E),B=t.cachedCanvases.getCanvas("pattern",J.size,U.size),q=B.context,W=o.createCanvasGraphics(q);if(W.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(W,i,a),q.translate(-J.scale*d,-U.scale*u),W.transform(J.scale,0,0,U.scale,0,0),q.save(),this.clipBbox(W,d,u,f,g),W.baseTransform=vt(W.ctx),W.executeOperatorList(s),W.endDrawing(),q.restore(),x||T){const D=B.canvas;x&&(S=l),T&&(C=c);const j=this.getSizeAndScale(S,this.ctx.canvas.width,w),Kt=this.getSizeAndScale(C,this.ctx.canvas.height,E),ae=j.size,Qt=Kt.size,_t=t.cachedCanvases.getCanvas("pattern-workaround",ae,Qt),ft=_t.context,pe=x?Math.floor(A/l):0,$e=T?Math.floor(y/c):0;for(let St=0;St<=pe;St++)for(let nt=0;nt<=$e;nt++)ft.drawImage(D,ae*St,Qt*nt,ae,Qt,0,0,ae,Qt);return{canvas:_t.canvas,scaleX:j.scale,scaleY:Kt.scale,offsetX:d,offsetY:u}}return{canvas:B.canvas,scaleX:J.scale,scaleY:U.scale,offsetX:d,offsetY:u}}getSizeAndScale(t,e,s){const i=Math.max(hh.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const a=i-e,o=n-s;t.ctx.rect(e,s,a,o),t.current.updateRectMinMax(vt(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Rd.COLORED:const a=this.ctx;i.fillStyle=a.fillStyle,i.strokeStyle=a.strokeStyle,n.fillColor=a.fillStyle,n.strokeColor=a.strokeStyle;break;case Rd.UNCOLORED:const o=N.makeHexColor(s[0],s[1],s[2]);i.fillStyle=o,i.strokeStyle=o,n.fillColor=o,n.strokeColor=o;break;default:throw new $p(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==ce.SHADING&&(n=N.transform(n,e.baseTransform),this.matrix&&(n=N.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let o=new DOMMatrix(n);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}};z(hh,"MAX_PATTERN_SIZE",3e3);let fc=hh;function vg({src:h,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:a=!1}){const o=de.isLittleEndian?4278190080:255,[l,c]=a?[n,o]:[o,n],d=s>>3,u=s&7,f=h.length;e=new Uint32Array(e.buffer);let g=0;for(let A=0;A<i;A++){for(const _=t+d;t<_;t++){const v=t<f?h[t]:255;e[g++]=v&128?c:l,e[g++]=v&64?c:l,e[g++]=v&32?c:l,e[g++]=v&16?c:l,e[g++]=v&8?c:l,e[g++]=v&4?c:l,e[g++]=v&2?c:l,e[g++]=v&1?c:l}if(u===0)continue;const y=t<f?h[t++]:255;for(let _=0;_<u;_++)e[g++]=y&1<<7-_?c:l}return{srcPos:t,destPos:g}}const Pd=16,kd=100,_g=15,Ld=10,Md=1e3,ve=16;function wg(h,t){if(h._removeMirroring)throw new Error("Context is already forwarding operations.");h.__originalSave=h.save,h.__originalRestore=h.restore,h.__originalRotate=h.rotate,h.__originalScale=h.scale,h.__originalTranslate=h.translate,h.__originalTransform=h.transform,h.__originalSetTransform=h.setTransform,h.__originalResetTransform=h.resetTransform,h.__originalClip=h.clip,h.__originalMoveTo=h.moveTo,h.__originalLineTo=h.lineTo,h.__originalBezierCurveTo=h.bezierCurveTo,h.__originalRect=h.rect,h.__originalClosePath=h.closePath,h.__originalBeginPath=h.beginPath,h._removeMirroring=()=>{h.save=h.__originalSave,h.restore=h.__originalRestore,h.rotate=h.__originalRotate,h.scale=h.__originalScale,h.translate=h.__originalTranslate,h.transform=h.__originalTransform,h.setTransform=h.__originalSetTransform,h.resetTransform=h.__originalResetTransform,h.clip=h.__originalClip,h.moveTo=h.__originalMoveTo,h.lineTo=h.__originalLineTo,h.bezierCurveTo=h.__originalBezierCurveTo,h.rect=h.__originalRect,h.closePath=h.__originalClosePath,h.beginPath=h.__originalBeginPath,delete h._removeMirroring},h.save=function(){t.save(),this.__originalSave()},h.restore=function(){t.restore(),this.__originalRestore()},h.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},h.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},h.transform=function(s,i,n,a,o,l){t.transform(s,i,n,a,o,l),this.__originalTransform(s,i,n,a,o,l)},h.setTransform=function(s,i,n,a,o,l){t.setTransform(s,i,n,a,o,l),this.__originalSetTransform(s,i,n,a,o,l)},h.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},h.rotate=function(s){t.rotate(s),this.__originalRotate(s)},h.clip=function(s){t.clip(s),this.__originalClip(s)},h.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},h.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},h.bezierCurveTo=function(e,s,i,n,a,o){t.bezierCurveTo(e,s,i,n,a,o),this.__originalBezierCurveTo(e,s,i,n,a,o)},h.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},h.closePath=function(){t.closePath(),this.__originalClosePath()},h.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Eg{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(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function gl(h,t,e,s,i,n,a,o,l,c){const[d,u,f,g,A,y]=vt(h);if(u===0&&f===0){const w=a*d+A,E=Math.round(w),S=o*g+y,C=Math.round(S),x=(a+l)*d+A,T=Math.abs(Math.round(x)-E)||1,R=(o+c)*g+y,L=Math.abs(Math.round(R)-C)||1;return h.setTransform(Math.sign(d),0,0,Math.sign(g),E,C),h.drawImage(t,e,s,i,n,0,0,T,L),h.setTransform(d,u,f,g,A,y),[T,L]}if(d===0&&g===0){const w=o*f+A,E=Math.round(w),S=a*u+y,C=Math.round(S),x=(o+c)*f+A,T=Math.abs(Math.round(x)-E)||1,R=(a+l)*u+y,L=Math.abs(Math.round(R)-C)||1;return h.setTransform(0,Math.sign(u),Math.sign(f),0,E,C),h.drawImage(t,e,s,i,n,0,0,L,T),h.setTransform(d,u,f,g,A,y),[L,T]}h.drawImage(t,e,s,i,n,a,o,l,c);const _=Math.hypot(d,u),v=Math.hypot(f,g);return[_*l,v*c]}function Sg(h){const{width:t,height:e}=h;if(t>Md||e>Md)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let a=new Uint8Array(n*(e+1)),o,l,c;const d=t+7&-8;let u=new Uint8Array(d*e),f=0;for(const v of h.data){let w=128;for(;w>0;)u[f++]=v&w?0:255,w>>=1}let g=0;for(f=0,u[f]!==0&&(a[0]=1,++g),l=1;l<t;l++)u[f]!==u[f+1]&&(a[l]=u[f]?2:1,++g),f++;for(u[f]!==0&&(a[l]=2,++g),o=1;o<e;o++){f=o*d,c=o*n,u[f-d]!==u[f]&&(a[c]=u[f]?1:8,++g);let v=(u[f]?4:0)+(u[f-d]?8:0);for(l=1;l<t;l++)v=(v>>2)+(u[f+1]?4:0)+(u[f-d+1]?8:0),i[v]&&(a[c+l]=i[v],++g),f++;if(u[f-d]!==u[f]&&(a[c+l]=u[f]?2:4,++g),g>s)return null}for(f=d*(e-1),c=o*n,u[f]!==0&&(a[c]=8,++g),l=1;l<t;l++)u[f]!==u[f+1]&&(a[c+l]=u[f]?4:8,++g),f++;if(u[f]!==0&&(a[c+l]=4,++g),g>s)return null;const A=new Int32Array([0,n,-1,0,-n,0,0,0,1]),y=new Path2D;for(o=0;g&&o<=e;o++){let v=o*n;const w=v+t;for(;v<w&&!a[v];)v++;if(v===w)continue;y.moveTo(v%n,o);const E=v;let S=a[v];do{const C=A[S];do v+=C;while(!a[v]);const x=a[v];x!==5&&x!==10?(S=x,a[v]=0):(S=x&51*S>>4,a[v]&=S>>2|S<<2),y.lineTo(v%n,v/n|0),a[v]||--g}while(E!==v);--o}return u=null,a=null,function(v){v.save(),v.scale(1/t,-1/e),v.translate(0,-e),v.fill(y),v.beginPath(),v.restore()}}class Id{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=eu,this.textMatrixScale=1,this.fontMatrix=jh,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=Zt.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const 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]=N.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){const s=N.applyTransform(e,t),i=N.applyTransform(e.slice(2),t),n=N.applyTransform([e[0],e[3]],t),a=N.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],a[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],a[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],a[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],a[1])}updateScalingPathMinMax(t,e){N.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,a,o,l,c,d){const u=N.bezierBoundingBox(e,s,i,n,a,o,l,c,d);d||this.updateRectMinMax(t,u)}getPathBoundingBox(t=ce.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===ce.STROKE){e||pt("Stroke bounding box must include transform.");const i=N.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,a=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=a,s[2]+=n,s[3]+=a}return s}updateClipFromPath(){const t=N.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=ce.FILL,e=null){return N.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Fd(h,t){if(typeof ImageData<"u"&&t instanceof ImageData){h.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%ve,n=(e-i)/ve,a=i===0?n:n+1,o=h.createImageData(s,ve);let l=0,c;const d=t.data,u=o.data;let f,g,A,y;if(t.kind===vl.GRAYSCALE_1BPP){const _=d.byteLength,v=new Uint32Array(u.buffer,0,u.byteLength>>2),w=v.length,E=s+7>>3,S=4294967295,C=de.isLittleEndian?4278190080:255;for(f=0;f<a;f++){for(A=f<n?ve:i,c=0,g=0;g<A;g++){const x=_-l;let T=0;const R=x>E?s:x*8-7,L=R&-8;let O=0,I=0;for(;T<L;T+=8)I=d[l++],v[c++]=I&128?S:C,v[c++]=I&64?S:C,v[c++]=I&32?S:C,v[c++]=I&16?S:C,v[c++]=I&8?S:C,v[c++]=I&4?S:C,v[c++]=I&2?S:C,v[c++]=I&1?S:C;for(;T<R;T++)O===0&&(I=d[l++],O=128),v[c++]=I&O?S:C,O>>=1}for(;c<w;)v[c++]=0;h.putImageData(o,0,f*ve)}}else if(t.kind===vl.RGBA_32BPP){for(g=0,y=s*ve*4,f=0;f<n;f++)u.set(d.subarray(l,l+y)),l+=y,h.putImageData(o,0,g),g+=ve;f<a&&(y=s*i*4,u.set(d.subarray(l,l+y)),h.putImageData(o,0,g))}else if(t.kind===vl.RGB_24BPP)for(A=ve,y=s*A,f=0;f<a;f++){for(f>=n&&(A=i,y=s*A),c=0,g=y;g--;)u[c++]=d[l++],u[c++]=d[l++],u[c++]=d[l++],u[c++]=255;h.putImageData(o,0,f*ve)}else throw new Error(`bad image kind: ${t.kind}`)}function Dd(h,t){if(t.bitmap){h.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%ve,n=(e-i)/ve,a=i===0?n:n+1,o=h.createImageData(s,ve);let l=0;const c=t.data,d=o.data;for(let u=0;u<a;u++){const f=u<n?ve:i;({srcPos:l}=vg({src:c,srcPos:l,dest:d,width:s,height:f,nonBlackColor:0})),h.putImageData(o,0,u*ve)}}function Sa(h,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)h[s]!==void 0&&(t[s]=h[s]);h.setLineDash!==void 0&&(t.setLineDash(h.getLineDash()),t.lineDashOffset=h.lineDashOffset)}function ml(h){if(h.strokeStyle=h.fillStyle="#000000",h.fillRule="nonzero",h.globalAlpha=1,h.lineWidth=1,h.lineCap="butt",h.lineJoin="miter",h.miterLimit=10,h.globalCompositeOperation="source-over",h.font="10px sans-serif",h.setLineDash!==void 0&&(h.setLineDash([]),h.lineDashOffset=0),!re){const{filter:t}=h;t!=="none"&&t!==""&&(h.filter="none")}}function Od(h,t){if(t)return!0;const e=N.singularValueDecompose2dScale(h);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Bi.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const xg=["butt","round","square"],Cg=["miter","round","bevel"],Tg={},Nd={};var $i,pc,gc;const _d=class _d{constructor(t,e,s,i,n,{optionalContentConfig:a,markedContentStack:o=null},l,c){b(this,$i);this.ctx=t,this.current=new Id(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=o||[],this.optionalContentConfig=a,this.cachedCanvases=new Eg(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,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}){const n=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=o,s){const l=this.cachedCanvases.getCanvas("transparent",n,a);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...vt(this.compositeCtx))}this.ctx.save(),ml(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=vt(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,a=t.fnArray;let o=e||0;const l=n.length;if(l===o)return o;const c=l-o>Ld&&typeof s=="function",d=c?Date.now()+_g:0;let u=0;const f=this.commonObjs,g=this.objs;let A;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(A=a[o],A!==qe.dependency)this[A].apply(this,n[o]);else for(const y of n[o]){const _=y.startsWith("g_")?f:g;if(!_.has(y))return _.get(y,s),o}if(o++,o===l)return o;if(c&&++u>Ld){if(Date.now()>d)return s(),o;u=0}}}endDrawing(){m(this,$i,pc).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),m(this,$i,gc).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let n=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=s,l=i,c="prescale1",d,u;for(;n>2&&o>1||a>2&&l>1;){let f=o,g=l;n>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),n/=o/f),a>2&&l>1&&(g=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/g),d=this.cachedCanvases.getCanvas(c,f,g),u=d.context,u.clearRect(0,0,f,g),u.drawImage(t,0,0,o,l,0,0,f,g),t=d.canvas,o=f,l=g,c=c==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,a=this.current.patternFill,o=vt(e);let l,c,d,u;if((t.bitmap||t.data)&&t.count>1){const R=t.bitmap||t.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),n]),l=this._cachedBitmapsMap.get(R),l||(l=new Map,this._cachedBitmapsMap.set(R,l));const L=l.get(c);if(L&&!a){const O=Math.round(Math.min(o[0],o[2])+o[4]),I=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:L,offsetX:O,offsetY:I}}d=L}d||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),Dd(u.context,t));let f=N.transform(o,[1/s,0,0,-1/i,0,0]);f=N.transform(f,[1,0,0,1,0,-i]);const[g,A,y,_]=N.getAxialAlignedBoundingBox([0,0,s,i],f),v=Math.round(y-g)||1,w=Math.round(_-A)||1,E=this.cachedCanvases.getCanvas("fillCanvas",v,w),S=E.context,C=g,x=A;S.translate(-C,-x),S.transform(...f),d||(d=this._scaleImage(u.canvas,ks(S)),d=d.img,l&&a&&l.set(c,d)),S.imageSmoothingEnabled=Od(vt(S),t.interpolate),gl(S,d,0,0,d.width,d.height,0,0,s,i),S.globalCompositeOperation="source-in";const T=N.transform(ks(S),[1,0,0,1,-C,-x]);return S.fillStyle=a?n.getPattern(e,this,T,ce.FILL):n,S.fillRect(0,0,s,i),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,E.canvas)),{canvas:E.canvas,offsetX:Math.round(C),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=xg[t]}setLineJoin(t){this.ctx.lineJoin=Cg[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[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(){const 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");const 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;const n=this.ctx;n.setTransform(...vt(this.suspendedCtx)),Sa(this.suspendedCtx,n),wg(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(),Sa(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];const 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){const n=i[0],a=i[1],o=i[2]-n,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,n,a,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,a,o,l,c,d,u){let f=t.canvas,g=l-d,A=c-u;if(a){const _=N.makeHexColor(...a);if(g<0||A<0||g+s>f.width||A+i>f.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),w=v.context;w.drawImage(f,-g,-A),w.globalCompositeOperation="destination-atop",w.fillStyle=_,w.fillRect(0,0,s,i),w.globalCompositeOperation="source-over",f=v.canvas,g=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(g,A,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=_,t.fillRect(g,A,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const y=new Path2D;y.rect(l,c,s,i),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(f,g,A,s,i,l,c,s,i),e.restore()}save(){this.inSMaskMode?(Sa(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const 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(),Sa(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,a){this.ctx.transform(t,e,s,i,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let a=n.x,o=n.y,l,c;const d=vt(i),u=d[0]===0&&d[3]===0||d[1]===0&&d[2]===0,f=u?s.slice(0):null;for(let g=0,A=0,y=t.length;g<y;g++)switch(t[g]|0){case qe.rectangle:a=e[A++],o=e[A++];const _=e[A++],v=e[A++],w=a+_,E=o+v;i.moveTo(a,o),_===0||v===0?i.lineTo(w,E):(i.lineTo(w,o),i.lineTo(w,E),i.lineTo(a,E)),u||n.updateRectMinMax(d,[a,o,w,E]),i.closePath();break;case qe.moveTo:a=e[A++],o=e[A++],i.moveTo(a,o),u||n.updatePathMinMax(d,a,o);break;case qe.lineTo:a=e[A++],o=e[A++],i.lineTo(a,o),u||n.updatePathMinMax(d,a,o);break;case qe.curveTo:l=a,c=o,a=e[A+4],o=e[A+5],i.bezierCurveTo(e[A],e[A+1],e[A+2],e[A+3],a,o),n.updateCurvePathMinMax(d,l,c,e[A],e[A+1],e[A+2],e[A+3],a,o,f),A+=6;break;case qe.curveTo2:l=a,c=o,i.bezierCurveTo(a,o,e[A],e[A+1],e[A+2],e[A+3]),n.updateCurvePathMinMax(d,l,c,a,o,e[A],e[A+1],e[A+2],e[A+3],f),a=e[A+2],o=e[A+3],A+=4;break;case qe.curveTo3:l=a,c=o,a=e[A+2],o=e[A+3],i.bezierCurveTo(e[A],e[A+1],a,o,a,o),n.updateCurvePathMinMax(d,l,c,e[A],e[A+1],a,o,a,o,f),A+=4;break;case qe.closePath:i.closePath();break}u&&n.updateScalingPathMinMax(d,f),n.setCurrentPoint(a,o)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&(s!=null&&s.getPattern)?(e.save(),e.strokeStyle=s.getPattern(e,this,ks(e),ce.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){const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;let n=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,ks(e),ce.FILL),n=!0);const a=this.current.getClippedPathBoundingBox();this.contentVisible&&a!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(a)}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=Tg}eoClip(){this.pendingClip=Nd}beginText(){this.current.textMatrix=eu,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var d;const s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||jh,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&K("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;const n=s.loadedName||"sans-serif",a=((d=s.systemFontInfo)==null?void 0:d.css)||`"${n}", ${s.fallbackName}`;let o="normal";s.black?o="900":s.bold&&(o="bold");const l=s.italic?"italic":"normal";let c=e;e<Pd?c=Pd:e>kd&&(c=kd),this.current.fontSizeScale=e/c,this.ctx.font=`${l} ${o} ${c}px ${a}`}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,a){this.current.textMatrix=[t,e,s,i,n,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const n=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,d=l&Zt.FILL_STROKE_MASK,u=!!(l&Zt.ADD_TO_PATH_FLAG),f=a.patternFill&&!o.missingFile;let g;(o.disableFontFace||u||f)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||f?(n.save(),n.translate(e,s),n.beginPath(),g(n,c),i&&n.setTransform(...i),(d===Zt.FILL||d===Zt.FILL_STROKE)&&n.fill(),(d===Zt.STROKE||d===Zt.FILL_STROKE)&&n.stroke(),n.restore()):((d===Zt.FILL||d===Zt.FILL_STROKE)&&n.fillText(t,e,s),(d===Zt.STROKE||d===Zt.FILL_STROKE)&&n.strokeText(t,e,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:vt(n),x:e,y:s,fontSize:c,addToPath:g})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return tt(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,a=e.fontSizeScale,o=e.charSpacing,l=e.wordSpacing,c=e.fontDirection,d=e.textHScale*c,u=t.length,f=s.vertical,g=f?1:-1,A=s.defaultVMetrics,y=i*e.fontMatrix[0],_=e.textRenderingMode===Zt.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),c>0?n.scale(d,-1):n.scale(d,1);let v;if(e.patternFill){n.save();const x=e.fillColor.getPattern(n,this,ks(n),ce.FILL);v=vt(n),n.restore(),n.fillStyle=x}let w=e.lineWidth;const E=e.textMatrixScale;if(E===0||w===0){const x=e.textRenderingMode&Zt.FILL_STROKE_MASK;(x===Zt.STROKE||x===Zt.FILL_STROKE)&&(w=this.getSinglePixelWidth())}else w/=E;if(a!==1&&(n.scale(a,a),w/=a),n.lineWidth=w,s.isInvalidPDFjsFont){const x=[];let T=0;for(const R of t)x.push(R.unicode),T+=R.width;n.fillText(x.join(""),0,0),e.x+=T*y*d,n.restore(),this.compose();return}let S=0,C;for(C=0;C<u;++C){const x=t[C];if(typeof x=="number"){S+=g*x*i/1e3;continue}let T=!1;const R=(x.isSpace?l:0)+o,L=x.fontChar,O=x.accent;let I,J,U=x.width;if(f){const q=x.vmetric||A,W=-(x.vmetric?q[1]:U*.5)*y,D=q[2]*y;U=q?-q[0]:U,I=W/a,J=(S+D)/a}else I=S/a,J=0;if(s.remeasure&&U>0){const q=n.measureText(L).width*1e3/i*a;if(U<q&&this.isFontSubpixelAAEnabled){const W=U/q;T=!0,n.save(),n.scale(W,1),I/=W}else U!==q&&(I+=(U-q)/2e3*i/a)}if(this.contentVisible&&(x.isInFont||s.missingFile)){if(_&&!O)n.fillText(L,I,J);else if(this.paintChar(L,I,J,v),O){const q=I+i*O.offset.x/a,W=J-i*O.offset.y/a;this.paintChar(O.fontChar,q,W,v)}}const B=f?U*y-R*c:U*y+R*c;S+=B,T&&n.restore()}f?e.y-=S:e.x+=S*d,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,a=s.fontDirection,o=i.vertical?1:-1,l=s.charSpacing,c=s.wordSpacing,d=s.textHScale*a,u=s.fontMatrix||jh,f=t.length,g=s.textRenderingMode===Zt.INVISIBLE;let A,y,_,v;if(!(g||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(d,a),A=0;A<f;++A){if(y=t[A],typeof y=="number"){v=o*y*n/1e3,this.ctx.translate(v,0),s.x+=v*d;continue}const w=(y.isSpace?c:0)+l,E=i.charProcOperatorList[y.operatorListId];if(!E){K(`Type3 character "${y.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=y,this.save(),e.scale(n,n),e.transform(...u),this.executeOperatorList(E),this.restore()),_=N.applyTransform([y.width,0],u)[0]*n+w,e.translate(_,0),s.x+=_*d}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,a){this.ctx.rect(s,i,n-s,a-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||vt(this.ctx),n={createCanvasGraphics:a=>new _d(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new fc(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=N.makeHexColor(t,e,s)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=N.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=yg(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,ks(e),ce.SHADING);const i=ks(e);if(i){const{width:n,height:a}=e.canvas,[o,l,c,d]=N.getAxialAlignedBoundingBox([0,0,n,a],i);this.ctx.fillRect(o,l,c-o,d-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){pt("Should not call beginInlineImage")}beginImageData(){pt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=vt(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(vt(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);const e=this.ctx;t.isolated||vh("TODO: Support non-isolated groups."),t.knockout&&K("Knockout groups not supported.");const s=vt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=N.getAxialAlignedBoundingBox(t.bbox,vt(e));const n=[0,0,e.canvas.width,e.canvas.height];i=N.intersect(i,n)||[0,0,0,0];const a=Math.floor(i[0]),o=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-a,1),c=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,c]);let d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,l,c),f=u.context;f.translate(-a,-o),f.transform(...s),t.smask?this.smaskStack.push({canvas:u.canvas,context:f,offsetX:a,offsetY:o,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(a,o),e.save()),Sa(e,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const 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();const i=vt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=N.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(m(this,$i,pc).call(this),ml(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const a=e[2]-e[0],o=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]=a,e[3]=o;const[l,c]=N.singularValueDecompose2dScale(vt(this.ctx)),{viewportScale:d}=this,u=Math.ceil(a*this.outputScaleX*d),f=Math.ceil(o*this.outputScaleY*d);this.annotationCanvas=this.canvasFactory.create(u,f);const{canvas:g,context:A}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=A,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,o*c),ml(this.ctx)}else ml(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new Id(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),m(this,$i,gc).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=Sg(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),a=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const l=vt(o);o.transform(e,s,i,n,0,0);const c=this._createMaskCanvas(t);o.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let d=0,u=a.length;d<u;d+=2){const f=N.transform(l,[e,s,i,n,a[d],a[d+1]]),[g,A]=N.applyTransform([0,0],f);o.drawImage(c.canvas,g,A)}o.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:a,width:o,height:l,transform:c}=n,d=this.cachedCanvases.getCanvas("maskCanvas",o,l),u=d.context;u.save();const f=this.getObject(a,n);Dd(u,f),u.globalCompositeOperation="source-in",u.fillStyle=i?s.getPattern(u,this,ks(e),ce.FILL):s,u.fillRect(0,0,o,l),u.restore(),e.save(),e.transform(...c),e.scale(1,-1),gl(e,d.canvas,0,0,o,l,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){K("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n){K("Dependent image isn't ready yet");return}const a=n.width,o=n.height,l=[];for(let c=0,d=i.length;c<d;c+=2)l.push({transform:[e,0,0,s,i[c],i[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(n,l)}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;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!re){const{filter:o}=i;o!=="none"&&o!==""&&(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{const l=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Fd(l,t),n=this.applyTransferMapsToCanvas(l)}const a=this._scaleImage(n,ks(i));i.imageSmoothingEnabled=Od(vt(i),t.interpolate),gl(i,a.img,0,0,a.paintWidth,a.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,a=t.height,l=this.cachedCanvases.getCanvas("inlineImage",n,a).context;Fd(l,t),i=this.applyTransferMapsToCanvas(l)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),gl(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){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Nd?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=vt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const 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){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),c=Math.abs(n);if(l===c)if(t===0)a=o=1/l;else{const d=l*t;a=o=d<1?1/d:1}else if(t===0)a=1/l,o=1/c;else{const d=l*t,u=c*t;a=d<1?1/d:1,o=u<1?1/u:1}}else{const l=Math.abs(e*n-s*i),c=Math.hypot(e,s),d=Math.hypot(i,n);if(t===0)a=d/l,o=c/l;else{const u=t*l;a=d>u?d/u:1,o=c>u?c/u:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const a=e.getLineDash();if(t&&e.save(),e.scale(i,n),a.length>0){const o=Math.max(i,n);e.setLineDash(a.map(l=>l/o)),e.lineDashOffset/=o}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}};$i=new WeakSet,pc=function(){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)},gc=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}};let gr=_d;for(const h in qe)gr.prototype[h]!==void 0&&(gr.prototype[qe[h]]=gr.prototype[h]);var po,go;class ni{static get workerPort(){return r(this,po)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,po,t)}static get workerSrc(){return r(this,go)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,go,t)}}po=new WeakMap,go=new WeakMap,b(ni,po,null),b(ni,go,"");const bl={DATA:1,ERROR:2},Rt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function we(h){switch(h instanceof Error||typeof h=="object"&&h!==null||pt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),h.name){case"AbortException":return new sr(h.message);case"MissingPDFException":return new er(h.message);case"PasswordException":return new Bh(h.message,h.code);case"UnexpectedResponseException":return new _h(h.message,h.status);case"UnknownErrorException":return new Uh(h.message,h.details);default:return new Uh(h.message,h.toString())}}var Ir,ze,ju,Bu,Uu,Rl;class Ia{constructor(t,e,s){b(this,ze);b(this,Ir,new AbortController);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",m(this,ze,ju).bind(this),{signal:r(this,Ir).signal})}on(t,e){const 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){const 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(a){n.reject(a)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const d=Promise.withResolvers();return this.streamControllers[n]={controller:c,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:n,data:e,desiredSize:c.desiredSize},i),d.promise},pull:c=>{const d=Promise.withResolvers();return this.streamControllers[n].pullCall=d,l.postMessage({sourceName:a,targetName:o,stream:Rt.PULL,streamId:n,desiredSize:c.desiredSize}),d.promise},cancel:c=>{Dt(c instanceof Error,"cancel must have a valid reason");const d=Promise.withResolvers();return this.streamControllers[n].cancelCall=d,this.streamControllers[n].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Rt.CANCEL,streamId:n,reason:we(c)}),d.promise}},s)}destroy(){var t;(t=r(this,Ir))==null||t.abort(),p(this,Ir,null)}}Ir=new WeakMap,ze=new WeakSet,ju=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){m(this,ze,Uu).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===bl.DATA)i.resolve(t.data);else if(t.callback===bl.ERROR)i.reject(we(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,n=this.comObj;new Promise(function(a){a(e(t.data))}).then(function(a){n.postMessage({sourceName:s,targetName:i,callback:bl.DATA,callbackId:t.callbackId,data:a})},function(a){n.postMessage({sourceName:s,targetName:i,callback:bl.ERROR,callbackId:t.callbackId,reason:we(a)})});return}if(t.streamId){m(this,ze,Bu).call(this,t);return}e(t.data)},Bu=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(c,d=1,u){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=d,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:Rt.ENQUEUE,streamId:e,chunk:c},u)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Rt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(c){Dt(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Rt.ERROR,streamId:e,reason:we(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,new Promise(function(c){c(o(t.data,l))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Rt.START_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:Rt.START_COMPLETE,streamId:e,reason:we(c)})})},Uu=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Rt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(we(t.reason));break;case Rt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(we(t.reason));break;case Rt.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:Rt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,new Promise(function(l){var c;l((c=o.onPull)==null?void 0:c.call(o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Rt.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Rt.PULL_COMPLETE,streamId:e,reason:we(l)})});break;case Rt.ENQUEUE:if(Dt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Rt.CLOSE:if(Dt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),m(this,ze,Rl).call(this,a,e);break;case Rt.ERROR:Dt(a,"error should have stream controller"),a.controller.error(we(t.reason)),m(this,ze,Rl).call(this,a,e);break;case Rt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(we(t.reason)),m(this,ze,Rl).call(this,a,e);break;case Rt.CANCEL:if(!o)break;new Promise(function(l){var c;l((c=o.onCancel)==null?void 0:c.call(o,we(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Rt.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Rt.CANCEL_COMPLETE,streamId:e,reason:we(l)})}),o.sinkCapability.reject(we(t.reason)),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Rl=async function(t,e){var s,i,n;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(n=t.cancelCall)==null?void 0:n.promise]),delete this.streamControllers[e]};var An,mo;class Rg{constructor({parsedData:t,rawData:e}){b(this,An);b(this,mo);p(this,An,t),p(this,mo,e)}getRaw(){return r(this,mo)}get(t){return r(this,An).get(t)??null}getAll(){return ad(r(this,An))}has(t){return r(this,An).has(t)}}An=new WeakMap,mo=new WeakMap;const cr=Symbol("INTERNAL");var bo,Ao,yo,Fr;class Pg{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){b(this,bo,!1);b(this,Ao,!1);b(this,yo,!1);b(this,Fr,!0);p(this,bo,!!(t&Le.DISPLAY)),p(this,Ao,!!(t&Le.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(r(this,yo))return r(this,Fr);if(!r(this,Fr))return!1;const{print:t,view:e}=this.usage;return r(this,bo)?(e==null?void 0:e.viewState)!=="OFF":r(this,Ao)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==cr&&pt("Internal method `_setVisible` called."),p(this,yo,s),p(this,Fr,e)}}bo=new WeakMap,Ao=new WeakMap,yo=new WeakMap,Fr=new WeakMap;var Si,ot,Dr,Or,vo,mc;class kg{constructor(t,e=Le.DISPLAY){b(this,vo);b(this,Si,null);b(this,ot,new Map);b(this,Dr,null);b(this,Or,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,Or,t.order);for(const s of t.groups)r(this,ot).set(s.id,new Pg(e,s));if(t.baseState==="OFF")for(const s of r(this,ot).values())s._setVisible(cr,!1);for(const s of t.on)r(this,ot).get(s)._setVisible(cr,!0);for(const s of t.off)r(this,ot).get(s)._setVisible(cr,!1);p(this,Dr,this.getHash())}}isVisible(t){if(r(this,ot).size===0)return!0;if(!t)return vh("Optional content group not defined."),!0;if(t.type==="OCG")return r(this,ot).has(t.id)?r(this,ot).get(t.id).visible:(K(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,vo,mc).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!r(this,ot).has(e))return K(`Optional content group not found: ${e}`),!0;if(r(this,ot).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!r(this,ot).has(e))return K(`Optional content group not found: ${e}`),!0;if(!r(this,ot).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!r(this,ot).has(e))return K(`Optional content group not found: ${e}`),!0;if(!r(this,ot).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!r(this,ot).has(e))return K(`Optional content group not found: ${e}`),!0;if(r(this,ot).get(e).visible)return!1}return!0}return K(`Unknown optional content policy ${t.policy}.`),!0}return K(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var n;const i=r(this,ot).get(t);if(!i){K(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((n=r(this,ot).get(o))==null||n._setVisible(cr,!1,!0));i._setVisible(cr,!!e,!0),p(this,Si,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=r(this,ot).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}}p(this,Si,null)}get hasInitialVisibility(){return r(this,Dr)===null||this.getHash()===r(this,Dr)}getOrder(){return r(this,ot).size?r(this,Or)?r(this,Or).slice():[...r(this,ot).keys()]:null}getGroups(){return r(this,ot).size>0?ad(r(this,ot)):null}getGroup(t){return r(this,ot).get(t)||null}getHash(){if(r(this,Si)!==null)return r(this,Si);const t=new Ru;for(const[e,s]of r(this,ot))t.update(`${e}:${s.visible}`);return p(this,Si,t.hexdigest())}}Si=new WeakMap,ot=new WeakMap,Dr=new WeakMap,Or=new WeakMap,vo=new WeakSet,mc=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let a;if(Array.isArray(n))a=m(this,vo,mc).call(this,n);else if(r(this,ot).has(n))a=r(this,ot).get(n).visible;else return K(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};class Lg{constructor(t,{disableRange:e=!1,disableStream:s=!1}){Dt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:a,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(n==null?void 0:n.length)>0){const l=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,c)=>{this._onReceiveData({begin:l,chunk:c})}),t.addProgressListener((l,c)=>{this._onProgress({loaded:l,total:c})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const 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{const i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});Dt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,i,n;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(n=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||n.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Dt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Mg(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Ig(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class Mg{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=hd(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const 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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Ig{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(const 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){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Fg(h){let t=!0,e=s("filename\\*","i").exec(h);if(e){e=e[1];let d=o(e);return d=unescape(d),d=l(d),d=c(d),n(d)}if(e=a(h),e){const d=c(e);return n(d)}if(e=s("filename","i").exec(h),e){e=e[1];let d=o(e);return d=c(d),n(d)}function s(d,u){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(d,u){if(d){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const f=new TextDecoder(d,{fatal:!0}),g=wh(u);u=f.decode(g),t=!1}catch{}}return u}function n(d){return t&&/[\x80-\xff]/.test(d)&&(d=i("utf-8",d),t&&(d=i("iso-8859-1",d))),d}function a(d){const u=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(d))!==null;){let[,y,_,v]=f;if(y=parseInt(y,10),y in u){if(y===0)break;continue}u[y]=[_,v]}const A=[];for(let y=0;y<u.length&&y in u;++y){let[_,v]=u[y];v=o(v),_&&(v=unescape(v),y===0&&(v=l(v))),A.push(v)}return A.join("")}function o(d){if(d.startsWith('"')){const u=d.slice(1).split('\\"');for(let f=0;f<u.length;++f){const g=u[f].indexOf('"');g!==-1&&(u[f]=u[f].slice(0,g),u.length=f+1),u[f]=u[f].replaceAll(/\\(.)/g,"$1")}d=u.join('"')}return d}function l(d){const u=d.indexOf("'");if(u===-1)return d;const f=d.slice(0,u),A=d.slice(u+1).replace(/^[^']*'/,"");return i(f,A)}function c(d){return!d.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(d)?d:d.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(u,f,g,A){if(g==="q"||g==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(y,_){return String.fromCharCode(parseInt(_,16))}),i(f,A);try{A=atob(A)}catch{}return i(f,A)})}return""}function pd(h,t){const e=new Headers;if(!h||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function gd({responseHeaders:h,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(h.get("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||h.get("Accept-Ranges")!=="bytes"||(h.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function md(h){const t=h.get("Content-Disposition");if(t){let e=Fg(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(hd(e))return e}return null}function xh(h,t){return h===404||h===0&&t.startsWith("file:")?new er('Missing PDF "'+t+'".'):new _h(`Unexpected server response (${h}) while retrieving PDF "${t}".`,h)}function zu(h){return h===200||h===206}function Gu(h,t,e){return{method:"GET",headers:h,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function $u(h){return h instanceof Uint8Array?h.buffer:h instanceof ArrayBuffer?h:(K(`getArrayBuffer - unexpected data format: ${h}`),new Uint8Array(h).buffer)}class Hd{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=pd(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return Dt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Dg(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Og(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class Dg{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const 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;const s=new Headers(t.headers),i=e.url;fetch(i,Gu(s,this._withCredentials,this._abortController)).then(n=>{if(!zu(n.status))throw xh(n.status,i);this._reader=n.body.getReader(),this._headersCapability.resolve();const a=n.headers,{allowRangeRequests:o,suggestedLength:l}=gd({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=md(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new sr("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(){var s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:$u(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class Og{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`);const a=i.url;fetch(a,Gu(n,this._withCredentials,this._abortController)).then(o=>{if(!zu(o.status))throw xh(o.status,a);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:$u(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const Fh=200,Dh=206;function Ng(h){const t=h.response;return typeof t!="string"?t:wh(t).buffer}class Hg{constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=pd(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[n,a]of this.headers)e.setRequestHeader(n,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=Dh):i.expectedStatus=Fh,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){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){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){var l,c,d;const s=this.pendingRequests[t];if(!s)return;const 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){(l=s.onError)==null||l.call(s,i.status);return}const n=i.status||Fh;if(!(n===Fh&&s.expectedStatus===Dh)&&n!==s.expectedStatus){(c=s.onError)==null||c.call(s,i.status);return}const o=Ng(i);if(n===Dh){const u=i.getResponseHeader("Content-Range"),f=/bytes (\d+)-(\d+)\/(\d+)/.exec(u);s.onDone({begin:parseInt(f[1],10),chunk:o})}else o?s.onDone({begin:0,chunk:o}):(d=s.onError)==null||d.call(s,i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class jg{constructor(t){this._source=t,this._manager=new Hg(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Dt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Bg(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Ug(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class Bg{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),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(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),s=new Headers(e.getAllResponseHeaders().trim().split(/[\r\n]+/).map(a=>{const[o,...l]=a.split(": ");return[o,l.join(": ")]})),{allowRangeRequests:i,suggestedLength:n}=gd({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=md(s),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(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=xh(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{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(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const 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}}class Ug{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=xh(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const 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()}}const zg=/^[a-z][a-z0-9\-+.]+:/i;function Gg(h){if(zg.test(h))return new URL(h);const t=Ui.get("url");return new URL(t.pathToFileURL(h))}function Wu(h,t,e){return h.protocol==="http:"?Ui.get("http").request(h,{headers:t},e):Ui.get("https").request(h,{headers:t},e)}class $g{constructor(t){this.source=t,this.url=Gg(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=pd(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return Dt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new qg(this):new Wg(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new Xg(this,t,e):new Vg(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class Vu{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{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 sr("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class qu{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{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)}}class Wg extends Vu{constructor(t){super(t);const e=Object.fromEntries(t.headers),s=i=>{if(i.statusCode===404){const l=new er(`Missing PDF "${this._url}".`);this._storedError=l,this._headersCapability.reject(l);return}this._headersCapability.resolve(),this._setReadableStream(i);const n=new Headers(this._readableStream.headers),{allowRangeRequests:a,suggestedLength:o}=gd({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=md(n)};this._request=Wu(this._url,e,s),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class Vg extends qu{constructor(t,e,s){super(t);const i=Object.fromEntries(t.headers);i.Range=`bytes=${e}-${s-1}`;const n=a=>{if(a.statusCode===404){const o=new er(`Missing PDF "${this._url}".`);this._storedError=o;return}this._setReadableStream(a)};this._request=Wu(this._url,i,n),this._request.on("error",a=>{this._storedError=a}),this._request.end()}}class qg extends Vu{constructor(t){super(t);const e=Ui.get("fs");e.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(e.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new er(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}}class Xg extends qu{constructor(t,e,s){super(t);const i=Ui.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:s-1}))}}const Yg=1e5,ge=30,Kg=.8;var Zd,xi,Ae,_o,wo,yn,Bs,Eo,So,vn,Nr,Hr,Ci,jr,xo,Br,_n,Co,To,Et,wn,En,Ro,Ti,Ur,li,Xu,Yu,Ac,Ie,Pl,yc,Ku,Qu;let bc=(Et=class{constructor({textContentSource:t,container:e,viewport:s}){b(this,li);b(this,xi,Promise.withResolvers());b(this,Ae,null);b(this,_o,!1);b(this,wo,!!((Zd=globalThis.FontInspector)!=null&&Zd.enabled));b(this,yn,null);b(this,Bs,null);b(this,Eo,0);b(this,So,0);b(this,vn,null);b(this,Nr,null);b(this,Hr,0);b(this,Ci,0);b(this,jr,Object.create(null));b(this,xo,[]);b(this,Br,null);b(this,_n,[]);b(this,Co,new WeakMap);b(this,To,null);var l;if(t instanceof ReadableStream)p(this,Br,t);else if(typeof t=="object")p(this,Br,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,Ae,p(this,Nr,e)),p(this,Ci,s.scale*(globalThis.devicePixelRatio||1)),p(this,Hr,s.rotation),p(this,Bs,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:a,pageY:o}=s.rawDims;p(this,To,[1,0,0,-1,-a,o+n]),p(this,So,i),p(this,Eo,n),m(l=Et,Ie,Ku).call(l),Yn(e,s),r(this,xi).promise.finally(()=>{r(Et,Ur).delete(this),p(this,Bs,null),p(this,jr,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=de.platform;return tt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{r(this,vn).read().then(({value:e,done:s})=>{if(s){r(this,xi).resolve();return}r(this,yn)??p(this,yn,e.lang),Object.assign(r(this,jr),e.styles),m(this,li,Xu).call(this,e.items),t()},r(this,xi).reject)};return p(this,vn,r(this,Br).getReader()),r(Et,Ur).add(this),t(),r(this,xi).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==r(this,Hr)&&(e==null||e(),p(this,Hr,i),Yn(r(this,Nr),{rotation:i})),s!==r(this,Ci)){e==null||e(),p(this,Ci,s);const a={div:null,properties:null,ctx:m(n=Et,Ie,Pl).call(n,r(this,yn))};for(const o of r(this,_n))a.properties=r(this,Co).get(o),a.div=o,m(this,li,Ac).call(this,a)}}cancel(){var e;const t=new sr("TextLayer task cancelled.");(e=r(this,vn))==null||e.cancel(t).catch(()=>{}),p(this,vn,null),r(this,xi).reject(t)}get textDivs(){return r(this,_n)}get textContentItemsStr(){return r(this,xo)}static cleanup(){if(!(r(this,Ur).size>0)){r(this,wn).clear();for(const{canvas:t}of r(this,En).values())t.remove();r(this,En).clear()}}},xi=new WeakMap,Ae=new WeakMap,_o=new WeakMap,wo=new WeakMap,yn=new WeakMap,Bs=new WeakMap,Eo=new WeakMap,So=new WeakMap,vn=new WeakMap,Nr=new WeakMap,Hr=new WeakMap,Ci=new WeakMap,jr=new WeakMap,xo=new WeakMap,Br=new WeakMap,_n=new WeakMap,Co=new WeakMap,To=new WeakMap,wn=new WeakMap,En=new WeakMap,Ro=new WeakMap,Ti=new WeakMap,Ur=new WeakMap,li=new WeakSet,Xu=function(t){var i,n;if(r(this,_o))return;(n=r(this,Bs)).ctx??(n.ctx=m(i=Et,Ie,Pl).call(i,r(this,yn)));const e=r(this,_n),s=r(this,xo);for(const a of t){if(e.length>Yg){K("Ignoring additional textDivs for performance reasons."),p(this,_o,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=r(this,Ae);p(this,Ae,document.createElement("span")),r(this,Ae).classList.add("markedContent"),a.id!==null&&r(this,Ae).setAttribute("id",`${a.id}`),o.append(r(this,Ae))}else a.type==="endMarkedContent"&&p(this,Ae,r(this,Ae).parentNode);continue}s.push(a.str),m(this,li,Yu).call(this,a)}},Yu=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};r(this,_n).push(e);const i=N.transform(r(this,To),t.transform);let n=Math.atan2(i[1],i[0]);const a=r(this,jr)[t.fontName];a.vertical&&(n+=Math.PI/2);let o=r(this,wo)&&a.fontSubstitution||a.fontFamily;o=Et.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),c=l*m(y=Et,Ie,Qu).call(y,o,r(this,yn));let d,u;n===0?(d=i[4],u=i[5]-c):(d=i[4]+c*Math.sin(n),u=i[5]-c*Math.cos(n));const f="calc(var(--scale-factor)*",g=e.style;r(this,Ae)===r(this,Nr)?(g.left=`${(100*d/r(this,So)).toFixed(2)}%`,g.top=`${(100*u/r(this,Eo)).toFixed(2)}%`):(g.left=`${f}${d.toFixed(2)}px)`,g.top=`${f}${u.toFixed(2)}px)`),g.fontSize=`${f}${(r(Et,Ti)*l).toFixed(2)}px)`,g.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,r(this,wo)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const _=Math.abs(t.transform[0]),v=Math.abs(t.transform[3]);_!==v&&Math.max(_,v)/Math.min(_,v)>1.5&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),r(this,Co).set(e,s),r(this,Bs).div=e,r(this,Bs).properties=s,m(this,li,Ac).call(this,r(this,Bs)),s.hasText&&r(this,Ae).append(e),s.hasEOL){const _=document.createElement("br");_.setAttribute("role","presentation"),r(this,Ae).append(_)}},Ac=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:n}=e;let a="";if(r(Et,Ti)>1&&(a=`scale(${1/r(Et,Ti)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=n,{canvasWidth:c,fontSize:d}=s;m(o=Et,Ie,yc).call(o,i,d*r(this,Ci),l);const{width:u}=i.measureText(e.textContent);u>0&&(a=`scaleX(${c*r(this,Ci)/u}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(n.transform=a)},Ie=new WeakSet,Pl=function(t=null){let e=r(this,En).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),r(this,En).set(t,e),r(this,Ro).set(e,{size:0,family:""})}return e},yc=function(t,e,s){const i=r(this,Ro).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},Ku=function(){if(r(this,Ti)!==null)return;const 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),p(this,Ti,t.getBoundingClientRect().height),t.remove()},Qu=function(t,e){const s=r(this,wn).get(t);if(s)return s;const i=m(this,Ie,Pl).call(this,e);i.canvas.width=i.canvas.height=ge,m(this,Ie,yc).call(this,i,ge,t);const n=i.measureText("");let a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);if(a){const d=a/(a+o);return r(this,wn).set(t,d),i.canvas.width=i.canvas.height=0,d}i.strokeStyle="red",i.clearRect(0,0,ge,ge),i.strokeText("g",0,0);let l=i.getImageData(0,0,ge,ge).data;o=0;for(let d=l.length-1-3;d>=0;d-=4)if(l[d]>0){o=Math.ceil(d/4/ge);break}i.clearRect(0,0,ge,ge),i.strokeText("A",0,ge),l=i.getImageData(0,0,ge,ge).data,a=0;for(let d=0,u=l.length;d<u;d+=4)if(l[d]>0){a=ge-Math.floor(d/4/ge);break}i.canvas.width=i.canvas.height=0;const c=a?a/(a+o):Kg;return r(this,wn).set(t,c),c},b(Et,Ie),b(Et,wn,new Map),b(Et,En,new Map),b(Et,Ro,new WeakMap),b(Et,Ti,null),b(Et,Ur,new Set),Et);class Wa{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){var l;if(!n)return;let a=null;const o=n.name;if(o==="#text")a=n.value;else if(Wa.shouldBuildText(o))(l=n==null?void 0:n.attributes)!=null&&l.textContent?a=n.attributes.textContent:n.value&&(a=n.value);else return;if(a!==null&&e.push({str:a}),!!n.children)for(const c of n.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const Qg=65536,Jg=100,Zg=5e3,tm=re?ug:hg,em=re?fg:Iu,sm=re?dg:cg,im=re?pg:Nu;function nm(h={}){typeof h=="string"||h instanceof URL?h={url:h}:(h instanceof ArrayBuffer||ArrayBuffer.isView(h))&&(h={data:h});const t=new vc,{docId:e}=t,s=h.url?rm(h.url):null,i=h.data?am(h.data):null,n=h.httpHeaders||null,a=h.withCredentials===!0,o=h.password??null,l=h.range instanceof Ju?h.range:null,c=Number.isInteger(h.rangeChunkSize)&&h.rangeChunkSize>0?h.rangeChunkSize:Qg;let d=h.worker instanceof mr?h.worker:null;const u=h.verbosity,f=typeof h.docBaseUrl=="string"&&!Sh(h.docBaseUrl)?h.docBaseUrl:null,g=typeof h.cMapUrl=="string"?h.cMapUrl:null,A=h.cMapPacked!==!1,y=h.CMapReaderFactory||em,_=typeof h.standardFontDataUrl=="string"?h.standardFontDataUrl:null,v=h.StandardFontDataFactory||im,w=h.stopAtErrors!==!0,E=Number.isInteger(h.maxImageSize)&&h.maxImageSize>-1?h.maxImageSize:-1,S=h.isEvalSupported!==!1,C=typeof h.isOffscreenCanvasSupported=="boolean"?h.isOffscreenCanvasSupported:!re,x=typeof h.isChrome=="boolean"?h.isChrome:!de.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),T=Number.isInteger(h.canvasMaxAreaInBytes)?h.canvasMaxAreaInBytes:-1,R=typeof h.disableFontFace=="boolean"?h.disableFontFace:re,L=h.fontExtraProperties===!0,O=h.enableXfa===!0,I=h.ownerDocument||globalThis.document,J=h.disableRange===!0,U=h.disableStream===!0,B=h.disableAutoFetch===!0,q=h.pdfBug===!0,W=h.CanvasFactory||tm,D=h.FilterFactory||sm,j=h.enableHWA===!0,Kt=l?l.length:h.length??NaN,ae=typeof h.useSystemFonts=="boolean"?h.useSystemFonts:!re&&!R,Qt=typeof h.useWorkerFetch=="boolean"?h.useWorkerFetch:y===Iu&&v===Nu&&g&&_&&Ca(g,document.baseURI)&&Ca(_,document.baseURI);h.canvasFactory&&Cd("`canvasFactory`-instance option, please use `CanvasFactory` instead."),h.filterFactory&&Cd("`filterFactory`-instance option, please use `FilterFactory` instead.");const _t=null;Bp(u);const ft={canvasFactory:new W({ownerDocument:I,enableHWA:j}),filterFactory:new D({docId:e,ownerDocument:I}),cMapReaderFactory:Qt?null:new y({baseUrl:g,isCompressed:A}),standardFontDataFactory:Qt?null:new v({baseUrl:_})};if(!d){const St={verbosity:u,port:ni.workerPort};d=St.port?mr.fromPort(St):new mr(St),t._worker=d}const pe={docId:e,apiVersion:"4.8.69",data:i,password:o,disableAutoFetch:B,rangeChunkSize:c,length:Kt,docBaseUrl:f,enableXfa:O,evaluatorOptions:{maxImageSize:E,disableFontFace:R,ignoreErrors:w,isEvalSupported:S,isOffscreenCanvasSupported:C,isChrome:x,canvasMaxAreaInBytes:T,fontExtraProperties:L,useSystemFonts:ae,cMapUrl:Qt?g:null,standardFontDataUrl:Qt?_:null}},$e={disableFontFace:R,fontExtraProperties:L,ownerDocument:I,pdfBug:q,styleElement:_t,loadingParams:{disableAutoFetch:B,enableXfa:O}};return d.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const St=d.messageHandler.sendWithPromise("GetDocRequest",pe,i?[i.buffer]:null);let nt;if(l)nt=new Lg(l,{disableRange:J,disableStream:U});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let ls;re?ls=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&Ca(s)?Hd:$g:ls=Ca(s)?Hd:jg,nt=new ls({url:s,length:Kt,httpHeaders:n,withCredentials:a,rangeChunkSize:c,disableRange:J,disableStream:U})}return St.then(ls=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const We=new Ia(e,ls,d.port),gt=new cm(We,t,nt,$e,ft);t._transport=gt,We.send("Ready",null)})}).catch(t._capability.reject),t}function rm(h){if(h instanceof URL)return h.href;try{return new URL(h,window.location).href}catch{if(re&&typeof h=="string")return h}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function am(h){if(re&&typeof Buffer<"u"&&h instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength)return h;if(typeof h=="string")return wh(h);if(h instanceof ArrayBuffer||ArrayBuffer.isView(h)||typeof h=="object"&&!isNaN(h==null?void 0:h.length))return new Uint8Array(h);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function jd(h){return typeof h=="object"&&Number.isInteger(h==null?void 0:h.num)&&h.num>=0&&Number.isInteger(h==null?void 0:h.gen)&&h.gen>=0}var ch;const dh=class dh{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${oe(dh,ch)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,e,s;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(i){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,i}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};ch=new WeakMap,b(dh,ch,0);let vc=dh,Ju=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(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){pt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class om{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 tt(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"}={}){const{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()}}var Ri,Us,Be,dr,kl;class lm{constructor(t,e,s,i=!1){b(this,Be);b(this,Ri,null);b(this,Us,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new xd:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Zu,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 ll({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{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 tt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=ui.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1}){var S,C;(S=this._stats)==null||S.time("Overall");const f=this._transport.getRenderingIntent(s,i,d,u),{renderingIntent:g,cacheKey:A}=f;p(this,Us,!1),m(this,Be,kl).call(this),o||(o=this._transport.getOptionalContentConfig(g));let y=this._intentStates.get(A);y||(y=Object.create(null),this._intentStates.set(A,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const _=!!(g&Le.PRINT);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(C=this._stats)==null||C.time("Page Request"),this._pumpOperatorList(f));const v=x=>{var T;y.renderTasks.delete(w),(this._maybeCleanupAfterRender||_)&&p(this,Us,!0),m(this,Be,dr).call(this,!_),x?(w.capability.reject(x),this._abortOperatorList({intentState:y,reason:x instanceof Error?x:new Error(x)})):w.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(T=globalThis.Stats)!=null&&T.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},w=new wc({callback:v,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:c});(y.renderTasks||(y.renderTasks=new Set)).add(w);const E=w.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([x,T])=>{var R;if(this.destroyed){v();return}if((R=this._stats)==null||R.time("Rendering"),!(T.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");w.initializeGraphics({transparency:x,optionalContentConfig:T}),w.operatorListChanged()}).catch(v),E}getOperatorList({intent:t="display",annotationMode:e=ui.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function n(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0);let o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=n,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(a)),o.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=>Wa.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){a.read().then(function({value:l,done:c}){if(c){s(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),n()},i)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};n()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,Us,!1),m(this,Be,kl).call(this),Promise.all(t)}cleanup(t=!1){p(this,Us,!0);const e=m(this,Be,dr).call(this,!1);return t&&e&&this._stats&&(this._stats=new xd),e}_startRenderPage(t,e){var i,n;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(n=s.displayReadyCapability)==null||n.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(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&m(this,Be,dr).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:n,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},a).getReader(),c=this._intentStates.get(e);c.streamReader=l;const d=()=>{l.read().then(({value:u,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,c),d())},u=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();m(this,Be,dr).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(u);else if(c.opListReadCapability)c.opListReadCapability.reject(u);else throw u}})};d()}_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 ld){let i=Jg;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 sr(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}Ri=new WeakMap,Us=new WeakMap,Be=new WeakSet,dr=function(t=!1){if(m(this,Be,kl).call(this),!r(this,Us)||this.destroyed)return!1;if(t)return p(this,Ri,setTimeout(()=>{p(this,Ri,null),m(this,Be,dr).call(this,!1)},Zg)),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,Us,!1),!0},kl=function(){r(this,Ri)&&(clearTimeout(r(this,Ri)),p(this,Ri,null))};var zs,uh;class hm{constructor(){b(this,zs,new Map);b(this,uh,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};r(this,uh).then(()=>{for(const[i]of r(this,zs))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:n}=s;if(n.aborted){K("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}r(this,zs).set(e,i)}removeEventListener(t,e){const s=r(this,zs).get(e);s==null||s(),r(this,zs).delete(e)}terminate(){for(const[,t]of r(this,zs))t==null||t();r(this,zs).clear()}}zs=new WeakMap,uh=new WeakMap;var fh,Sn,xn,zr,Ll,Gr,Ml;const mt=class mt{constructor({name:t=null,port:e=null,verbosity:s=Up()}={}){b(this,zr);var i;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((i=r(mt,xn))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(r(mt,xn)||p(mt,xn,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return re?Promise.all([Ui.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Ia("main","worker",t),this._messageHandler.on("ready",function(){}),m(this,zr,Ll).call(this)}_initialize(){if(r(mt,Sn)||r(mt,Gr,Ml)){this._setupFakeWorker();return}let{workerSrc:t}=mt;try{mt._isSameOrigin(window.location.href,t)||(t=mt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Ia("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",o=>{if(n.abort(),this.destroyed||!o){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,m(this,zr,Ll).call(this)}),s.on("ready",o=>{if(n.abort(),this.destroyed){i();return}try{a()}catch{this._setupFakeWorker()}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{vh("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){r(mt,Sn)||(K("Setting up fake worker."),p(mt,Sn,!0)),mt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new hm;this._port=e;const s=`fake${oe(mt,fh)._++}`,i=new Ia(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new Ia(s,s+"_worker",e),m(this,zr,Ll).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(t=r(mt,xn))==null||t.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){var s;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const e=(s=r(this,xn))==null?void 0: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 mt(t)}static get workerSrc(){if(ni.workerSrc)return ni.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return tt(this,"_setupFakeWorkerGlobal",(async()=>r(this,Gr,Ml)?r(this,Gr,Ml):(await import(this.workerSrc)).WorkerMessageHandler)())}};fh=new WeakMap,Sn=new WeakMap,xn=new WeakMap,zr=new WeakSet,Ll=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Gr=new WeakSet,Ml=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},b(mt,Gr),b(mt,fh,0),b(mt,Sn,!1),b(mt,xn),re&&(p(mt,Sn,!0),ni.workerSrc||(ni.workerSrc="./pdf.worker.mjs")),mt._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}const i=new URL(e,s);return s.origin===i.origin},mt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let mr=mt;var Gs,_s,$r,Wr,ws,Cn,Fa;class cm{constructor(t,e,s,i,n){b(this,Cn);b(this,Gs,new Map);b(this,_s,new Map);b(this,$r,new Map);b(this,Wr,new Map);b(this,ws,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Zu,this.fontLoader=new og({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()}get annotationStorage(){return tt(this,"annotationStorage",new ud)}getRenderingIntent(t,e=ui.ENABLE,s=null,i=!1,n=!1){let a=Le.DISPLAY,o=lc;switch(t){case"any":a=Le.ANY;break;case"display":break;case"print":a=Le.PRINT;break;default:K(`getRenderingIntent - invalid intent: ${t}`)}const l=a&Le.PRINT&&s instanceof ku?s:this.annotationStorage;switch(e){case ui.DISABLE:a+=Le.ANNOTATIONS_DISABLE;break;case ui.ENABLE:break;case ui.ENABLE_FORMS:a+=Le.ANNOTATIONS_FORMS;break;case ui.ENABLE_STORAGE:a+=Le.ANNOTATIONS_STORAGE,o=l.serializable;break;default:K(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=Le.IS_EDITING),n&&(a+=Le.OPLIST);const{ids:c,hash:d}=l.modifiedIds,u=[a,o.hash,d];return{renderingIntent:a,cacheKey:u.join("_"),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=r(this,ws))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of r(this,_s).values())t.push(i._destroy());r(this,_s).clear(),r(this,$r).clear(),r(this,Wr).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i;this.commonObjs.clear(),this.fontLoader.clear(),r(this,Gs).clear(),this.filterFactory.destroy(),bc.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new sr("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{Dt(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:a}){if(a){i.close();return}Dt(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(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:n,contentLength:a}=this._fullReader;return(!i||!n)&&(this._lastProgress&&((o=e.onProgress)==null||o.call(e,this._lastProgress)),this._fullReader.onProgress=l=>{var c;(c=e.onProgress)==null||c.call(e,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:n,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{Dt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:a,done:o}){if(o){i.close();return}Dt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{n.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new om(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Bh(s.message,s.code);break;case"InvalidPDFException":i=new su(s.message);break;case"MissingPDFException":i=new er(s.message);break;case"UnexpectedResponseException":i=new _h(s.message,s.status);break;case"UnknownErrorException":i=new Uh(s.message,s.details);break;default:pt("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(p(this,ws,Promise.withResolvers()),e.onPassword){const i=n=>{n instanceof Error?r(this,ws).reject(n):r(this,ws).resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){r(this,ws).reject(n)}}else r(this,ws).reject(new Bh(s.message,s.code));return r(this,ws).promise}),t.on("DataLoaded",s=>{var i;(i=e.onProgress)==null||i.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;r(this,_s).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:o,fontExtraProperties:l,pdfBug:c}=this._params;if("error"in n){const g=n.error;K(`Error during font loading: ${g}`),this.commonObjs.resolve(s,g);break}const d=c&&((a=globalThis.FontInspector)!=null&&a.enabled)?(g,A)=>globalThis.FontInspector.fontAdded(g,A):null,u=new lg(n,{disableFontFace:o,inspectFont:d});this.fontLoader.bind(u).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&u.data&&(u.data=null),this.commonObjs.resolve(s,u)});break;case"CopyLocalImage":const{imageRef:f}=n;Dt(f,"The imageRef must be defined.");for(const g of r(this,_s).values())for(const[,A]of g.objs)if((A==null?void 0:A.ref)===f)return A.dataLen?(this.commonObjs.resolve(s,structuredClone(A)),A.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,a])=>{var l;if(this.destroyed)return;const o=r(this,_s).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(n){case"Image":o.objs.resolve(s,a),(a==null?void 0:a.dataLen)>Op&&(o._maybeCleanupAfterRender=!0);break;case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{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(){var s;this.annotationStorage.size<=0&&K("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.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."));const e=t-1,s=r(this,$r).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&r(this,Wr).set(n.refStr,t);const a=new lm(e,n,this,this._params.pdfBug);return r(this,_s).set(e,a),a});return r(this,$r).set(e,i),i}getPageIndex(t){return jd(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 m(this,Cn,Fa).call(this,"GetFieldObjects")}hasJSActions(){return m(this,Cn,Fa).call(this,"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 m(this,Cn,Fa).call(this,"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 m(this,Cn,Fa).call(this,"GetOptionalContentConfig").then(e=>new kg(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=r(this,Gs).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var n,a;return{info:i[0],metadata:i[1]?new Rg(i[1]):null,contentDispositionFilename:((n=this._fullReader)==null?void 0:n.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return r(this,Gs).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(const e of r(this,_s).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),r(this,Gs).clear(),this.filterFactory.destroy(!0),bc.cleanup()}}cachedPageNumber(t){if(!jd(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return r(this,Wr).get(e)??null}}Gs=new WeakMap,_s=new WeakMap,$r=new WeakMap,Wr=new WeakMap,ws=new WeakMap,Cn=new WeakSet,Fa=function(t,e=null){const s=r(this,Gs).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return r(this,Gs).set(t,i),i};const Al=Symbol("INITIAL_DATA");var Ze,Po,_c;class Zu{constructor(){b(this,Po);b(this,Ze,Object.create(null))}get(t,e=null){if(e){const i=m(this,Po,_c).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=r(this,Ze)[t];if(!s||s.data===Al)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=r(this,Ze)[t];return!!e&&e.data!==Al}resolve(t,e=null){const s=m(this,Po,_c).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in r(this,Ze)){const{data:s}=r(this,Ze)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,Ze,Object.create(null))}*[Symbol.iterator](){for(const t in r(this,Ze)){const{data:e}=r(this,Ze)[t];e!==Al&&(yield[t,e])}}}Ze=new WeakMap,Po=new WeakSet,_c=function(t){var e;return(e=r(this,Ze))[t]||(e[t]={...Promise.withResolvers(),data:Al})};var Pi;class dm{constructor(t){b(this,Pi,null);p(this,Pi,t),this.onContinue=null}get promise(){return r(this,Pi).capability.promise}cancel(t=0){r(this,Pi).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=r(this,Pi).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=r(this,Pi);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}Pi=new WeakMap;var ki,Tn;const Qi=class Qi{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:d=!1,pdfBug:u=!1,pageColors:f=null}){b(this,ki,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new dm(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}){var o,l;if(this.cancelled)return;if(this._canvas){if(r(Qi,Tn).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.");r(Qi,Tn).add(this._canvas)}this._pdfBug&&((o=globalThis.StepperManager)!=null&&o.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:a}=this.params;this.gfx=new gr(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:a}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(t=null,e=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),r(this,ki)&&(window.cancelAnimationFrame(r(this,ki)),p(this,ki,null)),r(Qi,Tn).delete(this._canvas),this.callback(t||new ld(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.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?p(this,ki,window.requestAnimationFrame(()=>{p(this,ki,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(),r(Qi,Tn).delete(this._canvas),this.callback())))}};ki=new WeakMap,Tn=new WeakMap,b(Qi,Tn,new WeakSet);let wc=Qi;const um="4.8.69",fm="3634dab10";function Bd(h){return Math.floor(Math.max(0,Math.min(1,h))*255).toString(16).padStart(2,"0")}function xa(h){return Math.max(0,Math.min(255,255*h))}class Ud{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=xa(t),[t,t,t]}static G_HTML([t]){const e=Bd(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(xa)}static RGB_HTML(t){return`#${t.map(Bd).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[xa(1-Math.min(1,t+i)),xa(1-Math.min(1,s+i)),xa(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,a=1-s,o=Math.min(i,n,a);return["CMYK",i,n,a,o]}}class pm{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const 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){pt("Abstract method `_createSVG` called.")}}class bd extends pm{_createSVG(t){return document.createElementNS(Ls,t)}}class tf{static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,c]of Object.entries(a))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}o&&n.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var u,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:n,linkService:s});const o=n!=="richText",l=t.div;if(l.append(a),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=g}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);a.append(g),o&&Wa.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const d=[[i,-1,a]];for(;d.length>0;){const[g,A,y]=d.at(-1);if(A+1===g.children.length){d.pop();continue}const _=g.children[++d.at(-1)[1]];if(_===null)continue;const{name:v}=_;if(v==="#text"){const E=document.createTextNode(_.value);c.push(E),y.append(E);continue}const w=(u=_==null?void 0:_.attributes)!=null&&u.xmlns?document.createElementNS(_.attributes.xmlns,v):document.createElement(v);if(y.append(w),_.attributes&&this.setAttributes({html:w,element:_,storage:e,intent:n,linkService:s}),((f=_.children)==null?void 0:f.length)>0)d.push([_,-1,w]);else if(_.value){const E=document.createTextNode(_.value);o&&Wa.shouldBuildText(v)&&c.push(E),w.append(E)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const cl=1e3,gm=9,Qn=new WeakSet;function ri(h){return{width:h[2]-h[0],height:h[3]-h[1]}}class mm{static create(t){switch(t.data.annotationType){case Lt.LINK:return new ef(t);case Lt.TEXT:return new bm(t);case Lt.WIDGET:switch(t.data.fieldType){case"Tx":return new Am(t);case"Btn":return t.data.radioButton?new rf(t):t.data.checkBox?new vm(t):new _m(t);case"Ch":return new wm(t);case"Sig":return new ym(t)}return new ir(t);case Lt.POPUP:return new Sc(t);case Lt.FREETEXT:return new cf(t);case Lt.LINE:return new Sm(t);case Lt.SQUARE:return new xm(t);case Lt.CIRCLE:return new Cm(t);case Lt.POLYLINE:return new df(t);case Lt.CARET:return new Rm(t);case Lt.INK:return new Ad(t);case Lt.POLYGON:return new Tm(t);case Lt.HIGHLIGHT:return new uf(t);case Lt.UNDERLINE:return new Pm(t);case Lt.SQUIGGLY:return new km(t);case Lt.STRIKEOUT:return new Lm(t);case Lt.STAMP:return new ff(t);case Lt.FILEATTACHMENT:return new Mm(t);default:return new Ct(t)}}}var Rn,Vr,qr,ko,Ec;const wd=class wd{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){b(this,ko);b(this,Rn,null);b(this,Vr,!1);b(this,qr,null);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!=null&&t.str||e!=null&&e.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return wd._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;r(this,Rn)||p(this,Rn,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&m(this,ko,Ec).call(this,e),(s=r(this,qr))==null||s.popup.updateEdited(t)}resetEdited(){var t;r(this,Rn)&&(m(this,ko,Ec).call(this,r(this,Rn).rect),(t=r(this,qr))==null||t.popup.resetEdited(),p(this,Rn,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof ir||(n.tabIndex=cl);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Sc){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,n),n}const{width:o,height:l}=ri(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const y=e.borderStyle.horizontalCornerRadius,_=e.borderStyle.verticalCornerRadius;if(y>0||_>0){const w=`calc(${y}px * var(--scale-factor)) / calc(${_}px * var(--scale-factor))`;a.borderRadius=w}else if(this instanceof rf){const w=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=w}switch(e.borderStyle.style){case Ea.SOLID:a.borderStyle="solid";break;case Ea.DASHED:a.borderStyle="dashed";break;case Ea.BEVELED:K("Unimplemented border style: beveled");break;case Ea.INSET:K("Unimplemented border style: inset");break;case Ea.UNDERLINE:a.borderBottomStyle="solid";break}const v=e.borderColor||null;v?(p(this,Vr,!0),a.borderColor=N.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):a.borderWidth=0}const c=N.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:d,pageHeight:u,pageX:f,pageY:g}=i.rawDims;a.left=`${100*(c[0]-f)/d}%`,a.top=`${100*(c[1]-g)/u}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/d}%`,a.height=`${100*l/u}%`):this.setRotation(A,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:a}=ri(this.data.rect);let o,l;t%180===0?(o=100*n/s,l=100*a/i):(o=100*a/s,l=100*n/i),e.style.width=`${o}%`,e.style.height=`${l}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],a=n[0],o=n.slice(1);i.target.style[s]=Ud[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Ud[`${a}_rgb`](o)})};return tt(this,"_commonActions",{display:e=>{const{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=>{const{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=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];n==null||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:n},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(y=>Math.fround(y));if(t.length===8){const[y,_,v,w]=t.subarray(2,6);if(i===y&&n===_&&e===v&&s===w)return}const{style:a}=this.container;let o;if(r(this,Vr)){const{borderColor:y,borderWidth:_}=a;a.borderWidth=0,o=["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="${y}" stroke-width="${_}">`],this.container.classList.add("hasBorder")}const l=i-e,c=n-s,{svgFactory:d}=this,u=d.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const f=d.createElement("defs");u.append(f);const g=d.createElement("clipPath"),A=`clippath_${this.data.id}`;g.setAttribute("id",A),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let y=2,_=t.length;y<_;y+=8){const v=t[y],w=t[y+1],E=t[y+2],S=t[y+3],C=d.createElement("rect"),x=(E-e)/l,T=(n-w)/c,R=(v-E)/l,L=(w-S)/c;C.setAttribute("x",x),C.setAttribute("y",T),C.setAttribute("width",R),C.setAttribute("height",L),g.append(C),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${T}" width="${R}" height="${L}"/>`)}r(this,Vr)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${A})`}_createPopup(){const{data:t}=this,e=p(this,qr,new Sc({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(){pt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:a,exportValues:o}of i){if(n===-1||a===e)continue;const l=typeof o=="string"?o:null,c=document.querySelector(`[data-element-id="${a}"]`);if(c&&!Qn.has(c)){K(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,a=i.getAttribute("data-element-id");a!==e&&Qn.has(i)&&s.push({id:a,exportValue:n,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}};Rn=new WeakMap,Vr=new WeakMap,qr=new WeakMap,ko=new WeakSet,Ec=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t);const{width:c,height:d}=ri(t);e.left=`${100*(t[0]-o)/n}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*c/n}%`,e.height=`${100*d/a}%`):this.setRotation(i)};let Ct=wd;var Me,Vi,sf,nf;class ef extends Ct{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});b(this,Me);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action),n=!0):e.attachment?(m(this,Me,sf).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(m(this,Me,nf).call(this,i,e.setOCGState),n=!0):e.dest?(this._bindLink(i,e.dest),n=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container}_bindLink(e,s){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&m(this,Me,Vi).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),m(this,Me,Vi).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(s.actions)){const a=i.get(n);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:n}}),!1})}e.onclick||(e.onclick=()=>!1),m(this,Me,Vi).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),m(this,Me,Vi).call(this),!this._fieldObjects){K('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var u;i==null||i();const{fields:n,refs:a,include:o}=s,l=[];if(n.length!==0||a.length!==0){const f=new Set(a);for(const g of n){const A=this._fieldObjects[g]||[];for(const{id:y}of A)f.add(y)}for(const g of Object.values(this._fieldObjects))for(const A of g)f.has(A.id)===o&&l.push(A)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const c=this.annotationStorage,d=[];for(const f of l){const{id:g}=f;switch(d.push(g),f.type){case"text":{const y=f.defaultValue||"";c.setValue(g,{value:y});break}case"checkbox":case"radiobutton":{const y=f.defaultValue===f.exportValues;c.setValue(g,{value:y});break}case"combobox":case"listbox":{const y=f.defaultValue||"";c.setValue(g,{value:y});break}default:continue}const A=document.querySelector(`[data-element-id="${g}"]`);if(A){if(!Qn.has(A)){K(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;A.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}})),!1}}}Me=new WeakSet,Vi=function(){this.container.setAttribute("data-internal-link","")},sf=function(e,s,i=null){e.href=this.linkService.getAnchorUrl(""),s.description&&(e.title=s.description),e.onclick=()=>{var n;return(n=this.downloadManager)==null||n.openOrDownloadData(s.content,s.filename,i),!1},m(this,Me,Vi).call(this)},nf=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),m(this,Me,Vi).call(this)};class bm extends Ct{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class ir extends Ct{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return de.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a)}}))})}_setEventListeners(t,e,s,i){var n,a,o;for(const[l,c]of s)(c==="Action"||(n=this.data.actions)!=null&&n[c])&&((c==="Focus"||c==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,c,i),c==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":N.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||gm,n=t.style;let a;const o=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o),d=Math.round(c/(kh*i))||1,u=c/d;a=Math.min(i,l(u/kh))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/kh))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=N.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)}}class Am extends ir{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),n.setValue(a.id,{[i]:s})}render(){var i,n;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let c=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
3
+ `))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const d={userValue:o,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",c??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Qn.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=cl,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",f=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),d.formattedValue=null}),s.addEventListener("resetform",f=>{const g=this.data.defaultFieldValue??"";s.value=d.userValue=g,d.formattedValue=null});let u=f=>{const{formattedValue:g}=d;g!=null&&(f.target.value=g),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{var y;if(d.focused)return;const{target:A}=g;d.userValue&&(A.value=d.userValue),d.lastCommittedValue=A.value,d.commitKey=1,(y=this.data.actions)!=null&&y.Focus||(d.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const A={value(y){d.userValue=y.detail.value??"",t.setValue(e,{value:d.userValue.toString()}),y.target.value=d.userValue},formattedValue(y){const{formattedValue:_}=y.detail;d.formattedValue=_,_!=null&&y.target!==document.activeElement&&(y.target.value=_),t.setValue(e,{formattedValue:_})},selRange(y){y.target.setSelectionRange(...y.detail.selRange)},charLimit:y=>{var E;const{charLimit:_}=y.detail,{target:v}=y;if(_===0){v.removeAttribute("maxLength");return}v.setAttribute("maxLength",_);let w=d.userValue;!w||w.length<=_||(w=w.slice(0,_),v.value=d.userValue=w,t.setValue(e,{value:w}),(E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,willCommit:!0,commitKey:1,selStart:v.selectionStart,selEnd:v.selectionEnd}}))}};this._dispatchEventFromSandbox(A,g)}),s.addEventListener("keydown",g=>{var _;d.commitKey=1;let A=-1;if(g.key==="Escape"?A=0:g.key==="Enter"&&!this.data.multiLine?A=2:g.key==="Tab"&&(d.commitKey=3),A===-1)return;const{value:y}=g.target;d.lastCommittedValue!==y&&(d.lastCommittedValue=y,d.userValue=y,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,willCommit:!0,commitKey:A,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const f=u;u=null,s.addEventListener("blur",g=>{var y,_;if(!d.focused||!g.relatedTarget)return;(y=this.data.actions)!=null&&y.Blur||(d.focused=!1);const{value:A}=g.target;d.userValue=A,d.lastCommittedValue!==A&&((_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:d.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}})),f(g)}),(n=this.data.actions)!=null&&n.Keystroke&&s.addEventListener("beforeinput",g=>{var C;d.lastCommittedValue=null;const{data:A,target:y}=g,{value:_,selectionStart:v,selectionEnd:w}=y;let E=v,S=w;switch(g.inputType){case"deleteWordBackward":{const x=_.substring(0,v).match(/\w*[^\w]*$/);x&&(E-=x[0].length);break}case"deleteWordForward":{const x=_.substring(v).match(/^[^\w]*\w*/);x&&(S+=x[0].length);break}case"deleteContentBackward":v===w&&(E-=1);break;case"deleteContentForward":v===w&&(S+=1);break}g.preventDefault(),(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:A||"",willCommit:!1,selStart:E,selEnd:S}})}),this._setEventListeners(s,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(u&&s.addEventListener("blur",u),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${g}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}}class ym extends ir{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class vm extends ir{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let 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");const n=document.createElement("input");return Qn.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=cl,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s)){const d=l&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=d),t.setValue(c.id,{value:d})}t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};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)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class rf extends ir{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let 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(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const n=document.createElement("input");if(Qn.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=cl,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;n.addEventListener("updatefromsandbox",o=>{const l={value:c=>{const d=a===c.detail.value;for(const u of this._getElementsByName(c.target.name)){const f=d&&u.id===s;u.domElement&&(u.domElement.checked=f),t.setValue(u.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class _m extends ef{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class wm extends ir{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Qn.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=cl;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",d=>{const u=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===u});for(const d of this.data.options){const u=document.createElement("option");u.textContent=d.displayValue,u.value=d.exportValue,s.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),n=!1),i.append(u)}let a=null;if(n){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),a=()=>{d.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=d=>{const u=d?"value":"textContent",{options:f,multiple:g}=i;return g?Array.prototype.filter.call(f,A=>A.selected).map(A=>A[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const c=d=>{const u=d.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const u={value(f){a==null||a();const g=f.detail.value,A=new Set(Array.isArray(g)?g:[g]);for(const y of i.options)y.selected=A.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const g=i.options,A=f.detail.remove;g[A].selected=!1,i.remove(A),g.length>0&&Array.prototype.findIndex.call(g,_=>_.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(f){const{index:g,displayValue:A,exportValue:y}=f.detail.insert,_=i.children[g],v=document.createElement("option");v.textContent=A,v.value=y,_?_.before(v):i.append(v),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},items(f){const{items:g}=f.detail;for(;i.length!==0;)i.remove(0);for(const A of g){const{displayValue:y,exportValue:_}=A,v=document.createElement("option");v.textContent=y,v.value=_,i.append(v)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},indices(f){const g=new Set(f.detail.indices);for(const A of f.target.options)A.selected=g.has(A.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,d)}),i.addEventListener("input",d=>{var g;const u=o(!0),f=o(!1);t.setValue(e,{value:u}),d.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:f,changeEx:u,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"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Sc extends Ct{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:Ct._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Em({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(const 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=>`${od}${s}`).join(",")),this.container}}var Xr,ph,gh,Yr,Pn,wt,$s,Kr,Lo,Mo,Qr,Ws,ts,Vs,Io,qs,Fo,kn,Ln,ct,Il,xc,af,of,lf,hf,Fl,Dl,Cc;class Em{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:o,parent:l,rect:c,parentRect:d,open:u}){b(this,ct);b(this,Xr,m(this,ct,lf).bind(this));b(this,ph,m(this,ct,Cc).bind(this));b(this,gh,m(this,ct,Dl).bind(this));b(this,Yr,m(this,ct,Fl).bind(this));b(this,Pn,null);b(this,wt,null);b(this,$s,null);b(this,Kr,null);b(this,Lo,null);b(this,Mo,null);b(this,Qr,null);b(this,Ws,!1);b(this,ts,null);b(this,Vs,null);b(this,Io,null);b(this,qs,null);b(this,Fo,null);b(this,kn,null);b(this,Ln,!1);var f;p(this,wt,t),p(this,Fo,i),p(this,$s,a),p(this,qs,o),p(this,Mo,l),p(this,Pn,e),p(this,Io,c),p(this,Qr,d),p(this,Lo,s),p(this,Kr,cd.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",r(this,Yr)),g.addEventListener("mouseenter",r(this,gh)),g.addEventListener("mouseleave",r(this,ph)),g.classList.add("popupTriggerArea");for(const g of s)(f=g.container)==null||f.addEventListener("keydown",r(this,Xr));r(this,wt).hidden=!0,u&&m(this,ct,Fl).call(this)}render(){if(r(this,ts))return;const t=p(this,ts,document.createElement("div"));if(t.className="popup",r(this,Pn)){const n=t.style.outlineColor=N.makeHexColor(...r(this,Pn));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=N.makeHexColor(...r(this,Pn).map(o=>Math.floor(.7*(255-o)+o)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=r(this,Fo),t.append(e),r(this,Kr)){const 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:r(this,Kr).valueOf()})),e.append(n)}const i=r(this,ct,Il);if(i)tf.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(r(this,$s));t.append(n)}r(this,wt).append(t)}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let n=0,a=i.length;n<a;++n){const o=i[n];s.append(document.createTextNode(o)),n<a-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popupContent:e}){var s;r(this,kn)||p(this,kn,{contentsObj:r(this,$s),richText:r(this,qs)}),t&&p(this,Vs,null),e&&(p(this,qs,m(this,ct,of).call(this,e)),p(this,$s,null)),(s=r(this,ts))==null||s.remove(),p(this,ts,null)}resetEdited(){var t;r(this,kn)&&({contentsObj:oe(this,$s)._,richText:oe(this,qs)._}=r(this,kn),p(this,kn,null),(t=r(this,ts))==null||t.remove(),p(this,ts,null),p(this,Vs,null))}forceHide(){p(this,Ln,this.isVisible),r(this,Ln)&&(r(this,wt).hidden=!0)}maybeShow(){r(this,Ln)&&(r(this,ts)||m(this,ct,Dl).call(this),p(this,Ln,!1),r(this,wt).hidden=!1)}get isVisible(){return r(this,wt).hidden===!1}}Xr=new WeakMap,ph=new WeakMap,gh=new WeakMap,Yr=new WeakMap,Pn=new WeakMap,wt=new WeakMap,$s=new WeakMap,Kr=new WeakMap,Lo=new WeakMap,Mo=new WeakMap,Qr=new WeakMap,Ws=new WeakMap,ts=new WeakMap,Vs=new WeakMap,Io=new WeakMap,qs=new WeakMap,Fo=new WeakMap,kn=new WeakMap,Ln=new WeakMap,ct=new WeakSet,Il=function(){const t=r(this,qs),e=r(this,$s);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&r(this,qs).html||null},xc=function(){var t,e,s;return((s=(e=(t=r(this,ct,Il))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},af=function(){var t,e,s;return((s=(e=(t=r(this,ct,Il))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},of=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:r(this,ct,af),fontSize:r(this,ct,xc)?`calc(${r(this,ct,xc)}px * var(--scale-factor))`:""}};for(const n of t.split(`
4
+ `))e.push({name:"span",value:n,attributes:i});return s},lf=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&r(this,Ws))&&m(this,ct,Fl).call(this)},hf=function(){if(r(this,Vs)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=r(this,Mo);let a=!!r(this,Qr),o=a?r(this,Qr):r(this,Io);for(const A of r(this,Lo))if(!o||N.intersect(A.data.rect,o)!==null){o=A.data.rect,a=!0;break}const l=N.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),d=a?o[2]-o[0]+5:0,u=l[0]+d,f=l[1];p(this,Vs,[100*(u-i)/e,100*(f-n)/s]);const{style:g}=r(this,wt);g.left=`${r(this,Vs)[0]}%`,g.top=`${r(this,Vs)[1]}%`},Fl=function(){p(this,Ws,!r(this,Ws)),r(this,Ws)?(m(this,ct,Dl).call(this),r(this,wt).addEventListener("click",r(this,Yr)),r(this,wt).addEventListener("keydown",r(this,Xr))):(m(this,ct,Cc).call(this),r(this,wt).removeEventListener("click",r(this,Yr)),r(this,wt).removeEventListener("keydown",r(this,Xr)))},Dl=function(){r(this,ts)||this.render(),this.isVisible?r(this,Ws)&&r(this,wt).classList.add("focused"):(m(this,ct,hf).call(this),r(this,wt).hidden=!1,r(this,wt).style.zIndex=parseInt(r(this,wt).style.zIndex)+1e3)},Cc=function(){r(this,wt).classList.remove("focused"),!(r(this,Ws)||!this.isVisible)&&(r(this,wt).hidden=!0,r(this,wt).style.zIndex=parseInt(r(this,wt).style.zIndex)-1e3)};class cf extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=X.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const 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}}var Do;class Sm extends Ct{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,Do,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:s,height:i}=ri(e.rect),n=this.svgFactory.create(s,i,!0),a=p(this,Do,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,Do)}addHighlightArea(){this.container.classList.add("highlightArea")}}Do=new WeakMap;var Oo;class xm extends Ct{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,Oo,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:s,height:i}=ri(e.rect),n=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,Oo,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),n.append(o),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,Oo)}addHighlightArea(){this.container.classList.add("highlightArea")}}Oo=new WeakMap;var No;class Cm extends Ct{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,No,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:s,height:i}=ri(e.rect),n=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,No,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),n.append(o),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,No)}addHighlightArea(){this.container.classList.add("highlightArea")}}No=new WeakMap;var Ho;class df extends Ct{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,Ho,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:n}}=this;if(!s)return this.container;const{width:a,height:o}=ri(e),l=this.svgFactory.create(a,o,!0);let c=[];for(let u=0,f=s.length;u<f;u+=2){const g=s[u]-e[0],A=e[3]-s[u+1];c.push(`${g},${A}`)}c=c.join(" ");const d=p(this,Ho,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",c),d.setAttribute("stroke-width",i.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),l.append(d),this.container.append(l),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,Ho)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ho=new WeakMap;class Tm extends df{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Rm extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var jo;class Ad extends Ct{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,jo,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?X.HIGHLIGHT:X.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,inkLists:s,borderStyle:i,popupRef:n}}=this,{width:a,height:o}=ri(e),l=this.svgFactory.create(a,o,!0);for(const c of s){let d=[];for(let f=0,g=c.length;f<g;f+=2){const A=c[f]-e[0],y=e[3]-c[f+1];d.push(`${A},${y}`)}d=d.join(" ");const u=this.svgFactory.createElement(this.svgElementName);r(this,jo).push(u),u.setAttribute("points",d),u.setAttribute("stroke-width",i.width||1),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),l.append(u)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}getElementsToTriggerPopup(){return r(this,jo)}addHighlightArea(){this.container.classList.add("highlightArea")}}jo=new WeakMap;class uf extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=X.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Pm extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class km extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Lm extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class ff extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=X.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var Bo,Uo,Tc;class Mm extends Ct{constructor(e){var i;super(e,{isRenderable:!0});b(this,Uo);b(this,Bo,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",m(this,Uo,Tc).bind(this)),p(this,Bo,i);const{isMac:n}=de.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(n?a.metaKey:a.ctrlKey)&&m(this,Uo,Tc).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return r(this,Bo)}addHighlightArea(){this.container.classList.add("highlightArea")}}Bo=new WeakMap,Uo=new WeakSet,Tc=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var zo,Mn,In,Go,Zn,pf,Rc,tu;let Im=(tu=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a,structTreeLayer:o}){b(this,Zn);b(this,zo,null);b(this,Mn,null);b(this,In,new Map);b(this,Go,null);this.div=t,p(this,zo,e),p(this,Mn,s),p(this,Go,o||null),this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return r(this,In).size>0}async render(t){var a;const{annotations:e}=t,s=this.div;Yn(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new bd,annotationStorage:t.annotationStorage||new ud,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const o of e){if(o.noHTML)continue;const l=o.annotationType===Lt.POPUP;if(l){const u=i.get(o.id);if(!u)continue;n.elements=u}else{const{width:u,height:f}=ri(o.rect);if(u<=0||f<=0)continue}n.data=o;const c=mm.create(n);if(!c.isRenderable)continue;if(!l&&o.popupRef){const u=i.get(o.popupRef);u?u.push(c):i.set(o.popupRef,[c])}const d=c.render();o.hidden&&(d.style.visibility="hidden"),await m(this,Zn,pf).call(this,d,o.id),c._isEditable&&(r(this,In).set(c.data.id,c),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(c))}m(this,Zn,Rc).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,Yn(e,{rotation:t.rotation}),m(this,Zn,Rc).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(r(this,In).values())}getEditableAnnotation(t){return r(this,In).get(t)}},zo=new WeakMap,Mn=new WeakMap,In=new WeakMap,Go=new WeakMap,Zn=new WeakSet,pf=async function(t,e){var a,o;const s=t.firstChild||t,i=s.id=`${od}${e}`,n=await((a=r(this,Go))==null?void 0:a.getAriaAttributes(i));if(n)for(const[l,c]of n)s.setAttribute(l,c);this.div.append(t),(o=r(this,zo))==null||o.moveElementInDOM(this.div,t,s,!1)},Rc=function(){if(!r(this,Mn))return;const t=this.div;for(const[e,s]of r(this,Mn)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}r(this,Mn).clear()},tu);const yl=/\r\n?|\n/g;var es,xe,$o,Fn,Ce,kt,gf,mf,bf,Ol,oi,Nl,Hl,Af,kc,yf;const ut=class ut extends lt{constructor(e){super({...e,name:"freeTextEditor"});b(this,kt);b(this,es);b(this,xe,"");b(this,$o,`${this.id}-editor`);b(this,Fn,null);b(this,Ce);p(this,es,e.color||ut._defaultColor||lt._defaultLineColor),p(this,Ce,e.fontSize||ut._defaultFontSize)}static get _keyboardManager(){const e=ut.prototype,s=a=>a.isEmpty(),i=Kn.TRANSLATE_SMALL,n=Kn.TRANSLATE_BIG;return tt(this,"_keyboardManager",new hl([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}]]))}static initialize(e,s){lt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case G.FREETEXT_SIZE:ut._defaultFontSize=s;break;case G.FREETEXT_COLOR:ut._defaultColor=s;break}}updateParams(e,s){switch(e){case G.FREETEXT_SIZE:m(this,kt,gf).call(this,s);break;case G.FREETEXT_COLOR:m(this,kt,mf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[G.FREETEXT_SIZE,ut._defaultFontSize],[G.FREETEXT_COLOR,ut._defaultColor||lt._defaultLineColor]]}get propertiesToUpdate(){return[[G.FREETEXT_SIZE,r(this,Ce)],[G.FREETEXT_COLOR,r(this,es)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-ut._internalPadding*e,-(ut._internalPadding+r(this,Ce))*e]}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(X.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,Fn,new AbortController);const e=this._uiManager.combinedSignal(r(this,Fn));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){var e;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",r(this,$o)),this._isDraggable=!0,(e=r(this,Fn))==null||e.abort(),p(this,Fn,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var e;this.width||(this.enableEditMode(),this.editorDiv.focus(),(e=this._initialOptions)!=null&&e.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()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=r(this,xe),s=p(this,xe,m(this,kt,bf).call(this).trimEnd());if(e===s)return;const i=n=>{if(p(this,xe,n),!n){this.remove();return}m(this,kt,Hl).call(this),this._uiManager.rebuild(this),m(this,kt,Ol).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),m(this,kt,Ol).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){ut._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",r(this,$o)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${r(this,Ce)}px * var(--scale-factor))`,i.color=r(this,es),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Kl(this,this.div,["dblclick","keydown"]),this.width){const[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[d,u]=this.pageDimensions,[f,g]=this.pageTranslation;let A,y;switch(this.rotation){case 0:A=e+(o[0]-f)/d,y=s+this.height-(o[1]-g)/u;break;case 90:A=e+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,c]=[c,-l];break;case 180:A=e-this.width+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,c]=[-l,-c];break;case 270:A=e+(o[0]-f-this.height*u)/d,y=s+(o[1]-g-this.width*d)/u,[l,c]=[-c,l];break}this.setAt(A*n,y*a,l,c)}else this.setAt(e*n,s*a,this.width*n,this.height*a);m(this,kt,Hl).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var A,y,_;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=m(A=ut,oi,kc).call(A,s.getData("text")||"").replaceAll(yl,`
5
+ `);if(!n)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!n.includes(`
6
+ `)){o.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:c}=o,d=[],u=[];if(l.nodeType===Node.TEXT_NODE){const v=l.parentElement;if(u.push(l.nodeValue.slice(c).replaceAll(yl,"")),v!==this.editorDiv){let w=d;for(const E of this.editorDiv.childNodes){if(E===v){w=u;continue}w.push(m(y=ut,oi,Nl).call(y,E))}}d.push(l.nodeValue.slice(0,c).replaceAll(yl,""))}else if(l===this.editorDiv){let v=d,w=0;for(const E of this.editorDiv.childNodes)w++===c&&(v=u),v.push(m(_=ut,oi,Nl).call(_,E))}p(this,xe,`${d.join(`
7
+ `)}${n}${u.join(`
8
+ `)}`),m(this,kt,Hl).call(this);const f=new Range;let g=d.reduce((v,w)=>v+w.length,0);for(const{firstChild:v}of this.editorDiv.childNodes)if(v.nodeType===Node.TEXT_NODE){const w=v.nodeValue.length;if(g<=w){f.setStart(v,g),f.setEnd(v,g);break}g-=w}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}static async deserialize(e,s,i){var o;let n=null;if(e instanceof cf){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:d,rotation:u,id:f,popupRef:g},textContent:A,textPosition:y,parent:{page:{pageNumber:_}}}=e;if(!A||A.length===0)return null;n=e={annotationType:X.FREETEXT,color:Array.from(c),fontSize:l,value:A.join(`
9
+ `),position:y,pageIndex:_-1,rect:d.slice(0),rotation:u,id:f,deleted:!1,popupRef:g}}const a=await super.deserialize(e,s,i);return p(a,Ce,e.fontSize),p(a,es,N.makeHexColor(...e.color)),p(a,xe,m(o=ut,oi,kc).call(o,e.value)),a.annotationElementId=e.id||null,a._initialData=n,a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=ut._internalPadding*this.parentScale,i=this.getRect(s,s),n=lt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:r(this,es)),a={annotationType:X.FREETEXT,color:n,fontSize:r(this,Ce),value:m(this,kt,Af).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!m(this,kt,yf).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${r(this,Ce)}px * var(--scale-factor))`,i.color=r(this,es),s.replaceChildren();for(const a of r(this,xe).split(`
10
+ `)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const n=ut._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(n,n),popupContent:r(this,xe)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};es=new WeakMap,xe=new WeakMap,$o=new WeakMap,Fn=new WeakMap,Ce=new WeakMap,kt=new WeakSet,gf=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-r(this,Ce))*this.parentScale),p(this,Ce,n),m(this,kt,Ol).call(this)},i=r(this,Ce);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},mf=function(e){const s=n=>{p(this,es,this.editorDiv.style.color=n)},i=r(this,es);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},bf=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const n of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&n.nodeName==="BR"||(e.push(m(i=ut,oi,Nl).call(i,n)),s=n);return e.join(`
11
+ `)},Ol=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",n.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},oi=new WeakSet,Nl=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(yl,"")},Hl=function(){if(this.editorDiv.replaceChildren(),!!r(this,xe))for(const e of r(this,xe).split(`
12
+ `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Af=function(){return r(this,xe).replaceAll(" "," ")},kc=function(e){return e.replaceAll(" "," ")},yf=function(e){const{value:s,fontSize:i,color:n,pageIndex:a}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==n[l])||e.pageIndex!==a},b(ut,oi),z(ut,"_freeTextDefaultContent",""),z(ut,"_internalPadding",0),z(ut,"_defaultColor",null),z(ut,"_defaultFontSize",10),z(ut,"_type","freetext"),z(ut,"_editorType",X.FREETEXT);let Pc=ut,vf=class{toSVGPath(){pt("Abstract method `toSVGPath` must be implemented.")}get box(){pt("Abstract getter `box` must be implemented.")}serialize(t,e){pt("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){pt("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){pt("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}};var Te,ss,Jr,Zr,Es,Q,Dn,On,Wo,Vo,ta,ea,Li,qo,mh,bh,Ot,Da,_f,wf,Ef,Sf,xf,Cf;const Is=class Is{constructor({x:t,y:e},s,i,n,a,o=0){b(this,Ot);b(this,Te);b(this,ss,[]);b(this,Jr);b(this,Zr);b(this,Es,[]);b(this,Q,new Float64Array(18));b(this,Dn);b(this,On);b(this,Wo);b(this,Vo);b(this,ta);b(this,ea);b(this,Li,[]);p(this,Te,s),p(this,ea,n*i),p(this,Zr,a),r(this,Q).set([NaN,NaN,NaN,NaN,t,e],6),p(this,Jr,o),p(this,Vo,r(Is,qo)*i),p(this,Wo,r(Is,bh)*i),p(this,ta,i),r(this,Li).push(t,e)}isEmpty(){return isNaN(r(this,Q)[8])}add({x:t,y:e}){var L;p(this,Dn,t),p(this,On,e);const[s,i,n,a]=r(this,Te);let[o,l,c,d]=r(this,Q).subarray(8,12);const u=t-c,f=e-d,g=Math.hypot(u,f);if(g<r(this,Wo))return!1;const A=g-r(this,Vo),y=A/g,_=y*u,v=y*f;let w=o,E=l;o=c,l=d,c+=_,d+=v,(L=r(this,Li))==null||L.push(t,e);const S=-v/A,C=_/A,x=S*r(this,ea),T=C*r(this,ea);return r(this,Q).set(r(this,Q).subarray(2,8),0),r(this,Q).set([c+x,d+T],4),r(this,Q).set(r(this,Q).subarray(14,18),12),r(this,Q).set([c-x,d-T],16),isNaN(r(this,Q)[6])?(r(this,Es).length===0&&(r(this,Q).set([o+x,l+T],2),r(this,Es).push(NaN,NaN,NaN,NaN,(o+x-s)/n,(l+T-i)/a),r(this,Q).set([o-x,l-T],14),r(this,ss).push(NaN,NaN,NaN,NaN,(o-x-s)/n,(l-T-i)/a)),r(this,Q).set([w,E,o,l,c,d],6),!this.isEmpty()):(r(this,Q).set([w,E,o,l,c,d],6),Math.abs(Math.atan2(E-l,w-o)-Math.atan2(v,_))<Math.PI/2?([o,l,c,d]=r(this,Q).subarray(2,6),r(this,Es).push(NaN,NaN,NaN,NaN,((o+c)/2-s)/n,((l+d)/2-i)/a),[o,l,w,E]=r(this,Q).subarray(14,18),r(this,ss).push(NaN,NaN,NaN,NaN,((w+o)/2-s)/n,((E+l)/2-i)/a),!0):([w,E,o,l,c,d]=r(this,Q).subarray(0,6),r(this,Es).push(((w+5*o)/6-s)/n,((E+5*l)/6-i)/a,((5*o+c)/6-s)/n,((5*l+d)/6-i)/a,((o+c)/2-s)/n,((l+d)/2-i)/a),[c,d,o,l,w,E]=r(this,Q).subarray(12,18),r(this,ss).push(((w+5*o)/6-s)/n,((E+5*l)/6-i)/a,((5*o+c)/6-s)/n,((5*l+d)/6-i)/a,((o+c)/2-s)/n,((l+d)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=r(this,Es),e=r(this,ss);if(isNaN(r(this,Q)[6])&&!this.isEmpty())return m(this,Ot,_f).call(this);const 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]}`);m(this,Ot,Ef).call(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 m(this,Ot,wf).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,a){return new Tf(t,e,s,i,n,a)}getOutlines(){var u;const t=r(this,Es),e=r(this,ss),s=r(this,Q),[i,n,a,o]=r(this,Te),l=new Float64Array((((u=r(this,Li))==null?void 0:u.length)??0)+2);for(let f=0,g=l.length-2;f<g;f+=2)l[f]=(r(this,Li)[f]-i)/a,l[f+1]=(r(this,Li)[f+1]-n)/o;if(l[l.length-2]=(r(this,Dn)-i)/a,l[l.length-1]=(r(this,On)-n)/o,isNaN(s[6])&&!this.isEmpty())return m(this,Ot,Sf).call(this,l);const c=new Float64Array(r(this,Es).length+24+r(this,ss).length);let d=t.length;for(let f=0;f<d;f+=2){if(isNaN(t[f])){c[f]=c[f+1]=NaN;continue}c[f]=t[f],c[f+1]=t[f+1]}d=m(this,Ot,Cf).call(this,c,d);for(let f=e.length-6;f>=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){c[d]=c[d+1]=NaN,d+=2;continue}c[d]=e[f+g],c[d+1]=e[f+g+1],d+=2}return m(this,Ot,xf).call(this,c,d),this.newFreeDrawOutline(c,l,r(this,Te),r(this,ta),r(this,Jr),r(this,Zr))}};Te=new WeakMap,ss=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,Es=new WeakMap,Q=new WeakMap,Dn=new WeakMap,On=new WeakMap,Wo=new WeakMap,Vo=new WeakMap,ta=new WeakMap,ea=new WeakMap,Li=new WeakMap,qo=new WeakMap,mh=new WeakMap,bh=new WeakMap,Ot=new WeakSet,Da=function(){const t=r(this,Q).subarray(4,6),e=r(this,Q).subarray(16,18),[s,i,n,a]=r(this,Te);return[(r(this,Dn)+(t[0]-e[0])/2-s)/n,(r(this,On)+(t[1]-e[1])/2-i)/a,(r(this,Dn)+(e[0]-t[0])/2-s)/n,(r(this,On)+(e[1]-t[1])/2-i)/a]},_f=function(){const[t,e,s,i]=r(this,Te),[n,a,o,l]=m(this,Ot,Da).call(this);return`M${(r(this,Q)[2]-t)/s} ${(r(this,Q)[3]-e)/i} L${(r(this,Q)[4]-t)/s} ${(r(this,Q)[5]-e)/i} L${n} ${a} L${o} ${l} L${(r(this,Q)[16]-t)/s} ${(r(this,Q)[17]-e)/i} L${(r(this,Q)[14]-t)/s} ${(r(this,Q)[15]-e)/i} Z`},wf=function(t){const e=r(this,ss);t.push(`L${e[4]} ${e[5]} Z`)},Ef=function(t){const[e,s,i,n]=r(this,Te),a=r(this,Q).subarray(4,6),o=r(this,Q).subarray(16,18),[l,c,d,u]=m(this,Ot,Da).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/n} L${l} ${c} L${d} ${u} L${(o[0]-e)/i} ${(o[1]-s)/n}`)},Sf=function(t){const e=r(this,Q),[s,i,n,a]=r(this,Te),[o,l,c,d]=m(this,Ot,Da).call(this),u=new Float64Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/a],0),this.newFreeDrawOutline(u,t,r(this,Te),r(this,ta),r(this,Jr),r(this,Zr))},xf=function(t,e){const s=r(this,ss);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Cf=function(t,e){const s=r(this,Q).subarray(4,6),i=r(this,Q).subarray(16,18),[n,a,o,l]=r(this,Te),[c,d,u,f]=m(this,Ot,Da).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-a)/l],e),e+=24},b(Is,qo,8),b(Is,mh,2),b(Is,bh,r(Is,qo)+r(Is,mh));let Jl=Is;var sa,Nn,Xs,Xo,Re,Yo,xt,_e,Oa,Na,Rf;class Tf extends vf{constructor(e,s,i,n,a,o){super();b(this,_e);b(this,sa);b(this,Nn,null);b(this,Xs);b(this,Xo);b(this,Re);b(this,Yo);b(this,xt);p(this,xt,e),p(this,Re,s),p(this,sa,i),p(this,Yo,n),p(this,Xs,a),p(this,Xo,o),m(this,_e,Rf).call(this,o);const{x:l,y:c,width:d,height:u}=r(this,Nn);for(let f=0,g=e.length;f<g;f+=2)e[f]=(e[f]-l)/d,e[f+1]=(e[f+1]-c)/u;for(let f=0,g=s.length;f<g;f+=2)s[f]=(s[f]-l)/d,s[f+1]=(s[f+1]-c)/u}toSVGPath(){const e=[`M${r(this,xt)[4]} ${r(this,xt)[5]}`];for(let s=6,i=r(this,xt).length;s<i;s+=6){if(isNaN(r(this,xt)[s])){e.push(`L${r(this,xt)[s+4]} ${r(this,xt)[s+5]}`);continue}e.push(`C${r(this,xt)[s]} ${r(this,xt)[s+1]} ${r(this,xt)[s+2]} ${r(this,xt)[s+3]} ${r(this,xt)[s+4]} ${r(this,xt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,n],a){const o=i-e,l=n-s;let c,d;switch(a){case 0:c=m(this,_e,Oa).call(this,r(this,xt),e,n,o,-l),d=m(this,_e,Oa).call(this,r(this,Re),e,n,o,-l);break;case 90:c=m(this,_e,Na).call(this,r(this,xt),e,s,o,l),d=m(this,_e,Na).call(this,r(this,Re),e,s,o,l);break;case 180:c=m(this,_e,Oa).call(this,r(this,xt),i,s,-o,l),d=m(this,_e,Oa).call(this,r(this,Re),i,s,-o,l);break;case 270:c=m(this,_e,Na).call(this,r(this,xt),i,n,-o,-l),d=m(this,_e,Na).call(this,r(this,Re),i,n,-o,-l);break}return{outline:Array.from(c),points:[Array.from(d)]}}get box(){return r(this,Nn)}newOutliner(e,s,i,n,a,o=0){return new Jl(e,s,i,n,a,o)}getNewOutline(e,s){const{x:i,y:n,width:a,height:o}=r(this,Nn),[l,c,d,u]=r(this,sa),f=a*d,g=o*u,A=i*d+l,y=n*u+c,_=this.newOutliner({x:r(this,Re)[0]*f+A,y:r(this,Re)[1]*g+y},r(this,sa),r(this,Yo),e,r(this,Xo),s??r(this,Xs));for(let v=2;v<r(this,Re).length;v+=2)_.add({x:r(this,Re)[v]*f+A,y:r(this,Re)[v+1]*g+y});return _.getOutlines()}get mustRemoveSelfIntersections(){return!0}}sa=new WeakMap,Nn=new WeakMap,Xs=new WeakMap,Xo=new WeakMap,Re=new WeakMap,Yo=new WeakMap,xt=new WeakMap,_e=new WeakSet,Oa=function(e,s,i,n,a){const o=new Float64Array(e.length);for(let l=0,c=e.length;l<c;l+=2)o[l]=s+e[l]*n,o[l+1]=i+e[l+1]*a;return o},Na=function(e,s,i,n,a){const o=new Float64Array(e.length);for(let l=0,c=e.length;l<c;l+=2)o[l]=s+e[l+1]*n,o[l+1]=i+e[l]*a;return o},Rf=function(e){const s=r(this,xt);let i=s[4],n=s[5],a=i,o=n,l=i,c=n,d=i,u=n;const f=e?Math.max:Math.min;for(let v=6,w=s.length;v<w;v+=6){if(isNaN(s[v]))a=Math.min(a,s[v+4]),o=Math.min(o,s[v+5]),l=Math.max(l,s[v+4]),c=Math.max(c,s[v+5]),u<s[v+5]?(d=s[v+4],u=s[v+5]):u===s[v+5]&&(d=f(d,s[v+4]));else{const E=N.bezierBoundingBox(i,n,...s.slice(v,v+6));a=Math.min(a,E[0]),o=Math.min(o,E[1]),l=Math.max(l,E[2]),c=Math.max(c,E[3]),u<E[3]?(d=E[2],u=E[3]):u===E[3]&&(d=f(d,E[2]))}i=s[v+4],n=s[v+5]}const g=a-r(this,Xs),A=o-r(this,Xs),y=l-a+2*r(this,Xs),_=c-o+2*r(this,Xs);p(this,Nn,{x:g,y:A,width:y,height:_,lastPoint:[d,u]})};var Ko,Mi,is,fe,Pf,jl,kf,Lf,Lc;class zd{constructor(t,e=0,s=0,i=!0){b(this,fe);b(this,Ko);b(this,Mi,[]);b(this,is,[]);let n=1/0,a=-1/0,o=1/0,l=-1/0;const c=10**-4;for(const{x:_,y:v,width:w,height:E}of t){const S=Math.floor((_-e)/c)*c,C=Math.ceil((_+w+e)/c)*c,x=Math.floor((v-e)/c)*c,T=Math.ceil((v+E+e)/c)*c,R=[S,x,T,!0],L=[C,x,T,!1];r(this,Mi).push(R,L),n=Math.min(n,S),a=Math.max(a,C),o=Math.min(o,x),l=Math.max(l,T)}const d=a-n+2*s,u=l-o+2*s,f=n-s,g=o-s,A=r(this,Mi).at(i?-1:-2),y=[A[0],A[2]];for(const _ of r(this,Mi)){const[v,w,E]=_;_[0]=(v-f)/d,_[1]=(w-g)/u,_[2]=(E-g)/u}p(this,Ko,{x:f,y:g,width:d,height:u,lastPoint:y})}getOutlines(){r(this,Mi).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of r(this,Mi))e[3]?(t.push(...m(this,fe,Lc).call(this,e)),m(this,fe,kf).call(this,e)):(m(this,fe,Lf).call(this,e),t.push(...m(this,fe,Lc).call(this,e)));return m(this,fe,Pf).call(this,t)}}Ko=new WeakMap,Mi=new WeakMap,is=new WeakMap,fe=new WeakSet,Pf=function(t){const e=[],s=new Set;for(const a of t){const[o,l,c]=a;e.push([o,l,a],[o,c,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],c=e[a+1][2];l.push(c),c.push(l),s.add(l),s.add(c)}const i=[];let n;for(;s.size>0;){const a=s.values().next().value;let[o,l,c,d,u]=a;s.delete(a);let f=o,g=l;for(n=[o,c],i.push(n);;){let A;if(s.has(d))A=d;else if(s.has(u))A=u;else break;s.delete(A),[o,l,c,d,u]=A,f!==o&&(n.push(f,g,o,g===l?l:c),f=o),g=g===l?c:l}n.push(f,g)}return new Fm(i,r(this,Ko))},jl=function(t){const e=r(this,is);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,a=e[n][0];if(a===t)return n;a<t?s=n+1:i=n-1}return i+1},kf=function([,t,e]){const s=m(this,fe,jl).call(this,t);r(this,is).splice(s,0,[t,e])},Lf=function([,t,e]){const s=m(this,fe,jl).call(this,t);for(let i=s;i<r(this,is).length;i++){const[n,a]=r(this,is)[i];if(n!==t)break;if(n===t&&a===e){r(this,is).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,a]=r(this,is)[i];if(n!==t)break;if(n===t&&a===e){r(this,is).splice(i,1);return}}},Lc=function(t){const[e,s,i]=t,n=[[e,s,i]],a=m(this,fe,jl).call(this,i);for(let o=0;o<a;o++){const[l,c]=r(this,is)[o];for(let d=0,u=n.length;d<u;d++){const[,f,g]=n[d];if(!(c<=f||g<=l)){if(f>=l){if(g>c)n[d][1]=c;else{if(u===1)return[];n.splice(d,1),d--,u--}continue}n[d][2]=l,g>c&&n.push([e,c,g])}}}return n};var Qo,ia;class Fm extends vf{constructor(e,s){super();b(this,Qo);b(this,ia);p(this,ia,e),p(this,Qo,s)}toSVGPath(){const e=[];for(const s of r(this,ia)){let[i,n]=s;e.push(`M${i} ${n}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),n=l):l===n&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,n],a){const o=[],l=i-e,c=n-s;for(const d of r(this,ia)){const u=new Array(d.length);for(let f=0;f<d.length;f+=2)u[f]=e+d[f]*l,u[f+1]=n-d[f+1]*c;o.push(u)}return o}get box(){return r(this,Qo)}get classNamesForDrawing(){return["highlight"]}get classNamesForOutlining(){return["highlightOutline"]}}Qo=new WeakMap,ia=new WeakMap;class Mc extends Jl{newFreeDrawOutline(t,e,s,i,n,a){return new Dm(t,e,s,i,n,a)}get classNamesForDrawing(){return["highlight","free"]}}class Dm extends Tf{get classNamesForDrawing(){return["highlight","free"]}get classNamesForOutlining(){return["highlightOutline","free"]}newOutliner(t,e,s,i,n,a=0){return new Mc(t,e,s,i,n,a)}}var ns,Hn,na,It,Jo,ra,Zo,tl,Ii,rs,aa,el,ht,Ic,Fc,Dc,qi,Mf,di;const me=class me{constructor({editor:t=null,uiManager:e=null}){b(this,ht);b(this,ns,null);b(this,Hn,null);b(this,na);b(this,It,null);b(this,Jo,!1);b(this,ra,!1);b(this,Zo,null);b(this,tl);b(this,Ii,null);b(this,rs,null);b(this,aa);var s;t?(p(this,ra,!1),p(this,aa,G.HIGHLIGHT_COLOR),p(this,Zo,t)):(p(this,ra,!0),p(this,aa,G.HIGHLIGHT_DEFAULT_COLOR)),p(this,rs,(t==null?void 0:t._uiManager)||e),p(this,tl,r(this,rs)._eventBus),p(this,na,(t==null?void 0:t.color)||((s=r(this,rs))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),r(me,el)||p(me,el,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"}))}static get _keyboardManager(){return tt(this,"_keyboardManager",new hl([[["Escape","mac+Escape"],me.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],me.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],me.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],me.prototype._moveToPrevious],[["Home","mac+Home"],me.prototype._moveToBeginning],[["End","mac+End"],me.prototype._moveToEnd]]))}renderButton(){const t=p(this,ns,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=r(this,rs)._signal;t.addEventListener("click",m(this,ht,qi).bind(this),{signal:e}),t.addEventListener("keydown",m(this,ht,Dc).bind(this),{signal:e});const s=p(this,Hn,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=r(this,na),t.append(s),t}renderMainDropdown(){const t=p(this,It,m(this,ht,Ic).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===r(this,ns)){m(this,ht,qi).call(this,t);return}const e=t.target.getAttribute("data-color");e&&m(this,ht,Fc).call(this,e,t)}_moveToNext(t){var e,s;if(!r(this,ht,di)){m(this,ht,qi).call(this,t);return}if(t.target===r(this,ns)){(e=r(this,It).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=r(this,It))==null?void 0:e.firstChild)||t.target===r(this,ns)){r(this,ht,di)&&this._hideDropdownFromKeyboard();return}r(this,ht,di)||m(this,ht,qi).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!r(this,ht,di)){m(this,ht,qi).call(this,t);return}(e=r(this,It).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!r(this,ht,di)){m(this,ht,qi).call(this,t);return}(e=r(this,It).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=r(this,It))==null||t.classList.add("hidden"),(e=r(this,Ii))==null||e.abort(),p(this,Ii,null)}_hideDropdownFromKeyboard(){var t;if(!r(this,ra)){if(!r(this,ht,di)){(t=r(this,Zo))==null||t.unselect();return}this.hideDropdown(),r(this,ns).focus({preventScroll:!0,focusVisible:r(this,Jo)})}}updateColor(t){if(r(this,Hn)&&(r(this,Hn).style.backgroundColor=t),!r(this,It))return;const e=r(this,rs).highlightColors.values();for(const s of r(this,It).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=r(this,ns))==null||t.remove(),p(this,ns,null),p(this,Hn,null),(e=r(this,It))==null||e.remove(),p(this,It,null)}};ns=new WeakMap,Hn=new WeakMap,na=new WeakMap,It=new WeakMap,Jo=new WeakMap,ra=new WeakMap,Zo=new WeakMap,tl=new WeakMap,Ii=new WeakMap,rs=new WeakMap,aa=new WeakMap,el=new WeakMap,ht=new WeakSet,Ic=function(){const t=document.createElement("div"),e=r(this,rs)._signal;t.addEventListener("contextmenu",Ge,{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(const[s,i]of r(this,rs).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",r(me,el)[s]);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=i,n.setAttribute("aria-selected",i===r(this,na)),n.addEventListener("click",m(this,ht,Fc).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",m(this,ht,Dc).bind(this),{signal:e}),t},Fc=function(t,e){e.stopPropagation(),r(this,tl).dispatch("switchannotationeditorparams",{source:this,type:r(this,aa),value:t})},Dc=function(t){me._keyboardManager.exec(this,t)},qi=function(t){if(r(this,ht,di)){this.hideDropdown();return}if(p(this,Jo,t.detail===0),r(this,Ii)||(p(this,Ii,new AbortController),window.addEventListener("pointerdown",m(this,ht,Mf).bind(this),{signal:r(this,rs).combinedSignal(r(this,Ii))})),r(this,It)){r(this,It).classList.remove("hidden");return}const e=p(this,It,m(this,ht,Ic).call(this));r(this,ns).append(e)},Mf=function(t){var e;(e=r(this,It))!=null&&e.contains(t.target)||this.hideDropdown()},di=function(){return r(this,It)&&!r(this,It).classList.contains("hidden")},b(me,el,null);let Zl=me;var oa,sl,Ys,jn,la,Ne,il,nl,Bn,as,ie,ye,ha,Ks,Ft,ca,He,rl,V,Oc,Bl,If,Ff,Df,Nc,Xi,Ue,ur,Of,Ul,Ha,Nf,Hf,jf,Bf,Uf;const it=class it extends lt{constructor(e){super({...e,name:"highlightEditor"});b(this,V);b(this,oa,null);b(this,sl,0);b(this,Ys);b(this,jn,null);b(this,la,null);b(this,Ne,null);b(this,il,null);b(this,nl,0);b(this,Bn,null);b(this,as,null);b(this,ie,null);b(this,ye,!1);b(this,ha,null);b(this,Ks);b(this,Ft,null);b(this,ca,"");b(this,He);b(this,rl,"");this.color=e.color||it._defaultColor,p(this,He,e.thickness||it._defaultThickness),p(this,Ks,e.opacity||it._defaultOpacity),p(this,Ys,e.boxes||null),p(this,rl,e.methodOfCreation||""),p(this,ca,e.text||""),this._isDraggable=!1,e.highlightId>-1?(p(this,ye,!0),m(this,V,Bl).call(this,e),m(this,V,Xi).call(this)):r(this,Ys)&&(p(this,oa,e.anchorNode),p(this,sl,e.anchorOffset),p(this,il,e.focusNode),p(this,nl,e.focusOffset),m(this,V,Oc).call(this),m(this,V,Xi).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=it.prototype;return tt(this,"_keyboardManager",new hl([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:r(this,ye)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:r(this,He),methodOfCreation:r(this,rl)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;lt.initialize(e,s),it._defaultColor||(it._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case G.HIGHLIGHT_DEFAULT_COLOR:it._defaultColor=s;break;case G.HIGHLIGHT_THICKNESS:it._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return r(this,ha)}updateParams(e,s){switch(e){case G.HIGHLIGHT_COLOR:m(this,V,If).call(this,s);break;case G.HIGHLIGHT_THICKNESS:m(this,V,Ff).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[G.HIGHLIGHT_DEFAULT_COLOR,it._defaultColor],[G.HIGHLIGHT_THICKNESS,it._defaultThickness]]}get propertiesToUpdate(){return[[G.HIGHLIGHT_COLOR,this.color||it._defaultColor],[G.HIGHLIGHT_THICKNESS,r(this,He)||it._defaultThickness],[G.HIGHLIGHT_FREE,r(this,ye)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(p(this,la,new Zl({editor:this})),e.addColorPicker(r(this,la))),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(m(this,V,Ha).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,m(this,V,Ha).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){m(this,V,Nc).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,V,Xi).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?m(this,V,Nc).call(this):e&&(m(this,V,Xi).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var n,a,o;const{drawLayer:s}=this.parent;let i;r(this,ye)?(e=(e-this.rotation+360)%360,i=m(n=it,Ue,ur).call(n,r(this,as).box,e)):i=m(a=it,Ue,ur).call(a,this,e),s.rotate(r(this,ie),e),s.rotate(r(this,Ft),e),s.updateBox(r(this,ie),i),s.updateBox(r(this,Ft),m(o=it,Ue,ur).call(o,r(this,Ne).box,e))}render(){if(this.div)return this.div;const e=super.render();r(this,ca)&&(e.setAttribute("aria-label",r(this,ca)),e.setAttribute("role","mark")),r(this,ye)?e.classList.add("free"):this.div.addEventListener("keydown",m(this,V,Of).bind(this),{signal:this._uiManager._signal});const s=p(this,Bn,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=r(this,jn);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),Kl(this,r(this,Bn),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent.drawLayer.addClass(r(this,Ft),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(r(this,Ft),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:m(this,V,Ul).call(this,!0);break;case 1:case 3:m(this,V,Ul).call(this,!1);break}}select(){var e,s;super.select(),r(this,Ft)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,Ft),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(r(this,Ft),"selected"))}unselect(){var e;super.unselect(),r(this,Ft)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,Ft),"selected"),r(this,ye)||m(this,V,Ul).call(this,!1))}get _mustFixPosition(){return!r(this,ye)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(r(this,ie),e),this.parent.drawLayer.show(r(this,Ft),e))}static startHighlighting(e,s,{target:i,x:n,y:a}){const{x:o,y:l,width:c,height:d}=i.getBoundingClientRect(),u=new AbortController,f=e.combinedSignal(u),g=y=>{y.preventDefault(),y.stopPropagation()},A=y=>{u.abort(),m(this,Ue,Bf).call(this,e,y)};window.addEventListener("blur",A,{signal:f}),window.addEventListener("pointerup",A,{signal:f}),window.addEventListener("pointerdown",g,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Ge,{signal:f}),i.addEventListener("pointermove",m(this,Ue,jf).bind(this,e),{signal:f}),this._freeHighlight=new Mc({x:n,y:a},[o,l,c,d],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static async deserialize(e,s,i){var y,_,v,w;let n=null;if(e instanceof uf){const{data:{quadPoints:E,rect:S,rotation:C,id:x,color:T,opacity:R,popupRef:L},parent:{page:{pageNumber:O}}}=e;n=e={annotationType:X.HIGHLIGHT,color:Array.from(T),opacity:R,quadPoints:E,boxes:null,pageIndex:O-1,rect:S.slice(0),rotation:C,id:x,deleted:!1,popupRef:L}}else if(e instanceof Ad){const{data:{inkLists:E,rect:S,rotation:C,id:x,color:T,borderStyle:{rawWidth:R},popupRef:L},parent:{page:{pageNumber:O}}}=e;n=e={annotationType:X.HIGHLIGHT,color:Array.from(T),thickness:R,inkLists:E,boxes:null,pageIndex:O-1,rect:S.slice(0),rotation:C,id:x,deleted:!1,popupRef:L}}const{color:a,quadPoints:o,inkLists:l,opacity:c}=e,d=await super.deserialize(e,s,i);d.color=N.makeHexColor(...a),p(d,Ks,c||1),l&&p(d,He,e.thickness),d.annotationElementId=e.id||null,d._initialData=n;const[u,f]=d.pageDimensions,[g,A]=d.pageTranslation;if(o){const E=p(d,Ys,[]);for(let S=0;S<o.length;S+=8)E.push({x:(o[S]-g)/u,y:1-(o[S+1]-A)/f,width:(o[S+2]-o[S])/u,height:(o[S+1]-o[S+5])/f});m(y=d,V,Oc).call(y),m(_=d,V,Xi).call(_),d.rotate(d.rotation)}else if(l){p(d,ye,!0);const E=l[0],S={x:E[0]-g,y:f-(E[1]-A)},C=new Mc(S,[0,0,u,f],1,r(d,He)/2,!0,.001);for(let R=0,L=E.length;R<L;R+=2)S.x=E[R]-g,S.y=f-(E[R+1]-A),C.add(S);const{id:x,clipPathId:T}=s.drawLayer.draw(C,d.color,d._defaultOpacity,!0);m(v=d,V,Bl).call(v,{highlightOutlines:C.getOutlines(),highlightId:x,clipPathId:T}),m(w=d,V,Xi).call(w)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=this.getRect(0,0),i=lt._colorManager.convert(this.color),n={annotationType:X.HIGHLIGHT,color:i,opacity:r(this,Ks),thickness:r(this,He),quadPoints:m(this,V,Nf).call(this),outlines:m(this,V,Hf).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:m(this,V,Ha).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!m(this,V,Uf).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};oa=new WeakMap,sl=new WeakMap,Ys=new WeakMap,jn=new WeakMap,la=new WeakMap,Ne=new WeakMap,il=new WeakMap,nl=new WeakMap,Bn=new WeakMap,as=new WeakMap,ie=new WeakMap,ye=new WeakMap,ha=new WeakMap,Ks=new WeakMap,Ft=new WeakMap,ca=new WeakMap,He=new WeakMap,rl=new WeakMap,V=new WeakSet,Oc=function(){const e=new zd(r(this,Ys),.001);p(this,as,e.getOutlines()),{x:this.x,y:this.y,width:this.width,height:this.height}=r(this,as).box;const s=new zd(r(this,Ys),.0025,.001,this._uiManager.direction==="ltr");p(this,Ne,s.getOutlines());const{lastPoint:i}=r(this,Ne).box;p(this,ha,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Bl=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var u,f;if(p(this,as,e),p(this,Ne,e.getNewOutline(r(this,He)/2+1.5,.0025)),s>=0)p(this,ie,s),p(this,jn,i),this.parent.drawLayer.finalizeLine(s,e),p(this,Ft,this.parent.drawLayer.drawOutline(r(this,Ne)));else if(this.parent){const g=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(r(this,ie),e),this.parent.drawLayer.updateBox(r(this,ie),m(u=it,Ue,ur).call(u,r(this,as).box,(g-this.rotation+360)%360)),this.parent.drawLayer.updateLine(r(this,Ft),r(this,Ne)),this.parent.drawLayer.updateBox(r(this,Ft),m(f=it,Ue,ur).call(f,r(this,Ne).box,g))}const{x:a,y:o,width:l,height:c}=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=c;break;case 90:{const[g,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/g,this.height=c*g/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[g,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/g,this.height=c*g/A;break}}const{lastPoint:d}=r(this,Ne).box;p(this,ha,[(d[0]-a)/l,(d[1]-o)/c])},If=function(e){const s=(a,o)=>{var l,c,d;this.color=a,(l=this.parent)==null||l.drawLayer.changeColor(r(this,ie),a),(c=r(this,la))==null||c.updateColor(a),p(this,Ks,o),(d=this.parent)==null||d.drawLayer.changeOpacity(r(this,ie),o)},i=this.color,n=r(this,Ks);this.addCommands({cmd:s.bind(this,e,it._defaultOpacity),undo:s.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},Ff=function(e){const s=r(this,He),i=n=>{p(this,He,n),m(this,V,Df).call(this,n)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Df=function(e){if(!r(this,ye))return;m(this,V,Bl).call(this,{highlightOutlines:r(this,as).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Nc=function(){r(this,ie)===null||!this.parent||(this.parent.drawLayer.remove(r(this,ie)),p(this,ie,null),this.parent.drawLayer.remove(r(this,Ft)),p(this,Ft,null))},Xi=function(e=this.parent){r(this,ie)===null&&({id:oe(this,ie)._,clipPathId:oe(this,jn)._}=e.drawLayer.draw(r(this,as),this.color,r(this,Ks)),p(this,Ft,e.drawLayer.drawOutline(r(this,Ne))),r(this,Bn)&&(r(this,Bn).style.clipPath=r(this,jn)))},Ue=new WeakSet,ur=function({x:e,y:s,width:i,height:n},a){switch(a){case 90:return{x:1-s-n,y:e,width:n,height:i};case 180:return{x:1-e-i,y:1-s-n,width:i,height:n};case 270:return{x:s,y:1-e-i,width:n,height:i}}return{x:e,y:s,width:i,height:n}},Of=function(e){it._keyboardManager.exec(this,e)},Ul=function(e){if(!r(this,oa))return;const s=window.getSelection();e?s.setPosition(r(this,oa),r(this,sl)):s.setPosition(r(this,il),r(this,nl))},Ha=function(){return r(this,ye)?this.rotation:0},Nf=function(){if(r(this,ye))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,a=r(this,Ys),o=new Float32Array(a.length*8);let l=0;for(const{x:c,y:d,width:u,height:f}of a){const g=c*e+i,A=(1-d-f)*s+n;o[l]=o[l+4]=g,o[l+1]=o[l+3]=A,o[l+2]=o[l+6]=g+u*e,o[l+5]=o[l+7]=A+f*s,l+=8}return o},Hf=function(e){return r(this,as).serialize(e,m(this,V,Ha).call(this))},jf=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Bf=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Uf=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},b(it,Ue),z(it,"_defaultColor",null),z(it,"_defaultOpacity",1),z(it,"_defaultThickness",12),z(it,"_type","highlight"),z(it,"_editorType",X.HIGHLIGHT),z(it,"_freeHighlightId",-1),z(it,"_freeHighlight",null),z(it,"_freeHighlightClipId","");let th=it;var Un,zn,Ss,Qs,je,Gn,$n,Wn,Js,da,Vn,qn,Fi,P,zf,Gf,$f,Wf,jc,Vf,Bc,qf,Xf,Yf,Kf,Qf,Yi,Uc,zc,Gc,zl,Gl,fr,$c,$l,hi,Jf,Wc,Zf,tp,Vc,Wl,ja;const bt=class bt extends lt{constructor(e){super({...e,name:"inkEditor"});b(this,P);b(this,Un,0);b(this,zn,0);b(this,Ss,null);b(this,Qs,new Path2D);b(this,je,!1);b(this,Gn,null);b(this,$n,!1);b(this,Wn,!1);b(this,Js,null);b(this,da,null);b(this,Vn,0);b(this,qn,0);b(this,Fi,null);this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(e,s){lt.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case G.INK_THICKNESS:bt._defaultThickness=s;break;case G.INK_COLOR:bt._defaultColor=s;break;case G.INK_OPACITY:bt._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case G.INK_THICKNESS:m(this,P,zf).call(this,s);break;case G.INK_COLOR:m(this,P,Gf).call(this,s);break;case G.INK_OPACITY:m(this,P,$f).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[G.INK_THICKNESS,bt._defaultThickness],[G.INK_COLOR,bt._defaultColor||lt._defaultLineColor],[G.INK_OPACITY,Math.round(bt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[G.INK_THICKNESS,this.thickness||bt._defaultThickness],[G.INK_COLOR,this.color||bt._defaultColor||lt._defaultLineColor],[G.INK_OPACITY,Math.round(100*(this.opacity??bt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(m(this,P,zl).call(this),m(this,P,Gl).call(this)),this.isAttachedToDOM||(this.parent.add(this),m(this,P,fr).call(this)),m(this,P,ja).call(this)))}remove(){var e;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,r(this,Ss)&&(clearTimeout(r(this,Ss)),p(this,Ss,null)),(e=r(this,Js))==null||e.disconnect(),p(this,Js,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&e===null&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){const[e,s]=this.parentDimensions,i=this.width*e,n=this.height*s;this.setDimensions(i,n)}enableEditMode(){r(this,je)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,m(this,P,Uc).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),m(this,P,zc).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){r(this,je)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),p(this,je,!0),this.div.classList.add("disabled"),m(this,P,ja).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),this.enableEditMode())}canvasPointerdown(e){e.button!==0||!this.isInEditMode()||r(this,je)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),m(this,P,Vf).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),m(this,P,Bc).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),m(this,P,Gc).call(this,e)}canvasPointerleave(e){m(this,P,Gc).call(this,e)}get isResizable(){return!this.isEmpty()&&r(this,je)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,n,a,o]=m(this,P,Wf).call(this);if(this.setAt(i,n,0,0),this.setDims(a,o),m(this,P,zl).call(this),this.width){const[l,c]=this.parentDimensions;this.setAspectRatio(this.width*l,this.height*c),this.setAt(e*l,s*c,this.width*l,this.height*c),p(this,Wn,!0),m(this,P,fr).call(this),this.setDims(this.width*l,this.height*c),m(this,P,Yi).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return m(this,P,Gl).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(r(this,Vn)===i&&r(this,qn)===n)return;p(this,Vn,i),p(this,qn,n),this.canvas.style.visibility="hidden";const[a,o]=this.parentDimensions;this.width=e/a,this.height=s/o,this.fixAndSetPosition(),r(this,je)&&m(this,P,$c).call(this,e,s),m(this,P,fr).call(this),m(this,P,Yi).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(e,s,i){var _,v,w;if(e instanceof Ad)return null;const n=await super.deserialize(e,s,i);n.thickness=e.thickness,n.color=N.makeHexColor(...e.color),n.opacity=e.opacity;const[a,o]=n.pageDimensions,l=n.width*a,c=n.height*o,d=n.parentScale,u=e.thickness/2;p(n,je,!0),p(n,Vn,Math.round(l)),p(n,qn,Math.round(c));const{paths:f,rect:g,rotation:A}=e;for(let{bezier:E}of f){E=m(_=bt,hi,Zf).call(_,E,g,A);const S=[];n.paths.push(S);let C=d*(E[0]-u),x=d*(E[1]-u);for(let R=2,L=E.length;R<L;R+=6){const O=d*(E[R]-u),I=d*(E[R+1]-u),J=d*(E[R+2]-u),U=d*(E[R+3]-u),B=d*(E[R+4]-u),q=d*(E[R+5]-u);S.push([[C,x],[O,I],[J,U],[B,q]]),C=B,x=q}const T=m(this,hi,Jf).call(this,S);n.bezierPath2D.push(T)}const y=m(v=n,P,Vc).call(v);return p(n,zn,Math.max(lt.MIN_SIZE,y[2]-y[0])),p(n,Un,Math.max(lt.MIN_SIZE,y[3]-y[1])),m(w=n,P,$c).call(w,l,c),n}serialize(){if(this.isEmpty())return null;const e=this.getRect(0,0),s=lt._colorManager.convert(this.ctx.strokeStyle);return{annotationType:X.INK,color:s,thickness:this.thickness,opacity:this.opacity,paths:m(this,P,tp).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};Un=new WeakMap,zn=new WeakMap,Ss=new WeakMap,Qs=new WeakMap,je=new WeakMap,Gn=new WeakMap,$n=new WeakMap,Wn=new WeakMap,Js=new WeakMap,da=new WeakMap,Vn=new WeakMap,qn=new WeakMap,Fi=new WeakMap,P=new WeakSet,zf=function(e){const s=n=>{this.thickness=n,m(this,P,ja).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},Gf=function(e){const s=n=>{this.color=n,m(this,P,Yi).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},$f=function(e){const s=n=>{this.opacity=n,m(this,P,Yi).call(this)};e/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},Wf=function(){const{parentRotation:e,parentDimensions:[s,i]}=this;switch(e){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},jc=function(){const{ctx:e,color:s,opacity:i,thickness:n,parentScale:a,scaleFactor:o}=this;e.lineWidth=n*a/o,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${s}${ig(i)}`},Vf=function(e,s){this.canvas.addEventListener("contextmenu",Ge,{signal:this._uiManager._signal}),m(this,P,zc).call(this),p(this,Gn,new AbortController);const i=this._uiManager.combinedSignal(r(this,Gn));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,r(this,Wn)||(p(this,Wn,!0),m(this,P,fr).call(this),this.thickness||(this.thickness=bt._defaultThickness),this.color||(this.color=bt._defaultColor||lt._defaultLineColor),this.opacity??(this.opacity=bt._defaultOpacity)),this.currentPath.push([e,s]),p(this,$n,!1),m(this,P,jc).call(this),p(this,Fi,()=>{m(this,P,Yf).call(this),r(this,Fi)&&window.requestAnimationFrame(r(this,Fi))}),window.requestAnimationFrame(r(this,Fi))},Bc=function(e,s){const[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&s===n)return;const a=this.currentPath;let o=r(this,Qs);if(a.push([e,s]),p(this,$n,!0),a.length<=2){o.moveTo(...a[0]),o.lineTo(e,s);return}a.length===3&&(p(this,Qs,o=new Path2D),o.moveTo(...a[0])),m(this,P,Kf).call(this,o,...a.at(-3),...a.at(-2),e,s)},qf=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);r(this,Qs).lineTo(...e)},Xf=function(e,s){p(this,Fi,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),m(this,P,Bc).call(this,e,s),m(this,P,qf).call(this);let i;if(this.currentPath.length!==1)i=m(this,P,Qf).call(this);else{const c=[e,s];i=[[c,c.slice(),c.slice(),c]]}const n=r(this,Qs),a=this.currentPath;this.currentPath=[],p(this,Qs,new Path2D);const o=()=>{this.allRawPaths.push(a),this.paths.push(i),this.bezierPath2D.push(n),this._uiManager.rebuild(this)},l=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(m(this,P,zl).call(this),m(this,P,Gl).call(this)),m(this,P,ja).call(this))};this.addCommands({cmd:o,undo:l,mustExec:!0})},Yf=function(){if(!r(this,$n))return;p(this,$n,!1);const e=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(o=>o[0]),n=s.map(o=>o[1]);Math.min(...i)-e,Math.max(...i)+e,Math.min(...n)-e,Math.max(...n)+e;const{ctx:a}=this;a.save(),a.clearRect(0,0,this.canvas.width,this.canvas.height);for(const o of this.bezierPath2D)a.stroke(o);a.stroke(r(this,Qs)),a.restore()},Kf=function(e,s,i,n,a,o,l){const c=(s+n)/2,d=(i+a)/2,u=(n+o)/2,f=(a+l)/2;e.bezierCurveTo(c+2*(n-c)/3,d+2*(a-d)/3,u+2*(n-u)/3,f+2*(a-f)/3,u,f)},Qf=function(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const s=[];let i,[n,a]=e[0];for(i=1;i<e.length-2;i++){const[g,A]=e[i],[y,_]=e[i+1],v=(g+y)/2,w=(A+_)/2,E=[n+2*(g-n)/3,a+2*(A-a)/3],S=[v+2*(g-v)/3,w+2*(A-w)/3];s.push([[n,a],E,S,[v,w]]),[n,a]=[v,w]}const[o,l]=e[i],[c,d]=e[i+1],u=[n+2*(o-n)/3,a+2*(l-a)/3],f=[c+2*(o-c)/3,d+2*(l-d)/3];return s.push([[n,a],u,f,[c,d]]),s},Yi=function(){if(this.isEmpty()){m(this,P,$l).call(this);return}m(this,P,jc).call(this);const{canvas:e,ctx:s}=this;s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e.width,e.height),m(this,P,$l).call(this);for(const i of this.bezierPath2D)s.stroke(i)},Uc=function(){if(r(this,da))return;p(this,da,new AbortController);const e=this._uiManager.combinedSignal(r(this,da));this.canvas.addEventListener("pointerdown",this.canvasPointerdown.bind(this),{signal:e})},zc=function(){var e;(e=this.pointerdownAC)==null||e.abort(),this.pointerdownAC=null},Gc=function(e){var s;(s=r(this,Gn))==null||s.abort(),p(this,Gn,null),m(this,P,Uc).call(this),r(this,Ss)&&clearTimeout(r(this,Ss)),p(this,Ss,setTimeout(()=>{p(this,Ss,null),this.canvas.removeEventListener("contextmenu",Ge)},10)),m(this,P,Xf).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},zl=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},Gl=function(){p(this,Js,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),r(this,Js).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,Js))==null||e.disconnect(),p(this,Js,null)},{once:!0})},fr=function(){if(!r(this,Wn))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),m(this,P,$l).call(this)},$c=function(e,s){const i=m(this,P,Wl).call(this),n=(e-i)/r(this,zn),a=(s-i)/r(this,Un);this.scaleFactor=Math.min(n,a)},$l=function(){const e=m(this,P,Wl).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},hi=new WeakSet,Jf=function(e){const s=new Path2D;for(let i=0,n=e.length;i<n;i++){const[a,o,l,c]=e[i];i===0&&s.moveTo(...a),s.bezierCurveTo(o[0],o[1],l[0],l[1],c[0],c[1])}return s},Wc=function(e,s,i){const[n,a,o,l]=s;switch(i){case 0:for(let c=0,d=e.length;c<d;c+=2)e[c]+=n,e[c+1]=l-e[c+1];break;case 90:for(let c=0,d=e.length;c<d;c+=2){const u=e[c];e[c]=e[c+1]+n,e[c+1]=u+a}break;case 180:for(let c=0,d=e.length;c<d;c+=2)e[c]=o-e[c],e[c+1]+=a;break;case 270:for(let c=0,d=e.length;c<d;c+=2){const u=e[c];e[c]=o-e[c+1],e[c+1]=l-u}break;default:throw new Error("Invalid rotation")}return e},Zf=function(e,s,i){const[n,a,o,l]=s;switch(i){case 0:for(let c=0,d=e.length;c<d;c+=2)e[c]-=n,e[c+1]=l-e[c+1];break;case 90:for(let c=0,d=e.length;c<d;c+=2){const u=e[c];e[c]=e[c+1]-a,e[c+1]=u-n}break;case 180:for(let c=0,d=e.length;c<d;c+=2)e[c]=o-e[c],e[c+1]-=a;break;case 270:for(let c=0,d=e.length;c<d;c+=2){const u=e[c];e[c]=l-e[c+1],e[c+1]=o-u}break;default:throw new Error("Invalid rotation")}return e},tp=function(e,s,i,n){var d,u;const a=[],o=this.thickness/2,l=e*s+o,c=e*i+o;for(const f of this.paths){const g=[],A=[];for(let y=0,_=f.length;y<_;y++){const[v,w,E,S]=f[y];if(v[0]===S[0]&&v[1]===S[1]&&_===1){const U=e*v[0]+l,B=e*v[1]+c;g.push(U,B),A.push(U,B);break}const C=e*v[0]+l,x=e*v[1]+c,T=e*w[0]+l,R=e*w[1]+c,L=e*E[0]+l,O=e*E[1]+c,I=e*S[0]+l,J=e*S[1]+c;y===0&&(g.push(C,x),A.push(C,x)),g.push(T,R,L,O,I,J),A.push(T,R),y===_-1&&A.push(I,J)}a.push({bezier:m(d=bt,hi,Wc).call(d,g,n,this.rotation),points:m(u=bt,hi,Wc).call(u,A,n,this.rotation)})}return a},Vc=function(){let e=1/0,s=-1/0,i=1/0,n=-1/0;for(const a of this.paths)for(const[o,l,c,d]of a){const u=N.bezierBoundingBox(...o,...l,...c,...d);e=Math.min(e,u[0]),i=Math.min(i,u[1]),s=Math.max(s,u[2]),n=Math.max(n,u[3])}return[e,i,s,n]},Wl=function(){return r(this,je)?Math.ceil(this.thickness*this.parentScale):0},ja=function(e=!1){if(this.isEmpty())return;if(!r(this,je)){m(this,P,Yi).call(this);return}const s=m(this,P,Vc).call(this),i=m(this,P,Wl).call(this);p(this,zn,Math.max(lt.MIN_SIZE,s[2]-s[0])),p(this,Un,Math.max(lt.MIN_SIZE,s[3]-s[1]));const n=Math.ceil(i+r(this,zn)*this.scaleFactor),a=Math.ceil(i+r(this,Un)*this.scaleFactor),[o,l]=this.parentDimensions;this.width=n/o,this.height=a/l,this.setAspectRatio(n,a);const c=this.translationX,d=this.translationY;this.translationX=-s[0],this.translationY=-s[1],m(this,P,fr).call(this),m(this,P,Yi).call(this),p(this,Vn,n),p(this,qn,a),this.setDims(n,a);const u=e?i/this.scaleFactor/2:0;this.translate(c-this.translationX-u,d-this.translationY-u)},b(bt,hi),z(bt,"_defaultColor",null),z(bt,"_defaultOpacity",1),z(bt,"_defaultThickness",1),z(bt,"_type","ink"),z(bt,"_editorType",X.INK);let Hc=bt;var yt,qt,Di,Zs,Oi,ua,xs,ti,Cs,Pe,fa,Z,Ba,Ua,Vl,Xc,ep,ql,Yc,Xl,sp,ip;const $a=class $a extends lt{constructor(e){super({...e,name:"stampEditor"});b(this,Z);b(this,yt,null);b(this,qt,null);b(this,Di,null);b(this,Zs,null);b(this,Oi,null);b(this,ua,"");b(this,xs,null);b(this,ti,null);b(this,Cs,null);b(this,Pe,!1);b(this,fa,!1);p(this,Zs,e.bitmapUrl),p(this,Oi,e.bitmapFile)}static initialize(e,s){lt.initialize(e,s)}static get supportedTypes(){return tt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return tt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(X.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:n,width:a,height:o,channels:n.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var e,s;r(this,qt)&&(p(this,yt,null),this._uiManager.imageManager.deleteId(r(this,qt)),(e=r(this,xs))==null||e.remove(),p(this,xs,null),(s=r(this,ti))==null||s.disconnect(),p(this,ti,null),r(this,Cs)&&(clearTimeout(r(this,Cs)),p(this,Cs,null))),super.remove()}rebuild(){if(!this.parent){r(this,qt)&&m(this,Z,Vl).call(this);return}super.rebuild(),this.div!==null&&(r(this,qt)&&r(this,xs)===null&&m(this,Z,Vl).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(r(this,Di)||r(this,yt)||r(this,Zs)||r(this,Oi)||r(this,qt))}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;if(this.width&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),r(this,yt)?m(this,Z,Xc).call(this):m(this,Z,Vl).call(this),this.width&&!this.annotationElementId){const[i,n]=this.parentDimensions;this.setAt(e*i,s*n,this.width*i,this.height*n)}return this.div}copyCanvas(e,s,i=!1){var g;e||(e=224);const{width:n,height:a}=r(this,yt),o=new Gh;let l=r(this,yt),c=n,d=a,u=null;if(s){if(n>s||a>s){const R=Math.min(s/n,s/a);c=Math.floor(n*R),d=Math.floor(a*R)}u=document.createElement("canvas");const A=u.width=Math.ceil(c*o.sx),y=u.height=Math.ceil(d*o.sy);r(this,Pe)||(l=m(this,Z,ql).call(this,A,y));const _=u.getContext("2d");_.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":(g=window.matchMedia)!=null&&g.call(window,"(prefers-color-scheme: dark)").matches&&(v="#8f8f9d",w="#42414d");const E=15,S=E*o.sx,C=E*o.sy,x=new OffscreenCanvas(S*2,C*2),T=x.getContext("2d");T.fillStyle=v,T.fillRect(0,0,S*2,C*2),T.fillStyle=w,T.fillRect(0,0,S,C),T.fillRect(S,C,S,C),_.fillStyle=_.createPattern(x,"repeat"),_.fillRect(0,0,A,y),_.drawImage(l,0,0,l.width,l.height,0,0,A,y)}let f=null;if(i){let A,y;if(o.symmetric&&l.width<e&&l.height<e)A=l.width,y=l.height;else if(l=r(this,yt),n>e||a>e){const w=Math.min(e/n,e/a);A=Math.floor(n*w),y=Math.floor(a*w),r(this,Pe)||(l=m(this,Z,ql).call(this,A,y))}const v=new OffscreenCanvas(A,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,A,y),f={width:A,height:y,data:v.getImageData(0,0,A,y).data}}return{canvas:u,width:c,height:d,imageData:f}}getImageForAltText(){return r(this,xs)}static async deserialize(e,s,i){var y;let n=null;if(e instanceof ff){const{data:{rect:_,rotation:v,id:w,structParent:E,popupRef:S},container:C,parent:{page:{pageNumber:x}}}=e,T=C.querySelector("canvas"),R=i.imageManager.getFromCanvas(C.id,T);T.remove();const L=((y=await s._structTree.getAriaAttributes(`${od}${w}`))==null?void 0:y.get("aria-label"))||"";n=e={annotationType:X.STAMP,bitmapId:R.id,bitmap:R.bitmap,pageIndex:x-1,rect:_.slice(0),rotation:v,id:w,deleted:!1,accessibilityData:{decorative:!1,altText:L},isSvg:!1,structParent:E,popupRef:S}}const a=await super.deserialize(e,s,i),{rect:o,bitmap:l,bitmapUrl:c,bitmapId:d,isSvg:u,accessibilityData:f}=e;d&&i.imageManager.isValidId(d)?(p(a,qt,d),l&&p(a,yt,l)):p(a,Zs,c),p(a,Pe,u);const[g,A]=a.pageDimensions;return a.width=(o[2]-o[0])/g,a.height=(o[3]-o[1])/A,a.annotationElementId=e.id||null,f&&(a.altTextData=f),a._initialData=n,p(a,fa,!!n),a}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:X.STAMP,bitmapId:r(this,qt),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:r(this,Pe),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=m(this,Z,Xl).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:n,altText:a}=this.serializeAltText(!1);if(!n&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=m(this,Z,ip).call(this,i);if(l.isSame)return null;l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const o=r(this,Pe)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(r(this,qt)))s.stamps.set(r(this,qt),{area:o,serialized:i}),i.bitmap=m(this,Z,Xl).call(this,!1);else if(r(this,Pe)){const l=s.stamps.get(r(this,qt));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=m(this,Z,Xl).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};yt=new WeakMap,qt=new WeakMap,Di=new WeakMap,Zs=new WeakMap,Oi=new WeakMap,ua=new WeakMap,xs=new WeakMap,ti=new WeakMap,Cs=new WeakMap,Pe=new WeakMap,fa=new WeakMap,Z=new WeakSet,Ba=function(e,s=!1){if(!e){this.remove();return}p(this,yt,e.bitmap),s||(p(this,qt,e.id),p(this,Pe,e.isSvg)),e.file&&p(this,ua,e.file.name),m(this,Z,Xc).call(this)},Ua=function(){if(p(this,Di,null),this._uiManager.enableWaiting(!1),!!r(this,xs)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,yt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,yt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Vl=function(){if(r(this,qt)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(r(this,qt)).then(i=>m(this,Z,Ba).call(this,i,!0)).finally(()=>m(this,Z,Ua).call(this));return}if(r(this,Zs)){const i=r(this,Zs);p(this,Zs,null),this._uiManager.enableWaiting(!0),p(this,Di,this._uiManager.imageManager.getFromUrl(i).then(n=>m(this,Z,Ba).call(this,n)).finally(()=>m(this,Z,Ua).call(this)));return}if(r(this,Oi)){const i=r(this,Oi);p(this,Oi,null),this._uiManager.enableWaiting(!0),p(this,Di,this._uiManager.imageManager.getFromFile(i).then(n=>m(this,Z,Ba).call(this,n)).finally(()=>m(this,Z,Ua).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=$a.supportedTypesStr;const s=this._uiManager._signal;p(this,Di,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),m(this,Z,Ba).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>m(this,Z,Ua).call(this))),e.click()},Xc=function(){const{div:e}=this;let{width:s,height:i}=r(this,yt);const[n,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*n,i=this.height*a;else if(s>o*n||i>o*a){const u=Math.min(o*n/s,o*a/i);s*=u,i*=u}const[l,c]=this.parentDimensions;this.setDims(s*l/n,i*c/a),this._uiManager.enableWaiting(!1);const d=p(this,xs,document.createElement("canvas"));d.setAttribute("role","img"),this.addContainer(d),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),m(this,Z,Yc).call(this,s,i),m(this,Z,sp).call(this),r(this,fa)||(this.parent.addUndoableEditor(this),p(this,fa,!0)),this._reportTelemetry({action:"inserted_image"}),r(this,ua)&&d.setAttribute("aria-label",r(this,ua))},ep=function(e,s){var o;const[i,n]=this.parentDimensions;this.width=e/i,this.height=s/n,(o=this._initialOptions)!=null&&o.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,r(this,Cs)!==null&&clearTimeout(r(this,Cs)),p(this,Cs,setTimeout(()=>{p(this,Cs,null),m(this,Z,Yc).call(this,e,s)},200))},ql=function(e,s){const{width:i,height:n}=r(this,yt);let a=i,o=n,l=r(this,yt);for(;a>2*e||o>2*s;){const c=a,d=o;a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,c,d,0,0,a,o),l=u.transferToImageBitmap()}return l},Yc=function(e,s){const i=new Gh,n=Math.ceil(e*i.sx),a=Math.ceil(s*i.sy),o=r(this,xs);if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;const l=r(this,Pe)?r(this,yt):m(this,Z,ql).call(this,n,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(l,0,0,l.width,l.height,0,0,n,a)},Xl=function(e){if(e){if(r(this,Pe)){const n=this._uiManager.imageManager.getSvgUrl(r(this,qt));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=r(this,yt),s.getContext("2d").drawImage(r(this,yt),0,0),s.toDataURL()}if(r(this,Pe)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Bi.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Bi.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,a);return o.getContext("2d").drawImage(r(this,yt),0,0,r(this,yt).width,r(this,yt).height,0,0,n,a),o.transferToImageBitmap()}return structuredClone(r(this,yt))},sp=function(){this._uiManager._signal&&(p(this,ti,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&m(this,Z,ep).call(this,s.width,s.height)})),r(this,ti).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,ti))==null||e.disconnect(),p(this,ti,null)},{once:!0}))},ip=function(e){var c;const{rect:s,pageIndex:i,accessibilityData:{altText:n}}=this._initialData,a=e.rect.every((d,u)=>Math.abs(d-s[u])<1),o=e.pageIndex===i,l=(((c=e.accessibilityData)==null?void 0:c.alt)||"")===n;return{isSame:a&&o&&l,isSameAltText:l}},z($a,"_type","stamp"),z($a,"_editorType",X.STAMP);let qc=$a;var Xn,pa,Ts,Ni,ei,ke,Hi,ga,ma,ne,si,H,ji,Yt,np,Qc,Jc,Zc,Yl;const Ve=class Ve{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:a,drawLayer:o,textLayer:l,viewport:c,l10n:d}){b(this,Yt);b(this,Xn);b(this,pa,!1);b(this,Ts,null);b(this,Ni,null);b(this,ei,null);b(this,ke,new Map);b(this,Hi,!1);b(this,ga,!1);b(this,ma,!1);b(this,ne,null);b(this,si,null);b(this,H);const u=[...r(Ve,ji).values()];if(!Ve._initialized){Ve._initialized=!0;for(const f of u)f.initialize(d,t)}t.registerEditorTypes(u),p(this,H,t),this.pageIndex=e,this.div=s,p(this,Xn,n),p(this,Ts,a),this.viewport=c,p(this,ne,l),this.drawLayer=o,this._structTree=i,r(this,H).addLayer(this)}get isEmpty(){return r(this,ke).size===0}get isInvisible(){return this.isEmpty&&r(this,H).getMode()===X.NONE}updateToolbar(t){r(this,H).updateToolbar(t)}updateMode(t=r(this,H).getMode()){switch(m(this,Yt,Yl).call(this),t){case X.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case X.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case X.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of r(Ve,ji).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=r(this,ne))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(r(this,H).getMode()!==X.INK)return;if(!t){for(const s of r(this,ke).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){r(this,H).setEditingState(t)}addCommands(t){r(this,H).addCommands(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=r(this,Ts))==null||e.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of r(this,ke).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(r(this,H).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!r(this,Ts))return;const e=r(this,Ts).getEditableAnnotations();for(const s of e){if(s.hide(),r(this,H).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;p(this,ma,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of r(this,ke).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else e.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(r(this,Ts)){const n=r(this,Ts).getEditableAnnotations();for(const a of n){const{id:o}=a.data;if(r(this,H).isDeletedAnnotationElement(o))continue;let l=e.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=t.get(o),l&&(r(this,H).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}m(this,Yt,Yl).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of r(Ve,ji).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,ma,!1)}getEditableAnnotation(t){var e;return((e=r(this,Ts))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){r(this,H).getActive()!==t&&r(this,H).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=r(this,ne))!=null&&t.div&&!r(this,si)){p(this,si,new AbortController);const e=r(this,H).combinedSignal(r(this,si));r(this,ne).div.addEventListener("pointerdown",m(this,Yt,np).bind(this),{signal:e}),r(this,ne).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=r(this,ne))!=null&&t.div&&r(this,si)&&(r(this,si).abort(),p(this,si,null),r(this,ne).div.classList.remove("highlighting"))}enableClick(){if(r(this,Ni))return;p(this,Ni,new AbortController);const t=r(this,H).combinedSignal(r(this,Ni));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){var t;(t=r(this,Ni))==null||t.abort(),p(this,Ni,null)}attach(t){r(this,ke).set(t.id,t);const{annotationElementId:e}=t;e&&r(this,H).isDeletedAnnotationElement(e)&&r(this,H).removeDeletedAnnotationElement(t)}detach(t){var e;r(this,ke).delete(t.id),(e=r(this,Xn))==null||e.removePointerInTextLayer(t.contentDiv),!r(this,ma)&&t.annotationElementId&&r(this,H).addDeletedAnnotationElement(t)}remove(t){this.detach(t),r(this,H).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,r(this,ga)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(r(this,H).addDeletedAnnotationElement(t.annotationElementId),lt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.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),r(this,H).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),r(this,H).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!r(this,ei)&&(t._focusEventsAllowed=!1,p(this,ei,setTimeout(()=>{p(this,ei,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:r(this,H)._signal}),e.focus())},0))),t._structTreeParentId=(s=r(this,Xn))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return r(this,H).getId()}combinedSignal(t){return r(this,H).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=r(this,Yt,Qc))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){r(this,H).updateToolbar(t),r(this,H).updateMode(t);const{offsetX:s,offsetY:i}=m(this,Yt,Zc).call(this),n=this.getNextId(),a=m(this,Yt,Jc).call(this,{parent:this,id:n,x:s,y:i,uiManager:r(this,H),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=r(Ve,ji).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,r(this,H)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=m(this,Yt,Jc).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:r(this,H),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(m(this,Yt,Zc).call(this),!0)}setSelected(t){r(this,H).setSelected(t)}toggleSelected(t){r(this,H).toggleSelected(t)}unselect(t){r(this,H).unselect(t)}pointerup(t){const{isMac:e}=de.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&r(this,Hi)){if(p(this,Hi,!1),!r(this,pa)){p(this,pa,!0);return}if(r(this,H).getMode()===X.STAMP){r(this,H).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(r(this,H).getMode()===X.HIGHLIGHT&&this.enableTextSelection(),r(this,Hi)){p(this,Hi,!1);return}const{isMac:e}=de.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;p(this,Hi,!0);const s=r(this,H).getActive();p(this,pa,!s||s.isEmpty())}findNewParent(t,e,s){const i=r(this,H).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=r(this,H).getActive())==null?void 0:t.parent)===this&&(r(this,H).commitOrRemove(),r(this,H).setActiveEditor(null)),r(this,ei)&&(clearTimeout(r(this,ei)),p(this,ei,null));for(const s of r(this,ke).values())(e=r(this,Xn))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,r(this,ke).clear(),r(this,H).removeLayer(this)}render({viewport:t}){this.viewport=t,Yn(this.div,t);for(const e of r(this,H).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){r(this,H).commitOrRemove(),m(this,Yt,Yl).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Yn(this.div,{rotation:s}),e!==s)for(const i of r(this,ke).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return r(this,H).viewParameters.realScale}};Xn=new WeakMap,pa=new WeakMap,Ts=new WeakMap,Ni=new WeakMap,ei=new WeakMap,ke=new WeakMap,Hi=new WeakMap,ga=new WeakMap,ma=new WeakMap,ne=new WeakMap,si=new WeakMap,H=new WeakMap,ji=new WeakMap,Yt=new WeakSet,np=function(t){r(this,H).unselectAll();const{target:e}=t;if(e===r(this,ne).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&r(this,ne).div.contains(e)){const{isMac:s}=de.platform;if(t.button!==0||t.ctrlKey&&s)return;r(this,H).showAllEditors("highlight",!0,!0),r(this,ne).div.classList.add("free"),this.toggleDrawing(),th.startHighlighting(this,r(this,H).direction==="ltr",{target:r(this,ne).div,x:t.x,y:t.y}),r(this,ne).div.addEventListener("pointerup",()=>{r(this,ne).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:r(this,H)._signal}),t.preventDefault()}},Qc=function(){return r(Ve,ji).get(r(this,H).getMode())},Jc=function(t){const e=r(this,Yt,Qc);return e?new e.prototype.constructor(t):null},Zc=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),c=(n+o)/2-t,d=(a+l)/2-e,[u,f]=this.viewport.rotation%180===0?[c,d]:[d,c];return{offsetX:u,offsetY:f}},Yl=function(){p(this,ga,!0);for(const t of r(this,ke).values())t.isEmpty()&&t.remove();p(this,ga,!1)},z(Ve,"_initialized",!1),b(Ve,ji,new Map([Pc,Hc,qc,th].map(t=>[t._editorType,t])));let Kc=Ve;var Rs,al,Pt,ii,ol,ed,tr,sd,rp;const $t=class $t{constructor({pageIndex:t}){b(this,tr);b(this,Rs,null);b(this,al,0);b(this,Pt,new Map);b(this,ii,new Map);this.pageIndex=t}setParent(t){if(!r(this,Rs)){p(this,Rs,t);return}if(r(this,Rs)!==t){if(r(this,Pt).size>0)for(const e of r(this,Pt).values())e.remove(),t.append(e);p(this,Rs,t)}}static get _svgFactory(){return tt(this,"_svgFactory",new bd)}draw(t,e,s,i=!1){const n=oe(this,al)._++,a=m(this,tr,sd).call(this,t.box);a.classList.add(...t.classNamesForDrawing);const o=$t._svgFactory.createElement("defs");a.append(o);const l=$t._svgFactory.createElement("path");o.append(l);const c=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",c),l.setAttribute("d",t.toSVGPath()),i&&r(this,ii).set(n,l);const d=m(this,tr,rp).call(this,o,c),u=$t._svgFactory.createElement("use");return a.append(u),a.setAttribute("fill",e),a.setAttribute("fill-opacity",s),u.setAttribute("href",`#${c}`),r(this,Pt).set(n,a),{id:n,clipPathId:`url(#${d})`}}drawOutline(t){const e=oe(this,al)._++,s=m(this,tr,sd).call(this,t.box);s.classList.add(...t.classNamesForOutlining);const i=$t._svgFactory.createElement("defs");s.append(i);const n=$t._svgFactory.createElement("path");i.append(n);const a=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",a),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(t.mustRemoveSelfIntersections){const d=$t._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=$t._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=$t._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")}const l=$t._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const c=l.cloneNode();return s.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),r(this,Pt).set(e,s),e}finalizeLine(t,e){const s=r(this,ii).get(t);r(this,ii).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){r(this,Pt).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){r(this,ii).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;m(s=$t,ol,ed).call(s,r(this,Pt).get(t),e)}show(t,e){r(this,Pt).get(t).classList.toggle("hidden",!e)}rotate(t,e){r(this,Pt).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){r(this,Pt).get(t).setAttribute("fill",e)}changeOpacity(t,e){r(this,Pt).get(t).setAttribute("fill-opacity",e)}addClass(t,e){r(this,Pt).get(t).classList.add(e)}removeClass(t,e){r(this,Pt).get(t).classList.remove(e)}getSVGRoot(t){return r(this,Pt).get(t)}remove(t){r(this,ii).delete(t),r(this,Rs)!==null&&(r(this,Pt).get(t).remove(),r(this,Pt).delete(t))}destroy(){p(this,Rs,null);for(const t of r(this,Pt).values())t.remove();r(this,Pt).clear(),r(this,ii).clear()}};Rs=new WeakMap,al=new WeakMap,Pt=new WeakMap,ii=new WeakMap,ol=new WeakSet,ed=function(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*n}%`},tr=new WeakSet,sd=function(t){var s;const e=$t._svgFactory.create(1,1,!0);return r(this,Rs).append(e),e.setAttribute("aria-hidden",!0),m(s=$t,ol,ed).call(s,e,t),e},rp=function(t,e){const s=$t._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=$t._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},b($t,ol);let td=$t;var Om=$.AbortException,Nm=$.AnnotationEditorLayer,Hm=$.AnnotationEditorParamsType,jm=$.AnnotationEditorType,Bm=$.AnnotationEditorUIManager,ap=$.AnnotationLayer,op=$.AnnotationMode,Um=$.ColorPicker,zm=$.DOMSVGFactory,Gm=$.DrawLayer,$m=$.FeatureTest,lp=$.GlobalWorkerOptions,Wm=$.ImageKind,Vm=$.InvalidPDFException,qm=$.MissingPDFException,Xm=$.OPS,Ym=$.OutputScale,Km=$.PDFDataRangeTransport,Qm=$.PDFDateString,Jm=$.PDFWorker,Zm=$.PasswordResponses,tb=$.PermissionFlag,eb=$.PixelsPerInch,sb=$.RenderingCancelledException,hp=$.TextLayer,ib=$.UnexpectedResponseException,nb=$.Util,rb=$.VerbosityLevel,ab=$.XfaLayer,ob=$.build,lb=$.createValidAbsoluteUrl,hb=$.fetchData,cp=$.getDocument,cb=$.getFilenameFromUrl,db=$.getPdfFilenameFromUrl,ub=$.getXfaPageViewport,fb=$.isDataScheme,pb=$.isPdfFile,gb=$.noContextMenu,mb=$.normalizeUnicode,bb=$.setLayerDimensions,Ab=$.shadow,yb=$.version;const dp=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Om,AnnotationEditorLayer:Nm,AnnotationEditorParamsType:Hm,AnnotationEditorType:jm,AnnotationEditorUIManager:Bm,AnnotationLayer:ap,AnnotationMode:op,ColorPicker:Um,DOMSVGFactory:zm,DrawLayer:Gm,FeatureTest:$m,GlobalWorkerOptions:lp,ImageKind:Wm,InvalidPDFException:Vm,MissingPDFException:qm,OPS:Xm,OutputScale:Ym,PDFDataRangeTransport:Km,PDFDateString:Qm,PDFWorker:Jm,PasswordResponses:Zm,PermissionFlag:tb,PixelsPerInch:eb,RenderingCancelledException:sb,TextLayer:hp,UnexpectedResponseException:ib,Util:nb,VerbosityLevel:rb,XfaLayer:ab,build:ob,createValidAbsoluteUrl:lb,fetchData:hb,getDocument:cp,getFilenameFromUrl:cb,getPdfFilenameFromUrl:db,getXfaPageViewport:ub,isDataScheme:fb,isPdfFile:pb,noContextMenu:gb,normalizeUnicode:mb,setLayerDimensions:bb,shadow:Ab,version:yb},Symbol.toStringTag,{value:"Module"}));var Ht=function(h,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,n;s<i;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return h.concat(n||Array.prototype.slice.call(t))},vb=["onCopy","onCut","onPaste"],_b=["onCompositionEnd","onCompositionStart","onCompositionUpdate"],wb=["onFocus","onBlur"],Eb=["onInput","onInvalid","onReset","onSubmit"],Sb=["onLoad","onError"],xb=["onKeyDown","onKeyPress","onKeyUp"],Cb=["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],Tb=["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],Rb=["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],Pb=["onSelect"],kb=["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],Lb=["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],Mb=["onScroll"],Ib=["onWheel"],Fb=["onAnimationStart","onAnimationEnd","onAnimationIteration"],Db=["onTransitionEnd"],Ob=["onToggle"],Nb=["onChange"],Hb=Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht(Ht([],vb,!0),_b,!0),wb,!0),Eb,!0),Sb,!0),xb,!0),Cb,!0),Tb,!0),Rb,!0),Pb,!0),kb,!0),Lb,!0),Mb,!0),Ib,!0),Fb,!0),Db,!0),Nb,!0),Ob,!0);function yd(h,t){var e={};return Hb.forEach(function(s){var i=h[s];i&&(t?e[s]=(function(n){return i(n,t(s))}):e[s]=i)}),e}function Aa(h){var t=!1,e=new Promise(function(s,i){h.then(function(n){return!t&&s(n)}).catch(function(n){return!t&&i(n)})});return{promise:e,cancel:function(){t=!0}}}var jb=process.env.NODE_ENV==="production",Oh="Invariant failed";function et(h,t){if(!h){if(jb)throw new Error(Oh);var e=typeof t=="function"?t():t,s=e?"".concat(Oh,": ").concat(e):Oh;throw new Error(s)}}var Nh,Gd;function Bb(){if(Gd)return Nh;Gd=1;var h=process.env.NODE_ENV!=="production",t=function(){};if(h){var e=function(i,n){var a=arguments.length;n=new Array(a>1?a-1:0);for(var o=1;o<a;o++)n[o-1]=arguments[o];var l=0,c="Warning: "+i.replace(/%s/g,function(){return n[l++]});typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}};t=function(s,i,n){var a=arguments.length;n=new Array(a>2?a-2:0);for(var o=2;o<a;o++)n[o-2]=arguments[o];if(i===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");s||e.apply(null,[i].concat(n))}}return Nh=t,Nh}var Ub=Bb();const Xt=Dp(Ub);var $d=Object.prototype.hasOwnProperty;function Wd(h,t,e){for(e of h.keys())if(br(e,t))return e}function br(h,t){var e,s,i;if(h===t)return!0;if(h&&t&&(e=h.constructor)===t.constructor){if(e===Date)return h.getTime()===t.getTime();if(e===RegExp)return h.toString()===t.toString();if(e===Array){if((s=h.length)===t.length)for(;s--&&br(h[s],t[s]););return s===-1}if(e===Set){if(h.size!==t.size)return!1;for(s of h)if(i=s,i&&typeof i=="object"&&(i=Wd(t,i),!i)||!t.has(i))return!1;return!0}if(e===Map){if(h.size!==t.size)return!1;for(s of h)if(i=s[0],i&&typeof i=="object"&&(i=Wd(t,i),!i)||!br(s[1],t.get(i)))return!1;return!0}if(e===ArrayBuffer)h=new Uint8Array(h),t=new Uint8Array(t);else if(e===DataView){if((s=h.byteLength)===t.byteLength)for(;s--&&h.getInt8(s)===t.getInt8(s););return s===-1}if(ArrayBuffer.isView(h)){if((s=h.byteLength)===t.byteLength)for(;s--&&h[s]===t[s];);return s===-1}if(!e||typeof h=="object"){s=0;for(e in h)if($d.call(h,e)&&++s&&!$d.call(t,e)||!(e in t)||!br(h[e],t[e]))return!1;return Object.keys(t).length===s}}return h!==h&&t!==t}const up=F.createContext(null);function Ar({children:h,type:t}){return st.jsxRuntimeExports.jsx("div",{className:`react-pdf__message react-pdf__message--${t}`,children:h})}const zb="noopener noreferrer nofollow";class Gb{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return et(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(t){et(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}goToDestination(t){return new Promise(e=>{et(this.pdfDocument,"PDF document not loaded."),et(t,"Destination is not specified."),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{et(Array.isArray(e),`"${e}" is not a valid destination array.`);const s=e[0];new Promise(i=>{et(this.pdfDocument,"PDF document not loaded."),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{et(!1,`"${s}" is not a valid page reference.`)}):typeof s=="number"?i(s):et(!1,`"${s}" is not a valid destination reference.`)}).then(i=>{const n=i+1;et(this.pdfViewer,"PDF viewer is not initialized."),et(n>=1&&n<=this.pagesCount,`"${n}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:i,pageNumber:n})})})}navigateTo(t){this.goToDestination(t)}goToPage(t){const e=t-1;et(this.pdfViewer,"PDF viewer is not initialized."),et(t>=1&&t<=this.pagesCount,`"${t}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||zb,t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const id={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Ch=typeof window<"u",fp=Ch&&window.location.protocol==="file:";function pp(h){return typeof h<"u"}function cs(h){return pp(h)&&h!==null}function $b(h){return typeof h=="string"}function Wb(h){return h instanceof ArrayBuffer}function Vb(h){return et(Ch,"isBlob can only be used in a browser environment"),h instanceof Blob}function nd(h){return $b(h)&&/^data:/.test(h)}function Vd(h){et(nd(h),"Invalid data URI.");const[t="",e=""]=h.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function qb(){return Ch&&window.devicePixelRatio||1}const gp="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function qd(){Xt(!fp,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${gp}`)}function Xb(){Xt(!fp,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${gp}`)}function zi(h){h!=null&&h.cancel&&h.cancel()}function rd(h,t){return Object.defineProperty(h,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(h,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(h,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(h,"originalHeight",{get(){return this.view[3]},configurable:!0}),h}function Yb(h){return h.name==="RenderingCancelledException"}function Kb(h){return new Promise((t,e)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return e(new Error("Error while reading a file."));t(s.result)},s.onerror=i=>{if(!i.target)return e(new Error("Error while reading a file."));const{error:n}=i.target;if(!n)return e(new Error("Error while reading a file."));switch(n.code){case n.NOT_FOUND_ERR:return e(new Error("Error while reading a file: File not found."));case n.SECURITY_ERR:return e(new Error("Error while reading a file: Security error."));case n.ABORT_ERR:return e(new Error("Error while reading a file: Aborted."));default:return e(new Error("Error while reading a file."))}},s.readAsArrayBuffer(h)})}function Qb(h,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return h}}function Jn(){return F.useReducer(Qb,{value:void 0,error:void 0})}var Jb=function(h,t,e,s){function i(n){return n instanceof e?n:new e(function(a){a(n)})}return new(e||(e=Promise))(function(n,a){function o(d){try{c(s.next(d))}catch(u){a(u)}}function l(d){try{c(s.throw(d))}catch(u){a(u)}}function c(d){d.done?n(d.value):i(d.value).then(o,l)}c((s=s.apply(h,t||[])).next())})},Xd=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(h,s[i])&&(e[s[i]]=h[s[i]]);return e};const{PDFDataRangeTransport:Zb}=dp,tA=(h,t)=>{switch(t){case id.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");h(e);break}case id.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");h(e);break}}};function Yd(h){return typeof h=="object"&&h!==null&&("data"in h||"range"in h||"url"in h)}const eA=F.forwardRef(function(t,e){var{children:s,className:i,error:n="Failed to load PDF file.",externalLinkRel:a,externalLinkTarget:o,file:l,inputRef:c,imageResourcesPath:d,loading:u="Loading PDF…",noData:f="No PDF file specified.",onItemClick:g,onLoadError:A,onLoadProgress:y,onLoadSuccess:_,onPassword:v=tA,onSourceError:w,onSourceSuccess:E,options:S,renderMode:C,rotate:x}=t,T=Xd(t,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[R,L]=Jn(),{value:O,error:I}=R,[J,U]=Jn(),{value:B,error:q}=J,W=F.useRef(new Gb),D=F.useRef([]),j=F.useRef(void 0),Kt=F.useRef(void 0);l&&l!==j.current&&Yd(l)&&(Xt(!br(l,j.current),`File prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),j.current=l),S&&S!==Kt.current&&(Xt(!br(S,Kt.current),`Options prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),Kt.current=S);const ae=F.useRef({scrollPageIntoView:dt=>{const{dest:Tt,pageNumber:Jt,pageIndex:Nt=Jt-1}=dt;if(g){g({dest:Tt,pageIndex:Nt,pageNumber:Jt});return}const nr=D.current[Nt];if(nr){nr.scrollIntoView();return}Xt(!1,`An internal link leading to page ${Jt} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});F.useImperativeHandle(e,()=>({linkService:W,pages:D,viewer:ae}),[]);function Qt(){E&&E()}function _t(){I&&(Xt(!1,I.toString()),w&&w(I))}function ft(){L({type:"RESET"})}F.useEffect(ft,[l,L]);const pe=F.useCallback(()=>Jb(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return nd(l)?{data:Vd(l)}:(qd(),{url:l});if(l instanceof Zb)return{range:l};if(Wb(l))return{data:l};if(Ch&&Vb(l))return{data:yield Kb(l)};if(et(typeof l=="object","Invalid parameter in file, need either Uint8Array, string or a parameter object"),et(Yd(l),"Invalid parameter object: need either .data, .range or .url"),"url"in l&&typeof l.url=="string"){if(nd(l.url)){const{url:dt}=l,Tt=Xd(l,["url"]),Jt=Vd(dt);return Object.assign({data:Jt},Tt)}qd()}return l}),[l]);F.useEffect(()=>{const dt=Aa(pe());return dt.promise.then(Tt=>{L({type:"RESOLVE",value:Tt})}).catch(Tt=>{L({type:"REJECT",error:Tt})}),()=>{zi(dt)}},[pe,L]),F.useEffect(()=>{if(!(typeof O>"u")){if(O===!1){_t();return}Qt()}},[O]);function $e(){B&&(_&&_(B),D.current=new Array(B.numPages),W.current.setDocument(B))}function St(){q&&(Xt(!1,q.toString()),A&&A(q))}F.useEffect(function(){U({type:"RESET"})},[U,O]),F.useEffect(function(){if(!O)return;const Tt=S?Object.assign(Object.assign({},O),S):O,Jt=cp(Tt);y&&(Jt.onProgress=y),v&&(Jt.onPassword=v);const Nt=Jt,nr=Nt.promise.then(wa=>{U({type:"RESOLVE",value:wa})}).catch(wa=>{Nt.destroyed||U({type:"REJECT",error:wa})});return()=>{nr.finally(()=>Nt.destroy())}},[S,U,O]),F.useEffect(()=>{if(!(typeof B>"u")){if(B===!1){St();return}$e()}},[B]),F.useEffect(function(){W.current.setViewer(ae.current),W.current.setExternalLinkRel(a),W.current.setExternalLinkTarget(o)},[a,o]);const nt=F.useCallback((dt,Tt)=>{D.current[dt]=Tt},[]),ls=F.useCallback(dt=>{delete D.current[dt]},[]),We=F.useMemo(()=>({imageResourcesPath:d,linkService:W.current,onItemClick:g,pdf:B,registerPage:nt,renderMode:C,rotate:x,unregisterPage:ls}),[d,g,B,nt,C,x,ls]),gt=F.useMemo(()=>yd(T,()=>B),[T,B]);function va(){return st.jsxRuntimeExports.jsx(up.Provider,{value:We,children:s})}function _a(){return l?B==null?st.jsxRuntimeExports.jsx(Ar,{type:"loading",children:typeof u=="function"?u():u}):B===!1?st.jsxRuntimeExports.jsx(Ar,{type:"error",children:typeof n=="function"?n():n}):va():st.jsxRuntimeExports.jsx(Ar,{type:"no-data",children:typeof f=="function"?f():f})}return st.jsxRuntimeExports.jsx("div",Object.assign({className:ba("react-pdf__Document",i),ref:c,style:{"--scale-factor":"1"}},gt,{children:_a()}))}),mp=F.createContext(null);class sA{constructor({num:t,gen:e}){this.num=t,this.gen=e}toString(){let t=`${this.num}R`;return this.gen!==0&&(t+=this.gen),t}}function Hh(h){const t=F.useRef(void 0),e=t.current;return pp(e)?()=>e:()=>{const s=h();return t.current=s,s}}function ya(){return F.useContext(up)}function bp(){return F.useContext(mp)}var Kd=function(h,t,e,s){function i(n){return n instanceof e?n:new e(function(a){a(n)})}return new(e||(e=Promise))(function(n,a){function o(d){try{c(s.next(d))}catch(u){a(u)}}function l(d){try{c(s.throw(d))}catch(u){a(u)}}function c(d){d.done?n(d.value):i(d.value).then(o,l)}c((s=s.apply(h,t||[])).next())})},iA=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(h,s[i])&&(e[s[i]]=h[s[i]]);return e};function Ap(h){const t=ya(),e=bp();et(e,"Unable to find Outline context.");const s=Object.assign(Object.assign(Object.assign({},t),e),h),{item:i,linkService:n,onItemClick:a,pdf:o}=s,l=iA(s,["item","linkService","onItemClick","pdf"]);et(o,"Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.");const c=Hh(()=>typeof i.dest=="string"?o.getDestination(i.dest):i.dest),d=Hh(()=>Kd(this,void 0,void 0,function*(){const A=yield c();if(!A)throw new Error("Destination not found.");const[y]=A;return o.getPageIndex(new sA(y))})),u=Hh(()=>Kd(this,void 0,void 0,function*(){return(yield d())+1}));function f(A){A.preventDefault(),et(a||n,"Either onItemClick callback or linkService must be defined in order to navigate to an outline item."),a?Promise.all([c(),d(),u()]).then(([y,_,v])=>{a({dest:y,pageIndex:_,pageNumber:v})}):n&&n.goToDestination(i.dest)}function g(){if(!i.items||!i.items.length)return null;const{items:A}=i;return st.jsxRuntimeExports.jsx("ul",{children:A.map((y,_)=>st.jsxRuntimeExports.jsx(Ap,Object.assign({item:y,pdf:o},l),typeof y.dest=="string"?y.dest:_))})}return st.jsxRuntimeExports.jsxs("li",{children:[st.jsxRuntimeExports.jsx("a",{href:"#",onClick:f,children:i.title}),g()]})}var nA=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(h,s[i])&&(e[s[i]]=h[s[i]]);return e};function rA(h){const t=ya(),e=Object.assign(Object.assign({},t),h),{className:s,inputRef:i,onItemClick:n,onLoadError:a,onLoadSuccess:o,pdf:l}=e,c=nA(e,["className","inputRef","onItemClick","onLoadError","onLoadSuccess","pdf"]);et(l,"Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.");const[d,u]=Jn(),{value:f,error:g}=d;function A(){typeof f>"u"||f===!1||o&&o(f)}function y(){g&&(Xt(!1,g.toString()),a&&a(g))}F.useEffect(function(){u({type:"RESET"})},[u,l]),F.useEffect(function(){if(!l)return;const S=Aa(l.getOutline()),C=S;return S.promise.then(x=>{u({type:"RESOLVE",value:x})}).catch(x=>{u({type:"REJECT",error:x})}),()=>zi(C)},[u,l]),F.useEffect(()=>{if(f!==void 0){if(f===!1){y();return}A()}},[f]);const _=F.useMemo(()=>({onItemClick:n}),[n]),v=F.useMemo(()=>yd(c,()=>f),[c,f]);if(!f)return null;function w(){return f?st.jsxRuntimeExports.jsx("ul",{children:f.map((E,S)=>st.jsxRuntimeExports.jsx(Ap,{item:E,pdf:l},typeof E.dest=="string"?E.dest:S))}):null}return st.jsxRuntimeExports.jsx("div",Object.assign({className:ba("react-pdf__Outline",s),ref:i},v,{children:st.jsxRuntimeExports.jsx(mp.Provider,{value:_,children:w()})}))}function yp(){for(var h=[],t=0;t<arguments.length;t++)h[t]=arguments[t];var e=h.filter(Boolean);if(e.length<=1){var s=e[0];return s||null}return function(n){e.forEach(function(a){typeof a=="function"?a(n):a&&(a.current=n)})}}const vp=F.createContext(null),_p={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},aA=/^H(\d+)$/;function oA(h){return h in _p}function Th(h){return"children"in h}function wp(h){return Th(h)?h.children.length===1&&0 in h.children&&"id"in h.children[0]:!1}function lA(h){const t={};if(Th(h)){const{role:e}=h,s=e.match(aA);if(s)t.role="heading",t["aria-level"]=Number(s[1]);else if(oA(e)){const i=_p[e];i&&(t.role=i)}}return t}function Ep(h){const t={};if(Th(h)){if(h.alt!==void 0&&(t["aria-label"]=h.alt),h.lang!==void 0&&(t.lang=h.lang),wp(h)){const[e]=h.children;if(e){const s=Ep(e);return Object.assign(Object.assign({},t),s)}}}else"id"in h&&(t["aria-owns"]=h.id);return t}function hA(h){return h?Object.assign(Object.assign({},lA(h)),Ep(h)):null}function Sp({className:h,node:t}){const e=F.useMemo(()=>hA(t),[t]),s=F.useMemo(()=>!Th(t)||wp(t)?null:t.children.map((i,n)=>st.jsxRuntimeExports.jsx(Sp,{node:i},n)),[t]);return st.jsxRuntimeExports.jsx("span",Object.assign({className:h},e,{children:s}))}function dl(){return F.useContext(vp)}function cA(){const h=dl();et(h,"Unable to find Page context.");const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=h,[s,i]=Jn(),{value:n,error:a}=s,{customTextRenderer:o,page:l}=h;function c(){n&&e&&e(n)}function d(){a&&(Xt(!1,a.toString()),t&&t(a))}return F.useEffect(function(){i({type:"RESET"})},[i,l]),F.useEffect(function(){if(o||!l)return;const f=Aa(l.getStructTree()),g=f;return f.promise.then(A=>{i({type:"RESOLVE",value:A})}).catch(A=>{i({type:"REJECT",error:A})}),()=>zi(g)},[o,l,i]),F.useEffect(()=>{if(n!==void 0){if(n===!1){d();return}c()}},[n]),n?st.jsxRuntimeExports.jsx(Sp,{className:"react-pdf__Page__structTree structTree",node:n}):null}const Qd=op;function dA(h){const t=dl();et(t,"Unable to find Page context.");const e=Object.assign(Object.assign({},t),h),{_className:s,canvasBackground:i,devicePixelRatio:n=qb(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:c,renderTextLayer:d,rotate:u,scale:f}=e,{canvasRef:g}=h;et(l,"Attempted to render page canvas, but no page was specified.");const A=F.useRef(null);function y(){l&&o&&o(rd(l,f))}function _(S){Yb(S)||(Xt(!1,S.toString()),a&&a(S))}const v=F.useMemo(()=>l.getViewport({scale:f*n,rotation:u}),[n,l,u,f]),w=F.useMemo(()=>l.getViewport({scale:f,rotation:u}),[l,u,f]);F.useEffect(function(){if(!l)return;l.cleanup();const{current:C}=A;if(!C)return;C.width=v.width,C.height=v.height,C.style.width=`${Math.floor(w.width)}px`,C.style.height=`${Math.floor(w.height)}px`,C.style.visibility="hidden";const x={annotationMode:c?Qd.ENABLE_FORMS:Qd.ENABLE,canvasContext:C.getContext("2d",{alpha:!1}),viewport:v};i&&(x.background=i);const T=l.render(x),R=T;return T.promise.then(()=>{C.style.visibility="",y()}).catch(_),()=>zi(R)},[i,l,c,v,w]);const E=F.useCallback(()=>{const{current:S}=A;S&&(S.width=0,S.height=0)},[]);return F.useEffect(()=>E,[E]),st.jsxRuntimeExports.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:yp(g,A),style:{display:"block",userSelect:"none"},children:d?st.jsxRuntimeExports.jsx(cA,{}):null})}function uA(h){return"str"in h}function fA(){const h=dl();et(h,"Unable to find Page context.");const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:a,pageIndex:o,pageNumber:l,rotate:c,scale:d}=h;et(a,"Attempted to load page text content, but no page was specified.");const[u,f]=Jn(),{value:g,error:A}=u,y=F.useRef(null);Xt(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function _(){g&&s&&s(g)}function v(){A&&(Xt(!1,A.toString()),e&&e(A))}F.useEffect(function(){f({type:"RESET"})},[a,f]),F.useEffect(function(){if(!a)return;const R=Aa(a.getTextContent()),L=R;return R.promise.then(O=>{f({type:"RESOLVE",value:O})}).catch(O=>{f({type:"REJECT",error:O})}),()=>zi(L)},[a,f]),F.useEffect(()=>{if(g!==void 0){if(g===!1){v();return}_()}},[g]);const w=F.useCallback(()=>{n&&n()},[n]),E=F.useCallback(T=>{Xt(!1,T.toString()),i&&i(T)},[i]);function S(){const T=y.current;T&&T.classList.add("selecting")}function C(){const T=y.current;T&&T.classList.remove("selecting")}const x=F.useMemo(()=>a.getViewport({scale:d,rotation:c}),[a,c,d]);return F.useLayoutEffect(function(){if(!a||!g)return;const{current:R}=y;if(!R)return;R.innerHTML="";const L=a.streamTextContent({includeMarkedContent:!0}),O={container:R,textContentSource:L,viewport:x},I=new hp(O),J=I;return I.render().then(()=>{const U=document.createElement("div");U.className="endOfContent",R.append(U);const B=R.querySelectorAll('[role="presentation"]');if(t){let q=0;g.items.forEach((W,D)=>{if(!uA(W))return;const j=B[q];if(!j)return;const Kt=t(Object.assign({pageIndex:o,pageNumber:l,itemIndex:D},W));j.innerHTML=Kt,q+=W.str&&W.hasEOL?2:1})}w()}).catch(E),()=>zi(J)},[t,E,w,a,o,l,g,x]),st.jsxRuntimeExports.jsx("div",{className:ba("react-pdf__Page__textContent","textLayer"),onMouseUp:C,onMouseDown:S,ref:y})}function pA(){const h=ya(),t=dl();et(t,"Unable to find Page context.");const e=Object.assign(Object.assign({},h),t),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:n,onGetAnnotationsSuccess:a,onRenderAnnotationLayerError:o,onRenderAnnotationLayerSuccess:l,page:c,pdf:d,renderForms:u,rotate:f,scale:g=1}=e;et(d,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),et(c,"Attempted to load page annotations, but no page was specified."),et(i,"Attempted to load page annotations, but no linkService was specified.");const[A,y]=Jn(),{value:_,error:v}=A,w=F.useRef(null);Xt(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function E(){_&&a&&a(_)}function S(){v&&(Xt(!1,v.toString()),n&&n(v))}F.useEffect(function(){y({type:"RESET"})},[y,c]),F.useEffect(function(){if(!c)return;const L=Aa(c.getAnnotations()),O=L;return L.promise.then(I=>{y({type:"RESOLVE",value:I})}).catch(I=>{y({type:"REJECT",error:I})}),()=>{zi(O)}},[y,c]),F.useEffect(()=>{if(_!==void 0){if(_===!1){S();return}E()}},[_]);function C(){l&&l()}function x(R){Xt(!1,`${R}`),o&&o(R)}const T=F.useMemo(()=>c.getViewport({scale:g,rotation:f}),[c,f,g]);return F.useEffect(function(){if(!d||!c||!i||!_)return;const{current:L}=w;if(!L)return;const O=T.clone({dontFlip:!0}),I={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:L,l10n:null,page:c,structTreeLayer:null,viewport:O},J={annotations:_,annotationStorage:d.annotationStorage,div:L,imageResourcesPath:s,linkService:i,page:c,renderForms:u,viewport:O};L.innerHTML="";try{new ap(I).render(J),C()}catch(U){x(U)}return()=>{}},[_,s,i,c,d,u,T]),st.jsxRuntimeExports.jsx("div",{className:ba("react-pdf__Page__annotations","annotationLayer"),ref:w})}var gA=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(h,s[i])&&(e[s[i]]=h[s[i]]);return e};const Jd=1;function xp(h){const t=ya(),e=Object.assign(Object.assign({},t),h),{_className:s="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:n,canvasRef:a,children:o,className:l,customRenderer:c,customTextRenderer:d,devicePixelRatio:u,error:f="Failed to load the page.",height:g,inputRef:A,loading:y="Loading page…",noData:_="No page specified.",onGetAnnotationsError:v,onGetAnnotationsSuccess:w,onGetStructTreeError:E,onGetStructTreeSuccess:S,onGetTextError:C,onGetTextSuccess:x,onLoadError:T,onLoadSuccess:R,onRenderAnnotationLayerError:L,onRenderAnnotationLayerSuccess:O,onRenderError:I,onRenderSuccess:J,onRenderTextLayerError:U,onRenderTextLayerSuccess:B,pageIndex:q,pageNumber:W,pdf:D,registerPage:j,renderAnnotationLayer:Kt=!0,renderForms:ae=!1,renderMode:Qt="canvas",renderTextLayer:_t=!0,rotate:ft,scale:pe=Jd,unregisterPage:$e,width:St}=e,nt=gA(e,["_className","_enableRegisterUnregisterPage","canvasBackground","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[ls,We]=Jn(),{value:gt,error:va}=ls,_a=F.useRef(null);et(D,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");const dt=cs(W)?W-1:q??null,Tt=W??(cs(q)?q+1:null),Jt=ft??(gt?gt.rotate:null),Nt=F.useMemo(()=>{if(!gt)return null;let rr=1;const fl=pe??Jd;if(St||g){const pl=gt.getViewport({scale:1,rotation:Jt});St?rr=St/pl.width:g&&(rr=g/pl.height)}return fl*rr},[g,gt,Jt,pe,St]);F.useEffect(function(){return()=>{cs(dt)&&i&&$e&&$e(dt)}},[i,D,dt,$e]);function nr(){if(R){if(!gt||!Nt)return;R(rd(gt,Nt))}if(i&&j){if(!cs(dt)||!_a.current)return;j(dt,_a.current)}}function wa(){va&&(Xt(!1,va.toString()),T&&T(va))}F.useEffect(function(){We({type:"RESET"})},[We,D,dt]),F.useEffect(function(){if(!D||!Tt)return;const fl=Aa(D.getPage(Tt)),pl=fl;return fl.promise.then(Rh=>{We({type:"RESOLVE",value:Rh})}).catch(Rh=>{We({type:"REJECT",error:Rh})}),()=>zi(pl)},[We,D,Tt]),F.useEffect(()=>{if(gt!==void 0){if(gt===!1){wa();return}nr()}},[gt,Nt]);const Cp=F.useMemo(()=>gt&&cs(dt)&&Tt&&cs(Jt)&&cs(Nt)?{_className:s,canvasBackground:n,customTextRenderer:d,devicePixelRatio:u,onGetAnnotationsError:v,onGetAnnotationsSuccess:w,onGetStructTreeError:E,onGetStructTreeSuccess:S,onGetTextError:C,onGetTextSuccess:x,onRenderAnnotationLayerError:L,onRenderAnnotationLayerSuccess:O,onRenderError:I,onRenderSuccess:J,onRenderTextLayerError:U,onRenderTextLayerSuccess:B,page:gt,pageIndex:dt,pageNumber:Tt,renderForms:ae,renderTextLayer:_t,rotate:Jt,scale:Nt}:null,[s,n,d,u,v,w,E,S,C,x,L,O,I,J,U,B,gt,dt,Tt,ae,_t,Jt,Nt]),Tp=F.useMemo(()=>yd(nt,()=>gt&&(Nt?rd(gt,Nt):void 0)),[nt,gt,Nt]),ul=`${dt}@${Nt}/${Jt}`;function Rp(){switch(Qt){case"custom":return et(c,'renderMode was set to "custom", but no customRenderer was passed.'),st.jsxRuntimeExports.jsx(c,{},`${ul}_custom`);case"none":return null;case"canvas":default:return st.jsxRuntimeExports.jsx(dA,{canvasRef:a},`${ul}_canvas`)}}function Pp(){return _t?st.jsxRuntimeExports.jsx(fA,{},`${ul}_text`):null}function kp(){return Kt?st.jsxRuntimeExports.jsx(pA,{},`${ul}_annotations`):null}function Lp(){return st.jsxRuntimeExports.jsxs(vp.Provider,{value:Cp,children:[Rp(),Pp(),kp(),o]})}function Mp(){return Tt?D===null||gt===void 0||gt===null?st.jsxRuntimeExports.jsx(Ar,{type:"loading",children:typeof y=="function"?y():y}):D===!1||gt===!1?st.jsxRuntimeExports.jsx(Ar,{type:"error",children:typeof f=="function"?f():f}):Lp():st.jsxRuntimeExports.jsx(Ar,{type:"no-data",children:typeof _=="function"?_():_})}return st.jsxRuntimeExports.jsx("div",Object.assign({className:ba(s,l),"data-page-number":Tt,ref:yp(A,_a),style:{"--scale-factor":`${Nt}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},Tp,{children:Mp()}))}var mA=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(h,s[i])&&(e[s[i]]=h[s[i]]);return e};function bA(h){const t=ya(),e=Object.assign(Object.assign({},t),h),{className:s,linkService:i,onItemClick:n,pageIndex:a,pageNumber:o,pdf:l}=e;et(l,"Attempted to load a thumbnail, but no document was specified. Wrap <Thumbnail /> in a <Document /> or pass explicit `pdf` prop.");const c=cs(o)?o-1:a??null,d=o??(cs(a)?a+1:null);function u(y){y.preventDefault(),!(!cs(c)||!d)&&(et(n||i,"Either onItemClick callback or linkService must be defined in order to navigate to an outline item."),n?n({pageIndex:c,pageNumber:d}):i&&i.goToPage(d))}const{className:f,onItemClick:g}=h,A=mA(h,["className","onItemClick"]);return st.jsxRuntimeExports.jsx("a",{className:ba("react-pdf__Thumbnail",s),href:d?"#":void 0,onClick:u,children:st.jsxRuntimeExports.jsx(xp,Object.assign({},A,{_className:"react-pdf__Thumbnail__page",_enableRegisterUnregisterPage:!1,renderAnnotationLayer:!1,renderTextLayer:!1}))})}Xb();lp.workerSrc="pdf.worker.mjs";exports.Document=eA;exports.Outline=rA;exports.Page=xp;exports.PasswordResponses=id;exports.Thumbnail=bA;exports.pdfjs=dp;exports.useDocumentContext=ya;exports.useOutlineContext=bp;exports.usePageContext=dl;
13
+ //# sourceMappingURL=index-Bn7sjSSa.cjs.map