var jp=Object.defineProperty;var Sd=h=>{throw TypeError(h)};var Wp=(h,t,e)=>t in h?jp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e;var G=(h,t,e)=>Wp(h,typeof t!="symbol"?t+"":t,e),Nh=(h,t,e)=>t.has(h)||Sd("Cannot "+e);var r=(h,t,e)=>(Nh(h,t,"read from private field"),e?e.call(h):t.get(h)),v=(h,t,e)=>t.has(h)?Sd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(h):t.set(h,e),m=(h,t,e,s)=>(Nh(h,t,"write to private field"),s?s.call(h,e):t.set(h,e),e),b=(h,t,e)=>(Nh(h,t,"access private method"),e);var me=(h,t,e,s)=>({set _(i){m(h,t,i,e)},get _(){return r(h,t,s)}});import{_ as dl,as as zp,r as F,j as P,eZ as ht,aX as yh,ao as Up,ap as $p,a6 as iu,I as St,ac as ul,at as vl,g as Pe,G as Gl,aN as Gp,m as _h,dH as Vp,bc as Vl,y as $h,b as qp,O as Xp,e_ as Yp,A as Kp,a2 as Qp,bb as Jp,aa as Zp,al as tg,dP as eg,b2 as sg,x as ig}from"./index-Bf3Szspx.js";import{p as Gh}from"./events-Bt_4TEL1.js";import{C as ng,W as rg}from"./index-Bq-cDgra.js";import{C as ag}from"./index-CuD4GeMJ.js";import{I as nu}from"./Icon-SjE0NP4G.js";import{P as og}from"./constants-CRQ_PpK1.js";import"./Range-Lr2yBeG-.js";import"./styles-Dn_ABaqt.js";import{g as lg}from"./utils-D4cb70EA.js";import"./qr-event-ndwUpvh-.js";import"./styles--7VhC-7G.js";import"./index-PGYQml4V.js";import"./array-BidGy2xO.js";import"./Actions-CElW33Yu.js";import"./Img-DiMrYU9I.js";import"./styles-B4EP7QEU.js";import"./circle_images-CNsFIm_y.js";import"./hooks-BNxbM_V_.js";import"./SidebarDesktop-DP8AlbVt.js";import"./Box-BF9Usm77.js";import"./styles-B026eHci.js";import"./Alert-DQ-rWV5J.js";import"./IconButton-gBm8Z635.js";import"./styles-KBg8_6X7.js";import"./qr-code-styling-C76dGgmR.js";import"./Add-B7c7DKwf.js";import"./frames-qHk4kRJf.js";var ya={};ya.d=(h,t)=>{for(var e in t)ya.o(t,e)&&!ya.o(h,e)&&Object.defineProperty(h,e,{enumerable:!0,get:t[e]})};ya.o=(h,t)=>Object.prototype.hasOwnProperty.call(h,t);var z=globalThis.pdfjsLib={};ya.d(z,{AbortException:()=>$n,AnnotationEditorLayer:()=>ed,AnnotationEditorParamsType:()=>U,AnnotationEditorType:()=>Z,AnnotationEditorUIManager:()=>Hn,AnnotationLayer:()=>ab,AnnotationMode:()=>hi,CMapCompressionType:()=>qh,ColorPicker:()=>Zl,DOMSVGFactory:()=>ud,DrawLayer:()=>rd,FeatureTest:()=>de,GlobalWorkerOptions:()=>Js,ImageKind:()=>Al,InvalidPDFException:()=>au,MissingPDFException:()=>Un,OPS:()=>je,Outliner:()=>Oc,PDFDataRangeTransport:()=>ef,PDFDateString:()=>fu,PDFWorker:()=>er,PasswordResponses:()=>ug,PermissionFlag:()=>dg,PixelsPerInch:()=>Li,RenderingCancelledException:()=>fd,TextLayer:()=>Ql,UnexpectedResponseException:()=>Sh,Util:()=>H,VerbosityLevel:()=>wh,XfaLayer:()=>nf,build:()=>jm,createValidAbsoluteUrl:()=>mg,fetchData:()=>kh,getDocument:()=>Lm,getFilenameFromUrl:()=>Cg,getPdfFilenameFromUrl:()=>Tg,getXfaPageViewport:()=>Pg,isDataScheme:()=>pd,isPdfFile:()=>gd,noContextMenu:()=>fe,normalizeUnicode:()=>wg,renderTextLayer:()=>wm,setLayerDimensions:()=>Nn,shadow:()=>tt,updateTextLayer:()=>Em,version:()=>Bm});const Jt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ru=[1,0,0,1,0,0],Vh=[.001,0,0,.001,0,0],hg=1e7,Hh=1.35,Oe={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},hi={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},cg="pdfjs_internal_editor_",Z={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},U={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},dg={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},qt={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},Al={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Ct={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},sa={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},wh={ERRORS:0,WARNINGS:1,INFOS:5},qh={NONE:0,BINARY:1},je={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},ug={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Eh=wh.WARNINGS;function fg(h){Number.isInteger(h)&&(Eh=h)}function pg(){return Eh}function xh(h){Eh>=wh.INFOS&&console.log(`Info: ${h}`)}function q(h){Eh>=wh.WARNINGS&&console.log(`Warning: ${h}`)}function at(h){throw new Error(h)}function It(h,t){h||at(t)}function gg(h){switch(h==null?void 0:h.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function mg(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=_g(h)}catch{}}const s=t?new URL(h,t):new URL(h);if(gg(s))return s}catch{}return null}function tt(h,t,e,s=!1){return Object.defineProperty(h,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Di=function(){function t(e,s){this.constructor===t&&at("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class Xh extends Di{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Yh extends Di{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class au extends Di{constructor(t){super(t,"InvalidPDFException")}}class Un extends Di{constructor(t){super(t,"MissingPDFException")}}class Sh extends Di{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class bg extends Di{constructor(t){super(t,"FormatError")}}class $n extends Di{constructor(t){super(t,"AbortException")}}function ou(h){(typeof h!="object"||(h==null?void 0:h.length)===void 0)&&at("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 Ch(h){typeof h!="string"&&at("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 vg(h){return String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,h&255)}function cd(h){const t=Object.create(null);for(const[e,s]of h)t[e]=s;return t}function Ag(){const h=new Uint8Array(4);return h[0]=1,new Uint32Array(h.buffer,0,1)[0]===1}function yg(){try{return new Function(""),!0}catch{return!1}}class de{static get isLittleEndian(){return tt(this,"isLittleEndian",Ag())}static get isEvalSupported(){return tt(this,"isEvalSupported",yg())}static get isOffscreenCanvasSupported(){return tt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?tt(this,"platform",{isMac:navigator.platform.includes("Mac")}):tt(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){var t,e;return tt(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Bh=Array.from(Array(256).keys(),h=>h.toString(16).padStart(2,"0"));var ti,yl,Kh;class H{static makeHexColor(t,e,s){return`#${Bh[t]}${Bh[e]}${Bh[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,ti,Kh).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,ti,Kh).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}}ti=new WeakSet,yl=function(t,e,s,i,n,a,o,l,c,d){if(c<=0||c>=1)return;const u=1-c,f=c*c,p=f*c,g=u*(u*(u*t+3*c*e)+3*f*s)+p*i,A=u*(u*(u*n+3*c*a)+3*f*o)+p*l;d[0]=Math.min(d[0],g),d[1]=Math.min(d[1],A),d[2]=Math.max(d[2],g),d[3]=Math.max(d[3],A)},Kh=function(t,e,s,i,n,a,o,l,c,d,u,f){if(Math.abs(c)<1e-12){Math.abs(d)>=1e-12&&b(this,ti,yl).call(this,t,e,s,i,n,a,o,l,-u/d,f);return}const p=d**2-4*u*c;if(p<0)return;const g=Math.sqrt(p),A=2*c;b(this,ti,yl).call(this,t,e,s,i,n,a,o,l,(-d+g)/A,f),b(this,ti,yl).call(this,t,e,s,i,n,a,o,l,(-d-g)/A,f)},v(H,ti);function _g(h){return decodeURIComponent(escape(h))}let jh=null,Cd=null;function wg(h){return jh||(jh=/([\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,Cd=new Map([["ſt","ſt"]])),h.replaceAll(jh,(t,e,s)=>e?e.normalize("NFKC"):Cd.get(s))}function Eg(){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 ou(h)}const lu="pdfjs_internal_id_",_s={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 Th{constructor(){this.constructor===Th&&at("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){}}var xa;const _d=class _d{constructor({enableHWA:t=!1}={}){v(this,xa,!1);this.constructor===_d&&at("Cannot initialize BaseCanvasFactory."),m(this,xa,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!r(this,xa)})}}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){at("Abstract method `_createCanvas` called.")}};xa=new WeakMap;let ql=_d;class Ph{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===Ph&&at("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?qh.BINARY:qh.NONE;return this._fetchData(e,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){at("Abstract method `_fetchData` called.")}}class Rh{constructor({baseUrl:t=null}){this.constructor===Rh&&at("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){at("Abstract method `_fetchData` called.")}}class dd{constructor(){this.constructor===dd&&at("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){at("Abstract method `_createSVG` called.")}}const Es="http://www.w3.org/2000/svg",Bi=class Bi{};G(Bi,"CSS",96),G(Bi,"PDF",72),G(Bi,"PDF_TO_CSS_UNITS",Bi.CSS/Bi.PDF);let Li=Bi;var Wi,ss,Ps,le,eh,zi,N,Xt,qn,Xn,_l,hu,Qh,Yn,ra,aa,Jh,oa;class xg extends Th{constructor({docId:e,ownerDocument:s=globalThis.document}={}){super();v(this,N);v(this,Wi);v(this,ss);v(this,Ps);v(this,le);v(this,eh);v(this,zi,0);m(this,Ps,e),m(this,le,s)}addFilter(e){if(!e)return"none";let s=r(this,N,Xt).get(e);if(s)return s;const[i,n,a]=b(this,N,_l).call(this,e),o=e.length===1?i:`${i}${n}${a}`;if(s=r(this,N,Xt).get(o),s)return r(this,N,Xt).set(e,s),s;const l=`g_${r(this,Ps)}_transfer_map_${me(this,zi)._++}`,c=`url(#${l})`;r(this,N,Xt).set(e,c),r(this,N,Xt).set(o,c);const d=b(this,N,Yn).call(this,l);return b(this,N,aa).call(this,i,n,a,d),c}addHCMFilter(e,s){var g;const i=`${e}-${s}`,n="base";let a=r(this,N,qn).get(n);if((a==null?void 0:a.key)===i||(a?((g=a.filter)==null||g.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},r(this,N,qn).set(n,a)),!e||!s))return a.url;const o=b(this,N,oa).call(this,e);e=H.makeHexColor(...o);const l=b(this,N,oa).call(this,s);if(s=H.makeHexColor(...l),r(this,N,Xn).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=new Array(256);for(let A=0;A<=255;A++){const _=A/255;c[A]=_<=.03928?_/12.92:((_+.055)/1.055)**2.4}const d=c.join(","),u=`g_${r(this,Ps)}_hcm_filter`,f=a.filter=b(this,N,Yn).call(this,u);b(this,N,aa).call(this,d,d,d,f),b(this,N,Qh).call(this,f);const p=(A,_)=>{const y=o[A]/255,w=l[A]/255,E=new Array(_+1);for(let x=0;x<=_;x++)E[x]=y+x/_*(w-y);return E.join(",")};return b(this,N,aa).call(this,p(0,5),p(1,5),p(2,5),f),a.url=`url(#${u})`,a.url}addAlphaFilter(e){let s=r(this,N,Xt).get(e);if(s)return s;const[i]=b(this,N,_l).call(this,[e]),n=`alpha_${i}`;if(s=r(this,N,Xt).get(n),s)return r(this,N,Xt).set(e,s),s;const a=`g_${r(this,Ps)}_alpha_map_${me(this,zi)._++}`,o=`url(#${a})`;r(this,N,Xt).set(e,o),r(this,N,Xt).set(n,o);const l=b(this,N,Yn).call(this,a);return b(this,N,Jh).call(this,i,l),o}addLuminosityFilter(e){let s=r(this,N,Xt).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=b(this,N,_l).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=r(this,N,Xt).get(n),s)return r(this,N,Xt).set(e,s),s;const a=`g_${r(this,Ps)}_luminosity_map_${me(this,zi)._++}`,o=`url(#${a})`;r(this,N,Xt).set(e,o),r(this,N,Xt).set(n,o);const l=b(this,N,Yn).call(this,a);return b(this,N,hu).call(this,l),e&&b(this,N,Jh).call(this,i,l),o}addHighlightHCMFilter(e,s,i,n,a){var w;const o=`${s}-${i}-${n}-${a}`;let l=r(this,N,qn).get(e);if((l==null?void 0:l.key)===o||(l?((w=l.filter)==null||w.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},r(this,N,qn).set(e,l)),!s||!i))return l.url;const[c,d]=[s,i].map(b(this,N,oa).bind(this));let u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[p,g]=[n,a].map(b(this,N,oa).bind(this));f<u&&([u,f,p,g]=[f,u,g,p]),r(this,N,Xn).style.color="";const A=(E,x,S)=>{const C=new Array(256),T=(f-u)/S,R=E/255,M=(x-E)/(255*S);let B=0;for(let I=0;I<=S;I++){const $=Math.round(u+I*T),V=R+I*M;for(let W=B;W<=$;W++)C[W]=V;B=$+1}for(let I=B;I<256;I++)C[I]=C[B-1];return C.join(",")},_=`g_${r(this,Ps)}_hcm_${e}_filter`,y=l.filter=b(this,N,Yn).call(this,_);return b(this,N,Qh).call(this,y),b(this,N,aa).call(this,A(p[0],g[0],5),A(p[1],g[1],5),A(p[2],g[2],5),y),l.url=`url(#${_})`,l.url}destroy(e=!1){e&&r(this,N,qn).size!==0||(r(this,ss)&&(r(this,ss).parentNode.parentNode.remove(),m(this,ss,null)),r(this,Wi)&&(r(this,Wi).clear(),m(this,Wi,null)),m(this,zi,0))}}Wi=new WeakMap,ss=new WeakMap,Ps=new WeakMap,le=new WeakMap,eh=new WeakMap,zi=new WeakMap,N=new WeakSet,Xt=function(){return r(this,Wi)||m(this,Wi,new Map)},qn=function(){return r(this,eh)||m(this,eh,new Map)},Xn=function(){if(!r(this,ss)){const e=r(this,le).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,le).createElementNS(Es,"svg");i.setAttribute("width",0),i.setAttribute("height",0),m(this,ss,r(this,le).createElementNS(Es,"defs")),e.append(i),i.append(r(this,ss)),r(this,le).body.append(e)}return r(this,ss)},_l=function(e){if(e.length===1){const c=e[0],d=new Array(256);for(let f=0;f<256;f++)d[f]=c[f]/255;const u=d.join(",");return[u,u,u]}const[s,i,n]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let c=0;c<256;c++)a[c]=s[c]/255,o[c]=i[c]/255,l[c]=n[c]/255;return[a.join(","),o.join(","),l.join(",")]},hu=function(e){const s=r(this,le).createElementNS(Es,"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)},Qh=function(e){const s=r(this,le).createElementNS(Es,"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)},Yn=function(e){const s=r(this,le).createElementNS(Es,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),r(this,N,Xn).append(s),s},ra=function(e,s,i){const n=r(this,le).createElementNS(Es,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},aa=function(e,s,i,n){const a=r(this,le).createElementNS(Es,"feComponentTransfer");n.append(a),b(this,N,ra).call(this,a,"feFuncR",e),b(this,N,ra).call(this,a,"feFuncG",s),b(this,N,ra).call(this,a,"feFuncB",i)},Jh=function(e,s){const i=r(this,le).createElementNS(Es,"feComponentTransfer");s.append(i),b(this,N,ra).call(this,i,"feFuncA",e)},oa=function(e){return r(this,N,Xn).style.color=e,md(getComputedStyle(r(this,N,Xn)).getPropertyValue("color"))};class Sg extends ql{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}async function kh(h,t="text"){if(la(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 cu extends Ph{_fetchData(t,e){return kh(t,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):Ch(s),compressionType:e}))}}class du extends Rh{_fetchData(t){return kh(t,"arraybuffer").then(e=>new Uint8Array(e))}}class ud extends dd{_createSVG(t){return document.createElementNS(Es,t)}}class il{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,d,u,f;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,A,_;c===0?(p=Math.abs(l-t[1])*e+i,g=Math.abs(o-t[0])*e+n,A=(t[3]-t[1])*e,_=(t[2]-t[0])*e):(p=Math.abs(o-t[0])*e+i,g=Math.abs(l-t[1])*e+n,A=(t[2]-t[0])*e,_=(t[3]-t[1])*e),this.transform=[c*e,d*e,u*e,f*e,p-c*e*o-u*e*l,g-d*e*o-f*e*l],this.width=A,this.height=_}get rawDims(){const{viewBox:t}=this;return tt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new il({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return H.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=H.applyTransform([t[0],t[1]],this.transform),s=H.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return H.applyInverseTransform([t,e],this.transform)}}class fd extends Di{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function pd(h){const t=h.length;let e=0;for(;e<t&&h[e].trim()==="";)e++;return h.substring(e,e+5).toLowerCase()==="data:"}function gd(h){return typeof h=="string"&&/\.pdf$/i.test(h)}function Cg(h){return[h]=h.split(/[#?]/,1),h.substring(h.lastIndexOf("/")+1)}function Tg(h,t="document.pdf"){if(typeof h!="string")return t;if(pd(h))return q('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 Td{constructor(){G(this,"started",Object.create(null));G(this,"times",[])}time(t){t in this.started&&q(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||q(`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 la(h,t){try{const{protocol:e}=t?new URL(h,t):new URL(h);return e==="http:"||e==="https:"}catch{return!1}}function fe(h){h.preventDefault()}function uu(h){console.log("Deprecated API usage: "+h)}let Pd;class fu{static toDateObject(t){if(!t||typeof t!="string")return null;Pd||(Pd=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=Pd.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 Pg(h,{scale:t=1,rotation:e=0}){const{width:s,height:i}=h.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new il({viewBox:n,scale:t,rotation:e})}function md(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):(q(`Not a valid color format: "${h}"`),[0,0,0])}function Rg(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,md(s))}t.remove()}function mt(h){const{a:t,b:e,c:s,d:i,e:n,f:a}=h.getTransform();return[t,e,s,i,n,a]}function ws(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 Nn(h,t,e=!1,s=!0){if(t instanceof il){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:a}=h,o=de.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${n}px`,d=o?`round(${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 Ui,$i,Ae,Gi,sh,pu,ne,gu,mu,wl,bu,tc;const ih=class ih{constructor(t){v(this,ne);v(this,Ui,null);v(this,$i,null);v(this,Ae);v(this,Gi,null);m(this,Ae,t)}render(){const t=m(this,Ui,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=r(this,Ae)._uiManager._signal;t.addEventListener("contextmenu",fe,{signal:e}),t.addEventListener("pointerdown",b(ih,sh,pu),{signal:e});const s=m(this,Gi,document.createElement("div"));s.className="buttons",t.append(s);const i=r(this,Ae).toolbarPosition;if(i){const{style:n}=t,a=r(this,Ae)._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*a}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return b(this,ne,bu).call(this),t}hide(){var t;r(this,Ui).classList.add("hidden"),(t=r(this,$i))==null||t.hideDropdown()}show(){r(this,Ui).classList.remove("hidden")}addAltTextButton(t){b(this,ne,wl).call(this,t),r(this,Gi).prepend(t,r(this,ne,tc))}addColorPicker(t){m(this,$i,t);const e=t.renderButton();b(this,ne,wl).call(this,e),r(this,Gi).prepend(e,r(this,ne,tc))}remove(){var t;r(this,Ui).remove(),(t=r(this,$i))==null||t.destroy(),m(this,$i,null)}};Ui=new WeakMap,$i=new WeakMap,Ae=new WeakMap,Gi=new WeakMap,sh=new WeakSet,pu=function(t){t.stopPropagation()},ne=new WeakSet,gu=function(t){r(this,Ae)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},mu=function(t){r(this,Ae)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},wl=function(t){const e=r(this,Ae)._uiManager._signal;t.addEventListener("focusin",b(this,ne,gu).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,ne,mu).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",fe,{signal:e})},bu=function(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${r(this,Ae).editorType}-button`),b(this,ne,wl).call(this,t),t.addEventListener("click",e=>{r(this,Ae)._uiManager.delete()},{signal:r(this,Ae)._uiManager._signal}),r(this,Gi).append(t)},tc=function(){const t=document.createElement("div");return t.className="divider",t},v(ih,sh);let Zh=ih;var Sa,Vi,qi,Mi,vu,Au,yu;class kg{constructor(t){v(this,Mi);v(this,Sa,null);v(this,Vi,null);v(this,qi);m(this,qi,t)}show(t,e,s){const[i,n]=b(this,Mi,Au).call(this,e,s),{style:a}=r(this,Vi)||m(this,Vi,b(this,Mi,vu).call(this));t.append(r(this,Vi)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){r(this,Vi).remove()}}Sa=new WeakMap,Vi=new WeakMap,qi=new WeakMap,Mi=new WeakSet,vu=function(){const t=m(this,Vi,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",fe,{signal:r(this,qi)._signal});const e=m(this,Sa,document.createElement("div"));return e.className="buttons",t.append(e),b(this,Mi,yu).call(this),t},Au=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]},yu=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=r(this,qi)._signal;t.addEventListener("contextmenu",fe,{signal:s}),t.addEventListener("click",()=>{r(this,qi).highlightSelection("floating_button")},{signal:s}),r(this,Sa).append(t)};function Xl(h,t,e){for(const s of e)t.addEventListener(s,h[s].bind(h))}function Lg(h){return Math.round(Math.min(255,Math.max(1,255*h))).toString(16).padStart(2,"0")}var nh;class Mg{constructor(){v(this,nh,0)}get id(){return`${cg}${me(this,nh)._++}`}}nh=new WeakMap;var Ca,rh,Me,Ta,sc;const wd=class wd{constructor(){v(this,Ta);v(this,Ca,Eg());v(this,rh,0);v(this,Me,null)}static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return tt(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return b(this,Ta,sc).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return b(this,Ta,sc).call(this,t,t)}async getFromId(t){r(this,Me)||m(this,Me,new Map);const e=r(this,Me).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,Me).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){r(this,Me)||m(this,Me,new Map);const e=r(this,Me).get(t);e&&(e.refCounter-=1,e.refCounter===0&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${r(this,Ca)}_`)}};Ca=new WeakMap,rh=new WeakMap,Me=new WeakMap,Ta=new WeakSet,sc=async function(t,e){r(this,Me)||m(this,Me,new Map);let s=r(this,Me).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,Ca)}_${me(this,rh)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await kh(e,"blob")):i=s.file=e,i.type==="image/svg+xml"){const n=wd._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,Me).set(t,s),s&&r(this,Me).set(s.id,s),s};let ec=wd;var Ot,ci,Pa,Nt;class Ig{constructor(t=128){v(this,Ot,[]);v(this,ci,!1);v(this,Pa);v(this,Nt,-1);m(this,Pa,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),r(this,ci))return;const l={cmd:t,undo:e,post:s,type:n};if(r(this,Nt)===-1){r(this,Ot).length>0&&(r(this,Ot).length=0),m(this,Nt,0),r(this,Ot).push(l);return}if(a&&r(this,Ot)[r(this,Nt)].type===n){o&&(l.undo=r(this,Ot)[r(this,Nt)].undo),r(this,Ot)[r(this,Nt)]=l;return}const c=r(this,Nt)+1;c===r(this,Pa)?r(this,Ot).splice(0,1):(m(this,Nt,c),c<r(this,Ot).length&&r(this,Ot).splice(c)),r(this,Ot).push(l)}undo(){if(r(this,Nt)===-1)return;m(this,ci,!0);const{undo:t,post:e}=r(this,Ot)[r(this,Nt)];t(),e==null||e(),m(this,ci,!1),m(this,Nt,r(this,Nt)-1)}redo(){if(r(this,Nt)<r(this,Ot).length-1){m(this,Nt,r(this,Nt)+1),m(this,ci,!0);const{cmd:t,post:e}=r(this,Ot)[r(this,Nt)];t(),e==null||e(),m(this,ci,!1)}}hasSomethingToUndo(){return r(this,Nt)!==-1}hasSomethingToRedo(){return r(this,Nt)<r(this,Ot).length-1}destroy(){m(this,Ot,null)}}Ot=new WeakMap,ci=new WeakMap,Pa=new WeakMap,Nt=new WeakMap;var ah,_u;class nl{constructor(t){v(this,ah);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=de.platform;for(const[s,i,n={}]of t)for(const a of s){const o=a.startsWith("mac+");e&&o?(this.callbacks.set(a.slice(4),{callback:i,options:n}),this.allKeys.add(a.split("+").at(-1))):!e&&!o&&(this.callbacks.set(a,{callback:i,options:n}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(b(this,ah,_u).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()))}}ah=new WeakSet,_u=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 oh=class oh{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Rg(t),tt(this,"_colors",t)}convert(t){const e=md(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 oh._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?H.makeHexColor(...e):t}};G(oh,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let ic=oh;var nr,ye,Pt,Bt,rr,Rs,ar,We,or,Xi,is,ze,Yi,Ra,ka,ns,lr,di,rs,lh,ui,La,Ki,Ma,hr,jt,it,ks,Qi,Ia,Da,Fa,Oa,Na,Ha,Ba,ja,Wa,za,Ua,$a,Ga,fi,as,Ls,Va,k,El,wu,Eu,xl,xu,Su,Cu,nc,Tu,rc,ac,Pu,te,ai,Ru,ku,oc,Lu,ha,lc;const Zn=class Zn{constructor(t,e,s,i,n,a,o,l,c){v(this,k);v(this,nr,new AbortController);v(this,ye,null);v(this,Pt,new Map);v(this,Bt,new Map);v(this,rr,null);v(this,Rs,null);v(this,ar,null);v(this,We,new Ig);v(this,or,0);v(this,Xi,new Set);v(this,is,null);v(this,ze,null);v(this,Yi,new Set);v(this,Ra,!1);v(this,ka,null);v(this,ns,null);v(this,lr,null);v(this,di,!1);v(this,rs,null);v(this,lh,new Mg);v(this,ui,!1);v(this,La,!1);v(this,Ki,null);v(this,Ma,null);v(this,hr,null);v(this,jt,Z.NONE);v(this,it,new Set);v(this,ks,null);v(this,Qi,null);v(this,Ia,null);v(this,Da,this.blur.bind(this));v(this,Fa,this.focus.bind(this));v(this,Oa,this.copy.bind(this));v(this,Na,this.cut.bind(this));v(this,Ha,this.paste.bind(this));v(this,Ba,this.keydown.bind(this));v(this,ja,this.keyup.bind(this));v(this,Wa,this.onEditingAction.bind(this));v(this,za,this.onPageChanging.bind(this));v(this,Ua,this.onScaleChanging.bind(this));v(this,$a,this.onRotationChanging.bind(this));v(this,Ga,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});v(this,fi,[0,0]);v(this,as,null);v(this,Ls,null);v(this,Va,null);this._signal=r(this,nr).signal,m(this,Ls,t),m(this,Va,e),m(this,rr,s),this._eventBus=i,this._eventBus._on("editingaction",r(this,Wa)),this._eventBus._on("pagechanging",r(this,za)),this._eventBus._on("scalechanging",r(this,Ua)),this._eventBus._on("rotationchanging",r(this,$a)),b(this,k,xu).call(this),b(this,k,Pu).call(this),b(this,k,nc).call(this),m(this,Rs,n.annotationStorage),m(this,ka,n.filterFactory),m(this,Qi,a),m(this,lr,o||null),m(this,Ra,l),m(this,hr,c||null),this.viewParameters={realScale:Li.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=Zn.prototype,e=a=>r(a,Ls).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return tt(this,"_keyboardManager",new nl([[["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,Ls).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,Ls).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}destroy(){var t,e,s;(t=r(this,nr))==null||t.abort(),m(this,nr,null),this._signal=null,this._eventBus._off("editingaction",r(this,Wa)),this._eventBus._off("pagechanging",r(this,za)),this._eventBus._off("scalechanging",r(this,Ua)),this._eventBus._off("rotationchanging",r(this,$a));for(const i of r(this,Bt).values())i.destroy();r(this,Bt).clear(),r(this,Pt).clear(),r(this,Yi).clear(),m(this,ye,null),r(this,it).clear(),r(this,We).destroy(),(e=r(this,rr))==null||e.destroy(),(s=r(this,rs))==null||s.hide(),m(this,rs,null),r(this,ns)&&(clearTimeout(r(this,ns)),m(this,ns,null)),r(this,as)&&(clearTimeout(r(this,as)),m(this,as,null))}async mlGuess(t){var e;return((e=r(this,hr))==null?void 0:e.guess(t))||null}get hasMLManager(){return!!r(this,hr)}get hcmFilter(){return tt(this,"hcmFilter",r(this,Qi)?r(this,ka).addHCMFilter(r(this,Qi).foreground,r(this,Qi).background):"none")}get direction(){return tt(this,"direction",getComputedStyle(r(this,Ls)).direction)}get highlightColors(){return tt(this,"highlightColors",r(this,lr)?new Map(r(this,lr).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return tt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){m(this,Ma,t)}editAltText(t){var e;(e=r(this,rr))==null||e.editAltText(this,t)}onPageChanging({pageNumber:t}){m(this,or,t-1)}focusMainContainer(){r(this,Ls).focus()}findParent(t,e){for(const s of r(this,Bt).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,Va).classList.toggle("noUserSelect",t)}addShouldRescale(t){r(this,Yi).add(t)}removeShouldRescale(t){r(this,Yi).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Li.PDF_TO_CSS_UNITS;for(const e of r(this,Yi))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,k,El).call(this,e).closest(".textLayer"),d=this.getSelectionBoxes(c);if(d){e.empty(),r(this,jt)===Z.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:Z.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const u of r(this,Bt).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,Rs)&&!r(this,Rs).has(t.id)&&r(this,Rs).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,r(this,di)&&(m(this,di,!1),b(this,k,xl).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of r(this,it))if(e.div.contains(t)){m(this,Ki,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!r(this,Ki))return;const[t,e]=r(this,Ki);m(this,Ki,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,k,nc).call(this),b(this,k,rc).call(this)}removeEditListeners(){b(this,k,Tu).call(this),b(this,k,ac).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of r(this,ze))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of r(this,ze))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=r(this,ye))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of r(this,it)){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,ze))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){q(`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,k,oc).call(this,l);b(this,k,lc).call(this,n)},o=()=>{for(const l of n)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(n){q(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),r(this,jt)!==Z.NONE&&!this.isEditorHandlingKeyboard&&Zn._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,r(this,di)&&(m(this,di,!1),b(this,k,xl).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(t){t?(b(this,k,Su).call(this),b(this,k,rc).call(this),b(this,k,te).call(this,{isEditing:r(this,jt)!==Z.NONE,isEmpty:b(this,k,ha).call(this),hasSomethingToUndo:r(this,We).hasSomethingToUndo(),hasSomethingToRedo:r(this,We).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,k,Cu).call(this),b(this,k,ac).call(this),b(this,k,te).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!r(this,ze)){m(this,ze,t);for(const e of r(this,ze))b(this,k,ai).call(this,e.defaultPropertiesToUpdate)}}getId(){return r(this,lh).id}get currentLayer(){return r(this,Bt).get(r(this,or))}getLayer(t){return r(this,Bt).get(t)}get currentPageIndex(){return r(this,or)}addLayer(t){r(this,Bt).set(t.pageIndex,t),r(this,ui)?t.enable():t.disable()}removeLayer(t){r(this,Bt).delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(r(this,jt)!==t){if(m(this,jt,t),t===Z.NONE){this.setEditingState(!1),b(this,k,ku).call(this);return}this.setEditingState(!0),b(this,k,Ru).call(this),this.unselectAll();for(const i of r(this,Bt).values())i.updateMode(t);if(!e&&s){this.addNewEditorFromKeyboard();return}if(e){for(const i of r(this,Pt).values())if(i.annotationElementId===e){this.setSelected(i),i.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==r(this,jt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(r(this,ze)){switch(t){case U.CREATE:this.currentLayer.addNewEditor();return;case U.HIGHLIGHT_DEFAULT_COLOR:(s=r(this,Ma))==null||s.updateColor(e);break;case U.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(r(this,Ia)||m(this,Ia,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of r(this,it))i.updateParams(t,e);for(const i of r(this,ze))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const a of r(this,Pt).values())a.editorType===t&&a.show(e);(((n=r(this,Ia))==null?void 0:n.get(U.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,k,ai).call(this,[[U.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(r(this,La)!==t){m(this,La,t);for(const e of r(this,Bt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of r(this,Pt).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return r(this,Pt).get(t)}addEditor(t){r(this,Pt).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(r(this,ns)&&clearTimeout(r(this,ns)),m(this,ns,setTimeout(()=>{this.focusMainContainer(),m(this,ns,null)},0))),r(this,Pt).delete(t.id),this.unselect(t),(!t.annotationElementId||!r(this,Xi).has(t.annotationElementId))&&((e=r(this,Rs))==null||e.remove(t.id))}addDeletedAnnotationElement(t){r(this,Xi).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return r(this,Xi).has(t)}removeDeletedAnnotationElement(t){r(this,Xi).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){r(this,ye)!==t&&(m(this,ye,t),t&&b(this,k,ai).call(this,t.propertiesToUpdate))}updateUI(t){r(this,k,Lu)===t&&b(this,k,ai).call(this,t.propertiesToUpdate)}toggleSelected(t){if(r(this,it).has(t)){r(this,it).delete(t),t.unselect(),b(this,k,te).call(this,{hasSelectedEditor:this.hasSelection});return}r(this,it).add(t),t.select(),b(this,k,ai).call(this,t.propertiesToUpdate),b(this,k,te).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of r(this,it))e!==t&&e.unselect();r(this,it).clear(),r(this,it).add(t),t.select(),b(this,k,ai).call(this,t.propertiesToUpdate),b(this,k,te).call(this,{hasSelectedEditor:!0})}isSelected(t){return r(this,it).has(t)}get firstSelectedEditor(){return r(this,it).values().next().value}unselect(t){t.unselect(),r(this,it).delete(t),b(this,k,te).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return r(this,it).size!==0}get isEnterHandled(){return r(this,it).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){r(this,We).undo(),b(this,k,te).call(this,{hasSomethingToUndo:r(this,We).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,k,ha).call(this)})}redo(){r(this,We).redo(),b(this,k,te).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:r(this,We).hasSomethingToRedo(),isEmpty:b(this,k,ha).call(this)})}addCommands(t){r(this,We).add(t),b(this,k,te).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,k,ha).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...r(this,it)],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)b(this,k,oc).call(this,i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){var t;(t=r(this,ye))==null||t.commitOrRemove()}hasSomethingToControl(){return r(this,ye)||this.hasSelection}selectAll(){for(const t of r(this,it))t.commit();b(this,k,lc).call(this,r(this,Pt).values())}unselectAll(){if(!(r(this,ye)&&(r(this,ye).commitOrRemove(),r(this,jt)!==Z.NONE))&&this.hasSelection){for(const t of r(this,it))t.unselect();r(this,it).clear(),b(this,k,te).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;r(this,fi)[0]+=t,r(this,fi)[1]+=e;const[i,n]=r(this,fi),a=[...r(this,it)],o=1e3;r(this,as)&&clearTimeout(r(this,as)),m(this,as,setTimeout(()=>{m(this,as,null),r(this,fi)[0]=r(this,fi)[1]=0,this.addCommands({cmd:()=>{for(const l of a)r(this,Pt).has(l.id)&&l.translateInPage(i,n)},undo:()=>{for(const l of a)r(this,Pt).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,is,new Map);for(const t of r(this,it))r(this,is).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!r(this,is))return!1;this.disableUserSelect(!1);const t=r(this,is);m(this,is,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,Pt).has(i.id)){const l=r(this,Bt).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,is))for(const s of r(this,is).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,it).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return r(this,ye)===t}getActive(){return r(this,ye)}getMode(){return r(this,jt)}get imageManager(){return tt(this,"imageManager",new ec)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,d=e.rangeCount;c<d;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(c,d,u,f)=>({x:(d-i)/a,y:1-(c+u-s)/n,width:f/a,height:u/n});break;case"180":o=(c,d,u,f)=>({x:1-(c+u-s)/n,y:1-(d+f-i)/a,width:u/n,height:f/a});break;case"270":o=(c,d,u,f)=>({x:1-(d+f-i)/a,y:(c-s)/n,width:f/a,height:u/n});break;default:o=(c,d,u,f)=>({x:(c-s)/n,y:(d-i)/a,width:u/n,height:f/a});break}const l=[];for(let c=0,d=e.rangeCount;c<d;c++){const u=e.getRangeAt(c);if(!u.collapsed)for(const{x:f,y:p,width:g,height:A}of u.getClientRects())g===0||A===0||l.push(o(f,p,g,A))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(r(this,ar)||m(this,ar,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=r(this,ar))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=r(this,ar))==null?void 0:i.get(t.data.id);if(!e)return;const s=r(this,Rs).getRawValue(e);s&&(r(this,jt)===Z.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}};nr=new WeakMap,ye=new WeakMap,Pt=new WeakMap,Bt=new WeakMap,rr=new WeakMap,Rs=new WeakMap,ar=new WeakMap,We=new WeakMap,or=new WeakMap,Xi=new WeakMap,is=new WeakMap,ze=new WeakMap,Yi=new WeakMap,Ra=new WeakMap,ka=new WeakMap,ns=new WeakMap,lr=new WeakMap,di=new WeakMap,rs=new WeakMap,lh=new WeakMap,ui=new WeakMap,La=new WeakMap,Ki=new WeakMap,Ma=new WeakMap,hr=new WeakMap,jt=new WeakMap,it=new WeakMap,ks=new WeakMap,Qi=new WeakMap,Ia=new WeakMap,Da=new WeakMap,Fa=new WeakMap,Oa=new WeakMap,Na=new WeakMap,Ha=new WeakMap,Ba=new WeakMap,ja=new WeakMap,Wa=new WeakMap,za=new WeakMap,Ua=new WeakMap,$a=new WeakMap,Ga=new WeakMap,fi=new WeakMap,as=new WeakMap,Ls=new WeakMap,Va=new WeakMap,k=new WeakSet,El=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},wu=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,k,El).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(r(this,rs)||m(this,rs,new kg(this)),r(this,rs).show(s,i,this.direction==="ltr"))},Eu=function(){var n,a,o;const t=document.getSelection();if(!t||t.isCollapsed){r(this,ks)&&((n=r(this,rs))==null||n.hide(),m(this,ks,null),b(this,k,te).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===r(this,ks))return;if(!b(this,k,El).call(this,t).closest(".textLayer")){r(this,ks)&&((a=r(this,rs))==null||a.hide(),m(this,ks,null),b(this,k,te).call(this,{hasSelectedText:!1}));return}if((o=r(this,rs))==null||o.hide(),m(this,ks,e),b(this,k,te).call(this,{hasSelectedText:!0}),!(r(this,jt)!==Z.HIGHLIGHT&&r(this,jt)!==Z.NONE)&&(r(this,jt)===Z.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),m(this,di,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=this._signal,c=d=>{d.type==="pointerup"&&d.button!==0||(window.removeEventListener("pointerup",c),window.removeEventListener("blur",c),d.type==="pointerup"&&b(this,k,xl).call(this,"main_toolbar"))};window.addEventListener("pointerup",c,{signal:l}),window.addEventListener("blur",c,{signal:l})}},xl=function(t=""){r(this,jt)===Z.HIGHLIGHT?this.highlightSelection(t):r(this,Ra)&&b(this,k,wu).call(this)},xu=function(){document.addEventListener("selectionchange",b(this,k,Eu).bind(this),{signal:this._signal})},Su=function(){const t=this._signal;window.addEventListener("focus",r(this,Fa),{signal:t}),window.addEventListener("blur",r(this,Da),{signal:t})},Cu=function(){window.removeEventListener("focus",r(this,Fa)),window.removeEventListener("blur",r(this,Da))},nc=function(){const t=this._signal;window.addEventListener("keydown",r(this,Ba),{signal:t}),window.addEventListener("keyup",r(this,ja),{signal:t})},Tu=function(){window.removeEventListener("keydown",r(this,Ba)),window.removeEventListener("keyup",r(this,ja))},rc=function(){const t=this._signal;document.addEventListener("copy",r(this,Oa),{signal:t}),document.addEventListener("cut",r(this,Na),{signal:t}),document.addEventListener("paste",r(this,Ha),{signal:t})},ac=function(){document.removeEventListener("copy",r(this,Oa)),document.removeEventListener("cut",r(this,Na)),document.removeEventListener("paste",r(this,Ha))},Pu=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},te=function(t){Object.entries(t).some(([s,i])=>r(this,Ga)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(r(this,Ga),t)}),r(this,jt)===Z.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,k,ai).call(this,[[U.HIGHLIGHT_FREE,!0]]))},ai=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Ru=function(){if(!r(this,ui)){m(this,ui,!0);for(const t of r(this,Bt).values())t.enable();for(const t of r(this,Pt).values())t.enable()}},ku=function(){if(this.unselectAll(),r(this,ui)){m(this,ui,!1);for(const t of r(this,Bt).values())t.disable();for(const t of r(this,Pt).values())t.disable()}},oc=function(t){const e=r(this,Bt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Lu=function(){let t=null;for(t of r(this,it));return t},ha=function(){if(r(this,Pt).size===0)return!0;if(r(this,Pt).size===1)for(const t of r(this,Pt).values())return t.isEmpty();return!1},lc=function(t){for(const e of r(this,it))e.unselect();r(this,it).clear();for(const e of t)e.isEmpty()||(r(this,it).add(e),e.select());b(this,k,te).call(this,{hasSelectedEditor:this.hasSelection})},G(Zn,"TRANSLATE_SMALL",1),G(Zn,"TRANSLATE_BIG",10);let Hn=Zn;var Ms,Is,Ue,Ds,_e,cr,$e,qa,hc;const xs=class xs{constructor(t){v(this,qa);v(this,Ms,"");v(this,Is,!1);v(this,Ue,null);v(this,Ds,null);v(this,_e,null);v(this,cr,!1);v(this,$e,null);m(this,$e,t)}static initialize(t){xs._l10nPromise||(xs._l10nPromise=t)}async render(){const t=m(this,Ue,document.createElement("button"));t.className="altText";const e=await xs._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";const s=r(this,$e)._uiManager._signal;t.addEventListener("contextmenu",fe,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),r(this,$e)._uiManager.editAltText(r(this,$e))};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(m(this,cr,!0),i(n))},{signal:s}),await b(this,qa,hc).call(this),t}finish(){r(this,Ue)&&(r(this,Ue).focus({focusVisible:r(this,cr)}),m(this,cr,!1))}isEmpty(){return!r(this,Ms)&&!r(this,Is)}get data(){return{altText:r(this,Ms),decorative:r(this,Is)}}set data({altText:t,decorative:e}){r(this,Ms)===t&&r(this,Is)===e||(m(this,Ms,t),m(this,Is,e),b(this,qa,hc).call(this))}toggle(t=!1){r(this,Ue)&&(!t&&r(this,_e)&&(clearTimeout(r(this,_e)),m(this,_e,null)),r(this,Ue).disabled=!t)}destroy(){var t;(t=r(this,Ue))==null||t.remove(),m(this,Ue,null),m(this,Ds,null)}};Ms=new WeakMap,Is=new WeakMap,Ue=new WeakMap,Ds=new WeakMap,_e=new WeakMap,cr=new WeakMap,$e=new WeakMap,qa=new WeakSet,hc=async function(){var i;const t=r(this,Ue);if(!t)return;if(!r(this,Ms)&&!r(this,Is)){t.classList.remove("done"),(i=r(this,Ds))==null||i.remove();return}t.classList.add("done"),xs._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(n=>{t.setAttribute("aria-label",n)});let e=r(this,Ds);if(!e){m(this,Ds,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip");const n=e.id=`alt-text-tooltip-${r(this,$e).id}`;t.setAttribute("aria-describedby",n);const a=100,o=r(this,$e)._uiManager._signal;o.addEventListener("abort",()=>{clearTimeout(r(this,_e)),m(this,_e,null)},{once:!0}),t.addEventListener("mouseenter",()=>{m(this,_e,setTimeout(()=>{m(this,_e,null),r(this,Ds).classList.add("show"),r(this,$e)._reportTelemetry({action:"alt_text_tooltip"})},a))},{signal:o}),t.addEventListener("mouseleave",()=>{var l;r(this,_e)&&(clearTimeout(r(this,_e)),m(this,_e,null)),(l=r(this,Ds))==null||l.classList.remove("show")},{signal:o})}e.innerText=r(this,Is)?await xs._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):r(this,Ms),e.parentNode||t.append(e);const s=r(this,$e).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},G(xs,"_l10nPromise",null);let Yl=xs;var Ji,Ge,Yt,dr,Zi,Wt,tn,ur,fr,Kt,Xa,en,pi,Ya,sn,Fs,os,pr,gr,Ie,Ka,hh,Y,cc,Qa,dc,uc,Mu,Iu,fc,pc,gc,Du,Fu,Ou,Nu,mc,ca;const lt=class lt{constructor(t){v(this,Y);v(this,Ji,null);v(this,Ge,null);v(this,Yt,null);v(this,dr,!1);v(this,Zi,!1);v(this,Wt,null);v(this,tn,null);v(this,ur,this.focusin.bind(this));v(this,fr,this.focusout.bind(this));v(this,Kt,null);v(this,Xa,"");v(this,en,!1);v(this,pi,null);v(this,Ya,!1);v(this,sn,!1);v(this,Fs,!1);v(this,os,null);v(this,pr,0);v(this,gr,0);v(this,Ie,null);G(this,"_initialOptions",Object.create(null));G(this,"_isVisible",!0);G(this,"_uiManager",null);G(this,"_focusEventsAllowed",!0);G(this,"_l10nPromise",null);v(this,Ka,!1);v(this,hh,lt._zIndex++);this.constructor===lt&&at("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=lt.prototype._resizeWithKeyboard,e=Hn.TRANSLATE_SMALL,s=Hn.TRANSLATE_BIG;return tt(this,"_resizerKeyboardManager",new nl([[["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"],lt.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return tt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Dg({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(lt._l10nPromise||(lt._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)lt._l10nPromise.set(n,t.get(n));if(lt._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);lt._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){at("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return r(this,Ka)}set _isDraggable(t){var e;m(this,Ka,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,hh)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):b(this,Y,ca).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(r(this,en)?m(this,en,!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,Y,cc).call(this,this.parentDimensions,t,e)}translateInPage(t,e){r(this,pi)||m(this,pi,[this.x,this.y]),b(this,Y,cc).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){r(this,pi)||m(this,pi,[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,pi)&&(r(this,pi)[0]!==this.x||r(this,pi)[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=lt,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=lt,Qa,dc).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=lt,Qa,dc).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 de.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,Zi)||(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,Zi)&&e.endsWith("%");if(i&&n)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!r(this,Zi)&&!n&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=r(this,Yt))==null||t.finish()}async addEditToolbar(){return r(this,Kt)||r(this,sn)?r(this,Kt):(m(this,Kt,new Zh(this)),this.div.append(r(this,Kt).render()),r(this,Yt)&&r(this,Kt).addAltTextButton(await r(this,Yt).render()),r(this,Kt))}removeEditToolbar(){var t;r(this,Kt)&&(r(this,Kt).remove(),m(this,Kt,null),(t=r(this,Yt))==null||t.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){r(this,Yt)||(Yl.initialize(lt._l10nPromise),m(this,Yt,new Yl(this)),r(this,Ji)&&(r(this,Yt).data=r(this,Ji),m(this,Ji,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=r(this,Yt))==null?void 0:t.data}set altTextData(t){r(this,Yt)&&(r(this,Yt).data=t)}hasAltText(){var t;return!((t=r(this,Yt))!=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();const t=this._uiManager._signal;this.div.addEventListener("focusin",r(this,ur),{signal:t}),this.div.addEventListener("focusout",r(this,fr),{signal:t});const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*s/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),Xl(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=de.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(m(this,en,!0),this._isDraggable){b(this,Y,Du).call(this,t);return}b(this,Y,gc).call(this,t)}moveInDOM(){r(this,os)&&clearTimeout(r(this,os)),m(this,os,setTimeout(()=>{var t;m(this,os,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,a]=this.pageDimensions,[o,l]=this.pageTranslation,c=t/i,d=e/i,u=this.x*n,f=this.y*a,p=this.width*n,g=this.height*a;switch(s){case 0:return[u+c+o,a-f-d-g+l,u+c+p+o,a-f-d+l];case 90:return[u+d+o,a-f+c+l,u+d+g+o,a-f+c+p+l];case 180:return[u-c-p+o,a-f+d+l,u-c+o,a-f+d+g+l];case 270:return[u-d-g+o,a-f-c-p+l,u-d+o,a-f-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,o=n-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[n,e-i,o,l];case 270:return[n,e-a,l,o];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){m(this,sn,!0)}disableEditMode(){m(this,sn,!1)}isInEditMode(){return r(this,sn)}shouldGetKeyboardEvents(){return r(this,Fs)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var e,s;const t=this._uiManager._signal;(e=this.div)==null||e.addEventListener("focusin",r(this,ur),{signal:t}),(s=this.div)==null||s.addEventListener("focusout",r(this,fr),{signal:t})}rotate(t){}serialize(t=!1,e=null){at("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,m(i,Ji,t.accessibilityData);const[n,a]=i.pageDimensions,[o,l,c,d]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/n,i.y=l/a,i.width=c/n,i.height=d/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){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,os)&&(clearTimeout(r(this,os)),m(this,os,null)),b(this,Y,ca).call(this),this.removeEditToolbar(),r(this,Ie)){for(const t of r(this,Ie).values())clearTimeout(t);m(this,Ie,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,Y,Mu).call(this),r(this,Wt).classList.remove("hidden"),Xl(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,tn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=r(this,Wt).children;if(!r(this,Ge)){m(this,Ge,Array.from(e));const a=b(this,Y,Fu).bind(this),o=b(this,Y,Ou).bind(this),l=this._uiManager._signal;for(const c of r(this,Ge)){const d=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",a,{signal:l}),c.addEventListener("blur",o,{signal:l}),c.addEventListener("focus",b(this,Y,Nu).bind(this,d),{signal:l}),lt._l10nPromise.get(`pdfjs-editor-resizer-label-${d}`).then(u=>c.setAttribute("aria-label",u))}}const s=r(this,Ge)[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,Ge).length/4);if(n!==i){if(n<i)for(let o=0;o<i-n;o++)r(this,Wt).append(r(this,Wt).firstChild);else if(n>i)for(let o=0;o<n-i;o++)r(this,Wt).firstChild.before(r(this,Wt).lastChild);let a=0;for(const o of e){const c=r(this,Ge)[a++].getAttribute("data-resizer-name");lt._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(d=>o.setAttribute("aria-label",d))}}b(this,Y,mc).call(this,0),m(this,Fs,!0),r(this,Wt).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){r(this,Fs)&&b(this,Y,pc).call(this,r(this,Xa),{movementX:t,movementY:e})}_stopResizingWithKeyboard(){b(this,Y,ca).call(this),this.div.focus()}select(){var t,e;if(this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!r(this,Kt)){this.addEditToolbar().then(()=>{var s,i;(s=this.div)!=null&&s.classList.contains("selectedEditor")&&((i=r(this,Kt))==null||i.show())});return}(e=r(this,Kt))==null||e.show()}unselect(){var t,e,s,i;(t=r(this,Wt))==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,Kt))==null||i.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return r(this,Ya)}set isEditing(t){m(this,Ya,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){m(this,Zi,!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,Ie)||m(this,Ie,new Map);const{action:s}=t;let i=r(this,Ie).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),r(this,Ie).delete(s),r(this,Ie).size===0&&m(this,Ie,null)},lt._telemetryTimeout),r(this,Ie).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()}};Ji=new WeakMap,Ge=new WeakMap,Yt=new WeakMap,dr=new WeakMap,Zi=new WeakMap,Wt=new WeakMap,tn=new WeakMap,ur=new WeakMap,fr=new WeakMap,Kt=new WeakMap,Xa=new WeakMap,en=new WeakMap,pi=new WeakMap,Ya=new WeakMap,sn=new WeakMap,Fs=new WeakMap,os=new WeakMap,pr=new WeakMap,gr=new WeakMap,Ie=new WeakMap,Ka=new WeakMap,hh=new WeakMap,Y=new WeakSet,cc=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()},Qa=new WeakSet,dc=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]}},uc=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]}},Mu=function(){if(r(this,Wt))return;m(this,Wt,document.createElement("div")),r(this,Wt).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");r(this,Wt).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,Y,Iu).bind(this,s),{signal:e}),i.addEventListener("contextmenu",fe,{signal:e}),i.tabIndex=-1}this.div.prepend(r(this,Wt))},Iu=function(t,e){var A;e.preventDefault();const{isMac:s}=de.platform;if(e.button!==0||e.ctrlKey&&s)return;(A=r(this,Yt))==null||A.toggle(!1);const i=b(this,Y,pc).bind(this,t),n=this._isDraggable;this._isDraggable=!1;const a=this._uiManager._signal,o={passive:!0,capture:!0,signal:a};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,o),window.addEventListener("contextmenu",fe,{signal:a});const l=this.x,c=this.y,d=this.width,u=this.height,f=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 _;this.parent.togglePointerEvents(!0),(_=r(this,Yt))==null||_.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",i,o),window.removeEventListener("contextmenu",fe),this.parent.div.style.cursor=f,this.div.style.cursor=p,b(this,Y,fc).call(this,l,c,d,u)};window.addEventListener("pointerup",g,{signal:a}),window.addEventListener("blur",g,{signal:a})},fc=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})},pc=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,o=this.width,l=this.height,c=lt.MIN_SIZE/s,d=lt.MIN_SIZE/i,u=D=>Math.round(D*1e4)/1e4,f=b(this,Y,uc).call(this,this.rotation),p=(D,O)=>[f[0]*D+f[2]*O,f[1]*D+f[3]*O],g=b(this,Y,uc).call(this,360-this.rotation),A=(D,O)=>[g[0]*D+g[2]*O,g[1]*D+g[3]*O];let _,y,w=!1,E=!1;switch(t){case"topLeft":w=!0,_=(D,O)=>[0,0],y=(D,O)=>[D,O];break;case"topMiddle":_=(D,O)=>[D/2,0],y=(D,O)=>[D/2,O];break;case"topRight":w=!0,_=(D,O)=>[D,0],y=(D,O)=>[0,O];break;case"middleRight":E=!0,_=(D,O)=>[D,O/2],y=(D,O)=>[0,O/2];break;case"bottomRight":w=!0,_=(D,O)=>[D,O],y=(D,O)=>[0,0];break;case"bottomMiddle":_=(D,O)=>[D/2,O],y=(D,O)=>[D/2,0];break;case"bottomLeft":w=!0,_=(D,O)=>[0,O],y=(D,O)=>[D,0];break;case"middleLeft":E=!0,_=(D,O)=>[0,O/2],y=(D,O)=>[D,O/2];break}const x=_(o,l),S=y(o,l);let C=p(...S);const T=u(n+C[0]),R=u(a+C[1]);let M=1,B=1,[I,$]=this.screenToPageTranslation(e.movementX,e.movementY);if([I,$]=A(I/s,$/i),w){const D=Math.hypot(o,l);M=B=Math.max(Math.min(Math.hypot(S[0]-x[0]-I,S[1]-x[1]-$)/D,1/o,1/l),c/o,d/l)}else E?M=Math.max(c,Math.min(1,Math.abs(S[0]-x[0]-I)))/o:B=Math.max(d,Math.min(1,Math.abs(S[1]-x[1]-$)))/l;const V=u(o*M),W=u(l*B);C=p(...y(V,W));const X=T-C[0],Q=R-C[1];this.width=V,this.height=W,this.x=X,this.y=Q,this.setDims(s*V,i*W),this.fixAndSetPosition()},gc=function(t){const{isMac:e}=de.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Du=function(t){const e=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let s,i;const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),s={passive:!0,capture:!0,signal:n},m(this,pr,t.clientX),m(this,gr,t.clientY),i=o=>{const{clientX:l,clientY:c}=o,[d,u]=this.screenToPageTranslation(l-r(this,pr),c-r(this,gr));m(this,pr,l),m(this,gr,c),this._uiManager.dragSelectedEditors(d,u)},window.addEventListener("pointermove",i,s));const a=()=>{window.removeEventListener("pointerup",a),window.removeEventListener("blur",a),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),m(this,en,!1),this._uiManager.endDragSession()||b(this,Y,gc).call(this,t)};window.addEventListener("pointerup",a,{signal:n}),window.addEventListener("blur",a,{signal:n})},Fu=function(t){lt._resizerKeyboardManager.exec(this,t)},Ou=function(t){var e;r(this,Fs)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==r(this,Wt)&&b(this,Y,ca).call(this)},Nu=function(t){m(this,Xa,r(this,Fs)?t:"")},mc=function(t){if(r(this,Ge))for(const e of r(this,Ge))e.tabIndex=t},ca=function(){if(m(this,Fs,!1),b(this,Y,mc).call(this,-1),r(this,tn)){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=r(this,tn);b(this,Y,fc).call(this,t,e,s,i),m(this,tn,null)}},v(lt,Qa),G(lt,"_borderLineWidth",-1),G(lt,"_colorManager",new ic),G(lt,"_zIndex",1),G(lt,"_telemetryTimeout",1e3);let nt=lt;class Dg extends nt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const Rd=3285377520,Le=4294901760,es=65535;class Hu{constructor(t){this.h1=t?t&4294967295:Rd,this.h2=t?t&4294967295:Rd}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let A=0,_=t.length;A<_;A++){const y=t.charCodeAt(A);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,f=461845907,p=u&es,g=f&es;for(let A=0;A<i;A++)A&1?(o=a[A],o=o*u&Le|o*p&es,o=o<<15|o>>>17,o=o*f&Le|o*g&es,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[A],l=l*u&Le|l*p&es,l=l<<15|l>>>17,l=l*f&Le|l*g&es,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&Le|o*p&es,o=o<<15|o>>>17,o=o*f&Le|o*g&es,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&Le|t*36045&es,e=e*4283543511&Le|((e<<16|t>>>16)*2950163797&Le)>>>16,t^=e>>>1,t=t*444984403&Le|t*60499&es,e=e*3301882366&Le|((e<<16|t>>>16)*3120437893&Le)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const bc=Object.freeze({map:null,hash:"",transfer:void 0});var nn,zt,ch,Bu;class bd{constructor(){v(this,ch);v(this,nn,!1);v(this,zt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=r(this,zt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return r(this,zt).get(t)}remove(t){if(r(this,zt).delete(t),r(this,zt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of r(this,zt).values())if(e instanceof nt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=r(this,zt).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,zt).set(t,e);i&&b(this,ch,Bu).call(this),e instanceof nt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return r(this,zt).has(t)}getAll(){return r(this,zt).size>0?cd(r(this,zt)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return r(this,zt).size}resetModified(){r(this,nn)&&(m(this,nn,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new ju(this)}get serializable(){if(r(this,zt).size===0)return bc;const t=new Map,e=new Hu,s=[],i=Object.create(null);let n=!1;for(const[a,o]of r(this,zt)){const l=o instanceof nt?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}:bc}get editorStats(){let t=null;const e=new Map;for(const s of r(this,zt).values()){if(!(s instanceof nt))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}}nn=new WeakMap,zt=new WeakMap,ch=new WeakSet,Bu=function(){r(this,nn)||(m(this,nn,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Ja;class ju extends bd{constructor(e){super();v(this,Ja);const{map:s,hash:i,transfer:n}=e.serializable,a=structuredClone(s,n?{transfer:n}:null);m(this,Ja,{map:a,hash:i,transfer:n})}get print(){at("Should not call PrintAnnotationStorage.print")}get serializable(){return r(this,Ja)}}Ja=new WeakMap;var mr;class Fg{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){v(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(It(!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{q(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}at("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 q(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return tt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(Jt||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),tt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(It(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return tt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(x,S){return x.charCodeAt(S)<<24|x.charCodeAt(S+1)<<16|x.charCodeAt(S+2)<<8|x.charCodeAt(S+3)&255}function i(x,S,C,T){const R=x.substring(0,S),M=x.substring(S+C);return R+T+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(x,S){if(++c>30){q("Load test font never loaded."),S();return}if(l.font="30px "+x,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){S();return}setTimeout(d.bind(null,x,S))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,u.length,u);const g=16,A=1482184792;let _=s(f,g);for(n=0,a=u.length-3;n<a;n+=4)_=_-A+s(u,n)|0;n<u.length&&(_=_-A+s(u+"XXX",n)|0),f=i(f,g,4,vg(_));const y=`url(data:font/opentype;base64,${btoa(f)});`,w=`@font-face {font-family:"${u}";src:${y}}`;this.insertRule(w);const E=this._document.createElement("div");E.style.visibility="hidden",E.style.width=E.style.height="10px",E.style.position="absolute",E.style.top=E.style.left="0px";for(const x of[t.loadedName,u]){const S=this._document.createElement("span");S.textContent="Hi",S.style.fontFamily=x,E.append(S)}this._document.body.append(E),d(u,()=>{E.remove(),e.complete()})}}mr=new WeakMap;class Og{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=ou(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){q(`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 _s.BEZIER_CURVE_TO:{const[o,l,c,d,u,f]=s.slice(n,n+6);i.push(p=>p.bezierCurveTo(o,l,c,d,u,f)),n+=6}break;case _s.MOVE_TO:{const[o,l]=s.slice(n,n+2);i.push(c=>c.moveTo(o,l)),n+=2}break;case _s.LINE_TO:{const[o,l]=s.slice(n,n+2);i.push(c=>c.lineTo(o,l)),n+=2}break;case _s.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 _s.RESTORE:i.push(o=>o.restore());break;case _s.SAVE:i.push(o=>o.save());break;case _s.SCALE:It(i.length===2,"Scale command is only valid at the third position.");break;case _s.TRANSFORM:{const[o,l,c,d,u,f]=s.slice(n,n+6);i.push(p=>p.transform(o,l,c,d,u,f)),n+=6}break;case _s.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(Jt){var vc=Promise.withResolvers(),_a=null;(async()=>{const t=await dl(()=>import("./index-Bf3Szspx.js").then(o=>o.gl),[]),e=await dl(()=>import("./index-Bf3Szspx.js").then(o=>o.gl),[]),s=await dl(()=>import("./index-Bf3Szspx.js").then(o=>o.gl),[]),i=await dl(()=>import("./index-Bf3Szspx.js").then(o=>o.gl),[]);let n,a;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:a}))})().then(t=>{_a=t,vc.resolve()},t=>{q(`loadPackages: ${t}`),_a=new Map,vc.resolve()})}class ys{static get promise(){return vc.promise}static get(t){return _a==null?void 0:_a.get(t)}}const Wu=function(h){return ys.get("fs").promises.readFile(h).then(e=>new Uint8Array(e))};class Ng extends Th{}class Hg extends ql{_createCanvas(t,e){return ys.get("canvas").createCanvas(t,e)}}class Bg extends Ph{_fetchData(t,e){return Wu(t).then(s=>({cMapData:s,compressionType:e}))}}class jg extends Rh{_fetchData(t){return Wu(t)}}const ie={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Ac(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 rl{constructor(){this.constructor===rl&&at("Cannot initialize BaseShadingPattern.")}getPattern(){at("Abstract method `getPattern` called.")}}class Wg extends rl{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===ie.STROKE||i===ie.FILL){const a=e.current.getClippedPathBoundingBox(i,mt(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=H.transform(s,[1,0,0,1,a[0],a[1]]),d.transform(...e.baseTransform),this.matrix&&d.transform(...this.matrix),Ac(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 Ac(t,this._bbox),n=this._createGradient(t);return n}}function Wh(h,t,e,s,i,n,a,o){const l=t.coords,c=t.colors,d=h.data,u=h.width*4;let f;l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=n,n=a,a=f),l[s+1]>l[i+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=n,n=a,a=f);const p=(l[e]+t.offsetX)*t.scaleX,g=(l[e+1]+t.offsetY)*t.scaleY,A=(l[s]+t.offsetX)*t.scaleX,_=(l[s+1]+t.offsetY)*t.scaleY,y=(l[i]+t.offsetX)*t.scaleX,w=(l[i+1]+t.offsetY)*t.scaleY;if(g>=w)return;const E=c[n],x=c[n+1],S=c[n+2],C=c[a],T=c[a+1],R=c[a+2],M=c[o],B=c[o+1],I=c[o+2],$=Math.round(g),V=Math.round(w);let W,X,Q,D,O,pe,Re,ni;for(let At=$;At<=V;At++){if(At<_){const ft=At<g?0:(g-At)/(g-_);W=p-(p-A)*ft,X=E-(E-C)*ft,Q=x-(x-T)*ft,D=S-(S-R)*ft}else{let ft;At>w?ft=1:_===w?ft=0:ft=(_-At)/(_-w),W=A-(A-y)*ft,X=C-(C-M)*ft,Q=T-(T-B)*ft,D=R-(R-I)*ft}let pt;At<g?pt=0:At>w?pt=1:pt=(g-At)/(g-w),O=p-(p-y)*pt,pe=E-(E-M)*pt,Re=x-(x-B)*pt,ni=S-(S-I)*pt;const ke=Math.round(Math.min(W,O)),ge=Math.round(Math.max(W,O));let Zt=u*At+ke*4;for(let ft=ke;ft<=ge;ft++)pt=(W-ft)/(W-O),pt<0?pt=0:pt>1&&(pt=1),d[Zt++]=X-(X-pe)*pt|0,d[Zt++]=Q-(Q-Re)*pt|0,d[Zt++]=D-(D-ni)*pt|0,d[Zt++]=255}}function zg(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++)Wh(h,e,s[d],s[d+1],s[d+o],i[d],i[d+1],i[d+o]),Wh(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)Wh(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 Ug extends rl{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,d=Math.ceil(this._bounds[3])-l,u=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(d*t[1]*1.1)),3e3),p=c/u,g=d/f,A={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/p,scaleY:1/g},_=u+2*2,y=f+2*2,w=s.getCanvas("mesh",_,y,!1),E=w.context,x=E.createImageData(u,f);if(e){const C=x.data;for(let T=0,R=C.length;T<R;T+=4)C[T]=e[0],C[T+1]=e[1],C[T+2]=e[2],C[T+3]=255}for(const C of this._figures)zg(x,C,A);return E.putImageData(x,2,2),{canvas:w.canvas,offsetX:o-2*p,offsetY:l-2*g,scaleX:p,scaleY:g}}getPattern(t,e,s,i){Ac(t,this._bbox);let n;if(i===ie.SHADING)n=H.singularValueDecompose2dScale(mt(t));else if(n=H.singularValueDecompose2dScale(e.baseTransform),this.matrix){const o=H.singularValueDecompose2dScale(this.matrix);n=[n[0]*o[0],n[1]*o[1]]}const a=this._createMeshCanvas(n,i===ie.SHADING?null:this._background,e.cachedCanvases);return i!==ie.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 $g extends rl{getPattern(){return"hotpink"}}function Gg(h){switch(h[0]){case"RadialAxial":return new Wg(h);case"Mesh":return new Ug(h);case"Dummy":return new $g}throw new Error(`Unknown IR type: ${h[0]}`)}const kd={COLORED:1,UNCOLORED:2},dh=class dh{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;xh("TilingType: "+o);const d=s[0],u=s[1],f=s[2],p=s[3],g=H.singularValueDecompose2dScale(this.matrix),A=H.singularValueDecompose2dScale(this.baseTransform),_=[g[0]*A[0],g[1]*A[1]],y=this.getSizeAndScale(i,this.ctx.canvas.width,_[0]),w=this.getSizeAndScale(n,this.ctx.canvas.height,_[1]),E=t.cachedCanvases.getCanvas("pattern",y.size,w.size,!0),x=E.context,S=c.createCanvasGraphics(x);S.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(S,a,l);let C=d,T=u,R=f,M=p;return d<0&&(C=0,R+=Math.abs(d)),u<0&&(T=0,M+=Math.abs(u)),x.translate(-(y.scale*C),-(w.scale*T)),S.transform(y.scale,0,0,w.scale,0,0),x.save(),this.clipBbox(S,C,T,R,M),S.baseTransform=mt(S.ctx),S.executeOperatorList(e),S.endDrawing(),{canvas:E.canvas,scaleX:y.scale,scaleY:w.scale,offsetX:C,offsetY:T}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(dh.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(mt(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case kd.COLORED:const a=this.ctx;i.fillStyle=a.fillStyle,i.strokeStyle=a.strokeStyle,n.fillColor=a.fillStyle,n.strokeColor=a.strokeStyle;break;case kd.UNCOLORED:const o=H.makeHexColor(s[0],s[1],s[2]);i.fillStyle=o,i.strokeStyle=o,n.fillColor=o,n.strokeColor=o;break;default:throw new bg(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==ie.SHADING&&(n=H.transform(n,e.baseTransform),this.matrix&&(n=H.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}};G(dh,"MAX_PATTERN_SIZE",3e3);let yc=dh;function Vg({src:h,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:a=!1}){const o=de.isLittleEndian?4278190080:255,[l,c]=a?[n,o]:[o,n],d=s>>3,u=s&7,f=h.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;g++){for(const _=t+d;t<_;t++){const y=t<f?h[t]:255;e[p++]=y&128?c:l,e[p++]=y&64?c:l,e[p++]=y&32?c:l,e[p++]=y&16?c:l,e[p++]=y&8?c:l,e[p++]=y&4?c:l,e[p++]=y&2?c:l,e[p++]=y&1?c:l}if(u===0)continue;const A=t<f?h[t++]:255;for(let _=0;_<u;_++)e[p++]=A&1<<7-_?c:l}return{srcPos:t,destPos:p}}const Ld=16,Md=100,qg=15,Id=10,Dd=1e3,ce=16;function Xg(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 Yg{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 fl(h,t,e,s,i,n,a,o,l,c){const[d,u,f,p,g,A]=mt(h);if(u===0&&f===0){const w=a*d+g,E=Math.round(w),x=o*p+A,S=Math.round(x),C=(a+l)*d+g,T=Math.abs(Math.round(C)-E)||1,R=(o+c)*p+A,M=Math.abs(Math.round(R)-S)||1;return h.setTransform(Math.sign(d),0,0,Math.sign(p),E,S),h.drawImage(t,e,s,i,n,0,0,T,M),h.setTransform(d,u,f,p,g,A),[T,M]}if(d===0&&p===0){const w=o*f+g,E=Math.round(w),x=a*u+A,S=Math.round(x),C=(o+c)*f+g,T=Math.abs(Math.round(C)-E)||1,R=(a+l)*u+A,M=Math.abs(Math.round(R)-S)||1;return h.setTransform(0,Math.sign(u),Math.sign(f),0,E,S),h.drawImage(t,e,s,i,n,0,0,M,T),h.setTransform(d,u,f,p,g,A),[M,T]}h.drawImage(t,e,s,i,n,a,o,l,c);const _=Math.hypot(d,u),y=Math.hypot(f,p);return[_*l,y*c]}function Kg(h){const{width:t,height:e}=h;if(t>Dd||e>Dd)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let a=new Uint8Array(n*(e+1)),o,l,c;const d=t+7&-8;let u=new Uint8Array(d*e),f=0;for(const y of h.data){let w=128;for(;w>0;)u[f++]=y&w?0:255,w>>=1}let p=0;for(f=0,u[f]!==0&&(a[0]=1,++p),l=1;l<t;l++)u[f]!==u[f+1]&&(a[l]=u[f]?2:1,++p),f++;for(u[f]!==0&&(a[l]=2,++p),o=1;o<e;o++){f=o*d,c=o*n,u[f-d]!==u[f]&&(a[c]=u[f]?1:8,++p);let y=(u[f]?4:0)+(u[f-d]?8:0);for(l=1;l<t;l++)y=(y>>2)+(u[f+1]?4:0)+(u[f-d+1]?8:0),i[y]&&(a[c+l]=i[y],++p),f++;if(u[f-d]!==u[f]&&(a[c+l]=u[f]?2:4,++p),p>s)return null}for(f=d*(e-1),c=o*n,u[f]!==0&&(a[c]=8,++p),l=1;l<t;l++)u[f]!==u[f+1]&&(a[c+l]=u[f]?4:8,++p),f++;if(u[f]!==0&&(a[c+l]=4,++p),p>s)return null;const g=new Int32Array([0,n,-1,0,-n,0,0,0,1]),A=new Path2D;for(o=0;p&&o<=e;o++){let y=o*n;const w=y+t;for(;y<w&&!a[y];)y++;if(y===w)continue;A.moveTo(y%n,o);const E=y;let x=a[y];do{const S=g[x];do y+=S;while(!a[y]);const C=a[y];C!==5&&C!==10?(x=C,a[y]=0):(x=C&51*x>>4,a[y]&=x>>2|x<<2),A.lineTo(y%n,y/n|0),a[y]||--p}while(E!==y);--o}return u=null,a=null,function(y){y.save(),y.scale(1/t,-1/e),y.translate(0,-e),y.fill(A),y.beginPath(),y.restore()}}class Fd{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=ru,this.textMatrixScale=1,this.fontMatrix=Vh,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=qt.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]=H.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=H.applyTransform(e,t),i=H.applyTransform(e.slice(2),t),n=H.applyTransform([e[0],e[3]],t),a=H.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){H.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=H.bezierBoundingBox(e,s,i,n,a,o,l,c,d);d||this.updateRectMinMax(t,u)}getPathBoundingBox(t=ie.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===ie.STROKE){e||at("Stroke bounding box must include transform.");const i=H.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=H.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=ie.FILL,e=null){return H.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Od(h,t){if(typeof ImageData<"u"&&t instanceof ImageData){h.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%ce,n=(e-i)/ce,a=i===0?n:n+1,o=h.createImageData(s,ce);let l=0,c;const d=t.data,u=o.data;let f,p,g,A;if(t.kind===Al.GRAYSCALE_1BPP){const _=d.byteLength,y=new Uint32Array(u.buffer,0,u.byteLength>>2),w=y.length,E=s+7>>3,x=4294967295,S=de.isLittleEndian?4278190080:255;for(f=0;f<a;f++){for(g=f<n?ce:i,c=0,p=0;p<g;p++){const C=_-l;let T=0;const R=C>E?s:C*8-7,M=R&-8;let B=0,I=0;for(;T<M;T+=8)I=d[l++],y[c++]=I&128?x:S,y[c++]=I&64?x:S,y[c++]=I&32?x:S,y[c++]=I&16?x:S,y[c++]=I&8?x:S,y[c++]=I&4?x:S,y[c++]=I&2?x:S,y[c++]=I&1?x:S;for(;T<R;T++)B===0&&(I=d[l++],B=128),y[c++]=I&B?x:S,B>>=1}for(;c<w;)y[c++]=0;h.putImageData(o,0,f*ce)}}else if(t.kind===Al.RGBA_32BPP){for(p=0,A=s*ce*4,f=0;f<n;f++)u.set(d.subarray(l,l+A)),l+=A,h.putImageData(o,0,p),p+=ce;f<a&&(A=s*i*4,u.set(d.subarray(l,l+A)),h.putImageData(o,0,p))}else if(t.kind===Al.RGB_24BPP)for(g=ce,A=s*g,f=0;f<a;f++){for(f>=n&&(g=i,A=s*g),c=0,p=A;p--;)u[c++]=d[l++],u[c++]=d[l++],u[c++]=d[l++],u[c++]=255;h.putImageData(o,0,f*ce)}else throw new Error(`bad image kind: ${t.kind}`)}function Nd(h,t){if(t.bitmap){h.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%ce,n=(e-i)/ce,a=i===0?n:n+1,o=h.createImageData(s,ce);let l=0;const c=t.data,d=o.data;for(let u=0;u<a;u++){const f=u<n?ce:i;({srcPos:l}=Vg({src:c,srcPos:l,dest:d,width:s,height:f,nonBlackColor:0})),h.putImageData(o,0,u*ce)}}function ia(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 pl(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),!Jt){const{filter:t}=h;t!=="none"&&t!==""&&(h.filter="none")}}function Hd(h,t){if(t)return!0;const e=H.singularValueDecompose2dScale(h);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Li.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const Qg=["butt","round","square"],Jg=["miter","round","bevel"],Zg={},Bd={};var Ii,_c,wc;const Ed=class Ed{constructor(t,e,s,i,n,{optionalContentConfig:a,markedContentStack:o=null},l,c){v(this,Ii);this.ctx=t,this.current=new Fd(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 Yg(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(...mt(this.compositeCtx))}this.ctx.save(),pl(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=mt(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>Id&&typeof s=="function",d=c?Date.now()+qg:0;let u=0;const f=this.commonObjs,p=this.objs;let g;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(g=a[o],g!==je.dependency)this[g].apply(this,n[o]);else for(const A of n[o]){const _=A.startsWith("g_")?f:p;if(!_.has(A))return _.get(A,s),o}if(o++,o===l)return o;if(c&&++u>Id){if(Date.now()>d)return s(),o;u=0}}}endDrawing(){b(this,Ii,_c).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,Ii,wc).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 f=o,p=l;n>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),n/=o/f),a>2&&l>1&&(p=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/p),d=this.cachedCanvases.getCanvas(c,f,p),u=d.context,u.clearRect(0,0,f,p),u.drawImage(t,0,0,o,l,0,0,f,p),t=d.canvas,o=f,l=p,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=mt(e);let l,c,d,u;if((t.bitmap||t.data)&&t.count>1){const R=t.bitmap||t.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),n]),l=this._cachedBitmapsMap.get(R),l||(l=new Map,this._cachedBitmapsMap.set(R,l));const M=l.get(c);if(M&&!a){const B=Math.round(Math.min(o[0],o[2])+o[4]),I=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:M,offsetX:B,offsetY:I}}d=M}d||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),Nd(u.context,t));let f=H.transform(o,[1/s,0,0,-1/i,0,0]);f=H.transform(f,[1,0,0,1,0,-i]);const[p,g,A,_]=H.getAxialAlignedBoundingBox([0,0,s,i],f),y=Math.round(A-p)||1,w=Math.round(_-g)||1,E=this.cachedCanvases.getCanvas("fillCanvas",y,w),x=E.context,S=p,C=g;x.translate(-S,-C),x.transform(...f),d||(d=this._scaleImage(u.canvas,ws(x)),d=d.img,l&&a&&l.set(c,d)),x.imageSmoothingEnabled=Hd(mt(x),t.interpolate),fl(x,d,0,0,d.width,d.height,0,0,s,i),x.globalCompositeOperation="source-in";const T=H.transform(ws(x),[1,0,0,1,-S,-C]);return x.fillStyle=a?n.getPattern(e,this,T,ie.FILL):n,x.fillRect(0,0,s,i),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,E.canvas)),{canvas:E.canvas,offsetX:Math.round(S),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=Qg[t]}setLineJoin(t){this.ctx.lineJoin=Jg[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(...mt(this.suspendedCtx)),ia(this.suspendedCtx,n),Xg(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(),ia(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){const n=i[0],a=i[1],o=i[2]-n,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,a,o,l,c,d,u){let f=t.canvas,p=l-d,g=c-u;if(a){if(p<0||g<0||p+s>f.width||g+i>f.height){const _=this.cachedCanvases.getCanvas("maskExtension",s,i),y=_.context;y.drawImage(f,-p,-g),a.some(w=>w!==0)&&(y.globalCompositeOperation="destination-atop",y.fillStyle=H.makeHexColor(...a),y.fillRect(0,0,s,i),y.globalCompositeOperation="source-over"),f=_.canvas,p=g=0}else if(a.some(_=>_!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const _=new Path2D;_.rect(p,g,s,i),t.clip(_),t.globalCompositeOperation="destination-atop",t.fillStyle=H.makeHexColor(...a),t.fillRect(p,g,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 A=new Path2D;A.rect(l,c,s,i),e.clip(A),e.globalCompositeOperation="destination-in",e.drawImage(f,p,g,s,i,l,c,s,i),e.restore()}save(){this.inSMaskMode?(ia(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(),ia(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=mt(i),u=d[0]===0&&d[3]===0||d[1]===0&&d[2]===0,f=u?s.slice(0):null;for(let p=0,g=0,A=t.length;p<A;p++)switch(t[p]|0){case je.rectangle:a=e[g++],o=e[g++];const _=e[g++],y=e[g++],w=a+_,E=o+y;i.moveTo(a,o),_===0||y===0?i.lineTo(w,E):(i.lineTo(w,o),i.lineTo(w,E),i.lineTo(a,E)),u||n.updateRectMinMax(d,[a,o,w,E]),i.closePath();break;case je.moveTo:a=e[g++],o=e[g++],i.moveTo(a,o),u||n.updatePathMinMax(d,a,o);break;case je.lineTo:a=e[g++],o=e[g++],i.lineTo(a,o),u||n.updatePathMinMax(d,a,o);break;case je.curveTo:l=a,c=o,a=e[g+4],o=e[g+5],i.bezierCurveTo(e[g],e[g+1],e[g+2],e[g+3],a,o),n.updateCurvePathMinMax(d,l,c,e[g],e[g+1],e[g+2],e[g+3],a,o,f),g+=6;break;case je.curveTo2:l=a,c=o,i.bezierCurveTo(a,o,e[g],e[g+1],e[g+2],e[g+3]),n.updateCurvePathMinMax(d,l,c,a,o,e[g],e[g+1],e[g+2],e[g+3],f),a=e[g+2],o=e[g+3],g+=4;break;case je.curveTo3:l=a,c=o,a=e[g+2],o=e[g+3],i.bezierCurveTo(e[g],e[g+1],a,o,a,o),n.updateCurvePathMinMax(d,l,c,e[g],e[g+1],a,o,a,o,f),g+=4;break;case je.closePath:i.closePath();break}u&&n.updateScalingPathMinMax(d,f),n.setCurrentPoint(a,o)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&(s!=null&&s.getPattern)?(e.save(),e.strokeStyle=s.getPattern(e,this,ws(e),ie.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,ws(e),ie.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=Zg}eoClip(){this.pendingClip=Bd}beginText(){this.current.textMatrix=ru,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||Vh,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&q("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<Ld?c=Ld:e>Md&&(c=Md),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&qt.FILL_STROKE_MASK,u=!!(l&qt.ADD_TO_PATH_FLAG),f=a.patternFill&&!o.missingFile;let p;(o.disableFontFace||u||f)&&(p=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||f?(n.save(),n.translate(e,s),n.beginPath(),p(n,c),i&&n.setTransform(...i),(d===qt.FILL||d===qt.FILL_STROKE)&&n.fill(),(d===qt.STROKE||d===qt.FILL_STROKE)&&n.stroke(),n.restore()):((d===qt.FILL||d===qt.FILL_STROKE)&&n.fillText(t,e,s),(d===qt.STROKE||d===qt.FILL_STROKE)&&n.strokeText(t,e,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:mt(n),x:e,y:s,fontSize:c,addToPath:p})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return tt(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,a=e.fontSizeScale,o=e.charSpacing,l=e.wordSpacing,c=e.fontDirection,d=e.textHScale*c,u=t.length,f=s.vertical,p=f?1:-1,g=s.defaultVMetrics,A=i*e.fontMatrix[0],_=e.textRenderingMode===qt.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,ws(n),ie.FILL);y=mt(n),n.restore(),n.fillStyle=C}let w=e.lineWidth;const E=e.textMatrixScale;if(E===0||w===0){const C=e.textRenderingMode&qt.FILL_STROKE_MASK;(C===qt.STROKE||C===qt.FILL_STROKE)&&(w=this.getSinglePixelWidth())}else w/=E;if(a!==1&&(n.scale(a,a),w/=a),n.lineWidth=w,s.isInvalidPDFjsFont){const C=[];let T=0;for(const R of t)C.push(R.unicode),T+=R.width;n.fillText(C.join(""),0,0),e.x+=T*A*d,n.restore(),this.compose();return}let x=0,S;for(S=0;S<u;++S){const C=t[S];if(typeof C=="number"){x+=p*C*i/1e3;continue}let T=!1;const R=(C.isSpace?l:0)+o,M=C.fontChar,B=C.accent;let I,$,V=C.width;if(f){const X=C.vmetric||g,Q=-(C.vmetric?X[1]:V*.5)*A,D=X[2]*A;V=X?-X[0]:V,I=Q/a,$=(x+D)/a}else I=x/a,$=0;if(s.remeasure&&V>0){const X=n.measureText(M).width*1e3/i*a;if(V<X&&this.isFontSubpixelAAEnabled){const Q=V/X;T=!0,n.save(),n.scale(Q,1),I/=Q}else V!==X&&(I+=(V-X)/2e3*i/a)}if(this.contentVisible&&(C.isInFont||s.missingFile)){if(_&&!B)n.fillText(M,I,$);else if(this.paintChar(M,I,$,y),B){const X=I+i*B.offset.x/a,Q=$-i*B.offset.y/a;this.paintChar(B.fontChar,X,Q,y)}}const W=f?V*A-R*c:V*A+R*c;x+=W,T&&n.restore()}f?e.y-=x:e.x+=x*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||Vh,f=t.length,p=s.textRenderingMode===qt.INVISIBLE;let g,A,_,y;if(!(p||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),g=0;g<f;++g){if(A=t[g],typeof A=="number"){y=o*A*n/1e3,this.ctx.translate(y,0),s.x+=y*d;continue}const w=(A.isSpace?c:0)+l,E=i.charProcOperatorList[A.operatorListId];if(!E){q(`Type3 character "${A.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=A,this.save(),e.scale(n,n),e.transform(...u),this.executeOperatorList(E),this.restore()),_=H.applyTransform([A.width,0],u)[0]*n+w,e.translate(_,0),s.x+=_*d}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,a){this.ctx.rect(s,i,n-s,a-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||mt(this.ctx),n={createCanvasGraphics:a=>new Ed(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new yc(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=H.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=H.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=Gg(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,ws(e),ie.SHADING);const i=ws(e);if(i){const{width:n,height:a}=e.canvas,[o,l,c,d]=H.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(){at("Should not call beginInlineImage")}beginImageData(){at("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=mt(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(mt(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||xh("TODO: Support non-isolated groups."),t.knockout&&q("Knockout groups not supported.");const s=mt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=H.getAxialAlignedBoundingBox(t.bbox,mt(e));const n=[0,0,e.canvas.width,e.canvas.height];i=H.intersect(i,n)||[0,0,0,0];const a=Math.floor(i[0]),o=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-a,1),c=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,c]);let d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,l,c),f=u.context;f.translate(-a,-o),f.transform(...s),t.smask?this.smaskStack.push({canvas:u.canvas,context:f,offsetX:a,offsetY:o,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,o),e.save()),ia(e,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=mt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=H.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,Ii,_c).call(this),pl(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]=H.singularValueDecompose2dScale(mt(this.ctx)),{viewportScale:d}=this,u=Math.ceil(a*this.outputScaleX*d),f=Math.ceil(o*this.outputScaleY*d);this.annotationCanvas=this.canvasFactory.create(u,f);const{canvas:p,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,o*c),pl(this.ctx)}else pl(this.ctx),this.ctx.rect(e[0],e[1],a,o),this.ctx.clip(),this.endPath()}this.current=new Fd(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),b(this,Ii,wc).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=Kg(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=mt(o);o.transform(e,s,i,n,0,0);const c=this._createMaskCanvas(t);o.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let d=0,u=a.length;d<u;d+=2){const f=H.transform(l,[e,s,i,n,a[d],a[d+1]]),[p,g]=H.applyTransform([0,0],f);o.drawImage(c.canvas,p,g)}o.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:a,width:o,height:l,transform:c}=n,d=this.cachedCanvases.getCanvas("maskCanvas",o,l),u=d.context;u.save();const f=this.getObject(a,n);Nd(u,f),u.globalCompositeOperation="source-in",u.fillStyle=i?s.getPattern(u,this,ws(e),ie.FILL):s,u.fillRect(0,0,o,l),u.restore(),e.save(),e.transform(...c),e.scale(1,-1),fl(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){q("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){q("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(),!Jt){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;Od(l,t),n=this.applyTransferMapsToCanvas(l)}const a=this._scaleImage(n,ws(i));i.imageSmoothingEnabled=Hd(mt(i),t.interpolate),fl(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;Od(l,t),i=this.applyTransferMapsToCanvas(l)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),fl(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===Bd?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=mt(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}};Ii=new WeakSet,_c=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)},wc=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 tr=Ed;for(const h in je)tr.prototype[h]!==void 0&&(tr.prototype[je[h]]=tr.prototype[h]);var Za,to;class Js{static get workerPort(){return r(this,Za)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");m(this,Za,t)}static get workerSrc(){return r(this,to)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");m(this,to,t)}}Za=new WeakMap,to=new WeakMap,v(Js,Za,null),v(Js,to,"");const gl={UNKNOWN:0,DATA:1,ERROR:2},Et={UNKNOWN:0,CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function be(h){switch(h instanceof Error||typeof h=="object"&&h!==null||at('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),h.name){case"AbortException":return new $n(h.message);case"MissingPDFException":return new Un(h.message);case"PasswordException":return new Xh(h.message,h.code);case"UnexpectedResponseException":return new Sh(h.message,h.status);case"UnknownErrorException":return new Yh(h.message,h.details);default:return new Yh(h.message,h.toString())}}var vs,zu,Uu,Sl;class da{constructor(t,e,s){v(this,vs);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,vs,Uu).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===gl.DATA)l.resolve(n.data);else if(n.callback===gl.ERROR)l.reject(be(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:gl.DATA,callbackId:n.callbackId,data:c})},function(c){s.postMessage({sourceName:o,targetName:l,callback:gl.ERROR,callbackId:n.callbackId,reason:be(c)})});return}if(n.streamId){b(this,vs,zu).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:Et.PULL,streamId:n,desiredSize:c.desiredSize}),d.promise},cancel:c=>{It(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:Et.CANCEL,streamId:n,reason:be(c)}),d.promise}},s)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}vs=new WeakSet,zu=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(c,d=1,u){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=d,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:Et.ENQUEUE,streamId:e,chunk:c},u)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Et.CLOSE,streamId:e}),delete a.streamSinks[e])},error(c){It(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Et.ERROR,streamId:e,reason:be(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:Et.START_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:Et.START_COMPLETE,streamId:e,reason:be(c)})})},Uu=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Et.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(be(t.reason));break;case Et.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(be(t.reason));break;case Et.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:Et.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:Et.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Et.PULL_COMPLETE,streamId:e,reason:be(l)})});break;case Et.ENQUEUE:if(It(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Et.CLOSE:if(It(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,vs,Sl).call(this,a,e);break;case Et.ERROR:It(a,"error should have stream controller"),a.controller.error(be(t.reason)),b(this,vs,Sl).call(this,a,e);break;case Et.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(be(t.reason)),b(this,vs,Sl).call(this,a,e);break;case Et.CANCEL:if(!o)break;new Promise(function(l){var c;l((c=o.onCancel)==null?void 0:c.call(o,be(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Et.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Et.CANCEL_COMPLETE,streamId:e,reason:be(l)})}),o.sinkCapability.reject(be(t.reason)),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Sl=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 rn,eo;class tm{constructor({parsedData:t,rawData:e}){v(this,rn);v(this,eo);m(this,rn,t),m(this,eo,e)}getRaw(){return r(this,eo)}get(t){return r(this,rn).get(t)??null}getAll(){return cd(r(this,rn))}has(t){return r(this,rn).has(t)}}rn=new WeakMap,eo=new WeakMap;const oi=Symbol("INTERNAL");var so,io,no,br;class em{constructor(t,{name:e,intent:s,usage:i}){v(this,so,!1);v(this,io,!1);v(this,no,!1);v(this,br,!0);m(this,so,!!(t&Oe.DISPLAY)),m(this,io,!!(t&Oe.PRINT)),this.name=e,this.intent=s,this.usage=i}get visible(){if(r(this,no))return r(this,br);if(!r(this,br))return!1;const{print:t,view:e}=this.usage;return r(this,so)?(e==null?void 0:e.viewState)!=="OFF":r(this,io)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==oi&&at("Internal method `_setVisible` called."),m(this,no,s),m(this,br,e)}}so=new WeakMap,io=new WeakMap,no=new WeakMap,br=new WeakMap;var gi,rt,vr,Ar,ro,Ec;class sm{constructor(t,e=Oe.DISPLAY){v(this,ro);v(this,gi,null);v(this,rt,new Map);v(this,vr,null);v(this,Ar,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,m(this,Ar,t.order);for(const s of t.groups)r(this,rt).set(s.id,new em(e,s));if(t.baseState==="OFF")for(const s of r(this,rt).values())s._setVisible(oi,!1);for(const s of t.on)r(this,rt).get(s)._setVisible(oi,!0);for(const s of t.off)r(this,rt).get(s)._setVisible(oi,!1);m(this,vr,this.getHash())}}isVisible(t){if(r(this,rt).size===0)return!0;if(!t)return xh("Optional content group not defined."),!0;if(t.type==="OCG")return r(this,rt).has(t.id)?r(this,rt).get(t.id).visible:(q(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,ro,Ec).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!r(this,rt).has(e))return q(`Optional content group not found: ${e}`),!0;if(r(this,rt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!r(this,rt).has(e))return q(`Optional content group not found: ${e}`),!0;if(!r(this,rt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!r(this,rt).has(e))return q(`Optional content group not found: ${e}`),!0;if(!r(this,rt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!r(this,rt).has(e))return q(`Optional content group not found: ${e}`),!0;if(r(this,rt).get(e).visible)return!1}return!0}return q(`Unknown optional content policy ${t.policy}.`),!0}return q(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=r(this,rt).get(t);if(!s){q(`Optional content group not found: ${t}`);return}s._setVisible(oi,!!e,!0),m(this,gi,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,rt).get(i);if(n)switch(s){case"ON":n._setVisible(oi,!0);break;case"OFF":n._setVisible(oi,!1);break;case"Toggle":n._setVisible(oi,!n.visible);break}}m(this,gi,null)}get hasInitialVisibility(){return r(this,vr)===null||this.getHash()===r(this,vr)}getOrder(){return r(this,rt).size?r(this,Ar)?r(this,Ar).slice():[...r(this,rt).keys()]:null}getGroups(){return r(this,rt).size>0?cd(r(this,rt)):null}getGroup(t){return r(this,rt).get(t)||null}getHash(){if(r(this,gi)!==null)return r(this,gi);const t=new Hu;for(const[e,s]of r(this,rt))t.update(`${e}:${s.visible}`);return m(this,gi,t.hexdigest())}}gi=new WeakMap,rt=new WeakMap,vr=new WeakMap,Ar=new WeakMap,ro=new WeakSet,Ec=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,ro,Ec).call(this,n);else if(r(this,rt).has(n))a=r(this,rt).get(n).visible;else return q(`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 im{constructor(t,{disableRange:e=!1,disableStream:s=!1}){It(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)});It(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(){It(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new nm(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new rm(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 nm{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=gd(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 rm{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 am(h){let t=!0,e=s("filename\\*","i").exec(h);if(e){e=e[1];let d=o(e);return d=unescape(d),d=l(d),d=c(d),n(d)}if(e=a(h),e){const d=c(e);return n(d)}if(e=s("filename","i").exec(h),e){e=e[1];let d=o(e);return d=c(d),n(d)}function s(d,u){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(d,u){if(d){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const f=new TextDecoder(d,{fatal:!0}),p=Ch(u);u=f.decode(p),t=!1}catch{}}return u}function n(d){return t&&/[\x80-\xff]/.test(d)&&(d=i("utf-8",d),t&&(d=i("iso-8859-1",d))),d}function a(d){const u=[];let f;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=p.exec(d))!==null;){let[,A,_,y]=f;if(A=parseInt(A,10),A in u){if(A===0)break;continue}u[A]=[_,y]}const g=[];for(let A=0;A<u.length&&A in u;++A){let[_,y]=u[A];y=o(y),_&&(y=unescape(y),A===0&&(y=l(y))),g.push(y)}return g.join("")}function o(d){if(d.startsWith('"')){const u=d.slice(1).split('\\"');for(let f=0;f<u.length;++f){const p=u[f].indexOf('"');p!==-1&&(u[f]=u[f].slice(0,p),u.length=f+1),u[f]=u[f].replaceAll(/\\(.)/g,"$1")}d=u.join('"')}return d}function l(d){const u=d.indexOf("'");if(u===-1)return d;const f=d.slice(0,u),g=d.slice(u+1).replace(/^[^']*'/,"");return i(f,g)}function c(d){return!d.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(d)?d:d.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(u,f,p,g){if(p==="q"||p==="Q")return g=g.replaceAll("_"," "),g=g.replaceAll(/=([0-9a-fA-F]{2})/g,function(A,_){return String.fromCharCode(parseInt(_,16))}),i(f,g);try{g=atob(g)}catch{}return i(f,g)})}return""}function vd({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 Ad(h){const t=h("Content-Disposition");if(t){let e=am(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(gd(e))return e}return null}function Lh(h,t){return h===404||h===0&&t.startsWith("file:")?new Un('Missing PDF "'+t+'".'):new Sh(`Unexpected server response (${h}) while retrieving PDF "${t}".`,h)}function $u(h){return h===200||h===206}function Gu(h,t,e){return{method:"GET",headers:h,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Vu(h){const t=new Headers;for(const e in h){const s=h[e];s!==void 0&&t.append(e,s)}return t}function qu(h){return h instanceof Uint8Array?h.buffer:h instanceof ArrayBuffer?h:(q(`getArrayBuffer - unexpected data format: ${h}`),new Uint8Array(h).buffer)}class jd{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 It(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new om(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new lm(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 om{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=Vu(this._stream.httpHeaders);const s=e.url;fetch(s,Gu(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!$u(i.status))throw Lh(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=l=>i.headers.get(l),{allowRangeRequests:a,suggestedLength:o}=vd({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=Ad(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new $n("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:qu(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class lm{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=Vu(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,Gu(this._headers,this._withCredentials,this._abortController)).then(a=>{if(!$u(a.status))throw Lh(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:qu(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const zh=200,Uh=206;function hm(h){const t=h.response;return typeof t!="string"?t:Ch(t).buffer}class cm{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=Uh):i.expectedStatus=zh,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||zh;if(!(n===zh&&s.expectedStatus===Uh)&&n!==s.expectedStatus){(c=s.onError)==null||c.call(s,i.status);return}const o=hm(i);if(n===Uh){const u=i.getResponseHeader("Content-Range"),f=/bytes (\d+)-(\d+)\/(\d+)/.exec(u);s.onDone({begin:parseInt(f[1],10),chunk:o})}else o?s.onDone({begin:0,chunk:o}):(d=s.onError)==null||d.call(s,i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class dm{constructor(t){this._source=t,this._manager=new cm(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 It(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new um(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new fm(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 um{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}=vd({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Ad(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=Lh(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 fm{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=Lh(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 Xu=/^file:\/\/\/[a-zA-Z]:\//;function pm(h){const t=ys.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 gm{constructor(t){this.source=t,this.url=pm(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 It(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new vm(this):new mm(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new Am(this,t,e):new bm(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 Yu{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 $n("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Ku{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 Kl(h,t){return{protocol:h.protocol,auth:h.auth,host:h.hostname,port:h.port,path:h.path,method:"GET",headers:t}}class mm extends Yu{constructor(t){super(t);const e=s=>{if(s.statusCode===404){const o=new Un(`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}=vd({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=Ad(i)};if(this._request=null,this._url.protocol==="http:"){const s=ys.get("http");this._request=s.request(Kl(this._url,t.httpHeaders),e)}else{const s=ys.get("https");this._request=s.request(Kl(this._url,t.httpHeaders),e)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class bm extends Ku{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 Un(`Missing PDF "${this._url}".`);this._storedError=a;return}this._setReadableStream(n)};if(this._request=null,this._url.protocol==="http:"){const n=ys.get("http");this._request=n.request(Kl(this._url,this._httpHeaders),i)}else{const n=ys.get("https");this._request=n.request(Kl(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class vm extends Yu{constructor(t){super(t);let e=decodeURIComponent(this._url.path);Xu.test(this._url.href)&&(e=e.replace(/^\//,""));const s=ys.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 Un(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class Am extends Ku{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);Xu.test(this._url.href)&&(i=i.replace(/^\//,""));const n=ys.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const ym=1e5,oe=30,_m=.8;var eu,mi,he,ao,oo,an,Os,lo,ho,on,yr,_r,bi,wr,co,Er,ln,uo,fo,Mt,hn,cn,vi,xr,si,Qu,Ju,xc,As,Cl,Zu,tf;let Ql=(Mt=class{constructor({textContentSource:t,container:e,viewport:s}){v(this,si);v(this,mi,Promise.withResolvers());v(this,he,null);v(this,ao,!1);v(this,oo,!!((eu=globalThis.FontInspector)!=null&&eu.enabled));v(this,an,null);v(this,Os,null);v(this,lo,0);v(this,ho,0);v(this,on,null);v(this,yr,null);v(this,_r,0);v(this,bi,0);v(this,wr,Object.create(null));v(this,co,[]);v(this,Er,null);v(this,ln,[]);v(this,uo,new WeakMap);v(this,fo,null);var l;if(t instanceof ReadableStream)m(this,Er,t);else if(typeof t=="object")m(this,Er,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');m(this,he,m(this,yr,e)),m(this,bi,s.scale*(globalThis.devicePixelRatio||1)),m(this,_r,s.rotation),m(this,Os,{prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:a,pageY:o}=s.rawDims;m(this,fo,[1,0,0,-1,-a,o+n]),m(this,ho,i),m(this,lo,n),b(l=Mt,As,Zu).call(l),Nn(e,s),r(this,mi).promise.catch(()=>{}).then(()=>{r(Mt,xr).delete(this),m(this,Os,null),m(this,wr,null)})}render(){const t=()=>{r(this,on).read().then(({value:e,done:s})=>{if(s){r(this,mi).resolve();return}r(this,an)??m(this,an,e.lang),Object.assign(r(this,wr),e.styles),b(this,si,Qu).call(this,e.items),t()},r(this,mi).reject)};return m(this,on,r(this,Er).getReader()),r(Mt,xr).add(this),t(),r(this,mi).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==r(this,_r)&&(e==null||e(),m(this,_r,i),Nn(r(this,yr),{rotation:i})),s!==r(this,bi)){e==null||e(),m(this,bi,s);const a={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:b(n=Mt,As,Cl).call(n,r(this,an))};for(const o of r(this,ln))a.properties=r(this,uo).get(o),a.div=o,b(this,si,xc).call(this,a)}}cancel(){var e;const t=new $n("TextLayer task cancelled.");(e=r(this,on))==null||e.cancel(t).catch(()=>{}),m(this,on,null),r(this,mi).reject(t)}get textDivs(){return r(this,ln)}get textContentItemsStr(){return r(this,co)}static cleanup(){if(!(r(this,xr).size>0)){r(this,hn).clear();for(const{canvas:t}of r(this,cn).values())t.remove();r(this,cn).clear()}}},mi=new WeakMap,he=new WeakMap,ao=new WeakMap,oo=new WeakMap,an=new WeakMap,Os=new WeakMap,lo=new WeakMap,ho=new WeakMap,on=new WeakMap,yr=new WeakMap,_r=new WeakMap,bi=new WeakMap,wr=new WeakMap,co=new WeakMap,Er=new WeakMap,ln=new WeakMap,uo=new WeakMap,fo=new WeakMap,hn=new WeakMap,cn=new WeakMap,vi=new WeakMap,xr=new WeakMap,si=new WeakSet,Qu=function(t){var i,n;if(r(this,ao))return;(n=r(this,Os)).ctx??(n.ctx=b(i=Mt,As,Cl).call(i,r(this,an)));const e=r(this,ln),s=r(this,co);for(const a of t){if(e.length>ym){q("Ignoring additional textDivs for performance reasons."),m(this,ao,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=r(this,he);m(this,he,document.createElement("span")),r(this,he).classList.add("markedContent"),a.id!==null&&r(this,he).setAttribute("id",`${a.id}`),o.append(r(this,he))}else a.type==="endMarkedContent"&&m(this,he,r(this,he).parentNode);continue}s.push(a.str),b(this,si,Ju).call(this,a)}},Ju=function(t){var A;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};r(this,ln).push(e);const i=H.transform(r(this,fo),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,oo)&&a.fontSubstitution||a.fontFamily,l=Math.hypot(i[2],i[3]),c=l*b(A=Mt,As,tf).call(A,o,r(this,an));let d,u;n===0?(d=i[4],u=i[5]-c):(d=i[4]+c*Math.sin(n),u=i[5]-c*Math.cos(n));const f="calc(var(--scale-factor)*",p=e.style;r(this,he)===r(this,yr)?(p.left=`${(100*d/r(this,ho)).toFixed(2)}%`,p.top=`${(100*u/r(this,lo)).toFixed(2)}%`):(p.left=`${f}${d.toFixed(2)}px)`,p.top=`${f}${u.toFixed(2)}px)`),p.fontSize=`${f}${(r(Mt,vi)*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,r(this,oo)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let g=!1;if(t.str.length>1)g=!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&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),r(this,uo).set(e,s),r(this,Os).div=e,r(this,Os).properties=s,b(this,si,xc).call(this,r(this,Os)),s.hasText&&r(this,he).append(e),s.hasEOL){const _=document.createElement("br");_.setAttribute("role","presentation"),r(this,he).append(_)}},xc=function(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:a}=t,{style:o}=e;let l="";if(r(Mt,vi)>1&&(l=`scale(${1/r(Mt,vi)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:c}=o,{canvasWidth:d,fontSize:u}=s;(n!==u||a!==c)&&(i.font=`${u*r(this,bi)}px ${c}`,t.prevFontSize=u,t.prevFontFamily=c);const{width:f}=i.measureText(e.textContent);f>0&&(l=`scaleX(${d*r(this,bi)/f}) ${l}`)}s.angle!==0&&(l=`rotate(${s.angle}deg) ${l}`),l.length>0&&(o.transform=l)},As=new WeakSet,Cl=function(t=null){let e=r(this,cn).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),r(this,cn).set(t,e)}return e},Zu=function(){if(r(this,vi)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),m(this,vi,t.getBoundingClientRect().height),t.remove()},tf=function(t,e){const s=r(this,hn).get(t);if(s)return s;const i=b(this,As,Cl).call(this,e),n=i.font;i.canvas.width=i.canvas.height=oe,i.font=`${oe}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,hn).set(t,u),i.canvas.width=i.canvas.height=0,i.font=n,u}i.strokeStyle="red",i.clearRect(0,0,oe,oe),i.strokeText("g",0,0);let c=i.getImageData(0,0,oe,oe).data;l=0;for(let u=c.length-1-3;u>=0;u-=4)if(c[u]>0){l=Math.ceil(u/4/oe);break}i.clearRect(0,0,oe,oe),i.strokeText("A",0,oe),c=i.getImageData(0,0,oe,oe).data,o=0;for(let u=0,f=c.length;u<f;u+=4)if(c[u]>0){o=oe-Math.floor(u/4/oe);break}i.canvas.width=i.canvas.height=0,i.font=n;const d=o?o/(o+l):_m;return r(this,hn).set(t,d),d},v(Mt,As),v(Mt,hn,new Map),v(Mt,cn,new Map),v(Mt,vi,null),v(Mt,xr,new Set),Mt);function wm(){uu("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:h,container:t,viewport:e,...s}=arguments[0],i=Object.keys(s);i.length>0&&q("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new Ql({textContentSource:h,container:t,viewport:e}),{textDivs:a,textContentItemsStr:o}=n;return{promise:n.render(),textDivs:a,textContentItemsStr:o}}function Em(){uu("`updateTextLayer`, please use `TextLayer` instead.")}class Ea{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(Ea.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 xm=65536,Sm=100,Cm=5e3,Tm=Jt?Hg:Sg,Pm=Jt?Bg:cu,Rm=Jt?Ng:xg,km=Jt?jg:du;function Lm(h={}){typeof h=="string"||h instanceof URL?h={url:h}:(h instanceof ArrayBuffer||ArrayBuffer.isView(h))&&(h={data:h});const t=new Sc,{docId:e}=t,s=h.url?Mm(h.url):null,i=h.data?Im(h.data):null,n=h.httpHeaders||null,a=h.withCredentials===!0,o=h.password??null,l=h.range instanceof ef?h.range:null,c=Number.isInteger(h.rangeChunkSize)&&h.rangeChunkSize>0?h.rangeChunkSize:xm;let d=h.worker instanceof er?h.worker:null;const u=h.verbosity,f=typeof h.docBaseUrl=="string"&&!pd(h.docBaseUrl)?h.docBaseUrl:null,p=typeof h.cMapUrl=="string"?h.cMapUrl:null,g=h.cMapPacked!==!1,A=h.CMapReaderFactory||Pm,_=typeof h.standardFontDataUrl=="string"?h.standardFontDataUrl:null,y=h.StandardFontDataFactory||km,w=h.stopAtErrors!==!0,E=Number.isInteger(h.maxImageSize)&&h.maxImageSize>-1?h.maxImageSize:-1,x=h.isEvalSupported!==!1,S=typeof h.isOffscreenCanvasSupported=="boolean"?h.isOffscreenCanvasSupported:!Jt,C=Number.isInteger(h.canvasMaxAreaInBytes)?h.canvasMaxAreaInBytes:-1,T=typeof h.disableFontFace=="boolean"?h.disableFontFace:Jt,R=h.fontExtraProperties===!0,M=h.enableXfa===!0,B=h.ownerDocument||globalThis.document,I=h.disableRange===!0,$=h.disableStream===!0,V=h.disableAutoFetch===!0,W=h.pdfBug===!0,X=h.enableHWA===!0,Q=l?l.length:h.length??NaN,D=typeof h.useSystemFonts=="boolean"?h.useSystemFonts:!Jt&&!T,O=typeof h.useWorkerFetch=="boolean"?h.useWorkerFetch:A===cu&&y===du&&p&&_&&la(p,document.baseURI)&&la(_,document.baseURI),pe=h.canvasFactory||new Tm({ownerDocument:B,enableHWA:X}),Re=h.filterFactory||new Rm({docId:e,ownerDocument:B}),ni=null;fg(u);const At={canvasFactory:pe,filterFactory:Re};if(O||(At.cMapReaderFactory=new A({baseUrl:p,isCompressed:g}),At.standardFontDataFactory=new y({baseUrl:_})),!d){const ge={verbosity:u,port:Js.workerPort};d=ge.port?er.fromPort(ge):new er(ge),t._worker=d}const pt={docId:e,apiVersion:"4.4.168",data:i,password:o,disableAutoFetch:V,rangeChunkSize:c,length:Q,docBaseUrl:f,enableXfa:M,evaluatorOptions:{maxImageSize:E,disableFontFace:T,ignoreErrors:w,isEvalSupported:x,isOffscreenCanvasSupported:S,canvasMaxAreaInBytes:C,fontExtraProperties:R,useSystemFonts:D,cMapUrl:O?p:null,standardFontDataUrl:O?_:null}},ke={disableFontFace:T,fontExtraProperties:R,ownerDocument:B,pdfBug:W,styleElement:ni,loadingParams:{disableAutoFetch:V,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 ge=d.messageHandler.sendWithPromise("GetDocRequest",pt,i?[i.buffer]:null);let Zt;if(l)Zt=new im(l,{disableRange:I,disableStream:$});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");Zt=(ae=>Jt?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&la(ae.url)?new jd(ae):new gm(ae):la(ae.url)?new jd(ae):new dm(ae))({url:s,length:Q,httpHeaders:n,withCredentials:a,rangeChunkSize:c,disableRange:I,disableStream:$})}return ge.then(ft=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const ae=new da(e,ft,d.port),ts=new Nm(ae,t,Zt,ke,At);t._transport=ts,ae.send("Ready",null)})}).catch(t._capability.reject),t}function Mm(h){if(h instanceof URL)return h.href;try{return new URL(h,window.location).href}catch{if(Jt&&typeof h=="string")return h}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Im(h){if(Jt&&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 Ch(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 Wd(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 uh;const fh=class fh{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${me(fh,uh)._++}`,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)}};uh=new WeakMap,v(fh,uh,0);let Sc=fh,ef=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){at("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Dm{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 tt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Ai,Ns,Ne,Kn,Tl;class Fm{constructor(t,e,s,i=!1){v(this,Ne);v(this,Ai,null);v(this,Ns,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Td:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new sf,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 il({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return tt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=hi.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:d=null}){var E,x;(E=this._stats)==null||E.time("Overall");const u=this._transport.getRenderingIntent(s,i,d),{renderingIntent:f,cacheKey:p}=u;m(this,Ns,!1),b(this,Ne,Tl).call(this),o||(o=this._transport.getOptionalContentConfig(f));let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const A=!!(f&Oe.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(x=this._stats)==null||x.time("Page Request"),this._pumpOperatorList(u));const _=S=>{var C;g.renderTasks.delete(y),(this._maybeCleanupAfterRender||A)&&m(this,Ns,!0),b(this,Ne,Kn).call(this,!A),S?(y.capability.reject(S),this._abortOperatorList({intentState:g,reason:S instanceof Error?S:new Error(S)})):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 Tc({callback:_,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:c});(g.renderTasks||(g.renderTasks=new Set)).add(y);const w=y.task;return Promise.all([g.displayReadyCapability.promise,o]).then(([S,C])=>{var T;if(this.destroyed){_();return}if((T=this._stats)==null||T.time("Rendering"),!(C.renderingIntent&f))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:S,optionalContentConfig:C}),y.operatorListChanged()}).catch(_),w}getOperatorList({intent:t="display",annotationMode:e=hi.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=>Ea.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,Ns,!1),b(this,Ne,Tl).call(this),Promise.all(t)}cleanup(t=!1){m(this,Ns,!0);const e=b(this,Ne,Kn).call(this,!1);return t&&e&&this._stats&&(this._stats=new Td),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,Ne,Kn).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,Ne,Kn).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 fd){let i=Sm;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 $n(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}}Ai=new WeakMap,Ns=new WeakMap,Ne=new WeakSet,Kn=function(t=!1){if(b(this,Ne,Tl).call(this),!r(this,Ns)||this.destroyed)return!1;if(t)return m(this,Ai,setTimeout(()=>{m(this,Ai,null),b(this,Ne,Kn).call(this,!1)},Cm)),!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,Ns,!1),!0},Tl=function(){r(this,Ai)&&(clearTimeout(r(this,Ai)),m(this,Ai,null))};var dn,ph;class Om{constructor(){v(this,dn,new Set);v(this,ph,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};r(this,ph).then(()=>{for(const i of r(this,dn))i.call(this,s)})}addEventListener(t,e){r(this,dn).add(e)}removeEventListener(t,e){r(this,dn).delete(e)}terminate(){r(this,dn).clear()}}dn=new WeakMap,ph=new WeakMap;const Ts={isWorkerDisabled:!1,fakeWorkerId:0};Jt&&(Ts.isWorkerDisabled=!0,Js.workerSrc||(Js.workerSrc="./pdf.worker.mjs")),Ts.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},Ts.createCDNWrapper=function(h){const t=`await import("${h}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};var un,Sr,Pl,Cr,Rl;const ve=class ve{constructor({name:t=null,port:e=null,verbosity:s=pg()}={}){v(this,Sr);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(ve,un))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(r(ve,un)||m(ve,un,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return Jt?Promise.all([ys.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 da("main","worker",t),this._messageHandler.on("ready",function(){}),b(this,Sr,Pl).call(this)}_initialize(){if(Ts.isWorkerDisabled||r(ve,Cr,Rl)){this._setupFakeWorker();return}let{workerSrc:t}=ve;try{Ts.isSameOrigin(window.location.href,t)||(t=Ts.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new da("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",o=>{if(n.abort(),this.destroyed||!o){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,b(this,Sr,Pl).call(this)}),s.on("ready",o=>{if(n.abort(),this.destroyed){i();return}try{a()}catch{this._setupFakeWorker()}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{xh("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Ts.isWorkerDisabled||(q("Setting up fake worker."),Ts.isWorkerDisabled=!0),ve._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new Om;this._port=e;const s=`fake${Ts.fakeWorkerId++}`,i=new da(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new da(s,s+"_worker",e),b(this,Sr,Pl).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(t=r(ve,un))==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,un))==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 ve(t)}static get workerSrc(){if(Js.workerSrc)return Js.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return tt(this,"_setupFakeWorkerGlobal",(async()=>r(this,Cr,Rl)?r(this,Cr,Rl):(await import(this.workerSrc)).WorkerMessageHandler)())}};un=new WeakMap,Sr=new WeakSet,Pl=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Cr=new WeakSet,Rl=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},v(ve,Cr),v(ve,un);let er=ve;var Hs,ls,Tr,Pr,hs,fn,ua;class Nm{constructor(t,e,s,i,n){v(this,fn);v(this,Hs,new Map);v(this,ls,new Map);v(this,Tr,new Map);v(this,Pr,new Map);v(this,hs,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new sf,this.fontLoader=new Fg({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return tt(this,"annotationStorage",new bd)}getRenderingIntent(t,e=hi.ENABLE,s=null,i=!1){let n=Oe.DISPLAY,a=bc;switch(t){case"any":n=Oe.ANY;break;case"display":break;case"print":n=Oe.PRINT;break;default:q(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case hi.DISABLE:n+=Oe.ANNOTATIONS_DISABLE;break;case hi.ENABLE:break;case hi.ENABLE_FORMS:n+=Oe.ANNOTATIONS_FORMS;break;case hi.ENABLE_STORAGE:n+=Oe.ANNOTATIONS_STORAGE,a=(n&Oe.PRINT&&s instanceof ju?s:this.annotationStorage).serializable;break;default:q(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=Oe.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,hs))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of r(this,ls).values())t.push(i._destroy());r(this,ls).clear(),r(this,Tr).clear(),r(this,Pr).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,Hs).clear(),this.filterFactory.destroy(),Ql.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new $n("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)=>{It(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}It(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)=>{It(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}It(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 Dm(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Xh(s.message,s.code);break;case"InvalidPDFException":i=new au(s.message);break;case"MissingPDFException":i=new Un(s.message);break;case"UnexpectedResponseException":i=new Sh(s.message,s.status);break;case"UnknownErrorException":i=new Yh(s.message,s.details);break;default:at("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(m(this,hs,Promise.withResolvers()),e.onPassword){const i=n=>{n instanceof Error?r(this,hs).reject(n):r(this,hs).resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){r(this,hs).reject(n)}}else r(this,hs).reject(new Xh(s.message,s.code));return r(this,hs).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,ls).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 p=n.error;q(`Error during font loading: ${p}`),this.commonObjs.resolve(s,p);break}const d=c&&((a=globalThis.FontInspector)!=null&&a.enabled)?(p,g)=>globalThis.FontInspector.fontAdded(p,g):null,u=new Og(n,{disableFontFace:o,inspectFont:d});this.fontLoader.bind(u).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&u.data&&(u.data=null),this.commonObjs.resolve(s,u)});break;case"CopyLocalImage":const{imageRef:f}=n;It(f,"The imageRef must be defined.");for(const p of r(this,ls).values())for(const[,g]of p.objs)if((g==null?void 0:g.ref)===f)return g.dataLen?(this.commonObjs.resolve(s,structuredClone(g)),g.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,ls).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)>hg&&(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&&q("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,Tr).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,Pr).set(n.refStr,t);const a=new Fm(e,n,this,this._params.pdfBug);return r(this,ls).set(e,a),a});return r(this,Tr).set(e,i),i}getPageIndex(t){return Wd(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,fn,ua).call(this,"GetFieldObjects")}hasJSActions(){return b(this,fn,ua).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,fn,ua).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,fn,ua).call(this,"GetOptionalContentConfig").then(e=>new sm(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=r(this,Hs).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 tm(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,Hs).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,ls).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),r(this,Hs).clear(),this.filterFactory.destroy(!0),Ql.cleanup()}}cachedPageNumber(t){if(!Wd(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return r(this,Pr).get(e)??null}}Hs=new WeakMap,ls=new WeakMap,Tr=new WeakMap,Pr=new WeakMap,hs=new WeakMap,fn=new WeakSet,ua=function(t,e=null){const s=r(this,Hs).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return r(this,Hs).set(t,i),i};const ml=Symbol("INITIAL_DATA");var Ve,po,Cc;class sf{constructor(){v(this,po);v(this,Ve,Object.create(null))}get(t,e=null){if(e){const i=b(this,po,Cc).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=r(this,Ve)[t];if(!s||s.data===ml)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=r(this,Ve)[t];return!!e&&e.data!==ml}resolve(t,e=null){const s=b(this,po,Cc).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in r(this,Ve)){const{data:s}=r(this,Ve)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}m(this,Ve,Object.create(null))}*[Symbol.iterator](){for(const t in r(this,Ve)){const{data:e}=r(this,Ve)[t];e!==ml&&(yield[t,e])}}}Ve=new WeakMap,po=new WeakSet,Cc=function(t){var e;return(e=r(this,Ve))[t]||(e[t]={...Promise.withResolvers(),data:ml})};var yi;class Hm{constructor(t){v(this,yi,null);m(this,yi,t),this.onContinue=null}get promise(){return r(this,yi).capability.promise}cancel(t=0){r(this,yi).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=r(this,yi).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=r(this,yi);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}yi=new WeakMap;var _i,pn;const ji=class ji{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:d=!1,pdfBug:u=!1,pageColors:f=null}){v(this,_i,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Hm(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(ji,pn).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(ji,pn).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 tr(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(t=null,e=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),r(this,_i)&&(window.cancelAnimationFrame(r(this,_i)),m(this,_i,null)),r(ji,pn).delete(this._canvas),this.callback(t||new fd(`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?m(this,_i,window.requestAnimationFrame(()=>{m(this,_i,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),r(ji,pn).delete(this._canvas),this.callback())))}};_i=new WeakMap,pn=new WeakMap,v(ji,pn,new WeakSet);let Tc=ji;const Bm="4.4.168",jm="19fbc8998";function zd(h){return Math.floor(Math.max(0,Math.min(1,h))*255).toString(16).padStart(2,"0")}function na(h){return Math.max(0,Math.min(255,255*h))}class Ud{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=na(t),[t,t,t]}static G_HTML([t]){const e=zd(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(na)}static RGB_HTML(t){return`#${t.map(zd).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[na(1-Math.min(1,t+i)),na(1-Math.min(1,s+i)),na(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 nf{static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,c]of Object.entries(a))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}o&&n.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var u,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:n,linkService:s});const o=n!=="richText",l=t.div;if(l.append(a),t.viewport){const p=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=p}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const p=document.createTextNode(i.value);a.append(p),o&&Ea.shouldBuildText(i.name)&&c.push(p)}return{textDivs:c}}const d=[[i,-1,a]];for(;d.length>0;){const[p,g,A]=d.at(-1);if(g+1===p.children.length){d.pop();continue}const _=p.children[++d.at(-1)[1]];if(_===null)continue;const{name:y}=_;if(y==="#text"){const E=document.createTextNode(_.value);c.push(E),A.append(E);continue}const w=(u=_==null?void 0:_.attributes)!=null&&u.xmlns?document.createElementNS(_.attributes.xmlns,y):document.createElement(y);if(A.append(w),_.attributes&&this.setAttributes({html:w,element:_,storage:e,intent:n,linkService:s}),((f=_.children)==null?void 0:f.length)>0)d.push([_,-1,w]);else if(_.value){const E=document.createTextNode(_.value);o&&Ea.shouldBuildText(y)&&c.push(E),w.append(E)}}for(const p of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))p.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 al=1e3,Wm=9,Bn=new WeakSet;function Zs(h){return{width:h[2]-h[0],height:h[3]-h[1]}}class zm{static create(t){switch(t.data.annotationType){case Ct.LINK:return new rf(t);case Ct.TEXT:return new Um(t);case Ct.WIDGET:switch(t.data.fieldType){case"Tx":return new $m(t);case"Btn":return t.data.radioButton?new lf(t):t.data.checkBox?new Vm(t):new qm(t);case"Ch":return new Xm(t);case"Sig":return new Gm(t)}return new Gn(t);case Ct.POPUP:return new Rc(t);case Ct.FREETEXT:return new ff(t);case Ct.LINE:return new Km(t);case Ct.SQUARE:return new Qm(t);case Ct.CIRCLE:return new Jm(t);case Ct.POLYLINE:return new pf(t);case Ct.CARET:return new tb(t);case Ct.INK:return new gf(t);case Ct.POLYGON:return new Zm(t);case Ct.HIGHLIGHT:return new eb(t);case Ct.UNDERLINE:return new sb(t);case Ct.SQUIGGLY:return new ib(t);case Ct.STRIKEOUT:return new nb(t);case Ct.STAMP:return new mf(t);case Ct.FILEATTACHMENT:return new rb(t);default:return new _t(t)}}}var gn,Rr,kr,go,Pc;const xd=class xd{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){v(this,go);v(this,gn,null);v(this,Rr,!1);v(this,kr,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 xd._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;r(this,gn)||m(this,gn,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&b(this,go,Pc).call(this,e),(s=r(this,kr))==null||s.popup.updateEdited(t)}resetEdited(){var t;r(this,gn)&&(b(this,go,Pc).call(this,r(this,gn).rect),(t=r(this,kr))==null||t.popup.resetEdited(),m(this,gn,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 Gn||(n.tabIndex=al);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 Rc){const{rotation:A}=e;return!e.hasOwnCanvas&&A!==0&&this.setRotation(A,n),n}const{width:o,height:l}=Zs(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const A=e.borderStyle.horizontalCornerRadius,_=e.borderStyle.verticalCornerRadius;if(A>0||_>0){const w=`calc(${A}px * var(--scale-factor)) / calc(${_}px * var(--scale-factor))`;a.borderRadius=w}else if(this instanceof lf){const w=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=w}switch(e.borderStyle.style){case sa.SOLID:a.borderStyle="solid";break;case sa.DASHED:a.borderStyle="dashed";break;case sa.BEVELED:q("Unimplemented border style: beveled");break;case sa.INSET:q("Unimplemented border style: inset");break;case sa.UNDERLINE:a.borderBottomStyle="solid";break}const y=e.borderColor||null;y?(m(this,Rr,!0),a.borderColor=H.makeHexColor(y[0]|0,y[1]|0,y[2]|0)):a.borderWidth=0}const c=H.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:d,pageHeight:u,pageX:f,pageY:p}=i.rawDims;a.left=`${100*(c[0]-f)/d}%`,a.top=`${100*(c[1]-p)/u}%`;const{rotation:g}=e;return e.hasOwnCanvas||g===0?(a.width=`${100*o/d}%`,a.height=`${100*l/u}%`):this.setRotation(g,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}=Zs(this.data.rect);let o,l;t%180===0?(o=100*n/s,l=100*a/i):(o=100*a/s,l=100*n/i),e.style.width=`${o}%`,e.style.height=`${l}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],a=n[0],o=n.slice(1);i.target.style[s]=Ud[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Ud[`${a}_rgb`](o)})};return tt(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];n==null||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:n},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(A=>Math.fround(A));if(t.length===8){const[A,_,y,w]=t.subarray(2,6);if(i===A&&n===_&&e===y&&s===w)return}const{style:a}=this.container;let o;if(r(this,Rr)){const{borderColor:A,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="${A}" stroke-width="${_}">`],this.container.classList.add("hasBorder")}const l=i-e,c=n-s,{svgFactory:d}=this,u=d.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const f=d.createElement("defs");u.append(f);const p=d.createElement("clipPath"),g=`clippath_${this.data.id}`;p.setAttribute("id",g),p.setAttribute("clipPathUnits","objectBoundingBox"),f.append(p);for(let A=2,_=t.length;A<_;A+=8){const y=t[A],w=t[A+1],E=t[A+2],x=t[A+3],S=d.createElement("rect"),C=(E-e)/l,T=(n-w)/c,R=(y-E)/l,M=(w-x)/c;S.setAttribute("x",C),S.setAttribute("y",T),S.setAttribute("width",R),S.setAttribute("height",M),p.append(S),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${C}" y="${T}" width="${R}" height="${M}"/>`)}r(this,Rr)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${g})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=m(this,kr,new Rc({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(){at("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&&!Bn.has(c)){q(`_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&&Bn.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})})}};gn=new WeakMap,Rr=new WeakMap,kr=new WeakMap,go=new WeakSet,Pc=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}=Zs(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 _t=xd;var Te,Oi,af,of;class rf extends _t{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});v(this,Te);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,Te,af).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(b(this,Te,of).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,Te,Oi).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),b(this,Te,Oi).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,Te,Oi).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,Te,Oi).call(this),!this._fieldObjects){q('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var u;i==null||i();const{fields:n,refs:a,include:o}=s,l=[];if(n.length!==0||a.length!==0){const f=new Set(a);for(const p of n){const g=this._fieldObjects[p]||[];for(const{id:A}of g)f.add(A)}for(const p of Object.values(this._fieldObjects))for(const g of p)f.has(g.id)===o&&l.push(g)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const c=this.annotationStorage,d=[];for(const f of l){const{id:p}=f;switch(d.push(p),f.type){case"text":{const A=f.defaultValue||"";c.setValue(p,{value:A});break}case"checkbox":case"radiobutton":{const A=f.defaultValue===f.exportValues;c.setValue(p,{value:A});break}case"combobox":case"listbox":{const A=f.defaultValue||"";c.setValue(p,{value:A});break}default:continue}const g=document.querySelector(`[data-element-id="${p}"]`);if(g){if(!Bn.has(g)){q(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;g.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}}}Te=new WeakSet,Oi=function(){this.container.setAttribute("data-internal-link","")},af=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,Te,Oi).call(this)},of=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),b(this,Te,Oi).call(this)};class Um extends _t{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 Gn extends _t{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return de.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a)}}))})}_setEventListeners(t,e,s,i){var n,a,o;for(const[l,c]of s)(c==="Action"||(n=this.data.actions)!=null&&n[c])&&((c==="Focus"||c==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,c,i),c==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":H.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Wm,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/(Hh*i))||1,u=c/d;a=Math.min(i,l(u/Hh))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/Hh))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=H.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 $m extends Gn{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),Bn.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=al,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",f=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),d.formattedValue=null}),s.addEventListener("resetform",f=>{const p=this.data.defaultFieldValue??"";s.value=d.userValue=p,d.formattedValue=null});let u=f=>{const{formattedValue:p}=d;p!=null&&(f.target.value=p),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",p=>{var A;if(d.focused)return;const{target:g}=p;d.userValue&&(g.value=d.userValue),d.lastCommittedValue=g.value,d.commitKey=1,(A=this.data.actions)!=null&&A.Focus||(d.focused=!0)}),s.addEventListener("updatefromsandbox",p=>{this.showElementAndHideCanvas(p.target);const g={value(A){d.userValue=A.detail.value??"",t.setValue(e,{value:d.userValue.toString()}),A.target.value=d.userValue},formattedValue(A){const{formattedValue:_}=A.detail;d.formattedValue=_,_!=null&&A.target!==document.activeElement&&(A.target.value=_),t.setValue(e,{formattedValue:_})},selRange(A){A.target.setSelectionRange(...A.detail.selRange)},charLimit:A=>{var E;const{charLimit:_}=A.detail,{target:y}=A;if(_===0){y.removeAttribute("maxLength");return}y.setAttribute("maxLength",_);let w=d.userValue;!w||w.length<=_||(w=w.slice(0,_),y.value=d.userValue=w,t.setValue(e,{value:w}),(E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,willCommit:!0,commitKey:1,selStart:y.selectionStart,selEnd:y.selectionEnd}}))}};this._dispatchEventFromSandbox(g,p)}),s.addEventListener("keydown",p=>{var _;d.commitKey=1;let g=-1;if(p.key==="Escape"?g=0:p.key==="Enter"&&!this.data.multiLine?g=2:p.key==="Tab"&&(d.commitKey=3),g===-1)return;const{value:A}=p.target;d.lastCommittedValue!==A&&(d.lastCommittedValue=A,d.userValue=A,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:g,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}}))});const f=u;u=null,s.addEventListener("blur",p=>{var A,_;if(!d.focused||!p.relatedTarget)return;(A=this.data.actions)!=null&&A.Blur||(d.focused=!1);const{value:g}=p.target;d.userValue=g,d.lastCommittedValue!==g&&((_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:g,willCommit:!0,commitKey:d.commitKey,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}})),f(p)}),(n=this.data.actions)!=null&&n.Keystroke&&s.addEventListener("beforeinput",p=>{var S;d.lastCommittedValue=null;const{data:g,target:A}=p,{value:_,selectionStart:y,selectionEnd:w}=A;let E=y,x=w;switch(p.inputType){case"deleteWordBackward":{const C=_.substring(0,y).match(/\w*[^\w]*$/);C&&(E-=C[0].length);break}case"deleteWordForward":{const C=_.substring(y).match(/^[^\w]*\w*/);C&&(x+=C[0].length);break}case"deleteContentBackward":y===w&&(E-=1);break;case"deleteContentForward":y===w&&(x+=1);break}p.preventDefault(),(S=this.linkService.eventBus)==null||S.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:g||"",willCommit:!1,selStart:E,selEnd:x}})}),this._setEventListeners(s,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],p=>p.target.value)}if(u&&s.addEventListener("blur",u),this.data.comb){const p=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${p}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 Gm extends Gn{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Vm extends Gn{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 Bn.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=al,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 lf extends Gn{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(Bn.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=al,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;n.addEventListener("updatefromsandbox",o=>{const l={value:c=>{const d=a===c.detail.value;for(const u of this._getElementsByName(c.target.name)){const f=d&&u.id===s;u.domElement&&(u.domElement.checked=f),t.setValue(u.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class qm extends rf{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 Xm extends Gn{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");Bn.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=al;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const u=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===u});for(const d of this.data.options){const u=document.createElement("option");u.textContent=d.displayValue,u.value=d.exportValue,s.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),n=!1),i.append(u)}let a=null;if(n){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),a=()=>{d.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=d=>{const u=d?"value":"textContent",{options:f,multiple:p}=i;return p?Array.prototype.filter.call(f,g=>g.selected).map(g=>g[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const c=d=>{const u=d.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const u={value(f){a==null||a();const p=f.detail.value,g=new Set(Array.isArray(p)?p:[p]);for(const A of i.options)A.selected=g.has(A.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const p=i.options,g=f.detail.remove;p[g].selected=!1,i.remove(g),p.length>0&&Array.prototype.findIndex.call(p,_=>_.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(f){const{index:p,displayValue:g,exportValue:A}=f.detail.insert,_=i.children[p],y=document.createElement("option");y.textContent=g,y.value=A,_?_.before(y):i.append(y),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},items(f){const{items:p}=f.detail;for(;i.length!==0;)i.remove(0);for(const g of p){const{displayValue:A,exportValue:_}=g,y=document.createElement("option");y.textContent=A,y.value=_,i.append(y)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},indices(f){const p=new Set(f.detail.indices);for(const g of f.target.options)g.selected=p.has(g.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,d)}),i.addEventListener("input",d=>{var p;const u=o(!0),f=o(!1);t.setValue(e,{value:u}),d.preventDefault(),(p=this.linkService.eventBus)==null||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:f,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Rc extends _t{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:_t._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Ym({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=>`${lu}${s}`).join(",")),this.container}}var Lr,gh,mh,Mr,mn,vt,Bs,bn,mo,bo,Ir,js,qe,Ws,vo,zs,Ao,vn,An,ot,kl,kc,hf,cf,df,uf,Ll,Ml,Lc;class Ym{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:o,parent:l,rect:c,parentRect:d,open:u}){v(this,ot);v(this,Lr,b(this,ot,df).bind(this));v(this,gh,b(this,ot,Lc).bind(this));v(this,mh,b(this,ot,Ml).bind(this));v(this,Mr,b(this,ot,Ll).bind(this));v(this,mn,null);v(this,vt,null);v(this,Bs,null);v(this,bn,null);v(this,mo,null);v(this,bo,null);v(this,Ir,null);v(this,js,!1);v(this,qe,null);v(this,Ws,null);v(this,vo,null);v(this,zs,null);v(this,Ao,null);v(this,vn,null);v(this,An,!1);var f;m(this,vt,t),m(this,Ao,i),m(this,Bs,a),m(this,zs,o),m(this,bo,l),m(this,mn,e),m(this,vo,c),m(this,Ir,d),m(this,mo,s),m(this,bn,fu.toDateObject(n)),this.trigger=s.flatMap(p=>p.getElementsToTriggerPopup());for(const p of this.trigger)p.addEventListener("click",r(this,Mr)),p.addEventListener("mouseenter",r(this,mh)),p.addEventListener("mouseleave",r(this,gh)),p.classList.add("popupTriggerArea");for(const p of s)(f=p.container)==null||f.addEventListener("keydown",r(this,Lr));r(this,vt).hidden=!0,u&&b(this,ot,Ll).call(this)}render(){if(r(this,qe))return;const t=m(this,qe,document.createElement("div"));if(t.className="popup",r(this,mn)){const n=t.style.outlineColor=H.makeHexColor(...r(this,mn));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=H.makeHexColor(...r(this,mn).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,Ao),t.append(e),r(this,bn)){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,bn).toLocaleDateString(),time:r(this,bn).toLocaleTimeString()})),e.append(n)}const i=r(this,ot,kl);if(i)nf.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(r(this,Bs));t.append(n)}r(this,vt).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,vn)||m(this,vn,{contentsObj:r(this,Bs),richText:r(this,zs)}),t&&m(this,Ws,null),e&&(m(this,zs,b(this,ot,cf).call(this,e)),m(this,Bs,null)),(s=r(this,qe))==null||s.remove(),m(this,qe,null)}resetEdited(){var t;r(this,vn)&&({contentsObj:me(this,Bs)._,richText:me(this,zs)._}=r(this,vn),m(this,vn,null),(t=r(this,qe))==null||t.remove(),m(this,qe,null),m(this,Ws,null))}forceHide(){m(this,An,this.isVisible),r(this,An)&&(r(this,vt).hidden=!0)}maybeShow(){r(this,An)&&(r(this,qe)||b(this,ot,Ml).call(this),m(this,An,!1),r(this,vt).hidden=!1)}get isVisible(){return r(this,vt).hidden===!1}}Lr=new WeakMap,gh=new WeakMap,mh=new WeakMap,Mr=new WeakMap,mn=new WeakMap,vt=new WeakMap,Bs=new WeakMap,bn=new WeakMap,mo=new WeakMap,bo=new WeakMap,Ir=new WeakMap,js=new WeakMap,qe=new WeakMap,Ws=new WeakMap,vo=new WeakMap,zs=new WeakMap,Ao=new WeakMap,vn=new WeakMap,An=new WeakMap,ot=new WeakSet,kl=function(){const t=r(this,zs),e=r(this,Bs);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&r(this,zs).html||null},kc=function(){var t,e,s;return((s=(e=(t=r(this,ot,kl))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},hf=function(){var t,e,s;return((s=(e=(t=r(this,ot,kl))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},cf=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:r(this,ot,hf),fontSize:r(this,ot,kc)?`calc(${r(this,ot,kc)}px * var(--scale-factor))`:""}};for(const n of t.split(`
`))e.push({name:"span",value:n,attributes:i});return s},df=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&r(this,js))&&b(this,ot,Ll).call(this)},uf=function(){if(r(this,Ws)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=r(this,bo);let a=!!r(this,Ir),o=a?r(this,Ir):r(this,vo);for(const g of r(this,mo))if(!o||H.intersect(g.data.rect,o)!==null){o=g.data.rect,a=!0;break}const l=H.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),d=a?o[2]-o[0]+5:0,u=l[0]+d,f=l[1];m(this,Ws,[100*(u-i)/e,100*(f-n)/s]);const{style:p}=r(this,vt);p.left=`${r(this,Ws)[0]}%`,p.top=`${r(this,Ws)[1]}%`},Ll=function(){m(this,js,!r(this,js)),r(this,js)?(b(this,ot,Ml).call(this),r(this,vt).addEventListener("click",r(this,Mr)),r(this,vt).addEventListener("keydown",r(this,Lr))):(b(this,ot,Lc).call(this),r(this,vt).removeEventListener("click",r(this,Mr)),r(this,vt).removeEventListener("keydown",r(this,Lr)))},Ml=function(){r(this,qe)||this.render(),this.isVisible?r(this,js)&&r(this,vt).classList.add("focused"):(b(this,ot,uf).call(this),r(this,vt).hidden=!1,r(this,vt).style.zIndex=parseInt(r(this,vt).style.zIndex)+1e3)},Lc=function(){r(this,vt).classList.remove("focused"),!(r(this,js)||!this.isVisible)&&(r(this,vt).hidden=!0,r(this,vt).style.zIndex=parseInt(r(this,vt).style.zIndex)-1e3)};class ff extends _t{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Z.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 yo;class Km extends _t{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,yo,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:s,height:i}=Zs(e.rect),n=this.svgFactory.create(s,i,!0),a=m(this,yo,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,yo)}addHighlightArea(){this.container.classList.add("highlightArea")}}yo=new WeakMap;var _o;class Qm extends _t{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,_o,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:s,height:i}=Zs(e.rect),n=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=m(this,_o,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,_o)}addHighlightArea(){this.container.classList.add("highlightArea")}}_o=new WeakMap;var wo;class Jm extends _t{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,wo,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:s,height:i}=Zs(e.rect),n=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=m(this,wo,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,wo)}addHighlightArea(){this.container.classList.add("highlightArea")}}wo=new WeakMap;var Eo;class pf extends _t{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,Eo,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:n}}=this;if(!s)return this.container;const{width:a,height:o}=Zs(e),l=this.svgFactory.create(a,o,!0);let c=[];for(let u=0,f=s.length;u<f;u+=2){const p=s[u]-e[0],g=e[3]-s[u+1];c.push(`${p},${g}`)}c=c.join(" ");const d=m(this,Eo,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",c),d.setAttribute("stroke-width",i.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),l.append(d),this.container.append(l),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return r(this,Eo)}addHighlightArea(){this.container.classList.add("highlightArea")}}Eo=new WeakMap;class Zm extends pf{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class tb extends _t{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 xo;class gf extends _t{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,xo,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=Z.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,inkLists:s,borderStyle:i,popupRef:n}}=this,{width:a,height:o}=Zs(e),l=this.svgFactory.create(a,o,!0);for(const c of s){let d=[];for(let f=0,p=c.length;f<p;f+=2){const g=c[f]-e[0],A=e[3]-c[f+1];d.push(`${g},${A}`)}d=d.join(" ");const u=this.svgFactory.createElement(this.svgElementName);r(this,xo).push(u),u.setAttribute("points",d),u.setAttribute("stroke-width",i.width||1),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),!n&&this.hasPopupData&&this._createPopup(),l.append(u)}return this.container.append(l),this.container}getElementsToTriggerPopup(){return r(this,xo)}addHighlightArea(){this.container.classList.add("highlightArea")}}xo=new WeakMap;class eb extends _t{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 sb extends _t{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 ib extends _t{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 nb extends _t{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 mf extends _t{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 So,Co,Mc;class rb extends _t{constructor(e){var i;super(e,{isRenderable:!0});v(this,Co);v(this,So,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,Co,Mc).bind(this)),m(this,So,i);const{isMac:n}=de.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(n?a.metaKey:a.ctrlKey)&&b(this,Co,Mc).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return r(this,So)}addHighlightArea(){this.container.classList.add("highlightArea")}}So=new WeakMap,Co=new WeakSet,Mc=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var To,yn,Dr,Wn,bf,Ic,su;let ab=(su=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a}){v(this,Wn);v(this,To,null);v(this,yn,null);v(this,Dr,new Map);this.div=t,m(this,To,e),m(this,yn,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;Nn(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 ud,annotationStorage:t.annotationStorage||new bd,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===Ct.POPUP;if(l){const u=i.get(o.id);if(!u)continue;n.elements=u}else{const{width:u,height:f}=Zs(o.rect);if(u<=0||f<=0)continue}n.data=o;const c=zm.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,Wn,bf).call(this,d,o.id),c.annotationEditorType>0&&(r(this,Dr).set(c.data.id,c),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(c))}b(this,Wn,Ic).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,Nn(e,{rotation:t.rotation}),b(this,Wn,Ic).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(r(this,Dr).values())}getEditableAnnotation(t){return r(this,Dr).get(t)}},To=new WeakMap,yn=new WeakMap,Dr=new WeakMap,Wn=new WeakSet,bf=function(t,e){var i;const s=t.firstChild||t;s.id=`${lu}${e}`,this.div.append(t),(i=r(this,To))==null||i.moveElementInDOM(this.div,t,s,!1)},Ic=function(){if(!r(this,yn))return;const t=this.div;for(const[e,s]of r(this,yn)){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,yn).clear()},su);const bl=/\r\n?|\n/g;var Po,Ro,ko,Lo,Mo,Xe,we,Io,Ee,Fr,xt,vf,Af,yf,Il,ei,Dl,Fl,_f,Fc,wf;const ut=class ut extends nt{constructor(e){super({...e,name:"freeTextEditor"});v(this,xt);v(this,Po,this.editorDivBlur.bind(this));v(this,Ro,this.editorDivFocus.bind(this));v(this,ko,this.editorDivInput.bind(this));v(this,Lo,this.editorDivKeydown.bind(this));v(this,Mo,this.editorDivPaste.bind(this));v(this,Xe);v(this,we,"");v(this,Io,`${this.id}-editor`);v(this,Ee);v(this,Fr,null);m(this,Xe,e.color||ut._defaultColor||nt._defaultLineColor),m(this,Ee,e.fontSize||ut._defaultFontSize)}static get _keyboardManager(){const e=ut.prototype,s=a=>a.isEmpty(),i=Hn.TRANSLATE_SMALL,n=Hn.TRANSLATE_BIG;return tt(this,"_keyboardManager",new nl([[["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){nt.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 U.FREETEXT_SIZE:ut._defaultFontSize=s;break;case U.FREETEXT_COLOR:ut._defaultColor=s;break}}updateParams(e,s){switch(e){case U.FREETEXT_SIZE:b(this,xt,vf).call(this,s);break;case U.FREETEXT_COLOR:b(this,xt,Af).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[U.FREETEXT_SIZE,ut._defaultFontSize],[U.FREETEXT_COLOR,ut._defaultColor||nt._defaultLineColor]]}get propertiesToUpdate(){return[[U.FREETEXT_SIZE,r(this,Ee)],[U.FREETEXT_COLOR,r(this,Xe)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-ut._internalPadding*e,-(ut._internalPadding+r(this,Ee))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Z.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const e=this._uiManager._signal;this.editorDiv.addEventListener("keydown",r(this,Lo),{signal:e}),this.editorDiv.addEventListener("focus",r(this,Ro),{signal:e}),this.editorDiv.addEventListener("blur",r(this,Po),{signal:e}),this.editorDiv.addEventListener("input",r(this,ko),{signal:e}),this.editorDiv.addEventListener("paste",r(this,Mo),{signal:e})}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,Io)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",r(this,Lo)),this.editorDiv.removeEventListener("focus",r(this,Ro)),this.editorDiv.removeEventListener("blur",r(this,Po)),this.editorDiv.removeEventListener("input",r(this,ko)),this.editorDiv.removeEventListener("paste",r(this,Mo)),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,we),s=m(this,we,b(this,xt,yf).call(this).trimEnd());if(e===s)return;const i=n=>{if(m(this,we,n),!n){this.remove();return}b(this,xt,Fl).call(this),this._uiManager.rebuild(this),b(this,xt,Il).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,xt,Il).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){ut._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",r(this,Io)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),nt._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,Ee)}px * var(--scale-factor))`,i.color=r(this,Xe),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Xl(this,this.div,["dblclick","keydown"]),this.width){const[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=r(this,Fr);let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[d,u]=this.pageDimensions,[f,p]=this.pageTranslation;let g,A;switch(this.rotation){case 0:g=e+(o[0]-f)/d,A=s+this.height-(o[1]-p)/u;break;case 90:g=e+(o[0]-f)/d,A=s-(o[1]-p)/u,[l,c]=[c,-l];break;case 180:g=e-this.width+(o[0]-f)/d,A=s-(o[1]-p)/u,[l,c]=[-l,-c];break;case 270:g=e+(o[0]-f-this.height*u)/d,A=s+(o[1]-p-this.width*d)/u,[l,c]=[-c,l];break}this.setAt(g*n,A*a,l,c)}else this.setAt(e*n,s*a,this.width*n,this.height*a);b(this,xt,Fl).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var g,A,_;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=b(g=ut,ei,Fc).call(g,s.getData("text")||"").replaceAll(bl,`
`);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(bl,"")),y!==this.editorDiv){let w=d;for(const E of this.editorDiv.childNodes){if(E===y){w=u;continue}w.push(b(A=ut,ei,Dl).call(A,E))}}d.push(l.nodeValue.slice(0,c).replaceAll(bl,""))}else if(l===this.editorDiv){let y=d,w=0;for(const E of this.editorDiv.childNodes)w++===c&&(y=u),y.push(b(_=ut,ei,Dl).call(_,E))}m(this,we,`${d.join(`
`)}${n}${u.join(`
`)}`),b(this,xt,Fl).call(this);const f=new Range;let p=d.reduce((y,w)=>y+w.length,0);for(const{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){const w=y.nodeValue.length;if(p<=w){f.setStart(y,p),f.setEnd(y,p);break}p-=w}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}static deserialize(e,s,i){var o;let n=null;if(e instanceof ff){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:d,rotation:u,id:f},textContent:p,textPosition:g,parent:{page:{pageNumber:A}}}=e;if(!p||p.length===0)return null;n=e={annotationType:Z.FREETEXT,color:Array.from(c),fontSize:l,value:p.join(`
`),position:g,pageIndex:A-1,rect:d.slice(0),rotation:u,id:f,deleted:!1}}const a=super.deserialize(e,s,i);return m(a,Ee,e.fontSize),m(a,Xe,H.makeHexColor(...e.color)),m(a,we,b(o=ut,ei,Fc).call(o,e.value)),a.annotationElementId=e.id||null,m(a,Fr,n),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const s=ut._internalPadding*this.parentScale,i=this.getRect(s,s),n=nt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:r(this,Xe)),a={annotationType:Z.FREETEXT,color:n,fontSize:r(this,Ee),value:b(this,xt,_f).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!b(this,xt,wf).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,Ee)}px * var(--scale-factor))`,i.color=r(this,Xe),s.replaceChildren();for(const a of r(this,we).split(`
`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const n=ut._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(n,n),popupContent:r(this,we)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};Po=new WeakMap,Ro=new WeakMap,ko=new WeakMap,Lo=new WeakMap,Mo=new WeakMap,Xe=new WeakMap,we=new WeakMap,Io=new WeakMap,Ee=new WeakMap,Fr=new WeakMap,xt=new WeakSet,vf=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-r(this,Ee))*this.parentScale),m(this,Ee,n),b(this,xt,Il).call(this)},i=r(this,Ee);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Af=function(e){const s=n=>{m(this,Xe,this.editorDiv.style.color=n)},i=r(this,Xe);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},yf=function(){var s;const e=[];this.editorDiv.normalize();for(const i of this.editorDiv.childNodes)e.push(b(s=ut,ei,Dl).call(s,i));return e.join(`
`)},Il=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()},ei=new WeakSet,Dl=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(bl,"")},Fl=function(){if(this.editorDiv.replaceChildren(),!!r(this,we))for(const e of r(this,we).split(`
`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},_f=function(){return r(this,we).replaceAll(" "," ")},Fc=function(e){return e.replaceAll(" "," ")},wf=function(e){const{value:s,fontSize:i,color:n,pageIndex:a}=r(this,Fr);return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==n[l])||e.pageIndex!==a},v(ut,ei),G(ut,"_freeTextDefaultContent",""),G(ut,"_internalPadding",0),G(ut,"_defaultColor",null),G(ut,"_defaultFontSize",10),G(ut,"_type","freetext"),G(ut,"_editorType",Z.FREETEXT);let Dc=ut;var Do,wi,Ye,re,Ef,Ol,xf,Sf,Nc;class Oc{constructor(t,e=0,s=0,i=!0){v(this,re);v(this,Do);v(this,wi,[]);v(this,Ye,[]);let n=1/0,a=-1/0,o=1/0,l=-1/0;const d=10**-4;for(const{x:y,y:w,width:E,height:x}of t){const S=Math.floor((y-e)/d)*d,C=Math.ceil((y+E+e)/d)*d,T=Math.floor((w-e)/d)*d,R=Math.ceil((w+x+e)/d)*d,M=[S,T,R,!0],B=[C,T,R,!1];r(this,wi).push(M,B),n=Math.min(n,S),a=Math.max(a,C),o=Math.min(o,T),l=Math.max(l,R)}const u=a-n+2*s,f=l-o+2*s,p=n-s,g=o-s,A=r(this,wi).at(i?-1:-2),_=[A[0],A[2]];for(const y of r(this,wi)){const[w,E,x]=y;y[0]=(w-p)/u,y[1]=(E-g)/f,y[2]=(x-g)/f}m(this,Do,{x:p,y:g,width:u,height:f,lastPoint:_})}getOutlines(){r(this,wi).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of r(this,wi))e[3]?(t.push(...b(this,re,Nc).call(this,e)),b(this,re,xf).call(this,e)):(b(this,re,Sf).call(this,e),t.push(...b(this,re,Nc).call(this,e)));return b(this,re,Ef).call(this,t)}}Do=new WeakMap,wi=new WeakMap,Ye=new WeakMap,re=new WeakSet,Ef=function(t){const e=[],s=new Set;for(const a of t){const[o,l,c]=a;e.push([o,l,a],[o,c,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],c=e[a+1][2];l.push(c),c.push(l),s.add(l),s.add(c)}const i=[];let n;for(;s.size>0;){const a=s.values().next().value;let[o,l,c,d,u]=a;s.delete(a);let f=o,p=l;for(n=[o,c],i.push(n);;){let g;if(s.has(d))g=d;else if(s.has(u))g=u;else break;s.delete(g),[o,l,c,d,u]=g,f!==o&&(n.push(f,p,o,p===l?l:c),f=o),p=p===l?c:l}n.push(f,p)}return new ob(i,r(this,Do))},Ol=function(t){const e=r(this,Ye);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},xf=function([,t,e]){const s=b(this,re,Ol).call(this,t);r(this,Ye).splice(s,0,[t,e])},Sf=function([,t,e]){const s=b(this,re,Ol).call(this,t);for(let i=s;i<r(this,Ye).length;i++){const[n,a]=r(this,Ye)[i];if(n!==t)break;if(n===t&&a===e){r(this,Ye).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,a]=r(this,Ye)[i];if(n!==t)break;if(n===t&&a===e){r(this,Ye).splice(i,1);return}}},Nc=function(t){const[e,s,i]=t,n=[[e,s,i]],a=b(this,re,Ol).call(this,i);for(let o=0;o<a;o++){const[l,c]=r(this,Ye)[o];for(let d=0,u=n.length;d<u;d++){const[,f,p]=n[d];if(!(c<=f||p<=l)){if(f>=l){if(p>c)n[d][1]=c;else{if(u===1)return[];n.splice(d,1),d--,u--}continue}n[d][2]=l,p>c&&n.push([e,c,p])}}}return n};class Cf{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 Bc}}var Fo,Or;class ob extends Cf{constructor(e,s){super();v(this,Fo);v(this,Or);m(this,Or,e),m(this,Fo,s)}toSVGPath(){const e=[];for(const s of r(this,Or)){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,Or)){const u=new Array(d.length);for(let f=0;f<d.length;f+=2)u[f]=e+d[f]*l,u[f+1]=n-d[f+1]*c;o.push(u)}return o}get box(){return r(this,Fo)}}Fo=new WeakMap,Or=new WeakMap;var cs,Us,Nr,Hr,ds,J,_n,wn,Oo,No,Br,jr,Ei,Ho,bh,vh,Bo,Hc;const Ss=class Ss{constructor({x:t,y:e},s,i,n,a,o=0){v(this,Bo);v(this,cs);v(this,Us,[]);v(this,Nr);v(this,Hr);v(this,ds,[]);v(this,J,new Float64Array(18));v(this,_n);v(this,wn);v(this,Oo);v(this,No);v(this,Br);v(this,jr);v(this,Ei,[]);m(this,cs,s),m(this,jr,n*i),m(this,Hr,a),r(this,J).set([NaN,NaN,NaN,NaN,t,e],6),m(this,Nr,o),m(this,No,r(Ss,Ho)*i),m(this,Oo,r(Ss,vh)*i),m(this,Br,i),r(this,Ei).push(t,e)}get free(){return!0}isEmpty(){return isNaN(r(this,J)[8])}add({x:t,y:e}){var M;m(this,_n,t),m(this,wn,e);const[s,i,n,a]=r(this,cs);let[o,l,c,d]=r(this,J).subarray(8,12);const u=t-c,f=e-d,p=Math.hypot(u,f);if(p<r(this,Oo))return!1;const g=p-r(this,No),A=g/p,_=A*u,y=A*f;let w=o,E=l;o=c,l=d,c+=_,d+=y,(M=r(this,Ei))==null||M.push(t,e);const x=-y/g,S=_/g,C=x*r(this,jr),T=S*r(this,jr);return r(this,J).set(r(this,J).subarray(2,8),0),r(this,J).set([c+C,d+T],4),r(this,J).set(r(this,J).subarray(14,18),12),r(this,J).set([c-C,d-T],16),isNaN(r(this,J)[6])?(r(this,ds).length===0&&(r(this,J).set([o+C,l+T],2),r(this,ds).push(NaN,NaN,NaN,NaN,(o+C-s)/n,(l+T-i)/a),r(this,J).set([o-C,l-T],14),r(this,Us).push(NaN,NaN,NaN,NaN,(o-C-s)/n,(l-T-i)/a)),r(this,J).set([w,E,o,l,c,d],6),!this.isEmpty()):(r(this,J).set([w,E,o,l,c,d],6),Math.abs(Math.atan2(E-l,w-o)-Math.atan2(y,_))<Math.PI/2?([o,l,c,d]=r(this,J).subarray(2,6),r(this,ds).push(NaN,NaN,NaN,NaN,((o+c)/2-s)/n,((l+d)/2-i)/a),[o,l,w,E]=r(this,J).subarray(14,18),r(this,Us).push(NaN,NaN,NaN,NaN,((w+o)/2-s)/n,((E+l)/2-i)/a),!0):([w,E,o,l,c,d]=r(this,J).subarray(0,6),r(this,ds).push(((w+5*o)/6-s)/n,((E+5*l)/6-i)/a,((5*o+c)/6-s)/n,((5*l+d)/6-i)/a,((o+c)/2-s)/n,((l+d)/2-i)/a),[c,d,o,l,w,E]=r(this,J).subarray(12,18),r(this,Us).push(((w+5*o)/6-s)/n,((E+5*l)/6-i)/a,((5*o+c)/6-s)/n,((5*l+d)/6-i)/a,((o+c)/2-s)/n,((l+d)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=r(this,ds),e=r(this,Us),s=r(this,J).subarray(4,6),i=r(this,J).subarray(16,18),[n,a,o,l]=r(this,cs),[c,d,u,f]=b(this,Bo,Hc).call(this);if(isNaN(r(this,J)[6])&&!this.isEmpty())return`M${(r(this,J)[2]-n)/o} ${(r(this,J)[3]-a)/l} L${(r(this,J)[4]-n)/o} ${(r(this,J)[5]-a)/l} L${c} ${d} L${u} ${f} L${(r(this,J)[16]-n)/o} ${(r(this,J)[17]-a)/l} L${(r(this,J)[14]-n)/o} ${(r(this,J)[15]-a)/l} Z`;const p=[];p.push(`M${t[4]} ${t[5]}`);for(let g=6;g<t.length;g+=6)isNaN(t[g])?p.push(`L${t[g+4]} ${t[g+5]}`):p.push(`C${t[g]} ${t[g+1]} ${t[g+2]} ${t[g+3]} ${t[g+4]} ${t[g+5]}`);p.push(`L${(s[0]-n)/o} ${(s[1]-a)/l} L${c} ${d} L${u} ${f} L${(i[0]-n)/o} ${(i[1]-a)/l}`);for(let g=e.length-6;g>=6;g-=6)isNaN(e[g])?p.push(`L${e[g+4]} ${e[g+5]}`):p.push(`C${e[g]} ${e[g+1]} ${e[g+2]} ${e[g+3]} ${e[g+4]} ${e[g+5]}`);return p.push(`L${e[4]} ${e[5]} Z`),p.join(" ")}getOutlines(){var y;const t=r(this,ds),e=r(this,Us),s=r(this,J),i=s.subarray(4,6),n=s.subarray(16,18),[a,o,l,c]=r(this,cs),d=new Float64Array((((y=r(this,Ei))==null?void 0:y.length)??0)+2);for(let w=0,E=d.length-2;w<E;w+=2)d[w]=(r(this,Ei)[w]-a)/l,d[w+1]=(r(this,Ei)[w+1]-o)/c;d[d.length-2]=(r(this,_n)-a)/l,d[d.length-1]=(r(this,wn)-o)/c;const[u,f,p,g]=b(this,Bo,Hc).call(this);if(isNaN(s[6])&&!this.isEmpty()){const w=new Float64Array(36);return w.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,f,NaN,NaN,NaN,NaN,p,g,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 Bc(w,d,r(this,cs),r(this,Br),r(this,Nr),r(this,Hr))}const A=new Float64Array(r(this,ds).length+24+r(this,Us).length);let _=t.length;for(let w=0;w<_;w+=2){if(isNaN(t[w])){A[w]=A[w+1]=NaN;continue}A[w]=t[w],A[w+1]=t[w+1]}A.set([NaN,NaN,NaN,NaN,(i[0]-a)/l,(i[1]-o)/c,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,p,g,NaN,NaN,NaN,NaN,(n[0]-a)/l,(n[1]-o)/c],_),_+=24;for(let w=e.length-6;w>=6;w-=6)for(let E=0;E<6;E+=2){if(isNaN(e[w+E])){A[_]=A[_+1]=NaN,_+=2;continue}A[_]=e[w+E],A[_+1]=e[w+E+1],_+=2}return A.set([NaN,NaN,NaN,NaN,e[4],e[5]],_),new Bc(A,d,r(this,cs),r(this,Br),r(this,Nr),r(this,Hr))}};cs=new WeakMap,Us=new WeakMap,Nr=new WeakMap,Hr=new WeakMap,ds=new WeakMap,J=new WeakMap,_n=new WeakMap,wn=new WeakMap,Oo=new WeakMap,No=new WeakMap,Br=new WeakMap,jr=new WeakMap,Ei=new WeakMap,Ho=new WeakMap,bh=new WeakMap,vh=new WeakMap,Bo=new WeakSet,Hc=function(){const t=r(this,J).subarray(4,6),e=r(this,J).subarray(16,18),[s,i,n,a]=r(this,cs);return[(r(this,_n)+(t[0]-e[0])/2-s)/n,(r(this,wn)+(t[1]-e[1])/2-i)/a,(r(this,_n)+(e[0]-t[0])/2-s)/n,(r(this,wn)+(e[1]-t[1])/2-i)/a]},v(Ss,Ho,8),v(Ss,bh,2),v(Ss,vh,r(Ss,Ho)+r(Ss,bh));let Jl=Ss;var Wr,En,$s,jo,xe,Wo,yt,ue,fa,pa,Tf;class Bc extends Cf{constructor(e,s,i,n,a,o){super();v(this,ue);v(this,Wr);v(this,En,null);v(this,$s);v(this,jo);v(this,xe);v(this,Wo);v(this,yt);m(this,yt,e),m(this,xe,s),m(this,Wr,i),m(this,Wo,n),m(this,$s,a),m(this,jo,o),b(this,ue,Tf).call(this,o);const{x:l,y:c,width:d,height:u}=r(this,En);for(let f=0,p=e.length;f<p;f+=2)e[f]=(e[f]-l)/d,e[f+1]=(e[f+1]-c)/u;for(let f=0,p=s.length;f<p;f+=2)s[f]=(s[f]-l)/d,s[f+1]=(s[f+1]-c)/u}toSVGPath(){const e=[`M${r(this,yt)[4]} ${r(this,yt)[5]}`];for(let s=6,i=r(this,yt).length;s<i;s+=6){if(isNaN(r(this,yt)[s])){e.push(`L${r(this,yt)[s+4]} ${r(this,yt)[s+5]}`);continue}e.push(`C${r(this,yt)[s]} ${r(this,yt)[s+1]} ${r(this,yt)[s+2]} ${r(this,yt)[s+3]} ${r(this,yt)[s+4]} ${r(this,yt)[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,ue,fa).call(this,r(this,yt),e,n,o,-l),d=b(this,ue,fa).call(this,r(this,xe),e,n,o,-l);break;case 90:c=b(this,ue,pa).call(this,r(this,yt),e,s,o,l),d=b(this,ue,pa).call(this,r(this,xe),e,s,o,l);break;case 180:c=b(this,ue,fa).call(this,r(this,yt),i,s,-o,l),d=b(this,ue,fa).call(this,r(this,xe),i,s,-o,l);break;case 270:c=b(this,ue,pa).call(this,r(this,yt),i,n,-o,-l),d=b(this,ue,pa).call(this,r(this,xe),i,n,-o,-l);break}return{outline:Array.from(c),points:[Array.from(d)]}}get box(){return r(this,En)}getNewOutline(e,s){const{x:i,y:n,width:a,height:o}=r(this,En),[l,c,d,u]=r(this,Wr),f=a*d,p=o*u,g=i*d+l,A=n*u+c,_=new Jl({x:r(this,xe)[0]*f+g,y:r(this,xe)[1]*p+A},r(this,Wr),r(this,Wo),e,r(this,jo),s??r(this,$s));for(let y=2;y<r(this,xe).length;y+=2)_.add({x:r(this,xe)[y]*f+g,y:r(this,xe)[y+1]*p+A});return _.getOutlines()}}Wr=new WeakMap,En=new WeakMap,$s=new WeakMap,jo=new WeakMap,xe=new WeakMap,Wo=new WeakMap,yt=new WeakMap,ue=new WeakSet,fa=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},pa=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},Tf=function(e){const s=r(this,yt);let i=s[4],n=s[5],a=i,o=n,l=i,c=n,d=i,u=n;const f=e?Math.max:Math.min;for(let y=6,w=s.length;y<w;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=f(d,s[y+4]));else{const E=H.bezierBoundingBox(i,n,...s.slice(y,y+6));a=Math.min(a,E[0]),o=Math.min(o,E[1]),l=Math.max(l,E[2]),c=Math.max(c,E[3]),u<E[3]?(d=E[2],u=E[3]):u===E[3]&&(d=f(d,E[2]))}i=s[y+4],n=s[y+5]}const p=a-r(this,$s),g=o-r(this,$s),A=l-a+2*r(this,$s),_=c-o+2*r(this,$s);m(this,En,{x:p,y:g,width:A,height:_,lastPoint:[d,u]})};var zo,Uo,Ke,xn,zr,Rt,$o,Ur,Go,Vo,Qe,$r,ct,jc,Wc,Pf,Ni,Rf,li;const Cs=class Cs{constructor({editor:t=null,uiManager:e=null}){v(this,ct);v(this,zo,b(this,ct,Pf).bind(this));v(this,Uo,b(this,ct,Rf).bind(this));v(this,Ke,null);v(this,xn,null);v(this,zr);v(this,Rt,null);v(this,$o,!1);v(this,Ur,!1);v(this,Go,null);v(this,Vo);v(this,Qe,null);v(this,$r);var s;t?(m(this,Ur,!1),m(this,$r,U.HIGHLIGHT_COLOR),m(this,Go,t)):(m(this,Ur,!0),m(this,$r,U.HIGHLIGHT_DEFAULT_COLOR)),m(this,Qe,(t==null?void 0:t._uiManager)||e),m(this,Vo,r(this,Qe)._eventBus),m(this,zr,(t==null?void 0:t.color)||((s=r(this,Qe))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98")}static get _keyboardManager(){return tt(this,"_keyboardManager",new nl([[["Escape","mac+Escape"],Cs.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Cs.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Cs.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Cs.prototype._moveToPrevious],[["Home","mac+Home"],Cs.prototype._moveToBeginning],[["End","mac+End"],Cs.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);const e=r(this,Qe)._signal;t.addEventListener("click",b(this,ct,Ni).bind(this),{signal:e}),t.addEventListener("keydown",r(this,zo),{signal:e});const s=m(this,xn,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=r(this,zr),t.append(s),t}renderMainDropdown(){const t=m(this,Rt,b(this,ct,jc).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===r(this,Ke)){b(this,ct,Ni).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,ct,Wc).call(this,e,t)}_moveToNext(t){var e,s;if(!r(this,ct,li)){b(this,ct,Ni).call(this,t);return}if(t.target===r(this,Ke)){(e=r(this,Rt).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=r(this,Rt))==null?void 0:e.firstChild)||t.target===r(this,Ke)){r(this,ct,li)&&this._hideDropdownFromKeyboard();return}r(this,ct,li)||b(this,ct,Ni).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!r(this,ct,li)){b(this,ct,Ni).call(this,t);return}(e=r(this,Rt).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!r(this,ct,li)){b(this,ct,Ni).call(this,t);return}(e=r(this,Rt).lastChild)==null||e.focus()}hideDropdown(){var t;(t=r(this,Rt))==null||t.classList.add("hidden"),window.removeEventListener("pointerdown",r(this,Uo))}_hideDropdownFromKeyboard(){var t;if(!r(this,Ur)){if(!r(this,ct,li)){(t=r(this,Go))==null||t.unselect();return}this.hideDropdown(),r(this,Ke).focus({preventScroll:!0,focusVisible:r(this,$o)})}}updateColor(t){if(r(this,xn)&&(r(this,xn).style.backgroundColor=t),!r(this,Rt))return;const e=r(this,Qe).highlightColors.values();for(const s of r(this,Rt).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,xn,null),(e=r(this,Rt))==null||e.remove(),m(this,Rt,null)}};zo=new WeakMap,Uo=new WeakMap,Ke=new WeakMap,xn=new WeakMap,zr=new WeakMap,Rt=new WeakMap,$o=new WeakMap,Ur=new WeakMap,Go=new WeakMap,Vo=new WeakMap,Qe=new WeakMap,$r=new WeakMap,ct=new WeakSet,jc=function(){const t=document.createElement("div"),e=r(this,Qe)._signal;t.addEventListener("contextmenu",fe,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of r(this,Qe).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${s}`);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=i,n.setAttribute("aria-selected",i===r(this,zr)),n.addEventListener("click",b(this,ct,Wc).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",r(this,zo),{signal:e}),t},Wc=function(t,e){e.stopPropagation(),r(this,Vo).dispatch("switchannotationeditorparams",{source:this,type:r(this,$r),value:t})},Pf=function(t){Cs._keyboardManager.exec(this,t)},Ni=function(t){if(r(this,ct,li)){this.hideDropdown();return}if(m(this,$o,t.detail===0),window.addEventListener("pointerdown",r(this,Uo),{signal:r(this,Qe)._signal}),r(this,Rt)){r(this,Rt).classList.remove("hidden");return}const e=m(this,Rt,b(this,ct,jc).call(this));r(this,Ke).append(e)},Rf=function(t){var e;(e=r(this,Rt))!=null&&e.contains(t.target)||this.hideDropdown()},li=function(){return r(this,Rt)&&!r(this,Rt).classList.contains("hidden")};let Zl=Cs;var Gr,qo,xi,Sn,Vr,De,Xo,Yo,Cn,Je,ee,Se,Ah,qr,Tn,kt,Xr,us,Ko,K,zc,Uc,kf,Lf,Mf,$c,ga,He,Qn,If,Nl,ma,Df,Ff,Of,Nf;const st=class st extends nt{constructor(e){super({...e,name:"highlightEditor"});v(this,K);v(this,Gr,null);v(this,qo,0);v(this,xi);v(this,Sn,null);v(this,Vr,null);v(this,De,null);v(this,Xo,null);v(this,Yo,0);v(this,Cn,null);v(this,Je,null);v(this,ee,null);v(this,Se,!1);v(this,Ah,b(this,K,If).bind(this));v(this,qr,null);v(this,Tn);v(this,kt,null);v(this,Xr,"");v(this,us);v(this,Ko,"");this.color=e.color||st._defaultColor,m(this,us,e.thickness||st._defaultThickness),m(this,Tn,e.opacity||st._defaultOpacity),m(this,xi,e.boxes||null),m(this,Ko,e.methodOfCreation||""),m(this,Xr,e.text||""),this._isDraggable=!1,e.highlightId>-1?(m(this,Se,!0),b(this,K,Uc).call(this,e),b(this,K,ga).call(this)):(m(this,Gr,e.anchorNode),m(this,qo,e.anchorOffset),m(this,Xo,e.focusNode),m(this,Yo,e.focusOffset),b(this,K,zc).call(this),b(this,K,ga).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=st.prototype;return tt(this,"_keyboardManager",new nl([[["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,Se)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:r(this,us),methodOfCreation:r(this,Ko)}}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;nt.initialize(e,s),st._defaultColor||(st._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case U.HIGHLIGHT_DEFAULT_COLOR:st._defaultColor=s;break;case U.HIGHLIGHT_THICKNESS:st._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return r(this,qr)}updateParams(e,s){switch(e){case U.HIGHLIGHT_COLOR:b(this,K,kf).call(this,s);break;case U.HIGHLIGHT_THICKNESS:b(this,K,Lf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[U.HIGHLIGHT_DEFAULT_COLOR,st._defaultColor],[U.HIGHLIGHT_THICKNESS,st._defaultThickness]]}get propertiesToUpdate(){return[[U.HIGHLIGHT_COLOR,this.color||st._defaultColor],[U.HIGHLIGHT_THICKNESS,r(this,us)||st._defaultThickness],[U.HIGHLIGHT_FREE,r(this,Se)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(m(this,Vr,new Zl({editor:this})),e.addColorPicker(r(this,Vr))),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,K,ma).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,K,ma).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){b(this,K,$c).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,K,ga).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?b(this,K,$c).call(this):e&&(b(this,K,ga).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,Se)?(e=(e-this.rotation+360)%360,i=b(n=st,He,Qn).call(n,r(this,Je).box,e)):i=b(a=st,He,Qn).call(a,this,e),s.rotate(r(this,ee),e),s.rotate(r(this,kt),e),s.updateBox(r(this,ee),i),s.updateBox(r(this,kt),b(o=st,He,Qn).call(o,r(this,De).box,e))}render(){if(this.div)return this.div;const e=super.render();r(this,Xr)&&(e.setAttribute("aria-label",r(this,Xr)),e.setAttribute("role","mark")),r(this,Se)?e.classList.add("free"):this.div.addEventListener("keydown",r(this,Ah),{signal:this._uiManager._signal});const s=m(this,Cn,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=r(this,Sn);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),Xl(this,r(this,Cn),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.parent.drawLayer.addClass(r(this,kt),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(r(this,kt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,K,Nl).call(this,!0);break;case 1:case 3:b(this,K,Nl).call(this,!1);break}}select(){var e,s;super.select(),r(this,kt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,kt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(r(this,kt),"selected"))}unselect(){var e;super.unselect(),r(this,kt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,kt),"selected"),r(this,Se)||b(this,K,Nl).call(this,!1))}get _mustFixPosition(){return!r(this,Se)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(r(this,ee),e),this.parent.drawLayer.show(r(this,kt),e))}static startHighlighting(e,s,{target:i,x:n,y:a}){const{x:o,y:l,width:c,height:d}=i.getBoundingClientRect(),u=_=>{b(this,He,Of).call(this,e,_)},f=e._signal,p={capture:!0,passive:!1,signal:f},g=_=>{_.preventDefault(),_.stopPropagation()},A=_=>{i.removeEventListener("pointermove",u),window.removeEventListener("blur",A),window.removeEventListener("pointerup",A),window.removeEventListener("pointerdown",g,p),window.removeEventListener("contextmenu",fe),b(this,He,Nf).call(this,e,_)};window.addEventListener("blur",A,{signal:f}),window.addEventListener("pointerup",A,{signal:f}),window.addEventListener("pointerdown",g,p),window.addEventListener("contextmenu",fe,{signal:f}),i.addEventListener("pointermove",u,{signal:f}),this._freeHighlight=new Jl({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 A;const n=super.deserialize(e,s,i),{rect:[a,o,l,c],color:d,quadPoints:u}=e;n.color=H.makeHexColor(...d),m(n,Tn,e.opacity);const[f,p]=n.pageDimensions;n.width=(l-a)/f,n.height=(c-o)/p;const g=m(n,xi,[]);for(let _=0;_<u.length;_+=8)g.push({x:(u[4]-l)/f,y:(c-(1-u[_+5]))/p,width:(u[_+2]-u[_])/f,height:(u[_+5]-u[_+1])/p});return b(A=n,K,zc).call(A),n}serialize(e=!1){if(this.isEmpty()||e)return null;const s=this.getRect(0,0),i=nt._colorManager.convert(this.color);return{annotationType:Z.HIGHLIGHT,color:i,opacity:r(this,Tn),thickness:r(this,us),quadPoints:b(this,K,Df).call(this),outlines:b(this,K,Ff).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:b(this,K,ma).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}};Gr=new WeakMap,qo=new WeakMap,xi=new WeakMap,Sn=new WeakMap,Vr=new WeakMap,De=new WeakMap,Xo=new WeakMap,Yo=new WeakMap,Cn=new WeakMap,Je=new WeakMap,ee=new WeakMap,Se=new WeakMap,Ah=new WeakMap,qr=new WeakMap,Tn=new WeakMap,kt=new WeakMap,Xr=new WeakMap,us=new WeakMap,Ko=new WeakMap,K=new WeakSet,zc=function(){const e=new Oc(r(this,xi),.001);m(this,Je,e.getOutlines()),{x:this.x,y:this.y,width:this.width,height:this.height}=r(this,Je).box;const s=new Oc(r(this,xi),.0025,.001,this._uiManager.direction==="ltr");m(this,De,s.getOutlines());const{lastPoint:i}=r(this,De).box;m(this,qr,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Uc=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var u,f;if(m(this,Je,e),m(this,De,e.getNewOutline(r(this,us)/2+1.5,.0025)),s>=0)m(this,ee,s),m(this,Sn,i),this.parent.drawLayer.finalizeLine(s,e),m(this,kt,this.parent.drawLayer.highlightOutline(r(this,De)));else if(this.parent){const p=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(r(this,ee),e),this.parent.drawLayer.updateBox(r(this,ee),b(u=st,He,Qn).call(u,r(this,Je).box,(p-this.rotation+360)%360)),this.parent.drawLayer.updateLine(r(this,kt),r(this,De)),this.parent.drawLayer.updateBox(r(this,kt),b(f=st,He,Qn).call(f,r(this,De).box,p))}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[p,g]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*g/p,this.height=c*p/g;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[p,g]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*g/p,this.height=c*p/g;break}}const{lastPoint:d}=r(this,De).box;m(this,qr,[(d[0]-a)/l,(d[1]-o)/c])},kf=function(e){const s=n=>{var a,o;this.color=n,(a=this.parent)==null||a.drawLayer.changeColor(r(this,ee),n),(o=r(this,Vr))==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:U.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},Lf=function(e){const s=r(this,us),i=n=>{m(this,us,n),b(this,K,Mf).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:U.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Mf=function(e){if(!r(this,Se))return;b(this,K,Uc).call(this,{highlightOutlines:r(this,Je).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},$c=function(){r(this,ee)===null||!this.parent||(this.parent.drawLayer.remove(r(this,ee)),m(this,ee,null),this.parent.drawLayer.remove(r(this,kt)),m(this,kt,null))},ga=function(e=this.parent){r(this,ee)===null&&({id:me(this,ee)._,clipPathId:me(this,Sn)._}=e.drawLayer.highlight(r(this,Je),this.color,r(this,Tn)),m(this,kt,e.drawLayer.highlightOutline(r(this,De))),r(this,Cn)&&(r(this,Cn).style.clipPath=r(this,Sn)))},He=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}},If=function(e){st._keyboardManager.exec(this,e)},Nl=function(e){if(!r(this,Gr))return;const s=window.getSelection();e?s.setPosition(r(this,Gr),r(this,qo)):s.setPosition(r(this,Xo),r(this,Yo))},ma=function(){return r(this,Se)?this.rotation:0},Df=function(){if(r(this,Se))return null;const[e,s]=this.pageDimensions,i=r(this,xi),n=new Float32Array(i.length*8);let a=0;for(const{x:o,y:l,width:c,height:d}of i){const u=o*e,f=(1-l-d)*s;n[a]=n[a+4]=u,n[a+1]=n[a+3]=f,n[a+2]=n[a+6]=u+c*e,n[a+5]=n[a+7]=f+d*s,a+=8}return n},Ff=function(e){return r(this,Je).serialize(e,b(this,K,ma).call(this))},Of=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Nf=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=""},v(st,He),G(st,"_defaultColor",null),G(st,"_defaultOpacity",1),G(st,"_defaultThickness",12),G(st,"_l10nPromise"),G(st,"_type","highlight"),G(st,"_editorType",Z.HIGHLIGHT),G(st,"_freeHighlightId",-1),G(st,"_freeHighlight",null),G(st,"_freeHighlightClipId","");let th=st;var Pn,Rn,Qo,Jo,Zo,kn,fs,Gs,Fe,Ln,Mn,Vs,In,Dn,Si,L,Hf,Bf,jf,Wf,Vc,zf,qc,Uf,$f,Gf,Vf,qf,Hi,Xc,Hl,Bl,Jn,Yc,jl,ii,Xf,Kc,Yf,Kf,Qc,Wl,ba;const gt=class gt extends nt{constructor(e){super({...e,name:"inkEditor"});v(this,L);v(this,Pn,0);v(this,Rn,0);v(this,Qo,this.canvasPointermove.bind(this));v(this,Jo,this.canvasPointerleave.bind(this));v(this,Zo,this.canvasPointerup.bind(this));v(this,kn,this.canvasPointerdown.bind(this));v(this,fs,null);v(this,Gs,new Path2D);v(this,Fe,!1);v(this,Ln,!1);v(this,Mn,!1);v(this,Vs,null);v(this,In,0);v(this,Dn,0);v(this,Si,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){nt.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case U.INK_THICKNESS:gt._defaultThickness=s;break;case U.INK_COLOR:gt._defaultColor=s;break;case U.INK_OPACITY:gt._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case U.INK_THICKNESS:b(this,L,Hf).call(this,s);break;case U.INK_COLOR:b(this,L,Bf).call(this,s);break;case U.INK_OPACITY:b(this,L,jf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[U.INK_THICKNESS,gt._defaultThickness],[U.INK_COLOR,gt._defaultColor||nt._defaultLineColor],[U.INK_OPACITY,Math.round(gt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[U.INK_THICKNESS,this.thickness||gt._defaultThickness],[U.INK_COLOR,this.color||gt._defaultColor||nt._defaultLineColor],[U.INK_OPACITY,Math.round(100*(this.opacity??gt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(b(this,L,Hl).call(this),b(this,L,Bl).call(this)),this.isAttachedToDOM||(this.parent.add(this),b(this,L,Jn).call(this)),b(this,L,ba).call(this)))}remove(){var e;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,r(this,fs)&&(clearTimeout(r(this,fs)),m(this,fs,null)),(e=r(this,Vs))==null||e.disconnect(),m(this,Vs,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,Fe)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",r(this,kn),{signal:this._uiManager._signal}))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",r(this,kn)))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){r(this,Fe)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),m(this,Fe,!0),this.div.classList.add("disabled"),b(this,L,ba).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,Fe)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),b(this,L,zf).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),b(this,L,qc).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),b(this,L,Xc).call(this,e)}canvasPointerleave(e){b(this,L,Xc).call(this,e)}get isResizable(){return!this.isEmpty()&&r(this,Fe)}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,L,Wf).call(this);if(this.setAt(i,n,0,0),this.setDims(a,o),b(this,L,Hl).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,Mn,!0),b(this,L,Jn).call(this),this.setDims(this.width*l,this.height*c),b(this,L,Hi).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return b(this,L,Bl).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(r(this,In)===i&&r(this,Dn)===n)return;m(this,In,i),m(this,Dn,n),this.canvas.style.visibility="hidden";const[a,o]=this.parentDimensions;this.width=e/a,this.height=s/o,this.fixAndSetPosition(),r(this,Fe)&&b(this,L,Yc).call(this,e,s),b(this,L,Jn).call(this),b(this,L,Hi).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(e,s,i){var _,y,w;if(e instanceof gf)return null;const n=super.deserialize(e,s,i);n.thickness=e.thickness,n.color=H.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,Fe,!0),m(n,In,Math.round(l)),m(n,Dn,Math.round(c));const{paths:f,rect:p,rotation:g}=e;for(let{bezier:E}of f){E=b(_=gt,ii,Yf).call(_,E,p,g);const x=[];n.paths.push(x);let S=d*(E[0]-u),C=d*(E[1]-u);for(let R=2,M=E.length;R<M;R+=6){const B=d*(E[R]-u),I=d*(E[R+1]-u),$=d*(E[R+2]-u),V=d*(E[R+3]-u),W=d*(E[R+4]-u),X=d*(E[R+5]-u);x.push([[S,C],[B,I],[$,V],[W,X]]),S=W,C=X}const T=b(this,ii,Xf).call(this,x);n.bezierPath2D.push(T)}const A=b(y=n,L,Qc).call(y);return m(n,Rn,Math.max(nt.MIN_SIZE,A[2]-A[0])),m(n,Pn,Math.max(nt.MIN_SIZE,A[3]-A[1])),b(w=n,L,Yc).call(w,l,c),n}serialize(){if(this.isEmpty())return null;const e=this.getRect(0,0),s=nt._colorManager.convert(this.ctx.strokeStyle);return{annotationType:Z.INK,color:s,thickness:this.thickness,opacity:this.opacity,paths:b(this,L,Kf).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};Pn=new WeakMap,Rn=new WeakMap,Qo=new WeakMap,Jo=new WeakMap,Zo=new WeakMap,kn=new WeakMap,fs=new WeakMap,Gs=new WeakMap,Fe=new WeakMap,Ln=new WeakMap,Mn=new WeakMap,Vs=new WeakMap,In=new WeakMap,Dn=new WeakMap,Si=new WeakMap,L=new WeakSet,Hf=function(e){const s=n=>{this.thickness=n,b(this,L,ba).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:U.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},Bf=function(e){const s=n=>{this.color=n,b(this,L,Hi).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:U.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},jf=function(e){const s=n=>{this.opacity=n,b(this,L,Hi).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:U.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},Wf=function(){const{parentRotation:e,parentDimensions:[s,i]}=this;switch(e){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},Vc=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}${Lg(i)}`},zf=function(e,s){const i=this._uiManager._signal;this.canvas.addEventListener("contextmenu",fe,{signal:i}),this.canvas.addEventListener("pointerleave",r(this,Jo),{signal:i}),this.canvas.addEventListener("pointermove",r(this,Qo),{signal:i}),this.canvas.addEventListener("pointerup",r(this,Zo),{signal:i}),this.canvas.removeEventListener("pointerdown",r(this,kn)),this.isEditing=!0,r(this,Mn)||(m(this,Mn,!0),b(this,L,Jn).call(this),this.thickness||(this.thickness=gt._defaultThickness),this.color||(this.color=gt._defaultColor||nt._defaultLineColor),this.opacity??(this.opacity=gt._defaultOpacity)),this.currentPath.push([e,s]),m(this,Ln,!1),b(this,L,Vc).call(this),m(this,Si,()=>{b(this,L,Gf).call(this),r(this,Si)&&window.requestAnimationFrame(r(this,Si))}),window.requestAnimationFrame(r(this,Si))},qc=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,Gs);if(a.push([e,s]),m(this,Ln,!0),a.length<=2){o.moveTo(...a[0]),o.lineTo(e,s);return}a.length===3&&(m(this,Gs,o=new Path2D),o.moveTo(...a[0])),b(this,L,Vf).call(this,o,...a.at(-3),...a.at(-2),e,s)},Uf=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);r(this,Gs).lineTo(...e)},$f=function(e,s){m(this,Si,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),b(this,L,qc).call(this,e,s),b(this,L,Uf).call(this);let i;if(this.currentPath.length!==1)i=b(this,L,qf).call(this);else{const c=[e,s];i=[[c,c.slice(),c.slice(),c]]}const n=r(this,Gs),a=this.currentPath;this.currentPath=[],m(this,Gs,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,L,Hl).call(this),b(this,L,Bl).call(this)),b(this,L,ba).call(this))};this.addCommands({cmd:o,undo:l,mustExec:!0})},Gf=function(){if(!r(this,Ln))return;m(this,Ln,!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,Gs)),a.restore()},Vf=function(e,s,i,n,a,o,l){const c=(s+n)/2,d=(i+a)/2,u=(n+o)/2,f=(a+l)/2;e.bezierCurveTo(c+2*(n-c)/3,d+2*(a-d)/3,u+2*(n-u)/3,f+2*(a-f)/3,u,f)},qf=function(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const s=[];let i,[n,a]=e[0];for(i=1;i<e.length-2;i++){const[p,g]=e[i],[A,_]=e[i+1],y=(p+A)/2,w=(g+_)/2,E=[n+2*(p-n)/3,a+2*(g-a)/3],x=[y+2*(p-y)/3,w+2*(g-w)/3];s.push([[n,a],E,x,[y,w]]),[n,a]=[y,w]}const[o,l]=e[i],[c,d]=e[i+1],u=[n+2*(o-n)/3,a+2*(l-a)/3],f=[c+2*(o-c)/3,d+2*(l-d)/3];return s.push([[n,a],u,f,[c,d]]),s},Hi=function(){if(this.isEmpty()){b(this,L,jl).call(this);return}b(this,L,Vc).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,L,jl).call(this);for(const i of this.bezierPath2D)s.stroke(i)},Xc=function(e){this.canvas.removeEventListener("pointerleave",r(this,Jo)),this.canvas.removeEventListener("pointermove",r(this,Qo)),this.canvas.removeEventListener("pointerup",r(this,Zo)),this.canvas.addEventListener("pointerdown",r(this,kn),{signal:this._uiManager._signal}),r(this,fs)&&clearTimeout(r(this,fs)),m(this,fs,setTimeout(()=>{m(this,fs,null),this.canvas.removeEventListener("contextmenu",fe)},10)),b(this,L,$f).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Hl=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")},Bl=function(){m(this,Vs,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),r(this,Vs).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,Vs))==null||e.disconnect(),m(this,Vs,null)},{once:!0})},Jn=function(){if(!r(this,Mn))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),b(this,L,jl).call(this)},Yc=function(e,s){const i=b(this,L,Wl).call(this),n=(e-i)/r(this,Rn),a=(s-i)/r(this,Pn);this.scaleFactor=Math.min(n,a)},jl=function(){const e=b(this,L,Wl).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},ii=new WeakSet,Xf=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},Kc=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},Yf=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},Kf=function(e,s,i,n){var d,u;const a=[],o=this.thickness/2,l=e*s+o,c=e*i+o;for(const f of this.paths){const p=[],g=[];for(let A=0,_=f.length;A<_;A++){const[y,w,E,x]=f[A];if(y[0]===x[0]&&y[1]===x[1]&&_===1){const V=e*y[0]+l,W=e*y[1]+c;p.push(V,W),g.push(V,W);break}const S=e*y[0]+l,C=e*y[1]+c,T=e*w[0]+l,R=e*w[1]+c,M=e*E[0]+l,B=e*E[1]+c,I=e*x[0]+l,$=e*x[1]+c;A===0&&(p.push(S,C),g.push(S,C)),p.push(T,R,M,B,I,$),g.push(T,R),A===_-1&&g.push(I,$)}a.push({bezier:b(d=gt,ii,Kc).call(d,p,n,this.rotation),points:b(u=gt,ii,Kc).call(u,g,n,this.rotation)})}return a},Qc=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=H.bezierBoundingBox(...o,...l,...c,...d);e=Math.min(e,u[0]),i=Math.min(i,u[1]),s=Math.max(s,u[2]),n=Math.max(n,u[3])}return[e,i,s,n]},Wl=function(){return r(this,Fe)?Math.ceil(this.thickness*this.parentScale):0},ba=function(e=!1){if(this.isEmpty())return;if(!r(this,Fe)){b(this,L,Hi).call(this);return}const s=b(this,L,Qc).call(this),i=b(this,L,Wl).call(this);m(this,Rn,Math.max(nt.MIN_SIZE,s[2]-s[0])),m(this,Pn,Math.max(nt.MIN_SIZE,s[3]-s[1]));const n=Math.ceil(i+r(this,Rn)*this.scaleFactor),a=Math.ceil(i+r(this,Pn)*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,L,Jn).call(this),b(this,L,Hi).call(this),m(this,In,n),m(this,Dn,a),this.setDims(n,a);const u=e?i/this.scaleFactor/2:0;this.translate(c-this.translationX-u,d-this.translationY-u)},v(gt,ii),G(gt,"_defaultColor",null),G(gt,"_defaultOpacity",1),G(gt,"_defaultThickness",1),G(gt,"_type","ink"),G(gt,"_editorType",Z.INK);let Gc=gt;var Ut,$t,Ci,qs,Ti,Yr,ps,Xs,gs,Ze,tl,et,va,Aa,zl,Zc,Qf,Jf,td,Ul,Zf;const wa=class wa extends nt{constructor(e){super({...e,name:"stampEditor"});v(this,et);v(this,Ut,null);v(this,$t,null);v(this,Ci,null);v(this,qs,null);v(this,Ti,null);v(this,Yr,"");v(this,ps,null);v(this,Xs,null);v(this,gs,null);v(this,Ze,!1);v(this,tl,!1);m(this,qs,e.bitmapUrl),m(this,Ti,e.bitmapFile)}static initialize(e,s){nt.initialize(e,s)}static get supportedTypes(){return tt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return tt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(Z.STAMP,{bitmapFile:e.getAsFile()})}remove(){var e,s;r(this,$t)&&(m(this,Ut,null),this._uiManager.imageManager.deleteId(r(this,$t)),(e=r(this,ps))==null||e.remove(),m(this,ps,null),(s=r(this,Xs))==null||s.disconnect(),m(this,Xs,null),r(this,gs)&&(clearTimeout(r(this,gs)),m(this,gs,null))),super.remove()}rebuild(){if(!this.parent){r(this,$t)&&b(this,et,zl).call(this);return}super.rebuild(),this.div!==null&&(r(this,$t)&&r(this,ps)===null&&b(this,et,zl).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(r(this,Ci)||r(this,Ut)||r(this,qs)||r(this,Ti)||r(this,$t))}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,Ut)?b(this,et,Zc).call(this):b(this,et,zl).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,ps)}static deserialize(e,s,i){if(e instanceof mf)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,$t,l):m(n,qs,o),m(n,Ze,c);const[u,f]=n.pageDimensions;return n.width=(a[2]-a[0])/u,n.height=(a[3]-a[1])/f,d&&(n.altTextData=d),n}serialize(e=!1,s=null){if(this.isEmpty())return null;const i={annotationType:Z.STAMP,bitmapId:r(this,$t),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:r(this,Ze),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=b(this,et,Ul).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,Ze)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(r(this,$t)))s.stamps.set(r(this,$t),{area:o,serialized:i}),i.bitmap=b(this,et,Ul).call(this,!1);else if(r(this,Ze)){const l=s.stamps.get(r(this,$t));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,et,Ul).call(this,!1))}return i}};Ut=new WeakMap,$t=new WeakMap,Ci=new WeakMap,qs=new WeakMap,Ti=new WeakMap,Yr=new WeakMap,ps=new WeakMap,Xs=new WeakMap,gs=new WeakMap,Ze=new WeakMap,tl=new WeakMap,et=new WeakSet,va=function(e,s=!1){if(!e){this.remove();return}m(this,Ut,e.bitmap),s||(m(this,$t,e.id),m(this,Ze,e.isSvg)),e.file&&m(this,Yr,e.file.name),b(this,et,Zc).call(this)},Aa=function(){m(this,Ci,null),this._uiManager.enableWaiting(!1),r(this,ps)&&this.div.focus()},zl=function(){if(r(this,$t)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(r(this,$t)).then(i=>b(this,et,va).call(this,i,!0)).finally(()=>b(this,et,Aa).call(this));return}if(r(this,qs)){const i=r(this,qs);m(this,qs,null),this._uiManager.enableWaiting(!0),m(this,Ci,this._uiManager.imageManager.getFromUrl(i).then(n=>b(this,et,va).call(this,n)).finally(()=>b(this,et,Aa).call(this)));return}if(r(this,Ti)){const i=r(this,Ti);m(this,Ti,null),this._uiManager.enableWaiting(!0),m(this,Ci,this._uiManager.imageManager.getFromFile(i).then(n=>b(this,et,va).call(this,n)).finally(()=>b(this,et,Aa).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=wa.supportedTypesStr;const s=this._uiManager._signal;m(this,Ci,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);b(this,et,va).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,et,Aa).call(this))),e.click()},Zc=function(){const{div:e}=this;let{width:s,height:i}=r(this,Ut);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,ps,document.createElement("canvas"));e.append(d),e.hidden=!1,b(this,et,td).call(this,s,i),b(this,et,Zf).call(this),r(this,tl)||(this.parent.addUndoableEditor(this),m(this,tl,!0)),this._reportTelemetry({action:"inserted_image"}),r(this,Yr)&&d.setAttribute("aria-label",r(this,Yr))},Qf=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,gs)!==null&&clearTimeout(r(this,gs)),m(this,gs,setTimeout(()=>{m(this,gs,null),b(this,et,td).call(this,e,s)},200))},Jf=function(e,s){const{width:i,height:n}=r(this,Ut);let a=i,o=n,l=r(this,Ut);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},td=function(e,s){e=Math.ceil(e),s=Math.ceil(s);const i=r(this,ps);if(!i||i.width===e&&i.height===s)return;i.width=e,i.height=s;const n=r(this,Ze)?r(this,Ut):b(this,et,Jf).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)},Ul=function(e){if(e){if(r(this,Ze)){const n=this._uiManager.imageManager.getSvgUrl(r(this,$t));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=r(this,Ut),s.getContext("2d").drawImage(r(this,Ut),0,0),s.toDataURL()}if(r(this,Ze)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Li.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Li.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,a);return o.getContext("2d").drawImage(r(this,Ut),0,0,r(this,Ut).width,r(this,Ut).height,0,0,n,a),o.transferToImageBitmap()}return structuredClone(r(this,Ut))},Zf=function(){this._uiManager._signal&&(m(this,Xs,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&b(this,et,Qf).call(this,s.width,s.height)})),r(this,Xs).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,Xs))==null||e.disconnect(),m(this,Xs,null)},{once:!0}))},G(wa,"_type","stamp"),G(wa,"_editorType",Z.STAMP);let Jc=wa;var Fn,Kr,ms,On,Ys,Ks,Qs,Ce,Pi,Qr,Jr,se,j,Ri,Gt,tp,sd,id,nd,$l;const Be=class Be{constructor({uiManager:t,pageIndex:e,div:s,accessibilityManager:i,annotationLayer:n,drawLayer:a,textLayer:o,viewport:l,l10n:c}){v(this,Gt);v(this,Fn);v(this,Kr,!1);v(this,ms,null);v(this,On,null);v(this,Ys,null);v(this,Ks,null);v(this,Qs,null);v(this,Ce,new Map);v(this,Pi,!1);v(this,Qr,!1);v(this,Jr,!1);v(this,se,null);v(this,j);const d=[...r(Be,Ri).values()];if(!Be._initialized){Be._initialized=!0;for(const u of d)u.initialize(c,t)}t.registerEditorTypes(d),m(this,j,t),this.pageIndex=e,this.div=s,m(this,Fn,i),m(this,ms,n),this.viewport=l,m(this,se,o),this.drawLayer=a,r(this,j).addLayer(this)}get isEmpty(){return r(this,Ce).size===0}get isInvisible(){return this.isEmpty&&r(this,j).getMode()===Z.NONE}updateToolbar(t){r(this,j).updateToolbar(t)}updateMode(t=r(this,j).getMode()){switch(b(this,Gt,$l).call(this),t){case Z.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Z.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case Z.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(Be,Ri).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=r(this,se))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(r(this,j).getMode()!==Z.INK)return;if(!t){for(const s of r(this,Ce).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){r(this,j).setEditingState(t)}addCommands(t){r(this,j).addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=r(this,ms))==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,Ce).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(r(this,j).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!r(this,ms))return;const e=r(this,ms).getEditableAnnotations();for(const s of e){if(s.hide(),r(this,j).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,Jr,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of r(this,Ce).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,ms)){const n=r(this,ms).getEditableAnnotations();for(const a of n){const{id:o}=a.data;if(r(this,j).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,j).addChangedExistingAnnotation(l),l.renderAnnotationElement(a),l.show(!1)),a.show()}}b(this,Gt,$l).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of r(Be,Ri).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),m(this,Jr,!1)}getEditableAnnotation(t){var e;return((e=r(this,ms))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){r(this,j).getActive()!==t&&r(this,j).setActiveEditor(t)}enableTextSelection(){var t;this.div.tabIndex=-1,(t=r(this,se))!=null&&t.div&&!r(this,Ks)&&(m(this,Ks,b(this,Gt,tp).bind(this)),r(this,se).div.addEventListener("pointerdown",r(this,Ks),{signal:r(this,j)._signal}),r(this,se).div.classList.add("highlighting"))}disableTextSelection(){var t;this.div.tabIndex=0,(t=r(this,se))!=null&&t.div&&r(this,Ks)&&(r(this,se).div.removeEventListener("pointerdown",r(this,Ks)),m(this,Ks,null),r(this,se).div.classList.remove("highlighting"))}enableClick(){if(r(this,Ys))return;const t=r(this,j)._signal;m(this,Ys,this.pointerdown.bind(this)),m(this,On,this.pointerup.bind(this)),this.div.addEventListener("pointerdown",r(this,Ys),{signal:t}),this.div.addEventListener("pointerup",r(this,On),{signal:t})}disableClick(){r(this,Ys)&&(this.div.removeEventListener("pointerdown",r(this,Ys)),this.div.removeEventListener("pointerup",r(this,On)),m(this,Ys,null),m(this,On,null))}attach(t){r(this,Ce).set(t.id,t);const{annotationElementId:e}=t;e&&r(this,j).isDeletedAnnotationElement(e)&&r(this,j).removeDeletedAnnotationElement(t)}detach(t){var e;r(this,Ce).delete(t.id),(e=r(this,Fn))==null||e.removePointerInTextLayer(t.contentDiv),!r(this,Jr)&&t.annotationElementId&&r(this,j).addDeletedAnnotationElement(t)}remove(t){this.detach(t),r(this,j).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,r(this,Qr)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(r(this,j).addDeletedAnnotationElement(t.annotationElementId),nt.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,j).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),r(this,j).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!r(this,Qs)&&(t._focusEventsAllowed=!1,m(this,Qs,setTimeout(()=>{m(this,Qs,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:r(this,j)._signal}),e.focus())},0))),t._structTreeParentId=(s=r(this,Fn))==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,j).getId()}get _signal(){return r(this,j)._signal}canCreateNewEmptyEditor(){var t;return(t=r(this,Gt,sd))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){r(this,j).updateToolbar(t),r(this,j).updateMode(t);const{offsetX:s,offsetY:i}=b(this,Gt,nd).call(this),n=this.getNextId(),a=b(this,Gt,id).call(this,{parent:this,id:n,x:s,y:i,uiManager:r(this,j),isCentered:!0,...e});a&&this.add(a)}deserialize(t){var e;return((e=r(Be,Ri).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,r(this,j)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=b(this,Gt,id).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:r(this,j),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(b(this,Gt,nd).call(this),!0)}setSelected(t){r(this,j).setSelected(t)}toggleSelected(t){r(this,j).toggleSelected(t)}isSelected(t){return r(this,j).isSelected(t)}unselect(t){r(this,j).unselect(t)}pointerup(t){const{isMac:e}=de.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&r(this,Pi)){if(m(this,Pi,!1),!r(this,Kr)){m(this,Kr,!0);return}if(r(this,j).getMode()===Z.STAMP){r(this,j).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(r(this,j).getMode()===Z.HIGHLIGHT&&this.enableTextSelection(),r(this,Pi)){m(this,Pi,!1);return}const{isMac:e}=de.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;m(this,Pi,!0);const s=r(this,j).getActive();m(this,Kr,!s||s.isEmpty())}findNewParent(t,e,s){const i=r(this,j).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=r(this,j).getActive())==null?void 0:t.parent)===this&&(r(this,j).commitOrRemove(),r(this,j).setActiveEditor(null)),r(this,Qs)&&(clearTimeout(r(this,Qs)),m(this,Qs,null));for(const s of r(this,Ce).values())(e=r(this,Fn))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,r(this,Ce).clear(),r(this,j).removeLayer(this)}render({viewport:t}){this.viewport=t,Nn(this.div,t);for(const e of r(this,j).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){r(this,j).commitOrRemove(),b(this,Gt,$l).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Nn(this.div,{rotation:s}),e!==s)for(const i of r(this,Ce).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,j).viewParameters.realScale}};Fn=new WeakMap,Kr=new WeakMap,ms=new WeakMap,On=new WeakMap,Ys=new WeakMap,Ks=new WeakMap,Qs=new WeakMap,Ce=new WeakMap,Pi=new WeakMap,Qr=new WeakMap,Jr=new WeakMap,se=new WeakMap,j=new WeakMap,Ri=new WeakMap,Gt=new WeakSet,tp=function(t){if(r(this,j).unselectAll(),t.target===r(this,se).div){const{isMac:e}=de.platform;if(t.button!==0||t.ctrlKey&&e)return;r(this,j).showAllEditors("highlight",!0,!0),r(this,se).div.classList.add("free"),th.startHighlighting(this,r(this,j).direction==="ltr",t),r(this,se).div.addEventListener("pointerup",()=>{r(this,se).div.classList.remove("free")},{once:!0,signal:r(this,j)._signal}),t.preventDefault()}},sd=function(){return r(Be,Ri).get(r(this,j).getMode())},id=function(t){const e=r(this,Gt,sd);return e?new e.prototype.constructor(t):null},nd=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),c=(n+o)/2-t,d=(a+l)/2-e,[u,f]=this.viewport.rotation%180===0?[c,d]:[d,c];return{offsetX:u,offsetY:f}},$l=function(){m(this,Qr,!0);for(const t of r(this,Ce).values())t.isEmpty()&&t.remove();m(this,Qr,!1)},G(Be,"_initialized",!1),v(Be,Ri,new Map([Dc,Gc,Jc,th].map(t=>[t._editorType,t])));let ed=Be;var bs,el,Lt,ki,sl,ad,zn,od,ep;const Ht=class Ht{constructor({pageIndex:t}){v(this,zn);v(this,bs,null);v(this,el,0);v(this,Lt,new Map);v(this,ki,new Map);this.pageIndex=t}setParent(t){if(!r(this,bs)){m(this,bs,t);return}if(r(this,bs)!==t){if(r(this,Lt).size>0)for(const e of r(this,Lt).values())e.remove(),t.append(e);m(this,bs,t)}}static get _svgFactory(){return tt(this,"_svgFactory",new ud)}highlight(t,e,s,i=!1){const n=me(this,el)._++,a=b(this,zn,od).call(this,t.box);a.classList.add("highlight"),t.free&&a.classList.add("free");const o=Ht._svgFactory.createElement("defs");a.append(o);const l=Ht._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,ki).set(n,l);const d=b(this,zn,ep).call(this,o,c),u=Ht._svgFactory.createElement("use");return a.append(u),a.setAttribute("fill",e),a.setAttribute("fill-opacity",s),u.setAttribute("href",`#${c}`),r(this,Lt).set(n,a),{id:n,clipPathId:`url(#${d})`}}highlightOutline(t){const e=me(this,el)._++,s=b(this,zn,od).call(this,t.box);s.classList.add("highlightOutline");const i=Ht._svgFactory.createElement("defs");s.append(i);const n=Ht._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=Ht._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=Ht._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=Ht._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const l=Ht._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,Lt).set(e,s),e}finalizeLine(t,e){const s=r(this,ki).get(t);r(this,ki).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){r(this,Lt).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),r(this,ki).delete(t)}updatePath(t,e){r(this,ki).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;b(s=Ht,sl,ad).call(s,r(this,Lt).get(t),e)}show(t,e){r(this,Lt).get(t).classList.toggle("hidden",!e)}rotate(t,e){r(this,Lt).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){r(this,Lt).get(t).setAttribute("fill",e)}changeOpacity(t,e){r(this,Lt).get(t).setAttribute("fill-opacity",e)}addClass(t,e){r(this,Lt).get(t).classList.add(e)}removeClass(t,e){r(this,Lt).get(t).classList.remove(e)}remove(t){r(this,bs)!==null&&(r(this,Lt).get(t).remove(),r(this,Lt).delete(t))}destroy(){m(this,bs,null);for(const t of r(this,Lt).values())t.remove();r(this,Lt).clear()}};bs=new WeakMap,el=new WeakMap,Lt=new WeakMap,ki=new WeakMap,sl=new WeakSet,ad=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}%`},zn=new WeakSet,od=function(t){var s;const e=Ht._svgFactory.create(1,1,!0);return r(this,bs).append(e),e.setAttribute("aria-hidden",!0),b(s=Ht,sl,ad).call(s,e,t),e},ep=function(t,e){const s=Ht._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=Ht._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},v(Ht,sl);let rd=Ht;var lb=z.AbortException,hb=z.AnnotationEditorLayer,cb=z.AnnotationEditorParamsType,db=z.AnnotationEditorType,ub=z.AnnotationEditorUIManager,sp=z.AnnotationLayer,ip=z.AnnotationMode,fb=z.CMapCompressionType,pb=z.ColorPicker,gb=z.DOMSVGFactory,mb=z.DrawLayer,bb=z.FeatureTest,Mh=z.GlobalWorkerOptions,vb=z.ImageKind,Ab=z.InvalidPDFException,yb=z.MissingPDFException,_b=z.OPS,wb=z.Outliner,Eb=z.PDFDataRangeTransport,xb=z.PDFDateString,Sb=z.PDFWorker,Cb=z.PasswordResponses,Tb=z.PermissionFlag,Pb=z.PixelsPerInch,Rb=z.RenderingCancelledException,np=z.TextLayer,kb=z.UnexpectedResponseException,Lb=z.Util,Mb=z.VerbosityLevel,Ib=z.XfaLayer,Db=z.build,Fb=z.createValidAbsoluteUrl,Ob=z.fetchData,rp=z.getDocument,Nb=z.getFilenameFromUrl,Hb=z.getPdfFilenameFromUrl,Bb=z.getXfaPageViewport,jb=z.isDataScheme,Wb=z.isPdfFile,zb=z.noContextMenu,Ub=z.normalizeUnicode,$b=z.renderTextLayer,Gb=z.setLayerDimensions,Vb=z.shadow,qb=z.updateTextLayer,Xb=z.version;const Yb=Object.freeze(Object.defineProperty({__proto__:null,AbortException:lb,AnnotationEditorLayer:hb,AnnotationEditorParamsType:cb,AnnotationEditorType:db,AnnotationEditorUIManager:ub,AnnotationLayer:sp,AnnotationMode:ip,CMapCompressionType:fb,ColorPicker:pb,DOMSVGFactory:gb,DrawLayer:mb,FeatureTest:bb,GlobalWorkerOptions:Mh,ImageKind:vb,InvalidPDFException:Ab,MissingPDFException:yb,OPS:_b,Outliner:wb,PDFDataRangeTransport:Eb,PDFDateString:xb,PDFWorker:Sb,PasswordResponses:Cb,PermissionFlag:Tb,PixelsPerInch:Pb,RenderingCancelledException:Rb,TextLayer:np,UnexpectedResponseException:kb,Util:Lb,VerbosityLevel:Mb,XfaLayer:Ib,build:Db,createValidAbsoluteUrl:Fb,fetchData:Ob,getDocument:rp,getFilenameFromUrl:Nb,getPdfFilenameFromUrl:Hb,getXfaPageViewport:Bb,isDataScheme:jb,isPdfFile:Wb,noContextMenu:zb,normalizeUnicode:Ub,renderTextLayer:$b,setLayerDimensions:Gb,shadow:Vb,updateTextLayer:qb,version:Xb},Symbol.toStringTag,{value:"Module"}));var Ft=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))},Kb=["onCopy","onCut","onPaste"],Qb=["onCompositionEnd","onCompositionStart","onCompositionUpdate"],Jb=["onFocus","onBlur"],Zb=["onInput","onInvalid","onReset","onSubmit"],tv=["onLoad","onError"],ev=["onKeyDown","onKeyPress","onKeyUp"],sv=["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"],nv=["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],rv=["onSelect"],av=["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],ov=["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],lv=["onScroll"],hv=["onWheel"],cv=["onAnimationStart","onAnimationEnd","onAnimationIteration"],dv=["onTransitionEnd"],uv=["onToggle"],fv=["onChange"],pv=Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft(Ft([],Kb,!0),Qb,!0),Jb,!0),Zb,!0),tv,!0),ev,!0),sv,!0),iv,!0),nv,!0),rv,!0),av,!0),ov,!0),lv,!0),hv,!0),cv,!0),dv,!0),fv,!0),uv,!0);function ap(h,t){var e={};return pv.forEach(function(s){var i=h[s];i&&(t?e[s]=function(n){return i(n,t(s))}:e[s]=i)}),e}function ol(h){var t=!1,e=new Promise(function(s,i){h.then(function(n){return!t&&s(n)}).catch(function(n){return!t&&i(n)})});return{promise:e,cancel:function(){t=!0}}}var gv=function(){},mv=gv;const Qt=zp(mv);var $d=Object.prototype.hasOwnProperty;function Gd(h,t,e){for(e of h.keys())if(sr(e,t))return e}function sr(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--&&sr(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=Gd(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=Gd(t,i),!i)||!sr(s[1],t.get(i)))return!1;return!0}if(e===ArrayBuffer)h=new Uint8Array(h),t=new Uint8Array(t);else if(e===DataView){if((s=h.byteLength)===t.byteLength)for(;s--&&h.getInt8(s)===t.getInt8(s););return s===-1}if(ArrayBuffer.isView(h)){if((s=h.byteLength)===t.byteLength)for(;s--&&h[s]===t[s];);return s===-1}if(!e||typeof h=="object"){s=0;for(e in h)if($d.call(h,e)&&++s&&!$d.call(t,e)||!(e in t)||!sr(h[e],t[e]))return!1;return Object.keys(t).length===s}}return h!==h&&t!==t}const op=F.createContext(null);function ir({children:h,type:t}){return P.jsx("div",{className:`react-pdf__message react-pdf__message--${t}`,children:h})}const bv="noopener noreferrer nofollow";class vv{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 ht(this.pdfViewer),this.pdfViewer.currentPageNumber||0}set page(t){ht(this.pdfViewer),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}goToDestination(t){return new Promise(e=>{ht(this.pdfDocument),ht(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{ht(Array.isArray(e));const s=e[0];new Promise(i=>{ht(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{ht(!1)}):typeof s=="number"?i(s):ht(!1)}).then(i=>{const n=i+1;ht(this.pdfViewer),ht(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;ht(this.pdfViewer),ht(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||bv,t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const Vd={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Ih=typeof document<"u",lp=Ih&&window.location.protocol==="file:";function Av(h){return typeof h<"u"}function Fi(h){return Av(h)&&h!==null}function yv(h){return typeof h=="string"}function _v(h){return h instanceof ArrayBuffer}function wv(h){return ht(Ih),h instanceof Blob}function ld(h){return yv(h)&&/^data:/.test(h)}function qd(h){ht(ld(h));const[t="",e=""]=h.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function Ev(){return Ih&&window.devicePixelRatio||1}const hp="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function Xd(){Qt(!lp,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${hp}`)}function xv(){Qt(!lp,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${hp}`)}function jn(h){h!=null&&h.cancel&&h.cancel()}function hd(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 Sv(h){return h.name==="RenderingCancelledException"}function Cv(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 Tv(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 Zr(){return F.useReducer(Tv,{value:void 0,error:void 0})}var Pv=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())})},Yd=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:Rv}=Yb,kv=(h,t)=>{switch(t){case Vd.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");h(e);break}case Vd.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");h(e);break}}};function Kd(h){return typeof h=="object"&&h!==null&&("data"in h||"range"in h||"url"in h)}const cp=F.forwardRef(function(t,e){var{children:s,className:i,error:n="Failed to load PDF file.",externalLinkRel:a,externalLinkTarget:o,file:l,inputRef:c,imageResourcesPath:d,loading:u="Loading PDF…",noData:f="No PDF file specified.",onItemClick:p,onLoadError:g,onLoadProgress:A,onLoadSuccess:_,onPassword:y=kv,onSourceError:w,onSourceSuccess:E,options:x,renderMode:S,rotate:C}=t,T=Yd(t,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[R,M]=Zr(),{value:B,error:I}=R,[$,V]=Zr(),{value:W,error:X}=$,Q=F.useRef(new vv),D=F.useRef([]),O=F.useRef(void 0),pe=F.useRef(void 0);l&&l!==O.current&&Kd(l)&&(Qt(!sr(l,O.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.`),O.current=l),x&&x!==pe.current&&(Qt(!sr(x,pe.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.`),pe.current=x);const Re=F.useRef({scrollPageIntoView:dt=>{const{dest:wt,pageNumber:Vt,pageIndex:Dt=Vt-1}=dt;if(p){p({dest:wt,pageIndex:Dt,pageNumber:Vt});return}const ri=D.current[Dt];if(ri){ri.scrollIntoView();return}Qt(!1,`An internal link leading to page ${Vt} 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:Q,pages:D,viewer:Re}),[]);function ni(){E&&E()}function At(){I&&(Qt(!1,I.toString()),w&&w(I))}function pt(){M({type:"RESET"})}F.useEffect(pt,[l,M]);const ke=F.useCallback(()=>Pv(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return ld(l)?{data:qd(l)}:(Xd(),{url:l});if(l instanceof Rv)return{range:l};if(_v(l))return{data:l};if(Ih&&wv(l))return{data:yield Cv(l)};if(ht(typeof l=="object"),ht(Kd(l)),"url"in l&&typeof l.url=="string"){if(ld(l.url)){const{url:dt}=l,wt=Yd(l,["url"]),Vt=qd(dt);return Object.assign({data:Vt},wt)}Xd()}return l}),[l]);F.useEffect(()=>{const dt=ol(ke());return dt.promise.then(wt=>{M({type:"RESOLVE",value:wt})}).catch(wt=>{M({type:"REJECT",error:wt})}),()=>{jn(dt)}},[ke,M]),F.useEffect(()=>{if(!(typeof B>"u")){if(B===!1){At();return}ni()}},[B]);function ge(){W&&(_&&_(W),D.current=new Array(W.numPages),Q.current.setDocument(W))}function Zt(){X&&(Qt(!1,X.toString()),g&&g(X))}F.useEffect(function(){V({type:"RESET"})},[V,B]),F.useEffect(function(){if(!B)return;const wt=Object.assign(Object.assign({},B),x),Vt=rp(wt);A&&(Vt.onProgress=A),y&&(Vt.onPassword=y);const Dt=Vt;return Dt.promise.then(ri=>{V({type:"RESOLVE",value:ri})}).catch(ri=>{Dt.destroyed||V({type:"REJECT",error:ri})}),()=>{Dt.destroy()}},[x,V,B]),F.useEffect(()=>{if(!(typeof W>"u")){if(W===!1){Zt();return}ge()}},[W]),F.useEffect(function(){Q.current.setViewer(Re.current),Q.current.setExternalLinkRel(a),Q.current.setExternalLinkTarget(o)},[a,o]);const ft=F.useCallback((dt,wt)=>{D.current[dt]=wt},[]),ae=F.useCallback(dt=>{delete D.current[dt]},[]),ts=F.useMemo(()=>({imageResourcesPath:d,linkService:Q.current,onItemClick:p,pdf:W,registerPage:ft,renderMode:S,rotate:C,unregisterPage:ae}),[d,p,W,ft,S,C,ae]),bt=F.useMemo(()=>ap(T,()=>W),[T,W]);function ta(){return P.jsx(op.Provider,{value:ts,children:s})}function ea(){return l?W==null?P.jsx(ir,{type:"loading",children:typeof u=="function"?u():u}):W===!1?P.jsx(ir,{type:"error",children:typeof n=="function"?n():n}):ta():P.jsx(ir,{type:"no-data",children:typeof f=="function"?f():f})}return P.jsx("div",Object.assign({className:yh("react-pdf__Document",i),ref:c,style:{"--scale-factor":"1"}},bt,{children:ea()}))});function dp(){return F.useContext(op)}function up(){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 fp=F.createContext(null),pp={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},Lv=/^H(\d+)$/;function Mv(h){return h in pp}function Dh(h){return"children"in h}function gp(h){return Dh(h)?h.children.length===1&&0 in h.children&&"id"in h.children[0]:!1}function Iv(h){const t={};if(Dh(h)){const{role:e}=h,s=e.match(Lv);if(s)t.role="heading",t["aria-level"]=Number(s[1]);else if(Mv(e)){const i=pp[e];i&&(t.role=i)}}return t}function mp(h){const t={};if(Dh(h)){if(h.alt!==void 0&&(t["aria-label"]=h.alt),h.lang!==void 0&&(t.lang=h.lang),gp(h)){const[e]=h.children;if(e){const s=mp(e);return Object.assign(Object.assign({},t),s)}}}else"id"in h&&(t["aria-owns"]=h.id);return t}function Dv(h){return h?Object.assign(Object.assign({},Iv(h)),mp(h)):null}function bp({className:h,node:t}){const e=F.useMemo(()=>Dv(t),[t]),s=F.useMemo(()=>!Dh(t)||gp(t)?null:t.children.map((i,n)=>P.jsx(bp,{node:i},n)),[t]);return P.jsx("span",Object.assign({className:h},e,{children:s}))}function Fh(){return F.useContext(fp)}function Fv(){const h=Fh();ht(h);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=h,[s,i]=Zr(),{value:n,error:a}=s,{customTextRenderer:o,page:l}=h;function c(){n&&e&&e(n)}function d(){a&&(Qt(!1,a.toString()),t&&t(a))}return F.useEffect(function(){i({type:"RESET"})},[i,l]),F.useEffect(function(){if(o||!l)return;const f=ol(l.getStructTree()),p=f;return f.promise.then(g=>{i({type:"RESOLVE",value:g})}).catch(g=>{i({type:"REJECT",error:g})}),()=>jn(p)},[o,l,i]),F.useEffect(()=>{if(n!==void 0){if(n===!1){d();return}c()}},[n]),n?P.jsx(bp,{className:"react-pdf__Page__structTree structTree",node:n}):null}const Qd=ip;function Ov(h){const t=Fh();ht(t);const e=Object.assign(Object.assign({},t),h),{_className:s,canvasBackground:i,devicePixelRatio:n=Ev(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:c,renderTextLayer:d,rotate:u,scale:f}=e,{canvasRef:p}=h;ht(l);const g=F.useRef(null);function A(){l&&o&&o(hd(l,f))}function _(x){Sv(x)||(Qt(!1,x.toString()),a&&a(x))}const y=F.useMemo(()=>l.getViewport({scale:f*n,rotation:u}),[n,l,u,f]),w=F.useMemo(()=>l.getViewport({scale:f,rotation:u}),[l,u,f]);F.useEffect(function(){if(!l)return;l.cleanup();const{current:S}=g;if(!S)return;S.width=y.width,S.height=y.height,S.style.width=`${Math.floor(w.width)}px`,S.style.height=`${Math.floor(w.height)}px`,S.style.visibility="hidden";const C={annotationMode:c?Qd.ENABLE_FORMS:Qd.ENABLE,canvasContext:S.getContext("2d",{alpha:!1}),viewport:y};i&&(C.background=i);const T=l.render(C),R=T;return T.promise.then(()=>{S.style.visibility="",A()}).catch(_),()=>jn(R)},[i,l,c,y,w]);const E=F.useCallback(()=>{const{current:x}=g;x&&(x.width=0,x.height=0)},[]);return F.useEffect(()=>E,[E]),P.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:up(p,g),style:{display:"block",userSelect:"none"},children:d?P.jsx(Fv,{}):null})}function Nv(h){return"str"in h}function Hv(){const h=Fh();ht(h);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:a,pageIndex:o,pageNumber:l,rotate:c,scale:d}=h;ht(a);const[u,f]=Zr(),{value:p,error:g}=u,A=F.useRef(null),_=F.useRef(void 0);Qt(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function y(){p&&s&&s(p)}function w(){g&&(Qt(!1,g.toString()),e&&e(g))}F.useEffect(function(){f({type:"RESET"})},[a,f]),F.useEffect(function(){if(!a)return;const M=ol(a.getTextContent()),B=M;return M.promise.then(I=>{f({type:"RESOLVE",value:I})}).catch(I=>{f({type:"REJECT",error:I})}),()=>jn(B)},[a,f]),F.useEffect(()=>{if(p!==void 0){if(p===!1){w();return}y()}},[p]);const E=F.useCallback(()=>{n&&n()},[n]),x=F.useCallback(R=>{Qt(!1,R.toString()),i&&i(R)},[i]);function S(){const R=_.current;R&&R.classList.add("active")}function C(){const R=_.current;R&&R.classList.remove("active")}const T=F.useMemo(()=>a.getViewport({scale:d,rotation:c}),[a,c,d]);return F.useLayoutEffect(function(){if(!a||!p)return;const{current:M}=A;if(!M)return;M.innerHTML="";const B=a.streamTextContent({includeMarkedContent:!0}),I={container:M,textContentSource:B,viewport:T},$=new np(I),V=$;return $.render().then(()=>{const W=document.createElement("div");W.className="endOfContent",M.append(W),_.current=W;const X=M.querySelectorAll('[role="presentation"]');if(t){let Q=0;p.items.forEach((D,O)=>{if(!Nv(D))return;const pe=X[Q];if(!pe)return;const Re=t(Object.assign({pageIndex:o,pageNumber:l,itemIndex:O},D));pe.innerHTML=Re,Q+=D.str&&D.hasEOL?2:1})}E()}).catch(x),()=>jn(V)},[t,x,E,a,o,l,p,T]),P.jsx("div",{className:yh("react-pdf__Page__textContent","textLayer"),onMouseUp:C,onMouseDown:S,ref:A})}function Bv(){const h=dp(),t=Fh();ht(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:f,scale:p=1}=e;ht(d),ht(c),ht(i);const[g,A]=Zr(),{value:_,error:y}=g,w=F.useRef(null);Qt(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function E(){_&&a&&a(_)}function x(){y&&(Qt(!1,y.toString()),n&&n(y))}F.useEffect(function(){A({type:"RESET"})},[A,c]),F.useEffect(function(){if(!c)return;const M=ol(c.getAnnotations()),B=M;return M.promise.then(I=>{A({type:"RESOLVE",value:I})}).catch(I=>{A({type:"REJECT",error:I})}),()=>{jn(B)}},[A,c]),F.useEffect(()=>{if(_!==void 0){if(_===!1){x();return}E()}},[_]);function S(){l&&l()}function C(R){Qt(!1,`${R}`),o&&o(R)}const T=F.useMemo(()=>c.getViewport({scale:p,rotation:f}),[c,f,p]);return F.useEffect(function(){if(!d||!c||!i||!_)return;const{current:M}=w;if(!M)return;const B=T.clone({dontFlip:!0}),I={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:M,l10n:null,page:c,viewport:B},$={annotations:_,annotationStorage:d.annotationStorage,div:M,imageResourcesPath:s,linkService:i,page:c,renderForms:u,viewport:B};M.innerHTML="";try{new sp(I).render($),S()}catch(V){C(V)}return()=>{}},[_,s,i,c,d,u,T]),P.jsx("div",{className:yh("react-pdf__Page__annotations","annotationLayer"),ref:w})}var jv=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(h,s[i])&&(e[s[i]]=h[s[i]]);return e};const Jd=1;function vp(h){const t=dp(),e=Object.assign(Object.assign({},t),h),{_className:s="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:n,canvasRef:a,children:o,className:l,customRenderer:c,customTextRenderer:d,devicePixelRatio:u,error:f="Failed to load the page.",height:p,inputRef:g,loading:A="Loading page…",noData:_="No page specified.",onGetAnnotationsError:y,onGetAnnotationsSuccess:w,onGetStructTreeError:E,onGetStructTreeSuccess:x,onGetTextError:S,onGetTextSuccess:C,onLoadError:T,onLoadSuccess:R,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:B,onRenderError:I,onRenderSuccess:$,onRenderTextLayerError:V,onRenderTextLayerSuccess:W,pageIndex:X,pageNumber:Q,pdf:D,registerPage:O,renderAnnotationLayer:pe=!0,renderForms:Re=!1,renderMode:ni="canvas",renderTextLayer:At=!0,rotate:pt,scale:ke=Jd,unregisterPage:ge,width:Zt}=e,ft=jv(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"]),[ae,ts]=Zr(),{value:bt,error:ta}=ae,ea=F.useRef(null);ht(D);const dt=Fi(Q)?Q-1:X??null,wt=Q??(Fi(X)?X+1:null),Vt=pt??(bt?bt.rotate:null),Dt=F.useMemo(()=>{if(!bt)return null;let Vn=1;const hl=ke??Jd;if(Zt||p){const cl=bt.getViewport({scale:1,rotation:Vt});Zt?Vn=Zt/cl.width:p&&(Vn=p/cl.height)}return hl*Vn},[p,bt,Vt,ke,Zt]);F.useEffect(function(){return()=>{Fi(dt)&&i&&ge&&ge(dt)}},[i,D,dt,ge]);function ri(){if(R){if(!bt||!Dt)return;R(hd(bt,Dt))}if(i&&O){if(!Fi(dt)||!ea.current)return;O(dt,ea.current)}}function Mp(){ta&&(Qt(!1,ta.toString()),T&&T(ta))}F.useEffect(function(){ts({type:"RESET"})},[ts,D,dt]),F.useEffect(function(){if(!D||!wt)return;const hl=ol(D.getPage(wt)),cl=hl;return hl.promise.then(Oh=>{ts({type:"RESOLVE",value:Oh})}).catch(Oh=>{ts({type:"REJECT",error:Oh})}),()=>jn(cl)},[ts,D,wt]),F.useEffect(()=>{if(bt!==void 0){if(bt===!1){Mp();return}ri()}},[bt,Dt]);const Ip=F.useMemo(()=>bt&&Fi(dt)&&wt&&Fi(Vt)&&Fi(Dt)?{_className:s,canvasBackground:n,customTextRenderer:d,devicePixelRatio:u,onGetAnnotationsError:y,onGetAnnotationsSuccess:w,onGetStructTreeError:E,onGetStructTreeSuccess:x,onGetTextError:S,onGetTextSuccess:C,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:B,onRenderError:I,onRenderSuccess:$,onRenderTextLayerError:V,onRenderTextLayerSuccess:W,page:bt,pageIndex:dt,pageNumber:wt,renderForms:Re,renderTextLayer:At,rotate:Vt,scale:Dt}:null,[s,n,d,u,y,w,E,x,S,C,M,B,I,$,V,W,bt,dt,wt,Re,At,Vt,Dt]),Dp=F.useMemo(()=>ap(ft,()=>bt&&(Dt?hd(bt,Dt):void 0)),[ft,bt,Dt]),ll=`${dt}@${Dt}/${Vt}`;function Fp(){switch(ni){case"custom":return ht(c),P.jsx(c,{},`${ll}_custom`);case"none":return null;case"canvas":default:return P.jsx(Ov,{canvasRef:a},`${ll}_canvas`)}}function Op(){return At?P.jsx(Hv,{},`${ll}_text`):null}function Np(){return pe?P.jsx(Bv,{},`${ll}_annotations`):null}function Hp(){return P.jsxs(fp.Provider,{value:Ip,children:[Fp(),Op(),Np(),o]})}function Bp(){return wt?D===null||bt===void 0||bt===null?P.jsx(ir,{type:"loading",children:typeof A=="function"?A():A}):D===!1||bt===!1?P.jsx(ir,{type:"error",children:typeof f=="function"?f():f}):Hp():P.jsx(ir,{type:"no-data",children:typeof _=="function"?_():_})}return P.jsx("div",Object.assign({className:yh(s,l),"data-page-number":wt,ref:up(g,ea),style:{"--scale-factor":`${Dt}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},Dp,{children:Bp()}))}xv();Mh.workerSrc="pdf.worker.mjs";var yd={},Wv=$p;Object.defineProperty(yd,"__esModule",{value:!0});var Ap=yd.default=void 0,zv=Wv(Up()),Uv=P;Ap=yd.default=(0,zv.default)((0,Uv.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");function $v({right:h}){return P.jsx(iu,{style:h?{transform:"rotate(180deg)"}:{},icon:{parts:[{type:"circle",props:{cx:"26",cy:"26",r:"25",stroke:"currentColor",strokeWidth:"2",fill:"none"}},{type:"path",props:{d:"M30 18L21 26L30 34",stroke:"currentColor",strokeWidth:"2",fill:"none"}}],viewSize:52}})}function Gv({right:h}){return P.jsx(iu,{style:h?{transform:"rotate(180deg)"}:{},icon:{parts:[{type:"circle",props:{cx:"20",cy:"20",r:"19",stroke:"currentColor",strokeWidth:"2",fill:"none"}},{type:"path",props:{d:"M23.0769 13.8462L16.1538 20L23.0769 26.1539",stroke:"currentColor",strokeWidth:"2",fill:"none"}}],viewSize:40}})}const Zd={position:"absolute",top:"calc(50% - 26px)",borderRadius:"50%",width:52,height:52},Tt={BackgroundOverlay:St("div")(h=>({position:"absolute",top:-1,left:0,width:"100%",background:h.color,zIndex:1,height:149})),ContentContiner:St("div")({position:"relative",alignItems:"center",display:"flex",width:"100%",flexDirection:"column"}),ContentWrapper:St(ul("div",["hasArrows"]))(({theme:h,hasArrows:t})=>({background:"#fff",borderRadius:"8px",padding:"36px",display:"flex",flexDirection:"column",alignItems:"center",position:"relative",width:389,zIndex:2,...t?{[h.breakpoints.down("sm")]:{maxWidth:"calc(100vw - 124px)"},[h.breakpoints.down(442)]:{padding:"24px 20px 92px"},"&.force-mobile":{padding:"24px 20px",maxWidth:"calc(100vw - 124px)"}}:{"@media (max-width: 442px)":{maxWidth:280,padding:"24px 20px 92px","&.fullscreen":{maxWidth:"100vw",height:"100vh"}},"&.force-mobile":{maxWidth:280,padding:"24px 20px","&.fullscreen":{maxWidth:"100vw",height:"100vh"}}}})),ButtonPrev:St(ul("button",["color"]))(({theme:h,color:t})=>({...Zd,left:-84,color:t,[h.breakpoints.down("sm")]:{width:40,height:40,left:-52}})),ButtonNext:St(ul("button",["color"]))(({theme:h,color:t})=>({...Zd,right:-84,color:t,[h.breakpoints.down("sm")]:{width:40,height:40,right:-52}})),HeaderText:St("div")(h=>({color:h.color,marginBottom:"12px",textAlign:"center",fontSize:"13px",lineHeight:"19px","@media (max-width: 442px)":{marginBottom:"12px"},"&.force-mobile":{marginBottom:"12px"}})),Subtitle:St("h2")(h=>({color:h.color,fontSize:"16px",lineHeight:"25px",marginTop:"12px",fontWeight:300,marginBottom:"33px",textAlign:"center",minHeight:"25px","@media (max-width: 442px)":{fontSize:"14px",lineHeight:"21px",marginBottom:"28px"},"&.force-mobile":{fontSize:"14px",lineHeight:"21px",marginBottom:"28px"},".contained-box &":{marginBottom:20}})),ButtonWrapper:St("div")(({theme:h})=>({marginTop:20,display:"flex",justifyContent:"center",position:"relative",zIndex:2,width:"100%",[h.breakpoints.down(442)]:{width:"calc(100vw - 20px)",position:"absolute",bottom:24}})),ViewPdfButton:St("a")(({theme:h,...t})=>({width:"100%",display:"block","& button":{width:"100%",background:t.color,"&:hover":{background:t.color},color:vl.getFontColor(t.color)},[h.breakpoints.down(442)]:{minWidth:232,width:"auto"},"&.force-mobile":{minWidth:232}})),ButtonText:St("p")({whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"}),Website:St("div")({color:Pe.gray.darkest,fontSize:"13px",lineHeight:"19px",textAlign:"center",minHeight:"19px",marginBottom:"52px",display:"block",marginTop:"32px",padding:"0 30px","@media (max-width: 442px)":{marginBottom:"42px",marginTop:"24px"},"&.force-mobile":{marginBottom:"42px",marginTop:"24px"}}),PdfContentWrapper:St(ul("div",["fullscreen"]))(({fullscreen:h})=>({width:"100%",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",zIndex:2,flexDirection:"column",height:"390px",background:"white",overflow:"hidden","& canvas":{margin:"0 auto"},"@media (max-width: 442px)":{height:h?"100vh":273},"&.force-mobile":{height:h?"100vh":273},"& .react-pdf__Document":{marginTop:"auto",marginBottom:"auto"}})),PdfEmpty:St("div")({backgroundColor:Pe.secondary.lightBlue,borderRadius:8,height:"100%",width:"100%",...Gl.centerFlex,"& svg":{color:Pe.gray.normal}},{name:"PdfEmpty"}),Thumbnail:St("img")({width:"auto",maxWidth:"100%",height:"auto",verticalAlign:"top"}),BoxShadow:St("div")({position:"absolute",top:"148px",left:0,width:"100%",height:"calc(100% - 148px)",boxShadow:Gp,zIndex:1,"@media (max-width: 442px)":{top:"145px",height:"calc(100% - 145px)"},"&.force-mobile":{top:"145px",height:"calc(100% - 145px)"}}),HeaderContainer:St("div")(h=>({background:h.color,width:"100%",padding:"30px 30px 0px","@media (max-width: 442px)":{padding:"28px 0px 0px"},"&.force-mobile":{padding:"28px 0px 0px"}})),HeaderWrapper:St("div")({width:"389px",margin:"0 auto","@media (max-width: 442px)":{width:"280px"},"&.force-mobile":{width:"280px"}}),Title:St(ag)({minHeight:"22px",paddingTop:16,"@media (max-width: 650px)":{fontSize:"22px",lineHeight:"22px"},"&.force-mobile":{fontSize:"22px",lineHeight:"22px"}}),PdfError:St("div")({width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"})};function yp({title:h="",description:t="",titleColor:e,textColor:s,forceMobileClass:i=""}){return P.jsxs(P.Fragment,{children:[P.jsx(Tt.Title,{color:e,className:i,children:h}),P.jsx(Tt.Subtitle,{color:s,className:i,children:t})]})}const _p={width:"100%",marginTop:0},wp={width:"calc(100% - 40px)",maxWidth:388,margin:"0 auto"},Ep={padding:12,width:"100%",minHeight:72,display:"grid",gridTemplateColumns:"48px 1fr 16px",gap:12,justifyContent:"space-between",alignItems:"center",background:Pe.white},xp={width:48,height:48,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden","& .react-pdf__Document":{marginTop:"auto",marginBottom:"auto",width:48,height:48,display:"flex",justifyContent:"center",alignItems:"center","& .react-pdf__Page":{width:48,height:"100%"}}},Sp={width:"100%",height:"auto",verticalAlign:"top"},Cp={color:Pe.black,fontSize:14,fontWeight:400,lineHeight:"24px"},Tp={color:"#5A5B70",fontSize:12,fontWeight:400,lineHeight:"20px"},Pp=h=>({color:t})=>({color:t||Pe.black,transition:Gl.transition(),[`.${h.itemRoot}:hover &, .${h.itemRoot}:active &`]:{color:Pe.primary.darkBlue}}),Rp={margin:"auto",display:"flex",justifyContent:"center",alignItems:"center"},Vv=_h((h,t,e)=>({root:_p,container:wp,itemRoot:{...Ep,borderRadius:8,"&:not(:last-child)":{marginBottom:8}},itemInfo:{},itemImageWrapper:xp,itemImage:Sp,itemTitle:Cp,itemDescription:Tp,arrowIcon:Pp(e),avatarWrapper:Rp}),"Preview-Pdf-Isolated"),qv=_h((h,t,e)=>({root:{..._p,marginTop:8,"&.avatar":{marginTop:52}},container:{...wp,background:Pe.white,paddingTop:24,borderRadius:4},itemRoot:{...Ep,borderTop:"1px solid #CDD1E0","&:last-child":{borderRadius:"0 0 4px 4px"}},itemInfo:{},itemImageWrapper:xp,itemImage:Sp,itemTitle:Cp,itemDescription:Tp,arrowIcon:Pp(e),avatarWrapper:{...Rp,marginTop:-75},titlesWrapper:{padding:"0 20px"}}),"Preview-Pdf-Box"),Xv=_h({root:{width:30,height:30}}),kp={isolated:Vv,box:qv},Lp="/assets/mockup-pdf-default-img-BG1ik_BW.webp";function Yv(){const h=Xv();return P.jsx(Vp,{classes:h})}Mh.workerSrc=new URL("/assets/pdf.worker.min-DGf6LXVo.mjs",import.meta.url).toString();const tu={width:48,height:48,pageNumber:1};function Kv({src:h="",pdfSrc:t="",alt:e="",classes:s={itemImage:""},onLoad:i=()=>{},thumbnail:n=""}){const[a,o]=F.useState(!1),[l,c]=F.useState(!1),[d,u]=F.useState(h),f={width:tu.width},p=Vl(d,f),g=n?Vl(n,f):"",A=()=>{o(!0)};return F.useEffect(()=>{o(!1),u(h)},[h]),!h&&g&&!a?P.jsx("img",{className:s.itemImage,src:g,alt:"Pdf thumbnail",onLoad:i,onError:A}):(!h||a)&&!l?P.jsx(cp,{file:t,loading:P.jsx(Yv,{}),onLoadError:()=>c(!0),onLoadSuccess:()=>c(!1),children:P.jsx(vp,{...tu})}):P.jsx("img",{className:s.itemImage,src:!h||a&&l?Lp:p,alt:e,onLoad:i,onError:A})}function Qv({pdfUrl:h="#",variant:t="isolated",image:e="",imageAlt:s="Pdf Image",name:i="",description:n="",builderMode:a=!1,design:o={},arrowsColor:l="",thumbnail:c=""}){const u=(kp[t]||(()=>({})))({color:l||o.primary}),f=h.trim();return P.jsxs("a",{className:u.itemRoot,target:"_blank",rel:"noopener noreferrer","data-event":Gh.VIEW_PDF,href:f,onClick:p=>{a&&p.preventDefault()},children:[P.jsx("div",{className:u.itemImageWrapper,children:P.jsx(Kv,{src:e,alt:s,classes:u,pdfSrc:f,thumbnail:c})}),P.jsxs("div",{className:u.itemInfo,children:[i&&P.jsx("p",{className:u.itemTitle,children:i}),P.jsx("p",{className:u.itemDescription,children:n})]}),P.jsx(nu,{className:u.arrowIcon,name:"chevron_right3",size:14})]})}const Jv=_h({root:{height:100,width:100,borderRadius:"100%",border:`2px solid ${Pe.gray.normal}`,backgroundColor:Pe.white,...Gl.centerFlex},imageWrapper:{height:82,width:82,borderRadius:"100%",overflow:"hidden",...Gl.centerFlex},forceMobile:{},image:{maxHeight:"100%",maxWidth:"100%"}},"Preview-Avatar");function Zv({photoSrc:h,alt:t="",onLoad:e=()=>{},forceMobile:s=!1}){const i=Jv(),[n,a]=F.useState(!1),o=Vl(h),l=()=>{a(!0)};return P.jsx("div",{className:$h(i.root,{[i.forceMobile]:s}),children:P.jsx("div",{className:$h(i.imageWrapper,{[i.forceMobile]:s}),children:P.jsx("img",{src:n?Lp:o,alt:t,className:i.image,onLoad:e,onError:n?e:l})})})}function tA({data:h={},forceMobileClass:t="",variant:e="isolated",forceMobile:s=!1,avatar:i=!1,builderMode:n=!1,className:a="",arrowsColor:o="",titleColor:l,textColor:c}){const u=(kp[e]||(()=>({})))(),{title:f="",description:p="",pdfs:g=[]}=h||{};return P.jsx("div",{className:$h([u.root,a,{avatar:i}]),children:P.jsxs("div",{className:u.container,children:[i&&(h==null?void 0:h.photo)&&P.jsx("div",{className:u.avatarWrapper,children:P.jsx(Zv,{photoSrc:h==null?void 0:h.photo,alt:"Avatar",forceMobile:s})}),P.jsx("div",{className:u.titlesWrapper,children:P.jsx(yp,{title:f,description:p,titleColor:l,textColor:c,forceMobileClass:t})}),!!(g!=null&&g.length)&&g.map(A=>{const _=A instanceof File?A.blob:`${h.googleCloudStorageUriPrefix}/${A.file}`;return P.jsx(Qv,{variant:e,...A,builderMode:n,design:h==null?void 0:h.design,pdfUrl:_,thumbnail:A.thumbnail,arrowsColor:o},_)})]})})}function eA(h,t){if(!h&&h!==0)return{};const{design:e={}}=t||{},s=`linear-gradient(180deg, ${e.secondary} 0%, ${e.primary} 100%)`;return[{wrapperStyle:{backgroundColor:Pe.white,contrastText:!1,headerColor:e.primary},headerContainerProps:{color:e.primary},pdfListProps:{variant:"default",avatar:!1,textColorBg:e.primary},websiteProps:{},reportAbuseProps:{variant:"default"}},{wrapperStyle:{backgroundColor:e.secondary,contrastText:!0},headerContainerProps:{color:"transparent"},pdfListProps:{variant:"isolated",avatar:!1,arrowsColor:e.primary,textColorBg:e.secondary},websiteProps:{},reportAbuseProps:{variant:"white"}},{wrapperStyle:{backgroundColor:e.primary,background:s,contrastText:!0},headerContainerProps:{color:"transparent"},pdfListProps:{variant:"box",avatar:!1,className:"contained-box",arrowsColor:e.secondary,textColorBg:Pe.white},websiteProps:{},reportAbuseProps:{variant:"white"}},{wrapperStyle:{backgroundColor:e.secondary,contrastText:!0},headerContainerProps:{color:"transparent"},pdfListProps:{variant:"isolated",avatar:!0,arrowsColor:e.primary,textColorBg:e.secondary},websiteProps:{},reportAbuseProps:{variant:"white"}},{wrapperStyle:{backgroundColor:e.primary,background:s,contrastText:!0},headerContainerProps:{color:"transparent"},pdfListProps:{variant:"box",avatar:!0,className:"contained-box",arrowsColor:e.secondary,textColorBg:Pe.white},websiteProps:{},reportAbuseProps:{variant:"white"}}][h]||{}}function sA({data:h,builderMode:t,previewData:e}){var i;if(!((i=h.timeScheduling)!=null&&i.enabled))return h;if(Object.assign(h,{pdf:"",languages:{},...og}),t){if(!(e!=null&&e.range))return h={...h,...h.sections[0]},h;let n=null;const a=h.sections.find(o=>{var l,c,d,u;return(c=(l=h.timeScheduling.itemRanges)==null?void 0:l[o.id])!=null&&c.length||n||(n=o),(u=(d=h.timeScheduling.itemRanges)==null?void 0:d[o.id])==null?void 0:u.includes(e==null?void 0:e.range)});return(a||n)&&(h={...h,...a||n}),h}const s=lg(h,"sections");return s&&(h={...h,...s}),h}Mh.workerSrc=new URL("/assets/pdf.worker.min-DGf6LXVo.mjs",import.meta.url).toString();const IA=({data:h,inPreview:t=!1,onLoad:e=()=>{},builderMode:s,crmMode:i=!1,forceMobile:n=!1,previewData:a})=>{var D;const o=qp(),l=Xp(),c=Yp(sA({data:h,builderMode:s,previewData:a})),{wrapperStyle:d,pdfListProps:u,websiteProps:f,headerContainerProps:p}=eA((c==null?void 0:c.pageTemplateId)||0,c),g=c.pdf?[`${c.googleCloudStorageUriPrefix}/${c.pdf}`]:c.pdfs.map(O=>O instanceof File?O.blob:`${c.googleCloudStorageUriPrefix}/${O.file}`),A=g.map(O=>O!=null&&O.thumbnail?Vl(O.thumbnail):""),[_,y]=F.useState(0),w=g[_]||"",E=A[_]||"",S=Kp("xs")?Gv:$v,C=Qp("(max-width: 442px)"),T=s&&g.length<2&&c.directPdfLink;let R={width:318,height:390,pageNumber:1};C&&(R={width:232,height:272,pageNumber:1}),T&&(R={width:320,height:389,pageNumber:1});function M(){y(_===0?g.length-1:_-1)}function B(){y((_+1)%g.length)}n||Jp(c.title||`${Zp} - PDF`),F.useEffect(()=>{var O;c.pdf||e(),c.directPdfLink&&!s&&g.length&&(window.location.href=g[0]),!s&&!g.length&&((O=c==null?void 0:c.timeScheduling)!=null&&O.enabled)&&l.replace("/qr/invalid-schedule")},[]),F.useEffect(()=>{y(0)},[g.length]);const I=(window==null?void 0:window.self)!==window.top,$=n?"force-mobile":"",{titleColor:V,textColor:W}=vl.getFontsColors({colors:c==null?void 0:c.fontsColors,bgColor:(D=c==null?void 0:c.design)==null?void 0:D.primary});if(c.directPdfLink&&!s)return!1;const X=d!=null&&d.contrastText?{color:vl.getFontColor((d==null?void 0:d.backgroundColor)||"#ffffff")}:{},Q=!(c!=null&&c.pageTemplateId);return P.jsx(ng,{children:P.jsxs(rg,{loaded:!t,fullscreen:T,withScrollbars:s||i,style:d,children:[P.jsx(tg,{}),!T&&P.jsx(Tt.HeaderContainer,{...p,className:$,style:I?{paddingTop:50}:{},children:P.jsxs(Tt.HeaderWrapper,{className:$,children:[P.jsx(Tt.HeaderText,{color:W,className:$,children:c.org}),Q&&P.jsx(yp,{title:c==null?void 0:c.title,description:c==null?void 0:c.description,textColor:W,titleColor:V,forceMobileClass:$})]})}),(c==null?void 0:c.pageTemplateId)>0&&!(c!=null&&c.directPdfLink)&&P.jsx(tA,{...u,data:c,forceMobileclass:$,builderMode:s,titleColor:V,textColor:W}),(Q||(c==null?void 0:c.directPdfLink))&&P.jsxs(Tt.ContentContiner,{children:[!T&&P.jsx(Tt.BackgroundOverlay,{color:c.design.primary}),P.jsxs(Tt.ContentWrapper,{className:(T?"fullscreen":"")+$,hasArrows:g.length>1,children:[g.length>1&&P.jsxs(P.Fragment,{children:[P.jsx(Tt.ButtonPrev,{color:c.design.secondary,onClick:M,children:P.jsx(S,{})}),P.jsx(Tt.ButtonNext,{color:c.design.secondary,onClick:B,children:P.jsx(S,{right:!0})})]}),P.jsx(Tt.BoxShadow,{className:$}),P.jsx(Tt.PdfContentWrapper,{fullscreen:T,className:$,children:E?P.jsx(Tt.Thumbnail,{src:E,alt:"Pdf thumbnail",onLoad:e}):P.jsx(P.Fragment,{children:w?P.jsx(cp,{file:w,loading:eg,onLoadSuccess:e,onLoadError:e,error:()=>P.jsx(Tt.PdfError,{children:P.jsx(sg,{size:57,sx:{fill:"red"}})}),children:P.jsx(vp,{pageNumber:1,...R})}):P.jsx(Tt.PdfEmpty,{children:P.jsx(nu,{name:"image_empty",size:160})})})}),!T&&P.jsx(Tt.ButtonWrapper,{children:P.jsx(Tt.ViewPdfButton,{href:w.trim()||"#",onClick:O=>{s&&O.preventDefault()},color:c.design.secondary,target:"_blank",rel:"noopener noreferrer",className:$,"data-event":Gh.VIEW_PDF,children:P.jsx(ig,{startIcon:P.jsx(Ap,{}),children:P.jsx(Tt.ButtonText,{children:c.button||o.formatMessage({id:"previews.pdf.button"})})})})})]},g.length)]}),P.jsx(Tt.Website,{className:$,...f,children:P.jsx("a",{href:c.web?c.web.trim():"",target:"_blank",rel:"noopener noreferrer",style:X,"data-event":Gh.CLICK_WEBSITE,children:c.web?vl.removeUriProtocol(c.web):""})})]})})};export{IA as default};