detect/detect.gui/Embedded/dist/assets/index-f5995323.js
2025-06-05 04:29:09 +08:00

13 lines
374 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var eb=Object.defineProperty,sb=Object.defineProperties;var ib=Object.getOwnPropertyDescriptors;var Zh=Object.getOwnPropertySymbols,nb=Object.getPrototypeOf,Tp=Object.prototype.hasOwnProperty,Pp=Object.prototype.propertyIsEnumerable,rb=Reflect.get;var uo=Math.pow,Nu=(d,t,e)=>t in d?eb(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ys=(d,t)=>{for(var e in t||(t={}))Tp.call(t,e)&&Nu(d,e,t[e]);if(Zh)for(var e of Zh(t))Pp.call(t,e)&&Nu(d,e,t[e]);return d},_r=(d,t)=>sb(d,ib(t));var Rp=(d,t)=>{var e={};for(var s in d)Tp.call(d,s)&&t.indexOf(s)<0&&(e[s]=d[s]);if(d!=null&&Zh)for(var s of Zh(d))t.indexOf(s)<0&&Pp.call(d,s)&&(e[s]=d[s]);return e};var O=(d,t,e)=>(Nu(d,typeof t!="symbol"?t+"":t,e),e),Ou=(d,t,e)=>{if(!t.has(d))throw TypeError("Cannot "+e)};var n=(d,t,e)=>(Ou(d,t,"read from private field"),e?e.call(d):t.get(d)),u=(d,t,e)=>{if(t.has(d))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(d):t.set(d,e)},p=(d,t,e,s)=>(Ou(d,t,"write to private field"),s?s.call(d,e):t.set(d,e),e);var qt=(d,t,e,s)=>({set _(i){p(d,t,i,e)},get _(){return n(d,t,s)}}),b=(d,t,e)=>(Ou(d,t,"access private method"),e),ji=(d,t,e)=>rb(nb(d),e,t);var I=(d,t,e)=>new Promise((s,i)=>{var r=l=>{try{o(e.next(l))}catch(h){i(h)}},a=l=>{try{o(e.throw(l))}catch(h){i(h)}},o=l=>l.done?s(l.value):Promise.resolve(l.value).then(r,a);o((e=e.apply(d,t)).next())});import{k as ab,_ as Jp,l as ob,S as lb,m as hb,L as cb,n as db,j as ub}from"./index.js";import{u as fb,B as pb}from"./useTable-d1207d4e.js";import{T as gb}from"./useForm-e7697b0a.js";import{O as mb,N as Zp,Q as bb,R as Ab,U as yb,V as wb,W as vb,j as Bu}from"./antd-9db9238b.js";import{T as _b,r as Sb,s as Eb,c as Cb,a as kp}from"./drawer-c948bbc6.js";import{u as xb}from"./index-4d8a4acc.js";import{l as bo,a6 as tg,m as Hu,A as zu,Z as Dc,_ as qu,$ as Zs,ad as Mp,a8 as eg,k as oe,a0 as Tb,a5 as si,G as kr,d as Pb,f as Wi,c as Rb,o as kb,b as Mb,u as he,a4 as Lb}from"./vue-72a104e4.js";import{u as Ib}from"./index-b65f63bb.js";import Db from"./result-472c0bd9.js";import"./useWindowSizeFn-c13a0e28.js";import"./onMountedOrActivated-ee461833.js";import"./sortable.esm-15c0a34e.js";import"./copyTextToClipboard-e4460fb5.js";import"./deviceApi-af691457.js";import"./modal-afda945a.js";var Do={};Do.d=(d,t)=>{for(var e in t)Do.o(t,e)&&!Do.o(d,e)&&Object.defineProperty(d,e,{enumerable:!0,get:t[e]})};Do.o=(d,t)=>Object.prototype.hasOwnProperty.call(d,t);var z=globalThis.pdfjsLib={};Do.d(z,{AbortException:()=>$i,AnnotationEditorLayer:()=>np,AnnotationEditorParamsType:()=>Y,AnnotationEditorType:()=>V,AnnotationEditorUIManager:()=>Ar,AnnotationLayer:()=>Ry,AnnotationMode:()=>ii,ColorPicker:()=>zc,DOMSVGFactory:()=>Ap,DrawLayer:()=>op,FeatureTest:()=>te,GlobalWorkerOptions:()=>ti,ImageKind:()=>nc,InvalidPDFException:()=>Ku,MissingPDFException:()=>Fo,OPS:()=>Fe,OutputScale:()=>Ju,PDFDataRangeTransport:()=>im,PDFDateString:()=>pp,PDFWorker:()=>Dr,PasswordResponses:()=>Bb,PermissionFlag:()=>Ob,PixelsPerInch:()=>Gi,RenderingCancelledException:()=>up,TextLayer:()=>No,TouchManager:()=>Bc,UnexpectedResponseException:()=>Fc,Util:()=>F,VerbosityLevel:()=>Tu,XfaLayer:()=>rm,build:()=>hy,createValidAbsoluteUrl:()=>Gb,fetchData:()=>Mu,getDocument:()=>ty,getFilenameFromUrl:()=>Qb,getPdfFilenameFromUrl:()=>Jb,getXfaPageViewport:()=>Zb,isDataScheme:()=>Lu,isPdfFile:()=>fp,noContextMenu:()=>Ke,normalizeUnicode:()=>qb,setLayerDimensions:()=>br,shadow:()=>X,stopEvent:()=>Se,version:()=>ly});const Xt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),sg=[1,0,0,1,0,0],Yu=[.001,0,0,.001,0,0],Fb=1e7,$u=1.35,_e={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ii={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Nb="pdfjs_internal_editor_",V={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Y={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Ob={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ht={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},nc={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},vt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},fo={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Tu={ERRORS:0,WARNINGS:1,INFOS:5},Fe={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},Bb={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Pu=Tu.WARNINGS;function Hb(d){Number.isInteger(d)&&(Pu=d)}function zb(){return Pu}function Ru(d){Pu>=Tu.INFOS}function U(d){Pu>=Tu.WARNINGS}function st(d){throw new Error(d)}function wt(d,t){d||st(t)}function $b(d){switch(d==null?void 0:d.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Gb(d,t=null,e=null){if(!d)return null;try{if(e&&typeof d=="string"){if(e.addDefaultProtocol&&d.startsWith("www.")){const i=d.match(/\./g);(i==null?void 0:i.length)>=2&&(d=`http://${d}`)}if(e.tryConvertEncoding)try{d=Xb(d)}catch(i){}}const s=t?new URL(d,t):new URL(d);if($b(s))return s}catch(s){}return null}function X(d,t,e,s=!1){return Object.defineProperty(d,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Vi=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class Lp extends Vi{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Gu extends Vi{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ku extends Vi{constructor(t){super(t,"InvalidPDFException")}}class Fo extends Vi{constructor(t){super(t,"MissingPDFException")}}class Fc extends Vi{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Vb extends Vi{constructor(t){super(t,"FormatError")}}class $i extends Vi{constructor(t){super(t,"AbortException")}}function ig(d){(typeof d!="object"||(d==null?void 0:d.length)===void 0)&&st("Invalid argument for bytesToString");const t=d.length,e=8192;if(t<e)return String.fromCharCode.apply(null,d);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=d.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function ku(d){typeof d!="string"&&st("Invalid argument for stringToBytes");const t=d.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=d.charCodeAt(s)&255;return e}function Ub(d){return String.fromCharCode(d>>24&255,d>>16&255,d>>8&255,d&255)}function cp(d){const t=Object.create(null);for(const[e,s]of d)t[e]=s;return t}function jb(){const d=new Uint8Array(4);return d[0]=1,new Uint32Array(d.buffer,0,1)[0]===1}function Wb(){try{return new Function(""),!0}catch(d){return!1}}class te{static get isLittleEndian(){return X(this,"isLittleEndian",jb())}static get isEvalSupported(){return X(this,"isEvalSupported",Wb())}static get isOffscreenCanvasSupported(){return X(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas!="undefined")}static get isImageDecoderSupported(){return X(this,"isImageDecoderSupported",typeof ImageDecoder!="undefined")}static get platform(){return typeof navigator!="undefined"&&typeof(navigator==null?void 0:navigator.platform)=="string"?X(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")}):X(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return X(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Vu=Array.from(Array(256).keys(),d=>d.toString(16).padStart(2,"0"));var Fr,rc,Bo,Qu;class F{static makeHexColor(t,e,s){return`#${Vu[t]}${Vu[e]}${Vu[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,r=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,r]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),r=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],r[0],a[0]),Math.min(s[1],i[1],r[1],a[1]),Math.max(s[0],i[0],r[0],a[0]),Math.max(s[1],i[1],r[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],r=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],o=(s+a)/2,l=Math.sqrt(uo(s+a,2)-4*(s*a-r*i))/2,h=o+l||1,c=o-l||1;return[Math.sqrt(h),Math.sqrt(c)]}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 r=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 r>a?null:[s,r,i,a]}static bezierBoundingBox(t,e,s,i,r,a,o,l,h){return h?(h[0]=Math.min(h[0],t,o),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,o),h[3]=Math.max(h[3],e,l)):h=[Math.min(t,o),Math.min(e,l),Math.max(t,o),Math.max(e,l)],b(this,Bo,Qu).call(this,t,s,r,o,e,i,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),h),b(this,Bo,Qu).call(this,t,s,r,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),h),h}}Fr=new WeakSet,rc=function(t,e,s,i,r,a,o,l,h,c){if(h<=0||h>=1)return;const f=1-h,g=h*h,m=g*h,A=f*(f*(f*t+3*h*e)+3*g*s)+m*i,y=f*(f*(f*r+3*h*a)+3*g*o)+m*l;c[0]=Math.min(c[0],A),c[1]=Math.min(c[1],y),c[2]=Math.max(c[2],A),c[3]=Math.max(c[3],y)},Bo=new WeakSet,Qu=function(t,e,s,i,r,a,o,l,h,c,f,g){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,Fr,rc).call(this,t,e,s,i,r,a,o,l,-f/c,g);return}const m=uo(c,2)-4*f*h;if(m<0)return;const A=Math.sqrt(m),y=2*h;b(this,Fr,rc).call(this,t,e,s,i,r,a,o,l,(-c+A)/y,g),b(this,Fr,rc).call(this,t,e,s,i,r,a,o,l,(-c-A)/y,g)},u(F,Fr),u(F,Bo);function Xb(d){return decodeURIComponent(escape(d))}let Uu=null,Ip=null;function qb(d){return Uu||(Uu=/([\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,Ip=new Map([["ſt","ſt"]])),d.replaceAll(Uu,(t,e,s)=>e?e.normalize("NFKC"):Ip.get(s))}function Yb(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const d=new Uint8Array(32);return crypto.getRandomValues(d),ig(d)}const dp="pdfjs_internal_id_";function Kb(d){return Uint8Array.prototype.toBase64?d.toBase64():btoa(ig(d))}typeof Promise.try!="function"&&(Promise.try=function(d,...t){return new Promise(e=>{e(d(...t))})});const ws="http://www.w3.org/2000/svg",Ki=class Ki{};O(Ki,"CSS",96),O(Ki,"PDF",72),O(Ki,"PDF_TO_CSS_UNITS",Ki.CSS/Ki.PDF);let Gi=Ki;function Mu(d,t="text"){return I(this,null,function*(){if(Ao(d,document.baseURI)){const e=yield fetch(d);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",d,!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 Kh{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,f,g,m;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,f=0,g=0,m=1;break;case 90:c=0,f=1,g=1,m=0;break;case 270:c=0,f=-1,g=-1,m=0;break;case 0:c=1,f=0,g=0,m=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(g=-g,m=-m);let A,y,v,w;c===0?(A=Math.abs(h-t[1])*s+r,y=Math.abs(l-t[0])*s+a,v=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(A=Math.abs(l-t[0])*s+r,y=Math.abs(h-t[1])*s+a,v=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,f*s,g*s,m*s,A-c*s*l-g*s*h,y-f*s*l-m*s*h],this.width=v,this.height=w}get rawDims(){const{userUnit:t,viewBox:e}=this,s=e.map(i=>i*t);return X(this,"rawDims",{pageWidth:s[2]-s[0],pageHeight:s[3]-s[1],pageX:s[0],pageY:s[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new Kh({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){return F.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=F.applyTransform([t[0],t[1]],this.transform),s=F.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return F.applyInverseTransform([t,e],this.transform)}}class up extends Vi{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Lu(d){const t=d.length;let e=0;for(;e<t&&d[e].trim()==="";)e++;return d.substring(e,e+5).toLowerCase()==="data:"}function fp(d){return typeof d=="string"&&/\.pdf$/i.test(d)}function Qb(d){return[d]=d.split(/[#?]/,1),d.substring(d.lastIndexOf("/")+1)}function Jb(d,t="document.pdf"){if(typeof d!="string")return t;if(Lu(d))return U('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(d);let r=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(r&&(r=r[0],r.includes("%")))try{r=s.exec(decodeURIComponent(r))[0]}catch(a){}return r||t}class Dp{constructor(){O(this,"started",Object.create(null));O(this,"times",[])}time(t){t in this.started&&U(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||U(`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:r}of this.times)t.push(`${s.padEnd(e)} ${r-i}ms
`);return t.join("")}}function Ao(d,t){try{const{protocol:e}=t?new URL(d,t):new URL(d);return e==="http:"||e==="https:"}catch(e){return!1}}function Ke(d){d.preventDefault()}function Se(d){d.preventDefault(),d.stopPropagation()}var Ho;class pp{static toDateObject(t){if(!t||typeof t!="string")return null;n(this,Ho)||p(this,Ho,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,Ho).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 r=parseInt(e[3],10);r=r>=1&&r<=31?r: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 h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let f=parseInt(e[9],10)||0;return f=f>=0&&f<=59?f:0,h==="-"?(a+=c,o+=f):h==="+"&&(a-=c,o-=f),new Date(Date.UTC(s,i,r,a,o,l))}}Ho=new WeakMap,u(pp,Ho,void 0);function Zb(d,{scale:t=1,rotation:e=0}){const{width:s,height:i}=d.attributes.style,r=[0,0,parseInt(s),parseInt(i)];return new Kh({viewBox:r,userUnit:1,scale:t,rotation:e})}function gp(d){if(d.startsWith("#")){const t=parseInt(d.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return d.startsWith("rgb(")?d.slice(4,-1).split(",").map(t=>parseInt(t)):d.startsWith("rgba(")?d.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(U(`Not a valid color format: "${d}"`),[0,0,0])}function tA(d){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of d.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;d.set(e,gp(s))}t.remove()}function lt(d){const{a:t,b:e,c:s,d:i,e:r,f:a}=d.getTransform();return[t,e,s,i,r,a]}function Je(d){const{a:t,b:e,c:s,d:i,e:r,f:a}=d.getTransform().invertSelf();return[t,e,s,i,r,a]}function br(d,t,e=!1,s=!0){if(t instanceof Kh){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=d,o=te.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,h=`var(--scale-factor) * ${r}px`,c=o?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,f=o?`round(down, ${h}, var(--scale-round-y, 1px))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=c,a.height=f):(a.width=f,a.height=c)}s&&d.setAttribute("data-main-rotation",t.rotation)}class Ju{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 ni,Zi,Ne,tn,zo,$o,Vc,ng,Uc,rg,jc,ag,Nr,ac,Wc,og,Go,tf;const Ss=class Ss{constructor(t){u(this,Uc);u(this,jc);u(this,Nr);u(this,Wc);u(this,Go);u(this,ni,null);u(this,Zi,null);u(this,Ne,void 0);u(this,tn,null);u(this,zo,null);p(this,Ne,t),n(Ss,$o)||p(Ss,$o,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,ni,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,Ne)._uiManager._signal;t.addEventListener("contextmenu",Ke,{signal:e}),t.addEventListener("pointerdown",b(Ss,Vc,ng),{signal:e});const s=p(this,tn,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,Ne).toolbarPosition;if(i){const{style:r}=t,a=n(this,Ne)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return b(this,Wc,og).call(this),t}get div(){return n(this,ni)}hide(){var t;n(this,ni).classList.add("hidden"),(t=n(this,Zi))==null||t.hideDropdown()}show(){var t;n(this,ni).classList.remove("hidden"),(t=n(this,zo))==null||t.shown()}addAltText(t){return I(this,null,function*(){const e=yield t.render();b(this,Nr,ac).call(this,e),n(this,tn).prepend(e,n(this,Go,tf)),p(this,zo,t)})}addColorPicker(t){p(this,Zi,t);const e=t.renderButton();b(this,Nr,ac).call(this,e),n(this,tn).prepend(e,n(this,Go,tf))}remove(){var t;n(this,ni).remove(),(t=n(this,Zi))==null||t.destroy(),p(this,Zi,null)}};ni=new WeakMap,Zi=new WeakMap,Ne=new WeakMap,tn=new WeakMap,zo=new WeakMap,$o=new WeakMap,Vc=new WeakSet,ng=function(t){t.stopPropagation()},Uc=new WeakSet,rg=function(t){n(this,Ne)._focusEventsAllowed=!1,Se(t)},jc=new WeakSet,ag=function(t){n(this,Ne)._focusEventsAllowed=!0,Se(t)},Nr=new WeakSet,ac=function(t){const e=n(this,Ne)._uiManager._signal;t.addEventListener("focusin",b(this,Uc,rg).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,jc,ag).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ke,{signal:e})},Wc=new WeakSet,og=function(){const{editorType:t,_uiManager:e}=n(this,Ne),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",n(Ss,$o)[t]),b(this,Nr,ac).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,tn).append(s)},Go=new WeakSet,tf=function(){const t=document.createElement("div");return t.className="divider",t},u(Ss,Vc),u(Ss,$o,null);let Zu=Ss;var Vo,en,sn,Xc,lg,qc,hg,Yc,cg;class eA{constructor(t){u(this,Xc);u(this,qc);u(this,Yc);u(this,Vo,null);u(this,en,null);u(this,sn,void 0);p(this,sn,t)}show(t,e,s){const[i,r]=b(this,qc,hg).call(this,e,s),{style:a}=n(this,en)||p(this,en,b(this,Xc,lg).call(this));t.append(n(this,en)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,en).remove()}}Vo=new WeakMap,en=new WeakMap,sn=new WeakMap,Xc=new WeakSet,lg=function(){const t=p(this,en,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ke,{signal:n(this,sn)._signal});const e=p(this,Vo,document.createElement("div"));return e.className="buttons",t.append(e),b(this,Yc,cg).call(this),t},qc=new WeakSet,hg=function(t,e){let s=0,i=0;for(const r of t){const a=r.y+r.height;if(a<s)continue;const o=r.x+(e?r.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]},Yc=new WeakSet,cg=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=n(this,sn)._signal;t.addEventListener("contextmenu",Ke,{signal:s}),t.addEventListener("click",()=>{n(this,sn).highlightSelection("floating_button")},{signal:s}),n(this,Vo).append(t)};function Nc(d,t,e){for(const s of e)t.addEventListener(s,d[s].bind(d))}var Kc;class sA{constructor(){u(this,Kc,0)}get id(){return`${Nb}${qt(this,Kc)._++}`}}Kc=new WeakMap;var Or,Uo,Gt,Br,oc;const wp=class wp{constructor(){u(this,Br);u(this,Or,Yb());u(this,Uo,0);u(this,Gt,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 r=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 X(this,"_isSVGFittingCanvas",r)}getFromFile(t){return I(this,null,function*(){const{lastModified:e,name:s,size:i,type:r}=t;return b(this,Br,oc).call(this,`${e}_${s}_${i}_${r}`,t)})}getFromUrl(t){return I(this,null,function*(){return b(this,Br,oc).call(this,t,t)})}getFromBlob(t,e){return I(this,null,function*(){const s=yield e;return b(this,Br,oc).call(this,t,s)})}getFromId(t){return I(this,null,function*(){n(this,Gt)||p(this,Gt,new Map);const e=n(this,Gt).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){n(this,Gt)||p(this,Gt,new Map);let s=n(this,Gt).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_${n(this,Or)}_${qt(this,Uo)._++}`,refCounter:1,isSvg:!1},n(this,Gt).set(t,s),n(this,Gt).set(s.id,s),s}getSvgUrl(t){const e=n(this,Gt).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,Gt)||p(this,Gt,new Map);const e=n(this,Gt).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,Or)}_`)}};Or=new WeakMap,Uo=new WeakMap,Gt=new WeakMap,Br=new WeakSet,oc=function(t,e){return I(this,null,function*(){n(this,Gt)||p(this,Gt,new Map);let s=n(this,Gt).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,Or)}_${qt(this,Uo)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=yield Mu(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=wp._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=()=>I(this,null,function*(){const f=s.svgUrl=a.result;o.src=(yield r)?`${f}#svgView(preserveAspectRatio(none))`:f}),o.onerror=a.onerror=c});a.readAsDataURL(i),yield l}else s.bitmap=yield createImageBitmap(i);s.refCounter=1}catch(i){U(i),s=null}return n(this,Gt).set(t,s),s&&n(this,Gt).set(s.id,s),s})};let ef=wp;var mt,ri,jo,ct;class iA{constructor(t=128){u(this,mt,[]);u(this,ri,!1);u(this,jo,void 0);u(this,ct,-1);p(this,jo,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,ri))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,ct)===-1){n(this,mt).length>0&&(n(this,mt).length=0),p(this,ct,0),n(this,mt).push(l);return}if(a&&n(this,mt)[n(this,ct)].type===r){o&&(l.undo=n(this,mt)[n(this,ct)].undo),n(this,mt)[n(this,ct)]=l;return}const h=n(this,ct)+1;h===n(this,jo)?n(this,mt).splice(0,1):(p(this,ct,h),h<n(this,mt).length&&n(this,mt).splice(h)),n(this,mt).push(l)}undo(){if(n(this,ct)===-1)return;p(this,ri,!0);const{undo:t,post:e}=n(this,mt)[n(this,ct)];t(),e==null||e(),p(this,ri,!1),p(this,ct,n(this,ct)-1)}redo(){if(n(this,ct)<n(this,mt).length-1){p(this,ct,n(this,ct)+1),p(this,ri,!0);const{cmd:t,post:e}=n(this,mt)[n(this,ct)];t(),e==null||e(),p(this,ri,!1)}}hasSomethingToUndo(){return n(this,ct)!==-1}hasSomethingToRedo(){return n(this,ct)<n(this,mt).length-1}cleanType(t){if(n(this,ct)!==-1){for(let e=n(this,ct);e>=0;e--)if(n(this,mt)[e].type!==t){n(this,mt).splice(e+1,n(this,ct)-e),p(this,ct,e);return}n(this,mt).length=0,p(this,ct,-1)}}destroy(){p(this,mt,null)}}mt=new WeakMap,ri=new WeakMap,jo=new WeakMap,ct=new WeakMap;var Qc,dg;class Qh{constructor(t){u(this,Qc);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=te.platform;for(const[s,i,r={}]of t)for(const a of s){const o=a.startsWith("mac+");e&&o?(this.callbacks.set(a.slice(4),{callback:i,options:r}),this.allKeys.add(a.split("+").at(-1))):!e&&!o&&(this.callbacks.set(a,{callback:i,options:r}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(b(this,Qc,dg).call(this,e));if(!s)return;const{callback:i,options:{bubbles:r=!1,args:a=[],checker:o=null}}=s;o&&!o(t,e)||(i.bind(t,...a,e)(),r||Se(e))}}Qc=new WeakSet,dg=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 Jc=class Jc{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return tA(t),X(this,"_colors",t)}convert(t){const e=gp(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,a)=>r===e[a]))return Jc._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?F.makeHexColor(...e):t}};O(Jc,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let sf=Jc;var Hr,ce,_t,Lt,zr,Cs,$r,xe,ai,nn,Gr,rn,es,Oe,an,Wo,Xo,Vr,qo,ss,oi,Ur,li,is,Zc,hi,Yo,ci,on,Ko,Qo,Ct,Z,xs,ln,Jo,Zo,di,ns,Ts,tl,Te,jr,lc,el,nf,td,ug,ed,fg,Wr,hc,sd,pg,id,gg,nd,mg,sl,rf,rd,bg,il,af,nl,of,ad,Ag,It,Yt,Be,vs,od,yg,ld,wg,rl,lf,hd,vg,hn,yo,al,hf;const Mr=class Mr{constructor(t,e,s,i,r,a,o,l,h,c,f,g,m){u(this,jr);u(this,el);u(this,td);u(this,ed);u(this,Wr);u(this,sd);u(this,id);u(this,nd);u(this,sl);u(this,rd);u(this,il);u(this,nl);u(this,ad);u(this,It);u(this,Be);u(this,od);u(this,ld);u(this,rl);u(this,hd);u(this,hn);u(this,al);u(this,Hr,new AbortController);u(this,ce,null);u(this,_t,new Map);u(this,Lt,new Map);u(this,zr,null);u(this,Cs,null);u(this,$r,null);u(this,xe,new iA);u(this,ai,null);u(this,nn,null);u(this,Gr,0);u(this,rn,new Set);u(this,es,null);u(this,Oe,null);u(this,an,new Set);O(this,"_editorUndoBar",null);u(this,Wo,!1);u(this,Xo,!1);u(this,Vr,!1);u(this,qo,null);u(this,ss,null);u(this,oi,null);u(this,Ur,null);u(this,li,!1);u(this,is,null);u(this,Zc,new sA);u(this,hi,!1);u(this,Yo,!1);u(this,ci,null);u(this,on,null);u(this,Ko,null);u(this,Qo,null);u(this,Ct,V.NONE);u(this,Z,new Set);u(this,xs,null);u(this,ln,null);u(this,Jo,null);u(this,Zo,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});u(this,di,[0,0]);u(this,ns,null);u(this,Ts,null);u(this,tl,null);u(this,Te,null);const A=this._signal=n(this,Hr).signal;p(this,Ts,t),p(this,tl,e),p(this,zr,s),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:A}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:A}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:A}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:A}),i._on("setpreference",this.onSetPreference.bind(this),{signal:A}),i._on("switchannotationeditorparams",y=>this.updateParams(y.type,y.value),{signal:A}),b(this,sd,pg).call(this),b(this,ad,Ag).call(this),b(this,sl,rf).call(this),p(this,Cs,r.annotationStorage),p(this,qo,r.filterFactory),p(this,ln,a),p(this,Ur,o||null),p(this,Wo,l),p(this,Xo,h),p(this,Vr,c),p(this,Qo,f||null),this.viewParameters={realScale:Gi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=m!==!1}static get _keyboardManager(){const t=Mr.prototype,e=a=>n(a,Ts).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,r=this.TRANSLATE_BIG;return X(this,"_keyboardManager",new Qh([[["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)&&n(a,Ts).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,Ts).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:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,i,r;(t=n(this,Te))==null||t.resolve(),p(this,Te,null),(e=n(this,Hr))==null||e.abort(),p(this,Hr,null),this._signal=null;for(const a of n(this,Lt).values())a.destroy();n(this,Lt).clear(),n(this,_t).clear(),n(this,an).clear(),p(this,ce,null),n(this,Z).clear(),n(this,xe).destroy(),(s=n(this,zr))==null||s.destroy(),(i=n(this,is))==null||i.hide(),p(this,is,null),n(this,ss)&&(clearTimeout(n(this,ss)),p(this,ss,null)),n(this,ns)&&(clearTimeout(n(this,ns)),p(this,ns,null)),(r=this._editorUndoBar)==null||r.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,Qo)}get useNewAltTextFlow(){return n(this,Xo)}get useNewAltTextWhenAddingImage(){return n(this,Vr)}get hcmFilter(){return X(this,"hcmFilter",n(this,ln)?n(this,qo).addHCMFilter(n(this,ln).foreground,n(this,ln).background):"none")}get direction(){return X(this,"direction",getComputedStyle(n(this,Ts)).direction)}get highlightColors(){return X(this,"highlightColors",n(this,Ur)?new Map(n(this,Ur).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return X(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,nn,t)}setMainHighlightColorPicker(t){p(this,Ko,t)}editAltText(t,e=!1){var s;(s=n(this,zr))==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,Vr,e);break}}onPageChanging({pageNumber:t}){p(this,Gr,t-1)}focusMainContainer(){n(this,Ts).focus()}findParent(t,e){for(const s of n(this,Lt).values()){const{x:i,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){n(this,tl).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,an).add(t)}removeShouldRescale(t){n(this,an).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Gi.PDF_TO_CSS_UNITS;for(const s of n(this,an))s.onScaleChanging();(e=n(this,nn))==null||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:r,focusOffset:a}=e,o=e.toString(),h=b(this,jr,lc).call(this,e).closest(".textLayer"),c=this.getSelectionBoxes(h);if(!c)return;e.empty();const f=b(this,el,nf).call(this,h),g=n(this,Ct)===V.NONE,m=()=>{f==null||f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:s,anchorOffset:i,focusNode:r,focusOffset:a,text:o}),g&&this.showAllEditors("highlight",!0,!0)};if(g){this.switchToMode(V.HIGHLIGHT,m);return}m()}addToAnnotationStorage(t){!t.isEmpty()&&n(this,Cs)&&!n(this,Cs).has(t.id)&&n(this,Cs).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,n(this,li)&&(p(this,li,!1),b(this,Wr,hc).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,Z))if(e.div.contains(t)){p(this,on,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,on))return;const[t,e]=n(this,on);p(this,on,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,sl,rf).call(this),b(this,il,af).call(this)}removeEditListeners(){b(this,rd,bg).call(this),b(this,nl,of).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,Oe))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,Oe))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,ce))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,Z)){const r=i.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){return I(this,null,function*(){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const a of n(this,Oe))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){U(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const h=yield i.deserialize(l);if(!h)return;r.push(h)}const a=()=>{for(const l of r)b(this,rl,lf).call(this,l);b(this,al,hf).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){U(`paste: "${r.message}".`)}})}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,Ct)!==V.NONE&&!this.isEditorHandlingKeyboard&&Mr._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,li)&&(p(this,li,!1),b(this,Wr,hc).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?(b(this,id,gg).call(this),b(this,il,af).call(this),b(this,It,Yt).call(this,{isEditing:n(this,Ct)!==V.NONE,isEmpty:b(this,hn,yo).call(this),hasSomethingToUndo:n(this,xe).hasSomethingToUndo(),hasSomethingToRedo:n(this,xe).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,nd,mg).call(this),b(this,nl,of).call(this),b(this,It,Yt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,Oe)){p(this,Oe,t);for(const e of n(this,Oe))b(this,Be,vs).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,Zc).id}get currentLayer(){return n(this,Lt).get(n(this,Gr))}getLayer(t){return n(this,Lt).get(t)}get currentPageIndex(){return n(this,Gr)}addLayer(t){n(this,Lt).set(t.pageIndex,t),n(this,hi)?t.enable():t.disable()}removeLayer(t){n(this,Lt).delete(t.pageIndex)}updateMode(t,e=null,s=!1){return I(this,null,function*(){var i;if(n(this,Ct)!==t&&!(n(this,Te)&&(yield n(this,Te).promise,!n(this,Te)))){if(p(this,Te,Promise.withResolvers()),p(this,Ct,t),t===V.NONE){this.setEditingState(!1),b(this,ld,wg).call(this),(i=this._editorUndoBar)==null||i.hide(),n(this,Te).resolve();return}this.setEditingState(!0),yield b(this,od,yg).call(this),this.unselectAll();for(const r of n(this,Lt).values())r.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),n(this,Te).resolve();return}for(const r of n(this,_t).values())r.annotationElementId===e?(this.setSelected(r),r.enterInEditMode()):r.unselect();n(this,Te).resolve()}})}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==n(this,Ct)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(n(this,Oe)){switch(t){case Y.CREATE:this.currentLayer.addNewEditor();return;case Y.HIGHLIGHT_DEFAULT_COLOR:(s=n(this,Ko))==null||s.updateColor(e);break;case Y.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,Jo)||p(this,Jo,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of n(this,Z))i.updateParams(t,e);for(const i of n(this,Oe))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r,a;for(const o of n(this,_t).values())o.editorType===t&&o.show(e);((a=(r=n(this,Jo))==null?void 0:r.get(Y.HIGHLIGHT_SHOW_ALL))!=null?a:!0)!==e&&b(this,Be,vs).call(this,[[Y.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,Yo)!==t){p(this,Yo,t);for(const e of n(this,Lt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of n(this,_t).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return n(this,_t).get(t)}addEditor(t){n(this,_t).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(n(this,ss)&&clearTimeout(n(this,ss)),p(this,ss,setTimeout(()=>{this.focusMainContainer(),p(this,ss,null)},0))),n(this,_t).delete(t.id),this.unselect(t),(!t.annotationElementId||!n(this,rn).has(t.annotationElementId))&&((e=n(this,Cs))==null||e.remove(t.id))}addDeletedAnnotationElement(t){n(this,rn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,rn).has(t)}removeDeletedAnnotationElement(t){n(this,rn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,ce)!==t&&(p(this,ce,t),t&&b(this,Be,vs).call(this,t.propertiesToUpdate))}updateUI(t){n(this,hd,vg)===t&&b(this,Be,vs).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,Be,vs).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,Z).has(t)){n(this,Z).delete(t),t.unselect(),b(this,It,Yt).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,Z).add(t),t.select(),b(this,Be,vs).call(this,t.propertiesToUpdate),b(this,It,Yt).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;(e=n(this,nn))==null||e.commitOrRemove();for(const s of n(this,Z))s!==t&&s.unselect();n(this,Z).clear(),n(this,Z).add(t),t.select(),b(this,Be,vs).call(this,t.propertiesToUpdate),b(this,It,Yt).call(this,{hasSelectedEditor:!0})}isSelected(t){return n(this,Z).has(t)}get firstSelectedEditor(){return n(this,Z).values().next().value}unselect(t){t.unselect(),n(this,Z).delete(t),b(this,It,Yt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,Z).size!==0}get isEnterHandled(){return n(this,Z).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,xe).undo(),b(this,It,Yt).call(this,{hasSomethingToUndo:n(this,xe).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,hn,yo).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,xe).redo(),b(this,It,Yt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,xe).hasSomethingToRedo(),isEmpty:b(this,hn,yo).call(this)})}addCommands(t){n(this,xe).add(t),b(this,It,Yt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,hn,yo).call(this)})}cleanUndoStack(t){n(this,xe).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...n(this,Z)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},i=()=>{for(const a of e)b(this,rl,lf).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,ce))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,ce)||this.hasSelection}selectAll(){for(const t of n(this,Z))t.commit();b(this,al,hf).call(this,n(this,_t).values())}unselectAll(){var t;if(!(n(this,ce)&&(n(this,ce).commitOrRemove(),n(this,Ct)!==V.NONE))&&!((t=n(this,nn))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of n(this,Z))e.unselect();n(this,Z).clear(),b(this,It,Yt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,di)[0]+=t,n(this,di)[1]+=e;const[i,r]=n(this,di),a=[...n(this,Z)],o=1e3;n(this,ns)&&clearTimeout(n(this,ns)),p(this,ns,setTimeout(()=>{p(this,ns,null),n(this,di)[0]=n(this,di)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,_t).has(l.id)&&l.translateInPage(i,r)},undo:()=>{for(const l of a)n(this,_t).has(l.id)&&l.translateInPage(-i,-r)},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,es,new Map);for(const t of n(this,Z))n(this,es).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,es))return!1;this.disableUserSelect(!1);const t=n(this,es);p(this,es,null);let e=!1;for(const[{x:i,y:r,pageIndex:a},o]of t)o.newX=i,o.newY=r,o.newPageIndex=a,e||(e=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,r,a,o)=>{if(n(this,_t).has(i.id)){const l=n(this,Lt).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of t)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,es))for(const s of n(this,es).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())||n(this,Z).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,ce)===t}getActive(){return n(this,ce)}getMode(){return n(this,Ct)}get imageManager(){return X(this,"imageManager",new ef)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(h,c,f,g)=>({x:(c-i)/a,y:1-(h+f-s)/r,width:g/a,height:f/r});break;case"180":o=(h,c,f,g)=>({x:1-(h+f-s)/r,y:1-(c+g-i)/a,width:f/r,height:g/a});break;case"270":o=(h,c,f,g)=>({x:1-(c+g-i)/a,y:(h-s)/r,width:g/a,height:f/r});break;default:o=(h,c,f,g)=>({x:(h-s)/r,y:(c-i)/a,width:f/r,height:g/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const f=e.getRangeAt(h);if(!f.collapsed)for(const{x:g,y:m,width:A,height:y}of f.getClientRects())A===0||y===0||l.push(o(g,m,A,y))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,$r)||p(this,$r,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,$r))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,$r))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,Cs).getRawValue(e);s&&(n(this,Ct)===V.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}};Hr=new WeakMap,ce=new WeakMap,_t=new WeakMap,Lt=new WeakMap,zr=new WeakMap,Cs=new WeakMap,$r=new WeakMap,xe=new WeakMap,ai=new WeakMap,nn=new WeakMap,Gr=new WeakMap,rn=new WeakMap,es=new WeakMap,Oe=new WeakMap,an=new WeakMap,Wo=new WeakMap,Xo=new WeakMap,Vr=new WeakMap,qo=new WeakMap,ss=new WeakMap,oi=new WeakMap,Ur=new WeakMap,li=new WeakMap,is=new WeakMap,Zc=new WeakMap,hi=new WeakMap,Yo=new WeakMap,ci=new WeakMap,on=new WeakMap,Ko=new WeakMap,Qo=new WeakMap,Ct=new WeakMap,Z=new WeakMap,xs=new WeakMap,ln=new WeakMap,Jo=new WeakMap,Zo=new WeakMap,di=new WeakMap,ns=new WeakMap,Ts=new WeakMap,tl=new WeakMap,Te=new WeakMap,jr=new WeakSet,lc=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},el=new WeakSet,nf=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,Lt).values())if(s.hasTextLayer(t))return s;return null},td=new WeakSet,ug=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,jr,lc).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,is)||p(this,is,new eA(this)),n(this,is).show(s,i,this.direction==="ltr"))},ed=new WeakSet,fg=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,xs)&&((r=n(this,is))==null||r.hide(),p(this,xs,null),b(this,It,Yt).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,xs))return;const i=b(this,jr,lc).call(this,t).closest(".textLayer");if(!i){n(this,xs)&&((a=n(this,is))==null||a.hide(),p(this,xs,null),b(this,It,Yt).call(this,{hasSelectedText:!1}));return}if((o=n(this,is))==null||o.hide(),p(this,xs,e),b(this,It,Yt).call(this,{hasSelectedText:!0}),!(n(this,Ct)!==V.HIGHLIGHT&&n(this,Ct)!==V.NONE)&&(n(this,Ct)===V.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,li,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,Ct)===V.HIGHLIGHT?b(this,el,nf).call(this,i):null;l==null||l.toggleDrawing();const h=new AbortController,c=this.combinedSignal(h),f=g=>{g.type==="pointerup"&&g.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),g.type==="pointerup"&&b(this,Wr,hc).call(this,"main_toolbar"))};window.addEventListener("pointerup",f,{signal:c}),window.addEventListener("blur",f,{signal:c})}},Wr=new WeakSet,hc=function(t=""){n(this,Ct)===V.HIGHLIGHT?this.highlightSelection(t):n(this,Wo)&&b(this,td,ug).call(this)},sd=new WeakSet,pg=function(){document.addEventListener("selectionchange",b(this,ed,fg).bind(this),{signal:this._signal})},id=new WeakSet,gg=function(){if(n(this,oi))return;p(this,oi,new AbortController);const t=this.combinedSignal(n(this,oi));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},nd=new WeakSet,mg=function(){var t;(t=n(this,oi))==null||t.abort(),p(this,oi,null)},sl=new WeakSet,rf=function(){if(n(this,ci))return;p(this,ci,new AbortController);const t=this.combinedSignal(n(this,ci));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},rd=new WeakSet,bg=function(){var t;(t=n(this,ci))==null||t.abort(),p(this,ci,null)},il=new WeakSet,af=function(){if(n(this,ai))return;p(this,ai,new AbortController);const t=this.combinedSignal(n(this,ai));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})},nl=new WeakSet,of=function(){var t;(t=n(this,ai))==null||t.abort(),p(this,ai,null)},ad=new WeakSet,Ag=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},It=new WeakSet,Yt=function(t){Object.entries(t).some(([s,i])=>n(this,Zo)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(n(this,Zo),t)}),n(this,Ct)===V.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,Be,vs).call(this,[[Y.HIGHLIGHT_FREE,!0]]))},Be=new WeakSet,vs=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},od=new WeakSet,yg=function(){return I(this,null,function*(){if(!n(this,hi)){p(this,hi,!0);const t=[];for(const e of n(this,Lt).values())t.push(e.enable());yield Promise.all(t);for(const e of n(this,_t).values())e.enable()}})},ld=new WeakSet,wg=function(){if(this.unselectAll(),n(this,hi)){p(this,hi,!1);for(const t of n(this,Lt).values())t.disable();for(const t of n(this,_t).values())t.disable()}},rl=new WeakSet,lf=function(t){const e=n(this,Lt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},hd=new WeakSet,vg=function(){let t=null;for(t of n(this,Z));return t},hn=new WeakSet,yo=function(){if(n(this,_t).size===0)return!0;if(n(this,_t).size===1)for(const t of n(this,_t).values())return t.isEmpty();return!1},al=new WeakSet,hf=function(t){for(const e of n(this,Z))e.unselect();n(this,Z).clear();for(const e of t)e.isEmpty()||(n(this,Z).add(e),e.select());b(this,It,Yt).call(this,{hasSelectedEditor:this.hasSelection})},O(Mr,"TRANSLATE_SMALL",1),O(Mr,"TRANSLATE_BIG",10);let Ar=Mr;var xt,rs,He,Xr,as,de,qr,os,ne,Ps,cn,ls,ui,dn,wo,Yr,cc;const Kt=class Kt{constructor(t){u(this,dn);u(this,Yr);u(this,xt,null);u(this,rs,!1);u(this,He,null);u(this,Xr,null);u(this,as,null);u(this,de,null);u(this,qr,!1);u(this,os,null);u(this,ne,null);u(this,Ps,null);u(this,cn,null);u(this,ls,!1);p(this,ne,t),p(this,ls,t._uiManager.useNewAltTextFlow),n(Kt,ui)||p(Kt,ui,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){var e;(e=Kt._l10n)!=null||(Kt._l10n=t)}render(){return I(this,null,function*(){const t=p(this,He,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,Xr,document.createElement("span"));t.append(e),n(this,ls)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(Kt,ui).missing),e.setAttribute("data-l10n-id",n(Kt,ui)["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=n(this,ne)._uiManager._signal;t.addEventListener("contextmenu",Ke,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,ne)._uiManager.editAltText(n(this,ne)),n(this,ls)&&n(this,ne)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,dn,wo)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,qr,!0),i(r))},{signal:s}),yield b(this,Yr,cc).call(this),t})}finish(){n(this,He)&&(n(this,He).focus({focusVisible:n(this,qr)}),p(this,qr,!1))}isEmpty(){return n(this,ls)?n(this,xt)===null:!n(this,xt)&&!n(this,rs)}hasData(){return n(this,ls)?n(this,xt)!==null||!!n(this,Ps):this.isEmpty()}get guessedText(){return n(this,Ps)}setGuessedText(t){return I(this,null,function*(){n(this,xt)===null&&(p(this,Ps,t),p(this,cn,yield Kt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,Yr,cc).call(this))})}toggleAltTextBadge(t=!1){var e;if(!n(this,ls)||n(this,xt)){(e=n(this,os))==null||e.remove(),p(this,os,null);return}if(!n(this,os)){const s=p(this,os,document.createElement("div"));s.className="noAltTextBadge",n(this,ne).div.append(s)}n(this,os).classList.toggle("hidden",!t)}serialize(t){let e=n(this,xt);return!t&&n(this,Ps)===e&&(e=n(this,cn)),{altText:e,decorative:n(this,rs),guessedText:n(this,Ps),textWithDisclaimer:n(this,cn)}}get data(){return{altText:n(this,xt),decorative:n(this,rs)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(p(this,Ps,s),p(this,cn,i)),!(n(this,xt)===t&&n(this,rs)===e)&&(r||(p(this,xt,t),p(this,rs,e)),b(this,Yr,cc).call(this))}toggle(t=!1){n(this,He)&&(!t&&n(this,de)&&(clearTimeout(n(this,de)),p(this,de,null)),n(this,He).disabled=!t)}shown(){n(this,ne)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,dn,wo)}})}destroy(){var t,e;(t=n(this,He))==null||t.remove(),p(this,He,null),p(this,Xr,null),p(this,as,null),(e=n(this,os))==null||e.remove(),p(this,os,null)}};xt=new WeakMap,rs=new WeakMap,He=new WeakMap,Xr=new WeakMap,as=new WeakMap,de=new WeakMap,qr=new WeakMap,os=new WeakMap,ne=new WeakMap,Ps=new WeakMap,cn=new WeakMap,ls=new WeakMap,ui=new WeakMap,dn=new WeakSet,wo=function(){return n(this,xt)&&"added"||n(this,xt)===null&&this.guessedText&&"review"||"missing"},Yr=new WeakSet,cc=function(){return I(this,null,function*(){var i,r,a;const t=n(this,He);if(!t)return;if(n(this,ls)){if(t.classList.toggle("done",!!n(this,xt)),t.setAttribute("data-l10n-id",n(Kt,ui)[n(this,dn,wo)]),(i=n(this,Xr))==null||i.setAttribute("data-l10n-id",n(Kt,ui)[`${n(this,dn,wo)}-label`]),!n(this,xt)){(r=n(this,as))==null||r.remove();return}}else{if(!n(this,xt)&&!n(this,rs)){t.classList.remove("done"),(a=n(this,as))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,as);if(!e){p(this,as,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,ne).id}`;const o=100,l=n(this,ne)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,de)),p(this,de,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,de,setTimeout(()=>{p(this,de,null),n(this,as).classList.add("show"),n(this,ne)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;n(this,de)&&(clearTimeout(n(this,de)),p(this,de,null)),(h=n(this,as))==null||h.classList.remove("show")},{signal:l})}n(this,rs)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,xt)),e.parentNode||t.append(e);const s=n(this,ne).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)})},u(Kt,ui,null),O(Kt,"_l10n",null);let Oc=Kt;var ol,un,ll,hl,cl,dl,ul,Kr,Rs,fn,fi,cd,_g,dd,Sg,fl,cf;const vp=class vp{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){u(this,cd);u(this,dd);u(this,fl);u(this,ol,void 0);u(this,un,!1);u(this,ll,null);u(this,hl,void 0);u(this,cl,void 0);u(this,dl,void 0);u(this,ul,void 0);u(this,Kr,void 0);u(this,Rs,null);u(this,fn,void 0);u(this,fi,null);p(this,ol,t),p(this,ll,s),p(this,hl,e),p(this,cl,i),p(this,dl,r),p(this,ul,a),p(this,fn,new AbortController),p(this,Kr,AbortSignal.any([o,n(this,fn).signal])),t.addEventListener("touchstart",b(this,cd,_g).bind(this),{passive:!1,signal:n(this,Kr)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return X(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;(t=n(this,fn))==null||t.abort(),p(this,fn,null)}};ol=new WeakMap,un=new WeakMap,ll=new WeakMap,hl=new WeakMap,cl=new WeakMap,dl=new WeakMap,ul=new WeakMap,Kr=new WeakMap,Rs=new WeakMap,fn=new WeakMap,fi=new WeakMap,cd=new WeakSet,_g=function(t){var i,r,a;if((i=n(this,hl))!=null&&i.call(this)||t.touches.length<2)return;if(!n(this,fi)){p(this,fi,new AbortController);const o=AbortSignal.any([n(this,Kr),n(this,fi).signal]),l=n(this,ol),h={signal:o,passive:!1};l.addEventListener("touchmove",b(this,dd,Sg).bind(this),h),l.addEventListener("touchend",b(this,fl,cf).bind(this),h),l.addEventListener("touchcancel",b(this,fl,cf).bind(this),h),(r=n(this,cl))==null||r.call(this)}if(Se(t),t.touches.length!==2||(a=n(this,ll))!=null&&a.call(this)){p(this,Rs,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),p(this,Rs,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},dd=new WeakSet,Sg=function(t){var S;if(!n(this,Rs)||t.touches.length!==2)return;let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:r}=e,{screenX:a,screenY:o}=s,l=n(this,Rs),{touch0X:h,touch0Y:c,touch1X:f,touch1Y:g}=l,m=f-h,A=g-c,y=a-i,v=o-r,w=Math.hypot(y,v)||1,_=Math.hypot(m,A)||1;if(!n(this,un)&&Math.abs(_-w)<=vp.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,t.preventDefault(),!n(this,un)){p(this,un,!0);return}const E=[(i+a)/2,(r+o)/2];(S=n(this,dl))==null||S.call(this,E,_,w)},fl=new WeakSet,cf=function(t){var e;n(this,fi).abort(),p(this,fi,null),(e=n(this,ul))==null||e.call(this),n(this,Rs)&&(t.preventDefault(),p(this,Rs,null),p(this,un,!1))};let Bc=vp;var pn,ze,at,Qr,pi,pl,gn,Dt,mn,ks,gi,gl,bn,ue,ml,An,Ms,hs,Jr,Zr,Pe,yn,bl,ud,Al,df,yl,uf,ta,dc,fd,Eg,pd,Cg,wl,ff,ea,uc,vl,pf,gd,xg,md,Tg,bd,Pg,_l,gf,Ad,Rg,Sl,mf,yd,kg,wd,Mg,vd,Lg,El,bf,wn,vo;const j=class j{constructor(t){u(this,Al);u(this,ta);u(this,fd);u(this,pd);u(this,wl);u(this,ea);u(this,vl);u(this,gd);u(this,md);u(this,bd);u(this,_l);u(this,Ad);u(this,Sl);u(this,yd);u(this,wd);u(this,vd);u(this,El);u(this,wn);u(this,pn,null);u(this,ze,null);u(this,at,null);u(this,Qr,!1);u(this,pi,null);u(this,pl,"");u(this,gn,!1);u(this,Dt,null);u(this,mn,null);u(this,ks,null);u(this,gi,null);u(this,gl,"");u(this,bn,!1);u(this,ue,null);u(this,ml,!1);u(this,An,!1);u(this,Ms,!1);u(this,hs,null);u(this,Jr,0);u(this,Zr,0);u(this,Pe,null);u(this,yn,null);O(this,"_editToolbar",null);O(this,"_initialOptions",Object.create(null));O(this,"_initialData",null);O(this,"_isVisible",!0);O(this,"_uiManager",null);O(this,"_focusEventsAllowed",!0);u(this,bl,!1);u(this,ud,j._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:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,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=j.prototype._resizeWithKeyboard,e=Ar.TRANSLATE_SMALL,s=Ar.TRANSLATE_BIG;return X(this,"_resizerKeyboardManager",new Qh([[["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"],j.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return X(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new nA({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){var i;if((i=j._l10n)!=null||(j._l10n=t),j._l10nResizer||(j._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"})),j._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);j._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){st("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,bl)}set _isDraggable(t){var e;p(this,bl,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=n(this,ud)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):b(this,wn,vo).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,bn)?p(this,bn,!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[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/a,this.fixAndSetPosition()}translate(t,e){b(this,Al,df).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,ue)||p(this,ue,[this.x,this.y,this.width,this.height]),b(this,Al,df).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){n(this,ue)||p(this,ue,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:f,y:g}=this.div.getBoundingClientRect();this.parent.findNewParent(this,f,g)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,h]=this.getBaseTranslation();a+=l,o+=h;const{style:c}=s;c.left=`${(100*a).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,ue)&&(n(this,ue)[0]!==this.x||n(this,ue)[1]!==this.y)}get _hasBeenResized(){return!!n(this,ue)&&(n(this,ue)[2]!==this.width||n(this,ue)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=j,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(t){case 0:r=Math.max(0,Math.min(s-o,r)),a=Math.max(0,Math.min(i-l,a));break;case 90:r=Math.max(0,Math.min(s-l,r)),a=Math.min(i,Math.max(o,a));break;case 180:r=Math.min(s,Math.max(o,r)),a=Math.min(i,Math.max(l,a));break;case 270:r=Math.min(s,Math.max(l,r)),a=Math.max(0,Math.min(i-o,a));break}this.x=r/=s,this.y=a/=i;const[h,c]=this.getBaseTranslation();r+=h,a+=c,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return b(s=j,yl,uf).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=j,yl,uf).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,{style:r}=this.div;r.width=`${(100*t/s).toFixed(2)}%`,n(this,gn)||(r.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),r=!n(this,gn)&&e.endsWith("%");if(i&&r)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!n(this,gn)&&!r&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=n(this,at))==null||t.finish()}addEditToolbar(){return I(this,null,function*(){return this._editToolbar||n(this,An)?this._editToolbar:(this._editToolbar=new Zu(this),this.div.append(this._editToolbar.render()),n(this,at)&&(yield this._editToolbar.addAltText(n(this,at))),this._editToolbar)})}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=n(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()}addAltTextButton(){return I(this,null,function*(){n(this,at)||(Oc.initialize(j._l10n),p(this,at,new Oc(this)),n(this,pn)&&(n(this,at).data=n(this,pn),p(this,pn,null)),yield this.addEditToolbar())})}get altTextData(){var t;return(t=n(this,at))==null?void 0:t.data}set altTextData(t){n(this,at)&&(n(this,at).data=t)}get guessedAltText(){var t;return(t=n(this,at))==null?void 0:t.guessedText}setGuessedAltText(t){return I(this,null,function*(){var e;yield(e=n(this,at))==null?void 0:e.setGuessedText(t)})}serializeAltText(t){var e;return(e=n(this,at))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,at)&&!n(this,at).isEmpty()}hasAltTextData(){var t,e;return(e=(t=n(this,at))==null?void 0:t.hasData())!=null?e:!1}render(){var r;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=n(this,Qr)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),b(this,Sl,mf).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),Nc(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,yn)||p(this,yn,new Bc({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,gd,xg).bind(this),onPinching:b(this,md,Tg).bind(this),onPinchEnd:b(this,bd,Pg).bind(this),signal:this._uiManager._signal}))),(r=this._uiManager._editorUndoBar)==null||r.hide(),this.div}pointerdown(t){const{isMac:e}=te.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,bn,!0),this._isDraggable){b(this,Ad,Rg).call(this,t);return}b(this,_l,gf).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,hs)&&clearTimeout(n(this,hs)),p(this,hs,setTimeout(()=>{var t;p(this,hs,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/i,c=e/i,f=this.x*r,g=this.y*a,m=this.width*r,A=this.height*a;switch(s){case 0:return[f+h+o,a-g-c-A+l,f+h+m+o,a-g-c+l];case 90:return[f+c+o,a-g+h+l,f+c+A+o,a-g+h+m+l];case 180:return[f-h-m+o,a-g+c+l,f-h+o,a-g+c+A+l];case 270:return[f-c-A+o,a-g-h-m+l,f-c+o,a-g-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,a]=t,o=r-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[r,e-i,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){p(this,An,!0)}disableEditMode(){p(this,An,!1)}isInEditMode(){return n(this,An)}shouldGetKeyboardEvents(){return n(this,Ms)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&i>0&&t<r&&s>0}rebuild(){b(this,Sl,mf).call(this)}rotate(t){}resize(){}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){st("An editor must be serializable")}static deserialize(t,e,s){return I(this,null,function*(){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,p(i,pn,t.accessibilityData);const[r,a]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/r,i.y=l/a,i.width=h/r,i.height=c/a,i})}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e;if((t=n(this,gi))==null||t.abort(),p(this,gi,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),n(this,hs)&&(clearTimeout(n(this,hs)),p(this,hs,null)),b(this,wn,vo).call(this),this.removeEditToolbar(),n(this,Pe)){for(const s of n(this,Pe).values())clearTimeout(s);p(this,Pe,null)}this.parent=null,(e=n(this,yn))==null||e.destroy(),p(this,yn,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,fd,Eg).call(this),n(this,Dt).classList.remove("hidden"),Nc(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,ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,Dt).children;if(!n(this,ze)){p(this,ze,Array.from(e));const a=b(this,yd,kg).bind(this),o=b(this,wd,Mg).bind(this),l=this._uiManager._signal;for(const h of n(this,ze)){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",b(this,vd,Lg).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",j._l10nResizer[c])}}const s=n(this,ze)[0];let i=0;for(const a of e){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,ze).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,Dt).append(n(this,Dt).firstChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,Dt).firstChild.before(n(this,Dt).lastChild);let a=0;for(const o of e){const h=n(this,ze)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",j._l10nResizer[h])}}b(this,El,bf).call(this,0),p(this,Ms,!0),n(this,Dt).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,Ms)&&b(this,vl,pf).call(this,n(this,gl),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,wn,vo).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,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=n(this,at))==null||s.toggleAltTextBadge(!1)}unselect(){var t,e,s,i,r;(t=n(this,Dt))==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(),(r=n(this,at))==null||r.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return n(this,ml)}set isEditing(t){p(this,ml,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,gn,!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){n(this,Pe)||p(this,Pe,new Map);const{action:s}=t;let i=n(this,Pe).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,Pe).delete(s),n(this,Pe).size===0&&p(this,Pe,null)},j._telemetryTimeout),n(this,Pe).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,Qr,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,Qr,!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()}};pn=new WeakMap,ze=new WeakMap,at=new WeakMap,Qr=new WeakMap,pi=new WeakMap,pl=new WeakMap,gn=new WeakMap,Dt=new WeakMap,mn=new WeakMap,ks=new WeakMap,gi=new WeakMap,gl=new WeakMap,bn=new WeakMap,ue=new WeakMap,ml=new WeakMap,An=new WeakMap,Ms=new WeakMap,hs=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,Pe=new WeakMap,yn=new WeakMap,bl=new WeakMap,ud=new WeakMap,Al=new WeakSet,df=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},yl=new WeakSet,uf=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]}},ta=new WeakSet,dc=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]}},fd=new WeakSet,Eg=function(){if(n(this,Dt))return;p(this,Dt,document.createElement("div")),n(this,Dt).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");n(this,Dt).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,pd,Cg).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ke,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,Dt))},pd=new WeakSet,Cg=function(t,e){var c;e.preventDefault();const{isMac:s}=te.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=n(this,at))==null||c.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,mn,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,vl,pf).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Se,{passive:!1,signal:a}),window.addEventListener("contextmenu",Ke,{signal:a}),p(this,ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var f;r.abort(),this.parent.togglePointerEvents(!0),(f=n(this,at))==null||f.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,ea,uc).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},wl=new WeakSet,ff=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e;const[r,a]=this.parentDimensions;this.setDims(r*s,a*i),this.fixAndSetPosition(),this._onResized()},ea=new WeakSet,uc=function(){if(!n(this,ks))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,ks);p(this,ks,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===i||this.addCommands({cmd:b(this,wl,ff).bind(this,r,a,o,l),undo:b(this,wl,ff).bind(this,t,e,s,i),mustExec:!0})},vl=new WeakSet,pf=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=j.MIN_SIZE/s,c=j.MIN_SIZE/i,f=b(this,ta,dc).call(this,this.rotation),g=(x,R)=>[f[0]*x+f[2]*R,f[1]*x+f[3]*R],m=b(this,ta,dc).call(this,360-this.rotation),A=(x,R)=>[m[0]*x+m[2]*R,m[1]*x+m[3]*R];let y,v,w=!1,_=!1;switch(t){case"topLeft":w=!0,y=(x,R)=>[0,0],v=(x,R)=>[x,R];break;case"topMiddle":y=(x,R)=>[x/2,0],v=(x,R)=>[x/2,R];break;case"topRight":w=!0,y=(x,R)=>[x,0],v=(x,R)=>[0,R];break;case"middleRight":_=!0,y=(x,R)=>[x,R/2],v=(x,R)=>[0,R/2];break;case"bottomRight":w=!0,y=(x,R)=>[x,R],v=(x,R)=>[0,0];break;case"bottomMiddle":y=(x,R)=>[x/2,R],v=(x,R)=>[x/2,0];break;case"bottomLeft":w=!0,y=(x,R)=>[0,R],v=(x,R)=>[x,0];break;case"middleLeft":_=!0,y=(x,R)=>[0,R/2],v=(x,R)=>[x,R/2];break}const E=y(o,l),S=v(o,l);let C=g(...S);const P=j._round(r+C[0]),T=j._round(a+C[1]);let k=1,N=1,$,B;if(e.fromKeyboard)({deltaX:$,deltaY:B}=e);else{const{screenX:x,screenY:R}=e,[G,J]=n(this,mn);[$,B]=this.screenToPageTranslation(x-G,R-J),n(this,mn)[0]=x,n(this,mn)[1]=R}if([$,B]=A($/s,B/i),w){const x=Math.hypot(o,l);k=N=Math.max(Math.min(Math.hypot(S[0]-E[0]-$,S[1]-E[1]-B)/x,1/o,1/l),h/o,c/l)}else _?k=Math.max(h,Math.min(1,Math.abs(S[0]-E[0]-$)))/o:N=Math.max(c,Math.min(1,Math.abs(S[1]-E[1]-B)))/l;const it=j._round(o*k),nt=j._round(l*N);C=g(...v(it,nt));const K=P-C[0],Et=T-C[1];n(this,ue)||p(this,ue,[this.x,this.y,this.width,this.height]),this.width=it,this.height=nt,this.x=K,this.y=Et,this.setDims(s*it,i*nt),this.fixAndSetPosition(),this._onResizing()},gd=new WeakSet,xg=function(){var t;p(this,ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,at))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},md=new WeakSet,Tg=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,ta,dc).call(this,this.rotation),o=(P,T)=>[a[0]*P+a[2]*T,a[1]*P+a[3]*T],[l,h]=this.parentDimensions,c=this.x,f=this.y,g=this.width,m=this.height,A=j.MIN_SIZE/l,y=j.MIN_SIZE/h;r=Math.max(Math.min(r,1/g,1/m),A/g,y/m);const v=j._round(g*r),w=j._round(m*r);if(v===g&&w===m)return;n(this,ue)||p(this,ue,[c,f,g,m]);const _=o(g/2,m/2),E=j._round(c+_[0]),S=j._round(f+_[1]),C=o(v/2,w/2);this.x=E-C[0],this.y=S-C[1],this.width=v,this.height=w,this.setDims(l*v,h*w),this.fixAndSetPosition(),this._onResizing()},bd=new WeakSet,Pg=function(){var t;(t=n(this,at))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,ea,uc).call(this)},_l=new WeakSet,gf=function(t){const{isMac:e}=te.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Ad=new WeakSet,Rg=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=h=>{i.abort(),p(this,pi,null),p(this,bn,!1),this._uiManager.endDragSession()||b(this,_l,gf).call(this,h),s&&this._onStopDragging()};e&&(p(this,Jr,t.clientX),p(this,Zr,t.clientY),p(this,pi,t.pointerId),p(this,pl,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._onStartDragging());const{clientX:c,clientY:f,pointerId:g}=h;if(g!==n(this,pi)){Se(h);return}const[m,A]=this.screenToPageTranslation(c-n(this,Jr),f-n(this,Zr));p(this,Jr,c),p(this,Zr,f),this._uiManager.dragSelectedEditors(m,A)},a),window.addEventListener("touchmove",Se,a),window.addEventListener("pointerdown",h=>{h.pointerType===n(this,pl)&&(n(this,yn)||h.isPrimary)&&o(h),Se(h)},a));const l=h=>{if(!n(this,pi)||n(this,pi)===h.pointerId){o(h);return}Se(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Sl=new WeakSet,mf=function(){if(n(this,gi)||!this.div)return;p(this,gi,new AbortController);const t=this._uiManager.combinedSignal(n(this,gi));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},yd=new WeakSet,kg=function(t){j._resizerKeyboardManager.exec(this,t)},wd=new WeakSet,Mg=function(t){var e;n(this,Ms)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,Dt)&&b(this,wn,vo).call(this)},vd=new WeakSet,Lg=function(t){p(this,gl,n(this,Ms)?t:"")},El=new WeakSet,bf=function(t){if(n(this,ze))for(const e of n(this,ze))e.tabIndex=t},wn=new WeakSet,vo=function(){p(this,Ms,!1),b(this,El,bf).call(this,-1),b(this,ea,uc).call(this)},u(j,yl),O(j,"_l10n",null),O(j,"_l10nResizer",null),O(j,"_borderLineWidth",-1),O(j,"_colorManager",new sf),O(j,"_zIndex",1),O(j,"_telemetryTimeout",1e3);let ut=j;class nA extends ut{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Fp=3285377520,Ce=4294901760,Ze=65535;class Ig{constructor(t){this.h1=t?t&4294967295:Fp,this.h2=t?t&4294967295:Fp}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let y=0,v=t.length;y<v;y++){const w=t.charCodeAt(y);w<=255?e[s++]=w:(e[s++]=w>>>8,e[s++]=w&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,r=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,h=this.h1,c=this.h2;const f=3432918353,g=461845907,m=f&Ze,A=g&Ze;for(let y=0;y<i;y++)y&1?(o=a[y],o=o*f&Ce|o*m&Ze,o=o<<15|o>>>17,o=o*g&Ce|o*A&Ze,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[y],l=l*f&Ce|l*m&Ze,l=l<<15|l>>>17,l=l*g&Ce|l*A&Ze,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*f&Ce|o*m&Ze,o=o<<15|o>>>17,o=o*g&Ce|o*A&Ze,i&1?h^=o:c^=o}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Ce|t*36045&Ze,e=e*4283543511&Ce|((e<<16|t>>>16)*2950163797&Ce)>>>16,t^=e>>>1,t=t*444984403&Ce|t*60499&Ze,e=e*3301882366&Ce|((e<<16|t>>>16)*3120437893&Ce)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Af=Object.freeze({map:null,hash:"",transfer:void 0});var vn,_n,Tt,_d,Dg;class mp{constructor(){u(this,_d);u(this,vn,!1);u(this,_n,null);u(this,Tt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=n(this,Tt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,Tt).get(t)}remove(t){if(n(this,Tt).delete(t),n(this,Tt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of n(this,Tt).values())if(e instanceof ut)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=n(this,Tt).get(t);let i=!1;if(s!==void 0)for(const[r,a]of Object.entries(e))s[r]!==a&&(i=!0,s[r]=a);else i=!0,n(this,Tt).set(t,e);i&&b(this,_d,Dg).call(this),e instanceof ut&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return n(this,Tt).has(t)}getAll(){return n(this,Tt).size>0?cp(n(this,Tt)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return n(this,Tt).size}resetModified(){n(this,vn)&&(p(this,vn,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Fg(this)}get serializable(){if(n(this,Tt).size===0)return Af;const t=new Map,e=new Ig,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,Tt)){const l=o instanceof ut?o.serialize(!1,i):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Af}get editorStats(){var s;let t=null;const e=new Map;for(const i of n(this,Tt).values()){if(!(i instanceof ut))continue;const r=i.telemetryFinalData;if(!r)continue;const{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(i).constructor),t||(t=Object.create(null));const o=t[a]||(t[a]=new Map);for(const[l,h]of Object.entries(r)){if(l==="type")continue;let c=o.get(l);c||(c=new Map,o.set(l,c));const f=(s=c.get(h))!=null?s:0;c.set(h,f+1)}}for(const[i,r]of e)t[i]=r.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){p(this,_n,null)}get modifiedIds(){if(n(this,_n))return n(this,_n);const t=[];for(const e of n(this,Tt).values())!(e instanceof ut)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return p(this,_n,{ids:new Set(t),hash:t.join(",")})}}vn=new WeakMap,_n=new WeakMap,Tt=new WeakMap,_d=new WeakSet,Dg=function(){n(this,vn)||(p(this,vn,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Cl;class Fg extends mp{constructor(e){super();u(this,Cl,void 0);const{map:s,hash:i,transfer:r}=e.serializable,a=structuredClone(s,r?{transfer:r}:null);p(this,Cl,{map:a,hash:i,transfer:r})}get print(){st("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Cl)}get modifiedIds(){return X(this,"modifiedIds",{ids:new Set,hash:""})}}Cl=new WeakMap;var sa;class rA{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){u(this,sa,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(),n(this,sa).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(s){return I(this,arguments,function*({systemFontInfo:t,_inspectFont:e}){if(!(!t||n(this,sa).has(t.loadedName))){if(wt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=t,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{yield o.load(),n(this,sa).add(i),e==null||e(t)}catch(l){U(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}st("Not implemented: loadSystemFont without the Font Loading API.")}})}bind(t){return I(this,null,function*(){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){yield this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{yield s.loaded}catch(i){throw U(`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;yield 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 X(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(Xt||typeof navigator!="undefined"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),X(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(wt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.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 X(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,P,T){const k=S.substring(0,C),N=S.substring(C+P);return k+T+N}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let h=0;function c(S,C){if(++h>30){U("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(c.bind(null,S,C))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=i(g,976,f.length,f);const A=16,y=1482184792;let v=s(g,A);for(r=0,a=f.length-3;r<a;r+=4)v=v-y+s(f,r)|0;r<f.length&&(v=v-y+s(f+"XXX",r)|0),g=i(g,A,4,Ub(v));const w=`url(data:font/opentype;base64,${btoa(g)});`,_=`@font-face {font-family:"${f}";src:${w}}`;this.insertRule(_);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,f]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=S,E.append(C)}this._document.body.append(E),c(f,()=>{E.remove(),e.complete()})}}sa=new WeakMap;class aA{constructor(t,{disableFontFace:e=!1,fontExtraProperties:s=!1,inspectFont:i=null}){this.compiledGlyphs=Object.create(null);for(const r in t)this[r]=t[r];this.disableFontFace=e===!0,this.fontExtraProperties=s===!0,this._inspectFont=i}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,${Kb(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];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(a){U(`getPathGenerator - ignoring character: "${a}".`)}const r=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}}const tc={DATA:1,ERROR:2},yt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Np(){}function se(d){if(d instanceof $i||d instanceof Ku||d instanceof Fo||d instanceof Lp||d instanceof Fc||d instanceof Gu)return d;switch(d instanceof Error||typeof d=="object"&&d!==null||st('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),d.name){case"AbortException":return new $i(d.message);case"InvalidPDFException":return new Ku(d.message);case"MissingPDFException":return new Fo(d.message);case"PasswordException":return new Lp(d.message,d.code);case"UnexpectedResponseException":return new Fc(d.message,d.status);case"UnknownErrorException":return new Gu(d.message,d.details)}return new Gu(d.message,d.toString())}var ia,Sd,Ng,Ed,Og,Cd,Bg,na,fc;class _o{constructor(t,e,s){u(this,Sd);u(this,Ed);u(this,Cd);u(this,na);u(this,ia,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",b(this,Sd,Ng).bind(this),{signal:n(this,ia).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++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:yt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{wt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[r].cancelCall=c,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:yt.CANCEL,streamId:r,reason:se(h)}),c.promise}},s)}destroy(){var t;(t=n(this,ia))==null||t.abort(),p(this,ia,null)}}ia=new WeakMap,Sd=new WeakSet,Ng=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,Cd,Bg).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===tc.DATA)i.resolve(t.data);else if(t.callback===tc.ERROR)i.reject(se(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,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:tc.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:tc.ERROR,callbackId:t.callbackId,reason:se(a)})});return}if(t.streamId){b(this,Ed,Og).call(this,t);return}e(t.data)},Ed=new WeakSet,Og=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,c=1,f){if(this.isCancelled)return;const g=this.desiredSize;this.desiredSize-=c,g>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:yt.ENQUEUE,streamId:e,chunk:h},f)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:yt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){wt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:yt.ERROR,streamId:e,reason:se(h)}))},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,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:yt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:yt.START_COMPLETE,streamId:e,reason:se(h)})})},Cd=new WeakSet,Bg=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case yt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(se(t.reason));break;case yt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(se(t.reason));break;case yt.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Np).then(function(){r.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,reason:se(h)})});break;case yt.ENQUEUE:if(wt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case yt.CLOSE:if(wt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,na,fc).call(this,a,e);break;case yt.ERROR:wt(a,"error should have stream controller"),a.controller.error(se(t.reason)),b(this,na,fc).call(this,a,e);break;case yt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(se(t.reason)),b(this,na,fc).call(this,a,e);break;case yt.CANCEL:if(!o)break;const l=se(t.reason);Promise.try(o.onCancel||Np,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:yt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:yt.CANCEL_COMPLETE,streamId:e,reason:se(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},na=new WeakSet,fc=function(t,e){return I(this,null,function*(){var s,i,r;yield Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]})};var xl;class Hg{constructor({enableHWA:t=!1}){u(this,xl,!1);p(this,xl,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:!n(this,xl)})}}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){st("Abstract method `_createCanvas` called.")}}xl=new WeakMap;class oA extends Hg{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 zg{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}fetch(e){return I(this,arguments,function*({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 s=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(s).then(i=>({cMapData:i,isCompressed:this.isCompressed})).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${s}`)})})}_fetch(t){return I(this,null,function*(){st("Abstract method `_fetch` called.")})}}class $g extends zg{_fetch(t){return I(this,null,function*(){const e=yield Mu(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ku(e)})}}class Gg{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}destroy(t=!1){}}var Sn,ra,Ls,Is,Vt,En,Cn,Pt,zt,xn,So,mi,Sr,aa,pc,bi,Er,xd,Vg,Tl,yf,Ai,Cr,Tn,Eo,Pn,Co,Pl,wf,Rn,xo;class lA extends Gg{constructor({docId:e,ownerDocument:s=globalThis.document}){super();u(this,Pt);u(this,xn);u(this,mi);u(this,aa);u(this,bi);u(this,xd);u(this,Tl);u(this,Ai);u(this,Tn);u(this,Pn);u(this,Pl);u(this,Rn);u(this,Sn,void 0);u(this,ra,void 0);u(this,Ls,void 0);u(this,Is,void 0);u(this,Vt,void 0);u(this,En,void 0);u(this,Cn,0);p(this,Is,e),p(this,Vt,s)}addFilter(e){if(!e)return"none";let s=n(this,Pt,zt).get(e);if(s)return s;const[i,r,a]=b(this,aa,pc).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,Pt,zt).get(o),s)return n(this,Pt,zt).set(e,s),s;const l=`g_${n(this,Is)}_transfer_map_${qt(this,Cn)._++}`,h=b(this,bi,Er).call(this,l);n(this,Pt,zt).set(e,h),n(this,Pt,zt).set(o,h);const c=b(this,Ai,Cr).call(this,l);return b(this,Pn,Co).call(this,i,r,a,c),h}addHCMFilter(e,s){var A;const i=`${e}-${s}`,r="base";let a=n(this,xn,So).get(r);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},n(this,xn,So).set(r,a)),!e||!s))return a.url;const o=b(this,Rn,xo).call(this,e);e=F.makeHexColor(...o);const l=b(this,Rn,xo).call(this,s);if(s=F.makeHexColor(...l),n(this,mi,Sr).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let y=0;y<=255;y++){const v=y/255;h[y]=v<=.03928?v/12.92:uo((v+.055)/1.055,2.4)}const c=h.join(","),f=`g_${n(this,Is)}_hcm_filter`,g=a.filter=b(this,Ai,Cr).call(this,f);b(this,Pn,Co).call(this,c,c,c,g),b(this,Tl,yf).call(this,g);const m=(y,v)=>{const w=o[y]/255,_=l[y]/255,E=new Array(v+1);for(let S=0;S<=v;S++)E[S]=w+S/v*(_-w);return E.join(",")};return b(this,Pn,Co).call(this,m(0,5),m(1,5),m(2,5),g),a.url=b(this,bi,Er).call(this,f),a.url}addAlphaFilter(e){let s=n(this,Pt,zt).get(e);if(s)return s;const[i]=b(this,aa,pc).call(this,[e]),r=`alpha_${i}`;if(s=n(this,Pt,zt).get(r),s)return n(this,Pt,zt).set(e,s),s;const a=`g_${n(this,Is)}_alpha_map_${qt(this,Cn)._++}`,o=b(this,bi,Er).call(this,a);n(this,Pt,zt).set(e,o),n(this,Pt,zt).set(r,o);const l=b(this,Ai,Cr).call(this,a);return b(this,Pl,wf).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,Pt,zt).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=b(this,aa,pc).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,Pt,zt).get(r),s)return n(this,Pt,zt).set(e,s),s;const a=`g_${n(this,Is)}_luminosity_map_${qt(this,Cn)._++}`,o=b(this,bi,Er).call(this,a);n(this,Pt,zt).set(e,o),n(this,Pt,zt).set(r,o);const l=b(this,Ai,Cr).call(this,a);return b(this,xd,Vg).call(this,l),e&&b(this,Pl,wf).call(this,i,l),o}addHighlightHCMFilter(e,s,i,r,a){var _;const o=`${s}-${i}-${r}-${a}`;let l=n(this,xn,So).get(e);if((l==null?void 0:l.key)===o||(l?((_=l.filter)==null||_.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,xn,So).set(e,l)),!s||!i))return l.url;const[h,c]=[s,i].map(b(this,Rn,xo).bind(this));let f=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),g=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[m,A]=[r,a].map(b(this,Rn,xo).bind(this));g<f&&([f,g,m,A]=[g,f,A,m]),n(this,mi,Sr).style.color="";const y=(E,S,C)=>{const P=new Array(256),T=(g-f)/C,k=E/255,N=(S-E)/(255*C);let $=0;for(let B=0;B<=C;B++){const it=Math.round(f+B*T),nt=k+B*N;for(let K=$;K<=it;K++)P[K]=nt;$=it+1}for(let B=$;B<256;B++)P[B]=P[$-1];return P.join(",")},v=`g_${n(this,Is)}_hcm_${e}_filter`,w=l.filter=b(this,Ai,Cr).call(this,v);return b(this,Tl,yf).call(this,w),b(this,Pn,Co).call(this,y(m[0],A[0],5),y(m[1],A[1],5),y(m[2],A[2],5),w),l.url=b(this,bi,Er).call(this,v),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,En))!=null&&s.size)||((i=n(this,Ls))==null||i.parentNode.parentNode.remove(),p(this,Ls,null),(r=n(this,ra))==null||r.clear(),p(this,ra,null),(a=n(this,En))==null||a.clear(),p(this,En,null),p(this,Cn,0))}}Sn=new WeakMap,ra=new WeakMap,Ls=new WeakMap,Is=new WeakMap,Vt=new WeakMap,En=new WeakMap,Cn=new WeakMap,Pt=new WeakSet,zt=function(){return n(this,ra)||p(this,ra,new Map)},xn=new WeakSet,So=function(){return n(this,En)||p(this,En,new Map)},mi=new WeakSet,Sr=function(){if(!n(this,Ls)){const e=n(this,Vt).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=n(this,Vt).createElementNS(ws,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Ls,n(this,Vt).createElementNS(ws,"defs")),e.append(i),i.append(n(this,Ls)),n(this,Vt).body.append(e)}return n(this,Ls)},aa=new WeakSet,pc=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let g=0;g<256;g++)c[g]=h[g]/255;const f=c.join(",");return[f,f,f]}const[s,i,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=i[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},bi=new WeakSet,Er=function(e){if(n(this,Sn)===void 0){p(this,Sn,"");const s=n(this,Vt).URL;s!==n(this,Vt).baseURI&&(Lu(s)?U('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,Sn,s.split("#",1)[0]))}return`url(${n(this,Sn)}#${e})`},xd=new WeakSet,Vg=function(e){const s=n(this,Vt).createElementNS(ws,"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)},Tl=new WeakSet,yf=function(e){const s=n(this,Vt).createElementNS(ws,"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)},Ai=new WeakSet,Cr=function(e){const s=n(this,Vt).createElementNS(ws,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,mi,Sr).append(s),s},Tn=new WeakSet,Eo=function(e,s,i){const r=n(this,Vt).createElementNS(ws,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},Pn=new WeakSet,Co=function(e,s,i,r){const a=n(this,Vt).createElementNS(ws,"feComponentTransfer");r.append(a),b(this,Tn,Eo).call(this,a,"feFuncR",e),b(this,Tn,Eo).call(this,a,"feFuncG",s),b(this,Tn,Eo).call(this,a,"feFuncB",i)},Pl=new WeakSet,wf=function(e,s){const i=n(this,Vt).createElementNS(ws,"feComponentTransfer");s.append(i),b(this,Tn,Eo).call(this,i,"feFuncA",e)},Rn=new WeakSet,xo=function(e){return n(this,mi,Sr).style.color=e,gp(getComputedStyle(n(this,mi,Sr)).getPropertyValue("color"))};class Ug{constructor({baseUrl:t=null}){this.baseUrl=t}fetch(e){return I(this,arguments,function*({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 s=`${this.baseUrl}${t}`;return this._fetch(s).catch(i=>{throw new Error(`Unable to load font data at: ${s}`)})})}_fetch(t){return I(this,null,function*(){st("Abstract method `_fetch` called.")})}}class jg extends Ug{_fetch(t){return I(this,null,function*(){const e=yield Mu(t,"arraybuffer");return new Uint8Array(e)})}}Xt&&U("Please use the `legacy` build in Node.js environments.");function Wg(d){return I(this,null,function*(){const e=yield process.getBuiltinModule("fs").promises.readFile(d);return new Uint8Array(e)})}class hA extends Gg{}class cA extends Hg{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class dA extends zg{_fetch(t){return I(this,null,function*(){return Wg(t)})}}class uA extends Ug{_fetch(t){return I(this,null,function*(){return Wg(t)})}}const Wt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function vf(d,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),d.clip(i)}class bp{getPattern(){st("Abstract method `getPattern` called.")}}class fA extends bp{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 r;if(i===Wt.STROKE||i===Wt.FILL){const a=e.current.getClippedPathBoundingBox(i,lt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=e.cachedCanvases.getCanvas("pattern",o,l),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-a[0],-a[1]),s=F.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),vf(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat");const f=new DOMMatrix(s);r.setTransform(f)}else vf(t,this._bbox),r=this._createGradient(t);return r}}function ju(d,t,e,s,i,r,a,o){const l=t.coords,h=t.colors,c=d.data,f=d.width*4;let g;l[e+1]>l[s+1]&&(g=e,e=s,s=g,g=r,r=a,a=g),l[s+1]>l[i+1]&&(g=s,s=i,i=g,g=a,a=o,o=g),l[e+1]>l[s+1]&&(g=e,e=s,s=g,g=r,r=a,a=g);const m=(l[e]+t.offsetX)*t.scaleX,A=(l[e+1]+t.offsetY)*t.scaleY,y=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY,w=(l[i]+t.offsetX)*t.scaleX,_=(l[i+1]+t.offsetY)*t.scaleY;if(A>=_)return;const E=h[r],S=h[r+1],C=h[r+2],P=h[a],T=h[a+1],k=h[a+2],N=h[o],$=h[o+1],B=h[o+2],it=Math.round(A),nt=Math.round(_);let K,Et,x,R,G,J,H,Bt;for(let rt=it;rt<=nt;rt++){if(rt<v){const Q=rt<A?0:(A-rt)/(A-v);K=m-(m-y)*Q,Et=E-(E-P)*Q,x=S-(S-T)*Q,R=C-(C-k)*Q}else{let Q;rt>_?Q=1:v===_?Q=0:Q=(v-rt)/(v-_),K=y-(y-w)*Q,Et=P-(P-N)*Q,x=T-(T-$)*Q,R=k-(k-B)*Q}let ft;rt<A?ft=0:rt>_?ft=1:ft=(A-rt)/(A-_),G=m-(m-w)*ft,J=E-(E-N)*ft,H=S-(S-$)*ft,Bt=C-(C-B)*ft;const Qe=Math.round(Math.min(K,G)),Ee=Math.round(Math.max(K,G));let ht=f*rt+Qe*4;for(let Q=Qe;Q<=Ee;Q++)ft=(K-Q)/(K-G),ft<0?ft=0:ft>1&&(ft=1),c[ht++]=Et-(Et-J)*ft|0,c[ht++]=x-(x-H)*ft|0,c[ht++]=R-(R-Bt)*ft|0,c[ht++]=255}}function pA(d,t,e){const s=t.coords,i=t.colors;let r,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let c=r*o;for(let f=0;f<h;f++,c++)ju(d,e,s[c],s[c+1],s[c+o],i[c],i[c+1],i[c+o]),ju(d,e,s[c+o+1],s[c+1],s[c+o],i[c+o+1],i[c+1],i[c+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)ju(d,e,s[r],s[r+1],s[r+2],i[r],i[r+1],i[r+2]);break;default:throw new Error("illegal figure")}}class gA extends bp{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]),h=Math.ceil(this._bounds[2])-o,c=Math.ceil(this._bounds[3])-l,f=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),g=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),m=h/f,A=c/g,y={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/m,scaleY:1/A},v=f+2*2,w=g+2*2,_=s.getCanvas("mesh",v,w),E=_.context,S=E.createImageData(f,g);if(e){const P=S.data;for(let T=0,k=P.length;T<k;T+=4)P[T]=e[0],P[T+1]=e[1],P[T+2]=e[2],P[T+3]=255}for(const P of this._figures)pA(S,P,y);return E.putImageData(S,2,2),{canvas:_.canvas,offsetX:o-2*m,offsetY:l-2*A,scaleX:m,scaleY:A}}getPattern(t,e,s,i){vf(t,this._bbox);let r;if(i===Wt.SHADING)r=F.singularValueDecompose2dScale(lt(t));else if(r=F.singularValueDecompose2dScale(e.baseTransform),this.matrix){const o=F.singularValueDecompose2dScale(this.matrix);r=[r[0]*o[0],r[1]*o[1]]}const a=this._createMeshCanvas(r,i===Wt.SHADING?null:this._background,e.cachedCanvases);return i!==Wt.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 mA extends bp{getPattern(){return"hotpink"}}function bA(d){switch(d[0]){case"RadialAxial":return new fA(d);case"Mesh":return new gA(d);case"Dummy":return new mA}throw new Error(`Unknown IR type: ${d[0]}`)}const Op={COLORED:1,UNCOLORED:2},Td=class Td{constructor(t,e,s,i,r){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=r}createPatternCanvas(t){const{bbox:e,operatorList:s,paintType:i,tilingType:r,color:a,canvasGraphicsFactory:o}=this;let{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),Ru("TilingType: "+r);const c=e[0],f=e[1],g=e[2],m=e[3],A=g-c,y=m-f,v=F.singularValueDecompose2dScale(this.matrix),w=F.singularValueDecompose2dScale(this.baseTransform),_=v[0]*w[0],E=v[1]*w[1];let S=A,C=y,P=!1,T=!1;const k=Math.ceil(l*_),N=Math.ceil(h*E),$=Math.ceil(A*_),B=Math.ceil(y*E);k>=$?S=l:P=!0,N>=B?C=h:T=!0;const it=this.getSizeAndScale(S,this.ctx.canvas.width,_),nt=this.getSizeAndScale(C,this.ctx.canvas.height,E),K=t.cachedCanvases.getCanvas("pattern",it.size,nt.size),Et=K.context,x=o.createCanvasGraphics(Et);if(x.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(x,i,a),Et.translate(-it.scale*c,-nt.scale*f),x.transform(it.scale,0,0,nt.scale,0,0),Et.save(),this.clipBbox(x,c,f,g,m),x.baseTransform=lt(x.ctx),x.executeOperatorList(s),x.endDrawing(),Et.restore(),P||T){const R=K.canvas;P&&(S=l),T&&(C=h);const G=this.getSizeAndScale(S,this.ctx.canvas.width,_),J=this.getSizeAndScale(C,this.ctx.canvas.height,E),H=G.size,Bt=J.size,rt=t.cachedCanvases.getCanvas("pattern-workaround",H,Bt),ft=rt.context,Qe=P?Math.floor(A/l):0,Ee=T?Math.floor(y/h):0;for(let ht=0;ht<=Qe;ht++)for(let Q=0;Q<=Ee;Q++)ft.drawImage(R,H*ht,Bt*Q,H,Bt,0,0,H,Bt);return{canvas:rt.canvas,scaleX:G.scale,scaleY:J.scale,offsetX:c,offsetY:f}}return{canvas:K.canvas,scaleX:it.scale,scaleY:nt.scale,offsetX:c,offsetY:f}}getSizeAndScale(t,e,s){const i=Math.max(Td.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const a=i-e,o=r-s;t.ctx.rect(e,s,a,o),t.current.updateRectMinMax(lt(t.ctx),[e,s,i,r]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,r=t.current;switch(e){case Op.COLORED:const a=this.ctx;i.fillStyle=a.fillStyle,i.strokeStyle=a.strokeStyle,r.fillColor=a.fillStyle,r.strokeColor=a.strokeStyle;break;case Op.UNCOLORED:const o=F.makeHexColor(s[0],s[1],s[2]);i.fillStyle=o,i.strokeStyle=o,r.fillColor=o,r.strokeColor=o;break;default:throw new Vb(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let r=s;i!==Wt.SHADING&&(r=F.transform(r,e.baseTransform),this.matrix&&(r=F.transform(r,this.matrix)));const a=this.createPatternCanvas(e);let o=new DOMMatrix(r);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}};O(Td,"MAX_PATTERN_SIZE",3e3);let _f=Td;function AA({src:d,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=te.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,f=s&7,g=d.length;e=new Uint32Array(e.buffer);let m=0;for(let A=0;A<i;A++){for(const v=t+c;t<v;t++){const w=t<g?d[t]:255;e[m++]=w&128?h:l,e[m++]=w&64?h:l,e[m++]=w&32?h:l,e[m++]=w&16?h:l,e[m++]=w&8?h:l,e[m++]=w&4?h:l,e[m++]=w&2?h:l,e[m++]=w&1?h:l}if(f===0)continue;const y=t<g?d[t++]:255;for(let v=0;v<f;v++)e[m++]=y&1<<7-v?h:l}return{srcPos:t,destPos:m}}const Bp=16,Hp=100,yA=15,zp=10,$p=1e3,le=16;function wA(d,t){if(d._removeMirroring)throw new Error("Context is already forwarding operations.");d.__originalSave=d.save,d.__originalRestore=d.restore,d.__originalRotate=d.rotate,d.__originalScale=d.scale,d.__originalTranslate=d.translate,d.__originalTransform=d.transform,d.__originalSetTransform=d.setTransform,d.__originalResetTransform=d.resetTransform,d.__originalClip=d.clip,d.__originalMoveTo=d.moveTo,d.__originalLineTo=d.lineTo,d.__originalBezierCurveTo=d.bezierCurveTo,d.__originalRect=d.rect,d.__originalClosePath=d.closePath,d.__originalBeginPath=d.beginPath,d._removeMirroring=()=>{d.save=d.__originalSave,d.restore=d.__originalRestore,d.rotate=d.__originalRotate,d.scale=d.__originalScale,d.translate=d.__originalTranslate,d.transform=d.__originalTransform,d.setTransform=d.__originalSetTransform,d.resetTransform=d.__originalResetTransform,d.clip=d.__originalClip,d.moveTo=d.__originalMoveTo,d.lineTo=d.__originalLineTo,d.bezierCurveTo=d.__originalBezierCurveTo,d.rect=d.__originalRect,d.closePath=d.__originalClosePath,d.beginPath=d.__originalBeginPath,delete d._removeMirroring},d.save=function(){t.save(),this.__originalSave()},d.restore=function(){t.restore(),this.__originalRestore()},d.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},d.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},d.transform=function(s,i,r,a,o,l){t.transform(s,i,r,a,o,l),this.__originalTransform(s,i,r,a,o,l)},d.setTransform=function(s,i,r,a,o,l){t.setTransform(s,i,r,a,o,l),this.__originalSetTransform(s,i,r,a,o,l)},d.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},d.rotate=function(s){t.rotate(s),this.__originalRotate(s)},d.clip=function(s){t.clip(s),this.__originalClip(s)},d.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},d.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},d.bezierCurveTo=function(e,s,i,r,a,o){t.bezierCurveTo(e,s,i,r,a,o),this.__originalBezierCurveTo(e,s,i,r,a,o)},d.rect=function(e,s,i,r){t.rect(e,s,i,r),this.__originalRect(e,s,i,r)},d.closePath=function(){t.closePath(),this.__originalClosePath()},d.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class vA{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 ec(d,t,e,s,i,r,a,o,l,h){const[c,f,g,m,A,y]=lt(d);if(f===0&&g===0){const _=a*c+A,E=Math.round(_),S=o*m+y,C=Math.round(S),P=(a+l)*c+A,T=Math.abs(Math.round(P)-E)||1,k=(o+h)*m+y,N=Math.abs(Math.round(k)-C)||1;return d.setTransform(Math.sign(c),0,0,Math.sign(m),E,C),d.drawImage(t,e,s,i,r,0,0,T,N),d.setTransform(c,f,g,m,A,y),[T,N]}if(c===0&&m===0){const _=o*g+A,E=Math.round(_),S=a*f+y,C=Math.round(S),P=(o+h)*g+A,T=Math.abs(Math.round(P)-E)||1,k=(a+l)*f+y,N=Math.abs(Math.round(k)-C)||1;return d.setTransform(0,Math.sign(f),Math.sign(g),0,E,C),d.drawImage(t,e,s,i,r,0,0,N,T),d.setTransform(c,f,g,m,A,y),[N,T]}d.drawImage(t,e,s,i,r,a,o,l,h);const v=Math.hypot(c,f),w=Math.hypot(g,m);return[v*l,w*h]}function _A(d){const{width:t,height:e}=d;if(t>$p||e>$p)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),r=t+1;let a=new Uint8Array(r*(e+1)),o,l,h;const c=t+7&-8;let f=new Uint8Array(c*e),g=0;for(const w of d.data){let _=128;for(;_>0;)f[g++]=w&_?0:255,_>>=1}let m=0;for(g=0,f[g]!==0&&(a[0]=1,++m),l=1;l<t;l++)f[g]!==f[g+1]&&(a[l]=f[g]?2:1,++m),g++;for(f[g]!==0&&(a[l]=2,++m),o=1;o<e;o++){g=o*c,h=o*r,f[g-c]!==f[g]&&(a[h]=f[g]?1:8,++m);let w=(f[g]?4:0)+(f[g-c]?8:0);for(l=1;l<t;l++)w=(w>>2)+(f[g+1]?4:0)+(f[g-c+1]?8:0),i[w]&&(a[h+l]=i[w],++m),g++;if(f[g-c]!==f[g]&&(a[h+l]=f[g]?2:4,++m),m>s)return null}for(g=c*(e-1),h=o*r,f[g]!==0&&(a[h]=8,++m),l=1;l<t;l++)f[g]!==f[g+1]&&(a[h+l]=f[g]?4:8,++m),g++;if(f[g]!==0&&(a[h+l]=4,++m),m>s)return null;const A=new Int32Array([0,r,-1,0,-r,0,0,0,1]),y=new Path2D;for(o=0;m&&o<=e;o++){let w=o*r;const _=w+t;for(;w<_&&!a[w];)w++;if(w===_)continue;y.moveTo(w%r,o);const E=w;let S=a[w];do{const C=A[S];do w+=C;while(!a[w]);const P=a[w];P!==5&&P!==10?(S=P,a[w]=0):(S=P&51*S>>4,a[w]&=S>>2|S<<2),y.lineTo(w%r,w/r|0),a[w]||--m}while(E!==w);--o}return f=null,a=null,function(w){w.save(),w.scale(1/t,-1/e),w.translate(0,-e),w.fill(y),w.beginPath(),w.restore()}}class Gp{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=sg,this.textMatrixScale=1,this.fontMatrix=Yu,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=Ht.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){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]=F.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=F.applyTransform(e,t),i=F.applyTransform(e.slice(2),t),r=F.applyTransform([e[0],e[3]],t),a=F.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],r[0],a[0]),this.minY=Math.min(this.minY,s[1],i[1],r[1],a[1]),this.maxX=Math.max(this.maxX,s[0],i[0],r[0],a[0]),this.maxY=Math.max(this.maxY,s[1],i[1],r[1],a[1])}updateScalingPathMinMax(t,e){F.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,r,a,o,l,h,c){const f=F.bezierBoundingBox(e,s,i,r,a,o,l,h,c);c||this.updateRectMinMax(t,f)}getPathBoundingBox(t=Wt.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Wt.STROKE){e||st("Stroke bounding box must include transform.");const i=F.singularValueDecompose2dScale(e),r=i[0]*this.lineWidth/2,a=i[1]*this.lineWidth/2;s[0]-=r,s[1]-=a,s[2]+=r,s[3]+=a}return s}updateClipFromPath(){const t=F.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=Wt.FILL,e=null){return F.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Vp(d,t){if(t instanceof ImageData){d.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%le,r=(e-i)/le,a=i===0?r:r+1,o=d.createImageData(s,le);let l=0,h;const c=t.data,f=o.data;let g,m,A,y;if(t.kind===nc.GRAYSCALE_1BPP){const v=c.byteLength,w=new Uint32Array(f.buffer,0,f.byteLength>>2),_=w.length,E=s+7>>3,S=4294967295,C=te.isLittleEndian?4278190080:255;for(g=0;g<a;g++){for(A=g<r?le:i,h=0,m=0;m<A;m++){const P=v-l;let T=0;const k=P>E?s:P*8-7,N=k&-8;let $=0,B=0;for(;T<N;T+=8)B=c[l++],w[h++]=B&128?S:C,w[h++]=B&64?S:C,w[h++]=B&32?S:C,w[h++]=B&16?S:C,w[h++]=B&8?S:C,w[h++]=B&4?S:C,w[h++]=B&2?S:C,w[h++]=B&1?S:C;for(;T<k;T++)$===0&&(B=c[l++],$=128),w[h++]=B&$?S:C,$>>=1}for(;h<_;)w[h++]=0;d.putImageData(o,0,g*le)}}else if(t.kind===nc.RGBA_32BPP){for(m=0,y=s*le*4,g=0;g<r;g++)f.set(c.subarray(l,l+y)),l+=y,d.putImageData(o,0,m),m+=le;g<a&&(y=s*i*4,f.set(c.subarray(l,l+y)),d.putImageData(o,0,m))}else if(t.kind===nc.RGB_24BPP)for(A=le,y=s*A,g=0;g<a;g++){for(g>=r&&(A=i,y=s*A),h=0,m=y;m--;)f[h++]=c[l++],f[h++]=c[l++],f[h++]=c[l++],f[h++]=255;d.putImageData(o,0,g*le)}else throw new Error(`bad image kind: ${t.kind}`)}function Up(d,t){if(t.bitmap){d.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%le,r=(e-i)/le,a=i===0?r:r+1,o=d.createImageData(s,le);let l=0;const h=t.data,c=o.data;for(let f=0;f<a;f++){const g=f<r?le:i;({srcPos:l}=AA({src:h,srcPos:l,dest:c,width:s,height:g,nonBlackColor:0})),d.putImageData(o,0,f*le)}}function po(d,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)d[s]!==void 0&&(t[s]=d[s]);d.setLineDash!==void 0&&(t.setLineDash(d.getLineDash()),t.lineDashOffset=d.lineDashOffset)}function sc(d){if(d.strokeStyle=d.fillStyle="#000000",d.fillRule="nonzero",d.globalAlpha=1,d.lineWidth=1,d.lineCap="butt",d.lineJoin="miter",d.miterLimit=10,d.globalCompositeOperation="source-over",d.font="10px sans-serif",d.setLineDash!==void 0&&(d.setLineDash([]),d.lineDashOffset=0),!Xt){const{filter:t}=d;t!=="none"&&t!==""&&(d.filter="none")}}function jp(d,t){if(t)return!0;const e=F.singularValueDecompose2dScale(d);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Gi.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const SA=["butt","round","square"],EA=["miter","round","bevel"],CA={},Wp={};var Rl,Sf,kl,Ef,Ml,Cf;const _p=class _p{constructor(t,e,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,h){u(this,Rl);u(this,kl);u(this,Ml);this.ctx=t,this.current=new Gp(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=r,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 vA(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.cachedCanvases.getCanvas("transparent",r,a);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...lt(this.compositeCtx))}this.ctx.save(),sc(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=lt(this.ctx)}executeOperatorList(t,e,s,i){const r=t.argsArray,a=t.fnArray;let o=e||0;const l=r.length;if(l===o)return o;const h=l-o>zp&&typeof s=="function",c=h?Date.now()+yA:0;let f=0;const g=this.commonObjs,m=this.objs;let A;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(A=a[o],A!==Fe.dependency)this[A].apply(this,r[o]);else for(const y of r[o]){const v=y.startsWith("g_")?g:m;if(!v.has(y))return v.get(y,s),o}if(o++,o===l)return o;if(h&&++f>zp){if(Date.now()>c)return s(),o;f=0}}}endDrawing(){b(this,Rl,Sf).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),b(this,kl,Ef).call(this)}_scaleImage(t,e){var g,m;const s=(g=t.width)!=null?g:t.displayWidth,i=(m=t.height)!=null?m:t.displayHeight;let r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=s,l=i,h="prescale1",c,f;for(;r>2&&o>1||a>2&&l>1;){let A=o,y=l;r>2&&o>1&&(A=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),r/=o/A),a>2&&l>1&&(y=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/y),c=this.cachedCanvases.getCanvas(h,A,y),f=c.context,f.clearRect(0,0,A,y),f.drawImage(t,0,0,o,l,0,0,A,y),t=c.canvas,o=A,l=y,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,r=this.current.fillColor,a=this.current.patternFill,o=lt(e);let l,h,c,f;if((t.bitmap||t.data)&&t.count>1){const k=t.bitmap||t.data.buffer;h=JSON.stringify(a?o:[o.slice(0,4),r]),l=this._cachedBitmapsMap.get(k),l||(l=new Map,this._cachedBitmapsMap.set(k,l));const N=l.get(h);if(N&&!a){const $=Math.round(Math.min(o[0],o[2])+o[4]),B=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:N,offsetX:$,offsetY:B}}c=N}c||(f=this.cachedCanvases.getCanvas("maskCanvas",s,i),Up(f.context,t));let g=F.transform(o,[1/s,0,0,-1/i,0,0]);g=F.transform(g,[1,0,0,1,0,-i]);const[m,A,y,v]=F.getAxialAlignedBoundingBox([0,0,s,i],g),w=Math.round(y-m)||1,_=Math.round(v-A)||1,E=this.cachedCanvases.getCanvas("fillCanvas",w,_),S=E.context,C=m,P=A;S.translate(-C,-P),S.transform(...g),c||(c=this._scaleImage(f.canvas,Je(S)),c=c.img,l&&a&&l.set(h,c)),S.imageSmoothingEnabled=jp(lt(S),t.interpolate),ec(S,c,0,0,c.width,c.height,0,0,s,i),S.globalCompositeOperation="source-in";const T=F.transform(Je(S),[1,0,0,1,-C,-P]);return S.fillStyle=a?r.getPattern(e,this,T,Wt.FILL):r,S.fillRect(0,0,s,i),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(h,E.canvas)),{canvas:E.canvas,offsetX:Math.round(C),offsetY:Math.round(P)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=SA[t]}setLineJoin(t){this.ctx.lineJoin=EA[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 r=this.ctx;r.setTransform(...lt(this.suspendedCtx)),po(this.suspendedCtx,r),wA(r,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(),po(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 r=i[0],a=i[1],o=i[2]-r,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,r,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,r,a,o,l,h,c,f){let g=t.canvas,m=l-c,A=h-f;if(a){const v=F.makeHexColor(...a);if(m<0||A<0||m+s>g.width||A+i>g.height){const w=this.cachedCanvases.getCanvas("maskExtension",s,i),_=w.context;_.drawImage(g,-m,-A),_.globalCompositeOperation="destination-atop",_.fillStyle=v,_.fillRect(0,0,s,i),_.globalCompositeOperation="source-over",g=w.canvas,m=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const w=new Path2D;w.rect(m,A,s,i),t.clip(w),t.globalCompositeOperation="destination-atop",t.fillStyle=v,t.fillRect(m,A,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),r==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):r==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const y=new Path2D;y.rect(l,h,s,i),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(g,m,A,s,i,l,h,s,i),e.restore()}save(){this.inSMaskMode?(po(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(),po(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,r,a){this.ctx.transform(t,e,s,i,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,r=this.current;let a=r.x,o=r.y,l,h;const c=lt(i),f=c[0]===0&&c[3]===0||c[1]===0&&c[2]===0,g=f?s.slice(0):null;for(let m=0,A=0,y=t.length;m<y;m++)switch(t[m]|0){case Fe.rectangle:a=e[A++],o=e[A++];const v=e[A++],w=e[A++],_=a+v,E=o+w;i.moveTo(a,o),v===0||w===0?i.lineTo(_,E):(i.lineTo(_,o),i.lineTo(_,E),i.lineTo(a,E)),f||r.updateRectMinMax(c,[a,o,_,E]),i.closePath();break;case Fe.moveTo:a=e[A++],o=e[A++],i.moveTo(a,o),f||r.updatePathMinMax(c,a,o);break;case Fe.lineTo:a=e[A++],o=e[A++],i.lineTo(a,o),f||r.updatePathMinMax(c,a,o);break;case Fe.curveTo:l=a,h=o,a=e[A+4],o=e[A+5],i.bezierCurveTo(e[A],e[A+1],e[A+2],e[A+3],a,o),r.updateCurvePathMinMax(c,l,h,e[A],e[A+1],e[A+2],e[A+3],a,o,g),A+=6;break;case Fe.curveTo2:l=a,h=o,i.bezierCurveTo(a,o,e[A],e[A+1],e[A+2],e[A+3]),r.updateCurvePathMinMax(c,l,h,a,o,e[A],e[A+1],e[A+2],e[A+3],g),a=e[A+2],o=e[A+3],A+=4;break;case Fe.curveTo3:l=a,h=o,a=e[A+2],o=e[A+3],i.bezierCurveTo(e[A],e[A+1],a,o,a,o),r.updateCurvePathMinMax(c,l,h,e[A],e[A+1],a,o,a,o,g),A+=4;break;case Fe.closePath:i.closePath();break}f&&r.updateScalingPathMinMax(c,g),r.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,Je(e),Wt.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 r=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,Je(e),Wt.FILL),r=!0);const a=this.current.getClippedPathBoundingBox();this.contentVisible&&a!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),r&&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=CA}eoClip(){this.pendingClip=Wp}beginText(){this.current.textMatrix=sg,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}const s=new Path2D,i=e.getTransform().invertSelf();for(const{transform:r,x:a,y:o,fontSize:l,path:h}of t)s.addPath(h,new DOMMatrix(r).preMultiplySelf(i).translate(a,o).scale(l,-l));e.clip(s),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var c;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||Yu,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&U("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 r=s.loadedName||"sans-serif",a=((c=s.systemFontInfo)==null?void 0:c.css)||`"${r}", ${s.fallbackName}`;let o="normal";s.black?o="900":s.bold&&(o="bold");const l=s.italic?"italic":"normal";let h=e;e<Bp?h=Bp:e>Hp&&(h=Hp),this.current.fontSizeScale=e/h,this.ctx.font=`${l} ${o} ${h}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,r,a){this.current.textMatrix=[t,e,s,i,r,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,r){const a=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,f=h&Ht.FILL_STROKE_MASK,g=!!(h&Ht.ADD_TO_PATH_FLAG),m=o.patternFill&&!l.missingFile,A=o.patternStroke&&!l.missingFile;let y;if((l.disableFontFace||g||m||A)&&(y=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||m||A){if(a.save(),a.translate(e,s),a.scale(c,-c),f===Ht.FILL||f===Ht.FILL_STROKE)if(i){const v=a.getTransform();a.setTransform(...i),a.fill(b(this,Ml,Cf).call(this,y,v,i))}else a.fill(y);if(f===Ht.STROKE||f===Ht.FILL_STROKE)if(r){const v=a.getTransform();a.setTransform(...r),a.stroke(b(this,Ml,Cf).call(this,y,v,r))}else a.lineWidth/=c,a.stroke(y);a.restore()}else(f===Ht.FILL||f===Ht.FILL_STROKE)&&a.fillText(t,e,s),(f===Ht.STROKE||f===Ht.FILL_STROKE)&&a.strokeText(t,e,s);g&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:lt(a),x:e,y:s,fontSize:c,path:y})}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 X(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 r=this.ctx,a=e.fontSizeScale,o=e.charSpacing,l=e.wordSpacing,h=e.fontDirection,c=e.textHScale*h,f=t.length,g=s.vertical,m=g?1:-1,A=s.defaultVMetrics,y=i*e.fontMatrix[0],v=e.textRenderingMode===Ht.FILL&&!s.disableFontFace&&!e.patternFill;r.save(),r.transform(...e.textMatrix),r.translate(e.x,e.y+e.textRise),h>0?r.scale(c,-1):r.scale(c,1);let w,_;if(e.patternFill){r.save();const T=e.fillColor.getPattern(r,this,Je(r),Wt.FILL);w=lt(r),r.restore(),r.fillStyle=T}if(e.patternStroke){r.save();const T=e.strokeColor.getPattern(r,this,Je(r),Wt.STROKE);_=lt(r),r.restore(),r.strokeStyle=T}let E=e.lineWidth;const S=e.textMatrixScale;if(S===0||E===0){const T=e.textRenderingMode&Ht.FILL_STROKE_MASK;(T===Ht.STROKE||T===Ht.FILL_STROKE)&&(E=this.getSinglePixelWidth())}else E/=S;if(a!==1&&(r.scale(a,a),E/=a),r.lineWidth=E,s.isInvalidPDFjsFont){const T=[];let k=0;for(const N of t)T.push(N.unicode),k+=N.width;r.fillText(T.join(""),0,0),e.x+=k*y*c,r.restore(),this.compose();return}let C=0,P;for(P=0;P<f;++P){const T=t[P];if(typeof T=="number"){C+=m*T*i/1e3;continue}let k=!1;const N=(T.isSpace?l:0)+o,$=T.fontChar,B=T.accent;let it,nt,K=T.width;if(g){const x=T.vmetric||A,R=-(T.vmetric?x[1]:K*.5)*y,G=x[2]*y;K=x?-x[0]:K,it=R/a,nt=(C+G)/a}else it=C/a,nt=0;if(s.remeasure&&K>0){const x=r.measureText($).width*1e3/i*a;if(K<x&&this.isFontSubpixelAAEnabled){const R=K/x;k=!0,r.save(),r.scale(R,1),it/=R}else K!==x&&(it+=(K-x)/2e3*i/a)}if(this.contentVisible&&(T.isInFont||s.missingFile)){if(v&&!B)r.fillText($,it,nt);else if(this.paintChar($,it,nt,w,_),B){const x=it+i*B.offset.x/a,R=nt-i*B.offset.y/a;this.paintChar(B.fontChar,x,R,w,_)}}const Et=g?K*y-N*h:K*y+N*h;C+=Et,k&&r.restore()}g?e.y-=C:e.x+=C*c,r.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,r=s.fontSize,a=s.fontDirection,o=i.vertical?1:-1,l=s.charSpacing,h=s.wordSpacing,c=s.textHScale*a,f=s.fontMatrix||Yu,g=t.length,m=s.textRenderingMode===Ht.INVISIBLE;let A,y,v,w;if(!(m||r===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(c,a),A=0;A<g;++A){if(y=t[A],typeof y=="number"){w=o*y*r/1e3,this.ctx.translate(w,0),s.x+=w*c;continue}const _=(y.isSpace?h:0)+l,E=i.charProcOperatorList[y.operatorListId];if(!E){U(`Type3 character "${y.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=y,this.save(),e.scale(r,r),e.transform(...f),this.executeOperatorList(E),this.restore()),v=F.applyTransform([y.width,0],f)[0]*r+_,e.translate(v,0),s.x+=v*c}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,r,a){this.ctx.rect(s,i,r-s,a-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||lt(this.ctx),r={createCanvasGraphics:a=>new _p(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new _f(t,s,this.ctx,r,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=F.makeHexColor(t,e,s),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=F.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=bA(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,Je(e),Wt.SHADING);const i=Je(e);if(i){const{width:r,height:a}=e.canvas,[o,l,h,c]=F.getAxialAlignedBoundingBox([0,0,r,a],i);this.ctx.fillRect(o,l,h-o,c-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){st("Should not call beginInlineImage")}beginImageData(){st("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=lt(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(lt(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||Ru("TODO: Support non-isolated groups."),t.knockout&&U("Knockout groups not supported.");const s=lt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=F.getAxialAlignedBoundingBox(t.bbox,lt(e));const r=[0,0,e.canvas.width,e.canvas.height];i=F.intersect(i,r)||[0,0,0,0];const a=Math.floor(i[0]),o=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-a,1),h=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const f=this.cachedCanvases.getCanvas(c,l,h),g=f.context;g.translate(-a,-o),g.transform(...s),t.smask?this.smaskStack.push({canvas:f.canvas,context:g,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()),po(e,g),this.ctx=g,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=lt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const r=F.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(r)}}beginAnnotation(t,e,s,i,r){if(b(this,Rl,Sf).call(this),sc(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(r&&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,h]=F.singularValueDecompose2dScale(lt(this.ctx)),{viewportScale:c}=this,f=Math.ceil(a*this.outputScaleX*c),g=Math.ceil(o*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(f,g);const{canvas:m,context:A}=this.annotationCanvas;this.annotationCanvasMap.set(t,m),this.annotationCanvas.savedCtx=this.ctx,this.ctx=A,this.ctx.save(),this.ctx.setTransform(l,0,0,-h,0,o*h),sc(this.ctx)}else sc(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new Gp(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),b(this,kl,Ef).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=_A(t)),i.compiled)){i.compiled(s);return}const r=this._createMaskCanvas(t),a=r.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,r.offsetX,r.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,r,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const l=lt(o);o.transform(e,s,i,r,0,0);const h=this._createMaskCanvas(t);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]);for(let c=0,f=a.length;c<f;c+=2){const g=F.transform(l,[e,s,i,r,a[c],a[c+1]]),[m,A]=F.applyTransform([0,0],g);o.drawImage(h.canvas,m,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 r of t){const{data:a,width:o,height:l,transform:h}=r,c=this.cachedCanvases.getCanvas("maskCanvas",o,l),f=c.context;f.save();const g=this.getObject(a,r);Up(f,g),f.globalCompositeOperation="source-in",f.fillStyle=i?s.getPattern(f,this,Je(e),Wt.FILL):s,f.fillRect(0,0,o,l),f.restore(),e.save(),e.transform(...h),e.scale(1,-1),ec(e,c.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){U("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const r=this.getObject(t);if(!r){U("Dependent image isn't ready yet");return}const a=r.width,o=r.height,l=[];for(let h=0,c=i.length;h<c;h+=2)l.push({transform:[e,0,0,s,i[h],i[h+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(r,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,r=this.cachedCanvases.getCanvas("inlineImage",s,i),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",r.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!Xt){const{filter:o}=i;o!=="none"&&o!==""&&(i.filter="none")}i.scale(1/e,-1/s);let r;if(t.bitmap)r=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)r=t;else{const l=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Vp(l,t),r=this.applyTransferMapsToCanvas(l)}const a=this._scaleImage(r,Je(i));i.imageSmoothingEnabled=jp(lt(i),t.interpolate),ec(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 r=t.width,a=t.height,l=this.cachedCanvases.getCanvas("inlineImage",r,a).context;Vp(l,t),i=this.applyTransferMapsToCanvas(l)}for(const r of e)s.save(),s.transform(...r.transform),s.scale(1,-1),ec(s,i,r.x,r.y,r.w,r.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===Wp?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=lt(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:r}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),h=Math.abs(r);if(l===h)if(t===0)a=o=1/l;else{const c=l*t;a=o=c<1?1/c:1}else if(t===0)a=1/l,o=1/h;else{const c=l*t,f=h*t;a=c<1?1/c:1,o=f<1?1/f:1}}else{const l=Math.abs(e*r-s*i),h=Math.hypot(e,s),c=Math.hypot(i,r);if(t===0)a=c/l,o=h/l;else{const f=t*l;a=c>f?c/f:1,o=h>f?h/f:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,r]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&r===1){e.stroke();return}const a=e.getLineDash();if(t&&e.save(),e.scale(i,r),a.length>0){const o=Math.max(i,r);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}};Rl=new WeakSet,Sf=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)},kl=new WeakSet,Ef=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}}},Ml=new WeakSet,Cf=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i};let Ir=_p;for(const d in Fe)Ir.prototype[d]!==void 0&&(Ir.prototype[Fe[d]]=Ir.prototype[d]);var Ll,Il;class ti{static get workerPort(){return n(this,Ll)}static set workerPort(t){if(!(typeof Worker!="undefined"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Ll,t)}static get workerSrc(){return n(this,Il)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,Il,t)}}Ll=new WeakMap,Il=new WeakMap,u(ti,Ll,null),u(ti,Il,"");var kn,Dl;class xA{constructor({parsedData:t,rawData:e}){u(this,kn,void 0);u(this,Dl,void 0);p(this,kn,t),p(this,Dl,e)}getRaw(){return n(this,Dl)}get(t){var e;return(e=n(this,kn).get(t))!=null?e:null}getAll(){return cp(n(this,kn))}has(t){return n(this,kn).has(t)}}kn=new WeakMap,Dl=new WeakMap;const xr=Symbol("INTERNAL");var Fl,Nl,Ol,oa;class TA{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){u(this,Fl,!1);u(this,Nl,!1);u(this,Ol,!1);u(this,oa,!0);p(this,Fl,!!(t&_e.DISPLAY)),p(this,Nl,!!(t&_e.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,Ol))return n(this,oa);if(!n(this,oa))return!1;const{print:t,view:e}=this.usage;return n(this,Fl)?(e==null?void 0:e.viewState)!=="OFF":n(this,Nl)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==xr&&st("Internal method `_setVisible` called."),p(this,Ol,s),p(this,oa,e)}}Fl=new WeakMap,Nl=new WeakMap,Ol=new WeakMap,oa=new WeakMap;var yi,tt,la,ha,Bl,xf;class PA{constructor(t,e=_e.DISPLAY){u(this,Bl);u(this,yi,null);u(this,tt,new Map);u(this,la,null);u(this,ha,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,ha,t.order);for(const s of t.groups)n(this,tt).set(s.id,new TA(e,s));if(t.baseState==="OFF")for(const s of n(this,tt).values())s._setVisible(xr,!1);for(const s of t.on)n(this,tt).get(s)._setVisible(xr,!0);for(const s of t.off)n(this,tt).get(s)._setVisible(xr,!1);p(this,la,this.getHash())}}isVisible(t){if(n(this,tt).size===0)return!0;if(!t)return Ru("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,tt).has(t.id)?n(this,tt).get(t.id).visible:(U(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,Bl,xf).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,tt).has(e))return U(`Optional content group not found: ${e}`),!0;if(n(this,tt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,tt).has(e))return U(`Optional content group not found: ${e}`),!0;if(!n(this,tt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,tt).has(e))return U(`Optional content group not found: ${e}`),!0;if(!n(this,tt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,tt).has(e))return U(`Optional content group not found: ${e}`),!0;if(n(this,tt).get(e).visible)return!1}return!0}return U(`Unknown optional content policy ${t.policy}.`),!0}return U(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,tt).get(t);if(!i){U(`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&&((r=n(this,tt).get(o))==null||r._setVisible(xr,!1,!0));i._setVisible(xr,!!e,!0),p(this,yi,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 r=n(this,tt).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}p(this,yi,null)}get hasInitialVisibility(){return n(this,la)===null||this.getHash()===n(this,la)}getOrder(){return n(this,tt).size?n(this,ha)?n(this,ha).slice():[...n(this,tt).keys()]:null}getGroups(){return n(this,tt).size>0?cp(n(this,tt)):null}getGroup(t){return n(this,tt).get(t)||null}getHash(){if(n(this,yi)!==null)return n(this,yi);const t=new Ig;for(const[e,s]of n(this,tt))t.update(`${e}:${s.visible}`);return p(this,yi,t.hexdigest())}}yi=new WeakMap,tt=new WeakMap,la=new WeakMap,ha=new WeakMap,Bl=new WeakSet,xf=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let a;if(Array.isArray(r))a=b(this,Bl,xf).call(this,r);else if(n(this,tt).has(r))a=n(this,tt).get(r).visible;else return U(`Optional content group not found: ${r}`),!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 RA{constructor(t,{disableRange:e=!1,disableStream:s=!1}){wt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:r,progressiveDone:a,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(r==null?void 0:r.length)>0){const l=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).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,h)=>{this._onReceiveData({begin:l,chunk:h})}),t.addProgressListener((l,h)=>{this._onProgress({loaded:l,total:h})}),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(r){return r._begin!==t?!1:(r._enqueue(s),!0)});wt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t,e;return(e=(t=this._fullRequestReader)==null?void 0:t._loaded)!=null?e:0}_onProgress(t){var e,s,i,r;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(r=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||r.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(){wt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new kA(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new MA(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 kA{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=fp(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.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}read(){return I(this,null,function*(){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 MA{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}read(){return I(this,null,function*(){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 LA(d){let t=!0,e=s("filename\\*","i").exec(d);if(e){e=e[1];let c=o(e);return c=unescape(c),c=l(c),c=h(c),r(c)}if(e=a(d),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(d),e){e=e[1];let c=o(e);return c=h(c),r(c)}function s(c,f){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',f)}function i(c,f){if(c){if(!/^[\x00-\xFF]+$/.test(f))return f;try{const g=new TextDecoder(c,{fatal:!0}),m=ku(f);f=g.decode(m),t=!1}catch(g){}}return f}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function a(c){const f=[];let g;const m=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(g=m.exec(c))!==null;){let[,y,v,w]=g;if(y=parseInt(y,10),y in f){if(y===0)break;continue}f[y]=[v,w]}const A=[];for(let y=0;y<f.length&&y in f;++y){let[v,w]=f[y];w=o(w),v&&(w=unescape(w),y===0&&(w=l(w))),A.push(w)}return A.join("")}function o(c){if(c.startsWith('"')){const f=c.slice(1).split('\\"');for(let g=0;g<f.length;++g){const m=f[g].indexOf('"');m!==-1&&(f[g]=f[g].slice(0,m),f.length=g+1),f[g]=f[g].replaceAll(/\\(.)/g,"$1")}c=f.join('"')}return c}function l(c){const f=c.indexOf("'");if(f===-1)return c;const g=c.slice(0,f),A=c.slice(f+1).replace(/^[^']*'/,"");return i(g,A)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(f,g,m,A){if(m==="q"||m==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(y,v){return String.fromCharCode(parseInt(v,16))}),i(g,A);try{A=atob(A)}catch(y){}return i(g,A)})}return""}function Xg(d,t){const e=new Headers;if(!d||!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 Iu(d){try{return new URL(d).origin}catch(t){}return null}function qg({responseHeaders:d,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(d.get("Content-Length"),10);return!Number.isInteger(r)||(i.suggestedLength=r,r<=2*e)||s||!t||d.get("Accept-Ranges")!=="bytes"||(d.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Yg(d){const t=d.get("Content-Disposition");if(t){let e=LA(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch(s){}if(fp(e))return e}return null}function Du(d,t){return d===404||d===0&&t.startsWith("file:")?new Fo('Missing PDF "'+t+'".'):new Fc(`Unexpected server response (${d}) while retrieving PDF "${t}".`,d)}function Kg(d){return d===200||d===206}function Qg(d,t,e){return{method:"GET",headers:d,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Jg(d){return d instanceof Uint8Array?d.buffer:d instanceof ArrayBuffer?d:(U(`getArrayBuffer - unexpected data format: ${d}`),new Uint8Array(d).buffer)}class Xp{constructor(t){O(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Xg(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return(e=(t=this._fullRequestReader)==null?void 0:t._loaded)!=null?e:0}getFullReader(){return wt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new IA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new DA(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 IA{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,Qg(s,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=Iu(r.url),!Kg(r.status))throw Du(r.status,i);this._reader=r.body.getReader(),this._headersCapability.resolve();const a=r.headers,{allowRangeRequests:o,suggestedLength:l}=qg({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=Yg(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new $i("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}read(){return I(this,null,function*(){var s;yield this._headersCapability.promise;const{value:t,done:e}=yield 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:Jg(t),done:!1})})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class DA{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 r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`);const a=i.url;fetch(a,Qg(r,this._withCredentials,this._abortController)).then(o=>{const l=Iu(o.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!Kg(o.status))throw Du(o.status,a);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){return I(this,null,function*(){var s;yield this._readCapability.promise;const{value:t,done:e}=yield this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:Jg(t),done:!1})})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const Wu=200,Xu=206;function FA(d){const t=d.response;return typeof t!="string"?t:ku(t).buffer}class NA{constructor({url:t,httpHeaders:e,withCredentials:s}){O(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Xg(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}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[r,a]of this.headers)e.setRequestHeader(r,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=Xu):i.expectedStatus=Wu,e.responseType="arraybuffer",wt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){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){s.onError(i.status);return}const r=i.status||Wu;if(!(r===Wu&&s.expectedStatus===Xu)&&r!==s.expectedStatus){s.onError(i.status);return}const o=FA(i);if(r===Xu){const l=i.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);h?s.onDone({begin:parseInt(h[1],10),chunk:o}):(U('Missing or invalid "Content-Range" header.'),s.onError(0))}else o?s.onDone({begin:0,chunk:o}):s.onError(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 OA{constructor(t){this._source=t,this._manager=new NA(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 wt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new BA(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new HA(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 BA{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Iu(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[l,...h]=o.split(": ");return[l,h.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:a}=qg({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=Yg(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Du(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}read(){return I(this,null,function*(){if(yield this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};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 HA{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var e;const t=Iu((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_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){var e;(e=this._storedError)!=null||(this._storedError=Du(t,this._url));for(const s of this._requests)s.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}read(){return I(this,null,function*(){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 zA=/^[a-z][a-z0-9\-+.]+:/i;function $A(d){if(zA.test(d))return new URL(d);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(d))}class GA{constructor(t){this.source=t,this.url=$A(t.url),wt(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return(e=(t=this._fullRequestReader)==null?void 0:t._loaded)!=null?e:0}getFullReader(){return wt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new VA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new UA(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 VA{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();const s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new Fo(`Missing PDF "${this._url}".`)),this._storedError=i,this._headersCapability.reject(i)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return I(this,null,function*(){var s;if(yield 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 $i("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class UA{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const r=process.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){return I(this,null,function*(){var s;if(yield 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)}}const jA=1e5,ee=30,WA=.8;var Qp,wi,re,Hl,zl,Mn,Ds,$l,Gl,Ln,ca,da,vi,ua,Vl,fa,In,Ul,jl,Dn,Fn,Wl,_i,pa,Pd,Zg,Rd,tm,Xl,Tf,ga,gc,ql,Pf,kd,em,Md,sm;const pt=class pt{constructor({textContentSource:t,container:e,viewport:s}){u(this,Pd);u(this,Rd);u(this,Xl);u(this,wi,Promise.withResolvers());u(this,re,null);u(this,Hl,!1);u(this,zl,!!((Qp=globalThis.FontInspector)!=null&&Qp.enabled));u(this,Mn,null);u(this,Ds,null);u(this,$l,0);u(this,Gl,0);u(this,Ln,null);u(this,ca,null);u(this,da,0);u(this,vi,0);u(this,ua,Object.create(null));u(this,Vl,[]);u(this,fa,null);u(this,In,[]);u(this,Ul,new WeakMap);u(this,jl,null);var l;if(t instanceof ReadableStream)p(this,fa,t);else if(typeof t=="object")p(this,fa,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,re,p(this,ca,e)),p(this,vi,s.scale*(globalThis.devicePixelRatio||1)),p(this,da,s.rotation),p(this,Ds,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:r,pageX:a,pageY:o}=s.rawDims;p(this,jl,[1,0,0,-1,-a,o+r]),p(this,Gl,i),p(this,$l,r),b(l=pt,kd,em).call(l),br(e,s),n(this,wi).promise.finally(()=>{n(pt,pa).delete(this),p(this,Ds,null),p(this,ua,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=te.platform;return X(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{n(this,Ln).read().then(({value:e,done:s})=>{var i;if(s){n(this,wi).resolve();return}(i=n(this,Mn))!=null||p(this,Mn,e.lang),Object.assign(n(this,ua),e.styles),b(this,Pd,Zg).call(this,e.items),t()},n(this,wi).reject)};return p(this,Ln,n(this,fa).getReader()),n(pt,pa).add(this),t(),n(this,wi).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==n(this,da)&&(e==null||e(),p(this,da,i),br(n(this,ca),{rotation:i})),s!==n(this,vi)){e==null||e(),p(this,vi,s);const a={div:null,properties:null,ctx:b(r=pt,ga,gc).call(r,n(this,Mn))};for(const o of n(this,In))a.properties=n(this,Ul).get(o),a.div=o,b(this,Xl,Tf).call(this,a)}}cancel(){var e;const t=new $i("TextLayer task cancelled.");(e=n(this,Ln))==null||e.cancel(t).catch(()=>{}),p(this,Ln,null),n(this,wi).reject(t)}get textDivs(){return n(this,In)}get textContentItemsStr(){return n(this,Vl)}static cleanup(){if(!(n(this,pa).size>0)){n(this,Dn).clear();for(const{canvas:t}of n(this,Fn).values())t.remove();n(this,Fn).clear()}}};wi=new WeakMap,re=new WeakMap,Hl=new WeakMap,zl=new WeakMap,Mn=new WeakMap,Ds=new WeakMap,$l=new WeakMap,Gl=new WeakMap,Ln=new WeakMap,ca=new WeakMap,da=new WeakMap,vi=new WeakMap,ua=new WeakMap,Vl=new WeakMap,fa=new WeakMap,In=new WeakMap,Ul=new WeakMap,jl=new WeakMap,Dn=new WeakMap,Fn=new WeakMap,Wl=new WeakMap,_i=new WeakMap,pa=new WeakMap,Pd=new WeakSet,Zg=function(t){var i,r,a;if(n(this,Hl))return;(a=(r=n(this,Ds)).ctx)!=null||(r.ctx=b(i=pt,ga,gc).call(i,n(this,Mn)));const e=n(this,In),s=n(this,Vl);for(const o of t){if(e.length>jA){U("Ignoring additional textDivs for performance reasons."),p(this,Hl,!0);return}if(o.str===void 0){if(o.type==="beginMarkedContentProps"||o.type==="beginMarkedContent"){const l=n(this,re);p(this,re,document.createElement("span")),n(this,re).classList.add("markedContent"),o.id!==null&&n(this,re).setAttribute("id",`${o.id}`),l.append(n(this,re))}else o.type==="endMarkedContent"&&p(this,re,n(this,re).parentNode);continue}s.push(o.str),b(this,Rd,tm).call(this,o)}},Rd=new WeakSet,tm=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,In).push(e);const i=F.transform(n(this,jl),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,ua)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,zl)&&a.fontSubstitution||a.fontFamily;o=pt.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*b(y=pt,Md,sm).call(y,o,n(this,Mn));let c,f;r===0?(c=i[4],f=i[5]-h):(c=i[4]+h*Math.sin(r),f=i[5]-h*Math.cos(r));const g="calc(var(--scale-factor)*",m=e.style;n(this,re)===n(this,ca)?(m.left=`${(100*c/n(this,Gl)).toFixed(2)}%`,m.top=`${(100*f/n(this,$l)).toFixed(2)}%`):(m.left=`${g}${c.toFixed(2)}px)`,m.top=`${g}${f.toFixed(2)}px)`),m.fontSize=`${g}${(n(pt,_i)*l).toFixed(2)}px)`,m.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,n(this,zl)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const v=Math.abs(t.transform[0]),w=Math.abs(t.transform[3]);v!==w&&Math.max(v,w)/Math.min(v,w)>1.5&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,Ul).set(e,s),n(this,Ds).div=e,n(this,Ds).properties=s,b(this,Xl,Tf).call(this,n(this,Ds)),s.hasText&&n(this,re).append(e),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),n(this,re).append(v)}},Xl=new WeakSet,Tf=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:r}=e;let a="";if(n(pt,_i)>1&&(a=`scale(${1/n(pt,_i)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=r,{canvasWidth:h,fontSize:c}=s;b(o=pt,ql,Pf).call(o,i,c*n(this,vi),l);const{width:f}=i.measureText(e.textContent);f>0&&(a=`scaleX(${h*n(this,vi)/f}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)},ga=new WeakSet,gc=function(t=null){let e=n(this,Fn).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}),n(this,Fn).set(t,e),n(this,Wl).set(e,{size:0,family:""})}return e},ql=new WeakSet,Pf=function(t,e,s){const i=n(this,Wl).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},kd=new WeakSet,em=function(){if(n(this,_i)!==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,_i,t.getBoundingClientRect().height),t.remove()},Md=new WeakSet,sm=function(t,e){const s=n(this,Dn).get(t);if(s)return s;const i=b(this,ga,gc).call(this,e);i.canvas.width=i.canvas.height=ee,b(this,ql,Pf).call(this,i,ee,t);const r=i.measureText("");let a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);if(a){const c=a/(a+o);return n(this,Dn).set(t,c),i.canvas.width=i.canvas.height=0,c}i.strokeStyle="red",i.clearRect(0,0,ee,ee),i.strokeText("g",0,0);let l=i.getImageData(0,0,ee,ee).data;o=0;for(let c=l.length-1-3;c>=0;c-=4)if(l[c]>0){o=Math.ceil(c/4/ee);break}i.clearRect(0,0,ee,ee),i.strokeText("A",0,ee),l=i.getImageData(0,0,ee,ee).data,a=0;for(let c=0,f=l.length;c<f;c+=4)if(l[c]>0){a=ee-Math.floor(c/4/ee);break}i.canvas.width=i.canvas.height=0;const h=a?a/(a+o):WA;return n(this,Dn).set(t,h),h},u(pt,ga),u(pt,ql),u(pt,kd),u(pt,Md),u(pt,Dn,new Map),u(pt,Fn,new Map),u(pt,Wl,new WeakMap),u(pt,_i,null),u(pt,pa,new Set);let No=pt;class Oo{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(Oo.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const h of r.children)i(h)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const XA=65536,qA=100,YA=5e3,KA=Xt?cA:oA,QA=Xt?dA:$g,JA=Xt?hA:lA,ZA=Xt?uA:jg;function ty(d={}){var ht,Q;typeof d=="string"||d instanceof URL?d={url:d}:(d instanceof ArrayBuffer||ArrayBuffer.isView(d))&&(d={data:d});const t=new Rf,{docId:e}=t,s=d.url?ey(d.url):null,i=d.data?sy(d.data):null,r=d.httpHeaders||null,a=d.withCredentials===!0,o=(ht=d.password)!=null?ht:null,l=d.range instanceof im?d.range:null,h=Number.isInteger(d.rangeChunkSize)&&d.rangeChunkSize>0?d.rangeChunkSize:XA;let c=d.worker instanceof Dr?d.worker:null;const f=d.verbosity,g=typeof d.docBaseUrl=="string"&&!Lu(d.docBaseUrl)?d.docBaseUrl:null,m=typeof d.cMapUrl=="string"?d.cMapUrl:null,A=d.cMapPacked!==!1,y=d.CMapReaderFactory||QA,v=typeof d.standardFontDataUrl=="string"?d.standardFontDataUrl:null,w=d.StandardFontDataFactory||ZA,_=d.stopAtErrors!==!0,E=Number.isInteger(d.maxImageSize)&&d.maxImageSize>-1?d.maxImageSize:-1,S=d.isEvalSupported!==!1,C=typeof d.isOffscreenCanvasSupported=="boolean"?d.isOffscreenCanvasSupported:!Xt,P=typeof d.isImageDecoderSupported=="boolean"?d.isImageDecoderSupported:!Xt&&(te.platform.isFirefox||!globalThis.chrome),T=Number.isInteger(d.canvasMaxAreaInBytes)?d.canvasMaxAreaInBytes:-1,k=typeof d.disableFontFace=="boolean"?d.disableFontFace:Xt,N=d.fontExtraProperties===!0,$=d.enableXfa===!0,B=d.ownerDocument||globalThis.document,it=d.disableRange===!0,nt=d.disableStream===!0,K=d.disableAutoFetch===!0,Et=d.pdfBug===!0,x=d.CanvasFactory||KA,R=d.FilterFactory||JA,G=d.enableHWA===!0,J=l?l.length:(Q=d.length)!=null?Q:NaN,H=typeof d.useSystemFonts=="boolean"?d.useSystemFonts:!Xt&&!k,Bt=typeof d.useWorkerFetch=="boolean"?d.useWorkerFetch:y===$g&&w===jg&&m&&v&&Ao(m,document.baseURI)&&Ao(v,document.baseURI),rt=null;Hb(f);const ft={canvasFactory:new x({ownerDocument:B,enableHWA:G}),filterFactory:new R({docId:e,ownerDocument:B}),cMapReaderFactory:Bt?null:new y({baseUrl:m,isCompressed:A}),standardFontDataFactory:Bt?null:new w({baseUrl:v})};if(!c){const Ui={verbosity:f,port:ti.workerPort};c=Ui.port?Dr.fromPort(Ui):new Dr(Ui),t._worker=c}const Qe={docId:e,apiVersion:"4.10.38",data:i,password:o,disableAutoFetch:K,rangeChunkSize:h,length:J,docBaseUrl:g,enableXfa:$,evaluatorOptions:{maxImageSize:E,disableFontFace:k,ignoreErrors:_,isEvalSupported:S,isOffscreenCanvasSupported:C,isImageDecoderSupported:P,canvasMaxAreaInBytes:T,fontExtraProperties:N,useSystemFonts:H,cMapUrl:Bt?m:null,standardFontDataUrl:Bt?v:null}},Ee={disableFontFace:k,fontExtraProperties:N,ownerDocument:B,pdfBug:Et,styleElement:rt,loadingParams:{disableAutoFetch:K,enableXfa:$}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Ui=c.messageHandler.sendWithPromise("GetDocRequest",Qe,i?[i.buffer]:null);let Fu;if(l)Fu=new RA(l,{disableRange:it,disableStream:nt});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let vr;if(Xt)if(Ao(s)){if(typeof fetch=="undefined"||typeof Response=="undefined"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");vr=Xp}else vr=GA;else vr=Ao(s)?Xp:OA;Fu=new vr({url:s,length:J,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:it,disableStream:nt})}return Ui.then(vr=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const xp=new _o(e,vr,c.port),tb=new ay(xp,t,Fu,Ee,ft);t._transport=tb,xp.send("Ready",null)})}).catch(t._capability.reject),t}function ey(d){if(d instanceof URL)return d.href;try{return new URL(d,window.location).href}catch(t){if(Xt&&typeof d=="string")return d}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function sy(d){if(Xt&&typeof Buffer!="undefined"&&d instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(d instanceof Uint8Array&&d.byteLength===d.buffer.byteLength)return d;if(typeof d=="string")return ku(d);if(d instanceof ArrayBuffer||ArrayBuffer.isView(d)||typeof d=="object"&&!isNaN(d==null?void 0:d.length))return new Uint8Array(d);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function qp(d){return typeof d=="object"&&Number.isInteger(d==null?void 0:d.num)&&d.num>=0&&Number.isInteger(d==null?void 0:d.gen)&&d.gen>=0}var Ld;const Id=class Id{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${qt(Id,Ld)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return I(this,null,function*(){var t,e,s,i;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),yield(e=this._transport)==null?void 0:e.destroy()}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null})}};Ld=new WeakMap,u(Id,Ld,0);let Rf=Id;class im{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){st("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class iy{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 X(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 Si,Fs,Ei,Tr,ma,mc;class ny{constructor(t,e,s,i=!1){u(this,Ei);u(this,ma);u(this,Si,null);u(this,Fs,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Dp:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new nm,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:r=!1}={}){return new Kh({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}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 X(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){return I(this,null,function*(){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=ii.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:f=!1}){var S,C;(S=this._stats)==null||S.time("Overall");const g=this._transport.getRenderingIntent(s,i,c,f),{renderingIntent:m,cacheKey:A}=g;p(this,Fs,!1),b(this,ma,mc).call(this),o||(o=this._transport.getOptionalContentConfig(m));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 v=!!(m&_e.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(g));const w=P=>{var T;y.renderTasks.delete(_),(this._maybeCleanupAfterRender||v)&&p(this,Fs,!0),b(this,Ei,Tr).call(this,!v),P?(_.capability.reject(P),this._abortOperatorList({intentState:y,reason:P instanceof Error?P:new Error(P)})):_.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))},_=new Mf({callback:w,params:{canvasContext:t,viewport:e,transform:r,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:!v,pdfBug:this._pdfBug,pageColors:h});(y.renderTasks||(y.renderTasks=new Set)).add(_);const E=_.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([P,T])=>{var k;if(this.destroyed){w();return}if((k=this._stats)==null||k.time("Rendering"),!(T.renderingIntent&m))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:P,optionalContentConfig:T}),_.operatorListChanged()}).catch(w),E}getOperatorList({intent:t="display",annotationMode:e=ii.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var h;function r(){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=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.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=>Oo.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function r(){a.read().then(function({value:l,done:h}){var c;if(h){s(o);return}(c=o.lang)!=null||(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),r()},i)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};r()})}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,Fs,!1),b(this,ma,mc).call(this),Promise.all(t)}cleanup(t=!1){p(this,Fs,!0);const e=b(this,Ei,Tr).call(this,!1);return t&&e&&this._stats&&(this._stats=new Dp),e}_startRenderPage(t,e){var i,r;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.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&&b(this,Ei,Tr).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},a).getReader(),h=this._intentStates.get(e);h.streamReader=l;const c=()=>{l.read().then(({value:f,done:g})=>{if(g){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(f,h),c())},f=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const g of h.renderTasks)g.operatorListChanged();b(this,Ei,Tr).call(this,!0)}if(h.displayReadyCapability)h.displayReadyCapability.reject(f);else if(h.opListReadCapability)h.opListReadCapability.reject(f);else throw f}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof up){let i=qA;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 $i(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}Si=new WeakMap,Fs=new WeakMap,Ei=new WeakSet,Tr=function(t=!1){if(b(this,ma,mc).call(this),!n(this,Fs)||this.destroyed)return!1;if(t)return p(this,Si,setTimeout(()=>{p(this,Si,null),b(this,Ei,Tr).call(this,!1)},YA)),!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,Fs,!1),!0},ma=new WeakSet,mc=function(){n(this,Si)&&(clearTimeout(n(this,Si)),p(this,Si,null))};var Ns,Dd;class ry{constructor(){u(this,Ns,new Map);u(this,Dd,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,Dd).then(()=>{for(const[i]of n(this,Ns))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){U("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,Ns).set(e,i)}removeEventListener(t,e){const s=n(this,Ns).get(e);s==null||s(),n(this,Ns).delete(e)}terminate(){for(const[,t]of n(this,Ns))t==null||t();n(this,Ns).clear()}}Ns=new WeakMap,Dd=new WeakMap;var Fd,Nn,On,ba,bc,Aa,Ac;const ot=class ot{constructor({name:t=null,port:e=null,verbosity:s=zb()}={}){u(this,ba);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=n(ot,On))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(n(ot,On)||p(ot,On,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new _o("main","worker",t),this._messageHandler.on("ready",function(){}),b(this,ba,bc).call(this)}_initialize(){if(n(ot,Nn)||n(ot,Aa,Ac)){this._setupFakeWorker();return}let{workerSrc:t}=ot;try{ot._isSameOrigin(window.location.href,t)||(t=ot._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new _o("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,b(this,ba,bc).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch(l){this._setupFakeWorker()}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch(e){Ru("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){n(ot,Nn)||(U("Setting up fake worker."),p(ot,Nn,!0)),ot._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new ry;this._port=e;const s=`fake${qt(ot,Fd)._++}`,i=new _o(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new _o(s,s+"_worker",e),b(this,ba,bc).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t,e,s;this.destroyed=!0,(t=this._webWorker)==null||t.terminate(),this._webWorker=null,(e=n(ot,On))==null||e.delete(this._port),this._port=null,(s=this._messageHandler)==null||s.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=n(this,On))==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 ot(t)}static get workerSrc(){if(ti.workerSrc)return ti.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return X(this,"_setupFakeWorkerGlobal",(()=>I(this,null,function*(){return n(this,Aa,Ac)?n(this,Aa,Ac):(yield ab(()=>import(this.workerSrc),[],import.meta.url)).WorkerMessageHandler}))())}};Fd=new WeakMap,Nn=new WeakMap,On=new WeakMap,ba=new WeakSet,bc=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Aa=new WeakSet,Ac=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch(e){return null}},u(ot,Aa),u(ot,Fd,0),u(ot,Nn,!1),u(ot,On,void 0),Xt&&(p(ot,Nn,!0),ti.workerSrc||(ti.workerSrc="./pdf.worker.mjs")),ot._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch(r){return!1}const i=new URL(e,s);return s.origin===i.origin},ot._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Dr=ot;var Os,cs,ya,wa,Bs,Bn,To;class ay{constructor(t,e,s,i,r){u(this,Bn);u(this,Os,new Map);u(this,cs,new Map);u(this,ya,new Map);u(this,wa,new Map);u(this,Bs,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new nm,this.fontLoader=new rA({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.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 X(this,"annotationStorage",new mp)}getRenderingIntent(t,e=ii.ENABLE,s=null,i=!1,r=!1){let a=_e.DISPLAY,o=Af;switch(t){case"any":a=_e.ANY;break;case"display":break;case"print":a=_e.PRINT;break;default:U(`getRenderingIntent - invalid intent: ${t}`)}const l=a&_e.PRINT&&s instanceof Fg?s:this.annotationStorage;switch(e){case ii.DISABLE:a+=_e.ANNOTATIONS_DISABLE;break;case ii.ENABLE:break;case ii.ENABLE_FORMS:a+=_e.ANNOTATIONS_FORMS;break;case ii.ENABLE_STORAGE:a+=_e.ANNOTATIONS_STORAGE,o=l.serializable;break;default:U(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=_e.IS_EDITING),r&&(a+=_e.OPLIST);const{ids:h,hash:c}=l.modifiedIds,f=[a,o.hash,c];return{renderingIntent:a,cacheKey:f.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,Bs))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,cs).values())t.push(i._destroy());n(this,cs).clear(),n(this,ya).clear(),n(this,wa).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,Os).clear(),this.filterFactory.destroy(),No.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new $i("Worker was terminated.")),(r=this.messageHandler)==null||r.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)=>{wt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},i.onPull=()=>{this._fullReader.read().then(function({value:r,done:a}){if(a){i.close();return}wt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{this._fullReader.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",s=>I(this,null,function*(){var o;yield this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=this._fullReader;return(!i||!r)&&(this._lastProgress&&((o=e.onProgress)==null||o.call(e,this._lastProgress)),this._fullReader.onProgress=l=>{var h;(h=e.onProgress)==null||h.call(e,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}})),t.on("GetRangeReader",(s,i)=>{wt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}wt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{r.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 iy(s,this))}),t.on("DocException",s=>{e._capability.reject(se(s))}),t.on("PasswordRequest",s=>{p(this,Bs,Promise.withResolvers());try{if(!e.onPassword)throw se(s);const i=r=>{r instanceof Error?n(this,Bs).reject(r):n(this,Bs).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,Bs).reject(i)}return n(this,Bs).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;n(this,cs).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:o,fontExtraProperties:l,pdfBug:h}=this._params;if("error"in r){const m=r.error;U(`Error during font loading: ${m}`),this.commonObjs.resolve(s,m);break}const c=h&&((a=globalThis.FontInspector)!=null&&a.enabled)?(m,A)=>globalThis.FontInspector.fontAdded(m,A):null,f=new aA(r,{disableFontFace:o,fontExtraProperties:l,inspectFont:c});this.fontLoader.bind(f).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&f.data&&(f.data=null),this.commonObjs.resolve(s,f)});break;case"CopyLocalImage":const{imageRef:g}=r;wt(g,"The imageRef must be defined.");for(const m of n(this,cs).values())for(const[,A]of m.objs)if((A==null?void 0:A.ref)===g)return A.dataLen?(this.commonObjs.resolve(s,structuredClone(A)),A.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,r);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,cs).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":o.objs.resolve(s,a),(a==null?void 0:a.dataLen)>Fb&&(o._maybeCleanupAfterRender=!0);break;case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",s=>I(this,null,function*(){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",s=>I(this,null,function*(){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,i;this.annotationStorage.size<=0&&U("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:(i=(s=this._fullReader)==null?void 0:s.filename)!=null?i: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=n(this,ya).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&n(this,wa).set(r.refStr,t);const a=new ny(e,r,this,this._params.pdfBug);return n(this,cs).set(e,a),a});return n(this,ya).set(e,i),i}getPageIndex(t){return qp(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 b(this,Bn,To).call(this,"GetFieldObjects")}hasJSActions(){return b(this,Bn,To).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 b(this,Bn,To).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 b(this,Bn,To).call(this,"GetOptionalContentConfig").then(e=>new PA(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=n(this,Os).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var r,a,o,l;return{info:i[0],metadata:i[1]?new xA(i[1]):null,contentDispositionFilename:(a=(r=this._fullReader)==null?void 0:r.filename)!=null?a:null,contentLength:(l=(o=this._fullReader)==null?void 0:o.contentLength)!=null?l:null}});return n(this,Os).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(t=!1){return I(this,null,function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(const e of n(this,cs).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,Os).clear(),this.filterFactory.destroy(!0),No.cleanup()}})}cachedPageNumber(t){var s;if(!qp(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return(s=n(this,wa).get(e))!=null?s:null}}Os=new WeakMap,cs=new WeakMap,ya=new WeakMap,wa=new WeakMap,Bs=new WeakMap,Bn=new WeakSet,To=function(t,e=null){const s=n(this,Os).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return n(this,Os).set(t,i),i};const go=Symbol("INITIAL_DATA");var fe,Yl,kf;class nm{constructor(){u(this,Yl);u(this,fe,Object.create(null))}get(t,e=null){if(e){const i=b(this,Yl,kf).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=n(this,fe)[t];if(!s||s.data===go)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,fe)[t];return!!e&&e.data!==go}delete(t){const e=n(this,fe)[t];return!e||e.data===go?!1:(delete n(this,fe)[t],!0)}resolve(t,e=null){const s=b(this,Yl,kf).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in n(this,fe)){const{data:s}=n(this,fe)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,fe,Object.create(null))}*[Symbol.iterator](){for(const t in n(this,fe)){const{data:e}=n(this,fe)[t];e!==go&&(yield[t,e])}}}fe=new WeakMap,Yl=new WeakSet,kf=function(t){var e;return(e=n(this,fe))[t]||(e[t]=_r(ys({},Promise.withResolvers()),{data:go}))};var Ci;class oy{constructor(t){u(this,Ci,null);p(this,Ci,t),this.onContinue=null}get promise(){return n(this,Ci).capability.promise}cancel(t=0){n(this,Ci).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=n(this,Ci).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=n(this,Ci);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}Ci=new WeakMap;var xi,Hn;const Qi=class Qi{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:f=!1,pageColors:g=null}){u(this,xi,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=f,this.pageColors=g,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window!="undefined",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new oy(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(n(Qi,Hn).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.");n(Qi,Hn).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:r,background:a}=this.params;this.gfx=new Ir(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,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(),n(this,xi)&&(window.cancelAnimationFrame(n(this,xi)),p(this,xi,null)),n(Qi,Hn).delete(this._canvas),this.callback(t||new up(`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,xi,window.requestAnimationFrame(()=>{p(this,xi,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){return I(this,null,function*(){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(),n(Qi,Hn).delete(this._canvas),this.callback())))})}};xi=new WeakMap,Hn=new WeakMap,u(Qi,Hn,new WeakSet);let Mf=Qi;const ly="4.10.38",hy="f9bea397f";function Yp(d){return Math.floor(Math.max(0,Math.min(1,d))*255).toString(16).padStart(2,"0")}function mo(d){return Math.max(0,Math.min(255,255*d))}class Kp{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=mo(t),[t,t,t]}static G_HTML([t]){const e=Yp(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(mo)}static RGB_HTML(t){return`#${t.map(Yp).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[mo(1-Math.min(1,t+i)),mo(1-Math.min(1,s+i)),mo(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,r=1-e,a=1-s,o=Math.min(i,r,a);return["CMYK",i,r,a,o]}}class cy{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){st("Abstract method `_createSVG` called.")}}class Ap extends cy{_createSVG(t){return document.createElementNS(ws,t)}}class rm{static setupStorage(t,e,s,i,r){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="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"),r==="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),r==="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,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,h]of Object.entries(a))if(h!=null)switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var f,g;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const m=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=m}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const m=document.createTextNode(i.value);a.append(m),o&&Oo.shouldBuildText(i.name)&&h.push(m)}return{textDivs:h}}const c=[[i,-1,a]];for(;c.length>0;){const[m,A,y]=c.at(-1);if(A+1===m.children.length){c.pop();continue}const v=m.children[++c.at(-1)[1]];if(v===null)continue;const{name:w}=v;if(w==="#text"){const E=document.createTextNode(v.value);h.push(E),y.append(E);continue}const _=(f=v==null?void 0:v.attributes)!=null&&f.xmlns?document.createElementNS(v.attributes.xmlns,w):document.createElement(w);if(y.append(_),v.attributes&&this.setAttributes({html:_,element:v,storage:e,intent:r,linkService:s}),((g=v.children)==null?void 0:g.length)>0)c.push([v,-1,_]);else if(v.value){const E=document.createTextNode(v.value);o&&Oo.shouldBuildText(w)&&h.push(E),_.append(E)}}for(const m of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))m.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Jh=1e3,dy=9,yr=new WeakSet;function zi(d){return{width:d[2]-d[0],height:d[3]-d[1]}}class uy{static create(t){switch(t.data.annotationType){case vt.LINK:return new am(t);case vt.TEXT:return new fy(t);case vt.WIDGET:switch(t.data.fieldType){case"Tx":return new py(t);case"Btn":return t.data.radioButton?new hm(t):t.data.checkBox?new my(t):new by(t);case"Ch":return new Ay(t);case"Sig":return new gy(t)}return new wr(t);case vt.POPUP:return new If(t);case vt.FREETEXT:return new pm(t);case vt.LINE:return new wy(t);case vt.SQUARE:return new vy(t);case vt.CIRCLE:return new _y(t);case vt.POLYLINE:return new gm(t);case vt.CARET:return new Ey(t);case vt.INK:return new yp(t);case vt.POLYGON:return new Sy(t);case vt.HIGHLIGHT:return new mm(t);case vt.UNDERLINE:return new Cy(t);case vt.SQUIGGLY:return new xy(t);case vt.STRIKEOUT:return new Ty(t);case vt.STAMP:return new bm(t);case vt.FILEATTACHMENT:return new Py(t);default:return new At(t)}}}var zn,va,_a,Kl,Lf;const Sp=class Sp{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){u(this,Kl);u(this,zn,null);u(this,va,!1);u(this,_a,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 Sp._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;n(this,zn)||p(this,zn,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&b(this,Kl,Lf).call(this,e),(s=n(this,_a))==null||s.popup.updateEdited(t)}resetEdited(){var t;n(this,zn)&&(b(this,Kl,Lf).call(this,n(this,zn).rect),(t=n(this,_a))==null||t.popup.resetEdited(),p(this,zn,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),this instanceof wr||(r.tabIndex=Jh);const{style:a}=r;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof If){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,r),r}const{width:o,height:l}=zi(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const y=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(y>0||v>0){const _=`calc(${y}px * var(--scale-factor)) / calc(${v}px * var(--scale-factor))`;a.borderRadius=_}else if(this instanceof hm){const _=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=_}switch(e.borderStyle.style){case fo.SOLID:a.borderStyle="solid";break;case fo.DASHED:a.borderStyle="dashed";break;case fo.BEVELED:U("Unimplemented border style: beveled");break;case fo.INSET:U("Unimplemented border style: inset");break;case fo.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(p(this,va,!0),a.borderColor=F.makeHexColor(w[0]|0,w[1]|0,w[2]|0)):a.borderWidth=0}const h=F.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:f,pageX:g,pageY:m}=i.rawDims;a.left=`${100*(h[0]-g)/c}%`,a.top=`${100*(h[1]-m)/f}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/c}%`,a.height=`${100*l/f}%`):this.setRotation(A,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:r,height:a}=zi(this.data.rect);let o,l;t%180===0?(o=100*r/s,l=100*a/i):(o=100*a/s,l=100*r/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 r=i.detail[e],a=r[0],o=r.slice(1);i.target.style[s]=Kp[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Kp[`${a}_rgb`](o)})};return X(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 r=t[i]||s[i];r==null||r(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,r]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:r},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(y=>Math.fround(y));if(t.length===8){const[y,v,w,_]=t.subarray(2,6);if(i===y&&r===v&&e===w&&s===_)return}const{style:a}=this.container;let o;if(n(this,va)){const{borderColor:y,borderWidth:v}=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="${v}">`],this.container.classList.add("hasBorder")}const l=i-e,h=r-s,{svgFactory:c}=this,f=c.createElement("svg");f.classList.add("quadrilateralsContainer"),f.setAttribute("width",0),f.setAttribute("height",0);const g=c.createElement("defs");f.append(g);const m=c.createElement("clipPath"),A=`clippath_${this.data.id}`;m.setAttribute("id",A),m.setAttribute("clipPathUnits","objectBoundingBox"),g.append(m);for(let y=2,v=t.length;y<v;y+=8){const w=t[y],_=t[y+1],E=t[y+2],S=t[y+3],C=c.createElement("rect"),P=(E-e)/l,T=(r-_)/h,k=(w-E)/l,N=(_-S)/h;C.setAttribute("x",P),C.setAttribute("y",T),C.setAttribute("width",k),C.setAttribute("height",N),m.append(C),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${P}" y="${T}" width="${k}" height="${N}"/>`)}n(this,va)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(f),this.container.style.clipPath=`url(#${A})`}_createPopup(){const{data:t}=this,e=p(this,_a,new If({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(){st("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:r,id:a,exportValues:o}of i){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!yr.has(h)){U(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==e&&yr.has(i)&&s.push({id:a,exportValue:r,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})})}};zn=new WeakMap,va=new WeakMap,_a=new WeakMap,Kl=new WeakSet,Lf=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t);const{width:h,height:c}=zi(t);e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*h/r}%`,e.height=`${100*c/a}%`):this.setRotation(i)};let At=Sp;var Hs,Xi,Nd,om,Od,lm;class am extends At{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});u(this,Hs);u(this,Nd);u(this,Od);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(i,e.action),r=!0):e.attachment?(b(this,Nd,om).call(this,i,e.attachment,e.attachmentDest),r=!0):e.setOCGState?(b(this,Od,lm).call(this,i,e.setOCGState),r=!0):e.dest?(this._bindLink(i,e.dest),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),r=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&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==="")&&b(this,Hs,Xi).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),b(this,Hs,Xi).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=i.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}e.onclick||(e.onclick=()=>!1),b(this,Hs,Xi).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,Hs,Xi).call(this),!this._fieldObjects){U('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var f;i==null||i();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const g=new Set(a);for(const m of r){const A=this._fieldObjects[m]||[];for(const{id:y}of A)g.add(y)}for(const m of Object.values(this._fieldObjects))for(const A of m)g.has(A.id)===o&&l.push(A)}else for(const g of Object.values(this._fieldObjects))l.push(...g);const h=this.annotationStorage,c=[];for(const g of l){const{id:m}=g;switch(c.push(m),g.type){case"text":{const y=g.defaultValue||"";h.setValue(m,{value:y});break}case"checkbox":case"radiobutton":{const y=g.defaultValue===g.exportValues;h.setValue(m,{value:y});break}case"combobox":case"listbox":{const y=g.defaultValue||"";h.setValue(m,{value:y});break}default:continue}const A=document.querySelector(`[data-element-id="${m}"]`);if(A){if(!yr.has(A)){U(`_bindResetFormAction - element not allowed: ${m}`);continue}}else continue;A.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((f=this.linkService.eventBus)==null||f.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}Hs=new WeakSet,Xi=function(){this.container.setAttribute("data-internal-link","")},Nd=new WeakSet,om=function(e,s,i=null){e.href=this.linkService.getAnchorUrl(""),s.description&&(e.title=s.description),e.onclick=()=>{var r;return(r=this.downloadManager)==null||r.openOrDownloadData(s.content,s.filename,i),!1},b(this,Hs,Xi).call(this)},Od=new WeakSet,lm=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),b(this,Hs,Xi).call(this)};class fy extends At{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 wr extends At{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 te.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){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:r(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}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a)}}))})}_setEventListeners(t,e,s,i){var r,a,o;for(const[l,h]of s)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,h,i),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="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":F.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||dy,r=t.style;let a;const o=2,l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o),c=Math.round(h/($u*i))||1,f=h/c;a=Math.min(i,l(f/$u))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(h/$u))}r.fontSize=`calc(${a}px * var(--scale-factor))`,r.color=F.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class py extends wr{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 r=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[i]:s})}render(){var i,r;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 h=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
`))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const c={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h!=null?h:o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",h!=null?h:o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),yr.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=Jh,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",g=>{t.setValue(e,{value:g.target.value}),this.setPropertyOnSiblings(s,"value",g.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",g=>{var A;const m=(A=this.data.defaultFieldValue)!=null?A:"";s.value=c.userValue=m,c.formattedValue=null});let f=g=>{const{formattedValue:m}=c;m!=null&&(g.target.value=m),g.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",m=>{var y;if(c.focused)return;const{target:A}=m;c.userValue&&(A.value=c.userValue),c.lastCommittedValue=A.value,c.commitKey=1,(y=this.data.actions)!=null&&y.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",m=>{this.showElementAndHideCanvas(m.target);const A={value(y){var v;c.userValue=(v=y.detail.value)!=null?v:"",t.setValue(e,{value:c.userValue.toString()}),y.target.value=c.userValue},formattedValue(y){const{formattedValue:v}=y.detail;c.formattedValue=v,v!=null&&y.target!==document.activeElement&&(y.target.value=v),t.setValue(e,{formattedValue:v})},selRange(y){y.target.setSelectionRange(...y.detail.selRange)},charLimit:y=>{var E;const{charLimit:v}=y.detail,{target:w}=y;if(v===0){w.removeAttribute("maxLength");return}w.setAttribute("maxLength",v);let _=c.userValue;!_||_.length<=v||(_=_.slice(0,v),w.value=c.userValue=_,t.setValue(e,{value:_}),(E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:1,selStart:w.selectionStart,selEnd:w.selectionEnd}}))}};this._dispatchEventFromSandbox(A,m)}),s.addEventListener("keydown",m=>{var v;c.commitKey=1;let A=-1;if(m.key==="Escape"?A=0:m.key==="Enter"&&!this.data.multiLine?A=2:m.key==="Tab"&&(c.commitKey=3),A===-1)return;const{value:y}=m.target;c.lastCommittedValue!==y&&(c.lastCommittedValue=y,c.userValue=y,(v=this.linkService.eventBus)==null||v.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,willCommit:!0,commitKey:A,selStart:m.target.selectionStart,selEnd:m.target.selectionEnd}}))});const g=f;f=null,s.addEventListener("blur",m=>{var y,v;if(!c.focused||!m.relatedTarget)return;(y=this.data.actions)!=null&&y.Blur||(c.focused=!1);const{value:A}=m.target;c.userValue=A,c.lastCommittedValue!==A&&((v=this.linkService.eventBus)==null||v.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:c.commitKey,selStart:m.target.selectionStart,selEnd:m.target.selectionEnd}})),g(m)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",m=>{var C;c.lastCommittedValue=null;const{data:A,target:y}=m,{value:v,selectionStart:w,selectionEnd:_}=y;let E=w,S=_;switch(m.inputType){case"deleteWordBackward":{const P=v.substring(0,w).match(/\w*[^\w]*$/);P&&(E-=P[0].length);break}case"deleteWordForward":{const P=v.substring(w).match(/^[^\w]*\w*/);P&&(S+=P[0].length);break}case"deleteContentBackward":w===_&&(E-=1);break;case"deleteContentForward":w===_&&(S+=1);break}m.preventDefault(),(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,change:A||"",willCommit:!1,selStart:E,selEnd:S}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],m=>m.target.value)}if(f&&s.addEventListener("blur",f),this.data.comb){const m=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${m}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 gy extends wr{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class my extends wr{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 r=document.createElement("input");return yr.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=Jh,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s)){const c=l&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.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(r,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(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class hm extends wr{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 r=document.createElement("input");if(yr.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=Jh,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const c=a===h.detail.value;for(const f of this._getElementsByName(h.target.name)){const g=c&&f.id===s;f.domElement&&(f.domElement.checked=g),t.setValue(f.id,{value:g})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,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(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class by extends am{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 Ay extends wr{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");yr.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=Jh;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",c=>{const f=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===f});for(const c of this.data.options){const f=document.createElement("option");f.textContent=c.displayValue,f.value=c.exportValue,s.value.includes(c.exportValue)&&(f.setAttribute("selected",!0),r=!1),i.append(f)}let a=null;if(r){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),a=()=>{c.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=c=>{const f=c?"value":"textContent",{options:g,multiple:m}=i;return m?Array.prototype.filter.call(g,A=>A.selected).map(A=>A[f]):g.selectedIndex===-1?null:g[g.selectedIndex][f]};let l=o(!1);const h=c=>{const f=c.target.options;return Array.prototype.map.call(f,g=>({displayValue:g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const f={value(g){a==null||a();const m=g.detail.value,A=new Set(Array.isArray(m)?m:[m]);for(const y of i.options)y.selected=A.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(g){i.multiple=!0},remove(g){const m=i.options,A=g.detail.remove;m[A].selected=!1,i.remove(A),m.length>0&&Array.prototype.findIndex.call(m,v=>v.selected)===-1&&(m[0].selected=!0),t.setValue(e,{value:o(!0),items:h(g)}),l=o(!1)},clear(g){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(g){const{index:m,displayValue:A,exportValue:y}=g.detail.insert,v=i.children[m],w=document.createElement("option");w.textContent=A,w.value=y,v?v.before(w):i.append(w),t.setValue(e,{value:o(!0),items:h(g)}),l=o(!1)},items(g){const{items:m}=g.detail;for(;i.length!==0;)i.remove(0);for(const A of m){const{displayValue:y,exportValue:v}=A,w=document.createElement("option");w.textContent=y,w.value=v,i.append(w)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(g)}),l=o(!1)},indices(g){const m=new Set(g.detail.indices);for(const A of g.target.options)A.selected=m.has(A.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(f,c)}),i.addEventListener("input",c=>{var m;const f=o(!0),g=o(!1);t.setValue(e,{value:f}),c.preventDefault(),(m=this.linkService.eventBus)==null||m.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:g,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):i.addEventListener("input",function(c){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class If extends At{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:At._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new yy({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=>`${dp}${s}`).join(",")),this.container}}var Sa,Bd,Hd,Ea,$n,gt,zs,Ca,Ql,Jl,xa,$s,$e,Gs,Zl,Vs,th,Gn,Vn,Ta,yc,eh,Df,zd,cm,$d,dm,Gd,um,Vd,fm,Pa,wc,Ra,vc,sh,Ff;class yy{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:f}){u(this,Ta);u(this,eh);u(this,zd);u(this,$d);u(this,Gd);u(this,Vd);u(this,Pa);u(this,Ra);u(this,sh);u(this,Sa,b(this,Gd,um).bind(this));u(this,Bd,b(this,sh,Ff).bind(this));u(this,Hd,b(this,Ra,vc).bind(this));u(this,Ea,b(this,Pa,wc).bind(this));u(this,$n,null);u(this,gt,null);u(this,zs,null);u(this,Ca,null);u(this,Ql,null);u(this,Jl,null);u(this,xa,null);u(this,$s,!1);u(this,$e,null);u(this,Gs,null);u(this,Zl,null);u(this,Vs,null);u(this,th,null);u(this,Gn,null);u(this,Vn,!1);var g;p(this,gt,t),p(this,th,i),p(this,zs,a),p(this,Vs,o),p(this,Jl,l),p(this,$n,e),p(this,Zl,h),p(this,xa,c),p(this,Ql,s),p(this,Ca,pp.toDateObject(r)),this.trigger=s.flatMap(m=>m.getElementsToTriggerPopup());for(const m of this.trigger)m.addEventListener("click",n(this,Ea)),m.addEventListener("mouseenter",n(this,Hd)),m.addEventListener("mouseleave",n(this,Bd)),m.classList.add("popupTriggerArea");for(const m of s)(g=m.container)==null||g.addEventListener("keydown",n(this,Sa));n(this,gt).hidden=!0,f&&b(this,Pa,wc).call(this)}render(){if(n(this,$e))return;const t=p(this,$e,document.createElement("div"));if(t.className="popup",n(this,$n)){const r=t.style.outlineColor=F.makeHexColor(...n(this,$n));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`:t.style.backgroundColor=F.makeHexColor(...n(this,$n).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}=n(this,th),t.append(e),n(this,Ca)){const r=document.createElement("span");r.classList.add("popupDate"),r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,Ca).valueOf()})),e.append(r)}const i=n(this,Ta,yc);if(i)rm.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const r=this._formatContents(n(this,zs));t.append(r)}n(this,gt).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 r=0,a=i.length;r<a;++r){const o=i[r];s.append(document.createTextNode(o)),r<a-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popupContent:e}){var s;n(this,Gn)||p(this,Gn,{contentsObj:n(this,zs),richText:n(this,Vs)}),t&&p(this,Gs,null),e&&(p(this,Vs,b(this,$d,dm).call(this,e)),p(this,zs,null)),(s=n(this,$e))==null||s.remove(),p(this,$e,null)}resetEdited(){var t;n(this,Gn)&&({contentsObj:qt(this,zs)._,richText:qt(this,Vs)._}=n(this,Gn),p(this,Gn,null),(t=n(this,$e))==null||t.remove(),p(this,$e,null),p(this,Gs,null))}forceHide(){p(this,Vn,this.isVisible),n(this,Vn)&&(n(this,gt).hidden=!0)}maybeShow(){n(this,Vn)&&(n(this,$e)||b(this,Ra,vc).call(this),p(this,Vn,!1),n(this,gt).hidden=!1)}get isVisible(){return n(this,gt).hidden===!1}}Sa=new WeakMap,Bd=new WeakMap,Hd=new WeakMap,Ea=new WeakMap,$n=new WeakMap,gt=new WeakMap,zs=new WeakMap,Ca=new WeakMap,Ql=new WeakMap,Jl=new WeakMap,xa=new WeakMap,$s=new WeakMap,$e=new WeakMap,Gs=new WeakMap,Zl=new WeakMap,Vs=new WeakMap,th=new WeakMap,Gn=new WeakMap,Vn=new WeakMap,Ta=new WeakSet,yc=function(){const t=n(this,Vs),e=n(this,zs);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,Vs).html||null},eh=new WeakSet,Df=function(){var t,e,s;return((s=(e=(t=n(this,Ta,yc))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},zd=new WeakSet,cm=function(){var t,e,s;return((s=(e=(t=n(this,Ta,yc))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},$d=new WeakSet,dm=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,zd,cm),fontSize:n(this,eh,Df)?`calc(${n(this,eh,Df)}px * var(--scale-factor))`:""}};for(const r of t.split(`
`))e.push({name:"span",value:r,attributes:i});return s},Gd=new WeakSet,um=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,$s))&&b(this,Pa,wc).call(this)},Vd=new WeakSet,fm=function(){if(n(this,Gs)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,Jl);let a=!!n(this,xa),o=a?n(this,xa):n(this,Zl);for(const A of n(this,Ql))if(!o||F.intersect(A.data.rect,o)!==null){o=A.data.rect,a=!0;break}const l=F.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),h=5,c=a?o[2]-o[0]+h:0,f=l[0]+c,g=l[1];p(this,Gs,[100*(f-i)/e,100*(g-r)/s]);const{style:m}=n(this,gt);m.left=`${n(this,Gs)[0]}%`,m.top=`${n(this,Gs)[1]}%`},Pa=new WeakSet,wc=function(){p(this,$s,!n(this,$s)),n(this,$s)?(b(this,Ra,vc).call(this),n(this,gt).addEventListener("click",n(this,Ea)),n(this,gt).addEventListener("keydown",n(this,Sa))):(b(this,sh,Ff).call(this),n(this,gt).removeEventListener("click",n(this,Ea)),n(this,gt).removeEventListener("keydown",n(this,Sa)))},Ra=new WeakSet,vc=function(){n(this,$e)||this.render(),this.isVisible?n(this,$s)&&n(this,gt).classList.add("focused"):(b(this,Vd,fm).call(this),n(this,gt).hidden=!1,n(this,gt).style.zIndex=parseInt(n(this,gt).style.zIndex)+1e3)},sh=new WeakSet,Ff=function(){n(this,gt).classList.remove("focused"),!(n(this,$s)||!this.isVisible)&&(n(this,gt).hidden=!0,n(this,gt).style.zIndex=parseInt(n(this,gt).style.zIndex)-1e3)};class pm extends At{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=V.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 ih;class wy extends At{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});u(this,ih,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:s,height:i}=zi(e.rect),r=this.svgFactory.create(s,i,!0),a=p(this,ih,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"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,ih)}addHighlightArea(){this.container.classList.add("highlightArea")}}ih=new WeakMap;var nh;class vy extends At{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});u(this,nh,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:s,height:i}=zi(e.rect),r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,nh,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"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,nh)}addHighlightArea(){this.container.classList.add("highlightArea")}}nh=new WeakMap;var rh;class _y extends At{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});u(this,rh,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:s,height:i}=zi(e.rect),r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,rh,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"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,rh)}addHighlightArea(){this.container.classList.add("highlightArea")}}rh=new WeakMap;var ah;class gm extends At{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});u(this,ah,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:r}}=this;if(!s)return this.container;const{width:a,height:o}=zi(e),l=this.svgFactory.create(a,o,!0);let h=[];for(let f=0,g=s.length;f<g;f+=2){const m=s[f]-e[0],A=e[3]-s[f+1];h.push(`${m},${A}`)}h=h.join(" ");const c=p(this,ah,this.svgFactory.createElement(this.svgElementName));return c.setAttribute("points",h),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),l.append(c),this.container.append(l),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,ah)}addHighlightArea(){this.container.classList.add("highlightArea")}}ah=new WeakMap;class Sy extends gm{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ey extends At{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 oh,Un,lh,Nf;class yp extends At{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});u(this,lh);u(this,oh,null);u(this,Un,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?V.HIGHLIGHT:V.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:h}=b(this,lh,Nf).call(this,s,e),c=this.svgFactory.create(l,h,!0),f=p(this,oh,this.svgFactory.createElement("svg:g"));c.append(f),f.setAttribute("stroke-width",r.width||1),f.setAttribute("stroke-linecap","round"),f.setAttribute("stroke-linejoin","round"),f.setAttribute("stroke-miterlimit",10),f.setAttribute("stroke","transparent"),f.setAttribute("fill","transparent"),f.setAttribute("transform",o);for(let g=0,m=i.length;g<m;g++){const A=this.svgFactory.createElement(this.svgElementName);n(this,Un).push(A),A.setAttribute("points",i[g].join(",")),f.append(A)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:i,rect:r}=e,a=n(this,oh);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,Un).length;o<l;o++)n(this,Un)[o].setAttribute("points",i[o].join(","));if(r){const{transform:o,width:l,height:h}=b(this,lh,Nf).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,Un)}addHighlightArea(){this.container.classList.add("highlightArea")}}oh=new WeakMap,Un=new WeakMap,lh=new WeakSet,Nf=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class mm extends At{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=V.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Cy extends At{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 xy extends At{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 Ty extends At{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 bm extends At{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=V.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 hh,ch,Of;class Py extends At{constructor(e){var i;super(e,{isRenderable:!0});u(this,ch);u(this,hh,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",ys({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",b(this,ch,Of).bind(this)),p(this,hh,i);const{isMac:r}=te.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,ch,Of).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,hh)}addHighlightArea(){this.container.classList.add("highlightArea")}}hh=new WeakMap,ch=new WeakSet,Of=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var dh,jn,Wn,uh,Ud,Am,fh,Bf;class Ry{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:a,structTreeLayer:o}){u(this,Ud);u(this,fh);u(this,dh,null);u(this,jn,null);u(this,Wn,new Map);u(this,uh,null);this.div=t,p(this,dh,e),p(this,jn,s),p(this,uh,o||null),this.page=r,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return n(this,Wn).size>0}render(t){return I(this,null,function*(){var a;const{annotations:e}=t,s=this.div;br(s,this.viewport);const i=new Map,r={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Ap,annotationStorage:t.annotationStorage||new mp,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===vt.POPUP;if(l){const f=i.get(o.id);if(!f)continue;r.elements=f}else{const{width:f,height:g}=zi(o.rect);if(f<=0||g<=0)continue}r.data=o;const h=uy.create(r);if(!h.isRenderable)continue;if(!l&&o.popupRef){const f=i.get(o.popupRef);f?f.push(h):i.set(o.popupRef,[h])}const c=h.render();o.hidden&&(c.style.visibility="hidden"),yield b(this,Ud,Am).call(this,c,o.id),h._isEditable&&(n(this,Wn).set(h.data.id,h),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(h))}b(this,fh,Bf).call(this)})}update({viewport:t}){const e=this.div;this.viewport=t,br(e,{rotation:t.rotation}),b(this,fh,Bf).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(n(this,Wn).values())}getEditableAnnotation(t){return n(this,Wn).get(t)}}dh=new WeakMap,jn=new WeakMap,Wn=new WeakMap,uh=new WeakMap,Ud=new WeakSet,Am=function(t,e){return I(this,null,function*(){var a,o;const s=t.firstChild||t,i=s.id=`${dp}${e}`,r=yield(a=n(this,uh))==null?void 0:a.getAriaAttributes(i);if(r)for(const[l,h]of r)s.setAttribute(l,h);this.div.append(t),(o=n(this,dh))==null||o.moveElementInDOM(this.div,t,s,!1)})},fh=new WeakSet,Bf=function(){if(!n(this,jn))return;const t=this.div;for(const[e,s]of n(this,jn)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:r}=i;r?r.nodeName==="CANVAS"?r.replaceWith(s):r.classList.contains("annotationContent")?r.after(s):r.before(s):i.append(s)}n(this,jn).clear()};const ic=/\r\n?|\n/g;var Ge,pe,ph,Xn,ge,jd,ym,Wd,wm,Xd,vm,ka,_c,Ma,Sc,La,Ec,qd,_m,gh,zf,Yd,Sm;const et=class et extends ut{constructor(e){super(_r(ys({},e),{name:"freeTextEditor"}));u(this,jd);u(this,Wd);u(this,Xd);u(this,ka);u(this,La);u(this,qd);u(this,Yd);u(this,Ge,void 0);u(this,pe,"");u(this,ph,`${this.id}-editor`);u(this,Xn,null);u(this,ge,void 0);p(this,Ge,e.color||et._defaultColor||ut._defaultLineColor),p(this,ge,e.fontSize||et._defaultFontSize)}static get _keyboardManager(){const e=et.prototype,s=a=>a.isEmpty(),i=Ar.TRANSLATE_SMALL,r=Ar.TRANSLATE_BIG;return X(this,"_keyboardManager",new Qh([[["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:[-r,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){ut.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case Y.FREETEXT_SIZE:et._defaultFontSize=s;break;case Y.FREETEXT_COLOR:et._defaultColor=s;break}}updateParams(e,s){switch(e){case Y.FREETEXT_SIZE:b(this,jd,ym).call(this,s);break;case Y.FREETEXT_COLOR:b(this,Wd,wm).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Y.FREETEXT_SIZE,et._defaultFontSize],[Y.FREETEXT_COLOR,et._defaultColor||ut._defaultLineColor]]}get propertiesToUpdate(){return[[Y.FREETEXT_SIZE,n(this,ge)],[Y.FREETEXT_COLOR,n(this,Ge)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-et._internalPadding*e,-(et._internalPadding+n(this,ge))*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(V.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,Xn,new AbortController);const e=this._uiManager.combinedSignal(n(this,Xn));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",n(this,ph)),this._isDraggable=!0,(e=n(this,Xn))==null||e.abort(),p(this,Xn,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(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.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=n(this,pe),s=p(this,pe,b(this,Xd,vm).call(this).trimEnd());if(e===s)return;const i=r=>{if(p(this,pe,r),!r){this.remove();return}b(this,La,Ec).call(this),this._uiManager.rebuild(this),b(this,ka,_c).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,ka,_c).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){et._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",n(this,ph)),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(${n(this,ge)}px * var(--scale-factor))`,i.color=n(this,Ge),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Nc(this,this.div,["dblclick","keydown"]),this.width){const[r,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[c,f]=this.pageDimensions,[g,m]=this.pageTranslation;let A,y;switch(this.rotation){case 0:A=e+(o[0]-g)/c,y=s+this.height-(o[1]-m)/f;break;case 90:A=e+(o[0]-g)/c,y=s-(o[1]-m)/f,[l,h]=[h,-l];break;case 180:A=e-this.width+(o[0]-g)/c,y=s-(o[1]-m)/f,[l,h]=[-l,-h];break;case 270:A=e+(o[0]-g-this.height*f)/c,y=s+(o[1]-m-this.width*c)/f,[l,h]=[-h,l];break}this.setAt(A*r,y*a,l,h)}else this.setAt(e*r,s*a,this.width*r,this.height*a);b(this,La,Ec).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,v;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=b(A=et,gh,zf).call(A,s.getData("text")||"").replaceAll(ic,`
`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,c=[],f=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(f.push(l.nodeValue.slice(h).replaceAll(ic,"")),w!==this.editorDiv){let _=c;for(const E of this.editorDiv.childNodes){if(E===w){_=f;continue}_.push(b(y=et,Ma,Sc).call(y,E))}}c.push(l.nodeValue.slice(0,h).replaceAll(ic,""))}else if(l===this.editorDiv){let w=c,_=0;for(const E of this.editorDiv.childNodes)_++===h&&(w=f),w.push(b(v=et,Ma,Sc).call(v,E))}p(this,pe,`${c.join(`
`)}${r}${f.join(`
`)}`),b(this,La,Ec).call(this);const g=new Range;let m=c.reduce((w,_)=>w+_.length,0);for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const _=w.nodeValue.length;if(m<=_){g.setStart(w,m),g.setEnd(w,m);break}m-=_}a.removeAllRanges(),a.addRange(g)}get contentDiv(){return this.editorDiv}static deserialize(e,s,i){return I(this,null,function*(){var o;let r=null;if(e instanceof pm){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:f,id:g,popupRef:m},textContent:A,textPosition:y,parent:{page:{pageNumber:v}}}=e;if(!A||A.length===0)return null;r=e={annotationType:V.FREETEXT,color:Array.from(h),fontSize:l,value:A.join(`
`),position:y,pageIndex:v-1,rect:c.slice(0),rotation:f,id:g,deleted:!1,popupRef:m}}const a=yield ji(et,this,"deserialize").call(this,e,s,i);return p(a,ge,e.fontSize),p(a,Ge,F.makeHexColor(...e.color)),p(a,pe,b(o=et,gh,zf).call(o,e.value)),a.annotationElementId=e.id||null,a._initialData=r,a})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=et._internalPadding*this.parentScale,i=this.getRect(s,s),r=ut._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:n(this,Ge)),a={annotationType:V.FREETEXT,color:r,fontSize:n(this,ge),value:b(this,qd,_m).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!b(this,Yd,Sm).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(${n(this,ge)}px * var(--scale-factor))`,i.color=n(this,Ge),s.replaceChildren();for(const a of n(this,pe).split(`
`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const r=et._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(r,r),popupContent:n(this,pe)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};Ge=new WeakMap,pe=new WeakMap,ph=new WeakMap,Xn=new WeakMap,ge=new WeakMap,jd=new WeakSet,ym=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-n(this,ge))*this.parentScale),p(this,ge,r),b(this,ka,_c).call(this)},i=n(this,ge);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Y.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Wd=new WeakSet,wm=function(e){const s=r=>{p(this,Ge,this.editorDiv.style.color=r)},i=n(this,Ge);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Y.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Xd=new WeakSet,vm=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(b(i=et,Ma,Sc).call(i,r)),s=r);return e.join(`
`)},ka=new WeakSet,_c=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.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()},Ma=new WeakSet,Sc=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(ic,"")},La=new WeakSet,Ec=function(){if(this.editorDiv.replaceChildren(),!!n(this,pe))for(const e of n(this,pe).split(`
`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},qd=new WeakSet,_m=function(){return n(this,pe).replaceAll(" "," ")},gh=new WeakSet,zf=function(e){return e.replaceAll(" "," ")},Yd=new WeakSet,Sm=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},u(et,Ma),u(et,gh),O(et,"_freeTextDefaultContent",""),O(et,"_internalPadding",0),O(et,"_defaultColor",null),O(et,"_defaultFontSize",10),O(et,"_type","freetext"),O(et,"_editorType",V.FREETEXT);let Hf=et;class L{toSVGPath(){st("Abstract method `toSVGPath` must be implemented.")}get box(){st("Abstract getter `box` must be implemented.")}serialize(t,e){st("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,i,r,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}}O(L,"PRECISION",1e-4);var me,Ve,Ia,Da,ds,W,qn,Yn,mh,bh,Fa,Na,Ti,Ah,Kd,Qd,Kn,Po,Jd,Em,Zd,Cm,tu,xm,eu,Tm,su,Pm,iu,Rm;const Es=class Es{constructor({x:t,y:e},s,i,r,a,o=0){u(this,Kn);u(this,Jd);u(this,Zd);u(this,tu);u(this,eu);u(this,su);u(this,iu);u(this,me,void 0);u(this,Ve,[]);u(this,Ia,void 0);u(this,Da,void 0);u(this,ds,[]);u(this,W,new Float32Array(18));u(this,qn,void 0);u(this,Yn,void 0);u(this,mh,void 0);u(this,bh,void 0);u(this,Fa,void 0);u(this,Na,void 0);u(this,Ti,[]);p(this,me,s),p(this,Na,r*i),p(this,Da,a),n(this,W).set([NaN,NaN,NaN,NaN,t,e],6),p(this,Ia,o),p(this,bh,n(Es,Ah)*i),p(this,mh,n(Es,Qd)*i),p(this,Fa,i),n(this,Ti).push(t,e)}isEmpty(){return isNaN(n(this,W)[8])}add({x:t,y:e}){var N;p(this,qn,t),p(this,Yn,e);const[s,i,r,a]=n(this,me);let[o,l,h,c]=n(this,W).subarray(8,12);const f=t-h,g=e-c,m=Math.hypot(f,g);if(m<n(this,mh))return!1;const A=m-n(this,bh),y=A/m,v=y*f,w=y*g;let _=o,E=l;o=h,l=c,h+=v,c+=w,(N=n(this,Ti))==null||N.push(t,e);const S=-w/A,C=v/A,P=S*n(this,Na),T=C*n(this,Na);return n(this,W).set(n(this,W).subarray(2,8),0),n(this,W).set([h+P,c+T],4),n(this,W).set(n(this,W).subarray(14,18),12),n(this,W).set([h-P,c-T],16),isNaN(n(this,W)[6])?(n(this,ds).length===0&&(n(this,W).set([o+P,l+T],2),n(this,ds).push(NaN,NaN,NaN,NaN,(o+P-s)/r,(l+T-i)/a),n(this,W).set([o-P,l-T],14),n(this,Ve).push(NaN,NaN,NaN,NaN,(o-P-s)/r,(l-T-i)/a)),n(this,W).set([_,E,o,l,h,c],6),!this.isEmpty()):(n(this,W).set([_,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,_-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=n(this,W).subarray(2,6),n(this,ds).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,_,E]=n(this,W).subarray(14,18),n(this,Ve).push(NaN,NaN,NaN,NaN,((_+o)/2-s)/r,((E+l)/2-i)/a),!0):([_,E,o,l,h,c]=n(this,W).subarray(0,6),n(this,ds).push(((_+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),[h,c,o,l,_,E]=n(this,W).subarray(12,18),n(this,Ve).push(((_+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,ds),e=n(this,Ve);if(isNaN(n(this,W)[6])&&!this.isEmpty())return b(this,Jd,Em).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]}`);b(this,tu,xm).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 b(this,Zd,Cm).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new km(t,e,s,i,r,a)}getOutlines(){var f,g;const t=n(this,ds),e=n(this,Ve),s=n(this,W),[i,r,a,o]=n(this,me),l=new Float32Array(((g=(f=n(this,Ti))==null?void 0:f.length)!=null?g:0)+2);for(let m=0,A=l.length-2;m<A;m+=2)l[m]=(n(this,Ti)[m]-i)/a,l[m+1]=(n(this,Ti)[m+1]-r)/o;if(l[l.length-2]=(n(this,qn)-i)/a,l[l.length-1]=(n(this,Yn)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,eu,Tm).call(this,l);const h=new Float32Array(n(this,ds).length+24+n(this,Ve).length);let c=t.length;for(let m=0;m<c;m+=2){if(isNaN(t[m])){h[m]=h[m+1]=NaN;continue}h[m]=t[m],h[m+1]=t[m+1]}c=b(this,iu,Rm).call(this,h,c);for(let m=e.length-6;m>=6;m-=6)for(let A=0;A<6;A+=2){if(isNaN(e[m+A])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[m+A],h[c+1]=e[m+A+1],c+=2}return b(this,su,Pm).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,me),n(this,Fa),n(this,Ia),n(this,Da))}};me=new WeakMap,Ve=new WeakMap,Ia=new WeakMap,Da=new WeakMap,ds=new WeakMap,W=new WeakMap,qn=new WeakMap,Yn=new WeakMap,mh=new WeakMap,bh=new WeakMap,Fa=new WeakMap,Na=new WeakMap,Ti=new WeakMap,Ah=new WeakMap,Kd=new WeakMap,Qd=new WeakMap,Kn=new WeakSet,Po=function(){const t=n(this,W).subarray(4,6),e=n(this,W).subarray(16,18),[s,i,r,a]=n(this,me);return[(n(this,qn)+(t[0]-e[0])/2-s)/r,(n(this,Yn)+(t[1]-e[1])/2-i)/a,(n(this,qn)+(e[0]-t[0])/2-s)/r,(n(this,Yn)+(e[1]-t[1])/2-i)/a]},Jd=new WeakSet,Em=function(){const[t,e,s,i]=n(this,me),[r,a,o,l]=b(this,Kn,Po).call(this);return`M${(n(this,W)[2]-t)/s} ${(n(this,W)[3]-e)/i} L${(n(this,W)[4]-t)/s} ${(n(this,W)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,W)[16]-t)/s} ${(n(this,W)[17]-e)/i} L${(n(this,W)[14]-t)/s} ${(n(this,W)[15]-e)/i} Z`},Zd=new WeakSet,Cm=function(t){const e=n(this,Ve);t.push(`L${e[4]} ${e[5]} Z`)},tu=new WeakSet,xm=function(t){const[e,s,i,r]=n(this,me),a=n(this,W).subarray(4,6),o=n(this,W).subarray(16,18),[l,h,c,f]=b(this,Kn,Po).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${f} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},eu=new WeakSet,Tm=function(t){const e=n(this,W),[s,i,r,a]=n(this,me),[o,l,h,c]=b(this,Kn,Po).call(this),f=new Float32Array(36);return f.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(f,t,n(this,me),n(this,Fa),n(this,Ia),n(this,Da))},su=new WeakSet,Pm=function(t,e){const s=n(this,Ve);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},iu=new WeakSet,Rm=function(t,e){const s=n(this,W).subarray(4,6),i=n(this,W).subarray(16,18),[r,a,o,l]=n(this,me),[h,c,f,g]=b(this,Kn,Po).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,f,g,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},u(Es,Ah,8),u(Es,Kd,2),u(Es,Qd,n(Es,Ah)+n(Es,Kd));let Hc=Es;var Oa,Qn,Us,yh,be,wh,bt,nu,Mm;class km extends L{constructor(e,s,i,r,a,o){super();u(this,nu);u(this,Oa,void 0);u(this,Qn,new Float32Array(4));u(this,Us,void 0);u(this,yh,void 0);u(this,be,void 0);u(this,wh,void 0);u(this,bt,void 0);p(this,bt,e),p(this,be,s),p(this,Oa,i),p(this,wh,r),p(this,Us,a),p(this,yh,o),this.lastPoint=[NaN,NaN],b(this,nu,Mm).call(this,o);const[l,h,c,f]=n(this,Qn);for(let g=0,m=e.length;g<m;g+=2)e[g]=(e[g]-l)/c,e[g+1]=(e[g+1]-h)/f;for(let g=0,m=s.length;g<m;g+=2)s[g]=(s[g]-l)/c,s[g+1]=(s[g+1]-h)/f}toSVGPath(){const e=[`M${n(this,bt)[4]} ${n(this,bt)[5]}`];for(let s=6,i=n(this,bt).length;s<i;s+=6){if(isNaN(n(this,bt)[s])){e.push(`L${n(this,bt)[s+4]} ${n(this,bt)[s+5]}`);continue}e.push(`C${n(this,bt)[s]} ${n(this,bt)[s+1]} ${n(this,bt)[s+2]} ${n(this,bt)[s+3]} ${n(this,bt)[s+4]} ${n(this,bt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,r],a){const o=i-e,l=r-s;let h,c;switch(a){case 0:h=L._rescale(n(this,bt),e,r,o,-l),c=L._rescale(n(this,be),e,r,o,-l);break;case 90:h=L._rescaleAndSwap(n(this,bt),e,s,o,l),c=L._rescaleAndSwap(n(this,be),e,s,o,l);break;case 180:h=L._rescale(n(this,bt),i,s,-o,l),c=L._rescale(n(this,be),i,s,-o,l);break;case 270:h=L._rescaleAndSwap(n(this,bt),i,r,-o,-l),c=L._rescaleAndSwap(n(this,be),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,Qn)}newOutliner(e,s,i,r,a,o=0){return new Hc(e,s,i,r,a,o)}getNewOutline(e,s){const[i,r,a,o]=n(this,Qn),[l,h,c,f]=n(this,Oa),g=a*c,m=o*f,A=i*c+l,y=r*f+h,v=this.newOutliner({x:n(this,be)[0]*g+A,y:n(this,be)[1]*m+y},n(this,Oa),n(this,wh),e,n(this,yh),s!=null?s:n(this,Us));for(let w=2;w<n(this,be).length;w+=2)v.add({x:n(this,be)[w]*g+A,y:n(this,be)[w+1]*m+y});return v.getOutlines()}}Oa=new WeakMap,Qn=new WeakMap,Us=new WeakMap,yh=new WeakMap,be=new WeakMap,wh=new WeakMap,bt=new WeakMap,nu=new WeakSet,Mm=function(e){const s=n(this,bt);let i=s[4],r=s[5],a=i,o=r,l=i,h=r,c=i,f=r;const g=e?Math.max:Math.min;for(let A=6,y=s.length;A<y;A+=6){if(isNaN(s[A]))a=Math.min(a,s[A+4]),o=Math.min(o,s[A+5]),l=Math.max(l,s[A+4]),h=Math.max(h,s[A+5]),f<s[A+5]?(c=s[A+4],f=s[A+5]):f===s[A+5]&&(c=g(c,s[A+4]));else{const v=F.bezierBoundingBox(i,r,...s.slice(A,A+6));a=Math.min(a,v[0]),o=Math.min(o,v[1]),l=Math.max(l,v[2]),h=Math.max(h,v[3]),f<v[3]?(c=v[2],f=v[3]):f===v[3]&&(c=g(c,v[2]))}i=s[A+4],r=s[A+5]}const m=n(this,Qn);m[0]=a-n(this,Us),m[1]=o-n(this,Us),m[2]=l-a+2*n(this,Us),m[3]=h-o+2*n(this,Us),this.lastPoint=[c,f]};var vh,_h,Pi,Ue,ru,Lm,Ba,Cc,au,Im,ou,Dm,Sh,Gf;class $f{constructor(t,e=0,s=0,i=!0){u(this,ru);u(this,Ba);u(this,au);u(this,ou);u(this,Sh);u(this,vh,void 0);u(this,_h,void 0);u(this,Pi,[]);u(this,Ue,[]);let r=1/0,a=-1/0,o=1/0,l=-1/0;const c=uo(10,-4);for(const{x:w,y:_,width:E,height:S}of t){const C=Math.floor((w-e)/c)*c,P=Math.ceil((w+E+e)/c)*c,T=Math.floor((_-e)/c)*c,k=Math.ceil((_+S+e)/c)*c,N=[C,T,k,!0],$=[P,T,k,!1];n(this,Pi).push(N,$),r=Math.min(r,C),a=Math.max(a,P),o=Math.min(o,T),l=Math.max(l,k)}const f=a-r+2*s,g=l-o+2*s,m=r-s,A=o-s,y=n(this,Pi).at(i?-1:-2),v=[y[0],y[2]];for(const w of n(this,Pi)){const[_,E,S]=w;w[0]=(_-m)/f,w[1]=(E-A)/g,w[2]=(S-A)/g}p(this,vh,new Float32Array([m,A,f,g])),p(this,_h,v)}getOutlines(){n(this,Pi).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,Pi))e[3]?(t.push(...b(this,Sh,Gf).call(this,e)),b(this,au,Im).call(this,e)):(b(this,ou,Dm).call(this,e),t.push(...b(this,Sh,Gf).call(this,e)));return b(this,ru,Lm).call(this,t)}}vh=new WeakMap,_h=new WeakMap,Pi=new WeakMap,Ue=new WeakMap,ru=new WeakSet,Lm=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,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],h=e[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const i=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,f]=a;s.delete(a);let g=o,m=l;for(r=[o,h],i.push(r);;){let A;if(s.has(c))A=c;else if(s.has(f))A=f;else break;s.delete(A),[o,l,h,c,f]=A,g!==o&&(r.push(g,m,o,m===l?l:h),g=o),m=m===l?h:l}r.push(g,m)}return new ky(i,n(this,vh),n(this,_h))},Ba=new WeakSet,Cc=function(t){const e=n(this,Ue);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:i=r-1}return i+1},au=new WeakSet,Im=function([,t,e]){const s=b(this,Ba,Cc).call(this,t);n(this,Ue).splice(s,0,[t,e])},ou=new WeakSet,Dm=function([,t,e]){const s=b(this,Ba,Cc).call(this,t);for(let i=s;i<n(this,Ue).length;i++){const[r,a]=n(this,Ue)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ue).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,Ue)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ue).splice(i,1);return}}},Sh=new WeakSet,Gf=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,Ba,Cc).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,Ue)[o];for(let c=0,f=r.length;c<f;c++){const[,g,m]=r[c];if(!(h<=g||m<=l)){if(g>=l){if(m>h)r[c][1]=h;else{if(f===1)return[];r.splice(c,1),c--,f--}continue}r[c][2]=l,m>h&&r.push([e,h,m])}}}return r};var Eh,Ha;class ky extends L{constructor(e,s,i){super();u(this,Eh,void 0);u(this,Ha,void 0);p(this,Ha,e),p(this,Eh,s),this.lastPoint=i}toSVGPath(){const e=[];for(const s of n(this,Ha)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,r],a){const o=[],l=i-e,h=r-s;for(const c of n(this,Ha)){const f=new Array(c.length);for(let g=0;g<c.length;g+=2)f[g]=e+c[g]*l,f[g+1]=r-c[g+1]*h;o.push(f)}return o}get box(){return n(this,Eh)}get classNamesForOutlining(){return["highlightOutline"]}}Eh=new WeakMap,Ha=new WeakMap;class Vf extends Hc{newFreeDrawOutline(t,e,s,i,r,a){return new My(t,e,s,i,r,a)}}class My extends km{newOutliner(t,e,s,i,r,a=0){return new Vf(t,e,s,i,r,a)}}var je,Jn,za,St,Ch,$a,xh,Th,Ri,We,Ga,Ph,Rh,Uf,kh,jf,Mh,Wf,js,qi,lu,Fm,us,ei;const ie=class ie{constructor({editor:t=null,uiManager:e=null}){u(this,Rh);u(this,kh);u(this,Mh);u(this,js);u(this,lu);u(this,us);u(this,je,null);u(this,Jn,null);u(this,za,void 0);u(this,St,null);u(this,Ch,!1);u(this,$a,!1);u(this,xh,null);u(this,Th,void 0);u(this,Ri,null);u(this,We,null);u(this,Ga,void 0);var s;t?(p(this,$a,!1),p(this,Ga,Y.HIGHLIGHT_COLOR),p(this,xh,t)):(p(this,$a,!0),p(this,Ga,Y.HIGHLIGHT_DEFAULT_COLOR)),p(this,We,(t==null?void 0:t._uiManager)||e),p(this,Th,n(this,We)._eventBus),p(this,za,(t==null?void 0:t.color)||((s=n(this,We))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),n(ie,Ph)||p(ie,Ph,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 X(this,"_keyboardManager",new Qh([[["Escape","mac+Escape"],ie.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ie.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ie.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ie.prototype._moveToPrevious],[["Home","mac+Home"],ie.prototype._moveToBeginning],[["End","mac+End"],ie.prototype._moveToEnd]]))}renderButton(){const t=p(this,je,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=n(this,We)._signal;t.addEventListener("click",b(this,js,qi).bind(this),{signal:e}),t.addEventListener("keydown",b(this,Mh,Wf).bind(this),{signal:e});const s=p(this,Jn,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=n(this,za),t.append(s),t}renderMainDropdown(){const t=p(this,St,b(this,Rh,Uf).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===n(this,je)){b(this,js,qi).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,kh,jf).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,us,ei)){b(this,js,qi).call(this,t);return}if(t.target===n(this,je)){(e=n(this,St).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,St))==null?void 0:e.firstChild)||t.target===n(this,je)){n(this,us,ei)&&this._hideDropdownFromKeyboard();return}n(this,us,ei)||b(this,js,qi).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,us,ei)){b(this,js,qi).call(this,t);return}(e=n(this,St).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,us,ei)){b(this,js,qi).call(this,t);return}(e=n(this,St).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,St))==null||t.classList.add("hidden"),(e=n(this,Ri))==null||e.abort(),p(this,Ri,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,$a)){if(!n(this,us,ei)){(t=n(this,xh))==null||t.unselect();return}this.hideDropdown(),n(this,je).focus({preventScroll:!0,focusVisible:n(this,Ch)})}}updateColor(t){if(n(this,Jn)&&(n(this,Jn).style.backgroundColor=t),!n(this,St))return;const e=n(this,We).highlightColors.values();for(const s of n(this,St).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=n(this,je))==null||t.remove(),p(this,je,null),p(this,Jn,null),(e=n(this,St))==null||e.remove(),p(this,St,null)}};je=new WeakMap,Jn=new WeakMap,za=new WeakMap,St=new WeakMap,Ch=new WeakMap,$a=new WeakMap,xh=new WeakMap,Th=new WeakMap,Ri=new WeakMap,We=new WeakMap,Ga=new WeakMap,Ph=new WeakMap,Rh=new WeakSet,Uf=function(){const t=document.createElement("div"),e=n(this,We)._signal;t.addEventListener("contextmenu",Ke,{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 n(this,We).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n(ie,Ph)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.setAttribute("aria-selected",i===n(this,za)),r.addEventListener("click",b(this,kh,jf).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,Mh,Wf).bind(this),{signal:e}),t},kh=new WeakSet,jf=function(t,e){e.stopPropagation(),n(this,Th).dispatch("switchannotationeditorparams",{source:this,type:n(this,Ga),value:t})},Mh=new WeakSet,Wf=function(t){ie._keyboardManager.exec(this,t)},js=new WeakSet,qi=function(t){if(n(this,us,ei)){this.hideDropdown();return}if(p(this,Ch,t.detail===0),n(this,Ri)||(p(this,Ri,new AbortController),window.addEventListener("pointerdown",b(this,lu,Fm).bind(this),{signal:n(this,We).combinedSignal(n(this,Ri))})),n(this,St)){n(this,St).classList.remove("hidden");return}const e=p(this,St,b(this,Rh,Uf).call(this));n(this,je).append(e)},lu=new WeakSet,Fm=function(t){var e;(e=n(this,St))!=null&&e.contains(t.target)||this.hideDropdown()},us=new WeakSet,ei=function(){return n(this,St)&&!n(this,St).classList.contains("hidden")},u(ie,Ph,null);let zc=ie;var Va,Lh,Ws,Zn,Ua,ae,Ih,Dh,tr,Re,Ae,Ft,ja,Xs,Ut,Wa,ke,Fh,Nh,Xf,Xa,xc,hu,Nm,cu,Om,du,Bm,Oh,qf,qs,Yi,ki,Pr,uu,Hm,qa,Tc,er,Ro,fu,zm,pu,$m,gu,Gm,mu,Vm,bu,Um;const q=class q extends ut{constructor(e){super(_r(ys({},e),{name:"highlightEditor"}));u(this,Nh);u(this,Xa);u(this,hu);u(this,cu);u(this,du);u(this,Oh);u(this,qs);u(this,uu);u(this,qa);u(this,er);u(this,fu);u(this,pu);u(this,bu);u(this,Va,null);u(this,Lh,0);u(this,Ws,void 0);u(this,Zn,null);u(this,Ua,null);u(this,ae,null);u(this,Ih,null);u(this,Dh,0);u(this,tr,null);u(this,Re,null);u(this,Ae,null);u(this,Ft,!1);u(this,ja,null);u(this,Xs,void 0);u(this,Ut,null);u(this,Wa,"");u(this,ke,void 0);u(this,Fh,"");this.color=e.color||q._defaultColor,p(this,ke,e.thickness||q._defaultThickness),p(this,Xs,e.opacity||q._defaultOpacity),p(this,Ws,e.boxes||null),p(this,Fh,e.methodOfCreation||""),p(this,Wa,e.text||""),this._isDraggable=!1,e.highlightId>-1?(p(this,Ft,!0),b(this,Xa,xc).call(this,e),b(this,qs,Yi).call(this)):n(this,Ws)&&(p(this,Va,e.anchorNode),p(this,Lh,e.anchorOffset),p(this,Ih,e.focusNode),p(this,Dh,e.focusOffset),b(this,Nh,Xf).call(this),b(this,qs,Yi).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=q.prototype;return X(this,"_keyboardManager",new Qh([[["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:n(this,Ft)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:n(this,ke),methodOfCreation:n(this,Fh)}}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;ut.initialize(e,s),q._defaultColor||(q._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case Y.HIGHLIGHT_DEFAULT_COLOR:q._defaultColor=s;break;case Y.HIGHLIGHT_THICKNESS:q._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,ja)}updateParams(e,s){switch(e){case Y.HIGHLIGHT_COLOR:b(this,hu,Nm).call(this,s);break;case Y.HIGHLIGHT_THICKNESS:b(this,cu,Om).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Y.HIGHLIGHT_DEFAULT_COLOR,q._defaultColor],[Y.HIGHLIGHT_THICKNESS,q._defaultThickness]]}get propertiesToUpdate(){return[[Y.HIGHLIGHT_COLOR,this.color||q._defaultColor],[Y.HIGHLIGHT_THICKNESS,n(this,ke)||q._defaultThickness],[Y.HIGHLIGHT_FREE,n(this,Ft)]]}addEditToolbar(){return I(this,null,function*(){const e=yield ji(q.prototype,this,"addEditToolbar").call(this);return e?(this._uiManager.highlightColors&&(p(this,Ua,new zc({editor:this})),e.addColorPicker(n(this,Ua))),e):null})}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(b(this,er,Ro).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,er,Ro).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){b(this,Oh,qf).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,qs,Yi).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?b(this,Oh,qf).call(this):e&&(b(this,qs,Yi).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 r,a,o;const{drawLayer:s}=this.parent;let i;n(this,Ft)?(e=(e-this.rotation+360)%360,i=b(r=q,ki,Pr).call(r,n(this,Re).box,e)):i=b(a=q,ki,Pr).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,Ae),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,Ut),{bbox:b(o=q,ki,Pr).call(o,n(this,ae).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,Wa)&&(e.setAttribute("aria-label",n(this,Wa)),e.setAttribute("role","mark")),n(this,Ft)?e.classList.add("free"):this.div.addEventListener("keydown",b(this,uu,Hm).bind(this),{signal:this._uiManager._signal});const s=p(this,tr,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,Zn);const[i,r]=this.parentDimensions;return this.setDims(this.width*i,this.height*r),Nc(this,n(this,tr),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,Ut),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,Ut),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,qa,Tc).call(this,!0);break;case 1:case 3:b(this,qa,Tc).call(this,!1);break}}select(){var e;super.select(),n(this,Ut)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,Ut),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,Ut)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,Ut),{rootClass:{selected:!1}}),n(this,Ft)||b(this,qa,Tc).call(this,!1))}get _mustFixPosition(){return!n(this,Ft)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,Ae),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,Ut),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:h,height:c}=i.getBoundingClientRect(),f=new AbortController,g=e.combinedSignal(f),m=A=>{f.abort(),b(this,mu,Vm).call(this,e,A)};window.addEventListener("blur",m,{signal:g}),window.addEventListener("pointerup",m,{signal:g}),window.addEventListener("pointerdown",Se,{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",Ke,{signal:g}),i.addEventListener("pointermove",b(this,gu,Gm).bind(this,e),{signal:g}),this._freeHighlight=new Vf({x:r,y:a},[o,l,h,c],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static deserialize(e,s,i){return I(this,null,function*(){var y,v,w,_;let r=null;if(e instanceof mm){const{data:{quadPoints:E,rect:S,rotation:C,id:P,color:T,opacity:k,popupRef:N},parent:{page:{pageNumber:$}}}=e;r=e={annotationType:V.HIGHLIGHT,color:Array.from(T),opacity:k,quadPoints:E,boxes:null,pageIndex:$-1,rect:S.slice(0),rotation:C,id:P,deleted:!1,popupRef:N}}else if(e instanceof yp){const{data:{inkLists:E,rect:S,rotation:C,id:P,color:T,borderStyle:{rawWidth:k},popupRef:N},parent:{page:{pageNumber:$}}}=e;r=e={annotationType:V.HIGHLIGHT,color:Array.from(T),thickness:k,inkLists:E,boxes:null,pageIndex:$-1,rect:S.slice(0),rotation:C,id:P,deleted:!1,popupRef:N}}const{color:a,quadPoints:o,inkLists:l,opacity:h}=e,c=yield ji(q,this,"deserialize").call(this,e,s,i);c.color=F.makeHexColor(...a),p(c,Xs,h||1),l&&p(c,ke,e.thickness),c.annotationElementId=e.id||null,c._initialData=r;const[f,g]=c.pageDimensions,[m,A]=c.pageTranslation;if(o){const E=p(c,Ws,[]);for(let S=0;S<o.length;S+=8)E.push({x:(o[S]-m)/f,y:1-(o[S+1]-A)/g,width:(o[S+2]-o[S])/f,height:(o[S+1]-o[S+5])/g});b(y=c,Nh,Xf).call(y),b(v=c,qs,Yi).call(v),c.rotate(c.rotation)}else if(l){p(c,Ft,!0);const E=l[0],S={x:E[0]-m,y:g-(E[1]-A)},C=new Vf(S,[0,0,f,g],1,n(c,ke)/2,!0,.001);for(let k=0,N=E.length;k<N;k+=2)S.x=E[k]-m,S.y=g-(E[k+1]-A),C.add(S);const{id:P,clipPathId:T}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);b(w=c,Xa,xc).call(w,{highlightOutlines:C.getOutlines(),highlightId:P,clipPathId:T}),b(_=c,qs,Yi).call(_)}return c})}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=this.getRect(0,0),i=ut._colorManager.convert(this.color),r={annotationType:V.HIGHLIGHT,color:i,opacity:n(this,Xs),thickness:n(this,ke),quadPoints:b(this,fu,zm).call(this),outlines:b(this,pu,$m).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:b(this,er,Ro).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!b(this,bu,Um).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Va=new WeakMap,Lh=new WeakMap,Ws=new WeakMap,Zn=new WeakMap,Ua=new WeakMap,ae=new WeakMap,Ih=new WeakMap,Dh=new WeakMap,tr=new WeakMap,Re=new WeakMap,Ae=new WeakMap,Ft=new WeakMap,ja=new WeakMap,Xs=new WeakMap,Ut=new WeakMap,Wa=new WeakMap,ke=new WeakMap,Fh=new WeakMap,Nh=new WeakSet,Xf=function(){const e=new $f(n(this,Ws),.001);p(this,Re,e.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,Re).box;const s=new $f(n(this,Ws),.0025,.001,this._uiManager.direction==="ltr");p(this,ae,s.getOutlines());const{lastPoint:i}=n(this,ae);p(this,ja,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Xa=new WeakSet,xc=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var f,g;p(this,Re,e);const r=1.5;if(p(this,ae,e.getNewOutline(n(this,ke)/2+r,.0025)),s>=0)p(this,Ae,s),p(this,Zn,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),p(this,Ut,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,ae).box,path:{d:n(this,ae).toSVGPath()}},!0));else if(this.parent){const m=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,Ae),{bbox:b(f=q,ki,Pr).call(f,n(this,Re).box,(m-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,Ut),{bbox:b(g=q,ki,Pr).call(g,n(this,ae).box,m),path:{d:n(this,ae).toSVGPath()}})}const[a,o,l,h]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[m,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/m,this.height=h*m/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[m,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/m,this.height=h*m/A;break}}const{lastPoint:c}=n(this,ae);p(this,ja,[(c[0]-a)/l,(c[1]-o)/h])},hu=new WeakSet,Nm=function(e){const s=(a,o)=>{var l,h;this.color=a,p(this,Xs,o),(l=this.parent)==null||l.drawLayer.updateProperties(n(this,Ae),{root:{fill:a,"fill-opacity":o}}),(h=n(this,Ua))==null||h.updateColor(a)},i=this.color,r=n(this,Xs);this.addCommands({cmd:s.bind(this,e,q._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Y.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},cu=new WeakSet,Om=function(e){const s=n(this,ke),i=r=>{p(this,ke,r),b(this,du,Bm).call(this,r)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Y.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},du=new WeakSet,Bm=function(e){if(!n(this,Ft))return;b(this,Xa,xc).call(this,{highlightOutlines:n(this,Re).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Oh=new WeakSet,qf=function(){n(this,Ae)===null||!this.parent||(this.parent.drawLayer.remove(n(this,Ae)),p(this,Ae,null),this.parent.drawLayer.remove(n(this,Ut)),p(this,Ut,null))},qs=new WeakSet,Yi=function(e=this.parent){n(this,Ae)===null&&({id:qt(this,Ae)._,clipPathId:qt(this,Zn)._}=e.drawLayer.draw({bbox:n(this,Re).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":n(this,Xs)},rootClass:{highlight:!0,free:n(this,Ft)},path:{d:n(this,Re).toSVGPath()}},!1,!0),p(this,Ut,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,Ft)},bbox:n(this,ae).box,path:{d:n(this,ae).toSVGPath()}},n(this,Ft))),n(this,tr)&&(n(this,tr).style.clipPath=n(this,Zn)))},ki=new WeakSet,Pr=function([e,s,i,r],a){switch(a){case 90:return[1-s-r,e,r,i];case 180:return[1-e-i,1-s-r,i,r];case 270:return[s,1-e-i,r,i]}return[e,s,i,r]},uu=new WeakSet,Hm=function(e){q._keyboardManager.exec(this,e)},qa=new WeakSet,Tc=function(e){if(!n(this,Va))return;const s=window.getSelection();e?s.setPosition(n(this,Va),n(this,Lh)):s.setPosition(n(this,Ih),n(this,Dh))},er=new WeakSet,Ro=function(){return n(this,Ft)?this.rotation:0},fu=new WeakSet,zm=function(){if(n(this,Ft))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,Ws),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:f,height:g}of a){const m=h*e+i,A=(1-c)*s+r;o[l]=o[l+4]=m,o[l+1]=o[l+3]=A,o[l+2]=o[l+6]=m+f*e,o[l+5]=o[l+7]=A-g*s,l+=8}return o},pu=new WeakSet,$m=function(e){return n(this,Re).serialize(e,b(this,er,Ro).call(this))},gu=new WeakSet,Gm=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},mu=new WeakSet,Vm=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=""},bu=new WeakSet,Um=function(e){const{color:s}=this._initialData;return e.color.some((i,r)=>i!==s[r])},u(q,ki),u(q,gu),u(q,mu),O(q,"_defaultColor",null),O(q,"_defaultOpacity",1),O(q,"_defaultThickness",12),O(q,"_type","highlight"),O(q,"_editorType",V.HIGHLIGHT),O(q,"_freeHighlightId",-1),O(q,"_freeHighlight",null),O(q,"_freeHighlightClipId","");let $c=q;var sr;class Ly{constructor(){u(this,sr,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,sr)[t]=e}toSVGProperties(){const t=n(this,sr);return p(this,sr,Object.create(null)),{root:t}}reset(){p(this,sr,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){st("Not implemented")}}sr=new WeakMap;var ye,Ya,Rt,ir,nr,Mi,Li,Ii,rr,Bh,Kf,Hh,Qf,zh,Jf,ar,ko,Au,jm,Ka,Pc,or,Mo,Di,Rr;const M=class M extends ut{constructor(e){super(e);u(this,Bh);u(this,Hh);u(this,zh);u(this,ar);u(this,Au);u(this,Ka);u(this,or);u(this,Di);u(this,ye,null);u(this,Ya,void 0);O(this,"_drawId",null);p(this,Ya,e.mustBeCommitted||!1),e.drawOutlines&&(b(this,Bh,Kf).call(this,e),b(this,ar,ko).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){st("Not implemented")}static get typesMap(){st("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(M,Rt).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=n(this,ye).updateProperty(s,l);h&&b(this,or,Mo).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties())};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,M._mergeSVGProperties(n(this,ye).getPathResizingSVGProperties(b(this,Ka,Pc).call(this)),{bbox:b(this,Di,Rr).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,M._mergeSVGProperties(n(this,ye).getPathResizedSVGProperties(b(this,Ka,Pc).call(this)),{bbox:b(this,Di,Rr).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,Di,Rr).call(this,e,s)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,M._mergeSVGProperties(n(this,ye).getPathTranslatedSVGProperties(b(this,Ka,Pc).call(this),this.parentDimensions),{bbox:b(this,Di,Rr).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,Ya)&&(p(this,Ya,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){b(this,zh,Jf).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,ar,ko).call(this),b(this,or,Mo).call(this,n(this,ye).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,zh,Jf).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,ar,ko).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,M._mergeSVGProperties({bbox:b(this,Di,Rr).call(this)},n(this,ye).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,or,Mo).call(this,n(this,ye).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const s=document.createElement("div");e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[i,r]=this.parentDimensions;return this.setDims(this.width*i,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,s,i,r,a){st("Not implemented")}static startDrawing(e,s,i,r){var v,w;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(n(M,Li)&&n(M,Li)!==c)return;const{viewport:{rotation:f}}=e,{width:g,height:m}=a.getBoundingClientRect(),A=p(M,ir,new AbortController),y=e.combinedSignal(A);if(n(M,Mi)||p(M,Mi,h),(v=n(M,Li))!=null||p(M,Li,c),window.addEventListener("pointerup",_=>{var E;n(M,Mi)===_.pointerId?this._endDraw(_):(E=n(M,Ii))==null||E.delete(_.pointerId)},{signal:y}),window.addEventListener("pointercancel",_=>{var E;n(M,Mi)===_.pointerId?this._currentParent.endDrawingSession():(E=n(M,Ii))==null||E.delete(_.pointerId)},{signal:y}),window.addEventListener("pointerdown",_=>{n(M,Li)===_.pointerType&&((n(M,Ii)||p(M,Ii,new Set)).add(_.pointerId),n(M,Rt).isCancellable()&&(n(M,Rt).removeLastElement(),n(M,Rt).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:y}),window.addEventListener("contextmenu",Ke,{signal:y}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:y}),a.addEventListener("touchmove",_=>{_.timeStamp===n(M,rr)&&Se(_)},{signal:y}),e.toggleDrawing(),(w=s._editorUndoBar)==null||w.hide(),n(M,Rt)){e.drawLayer.updateProperties(this._currentDrawId,n(M,Rt).startNew(o,l,g,m,f));return}s.updateUIForDefaultProperties(this),p(M,Rt,this.createDrawerInstance(o,l,g,m,f)),p(M,nr,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(M,nr).toSVGProperties(),n(M,Rt).defaultSVGProperties),!0,!1)}static _drawMove(e){var a;if(p(M,rr,-1),!n(M,Rt))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(n(M,Mi)===r){if(((a=n(M,Ii))==null?void 0:a.size)>=1){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(M,Rt).add(s,i)),p(M,rr,e.timeStamp),Se(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(M,Rt,null),p(M,nr,null),p(M,Li,null),p(M,rr,NaN)),n(M,ir)&&(n(M,ir).abort(),p(M,ir,null),p(M,Mi,NaN),p(M,Ii,null))}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),e&&s.drawLayer.updateProperties(this._currentDrawId,n(M,Rt).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=n(M,Rt),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:Y.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(Y.DRAW_STEP),!n(M,Rt).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(M,Rt).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(M,nr),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o){st("Not implemented")}static deserialize(e,s,i){return I(this,null,function*(){var f,g;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),c=yield ji(M,this,"deserialize").call(this,e,s,i);return c.createDrawingOptions(e),b(f=c,Bh,Kf).call(f,{drawOutlines:h}),b(g=c,ar,ko).call(g),c.onScaleChanging(),c.rotate(),c})}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,ye).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};ye=new WeakMap,Ya=new WeakMap,Rt=new WeakMap,ir=new WeakMap,nr=new WeakMap,Mi=new WeakMap,Li=new WeakMap,Ii=new WeakMap,rr=new WeakMap,Bh=new WeakSet,Kf=function({drawOutlines:e,drawId:s,drawingOptions:i}){p(this,ye,e),this._drawingOptions||(this._drawingOptions=i),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=b(this,Hh,Qf).call(this,e,this.parent),b(this,or,Mo).call(this,e.box)},Hh=new WeakSet,Qf=function(e,s){const{id:i}=s.drawLayer.draw(M._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},zh=new WeakSet,Jf=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},ar=new WeakSet,ko=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,Hh,Qf).call(this,n(this,ye),e)}},Au=new WeakSet,jm=function([e,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},Ka=new WeakSet,Pc=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},or=new WeakSet,Mo=function(e){if([this.x,this.y,this.width,this.height]=b(this,Au,jm).call(this,e),this.div){this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)}this._onResized()},Di=new WeakSet,Rr=function(){const{x:e,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,h]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(l/h),r*(h/l),i*(l/h)];case 5:return[1-s,e,i*(l/h),r*(h/l)];case 6:return[1-e-r*(h/l),1-s,r*(h/l),i*(l/h)];case 7:return[s-i*(l/h),1-e-r*(h/l),i*(l/h),r*(h/l)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(h/l),s,r*(h/l),i*(l/h)];case 13:return[1-s-i*(l/h),e-r*(h/l),i*(l/h),r*(h/l)];case 14:return[1-e,1-s-i*(l/h),r*(h/l),i*(l/h)];case 15:return[s,1-e,i*(l/h),r*(h/l)];default:return[e,s,i,r]}},O(M,"_currentDrawId",-1),O(M,"_currentParent",null),u(M,Rt,null),u(M,ir,null),u(M,nr,null),u(M,Mi,NaN),u(M,Li,null),u(M,Ii,null),u(M,rr,NaN),O(M,"_INNER_MARGIN",3);let Yf=M;var fs,kt,Mt,lr,Qa,Qt,Nt,Me,hr,cr,dr,Ja,Rc;class Iy{constructor(t,e,s,i,r,a){u(this,Ja);u(this,fs,new Float64Array(6));u(this,kt,void 0);u(this,Mt,void 0);u(this,lr,void 0);u(this,Qa,void 0);u(this,Qt,void 0);u(this,Nt,"");u(this,Me,0);u(this,hr,new Gc);u(this,cr,void 0);u(this,dr,void 0);p(this,cr,s),p(this,dr,i),p(this,lr,r),p(this,Qa,a),[t,e]=b(this,Ja,Rc).call(this,t,e);const o=p(this,kt,[NaN,NaN,NaN,NaN,t,e]);p(this,Qt,[t,e]),p(this,Mt,[{line:o,points:n(this,Qt)}]),n(this,fs).set(o,0)}updateProperty(t,e){t==="stroke-width"&&p(this,Qa,e)}isEmpty(){return!n(this,Mt)||n(this,Mt).length===0}isCancellable(){return n(this,Qt).length<=10}add(t,e){[t,e]=b(this,Ja,Rc).call(this,t,e);const[s,i,r,a]=n(this,fs).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,cr)*o,n(this,dr)*l)<=2?null:(n(this,Qt).push(t,e),isNaN(s)?(n(this,fs).set([r,a,t,e],2),n(this,kt).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,fs)[0])&&n(this,kt).splice(6,6),n(this,fs).set([s,i,r,a,t,e],0),n(this,kt).push(...L.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,Qt).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){p(this,cr,s),p(this,dr,i),p(this,lr,r),[t,e]=b(this,Ja,Rc).call(this,t,e);const a=p(this,kt,[NaN,NaN,NaN,NaN,t,e]);p(this,Qt,[t,e]);const o=n(this,Mt).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,Mt).push({line:a,points:n(this,Qt)}),n(this,fs).set(a,0),p(this,Me,0),this.toSVGPath(),null}getLastElement(){return n(this,Mt).at(-1)}setLastElement(t){return n(this,Mt)?(n(this,Mt).push(t),p(this,kt,t.line),p(this,Qt,t.points),p(this,Me,0),{path:{d:this.toSVGPath()}}):n(this,hr).setLastElement(t)}removeLastElement(){if(!n(this,Mt))return n(this,hr).removeLastElement();n(this,Mt).pop(),p(this,Nt,"");for(let t=0,e=n(this,Mt).length;t<e;t++){const{line:s,points:i}=n(this,Mt)[t];p(this,kt,s),p(this,Qt,i),p(this,Me,0),this.toSVGPath()}return{path:{d:n(this,Nt)}}}toSVGPath(){const t=L.svgRound(n(this,kt)[4]),e=L.svgRound(n(this,kt)[5]);if(n(this,Qt).length===2)return p(this,Nt,`${n(this,Nt)} M ${t} ${e} Z`),n(this,Nt);if(n(this,Qt).length<=6){const i=n(this,Nt).lastIndexOf("M");p(this,Nt,`${n(this,Nt).slice(0,i)} M ${t} ${e}`),p(this,Me,6)}if(n(this,Qt).length===4){const i=L.svgRound(n(this,kt)[10]),r=L.svgRound(n(this,kt)[11]);return p(this,Nt,`${n(this,Nt)} L ${i} ${r}`),p(this,Me,12),n(this,Nt)}const s=[];n(this,Me)===0&&(s.push(`M ${t} ${e}`),p(this,Me,6));for(let i=n(this,Me),r=n(this,kt).length;i<r;i+=6){const[a,o,l,h,c,f]=n(this,kt).slice(i,i+6).map(L.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${f}`)}return p(this,Nt,n(this,Nt)+s.join(" ")),p(this,Me,n(this,kt).length),n(this,Nt)}getOutlines(t,e,s,i){const r=n(this,Mt).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,hr).build(n(this,Mt),t,e,s,n(this,lr),n(this,Qa),i),p(this,fs,null),p(this,kt,null),p(this,Mt,null),p(this,Nt,null),n(this,hr)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}fs=new WeakMap,kt=new WeakMap,Mt=new WeakMap,lr=new WeakMap,Qa=new WeakMap,Qt=new WeakMap,Nt=new WeakMap,Me=new WeakMap,hr=new WeakMap,cr=new WeakMap,dr=new WeakMap,Ja=new WeakSet,Rc=function(t,e){return L._normalizePoint(t,e,n(this,cr),n(this,dr),n(this,lr))};var Jt,$h,Gh,we,ps,gs,Za,to,eo,Xe,_s,yu,Wm,wu,Xm,vu,qm;const Ep=class Ep extends L{constructor(){super(...arguments);u(this,Xe);u(this,yu);u(this,wu);u(this,vu);u(this,Jt,void 0);u(this,$h,0);u(this,Gh,void 0);u(this,we,void 0);u(this,ps,void 0);u(this,gs,void 0);u(this,Za,void 0);u(this,to,void 0);u(this,eo,void 0)}build(e,s,i,r,a,o,l){p(this,ps,s),p(this,gs,i),p(this,Za,r),p(this,to,a),p(this,eo,o),p(this,Gh,l!=null?l:0),p(this,we,e),b(this,wu,Xm).call(this)}setLastElement(e){return n(this,we).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,we).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,we)){if(e.push(`M${L.svgRound(s[4])} ${L.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12){e.push(`L${L.svgRound(s[10])} ${L.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,f]=s.subarray(i,i+6).map(L.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${f}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[h,c,f,g]=b(this,yu,Wm).call(this);let m,A,y,v,w,_,E,S,C;switch(n(this,to)){case 0:C=L._rescale,m=e,A=s+r,y=i,v=-r,w=e+h*i,_=s+(1-c-g)*r,E=e+(h+f)*i,S=s+(1-c)*r;break;case 90:C=L._rescaleAndSwap,m=e,A=s,y=i,v=r,w=e+c*i,_=s+h*r,E=e+(c+g)*i,S=s+(h+f)*r;break;case 180:C=L._rescale,m=e+i,A=s,y=-i,v=r,w=e+(1-h-f)*i,_=s+c*r,E=e+(1-h)*i,S=s+(c+g)*r;break;case 270:C=L._rescaleAndSwap,m=e+i,A=s+r,y=-i,v=-r,w=e+(1-c-g)*i,_=s+(1-h-f)*r,E=e+(1-c)*i,S=s+(1-h)*r;break}for(const{line:P,points:T}of n(this,we))o.push(C(P,m,A,y,v,a?new Array(P.length):null)),l.push(C(T,m,A,y,v,a?new Array(T.length):null));return{lines:o,points:l,rect:[w,_,E,S]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const f=[];let g,m,A,y,v;switch(h){case 0:v=L._rescale,g=-e/i,m=s/r+1,A=1/i,y=-1/r;break;case 90:v=L._rescaleAndSwap,g=-s/r,m=-e/i,A=1/r,y=1/i;break;case 180:v=L._rescale,g=e/i+1,m=-s/r,A=-1/i,y=1/r;break;case 270:v=L._rescaleAndSwap,g=s/r+1,m=e/i+1,A=-1/r,y=-1/i;break}if(!o){o=[];for(const _ of l){const E=_.length;if(E===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,_[0],_[1]]));continue}if(E===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,_[0],_[1],NaN,NaN,NaN,NaN,_[2],_[3]]));continue}const S=new Float32Array(3*(E-2));o.push(S);let[C,P,T,k]=_.subarray(0,4);S.set([NaN,NaN,NaN,NaN,C,P],0);for(let N=4;N<E;N+=2){const $=_[N],B=_[N+1];S.set(L.createBezierPoints(C,P,T,k,$,B),(N-2)*3),[C,P,T,k]=[T,k,$,B]}}}for(let _=0,E=o.length;_<E;_++)f.push({line:v(o[_].map(S=>S!=null?S:NaN),g,m,A,y),points:v(l[_].map(S=>S!=null?S:NaN),g,m,A,y)});const w=new Ep;return w.build(f,i,r,1,h,c,a),w}get box(){return n(this,Jt)}updateProperty(e,s){return e==="stroke-width"?b(this,vu,qm).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,Xe,_s).call(this);p(this,ps,e),p(this,gs,s),p(this,Za,i);const[o,l]=b(this,Xe,_s).call(this),h=o-r,c=l-a,f=n(this,Jt);return f[0]-=h,f[1]-=c,f[2]+=2*h,f[3]+=2*c,f}updateRotation(e){return p(this,$h,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,Jt).map(L.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,Jt);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,Jt);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,$h)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,h=s;break;case 270:r=-s/e,a=e/s,h=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${L.svgRound(l)} ${L.svgRound(h)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,Xe,_s).call(this),[l,h,c,f]=n(this,Jt);if(Math.abs(c-a)<=L.PRECISION||Math.abs(f-o)<=L.PRECISION){const v=e+i/2-(l+c/2),w=s+r/2-(h+f/2);return{path:{"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const g=(i-2*a)/(c-2*a),m=(r-2*o)/(f-2*o),A=c/i,y=f/r;return{path:{"transform-origin":`${L.svgRound(l)} ${L.svgRound(h)}`,transform:`${this.rotationTransform} scale(${A} ${y}) translate(${L.svgRound(a)} ${L.svgRound(o)}) scale(${g} ${m}) translate(${L.svgRound(-a)} ${L.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,Xe,_s).call(this),l=n(this,Jt),[h,c,f,g]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(f-a)<=L.PRECISION||Math.abs(g-o)<=L.PRECISION){const w=e+i/2-(h+f/2),_=s+r/2-(c+g/2);for(const{line:E,points:S}of n(this,we))L._translate(E,w,_,E),L._translate(S,w,_,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const m=(i-2*a)/(f-2*a),A=(r-2*o)/(g-2*o),y=-m*(h+a)+e+a,v=-A*(c+o)+s+o;if(m!==1||A!==1||y!==0||v!==0)for(const{line:w,points:_}of n(this,we))L._rescale(w,y,v,m,A,w),L._rescale(_,y,v,m,A,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,Jt),l=e-o[0],h=s-o[1];if(n(this,ps)===r&&n(this,gs)===a)for(const{line:c,points:f}of n(this,we))L._translate(c,l,h,c),L._translate(f,l,h,f);else{const c=n(this,ps)/r,f=n(this,gs)/a;p(this,ps,r),p(this,gs,a);for(const{line:g,points:m}of n(this,we))L._rescale(g,l,h,c,f,g),L._rescale(m,l,h,c,f,m);o[2]*=c,o[3]*=f}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,Jt);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${L.svgRound(e[0])} ${L.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}};Jt=new WeakMap,$h=new WeakMap,Gh=new WeakMap,we=new WeakMap,ps=new WeakMap,gs=new WeakMap,Za=new WeakMap,to=new WeakMap,eo=new WeakMap,Xe=new WeakSet,_s=function(e=n(this,eo)){const s=n(this,Gh)+e/2*n(this,Za);return n(this,to)%180===0?[s/n(this,ps),s/n(this,gs)]:[s/n(this,gs),s/n(this,ps)]},yu=new WeakSet,Wm=function(){const[e,s,i,r]=n(this,Jt),[a,o]=b(this,Xe,_s).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},wu=new WeakSet,Xm=function(){const e=p(this,Jt,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of n(this,we)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6){const[c,f]=r.subarray(l,l+2);e[0]=Math.min(e[0],c),e[1]=Math.min(e[1],f),e[2]=Math.max(e[2],c),e[3]=Math.max(e[3],f)}continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;l+=6){const[c,f,g,m,A,y]=r.subarray(l,l+6);F.bezierBoundingBox(a,o,c,f,g,m,A,y,e),a=A,o=y}}const[s,i]=b(this,Xe,_s).call(this);e[0]=Math.min(1,Math.max(0,e[0]-s)),e[1]=Math.min(1,Math.max(0,e[1]-i)),e[2]=Math.min(1,Math.max(0,e[2]+s)),e[3]=Math.min(1,Math.max(0,e[3]+i)),e[2]-=e[0],e[3]-=e[1]},vu=new WeakSet,qm=function(e){const[s,i]=b(this,Xe,_s).call(this);p(this,eo,e);const[r,a]=b(this,Xe,_s).call(this),[o,l]=[r-s,a-i],h=n(this,Jt);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};let Gc=Ep;var so;const Cp=class Cp extends Ly{constructor(e){super();u(this,so,void 0);p(this,so,e),super.updateProperties({fill:"none",stroke:ut._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,s){e==="stroke-width"&&(s!=null||(s=this["stroke-width"]),s*=n(this,so).realScale),super.updateSVGProperty(e,s)}clone(){const e=new Cp(n(this,so));return e.updateAll(this),e}};so=new WeakMap;let Zf=Cp;var _u,Ym;const Ji=class Ji extends Yf{constructor(e){super(_r(ys({},e),{name:"inkEditor"}));u(this,_u);this._willKeepAspectRatio=!0}static initialize(e,s){ut.initialize(e,s),this._defaultDrawingOptions=new Zf(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return X(this,"typesMap",new Map([[Y.INK_THICKNESS,"stroke-width"],[Y.INK_COLOR,"stroke"],[Y.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,r,a){return new Iy(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return Gc.deserialize(e,s,i,r,a,o)}static deserialize(e,s,i){return I(this,null,function*(){let r=null;if(e instanceof yp){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:f,opacity:g,borderStyle:{rawWidth:m},popupRef:A},parent:{page:{pageNumber:y}}}=e;r=e={annotationType:V.INK,color:Array.from(f),thickness:m,opacity:g,paths:{points:o},boxes:null,pageIndex:y-1,rect:l.slice(0),rotation:h,id:c,deleted:!1,popupRef:A}}const a=yield ji(Ji,this,"deserialize").call(this,e,s,i);return a.annotationElementId=e.id||null,a._initialData=r,a})}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=Ji.getDefaultDrawingOptions({stroke:F.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i,rect:r}=this.serializeDraw(e),{_drawingOptions:{stroke:a,"stroke-opacity":o,"stroke-width":l}}=this,h={annotationType:V.INK,color:ut._colorManager.convert(a),opacity:o,thickness:l,paths:{lines:s,points:i},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?h:this.annotationElementId&&!b(this,_u,Ym).call(this,h)?null:(h.id=this.annotationElementId,h)}renderAnnotationElement(e){const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s}),null}};_u=new WeakSet,Ym=function(e){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},O(Ji,"_type","ink"),O(Ji,"_editorType",V.INK),O(Ji,"_defaultDrawingOptions",null);let tp=Ji;var dt,Ot,Fi,Ys,Ni,io,ms,bs,ve,no,ur,Lo,fr,Io,ro,kc,Vh,sp,ao,Mc,Uh,ip,oo,Lc,Su,Km;const Lr=class Lr extends ut{constructor(e){super(_r(ys({},e),{name:"stampEditor"}));u(this,ur);u(this,fr);u(this,ro);u(this,Vh);u(this,ao);u(this,Uh);u(this,oo);u(this,Su);u(this,dt,null);u(this,Ot,null);u(this,Fi,null);u(this,Ys,null);u(this,Ni,null);u(this,io,"");u(this,ms,null);u(this,bs,null);u(this,ve,!1);u(this,no,!1);p(this,Ys,e.bitmapUrl),p(this,Ni,e.bitmapFile)}static initialize(e,s){ut.initialize(e,s)}static get supportedTypes(){return X(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return X(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(V.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){var i,r;const s=e.get("hasAltText");return{hasAltText:(i=s.get(!0))!=null?i:0,hasNoAltText:(r=s.get(!1))!=null?r:0}}mlGuessAltText(e=null,s=!0){return I(this,null,function*(){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!(yield i.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=yield i.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.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 h=l.output;return yield this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h})}remove(){var e;n(this,Ot)&&(p(this,dt,null),this._uiManager.imageManager.deleteId(n(this,Ot)),(e=n(this,ms))==null||e.remove(),p(this,ms,null),n(this,bs)&&(clearTimeout(n(this,bs)),p(this,bs,null))),super.remove()}rebuild(){if(!this.parent){n(this,Ot)&&b(this,ro,kc).call(this);return}super.rebuild(),this.div!==null&&(n(this,Ot)&&n(this,ms)===null&&b(this,ro,kc).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,Fi)||n(this,dt)||n(this,Ys)||n(this,Ni)||n(this,Ot))}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(),n(this,dt)?b(this,Vh,sp).call(this):b(this,ro,kc).call(this),this.width&&!this.annotationElementId){const[i,r]=this.parentDimensions;this.setAt(e*i,s*r,this.width*i,this.height*r)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,bs)!==null&&clearTimeout(n(this,bs)),p(this,bs,setTimeout(()=>{p(this,bs,null),b(this,Uh,ip).call(this)},200))}copyCanvas(e,s,i=!1){var m;e||(e=224);const{width:r,height:a}=n(this,dt),o=new Ju;let l=n(this,dt),h=r,c=a,f=null;if(s){if(r>s||a>s){const k=Math.min(s/r,s/a);h=Math.floor(r*k),c=Math.floor(a*k)}f=document.createElement("canvas");const A=f.width=Math.ceil(h*o.sx),y=f.height=Math.ceil(c*o.sy);n(this,ve)||(l=b(this,ao,Mc).call(this,A,y));const v=f.getContext("2d");v.filter=this._uiManager.hcmFilter;let w="white",_="#cfcfd8";this._uiManager.hcmFilter!=="none"?_="black":(m=window.matchMedia)!=null&&m.call(window,"(prefers-color-scheme: dark)").matches&&(w="#8f8f9d",_="#42414d");const E=15,S=E*o.sx,C=E*o.sy,P=new OffscreenCanvas(S*2,C*2),T=P.getContext("2d");T.fillStyle=w,T.fillRect(0,0,S*2,C*2),T.fillStyle=_,T.fillRect(0,0,S,C),T.fillRect(S,C,S,C),v.fillStyle=v.createPattern(P,"repeat"),v.fillRect(0,0,A,y),v.drawImage(l,0,0,l.width,l.height,0,0,A,y)}let g=null;if(i){let A,y;if(o.symmetric&&l.width<e&&l.height<e)A=l.width,y=l.height;else if(l=n(this,dt),r>e||a>e){const _=Math.min(e/r,e/a);A=Math.floor(r*_),y=Math.floor(a*_),n(this,ve)||(l=b(this,ao,Mc).call(this,A,y))}const w=new OffscreenCanvas(A,y).getContext("2d",{willReadFrequently:!0});w.drawImage(l,0,0,l.width,l.height,0,0,A,y),g={width:A,height:y,data:w.getImageData(0,0,A,y).data}}return{canvas:f,width:h,height:c,imageData:g}}getImageForAltText(){return n(this,ms)}static deserialize(e,s,i){return I(this,null,function*(){var y;let r=null;if(e instanceof bm){const{data:{rect:v,rotation:w,id:_,structParent:E,popupRef:S},container:C,parent:{page:{pageNumber:P}}}=e,T=C.querySelector("canvas"),k=i.imageManager.getFromCanvas(C.id,T);T.remove();const N=((y=yield s._structTree.getAriaAttributes(`${dp}${_}`))==null?void 0:y.get("aria-label"))||"";r=e={annotationType:V.STAMP,bitmapId:k.id,bitmap:k.bitmap,pageIndex:P-1,rect:v.slice(0),rotation:w,id:_,deleted:!1,accessibilityData:{decorative:!1,altText:N},isSvg:!1,structParent:E,popupRef:S}}const a=yield ji(Lr,this,"deserialize").call(this,e,s,i),{rect:o,bitmap:l,bitmapUrl:h,bitmapId:c,isSvg:f,accessibilityData:g}=e;c&&i.imageManager.isValidId(c)?(p(a,Ot,c),l&&p(a,dt,l)):p(a,Ys,h),p(a,ve,f);const[m,A]=a.pageDimensions;return a.width=(o[2]-o[0])/m,a.height=(o[3]-o[1])/A,a.annotationElementId=e.id||null,g&&(a.altTextData=g),a._initialData=r,p(a,no,!!r),a})}serialize(e=!1,s=null){var l;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:V.STAMP,bitmapId:n(this,Ot),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:n(this,ve),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=b(this,oo,Lc).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const h=b(this,Su,Km).call(this,i);if(h.isSame)return null;h.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=(l=this._initialData.structParent)!=null?l:-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,ve)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,Ot)))s.stamps.set(n(this,Ot),{area:o,serialized:i}),i.bitmap=b(this,oo,Lc).call(this,!1);else if(n(this,ve)){const h=s.stamps.get(n(this,Ot));o>h.area&&(h.area=o,h.serialized.bitmap.close(),h.serialized.bitmap=b(this,oo,Lc).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};dt=new WeakMap,Ot=new WeakMap,Fi=new WeakMap,Ys=new WeakMap,Ni=new WeakMap,io=new WeakMap,ms=new WeakMap,bs=new WeakMap,ve=new WeakMap,no=new WeakMap,ur=new WeakSet,Lo=function(e,s=!1){if(!e){this.remove();return}p(this,dt,e.bitmap),s||(p(this,Ot,e.id),p(this,ve,e.isSvg)),e.file&&p(this,io,e.file.name),b(this,Vh,sp).call(this)},fr=new WeakSet,Io=function(){if(p(this,Fi,null),this._uiManager.enableWaiting(!1),!!n(this,ms)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,dt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,dt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch(e){}}this.div.focus()}},ro=new WeakSet,kc=function(){if(n(this,Ot)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Ot)).then(i=>b(this,ur,Lo).call(this,i,!0)).finally(()=>b(this,fr,Io).call(this));return}if(n(this,Ys)){const i=n(this,Ys);p(this,Ys,null),this._uiManager.enableWaiting(!0),p(this,Fi,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,ur,Lo).call(this,r)).finally(()=>b(this,fr,Io).call(this)));return}if(n(this,Ni)){const i=n(this,Ni);p(this,Ni,null),this._uiManager.enableWaiting(!0),p(this,Fi,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,ur,Lo).call(this,r)).finally(()=>b(this,fr,Io).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Lr.supportedTypesStr;const s=this._uiManager._signal;p(this,Fi,new Promise(i=>{e.addEventListener("change",()=>I(this,null,function*(){if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=yield this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,ur,Lo).call(this,r)}i()}),{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,fr,Io).call(this))),e.click()},Vh=new WeakSet,sp=function(){var f;const{div:e}=this;let{width:s,height:i}=n(this,dt);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const g=Math.min(o*r/s,o*a/i);s*=g,i*=g}const[l,h]=this.parentDimensions;this.setDims(s*l/r,i*h/a),this._uiManager.enableWaiting(!1);const c=p(this,ms,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this.width=s/r,this.height=i/a,(f=this._initialOptions)!=null&&f.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),b(this,Uh,ip).call(this),n(this,no)||(this.parent.addUndoableEditor(this),p(this,no,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,io)&&c.setAttribute("aria-label",n(this,io))},ao=new WeakSet,Mc=function(e,s){const{width:i,height:r}=n(this,dt);let a=i,o=r,l=n(this,dt);for(;a>2*e||o>2*s;){const h=a,c=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 f=new OffscreenCanvas(a,o);f.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=f.transferToImageBitmap()}return l},Uh=new WeakSet,ip=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new Ju,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,ms);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,ve)?n(this,dt):b(this,ao,Mc).call(this,o,l),f=h.getContext("2d");f.filter=this._uiManager.hcmFilter,f.drawImage(c,0,0,c.width,c.height,0,0,o,l)},oo=new WeakSet,Lc=function(e){if(e){if(n(this,ve)){const r=this._uiManager.imageManager.getSvgUrl(n(this,Ot));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,dt),s.getContext("2d").drawImage(n(this,dt),0,0),s.toDataURL()}if(n(this,ve)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Gi.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Gi.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,dt),0,0,n(this,dt).width,n(this,dt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,dt))},Su=new WeakSet,Km=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},O(Lr,"_type","stamp"),O(Lr,"_editorType",V.STAMP);let ep=Lr;var pr,lo,As,Oi,Ks,Le,Bi,ho,gr,qe,Qs,jt,Js,D,Hi,Eu,Qm,Ie,ts,jh,rp,Wh,ap,co,Ic;const De=class De{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){u(this,Eu);u(this,Ie);u(this,jh);u(this,Wh);u(this,co);u(this,pr,void 0);u(this,lo,!1);u(this,As,null);u(this,Oi,null);u(this,Ks,null);u(this,Le,new Map);u(this,Bi,!1);u(this,ho,!1);u(this,gr,!1);u(this,qe,null);u(this,Qs,null);u(this,jt,null);u(this,Js,null);u(this,D,void 0);const f=[...n(De,Hi).values()];if(!De._initialized){De._initialized=!0;for(const g of f)g.initialize(c,t)}t.registerEditorTypes(f),p(this,D,t),this.pageIndex=e,this.div=s,p(this,pr,r),p(this,As,a),this.viewport=h,p(this,jt,l),this.drawLayer=o,this._structTree=i,n(this,D).addLayer(this)}get isEmpty(){return n(this,Le).size===0}get isInvisible(){return this.isEmpty&&n(this,D).getMode()===V.NONE}updateToolbar(t){n(this,D).updateToolbar(t)}updateMode(t=n(this,D).getMode()){switch(b(this,co,Ic).call(this),t){case V.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case V.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case V.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 n(De,Hi).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,jt))==null?void 0:e.div)}setEditingState(t){n(this,D).setEditingState(t)}addCommands(t){n(this,D).addCommands(t)}cleanUndoStack(t){n(this,D).cleanUndoStack(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=n(this,As))==null||e.div.classList.toggle("disabled",!t)}enable(){return I(this,null,function*(){p(this,gr,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of n(this,Le).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(n(this,D).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!n(this,As)){p(this,gr,!1);return}const e=n(this,As).getEditableAnnotations();for(const s of e){if(s.hide(),n(this,D).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=yield this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}p(this,gr,!1)})}disable(){var i;p(this,ho,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const r of n(this,Le).values())if(r.disableEditing(),!!r.annotationElementId){if(r.serialize()!==null){t.set(r.annotationElementId,r);continue}else e.set(r.annotationElementId,r);(i=this.getEditableAnnotation(r.annotationElementId))==null||i.show(),r.remove()}if(n(this,As)){const r=n(this,As).getEditableAnnotations();for(const a of r){const{id:o}=a.data;if(n(this,D).isDeletedAnnotationElement(o))continue;let l=e.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=t.get(o),l&&(n(this,D).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}b(this,co,Ic).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(De,Hi).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,ho,!1)}getEditableAnnotation(t){var e;return((e=n(this,As))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,D).getActive()!==t&&n(this,D).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,jt))!=null&&t.div&&!n(this,Js)){p(this,Js,new AbortController);const e=n(this,D).combinedSignal(n(this,Js));n(this,jt).div.addEventListener("pointerdown",b(this,Eu,Qm).bind(this),{signal:e}),n(this,jt).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,jt))!=null&&t.div&&n(this,Js)&&(n(this,Js).abort(),p(this,Js,null),n(this,jt).div.classList.remove("highlighting"))}enableClick(){if(n(this,Oi))return;p(this,Oi,new AbortController);const t=n(this,D).combinedSignal(n(this,Oi));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=n(this,Oi))==null||t.abort(),p(this,Oi,null)}attach(t){n(this,Le).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,D).isDeletedAnnotationElement(e)&&n(this,D).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,Le).delete(t.id),(e=n(this,pr))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,ho)&&t.annotationElementId&&n(this,D).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,D).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,D).addDeletedAnnotationElement(t.annotationElementId),ut.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),n(this,D).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,gr)),n(this,D).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,Ks)&&(t._focusEventsAllowed=!1,p(this,Ks,setTimeout(()=>{p(this,Ks,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,D)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,pr))==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 n(this,D).getId()}combinedSignal(t){return n(this,D).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,Ie,ts))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){n(this,D).updateToolbar(t),n(this,D).updateMode(t);const{offsetX:s,offsetY:i}=b(this,Wh,ap).call(this),r=this.getNextId(),a=b(this,jh,rp).call(this,ys({parent:this,id:r,x:s,y:i,uiManager:n(this,D),isCentered:!0},e));a&&this.add(a)}deserialize(t){return I(this,null,function*(){var e,s;return(yield(s=n(De,Hi).get((e=t.annotationType)!=null?e:t.annotationEditorType))==null?void 0:s.deserialize(t,this,n(this,D)))||null})}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),r=b(this,jh,rp).call(this,ys({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,D),isCentered:e},s));return r&&this.add(r),r}addNewEditor(){this.createAndAddNewEditor(b(this,Wh,ap).call(this),!0)}setSelected(t){n(this,D).setSelected(t)}toggleSelected(t){n(this,D).toggleSelected(t)}unselect(t){n(this,D).unselect(t)}pointerup(t){var s;const{isMac:e}=te.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&n(this,Bi)&&(p(this,Bi,!1),!((s=n(this,Ie,ts))!=null&&s.isDrawer&&n(this,Ie,ts).supportMultipleDrawings))){if(!n(this,lo)){p(this,lo,!0);return}if(n(this,D).getMode()===V.STAMP){n(this,D).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){var i;if(n(this,D).getMode()===V.HIGHLIGHT&&this.enableTextSelection(),n(this,Bi)){p(this,Bi,!1);return}const{isMac:e}=te.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,Bi,!0),(i=n(this,Ie,ts))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,D).getActive();p(this,lo,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus(),n(this,qe)){n(this,Ie,ts).startDrawing(this,n(this,D),!1,t);return}n(this,D).setCurrentDrawingSession(this),p(this,qe,new AbortController);const e=n(this,D).combinedSignal(n(this,qe));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,Qs,null),this.commitOrRemove())},{signal:e}),n(this,Ie,ts).startDrawing(this,n(this,D),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,Qs,e);return}n(this,Qs)&&setTimeout(()=>{var e;(e=n(this,Qs))==null||e.focus(),p(this,Qs,null)},0)}endDrawingSession(t=!1){return n(this,qe)?(n(this,D).setCurrentDrawingSession(null),n(this,qe).abort(),p(this,qe,null),p(this,Qs,null),n(this,Ie,ts).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,D).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,qe)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,qe)&&n(this,Ie,ts).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,D).getActive())==null?void 0:t.parent)===this&&(n(this,D).commitOrRemove(),n(this,D).setActiveEditor(null)),n(this,Ks)&&(clearTimeout(n(this,Ks)),p(this,Ks,null));for(const s of n(this,Le).values())(e=n(this,pr))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,Le).clear(),n(this,D).removeLayer(this)}render({viewport:t}){this.viewport=t,br(this.div,t);for(const e of n(this,D).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){n(this,D).commitOrRemove(),b(this,co,Ic).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,br(this.div,{rotation:s}),e!==s)for(const i of n(this,Le).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,D).viewParameters.realScale}};pr=new WeakMap,lo=new WeakMap,As=new WeakMap,Oi=new WeakMap,Ks=new WeakMap,Le=new WeakMap,Bi=new WeakMap,ho=new WeakMap,gr=new WeakMap,qe=new WeakMap,Qs=new WeakMap,jt=new WeakMap,Js=new WeakMap,D=new WeakMap,Hi=new WeakMap,Eu=new WeakSet,Qm=function(t){n(this,D).unselectAll();const{target:e}=t;if(e===n(this,jt).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&n(this,jt).div.contains(e)){const{isMac:s}=te.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,D).showAllEditors("highlight",!0,!0),n(this,jt).div.classList.add("free"),this.toggleDrawing(),$c.startHighlighting(this,n(this,D).direction==="ltr",{target:n(this,jt).div,x:t.x,y:t.y}),n(this,jt).div.addEventListener("pointerup",()=>{n(this,jt).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,D)._signal}),t.preventDefault()}},Ie=new WeakSet,ts=function(){return n(De,Hi).get(n(this,D).getMode())},jh=new WeakSet,rp=function(t){const e=n(this,Ie,ts);return e?new e.prototype.constructor(t):null},Wh=new WeakSet,ap=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),h=(r+o)/2-t,c=(a+l)/2-e,[f,g]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:f,offsetY:g}},co=new WeakSet,Ic=function(){for(const t of n(this,Le).values())t.isEmpty()&&t.remove()},O(De,"_initialized",!1),u(De,Hi,new Map([Hf,tp,ep,$c].map(t=>[t._editorType,t])));let np=De;var Ye,Xh,Zt,mr,Cu,Jm,qh,lp,xu,Zm,Yh,hp;const $t=class $t{constructor({pageIndex:t}){u(this,qh);u(this,xu);u(this,Yh);u(this,Ye,null);u(this,Xh,0);u(this,Zt,new Map);u(this,mr,new Map);this.pageIndex=t}setParent(t){if(!n(this,Ye)){p(this,Ye,t);return}if(n(this,Ye)!==t){if(n(this,Zt).size>0)for(const e of n(this,Zt).values())e.remove(),t.append(e);p(this,Ye,t)}}static get _svgFactory(){return X(this,"_svgFactory",new Ap)}draw(t,e=!1,s=!1){const i=qt(this,Xh)._++,r=b(this,qh,lp).call(this),a=$t._svgFactory.createElement("defs");r.append(a);const o=$t._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,mr).set(i,o);const h=s?b(this,xu,Zm).call(this,a,l):null,c=$t._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,Zt).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=qt(this,Xh)._++,i=b(this,qh,lp).call(this),r=$t._svgFactory.createElement("defs");i.append(r);const a=$t._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const f=$t._svgFactory.createElement("mask");r.append(f),l=`mask_p${this.pageIndex}_${s}`,f.setAttribute("id",l),f.setAttribute("maskUnits","objectBoundingBox");const g=$t._svgFactory.createElement("rect");f.append(g),g.setAttribute("width","1"),g.setAttribute("height","1"),g.setAttribute("fill","white");const m=$t._svgFactory.createElement("use");f.append(m),m.setAttribute("href",`#${o}`),m.setAttribute("stroke","none"),m.setAttribute("fill","black"),m.setAttribute("fill-rule","nonzero"),m.classList.add("mask")}const h=$t._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,Zt).set(s,i),s}finalizeDraw(t,e){n(this,mr).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,Zt).get(t):t;if(o){if(s&&b(this,Yh,hp).call(this,o,s),i&&b(l=$t,Cu,Jm).call(l,o,i),r){const{classList:h}=o;for(const[c,f]of Object.entries(r))h.toggle(c,f)}if(a){const c=o.firstChild.firstChild;b(this,Yh,hp).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,Zt).get(t);s&&(n(e,Ye).append(s),n(this,Zt).delete(t),n(e,Zt).set(t,s))}remove(t){n(this,mr).delete(t),n(this,Ye)!==null&&(n(this,Zt).get(t).remove(),n(this,Zt).delete(t))}destroy(){p(this,Ye,null);for(const t of n(this,Zt).values())t.remove();n(this,Zt).clear(),n(this,mr).clear()}};Ye=new WeakMap,Xh=new WeakMap,Zt=new WeakMap,mr=new WeakMap,Cu=new WeakSet,Jm=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},qh=new WeakSet,lp=function(){const t=$t._svgFactory.create(1,1,!0);return n(this,Ye).append(t),t.setAttribute("aria-hidden",!0),t},xu=new WeakSet,Zm=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 r=$t._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},Yh=new WeakSet,hp=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},u($t,Cu);let op=$t;globalThis.pdfjsTestingUtils={HighlightOutliner:$f};z.AbortException;z.AnnotationEditorLayer;z.AnnotationEditorParamsType;z.AnnotationEditorType;z.AnnotationEditorUIManager;z.AnnotationLayer;z.AnnotationMode;z.ColorPicker;z.DOMSVGFactory;z.DrawLayer;z.FeatureTest;var Dy=z.GlobalWorkerOptions;z.ImageKind;z.InvalidPDFException;z.MissingPDFException;z.OPS;z.OutputScale;z.PDFDataRangeTransport;z.PDFDateString;z.PDFWorker;z.PasswordResponses;z.PermissionFlag;z.PixelsPerInch;z.RenderingCancelledException;z.TextLayer;z.TouchManager;z.UnexpectedResponseException;z.Util;z.VerbosityLevel;z.XfaLayer;z.build;z.createValidAbsoluteUrl;z.fetchData;var Fy=z.getDocument;z.getFilenameFromUrl;z.getPdfFilenameFromUrl;z.getXfaPageViewport;z.isDataScheme;z.isPdfFile;z.noContextMenu;z.normalizeUnicode;z.setLayerDimensions;z.shadow;z.stopEvent;z.version;Dy.workerSrc="../pdf.worker.mjs";const Ny={name:"PdfViewer",data(){return{open:!1,zoomLevel:1.75,start:!1,selection:null,startPoint:null,scrollPoint:null,selectionStyle:null,captureButtonStyle:null,captureButtonVisible:!1,pdfData:void 0}},methods:{MinusOutlined:mb,PlusOutlined:Zp,CloseOutlined:bb,ScissorOutlined:Ab,h:bo,loadPdf(){return I(this,null,function*(){const e=yield(yield Fy({data:this.pdfData.slice()}).promise).getPage(1),s=e.getViewport({scale:this.zoomLevel}),i=this.$refs.pdfCanvas,r=i.getContext("2d");i.width=s.width,i.height=s.height,yield e.render({canvasContext:r,viewport:s}).promise})},show(){this.open=!0,this.scrollPoint={x:0,y:0},this.start=!1,this.selection=null,this.startPoint=null,this.selectionStyle=null,this.captureButtonVisible=!1},close(){document.getElementById("scroller").scrollTop=0,document.getElementById("scroller").scrollLeft=0,this.open=!1},startSelection(d){this.start=!0,this.startPoint={x:d.offsetX,y:d.offsetY},this.selection={x:d.offsetX,y:d.offsetY,width:0,height:0},this.selectionStyle=null,this.hideCaptureButton()},updateSelection(d){this.start&&this.startPoint&&(this.selection.width=Math.abs(d.offsetX-this.startPoint.x),this.selection.height=Math.abs(d.offsetY-this.startPoint.y),this.selection.x=Math.min(d.offsetX,this.startPoint.x),this.selection.y=Math.min(d.offsetY,this.startPoint.y),this.selectionStyle={left:`${this.selection.x}px`,top:`${this.selection.y}px`,width:`${this.selection.width}px`,height:`${this.selection.height}px`,position:"absolute",border:"2px dashed red"})},endSelection(){this.start=!1,this.showCaptureButton()},captureSelection(){const d=this.$refs.pdfCanvas;d.getContext("2d");const t=this.$refs.tempCanvas;t.width=this.selection.width,t.height=this.selection.height,t.getContext("2d").drawImage(d,this.selection.x,this.selection.y,this.selection.width,this.selection.height,0,0,t.width,t.height);const s=t.toDataURL("image/png");this.$emit("onCapture",s),this.close()},handleScroll(d){this.scrollPoint={x:d.srcElement.scrollLeft,y:d.srcElement.scrollTop},this.showCaptureButton()},showCaptureButton(){this.selection&&this.selection.width>50&&this.selection.height>30?(this.captureButtonStyle={left:`${this.selection.x-this.scrollPoint.x+1}px`,top:`${this.selection.y-this.scrollPoint.y+1}px`,position:"absolute",borderRadius:0},this.captureButtonVisible=!0):this.captureButtonVisible=!1},hideCaptureButton(){this.captureButtonVisible=!1},zoomIn(){return I(this,null,function*(){this.zoomLevel=Math.min(3,this.zoomLevel+.1),yield this.loadPdf()})},zoomOut(){return I(this,null,function*(){this.zoomLevel=Math.max(.5,this.zoomLevel-.1),yield this.loadPdf()})}}},Oy={class:"box"},By={ref:"pdfCanvas"},Hy={ref:"tempCanvas"},zy={class:"tool-box"};function $y(d,t,e,s,i,r){const a=tg("a-button");return Hu((Dc(),qu("div",Oy,[Zs("div",{id:"scroller",class:"pdf-viewer",onMousedown:t[0]||(t[0]=(...o)=>r.startSelection&&r.startSelection(...o)),onMousemove:t[1]||(t[1]=(...o)=>r.updateSelection&&r.updateSelection(...o)),onMouseup:t[2]||(t[2]=(...o)=>r.endSelection&&r.endSelection(...o)),onScroll:t[3]||(t[3]=(...o)=>r.handleScroll&&r.handleScroll(...o))},[Zs("canvas",By,null,512),Hu(Zs("canvas",Hy,null,512),[[zu,!1]]),i.selection?(Dc(),qu("div",{key:0,class:"selection-box",style:Mp(i.selectionStyle)},null,4)):eg("",!0)],32),Zs("div",zy,[oe(a,{type:"primary",class:"tool-button",icon:r.h(r.MinusOutlined),onClick:r.zoomOut},null,8,["icon","onClick"]),Zs("span",null,Tb(Math.round(i.zoomLevel*100))+"%",1),oe(a,{type:"primary",class:"tool-button",icon:r.h(r.PlusOutlined),onClick:r.zoomIn},null,8,["icon","onClick"]),oe(a,{type:"primary",style:{"border-radius":"8px","margin-left":"10px"},icon:r.h(r.CloseOutlined),onClick:r.close},{default:si(()=>t[4]||(t[4]=[kr("取 消")])),_:1},8,["icon","onClick"])]),Hu(oe(a,{type:"primary",class:"btn",style:Mp(i.captureButtonStyle),icon:r.h(r.ScissorOutlined),onClick:r.captureSelection},{default:si(()=>t[5]||(t[5]=[kr("截 图")])),_:1},8,["style","icon","onClick"]),[[zu,i.captureButtonVisible]])],512)),[[zu,i.open]])}const Gy=Jp(Ny,[["render",$y],["__scopeId","data-v-8c6af75c"]]),Vy={class:"header"},Uy=Pb({__name:"index",setup(d){const[t,{openModal:e}]=Ib(),s=Wi(),{hasPermission:i}=ob(),r=Wi([]),a=x=>{r.value=x.filter(R=>typeof R!="undefined")},[o,{openDrawer:l}]=xb(),[h,{reload:c}]=fb({api:x=>Eb(g(x)),columns:Cb,formConfig:{labelWidth:0,schemas:kp,showAdvancedButton:!1},rowSelection:{type:"checkbox",onChange:a,getCheckboxProps:x=>({disabled:x.state!==0})},useSearchForm:!0,showTableSetting:!1,bordered:!0,showIndexColumn:!1,canResize:!1,rowKey:x=>x.id,actionColumn:{width:420,title:"操作",dataIndex:"action",fixed:void 0}}),f=Wi(!1),g=x=>{const ft=x,{pageNum:R,pageSize:G,field:J="id",order:H="descend"}=ft,Bt=Rp(ft,["pageNum","pageSize","field","order"]),rt={pageNum:R,pageSize:G,orderByClause:`${J} ${H==="descend"?"desc":"asc"}`};return Object.keys(Bt).forEach(Qe=>{const Ee=kp.find(Ui=>Ui.field===Qe),ht=x[Qe];let Q=Qe;Ee?ht!==void 0&&ht!==""&&(Ee.component==="Input"?rt[Q]=`%${ht.trim()}%`:["Select","ApiSelect","ApiTreeSelect"].includes(Ee.component)?rt[Q]=ub(ht)?ht.value:ht:Ee.component==="RangePicker"?(Q==="startTimeQuery"&&(Q="startTime"),rt[`${Q}From`]=Bu(ht[0]).startOf("d").format("YYYY-MM-DD HH:mm:ss"),rt[`${Q}To`]=Bu(ht[1]).endOf("d").format("YYYY-MM-DD HH:mm:ss")):Ee.component==="DatePicker"?rt[Q]=Bu(ht).format(Ee.componentProps.format||"YYYY-MM-DD"):rt[Q]=ht):rt[Q]=ht}),rt},m=()=>{l(!0,{isUpdate:!1})},A=x=>{l(!0,{record:x,isUpdate:!0})},y=x=>{Sb(x.id).then(R=>{c()})},v=()=>{c()},w=x=>{const R=JSON.parse(x.paramJson),G=!x.results||x.results===""||x.results==="[]"?[]:JSON.parse(x.results);return R.forEach(J=>{const H=G.filter(Bt=>J.code===Bt.code);J.w=H.length==0?"":H[0].best_cal_width,J.h=H.length==0?"":H[0].best_cal_height,J.average_deviation=H.length==0?"":H[0].average_deviation,J.m_x=H.length==0?"":H[0].m_x,J.m_y=H.length==0?"":H[0].m_y,J.x_deviation=H.length==0?"":H[0].x_deviation,J.y_deviation=H.length==0?"":H[0].y_deviation,J.base=H.length==0?"":H[0].base,J.status=H.length==0?"":H[0].status}),R},_=x=>{const R=w(x);R&&(x.reportJson=JSON.stringify(R),e(!0,{record:x}))};let E=null;const S=Wi(),C=x=>{var R;E=x,(R=S.value)==null||R.click()},P=x=>{const R=x.target.files[0];if(R){const G=new FileReader;G.onload=J=>{k(J.target.result),S.value.value=""},G.readAsArrayBuffer(R)}},T=Wi(),k=x=>I(this,null,function*(){T.value.pdfData=x,yield T.value.loadPdf(),T.value.show()}),N=x=>{f.value=!0,OCRService.importByOCR(x).then(R=>{var J;if(R===""){f.value=!1,WebViewService.setMessage("没有预埋件数据!","information").then(()=>{});return}const G=JSON.parse(R);if(G.length===0){f.value=!1,WebViewService.setMessage("没有预埋件数据!","information").then(()=>{});return}if(E===null){const H={name:"",paramJson:JSON.stringify(G)};l(!0,{record:H,isUpdate:!1})}else(J=s.value)==null||J.setParamData(G);WebViewService.setMessage("数据导入成功!","success").then(()=>{}),f.value=!1},R=>{WebViewService.setMessage("数据导入失败!","error").then(()=>{}),f.value=!1})},$=x=>{const R=[...new Set([...x.id?[x.id]:[],...r.value.map(G=>G)])];DeviceClientService.assignTasks(R).then(()=>{WebViewService.setMessage("下发任务成功!","success").then(()=>{})},G=>{WebViewService.setMessage("下发任务失败!","error").then(()=>{})})},B=x=>{const R=[...new Set([...x.id?[x.id]:[],...r.value.map(G=>G)])];DeviceClientService.syncTasks(R).then(()=>{WebViewService.setMessage("同步任务成功!","success").then(()=>{}),c()},G=>{WebViewService.setMessage("同步任务失败!","error").then(()=>{})})},it=()=>I(this,null,function*(){try{const x=yield db({url:"./预埋件信息.xlsx",method:"GET",responseType:"blob"}),R=window.URL.createObjectURL(new Blob([x.data])),G=document.createElement("a");G.href=R,G.setAttribute("download","预埋件信息.xlsx"),document.body.appendChild(G),G.click(),G.remove()}catch(x){}}),nt=Wi([]),K=Rb(()=>x=>nt.value[x]?nt.value[x]:!1),Et=Wi();return kb(()=>{Et.value=setInterval(()=>{DeviceClientService.getDeviceConnected().then(x=>{nt.value=x},x=>{WebViewService.setMessage("获取设备连接出错","error").then(()=>{})})},300),WebViewService.setIsLoading(!1).then(()=>{})}),Mb(()=>{clearInterval(Et.value)}),(x,R)=>{const G=tg("a-button");return Dc(),qu("div",null,[Zs("div",Vy,[oe(he(lb),{size:"19",name:"list"}),R[0]||(R[0]=Zs("div",{class:"title"},"任务列表",-1))]),oe(he(pb),{onRegister:he(h)},{toolbar:si(()=>[oe(G,{type:"primary",onClick:m,icon:bo(he(Zp))},{default:si(()=>R[1]||(R[1]=[kr("新 增")])),_:1},8,["icon"]),Zs("input",{type:"file",ref_key:"fileInput",ref:S,accept:"application/pdf","aria-hidden":"true",onChange:P,style:{display:"none"}},null,544),R[5]||(R[5]=Zs("div",{style:{width:"5px"}},null,-1)),oe(G,{type:"default",onClick:$,icon:bo(he(yb)),disabled:r.value.length===0},{default:si(()=>R[2]||(R[2]=[kr("下发数据")])),_:1},8,["icon","disabled"]),oe(G,{type:"default",onClick:B,icon:bo(he(wb)),disabled:r.value.length===0},{default:si(()=>R[3]||(R[3]=[kr("同步数据")])),_:1},8,["icon","disabled"]),oe(G,{type:"default",onClick:it,icon:bo(he(vb))},{default:si(()=>R[4]||(R[4]=[kr("下载模板")])),_:1},8,["icon"])]),bodyCell:si(({column:J,record:H})=>[J.dataIndex==="action"?(Dc(),Lb(he(gb),{key:0,actions:[{label:"编辑",icon:"clarity:note-edit-line",onClick:A.bind(null,H),divider:!0,disabled:H.state!==0},{label:"删除",icon:"ant-design:delete-outlined",color:"error",popConfirm:{title:"是否确认删除",confirm:y.bind(null,H),placement:"topRight"},ifShow:he(i)("AUTH_DATA_TASK:DELETE"),disabled:H.state!==0,divider:!0},{label:"结果查看",icon:"ant-design:eye-outlined",onClick:_.bind(null,H),divider:!0,disabled:H.paramJson===void 0||H.paramJson===null||H.paramJson===""},{label:"下发数据",icon:"ant-design:download-outlined",onClick:$.bind(null,H),divider:!0,disabled:H.state!==0||!K.value(H.deviceSn)},{label:"同步数据",icon:"ant-design:sync-outlined",onClick:B.bind(null,H),divider:!0,disabled:!K.value(H.deviceSn)}]},null,8,["actions"])):eg("",!0)]),_:1},8,["onRegister"]),oe(_b,{ref_key:"taskDrawer",ref:s,onRegister:he(o),onSuccess:v,onOcrClick:C},null,8,["onRegister"]),oe(Gy,{ref_key:"pdfView",ref:T,onOnCapture:N},null,512),oe(Db,{onRegister:he(t)},null,8,["onRegister"]),oe(he(cb),{loading:f.value,absolute:!1,tip:"OCR识别中...",size:he(hb).LARGE,theme:"dark"},null,8,["loading","size"])])}}});const ow=Jp(Uy,[["__scopeId","data-v-5813e16d"]]);export{ow as default};