1
0
Fork 0
owl-admin-starter/public/admin-assets/assets/PdfViewer-BcWncS-T.js

13 lines
355 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var Im=Object.defineProperty;var Dm=(h,t,e)=>t in h?Im(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e;var U=(h,t,e)=>(Dm(h,typeof t!="symbol"?t+"":t,e),e),Zd=(h,t,e)=>{if(!t.has(h))throw TypeError("Cannot "+e)};var r=(h,t,e)=>(Zd(h,t,"read from private field"),e?e.call(h):t.get(h)),f=(h,t,e)=>{if(t.has(h))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(h):t.set(h,e)},m=(h,t,e,s)=>(Zd(h,t,"write to private field"),s?s.call(h,e):t.set(h,e),e);var ie=(h,t,e,s)=>({set _(i){m(h,t,i,e)},get _(){return r(h,t,s)}}),b=(h,t,e)=>(Zd(h,t,"access private method"),e);import{n as bh,r as F,j as ft,a2 as Ht,f as Fm,Q as Om,a3 as va,R as rt,a4 as Nm,H as Ah,a5 as Hm}from"./index-CIBSAuTc.js";var Ha={};Ha.d=(h,t)=>{for(var e in t)Ha.o(t,e)&&!Ha.o(h,e)&&Object.defineProperty(h,e,{enumerable:!0,get:t[e]})};Ha.o=(h,t)=>Object.prototype.hasOwnProperty.call(h,t);var B=globalThis.pdfjsLib={};Ha.d(B,{AbortException:()=>Hn,AnnotationEditorLayer:()=>Af,AnnotationEditorParamsType:()=>j,AnnotationEditorType:()=>W,AnnotationEditorUIManager:()=>Dn,AnnotationLayer:()=>OA,AnnotationMode:()=>zs,CMapCompressionType:()=>ou,ColorPicker:()=>tc,DOMSVGFactory:()=>Pf,DrawLayer:()=>Ef,FeatureTest:()=>Zt,GlobalWorkerOptions:()=>Os,ImageKind:()=>Sh,InvalidPDFException:()=>bp,MissingPDFException:()=>Nn,OPS:()=>Ee,Outliner:()=>Ju,PDFDataRangeTransport:()=>hg,PDFDateString:()=>Sp,PDFWorker:()=>Qn,PasswordResponses:()=>$m,PermissionFlag:()=>Um,PixelsPerInch:()=>mi,RenderingCancelledException:()=>Lf,TextLayer:()=>Jh,UnexpectedResponseException:()=>jd,Util:()=>k,VerbosityLevel:()=>Nd,XfaLayer:()=>dg,build:()=>mA,createValidAbsoluteUrl:()=>Wm,fetchData:()=>Wd,getDocument:()=>oA,getFilenameFromUrl:()=>sb,getPdfFilenameFromUrl:()=>ib,getXfaPageViewport:()=>nb,isDataScheme:()=>kf,isPdfFile:()=>Mf,noContextMenu:()=>te,normalizeUnicode:()=>Jm,renderTextLayer:()=>Jb,setLayerDimensions:()=>In,shadow:()=>X,updateTextLayer:()=>Zb,version:()=>gA});const Bt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),mp=[1,0,0,1,0,0],au=[.001,0,0,.001,0,0],Bm=1e7,tu=1.35,Ae={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},zs={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},jm="pdfjs_internal_editor_",W={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},j={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},Um={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ft={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},Sh={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},mt={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},ya={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Nd={ERRORS:0,WARNINGS:1,INFOS:5},ou={NONE:0,BINARY:1},Ee={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},$m={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Hd=Nd.WARNINGS;function zm(h){Number.isInteger(h)&&(Hd=h)}function Vm(){return Hd}function Bd(h){Hd>=Nd.INFOS&&console.log(`Info: ${h}`)}function V(h){Hd>=Nd.WARNINGS&&console.log(`Warning: ${h}`)}function tt(h){throw new Error(h)}function _t(h,t){h||tt(t)}function Gm(h){switch(h==null?void 0:h.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Wm(h,t=null,e=null){if(!h)return null;try{if(e&&typeof h=="string"){if(e.addDefaultProtocol&&h.startsWith("www.")){const i=h.match(/\./g);(i==null?void 0:i.length)>=2&&(h=`http://${h}`)}if(e.tryConvertEncoding)try{h=Qm(h)}catch{}}const s=t?new URL(h,t):new URL(h);if(Gm(s))return s}catch{}return null}function X(h,t,e,s=!1){return Object.defineProperty(h,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const bi=function(){function t(e,s){this.constructor===t&&tt("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class lu extends bi{constructor(t,e){super(t,"PasswordException"),this.code=e}}class hu extends bi{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class bp extends bi{constructor(t){super(t,"InvalidPDFException")}}class Nn extends bi{constructor(t){super(t,"MissingPDFException")}}class jd extends bi{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class qm extends bi{constructor(t){super(t,"FormatError")}}class Hn extends bi{constructor(t){super(t,"AbortException")}}function Ap(h){(typeof h!="object"||(h==null?void 0:h.length)===void 0)&&tt("Invalid argument for bytesToString");const t=h.length,e=8192;if(t<e)return String.fromCharCode.apply(null,h);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),a=h.subarray(i,n);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Ud(h){typeof h!="string"&&tt("Invalid argument for stringToBytes");const t=h.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=h.charCodeAt(s)&255;return e}function Xm(h){return String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,h&255)}function Tf(h){const t=Object.create(null);for(const[e,s]of h)t[e]=s;return t}function Ym(){const h=new Uint8Array(4);return h[0]=1,new Uint32Array(h.buffer,0,1)[0]===1}function Km(){try{return new Function(""),!0}catch{return!1}}class Zt{static get isLittleEndian(){return X(this,"isLittleEndian",Ym())}static get isEvalSupported(){return X(this,"isEvalSupported",Km())}static get isOffscreenCanvasSupported(){return X(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?X(this,"platform",{isMac:navigator.platform.includes("Mac")}):X(this,"platform",{isMac:!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 eu=Array.from(Array(256).keys(),h=>h.toString(16).padStart(2,"0"));var tr,xh,$a,cu;class k{static makeHexColor(t,e,s){return`#${eu[t]}${eu[e]}${eu[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],a[0]),Math.min(s[1],i[1],n[1],a[1]),Math.max(s[0],i[0],n[0],a[0]),Math.max(s[1],i[1],n[1],a[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],o=(s+a)/2,l=Math.sqrt((s+a)**2-4*(s*a-n*i))/2,c=o+l||1,d=o-l||1;return[Math.sqrt(c),Math.sqrt(d)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[s,n,i,a]}static bezierBoundingBox(t,e,s,i,n,a,o,l,c){return c?(c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l)):c=[Math.min(t,o),Math.min(e,l),Math.max(t,o),Math.max(e,l)],b(this,$a,cu).call(this,t,s,n,o,e,i,a,l,3*(-t+3*(s-n)+o),6*(t-2*s+n),3*(s-t),c),b(this,$a,cu).call(this,t,s,n,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),c),c}}tr=new WeakSet,xh=function(t,e,s,i,n,a,o,l,c,d){if(c<=0||c>=1)return;const u=1-c,p=c*c,g=p*c,A=u*(u*(u*t+3*c*e)+3*p*s)+g*i,v=u*(u*(u*n+3*c*a)+3*p*o)+g*l;d[0]=Math.min(d[0],A),d[1]=Math.min(d[1],v),d[2]=Math.max(d[2],A),d[3]=Math.max(d[3],v)},$a=new WeakSet,cu=function(t,e,s,i,n,a,o,l,c,d,u,p){if(Math.abs(c)<1e-12){Math.abs(d)>=1e-12&&b(this,tr,xh).call(this,t,e,s,i,n,a,o,l,-u/d,p);return}const g=d**2-4*u*c;if(g<0)return;const A=Math.sqrt(g),v=2*c;b(this,tr,xh).call(this,t,e,s,i,n,a,o,l,(-d+A)/v,p),b(this,tr,xh).call(this,t,e,s,i,n,a,o,l,(-d-A)/v,p)},f(k,tr),f(k,$a);function Qm(h){return decodeURIComponent(escape(h))}let su=null,Uf=null;function Jm(h){return su||(su=/([\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,Uf=new Map([["ſt","ſt"]])),h.replaceAll(su,(t,e,s)=>e?e.normalize("NFKC"):Uf.get(s))}function Zm(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const h=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(h);else for(let t=0;t<32;t++)h[t]=Math.floor(Math.random()*255);return Ap(h)}const vp="pdfjs_internal_id_",ss={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class $d{constructor(){this.constructor===$d&&tt("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class zd{constructor(){this.constructor===zd&&tt("Cannot initialize BaseCanvasFactory.")}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")}}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){tt("Abstract method `_createCanvas` called.")}}class Vd{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===Vd&&tt("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":""),s=this.isCompressed?ou.BINARY:ou.NONE;return this._fetchData(e,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){tt("Abstract method `_fetchData` called.")}}class Gd{constructor({baseUrl:t=null}){this.constructor===Gd&&tt("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}_fetchData(t){tt("Abstract method `_fetchData` called.")}}class Rf{constructor(){this.constructor===Rf&&tt("Cannot initialize BaseSVGFactory.")}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){tt("Abstract method `_createSVG` called.")}}const ns="http://www.w3.org/2000/svg",wi=class wi{};U(wi,"CSS",96),U(wi,"PDF",72),U(wi,"PDF_TO_CSS_UNITS",wi.CSS/wi.PDF);let mi=wi;var xi,Oe,hs,Yt,sc,Ci,wt,Ot,Vs,zn,Gs,Vn,er,Ch,ic,yp,za,du,Ws,Gn,Ti,wa,Ri,Sa,Va,uu,Pi,xa;class tb extends $d{constructor({docId:e,ownerDocument:s=globalThis.document}={}){super();f(this,wt);f(this,Vs);f(this,Gs);f(this,er);f(this,ic);f(this,za);f(this,Ws);f(this,Ti);f(this,Ri);f(this,Va);f(this,Pi);f(this,xi,void 0);f(this,Oe,void 0);f(this,hs,void 0);f(this,Yt,void 0);f(this,sc,void 0);f(this,Ci,0);m(this,hs,e),m(this,Yt,s)}addFilter(e){if(!e)return"none";let s=r(this,wt,Ot).get(e);if(s)return s;const[i,n,a]=b(this,er,Ch).call(this,e),o=e.length===1?i:`${i}${n}${a}`;if(s=r(this,wt,Ot).get(o),s)return r(this,wt,Ot).set(e,s),s;const l=`g_${r(this,hs)}_transfer_map_${ie(this,Ci)._++}`,c=`url(#${l})`;r(this,wt,Ot).set(e,c),r(this,wt,Ot).set(o,c);const d=b(this,Ws,Gn).call(this,l);return b(this,Ri,Sa).call(this,i,n,a,d),c}addHCMFilter(e,s){var A;const i=`${e}-${s}`,n="base";let a=r(this,Vs,zn).get(n);if((a==null?void 0:a.key)===i||(a?((A=a.filter)==null||A.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},r(this,Vs,zn).set(n,a)),!e||!s))return a.url;const o=b(this,Pi,xa).call(this,e);e=k.makeHexColor(...o);const l=b(this,Pi,xa).call(this,s);if(s=k.makeHexColor(...l),r(this,Gs,Vn).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=new Array(256);for(let v=0;v<=255;v++){const _=v/255;c[v]=_<=.03928?_/12.92:((_+.055)/1.055)**2.4}const d=c.join(","),u=`g_${r(this,hs)}_hcm_filter`,p=a.filter=b(this,Ws,Gn).call(this,u);b(this,Ri,Sa).call(this,d,d,d,p),b(this,za,du).call(this,p);const g=(v,_)=>{const y=o[v]/255,E=l[v]/255,w=new Array(_+1);for(let S=0;S<=_;S++)w[S]=y+S/_*(E-y);return w.join(",")};return b(this,Ri,Sa).call(this,g(0,5),g(1,5),g(2,5),p),a.url=`url(#${u})`,a.url}addAlphaFilter(e){let s=r(this,wt,Ot).get(e);if(s)return s;const[i]=b(this,er,Ch).call(this,[e]),n=`alpha_${i}`;if(s=r(this,wt,Ot).get(n),s)return r(this,wt,Ot).set(e,s),s;const a=`g_${r(this,hs)}_alpha_map_${ie(this,Ci)._++}`,o=`url(#${a})`;r(this,wt,Ot).set(e,o),r(this,wt,Ot).set(n,o);const l=b(this,Ws,Gn).call(this,a);return b(this,Va,uu).call(this,i,l),o}addLuminosityFilter(e){let s=r(this,wt,Ot).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=b(this,er,Ch).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=r(this,wt,Ot).get(n),s)return r(this,wt,Ot).set(e,s),s;const a=`g_${r(this,hs)}_luminosity_map_${ie(this,Ci)._++}`,o=`url(#${a})`;r(this,wt,Ot).set(e,o),r(this,wt,Ot).set(n,o);const l=b(this,Ws,Gn).call(this,a);return b(this,ic,yp).call(this,l),e&&b(this,Va,uu).call(this,i,l),o}addHighlightHCMFilter(e,s,i,n,a){var E;const o=`${s}-${i}-${n}-${a}`;let l=r(this,Vs,zn).get(e);if((l==null?void 0:l.key)===o||(l?((E=l.filter)==null||E.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},r(this,Vs,zn).set(e,l)),!s||!i))return l.url;const[c,d]=[s,i].map(b(this,Pi,xa).bind(this));let u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),p=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[g,A]=[n,a].map(b(this,Pi,xa).bind(this));p<u&&([u,p,g,A]=[p,u,A,g]),r(this,Gs,Vn).style.color="";const v=(w,S,x)=>{const C=new Array(256),R=(p-u)/x,P=w/255,M=(S-w)/(255*x);let O=0;for(let T=0;T<=x;T++){const $=Math.round(u+T*R),D=P+T*M;for(let I=O;I<=$;I++)C[I]=D;O=$+1}for(let T=O;T<256;T++)C[T]=C[O-1];return C.join(",")},_=`g_${r(this,hs)}_hcm_${e}_filter`,y=l.filter=b(this,Ws,Gn).call(this,_);return b(this,za,du).call(this,y),b(this,Ri,Sa).call(this,v(g[0],A[0],5),v(g[1],A[1],5),v(g[2],A[2],5),y),l.url=`url(#${_})`,l.url}destroy(e=!1){e&&r(this,Vs,zn).size!==0||(r(this,Oe)&&(r(this,Oe).parentNode.parentNode.remove(),m(this,Oe,null)),r(this,xi)&&(r(this,xi).clear(),m(this,xi,null)),m(this,Ci,0))}}xi=new WeakMap,Oe=new WeakMap,hs=new WeakMap,Yt=new WeakMap,sc=new WeakMap,Ci=new WeakMap,wt=new WeakSet,Ot=function(){return r(this,xi)||m(this,xi,new Map)},Vs=new WeakSet,zn=function(){return r(this,sc)||m(this,sc,new Map)},Gs=new WeakSet,Vn=function(){if(!r(this,Oe)){const e=r(this,Yt).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=r(this,Yt).createElementNS(ns,"svg");i.setAttribute("width",0),i.setAttribute("height",0),m(this,Oe,r(this,Yt).createElementNS(ns,"defs")),e.append(i),i.append(r(this,Oe)),r(this,Yt).body.append(e)}return r(this,Oe)},er=new WeakSet,Ch=function(e){if(e.length===1){const c=e[0],d=new Array(256);for(let p=0;p<256;p++)d[p]=c[p]/255;const u=d.join(",");return[u,u,u]}const[s,i,n]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let c=0;c<256;c++)a[c]=s[c]/255,o[c]=i[c]/255,l[c]=n[c]/255;return[a.join(","),o.join(","),l.join(",")]},ic=new WeakSet,yp=function(e){const s=r(this,Yt).createElementNS(ns,"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)},za=new WeakSet,du=function(e){const s=r(this,Yt).createElementNS(ns,"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)},Ws=new WeakSet,Gn=function(e){const s=r(this,Yt).createElementNS(ns,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),r(this,Gs,Vn).append(s),s},Ti=new WeakSet,wa=function(e,s,i){const n=r(this,Yt).createElementNS(ns,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},Ri=new WeakSet,Sa=function(e,s,i,n){const a=r(this,Yt).createElementNS(ns,"feComponentTransfer");n.append(a),b(this,Ti,wa).call(this,a,"feFuncR",e),b(this,Ti,wa).call(this,a,"feFuncG",s),b(this,Ti,wa).call(this,a,"feFuncB",i)},Va=new WeakSet,uu=function(e,s){const i=r(this,Yt).createElementNS(ns,"feComponentTransfer");s.append(i),b(this,Ti,wa).call(this,i,"feFuncA",e)},Pi=new WeakSet,xa=function(e){return r(this,Gs,Vn).style.color=e,If(getComputedStyle(r(this,Gs,Vn)).getPropertyValue("color"))};class eb extends zd{constructor({ownerDocument:t=globalThis.document}={}){super(),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}async function Wd(h,t="text"){if(Ca(h,document.baseURI)){const e=await fetch(h);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",h,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class _p extends Vd{_fetchData(t,e){return Wd(t,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):Ud(s),compressionType:e}))}}class Ep extends Gd{_fetchData(t){return Wd(t,"arraybuffer").then(e=>new Uint8Array(e))}}class Pf extends Rf{_createSVG(t){return document.createElementNS(ns,t)}}class ch{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,d,u,p;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,d=0,u=0,p=1;break;case 90:c=0,d=1,u=1,p=0;break;case 270:c=0,d=-1,u=-1,p=0;break;case 0:c=1,d=0,u=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,p=-p);let g,A,v,_;c===0?(g=Math.abs(l-t[1])*e+i,A=Math.abs(o-t[0])*e+n,v=(t[3]-t[1])*e,_=(t[2]-t[0])*e):(g=Math.abs(o-t[0])*e+i,A=Math.abs(l-t[1])*e+n,v=(t[2]-t[0])*e,_=(t[3]-t[1])*e),this.transform=[c*e,d*e,u*e,p*e,g-c*e*o-u*e*l,A-d*e*o-p*e*l],this.width=v,this.height=_}get rawDims(){const{viewBox:t}=this;return X(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new ch({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return k.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=k.applyTransform([t[0],t[1]],this.transform),s=k.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return k.applyInverseTransform([t,e],this.transform)}}class Lf extends bi{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function kf(h){const t=h.length;let e=0;for(;e<t&&h[e].trim()==="";)e++;return h.substring(e,e+5).toLowerCase()==="data:"}function Mf(h){return typeof h=="string"&&/\.pdf$/i.test(h)}function sb(h){return[h]=h.split(/[#?]/,1),h.substring(h.lastIndexOf("/")+1)}function ib(h,t="document.pdf"){if(typeof h!="string")return t;if(kf(h))return V('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(h);let n=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(n&&(n=n[0],n.includes("%")))try{n=s.exec(decodeURIComponent(n))[0]}catch{}return n||t}class $f{constructor(){U(this,"started",Object.create(null));U(this,"times",[])}time(t){t in this.started&&V(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||V(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
`);return t.join("")}}function Ca(h,t){try{const{protocol:e}=t?new URL(h,t):new URL(h);return e==="http:"||e==="https:"}catch{return!1}}function te(h){h.preventDefault()}function wp(h){console.log("Deprecated API usage: "+h)}let zf;class Sp{static toDateObject(t){if(!t||typeof t!="string")return null;zf||(zf=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=zf.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const c=e[7]||"Z";let d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,c==="-"?(a+=d,o+=u):c==="+"&&(a-=d,o-=u),new Date(Date.UTC(s,i,n,a,o,l))}}function nb(h,{scale:t=1,rotation:e=0}){const{width:s,height:i}=h.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new ch({viewBox:n,scale:t,rotation:e})}function If(h){if(h.startsWith("#")){const t=parseInt(h.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return h.startsWith("rgb(")?h.slice(4,-1).split(",").map(t=>parseInt(t)):h.startsWith("rgba(")?h.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(V(`Not a valid color format: "${h}"`),[0,0,0])}function rb(h){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of h.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;h.set(e,If(s))}t.remove()}function lt(h){const{a:t,b:e,c:s,d:i,e:n,f:a}=h.getTransform();return[t,e,s,i,n,a]}function is(h){const{a:t,b:e,c:s,d:i,e:n,f:a}=h.getTransform().invertSelf();return[t,e,s,i,n,a]}function In(h,t,e=!1,s=!0){if(t instanceof ch){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:a}=h,o=Zt.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${n}px`,d=o?`round(${l}, 1px)`:`calc(${l})`,u=o?`round(${c}, 1px)`:`calc(${c})`;!e||t.rotation%180===0?(a.width=d,a.height=u):(a.width=u,a.height=d)}s&&h.setAttribute("data-main-rotation",t.rotation)}var Li,ki,Ne,Mi,nc,xp,rc,Cp,ac,Tp,sr,Th,oc,Rp,Ga,pu;const lc=class lc{constructor(t){f(this,rc);f(this,ac);f(this,sr);f(this,oc);f(this,Ga);f(this,Li,null);f(this,ki,null);f(this,Ne,void 0);f(this,Mi,null);m(this,Ne,t)}render(){const t=m(this,Li,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",te),t.addEventListener("pointerdown",b(lc,nc,xp));const e=m(this,Mi,document.createElement("div"));e.className="buttons",t.append(e);const s=r(this,Ne).toolbarPosition;if(s){const{style:i}=t,n=r(this,Ne)._uiManager.direction==="ltr"?1-s[0]:s[0];i.insetInlineEnd=`${100*n}%`,i.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return b(this,oc,Rp).call(this),t}hide(){var t;r(this,Li).classList.add("hidden"),(t=r(this,ki))==null||t.hideDropdown()}show(){r(this,Li).classList.remove("hidden")}addAltTextButton(t){b(this,sr,Th).call(this,t),r(this,Mi).prepend(t,r(this,Ga,pu))}addColorPicker(t){m(this,ki,t);const e=t.renderButton();b(this,sr,Th).call(this,e),r(this,Mi).prepend(e,r(this,Ga,pu))}remove(){var t;r(this,Li).remove(),(t=r(this,ki))==null||t.destroy(),m(this,ki,null)}};Li=new WeakMap,ki=new WeakMap,Ne=new WeakMap,Mi=new WeakMap,nc=new WeakSet,xp=function(t){t.stopPropagation()},rc=new WeakSet,Cp=function(t){r(this,Ne)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},ac=new WeakSet,Tp=function(t){r(this,Ne)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},sr=new WeakSet,Th=function(t){t.addEventListener("focusin",b(this,rc,Cp).bind(this),{capture:!0}),t.addEventListener("focusout",b(this,ac,Tp).bind(this),{capture:!0}),t.addEventListener("contextmenu",te)},oc=new WeakSet,Rp=function(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${r(this,Ne).editorType}-button`),b(this,sr,Th).call(this,t),t.addEventListener("click",e=>{r(this,Ne)._uiManager.delete()}),r(this,Mi).append(t)},Ga=new WeakSet,pu=function(){const t=document.createElement("div");return t.className="divider",t},f(lc,nc);let fu=lc;var Wa,Ii,qa,hc,Pp,cc,Lp,dc,kp;class ab{constructor(t){f(this,hc);f(this,cc);f(this,dc);f(this,Wa,null);f(this,Ii,null);f(this,qa,void 0);m(this,qa,t)}show(t,e,s){const[i,n]=b(this,cc,Lp).call(this,e,s),{style:a}=r(this,Ii)||m(this,Ii,b(this,hc,Pp).call(this));t.append(r(this,Ii)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){r(this,Ii).remove()}}Wa=new WeakMap,Ii=new WeakMap,qa=new WeakMap,hc=new WeakSet,Pp=function(){const t=m(this,Ii,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",te);const e=m(this,Wa,document.createElement("div"));return e.className="buttons",t.append(e),b(this,dc,kp).call(this),t},cc=new WeakSet,Lp=function(t,e){let s=0,i=0;for(const n of t){const a=n.y+n.height;if(a<s)continue;const o=n.x+(e?n.width:0);if(a>s){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},dc=new WeakSet,kp=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"),t.addEventListener("contextmenu",te),t.addEventListener("click",()=>{r(this,qa).highlightSelection("floating_button")}),r(this,Wa).append(t)};function Yh(h,t,e){for(const s of e)t.addEventListener(s,h[s].bind(h))}function ob(h){return Math.round(Math.min(255,Math.max(1,255*h))).toString(16).padStart(2,"0")}var uc;class lb{constructor(){f(this,uc,0)}get id(){return`${jm}${ie(this,uc)._++}`}}uc=new WeakMap;var Xa,fc,pe,Ya,mu;const Hf=class Hf{constructor(){f(this,Ya);f(this,Xa,Zm());f(this,fc,0);f(this,pe,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"),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return X(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return b(this,Ya,mu).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return b(this,Ya,mu).call(this,t,t)}async getFromId(t){r(this,pe)||m(this,pe,new Map);const e=r(this,pe).get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){const e=r(this,pe).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){r(this,pe)||m(this,pe,new Map);const e=r(this,pe).get(t);e&&(e.refCounter-=1,e.refCounter===0&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${r(this,Xa)}_`)}};Xa=new WeakMap,fc=new WeakMap,pe=new WeakMap,Ya=new WeakSet,mu=async function(t,e){r(this,pe)||m(this,pe,new Map);let s=r(this,pe).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${r(this,Xa)}_${ie(this,fc)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Wd(e,"blob")):i=s.file=e,i.type==="image/svg+xml"){const n=Hf._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((c,d)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,c()},a.onload=async()=>{const u=s.svgUrl=a.result;o.src=await n?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=d});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return r(this,pe).set(t,s),s&&r(this,pe).set(s.id,s),s};let gu=Hf;var St,qs,Ka,xt;class hb{constructor(t=128){f(this,St,[]);f(this,qs,!1);f(this,Ka,void 0);f(this,xt,-1);m(this,Ka,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),r(this,qs))return;const l={cmd:t,undo:e,post:s,type:n};if(r(this,xt)===-1){r(this,St).length>0&&(r(this,St).length=0),m(this,xt,0),r(this,St).push(l);return}if(a&&r(this,St)[r(this,xt)].type===n){o&&(l.undo=r(this,St)[r(this,xt)].undo),r(this,St)[r(this,xt)]=l;return}const c=r(this,xt)+1;c===r(this,Ka)?r(this,St).splice(0,1):(m(this,xt,c),c<r(this,St).length&&r(this,St).splice(c)),r(this,St).push(l)}undo(){if(r(this,xt)===-1)return;m(this,qs,!0);const{undo:t,post:e}=r(this,St)[r(this,xt)];t(),e==null||e(),m(this,qs,!1),m(this,xt,r(this,xt)-1)}redo(){if(r(this,xt)<r(this,St).length-1){m(this,xt,r(this,xt)+1),m(this,qs,!0);const{cmd:t,post:e}=r(this,St)[r(this,xt)];t(),e==null||e(),m(this,qs,!1)}}hasSomethingToUndo(){return r(this,xt)!==-1}hasSomethingToRedo(){return r(this,xt)<r(this,St).length-1}destroy(){m(this,St,null)}}St=new WeakMap,qs=new WeakMap,Ka=new WeakMap,xt=new WeakMap;var pc,Mp;class dh{constructor(t){f(this,pc);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Zt.platform;for(const[s,i,n={}]of t)for(const a of s){const o=a.startsWith("mac+");e&&o?(this.callbacks.set(a.slice(4),{callback:i,options:n}),this.allKeys.add(a.split("+").at(-1))):!e&&!o&&(this.callbacks.set(a,{callback:i,options:n}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(b(this,pc,Mp).call(this,e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:a=[],checker:o=null}}=s;o&&!o(t,e)||(i.bind(t,...a,e)(),n||(e.stopPropagation(),e.preventDefault()))}}pc=new WeakSet,Mp=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 gc=class gc{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return rb(t),X(this,"_colors",t)}convert(t){const e=If(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,a)=>n===e[a]))return gc._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?k.makeHexColor(...e):t}};U(gc,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let bu=gc;var ae,bt,Tt,ir,cs,nr,we,rr,Di,He,ds,Fi,Qa,Ja,Be,ar,Xs,je,mc,Ys,Za,Oi,to,or,Rt,Q,us,Ni,eo,so,io,no,ro,ao,oo,lo,ho,co,uo,fo,po,go,Ks,Ue,fs,mo,lr,Rh,bc,Ip,Ac,Dp,hr,Ph,vc,Fp,yc,Op,_c,Np,bo,Au,Ao,vu,vo,yu,yo,_u,_o,Eu,Pt,$t,$e,js,Ec,Hp,wc,Bp,Eo,wu,Sc,jp,Hi,Ta,wo,Su;const Yn=class Yn{constructor(t,e,s,i,n,a,o,l,c){f(this,lr);f(this,bc);f(this,Ac);f(this,hr);f(this,vc);f(this,yc);f(this,_c);f(this,bo);f(this,Ao);f(this,vo);f(this,yo);f(this,_o);f(this,Pt);f(this,$e);f(this,Ec);f(this,wc);f(this,Eo);f(this,Sc);f(this,Hi);f(this,wo);f(this,ae,null);f(this,bt,new Map);f(this,Tt,new Map);f(this,ir,null);f(this,cs,null);f(this,nr,null);f(this,we,new hb);f(this,rr,0);f(this,Di,new Set);f(this,He,null);f(this,ds,null);f(this,Fi,new Set);f(this,Qa,!1);f(this,Ja,null);f(this,Be,null);f(this,ar,null);f(this,Xs,!1);f(this,je,null);f(this,mc,new lb);f(this,Ys,!1);f(this,Za,!1);f(this,Oi,null);f(this,to,null);f(this,or,null);f(this,Rt,W.NONE);f(this,Q,new Set);f(this,us,null);f(this,Ni,null);f(this,eo,null);f(this,so,this.blur.bind(this));f(this,io,this.focus.bind(this));f(this,no,this.copy.bind(this));f(this,ro,this.cut.bind(this));f(this,ao,this.paste.bind(this));f(this,oo,this.keydown.bind(this));f(this,lo,this.keyup.bind(this));f(this,ho,this.onEditingAction.bind(this));f(this,co,this.onPageChanging.bind(this));f(this,uo,this.onScaleChanging.bind(this));f(this,fo,b(this,Ac,Dp).bind(this));f(this,po,this.onRotationChanging.bind(this));f(this,go,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});f(this,Ks,[0,0]);f(this,Ue,null);f(this,fs,null);f(this,mo,null);m(this,fs,t),m(this,mo,e),m(this,ir,s),this._eventBus=i,this._eventBus._on("editingaction",r(this,ho)),this._eventBus._on("pagechanging",r(this,co)),this._eventBus._on("scalechanging",r(this,uo)),this._eventBus._on("rotationchanging",r(this,po)),b(this,vc,Fp).call(this),b(this,Ao,vu).call(this),m(this,cs,n.annotationStorage),m(this,Ja,n.filterFactory),m(this,Ni,a),m(this,ar,o||null),m(this,Qa,l),m(this,or,c||null),this.viewParameters={realScale:mi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=Yn.prototype,e=a=>r(a,fs).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return X(this,"_keyboardManager",new dh([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,fs).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,fs).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}destroy(){var t,e;b(this,vo,yu).call(this),b(this,bo,Au).call(this),this._eventBus._off("editingaction",r(this,ho)),this._eventBus._off("pagechanging",r(this,co)),this._eventBus._off("scalechanging",r(this,uo)),this._eventBus._off("rotationchanging",r(this,po));for(const s of r(this,Tt).values())s.destroy();r(this,Tt).clear(),r(this,bt).clear(),r(this,Fi).clear(),m(this,ae,null),r(this,Q).clear(),r(this,we).destroy(),(t=r(this,ir))==null||t.destroy(),(e=r(this,je))==null||e.hide(),m(this,je,null),r(this,Be)&&(clearTimeout(r(this,Be)),m(this,Be,null)),r(this,Ue)&&(clearTimeout(r(this,Ue)),m(this,Ue,null)),b(this,yc,Op).call(this)}async mlGuess(t){var e;return((e=r(this,or))==null?void 0:e.guess(t))||null}get hasMLManager(){return!!r(this,or)}get hcmFilter(){return X(this,"hcmFilter",r(this,Ni)?r(this,Ja).addHCMFilter(r(this,Ni).foreground,r(this,Ni).background):"none")}get direction(){return X(this,"direction",getComputedStyle(r(this,fs)).direction)}get highlightColors(){return X(this,"highlightColors",r(this,ar)?new Map(r(this,ar).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)}setMainHighlightColorPicker(t){m(this,to,t)}editAltText(t){var e;(e=r(this,ir))==null||e.editAltText(this,t)}onPageChanging({pageNumber:t}){m(this,rr,t-1)}focusMainContainer(){r(this,fs).focus()}findParent(t,e){for(const s of r(this,Tt).values()){const{x:i,y:n,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=n&&e<=n+o)return s}return null}disableUserSelect(t=!1){r(this,mo).classList.toggle("noUserSelect",t)}addShouldRescale(t){r(this,Fi).add(t)}removeShouldRescale(t){r(this,Fi).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*mi.PDF_TO_CSS_UNITS;for(const e of r(this,Fi))e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a}=e,o=e.toString(),c=b(this,lr,Rh).call(this,e).closest(".textLayer"),d=this.getSelectionBoxes(c);if(d){e.empty(),r(this,Rt)===W.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:W.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const u of r(this,Tt).values())if(u.hasTextLayer(c)){u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a,text:o});break}}}addToAnnotationStorage(t){!t.isEmpty()&&r(this,cs)&&!r(this,cs).has(t.id)&&r(this,cs).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,r(this,Xs)&&(m(this,Xs,!1),b(this,hr,Ph).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of r(this,Q))if(e.div.contains(t)){m(this,Oi,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!r(this,Oi))return;const[t,e]=r(this,Oi);m(this,Oi,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0}),e.focus()}addEditListeners(){b(this,Ao,vu).call(this),b(this,yo,_u).call(this)}removeEditListeners(){b(this,vo,yu).call(this),b(this,_o,Eu).call(this)}copy(t){var s;if(t.preventDefault(),(s=r(this,ae))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of r(this,Q)){const n=i.serialize(!0);n&&e.push(n)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const a of r(this,ds))if(a.isHandlingMimeForPasting(n.type)){a.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){V(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const l of s){const c=i.deserialize(l);if(!c)return;n.push(c)}const a=()=>{for(const l of n)b(this,Eo,wu).call(this,l);b(this,wo,Su).call(this,n)},o=()=>{for(const l of n)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(n){V(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),r(this,Rt)!==W.NONE&&!this.isEditorHandlingKeyboard&&Yn._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,r(this,Xs)&&(m(this,Xs,!1),b(this,hr,Ph).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,_c,Np).call(this),b(this,yo,_u).call(this),b(this,Pt,$t).call(this,{isEditing:r(this,Rt)!==W.NONE,isEmpty:b(this,Hi,Ta).call(this),hasSomethingToUndo:r(this,we).hasSomethingToUndo(),hasSomethingToRedo:r(this,we).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,bo,Au).call(this),b(this,_o,Eu).call(this),b(this,Pt,$t).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!r(this,ds)){m(this,ds,t);for(const e of r(this,ds))b(this,$e,js).call(this,e.defaultPropertiesToUpdate)}}getId(){return r(this,mc).id}get currentLayer(){return r(this,Tt).get(r(this,rr))}getLayer(t){return r(this,Tt).get(t)}get currentPageIndex(){return r(this,rr)}addLayer(t){r(this,Tt).set(t.pageIndex,t),r(this,Ys)?t.enable():t.disable()}removeLayer(t){r(this,Tt).delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(r(this,Rt)!==t){if(m(this,Rt,t),t===W.NONE){this.setEditingState(!1),b(this,wc,Bp).call(this);return}this.setEditingState(!0),b(this,Ec,Hp).call(this),this.unselectAll();for(const i of r(this,Tt).values())i.updateMode(t);if(!e&&s){this.addNewEditorFromKeyboard();return}if(e){for(const i of r(this,bt).values())if(i.annotationElementId===e){this.setSelected(i),i.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==r(this,Rt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(r(this,ds)){switch(t){case j.CREATE:this.currentLayer.addNewEditor();return;case j.HIGHLIGHT_DEFAULT_COLOR:(s=r(this,to))==null||s.updateColor(e);break;case j.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(r(this,eo)||m(this,eo,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of r(this,Q))i.updateParams(t,e);for(const i of r(this,ds))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const a of r(this,bt).values())a.editorType===t&&a.show(e);(((n=r(this,eo))==null?void 0:n.get(j.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,$e,js).call(this,[[j.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(r(this,Za)!==t){m(this,Za,t);for(const e of r(this,Tt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of r(this,bt).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return r(this,bt).get(t)}addEditor(t){r(this,bt).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(r(this,Be)&&clearTimeout(r(this,Be)),m(this,Be,setTimeout(()=>{this.focusMainContainer(),m(this,Be,null)},0))),r(this,bt).delete(t.id),this.unselect(t),(!t.annotationElementId||!r(this,Di).has(t.annotationElementId))&&((e=r(this,cs))==null||e.remove(t.id))}addDeletedAnnotationElement(t){r(this,Di).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return r(this,Di).has(t)}removeDeletedAnnotationElement(t){r(this,Di).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){r(this,ae)!==t&&(m(this,ae,t),t&&b(this,$e,js).call(this,t.propertiesToUpdate))}updateUI(t){r(this,Sc,jp)===t&&b(this,$e,js).call(this,t.propertiesToUpdate)}toggleSelected(t){if(r(this,Q).has(t)){r(this,Q).delete(t),t.unselect(),b(this,Pt,$t).call(this,{hasSelectedEditor:this.hasSelection});return}r(this,Q).add(t),t.select(),b(this,$e,js).call(this,t.propertiesToUpdate),b(this,Pt,$t).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of r(this,Q))e!==t&&e.unselect();r(this,Q).clear(),r(this,Q).add(t),t.select(),b(this,$e,js).call(this,t.propertiesToUpdate),b(this,Pt,$t).call(this,{hasSelectedEditor:!0})}isSelected(t){return r(this,Q).has(t)}get firstSelectedEditor(){return r(this,Q).values().next().value}unselect(t){t.unselect(),r(this,Q).delete(t),b(this,Pt,$t).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return r(this,Q).size!==0}get isEnterHandled(){return r(this,Q).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){r(this,we).undo(),b(this,Pt,$t).call(this,{hasSomethingToUndo:r(this,we).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,Hi,Ta).call(this)})}redo(){r(this,we).redo(),b(this,Pt,$t).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:r(this,we).hasSomethingToRedo(),isEmpty:b(this,Hi,Ta).call(this)})}addCommands(t){r(this,we).add(t),b(this,Pt,$t).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,Hi,Ta).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...r(this,Q)],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)b(this,Eo,wu).call(this,i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){var t;(t=r(this,ae))==null||t.commitOrRemove()}hasSomethingToControl(){return r(this,ae)||this.hasSelection}selectAll(){for(const t of r(this,Q))t.commit();b(this,wo,Su).call(this,r(this,bt).values())}unselectAll(){if(!(r(this,ae)&&(r(this,ae).commitOrRemove(),r(this,Rt)!==W.NONE))&&this.hasSelection){for(const t of r(this,Q))t.unselect();r(this,Q).clear(),b(this,Pt,$t).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;r(this,Ks)[0]+=t,r(this,Ks)[1]+=e;const[i,n]=r(this,Ks),a=[...r(this,Q)],o=1e3;r(this,Ue)&&clearTimeout(r(this,Ue)),m(this,Ue,setTimeout(()=>{m(this,Ue,null),r(this,Ks)[0]=r(this,Ks)[1]=0,this.addCommands({cmd:()=>{for(const l of a)r(this,bt).has(l.id)&&l.translateInPage(i,n)},undo:()=>{for(const l of a)r(this,bt).has(l.id)&&l.translateInPage(-i,-n)},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),m(this,He,new Map);for(const t of r(this,Q))r(this,He).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!r(this,He))return!1;this.disableUserSelect(!1);const t=r(this,He);m(this,He,null);let e=!1;for(const[{x:i,y:n,pageIndex:a},o]of t)o.newX=i,o.newY=n,o.newPageIndex=a,e||(e=i!==o.savedX||n!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,n,a,o)=>{if(r(this,bt).has(i.id)){const l=r(this,Tt).get(o);l?i._setParentAndPosition(l,n,a):(i.pageIndex=o,i.x=n,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:a,newPageIndex:o}]of t)s(i,n,a,o)},undo:()=>{for(const[i,{savedX:n,savedY:a,savedPageIndex:o}]of t)s(i,n,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(r(this,He))for(const s of r(this,He).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||r(this,Q).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return r(this,ae)===t}getActive(){return r(this,ae)}getMode(){return r(this,Rt)}get imageManager(){return X(this,"imageManager",new gu)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,d=e.rangeCount;c<d;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(c,d,u,p)=>({x:(d-i)/a,y:1-(c+u-s)/n,width:p/a,height:u/n});break;case"180":o=(c,d,u,p)=>({x:1-(c+u-s)/n,y:1-(d+p-i)/a,width:u/n,height:p/a});break;case"270":o=(c,d,u,p)=>({x:1-(d+p-i)/a,y:(c-s)/n,width:p/a,height:u/n});break;default:o=(c,d,u,p)=>({x:(c-s)/n,y:(d-i)/a,width:u/n,height:p/a});break}const l=[];for(let c=0,d=e.rangeCount;c<d;c++){const u=e.getRangeAt(c);if(!u.collapsed)for(const{x:p,y:g,width:A,height:v}of u.getClientRects())A===0||v===0||l.push(o(p,g,A,v))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(r(this,nr)||m(this,nr,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=r(this,nr))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=r(this,nr))==null?void 0:i.get(t.data.id);if(!e)return;const s=r(this,cs).getRawValue(e);s&&(r(this,Rt)===W.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}};ae=new WeakMap,bt=new WeakMap,Tt=new WeakMap,ir=new WeakMap,cs=new WeakMap,nr=new WeakMap,we=new WeakMap,rr=new WeakMap,Di=new WeakMap,He=new WeakMap,ds=new WeakMap,Fi=new WeakMap,Qa=new WeakMap,Ja=new WeakMap,Be=new WeakMap,ar=new WeakMap,Xs=new WeakMap,je=new WeakMap,mc=new WeakMap,Ys=new WeakMap,Za=new WeakMap,Oi=new WeakMap,to=new WeakMap,or=new WeakMap,Rt=new WeakMap,Q=new WeakMap,us=new WeakMap,Ni=new WeakMap,eo=new WeakMap,so=new WeakMap,io=new WeakMap,no=new WeakMap,ro=new WeakMap,ao=new WeakMap,oo=new WeakMap,lo=new WeakMap,ho=new WeakMap,co=new WeakMap,uo=new WeakMap,fo=new WeakMap,po=new WeakMap,go=new WeakMap,Ks=new WeakMap,Ue=new WeakMap,fs=new WeakMap,mo=new WeakMap,lr=new WeakSet,Rh=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},bc=new WeakSet,Ip=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,lr,Rh).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(r(this,je)||m(this,je,new ab(this)),r(this,je).show(s,i,this.direction==="ltr"))},Ac=new WeakSet,Dp=function(){var n,a,o;const t=document.getSelection();if(!t||t.isCollapsed){r(this,us)&&((n=r(this,je))==null||n.hide(),m(this,us,null),b(this,Pt,$t).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===r(this,us))return;if(!b(this,lr,Rh).call(this,t).closest(".textLayer")){r(this,us)&&((a=r(this,je))==null||a.hide(),m(this,us,null),b(this,Pt,$t).call(this,{hasSelectedText:!1}));return}if((o=r(this,je))==null||o.hide(),m(this,us,e),b(this,Pt,$t).call(this,{hasSelectedText:!0}),!(r(this,Rt)!==W.HIGHLIGHT&&r(this,Rt)!==W.NONE)&&(r(this,Rt)===W.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),m(this,Xs,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=c=>{c.type==="pointerup"&&c.button!==0||(window.removeEventListener("pointerup",l),window.removeEventListener("blur",l),c.type==="pointerup"&&b(this,hr,Ph).call(this,"main_toolbar"))};window.addEventListener("pointerup",l),window.addEventListener("blur",l)}},hr=new WeakSet,Ph=function(t=""){r(this,Rt)===W.HIGHLIGHT?this.highlightSelection(t):r(this,Qa)&&b(this,bc,Ip).call(this)},vc=new WeakSet,Fp=function(){document.addEventListener("selectionchange",r(this,fo))},yc=new WeakSet,Op=function(){document.removeEventListener("selectionchange",r(this,fo))},_c=new WeakSet,Np=function(){window.addEventListener("focus",r(this,io)),window.addEventListener("blur",r(this,so))},bo=new WeakSet,Au=function(){window.removeEventListener("focus",r(this,io)),window.removeEventListener("blur",r(this,so))},Ao=new WeakSet,vu=function(){window.addEventListener("keydown",r(this,oo)),window.addEventListener("keyup",r(this,lo))},vo=new WeakSet,yu=function(){window.removeEventListener("keydown",r(this,oo)),window.removeEventListener("keyup",r(this,lo))},yo=new WeakSet,_u=function(){document.addEventListener("copy",r(this,no)),document.addEventListener("cut",r(this,ro)),document.addEventListener("paste",r(this,ao))},_o=new WeakSet,Eu=function(){document.removeEventListener("copy",r(this,no)),document.removeEventListener("cut",r(this,ro)),document.removeEventListener("paste",r(this,ao))},Pt=new WeakSet,$t=function(t){Object.entries(t).some(([s,i])=>r(this,go)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(r(this,go),t)}),r(this,Rt)===W.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,$e,js).call(this,[[j.HIGHLIGHT_FREE,!0]]))},$e=new WeakSet,js=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Ec=new WeakSet,Hp=function(){if(!r(this,Ys)){m(this,Ys,!0);for(const t of r(this,Tt).values())t.enable();for(const t of r(this,bt).values())t.enable()}},wc=new WeakSet,Bp=function(){if(this.unselectAll(),r(this,Ys)){m(this,Ys,!1);for(const t of r(this,Tt).values())t.disable();for(const t of r(this,bt).values())t.disable()}},Eo=new WeakSet,wu=function(t){const e=r(this,Tt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Sc=new WeakSet,jp=function(){let t=null;for(t of r(this,Q));return t},Hi=new WeakSet,Ta=function(){if(r(this,bt).size===0)return!0;if(r(this,bt).size===1)for(const t of r(this,bt).values())return t.isEmpty();return!1},wo=new WeakSet,Su=function(t){for(const e of r(this,Q))e.unselect();r(this,Q).clear();for(const e of t)e.isEmpty()||(r(this,Q).add(e),e.select());b(this,Pt,$t).call(this,{hasSelectedEditor:this.hasSelection})},U(Yn,"TRANSLATE_SMALL",1),U(Yn,"TRANSLATE_BIG",10);let Dn=Yn;var ps,gs,Se,ms,xe,cr,bs,So,xu;const rs=class rs{constructor(t){f(this,So);f(this,ps,"");f(this,gs,!1);f(this,Se,null);f(this,ms,null);f(this,xe,null);f(this,cr,!1);f(this,bs,null);m(this,bs,t)}static initialize(t){rs._l10nPromise||(rs._l10nPromise=t)}async render(){const t=m(this,Se,document.createElement("button"));t.className="altText";const e=await rs._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0",t.addEventListener("contextmenu",te),t.addEventListener("pointerdown",i=>i.stopPropagation());const s=i=>{i.preventDefault(),r(this,bs)._uiManager.editAltText(r(this,bs))};return t.addEventListener("click",s,{capture:!0}),t.addEventListener("keydown",i=>{i.target===t&&i.key==="Enter"&&(m(this,cr,!0),s(i))}),await b(this,So,xu).call(this),t}finish(){r(this,Se)&&(r(this,Se).focus({focusVisible:r(this,cr)}),m(this,cr,!1))}isEmpty(){return!r(this,ps)&&!r(this,gs)}get data(){return{altText:r(this,ps),decorative:r(this,gs)}}set data({altText:t,decorative:e}){r(this,ps)===t&&r(this,gs)===e||(m(this,ps,t),m(this,gs,e),b(this,So,xu).call(this))}toggle(t=!1){r(this,Se)&&(!t&&r(this,xe)&&(clearTimeout(r(this,xe)),m(this,xe,null)),r(this,Se).disabled=!t)}destroy(){var t;(t=r(this,Se))==null||t.remove(),m(this,Se,null),m(this,ms,null)}};ps=new WeakMap,gs=new WeakMap,Se=new WeakMap,ms=new WeakMap,xe=new WeakMap,cr=new WeakMap,bs=new WeakMap,So=new WeakSet,xu=async function(){var i;const t=r(this,Se);if(!t)return;if(!r(this,ps)&&!r(this,gs)){t.classList.remove("done"),(i=r(this,ms))==null||i.remove();return}t.classList.add("done"),rs._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(n=>{t.setAttribute("aria-label",n)});let e=r(this,ms);if(!e){m(this,ms,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip");const n=e.id=`alt-text-tooltip-${r(this,bs).id}`;t.setAttribute("aria-describedby",n);const a=100;t.addEventListener("mouseenter",()=>{m(this,xe,setTimeout(()=>{m(this,xe,null),r(this,ms).classList.add("show"),r(this,bs)._reportTelemetry({action:"alt_text_tooltip"})},a))}),t.addEventListener("mouseleave",()=>{var o;r(this,xe)&&(clearTimeout(r(this,xe)),m(this,xe,null)),(o=r(this,ms))==null||o.classList.remove("show")})}e.innerText=r(this,gs)?await rs._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):r(this,ps),e.parentNode||t.append(e);const s=r(this,bs).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},U(rs,"_l10nPromise",null);let Kh=rs;var Ce,zt,dr,Bi,Lt,ji,ur,fr,Nt,xo,Ui,Qs,Co,$i,As,ze,pr,gr,ge,To,xc,Ro,Cu,Po,Tu,Lo,Ru,Cc,Up,Tc,$p,ko,Pu,Mo,Lu,Io,ku,Rc,zp,Pc,Vp,Lc,Gp,kc,Wp,Do,Mu,zi,Ra;const et=class et{constructor(t){f(this,Ro);f(this,Lo);f(this,Cc);f(this,Tc);f(this,ko);f(this,Mo);f(this,Io);f(this,Rc);f(this,Pc);f(this,Lc);f(this,kc);f(this,Do);f(this,zi);f(this,Ce,null);f(this,zt,null);f(this,dr,!1);f(this,Bi,!1);f(this,Lt,null);f(this,ji,null);f(this,ur,this.focusin.bind(this));f(this,fr,this.focusout.bind(this));f(this,Nt,null);f(this,xo,"");f(this,Ui,!1);f(this,Qs,null);f(this,Co,!1);f(this,$i,!1);f(this,As,!1);f(this,ze,null);f(this,pr,0);f(this,gr,0);f(this,ge,null);U(this,"_initialOptions",Object.create(null));U(this,"_isVisible",!0);U(this,"_uiManager",null);U(this,"_focusEventsAllowed",!0);U(this,"_l10nPromise",null);f(this,To,!1);f(this,xc,et._zIndex++);this.constructor===et&&tt("Cannot initialize AnnotationEditor."),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=et.prototype._resizeWithKeyboard,e=Dn.TRANSLATE_SMALL,s=Dn.TRANSLATE_BIG;return X(this,"_resizerKeyboardManager",new dh([[["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"],et.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return X(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new cb({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,s){if(et._l10nPromise||(et._l10nPromise=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(n=>[n,t.get(n.replaceAll(/([A-Z])/g,a=>`-${a.toLowerCase()}`))]))),s!=null&&s.strings)for(const n of s.strings)et._l10nPromise.set(n,t.get(n));if(et._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);et._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){tt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return r(this,To)}set _isDraggable(t){var e;m(this,To,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=r(this,xc)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):b(this,zi,Ra).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(r(this,Ui)?m(this,Ui,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/a,this.fixAndSetPosition()}translate(t,e){b(this,Ro,Cu).call(this,this.parentDimensions,t,e)}translateInPage(t,e){r(this,Qs)||m(this,Qs,[this.x,this.y]),b(this,Ro,Cu).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){r(this,Qs)||m(this,Qs,[this.x,this.y]);const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:c,y:d}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,d)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[o,l]=this.getBaseTranslation();n+=o,a+=l,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!r(this,Qs)&&(r(this,Qs)[0]!==this.x||r(this,Qs)[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=et,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:a,height:o}=this;if(a*=e,o*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-a,i)),n=Math.max(0,Math.min(s-o,n));break;case 90:i=Math.max(0,Math.min(e-o,i)),n=Math.min(s,Math.max(a,n));break;case 180:i=Math.min(e,Math.max(a,i)),n=Math.min(s,Math.max(o,n));break;case 270:i=Math.min(e,Math.max(o,i)),n=Math.max(0,Math.min(s-a,n));break}this.x=i/=e,this.y=n/=s;const[l,c]=this.getBaseTranslation();i+=l,n+=c;const{style:d}=this.div;d.left=`${(100*i).toFixed(2)}%`,d.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return b(s=et,Po,Tu).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=et,Po,Tu).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,i=e*t,n=s*t;return Zt.isCSSRoundSupported?[Math.round(i),Math.round(n)]:[i,n]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,r(this,Bi)||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!r(this,Bi)&&e.endsWith("%");if(i&&n)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!r(this,Bi)&&!n&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=r(this,zt))==null||t.finish()}async addEditToolbar(){return r(this,Nt)||r(this,$i)?r(this,Nt):(m(this,Nt,new fu(this)),this.div.append(r(this,Nt).render()),r(this,zt)&&r(this,Nt).addAltTextButton(await r(this,zt).render()),r(this,Nt))}removeEditToolbar(){var t;r(this,Nt)&&(r(this,Nt).remove(),m(this,Nt,null),(t=r(this,zt))==null||t.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){r(this,zt)||(Kh.initialize(et._l10nPromise),m(this,zt,new Kh(this)),await this.addEditToolbar())}get altTextData(){var t;return(t=r(this,zt))==null?void 0:t.data}set altTextData(t){r(this,zt)&&(r(this,zt).data=t)}hasAltText(){var t;return!((t=r(this,zt))!=null&&t.isEmpty())}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=r(this,dr)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.div.addEventListener("focusin",r(this,ur)),this.div.addEventListener("focusout",r(this,fr));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),Yh(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=Zt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(m(this,Ui,!0),this._isDraggable){b(this,Rc,zp).call(this,t);return}b(this,Io,ku).call(this,t)}moveInDOM(){r(this,ze)&&clearTimeout(r(this,ze)),m(this,ze,setTimeout(()=>{var t;m(this,ze,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,a]=this.pageDimensions,[o,l]=this.pageTranslation,c=t/i,d=e/i,u=this.x*n,p=this.y*a,g=this.width*n,A=this.height*a;switch(s){case 0:return[u+c+o,a-p-d-A+l,u+c+g+o,a-p-d+l];case 90:return[u+d+o,a-p+c+l,u+d+A+o,a-p+c+g+l];case 180:return[u-c-g+o,a-p+d+l,u-c+o,a-p+d+A+l];case 270:return[u-d-A+o,a-p-c-g+l,u-d+o,a-p-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,o=n-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[n,e-i,o,l];case 270:return[n,e-a,l,o];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){m(this,$i,!0)}disableEditMode(){m(this,$i,!1)}isInEditMode(){return r(this,$i)}shouldGetKeyboardEvents(){return r(this,As)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var t,e;(t=this.div)==null||t.addEventListener("focusin",r(this,ur)),(e=this.div)==null||e.addEventListener("focusout",r(this,fr))}rotate(t){}serialize(t=!1,e=null){tt("An editor must be serializable")}static deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation;const[n,a]=i.pageDimensions,[o,l,c,d]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/n,i.y=l/a,i.width=c/n,i.height=d/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",r(this,ur)),this.div.removeEventListener("focusout",r(this,fr)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),r(this,ze)&&(clearTimeout(r(this,ze)),m(this,ze,null)),b(this,zi,Ra).call(this),this.removeEditToolbar(),r(this,ge)){for(const t of r(this,ge).values())clearTimeout(t);m(this,ge,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,Cc,Up).call(this),r(this,Lt).classList.remove("hidden"),Yh(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),m(this,ji,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=r(this,Lt).children;if(!r(this,Ce)){m(this,Ce,Array.from(e));const a=b(this,Pc,Vp).bind(this),o=b(this,Lc,Gp).bind(this);for(const l of r(this,Ce)){const c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",a),l.addEventListener("blur",o),l.addEventListener("focus",b(this,kc,Wp).bind(this,c)),et._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(d=>l.setAttribute("aria-label",d))}}const s=r(this,Ce)[0];let i=0;for(const a of e){if(a===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(r(this,Ce).length/4);if(n!==i){if(n<i)for(let o=0;o<i-n;o++)r(this,Lt).append(r(this,Lt).firstChild);else if(n>i)for(let o=0;o<n-i;o++)r(this,Lt).firstChild.before(r(this,Lt).lastChild);let a=0;for(const o of e){const c=r(this,Ce)[a++].getAttribute("data-resizer-name");et._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(d=>o.setAttribute("aria-label",d))}}b(this,Do,Mu).call(this,0),m(this,As,!0),r(this,Lt).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){r(this,As)&&b(this,Mo,Lu).call(this,r(this,xo),{movementX:t,movementY:e})}_stopResizingWithKeyboard(){b(this,zi,Ra).call(this),this.div.focus()}select(){var t,e;if(this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!r(this,Nt)){this.addEditToolbar().then(()=>{var s,i;(s=this.div)!=null&&s.classList.contains("selectedEditor")&&((i=r(this,Nt))==null||i.show())});return}(e=r(this,Nt))==null||e.show()}unselect(){var t,e,s,i;(t=r(this,Lt))==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=r(this,Nt))==null||i.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return r(this,Co)}set isEditing(t){m(this,Co,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){m(this,Bi,!0);const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){r(this,ge)||m(this,ge,new Map);const{action:s}=t;let i=r(this,ge).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),r(this,ge).delete(s),r(this,ge).size===0&&m(this,ge,null)},et._telemetryTimeout),r(this,ge).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),m(this,dr,!1)}disable(){this.div&&(this.div.tabIndex=-1),m(this,dr,!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.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};Ce=new WeakMap,zt=new WeakMap,dr=new WeakMap,Bi=new WeakMap,Lt=new WeakMap,ji=new WeakMap,ur=new WeakMap,fr=new WeakMap,Nt=new WeakMap,xo=new WeakMap,Ui=new WeakMap,Qs=new WeakMap,Co=new WeakMap,$i=new WeakMap,As=new WeakMap,ze=new WeakMap,pr=new WeakMap,gr=new WeakMap,ge=new WeakMap,To=new WeakMap,xc=new WeakMap,Ro=new WeakSet,Cu=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()},Po=new WeakSet,Tu=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]}},Lo=new WeakSet,Ru=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]}},Cc=new WeakSet,Up=function(){if(r(this,Lt))return;m(this,Lt,document.createElement("div")),r(this,Lt).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"];for(const e of t){const s=document.createElement("div");r(this,Lt).append(s),s.classList.add("resizer",e),s.setAttribute("data-resizer-name",e),s.addEventListener("pointerdown",b(this,Tc,$p).bind(this,e)),s.addEventListener("contextmenu",te),s.tabIndex=-1}this.div.prepend(r(this,Lt))},Tc=new WeakSet,$p=function(t,e){var A;e.preventDefault();const{isMac:s}=Zt.platform;if(e.button!==0||e.ctrlKey&&s)return;(A=r(this,zt))==null||A.toggle(!1);const i=b(this,Mo,Lu).bind(this,t),n=this._isDraggable;this._isDraggable=!1;const a={passive:!0,capture:!0};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,a),window.addEventListener("contextmenu",te);const o=this.x,l=this.y,c=this.width,d=this.height,u=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const g=()=>{var v;this.parent.togglePointerEvents(!0),(v=r(this,zt))==null||v.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",i,a),window.removeEventListener("contextmenu",te),this.parent.div.style.cursor=u,this.div.style.cursor=p,b(this,ko,Pu).call(this,o,l,c,d)};window.addEventListener("pointerup",g),window.addEventListener("blur",g)},ko=new WeakSet,Pu=function(t,e,s,i){const n=this.x,a=this.y,o=this.width,l=this.height;n===t&&a===e&&o===s&&l===i||this.addCommands({cmd:()=>{this.width=o,this.height=l,this.x=n,this.y=a;const[c,d]=this.parentDimensions;this.setDims(c*o,d*l),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[c,d]=this.parentDimensions;this.setDims(c*s,d*i),this.fixAndSetPosition()},mustExec:!0})},Mo=new WeakSet,Lu=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,o=this.width,l=this.height,c=et.MIN_SIZE/s,d=et.MIN_SIZE/i,u=L=>Math.round(L*1e4)/1e4,p=b(this,Lo,Ru).call(this,this.rotation),g=(L,H)=>[p[0]*L+p[2]*H,p[1]*L+p[3]*H],A=b(this,Lo,Ru).call(this,360-this.rotation),v=(L,H)=>[A[0]*L+A[2]*H,A[1]*L+A[3]*H];let _,y,E=!1,w=!1;switch(t){case"topLeft":E=!0,_=(L,H)=>[0,0],y=(L,H)=>[L,H];break;case"topMiddle":_=(L,H)=>[L/2,0],y=(L,H)=>[L/2,H];break;case"topRight":E=!0,_=(L,H)=>[L,0],y=(L,H)=>[0,H];break;case"middleRight":w=!0,_=(L,H)=>[L,H/2],y=(L,H)=>[0,H/2];break;case"bottomRight":E=!0,_=(L,H)=>[L,H],y=(L,H)=>[0,0];break;case"bottomMiddle":_=(L,H)=>[L/2,H],y=(L,H)=>[L/2,0];break;case"bottomLeft":E=!0,_=(L,H)=>[0,H],y=(L,H)=>[L,0];break;case"middleLeft":w=!0,_=(L,H)=>[0,H/2],y=(L,H)=>[L,H/2];break}const S=_(o,l),x=y(o,l);let C=g(...x);const R=u(n+C[0]),P=u(a+C[1]);let M=1,O=1,[T,$]=this.screenToPageTranslation(e.movementX,e.movementY);if([T,$]=v(T/s,$/i),E){const L=Math.hypot(o,l);M=O=Math.max(Math.min(Math.hypot(x[0]-S[0]-T,x[1]-S[1]-$)/L,1/o,1/l),c/o,d/l)}else w?M=Math.max(c,Math.min(1,Math.abs(x[0]-S[0]-T)))/o:O=Math.max(d,Math.min(1,Math.abs(x[1]-S[1]-$)))/l;const D=u(o*M),I=u(l*O);C=g(...y(D,I));const z=R-C[0],Y=P-C[1];this.width=D,this.height=I,this.x=z,this.y=Y,this.setDims(s*D,i*I),this.fixAndSetPosition()},Io=new WeakSet,ku=function(t){const{isMac:e}=Zt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Rc=new WeakSet,zp=function(t){const e=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let s,i;e&&(this.div.classList.add("moving"),s={passive:!0,capture:!0},m(this,pr,t.clientX),m(this,gr,t.clientY),i=a=>{const{clientX:o,clientY:l}=a,[c,d]=this.screenToPageTranslation(o-r(this,pr),l-r(this,gr));m(this,pr,o),m(this,gr,l),this._uiManager.dragSelectedEditors(c,d)},window.addEventListener("pointermove",i,s));const n=()=>{window.removeEventListener("pointerup",n),window.removeEventListener("blur",n),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),m(this,Ui,!1),this._uiManager.endDragSession()||b(this,Io,ku).call(this,t)};window.addEventListener("pointerup",n),window.addEventListener("blur",n)},Pc=new WeakSet,Vp=function(t){et._resizerKeyboardManager.exec(this,t)},Lc=new WeakSet,Gp=function(t){var e;r(this,As)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==r(this,Lt)&&b(this,zi,Ra).call(this)},kc=new WeakSet,Wp=function(t){m(this,xo,r(this,As)?t:"")},Do=new WeakSet,Mu=function(t){if(r(this,Ce))for(const e of r(this,Ce))e.tabIndex=t},zi=new WeakSet,Ra=function(){if(m(this,As,!1),b(this,Do,Mu).call(this,-1),r(this,ji)){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=r(this,ji);b(this,ko,Pu).call(this,t,e,s,i),m(this,ji,null)}},f(et,Po),U(et,"_borderLineWidth",-1),U(et,"_colorManager",new bu),U(et,"_zIndex",1),U(et,"_telemetryTimeout",1e3);let J=et;class cb extends J{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const Vf=3285377520,fe=4294901760,Fe=65535;class qp{constructor(t){this.h1=t?t&4294967295:Vf,this.h2=t?t&4294967295:Vf}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let v=0,_=t.length;v<_;v++){const y=t.charCodeAt(v);y<=255?e[s++]=y:(e[s++]=y>>>8,e[s++]=y&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,c=this.h1,d=this.h2;const u=3432918353,p=461845907,g=u&Fe,A=p&Fe;for(let v=0;v<i;v++)v&1?(o=a[v],o=o*u&fe|o*g&Fe,o=o<<15|o>>>17,o=o*p&fe|o*A&Fe,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[v],l=l*u&fe|l*g&Fe,l=l<<15|l>>>17,l=l*p&fe|l*A&Fe,d^=l,d=d<<13|d>>>19,d=d*5+3864292196);switch(o=0,n){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*u&fe|o*g&Fe,o=o<<15|o>>>17,o=o*p&fe|o*A&Fe,i&1?c^=o:d^=o}this.h1=c,this.h2=d}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&fe|t*36045&Fe,e=e*4283543511&fe|((e<<16|t>>>16)*2950163797&fe)>>>16,t^=e>>>1,t=t*444984403&fe|t*60499&Fe,e=e*3301882366&fe|((e<<16|t>>>16)*3120437893&fe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Iu=Object.freeze({map:null,hash:"",transfer:void 0});var Vi,kt,Mc,Xp;class Df{constructor(){f(this,Mc);f(this,Vi,!1);f(this,kt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=r(this,kt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return r(this,kt).get(t)}remove(t){if(r(this,kt).delete(t),r(this,kt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of r(this,kt).values())if(e instanceof J)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=r(this,kt).get(t);let i=!1;if(s!==void 0)for(const[n,a]of Object.entries(e))s[n]!==a&&(i=!0,s[n]=a);else i=!0,r(this,kt).set(t,e);i&&b(this,Mc,Xp).call(this),e instanceof J&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return r(this,kt).has(t)}getAll(){return r(this,kt).size>0?Tf(r(this,kt)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return r(this,kt).size}resetModified(){r(this,Vi)&&(m(this,Vi,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Yp(this)}get serializable(){if(r(this,kt).size===0)return Iu;const t=new Map,e=new qp,s=[],i=Object.create(null);let n=!1;for(const[a,o]of r(this,kt)){const l=o instanceof J?o.serialize(!1,i):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),n||(n=!!l.bitmap))}if(n)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Iu}get editorStats(){let t=null;const e=new Map;for(const s of r(this,kt).values()){if(!(s instanceof J))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const a=t[n]||(t[n]=new Map);for(const[o,l]of Object.entries(i)){if(o==="type")continue;let c=a.get(o);c||(c=new Map,a.set(o,c));const d=c.get(l)??0;c.set(l,d+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}}Vi=new WeakMap,kt=new WeakMap,Mc=new WeakSet,Xp=function(){r(this,Vi)||(m(this,Vi,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Fo;class Yp extends Df{constructor(e){super();f(this,Fo,void 0);const{map:s,hash:i,transfer:n}=e.serializable,a=structuredClone(s,n?{transfer:n}:null);m(this,Fo,{map:a,hash:i,transfer:n})}get print(){tt("Should not call PrintAnnotationStorage.print")}get serializable(){return r(this,Fo)}}Fo=new WeakMap;var mr;class db{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){f(this,mr,new Set);this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),r(this,mr).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||r(this,mr).has(t.loadedName))){if(_t(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,a=new FontFace(s,i,n);this.addNativeFontFace(a);try{await a.load(),r(this,mr).add(s),e==null||e(t)}catch{V(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}tt("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw V(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return X(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(Bt||typeof navigator<"u"&&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(_t(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return X(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(S,x){return S.charCodeAt(x)<<24|S.charCodeAt(x+1)<<16|S.charCodeAt(x+2)<<8|S.charCodeAt(x+3)&255}function i(S,x,C,R){const P=S.substring(0,x),M=S.substring(x+C);return P+R+M}let n,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let c=0;function d(S,x){if(++c>30){V("Load test font never loaded."),x();return}if(l.font="30px "+S,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){x();return}setTimeout(d.bind(null,S,x))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let p=this._loadTestFont;p=i(p,976,u.length,u);const A=16,v=1482184792;let _=s(p,A);for(n=0,a=u.length-3;n<a;n+=4)_=_-v+s(u,n)|0;n<u.length&&(_=_-v+s(u+"XXX",n)|0),p=i(p,A,4,Xm(_));const y=`url(data:font/opentype;base64,${btoa(p)});`,E=`@font-face {font-family:"${u}";src:${y}}`;this.insertRule(E);const w=this._document.createElement("div");w.style.visibility="hidden",w.style.width=w.style.height="10px",w.style.position="absolute",w.style.top=w.style.left="0px";for(const S of[t.loadedName,u]){const x=this._document.createElement("span");x.textContent="Hi",x.style.fontFamily=S,w.append(x)}this._document.body.append(w),d(u,()=>{w.remove(),e.complete()})}}mr=new WeakMap;class ub{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var i;if(!this.data||this.disableFontFace)return null;const t=Ap(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${e}}`}return(i=this._inspectFont)==null||i.call(this,this,e),s}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){V(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,a){};const i=[];for(let n=0,a=s.length;n<a;)switch(s[n++]){case ss.BEZIER_CURVE_TO:{const[o,l,c,d,u,p]=s.slice(n,n+6);i.push(g=>g.bezierCurveTo(o,l,c,d,u,p)),n+=6}break;case ss.MOVE_TO:{const[o,l]=s.slice(n,n+2);i.push(c=>c.moveTo(o,l)),n+=2}break;case ss.LINE_TO:{const[o,l]=s.slice(n,n+2);i.push(c=>c.lineTo(o,l)),n+=2}break;case ss.QUADRATIC_CURVE_TO:{const[o,l,c,d]=s.slice(n,n+4);i.push(u=>u.quadraticCurveTo(o,l,c,d)),n+=4}break;case ss.RESTORE:i.push(o=>o.restore());break;case ss.SAVE:i.push(o=>o.save());break;case ss.SCALE:_t(i.length===2,"Scale command is only valid at the third position.");break;case ss.TRANSFORM:{const[o,l,c,d,u,p]=s.slice(n,n+6);i.push(g=>g.transform(o,l,c,d,u,p)),n+=6}break;case ss.TRANSLATE:{const[o,l]=s.slice(n,n+2);i.push(c=>c.translate(o,l)),n+=2}break}return this.compiledGlyphs[e]=function(a,o){i[0](a),i[1](a),a.scale(o,-o);for(let l=2,c=i.length;l<c;l++)i[l](a)}}}if(Bt){var Du=Promise.withResolvers(),Ba=null;(async()=>{const t=await bh(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),e=await bh(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await bh(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await bh(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);let n,a;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:a}))})().then(t=>{Ba=t,Du.resolve()},t=>{V(`loadPackages: ${t}`),Ba=new Map,Du.resolve()})}class es{static get promise(){return Du.promise}static get(t){return Ba==null?void 0:Ba.get(t)}}const Kp=function(h){return es.get("fs").promises.readFile(h).then(e=>new Uint8Array(e))};class fb extends $d{}class pb extends zd{_createCanvas(t,e){return es.get("canvas").createCanvas(t,e)}}class gb extends Vd{_fetchData(t,e){return Kp(t).then(s=>({cMapData:s,compressionType:e}))}}class mb extends Gd{_fetchData(t){return Kp(t)}}const Wt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Fu(h,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),h.clip(i)}class uh{constructor(){this.constructor===uh&&tt("Cannot initialize BaseShadingPattern.")}getPattern(){tt("Abstract method `getPattern` called.")}}class bb extends uh{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===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,c=e.cachedCanvases.getCanvas("pattern",o,l,!0),d=c.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-a[0],-a[1]),s=k.transform(s,[1,0,0,1,a[0],a[1]]),d.transform(...e.baseTransform),this.matrix&&d.transform(...this.matrix),Fu(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),n=t.createPattern(c.canvas,"no-repeat");const u=new DOMMatrix(s);n.setTransform(u)}else Fu(t,this._bbox),n=this._createGradient(t);return n}}function iu(h,t,e,s,i,n,a,o){const l=t.coords,c=t.colors,d=h.data,u=h.width*4;let p;l[e+1]>l[s+1]&&(p=e,e=s,s=p,p=n,n=a,a=p),l[s+1]>l[i+1]&&(p=s,s=i,i=p,p=a,a=o,o=p),l[e+1]>l[s+1]&&(p=e,e=s,s=p,p=n,n=a,a=p);const g=(l[e]+t.offsetX)*t.scaleX,A=(l[e+1]+t.offsetY)*t.scaleY,v=(l[s]+t.offsetX)*t.scaleX,_=(l[s+1]+t.offsetY)*t.scaleY,y=(l[i]+t.offsetX)*t.scaleX,E=(l[i+1]+t.offsetY)*t.scaleY;if(A>=E)return;const w=c[n],S=c[n+1],x=c[n+2],C=c[a],R=c[a+1],P=c[a+2],M=c[o],O=c[o+1],T=c[o+2],$=Math.round(A),D=Math.round(E);let I,z,Y,L,H,jt,ue,ee;for(let dt=$;dt<=D;dt++){if(dt<_){const K=dt<A?0:(A-dt)/(A-_);I=g-(g-v)*K,z=w-(w-C)*K,Y=S-(S-R)*K,L=x-(x-P)*K}else{let K;dt>E?K=1:_===E?K=0:K=(_-dt)/(_-E),I=v-(v-y)*K,z=C-(C-M)*K,Y=R-(R-O)*K,L=P-(P-T)*K}let ot;dt<A?ot=0:dt>E?ot=1:ot=(A-dt)/(A-E),H=g-(g-y)*ot,jt=w-(w-M)*ot,ue=S-(S-O)*ot,ee=x-(x-T)*ot;const Dt=Math.round(Math.min(I,H)),ve=Math.round(Math.max(I,H));let qt=u*dt+Dt*4;for(let K=Dt;K<=ve;K++)ot=(I-K)/(I-H),ot<0?ot=0:ot>1&&(ot=1),d[qt++]=z-(z-jt)*ot|0,d[qt++]=Y-(Y-ue)*ot|0,d[qt++]=L-(L-ee)*ot|0,d[qt++]=255}}function Ab(h,t,e){const s=t.coords,i=t.colors;let n,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,c=o-1;for(n=0;n<l;n++){let d=n*o;for(let u=0;u<c;u++,d++)iu(h,e,s[d],s[d+1],s[d+o],i[d],i[d+1],i[d+o]),iu(h,e,s[d+o+1],s[d+1],s[d+o],i[d+o+1],i[d+1],i[d+o])}break;case"triangles":for(n=0,a=s.length;n<a;n+=3)iu(h,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class vb extends uh{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,d=Math.ceil(this._bounds[3])-l,u=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3),p=Math.min(Math.ceil(Math.abs(d*t[1]*1.1)),3e3),g=c/u,A=d/p,v={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/A},_=u+2*2,y=p+2*2,E=s.getCanvas("mesh",_,y,!1),w=E.context,S=w.createImageData(u,p);if(e){const C=S.data;for(let R=0,P=C.length;R<P;R+=4)C[R]=e[0],C[R+1]=e[1],C[R+2]=e[2],C[R+3]=255}for(const C of this._figures)Ab(S,C,v);return w.putImageData(S,2,2),{canvas:E.canvas,offsetX:o-2*g,offsetY:l-2*A,scaleX:g,scaleY:A}}getPattern(t,e,s,i){Fu(t,this._bbox);let n;if(i===Wt.SHADING)n=k.singularValueDecompose2dScale(lt(t));else if(n=k.singularValueDecompose2dScale(e.baseTransform),this.matrix){const o=k.singularValueDecompose2dScale(this.matrix);n=[n[0]*o[0],n[1]*o[1]]}const a=this._createMeshCanvas(n,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 yb extends uh{getPattern(){return"hotpink"}}function _b(h){switch(h[0]){case"RadialAxial":return new bb(h);case"Mesh":return new vb(h);case"Dummy":return new yb}throw new Error(`Unknown IR type: ${h[0]}`)}const Gf={COLORED:1,UNCOLORED:2},Ic=class Ic{constructor(t,e,s,i,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,i=this.xstep,n=this.ystep,a=this.paintType,o=this.tilingType,l=this.color,c=this.canvasGraphicsFactory;Bd("TilingType: "+o);const d=s[0],u=s[1],p=s[2],g=s[3],A=k.singularValueDecompose2dScale(this.matrix),v=k.singularValueDecompose2dScale(this.baseTransform),_=[A[0]*v[0],A[1]*v[1]],y=this.getSizeAndScale(i,this.ctx.canvas.width,_[0]),E=this.getSizeAndScale(n,this.ctx.canvas.height,_[1]),w=t.cachedCanvases.getCanvas("pattern",y.size,E.size,!0),S=w.context,x=c.createCanvasGraphics(S);x.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(x,a,l);let C=d,R=u,P=p,M=g;return d<0&&(C=0,P+=Math.abs(d)),u<0&&(R=0,M+=Math.abs(u)),S.translate(-(y.scale*C),-(E.scale*R)),x.transform(y.scale,0,0,E.scale,0,0),S.save(),this.clipBbox(x,C,R,P,M),x.baseTransform=lt(x.ctx),x.executeOperatorList(e),x.endDrawing(),{canvas:w.canvas,scaleX:y.scale,scaleY:E.scale,offsetX:C,offsetY:R}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(Ic.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const a=i-e,o=n-s;t.ctx.rect(e,s,a,o),t.current.updateRectMinMax(lt(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Gf.COLORED:const a=this.ctx;i.fillStyle=a.fillStyle,i.strokeStyle=a.strokeStyle,n.fillColor=a.fillStyle,n.strokeColor=a.strokeStyle;break;case Gf.UNCOLORED:const o=k.makeHexColor(s[0],s[1],s[2]);i.fillStyle=o,i.strokeStyle=o,n.fillColor=o,n.strokeColor=o;break;default:throw new qm(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==Wt.SHADING&&(n=k.transform(n,e.baseTransform),this.matrix&&(n=k.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let o=new DOMMatrix(n);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}};U(Ic,"MAX_PATTERN_SIZE",3e3);let Ou=Ic;function Eb({src:h,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:a=!1}){const o=Zt.isLittleEndian?4278190080:255,[l,c]=a?[n,o]:[o,n],d=s>>3,u=s&7,p=h.length;e=new Uint32Array(e.buffer);let g=0;for(let A=0;A<i;A++){for(const _=t+d;t<_;t++){const y=t<p?h[t]:255;e[g++]=y&128?c:l,e[g++]=y&64?c:l,e[g++]=y&32?c:l,e[g++]=y&16?c:l,e[g++]=y&8?c:l,e[g++]=y&4?c:l,e[g++]=y&2?c:l,e[g++]=y&1?c:l}if(u===0)continue;const v=t<p?h[t++]:255;for(let _=0;_<u;_++)e[g++]=v&1<<7-_?c:l}return{srcPos:t,destPos:g}}const Wf=16,qf=100,wb=15,Xf=10,Yf=1e3,Qt=16;function Sb(h,t){if(h._removeMirroring)throw new Error("Context is already forwarding operations.");h.__originalSave=h.save,h.__originalRestore=h.restore,h.__originalRotate=h.rotate,h.__originalScale=h.scale,h.__originalTranslate=h.translate,h.__originalTransform=h.transform,h.__originalSetTransform=h.setTransform,h.__originalResetTransform=h.resetTransform,h.__originalClip=h.clip,h.__originalMoveTo=h.moveTo,h.__originalLineTo=h.lineTo,h.__originalBezierCurveTo=h.bezierCurveTo,h.__originalRect=h.rect,h.__originalClosePath=h.closePath,h.__originalBeginPath=h.beginPath,h._removeMirroring=()=>{h.save=h.__originalSave,h.restore=h.__originalRestore,h.rotate=h.__originalRotate,h.scale=h.__originalScale,h.translate=h.__originalTranslate,h.transform=h.__originalTransform,h.setTransform=h.__originalSetTransform,h.resetTransform=h.__originalResetTransform,h.clip=h.__originalClip,h.moveTo=h.__originalMoveTo,h.lineTo=h.__originalLineTo,h.bezierCurveTo=h.__originalBezierCurveTo,h.rect=h.__originalRect,h.closePath=h.__originalClosePath,h.beginPath=h.__originalBeginPath,delete h._removeMirroring},h.save=function(){t.save(),this.__originalSave()},h.restore=function(){t.restore(),this.__originalRestore()},h.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},h.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},h.transform=function(s,i,n,a,o,l){t.transform(s,i,n,a,o,l),this.__originalTransform(s,i,n,a,o,l)},h.setTransform=function(s,i,n,a,o,l){t.setTransform(s,i,n,a,o,l),this.__originalSetTransform(s,i,n,a,o,l)},h.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},h.rotate=function(s){t.rotate(s),this.__originalRotate(s)},h.clip=function(s){t.clip(s),this.__originalClip(s)},h.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},h.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},h.bezierCurveTo=function(e,s,i,n,a,o){t.bezierCurveTo(e,s,i,n,a,o),this.__originalBezierCurveTo(e,s,i,n,a,o)},h.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},h.closePath=function(){t.closePath(),this.__originalClosePath()},h.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class xb{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 vh(h,t,e,s,i,n,a,o,l,c){const[d,u,p,g,A,v]=lt(h);if(u===0&&p===0){const E=a*d+A,w=Math.round(E),S=o*g+v,x=Math.round(S),C=(a+l)*d+A,R=Math.abs(Math.round(C)-w)||1,P=(o+c)*g+v,M=Math.abs(Math.round(P)-x)||1;return h.setTransform(Math.sign(d),0,0,Math.sign(g),w,x),h.drawImage(t,e,s,i,n,0,0,R,M),h.setTransform(d,u,p,g,A,v),[R,M]}if(d===0&&g===0){const E=o*p+A,w=Math.round(E),S=a*u+v,x=Math.round(S),C=(o+c)*p+A,R=Math.abs(Math.round(C)-w)||1,P=(a+l)*u+v,M=Math.abs(Math.round(P)-x)||1;return h.setTransform(0,Math.sign(u),Math.sign(p),0,w,x),h.drawImage(t,e,s,i,n,0,0,M,R),h.setTransform(d,u,p,g,A,v),[M,R]}h.drawImage(t,e,s,i,n,a,o,l,c);const _=Math.hypot(d,u),y=Math.hypot(p,g);return[_*l,y*c]}function Cb(h){const{width:t,height:e}=h;if(t>Yf||e>Yf)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let a=new Uint8Array(n*(e+1)),o,l,c;const d=t+7&-8;let u=new Uint8Array(d*e),p=0;for(const y of h.data){let E=128;for(;E>0;)u[p++]=y&E?0:255,E>>=1}let g=0;for(p=0,u[p]!==0&&(a[0]=1,++g),l=1;l<t;l++)u[p]!==u[p+1]&&(a[l]=u[p]?2:1,++g),p++;for(u[p]!==0&&(a[l]=2,++g),o=1;o<e;o++){p=o*d,c=o*n,u[p-d]!==u[p]&&(a[c]=u[p]?1:8,++g);let y=(u[p]?4:0)+(u[p-d]?8:0);for(l=1;l<t;l++)y=(y>>2)+(u[p+1]?4:0)+(u[p-d+1]?8:0),i[y]&&(a[c+l]=i[y],++g),p++;if(u[p-d]!==u[p]&&(a[c+l]=u[p]?2:4,++g),g>s)return null}for(p=d*(e-1),c=o*n,u[p]!==0&&(a[c]=8,++g),l=1;l<t;l++)u[p]!==u[p+1]&&(a[c+l]=u[p]?4:8,++g),p++;if(u[p]!==0&&(a[c+l]=4,++g),g>s)return null;const A=new Int32Array([0,n,-1,0,-n,0,0,0,1]),v=new Path2D;for(o=0;g&&o<=e;o++){let y=o*n;const E=y+t;for(;y<E&&!a[y];)y++;if(y===E)continue;v.moveTo(y%n,o);const w=y;let S=a[y];do{const x=A[S];do y+=x;while(!a[y]);const C=a[y];C!==5&&C!==10?(S=C,a[y]=0):(S=C&51*S>>4,a[y]&=S>>2|S<<2),v.lineTo(y%n,y/n|0),a[y]||--g}while(w!==y);--o}return u=null,a=null,function(y){y.save(),y.scale(1/t,-1/e),y.translate(0,-e),y.fill(v),y.beginPath(),y.restore()}}class Kf{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=mp,this.textMatrixScale=1,this.fontMatrix=au,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=Ft.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=k.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=k.applyTransform(e,t),i=k.applyTransform(e.slice(2),t),n=k.applyTransform([e[0],e[3]],t),a=k.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],a[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],a[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],a[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],a[1])}updateScalingPathMinMax(t,e){k.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,a,o,l,c,d){const u=k.bezierBoundingBox(e,s,i,n,a,o,l,c,d);d||this.updateRectMinMax(t,u)}getPathBoundingBox(t=Wt.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Wt.STROKE){e||tt("Stroke bounding box must include transform.");const i=k.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,a=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=a,s[2]+=n,s[3]+=a}return s}updateClipFromPath(){const t=k.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 k.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Qf(h,t){if(typeof ImageData<"u"&&t instanceof ImageData){h.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%Qt,n=(e-i)/Qt,a=i===0?n:n+1,o=h.createImageData(s,Qt);let l=0,c;const d=t.data,u=o.data;let p,g,A,v;if(t.kind===Sh.GRAYSCALE_1BPP){const _=d.byteLength,y=new Uint32Array(u.buffer,0,u.byteLength>>2),E=y.length,w=s+7>>3,S=4294967295,x=Zt.isLittleEndian?4278190080:255;for(p=0;p<a;p++){for(A=p<n?Qt:i,c=0,g=0;g<A;g++){const C=_-l;let R=0;const P=C>w?s:C*8-7,M=P&-8;let O=0,T=0;for(;R<M;R+=8)T=d[l++],y[c++]=T&128?S:x,y[c++]=T&64?S:x,y[c++]=T&32?S:x,y[c++]=T&16?S:x,y[c++]=T&8?S:x,y[c++]=T&4?S:x,y[c++]=T&2?S:x,y[c++]=T&1?S:x;for(;R<P;R++)O===0&&(T=d[l++],O=128),y[c++]=T&O?S:x,O>>=1}for(;c<E;)y[c++]=0;h.putImageData(o,0,p*Qt)}}else if(t.kind===Sh.RGBA_32BPP){for(g=0,v=s*Qt*4,p=0;p<n;p++)u.set(d.subarray(l,l+v)),l+=v,h.putImageData(o,0,g),g+=Qt;p<a&&(v=s*i*4,u.set(d.subarray(l,l+v)),h.putImageData(o,0,g))}else if(t.kind===Sh.RGB_24BPP)for(A=Qt,v=s*A,p=0;p<a;p++){for(p>=n&&(A=i,v=s*A),c=0,g=v;g--;)u[c++]=d[l++],u[c++]=d[l++],u[c++]=d[l++],u[c++]=255;h.putImageData(o,0,p*Qt)}else throw new Error(`bad image kind: ${t.kind}`)}function Jf(h,t){if(t.bitmap){h.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%Qt,n=(e-i)/Qt,a=i===0?n:n+1,o=h.createImageData(s,Qt);let l=0;const c=t.data,d=o.data;for(let u=0;u<a;u++){const p=u<n?Qt:i;({srcPos:l}=Eb({src:c,srcPos:l,dest:d,width:s,height:p,nonBlackColor:0})),h.putImageData(o,0,u*Qt)}}function _a(h,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)h[s]!==void 0&&(t[s]=h[s]);h.setLineDash!==void 0&&(t.setLineDash(h.getLineDash()),t.lineDashOffset=h.lineDashOffset)}function yh(h){if(h.strokeStyle=h.fillStyle="#000000",h.fillRule="nonzero",h.globalAlpha=1,h.lineWidth=1,h.lineCap="butt",h.lineJoin="miter",h.miterLimit=10,h.globalCompositeOperation="source-over",h.font="10px sans-serif",h.setLineDash!==void 0&&(h.setLineDash([]),h.lineDashOffset=0),!Bt){const{filter:t}=h;t!=="none"&&t!==""&&(h.filter="none")}}function Zf(h,t){if(t)return!0;const e=k.singularValueDecompose2dScale(h);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*mi.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const Tb=["butt","round","square"],Rb=["miter","round","bevel"],Pb={},tp={};var Oo,Nu,No,Hu;const Bf=class Bf{constructor(t,e,s,i,n,{optionalContentConfig:a,markedContentStack:o=null},l,c){f(this,Oo);f(this,No);this.ctx=t,this.current=new Kf(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedCanvases=new xb(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=o,s){const l=this.cachedCanvases.getCanvas("transparent",n,a);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...lt(this.compositeCtx))}this.ctx.save(),yh(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 n=t.argsArray,a=t.fnArray;let o=e||0;const l=n.length;if(l===o)return o;const c=l-o>Xf&&typeof s=="function",d=c?Date.now()+wb:0;let u=0;const p=this.commonObjs,g=this.objs;let A;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(A=a[o],A!==Ee.dependency)this[A].apply(this,n[o]);else for(const v of n[o]){const _=v.startsWith("g_")?p:g;if(!_.has(v))return _.get(v,s),o}if(o++,o===l)return o;if(c&&++u>Xf){if(Date.now()>d)return s(),o;u=0}}}endDrawing(){b(this,Oo,Nu).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),b(this,No,Hu).call(this)}_scaleImage(t,e){const s=t.width,i=t.height;let n=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=s,l=i,c="prescale1",d,u;for(;n>2&&o>1||a>2&&l>1;){let p=o,g=l;n>2&&o>1&&(p=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),n/=o/p),a>2&&l>1&&(g=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/g),d=this.cachedCanvases.getCanvas(c,p,g),u=d.context,u.clearRect(0,0,p,g),u.drawImage(t,0,0,o,l,0,0,p,g),t=d.canvas,o=p,l=g,c=c==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,a=this.current.patternFill,o=lt(e);let l,c,d,u;if((t.bitmap||t.data)&&t.count>1){const P=t.bitmap||t.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),n]),l=this._cachedBitmapsMap.get(P),l||(l=new Map,this._cachedBitmapsMap.set(P,l));const M=l.get(c);if(M&&!a){const O=Math.round(Math.min(o[0],o[2])+o[4]),T=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:M,offsetX:O,offsetY:T}}d=M}d||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),Jf(u.context,t));let p=k.transform(o,[1/s,0,0,-1/i,0,0]);p=k.transform(p,[1,0,0,1,0,-i]);const[g,A,v,_]=k.getAxialAlignedBoundingBox([0,0,s,i],p),y=Math.round(v-g)||1,E=Math.round(_-A)||1,w=this.cachedCanvases.getCanvas("fillCanvas",y,E),S=w.context,x=g,C=A;S.translate(-x,-C),S.transform(...p),d||(d=this._scaleImage(u.canvas,is(S)),d=d.img,l&&a&&l.set(c,d)),S.imageSmoothingEnabled=Zf(lt(S),t.interpolate),vh(S,d,0,0,d.width,d.height,0,0,s,i),S.globalCompositeOperation="source-in";const R=k.transform(is(S),[1,0,0,1,-x,-C]);return S.fillStyle=a?n.getPattern(e,this,R,Wt.FILL):n,S.fillRect(0,0,s,i),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,w.canvas)),{canvas:w.canvas,offsetX:Math.round(x),offsetY:Math.round(C)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Tb[t]}setLineJoin(t){this.ctx.lineJoin=Rb[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...lt(this.suspendedCtx)),_a(this.suspendedCtx,n),Sb(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),_a(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){const n=i[0],a=i[1],o=i[2]-n,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,a,o,l,c,d,u){let p=t.canvas,g=l-d,A=c-u;if(a){if(g<0||A<0||g+s>p.width||A+i>p.height){const _=this.cachedCanvases.getCanvas("maskExtension",s,i),y=_.context;y.drawImage(p,-g,-A),a.some(E=>E!==0)&&(y.globalCompositeOperation="destination-atop",y.fillStyle=k.makeHexColor(...a),y.fillRect(0,0,s,i),y.globalCompositeOperation="source-over"),p=_.canvas,g=A=0}else if(a.some(_=>_!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const _=new Path2D;_.rect(g,A,s,i),t.clip(_),t.globalCompositeOperation="destination-atop",t.fillStyle=k.makeHexColor(...a),t.fillRect(g,A,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const v=new Path2D;v.rect(l,c,s,i),e.clip(v),e.globalCompositeOperation="destination-in",e.drawImage(p,g,A,s,i,l,c,s,i),e.restore()}save(){this.inSMaskMode?(_a(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(),_a(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,a){this.ctx.transform(t,e,s,i,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let a=n.x,o=n.y,l,c;const d=lt(i),u=d[0]===0&&d[3]===0||d[1]===0&&d[2]===0,p=u?s.slice(0):null;for(let g=0,A=0,v=t.length;g<v;g++)switch(t[g]|0){case Ee.rectangle:a=e[A++],o=e[A++];const _=e[A++],y=e[A++],E=a+_,w=o+y;i.moveTo(a,o),_===0||y===0?i.lineTo(E,w):(i.lineTo(E,o),i.lineTo(E,w),i.lineTo(a,w)),u||n.updateRectMinMax(d,[a,o,E,w]),i.closePath();break;case Ee.moveTo:a=e[A++],o=e[A++],i.moveTo(a,o),u||n.updatePathMinMax(d,a,o);break;case Ee.lineTo:a=e[A++],o=e[A++],i.lineTo(a,o),u||n.updatePathMinMax(d,a,o);break;case Ee.curveTo:l=a,c=o,a=e[A+4],o=e[A+5],i.bezierCurveTo(e[A],e[A+1],e[A+2],e[A+3],a,o),n.updateCurvePathMinMax(d,l,c,e[A],e[A+1],e[A+2],e[A+3],a,o,p),A+=6;break;case Ee.curveTo2:l=a,c=o,i.bezierCurveTo(a,o,e[A],e[A+1],e[A+2],e[A+3]),n.updateCurvePathMinMax(d,l,c,a,o,e[A],e[A+1],e[A+2],e[A+3],p),a=e[A+2],o=e[A+3],A+=4;break;case Ee.curveTo3:l=a,c=o,a=e[A+2],o=e[A+3],i.bezierCurveTo(e[A],e[A+1],a,o,a,o),n.updateCurvePathMinMax(d,l,c,e[A],e[A+1],a,o,a,o,p),A+=4;break;case Ee.closePath:i.closePath();break}u&&n.updateScalingPathMinMax(d,p),n.setCurrentPoint(a,o)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&(s!=null&&s.getPattern)?(e.save(),e.strokeStyle=s.getPattern(e,this,is(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 n=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,is(e),Wt.FILL),n=!0);const a=this.current.getClippedPathBoundingBox();this.contentVisible&&a!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Pb}eoClip(){this.pendingClip=tp}beginText(){this.current.textMatrix=mp,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var d;const s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||au,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&V("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",a=((d=s.systemFontInfo)==null?void 0:d.css)||`"${n}", ${s.fallbackName}`;let o="normal";s.black?o="900":s.bold&&(o="bold");const l=s.italic?"italic":"normal";let c=e;e<Wf?c=Wf:e>qf&&(c=qf),this.current.fontSizeScale=e/c,this.ctx.font=`${l} ${o} ${c}px ${a}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,a){this.current.textMatrix=[t,e,s,i,n,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const n=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,d=l&Ft.FILL_STROKE_MASK,u=!!(l&Ft.ADD_TO_PATH_FLAG),p=a.patternFill&&!o.missingFile;let g;(o.disableFontFace||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||p?(n.save(),n.translate(e,s),n.beginPath(),g(n,c),i&&n.setTransform(...i),(d===Ft.FILL||d===Ft.FILL_STROKE)&&n.fill(),(d===Ft.STROKE||d===Ft.FILL_STROKE)&&n.stroke(),n.restore()):((d===Ft.FILL||d===Ft.FILL_STROKE)&&n.fillText(t,e,s),(d===Ft.STROKE||d===Ft.FILL_STROKE)&&n.strokeText(t,e,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:lt(n),x:e,y:s,fontSize:c,addToPath:g})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return 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 n=this.ctx,a=e.fontSizeScale,o=e.charSpacing,l=e.wordSpacing,c=e.fontDirection,d=e.textHScale*c,u=t.length,p=s.vertical,g=p?1:-1,A=s.defaultVMetrics,v=i*e.fontMatrix[0],_=e.textRenderingMode===Ft.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),c>0?n.scale(d,-1):n.scale(d,1);let y;if(e.patternFill){n.save();const C=e.fillColor.getPattern(n,this,is(n),Wt.FILL);y=lt(n),n.restore(),n.fillStyle=C}let E=e.lineWidth;const w=e.textMatrixScale;if(w===0||E===0){const C=e.textRenderingMode&Ft.FILL_STROKE_MASK;(C===Ft.STROKE||C===Ft.FILL_STROKE)&&(E=this.getSinglePixelWidth())}else E/=w;if(a!==1&&(n.scale(a,a),E/=a),n.lineWidth=E,s.isInvalidPDFjsFont){const C=[];let R=0;for(const P of t)C.push(P.unicode),R+=P.width;n.fillText(C.join(""),0,0),e.x+=R*v*d,n.restore(),this.compose();return}let S=0,x;for(x=0;x<u;++x){const C=t[x];if(typeof C=="number"){S+=g*C*i/1e3;continue}let R=!1;const P=(C.isSpace?l:0)+o,M=C.fontChar,O=C.accent;let T,$,D=C.width;if(p){const z=C.vmetric||A,Y=-(C.vmetric?z[1]:D*.5)*v,L=z[2]*v;D=z?-z[0]:D,T=Y/a,$=(S+L)/a}else T=S/a,$=0;if(s.remeasure&&D>0){const z=n.measureText(M).width*1e3/i*a;if(D<z&&this.isFontSubpixelAAEnabled){const Y=D/z;R=!0,n.save(),n.scale(Y,1),T/=Y}else D!==z&&(T+=(D-z)/2e3*i/a)}if(this.contentVisible&&(C.isInFont||s.missingFile)){if(_&&!O)n.fillText(M,T,$);else if(this.paintChar(M,T,$,y),O){const z=T+i*O.offset.x/a,Y=$-i*O.offset.y/a;this.paintChar(O.fontChar,z,Y,y)}}const I=p?D*v-P*c:D*v+P*c;S+=I,R&&n.restore()}p?e.y-=S:e.x+=S*d,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,a=s.fontDirection,o=i.vertical?1:-1,l=s.charSpacing,c=s.wordSpacing,d=s.textHScale*a,u=s.fontMatrix||au,p=t.length,g=s.textRenderingMode===Ft.INVISIBLE;let A,v,_,y;if(!(g||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(d,a),A=0;A<p;++A){if(v=t[A],typeof v=="number"){y=o*v*n/1e3,this.ctx.translate(y,0),s.x+=y*d;continue}const E=(v.isSpace?c:0)+l,w=i.charProcOperatorList[v.operatorListId];if(!w){V(`Type3 character "${v.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=v,this.save(),e.scale(n,n),e.transform(...u),this.executeOperatorList(w),this.restore()),_=k.applyTransform([v.width,0],u)[0]*n+E,e.translate(_,0),s.x+=_*d}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,a){this.ctx.rect(s,i,n-s,a-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||lt(this.ctx),n={createCanvasGraphics:a=>new Bf(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ou(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const i=k.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=k.makeHexColor(t,e,s);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=_b(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,is(e),Wt.SHADING);const i=is(e);if(i){const{width:n,height:a}=e.canvas,[o,l,c,d]=k.getAxialAlignedBoundingBox([0,0,n,a],i);this.ctx.fillRect(o,l,c-o,d-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){tt("Should not call beginInlineImage")}beginImageData(){tt("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||Bd("TODO: Support non-isolated groups."),t.knockout&&V("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=k.getAxialAlignedBoundingBox(t.bbox,lt(e));const n=[0,0,e.canvas.width,e.canvas.height];i=k.intersect(i,n)||[0,0,0,0];const a=Math.floor(i[0]),o=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-a,1),c=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,c]);let d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,l,c),p=u.context;p.translate(-a,-o),p.transform(...s),t.smask?this.smaskStack.push({canvas:u.canvas,context:p,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()),_a(e,p),this.ctx=p,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 n=k.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(b(this,Oo,Nu).call(this),yh(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const a=e[2]-e[0],o=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=a,e[3]=o;const[l,c]=k.singularValueDecompose2dScale(lt(this.ctx)),{viewportScale:d}=this,u=Math.ceil(a*this.outputScaleX*d),p=Math.ceil(o*this.outputScaleY*d);this.annotationCanvas=this.canvasFactory.create(u,p);const{canvas:g,context:A}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=A,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,o*c),yh(this.ctx)}else yh(this.ctx),this.ctx.rect(e[0],e[1],a,o),this.ctx.clip(),this.endPath()}this.current=new Kf(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),b(this,No,Hu).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=Cb(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),a=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const l=lt(o);o.transform(e,s,i,n,0,0);const c=this._createMaskCanvas(t);o.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let d=0,u=a.length;d<u;d+=2){const p=k.transform(l,[e,s,i,n,a[d],a[d+1]]),[g,A]=k.applyTransform([0,0],p);o.drawImage(c.canvas,g,A)}o.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:a,width:o,height:l,transform:c}=n,d=this.cachedCanvases.getCanvas("maskCanvas",o,l),u=d.context;u.save();const p=this.getObject(a,n);Jf(u,p),u.globalCompositeOperation="source-in",u.fillStyle=i?s.getPattern(u,this,is(e),Wt.FILL):s,u.fillRect(0,0,o,l),u.restore(),e.save(),e.transform(...c),e.scale(1,-1),vh(e,d.canvas,0,0,o,l,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){V("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n){V("Dependent image isn't ready yet");return}const a=n.width,o=n.height,l=[];for(let c=0,d=i.length;c<d;c+=2)l.push({transform:[e,0,0,s,i[c],i[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(n,l)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!Bt){const{filter:o}=i;o!=="none"&&o!==""&&(i.filter="none")}i.scale(1/e,-1/s);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const l=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Qf(l,t),n=this.applyTransferMapsToCanvas(l)}const a=this._scaleImage(n,is(i));i.imageSmoothingEnabled=Zf(lt(i),t.interpolate),vh(i,a.img,0,0,a.paintWidth,a.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,a=t.height,l=this.cachedCanvases.getCanvas("inlineImage",n,a).context;Qf(l,t),i=this.applyTransferMapsToCanvas(l)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),vh(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===tp?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:n}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),c=Math.abs(n);if(l===c)if(t===0)a=o=1/l;else{const d=l*t;a=o=d<1?1/d:1}else if(t===0)a=1/l,o=1/c;else{const d=l*t,u=c*t;a=d<1?1/d:1,o=u<1?1/u:1}}else{const l=Math.abs(e*n-s*i),c=Math.hypot(e,s),d=Math.hypot(i,n);if(t===0)a=d/l,o=c/l;else{const u=t*l;a=d>u?d/u:1,o=c>u?c/u:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const a=e.getLineDash();if(t&&e.save(),e.scale(i,n),a.length>0){const o=Math.max(i,n);e.setLineDash(a.map(l=>l/o)),e.lineDashOffset/=o}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Oo=new WeakSet,Nu=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},No=new WeakSet,Hu=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}};let Kn=Bf;for(const h in Ee)Kn.prototype[h]!==void 0&&(Kn.prototype[Ee[h]]=Kn.prototype[h]);var Ho,Bo;class Os{static get workerPort(){return r(this,Ho)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");m(this,Ho,t)}static get workerSrc(){return r(this,Bo)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");m(this,Bo,t)}}Ho=new WeakMap,Bo=new WeakMap,f(Os,Ho,null),f(Os,Bo,"");const _h={UNKNOWN:0,DATA:1,ERROR:2},gt={UNKNOWN:0,CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function ne(h){switch(h instanceof Error||typeof h=="object"&&h!==null||tt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),h.name){case"AbortException":return new Hn(h.message);case"MissingPDFException":return new Nn(h.message);case"PasswordException":return new lu(h.message,h.code);case"UnexpectedResponseException":return new jd(h.message,h.status);case"UnknownErrorException":return new hu(h.message,h.details);default:return new hu(h.message,h.toString())}}var Dc,Qp,Fc,Jp,br,Lh;class Pa{constructor(t,e,s){f(this,Dc);f(this,Fc);f(this,br);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),this._onComObjOnMessage=i=>{const n=i.data;if(n.targetName!==this.sourceName)return;if(n.stream){b(this,Fc,Jp).call(this,n);return}if(n.callback){const o=n.callbackId,l=this.callbackCapabilities[o];if(!l)throw new Error(`Cannot resolve callback ${o}`);if(delete this.callbackCapabilities[o],n.callback===_h.DATA)l.resolve(n.data);else if(n.callback===_h.ERROR)l.reject(ne(n.reason));else throw new Error("Unexpected callback case");return}const a=this.actionHandler[n.action];if(!a)throw new Error(`Unknown action from worker: ${n.action}`);if(n.callbackId){const o=this.sourceName,l=n.sourceName;new Promise(function(c){c(a(n.data))}).then(function(c){s.postMessage({sourceName:o,targetName:l,callback:_h.DATA,callbackId:n.callbackId,data:c})},function(c){s.postMessage({sourceName:o,targetName:l,callback:_h.ERROR,callbackId:n.callbackId,reason:ne(c)})});return}if(n.streamId){b(this,Dc,Qp).call(this,n);return}a(n.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){n.reject(a)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const d=Promise.withResolvers();return this.streamControllers[n]={controller:c,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:n,data:e,desiredSize:c.desiredSize},i),d.promise},pull:c=>{const d=Promise.withResolvers();return this.streamControllers[n].pullCall=d,l.postMessage({sourceName:a,targetName:o,stream:gt.PULL,streamId:n,desiredSize:c.desiredSize}),d.promise},cancel:c=>{_t(c instanceof Error,"cancel must have a valid reason");const d=Promise.withResolvers();return this.streamControllers[n].cancelCall=d,this.streamControllers[n].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:gt.CANCEL,streamId:n,reason:ne(c)}),d.promise}},s)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}Dc=new WeakSet,Qp=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(c,d=1,u){if(this.isCancelled)return;const p=this.desiredSize;this.desiredSize-=d,p>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:gt.ENQUEUE,streamId:e,chunk:c},u)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:gt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(c){_t(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:gt.ERROR,streamId:e,reason:ne(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,new Promise(function(c){c(o(t.data,l))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:gt.START_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:gt.START_COMPLETE,streamId:e,reason:ne(c)})})},Fc=new WeakSet,Jp=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case gt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(ne(t.reason));break;case gt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(ne(t.reason));break;case gt.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:gt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,new Promise(function(l){var c;l((c=o.onPull)==null?void 0:c.call(o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:gt.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:gt.PULL_COMPLETE,streamId:e,reason:ne(l)})});break;case gt.ENQUEUE:if(_t(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case gt.CLOSE:if(_t(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,br,Lh).call(this,a,e);break;case gt.ERROR:_t(a,"error should have stream controller"),a.controller.error(ne(t.reason)),b(this,br,Lh).call(this,a,e);break;case gt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(ne(t.reason)),b(this,br,Lh).call(this,a,e);break;case gt.CANCEL:if(!o)break;new Promise(function(l){var c;l((c=o.onCancel)==null?void 0:c.call(o,ne(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:gt.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:gt.CANCEL_COMPLETE,streamId:e,reason:ne(l)})}),o.sinkCapability.reject(ne(t.reason)),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},br=new WeakSet,Lh=async function(t,e){var s,i,n;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(n=t.cancelCall)==null?void 0:n.promise]),delete this.streamControllers[e]};var Gi,jo;class Lb{constructor({parsedData:t,rawData:e}){f(this,Gi,void 0);f(this,jo,void 0);m(this,Gi,t),m(this,jo,e)}getRaw(){return r(this,jo)}get(t){return r(this,Gi).get(t)??null}getAll(){return Tf(r(this,Gi))}has(t){return r(this,Gi).has(t)}}Gi=new WeakMap,jo=new WeakMap;const Us=Symbol("INTERNAL");var Uo,$o,zo,Ar;class kb{constructor(t,{name:e,intent:s,usage:i}){f(this,Uo,!1);f(this,$o,!1);f(this,zo,!1);f(this,Ar,!0);m(this,Uo,!!(t&Ae.DISPLAY)),m(this,$o,!!(t&Ae.PRINT)),this.name=e,this.intent=s,this.usage=i}get visible(){if(r(this,zo))return r(this,Ar);if(!r(this,Ar))return!1;const{print:t,view:e}=this.usage;return r(this,Uo)?(e==null?void 0:e.viewState)!=="OFF":r(this,$o)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Us&&tt("Internal method `_setVisible` called."),m(this,zo,s),m(this,Ar,e)}}Uo=new WeakMap,$o=new WeakMap,zo=new WeakMap,Ar=new WeakMap;var Js,Z,vr,yr,Vo,Bu;class Mb{constructor(t,e=Ae.DISPLAY){f(this,Vo);f(this,Js,null);f(this,Z,new Map);f(this,vr,null);f(this,yr,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,m(this,yr,t.order);for(const s of t.groups)r(this,Z).set(s.id,new kb(e,s));if(t.baseState==="OFF")for(const s of r(this,Z).values())s._setVisible(Us,!1);for(const s of t.on)r(this,Z).get(s)._setVisible(Us,!0);for(const s of t.off)r(this,Z).get(s)._setVisible(Us,!1);m(this,vr,this.getHash())}}isVisible(t){if(r(this,Z).size===0)return!0;if(!t)return Bd("Optional content group not defined."),!0;if(t.type==="OCG")return r(this,Z).has(t.id)?r(this,Z).get(t.id).visible:(V(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,Vo,Bu).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!r(this,Z).has(e))return V(`Optional content group not found: ${e}`),!0;if(r(this,Z).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!r(this,Z).has(e))return V(`Optional content group not found: ${e}`),!0;if(!r(this,Z).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!r(this,Z).has(e))return V(`Optional content group not found: ${e}`),!0;if(!r(this,Z).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!r(this,Z).has(e))return V(`Optional content group not found: ${e}`),!0;if(r(this,Z).get(e).visible)return!1}return!0}return V(`Unknown optional content policy ${t.policy}.`),!0}return V(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=r(this,Z).get(t);if(!s){V(`Optional content group not found: ${t}`);return}s._setVisible(Us,!!e,!0),m(this,Js,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=r(this,Z).get(i);if(n)switch(s){case"ON":n._setVisible(Us,!0);break;case"OFF":n._setVisible(Us,!1);break;case"Toggle":n._setVisible(Us,!n.visible);break}}m(this,Js,null)}get hasInitialVisibility(){return r(this,vr)===null||this.getHash()===r(this,vr)}getOrder(){return r(this,Z).size?r(this,yr)?r(this,yr).slice():[...r(this,Z).keys()]:null}getGroups(){return r(this,Z).size>0?Tf(r(this,Z)):null}getGroup(t){return r(this,Z).get(t)||null}getHash(){if(r(this,Js)!==null)return r(this,Js);const t=new qp;for(const[e,s]of r(this,Z))t.update(`${e}:${s.visible}`);return m(this,Js,t.hexdigest())}}Js=new WeakMap,Z=new WeakMap,vr=new WeakMap,yr=new WeakMap,Vo=new WeakSet,Bu=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let a;if(Array.isArray(n))a=b(this,Vo,Bu).call(this,n);else if(r(this,Z).has(n))a=r(this,Z).get(n).visible;else return V(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};class Ib{constructor(t,{disableRange:e=!1,disableStream:s=!1}){_t(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:a,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(n==null?void 0:n.length)>0){const l=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,c)=>{this._onReceiveData({begin:l,chunk:c})}),t.addProgressListener((l,c)=>{this._onProgress({loaded:l,total:c})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});_t(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,i,n;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(n=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||n.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){_t(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Db(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Fb(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 Db{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Mf(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Fb{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ob(h){let t=!0,e=s("filename\\*","i").exec(h);if(e){e=e[1];let d=o(e);return d=unescape(d),d=l(d),d=c(d),n(d)}if(e=a(h),e){const d=c(e);return n(d)}if(e=s("filename","i").exec(h),e){e=e[1];let d=o(e);return d=c(d),n(d)}function s(d,u){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(d,u){if(d){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const p=new TextDecoder(d,{fatal:!0}),g=Ud(u);u=p.decode(g),t=!1}catch{}}return u}function n(d){return t&&/[\x80-\xff]/.test(d)&&(d=i("utf-8",d),t&&(d=i("iso-8859-1",d))),d}function a(d){const u=[];let p;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(p=g.exec(d))!==null;){let[,v,_,y]=p;if(v=parseInt(v,10),v in u){if(v===0)break;continue}u[v]=[_,y]}const A=[];for(let v=0;v<u.length&&v in u;++v){let[_,y]=u[v];y=o(y),_&&(y=unescape(y),v===0&&(y=l(y))),A.push(y)}return A.join("")}function o(d){if(d.startsWith('"')){const u=d.slice(1).split('\\"');for(let p=0;p<u.length;++p){const g=u[p].indexOf('"');g!==-1&&(u[p]=u[p].slice(0,g),u.length=p+1),u[p]=u[p].replaceAll(/\\(.)/g,"$1")}d=u.join('"')}return d}function l(d){const u=d.indexOf("'");if(u===-1)return d;const p=d.slice(0,u),A=d.slice(u+1).replace(/^[^']*'/,"");return i(p,A)}function c(d){return!d.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(d)?d:d.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(u,p,g,A){if(g==="q"||g==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(v,_){return String.fromCharCode(parseInt(_,16))}),i(p,A);try{A=atob(A)}catch{}return i(p,A)})}return""}function Ff({getResponseHeader:h,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(h("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||h("Accept-Ranges")!=="bytes"||(h("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Of(h){const t=h("Content-Disposition");if(t){let e=Ob(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Mf(e))return e}return null}function qd(h,t){return h===404||h===0&&t.startsWith("file:")?new Nn('Missing PDF "'+t+'".'):new jd(`Unexpected server response (${h}) while retrieving PDF "${t}".`,h)}function Zp(h){return h===200||h===206}function tg(h,t,e){return{method:"GET",headers:h,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function eg(h){const t=new Headers;for(const e in h){const s=h[e];s!==void 0&&t.append(e,s)}return t}function sg(h){return h instanceof Uint8Array?h.buffer:h instanceof ArrayBuffer?h:(V(`getArrayBuffer - unexpected data format: ${h}`),new Uint8Array(h).buffer)}class ep{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return _t(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Nb(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Hb(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 Nb{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,this._headers=eg(this._stream.httpHeaders);const s=e.url;fetch(s,tg(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!Zp(i.status))throw qd(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=l=>i.headers.get(l),{allowRangeRequests:a,suggestedLength:o}=Ff({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=Of(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Hn("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:sg(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class Hb{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,this._headers=eg(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,tg(this._headers,this._withCredentials,this._abortController)).then(a=>{if(!Zp(a.status))throw qd(a.status,n);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:sg(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const nu=200,ru=206;function Bb(h){const t=h.response;return typeof t!="string"?t:Ud(t).buffer}class jb{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const n in this.httpHeaders){const a=this.httpHeaders[n];a!==void 0&&e.setRequestHeader(n,a)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=ru):i.expectedStatus=nu,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){var l,c,d;const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){(l=s.onError)==null||l.call(s,i.status);return}const n=i.status||nu;if(!(n===nu&&s.expectedStatus===ru)&&n!==s.expectedStatus){(c=s.onError)==null||c.call(s,i.status);return}const o=Bb(i);if(n===ru){const u=i.getResponseHeader("Content-Range"),p=/bytes (\d+)-(\d+)\/(\d+)/.exec(u);s.onDone({begin:parseInt(p[1],10),chunk:o})}else o?s.onDone({begin:0,chunk:o}):(d=s.onError)==null||d.call(s,i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Ub{constructor(t){this._source=t,this._manager=new jb(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),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 _t(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new $b(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new zb(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 $b{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),s=a=>e.getResponseHeader(a),{allowRangeRequests:i,suggestedLength:n}=Ff({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Of(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=qd(t,this._url),this._headersReceivedCapability.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._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersReceivedCapability.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 zb{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=qd(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const ig=/^file:\/\/\/[a-zA-Z]:\//;function Vb(h){const t=es.get("url"),e=t.parse(h);return e.protocol==="file:"||e.host?e:/^[a-z]:[/\\]/i.test(h)?t.parse(`file:///${h}`):(e.host||(e.protocol="file:"),e)}class Gb{constructor(t){this.source=t,this.url=Vb(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return _t(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new Xb(this):new Wb(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new Yb(this,t,e):new qb(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 ng{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Hn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class rg{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function Qh(h,t){return{protocol:h.protocol,auth:h.auth,host:h.hostname,port:h.port,path:h.path,method:"GET",headers:t}}class Wb extends ng{constructor(t){super(t);const e=s=>{if(s.statusCode===404){const o=new Nn(`Missing PDF "${this._url}".`);this._storedError=o,this._headersCapability.reject(o);return}this._headersCapability.resolve(),this._setReadableStream(s);const i=o=>this._readableStream.headers[o.toLowerCase()],{allowRangeRequests:n,suggestedLength:a}=Ff({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=Of(i)};if(this._request=null,this._url.protocol==="http:"){const s=es.get("http");this._request=s.request(Qh(this._url,t.httpHeaders),e)}else{const s=es.get("https");this._request=s.request(Qh(this._url,t.httpHeaders),e)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class qb extends rg{constructor(t,e,s){super(t),this._httpHeaders={};for(const n in t.httpHeaders){const a=t.httpHeaders[n];a!==void 0&&(this._httpHeaders[n]=a)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const i=n=>{if(n.statusCode===404){const a=new Nn(`Missing PDF "${this._url}".`);this._storedError=a;return}this._setReadableStream(n)};if(this._request=null,this._url.protocol==="http:"){const n=es.get("http");this._request=n.request(Qh(this._url,this._httpHeaders),i)}else{const n=es.get("https");this._request=n.request(Qh(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class Xb extends ng{constructor(t){super(t);let e=decodeURIComponent(this._url.path);ig.test(this._url.href)&&(e=e.replace(/^\//,""));const s=es.get("fs");s.promises.lstat(e).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(e)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new Nn(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class Yb extends rg{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);ig.test(this._url.href)&&(i=i.replace(/^\//,""));const n=es.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const Kb=1e5,Xt=30,Qb=.8;var pp,Zs,Kt,Go,Wo,Wi,vs,qo,Xo,qi,_r,Er,ti,wr,Yo,Sr,Xi,Ko,Qo,Jt,Yi,Ki,xr,Oc,ag,Nc,og,Jo,ju,Cr,kh,Hc,lg;let Jh=(Jt=class{constructor({textContentSource:t,container:e,viewport:s}){f(this,Oc);f(this,Nc);f(this,Jo);f(this,Zs,Promise.withResolvers());f(this,Kt,null);f(this,Go,!1);f(this,Wo,!!((pp=globalThis.FontInspector)!=null&&pp.enabled));f(this,Wi,null);f(this,vs,null);f(this,qo,0);f(this,Xo,0);f(this,qi,null);f(this,_r,null);f(this,Er,0);f(this,ti,0);f(this,wr,Object.create(null));f(this,Yo,[]);f(this,Sr,null);f(this,Xi,[]);f(this,Ko,new WeakMap);f(this,Qo,null);if(t instanceof ReadableStream)m(this,Sr,t);else if(typeof t=="object")m(this,Sr,new ReadableStream({start(l){l.enqueue(t),l.close()}}));else throw new Error('No "textContentSource" parameter specified.');m(this,Kt,m(this,_r,e)),m(this,ti,s.scale*(globalThis.devicePixelRatio||1)),m(this,Er,s.rotation),m(this,vs,{prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:a,pageY:o}=s.rawDims;m(this,Qo,[1,0,0,-1,-a,o+n]),m(this,Xo,i),m(this,qo,n),In(e,s),r(this,Zs).promise.catch(()=>{}).then(()=>{r(Jt,xr).delete(this),m(this,vs,null),m(this,wr,null)})}render(){const t=()=>{r(this,qi).read().then(({value:e,done:s})=>{if(s){r(this,Zs).resolve();return}r(this,Wi)??m(this,Wi,e.lang),Object.assign(r(this,wr),e.styles),b(this,Oc,ag).call(this,e.items),t()},r(this,Zs).reject)};return m(this,qi,r(this,Sr).getReader()),r(Jt,xr).add(this),t(),r(this,Zs).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==r(this,Er)&&(e==null||e(),m(this,Er,i),In(r(this,_r),{rotation:i})),s!==r(this,ti)){e==null||e(),m(this,ti,s);const a={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:b(n=Jt,Cr,kh).call(n,r(this,Wi))};for(const o of r(this,Xi))a.properties=r(this,Ko).get(o),a.div=o,b(this,Jo,ju).call(this,a)}}cancel(){var e;const t=new Hn("TextLayer task cancelled.");(e=r(this,qi))==null||e.cancel(t).catch(()=>{}),m(this,qi,null),r(this,Zs).reject(t)}get textDivs(){return r(this,Xi)}get textContentItemsStr(){return r(this,Yo)}static cleanup(){if(!(r(this,xr).size>0)){r(this,Yi).clear();for(const{canvas:t}of r(this,Ki).values())t.remove();r(this,Ki).clear()}}},Zs=new WeakMap,Kt=new WeakMap,Go=new WeakMap,Wo=new WeakMap,Wi=new WeakMap,vs=new WeakMap,qo=new WeakMap,Xo=new WeakMap,qi=new WeakMap,_r=new WeakMap,Er=new WeakMap,ti=new WeakMap,wr=new WeakMap,Yo=new WeakMap,Sr=new WeakMap,Xi=new WeakMap,Ko=new WeakMap,Qo=new WeakMap,Yi=new WeakMap,Ki=new WeakMap,xr=new WeakMap,Oc=new WeakSet,ag=function(t){var i,n;if(r(this,Go))return;(n=r(this,vs)).ctx||(n.ctx=b(i=Jt,Cr,kh).call(i,r(this,Wi)));const e=r(this,Xi),s=r(this,Yo);for(const a of t){if(e.length>Kb){V("Ignoring additional textDivs for performance reasons."),m(this,Go,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=r(this,Kt);m(this,Kt,document.createElement("span")),r(this,Kt).classList.add("markedContent"),a.id!==null&&r(this,Kt).setAttribute("id",`${a.id}`),o.append(r(this,Kt))}else a.type==="endMarkedContent"&&m(this,Kt,r(this,Kt).parentNode);continue}s.push(a.str),b(this,Nc,og).call(this,a)}},Nc=new WeakSet,og=function(t){var v;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};r(this,Xi).push(e);const i=k.transform(r(this,Qo),t.transform);let n=Math.atan2(i[1],i[0]);const a=r(this,wr)[t.fontName];a.vertical&&(n+=Math.PI/2);const o=r(this,Wo)&&a.fontSubstitution||a.fontFamily,l=Math.hypot(i[2],i[3]),c=l*b(v=Jt,Hc,lg).call(v,o,r(this,Wi));let d,u;n===0?(d=i[4],u=i[5]-c):(d=i[4]+c*Math.sin(n),u=i[5]-c*Math.cos(n));const p="calc(var(--scale-factor)*",g=e.style;r(this,Kt)===r(this,_r)?(g.left=`${(100*d/r(this,Xo)).toFixed(2)}%`,g.top=`${(100*u/r(this,qo)).toFixed(2)}%`):(g.left=`${p}${d.toFixed(2)}px)`,g.top=`${p}${u.toFixed(2)}px)`),g.fontSize=`${p}${l.toFixed(2)}px)`,g.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,r(this,Wo)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const _=Math.abs(t.transform[0]),y=Math.abs(t.transform[3]);_!==y&&Math.max(_,y)/Math.min(_,y)>1.5&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),r(this,Ko).set(e,s),r(this,vs).div=e,r(this,vs).properties=s,b(this,Jo,ju).call(this,r(this,vs)),s.hasText&&r(this,Kt).append(e),s.hasEOL){const _=document.createElement("br");_.setAttribute("role","presentation"),r(this,Kt).append(_)}},Jo=new WeakSet,ju=function(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:a}=t,{style:o}=e;let l="";if(s.canvasWidth!==0&&s.hasText){const{fontFamily:c}=o,{canvasWidth:d,fontSize:u}=s;(n!==u||a!==c)&&(i.font=`${u*r(this,ti)}px ${c}`,t.prevFontSize=u,t.prevFontFamily=c);const{width:p}=i.measureText(e.textContent);p>0&&(l=`scaleX(${d*r(this,ti)/p})`)}s.angle!==0&&(l=`rotate(${s.angle}deg) ${l}`),l.length>0&&(o.transform=l)},Cr=new WeakSet,kh=function(t=null){let e=r(this,Ki).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}),r(this,Ki).set(t,e)}return e},Hc=new WeakSet,lg=function(t,e){const s=r(this,Yi).get(t);if(s)return s;const i=b(this,Cr,kh).call(this,e),n=i.font;i.canvas.width=i.canvas.height=Xt,i.font=`${Xt}px ${t}`;const a=i.measureText("");let o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);if(o){const u=o/(o+l);return r(this,Yi).set(t,u),i.canvas.width=i.canvas.height=0,i.font=n,u}i.strokeStyle="red",i.clearRect(0,0,Xt,Xt),i.strokeText("g",0,0);let c=i.getImageData(0,0,Xt,Xt).data;l=0;for(let u=c.length-1-3;u>=0;u-=4)if(c[u]>0){l=Math.ceil(u/4/Xt);break}i.clearRect(0,0,Xt,Xt),i.strokeText("A",0,Xt),c=i.getImageData(0,0,Xt,Xt).data,o=0;for(let u=0,p=c.length;u<p;u+=4)if(c[u]>0){o=Xt-Math.floor(u/4/Xt);break}i.canvas.width=i.canvas.height=0,i.font=n;const d=o?o/(o+l):Qb;return r(this,Yi).set(t,d),d},f(Jt,Cr),f(Jt,Hc),f(Jt,Yi,new Map),f(Jt,Ki,new Map),f(Jt,xr,new Set),Jt);function Jb(){wp("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:h,container:t,viewport:e,...s}=arguments[0],i=Object.keys(s);i.length>0&&V("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new Jh({textContentSource:h,container:t,viewport:e}),{textDivs:a,textContentItemsStr:o}=n;return{promise:n.render(),textDivs:a,textContentItemsStr:o}}function Zb(){wp("`updateTextLayer`, please use `TextLayer` instead.")}class Ua{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){var l;if(!n)return;let a=null;const o=n.name;if(o==="#text")a=n.value;else if(Ua.shouldBuildText(o))(l=n==null?void 0:n.attributes)!=null&&l.textContent?a=n.attributes.textContent:n.value&&(a=n.value);else return;if(a!==null&&e.push({str:a}),!!n.children)for(const c of n.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const tA=65536,eA=100,sA=5e3,iA=Bt?pb:eb,nA=Bt?gb:_p,rA=Bt?fb:tb,aA=Bt?mb:Ep;function oA(h){if(typeof h=="string"||h instanceof URL?h={url:h}:(h instanceof ArrayBuffer||ArrayBuffer.isView(h))&&(h={data:h}),typeof h!="object")throw new Error("Invalid parameter in getDocument, need parameter object.");if(!h.url&&!h.data&&!h.range)throw new Error("Invalid parameter object: need either .data, .range or .url");const t=new Uu,{docId:e}=t,s=h.url?lA(h.url):null,i=h.data?hA(h.data):null,n=h.httpHeaders||null,a=h.withCredentials===!0,o=h.password??null,l=h.range instanceof hg?h.range:null,c=Number.isInteger(h.rangeChunkSize)&&h.rangeChunkSize>0?h.rangeChunkSize:tA;let d=h.worker instanceof Qn?h.worker:null;const u=h.verbosity,p=typeof h.docBaseUrl=="string"&&!kf(h.docBaseUrl)?h.docBaseUrl:null,g=typeof h.cMapUrl=="string"?h.cMapUrl:null,A=h.cMapPacked!==!1,v=h.CMapReaderFactory||nA,_=typeof h.standardFontDataUrl=="string"?h.standardFontDataUrl:null,y=h.StandardFontDataFactory||aA,E=h.stopAtErrors!==!0,w=Number.isInteger(h.maxImageSize)&&h.maxImageSize>-1?h.maxImageSize:-1,S=h.isEvalSupported!==!1,x=typeof h.isOffscreenCanvasSupported=="boolean"?h.isOffscreenCanvasSupported:!Bt,C=Number.isInteger(h.canvasMaxAreaInBytes)?h.canvasMaxAreaInBytes:-1,R=typeof h.disableFontFace=="boolean"?h.disableFontFace:Bt,P=h.fontExtraProperties===!0,M=h.enableXfa===!0,O=h.ownerDocument||globalThis.document,T=h.disableRange===!0,$=h.disableStream===!0,D=h.disableAutoFetch===!0,I=h.pdfBug===!0,z=l?l.length:h.length??NaN,Y=typeof h.useSystemFonts=="boolean"?h.useSystemFonts:!Bt&&!R,L=typeof h.useWorkerFetch=="boolean"?h.useWorkerFetch:v===_p&&y===Ep&&g&&_&&Ca(g,document.baseURI)&&Ca(_,document.baseURI),H=h.canvasFactory||new iA({ownerDocument:O}),jt=h.filterFactory||new rA({docId:e,ownerDocument:O}),ue=null;zm(u);const ee={canvasFactory:H,filterFactory:jt};if(L||(ee.cMapReaderFactory=new v({baseUrl:g,isCompressed:A}),ee.standardFontDataFactory=new y({baseUrl:_})),!d){const Dt={verbosity:u,port:Os.workerPort};d=Dt.port?Qn.fromPort(Dt):new Qn(Dt),t._worker=d}const dt={docId:e,apiVersion:"4.3.136",data:i,password:o,disableAutoFetch:D,rangeChunkSize:c,length:z,docBaseUrl:p,enableXfa:M,evaluatorOptions:{maxImageSize:w,disableFontFace:R,ignoreErrors:E,isEvalSupported:S,isOffscreenCanvasSupported:x,canvasMaxAreaInBytes:C,fontExtraProperties:P,useSystemFonts:Y,cMapUrl:L?g:null,standardFontDataUrl:L?_:null}},ot={disableFontFace:R,fontExtraProperties:P,ownerDocument:O,pdfBug:I,styleElement:ue,loadingParams:{disableAutoFetch:D,enableXfa:M}};return d.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const Dt=d.messageHandler.sendWithPromise("GetDocRequest",dt,i?[i.buffer]:null);let ve;return l?ve=new Ib(l,{disableRange:T,disableStream:$}):i||(ve=(K=>Bt?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&Ca(K.url)?new ep(K):new Gb(K):Ca(K.url)?new ep(K):new Ub(K))({url:s,length:z,httpHeaders:n,withCredentials:a,rangeChunkSize:c,disableRange:T,disableStream:$})),Dt.then(qt=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const K=new Pa(e,qt,d.port),jn=new fA(K,t,ve,ot,ee);t._transport=jn,K.send("Ready",null)})}).catch(t._capability.reject),t}function lA(h){if(h instanceof URL)return h.href;try{return new URL(h,window.location).href}catch{if(Bt&&typeof h=="string")return h}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function hA(h){if(Bt&&typeof Buffer<"u"&&h instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength)return h;if(typeof h=="string")return Ud(h);if(h instanceof ArrayBuffer||ArrayBuffer.isView(h)||typeof h=="object"&&!isNaN(h==null?void 0:h.length))return new Uint8Array(h);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function sp(h){return typeof h=="object"&&Number.isInteger(h==null?void 0:h.num)&&h.num>=0&&Number.isInteger(h==null?void 0:h.gen)&&h.gen>=0}var Bc;const jc=class jc{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${ie(jc,Bc)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,e,s;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(i){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,i}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};Bc=new WeakMap,f(jc,Bc,0);let Uu=jc,hg=class{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){tt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class cA{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return 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 ei,ys,si,Wn,Tr,Mh;class dA{constructor(t,e,s,i=!1){f(this,si);f(this,Tr);f(this,ei,null);f(this,ys,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new $f:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new cg,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new ch({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return X(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=zs.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:d=null}){var w,S;(w=this._stats)==null||w.time("Overall");const u=this._transport.getRenderingIntent(s,i,d),{renderingIntent:p,cacheKey:g}=u;m(this,ys,!1),b(this,Tr,Mh).call(this),o||(o=this._transport.getOptionalContentConfig(p));let A=this._intentStates.get(g);A||(A=Object.create(null),this._intentStates.set(g,A)),A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const v=!!(p&Ae.PRINT);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(S=this._stats)==null||S.time("Page Request"),this._pumpOperatorList(u));const _=x=>{var C;A.renderTasks.delete(y),(this._maybeCleanupAfterRender||v)&&m(this,ys,!0),b(this,si,Wn).call(this,!v),x?(y.capability.reject(x),this._abortOperatorList({intentState:A,reason:x instanceof Error?x:new Error(x)})):y.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(C=globalThis.Stats)!=null&&C.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},y=new zu({callback:_,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:c});(A.renderTasks||(A.renderTasks=new Set)).add(y);const E=y.task;return Promise.all([A.displayReadyCapability.promise,o]).then(([x,C])=>{var R;if(this.destroyed){_();return}if((R=this._stats)==null||R.time("Rendering"),!(C.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:x,optionalContentConfig:C}),y.operatorListChanged()}).catch(_),E}getOperatorList({intent:t="display",annotationMode:e=zs.ENABLE,printAnnotationStorage:s=null}={}){var l;function i(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o))}const n=this._transport.getRenderingIntent(t,e,s,!0);let a=this._intentStates.get(n.cacheKey);a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a));let o;return a.opListReadCapability||(o=Object.create(null),o.operatorListChanged=i,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||(a.renderTasks=new Set)).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(l=this._stats)==null||l.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Ua.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){a.read().then(function({value:l,done:c}){if(c){s(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),n()},i)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};n()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),m(this,ys,!1),b(this,Tr,Mh).call(this),Promise.all(t)}cleanup(t=!1){m(this,ys,!0);const e=b(this,si,Wn).call(this,!1);return t&&e&&this._stats&&(this._stats=new $f),e}_startRenderPage(t,e){var i,n;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(n=s.displayReadyCapability)==null||n.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&b(this,si,Wn).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s}){const{map:i,transfer:n}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i},n).getReader(),l=this._intentStates.get(e);l.streamReader=o;const c=()=>{o.read().then(({value:d,done:u})=>{if(u){l.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,l),c())},d=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const u of l.renderTasks)u.operatorListChanged();b(this,si,Wn).call(this,!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(d);else if(l.opListReadCapability)l.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Lf){let i=eA;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 Hn(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}ei=new WeakMap,ys=new WeakMap,si=new WeakSet,Wn=function(t=!1){if(b(this,Tr,Mh).call(this),!r(this,ys)||this.destroyed)return!1;if(t)return m(this,ei,setTimeout(()=>{m(this,ei,null),b(this,si,Wn).call(this,!1)},sA)),!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(),m(this,ys,!1),!0},Tr=new WeakSet,Mh=function(){r(this,ei)&&(clearTimeout(r(this,ei)),m(this,ei,null))};var Qi,Uc;class uA{constructor(){f(this,Qi,new Set);f(this,Uc,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};r(this,Uc).then(()=>{for(const i of r(this,Qi))i.call(this,s)})}addEventListener(t,e){r(this,Qi).add(e)}removeEventListener(t,e){r(this,Qi).delete(e)}terminate(){r(this,Qi).clear()}}Qi=new WeakMap,Uc=new WeakMap;const ls={isWorkerDisabled:!1,fakeWorkerId:0};Bt&&(ls.isWorkerDisabled=!0,Os.workerSrc||(Os.workerSrc="./pdf.worker.mjs")),ls.isSameOrigin=function(h,t){let e;try{if(e=new URL(h),!e.origin||e.origin==="null")return!1}catch{return!1}const s=new URL(t,e);return e.origin===s.origin},ls.createCDNWrapper=function(h){const t=`await import("${h}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};var Ji,Rr,Ih;const re=class re{constructor({name:t=null,port:e=null,verbosity:s=Vm()}={}){var i;if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if((i=r(re,Ji))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(r(re,Ji)||m(re,Ji,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return Bt?Promise.all([es.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Pa("main","worker",t),this._messageHandler.on("ready",function(){}),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!ls.isWorkerDisabled&&!r(re,Rr,Ih)){let{workerSrc:t}=re;try{ls.isSameOrigin(window.location.href,t)||(t=ls.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Pa("main","worker",e),i=()=>{e.removeEventListener("error",n),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=()=>{this._webWorker||i()};e.addEventListener("error",n),s.on("test",o=>{if(e.removeEventListener("error",n),this.destroyed){i();return}o?(this._messageHandler=s,this._port=e,this._webWorker=e,this._readyCapability.resolve(),s.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),s.destroy(),e.terminate())}),s.on("ready",o=>{if(e.removeEventListener("error",n),this.destroyed){i();return}try{a()}catch{this._setupFakeWorker()}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Bd("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){ls.isWorkerDisabled||(V("Setting up fake worker."),ls.isWorkerDisabled=!0),re._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new uA;this._port=e;const s=`fake${ls.fakeWorkerId++}`,i=new Pa(s+"_worker",s,e);t.setup(i,e);const n=new Pa(s,s+"_worker",e);this._messageHandler=n,this._readyCapability.resolve(),n.send("configure",{verbosity:this.verbosity})}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(t=r(re,Ji))==null||t.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){var s;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const e=(s=r(this,Ji))==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 re(t)}static get workerSrc(){if(Os.workerSrc)return Os.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return X(this,"_setupFakeWorkerGlobal",(async()=>r(this,Rr,Ih)?r(this,Rr,Ih):(await import(this.workerSrc)).WorkerMessageHandler)())}};Ji=new WeakMap,Rr=new WeakSet,Ih=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},f(re,Rr),f(re,Ji,void 0);let Qn=re;var _s,Ve,Pr,Lr,Ge,Zi,La;class fA{constructor(t,e,s,i,n){f(this,Zi);f(this,_s,new Map);f(this,Ve,new Map);f(this,Pr,new Map);f(this,Lr,new Map);f(this,Ge,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new cg,this.fontLoader=new db({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return X(this,"annotationStorage",new Df)}getRenderingIntent(t,e=zs.ENABLE,s=null,i=!1){let n=Ae.DISPLAY,a=Iu;switch(t){case"any":n=Ae.ANY;break;case"display":break;case"print":n=Ae.PRINT;break;default:V(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case zs.DISABLE:n+=Ae.ANNOTATIONS_DISABLE;break;case zs.ENABLE:break;case zs.ENABLE_FORMS:n+=Ae.ANNOTATIONS_FORMS;break;case zs.ENABLE_STORAGE:n+=Ae.ANNOTATIONS_STORAGE,a=(n&Ae.PRINT&&s instanceof Yp?s:this.annotationStorage).serializable;break;default:V(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=Ae.OPLIST),{renderingIntent:n,cacheKey:`${n}_${a.hash}`,annotationStorageSerializable:a}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=r(this,Ge))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of r(this,Ve).values())t.push(i._destroy());r(this,Ve).clear(),r(this,Pr).clear(),r(this,Lr).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i;this.commonObjs.clear(),this.fontLoader.clear(),r(this,_s).clear(),this.filterFactory.destroy(),Jh.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new Hn("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{_t(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:a}){if(a){i.close();return}_t(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",s=>{const i=Promise.withResolvers(),n=this._fullReader;return n.headersReady.then(()=>{var a;(!n.isStreamingSupported||!n.isRangeSupported)&&(this._lastProgress&&((a=e.onProgress)==null||a.call(e,this._lastProgress)),n.onProgress=o=>{var l;(l=e.onProgress)==null||l.call(e,{loaded:o.loaded,total:o.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},i.reject),i.promise}),t.on("GetRangeReader",(s,i)=>{_t(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:a,done:o}){if(o){i.close();return}_t(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{n.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new cA(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new lu(s.message,s.code);break;case"InvalidPDFException":i=new bp(s.message);break;case"MissingPDFException":i=new Nn(s.message);break;case"UnexpectedResponseException":i=new jd(s.message,s.status);break;case"UnknownErrorException":i=new hu(s.message,s.details);break;default:tt("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(m(this,Ge,Promise.withResolvers()),e.onPassword){const i=n=>{n instanceof Error?r(this,Ge).reject(n):r(this,Ge).resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){r(this,Ge).reject(n)}}else r(this,Ge).reject(new lu(s.message,s.code));return r(this,Ge).promise}),t.on("DataLoaded",s=>{var i;(i=e.onProgress)==null||i.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;r(this,Ve).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:o,fontExtraProperties:l,pdfBug:c}=this._params;if("error"in n){const g=n.error;V(`Error during font loading: ${g}`),this.commonObjs.resolve(s,g);break}const d=c&&((a=globalThis.FontInspector)!=null&&a.enabled)?(g,A)=>globalThis.FontInspector.fontAdded(g,A):null,u=new ub(n,{disableFontFace:o,inspectFont:d});this.fontLoader.bind(u).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&u.data&&(u.data=null),this.commonObjs.resolve(s,u)});break;case"CopyLocalImage":const{imageRef:p}=n;_t(p,"The imageRef must be defined.");for(const g of r(this,Ve).values())for(const[,A]of g.objs)if((A==null?void 0:A.ref)===p)return A.dataLen?(this.commonObjs.resolve(s,structuredClone(A)),A.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,a])=>{var l;if(this.destroyed)return;const o=r(this,Ve).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(n){case"Image":o.objs.resolve(s,a),(a==null?void 0:a.dataLen)>Bm&&(o._maybeCleanupAfterRender=!0);break;case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(s):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(s):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&V("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=r(this,Pr).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&r(this,Lr).set(n.refStr,t);const a=new dA(e,n,this,this._params.pdfBug);return r(this,Ve).set(e,a),a});return r(this,Pr).set(e,i),i}getPageIndex(t){return sp(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,Zi,La).call(this,"GetFieldObjects")}hasJSActions(){return b(this,Zi,La).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,Zi,La).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,Zi,La).call(this,"GetOptionalContentConfig").then(e=>new Mb(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=r(this,_s).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var n,a;return{info:i[0],metadata:i[1]?new Lb(i[1]):null,contentDispositionFilename:((n=this._fullReader)==null?void 0:n.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return r(this,_s).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of r(this,Ve).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),r(this,_s).clear(),this.filterFactory.destroy(!0),Jh.cleanup()}}cachedPageNumber(t){if(!sp(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return r(this,Lr).get(e)??null}}_s=new WeakMap,Ve=new WeakMap,Pr=new WeakMap,Lr=new WeakMap,Ge=new WeakMap,Zi=new WeakSet,La=function(t,e=null){const s=r(this,_s).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return r(this,_s).set(t,i),i};const Eh=Symbol("INITIAL_DATA");var Te,Zo,$u;class cg{constructor(){f(this,Zo);f(this,Te,Object.create(null))}get(t,e=null){if(e){const i=b(this,Zo,$u).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=r(this,Te)[t];if(!s||s.data===Eh)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=r(this,Te)[t];return!!e&&e.data!==Eh}resolve(t,e=null){const s=b(this,Zo,$u).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in r(this,Te)){const{data:s}=r(this,Te)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}m(this,Te,Object.create(null))}*[Symbol.iterator](){for(const t in r(this,Te)){const{data:e}=r(this,Te)[t];e!==Eh&&(yield[t,e])}}}Te=new WeakMap,Zo=new WeakSet,$u=function(t){var e;return(e=r(this,Te))[t]||(e[t]={...Promise.withResolvers(),data:Eh})};var ii;class pA{constructor(t){f(this,ii,null);m(this,ii,t),this.onContinue=null}get promise(){return r(this,ii).capability.promise}cancel(t=0){r(this,ii).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=r(this,ii).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=r(this,ii);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}ii=new WeakMap;var tn;const Si=class Si{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:d=!1,pdfBug:u=!1,pageColors:p=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=u,this.pageColors=p,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new pA(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var o,l;if(this.cancelled)return;if(this._canvas){if(r(Si,tn).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");r(Si,tn).add(this._canvas)}this._pdfBug&&((o=globalThis.StepperManager)!=null&&o.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:a}=this.params;this.gfx=new Kn(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(t=null,e=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),r(Si,tn).delete(this._canvas),this.callback(t||new Lf(`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?window.requestAnimationFrame(()=>{this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),r(Si,tn).delete(this._canvas),this.callback())))}};tn=new WeakMap,f(Si,tn,new WeakSet);let zu=Si;const gA="4.3.136",mA="0cec64437";function ip(h){return Math.floor(Math.max(0,Math.min(1,h))*255).toString(16).padStart(2,"0")}function Ea(h){return Math.max(0,Math.min(255,255*h))}class np{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=Ea(t),[t,t,t]}static G_HTML([t]){const e=ip(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(Ea)}static RGB_HTML(t){return`#${t.map(ip).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[Ea(1-Math.min(1,t+i)),Ea(1-Math.min(1,s+i)),Ea(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,a=1-s,o=Math.min(i,n,a);return["CMYK",i,n,a,o]}}class dg{static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,c]of Object.entries(a))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}o&&n.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var u,p;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:n,linkService:s});const o=n!=="richText",l=t.div;if(l.append(a),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=g}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);a.append(g),o&&Ua.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const d=[[i,-1,a]];for(;d.length>0;){const[g,A,v]=d.at(-1);if(A+1===g.children.length){d.pop();continue}const _=g.children[++d.at(-1)[1]];if(_===null)continue;const{name:y}=_;if(y==="#text"){const w=document.createTextNode(_.value);c.push(w),v.append(w);continue}const E=(u=_==null?void 0:_.attributes)!=null&&u.xmlns?document.createElementNS(_.attributes.xmlns,y):document.createElement(y);if(v.append(E),_.attributes&&this.setAttributes({html:E,element:_,storage:e,intent:n,linkService:s}),((p=_.children)==null?void 0:p.length)>0)d.push([_,-1,E]);else if(_.value){const w=document.createTextNode(_.value);o&&Ua.shouldBuildText(y)&&c.push(w),E.append(w)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const fh=1e3,bA=9,Fn=new WeakSet;function Ns(h){return{width:h[2]-h[0],height:h[3]-h[1]}}class AA{static create(t){switch(t.data.annotationType){case mt.LINK:return new ug(t);case mt.TEXT:return new vA(t);case mt.WIDGET:switch(t.data.fieldType){case"Tx":return new yA(t);case"Btn":return t.data.radioButton?new gg(t):t.data.checkBox?new EA(t):new wA(t);case"Ch":return new SA(t);case"Sig":return new _A(t)}return new Bn(t);case mt.POPUP:return new Gu(t);case mt.FREETEXT:return new yg(t);case mt.LINE:return new CA(t);case mt.SQUARE:return new TA(t);case mt.CIRCLE:return new RA(t);case mt.POLYLINE:return new _g(t);case mt.CARET:return new LA(t);case mt.INK:return new Eg(t);case mt.POLYGON:return new PA(t);case mt.HIGHLIGHT:return new kA(t);case mt.UNDERLINE:return new MA(t);case mt.SQUIGGLY:return new IA(t);case mt.STRIKEOUT:return new DA(t);case mt.STAMP:return new wg(t);case mt.FILEATTACHMENT:return new FA(t);default:return new pt(t)}}}var en,kr,Mr,tl,Vu;const jf=class jf{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){f(this,tl);f(this,en,null);f(this,kr,!1);f(this,Mr,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 hasPopupData(){return jf._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;r(this,en)||m(this,en,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&b(this,tl,Vu).call(this,e),(s=r(this,Mr))==null||s.popup.updateEdited(t)}resetEdited(){var t;r(this,en)&&(b(this,tl,Vu).call(this,r(this,en).rect),(t=r(this,Mr))==null||t.popup.resetEdited(),m(this,en,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Bn||(n.tabIndex=fh);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.popupRef&&n.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Gu){const{rotation:v}=e;return!e.hasOwnCanvas&&v!==0&&this.setRotation(v,n),n}const{width:o,height:l}=Ns(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const v=e.borderStyle.horizontalCornerRadius,_=e.borderStyle.verticalCornerRadius;if(v>0||_>0){const E=`calc(${v}px * var(--scale-factor)) / calc(${_}px * var(--scale-factor))`;a.borderRadius=E}else if(this instanceof gg){const E=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=E}switch(e.borderStyle.style){case ya.SOLID:a.borderStyle="solid";break;case ya.DASHED:a.borderStyle="dashed";break;case ya.BEVELED:V("Unimplemented border style: beveled");break;case ya.INSET:V("Unimplemented border style: inset");break;case ya.UNDERLINE:a.borderBottomStyle="solid";break}const y=e.borderColor||null;y?(m(this,kr,!0),a.borderColor=k.makeHexColor(y[0]|0,y[1]|0,y[2]|0)):a.borderWidth=0}const c=k.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:d,pageHeight:u,pageX:p,pageY:g}=i.rawDims;a.left=`${100*(c[0]-p)/d}%`,a.top=`${100*(c[1]-g)/u}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/d}%`,a.height=`${100*l/u}%`):this.setRotation(A,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:a}=Ns(this.data.rect);let o,l;t%180===0?(o=100*n/s,l=100*a/i):(o=100*a/s,l=100*n/i),e.style.width=`${o}%`,e.style.height=`${l}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],a=n[0],o=n.slice(1);i.target.style[s]=np[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:np[`${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 n=t[i]||s[i];n==null||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:n},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect;if(t.length===1){const[,{x:v,y:_},{x:y,y:E}]=t[0];if(i===v&&n===_&&e===y&&s===E)return}const{style:a}=this.container;let o;if(r(this,kr)){const{borderColor:v,borderWidth:_}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${v}" stroke-width="${_}">`],this.container.classList.add("hasBorder")}const l=i-e,c=n-s,{svgFactory:d}=this,u=d.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const p=d.createElement("defs");u.append(p);const g=d.createElement("clipPath"),A=`clippath_${this.data.id}`;g.setAttribute("id",A),g.setAttribute("clipPathUnits","objectBoundingBox"),p.append(g);for(const[,{x:v,y:_},{x:y,y:E}]of t){const w=d.createElement("rect"),S=(y-e)/l,x=(n-_)/c,C=(v-y)/l,R=(_-E)/c;w.setAttribute("x",S),w.setAttribute("y",x),w.setAttribute("width",C),w.setAttribute("height",R),g.append(w),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${S}" y="${x}" width="${C}" height="${R}"/>`)}r(this,kr)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${A})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=m(this,Mr,new Gu({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(s.render())}render(){tt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:a,exportValues:o}of i){if(n===-1||a===e)continue;const l=typeof o=="string"?o:null,c=document.querySelector(`[data-element-id="${a}"]`);if(c&&!Fn.has(c)){V(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,a=i.getAttribute("data-element-id");a!==e&&Fn.has(i)&&s.push({id:a,exportValue:n,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}get _isEditable(){return!1}_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})})}};en=new WeakMap,kr=new WeakMap,Mr=new WeakMap,tl=new WeakSet,Vu=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t);const{width:c,height:d}=Ns(t);e.left=`${100*(t[0]-o)/n}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*c/n}%`,e.height=`${100*d/a}%`):this.setRotation(i)};let pt=jf;var Es,yi,$c,fg,zc,pg;class ug extends pt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});f(this,Es);f(this,$c);f(this,zc);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action),n=!0):e.attachment?(b(this,$c,fg).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(b(this,zc,pg).call(this,i,e.setOCGState),n=!0):e.dest?(this._bindLink(i,e.dest),n=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container}_bindLink(e,s){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&b(this,Es,yi).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),b(this,Es,yi).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(s.actions)){const a=i.get(n);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:n}}),!1})}e.onclick||(e.onclick=()=>!1),b(this,Es,yi).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,Es,yi).call(this),!this._fieldObjects){V('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var u;i==null||i();const{fields:n,refs:a,include:o}=s,l=[];if(n.length!==0||a.length!==0){const p=new Set(a);for(const g of n){const A=this._fieldObjects[g]||[];for(const{id:v}of A)p.add(v)}for(const g of Object.values(this._fieldObjects))for(const A of g)p.has(A.id)===o&&l.push(A)}else for(const p of Object.values(this._fieldObjects))l.push(...p);const c=this.annotationStorage,d=[];for(const p of l){const{id:g}=p;switch(d.push(g),p.type){case"text":{const v=p.defaultValue||"";c.setValue(g,{value:v});break}case"checkbox":case"radiobutton":{const v=p.defaultValue===p.exportValues;c.setValue(g,{value:v});break}case"combobox":case"listbox":{const v=p.defaultValue||"";c.setValue(g,{value:v});break}default:continue}const A=document.querySelector(`[data-element-id="${g}"]`);if(A){if(!Fn.has(A)){V(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;A.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}})),!1}}}Es=new WeakSet,yi=function(){this.container.setAttribute("data-internal-link","")},$c=new WeakSet,fg=function(e,s,i=null){e.href=this.linkService.getAnchorUrl(""),s.description&&(e.title=s.description),e.onclick=()=>{var n;return(n=this.downloadManager)==null||n.openOrDownloadData(s.content,s.filename,i),!1},b(this,Es,yi).call(this)},zc=new WeakSet,pg=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),b(this,Es,yi).call(this)};class vA extends pt{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 Bn extends pt{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 Zt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a)}}))})}_setEventListeners(t,e,s,i){var n,a,o;for(const[l,c]of s)(c==="Action"||(n=this.data.actions)!=null&&n[c])&&((c==="Focus"||c==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,c,i),c==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":k.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||bA,n=t.style;let a;const o=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o),d=Math.round(c/(tu*i))||1,u=c/d;a=Math.min(i,l(u/tu))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/tu))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=k.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class yA extends Bn{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),n.setValue(a.id,{[i]:s})}render(){var i,n;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let c=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const d={userValue:o,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",c??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Fn.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=fh,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",p=>{t.setValue(e,{value:p.target.value}),this.setPropertyOnSiblings(s,"value",p.target.value,"value"),d.formattedValue=null}),s.addEventListener("resetform",p=>{const g=this.data.defaultFieldValue??"";s.value=d.userValue=g,d.formattedValue=null});let u=p=>{const{formattedValue:g}=d;g!=null&&(p.target.value=g),p.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{var v;if(d.focused)return;const{target:A}=g;d.userValue&&(A.value=d.userValue),d.lastCommittedValue=A.value,d.commitKey=1,(v=this.data.actions)!=null&&v.Focus||(d.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const A={value(v){d.userValue=v.detail.value??"",t.setValue(e,{value:d.userValue.toString()}),v.target.value=d.userValue},formattedValue(v){const{formattedValue:_}=v.detail;d.formattedValue=_,_!=null&&v.target!==document.activeElement&&(v.target.value=_),t.setValue(e,{formattedValue:_})},selRange(v){v.target.setSelectionRange(...v.detail.selRange)},charLimit:v=>{var w;const{charLimit:_}=v.detail,{target:y}=v;if(_===0){y.removeAttribute("maxLength");return}y.setAttribute("maxLength",_);let E=d.userValue;!E||E.length<=_||(E=E.slice(0,_),y.value=d.userValue=E,t.setValue(e,{value:E}),(w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:1,selStart:y.selectionStart,selEnd:y.selectionEnd}}))}};this._dispatchEventFromSandbox(A,g)}),s.addEventListener("keydown",g=>{var _;d.commitKey=1;let A=-1;if(g.key==="Escape"?A=0:g.key==="Enter"&&!this.data.multiLine?A=2:g.key==="Tab"&&(d.commitKey=3),A===-1)return;const{value:v}=g.target;d.lastCommittedValue!==v&&(d.lastCommittedValue=v,d.userValue=v,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:A,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const p=u;u=null,s.addEventListener("blur",g=>{var v,_;if(!d.focused||!g.relatedTarget)return;(v=this.data.actions)!=null&&v.Blur||(d.focused=!1);const{value:A}=g.target;d.userValue=A,d.lastCommittedValue!==A&&((_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:d.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}})),p(g)}),(n=this.data.actions)!=null&&n.Keystroke&&s.addEventListener("beforeinput",g=>{var x;d.lastCommittedValue=null;const{data:A,target:v}=g,{value:_,selectionStart:y,selectionEnd:E}=v;let w=y,S=E;switch(g.inputType){case"deleteWordBackward":{const C=_.substring(0,y).match(/\w*[^\w]*$/);C&&(w-=C[0].length);break}case"deleteWordForward":{const C=_.substring(y).match(/^[^\w]*\w*/);C&&(S+=C[0].length);break}case"deleteContentBackward":y===E&&(w-=1);break;case"deleteContentForward":y===E&&(S+=1);break}g.preventDefault(),(x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:A||"",willCommit:!1,selStart:w,selEnd:S}})}),this._setEventListeners(s,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(u&&s.addEventListener("blur",u),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${g}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class _A extends Bn{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class EA extends Bn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Fn.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=fh,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s)){const d=l&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=d),t.setValue(c.id,{value:d})}t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class gg extends Bn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const n=document.createElement("input");if(Fn.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=fh,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;n.addEventListener("updatefromsandbox",o=>{const l={value:c=>{const d=a===c.detail.value;for(const u of this._getElementsByName(c.target.name)){const p=d&&u.id===s;u.domElement&&(u.domElement.checked=p),t.setValue(u.id,{value:p})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class wA extends ug{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 SA extends Bn{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");Fn.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=fh;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const u=this.data.defaultFieldValue;for(const p of i.options)p.selected=p.value===u});for(const d of this.data.options){const u=document.createElement("option");u.textContent=d.displayValue,u.value=d.exportValue,s.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),n=!1),i.append(u)}let a=null;if(n){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),a=()=>{d.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=d=>{const u=d?"value":"textContent",{options:p,multiple:g}=i;return g?Array.prototype.filter.call(p,A=>A.selected).map(A=>A[u]):p.selectedIndex===-1?null:p[p.selectedIndex][u]};let l=o(!1);const c=d=>{const u=d.target.options;return Array.prototype.map.call(u,p=>({displayValue:p.textContent,exportValue:p.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const u={value(p){a==null||a();const g=p.detail.value,A=new Set(Array.isArray(g)?g:[g]);for(const v of i.options)v.selected=A.has(v.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(p){i.multiple=!0},remove(p){const g=i.options,A=p.detail.remove;g[A].selected=!1,i.remove(A),g.length>0&&Array.prototype.findIndex.call(g,_=>_.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:o(!0),items:c(p)}),l=o(!1)},clear(p){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(p){const{index:g,displayValue:A,exportValue:v}=p.detail.insert,_=i.children[g],y=document.createElement("option");y.textContent=A,y.value=v,_?_.before(y):i.append(y),t.setValue(e,{value:o(!0),items:c(p)}),l=o(!1)},items(p){const{items:g}=p.detail;for(;i.length!==0;)i.remove(0);for(const A of g){const{displayValue:v,exportValue:_}=A,y=document.createElement("option");y.textContent=v,y.value=_,i.append(y)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:c(p)}),l=o(!1)},indices(p){const g=new Set(p.detail.indices);for(const A of p.target.options)A.selected=g.has(A.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(p){p.target.disabled=!p.detail.editable}};this._dispatchEventFromSandbox(u,d)}),i.addEventListener("input",d=>{var g;const u=o(!0),p=o(!1);t.setValue(e,{value:u}),d.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:p,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Gu extends pt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:pt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new xA({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,e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${vp}${s}`).join(",")),this.container}}var Ir,Vc,Gc,Dr,sn,ct,ws,nn,el,sl,Fr,Ss,Re,xs,il,Cs,nl,rn,an,Or,Dh,rl,Wu,Wc,mg,qc,bg,Xc,Ag,Yc,vg,Nr,Fh,Hr,Oh,al,qu;class xA{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:o,parent:l,rect:c,parentRect:d,open:u}){f(this,Or);f(this,rl);f(this,Wc);f(this,qc);f(this,Xc);f(this,Yc);f(this,Nr);f(this,Hr);f(this,al);f(this,Ir,b(this,Xc,Ag).bind(this));f(this,Vc,b(this,al,qu).bind(this));f(this,Gc,b(this,Hr,Oh).bind(this));f(this,Dr,b(this,Nr,Fh).bind(this));f(this,sn,null);f(this,ct,null);f(this,ws,null);f(this,nn,null);f(this,el,null);f(this,sl,null);f(this,Fr,null);f(this,Ss,!1);f(this,Re,null);f(this,xs,null);f(this,il,null);f(this,Cs,null);f(this,nl,null);f(this,rn,null);f(this,an,!1);var p;m(this,ct,t),m(this,nl,i),m(this,ws,a),m(this,Cs,o),m(this,sl,l),m(this,sn,e),m(this,il,c),m(this,Fr,d),m(this,el,s),m(this,nn,Sp.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",r(this,Dr)),g.addEventListener("mouseenter",r(this,Gc)),g.addEventListener("mouseleave",r(this,Vc)),g.classList.add("popupTriggerArea");for(const g of s)(p=g.container)==null||p.addEventListener("keydown",r(this,Ir));r(this,ct).hidden=!0,u&&b(this,Nr,Fh).call(this)}render(){if(r(this,Re))return;const t=m(this,Re,document.createElement("div"));if(t.className="popup",r(this,sn)){const n=t.style.outlineColor=k.makeHexColor(...r(this,sn));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=k.makeHexColor(...r(this,sn).map(o=>Math.floor(.7*(255-o)+o)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=r(this,nl),t.append(e),r(this,nn)){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),n.setAttribute("data-l10n-args",JSON.stringify({date:r(this,nn).toLocaleDateString(),time:r(this,nn).toLocaleTimeString()})),e.append(n)}const i=r(this,Or,Dh);if(i)dg.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(r(this,ws));t.append(n)}r(this,ct).append(t)}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let n=0,a=i.length;n<a;++n){const o=i[n];s.append(document.createTextNode(o)),n<a-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popupContent:e}){var s;r(this,rn)||m(this,rn,{contentsObj:r(this,ws),richText:r(this,Cs)}),t&&m(this,xs,null),e&&(m(this,Cs,b(this,qc,bg).call(this,e)),m(this,ws,null)),(s=r(this,Re))==null||s.remove(),m(this,Re,null)}resetEdited(){var t;r(this,rn)&&({contentsObj:ie(this,ws)._,richText:ie(this,Cs)._}=r(this,rn),m(this,rn,null),(t=r(this,Re))==null||t.remove(),m(this,Re,null),m(this,xs,null))}forceHide(){m(this,an,this.isVisible),r(this,an)&&(r(this,ct).hidden=!0)}maybeShow(){r(this,an)&&(r(this,Re)||b(this,Hr,Oh).call(this),m(this,an,!1),r(this,ct).hidden=!1)}get isVisible(){return r(this,ct).hidden===!1}}Ir=new WeakMap,Vc=new WeakMap,Gc=new WeakMap,Dr=new WeakMap,sn=new WeakMap,ct=new WeakMap,ws=new WeakMap,nn=new WeakMap,el=new WeakMap,sl=new WeakMap,Fr=new WeakMap,Ss=new WeakMap,Re=new WeakMap,xs=new WeakMap,il=new WeakMap,Cs=new WeakMap,nl=new WeakMap,rn=new WeakMap,an=new WeakMap,Or=new WeakSet,Dh=function(){const t=r(this,Cs),e=r(this,ws);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&r(this,Cs).html||null},rl=new WeakSet,Wu=function(){var t,e,s;return((s=(e=(t=r(this,Or,Dh))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},Wc=new WeakSet,mg=function(){var t,e,s;return((s=(e=(t=r(this,Or,Dh))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},qc=new WeakSet,bg=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:r(this,Wc,mg),fontSize:r(this,rl,Wu)?`calc(${r(this,rl,Wu)}px * var(--scale-factor))`:""}};for(const n of t.split(`
`))e.push({name:"span",value:n,attributes:i});return s},Xc=new WeakSet,Ag=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&r(this,Ss))&&b(this,Nr,Fh).call(this)},Yc=new WeakSet,vg=function(){if(r(this,xs)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=r(this,sl);let a=!!r(this,Fr),o=a?r(this,Fr):r(this,il);for(const A of r(this,el))if(!o||k.intersect(A.data.rect,o)!==null){o=A.data.rect,a=!0;break}const l=k.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),d=a?o[2]-o[0]+5:0,u=l[0]+d,p=l[1];m(this,xs,[100*(u-i)/e,100*(p-n)/s]);const{style:g}=r(this,ct);g.left=`${r(this,xs)[0]}%`,g.top=`${r(this,xs)[1]}%`},Nr=new WeakSet,Fh=function(){m(this,Ss,!r(this,Ss)),r(this,Ss)?(b(this,Hr,Oh).call(this),r(this,ct).addEventListener("click",r(this,Dr)),r(this,ct).addEventListener("keydown",r(this,Ir))):(b(this,al,qu).call(this),r(this,ct).removeEventListener("click",r(this,Dr)),r(this,ct).removeEventListener("keydown",r(this,Ir)))},Hr=new WeakSet,Oh=function(){r(this,Re)||this.render(),this.isVisible?r(this,Ss)&&r(this,ct).classList.add("focused"):(b(this,Yc,vg).call(this),r(this,ct).hidden=!1,r(this,ct).style.zIndex=parseInt(r(this,ct).style.zIndex)+1e3)},al=new WeakSet,qu=function(){r(this,ct).classList.remove("focused"),!(r(this,Ss)||!this.isVisible)&&(r(this,ct).hidden=!0,r(this,ct).style.zIndex=parseInt(r(this,ct).style.zIndex)-1e3)};class yg extends pt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=W.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}get _isEditable(){return this.data.hasOwnCanvas}}var ol;class CA extends pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});f(this,ol,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:s,height:i}=Ns(e.rect),n=this.svgFactory.create(s,i,!0),a=m(this,ol,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,ol)}addHighlightArea(){this.container.classList.add("highlightArea")}}ol=new WeakMap;var ll;class TA extends pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});f(this,ll,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:s,height:i}=Ns(e.rect),n=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=m(this,ll,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),n.append(o),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,ll)}addHighlightArea(){this.container.classList.add("highlightArea")}}ll=new WeakMap;var hl;class RA extends pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});f(this,hl,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:s,height:i}=Ns(e.rect),n=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=m(this,hl,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),n.append(o),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,hl)}addHighlightArea(){this.container.classList.add("highlightArea")}}hl=new WeakMap;var cl;class _g extends pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});f(this,cl,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const e=this.data,{width:s,height:i}=Ns(e.rect),n=this.svgFactory.create(s,i,!0);let a=[];for(const l of e.vertices){const c=l.x-e.rect[0],d=e.rect[3]-l.y;a.push(c+","+d)}a=a.join(" ");const o=m(this,cl,this.svgFactory.createElement(this.svgElementName));return o.setAttribute("points",a),o.setAttribute("stroke-width",e.borderStyle.width||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),n.append(o),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,cl)}addHighlightArea(){this.container.classList.add("highlightArea")}}cl=new WeakMap;class PA extends _g{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class LA extends pt{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 dl;class Eg extends pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});f(this,dl,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=W.INK}render(){this.container.classList.add(this.containerClassName);const e=this.data,{width:s,height:i}=Ns(e.rect),n=this.svgFactory.create(s,i,!0);for(const a of e.inkLists){let o=[];for(const c of a){const d=c.x-e.rect[0],u=e.rect[3]-c.y;o.push(`${d},${u}`)}o=o.join(" ");const l=this.svgFactory.createElement(this.svgElementName);r(this,dl).push(l),l.setAttribute("points",o),l.setAttribute("stroke-width",e.borderStyle.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),!e.popupRef&&this.hasPopupData&&this._createPopup(),n.append(l)}return this.container.append(n),this.container}getElementsToTriggerPopup(){return r(this,dl)}addHighlightArea(){this.container.classList.add("highlightArea")}}dl=new WeakMap;class kA extends pt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class MA extends pt{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 IA extends pt{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 DA extends pt{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 wg extends pt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var ul,fl,Xu;class FA extends pt{constructor(e){var i;super(e,{isRenderable:!0});f(this,fl);f(this,ul,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",b(this,fl,Xu).bind(this)),m(this,ul,i);const{isMac:n}=Zt.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(n?a.metaKey:a.ctrlKey)&&b(this,fl,Xu).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return r(this,ul)}addHighlightArea(){this.container.classList.add("highlightArea")}}ul=new WeakMap,fl=new WeakSet,Xu=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var pl,on,Br,Kc,Sg,gl,Yu,gp;let OA=(gp=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a}){f(this,Kc);f(this,gl);f(this,pl,null);f(this,on,null);f(this,Br,new Map);this.div=t,m(this,pl,e),m(this,on,s),this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}async render(t){var a;const{annotations:e}=t,s=this.div;In(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Pf,annotationStorage:t.annotationStorage||new Df,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===mt.POPUP;if(l){const u=i.get(o.id);if(!u)continue;n.elements=u}else{const{width:u,height:p}=Ns(o.rect);if(u<=0||p<=0)continue}n.data=o;const c=AA.create(n);if(!c.isRenderable)continue;if(!l&&o.popupRef){const u=i.get(o.popupRef);u?u.push(c):i.set(o.popupRef,[c])}const d=c.render();o.hidden&&(d.style.visibility="hidden"),b(this,Kc,Sg).call(this,d,o.id),c.annotationEditorType>0&&(r(this,Br).set(c.data.id,c),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(c))}b(this,gl,Yu).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,In(e,{rotation:t.rotation}),b(this,gl,Yu).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(r(this,Br).values())}getEditableAnnotation(t){return r(this,Br).get(t)}},pl=new WeakMap,on=new WeakMap,Br=new WeakMap,Kc=new WeakSet,Sg=function(t,e){var i;const s=t.firstChild||t;s.id=`${vp}${e}`,this.div.append(t),(i=r(this,pl))==null||i.moveElementInDOM(this.div,t,s,!1)},gl=new WeakSet,Yu=function(){if(!r(this,on))return;const t=this.div;for(const[e,s]of r(this,on)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}r(this,on).clear()},gp);const wh=/\r\n?|\n/g;var ml,bl,Al,vl,yl,Pe,oe,_l,le,jr,Qc,xg,Jc,Cg,Zc,Tg,Ur,Nh,$r,Hh,zr,Bh,td,Rg,El,Qu,ed,Pg;const st=class st extends J{constructor(e){super({...e,name:"freeTextEditor"});f(this,Qc);f(this,Jc);f(this,Zc);f(this,Ur);f(this,zr);f(this,td);f(this,ed);f(this,ml,this.editorDivBlur.bind(this));f(this,bl,this.editorDivFocus.bind(this));f(this,Al,this.editorDivInput.bind(this));f(this,vl,this.editorDivKeydown.bind(this));f(this,yl,this.editorDivPaste.bind(this));f(this,Pe,void 0);f(this,oe,"");f(this,_l,`${this.id}-editor`);f(this,le,void 0);f(this,jr,null);m(this,Pe,e.color||st._defaultColor||J._defaultLineColor),m(this,le,e.fontSize||st._defaultFontSize)}static get _keyboardManager(){const e=st.prototype,s=a=>a.isEmpty(),i=Dn.TRANSLATE_SMALL,n=Dn.TRANSLATE_BIG;return X(this,"_keyboardManager",new dh([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}]]))}static initialize(e,s){J.initialize(e,s,{strings:["pdfjs-free-text-default-content"]});const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case j.FREETEXT_SIZE:st._defaultFontSize=s;break;case j.FREETEXT_COLOR:st._defaultColor=s;break}}updateParams(e,s){switch(e){case j.FREETEXT_SIZE:b(this,Qc,xg).call(this,s);break;case j.FREETEXT_COLOR:b(this,Jc,Cg).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[j.FREETEXT_SIZE,st._defaultFontSize],[j.FREETEXT_COLOR,st._defaultColor||J._defaultLineColor]]}get propertiesToUpdate(){return[[j.FREETEXT_SIZE,r(this,le)],[j.FREETEXT_COLOR,r(this,Pe)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-st._internalPadding*e,-(st._internalPadding+r(this,le))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(W.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.editorDiv.addEventListener("keydown",r(this,vl)),this.editorDiv.addEventListener("focus",r(this,bl)),this.editorDiv.addEventListener("blur",r(this,ml)),this.editorDiv.addEventListener("input",r(this,Al)),this.editorDiv.addEventListener("paste",r(this,yl)))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",r(this,_l)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",r(this,vl)),this.editorDiv.removeEventListener("focus",r(this,bl)),this.editorDiv.removeEventListener("blur",r(this,ml)),this.editorDiv.removeEventListener("input",r(this,Al)),this.editorDiv.removeEventListener("paste",r(this,yl)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var e;this.width||(this.enableEditMode(),this.editorDiv.focus(),(e=this._initialOptions)!=null&&e.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=r(this,oe),s=m(this,oe,b(this,Zc,Tg).call(this).trimEnd());if(e===s)return;const i=n=>{if(m(this,oe,n),!n){this.remove();return}b(this,zr,Bh).call(this),this._uiManager.rebuild(this),b(this,Ur,Nh).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,Ur,Nh).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){st._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",r(this,_l)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),J._l10nPromise.get("pdfjs-free-text-default-content").then(n=>{var a;return(a=this.editorDiv)==null?void 0:a.setAttribute("default-content",n)}),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${r(this,le)}px * var(--scale-factor))`,i.color=r(this,Pe),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Yh(this,this.div,["dblclick","keydown"]),this.width){const[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=r(this,jr);let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[d,u]=this.pageDimensions,[p,g]=this.pageTranslation;let A,v;switch(this.rotation){case 0:A=e+(o[0]-p)/d,v=s+this.height-(o[1]-g)/u;break;case 90:A=e+(o[0]-p)/d,v=s-(o[1]-g)/u,[l,c]=[c,-l];break;case 180:A=e-this.width+(o[0]-p)/d,v=s-(o[1]-g)/u,[l,c]=[-l,-c];break;case 270:A=e+(o[0]-p-this.height*u)/d,v=s+(o[1]-g-this.width*d)/u,[l,c]=[-c,l];break}this.setAt(A*n,v*a,l,c)}else this.setAt(e*n,s*a,this.width*n,this.height*a);b(this,zr,Bh).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var A,v,_;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=b(A=st,El,Qu).call(A,s.getData("text")||"").replaceAll(wh,`
`);if(!n)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!n.includes(`
`)){o.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:c}=o,d=[],u=[];if(l.nodeType===Node.TEXT_NODE){const y=l.parentElement;if(u.push(l.nodeValue.slice(c).replaceAll(wh,"")),y!==this.editorDiv){let E=d;for(const w of this.editorDiv.childNodes){if(w===y){E=u;continue}E.push(b(v=st,$r,Hh).call(v,w))}}d.push(l.nodeValue.slice(0,c).replaceAll(wh,""))}else if(l===this.editorDiv){let y=d,E=0;for(const w of this.editorDiv.childNodes)E++===c&&(y=u),y.push(b(_=st,$r,Hh).call(_,w))}m(this,oe,`${d.join(`
`)}${n}${u.join(`
`)}`),b(this,zr,Bh).call(this);const p=new Range;let g=d.reduce((y,E)=>y+E.length,0);for(const{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){const E=y.nodeValue.length;if(g<=E){p.setStart(y,g),p.setEnd(y,g);break}g-=E}a.removeAllRanges(),a.addRange(p)}get contentDiv(){return this.editorDiv}static deserialize(e,s,i){var o;let n=null;if(e instanceof yg){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:d,rotation:u,id:p},textContent:g,textPosition:A,parent:{page:{pageNumber:v}}}=e;if(!g||g.length===0)return null;n=e={annotationType:W.FREETEXT,color:Array.from(c),fontSize:l,value:g.join(`
`),position:A,pageIndex:v-1,rect:d.slice(0),rotation:u,id:p,deleted:!1}}const a=super.deserialize(e,s,i);return m(a,le,e.fontSize),m(a,Pe,k.makeHexColor(...e.color)),m(a,oe,b(o=st,El,Qu).call(o,e.value)),a.annotationElementId=e.id||null,m(a,jr,n),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const s=st._internalPadding*this.parentScale,i=this.getRect(s,s),n=J._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:r(this,Pe)),a={annotationType:W.FREETEXT,color:n,fontSize:r(this,le),value:b(this,td,Rg).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!b(this,ed,Pg).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${r(this,le)}px * var(--scale-factor))`,i.color=r(this,Pe),s.replaceChildren();for(const a of r(this,oe).split(`
`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const n=st._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(n,n),popupContent:r(this,oe)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};ml=new WeakMap,bl=new WeakMap,Al=new WeakMap,vl=new WeakMap,yl=new WeakMap,Pe=new WeakMap,oe=new WeakMap,_l=new WeakMap,le=new WeakMap,jr=new WeakMap,Qc=new WeakSet,xg=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-r(this,le))*this.parentScale),m(this,le,n),b(this,Ur,Nh).call(this)},i=r(this,le);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Jc=new WeakSet,Cg=function(e){const s=n=>{m(this,Pe,this.editorDiv.style.color=n)},i=r(this,Pe);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Zc=new WeakSet,Tg=function(){var s;const e=[];this.editorDiv.normalize();for(const i of this.editorDiv.childNodes)e.push(b(s=st,$r,Hh).call(s,i));return e.join(`
`)},Ur=new WeakSet,Nh=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",n.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},$r=new WeakSet,Hh=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(wh,"")},zr=new WeakSet,Bh=function(){if(this.editorDiv.replaceChildren(),!!r(this,oe))for(const e of r(this,oe).split(`
`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},td=new WeakSet,Rg=function(){return r(this,oe).replaceAll(" "," ")},El=new WeakSet,Qu=function(e){return e.replaceAll(" "," ")},ed=new WeakSet,Pg=function(e){const{value:s,fontSize:i,color:n,pageIndex:a}=r(this,jr);return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==n[l])||e.pageIndex!==a},f(st,$r),f(st,El),U(st,"_freeTextDefaultContent",""),U(st,"_internalPadding",0),U(st,"_defaultColor",null),U(st,"_defaultFontSize",10),U(st,"_type","freetext"),U(st,"_editorType",W.FREETEXT);let Ku=st;var wl,ni,Le,sd,Lg,Vr,jh,id,kg,nd,Mg,Sl,Zu;class Ju{constructor(t,e=0,s=0,i=!0){f(this,sd);f(this,Vr);f(this,id);f(this,nd);f(this,Sl);f(this,wl,void 0);f(this,ni,[]);f(this,Le,[]);let n=1/0,a=-1/0,o=1/0,l=-1/0;const d=10**-4;for(const{x:y,y:E,width:w,height:S}of t){const x=Math.floor((y-e)/d)*d,C=Math.ceil((y+w+e)/d)*d,R=Math.floor((E-e)/d)*d,P=Math.ceil((E+S+e)/d)*d,M=[x,R,P,!0],O=[C,R,P,!1];r(this,ni).push(M,O),n=Math.min(n,x),a=Math.max(a,C),o=Math.min(o,R),l=Math.max(l,P)}const u=a-n+2*s,p=l-o+2*s,g=n-s,A=o-s,v=r(this,ni).at(i?-1:-2),_=[v[0],v[2]];for(const y of r(this,ni)){const[E,w,S]=y;y[0]=(E-g)/u,y[1]=(w-A)/p,y[2]=(S-A)/p}m(this,wl,{x:g,y:A,width:u,height:p,lastPoint:_})}getOutlines(){r(this,ni).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of r(this,ni))e[3]?(t.push(...b(this,Sl,Zu).call(this,e)),b(this,id,kg).call(this,e)):(b(this,nd,Mg).call(this,e),t.push(...b(this,Sl,Zu).call(this,e)));return b(this,sd,Lg).call(this,t)}}wl=new WeakMap,ni=new WeakMap,Le=new WeakMap,sd=new WeakSet,Lg=function(t){const e=[],s=new Set;for(const a of t){const[o,l,c]=a;e.push([o,l,a],[o,c,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],c=e[a+1][2];l.push(c),c.push(l),s.add(l),s.add(c)}const i=[];let n;for(;s.size>0;){const a=s.values().next().value;let[o,l,c,d,u]=a;s.delete(a);let p=o,g=l;for(n=[o,c],i.push(n);;){let A;if(s.has(d))A=d;else if(s.has(u))A=u;else break;s.delete(A),[o,l,c,d,u]=A,p!==o&&(n.push(p,g,o,g===l?l:c),p=o),g=g===l?c:l}n.push(p,g)}return new NA(i,r(this,wl))},Vr=new WeakSet,jh=function(t){const e=r(this,Le);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,a=e[n][0];if(a===t)return n;a<t?s=n+1:i=n-1}return i+1},id=new WeakSet,kg=function([,t,e]){const s=b(this,Vr,jh).call(this,t);r(this,Le).splice(s,0,[t,e])},nd=new WeakSet,Mg=function([,t,e]){const s=b(this,Vr,jh).call(this,t);for(let i=s;i<r(this,Le).length;i++){const[n,a]=r(this,Le)[i];if(n!==t)break;if(n===t&&a===e){r(this,Le).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,a]=r(this,Le)[i];if(n!==t)break;if(n===t&&a===e){r(this,Le).splice(i,1);return}}},Sl=new WeakSet,Zu=function(t){const[e,s,i]=t,n=[[e,s,i]],a=b(this,Vr,jh).call(this,i);for(let o=0;o<a;o++){const[l,c]=r(this,Le)[o];for(let d=0,u=n.length;d<u;d++){const[,p,g]=n[d];if(!(c<=p||g<=l)){if(p>=l){if(g>c)n[d][1]=c;else{if(u===1)return[];n.splice(d,1),d--,u--}continue}n[d][2]=l,g>c&&n.push([e,c,g])}}}return n};class Ig{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(t,e){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof ef}}var xl,Gr;class NA extends Ig{constructor(e,s){super();f(this,xl,void 0);f(this,Gr,void 0);m(this,Gr,e),m(this,xl,s)}toSVGPath(){const e=[];for(const s of r(this,Gr)){let[i,n]=s;e.push(`M${i} ${n}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),n=l):l===n&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,n],a){const o=[],l=i-e,c=n-s;for(const d of r(this,Gr)){const u=new Array(d.length);for(let p=0;p<d.length;p+=2)u[p]=e+d[p]*l,u[p+1]=n-d[p+1]*c;o.push(u)}return o}get box(){return r(this,xl)}}xl=new WeakMap,Gr=new WeakMap;var We,Ts,Wr,qr,qe,G,ln,hn,Cl,Tl,Xr,Yr,ri,Rl,rd,ad,Pl,tf;const as=class as{constructor({x:t,y:e},s,i,n,a,o=0){f(this,Pl);f(this,We,void 0);f(this,Ts,[]);f(this,Wr,void 0);f(this,qr,void 0);f(this,qe,[]);f(this,G,new Float64Array(18));f(this,ln,void 0);f(this,hn,void 0);f(this,Cl,void 0);f(this,Tl,void 0);f(this,Xr,void 0);f(this,Yr,void 0);f(this,ri,[]);m(this,We,s),m(this,Yr,n*i),m(this,qr,a),r(this,G).set([NaN,NaN,NaN,NaN,t,e],6),m(this,Wr,o),m(this,Tl,r(as,Rl)*i),m(this,Cl,r(as,ad)*i),m(this,Xr,i),r(this,ri).push(t,e)}get free(){return!0}isEmpty(){return isNaN(r(this,G)[8])}add({x:t,y:e}){var M;m(this,ln,t),m(this,hn,e);const[s,i,n,a]=r(this,We);let[o,l,c,d]=r(this,G).subarray(8,12);const u=t-c,p=e-d,g=Math.hypot(u,p);if(g<r(this,Cl))return!1;const A=g-r(this,Tl),v=A/g,_=v*u,y=v*p;let E=o,w=l;o=c,l=d,c+=_,d+=y,(M=r(this,ri))==null||M.push(t,e);const S=-y/A,x=_/A,C=S*r(this,Yr),R=x*r(this,Yr);return r(this,G).set(r(this,G).subarray(2,8),0),r(this,G).set([c+C,d+R],4),r(this,G).set(r(this,G).subarray(14,18),12),r(this,G).set([c-C,d-R],16),isNaN(r(this,G)[6])?(r(this,qe).length===0&&(r(this,G).set([o+C,l+R],2),r(this,qe).push(NaN,NaN,NaN,NaN,(o+C-s)/n,(l+R-i)/a),r(this,G).set([o-C,l-R],14),r(this,Ts).push(NaN,NaN,NaN,NaN,(o-C-s)/n,(l-R-i)/a)),r(this,G).set([E,w,o,l,c,d],6),!this.isEmpty()):(r(this,G).set([E,w,o,l,c,d],6),Math.abs(Math.atan2(w-l,E-o)-Math.atan2(y,_))<Math.PI/2?([o,l,c,d]=r(this,G).subarray(2,6),r(this,qe).push(NaN,NaN,NaN,NaN,((o+c)/2-s)/n,((l+d)/2-i)/a),[o,l,E,w]=r(this,G).subarray(14,18),r(this,Ts).push(NaN,NaN,NaN,NaN,((E+o)/2-s)/n,((w+l)/2-i)/a),!0):([E,w,o,l,c,d]=r(this,G).subarray(0,6),r(this,qe).push(((E+5*o)/6-s)/n,((w+5*l)/6-i)/a,((5*o+c)/6-s)/n,((5*l+d)/6-i)/a,((o+c)/2-s)/n,((l+d)/2-i)/a),[c,d,o,l,E,w]=r(this,G).subarray(12,18),r(this,Ts).push(((E+5*o)/6-s)/n,((w+5*l)/6-i)/a,((5*o+c)/6-s)/n,((5*l+d)/6-i)/a,((o+c)/2-s)/n,((l+d)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=r(this,qe),e=r(this,Ts),s=r(this,G).subarray(4,6),i=r(this,G).subarray(16,18),[n,a,o,l]=r(this,We),[c,d,u,p]=b(this,Pl,tf).call(this);if(isNaN(r(this,G)[6])&&!this.isEmpty())return`M${(r(this,G)[2]-n)/o} ${(r(this,G)[3]-a)/l} L${(r(this,G)[4]-n)/o} ${(r(this,G)[5]-a)/l} L${c} ${d} L${u} ${p} L${(r(this,G)[16]-n)/o} ${(r(this,G)[17]-a)/l} L${(r(this,G)[14]-n)/o} ${(r(this,G)[15]-a)/l} Z`;const g=[];g.push(`M${t[4]} ${t[5]}`);for(let A=6;A<t.length;A+=6)isNaN(t[A])?g.push(`L${t[A+4]} ${t[A+5]}`):g.push(`C${t[A]} ${t[A+1]} ${t[A+2]} ${t[A+3]} ${t[A+4]} ${t[A+5]}`);g.push(`L${(s[0]-n)/o} ${(s[1]-a)/l} L${c} ${d} L${u} ${p} L${(i[0]-n)/o} ${(i[1]-a)/l}`);for(let A=e.length-6;A>=6;A-=6)isNaN(e[A])?g.push(`L${e[A+4]} ${e[A+5]}`):g.push(`C${e[A]} ${e[A+1]} ${e[A+2]} ${e[A+3]} ${e[A+4]} ${e[A+5]}`);return g.push(`L${e[4]} ${e[5]} Z`),g.join(" ")}getOutlines(){var y;const t=r(this,qe),e=r(this,Ts),s=r(this,G),i=s.subarray(4,6),n=s.subarray(16,18),[a,o,l,c]=r(this,We),d=new Float64Array((((y=r(this,ri))==null?void 0:y.length)??0)+2);for(let E=0,w=d.length-2;E<w;E+=2)d[E]=(r(this,ri)[E]-a)/l,d[E+1]=(r(this,ri)[E+1]-o)/c;d[d.length-2]=(r(this,ln)-a)/l,d[d.length-1]=(r(this,hn)-o)/c;const[u,p,g,A]=b(this,Pl,tf).call(this);if(isNaN(s[6])&&!this.isEmpty()){const E=new Float64Array(36);return E.set([NaN,NaN,NaN,NaN,(s[2]-a)/l,(s[3]-o)/c,NaN,NaN,NaN,NaN,(s[4]-a)/l,(s[5]-o)/c,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,g,A,NaN,NaN,NaN,NaN,(s[16]-a)/l,(s[17]-o)/c,NaN,NaN,NaN,NaN,(s[14]-a)/l,(s[15]-o)/c],0),new ef(E,d,r(this,We),r(this,Xr),r(this,Wr),r(this,qr))}const v=new Float64Array(r(this,qe).length+24+r(this,Ts).length);let _=t.length;for(let E=0;E<_;E+=2){if(isNaN(t[E])){v[E]=v[E+1]=NaN;continue}v[E]=t[E],v[E+1]=t[E+1]}v.set([NaN,NaN,NaN,NaN,(i[0]-a)/l,(i[1]-o)/c,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,g,A,NaN,NaN,NaN,NaN,(n[0]-a)/l,(n[1]-o)/c],_),_+=24;for(let E=e.length-6;E>=6;E-=6)for(let w=0;w<6;w+=2){if(isNaN(e[E+w])){v[_]=v[_+1]=NaN,_+=2;continue}v[_]=e[E+w],v[_+1]=e[E+w+1],_+=2}return v.set([NaN,NaN,NaN,NaN,e[4],e[5]],_),new ef(v,d,r(this,We),r(this,Xr),r(this,Wr),r(this,qr))}};We=new WeakMap,Ts=new WeakMap,Wr=new WeakMap,qr=new WeakMap,qe=new WeakMap,G=new WeakMap,ln=new WeakMap,hn=new WeakMap,Cl=new WeakMap,Tl=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,ri=new WeakMap,Rl=new WeakMap,rd=new WeakMap,ad=new WeakMap,Pl=new WeakSet,tf=function(){const t=r(this,G).subarray(4,6),e=r(this,G).subarray(16,18),[s,i,n,a]=r(this,We);return[(r(this,ln)+(t[0]-e[0])/2-s)/n,(r(this,hn)+(t[1]-e[1])/2-i)/a,(r(this,ln)+(e[0]-t[0])/2-s)/n,(r(this,hn)+(e[1]-t[1])/2-i)/a]},f(as,Rl,8),f(as,rd,2),f(as,ad,r(as,Rl)+r(as,rd));let Zh=as;var Kr,cn,Rs,Ll,he,kl,ut,dn,ka,un,Ma,od,Dg;class ef extends Ig{constructor(e,s,i,n,a,o){super();f(this,dn);f(this,un);f(this,od);f(this,Kr,void 0);f(this,cn,null);f(this,Rs,void 0);f(this,Ll,void 0);f(this,he,void 0);f(this,kl,void 0);f(this,ut,void 0);m(this,ut,e),m(this,he,s),m(this,Kr,i),m(this,kl,n),m(this,Rs,a),m(this,Ll,o),b(this,od,Dg).call(this,o);const{x:l,y:c,width:d,height:u}=r(this,cn);for(let p=0,g=e.length;p<g;p+=2)e[p]=(e[p]-l)/d,e[p+1]=(e[p+1]-c)/u;for(let p=0,g=s.length;p<g;p+=2)s[p]=(s[p]-l)/d,s[p+1]=(s[p+1]-c)/u}toSVGPath(){const e=[`M${r(this,ut)[4]} ${r(this,ut)[5]}`];for(let s=6,i=r(this,ut).length;s<i;s+=6){if(isNaN(r(this,ut)[s])){e.push(`L${r(this,ut)[s+4]} ${r(this,ut)[s+5]}`);continue}e.push(`C${r(this,ut)[s]} ${r(this,ut)[s+1]} ${r(this,ut)[s+2]} ${r(this,ut)[s+3]} ${r(this,ut)[s+4]} ${r(this,ut)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,n],a){const o=i-e,l=n-s;let c,d;switch(a){case 0:c=b(this,dn,ka).call(this,r(this,ut),e,n,o,-l),d=b(this,dn,ka).call(this,r(this,he),e,n,o,-l);break;case 90:c=b(this,un,Ma).call(this,r(this,ut),e,s,o,l),d=b(this,un,Ma).call(this,r(this,he),e,s,o,l);break;case 180:c=b(this,dn,ka).call(this,r(this,ut),i,s,-o,l),d=b(this,dn,ka).call(this,r(this,he),i,s,-o,l);break;case 270:c=b(this,un,Ma).call(this,r(this,ut),i,n,-o,-l),d=b(this,un,Ma).call(this,r(this,he),i,n,-o,-l);break}return{outline:Array.from(c),points:[Array.from(d)]}}get box(){return r(this,cn)}getNewOutline(e,s){const{x:i,y:n,width:a,height:o}=r(this,cn),[l,c,d,u]=r(this,Kr),p=a*d,g=o*u,A=i*d+l,v=n*u+c,_=new Zh({x:r(this,he)[0]*p+A,y:r(this,he)[1]*g+v},r(this,Kr),r(this,kl),e,r(this,Ll),s??r(this,Rs));for(let y=2;y<r(this,he).length;y+=2)_.add({x:r(this,he)[y]*p+A,y:r(this,he)[y+1]*g+v});return _.getOutlines()}}Kr=new WeakMap,cn=new WeakMap,Rs=new WeakMap,Ll=new WeakMap,he=new WeakMap,kl=new WeakMap,ut=new WeakMap,dn=new WeakSet,ka=function(e,s,i,n,a){const o=new Float64Array(e.length);for(let l=0,c=e.length;l<c;l+=2)o[l]=s+e[l]*n,o[l+1]=i+e[l+1]*a;return o},un=new WeakSet,Ma=function(e,s,i,n,a){const o=new Float64Array(e.length);for(let l=0,c=e.length;l<c;l+=2)o[l]=s+e[l+1]*n,o[l+1]=i+e[l]*a;return o},od=new WeakSet,Dg=function(e){const s=r(this,ut);let i=s[4],n=s[5],a=i,o=n,l=i,c=n,d=i,u=n;const p=e?Math.max:Math.min;for(let y=6,E=s.length;y<E;y+=6){if(isNaN(s[y]))a=Math.min(a,s[y+4]),o=Math.min(o,s[y+5]),l=Math.max(l,s[y+4]),c=Math.max(c,s[y+5]),u<s[y+5]?(d=s[y+4],u=s[y+5]):u===s[y+5]&&(d=p(d,s[y+4]));else{const w=k.bezierBoundingBox(i,n,...s.slice(y,y+6));a=Math.min(a,w[0]),o=Math.min(o,w[1]),l=Math.max(l,w[2]),c=Math.max(c,w[3]),u<w[3]?(d=w[2],u=w[3]):u===w[3]&&(d=p(d,w[2]))}i=s[y+4],n=s[y+5]}const g=a-r(this,Rs),A=o-r(this,Rs),v=l-a+2*r(this,Rs),_=c-o+2*r(this,Rs);m(this,cn,{x:g,y:A,width:v,height:_,lastPoint:[d,u]})};var Ml,Il,ke,fn,Qr,At,Dl,Jr,Fl,Ol,ai,Zr,Nl,sf,Hl,nf,ld,Fg,Ps,_i,hd,Og,Xe,$s;const os=class os{constructor({editor:t=null,uiManager:e=null}){f(this,Nl);f(this,Hl);f(this,ld);f(this,Ps);f(this,hd);f(this,Xe);f(this,Ml,b(this,ld,Fg).bind(this));f(this,Il,b(this,hd,Og).bind(this));f(this,ke,null);f(this,fn,null);f(this,Qr,void 0);f(this,At,null);f(this,Dl,!1);f(this,Jr,!1);f(this,Fl,null);f(this,Ol,void 0);f(this,ai,null);f(this,Zr,void 0);var s;t?(m(this,Jr,!1),m(this,Zr,j.HIGHLIGHT_COLOR),m(this,Fl,t)):(m(this,Jr,!0),m(this,Zr,j.HIGHLIGHT_DEFAULT_COLOR)),m(this,ai,(t==null?void 0:t._uiManager)||e),m(this,Ol,r(this,ai)._eventBus),m(this,Qr,(t==null?void 0:t.color)||((s=r(this,ai))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98")}static get _keyboardManager(){return X(this,"_keyboardManager",new dh([[["Escape","mac+Escape"],os.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],os.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],os.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],os.prototype._moveToPrevious],[["Home","mac+Home"],os.prototype._moveToBeginning],[["End","mac+End"],os.prototype._moveToEnd]]))}renderButton(){const t=m(this,ke,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0),t.addEventListener("click",b(this,Ps,_i).bind(this)),t.addEventListener("keydown",r(this,Ml));const e=m(this,fn,document.createElement("span"));return e.className="swatch",e.setAttribute("aria-hidden",!0),e.style.backgroundColor=r(this,Qr),t.append(e),t}renderMainDropdown(){const t=m(this,At,b(this,Nl,sf).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===r(this,ke)){b(this,Ps,_i).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,Hl,nf).call(this,e,t)}_moveToNext(t){var e,s;if(!r(this,Xe,$s)){b(this,Ps,_i).call(this,t);return}if(t.target===r(this,ke)){(e=r(this,At).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=r(this,At))==null?void 0:e.firstChild)||t.target===r(this,ke)){r(this,Xe,$s)&&this._hideDropdownFromKeyboard();return}r(this,Xe,$s)||b(this,Ps,_i).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!r(this,Xe,$s)){b(this,Ps,_i).call(this,t);return}(e=r(this,At).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!r(this,Xe,$s)){b(this,Ps,_i).call(this,t);return}(e=r(this,At).lastChild)==null||e.focus()}hideDropdown(){var t;(t=r(this,At))==null||t.classList.add("hidden"),window.removeEventListener("pointerdown",r(this,Il))}_hideDropdownFromKeyboard(){var t;if(!r(this,Jr)){if(!r(this,Xe,$s)){(t=r(this,Fl))==null||t.unselect();return}this.hideDropdown(),r(this,ke).focus({preventScroll:!0,focusVisible:r(this,Dl)})}}updateColor(t){if(r(this,fn)&&(r(this,fn).style.backgroundColor=t),!r(this,At))return;const e=r(this,ai).highlightColors.values();for(const s of r(this,At).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=r(this,ke))==null||t.remove(),m(this,ke,null),m(this,fn,null),(e=r(this,At))==null||e.remove(),m(this,At,null)}};Ml=new WeakMap,Il=new WeakMap,ke=new WeakMap,fn=new WeakMap,Qr=new WeakMap,At=new WeakMap,Dl=new WeakMap,Jr=new WeakMap,Fl=new WeakMap,Ol=new WeakMap,ai=new WeakMap,Zr=new WeakMap,Nl=new WeakSet,sf=function(){const t=document.createElement("div");t.addEventListener("contextmenu",te),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[e,s]of r(this,ai).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",s),i.title=e,i.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${e}`);const n=document.createElement("span");i.append(n),n.className="swatch",n.style.backgroundColor=s,i.setAttribute("aria-selected",s===r(this,Qr)),i.addEventListener("click",b(this,Hl,nf).bind(this,s)),t.append(i)}return t.addEventListener("keydown",r(this,Ml)),t},Hl=new WeakSet,nf=function(t,e){e.stopPropagation(),r(this,Ol).dispatch("switchannotationeditorparams",{source:this,type:r(this,Zr),value:t})},ld=new WeakSet,Fg=function(t){os._keyboardManager.exec(this,t)},Ps=new WeakSet,_i=function(t){if(r(this,Xe,$s)){this.hideDropdown();return}if(m(this,Dl,t.detail===0),window.addEventListener("pointerdown",r(this,Il)),r(this,At)){r(this,At).classList.remove("hidden");return}const e=m(this,At,b(this,Nl,sf).call(this));r(this,ke).append(e)},hd=new WeakSet,Og=function(t){var e;(e=r(this,At))!=null&&e.contains(t.target)||this.hideDropdown()},Xe=new WeakSet,$s=function(){return r(this,At)&&!r(this,At).classList.contains("hidden")};let tc=os;var ta,Bl,oi,pn,ea,me,jl,Ul,gn,Me,Vt,ce,cd,sa,mn,vt,ia,Ye,$l,zl,rf,Vl,af,dd,Ng,ud,Hg,fd,Bg,Gl,of,bn,Ia,li,qn,pd,jg,na,Uh,An,Da,gd,Ug,md,$g,bd,zg,Ad,Vg;const q=class q extends J{constructor(e){super({...e,name:"highlightEditor"});f(this,zl);f(this,Vl);f(this,dd);f(this,ud);f(this,fd);f(this,Gl);f(this,bn);f(this,pd);f(this,na);f(this,An);f(this,gd);f(this,md);f(this,ta,null);f(this,Bl,0);f(this,oi,void 0);f(this,pn,null);f(this,ea,null);f(this,me,null);f(this,jl,null);f(this,Ul,0);f(this,gn,null);f(this,Me,null);f(this,Vt,null);f(this,ce,!1);f(this,cd,b(this,pd,jg).bind(this));f(this,sa,null);f(this,mn,void 0);f(this,vt,null);f(this,ia,"");f(this,Ye,void 0);f(this,$l,"");this.color=e.color||q._defaultColor,m(this,Ye,e.thickness||q._defaultThickness),m(this,mn,e.opacity||q._defaultOpacity),m(this,oi,e.boxes||null),m(this,$l,e.methodOfCreation||""),m(this,ia,e.text||""),this._isDraggable=!1,e.highlightId>-1?(m(this,ce,!0),b(this,Vl,af).call(this,e),b(this,bn,Ia).call(this)):(m(this,ta,e.anchorNode),m(this,Bl,e.anchorOffset),m(this,jl,e.focusNode),m(this,Ul,e.focusOffset),b(this,zl,rf).call(this),b(this,bn,Ia).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=q.prototype;return X(this,"_keyboardManager",new dh([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:r(this,ce)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:r(this,Ye),methodOfCreation:r(this,$l)}}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;J.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 j.HIGHLIGHT_DEFAULT_COLOR:q._defaultColor=s;break;case j.HIGHLIGHT_THICKNESS:q._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return r(this,sa)}updateParams(e,s){switch(e){case j.HIGHLIGHT_COLOR:b(this,dd,Ng).call(this,s);break;case j.HIGHLIGHT_THICKNESS:b(this,ud,Hg).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[j.HIGHLIGHT_DEFAULT_COLOR,q._defaultColor],[j.HIGHLIGHT_THICKNESS,q._defaultThickness]]}get propertiesToUpdate(){return[[j.HIGHLIGHT_COLOR,this.color||q._defaultColor],[j.HIGHLIGHT_THICKNESS,r(this,Ye)||q._defaultThickness],[j.HIGHLIGHT_FREE,r(this,ce)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(m(this,ea,new tc({editor:this})),e.addColorPicker(r(this,ea))),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,An,Da).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,An,Da).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){b(this,Gl,of).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,bn,Ia).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?b(this,Gl,of).call(this):e&&(b(this,bn,Ia).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var n,a,o;const{drawLayer:s}=this.parent;let i;r(this,ce)?(e=(e-this.rotation+360)%360,i=b(n=q,li,qn).call(n,r(this,Me).box,e)):i=b(a=q,li,qn).call(a,this,e),s.rotate(r(this,Vt),e),s.rotate(r(this,vt),e),s.updateBox(r(this,Vt),i),s.updateBox(r(this,vt),b(o=q,li,qn).call(o,r(this,me).box,e))}render(){if(this.div)return this.div;const e=super.render();r(this,ia)&&(e.setAttribute("aria-label",r(this,ia)),e.setAttribute("role","mark")),r(this,ce)?e.classList.add("free"):this.div.addEventListener("keydown",r(this,cd));const s=m(this,gn,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=r(this,pn);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),Yh(this,r(this,gn),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.parent.drawLayer.addClass(r(this,vt),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(r(this,vt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,na,Uh).call(this,!0);break;case 1:case 3:b(this,na,Uh).call(this,!1);break}}select(){var e,s;super.select(),r(this,vt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,vt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(r(this,vt),"selected"))}unselect(){var e;super.unselect(),r(this,vt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,vt),"selected"),r(this,ce)||b(this,na,Uh).call(this,!1))}get _mustFixPosition(){return!r(this,ce)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(r(this,Vt),e),this.parent.drawLayer.show(r(this,vt),e))}static startHighlighting(e,s,{target:i,x:n,y:a}){const{x:o,y:l,width:c,height:d}=i.getBoundingClientRect(),u=v=>{b(this,bd,zg).call(this,e,v)},p={capture:!0,passive:!1},g=v=>{v.preventDefault(),v.stopPropagation()},A=v=>{i.removeEventListener("pointermove",u),window.removeEventListener("blur",A),window.removeEventListener("pointerup",A),window.removeEventListener("pointerdown",g,p),window.removeEventListener("contextmenu",te),b(this,Ad,Vg).call(this,e,v)};window.addEventListener("blur",A),window.addEventListener("pointerup",A),window.addEventListener("pointerdown",g,p),window.addEventListener("contextmenu",te),i.addEventListener("pointermove",u),this._freeHighlight=new Zh({x:n,y:a},[o,l,c,d],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static deserialize(e,s,i){var v;const n=super.deserialize(e,s,i),{rect:[a,o,l,c],color:d,quadPoints:u}=e;n.color=k.makeHexColor(...d),m(n,mn,e.opacity);const[p,g]=n.pageDimensions;n.width=(l-a)/p,n.height=(c-o)/g;const A=m(n,oi,[]);for(let _=0;_<u.length;_+=8)A.push({x:(u[4]-l)/p,y:(c-(1-u[_+5]))/g,width:(u[_+2]-u[_])/p,height:(u[_+5]-u[_+1])/g});return b(v=n,zl,rf).call(v),n}serialize(e=!1){if(this.isEmpty()||e)return null;const s=this.getRect(0,0),i=J._colorManager.convert(this.color);return{annotationType:W.HIGHLIGHT,color:i,opacity:r(this,mn),thickness:r(this,Ye),quadPoints:b(this,gd,Ug).call(this),outlines:b(this,md,$g).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:b(this,An,Da).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}};ta=new WeakMap,Bl=new WeakMap,oi=new WeakMap,pn=new WeakMap,ea=new WeakMap,me=new WeakMap,jl=new WeakMap,Ul=new WeakMap,gn=new WeakMap,Me=new WeakMap,Vt=new WeakMap,ce=new WeakMap,cd=new WeakMap,sa=new WeakMap,mn=new WeakMap,vt=new WeakMap,ia=new WeakMap,Ye=new WeakMap,$l=new WeakMap,zl=new WeakSet,rf=function(){const e=new Ju(r(this,oi),.001);m(this,Me,e.getOutlines()),{x:this.x,y:this.y,width:this.width,height:this.height}=r(this,Me).box;const s=new Ju(r(this,oi),.0025,.001,this._uiManager.direction==="ltr");m(this,me,s.getOutlines());const{lastPoint:i}=r(this,me).box;m(this,sa,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Vl=new WeakSet,af=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var u,p;if(m(this,Me,e),m(this,me,e.getNewOutline(r(this,Ye)/2+1.5,.0025)),s>=0)m(this,Vt,s),m(this,pn,i),this.parent.drawLayer.finalizeLine(s,e),m(this,vt,this.parent.drawLayer.highlightOutline(r(this,me)));else if(this.parent){const g=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(r(this,Vt),e),this.parent.drawLayer.updateBox(r(this,Vt),b(u=q,li,qn).call(u,r(this,Me).box,(g-this.rotation+360)%360)),this.parent.drawLayer.updateLine(r(this,vt),r(this,me)),this.parent.drawLayer.updateBox(r(this,vt),b(p=q,li,qn).call(p,r(this,me).box,g))}const{x:a,y:o,width:l,height:c}=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=c;break;case 90:{const[g,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/g,this.height=c*g/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[g,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/g,this.height=c*g/A;break}}const{lastPoint:d}=r(this,me).box;m(this,sa,[(d[0]-a)/l,(d[1]-o)/c])},dd=new WeakSet,Ng=function(e){const s=n=>{var a,o;this.color=n,(a=this.parent)==null||a.drawLayer.changeColor(r(this,Vt),n),(o=r(this,ea))==null||o.updateColor(n)},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},ud=new WeakSet,Hg=function(e){const s=r(this,Ye),i=n=>{m(this,Ye,n),b(this,fd,Bg).call(this,n)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},fd=new WeakSet,Bg=function(e){if(!r(this,ce))return;b(this,Vl,af).call(this,{highlightOutlines:r(this,Me).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Gl=new WeakSet,of=function(){r(this,Vt)===null||!this.parent||(this.parent.drawLayer.remove(r(this,Vt)),m(this,Vt,null),this.parent.drawLayer.remove(r(this,vt)),m(this,vt,null))},bn=new WeakSet,Ia=function(e=this.parent){r(this,Vt)===null&&({id:ie(this,Vt)._,clipPathId:ie(this,pn)._}=e.drawLayer.highlight(r(this,Me),this.color,r(this,mn)),m(this,vt,e.drawLayer.highlightOutline(r(this,me))),r(this,gn)&&(r(this,gn).style.clipPath=r(this,pn)))},li=new WeakSet,qn=function({x:e,y:s,width:i,height:n},a){switch(a){case 90:return{x:1-s-n,y:e,width:n,height:i};case 180:return{x:1-e-i,y:1-s-n,width:i,height:n};case 270:return{x:s,y:1-e-i,width:n,height:i}}return{x:e,y:s,width:i,height:n}},pd=new WeakSet,jg=function(e){q._keyboardManager.exec(this,e)},na=new WeakSet,Uh=function(e){if(!r(this,ta))return;const s=window.getSelection();e?s.setPosition(r(this,ta),r(this,Bl)):s.setPosition(r(this,jl),r(this,Ul))},An=new WeakSet,Da=function(){return r(this,ce)?this.rotation:0},gd=new WeakSet,Ug=function(){if(r(this,ce))return null;const[e,s]=this.pageDimensions,i=r(this,oi),n=new Array(i.length*8);let a=0;for(const{x:o,y:l,width:c,height:d}of i){const u=o*e,p=(1-l-d)*s;n[a]=n[a+4]=u,n[a+1]=n[a+3]=p,n[a+2]=n[a+6]=u+c*e,n[a+5]=n[a+7]=p+d*s,a+=8}return n},md=new WeakSet,$g=function(e){return r(this,Me).serialize(e,b(this,An,Da).call(this))},bd=new WeakSet,zg=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Ad=new WeakSet,Vg=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.removeFreeHighlight(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=""},f(q,li),f(q,bd),f(q,Ad),U(q,"_defaultColor",null),U(q,"_defaultOpacity",1),U(q,"_defaultThickness",12),U(q,"_l10nPromise"),U(q,"_type","highlight"),U(q,"_editorType",W.HIGHLIGHT),U(q,"_freeHighlightId",-1),U(q,"_freeHighlight",null),U(q,"_freeHighlightClipId","");let ec=q;var vn,yn,Wl,ql,Xl,_n,Ke,Ls,be,En,wn,Sn,xn,Cn,hi,vd,Gg,yd,Wg,_d,qg,Ed,Xg,Yl,hf,wd,Yg,Kl,cf,Sd,Kg,xd,Qg,Cd,Jg,Td,Zg,Rd,tm,ks,Ei,Ql,df,ra,$h,aa,zh,ci,Xn,Jl,uf,oa,Vh,Pd,em,Zl,ff,Ld,sm,kd,im,th,pf,la,Gh,Tn,Fa;const at=class at extends J{constructor(e){super({...e,name:"inkEditor"});f(this,vd);f(this,yd);f(this,_d);f(this,Ed);f(this,Yl);f(this,wd);f(this,Kl);f(this,Sd);f(this,xd);f(this,Cd);f(this,Td);f(this,Rd);f(this,ks);f(this,Ql);f(this,ra);f(this,aa);f(this,ci);f(this,Jl);f(this,oa);f(this,kd);f(this,th);f(this,la);f(this,Tn);f(this,vn,0);f(this,yn,0);f(this,Wl,this.canvasPointermove.bind(this));f(this,ql,this.canvasPointerleave.bind(this));f(this,Xl,this.canvasPointerup.bind(this));f(this,_n,this.canvasPointerdown.bind(this));f(this,Ke,null);f(this,Ls,new Path2D);f(this,be,!1);f(this,En,!1);f(this,wn,!1);f(this,Sn,null);f(this,xn,0);f(this,Cn,0);f(this,hi,null);this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(e,s){J.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case j.INK_THICKNESS:at._defaultThickness=s;break;case j.INK_COLOR:at._defaultColor=s;break;case j.INK_OPACITY:at._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case j.INK_THICKNESS:b(this,vd,Gg).call(this,s);break;case j.INK_COLOR:b(this,yd,Wg).call(this,s);break;case j.INK_OPACITY:b(this,_d,qg).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[j.INK_THICKNESS,at._defaultThickness],[j.INK_COLOR,at._defaultColor||J._defaultLineColor],[j.INK_OPACITY,Math.round(at._defaultOpacity*100)]]}get propertiesToUpdate(){return[[j.INK_THICKNESS,this.thickness||at._defaultThickness],[j.INK_COLOR,this.color||at._defaultColor||J._defaultLineColor],[j.INK_OPACITY,Math.round(100*(this.opacity??at._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(b(this,ra,$h).call(this),b(this,aa,zh).call(this)),this.isAttachedToDOM||(this.parent.add(this),b(this,ci,Xn).call(this)),b(this,Tn,Fa).call(this)))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,r(this,Ke)&&(clearTimeout(r(this,Ke)),m(this,Ke,null)),r(this,Sn).disconnect(),m(this,Sn,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&e===null&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){const[e,s]=this.parentDimensions,i=this.width*e,n=this.height*s;this.setDimensions(i,n)}enableEditMode(){r(this,be)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",r(this,_n)))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",r(this,_n)))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){r(this,be)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),m(this,be,!0),this.div.classList.add("disabled"),b(this,Tn,Fa).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),this.enableEditMode())}canvasPointerdown(e){e.button!==0||!this.isInEditMode()||r(this,be)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),b(this,wd,Yg).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),b(this,Kl,cf).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),b(this,Ql,df).call(this,e)}canvasPointerleave(e){b(this,Ql,df).call(this,e)}get isResizable(){return!this.isEmpty()&&r(this,be)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,n,a,o]=b(this,Ed,Xg).call(this);if(this.setAt(i,n,0,0),this.setDims(a,o),b(this,ra,$h).call(this),this.width){const[l,c]=this.parentDimensions;this.setAspectRatio(this.width*l,this.height*c),this.setAt(e*l,s*c,this.width*l,this.height*c),m(this,wn,!0),b(this,ci,Xn).call(this),this.setDims(this.width*l,this.height*c),b(this,ks,Ei).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return b(this,aa,zh).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(r(this,xn)===i&&r(this,Cn)===n)return;m(this,xn,i),m(this,Cn,n),this.canvas.style.visibility="hidden";const[a,o]=this.parentDimensions;this.width=e/a,this.height=s/o,this.fixAndSetPosition(),r(this,be)&&b(this,Jl,uf).call(this,e,s),b(this,ci,Xn).call(this),b(this,ks,Ei).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(e,s,i){var _,y,E;if(e instanceof Eg)return null;const n=super.deserialize(e,s,i);n.thickness=e.thickness,n.color=k.makeHexColor(...e.color),n.opacity=e.opacity;const[a,o]=n.pageDimensions,l=n.width*a,c=n.height*o,d=n.parentScale,u=e.thickness/2;m(n,be,!0),m(n,xn,Math.round(l)),m(n,Cn,Math.round(c));const{paths:p,rect:g,rotation:A}=e;for(let{bezier:w}of p){w=b(_=at,Ld,sm).call(_,w,g,A);const S=[];n.paths.push(S);let x=d*(w[0]-u),C=d*(w[1]-u);for(let P=2,M=w.length;P<M;P+=6){const O=d*(w[P]-u),T=d*(w[P+1]-u),$=d*(w[P+2]-u),D=d*(w[P+3]-u),I=d*(w[P+4]-u),z=d*(w[P+5]-u);S.push([[x,C],[O,T],[$,D],[I,z]]),x=I,C=z}const R=b(this,Pd,em).call(this,S);n.bezierPath2D.push(R)}const v=b(y=n,th,pf).call(y);return m(n,yn,Math.max(J.MIN_SIZE,v[2]-v[0])),m(n,vn,Math.max(J.MIN_SIZE,v[3]-v[1])),b(E=n,Jl,uf).call(E,l,c),n}serialize(){if(this.isEmpty())return null;const e=this.getRect(0,0),s=J._colorManager.convert(this.ctx.strokeStyle);return{annotationType:W.INK,color:s,thickness:this.thickness,opacity:this.opacity,paths:b(this,kd,im).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};vn=new WeakMap,yn=new WeakMap,Wl=new WeakMap,ql=new WeakMap,Xl=new WeakMap,_n=new WeakMap,Ke=new WeakMap,Ls=new WeakMap,be=new WeakMap,En=new WeakMap,wn=new WeakMap,Sn=new WeakMap,xn=new WeakMap,Cn=new WeakMap,hi=new WeakMap,vd=new WeakSet,Gg=function(e){const s=n=>{this.thickness=n,b(this,Tn,Fa).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},yd=new WeakSet,Wg=function(e){const s=n=>{this.color=n,b(this,ks,Ei).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},_d=new WeakSet,qg=function(e){const s=n=>{this.opacity=n,b(this,ks,Ei).call(this)};e/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},Ed=new WeakSet,Xg=function(){const{parentRotation:e,parentDimensions:[s,i]}=this;switch(e){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},Yl=new WeakSet,hf=function(){const{ctx:e,color:s,opacity:i,thickness:n,parentScale:a,scaleFactor:o}=this;e.lineWidth=n*a/o,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${s}${ob(i)}`},wd=new WeakSet,Yg=function(e,s){this.canvas.addEventListener("contextmenu",te),this.canvas.addEventListener("pointerleave",r(this,ql)),this.canvas.addEventListener("pointermove",r(this,Wl)),this.canvas.addEventListener("pointerup",r(this,Xl)),this.canvas.removeEventListener("pointerdown",r(this,_n)),this.isEditing=!0,r(this,wn)||(m(this,wn,!0),b(this,ci,Xn).call(this),this.thickness||(this.thickness=at._defaultThickness),this.color||(this.color=at._defaultColor||J._defaultLineColor),this.opacity??(this.opacity=at._defaultOpacity)),this.currentPath.push([e,s]),m(this,En,!1),b(this,Yl,hf).call(this),m(this,hi,()=>{b(this,Cd,Jg).call(this),r(this,hi)&&window.requestAnimationFrame(r(this,hi))}),window.requestAnimationFrame(r(this,hi))},Kl=new WeakSet,cf=function(e,s){const[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&s===n)return;const a=this.currentPath;let o=r(this,Ls);if(a.push([e,s]),m(this,En,!0),a.length<=2){o.moveTo(...a[0]),o.lineTo(e,s);return}a.length===3&&(m(this,Ls,o=new Path2D),o.moveTo(...a[0])),b(this,Td,Zg).call(this,o,...a.at(-3),...a.at(-2),e,s)},Sd=new WeakSet,Kg=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);r(this,Ls).lineTo(...e)},xd=new WeakSet,Qg=function(e,s){m(this,hi,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),b(this,Kl,cf).call(this,e,s),b(this,Sd,Kg).call(this);let i;if(this.currentPath.length!==1)i=b(this,Rd,tm).call(this);else{const c=[e,s];i=[[c,c.slice(),c.slice(),c]]}const n=r(this,Ls),a=this.currentPath;this.currentPath=[],m(this,Ls,new Path2D);const o=()=>{this.allRawPaths.push(a),this.paths.push(i),this.bezierPath2D.push(n),this._uiManager.rebuild(this)},l=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(b(this,ra,$h).call(this),b(this,aa,zh).call(this)),b(this,Tn,Fa).call(this))};this.addCommands({cmd:o,undo:l,mustExec:!0})},Cd=new WeakSet,Jg=function(){if(!r(this,En))return;m(this,En,!1);const e=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(o=>o[0]),n=s.map(o=>o[1]);Math.min(...i)-e,Math.max(...i)+e,Math.min(...n)-e,Math.max(...n)+e;const{ctx:a}=this;a.save(),a.clearRect(0,0,this.canvas.width,this.canvas.height);for(const o of this.bezierPath2D)a.stroke(o);a.stroke(r(this,Ls)),a.restore()},Td=new WeakSet,Zg=function(e,s,i,n,a,o,l){const c=(s+n)/2,d=(i+a)/2,u=(n+o)/2,p=(a+l)/2;e.bezierCurveTo(c+2*(n-c)/3,d+2*(a-d)/3,u+2*(n-u)/3,p+2*(a-p)/3,u,p)},Rd=new WeakSet,tm=function(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const s=[];let i,[n,a]=e[0];for(i=1;i<e.length-2;i++){const[g,A]=e[i],[v,_]=e[i+1],y=(g+v)/2,E=(A+_)/2,w=[n+2*(g-n)/3,a+2*(A-a)/3],S=[y+2*(g-y)/3,E+2*(A-E)/3];s.push([[n,a],w,S,[y,E]]),[n,a]=[y,E]}const[o,l]=e[i],[c,d]=e[i+1],u=[n+2*(o-n)/3,a+2*(l-a)/3],p=[c+2*(o-c)/3,d+2*(l-d)/3];return s.push([[n,a],u,p,[c,d]]),s},ks=new WeakSet,Ei=function(){if(this.isEmpty()){b(this,oa,Vh).call(this);return}b(this,Yl,hf).call(this);const{canvas:e,ctx:s}=this;s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e.width,e.height),b(this,oa,Vh).call(this);for(const i of this.bezierPath2D)s.stroke(i)},Ql=new WeakSet,df=function(e){this.canvas.removeEventListener("pointerleave",r(this,ql)),this.canvas.removeEventListener("pointermove",r(this,Wl)),this.canvas.removeEventListener("pointerup",r(this,Xl)),this.canvas.addEventListener("pointerdown",r(this,_n)),r(this,Ke)&&clearTimeout(r(this,Ke)),m(this,Ke,setTimeout(()=>{m(this,Ke,null),this.canvas.removeEventListener("contextmenu",te)},10)),b(this,xd,Qg).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},ra=new WeakSet,$h=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},aa=new WeakSet,zh=function(){m(this,Sn,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),r(this,Sn).observe(this.div)},ci=new WeakSet,Xn=function(){if(!r(this,wn))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),b(this,oa,Vh).call(this)},Jl=new WeakSet,uf=function(e,s){const i=b(this,la,Gh).call(this),n=(e-i)/r(this,yn),a=(s-i)/r(this,vn);this.scaleFactor=Math.min(n,a)},oa=new WeakSet,Vh=function(){const e=b(this,la,Gh).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},Pd=new WeakSet,em=function(e){const s=new Path2D;for(let i=0,n=e.length;i<n;i++){const[a,o,l,c]=e[i];i===0&&s.moveTo(...a),s.bezierCurveTo(o[0],o[1],l[0],l[1],c[0],c[1])}return s},Zl=new WeakSet,ff=function(e,s,i){const[n,a,o,l]=s;switch(i){case 0:for(let c=0,d=e.length;c<d;c+=2)e[c]+=n,e[c+1]=l-e[c+1];break;case 90:for(let c=0,d=e.length;c<d;c+=2){const u=e[c];e[c]=e[c+1]+n,e[c+1]=u+a}break;case 180:for(let c=0,d=e.length;c<d;c+=2)e[c]=o-e[c],e[c+1]+=a;break;case 270:for(let c=0,d=e.length;c<d;c+=2){const u=e[c];e[c]=o-e[c+1],e[c+1]=l-u}break;default:throw new Error("Invalid rotation")}return e},Ld=new WeakSet,sm=function(e,s,i){const[n,a,o,l]=s;switch(i){case 0:for(let c=0,d=e.length;c<d;c+=2)e[c]-=n,e[c+1]=l-e[c+1];break;case 90:for(let c=0,d=e.length;c<d;c+=2){const u=e[c];e[c]=e[c+1]-a,e[c+1]=u-n}break;case 180:for(let c=0,d=e.length;c<d;c+=2)e[c]=o-e[c],e[c+1]-=a;break;case 270:for(let c=0,d=e.length;c<d;c+=2){const u=e[c];e[c]=l-e[c+1],e[c+1]=o-u}break;default:throw new Error("Invalid rotation")}return e},kd=new WeakSet,im=function(e,s,i,n){var d,u;const a=[],o=this.thickness/2,l=e*s+o,c=e*i+o;for(const p of this.paths){const g=[],A=[];for(let v=0,_=p.length;v<_;v++){const[y,E,w,S]=p[v];if(y[0]===S[0]&&y[1]===S[1]&&_===1){const D=e*y[0]+l,I=e*y[1]+c;g.push(D,I),A.push(D,I);break}const x=e*y[0]+l,C=e*y[1]+c,R=e*E[0]+l,P=e*E[1]+c,M=e*w[0]+l,O=e*w[1]+c,T=e*S[0]+l,$=e*S[1]+c;v===0&&(g.push(x,C),A.push(x,C)),g.push(R,P,M,O,T,$),A.push(R,P),v===_-1&&A.push(T,$)}a.push({bezier:b(d=at,Zl,ff).call(d,g,n,this.rotation),points:b(u=at,Zl,ff).call(u,A,n,this.rotation)})}return a},th=new WeakSet,pf=function(){let e=1/0,s=-1/0,i=1/0,n=-1/0;for(const a of this.paths)for(const[o,l,c,d]of a){const u=k.bezierBoundingBox(...o,...l,...c,...d);e=Math.min(e,u[0]),i=Math.min(i,u[1]),s=Math.max(s,u[2]),n=Math.max(n,u[3])}return[e,i,s,n]},la=new WeakSet,Gh=function(){return r(this,be)?Math.ceil(this.thickness*this.parentScale):0},Tn=new WeakSet,Fa=function(e=!1){if(this.isEmpty())return;if(!r(this,be)){b(this,ks,Ei).call(this);return}const s=b(this,th,pf).call(this),i=b(this,la,Gh).call(this);m(this,yn,Math.max(J.MIN_SIZE,s[2]-s[0])),m(this,vn,Math.max(J.MIN_SIZE,s[3]-s[1]));const n=Math.ceil(i+r(this,yn)*this.scaleFactor),a=Math.ceil(i+r(this,vn)*this.scaleFactor),[o,l]=this.parentDimensions;this.width=n/o,this.height=a/l,this.setAspectRatio(n,a);const c=this.translationX,d=this.translationY;this.translationX=-s[0],this.translationY=-s[1],b(this,ci,Xn).call(this),b(this,ks,Ei).call(this),m(this,xn,n),m(this,Cn,a),this.setDims(n,a);const u=e?i/this.scaleFactor/2:0;this.translate(c-this.translationX-u,d-this.translationY-u)},f(at,Pd),f(at,Zl),f(at,Ld),U(at,"_defaultColor",null),U(at,"_defaultOpacity",1),U(at,"_defaultThickness",1),U(at,"_type","ink"),U(at,"_editorType",W.INK);let lf=at;var Mt,It,di,Ms,ui,ha,Qe,Rn,Je,Ie,eh,Pn,Oa,Ln,Na,ca,Wh,sh,mf,Md,nm,Id,rm,ih,bf,da,qh,Dd,am;const ja=class ja extends J{constructor(e){super({...e,name:"stampEditor"});f(this,Pn);f(this,Ln);f(this,ca);f(this,sh);f(this,Md);f(this,Id);f(this,ih);f(this,da);f(this,Dd);f(this,Mt,null);f(this,It,null);f(this,di,null);f(this,Ms,null);f(this,ui,null);f(this,ha,"");f(this,Qe,null);f(this,Rn,null);f(this,Je,null);f(this,Ie,!1);f(this,eh,!1);m(this,Ms,e.bitmapUrl),m(this,ui,e.bitmapFile)}static initialize(e,s){J.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(W.STAMP,{bitmapFile:e.getAsFile()})}remove(){var e,s;r(this,It)&&(m(this,Mt,null),this._uiManager.imageManager.deleteId(r(this,It)),(e=r(this,Qe))==null||e.remove(),m(this,Qe,null),(s=r(this,Rn))==null||s.disconnect(),m(this,Rn,null),r(this,Je)&&(clearTimeout(r(this,Je)),m(this,Je,null))),super.remove()}rebuild(){if(!this.parent){r(this,It)&&b(this,ca,Wh).call(this);return}super.rebuild(),this.div!==null&&(r(this,It)&&r(this,Qe)===null&&b(this,ca,Wh).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(r(this,di)||r(this,Mt)||r(this,Ms)||r(this,ui)||r(this,It))}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.addAltTextButton(),r(this,Mt)?b(this,sh,mf).call(this):b(this,ca,Wh).call(this),this.width){const[i,n]=this.parentDimensions;this.setAt(e*i,s*n,this.width*i,this.height*n)}return this.div}getImageForAltText(){return r(this,Qe)}static deserialize(e,s,i){if(e instanceof wg)return null;const n=super.deserialize(e,s,i),{rect:a,bitmapUrl:o,bitmapId:l,isSvg:c,accessibilityData:d}=e;l&&i.imageManager.isValidId(l)?m(n,It,l):m(n,Ms,o),m(n,Ie,c);const[u,p]=n.pageDimensions;return n.width=(a[2]-a[0])/u,n.height=(a[3]-a[1])/p,d&&(n.altTextData=d),n}serialize(e=!1,s=null){if(this.isEmpty())return null;const i={annotationType:W.STAMP,bitmapId:r(this,It),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:r(this,Ie),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=b(this,da,qh).call(this,!0),i.accessibilityData=this.altTextData,i;const{decorative:n,altText:a}=this.altTextData;if(!n&&a&&(i.accessibilityData={type:"Figure",alt:a}),s===null)return i;s.stamps||(s.stamps=new Map);const o=r(this,Ie)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(r(this,It)))s.stamps.set(r(this,It),{area:o,serialized:i}),i.bitmap=b(this,da,qh).call(this,!1);else if(r(this,Ie)){const l=s.stamps.get(r(this,It));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,da,qh).call(this,!1))}return i}};Mt=new WeakMap,It=new WeakMap,di=new WeakMap,Ms=new WeakMap,ui=new WeakMap,ha=new WeakMap,Qe=new WeakMap,Rn=new WeakMap,Je=new WeakMap,Ie=new WeakMap,eh=new WeakMap,Pn=new WeakSet,Oa=function(e,s=!1){if(!e){this.remove();return}m(this,Mt,e.bitmap),s||(m(this,It,e.id),m(this,Ie,e.isSvg)),e.file&&m(this,ha,e.file.name),b(this,sh,mf).call(this)},Ln=new WeakSet,Na=function(){m(this,di,null),this._uiManager.enableWaiting(!1),r(this,Qe)&&this.div.focus()},ca=new WeakSet,Wh=function(){if(r(this,It)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(r(this,It)).then(s=>b(this,Pn,Oa).call(this,s,!0)).finally(()=>b(this,Ln,Na).call(this));return}if(r(this,Ms)){const s=r(this,Ms);m(this,Ms,null),this._uiManager.enableWaiting(!0),m(this,di,this._uiManager.imageManager.getFromUrl(s).then(i=>b(this,Pn,Oa).call(this,i)).finally(()=>b(this,Ln,Na).call(this)));return}if(r(this,ui)){const s=r(this,ui);m(this,ui,null),this._uiManager.enableWaiting(!0),m(this,di,this._uiManager.imageManager.getFromFile(s).then(i=>b(this,Pn,Oa).call(this,i)).finally(()=>b(this,Ln,Na).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=ja.supportedTypesStr,m(this,di,new Promise(s=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(e.files[0]);b(this,Pn,Oa).call(this,i)}s()}),e.addEventListener("cancel",()=>{this.remove(),s()})}).finally(()=>b(this,Ln,Na).call(this))),e.click()},sh=new WeakSet,mf=function(){const{div:e}=this;let{width:s,height:i}=r(this,Mt);const[n,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*n,i=this.height*a;else if(s>o*n||i>o*a){const u=Math.min(o*n/s,o*a/i);s*=u,i*=u}const[l,c]=this.parentDimensions;this.setDims(s*l/n,i*c/a),this._uiManager.enableWaiting(!1);const d=m(this,Qe,document.createElement("canvas"));e.append(d),e.hidden=!1,b(this,ih,bf).call(this,s,i),b(this,Dd,am).call(this),r(this,eh)||(this.parent.addUndoableEditor(this),m(this,eh,!0)),this._reportTelemetry({action:"inserted_image"}),r(this,ha)&&d.setAttribute("aria-label",r(this,ha))},Md=new WeakSet,nm=function(e,s){var o;const[i,n]=this.parentDimensions;this.width=e/i,this.height=s/n,this.setDims(e,s),(o=this._initialOptions)!=null&&o.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,r(this,Je)!==null&&clearTimeout(r(this,Je)),m(this,Je,setTimeout(()=>{m(this,Je,null),b(this,ih,bf).call(this,e,s)},200))},Id=new WeakSet,rm=function(e,s){const{width:i,height:n}=r(this,Mt);let a=i,o=n,l=r(this,Mt);for(;a>2*e||o>2*s;){const c=a,d=o;a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,c,d,0,0,a,o),l=u.transferToImageBitmap()}return l},ih=new WeakSet,bf=function(e,s){e=Math.ceil(e),s=Math.ceil(s);const i=r(this,Qe);if(!i||i.width===e&&i.height===s)return;i.width=e,i.height=s;const n=r(this,Ie)?r(this,Mt):b(this,Id,rm).call(this,e,s);if(this._uiManager.hasMLManager&&!this.hasAltText()){const l=new OffscreenCanvas(e,s).getContext("2d");l.drawImage(n,0,0,n.width,n.height,0,0,e,s),this._uiManager.mlGuess({service:"image-to-text",request:{data:l.getImageData(0,0,e,s).data,width:e,height:s,channels:4}}).then(c=>{const d=(c==null?void 0:c.output)||"";this.parent&&d&&!this.hasAltText()&&(this.altTextData={altText:d,decorative:!1})})}const a=i.getContext("2d");a.filter=this._uiManager.hcmFilter,a.drawImage(n,0,0,n.width,n.height,0,0,e,s)},da=new WeakSet,qh=function(e){if(e){if(r(this,Ie)){const n=this._uiManager.imageManager.getSvgUrl(r(this,It));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=r(this,Mt),s.getContext("2d").drawImage(r(this,Mt),0,0),s.toDataURL()}if(r(this,Ie)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*mi.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*mi.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,a);return o.getContext("2d").drawImage(r(this,Mt),0,0,r(this,Mt).width,r(this,Mt).height,0,0,n,a),o.transferToImageBitmap()}return structuredClone(r(this,Mt))},Dd=new WeakSet,am=function(){m(this,Rn,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&b(this,Md,nm).call(this,s.width,s.height)})),r(this,Rn).observe(this.div)},U(ja,"_type","stamp"),U(ja,"_editorType",W.STAMP);let gf=ja;var kn,ua,Ze,Mn,Is,Ds,Fs,de,fi,fa,pa,Gt,N,pi,Fd,om,nh,vf,rh,yf,ah,_f,ga,Xh;const _e=class _e{constructor({uiManager:t,pageIndex:e,div:s,accessibilityManager:i,annotationLayer:n,drawLayer:a,textLayer:o,viewport:l,l10n:c}){f(this,Fd);f(this,nh);f(this,rh);f(this,ah);f(this,ga);f(this,kn,void 0);f(this,ua,!1);f(this,Ze,null);f(this,Mn,null);f(this,Is,null);f(this,Ds,null);f(this,Fs,null);f(this,de,new Map);f(this,fi,!1);f(this,fa,!1);f(this,pa,!1);f(this,Gt,null);f(this,N,void 0);const d=[...r(_e,pi).values()];if(!_e._initialized){_e._initialized=!0;for(const u of d)u.initialize(c,t)}t.registerEditorTypes(d),m(this,N,t),this.pageIndex=e,this.div=s,m(this,kn,i),m(this,Ze,n),this.viewport=l,m(this,Gt,o),this.drawLayer=a,r(this,N).addLayer(this)}get isEmpty(){return r(this,de).size===0}get isInvisible(){return this.isEmpty&&r(this,N).getMode()===W.NONE}updateToolbar(t){r(this,N).updateToolbar(t)}updateMode(t=r(this,N).getMode()){switch(b(this,ga,Xh).call(this),t){case W.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case W.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case W.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of r(_e,pi).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=r(this,Gt))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(r(this,N).getMode()!==W.INK)return;if(!t){for(const s of r(this,de).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){r(this,N).setEditingState(t)}addCommands(t){r(this,N).addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=r(this,Ze))==null||e.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of r(this,de).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(r(this,N).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!r(this,Ze))return;const e=r(this,Ze).getEditableAnnotations();for(const s of e){if(s.hide(),r(this,N).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;m(this,pa,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of r(this,de).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else e.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(r(this,Ze)){const n=r(this,Ze).getEditableAnnotations();for(const a of n){const{id:o}=a.data;if(r(this,N).isDeletedAnnotationElement(o))continue;let l=e.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=t.get(o),l&&(r(this,N).addChangedExistingAnnotation(l),l.renderAnnotationElement(a),l.show(!1)),a.show()}}b(this,ga,Xh).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of r(_e,pi).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),m(this,pa,!1)}getEditableAnnotation(t){var e;return((e=r(this,Ze))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){r(this,N).getActive()!==t&&r(this,N).setActiveEditor(t)}enableTextSelection(){var t;this.div.tabIndex=-1,(t=r(this,Gt))!=null&&t.div&&!r(this,Ds)&&(m(this,Ds,b(this,Fd,om).bind(this)),r(this,Gt).div.addEventListener("pointerdown",r(this,Ds)),r(this,Gt).div.classList.add("highlighting"))}disableTextSelection(){var t;this.div.tabIndex=0,(t=r(this,Gt))!=null&&t.div&&r(this,Ds)&&(r(this,Gt).div.removeEventListener("pointerdown",r(this,Ds)),m(this,Ds,null),r(this,Gt).div.classList.remove("highlighting"))}enableClick(){r(this,Is)||(m(this,Is,this.pointerdown.bind(this)),m(this,Mn,this.pointerup.bind(this)),this.div.addEventListener("pointerdown",r(this,Is)),this.div.addEventListener("pointerup",r(this,Mn)))}disableClick(){r(this,Is)&&(this.div.removeEventListener("pointerdown",r(this,Is)),this.div.removeEventListener("pointerup",r(this,Mn)),m(this,Is,null),m(this,Mn,null))}attach(t){r(this,de).set(t.id,t);const{annotationElementId:e}=t;e&&r(this,N).isDeletedAnnotationElement(e)&&r(this,N).removeDeletedAnnotationElement(t)}detach(t){var e;r(this,de).delete(t.id),(e=r(this,kn))==null||e.removePointerInTextLayer(t.contentDiv),!r(this,pa)&&t.annotationElementId&&r(this,N).addDeletedAnnotationElement(t)}remove(t){this.detach(t),r(this,N).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,r(this,fa)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(r(this,N).addDeletedAnnotationElement(t.annotationElementId),J.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),r(this,N).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),r(this,N).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!r(this,Fs)&&(t._focusEventsAllowed=!1,m(this,Fs,setTimeout(()=>{m(this,Fs,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0}),e.focus())},0))),t._structTreeParentId=(s=r(this,kn))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return r(this,N).getId()}canCreateNewEmptyEditor(){var t;return(t=r(this,nh,vf))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){r(this,N).updateToolbar(t),r(this,N).updateMode(t);const{offsetX:s,offsetY:i}=b(this,ah,_f).call(this),n=this.getNextId(),a=b(this,rh,yf).call(this,{parent:this,id:n,x:s,y:i,uiManager:r(this,N),isCentered:!0,...e});a&&this.add(a)}deserialize(t){var e;return((e=r(_e,pi).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,r(this,N)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=b(this,rh,yf).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:r(this,N),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(b(this,ah,_f).call(this),!0)}setSelected(t){r(this,N).setSelected(t)}toggleSelected(t){r(this,N).toggleSelected(t)}isSelected(t){return r(this,N).isSelected(t)}unselect(t){r(this,N).unselect(t)}pointerup(t){const{isMac:e}=Zt.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&r(this,fi)){if(m(this,fi,!1),!r(this,ua)){m(this,ua,!0);return}if(r(this,N).getMode()===W.STAMP){r(this,N).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(r(this,N).getMode()===W.HIGHLIGHT&&this.enableTextSelection(),r(this,fi)){m(this,fi,!1);return}const{isMac:e}=Zt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;m(this,fi,!0);const s=r(this,N).getActive();m(this,ua,!s||s.isEmpty())}findNewParent(t,e,s){const i=r(this,N).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=r(this,N).getActive())==null?void 0:t.parent)===this&&(r(this,N).commitOrRemove(),r(this,N).setActiveEditor(null)),r(this,Fs)&&(clearTimeout(r(this,Fs)),m(this,Fs,null));for(const s of r(this,de).values())(e=r(this,kn))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,r(this,de).clear(),r(this,N).removeLayer(this)}render({viewport:t}){this.viewport=t,In(this.div,t);for(const e of r(this,N).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){r(this,N).commitOrRemove(),b(this,ga,Xh).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,In(this.div,{rotation:s}),e!==s)for(const i of r(this,de).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return r(this,N).viewParameters.realScale}};kn=new WeakMap,ua=new WeakMap,Ze=new WeakMap,Mn=new WeakMap,Is=new WeakMap,Ds=new WeakMap,Fs=new WeakMap,de=new WeakMap,fi=new WeakMap,fa=new WeakMap,pa=new WeakMap,Gt=new WeakMap,N=new WeakMap,pi=new WeakMap,Fd=new WeakSet,om=function(t){if(r(this,N).unselectAll(),t.target===r(this,Gt).div){const{isMac:e}=Zt.platform;if(t.button!==0||t.ctrlKey&&e)return;r(this,N).showAllEditors("highlight",!0,!0),r(this,Gt).div.classList.add("free"),ec.startHighlighting(this,r(this,N).direction==="ltr",t),r(this,Gt).div.addEventListener("pointerup",()=>{r(this,Gt).div.classList.remove("free")},{once:!0}),t.preventDefault()}},nh=new WeakSet,vf=function(){return r(_e,pi).get(r(this,N).getMode())},rh=new WeakSet,yf=function(t){const e=r(this,nh,vf);return e?new e.prototype.constructor(t):null},ah=new WeakSet,_f=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),c=(n+o)/2-t,d=(a+l)/2-e,[u,p]=this.viewport.rotation%180===0?[c,d]:[d,c];return{offsetX:u,offsetY:p}},ga=new WeakSet,Xh=function(){m(this,fa,!0);for(const t of r(this,de).values())t.isEmpty()&&t.remove();m(this,fa,!1)},U(_e,"_initialized",!1),f(_e,pi,new Map([Ku,lf,gf,ec].map(t=>[t._editorType,t])));let Af=_e;var ts,oh,yt,gi,lh,wf,hh,Sf,Od,lm;const Ct=class Ct{constructor({pageIndex:t}){f(this,hh);f(this,Od);f(this,ts,null);f(this,oh,0);f(this,yt,new Map);f(this,gi,new Map);this.pageIndex=t}setParent(t){if(!r(this,ts)){m(this,ts,t);return}if(r(this,ts)!==t){if(r(this,yt).size>0)for(const e of r(this,yt).values())e.remove(),t.append(e);m(this,ts,t)}}static get _svgFactory(){return X(this,"_svgFactory",new Pf)}highlight(t,e,s,i=!1){const n=ie(this,oh)._++,a=b(this,hh,Sf).call(this,t.box);a.classList.add("highlight"),t.free&&a.classList.add("free");const o=Ct._svgFactory.createElement("defs");a.append(o);const l=Ct._svgFactory.createElement("path");o.append(l);const c=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",c),l.setAttribute("d",t.toSVGPath()),i&&r(this,gi).set(n,l);const d=b(this,Od,lm).call(this,o,c),u=Ct._svgFactory.createElement("use");return a.append(u),a.setAttribute("fill",e),a.setAttribute("fill-opacity",s),u.setAttribute("href",`#${c}`),r(this,yt).set(n,a),{id:n,clipPathId:`url(#${d})`}}highlightOutline(t){const e=ie(this,oh)._++,s=b(this,hh,Sf).call(this,t.box);s.classList.add("highlightOutline");const i=Ct._svgFactory.createElement("defs");s.append(i);const n=Ct._svgFactory.createElement("path");i.append(n);const a=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",a),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(t.free){s.classList.add("free");const d=Ct._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=Ct._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const p=Ct._svgFactory.createElement("use");d.append(p),p.setAttribute("href",`#${a}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const l=Ct._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const c=l.cloneNode();return s.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),r(this,yt).set(e,s),e}finalizeLine(t,e){const s=r(this,gi).get(t);r(this,gi).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){r(this,yt).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),r(this,gi).delete(t)}updatePath(t,e){r(this,gi).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;b(s=Ct,lh,wf).call(s,r(this,yt).get(t),e)}show(t,e){r(this,yt).get(t).classList.toggle("hidden",!e)}rotate(t,e){r(this,yt).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){r(this,yt).get(t).setAttribute("fill",e)}changeOpacity(t,e){r(this,yt).get(t).setAttribute("fill-opacity",e)}addClass(t,e){r(this,yt).get(t).classList.add(e)}removeClass(t,e){r(this,yt).get(t).classList.remove(e)}remove(t){r(this,ts)!==null&&(r(this,yt).get(t).remove(),r(this,yt).delete(t))}destroy(){m(this,ts,null);for(const t of r(this,yt).values())t.remove();r(this,yt).clear()}};ts=new WeakMap,oh=new WeakMap,yt=new WeakMap,gi=new WeakMap,lh=new WeakSet,wf=function(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*n}%`},hh=new WeakSet,Sf=function(t){var s;const e=Ct._svgFactory.create(1,1,!0);return r(this,ts).append(e),e.setAttribute("aria-hidden",!0),b(s=Ct,lh,wf).call(s,e,t),e},Od=new WeakSet,lm=function(t,e){const s=Ct._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=Ct._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},f(Ct,lh);let Ef=Ct;var HA=B.AbortException,BA=B.AnnotationEditorLayer,jA=B.AnnotationEditorParamsType,UA=B.AnnotationEditorType,$A=B.AnnotationEditorUIManager,hm=B.AnnotationLayer,cm=B.AnnotationMode,zA=B.CMapCompressionType,VA=B.ColorPicker,GA=B.DOMSVGFactory,WA=B.DrawLayer,qA=B.FeatureTest,Nf=B.GlobalWorkerOptions,XA=B.ImageKind,YA=B.InvalidPDFException,KA=B.MissingPDFException,QA=B.OPS,JA=B.Outliner,ZA=B.PDFDataRangeTransport,tv=B.PDFDateString,ev=B.PDFWorker,sv=B.PasswordResponses,iv=B.PermissionFlag,nv=B.PixelsPerInch,rv=B.RenderingCancelledException,dm=B.TextLayer,av=B.UnexpectedResponseException,ov=B.Util,lv=B.VerbosityLevel,hv=B.XfaLayer,cv=B.build,dv=B.createValidAbsoluteUrl,uv=B.fetchData,um=B.getDocument,fv=B.getFilenameFromUrl,pv=B.getPdfFilenameFromUrl,gv=B.getXfaPageViewport,mv=B.isDataScheme,bv=B.isPdfFile,Av=B.noContextMenu,vv=B.normalizeUnicode,yv=B.renderTextLayer,_v=B.setLayerDimensions,Ev=B.shadow,wv=B.updateTextLayer,Sv=B.version;const xv=Object.freeze(Object.defineProperty({__proto__:null,AbortException:HA,AnnotationEditorLayer:BA,AnnotationEditorParamsType:jA,AnnotationEditorType:UA,AnnotationEditorUIManager:$A,AnnotationLayer:hm,AnnotationMode:cm,CMapCompressionType:zA,ColorPicker:VA,DOMSVGFactory:GA,DrawLayer:WA,FeatureTest:qA,GlobalWorkerOptions:Nf,ImageKind:XA,InvalidPDFException:YA,MissingPDFException:KA,OPS:QA,Outliner:JA,PDFDataRangeTransport:ZA,PDFDateString:tv,PDFWorker:ev,PasswordResponses:sv,PermissionFlag:iv,PixelsPerInch:nv,RenderingCancelledException:rv,TextLayer:dm,UnexpectedResponseException:av,Util:ov,VerbosityLevel:lv,XfaLayer:hv,build:cv,createValidAbsoluteUrl:dv,fetchData:uv,getDocument:um,getFilenameFromUrl:fv,getPdfFilenameFromUrl:pv,getXfaPageViewport:gv,isDataScheme:mv,isPdfFile:bv,noContextMenu:Av,normalizeUnicode:vv,renderTextLayer:yv,setLayerDimensions:_v,shadow:Ev,updateTextLayer:wv,version:Sv},Symbol.toStringTag,{value:"Module"}));var Et=function(h,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,n;s<i;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return h.concat(n||Array.prototype.slice.call(t))},Cv=["onCopy","onCut","onPaste"],Tv=["onCompositionEnd","onCompositionStart","onCompositionUpdate"],Rv=["onFocus","onBlur"],Pv=["onInput","onInvalid","onReset","onSubmit"],Lv=["onLoad","onError"],kv=["onKeyDown","onKeyPress","onKeyUp"],Mv=["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],Iv=["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],Dv=["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],Fv=["onSelect"],Ov=["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],Nv=["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],Hv=["onScroll"],Bv=["onWheel"],jv=["onAnimationStart","onAnimationEnd","onAnimationIteration"],Uv=["onTransitionEnd"],$v=["onToggle"],zv=["onChange"],Vv=Et(Et(Et(Et(Et(Et(Et(Et(Et(Et(Et(Et(Et(Et(Et(Et(Et(Et([],Cv,!0),Tv,!0),Rv,!0),Pv,!0),Lv,!0),kv,!0),Mv,!0),Iv,!0),Dv,!0),Fv,!0),Ov,!0),Nv,!0),Hv,!0),Bv,!0),jv,!0),Uv,!0),zv,!0),$v,!0);function fm(h,t){var e={};return Vv.forEach(function(s){var i=h[s];i&&(t?e[s]=function(n){return i(n,t(s))}:e[s]=i)}),e}function ph(h){var t=!1,e=new Promise(function(s,i){h.then(function(n){return!t&&s(n)}).catch(function(n){return!t&&i(n)})});return{promise:e,cancel:function(){t=!0}}}function pm(h){var t,e,s="";if(typeof h=="string"||typeof h=="number")s+=h;else if(typeof h=="object")if(Array.isArray(h)){var i=h.length;for(t=0;t<i;t++)h[t]&&(e=pm(h[t]))&&(s&&(s+=" "),s+=e)}else for(e in h)h[e]&&(s&&(s+=" "),s+=e);return s}function Xd(){for(var h,t,e=0,s="",i=arguments.length;e<i;e++)(h=arguments[e])&&(t=pm(h))&&(s&&(s+=" "),s+=t);return s}var Gv="Invariant failed";function it(h,t){if(!h)throw new Error(Gv)}var rp=Object.prototype.hasOwnProperty;function ap(h,t,e){for(e of h.keys())if(Jn(e,t))return e}function Jn(h,t){var e,s,i;if(h===t)return!0;if(h&&t&&(e=h.constructor)===t.constructor){if(e===Date)return h.getTime()===t.getTime();if(e===RegExp)return h.toString()===t.toString();if(e===Array){if((s=h.length)===t.length)for(;s--&&Jn(h[s],t[s]););return s===-1}if(e===Set){if(h.size!==t.size)return!1;for(s of h)if(i=s,i&&typeof i=="object"&&(i=ap(t,i),!i)||!t.has(i))return!1;return!0}if(e===Map){if(h.size!==t.size)return!1;for(s of h)if(i=s[0],i&&typeof i=="object"&&(i=ap(t,i),!i)||!Jn(s[1],t.get(i)))return!1;return!0}if(e===ArrayBuffer)h=new Uint8Array(h),t=new Uint8Array(t);else if(e===DataView){if((s=h.byteLength)===t.byteLength)for(;s--&&h.getInt8(s)===t.getInt8(s););return s===-1}if(ArrayBuffer.isView(h)){if((s=h.byteLength)===t.byteLength)for(;s--&&h[s]===t[s];);return s===-1}if(!e||typeof h=="object"){s=0;for(e in h)if(rp.call(h,e)&&++s&&!rp.call(t,e)||!(e in t)||!Jn(h[e],t[e]))return!1;return Object.keys(t).length===s}}return h!==h&&t!==t}const gm=F.createContext(null);function Zn({children:h,type:t}){return ft("div",{className:`react-pdf__message react-pdf__message--${t}`,children:h})}const Wv="noopener noreferrer nofollow";class qv{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return it(this.pdfViewer),this.pdfViewer.currentPageNumber||0}set page(t){it(this.pdfViewer),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}goToDestination(t){return new Promise(e=>{it(this.pdfDocument),it(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{it(Array.isArray(e));const s=e[0];new Promise(i=>{it(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{it(!1)}):typeof s=="number"?i(s):it(!1)}).then(i=>{const n=i+1;it(this.pdfViewer),it(n>=1&&n<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:i,pageNumber:n})})})}navigateTo(t){this.goToDestination(t)}goToPage(t){const e=t-1;it(this.pdfViewer),it(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||Wv,t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const op={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Yd=typeof document<"u",mm=Yd&&window.location.protocol==="file:";function Xv(h){return typeof h<"u"}function vi(h){return Xv(h)&&h!==null}function Yv(h){return typeof h=="string"}function Kv(h){return h instanceof ArrayBuffer}function Qv(h){return it(Yd),h instanceof Blob}function xf(h){return Yv(h)&&/^data:/.test(h)}function lp(h){it(xf(h));const[t="",e=""]=h.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function Jv(){return Yd&&window.devicePixelRatio||1}const bm="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function hp(){Ht(!mm,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${bm}`)}function Zv(){Ht(!mm,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${bm}`)}function On(h){h&&h.cancel&&h.cancel()}function Cf(h,t){return Object.defineProperty(h,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(h,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(h,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(h,"originalHeight",{get(){return this.view[3]},configurable:!0}),h}function ty(h){return h.name==="RenderingCancelledException"}function ey(h){return new Promise((t,e)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return e(new Error("Error while reading a file."));t(s.result)},s.onerror=i=>{if(!i.target)return e(new Error("Error while reading a file."));const{error:n}=i.target;if(!n)return e(new Error("Error while reading a file."));switch(n.code){case n.NOT_FOUND_ERR:return e(new Error("Error while reading a file: File not found."));case n.SECURITY_ERR:return e(new Error("Error while reading a file: Security error."));case n.ABORT_ERR:return e(new Error("Error while reading a file: Aborted."));default:return e(new Error("Error while reading a file."))}},s.readAsArrayBuffer(h)})}function sy(h,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return h}}function ma(){return F.useReducer(sy,{value:void 0,error:void 0})}var iy=function(h,t,e,s){function i(n){return n instanceof e?n:new e(function(a){a(n)})}return new(e||(e=Promise))(function(n,a){function o(d){try{c(s.next(d))}catch(u){a(u)}}function l(d){try{c(s.throw(d))}catch(u){a(u)}}function c(d){d.done?n(d.value):i(d.value).then(o,l)}c((s=s.apply(h,t||[])).next())})},cp=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(h,s[i])&&(e[s[i]]=h[s[i]]);return e};const{PDFDataRangeTransport:ny}=xv,ry=(h,t)=>{switch(t){case op.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");h(e);break}case op.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");h(e);break}}};function dp(h){return typeof h=="object"&&h!==null&&("data"in h||"range"in h||"url"in h)}const ay=F.forwardRef(function(t,e){var{children:s,className:i,error:n="Failed to load PDF file.",externalLinkRel:a,externalLinkTarget:o,file:l,inputRef:c,imageResourcesPath:d,loading:u="Loading PDF…",noData:p="No PDF file specified.",onItemClick:g,onLoadError:A,onLoadProgress:v,onLoadSuccess:_,onPassword:y=ry,onSourceError:E,onSourceSuccess:w,options:S,renderMode:x,rotate:C}=t,R=cp(t,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[P,M]=ma(),{value:O,error:T}=P,[$,D]=ma(),{value:I,error:z}=$,Y=F.useRef(new qv),L=F.useRef([]),H=F.useRef(void 0),jt=F.useRef(void 0);l&&l!==H.current&&dp(l)&&(Ht(!Jn(l,H.current),`File prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),H.current=l),S&&S!==jt.current&&(Ht(!Jn(S,jt.current),`Options prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),jt.current=S);const ue=F.useRef({scrollPageIntoView:nt=>{const{dest:Ut,pageNumber:ye,pageIndex:Bs=ye-1}=nt;if(g){g({dest:Ut,pageIndex:Bs,pageNumber:ye});return}const gh=L.current[Bs];if(gh){gh.scrollIntoView();return}Ht(!1,`An internal link leading to page ${ye} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});F.useImperativeHandle(e,()=>({linkService:Y,pages:L,viewer:ue}),[]);function ee(){w&&w()}function dt(){T&&(Ht(!1,T.toString()),E&&E(T))}function ot(){M({type:"RESET"})}F.useEffect(ot,[l,M]);const Dt=F.useCallback(()=>iy(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return xf(l)?{data:lp(l)}:(hp(),{url:l});if(l instanceof ny)return{range:l};if(Kv(l))return{data:l};if(Yd&&Qv(l))return{data:yield ey(l)};if(it(typeof l=="object"),it(dp(l)),"url"in l&&typeof l.url=="string"){if(xf(l.url)){const{url:nt}=l,Ut=cp(l,["url"]),ye=lp(nt);return Object.assign({data:ye},Ut)}hp()}return l}),[l]);F.useEffect(()=>{const nt=ph(Dt());return nt.promise.then(Ut=>{M({type:"RESOLVE",value:Ut})}).catch(Ut=>{M({type:"REJECT",error:Ut})}),()=>{On(nt)}},[Dt,M]),F.useEffect(()=>{if(!(typeof O>"u")){if(O===!1){dt();return}ee()}},[O]);function ve(){I&&(_&&_(I),L.current=new Array(I.numPages),Y.current.setDocument(I))}function qt(){z&&(Ht(!1,z.toString()),A&&A(z))}function K(){D({type:"RESET"})}F.useEffect(K,[D,O]);function jn(){if(!O)return;const nt=Object.assign(Object.assign({},O),S),Ut=um(nt);v&&(Ut.onProgress=v),y&&(Ut.onPassword=y);const ye=Ut;return ye.promise.then(Bs=>{D({type:"RESOLVE",value:Bs})}).catch(Bs=>{ye.destroyed||D({type:"REJECT",error:Bs})}),()=>{ye.destroy()}}F.useEffect(jn,[S,D,O]),F.useEffect(()=>{if(!(typeof I>"u")){if(I===!1){qt();return}ve()}},[I]);function Ai(){Y.current.setViewer(ue.current),Y.current.setExternalLinkRel(a),Y.current.setExternalLinkTarget(o)}F.useEffect(Ai,[a,o]);function ht(nt,Ut){L.current[nt]=Ut}function ba(nt){delete L.current[nt]}const Aa=F.useMemo(()=>({imageResourcesPath:d,linkService:Y.current,onItemClick:g,pdf:I,registerPage:ht,renderMode:x,rotate:C,unregisterPage:ba}),[d,g,I,x,C]),se=F.useMemo(()=>fm(R,()=>I),[R,I]);function De(){return ft(gm.Provider,{value:Aa,children:s})}function Hs(){return l?I==null?ft(Zn,{type:"loading",children:typeof u=="function"?u():u}):I===!1?ft(Zn,{type:"error",children:typeof n=="function"?n():n}):De():ft(Zn,{type:"no-data",children:typeof p=="function"?p():p})}return ft("div",Object.assign({className:Xd("react-pdf__Document",i),ref:c,style:{"--scale-factor":"1"}},se,{children:Hs()}))});function Am(){return F.useContext(gm)}function vm(){for(var h=[],t=0;t<arguments.length;t++)h[t]=arguments[t];var e=h.filter(Boolean);if(e.length<=1){var s=e[0];return s||null}return function(n){e.forEach(function(a){typeof a=="function"?a(n):a&&(a.current=n)})}}const ym=F.createContext(null),_m={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},oy=/^H(\d+)$/;function ly(h){return h in _m}function Kd(h){return"children"in h}function Em(h){return Kd(h)?h.children.length===1&&0 in h.children&&"id"in h.children[0]:!1}function hy(h){const t={};if(Kd(h)){const{role:e}=h,s=e.match(oy);if(s)t.role="heading",t["aria-level"]=Number(s[1]);else if(ly(e)){const i=_m[e];i&&(t.role=i)}}return t}function wm(h){const t={};if(Kd(h)){if(h.alt!==void 0&&(t["aria-label"]=h.alt),h.lang!==void 0&&(t.lang=h.lang),Em(h)){const[e]=h.children;if(e){const s=wm(e);return Object.assign(Object.assign({},t),s)}}}else"id"in h&&(t["aria-owns"]=h.id);return t}function cy(h){return h?Object.assign(Object.assign({},hy(h)),wm(h)):null}function Sm({className:h,node:t}){const e=F.useMemo(()=>cy(t),[t]),s=F.useMemo(()=>!Kd(t)||Em(t)?null:t.children.map((i,n)=>ft(Sm,{node:i},n)),[t]);return ft("span",Object.assign({className:h},e,{children:s}))}function Qd(){return F.useContext(ym)}function dy(){const h=Qd();it(h);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=h,[s,i]=ma(),{value:n,error:a}=s,{customTextRenderer:o,page:l}=h;function c(){n&&e&&e(n)}function d(){a&&(Ht(!1,a.toString()),t&&t(a))}function u(){i({type:"RESET"})}F.useEffect(u,[i,l]);function p(){if(o||!l)return;const g=ph(l.getStructTree()),A=g;return g.promise.then(v=>{i({type:"RESOLVE",value:v})}).catch(v=>{i({type:"REJECT",error:v})}),()=>On(A)}return F.useEffect(p,[o,l,i]),F.useEffect(()=>{if(n!==void 0){if(n===!1){d();return}c()}},[n]),n?ft(Sm,{className:"react-pdf__Page__structTree structTree",node:n}):null}const up=cm;function uy(h){const t=Qd();it(t);const e=Object.assign(Object.assign({},t),h),{_className:s,canvasBackground:i,devicePixelRatio:n=Jv(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:c,renderTextLayer:d,rotate:u,scale:p}=e,{canvasRef:g}=h;it(l);const A=F.useRef(null);function v(){l&&o&&o(Cf(l,p))}function _(x){ty(x)||(Ht(!1,x.toString()),a&&a(x))}const y=F.useMemo(()=>l.getViewport({scale:p*n,rotation:u}),[n,l,u,p]),E=F.useMemo(()=>l.getViewport({scale:p,rotation:u}),[l,u,p]);function w(){if(!l)return;l.cleanup();const{current:x}=A;if(!x)return;x.width=y.width,x.height=y.height,x.style.width=`${Math.floor(E.width)}px`,x.style.height=`${Math.floor(E.height)}px`,x.style.visibility="hidden";const C={annotationMode:c?up.ENABLE_FORMS:up.ENABLE,canvasContext:x.getContext("2d",{alpha:!1}),viewport:y};i&&(C.background=i);const R=l.render(C),P=R;return R.promise.then(()=>{x.style.visibility="",v()}).catch(_),()=>On(P)}F.useEffect(w,[i,A,n,l,c,y,E]);const S=F.useCallback(()=>{const{current:x}=A;x&&(x.width=0,x.height=0)},[A]);return F.useEffect(()=>S,[S]),ft("canvas",{className:`${s}__canvas`,dir:"ltr",ref:vm(g,A),style:{display:"block",userSelect:"none"},children:d?ft(dy,{}):null})}function fy(h){return"str"in h}function py(){const h=Qd();it(h);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:a,pageIndex:o,pageNumber:l,rotate:c,scale:d}=h;it(a);const[u,p]=ma(),{value:g,error:A}=u,v=F.useRef(null),_=F.useRef(void 0);Ht(parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function y(){g&&s&&s(g)}function E(){A&&(Ht(!1,A.toString()),e&&e(A))}function w(){p({type:"RESET"})}F.useEffect(w,[a,p]);function S(){if(!a)return;const T=ph(a.getTextContent()),$=T;return T.promise.then(D=>{p({type:"RESOLVE",value:D})}).catch(D=>{p({type:"REJECT",error:D})}),()=>On($)}F.useEffect(S,[a,p]),F.useEffect(()=>{if(g!==void 0){if(g===!1){E();return}y()}},[g]);const x=F.useCallback(()=>{n&&n()},[n]),C=F.useCallback(T=>{Ht(!1,T.toString()),i&&i(T)},[i]);function R(){const T=_.current;T&&T.classList.add("active")}function P(){const T=_.current;T&&T.classList.remove("active")}const M=F.useMemo(()=>a.getViewport({scale:d,rotation:c}),[a,c,d]);function O(){if(!a||!g)return;const{current:T}=v;if(!T)return;T.innerHTML="";const $=a.streamTextContent({includeMarkedContent:!0}),D={container:T,textContentSource:$,viewport:M},I=new dm(D),z=I;return I.render().then(()=>{const Y=document.createElement("div");Y.className="endOfContent",T.append(Y),_.current=Y;const L=T.querySelectorAll('[role="presentation"]');if(t){let H=0;g.items.forEach((jt,ue)=>{if(!fy(jt))return;const ee=L[H];if(!ee)return;const dt=t(Object.assign({pageIndex:o,pageNumber:l,itemIndex:ue},jt));ee.innerHTML=dt,H+=jt.str&&jt.hasEOL?2:1})}x()}).catch(C),()=>On(z)}return F.useLayoutEffect(O,[t,C,x,a,o,l,g,M]),ft("div",{className:Xd("react-pdf__Page__textContent","textLayer"),onMouseUp:P,onMouseDown:R,ref:v})}function gy(){const h=Am(),t=Qd();it(t);const e=Object.assign(Object.assign({},h),t),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:n,onGetAnnotationsSuccess:a,onRenderAnnotationLayerError:o,onRenderAnnotationLayerSuccess:l,page:c,pdf:d,renderForms:u,rotate:p,scale:g=1}=e;it(d),it(c),it(i);const[A,v]=ma(),{value:_,error:y}=A,E=F.useRef(null);Ht(parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function w(){_&&a&&a(_)}function S(){y&&(Ht(!1,y.toString()),n&&n(y))}function x(){v({type:"RESET"})}F.useEffect(x,[v,c]);function C(){if(!c)return;const T=ph(c.getAnnotations()),$=T;return T.promise.then(D=>{v({type:"RESOLVE",value:D})}).catch(D=>{v({type:"REJECT",error:D})}),()=>{On($)}}F.useEffect(C,[v,c,u]),F.useEffect(()=>{if(_!==void 0){if(_===!1){S();return}w()}},[_]);function R(){l&&l()}function P(T){Ht(!1,`${T}`),o&&o(T)}const M=F.useMemo(()=>c.getViewport({scale:g,rotation:p}),[c,p,g]);function O(){if(!d||!c||!i||!_)return;const{current:T}=E;if(!T)return;const $=M.clone({dontFlip:!0}),D={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:T,l10n:null,page:c,viewport:$},I={annotations:_,annotationStorage:d.annotationStorage,div:T,imageResourcesPath:s,linkService:i,page:c,renderForms:u,viewport:$};T.innerHTML="";try{new hm(D).render(I),R()}catch(z){P(z)}return()=>{}}return F.useEffect(O,[_,s,i,c,u,M]),ft("div",{className:Xd("react-pdf__Page__annotations","annotationLayer"),ref:E})}var my=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(h,s[i])&&(e[s[i]]=h[s[i]]);return e};const fp=1;function by(h){const t=Am(),e=Object.assign(Object.assign({},t),h),{_className:s="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:n,canvasRef:a,children:o,className:l,customRenderer:c,customTextRenderer:d,devicePixelRatio:u,error:p="Failed to load the page.",height:g,inputRef:A,loading:v="Loading page…",noData:_="No page specified.",onGetAnnotationsError:y,onGetAnnotationsSuccess:E,onGetStructTreeError:w,onGetStructTreeSuccess:S,onGetTextError:x,onGetTextSuccess:C,onLoadError:R,onLoadSuccess:P,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:O,onRenderError:T,onRenderSuccess:$,onRenderTextLayerError:D,onRenderTextLayerSuccess:I,pageIndex:z,pageNumber:Y,pdf:L,registerPage:H,renderAnnotationLayer:jt=!0,renderForms:ue=!1,renderMode:ee="canvas",renderTextLayer:dt=!0,rotate:ot,scale:Dt=fp,unregisterPage:ve,width:qt}=e,K=my(e,["_className","_enableRegisterUnregisterPage","canvasBackground","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[jn,Ai]=ma(),{value:ht,error:ba}=jn,Aa=F.useRef(null);it(L);const se=vi(Y)?Y-1:z??null,De=Y??(vi(z)?z+1:null),Hs=ot??(ht?ht.rotate:null),nt=F.useMemo(()=>{if(!ht)return null;let Un=1;const Jd=Dt??fp;if(qt||g){const $n=ht.getViewport({scale:1,rotation:Hs});qt?Un=qt/$n.width:g&&(Un=g/$n.height)}return Jd*Un},[g,ht,Hs,Dt,qt]);function Ut(){return()=>{vi(se)&&i&&ve&&ve(se)}}F.useEffect(Ut,[i,L,se,ve]);function ye(){if(P){if(!ht||!nt)return;P(Cf(ht,nt))}if(i&&H){if(!vi(se)||!Aa.current)return;H(se,Aa.current)}}function Bs(){ba&&(Ht(!1,ba.toString()),R&&R(ba))}function gh(){Ai({type:"RESET"})}F.useEffect(gh,[Ai,L,se]);function xm(){if(!L||!De)return;const Un=ph(L.getPage(De)),Jd=Un;return Un.promise.then($n=>{Ai({type:"RESOLVE",value:$n})}).catch($n=>{Ai({type:"REJECT",error:$n})}),()=>On(Jd)}F.useEffect(xm,[Ai,L,se,De,H]),F.useEffect(()=>{if(ht!==void 0){if(ht===!1){Bs();return}ye()}},[ht,nt]);const Cm=F.useMemo(()=>ht&&vi(se)&&De&&vi(Hs)&&vi(nt)?{_className:s,canvasBackground:n,customTextRenderer:d,devicePixelRatio:u,onGetAnnotationsError:y,onGetAnnotationsSuccess:E,onGetStructTreeError:w,onGetStructTreeSuccess:S,onGetTextError:x,onGetTextSuccess:C,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:O,onRenderError:T,onRenderSuccess:$,onRenderTextLayerError:D,onRenderTextLayerSuccess:I,page:ht,pageIndex:se,pageNumber:De,renderForms:ue,renderTextLayer:dt,rotate:Hs,scale:nt}:null,[s,n,d,u,y,E,w,S,x,C,M,O,T,$,D,I,ht,se,De,ue,dt,Hs,nt]),Tm=F.useMemo(()=>fm(K,()=>ht&&(nt?Cf(ht,nt):void 0)),[K,ht,nt]),mh=`${se}@${nt}/${Hs}`;function Rm(){switch(ee){case"custom":return it(c),ft(c,{},`${mh}_custom`);case"none":return null;case"canvas":default:return ft(uy,{canvasRef:a},`${mh}_canvas`)}}function Pm(){return dt?ft(py,{},`${mh}_text`):null}function Lm(){return jt?ft(gy,{},`${mh}_annotations`):null}function km(){return Fm(ym.Provider,{value:Cm,children:[Rm(),Pm(),Lm(),o]})}function Mm(){return De?L===null||ht===void 0||ht===null?ft(Zn,{type:"loading",children:typeof v=="function"?v():v}):L===!1||ht===!1?ft(Zn,{type:"error",children:typeof p=="function"?p():p}):km():ft(Zn,{type:"no-data",children:typeof _=="function"?_():_})}return ft("div",Object.assign({className:Xd(s,l),"data-page-number":De,ref:vm(A,Aa),style:{"--scale-factor":`${nt}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},Tm,{children:Mm()}))}Zv();Nf.workerSrc="pdf.worker.mjs";var Ay=function(h){var t=h.pdfjsWorkerSrc,e=h.classnames,s=h.className,i=h.loading,n=h.width,a=n===void 0?300:n,o=va(rt.useState(h.file),2),l=o[0],c=o[1],d=va(rt.useState(!1),2),u=d[0],p=d[1],g=va(rt.useState(1),2),A=g[0],v=g[1],_=va(rt.useState(1),2),y=_[0],E=_[1],w=va(rt.useState(1),2),S=w[0],x=w[1],C=rt.useRef();rt.useEffect(function(){t&&(Nf.workerSrc=t)},[h.pdfjsWorkerSrc]),rt.useEffect(function(){h.file instanceof ArrayBuffer&&h.file.byteLength>0?c(h.file):c(void 0)},[h.file]);function R(D){var I=D.numPages;p(!0),x(I)}function P(D){var I=A+D;I<=0||I>S||v(I)}function M(D){var I=+D.target.value;if(isNaN(I)||I<=0||I>S){C.current&&(C.current.value=A+"");return}v(I)}function O(D){E(y*D)}function T(){return rt.createElement("div",{className:e("PdfViewer-Loading")},rt.createElement(Nm,null))}function $(){return rt.createElement("div",{className:e("PdfViewer-Tool")},rt.createElement(Ah,{className:"icon",icon:"prev",onClick:function(){return P(-1)}}),rt.createElement(Hm,{className:"page-input",value:A,onBlur:M,ref:C}),rt.createElement("span",{className:"gap"},"/"),rt.createElement("span",null,S),rt.createElement(Ah,{className:"icon",icon:"next",onClick:function(){return P(1)}}),rt.createElement(Ah,{className:"icon",icon:"zoom-in",onClick:function(){return O(1.2)}}),rt.createElement(Ah,{className:"icon",icon:"zoom-out",onClick:function(){return O(.8)}}))}return rt.createElement("div",{className:e(s,"PdfViewer")},!l||i?T():rt.createElement(rt.Fragment,null,rt.createElement("div",{className:e("PdfViewer-Content",{"is-loaded":u})},rt.createElement(ay,{file:l,onLoadSuccess:R,onLoadError:function(D){return console.log(D)},loading:T()},rt.createElement(by,{className:e("PdfViewer-Content-Page"),pageNumber:A,width:a,height:h.height,loading:T(),noData:rt.createElement("div",null,"No PDF data"),scale:y,renderTextLayer:!1,renderAnnotationLayer:!1}))),u?$():null))},wy=Om(Ay);export{wy as default};