PageSourceSearch

https://rc-editor.de/app/chunk-4J7MSUVO.js

js rc-editor.de collected 2026-10-07 05:00:58 UTC 401,344 bytes, 12 lines download raw bytes

vendor: 13,412 bytes, line 1
1import{a as lt,b as At}from"./chunk-SP56S34E.js";var Le={};Le.d=(l,t)=>{for(var e in t)Le.o(t,e)&&!Le.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})};Le.o=(l,t)=>Object.prototype.hasOwnProperty.call(l,t);var rt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Ms=[.001,0,0,.001,0,0],De=1.35,sr=.35,Wr=sr/De,ht={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},_t={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},ie="pdfjs_internal_editor_",D={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},N={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},ir={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ks={TRIANGLES:1,LATTICE:2,PATCH:3},et={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Re={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},tt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};var Ft={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var us={ERRORS:0,WARNINGS:1,INFOS:5},ne={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},Kt={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},nr={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},fs=us.WARNINGS;function rr(l){Number.isInteger(l)&&(fs=l)}function ar(){return fs}function ps(l){fs>=us.INFOS&&console.info(`Info: ${l}`)}function R(l){fs>=us.WARNINGS&&console.warn(`Warning: ${l}`)}function B(l){throw new Error(l)}function O(l,t){l||B(t)}function or(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Bn(l,t=null,e=null){if(!l)return null;if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=ur(l)}catch{}let s=t?URL.parse(l,t):URL.parse(l);return or(s)?s:null}function Un(l,t,e=!1){let s=URL.parse(l);return s?(s.hash=t,s.href):e&&Bn(l,"http://example.com")?l.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Is(l){return l.substring(l.lastIndexOf("/")+1)}function L(l,t,e,s=!1){return Object.defineProperty(l,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}var Dt=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})(),Ne=class extends Dt{constructor(t,e){super(t,"PasswordException"),this.code=e}},ee=class extends Dt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},re=class extends Dt{constructor(t){super(t,"InvalidPDFException")}},jt=class extends Dt{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}},Ls=class extends Dt{constructor(t){super(t,"FormatError")}},yt=class extends Dt{constructor(t){super(t,"AbortException")}};function lr(l){(typeof l!="object"||l?.length===void 0)&&B("Invalid argument for bytesToString");let t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);let s=[];for(let i=0;i<t;i+=e){let n=Math.min(i+e,t),r=l.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function gs(l){typeof l!="string"&&B("Invalid argument for stringToBytes");let t=l.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=l.charCodeAt(s)&255;return e}function hr(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function cr(){let l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function dr(){try{return new Function(""),!0}catch{return!1}}var K=class{static get isLittleEndian(){return L(this,"isLittleEndian",cr())}static get isEvalSupported(){return L(this,"isEvalSupported",dr())}static get isOffscreenCanvasSupported(){return L(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return L(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return L(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return L(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:t,userAgent:e}=navigator;return L(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return L(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}},_s=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0")),T=class{static makeHexColor(t,e,s){return`#${_s[t]}${_s[e]}${_s[s]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){let i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],h=e[5];for(let c=0;c<6;c+=2){let d=t[s+c],u=t[s+c+1];t[s+c]=d*i+u*r+o,t[s+c+1]=d*n+u*a+h}}static applyInverseTransform(t,e){let s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],h=e[5],c=t[0],d=t[1],u=t[2],f=t[3],p=i*c+o,g=p,m=i*u+o,b=m,y=a*d+h,A=y,v=a*f+h,w=v;if(n!==0||r!==0){let E=n*c,S=n*u,_=r*d,C=r*f;p+=_,b+=_,m+=C,g+=C,y+=E,w+=E,v+=S,A+=S}s[0]=Math.min(s[0],p,m,g,b),s[1]=Math.min(s[1],y,v,A,w),s[2]=Math.max(s[2],p,m,g,b),s[3]=Math.max(s[3],y,v,A,w)}static inverseTransform(t){let 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,e){let s=t[0],i=t[1],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,h=n**2+r**2,c=(a+h)/2,d=Math.sqrt(c**2-(a*h-o**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){let 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){let 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;let 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 pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,h,c){if(h<=0||h>=1)return;let d=1-h,u=h*h,f=u*h,p=d*(d*(d*t+3*h*e)+3*u*s)+f*i,g=d*(d*(d*n+3*h*r)+3*u*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,s,i,n,r,a,o,h,c,d,u){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/c,u);return}let f=c**2-4*d*h;if(f<0)return;let p=Math.sqrt(f),g=2*h;this.#t(t,e,s,i,n,r,a,o,(-c+p)/g,u),this.#t(t,e,s,i,n,r,a,o,(-c-p)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,h){h[0]=Math.min(h[0],t,a),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,a),h[3]=Math.max(h[3],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),h),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),h)}};function ur(l){return decodeURIComponent(escape(l))}var Cs=null,pn=null;function fr(l){return Cs||(Cs=/([\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,pn=new Map([["\uFB05","\u017Ft"]])),l.replaceAll(Cs,(t,e,s)=>e?e.normalize("NFKC"):pn.get(s))}function Hn(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let l=new Uint8Array(32);return crypto.getRandomValues(l),lr(l)}var Bt="pdfjs_internal_id_";function pr(l,t,e){if(!Array.isArray(e)||e.length<2)return!1;let[s,i,...n]=e;if(!l(s)&&!Number.isInteger(s)||!t(i))return!1;let r=n.length,a=!0;switch(i.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(let o of n)if(!(typeof o=="number"||a&&o===null))return!1;return!0}var $n=()=>[],cn=()=>new Map,Ds=()=>Object.create(null);function st(l,t,e){return Math.min(Math.max(l,t),e)}typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(l){return l.reduce((t,e)=>t+e,0)});var ae=class l{static textContent(t){let e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null,a=n.name;if(a==="#text")r=n.value;else if(l.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(let o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}},Fe=class{static setupStorage(t,e,s,i,n){let 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(let 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=>{let o=a.target.options,h=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){let{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(let[o,h]of Object.entries(r))if(h!=null)switch(o){case"class":h.length&&t.setAttribute(o,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,h)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){let e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.
1intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});let a=n!=="richText",o=t.div;if(o.append(r),t.viewport){let d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");let h=[];if(i.children.length===0){if(i.value){let d=document.createTextNode(i.value);r.append(d),a&&ae.shouldBuildText(i.name)&&h.push(d)}return{textDivs:h}}let c=[[i,-1,r]];for(;c.length>0;){let[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}let p=d.children[++c.at(-1)[1]];if(p===null)continue;let{name:g}=p;if(g==="#text"){let b=document.createTextNode(p.value);h.push(b),f.append(b);continue}let m=p?.attributes?.xmlns?document.createElementNS(p.attributes.xmlns,g):document.createElement(g);if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:n,linkService:s}),p.children?.length>0)c.push([p,-1,m]);else if(p.value){let b=document.createTextNode(p.value);a&&ae.shouldBuildText(g)&&h.push(b),m.append(b)}}for(let d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}},wt="http://www.w3.org/2000/svg",Tt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Ee(l,t="text"){if(Zt(l,document.baseURI)){let e=await fetch(l);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{let i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}var oe=class l{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;let o=(t[2]+t[0])/2,h=(t[3]+t[1])/2,c,d,u,f;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,m,b;c===0?(p=Math.abs(h-t[1])*s+n,g=Math.abs(o-t[0])*s+r,m=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(h-t[1])*s+r,m=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[c*s,d*s,u*s,f*s,p-c*s*o-u*s*h,g-d*s*o-f*s*h],this.width=m,this.height=b}get rawDims(){let t=this.viewBox;return L(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 l({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){let s=[t,e];return T.applyTransform(s,this.transform),s}convertToViewportRectangle(t){let e=[t[0],t[1]];T.applyTransform(e,this.transform);let s=[t[2],t[3]];return T.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){let s=[t,e];return T.applyInverseTransform(s,this.transform),s}},le=class extends Dt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function ms(l){let t=l.length,e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function dn(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function gr(l){return[l]=l.split(/[#?]/,1),Is(l)}function mr(l,t="document.pdf"){if(typeof l!="string")return t;if(ms(l))return R('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let s=(a=>{try{return new URL(a)}catch{try{return new URL(decodeURIComponent(a))}catch{try{return new URL(a,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{return null}}}}})(l);if(!s)return t;let i=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=Is(o),/^\.pdf$/i.test(o))?a:o}catch{return a}},n=/\.pdf$/i,r=Is(s.pathname);if(n.test(r))return i(r);if(s.searchParams.size>0){let a=h=>[...h].findLast(c=>n.test(c)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return i(o)}if(s.hash){let o=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(o)return i(o[0])}return t}var Oe=class{started=Object.create(null);times=[];time(t){t in this.started&&R(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||R(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:s}of this.times)e=Math.max(s.length,e);for(let{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
2`);return t.join("")}};function Zt(l,t){let e=t?URL.parse(l,t):URL.parse(l);return/https?:/.test(e?.protocol??"")}function ft(l){l.preventDefault()}function Y(l){l.preventDefault(),l.stopPropagation()}function jn(l){console.log("Deprecated API usage: "+l)}var he=class{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let s=parseInt(e[1],10),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;let h=e[7]||"Z",c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(r+=c,a+=d):h==="+"&&(r-=c,a-=d),new Date(Date.UTC(s,i,n,r,a,o))}};function br(l,{scale:t=1,rotation:e=0}){let{width:s,height:i}=l.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new oe({viewBox:n,userUnit:1,scale:t,rotation:e})}function Se(l){if(l.startsWith("#")){let t=parseInt(l.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(R(`Not a valid color format: "${l}"`),[0,0,0])}function yr(l){let t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(let e of l.keys()){t.style.color=e;let s=window.getComputedStyle(t).color;l.set(e,Se(s))}t.remove()}function V(l){let{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform();return[t,e,s,i,n,r]}function mt(l){let{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform().invertSelf();return[t,e,s,i,n,r]}function Mt(l,t,e=!1,s=!0){if(t instanceof oe){let{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=l,a=K.isCSSRoundSupported,o=`var(--total-scale-factor) * ${i}px`,h=`var(--total-scale-factor) * ${n}px`,c=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=a?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(r.width=c,r.height=d):(r.width=d,r.height=c)}s&&l.setAttribute("data-main-rotation",t.rotation)}var vt=class l{constructor(){let{pixelRatio:t}=l;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,n=-1){let r=1/0,a=1/0,o=1/0;s=l.capPixels(s,n),s>0&&(r=Math.sqrt(s/(t*e))),i!==-1&&(a=i/t,o=i/e);let h=Math.min(r,a,o);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>
2=0){let s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}},Rs=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"],Ns=class{static get isDarkMode(){return L(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}},Fs=class{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:s}=window.getComputedStyle(t);return t.remove(),L(this,"commentForegroundColor",Se(s))}};function Ar(l,t,e,s){s=st(s??1,0,1);let i=255*(1-s);return l=Math.round(l*s+i),t=Math.round(t*s+i),e=Math.round(e*s+i),[l,t,e]}function gn(l,t){let e=l[0]/255,s=l[1]/255,i=l[2]/255,n=Math.max(e,s,i),r=Math.min(e,s,i),a=(n+r)/2;if(n===r)t[0]=t[1]=0;else{let o=n-r;switch(t[1]=a<.5?o/(n+r):o/(2-n-r),n){case e:t[0]=((s-i)/o+(s<i?6:0))*60;break;case s:t[0]=((i-e)/o+2)*60;break;case i:t[0]=((e-s)/o+4)*60;break}}t[2]=a}function Os(l,t){let e=l[0],s=l[1],i=l[2],n=(1-Math.abs(2*i-1))*s,r=n*(1-Math.abs(e/60%2-1)),a=i-n/2;switch(Math.floor(e/60)){case 0:t[0]=n+a,t[1]=r+a,t[2]=a;break;case 1:t[0]=r+a,t[1]=n+a,t[2]=a;break;case 2:t[0]=a,t[1]=n+a,t[2]=r+a;break;case 3:t[0]=a,t[1]=r+a,t[2]=n+a;break;case 4:t[0]=r+a,t[1]=a,t[2]=n+a;break;case 5:case 6:t[0]=n+a,t[1]=a,t[2]=r+a;break}}function mn(l){return l<=.03928?l/12.92:((l+.055)/1.055)**2.4}function bn(l,t,e){Os(l,e),e.map(mn);let s=.2126*e[0]+.7152*e[1]+.0722*e[2];Os(t,e),e.map(mn);let i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}var yn=new Map;function wr(l,t){let e=l[0]+l[1]*256+l[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,s=yn.get(e);if(s)return s;let i=new Float32Array(9),n=i.subarray(0,3),r=i.subarray(3,6);gn(l,r);let a=i.subarray(6,9);gn(t,a);let o=a[2]<.5,h=o?12:4.5;if(r[2]=o?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),bn(r,a,n)<h){let c,d;o?(c=r[2],d=1):(c=0,d=r[2]);let u=.005;for(;d-c>u;){let f=r[2]=(c+d)/2;o===bn(r,a,n)<h?c=f:d=f}r[2]=o?d:c}return Os(r,n),s=T.makeHexColor(Math.round(n[0]*255),Math.round(n[1]*255),Math.round(n[2]*255)),yn.set(e,s),s}function Gn({html:l,dir:t,className:e},s){let i=document.createDocumentFragment();if(typeof l=="string"){let n=document.createElement("p");n.dir=t||"auto";let r=l.split(/(?:\r\n?|\n)/);for(let a=0,o=r.length;a<o;++a){let h=r[a];n.append(document.createTextNode(h)),a<o-1&&n.append(document.createElement("br"))}i.append(n)}else Fe.render({xfaHtml:l,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function zn(l){let t=new Path2D;if(!l)return t;for(let e=0,s=l.length;e<s;)switch(l[e++]){case Kt.moveTo:t.moveTo(l[e++],l[e++]);break;case Kt.lineTo:t.lineTo(l[e++],l[e++]);break;case Kt.curveTo:t.bezierCurveTo(l[e++],l[e++],l[e++],l[e++],l[e++],l[e++]);break;case Kt.quadraticCurveTo:t.quadraticCurveTo(l[e++],l[e++],l[e++],l[e++]);break;case Kt.closePath:t.closePath();break;default:R(`Unrecognized drawing path operator: ${l[e-1]}`);break}return t}var Bs=class{#t=null;#e=null;#i=null;#s=0;#a=[];#r=null;#n=null;get pagesNumber(){return this.#s}set pagesNumber(t){this.#s!==t&&(this.#s=t,this.#o())}#o(){this.#e=null,this.#t=null}addListener(t){this.#a.push(t)}removeListener(t){let e=this.#a.indexOf(t);e>=0&&this.#a.splice(e,1)}#h(t){for(let e of this.#a)e(t)}#l(t){if(this.#e)return;let e=this.#s,s=this.#e=new Uint32Array(e);this.#i=new Int32Array(s);let i=this.#t=new Map;if(t)for(let n=1;n<=e;n++)s[n-1]=n,i.set(n,[n])}#u(){let t=this.#t,e=this.#e;t.clear();for(let s=0,i=this.#s;s<i;s++){let n=e[s],r=t.get(n);r?r.push(s+1):t.set(n,[s+1])}}movePages(t,e,s){this.#l(!0);let i=this.#e,n=this.#t,r=e.length,a=new Uint32Array(r),o=0;for(let u=0;u<r;u++){let f=e[u]-1;a[u]=i[f],f<s&&(o+=1)}let h=this.#s,c=s-o,d=h-r;c=st(c,0,d);for(let u=0,f=0;u<h;u++)t.has(u+1)||(i[f++]=i[u]);i.copyWithin(c+r,c,d),i.set(a,c),this.#d(n,null),this.#u(),this.#h({type:"move"}),i.every((u,f)=>u===f+1)&&this.#o()}deletePages(t){this.#l(!0);let e=this.#e,s=this.#t;this.pagesNumber-=t.length,this.#l(!1);let i=this.#e,n=0,r=0;for(let a of t){let o=a-1;o!==n&&(i.set(e.subarray(n,o),r),r+=o-n),n=o+1}n<e.length&&i.set(e.subarray(n),r),this.#d(s,null),this.#u(),this.#h({type:"delete",pageNumbers:t})}copyPages(t){this.#l(!0),this.#n=t,this.#r=t.map(e=>this.#e[e-1]),this.#h({type:"copy",pageNumbers:t})}pastePages(t){this.#l(!0);let e=this.#e,s=this.#t,i=this.#n,n=new Map,r=t;for(let o of i)n.set(++r,o);this.pagesNumber+=i.length,this.#l(!1);let a=this.#e;a.set(e.subarray(0,t),0),a.set(this.#r,t),a.set(e.subarray(t),t+i.length),this.#d(s,n),this.#u(),this.#h({type:"paste"}),this.#r=null}#d(t,e){let s=this.#i,i=this.#e,n=new Map;for(let r=0,a=this.#s;r<a;
2r++){let o=e?.get(r+1);if(o){s[r]=-o;continue}let h=i[r],c=n.get(h)||0;s[r]=t.get(h)?.[c],n.set(h,c+1)}}hasBeenAltered(){return this.#e!==null}getPageMappingForSaving(){let t=this.#t,e=0;for(let i of t.values())e=Math.max(e,i.length);let s=new Array(e);for(let i=0;i<e;i++)s[i]={document:null,pageIndices:[],includePages:[]};for(let[i,n]of t)for(let r=0,a=n.length;r<a;r++)s[r].includePages.push([i-1,n[r]-1]);for(let{includePages:i,pageIndices:n}of s){i.sort((r,a)=>r[0]-a[0]);for(let r=0,a=i.length;r<a;r++)n.push(i[r][1]),i[r]=i[r][0]}return s}getPrevPageNumber(t){return this.#i[t-1]??0}getPageNumber(t){return this.#t?this.#t.get(t)?.[0]??0:t}getPageId(t){return this.#e?.[t-1]??t}getMapping(){return this.#e.subarray(0,this.pagesNumber)}},Us=class l{#t=null;#e=null;#i;#s=null;#a=null;#r=null;#n=null;#o=null;static#h=null;constructor(t){this.#i=t,l.#h||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#i._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",ft,{signal:e}),t.addEventListener("pointerdown",l.#l,{signal:e}));let s=this.#s=document.createElement("div");s.className="buttons",t.append(s);let i=this.#i.toolbarPosition;if(i){let{style:n}=t,r=this.#i._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#l(t){t.stopPropagation()}#u(t){this.#i._focusEventsAllowed=!1,Y(t)}#d(t){this.#i._focusEventsAllowed=!0,Y(t)}#f(t){let e=this.#i._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ft,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#a?.shown(),this.#r?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#i,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",l.#h[t]),this.#f(s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),this.#s.append(s)}get#m(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#f(e),this.#s.append(e,this.#m),this.#a=t}addComment(t,e=null){if(this.#r)return;let s=t.renderForToolbar();if(!s)return;this.#f(s);let i=this.#n=this.#m;e?(this.#s.insertBefore(s,e),this.#s.insertBefore(i,e)):this.#s.append(s,i),this.#r=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;let e=t.renderButton();this.#f(e),this.#s.append(e,this.#m)}async addEditSignatureButton(t){let e=this.#o=await t.renderEditButton(this.#i);this.#f(e),this.#s.append(e,this.#m)}removeButton(t){t==="comment"&&(this.#r?.removeToolbarCommentButton(),this.#r=null,this.#n?.remove(),this.#n=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;let i=this.#s.querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}},Hs=class{#t=null;#e=null;#i;constructor(t){this.#i=t}#s(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#i._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",ft,{signal:e});let s=this.#t=document.createElement("div");return s.className="buttons",t.append(s),this.#i.hasCommentManager()&&this.#r("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#i.commentSelection("floating_button")}),this.#r("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#i.highlightSelection("floating_button")}),t}#a(t,e){let s=0,i=0;for(let n of t){let r=n.y+n.height;if(r<s)continue;let 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){let[i,n]=this.#a(e,s),{style:r}=this.#e||=this.#s();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#r(t,e,s,i){let n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);let r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);let a=this.#i._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",ft,{signal:a}),n.addEventListener("click",i,{signal:a})),this.#t.append(n)}};function Vn(l,t,e){for(let s of e)t.addEventListener(s,l[s].bind(l))}var nt=class l{static#t=NaN;static#e=null;static#i=NaN;static#s=null;static initializeAndAddPointerId(t){(l.#e||=new Set).add(t)}static setPointer(t,e){l.#t||=e,l.#s??=t}static setTimeStamp(t){l.#i=t}static isSamePointerId(t){return l.#t===t}static isSamePointerIdOrRemove(t){return l.#t===t?!0:(l.#e?.delete(t),!1)}static isSamePointerType(t){return l.#s===t}static isInitializedAndDifferentPointerType(t){return l.#s!==null&&!l.isSamePointerType(t)}static isSameTimeStamp(t){return l.#i===t}static isUsingMultiplePointers(){return l.#e?.size>=1}static clearPointerType(){l.#s=null}static clearPointerIds(){l.#t=NaN,l.#e=null}static clearTimeStamp(){l.#i=NaN}},$s=class{#t=0;get id(){return`${ie}${this.#t++}`}},js=class l{#t=Hn();#e=0;#i=null;static get _isSVGFittingCanvas(){let 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;let 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 L(this,"_isSVGFittingCanvas",n)}async#s(t,e){this.#i||=new Map;let s=this.#i.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 Ee(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){let n=l._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((h,c)=>{a.onload=()=>
2{s.bitmap=a,s.isSvg=!0,h()},r.onload=async()=>{let d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){R(i),s=null}return this.#i.set(t,s),s&&this.#i.set(s.id,s),s}async getFromFile(t){let{lastModified:e,name:s,size:i,type:n}=t;return this.#s(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#s(t,t)}async getFromBlob(t,e){let s=await e;return this.#s(t,s)}async getFromId(t){this.#i||=new Map;let e=this.#i.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#i||=new Map;let s=this.#i.get(t);if(s?.bitmap)return s.refCounter+=1,s;let i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#i.set(t,s),this.#i.set(s.id,s),s}getSvgUrl(t){let e=this.#i.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#i||=new Map;let e=this.#i.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;let{bitmap:s}=e;if(!e.url&&!e.file){let i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}},Gs=class{#t=[];#e=!1;#i;#s=-1;constructor(t=128){this.#i=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;let o={cmd:t,undo:e,post:s,type:n};if(this.#s===-1){this.#t.length>0&&(this.#t.length=0),this.#s=0,this.#t.push(o);return}if(r&&this.#t[this.#s].type===n){a&&(o.undo=this.#t[this.#s].undo),this.#t[this.#s]=o;return}let h=this.#s+1;h===this.#i?this.#t.splice(0,1):(this.#s=h,h<this.#t.length&&this.#t.splice(h)),this.#t.push(o)}undo(){if(this.#s===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1,this.#s-=1}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(t){if(this.#s!==-1){for(let e=this.#s;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#s-e),this.#s=e;return}this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}},kt=class{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=K.platform;for(let[s,i,n={}]of t)for(let r of s){let 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);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let s=this.callbacks.get(this.#t(e));if(!s)return;let{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||Y(e))}},zs=class l{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return yr(t),L(this,"_colors",t)}convert(t){let e=Se(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return l._colorsMapping.get(s);return e}getHexCode(t){let e=this._colors.get(t);return e?T.makeHexColor(...e):t}},ce=(()=>{class l{#t=new AbortController;#e=null;#i=null;#s=new Map;#a=new Map;#r=null;#n=null;#o=null;#h=new Gs;#l=null;#u=null;#d=null;#f=0;#m=new Set;#g=null;#c=null;#p=new Set;_editorUndoBar=null;#b=!1;#A=!1;#y=!1;#C=null;#S=null;#v=null;#x=null;#w=!1;#_=null;#k=new $s;#P=!1;#M=!1;#O=!1;#L=null;#R=null;#B=null;#N=null;#z=null;#T=D.NONE;#E=new Set;#D=null;#U=null;#$=null;#X=null;#W=null;
vendor: 28,664 bytes, line 2
2#Y={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#j=[0,0];#F=null;#V=null;#J=null;#Z=null;#H=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let e=l.prototype,s=a=>a.#V.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),i=(a,{target:o})=>{if(o instanceof HTMLInputElement){let{type:h}=o;return h!=="text"&&h!=="number"}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return L(this,"_keyboardManager",new kt([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],e.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:i}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&a.#V.contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&a.#V.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:s}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:s}]]))}constructor(e,s,i,n,r,a,o,h,c,d,u,f,p,g,m,b){let y=this._signal=this.#t.signal;this.#V=e,this.#J=s,this.#Z=i,this.#r=n,this.#l=r,this.#U=a,this.#W=h,this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:y}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:y}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:y}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:y}),o._on("setpreference",this.onSetPreference.bind(this),{signal:y}),o._on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),{signal:y}),window.addEventListener("pointerdown",()=>{this.#M=!0},{capture:!0,signal:y}),window.addEventListener("pointerup",()=>{this.#M=!1},{capture:!0,signal:y}),window.addEventListener("beforeunload",this.#nt.bind(this),{capture:!0,signal:y}),this.#ot(),this.#ft(),this.#et(),this.#n=h.annotationStorage,this.#C=h.filterFactory,this.#$=c,this.#x=d||null,this.#b=u,this.#A=f,this.#y=p,this.#z=g||null,this.viewParameters={realScale:Tt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=m||null,this._supportsPinchToZoom=b!==!1,r?.setSidebarUiManager(this)}destroy(){this.#H?.resolve(),this.#H=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let e of this.#a.values())e.destroy();this.#a.clear(),this.#s.clear(),this.#p.clear(),this.#N?.clear(),this.#e=null,this.#E.clear(),this.#h.destroy(),this.#r?.destroy(),this.#l?.destroy(),this.#U?.destroy(),this.#_?.hide(),this.#_=null,this.#B?.destroy(),this.#B=null,this.#i=null,this.#S&&(clearTimeout(this.#S),this.#S=null),this.#F&&(clearTimeout(this.#F),this.#F=null),this._editorUndoBar?.destroy(),this.#W=null}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#z}get useNewAltTextFlow(){return this.#A}get useNewAltTextWhenAddingImage(){return this.#y}get hcmFilter(){return L(this,"hcmFilter",this.#$?this.#C.addHCMFilter(this.#$.foreground,this.#$.background):"none")}get direction(){return L(this,"direction",getComputedStyle(this.#V).direction)}get _highlightColors(){return L(this,"_highlightColors",this.#x?new Map(this.#x.split(",").map(e=>(e=e.split("=").map(s=>s.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){let{_highlightColors:e}=this;if(!e)return L(this,"highlightColors",null);let s=new Map,i=!!this.#$;for(let[n,r]of e){let a=n.endsWith("_HCM");if(i&&a){s.set(n.replace("_HCM",""),r);continue}!i&&!a&&s.set(n,r)}return L(this,"highlightColors",s)}get highlightColorNames(){return L(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;let s=this.highlightColorNames.get(e);return this._highlightColors.get(s)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#d=e}setMainHighlightColorPicker(e){this.#B=e}editAltText(e,s=!1){this.#r?.editAltText(this,e,s)}hasCommentManager(){return!!this.#l}editComment(e,s,i,n){this.#l?.showDialog(this,e,s,i,n)}selectComment(e,s){this.#a.get(e)?.getEditorByUID(s)?.toggleComment(!0,!0)}updateComment(e){this.#l?.updateComment(e.getData())}updatePopupColor(e){this.#l?.updatePopupColor(e)}removeComment(e){this.#l?.removeComments([e.uid])}deleteComment(e,s){let i=()=>{e.comment=s},n=()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),e.comment=null};this.addCommands({cmd:n,undo:i,mustExec:!0})}toggleComment(e,s,i=void 0){this.#l?.toggleCommentPopup(e,s,i)}makeCommentColor(e,s){return e&&this.#l?.makeCommentColor(e,s)||null}getCommentDialogElement(){return this.#l?.dialogElement||null}async waitForEditorsRendered(e){if(this.#a.has(e-1))return;let{resolve:s,promise:i}=Promise.withResolvers(),n=r=>{r.pageNumber===e&&(this._eventBus._off("editorsrendered",n),s())};this._eventBus.on("editorsrendered",n),await i}getSignature(e){this.#U?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#U}switchToMode(e,s){this._eventBus.on("annotationeditormodechanged",s,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,s){this._eventBus.dispatch("setpreference",{source:this,name:e,value:s})}onSetPreference({name:e,value:s}){e==="enableNewAltTextWhenAddingImage"&&(this.#y=s)}onPageChanging({pageNumber:e}){this.#f=e-1}deletePage(e){for(let s of this.getEditors(e))s.remove();this.#a.delete(e),this.#f===e&&(this.#f=0)}focusMainContainer(){this.#V.focus()}findParent(e,s){for(let i of this.#a.values()){let{x:n,y:r,width:a,height:o}=i.div.getBoundingClientRect();if(e>=n&&e<=n+a&&s>=r&&s<=r+o)return i}return null}disableUserSelect(e=!1){this.#J.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#p.add(e)}removeShouldRescale(e){this.#p.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Tt.PDF_TO_CSS_UNITS;for(let s of this.#p)s.onScaleChanging();this.#d?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#Q({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#tt(e){let{currentLayer:s}=this;if(s.hasTextLayer(e))return s;for(let i of this.#a.values())if(i.hasTextLayer(e))return i;return null}highlightSelection(e="",s=!1){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o}=i,h=i.toString(),d=this.#Q(i).closest(".textLayer"),u=this.getSelectionBoxes(d);if(!u)return;i.empty();let f=this.#tt(d),p=this.#T===D.NONE,g=()=>{let m=f?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:u,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o,text:h});p&&this.showAllEditors("highlight",!0,!0),s&&m?.editComment()};if(p){this.switchToMode(D.HIGHLIGHT,g);return}g()}commentSelection(e=""){this.highlightSelection(e,!0)}#nt(e){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#rt(){let e=document.getSelection();if(!e||e.isCollapsed)return;let i=this.#Q(e).closest(".textLayer"),n=this.getSelectionBoxes(i);n&&(this.#_||=new Hs(this),this.#_.show(i,n,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(e){if(!this.#n)return null;let s=`${ie}${e}`,i=this.#n.getRawValue(s);return i&&this.#n.remove(s),i}addToAnnotationStorage(e){!e.isEmpty()&&this.#n&&!this.#n.has(e.id)&&this.#n.setValue(e.id,e)}a11yAlert(e,s=null){let i=this.#Z;i&&(i.setAttribute("data-l10n-id",e),s?i.setAttribute("data-l10n-args",JSON.stringify(s)):i.removeAttribute("data-l10n-args"))}#at(){let e=document.getSelection();if(!e||e.isCollapsed){this.#D&&(this.#_?.hide(),this.#D=null,this.#I({hasSelectedText:!1}));return}let{anchorNode:s}=e;if(s===this.#D)return;let n=this.#Q(e).closest(".textLayer");if(!n){this.#D&&(this.#_?.hide(),this.#D=null,this.#I({hasSelectedText:!1}));return}if(this.#_?.hide(),this.#D=s,this.#I({hasSelectedText:!0}),!(this.#T!==D.HIGHLIGHT&&this.#T!==D.NONE)&&(this.#T===D.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#w=this.isShiftKeyDown,!this.isShiftKeyDown)){let r=this.#T===D.HIGHLIGHT?this.#tt(n):null;if(r?.toggleDrawing(),this.#M){let a=new AbortController,o=this.combinedSignal(a),h=c=>{c.type==="pointerup"&&c.button!==0||(a.abort(),r?.toggleDrawing(!0),c.type==="pointerup"&&this.#K("main_toolbar"))};window.addEventListener("pointerup",h,{signal:o}),window.addEventListener("blur",h,{signal:o})}else r?.toggleDrawing(!0),this.#K("main_toolbar")}}#K(e=""){this.#T===D.HIGHLIGHT?this.highlightSelection(e):this.#b&&this.#rt()}#ot(){document.addEventListener("selectionchange",this.#at.bind(this),{signal:this._signal})}#lt(){if(this.#v)return;this.#v=new AbortController;let e=this.combinedSignal(this.#v);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#ht(){this.#v?.abort(),this.#v=null}blur(){if(this.isShiftKeyDown=!1,this.#w&&(this.#w=!1,this.#K("main_toolbar")),!this.hasSelection)return;let{activeElement:e}=document;for(let s of this.#E)if(s.div.contains(e)){this.#R=[s,e],s._focusEventsAllowed=!1;break}}focus(){if(!this.#R)return;let[e,s]=this.#R;this.#R=null,s.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),s.focus()}#et(){if(this.#L)return;this.#L=new AbortController;let e=this.combinedSignal(this.#L);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#ct(){this.#L?.abort(),this.#L=null}#dt(){if(this.#u)return;this.#u=new AbortController;let e=this.combinedSignal(this.#u);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#ut(){this.#u?.abort(),this.#u=null}#ft(){let e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#et(),this.setEditingState(!0)}removeEditListeners(){this.#ct(),this.setEditingState(!1)}dragOver(e){for(let{type:s}of e.dataTransfer.items)for(let i of this.#c)if(i.isHandlingMimeForPasting(s)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(let s of e.dataTransfer.items)for(let i of this.#c)if(i.isHandlingMimeForPasting(s.type)){i.paste(s,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let s=[];for(let i of this.#E){let n=i.serialize(!0);n&&s.push(n)}s.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(s))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();let{clipboardData:s}=e;for(let r of s.items)for(let a of this.#c)if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let i=s.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(r){R(`paste: "${r.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let n=this.currentLayer;try{let r=[];for(let h of i){let c=await n.deserialize(h);if(!c)return;r.push(c)}let a=()=>{for(let h of r)this.#st(h);this.#it(r)},o=()=>{for(let h of r)h.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){R(`paste: "${r.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),this.#T!==D.NONE&&!this.isEditorHandlingKeyboard&&l._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,this.#w&&(this.#w=!1,this.#K("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}#I(e){Object.entries(e).some(([i,n])=>this.#Y[i]!==n)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#Y,e)}),this.#T===D.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#G([[N.HIGHLIGHT_FREE,!0]]))}#G(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#lt(),this.#dt(),this.#I({isEditing:this.#T!==D.NONE,isEmpty:this.#q(),hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:this.#h.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ht(),this.#ut(),this.#I({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#c){this.#c=e;for(let s of this.#c)this.#G(s.defaultPropertiesToUpdate)}}getId(){return this.#k.id}get currentLayer(){return this.#a.get(this.#f)}getLayer(e){return this.#a.get(e)}get currentPageIndex(){return this.#f}addLayer(e){this.#a.set(e.pageIndex,e),this.#P?e.enable():e.disable()}removeLayer(e){this.#a.delete(e.pageIndex)}async updateMode(e,s=null,i=!1,n=!1,r=!1,a=!1){if(this.#T!==e&&!(this.#H&&(await this.#H.promise,!this.#H))){if(this.#H=Promise.withResolvers(),this.#d?.commitOrRemove(),this.#T===D.POPUP&&this.#l?.hideSidebar(),this.#l?.destroyPopup(),this.#T=e,e===D.NONE){this.setEditingState(!1),this.#gt();for(let o of this.#s.values())o.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#H.resolve();return}for(let o of this.#s.values())o.addStandaloneCommentButton();e===D.SIGNATURE&&await this.#U?.loadSignatures(),i&&nt.clearPointerType(),this.setEditingState(!0),await this.#pt(),this.unselectAll();for(let o of this.#a.values())o.updateMode(e);if(e===D.POPUP){this.#i||=await this.#W.getAnnotationsByType(new Set(this.#c.map(c=>c._editorType)));let o=new Set,h=[];for(let c of this.#s.values()){let{annotationElementId:d,hasComment:u,deleted:f}=c;d&&o.add(d),u&&!f&&h.push(c.getData())}for(let c of this.#i){let{id:d,popupRef:u,contentsObj:f}=c;u&&f?.str&&!o.has(d)&&!this.#m.has(d)&&h.push(c)}this.#l?.showSidebar(h)}if(!s){n&&this.addNewEditorFromKeyboard(),this.#H.resolve();return}for(let o of this.#s.values())o.uid===s?(this.setSelected(o),a?o.editComment():r?o.enterInEditMode():o.focus()):o.unselect();this.#H.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==this.#T&&this._eventBus.dispatch("switchannotationeditormode",lt({source:this},e))}updateParams(e,s){if(this.#c){switch(e){case N.CREATE:this.currentLayer.addNewEditor(s);return;case N.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#X||=new Map).set(e,s),this.showAllEditors("highlight",s);break}if(this.hasSelection)for(let i of this.#E)i.updateParams(e,s);else for(let i of this.#c)i.updateDefaultParams(e,s)}}showAllEditors(e,s,i=!1){for(let r of this.#s.values())r.editorType===e&&r.show(s);(this.#X?.get(N.HIGHLIGHT_SHOW_ALL)??!0)!==s&&this.#G([[N.HIGHLIGHT_SHOW_ALL,s]])}enableWaiting(e=!1){if(this.#O!==e){this.#O=e;for(let s of this.#a.values())e?s.disableClick():s.enableClick(),s.div.classList.toggle("waiting",e)}}async#pt(){if(!this.#P){this.#P=!0;let e=[];for(let s of this.#a.values())e.push(s.enable());await Promise.all(e);for(let s of this.#s.values())s.enable()}}#gt(){if(this.unselectAll(),this.#P){this.#P=!1;for(let e of this.#a.values())e.disable();for(let e of this.#s.values())e.disable()}}*getEditors(e){for(let s of this.#s.values())s.pageIndex===e&&(yield s)}getEditor(e){return this.#s.get(e)}addEditor(e){this.#s.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#S&&clearTimeout(this.#S),this.#S=setTimeout(()=>{this.focusMainContainer(),this.#S=null},0)),this.#s.delete(e.id),e.annotationElementId&&this.#N?.delete(e.annotationElementId),this.unselect(e),(!e.annotationElementId||!this.#m.has(e.annotationElementId))&&this.#n?.remove(e.id)}addDeletedAnnotationElement(e){this.#m.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#m.has(e)}removeDeletedAnnotationElement(e){this.#m.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#st(e){let s=this.#a.get(e.pageIndex);s?s.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#e!==e&&(this.#e=e,e&&this.#G(e.propertiesToUpdate))}get#mt(){let e=null;for(e of this.#E);return e}updateUI(e){this.#mt===e&&this.#G(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#G(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#E.has(e)){this.#E.delete(e),e.unselect(),this.#I({hasSelectedEditor:this.hasSelection});return}this.#E.add(e),e.select(),this.#G(e.propertiesToUpdate),this.#I({hasSelectedEditor:!0})}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid}),this.#d?.commitOrRemove();for(let s of this.#E)s!==e&&s.unselect();this.#E.clear(),this.#E.add(e),e.select(),this.#G(e.propertiesToUpdate),this.#I({hasSelectedEditor:!0})}isSelected(e){return this.#E.has(e)}get firstSelectedEditor(){return this.#E.values().next().value}unselect(e){e.unselect(),this.#E.delete(e),this.#I({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#E.size!==0}get isEnterHandled(){return this.#E.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#h.undo(),this.#I({hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#q()}),this._editorUndoBar?.hide()}redo(){this.#h.redo(),this.#I({hasSomethingToUndo:!0,hasSomethingToRedo:this.#h.hasSomethingToRedo(),isEmpty:this.#q()})}addCommands(e){this.#h.add(e),this.#I({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#q()})}cleanUndoStack(e){this.#h.cleanType(e)}#q(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(let e of this.#s.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();let e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;let s=e?[e]:[...this.#E],i=()=>{this._editorUndoBar?.show(n,s.length===1?s[0].editorType:s.length);for(let r of s)r.remove()},n=()=>{for(let r of s)this.#st(r)};this.addCommands({cmd:i,undo:n,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#it(e){for(let s of this.#E)s.unselect();this.#E.clear();for(let s of e)s.isEmpty()||(this.#E.add(s),s.select());this.#I({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#E)e.commit();this.#it(this.#s.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#T!==D.NONE))&&!this.#d?.commitOrRemove()&&this.hasSelection){for(let e of this.#E)e.unselect();this.#E.clear(),this.#I({hasSelectedEditor:!1})}}translateSelectedEditors(e,s,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#j[0]+=e,this.#j[1]+=s;let[n,r]=this.#j,a=[...this.#E],o=1e3;this.#F&&clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#F=null,this.#j[0]=this.#j[1]=0,this.addCommands({cmd:()=>{for(let h of a)this.#s.has(h.id)&&(h.translateInPage(n,r),h.translationDone())},undo:()=>{for(let h of a)this.#s.has(h.id)&&(h.translateInPage(-n,-r),h.translationDone())},mustExec:!1})},o);for(let h of a)h.translateInPage(e,s),h.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#g=new Map;for(let e of this.#E)this.#g.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#g)return!1;this.disableUserSelect(!1);let e=this.#g;this.#g=null;let s=!1;for(let[{x:n,y:r,pageIndex:a},o]of e)o.newX=n,o.newY=r,o.newPageIndex=a,s||=n!==o.savedX||r!==o.savedY||a!==o.savedPageIndex;if(!s)return!1;let i=(n,r,a,o)=>{if(this.#s.has(n.id)){let h=this.#a.get(o);h?n._setParentAndPosition(h,r,a):(n.pageIndex=o,n.x=r,n.y=a)}};return this.addCommands({cmd:()=>{for(let[n,{newX:r,newY:a,newPageIndex:o}]of e)i(n,r,a,o)},undo:()=>{for(let[n,{savedX:r,savedY:a,savedPageIndex:o}]of e)i(n,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(e,s){if(this.#g)for(let i of this.#g.keys())i.drag(e,s)}rebuild(e){if(e.parent===null){let s=this.getLayer(e.pageIndex);s?(s.changeParent(e),s.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#E.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#e===e}getActive(){return this.#e}getMode(){return this.#T}isEditingMode(){return this.#T!==D.NONE}get imageManager(){return L(this,"imageManager",new js)}getSelectionBoxes(e){if(!e)return null;let s=document.getSelection();for(let c=0,d=s.rangeCount;c<d;c++)if(!e.contains(s.getRangeAt(c).commonAncestorContainer))return null;let{x:i,y:n,width:r,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute("data-main-rotation")){case"90":o=(c,d,u,f)=>({x:(d-n)/a,y:1-(c+u-i)/r,width:f/a,height:u/r});break;case"180":o=(c,d,u,f)=>({x:1-(c+u-i)/r,y:1-(d+f-n)/a,width:u/r,height:f/a});break;case"270":o=(c,d,u,f)=>({x:1-(d+f-n)/a,y:(c-i)/r,width:f/a,height:u/r});break;default:o=(c,d,u,f)=>({x:(c-i)/r,y:(d-n)/a,width:u/r,height:f/a});break}let h=[];for(let c=0,d=s.rangeCount;c<d;c++){let u=s.getRangeAt(c);if(!u.collapsed)for(let{x:f,y:p,width:g,height:m}of u.getClientRects())g===0||m===0||h.push(o(f,p,g,m))}return h.length===0?null:h}addChangedExistingAnnotation({annotationElementId:e,id:s}){(this.#o||=new Map).set(e,s)}removeChangedExistingAnnotation({annotationElementId:e}){this.#o?.delete(e)}renderAnnotationElement(e){let s=this.#o?.get(e.data.id);if(!s)return;let i=this.#n.getRawValue(s);i&&(this.#T===D.NONE&&!i.hasBeenModified||i.renderAnnotationElement(e))}setMissingCanvas(e,s,i){let n=this.#N?.get(e);n&&(n.setCanvas(s,i),this.#N.delete(e))}addMissingCanvas(e,s){(this.#N||=new Map).set(e,s)}}return l})(),An=(()=>{class l{#t=null;#e=!1;#i=null;#s=null;#a=null;#r=null;#n=!1;#o=null;#h=null;#l=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(e){this.#h=e,this.#d=e._uiManager.useNewAltTextFlow,l.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(e){l._l10n??=e}async render(){let e=this.#i=document.createElement("button");e.className="altText",e.tabIndex="0";let s=this.#s=document.createElement("span");e.append(s),this.#d?(e.classList.add("new"),e.setAttribute("data-l10n-id",l.#f.missing),s.setAttribute("data-l10n-id",l.#f["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),s.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#h._uiManager._signal;e.addEventListener("contextmenu",ft,{signal:i}),e.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:i});let n=r=>{r.preventDefault(),this.#h._uiManager.editAltText(this.#h),this.#d&&this.#h._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#m}})};return e.addEventListener("click",n,{capture:!0,signal:i}),e.addEventListener("keydown",r=>{r.target===e&&r.key==="Enter"&&(this.#n=!0,n(r))},{signal:i}),await this.#g(),e}get#m(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#i&&(this.#i.focus({focusVisible:this.#n}),this.#n=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(e){this.#t===null&&(this.#l=e,this.#u=await l._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),this.#g())}toggleAltTextBadge(e=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){let s=this.#o=document.createElement("div");s.className="noAltTextBadge",this.#h.div.append(s)}this.#o.classList.toggle("hidden",!e)}serialize(e){let s=this.#t;return!e&&this.#l===s&&(s=this.#u),{altText:s,decorative:this.#e,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:e,decorative:s,guessedText:i,textWithDisclaimer:n,cancel:r=!1}){i&&(this.#l=i,this.#u=n),!(this.#t===e&&this.#e===s)&&(r||(this.#t=e,this.#e=s),this.#g())}toggle(e=!1){this.#i&&(!e&&this.#r&&(clearTimeout(this.#r),this.#r=null),this.#i.disabled=!e)}shown(){this.#h._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#m}})}destroy(){this.#i?.remove(),this.#i=null,this.#s=null,this.#a=null,this.#o?.remove(),this.#o=null}async#g(){let e=this.#i;if(!e)return;if(this.#d){if(e.classList.toggle("done",!!this.#t),e.setAttribute("data-l10n-id",l.#f[this.#m]),this.#s?.setAttribute("data-l10n-id",l.#f[`${this.#m}-label`]),!this.#t){this.#a?.remove();return}}else{if(!this.#t&&!this.#e){e.classList.remove("done"),this.#a?.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let s=this.#a;if(!s){this.#a=s=document.createElement("span"),s.className="tooltip",s.setAttribute("role","tooltip"),s.id=`alt-text-tooltip-${this.#h.id}`;let n=100,r=this.#h._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#r),this.#r=null},{once:!0}),e.addEventListener("mouseenter",()=>{this.#r=setTimeout(()=>{this.#r=null,this.#a.classList.add("show"),this.#h._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:r}),e.addEventListener("mouseleave",()=>{this.#r&&(clearTimeout(this.#r),this.#r=null),this.#a?.classList.remove("show")},{signal:r})}this.#e?s.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(s.removeAttribute("data-l10n-id"),s.textContent=this.#t),s.parentNode||e.append(s),this.#h.getElementForAltText()?.setAttribute("aria-describedby",s.id)}}return l})(),Ut=class{#t=null;#e=null;#i=!1;#s=null;#a=null;#r=null;#n=null;#o=null;#h=!1;#l=null;constructor(t){this.#s=t}renderForToolbar(){let t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){let t=this.#t=document.createElement("button");t.className="annotationCommentButton";let e=this.#s.commentButtonPosition;if(e){let{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#s._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let i=this.#s.commentButtonColor;i&&(s.backgroundColor=i)}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;let t=this.#s.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#s._uiManager.updatePopupColor(this.#s)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#s.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#l)return this.#l;if(!this.#t)return null;let{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#s.parent.boundingClientRect;return[(t-i)/r,(e+s-n)/a]}set commentPopupPositionInLayer(t){this.#l=t}hasDefaultPopupPosition(){return this.#l===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#u(t,e){if(!this.#s._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControl
2sElements=[this.#s._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));let s=this.#s._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",ft,{signal:s}),e&&(t.addEventListener("focusin",n=>{this.#s._focusEventsAllowed=!1,Y(n)},{capture:!0,signal:s}),t.addEventListener("focusout",n=>{this.#s._focusEventsAllowed=!0,Y(n)},{capture:!0,signal:s})),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});let i=n=>{n.preventDefault(),t===this.#e?this.edit():this.#s.toggleComment(!0)};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}),t.addEventListener("pointerenter",()=>{this.#s.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#s.toggleComment(!1,!1)},{signal:s}),t}edit(t){let e=this.commentPopupPositionInLayer,s,i;if(e)[s,i]=e;else{[s,i]=this.#s.commentButtonPosition;let{width:c,height:d,x:u,y:f}=this.#s;s=u+s*c,i=f+i*d}let n=this.#s.parent.boundingClientRect,{x:r,y:a,width:o,height:h}=n;this.#s._uiManager.editComment(this.#s,r+s*o,a+i*h,At(lt({},t),{parentDimensions:n}))}finish(){this.#e&&(this.#e.focus({focusVisible:this.#i}),this.#i=!1)}isDeleted(){return this.#h||this.#n===""}isEmpty(){return this.#n===null}hasBeenEdited(){return this.isDeleted()||this.#n!==this.#a}serialize(){return this.data}get data(){return{text:this.#n,richText:this.#r,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#n&&(this.#r=null),t===null){this.#n="",this.#h=!0;return}this.#n=t,this.#o=new Date,this.#h=!1}restoreData({text:t,richText:e,date:s}){this.#n=t,this.#r=e,this.#o=s,this.#h=!1}setInitialText(t,e=null){this.#a=t,this.data=t,this.#o=null,this.#r=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#n="",this.#r=null,this.#o=null,this.#s=null,this.#i=!1,this.#h=!1}},Be=class l{#t;#e=!1;#i=null;#s;#a;#r;#n;#o=null;#h;#l=null;#u;#d=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#t=t,this.#i=s,this.#s=e,this.#a=i,this.#r=n,this.#n=r,this.#u=new AbortController,this.#h=AbortSignal.any([a,this.#u.signal]),t.addEventListener("touchstart",this.#f.bind(this),{passive:!1,signal:this.#h})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/vt.pixelRatio}#f(t){if(this.#s?.())return;if(t.touches.length===1){if(this.#o)return;let i=this.#o=new AbortController,n=AbortSignal.any([this.#h,i.signal]),r=this.#t,a={capture:!0,signal:n,passive:!1},o=h=>{h.pointerType==="touch"&&(this.#o?.abort(),this.#o=null)};r.addEventListener("pointerdown",h=>{h.pointerType==="touch"&&(Y(h),o(h))},a),r.addEventListener("pointerup",o,a),r.addEventListener("pointercancel",o,a);return}if(!this.#d){this.#d=new AbortController;let i=AbortSignal.any([this.#h,this.#d.signal]),n=this.#t,r={signal:i,capture:!1,passive:!1};n.addEventListener("touchmove",this.#m.bind(this),r);let a=this.#g.bind(this);n.addEventListener("touchend",a,r),n.addEventListener("touchcancel",a,r),r.capture=!0,n.addEventListener("pointerdown",Y,r),n.addEventListener("pointermove",Y,r),n.addEventListener("pointercancel",Y,r),n.addEventListener("pointerup",Y,r),this.#a?.()}if(Y(t),t.touches.length!==2||this.#i?.()){this.#l=null;return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),this.#l={touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#m(t){if(!this.#l||t.touches.length!==2)return;Y(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);let{screenX:i,screenY:n}=e,{screenX:r,screenY:a}=s,o=this.#l,{touch0X:h,touch0Y:c,touch1X:d,touch1Y:u}=o,f=d-h,p=u-c,g=r-i,m=a-n,b=Math.hypot(g,m)||1,y=Math.hypot(f,p)||1;if(!this.#e&&Math.abs(y-b)<=l.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=i,o.touch0Y=n,o.touch1X=r,o.touch1Y=a,!this.#e){this.#e=!0;return}let A=[(i+r)/2,(n+a)/2];this.#r?.(A,y,b)}#g(t){t.touches.length>=2||(this.#d&&(this.#d.abort(),this.#d=null,this.#n?.()),this.#l&&(Y(t),this.#l=null,this.#e=!1))}destroy(){this.#u?.abort(),this.#u=null,this.#o?.abort(),this.#o=null}},$=class l{#t=null;#e=null;#i=null;#s=null;#a=null;#r=!1;#n=null;#o="";#h=null;#l=null;#u=null;#d=null;#f=null;#m="";#g=!1;#c=null;#p=!1;#b=!1;#A=!1;#y=null;#C=0;#S=0;#v=null;#x=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#w=!1;#_=l._zIndex++;static _borderLineWidth=-1;static _colorManager=new zs;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=l.prototype._resizeWithKeyboard,e=ce.TRANSLATE_SMALL,s=ce.TRANSLATE_BIG;return L(this,"_resizerKeyboardManager",new kt([[["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"],l.prototype._stopResizingWithKeyboard]]))}constructor(t){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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;let{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];let[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return L(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new Vs({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(l._l10n??=t,l._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),l._borderLineWidth!==-1)return;let s=getComputedStyle(document.documentElement);l._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){B("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#w}set _isDraggable(t){this.#w=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[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}
vendor: 25,877 bytes, line 2
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#_}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#F(),this.#d?.remove(),this.#d=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#g?this.#g=!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.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){let[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){let[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}#k([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#k(this.parentDimensions,t,e)}translateInPage(t,e){this.#c||=[this.x,this.y,this.width,this.height],this.#k(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#c||=[this.x,this.y,this.width,this.height];let{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this,[o,h]=this.getBaseTranslation();r+=o,a+=h;let{style:c}=s;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:s}=l,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){let{div:{style:e},pageDimensions:[s,i]}=this,{x:n,y:r,width:a,height:o}=this;if(a*=s,o*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=st(n,0,s-a),r=st(r,0,i-o);break;case 90:n=st(n,0,s-o),r=st(r,a,i);break;case 180:n=st(n,a,s),r=st(r,o,i);break;case 270:n=st(n,o,s),r=st(r,0,i-a);break}this.x=n/=s,this.y=r/=i;let[h,c]=this.getBaseTranslation();n+=h,r+=c,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).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 l.#P(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return l.#P(t,e,360-this.parentRotation)}#M(t){switch(t){case 90:{let[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{let[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(){let{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){let{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#O(){if(this.#h)return;this.#h=document.createElement("div"),this.#h.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let s of t){let i=document.createElement("div");this.#h.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#L.bind(this,s),{signal:e}),i.addEventListener("contextmenu",ft,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#h)}#L(t,e){e.preventDefault();let{isMac:s}=K.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#i?.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,this.#l=[e.screenX,e.screenY];let n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#N.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Y,{passive:!1,signal:r}),window.addEventListener("contextmenu",ft,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let h=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#B()};window.addEventListener("pointerup",h,{signal:r}),window.addEventListener("blur",h,{signal:r})}#R(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#B(){if(!this.#u)return;let{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;let n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:this.#R.bind(this,n,r,a,o),undo:this.#R.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#N(t,e){let[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,h=l.MIN_SIZE/s,c=l.MIN_SIZE/i,d=this.#M(this.rotation),u=(k,I)=>[d[0]*k+d[2]*I,d[1]*k+d[3]*I],f=this.#M(360-this.rotation),p=(k,I)=>[f[0]*k+f[2]*I,f[1]*k+f[3]*I],g,m,b=!1,y=!1;switch(t){case"topLeft":b=!0,g=(k,I)=>[0,0],m=(k,I)=>[k,I];break;case"topMiddle":g=(k,I)=>[k/2,0],m=(k,I)=>[k/2,I];break;case"topRight":b=!0,g=(k,I)=>[k,0],m=(k,I)=>[0,I];break;case"middleRight":y=!0,g=(k,I)=>[k,I/2],m=(k,I)=>[0,I/2];break;case"bottomRight":b=!0,g=(k,I)=>[k,I],m=(k,I)=>[0,0];break;case"bottomMiddle":g=(k,I)=>[k/2,I],m=(k,I)=>[k/2,0];break;case"bottomLeft":b=!0,g=(k,I)=>[0,I],m=(k,I)=>[k,0];break;case"middleLeft":y=!0,g=(k,I)=>[0,I/2],m=(k,I)=>[k,I/2];break}let A=g(a,o),v=m(a,o),w=u(...v),E=l._round(n+w[0]),S=l._round(r+w[1]),_=1,C=1,M,x;if(e.fromKeyboard)({deltaX:M,deltaY:x}=e);else{let{screenX:k,screenY:I}=e,[j,X]=this.#l;[M,x]=this.screenToPageTranslation(k-j,I-X),this.#l[0]=k,this.#l[1]=I}if([M,x]=p(M/s,x/i),b){let k=Math.hypot(a,o);_=C=Math.max(Math.min(Math.hypot(v[0]-A[0]-M,v[1]-A[1]-x)/k,1/a,1/o),h/a,c/o)}else y?_=st(Math.abs(v[0]-A[0]-M),h,1)/a:C=st(Math.abs(v[1]-A[1]-x),c,1)/o;let U=l._round(a*_),H=l._round(o*C);w=u(...m(U,H));let F=E-w[0],q=S-w[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=U,this.height=H,this.x=F,this.y=q,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#b)return this._editToolbar;this._editToolbar=new Us(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#i?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#i||(An.initialize(l._l10n),this.#i=new An(this),this.#t&&(this.#i.data=this.#t,this.#t=null)),this.#i}get altTextData(){return this.#i?.data}set altTextData(t){this.#i&&(this.#i.data=t)}get guessedAltText(){return this.#i?.guessedText}async setGuessedAltText(t){await this.#i?.setGuessedText(t)}serializeAltText(t){return this.#i?.serialize(t)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}focusCommentButton(){this.#s?.focusButton()}addCommentButton(){return this.canAddComment?this.#s||=new Ut(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#a){this._uiManager.isEditingMode()&&this.#a.classList.remove("hidden");return}this.hasComment&&(this.#a=this.#s.renderForStandalone(),this.div.append(this.#a))}}removeStandaloneCommentButton(){this.#s.removeStandaloneCommentButton(),this.#a=null}hideStandaloneCommentButton(){this.#a?.classList.add("hidden")}get comment(){if(!this.#s)return null;let{data:{richText:t,text:e,date:s,deleted:i}}=this.#s;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#s||=new Ut(this),typeof t=="object"&&t!==null?this.#s.restoreData(t):this.#s.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:s}){if(!e||(this.#s||=new Ut(this),this.#s.setInitialText(t,s),!this.annotationElementId))return;let i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#s?.hasBeenEdited()}get hasDeletedComment(){return this.#s?.isDeleted()}get hasComment(){return!!this.#s&&!this.#s.isEmpty()&&!this.#s.isDeleted()}async editComment(t){this.#s||=new Ut(this),this.#s.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#s.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,i]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=i-100,h=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,h,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#s.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#r?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#$();let[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);let[i,n]=this.getInitialTranslation();return this.translate(i,n),Vn(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#x||=new Be({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#z.bind(this),onPinching:this.#T.bind(this),onPinchEnd:this.#E.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#z(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#T(t,e,s){let n=.7*(s/e)+1-.7;if(n===1)return;let r=this.#M(this.rotation),a=(E,S)=>[r[0]*E+r[2]*S,r[1]*E+r[3]*S],[o,h]=this.parentDimensions,c=this.x,d=this.y,u=this.width,f=this.height,p=l.MIN_SIZE/o,g=l.MIN_SIZE/h;n=Math.max(Math.min(n,1/u,1/f),p/u,g/f);let m=l._round(u*n),b=l._round(f*n);if(m===u&&b===f)return;this.#c||=[c,d,u,f];let y=a(u/2,f/2),A=l._round(c+y[0]),v=l._round(d+y[1]),w=a(m/2,b/2);this.x=A-w[0],this.y=v-w[1],this.width=m,this.height=b,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#E(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#B()}pointerdown(t){let{isMac:e}=K.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#g=!0,this._isDraggable){this.#U(t);return}this.#D(t)}#D(t){let{isMac:e}=K.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#U(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1,i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=h=>{i.abort(),this.#n=null,this.#g=!1,this._uiManager.endDragSession()||this.#D(h),s&&this._onStopDragging()};e&&(this.#C=t.clientX,this.#S=t.clientY,this.#n=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:c,clientY:d,pointerId:u}=h;if(u!==this.#n){Y(h);return}let[f,p]=this.screenToPageTranslation(c-this.#C,d-this.#S);this.#C=c,this.#S=d,this._uiManager.dragSelectedEditors(f,p)},r),window.addEventListener("touchmove",Y,r),window.addEventListener("pointerdown",h=>{h.pointerType===this.#o&&(this.#x||h.isPrimary)&&a(h),Y(h)},r));let o=h=>{if(!this.#n||this.#n===h.pointerId){a(h);return}Y(h)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){let i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,h=t/i,c=e/i,d=this.x*n,u=this.y*r,f=this.width*n,p=this.height*r;switch(s){case 0:return[d+h+a,r-u-c-p+o,d+h+f+a,r-u-c+o];case 90:return[d+c+a,r-u+h+o,d+c+p+a,r-u+h+f+o];case 180:return[d-h-f+a,r-u+c+o,d-h+a,r-u+c+p+o];case 270:return[d-c-p+a,r-u-h-f+o,d-c+a,r-u-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[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")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&l._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#s?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:s,opacity:i,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:h,modificationDate:c}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:h,modificationDate:s||c,popupRef:!n,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#b=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#b=!1,!0):!1}isInEditMode(){return this.#b}shouldGetKeyboardEvents(){return this.#A}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}#$(){if(this.#f||!this.div)return;this.#f=new AbortController;let t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#$()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,s){let i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;let[n,r]=i.pageDimensions,[a,o,h,c]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=h/n,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#y&&(clearTimeout(this.#y),this.#y=null),this.#F(),this.removeEditToolbar(),this.#v){for(let t of this.#v.values())clearTimeout(t);this.#v=null}this.parent=null,this.#x?.destroy(),this.#x=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#O(),this.#h.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[s,i,n,r]=this.getPDFRect();return[l._round(s+(n-s)*t),l._round(i+(r-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#s.commentPopupPositionInLayer}set commentPopupPosition(t){this.#s.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#s.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#s.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#s?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#h.children;if(!this.#e){this.#e=Array.from(e);let r=this.#X.bind(this),a=this.#W.bind(this),o=this._uiManager._signal;for(let h of this.#e){let c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",r,{signal:o}),h.addEventListener("blur",a,{signal:o}),h.addEventListener("focus",this.#Y.bind(this,c),{signal:o}),h.setAttribute("data-l10n-id",l._l10nResizer[c])}}let s=this.#e[0],i=0;for(let r of e){if(r===s)break;i++}let 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.#h.append(this.#h.firstElementChild);else if(n>i)for(let a=0;a<n-i;a++)this.#h.firstElementChild.before(this.#h.lastElementChild);let r=0;for(let a of e){let h=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",l._l10nResizer[h])}}this.#j(0),this.#A=!0,this.#h.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#X(t){l._resizerKeyboardManager.exec(this,t)}#W(t){this.#A&&t.relatedTarget?.parentNode!==this.#h&&this.#F()}#Y(t){this.#m=this.#A?t:""}#j(t){if(this.#e)for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#A&&this.#N(this.#m,{deltaX:t,deltaY:e,fromKeyboard:!0})}#F(){this.#A=!1,this.#j(-1),this.#B()}_stopResizingWithKeyboard(){this.#F(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#h?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}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))}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.#v||=new Map;let{action:s}=t,i=this.#v.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#v.delete(s),this.#v.size===0&&(this.#v=null)},l._telemetryTimeout),this.#v.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.#r=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#r=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;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"){let s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}},Vs=class extends ${constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},wn=3285377520,dt=4294901760,bt=65535,Ue=class{constructor(t){this.h1=t?t&4294967295:wn,this.h2=t?t&4294967295:wn}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,m=t.length;g<m;g++){let b=t.charCodeAt(g);b<=255?e[s++]=b:(e[s++]=b>>>8,e[s++]=b&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.");let i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i),a=0,o=0,h=this.h1,c=this.h2,d=3432918353,u=461845907,f=d&bt,p=u&bt;for(let g=0;g<i;g++)g&1?(a=r[g],a=a*d&dt|a*f&bt,a=a<<15|a>>>17,a=a*u&dt|a*p&bt,h^=a,h=h<<13|h>>>19,h=h*5+3864292196):(o=r[g],o=o*d&dt|o*f&bt,o=o<<15|o>>>17,o=o*u&dt|o*p&bt,c^=o,c=c<<13|c>>>19,c=c*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&dt|a*f&bt,a=a<<15|a>>>17,a=a*u&dt|a*p&bt,i&1?h^=a:c^=a}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&dt|t*36045&bt,e=e*4283543511&dt|((e<<16|t>>>16)*2950163797&dt)>>>16,t^=e>>>1,t=t*444984403&dt|t*60499&bt,e=e*3301882366&dt|((e<<16|t>>>16)*3120437893&dt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}},de=Object.freeze({map:null,hash:"",transfer:void 0}),ue=class{#t=!1;#e=null;#i=null;#s=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){let s=this.#s.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#s.get(t)}remove(t){let e=this.#s.get(t);if(e!==void 0&&(e instanceof $&&this.#i.delete(e.annotationElementId),this.#s.delete(t),this.#s.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(let s of this.#s.values())if(s instanceof $)return;this.onAnnotationEditor(null)}}setValue(t,e){let s=this.#s.get(t),i=!1;if(s!==void 0)for(let[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#s.set(t,e);i&&this.#a(),e instanceof $&&((this.#i||=new Map).set(e.annotationElementId,e),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#s.has(t)}get size(){return this.#s.size}#a(){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 He(this)}get serializable(){if(this.#s.size===0)return de;let t=new Map,e=new Ue,s=[],i=Object.create(null),n=!1;for(let[r,a]of this.#s){let o=a instanceof $?a.serialize(!1,i):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(let r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:de}get editorStats(){let t=null,e=new Map,s=0,i=0;for(let n of this.#s.values()){if(!(n instanceof $)){n.popup&&(n.popup.deleted?i+=1:s+=1);continue}n.isCommentDeleted?i+=1:n.hasEditedComment&&(s+=1);let r=n.telemetryFinalData;if(!r)continue;let{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(n).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[h,c]of Object.entries(r)){if(h==="type")continue;let d=o.getOrInsertComputed(h,cn);d.set(c,(d.get(c)??0)+1)}}if((i>0||s>0)&&(t||=Object.create(null),t.comments={deleted:i,edited:s}),!t)return null;for(let[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){let s=this.#i?.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return this.#i?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;let t=[];
2if(this.#i)for(let e of this.#i.values())e.serialize()&&t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#s.entries()}},He=class extends ue{#t=de;constructor(t){super();let{serializable:e}=t;if(e===de)return;let{map:s,hash:i,transfer:n}=e,r=structuredClone(s,n?{transfer:n}:null);this.#t={map:r,hash:i,transfer:[]}}get print(){B("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return L(this,"modifiedIds",{ids:new Set,hash:""})}},Ws=class{#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));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let 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,disableFontFace:e,_inspectFont:s}){if(!(!t||this.#t.has(t.loadedName))){if(O(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:n,style:r}=t,a=new FontFace(i,n,r);this.addNativeFontFace(a);try{await a.load(),this.#t.add(i),s?.(t)}catch{R(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}B("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){let s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw R(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{let i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return L(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return L(this,"isSyncFontLoadingSupported",rt||K.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(O(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){let n=s.shift();setTimeout(n.callback,0)}}let{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return L(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(v,w){return v.charCodeAt(w)<<24|v.charCodeAt(w+1)<<16|v.charCodeAt(w+2)<<8|v.charCodeAt(w+3)&255}function i(v,w,E,S){let _=v.substring(0,w),C=v.substring(w+E);return _+S+C}let n,r,a=this._document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d"),h=0;function c(v,w){if(++h>30){R("Load test font never loaded."),w();return}if(o.font="30px "+v,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0){w();return}setTimeout(c.bind(null,v,w))}let d=`lt${Date.now()}${this.loadTestFontId++}`,u=this._loadTestFont;u=i(u,976,d.length,d);let p=16,g=1482184792,m=s(u,p);for(n=0,r=d.length-3;n<r;n+=4)m=m-g+s(d,n)|0;n<d.length&&(m=m-g+s(d+"XXX",n)|0),u=i(u,p,4,hr(m));let b=`url(data:font/opentype;base64,${btoa(u)});`,y=`@font-face {font-family:"${d}";src:${b}}`;this.insertRule(y);let A=this._document.createElement("div");A.style.visibility="hidden",A.style.width=A.style.height="10px",A.style.position="absolute",A.style.top=A.style.left="0px";for(let v of[t.loadedName,d]){let w=this._document.createElement("span");w.textContent="Hi",w.style.fontFamily=v,A.append(w)}this._document.body.append(A),c(d,()=>{A.remove(),e.complete()})}},Xs=class{#t;constructor(t,e=null,s,i){this.compiledGlyphs=Object.create(null),this.#t=t,this._inspectFont=e,s&&Object.assign(this,s),i&&(this.charProcOperatorList=i)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let 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;let t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e,i;try{i=t.get(s)}catch(r){R(`getPathGenerator - ignoring character: "${r}".`)}let n=zn(i?.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace??!1}set disableFontFace(t){L(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#t.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}
2get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}set bbox(t){L(this,"bbox",t)}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}},vn=(()=>{class l{#t;#e;#i;static strings=["fontFamily","fontWeight","italicAngle"];static write(e){let s=new TextEncoder,i={},n=0;for(let c of l.strings){let d=s.encode(e[c]);i[c]=d,n+=4+d.length}let r=new ArrayBuffer(n),a=new Uint8Array(r),o=new DataView(r),h=0;for(let c of l.strings){let d=i[c],u=d.length;o.setUint32(h,u),a.set(d,h+4),h+=4+u}return O(h===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}constructor(e){this.#t=e,this.#e=new DataView(this.#t),this.#i=new TextDecoder}#s(e){O(e<l.strings.length,"Invalid string index");let s=0;for(let n=0;n<e;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return this.#i.decode(new Uint8Array(this.#t,s+4,i))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}}return l})(),En=(()=>{class l{#t;#e;#i;static strings=["css","loadedName","baseFontName","src"];static write(e){let s=new TextEncoder,i={},n=0;for(let f of l.strings){let p=s.encode(e[f]);i[f]=p,n+=4+p.length}n+=4;let r,a,o=1+n;e.style&&(r=s.encode(e.style.style),a=s.encode(e.style.weight),o+=4+r.length+4+a.length);let h=new ArrayBuffer(o),c=new Uint8Array(h),d=new DataView(h),u=0;d.setUint8(u++,e.guessFallback?1:0),d.setUint32(u,0),u+=4,n=0;for(let f of l.strings){let p=i[f],g=p.length;n+=4+g,d.setUint32(u,g),c.set(p,u+4),u+=4+g}return d.setUint32(u-n-4,n),e.style&&(d.setUint32(u,r.length),c.set(r,u+4),u+=4+r.length,d.setUint32(u,a.length),c.set(a,u+4),u+=4+a.length),O(u<=h.byteLength,"SubstitionInfo.write: Buffer overflow"),h.transferToFixedLength(u)}constructor(e){this.#t=e,this.#e=new DataView(this.#t),this.#i=new TextDecoder}get guessFallback(){return this.#e.getUint8(0)!==0}#s(e){O(e<l.strings.length,"Invalid string index");let s=5;for(let n=0;n<e;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return this.#i.decode(new Uint8Array(this.#t,s+4,i))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){let e=1;e+=4+this.#e.getUint32(e);let s=this.#e.getUint32(e),i=this.#i.decode(new Uint8Array(this.#t,e+4,s));e+=4+s;let n=this.#e.getUint32(e),r=this.#i.decode(new Uint8Array(this.#t,e+4,n));return{style:i,weight:r}}}return l})(),vr=(()=>{class l{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static#t=Math.ceil(this.bools.length*2/8);static#e=this.#t+this.numbers.length*8;static#i=this.#e+1+8;static#s=this.#i+1+48;static#a=this.#s+1+6;#r;#n;#o;constructor({data:e,extra:s}){this.#r=e,this.#n=new TextDecoder,this.#o=new DataView(this.#r),s&&Object.assign(this,s)}#h(e){O(e<l.bools.length,"Invalid boolean index");let s=Math.floor(e/4),i=e*2%8,n=this.#o.getUint8(s)>>i&3;return n===0?void 0:n===2}get black(){return this.#h(0)}get bold(){return this.#h(1)}get disableFontFace(){return this.#h(2)}get fontExtraProperties(){return this.#h(3)}get isInvalidPDFjsFont(){return this.#h(4)}get isType3Font(){return this.#h(5)}get italic(){return this.#h(6)}get missingFile(){return this.#h(7)}get remeasure(){return this.#h(8)}get vertical(){return this.#h(9)}#l(e){return O(e<l.numbers.length,"Invalid number index"),this.#o.getFloat64(l.#t+e*8)}get ascent(){return this.#l(0)}get defaultWidth(){return this.#l(1)}get descent(){return this.#l(2)}get bbox(){let e=l.#e;if(this.#o.getUint8(e)===0)return;e+=1;let i=[];for(let n=0;n<4;n++)i.push(this.#o.getInt16(e,!0)),e+=2;return i}get fontMatrix(){let e=l.#i;if(this.#o.getUint8(e)===0)return;e+=1;let i=[];for(let n=0;n<6;n++)i.push(this.#o.getFloat64(e,!0)),e+=8;return i}get defaultVMetrics(){let e=l.#s;if(this.#o.getUint8(e)===0)return;e+=1;let i=[];for(let n=0;n<3;n++)i.push(this.#o.getInt16(e,!0)),e+=2;return i}#u(e){O(e<l.strings.length,"Invalid string index");let s=l.#a+4;for(let r=0;r<e;r++)s+=this.#o.getUint32(s)+4;let i=this.#o.getUint32(s),n=new Uint8Array(i);return n.set(new Uint8Array(this.#r,s+4,i)),this.#n.decode(n)}get fallbackName(){return this.#u(0)}get loadedName(){return this.#u(1)}get mimetype(){return this.#u(2)}get name(){return this.#u(3)}get data(){let e=l.#a,s=this.#o.getUint32(e);e+=4+s;let i=this.#o.getUint32(e);e+=4+i;let n=this.#o.getUint32(e);e+=4+n;let r=this.#o.getUint32(e);if(r!==0)return new Uint8Array(this.#r,e+4,r)}clearData(){let e=l.#a,s=this.#o.getUint32(e);e+=4+s;let i=this.#o.getUint32(e);e+=4+i;let n=this.#o.getUint32(e);e+=4+n;let r=this.#o.getUint32(e);new Uint8Array(this.#r,e+4,r).fill(0),this.#o.setUint32(e,0)}get cssFontInfo(){let e=l.#a,s=this.#o.getUint32(e);e+=4+s;let i=this.#o.getUint32(e);e+=4+i;let n=this.#o.getUint32(e);if(n===0)return null;let r=new Uint8Array(n);return r.set(new Uint8Array(this.#r,e+4,n)),new vn(r.buffer)}get systemFontInfo(){let e=l.#a,s=this.#o.getUint32(e);e+=4+s;let i=this.#o.getUint32(e);if(i===0)return null;let n=new Uint8Array(i);return n.set(new Uint8Array(this.#r,e+4,i)),new En(n.buffer)}static write(e){let s=e.systemFontInfo?En.write(e.systemFontInfo):null,i=e.cssFontInfo?vn.write(e.cssFontInfo):null,n=new TextEncoder,r={},a=0;for(let m of l.strings)r[m]=n.encode(e[m]),a+=4+r[m].length;
2let o=l.#a+4+a+4+(s?s.byteLength:0)+4+(i?i.byteLength:0)+4+(e.data?e.data.length:0),h=new ArrayBuffer(o),c=new Uint8Array(h),d=new DataView(h),u=0,f=l.bools.length,p=0,g=0;for(let m=0;m<f;m++){let b=e[l.bools[m]];p|=(b===void 0?0:b?2:1)<<g,g+=2,(g===8||m===f-1)&&(d.setUint8(u++,p),p=0,g=0)}O(u===l.#t,"FontInfo.write: Boolean properties offset mismatch");for(let m of l.numbers)d.setFloat64(u,e[m]),u+=8;if(O(u===l.#e,"FontInfo.write: Number properties offset mismatch"),e.bbox){d.setUint8(u++,4);for(let m of e.bbox)d.setInt16(u,m,!0),u+=2}else d.setUint8(u++,0),u+=8;if(O(u===l.#i,"FontInfo.write: BBox properties offset mismatch"),e.fontMatrix){d.setUint8(u++,6);for(let m of e.fontMatrix)d.setFloat64(u,m,!0),u+=8}else d.setUint8(u++,0),u+=48;if(O(u===l.#s,"FontInfo.write: FontMatrix properties offset mismatch"),e.defaultVMetrics){d.setUint8(u++,1);for(let m of e.defaultVMetrics)d.setInt16(u,m,!0),u+=2}else d.setUint8(u++,0),u+=6;O(u===l.#a,"FontInfo.write: DefaultVMetrics properties offset mismatch"),d.setUint32(l.#a,0),u+=4;for(let m of l.strings){let b=r[m],y=b.length;d.setUint32(u,y),c.set(b,u+4),u+=4+y}if(d.setUint32(l.#a,u-l.#a-4),!s)d.setUint32(u,0),u+=4;else{let m=s.byteLength;d.setUint32(u,m),O(u+4+m<=h.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),c.set(new Uint8Array(s),u+4),u+=4+m}if(!i)d.setUint32(u,0),u+=4;else{let m=i.byteLength;d.setUint32(u,m),O(u+4+m<=h.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),c.set(new Uint8Array(i),u+4),u+=4+m}return e.data===void 0?(d.setUint32(u,0),u+=4):(d.setUint32(u,e.data.length),c.set(e.data,u+4),u+=4+e.data.length),O(u<=h.byteLength,"FontInfo.write: Buffer overflow"),h.transferToFixedLength(u)}}return l})(),Ys=class l{static#t=0;static#e=1;static#i=2;static#s=3;static#a=4;static#r=8;static#n=12;static#o=16;constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}static write(t){let e,s=null,i=[],n=[],r=[],a=[],o=null,h=null;switch(t[0]){case"RadialAxial":e=t[1]==="axial"?1:2,s=t[2],r=t[3],e===1?i.push(...t[4],...t[5]):i.push(t[4][0],t[4][1],t[6],t[5][0],t[5][1],t[7]);break;case"Mesh":e=3,o=t[1],i=t[2],n=t[3],a=t[4]||[],s=t[6],h=t[7];break;default:throw new Error(`Unsupported pattern type: ${t[0]}`)}let c=Math.floor(i.length/2),d=Math.floor(n.length/3),u=r.length,f=a.length,p=0;for(let w of a)p+=1,p=Math.ceil(p/4)*4,p+=4+w.coords.length*4,p+=4+w.colors.length*4,w.verticesPerRow!==void 0&&(p+=4);let g=20+c*8+d*3+u*8+(s?16:0)+(h?3:0)+p,m=new ArrayBuffer(g),b=new DataView(m),y=new Uint8Array(m);b.setUint8(l.#t,e),b.setUint8(l.#e,s?1:0),b.setUint8(l.#i,h?1:0),b.setUint8(l.#s,o),b.setUint32(l.#a,c,!0),b.setUint32(l.#r,d,!0),b.setUint32(l.#n,u,!0),b.setUint32(l.#o,f,!0);let A=20;new Float32Array(m,A,c*2).set(i),A+=c*8,y.set(n,A),A+=d*3;for(let[w,E]of r)b.setFloat32(A,w,!0),A+=4,b.setUint32(A,parseInt(E.slice(1),16),!0),A+=4;if(s)for(let w of s)b.setFloat32(A,w,!0),A+=4;h&&(y.set(h,A),A+=3);for(let w=0;w<a.length;w++){let E=a[w];b.setUint8(A,E.type),A+=1,A=Math.ceil(A/4)*4,b.setUint32(A,E.coords.length,!0),A+=4,new Int32Array(m,A,E.coords.length).set(E.coords),A+=E.coords.length*4,b.setUint32(A,E.colors.length,!0),A+=4,new Int32Array(m,A,E.colors.length).set(E.colors),A+=E.colors.length*4,E.verticesPerRow!==void 0&&(b.setUint32(A,E.verticesPerRow,!0),A+=4)}return m}getIR(){let t=this.view,e=this.data[l.#t],s=!!this.data[l.#e],i=!!this.data[l.#i],n=t.getUint32(l.#a,!0),r=t.getUint32(l.#r,!0),a=t.getUint32(l.#n,!0),o=t.getUint32(l.#o,!0),h=20,c=new Float32Array(this.buffer,h,n*2);h+=n*8;let d=new Uint8Array(this.buffer,h,r*3);h+=r*3;let u=[];for(let m=0;m<a;++m){let b=t.getFloat32(h,!0);h+=4;let y=t.getUint32(h,!0);h+=4,u.push([b,`#${y.toString(16).padStart(6,"0")}`])}let f=null;if(s){f=[];for(let m=0;m<4;++m)f.push(t.getFloat32(h,!0)),h+=4}let p=null;i&&(p=new Uint8Array(this.buffer,h,3),h+=3);let g=[];for(let m=0;m<o;++m){let b=t.getUint8(h);h+=1,h=Math.ceil(h/4)*4;let y=t.getUint32(h,!0);h+=4;let A=new Int32Array(this.buffer,h,y);h+=y*4;let v=t.getUint32(h,!0);h+=4;let w=new Int32Array(this.buffer,h,v);h+=v*4;let E={type:b,coords:A,colors:w};b===ks.LATTICE&&(E.verticesPerRow=t.getUint32(h,!0),h+=4),g.push(E)}if(e===1)return["RadialAxial","axial",f,u,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",f,u,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(e===3){let m=this.data[l.#s],b=null;if(c.length>0){let y=c[0],A=c[0],v=c[1],w=c[1];for(let E=0;E<c.length;E+=2){let S=c[E],_=c[E+1];y=y>S?S:y,v=v>_?_:v,A=A<S?S:A,w=w<_?_:w}b=[y,v,A,w]}return["Mesh",m,c,d,g,b,f,p]}throw new Error(`Unsupported pattern kind: ${e}`)}},Ks=class{static write(t){let e,s;return K.isFloat16ArraySupported?(s=new ArrayBuffer(t.length*2),e=new Float16Array(s)):(s=new ArrayBuffer(t.length*4),e=new Float32Array(s)),e.set(t),s}#t;constructor(t){this.#t=t}get path(){return K.isFloat16ArraySupported?new Float16Array(this.#t):new Float32Array(this.#t)}};function Er(l){if(l instanceof URL)return l;if(typeof l=="string"){if(rt){if(/^[a-z][a-z0-9\-+.]+:/i.test(l))return new URL(l);let e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(l))}let t=URL.parse(l,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Sr(l){if(rt&&typeof Buffer<"u"&&l instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength)return l;if(typeof l=="string")return gs(l);
2if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)||typeof l=="object"&&!isNaN(l?.length))return new Uint8Array(l);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function _e(l){if(typeof l!="string")return null;if(l.endsWith("/"))return l;throw new Error(`Invalid factory url: "${l}" must include trailing slash.`)}var qs=l=>typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0,_r=l=>typeof l=="object"&&typeof l?.name=="string",Cr=pr.bind(null,qs,_r),Qs=class{#t=new Map;#e=Promise.resolve();postMessage(t,e){let s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){let{signal:n}=s;if(n.aborted){R("LoopbackPort - cannot use an `aborted` signal.");return}let r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}},Ce={DATA:1,ERROR:2},Z={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Sn(){}function at(l){if(l instanceof yt||l instanceof re||l instanceof Ne||l instanceof jt||l instanceof ee)return l;switch(l instanceof Error||typeof l=="object"&&l!==null||B('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new yt(l.message);case"InvalidPDFException":return new re(l.message);case"PasswordException":return new Ne(l.message,l.code);case"ResponseException":return new jt(l.message,l.status,l.missing);case"UnknownErrorException":return new ee(l.message,l.details)}return new ee(l.message,l.toString())}var xt=class{#t=new AbortController;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),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#s(t);return}if(t.callback){let s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===Ce.DATA)i.resolve(t.data);else if(t.callback===Ce.ERROR)i.reject(at(t.reason));else throw new Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:s,targetName:i,callback:Ce.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:s,targetName:i,callback:Ce.ERROR,callbackId:t.callbackId,reason:at(r)})});return}if(t.streamId){this.#i(t);return}e(t.data)}on(t,e){let s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){let 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){let n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:h=>{let c=Promise.withResolvers();return this.streamControllers[n]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{let c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:Z.P
2ULL,streamId:n,desiredSize:h.desiredSize}),c.promise},cancel:h=>{O(h instanceof Error,"cancel must have a valid reason");let c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Z.CANCEL,streamId:n,reason:at(h)}),c.promise}},s)}#i(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(h,c=1,d){if(this.isCancelled)return;let u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:Z.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Z.CLOSE,streamId:e}),delete r.streamSinks[e])},error(h){O(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Z.ERROR,streamId:e,reason:at(h)}))},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,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Z.START_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:Z.START_COMPLETE,streamId:e,reason:at(h)})})}#s(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Z.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(at(t.reason));break;case Z.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(at(t.reason));break;case Z.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:Z.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Sn).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Z.PULL_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:Z.PULL_COMPLETE,streamId:e,reason:at(h)})});break;case Z.ENQUEUE:if(O(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Z.CLOSE:if(O(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#a(r,e);break;case Z.ERROR:O(r,"error should have stream controller"),r.controller.error(at(t.reason)),this.#a(r,e);break;case Z.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(at(t.reason)),this.#a(r,e);break;case Z.CANCEL:if(!a)break;let o=at(t.reason);Promise.try(a.onCancel||Sn,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Z.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:Z.CANCEL_COMPLETE,streamId:e,reason:at(h)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#a(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}},$e=class{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");let 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){B("Abstract method `_createCanvas` called.")}},Js=class extends $e{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let s=this._document.createElement("canvas");return s.width=t,s.height=e,s}},je=class{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){B("Abstract method `_fetch` called.")}},Ge=class extends je{async _fetch(t){let e=await Ee(t,this.isCompressed?"bytes":"text");return e instanceof Uint8Array?e:gs(e)}},ze=class{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){}},Zs=class extends ze{#t;#e;#i;#s;#a;#r;#n=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#s=t,this.#a=e}get#o(){return this.#e||=new Map}get#h(){return this.#r||=new Map}get#l(){if(!this.#i){let t=this.#a.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;let s=this.#a.createElementNS(wt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#i=this.#a.createElementNS(wt,"defs"),t.append(s),s.append(this.#i),this.#a.body.append(t)}return this.#i}#u(t){if(t.length===1){let o=t[0],h=new Array(256);for(let d=0;d<256;d++)h[d]=o[d]/255;let c=h.join(",");return[c,c,c]}let[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(",")]}#d(t){if(this.#t===void 0){this.#t="";let e=this.#a.URL;e!==this.#a.baseURI&&(ms(e)?R('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=Un(e,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;let[s,i,n]=this.#u(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;let a=`g_${this.#s}_transfer_map_${this.#n++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);
2let h=this.#g(a);return this.#p(s,i,n,h),o}addHCMFilter(t,e){let s=`${t}-${e}`,i="base",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;let r=this.#A(t);t=T.makeHexColor(...r);let a=this.#A(e);if(e=T.makeHexColor(...a),this.#l.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return n.url;let o=new Array(256);for(let f=0;f<=255;f++){let p=f/255;o[f]=p<=.03928?p/12.92:((p+.055)/1.055)**2.4}let h=o.join(","),c=`g_${this.#s}_hcm_filter`,d=n.filter=this.#g(c);this.#p(h,h,h,d),this.#m(d);let u=(f,p)=>{let g=r[f]/255,m=a[f]/255,b=new Array(p+1);for(let y=0;y<=p;y++)b[y]=g+y/p*(m-g);return b.join(",")};return this.#p(u(0,5),u(1,5),u(2,5),d),n.url=this.#d(c),n.url}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;let[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#s}_alpha_map_${this.#n++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#g(n);return this.#b(s,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#u([t]),i=`luminosity_${s}`):i="luminosity",e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#s}_luminosity_map_${this.#n++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#g(n);return this.#f(a),t&&this.#b(s,a),r}addHighlightHCMFilter(t,e,s,i,n){let r=`${e}-${s}-${i}-${n}`,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;let[o,h]=[e,s].map(this.#A.bind(this)),c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,f]=[i,n].map(this.#A.bind(this));d<c&&([c,d,u,f]=[d,c,f,u]),this.#l.style.color="";let p=(b,y,A)=>{let v=new Array(256),w=(d-c)/A,E=b/255,S=(y-b)/(255*A),_=0;for(let C=0;C<=A;C++){let M=Math.round(c+C*w),x=E+C*S;for(let U=_;U<=M;U++)v[U]=x;_=M+1}for(let C=_;C<256;C++)v[C]=v[_-1];return v.join(",")},g=`g_${this.#s}_hcm_${t}_filter`,m=a.filter=this.#g(g);return this.#m(m),this.#p(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),m),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#r?.size||(this.#i?.parentNode.parentNode.remove(),this.#i=null,this.#e?.clear(),this.#e=null,this.#r?.clear(),this.#r=null,this.#n=0)}#f(t){let e=this.#a.createElementNS(wt,"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)}#m(t){let e=this.#a.createElementNS(wt,"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)}#g(t){let e=this.#a.createElementNS(wt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#l.append(e),e}#c(t,e,s){let i=this.#a.createElementNS(wt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#p(t,e,s,i){let n=this.#a.createElementNS(wt,"feComponentTransfer");i.append(n),this.#c(n,"feFuncR",t),this.#c(n,"feFuncG",e),this.#c(n,"feFuncB",s)}#b(t,e){let s=this.#a.createElementNS(wt,"feComponentTransfer");e.append(s),this.#c(s,"feFuncA",t)}#A(t){return this.#l.style.color=t,Se(getComputedStyle(this.#l).getPropertyValue("color"))}},Ve=class{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){B("Abstract method `_fetch` called.")}},We=class extends Ve{async _fetch(t){return Ee(t,"bytes")}},Xe=class{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){B("Abstract method `_fetch` called.")}},Ye=class extends Xe{async _fetch(t){return Ee(t,"bytes")}};rt&&R("Please use the `legacy` build in Node.js environments.");async function un(l){let e=await process.getBuiltinModule("fs").promises.readFile(l);return new Uint8Array(e)}var ti=class extends ze{},ei=class extends $e{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}},si=class extends je{async _fetch(t){return un(t)}},ii=class extends Ve{async _fetch(t){return un(t)}},ni=class extends Xe{async _fetch(t){return un(t)}},Nt="__forcedDependency",{floor:_n,ceil:Cn}=Math;function Te(l,t,e,s,i,n){l[t*4+0]=Math.min(l[t*4+0],e),l[t*4+1]=Math.min(l[t*4+1],s),l[t*4+2]=Math.max(l[t*4+2],i),l[t*4+3]=Math.max(l[t*4+3],n)}var ri=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0],ai=class{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===ri}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}},xe=(l,t)=>l?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1})),oi=class{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[Nt]:[]};#i=new Map;#s=[];#a=[];#r=[[1,0,0,1,0,0]];#n=[-1/0,-1/0,1/0,1/0];#o=new Float64Array([1/0,1/0,-1/0,-1/0]);#h=-1;#l=new Set;#u=new Map;#d=new Map;#f;#m;#g;#c;#p;constructor(t,e,s=!1){this.#f=t.width,this.#m=t.height,this.#b(e),s&&(this.#p=new Map)}growOperationsCount(t){t>=this.#c.length&&this.#b(t,this.#c)}#b(t,e){let s=new ArrayBuffer(t*4);
2this.#g=new Uint8ClampedArray(s),this.#c=new Uint32Array(s),e&&e.length>0?(this.#c.set(e),this.#c.fill(ri,e.length)):this.#c.fill(ri)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[Nt]:{__proto__:this.#e[Nt]}},this.#n={__proto__:this.#n},this.#s.push(t),this}restore(t){let e=Object.getPrototypeOf(this.#t);if(e===null)return this;this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this.#n=Object.getPrototypeOf(this.#n);let s=this.#s.pop();return s!==void 0&&(xe(this.#p,t)?.dependencies.add(s),this.#c[t]=this.#c[s]),this}recordOpenMarker(t){return this.#s.push(t),this}getOpenMarker(){return this.#s.length===0?null:this.#s.at(-1)}recordCloseMarker(t){let e=this.#s.pop();return e!==void 0&&(xe(this.#p,t)?.dependencies.add(e),this.#c[t]=this.#c[e]),this}beginMarkedContent(t){return this.#a.push(t),this}endMarkedContent(t){let e=this.#a.pop();return e!==void 0&&(xe(this.#p,t)?.dependencies.add(e),this.#c[t]=this.#c[e]),this}pushBaseTransform(t){return this.#r.push(T.multiplyByDOMMatrix(this.#r.at(-1),t.getTransform())),this}popBaseTransform(){return this.#r.length>1&&this.#r.pop(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#i.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#i.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Nt,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#l)this.recordFutureForcedDependency(Nt,t);return this}resetBBox(t){return this.#h!==t&&(this.#h=t,this.#o[0]=1/0,this.#o[1]=1/0,this.#o[2]=-1/0,this.#o[3]=-1/0),this}recordClipBox(t,e,s,i,n,r){let a=T.multiplyByDOMMatrix(this.#r.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];T.axialAlignedBoundingBox([s,n,i,r],a,o);let h=T.intersect(this.#n,o);return h?(this.#n[0]=h[0],this.#n[1]=h[1],this.#n[2]=h[2],this.#n[3]=h[3]):(this.#n[0]=this.#n[1]=1/0,this.#n[2]=this.#n[3]=-1/0),this}recordBBox(t,e,s,i,n,r){let a=this.#n;if(a[0]===1/0)return this;let o=T.multiplyByDOMMatrix(this.#r.at(-1),e.getTransform());if(a[0]===-1/0)return T.axialAlignedBoundingBox([s,n,i,r],o,this.#o),this;let h=[1/0,1/0,-1/0,-1/0];return T.axialAlignedBoundingBox([s,n,i,r],o,h),this.#o[0]=Math.min(this.#o[0],Math.max(h[0],a[0])),this.#o[1]=Math.min(this.#o[1],Math.max(h[1],a[1])),this.#o[2]=Math.max(this.#o[2],Math.min(h[2],a[2])),this.#o[3]=Math.max(this.#o[3],Math.min(h[3],a[3])),this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){let o=s.bbox,h,c;if(o&&(h=o[2]!==o[0]&&o[3]!==o[1]&&this.#d.get(s),h!==!1&&(c=[0,0,0,0],T.axialAlignedBoundingBox(o,s.fontMatrix,c),(i!==1||n!==0||r!==0)&&T.scaleMinMax([i,0,0,-i,n,r],c),h)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!a)return this.recordFullPageBBox(t);let d=a();return o&&c&&h===void 0&&(h=c[0]<=n-d.actualBoundingBoxLeft&&c[2]>=n+d.actualBoundingBoxRight&&c[1]<=r-d.actualBoundingBoxAscent&&c[3]>=r+d.actualBoundingBoxDescent,this.#d.set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,n-d.actualBoundingBoxLeft,n+d.actualBoundingBoxRight,r-d.actualBoundingBoxAscent,r+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o[0]=Math.max(0,this.#n[0]),this.#o[1]=Math.max(0,this.#n[1]),this.#o[2]=Math.min(this.#f,this.#n[2]),this.#o[3]=Math.min(this.#m,this.#n[3]),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){let s=this.#l,i=this.#t,n=this.#e;for(let r of e)r in this.#t?s.add(i[r]):r in n&&n[r].forEach(s.add,s);return this}recordNamedDependency(t,e){return this.#i.has(e)&&this.#l.add(this.#i.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Nt]),this.#p){let s=xe(this.#p,t),{dependencies:i}=s;this.#l.forEach(i.add,i),this.#s.forEach(i.add,i),this.#a.forEach(i.add,i),i.delete(t),s.isRenderingOperation=!0}if(this.#h===t){let s=_n(this.#o[0]*256/this.#f),i=_n(this.#o[1]*256/this.#m),n=Cn(this.#o[2]*256/this.#f),r=Cn(this.#o[3]*256/this.#m);Te(this.#g,t,s,i,n,r);for(let a of this.#l)a!==t&&Te(this.#g,a,s,i,n,r);for(let a of this.#s)a!==t&&Te(this.#g,a,s,i,n,r);for(let a of this.#a)a!==t&&Te(this.#g,a,s,i,n,r);e||(this.#l.clear(),this.#h=-1)}return this}recordShowTextOperation(t,e=!1){let s=Array.from(this.#l);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(let i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){return this.#h===t&&(this.#h=-1,this.#n[0]=Math.max(this.#n[0],this.#o[0]),this.#n[1]=Math.max(this.#n[1],this.#o[1]),this.#n[2]=Math.min(this.#n[2],this.#o[2]),this.#n[3]=Math.min(this.#n[3],this.#o[3]),e||this.#l.clear()),this}_takePendingDependencies(){let t=this.#l;
2return this.#l=new Set,t}_extractOperation(t){let e=this.#u.get(t);return this.#u.delete(t),e}_pushPendingDependencies(t){for(let e of t)this.#l.add(e)}take(){return this.#d.clear(),new ai(this.#c,this.#g)}takeDebugMetadata(){return this.#p}},Ke=class l{#t;#e;#i;#s=0;#a=0;constructor(t,e,s){if(t instanceof l&&t.#i===!!s)return t;this.#t=t,this.#e=e,this.#i=!!s}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#a++,this.#t.save(this.#e),this}restore(t){return this.#a>0&&(this.#t.restore(this.#e),this.#a--),this}recordOpenMarker(t){return this.#s++,this}getOpenMarker(){return this.#s>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#s--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#i||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,s,i,n,r){return this.#i||this.#t.recordClipBox(this.#e,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#i||this.#t.recordBBox(this.#e,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i,n,r,a){return this.#i||this.#t.recordCharacterBBox(this.#e,e,s,i,n,r,a),this}recordFullPageBBox(t){return this.#i||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#i||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}},ut={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},it={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function li(l,t){if(!t)return;let e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),l.clip(i)}var fe=class{isModifyingCurrentTransform(){return!1}getPattern(){B("Abstract method `getPattern` called.")}},hi=class extends fe{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}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}_createGradient(t,e=null){let s,i=this._p0,n=this._p1;if(e&&(i=i.slice(),n=n.slice(),T.applyTransform(i,e),T.applyTransform(n,e)),this._type==="axial")s=t.createLinearGradient(i[0],i[1],n[0],n[1]);else if(this._type==="radial"){let r=this._r0,a=this._r1;if(e){let o=new Float32Array(2);T.singularValueDecompose2dScale(e,o),r*=o[0],a*=o[0]}s=t.createRadialGradient(i[0],i[1],r,n[0],n[1],a)}for(let r of this._colorStops)s.addColorStop(r[0],r[1]);return s}getPattern(t,e,s,i){let n;if(i===it.STROKE||i===it.FILL){if(this.isOriginBased()){let u=T.transform(s,e.baseTransform);
2this.matrix&&(u=T.transform(u,this.matrix));let f=.001,p=Math.hypot(u[0],u[1]),g=Math.hypot(u[2],u[3]),m=(u[0]*u[2]+u[1]*u[3])/(p*g);if(Math.abs(m)<f)if(this.isRadial()){if(Math.abs(p-g)<f)return this._createGradient(t,u)}else return this._createGradient(t,u)}let r=e.current.getClippedPathBoundingBox(i,V(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,h=e.cachedCanvases.getCanvas("pattern",a,o),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),s=T.transform(s,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),li(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(h.canvas,"no-repeat");let d=new DOMMatrix(s);n.setTransform(d)}else li(t,this._bbox),n=this._createGradient(t);return n}};function Ts(l,t,e,s,i,n,r,a){let o=t.coords,h=t.colors,c=l.data,d=l.width*4,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);let f=(o[e]+t.offsetX)*t.scaleX,p=(o[e+1]+t.offsetY)*t.scaleY,g=(o[s]+t.offsetX)*t.scaleX,m=(o[s+1]+t.offsetY)*t.scaleY,b=(o[i]+t.offsetX)*t.scaleX,y=(o[i+1]+t.offsetY)*t.scaleY;if(p>=y)return;let A=h[n],v=h[n+1],w=h[n+2],E=h[r],S=h[r+1],_=h[r+2],C=h[a],M=h[a+1],x=h[a+2],U=Math.round(p),H=Math.round(y),F,q,k,I,j,X,St,Q;for(let z=U;z<=H;z++){if(z<m){let J=z<p?0:(p-z)/(p-m);F=f-(f-g)*J,q=A-(A-E)*J,k=v-(v-S)*J,I=w-(w-_)*J}else{let J;z>y?J=1:m===y?J=0:J=(m-z)/(m-y),F=g-(g-b)*J,q=E-(E-C)*J,k=S-(S-M)*J,I=_-(_-x)*J}let G;z<p?G=0:z>y?G=1:G=(p-z)/(p-y),j=f-(f-b)*G,X=A-(A-C)*G,St=v-(v-M)*G,Q=w-(w-x)*G;let gt=Math.round(Math.min(F,j)),Rt=Math.round(Math.max(F,j)),pt=d*z+gt*4;for(let J=gt;J<=Rt;J++)G=(F-J)/(F-j),G<0?G=0:G>1&&(G=1),c[pt++]=q-(q-X)*G|0,c[pt++]=k-(k-St)*G|0,c[pt++]=I-(I-Q)*G|0,c[pt++]=255}}function Tr(l,t,e){let s=t.coords,i=t.colors,n,r;switch(t.type){case ks.LATTICE:let a=t.verticesPerRow,o=Math.floor(s.length/a)-1,h=a-1;for(n=0;n<o;n++){let c=n*a;for(let d=0;d<h;d++,c++)Ts(l,e,s[c],s[c+1],s[c+a],i[c],i[c+1],i[c+a]),Ts(l,e,s[c+a+1],s[c+1],s[c+a],i[c+a+1],i[c+1],i[c+a])}break;case ks.TRIANGLES:for(n=0,r=s.length;n<r;n+=3)Ts(l,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}var ci=class extends fe{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,s){let a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,d=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),f=h/d,p=c/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/f,scaleY:1/p},m=d+4,b=u+4,y=s.getCanvas("mesh",m,b),A=y.context,v=A.createImageData(d,u);if(e){let E=v.data;for(let S=0,_=E.length;S<_;S+=4)E[S]=e[0],E[S+1]=e[1],E[S+2]=e[2],E[S+3]=255}for(let E of this._figures)Tr(v,E,g);return A.putImageData(v,2,2),{canvas:y.canvas,offsetX:a-2*f,offsetY:o-2*p,scaleX:f,scaleY:p}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){li(t,this._bbox);let n=new Float32Array(2);if(i===it.SHADING)T.singularValueDecompose2dScale(V(t),n);else if(this.matrix){T.singularValueDecompose2dScale(this.matrix,n);let[a,o]=n;T.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=a,n[1]*=o}else T.singularValueDecompose2dScale(e.baseTransform,n);let r=this._createMeshCanvas(n,i===it.SHADING?null:this._background,e.cachedCanvases);return i!==it.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")}},di=class extends fe{getPattern(){return"hotpink"}};function xr(l){switch(l[0]){case"RadialAxial":return new hi(l);case"Mesh":return new ci(l);case"Dummy":return new di}throw new Error(`Unknown IR type: ${l[0]}`)}var Tn={COLORED:1,UNCOLORED:2},Pr=(()=>{class l{static MAX_PATTERN_SIZE=3e3;constructor(e,s,i,n){this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(e,s){let{bbox:i,operatorList:n,paintType:r,tilingType:a,color:o,canvasGraphicsFactory:h}=this,{xstep:c,ystep:d}=this;c=Math.abs(c),d=Math.abs(d),ps("TilingType: "+a);let u=i[0],f=i[1],p=i[2],g=i[3],m=p-u,b=g-f,y=new Float32Array(2);T.singularValueDecompose2dScale(this.matrix,y);let[A,v]=y;T.singularValueDecompose2dScale(this.baseTransform,y);let w=A*y[0],E=v*y[1],S=m,_=b,C=!1,M=!1,x=Math.ceil(c*w),U=Math.ceil(d*E),H=Math.ceil(m*w),F=Math.ceil(b*E);x>=H?S=c:C=!0,U>=F?_=d:M=!0;let q=this.getSizeAndScale(S,this.ctx.canvas.width,w),k=this.getSizeAndScale(_,this.ctx.canvas.height,E),I=e.cachedCanvases.getCanvas("pattern",q.size,k.size),j=I.context,X=h.createCanvasGraphics(j,s);if(X.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(X,r,o),j.translate(-q.scale*u,-k.scale*f),X.transform(0,q.scale,0,0,k.scale,0,0),j.save(),X.dependencyTracker?.save(),this.clipBbox(X,u,f,p,g),X.baseTransform=V(X.ctx),X.executeOperatorList(n),X.endDrawing(),X.dependencyTracker?.restore(
2),j.restore(),C||M){let St=I.canvas;C&&(S=c),M&&(_=d);let Q=this.getSizeAndScale(S,this.ctx.canvas.width,w),z=this.getSizeAndScale(_,this.ctx.canvas.height,E),G=Q.size,gt=z.size,Rt=e.cachedCanvases.getCanvas("pattern-workaround",G,gt),pt=Rt.context,J=C?Math.floor(m/c):0,vs=M?Math.floor(b/d):0;for(let Xt=0;Xt<=J;Xt++)for(let Yt=0;Yt<=vs;Yt++)pt.drawImage(St,G*Xt,gt*Yt,G,gt,0,0,G,gt);return{canvas:Rt.canvas,scaleX:Q.scale,scaleY:z.scale,offsetX:u,offsetY:f}}return{canvas:I.canvas,scaleX:q.scale,scaleY:k.scale,offsetX:u,offsetY:f}}getSizeAndScale(e,s,i){let n=Math.max(l.MAX_PATTERN_SIZE,s),r=Math.ceil(e*i);return r>=n?r=n:i=r/e,{scale:i,size:r}}clipBbox(e,s,i,n,r){let a=n-s,o=r-i;e.ctx.rect(s,i,a,o),T.axialAlignedBoundingBox([s,i,n,r],V(e.ctx),e.current.minMax),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,s,i){let n=e.ctx,r=e.current;switch(s){case Tn.COLORED:let{fillStyle:a,strokeStyle:o}=this.ctx;n.fillStyle=r.fillColor=a,n.strokeStyle=r.strokeColor=o;break;case Tn.UNCOLORED:n.fillStyle=n.strokeStyle=i,r.fillColor=r.strokeColor=i;break;default:throw new Ls(`Unsupported paint type: ${s}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,s,i,n,r){let a=i;n!==it.SHADING&&(a=T.transform(a,s.baseTransform),this.matrix&&(a=T.transform(a,this.matrix)));let o=this.createPatternCanvas(s,r),h=new DOMMatrix(a);h=h.translate(o.offsetX,o.offsetY),h=h.scale(1/o.scaleX,1/o.scaleY);let c=e.createPattern(o.canvas,"repeat");return c.setTransform(h),c}}return l})();function Mr({src:l,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){let a=K.isLittleEndian?4278190080:255,[o,h]=r?[n,a]:[a,n],c=s>>3,d=s&7,u=o^h,f=l.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;++g){for(let b=t+c;t<b;++t,p+=8){let y=l[t];e[p]=o^-(y>>7&1)&u,e[p+1]=o^-(y>>6&1)&u,e[p+2]=o^-(y>>5&1)&u,e[p+3]=o^-(y>>4&1)&u,e[p+4]=o^-(y>>3&1)&u,e[p+5]=o^-(y>>2&1)&u,e[p+6]=o^-(y>>1&1)&u,e[p+7]=o^-(y&1)&u}if(d===0)continue;let m=t<f?l[t++]:255;for(let b=0;b<d;++b,++p)e[p]=o^-(m>>7-b&1)&u}return{srcPos:t,destPos:p}}var xn=16,Pn=100,kr=15,Mn=10,ot=16,xs=new DOMMatrix,ct=new Float32Array(2),Ht=new Float32Array([1/0,1/0,-1/0,-1/0]);function Ir(l,t){if(l._removeMirroring)throw new Error("Context is already forwarding operations.");l.__originalSave=l.save,l.__originalRestore=l.restore,l.__originalRotate=l.rotate,l.__originalScale=l.scale,l.__originalTranslate=l.translate,l.__originalTransform=l.transform,l.__originalSetTransform=l.setTransform,l.__originalResetTransform=l.resetTransform,l.__originalClip=l.clip,l.__originalMoveTo=l.moveTo,l.__originalLineTo=l.lineTo,l.__originalBezierCurveTo=l.bezierCurveTo,l.__originalRect=l.rect,l.__originalClosePath=l.closePath,l.__originalBeginPath=l.beginPath,l._removeMirroring=()=>{l.save=l.__originalSave,l.restore=l.__originalRestore,l.rotate=l.__originalRotate,l.scale=l.__originalScale,l.translate=l.__originalTranslate,l.transform=l.__originalTransform,l.setTransform=l.__originalSetTransform,l.resetTransform=l.__originalResetTransform,l.clip=l.__originalClip,l.moveTo=l.__originalMoveTo,l.lineTo=l.__originalLineTo,l.bezierCurveTo=l.__originalBezierCurveTo,l.rect=l.__originalRect,l.closePath=l.__originalClosePath,l.beginPath=l.__originalBeginPath,delete l._removeMirroring},l.save=function(){t.save(),this.__originalSave()},l.restore=function(){t.restore(),this.__originalRestore()},l.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},l.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},l.transform=function(e,s,i,n,r,a){t.transform(e,s,i,n,r,a),this.__originalTransform(e,s,i,n,r,a)},l.setTransform=function(e,s,i,n,r,a){t.setTransform(e,s,i,n,r,a),this.__originalSetTransform(e,s,i,n,r,a)},l.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},l.rotate=function(e){t.rotate(e),this.__originalRotate(e)},l.clip=function(e){t.clip(e),this.__originalClip(e)},l.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},l.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},l.bezierCurveTo=function(e,s,i,n,r,a){t.bezierCurveTo(e,s,i,n,r,a),this.__originalBezierCurveTo(e,s,i,n,r,a)},l.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},l.closePath=function(){t.closePath(),this.__originalClosePath()},l.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}var ui=class{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(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}};function Pe(l,t,e,s,i,n,r,a,o,h){let[c,d,u,f,p,g]=V(l);if(d===0&&u===0){let y=r*c+p,A=Math.round(y),v=a*f+g,w=Math.round(v),E=(r+o)*c+p,S=Math.abs(Math.round(E)-A)||1,_=(a+h)*f+g,C=Math.abs(Math.round(_)-w)||1;return l.setTransform(Math.sign(c),0,0,Math.sign(f),A,w),l.drawImage(t,e,s,i,n,0,0,S,C),l.setTransform(c,d,u,f,p,g),[S,C]}if(c===0&&f===0){let y=a*u+p,A=Math.round(y),v=r*d+g,w=Math.round(v),E=(a+h)*u+p,S=Math.abs(Math.round(E)-A)||1,_=(r+o)*d+g,C=Math.abs(Math.round(_)-w)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,A,w),l.drawImage(t,e,s,i,n,0,0,C,S),l.setTransform(c,d,u,f,p,g),[C,S]}l.drawImage(t,e,s,i,n,r,a,o,h);let m=Math.hypot(c,d),b=Math.hypot(u,f);return[m*o,b*h]}var qe=class{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Ms;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=et.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,s){s?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=Ht.slice()}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=it.FILL,e=null){let s=this.minMax.slice();if(t===it.STROKE){e||B("Stroke bounding box must include transform."),T.singularValueDecompose2dScale(e,ct);let i=ct[0]*this.lineWidth/2,n=ct[1]*this.lineWidth/2;s[0]-=i,s[1]-=n,s[2]+=i,s[3]+=n}return s}updateClipFromPath(){let t=T.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(Ht,0)}getClippedPathBoundingBox(t=it.FILL,e=null){return T.intersect(this.clipBox,this.getPathBoundingBox(t,e))}};function kn(l,t){if(t instanceof ImageData){l.putImageData(t,0,0);return}let e=t.height,s=t.width,i=e%ot,n=(e-i)/ot,r=i===0?n:n+1,a=l.createImageData(s,ot),o=0,h,c=t.data,d=a.data,u,f,p,g;if(t.kind===Re.GRAYSCALE_1BPP){let m=c.byteLength,b=new Uint32Array(d.buffer,0,d.byteLength>>2),y=b.length,A=s+7>>3,v=4294967295,w=K.isLittleEndian?4278190080:255;for(u=0;
2u<r;u++){for(p=u<n?ot:i,h=0,f=0;f<p;f++){let E=m-o,S=0,_=E>A?s:E*8-7,C=_&-8,M=0,x=0;for(;S<C;S+=8)x=c[o++],b[h++]=x&128?v:w,b[h++]=x&64?v:w,b[h++]=x&32?v:w,b[h++]=x&16?v:w,b[h++]=x&8?v:w,b[h++]=x&4?v:w,b[h++]=x&2?v:w,b[h++]=x&1?v:w;for(;S<_;S++)M===0&&(x=c[o++],M=128),b[h++]=x&M?v:w,M>>=1}for(;h<y;)b[h++]=0;l.putImageData(a,0,u*ot)}}else if(t.kind===Re.RGBA_32BPP){for(f=0,g=s*ot*4,u=0;u<n;u++)d.set(c.subarray(o,o+g)),o+=g,l.putImageData(a,0,f),f+=ot;u<r&&(g=s*i*4,d.set(c.subarray(o,o+g)),l.putImageData(a,0,f))}else if(t.kind===Re.RGB_24BPP)for(p=ot,g=s*p,u=0;u<r;u++){for(u>=n&&(p=i,g=s*p),h=0,f=g;f--;)d[h++]=c[o++],d[h++]=c[o++],d[h++]=c[o++],d[h++]=255;l.putImageData(a,0,u*ot)}else throw new Error(`bad image kind: ${t.kind}`)}function In(l,t){if(t.bitmap){l.drawImage(t.bitmap,0,0);return}let e=t.height,s=t.width,i=e%ot,n=(e-i)/ot,r=i===0?n:n+1,a=l.createImageData(s,ot),o=0,h=t.data,c=a.data;for(let d=0;d<r;d++){let u=d<n?ot:i;({srcPos:o}=Mr({src:h,srcPos:o,dest:c,width:s,height:u,nonBlackColor:0})),l.putImageData(a,0,d*ot)}}function qt(l,t){let e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let s of e)l[s]!==void 0&&(t[s]=l[s]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function Me(l){l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0);let{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}function Ln(l,t){if(t)return!0;T.singularValueDecompose2dScale(l,ct);let e=Math.fround(vt.pixelRatio*Tt.PDF_TO_CSS_UNITS);return ct[0]<=e&&ct[1]<=e}var Lr=["butt","round","square"],Dr=["miter","round","bevel"],Rr={},Dn={},$t=class l{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,h,c){this.ctx=t,this.current=new qe(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],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 ui(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null}getObject(t,e,s=null){return typeof e=="string"?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){let 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){let 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(...V(this.compositeCtx))}this.ctx.save(),Me(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=V(this.ctx)}executeOperatorList(t,e,s,i,n){let r=t.argsArray,a=t.fnArray,o=e||0,h=r.length;if(h===o)return o;let c=h-o>Mn&&typeof s=="function",d=c?Date.now()+kr:0,u=0,f=this.commonObjs,p=this.objs,g,m;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(!n||n(o))if(g=a[o],m=r[o]??null,g!==ne.dependency)m===null?this[g](o):this[g](o,...m);else for(let b of m){this.dependencyTracker?.recordNamedData(b,o);let y=b.startsWith("g_")?f:p;if(!y.has(b))return y.get(b,s),o}if(o++,o===h)return o;if(c&&++u>Mn){if(Date.now()>d)return s(),o;u=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;
2)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let 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){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let s=t.width??t.displayWidth,i=t.height??t.displayHeight,n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=s,o=i,h="prescale1",c,d;for(;n>2&&a>1||r>2&&o>1;){let u=a,f=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&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,r/=o/f),c=this.cachedCanvases.getCanvas(h,u,f),d=c.context,d.clearRect(0,0,u,f),d.drawImage(t,0,0,a,o,0,0,u,f),t=c.canvas,a=u,o=f,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:o}}_createMaskCanvas(t,e){let s=this.ctx,{width:i,height:n}=e,r=this.current.fillColor,a=this.current.patternFill,o=V(s),h,c,d,u;if((e.bitmap||e.data)&&e.count>1){let M=e.bitmap||e.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),r]),h=this._cachedBitmapsMap.getOrInsertComputed(M,cn);let x=h.get(c);if(x&&!a){let U=Math.round(Math.min(o[0],o[2])+o[4]),H=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,ut.transformAndFill),{canvas:x,offsetX:U,offsetY:H}}d=x}d||(u=this.cachedCanvases.getCanvas("maskCanvas",i,n),In(u.context,e));let f=T.transform(o,[1/i,0,0,-1/n,0,0]);f=T.transform(f,[1,0,0,1,0,-n]);let p=Ht.slice();T.axialAlignedBoundingBox([0,0,i,n],f,p);let[g,m,b,y]=p,A=Math.round(b-g)||1,v=Math.round(y-m)||1,w=this.cachedCanvases.getCanvas("fillCanvas",A,v),E=w.context,S=g,_=m;E.translate(-S,-_),E.transform(...f),d||(d=this._scaleImage(u.canvas,mt(E)),d=d.img,h&&a&&h.set(c,d)),E.imageSmoothingEnabled=Ln(V(E),e.interpolate),Pe(E,d,0,0,d.width,d.height,0,0,i,n),E.globalCompositeOperation="source-in";let C=T.transform(mt(E),[1,0,0,1,-S,-_]);return E.fillStyle=a?r.getPattern(s,this,C,it.FILL,t):r,E.fillRect(0,0,i,n),h&&!a&&(this.cachedCanvases.delete("fillCanvas"),h.set(c,w.canvas)),this.dependencyTracker?.recordDependencies(t,ut.transformAndFill),{canvas:w.canvas,offsetX:Math.round(S),offsetY:Math.round(_)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=Lr[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Dr[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.recordSimpleData("dash",t);let i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[s,i]of e)switch(s){case"LW":this.setLineWidth(t,i);break;case"LC":this.setLineCap(t,i);break;case"LJ":this.setLineJoin(t,i);break;case"ML":this.setMiterLimit(t,i);break;case"D":this.setDash(t,i[0],i[1]);break;case"RI":this.setRenderingIntent(t,i);break;case"FL":this.setFlatness(t,i);break;case"Font":this.setFont(t,i[0],i[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=i;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=i;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,s=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(i,e,s);this.suspendedCtx=this.ctx;let r=this.ctx=n.context;r.setTransform(this.suspendedCtx.getTransform()),qt(this.suspendedCtx,r),Ir(r,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),qt(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];let 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){let 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,h,c,d){let u=t.canvas,f=o-c,p=h-d;if(r)if(f<0||p<0||f+s>u.width||p+i>u.height){let m=this.cachedCanvases.getCanvas("maskExtension",s,i),b=m.context;b.drawImage(u,-f,-p),b.globalCompositeOperation="destination-atop",b.fillStyle=r,b.fillRect(0,0,s,i),b.globalCompositeOperation="source-over",u=m.canvas,f=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let m=new Path2D;m.rect(f,p,s,i),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(f,p,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));let g=new Path2D;g.rect(o,h,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(u,f,p,s,i,o,h,s,i),e.restore()}save(t){this.inSMaskMode&&qt(this.ctx,this.suspendedCtx),this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&qt(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,n,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[n]=s;if(!i){n||=s[0]=new Path2D,this[e](t,n);return}if(this.dependencyTracker!==null){let r=e===ne.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-r,i[2]+r,i[1]-r,i[3]+r).recordDependencies(t,["transform"])}n instanceof Path2D||(n=s[0]=zn(n)),T.axialAlignedBoundingBox(i,V(this.ctx),this.current.minMax),this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){let i=this.ctx,n=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof n=="object"&&n?.getPattern){let r=n.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=n.getPattern(i,this,mt(i),it.STROKE,t),r){let a=new Path2D;a.addPath(e,i.getTransform().invertSelf().multiplySelf(r)),e=a}this.rescaleAndStroke(e,!1),i.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,ut.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(it.STROKE,V(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){let i=this.ctx,n=this.current.fillColor,r=this.current.patternFill,a=!1;if(r){let h=n.isModifyingCurrentTransform()?i.getTransform():null;if(this.dependencyTracker?.save(t),i.save(),i.fillStyle=n.getPattern(i,this,mt(i),it.FILL,t),h){let c=new Path2D;c.addPath(e,i.getTransform().invertSelf().multiplySelf(h)),e=c}a=!0}let o=this.current.getClippedPathBoundingBox();this.contentVisible&&o!==null&&(this.pendingEOFill?(i.fill(e,"evenodd"),this.pendingEOFill=!1):i.fill(e)),this.dependencyTracker?.recordDependencies(t,ut.fill),a&&(i.restore(),this.dependencyTracker?.restore(t)),s&&this.consumePath(t,e,o)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,ut.rawFillPath).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Rr}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Dn}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){let i=new Path2D,n=s.getTransform().invertSelf();for(let{transform:r,x:a,y:o,fontSize:h,path:c}of e)c&&i.addPath(c,new DOMMatrix(r).preMultiplySelf(n).translate(a,o).scale(h,-h));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let i=this.commonObjs.get(e),n=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(n.fontMatrix=i.fontMatrix||Ms,(n.fontMatrix[0]===0||n.fontMatrix[3]===0)&&R("Invalid font matrix for font "+e),s<0?(s=-s,n.fontDirection=-1):n.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;let r=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${r}", ${i.fallbackName}`,o="normal";i.black?o="900":i.bold&&(o="bold");let h=i.italic?"italic":"normal",c=s;s<xn?c=xn:s>Pn&&(c=Pn),this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${o} ${c}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);let{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#i(t,e,s){let i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i}paintChar(t,e,s,i,n,r){let a=this.ctx,o=this.current,h=o.font,c=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,u=c&et.FILL_STROKE_MASK,f=!!(c&et.ADD_TO_PATH_FLAG),p=o.patternFill&&!h.missingFile,g=o.patternStroke&&!h.missingFile,m;
2if((h.disableFontFace||f||p||g)&&!h.missingFile&&(m=h.getPathGenerator(this.commonObjs,e)),m&&(h.disableFontFace||p||g)){a.save(),a.translate(s,i),a.scale(d,-d),this.dependencyTracker?.recordCharacterBBox(t,a,h);let b;if(u===et.FILL||u===et.FILL_STROKE)if(n){b=a.getTransform(),a.setTransform(...n);let y=this.#i(m,b,n);a.fill(y)}else a.fill(m);if(u===et.STROKE||u===et.FILL_STROKE)if(r){b||=a.getTransform(),a.setTransform(...r);let{a:y,b:A,c:v,d:w}=b,E=T.inverseTransform(r),S=T.transform([y,A,v,w,0,0],E);T.singularValueDecompose2dScale(S,ct),a.lineWidth*=Math.max(ct[0],ct[1])/d,a.stroke(this.#i(m,b,r))}else a.lineWidth/=d,a.stroke(m);a.restore()}else(u===et.FILL||u===et.FILL_STROKE)&&(a.fillText(e,s,i),this.dependencyTracker?.recordCharacterBBox(t,a,h,d,s,i,()=>a.measureText(e))),(u===et.STROKE||u===et.FILL_STROKE)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,a,h,d,s,i,()=>a.measureText(e)).recordDependencies(t,ut.stroke),a.strokeText(e,s,i));f&&((this.pendingTextPaths||=[]).push({transform:V(a),x:s,y:i,fontSize:d,path:m}),this.dependencyTracker?.recordCharacterBBox(t,a,h,d,s,i))}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return L(this,"isFontSubpixelAAEnabled",s)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,ut.showText).resetBBox(t),this.current.textRenderingMode&et.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());let s=this.current,i=s.font;if(i.isType3Font){this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t);return}let n=s.fontSize;if(n===0){this.dependencyTracker?.recordOperation(t);return}let r=this.ctx,a=s.fontSizeScale,o=s.charSpacing,h=s.wordSpacing,c=s.fontDirection,d=s.textHScale*c,u=e.length,f=i.vertical,p=f?1:-1,g=i.defaultVMetrics,m=n*s.fontMatrix[0],b=s.textRenderingMode===et.FILL&&!i.disableFontFace&&!s.patternFill;r.save(),s.textMatrix&&r.transform(...s.textMatrix),r.translate(s.x,s.y+s.textRise),c>0?r.scale(d,-1):r.scale(d,1);let y,A,v=s.textRenderingMode&et.FILL_STROKE_MASK,w=v===et.FILL||v===et.FILL_STROKE,E=v===et.STROKE||v===et.FILL_STROKE;if(w&&s.patternFill){r.save();let x=s.fillColor.getPattern(r,this,mt(r),it.FILL,t);y=V(r),r.restore(),r.fillStyle=x}if(E&&s.patternStroke){r.save();let x=s.strokeColor.getPattern(r,this,mt(r),it.STROKE,t);A=V(r),r.restore(),r.strokeStyle=x}let S=s.lineWidth,_=s.textMatrixScale;if(_===0||S===0?E&&(S=this.getSinglePixelWidth()):S/=_,a!==1&&(r.scale(a,a),S/=a),r.lineWidth=S,i.isInvalidPDFjsFont){let x=[],U=0;for(let F of e)x.push(F.unicode),U+=F.width;let H=x.join("");if(r.fillText(H,0,0),this.dependencyTracker!==null){let F=r.measureText(H);this.dependencyTracker.recordBBox(t,this.ctx,-F.actualBoundingBoxLeft,F.actualBoundingBoxRight,-F.actualBoundingBoxAscent,F.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=U*m*d,r.restore(),this.compose();return}let C=0,M;for(M=0;M<u;++M){let x=e[M];if(typeof x=="number"){C+=p*x*n/1e3;continue}let U=!1,H=(x.isSpace?h:0)+o,F=x.fontChar,q=x.accent,k,I,j=x.width;if(f){let Q=x.vmetric||g,z=-(x.vmetric?Q[1]:j*.5)*m,G=Q[2]*m;j=Q?-Q[0]:j,k=z/a,I=(C+G)/a}else k=C/a,I=0;let X;if(i.remeasure&&j>0){X=r.measureText(F);let Q=X.width*1e3/n*a;if(j<Q&&this.isFontSubpixelAAEnabled){let z=j/Q;U=!0,r.save(),r.scale(z,1),k/=z}else j!==Q&&(k+=(j-Q)/2e3*n/a)}if(this.contentVisible&&(x.isInFont||i.missingFile)){if(b&&!q)r.fillText(F,k,I),this.dependencyTracker?.recordCharacterBBox(t,r,X?{bbox:null}:i,n/a,k,I,()=>X??r.measureText(F));else if(this.paintChar(t,F,k,I,y,A),q){let Q=k+n*q.offset.x/a,z=I-n*q.offset.y/a;this.paintChar(t,q.fontChar,Q,z,y,A)}}let St=f?j*m-H*c:j*m+H*c;C+=St,U&&r.restore()}f?s.y-=C:s.x+=C*d,r.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){let s=this.ctx,i=this.current,n=i.font,r=i.fontSize,a=i.fontDirection,o=n.vertical?1:-1,h=i.charSpacing,c=i.wordSpacing,d=i.textHScale*a,u=i.fontMatrix||Ms,f=e.length,p=i.textRenderingMode===et.INVISIBLE,g,m,b,y;if(p||r===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(d,a);let A=this.dependencyTracker;
2for(this.dependencyTracker=A?new Ke(A,t):null,g=0;g<f;++g){if(m=e[g],typeof m=="number"){y=o*m*r/1e3,this.ctx.translate(y,0),i.x+=y*d;continue}let v=(m.isSpace?c:0)+h,w=n.charProcOperatorList[m.operatorListId];w?this.contentVisible&&(this.save(),s.scale(r,r),s.transform(...u),this.executeOperatorList(w),this.restore()):R(`Type3 character "${m.operatorListId}" is not available.`);let E=[m.width,0];T.applyTransform(E,u),b=E[0]*r+v,s.translate(b,0),i.x+=b*d}s.restore(),A&&(this.dependencyTracker=A)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,n,r,a){let o=new Path2D;o.rect(i,n,r-i,a-n),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,i,r,n,a).recordClipBox(t,this.ctx,i,r,n,a),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){let i=this.baseTransform||V(this.ctx),n={createCanvasGraphics:(r,a)=>new l(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Ke(this.dependencyTracker,a,!0):null)};s=new Pr(e,this.ctx,n,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
2setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,s=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=xr(this.getObject(t,e)),this.cachedPatterns.set(e,i)),s&&(i.matrix=s),i}shadingFill(t,e){if(!this.contentVisible)return;let s=this.ctx;this.save(t);let i=this._getPattern(t,e);s.fillStyle=i.getPattern(s,this,mt(s),it.SHADING,t);let n=mt(s);if(n){let{width:r,height:a}=s.canvas,o=Ht.slice();T.axialAlignedBoundingBox([0,0,r,a],n,o);let[h,c,d,u]=o;this.ctx.fillRect(h,c,d-h,u-c)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,ut.transform).recordDependencies(t,ut.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){B("Should not call beginInlineImage")}beginImageData(){B("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=V(this.ctx),s)){T.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);let[i,n,r,a]=s,o=new Path2D;o.rect(i,n,r-i,a-n),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,i,r,n,a),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let s=this.ctx;e.isolated||ps("TODO: Support non-isolated groups."),e.knockout&&R("Knockout groups not supported.");let i=V(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let n=Ht.slice();T.axialAlignedBoundingBox(e.bbox,V(s),n);let r=[0,0,s.canvas.width,s.canvas.height];n=T.intersect(n,r)||[0,0,0,0];let a=Math.floor(n[0]),o=Math.floor(n[1]),h=Math.max(Math.ceil(n[2])-a,1),c=Math.max(Math.ceil(n[3])-o,1);this.current.startNewPathAndClipBox([0,0,h,c]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);let u=this.cachedCanvases.getCanvas(d,h,c),f=u.context;f.translate(-a,-o),f.transform(...i);let p=new Path2D,[g,m,b,y]=e.bbox;if(p.rect(g,m,b-g,y-m),e.matrix){let A=new Path2D;A.addPath(p,new DOMMatrix(e.matrix)),p=A}f.clip(p),e.smask&&this.smaskStack.push({canvas:u.canvas,context:f,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(s.setTransform(1,0,0,1,0,0),s.translate(a,o),s.save()),qt(s,f),this.ctx=f,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let s=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();let n=V(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...n);let r=Ht.slice();T.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],n,r),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(r)}}beginAnnotation(t,e,s,i,n,r){if(this.#t(),Me(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){let a=s[2]-s[0],o=s[3]-s[1];if(r&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=a,s[3]=o,T.singularValueDecompose2dScale(V(this.ctx),ct);let{viewportScale:h}=this,c=Math.ceil(a*this.outputScaleX*h),d=Math.ceil(o*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,d);let{canvas:u,context:f}=this.annotationCanvas;this.annotationCanvasMap.set(e,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(ct[0],0,0,-ct[1],0,o*ct[1]),Me(this.ctx)}else{Me(this.ctx),this.endPath(t);let h=new Path2D;h.rect(s[0],s[1],a,o),this.ctx.clip(h)}}
2this.current=new qe(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...i),this.transform(t,...n)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let s=e.count;e=this.getObject(t,e.data,e),e.count=s;let i=this.ctx,n=this._createMaskCanvas(t,e),r=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,n.offsetX,n.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+r.width,n.offsetY,n.offsetY+r.height).recordOperation(t),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s,i=0,n=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.ctx;o.save();let h=V(o);o.transform(s,i,n,r,0,0);let c=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),this.dependencyTracker?.resetBBox(t);for(let d=0,u=a.length;d<u;d+=2){let f=T.transform(h,[s,i,n,r,a[d],a[d+1]]);o.drawImage(c.canvas,f[4],f[5]),this.dependencyTracker?.recordBBox(t,this.ctx,f[4],f[4]+c.canvas.width,f[5],f[5]+c.canvas.height)}o.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let s=this.ctx,i=this.current.fillColor,n=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,ut.transformAndFill);for(let r of e){let{data:a,width:o,height:h,transform:c}=r,d=this.cachedCanvases.getCanvas("maskCanvas",o,h),u=d.context;u.save();let f=this.getObject(t,a,r);In(u,f),u.globalCompositeOperation="source-in",u.fillStyle=n?i.getPattern(u,this,mt(s),it.FILL,t):i,u.fillRect(0,0,o,h),u.restore(),s.save(),s.transform(...c),s.scale(1,-1),Pe(s,d.canvas,0,0,o,h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,s,0,o,0,h),s.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;let s=this.getObject(t,e);if(!s){R("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,n){if(!this.contentVisible)return;let r=this.getObject(t,e);if(!r){R("Dependent image isn't ready yet");return}let a=r.width,o=r.height,h=[];for(let c=0,d=n.length;c<d;c+=2)h.push({transform:[s,0,0,i,n[c],n[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,h)}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;let{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,e){if(!this.contentVisible)return;let s=e.width,i=e.height,n=this.ctx;this.save(t);let{filter:r}=n;r!=="none"&&r!==""&&(n.filter="none"),n.scale(1/s,-1/i);let a;if(e.bitmap)a=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)a=e;else{let c=this.cachedCanvases.getCanvas("inlineImage",s,i).context;kn(c,e),a=this.applyTransferMapsToCanvas(c)}let o=this._scaleImage(a,mt(n));n.imageSmoothingEnabled=Ln(V(n),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,n,0,s,-i,0).recordDependencies(t,ut.imageXObject).recordOperation(t),Pe(n,o.img,0,0,o.paintWidth,o.paintHeight,0,-i,s,i),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible)return;let i=this.ctx,n;if(e.bitmap)n=e.bitmap;else{let r=e.width,a=e.height,h=this.cachedCanvases.getCanvas("inlineImage",r,a).context;kn(h,e),n=this.applyTransferMapsToCanvas(h)}this.dependencyTracker?.resetBBox(t);for(let r of s)i.save(),i.transform(...r.transform),i.scale(1,-1),Pe(i,n,r.x,r.y,r.w,r.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,1,-1,0),i.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,ut.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){this.dependencyTracker?.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){let i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);let n=this.ctx;this.pendingClip?(i||(this.pendingClip===Dn?n.clip(e,"evenodd"):n.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=V(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let 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){let{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform(),r,a;if(s===0&&i===0){let o=Math.abs(e),h=Math.abs(n);if(o===h)if(t===0)r=a=1/o;else{let c=o*t;r=a=c<1?1/c:1}else if(t===0)r=1/o,a=1/h;else{let c=o*t,d=h*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{let o=Math.abs(e*n-s*i),h=Math.hypot(e,s),c=Math.hypot(i,n);if(t===0)r=c/o,a=h/o;else{let d=t*o;r=c>d?c/d:1,a=h>d?h/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:s,current:{lineWidth:i}}=this,[n,r]=this.getScaleForStroking();if(n===r){s.lineWidth=(i||1)*n,s.stroke(t);return}let a=s.getLineDash();e&&s.save(),s.scale(n,r),xs.a=1/n,xs.d=1/r;let o=new Path2D;if(o.addPath(t,xs),a.length>0){let h=Math.max(n,r);s.setLineDash(a.map(c=>c/h)),s.lineDashOffset/=h}
2s.lineWidth=i||1,s.stroke(o),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};for(let l in ne)$t.prototype[l]!==void 0&&($t.prototype[ne[l]]=$t.prototype[l]);var Pt=class{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}},fi=class{#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}[Symbol.iterator](){return this.#t.entries()}},Ot=Symbol("INTERNAL"),pi=class{#t=!1;#e=!1;#i=!1;#s=!0;constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){this.#t=!!(t&ht.DISPLAY),this.#e=!!(t&ht.PRINT),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(this.#i)return this.#s;if(!this.#s)return!1;let{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ot&&B("Internal method `_setVisible` called."),this.#i=s,this.#s=e}},gi=class{#t=null;#e=new Map;#i=null;#s=null;constructor(t,e=ht.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#s=t.order;for(let s of t.groups)this.#e.set(s.id,new pi(e,s));if(t.baseState==="OFF")for(let s of this.#e.values())s._setVisible(Ot,!1);for(let s of t.on)this.#e.get(s)._setVisible(Ot,!0);for(let s of t.off)this.#e.get(s)._setVisible(Ot,!1);this.#i=this.getHash()}}#a(t){let e=t.length;if(e<2)return!0;let s=t[0];for(let i=1;i<e;i++){let n=t[i],r;if(Array.isArray(n))r=this.#a(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return R(`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;if(!t)return ps("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(R(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#a(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return R(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(let e of t.ids){if(!this.#e.has(e))return R(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(let e of t.ids){if(!this.#e.has(e))return R(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(let e of t.ids){if(!this.#e.has(e))return R(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return R(`Unknown optional content policy ${t.policy}.`),!0}return R(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){let i=this.#e.get(t);if(!i){R(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(let n of i.rbGroups)for(let r of n)r!==t&&this.#e.get(r)?._setVisible(Ot,!1,!0);i._setVisible(Ot,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(let i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}let n=this.#e.get(i);if(n)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#i===null||this.getHash()===this.#i}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new Ue;for(let[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}},Gt=class{#t=null;#e=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,s){this._source=t,this.#t=e,this.#e=s}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return O(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#t(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new this.#e(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){this._fullReader?.cancel(t);for(let e of new Set(this._rangeReaders))e.cancel(t)}},zt=class{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}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(){B("Abstract method `read` called")}cancel(t){B("Abstract method `cancel` called")}},Vt=class{_stream=null;constructor(t,e,s){this._stream=t}async read(){B("Abstract method `read` called")}cancel(t){B("Abstract method `cancel` called")}};function Rn(l){return l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength?l.buffer:new Uint8Array(l).buffer}function bs(){for(let l of this._requests)l.resolve({value:void 0,done:!0});this._requests.length=0}var mi=class extends Gt{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,bi,yi);let{pdfDataRangeTransport:e}=t,{initialData:s,progressiveDone:i}=e;if(s?.length>0){let n=Rn(s);this._queuedChunks.push(n)}this._progressiveDone=i,e.addRangeListener((n,r)=>{this.#t(n,r)}),e.addProgressiveReadListener(n=>{this.#t(void 0,n)}),e.addProgressiveDoneListener(()=>{this._fullReader?.progressiveDone(),this._progressiveDone=!0}),e.transportReady()}#t(t,e){let s=Rn(e);if(t===void 0)this._fullReader?this._fullReader._enqueue(s):this._queuedChunks.push(s);else{let i=this._rangeReaders.keys().find(n=>n._begin===t);O(i,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),i._enqueue(s)}}getFullReader(){let t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){let s=super.getRangeReader(t,e);return s&&(s.onDone=()=>this._rangeReaders.delete(s),this._source.pdfDataRangeTransport.requestDataRange(t,e)),s}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}},bi=class extends zt{#t=bs.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);let{pdfDataRangeTransport:e,disableRange:s,disableStream:i}=t._source,{length:n,contentDispositionFilename:r}=e;this._queuedChunks=t._queuedChunks||[];for(let o of this._queuedChunks)this._loaded+=o.byteLength;this._done=t._progressiveDone,this._contentLength=n,this._isStreamingSupported=!i,this._isRangeSupported=!s,dn(r)&&(this._filename=r),this._headersCapability.resolve();let a=this._loaded;Promise.resolve().then(()=>{a>0&&this._loaded===a&&this._callOnProgress()})}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t()}progressiveDone(){this._done||=!0,this._queuedChunks.length===0&&this.#t()}},yi=class extends Vt{#t=bs.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,s){super(t,e,s),this._begin=e}_enqueue(t){this._done||(this._requests.length===0?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#t()),this._done=!0,this.onDone?.())}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this.onDone?.()}};function Nr(l){let t=!0,e=s("filename\\*","i").exec(l);if(e){e=e[1];let c=a(e);return c=unescape(c),c=o(c),c=h(c),n(c)}if(e=r(l),e){let c=h(e);return n(c)}
2if(e=s("filename","i").exec(l),e){e=e[1];let c=a(e);return c=h(c),n(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{let u=new TextDecoder(c,{fatal:!0}),f=gs(d);d=u.decode(f),t=!1}catch{}}return d}function n(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function r(c){let d=[],u,f=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=f.exec(c))!==null;){let[,g,m,b]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[m,b]}let p=[];for(let g=0;g<d.length&&g in d;++g){let[m,b]=d[g];b=a(b),m&&(b=unescape(b),g===0&&(b=o(b))),p.push(b)}return p.join("")}function a(c){if(c.startsWith('"')){let d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){let f=d[u].indexOf('"');f!==-1&&(d[u]=d[u].slice(0,f),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function o(c){let d=c.indexOf("'");if(d===-1)return c;let u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return i(u,p)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,m){return String.fromCharCode(parseInt(m,16))}),i(u,p);try{p=atob(p)}catch{}return i(u,p)})}return""}function Wn(l,t){let e=new Headers;if(!l||!t||typeof t!="object")return e;for(let s in t){let i=t[s];i!==void 0&&e.append(s,i)}return e}function ys(l){return URL.parse(l)?.origin??null}function Xn({responseHeaders:l,isHttp:t,rangeChunkSize:e,disableRange:s}){let i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(l.get("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||l.get("Accept-Ranges")!=="bytes"||(l.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Yn(l){let t=l.get("Content-Disposition");if(t){let e=Nr(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(dn(e))return e}return null}function As(l,t){return new jt(`Unexpected server response (${l}) while retrieving PDF "${t.href}".`,l,l===404||l===0&&t.protocol==="file:")}function Kn(l,t){if(l!==t)throw new Error(`Expected range response-origin "${l}" to match "${t}".`)}function qn(l,t,e,s){return fetch(l,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function Qn(l,t){if(l!==200&&l!==206)throw As(l,t)}function ws(l){if(l instanceof Uint8Array)return l.buffer;if(l instanceof ArrayBuffer)return l;throw new Error(`getArrayBuffer - unexpected data: ${l}`)}var Ai=class extends Gt{_responseOrigin=null;constructor(t){super(t,wi,vi);let{httpHeaders:e,url:s}=t;O(/https?:/.test(s.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Wn(!0,e)}},wi=class extends zt{_abortController=new AbortController;_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:s,length:i,rangeChunkSize:n,url:r,withCredentials:a}=t._source;this._contentLength=i,this._isStreamingSupported=!s,this._isRangeSupported=!e;let o=new Headers(t.headers);qn(r,o,a,this._abortController).then(h=>{t._responseOrigin=ys(h.url),Qn(h.status,r),this._reader=h.body.getReader();let c=h.headers,{allowRangeRequests:d,suggestedLength:u}=Xn({responseHeaders:c,isHttp:!0,rangeChunkSize:n,disableRange:e});this._isRangeSupported=d,this._contentLength=u||this._contentLength,this._filename=Yn(c),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new yt("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:ws(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},vi=class extends Vt{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);let{url:i,withCredentials:n}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`),qn(i,r,n,this._abortController).then(a=>{let o=ys(a.url);Kn(o,t._responseOrigin),Qn(a.status,i),this._reader=a.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:ws(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},Ps=200,Nn=206;function Fr(l){return typeof l!="string"?l:gs(l).buffer}var Ei=class extends Gt{#t=new WeakMap;_responseOrigin=null;constructor(t){super(t,Si,_i);let{httpHeaders:e,url:s}=t;this.url=s,this.isHttp=/https?:/.test(s.protocol),this.headers=Wn(this.isHttp,e)}_request(t){let e=new XMLHttpRequest,s={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#t.set(e,s),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(let[i,n]of this.headers)e.setRequestHeader(i,n);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.validateStatus=i=>i===Nn||i===Ps):s.validateStatus=i=>i===Ps,e.responseType="arraybuffer",O(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#i.bind(this,e),e.onprogress=this.#e.bind(this,e),e.send(null),e}#e(t,e){this.#t.get(t)?.onProgress?.(e)}#i(t,e){let s=this.#t.get(t);if(!s||(t.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),t.readyState!==4)||!this.#t.has(t))return;if(this.#t.delete(t),t.status===0&&this.isHttp){s.onError(t.status);return}let i=t.status||Ps;if(!s.validateStatus(i)){s.onError(t.status);return}let n=Fr(t.response);if(i===Nn){let r=t.getResponseHeader("Content-Range");/bytes (\d+)-(\d+)\/(\d+)/.test(r)?s.onDone(n):(R('Missing or invalid "Content-Range" header.'),s.onError(0))}else n?s.onDone(n):s.onError(t.status)}
2_abortRequest(t){this.#t.has(t)&&(this.#t.delete(t),t.abort())}getRangeReader(t,e){let s=super.getRangeReader(t,e);return s&&(s.onClosed=()=>this._rangeReaders.delete(s)),s}},Si=class extends zt{#t=bs.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t);let{length:e}=t._source;this._contentLength=e,this._fullRequestXhr=t._request({onHeadersReceived:this.#e.bind(this),onDone:this.#i.bind(this),onError:this.#s.bind(this),onProgress:this.#a.bind(this)})}#e(){let t=this._stream,{disableRange:e,rangeChunkSize:s}=t._source,i=this._fullRequestXhr;t._responseOrigin=ys(i.responseURL);let n=i.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(h=>{let[c,...d]=h.split(": ");return[c,d.join(": ")]}):[]),{allowRangeRequests:a,suggestedLength:o}=Xn({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:s,disableRange:e});a&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=Yn(r),this._isRangeSupported&&t._abortRequest(i),this._headersCapability.resolve()}#i(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,this._cachedChunks.length===0&&this.#t()}#s(t){this._storedError=As(t,this._stream.url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#a(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#t(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}},_i=class extends Vt{#t=bs.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,s){super(t,e,s),this._requestXhr=t._request({begin:e,end:s,onHeadersReceived:this.#e.bind(this),onDone:this.#i.bind(this),onError:this.#s.bind(this),onProgress:null})}#e(){let t=ys(this._requestXhr?.responseURL);try{Kn(t,this._stream._responseOrigin)}catch(e){this._storedError=e,this.#s(0)}}#i(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#t(),this.onClosed?.()}#s(t){this._storedError??=As(t,this._stream.url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}};function Jn(l){let{Readable:t}=process.getBuiltinModule("stream");return typeof t.toWeb=="function"?t.toWeb(l):process.getBuiltinModule("module").createRequire(import.meta.url)("node-readable-to-web-readable-stream").makeDefaultReadableStreamFromNodeReadable(l)}var Ci=class extends Gt{constructor(t){super(t,Ti,xi);let{url:e}=t;O(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}},Ti=class extends zt{_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:s,length:i,rangeChunkSize:n,url:r}=t._source;this._contentLength=i,this._isStreamingSupported=!s,this._isRangeSupported=!e;let a=process.getBuiltinModule("fs");a.promises.lstat(r).then(o=>{let h=a.createReadStream(r),c=Jn(h);this._reader=c.getReader();let{size:d}=o;d<=2*n&&(this._isRangeSupported=!1),this._contentLength=d,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new yt("Streaming is disabled.")),this._headersCapability.resolve()}).catch(o=>{o.code==="ENOENT"&&(o=As(0,r)),this._headersCapability.reject(o)})}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:ws(t),done:!1})}cancel(t){this._reader?.cancel(t)}},xi=class extends Vt{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);let{url:i}=t._source,n=process.getBuiltinModule("fs");try{let r=n.createReadStream(i,{start:e,end:s-1}),a=Jn(r);this._reader=a.getReader(),this._readCapability.resolve()}catch(r){this._readCapability.reject(r)}}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:ws(t),done:!1}}cancel(t){this._reader?.cancel(t)}},te=Symbol("INITIAL_DATA"),Or=()=>At(lt({},Promise.withResolvers()),{data:te}),Qe=class{#t=new Map;#e(t){return this.#t.getOrInsertComputed(t,Or)}get(t,e=null){if(e){let i=this.#e(t);return i.promise.then(()=>e(i.data)),null}let s=this.#t.get(t);if(!s||s.data===te)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){let e=this.#t.get(t);return!!e&&e.data!==te}delete(t){let e=this.#t.get(t);return!e||e.data===te?!1:(this.#t.delete(t),!0)}resolve(t,e=null){let s=this.#e(t);s.data=e,s.resolve()}clear(){for(let{data:t}of this.#t.values())t?.bitmap?.close();this.#t.clear()}*[Symbol.iterator](){for(let[t,{data:e}]of this.#t)e!==te&&(yield[t,e])}},Br=1e5,Fn=30,pe=class l{#t=Promise.withResolvers();#e=null;#i=!1;#s=!!globalThis.FontInspector?.enabled;#a=null;#r=null;#n=0;#o=0;#h=null;#l=null;#u=0;#d=0;#f=Object.create(null);#m=[];#g=null;#c=[];#p=new WeakMap;#b=null;static#A=new Map;static#y=new Map;static#C=new WeakMap;static#S=null;static#v=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#g=t;else if(typeof t=="object")this.#g=new ReadableStream({start(o){o.enqueue(t),o.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#l=e,this.#d=s.scale*vt.pixelRatio,this.#u=s.rotation,this.#r={div:null,properties:null,ctx:null};let{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;this.#b=[1,0,0,-1,-r,a+n],this.#o=i,this.#n=n,l.#M(),e.style.setProperty("--min-font-size",l.#S),Mt(e,s),this.#t.promise.finally(()=>{l.#v.delete(this),this.#r=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=K.platform;return L(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#h.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#a??=e.lang,Object.assign(this.#f,e.styles),this.#x(e.items),t()},this.#t.reject)};return this.#h=this.#g.getReader(),l.#v.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let s=t.scale*vt.pixelRatio,i=t.rotation;if(i!==this.#u&&(e?.(),this.#u=i,Mt(this.#l,{rotation:i})),s!==this.#d){e?.(),this.#d=s;let n={div:null,properties:null,ctx:l.#k(this.#a)};for(let r of this.#c)n.properties=this.#p.get(r),n.div=r,this.#_(n)}}cancel(){let t=new yt("TextLayer task cancelled.");this.#h?.cancel(t).catch(()=>{}),this.#h=null,this.#t.reject(t)}get textDivs(){return this.#c}get textContentItemsStr(){return this.#m}#x(t){if(this.#i)return;this.#r.ctx??=l.#k(this.#a);let e=this.#c,s=this.#m;for(let i of t){if(e.length>Br){R("Ignoring additional textDivs for performance reasons."),this.#i=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){let n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id&&this.#e.setAttribute("id",`${i.id}`),i.tag==="Artifact"&&(this.#e.ariaHidden=!0),n.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(i.str),this.#w(i)}}#w(t){let e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#c.push(e);let i=T.transform(this.#b,t.transform),n=Math.atan2(i[1],i[0]),r=this.#f[t.fontName];r.vertical&&(n+=Math.PI/2);let a=this.#s&&r.fontSubstitution||r.fontFamily;a=l.fontFamilyMap.get(a)||a;let o=Math.hypot(i[2],i[3]),h=o*l.#O(a,r,this.#a),c,d;n===0?(c=i[4],d=i[5]-h):(c=i[4]+h*Math.sin(n),d=i[5]-h*Math.cos(n));let u=e.style;u.left=`${(100*c/this.#o).toFixed(2)}%`,u.top=`${(100*d/this.#n).toFixed(2)}%`,u.setProperty("--font-height",`${o.toFixed(2)}px`),u.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#s&&(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]){let p=Math.abs(t.transform[0]),g=Math.abs(t.transform[3]);p!==g&&Math.max(p,g)/Math.min(p,g)>1.5&&(f=!0)}if(f&&(s.canvasWidth=r.vertical?t.height:t.width),this.#p.set(e,s),this.#r.div=e,this.#r.properties=s,this.#_(this.#r),s.hasText&&this.#e.append(e),s.hasEOL){let p=document.createElement("br");p.setAttribute("role","presentation"),this.#e.append(p)}}#_(t){let{div:e,properties:s,ctx:i}=t,{style:n}=e;if(s.canvasWidth!==0&&s.hasText){let{fontFamily:r}=n,{canvasWidth:a,fontSize:o}=s;l.#P(i,o*this.#d,r);let{width:h}=i.measureText(e.textContent);h>0&&n.setProperty("--scale-x",a*this.#d/h)}s.angle!==0&&n.setProperty("--rotate",`${s.angle}deg`)}static cleanup(){if(!(this.#v.size>0)){this.#A.clear();for(let{canvas:t}of this.#y.values())t.remove();this.#y.clear()}}static#k(t=null){let e=this.#y.get(t||="");if(!e){let 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),this.#C.set(e,{size:0,family:""})}return e}static#P(t,e,s){let i=this.#C.get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)}static#M(){if(this.#S!==null)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#S=t.getBoundingClientRect().height,t.remove()}static#O(t,e,s){let i=this.#A.get(t);if(i)return i;let n=this.#k(s);n.canvas.width=n.canvas.height=Fn,this.#P(n,Fn,t);let r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);
2n.canvas.width=n.canvas.height=0;let h=.8;return a?h=a/(a+o):(K.platform.isFirefox&&R("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),this.#A.set(t,h),h}},Ur=100;function Hr(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});let t=new Pi,{docId:e}=t,s=l.url?Er(l.url):null,i=l.data?Sr(l.data):null,n=l.httpHeaders||null,r=l.withCredentials===!0,a=l.password??null,o=l.range instanceof Je?l.range:null,h=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:2**16,c=l.worker instanceof ge?l.worker:null,d=l.verbosity,u=typeof l.docBaseUrl=="string"&&!ms(l.docBaseUrl)?l.docBaseUrl:null,f=_e(l.cMapUrl),p=l.cMapPacked!==!1,g=l.CMapReaderFactory||(rt?si:Ge),m=_e(l.iccUrl),b=_e(l.standardFontDataUrl),y=l.StandardFontDataFactory||(rt?ii:We),A=_e(l.wasmUrl),v=l.WasmFactory||(rt?ni:Ye),w=l.stopAtErrors!==!0,E=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,S=l.isEvalSupported!==!1,_=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!rt,C=typeof l.isImageDecoderSupported=="boolean"?l.isImageDecoderSupported:!rt&&(K.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,x=typeof l.disableFontFace=="boolean"?l.disableFontFace:rt,U=l.fontExtraProperties===!0,H=l.enableXfa===!0,F=l.ownerDocument||globalThis.document,q=l.disableRange===!0,k=l.disableStream===!0,I=l.disableAutoFetch===!0,j=l.pdfBug===!0,X=l.CanvasFactory||(rt?ei:Js),St=l.FilterFactory||(rt?ti:Zs),Q=l.enableHWA===!0,z=l.useWasm!==!1,G=l.pagesMapper||new Bs,gt=o?o.length:l.length??NaN,Rt=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!rt&&!x,pt=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:!!(g===Ge&&y===We&&v===Ye&&f&&b&&A&&Zt(f,document.baseURI)&&Zt(b,document.baseURI)&&Zt(A,document.baseURI)),J=null;rr(d);let vs={canvasFactory:new X({ownerDocument:F,enableHWA:Q}),filterFactory:new St({docId:e,ownerDocument:F}),cMapReaderFactory:pt?null:new g({baseUrl:f,isCompressed:p}),standardFontDataFactory:pt?null:new y({baseUrl:b}),wasmFactory:pt?null:new v({baseUrl:A})};c||(c=ge.create({verbosity:d,port:Pt.workerPort}),t._worker=c);let Xt={docId:e,apiVersion:"5.5.207",data:i,password:a,disableAutoFetch:I,rangeChunkSize:h,length:gt,docBaseUrl:u,enableXfa:H,evaluatorOptions:{maxImageSize:E,disableFontFace:x,ignoreErrors:w,isEvalSupported:S,isOffscreenCanvasSupported:_,isImageDecoderSupported:C,canvasMaxAreaInBytes:M,fontExtraProperties:U,useSystemFonts:Rt,useWasm:z,useWorkerFetch:pt,cMapUrl:f,iccUrl:m,standardFontDataUrl:b,wasmUrl:A}},Yt={ownerDocument:F,pdfBug:j,styleElement:J,enableHWA:Q,loadingParams:{disableAutoFetch:I,enableXfa:H}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");let tr=c.messageHandler.sendWithPromise("GetDocRequest",Xt,i?[i.buffer]:null),Es;if(o)Es=new mi({pdfDataRangeTransport:o,disableRange:q,disableStream:k});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let Ss=Zt(s)?Ai:rt?Ci:Ei;Es=new Ss({url:s,length:gt,httpHeaders:n,withCredentials:r,rangeChunkSize:h,disableRange:q,disableStream:k})}return tr.then(Ss=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");let fn=new xt(e,Ss,c.port),er=new Ii(fn,t,Es,Yt,vs,G);t._transport=er,fn.send("Ready",null)})}).catch(t._capability.reject),t}var Pi=class l{static#t=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${l.#t++}`;destroyed=!1;onPassword=null;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?.destroy(),this._worker=null}async getData(){return this._transport.getData()}},Je=class{#t=Promise.withResolvers();#e=[];#i=[];#s=[];constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,Object.defineProperty(this,"onDataProgress",{value:()=>{jn("`PDFDataRangeTransport.prototype.onDataProgress` - method was removed, since loading progress is now reported automatically through the `PDFDataTransportStream` class (and related code).")}})}addRangeListener(t){this.#s.push(t)}addProgressiveReadListener(t){this.#i.push(t)}addProgressiveDoneListener(t){this.#e.push(t)}onDataRange(t,e){for(let s of this.#s)s(t,e)}onDataProgressiveRead(t){this.#t.promise.then(()=>{for(let e of this.#i)e(t)})}onDataProgressiveDone(){this.#t.promise.then(()=>{for(let t of this.#e)t()})}transportReady(){this.#t.resolve()}requestDataRange(t,e){B("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},Mi=class{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return L(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{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()}extractPages(t){return this._transport.extractPages(t)}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()}},ki=class{#t=!1;#e=null;constructor(t,e,s,i,n=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=n?new Oe:null,this._pdfBug=n,this.commonObjs=s.commonObjs,this.objs=new Qe,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#e=i}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-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 oe({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){let{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 L(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}
2render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:n=_t.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1,recordOperations:f=!1,operationsFilter:p=null}){this._stats?.time("Overall");let g=this._transport.getRenderingIntent(i,n,d,u),{renderingIntent:m,cacheKey:b}=g;this.#t=!1,o||=this._transport.getOptionalContentConfig(m);let y=this._intentStates.getOrInsertComputed(b,Ds);y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);let A=!!(m&ht.PRINT);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g));let v=!!(this._pdfBug&&globalThis.StepperManager?.enabled),w=!this.recordedBBoxes&&(f||v),E=C=>{if(y.renderTasks.delete(S),w){let M=S.gfx?.dependencyTracker.take();M&&(S.stepper&&S.stepper.setOperatorBBoxes(M,S.gfx.dependencyTracker.takeDebugMetadata()),f&&(this.recordedBBoxes=M))}A&&(this.#t=!0),this.#i(),C?(S.capability.reject(C),this._abortOperatorList({intentState:y,reason:C instanceof Error?C:new Error(C)})):S.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},S=new Di({callback:E,params:{canvas:e,canvasContext:t,dependencyTracker:w?new oi(e,y.operatorList.length,v):null,viewport:s,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:p});(y.renderTasks||=new Set).add(S);let _=S.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([C,M])=>{if(this.destroyed){E();return}if(this._stats?.time("Rendering"),!(M.renderingIntent&m))throw new Error("Mu
2st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");S.initializeGraphics({transparency:C,optionalContentConfig:M}),S.operatorListChanged()}).catch(E),_}getOperatorList({intent:t="display",annotationMode:e=_t.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){function n(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o))}let r=this._transport.getRenderingIntent(t,e,s,i,!0),a=this._intentStates.getOrInsertComputed(r.cacheKey,Ds),o;return a.opListReadCapability||(o=Object.create(null),o.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>ae.textContent(i));let e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(let i of e)s.lang??=i.lang,Object.assign(s.styles,i.styles),s.items.push(...i.items);return s}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;let e=this.#i();return t&&e&&(this._stats&&=new Oe),e}#i(){if(!this.#t||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}_startRenderPage(t,e){let 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(let s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#i()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){let{map:n,transfer:r}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},void 0,r).getReader(),h=this._intentStates.get(e);h.streamReader=o;let c=()=>{o.read().then(({value:d,done:u})=>{if(u){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,h),c())},d=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(let u of h.renderTasks)u.operatorListChanged();this.#i()}if(h.displayReadyCapability)h.displayReadyCapability.reject(d);else if(h.opListReadCapability)h.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof le){let i=Ur;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 yt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}},ge=class l{#t=Promise.withResolvers();#e=null;#i=null;#s=null;static#a=0;static#r=!1;static#n=new WeakMap;static{rt&&(this.#r=!0,Pt.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let s=URL.parse(t);if(!s?.origin||s.origin==="null")return!1;let i=new URL(e,s);return s.origin===i.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{if(jn("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:s=ar()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(l.#n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");l.#n.set(e,this),this.#h(e)}else this.#l()}get promise(){return this.#t.promise}#o(){this.#t.resolve(),this.#e.send("configure",{verbosity:this.verbosity})}get port(){return this.#i}get messageHandler(){return this.#e}#h(t){this.#i=t,this.#e=new xt("main","worker",t),this.#e.on("ready",()=>{}),this.#o()}#l(){if(l.#r||l.#d){this.#u();return}let{workerSrc:t}=l;try{l._isSameOrigin(window.location,t)||(t=l._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),s=new xt("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this.#t.reject(new Error("Worker was destroyed")):this.#u()},n=new AbortController;e.addEventListener("error",()=>{this.#s||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this.#e=s,this.#i=e,this.#s=e,this.#o()}),s.on("ready",a=>
2{if(n.abort(),this.destroyed){i();return}try{r()}catch{this.#u()}});let r=()=>{let a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{ps("The worker has been disabled.")}this.#u()}#u(){l.#r||(R("Setting up fake worker."),l.#r=!0),l._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this.#t.reject(new Error("Worker was destroyed"));return}let e=new Qs;this.#i=e;let s=`fake${l.#a++}`,i=new xt(s+"_worker",s,e);t.setup(i,e),this.#e=new xt(s,s+"_worker",e),this.#o()}).catch(t=>{this.#t.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#s?.terminate(),this.#s=null,l.#n.delete(this.#i),this.#i=null,this.#e?.destroy(),this.#e=null}static create(t){let e=this.#n.get(t?.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new l(t)}static get workerSrc(){if(Pt.workerSrc)return Pt.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#d(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return L(this,"_setupFakeWorkerGlobal",(async()=>this.#d?this.#d:(await import(this.workerSrc)).WorkerMessageHandler)())}},Ii=class{downloadInfoCapability=Promise.withResolvers();#t=null;#e=new Map;#i=null;#s=new Map;#a=new Map;#r=new Map;#n=null;#o=null;constructor(t,e,s,i,n,r){this.messageHandler=t,this.loadingTask=e,this.#i=s,this.commonObjs=new Qe,this.fontLoader=new Ws({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler(),this.pagesMapper=r,this.pagesMapper.addListener(this.#h.bind(this))}#h({type:t,pageNumbers:e}){if(t==="copy"){this.#o=new Map;for(let r of e)this.#o.set(r,{proxy:this.#s.get(r-1)||null,promise:this.#a.get(r-1)||null});return}if(t==="delete")for(let r of e)this.#s.delete(r-1),this.#a.delete(r-1);let s=new Map,i=new Map,{pagesMapper:n}=this;for(let r=0,a=n.pagesNumber;r<a;r++){let o=n.getPrevPageNumber(r+1);if(o<0){let{proxy:u,promise:f}=this.#o?.get(-o)||{};u&&s.set(r,u),f&&i.set(r,f);continue}let h=o-1,c=this.#s.get(h);c&&s.set(r,c);let d=this.#a.get(h);d&&i.set(r,d)}this.#s=s,this.#a=i}#l(t,e=null){return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#u({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:st(Math.round(t/e*100),0,100)})}get annotationStorage(){return L(this,"annotationStorage",new ue)}getRenderingIntent(t,e=_t.ENABLE,s=null,i=!1,n=!1){let r=ht.DISPLAY,a=de;switch(t){case"any":r=ht.ANY;break;case"display":break;case"print":r=ht.PRINT;break;default:R(`getRenderingIntent - invalid intent: ${t}`)}let o=r&ht.PRINT&&s instanceof He?s:this.annotationStorage;switch(e){case _t.DISABLE:r+=ht.ANNOTATIONS_DISABLE;break;case _t.ENABLE:break;case _t.ENABLE_FORMS:r+=ht.ANNOTATIONS_FORMS;break;case _t.ENABLE_STORAGE:r+=ht.ANNOTATIONS_STORAGE,a=o.serializable;break;default:R(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(r+=ht.IS_EDITING),n&&(r+=ht.OPLIST);let{ids:h,hash:c}=o.modifiedIds,d=[r,a.hash,c];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#n?.reject(new Error("Worker was destroyed during onPassword callback"));let t=[];for(let s of this.#s.values())t.push(s._destroy());this.#s.clear(),this.#a.clear(),this.#r.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),pe.cleanup(),this.#i?.cancelAllRequests(new yt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{O(this.#i,"GetReader - no `BasePDFStream` instance available."),this.#t=this.#i.getFullReader(),this.#t.onProgress=n=>this.#u(n),i.onPull=()=>{this.#t.read().then(function({value:n,done:r}){if(r){i.close();return}O(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this.#t.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async s=>{await this.#t.headersReady;let{isStreamingSupported:i,isRangeSupported:n,contentLength:r}=this.#t;return i&&n&&(this.#t.onProgress=null),{isStreamingSupported:i,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(s,i)=>{O(this.#i,"GetRangeReader - no `BasePDFStream` instance available.");let n=this.#i.getRangeReader(s.begin,s.end);
2if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}O(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.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Mi(s,this))}),t.on("DocException",s=>{e._capability.reject(at(s))}),t.on("PasswordRequest",s=>{this.#n=Promise.withResolvers();try{if(!e.onPassword)throw at(s);let i=n=>{n instanceof Error?this.#n.reject(n):this.#n.resolve({password:n})};e.onPassword(i,s.code)}catch(i){this.#n.reject(i)}return this.#n.promise}),t.on("DataLoaded",s=>{this.#u({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#s.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":if("error"in n){let d=n.error;R(`Error during font loading: ${d}`),this.commonObjs.resolve(s,d);break}let r=new vr(n),a=this._params.pdfBug&&globalThis.FontInspector?.enabled?(d,u)=>globalThis.FontInspector.fontAdded(d,u):null,o=new Xs(r,a,n.extra,n.charProcOperatorList);this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!o.fontExtraProperties&&o.data&&o.clearData(),this.commonObjs.resolve(s,o)});break;case"CopyLocalImage":let{imageRef:h}=n;O(h,"The imageRef must be defined.");for(let d of this.#s.values())for(let[,u]of d.objs)if(u?.ref===h)return u.dataLen?(this.commonObjs.resolve(s,structuredClone(u)),u.dataLen):null;break;case"FontPath":this.commonObjs.resolve(s,new Ks(n));break;case"Image":this.commonObjs.resolve(s,n);break;case"Pattern":let c=new Ys(n);this.commonObjs.resolve(s,c.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;let a=this.#s.get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{this.destroyed||this.#u(s)}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");let i=this[s.type];if(!i)throw new Error(`${s.type} not initialized, see the \`useWorkerFetch\` parameter.`);return i.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&R("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#t?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){return this.messageHandler.sendWithPromise("ExtractPages",{pageInfos:t})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));let e=t-1,s=this.pagesMapper.getPageId(t)-1,i=this.#a.get(e);if(i)return i;let n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&this.#r.set(r.refStr,s);let a=new ki(e,r,this,this.pagesMapper,this._params.pdfBug);return this.#s.set(e,a),a});return this.#a.set(e,n),n}async getPageIndex(t){if(!qs(t))throw new Error("Invalid pageIndex request.");let e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#l("GetFieldObjects")}hasJSActions(){return this.#l("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithProm
2ise("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)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#l("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#l("GetOptionalContentConfig").then(e=>new gi(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata";return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>({info:e[0],metadata:e[1]?new fi(e[1]):null,contentDispositionFilename:this.#t?.filename??null,contentLength:this.#t?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#s.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(!0),pe.cleanup()}}cachedPageNumber(t){if(!qs(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=this.#r.get(e);if(s>=0){let i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}},Li=class{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}},Di=class l{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null,enableHWA:f=!1,operationsFilter:p=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=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Li(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=f,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(l.#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.");l.#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());let{viewport:s,transform:i,background:n,dependencyTracker:r}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new $t(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:n}),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),l.#e.delete(this._canvas),t||=new le(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),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._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),l.#e.delete(this._canvas),this.callback())))}},$r="5.5.207",jr="527964698",Ze=class l{#t=null;#e=null;#i;#s=null;#a=!1;#r=!1;#n=null;#o;#h=null;#l=null;static#u=null;static get _keyboardManager(){return L(this,"_keyboardManager",new kt([[["Escape","mac+Escape"],l.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],l.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],l.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],l.prototype._moveToPrevious],[["Home","mac+Home"],l.prototype._moveToBeginning],[["End","mac+End"],l.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#r=!1,this.#n=t):this.#r=!0,this.#l=t?._uiManager||e,this.#o=this.#l._eventBus,this.#i=t?.color?.toUpperCase()||this.#l?.highlightColors.values().next().value||"#FFFF98",l.#u||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#n&&(t.ariaControls=`${this.#n.id}_colorpicker_dropdown`);let e=this.#l._signal;t.addEventListener("click",this.#g.bind(this),{signal:e}),t.addEventListener("keydown",this.#m.bind(this),{signal:e});let s=this.#e=document.createElement("span");return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=this.#i,t.append(s),t}renderMainDropdown(){let t=this.#s=this.#d();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#d(){let t=document.createElement("div"),e=this.#l._signal;t.addEventListener("contextmenu",ft,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#n&&(t.id=`${this.#n.id}_colorpicker_dropdown`);for(let[s,i]of this.#l.highlightColors){let n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",l.#u[s]);let r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.ariaSelected=i===this.#i,n.addEventListener("click",this.#f.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#m.bind(this),{signal:e}),t}#f(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:N.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#g(t);return}let e=t.target.getAttribute("data-color");e&&this.#f(e,t)}_moveToNext(t){if(!this.#p){this.#g(t);return}if(t.target===this.#t){this.#s.firstElementChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#s?.firstElementChild||t.target===this.#t){this.#p&&this._hideDropdownFromKeyboard();return}this.#p||this.#g(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#p){this.#g(t);return}this.#s.firstElementChild?.focus()}_moveToEnd(t){if(!this.#p){this.#g(t);return}this.#s.lastElementChild?.focus()}#m(t){l._keyboardManager.exec(this,t)}#g(t){if(this.#p){this.hideDropdown();return}if(this.#a=t.detail===0,this.#h||(this.#h=new AbortController,window.addEventListener("pointerdown",this.#c.bind(this),{signal:this.#l.combinedSignal(this.#h)})),this.#t.ariaExpanded="true",this.#s){this.#s.classList.remove("hidden");return}let e=this.#s=this.#d();this.#t.append(e)}#c(t){this.#s?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#h?.abort(),this.#h=null}get#p(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#r){if(!this.#p){this.#n?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#a})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#s)return;let e=this.#l.highlightColors.values();for(let s of this.#s.children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}},ts=class l{#t=null;#e=null;#i=null;static#s=null;constructor(t){this.#e=t,this.#i=t._uiManager,l.#s||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;let{editorType:t,colorType:e,color:s}=this.#e,i=this.#t=document.createElement("input");return i.type="color",i.value=s||"#000000",i.className="basicColorPicker",i.tabIndex=0,i.setAttribute("data-l10n-id",l.#s[t]),i.addEventListener("input",()=>{this.#i.updateParams(e,i.value)},{signal:this.#i._signal}),i}update(t){this.#t&&(this.#t.value=t)}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}};function On(l){return Math.floor(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}function Qt(l){return Math.max(0,Math.min(255,255*l))}var es=class{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]}
2static G_rgb([t]){return t=Qt(t),[t,t,t]}static G_HTML([t]){let e=On(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(Qt)}static RGB_HTML(t){return`#${t.map(On).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[Qt(1-Math.min(1,t+i)),Qt(1-Math.min(1,s+i)),Qt(1-Math.min(1,e+i))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){let i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}};var Ri=class{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");let 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){B("Abstract method `_createSVG` called.")}},Wt=class extends Ri{_createSVG(t){return document.createElementNS(wt,t)}},Gr=9,It=new WeakSet,zr=new Date().getTimezoneOffset()*60*1e3,se=class{static create(t){switch(t.data.annotationType){case tt.LINK:return new me(t);case tt.TEXT:return new Fi(t);case tt.WIDGET:switch(t.data.fieldType){case"Tx":return new Oi(t);case"Btn":return t.data.radioButton?new ss(t):t.data.checkBox?new Ui(t):new Hi(t);case"Ch":return new $i(t);case"Sig":return new Bi(t)}return new Et(t);case tt.POPUP:return new be(t);case tt.FREETEXT:return new is(t);case tt.LINE:return new Gi(t);case tt.SQUARE:return new zi(t);case tt.CIRCLE:return new Vi(t);case tt.POLYLINE:return new ns(t);case tt.CARET:return new Xi(t);case tt.INK:return new ye(t);case tt.POLYGON:return new Wi(t);case tt.HIGHLIGHT:return new rs(t);case tt.UNDERLINE:return new Yi(t);case tt.SQUIGGLY:return new Ki(t);case tt.STRIKEOUT:return new qi(t);case tt.STAMP:return new as(t);case tt.FILEATTACHMENT:return new Qi(t);default:return new W(t)}}},W=class l{#t=null;#e=!1;#i=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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return l._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}
2get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:s,rect:i}=this.data,n=-1/0,r=-1/0;if(e?.length>=8){for(let a=0;a<e.length;a+=8)e[a+1]>r?(r=e[a+1],n=e[a+2]):e[a+1]===r&&(n=Math.max(n,e[a+2]));return[n,r]}if(s?.length>=1){for(let a of s)for(let o=0,h=a.length;o<h;o+=2)a[o+1]>r?(r=a[o+1],n=a[o]):a[o+1]===r&&(n=Math.max(n,a[o]));if(n!==1/0)return[n,r]}return i?[i[2],i[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/s,t[1]=100*(t[1]-r)/i,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${ie}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${ie}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#i?.popup||this.popup)?.remove(),this.#i=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#t||={rect:this.data.rect.slice(0)});let{rect:e,popup:s}=t;e&&this.#s(e);let i=this.#i?.popup||this.popup;!i&&s?.text&&(this._createPopup(s),i=this.#i.popup),i&&(i.updateEdited(t),s?.deleted&&(i.remove(),this.#i=null,this.popup=null))}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#i?.popup.resetEdited(),this.#t=null)}#s(t){let{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),e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,i===0?(e.width=`${100*(t[2]-t[0])/n}%`,e.height=`${100*(t[3]-t[1])/r}%`):this.setRotation(i)}_createContainer(t){let{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),!(this instanceof Et)&&!(this instanceof me)&&(n.tabIndex=0);let{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof be){let{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;let g=e.borderStyle.horizontalCornerRadius,m=e.borderStyle.verticalCornerRadius;if(g>0||m>0){let y=`calc(${g}px * var(--total-scale-factor)) / calc(${m}px * var(--total-scale-factor))`;r.borderRadius=y}else if(this instanceof ss){let y=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;r.borderRadius=y}switch(e.borderStyle.style){case Ft.SOLID:r.borderStyle="solid";break;case Ft.DASHED:r.borderStyle="dashed";break;case Ft.BEVELED:R("Unimplemented border style: beveled");break;case Ft.INSET:R("Unimplemented border style: inset");break;case Ft.UNDERLINE:r.borderBottomStyle="solid";break;default:break}let b=e.borderColor||null;b?(this.#e=!0,r.borderColor=T.makeHexColor(b[0]|0,b[1]|0,b[2]|0)):r.borderWidth=0}let h=T.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:f}=i.rawDims;r.left=`${100*(h[0]-u)/c}%`,r.top=`${100*(h[1]-f)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||p===0?(r.width=`${100*a/c}%`,r.height=`${100*o/d}%`):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=this;t%180!==0&&([n,r]=[r,n]),e.style.width=`${100*n/s}%`,e.style.height=`${100*r/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,s,i)=>{let n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=es[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:es[`${r}_rgb`](a)})};return L(this,"_commonActions",{display:e=>{let{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=>{let{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=>{let s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){let s=this._commonActions;for(let i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let s=this._commonActions;for(let[i,n]of Object.entries(e)){let r=s[i];if(r){let a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,s,i,n]=this.data.rect.map(g=>Math.fround(g));if(t.length===8){let[g,m,b,y]=t.subarray(2,6);if(i===g&&n===m&&e===b&&s===y)return}let{style:r}=this.container,a;if(this.#e){let{borderColor:g,borderWidth:m}=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="${m}">`],this.container.classList.add("hasBorder")}let o=i-e,h=n-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";let u=c.createElement("defs");d.append(u);let f=c.createElement("clipPath"),p=`clippath_${this.data.id}`;f.setAttribute("id",p),f.setAttribute("clipPathUnits","objectBoundingBox"),u.append(f);for(let g=2,m=t.length;g<m;g+=8){let b=t[g],y=t[g+1],A=t[g+2],v=t[g+3],w=c.createElement("rect"),E=(A-e)/o,S=(n-y)/h,_=(b-A)/o,C=(y-v)/h;w.setAttribute("x",E),w.setAttribute("y",S),w.setAttribute("width",_),w.setAttribute("height",C),f.append(w),a?.push(`<rect vector-effect="non-scaling-stroke" x="${E}" y="${S}" width="${_}" height="${C}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){let{data:e}=this,s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate),this.#i=new be({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#i||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#i}render(){B("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let s=[];if(this._fieldObjects){let i=this._fieldObjects[t];if(i)for(let{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;let o=typeof a=="string"?a:null,h=document.querySelector(`[data-element-id="${r}"]`);if(h&&!It.has(h)){R(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:h})}return s}for(let i of document.getElementsByName(t)){let{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(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}},Ni=class extends W{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}
2get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}},me=class extends W{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{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,t.overlaidText),i=!0):t.attachment?(this.#e(s,t.attachment,t.overlaidText,t.attachmentDest),i=!0):t.setOCGState?(this.#i(s,t.setOCGState,t.overlaidText),i=!0):t.dest?(this._bindLink(s,t.dest,t.overlaidText),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("linkAnnotation"),i&&(this.contentElement=s,this.container.append(s)),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,s=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t(),s&&(t.title=s)}_bindNamedAction(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),s&&(t.title=s),this.#t()}#e(t,e,s="",i=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:s&&(t.title=s),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#t()}#i(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),s&&(t.title=s),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let i of Object.keys(e.actions)){let n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){let s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){R('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();let{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){let c=new Set(n);for(let d of i){let u=this._fieldObjects[d]||[];for(let{id:f}of u)c.add(f)}for(let d of Object.values(this._fieldObjects))for(let u of d)c.has(u.id)===r&&a.push(u)}else for(let c of Object.values(this._fieldObjects))a.push(...c);let o=this.annotationStorage,h=[];for(let c of a){let{id:d}=c;switch(h.push(d),c.type){case"text":{let f=c.defaultValue||"";o.setValue(d,{value:f});break}case"checkbox":case"radiobutton":{let f=c.defaultValue===c.exportValues;o.setValue(d,{value:f});break}case"combobox":case"listbox":{let f=c.defaultValue||"";o.setValue(d,{value:f});break}default:continue}let u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!It.has(u)){R(`_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:h,name:"ResetForm"}}),!1}}},Fi=class extends W{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let 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.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}
2,Et=class extends W{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return K.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(let[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){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":T.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Gr,n=t.style,r,a=2,o=h=>Math.round(10*h)/10;if(this.data.multiLine){let h=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(h/(De*i))||1,d=h/c;r=Math.min(i,o(d/De))}else{let h=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,o(h/De))}n.fontSize=`calc(${r}px * var(--total-scale-factor))`,n.color=T.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)}},Oi=class extends Et{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){let n=this.annotationStorage;
2for(let r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){let i=t.getValue(e,{value:this.data.fieldValue}),n=i.value||"",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,""));let 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=this.data.password?"password":"text",s.setAttribute("value",a??n),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),It.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;let{datetimeFormat:h,datetimeType:c,timeStep:d}=this.data,u=!!c&&this.enableScripting;h&&(s.title=h),this._setRequired(s,this.data.required),r&&(s.maxLength=r),s.addEventListener("input",p=>{t.setValue(e,{value:p.target.value}),this.setPropertyOnSiblings(s,"value",p.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",p=>{let g=this.data.defaultFieldValue??"";s.value=o.userValue=g,o.formattedValue=null});let f=p=>{let{formattedValue:g}=o;g!=null&&(p.target.value=g),p.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{if(o.focused)return;let{target:m}=g;if(u&&(m.type=c,d&&(m.step=d)),o.userValue){let b=o.userValue;if(u)if(c==="time"){let y=new Date(b),A=[y.getHours(),y.getMinutes(),y.getSeconds()];m.value=A.map(v=>v.toString().padStart(2,"0")).join(":")}else m.value=new Date(b-zr).toISOString().split(c==="date"?"T":".",1)[0];else m.value=b}o.lastCommittedValue=m.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);let m={value(b){o.userValue=b.detail.value??"",u||t.setValue(e,{value:o.userValue.toString()}),b.target.value=o.userValue},formattedValue(b){let{formattedValue:y}=b.detail;o.formattedValue=y,y!=null&&b.target!==document.activeElement&&(b.target.value=y);let A={formattedValue:y};u&&(A.value=y),t.setValue(e,A)},selRange(b){b.target.setSelectionRange(...b.detail.selRange)},charLimit:b=>{let{charLimit:y}=b.detail,{target:A}=b;if(y===0){A.removeAttribute("maxLength");return}A.setAttribute("maxLength",y);let v=o.userValue;!v||v.length<=y||(v=v.slice(0,y),A.value=o.userValue=v,t.setValue(e,{value:v}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:1,selStart:A.selectionStart,selEnd:A.selectionEnd}}))}};this._dispatchEventFromSandbox(m,g)}),s.addEventListener("keydown",g=>{o.commitKey=1;let m=-1;if(g.key==="Escape"?m=0:g.key==="Enter"&&!this.data.multiLine?m=2:g.key==="Tab"&&(o.commitKey=3),m===-1)return;let{value:b}=g.target;o.lastCommittedValue!==b&&(o.lastCommittedValue=b,o.userValue=b,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:m,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});let p=f;f=null,s.addEventListener("blur",g=>{if(!o.focused||!g.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{target:m}=g,{value:b}=m;if(u){if(b&&c==="time"){let y=b.split(":").map(A=>parseInt(A,10));b=new Date(2e3,0,1,y[0],y[1],y[2]||0).valueOf(),m.step=""}else b.includes("T")||(b=`${b}T00:00`),b=new Date(b).valueOf();m.type="text"}o.userValue=b,o.lastCommittedValue!==b&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:o.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}),p(g)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",g=>{o.lastCommittedValue=null;let{data:m,target:b}=g,{value:y,selectionStart:A,selectionEnd:v}=b,w=A,E=v;
3switch(g.inputType){case"deleteWordBackward":{let S=y.substring(0,A).match(/\w*[^\w]*$/);S&&(w-=S[0].length);break}case"deleteWordForward":{let S=y.substring(A).match(/^[^\w]*\w*/);S&&(E+=S[0].length);break}case"deleteContentBackward":A===v&&(w-=1);break;case"deleteContentForward":A===v&&(E+=1);break}g.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,change:m||"",willCommit:!1,selStart:w,selEnd:E}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(f&&s.addEventListener("blur",f),this.data.comb){let g=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.letterSpacing=`calc(${g}px * var(--total-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}},Bi=class extends Et{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}},Ui=class extends Et{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,s=e.id,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");let 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=0,n.addEventListener("change",r=>{let{name:a,checked:o}=r.target;for(let h of this._getElementsByName(a,s)){let c=o&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{let a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{let 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}},ss=class extends Et{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,s=e.id,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(let r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});let 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=0,n.addEventListener("change",r=>{let{name:a,checked:o}=r.target;for(let h of this._getElementsByName(a,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{let a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){let r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{let o={value:h=>{let c=r===h.detail.value;for(let d of this._getElementsByName(h.target.name)){let u=c&&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}},Hi=class extends me{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}},$i=class extends Et{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let 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=0;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",c=>{let d=this.data.defaultFieldValue;for(let u of i.options)u.selected=u.value===d});for(let c of this.data.options){let d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,s.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){let c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),r=()=>{c.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}let a=c=>{let d=c?"value":"textContent",{options:u,multiple:f}=i;return f?Array.prototype.filter.call(u,p=>p.selected).map(p=>p[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]},o=a(!1),h=c=>{let d=c.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{let d={value(u){r?.();let f=u.detail.value,p=new Set(Array.isArray(f)?f:[f]);for(let g of i.options)g.selected=p.has(g.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(u){i.multiple=!0},remove(u){let f=i.options,p=u.detail.remove;f[p].selected=!1,i.remove(p),f.length>0&&Array.prototype.findIndex.call(f,m=>m.selected)===-1&&(f[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},clear(u){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(u){let{index:f,displayValue:p,exportValue:g}=u.detail.insert,m=i.children[f],b=document.createElement("option");b.textContent=p,b.value=g,m?m.before(b):i.append(b),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},items(u){let{items:f}=u.detail;for(;i.length!==0;)i.remove(0);for(let p of f){let{displayValue:g,exportValue:m}=p,b=document.createElement("option");b.textContent=g,b.value=m,i.append(b)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},indices(u){let f=new Set(u.detail.indices);for(let p of u.target.options)p.selected=f.has(p.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.addEventListener("input",c=>{let d=a(!0),u=a(!1);t.setValue(e,{value:d}),c.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"]],c=>c.target.value)):i.addEventListener("input",function(c){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},be=class extends W{constructor(t){let{data:e,elements:s,parent:i}=t,n=!!i._commentManager;if(super(t,{isRenderable:!n&&W._hasPopupData(e)}),this.elements=s,n&&W._hasPopupData(e)){let r=this.popup=this.#t();for(let a of s)a.popup=r}else this.popup=null}#t(){return new ji({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,c
3ommentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#t(),s=[];for(let i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",s.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",s.map(i=>`${Bt}${i}`).join(",")),this.container}},ji=class{#t=null;#e=this.#z.bind(this);#i=this.#U.bind(this);#s=this.#D.bind(this);#a=this.#E.bind(this);#r=null;#n=null;#o=null;#h=null;#l=null;#u=null;#d=null;#f=!1;#m=null;#g=null;#c=null;#p=null;#b=null;#A=null;#y=null;#C=null;#S=null;#v=null;#x=!1;#w=null;#_=null;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:h,parentRect:c,open:d,commentManager:u=null}){this.#n=t,this.#S=i,this.#o=r,this.#C=a,this.#u=o,this.#r=e,this.#y=h,this.#d=c,this.#l=s,this.#t=u,this.#w=s[0],this.#h=he.toDateObject(n),this.trigger=s.flatMap(f=>f.getElementsToTriggerPopup()),u||(this.#k(),this.#n.hidden=!0,d&&this.#E())}#k(){if(this.#g)return;this.#g=new AbortController;let{signal:t}=this.#g;for(let e of this.trigger)e.addEventListener("click",this.#a,{signal:t}),e.addEventListener("pointerenter",this.#s,{signal:t}),e.addEventListener("pointerleave",this.#i,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#l)e.container?.addEventListener("keydown",this.#e,{signal:t})}#P(){let t=this.#l.find(e=>e.hasCommentButton);t&&(this.#b=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#p){this.#p.parentNode||this.#w.container.after(this.#p);return}if(this.#b||this.#P(),!this.#b)return;let{signal:t}=this.#g=new AbortController,e=this.#w.hasOwnCommentButton,s=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},i=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},n=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(e){this.#p=this.#w.container;for(let r of this.trigger)r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",s,{signal:t}),r.addEventListener("pointerenter",i,{signal:t}),r.addEventListener("pointerleave",n,{signal:t}),r.classList.add("popupTriggerArea")}else{let r=this.#p=document.createElement("button");r.className="annotationCommentButton";let a=this.#w.container;r.style.zIndex=a.style.zIndex+1,r.tabIndex=0,r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#O(),this.#M(),r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",s,{signal:t}),r.addEventListener("pointerenter",i,{signal:t}),r.addEventListener("pointerleave",n,{signal:t}),a.after(r)}}#M(){if(this.#w.extraPopupElement&&!this.#w.editor)return;this.#p||this.renderCommentButton();let[t,e]=this.#b,{style:s}=this.#p;s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`}#O(){this.#w.extraPopupElement||(this.#p||this.renderCommentButton(),this.#p.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){let{color:t,opacity:e}=this.#w.commentData;return t?this.#u._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#p?.focus()},0)}getData(){let{richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}=this.#w.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}}get elementBeforePopup(){return this.#p}get comment(){return this.#_||=this.#w.commentText,this.#_}set comment(t){t!==this.comment&&(this.#w.commentText=this.#_=t)}focus(){this.#w.container?.focus()}get parentBoundingClientRect(){return this.#w.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#p&&(this.#p.classList.toggle("selected",t),this.#p.ariaExpanded=e)}setSelectedCommentButton(t){this.#p.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#A)return this.#A;let{x:t,y:e,height:s}=this.#p.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#w.layer.getBoundingClientRect();return[(t-i)/r,(e+s-n)/a]}set commentPopupPosition(t){this.#A=t}hasDefaultPopupPosition(){return this.#A===null}get commentButtonPosition(){return this.#b}get commentButtonWidth(){return this.#p.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,s]=this.#A||this.commentButtonPosition.map(h=>h/100),i=this.parentBoundingClientRect,{x:n,y:r,width:a,height:o}=i;this.#t.showDialog(null,this,n+e*a,r+s*o,At(lt({},t),{parentDimensions:i}))}
3render(){if(this.#m)return;let t=this.#m=document.createElement("div");if(t.className="popup",this.#r){let s=t.style.outlineColor=T.makeHexColor(...this.#r);t.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#S?.str){let s=document.createElement("span");s.className="title",e.append(s),{dir:s.dir,str:s.textContent}=this.#S}if(t.append(e),this.#h){let s=document.createElement("time");s.className="popupDate",s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#h.valueOf()})),s.dateTime=this.#h.toISOString(),e.append(s)}Gn({html:this.#L||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#n.append(t)}get#L(){let t=this.#C,e=this.#o;return t?.str&&(!e?.str||e.str===t.str)&&this.#C.html||null}get#R(){return this.#L?.attributes?.style?.fontSize||0}get#B(){return this.#L?.attributes?.style?.color||null}#N(t){let e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#B,fontSize:this.#R?`calc(${this.#R}px * var(--total-scale-factor))`:""}};for(let n of t.split(`
4`))e.push({name:"span",value:n,attributes:i});return s}#z(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#f)&&this.#E()}updateEdited({rect:t,popup:e,deleted:s}){if(this.#t){s?(this.remove(),this.#_=null):e&&(e.deleted?this.remove():(this.#O(),this.#_=e.text)),t&&(this.#b=null,this.#P(),this.#M());return}if(s||e?.deleted){this.remove();return}this.#k(),this.#v||={contentsObj:this.#o,richText:this.#C},t&&(this.#c=null),e&&e.text&&(this.#C=this.#N(e.text),this.#h=he.toDateObject(e.date),this.#o=null),this.#m?.remove(),this.#m=null}resetEdited(){this.#v&&({contentsObj:this.#o,richText:this.#C}=this.#v,this.#v=null,this.#m?.remove(),this.#m=null,this.#c=null)}remove(){if(this.#g?.abort(),this.#g=null,this.#m?.remove(),this.#m=null,this.#x=!1,this.#f=!1,this.#p?.remove(),this.#p=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#T(){if(this.#c!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#u,r=!!this.#d,a=r?this.#d:this.#y;for(let p of this.#l)if(!a||T.intersect(p.data.rect,a)!==null){a=p.data.rect,r=!0;break}let o=T.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),c=r?a[2]-a[0]+5:0,d=o[0]+c,u=o[1];this.#c=[100*(d-i)/e,100*(u-n)/s];let{style:f}=this.#n;f.left=`${this.#c[0]}%`,f.top=`${this.#c[1]}%`}#E(){if(this.#t){this.#t.toggleCommentPopup(this,!1);return}this.#f=!this.#f,this.#f?(this.#D(),this.#n.addEventListener("click",this.#a),this.#n.addEventListener("keydown",this.#e)):(this.#U(),this.#n.removeEventListener("click",this.#a),this.#n.removeEventListener("keydown",this.#e))}#D(){this.#m||this.render(),this.isVisible?this.#f&&this.#n.classList.add("focused"):(this.#T(),this.#n.hidden=!1,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)+1e3)}#U(){this.#n.classList.remove("focused"),!(this.#f||!this.isVisible)&&(this.#n.hidden=!0,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)-1e3)}forceHide(){this.#x=this.isVisible,this.#x&&(this.#n.hidden=!0)}maybeShow(){this.#t||(this.#k(),this.#x&&(this.#m||this.#D(),this.#x=!1,this.#n.hidden=!1))}get isVisible(){return this.#t?!1:this.#n.hidden===!1}},is=class extends W{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=D.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}},Gi=class extends W{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:s}=this,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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},zi=class extends W{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:s}=this,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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Vi=class extends W{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:s}=this,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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ns=class extends W{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:n,height:r}=this;if(!e)return this.container;let a=this.svgFactory.create(n,r,!0),o=[];for(let c=0,d=e.length;c<d;c+=2){let u=e[c]-t[0],f=t[3]-e[c+1];o.push(`${u},${f}`)}o=o.join(" ");let h=this.#t=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",o),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),a.append(h),this.container.append(a),!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Wi=class extends ns{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},Xi=class extends W{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}
4,ye=class extends W{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?D.HIGHLIGHT:D.INK}#i(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#i(e,t),h=this.svgFactory.create(a,o,!0),c=this.#t=this.svgFactory.createElement("svg:g");h.append(c),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),c.setAttribute("stroke-miterlimit",10),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),c.setAttribute("transform",r);for(let d=0,u=s.length;d<u;d++){let f=this.svgFactory.createElement(this.svgElementName);this.#e.push(f),f.setAttribute("points",s[d].join(",")),c.append(f)}return!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:s,rect:i}=t,n=this.#t;if(e>=0&&n.setAttribute("stroke-width",e||1),s)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",s[r].join(","));if(i){let{transform:r,width:a,height:o}=this.#i(this.data.rotation,i);n.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),n.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},rs=class extends W{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=D.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}},Yi=class extends W{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){let s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}},Ki=class extends W{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){let s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}},qi=class extends W{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){let s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}},as=class extends W{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=D.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}
4,Qi=class extends W{#t=null;constructor(t){super(t,{isRenderable:!0});let{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",lt({source:this},e))}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,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;let{isMac:i}=K.platform;return t.addEventListener("keydown",n=>{n.key==="Enter"&&(i?n.metaKey:n.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,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)}},Ji=class l{#t=null;#e=null;#i=null;#s=new Map;#a=null;#r=null;#n=[];#o=!1;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r,structTreeLayer:a,commentManager:o,linkService:h,annotationStorage:c}){this.div=t,this.#t=e,this.#e=s,this.#a=a||null,this.#r=h||null,this.#i=c||new ue,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i,this._commentManager=o||null}hasEditableAnnotations(){return this.#s.size>0}async render(t){let{annotations:e}=t,s=this.div;Mt(s,this.viewport);let i=new Map,n=[],r={data:null,layer:s,linkService:this.#r,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Wt,annotationStorage:this.#i,enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let a of e){if(a.noHTML)continue;let o=a.annotationType===tt.POPUP;if(o){let d=i.get(a.id);if(!d)continue;if(!this._commentManager){n.push(a);continue}r.elements=d}else if(a.rect[2]===a.rect[0]||a.rect[3]===a.rect[1])continue;r.data=a;let h=se.create(r);if(!h.isRenderable)continue;o||(this.#n.push(h),a.popupRef&&i.getOrInsertComputed(a.popupRef,$n).push(h));let c=h.render();a.hidden&&(c.style.visibility="hidden"),h._isEditable&&(this.#s.set(h.data.id,h),this._annotationEditorUIManager?.renderAnnotationElement(h))}await this.#h();for(let a of n){let o=r.elements=i.get(a.id);r.data=a;let h=se.create(r);if(!h.isRenderable)continue;let c=h.render();h.contentElement.id=`${Bt}${a.id}`,a.hidden&&(c.style.visibility="hidden"),o.at(-1).container.after(c)}this.#l()}async#h(){if(this.#n.length===0)return;this.div.replaceChildren();let t=[];if(!this.#o){this.#o=!0;for(let{contentElement:s,data:{id:i}}of this.#n){let n=s.id=`${Bt}${i}`;t.push(this.#a?.getAriaAttributes(n).then(r=>{if(r)for(let[a,o]of r)s.setAttribute(a,o)}))}}this.#n.sort(({data:{rect:[s,i,n,r]}},{data:{rect:[a,o,h,c]}})=>{if(s===n&&i===r)return 1;if(a===h&&o===c)return-1;let d=r,u=i,f=(i+r)/2,p=c,g=o,m=(o+c)/2;if(f>=p&&m<=u)return-1;if(m>=d&&f<=g)return 1;let b=(s+n)/2,y=(a+h)/2;return b-y});let e=document.createDocumentFragment();for(let s of this.#n)e.append(s.container),this._commentManager?(s.extraPopupElement?.popup||s.popup)?.renderCommentButton():s.extraPopupElement&&e.append(s.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#t)for(let s of this.#n)this.#t.addPointerInTextLayer(s.contentElement,!1)}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#r,svgFactory:new Wt,parent:this};for(let s of t){s.borderStyle||=l._defaultBorderStyle,e.data=s;let i=se.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${Bt}${s.id}`,this.#n.push(i))}await this.#h()}update({viewport:t}){let e=this.div;this.viewport=t,Mt(e,{rotation:t.rotation}),this.#l(),e.hidden=!1}#l(){if(!this.#e)return;let t=this.div;for(let[e,s]of this.#e){let i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";let{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s);let r=this.#s.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,i.id,s),r._hasNoCanvas=!1):r.canvas=s)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#s.values())}getEditableAnnotation(t){return this.#s.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:s,rotation:i}=t,n=new Ni({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#r,annotationStorage:this.#i});return n.render(),n.contentElement.id=`${Bt}${s}`,n.createOrUpdatePopup(),this.#n.push(n),n}removeAnnotation(t){let e=this.#n.findIndex(i=>i.data.id===t);if(e<0)return;let[s]=this.#n.splice(e,1);this.#t?.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(let e of t)e.updateFakeAnnotationElement(this);this.#h()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return L(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Ft.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},ke=/\r\n?|\n/g,Zi=class l extends ${#t="";#e=`${this.id}-editor`;#i=null;#s;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=l.prototype,e=n=>n.isEmpty(),s=ce.TRANSLATE_SMALL,i=ce.TRANSLATE_BIG;return L(this,"_keyboardManager",new kt([[["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=D.FREETEXT;constructor(t){super(At(lt({},t),{name:"freeTextEditor"})),this.color=t.color||l._defaultColor||$._defaultLineColor,this.#s=t.fontSize||l._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static initialize(t,e){$.initialize(t,e);let s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}
4static updateDefaultParams(t,e){switch(t){case N.FREETEXT_SIZE:l._defaultFontSize=e;break;case N.FREETEXT_COLOR:l._defaultColor=e;break}}updateParams(t,e){switch(t){case N.FREETEXT_SIZE:this.#a(e);break;case N.FREETEXT_COLOR:this.#r(e);break}}static get defaultPropertiesToUpdate(){return[[N.FREETEXT_SIZE,l._defaultFontSize],[N.FREETEXT_COLOR,l._defaultColor||$._defaultLineColor]]}get propertiesToUpdate(){return[[N.FREETEXT_SIZE,this.#s],[N.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new ts(this),[["colorPicker",this._colorPicker]]}get colorType(){return N.FREETEXT_COLOR}#a(t){let e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-this.#s)*this.parentScale),this.#s=i,this.#o()},s=this.#s;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#r(t){let e=i=>{this.color=i,this.onUpdatedColor()},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:N.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-l._internalPadding*t,-(l._internalPadding+this.#s)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#i=new AbortController;let t=this._uiManager.combinedSignal(this.#i);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#e),this._isDraggable=!0,this.#i?.abort(),this.#i=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&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()}#n(){let t=[];this.editorDiv.normalize();let e=null;for(let s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"||(t.push(l.#h(s)),e=s);return t.join(`
5`)}#o(){let[t,e]=this.parentDimensions,s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{let{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();let t=this.#t,e=this.#t=this.#n().trimEnd();if(t===e)return;let s=i=>{if(this.#t=i,!i){this.remove();return}this.#l(),this._uiManager.rebuild(this),this.#o()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){l._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)}get canChangeContent(){return!0}
5render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#e),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#s}px * var(--total-scale-factor))`,s.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[i,n]=this.parentDimensions;if(this.annotationElementId){let{position:r}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[h,c]=this.pageDimensions,[d,u]=this.pageTranslation,f,p;switch(this.rotation){case 0:f=t+(r[0]-d)/h,p=e+this.height-(r[1]-u)/c;break;case 90:f=t+(r[0]-d)/h,p=e-(r[1]-u)/c,[a,o]=[o,-a];break;case 180:f=t-this.width+(r[0]-d)/h,p=e-(r[1]-u)/c,[a,o]=[-a,-o];break;case 270:f=t+(r[0]-d-this.height*c)/h,p=e+(r[1]-u-this.width*h)/c,[a,o]=[-o,a];break}this.setAt(f*i,p*n,a,o)}else this._moveAfterPaste(t,e);this.#l(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#h(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(ke,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();let i=l.#d(e.getData("text")||"").replaceAll(ke,`
6`);if(!i)return;let n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();let r=n.getRangeAt(0);if(!i.includes(`
vendor: 8,304 bytes, lines 7-12
7`)){r.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),n.collapseToStart();return}let{startContainer:a,startOffset:o}=r,h=[],c=[];if(a.nodeType===Node.TEXT_NODE){let f=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(ke,"")),f!==this.editorDiv){let p=h;for(let g of this.editorDiv.childNodes){if(g===f){p=c;continue}p.push(l.#h(g))}}h.push(a.nodeValue.slice(0,o).replaceAll(ke,""))}else if(a===this.editorDiv){let f=h,p=0;for(let g of this.editorDiv.childNodes)p++===o&&(f=c),f.push(l.#h(g))}this.#t=`${h.join(`
8`)}${i}${c.join(`
9`)}`,this.#l();let d=new Range,u=Math.sumPrecise(h.map(f=>f.length));for(let{firstChild:f}of this.editorDiv.childNodes)if(f.nodeType===Node.TEXT_NODE){let p=f.nodeValue.length;if(u<=p){d.setStart(f,u),d.setEnd(f,u);break}u-=p}n.removeAllRanges(),n.addRange(d)}#l(){if(this.editorDiv.replaceChildren(),!!this.#t)for(let t of this.#t.split(`
10`)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll("\xA0"," ")}static#d(t){return t.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=l._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let i=null;if(t instanceof is){let{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:h,id:c,popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},textContent:m,textPosition:b,parent:{page:{pageNumber:y}}}=t;if(!m||m.length===0)return null;i=t={annotationType:D.FREETEXT,color:Array.from(a),fontSize:r,value:m.join(`
11`),position:b,pageIndex:y-1,rect:o.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:d,comment:f?.str||null,richText:u,creationDate:p,modificationDate:g}}let n=await super.deserialize(t,e,s);return n.#s=t.fontSize,n.color=T.makeHexColor(...t.color),n.#t=l.#d(t.value),n._initialData=i,t.comment&&n.setCommentData(t),n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=$._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(t),{color:e,fontSize:this.#s,value:this.#u()});return this.addComment(s),t?(s.isCopy=!0,s):this.annotationElementId&&!this.#f(s)?null:(s.id=this.annotationElementId,s)}#f(t){let{value:e,fontSize:s,color:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==i[a])||t.pageIndex!==n}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:s}=e;s.fontSize=`calc(${this.#s}px * var(--total-scale-factor))`,s.color=this.color,e.replaceChildren();for(let i of this.#t.split(`
12`)){let n=document.createElement("div");n.append(i?document.createTextNode(i):document.createElement("br")),e.append(n)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}},P=(()=>{class l{static PRECISION=1e-4;toSVGPath(){B("Abstract method `toSVGPath` must be implemented.")}get box(){B("Abstract getter `box` must be implemented.")}serialize(e,s){B("Abstract method `serialize` must be implemented.")}static _rescale(e,s,i,n,r,a){a||=new Float32Array(e.length);for(let o=0,h=e.length;o<h;o+=2)a[o]=s+e[o]*n,a[o+1]=i+e[o+1]*r;return a}static _rescaleAndSwap(e,s,i,n,r,a){a||=new Float32Array(e.length);for(let o=0,h=e.length;o<h;o+=2)a[o]=s+e[o+1]*n,a[o+1]=i+e[o]*r;return a}static _translate(e,s,i,n){n||=new Float32Array(e.length);for(let r=0,a=e.length;r<a;r+=2)n[r]=s+e[r],n[r+1]=i+e[r+1];return n}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,s,i,n,r){switch(r){case 90:return[1-s/i,e/n];case 180:return[1-e/i,1-s/n];case 270:return[s/i,1-e/n];default:return[e/i,s/n]}}static _normalizePagePoint(e,s,i){switch(i){case 90:return[1-s,e];case 180:return[1-e,1-s];case 270:return[s,1-e];default:return[e,s]}}static createBezierPoints(e,s,i,n,r,a){return[(e+5*i)/6,(s+5*n)/6,(5*i+r)/6,(5*n+a)/6,(i+r)/2,(n+a)/2]}}return l})(),os=class l{#t;#e=[];#i;#s;#a=[];#r=new Float32Array(18);#n;#o;#h;#l;#u;#d;#f=[];static#m=8;static#g=2;static#c=l.#m+l.#g;constructor({x:t,y:e},s,i,n,r,a=0){this.#t=s,this.#d=n*i,this.#s=r,this.#r.set([NaN,NaN,NaN,NaN,t,e],6),this.#i=a,this.#l=l.#m*i,this.#h=l.#c*i,this.#u=i,this.#f.push(t,e)}isEmpty(){return isNaN(this.#r[8])}#p(){let t=this.#r.subarray(4,6),e=this.#r.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#n+(t[0]-e[0])/2-s)/n,(this.#o+(t[1]-e[1])/2-i)/r,(this.#n+(e[0]-t[0])/2-s)/n,(this.#o+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#n=t,this.#o=e;let[s,i,n,r]=this.#t,[a,o,h,c]=this.#r.subarray(8,12),d=t-h,u=e-c,f=Math.hypot(d,u);if(f<this.#h)return!1;let p=f-this.#l,g=p/f,m=g*d,b=g*u,y=a,A=o;a=h,o=c,h+=m,c+=b,this.#f?.push(t,e);let v=-b/p,w=m/p,E=v*this.#d,S=w*this.#d;return this.#r.set(this.#r.subarray(2,8),0),this.#r.set([h+E,c+S],4),this.#r.set(this.#r.subarray(14,18),12),this.#r.set([h-E,c-S],16),isNaN(this.#r[6])?(this.#a.length===0&&(this.#r.set([a+E,o+S],2),this.#a.push(NaN,NaN,NaN,NaN,(a+E-s)/n,(o+S-i)/r),this.#r.set([a-E,o-S],14),this.#e.push(NaN,NaN,NaN,NaN,(a-E-s)/n,(o-S-i)/r)),this.#r.set([y,A,a,o,h,c],6),!this.isEmpty()):(this.#r.set([y,A,a,o,h,c],6),Math.abs(Math.atan2(A-o,y-a)-Math.atan2(b,m))<Math.PI/2?([a,o,h,c]=this.#r.subarray(2,6),this.#a.push(NaN,NaN,NaN,NaN,((a+h)/2-s)/n,((o+c)/2-i)/r),[a,o,y,A]=this.#r.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((y+a)/2-s)/n,((A+o)/2-i)/r),!0):([y,A,a,o,h,c]=this.#r.subarray(0,6),this.#a.push(((y+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),[h,c,a,o,y,A]=this.#r.subarray(12,18),this.#e.push(((y+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";let t=this.#a,e=this.#e;if(isNaN(this.#r[6])&&!this.isEmpty())return this.#b();let s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#y(s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#A(s),s.join(" ")}#b(){let[t,e,s,i]=this.#t,[n,r,a,o]=this.#p();return`M${(this.#r[2]-t)/s} ${(this.#r[3]-e)/i} L${(this.#r[4]-t)/s} ${(this.#r[5]-e)/i} L${n} ${r} L${a} ${o} L${(this.#r[16]-t)/s} ${(this.#r[17]-e)/i} L${(this.#r[14]-t)/s} ${(this.#r[15]-e)/i} Z`}#A(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#y(t){let[e,s,i,n]=this.#t,r=this.#r.subarray(4,6),a=this.#r.subarray(16,18),[o,h,c,d]=this.#p();t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${o} ${h} L${c} ${d} L${(a[0]-e)/i} ${(a[1]-s)/n}`)}newFreeDrawOutline(t,e,s,i,n,r){return new ls(t,e,s,i,n,r)}getOutlines(){let t=this.#a,e=this.#e,s=this.#r,[i,n,r,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let d=0,u=o.length-2;d<u;d+=2)o[d]=(this.#f[d]-i)/r,o[d+1]=(this.#f[d+1]-n)/a;if(o[o.length-2]=(this.#n-i)/r,o[o.length-1]=(this.#o-n)/a,isNaN(s[6])&&!this.isEmpty())return this.#C(o);let h=new Float32Array(this.#a.length+24+this.#e.length),c=t.length;for(let d=0;d<c;d+=2){if(isNaN(t[d])){h[d]=h[d+1]=NaN;continue}h[d]=t[d],h[d+1]=t[d+1]}c=this.#v(h,c);for(let d=e.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2){if(isNaN(e[d+u])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[d+u],h[c+1]=e[d+u+1],c+=2}return this.#S(h,c),this.newFreeDrawOutline(h,o,this.#t,this.#u,this.#i,this.#s)}#C(t){let e=this.#r,[s,i,n,r]=this.#t,[a,o,h,c]=this.#p(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(d,t,this.#t,this.#u,this.#i,this.#s)}#S(t,e){let s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#v(t,e){let s=this.#r.subarray(4,6),i=this.#r.subarray(16,18),[n,r,a,o]=this.#t,[h,c,d,u]=this.#p();return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o],e),e+=24}},ls=class extends P{#t;
12#e=new Float32Array(4);#i;#s;#a;#r;#n;constructor(t,e,s,i,n,r){super(),this.#n=t,this.#a=e,this.#t=s,this.#r=i,this.#i=n,this.#s=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(r);let[a,o,h,c]=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/h,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/h,e[d+1]=(e[d+1]-o)/c}toSVGPath(){let t=[`M${this.#n[4]} ${this.#n[5]}`];for(let e=6,s=this.#n.length;e<s;e+=6){if(isNaN(this.#n[e])){t.push(`L${this.#n[e+4]} ${this.#n[e+5]}`);continue}t.push(`C${this.#n[e]} ${this.#n[e+1]} ${this.#n[e+2]} ${this.#n[e+3]} ${this.#n[e+4]} ${this.#n[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){let r=s-t,a=i-e,o,h;switch(n){case 0:o=P._rescale(this.#n,t,i,r,-a),h=P._rescale(this.#a,t,i,r,-a);break;case 90:o=P._rescaleAndSwap(this.#n,t,e,r,a),h=P._rescaleAndSwap(this.#a,t,e,r,a);break;case 180:o=P._rescale(this.#n,s,e,-r,a),h=P._rescale(this.#a,s,e,-r,a);break;case 270:o=P._rescaleAndSwap(this.#n,s,i,-r,-a),h=P._rescaleAndSwap(this.#a,s,i,-r,-a);break}return{outline:Array.from(o),points:[Array.from(h)]}}#o(t){let e=this.#n,s=e[4],i=e[5],n=[s,i,s,i],r=s,a=i,o=s,h=i,c=t?Math.max:Math.min,d=new Float32Array(4);for(let f=6,p=e.length;f<p;f+=6){let g=e[f+4],m=e[f+5];isNaN(e[f])?(T.pointBoundingBox(g,m,n),a>m?(r=g,a=m):a===m&&(r=c(r,g)),h<m?(o=g,h=m):h===m&&(o=c(o,g))):(d[0]=d[1]=1/0,d[2]=d[3]=-1/0,T.bezierBoundingBox(s,i,...e.slice(f,f+6),d),T.rectBoundingBox(d[0],d[1],d[2],d[3],n),a>d[1]?(r=d[0],a=d[1]):a===d[1]&&(r=c(r,d[0])),h<d[3]?(o=d[2],h=d[3]):h===d[3]&&(o=c(o,d[2]))),s=g,i=m}let u=this.#e;u[0]=n[0]-this.#i,u[1]=n[1]-this.#i,u[2]=n[2]-n[0]+2*this.#i,u[3]=n[3]-n[1]+2*this.#i,this.firstPoint=[r,a],this.lastPoint=[o,h]}get box(){return this.#e}newOutliner(t,e,s,i,n,r=0){return new os(t,e,s,i,n,r)}getNewOutline(t,e){let[s,i,n,r]=this.#e,[a,o,h,c]=this.#t,d=n*h,u=r*c,f=s*h+a,p=i*c+o,g=this.newOutliner({x:this.#a[0]*d+f,y:this.#a[1]*u+p},this.#t,this.#r,t,this.#s,e??this.#i);for(let m=2;m<this.#a.length;m+=2)g.add({x:this.#a[m]*d+f,y:this.#a[m+1]*u+p});return g.getOutlines()}},Ae=class{#t;#e;#i;#s=[];#a=[];constructor(t,e=0,s=0,i=!0){let n=[1/0,1/0,-1/0,-1/0],a=10**-4;for(let{x:m,y:b,width:y,height:A}of t){let v=Math.floor((m-e)/a)*a,w=Math.ceil((m+y+e)/a)*a,E=Math.floor((b-e)/a)*a,S=Math.ceil((b+A+e)/a)*a,_=[v,E,S,!0],C=[w,E,S,!1];this.#s.push(_,C),T.rectBoundingBox(v,E,w,S,n)}let o=n[2]-n[0]+2*s,h=n[3]-n[1]+2*s,c=n[0]-s,d=n[1]-s,u=i?-1/0:1/0,f=1/0,p=this.#s.at(i?-1:-2),g=[p[0],p[2]];for(let m of this.#s){let[b,y,A,v]=m;!v&&i?y<f?(f=y,u=b):y===f&&(u=Math.max(u,b)):v&&!i&&(y<f?(f=y,u=b):y===f&&(u=Math.min(u,b))),m[0]=(b-c)/o,m[1]=(y-d)/h,m[2]=(A-d)/h}this.#t=new Float32Array([c,d,o,h]),this.#e=[u,f],this.#i=g}getOutlines(){this.#s.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);let t=[];for(let e of this.#s)e[3]?(t.push(...this.#l(e)),this.#o(e)):(this.#h(e),t.push(...this.#l(e)));return this.#r(t)}#r(t){let e=[],s=new Set;for(let r of t){let[a,o,h]=r;e.push([a,o,r],[a,h,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){let o=e[r][2],h=e[r+1][2];o.push(h),h.push(o),s.add(o),s.add(h)}let i=[],n;for(;s.size>0;){let r=s.values().next().value,[a,o,h,c,d]=r;s.delete(r);let u=a,f=o;for(n=[a,h],i.push(n);;){let p;if(s.has(c))p=c;else if(s.has(d))p=d;else break;s.delete(p),[a,o,h,c,d]=p,u!==a&&(n.push(u,f,a,f===o?o:h),u=a),f=f===o?h:o}n.push(u,f)}return new tn(i,this.#t,this.#e,this.#i)}#n(t){let e=this.#a,s=0,i=e.length-1;for(;s<=i;){let n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1}#o([,t,e]){let s=this.#n(t);this.#a.splice(s,0,[t,e])}#h([,t,e]){let s=this.#n(t);for(let i=s;i<this.#a.length;i++){let[n,r]=this.#a[i];if(n!==t)break;if(n===t&&r===e){this.#a.splice(i,1);return}}for(let i=s-1;i>=0;i--){let[n,r]=this.#a[i];if(n!==t)break;if(n===t&&r===e){this.#a.splice(i,1);return}}}#l(t){let[e,s,i]=t,n=[[e,s,i]],r=this.#n(i);for(let a=0;a<r;a++){let[o,h]=this.#a[a];for(let c=0,d=n.length;c<d;c++){let[,u,f]=n[c];if(!(h<=u||f<=o)){if(u>=o){if(f>h)n[c][1]=h;else{if(d===1)return[];n.splice(c,1),c--,d--}continue}n[c][2]=o,f>h&&n.push([e,h,f])}}}return n}},tn=class extends P{#t;#e;constructor(t,e,s,i){super(),this.#e=t,this.#t=e,this.firstPoint=s,this.lastPoint=i}toSVGPath(){let t=[];for(let e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){let 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){let r=[],a=s-t,o=i-e;for(let h of this.#e){let c=new Array(h.length);for(let d=0;d<h.length;d+=2)c[d]=t+h[d]*a,c[d+1]=i-h[d+1]*o;r.push(c)}return r}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}},we=class extends os{newFreeDrawOutline(t,e,s,i,n,r){return new en(t,e,s,i,n,r)}},en=class extends ls{newOutliner(t,e,s,i,n,r=0){return new we(t,e,s,i,n,r)}},hs=class l extends ${#t=null;#e=0;#i;#s=null;#a=null;#r=null;#n=null;#o=0;#h=null;#l=null;#u=null;#d=!1;#f=null;#m=null;#g=null;#c="";#p;#b="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=D.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=l.prototype;return L(this,"_keyboardManager",new kt([[["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(At(lt({},t),{name:"highlightEditor"})),this.color=t.color||l._defaultColor,this.#p=t.thickness||l._defaultThickness,this.opacity=t.opacity||l._defaultOpacity,this.#i=t.boxes||null,this.#b=t.methodOfCreation||"",this.#c=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#d=!0,this.#y(t),this.#w()):this.#i&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#n=t.focusNode,this.#o=t.focusOffset,this.#A(),this.#w(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#p,methodOfCreation:this.#b}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#A(){let t=new Ae(this.#i,.001);this.#l=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#l.box;let e=new Ae(this.#i,.0025,.001,this._uiManager.direction==="ltr");this.#r=e.getOutlines();let{firstPoint:s}=this.#l;this.#f=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height];let{lastPoint:i}=this.#r;this.#m=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#y({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#l=t;let i=1.5;if(this.#r=t.getNewOutline(this.#p/2+i,.0025),e>=0)this.#u=e,this.#s=s,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#g=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},!0);else if(this.parent){let d=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:l.#_(this.#l.box,(d-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#g,{bbox:l.#_(this.#r.box,d),path:{d:this.#r.toSVGPath()}})}let[n,r,a,o]=t.box;switch(this.rotation){case 0:this.x=n,this.y=r,this.width=a,this.height=o;break;case 90:{let[d,u]=this.parentDimensions;this.x=r,this.y=1-n,this.width=a*u/d,this.height=o*d/u;break}case 180:this.x=1-n,this.y=1-r,this.width=a,this.height=o;break;case 270:{let[d,u]=this.parentDimensions;this.x=1-r,this.y=n,this.width=a*u/d,this.height=o*d/u;break}}let{firstPoint:h}=t;this.#f=[(h[0]-n)/a,(h[1]-r)/o];let{lastPoint:c}=this.#r;this.#m=[(c[0]-n)/a,(c[1]-r)/o]}static initialize(t,e){$.initialize(t,e),l._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case N.HIGHLIGHT_COLOR:l._defaultColor=e;break;case N.HIGHLIGHT_THICKNESS:l._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#m}get commentButtonPosition(){return this.#f}updateParams(t,e){switch(t){case N.HIGHLIGHT_COLOR:this.#C(e);break;case N.HIGHLIGHT_THICKNESS:this.#S(e);break}}static get defaultPropertiesToUpdate(){return[[N.HIGHLIGHT_COLOR,l._defaultColor],[N.HIGHLIGHT_THICKNESS,l._defaultThickness]]}get propertiesToUpdate(){return[[N.HIGHLIGHT_COLOR,this.color||l._defaultColor],[N.HIGHLIGHT_THICKNESS,this.#p||l._defaultThickness],[N.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#a?.updateColor(this.color),super.onUpdatedColor()}#C(t){let e=(n,r)=>{this.color=n,this.opacity=r,this.onUpdatedColor()},s=this.color,i=this.opacity;this.addCommands({cmd:e.bind(this,t,l._defaultOpacity),undo:e.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#S(t){let e=this.#p,s=i=>{this.#p=i,this.#v(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#a=new Ze({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#M())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#M())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#x(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#w(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#x():t&&(this.#w(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#v(t){this.#d&&(this.#y({highlightOutlines:this.#l.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#x(){this.#u===null||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#g),this.#g=null)}#w(t=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#s}=t.drawLayer.draw({bbox:this.#l.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0),this.#g=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},this.#d),this.#h&&(this.#h.style.clipPath=this.#s))}static#_([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}rotate(t){let{drawLayer:e}=this.parent,s;this.#d?(t=(t-this.rotation+360)%360,s=l.#_(this.#l.box,t)):s=l.#_([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#u,{bbox:s,root:{"data-main-rotation":t}}),e.updateProperties(this.#g,{bbox:l.#_(this.#r.box,t),root:{"data-main-rotation":t}})}
12render(){if(this.div)return this.div;let t=super.render();this.#c&&(t.setAttribute("aria-label",this.#c),t.setAttribute("role","mark")),this.#d?t.classList.add("free"):this.div.addEventListener("keydown",this.#k.bind(this),{signal:this._uiManager._signal});let e=this.#h=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#s,this.setDims(),Vn(this,this.#h,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!1}})}#k(t){l._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#P(!0);break;case 1:case 3:this.#P(!1);break}}#P(t){if(!this.#t)return;let e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#n,this.#o)}select(){super.select(),this.#g&&this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#g&&(this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{selected:!1}}),this.#d||this.#P(!1))}get _mustFixPosition(){return!this.#d}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#g,{rootClass:{hidden:!t}}))}#M(){return this.#d?this.rotation:0}#O(){if(this.#d)return null;let[t,e]=this.pageDimensions,[s,i]=this.pageTranslation,n=this.#i,r=new Float32Array(n.length*8),a=0;for(let{x:o,y:h,width:c,height:d}of n){let u=o*t+s,f=(1-h)*e+i;r[a]=r[a+4]=u,r[a+1]=r[a+3]=f,r[a+2]=r[a+6]=u+c*t,r[a+5]=r[a+7]=f-d*e,a+=8}return r}#L(t){return this.#l.serialize(t,this.#M())}static startHighlighting(t,e,{target:s,x:i,y:n}){let{x:r,y:a,width:o,height:h}=s.getBoundingClientRect(),c=new AbortController,d=t.combinedSignal(c),u=f=>{c.abort(),this.#B(t,f)};window.addEventListener("blur",u,{signal:d}),window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("pointerdown",Y,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",ft,{signal:d}),s.addEventListener("pointermove",this.#R.bind(this,t),{signal:d}),this._freeHighlight=new we({x:i,y:n},[r,a,o,h],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#R(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#B(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(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 async deserialize(t,e,s){let i=null;if(t instanceof rs){let{data:{quadPoints:p,rect:g,rotation:m,id:b,color:y,opacity:A,popupRef:v,richText:w,contentsObj:E,creationDate:S,modificationDate:_},parent:{page:{pageNumber:C}}}=t;i=t={annotationType:D.HIGHLIGHT,color:Array.from(y),opacity:A,quadPoints:p,boxes:null,pageIndex:C-1,rect:g.slice(0),rotation:m,annotationElementId:b,id:b,deleted:!1,popupRef:v,richText:w,comment:E?.str||null,creationDate:S,modificationDate:_}}else if(t instanceof ye){let{data:{inkLists:p,rect:g,rotation:m,id:b,color:y,borderStyle:{rawWidth:A},popupRef:v,richText:w,contentsObj:E,creationDate:S,modificationDate:_},parent:{page:{pageNumber:C}}}=t;i=t={annotationType:D.HIGHLIGHT,color:Array.from(y),thickness:A,inkLists:p,boxes:null,pageIndex:C-1,rect:g.slice(0),rotation:m,annotationElementId:b,id:b,deleted:!1,popupRef:v,richText:w,comment:E?.str||null,creationDate:S,modificationDate:_}}let{color:n,quadPoints:r,inkLists:a,opacity:o}=t,h=await super.deserialize(t,e,s);h.color=T.makeHexColor(...n),h.opacity=o||1,a&&(h.#p=t.thickness),h._initialData=i,t.comment&&h.setCommentData(t);let[c,d]=h.pageDimensions,[u,f]=h.pageTranslation;if(r){let p=h.#i=[];for(let g=0;g<r.length;g+=8)p.push({x:(r[g]-u)/c,y:1-(r[g+1]-f)/d,width:(r[g+2]-r[g])/c,height:(r[g+1]-r[g+5])/
12d});h.#A(),h.#w(),h.rotate(h.rotation)}else if(a){h.#d=!0;let p=a[0],g={x:p[0]-u,y:d-(p[1]-f)},m=new we(g,[0,0,c,d],1,h.#p/2,!0,.001);for(let A=0,v=p.length;A<v;A+=2)g.x=p[A]-u,g.y=d-(p[A+1]-f),m.add(g);let{id:b,clipPathId:y}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:m.toSVGPath()}},!0,!0);h.#y({highlightOutlines:m.getOutlines(),highlightId:b,clipPathId:y}),h.#w(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=$._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),s=super.serialize(t);return Object.assign(s,{color:e,opacity:this.opacity,thickness:this.#p,quadPoints:this.#O(),outlines:this.#L(s.rect)}),this.addComment(s),this.annotationElementId&&!this.#N(s)?null:(s.id=this.annotationElementId,s)}#N(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}},cs=class{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){let t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){B("Not implemented")}},Zn=(()=>{class l extends ${#t=null;#e;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#i=null;static#s=null;static#a=null;static _INNER_MARGIN=3;constructor(e){super(e),this.#e=e.mustBeCommitted||!1,this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines(e){e.drawOutlines&&(this.#r(e),this.#h())}#r({drawOutlines:e,drawId:s,drawingOptions:i}){this.#t=e,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=this.#n(e,this.parent),this.#d(e.box)}#n(e,s){let{id:i}=s.drawLayer.draw(l._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(e,s){let i=new Set(Object.keys(e));for(let[n,r]of Object.entries(s))i.has(n)?Object.assign(e[n],r):e[n]=r;return e}static getDefaultDrawingOptions(e){B("Not implemented")}static get typesMap(){B("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){let i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(l.#i.updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){let i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){let e=[],s=this._defaultDrawingOptions;for(let[i,n]of this.typesMap)e.push([i,s[n]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:s}=this;for(let[i,n]of this.constructor.typesMap)e.push([i,s[n]]);return e}_updateProperty(e,s,i){let n=this._drawingOptions,r=n[s],a=o=>{n.updateProperty(s,o);let h=this.#t.updateProperty(s,o);h&&this.#d(h),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),e===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:a.bind(this,i),undo:a.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,l._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#u()),{bbox:this.#f()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,l._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#u()),{bbox:this.#f()}))}_onTranslating(e,s){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#f()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,l._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#f()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this.#o(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#h(),this.#d(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),this.#o()):e&&(this._uiManager.addShouldRescale(this),this.#h(e),s=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),s&&this.select()}#o(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#h(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#n(this.#t,e)}}#l([e,s,i,n]){let{parentDimensions:[r,a],rotation:o}=this;switch(o){case 90:return[s,1-e,i*(a/r),n*(r/a)];case 180:return[1-e,1-s,i,n];case 270:return[1-s,e,i*(a/r),n*(r/a)];default:return[e,s,i,n]}}#u(){let{x:e,y:s,width:i,height:n,parentDimensions:[r,a],rotation:o}=this;switch(o){case 90:return[1-s,e,i*(r/a),n*(a/r)];case 180:return[1-e,1-s,i,n];case 270:return[s,1-e,i*(r/a),n*(a/r)];default:return[e,s,i,n]}}#d(e){[this.x,this.y,this.width,this.height]=this.#l(e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#f(){let{x:e,y:s,width:i,height:n,rotation:r,parentRotation:a,parentDimensions:[o,h]}=this;switch((r*4+a)/90){case 1:return[1-s-n,e,n,i];case 2:return[1-e-i,1-s-n,i,n];case 3:return[s,1-e-i,n,i];
12case 4:return[e,s-i*(o/h),n*(h/o),i*(o/h)];case 5:return[1-s,e,i*(o/h),n*(h/o)];case 6:return[1-e-n*(h/o),1-s,n*(h/o),i*(o/h)];case 7:return[s-i*(o/h),1-e-n*(h/o),i*(o/h),n*(h/o)];case 8:return[e-i,s-n,i,n];case 9:return[1-s,e-i,n,i];case 10:return[1-e,1-s,i,n];case 11:return[s-n,1-e,n,i];case 12:return[e-n*(h/o),s,n*(h/o),i*(o/h)];case 13:return[1-s-i*(o/h),e-n*(h/o),i*(o/h),n*(h/o)];case 14:return[1-e,1-s-i*(o/h),n*(h/o),i*(o/h)];case 15:return[s,1-e,i*(o/h),n*(h/o)];default:return[e,s,i,n]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,l._mergeSVGProperties({bbox:this.#f()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#d(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);let i=super.render();i.classList.add("draw");let n=document.createElement("div");return i.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e,s,i,n,r){B("Not implemented")}static startDrawing(e,s,i,n){let{target:r,offsetX:a,offsetY:o,pointerId:h,pointerType:c}=n;if(nt.isInitializedAndDifferentPointerType(c))return;let{viewport:{rotation:d}}=e,{width:u,height:f}=r.getBoundingClientRect(),p=l.#s=new AbortController,g=e.combinedSignal(p);if(nt.setPointer(c,h),window.addEventListener("pointerup",m=>{nt.isSamePointerIdOrRemove(m.pointerId)&&this._endDraw(m)},{signal:g}),window.addEventListener("pointercancel",m=>{nt.isSamePointerIdOrRemove(m.pointerId)&&this._currentParent.endDrawingSession()},{signal:g}),window.addEventListener("pointerdown",m=>{nt.isSamePointerType(m.pointerType)&&(nt.initializeAndAddPointerId(m.pointerId),l.#i.isCancellable()&&(l.#i.removeLastElement(),l.#i.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",ft,{signal:g}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),r.addEventListener("touchmove",m=>{nt.isSameTimeStamp(m.timeStamp)&&Y(m)},{signal:g}),e.toggleDrawing(),s._editorUndoBar?.hide(),l.#i){e.drawLayer.updateProperties(this._currentDrawId,l.#i.startNew(a,o,u,f,d));return}s.updateUIForDefaultProperties(this),l.#i=this.createDrawerInstance(a,o,u,f,d),l.#a=this.getDefaultDrawingOptions(),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(l.#a.toSVGProperties(),l.#i.defaultSVGProperties),!0,!1)}static _drawMove(e){if(nt.isSameTimeStamp(e.timeStamp),!l.#i)return;let{offsetX:s,offsetY:i,pointerId:n}=e;if(nt.isSamePointerId(n)){if(nt.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,l.#i.add(s,i)),nt.setTimeStamp(e.timeStamp),Y(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,l.#i=null,l.#a=null,nt.clearTimeStamp()),l.#s&&(l.#s.abort(),l.#s=null,nt.clearPointerIds())}static _endDraw(e){let s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),e?.target===s.div&&s.drawLayer.updateProperties(this._currentDrawId,l.#i.end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){let i=l.#i,n=this._currentDrawId,r=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(n,i.setLastElement(r))},undo:()=>{s.drawLayer.updateProperties(n,i.removeLastElement())},mustExec:!1,type:N.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){let s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(N.DRAW_STEP),!l.#i.isEmpty()){let{pageDimensions:[i,n],scale:r}=s,a=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:l.#i.getOutlines(i*r,n*r,r,this._INNER_MARGIN),drawingOptions:l.#a,mustBeCommitted:!e});return this._cleanup(!0),a}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,n,r,a){B("Not implemented")}static async deserialize(e,s,i){let{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}=s.viewport,h=this.deserializeDraw(a,o,n,r,this._INNER_MARGIN,e),c=await super.deserialize(e,s,i);return c.createDrawingOptions(e),c.#r({drawOutlines:h}),c.#h(),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){let[s,i]=this.pageTranslation,[n,r]=this.pageDimensions;return this.#t.serialize([s,i,n,r],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}return l})(),sn=class{#t=new Float64Array(6);#e;#i;#s;#a;#r;#n="";#o=0;#h=new Lt;#l;#u;constructor(t,e,s,i,n,r){this.#l=s,this.#u=i,this.#s=n,this.#a=r,[t,e]=this.#d(t,e);let a=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#i=[{line:a,points:this.#r}],this.#t.set(a,0)}updateProperty(t,e){t==="stroke-width"&&(this.#a=e)}#d(t,e){return P._normalizePoint(t,e,this.#l,this.#u,this.#s)}isEmpty(){return!this.#i||this.#i.length===0}isCancellable(){return this.#r.length<=10}add(t,e){[t,e]=this.#d(t,e);let[s,i,n,r]=this.#t.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#l*a,this.#u*o)<=2?null:(this.#r.push(t,e),isNaN(s)?(this.#t.set([n,r,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([s,i,n,r,t,e],0),this.#e.push(...P.createBezierPoints(s,i,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){let s=this.add(t,e);return s||(this.#r.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,n){this.#l=s,this.#u=i,this.#s=n,[t,e]=this.#d(t,e);let r=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e];let a=this.#i.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#i.push({line:r,points:this.#r}),this.#t.set(r,0),this.#o=0,this.toSVGPath(),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){return this.#i?(this.#i.push(t),this.#e=t.line,this.#r=t.points,this.#o=0,{path:{d:this.toSVGPath()}}):this.#h.setLastElement(t)}removeLastElement(){if(!this.#i)return this.#h.removeLastElement();this.#i.pop(),this.#n="";for(let t=0,e=this.#i.length;t<e;t++){let{line:s,points:i}=this.#i[t];this.#e=s,this.#r=i,this.#o=0,this.toSVGPath()}return{path:{d:this.#n}}}toSVGPath(){let t=P.svgRound(this.#e[4]),e=P.svgRound(this.#e[5]);if(this.#r.length===2)return this.#n=`${this.#n} M ${t} ${e} Z`,this.#n;if(this.#r.length<=6){let i=this.#n.lastIndexOf("M");this.#n=`${this.#n.slice(0,i)} M ${t} ${e}`,this.#o=6}if(this.#r.length===4){let i=P.svgRound(this.#e[10]),n=P.svgRound(this.#e[11]);return this.#n=`${this.#n} L ${i} ${n}`,this.#o=12,this.#n}let s=[];this.#o===0&&(s.push(`M ${t} ${e}`),this.#o=6);for(let i=this.#o,n=this.#e.length;i<n;i+=6){let[r,a,o,h,c,d]=this.#e.slice(i,i+6).map(P.svgRound);s.push(`C${r} ${a} ${o} ${h} ${c} ${d}`)}return this.#n+=s.join(" "),this.#o=this.#e.length,this.#n}getOutlines(t,e,s,i){let n=this.#i.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#h.build(this.#i,t,e,s,this.#s,this.#a,i),this.#t=null,this.#e=null,this.#i=null,this.#n=null,this.#h}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}},Lt=class extends P{#t;#e=0;#i;#s;#a;#r;#n;#o;#h;build(t,e,s,i,n,r,a){this.#a=e,this.#r=s,this.#n=i,this.#o=n,this.#h=r,this.#i=a??0,this.#s=t,this.#d()}get thickness(){return this.#h}setLastElement(t){return this.#s.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#s){if(t.push(`M${P.svgRound(e[4])} ${P.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${P.svgRound(e[10])} ${P.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){let[n,r,a,o,h,c]=e.subarray(s,s+6).map(P.svgRound);t.push(`C${n} ${r} ${a} ${o} ${h} ${c}`)}}return t.join("")}serialize([t,e,s,i],n){let r=[],a=[],[o,h,c,d]=this.#u(),u,f,p,g,m,b,y,A,v;switch(this.#o){case 0:v=P._rescale,u=t,f=e+i,p=s,g=-i,m=t+o*s,b=e+(1-h-d)*i,y=t+(o+c)*s,A=e+(1-h)*i;break;case 90:v=P._rescaleAndSwap,u=t,f=e,p=s,g=i,m=t+h*s,b=e+o*i,y=t+(h+d)*s,A=e+(o+c)*i;break;case 180:v=P._rescale,u=t+s,f=e,p=-s,g=i,m=t+(1-o-c)*s,b=e+h*i,y=t+(1-o)*s,A=e+(h+d)*i;break;case 270:v=P._rescaleAndSwap,u=t+s,f=e+i,p=-s,g=-i,m=t+(1-h-d)*s,b=e+(1-o-c)*i,y=t+(1-h)*s,A=e+(1-o)*i;break}for(let{line:w,points:E}of this.#s)r.push(v(w,u,f,p,g,n?new Array(w.length):null)),a.push(v(E,u,f,p,g,n?new Array(E.length):null));return{lines:r,points:a,rect:[m,b,y,A]}}static deserialize(t,e,s,i,n,{paths:{lines:r,points:a},rotation:o,thickness:h}){let c=[],d,u,f,p,g;switch(o){case 0:g=P._rescale,d=-t/s,u=e/i+1,f=1/s,p=-1/i;break;case 90:g=P._rescaleAndSwap,d=-e/i,u=-t/s,f=1/i,p=1/s;break;case 180:g=P._rescale,d=t/s+1,u=-e/i,f=-1/s,p=1/i;break;case 270:g=P._rescaleAndSwap,d=e/i+1,u=t/s+1,f=-1/i,p=-1/s;break}if(!r){r=[];for(let b of a){let y=b.length;if(y===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,b[0],b[1]]));continue}if(y===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,b[0],b[1],NaN,NaN,NaN,NaN,b[2],b[3]]));continue}let A=new Float32Array(3*(y-2));
12r.push(A);let[v,w,E,S]=b.subarray(0,4);A.set([NaN,NaN,NaN,NaN,v,w],0);for(let _=4;_<y;_+=2){let C=b[_],M=b[_+1];A.set(P.createBezierPoints(v,w,E,S,C,M),(_-2)*3),[v,w,E,S]=[E,S,C,M]}}}for(let b=0,y=r.length;b<y;b++)c.push({line:g(r[b].map(A=>A??NaN),d,u,f,p),points:g(a[b].map(A=>A??NaN),d,u,f,p)});let m=new this.prototype.constructor;return m.build(c,s,i,1,o,h,n),m}#l(t=this.#h){let e=this.#i+t/2*this.#n;return this.#o%180===0?[e/this.#a,e/this.#r]:[e/this.#r,e/this.#a]}#u(){let[t,e,s,i]=this.#t,[n,r]=this.#l(0);return[t+n,e+r,s-2*n,i-2*r]}#d(){let t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:i}of this.#s){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6)T.pointBoundingBox(i[a],i[a+1],t);continue}let n=i[4],r=i[5];for(let a=6,o=i.length;a<o;a+=6){let[h,c,d,u,f,p]=i.subarray(a,a+6);T.bezierBoundingBox(n,r,h,c,d,u,f,p,t),n=f,r=p}}let[e,s]=this.#l();t[0]=st(t[0]-e,0,1),t[1]=st(t[1]-s,0,1),t[2]=st(t[2]+e,0,1),t[3]=st(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){let[e,s]=this.#l();this.#h=t;let[i,n]=this.#l(),[r,a]=[i-e,n-s],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],s){let[i,n]=this.#l();this.#a=t,this.#r=e,this.#n=s;let[r,a]=this.#l(),o=r-i,h=a-n,c=this.#t;return c[0]-=o,c[1]-=h,c[2]+=2*o,c[3]+=2*h,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(P.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,s=0,i=0,n=0,r=0,a=0,o=0;switch(this.#e){case 90:i=e/t,n=-t/e,a=t;break;case 180:s=-1,r=-1,a=t,o=e;break;case 270:i=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${n} ${r} ${P.svgRound(a)} ${P.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){let[n,r]=this.#l(),[a,o,h,c]=this.#t;if(Math.abs(h-n)<=P.PRECISION||Math.abs(c-r)<=P.PRECISION){let g=t+s/2-(a+h/2),m=e+i/2-(o+c/2);return{path:{"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${m})`}}}let d=(s-2*n)/(h-2*n),u=(i-2*r)/(c-2*r),f=h/s,p=c/i;return{path:{"transform-origin":`${P.svgRound(a)} ${P.svgRound(o)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${P.svgRound(n)} ${P.svgRound(r)}) scale(${d} ${u}) translate(${P.svgRound(-n)} ${P.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,s,i]){let[n,r]=this.#l(),a=this.#t,[o,h,c,d]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(c-n)<=P.PRECISION||Math.abs(d-r)<=P.PRECISION){let m=t+s/2-(o+c/2),b=e+i/2-(h+d/2);for(let{line:y,points:A}of this.#s)P._translate(y,m,b,y),P._translate(A,m,b,A);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let u=(s-2*n)/(c-2*n),f=(i-2*r)/(d-2*r),p=-u*(o+n)+t+n,g=-f*(h+r)+e+r;if(u!==1||f!==1||p!==0||g!==0)for(let{line:m,points:b}of this.#s)P._rescale(m,p,g,u,f,m),P._rescale(b,p,g,u,f,b);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){let[i,n]=s,r=this.#t,a=t-r[0],o=e-r[1];if(this.#a===i&&this.#r===n)for(let{line:h,points:c}of this.#s)P._translate(h,a,o,h),P._translate(c,a,o,c);else{let h=this.#a/i,c=this.#r/n;this.#a=i,this.#r=n;for(let{line:d,points:u}of this.#s)P._rescale(d,a,o,h,c,d),P._rescale(u,a,o,h,c,u);r[2]*=h,r[3]*=c}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${P.svgRound(t[0])} ${P.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}},ds=class l extends cs{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:$._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){let t=new l(this._viewParameters);return t.updateAll(this),t}},nn=class l extends Zn{static _type="ink";static _editorType=D.INK;static _defaultDrawingOptions=null;constructor(t){super(At(lt({},t),{name:"inkEditor"})),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){$.initialize(t,e),this._defaultDrawingOptions=new ds(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return L(this,"typesMap",new Map([[N.INK_THICKNESS,"stroke-width"],[N.INK_COLOR,"stroke"],[N.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,n){return new sn(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}
12static deserializeDraw(t,e,s,i,n,r){return Lt.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=null;if(t instanceof ye){let{data:{inkLists:r,rect:a,rotation:o,id:h,color:c,opacity:d,borderStyle:{rawWidth:u},popupRef:f,richText:p,contentsObj:g,creationDate:m,modificationDate:b},parent:{page:{pageNumber:y}}}=t;i=t={annotationType:D.INK,color:Array.from(c),thickness:u,opacity:d,paths:{points:r},boxes:null,pageIndex:y-1,rect:a.slice(0),rotation:o,annotationElementId:h,id:h,deleted:!1,popupRef:f,richText:p,comment:g?.str||null,creationDate:m,modificationDate:b}}let n=await super.deserialize(t,e,s);return n._initialData=i,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||=new ts(this),[["colorPicker",this._colorPicker]]}get colorType(){return N.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=l.getDefaultDrawingOptions({stroke:T.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:$._colorManager.convert(i),opacity:n,thickness:r,paths:{lines:e,points:s}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#t(a)?null:(a.id=this.annotationElementId,a)}#t(t){let{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}},ve=class extends Lt{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}},Ie=8,Jt=3,Ct=class{static#t={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#e(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i}static#i=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#s(t,e,s,i,n,r,a){let o=this.#e(s,i,n,r);for(let h=0;h<8;h++){let c=(-h+o-a+16)%8,d=this.#i[2*c],u=this.#i[2*c+1];if(t[(s+d)*e+(i+u)]!==0)return c}return-1}static#a(t,e,s,i,n,r,a){let o=this.#e(s,i,n,r);for(let h=0;h<8;h++){let c=(h+o+a+16)%8,d=this.#i[2*c],u=this.#i[2*c+1];if(t[(s+d)*e+(i+u)]!==0)return c}return-1}static#r(t,e,s,i){let n=t.length,r=new Int32Array(n);for(let c=0;c<n;c++)r[c]=t[c]<=i?1:0;for(let c=1;c<s-1;c++)r[c*e]=r[c*e+e-1]=0;for(let c=0;c<e;c++)r[c]=r[e*s-1-c]=0;let a=1,o,h=[];for(let c=1;c<s-1;c++){o=1;for(let d=1;d<e-1;d++){let u=c*e+d,f=r[u];if(f===0)continue;let p=c,g=d;if(f===1&&r[u-1]===0)a+=1,g-=1;else if(f>=1&&r[u+1]===0)a+=1,g+=1,f>1&&(o=f);else{f!==1&&(o=Math.abs(f));continue}let m=[d,c],b=g===d+1,y={isHole:b,points:m,id:a,parent:0};h.push(y);let A;for(let x of h)if(x.id===o){A=x;break}A?A.isHole?y.parent=b?A.parent:o:y.parent=b?o:A.parent:y.parent=b?o:0;let v=this.#s(r,e,c,d,p,g,0);if(v===-1){r[u]=-a,r[u]!==1&&(o=Math.abs(r[u]));continue}let w=this.#i[2*v],E=this.#i[2*v+1],S=c+w,_=d+E;p=S,g=_;let C=c,M=d;for(;;){let x=this.#a(r,e,C,M,p,g,1);w=this.#i[2*x],E=this.#i[2*x+1];let U=C+w,H=M+E;m.push(H,U);let F=C*e+M;if(r[F+1]===0?r[F]=-a:r[F]===1&&(r[F]=a),U===c&&H===d&&C===S&&M===_){r[u]!==1&&(o=Math.abs(r[u]));break}else p=C,g=M,C=U,M=H}}}return h}static#n(t,e,s,i){if(s-e<=4){for(let S=e;S<s-2;S+=2)i.push(t[S],t[S+1]);return}let n=t[e],r=t[e+1],a=t[s-4]-n,o=t[s-3]-r,h=Math.hypot(a,o),c=a/h,d=o/h,u=c*r-d*n,f=o/a,p=1/h,g=Math.atan(f),m=Math.cos(g),b=Math.sin(g),y=p*(Math.abs(m)+Math.abs(b)),A=p*(1-y+y**2),v=Math.max(Math.atan(Math.abs(b+m)*A),Math.atan(Math.abs(b-m)*A)),w=0,E=e;for(let S=e+2;S<s-2;S+=2){let _=Math.abs(u-c*t[S+1]+d*t[S]);_>w&&(E=S,w=_)}w>(h*v)**2?(this.#n(t,e,E+2,i),this.#n(t,E,s,i)):i.push(n,r)}static#o(t){let e=[],s=t.length;return this.#n(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#h(t,e,s,i,n,r){let a=new Float32Array(r**2),o=-2*i**2,h=r>>1;for(let g=0;g<r;g++){let m=(g-h)**2;for(let b=0;b<r;b++)a[g*r+b]=Math.exp((m+(b-h)**2)/o)}let c=new Float32Array(256),d=-2*n**2;for(let g=0;g<256;g++)c[g]=Math.exp(g**2/d);let u=t.length,f=new Uint8Array(u),p=new Uint32Array(256);for(let g=0;g<s;g++)for(let m=0;m<e;m++){let b=g*e+m,y=t[b],A=0,v=0;for(let E=0;E<r;E++){let S=g+E-h;if(!(S<0||S>=s))for(let _=0;_<r;_++){let C=m+_-h;if(C<0||C>=e)continue;let M=t[S*e+C],x=a[E*r+_]*c[Math.abs(M-y)];A+=M*x,v+=x}}let w=f[b]=Math.round(A/v);p[w]++}return[f,p]}static#l(t){let e=new Uint32Array(256);for(let s of t)e[s]++;return e}static#u(t){let e=t.length,s=new Uint8ClampedArray(e>>2),i=-1/0,n=1/0;for(let a=0,o=s.length;a<o;a++){let h=s[a]=t[a<<2];i=Math.max(i,h),n=Math.min(n,h)}let r=255/(i-n);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-n)*r;return s}static#d(t){let e,s=-1/0,i=-1/0,n=t.findIndex(o=>o!==0),r=n,a=n;for(e=n;e<256;e++){let o=t[e];o>s&&(e-r>i&&(i=e-r,a=e-1),s=o,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#f(t){let e=t,{width:s,height:i}=t,{maxDim:n}=this.#t,r=s,a=i;if(s>n||i>n){let u=s,f=i,p=Math.log2(Math.max(s,i)/n),g=Math.floor(p);p=p===g?g-1:g;for(let b=0;b<p;b++){r=Math.ceil(u/2),a=Math.ceil(f/2);let y=new OffscreenCanvas(r,a);y.getContext("2d").drawImage(t,0,0,u,f,0,0,r,a),u=r,f=a,t!==e&&t.close(),t=y.transferToImageBitmap()}let m=Math.min(n/r,n/a);r=Math.round(r*m),a=Math.round(a*m)}let h=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,r,a),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,r,a);let c=h.getImageData(0,0,r,a).data;return[this.#u(c),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},n,r,a,o){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1}),d=200,u=c.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:f,actualBoundingBoxRight:p,actualBoundingBoxAscent:g,actualBoundingBoxDescent:m,fontBoundingBoxAscent:b,fontBoundingBoxDescent:y,width:A}=c.measureText(t),v=1.5,w=Math.ceil(Math.max(Math.abs(f)+Math.abs(p)||0,A)*v),E=Math.ceil(Math.max(Math.abs(g)+Math.abs(m)||d,Math.abs(b)+Math.abs(y)||d)*v);h=new OffscreenCanvas(w,E),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=u,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,w,E),c.fillStyle="black",c.fillText(t,w*(v-1)/2,E*(3-v)/2);let S=this.#u(c.getImageData(0,0,w,E).data),_=this.#l(S),C=this.#d(_),M=this.#r(S,w,E,C);return this.processDrawnLines({lines:{curves:M,width:w,height:E},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,n){let[r,a,o]=this.#f(t),[h,c]=this.#h(r,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),d=this.#d(c),u=this.#r(h,a,o,d);return this.processDrawnLines({lines:{curves:u,width:a,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:r,areContours:a}){i%180!==0&&([e,s]=[s,e]);let{curves:o,width:h,height:c}=t,d=t.thickness??0,u=[],f=Math.min(e/h,s/c),p=f/e,g=f/s,m=[];for(let{points:y}
12of o){let A=r?this.#o(y):y;if(!A)continue;m.push(A);let v=A.length,w=new Float32Array(v),E=new Float32Array(3*(v===2?2:v-2));if(u.push({line:E,points:w}),v===2){w[0]=A[0]*p,w[1]=A[1]*g,E.set([NaN,NaN,NaN,NaN,w[0],w[1]],0);continue}let[S,_,C,M]=A;S*=p,_*=g,C*=p,M*=g,w.set([S,_,C,M],0),E.set([NaN,NaN,NaN,NaN,S,_],0);for(let x=4;x<v;x+=2){let U=w[x]=A[x]*p,H=w[x+1]=A[x+1]*g;E.set(P.createBezierPoints(S,_,C,M,U,H),(x-2)*3),[S,_,C,M]=[C,M,U,H]}}if(u.length===0)return null;let b=a?new ve:new Lt;return b.build(u,e,s,1,i,a?0:d,n),{outline:b,newCurves:m,areContours:a,thickness:d,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:n}){let r=1/0,a=-1/0,o=0;for(let A of t){o+=A.length;for(let v=2,w=A.length;v<w;v++){let E=A[v]-A[v-2];r=Math.min(r,E),a=Math.max(a,E)}}let h;r>=-128&&a<=127?h=Int8Array:r>=-32768&&a<=32767?h=Int16Array:h=Int32Array;let c=t.length,d=Ie+Jt*c,u=new Uint32Array(d),f=0;u[f++]=d*Uint32Array.BYTES_PER_ELEMENT+(o-2*c)*h.BYTES_PER_ELEMENT,u[f++]=0,u[f++]=i,u[f++]=n,u[f++]=e?0:1,u[f++]=Math.max(0,Math.floor(s??0)),u[f++]=c,u[f++]=h.BYTES_PER_ELEMENT;for(let A of t)u[f++]=A.length-2,u[f++]=A[0],u[f++]=A[1];let p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(u);let m=h.prototype.constructor;for(let A of t){let v=new m(A.length-2);for(let w=2,E=A.length;w<E;w++)v[w-2]=A[w]-A[w-2];g.write(v)}g.close();let b=await new Response(p.readable).arrayBuffer();return new Uint8Array(b).toBase64()}static async decompressSignature(t){try{let e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),n=i.getWriter();await n.ready,n.write(e).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let r=null,a=0;for await(let A of s)r||=new Uint8Array(new Uint32Array(A.buffer,0,4)[0]),r.set(A,a),a+=A.length;let o=new Uint32Array(r.buffer,0,r.length>>2),h=o[1];if(h!==0)throw new Error(`Invalid version: ${h}`);let c=o[2],d=o[3],u=o[4]===0,f=o[5],p=o[6],g=o[7],m=[],b=(Ie+Jt*p)*Uint32Array.BYTES_PER_ELEMENT,y;switch(g){case Int8Array.BYTES_PER_ELEMENT:y=new Int8Array(r.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:y=new Int16Array(r.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:y=new Int32Array(r.buffer,b);break}a=0;for(let A=0;A<p;A++){let v=o[Jt*A+Ie],w=new Float32Array(v+2);m.push(w);for(let E=0;E<Jt-1;E++)w[E]=o[Jt*A+Ie+E+1];for(let E=0;E<v;E++)w[E+2]=w[E]+y[a++]}return{areContours:u,thickness:f,outlines:m,width:c,height:d}}catch(e){return R(`decompressSignature: ${e}`),null}}},rn=class l extends cs{constructor(){super(),super.updateProperties({fill:$._defaultLineColor,"stroke-width":0})}clone(){let t=new l;return t.updateAll(this),t}},an=class l extends ds{constructor(t){super(t),super.updateProperties({stroke:$._defaultLineColor,"stroke-width":1})}clone(){let t=new l(this._viewParameters);return t.updateAll(this),t}},on=class l extends Zn{#t=!1;#e=null;#i=null;#s=null;static _type="signature";static _editorType=D.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super(At(lt({},t),{mustBeCommitted:!0,name:"signatureEditor"})),this._willKeepAspectRatio=!0,this.#i=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){$.initialize(t,e),this._defaultDrawingOptions=new rn,this._defaultDrawnSignatureOptions=new an(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return L(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e,{_isCopy:s}=this;if(s&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(this.#i){let{lines:i,mustSmooth:n,areContours:r,description:a,uuid:o,heightInPage:h}=this.#i,{rawDims:{pageWidth:c,pageHeight:d},rotation:u}=this.parent.viewport,f=Ct.processDrawnLines({lines:i,pageWidth:c,pageHeight:d,rotation:u,innerMargin:l._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(f,h,a,o)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#e||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#s=t,this.addEditToolbar()}getUuid(){return this.#s}get description(){return this.#e}set description(t){this.#e=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:s,width:i,height:n}=this.#i,r=Math.max(i,n),a=Ct.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:s,width:i,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,s,i){let{x:n,y:r}=this,{outline:a}=this.#i=t;this.#t=a instanceof ve,this.description=s;let o;this.#t?o=l.getDefaultDrawingOptions():(o=l._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});let[,h]=this.pageDimensions,c=e/h;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=n,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Ct.process(t,e,s,i,l._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return Ct.extractContoursFromText(t,e,s,i,n,l._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Ct.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:l._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=l.getDefaultDrawingOptions():(this._drawingOptions=l._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});return this.addComment(n),t?(n.paths={lines:e,points:s},n.uuid=this.#s,n.isCopy=!0):n.lines=e,this.#e&&(n.accessibilityData={type:"Figure",alt:this.#e}),n}static deserializeDraw(t,e,s,i,n,r){return r.areContours?ve.deserialize(t,e,s,i,n,r):Lt.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=await super.deserialize(t,e,s);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#s=t.uuid,i}},ln=class extends ${#t=null;#e=null;#i=null;#s=null;#a=null;#r="";#n=null;#o=!1;#h=null;#l=!1;#u=!1;static _type="stamp";static _editorType=D.STAMP;constructor(t){super(At(lt({},t),{name:"stampEditor"})),this.#s=t.bitmapUrl,this.#a=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){$.initialize(t,e)}static isHandlingMimeForPasting(t){return Rs.includes(t)}static paste(t,e){e.pasteEditor({mode:D.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#l=t.isSvg),t.file&&(this.#r=t.file.name),this.#g()}
12#f(){if(this.#i=null,this._uiManager.enableWaiting(!1),!!this.#n){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");let{data:i,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:n,height:r,channels:i.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#m(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#d(s,!0)).finally(()=>this.#f());return}if(this.#s){let s=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#d(i)).finally(()=>this.#f());return}if(this.#a){let s=this.#a;this.#a=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromFile(s).then(i=>this.#d(i)).finally(()=>this.#f());return}let t=document.createElement("input");t.type="file",t.accept=Rs.join(",");let e=this._uiManager._signal;this.#i=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#f()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#n?.remove(),this.#n=null,this.#h&&(clearTimeout(this.#h),this.#h=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#m();return}super.rebuild(),this.div!==null&&(this.#e&&this.#n===null&&this.#m(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#i||this.#t||this.#s||this.#a||this.#e||this.#o)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#o||(this.#t?this.#g():this.#m()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){let{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(this.#e=s,i&&(this.#t=i),this.#o=!1,this.#g())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#h!==null&&clearTimeout(this.#h);let t=200;this.#h=setTimeout(()=>{this.#h=null,this.#p()},t)}#g(){let{div:t}=this,{width:e,height:s}=this.#t,[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){let o=Math.min(r*i/e,r*n/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);let a=this.#n=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/i,this.height=s/n,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#p(),this.#u||(this.parent.addUndoableEditor(this),this.#u=!0),this._reportTelemetry({action:"inserted_image"}),this.#r&&this.div.setAttribute("aria-description",this.#r),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,s=!1){t||(t=224);let{width:i,height:n}=this.#t,r=new vt,a=this.#t,o=i,h=n,c=null;if(e){if(i>e||n>e){let E=Math.min(e/i,e/n);o=Math.floor(i*E),h=Math.floor(n*E)}c=document.createElement("canvas");let u=c.width=Math.ceil(o*r.sx),f=c.height=Math.ceil(h*r.sy);this.#l||(a=this.#c(u,f));let p=c.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",m="#cfcfd8";this._uiManager.hcmFilter!=="none"?m="black":Ns.isDarkMode&&(g="#8f8f9d",m="#42414d");let b=15,y=b*r.sx,A=b*r.sy,v=new OffscreenCanvas(y*2,A*2),w=v.getContext("2d");w.fillStyle=g,w.fillRect(0,0,y*2,A*2),w.fillStyle=m,w.fillRect(0,0,y,A),w.fillRect(y,A,y,A),p.fillStyle=p.createPattern(v,"repeat"),p.fillRect(0,0,u,f),p.drawImage(a,0,0,a.width,a.height,0,0,u,f)}let d=null;if(s){let u,f;if(r.symmetric&&a.width<t&&a.height<t)u=a.width,f=a.height;else if(a=this.#t,i>t||n>t){let m=Math.min(t/i,t/n);u=Math.floor(i*m),f=Math.floor(n*m),this.#l||(a=this.#c(u,f))}let g=new OffscreenCanvas(u,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,f),d={width:u,height:f,data:g.getImageData(0,0,u,f).data}}return{canvas:c,width:o,height:h,imageData:d}}#c(t,e){let{width:s,height:i}=this.#t,n=s,r=i,a=this.#t;for(;n>2*t||r>2*e;){let o=n,h=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));let c=new OffscreenCanvas(n,r);c.getContext("2d").drawImage(a,0,0,o,h,0,0,n,r),a=c.transferToImageBitmap()}return a}#p(){let[t,e]=this.parentDimensions,{width:s,height:i}=this,n=new vt,r=Math.ceil(s*t*n.sx),a=Math.ceil(i*e*n.sy),o=this.#n;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;let h=this.#l?this.#t:this.#c(r,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(h,0,0,h.width,h.height,0,0,r,a)}#b(t){if(t){if(this.#l){let i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}
12let 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.#l){let[e,s]=this.pageDimensions,i=Math.round(this.width*e*Tt.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*Tt.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)}static async deserialize(t,e,s){let i=null,n=!1;if(t instanceof as){let{data:{rect:g,rotation:m,id:b,structParent:y,popupRef:A,richText:v,contentsObj:w,creationDate:E,modificationDate:S},container:_,parent:{page:{pageNumber:C}},canvas:M}=t,x,U;M?(delete t.canvas,{id:x,bitmap:U}=s.imageManager.getFromCanvas(_.id,M),M.remove()):(n=!0,t._hasNoCanvas=!0);let H=(await e._structTree.getAriaAttributes(`${Bt}${b}`))?.get("aria-label")||"";i=t={annotationType:D.STAMP,bitmapId:x,bitmap:U,pageIndex:C-1,rect:g.slice(0),rotation:m,annotationElementId:b,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:H},isSvg:!1,structParent:y,popupRef:A,richText:v,comment:w?.str||null,creationDate:E,modificationDate:S}}let r=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:h,bitmapId:c,isSvg:d,accessibilityData:u}=t;n?(s.addMissingCanvas(t.id,r),r.#o=!0):c&&s.imageManager.isValidId(c)?(r.#e=c,o&&(r.#t=o)):r.#s=h,r.#l=d;let[f,p]=r.pageDimensions;return r.width=(a[2]-a[0])/f,r.height=(a[3]-a[1])/p,u&&(r.altTextData=u),r._initialData=i,t.comment&&r.setCommentData(t),r.#u=!!i,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#l});if(this.addComment(s),t)return s.bitmapUrl=this.#b(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;let{decorative:i,altText:n}=this.serializeAltText(!1);if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){let a=this.#A(s);return a.isSame?null:(a.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1,s.id=this.annotationElementId,delete s.bitmapId,s)}if(e===null)return s;e.stamps||=new Map;let r=this.#l?(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.#b(!1);else if(this.#l){let a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#b(!1))}return s}#A(t){let{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&n,isSameAltText:n}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}},Vr=(()=>{class l{#t;#e=!1;#i=null;#s=null;#a=null;#r=new Map;#n=!1;#o=!1;#h=!1;#l=null;#u=null;#d=null;#f=null;#m=null;#g=-1;#c;static _initialized=!1;static#p=new Map([Zi,nn,ln,hs,on].map(e=>[e._editorType,e]));constructor({uiManager:e,pageIndex:s,div:i,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:h,viewport:c,l10n:d}){let u=[...l.#p.values()];if(!l._initialized){l._initialized=!0;for(let f of u)f.initialize(d,e)}e.registerEditorTypes(u),this.#c=e,this.pageIndex=s,this.div=i,this.#t=r,this.#i=a,this.viewport=c,this.#d=h,this.drawLayer=o,this._structTree=n,this.#c.addLayer(this)}updatePageIndex(e){for(let s of this.#b)s.updatePageIndex(e);this.pageIndex=e,this.#c.addLayer(this)}async setClonedFrom(e){if(!e)return;let s=[];for(let i of e.#b){let n=i.serialize(!0);n&&(n.isCopy=!1,s.push(this.deserialize(n).then(r=>{r&&this.addOrRebuild(r)})))}await Promise.all(s)}get isEmpty(){return this.#r.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===D.NONE}updateToolbar(e){this.#c.updateToolbar(e)}updateMode(e=this.#c.getMode()){switch(this.#v(),e){case D.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case D.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case D.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:s}=this.div;if(s.toggle("nonEditing",!1),e===D.POPUP)s.toggle("commentEditing",!0);else{s.toggle("commentEditing",!1);for(let i of l.#p.values())s.toggle(`${i._type}Editing`,e===i._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===this.#d?.div}setEditingState(e){this.#c.setEditingState(e)}addCommands(e){this.#c.addCommands(e)}cleanUndoStack(e){this.#c.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#i?.togglePointerEvents(e)}get#b(){return this.#r.size!==0?this.#r.values():this.#c.getEditors(this.pageIndex)}async enable(){this.#h=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#m?.abort(),this.#m=null;let e=new Set;for(let i of this.#b)i.enableEditing(),i.show(!0),i.annotationElementId&&(this.#c.removeChangedExistingAnnotation(i),e.add(i.annotationElementId));let s=this.#i;if(s)for(let i of s.getEditableAnnotations()){if(i.hide(),this.#c.isDeletedAnnotationElement(i.data.id)||e.has(i.data.id))continue;let n=await this.deserialize(i);n&&(this.addOrRebuild(n),n.enableEditing())}this.#h=!1,this.#c._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#d&&!this.#m){this.#m=new AbortController;let n=this.#c.combinedSignal(this.#m);this.#d.div.addEventListener("pointerdown",r=>{let{clientX:o,clientY:h,timeStamp:c}=r,d=this.#g;if(c-d>500){this.#g=c;return}this.#g=-1;let{classList:u}=this.div;u.toggle("getElements",!0);let f=document.elementsFromPoint(o,h);if(u.toggle("getElements",!1),!this.div.contains(f[0]))return;let p,g=new RegExp(`^${ie}[0-9]+$`);for(let b of f)if(g.test(b.id)){p=b.id;break}if(!p)return;let m=this.#r.get(p);m?.annotationElementId===null&&(r.stopPropagation(),r.preventDefault(),m.dblclick(r))},{signal:n,capture:!0})}let e=this.#i,s=[];if(e){let n=new Map,r=new Map;for(let o of this.#b){if(o.disableEditing(),!o.annotationElementId){s.push(o);continue}if(o.serialize()!==null){n.set(o.annotationElementId,o);continue}else r.set(o.annotationElementId,o);this.getEditableAnnotation(o.annotationElementId)?.show(),o.remove()}let a=e.getEditableAnnotations();for(let o of a){let{id:h}=o.data;if(this.#c.isDeletedAnnotationElement(h)){o.updateEdited({deleted:!0}
12);continue}let c=r.get(h);if(c){c.resetAnnotationElement(o),c.show(!1),o.show();continue}c=n.get(h),c&&(this.#c.addChangedExistingAnnotation(c),c.renderAnnotationElement(o)&&c.show(!1)),o.show()}}this.#v(),this.isEmpty&&(this.div.hidden=!0);let{classList:i}=this.div;for(let n of l.#p.values())i.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e?.updateFakeAnnotations(s),this.#o=!1}getEditableAnnotation(e){return this.#i?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#c.getActive()!==e&&this.#c.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;let e=this.#c.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#A.bind(this),{signal:e}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting"))}#A(e){this.#c.unselectAll();let{target:s}=e;if(s===this.#d.div||(s.getAttribute("role")==="img"||s.classList.contains("endOfContent"))&&this.#d.div.contains(s)){let{isMac:i}=K.platform;if(e.button!==0||e.ctrlKey&&i)return;this.#c.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),hs.startHighlighting(this,this.#c.direction==="ltr",{target:this.#d.div,x:e.x,y:e.y}),this.#d.div.addEventListener("pointerup",()=>{this.#d.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#c._signal}),e.preventDefault()}}enableClick(){if(this.#s)return;this.#s=new AbortController;let e=this.#c.combinedSignal(this.#s);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});let s=this.pointerup.bind(this);this.div.addEventListener("pointerup",s,{signal:e}),this.div.addEventListener("pointercancel",s,{signal:e})}disableClick(){this.#s?.abort(),this.#s=null}attach(e){this.#r.set(e.id,e);let{annotationElementId:s}=e;s&&this.#c.isDeletedAnnotationElement(s)&&this.#c.removeDeletedAnnotationElement(e)}detach(e){this.#r.delete(e.id),this.#t?.removePointerInTextLayer(e.contentDiv),!this.#o&&e.annotationElementId&&this.#c.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#c.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(this.#c.addDeletedAnnotationElement(e),$.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),this.#c.addEditor(e),this.attach(e),!e.isAttachedToDOM){let s=e.render();this.div.append(s),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#h),this.#c.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:s}=document;e.div.contains(s)&&!this.#a&&(e._focusEventsAllowed=!1,this.#a=setTimeout(()=>{this.#a=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#c._signal}),s.focus())},0)),e._structTreeParentId=this.#t?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){let s=()=>e._uiManager.rebuild(e),i=()=>{e.remove()};this.addCommands({cmd:s,undo:i,mustExec:!1})}getEditorByUID(e){for(let s of this.#r.values())if(s.uid===e)return s;return null}getNextId(){return this.#c.getId()}get#y(){return l.#p.get(this.#c.getMode())}combinedSignal(e){return this.#c.combinedSignal(e)}#C(e){let s=this.#y;return s?new s.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#y?.canCreateNewEmptyEditor()}async pasteEditor(e,s){this.updateToolbar(e),await this.#c.updateMode(e.mode);let{offsetX:i,offsetY:n}=this.#S(),r=this.getNextId(),a=this.#C(lt({parent:this,id:r,x:i,y:n,uiManager:this.#c,isCentered:!0},s));a&&this.add(a)}async deserialize(e){return await l.#p.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#c)||null}createAndAddNewEditor(e,s,i={}){let n=this.getNextId(),r=this.#C(lt({parent:this,id:n,x:e.offsetX,y:e.offsetY,uiManager:this.#c,isCentered:s}
12,i));return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}#S(){let{x:e,y:s,width:i,height:n}=this.boundingClientRect,r=Math.max(0,e),a=Math.max(0,s),o=Math.min(window.innerWidth,e+i),h=Math.min(window.innerHeight,s+n),c=(r+o)/2-e,d=(a+h)/2-s,[u,f]=this.viewport.rotation%180===0?[c,d]:[d,c];return{offsetX:u,offsetY:f}}addNewEditor(e={}){this.createAndAddNewEditor(this.#S(),!0,e)}setSelected(e){this.#c.setSelected(e)}toggleSelected(e){this.#c.toggleSelected(e)}unselect(e){this.#c.unselect(e)}pointerup(e){let{isMac:s}=K.platform;if(e.button!==0||e.ctrlKey&&s||e.target!==this.div||!this.#n||(this.#n=!1,this.#y?.isDrawer&&this.#y.supportMultipleDrawings))return;if(!this.#e){this.#e=!0;return}let i=this.#c.getMode();if(i===D.STAMP||i===D.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){if(this.#c.getMode()===D.HIGHLIGHT&&this.enableTextSelection(),this.#n){this.#n=!1;return}let{isMac:s}=K.platform;if(e.button!==0||e.ctrlKey&&s||e.target!==this.div)return;if(this.#n=!0,this.#y?.isDrawer){this.startDrawingSession(e);return}let i=this.#c.getActive();this.#e=!i||i.isEmpty()}startDrawingSession(e){if(this.div.focus({preventScroll:!0}),this.#l){this.#y.startDrawing(this,this.#c,!1,e);return}this.#c.setCurrentDrawingSession(this),this.#l=new AbortController;let s=this.#c.combinedSignal(this.#l);this.div.addEventListener("blur",({relatedTarget:i})=>{i&&!this.div.contains(i)&&(this.#u=null,this.commitOrRemove())},{signal:s}),this.#y.startDrawing(this,this.#c,!1,e)}pause(e){if(e){let{activeElement:s}=document;this.div.contains(s)&&(this.#u=s);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(e=!1){return this.#l?(this.#c.setCurrentDrawingSession(null),this.#l.abort(),this.#l=null,this.#u=null,this.#y.endDrawing(e)):null}findNewParent(e,s,i){let n=this.#c.findParent(s,i);return n===null||n===this?!1:(n.changeParent(e),!0)}commitOrRemove(){return this.#l?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#l&&this.#y.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#c.getActive()?.parent===this&&(this.#c.commitOrRemove(),this.#c.setActiveEditor(null)),this.#a&&(clearTimeout(this.#a),this.#a=null);for(let e of this.#r.values())this.#t?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#r.clear(),this.#c.removeLayer(this)}#v(){for(let e of this.#r.values())e.isEmpty()&&e.remove()}render({viewport:e}){this.viewport=e,Mt(this.div,e);for(let s of this.#c.getEditors(this.pageIndex))this.add(s),s.rebuild();this.updateMode()}update({viewport:e}){this.#c.commitOrRemove(),this.#v();let s=this.viewport.rotation,i=e.rotation;if(this.viewport=e,Mt(this.div,{rotation:i}),s!==i)for(let n of this.#r.values())n.rotate(i)}get pageDimensions(){let{pageWidth:e,pageHeight:s}=this.viewport.rawDims;return[e,s]}get scale(){return this.#c.viewParameters.realScale}}return l})(),hn=class l{#t=null;#e=new Map;#i=new Map;static#s=0;setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#e.size>0)for(let e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return L(this,"_svgFactory",new Wt)}static#a(t,[e,s,i,n]){let{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`}#r(){let t=l._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#n(t,e){let s=l._svgFactory.createElement("clipPath");t.append(s);let i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");let n=l._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}#o(t,e){for(let[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)}draw(t,e=!1,s=!1){let i=l.#s++,n=this.#r(),r=l._svgFactory.createElement("defs");n.append(r);let a=l._svgFactory.createElement("path");r.append(a);let o=`path_${i}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#i.set(i,a);let h=s?this.#n(r,o):null,c=l._svgFactory.createElement("use");return n.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#e.set(i,n),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){let s=l.#s++,i=this.#r(),n=l._svgFactory.createElement("defs");i.append(n);let r=l._svgFactory.createElement("path");n.append(r);let a=`path_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){let d=l._svgFactory.createElement("mask");n.append(d),o=`mask_${s}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");let u=l._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");let f=l._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}let h=l._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${a}`),o&&h.setAttribute("mask",`url(#${o})`);let c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(s,i),s}finalizeDraw(t,e){this.#i.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:s,bbox:i,rootClass:n,path:r}=e,a=typeof t=="number"?this.#e.get(t):t;if(a){if(s&&this.#o(a,s),i&&l.#a(a,i),n){let{classList:o}=a;
12for(let[h,c]of Object.entries(n))o.toggle(h,c)}if(r){let h=a.firstElementChild.firstElementChild;this.#o(h,r)}}}updateParent(t,e){if(e===this)return;let s=this.#e.get(t);s&&(e.#t.append(s),this.#e.delete(t),e.#e.set(t,s))}remove(t){this.#i.delete(t),this.#t!==null&&(this.#e.get(t).remove(),this.#e.delete(t))}destroy(){this.#t=null;for(let t of this.#e.values())t.remove();this.#e.clear(),this.#i.clear()}};globalThis._pdfjsTestingUtils={HighlightOutliner:Ae};globalThis.pdfjsLib={AbortException:yt,AnnotationEditorLayer:Vr,AnnotationEditorParamsType:N,AnnotationEditorType:D,AnnotationEditorUIManager:ce,AnnotationLayer:Ji,AnnotationMode:_t,AnnotationType:tt,applyOpacity:Ar,build:jr,ColorPicker:Ze,createValidAbsoluteUrl:Bn,CSSConstants:Fs,DOMSVGFactory:Wt,DrawLayer:hn,FeatureTest:K,fetchData:Ee,findContrastColor:wr,getDocument:Hr,getFilenameFromUrl:gr,getPdfFilenameFromUrl:mr,getRGB:Se,getUuid:Hn,getXfaPageViewport:br,GlobalWorkerOptions:Pt,ImageKind:Re,InvalidPDFException:re,isDataScheme:ms,isPdfFile:dn,isValidExplicitDest:Cr,makeArr:$n,makeMap:cn,makeObj:Ds,MathClamp:st,noContextMenu:ft,normalizeUnicode:fr,OPS:ne,OutputScale:vt,PasswordResponses:nr,PDFDataRangeTransport:Je,PDFDateString:he,PDFWorker:ge,PermissionFlag:ir,PixelsPerInch:Tt,RenderingCancelledException:le,renderRichText:Gn,ResponseException:jt,setLayerDimensions:Mt,shadow:L,SignatureExtractor:Ct,stopEvent:Y,SupportedImageMimeTypes:Rs,TextLayer:pe,TouchManager:Be,updateUrlHash:Un,Util:T,VerbosityLevel:us,version:$r,XfaLayer:Fe};export{yt as AbortException,Vr as AnnotationEditorLayer,N as AnnotationEditorParamsType,D as AnnotationEditorType,ce as AnnotationEditorUIManager,Ji as AnnotationLayer,_t as AnnotationMode,tt as AnnotationType,Fs as CSSConstants,Ze as ColorPicker,Wt as DOMSVGFactory,hn as DrawLayer,K as FeatureTest,Pt as GlobalWorkerOptions,Re as ImageKind,re as InvalidPDFException,st as MathClamp,ne as OPS,vt as OutputScale,Je as PDFDataRangeTransport,he as PDFDateString,ge as PDFWorker,nr as PasswordResponses,ir as PermissionFlag,Tt as PixelsPerInch,le as RenderingCancelledException,jt as ResponseException,Ct as SignatureExtractor,Rs as SupportedImageMimeTypes,pe as TextLayer,Be as TouchManager,T as Util,us as VerbosityLevel,Fe as XfaLayer,Ar as applyOpacity,jr as build,Bn as createValidAbsoluteUrl,Ee as fetchData,wr as findContrastColor,Hr as getDocument,gr as getFilenameFromUrl,mr as getPdfFilenameFromUrl,Se as getRGB,Hn as getUuid,br as getXfaPageViewport,ms as isDataScheme,dn as isPdfFile,Cr as isValidExplicitDest,$n as makeArr,cn as makeMap,Ds as makeObj,ft as noContextMenu,fr as normalizeUnicode,Gn as renderRichText,Mt as setLayerDimensions,L as shadow,Y as stopEvent,Un as updateUrlHash,$r 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.