PageSourceSearch

https://lesvacances.co.kr/assets/pdf-CeFwI8GN.js

js lesvacances.co.kr collected 2026-10-03 01:25:37 UTC 309,839 bytes, 12 lines download raw bytes

1import{a9 as se}from"./index-BIjT-aNh.js";var Gt={};Gt.d=(c,t)=>{for(var e in t)Gt.o(t,e)&&!Gt.o(c,e)&&Object.defineProperty(c,e,{enumerable:!0,get:t[e]})};Gt.o=(c,t)=>Object.prototype.hasOwnProperty.call(c,t);var T=globalThis.pdfjsLib={};Gt.d(T,{AbortException:()=>Dt,AnnotationEditorLayer:()=>yt,AnnotationEditorParamsType:()=>R,AnnotationEditorType:()=>F,AnnotationEditorUIManager:()=>Tt,AnnotationLayer:()=>Vn,AnnotationMode:()=>xt,CMapCompressionType:()=>Re,ColorPicker:()=>gt,DOMSVGFactory:()=>Ue,DrawLayer:()=>Z,FeatureTest:()=>ot,GlobalWorkerOptions:()=>Vt,ImageKind:()=>he,InvalidPDFException:()=>ys,MissingPDFException:()=>Ft,OPS:()=>ft,Outliner:()=>Ne,PDFDataRangeTransport:()=>Hs,PDFDateString:()=>Ts,PDFWorker:()=>ut,PasswordResponses:()=>Qs,PermissionFlag:()=>Ks,PixelsPerInch:()=>Bt,RenderingCancelledException:()=>$e,TextLayer:()=>at,UnexpectedResponseException:()=>pe,Util:()=>S,VerbosityLevel:()=>de,XfaLayer:()=>zs,build:()=>xn,createValidAbsoluteUrl:()=>ei,fetchData:()=>_e,getDocument:()=>bn,getFilenameFromUrl:()=>di,getPdfFilenameFromUrl:()=>ui,getXfaPageViewport:()=>fi,isDataScheme:()=>je,isPdfFile:()=>We,noContextMenu:()=>ht,normalizeUnicode:()=>oi,renderTextLayer:()=>hn,setLayerDimensions:()=>Lt,shadow:()=>D,updateTextLayer:()=>ln,version:()=>Cn});const tt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),_s=[1,0,0,1,0,0],ke=[.001,0,0,.001,0,0],Xs=1e7,we=1.35,dt={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},xt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ys="pdfjs_internal_editor_",F={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},R={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},Ks={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},J={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},he={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},V={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},zt={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},de={ERRORS:0,WARNINGS:1,INFOS:5},Re={NONE:0,BINARY:1},ft={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},Qs={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let ue=de.WARNINGS;function Js(c){Number.isInteger(c)&&(ue=c)}function Zs(){return ue}function fe(c){ue>=de.INFOS&&console.log(`Info: ${c}`)}function I(c){ue>=de.WARNINGS&&console.log(`Warning: ${c}`)}function N(c){throw new Error(c)}function X(c,t){c||N(t)}function ti(c){switch(c?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function ei(c,t=null,e=null){if(!c)return null;try{if(e&&typeof c=="string"&&(e.addDefaultProtocol&&c.startsWith("www.")&&c.match(/\./g)?.length>=2&&(c=`http://${c}`),e.tryConvertEncoding))try{c=ai(c)}catch{}const s=t?new URL(c,t):new URL(c);if(ti(s))return s}catch{}return null}function D(c,t,e,s=!1){return Object.defineProperty(c,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const kt=(function(){function t(e,s){this.constructor===t&&N("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Pe extends kt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Me extends kt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class ys extends kt{constructor(t){super(t,"InvalidPDFException")}}class Ft extends kt{constructor(t){super(t,"MissingPDFException")}}class pe extends kt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class si extends kt{constructor(t){super(t,"FormatError")}}class Dt extends kt{constructor(t){super(t,"AbortException")}}function ws(c){(typeof c!="object"||c?.length===void 0)&&N("Invalid argument for bytesToString");const t=c.length,e=8192;if(t<e)return String.fromCharCode.apply(null,c);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=c.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function ge(c){typeof c!="string"&&N("Invalid argument for stringToBytes");const t=c.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=c.charCodeAt(s)&255;return e}function ii(c){return String.fromCharCode(c>>24&255,c>>16&255,c>>8&255,c&255)}function Be(c){const t=Object.create(null);for(const[e,s]of c)t[e]=s;return t}function ni(){const c=new Uint8Array(4);return c[0]=1,new Uint32Array(c.buffer,0,1)[0]===1}function ri(){try{return new Function(""),!0}catch{return!1}}class ot{static get isLittleEndian(){return D(this,"isLittleEndian",ni())}static get isEvalSupported(){return D(this,"isEvalSupported",ri())}static get isOffscreenCanvasSupported(){return D(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?D(this,"platform",{isMac:navigator.platform.includes("Mac")}):D(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return D(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Ee=Array.from(Array(256).keys(),c=>c.toString(16).padStart(2,"0"));class S{static makeHexColor(t,e,s){return`#${Ee[t]}${Ee[e]}${Ee[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),r=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[1],r[1])]}static inverseTransform(t){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],r=t[2]*e[1]+t[3]*e[3],a=(s+r)/2,o=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,l=a+o||1,h=a-o||1;return[Math.sqrt(l),Math.sqrt(h)]}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])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}static#t(t,e,s,i,n,r,a,o,l,h){if(l<=0||l>=1)return;const d=1-l,u=l*l,p=u*l,f=d*(d*(d*t+3*l*e)+3*u*s)+p*i,g=d*(d*(d*n+3*l*r)+3*u*a)+p*o;h[0]=Math.min(h[0],f),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],f),h[3]=Math.max(h[3],g)}static#e(t,e,s,i,n,r,a,o,l,h,d,u){if(Math.abs(l)<1e-12){Math.abs(h)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/h,u);return}const p=h**2-4*d*l;if(p<0)return;const f=Math.sqrt(p),g=2*l;this.#t(t,e,s,i,n,r,a,o,(-h+f)/g,u),this.#t(t,e,s,i,n,r,a,o,(-h-f)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,l){return l?(l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l),l}}function ai(c){return decodeURIComponent(escape(c))}let Se=null,ss=null;function oi(c){return Se||(Se=/([\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,ss=new Map([["ſt","ſt"]])),c.replaceAll(Se,(t,e,s)=>e?e.normalize("NFKC"):ss.get(s))}function hi(){if(typeof crypto<"u"&&typeof crypto?.randomUUID=="function")return crypto.randomUUID();const c=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto?.getRandomValues=="function")crypto.getRandomValues(c);else for(let t=0;t<32;t++)c[t]=Math.floor(Math.random()*255);return ws(c)}const Es="pdfjs_internal_id_",At={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 me{constructor(){this.constructor===me&&N("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class be{#t=!1;constructor({enableHWA:t=!1}={}){this.constructor===be&&N("Cannot initialize BaseCanvasFactory."),this.#t=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:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){N("Abstract method `_createCanvas` called.")}}class Ae{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===Ae&&N("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?Re.BINARY:Re.NONE;return this._fetchData(e,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){N("Abstract method `_fetchData` called.")}}class ve{constructor({baseUrl:t=null}){this.constructor===ve&&N("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){N("Abstract method `_fetchData` called.")}}class ze{constructor(){this.constructor===ze&&N("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){N("Abstract method `_createSVG` called.")}}const _t="http://www.w3.org/2000/svg";class Bt{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class li extends me{#t;#e;#s;#n;#o;#i=0;constructor({docId:t,ownerDocument:e=globalThis.document}={}){super(),this.#s=t,this.#n=e}get#r(){return this.#t||=new Map}get#h(){return this.#o||=new Map}get#c(){if(!this.#e){const t=this.#n.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=this.#n.createElementNS(_t,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#e=this.#n.createElementNS(_t,"defs"),t.append(s),s.append(this.#e),this.#n.body.append(t)}return this.#e}#d(t){if(t.length===1){const o=t[0],l=new Array(256);for(let d=0;d<256;d++)l[d]=o[d]/255;const h=l.join(",");return[h,h,h]}const[e,s,i]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}addFilter(t){if(!t)return"none";let e=this.#r.get(t);if(e)return e;const[s,i,n]=this.#d(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#r.get(r),e)return this.#r.set(t,e),e;const a=`g_${this.#s}_transfer_map_${this.#i++}`,o=`url(#${a})`;this.#r.set(t,o),this.#r.set(r,o);const l=this.#a(a);return this.#m(s,i,n,l),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let n=this.#h.get(i);if(n?.key===s||(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#h.set(i,n)),!t||!e))return n.url;const r=this.#A(t);t=S.makeHexColor(...r);const a=this.#A(e);
1if(e=S.makeHexColor(...a),this.#c.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return n.url;const o=new Array(256);for(let p=0;p<=255;p++){const f=p/255;o[p]=f<=.03928?f/12.92:((f+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#s}_hcm_filter`,d=n.filter=this.#a(h);this.#m(l,l,l,d),this.#l(d);const u=(p,f)=>{const g=r[p]/255,b=a[p]/255,m=new Array(f+1);for(let A=0;A<=f;A++)m[A]=g+A/f*(b-g);return m.join(",")};return this.#m(u(0,5),u(1,5),u(2,5),d),n.url=`url(#${h})`,n.url}addAlphaFilter(t){let e=this.#r.get(t);if(e)return e;const[s]=this.#d([t]),i=`alpha_${s}`;if(e=this.#r.get(i),e)return this.#r.set(t,e),e;const n=`g_${this.#s}_alpha_map_${this.#i++}`,r=`url(#${n})`;this.#r.set(t,r),this.#r.set(i,r);const a=this.#a(n);return this.#u(s,a),r}addLuminosityFilter(t){let e=this.#r.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#d([t]),i=`luminosity_${s}`):i="luminosity",e=this.#r.get(i),e)return this.#r.set(t,e),e;const n=`g_${this.#s}_luminosity_map_${this.#i++}`,r=`url(#${n})`;this.#r.set(t,r),this.#r.set(i,r);const a=this.#a(n);return this.#f(a),t&&this.#u(s,a),r}addHighlightHCMFilter(t,e,s,i,n){const r=`${e}-${s}-${i}-${n}`;let a=this.#h.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#h.set(t,a)),!e||!s))return a.url;const[o,l]=[e,s].map(this.#A.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[u,p]=[i,n].map(this.#A.bind(this));d<h&&([h,d,u,p]=[d,h,p,u]),this.#c.style.color="";const f=(m,A,_)=>{const v=new Array(256),y=(d-h)/_,w=m/255,E=(A-m)/(255*_);let x=0;for(let C=0;C<=_;C++){const O=Math.round(h+C*y),M=w+C*E;for(let j=x;j<=O;j++)v[j]=M;x=O+1}for(let C=x;C<256;C++)v[C]=v[x-1];return v.join(",")},g=`g_${this.#s}_hcm_${t}_filter`,b=a.filter=this.#a(g);return this.#l(b),this.#m(f(u[0],p[0],5),f(u[1],p[1],5),f(u[2],p[2],5),b),a.url=`url(#${g})`,a.url}destroy(t=!1){t&&this.#h.size!==0||(this.#e&&(this.#e.parentNode.parentNode.remove(),this.#e=null),this.#t&&(this.#t.clear(),this.#t=null),this.#i=0)}#f(t){const e=this.#n.createElementNS(_t,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#l(t){const e=this.#n.createElementNS(_t,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#a(t){const e=this.#n.createElementNS(_t,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#p(t,e,s){const i=this.#n.createElementNS(_t,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#m(t,e,s,i){const n=this.#n.createElementNS(_t,"feComponentTransfer");i.append(n),this.#p(n,"feFuncR",t),this.#p(n,"feFuncG",e),this.#p(n,"feFuncB",s)}#u(t,e){const s=this.#n.createElementNS(_t,"feComponentTransfer");e.append(s),this.#p(s,"feFuncA",t)}#A(t){return this.#c.style.color=t,Ge(getComputedStyle(this.#c).getPropertyValue("color"))}}class ci extends be{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 _e(c,t="text"){if(jt(c,document.baseURI)){const e=await fetch(c);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",c,!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 Ss extends Ae{_fetchData(t,e){return _e(t,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):ge(s),compressionType:e}))}}class Cs extends ve{_fetchData(t){return _e(t,"arraybuffer").then(e=>new Uint8Array(e))}}class Ue extends ze{_createSVG(t){return document.createElementNS(_t,t)}}class Xt{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let l,h,d,u;switch(s%=360,s<0&&(s+=360),s){case 180:l=-1,h=0,d=0,u=1;break;case 90:l=0,h=1,d=1,u=0;break;case 270:l=0,h=-1,d=-1,u=0;break;case 0:l=1,h=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u);let p,f,g,b;l===0?(p=Math.abs(o-t[1])*e+i,f=Math.abs(a-t[0])*e+n,g=(t[3]-t[1])*e,b=(t[2]-t[0])*e):(p=Math.abs(a-t[0])*e+i,f=Math.abs(o-t[1])*e+n,g=(t[2]-t[0])*e,b=(t[3]-t[1])*e),this.transform=[l*e,h*e,d*e,u*e,p-l*e*a-d*e*o,f-h*e*a-u*e*o],this.width=g,this.height=b}get rawDims(){const{viewBox:t}=this;return D(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 Xt({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return S.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=S.applyTransform([t[0],t[1]],this.transform),s=S.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return S.applyInverseTransform([t,e],this.transform)}}class $e extends kt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function je(c){const t=c.length;let e=0;for(;e<t&&c[e].trim()==="";)e++;return c.substring(e,e+5).toLowerCase()==="data:"}function We(c){return typeof c=="string"&&/\.pdf$/i.test(c)}function di(c){return[c]=c.split(/[#?]/,1),c.substring(c.lastIndexOf("/")+1)}function ui(c,t="document.pdf"){if(typeof c!="string")return t;if(je(c))return I('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(c);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 is{started=Object.create(null);times=[];time(t){t in this.started&&I(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||I(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
2`);return t.join("")}}function jt(c,t){try{const{protocol:e}=t?new URL(c,t):new URL(c);return e==="http:"||e==="https:"}catch{return!1}}function ht(c){c.preventDefault()}function xs(c){console.log("Deprecated API usage: "+c)}let ns;class Ts{static toDateObject(t){if(!t||typeof t!="string")return null;ns||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=ns.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 r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,l==="-"?(r+=h,a+=d):l==="+"&&(r-=h,a-=d),new Date(Date.UTC(s,i,n,r,a,o))}}function fi(c,{scale:t=1,rotation:e=0}){const{width:s,height:i}=c.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new Xt({viewBox:n,scale:t,rotation:e})}function Ge(c){if(c.startsWith("#")){const t=parseInt(c.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return c.startsWith("rgb(")?c.slice(4,-1).split(",").map(t=>parseInt(t)):c.startsWith("rgba(")?c.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(I(`Not a valid color format: "${c}"`),[0,0,0])}function pi(c){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of c.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;c.set(e,Ge(s))}t.remove()}function H(c){const{a:t,b:e,c:s,d:i,e:n,f:r}=c.getTransform();return[t,e,s,i,n,r]}function vt(c){const{a:t,b:e,c:s,d:i,e:n,f:r}=c.getTransform().invertSelf();return[t,e,s,i,n,r]}function Lt(c,t,e=!1,s=!0){if(t instanceof Xt){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=c,a=ot.isCSSRoundSupported,o=`var(--scale-factor) * ${i}px`,l=`var(--scale-factor) * ${n}px`,h=a?`round(${o}, 1px)`:`calc(${o})`,d=a?`round(${l}, 1px)`:`calc(${l})`;!e||t.rotation%180===0?(r.width=h,r.height=d):(r.width=d,r.height=h)}s&&c.setAttribute("data-main-rotation",t.rotation)}class Ve{#t=null;#e=null;#s;#n=null;constructor(t){this.#s=t}render(){const t=this.#t=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;t.addEventListener("contextmenu",ht,{signal:e}),t.addEventListener("pointerdown",Ve.#o,{signal:e});const s=this.#n=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}static#o(t){t.stopPropagation()}#i(t){this.#s._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#r(t){this.#s._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#h(t){const e=this.#s._uiManager._signal;t.addEventListener("focusin",this.#i.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#r.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ht,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden")}#c(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#s.editorType}-button`),this.#h(t),t.addEventListener("click",e=>{this.#s._uiManager.delete()},{signal:this.#s._uiManager._signal}),this.#n.append(t)}get#d(){const t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#h(t),this.#n.prepend(t,this.#d)}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#h(e),this.#n.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class gi{#t=null;#e=null;#s;constructor(t){this.#s=t}#n(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",ht,{signal:this.#s._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#i(),t}#o(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#o(e,s),{style:r}=this.#e||=this.#n();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#i(){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=this.#s._signal;t.addEventListener("contextmenu",ht,{signal:s}),t.addEventListener("click",()=>{this.#s.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}}function le(c,t,e){for(const s of e)t.addEventListener(s,c[s].bind(c))}function mi(c){return Math.round(Math.min(255,Math.max(1,255*c))).toString(16).padStart(2,"0")}class bi{#t=0;get id(){return`${Ys}${this.#t++}`}}class qe{#t=hi();#e=0;#s=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 D(this,"_isSVGFittingCanvas",n)}async#n(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await _e(e,"blob")):i=s.file=e,i.type==="image/svg+xml"){const n=qe._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((l,h)=>{a.onload=()=>
2{s.bitmap=a,s.isSvg=!0,l()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=h});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#n(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#n(t,t)}async getFromId(t){this.#s||=new Map;const e=this.#s.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=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);e&&(e.refCounter-=1,e.refCounter===0&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class Ai{#t=[];#e=!1;#s;#n=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:n};if(this.#n===-1){this.#t.length>0&&(this.#t.length=0),this.#n=0,this.#t.push(o);return}if(r&&this.#t[this.#n].type===n){a&&(o.undo=this.#t[this.#n].undo),this.#t[this.#n]=o;return}const l=this.#n+1;l===this.#s?this.#t.splice(0,1):(this.#n=l,l<this.#t.length&&this.#t.splice(l)),this.#t.push(o)}undo(){if(this.#n===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1,this.#n-=1}redo(){if(this.#n<this.#t.length-1){this.#n+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#t.length-1}destroy(){this.#t=null}}class Yt{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ot.platform;for(const[s,i,n={}]of t)for(const r of s){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(this.#t(e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||(e.stopPropagation(),e.preventDefault()))}}class Xe{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return pi(t),D(this,"_colors",t)}convert(t){const e=Ge(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return Xe._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?S.makeHexColor(...e):t}}class Tt{#t=new AbortController;#e=null;#s=new Map;#n=new Map;#o=null;#i=null;#r=null;#h=new Ai;#c=0;#d=new Set;#f=null;#l=null;#a=new Set;#p=!1;#m=null;#u=null;#A=null;#g=!1;#v=null;#y=new bi;#E=!1;#C=!1;#x=null;#P=null;#S=null;#_=F.NONE;#b=new Set;#w=null;#T=null;#k=null;#L=this.blur.bind(this);#M=this.focus.bind(this);#D=this.copy.bind(this);#I=this.cut.bind(this);#O=this.paste.bind(this);#F=this.keydown.bind(this);#W=this.keyup.bind(this);#G=this.onEditingAction.bind(this);#$=this.onPageChanging.bind(this);#z=this.onScaleChanging.bind(this);#N=this.onRotationChanging.bind(this);#Y={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#j=[0,0];#H=null;#U=null;#K=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Tt.prototype,e=r=>r.#U.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return D(this,"_keyboardManager",new Yt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#U.contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#U.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,l){this._signal=this.#t.signal,this.#U=t,this.#K=e,this.#o=s,this._eventBus=i,this._eventBus._on("editingaction",this.#G),this._eventBus._on("pagechanging",this.#$),this._eventBus._on("scalechanging",this.#z),this._eventBus._on("rotationchanging",this.#N
2),this.#nt(),this.#ht(),this.#Q(),this.#i=n.annotationStorage,this.#m=n.filterFactory,this.#T=r,this.#A=a||null,this.#p=o,this.#S=l||null,this.viewParameters={realScale:Bt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#t?.abort(),this.#t=null,this._signal=null,this._eventBus._off("editingaction",this.#G),this._eventBus._off("pagechanging",this.#$),this._eventBus._off("scalechanging",this.#z),this._eventBus._off("rotationchanging",this.#N);for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#s.clear(),this.#a.clear(),this.#e=null,this.#b.clear(),this.#h.destroy(),this.#o?.destroy(),this.#v?.hide(),this.#v=null,this.#u&&(clearTimeout(this.#u),this.#u=null),this.#H&&(clearTimeout(this.#H),this.#H=null)}async mlGuess(t){return this.#S?.guess(t)||null}get hasMLManager(){return!!this.#S}get hcmFilter(){return D(this,"hcmFilter",this.#T?this.#m.addHCMFilter(this.#T.foreground,this.#T.background):"none")}get direction(){return D(this,"direction",getComputedStyle(this.#U).direction)}get highlightColors(){return D(this,"highlightColors",this.#A?new Map(this.#A.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return D(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){this.#P=t}editAltText(t){this.#o?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#c=t-1}focusMainContainer(){this.#U.focus()}findParent(t,e){for(const s of this.#n.values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#K.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#a.add(t)}removeShouldRescale(t){this.#a.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Bt.PDF_TO_CSS_UNITS;for(const e of this.#a)e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#q({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),l=this.#q(e).closest(".textLayer"),h=this.getSelectionBoxes(l);if(h){e.empty(),this.#_===F.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:F.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const d of this.#n.values())if(d.hasTextLayer(l)){d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a});break}}}#st(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#q(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#v||=new gi(this),this.#v.show(s,i,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#i&&!this.#i.has(t.id)&&this.#i.setValue(t.id,t)}#it(){const t=document.getSelection();if(!t||t.isCollapsed){this.#w&&(this.#v?.hide(),this.#w=null,this.#R({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#w)return;if(!this.#q(t).closest(".textLayer")){this.#w&&(this.#v?.hide(),this.#w=null,this.#R({hasSelectedText:!1}));return}if(this.#v?.hide(),this.#w=e,this.#R({hasSelectedText:!0}),!(this.#_!==F.HIGHLIGHT&&this.#_!==F.NONE)&&(this.#_===F.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#g=this.isShiftKeyDown,!this.isShiftKeyDown)){const n=this._signal,r=a=>{a.type==="pointerup"&&a.button!==0||(window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),a.type==="pointerup"&&this.#X("main_toolbar"))};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}}#X(t=""){this.#_===F.HIGHLIGHT?this.highlightSelection(t):this.#p&&this.#st()}#nt(){document.addEventListener("selectionchange",this.#it.bind(this),{signal:this._signal})}#rt(){const t=this._signal;window.addEventListener("focus",this.#M,{signal:t}),window.addEventListener("blur",this.#L,{signal:t})}#at(){window.removeEventListener("focus",this.#M),window.removeEventListener("blur",this.#L)}blur(){if(this.isShiftKeyDown=!1,this.#g&&(this.#g=!1,this.#X("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#b)if(e.div.contains(t)){this.#x=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#x)return;const[t,e]=this.#x;this.#x=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Q(){const t=this._signal;window.addEventListener("keydown",this.#F,{signal:t}),window.addEventListener("keyup",this.#W,{signal:t})}#ot(){window.removeEventListener("keydown",this.#F),window.removeEventListener("keyup",this.#W)}#J(){const t=this._signal;document.addEventListener("copy",this.#D,{signal:t}),document.addEventListener("cut",this.#I,{signal:t}),document.addEventListener("paste",this.#O,{signal:t})}#Z(){document.removeEventListener("copy",this.#D),document.removeEventListener("cut",this.#I),document.removeEventListener("paste",this.#O)}#ht(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Q(),this.#J()}removeEditListeners(){this.#ot(),this.#Z()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#l)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#l)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#b){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of this.#l)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){I(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const o of s){const l=i.deserialize(o);if(!l)return;n.push(l)}const r=()=>{for(const o of n)this.#tt(o);this.#et(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){I(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#_!==F.NONE&&!this.isEditorHandlingKeyboard&&Tt._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#g&&(this.#g=!1,this.#X("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#R(t){Object.entries(t).some(([s,i])=>this.#Y[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#Y,t)}),this.#_===F.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#B([[R.HIGHLIGHT_FREE,!0]]))}#B(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#rt(),this.#J(),this.#R({isEditing:this.#_!==F.NONE,isEmpty:this.#V(),hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:this.#h.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#at(),this.#Z(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}
2registerEditorTypes(t){if(!this.#l){this.#l=t;for(const e of this.#l)this.#B(e.defaultPropertiesToUpdate)}}getId(){return this.#y.id}get currentLayer(){return this.#n.get(this.#c)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#c}addLayer(t){this.#n.set(t.pageIndex,t),this.#E?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(this.#_!==t){if(this.#_=t,t===F.NONE){this.setEditingState(!1),this.#ct();return}this.setEditingState(!0),this.#lt(),this.unselectAll();for(const i of this.#n.values())i.updateMode(t);if(!e&&s){this.addNewEditorFromKeyboard();return}if(e){for(const i of this.#s.values())if(i.annotationElementId===e){this.setSelected(i),i.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#_&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#l){switch(t){case R.CREATE:this.currentLayer.addNe
2wEditor();return;case R.HIGHLIGHT_DEFAULT_COLOR:this.#P?.updateColor(e);break;case R.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#k||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(const s of this.#b)s.updateParams(t,e);for(const s of this.#l)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const n of this.#s.values())n.editorType===t&&n.show(e);(this.#k?.get(R.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#B([[R.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#C!==t){this.#C=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}#lt(){if(!this.#E){this.#E=!0;for(const t of this.#n.values())t.enable();for(const t of this.#s.values())t.enable()}}#ct(){if(this.unselectAll(),this.#E){this.#E=!1;for(const t of this.#n.values())t.disable();for(const t of this.#s.values())t.disable()}}getEditors(t){const e=[];for(const s of this.#s.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#u&&clearTimeout(this.#u),this.#u=setTimeout(()=>{this.focusMainContainer(),this.#u=null},0)),this.#s.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#i?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tt(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#B(t.propertiesToUpdate))}get#dt(){let t=null;for(t of this.#b);return t}updateUI(t){this.#dt===t&&this.#B(t.propertiesToUpdate)}toggleSelected(t){if(this.#b.has(t)){this.#b.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#b.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){for(const e of this.#b)e!==t&&e.unselect();this.#b.clear(),this.#b.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#b.has(t)}get firstSelectedEditor(){return this.#b.values().next().value}unselect(t){t.unselect(),this.#b.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#b.size!==0}get isEnterHandled(){return this.#b.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#h.undo(),this.#R({hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#V()})}redo(){this.#h.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#h.hasSomethingToRedo(),isEmpty:this.#V()})}addCommands(t){this.#h.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#V()})}#V(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const t of this.#s.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#b],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)this.#tt(i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#et(t){for(const e of this.#b)e.unselect();this.#b.clear();for(const e of t)e.isEmpty()||(this.#b.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#b)t.commit();this.#et(this.#s.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#_!==F.NONE))&&this.hasSelection){for(const t of this.#b)t.unselect();this.#b.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#j[0]+=t,this.#j[1]+=e;const[i,n]=this.#j,r=[...this.#b],a=1e3;this.#H&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#H=null,this.#j[0]=this.#j[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#s.has(o.id)&&o.translateInPage(i,n)},undo:()=>{for(const o of r)this.#s.has(o.id)&&o.translateInPage(-i,-n)},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(const t of this.#b)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);const t=this.#f;this.#f=null;let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(i,n,r,a)=>{if(this.#s.has(i.id)){const o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(const s of this.#f.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(){return this.getActive()?.shouldGetKeyboardEvents()||this.#b.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#_}get imageManager(){return D(this,"imageManager",new qe)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,h=e.rangeCount;l<h;
2l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,h,d,u)=>({x:(h-i)/r,y:1-(l+d-s)/n,width:u/r,height:d/n});break;case"180":a=(l,h,d,u)=>({x:1-(l+d-s)/n,y:1-(h+u-i)/r,width:d/n,height:u/r});break;case"270":a=(l,h,d,u)=>({x:1-(h+u-i)/r,y:(l-s)/n,width:u/r,height:d/n});break;default:a=(l,h,d,u)=>({x:(l-s)/n,y:(h-i)/r,width:d/n,height:u/r});break}const o=[];for(let l=0,h=e.rangeCount;l<h;l++){const d=e.getRangeAt(l);if(!d.collapsed)for(const{x:u,y:p,width:f,height:g}of d.getClientRects())f===0||g===0||o.push(a(u,p,f,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#r||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#r?.delete(t)}renderAnnotationElement(t){const e=this.#r?.get(t.data.id);if(!e)return;const s=this.#i.getRawValue(e);s&&(this.#_===F.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}}class Pt{#t="";#e=!1;#s=null;#n=null;#o=null;#i=!1;#r=null;static _l10nPromise=null;constructor(t){this.#r=t}static initialize(t){Pt._l10nPromise||=t}async render(){const t=this.#s=document.createElement("button");t.className="altText";const e=await Pt._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";const s=this.#r._uiManager._signal;t.addEventListener("contextmenu",ht,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),this.#r._uiManager.editAltText(this.#r)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#i=!0,i(n))},{signal:s}),await this.#h(),t}finish(){this.#s&&(this.#s.focus({focusVisible:this.#i}),this.#i=!1)}isEmpty(){return!this.#t&&!this.#e}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e}){this.#t===t&&this.#e===e||(this.#t=t,this.#e=e,this.#h())}toggle(t=!1){this.#s&&(!t&&this.#o&&(clearTimeout(this.#o),this.#o=null),this.#s.disabled=!t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null}async#h(){const t=this.#s;if(!t)return;if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),Pt._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(i=>{t.setAttribute("aria-label",i)});let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");const i=e.id=`alt-text-tooltip-${this.#r.id}`;t.setAttribute("aria-describedby",i);const n=100,r=this.#r._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#o),this.#o=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#o=setTimeout(()=>{this.#o=null,this.#n.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:r}),t.addEventListener("mouseleave",()=>{this.#o&&(clearTimeout(this.#o),this.#o=null),this.#n?.classList.remove("show")},{signal:r})}e.innerText=this.#e?await Pt._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#t,e.parentNode||t.append(e),this.#r.getImageForAltText()?.setAttribute("aria-describedby",e.id)}}class k{#t=null;#e=null;#s=null;#n=!1;#o=!1;#i=null;#r=null;#h=this.focusin.bind(this);#c=this.focusout.bind(this);#d=null;#f="";#l=!1;#a=null;#p=!1;#m=!1;#u=!1;#A=null;#g=0;#v=0;#y=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#E=!1;#C=k._zIndex++;static _borderLineWidth=-1;static _colorManager=new Xe;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=k.prototype._resizeWithKeyboard,e=Tt.TRANSLATE_SMALL,s=Tt.TRANSLATE_BIG;return D(this,"_resizerKeyboardManager",new Yt([[["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"],k.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===k&&N("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:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return D(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new vi({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(k._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,r=>`-${r.toLowerCase()}`))])),s?.strings)for(const n of s.strings)k._l10nPromise.set(n,t.get(n));if(k._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);k._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){N("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=t,this.div?.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}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#C}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#F(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#l?this.#l=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}#x([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()}translate(t,e){this.#x(this.parentDimensions,t,e)}translateInPage(t,e){this.#a||=[this.x,this.y],this.#x(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#a||=[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:l,y:h}=this.div.getBoundingClientRect();this.parent.findNewParent(this,l,h)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:r}=this;const[a,o]=this.getBaseTranslation();n+=a,r+=o,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#a&&(this.#a[0]!==this.x||this.#a[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=k,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:r,height:a}=this;if(r*=e,a*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-r,i)),n=Math.max(0,Math.min(s-a,n));break;case 90:i=Math.max(0,Math.min(e-a,i)),n=Math.min(s,Math.max(r,n));break;case 180:i=Math.min(e,Math.max(r,i)),n=Math.min(s,Math.max(a,n));break;case 270:i=Math.min(e,Math.max(a,i)),n=Math.max(0,Math.min(s-r,n));break}this.x=i/=e,this.y=n/=s;const[o,l]=this.getBaseTranslation();i+=o,n+=l;const{style:h}=this.div;h.left=`${(100*i).toFixed(2)}%`,h.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#P(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return k.#P(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return k.#P(t,e,360-this.parentRotation)}#S(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]}}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 ot.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)}%`,this.#o||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!this.#o&&e.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!this.#o&&!n&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#_(){if(this.#i)return;this.#i=document.createElement("div"),this.#i.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");this.#i.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#b.bind(this,s),{signal:e}),i.addEventListener("contextmenu",ht,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#i)}#b(t,e){e.preventDefault();const{isMac:s}=ot.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this.#T.bind(this,t),n=this._isDraggable;this._isDraggable=!1;const r=this._uiManager._signal,a={passive:!0,capture:!0,signal:r};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,a),window.addEventListener("contextmenu",ht,{signal:r});const o=this.x,l=this.y,h=this.width,d=this.height,u=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const f=()=>{this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",f),window.removeEventListener("blur",f),window.removeEventListener("pointermove",i,a),window.removeEventListener("contextmenu",ht),this.parent.div.style.cursor=u,this.div.style.cursor=p,this.#w(o,l,h,d)};window.addEventListener("pointerup",f,{signal:r}),window.addEventListener("blur",f,{signal:r})}#w(t,e,s,i){const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:()=>{this.width=a,this.height=o,this.x=n,this.y=r;const[l,h]=this.parentDimensions;this.setDims(l*a,h*o),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[l,h]=this.parentDimensions;this.setDims(l*s,h*i),this.fixAndSetPosition()},mustExec:!0})}#T(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=k.MIN_SIZE/s,h=k.MIN_SIZE/i,d=P=>Math.round(P*1e4)/1e4,u=this.#S(this.rotation),p=(P,L)=>[u[0]*P+u[2]*L,u[1]*P+u[3]*L],f=this.#S(360-this.rotation),g=(P,L)=>[f[0]*P+f[2]*L,f[1]*P+f[3]*L];let b,m,A=!1,_=!1;switch(t){case"topLeft":A=!0,b=(P,L)=>[0,0],m=(P,L)=>[P,L];break;case"topMiddle":b=(P,L)=>[P/2,0],m=(P,L)=>
2[P/2,L];break;case"topRight":A=!0,b=(P,L)=>[P,0],m=(P,L)=>[0,L];break;case"middleRight":_=!0,b=(P,L)=>[P,L/2],m=(P,L)=>[0,L/2];break;case"bottomRight":A=!0,b=(P,L)=>[P,L],m=(P,L)=>[0,0];break;case"bottomMiddle":b=(P,L)=>[P/2,L],m=(P,L)=>[P/2,0];break;case"bottomLeft":A=!0,b=(P,L)=>[0,L],m=(P,L)=>[P,0];break;case"middleLeft":_=!0,b=(P,L)=>[0,L/2],m=(P,L)=>[P,L/2];break}const v=b(a,o),y=m(a,o);let w=p(...y);const E=d(n+w[0]),x=d(r+w[1]);let C=1,O=1,[M,j]=this.screenToPageTranslation(e.movementX,e.movementY);if([M,j]=g(M/s,j/i),A){const P=Math.hypot(a,o);C=O=Math.max(Math.min(Math.hypot(y[0]-v[0]-M,y[1]-v[1]-j)/P,1/a,1/o),l/a,h/o)}else _?C=Math.max(l,Math.min(1,Math.abs(y[0]-v[0]-M)))/a:O=Math.max(h,Math.min(1,Math.abs(y[1]-v[1]-j)))/o;const W=d(a*C),it=d(o*O);w=p(...m(W,it));const z=E-w[0],Q=x-w[1];this.width=W,this.height=it,this.x=z,this.y=Q,this.setDims(s*W,i*it),this.fixAndSetPosition()}altTextFinish(){this.#s?.finish()}async addEditToolbar(){return this.#d||this.#m?this.#d:(this.#d=new Ve(this),this.div.append(this.#d.render()),this.#s&&this.#d.addAltTextButton(await this.#s.render()),this.#d)}removeEditToolbar(){this.#d&&(this.#d.remove(),this.#d=null,this.#s?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#s||(Pt.initialize(k._l10nPromise),this.#s=new Pt(this),this.#t&&(this.#s.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}hasAltText(){return!this.#s?.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=this.#n?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",this.#h,{signal:t}),this.div.addEventListener("focusout",this.#c,{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),le(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#l=!0,this._isDraggable){this.#L(t);return}this.#k(t)}#k(t){const{isMac:e}=ot.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#L(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},this.#g=t.clientX,this.#v=t.clientY,i=a=>{const{clientX:o,clientY:l}=a,[h,d]=this.screenToPageTranslation(o-this.#g,l-this.#v);this.#g=o,this.#v=l,this._uiManager.dragSelectedEditors(h,d)},window.addEventListener("pointermove",i,s));const r=()=>{window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),this.#l=!1,this._uiManager.endDragSession()||this.#k(t)};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}moveInDOM(){this.#A&&clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#A=null,this.parent?.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,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/i,h=e/i,d=this.x*n,u=this.y*r,p=this.width*n,f=this.height*r;switch(s){case 0:return[d+l+a,r-u-h-f+o,d+l+p+a,r-u-h+o];case 90:return[d+h+a,r-u+l+o,d+h+f+a,r-u+l+p+o];case 180:return[d-l-p+a,r-u+h+o,d-l+a,r-u+h+f+o];case 270:return[d-h-f+a,r-u-l-p+o,d-h+a,r-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#u}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){const t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#h,{signal:t}),this.div?.addEventListener("focusout",this.#c,{signal:t})}rotate(t){}serialize(t=!1,e=null){N("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,i.#t=t.accessibilityData;const[n,r]=i.pageDimensions,[a,o,l,h]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=l/n,i.height=h/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",this.#h),this.div.removeEventListener("focusout",this.#c),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#A&&(clearTimeout(this.#A),this.#A=null),this.#F(),this.removeEditToolbar(),this.#y){for(const t of this.#y.values())clearTimeout(t);this.#y=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#_(),this.#i.classList.remove("hidden"),le(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#r={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#i.children;if(!this.#e){this.#e=Array.from(e);const r=this.#M.bind(this),a=this.#D.bind(this),o=this._uiManager._signal;for(const l of this.#e){const h=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#I.bind(this,h),{signal:o}),k._l10nPromise.get(`pdfjs-editor-resizer-label-${h}`).then(d=>l.setAttribute("aria-label",d))}}const s=this.#e[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#i.append(this.#i.firstChild);else if(n>i)for(let a=0;a<n-i;a++)this.#i.firstChild.before(this.#i.lastChild);let r=0;for(const a of e){const l=this.#e[r++].getAttribute("data-resizer-name");k._l10nPromise.get(`pdfjs-editor-resizer-label-${l}
2`).then(h=>a.setAttribute("aria-label",h))}}this.#O(0),this.#u=!0,this.#i.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#M(t){k._resizerKeyboardManager.exec(this,t)}#D(t){this.#u&&t.relatedTarget?.parentNode!==this.#i&&this.#F()}#I(t){this.#f=this.#u?t:""}#O(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#u&&this.#T(this.#f,{movementX:t,movementY:e})}#F(){if(this.#u=!1,this.#O(-1),this.#r){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#r;this.#w(t,e,s,i),this.#r=null}}_stopResizingWithKeyboard(){this.#F(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this.#d){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#d?.show()});return}this.#d?.show()}unselect(){this.#i?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#d?.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#o=!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){this.#y||=new Map;const{action:s}=t;let i=this.#y.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#y.delete(s),this.#y.size===0&&(this.#y=null)},k._telemetryTimeout),this.#y.set(s,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#n=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#n=!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()}}class vi extends k{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const rs=3285377520,ct=4294901760,pt=65535;class ks{constructor(t){this.h1=t?t&4294967295:rs,this.h2=t?t&4294967295:rs}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,b=t.length;g<b;g++){const m=t.charCodeAt(g);m<=255?e[s++]=m:(e[s++]=m>>>8,e[s++]=m&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i);let a=0,o=0,l=this.h1,h=this.h2;const d=3432918353,u=461845907,p=d&pt,f=u&pt;for(let g=0;g<i;g++)g&1?(a=r[g],a=a*d&ct|a*p&pt,a=a<<15|a>>>17,a=a*u&ct|a*f&pt,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(o=r[g],o=o*d&ct|o*p&pt,o=o<<15|o>>>17,o=o*u&ct|o*f&pt,h^=o,h=h<<13|h>>>19,h=h*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&ct|a*p&pt,a=a<<15|a>>>17,a=a*u&ct|a*f&pt,i&1?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&ct|t*36045&pt,e=e*4283543511&ct|((e<<16|t>>>16)*2950163797&ct)>>>16,t^=e>>>1,t=t*444984403&ct|t*60499&pt,e=e*3301882366&ct|((e<<16|t>>>16)*3120437893&ct)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Le=Object.freeze({map:null,hash:"",transfer:void 0});class Ye{#t=!1;#e=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#e.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#e.get(t)}remove(t){if(this.#e.delete(t),this.#e.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of this.#e.values())if(e instanceof k)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#e.get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#e.set(t,e);i&&this.#s(),e instanceof k&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#e.has(t)}getAll(){return this.#e.size>0?Be(this.#e):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#e.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Rs(this)}get serializable(){if(this.#e.size===0)return Le;const t=new Map,e=new ks,s=[],i=Object.create(null);let n=!1;for(const[r,a]of this.#e){const o=a instanceof k?a.serialize(!1,i):a;o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Le}get editorStats(){let t=null;const e=new Map;for(const s of this.#e.values()){if(!(s instanceof k))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);
2const r=t[n]||=new Map;for(const[a,o]of Object.entries(i)){if(a==="type")continue;let l=r.get(a);l||(l=new Map,r.set(a,l));const h=l.get(o)??0;l.set(o,h+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}}class Rs extends Ye{#t;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#t={map:n,hash:s,transfer:i}}get print(){N("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}}class _i{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));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(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(X(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),this.#t.add(s),e?.(t)}catch{I(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}N("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 I(`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(){const t=!!this._document?.fonts;return D(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(tt||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),D(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(X(!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 D(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(v,y){return v.charCodeAt(y)<<24|v.charCodeAt(y+1)<<16|v.charCodeAt(y+2)<<8|v.charCodeAt(y+3)&255}function i(v,y,w,E){const x=v.substring(0,y),C=v.substring(y+w);return x+E+C}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;function h(v,y){if(++l>30){I("Load test font never loaded."),y();return}if(o.font="30px "+v,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0){y();return}setTimeout(h.bind(null,v,y))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=i(u,976,d.length,d);const f=16,g=1482184792;let b=s(u,f);for(n=0,r=d.length-3;n<r;n+=4)b=b-g+s(d,n)|0;n<d.length&&(b=b-g+s(d+"XXX",n)|0),u=i(u,f,4,ii(b));const m=`url(data:font/opentype;base64,${btoa(u)});`,A=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(A);const _=this._document.createElement("div");_.style.visibility="hidden",_.style.width=_.style.height="10px",_.style.position="absolute",_.style.top=_.style.left="0px";for(const v of[t.loadedName,d]){const y=this._document.createElement("span");y.textContent="Hi",y.style.fontFamily=v,_.append(y)}this._document.body.append(_),h(d,()=>{_.remove(),e.complete()})}}class yi{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(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=ws(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 i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}return this._inspectFont?.(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){I(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,r){};const i=[];for(let n=0,r=s.length;n<r;)switch(s[n++]){case At.BEZIER_CURVE_TO:{const[a,o,l,h,d,u]=s.slice(n,n+6);i.push(p=>p.bezierCurveTo(a,o,l,h,d,u)),n+=6}break;case At.MOVE_TO:{const[a,o]=s.slice(n,n+2);i.push(l=>l.moveTo(a,o)),n+=2}break;case At.LINE_TO:{const[a,o]=s.slice(n,n+2);i.push(l=>l.lineTo(a,o)),n+=2}break;case At.QUADRATIC_CURVE_TO:{const[a,o,l,h]=s.slice(n,n+4);i.push(d=>d.quadraticCurveTo(a,o,l,h)),n+=4}break;case At.RESTORE:i.push(a=>
2a.restore());break;case At.SAVE:i.push(a=>a.save());break;case At.SCALE:X(i.length===2,"Scale command is only valid at the third position.");break;case At.TRANSFORM:{const[a,o,l,h,d,u]=s.slice(n,n+6);i.push(p=>p.transform(a,o,l,h,d,u)),n+=6}break;case At.TRANSLATE:{const[a,o]=s.slice(n,n+2);i.push(l=>l.translate(a,o)),n+=2}break}return this.compiledGlyphs[e]=function(r,a){i[0](r),i[1](r),r.scale(a,-a);for(let o=2,l=i.length;o<l;o++)i[o](r)}}}if(tt){var Ie=Promise.withResolvers(),Fe=null;(async()=>{const t=await se(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),e=await se(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await se(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await se(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);let n,r;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:r}))})().then(t=>{Fe=t,Ie.resolve()},t=>{I(`loadPackages: ${t}`),Fe=new Map,Ie.resolve()})}class mt{static get promise(){return Ie.promise}static get(t){return Fe?.get(t)}}const Ps=function(c){return mt.get("fs").promises.readFile(c).then(e=>new Uint8Array(e))};class wi extends me{}class Ei extends be{_createCanvas(t,e){return mt.get("canvas").createCanvas(t,e)}}class Si extends Ae{_fetchData(t,e){return Ps(t).then(s=>({cMapData:s,compressionType:e}))}}class Ci extends ve{_fetchData(t){return Ps(t)}}const st={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function De(c,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),c.clip(i)}class Kt{constructor(){this.constructor===Kt&&N("Cannot initialize BaseShadingPattern.")}getPattern(){N("Abstract method `getPattern` called.")}}class xi extends Kt{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===st.STROKE||i===st.FILL){const r=e.current.getClippedPathBoundingBox(i,H(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o,!0),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),s=S.transform(s,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),De(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else De(t,this._bbox),n=this._createGradient(t);return n}}function Ce(c,t,e,s,i,n,r,a){const o=t.coords,l=t.colors,h=c.data,d=c.width*4;let u;o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u),o[s+1]>o[i+1]&&(u=s,s=i,i=u,u=r,r=a,a=u),o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u);const p=(o[e]+t.offsetX)*t.scaleX,f=(o[e+1]+t.offsetY)*t.scaleY,g=(o[s]+t.offsetX)*t.scaleX,b=(o[s+1]+t.offsetY)*t.scaleY,m=(o[i]+t.offsetX)*t.scaleX,A=(o[i+1]+t.offsetY)*t.scaleY;if(f>=A)return;const _=l[n],v=l[n+1],y=l[n+2],w=l[r],E=l[r+1],x=l[r+2],C=l[a],O=l[a+1],M=l[a+2],j=Math.round(f),W=Math.round(A);let it,z,Q,P,L,Jt,Zt,te;for(let et=j;et<=W;et++){if(et<b){const G=et<f?0:(f-et)/(f-b);it=p-(p-g)*G,z=_-(_-w)*G,Q=v-(v-E)*G,P=y-(y-x)*G}else{let G;et>A?G=1:b===A?G=0:G=(b-et)/(b-A),it=g-(g-m)*G,z=w-(w-C)*G,Q=E-(E-O)*G,P=x-(x-M)*G}let Y;et<f?Y=0:et>A?Y=1:Y=(f-et)/(f-A),L=p-(p-m)*Y,Jt=_-(_-C)*Y,Zt=v-(v-O)*Y,te=y-(y-M)*Y;const ee=Math.round(Math.min(it,L)),Rt=Math.round(Math.max(it,L));let St=d*et+ee*4;for(let G=ee;G<=Rt;G++)Y=(it-G)/(it-L),Y<0?Y=0:Y>1&&(Y=1),h[St++]=z-(z-Jt)*Y|0,h[St++]=Q-(Q-Zt)*Y|0,h[St++]=P-(P-te)*Y|0,h[St++]=255}}function Ti(c,t,e){const s=t.coords,i=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,o=Math.floor(s.length/a)-1,l=a-1;for(n=0;n<o;n++){let h=n*a;for(let d=0;d<l;d++,h++)Ce(c,e,s[h],s[h+1],s[h+a],i[h],i[h+1],i[h+a]),Ce(c,e,s[h+a+1],s[h+1],s[h+a],i[h+a+1],i[h+1],i[h+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)Ce(c,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 ki extends Kt{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 a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),l=Math.ceil(this._bounds[2])-a,h=Math.ceil(this._bounds[3])-o,d=Math.min(Math.ceil(Math.abs(l*t[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3e3),p=l/d,f=h/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/p,scaleY:1/f},b=d+4,m=u+4,A=s.getCanvas("mesh",b,m,!1),_=A.context,v=_.createImageData(d,u);if(e){const w=v.data;for(let E=0,x=w.length;E<x;E+=4)w[E]=e[0],w[E+1]=e[1],w[E+2]=e[2],w[E+3]=255}for(const w of this._figures)Ti(v,w,g);return _.putImageData(v,2,2),{canvas:A.canvas,offsetX:a-2*p,offsetY:o-2*f,scaleX:p,scaleY:f}}getPattern(t,e,s,i){De(t,this._bbox);let n;if(i===st.SHADING)n=S.singularValueDecompose2dScale(H(t));else if(n=S.singularValueDecompose2dScale(e.baseTransform),this.matrix
2){const a=S.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,i===st.SHADING?null:this._background,e.cachedCanvases);return i!==st.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Ri extends Kt{getPattern(){return"hotpink"}}function Pi(c){switch(c[0]){case"RadialAxial":return new xi(c);case"Mesh":return new ki(c);case"Dummy":return new Ri}throw new Error(`Unknown IR type: ${c[0]}`)}const as={COLORED:1,UNCOLORED:2};class Ke{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,i=this.xstep,n=this.ystep,r=this.paintType,a=this.tilingType,o=this.color,l=this.canvasGraphicsFactory;fe("TilingType: "+a);const h=s[0],d=s[1],u=s[2],p=s[3],f=S.singularValueDecompose2dScale(this.matrix),g=S.singularValueDecompose2dScale(this.baseTransform),b=[f[0]*g[0],f[1]*g[1]],m=this.getSizeAndScale(i,this.ctx.canvas.width,b[0]),A=this.getSizeAndScale(n,this.ctx.canvas.height,b[1]),_=t.cachedCanvases.getCanvas("pattern",m.size,A.size,!0),v=_.context,y=l.createCanvasGraphics(v);y.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(y,r,o);let w=h,E=d,x=u,C=p;return h<0&&(w=0,x+=Math.abs(h)),d<0&&(E=0,C+=Math.abs(d)),v.translate(-(m.scale*w),-(A.scale*E)),y.transform(m.scale,0,0,A.scale,0,0),v.save(),this.clipBbox(y,w,E,x,C),y.baseTransform=H(y.ctx),y.executeOperatorList(e),y.endDrawing(),{canvas:_.canvas,scaleX:m.scale,scaleY:A.scale,offsetX:w,offsetY:E}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(Ke.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 r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(H(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case as.COLORED:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case as.UNCOLORED:const a=S.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new si(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==st.SHADING&&(n=S.transform(n,e.baseTransform),this.matrix&&(n=S.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function Mi({src:c,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=ot.isLittleEndian?4278190080:255,[o,l]=r?[n,a]:[a,n],h=s>>3,d=s&7,u=c.length;e=new Uint32Array(e.buffer);let p=0;for(let f=0;f<i;f++){for(const b=t+h;t<b;t++){const m=t<u?c[t]:255;e[p++]=m&128?l:o,e[p++]=m&64?l:o,e[p++]=m&32?l:o,e[p++]=m&16?l:o,e[p++]=m&8?l:o,e[p++]=m&4?l:o,e[p++]=m&2?l:o,e[p++]=m&1?l:o}if(d===0)continue;const g=t<u?c[t++]:255;for(let b=0;b<d;b++)e[p++]=g&1<<7-b?l:o}return{srcPos:t,destPos:p}}const os=16,hs=100,Li=15,ls=10,cs=1e3,rt=16;function Ii(c,t){if(c._removeMirroring)throw new Error("Context is already forwarding operations.");c.__originalSave=c.save,c.__originalRestore=c.restore,c.__originalRotate=c.rotate,c.__originalScale=c.scale,c.__originalTranslate=c.translate,c.__originalTransform=c.transform,c.__originalSetTransform=c.setTransform,c.__originalResetTransform=c.resetTransform,c.__originalClip=c.clip,c.__originalMoveTo=c.moveTo,c.__originalLineTo=c.lineTo,c.__originalBezierCurveTo=c.bezierCurveTo,c.__originalRect=c.rect,c.__originalClosePath=c.closePath,c.__originalBeginPath=c.beginPath,c._removeMirroring=()=>{c.save=c.__originalSave,c.restore=c.__originalRestore,c.rotate=c.__originalRotate,c.scale=c.__originalScale,c.translate=c.__originalTranslate,c.transform=c.__originalTransform,c.setTransform=c.__originalSetTransform,c.resetTransform=c.__originalResetTransform,c.clip=c.__originalClip,c.moveTo=c.__originalMoveTo,c.lineTo=c.__originalLineTo,c.bezierCurveTo=c.__originalBezierCurveTo,c.rect=c.__originalRect,c.closePath=c.__originalClosePath,c.beginPath=c.__originalBeginPath,delete c._removeMirroring},c.save=function(){t.save(),this.__originalSave()}
2,c.restore=function(){t.restore(),this.__originalRestore()},c.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},c.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},c.transform=function(s,i,n,r,a,o){t.transform(s,i,n,r,a,o),this.__originalTransform(s,i,n,r,a,o)},c.setTransform=function(s,i,n,r,a,o){t.setTransform(s,i,n,r,a,o),this.__originalSetTransform(s,i,n,r,a,o)},c.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},c.rotate=function(s){t.rotate(s),this.__originalRotate(s)},c.clip=function(s){t.clip(s),this.__originalClip(s)},c.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},c.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},c.bezierCurveTo=function(e,s,i,n,r,a){t.bezierCurveTo(e,s,i,n,r,a),this.__originalBezierCurveTo(e,s,i,n,r,a)},c.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},c.closePath=function(){t.closePath(),this.__originalClosePath()},c.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Fi{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 ie(c,t,e,s,i,n,r,a,o,l){const[h,d,u,p,f,g]=H(c);if(d===0&&u===0){const A=r*h+f,_=Math.round(A),v=a*p+g,y=Math.round(v),w=(r+o)*h+f,E=Math.abs(Math.round(w)-_)||1,x=(a+l)*p+g,C=Math.abs(Math.round(x)-y)||1;return c.setTransform(Math.sign(h),0,0,Math.sign(p),_,y),c.drawImage(t,e,s,i,n,0,0,E,C),c.setTransform(h,d,u,p,f,g),[E,C]}if(h===0&&p===0){const A=a*u+f,_=Math.round(A),v=r*d+g,y=Math.round(v),w=(a+l)*u+f,E=Math.abs(Math.round(w)-_)||1,x=(r+o)*d+g,C=Math.abs(Math.round(x)-y)||1;return c.setTransform(0,Math.sign(d),Math.sign(u),0,_,y),c.drawImage(t,e,s,i,n,0,0,C,E),c.setTransform(h,d,u,p,f,g),[C,E]}c.drawImage(t,e,s,i,n,r,a,o,l);const b=Math.hypot(h,d),m=Math.hypot(u,p);return[b*o,m*l]}function Di(c){const{width:t,height:e}=c;if(t>cs||e>cs)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 r=new Uint8Array(n*(e+1)),a,o,l;const h=t+7&-8;let d=new Uint8Array(h*e),u=0;for(const m of c.data){let A=128;for(;A>0;)d[u++]=m&A?0:255,A>>=1}let p=0;for(u=0,d[u]!==0&&(r[0]=1,++p),o=1;o<t;o++)d[u]!==d[u+1]&&(r[o]=d[u]?2:1,++p),u++;for(d[u]!==0&&(r[o]=2,++p),a=1;a<e;a++){u=a*h,l=a*n,d[u-h]!==d[u]&&(r[l]=d[u]?1:8,++p);let m=(d[u]?4:0)+(d[u-h]?8:0);for(o=1;o<t;o++)m=(m>>2)+(d[u+1]?4:0)+(d[u-h+1]?8:0),i[m]&&(r[l+o]=i[m],++p),u++;if(d[u-h]!==d[u]&&(r[l+o]=d[u]?2:4,++p),p>s)return null}for(u=h*(e-1),l=a*n,d[u]!==0&&(r[l]=8,++p),o=1;o<t;o++)d[u]!==d[u+1]&&(r[l+o]=d[u]?4:8,++p),u++;if(d[u]!==0&&(r[l+o]=4,++p),p>s)return null;const f=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;p&&a<=e;a++){let m=a*n;const A=m+t;for(;m<A&&!r[m];)m++;if(m===A)continue;g.moveTo(m%n,a);const _=m;let v=r[m];do{const y=f[v];do m+=y;while(!r[m]);const w=r[m];w!==5&&w!==10?(v=w,r[m]=0):(v=w&51*v>>4,r[m]&=v>>2|v<<2),g.lineTo(m%n,m/n|0),r[m]||--p}while(_!==m);--a}return d=null,r=null,function(m){m.save(),m.scale(1/t,-1/e),m.translate(0,-e),m.fill(g),m.beginPath(),m.restore()}}class ds{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=_s,this.textMatrixScale=1,this.fontMatrix=ke,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=J.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]=S.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=S.applyTransform(e,t),i=S.applyTransform(e.slice(2),t),n=S.applyTransform([e[0],e[3]],t),r=S.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){S.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,r,a,o,l,h){const d=S.bezierBoundingBox(e,s,i,n,r,a,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=st.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===st.STROKE){e||N("Stroke bounding box must include transform.");const i=S.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=S.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=st.FILL,e=null){return S.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function us(c,t){if(typeof ImageData<"u"&&t instanceof ImageData){c.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%rt,n=(e-i)/rt,r=i===0?n:n+1,a=c.createImageData(s,rt);let o=0,l;const h=t.data,d=a.data;let u,p,f,g;if(t.kind===he.GRAYSCALE_1BPP){const b=h.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),A=m.length,_=s+7>>3,v=4294967295,y=ot.isLittleEndian?4278190080:255;for(u=0;
2u<r;u++){for(f=u<n?rt:i,l=0,p=0;p<f;p++){const w=b-o;let E=0;const x=w>_?s:w*8-7,C=x&-8;let O=0,M=0;for(;E<C;E+=8)M=h[o++],m[l++]=M&128?v:y,m[l++]=M&64?v:y,m[l++]=M&32?v:y,m[l++]=M&16?v:y,m[l++]=M&8?v:y,m[l++]=M&4?v:y,m[l++]=M&2?v:y,m[l++]=M&1?v:y;for(;E<x;E++)O===0&&(M=h[o++],O=128),m[l++]=M&O?v:y,O>>=1}for(;l<A;)m[l++]=0;c.putImageData(a,0,u*rt)}}else if(t.kind===he.RGBA_32BPP){for(p=0,g=s*rt*4,u=0;u<n;u++)d.set(h.subarray(o,o+g)),o+=g,c.putImageData(a,0,p),p+=rt;u<r&&(g=s*i*4,d.set(h.subarray(o,o+g)),c.putImageData(a,0,p))}else if(t.kind===he.RGB_24BPP)for(f=rt,g=s*f,u=0;u<r;u++){for(u>=n&&(f=i,g=s*f),l=0,p=g;p--;)d[l++]=h[o++],d[l++]=h[o++],d[l++]=h[o++],d[l++]=255;c.putImageData(a,0,u*rt)}else throw new Error(`bad image kind: ${t.kind}`)}function fs(c,t){if(t.bitmap){c.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%rt,n=(e-i)/rt,r=i===0?n:n+1,a=c.createImageData(s,rt);let o=0;const l=t.data,h=a.data;for(let d=0;d<r;d++){const u=d<n?rt:i;({srcPos:o}=Mi({src:l,srcPos:o,dest:h,width:s,height:u,nonBlackColor:0})),c.putImageData(a,0,d*rt)}}function Ut(c,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)c[s]!==void 0&&(t[s]=c[s]);c.setLineDash!==void 0&&(t.setLineDash(c.getLineDash()),t.lineDashOffset=c.lineDashOffset)}function ne(c){if(c.strokeStyle=c.fillStyle="#000000",c.fillRule="nonzero",c.globalAlpha=1,c.lineWidth=1,c.lineCap="butt",c.lineJoin="miter",c.miterLimit=10,c.globalCompositeOperation="source-over",c.font="10px sans-serif",c.setLineDash!==void 0&&(c.setLineDash([]),c.lineDashOffset=0),!tt){const{filter:t}=c;t!=="none"&&t!==""&&(c.filter="none")}}function ps(c,t){if(t)return!0;const e=S.singularValueDecompose2dScale(c);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Bt.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const Oi=["butt","round","square"],Ni=["miter","round","bevel"],Hi={},gs={};class Ht{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,l){this.ctx=t,this.current=new ds(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new Fi(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,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,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){const o=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...H(this.compositeCtx))}this.ctx.save(),ne(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=H(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const l=o-a>ls&&typeof s=="function",h=l?Date.now()+Li:0;let d=0;const u=this.commonObjs,p=this.objs;let f;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(f=r[a],f!==ft.dependency)this[f].apply(this,n[a]);else for(const g of n[a]){const b=g.startsWith("g_")?u:p;if(!b.has(g))return b.get(g,s),a}if(a++,a===o)return a;if(l&&++d>ls){if(Date.now()>h)return s(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;
2)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)}endDrawing(){this.#t(),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(),this.#e()}#e(){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}}}_scaleImage(t,e){const s=t.width,i=t.height;let n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=s,o=i,l="prescale1",h,d;for(;n>2&&a>1||r>2&&o>1;){let u=a,p=o;n>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/u),r>2&&o>1&&(p=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,r/=o/p),h=this.cachedCanvases.getCanvas(l,u,p),d=h.context,d.clearRect(0,0,u,p),d.drawImage(t,0,0,a,o,0,0,u,p),t=h.canvas,a=u,o=p,l=l==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:o}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=H(e);let o,l,h,d;if((t.bitmap||t.data)&&t.count>1){const x=t.bitmap||t.data.buffer;l=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(x),o||(o=new Map,this._cachedBitmapsMap.set(x,o));const C=o.get(l);if(C&&!r){const O=Math.round(Math.min(a[0],a[2])+a[4]),M=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:C,offsetX:O,offsetY:M}}h=C}h||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),fs(d.context,t));let u=S.transform(a,[1/s,0,0,-1/i,0,0]);u=S.transform(u,[1,0,0,1,0,-i]);const[p,f,g,b]=S.getAxialAlignedBoundingBox([0,0,s,i],u),m=Math.round(g-p)||1,A=Math.round(b-f)||1,_=this.cachedCanvases.getCanvas("fillCanvas",m,A),v=_.context,y=p,w=f;v.translate(-y,-w),v.transform(...u),h||(h=this._scaleImage(d.canvas,vt(v)),h=h.img,o&&r&&o.set(l,h)),v.imageSmoothingEnabled=ps(H(v),t.interpolate),ie(v,h,0,0,h.width,h.height,0,0,s,i),v.globalCompositeOperation="source-in";const E=S.transform(vt(v),[1,0,0,1,-y,-w]);return v.fillStyle=r?n.getPattern(e,this,E,st.FILL):n,v.fillRect(0,0,s,i),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,_.canvas)),{canvas:_.canvas,offsetX:Math.round(y),offsetY:Math.round(w)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Oi[t]}setLineJoin(t){this.ctx.lineJoin=Ni[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(...H(this.suspendedCtx)),Ut(this.suspendedCtx,n),Ii(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(),Ut(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(
2)}composeSMask(t,e,s,i){const n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;a===0||o===0||(this.genericComposeSMask(e.context,s,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,o,l,h,d){let u=t.canvas,p=o-h,f=l-d;if(r){if(p<0||f<0||p+s>u.width||f+i>u.height){const b=this.cachedCanvases.getCanvas("maskExtension",s,i),m=b.context;m.drawImage(u,-p,-f),r.some(A=>A!==0)&&(m.globalCompositeOperation="destination-atop",m.fillStyle=S.makeHexColor(...r),m.fillRect(0,0,s,i),m.globalCompositeOperation="source-over"),u=b.canvas,p=f=0}else if(r.some(b=>b!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const b=new Path2D;b.rect(p,f,s,i),t.clip(b),t.globalCompositeOperation="destination-atop",t.fillStyle=S.makeHexColor(...r),t.fillRect(p,f,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(u,p,f,s,i,o,l,s,i),e.restore()}save(){this.inSMaskMode?(Ut(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(),Ut(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let r=n.x,a=n.y,o,l;const h=H(i),d=h[0]===0&&h[3]===0||h[1]===0&&h[2]===0,u=d?s.slice(0):null;for(let p=0,f=0,g=t.length;p<g;p++)switch(t[p]|0){case ft.rectangle:r=e[f++],a=e[f++];const b=e[f++],m=e[f++],A=r+b,_=a+m;i.moveTo(r,a),b===0||m===0?i.lineTo(A,_):(i.lineTo(A,a),i.lineTo(A,_),i.lineTo(r,_)),d||n.updateRectMinMax(h,[r,a,A,_]),i.closePath();break;case ft.moveTo:r=e[f++],a=e[f++],i.moveTo(r,a),d||n.updatePathMinMax(h,r,a);break;case ft.lineTo:r=e[f++],a=e[f++],i.lineTo(r,a),d||n.updatePathMinMax(h,r,a);break;case ft.curveTo:o=r,l=a,r=e[f+4],a=e[f+5],i.bezierCurveTo(e[f],e[f+1],e[f+2],e[f+3],r,a),n.updateCurvePathMinMax(h,o,l,e[f],e[f+1],e[f+2],e[f+3],r,a,u),f+=6;break;case ft.curveTo2:o=r,l=a,i.bezierCurveTo(r,a,e[f],e[f+1],e[f+2],e[f+3]),n.updateCurvePathMinMax(h,o,l,r,a,e[f],e[f+1],e[f+2],e[f+3],u),r=e[f+2],a=e[f+3],f+=4;break;case ft.curveTo3:o=r,l=a,r=e[f+2],a=e[f+3],i.bezierCurveTo(e[f],e[f+1],r,a,r,a),n.updateCurvePathMinMax(h,o,l,e[f],e[f+1],r,a,r,a,u),f+=4;break;case ft.closePath:i.closePath();break}d&&n.updateScalingPathMinMax(h,u),n.setCurrentPoint(r,a)}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?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,vt(e),st.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,vt(e),st.FILL),n=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Hi}
2eoClip(){this.pendingClip=gs}beginText(){this.current.textMatrix=_s,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){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||ke,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&I("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",r=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`;let a="normal";s.black?a="900":s.bold&&(a="bold");const o=s.italic?"italic":"normal";let l=e;e<os?l=os:e>hs&&(l=hs),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const n=this.ctx,r=this.current,a=r.font,o=r.textRenderingMode,l=r.fontSize/r.fontSizeScale,h=o&J.FILL_STROKE_MASK,d=!!(o&J.ADD_TO_PATH_FLAG),u=r.patternFill&&!a.missingFile;let p;(a.disableFontFace||d||u)&&(p=a.getPathGenerator(this.commonObjs,t)),a.disableFontFace||u?(n.save(),n.translate(e,s),n.beginPath(),p(n,l),i&&n.setTransform(...i),(h===J.FILL||h===J.FILL_STROKE)&&n.fill(),(h===J.STROKE||h===J.FILL_STROKE)&&n.stroke(),n.restore()):((h===J.FILL||h===J.FILL_STROKE)&&n.fillText(t,e,s),(h===J.STROKE||h===J.FILL_STROKE)&&n.strokeText(t,e,s)),d&&(this.pendingTextPaths||=[]).push({transform:H(n),x:e,y:s,fontSize:l,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 D(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,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,d=t.length,u=s.vertical,p=u?1:-1,f=s.defaultVMetrics,g=i*e.fontMatrix[0],b=e.textRenderingMode===J.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1);let m;if(e.patternFill){n.save();const w=e.fillColor.getPattern(n,this,vt(n),st.FILL);m=H(n),n.restore(),n.fillStyle=w}let A=e.lineWidth;const _=e.textMatrixScale;if(_===0||A===0){const w=e.textRenderingMode&J.FILL_STROKE_MASK;(w===J.STROKE||w===J.FILL_STROKE)&&(A=this.getSinglePixelWidth())}else A/=_;if(r!==1&&(n.scale(r,r),A/=r),n.lineWidth=A,s.isInvalidPDFjsFont){const w=[];let E=0;for(const x of t)w.push(x.unicode),E+=x.width;n.fillText(w.join(""),0,0),e.x+=E*g*h,n.restore(),this.compose();return}let v=0,y;for(y=0;y<d;++y){const w=t[y];if(typeof w=="number"){v+=p*w*i/1e3;continue}let E=!1;const x=(w.isSpace?o:0)+a,C=w.fontChar,O=w.accent;let M,j,W=w.width;if(u){const z=w.vmetric||f,Q=-(w.vmetric?z[1]:W*.5)*g,P=z[2]*g;W=z?-z[0]:W,M=Q/r,j=(v+P)/r}else M=v/r,j=0;if(s.remeasure&&W>0){const z=n.measureText(C).width*1e3/i*r;if(W<z&&this.isFontSubpixelAAEnabled){const Q=W/z;E=!0,n.save(),n.scale(Q,1),M/=Q}else W!==z&&(M+=(W-z)/2e3*i/r)}if(this.contentVisible&&(w.isInFont||s.missingFile)){if(b&&!O)n.fillText(C,M,j);else if(this.paintChar(C,M,j,m),O){const z=M+i*O.offset.x/r,Q=j-i*O.offset.y/r;this.paintChar(O.fontChar,z,Q,m)}}const it=u?W*g-x*l:W*g+x*l;
2v+=it,E&&n.restore()}u?e.y-=v:e.x+=v*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,o=s.charSpacing,l=s.wordSpacing,h=s.textHScale*r,d=s.fontMatrix||ke,u=t.length,p=s.textRenderingMode===J.INVISIBLE;let f,g,b,m;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(h,r),f=0;f<u;++f){if(g=t[f],typeof g=="number"){m=a*g*n/1e3,this.ctx.translate(m,0),s.x+=m*h;continue}const A=(g.isSpace?l:0)+o,_=i.charProcOperatorList[g.operatorListId];if(!_){I(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(_),this.restore()),b=S.applyTransform([g.width,0],d)[0]*n+A,e.translate(b,0),s.x+=b*h}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||H(this.ctx),n={createCanvasGraphics:r=>new Ht(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ke(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=S.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=S.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=Pi(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,vt(e),st.SHADING);const i=vt(e);if(i){const{width:n,height:r}=e.canvas,[a,o,l,h]=S.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,o,l-a,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){N("Should not call beginInlineImage")}beginImageData(){N("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=H(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(H(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;
2t.isolated||fe("TODO: Support non-isolated groups."),t.knockout&&I("Knockout groups not supported.");const s=H(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=S.getAxialAlignedBoundingBox(t.bbox,H(e));const n=[0,0,e.canvas.width,e.canvas.height];i=S.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-r,1),l=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(h,o,l),u=d.context;u.translate(-r,-a),u.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:u,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),Ut(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;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=H(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=S.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(this.#t(),ne(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=r,e[3]=a;const[o,l]=S.singularValueDecompose2dScale(H(this.ctx)),{viewportScale:h}=this,d=Math.ceil(r*this.outputScaleX*h),u=Math.ceil(a*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:p,context:f}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(o,0,0,-l,0,a*l),ne(this.ctx)}else ne(this.ctx),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.endPath()}this.current=new ds(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;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=Di(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=H(a);a.transform(e,s,i,n,0,0);const l=this._createMaskCanvas(t);a.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let h=0,d=r.length;h<d;h+=2){const u=S.transform(o,[e,s,i,n,r[h],r[h+1]]),[p,f]=S.applyTransform([0,0],u);a.drawImage(l.canvas,p,f)}a.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:r,width:a,height:o,transform:l}=n,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=h.context;d.save();const u=this.getObject(r,n);fs(d,u),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,vt(e),st.FILL):s,d.fillRect(0,0,a,o),d.restore(),e.save(),e.transform(...l),e.scale(1,-1),ie(e,h.canvas,0,0,a,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){I("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){I("Dependent image isn't ready yet");return}const r=n.width,a=n.height,o=[];for(let l=0,h=i.length;l<h;l+=2)o.push({transform:[e,0,0,s,i[l],i[l+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!tt){const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}i.scale(1/e,-1/s);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const o=this.cachedCanvases.getCanvas("inlineImage",e,s).context;us(o,t),n=this.applyTransferMapsToCanvas(o)}const r=this._scaleImage(n,vt(i));i.imageSmoothingEnabled=ps(H(i),t.interpolate),ie(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore(
2)}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,r=t.height,o=this.cachedCanvases.getCanvas("inlineImage",n,r).context;us(o,t),i=this.applyTransferMapsToCanvas(o)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),ie(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===gs?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=H(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 r,a;if(s===0&&i===0){const o=Math.abs(e),l=Math.abs(n);if(o===l)if(t===0)r=a=1/o;else{const h=o*t;r=a=h<1?1/h:1}else if(t===0)r=1/o,a=1/l;else{const h=o*t,d=l*t;r=h<1?1/h:1,a=d<1?1/d:1}}else{const o=Math.abs(e*n-s*i),l=Math.hypot(e,s),h=Math.hypot(i,n);if(t===0)r=h/o,a=l/o;else{const d=t*o;r=h>d?h/d:1,a=l>d?l/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}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 r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){const a=Math.max(i,n);e.setLineDash(r.map(o=>o/a)),e.lineDashOffset/=a}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const c in ft)Ht.prototype[c]!==void 0&&(Ht.prototype[ft[c]]=Ht.prototype[c]);class Vt{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}const re={DATA:1,ERROR:2},U={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function lt(c){switch(c instanceof Error||typeof c=="object"&&c!==null||N('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),c.name){case"AbortException":return new Dt(c.message);case"MissingPDFException":return new Ft(c.message);case"PasswordException":return new Pe(c.message,c.code);case"UnexpectedResponseException":return new pe(c.message,c.status);case"UnknownErrorException":return new Me(c.message,c.details);default:return new Me(c.message,c.toString())}}class Wt{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=i=>{const n=i.data;if(n.targetName!==this.sourceName)return;if(n.stream){this.#e(n);return}if(n.callback){const a=n.callbackId,o=this.callbackCapabilities[a];if(!o)throw new Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],n.callback===re.DATA)o.resolve(n.data);else if(n.callback===re.ERROR)o.reject(lt(n.reason));else throw new Error("Unexpected callback case");return}const r=this.actionHandler[n.action];if(!r)throw new Error(`Unknown action from worker: ${n.action}`);if(n.callbackId){const a=this.sourceName,o=n.sourceName;new Promise(function(l){l(r(n.data))}).then(function(l){s.postMessage({sourceName:a,targetName:o,callback:re.DATA,callbackId:n.callbackId,data:l})},function(l){s.postMessage({sourceName:a,targetName:o,callback:re.ERROR,callbackId:n.callbackId,reason:lt(l)})});return}if(n.streamId){this.#t(n);return}r(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)}
2sendWithPromise(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(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:l=>{const h=Promise.withResolvers();return this.streamControllers[n]={controller:l,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:l.desiredSize},i),h.promise},pull:l=>{const h=Promise.withResolvers();return this.streamControllers[n].pullCall=h,o.postMessage({sourceName:r,targetName:a,stream:U.PULL,streamId:n,desiredSize:l.desiredSize}),h.promise},cancel:l=>{X(l instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[n].cancelCall=h,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:U.CANCEL,streamId:n,reason:lt(l)}),h.promise}},s)}#t(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(l,h=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=h,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:U.ENQUEUE,streamId:e,chunk:l},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:U.CLOSE,streamId:e}),delete r.streamSinks[e])},error(l){X(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:U.ERROR,streamId:e,reason:lt(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise(function(l){l(a(t.data,o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:U.START_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:U.START_COMPLETE,streamId:e,reason:lt(l)})})}#e(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case U.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(lt(t.reason));break;case U.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(lt(t.reason));break;case U.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:U.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,new Promise(function(o){o(a.onPull?.())}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:U.PULL_COMPLETE,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:U.PULL_COMPLETE,streamId:e,reason:lt(o)})});break;case U.ENQUEUE:if(X(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case U.CLOSE:if(X(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#s(r,e);break;case U.ERROR:X(r,"error should have stream controller"),r.controller.error(lt(t.reason)),this.#s(r,e);break;case U.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(lt(t.reason)),this.#s(r,e);break;case U.CANCEL:if(!a)break;new Promise(function(o){o(a.onCancel?.(lt(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:U.CANCEL_COMPLETE,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:U.CANCEL_COMPLETE,streamId:e,reason:lt(o)})}),a.sinkCapability.reject(lt(t.reason)),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#s(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class Bi{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return Be(this.#t)}has(t){return this.#t.has(t)}}const Ct=Symbol("INTERNAL");class zi{#t=!1;#e=!1;#s=!1;#n=!0;constructor(t,{name:e,intent:s,usage:i}){this.#t=!!(t&dt.DISPLAY),this.#e=!!(t&dt.PRINT),this.name=e,this.intent=s,this.usage=i}get visible(){if(this.#s)return this.#n;if(!this.#n)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ct&&N("Internal method `_setVisible` called."),this.#s=s,this.#n=e}}class Ui{#t=null;#e=new Map;#s=null;#n=null;constructor(t,e=dt.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#n=t.order;for(const s of t.groups)this.#e.set(s.id,new zi(e,s));if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(Ct,!1);for(const s of t.on)this.#e.get(s)._setVisible(Ct,!0);for(const s of t.off)this.#e.get(s)._setVisible(Ct,!1);this.#s=this.getHash()}}#o(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 r;if(Array.isArray(n))r=this.#o(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return I(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;
2if(!t)return fe("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(I(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#o(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return I(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return I(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return I(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return I(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return I(`Unknown optional content policy ${t.policy}.`),!0}return I(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=this.#e.get(t);if(!s){I(`Optional content group not found: ${t}`);return}s._setVisible(Ct,!!e,!0),this.#t=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=this.#e.get(i);if(n)switch(s){case"ON":n._setVisible(Ct,!0);break;case"OFF":n._setVisible(Ct,!1);break;case"Toggle":n._setVisible(Ct,!n.visible);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Be(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new ks;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}}class $i{constructor(t,{disableRange:e=!1,disableStream:s=!1}){X(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const o=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,l)=>{this._onReceiveData({begin:o,chunk:l})}),t.addProgressListener((o,l)=>{this._onProgress({loaded:o,total:l})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),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)});X(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){X(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new ji(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Wi(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class ji{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=We(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;
2this._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 Wi{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 Gi(c){let t=!0,e=s("filename\\*","i").exec(c);if(e){e=e[1];let h=a(e);return h=unescape(h),h=o(h),h=l(h),n(h)}if(e=r(c),e){const h=l(e);return n(h)}if(e=s("filename","i").exec(c),e){e=e[1];let h=a(e);return h=l(h),n(h)}function s(h,d){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(h,d){if(h){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(h,{fatal:!0}),p=ge(d);d=u.decode(p),t=!1}catch{}}return d}function n(h){return t&&/[\x80-\xff]/.test(h)&&(h=i("utf-8",h),t&&(h=i("iso-8859-1",h))),h}function r(h){const d=[];let u;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=p.exec(h))!==null;){let[,g,b,m]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[b,m]}const f=[];for(let g=0;g<d.length&&g in d;++g){let[b,m]=d[g];m=a(m),b&&(m=unescape(m),g===0&&(m=o(m))),f.push(m)}return f.join("")}function a(h){if(h.startsWith('"')){const d=h.slice(1).split('\\"');for(let u=0;u<d.length;++u){const p=d[u].indexOf('"');p!==-1&&(d[u]=d[u].slice(0,p),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}h=d.join('"')}return h}function o(h){const d=h.indexOf("'");if(d===-1)return h;const u=h.slice(0,d),f=h.slice(d+1).replace(/^[^']*'/,"");return i(u,f)}function l(h){return!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h)?h:h.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,p,f){if(p==="q"||p==="Q")return f=f.replaceAll("_"," "),f=f.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,b){return String.fromCharCode(parseInt(b,16))}),i(u,f);try{f=atob(f)}catch{}return i(u,f)})}return""}function Qe({getResponseHeader:c,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(c("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||c("Accept-Ranges")!=="bytes"||(c("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Je(c){const t=c("Content-Disposition");if(t){let e=Gi(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(We(e))return e}return null}function ye(c,t){return c===404||c===0&&t.startsWith("file:")?new Ft('Missing PDF "'+t+'".'):new pe(`Unexpected server response (${c}) while retrieving PDF "${t}".`,c)}function Ms(c){return c===200||c===206}function Ls(c,t,e){return{method:"GET",headers:c,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Is(c){const t=new Headers;for(const e in c){const s=c[e];
2s!==void 0&&t.append(e,s)}return t}function Fs(c){return c instanceof Uint8Array?c.buffer:c instanceof ArrayBuffer?c:(I(`getArrayBuffer - unexpected data format: ${c}`),new Uint8Array(c).buffer)}class ms{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(){return this._fullRequestReader?._loaded??0}getFullReader(){return X(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Vi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new qi(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Vi{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=Is(this._stream.httpHeaders);const s=e.url;fetch(s,Ls(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!Ms(i.status))throw ye(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=o=>i.headers.get(o),{allowRangeRequests:r,suggestedLength:a}=Qe({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=Je(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Dt("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Fs(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class qi{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=Is(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,Ls(this._headers,this._withCredentials,this._abortController)).then(r=>{if(!Ms(r.status))throw ye(r.status,n);this._readCapability.resolve(),this._reader=r.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Fs(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const xe=200,Te=206;function Xi(c){const t=c.response;return typeof t!="string"?t:ge(t).buffer}class Yi{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 r=this.httpHeaders[n];r!==void 0&&e.setRequestHeader(n,r)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=Te):i.expectedStatus=xe,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){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError?.(i.status);return}const n=i.status||xe;if(!(n===xe&&s.expectedStatus===Te)&&n!==s.expectedStatus){s.onError?.(i.status);return}const a=Xi(i);if(n===Te){const o=i.getResponseHeader("Content-Range"),l=/bytes (\d+)-(\d+)\/(\d+)/.exec(o);s.onDone({begin:parseInt(l[1],10),chunk:a})}else a?s.onDone({begin:0,chunk:a}):s.onError?.(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}
2abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Ki{constructor(t){this._source=t,this._manager=new Yi(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 X(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Qi(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Ji(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Qi{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=r=>e.getResponseHeader(r),{allowRangeRequests:i,suggestedLength:n}=Qe({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Je(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=ye(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){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._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 Ji{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(){this.onClosed?.(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=ye(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){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
2(this._requestId),this._close()}}const Ds=/^file:\/\/\/[a-zA-Z]:\//;function Zi(c){const t=mt.get("url"),e=t.parse(c);return e.protocol==="file:"||e.host?e:/^[a-z]:[/\\]/i.test(c)?t.parse(`file:///${c}`):(e.host||(e.protocol="file:"),e)}class tn{constructor(t){this.source=t,this.url=Zi(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(){return this._fullRequestReader?._loaded??0}getFullReader(){return X(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new nn(this):new en(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new rn(this,t,e):new sn(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Os{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(){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,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Dt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Ns{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(){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,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function ce(c,t){return{protocol:c.protocol,auth:c.auth,host:c.hostname,port:c.port,path:c.path,method:"GET",headers:t}}class en extends Os{constructor(t){super(t);const e=s=>{if(s.statusCode===404){const a=new Ft(`Missing PDF "${this._url}".`);this._storedError=a,this._headersCapability.reject(a);return}this._headersCapability.resolve(),this._setReadableStream(s);const i=a=>this._readableStream.headers[a.toLowerCase()],{allowRangeRequests:n,suggestedLength:r}=Qe({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Je(i)};if(this._request=null,this._url.protocol==="http:"){const s=mt.get("http");this._request=s.request(ce(this._url,t.httpHeaders),e)}else{const s=mt.get("https");this._request=s.request(ce(this._url,t.httpHeaders),e)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class sn extends Ns{constructor(t,e,s){super(t),this._httpHeaders={};for(const n in t.httpHeaders){const r=t.httpHeaders[n];r!==void 0&&(this._httpHeaders[n]=r)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const i=n=>{if(n.statusCode===404){const r=new Ft(`Missing PDF "${this._url}".`);this._storedError=r;return}this._setReadableStream(n)};if(this._request=null,this._url.protocol==="http:"){const n=mt.get("http");this._request=n.request(ce(this._url,this._httpHeaders),i)}else{const n=mt.get("https");this._request=n.request(ce(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class nn extends Os{constructor(t){super(t);let e=decodeURIComponent(this._url.path);Ds.test(this._url.href)&&(e=e.replace(/^\//,""));const s=mt.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 Ft(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class rn extends Ns{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);Ds.test(this._url.href)&&(i=i.replace(/^\//,""));const n=mt.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const an=1e5,nt=30,on=.8;class at{#t=Promise.withResolvers();#e=null;#s=!1;#n=!!globalThis.FontInspector?.enabled;#o=null;#i=null;#r=0;#h=0;#c=null;#d=null;#f=0;#l=0;#a=Object.create(null);#p=[];#m=null;#u=[];#A=new WeakMap;#g=null;static#v=new Map;static#y=new Map;static#E=null;static#C=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#m=t;else if(typeof t=="object")this.#m=new ReadableStream({start(o){o.enqueue(t),o.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#d=e,this.#l=s.scale*(globalThis.devicePixelRatio||1),this.#f=s.rotation,this.#i={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;this.#g=[1,0,0,-1,-r,a+n],this.#h=i,this.#r=n,at.#b(),Lt(e,s),this.#t.promise.catch(()=>{}).then(()=>{at.#C.delete(this),this.#i=null,this.#a=null})}render(){const t=()=>{this.#c.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#o??=e.lang,Object.assign(this.#a,e.styles),this.#x(e.items),t()},this.#t.reject)};return this.#c=this.#m.getReader(),at.#C.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#f&&(e?.(),this.#f=i,Lt(this.#d,{rotation:i})),s!==this.#l){e?.(),this.#l=s;const n={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:at.#_(this.#o)};for(const r of this.#u)n.properties=this.#A.get(r),n.div=r,this.#S(n)}}cancel(){const t=new Dt("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#u}get textContentItemsStr(){return this.#p}#x(t){if(this.#s)return;this.#i.ctx??=at.#_(this.#o);const e=this.#u,s=this.#p;for(const i of t){if(e.length>an){I("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id!==null&&this.#e.setAttribute("id",`${i.id}`),n.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(i.str),this.#P(i)}}#P(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#u.push(e);const i=S.transform(this.#g,t.transform);let n=Math.atan2(i[1],i[0]);const r=this.#a[t.fontName];r.vertical&&(n+=Math.PI/2);const a=this.#n&&r.fontSubstitution||r.fontFamily,o=Math.hypot(i[2],i[3]),l=o*at.#w(a,this.#o);let h,d;n===0?(h=i[4],d=i[5]-l):(h=i[4]+l*Math.sin(n),d=i[5]-l*Math.cos(n));const u="calc(var(--scale-factor)*",p=e.style;this.#e===this.#d?(p.left=`${(100*h/this.#h).toFixed(2)}%`,p.top=`${(100*d/this.#r).toFixed(2)}%`):(p.left=`${u}${h.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(at.#E*o).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#n&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);g!==b&&Math.max(g,b)/Math.min(g,b)>1.5&&(f=!0)}if(f&&(s.canvasWidth=r.vertical?t.height:t.width),this.#A.set(e,s),this.#i.div=e,this.#i.properties=s,this.#S(this.#i),s.hasText&&this.#e.append(e),s.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#S(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:r}=t,{style:a}=e;let o="";if(at.#E>1&&(o=`scale(${1/at.#E})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=a,{canvasWidth:h,fontSize:d}=s;(n!==d||r!==l)&&(i.font=`${d*this.#l}px ${l}`,t.prevFontSize=d,t.prevFontFamily=l);const{width:u}=i.measureText(e.textContent);u>0&&(o=`scaleX(${h*this.#l/u}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#C.size>0)){this.#v.clear();for(const{canvas:t}of this.#y.values())t.remove();this.#y.clear()}}static#_(t=null){let e=this.#y.get(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}),this.#y.set(t,e)}return e}static#b(){if(this.#E!==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),this.#E=t.getBoundingClientRect().height,t.remove()}static#w(t,e){const s=this.#v.get(t);if(s)return s;const i=this.#_(e),n=i.font;i.canvas.width=i.canvas.height=nt,i.font=`${nt}
2px ${t}`;const r=i.measureText("");let a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);if(a){const d=a/(a+o);return this.#v.set(t,d),i.canvas.width=i.canvas.height=0,i.font=n,d}i.strokeStyle="red",i.clearRect(0,0,nt,nt),i.strokeText("g",0,0);let l=i.getImageData(0,0,nt,nt).data;o=0;for(let d=l.length-1-3;d>=0;d-=4)if(l[d]>0){o=Math.ceil(d/4/nt);break}i.clearRect(0,0,nt,nt),i.strokeText("A",0,nt),l=i.getImageData(0,0,nt,nt).data,a=0;for(let d=0,u=l.length;d<u;d+=4)if(l[d]>0){a=nt-Math.floor(d/4/nt);break}i.canvas.width=i.canvas.height=0,i.font=n;const h=a?a/(a+o):on;return this.#v.set(t,h),h}}function hn(){xs("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:c,container:t,viewport:e,...s}=arguments[0],i=Object.keys(s);i.length>0&&I("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new at({textContentSource:c,container:t,viewport:e}),{textDivs:r,textContentItemsStr:a}=n;return{promise:n.render(),textDivs:r,textContentItemsStr:a}}function ln(){xs("`updateTextLayer`, please use `TextLayer` instead.")}class qt{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(qt.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const cn=65536,dn=100,un=5e3,fn=tt?Ei:ci,pn=tt?Si:Ss,gn=tt?wi:li,mn=tt?Ci:Cs;function bn(c={}){typeof c=="string"||c instanceof URL?c={url:c}:(c instanceof ArrayBuffer||ArrayBuffer.isView(c))&&(c={data:c});const t=new Ze,{docId:e}=t,s=c.url?An(c.url):null,i=c.data?vn(c.data):null,n=c.httpHeaders||null,r=c.withCredentials===!0,a=c.password??null,o=c.range instanceof Hs?c.range:null,l=Number.isInteger(c.rangeChunkSize)&&c.rangeChunkSize>0?c.rangeChunkSize:cn;let h=c.worker instanceof ut?c.worker:null;const d=c.verbosity,u=typeof c.docBaseUrl=="string"&&!je(c.docBaseUrl)?c.docBaseUrl:null,p=typeof c.cMapUrl=="string"?c.cMapUrl:null,f=c.cMapPacked!==!1,g=c.CMapReaderFactory||pn,b=typeof c.standardFontDataUrl=="string"?c.standardFontDataUrl:null,m=c.StandardFontDataFactory||mn,A=c.stopAtErrors!==!0,_=Number.isInteger(c.maxImageSize)&&
2c.maxImageSize>-1?c.maxImageSize:-1,v=c.isEvalSupported!==!1,y=typeof c.isOffscreenCanvasSupported=="boolean"?c.isOffscreenCanvasSupported:!tt,w=Number.isInteger(c.canvasMaxAreaInBytes)?c.canvasMaxAreaInBytes:-1,E=typeof c.disableFontFace=="boolean"?c.disableFontFace:tt,x=c.fontExtraProperties===!0,C=c.enableXfa===!0,O=c.ownerDocument||globalThis.document,M=c.disableRange===!0,j=c.disableStream===!0,W=c.disableAutoFetch===!0,it=c.pdfBug===!0,z=c.enableHWA===!0,Q=o?o.length:c.length??NaN,P=typeof c.useSystemFonts=="boolean"?c.useSystemFonts:!tt&&!E,L=typeof c.useWorkerFetch=="boolean"?c.useWorkerFetch:g===Ss&&m===Cs&&p&&b&&jt(p,document.baseURI)&&jt(b,document.baseURI),Jt=c.canvasFactory||new fn({ownerDocument:O,enableHWA:z}),Zt=c.filterFactory||new gn({docId:e,ownerDocument:O}),te=null;Js(d);const et={canvasFactory:Jt,filterFactory:Zt};if(L||(et.cMapReaderFactory=new g({baseUrl:p,isCompressed:f}),et.standardFontDataFactory=new m({baseUrl:b})),!h){const Rt={verbosity:d,port:Vt.workerPort};h=Rt.port?ut.fromPort(Rt):new ut(Rt),t._worker=h}const Y={docId:e,apiVersion:"4.4.168",data:i,password:a,disableAutoFetch:W,rangeChunkSize:l,length:Q,docBaseUrl:u,enableXfa:C,evaluatorOptions:{maxImageSize:_,disableFontFace:E,ignoreErrors:A,isEvalSupported:v,isOffscreenCanvasSupported:y,canvasMaxAreaInBytes:w,fontExtraProperties:x,useSystemFonts:P,cMapUrl:L?p:null,standardFontDataUrl:L?b:null}},ee={disableFontFace:E,fontExtraProperties:x,ownerDocument:O,pdfBug:it,styleElement:te,loadingParams:{disableAutoFetch:W,enableXfa:C}};return h.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const Rt=h.messageHandler.sendWithPromise("GetDocRequest",Y,i?[i.buffer]:null);let St;if(o)St=new $i(o,{disableRange:M,disableStream:j});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");St=(bt=>tt?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&jt(bt.url)?new ms(bt):new tn(bt):jt(bt.url)?new ms(bt):new Ki(bt))({url:s,length:Q,httpHeaders:n,withCredentials:r,rangeChunkSize:l,disableRange:M,disableStream:j})}return Rt.then(G=>{if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const bt=new Wt(e,G,h.port),es=new En(bt,t,St,ee,et);t._transport=es,bt.send("Ready",null)})}).catch(t._capability.reject),t}function An(c){if(c instanceof URL)return c.href;try{return new URL(c,window.location).href}catch{if(tt&&typeof c=="string")return c}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function vn(c){if(tt&&typeof Buffer<"u"&&c instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(c instanceof Uint8Array&&c.byteLength===c.buffer.byteLength)return c;if(typeof c=="string")return ge(c);if(c instanceof ArrayBuffer||ArrayBuffer.isView(c)||typeof c=="object"&&!isNaN(c?.length))return new Uint8Array(c);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function bs(c){return typeof c=="object"&&Number.isInteger(c?.num)&&c.num>=0&&Number.isInteger(c?.gen)&&c.gen>=0}class Ze{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Ze.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class Hs{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){N("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class _n{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 D(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}
2=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()}}class yn{#t=null;#e=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new is:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Bs,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 Xt({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 D(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=xt.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(s,i,h),{renderingIntent:u,cacheKey:p}=d;this.#e=!1,this.#n(),a||=this._transport.getOptionalContentConfig(u);let f=this._intentStates.get(p);f||(f=Object.create(null),this._intentStates.set(p,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const g=!!(u&dt.PRINT);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const b=_=>{f.renderTasks.delete(m),(this._maybeCleanupAfterRender||g)&&(this.#e=!0),this.#s(!g),_?(m.capability.reject(_),this._abortOperatorList({intentState:f,reason:_ instanceof Error?_:new Error(_)})):m.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},m=new Nt({callback:b,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:f.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:l});(f.renderTasks||=new Set).add(m);const A=m.task;return Promise.all([f.displayReadyCapability.promise,a]).then(([_,v])=>{if(this.destroyed){b();return}if(this._stats?.time("Rendering"),!(v.renderingIntent&u))throw new Error("Mu
2st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");m.initializeGraphics({transparency:_,optionalContentConfig:v}),m.operatorListChanged()}).catch(b),A}getOperatorList({intent:t="display",annotationMode:e=xt.ENABLE,printAnnotationStorage:s=null}={}){function i(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))}const n=this._transport.getRenderingIntent(t,e,s,!0);let r=this._intentStates.get(n.cacheKey);r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r));let a;return r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=i,r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>qt.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){r.read().then(function({value:o,done:l}){if(l){s(a);return}a.lang??=o.lang,Object.assign(a.styles,o.styles),a.items.push(...o.items),n()},i)}const r=e.getReader(),a={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(),this.#e=!1,this.#n(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#s(!1);return t&&e&&(this._stats&&=new is),e}#s(t=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#s(!1)},un),!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(),this.#e=!1,!0}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#s(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s}){const{map:i,transfer:n}=s,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i},n).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then(({value:h,done:d})=>{if(d){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(h,o),l())},h=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const d of o.renderTasks)d.operatorListChanged();this.#s(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(h);else if(o.opListReadCapability)o.opListReadCapability.reject(h);else throw h}})};l()}_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 $e){let i=dn;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 Dt(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}}class wn{#t=new Set;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const i of this.#t)i.call(this,s)})}addEventListener(t,e){this.#t.add(e)}removeEventListener(t,e){this.#t.delete(e)}terminate(){this.#t.clear()}}const wt={isWorkerDisabled:!1,fakeWorkerId:0};
2tt&&(wt.isWorkerDisabled=!0,Vt.workerSrc||="./pdf.worker.mjs"),wt.isSameOrigin=function(c,t){let e;try{if(e=new URL(c),!e.origin||e.origin==="null")return!1}catch{return!1}const s=new URL(t,e);return e.origin===s.origin},wt.createCDNWrapper=function(c){const t=`await import("${c}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};class ut{static#t;constructor({name:t=null,port:e=null,verbosity:s=Zs()}={}){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(ut.#t?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(ut.#t||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return tt?Promise.all([mt.promise,this._readyCapability.promise]):this._readyCapability.promise}#e(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Wt("main","worker",t),this._messageHandler.on("ready",function(){}),this.#e()}_initialize(){if(wt.isWorkerDisabled||ut.#s){this._setupFakeWorker();return}let{workerSrc:t}=ut;try{wt.isSameOrigin(window.location.href,t)||(t=wt.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Wt("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,this.#e()}),s.on("ready",a=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{fe("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){wt.isWorkerDisabled||(I("Setting up fake worker."),wt.isWorkerDisabled=!0),ut._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new wn;this._port=e;const s=`fake${wt.fakeWorkerId++}`,i=new Wt(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new Wt(s,s+"_worker",e),this.#e()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),ut.#t?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#t?.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 ut(t)}static get workerSrc(){if(Vt.workerSrc)return Vt.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#s(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return D(this,"_setupFakeWorkerGlobal",(async()=>this.#s?this.#s:(await import(this.workerSrc)).WorkerMessageHandler)())}}class En{#t=new Map;#e=new Map;#s=new Map;#n=new Map;#o=null;constructor(t,e,s,i,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Bs,this.fontLoader=new _i({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()}#i(t,e=null){const s=this.#t.get(t);if(s)return s;
2const i=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,i),i}get annotationStorage(){return D(this,"annotationStorage",new Ye)}getRenderingIntent(t,e=xt.ENABLE,s=null,i=!1){let n=dt.DISPLAY,r=Le;switch(t){case"any":n=dt.ANY;break;case"display":break;case"print":n=dt.PRINT;break;default:I(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case xt.DISABLE:n+=dt.ANNOTATIONS_DISABLE;break;case xt.ENABLE:break;case xt.ENABLE_FORMS:n+=dt.ANNOTATIONS_FORMS;break;case xt.ENABLE_STORAGE:n+=dt.ANNOTATIONS_STORAGE,r=(n&dt.PRINT&&s instanceof Rs?s:this.annotationStorage).serializable;break;default:I(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=dt.OPLIST),{renderingIntent:n,cacheKey:`${n}_${r.hash}`,annotationStorageSerializable:r}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#s.clear(),this.#n.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),at.cleanup(),this._networkStream?.cancelAllRequests(new Dt("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)=>{X(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){i.close();return}X(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",s=>{const i=Promise.withResolvers(),n=this._fullReader;return n.headersReady.then(()=>{(!n.isStreamingSupported||!n.isRangeSupported)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),n.onProgress=r=>{e.onProgress?.({loaded:r.loaded,total:r.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},i.reject),i.promise}),t.on("GetRangeReader",(s,i)=>{X(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:r,done:a}){if(a){i.close();return}X(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new _n(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Pe(s.message,s.code);break;case"InvalidPDFException":i=new ys(s.message);break;case"MissingPDFException":i=new Ft(s.message);break;case"UnexpectedResponseException":i=new pe(s.message,s.status);break;case"UnknownErrorException":i=new Me(s.message,s.details);break;default:N("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(this.#o=Promise.withResolvers(),e.onPassword){const i=n=>{n instanceof Error?this.#o.reject(n):this.#o.resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){this.#o.reject(n)}}else this.#o.reject(new Pe(s.message,s.code));return this.#o.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:r,fontExtraProperties:a,pdfBug:o}=this._params;if("error"in n){const u=n.error;I(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const l=o&&globalThis.FontInspector?.enabled?(u,p)=>globalThis.FontInspector.fontAdded(u,p):null,h=new yi(n,{disableFontFace:r,inspectFont:l});this.fontLoader.bind(h).catch(()=>
2t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!a&&h.data&&(h.data=null),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:d}=n;X(d,"The imageRef must be defined.");for(const u of this.#e.values())for(const[,p]of u.objs)if(p?.ref===d)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;const a=this.#e.get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":a.objs.resolve(s,r),r?.dataLen>Xs&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",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(){this.annotationStorage.size<=0&&I("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:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.#s.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&&this.#n.set(n.refStr,t);const r=new yn(e,n,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#s.set(e,i),i}getPageIndex(t){return bs(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#i("GetFieldObjects")}hasJSActions(){return this.#i("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#i("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#i("GetOptionalContentConfig").then(e=>new Ui(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;
2const s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new Bi(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),at.cleanup()}}cachedPageNumber(t){if(!bs(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#n.get(e)??null}}const ae=Symbol("INITIAL_DATA");class Bs{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:ae}}get(t,e=null){if(e){const i=this.#e(t);return i.promise.then(()=>e(i.data)),null}const s=this.#t[t];if(!s||s.data===ae)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t[t];return!!e&&e.data!==ae}resolve(t,e=null){const s=this.#e(t);s.data=e,s.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==ae&&(yield[t,e])}}}class Sn{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class Nt{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Sn(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Nt.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Nt.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new Ht(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),Nt.#e.delete(this._canvas),this.callback(t||new $e(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}
2):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(),Nt.#e.delete(this._canvas),this.callback())))}}const Cn="4.4.168",xn="19fbc8998";function As(c){return Math.floor(Math.max(0,Math.min(1,c))*255).toString(16).padStart(2,"0")}function $t(c){return Math.max(0,Math.min(255,255*c))}class vs{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=$t(t),[t,t,t]}static G_HTML([t]){const e=As(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map($t)}static RGB_HTML(t){return`#${t.map(As).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[$t(1-Math.min(1,t+i)),$t(1-Math.min(1,s+i)),$t(1-Math.min(1,e+i))]}static CMYK_HTML(t){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,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class zs{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,l]of Object.entries(r))if(l!=null)switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(i.children.length===0){if(i.value){const d=document.createTextNode(i.value);r.append(d),a&&qt.shouldBuildText(i.name)&&l.push(d)}return{textDivs:l}}const h=[[i,-1,r]];for(;h.length>0;){const[d,u,p]=h.at(-1);if(u+1===d.children.length){h.pop();continue}const f=d.children[++h.at(-1)[1]];if(f===null)continue;const{name:g}=f;if(g==="#text"){const m=document.createTextNode(f.value);l.push(m),p.append(m);continue}const b=f?.attributes?.xmlns?document.createElementNS(f.attributes.xmlns,g):document.createElement(g);if(p.append(b),f.attributes&&this.setAttributes({html:b,element:f,storage:e,intent:n,linkService:s}),f.children?.length>0)h.push([f,-1,b]);
2else if(f.value){const m=document.createTextNode(f.value);a&&qt.shouldBuildText(g)&&l.push(m),b.append(m)}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Qt=1e3,Tn=9,It=new WeakSet;function Et(c){return{width:c[2]-c[0],height:c[3]-c[1]}}class kn{static create(t){switch(t.data.annotationType){case V.LINK:return new Us(t);case V.TEXT:return new Rn(t);case V.WIDGET:switch(t.data.fieldType){case"Tx":return new Pn(t);case"Btn":return t.data.radioButton?new $s(t):t.data.checkBox?new Ln(t):new In(t);case"Ch":return new Fn(t);case"Sig":return new Mn(t)}return new Ot(t);case V.POPUP:return new Oe(t);case V.FREETEXT:return new js(t);case V.LINE:return new On(t);case V.SQUARE:return new Nn(t);case V.CIRCLE:return new Hn(t);case V.POLYLINE:return new Ws(t);case V.CARET:return new zn(t);case V.INK:return new Gs(t);case V.POLYGON:return new Bn(t);case V.HIGHLIGHT:return new Un(t);case V.UNDERLINE:return new $n(t);case V.SQUIGGLY:return new jn(t);case V.STRIKEOUT:return new Wn(t);case V.STAMP:return new Vs(t);case V.FILEATTACHMENT:return new Gn(t);default:return new B(t)}}}class B{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get hasPopupData(){return B._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#n(e),this.#s?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#n(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#n(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t);const{width:l,height:h}=Et(t);e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,i===0?(e.width=`${100*l/n}%`,e.height=`${100*h/r}%`):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Ot||(n.tabIndex=Qt);const{style:r}=n;if(r.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 Oe){const{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}const{width:a,height:o}=Et(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,b=e.borderStyle.verticalCornerRadius;if(g>0||b>0){const A=`calc(${g}px * var(--scale-factor)) / calc(${b}px * var(--scale-factor))`;r.borderRadius=A}else if(this instanceof $s){const A=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=A}switch(e.borderStyle.style){case zt.SOLID:r.borderStyle="solid";break;case zt.DASHED:r.borderStyle="dashed";break;case zt.BEVELED:I("Unimplemented border style: beveled");break;case zt.INSET:I("Unimplemented border style: inset");break;case zt.UNDERLINE:r.borderBottomStyle="solid";break}const m=e.borderColor||null;m?(this.#e=!0,r.borderColor=S.makeHexColor(m[0]|0,m[1]|0,m[2]|0)):r.borderWidth=0}const l=S.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:h,pageHeight:d,pageX:u,pageY:p}=i.rawDims;r.left=`${100*(l[0]-u)/h}%`,r.top=`${100*(l[1]-p)/d}%`;const{rotation:f}=e;return e.hasOwnCanvas||f===0?(r.width=`${100*a/h}%`,r.height=`${100*o/d}%`):this.setRotation(f,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=Et(this.data.rect);let a,o;t%180===0?(a=100*n/s,o=100*r/i):(a=100*r/s,o=100*n/i),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=vs[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:vs[`${r}_rgb`](a)})};return D(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(()=>
2e.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))(t[i]||s[i])?.(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 r=s[i];if(r){const a={detail:{[i]:n},target:t};r(a),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(g=>Math.fround(g));if(t.length===8){const[g,b,m,A]=t.subarray(2,6);if(i===g&&n===b&&e===m&&s===A)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:b}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${g}" stroke-width="${b}">`],this.container.classList.add("hasBorder")}const o=i-e,l=n-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const u=h.createElement("defs");d.append(u);const p=h.createElement("clipPath"),f=`clippath_${this.data.id}`;p.setAttribute("id",f),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let g=2,b=t.length;g<b;g+=8){const m=t[g],A=t[g+1],_=t[g+2],v=t[g+3],y=h.createElement("rect"),w=(_-e)/o,E=(n-A)/l,x=(m-_)/o,C=(A-v)/l;y.setAttribute("x",w),y.setAttribute("y",E),y.setAttribute("width",x),y.setAttribute("height",C),p.append(y),a?.push(`<rect vector-effect="non-scaling-stroke" x="${w}" y="${E}" width="${x}" height="${C}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${f})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=this.#s=new Oe({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(){N("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:r,exportValues:a}of i){if(n===-1||r===e)continue;const o=typeof a=="string"?a:null,l=document.querySelector(`[data-element-id="${r}"]`);if(l&&!It.has(l)){I(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:l})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&It.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){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",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class Us extends B{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#s(s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkA
2nnotation"),i&&this.container.append(s),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){I('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){const h=new Set(n);for(const d of i){const u=this._fieldObjects[d]||[];for(const{id:p}of u)h.add(p)}for(const d of Object.values(this._fieldObjects))for(const u of d)h.has(u.id)===r&&a.push(u)}else for(const h of Object.values(this._fieldObjects))a.push(...h);const o=this.annotationStorage,l=[];for(const h of a){const{id:d}=h;switch(l.push(d),h.type){case"text":{const p=h.defaultValue||"";o.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{const p=h.defaultValue===h.exportValues;o.setValue(d,{value:p});break}case"combobox":case"listbox":{const p=h.defaultValue||"";o.setValue(d,{value:p});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!It.has(u)){I(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}}),!1}}}class Rn extends B{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 Ot extends B{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ot.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){for(const[n,r]of s)(r==="Action"||this.data.actions?.[r])&&((r==="Focus"||r==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,n,r,i),r==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):r==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":S.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Tn,n=t.style;let r;const a=2,o=l=>Math.round(10*l)/10;if(this.data.multiLine){const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a),h=Math.round(l/(we*i))||1,d=l/h;r=Math.min(i,o(d/we))}else{const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,o(l/we))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=S.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 Pn extends Ot{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;
2for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=i.formattedValue||this.data.textContent?.join(`
3`)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=a??n,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",a??n),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),It.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=Qt,this._setRequired(s,this.data.required),r&&(s.maxLength=r),s.addEventListener("input",h=>{t.setValue(e,{value:h.target.value}),this.setPropertyOnSiblings(s,"value",h.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",h=>{const d=this.data.defaultFieldValue??"";s.value=o.userValue=d,o.formattedValue=null});let l=h=>{const{formattedValue:d}=o;d!=null&&(h.target.value=d),h.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",d=>{if(o.focused)return;const{target:u}=d;o.userValue&&(u.value=o.userValue),o.lastCommittedValue=u.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),s.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target);const u={value(p){o.userValue=p.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),p.target.value=o.userValue},formattedValue(p){const{formattedValue:f}=p.detail;o.formattedValue=f,f!=null&&p.target!==document.activeElement&&(p.target.value=f),t.setValue(e,{formattedValue:f})},selRange(p){p.target.setSelectionRange(...p.detail.selRange)},charLimit:p=>{const{charLimit:f}=p.detail,{target:g}=p;if(f===0){g.removeAttribute("maxLength");return}g.setAttribute("maxLength",f);let b=o.userValue;!b||b.length<=f||(b=b.slice(0,f),g.value=o.userValue=b,t.setValue(e,{value:b}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:1,selStart:g.selectionStart,selEnd:g.selectionEnd}}))}};this._dispatchEventFromSandbox(u,d)}),s.addEventListener("keydown",d=>{o.commitKey=1;let u=-1;if(d.key==="Escape"?u=0:d.key==="Enter"&&!this.data.multiLine?u=2:d.key==="Tab"&&(o.commitKey=3),u===-1)return;const{value:p}=d.target;o.lastCommittedValue!==p&&(o.lastCommittedValue=p,o.userValue=p,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,willCommit:!0,commitKey:u,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});const h=l;l=null,s.addEventListener("blur",d=>{if(!o.focused||!d.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:u}=d.target;o.userValue=u,o.lastCommittedValue!==u&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:u,willCommit:!0,commitKey:o.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),h(d)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",d=>{o.lastCommittedValue=null;const{data:u,target:p}=d,{value:f,selectionStart:g,selectionEnd:b}=p;let m=g,A=b;switch(d.inputType){case"deleteWordBackward":{const _=f.substring(0,g).match(/\w*[^\w]*$/);_&&(m-=_[0].length);break}
vendor: 4,144 bytes, line 3
3case"deleteWordForward":{const _=f.substring(g).match(/^[^\w]*\w*/);_&&(A+=_[0].length);break}case"deleteContentBackward":g===b&&(m-=1);break;case"deleteContentForward":g===b&&(A+=1);break}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,change:u||"",willCommit:!1,selStart:m,selEnd:A}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(l&&s.addEventListener("blur",l),this.data.comb){const d=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.letterSpacing=`calc(${d}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Mn extends Ot{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Ln extends Ot{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 It.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=Qt,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const l of this._getElementsByName(a,s)){const h=o&&l.exportValue===e.exportValue;l.domElement&&(l.domElement.checked=h),t.setValue(l.id,{value:h})}t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class $s extends Ot{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 r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(It.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=Qt,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const l of this._getElementsByName(a,s))t.setValue(l.id,{value:!1});t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{const o={value:l=>{const h=r===l.detail.value;for(const d of this._getElementsByName(l.target.name)){const u=h&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}
3return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class In extends Us{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 Fn extends Ot{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");It.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=Qt;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",h=>{const d=this.data.defaultFieldValue;for(const u of i.options)u.selected=u.value===d});for(const h of this.data.options){const d=document.createElement("option");d.textContent=h.displayValue,d.value=h.exportValue,s.value.includes(h.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){const h=document.createElement("option");h.value=" ",h.setAttribute("hidden",!0),h.setAttribute("selected",!0),i.prepend(h),r=()=>{h.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}const a=h=>{const d=h?"value":"textContent",{options:u,multiple:p}=i;return p?Array.prototype.filter.call(u,f=>f.selected).map(f=>f[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]};let o=a(!1);const l=h=>{const d=h.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",h=>{const d={value(u){r?.();const p=u.detail.value,f=new Set(Array.isArray(p)?p:[p]);for(const g of i.options)g.selected=f.has(g.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(u){i.multiple=!0},remove(u){const p=i.options,f=u.detail.remove;p[f].selected=!1,i.remove(f),p.length>0&&Array.prototype.findIndex.call(p,b=>b.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:a(!0),items:l(u)}),o=a(!1)},clear(u){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(u){const{index:p,displayValue:f,exportValue:g}=u.detail.insert,b=i.children[p],m=document.createElement("option");m.textContent=f,m.value=g,b?b.before(m):i.append(m),t.setValue(e,{value:a(!0),items:l(u)}),o=a(!1)},items(u){const{items:p}=u.detail;for(;i.length!==0;)i.remove(0);for(const f of p){const{displayValue:g,exportValue:b}=f,m=document.createElement("option");m.textContent=g,m.value=b,i.append(m)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(u)}),o=a(!1)},indices(u){const p=new Set(u.detail.indices);for(const f of u.target.options)f.selected=p.has(f.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,h)}),i.addEventListener("input",h=>{const d=a(!0),u=a(!1);t.setValue(e,{value:d}),h.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],h=>h.target.value)):i.addEventListener("input",function(h){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Oe extends B{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:B._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Dn({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=>`${Es}${s}`).join(",")),this.container}}
3class Dn{#t=this.#P.bind(this);#e=this.#w.bind(this);#s=this.#b.bind(this);#n=this.#_.bind(this);#o=null;#i=null;#r=null;#h=null;#c=null;#d=null;#f=null;#l=!1;#a=null;#p=null;#m=null;#u=null;#A=null;#g=null;#v=!1;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:d}){this.#i=t,this.#A=i,this.#r=r,this.#u=a,this.#d=o,this.#o=e,this.#m=l,this.#f=h,this.#c=s,this.#h=Ts.toDateObject(n),this.trigger=s.flatMap(u=>u.getElementsToTriggerPopup());for(const u of this.trigger)u.addEventListener("click",this.#n),u.addEventListener("mouseenter",this.#s),u.addEventListener("mouseleave",this.#e),u.classList.add("popupTriggerArea");for(const u of s)u.container?.addEventListener("keydown",this.#t);this.#i.hidden=!0,d&&this.#_()}render(){if(this.#a)return;const t=this.#a=document.createElement("div");if(t.className="popup",this.#o){const n=t.style.outlineColor=S.makeHexColor(...this.#o);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=S.makeHexColor(...this.#o.map(a=>Math.floor(.7*(255-a)+a)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=this.#A,t.append(e),this.#h){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:this.#h.toLocaleDateString(),time:this.#h.toLocaleTimeString()})),e.append(n)}const i=this.#y;if(i)zs.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(this.#r);t.append(n)}this.#i.append(t)}get#y(){const t=this.#u,e=this.#r;return t?.str&&(!e?.str||e.str===t.str)&&this.#u.html||null}get#E(){return this.#y?.attributes?.style?.fontSize||0}get#C(){return this.#y?.attributes?.style?.color||null}#x(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#C,fontSize:this.#E?`calc(${this.#E}px * var(--scale-factor))`:""}};for(const n of t.split(`
4`))e.push({name:"span",value:n,attributes:i});return s}_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,r=i.length;n<r;++n){const a=i[n];s.append(document.createTextNode(a)),n<r-1&&s.append(document.createElement("br"))}return s}#P(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#l)&&this.#_()}updateEdited({rect:t,popupContent:e}){this.#g||={contentsObj:this.#r,richText:this.#u},t&&(this.#p=null),e&&(this.#u=this.#x(e),this.#r=null),this.#a?.remove(),this.#a=null}resetEdited(){this.#g&&({contentsObj:this.#r,richText:this.#u}=this.#g,this.#g=null,this.#a?.remove(),this.#a=null,this.#p=null)}#S(){if(this.#p!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#d;let r=!!this.#f,a=r?this.#f:this.#m;for(const f of this.#c)if(!a||S.intersect(f.data.rect,a)!==null){a=f.data.rect,r=!0;break}const o=S.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),h=r?a[2]-a[0]+5:0,d=o[0]+h,u=o[1];this.#p=[100*(d-i)/e,100*(u-n)/s];const{style:p}=this.#i;p.left=`${this.#p[0]}%`,p.top=`${this.#p[1]}%`}#_(){this.#l=!this.#l,this.#l?(this.#b(),this.#i.addEventListener("click",this.#n),this.#i.addEventListener("keydown",this.#t)):(this.#w(),this.#i.removeEventListener("click",this.#n),this.#i.removeEventListener("keydown",this.#t))}#b(){this.#a||this.render(),this.isVisible?this.#l&&this.#i.classList.add("focused"):(this.#S(),this.#i.hidden=!1,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)+1e3)}#w(){this.#i.classList.remove("focused"),!(this.#l||!this.isVisible)&&(this.#i.hidden=!0,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)-1e3)}forceHide(){this.#v=this.isVisible,this.#v&&(this.#i.hidden=!0)}maybeShow(){this.#v&&(this.#a||this.#b(),this.#v=!1,this.#i.hidden=!1)}get isVisible(){return this.#i.hidden===!1}}class js extends B{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=F.FREETEXT}
4render(){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}}class On extends B{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:s}=Et(t.rect),i=this.svgFactory.create(e,s,!0),n=this.#t=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Nn extends B{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:s}=Et(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Hn extends B{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:s}=Et(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ws extends B{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:i}}=this;if(!e)return this.container;const{width:n,height:r}=Et(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let h=0,d=e.length;h<d;h+=2){const u=e[h]-t[0],p=t[3]-e[h+1];o.push(`${u},${p}`)}o=o.join(" ");const l=this.#t=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",s.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Bn extends Ws{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class zn extends B{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Gs extends B{#t=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=F.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,inkLists:e,borderStyle:s,popupRef:i}}=this,{width:n,height:r}=Et(t),a=this.svgFactory.create(n,r,!0);for(const o of e){let l=[];for(let d=0,u=o.length;d<u;d+=2){const p=o[d]-t[0],f=t[3]-o[d+1];l.push(`${p},${f}`)}l=l.join(" ");const h=this.svgFactory.createElement(this.svgElementName);this.#t.push(h),h.setAttribute("points",l),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),!i&&this.hasPopupData&&this._createPopup(),a.append(h)}return this.container.append(a),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Un extends B{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}}
4class $n extends B{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 jn extends B{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 Wn extends B{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 Vs extends B{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Gn extends B{#t=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;const{isMac:i}=ot.platform;return t.addEventListener("keydown",n=>{n.key==="Enter"&&(i?n.metaKey:n.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class Vn{#t=null;#e=null;#s=new Map;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r}){this.div=t,this.#t=e,this.#e=s,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i}#n(t,e){const s=t.firstChild||t;s.id=`${Es}${e}`,this.div.append(t),this.#t?.moveElementInDOM(this.div,t,s,!1)}async render(t){const{annotations:e}=t,s=this.div;Lt(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 Ue,annotationStorage:t.annotationStorage||new Ye,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const r of e){if(r.noHTML)continue;const a=r.annotationType===V.POPUP;if(a){const h=i.get(r.id);if(!h)continue;n.elements=h}else{const{width:h,height:d}=Et(r.rect);if(h<=0||d<=0)continue}n.data=r;const o=kn.create(n);if(!o.isRenderable)continue;if(!a&&r.popupRef){const h=i.get(r.popupRef);h?h.push(o):i.set(r.popupRef,[o])}const l=o.render();r.hidden&&(l.style.visibility="hidden"),this.#n(l,r.id),o.annotationEditorType>0&&(this.#s.set(o.data.id,o),this._annotationEditorUIManager?.renderAnnotationElement(o))}this.#o()}update({viewport:t}){const e=this.div;this.viewport=t,Lt(e,{rotation:t.rotation}),this.#o(),e.hidden=!1}#o(){if(!this.#e)return;const t=this.div;for(const[e,s]of this.#e){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)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#s.values())}getEditableAnnotation(t){return this.#s.get(t)}}const oe=/\r\n?|\n/g;class q extends k{#t=this.editorDivBlur.bind(this);#e=this.editorDivFocus.bind(this);#s=this.editorDivInput.bind(this);#n=this.editorDivKeydown.bind(this);#o=this.editorDivPaste.bind(this);#i;#r="";#h=`${this.id}-editor`;#c;#d=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=q.prototype,e=n=>n.isEmpty(),s=Tt.TRANSLATE_SMALL,i=Tt.TRANSLATE_BIG;return D(this,"_keyboardManager",new Yt([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=F.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#i=t.color||q._defaultColor||k._defaultLineColor,this.#c=t.fontSize||q._defaultFontSize}static initialize(t,e){k.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}
4static updateDefaultParams(t,e){switch(t){case R.FREETEXT_SIZE:q._defaultFontSize=e;break;case R.FREETEXT_COLOR:q._defaultColor=e;break}}updateParams(t,e){switch(t){case R.FREETEXT_SIZE:this.#f(e);break;case R.FREETEXT_COLOR:this.#l(e);break}}static get defaultPropertiesToUpdate(){return[[R.FREETEXT_SIZE,q._defaultFontSize],[R.FREETEXT_COLOR,q._defaultColor||k._defaultLineColor]]}get propertiesToUpdate(){return[[R.FREETEXT_SIZE,this.#c],[R.FREETEXT_COLOR,this.#i]]}#f(t){const e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--scale-factor))`,this.translate(0,-(i-this.#c)*this.parentScale),this.#c=i,this.#p()},s=this.#c;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(t){const e=i=>{this.#i=this.editorDiv.style.color=i},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-q._internalPadding*t,-(q._internalPadding+this.#c)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(F.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const t=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#n,{signal:t}),this.editorDiv.addEventListener("focus",this.#e,{signal:t}),this.editorDiv.addEventListener("blur",this.#t,{signal:t}),this.editorDiv.addEventListener("input",this.#s,{signal:t}),this.editorDiv.addEventListener("paste",this.#o,{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#h),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#n),this.editorDiv.removeEventListener("focus",this.#e),this.editorDiv.removeEventListener("blur",this.#t),this.editorDiv.removeEventListener("input",this.#s),this.editorDiv.removeEventListener("paste",this.#o),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#a(){const t=[];this.editorDiv.normalize();for(const e of this.editorDiv.childNodes)t.push(q.#m(e));return t.join(`
5`)}#p(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:i,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",i.div.append(this.div),s=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#r,e=this.#r=this.#a().trimEnd();if(t===e)return;const s=i=>{if(this.#r=i,!i){this.remove();return}this.#u(),this._uiManager.rebuild(this),this.#p()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#p()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){q._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}
5render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#h),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),k._l10nPromise.get("pdfjs-free-text-default-content").then(i=>this.editorDiv?.setAttribute("default-content",i)),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#c}px * var(--scale-factor))`,s.color=this.#i,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),le(this,this.div,["dblclick","keydown"]),this.width){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this.#d;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[l,h]=this.pageDimensions,[d,u]=this.pageTranslation;let p,f;switch(this.rotation){case 0:p=t+(r[0]-d)/l,f=e+this.height-(r[1]-u)/h;break;case 90:p=t+(r[0]-d)/l,f=e-(r[1]-u)/h,[a,o]=[o,-a];break;case 180:p=t-this.width+(r[0]-d)/l,f=e-(r[1]-u)/h,[a,o]=[-a,-o];break;case 270:p=t+(r[0]-d-this.height*h)/l,f=e+(r[1]-u-this.width*l)/h,[a,o]=[-o,a];break}this.setAt(p*i,f*n,a,o)}else this.setAt(t*i,e*n,this.width*i,this.height*n);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#m(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(oe,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();const i=q.#g(e.getData("text")||"").replaceAll(oe,`
6`);if(!i)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!i.includes(`
7`)){r.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),n.collapseToStart();return}const{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){const p=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(oe,"")),p!==this.editorDiv){let f=l;for(const g of this.editorDiv.childNodes){if(g===p){f=h;continue}f.push(q.#m(g))}}l.push(a.nodeValue.slice(0,o).replaceAll(oe,""))}else if(a===this.editorDiv){let p=l,f=0;for(const g of this.editorDiv.childNodes)f++===o&&(p=h),p.push(q.#m(g))}this.#r=`${l.join(`
8`)}${i}${h.join(`
9`)}`,this.#u();const d=new Range;let u=l.reduce((p,f)=>p+f.length,0);for(const{firstChild:p}of this.editorDiv.childNodes)if(p.nodeType===Node.TEXT_NODE){const f=p.nodeValue.length;if(u<=f){d.setStart(p,u),d.setEnd(p,u);break}u-=f}n.removeAllRanges(),n.addRange(d)}#u(){if(this.editorDiv.replaceChildren(),!!this.#r)for(const t of this.#r.split(`
10`)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#A(){return this.#r.replaceAll(" "," ")}static#g(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static deserialize(t,e,s){let i=null;if(t instanceof js){const{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:l,id:h},textContent:d,textPosition:u,parent:{page:{pageNumber:p}}}=t;if(!d||d.length===0)return null;i=t={annotationType:F.FREETEXT,color:Array.from(a),fontSize:r,value:d.join(`
11`),position:u,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1}}const n=super.deserialize(t,e,s);return n.#c=t.fontSize,n.#i=S.makeHexColor(...t.color),n.#r=q.#g(t.value),n.annotationElementId=t.id||null,n.#d=i,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=q._internalPadding*this.parentScale,s=this.getRect(e,e),i=k._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#i),n={annotationType:F.FREETEXT,color:i,fontSize:this.#c,value:this.#A(),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#v(n)?null:(n.id=this.annotationElementId,n)}#v(t){const{value:e,fontSize:s,color:i,pageIndex:n}=this.#d;return this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==i[a])||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:s}=e;s.fontSize=`calc(${this.#c}px * var(--scale-factor))`,s.color=this.#i,e.replaceChildren();for(const n of this.#r.split(`
12`)){const r=document.createElement("div");r.append(n?document.createTextNode(n):document.createElement("br")),e.append(r)}const i=q._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#r}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Ne{#t;#e=[];#s=[];constructor(t,e=0,s=0,i=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const l=10**-4;for(const{x:b,y:m,width:A,height:_}of t){const v=Math.floor((b-e)/l)*l,y=Math.ceil((b+A+e)/l)*l,w=Math.floor((m-e)/l)*l,E=Math.ceil((m+_+e)/l)*l,x=[v,w,E,!0],C=[y,w,E,!1];this.#e.push(x,C),n=Math.min(n,v),r=Math.max(r,y),a=Math.min(a,w),o=Math.max(o,E)}const h=r-n+2*s,d=o-a+2*s,u=n-s,p=a-s,f=this.#e.at(i?-1:-2),g=[f[0],f[2]];for(const b of this.#e){const[m,A,_]=b;b[0]=(m-u)/h,b[1]=(A-p)/d,b[2]=(_-p)/d}this.#t={x:u,y:p,width:h,height:d,lastPoint:g}}getOutlines(){this.#e.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#e)e[3]?(t.push(...this.#h(e)),this.#i(e)):(this.#r(e),t.push(...this.#h(e)));return this.#n(t)}#n(t){const e=[],s=new Set;for(const r of t){const[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[a,o,l,h,d]=r;s.delete(r);let u=a,p=o;for(n=[a,l],i.push(n);;){let f;if(s.has(h))f=h;else if(s.has(d))f=d;else break;s.delete(f),[a,o,l,h,d]=f,u!==a&&(n.push(u,p,a,p===o?o:l),u=a),p=p===o?l:o}n.push(u,p)}return new qn(i,this.#t)}#o(t){const e=this.#s;let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1}#i([,t,e]){const s=this.#o(t);this.#s.splice(s,0,[t,e])}#r([,t,e]){const s=this.#o(t);for(let i=s;i<this.#s.length;i++){const[n,r]=this.#s[i];if(n!==t)break;
12if(n===t&&r===e){this.#s.splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,r]=this.#s[i];if(n!==t)break;if(n===t&&r===e){this.#s.splice(i,1);return}}}#h(t){const[e,s,i]=t,n=[[e,s,i]],r=this.#o(i);for(let a=0;a<r;a++){const[o,l]=this.#s[a];for(let h=0,d=n.length;h<d;h++){const[,u,p]=n[h];if(!(l<=u||p<=o)){if(u>=o){if(p>l)n[h][1]=l;else{if(d===1)return[];n.splice(h,1),h--,d--}continue}n[h][2]=o,p>l&&n.push([e,l,p])}}}return n}}class qs{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 He}}class qn extends qs{#t;#e;constructor(t,e){super(),this.#e=t,this.#t=e}toSVGPath(){const t=[];for(const e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${r}`),s=r)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const r=[],a=s-t,o=i-e;for(const l of this.#e){const h=new Array(l.length);for(let d=0;d<l.length;d+=2)h[d]=t+l[d]*a,h[d+1]=i-l[d+1]*o;r.push(h)}return r}get box(){return this.#t}}class Mt{#t;#e=[];#s;#n;#o=[];#i=new Float64Array(18);#r;#h;#c;#d;#f;#l;#a=[];static#p=8;static#m=2;static#u=Mt.#p+Mt.#m;constructor({x:t,y:e},s,i,n,r,a=0){this.#t=s,this.#l=n*i,this.#n=r,this.#i.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#d=Mt.#p*i,this.#c=Mt.#u*i,this.#f=i,this.#a.push(t,e)}get free(){return!0}isEmpty(){return isNaN(this.#i[8])}#A(){const t=this.#i.subarray(4,6),e=this.#i.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/n,(this.#h+(t[1]-e[1])/2-i)/r,(this.#r+(e[0]-t[0])/2-s)/n,(this.#h+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#r=t,this.#h=e;const[s,i,n,r]=this.#t;let[a,o,l,h]=this.#i.subarray(8,12);const d=t-l,u=e-h,p=Math.hypot(d,u);if(p<this.#c)return!1;const f=p-this.#d,g=f/p,b=g*d,m=g*u;let A=a,_=o;a=l,o=h,l+=b,h+=m,this.#a?.push(t,e);const v=-m/f,y=b/f,w=v*this.#l,E=y*this.#l;return this.#i.set(this.#i.subarray(2,8),0),this.#i.set([l+w,h+E],4),this.#i.set(this.#i.subarray(14,18),12),this.#i.set([l-w,h-E],16),isNaN(this.#i[6])?(this.#o.length===0&&(this.#i.set([a+w,o+E],2),this.#o.push(NaN,NaN,NaN,NaN,(a+w-s)/n,(o+E-i)/r),this.#i.set([a-w,o-E],14),this.#e.push(NaN,NaN,NaN,NaN,(a-w-s)/n,(o-E-i)/r)),this.#i.set([A,_,a,o,l,h],6),!this.isEmpty()):(this.#i.set([A,_,a,o,l,h],6),Math.abs(Math.atan2(_-o,A-a)-Math.atan2(m,b))<Math.PI/2?([a,o,l,h]=this.#i.subarray(2,6),this.#o.push(NaN,NaN,NaN,NaN,((a+l)/2-s)/n,((o+h)/2-i)/r),[a,o,A,_]=this.#i.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((A+a)/2-s)/n,((_+o)/2-i)/r),!0):([A,_,a,o,l,h]=this.#i.subarray(0,6),this.#o.push(((A+5*a)/6-s)/n,((_+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),[l,h,a,o,A,_]=this.#i.subarray(12,18),this.#e.push(((A+5*a)/6-s)/n,((_+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#o,e=this.#e,s=this.#i.subarray(4,6),i=this.#i.subarray(16,18),[n,r,a,o]=this.#t,[l,h,d,u]=this.#A();if(isNaN(this.#i[6])&&!this.isEmpty())return`M${(this.#i[2]-n)/a} ${(this.#i[3]-r)/o} L${(this.#i[4]-n)/a} ${(this.#i[5]-r)/o} L${l} ${h} L${d} ${u} L${(this.#i[16]-n)/a} ${(this.#i[17]-r)/o} L${(this.#i[14]-n)/a} ${(this.#i[15]-r)/o} Z`;const p=[];p.push(`M${t[4]} ${t[5]}`);for(let f=6;f<t.length;f+=6)isNaN(t[f])?p.push(`L${t[f+4]} ${t[f+5]}`):p.push(`C${t[f]} ${t[f+1]} ${t[f+2]} ${t[f+3]} ${t[f+4]} ${t[f+5]}`);p.push(`L${(s[0]-n)/a} ${(s[1]-r)/o} L${l} ${h} L${d} ${u} L${(i[0]-n)/a} ${(i[1]-r)/o}`);for(let f=e.length-6;f>=6;f-=6)isNaN(e[f])?p.push(`L${e[f+4]} ${e[f+5]}`):p.push(`C${e[f]} ${e[f+1]} ${e[f+2]} ${e[f+3]} ${e[f+4]} ${e[f+5]}`);return p.push(`L${e[4]} ${e[5]} Z`),p.join(" ")}getOutlines(){const t=this.#o,e=this.#e,s=this.#i,i=s.subarray(4,6),n=s.subarray(16,18),[r,a,o,l]=this.#t,h=new Float64Array((this.#a?.length??0)+2);for(let m=0,A=h.length-2;m<A;m+=2)h[m]=(this.#a[m]-r)/o,h[m+1]=(this.#a[m+1]-a)/l;h[h.length-2]=(this.#r-r)/o,h[h.length-1]=(this.#h-a)/l;
12const[d,u,p,f]=this.#A();if(isNaN(s[6])&&!this.isEmpty()){const m=new Float64Array(36);return m.set([NaN,NaN,NaN,NaN,(s[2]-r)/o,(s[3]-a)/l,NaN,NaN,NaN,NaN,(s[4]-r)/o,(s[5]-a)/l,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,p,f,NaN,NaN,NaN,NaN,(s[16]-r)/o,(s[17]-a)/l,NaN,NaN,NaN,NaN,(s[14]-r)/o,(s[15]-a)/l],0),new He(m,h,this.#t,this.#f,this.#s,this.#n)}const g=new Float64Array(this.#o.length+24+this.#e.length);let b=t.length;for(let m=0;m<b;m+=2){if(isNaN(t[m])){g[m]=g[m+1]=NaN;continue}g[m]=t[m],g[m+1]=t[m+1]}g.set([NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,p,f,NaN,NaN,NaN,NaN,(n[0]-r)/o,(n[1]-a)/l],b),b+=24;for(let m=e.length-6;m>=6;m-=6)for(let A=0;A<6;A+=2){if(isNaN(e[m+A])){g[b]=g[b+1]=NaN,b+=2;continue}g[b]=e[m+A],g[b+1]=e[m+A+1],b+=2}return g.set([NaN,NaN,NaN,NaN,e[4],e[5]],b),new He(g,h,this.#t,this.#f,this.#s,this.#n)}}class He extends qs{#t;#e=null;#s;#n;#o;#i;#r;constructor(t,e,s,i,n,r){super(),this.#r=t,this.#o=e,this.#t=s,this.#i=i,this.#s=n,this.#n=r,this.#d(r);const{x:a,y:o,width:l,height:h}=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/l,t[d+1]=(t[d+1]-o)/h;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/l,e[d+1]=(e[d+1]-o)/h}toSVGPath(){const t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6){if(isNaN(this.#r[e])){t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`);continue}t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){const r=s-t,a=i-e;let o,l;switch(n){case 0:o=this.#h(this.#r,t,i,r,-a),l=this.#h(this.#o,t,i,r,-a);break;case 90:o=this.#c(this.#r,t,e,r,a),l=this.#c(this.#o,t,e,r,a);break;case 180:o=this.#h(this.#r,s,e,-r,a),l=this.#h(this.#o,s,e,-r,a);break;case 270:o=this.#c(this.#r,s,i,-r,-a),l=this.#c(this.#o,s,i,-r,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#h(t,e,s,i,n){const r=new Float64Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}#c(t,e,s,i,n){const r=new Float64Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}#d(t){const e=this.#r;let s=e[4],i=e[5],n=s,r=i,a=s,o=i,l=s,h=i;const d=t?Math.max:Math.min;for(let b=6,m=e.length;b<m;b+=6){if(isNaN(e[b]))n=Math.min(n,e[b+4]),r=Math.min(r,e[b+5]),a=Math.max(a,e[b+4]),o=Math.max(o,e[b+5]),h<e[b+5]?(l=e[b+4],h=e[b+5]):h===e[b+5]&&(l=d(l,e[b+4]));else{const A=S.bezierBoundingBox(s,i,...e.slice(b,b+6));n=Math.min(n,A[0]),r=Math.min(r,A[1]),a=Math.max(a,A[2]),o=Math.max(o,A[3]),h<A[3]?(l=A[2],h=A[3]):h===A[3]&&(l=d(l,A[2]))}s=e[b+4],i=e[b+5]}const u=n-this.#s,p=r-this.#s,f=a-n+2*this.#s,g=o-r+2*this.#s;this.#e={x:u,y:p,width:f,height:g,lastPoint:[l,h]}}get box(){return this.#e}getNewOutline(t,e){const{x:s,y:i,width:n,height:r}=this.#e,[a,o,l,h]=this.#t,d=n*l,u=r*h,p=s*l+a,f=i*h+o,g=new Mt({x:this.#o[0]*d+p,y:this.#o[1]*u+f},this.#t,this.#i,t,this.#n,e??this.#s);for(let b=2;b<this.#o.length;b+=2)g.add({x:this.#o[b]*d+p,y:this.#o[b+1]*u+f});return g.getOutlines()}}class gt{#t=this.#m.bind(this);#e=this.#A.bind(this);#s=null;#n=null;#o;#i=null;#r=!1;#h=!1;#c=null;#d;#f=null;#l;static get _keyboardManager(){return D(this,"_keyboardManager",new Yt([[["Escape","mac+Escape"],gt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],gt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],gt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],gt.prototype._moveToPrevious],[["Home","mac+Home"],gt.prototype._moveToBeginning],[["End","mac+End"],gt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#h=!1,this.#l=R.HIGHLIGHT_COLOR,this.#c=t):(this.#h=!0,this.#l=R.HIGHLIGHT_DEFAULT_COLOR),this.#f=t?._uiManager||e,this.#d=this.#f._eventBus,this.#o=t?.color||this.#f?.highlightColors.values().next().value||"#FFFF98"}renderButton(){const t=this.#s=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=this.#f._signal;t.addEventListener("click",this.#u.bind(this),{signal:e}),t.addEventListener("keydown",this.#t,{signal:e});const s=this.#n=document.createElement("span");return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=this.#o,t.append(s),t}renderMainDropdown(){const t=this.#i=this.#a();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#a(){const t=document.createElement("div"),e=this.#f._signal;t.addEventListener("contextmenu",ht,{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 this.#f.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 r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===this.#o),n.addEventListener("click",this.#p.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#t,{signal:e}),t}#p(t,e){e.stopPropagation(),this.#d.dispatch("switchannotationeditorparams",{source:this,type:this.#l,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#s){this.#u(t);return}const e=t.target.getAttribute("data-color");e&&this.#p(e,t)}_moveToNext(t){if(!this.#g){this.#u(t);return}if(t.target===this.#s){this.#i.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstChild||t.target===this.#s){this.#g&&this._hideDropdownFromKeyboard();return}this.#g||this.#u(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#g){this.#u(t);return}this.#i.firstChild?.focus()}_moveToEnd(t){if(!this.#g){this.#u(t);return}this.#i.lastChild?.focus()}#m(t){gt._keyboardManager.exec(this,t)}#u(t){if(this.#g){this.hideDropdown();return}if(this.#r=t.detail===0,window.addEventListener("pointerdown",this.#e,{signal:this.#f._signal}),this.#i){this.#i.classList.remove("hidden");return}const e=this.#i=this.#a();this.#s.append(e)}#A(t){this.#i?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),window.removeEventListener("pointerdown",this.#e)}get#g(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#h){if(!this.#g){this.#c?.unselect();return}this.hideDropdown(),this.#s.focus({preventScroll:!0,focusVisible:this.#r})}}updateColor(t){if(this.#n&&(this.#n.style.backgroundColor=t),!this.#i)return;const e=this.#f.highlightColors.values();for(const s of this.#i.children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null,this.#i?.remove(),this.#i=null}}class $ extends k{#t=null;#e=0;#s;#n=null;#o=null;#i=null;#r=null;#h=0;#c=null;#d=null;#f=null;#l=!1;#a=this.#w.bind(this);#p=null;#m;#u=null;#A="";#g;#v="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=F.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=$.prototype;return D(this,"_keyboardManager",new Yt([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||$._defaultColor,this.#g=t.thickness||$._defaultThickness,this.#m=t.opacity||$._defaultOpacity,this.#s=t.boxes||null,this.#v=t.methodOfCreation||"",this.#A=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#l=!0,this.#E(t),this.#_()):(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#r=t.focusNode,this.#h=t.focusOffset,this.#y(),this.#_(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#l?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#v}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#y(){const t=new Ne(this.#s,.001);this.#d=t.getOutlines(),{x:this.x,y:this.y,width:this.width,height:this.height}=this.#d.box;const e=new Ne(this.#s,.0025,.001,this._uiManager.direction==="ltr");this.#i=e.getOutlines();const{lastPoint:s}=this.#i.box;this.#p=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#E({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#d=t;const i=1.5;if(this.#i=t.getNewOutline(this.#g/2+i,.0025),e>=0)this.#f=e,this.#n=s,this.parent.drawLayer.finalizeLine(e,t),this.#u=this.parent.drawLayer.highlightOutline(this.#i);else if(this.parent){const h=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#f,t),this.parent.drawLayer.updateBox(this.#f,$.#b(this.#d.box,(h-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#u,this.#i),this.parent.drawLayer.updateBox(this.#u,$.#b(this.#i.box,h))}const{x:n,y:r,width:a,height:o}=t.box;switch(this.rotation){case 0:this.x=n,this.y=r,this.width=a,this.height=o;break;case 90:{const[h,d]=this.parentDimensions;this.x=r,this.y=1-n,this.width=a*d/h,this.height=o*h/d;break}case 180:this.x=1-n,this.y=1-r,this.width=a,this.height=o;break;case 270:{const[h,d]=this.parentDimensions;this.x=1-r,this.y=n,this.width=a*d/h,this.height=o*h/d;break}}const{lastPoint:l}=this.#i.box;this.#p=[(l[0]-n)/a,(l[1]-r)/o]}static initialize(t,e){k.initialize(t,e),$._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case R.HIGHLIGHT_DEFAULT_COLOR:$._defaultColor=e;break;case R.HIGHLIGHT_THICKNESS:$._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#p}updateParams(t,e){switch(t){case R.HIGHLIGHT_COLOR:this.#C(e);break;case R.HIGHLIGHT_THICKNESS:this.#x(e);break}}static get defaultPropertiesToUpdate(){return[[R.HIGHLIGHT_DEFAULT_COLOR,$._defaultColor],[R.HIGHLIGHT_THICKNESS,$._defaultThickness]]}get propertiesToUpdate(){return[[R.HIGHLIGHT_COLOR,this.color||$._defaultColor],[R.HIGHLIGHT_THICKNESS,this.#g||$._defaultThickness],[R.HIGHLIGHT_FREE,this.#l]]}#C(t){const e=i=>{this.color=i,this.parent?.drawLayer.changeColor(this.#f,i),this.#o?.updateColor(i)},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#x(t){const e=this.#g,s=i=>{this.#g=i,this.#P(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#o=new gt({editor:this}),t.addColorPicker(this.#o)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#k())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#k())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#S(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#_(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#S():t&&(this.#_(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#P(t){if(!this.#l)return;this.#E({highlightOutlines:this.#d.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}#S(){this.#f===null||!this.parent||(this.parent.drawLayer.remove(this.#f),this.#f=null,this.parent.drawLayer.remove(this.#u),this.#u=null)}#_(t=this.parent){this.#f===null&&({id:this.#f,clipPathId:this.#n}=t.drawLayer.highlight(this.#d,this.color,this.#m),this.#u=t.drawLayer.highlightOutline(this.#i),this.#c&&(this.#c.style.clipPath=this.#n))}static#b({x:t,y:e,width:s,height:i},n){switch(n){case 90:return{x:1-e-i,y:t,width:i,height:s};case 180:return{x:1-t-s,y:1-e-i,width:s,height:i};case 270:return{x:e,y:1-t-s,width:i,height:s}}return{x:t,y:e,width:s,height:i}}rotate(t){const{drawLayer:e}=this.parent;let s;this.#l?(t=(t-this.rotation+360)%360,s=$.#b(this.#d.box,t)):s=$.#b(this,t),e.rotate(this.#f,t),e.rotate(this.#u,t),e.updateBox(this.#f,s),e.updateBox(this.#u,$.#b(this.#i.box,t))}
12render(){if(this.div)return this.div;const t=super.render();this.#A&&(t.setAttribute("aria-label",this.#A),t.setAttribute("role","mark")),this.#l?t.classList.add("free"):this.div.addEventListener("keydown",this.#a,{signal:this._uiManager._signal});const e=this.#c=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#n;const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),le(this,this.#c,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(this.#u,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#u,"hovered")}#w(t){$._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#T(!0);break;case 1:case 3:this.#T(!1);break}}#T(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#r,this.#h)}select(){super.select(),this.#u&&(this.parent?.drawLayer.removeClass(this.#u,"hovered"),this.parent?.drawLayer.addClass(this.#u,"selected"))}unselect(){super.unselect(),this.#u&&(this.parent?.drawLayer.removeClass(this.#u,"selected"),this.#l||this.#T(!1))}get _mustFixPosition(){return!this.#l}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(this.#f,t),this.parent.drawLayer.show(this.#u,t))}#k(){return this.#l?this.rotation:0}#L(){if(this.#l)return null;const[t,e]=this.pageDimensions,s=this.#s,i=new Float32Array(s.length*8);let n=0;for(const{x:r,y:a,width:o,height:l}of s){const h=r*t,d=(1-a-l)*e;i[n]=i[n+4]=h,i[n+1]=i[n+3]=d,i[n+2]=i[n+6]=h+o*t,i[n+5]=i[n+7]=d+l*e,n+=8}return i}#M(t){return this.#d.serialize(t,this.#k())}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:r,y:a,width:o,height:l}=s.getBoundingClientRect(),h=g=>{this.#D(t,g)},d=t._signal,u={capture:!0,passive:!1,signal:d},p=g=>{g.preventDefault(),g.stopPropagation()},f=g=>{s.removeEventListener("pointermove",h),window.removeEventListener("blur",f),window.removeEventListener("pointerup",f),window.removeEventListener("pointerdown",p,u),window.removeEventListener("contextmenu",ht),this.#I(t,g)};window.addEventListener("blur",f,{signal:d}),window.addEventListener("pointerup",f,{signal:d}),window.addEventListener("pointerdown",p,u),window.addEventListener("contextmenu",ht,{signal:d}),s.addEventListener("pointermove",h,{signal:d}),this._freeHighlight=new Mt({x:i,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static#D(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#I(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static deserialize(t,e,s){const i=super.deserialize(t,e,s),{rect:[n,r,a,o],color:l,quadPoints:h}=t;i.color=S.makeHexColor(...l),i.#m=t.opacity;const[d,u]=i.pageDimensions;i.width=(a-n)/d,i.height=(o-r)/u;const p=i.#s=[];for(let f=0;f<h.length;f+=8)p.push({x:(h[4]-a)/d,y:(o-(1-h[f+5]))/u,width:(h[f+2]-h[f])/d,height:(h[f+5]-h[f+1])/u});return i.#y(),i}serialize(t=!1){if(this.isEmpty()||t)return null;const e=this.getRect(0,0),s=k._colorManager.convert(this.color);return{annotationType:F.HIGHLIGHT,color:s,opacity:this.#m,thickness:this.#g,quadPoints:this.#L(),outlines:this.#M(e),pageIndex:this.pageIndex,rect:e,rotation:this.#k(),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}}class K extends k{#t=0;#e=0;#s=this.canvasPointermove.bind(this);#n=this.canvasPointerleave.bind(this);#o=this.canvasPointerup.bind(this);#i=this.canvasPointerdown.bind(this);#r=null;#h=new Path2D;#c=!1;#d=!1;#f=!1;#l=null;#a=0;#p=0;#m=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=F.INK;constructor(t){super({...t,name:"inkEditor"}),this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.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(t,e){k.initialize(t,e)}static updateDefaultParams(t,e){switch(t){case R.INK_THICKNESS:K._defaultThickness=e;break;case R.INK_COLOR:K._defaultColor=e;break;case R.INK_OPACITY:K._defaultOpacity=e/100;break}}updateParams(t,e){switch(t){case R.INK_THICKNESS:this.#u(e);break;case R.INK_COLOR:this.#A(e);break;case R.INK_OPACITY:this.#g(e);break}}static get defaultPropertiesToUpdate(){return[[R.INK_THICKNESS,K._defaultThickness],[R.INK_COLOR,K._defaultColor||k._defaultLineColor],[R.INK_OPACITY,Math.round(K._defaultOpacity*100)]]}get propertiesToUpdate(){return[[R.INK_THICKNESS,this.thickness||K._defaultThickness],[R.INK_COLOR,this.color||K._defaultColor||k._defaultLineColor],[R.INK_OPACITY,Math.round(100*(this.opacity??K._defaultOpacity))]]}#u(t){const e=i=>{this.thickness=i,this.#N()},s=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#A(t){const e=i=>{this.color=i,this.#w()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#g(t){const e=i=>{this.opacity=i,this.#w()};t/=100;const s=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(this.#k(),this.#L()),this.isAttachedToDOM||(this.parent.add(this),this.#M()),this.#N()))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#l?.disconnect(),this.#l=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,e]=this.parentDimensions,s=this.width*t,i=this.height*e;this.setDimensions(s,i)}enableEditMode(){this.#c||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#i,{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",this.#i))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}#v(){const{parentRotation:t,parentDimensions:[e,s]}=this;switch(t){case 90:return[0,s,s,e];case 180:return[e,s,e,s];case 270:return[e,0,s,e];default:return[0,0,e,s]}}#y(){const{ctx:t,color:e,opacity:s,thickness:i,parentScale:n,scaleFactor:r}=this;
12t.lineWidth=i*n/r,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${mi(s)}`}#E(t,e){const s=this._uiManager._signal;this.canvas.addEventListener("contextmenu",ht,{signal:s}),this.canvas.addEventListener("pointerleave",this.#n,{signal:s}),this.canvas.addEventListener("pointermove",this.#s,{signal:s}),this.canvas.addEventListener("pointerup",this.#o,{signal:s}),this.canvas.removeEventListener("pointerdown",this.#i),this.isEditing=!0,this.#f||(this.#f=!0,this.#M(),this.thickness||=K._defaultThickness,this.color||=K._defaultColor||k._defaultLineColor,this.opacity??=K._defaultOpacity),this.currentPath.push([t,e]),this.#d=!1,this.#y(),this.#m=()=>{this.#S(),this.#m&&window.requestAnimationFrame(this.#m)},window.requestAnimationFrame(this.#m)}#C(t,e){const[s,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===s&&e===i)return;const n=this.currentPath;let r=this.#h;if(n.push([t,e]),this.#d=!0,n.length<=2){r.moveTo(...n[0]),r.lineTo(t,e);return}n.length===3&&(this.#h=r=new Path2D,r.moveTo(...n[0])),this.#_(r,...n.at(-3),...n.at(-2),t,e)}#x(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);this.#h.lineTo(...t)}#P(t,e){this.#m=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#C(t,e),this.#x();let s;if(this.currentPath.length!==1)s=this.#b();else{const o=[t,e];s=[[o,o.slice(),o.slice(),o]]}const i=this.#h,n=this.currentPath;this.currentPath=[],this.#h=new Path2D;const r=()=>{this.allRawPaths.push(n),this.paths.push(s),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},a=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(this.#k(),this.#L()),this.#N())};this.addCommands({cmd:r,undo:a,mustExec:!0})}#S(){if(!this.#d)return;this.#d=!1;const t=Math.ceil(this.thickness*this.parentScale),e=this.currentPath.slice(-3),s=e.map(r=>r[0]),i=e.map(r=>r[1]);Math.min(...s)-t,Math.max(...s)+t,Math.min(...i)-t,Math.max(...i)+t;const{ctx:n}=this;n.save(),n.clearRect(0,0,this.canvas.width,this.canvas.height);for(const r of this.bezierPath2D)n.stroke(r);n.stroke(this.#h),n.restore()}#_(t,e,s,i,n,r,a){const o=(e+i)/2,l=(s+n)/2,h=(i+r)/2,d=(n+a)/2;t.bezierCurveTo(o+2*(i-o)/3,l+2*(n-l)/3,h+2*(i-h)/3,d+2*(n-d)/3,h,d)}#b(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const e=[];let s,[i,n]=t[0];for(s=1;s<t.length-2;s++){const[u,p]=t[s],[f,g]=t[s+1],b=(u+f)/2,m=(p+g)/2,A=[i+2*(u-i)/3,n+2*(p-n)/3],_=[b+2*(u-b)/3,m+2*(p-m)/3];e.push([[i,n],A,_,[b,m]]),[i,n]=[b,m]}const[r,a]=t[s],[o,l]=t[s+1],h=[i+2*(r-i)/3,n+2*(a-n)/3],d=[o+2*(r-o)/3,l+2*(a-l)/3];return e.push([[i,n],h,d,[o,l]]),e}#w(){if(this.isEmpty()){this.#I();return}this.#y();const{canvas:t,ctx:e}=this;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),this.#I();for(const s of this.bezierPath2D)e.stroke(s)}commit(){this.#c||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#c=!0,this.div.classList.add("disabled"),this.#N(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button!==0||!this.isInEditMode()||this.#c||(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),this.#E(t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),this.#C(t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),this.#T(t)}canvasPointerleave(t){this.#T(t)}#T(t){this.canvas.removeEventListener("pointerleave",this.#n),this.canvas.removeEventListener("pointermove",this.#s),this.canvas.removeEventListener("pointerup",this.#o),this.canvas.addEventListener("pointerdown",this.#i,{signal:this._uiManager._signal}),this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.canvas.removeEventListener("contextmenu",ht)},10),this.#P(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#k(){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")}
12#L(){this.#l=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}),this.#l.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#l?.disconnect(),this.#l=null},{once:!0})}get isResizable(){return!this.isEmpty()&&this.#c}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[s,i,n,r]=this.#v();if(this.setAt(s,i,0,0),this.setDims(n,r),this.#k(),this.width){const[a,o]=this.parentDimensions;this.setAspectRatio(this.width*a,this.height*o),this.setAt(t*a,e*o,this.width*a,this.height*o),this.#f=!0,this.#M(),this.setDims(this.width*a,this.height*o),this.#w(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#L(),this.div}#M(){if(!this.#f)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#I()}setDimensions(t,e){const s=Math.round(t),i=Math.round(e);if(this.#a===s&&this.#p===i)return;this.#a=s,this.#p=i,this.canvas.style.visibility="hidden";const[n,r]=this.parentDimensions;this.width=t/n,this.height=e/r,this.fixAndSetPosition(),this.#c&&this.#D(t,e),this.#M(),this.#w(),this.canvas.style.visibility="visible",this.fixDims()}#D(t,e){const s=this.#z(),i=(t-s)/this.#e,n=(e-s)/this.#t;this.scaleFactor=Math.min(i,n)}#I(){const t=this.#z()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#O(t){const e=new Path2D;for(let s=0,i=t.length;s<i;s++){const[n,r,a,o]=t[s];s===0&&e.moveTo(...n),e.bezierCurveTo(r[0],r[1],a[0],a[1],o[0],o[1])}return e}static#F(t,e,s){const[i,n,r,a]=e;switch(s){case 0:for(let o=0,l=t.length;o<l;o+=2)t[o]+=i,t[o+1]=a-t[o+1];break;case 90:for(let o=0,l=t.length;o<l;o+=2){const h=t[o];t[o]=t[o+1]+i,t[o+1]=h+n}break;case 180:for(let o=0,l=t.length;o<l;o+=2)t[o]=r-t[o],t[o+1]+=n;break;case 270:for(let o=0,l=t.length;o<l;o+=2){const h=t[o];t[o]=r-t[o+1],t[o+1]=a-h}break;default:throw new Error("Invalid rotation")}return t}static#W(t,e,s){const[i,n,r,a]=e;switch(s){case 0:for(let o=0,l=t.length;o<l;o+=2)t[o]-=i,t[o+1]=a-t[o+1];break;case 90:for(let o=0,l=t.length;o<l;o+=2){const h=t[o];t[o]=t[o+1]-n,t[o+1]=h-i}break;case 180:for(let o=0,l=t.length;o<l;o+=2)t[o]=r-t[o],t[o+1]-=n;break;case 270:for(let o=0,l=t.length;o<l;o+=2){const h=t[o];t[o]=a-t[o+1],t[o+1]=r-h}break;default:throw new Error("Invalid rotation")}return t}#G(t,e,s,i){const n=[],r=this.thickness/2,a=t*e+r,o=t*s+r;for(const l of this.paths){const h=[],d=[];for(let u=0,p=l.length;u<p;u++){const[f,g,b,m]=l[u];if(f[0]===m[0]&&f[1]===m[1]&&p===1){const O=t*f[0]+a,M=t*f[1]+o;h.push(O,M),d.push(O,M);break}const A=t*f[0]+a,_=t*f[1]+o,v=t*g[0]+a,y=t*g[1]+o,w=t*b[0]+a,E=t*b[1]+o,x=t*m[0]+a,C=t*m[1]+o;u===0&&(h.push(A,_),d.push(A,_)),h.push(v,y,w,E,x,C),d.push(v,y),u===p-1&&d.push(x,C)}n.push({bezier:K.#F(h,i,this.rotation),points:K.#F(d,i,this.rotation)})}return n}#$(){let t=1/0,e=-1/0,s=1/0,i=-1/0;for(const n of this.paths)for(const[r,a,o,l]of n){const h=S.bezierBoundingBox(...r,...a,...o,...l);t=Math.min(t,h[0]),s=Math.min(s,h[1]),e=Math.max(e,h[2]),i=Math.max(i,h[3])}return[t,s,e,i]}#z(){return this.#c?Math.ceil(this.thickness*this.parentScale):0}#N(t=!1){if(this.isEmpty())return;if(!this.#c){this.#w();return}const e=this.#$(),s=this.#z();this.#e=Math.max(k.MIN_SIZE,e[2]-e[0]),this.#t=Math.max(k.MIN_SIZE,e[3]-e[1]);const i=Math.ceil(s+this.#e*this.scaleFactor),n=Math.ceil(s+this.#t*this.scaleFactor),[r,a]=this.parentDimensions;this.width=i/r,this.height=n/a,this.setAspectRatio(i,n);const o=this.translationX,l=this.translationY;this.translationX=-e[0],this.translationY=-e[1],this.#M(),this.#w(),this.#a=i,this.#p=n,this.setDims(i,n);const h=t?s/this.scaleFactor/2:0;this.translate(o-this.translationX-h,l-this.translationY-h)}static deserialize(t,e,s){if(t instanceof Gs)return null;const i=super.deserialize(t,e,s);i.thickness=t.thickness,i.color=S.makeHexColor(...t.color),i.opacity=t.opacity;const[n,r]=i.pageDimensions,a=i.width*n,o=i.height*r,l=i.parentScale,h=t.thickness/2;i.#c=!0,i.#a=Math.round(a),i.#p=Math.round(o);const{paths:d,rect:u,rotation:p}=t;for(let{bezier:g}of d){g=K.#W(g,u,p);const b=[];i.paths.push(b);
12let m=l*(g[0]-h),A=l*(g[1]-h);for(let v=2,y=g.length;v<y;v+=6){const w=l*(g[v]-h),E=l*(g[v+1]-h),x=l*(g[v+2]-h),C=l*(g[v+3]-h),O=l*(g[v+4]-h),M=l*(g[v+5]-h);b.push([[m,A],[w,E],[x,C],[O,M]]),m=O,A=M}const _=this.#O(b);i.bezierPath2D.push(_)}const f=i.#$();return i.#e=Math.max(k.MIN_SIZE,f[2]-f[0]),i.#t=Math.max(k.MIN_SIZE,f[3]-f[1]),i.#D(a,o),i}serialize(){if(this.isEmpty())return null;const t=this.getRect(0,0),e=k._colorManager.convert(this.ctx.strokeStyle);return{annotationType:F.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:this.#G(this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class ts extends k{#t=null;#e=null;#s=null;#n=null;#o=null;#i="";#r=null;#h=null;#c=null;#d=!1;#f=!1;static _type="stamp";static _editorType=F.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#n=t.bitmapUrl,this.#o=t.bitmapFile}static initialize(t,e){k.initialize(t,e)}static get supportedTypes(){return D(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return D(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(F.STAMP,{bitmapFile:t.getAsFile()})}#l(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#d=t.isSvg),t.file&&(this.#i=t.file.name),this.#m()}#a(){this.#s=null,this._uiManager.enableWaiting(!1),this.#r&&this.div.focus()}#p(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#l(s,!0)).finally(()=>this.#a());return}if(this.#n){const s=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#l(i)).finally(()=>this.#a());return}if(this.#o){const s=this.#o;this.#o=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then(i=>this.#l(i)).finally(()=>this.#a());return}const t=document.createElement("input");t.type="file",t.accept=ts.supportedTypesStr;const e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this.#l(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#a()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#h?.disconnect(),this.#h=null,this.#c&&(clearTimeout(this.#c),this.#c=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#p();return}super.rebuild(),this.div!==null&&(this.#e&&this.#r===null&&this.#p(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#n||this.#o||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#t?this.#m():this.#p(),this.width){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i)}return this.div}#m(){const{div:t}=this;let{width:e,height:s}=this.#t;const[i,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>r*i||s>r*n){const h=Math.min(r*i/e,r*n/s);e*=h,s*=h}const[a,o]=this.parentDimensions;this.setDims(e*a/i,s*o/n),this._uiManager.enableWaiting(!1);const l=this.#r=document.createElement("canvas");t.append(l),t.hidden=!1,this.#g(e,s),this.#y(),this.#f||(this.parent.addUndoableEditor(this),this.#f=!0),this._reportTelemetry({action:"inserted_image"}),this.#i&&l.setAttribute("aria-label",this.#i)}#u(t,e){const[s,i]=this.parentDimensions;this.width=t/s,this.height=e/i,this.setDims(t,e),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this.#c!==null&&clearTimeout(this.#c);const n=200;this.#c=setTimeout(()=>{this.#c=null,this.#g(t,e)},n)}#A(t,e){const{width:s,height:i}=this.#t;let n=s,r=i,a=this.#t;for(;n>2*t||r>2*e;){const o=n,l=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(a,0,0,o,l,0,0,n,r),a=h.transferToImageBitmap()}return a}#g(t,e){t=Math.ceil(t),e=Math.ceil(e);const s=this.#r;if(!s||s.width===t&&s.height===e)return;s.width=t,s.height=e;const i=this.#d?this.#t:this.#A(t,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){const a=new OffscreenCanvas(t,e).getContext("2d");a.drawImage(i,0,0,i.width,i.height,0,0,t,e),this._uiManager.mlGuess({service:"image-to-text",request:{data:a.getImageData(0,0,t,e).data,width:t,height:e,channels:4}}).then(o=>{const l=o?.output||"";this.parent&&l&&!this.hasAltText()&&(this.altTextData={altText:l,decorative:!1})})}const n=s.getContext("2d");n.filter=this._uiManager.hcmFilter,n.drawImage(i,0,0,i.width,i.height,0,0,t,e)}
12getImageForAltText(){return this.#r}#v(t){if(t){if(this.#d){const i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#d){const[e,s]=this.pageDimensions,i=Math.round(this.width*e*Bt.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*Bt.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}#y(){this._uiManager._signal&&(this.#h=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.#u(e.width,e.height)}),this.#h.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#h?.disconnect(),this.#h=null},{once:!0}))}static deserialize(t,e,s){if(t instanceof Vs)return null;const i=super.deserialize(t,e,s),{rect:n,bitmapUrl:r,bitmapId:a,isSvg:o,accessibilityData:l}=t;a&&s.imageManager.isValidId(a)?i.#e=a:i.#n=r,i.#d=o;const[h,d]=i.pageDimensions;return i.width=(n[2]-n[0])/h,i.height=(n[3]-n[1])/d,l&&(i.altTextData=l),i}serialize(t=!1,e=null){if(this.isEmpty())return null;const s={annotationType:F.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#d,structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=this.#v(!0),s.accessibilityData=this.altTextData,s;const{decorative:i,altText:n}=this.altTextData;if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),e===null)return s;e.stamps||=new Map;const r=this.#d?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#v(!1);else if(this.#d){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#v(!1))}return s}}class yt{#t;#e=!1;#s=null;#n=null;#o=null;#i=null;#r=null;#h=new Map;#c=!1;#d=!1;#f=!1;#l=null;#a;static _initialized=!1;static#p=new Map([q,K,ts,$].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,accessibilityManager:i,annotationLayer:n,drawLayer:r,textLayer:a,viewport:o,l10n:l}){const h=[...yt.#p.values()];if(!yt._initialized){yt._initialized=!0;for(const d of h)d.initialize(l,t)}t.registerEditorTypes(h),this.#a=t,this.pageIndex=e,this.div=s,this.#t=i,this.#s=n,this.viewport=o,this.#l=a,this.drawLayer=r,this.#a.addLayer(this)}get isEmpty(){return this.#h.size===0}get isInvisible(){return this.isEmpty&&this.#a.getMode()===F.NONE}updateToolbar(t){this.#a.updateToolbar(t)}updateMode(t=this.#a.getMode()){switch(this.#v(),t){case F.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case F.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case F.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 yt.#p.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#l?.div}addInkEditorIfNeeded(t){if(this.#a.getMode()!==F.INK)return;if(!t){for(const s of this.#h.values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){this.#a.setEditingState(t)}addCommands(t){this.#a.addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of this.#h.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#a.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!this.#s)return;const e=this.#s.getEditableAnnotations();for(const s of e){if(s.hide(),this.#a.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){this.#f=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#h.values())if(i.disableEditing(),!!i.annotationElementId){if
12(i.serialize()!==null){t.set(i.annotationElementId,i);continue}else e.set(i.annotationElementId,i);this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()}if(this.#s){const i=this.#s.getEditableAnnotations();for(const n of i){const{id:r}=n.data;if(this.#a.isDeletedAnnotationElement(r))continue;let a=e.get(r);if(a){a.resetAnnotationElement(n),a.show(!1),n.show();continue}a=t.get(r),a&&(this.#a.addChangedExistingAnnotation(a),a.renderAnnotationElement(n),a.show(!1)),n.show()}}this.#v(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of yt.#p.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#f=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#a.getActive()!==t&&this.#a.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1,this.#l?.div&&!this.#i&&(this.#i=this.#m.bind(this),this.#l.div.addEventListener("pointerdown",this.#i,{signal:this.#a._signal}),this.#l.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#l?.div&&this.#i&&(this.#l.div.removeEventListener("pointerdown",this.#i),this.#i=null,this.#l.div.classList.remove("highlighting"))}#m(t){if(this.#a.unselectAll(),t.target===this.#l.div){const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e)return;this.#a.showAllEditors("highlight",!0,!0),this.#l.div.classList.add("free"),$.startHighlighting(this,this.#a.direction==="ltr",t),this.#l.div.addEventListener("pointerup",()=>{this.#l.div.classList.remove("free")},{once:!0,signal:this.#a._signal}),t.preventDefault()}}enableClick(){if(this.#o)return;const t=this.#a._signal;this.#o=this.pointerdown.bind(this),this.#n=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#o,{signal:t}),this.div.addEventListener("pointerup",this.#n,{signal:t})}disableClick(){this.#o&&(this.div.removeEventListener("pointerdown",this.#o),this.div.removeEventListener("pointerup",this.#n),this.#o=null,this.#n=null)}attach(t){this.#h.set(t.id,t);const{annotationElementId:e}=t;e&&this.#a.isDeletedAnnotationElement(e)&&this.#a.removeDeletedAnnotationElement(t)}detach(t){this.#h.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#f&&t.annotationElementId&&this.#a.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#a.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#d||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#a.addDeletedAnnotationElement(t.annotationElementId),k.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#a.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#a.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#a._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return this.#a.getId()}get#u(){return yt.#p.get(this.#a.getMode())}get _signal(){return this.#a._signal}#A(t){const e=this.#u;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#u?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#a.updateToolbar(t),this.#a.updateMode(t);const{offsetX:s,offsetY:i}=this.#g(),n=this.getNextId(),r=this.#A({parent:this,id:n,x:s,y:i,uiManager:this.#a,isCentered:!0,...e});r&&this.add(r)}deserialize(t){return yt.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#a)||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=this.#A({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#a,isCentered:e,...s});return n&&this.add(n),n}#g(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),l=(n+a)/2-t,h=(r+o)/2-e,[d,u]=this.viewport.rotation%180===0?[l,h]:[h,l];return{offsetX:d,offsetY:u}}addNewEditor(){this.createAndAddNewEditor(this.#g(),!0)}setSelected(t){this.#a.setSelected(t)}toggleSelected(t){this.#a.toggleSelected(t)}isSelected(t){return this.#a.isSelected(t)}unselect(t){this.#a.unselect(t)}pointerup(t){const{isMac:e}=ot.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#c){if(this.#c=!1,!this.#e){this.#e=!0;return}if(this.#a.getMode()===F.STAMP){this.#a.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#a.getMode()===F.HIGHLIGHT&&this.enableTextSelection(),this.#c){this.#c=!1;return}const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;this.#c=!0;const s=this.#a.getActive();this.#e=!s||s.isEmpty()}findNewParent(t,e,s){const i=this.#a.findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){this.#a.getActive()?.parent===this&&(this.#a.commitOrRemove(),this.#a.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(const t of this.#h.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#h.clear(),this.#a.removeLayer(this)}#v(){this.#d=!0;for(const t of this.#h.values())t.isEmpty()&&t.remove();this.#d=!1}render({viewport:t}){this.viewport=t,Lt(this.div,t);for(const e of this.#a.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#a.commitOrRemove(),this.#v();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Lt(this.div,{rotation:s}),e!==s)for(const i of this.#h.values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#a.viewParameters.realScale}}class Z{#t=null;#e=0;#s=new Map;#n=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#s.size>0)for(const e of this.#s.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return D(this,"_svgFactory",new Ue)}static#o(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`}#i(t){const e=Z._svgFactory.create(1,1,!0);return this.#t.append(e),e.setAttribute("aria-hidden",!0),Z.#o(e,t),e}#r(t,e){const s=Z._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=Z._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}highlight(t,e,s,i=!1){const n=this.#e++,r=this.#i(t.box);r.classList.add("highlight"),t.free&&r.classList.add("free");const a=Z._svgFactory.createElement("defs");r.append(a);const o=Z._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("d",t.toSVGPath()),i&&this.#n.set(n,o);const h=this.#r(a,l),d=Z._svgFactory.createElement("use");return r.append(d),r.setAttribute("fill",e),r.setAttribute("fill-opacity",s),d.setAttribute("href",`#${l}`),this.#s.set(n,r),{id:n,clipPathId:`url(#${h})`}}highlightOutline(t){const e=this.#e++,s=this.#i(t.box);s.classList.add("highlightOutline");const i=Z._svgFactory.createElement("defs");s.append(i);const n=Z._svgFactory.createElement("path");i.append(n);const r=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",r),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let a;if(t.free){s.classList.add("free");const h=Z._svgFactory.createElement("mask");i.append(h),a=`mask_p${this.pageIndex}_${e}`,h.setAttribute("id",a),h.setAttribute("maskUnits","objectBoundingBox");const d=Z._svgFactory.createElement("rect");h.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");const u=Z._svgFactory.createElement("use");h.append(u),u.setAttribute("href",`#${r}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}const o=Z._svgFactory.createElement("use");s.append(o),o.setAttribute("href",`#${r}`),a&&o.setAttribute("mask",`url(#${a})`);const l=o.cloneNode();return s.append(l),o.classList.add("mainOutline"),l.classList.add("secondaryOutline"),this.#s.set(e,s),e}finalizeLine(t,e){const s=this.#n.get(t);this.#n.delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#s.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),this.#n.delete(t)}updatePath(t,e){this.#n.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){Z.#o(this.#s.get(t),e)}show(t,e){this.#s.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#s.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#s.get(t).setAttribute("fill",e)}
12changeOpacity(t,e){this.#s.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#s.get(t).classList.add(e)}removeClass(t,e){this.#s.get(t).classList.remove(e)}remove(t){this.#t!==null&&(this.#s.get(t).remove(),this.#s.delete(t))}destroy(){this.#t=null;for(const t of this.#s.values())t.remove();this.#s.clear()}}var Yn=T.AbortException,Kn=T.AnnotationEditorLayer,Qn=T.AnnotationEditorParamsType,Jn=T.AnnotationEditorType,Zn=T.AnnotationEditorUIManager,tr=T.AnnotationLayer,er=T.AnnotationMode,sr=T.CMapCompressionType,ir=T.ColorPicker,nr=T.DOMSVGFactory,rr=T.DrawLayer,ar=T.FeatureTest,or=T.GlobalWorkerOptions,hr=T.ImageKind,lr=T.InvalidPDFException,cr=T.MissingPDFException,dr=T.OPS,ur=T.Outliner,fr=T.PDFDataRangeTransport,pr=T.PDFDateString,gr=T.PDFWorker,mr=T.PasswordResponses,br=T.PermissionFlag,Ar=T.PixelsPerInch,vr=T.RenderingCancelledException,_r=T.TextLayer,yr=T.UnexpectedResponseException,wr=T.Util,Er=T.VerbosityLevel,Sr=T.XfaLayer,Cr=T.build,xr=T.createValidAbsoluteUrl,Tr=T.fetchData,kr=T.getDocument,Rr=T.getFilenameFromUrl,Pr=T.getPdfFilenameFromUrl,Mr=T.getXfaPageViewport,Lr=T.isDataScheme,Ir=T.isPdfFile,Fr=T.noContextMenu,Dr=T.normalizeUnicode,Or=T.renderTextLayer,Nr=T.setLayerDimensions,Hr=T.shadow,Br=T.updateTextLayer,zr=T.version;export{Yn as AbortException,Kn as AnnotationEditorLayer,Qn as AnnotationEditorParamsType,Jn as AnnotationEditorType,Zn as AnnotationEditorUIManager,tr as AnnotationLayer,er as AnnotationMode,sr as CMapCompressionType,ir as ColorPicker,nr as DOMSVGFactory,rr as DrawLayer,ar as FeatureTest,or as GlobalWorkerOptions,hr as ImageKind,lr as InvalidPDFException,cr as MissingPDFException,dr as OPS,ur as Outliner,fr as PDFDataRangeTransport,pr as PDFDateString,gr as PDFWorker,mr as PasswordResponses,br as PermissionFlag,Ar as PixelsPerInch,vr as RenderingCancelledException,_r as TextLayer,yr as UnexpectedResponseException,wr as Util,Er as VerbosityLevel,Sr as XfaLayer,Cr as build,xr as createValidAbsoluteUrl,Tr as fetchData,kr as getDocument,Rr as getFilenameFromUrl,Pr as getPdfFilenameFromUrl,Mr as getXfaPageViewport,Lr as isDataScheme,Ir as isPdfFile,Fr as noContextMenu,Dr as normalizeUnicode,Or as renderTextLayer,Nr as setLayerDimensions,Hr as shadow,Br as updateTextLayer,zr as version};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.