1var db=Object.defineProperty;var vp=u=>{throw TypeError(u)};var ub=(u,t,e)=>t in u?db(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var P=(u,t,e)=>ub(u,typeof t!="symbol"?t+"":t,e),wu=(u,t,e)=>t.has(u)||vp("Cannot "+e);var i=(u,t,e)=>(wu(u,t,"read from private field"),e?e.call(u):t.get(u)),g=(u,t,e)=>t.has(u)?vp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),f=(u,t,e,s)=>(wu(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),m=(u,t,e)=>(wu(u,t,"access private method"),e);var zt=(u,t,e,s)=>({set _(n){f(u,t,n,e)},get _(){return i(u,t,s)}});const Ee=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ku=[.001,0,0,.001,0,0],vu=1.35,es={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},nn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ql="pdfjs_internal_editor_",j={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},Z={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},Kp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},se={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Kl={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},It={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},La={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Bc={ERRORS:0,WARNINGS:1,INFOS:5},yl={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},Vc={moveTo:0,lineTo:1,curveTo:2,closePath:3},Qp={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let du=Bc.WARNINGS;function fb(u){Number.isInteger(u)&&(du=u)}function pb(){return du}function uu(u){du>=Bc.INFOS&&`${u}`}function V(u){du>=Bc.WARNINGS&&console.warn(`Warning: ${u}`)}function At(u){throw new Error(u)}function et(u,t){u||At(t)}function gb(u){switch(u==null?void 0:u.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function tp(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"){if(e.addDefaultProtocol&&u.startsWith("www.")){const n=u.match(/\./g);(n==null?void 0:n.length)>=2&&(u=`http://${u}`)}if(e.tryConvertEncoding)try{u=wb(u)}catch{}}const s=t?URL.parse(u,t):URL.parse(u);return gb(s)?s:null}function ep(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&tp(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Y(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Ma=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class _p extends Ma{constructor(t,e){super(t,"PasswordException"),this.code=e}}class _u extends Ma{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ld extends Ma{constructor(t){super(t,"InvalidPDFException")}}class Jl extends Ma{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class mb extends Ma{constructor(t){super(t,"FormatError")}}class on extends Ma{constructor(t){super(t,"AbortException")}}function Jp(u){(typeof u!="object"||(u==null?void 0:u.length)===void 0)&&At("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let n=0;n<t;n+=e){const r=Math.min(n+e,t),a=u.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Hc(u){typeof u!="string"&&At("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=u.charCodeAt(s)&255;return e}function bb(u){return String.fromCharCode(u>>24&255,u>>16&255,u>>8&255,u&255)}function Ab(){const u=new Uint8Array(4);return u[0]=1,new Uint32Array(u.buffer,0,1)[0]===1}function yb(){try{return new Function(""),!0}catch{return!1}}class ee{static get isLittleEndian(){return Y(this,"isLittleEndian",Ab())}static get isEvalSupported(){return Y(this,"isEvalSupported",yb())}static get isOffscreenCanvasSupported(){return Y(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Y(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return Y(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(){var t,e;return Y(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Su=Array.from(Array(256).keys(),u=>u.toString(16).padStart(2,"0"));var rn,ed,Mu;class N{static makeHexColor(t,e,s){return`#${Su[t]}${Su[e]}${Su[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){const n=t[s],r=t[s+1];t[s]=n*e[0]+r*e[2]+e[4],t[s+1]=n*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const n=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5];for(let c=0;c<6;c+=2){const d=t[s+c],p=t[s+c+1];t[s+c]=d*n+p*a+l,t[s+c+1]=d*r+p*o+h}}static applyInverseTransform(t,e){const s=t[0],n=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const n=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5],c=t[0],d=t[1],p=t[2],b=t[3];let y=n*c+l,A=y,v=n*p+l,w=v,S=o*d+h,_=S,E=o*b+h,C=E;
1if(r!==0||a!==0){const x=r*c,T=r*p,k=a*d,M=a*b;y+=k,w+=k,v+=M,A+=M,S+=x,C+=x,E+=T,_+=T}s[0]=Math.min(s[0],y,v,A,w),s[1]=Math.min(s[1],S,E,_,C),s[2]=Math.max(s[2],y,v,A,w),s[3]=Math.max(s[3],S,E,_,C)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],n=t[1],r=t[2],a=t[3],o=s**2+n**2,l=s*r+n*a,h=r**2+a**2,c=(o+h)/2,d=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>n)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,n,a]}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,n,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,n),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,n)}static bezierBoundingBox(t,e,s,n,r,a,o,l,h){h[0]=Math.min(h[0],t,o),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,o),h[3]=Math.max(h[3],e,l),m(this,rn,Mu).call(this,t,s,r,o,e,n,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),h),m(this,rn,Mu).call(this,t,s,r,o,e,n,a,l,3*(-e+3*(n-a)+l),6*(e-2*n+a),3*(n-e),h)}}rn=new WeakSet,ed=function(t,e,s,n,r,a,o,l,h,c){if(h<=0||h>=1)return;const d=1-h,p=h*h,b=p*h,y=d*(d*(d*t+3*h*e)+3*p*s)+b*n,A=d*(d*(d*r+3*h*a)+3*p*o)+b*l;c[0]=Math.min(c[0],y),c[1]=Math.min(c[1],A),c[2]=Math.max(c[2],y),c[3]=Math.max(c[3],A)},Mu=function(t,e,s,n,r,a,o,l,h,c,d,p){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&m(this,rn,ed).call(this,t,e,s,n,r,a,o,l,-d/c,p);return}const b=c**2-4*d*h;if(b<0)return;const y=Math.sqrt(b),A=2*h;m(this,rn,ed).call(this,t,e,s,n,r,a,o,l,(-c+y)/A,p),m(this,rn,ed).call(this,t,e,s,n,r,a,o,l,(-c-y)/A,p)},g(N,rn);function wb(u){return decodeURIComponent(escape(u))}let Eu=null,Sp=null;function Zp(u){return Eu||(Eu=/([\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,Sp=new Map([["ï¬ ","Å¿t"]])),u.replaceAll(Eu,(t,e,s)=>e?e.normalize("NFKC"):Sp.get(s))}function sp(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),Jp(u)}const ip="pdfjs_internal_id_";function vb(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,n,...r]=e;if(!u(s)&&!Number.isInteger(s)||!t(n))return!1;const a=r.length;let o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}function Ae(u,t,e){return Math.min(Math.max(u,t),e)}function tg(u){return Uint8Array.prototype.toBase64?u.toBase64():btoa(Jp(u))}function _b(u){return Uint8Array.fromBase64?Uint8Array.fromBase64(u):Hc(atob(u))}typeof Promise.try!="function"&&(Promise.try=function(u,...t){return new Promise(e=>{e(u(...t))})});typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(u){return u.reduce((t,e)=>t+e,0)});class Zl{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function n(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(Zl.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const h of r.children)n(h)}return n(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class np{static setupStorage(t,e,s,n,r){const a=n.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{n.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",o=>{n.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),r==="print")break;t.addEventListener("input",o=>{n.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;n.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:n,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${n}`);for(const[l,h]of Object.entries(a))if(h!=null)switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,p;const e=t.annotationStorage,s=t.linkService,n=t.xfaHtml,r=t.intent||"display",a=document.createElement(n.name);n.attributes&&this.setAttributes({html:a,element:n,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const b=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=b}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(n.children.length===0){if(n.value){const b=document.createTextNode(n.value);a.append(b),o&&Zl.shouldBuildText(n.name)&&h.push(b)}return{textDivs:h}}const c=[[n,-1,a]];for(;c.length>0;){const[b,y,A]=c.at(-1);if(y+1===b.children.length){c.pop();continue}const v=b.children[++c.at(-1)[1]];if(v===null)continue;const{name:w}=v;if(w==="#text"){const _=document.createTextNode(v.value);h.push(_),A.append(_);continue}const S=(d=v==null?void 0:v.attributes)!=null&&d.xmlns?document.createElementNS(v.attributes.xmlns,w):document.createElement(w);if(A.append(S),v.attributes&&this.setAttributes({html:S,element:v,storage:e,intent:r,linkService:s}),((p=v.children)==null?void 0:p.length)>0)c.push([v,-1,S]);else if(v.value){const _=document.createTextNode(v.value);o&&Zl.shouldBuildText(w)&&h.push(_),S.append(_)}}for(const b of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))b.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Ai="http://www.w3.org/2000/svg",pr=class pr{};P(pr,"CSS",96),P(pr,"PDF",72),P(pr,"PDF_TO_CSS_UNITS",pr.CSS/pr.PDF);let ln=pr;async function _l(u,t="text"){if(kl(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const n=new XMLHttpRequest;n.open("GET",u,!0),n.responseType=t,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE){if(n.status===200||n.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(n.response);return}e(n.responseText);return}s(new Error(n.statusText))}},n.send(null)})}class Uc{constructor({viewBox:t,userUnit:e,scale:s,rotation:n,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=n,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,d,p,b;switch(n%=360,n<0&&(n+=360),n){case 180:c=-1,d=0,p=0,b=1;break;case 90:c=0,d=1,p=1,b=0;break;case 270:c=0,d=-1,p=-1,b=0;break;case 0:c=1,d=0,p=0,b=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(p=-p,b=-b);let y,A,v,w;c===0?(y=Math.abs(h-t[1])*s+r,A=Math.abs(l-t[0])*s+a,v=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(y=Math.abs(l-t[0])*s+r,A=Math.abs(h-t[1])*s+a,v=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,d*s,p*s,b*s,y-c*s*l-p*s*h,A-d*s*l-b*s*h],this.width=v,this.height=w}get rawDims(){const t=this.viewBox;return Y(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:n=this.offsetY,dontFlip:r=!1}={}){return new Uc({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return N.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];N.applyTransform(e,this.transform);const s=[t[2],t[3]];return N.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return N.applyInverseTransform(s,this.transform),s}}class fu extends Ma{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function $c(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function pu(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function eg(u){return[u]=u.split(/[#?]/,1),u.substring(u.lastIndexOf("/")+1)}function sg(u,t="document.pdf"){if(typeof u!="string")return t;if($c(u))return V('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{try{return new URL(decodeURIComponent(o))}catch{try{return new URL(o,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{return null}}}}})(u);if(!s)return t;const n=o=>{try{let l=decodeURIComponent(o);return l.includes("/")?(l=l.split("/").at(-1),l.test(/^\.pdf$/i)?l:o):l}catch{return o}},r=/\.pdf$/i,a=s.pathname.split("/").at(-1);if(r.test(a))return n(a);if(s.searchParams.size>0){const o=Array.from(s.searchParams.values()).reverse();for(const h of o)if(r.test(h))return n(h);const l=Array.from(s.searchParams.keys()).reverse();for(const h of l)if(r.test(h))return n(h)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return n(l[0])}return t}class Ep{constructor(){P(this,"started",Object.create(null));P(this,"times",[])}time(t){t in this.started&&V(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||V(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:n,end:r}of this.times)t.push(`${s.padEnd(e)} ${r-n}ms 2`);return t.join("")}}function kl(u,t){const e=t?URL.parse(u,t):URL.parse(u);return(e==null?void 0:e.protocol)==="http:"||(e==null?void 0:e.protocol)==="https:"}function rs(u){u.preventDefault()}function Pt(u){u.preventDefault(),u.stopPropagation()}function Sb(u){""+u}var nh;class th{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;i(this,nh)||f(this,nh,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=i(this,nh).exec(t);if(!e)return null;const s=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";
2let 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==="-"?(a+=c,o+=d):h==="+"&&(a-=c,o-=d),new Date(Date.UTC(s,n,r,a,o,l))}}nh=new WeakMap,g(th,nh);function ig(u,{scale:t=1,rotation:e=0}){const{width:s,height:n}=u.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new Uc({viewBox:r,userUnit:1,scale:t,rotation:e})}function Sl(u){if(u.startsWith("#")){const t=parseInt(u.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return u.startsWith("rgb(")?u.slice(4,-1).split(",").map(t=>parseInt(t)):u.startsWith("rgba(")?u.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(V(`Not a valid color format: "${u}"`),[0,0,0])}function Eb(u){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of u.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;u.set(e,Sl(s))}t.remove()}function Tt(u){const{a:t,b:e,c:s,d:n,e:r,f:a}=u.getTransform();return[t,e,s,n,r,a]}function $s(u){const{a:t,b:e,c:s,d:n,e:r,f:a}=u.getTransform().invertSelf();return[t,e,s,n,r,a]}function ar(u,t,e=!1,s=!0){if(t instanceof Uc){const{pageWidth:n,pageHeight:r}=t.rawDims,{style:a}=u,o=ee.isCSSRoundSupported,l=`var(--total-scale-factor) * ${n}px`,h=`var(--total-scale-factor) * ${r}px`,c=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,d=o?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=c,a.height=d):(a.width=d,a.height=c)}s&&u.setAttribute("data-main-rotation",t.rotation)}class Hs{constructor(){const{pixelRatio:t}=Hs;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,n,r=-1){let a=1/0,o=1/0,l=1/0;s=Hs.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),n!==-1&&(o=n/t,l=n/e);const h=Math.min(a,o,l);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>=0){const 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}}const Id=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Cb{static get isDarkMode(){var t;return Y(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class ng{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),Y(this,"commentForegroundColor",Sl(s))}}function rg(u,t,e,s){s=Math.min(Math.max(s??1,0),1);const n=255*(1-s);return u=Math.round(u*s+n),t=Math.round(t*s+n),e=Math.round(e*s+n),[u,t,e]}function Cp(u,t){const e=u[0]/255,s=u[1]/255,n=u[2]/255,r=Math.max(e,s,n),a=Math.min(e,s,n),o=(r+a)/2;if(r===a)t[0]=t[1]=0;else{const l=r-a;switch(t[1]=o<.5?l/(r+a):l/(2-r-a),r){case e:t[0]=((s-n)/l+(s<n?6:0))*60;break;case s:t[0]=((n-e)/l+2)*60;break;case n:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function Du(u,t){const e=u[0],s=u[1],n=u[2],r=(1-Math.abs(2*n-1))*s,a=r*(1-Math.abs(e/60%2-1)),o=n-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+o,t[1]=a+o,t[2]=o;break;case 1:t[0]=a+o,t[1]=r+o,t[2]=o;break;case 2:t[0]=o,t[1]=r+o,t[2]=a+o;break;case 3:t[0]=o,t[1]=a+o,t[2]=r+o;break;case 4:t[0]=a+o,t[1]=o,t[2]=r+o;break;case 5:case 6:t[0]=r+o,t[1]=o,t[2]=a+o;break}}function xp(u){return u<=.03928?u/12.92:((u+.055)/1.055)**2.4}function Tp(u,t,e){Du(u,e),e.map(xp);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Du(t,e),e.map(xp);const n=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const Pp=new Map;function ag(u,t){const e=u[0]+u[1]*256+u[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=Pp.get(e);if(s)return s;const n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);Cp(u,a);const o=n.subarray(6,9);Cp(t,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),Tp(a,o,r)<h){let c,d;l?(c=a[2],d=1):(c=0,d=a[2]);const p=.005;for(;d-c>p;){const b=a[2]=(c+d)/2;l===Tp(a,o,r)<h?c=b:d=b}a[2]=l?d:c}return Du(a,r),s=N.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),Pp.set(e,s),s}function rp({html:u,dir:t,className:e},s){const n=document.createDocumentFragment();if(typeof u=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=u.split(/(?:\r\n?|\n)/);for(let o=0,l=a.length;o<l;++o){const h=a[o];r.append(document.createTextNode(h)),o<l-1&&r.append(document.createElement("br"))}n.append(r)}else np.render({xfaHtml:u,div:n,intent:"richText"});n.firstChild.classList.add("richText",e),s.append(n)}var un,fn,hs,cs,rh,pn,Xa,qa,ah,Wd,og,ce,lg,hg,Ia,Ml;const vi=class vi{constructor(t){g(this,ce);g(this,un,null);g(this,fn,null);g(this,hs);g(this,cs,null);g(this,rh,null);g(this,pn,null);g(this,Xa,null);g(this,qa,null);f(this,hs,t),i(vi,ah)||f(vi,ah,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(){const t=f(this,un,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=i(this,hs)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",rs,{signal:e}),t.addEventListener("pointerdown",m(vi,Wd,og),{signal:e}));const s=f(this,cs,document.createElement("div"));s.className="buttons",t.append(s);const n=i(this,hs).toolbarPosition;if(n){const{style:r}=t,a=i(this,hs)._uiManager.direction==="ltr"?1-n[0]:n[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return i(this,un)}hide(){var t;i(this,un).classList.add("hidden"),(t=i(this,fn))==null||t.hideDropdown()}show(){var t,e;i(this,un).classList.remove("hidden"),(t=i(this,rh))==null||t.shown(),(e=i(this,pn))==null||e.shown()}
2addDeleteButton(){const{editorType:t,_uiManager:e}=i(this,hs),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",i(vi,ah)[t]),m(this,ce,Ia).call(this,s)&&s.addEventListener("click",n=>{e.delete()},{signal:e._signal}),i(this,cs).append(s)}async addAltText(t){const e=await t.render();m(this,ce,Ia).call(this,e),i(this,cs).append(e,i(this,ce,Ml)),f(this,rh,t)}addComment(t,e=null){if(i(this,pn))return;const s=t.renderForToolbar();if(!s)return;m(this,ce,Ia).call(this,s);const n=f(this,Xa,i(this,ce,Ml));e?(i(this,cs).insertBefore(s,e),i(this,cs).insertBefore(n,e)):i(this,cs).append(s,n),f(this,pn,t),t.toolbar=this}addColorPicker(t){if(i(this,fn))return;f(this,fn,t);const e=t.renderButton();m(this,ce,Ia).call(this,e),i(this,cs).append(e,i(this,ce,Ml))}async addEditSignatureButton(t){const e=f(this,qa,await t.renderEditButton(i(this,hs)));m(this,ce,Ia).call(this,e),i(this,cs).append(e,i(this,ce,Ml))}removeButton(t){var e,s;switch(t){case"comment":(e=i(this,pn))==null||e.removeToolbarCommentButton(),f(this,pn,null),(s=i(this,Xa))==null||s.remove(),f(this,Xa,null);break}}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e);break}}async addButtonBefore(t,e,s){const n=i(this,cs).querySelector(s);n&&t==="comment"&&this.addComment(e,n)}updateEditSignatureButton(t){i(this,qa)&&(i(this,qa).title=t)}remove(){var t;i(this,un).remove(),(t=i(this,fn))==null||t.destroy(),f(this,fn,null)}};un=new WeakMap,fn=new WeakMap,hs=new WeakMap,cs=new WeakMap,rh=new WeakMap,pn=new WeakMap,Xa=new WeakMap,qa=new WeakMap,ah=new WeakMap,Wd=new WeakSet,og=function(t){t.stopPropagation()},ce=new WeakSet,lg=function(t){i(this,hs)._focusEventsAllowed=!1,Pt(t)},hg=function(t){i(this,hs)._focusEventsAllowed=!0,Pt(t)},Ia=function(t){const e=i(this,hs)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",m(this,ce,lg).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",m(this,ce,hg).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",rs,{signal:e}),!0)},Ml=function(){const t=document.createElement("div");return t.className="divider",t},g(vi,Wd),g(vi,ah,null);let Ru=vi;var oh,br,Si,hn,cg,dg,Lu;class xb{constructor(t){g(this,hn);g(this,oh,null);g(this,br,null);g(this,Si);f(this,Si,t)}show(t,e,s){const[n,r]=m(this,hn,dg).call(this,e,s),{style:a}=i(this,br)||f(this,br,m(this,hn,cg).call(this));t.append(i(this,br)),a.insetInlineEnd=`${100*n}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){i(this,br).remove()}}oh=new WeakMap,br=new WeakMap,Si=new WeakMap,hn=new WeakSet,cg=function(){const t=f(this,br,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=i(this,Si)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",rs,{signal:e});const s=f(this,oh,document.createElement("div"));return s.className="buttons",t.append(s),i(this,Si).hasCommentManager()&&m(this,hn,Lu).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{i(this,Si).commentSelection("floating_button")}),m(this,hn,Lu).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{i(this,Si).highlightSelection("floating_button")}),t},dg=function(t,e){let s=0,n=0;for(const r of t){const a=r.y+r.height;if(a<s)continue;const o=r.x+(e?r.width:0);if(a>s){n=o,s=a;continue}e?o>n&&(n=o):o<n&&(n=o)}return[e?1-n:n,s]},Lu=function(t,e,s,n){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=i(this,Si)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",rs,{signal:o}),r.addEventListener("click",n,{signal:o})),i(this,oh).append(r)};function ug(u,t,e){for(const s of e)t.addEventListener(s,u[s].bind(u))}var Xd;
2class Tb{constructor(){g(this,Xd,0)}get id(){return`${Ql}${zt(this,Xd)._++}`}}Xd=new WeakMap;var Ya,lh,ue,Ka,sd;const pp=class pp{constructor(){g(this,Ka);g(this,Ya,sp());g(this,lh,0);g(this,ue,null)}static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),n=new Image;n.src=t;const r=n.decode().then(()=>(s.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return Y(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:n,type:r}=t;return m(this,Ka,sd).call(this,`${e}_${s}_${n}_${r}`,t)}async getFromUrl(t){return m(this,Ka,sd).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,Ka,sd).call(this,t,s)}async getFromId(t){i(this,ue)||f(this,ue,new Map);const e=i(this,ue).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){i(this,ue)||f(this,ue,new Map);let s=i(this,ue).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),s={bitmap:n.transferToImageBitmap(),id:`image_${i(this,Ya)}_${zt(this,lh)._++}`,refCounter:1,isSvg:!1},i(this,ue).set(t,s),i(this,ue).set(s.id,s),s}getSvgUrl(t){const e=i(this,ue).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var n;i(this,ue)||f(this,ue,new Map);const e=i(this,ue).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(n=s.close)==null||n.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${i(this,Ya)}_`)}};Ya=new WeakMap,lh=new WeakMap,ue=new WeakMap,Ka=new WeakSet,sd=async function(t,e){i(this,ue)||f(this,ue,new Map);let s=i(this,ue).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${i(this,Ya)}_${zt(this,lh)._++}`,refCounter:0,isSvg:!1});let n;if(typeof e=="string"?(s.url=e,n=await _l(e,"blob")):e instanceof File?n=s.file=e:e instanceof Blob&&(n=e),n.type==="image/svg+xml"){const r=pp._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const d=s.svgUrl=a.result;o.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=a.onerror=c});a.readAsDataURL(n),await l}else s.bitmap=await createImageBitmap(n);s.refCounter=1}catch(n){V(n),s=null}return i(this,ue).set(t,s),s&&i(this,ue).set(s.id,s),s};let Iu=pp;var Ft,gn,hh,xt;class Pb{constructor(t=128){g(this,Ft,[]);g(this,gn,!1);g(this,hh);g(this,xt,-1);f(this,hh,t)}add({cmd:t,undo:e,post:s,mustExec:n,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(n&&t(),i(this,gn))return;const l={cmd:t,undo:e,post:s,type:r};if(i(this,xt)===-1){i(this,Ft).length>0&&(i(this,Ft).length=0),f(this,xt,0),i(this,Ft).push(l);return}if(a&&i(this,Ft)[i(this,xt)].type===r){o&&(l.undo=i(this,Ft)[i(this,xt)].undo),i(this,Ft)[i(this,xt)]=l;return}const h=i(this,xt)+1;h===i(this,hh)?i(this,Ft).splice(0,1):(f(this,xt,h),h<i(this,Ft).length&&i(this,Ft).splice(h)),i(this,Ft).push(l)}undo(){if(i(this,xt)===-1)return;f(this,gn,!0);const{undo:t,post:e}=i(this,Ft)[i(this,xt)];t(),e==null||e(),f(this,gn,!1),f(this,xt,i(this,xt)-1)}redo(){if(i(this,xt)<i(this,Ft).length-1){f(this,xt,i(this,xt)+1),f(this,gn,!0);const{cmd:t,post:e}=i(this,Ft)[i(this,xt)];t(),e==null||e(),f(this,gn,!1)}}hasSomethingToUndo(){return i(this,xt)!==-1}hasSomethingToRedo(){return i(this,xt)<i(this,Ft).length-1}cleanType(t){if(i(this,xt)!==-1){for(let e=i(this,xt);e>=0;e--)if(i(this,Ft)[e].type!==t){i(this,Ft).splice(e+1,i(this,xt)-e),f(this,xt,e);return}i(this,Ft).length=0,f(this,xt,-1)}}destroy(){f(this,Ft,null)}}
2Ft=new WeakMap,gn=new WeakMap,hh=new WeakMap,xt=new WeakMap;var qd,fg;class zc{constructor(t){g(this,qd);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ee.platform;for(const[s,n,r={}]of t)for(const a of s){const o=a.startsWith("mac+");e&&o?(this.callbacks.set(a.slice(4),{callback:n,options:r}),this.allKeys.add(a.split("+").at(-1))):!e&&!o&&(this.callbacks.set(a,{callback:n,options:r}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(m(this,qd,fg).call(this,e));if(!s)return;const{callback:n,options:{bubbles:r=!1,args:a=[],checker:o=null}}=s;o&&!o(t,e)||(n.bind(t,...a,e)(),r||Pt(e))}}qd=new WeakSet,fg=function(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e};const Yd=class Yd{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Eb(t),Y(this,"_colors",t)}convert(t){const e=Sl(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,n]of this._colors)if(n.every((r,a)=>r===e[a]))return Yd._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?N.makeHexColor(...e):t}};P(Yd,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Fu=Yd;var Qa,Be,Ja,Mt,Vt,Za,ds,to,us,fe,mn,bn,eo,An,js,fs,Ar,ch,dh,so,uh,Vs,yn,io,wn,Ws,Kd,vn,no,fh,_n,yr,ro,Sn,ph,Ut,at,Ei,En,Cn,gh,ao,mh,xn,Xs,Ci,bh,Ah,ps,D,id,Nu,pg,gg,Dl,mg,bg,Ag,Ou,yg,Bu,Hu,wg,ye,yi,vg,_g,Uu,Sg,Rl,$u;const za=class za{constructor(t,e,s,n,r,a,o,l,h,c,d,p,b,y,A,v){g(this,D);g(this,Qa,new AbortController);g(this,Be,null);g(this,Ja,null);g(this,Mt,new Map);g(this,Vt,new Map);g(this,Za,null);g(this,ds,null);g(this,to,null);g(this,us,new Pb);g(this,fe,null);g(this,mn,null);g(this,bn,null);g(this,eo,0);g(this,An,new Set);g(this,js,null);g(this,fs,null);g(this,Ar,new Set);P(this,"_editorUndoBar",null);g(this,ch,!1);g(this,dh,!1);g(this,so,!1);g(this,uh,null);g(this,Vs,null);g(this,yn,null);g(this,io,null);g(this,wn,!1);g(this,Ws,null);g(this,Kd,new Tb);g(this,vn,!1);g(this,no,!1);g(this,fh,!1);g(this,_n,null);g(this,yr,null);g(this,ro,null);g(this,Sn,null);g(this,ph,null);g(this,Ut,j.NONE);g(this,at,new Set);g(this,Ei,null);g(this,En,null);g(this,Cn,null);g(this,gh,null);g(this,ao,null);g(this,mh,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});g(this,xn,[0,0]);g(this,Xs,null);g(this,Ci,null);g(this,bh,null);g(this,Ah,null);g(this,ps,null);const w=this._signal=i(this,Qa).signal;f(this,Ci,t),f(this,bh,e),f(this,Ah,s),f(this,Za,n),f(this,fe,r),f(this,En,a),f(this,ao,l),this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:w}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:w}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:w}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:w}),o._on("setpreference",this.onSetPreference.bind(this),{signal:w}),o._on("switchannotationeditorparams",S=>this.updateParams(S.type,S.value),{signal:w}),window.addEventListener("pointerdown",()=>{f(this,no,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{f(this,no,!1)},{capture:!0,signal:w}),m(this,D,mg).call(this),m(this,D,wg).call(this),m(this,D,Ou).call(this),f(this,ds,l.annotationStorage),f(this,uh,l.filterFactory),f(this,Cn,h),f(this,io,c||null),f(this,ch,d),f(this,dh,p),f(this,so,b),f(this,ph,y||null),this.viewParameters={realScale:ln.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=A||null,this._supportsPinchToZoom=v!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=za.prototype,e=a=>i(a,Ci).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return Y(this,"_keyboardManager",new zc([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&i(a,Ci).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&i(a,Ci).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,n,r,a,o,l,h;(t=i(this,ps))==null||t.resolve(),f(this,ps,null),(e=i(this,Qa))==null||e.abort(),f(this,Qa,null),this._signal=null;for(const c of i(this,Vt).values())c.destroy();i(this,Vt).clear(),i(this,Mt).clear(),i(this,Ar).clear(),(s=i(this,Sn))==null||s.clear(),f(this,Be,null),i(this,at).clear(),i(this,us).destroy(),(n=i(this,Za))==null||n.destroy(),(r=i(this,fe))==null||r.destroy(),(a=i(this,En))==null||a.destroy(),(o=i(this,Ws))==null||o.hide(),f(this,Ws,null),(l=i(this,ro))==null||l.destroy(),f(this,ro,null),f(this,Ja,null),i(this,Vs)&&(clearTimeout(i(this,Vs)),f(this,Vs,null)),i(this,Xs)&&(clearTimeout(i(this,Xs)),f(this,Xs,null)),(h=this._editorUndoBar)==null||h.destroy(),f(this,ao,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return i(this,ph)}get useNewAltTextFlow(){return i(this,dh)}get useNewAltTextWhenAddingImage(){return i(this,so)}get hcmFilter(){return Y(this,"hcmFilter",i(this,Cn)?i(this,uh).addHCMFilter(i(this,Cn).foreground,i(this,Cn).background):"none")}get direction(){return Y(this,"direction",getComputedStyle(i(this,Ci)).direction)}get _highlightColors(){return Y(this,"_highlightColors",i(this,io)?new Map(i(this,io).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return Y(this,"highlightColors",null);const e=new Map,s=!!i(this,Cn);for(const[n,r]of t){const a=n.endsWith("_HCM");if(s&&a){e.set(n.replace("_HCM",""),r);continue}!s&&!a&&e.set(n,r)}return Y(this,"highlightColors",e)}get highlightColorNames(){return Y(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),f(this,bn,t)}setMainHighlightColorPicker(t){f(this,ro,t)}editAltText(t,e=!1){var s;(s=i(this,Za))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!i(this,fe)}editComment(t,e,s,n){var r;(r=i(this,fe))==null||r.showDialog(this,t,e,s,n)}selectComment(t,e){const s=i(this,Vt).get(t),n=s==null?void 0:s.getEditorByUID(e);n==null||n.toggleComment(!0,!0)}updateComment(t){var e;(e=i(this,fe))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=i(this,fe))==null||e.updatePopupColor(t)}
2removeComment(t){var e;(e=i(this,fe))==null||e.removeComments([t.uid])}toggleComment(t,e,s=void 0){var n;(n=i(this,fe))==null||n.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=i(this,fe))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=i(this,fe))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(i(this,Vt).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),n=r=>{r.pageNumber===t&&(this._eventBus._off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n),await s}getSignature(t){var e;(e=i(this,En))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return i(this,En)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":f(this,so,e);break}}onPageChanging({pageNumber:t}){f(this,eo,t-1)}focusMainContainer(){i(this,Ci).focus()}findParent(t,e){for(const s of i(this,Vt).values()){const{x:n,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=n&&t<=n+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){i(this,bh).classList.toggle("noUserSelect",t)}addShouldRescale(t){i(this,Ar).add(t)}removeShouldRescale(t){i(this,Ar).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*ln.PDF_TO_CSS_UNITS;for(const s of i(this,Ar))s.onScaleChanging();(e=i(this,bn))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=m(this,D,id).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();const p=m(this,D,Nu).call(this,c),b=i(this,Ut)===j.NONE,y=()=>{const A=p==null?void 0:p.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o,text:l});b&&this.showAllEditors("highlight",!0,!0),e&&(A==null||A.editComment())};if(b){this.switchToMode(j.HIGHLIGHT,y);return}y()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!i(this,ds))return null;const e=`${Ql}${t}`,s=i(this,ds).getRawValue(e);return s&&i(this,ds).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&i(this,ds)&&!i(this,ds).has(t.id)&&i(this,ds).setValue(t.id,t)}a11yAlert(t,e=null){const s=i(this,Ah);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,i(this,wn)&&(f(this,wn,!1),m(this,D,Dl).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of i(this,at))if(e.div.contains(t)){f(this,yr,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!i(this,yr))return;const[t,e]=i(this,yr);f(this,yr,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,D,Ou).call(this),m(this,D,Bu).call(this)}removeEditListeners(){m(this,D,yg).call(this),m(this,D,Hu).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of i(this,fs))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of i(this,fs))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=i(this,Be))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const n of i(this,at)){const r=n.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const a of i(this,fs))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){V(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const n=this.currentLayer;try{const r=[];for(const l of s){const h=await n.deserialize(l);if(!h)return;r.push(h)}const a=()=>{for(const l of r)m(this,D,Uu).call(this,l);m(this,D,$u).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){V(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),i(this,Ut)!==j.NONE&&!this.isEditorHandlingKeyboard&&za._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,i(this,wn)&&(f(this,wn,!1),m(this,D,Dl).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}setEditingState(t){t?(m(this,D,bg).call(this),m(this,D,Bu).call(this),m(this,D,ye).call(this,{isEditing:i(this,Ut)!==j.NONE,isEmpty:m(this,D,Rl).call(this),hasSomethingToUndo:i(this,us).hasSomethingToUndo(),hasSomethingToRedo:i(this,us).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,D,Ag).call(this),m(this,D,Hu).call(this),m(this,D,ye).call(this,{isEditing:!1}),this.disableUserSelect(!1))}
2registerEditorTypes(t){if(!i(this,fs)){f(this,fs,t);for(const e of i(this,fs))m(this,D,yi).call(this,e.defaultPropertiesToUpdate)}}getId(){return i(this,Kd).id}get currentLayer(){return i(this,Vt).get(i(this,eo))}getLayer(t){return i(this,Vt).get(t)}get currentPageIndex(){return i(this,eo)}addLayer(t){i(this,Vt).set(t.pageIndex,t),i(this,vn)?t.enable():t.disable()}removeLayer(t){i(this,Vt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,n=!1,r=!1){var a,o,l,h,c,d;if(i(this,Ut)!==t&&!(i(this,ps)&&(await i(this,ps).promise,!i(this,ps)))){if(f(this,ps,Promise.withResolvers()),(a=i(this,bn))==null||a.commitOrRemove(),i(this,Ut)===j.POPUP&&((o=i(this,fe))==null||o.hideSidebar()),(l=i(this,fe))==null||l.destroyPopup(),f(this,Ut,t),t===j.NONE){this.setEditingState(!1),m(this,D,_g).call(this);for(const p of i(this,Mt).values())p.hideStandaloneCommentButton();(h=this._editorUndoBar)==null||h.hide(),this.toggleComment(null),i(this,ps).resolve();return}for(const p of i(this,Mt).values())p.addStandaloneCommentButton();t===j.SIGNATURE&&await((c=i(this,En))==null?void 0:c.loadSignatures()),this.setEditingState(!0),await m(this,D,vg).call(this),this.unselectAll();for(const p of i(this,Vt).values())p.updateMode(t);if(t===j.POPUP){i(this,Ja)||f(this,Ja,await i(this,ao).getAnnotationsByType(new Set(i(this,fs).map(y=>y._editorType))));const p=new Set,b=[];for(const y of i(this,Mt).values()){const{annotationElementId:A,hasComment:v,deleted:w}=y;A&&p.add(A),v&&!w&&b.push(y.getData())}for(const y of i(this,Ja)){const{id:A,popupRef:v,contentsObj:w}=y;v&&(w!=null&&w.str)&&!p.has(A)&&!i(this,An).has(A)&&b.push(y)}(d=i(this,fe))==null||d.showSidebar(b)}if(!e){s&&this.addNewEditorFromKeyboard(),i(this,ps).resolve();return}for(const p of i(this,Mt).values())p.uid===e?(this.setSelected(p),r?p.editComment():n?p.enterInEditMode():p.focus()):p.unselect();i(this,ps).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==i(this,Ut)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(i(this,fs)){switch(t){case Z.CREATE:this.currentLayer.addNewEditor(e);return;case Z.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(i(this,gh)||f(this,gh,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of i(this,at))s.updateParams(t,e);else for(const s of i(this,fs))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of i(this,Mt).values())a.editorType===t&&a.show(e);(((r=i(this,gh))==null?void 0:r.get(Z.HIGHLIGHT_SHOW_ALL))??!0)!==e&&m(this,D,yi).call(this,[[Z.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(i(this,fh)!==t){f(this,fh,t);for(const e of i(this,Vt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of i(this,Mt).values())e.pageIndex===t&&(yield e)}getEditor(t){return i(this,Mt).get(t)}addEditor(t){i(this,Mt).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(i(this,Vs)&&clearTimeout(i(this,Vs)),f(this,Vs,setTimeout(()=>{this.focusMainContainer(),f(this,Vs,null)},0))),i(this,Mt).delete(t.id),t.annotationElementId&&((e=i(this,Sn))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!i(this,An).has(t.annotationElementId))&&((s=i(this,ds))==null||s.remove(t.id))}addDeletedAnnotationElement(t){i(this,An).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return i(this,An).has(t)}removeDeletedAnnotationElement(t){i(this,An).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){i(this,Be)!==t&&(f(this,Be,t),t&&m(this,D,yi).call(this,t.propertiesToUpdate))}updateUI(t){i(this,D,Sg)===t&&m(this,D,yi).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){m(this,D,yi).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(i(this,at).has(t)){i(this,at).delete(t),t.unselect(),m(this,D,ye).call(this,{hasSelectedEditor:this.hasSelection});return}i(this,at).add(t),t.select(),m(this,D,yi).call(this,t.propertiesToUpdate),m(this,D,ye).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),(e=i(this,bn))==null||e.commitOrRemove();for(const s of i(this,at))s!==t&&s.unselect();i(this,at).clear(),i(this,at).add(t),t.select(),m(this,D,yi).call(this,t.propertiesToUpdate),m(this,D,ye).call(this,{hasSelectedEditor:!0})}isSelected(t){return i(this,at).has(t)}get firstSelectedEditor(){return i(this,at).values().next().value}unselect(t){t.unselect(),i(this,at).delete(t),m(this,D,ye).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return i(this,at).size!==0}get isEnterHandled(){return i(this,at).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;i(this,us).undo(),m(this,D,ye).call(this,{hasSomethingToUndo:i(this,us).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,D,Rl).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){i(this,us).redo(),m(this,D,ye).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:i(this,us).hasSomethingToRedo(),isEmpty:m(this,D,Rl).call(this)})}addCommands(t){i(this,us).add(t),m(this,D,ye).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,D,Rl).call(this)})}cleanUndoStack(t){i(this,us).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...i(this,at)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(n,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},n=()=>{for(const a of e)m(this,D,Uu).call(this,a)};this.addCommands({cmd:s,undo:n,mustExec:!0})}commitOrRemove(){var t;(t=i(this,Be))==null||t.commitOrRemove()}hasSomethingToControl(){return i(this,Be)||this.hasSelection}selectAll(){for(const t of i(this,at))t.commit();m(this,D,$u).call(this,i(this,Mt).values())}unselectAll(){var t;if(!(i(this,Be)&&(i(this,Be).commitOrRemove(),i(this,Ut)!==j.NONE))&&!((t=i(this,bn))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of i(this,at))e.unselect();i(this,at).clear(),m(this,D,ye).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;i(this,xn)[0]+=t,i(this,xn)[1]+=e;const[n,r]=i(this,xn),a=[...i(this,at)],o=1e3;i(this,Xs)&&clearTimeout(i(this,Xs)),f(this,Xs,setTimeout(()=>{f(this,Xs,null),i(this,xn)[0]=i(this,xn)[1]=0,this.addCommands({cmd:()=>{for(const l of a)i(this,Mt).has(l.id)&&(l.translateInPage(n,r),l.translationDone())},undo:()=>{for(const l of a)i(this,Mt).has(l.id)&&(l.translateInPage(-n,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),f(this,js,new Map);for(const t of i(this,at))i(this,js).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!i(this,js))return!1;this.disableUserSelect(!1);const t=i(this,js);f(this,js,null);let e=!1;for(const[{x:n,y:r,pageIndex:a},o]of t)o.newX=n,o.newY=r,o.newPageIndex=a,e||(e=n!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(n,r,a,o)=>
2{if(i(this,Mt).has(n.id)){const l=i(this,Vt).get(o);l?n._setParentAndPosition(l,r,a):(n.pageIndex=o,n.x=r,n.y=a)}};return this.addCommands({cmd:()=>{for(const[n,{newX:r,newY:a,newPageIndex:o}]of t)s(n,r,a,o)},undo:()=>{for(const[n,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(n,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(i(this,js))for(const s of i(this,js).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||i(this,at).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return i(this,Be)===t}getActive(){return i(this,Be)}getMode(){return i(this,Ut)}isEditingMode(){return i(this,Ut)!==j.NONE}get imageManager(){return Y(this,"imageManager",new Iu)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:n,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(h,c,d,p)=>({x:(c-n)/a,y:1-(h+d-s)/r,width:p/a,height:d/r});break;case"180":o=(h,c,d,p)=>({x:1-(h+d-s)/r,y:1-(c+p-n)/a,width:d/r,height:p/a});break;case"270":o=(h,c,d,p)=>({x:1-(c+p-n)/a,y:(h-s)/r,width:p/a,height:d/r});break;default:o=(h,c,d,p)=>({x:(h-s)/r,y:(c-n)/a,width:d/r,height:p/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:p,y:b,width:y,height:A}of d.getClientRects())y===0||A===0||l.push(o(p,b,y,A))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(i(this,to)||f(this,to,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=i(this,to))==null||e.delete(t)}renderAnnotationElement(t){var n;const e=(n=i(this,to))==null?void 0:n.get(t.data.id);if(!e)return;const s=i(this,ds).getRawValue(e);s&&(i(this,Ut)===j.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const n=(r=i(this,Sn))==null?void 0:r.get(t);n&&(n.setCanvas(e,s),i(this,Sn).delete(t))}addMissingCanvas(t,e){(i(this,Sn)||f(this,Sn,new Map)).set(t,e)}};Qa=new WeakMap,Be=new WeakMap,Ja=new WeakMap,Mt=new WeakMap,Vt=new WeakMap,Za=new WeakMap,ds=new WeakMap,to=new WeakMap,us=new WeakMap,fe=new WeakMap,mn=new WeakMap,bn=new WeakMap,eo=new WeakMap,An=new WeakMap,js=new WeakMap,fs=new WeakMap,Ar=new WeakMap,ch=new WeakMap,dh=new WeakMap,so=new WeakMap,uh=new WeakMap,Vs=new WeakMap,yn=new WeakMap,io=new WeakMap,wn=new WeakMap,Ws=new WeakMap,Kd=new WeakMap,vn=new WeakMap,no=new WeakMap,fh=new WeakMap,_n=new WeakMap,yr=new WeakMap,ro=new WeakMap,Sn=new WeakMap,ph=new WeakMap,Ut=new WeakMap,at=new WeakMap,Ei=new WeakMap,En=new WeakMap,Cn=new WeakMap,gh=new WeakMap,ao=new WeakMap,mh=new WeakMap,xn=new WeakMap,Xs=new WeakMap,Ci=new WeakMap,bh=new WeakMap,Ah=new WeakMap,ps=new WeakMap,D=new WeakSet,id=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Nu=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of i(this,Vt).values())if(s.hasTextLayer(t))return s;return null},pg=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=m(this,D,id).call(this,t).closest(".textLayer"),n=this.getSelectionBoxes(s);n&&(i(this,Ws)||f(this,Ws,new xb(this)),i(this,Ws).show(s,n,this.direction==="ltr"))},gg=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){i(this,Ei)&&((r=i(this,Ws))==null||r.hide(),f(this,Ei,null),m(this,D,ye).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===i(this,Ei))return;const n=m(this,D,id).call(this,t).closest(".textLayer");if(!n){i(this,Ei)&&((a=i(this,Ws))==null||a.hide(),f(this,Ei,null),m(this,D,ye).call(this,{hasSelectedText:!1}));return}if((o=i(this,Ws))==null||o.hide(),f(this,Ei,e),m(this,D,ye).call(this,{hasSelectedText:!0}),!(i(this,Ut)!==j.HIGHLIGHT&&i(this,Ut)!==j.NONE)&&(i(this,Ut)===j.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),f(this,wn,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=i(this,Ut)===j.HIGHLIGHT?m(this,D,Nu).call(this,n):null;if(l==null||l.toggleDrawing(),i(this,no)){const h=new AbortController,c=this.combinedSignal(h),d=p=>{p.type==="pointerup"&&p.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),p.t
2ype==="pointerup"&&m(this,D,Dl).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("blur",d,{signal:c})}else l==null||l.toggleDrawing(!0),m(this,D,Dl).call(this,"main_toolbar")}},Dl=function(t=""){i(this,Ut)===j.HIGHLIGHT?this.highlightSelection(t):i(this,ch)&&m(this,D,pg).call(this)},mg=function(){document.addEventListener("selectionchange",m(this,D,gg).bind(this),{signal:this._signal})},bg=function(){if(i(this,yn))return;f(this,yn,new AbortController);const t=this.combinedSignal(i(this,yn));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Ag=function(){var t;(t=i(this,yn))==null||t.abort(),f(this,yn,null)},Ou=function(){if(i(this,_n))return;f(this,_n,new AbortController);const t=this.combinedSignal(i(this,_n));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},yg=function(){var t;(t=i(this,_n))==null||t.abort(),f(this,_n,null)},Bu=function(){if(i(this,mn))return;f(this,mn,new AbortController);const t=this.combinedSignal(i(this,mn));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})},Hu=function(){var t;(t=i(this,mn))==null||t.abort(),f(this,mn,null)},wg=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},ye=function(t){Object.entries(t).some(([s,n])=>i(this,mh)[s]!==n)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(i(this,mh),t)}),i(this,Ut)===j.HIGHLIGHT&&t.hasSelectedEditor===!1&&m(this,D,yi).call(this,[[Z.HIGHLIGHT_FREE,!0]]))},yi=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},vg=async function(){if(!i(this,vn)){f(this,vn,!0);const t=[];for(const e of i(this,Vt).values())t.push(e.enable());await Promise.all(t);for(const e of i(this,Mt).values())e.enable()}},_g=function(){if(this.unselectAll(),i(this,vn)){f(this,vn,!1);for(const t of i(this,Vt).values())t.disable();for(const t of i(this,Mt).values())t.disable()}},Uu=function(t){const e=i(this,Vt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Sg=function(){let t=null;for(t of i(this,at));return t},Rl=function(){if(i(this,Mt).size===0)return!0;if(i(this,Mt).size===1)for(const t of i(this,Mt).values())return t.isEmpty();return!1},$u=function(t){for(const e of i(this,at))e.unselect();i(this,at).clear();for(const e of t)e.isEmpty()||(i(this,at).add(e),e.select());m(this,D,ye).call(this,{hasSelectedEditor:this.hasSelection})},P(za,"TRANSLATE_SMALL",1),P(za,"TRANSLATE_BIG",10);let or=za;var qt,qs,xs,oo,Ys,He,lo,Ks,ke,xi,wr,Qs,Tn,Bs,Ll,nd;const we=class we{constructor(t){g(this,Bs);g(this,qt,null);g(this,qs,!1);g(this,xs,null);g(this,oo,null);g(this,Ys,null);g(this,He,null);g(this,lo,!1);g(this,Ks,null);g(this,ke,null);g(this,xi,null);g(this,wr,null);g(this,Qs,!1);f(this,ke,t),f(this,Qs,t._uiManager.useNewAltTextFlow),i(we,Tn)||f(we,Tn,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){we._l10n??(we._l10n=t)}async render(){const t=f(this,xs,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=f(this,oo,document.createElement("span"));t.append(e),i(this,Qs)?(t.classList.add("new"),t.setAttribute("data-l10n-id",i(we,Tn).missing),e.setAttribute("data-l10n-id",i(we,Tn)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=i(this,ke)._uiManager._signal;t.addEventListener("contextmenu",rs,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const n=r=>{r.preventDefault(),i(this,ke)._uiManager.editAltText(i(this,ke)),i(this,Qs)&&i(this,ke)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:i(this,Bs,Ll)}})};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(f(this,lo,!0),n(r))},{signal:s}),await m(this,Bs,nd).call(this),t}finish(){i(this,xs)&&(i(this,xs).focus({focusVisible:i(this,lo)}),f(this,lo,!1))}isEmpty(){return i(this,Qs)?i(this,qt)===null:!i(this,qt)&&!i(this,qs)}hasData(){return i(this,Qs)?i(this,qt)!==null||!!i(this,xi):this.isEmpty()}get guessedText(){return i(this,xi)}async setGuessedText(t){i(this,qt)===null&&(f(this,xi,t),f(this,wr,await we._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,Bs,nd).call(this))}toggleAltTextBadge(t=!1){var e;if(!i(this,Qs)||i(this,qt)){(e=i(this,Ks))==null||e.remove(),f(this,Ks,null);return}if(!i(this,Ks)){const s=f(this,Ks,document.createElement("div"));s.className="noAltTextBadge",i(this,ke).div.append(s)}i(this,Ks).classList.toggle("hidden",!t)}serialize(t){let e=i(this,qt);return!t&&i(this,xi)===e&&(e=i(this,wr)),{altText:e,decorative:i(this,qs),guessedText:i(this,xi),textWithDisclaimer:i(this,wr)}}get data(){return{altText:i(this,qt),decorative:i(this,qs)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:n,cancel:r=!1}){s&&(f(this,xi,s),f(this,wr,n)),!(i(this,qt)===t&&i(this,qs)===e)&&(r||(f(this,qt,t),f(this,qs,e)),m(this,Bs,nd).call(this))}toggle(t=!1){i(this,xs)&&(!t&&i(this,He)&&(clearTimeout(i(this,He)),f(this,He,null)),i(this,xs).disabled=!t)}shown(){i(this,ke)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:i(this,Bs,Ll)}})}destroy(){var t,e;(t=i(this,xs))==null||t.remove(),f(this,xs,null),f(this,oo,null),f(this,Ys,null),(e=i(this,Ks))==null||e.remove(),f(this,Ks,null)}};qt=new WeakMap,qs=new WeakMap,xs=new WeakMap,oo=new WeakMap,Ys=new WeakMap,He=new WeakMap,lo=new WeakMap,Ks=new WeakMap,ke=new WeakMap,xi=new WeakMap,wr=new WeakMap,Qs=new WeakMap,Tn=new WeakMap,Bs=new WeakSet,Ll=function(){return i(this,qt)&&"added"||i(this,qt)===null&&this.guessedText&&"review"||"missing"},nd=async function(){var n,r,a;const t=i(this,xs);if(!t)return;if(i(this,Qs)){if(t.classList.toggle("done",!!i(this,qt)),t.setAttribute("data-l10n-id",i(we,Tn)[i(this,Bs,Ll)]),(n=i(this,oo))==null||n.setAttribute("data-l10n-id",i(we,Tn)[`${i(this,Bs,Ll)}-label`]),!i(this,qt)){(r=i(this,Ys))==null||r.remove();return}}else{if(!i(this,qt)&&!i(this,qs)){t.classList.remove("done"),(a=i(this,Ys))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=i(this,Ys);if(!e){f(this,Ys,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${i(this,ke).id}`;const o=100,l=i(this,ke)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(i(this,He)),f(this,He,null)},{once:!0}),t.addEventListener("mouseenter",()=>{f(this,He,setTimeout(()=>{f(this,He,null),i(this,Ys).classList.add("show"),i(this,ke)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;i(this,He)&&(clearTimeout(i(this,He)),f(this,He,null)),(h=i(this,Ys))==null||h.classList.remove("show")},{signal:l})}i(this,qs)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=i(this,qt)),e.parentNode||t.append(e);const s=i(this,ke).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},g(we,Tn,null),P(we,"_l10n",null);let Fd=we;var ie,gs,vr,wt,yh,_r,Ts,Sr,Er,Cr,wh,zu;class Wc{constructor(t){g(this,wh);g(this,ie,null);g(this,gs,null);g(this,vr,!1);g(this,wt,null);g(this,yh,null);g(this,_r,null);g(this,Ts,null);g(this,Sr,null);g(this,Er,!1);g(this,Cr,null);f(this,wt,t)}renderForToolbar(){const t=f(this,gs,document.createElement("button"));
2return t.className="comment",m(this,wh,zu).call(this,t,!1)}renderForStandalone(){const t=f(this,ie,document.createElement("button"));t.className="annotationCommentButton";const e=i(this,wt).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(i(this,wt)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const n=i(this,wt).commentButtonColor;n&&(s.backgroundColor=n)}return m(this,wh,zu).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=i(this,ie)??i(this,gs))==null||t.focus()},0)}onUpdatedColor(){if(!i(this,ie))return;const t=i(this,wt).commentButtonColor;t&&(i(this,ie).style.backgroundColor=t),i(this,wt)._uiManager.updatePopupColor(i(this,wt))}get commentButtonWidth(){var t;return(((t=i(this,ie))==null?void 0:t.getBoundingClientRect().width)??0)/i(this,wt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(i(this,Cr))return i(this,Cr);if(!i(this,ie))return null;const{x:t,y:e,height:s}=i(this,ie).getBoundingClientRect(),{x:n,y:r,width:a,height:o}=i(this,wt).parent.boundingClientRect;return[(t-n)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){f(this,Cr,t)}hasDefaultPopupPosition(){return i(this,Cr)===null}removeStandaloneCommentButton(){var t;(t=i(this,ie))==null||t.remove(),f(this,ie,null)}removeToolbarCommentButton(){var t;(t=i(this,gs))==null||t.remove(),f(this,gs,null)}setCommentButtonStates({selected:t,hasPopup:e}){i(this,ie)&&(i(this,ie).classList.toggle("selected",t),i(this,ie).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,n;if(e)[s,n]=e;else{[s,n]=i(this,wt).commentButtonPosition;const{width:c,height:d,x:p,y:b}=i(this,wt);s=p+s*c,n=b+n*d}const r=i(this,wt).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;i(this,wt)._uiManager.editComment(i(this,wt),a+s*l,o+n*h,{...t,parentDimensions:r})}finish(){i(this,gs)&&(i(this,gs).focus({focusVisible:i(this,vr)}),f(this,vr,!1))}isDeleted(){return i(this,Er)||i(this,Ts)===""}isEmpty(){return i(this,Ts)===null}hasBeenEdited(){return this.isDeleted()||i(this,Ts)!==i(this,yh)}serialize(){return this.data}get data(){return{text:i(this,Ts),richText:i(this,_r),date:i(this,Sr),deleted:this.isDeleted()}}set data(t){if(t!==i(this,Ts)&&f(this,_r,null),t===null){f(this,Ts,""),f(this,Er,!0);return}f(this,Ts,t),f(this,Sr,new Date),f(this,Er,!1)}setInitialText(t,e=null){f(this,yh,t),this.data=t,f(this,Sr,null),f(this,_r,e)}shown(){}destroy(){var t,e;(t=i(this,gs))==null||t.remove(),f(this,gs,null),(e=i(this,ie))==null||e.remove(),f(this,ie,null),f(this,Ts,""),f(this,_r,null),f(this,Sr,null),f(this,wt,null),f(this,vr,!1),f(this,Er,!1)}}ie=new WeakMap,gs=new WeakMap,vr=new WeakMap,wt=new WeakMap,yh=new WeakMap,_r=new WeakMap,Ts=new WeakMap,Sr=new WeakMap,Er=new WeakMap,Cr=new WeakMap,wh=new WeakSet,zu=function(t,e){if(!i(this,wt)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[i(this,wt)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const s=i(this,wt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",rs,{signal:s}),e&&(t.addEventListener("focusin",r=>{i(this,wt)._focusEventsAllowed=!1,Pt(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{i(this,wt)._focusEventsAllowed=!0,Pt(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const n=r=>{r.preventDefault(),t===i(this,gs)?this.edit():i(this,wt).toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(f(this,vr,!0),n(r))},{signal:s}),t.addEventListener("pointerenter",()=>{i(this,wt).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{i(this,wt).toggleComment(!1,!1)},{signal:s}),t};var ho,xr,vh,_h,Sh,Eh,Ch,Ti,Tr,Pi,Pr,ki,lr,Eg,Cg,xg;const gp=class gp{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:n=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){g(this,lr);g(this,ho);g(this,xr,!1);g(this,vh,null);g(this,_h);g(this,Sh);g(this,Eh);g(this,Ch);g(this,Ti,null);g(this,Tr);g(this,Pi,null);g(this,Pr);g(this,ki,null);f(this,ho,t),f(this,vh,s),f(this,_h,e),f(this,Sh,n),f(this,Eh,r),f(this,Ch,a),f(this,Pr,new AbortController),f(this,Tr,AbortSignal.any([o,i(this,Pr).signal])),t.addEventListener("touchstart",m(this,lr,Eg).bind(this),{passive:!1,signal:i(this,Tr)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Hs.pixelRatio}destroy(){var t,e;(t=i(this,Pr))==null||t.abort(),f(this,Pr,null),(e=i(this,Ti))==null||e.abort(),f(this,Ti,null)}};ho=new WeakMap,xr=new WeakMap,vh=new WeakMap,_h=new WeakMap,Sh=new WeakMap,Eh=new WeakMap,Ch=new WeakMap,Ti=new WeakMap,Tr=new WeakMap,Pi=new WeakMap,Pr=new WeakMap,ki=new WeakMap,lr=new WeakSet,Eg=function(t){var n,r,a;if((n=i(this,_h))!=null&&n.call(this))return;if(t.touches.length===1){if(i(this,Ti))return;const o=f(this,Ti,new AbortController),l=AbortSignal.any([i(this,Tr),o.signal]),h=i(this,ho),c={capture:!0,signal:l,passive:!1},d=p=>{var b;p.pointerType==="touch"&&((b=i(this,Ti))==null||b.abort(),f(this,Ti,null))};h.addEventListener("pointerdown",p=>{p.pointerType==="touch"&&(Pt(p),d(p))},c),h.addEventListener("pointerup",d,c),h.addEventListener("pointercancel",d,c);return}if(!i(this,ki)){f(this,ki,new AbortController);const o=AbortSignal.any([i(this,Tr),i(this,ki).signal]),l=i(this,ho),h={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",m(this,lr,Cg).bind(this),h);const c=m(this,lr,xg).bind(this);l.addEventListener("touchend",c,h),l.addEventListener("touchcancel",c,h),h.capture=!0,l.addEventListener("pointerdown",Pt,h),l.addEventListener("pointermove",Pt,h),l.addEventListener("pointercancel",Pt,h),l.addEventListener("pointerup",Pt,h),(r=i(this,Sh))==null||r.call(this)}if(Pt(t),t.touches.length!==2||(a=i(this,vh))!=null&&a.call(this)){f(this,Pi,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),f(this,Pi,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},Cg=function(t){var E;if(!i(this,Pi)||t.touches.length!==2)return;Pt(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:n,screenY:r}=e,{screenX:a,screenY:o}=s,l=i(this,Pi),{touch0X:h,touch0Y:c,touch1X:d,touch1Y:p}=l,b=d-h,y=p-c,A=a-n,v=o-r,w=Math.hypot(A,v)||1,S=Math.hypot(b,y)||1;if(!i(this,xr)&&Math.abs(S-w)<=gp.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!i(this,xr)){f(this,xr,!0);return}const _=[(n+a)/2,(r+o)/2];(E=i(this,Eh))==null||E.call(this,_,S,w)},xg=function(t){var e;t.touches.length>=2||(i(this,ki)&&(i(this,ki).abort(),f(this,ki,null),(e=i(this,Ch))==null||e.call(this)),i(this,Pi)&&(Pt(t),f(this,Pi,null),f(this,xr,!1)))};let eh=gp;var kr,Ps,Et,gt,Mi,co,Pn,xh,ne,Mr,Di,Js,kn,Th,Dr,Ue,Ph,Rr,Ri,Zs,uo,fo,ms,Lr,kh,Qd,z,Gu,Mh,ju,rd,Tg,Pg,Vu,ad,Wu,kg,Mg,Dg,Xu,Rg,qu,Lg,Ig,Fg,Yu,Il;const W=class W{constructor(t){g(this,z);g(this,kr,null);g(this,Ps,null);g(this,Et,null);g(this,gt,null);g(this,Mi,null);g(this,co,!1);g(this,Pn,null);g(this,xh,"");g(this,ne,null);g(this,Mr,null);g(this,Di,null);g(this,Js,null);g(this,kn,null);g(this,Th,"");g(this,Dr,!1);g(this,Ue,null);g(this,Ph,!1);g(this,Rr,!1);g(this,Ri,!1);g(this,Zs,null);g(this,uo,0);g(this,fo,0);g(this,ms,null);g(this,Lr,null);P(this,"isSelected",!1);P(this,"_isCopy",!1);P(this,"_editToolbar",null);P(this,"_initialOptions",Object.create(null));P(this,"_initialData",null);P(this,"_isVisible",!0);P(this,"_uiManager",null);P(this,"_focusEventsAllowed",!0);g(this,kh,!1);g(this,Qd,W._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,n],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=W.prototype._resizeWithKeyboard,e=or.TRANSLATE_SMALL,s=or.TRANSLATE_BIG;return Y(this,"_resizerKeyboardManager",new zc([[["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"],W.prototype._stopResizingWithKeyboard]]))}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 Y(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new kb({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(W._l10n??(W._l10n=t),W._l10nResizer||(W._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"})),W._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);W._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){At("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return i(this,kh)}set _isDraggable(t){var e;f(this,kh,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=i(this,Qd)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(m(this,z,Il).call(this),(e=i(this,Js))==null||e.remove(),f(this,Js,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(i(this,Dr)?f(this,Dr,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,n){const[r,a]=this.parentDimensions;[s,n]=this.screenToPageTranslation(s,n),this.x=(t+s)/r,this.y=(e+n)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,n]=this.parentDimensions;this.setAt(t*s,e*n,this.width*s,this.height*n),this._onTranslated()}translate(t,e){m(this,z,Gu).call(this,this.parentDimensions,t,e)}translateInPage(t,e){i(this,Ue)||f(this,Ue,[this.x,this.y,this.width,this.height]),m(this,z,Gu).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){i(this,Ue)||f(this,Ue,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[n,r]}=this;if(this.x+=t/n,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:p}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,p)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,h]=this.getBaseTranslation();a+=l,o+=h;const{style:c}=s;c.left=`${(100*a).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!i(this,Ue)&&(i(this,Ue)[0]!==this.x||i(this,Ue)[1]!==this.y)}get _hasBeenResized(){return!!i(this,Ue)&&(i(this,Ue)[2]!==this.width||i(this,Ue)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=W,n=s/t,r=s/e;switch(this.rotation){case 90:return[-n,r];case 180:return[n,r];case 270:return[n,-r];default:return[-n,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,n]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=n,r*=s,a*=n,this._mustFixPosition)switch(t){case 0:r=Ae(r,0,s-o),a=Ae(a,0,n-l);break;case 90:r=Ae(r,0,s-l),a=Ae(a,o,n);break;case 180:r=Ae(r,o,s),a=Ae(a,l,n);break;case 270:r=Ae(r,l,s),a=Ae(a,0,n-o);break}this.x=r/=s,this.y=a/=n;const[h,c]=this.getBaseTranslation();r+=h,a+=c,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return m(s=W,Mh,ju).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=W,Mh,ju).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=i(this,Et))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||i(this,Rr))return this._editToolbar;this._editToolbar=new Ru(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[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(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}
2removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=i(this,Et))==null||e.destroy()}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return i(this,Et)||(Fd.initialize(W._l10n),f(this,Et,new Fd(this)),i(this,kr)&&(i(this,Et).data=i(this,kr),f(this,kr,null))),i(this,Et)}get altTextData(){var t;return(t=i(this,Et))==null?void 0:t.data}set altTextData(t){i(this,Et)&&(i(this,Et).data=t)}get guessedAltText(){var t;return(t=i(this,Et))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=i(this,Et))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=i(this,Et))==null?void 0:e.serialize(t)}hasAltText(){return!!i(this,Et)&&!i(this,Et).isEmpty()}hasAltTextData(){var t;return((t=i(this,Et))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=i(this,gt))==null||t.focusButton()}addCommentButton(){return i(this,gt)||f(this,gt,new Wc(this))}addStandaloneCommentButton(){if(i(this,Mi)){this._uiManager.isEditingMode()&&i(this,Mi).classList.remove("hidden");return}this.hasComment&&(f(this,Mi,i(this,gt).renderForStandalone()),this.div.append(i(this,Mi)))}removeStandaloneCommentButton(){i(this,gt).removeStandaloneCommentButton(),f(this,Mi,null)}hideStandaloneCommentButton(){var t;(t=i(this,Mi))==null||t.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:s,deleted:n}}=i(this,gt);return{text:e,richText:t,date:s,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){i(this,gt)||f(this,gt,new Wc(this)),i(this,gt).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||(i(this,gt)||f(this,gt,new Wc(this)),i(this,gt).setInitialText(t,s),!this.annotationElementId))return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){var t;return(t=i(this,gt))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=i(this,gt))==null?void 0:t.isDeleted()}get hasComment(){return!!i(this,gt)&&!i(this,gt).isEmpty()&&!i(this,gt).isDeleted()}async editComment(t){i(this,gt)||f(this,gt,new Wc(this)),i(this,gt).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){i(this,gt).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,n]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=n-100,h=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,h,n]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){i(this,gt).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const 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=i(this,co)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),m(this,z,qu).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[n,r]=this.getInitialTranslation();return this.translate(n,r),ug(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(i(this,Lr)||f(this,Lr,new eh({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:m(this,z,kg).bind(this),onPinching:m(this,z,Mg).bind(this),onPinchEnd:m(this,z,Dg).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=ee.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(f(this,Dr,!0),this._isDraggable){m(this,z,Rg).call(this,t);return}m(this,z,Xu).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){i(this,Zs)&&clearTimeout(i(this,Zs)),f(this,Zs,setTimeout(()=>{var t;f(this,Zs,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const n=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/n,c=e/n,d=this.x*r,p=this.y*a,b=this.width*r,y=this.height*a;switch(s){case 0:return[d+h+o,a-p-c-y+l,d+h+b+o,a-p-c+l];case 90:return[d+c+o,a-p+h+l,d+c+y+o,a-p+h+b+l];case 180:return[d-h-b+o,a-p+c+l,d-h+o,a-p+c+y+l];case 270:return[d-c-y+o,a-p-h-b+l,d-c+o,a-p-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,n,r,a]=t,o=r-s,l=a-n;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-n,l,o];case 180:return[r,e-n,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}
2getNonHCMColor(){return this.color&&W._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=i(this,gt))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:n,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:h,modificationDate:c}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:h,modificationDate:s||c,popupRef:!r,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),f(this,Rr,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),f(this,Rr,!1),!0):!1}isInEditMode(){return i(this,Rr)}shouldGetKeyboardEvents(){return i(this,Ri)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:n}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&n>0&&t<r&&s>0}rebuild(){m(this,z,qu).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const n=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation,f(n,kr,t.accessibilityData),n._isCopy=t.isCopy||!1;const[r,a]=n.pageDimensions,[o,l,h,c]=n.getRectInCurrentCoords(t.rect,a);return n.x=o/r,n.y=l/a,n.width=h/r,n.height=c/a,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e;if((t=i(this,kn))==null||t.abort(),f(this,kn,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),i(this,Zs)&&(clearTimeout(i(this,Zs)),f(this,Zs,null)),m(this,z,Il).call(this),this.removeEditToolbar(),i(this,ms)){for(const s of i(this,ms).values())clearTimeout(s);f(this,ms,null)}this.parent=null,(e=i(this,Lr))==null||e.destroy(),f(this,Lr,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,z,Tg).call(this),i(this,ne).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,n,r,a]=this.getPDFRect();return[W._round(s+(r-s)*t),W._round(n+(a-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return i(this,gt).commentPopupPositionInLayer}set commentPopupPosition(t){i(this,gt).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return i(this,gt).hasDefaultPopupPosition()}get commentButtonWidth(){return i(this,gt).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){i(this,gt).setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),f(this,Di,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=i(this,ne).children;if(!i(this,Ps)){f(this,Ps,Array.from(e));const a=m(this,z,Lg).bind(this),o=m(this,z,Ig).bind(this),l=this._uiManager._signal;for(const h of i(this,Ps)){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",m(this,z,Fg).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",W._l10nResizer[c])}}const s=i(this,Ps)[0];let n=0;for(const a of e){if(a===s)break;n++}const r=(360-this.rotation+this.parentRotation)%360/90*(i(this,Ps).length/4);if(r!==n){if(r<n)for(let o=0;o<n-r;o++)i(this,ne).append(i(this,ne).firstChild);else if(r>n)for(let o=0;o<r-n;o++)i(this,ne).firstChild.before(i(this,ne).lastChild);let a=0;for(const o of e){const h=i(this,Ps)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",W._l10nResizer[h])}}m(this,z,Yu).call(this,0),f(this,Ri,!0),i(this,ne).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){i(this,Ri)&&m(this,z,Wu).call(this,i(this,Th),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){m(this,z,Il).call(this),this.div.focus()}select(){var t,e,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var n,r;(n=this.div)!=null&&n.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=i(this,Et))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,s,n,r;this.isSelected&&(this.isSelected=!1,(t=i(this,ne))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(n=this._editToolbar)==null||n.hide(),(r=i(this,Et))==null||r.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,
2!1))}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.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return i(this,Ph)}set isEditing(t){f(this,Ph,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){i(this,ms)||f(this,ms,new Map);const{action:s}=t;let n=i(this,ms).get(s);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(t),i(this,ms).delete(s),i(this,ms).size===0&&f(this,ms,null)},W._telemetryTimeout),i(this,ms).set(s,n);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),f(this,co,!1)}disable(){this.div&&(this.div.tabIndex=-1),f(this,co,!0)}updateFakeAnnotationElement(t){if(!i(this,Js)&&!this.deleted){f(this,Js,t.addFakeAnnotation(this));return}if(this.deleted){i(this,Js).remove(),f(this,Js,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&i(this,Js).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"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};kr=new WeakMap,Ps=new WeakMap,Et=new WeakMap,gt=new WeakMap,Mi=new WeakMap,co=new WeakMap,Pn=new WeakMap,xh=new WeakMap,ne=new WeakMap,Mr=new WeakMap,Di=new WeakMap,Js=new WeakMap,kn=new WeakMap,Th=new WeakMap,Dr=new WeakMap,Ue=new WeakMap,Ph=new WeakMap,Rr=new WeakMap,Ri=new WeakMap,Zs=new WeakMap,uo=new WeakMap,fo=new WeakMap,ms=new WeakMap,Lr=new WeakMap,kh=new WeakMap,Qd=new WeakMap,z=new WeakSet,Gu=function([t,e],s,n){[s,n]=this.screenToPageTranslation(s,n),this.x+=s/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Mh=new WeakSet,ju=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},rd=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},Tg=function(){if(i(this,ne))return;f(this,ne,document.createElement("div")),i(this,ne).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const n=document.createElement("div");i(this,ne).append(n),n.classList.add("resizer",s),n.setAttribute("data-resizer-name",s),n.addEventListener("pointerdown",m(this,z,Pg).bind(this,s),{signal:e}),n.addEventListener("contextmenu",rs,{signal:e}),n.tabIndex=-1}this.div.prepend(i(this,ne))},Pg=function(t,e){var c;e.preventDefault();const{isMac:s}=ee.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=i(this,Et))==null||c.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,f(this,Mr,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",m(this,z,Wu).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Pt,{passive:!1,signal:a}),window.addEventListener("contextmenu",rs,{signal:a}),f(this,Di,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var d;r.abort(),this.parent.togglePointerEvents(!0),(d=i(this,Et))==null||d.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=o,this.div.style.cursor=l,m(this,z,ad).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},Vu=function(t,e,s,n){this.width=s,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},ad=function(){if(!i(this,Di))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:n}=i(this,Di);f(this,Di,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===n||this.addCommands({cmd:m(this,z,Vu).bind(this,r,a,o,l),undo:m(this,z,Vu).bind(this,t,e,s,n),mustExec:!0})},Wu=function(t,e){const[s,n]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=W.MIN_SIZE/s,c=W.MIN_SIZE/n,d=m(this,z,rd).call(this,this.rotation),p=($,U)=>[d[0]*$+d[2]*U,d[1]*$+d[3]*U],b=m(this,z,rd).call(this,360-this.rotation),y=($,U)=>[b[0]*$+b[2]*U,b[1]*$+b[3]*U];let A,v,w=!1,S=!1;switch(t){case"topLeft":w=!0,A=($,U)=>[0,0],v=($,U)=>[$,U];break;case"topMiddle":A=($,U)=>[$/2,0],v=($,U)=>[$/2,U];break;case"topRight":w=!0,A=($,U)=>[$,0],v=($,U)=>[0,U];break;case"middleRight":S=!0,A=($,U)=>[$,U/2],v=($,U)=>[0,U/2];break;case"bottomRight":w=!0,A=($,U)=>[$,U],v=($,U)=>[0,0];break;case"bottomMiddle":A=($,U)=>[$/2,U],v=($,U)=>[$/2,0];break;case"bottomLeft":w=!0,A=($,U)=>[0,U],v=($,U)=>[$,0];break;case"middleLeft":S=!0,A=($,U)=>[0,U/2],v=($,U)=>[$,U/2];break}const _=A(o,l),E=v(o,l);let C=p(...E);const x=W._round(r+C[0]),T=W._round(a+C[1]);let k=1,M=1,I,R;if(e.fromKeyboard)({deltaX:I,deltaY:R}=e);else{const{screenX:$,screenY:U}=e,[yt,Ot]=i(this,Mr);[I,R]=this.screenToPageTranslation($-yt,U-Ot),i(this,Mr)[0]=$,i(this,Mr)[1]=U}if([I,R]=y(I/s,R/n),w){const $=Math.hypot(o,l);k=M=Math.max(Math.min(Math.hypot(E[0]-_[0]-I,E[1]-_[1]-R)/$,1/o,1/l),h/o,c/l)}else S?k=Ae(Math.abs(E[0]-_[0]-I),h,1)/o:M=Ae(Math.abs(E[1]-_[1]-R),c,1)/l;const H=W._round(o*k),q=W._round(l*M);C=p(...v(H,q));const G=x-C[0],tt=T-C[1];i(this,Ue)||f(this,Ue,[this.x,this.y,this.width,this.height]),this.width=H,this.height=q,this.x=G,this.y=tt,this.setDims(),this.fixAndSetPosition(),this._onResizing()},kg=function(){var t;f(this,Di,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=i(this,Et))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},Mg=function(t,e,s){let r=.7*(s/e)+1-.7;
2if(r===1)return;const a=m(this,z,rd).call(this,this.rotation),o=(x,T)=>[a[0]*x+a[2]*T,a[1]*x+a[3]*T],[l,h]=this.parentDimensions,c=this.x,d=this.y,p=this.width,b=this.height,y=W.MIN_SIZE/l,A=W.MIN_SIZE/h;r=Math.max(Math.min(r,1/p,1/b),y/p,A/b);const v=W._round(p*r),w=W._round(b*r);if(v===p&&w===b)return;i(this,Ue)||f(this,Ue,[c,d,p,b]);const S=o(p/2,b/2),_=W._round(c+S[0]),E=W._round(d+S[1]),C=o(v/2,w/2);this.x=_-C[0],this.y=E-C[1],this.width=v,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Dg=function(){var t;(t=i(this,Et))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),m(this,z,ad).call(this)},Xu=function(t){const{isMac:e}=ee.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Rg=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const n=new AbortController,r=this._uiManager.combinedSignal(n),a={capture:!0,passive:!1,signal:r},o=h=>{n.abort(),f(this,Pn,null),f(this,Dr,!1),this._uiManager.endDragSession()||m(this,z,Xu).call(this,h),s&&this._onStopDragging()};e&&(f(this,uo,t.clientX),f(this,fo,t.clientY),f(this,Pn,t.pointerId),f(this,xh,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:p}=h;if(p!==i(this,Pn)){Pt(h);return}const[b,y]=this.screenToPageTranslation(c-i(this,uo),d-i(this,fo));f(this,uo,c),f(this,fo,d),this._uiManager.dragSelectedEditors(b,y)},a),window.addEventListener("touchmove",Pt,a),window.addEventListener("pointerdown",h=>{h.pointerType===i(this,xh)&&(i(this,Lr)||h.isPrimary)&&o(h),Pt(h)},a));const l=h=>{if(!i(this,Pn)||i(this,Pn)===h.pointerId){o(h);return}Pt(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},qu=function(){if(i(this,kn)||!this.div)return;f(this,kn,new AbortController);const t=this._uiManager.combinedSignal(i(this,kn));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Lg=function(t){W._resizerKeyboardManager.exec(this,t)},Ig=function(t){var e;i(this,Ri)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==i(this,ne)&&m(this,z,Il).call(this)},Fg=function(t){f(this,Th,i(this,Ri)?t:"")},Yu=function(t){if(i(this,Ps))for(const e of i(this,Ps))e.tabIndex=t},Il=function(){f(this,Ri,!1),m(this,z,Yu).call(this,-1),m(this,z,ad).call(this)},g(W,Mh),P(W,"_l10n",null),P(W,"_l10nResizer",null),P(W,"_borderLineWidth",-1),P(W,"_colorManager",new Fu),P(W,"_zIndex",1),P(W,"_telemetryTimeout",1e3);let vt=W;class kb extends vt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const kp=3285377520,os=4294901760,zs=65535;class Ng{constructor(t){this.h1=t?t&4294967295:kp,this.h2=t?t&4294967295:kp}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let A=0,v=t.length;A<v;A++){const w=t.charCodeAt(A);w<=255?e[s++]=w:(e[s++]=w>>>8,e[s++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const n=s>>2,r=s-n*4,a=new Uint32Array(e.buffer,0,n);let o=0,l=0,h=this.h1,c=this.h2;const d=3432918353,p=461845907,b=d&zs,y=p&zs;for(let A=0;A<n;A++)A&1?(o=a[A],o=o*d&os|o*b&zs,o=o<<15|o>>>17,o=o*p&os|o*y&zs,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[A],l=l*d&os|l*b&zs,l=l<<15|l>>>17,l=l*p&os|l*y&zs,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=e[n*4+2]<<16;case 2:o^=e[n*4+1]<<8;case 1:o^=e[n*4],o=o*d&os|o*b&zs,o=o<<15|o>>>17,o=o*p&os|o*y&zs,n&1?h^=o:c^=o}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&os|t*36045&zs,e=e*4283543511&os|((e<<16|t>>>16)*2950163797&os)>>>16,t^=e>>>1,t=t*444984403&os|t*60499&zs,e=e*3301882366&os|((e<<16|t>>>16)*3120437893&os)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Ku=Object.freeze({map:null,hash:"",transfer:void 0});var Ir,Fr,Li,re,Jd,Og;class ap{constructor(){g(this,Jd);g(this,Ir,!1);g(this,Fr,null);g(this,Li,null);g(this,re,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=i(this,re).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return i(this,re).get(t)}remove(t){const e=i(this,re).get(t);if(e!==void 0&&(e instanceof vt&&i(this,Li).delete(e.annotationElementId),i(this,re).delete(t),i(this,re).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const s of i(this,re).values())if(s instanceof vt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=i(this,re).get(t);let n=!1;if(s!==void 0)for(const[r,a]of Object.entries(e))s[r]!==a&&(n=!0,s[r]=a);else n=!0,i(this,re).set(t,e);n&&m(this,Jd,Og).call(this),e instanceof vt&&((i(this,Li)||f(this,Li,new Map)).set(e.annotationElementId,e),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type))}has(t){return i(this,re).has(t)}get size(){return i(this,re).size}resetModified(){i(this,Ir)&&(f(this,Ir,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Bg(this)}get serializable(){if(i(this,re).size===0)return Ku;const t=new Map,e=new Ng,s=[],n=Object.create(null);let r=!1;
2for(const[a,o]of i(this,re)){const l=o instanceof vt?o.serialize(!1,n):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Ku}get editorStats(){let t=null;const e=new Map;let s=0,n=0;for(const r of i(this,re).values()){if(!(r instanceof vt)){r.popup&&(r.popup.deleted?n+=1:s+=1);continue}r.isCommentDeleted?n+=1:r.hasEditedComment&&(s+=1);const a=r.telemetryFinalData;if(!a)continue;const{type:o}=a;e.has(o)||e.set(o,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[h,c]of Object.entries(a)){if(h==="type")continue;let d=l.get(h);d||(d=new Map,l.set(h,d));const p=d.get(c)??0;d.set(c,p+1)}}if((n>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:n,edited:s}),!t)return null;for(const[r,a]of e)t[r]=a.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){f(this,Fr,null)}updateEditor(t,e){var n;const s=(n=i(this,Li))==null?void 0:n.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=i(this,Li))==null?void 0:e.get(t))||null}get modifiedIds(){if(i(this,Fr))return i(this,Fr);const t=[];if(i(this,Li))for(const e of i(this,Li).values())e.serialize()&&t.push(e.annotationElementId);return f(this,Fr,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return i(this,re).entries()}}Ir=new WeakMap,Fr=new WeakMap,Li=new WeakMap,re=new WeakMap,Jd=new WeakSet,Og=function(){i(this,Ir)||(f(this,Ir,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Dh;class Bg extends ap{constructor(e){super();g(this,Dh);const{map:s,hash:n,transfer:r}=e.serializable,a=structuredClone(s,r?{transfer:r}:null);f(this,Dh,{map:a,hash:n,transfer:r})}get print(){At("Should not call PrintAnnotationStorage.print")}get serializable(){return i(this,Dh)}get modifiedIds(){return Y(this,"modifiedIds",{ids:new Set,hash:""})}}Dh=new WeakMap;var po;class Mb{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){g(this,po,new Set);this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),i(this,po).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||i(this,po).has(t.loadedName))){if(et(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:r,style:a}=t,o=new FontFace(n,r,a);this.addNativeFontFace(o);try{await o.load(),i(this,po).add(n),s==null||s(t)}catch{V(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}At("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(n){throw V(`Failed to load font '${s.family}': '${n}'.`),t.disableFontFace=!0,n}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const n=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,n)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return Y(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return Y(this,"isSyncFontLoadingSupported",Ee||ee.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(et(!n.done,"completeRequest() cannot be called twice."),n.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,n={done:!1,complete:e,callback:t};return s.push(n),n}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Y(this,"_loadTestFont",t)}
2_prepareFontLoadEvent(t,e){function s(E,C){return E.charCodeAt(C)<<24|E.charCodeAt(C+1)<<16|E.charCodeAt(C+2)<<8|E.charCodeAt(C+3)&255}function n(E,C,x,T){const k=E.substring(0,C),M=E.substring(C+x);return k+T+M}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let h=0;function c(E,C){if(++h>30){V("Load test font never loaded."),C();return}if(l.font="30px "+E,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(c.bind(null,E,C))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let p=this._loadTestFont;p=n(p,976,d.length,d);const y=16,A=1482184792;let v=s(p,y);for(r=0,a=d.length-3;r<a;r+=4)v=v-A+s(d,r)|0;r<d.length&&(v=v-A+s(d+"XXX",r)|0),p=n(p,y,4,bb(v));const w=`url(data:font/opentype;base64,${btoa(p)});`,S=`@font-face {font-family:"${d}";src:${w}}`;this.insertRule(S);const _=this._document.createElement("div");_.style.visibility="hidden",_.style.width=_.style.height="10px",_.style.position="absolute",_.style.top=_.style.left="0px";for(const E of[t.loadedName,d]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=E,_.append(C)}this._document.body.append(_),c(d,()=>{_.remove(),e.complete()})}}po=new WeakMap;var ct;class Db{constructor(t,e=null,s,n){g(this,ct);this.compiledGlyphs=Object.create(null),f(this,ct,t),this._inspectFont=e,s&&Object.assign(this,s),n&&(this.charProcOperatorList=n)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${tg(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let n;try{n=t.get(s)}catch(a){V(`getPathGenerator - ignoring character: "${a}".`)}const r=new Path2D(n||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return i(this,ct).black}get bold(){return i(this,ct).bold}get disableFontFace(){return i(this,ct).disableFontFace??!1}get fontExtraProperties(){return i(this,ct).fontExtraProperties??!1}get isInvalidPDFjsFont(){return i(this,ct).isInvalidPDFjsFont}get isType3Font(){return i(this,ct).isType3Font}get italic(){return i(this,ct).italic}get missingFile(){return i(this,ct).missingFile}get remeasure(){return i(this,ct).remeasure}get vertical(){return i(this,ct).vertical}get ascent(){return i(this,ct).ascent}get defaultWidth(){return i(this,ct).defaultWidth}get descent(){return i(this,ct).descent}get bbox(){return i(this,ct).bbox}get fontMatrix(){return i(this,ct).fontMatrix}get fallbackName(){return i(this,ct).fallbackName}get loadedName(){return i(this,ct).loadedName}get mimetype(){return i(this,ct).mimetype}get name(){return i(this,ct).name}get data(){return i(this,ct).data}clearData(){i(this,ct).clearData()}get cssFontInfo(){return i(this,ct).cssFontInfo}get systemFontInfo(){return i(this,ct).systemFontInfo}get defaultVMetrics(){return i(this,ct).defaultVMetrics}}ct=new WeakMap;function Rb(u){if(u instanceof URL)return u.href;if(typeof u=="string"){if(Ee)return u;const t=URL.parse(u,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Lb(u){if(Ee&&typeof Buffer<"u"&&u instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength)return u;if(typeof u=="string")return Hc(u);if(u instanceof ArrayBuffer||ArrayBuffer.isView(u)||typeof u=="object"&&!isNaN(u==null?void 0:u.length))return new Uint8Array(u);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Xc(u){if(typeof u!="string")return null;if(u.endsWith("/"))return u;throw new Error(`Invalid factory url: "${u}" must include trailing slash.`)}const Qu=u=>typeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0,Ib=u=>
2typeof u=="object"&&typeof(u==null?void 0:u.name)=="string",Hg=vb.bind(null,Qu,Ib);var Ii,Zd;class Fb{constructor(){g(this,Ii,new Map);g(this,Zd,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};i(this,Zd).then(()=>{for(const[n]of i(this,Ii))n.call(this,s)})}addEventListener(t,e,s=null){let n=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){V("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);n=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}i(this,Ii).set(e,n)}removeEventListener(t,e){const s=i(this,Ii).get(e);s==null||s(),i(this,Ii).delete(e)}terminate(){for(const[,t]of i(this,Ii))t==null||t();i(this,Ii).clear()}}Ii=new WeakMap,Zd=new WeakMap;const qc={DATA:1,ERROR:2},Ht={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Mp(){}function Te(u){if(u instanceof on||u instanceof Ld||u instanceof _p||u instanceof Jl||u instanceof _u)return u;switch(u instanceof Error||typeof u=="object"&&u!==null||At('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new on(u.message);case"InvalidPDFException":return new Ld(u.message);case"PasswordException":return new _p(u.message,u.code);case"ResponseException":return new Jl(u.message,u.status,u.missing);case"UnknownErrorException":return new _u(u.message,u.details)}return new _u(u.message,u.toString())}var go,vs,Ug,$g,zg,od;class Fl{constructor(t,e,s){g(this,vs);g(this,go,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",m(this,vs,Ug).bind(this),{signal:i(this,go).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const n=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[n]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,n){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:h.desiredSize},n),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:Ht.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{et(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[r].cancelCall=c,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Ht.CANCEL,streamId:r,reason:Te(h)}),c.promise}},s)}destroy(){var t;(t=i(this,go))==null||t.abort(),f(this,go,null)}}go=new WeakMap,vs=new WeakSet,Ug=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){m(this,vs,zg).call(this,t);return}if(t.callback){const s=t.callbackId,n=this.callbackCapabilities[s];if(!n)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===qc.DATA)n.resolve(t.data);else if(t.callback===qc.ERROR)n.reject(Te(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,n=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:n,callback:qc.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:n,callback:qc.ERROR,callbackId:t.callbackId,reason:Te(a)})});return}if(t.streamId){m(this,vs,$g).call(this,t);return}e(t.data)},$g=function(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,c=1,d){if(this.isCancelled)return;const p=this.desiredSize;this.desiredSize-=c,p>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:n,stream:Ht.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:n,stream:Ht.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){et(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:n,stream:Ht.ERROR,streamId:e,reason:Te(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:n,stream:Ht.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Ht.START_COMPLETE,streamId:e,reason:Te(h)})})},zg=function(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Ht.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(Te(t.reason));break;case Ht.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(Te(t.reason));break;case Ht.PULL:if(!o){r.postMessage({sourceName:s,targetName:n,stream:Ht.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Mp).then(function(){r.postMessage({sourceName:s,targetName:n,stream:Ht.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Ht.PULL_COMPLETE,streamId:e,reason:Te(h)})});break;case Ht.ENQUEUE:if(et(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Ht.CLOSE:if(et(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),m(this,vs,od).call(this,a,e);break;case Ht.ERROR:et(a,"error should have stream controller"),a.controller.error(Te(t.reason)),m(this,vs,od).call(this,a,e);break;case Ht.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(Te(t.reason)),m(this,vs,od).call(this,a,e);break;case Ht.CANCEL:if(!o)break;const l=Te(t.reason);Promise.try(o.onCancel||Mp,l).then(function(){r.postMessage({sourceName:s,targetName:n,stream:Ht.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Ht.CANCEL_COMPLETE,streamId:e,reason:Te(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},od=async function(t,e){var s,n,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(n=t.pullCall)==null?void 0:n.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var Rh;class Gg{constructor({enableHWA:t=!1}){g(this,Rh,!1);f(this,Rh,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!i(this,Rh)})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){At("Abstract method `_createCanvas` called.")}}Rh=new WeakMap;class Nb extends Gg{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class jg{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.");const 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){At("Abstract method `_fetch` called.")}}class Dp extends jg{async _fetch(t){const e=await _l(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Hc(e)}}class Vg{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,n,r){return"none"}destroy(t=!1){}}var Nr,mo,Fi,Ni,pe,Or,Br,L,de,Nl,Fa,ld,Na,Wg,Ju,Oa,Ol,Bl,Zu,Hl;class Ob extends Vg{constructor({docId:e,ownerDocument:s=globalThis.document}){super();g(this,L);g(this,Nr);g(this,mo);g(this,Fi);g(this,Ni);g(this,pe);g(this,Or);g(this,Br,0);f(this,Ni,e),f(this,pe,s)}addFilter(e){if(!e)return"none";let s=i(this,L,de).get(e);if(s)return s;const[n,r,a]=m(this,L,ld).call(this,e),o=e.length===1?n:`${n}${r}${a}`;if(s=i(this,L,de).get(o),s)return i(this,L,de).set(e,s),s;const l=`g_${i(this,Ni)}_transfer_map_${zt(this,Br)._++}`,h=m(this,L,Na).call(this,l);i(this,L,de).set(e,h),i(this,L,de).set(o,h);const c=m(this,L,Oa).call(this,l);return m(this,L,Bl).call(this,n,r,a,c),h}addHCMFilter(e,s){var y;const n=`${e}-${s}`,r="base";let a=i(this,L,Nl).get(r);if((a==null?void 0:a.key)===n||(a?((y=a.filter)==null||y.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},i(this,L,Nl).set(r,a)),!e||!s))return a.url;const o=m(this,L,Hl).call(this,e);e=N.makeHexColor(...o);const l=m(this,L,Hl).call(this,s);if(s=N.makeHexColor(...l),i(this,L,Fa).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let A=0;A<=255;A++){const v=A/255;h[A]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const c=h.join(","),d=`g_${i(this,Ni)}_hcm_filter`,p=a.filter=m(this,L,Oa).call(this,d);m(this,L,Bl).call(this,c,c,c,p),m(this,L,Ju).call(this,p);const b=(A,v)=>{const w=o[A]/255,S=l[A]/255,_=new Array(v+1);for(let E=0;E<=v;E++)_[E]=w+E/v*(S-w);return _.join(",")};return m(this,L,Bl).call(this,b(0,5),b(1,5),b(2,5),p),a.url=m(this,L,Na).call(this,d),a.url}addAlphaFilter(e){let s=i(this,L,de).get(e);if(s)return s;const[n]=m(this,L,ld).call(this,[e]),r=`alpha_${n}`;if(s=i(this,L,de).get(r),s)return i(this,L,de).set(e,s),s;const a=`g_${i(this,Ni)}_alpha_map_${zt(this,Br)._++}`,o=m(this,L,Na).call(this,a);i(this,L,de).set(e,o),i(this,L,de).set(r,o);const l=m(this,L,Oa).call(this,a);return m(this,L,Zu).call(this,n,l),o}addLuminosityFilter(e){let s=i(this,L,de).get(e||"luminosity");if(s)return s;let n,r;if(e?([n]=m(this,L,ld).call(this,[e]),r=`luminosity_${n}`):r="luminosity",s=i(this,L,de).get(r),s)return i(this,L,de).set(e,s),s;const a=`g_${i(this,Ni)}_luminosity_map_${zt(this,Br)._++}`,o=m(this,L,Na).call(this,a);i(this,L,de).set(e,o),i(this,L,de).set(r,o);const l=m(this,L,Oa).call(this,a);return m(this,L,Wg).call(this,l),e&&m(this,L,Zu).call(this,n,l),o}addHighlightHCMFilter(e,s,n,r,a){var S;const o=`${s}-${n}-${r}-${a}`;let l=i(this,L,Nl).get(e);if((l==null?void 0:l.key)===o||(l?((S=l.filter)==null||S.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},i(this,L,Nl).set(e,l)),!s||!n))return l.url;const[h,c]=[s,n].map(m(this,L,Hl).bind(this));let d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),p=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[b,y]=[r,a].map(m(this,L,Hl).bind(this));
2p<d&&([d,p,b,y]=[p,d,y,b]),i(this,L,Fa).style.color="";const A=(_,E,C)=>{const x=new Array(256),T=(p-d)/C,k=_/255,M=(E-_)/(255*C);let I=0;for(let R=0;R<=C;R++){const H=Math.round(d+R*T),q=k+R*M;for(let G=I;G<=H;G++)x[G]=q;I=H+1}for(let R=I;R<256;R++)x[R]=x[I-1];return x.join(",")},v=`g_${i(this,Ni)}_hcm_${e}_filter`,w=l.filter=m(this,L,Oa).call(this,v);return m(this,L,Ju).call(this,w),m(this,L,Bl).call(this,A(b[0],y[0],5),A(b[1],y[1],5),A(b[2],y[2],5),w),l.url=m(this,L,Na).call(this,v),l.url}destroy(e=!1){var s,n,r,a;e&&((s=i(this,Or))!=null&&s.size)||((n=i(this,Fi))==null||n.parentNode.parentNode.remove(),f(this,Fi,null),(r=i(this,mo))==null||r.clear(),f(this,mo,null),(a=i(this,Or))==null||a.clear(),f(this,Or,null),f(this,Br,0))}}Nr=new WeakMap,mo=new WeakMap,Fi=new WeakMap,Ni=new WeakMap,pe=new WeakMap,Or=new WeakMap,Br=new WeakMap,L=new WeakSet,de=function(){return i(this,mo)||f(this,mo,new Map)},Nl=function(){return i(this,Or)||f(this,Or,new Map)},Fa=function(){if(!i(this,Fi)){const e=i(this,pe).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const n=i(this,pe).createElementNS(Ai,"svg");n.setAttribute("width",0),n.setAttribute("height",0),f(this,Fi,i(this,pe).createElementNS(Ai,"defs")),e.append(n),n.append(i(this,Fi)),i(this,pe).body.append(e)}return i(this,Fi)},ld=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let p=0;p<256;p++)c[p]=h[p]/255;const d=c.join(",");return[d,d,d]}const[s,n,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=n[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},Na=function(e){if(i(this,Nr)===void 0){f(this,Nr,"");const s=i(this,pe).URL;s!==i(this,pe).baseURI&&($c(s)?V('#createUrl: ignore "data:"-URL for performance reasons.'):f(this,Nr,ep(s,"")))}return`url(${i(this,Nr)}#${e})`},Wg=function(e){const s=i(this,pe).createElementNS(Ai,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(s)},Ju=function(e){const s=i(this,pe).createElementNS(Ai,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(s)},Oa=function(e){const s=i(this,pe).createElementNS(Ai,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),i(this,L,Fa).append(s),s},Ol=function(e,s,n){const r=i(this,pe).createElementNS(Ai,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),e.append(r)},Bl=function(e,s,n,r){const a=i(this,pe).createElementNS(Ai,"feComponentTransfer");r.append(a),m(this,L,Ol).call(this,a,"feFuncR",e),m(this,L,Ol).call(this,a,"feFuncG",s),m(this,L,Ol).call(this,a,"feFuncB",n)},Zu=function(e,s){const n=i(this,pe).createElementNS(Ai,"feComponentTransfer");
2s.append(n),m(this,L,Ol).call(this,n,"feFuncA",e)},Hl=function(e){return i(this,L,Fa).style.color=e,Sl(getComputedStyle(i(this,L,Fa)).getPropertyValue("color"))};class Xg{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.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){At("Abstract method `_fetch` called.")}}class Rp extends Xg{async _fetch(t){const e=await _l(t,"arraybuffer");return new Uint8Array(e)}}class qg{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.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){At("Abstract method `_fetch` called.")}}class Lp extends qg{async _fetch(t){const e=await _l(t,"arraybuffer");return new Uint8Array(e)}}Ee&&V("Please use the `legacy` build in Node.js environments.");async function op(u){const e=await process.getBuiltinModule("fs").promises.readFile(u);return new Uint8Array(e)}class Bb extends Vg{}class Hb extends Gg{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Ub extends jg{async _fetch(t){return op(t)}}class $b extends Xg{async _fetch(t){return op(t)}}class zb extends qg{async _fetch(t){return op(t)}}const Ra="__forcedDependency",{floor:Ip,ceil:Fp}=Math;function Yc(u,t,e,s,n,r){u[t*4+0]=Math.min(u[t*4+0],e),u[t*4+1]=Math.min(u[t*4+1],s),u[t*4+2]=Math.max(u[t*4+2],n),u[t*4+3]=Math.max(u[t*4+3],r)}const tf=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var bo,Mn;class Gb{constructor(t,e){g(this,bo);g(this,Mn);f(this,bo,t),f(this,Mn,e)}get length(){return i(this,bo).length}isEmpty(t){return i(this,bo)[t]===tf}minX(t){return i(this,Mn)[t*4+0]/256}minY(t){return i(this,Mn)[t*4+1]/256}maxX(t){return(i(this,Mn)[t*4+2]+1)/256}maxY(t){return(i(this,Mn)[t*4+3]+1)/256}}bo=new WeakMap,Mn=new WeakMap;const Kc=(u,t)=>{if(!u)return;let e=u.get(t);return e||(e={dependencies:new Set,isRenderingOperation:!1},u.set(t,e)),e};var Me,De,Hr,ks,Ur,Oi,ot,dt,Bi,Re,Lh,Ao,$r,zr,Hi,ge,ti,Ih,ef;class jb{constructor(t,e,s=!1){g(this,Ih);g(this,Me,{__proto__:null});g(this,De,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Ra]:[]});g(this,Hr,new Map);g(this,ks,[]);g(this,Ur,[]);g(this,Oi,[[1,0,0,1,0,0]]);g(this,ot,[-1/0,-1/0,1/0,1/0]);g(this,dt,new Float64Array([1/0,1/0,-1/0,-1/0]));g(this,Bi,-1);g(this,Re,new Set);g(this,Lh,new Map);g(this,Ao,new Map);g(this,$r);g(this,zr);g(this,Hi);g(this,ge);g(this,ti);f(this,$r,t.width),f(this,zr,t.height),m(this,Ih,ef).call(this,e),s&&f(this,ti,new Map)}growOperationsCount(t){t>=i(this,ge).length&&m(this,Ih,ef).call(this,t,i(this,ge))}save(t){return f(this,Me,{__proto__:i(this,Me)}),f(this,De,{__proto__:i(this,De),transform:{__proto__:i(this,De).transform},moveText:{__proto__:i(this,De).moveText},sameLineText:{__proto__:i(this,De).sameLineText},[Ra]:{__proto__:i(this,De)[Ra]}}),f(this,ot,{__proto__:i(this,ot)}),i(this,ks).push(t),this}restore(t){var n;const e=Object.getPrototypeOf(i(this,Me));if(e===null)return this;f(this,Me,e),f(this,De,Object.getPrototypeOf(i(this,De))),f(this,ot,Object.getPrototypeOf(i(this,ot)));const s=i(this,ks).pop();return s!==void 0&&((n=Kc(i(this,ti),t))==null||n.dependencies.add(s),i(this,ge)[t]=i(this,ge)[s]),this}recordOpenMarker(t){return i(this,ks).push(t),this}getOpenMarker(){return i(this,ks).length===0?null:i(this,ks).at(-1)}recordCloseMarker(t){var s;const e=i(this,ks).pop();return e!==void 0&&((s=Kc(i(this,ti),t))==null||s.dependencies.add(e),i(this,ge)[t]=i(this,ge)[e]),this}beginMarkedContent(t){return i(this,Ur).push(t),this}endMarkedContent(t){var s;const e=i(this,Ur).pop();return e!==void 0&&((s=Kc(i(this,ti),t))==null||s.dependencies.add(e),i(this,ge)[t]=i(this,ge)[e]),this}pushBaseTransform(t){return i(this,Oi).push(N.multiplyByDOMMatrix(i(this,Oi).at(-1),t.getTransform())),this}popBaseTransform(){return i(this,Oi).length>1&&i(this,Oi).pop(),this}recordSimpleData(t,e){return i(this,Me)[t]=e,this}recordIncrementalData(t,e){return i(this,De)[t].push(e),this}resetIncrementalData(t,e){return i(this,De)[t].length=0,this}recordNamedData(t,e){return i(this,Hr).set(t,e),this}recordSimpleDataFromNamed(t,e,s){i(this,Me)[t]=i(this,Hr).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Ra,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in i(this,Me)&&this.recordFutureForcedDependency(e,i(this,Me)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of i(this,Re))this.recordFutureForcedDependency(Ra,t);return this}resetBBox(t){return i(this,Bi)!==t&&(f(this,Bi,t),i(this,dt)[0]=1/0,i(this,dt)[1]=1/0,i(this,dt)[2]=-1/0,i(this,dt)[3]=-1/0),this}recordClipBox(t,e,s,n,r,a){const o=N.multiplyByDOMMatrix(i(this,Oi).at(-1),e.getTransform()),l=[1/0,1/0,-1/0,-1/0];N.axialAlignedBoundingBox([s,r,n,a],o,l);const h=N.intersect(i(this,ot),l);return h?(i(this,ot)[0]=h[0],i(this,ot)[1]=h[1],i(this,ot)[2]=h[2],i(this,ot)[3]=h[3]):(i(this,ot)[0]=i(this,ot)[1]=1/0,i(this,ot)[2]=i(this,ot)[3]=-1/0),this}recordBBox(t,e,s,n,r,a){const o=i(this,ot);if(o[0]===1/0)return this;const l=N.multiplyByDOMMatrix(i(this,Oi).at(-1),e.getTransform());if(o[0]===-1/0)return N.axialAlignedBoundingBox([s,r,n,a],l,i(this,dt)),this;const h=[1/0,1/0,-1/0,-1/0];return N.axialAlignedBoundingBox([s,r,n,a],l,h),i(this,dt)[0]=Math.min(i(this,dt)[0],Math.max(h[0],o[0])),i(this,dt)[1]=Math.min(i(this,dt)[1],Math.max(h[1],o[1])),i(this,dt)[2]=Math.max(i(this,dt)[2],Math.min(h[2],o[2])),i(this,dt)[3]=Math.max(i(this,dt)[3],Math.min(h[3],o[3])),this}recordCharacterBBox(t,e,s,n=1,r=0,a=0,o){const l=s.bbox;let h,c;if(l&&(h=l[2]!==l[0]&&l[3]!==l[1]&&i(this,Ao).get(s),h!==!1&&(c=[0,0,0,0],N.axialAlignedBoundingBox(l,s.fontMatrix,c),(n!==1||r!==0||a!==0)&&N.scaleMinMax([n,0,0,-n,r,a
2],c),h)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(t);const d=o();return l&&c&&h===void 0&&(h=c[0]<=r-d.actualBoundingBoxLeft&&c[2]>=r+d.actualBoundingBoxRight&&c[1]<=a-d.actualBoundingBoxAscent&&c[3]>=a+d.actualBoundingBoxDescent,i(this,Ao).set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return i(this,dt)[0]=Math.max(0,i(this,ot)[0]),i(this,dt)[1]=Math.max(0,i(this,ot)[1]),i(this,dt)[2]=Math.min(i(this,$r),i(this,ot)[2]),i(this,dt)[3]=Math.min(i(this,zr),i(this,ot)[3]),this}getSimpleIndex(t){return i(this,Me)[t]}recordDependencies(t,e){const s=i(this,Re),n=i(this,Me),r=i(this,De);for(const a of e)a in i(this,Me)?s.add(n[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return i(this,Hr).has(e)&&i(this,Re).add(i(this,Hr).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Ra]),i(this,ti)){const s=Kc(i(this,ti),t),{dependencies:n}=s;i(this,Re).forEach(n.add,n),i(this,ks).forEach(n.add,n),i(this,Ur).forEach(n.add,n),n.delete(t),s.isRenderingOperation=!0}if(i(this,Bi)===t){const s=Ip(i(this,dt)[0]*256/i(this,$r)),n=Ip(i(this,dt)[1]*256/i(this,zr)),r=Fp(i(this,dt)[2]*256/i(this,$r)),a=Fp(i(this,dt)[3]*256/i(this,zr));Yc(i(this,Hi),t,s,n,r,a);for(const o of i(this,Re))o!==t&&Yc(i(this,Hi),o,s,n,r,a);for(const o of i(this,ks))o!==t&&Yc(i(this,Hi),o,s,n,r,a);for(const o of i(this,Ur))o!==t&&Yc(i(this,Hi),o,s,n,r,a);e||(i(this,Re).clear(),f(this,Bi,-1))}return this}recordShowTextOperation(t,e=!1){const s=Array.from(i(this,Re));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const n of s)this.recordIncrementalData("sameLineText",n);return this}bboxToClipBoxDropOperation(t,e=!1){return i(this,Bi)===t&&(f(this,Bi,-1),i(this,ot)[0]=Math.max(i(this,ot)[0],i(this,dt)[0]),i(this,ot)[1]=Math.max(i(this,ot)[1],i(this,dt)[1]),i(this,ot)[2]=Math.min(i(this,ot)[2],i(this,dt)[2]),i(this,ot)[3]=Math.min(i(this,ot)[3],i(this,dt)[3]),e||i(this,Re).clear()),this}_takePendingDependencies(){const t=i(this,Re);return f(this,Re,new Set),t}_extractOperation(t){const e=i(this,Lh).get(t);return i(this,Lh).delete(t),e}_pushPendingDependencies(t){for(const e of t)i(this,Re).add(e)}take(){return i(this,Ao).clear(),new Gb(i(this,ge),i(this,Hi))}takeDebugMetadata(){return i(this,ti)}}Me=new WeakMap,De=new WeakMap,Hr=new WeakMap,ks=new WeakMap,Ur=new WeakMap,Oi=new WeakMap,ot=new WeakMap,dt=new WeakMap,Bi=new WeakMap,Re=new WeakMap,Lh=new WeakMap,Ao=new WeakMap,$r=new WeakMap,zr=new WeakMap,Hi=new WeakMap,ge=new WeakMap,ti=new WeakMap,Ih=new WeakSet,ef=function(t,e){const s=new ArrayBuffer(t*4);f(this,Hi,new Uint8ClampedArray(s)),f(this,ge,new Uint32Array(s)),e&&e.length>0?(i(this,ge).set(e),i(this,ge).fill(tf,e.length)):i(this,ge).fill(tf)};var mt,Dt,Ms,yo,wo;const mp=class mp{constructor(t,e,s){g(this,mt);g(this,Dt);g(this,Ms);g(this,yo,0);g(this,wo,0);if(t instanceof mp&&i(t,Ms)===!!s)return t;f(this,mt,t),f(this,Dt,e),f(this,Ms,!!s)}growOperationsCount(){throw new Error("Unreachable")}save(t){return zt(this,wo)._++,i(this,mt).save(i(this,Dt)),this}restore(t){return i(this,wo)>0&&(i(this,mt).restore(i(this,Dt)),zt(this,wo)._--),this}recordOpenMarker(t){return zt(this,yo)._++,this}getOpenMarker(){return i(this,yo)>0?i(this,Dt):i(this,mt).getOpenMarker()}recordCloseMarker(t){return zt(this,yo)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return i(this,mt).pushBaseTransform(t),this}popBaseTransform(){return i(this,mt).popBaseTransform(),this}recordSimpleData(t,e){return i(this,mt).recordSimpleData(t,i(this,Dt)),this}recordIncrementalData(t,e){return i(this,mt).recordIncrementalData(t,i(this,Dt)),this}resetIncrementalData(t,e){return i(this,mt).resetIncrementalData(t,i(this,Dt)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return i(this,mt).recordSimpleDataFromNamed(t,e,i(this,Dt)),this}recordFutureForcedDependency(t,e){return i(this,mt).recordFutureForcedDependency(t,i(this,Dt)),this}inheritSimpleDataAsFutureForcedDependencies(t){return i(this,mt).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return i(this,mt).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return i(this,Ms)||i(this,mt).resetBBox(i(this,Dt)),this}recordClipBox(t,e,s,n,r,a){return i(this,Ms)||i(this,mt).recordClipBox(i(this,Dt),e,s,n,r,a),this}recordBBox(t,e,s,n,r,a){return i(this,Ms)||i(this,mt).recordBBox(i(this,Dt),e,s,n,r,a),this}recordCharacterBBox(t,e,s,n,r,a,o){return i(this,Ms)||i(this,mt).recordCharacterBBox(i(this,Dt),e,s,n,r,a,o),this}recordFullPageBBox(t){return i(this,Ms)||i(this,mt).recordFullPageBBox(i(this,Dt)),this}getSimpleIndex(t){return i(this,mt).getSimpleIndex(t)}recordDependencies(t,e){return i(this,mt).recordDependencies(i(this,Dt),e),this}recordNamedDependency(t,e){return i(this,mt).recordNamedDependency(i(this,Dt),e),this}recordOperation(t){return i(this,mt).recordOperation(i(this,Dt),!0),this}recordShowTextOperation(t){return i(this,mt).recordShowTextOperation(i(this,Dt),!0),this}bboxToClipBoxDropOperation(t){return i(this,Ms)||i(this,mt).bboxToClipBoxDropOperation(i(this,Dt),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};mt=new WeakMap,Dt=new WeakMap,Ms=new WeakMap,yo=new WeakMap,wo=new WeakMap;let Nd=mp;const ls={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:["f
2ilter","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"]},le={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function sf(u,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],n=new Path2D;n.rect(t[0],t[1],e,s),u.clip(n)}class lp{isModifyingCurrentTransform(){return!1}getPattern(){At("Abstract method `getPattern` called.")}}class Vb extends lp{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,n){let r;if(n===le.STROKE||n===le.FILL){const a=e.current.getClippedPathBoundingBox(n,Tt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=e.cachedCanvases.getCanvas("pattern",o,l),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-a[0],-a[1]),s=N.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),sf(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat");const d=new DOMMatrix(s);r.setTransform(d)}else sf(t,this._bbox),r=this._createGradient(t);return r}}function Cu(u,t,e,s,n,r,a,o){const l=t.coords,h=t.colors,c=u.data,d=u.width*4;let p;l[e+1]>l[s+1]&&(p=e,e=s,s=p,p=r,r=a,a=p),l[s+1]>l[n+1]&&(p=s,s=n,n=p,p=a,a=o,o=p),l[e+1]>l[s+1]&&(p=e,e=s,s=p,p=r,r=a,a=p);const b=(l[e]+t.offsetX)*t.scaleX,y=(l[e+1]+t.offsetY)*t.scaleY,A=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY,w=(l[n]+t.offsetX)*t.scaleX,S=(l[n+1]+t.offsetY)*t.scaleY;if(y>=S)return;const _=h[r],E=h[r+1],C=h[r+2],x=h[a],T=h[a+1],k=h[a+2],M=h[o],I=h[o+1],R=h[o+2],H=Math.round(y),q=Math.round(S);let G,tt,$,U,yt,Ot,as,mi;for(let lt=H;lt<=q;lt++){if(lt<v){const Bt=lt<y?0:(y-lt)/(y-v);G=b-(b-A)*Bt,tt=_-(_-x)*Bt,$=E-(E-T)*Bt,U=C-(C-k)*Bt}else{let Bt;lt>S?Bt=1:v===S?Bt=0:Bt=(v-lt)/(v-S),G=A-(A-w)*Bt,tt=x-(x-M)*Bt,$=T-(T-I)*Bt,U=k-(k-R)*Bt}let ht;lt<y?ht=0:lt>S?ht=1:ht=(y-lt)/(y-S),yt=b-(b-w)*ht,Ot=_-(_-M)*ht,as=E-(E-I)*ht,mi=C-(C-R)*ht;const _s=Math.round(Math.min(G,yt)),Ss=Math.round(Math.max(G,yt));let bi=d*lt+_s*4;for(let Bt=_s;Bt<=Ss;Bt++)ht=(G-Bt)/(G-yt),ht<0?ht=0:ht>1&&(ht=1),c[bi++]=tt-(tt-Ot)*ht|0,c[bi++]=$-($-as)*ht|0,c[bi++]=U-(U-mi)*ht|0,c[bi++]=255}}function Wb(u,t,e){const s=t.coords,n=t.colors;let r,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let c=r*o;for(let d=0;d<h;d++,c++)Cu(u,e,s[c],s[c+1],s[c+o],n[c],n[c+1],n[c+o]),Cu(u,e,s[c+o+1],s[c+1],s[c+o],n[c+o+1],n[c+1],n[c+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)Cu(u,e,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class Xb extends lp{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){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-o,c=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),p=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),b=h/d,y=c/p,A={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/b,scaleY:1/y},v=d+2*2,w=p+2*2,S=s.getCanvas("mesh",v,w),_=S.context,E=_.createImageData(d,p);if(e){const x=E.data;for(let T=0,k=x.length;T<k;T+=4)x[T]=e[0],x[T+1]=e[1],x[T+2]=e[2],x[T+3]=255}for(const x of this._figures)Wb(E,x,A);return _.putImageData(E,2,2),{canvas:S.canvas,offsetX:o-2*b,offsetY:l-2*y,scaleX:b,scaleY:y}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,n){sf(t,this._bbox);const r=new Float32Array(2);if(n===le.SHADING)N.singularValueDecompose2dScale(Tt(t),r);
2else if(this.matrix){N.singularValueDecompose2dScale(this.matrix,r);const[o,l]=r;N.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=o,r[1]*=l}else N.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,n===le.SHADING?null:this._background,e.cachedCanvases);return n!==le.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class qb extends lp{getPattern(){return"hotpink"}}function Yb(u){switch(u[0]){case"RadialAxial":return new Vb(u);case"Mesh":return new Xb(u);case"Dummy":return new qb}throw new Error(`Unknown IR type: ${u[0]}`)}const Np={COLORED:1,UNCOLORED:2},tu=class tu{constructor(t,e,s,n){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t,e){var Ot,as;const{bbox:s,operatorList:n,paintType:r,tilingType:a,color:o,canvasGraphicsFactory:l}=this;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),uu("TilingType: "+a);const d=s[0],p=s[1],b=s[2],y=s[3],A=b-d,v=y-p,w=new Float32Array(2);N.singularValueDecompose2dScale(this.matrix,w);const[S,_]=w;N.singularValueDecompose2dScale(this.baseTransform,w);const E=S*w[0],C=_*w[1];let x=A,T=v,k=!1,M=!1;const I=Math.ceil(h*E),R=Math.ceil(c*C),H=Math.ceil(A*E),q=Math.ceil(v*C);I>=H?x=h:k=!0,R>=q?T=c:M=!0;const G=this.getSizeAndScale(x,this.ctx.canvas.width,E),tt=this.getSizeAndScale(T,this.ctx.canvas.height,C),$=t.cachedCanvases.getCanvas("pattern",G.size,tt.size),U=$.context,yt=l.createCanvasGraphics(U,e);if(yt.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(yt,r,o),U.translate(-G.scale*d,-tt.scale*p),yt.transform(0,G.scale,0,0,tt.scale,0,0),U.save(),(Ot=yt.dependencyTracker)==null||Ot.save(),this.clipBbox(yt,d,p,b,y),yt.baseTransform=Tt(yt.ctx),yt.executeOperatorList(n),yt.endDrawing(),(as=yt.dependencyTracker)==null||as.restore(
2),U.restore(),k||M){const mi=$.canvas;k&&(x=h),M&&(T=c);const lt=this.getSizeAndScale(x,this.ctx.canvas.width,E),ht=this.getSizeAndScale(T,this.ctx.canvas.height,C),_s=lt.size,Ss=ht.size,bi=t.cachedCanvases.getCanvas("pattern-workaround",_s,Ss),Bt=bi.context,bu=k?Math.floor(A/h):0,Au=M?Math.floor(v/c):0;for(let El=0;El<=bu;El++)for(let cr=0;cr<=Au;cr++)Bt.drawImage(mi,_s*El,Ss*cr,_s,Ss,0,0,_s,Ss);return{canvas:bi.canvas,scaleX:lt.scale,scaleY:ht.scale,offsetX:d,offsetY:p}}return{canvas:$.canvas,scaleX:G.scale,scaleY:tt.scale,offsetX:d,offsetY:p}}getSizeAndScale(t,e,s){const n=Math.max(tu.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=n?r=n:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,n,r){const a=n-e,o=r-s;t.ctx.rect(e,s,a,o),N.axialAlignedBoundingBox([e,s,n,r],Tt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const n=t.ctx,r=t.current;switch(e){case Np.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;n.fillStyle=r.fillColor=a,n.strokeStyle=r.strokeColor=o;break;case Np.UNCOLORED:n.fillStyle=n.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new mb(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,n,r){let a=s;n!==le.SHADING&&(a=N.transform(a,e.baseTransform),this.matrix&&(a=N.transform(a,this.matrix)));const o=this.createPatternCanvas(e,r);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const h=t.createPattern(o.canvas,"repeat");return h.setTransform(l),h}};P(tu,"MAX_PATTERN_SIZE",3e3);let nf=tu;function Kb({src:u,srcPos:t=0,dest:e,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=ee.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,d=s&7,p=u.length;e=new Uint32Array(e.buffer);let b=0;for(let y=0;y<n;y++){for(const v=t+c;t<v;t++){const w=t<p?u[t]:255;e[b++]=w&128?h:l,e[b++]=w&64?h:l,e[b++]=w&32?h:l,e[b++]=w&16?h:l,e[b++]=w&8?h:l,e[b++]=w&4?h:l,e[b++]=w&2?h:l,e[b++]=w&1?h:l}if(d===0)continue;const A=t<p?u[t++]:255;for(let v=0;v<d;v++)e[b++]=A&1<<7-v?h:l}return{srcPos:t,destPos:b}}const Op=16,Bp=100,Qb=15,Hp=10,Ne=16,xu=new DOMMatrix,ss=new Float32Array(2),$a=new Float32Array([1/0,1/0,-1/0,-1/0]);function Jb(u,t){if(u._removeMirroring)throw new Error("Context is already forwarding operations.");u.__originalSave=u.save,u.__originalRestore=u.restore,u.__originalRotate=u.rotate,u.__originalScale=u.scale,u.__originalTranslate=u.translate,u.__originalTransform=u.transform,u.__originalSetTransform=u.setTransform,u.__originalResetTransform=u.resetTransform,u.__originalClip=u.clip,u.__originalMoveTo=u.moveTo,u.__originalLineTo=u.lineTo,u.__originalBezierCurveTo=u.bezierCurveTo,u.__originalRect=u.rect,u.__originalClosePath=u.closePath,u.__originalBeginPath=u.beginPath,u._removeMirroring=()=>{u.save=u.__originalSave,u.restore=u.__originalRestore,u.rotate=u.__originalRotate,u.scale=u.__originalScale,u.translate=u.__originalTranslate,u.transform=u.__originalTransform,u.setTransform=u.__originalSetTransform,u.resetTransform=u.__originalResetTransform,u.clip=u.__originalClip,u.moveTo=u.__originalMoveTo,u.lineTo=u.__originalLineTo,u.bezierCurveTo=u.__originalBezierCurveTo,u.rect=u.__originalRect,u.closePath=u.__originalClosePath,u.beginPath=u.__originalBeginPath,delete u._removeMirroring},u.save=function(){t.save(),this.__originalSave()},u.restore=function(){t.restore(),this.__originalRestore()},u.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},u.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},u.transform=function(e,s,n,r,a,o){t.transform(e,s,n,r,a,o),this.__originalTransform(e,s,n,r,a,o)},u.setTransform=function(e,s,n,r,a,o){t.setTransform(e,s,n,r,a,o),this.__originalSetTransform(e,s,n,r,a,o)},u.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},u.rotate=function(e){t.rotate(e),this.__originalRotate(e)},u.clip=function(e){t.clip(e),this.__originalClip(e)},u.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},u.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},u.bezierCurveTo=function(e,s,n,r,a,o){t.bezierCurveTo(e,s,n,r,a,o),this.__originalBezierCurveTo(e,s,n,r,a,o)},u.rect=function(e,s,n,r){t.rect(e,s,n,r),this.__originalRect(e,s,n,r)},u.closePath=function(){t.closePath(),this.__originalClosePath()},u.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Zb{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let n;return this.cache[t]!==void 0?(n=this.cache[t],this.canvasFactory.reset(n,e,s)):(n=this.canvasFactory.create(e,s),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Qc(u,t,e,s,n,r,a,o,l,h){const[c,d,p,b,y,A]=Tt(u);
2if(d===0&&p===0){const S=a*c+y,_=Math.round(S),E=o*b+A,C=Math.round(E),x=(a+l)*c+y,T=Math.abs(Math.round(x)-_)||1,k=(o+h)*b+A,M=Math.abs(Math.round(k)-C)||1;return u.setTransform(Math.sign(c),0,0,Math.sign(b),_,C),u.drawImage(t,e,s,n,r,0,0,T,M),u.setTransform(c,d,p,b,y,A),[T,M]}if(c===0&&b===0){const S=o*p+y,_=Math.round(S),E=a*d+A,C=Math.round(E),x=(o+h)*p+y,T=Math.abs(Math.round(x)-_)||1,k=(a+l)*d+A,M=Math.abs(Math.round(k)-C)||1;return u.setTransform(0,Math.sign(d),Math.sign(p),0,_,C),u.drawImage(t,e,s,n,r,0,0,M,T),u.setTransform(c,d,p,b,y,A),[M,T]}u.drawImage(t,e,s,n,r,a,o,l,h);const v=Math.hypot(c,d),w=Math.hypot(p,b);return[v*l,w*h]}class Up{constructor(t,e,s){P(this,"alphaIsShape",!1);P(this,"fontSize",0);P(this,"fontSizeScale",1);P(this,"textMatrix",null);P(this,"textMatrixScale",1);P(this,"fontMatrix",ku);P(this,"leading",0);P(this,"x",0);P(this,"y",0);P(this,"lineX",0);P(this,"lineY",0);P(this,"charSpacing",0);P(this,"wordSpacing",0);P(this,"textHScale",1);P(this,"textRenderingMode",se.FILL);P(this,"textRise",0);P(this,"fillColor","#000000");P(this,"strokeColor","#000000");P(this,"patternFill",!1);P(this,"patternStroke",!1);P(this,"fillAlpha",1);P(this,"strokeAlpha",1);P(this,"lineWidth",1);P(this,"activeSMask",null);P(this,"transferMaps","none");s==null||s(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=$a.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=le.FILL,e=null){const s=this.minMax.slice();if(t===le.STROKE){e||At("Stroke bounding box must include transform."),N.singularValueDecompose2dScale(e,ss);const n=ss[0]*this.lineWidth/2,r=ss[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=N.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($a,0)}getClippedPathBoundingBox(t=le.FILL,e=null){return N.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function $p(u,t){if(t instanceof ImageData){u.putImageData(t,0,0);return}const e=t.height,s=t.width,n=e%Ne,r=(e-n)/Ne,a=n===0?r:r+1,o=u.createImageData(s,Ne);let l=0,h;const c=t.data,d=o.data;let p,b,y,A;if(t.kind===Kl.GRAYSCALE_1BPP){const v=c.byteLength,w=new Uint32Array(d.buffer,0,d.byteLength>>2),S=w.length,_=s+7>>3,E=4294967295,C=ee.isLittleEndian?4278190080:255;for(p=0;p<a;p++){for(y=p<r?Ne:n,h=0,b=0;b<y;b++){const x=v-l;let T=0;const k=x>_?s:x*8-7,M=k&-8;let I=0,R=0;for(;T<M;T+=8)R=c[l++],w[h++]=R&128?E:C,w[h++]=R&64?E:C,w[h++]=R&32?E:C,w[h++]=R&16?E:C,w[h++]=R&8?E:C,w[h++]=R&4?E:C,w[h++]=R&2?E:C,w[h++]=R&1?E:C;for(;T<k;T++)I===0&&(R=c[l++],I=128),w[h++]=R&I?E:C,I>>=1}for(;h<S;)w[h++]=0;u.putImageData(o,0,p*Ne)}}else if(t.kind===Kl.RGBA_32BPP){for(b=0,A=s*Ne*4,p=0;p<r;p++)d.set(c.subarray(l,l+A)),l+=A,u.putImageData(o,0,b),b+=Ne;p<a&&(A=s*n*4,d.set(c.subarray(l,l+A)),u.putImageData(o,0,b))}else if(t.kind===Kl.RGB_24BPP)for(y=Ne,A=s*y,p=0;p<a;p++){for(p>=r&&(y=n,A=s*y),h=0,b=A;b--;)d[h++]=c[l++],d[h++]=c[l++],d[h++]=c[l++],d[h++]=255;u.putImageData(o,0,p*Ne)}else throw new Error(`bad image kind: ${t.kind}`)}function zp(u,t){if(t.bitmap){u.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,n=e%Ne,r=(e-n)/Ne,a=n===0?r:r+1,o=u.createImageData(s,Ne);let l=0;const h=t.data,c=o.data;for(let d=0;d<a;d++){const p=d<r?Ne:n;({srcPos:l}=Kb({src:h,srcPos:l,dest:c,width:s,height:p,nonBlackColor:0})),u.putImageData(o,0,d*Ne)}}function Cl(u,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)u[s]!==void 0&&(t[s]=u[s]);u.setLineDash!==void 0&&(t.setLineDash(u.getLineDash()),t.lineDashOffset=u.lineDashOffset)}function Jc(u){u.strokeStyle=u.fillStyle="#000000",u.fillRule="nonzero",u.globalAlpha=1,u.lineWidth=1,u.lineCap="butt",u.lineJoin="miter",u.miterLimit=10,u.globalCompositeOperation="source-over",u.font="10px sans-serif",u.setLineDash!==void 0&&(u.setLineDash([]),u.lineDashOffset=0);const{filter:t}=u;t!=="none"&&t!==""&&(u.filter="none")}function Gp(u,t){if(t)return!0;N.singularValueDecompose2dScale(u,ss);const e=Math.fround(Hs.pixelRatio*ln.PDF_TO_CSS_UNITS);return ss[0]<=e&&ss[1]<=e}const tA=["butt","round","square"],eA=["miter","round","bevel"],sA={},jp={};var Us,rf,af,of;const bp=class bp{constructor(t,e,s,n,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c){g(this,Us);
2this.ctx=t,this.current=new Up(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=n,this.filterFactory=r,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=o||[],this.optionalContentConfig=a,this.cachedCanvases=new Zb(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null}getObject(t,e,s=null){var n;return typeof e=="string"?((n=this.dependencyTracker)==null||n.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:n=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.cachedCanvases.getCanvas("transparent",r,a);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Tt(this.compositeCtx))}this.ctx.save(),Jc(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=Tt(this.ctx)}executeOperatorList(t,e,s,n,r){var w;const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>Hp&&typeof s=="function",d=c?Date.now()+Qb:0;let p=0;const b=this.commonObjs,y=this.objs;let A,v;for(;;){if(n!==void 0&&l===n.nextBreakPoint)return n.breakIt(l,s),l;if(!r||r(l))if(A=o[l],v=a[l]??null,A!==yl.dependency)v===null?this[A](l):this[A](l,...v);else for(const S of v){(w=this.dependencyTracker)==null||w.recordNamedData(S,l);const _=S.startsWith("g_")?b:y;if(!_.has(S))return _.get(S,s),l}if(l++,l===h)return l;if(c&&++p>Hp){if(Date.now()>d)return s(),l;p=0}}}endDrawing(){m(this,Us,rf).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),m(this,Us,af).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,n=t.height??t.displayHeight;let r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=s,l=n,h="prescale1",c,d;for(;r>2&&o>1||a>2&&l>1;){let p=o,b=l;r>2&&o>1&&(p=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),r/=o/p),a>2&&l>1&&(b=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/b),c=this.cachedCanvases.getCanvas(h,p,b),d=c.context,d.clearRect(0,0,p,b),d.drawImage(t,0,0,o,l,0,0,p,b),t=c.canvas,o=p,l=b,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t,e){var I,R;const s=this.ctx,{width:n,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=Tt(s);let h,c,d,p;if((e.bitmap||e.data)&&e.count>1){const H=e.bitmap||e.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.get(H),h||(h=new Map,this._cachedBitmapsMap.set(H,h));const q=h.get(c);if(q&&!o){const G=Math.round(Math.min(l[0],l[2])+l[4]),tt=Math.round(Math.min(l[1],l[3])+l[5]);return(I=this.dependencyTracker)==null||I.recordDependencies(t,ls.transformAndFill),{canvas:q,offsetX:G,offsetY:tt}}d=q}d||(p=this.cachedCanvases.getCanvas("maskCanvas",n,r),zp(p.context,e));let b=N.transform(l,[1/n,0,0,-1/r,0,0]);b=N.transform(b,[1,0,0,1,0,-r]);const y=$a.slice();N.axialAlignedBoundingBox([0,0,n,r],b,y);const[A,v,w,S]=y,_=Math.round(w-A)||1,E=Math.round(S-v)||1,C=this.cachedCanvases.getCanvas("fillCanvas",_,E),x=C.context,T=A,k=v;x.translate(-T,-k),x.transform(...b),d||(d=this._scaleImage(p.canvas,$s(x)),d=d.img,h&&o&&h.set(c,d)),x.imageSmoothingEnabled=Gp(Tt(x),e.interpolate),Qc(x,d,0,0,d.width,d.height,0,0,n,r),x.globalCompositeOperation="source-in";const M=N.transform($s(x),[1,0,0,1,-T,-k]);return x.fillStyle=o?a.getPattern(s,this,M,le.FILL,t):a,x.fillRect(0,0,n,r),h&&!o&&
2(this.cachedCanvases.delete("fillCanvas"),h.set(c,C.canvas)),(R=this.dependencyTracker)==null||R.recordDependencies(t,ls.transformAndFill),{canvas:C.canvas,offsetX:Math.round(T),offsetY:Math.round(k)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=tA[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=eA[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,n,r,a,o;for(const[l,h]of e)switch(l){case"LW":this.setLineWidth(t,h);break;case"LC":this.setLineCap(t,h);break;case"LJ":this.setLineJoin(t,h);break;case"ML":this.setMiterLimit(t,h);break;case"D":this.setDash(t,h[0],h[1]);break;case"RI":this.setRenderingIntent(t,h);break;case"FL":this.setFlatness(t,h);break;case"Font":this.setFont(t,h[0],h[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=h;break;case"ca":(n=this.dependencyTracker)==null||n.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=h;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=h?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const 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");const e=this.ctx.canvas.width,s=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,e,s);this.suspendedCtx=this.ctx;const a=this.ctx=r.context;a.setTransform(this.suspendedCtx.getTransform()),Cl(this.suspendedCtx,a),Jb(a,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(),Cl(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,n){const r=n[0],a=n[1],o=n[2]-r,l=n[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,r,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,n,r,a,o,l,h,c,d){let p=t.canvas,b=l-c,y=h-d;if(a)if(b<0||y<0||b+s>p.width||y+n>p.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,n),w=v.context;w.drawImage(p,-b,-y),w.globalCompositeOperation="destination-atop",w.fillStyle=a,w.fillRect(0,0,s,n),w.globalCompositeOperation="source-over",p=v.canvas,b=y=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(b,y,s,n),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=a,t.fillRect(b,y,s,n),t.restore(
2)}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),r==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):r==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const A=new Path2D;A.rect(l,h,s,n),e.clip(A),e.globalCompositeOperation="destination-in",e.drawImage(p,b,y,s,n,l,h,s,n),e.restore()}save(t){var s;this.inSMaskMode&&Cl(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Cl(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,n,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,n,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,n){let[r]=s;if(!n){r||(r=s[0]=new Path2D),this[e](t,r);return}if(this.dependencyTracker!==null){const a=e===yl.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-a,n[2]+a,n[1]-a,n[3]+a).recordDependencies(t,["transform"])}if(!(r instanceof Path2D)){const a=s[0]=new Path2D;for(let o=0,l=r.length;o<l;)switch(r[o++]){case Vc.moveTo:a.moveTo(r[o++],r[o++]);break;case Vc.lineTo:a.lineTo(r[o++],r[o++]);break;case Vc.curveTo:a.bezierCurveTo(r[o++],r[o++],r[o++],r[o++],r[o++],r[o++]);break;case Vc.closePath:a.closePath();break;default:V(`Unrecognized drawing path operator: ${r[o-1]}`);break}r=a}N.axialAlignedBoundingBox(n,Tt(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var a;const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&(r!=null&&r.getPattern)){const o=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,$s(n),le.STROKE,t),o){const l=new Path2D;l.addPath(e,n.getTransform().invertSelf().multiplySelf(o)),e=l}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);(a=this.dependencyTracker)==null||a.recordDependencies(t,ls.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(le.STROKE,Tt(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var h,c,d;const n=this.ctx,r=this.current.fillColor,a=this.current.patternFill;let o=!1;if(a){const p=r.isModifyingCurrentTransform()?n.getTransform():null;if((h=this.dependencyTracker)==null||h.save(t),n.save(),n.fillStyle=r.getPattern(n,this,$s(n),le.FILL,t),p){const b=new Path2D;b.addPath(e,n.getTransform().invertSelf().multiplySelf(p)),e=b}o=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),(c=this.dependencyTracker)==null||c.recordDependencies(t,ls.fill),o&&(n.restore(),(d=this.dependencyTracker)==null||d.restore(t)),s&&this.consumePath(t,e,l)}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){var s;this.ctx.fill(e),(s=this.dependencyTracker)==null||s.recordDependencies(t,ls.rawFillPath).recordOperation(t)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=sA}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=jp}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:n}=this;e!==void 0&&n.recordFutureForcedDependency("textClip",n.getOpenMarker()).recordFutureForcedDependency("textClip",t),n.recordCloseMarker(t)}if(e!==void 0){const n=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:h,path:c}of e)c&&n.addPath(c,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(h,-h));s.clip(n)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var d,p;(d=this.dependencyTracker)==null||d.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||ku,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&V("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=s,n.isType3Font)return;const a=n.loadedName||"sans-serif",o=((p=n.systemFontInfo)==null?void 0:p.css)||`"${a}", ${n.fallbackName}`;let l="normal";n.black?l="900":n.bold&&(l="bold");const h=n.italic?"italic":"normal";let c=s;s<Op?c=Op:s>Bp&&(c=Bp),this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var n;(n=this.dependencyTracker)==null||n.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){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("textMatrix",t);const{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){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}
2paintChar(t,e,s,n,r,a){var w,S,_,E;const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,d=l.fontSize/l.fontSizeScale,p=c&se.FILL_STROKE_MASK,b=!!(c&se.ADD_TO_PATH_FLAG),y=l.patternFill&&!h.missingFile,A=l.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||b||y||A)&&!h.missingFile&&(v=h.getPathGenerator(this.commonObjs,e)),v&&(h.disableFontFace||y||A)){o.save(),o.translate(s,n),o.scale(d,-d),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,h);let C;if(p===se.FILL||p===se.FILL_STROKE)if(r){C=o.getTransform(),o.setTransform(...r);const x=m(this,Us,of).call(this,v,C,r);o.fill(x)}else o.fill(v);if(p===se.STROKE||p===se.FILL_STROKE)if(a){C||(C=o.getTransform()),o.setTransform(...a);const{a:x,b:T,c:k,d:M}=C,I=N.inverseTransform(a),R=N.transform([x,T,k,M,0,0],I);N.singularValueDecompose2dScale(R,ss),o.lineWidth*=Math.max(ss[0],ss[1])/d,o.stroke(m(this,Us,of).call(this,v,C,a))}else o.lineWidth/=d,o.stroke(v);o.restore()}else(p===se.FILL||p===se.FILL_STROKE)&&(o.fillText(e,s,n),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,h,d,s,n,()=>o.measureText(e))),(p===se.STROKE||p===se.FILL_STROKE)&&(this.dependencyTracker&&((_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,h,d,s,n,()=>o.measureText(e)).recordDependencies(t,ls.stroke)),o.strokeText(e,s,n));b&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Tt(o),x:s,y:n,fontSize:d,path:v}),(E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,h,d,s,n))}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let n=3;n<e.length;n+=4)if(e[n]>0&&e[n]<255){s=!0;break}return Y(this,"isFontSubpixelAAEnabled",s)}showText(t,e){var k,M,I,R;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,ls.showText).resetBBox(t),this.current.textRenderingMode&se.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,n=s.font;if(n.isType3Font){this.showType3Text(t,e),(k=this.dependencyTracker)==null||k.recordShowTextOperation(t);return}const r=s.fontSize;if(r===0){(M=this.dependencyTracker)==null||M.recordOperation(t);return}const a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,h=s.wordSpacing,c=s.fontDirection,d=s.textHScale*c,p=e.length,b=n.vertical,y=b?1:-1,A=n.defaultVMetrics,v=r*s.fontMatrix[0],w=s.textRenderingMode===se.FILL&&!n.disableFontFace&&!s.patternFill;a.save(),s.textMatrix&&a.transform(...s.textMatrix),a.translate(s.x,s.y+s.textRise),c>0?a.scale(d,-1):a.scale(d,1);let S,_;if(s.patternFill){a.save();const H=s.fillColor.getPattern(a,this,$s(a),le.FILL,t);S=Tt(a),a.restore(),a.fillStyle=H}if(s.patternStroke){a.save();const H=s.strokeColor.getPattern(a,this,$s(a),le.STROKE,t);_=Tt(a),a.restore(),a.strokeStyle=H}let E=s.lineWidth;const C=s.textMatrixScale;if(C===0||E===0){const H=s.textRenderingMode&se.FILL_STROKE_MASK;(H===se.STROKE||H===se.FILL_STROKE)&&(E=this.getSinglePixelWidth())}else E/=C;if(o!==1&&(a.scale(o,o),E/=o),a.lineWidth=E,n.isInvalidPDFjsFont){const H=[];let q=0;for(const tt of e)H.push(tt.unicode),q+=tt.width;const G=H.join("");if(a.fillText(G,0,0),this.dependencyTracker!==null){const tt=a.measureText(G);this.dependencyTracker.recordBBox(t,this.ctx,-tt.actualBoundingBoxLeft,tt.actualBoundingBoxRight,-tt.actualBoundingBoxAscent,tt.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=q*v*d,a.restore(),this.compose();return}let x=0,T;for(T=0;T<p;++T){const H=e[T];if(typeof H=="number"){x+=y*H*r/1e3;continue}let q=!1;const G=(H.isSpace?h:0)+l,tt=H.fontChar,$=H.accent;let U,yt,Ot=H.width;if(b){const lt=H.vmetric||A,ht=-(H.vmetric?lt[1]:Ot*.5)*v,_s=lt[2]*v;Ot=lt?-lt[0]:Ot,U=ht/o,yt=(x+_s)/o}else U=x/o,yt=0;let as;if(n.remeasure&&Ot>0){as=a.measureText(tt);const lt=as.width*1e3/r*o;if(Ot<lt&&this.isFontSubpixelAAEnabled){const ht=Ot/lt;q=!0,a.save(),a.scale(ht,1),U/=ht}else Ot!==lt&&(U+=(Ot-lt)/2e3*r/o)}if(this.contentVisible&&(H.isInFont||n.missingFile)){if(w&&!$)a.fillText(tt,U,yt),(I=this.dependencyTracker)==null||I.recordCharacterBBox(t,a,as?{bbox:null}:n,r/o,U,yt,()=>as??a.measureText(tt));else if(this.paintChar(t,tt,U,yt,S,_),$){const lt=U+r*$.offset.x/o,ht=yt-r*$.offset.y/o;this.paintChar(t,$.fontChar,lt,ht,S,_)}}const mi=b?Ot*v-G*c:Ot*v+G*c;
2x+=mi,q&&a.restore()}b?s.y-=x:s.x+=x*d,a.restore(),this.compose(),(R=this.dependencyTracker)==null||R.recordShowTextOperation(t)}showType3Text(t,e){const s=this.ctx,n=this.current,r=n.font,a=n.fontSize,o=n.fontDirection,l=r.vertical?1:-1,h=n.charSpacing,c=n.wordSpacing,d=n.textHScale*o,p=n.fontMatrix||ku,b=e.length,y=n.textRenderingMode===se.INVISIBLE;let A,v,w,S;if(y||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),n.textMatrix&&s.transform(...n.textMatrix),s.translate(n.x,n.y+n.textRise),s.scale(d,o);const _=this.dependencyTracker;for(this.dependencyTracker=_?new Nd(_,t):null,A=0;A<b;++A){if(v=e[A],typeof v=="number"){S=l*v*a/1e3,this.ctx.translate(S,0),n.x+=S*d;continue}const E=(v.isSpace?c:0)+h,C=r.charProcOperatorList[v.operatorListId];C?this.contentVisible&&(this.save(),s.scale(a,a),s.transform(...p),this.executeOperatorList(C),this.restore()):V(`Type3 character "${v.operatorListId}" is not available.`);const x=[v.width,0];N.applyTransform(x,p),w=x[0]*a+E,s.translate(w,0),n.x+=w*d}s.restore(),_&&(this.dependencyTracker=_)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,n,r,a,o){var h;const l=new Path2D;l.rect(n,r,a-n,o-r),this.ctx.clip(l),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,n,a,r,o).recordClipBox(t,this.ctx,n,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const n=this.baseTransform||Tt(this.ctx),r={createCanvasGraphics:(a,o)=>new bp(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Nd(this.dependencyTracker,o,!0):null)};s=new nf(e,this.ctx,r,n)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
2setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,s=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=Yb(this.getObject(t,e)),this.cachedPatterns.set(e,n)),s&&(n.matrix=s),n}shadingFill(t,e){var a;if(!this.contentVisible)return;const s=this.ctx;this.save(t);const n=this._getPattern(t,e);s.fillStyle=n.getPattern(s,this,$s(s),le.SHADING,t);const r=$s(s);if(r){const{width:o,height:l}=s.canvas,h=$a.slice();N.axialAlignedBoundingBox([0,0,o,l],r,h);const[c,d,p,b]=h;this.ctx.fillRect(c,d,p-c,b-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(a=this.dependencyTracker)==null||a.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,ls.transform).recordDependencies(t,ls.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){At("Should not call beginInlineImage")}beginImageData(){At("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var n;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Tt(this.ctx),s)){N.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,h=new Path2D;h.rect(r,a,o-r,l-a),this.ctx.clip(h),(n=this.dependencyTracker)==null||n.recordClipBox(t,this.ctx,r,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var _;if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;
2e.isolated||uu("TODO: Support non-isolated groups."),e.knockout&&V("Knockout groups not supported.");const n=Tt(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=$a.slice();N.axialAlignedBoundingBox(e.bbox,Tt(s),r);const a=[0,0,s.canvas.width,s.canvas.height];r=N.intersect(r,a)||[0,0,0,0];const o=Math.floor(r[0]),l=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-o,1),c=Math.max(Math.ceil(r[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,c]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);const p=this.cachedCanvases.getCanvas(d,h,c),b=p.context;b.translate(-o,-l),b.transform(...n);let y=new Path2D;const[A,v,w,S]=e.bbox;if(y.rect(A,v,w-A,S-v),e.matrix){const E=new Path2D;E.addPath(y,new DOMMatrix(e.matrix)),y=E}b.clip(y),e.smask&&this.smaskStack.push({canvas:p.canvas,context:b,offsetX:o,offsetY:l,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(o,l),s.save()),Cl(s,b),this.ctx=b,(_=this.dependencyTracker)==null||_.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){var r;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,(r=this.dependencyTracker)==null||r.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const a=Tt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...a);const o=$a.slice();N.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],a,o),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(t,e,s,n,r,a){if(m(this,Us,rf).call(this),Jc(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const o=s[2]-s[0],l=s[3]-s[1];if(a&&this.annotationCanvasMap){n=n.slice(),n[4]-=s[0],n[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=o,s[3]=l,N.singularValueDecompose2dScale(Tt(this.ctx),ss);const{viewportScale:h}=this,c=Math.ceil(o*this.outputScaleX*h),d=Math.ceil(l*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,d);const{canvas:p,context:b}=this.annotationCanvas;this.annotationCanvasMap.set(e,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=b,this.ctx.save(),this.ctx.setTransform(ss[0],0,0,-ss[1],0,l*ss[1]),Jc(this.ctx)}else{Jc(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],o,l),this.ctx.clip(h)}}this.current=new Up(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...n),this.transform(t,...r)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),m(this,Us,af).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){var o;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const n=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),(o=this.dependencyTracker)==null||o.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s,n=0,r=0,a,o){var d,p,b;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=this.ctx;l.save();const h=Tt(l);l.transform(s,n,r,a,0,0);const c=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),(d=this.dependencyTracker)==null||d.resetBBox(t);for(let y=0,A=o.length;y<A;y+=2){const v=N.transform(h,[s,n,r,a,o[y],o[y+1]]);l.drawImage(c.canvas,v[4],v[5]),(p=this.dependencyTracker)==null||p.recordBBox(t,this.ctx,v[4],v[4]+c.canvas.width,v[5],v[5]+c.canvas.height)}l.restore(),this.compose(),(b=this.dependencyTracker)==null||b.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var a,o,l;if(!this.contentVisible)return;const s=this.ctx,n=this.current.fillColor,r=this.current.patternFill;(a=this.dependencyTracker)==null||a.resetBBox(t).recordDependencies(t,ls.transformAndFill);for(const h of e){const{data:c,width:d,height:p,transform:b}=h,y=this.cachedCanvases.getCanvas("maskCanvas",d,p),A=y.context;A.save();const v=this.getObject(t,c,h);zp(A,v),A.globalCompositeOperation="source-in",A.fillStyle=r?n.getPattern(A,this,$s(s),le.FILL,t):n,A.fillRect(0,0,d,p),A.restore(
2),s.save(),s.transform(...b),s.scale(1,-1),Qc(s,y.canvas,0,0,d,p,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(t,s,0,d,0,p),s.restore()}this.compose(),(l=this.dependencyTracker)==null||l.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){V("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,n,r){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){V("Dependent image isn't ready yet");return}const o=a.width,l=a.height,h=[];for(let c=0,d=r.length;c<d;c+=2)h.push({transform:[s,0,0,n,r[c],r[c+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,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;const{bitmap:e,width:s,height:n}=t,r=this.cachedCanvases.getCanvas("inlineImage",s,n),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",r.canvas}paintInlineImageXObject(t,e){var h;if(!this.contentVisible)return;const s=e.width,n=e.height,r=this.ctx;this.save(t);const{filter:a}=r;a!=="none"&&a!==""&&(r.filter="none"),r.scale(1/s,-1/n);let o;if(e.bitmap)o=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)o=e;else{const d=this.cachedCanvases.getCanvas("inlineImage",s,n).context;$p(d,e),o=this.applyTransferMapsToCanvas(d)}const l=this._scaleImage(o,$s(r));r.imageSmoothingEnabled=Gp(Tt(r),e.interpolate),(h=this.dependencyTracker)==null||h.resetBBox(t).recordBBox(t,r,0,s,-n,0).recordDependencies(t,ls.imageXObject).recordOperation(t),Qc(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-n,s,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,s){var a,o,l;if(!this.contentVisible)return;const n=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const h=e.width,c=e.height,p=this.cachedCanvases.getCanvas("inlineImage",h,c).context;$p(p,e),r=this.applyTransferMapsToCanvas(p)}(a=this.dependencyTracker)==null||a.resetBBox(t);for(const h of s)n.save(),n.transform(...h.transform),n.scale(1,-1),Qc(n,r,h.x,h.y,h.w,h.h,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(t,n,0,1,-1,0),n.restore();(l=this.dependencyTracker)==null||l.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&((e=this.dependencyTracker)==null||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,ls.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var n;(n=this.dependencyTracker)==null||n.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(n||(this.pendingClip===jp?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Tt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:n,d:r}=this.ctx.getTransform();let a,o;if(s===0&&n===0){const l=Math.abs(e),h=Math.abs(r);if(l===h)if(t===0)a=o=1/l;else{const c=l*t;a=o=c<1?1/c:1}else if(t===0)a=1/l,o=1/h;else{const c=l*t,d=h*t;a=c<1?1/c:1,o=d<1?1/d:1}}else{const l=Math.abs(e*r-s*n),h=Math.hypot(e,s),c=Math.hypot(n,r);if(t===0)a=c/l,o=h/l;else{const d=t*l;a=c>d?c/d:1,o=h>d?h/d:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:n}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(n||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),xu.a=1/r,xu.d=1/a;const l=new Path2D;if(l.addPath(t,xu),o.length>0){const h=Math.max(r,a);
2s.setLineDash(o.map(c=>c/h)),s.lineDashOffset/=h}s.lineWidth=n||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Us=new WeakSet,rf=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},af=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},of=function(t,e,s){const n=new Path2D;return n.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),n};let Wa=bp;for(const u in yl)Wa.prototype[u]!==void 0&&(Wa.prototype[yl[u]]=Wa.prototype[u]);var vo,_o,Fh,So,hd;
2const Ga=class Ga{constructor(t){g(this,So);g(this,vo);g(this,_o);g(this,Fh);f(this,vo,t),f(this,_o,new DataView(i(this,vo))),f(this,Fh,new TextDecoder)}static write(t){const e=new TextEncoder,s={};let n=0;for(const h of Ga.strings){const c=e.encode(t[h]);s[h]=c,n+=4+c.length}const r=new ArrayBuffer(n),a=new Uint8Array(r),o=new DataView(r);let l=0;for(const h of Ga.strings){const c=s[h],d=c.length;o.setUint32(l,d),a.set(c,l+4),l+=4+d}return et(l===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}get fontFamily(){return m(this,So,hd).call(this,0)}get fontWeight(){return m(this,So,hd).call(this,1)}get italicAngle(){return m(this,So,hd).call(this,2)}};vo=new WeakMap,_o=new WeakMap,Fh=new WeakMap,So=new WeakSet,hd=function(t){et(t<Ga.strings.length,"Invalid string index");let e=0;for(let n=0;n<t;n++)e+=i(this,_o).getUint32(e)+4;const s=i(this,_o).getUint32(e);return i(this,Fh).decode(new Uint8Array(i(this,vo),e+4,s))},P(Ga,"strings",["fontFamily","fontWeight","italicAngle"]);let Od=Ga;var Dn,ei,Gr,jr,Ul;const ja=class ja{constructor(t){g(this,jr);g(this,Dn);g(this,ei);g(this,Gr);f(this,Dn,t),f(this,ei,new DataView(i(this,Dn))),f(this,Gr,new TextDecoder)}static write(t){const e=new TextEncoder,s={};let n=0;for(const p of ja.strings){const b=e.encode(t[p]);s[p]=b,n+=4+b.length}n+=4;let r,a,o=1+n;t.style&&(r=e.encode(t.style.style),a=e.encode(t.style.weight),o+=4+r.length+4+a.length);const l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let d=0;c.setUint8(d++,t.guessFallback?1:0),c.setUint32(d,0),d+=4,n=0;for(const p of ja.strings){const b=s[p],y=b.length;n+=4+y,c.setUint32(d,y),h.set(b,d+4),d+=4+y}return c.setUint32(d-n-4,n),t.style&&(c.setUint32(d,r.length),h.set(r,d+4),d+=4+r.length,c.setUint32(d,a.length),h.set(a,d+4),d+=4+a.length),et(d<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(d)}get guessFallback(){return i(this,ei).getUint8(0)!==0}get css(){return m(this,jr,Ul).call(this,0)}get loadedName(){return m(this,jr,Ul).call(this,1)}get baseFontName(){return m(this,jr,Ul).call(this,2)}get src(){return m(this,jr,Ul).call(this,3)}get style(){let t=1;t+=4+i(this,ei).getUint32(t);const e=i(this,ei).getUint32(t),s=i(this,Gr).decode(new Uint8Array(i(this,Dn),t+4,e));t+=4+e;const n=i(this,ei).getUint32(t),r=i(this,Gr).decode(new Uint8Array(i(this,Dn),t+4,n));return{style:s,weight:r}}};Dn=new WeakMap,ei=new WeakMap,Gr=new WeakMap,jr=new WeakSet,Ul=function(t){et(t<ja.strings.length,"Invalid string index");let e=5;for(let n=0;n<t;n++)e+=i(this,ei).getUint32(e)+4;const s=i(this,ei).getUint32(e);return i(this,Gr).decode(new Uint8Array(i(this,Dn),e+4,s))},P(ja,"strings",["css","loadedName","baseFontName","src"]);let Bd=ja;var Eo,Co,xo,To,$e,si,Nh,ut,Lt,Es,cd,$l;const X=class X{constructor({data:t,extra:e}){g(this,Lt);g(this,si);g(this,Nh);g(this,ut);f(this,si,t),f(this,Nh,new TextDecoder),f(this,ut,new DataView(i(this,si))),e&&Object.assign(this,e)}get black(){return m(this,Lt,Es).call(this,0)}get bold(){return m(this,Lt,Es).call(this,1)}get disableFontFace(){return m(this,Lt,Es).call(this,2)}get fontExtraProperties(){return m(this,Lt,Es).call(this,3)}get isInvalidPDFjsFont(){return m(this,Lt,Es).call(this,4)}get isType3Font(){return m(this,Lt,Es).call(this,5)}get italic(){return m(this,Lt,Es).call(this,6)}get missingFile(){return m(this,Lt,Es).call(this,7)}get remeasure(){return m(this,Lt,Es).call(this,8)}get vertical(){return m(this,Lt,Es).call(this,9)}get ascent(){return m(this,Lt,cd).call(this,0)}get defaultWidth(){return m(this,Lt,cd).call(this,1)}get descent(){return m(this,Lt,cd).call(this,2)}get bbox(){let t=i(X,Co);if(i(this,ut).getUint8(t)===0)return;t+=1;const s=[];for(let n=0;n<4;n++)s.push(i(this,ut).getInt16(t,!0)),t+=2;return s}get fontMatrix(){let t=i(X,xo);if(i(this,ut).getUint8(t)===0)return;t+=1;const s=[];for(let n=0;n<6;n++)s.push(i(this,ut).getFloat64(t,!0)),t+=8;return s}get defaultVMetrics(){let t=i(X,To);if(i(this,ut).getUint8(t)===0)return;t+=1;const s=[];for(let n=0;n<3;n++)s.push(i(this,ut).getInt16(t,!0)),t+=2;return s}get fallbackName(){return m(this,Lt,$l).call(this,0)}get loadedName(){return m(this,Lt,$l).call(this,1)}get mimetype(){return m(this,Lt,$l).call(this,2)}get name(){return m(this,Lt,$l).call(this,3)}get data(){let t=i(X,$e);const e=i(this,ut).getUint32(t);t+=4+e;const s=i(this,ut).getUint32(t);t+=4+s;const n=i(this,ut).getUint32(t);t+=4+n;const r=i(this,ut).getUint32(t);if(r!==0)return new Uint8Array(i(this,si),t+4,r)}clearData(){let t=i(X,$e);const e=i(this,ut).getUint32(t);t+=4+e;const s=i(this,ut).getUint32(t);t+=4+s;const n=i(this,ut).getUint32(t);t+=4+n;const r=i(this,ut).getUint32(t);new Uint8Array(i(this,si),t+4,r).fill(0),i(this,ut).setUint32(t,0)}get cssFontInfo(){let t=i(X,$e);const e=i(this,ut).getUint32(t);t+=4+e;const s=i(this,ut).getUint32(t);t+=4+s;const n=i(this,ut).getUint32(t);if(n===0)return null;
2const r=new Uint8Array(n);return r.set(new Uint8Array(i(this,si),t+4,n)),new Od(r.buffer)}get systemFontInfo(){let t=i(X,$e);const e=i(this,ut).getUint32(t);t+=4+e;const s=i(this,ut).getUint32(t);if(s===0)return null;const n=new Uint8Array(s);return n.set(new Uint8Array(i(this,si),t+4,s)),new Bd(n.buffer)}static write(t){const e=t.systemFontInfo?Bd.write(t.systemFontInfo):null,s=t.cssFontInfo?Od.write(t.cssFontInfo):null,n=new TextEncoder,r={};let a=0;for(const A of X.strings)r[A]=n.encode(t[A]),a+=4+r[A].length;const o=i(X,$e)+4+a+4+(e?e.byteLength:0)+4+(s?s.byteLength:0)+4+(t.data?t.data.length:0),l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let d=0;const p=X.bools.length;let b=0,y=0;for(let A=0;A<p;A++){const v=t[X.bools[A]];b|=(v===void 0?0:v?2:1)<<y,y+=2,(y===8||A===p-1)&&(c.setUint8(d++,b),b=0,y=0)}et(d===i(X,Eo),"FontInfo.write: Boolean properties offset mismatch");for(const A of X.numbers)c.setFloat64(d,t[A]),d+=8;if(et(d===i(X,Co),"FontInfo.write: Number properties offset mismatch"),t.bbox){c.setUint8(d++,4);for(const A of t.bbox)c.setInt16(d,A,!0),d+=2}else c.setUint8(d++,0),d+=2*4;if(et(d===i(X,xo),"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){c.setUint8(d++,6);for(const A of t.fontMatrix)c.setFloat64(d,A,!0),d+=8}else c.setUint8(d++,0),d+=8*6;if(et(d===i(X,To),"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){c.setUint8(d++,1);for(const A of t.defaultVMetrics)c.setInt16(d,A,!0),d+=2}else c.setUint8(d++,0),d+=3*2;et(d===i(X,$e),"FontInfo.write: DefaultVMetrics properties offset mismatch"),c.setUint32(i(X,$e),0),d+=4;for(const A of X.strings){const v=r[A],w=v.length;c.setUint32(d,w),h.set(v,d+4),d+=4+w}if(c.setUint32(i(X,$e),d-i(X,$e)-4),!e)c.setUint32(d,0),d+=4;else{const A=e.byteLength;c.setUint32(d,A),et(d+4+A<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(e),d+4),d+=4+A}if(!s)c.setUint32(d,0),d+=4;else{const A=s.byteLength;c.setUint32(d,A),et(d+4+A<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(s),d+4),d+=4+A}return t.data===void 0?(c.setUint32(d,0),d+=4):(c.setUint32(d,t.data.length),h.set(t.data,d+4),d+=4+t.data.length),et(d<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(d)}};Eo=new WeakMap,Co=new WeakMap,xo=new WeakMap,To=new WeakMap,$e=new WeakMap,si=new WeakMap,Nh=new WeakMap,ut=new WeakMap,Lt=new WeakSet,Es=function(t){et(t<X.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,n=i(this,ut).getUint8(e)>>s&3;return n===0?void 0:n===2},cd=function(t){return et(t<X.numbers.length,"Invalid number index"),i(this,ut).getFloat64(i(X,Eo)+t*8)},$l=function(t){et(t<X.strings.length,"Invalid string index");let e=i(X,$e)+4;for(let r=0;r<t;r++)e+=i(this,ut).getUint32(e)+4;const s=i(this,ut).getUint32(e),n=new Uint8Array(s);return n.set(new Uint8Array(i(this,si),e+4,s)),i(this,Nh).decode(n)},P(X,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),P(X,"numbers",["ascent","defaultWidth","descent"]),P(X,"strings",["fallbackName","loadedName","mimetype","name"]),g(X,Eo,Math.ceil(X.bools.length*2/8)),g(X,Co,i(X,Eo)+X.numbers.length*8),g(X,xo,i(X,Co)+1+2*4),g(X,To,i(X,xo)+1+8*6),g(X,$e,i(X,To)+1+2*3);let lf=X;var Oh,Bh;class fi{static get workerPort(){return i(this,Oh)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");f(this,Oh,t)}static get workerSrc(){return i(this,Bh)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");f(this,Bh,t)}}Oh=new WeakMap,Bh=new WeakMap,g(fi,Oh,null),g(fi,Bh,"");var Po,Hh;class iA{constructor({parsedData:t,rawData:e}){g(this,Po);g(this,Hh);f(this,Po,t),f(this,Hh,e)}getRaw(){return i(this,Hh)}get(t){return i(this,Po).get(t)??null}[Symbol.iterator](){return i(this,Po).entries()}}Po=new WeakMap,Hh=new WeakMap;const Ba=Symbol("INTERNAL");var Uh,$h,zh,ko;class nA{constructor(t,{name:e,intent:s,usage:n,rbGroups:r}){g(this,Uh,!1);g(this,$h,!1);g(this,zh,!1);g(this,ko,!0);f(this,Uh,!!(t&es.DISPLAY)),f(this,$h,!!(t&es.PRINT)),this.name=e,this.intent=s,this.usage=n,this.rbGroups=r}get visible(){if(i(this,zh))return i(this,ko);if(!i(this,ko))return!1;const{print:t,view:e}=this.usage;return i(this,Uh)?(e==null?void 0:e.viewState)!=="OFF":i(this,$h)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ba&&At("Internal method `_setVisible` called."),f(this,zh,s),f(this,ko,e)}}Uh=new WeakMap,$h=new WeakMap,zh=new WeakMap,ko=new WeakMap;var Rn,ft,Mo,Do,Gh,hf;class rA{constructor(t,e=es.DISPLAY){g(this,Gh);g(this,Rn,null);g(this,ft,new Map);g(this,Mo,null);g(this,Do,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,f(this,Do,t.order);for(const s of t.groups)i(this,ft).set(s.id,new nA(e,s));if(t.baseState==="OFF")for(const s of i(this,ft).values())s._setVisible(Ba,!1);for(const s of t.on)i(this,ft).get(s)._setVisible(Ba,!0);for(const s of t.off)i(this,ft).get(s)._setVisible(Ba,!1);f(this,Mo,this.getHash())}}isVisible(t){if(i(this,ft).size===0)return!0;
2if(!t)return uu("Optional content group not defined."),!0;if(t.type==="OCG")return i(this,ft).has(t.id)?i(this,ft).get(t.id).visible:(V(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,Gh,hf).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!i(this,ft).has(e))return V(`Optional content group not found: ${e}`),!0;if(i(this,ft).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!i(this,ft).has(e))return V(`Optional content group not found: ${e}`),!0;if(!i(this,ft).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!i(this,ft).has(e))return V(`Optional content group not found: ${e}`),!0;if(!i(this,ft).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!i(this,ft).has(e))return V(`Optional content group not found: ${e}`),!0;if(i(this,ft).get(e).visible)return!1}return!0}return V(`Unknown optional content policy ${t.policy}.`),!0}return V(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const n=i(this,ft).get(t);if(!n){V(`Optional content group not found: ${t}`);return}if(s&&e&&n.rbGroups.length)for(const a of n.rbGroups)for(const o of a)o!==t&&((r=i(this,ft).get(o))==null||r._setVisible(Ba,!1,!0));n._setVisible(Ba,!!e,!0),f(this,Rn,null)}setOCGState({state:t,preserveRB:e}){let s;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":s=n;continue}const r=i(this,ft).get(n);if(r)switch(s){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!r.visible,e);break}}f(this,Rn,null)}get hasInitialVisibility(){return i(this,Mo)===null||this.getHash()===i(this,Mo)}getOrder(){return i(this,ft).size?i(this,Do)?i(this,Do).slice():[...i(this,ft).keys()]:null}getGroup(t){return i(this,ft).get(t)||null}getHash(){if(i(this,Rn)!==null)return i(this,Rn);const t=new Ng;for(const[e,s]of i(this,ft))t.update(`${e}:${s.visible}`);return f(this,Rn,t.hexdigest())}[Symbol.iterator](){return i(this,ft).entries()}}Rn=new WeakMap,ft=new WeakMap,Mo=new WeakMap,Do=new WeakMap,Gh=new WeakSet,hf=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let n=1;n<e;n++){const r=t[n];let a;if(Array.isArray(r))a=m(this,Gh,hf).call(this,r);else if(i(this,ft).has(r))a=i(this,ft).get(r).visible;else return V(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};class aA{constructor(t,{disableRange:e=!1,disableStream:s=!1}){et(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:n,initialData:r,progressiveDone:a,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(r==null?void 0:r.length)>0){const l=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=n,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,h)=>{this._onReceiveData({begin:l,chunk:h})}),t.addProgressListener((l,h)=>{this._onProgress({loaded:l,total:h})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const n=this._rangeReaders.some(function(r){return r._begin!==t?!1:(r._enqueue(s),!0)});et(n,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,n,r;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(r=(n=this._fullRequestReader)==null?void 0:n.onProgress)==null||r.call(n,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){et(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new oA(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new lA(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class oA{constructor(t,e,s=!1,n=null){this._stream=t,this._done=s||!1,this._filename=pu(n)?n:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;
2this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class lA{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function hA(u){let t=!0,e=s("filename\\*","i").exec(u);if(e){e=e[1];let c=o(e);return c=unescape(c),c=l(c),c=h(c),r(c)}if(e=a(u),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(u),e){e=e[1];let c=o(e);return c=h(c),r(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function n(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const p=new TextDecoder(c,{fatal:!0}),b=Hc(d);d=p.decode(b),t=!1}catch{}}return d}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=n("utf-8",c),t&&(c=n("iso-8859-1",c))),c}function a(c){const d=[];let p;const b=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(p=b.exec(c))!==null;){let[,A,v,w]=p;if(A=parseInt(A,10),A in d){if(A===0)break;continue}d[A]=[v,w]}const y=[];for(let A=0;A<d.length&&A in d;++A){let[v,w]=d[A];w=o(w),v&&(w=unescape(w),A===0&&(w=l(w))),y.push(w)}return y.join("")}function o(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let p=0;p<d.length;++p){const b=d[p].indexOf('"');b!==-1&&(d[p]=d[p].slice(0,b),d.length=p+1),d[p]=d[p].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function l(c){const d=c.indexOf("'");if(d===-1)return c;const p=c.slice(0,d),y=c.slice(d+1).replace(/^[^']*'/,"");return n(p,y)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,p,b,y){if(b==="q"||b==="Q")return y=y.replaceAll("_"," "),y=y.replaceAll(/=([0-9a-fA-F]{2})/g,function(A,v){return String.fromCharCode(parseInt(v,16))}),n(p,y);try{y=atob(y)}catch{}return n(p,y)})}return""}function Yg(u,t){const e=new Headers;if(!u||!t||typeof t!="object")return e;for(const s in t){const n=t[s];n!==void 0&&e.append(s,n)}return e}function gu(u){var t;return((t=URL.parse(u))==null?void 0:t.origin)??null}function Kg({responseHeaders:u,isHttp:t,rangeChunkSize:e,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(u.get("Content-Length"),10);return!Number.isInteger(r)||(n.suggestedLength=r,r<=2*e)||s||!t||u.get("Accept-Ranges")!=="bytes"||(u.get("Content-Encoding")||"identity")!=="identity"||(n.allowRangeRequests=!0),n}function Qg(u){const t=u.get("Content-Disposition");if(t){let e=hA(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(pu(e))return e}return null}function Gc(u,t){return new Jl(`Unexpected server response (${u}) while retrieving PDF "${t}".`,u,u===404||u===0&&t.startsWith("file:"))}function Jg(u){return u===200||u===206}function Zg(u,t,e){return{method:"GET",headers:u,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function tm(u){return u instanceof Uint8Array?u.buffer:u instanceof ArrayBuffer?u:(V(`getArrayBuffer - unexpected data format: ${u}`),new Uint8Array(u).buffer)}class cA{constructor(t){P(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Yg(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return et(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new dA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new uA(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class dA{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const s=new Headers(t.headers),n=e.url;fetch(n,Zg(s,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=gu(r.url),!Jg(r.status))throw Gc(r.status,n);this._reader=r.body.getReader(),this._headersCapability.resolve();const a=r.headers,{allowRangeRequests:o,suggestedLength:l}=Kg({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=Qg(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new on("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:tm(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class uA{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`);const a=n.url;fetch(a,Zg(r,this._withCredentials,this._abortController)).then(o=>{const l=gu(o.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!Jg(o.status))throw Gc(o.status,a);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:tm(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const Tu=200,Pu=206;function fA(u){const t=u.response;return typeof t!="string"?t:Hc(t).buffer}class pA{constructor({url:t,httpHeaders:e,withCredentials:s}){P(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Yg(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,n=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[r,a]of this.headers)e.setRequestHeader(r,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),n.expectedStatus=Pu):n.expectedStatus=Tu,e.responseType="arraybuffer",et(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var n;const s=this.pendingRequests[t];s&&((n=s.onProgress)==null||n.call(s,e))}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const n=s.xhr;if(n.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),n.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],n.status===0&&this.isHttp){s.onError(n.status);return}const r=n.status||Tu;if(!(r===Tu&&s.expectedStatus===Pu)&&r!==s.expectedStatus){s.onError(n.status);return}const o=fA(n);if(r===Pu){const l=n.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);h?s.onDone({begin:parseInt(h[1],10),chunk:o}):(V('Missing or invalid "Content-Range" header.'),s.onError(0))}else o?s.onDone({begin:0,chunk:o}):s.onError(n.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}
2abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class gA{constructor(t){this._source=t,this._manager=new pA(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return et(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new mA(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new bA(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class mA{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=gu(e.responseURL);const s=e.getAllResponseHeaders(),n=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[l,...h]=o.split(": ");return[l,h.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:a}=Kg({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=Qg(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Gc(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class bA{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var e;const t=gu((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);
2t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=Gc(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const AA=/^[a-z][a-z0-9\-+.]+:/i;function yA(u){if(AA.test(u))return new URL(u);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(u))}class wA{constructor(t){this.source=t,this.url=yA(t.url),et(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return et(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new vA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new _A(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class vA{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(n=>{this._contentLength=n.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},n=>{n.code==="ENOENT"&&(n=Gc(0,this._url.href)),this._storedError=n,this._headersCapability.reject(n)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new on("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class _A{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const n=t.source;this._isStreamingSupported=!n.disableStream;const r=process.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const xl=Symbol("INITIAL_DATA");var ze,jh,cf;class em{constructor(){g(this,jh);g(this,ze,Object.create(null))}get(t,e=null){if(e){const n=m(this,jh,cf).call(this,t);return n.promise.then(()=>e(n.data)),null}const s=i(this,ze)[t];if(!s||s.data===xl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=i(this,ze)[t];return!!e&&e.data!==xl}delete(t){const e=i(this,ze)[t];return!e||e.data===xl?!1:(delete i(this,ze)[t],!0)}resolve(t,e=null){const s=m(this,jh,cf).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in i(this,ze)){const{data:s}=i(this,ze)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}f(this,ze,Object.create(null))}*[Symbol.iterator](){for(const t in i(this,ze)){const{data:e}=i(this,ze)[t];e!==xl&&(yield[t,e])}}}ze=new WeakMap,jh=new WeakSet,cf=function(t){var e;return(e=i(this,ze))[t]||(e[t]={...Promise.withResolvers(),data:xl})};const SA=1e5,Vp=30;var Yp,Ln,Le,Vh,Wh,Vr,Ui,Xh,qh,Wr,Ro,Lo,In,Io,Yh,Fo,Xr,Kh,Qh,No,qr,Jh,Fn,Oo,cn,sm,im,df,ns,dd,uf,nm,rm;const Gt=class Gt{constructor({textContentSource:t,container:e,viewport:s}){g(this,cn);g(this,Ln,Promise.withResolvers());g(this,Le,null);g(this,Vh,!1);g(this,Wh,!!((Yp=globalThis.FontInspector)!=null&&Yp.enabled));g(this,Vr,null);g(this,Ui,null);g(this,Xh,0);g(this,qh,0);g(this,Wr,null);g(this,Ro,null);g(this,Lo,0);g(this,In,0);g(this,Io,Object.create(null));g(this,Yh,[]);g(this,Fo,null);g(this,Xr,[]);g(this,Kh,new WeakMap);g(this,Qh,null);var l;if(t instanceof ReadableStream)f(this,Fo,t);else if(typeof t=="object")f(this,Fo,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');f(this,Le,f(this,Ro,e)),f(this,In,s.scale*Hs.pixelRatio),f(this,Lo,s.rotation),f(this,Ui,{div:null,properties:null,ctx:null});const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;f(this,Qh,[1,0,0,-1,-a,o+r]),f(this,qh,n),f(this,Xh,r),m(l=Gt,ns,nm).call(l),ar(e,s),i(this,Ln).promise.finally(()=>{i(Gt,Oo).delete(this),f(this,Ui,null),f(this,Io,null)}
2).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ee.platform;return Y(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{i(this,Wr).read().then(({value:e,done:s})=>{if(s){i(this,Ln).resolve();return}i(this,Vr)??f(this,Vr,e.lang),Object.assign(i(this,Io),e.styles),m(this,cn,sm).call(this,e.items),t()},i(this,Ln).reject)};return f(this,Wr,i(this,Fo).getReader()),i(Gt,Oo).add(this),t(),i(this,Ln).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*Hs.pixelRatio,n=t.rotation;if(n!==i(this,Lo)&&(e==null||e(),f(this,Lo,n),ar(i(this,Ro),{rotation:n})),s!==i(this,In)){e==null||e(),f(this,In,s);const a={div:null,properties:null,ctx:m(r=Gt,ns,dd).call(r,i(this,Vr))};for(const o of i(this,Xr))a.properties=i(this,Kh).get(o),a.div=o,m(this,cn,df).call(this,a)}}cancel(){var e;const t=new on("TextLayer task cancelled.");(e=i(this,Wr))==null||e.cancel(t).catch(()=>{}),f(this,Wr,null),i(this,Ln).reject(t)}get textDivs(){return i(this,Xr)}get textContentItemsStr(){return i(this,Yh)}static cleanup(){if(!(i(this,Oo).size>0)){i(this,No).clear();for(const{canvas:t}of i(this,qr).values())t.remove();i(this,qr).clear()}}};Ln=new WeakMap,Le=new WeakMap,Vh=new WeakMap,Wh=new WeakMap,Vr=new WeakMap,Ui=new WeakMap,Xh=new WeakMap,qh=new WeakMap,Wr=new WeakMap,Ro=new WeakMap,Lo=new WeakMap,In=new WeakMap,Io=new WeakMap,Yh=new WeakMap,Fo=new WeakMap,Xr=new WeakMap,Kh=new WeakMap,Qh=new WeakMap,No=new WeakMap,qr=new WeakMap,Jh=new WeakMap,Fn=new WeakMap,Oo=new WeakMap,cn=new WeakSet,sm=function(t){var n,r;if(i(this,Vh))return;(r=i(this,Ui)).ctx??(r.ctx=m(n=Gt,ns,dd).call(n,i(this,Vr)));const e=i(this,Xr),s=i(this,Yh);for(const a of t){if(e.length>SA){V("Ignoring additional textDivs for performance reasons."),f(this,Vh,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=i(this,Le);f(this,Le,document.createElement("span")),i(this,Le).classList.add("markedContent"),a.id&&i(this,Le).setAttribute("id",`${a.id}`),o.append(i(this,Le))}else a.type==="endMarkedContent"&&f(this,Le,i(this,Le).parentNode);continue}s.push(a.str),m(this,cn,im).call(this,a)}},im=function(t){var A;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};i(this,Xr).push(e);const n=N.transform(i(this,Qh),t.transform);let r=Math.atan2(n[1],n[0]);const a=i(this,Io)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=i(this,Wh)&&a.fontSubstitution||a.fontFamily;o=Gt.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*m(A=Gt,ns,rm).call(A,o,a,i(this,Vr));let c,d;
2r===0?(c=n[4],d=n[5]-h):(c=n[4]+h*Math.sin(r),d=n[5]-h*Math.cos(r));const p="calc(var(--total-scale-factor) *",b=e.style;i(this,Le)===i(this,Ro)?(b.left=`${(100*c/i(this,qh)).toFixed(2)}%`,b.top=`${(100*d/i(this,Xh)).toFixed(2)}%`):(b.left=`${p}${c.toFixed(2)}px)`,b.top=`${p}${d.toFixed(2)}px)`),b.fontSize=`${p}${(i(Gt,Fn)*l).toFixed(2)}px)`,b.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,i(this,Wh)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let y=!1;if(t.str.length>1)y=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const v=Math.abs(t.transform[0]),w=Math.abs(t.transform[3]);v!==w&&Math.max(v,w)/Math.min(v,w)>1.5&&(y=!0)}if(y&&(s.canvasWidth=a.vertical?t.height:t.width),i(this,Kh).set(e,s),i(this,Ui).div=e,i(this,Ui).properties=s,m(this,cn,df).call(this,i(this,Ui)),s.hasText&&i(this,Le).append(e),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),i(this,Le).append(v)}},df=function(t){var o;const{div:e,properties:s,ctx:n}=t,{style:r}=e;let a="";if(i(Gt,Fn)>1&&(a=`scale(${1/i(Gt,Fn)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=r,{canvasWidth:h,fontSize:c}=s;m(o=Gt,ns,uf).call(o,n,c*i(this,In),l);const{width:d}=n.measureText(e.textContent);d>0&&(a=`scaleX(${h*i(this,In)/d}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)},ns=new WeakSet,dd=function(t=null){let e=i(this,qr).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),i(this,qr).set(t,e),i(this,Jh).set(e,{size:0,family:""})}return e},uf=function(t,e,s){const n=i(this,Jh).get(t);e===n.size&&s===n.family||(t.font=`${e}px ${s}`,n.size=e,n.family=s)},nm=function(){if(i(this,Fn)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),f(this,Fn,t.getBoundingClientRect().height),t.remove()},rm=function(t,e,s){const n=i(this,No).get(t);if(n)return n;const r=m(this,ns,dd).call(this,s);r.canvas.width=r.canvas.height=Vp,m(this,ns,uf).call(this,r,Vp,t);const a=r.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return o?h=o/(o+l):(ee.platform.isFirefox&&V("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)),i(this,No).set(t,h),h},g(Gt,ns),g(Gt,No,new Map),g(Gt,qr,new Map),g(Gt,Jh,new WeakMap),g(Gt,Fn,null),g(Gt,Oo,new Set);let wl=Gt;const EA=100;function am(u={}){typeof u=="string"||u instanceof URL?u={url:u}:(u instanceof ArrayBuffer||ArrayBuffer.isView(u))&&(u={data:u});const t=new ff,{docId:e}=t,s=u.url?Rb(u.url):null,n=u.data?Lb(u.data):null,r=u.httpHeaders||null,a=u.withCredentials===!0,o=u.password??null,l=u.range instanceof hp?u.range:null,h=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:2**16;let c=u.worker instanceof vl?u.worker:null;const d=u.verbosity,p=typeof u.docBaseUrl=="string"&&!$c(u.docBaseUrl)?u.docBaseUrl:null,b=Xc(u.cMapUrl),y=u.cMapPacked!==!1,A=u.CMapReaderFactory||(Ee?Ub:Dp),v=Xc(u.iccUrl),w=Xc(u.standardFontDataUrl),S=u.StandardFontDataFactory||(Ee?$b:Rp),_=Xc(u.wasmUrl),E=u.WasmFactory||(Ee?zb:Lp),C=u.stopAtErrors!==!0,x=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,T=u.isEvalSupported!==!1,k=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!Ee,M=typeof u.isImageDecoderSupported=="boolean"?u.isImageDecoderSupported:!Ee&&(ee.platform.isFirefox||!globalThis.chrome),I=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,R=typeof u.disableFontFace=="boolean"?u.disableFontFace:Ee,H=u.fontExtraProperties===!0,q=u.enableXfa===!0,G=u.ownerDocument||globalThis.document,tt=u.disableRange===!0,$=u.disableStream===!0,U=u.disableAutoFetch===!0,yt=u.pdfBug===!0,Ot=u.CanvasFactory||(Ee?Hb:Nb),as=u.FilterFactory||(Ee?Bb:Ob),mi=u.enableHWA===!0,lt=u.useWasm!==!1,ht=l?l.length:u.length??NaN,_s=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!Ee&&!R,Ss=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:!!(A===Dp&&S===Rp&&E===Lp&&b&&w&&_&&kl(b,document.baseURI)&&kl(w,document.baseURI)&&kl(_,document.baseURI)),bi=null;fb(d);const Bt={canvasFactory:new Ot({ownerDocument:G,enableHWA:mi}),filterFactory:new as({docId:e,ownerDocument:G}),cMapReaderFactory:Ss?null:new A({baseUrl:b,isCompressed:y}),standardFontDataFactory:Ss?null:new S({baseUrl:w}),wasmFactory:Ss?null:new E({baseUrl:_})};c||(c=vl.create({verbosity:d,port:fi.workerPort}),t._worker=c);const bu={docId:e,apiVersion:"5.4.296",data:n,password:o,disableAutoFetch:U,rangeChunkSize:h,length:ht,docBaseUrl:p,enableXfa:q,evaluatorOptions:{maxImageSize:x,disableFontFace:R,ignoreErrors:C,isEvalSupported:T,isOffscreenCanvasSupported:k,isImageDecoderSupported:M,canvasMaxAreaInBytes:I,fontExtraProperties:H,useSystemFonts:_s,useWasm:lt,useWorkerFetch:Ss,cMapUrl:b,iccUrl:v,standardFontDataUrl:w,wasmUrl:_}},Au={ownerDocument:G,pdfBug:yt,styleElement:bi,loadingParams:{disableAutoFetch:U,enableXfa:q}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");
2const El=c.messageHandler.sendWithPromise("GetDocRequest",bu,n?[n.buffer]:null);let cr;if(l)cr=new aA(l,{disableRange:tt,disableStream:$});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");const yu=kl(s)?cA:Ee?wA:gA;cr=new yu({url:s,length:ht,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:tt,disableStream:$})}return El.then(yu=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const wp=new Fl(e,yu,c.port),cb=new TA(wp,t,cr,Au,Bt,mi);t._transport=cb,wp.send("Ready",null)})}).catch(t._capability.reject),t}var eu;const su=class su{constructor(){P(this,"_capability",Promise.withResolvers());P(this,"_transport",null);P(this,"_worker",null);P(this,"docId",`d${zt(su,eu)._++}`);P(this,"destroyed",!1);P(this,"onPassword",null);P(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,n;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(n=this._worker)==null||n.destroy(),this._worker=null}async getData(){return this._transport.getData()}};eu=new WeakMap,g(su,eu,0);let ff=su;var Yr,Zh,tc,ec,sc;class hp{constructor(t,e,s=!1,n=null){g(this,Yr,Promise.withResolvers());g(this,Zh,[]);g(this,tc,[]);g(this,ec,[]);g(this,sc,[]);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=n}addRangeListener(t){i(this,sc).push(t)}addProgressListener(t){i(this,ec).push(t)}addProgressiveReadListener(t){i(this,tc).push(t)}addProgressiveDoneListener(t){i(this,Zh).push(t)}onDataRange(t,e){for(const s of i(this,sc))s(t,e)}onDataProgress(t,e){i(this,Yr).promise.then(()=>{for(const s of i(this,ec))s(t,e)})}onDataProgressiveRead(t){i(this,Yr).promise.then(()=>{for(const e of i(this,tc))e(t)})}onDataProgressiveDone(){i(this,Yr).promise.then(()=>{for(const t of i(this,Zh))t()})}transportReady(){i(this,Yr).resolve()}requestDataRange(t,e){At("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Yr=new WeakMap,Zh=new WeakMap,tc=new WeakMap,ec=new WeakMap,sc=new WeakMap;class CA{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Y(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"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var $i,Kr,zl;class xA{constructor(t,e,s,n=!1){g(this,Kr);g(this,$i,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=n?new Ep:null,this._pdfBug=n,this.commonObjs=s.commonObjs,this.objs=new em,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:n=0,dontFlip:r=!1}={}){return new Uc({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}
2=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 Y(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:n="display",annotationMode:r=nn.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:p=!1,recordOperations:b=!1,operationsFilter:y=null}){var M,I,R;(M=this._stats)==null||M.time("Overall");const A=this._transport.getRenderingIntent(n,r,d,p),{renderingIntent:v,cacheKey:w}=A;f(this,$i,!1),l||(l=this._transport.getOptionalContentConfig(v));let S=this._intentStates.get(w);S||(S=Object.create(null),this._intentStates.set(w,S)),S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null);const _=!!(v&es.PRINT);S.displayReadyCapability||(S.displayReadyCapability=Promise.withResolvers(),S.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(I=this._stats)==null||I.time("Page Request"),this._pumpOperatorList(A));const E=!!(this._pdfBug&&((R=globalThis.StepperManager)!=null&&R.enabled)),C=!this.recordedBBoxes&&(b||E),x=H=>{var q,G;if(S.renderTasks.delete(T),C){const tt=(q=T.gfx)==null?void 0:q.dependencyTracker.take();tt&&(T.stepper&&T.stepper.setOperatorBBoxes(tt,T.gfx.dependencyTracker.takeDebugMetadata()),b&&(this.recordedBBoxes=tt))}_&&f(this,$i,!0),m(this,Kr,zl).call(this),H?(T.capability.reject(H),this._abortOperatorList({intentState:S,reason:H instanceof Error?H:new Error(H)})):T.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(G=globalThis.Stats)!=null&&G.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},T=new pf({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:C?new jb(e,S.operatorList.length,E):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:S.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:y});(S.renderTasks||(S.renderTasks=new Set)).add(T);const k=T.task;return Promise.all([S.displayReadyCapability.promise,l]).then(([H,q])=>{var G;if(this.destroyed){x();return}if((G=this._stats)==null||G.time("Rendering"),!(q.renderingIntent&v))throw new Error("Mu
2st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");T.initializeGraphics({transparency:H,optionalContentConfig:q}),T.operatorListChanged()}).catch(x),k}getOperatorList({intent:t="display",annotationMode:e=nn.ENABLE,printAnnotationStorage:s=null,isEditing:n=!1}={}){var h;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,n,!0);let o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(n){return n.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Zl.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,n){function r(){a.read().then(function({value:l,done:h}){if(h){s(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),r()},n)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),f(this,$i,!1),Promise.all(t)}cleanup(t=!1){f(this,$i,!0);const e=m(this,Kr,zl).call(this);return t&&e&&this._stats&&(this._stats=new Ep),e}_startRenderPage(t,e){var n,r;const s=this._intentStates.get(e);s&&((n=this._stats)==null||n.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,n=t.length;s<n;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&m(this,Kr,zl).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:n}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:n},a).getReader(),h=this._intentStates.get(e);h.streamReader=l;const c=()=>{l.read().then(({value:d,done:p})=>{if(p){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(const p of h.renderTasks)p.operatorListChanged();m(this,Kr,zl).call(this)}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 fu){let n=EA;e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},n);return}}if(t.streamReader.cancel(new on(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[n,r]of this._intentStates)if(r===t){this._intentStates.delete(n);break}this.cleanup()}}}get stats(){return this._stats}}$i=new WeakMap,Kr=new WeakSet,zl=function(){if(!i(this,$i)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),f(this,$i,!1),!0};var Nn,Ds,zi,Qr,iu,Jr,Zr,Ce,ud,om,lm,Gl,Bo,fd;const St=class St{constructor({name:t=null,port:e=null,verbosity:s=pb()}={}){g(this,Ce);g(this,Nn,Promise.withResolvers());g(this,Ds,null);g(this,zi,null);g(this,Qr,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(i(St,Zr).has(e))throw new Error("Cannot use more than one PDFWorker per port.");i(St,Zr).set(e,this),m(this,Ce,om).call(this,e)}else m(this,Ce,lm).call(this)}get promise(){return i(this,Nn).promise}get port(){return i(this,zi)}get messageHandler(){return i(this,Ds)}destroy(){var t,e;this.destroyed=!0,(t=i(this,Qr))==null||t.terminate(),f(this,Qr,null),i(St,Zr).delete(i(this,zi)),f(this,zi,null),(e=i(this,Ds))==null||e.destroy(),f(this,Ds,null)}static create(t){const e=i(this,Zr).get(t==null?void 0:t.port);
2if(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 St(t)}static get workerSrc(){if(fi.workerSrc)return fi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Y(this,"_setupFakeWorkerGlobal",(async()=>i(this,Bo,fd)?i(this,Bo,fd):(await import(this.workerSrc)).WorkerMessageHandler)())}};Nn=new WeakMap,Ds=new WeakMap,zi=new WeakMap,Qr=new WeakMap,iu=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,Ce=new WeakSet,ud=function(){i(this,Nn).resolve(),i(this,Ds).send("configure",{verbosity:this.verbosity})},om=function(t){f(this,zi,t),f(this,Ds,new Fl("main","worker",t)),i(this,Ds).on("ready",()=>{}),m(this,Ce,ud).call(this)},lm=function(){if(i(St,Jr)||i(St,Bo,fd)){m(this,Ce,Gl).call(this);return}let{workerSrc:t}=St;try{St._isSameOrigin(window.location,t)||(t=St._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Fl("main","worker",e),n=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?i(this,Nn).reject(new Error("Worker was destroyed")):m(this,Ce,Gl).call(this)},r=new AbortController;e.addEventListener("error",()=>{i(this,Qr)||n()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){n();return}f(this,Ds,s),f(this,zi,e),f(this,Qr,e),m(this,Ce,ud).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){n();return}try{a()}catch{m(this,Ce,Gl).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{uu("The worker has been disabled.")}m(this,Ce,Gl).call(this)},Gl=function(){i(St,Jr)||(V("Setting up fake worker."),f(St,Jr,!0)),St._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){i(this,Nn).reject(new Error("Worker was destroyed"));return}const e=new Fb;f(this,zi,e);const s=`fake${zt(St,iu)._++}`,n=new Fl(s+"_worker",s,e);t.setup(n,e),f(this,Ds,new Fl(s,s+"_worker",e)),m(this,Ce,ud).call(this)}).catch(t=>{i(this,Nn).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Bo=new WeakSet,fd=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},g(St,Bo),g(St,iu,0),g(St,Jr,!1),g(St,Zr,new WeakMap),Ee&&(f(St,Jr,!0),fi.workerSrc||(fi.workerSrc="./pdf.worker.mjs")),St._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const n=new URL(e,s);return s.origin===n.origin},St._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},St.fromPort=t=>{if(Sb("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return St.create(t)};let vl=St;var Gi,ii,Ho,Uo,ji,ta,jl;class TA{constructor(t,e,s,n,r,a){g(this,ta);g(this,Gi,new Map);g(this,ii,new Map);g(this,Ho,new Map);g(this,Uo,new Map);g(this,ji,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new em,this.fontLoader=new Mb({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.wasmFactory=r.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=a,this.setupMessageHandler()}get annotationStorage(){return Y(this,"annotationStorage",new ap)}getRenderingIntent(t,e=nn.ENABLE,s=null,n=!1,r=!1){let a=es.DISPLAY,o=Ku;switch(t){case"any":a=es.ANY;break;case"display":break;case"print":a=es.PRINT;break;default:V(`getRenderingIntent - invalid intent: ${t}`)}const l=a&es.PRINT&&s instanceof Bg?s:this.annotationStorage;switch(e){case nn.DISABLE:a+=es.ANNOTATIONS_DISABLE;break;case nn.ENABLE:break;case nn.ENABLE_FORMS:a+=es.ANNOTATIONS_FORMS;break;case nn.ENABLE_STORAGE:a+=es.ANNOTATIONS_STORAGE,o=l.serializable;break;default:V(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(a+=es.IS_EDITING),r&&(a+=es.OPLIST);const{ids:h,hash:c}=l.modifiedIds,d=[a,o.hash,c];return{renderingIntent:a,cacheKey:d.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=i(this,ji))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const n of i(this,ii).values())t.push(n._destroy());i(this,ii).clear(),i(this,Ho).clear(),i(this,Uo).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();
2const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var n,r;this.commonObjs.clear(),this.fontLoader.clear(),i(this,Gi).clear(),this.filterFactory.destroy(),wl.cleanup(),(n=this._networkStream)==null||n.cancelAllRequests(new on("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,n)=>{et(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},n.onPull=()=>{this._fullReader.read().then(function({value:r,done:a}){if(a){n.close();return}et(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{n.error(r)})},n.onCancel=r=>{this._fullReader.cancel(r),n.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:a}=this._fullReader;return(!n||!r)&&(this._lastProgress&&((o=e.onProgress)==null||o.call(e,this._lastProgress)),this._fullReader.onProgress=l=>{var h;(h=e.onProgress)==null||h.call(e,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,n)=>{et(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(s.begin,s.end);if(!r){n.close();return}n.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){n.close();return}et(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{n.error(a)})},n.onCancel=a=>{r.cancel(a),n.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new CA(s,this))}),t.on("DocException",s=>{e._capability.reject(Te(s))}),t.on("PasswordRequest",s=>{f(this,ji,Promise.withResolvers());try{if(!e.onPassword)throw Te(s);const n=r=>{r instanceof Error?i(this,ji).reject(r):i(this,ji).resolve({password:r})};e.onPassword(n,s.code)}catch(n){i(this,ji).reject(n)}return i(this,ji).promise}),t.on("DataLoaded",s=>{var n;(n=e.onProgress)==null||n.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;i(this,ii).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,n,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(n){case"Font":if("error"in r){const d=r.error;V(`Error during font loading: ${d}`),this.commonObjs.resolve(s,d);break}const o=new lf(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(d,p)=>globalThis.FontInspector.fontAdded(d,p):null,h=new Db(o,l,r.extra,r.charProcOperatorList);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!h.fontExtraProperties&&h.data&&h.clearData(),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:c}=r;et(c,"The imageRef must be defined.");for(const d of i(this,ii).values())for(const[,p]of d.objs)if((p==null?void 0:p.ref)===c)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,r);break;default:throw new Error(`Got unknown common object type ${n}`)}return null}),t.on("obj",([s,n,r,a])=>{var l;if(this.destroyed)return;const o=i(this,ii).get(n);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{var n;this.destroyed||(n=e.onProgress)==null||n.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");const n=this[s.type];if(!n)throw new Error(`${s.type} not initialized, see the \`useWorkerFetch\` parameter.`);return n.fetch(s)})}
2getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&V("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=i(this,Ho).get(e);if(s)return s;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&i(this,Uo).set(r.refStr,t);const a=new xA(e,r,this,this._params.pdfBug);return i(this,ii).set(e,a),a});return i(this,Ho).set(e,n),n}getPageIndex(t){return Qu(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return m(this,ta,jl).call(this,"GetFieldObjects")}hasJSActions(){return m(this,ta,jl).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return m(this,ta,jl).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return m(this,ta,jl).call(this,"GetOptionalContentConfig").then(e=>new rA(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=i(this,Gi).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(n=>{var r,a;return{info:n[0],metadata:n[1]?new iA(n[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return i(this,Gi).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of i(this,ii).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),i(this,Gi).clear(),this.filterFactory.destroy(!0),wl.cleanup()}}cachedPageNumber(t){if(!Qu(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return i(this,Uo).get(e)??null}}Gi=new WeakMap,ii=new WeakMap,Ho=new WeakMap,Uo=new WeakMap,ji=new WeakMap,ta=new WeakSet,jl=function(t,e=null){const s=i(this,Gi).get(t);if(s)return s;const n=this.messageHandler.sendWithPromise(t,e);return i(this,Gi).set(t,n),n};var On;class PA{constructor(t){g(this,On,null);P(this,"onContinue",null);P(this,"onError",null);f(this,On,t)}get promise(){return i(this,On).capability.promise}cancel(t=0){i(this,On).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=i(this,On).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=i(this,On);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}On=new WeakMap;var Bn,ea;const gr=class gr{constructor({callback:t,params:e,objs:s,commonObjs:n,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:p=null,enableHWA:b=!1,operationsFilter:y=null}){g(this,Bn,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=n,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=d,this.pageColors=p,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 PA(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=b,this._dependencyTracker=e.depen
2dencyTracker,this._operationsFilter=y}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var l,h;if(this.cancelled)return;if(this._canvas){if(i(gr,ea).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.");i(gr,ea).add(this._canvas)}this._pdfBug&&((l=globalThis.StepperManager)!=null&&l.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:n,background:r,dependencyTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Wa(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s,n,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),i(this,Bn)&&(window.cancelAnimationFrame(i(this,Bn)),f(this,Bn,null)),i(gr,ea).delete(this._canvas),t||(t=new fu(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(n=this.task).onError)==null||r.call(n,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.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?f(this,Bn,window.requestAnimationFrame(()=>{f(this,Bn,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),i(gr,ea).delete(this._canvas),this.callback())))}};Bn=new WeakMap,ea=new WeakMap,g(gr,ea,new WeakSet);let pf=gr;const hm="5.4.296",cm="f56dc8601";var Ge,sa,$o,Wt,ic,zo,Vi,nc,Hn,Rs,rc,pt,gf,mf,bf,dr,dm,dn;const Pe=class Pe{constructor({editor:t=null,uiManager:e=null}){g(this,pt);g(this,Ge,null);g(this,sa,null);g(this,$o);g(this,Wt,null);g(this,ic,!1);g(this,zo,!1);g(this,Vi,null);g(this,nc);g(this,Hn,null);g(this,Rs,null);var s,n;t?(f(this,zo,!1),f(this,Vi,t)):f(this,zo,!0),f(this,Rs,(t==null?void 0:t._uiManager)||e),f(this,nc,i(this,Rs)._eventBus),f(this,$o,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((n=i(this,Rs))==null?void 0:n.highlightColors.values().next().value)||"#FFFF98"),i(Pe,rc)||f(Pe,rc,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return Y(this,"_keyboardManager",new zc([[["Escape","mac+Escape"],Pe.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Pe.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Pe.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Pe.prototype._moveToPrevious],[["Home","mac+Home"],Pe.prototype._moveToBeginning],[["End","mac+End"],Pe.prototype._moveToEnd]]))}renderButton(){const t=f(this,Ge,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",i(this,Vi)&&(t.ariaControls=`${i(this,Vi).id}_colorpicker_dropdown`);const e=i(this,Rs)._signal;t.addEventListener("click",m(this,pt,dr).bind(this),{signal:e}),t.addEventListener("keydown",m(this,pt,bf).bind(this),{signal:e});const s=f(this,sa,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=i(this,$o),t.append(s),t}renderMainDropdown(){const t=f(this,Wt,m(this,pt,gf).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===i(this,Ge)){m(this,pt,dr).call(this,t);return}const e=t.target.getAttribute("data-color");e&&m(this,pt,mf).call(this,e,t)}_moveToNext(t){var e,s;if(!i(this,pt,dn)){m(this,pt,dr).call(this,t);return}if(t.target===i(this,Ge)){(e=i(this,Wt).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=i(this,Wt))==null?void 0:e.firstChild)||t.target===i(this,Ge)){i(this,pt,dn)&&this._hideDropdownFromKeyboard();return}i(this,pt,dn)||m(this,pt,dr).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!i(this,pt,dn)){m(this,pt,dr).call(this,t);return}(e=i(this,Wt).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!i(this,pt,dn)){m(this,pt,dr).call(this,t);return}(e=i(this,Wt).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=i(this,Wt))==null||t.classList.add("hidden"),i(this,Ge).ariaExpanded="false",(e=i(this,Hn))==null||e.abort(),f(this,Hn,null)}_hideDropdownFromKeyboard(){var t;if(!i(this,zo)){if(!i(this,pt,dn)){(t=i(this,Vi))==null||t.unselect();return}this.hideDropdown(),i(this,Ge).focus({preventScroll:!0,focusVisible:i(this,ic)})}}updateColor(t){if(i(this,sa)&&(i(this,sa).style.backgroundColor=t),!i(this,Wt))return;const e=i(this,Rs).highlightColors.values();for(const s of i(this,Wt).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=i(this,Ge))==null||t.remove(),f(this,Ge,null),f(this,sa,null),(e=i(this,Wt))==null||e.remove(),f(this,Wt,null)}};Ge=new WeakMap,sa=new WeakMap,$o=new WeakMap,Wt=new WeakMap,ic=new WeakMap,zo=new WeakMap,Vi=new WeakMap,nc=new WeakMap,Hn=new WeakMap,Rs=new WeakMap,rc=new WeakMap,pt=new WeakSet,gf=function(){const t=document.createElement("div"),e=i(this,Rs)._signal;t.addEventListener("contextmenu",rs,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),i(this,Vi)&&(t.id=`${i(this,Vi).id}_colorpicker_dropdown`);for(const[s,n]of i(this,Rs).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",n),r.title=s,r.setAttribute("data-l10n-id",i(Pe,rc)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.ariaSelected=n===i(this,$o),r.addEventListener("click",m(this,pt,mf).bind(this,n),{signal:e}),t.append(r)}return t.addEventListener("keydown",m(this,pt,bf).bind(this),{signal:e}),t},mf=function(t,e){e.stopPropagation(),i(this,nc).dispatch("switchannotationeditorparams",{source:this,type:Z.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},bf=function(t){Pe._keyboardManager.exec(this,t)},dr=function(t){if(i(this,pt,dn)){this.hideDropdown();return}if(f(this,ic,t.detail===0),i(this,Hn)||(f(this,Hn,new AbortController),window.addEventListener("pointerdown",m(this,pt,dm).bind(this),{signal:i(this,Rs).combinedSignal(i(this,Hn))})),i(this,Ge).ariaExpanded="true",i(this,Wt)){i(this,Wt).classList.remove("hidden");return}const e=f(this,Wt,m(this,pt,gf).call(this));i(this,Ge).append(e)},dm=function(t){var e;(e=i(this,Wt))!=null&&e.contains(t.target)||this.hideDropdown()},dn=function(){return i(this,Wt)&&!i(this,Wt).classList.contains("hidden")},g(Pe,rc,null);let sh=Pe;var ni,ac,Go,oc;const mr=class mr{constructor(t){g(this,ni,null);g(this,ac,null);g(this,Go,null);f(this,ac,t),f(this,Go,t._uiManager),i(mr,oc)||f(mr,oc,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(i(this,ni))return i(this,ni);const{editorType:t,colorType:e,colorValue:s}=i(this,ac),n=f(this,ni,document.createElement("input"));return n.type="color",n.value=s||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",i(mr,oc)[t]),n.addEventListener("input",()=>{i(this,Go).updateParams(e,n.value)},{signal:i(this,Go)._signal}),n}update(t){i(this,ni)&&(i(this,ni).value=t)}destroy(){var t;(t=i(this,ni))==null||t.remove(),f(this,ni,null)}hideDropdown(){}};ni=new WeakMap,ac=new WeakMap,Go=new WeakMap,oc=new WeakMap,g(mr,oc,null);let Hd=mr;function Wp(u){return Math.floor(Math.max(0,Math.min(1,u))*255).toString(16).padStart(2,"0")}function Tl(u){return Math.max(0,Math.min(255,255*u))}class Xp{static CMYK_G([t,e,s,n]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+n)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Tl(t),[t,t,t]}static G_HTML([t]){const e=Wp(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(Tl)}static RGB_HTML(t){return`#${t.map(Wp).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,s+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,s,n]){return[Tl(1-Math.min(1,t+n)),Tl(1-Math.min(1,s+n)),Tl(1-Math.min(1,e+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const n=1-t,r=1-e,a=1-s,o=Math.min(n,r,a);return["CMYK",n,r,a,o]}}class kA{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),s||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){At("Abstract method `_createSVG` called.")}}class ih extends kA{_createSVG(t){return document.createElementNS(Ai,t)}}const MA=9,ka=new WeakSet,DA=new Date().getTimezoneOffset()*60*1e3;class qp{static create(t){switch(t.data.annotationType){case It.LINK:return new cp(t);case It.TEXT:return new LA(t);case It.WIDGET:switch(t.data.fieldType){case"Tx":return new IA(t);case"Btn":return t.data.radioButton?new pm(t):t.data.checkBox?new NA(t):new OA
2(t);case"Ch":return new BA(t);case"Sig":return new FA(t)}return new Da(t);case It.POPUP:return new yf(t);case It.FREETEXT:return new ym(t);case It.LINE:return new UA(t);case It.SQUARE:return new $A(t);case It.CIRCLE:return new zA(t);case It.POLYLINE:return new wm(t);case It.CARET:return new jA(t);case It.INK:return new dp(t);case It.POLYGON:return new GA(t);case It.HIGHLIGHT:return new vm(t);case It.UNDERLINE:return new VA(t);case It.SQUIGGLY:return new WA(t);case It.STRIKEOUT:return new XA(t);case It.STAMP:return new _m(t);case It.FILEATTACHMENT:return new qA(t);default:return new kt(t)}}}var ia,jo,bs,lc,Af;const Ap=class Ap{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:n=!1}={}){g(this,lc);g(this,ia,null);g(this,jo,!1);g(this,bs,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Ap._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}
2get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:n}=this.data;let r=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;l<e.length;l+=8)e[l+1]>a?(a=e[l+1],r=e[l+2]):e[l+1]===a&&(r=Math.max(r,e[l+2]));return[r,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let h=0,c=l.length;h<c;h+=2)l[h+1]>a?(a=l[h+1],r=l[h]):l[h+1]===a&&(r=Math.max(r,l[h]));if(r!==1/0)return[r,a]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-a)/n,t}get commentText(){var e,s,n;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${Ql}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((n=t.contentsObj)==null?void 0:n.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${Ql}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=i(this,bs))==null?void 0:t.popup)||this.popup)==null||e.remove(),f(this,bs,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(i(this,ia)||f(this,ia,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&m(this,lc,Af).call(this,e);let n=((r=i(this,bs))==null?void 0:r.popup)||this.popup;!n&&(s!=null&&s.text)&&(this._createPopup(s),n=i(this,bs).popup),n&&(n.updateEdited(t),s!=null&&s.deleted&&(n.remove(),f(this,bs,null),this.popup=null))}resetEdited(){var t;i(this,ia)&&(m(this,lc,Af).call(this,i(this,ia).rect),(t=i(this,bs))==null||t.popup.resetEdited(),f(this,ia,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:n}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Da)&&!(this instanceof cp)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof yf){const{rotation:A}=e;return!e.hasOwnCanvas&&A!==0&&this.setRotation(A,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const A=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(A>0||v>0){const S=`calc(${A}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;a.borderRadius=S}else if(this instanceof pm){const S=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;a.borderRadius=S}switch(e.borderStyle.style){case La.SOLID:a.borderStyle="solid";break;case La.DASHED:a.borderStyle="dashed";break;case La.BEVELED:V("Unimplemented border style: beveled");break;case La.INSET:V("Unimplemented border style: inset");break;case La.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(f(this,jo,!0),a.borderColor=N.makeHexColor(w[0]|0,w[1]|0,w[2]|0)):a.borderWidth=0}const h=N.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:p,pageY:b}=n.rawDims;a.left=`${100*(h[0]-p)/c}%`,a.top=`${100*(h[1]-b)/d}%`;const{rotation:y}=e;return e.hasOwnCanvas||y===0?(a.width=`${100*o/c}%`,a.height=`${100*l/d}%`):this.setRotation(y,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:n}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/n}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,n)=>{const r=n.detail[e],a=r[0],o=r.slice(1);n.target.style[s]=Xp[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Xp[`${a}_rgb`](o)})};return Y(this,"_commonActions",{display:e=>{const{display:s}=e.detail,n=s%2===1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>
2e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const n of Object.keys(e.detail)){const r=t[n]||s[n];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[n,r]of Object.entries(e)){const a=s[n];if(a){const o={detail:{[n]:r},target:t};a(o),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,n,r]=this.data.rect.map(A=>Math.fround(A));if(t.length===8){const[A,v,w,S]=t.subarray(2,6);if(n===A&&r===v&&e===w&&s===S)return}const{style:a}=this.container;let o;if(i(this,jo)){const{borderColor:A,borderWidth:v}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${A}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=n-e,h=r-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const p=c.createElement("defs");d.append(p);const b=c.createElement("clipPath"),y=`clippath_${this.data.id}`;b.setAttribute("id",y),b.setAttribute("clipPathUnits","objectBoundingBox"),p.append(b);for(let A=2,v=t.length;A<v;A+=8){const w=t[A],S=t[A+1],_=t[A+2],E=t[A+3],C=c.createElement("rect"),x=(_-e)/l,T=(r-S)/h,k=(w-_)/l,M=(S-E)/h;C.setAttribute("x",x),C.setAttribute("y",T),C.setAttribute("width",k),C.setAttribute("height",M),b.append(C),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${T}" width="${k}" height="${M}"/>`)}i(this,jo)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${y})`}_createPopup(t=null){const{data:e}=this;let s,n;t?(s={str:t.text},n=t.date):(s=e.contentsObj,n=e.modificationDate);const r=f(this,bs,new yf({data:{color:e.color,titleObj:e.titleObj,modificationDate:n,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]}));this.parent._commentManager||this.parent.div.append(r.render())}get hasPopupElement(){return!!(i(this,bs)||this.popup||this.data.popupRef)}get extraPopupElement(){return i(this,bs)}render(){At("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:r,id:a,exportValues:o}of n){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!ka.has(h)){V(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const n of document.getElementsByName(t)){const{exportValue:r}=n,a=n.getAttribute("data-element-id");a!==e&&ka.has(n)&&s.push({id:a,exportValue:r,domElement:n})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};ia=new WeakMap,jo=new WeakMap,bs=new WeakMap,lc=new WeakSet,Af=function(t){const{container:{style:e},data:{rect:s,rotation:n},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,n===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(n)};let kt=Ap;class RA extends kt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),this.extraPopupElement.popup.renderCommentButton())}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.container.remove(),this.container=null,this.removePopup()}}var is,ur,um,fm;class cp extends kt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});g(this,is);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action,e.overlaidText),r=!0):e.attachment?(m(this,is,um).call(this,n,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(m(this,is,fm).call(this,n,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(n,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(n),this.container}_bindLink(e,s,n=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&m(this,is,ur).call(this),n&&(e.title=n)}_bindNamedAction(e,s,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),n&&(e.title=n),m(this,is,ur).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=n.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),m(this,is,ur).call(this)}_bindResetFormAction(e,s){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),m(this,is,ur).call(this),!this._fieldObjects){V('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{var d;n==null||n();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const p=new Set(a);for(const b of r){const y=this._fieldObjects[b]||[];for(const{id:A}of y)p.add(A)}for(const b of Object.values(this._fieldObjects))for(const y of b)p.has(y.id)===o&&l.push(y)}else for(const p of Object.values(this._fieldObjects))l.push(...p);const h=this.annotationStorage,c=[];for(const p of l){const{id:b}=p;switch(c.push(b),p.type){case"text":{const A=p.defaultValue||"";h.setValue(b,{value:A});break}case"checkbox":case"radiobutton":{const A=p.defaultValue===p.exportValues;h.setValue(b,{value:A});break}case"combobox":case"listbox":{const A=p.defaultValue||"";h.setValue(b,{value:A});break}default:continue}const y=document.querySelector(`[data-element-id="${b}"]`);if(y){if(!ka.has(y)){V(`_bindResetFormAction - element not allowed: ${b}`);continue}}else continue;y.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}is=new WeakSet,ur=function(){this.container.setAttribute("data-internal-link","")},um=function(e,s,n="",r=null){e.href=this.linkService.getAnchorUrl(""),s.description?e.title=s.description:n&&(e.title=n),e.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(s.content,s.filename,r),!1},m(this,is,ur).call(this)},fm=function(e,s,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),n&&(e.title=n),m(this,is,ur).call(this)};class LA extends kt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}
2class Da extends kt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ee.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,n,r){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(a)}}))})}_setEventListeners(t,e,s,n){var r,a,o;for(const[l,h]of s)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,h,n),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":N.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||MA,r=t.style;let a;const o=2,l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o),c=Math.round(h/(vu*n))||1,d=h/c;a=Math.min(n,l(d/vu))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(n,l(h/vu))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=N.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class IA extends Da{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,n){const r=this.annotationStorage;
2for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[n]:s})}render(){var n,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let h=a.formattedValue||((n=this.data.textContent)==null?void 0:n.join(` 3`))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const c={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",h??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),ka.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:d,datetimeType:p,timeStep:b}=this.data,y=!!p&&this.enableScripting;d&&(s.title=d),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",v=>{t.setValue(e,{value:v.target.value}),this.setPropertyOnSiblings(s,"value",v.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",v=>{const w=this.data.defaultFieldValue??"";s.value=c.userValue=w,c.formattedValue=null});let A=v=>{const{formattedValue:w}=c;w!=null&&(v.target.value=w),v.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var _;if(c.focused)return;const{target:S}=w;if(y&&(S.type=p,b&&(S.step=b)),c.userValue){const E=c.userValue;if(y)if(p==="time"){const C=new Date(E),x=[C.getHours(),C.getMinutes(),C.getSeconds()];S.value=x.map(T=>T.toString().padStart(2,"0")).join(":")}else S.value=new Date(E-DA).toISOString().split(p==="date"?"T":".",1)[0];else S.value=E}c.lastCommittedValue=S.value,c.commitKey=1,(_=this.data.actions)!=null&&_.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",w=>{this.showElementAndHideCanvas(w.target);const S={value(_){c.userValue=_.detail.value??"",y||t.setValue(e,{value:c.userValue.toString()}),_.target.value=c.userValue},formattedValue(_){const{formattedValue:E}=_.detail;c.formattedValue=E,E!=null&&_.target!==document.activeElement&&(_.target.value=E);const C={formattedValue:E};y&&(C.value=E),t.setValue(e,C)},selRange(_){_.target.setSelectionRange(..._.detail.selRange)},charLimit:_=>{var T;const{charLimit:E}=_.detail,{target:C}=_;if(E===0){C.removeAttribute("maxLength");return}C.setAttribute("maxLength",E);let x=c.userValue;!x||x.length<=E||(x=x.slice(0,E),C.value=c.userValue=x,t.setValue(e,{value:x}),(T=this.linkService.eventBus)==null||T.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:x,willCommit:!0,commitKey:1,selStart:C.selectionStart,selEnd:C.selectionEnd}}))}};this._dispatchEventFromSandbox(S,w)}),s.addEventListener("keydown",w=>{var E;c.commitKey=1;let S=-1;if(w.key==="Escape"?S=0:w.key==="Enter"&&!this.data.multiLine?S=2:w.key==="Tab"&&(c.commitKey=3),S===-1)return;const{value:_}=w.target;c.lastCommittedValue!==_&&(c.lastCommittedValue=_,c.userValue=_,(E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:S,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const v=A;A=null,s.addEventListener("blur",w=>{var E,C;if(!c.focused||!w.relatedTarget)return;(E=this.data.actions)!=null&&E.Blur||(c.focused=!1);const{target:S}=w;let{value:_}=S;if(y){if(_&&p==="time"){const x=_.split(":").map(T=>parseInt(T,10));_=new Date(2e3,0,1,x[0],x[1],x[2]||0).valueOf(),S.step=""}else _.includes("T")||(_=`${_}T00:00`),_=new Date(_).valueOf();S.type="text"}c.userValue=_,c.lastCommittedValue!==_&&((C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,
3commitKey:c.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),v(w)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",w=>{var M;c.lastCommittedValue=null;const{data:S,target:_}=w,{value:E,selectionStart:C,selectionEnd:x}=_;let T=C,k=x;switch(w.inputType){case"deleteWordBackward":{const I=E.substring(0,C).match(/\w*[^\w]*$/);I&&(T-=I[0].length);break}case"deleteWordForward":{const I=E.substring(C).match(/^[^\w]*\w*/);I&&(k+=I[0].length);break}case"deleteContentBackward":C===x&&(T-=1);break;case"deleteContentForward":C===x&&(k+=1);break}w.preventDefault(),(M=this.linkService.eventBus)==null||M.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,change:S||"",willCommit:!1,selStart:T,selEnd:k}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(A&&s.addEventListener("blur",A),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${w}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}}class FA extends Da{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class NA extends Da{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let n=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof n=="string"&&(n=n!=="Off",t.setValue(s,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return ka.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s)){const c=l&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class pm extends Da{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let n=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof n=="string"&&(n=n!==e.buttonValue,t.setValue(s,{value:n})),n)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const r=document.createElement("input");if(ka.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const c=a===h.detail.value;for(const d of this._getElementsByName(h.target.name)){const p=c&&d.id===s;d.domElement&&(d.domElement.checked=p),t.setValue(d.id,{value:p})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}
3return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class OA extends cp{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class BA extends Da{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");ka.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue;for(const p of n.options)p.selected=p.value===d});for(const c of this.data.options){const d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,s.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),r=!1),n.append(d)}let a=null;if(r){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),n.prepend(c),a=()=>{c.remove(),n.removeEventListener("input",a),a=null},n.addEventListener("input",a)}const o=c=>{const d=c?"value":"textContent",{options:p,multiple:b}=n;return b?Array.prototype.filter.call(p,y=>y.selected).map(y=>y[d]):p.selectedIndex===-1?null:p[p.selectedIndex][d]};let l=o(!1);const h=c=>{const d=c.target.options;return Array.prototype.map.call(d,p=>({displayValue:p.textContent,exportValue:p.value}))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",c=>{const d={value(p){a==null||a();const b=p.detail.value,y=new Set(Array.isArray(b)?b:[b]);for(const A of n.options)A.selected=y.has(A.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(p){n.multiple=!0},remove(p){const b=n.options,y=p.detail.remove;b[y].selected=!1,n.remove(y),b.length>0&&Array.prototype.findIndex.call(b,v=>v.selected)===-1&&(b[0].selected=!0),t.setValue(e,{value:o(!0),items:h(p)}),l=o(!1)},clear(p){for(;n.length!==0;)n.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(p){const{index:b,displayValue:y,exportValue:A}=p.detail.insert,v=n.children[b],w=document.createElement("option");w.textContent=y,w.value=A,v?v.before(w):n.append(w),t.setValue(e,{value:o(!0),items:h(p)}),l=o(!1)},items(p){const{items:b}=p.detail;for(;n.length!==0;)n.remove(0);for(const y of b){const{displayValue:A,exportValue:v}=y,w=document.createElement("option");w.textContent=A,w.value=v,n.append(w)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(p)}),l=o(!1)},indices(p){const b=new Set(p.detail.indices);for(const y of p.target.options)y.selected=b.has(y.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(p){p.target.disabled=!p.detail.editable}};this._dispatchEventFromSandbox(d,c)}),n.addEventListener("input",c=>{var b;const d=o(!0),p=o(!1);t.setValue(e,{value:d}),c.preventDefault(),(b=this.linkService.eventBus)==null||b.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:p,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(n,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)):n.addEventListener("input",function(c){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}var hc,wf;class yf extends kt{constructor(e){const{data:s,elements:n,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&kt._hasPopupData(s)});g(this,hc);if(this.elements=n,a&&kt._hasPopupData(s)){const o=this.popup=m(this,hc,wf).call(this);for(const l of n)l.popup=o}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";
3const s=this.popup=m(this,hc,wf).call(this),n=[];for(const r of this.elements)r.popup=s,r.container.ariaHasPopup="dialog",n.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",n.map(r=>`${ip}${r}`).join(",")),this.container}}hc=new WeakSet,wf=function(){return new HA({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,commentManager:this.parent._commentManager})};var je,Un,nu,ru,Vo,Wo,Rt,ri,$n,na,Xo,qo,ai,Ve,Wi,Xi,Yt,qi,zn,cc,Yi,Yo,ra,Gn,me,jn,Q,pd,vf,_f,Sf,gd,Ef,gm,mm,bm,Am,md,bd,Cf;class HA{constructor({container:t,color:e,elements:s,titleObj:n,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:d,commentManager:p=null}){g(this,Q);g(this,je,null);g(this,Un,m(this,Q,bm).bind(this));g(this,nu,m(this,Q,Cf).bind(this));g(this,ru,m(this,Q,bd).bind(this));g(this,Vo,m(this,Q,md).bind(this));g(this,Wo,null);g(this,Rt,null);g(this,ri,null);g(this,$n,null);g(this,na,null);g(this,Xo,null);g(this,qo,null);g(this,ai,!1);g(this,Ve,null);g(this,Wi,null);g(this,Xi,null);g(this,Yt,null);g(this,qi,null);g(this,zn,null);g(this,cc,null);g(this,Yi,null);g(this,Yo,null);g(this,ra,null);g(this,Gn,!1);g(this,me,null);g(this,jn,null);f(this,Rt,t),f(this,Yo,n),f(this,ri,a),f(this,Yi,o),f(this,Xo,l),f(this,Wo,e),f(this,cc,h),f(this,qo,c),f(this,na,s),f(this,je,p),f(this,me,s[0]),f(this,$n,th.toDateObject(r)),this.trigger=s.flatMap(b=>b.getElementsToTriggerPopup()),p?this.renderCommentButton():(m(this,Q,pd).call(this),i(this,Rt).hidden=!0,d&&m(this,Q,md).call(this))}renderCommentButton(){if(i(this,Yt)||(i(this,qi)||m(this,Q,vf).call(this),!i(this,qi)))return;const{signal:t}=f(this,Wi,new AbortController),e=!!i(this,me).extraPopupElement,s=()=>{i(this,je).toggleCommentPopup(this,!0,void 0,!e)},n=()=>{i(this,je).toggleCommentPopup(this,!1,!0,!e)},r=()=>{i(this,je).toggleCommentPopup(this,!1,!1)};if(e){f(this,Yt,i(this,me).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",i(this,Un),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",n,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),a.classList.add("popupTriggerArea")}else{const a=f(this,Yt,document.createElement("button"));a.className="annotationCommentButton";const o=i(this,me).container;a.style.zIndex=o.style.zIndex+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),m(this,Q,Sf).call(this),m(this,Q,_f).call(this),a.addEventListener("keydown",i(this,Un),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",n,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),o.after(a)}}get commentButtonColor(){const{color:t,opacity:e}=i(this,me).commentData;return t?i(this,Xo)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=i(this,Yt))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:n,modificationDate:r}=i(this,me).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:n,modificationDate:r}}get elementBeforePopup(){return i(this,Yt)}get comment(){return i(this,jn)||f(this,jn,i(this,me).commentText),i(this,jn)}set comment(t){t!==this.comment&&(i(this,me).commentText=f(this,jn,t))}get parentBoundingClientRect(){return i(this,me).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){i(this,Yt)&&(i(this,Yt).classList.toggle("selected",t),i(this,Yt).ariaExpanded=e)}setSelectedCommentButton(t){i(this,Yt).classList.toggle("selected",t)}get commentPopupPosition(){if(i(this,zn))return i(this,zn);const{x:t,y:e,height:s}=i(this,Yt).getBoundingClientRect(),{x:n,y:r,width:a,height:o}=i(this,me).layer.getBoundingClientRect();return[(t-n)/a,(e+s-r)/o]}set commentPopupPosition(t){f(this,zn,t)}hasDefaultPopupPosition(){return i(this,zn)===null}get commentButtonPosition(){return i(this,qi)}get commentButtonWidth(){return i(this,Yt).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=i(this,zn)||this.commentButtonPosition.map(h=>h/100),n=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=n;i(this,je).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:n})}render(){var s,n;if(i(this,Ve))return;const t=f(this,Ve,document.createElement("div"));if(t.className="popup",i(this,Wo)){const r=t.style.outlineColor=N.makeHexColor(...i(this,Wo));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=i(this,Yo))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=i(this,Yo)}if(t.append(e),i(this,$n)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:i(this,$n).valueOf()})),r.dateTime=i(this,$n).toISOString(),e.append(r)}rp({html:i(this,Q,gd)||i(this,ri).str,dir:(n=i(this,ri))==null?void 0:n.dir,className:"popupContent"},t),i(this,Rt).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var n;if(i(this,je)){s?(this.remove(),f(this,jn,null)):e&&(e.deleted?this.remove():(m(this,Q,Sf).call(this),f(this,jn,e.text))),t&&(f(this,qi,null),m(this,Q,vf).
3call(this),m(this,Q,_f).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}m(this,Q,pd).call(this),i(this,ra)||f(this,ra,{contentsObj:i(this,ri),richText:i(this,Yi)}),t&&f(this,Xi,null),e&&e.text&&(f(this,Yi,m(this,Q,mm).call(this,e.text)),f(this,$n,th.toDateObject(e.date)),f(this,ri,null)),(n=i(this,Ve))==null||n.remove(),f(this,Ve,null)}resetEdited(){var t;i(this,ra)&&({contentsObj:zt(this,ri)._,richText:zt(this,Yi)._}=i(this,ra),f(this,ra,null),(t=i(this,Ve))==null||t.remove(),f(this,Ve,null),f(this,Xi,null))}remove(){var t,e,s;if((t=i(this,Wi))==null||t.abort(),f(this,Wi,null),(e=i(this,Ve))==null||e.remove(),f(this,Ve,null),f(this,Gn,!1),f(this,ai,!1),(s=i(this,Yt))==null||s.remove(),f(this,Yt,null),this.trigger)for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){f(this,Gn,this.isVisible),i(this,Gn)&&(i(this,Rt).hidden=!0)}maybeShow(){i(this,je)||(m(this,Q,pd).call(this),i(this,Gn)&&(i(this,Ve)||m(this,Q,bd).call(this),f(this,Gn,!1),i(this,Rt).hidden=!1))}get isVisible(){return i(this,je)?!1:i(this,Rt).hidden===!1}}je=new WeakMap,Un=new WeakMap,nu=new WeakMap,ru=new WeakMap,Vo=new WeakMap,Wo=new WeakMap,Rt=new WeakMap,ri=new WeakMap,$n=new WeakMap,na=new WeakMap,Xo=new WeakMap,qo=new WeakMap,ai=new WeakMap,Ve=new WeakMap,Wi=new WeakMap,Xi=new WeakMap,Yt=new WeakMap,qi=new WeakMap,zn=new WeakMap,cc=new WeakMap,Yi=new WeakMap,Yo=new WeakMap,ra=new WeakMap,Gn=new WeakMap,me=new WeakMap,jn=new WeakMap,Q=new WeakSet,pd=function(){var e;if(i(this,Wi))return;f(this,Wi,new AbortController);const{signal:t}=i(this,Wi);for(const s of this.trigger)s.addEventListener("click",i(this,Vo),{signal:t}),s.addEventListener("pointerenter",i(this,ru),{signal:t}),s.addEventListener("pointerleave",i(this,nu),{signal:t}),s.classList.add("popupTriggerArea");for(const s of i(this,na))(e=s.container)==null||e.addEventListener("keydown",i(this,Un),{signal:t})},vf=function(){const t=i(this,na).find(e=>e.hasCommentButton);t&&f(this,qi,t._normalizePoint(t.commentButtonPosition))},_f=function(){if(i(this,me).extraPopupElement&&!i(this,me).editor)return;this.renderCommentButton();const[t,e]=i(this,qi),{style:s}=i(this,Yt);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},Sf=function(){i(this,me).extraPopupElement||(this.renderCommentButton(),i(this,Yt).style.backgroundColor=this.commentButtonColor||"")},gd=function(){const t=i(this,Yi),e=i(this,ri);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&i(this,Yi).html||null},Ef=function(){var t,e,s;return((s=(e=(t=i(this,Q,gd))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},gm=function(){var t,e,s;return((s=(e=(t=i(this,Q,gd))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},mm=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:i(this,Q,gm),fontSize:i(this,Q,Ef)?`calc(${i(this,Q,Ef)}px * var(--total-scale-factor))`:""}};for(const r of t.split(` 4`))e.push({name:"span",value:r,attributes:n});return s},bm=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&i(this,ai))&&m(this,Q,md).call(this)},Am=function(){if(i(this,Xi)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:n,pageY:r}}}=i(this,Xo);let a=!!i(this,qo),o=a?i(this,qo):i(this,cc);for(const y of i(this,na))if(!o||N.intersect(y.data.rect,o)!==null){o=y.data.rect,a=!0;break}const l=N.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),c=a?o[2]-o[0]+5:0,d=l[0]+c,p=l[1];f(this,Xi,[100*(d-n)/e,100*(p-r)/s]);const{style:b}=i(this,Rt);b.left=`${i(this,Xi)[0]}%`,b.top=`${i(this,Xi)[1]}%`},md=function(){if(i(this,je)){i(this,je).toggleCommentPopup(this,!1);return}f(this,ai,!i(this,ai)),i(this,ai)?(m(this,Q,bd).call(this),i(this,Rt).addEventListener("click",i(this,Vo)),i(this,Rt).addEventListener("keydown",i(this,Un))):(m(this,Q,Cf).call(this),i(this,Rt).removeEventListener("click",i(this,Vo)),i(this,Rt).removeEventListener("keydown",i(this,Un)))},bd=function(){i(this,Ve)||this.render(),this.isVisible?i(this,ai)&&i(this,Rt).classList.add("focused"):(m(this,Q,Am).call(this),i(this,Rt).hidden=!1,i(this,Rt).style.zIndex=parseInt(i(this,Rt).style.zIndex)+1e3)},Cf=function(){i(this,Rt).classList.remove("focused"),!(i(this,ai)||!this.isVisible)&&(i(this,Rt).hidden=!0,i(this,Rt).style.zIndex=parseInt(i(this,Rt).style.zIndex)-1e3)};class ym extends kt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=j.FREETEXT}
4render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var dc;class UA extends kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,dc,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:n}=this,r=this.svgFactory.create(s,n,!0),a=f(this,dc,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return i(this,dc)}addHighlightArea(){this.container.classList.add("highlightArea")}}dc=new WeakMap;var uc;class $A extends kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,uc,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:n}=this,r=this.svgFactory.create(s,n,!0),a=e.borderStyle.width,o=f(this,uc,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",n-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return i(this,uc)}addHighlightArea(){this.container.classList.add("highlightArea")}}uc=new WeakMap;var fc;class zA extends kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,fc,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:n}=this,r=this.svgFactory.create(s,n,!0),a=e.borderStyle.width,o=f(this,fc,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",n/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",n/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return i(this,fc)}addHighlightArea(){this.container.classList.add("highlightArea")}}fc=new WeakMap;var pc;class wm extends kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,pc,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:n,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let h=[];for(let d=0,p=s.length;d<p;d+=2){const b=s[d]-e[0],y=e[3]-s[d+1];h.push(`${b},${y}`)}h=h.join(" ");const c=f(this,pc,this.svgFactory.createElement(this.svgElementName));return c.setAttribute("points",h),c.setAttribute("stroke-width",n.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),l.append(c),this.container.append(l),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return i(this,pc)}addHighlightArea(){this.container.classList.add("highlightArea")}}pc=new WeakMap;class GA extends wm{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class jA extends kt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var gc,aa,mc,xf;class dp extends kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,mc);g(this,gc,null);g(this,aa,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?j.HIGHLIGHT:j.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:n,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:h}=m(this,mc,xf).call(this,s,e),c=this.svgFactory.create(l,h,!0),d=f(this,gc,this.svgFactory.createElement("svg:g"));c.append(d),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",o);for(let p=0,b=n.length;p<b;p++){const y=this.svgFactory.createElement(this.svgElementName);i(this,aa).push(y),y.setAttribute("points",n[p].join(",")),d.append(y)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:n,rect:r}=e,a=i(this,gc);if(s>=0&&a.setAttribute("stroke-width",s||1),n)for(let o=0,l=i(this,aa).length;o<l;o++)i(this,aa)[o].setAttribute("points",n[o].join(","));if(r){const{transform:o,width:l,height:h}=m(this,mc,xf).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return i(this,aa)}addHighlightArea(){this.container.classList.add("highlightArea")}}gc=new WeakMap,aa=new WeakMap,mc=new WeakSet,xf=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class vm extends kt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=j.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}
4class VA extends kt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class WA extends kt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class XA extends kt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class _m extends kt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=j.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var bc,Ac,Tf;class qA extends kt{constructor(e){var n;super(e,{isRenderable:!0});g(this,Ac);g(this,bc,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(n=this.linkService.eventBus)==null||n.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let n;s.hasAppearance||s.fillAlpha===0?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),n.addEventListener("dblclick",m(this,Ac,Tf).bind(this)),f(this,bc,n);const{isMac:r}=ee.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&m(this,Ac,Tf).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return i(this,bc)}addHighlightArea(){this.container.classList.add("highlightArea")}}bc=new WeakMap,Ac=new WeakSet,Tf=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var Ko,oa,Qo,Vn,yc,la,hr,Pf,kf;const yp=class yp{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:n,page:r,viewport:
4a,structTreeLayer:o,commentManager:l,linkService:h,annotationStorage:c}){g(this,hr);g(this,Ko,null);g(this,oa,null);g(this,Qo,null);g(this,Vn,new Map);g(this,yc,null);g(this,la,null);this.div=t,f(this,Ko,e),f(this,oa,s),f(this,yc,o||null),f(this,la,h||null),f(this,Qo,c||new ap),this.page=r,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=n,this._commentManager=l||null}hasEditableAnnotations(){return i(this,Vn).size>0}async render(t){var a,o,l;const{annotations:e}=t,s=this.div;ar(s,this.viewport);const n=new Map,r={data:null,layer:s,linkService:i(this,la),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new ih,annotationStorage:i(this,Qo),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const h of e){if(h.noHTML)continue;const c=h.annotationType===It.POPUP;if(c){const b=n.get(h.id);if(!b)continue;r.elements=b}else if(h.rect[2]===h.rect[0]||h.rect[3]===h.rect[1])continue;r.data=h;const d=qp.create(r);if(!d.isRenderable)continue;if(!c&&h.popupRef){const b=n.get(h.popupRef);b?b.push(d):n.set(h.popupRef,[d])}const p=d.render();h.hidden&&(p.style.visibility="hidden"),await m(this,hr,Pf).call(this,p,h.id,r.elements),(o=(a=d.extraPopupElement)==null?void 0:a.popup)==null||o.renderCommentButton(),d._isEditable&&(i(this,Vn).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}m(this,hr,kf).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:i(this,la),svgFactory:new ih,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=yp._defaultBorderStyle),e.data=s;const n=qp.create(e);if(!n.isRenderable)continue;const r=n.render();await m(this,hr,Pf).call(this,r,s.id,null)}}update({viewport:t}){const e=this.div;this.viewport=t,ar(e,{rotation:t.rotation}),m(this,hr,kf).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(i(this,Vn).values())}getEditableAnnotation(t){return i(this,Vn).get(t)}addFakeAnnotation(t){var o;const{div:e}=this,{id:s,rotation:n}=t,r=new RA({data:{id:s,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:i(this,la),annotationStorage:i(this,Qo)}),a=r.render();return e.append(a),(o=i(this,Ko))==null||o.moveElementInDOM(e,a,a,!1),r.createOrUpdatePopup(),r}static get _defaultBorderStyle(){return Y(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:La.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};Ko=new WeakMap,oa=new WeakMap,Qo=new WeakMap,Vn=new WeakMap,yc=new WeakMap,la=new WeakMap,hr=new WeakSet,Pf=async function(t,e,s){var o,l;const n=t.firstChild||t,r=n.id=`${ip}${e}`,a=await((o=i(this,yc))==null?void 0:o.getAriaAttributes(r));if(a)for(const[h,c]of a)n.setAttribute(h,c);s?s.at(-1).container.after(t):(this.div.append(t),(l=i(this,Ko))==null||l.moveElementInDOM(this.div,t,n,!1))},kf=function(){var e;if(!i(this,oa))return;const t=this.div;for(const[s,n]of i(this,oa)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;n.className="annotationContent";const{firstChild:a}=r;a?a.nodeName==="CANVAS"?a.replaceWith(n):a.classList.contains("annotationContent")?a.after(n):a.before(n):r.append(n);const o=i(this,Vn).get(s);o&&(o._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,n),o._hasNoCanvas=!1):o.canvas=n)}i(this,oa).clear()};let Ud=yp;const Zc=/\r\n?|\n/g;var We,wc,ha,Xe,$t,Sm,Em,Cm,Ad,an,yd,wd,xm,Df,Tm;const _t=class _t extends vt{constructor(e){super({...e,name:"freeTextEditor"});g(this,$t);g(this,We,"");g(this,wc,`${this.id}-editor`);g(this,ha,null);g(this,Xe);P(this,"_colorPicker",null);this.color=e.color||_t._defaultColor||vt._defaultLineColor,f(this,Xe,e.fontSize||_t._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=_t.prototype,s=a=>a.isEmpty(),n=or.TRANSLATE_SMALL,r=or.TRANSLATE_BIG;return Y(this,"_keyboardManager",new zc([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){vt.initialize(e,s);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}
4static updateDefaultParams(e,s){switch(e){case Z.FREETEXT_SIZE:_t._defaultFontSize=s;break;case Z.FREETEXT_COLOR:_t._defaultColor=s;break}}updateParams(e,s){switch(e){case Z.FREETEXT_SIZE:m(this,$t,Sm).call(this,s);break;case Z.FREETEXT_COLOR:m(this,$t,Em).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Z.FREETEXT_SIZE,_t._defaultFontSize],[Z.FREETEXT_COLOR,_t._defaultColor||vt._defaultLineColor]]}get propertiesToUpdate(){return[[Z.FREETEXT_SIZE,i(this,Xe)],[Z.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Hd(this)),[["colorPicker",this._colorPicker]]}get colorType(){return Z.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-_t._internalPadding*e,-(_t._internalPadding+i(this,Xe))*e]}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"),f(this,ha,new AbortController);const e=this._uiManager.combinedSignal(i(this,ha));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",i(this,wc)),this._isDraggable=!0,(e=i(this,ha))==null||e.abort(),f(this,ha,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=i(this,We),s=f(this,We,m(this,$t,Cm).call(this).trimEnd());if(e===s)return;const n=r=>{if(f(this,We,r),!r){this.remove();return}m(this,$t,wd).call(this),this._uiManager.rebuild(this),m(this,$t,Ad).call(this)};this.addCommands({cmd:()=>{n(s)},undo:()=>{n(e)},mustExec:!1}),m(this,$t,Ad).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){_t._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,s;(this._isCopy||this.annotationElementId)&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",i(this,wc)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${i(this,Xe)}px * var(--total-scale-factor))`,n.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){const[r,a]=this.parentDimensions;
4if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[c,d]=this.pageDimensions,[p,b]=this.pageTranslation;let y,A;switch(this.rotation){case 0:y=e+(o[0]-p)/c,A=s+this.height-(o[1]-b)/d;break;case 90:y=e+(o[0]-p)/c,A=s-(o[1]-b)/d,[l,h]=[h,-l];break;case 180:y=e-this.width+(o[0]-p)/c,A=s-(o[1]-b)/d,[l,h]=[-l,-h];break;case 270:y=e+(o[0]-p-this.height*d)/c,A=s+(o[1]-b-this.width*c)/d,[l,h]=[-h,l];break}this.setAt(y*r,A*a,l,h)}else this._moveAfterPaste(e,s);m(this,$t,wd).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var y,A,v;const s=e.clipboardData||window.clipboardData,{types:n}=s;if(n.length===1&&n[0]==="text/plain")return;e.preventDefault();const r=m(y=_t,an,Df).call(y,s.getData("text")||"").replaceAll(Zc,` 5`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(` 6`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,c=[],d=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(d.push(l.nodeValue.slice(h).replaceAll(Zc,"")),w!==this.editorDiv){let S=c;for(const _ of this.editorDiv.childNodes){if(_===w){S=d;continue}S.push(m(A=_t,an,yd).call(A,_))}}c.push(l.nodeValue.slice(0,h).replaceAll(Zc,""))}else if(l===this.editorDiv){let w=c,S=0;for(const _ of this.editorDiv.childNodes)S++===h&&(w=d),w.push(m(v=_t,an,yd).call(v,_))}f(this,We,`${c.join(` 7`)}${r}${d.join(` 8`)}`),m(this,$t,wd).call(this);const p=new Range;let b=Math.sumPrecise(c.map(w=>w.length));for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const S=w.nodeValue.length;if(b<=S){p.setStart(w,b),p.setEnd(w,b);break}b-=S}a.removeAllRanges(),a.addRange(p)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=_t._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,n){var o;let r=null;if(e instanceof ym){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:d,id:p,popupRef:b,richText:y,contentsObj:A,creationDate:v,modificationDate:w},textContent:S,textPosition:_,parent:{page:{pageNumber:E}}}=e;if(!S||S.length===0)return null;r=e={annotationType:j.FREETEXT,color:Array.from(h),fontSize:l,value:S.join(` 9`),position:_,pageIndex:E-1,rect:c.slice(0),rotation:d,annotationElementId:p,id:p,deleted:!1,popupRef:b,comment:(A==null?void 0:A.str)||null,richText:y,creationDate:v,modificationDate:w}}const a=await super.deserialize(e,s,n);return f(a,Xe,e.fontSize),a.color=N.makeHexColor(...e.color),f(a,We,m(o=_t,an,Df).call(o,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=vt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:s,fontSize:i(this,Xe),value:m(this,$t,xm).call(this)});return this.addComment(n),e?(n.isCopy=!0,n):this.annotationElementId&&!m(this,$t,Tm).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:n}=s;n.fontSize=`calc(${i(this,Xe)}px * var(--total-scale-factor))`,n.color=this.color,s.replaceChildren();for(const r of i(this,We).split(` 10`)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:i(this,We)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};We=new WeakMap,wc=new WeakMap,ha=new WeakMap,Xe=new WeakMap,$t=new WeakSet,Sm=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-i(this,Xe))*this.parentScale),f(this,Xe,r),m(this,$t,Ad).call(this)},n=i(this,Xe);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Z.FREETEXT_S
10IZE,overwriteIfSameType:!0,keepUndo:!0})},Em=function(e){const s=r=>{this.color=r,this.onUpdatedColor()},n=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Z.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Cm=function(){var n;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(m(n=_t,an,yd).call(n,r)),s=r);return e.join(` 11`)},Ad=function(){const[e,s]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),n=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=n.width/e,this.height=n.height/s):(this.width=n.height/e,this.height=n.width/s),this.fixAndSetPosition()},an=new WeakSet,yd=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Zc,"")},wd=function(){if(this.editorDiv.replaceChildren(),!!i(this,We))for(const e of i(this,We).split(` 12`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},xm=function(){return i(this,We).replaceAll("Â "," ")},Df=function(e){return e.replaceAll(" ","Â ")},Tm=function(e){const{value:s,fontSize:n,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==n||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},g(_t,an),P(_t,"_freeTextDefaultContent",""),P(_t,"_internalPadding",0),P(_t,"_defaultColor",null),P(_t,"_defaultFontSize",10),P(_t,"_type","freetext"),P(_t,"_editorType",j.FREETEXT);let Mf=_t;class F{toSVGPath(){At("Abstract method `toSVGPath` must be implemented.")}get box(){At("Abstract getter `box` must be implemented.")}serialize(t,e){At("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,n,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*n,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,n,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*n,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,n){n||(n=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)n[r]=e+t[r],n[r+1]=s+t[r+1];return n}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,n,r){switch(r){case 90:return[1-e/s,t/n];case 180:return[1-t/s,1-e/n];case 270:return[e/s,1-t/n];default:return[t/s,e/n]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,n,r,a){return[(t+5*s)/6,(e+5*n)/6,(5*s+r)/6,(5*n+a)/6,(s+r)/2,(n+a)/2]}}P(F,"PRECISION",1e-4);var qe,Ls,Jo,Zo,oi,J,ca,da,vc,_c,tl,el,Wn,Sc,au,ou,Xt,Vl,Pm,km,Mm,Dm,Rm,Lm;const _i=class _i{constructor({x:t,y:e},s,n,r,a,o=0){g(this,Xt);g(this,qe);g(this,Ls,[]);g(this,Jo);g(this,Zo);g(this,oi,[]);g(this,J,new Float32Array(18));g(this,ca);g(this,da);g(this,vc);g(this,_c);g(this,tl);g(this,el);g(this,Wn,[]);f(this,qe,s),f(this,el,r*n),f(this,Zo,a),i(this,J).set([NaN,NaN,NaN,NaN,t,e],6),f(this,Jo,o),f(this,_c,i(_i,Sc)*n),f(this,vc,i(_i,ou)*n),f(this,tl,n),i(this,Wn).push(t,e)}isEmpty(){return isNaN(i(this,J)[8])}add({x:t,y:e}){var M;f(this,ca,t),f(this,da,e);const[s,n,r,a]=i(this,qe);let[o,l,h,c]=i(this,J).subarray(8,12);const d=t-h,p=e-c,b=Math.hypot(d,p);if(b<i(this,vc))return!1;const y=b-i(this,_c),A=y/b,v=A*d,w=A*p;let S=o,_=l;o=h,l=c,h+=v,c+=w,(M=i(this,Wn))==null||M.push(t,e);const E=-w/y,C=v/y,x=E*i(this,el),T=C*i(this,el);return i(this,J).set(i(this,J).subarray(2,8),0),i(this,J).set([h+x,c+T],4),i(this,J).set(i(this,J).subarray(14,18),12),i(this,J).set([h-x,c-T],16),isNaN(i(this,J)[6])?(i(this,oi).length===0&&(i(this,J).set([o+x,l+T],2),i(this,oi).push(NaN,NaN,NaN,NaN,(o+x-s)/r,(l+T-n)/a),i(this,J).set([o-x,l-T],14),i(this,Ls).push(NaN,NaN,NaN,NaN,(o-x-s)/r,(l-T-n)/a)),i(this,J).set([S,_,o,l,h,c],6),!this.isEmpty()):(i(this,J).set([S,_,o,l,h,c],6),Math.abs(Math.atan2(_-l,S-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=i(this,J).subarray(2,6),i(this,oi).push(NaN,NaN,NaN,NaN,((o+
12h)/2-s)/r,((l+c)/2-n)/a),[o,l,S,_]=i(this,J).subarray(14,18),i(this,Ls).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((_+l)/2-n)/a),!0):([S,_,o,l,h,c]=i(this,J).subarray(0,6),i(this,oi).push(((S+5*o)/6-s)/r,((_+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),[h,c,o,l,S,_]=i(this,J).subarray(12,18),i(this,Ls).push(((S+5*o)/6-s)/r,((_+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=i(this,oi),e=i(this,Ls);if(isNaN(i(this,J)[6])&&!this.isEmpty())return m(this,Xt,Pm).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let n=6;n<t.length;n+=6)isNaN(t[n])?s.push(`L${t[n+4]} ${t[n+5]}`):s.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);m(this,Xt,Mm).call(this,s);for(let n=e.length-6;n>=6;n-=6)isNaN(e[n])?s.push(`L${e[n+4]} ${e[n+5]}`):s.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);return m(this,Xt,km).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,n,r,a){return new Im(t,e,s,n,r,a)}getOutlines(){var d;const t=i(this,oi),e=i(this,Ls),s=i(this,J),[n,r,a,o]=i(this,qe),l=new Float32Array((((d=i(this,Wn))==null?void 0:d.length)??0)+2);for(let p=0,b=l.length-2;p<b;p+=2)l[p]=(i(this,Wn)[p]-n)/a,l[p+1]=(i(this,Wn)[p+1]-r)/o;if(l[l.length-2]=(i(this,ca)-n)/a,l[l.length-1]=(i(this,da)-r)/o,isNaN(s[6])&&!this.isEmpty())return m(this,Xt,Dm).call(this,l);const h=new Float32Array(i(this,oi).length+24+i(this,Ls).length);let c=t.length;for(let p=0;p<c;p+=2){if(isNaN(t[p])){h[p]=h[p+1]=NaN;continue}h[p]=t[p],h[p+1]=t[p+1]}c=m(this,Xt,Lm).call(this,h,c);for(let p=e.length-6;p>=6;p-=6)for(let b=0;b<6;b+=2){if(isNaN(e[p+b])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[p+b],h[c+1]=e[p+b+1],c+=2}return m(this,Xt,Rm).call(this,h,c),this.newFreeDrawOutline(h,l,i(this,qe),i(this,tl),i(this,Jo),i(this,Zo))}};qe=new WeakMap,Ls=new WeakMap,Jo=new WeakMap,Zo=new WeakMap,oi=new WeakMap,J=new WeakMap,ca=new WeakMap,da=new WeakMap,vc=new WeakMap,_c=new WeakMap,tl=new WeakMap,el=new WeakMap,Wn=new WeakMap,Sc=new WeakMap,au=new WeakMap,ou=new WeakMap,Xt=new WeakSet,Vl=function(){const t=i(this,J).subarray(4,6),e=i(this,J).subarray(16,18),[s,n,r,a]=i(this,qe);return[(i(this,ca)+(t[0]-e[0])/2-s)/r,(i(this,da)+(t[1]-e[1])/2-n)/a,(i(this,ca)+(e[0]-t[0])/2-s)/r,(i(this,da)+(e[1]-t[1])/2-n)/a]},Pm=function(){const[t,e,s,n]=i(this,qe),[r,a,o,l]=m(this,Xt,Vl).call(this);return`M${(i(this,J)[2]-t)/s} ${(i(this,J)[3]-e)/n} L${(i(this,J)[4]-t)/s} ${(i(this,J)[5]-e)/n} L${r} ${a} L${o} ${l} L${(i(this,J)[16]-t)/s} ${(i(this,J)[17]-e)/n} L${(i(this,J)[14]-t)/s} ${(i(this,J)[15]-e)/n} Z`},km=function(t){const e=i(this,Ls);t.push(`L${e[4]} ${e[5]} Z`)},Mm=function(t){const[e,s,n,r]=i(this,qe),a=i(this,J).subarray(4,6),o=i(this,J).subarray(16,18),[l,h,c,d]=m(this,Xt,Vl).call(this);t.push(`L${(a[0]-e)/n} ${(a[1]-s)/r} L${l} ${h} L${c} ${d} L${(o[0]-e)/n} ${(o[1]-s)/r}`)},Dm=function(t){const e=i(this,J),[s,n,r,a]=i(this,qe),[o,l,h,c]=m(this,Xt,Vl).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-n)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-n)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-n)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-n)/a],0),this.newFreeDrawOutline(d,t,i(this,qe),i(this,tl),i(this,Jo),i(this,Zo))},Rm=function(t,e){const s=i(this,Ls);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Lm=function(t,e){const s=i(this,J).subarray(4,6),n=i(this,J).subarray(16,18),[r,a,o,l]=i(this,qe),[h,c,d,p]=m(this,Xt,Vl).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,d,p,NaN,NaN,NaN,NaN,(n[0]-r)/o,(n[1]-a)/l],e),e+=24},g(_i,Sc,8),g(_i,au,2),g(_i,ou,i(_i,Sc)+i(_i,au));let $d=_i;var sl,ua,Ki,Ec,Ye,Cc,Nt,lu,Fm;class Im extends F{constructor(e,s,n,r,a,o){super();g(this,lu);g(this,sl);g(this,ua,new Float32Array(4));g(this,Ki);g(this,Ec);g(this,Ye);g(this,Cc);g(this,Nt);f(this,Nt,e),f(this,Ye,s),f(this,sl,n),f(this,Cc,r),f(this,Ki,a),f(this,Ec,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],m(this,lu,Fm).call(this,o);const[l,h,c,d]=i(this,ua);for(let p=0,b=e.length;p<b;p+=2)e[p]=(e[p]-l)/c,e[p+1]=(e[p+1]-h)/d;for(let p=0,b=s.length;p<b;p+=2)s[p]=(s[p]-l)/c,s[p+1]=(s[p+1]-h)/d}toSVGPath(){const e=[`M${i(this,Nt)[4]} ${i(this,Nt)[5]}`];for(let s=6,n=i(this,Nt).length;s<n;s+=6){if(isNaN(i(this,Nt)[s])){e.push(`L${i(this,Nt)[s+4]} ${i(this,Nt)[s+5]}`);continue}e.push(`C${i(this,Nt)[s]} ${i(this,Nt)[s+1]} ${i(this,Nt)[s+2]} ${i(this,Nt)[s+3]} ${i(this,Nt)[s+4]} ${i(this,Nt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,n,r],a){const o=n-e,l=r-s;let h,c;switch(a){case 0:h=F._rescale(i(this,Nt),e,r,o,-l),c=F._rescale(i(this,Ye),e,r,o,-l);break;case 90:h=F._rescaleAndSwap(i(this,Nt),e,s,o,l),c=F._rescaleAndSwap(i(this,Ye),e,s,o,l);break;case 180:h=F._rescale(i(this,Nt),n,s,-o,l),c=F._rescale(i(this,Ye),n,s,-o,l);break;case 270:h=F._rescaleAndSwap(i(this,Nt),n,r,-o,-l),c=F._rescaleAndSwap(i(this,Ye),n,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return i(this,ua)}newOutliner(e,s,n,r,a,o=0){return new $d(e,s,n,r,a,o)}getNewOutline(e,s){const[n,r,a,o]=i(this,ua),[l,h,c,d]=i(this,sl),p=a*c,b=o*d,y=n*c+l,A=r*d+h,v=this.newOutliner({x:i(this,Ye)[0]*p+y,y:i(this,Ye)[1]*b+A},i(this,sl),i(this,Cc),e,i(this,Ec),s??i(this,Ki));for(let w=2;w<i(this,Ye).length;w+=2)v.add({x:i(this,Ye)[w]*p+y,y:i(this,Ye)[w+1]*b+A});return v.getOutlines()}}sl=new WeakMap,ua=new WeakMap,Ki=new WeakMap,Ec=new WeakMap,Ye=new WeakMap,Cc=new WeakMap,Nt=ne
12w WeakMap,lu=new WeakSet,Fm=function(e){const s=i(this,Nt);let n=s[4],r=s[5];const a=[n,r,n,r];let o=n,l=r,h=n,c=r;const d=e?Math.max:Math.min,p=new Float32Array(4);for(let y=6,A=s.length;y<A;y+=6){const v=s[y+4],w=s[y+5];isNaN(s[y])?(N.pointBoundingBox(v,w,a),l>w?(o=v,l=w):l===w&&(o=d(o,v)),c<w?(h=v,c=w):c===w&&(h=d(h,v))):(p[0]=p[1]=1/0,p[2]=p[3]=-1/0,N.bezierBoundingBox(n,r,...s.slice(y,y+6),p),N.rectBoundingBox(p[0],p[1],p[2],p[3],a),l>p[1]?(o=p[0],l=p[1]):l===p[1]&&(o=d(o,p[0])),c<p[3]?(h=p[2],c=p[3]):c===p[3]&&(h=d(h,p[2]))),n=v,r=w}const b=i(this,ua);b[0]=a[0]-i(this,Ki),b[1]=a[1]-i(this,Ki),b[2]=a[2]-a[0]+2*i(this,Ki),b[3]=a[3]-a[1]+2*i(this,Ki),this.firstPoint=[o,l],this.lastPoint=[h,c]};var xc,Tc,Pc,Xn,Is,xe,Nm,vd,Om,Bm,Lf;class Rf{constructor(t,e=0,s=0,n=!0){g(this,xe);g(this,xc);g(this,Tc);g(this,Pc);g(this,Xn,[]);g(this,Is,[]);const r=[1/0,1/0,-1/0,-1/0],a=10**-4;for(const{x:A,y:v,width:w,height:S}of t){const _=Math.floor((A-e)/a)*a,E=Math.ceil((A+w+e)/a)*a,C=Math.floor((v-e)/a)*a,x=Math.ceil((v+S+e)/a)*a,T=[_,C,x,!0],k=[E,C,x,!1];i(this,Xn).push(T,k),N.rectBoundingBox(_,C,E,x,r)}const o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,h=r[0]-s,c=r[1]-s;let d=n?-1/0:1/0,p=1/0;const b=i(this,Xn).at(n?-1:-2),y=[b[0],b[2]];for(const A of i(this,Xn)){const[v,w,S,_]=A;
12!_&&n?w<p?(p=w,d=v):w===p&&(d=Math.max(d,v)):_&&!n&&(w<p?(p=w,d=v):w===p&&(d=Math.min(d,v))),A[0]=(v-h)/o,A[1]=(w-c)/l,A[2]=(S-c)/l}f(this,xc,new Float32Array([h,c,o,l])),f(this,Tc,[d,p]),f(this,Pc,y)}getOutlines(){i(this,Xn).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of i(this,Xn))e[3]?(t.push(...m(this,xe,Lf).call(this,e)),m(this,xe,Om).call(this,e)):(m(this,xe,Bm).call(this,e),t.push(...m(this,xe,Lf).call(this,e)));return m(this,xe,Nm).call(this,t)}}xc=new WeakMap,Tc=new WeakMap,Pc=new WeakMap,Xn=new WeakMap,Is=new WeakMap,xe=new WeakSet,Nm=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],h=e[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const n=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,d]=a;s.delete(a);let p=o,b=l;for(r=[o,h],n.push(r);;){let y;if(s.has(c))y=c;else if(s.has(d))y=d;else break;s.delete(y),[o,l,h,c,d]=y,p!==o&&(r.push(p,b,o,b===l?l:h),p=o),b=b===l?h:l}r.push(p,b)}return new YA(n,i(this,xc),i(this,Tc),i(this,Pc))},vd=function(t){const e=i(this,Is);let s=0,n=e.length-1;for(;s<=n;){const r=s+n>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:n=r-1}return n+1},Om=function([,t,e]){const s=m(this,xe,vd).call(this,t);i(this,Is).splice(s,0,[t,e])},Bm=function([,t,e]){const s=m(this,xe,vd).call(this,t);for(let n=s;n<i(this,Is).length;n++){const[r,a]=i(this,Is)[n];if(r!==t)break;if(r===t&&a===e){i(this,Is).splice(n,1);return}}for(let n=s-1;n>=0;n--){const[r,a]=i(this,Is)[n];if(r!==t)break;if(r===t&&a===e){i(this,Is).splice(n,1);return}}},Lf=function(t){const[e,s,n]=t,r=[[e,s,n]],a=m(this,xe,vd).call(this,n);for(let o=0;o<a;o++){const[l,h]=i(this,Is)[o];for(let c=0,d=r.length;c<d;c++){const[,p,b]=r[c];if(!(h<=p||b<=l)){if(p>=l){if(b>h)r[c][1]=h;else{if(d===1)return[];r.splice(c,1),c--,d--}continue}r[c][2]=l,b>h&&r.push([e,h,b])}}}return r};var kc,il;class YA extends F{constructor(e,s,n,r){super();g(this,kc);g(this,il);f(this,il,e),f(this,kc,s),this.firstPoint=n,this.lastPoint=r}toSVGPath(){const e=[];for(const s of i(this,il)){let[n,r]=s;e.push(`M${n} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===n?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),n=o)}e.push("Z")}return e.join(" ")}serialize([e,s,n,r],a){const o=[],l=n-e,h=r-s;for(const c of i(this,il)){const d=new Array(c.length);for(let p=0;p<c.length;p+=2)d[p]=e+c[p]*l,d[p+1]=r-c[p+1]*h;o.push(d)}return o}get box(){return i(this,kc)}get classNamesForOutlining(){return["highlightOutline"]}}kc=new WeakMap,il=new WeakMap;class If extends $d{newFreeDrawOutline(t,e,s,n,r,a){return new KA(t,e,s,n,r,a)}}class KA extends Im{newOutliner(t,e,s,n,r,a=0){return new If(t,e,s,n,r,a)}}var nl,Mc,Qi,fa,Dc,Ie,Rc,Lc,pa,Ke,Qe,ae,rl,al,be,ol,As,Ic,K,Ff,_d,Hm,Um,$m,Nf,fr,ws,Ha,zm,Sd,Ed,Gm,jm,Vm,Wm,Xm;const nt=class nt extends vt{constructor(e){super({...e,name:"highlightEditor"});g(this,K);g(this,nl,null);g(this,Mc,0);g(this,Qi);g(this,fa,null);g(this,Dc,null);g(this,Ie,null);g(this,Rc,null);g(this,Lc,0);g(this,pa,null);g(this,Ke,null);g(this,Qe,null);g(this,ae,!1);g(this,rl,null);g(this,al,null);g(this,be,null);g(this,ol,"");g(this,As);g(this,Ic,"");this.color=e.color||nt._defaultColor,f(this,As,e.thickness||nt._defaultThickness),this.opacity=e.opacity||nt._defaultOpacity,f(this,Qi,e.boxes||null),f(this,Ic,e.methodOfCreation||""),f(this,ol,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(f(this,ae,!0),m(this,K,_d).call(this,e),m(this,K,fr).call(this)):i(this,Qi)&&(f(this,nl,e.anchorNode),f(this,Mc,e.anchorOffset),f(this,Rc,e.focusNode),f(this,Lc,e.focusOffset),m(this,K,Ff).call(this),m(this,K,fr).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=nt.prototype;return Y(this,"_keyboardManager",new zc([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:i(this,ae)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:i(this,As),methodOfCreation:i(this,Ic)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("
12color").size}}static initialize(e,s){var n;vt.initialize(e,s),nt._defaultColor||(nt._defaultColor=((n=s.highlightColors)==null?void 0:n.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case Z.HIGHLIGHT_COLOR:nt._defaultColor=s;break;case Z.HIGHLIGHT_THICKNESS:nt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return i(this,al)}get commentButtonPosition(){return i(this,rl)}updateParams(e,s){switch(e){case Z.HIGHLIGHT_COLOR:m(this,K,Hm).call(this,s);break;case Z.HIGHLIGHT_THICKNESS:m(this,K,Um).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Z.HIGHLIGHT_COLOR,nt._defaultColor],[Z.HIGHLIGHT_THICKNESS,nt._defaultThickness]]}get propertiesToUpdate(){return[[Z.HIGHLIGHT_COLOR,this.color||nt._defaultColor],[Z.HIGHLIGHT_THICKNESS,i(this,As)||nt._defaultThickness],[Z.HIGHLIGHT_FREE,i(this,ae)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(i(this,Qe),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=i(this,Dc))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",f(this,Dc,new sh({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(m(this,K,Ed).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,m(this,K,Ed).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){m(this,K,Nf).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,K,fr).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let s=!1;this.parent&&!e?m(this,K,Nf).call(this):e&&(m(this,K,fr).call(this,e),s=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let n;i(this,ae)?(e=(e-this.rotation+360)%360,n=m(r=nt,ws,Ha).call(r,i(this,Ke).box,e)):n=m(a=nt,ws,Ha).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(i(this,Qe),{bbox:n,root:{"data-main-rotation":e}}),s.updateProperties(i(this,be),{bbox:m(o=nt,ws,Ha).call(o,i(this,Ie).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();i(this,ol)&&(e.setAttribute("aria-label",i(this,ol)),e.setAttribute("role","mark")),i(this,ae)?e.classList.add("free"):this.div.addEventListener("keydown",m(this,K,zm).bind(this),{signal:this._uiManager._signal});const s=f(this,pa,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=i(this,fa),this.setDims(this.width,this.height),ug(this,i(this,pa),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(i(this,be),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(i(this,be),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:m(this,K,Sd).call(this,!0);break;case 1:case 3:m(this,K,Sd).call(this,!1);break}}select(){var e;super.select(),i(this,be)&&((e=this.parent)==null||e.drawLayer.updateProperties(i(this,be),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),i(this,be)&&((e=this.parent)==null||e.drawLayer.updateProperties(i(this,be),{rootClass:{selected:!1}}),i(this,ae)||m(this,K,Sd).call(this,!1))}get _mustFixPosition(){return!i(this,ae)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(i(this,Qe),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(i(this,be),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:n,x:r,y:a}){const{x:o,y:l,width:h,height:c}=n.getBoundingClientRect(),d=new AbortController,p=e.combinedSignal(d),b=y=>{d.abort(),m(this,ws,Wm).call(this,e,y)};window.addEventListener("blur",b,{signal:p}),window.addEventListener("pointerup",b,{signal:p}),window.addEventListener("pointerdown",Pt,{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",rs,{signal:p}),n.addEventListener("pointermove",m(this,ws,Vm).bind(this,e),{signal:p}),this._freeHighlight=new If({x:r,y:a},[o,l,h,c],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,s,n){var A,v,w,S;let r=null;if(e instanceof vm){const{data:{quadPoints:_,rect:E,rotation:C,id:x,color:T,opacity:k,popupRef:M,richText:I,contentsObj:R,creationDate:H,modificationDate:q},parent:{page:{pageNumber:G}}}=e;r=e={annotationType:j.HIGHLIGHT,color:Array.from(T),opacity:k,quadPoints:_,boxes:null,pageIndex:G-1,rect:E.slice(0),rotation:C,annotationElementId:x,id:x,deleted:!1,popupRef:M,richText:I,comment:(R==null?void 0:R.str)||null,creationDate:H,modificationDate:q}}else if(e instanceof dp){const{data:{inkLists:_,rect:E,rotation:C,id:x,color:T,borderStyle:{rawWidth:k},popupRef:M,richText:I,contentsObj:R,creationDate:H,modificationDate:q},parent:{page:{pageNumber:G}}}=e;r=e={annotationType:j.HIGHLIGHT,color:Array.from(T),thickness:k,inkLists:_,boxes:null,pageIndex:G-1,rect:E.slice(0),rotation:C,annotationElementId:x,id:x,deleted:!1,popupRef:M,richText:I,comment:(R==null?void 0:R.str)||null,creationDate:H,modificationDate:q}}const{color:a,quadPoints:o,inkLists:l,opacity:h}=e,c=await super.deserialize(e,s,n);c.color=N.makeHexColor(...a),c.opacity=h||1,l&&f(c,As,e.thickness),c._initialData=r,e.comment&&c.setCommentData(e);const[d,p]=c.pageDimensions,[b,y]=c.pageTranslation;if(o){const _=f(c,Qi,[]);for(let E=0;E<o.length;E+=8)_.push({x:(o[E]-b)/d,y:1-(o[E+1]-y)/p,width:(o[E+2]-o[E])/d,height:(o[E+1]-o[E+5])/p});m(A=c,K,Ff).call(A),m(v=c,K,fr).call(v),c.rotate(c.rotation)}else if(l){f(c,ae,!0);const _=l[0],E={x:_[0]-b,y:p-(_[1]-y)},C=new If(E,[0,0,d,p],1,i(c,As)/2,!0,.001);for(let k=0,M=_.length;k<M;k+=2)E.x=_[k]-b,E.y=p-(_[k+1]-y),C.add(E);const{id:x,clipPathId:T}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);m(w=c,K,_d).call(w,{highlightOutlines:C.getOutlines(),highlightId:x,clipPathId:T}),m(S=c,K,fr).call(S),c.rotate(c.parentRotation)}return c}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=vt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:s,opacity:this.opacity,thickness:i(this,As),quadPoints:m(this,K,Gm).call(this),outlines:m(this,K,jm).call(this,n.rect)}
12),this.addComment(n),this.annotationElementId&&!m(this,K,Xm).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};nl=new WeakMap,Mc=new WeakMap,Qi=new WeakMap,fa=new WeakMap,Dc=new WeakMap,Ie=new WeakMap,Rc=new WeakMap,Lc=new WeakMap,pa=new WeakMap,Ke=new WeakMap,Qe=new WeakMap,ae=new WeakMap,rl=new WeakMap,al=new WeakMap,be=new WeakMap,ol=new WeakMap,As=new WeakMap,Ic=new WeakMap,K=new WeakSet,Ff=function(){const e=new Rf(i(this,Qi),.001);f(this,Ke,e.getOutlines()),[this.x,this.y,this.width,this.height]=i(this,Ke).box;const s=new Rf(i(this,Qi),.0025,.001,this._uiManager.direction==="ltr");f(this,Ie,s.getOutlines());const{firstPoint:n}=i(this,Ke);f(this,rl,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]);const{lastPoint:r}=i(this,Ie);f(this,al,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},_d=function({highlightOutlines:e,highlightId:s,clipPathId:n}){var p,b;if(f(this,Ke,e),f(this,Ie,e.getNewOutline(i(this,As)/2+1.5,.0025)),s>=0)f(this,Qe,s),f(this,fa,n),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),f(this,be,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:i(this,Ie).box,path:{d:i(this,Ie).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(i(this,Qe),{bbox:m(p=nt,ws,Ha).call(p,i(this,Ke).box,(y-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(i(this,be),{bbox:m(b=nt,ws,Ha).call(b,i(this,Ie).box,y),path:{d:i(this,Ie).toSVGPath()}})}const[a,o,l,h]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[y,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/y,this.height=h*y/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[y,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/y,this.height=h*y/A;break}}const{firstPoint:c}=e;f(this,rl,[(c[0]-a)/l,(c[1]-o)/h]);const{lastPoint:d}=i(this,Ie);f(this,al,[(d[0]-a)/l,(d[1]-o)/h])},Hm=function(e){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,e,nt._defaultOpacity),undo:s.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Z.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},Um=function(e){const s=i(this,As),n=r=>{f(this,As,r),m(this,K,$m).call(this,r)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Z.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},$m=function(e){i(this,ae)&&(m(this,K,_d).call(this,{highlightOutlines:i(this,Ke).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))},Nf=function(){i(this,Qe)===null||!this.parent||(this.parent.drawLayer.remove(i(this,Qe)),f(this,Qe,null),this.parent.drawLayer.remove(i(this,be)),f(this,be,null))},fr=function(e=this.parent){i(this,Qe)===null&&({id:zt(this,Qe)._,clipPathId:zt(this,fa)._}=e.drawLayer.draw({bbox:i(this,Ke).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:i(this,ae)},path:{d:i(this,Ke).toSVGPath()}},!1,!0),f(this,be,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:i(this,ae)},bbox:i(this,Ie).box,path:{d:i(this,Ie).toSVGPath()}},i(this,ae))),i(this,pa)&&(i(this,pa).style.clipPath=i(this,fa)))},ws=new WeakSet,Ha=function([e,s,n,r],a){switch(a){case 90:return[1-s-r,e,r,n];case 180:return[1-e-n,1-s-r,n,r];case 270:return[s,1-e-n,r,n]}return[e,s,n,r]},zm=function(e){nt._keyboardManager.exec(this,e)},Sd=function(e){if(!i(this,nl))return;const s=window.getSelection();e?s.setPosition(i(this,nl),i(this,Mc)):s.setPosition(i(this,Rc),i(this,Lc))},Ed=function(){return i(this,ae)?this.rotation:0},Gm=function(){if(i(this,ae))return null;const[e,s]=this.pageDimensions,[n,r]=this.pageTranslation,a=i(this,Qi),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:d,height:p}of a){const b=h*e+n,y=(1-c)*s+r;o[l]=o[l+4]=b,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=b+d*e,o[l+5]=o[l+7]=y-p*s,l+=8}return o},jm=function(e){return i(this,Ke).serialize(e,m(this,K,Ed).call(this))},Vm=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Wm=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Xm=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((n,r)=>n!==s[r])},g(nt,ws),P(nt,"_defaultColor",null),P(nt,"_defaultOpacity",1),P(nt,"_defaultThickness",12),P(nt,"_type","highlight"),P(nt,"_editorType",j.HIGHLIGHT),P(nt,"_freeHighlightId",-1),P(nt,"_freeHighlight",null),P(nt,"_freeHighlightClipId","");let zd=nt;var ga;class qm{constructor(){g(this,ga,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){i(this,ga)[t]=e}toSVGProperties(){const t=i(this,ga);return f(this,ga,Object.create(null)),{root:t}}reset(){f(this,ga,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){At("Not implemented")}}ga=new WeakMap;var Je,ll,Kt,ma,ba,qn,Yn,Kn,Aa,st,Of,Bf,Hf,Wl,Ym,Cd,Xl,Ua;const O=class O extends vt{constructor(e){super(e);g(this,st);g(this,Je,null);g(this,ll);P(this,"_colorPicker",null);P(this,"_drawId",null);f(this,ll,e.mustBeCommitted||!1),this._addOutlines(e)}
12onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_addOutlines(e){e.drawOutlines&&(m(this,st,Of).call(this,e),m(this,st,Wl).call(this))}static _mergeSVGProperties(e,s){const n=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))n.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){At("Not implemented")}static get typesMap(){At("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,s),this._currentParent&&(i(O,Kt).updateProperty(n,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)e.push([n,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[n,r]of this.constructor.typesMap)e.push([n,s[r]]);return e}_updateProperty(e,s,n){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=i(this,Je).updateProperty(s,l);h&&m(this,st,Xl).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:o.bind(this,n),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,O._mergeSVGProperties(i(this,Je).getPathResizingSVGProperties(m(this,st,Cd).call(this)),{bbox:m(this,st,Ua).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,O._mergeSVGProperties(i(this,Je).getPathResizedSVGProperties(m(this,st,Cd).call(this)),{bbox:m(this,st,Ua).call(this)}))}_onTranslating(e,s){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{bbox:m(this,st,Ua).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,O._mergeSVGProperties(i(this,Je).getPathTranslatedSVGProperties(m(this,st,Cd).call(this),this.parentDimensions),{bbox:m(this,st,Ua).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,i(this,ll)&&(f(this,ll,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){m(this,st,Hf).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,st,Wl).call(this),m(this,st,Xl).call(this,i(this,Je).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),m(this,st,Hf).call(this)):e&&(this._uiManager.addShouldRescale(this),m(this,st,Wl).call(this,e),s=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,O._mergeSVGProperties({bbox:m(this,st,Ua).call(this)},i(this,Je).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&m(this,st,Xl).call(this,i(this,Je).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);const n=super.render();n.classList.add("draw");const r=document.createElement("div");return n.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),n}static createDrawerInstance(e,s,n,r,a){At("Not implemented")}static startDrawing(e,s,n,r){var v;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(i(O,Yn)&&i(O,Yn)!==c)return;const{viewport:{rotation:d}}=e,{width:p,height:b}=a.getBoundingClientRect(),y=f(O,ma,new AbortController),A=e.combinedSignal(y);if(i(O,qn)||f(O,qn,h),i(O,Yn)??f(O,Yn,c),window.addEventListener("pointerup",w=>{var S;i(O,qn)===w.pointerId?this._endDraw(w):(S=i(O,Kn))==null||S.delete(w.pointerId)},{signal:A}),window.addEventListener("pointercancel",w=>{var S;i(O,qn)===w.pointerId?this._currentParent.endDrawingSession():(S=i(O,Kn))==null||S.delete(w.pointerId)},{signal:A}),window.addEventListener("pointerdown",w=>{i(O,Yn)===w.pointerType&&((i(O,Kn)||f(O,Kn,new Set)).add(w.pointerId),i(O,Kt).isCancellable()&&(i(O,Kt).removeLastElement(),i(O,Kt).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:A}),window.addEventListener("contextmenu",rs,{signal:A}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:A}),a.addEventListener("touchmove",w=>{w.timeStamp===i(O,Aa)&&Pt(w)},{signal:A}),e.toggleDrawing(),(v=s._editorUndoBar)==null||v.hide(),i(O,Kt)){e.drawLayer.updateProperties(this._currentDrawId,i(O,Kt).startNew(o,l,p,b,d));return}s.updateUIForDefaultProperties(this),f(O,Kt,this.createDrawerInstance(o,l,p,b,d)),f(O,ba,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(i(O,ba).toSVGProperties(),i(O,Kt).defaultSVGProperties),!0,!1)}static _drawMove(e){var a;if(f(O,Aa,-1),!i(O,Kt))return;const{offsetX:s,offsetY:n,pointerId:r}=e;if(i(O,qn)===r){if(((a=i(O,Kn))==null?void 0:a.size)>=1){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,i(O,Kt).add(s,n)),f(O,Aa,e.timeStamp),Pt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,f(O,Kt,null),f(O,ba,null),f(O,Yn,null),f(O,Aa,NaN)),i(O,ma)&&(i(O,ma).abort(),f(O,ma,null),f(O,qn,NaN),f(O,Kn,null))}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,i(O,Kt).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const n=i(O,Kt),r=this._currentDrawId,a=n.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,n.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,n.removeLastElement())},mustExec:!1,type:Z.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(Z.DRAW_STEP),!i(O,Kt).isEmpty()){const{pageDimensions:[n,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:i(O,Kt).getOutlines(n*a,r*a,a,this._INNER_MARGIN),drawingOptions:i(O,ba),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,n,r,a,o){At("Not implemented")}static async deserialize(e,s,n){var d,p;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),c=await super.deserialize(e,s,n);return c.createDrawingOptions(e),m(d=c,st,Of).call(d,{drawOutlines:h}),m(p=c,st,Wl).call(p),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,n]=this.pageTranslation,[r,a]=this.pageDimensions;return i(this,Je).serialize([s,n,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};
12Je=new WeakMap,ll=new WeakMap,Kt=new WeakMap,ma=new WeakMap,ba=new WeakMap,qn=new WeakMap,Yn=new WeakMap,Kn=new WeakMap,Aa=new WeakMap,st=new WeakSet,Of=function({drawOutlines:e,drawId:s,drawingOptions:n}){f(this,Je,e),this._drawingOptions||(this._drawingOptions=n),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=m(this,st,Bf).call(this,e,this.parent),m(this,st,Xl).call(this,e.box)},Bf=function(e,s){const{id:n}=s.drawLayer.draw(O._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n},Hf=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Wl=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=m(this,st,Bf).call(this,i(this,Je),e)}},Ym=function([e,s,n,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,n*(o/a),r*(a/o)];case 180:return[1-e,1-s,n,r];case 270:return[1-s,e,n*(o/a),r*(a/o)];default:return[e,s,n,r]}},Cd=function(){const{x:e,y:s,width:n,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,n*(a/o),r*(o/a)];case 180:return[1-e,1-s,n,r];case 270:return[s,1-e,n*(a/o),r*(o/a)];default:return[e,s,n,r]}},Xl=function(e){[this.x,this.y,this.width,this.height]=m(this,st,Ym).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Ua=function(){const{x:e,y:s,width:n,height:r,rotation:a,parentRotation:o,parentDimensions:[l,h]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,n];case 2:return[1-e-n,1-s-r,n,r];case 3:return[s,1-e-n,r,n];case 4:return[e,s-n*(l/h),r*(h/l),n*(l/h)];case 5:return[1-s,e,n*(l/h),r*(h/l)];case 6:return[1-e-r*(h/l),1-s,r*(h/l),n*(l/h)];case 7:return[s-n*(l/h),1-e-r*(h/l),n*(l/h),r*(h/l)];case 8:return[e-n,s-r,n,r];case 9:return[1-s,e-n,r,n];case 10:return[1-e,1-s,n,r];case 11:return[s-r,1-e,r,n];case 12:return[e-r*(h/l),s,r*(h/l),n*(l/h)];case 13:return[1-s-n*(l/h),e-r*(h/l),n*(l/h),r*(h/l)];case 14:return[1-e,1-s-n*(l/h),r*(h/l),n*(l/h)];case 15:return[s,1-e,n*(l/h),r*(h/l)];default:return[e,s,n,r]}},P(O,"_currentDrawId",-1),P(O,"_currentParent",null),g(O,Kt,null),g(O,ma,null),g(O,ba,null),g(O,qn,NaN),g(O,Yn,null),g(O,Kn,null),g(O,Aa,NaN),P(O,"_INNER_MARGIN",3);let Gd=O;var li,Qt,Jt,ya,hl,ve,oe,ys,wa,va,_a,cl,xd;class QA{constructor(t,e,s,n,r,a){g(this,cl);g(this,li,new Float64Array(6));g(this,Qt);g(this,Jt);g(this,ya);g(this,hl);g(this,ve);g(this,oe,"");g(this,ys,0);g(this,wa,new jc);g(this,va);g(this,_a);f(this,va,s),f(this,_a,n),f(this,ya,r),f(this,hl,a),[t,e]=m(this,cl,xd).call(this,t,e);const o=f(this,Qt,[NaN,NaN,NaN,NaN,t,e]);f(this,ve,[t,e]),f(this,Jt,[{line:o,points:i(this,ve)}]),i(this,li).set(o,0)}updateProperty(t,e){t==="stroke-width"&&f(this,hl,e)}isEmpty(){return!i(this,Jt)||i(this,Jt).length===0}isCancellable(){return i(this,ve).length<=10}add(t,e){[t,e]=m(this,cl,xd).call(this,t,e);const[s,n,r,a]=i(this,li).subarray(2,6),o=t-r,l=e-a;return Math.hypot(i(this,va)*o,i(this,_a)*l)<=2?null:(i(this,ve).push(t,e),isNaN(s)?(i(this,li).set([r,a,t,e],2),i(this,Qt).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(i(this,li)[0])&&i(this,Qt).splice(6,6),i(this,li).set([s,n,r,a,t,e],0),i(this,Qt).push(...F.createBezierPoints(s,n,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(i(this,ve).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,n,r){f(this,va,s),f(this,_a,n),f(this,ya,r),[t,e]=m(this,cl,xd).call(this,t,e);const a=f(this,Qt,[NaN,NaN,NaN,NaN,t,e]);f(this,ve,[t,e]);const o=i(this,Jt).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),i(this,Jt).push({line:a,points:i(this,ve)}),i(this,li).set(a,0),f(this,ys,0),this.toSVGPath(),null}getLastElement(){return i(this,Jt).at(-1)}setLastElement(t){return i(this,Jt)?(i(this,Jt).push(t),f(this,Qt,t.line),f(this,ve,t.points),f(this,ys,0),{path:{d:this.toSVGPath()}}):i(this,wa).setLastElement(t)}removeLastElement(){if(!i(this,Jt))return i(this,wa).removeLastElement();i(this,Jt).pop(),f(this,oe,"");for(let t=0,e=i(this,Jt).length;t<e;t++){const{line:s,points:n}=i(this,Jt)[t];f(this,Qt,s),f(this,ve,n),f(this,ys,0),this.toSVGPath()}return{path:{d:i(this,oe)}}}toSVGPath(){const t=F.svgRound(i(this,Qt)[4]),e=F.svgRound(i(this,Qt)[5]);if(i(this,ve).length===2)return f(this,oe,`${i(this,oe)} M ${t} ${e} Z`),i(this,oe);if(i(this,ve).length<=6){const n=i(this,oe).lastIndexOf("M");f(this,oe,`${i(this,oe).slice(0,n)} M ${t} ${e}`),f(this,ys,6)}if(i(this,ve).length===4){const n=F.svgRound(i(this,Qt)[10]),r=F.svgRound(i(this,Qt)[11]);return f(this,oe,`${i(this,oe)} L ${n} ${r}`),f(this,ys,12),i(this,oe)}const s=[];i(this,ys)===0&&(s.push(`M ${t} ${e}`),f(this,ys,6));for(let n=i(this,ys),r=i(this,Qt).length;n<r;n+=6){const[a,o,l,h,c,d]=i(this,Qt).slice(n,n+6).map(F.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}return f(this,oe,i(this,oe)+s.join(" ")),f(this,ys,i(this,Qt).length),i(this,oe)}getOutlines(t,e,s,n){const r=i(this,Jt).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),i(this,wa).build(i(this,Jt),t,e,s,i(this,ya),i(this,hl),n),f(this,li,null),f(this,Qt,null),f(this,Jt,null),f(this,oe,null),i(this,wa)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}li=new WeakMap,Qt=new WeakMap,Jt=new WeakMap,ya=new WeakMap,hl=new WeakMap,ve=new WeakMap,oe=new WeakMap,ys=new WeakMap,wa=new WeakMap,va=new WeakMap,_a=new WeakMap,cl=new WeakSet,xd=function(t,e){return F._normalizePoint(t,e,i(this,va),i(this,_a),i(this,ya))};var _e,Fc,Nc,Ze,hi,ci,dl,ul,Sa,he,wi,Km,Qm,Jm;class jc extends F{constructor(){super(...arguments);g(this,he);g(this,_e);g(this,Fc,0);g(this,Nc);g(this,Ze);g(this,hi);g(this,ci);g(this,dl);g(this,ul);g(this,Sa)}build(e,s,n,r,a,o,l){f(this,hi,s),f(this,ci,n),f(this,dl,r),f(this,ul,a),f(this,Sa,o),f(this,Nc,l??0),f(this,Ze,e),m(this,he,Qm).call(this)}get thickness(){return i(this,Sa)}setLastElement(e){return i(this,Ze).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return i(this,Ze).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of i(this,Ze)){if(e.push(`M${F.svgRound(s[4])} ${F.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${F.svgRound(s[10])} ${F.svgRound(s[11])}`);continue}for(let n=6,r=s.length;n<r;n+=6){const[a,o,l,h,c,d]=s.subarray(n,n+6).map(F.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}}return e.join("")}serialize([e,s,n,r],a){const o=[],l=[],[h,c,d,p]=m(this,he,Km).call(this);let b,y,A,v,w,S,_,E,C;switch(i(this,ul)){case 0:C=F._rescale,b=e,y=s+r,A=n,v=-r,w=e+h*n,S=s+(1-c-p)*r,_=e+(h+d)*n,E=s+(1-c)*r;break;case 90:C=F._rescaleAndSwap,b=e,y=s,A=n,v=r,w=e+c*n,S=s+h*r,_=e+(c+p)*n,E=s+(h+d)*r;break;case 180:C=F._rescale,b=e+n,y=s,A=-n,v=r,w=e+(1-h-d)*n,S=s+c*r,_=e+(1-h)*n,E=s+(c+p)*r;break;case 270:C=F._rescaleAndSwap,b=e+n,y=s+r,A=-n,v=-r,w=e+(1-c-p)*n,S=s+(1-h-d)*r,_=e+(1-c)*n,E=s+(1-h)*r;break}for(const{line:x,points:T}of i(this,Ze))o.push(C(x,b,y,A,v,a?new Array(x.length):null)),l.push(C(T,b,y,A,v,a?new Array(T.length):null));return{lines:o,points:l,rect:[w,S,_,E]}}static deserialize(e,s,n,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const d=[];let p,b,y,A,v;switch(h){case 0:v=F._rescale,p=-e/n,b=s/r+1,y=1/n,A=-1/r;break;case 90:v=F._rescaleAndSwap,p=-s/r,b=-e/n,y=1/r,A=1/n;break;case 180:v=F._rescale,p=e/n+1,b=-s/r,y=-1/n,A=1/r;break;case 270:v=F._rescaleAndSwap,p=s/r+1,b=e/n+1,y=-1/r,A=-1/n;break}if(!o){o=[];for(const S of l){const _=S.length;if(_===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(_===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}const E=new Float32Array(3*(_-2));o.push(E);let[C,x,T,k]=S.subarray(0,4);E.set([NaN,NaN,NaN,NaN,C,x],0);for(let M=4;M<_;M+=2){const I=S[M],R=S[M+1];E.set(F.createBezierPoints(C,x,T,k,I,R),(M-2)*3),[C,x,T,k]=[T,k,I,R]}}}for(let S=0,_=o.length;S<_;S++)d.push({line:v(o[S].map(E=>E??NaN),p,b,y,A),points:v(l[S].map(E=>E??NaN),p,b,y,A)});const w=new this.prototype.constructor;return w.build(d,n,r,1,h,c,a),w}get box(){return i(this,_e)}updateProperty(e,s){return e==="stroke-width"?m(this,he,Jm).call(this,s):null}updateParentDimensions([e,s],n){const[r,a]=m(this,he,wi).call(this);f(this,hi,e),f(this,ci,s),f(this,dl,n);const[o,l]=m(this,he,wi).call(this),h=o-r,c=l-a,d=i(this,_e);return d[0]-=h,d[1]-=c,d[2]+=2*h,d[3]+=2*c,d}updateRotation(e){return f(this,Fc,e),{path:{transform:this.rotationTransform}}}get viewBox(){return i(this,_e).map(F.svgRound).join(" ")}get defaultProperties(){const[e,s]=i(this,_e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${F.svgRound(e)} ${F.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=i(this,_e);let n=0,r=0,a=0,o=0,l=0,h=0;switch(i(this,Fc)){case 90:r=s/e,a=-e/s,l=e;break;case 180:n=-1,o=-1,l=e,h=s;break;case 270:r=-s/e,a=e/s,h=s;break;default:return""}return`matrix(${n} ${r} ${a} ${o} ${F.svgRound(l)} ${F.svgRound(h)})`}getPathResizingSVGProperties([e,s,n,r]){const[a,o]=m(this,he,wi).call(this),[l,h,c,d]=i(this,_e);
12if(Math.abs(c-a)<=F.PRECISION||Math.abs(d-o)<=F.PRECISION){const v=e+n/2-(l+c/2),w=s+r/2-(h+d/2);return{path:{"transform-origin":`${F.svgRound(e)} ${F.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const p=(n-2*a)/(c-2*a),b=(r-2*o)/(d-2*o),y=c/n,A=d/r;return{path:{"transform-origin":`${F.svgRound(l)} ${F.svgRound(h)}`,transform:`${this.rotationTransform} scale(${y} ${A}) translate(${F.svgRound(a)} ${F.svgRound(o)}) scale(${p} ${b}) translate(${F.svgRound(-a)} ${F.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,n,r]){const[a,o]=m(this,he,wi).call(this),l=i(this,_e),[h,c,d,p]=l;if(l[0]=e,l[1]=s,l[2]=n,l[3]=r,Math.abs(d-a)<=F.PRECISION||Math.abs(p-o)<=F.PRECISION){const w=e+n/2-(h+d/2),S=s+r/2-(c+p/2);for(const{line:_,points:E}of i(this,Ze))F._translate(_,w,S,_),F._translate(E,w,S,E);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${F.svgRound(e)} ${F.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const b=(n-2*a)/(d-2*a),y=(r-2*o)/(p-2*o),A=-b*(h+a)+e+a,v=-y*(c+o)+s+o;if(b!==1||y!==1||A!==0||v!==0)for(const{line:w,points:S}of i(this,Ze))F._rescale(w,A,v,b,y,w),F._rescale(S,A,v,b,y,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${F.svgRound(e)} ${F.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],n){const[r,a]=n,o=i(this,_e),l=e-o[0],h=s-o[1];if(i(this,hi)===r&&i(this,ci)===a)for(const{line:c,points:d}of i(this,Ze))F._translate(c,l,h,c),F._translate(d,l,h,d);else{const c=i(this,hi)/r,d=i(this,ci)/a;f(this,hi,r),f(this,ci,a);for(const{line:p,points:b}of i(this,Ze))F._rescale(p,l,h,c,d,p),F._rescale(b,l,h,c,d,b);o[2]*=c,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${F.svgRound(e)} ${F.svgRound(s)}`}}}get defaultSVGProperties(){const e=i(this,_e);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${F.svgRound(e[0])} ${F.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}_e=new WeakMap,Fc=new WeakMap,Nc=new WeakMap,Ze=new WeakMap,hi=new WeakMap,ci=new WeakMap,dl=new WeakMap,ul=new WeakMap,Sa=new WeakMap,he=new WeakSet,wi=function(e=i(this,Sa)){const s=i(this,Nc)+e/2*i(this,dl);return i(this,ul)%180===0?[s/i(this,hi),s/i(this,ci)]:[s/i(this,ci),s/i(this,hi)]},Km=function(){const[e,s,n,r]=i(this,_e),[a,o]=m(this,he,wi).call(this,0);return[e+a,s+o,n-2*a,r-2*o]},Qm=function(){const e=f(this,_e,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of i(this,Ze)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)N.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;l+=6){const[c,d,p,b,y,A]=r.subarray(l,l+6);N.bezierBoundingBox(a,o,c,d,p,b,y,A,e),a=y,o=A}}const[s,n]=m(this,he,wi).call(this);e[0]=Ae(e[0]-s,0,1),e[1]=Ae(e[1]-n,0,1),e[2]=Ae(e[2]+s,0,1),e[3]=Ae(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]},Jm=function(e){const[s,n]=m(this,he,wi).call(this);f(this,Sa,e);const[r,a]=m(this,he,wi).call(this),[o,l]=[r-s,a-n],h=i(this,_e);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class mu extends qm{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:vt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new mu(this._viewParameters);return t.updateAll(this),t}}var hu,Zm;const Va=class Va extends Gd{constructor(e){super({...e,name:"inkEditor"});g(this,hu);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){vt.initialize(e,s),this._defaultDrawingOptions=new mu(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return Y(this,"typesMap",new Map([[Z.INK_THICKNESS,"stroke-width"],[Z.INK_COLOR,"stroke"],[Z.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,n,r,a){return new QA(e,s,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,n,r,a,o){return jc.deserialize(e,s,n,r,a,o)}static async deserialize(e,s,n){let r=null;if(e instanceof dp){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,opacity:p,borderStyle:{rawWidth:b},popupRef:y,richText:A,contentsObj:v,creationDate:w,modificationDate:S},parent:{page:{pageNumber:_}}}=e;r=e={annotationType:j.INK,color:Array.from(d),thickness:b,opacity:p,paths:{points:o},boxes:null,pageIndex:_-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:y,richText:A,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:S}}const a=await super.deserialize(e,s,n);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Hd(this)),[["colorPicker",this._colorPicker]]}get colorType(){return Z.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:n}=this;s.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:n}
12){this._drawingOptions=Va.getDefaultDrawingOptions({stroke:N.makeHexColor(...e),"stroke-width":s,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:vt._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:n}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!m(this,hu,Zm).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};hu=new WeakSet,Zm=function(e){const{color:s,thickness:n,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==n||e.opacity!==r||e.pageIndex!==a},P(Va,"_type","ink"),P(Va,"_editorType",j.INK),P(Va,"_defaultDrawingOptions",null);let Uf=Va;class $f extends jc{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const td=8,Pl=3;var Ea,rt,zf,Fs,tb,eb,Gf,Td,sb,ib,nb,jf,Vf,rb;class pi{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:n},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const d=200,p=c.font=`${s} ${n} ${d}px ${e}`,{actualBoundingBoxLeft:b,actualBoundingBoxRight:y,actualBoundingBoxAscent:A,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:S,width:_}=c.measureText(t),E=1.5,C=Math.ceil(Math.max(Math.abs(b)+Math.abs(y)||0,_)*E),x=Math.ceil(Math.max(Math.abs(A)+Math.abs(v)||d,Math.abs(w)+Math.abs(S)||d)*E);h=new OffscreenCanvas(C,x),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=p,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,C,x),c.fillStyle="black",c.fillText(t,C*(E-1)/2,x*(3-E)/2);const T=m(this,rt,jf).call(this,c.getImageData(0,0,C,x).data),k=m(this,rt,nb).call(this,T),M=m(this,rt,Vf).call(this,k),I=m(this,rt,Gf).call(this,T,C,x,M);return this.processDrawnLines({lines:{curves:I,width:C,height:x},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,n,r){const[a,o,l]=m(this,rt,rb).call(this,t),[h,c]=m(this,rt,ib).call(this,a,o,l,Math.hypot(o,l)*i(this,Ea).sigmaSFactor,i(this,Ea).sigmaR,i(this,Ea).kernelSize),d=m(this,rt,Vf).call(this,c),p=m(this,rt,Gf).call(this,h,o,l,d);return this.processDrawnLines({lines:{curves:p,width:o,height:l},pageWidth:e,pageHeight:s,rotation:n,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:n,innerMargin:r,mustSmooth:a,areContours:o}){n%180!==0&&([e,s]=[s,e]);const{curves:l,width:h,height:c}=t,d=t.thickness??0,p=[],b=Math.min(e/h,s/c),y=b/e,A=b/s,v=[];for(const{points:S}of l){const _=a?m(this,rt,sb).call(this,S):S;if(!_)continue;v.push(_);const E=_.length,C=new Float32Array(E),x=new Float32Array(3*(E===2?2:E-2));if(p.push({line:x,points:C}),E===2){C[0]=_[0]*y,C[1]=_[1]*A,x.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[T,k,M,I]=_;T*=y,k*=A,M*=y,I*=A,C.set([T,k,M,I],0),x.set([NaN,NaN,NaN,NaN,T,k],0);for(let R=4;R<E;R+=2){const H=C[R]=_[R]*y,q=C[R+1]=_[R+1]*A;x.set(F.createBezierPoints(T,k,M,I,H,q),(R-2)*3),[T,k,M,I]=[M,I,H,q]}}if(p.length===0)return null;const w=o?new $f:new jc;return w.build(p,e,s,1,n,o?0:d,r),{outline:w,newCurves:v,areContours:o,thickness:d,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:n,height:r}){let a=1/0,o=-1/0,l=0;for(const _ of t){l+=_.length;for(let E=2,C=_.length;E<C;E++){const x=_[E]-_[E-2];a=Math.min(a,x),o=Math.max(o,x)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,d=td+Pl*c,p=new Uint32Array(d);let b=0;p[b++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,p[b++]=0,p[b++]=n,p[b++]=r,p[b++]=e?0:1,p[b++]=Math.max(0,Math.floor(s??0)),p[b++]=c,p[b++]=h.BYTES_PER_ELEMENT;for(const _ of t)p[b++]=_.length-2,p[b++]=_[0],p[b++]=_[1];const y=new CompressionStream("deflate-raw"),A=y.writable.getWriter();await A.ready,A.write(p);const v=h.prototype.constructor;for(const _ of t){const E=new v(_.length-2);for(let C=2,x=_.length;C<x;C++)E[C-2]=_[C]-_[C-2];A.write(E)}A.close();const w=await new Response(y.readable).arrayBuffer(),S=new Uint8Array(w);return tg(S)}static async decompressSignature(t){try{const e=_b(t),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const _ of s)a||(a=new Uint8Array(new Uint32Array(_.buffer,0,4)[0])),a.set(_,o),o+=_.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],p=l[4]===0,b=l[5],y=l[6],A=l[7],v=[],w=(td+Pl*y)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(A){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,w);break}o=0;for(let _=0;_<y;_++){const E=l[Pl*_+td],C=new Float32Array(E+2);v.push(C);for(let x=0;x<Pl-1;x++)C[x]=l[Pl*_+td+x+1];for(let x=0;x<E;x++)C[x+2]=C[x]+S[o++]}return{areContours:p,thickness:b,outlines:v,width:c,height:d}}catch(e){return V(`decompressSignature: ${e}`),null}}}
12Ea=new WeakMap,rt=new WeakSet,zf=function(t,e,s,n){return s-=t,n-=e,s===0?n>0?0:4:s===1?n+6:2-n},Fs=new WeakMap,tb=function(t,e,s,n,r,a,o){const l=m(this,rt,zf).call(this,s,n,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,d=i(this,Fs)[2*c],p=i(this,Fs)[2*c+1];if(t[(s+d)*e+(n+p)]!==0)return c}return-1},eb=function(t,e,s,n,r,a,o){const l=m(this,rt,zf).call(this,s,n,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,d=i(this,Fs)[2*c],p=i(this,Fs)[2*c+1];if(t[(s+d)*e+(n+p)]!==0)return c}return-1},Gf=function(t,e,s,n){const r=t.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=t[c]<=n?1:0;for(let c=1;c<s-1;c++)a[c*e]=a[c*e+e-1]=0;for(let c=0;c<e;c++)a[c]=a[e*s-1-c]=0;let o=1,l;const h=[];for(let c=1;c<s-1;c++){l=1;for(let d=1;d<e-1;d++){const p=c*e+d,b=a[p];if(b===0)continue;let y=c,A=d;if(b===1&&a[p-1]===0)o+=1,A-=1;else if(b>=1&&a[p+1]===0)o+=1,A+=1,b>1&&(l=b);else{b!==1&&(l=Math.abs(b));continue}const v=[d,c],w=A===d+1,S={isHole:w,points:v,id:o,parent:0};h.push(S);let _;for(const R of h)if(R.id===l){_=R;break}_?_.isHole?S.parent=w?_.parent:l:S.parent=w?l:_.parent:S.parent=w?l:0;const E=m(this,rt,tb).call(this,a,e,c,d,y,A,0);if(E===-1){a[p]=-o,a[p]!==1&&(l=Math.abs(a[p]));continue}let C=i(this,Fs)[2*E],x=i(this,Fs)[2*E+1];const T=c+C,k=d+x;y=T,A=k;let M=c,I=d;for(;;){const R=m(this,rt,eb).call(this,a,e,M,I,y,A,1);C=i(this,Fs)[2*R],x=i(this,Fs)[2*R+1];const H=M+C,q=I+x;v.push(q,H);const G=M*e+I;if(a[G+1]===0?a[G]=-o:a[G]===1&&(a[G]=o),H===c&&q===d&&M===T&&I===k){a[p]!==1&&(l=Math.abs(a[p]));break}else y=M,A=I,M=H,I=q}}}return h},Td=function(t,e,s,n){if(s-e<=4){for(let T=e;T<s-2;T+=2)n.push(t[T],t[T+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,h=Math.hypot(o,l),c=o/h,d=l/h,p=c*a-d*r,b=l/o,y=1/h,A=Math.atan(b),v=Math.cos(A),w=Math.sin(A),S=y*(Math.abs(v)+Math.abs(w)),_=y*(1-S+S**2),E=Math.max(Math.atan(Math.abs(w+v)*_),Math.atan(Math.abs(w-v)*_));let C=0,x=e;for(let T=e+2;T<s-2;T+=2){const k=Math.abs(p-c*t[T+1]+d*t[T]);k>C&&(x=T,C=k)}C>(h*E)**2?(m(this,rt,Td).call(this,t,e,x+2,n),m(this,rt,Td).call(this,t,x,s,n)):n.push(r,a)},sb=function(t){const e=[],s=t.length;return m(this,rt,Td).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},ib=function(t,e,s,n,r,a){const o=new Float32Array(a**2),l=-2*n**2,h=a>>1;for(let A=0;A<a;A++){const v=(A-h)**2;for(let w=0;w<a;w++)o[A*a+w]=Math.exp((v+(w-h)**2)/l)}const c=new Float32Array(256),d=-2*r**2;for(let A=0;A<256;A++)c[A]=Math.exp(A**2/d);const p=t.length,b=new Uint8Array(p),y=new Uint32Array(256);for(let A=0;A<s;A++)for(let v=0;v<e;v++){const w=A*e+v,S=t[w];let _=0,E=0;for(let x=0;x<a;x++){const T=A+x-h;if(!(T<0||T>=s))for(let k=0;k<a;k++){const M=v+k-h;if(M<0||M>=e)continue;const I=t[T*e+M],R=o[x*a+k]*c[Math.abs(I-S)];_+=I*R,E+=R}}const C=b[w]=Math.round(_/E);y[C]++}return[b,y]},nb=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},jf=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let n=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const h=s[o]=t[o<<2];n=Math.max(n,h),r=Math.min(r,h)}const a=255/(n-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},Vf=function(t){let e,s=-1/0,n=-1/0;const r=t.findIndex(l=>l!==0);let a=r,o=r;for(e=r;e<256;e++){const l=t[e];l>s&&(e-a>n&&(n=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},rb=function(t){const e=t,{width:s,height:n}=t,{maxDim:r}=i(this,Ea);let a=s,o=n;if(s>r||n>r){let p=s,b=n,y=Math.log2(Math.max(s,n)/r);const A=Math.floor(y);y=y===A?A-1:A;for(let w=0;w<y;w++){a=Math.ceil(p/2),o=Math.ceil(b/2);const S=new OffscreenCanvas(a,o);S.getContext("2d").drawImage(t,0,0,p,b,0,0,a,o),p=a,b=o,t!==e&&t.close(),t=S.transferToImageBitmap()}const v=Math.min(r/a,r/o);a=Math.round(a*v),o=Math.round(o*v)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,a,o),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,a,o);const c=h.getImageData(0,0,a,o).data;return[m(this,rt,jf).call(this,c),a,o]},g(pi,rt),g(pi,Ea,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),g(pi,Fs,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class up extends qm{constructor(){super(),super.updateProperties({fill:vt._defaultLineColor,"stroke-width":0})}clone(){const t=new up;return t.updateAll(this),t}}class fp extends mu{constructor(t){super(t),super.updateProperties({stroke:vt._defaultLineColor,"stroke-width":1})}clone(){const t=new fp(this._viewParameters);return t.updateAll(this),t}}var Qn,di,Jn,Ca;const Oe=class Oe extends Gd{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});g(this,Qn,!1);g(this,di,null);g(this,Jn,null);g(this,Ca,null);this._willKeepAspectRatio=!0,f(this,Jn,e.signatureData||null),f(this,di,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){vt.initialize(e,s),this._defaultDrawingOptions=new up,this._defaultDrawnSignatureOptions=new fp(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return Y(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!i(this,di)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}
12render(){if(this.div)return this.div;let e,s;const{_isCopy:n}=this;if(n&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(i(this,Jn)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=i(this,Jn),{rawDims:{pageWidth:d,pageHeight:p},rotation:b}=this.parent.viewport,y=pi.processDrawnLines({lines:r,pageWidth:d,pageHeight:p,rotation:b,innerMargin:Oe._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(y,c,l,h)}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:i(this,di)||""}));return n&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){f(this,Ca,e),this.addEditToolbar()}getUuid(){return i(this,Ca)}get description(){return i(this,di)}set description(e){f(this,di,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:n,width:r,height:a}=i(this,Jn),o=Math.max(r,a),l=pi.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:n,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,n,r){const{x:a,y:o}=this,{outline:l}=f(this,Jn,e);f(this,Qn,l instanceof $f),this.description=n;let h;i(this,Qn)?h=Oe.getDefaultDrawingOptions():(h=Oe._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let d=s/c;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!n}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return pi.process(e,s,n,r,Oe._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:n,pageHeight:r},rotation:a}=this.parent.viewport;return pi.extractContoursFromText(e,s,n,r,a,Oe._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return pi.processDrawnLines({lines:e,pageWidth:s,pageHeight:n,rotation:r,innerMargin:Oe._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Oe.getDefaultDrawingOptions():(this._drawingOptions=Oe._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:i(this,Qn),color:[0,0,0],thickness:i(this,Qn)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:n},a.uuid=i(this,Ca),a.isCopy=!0):a.lines=s,i(this,di)&&(a.accessibilityData={type:"Figure",alt:i(this,di)}),a}static deserializeDraw(e,s,n,r,a,o){return o.areContours?$f.deserialize(e,s,n,r,a,o):jc.deserialize(e,s,n,r,a,o)}static async deserialize(e,s,n){var a;const r=await super.deserialize(e,s,n);return f(r,Qn,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",f(r,Ca,e.uuid),r}};Qn=new WeakMap,di=new WeakMap,Jn=new WeakMap,Ca=new WeakMap,P(Oe,"_type","signature"),P(Oe,"_editorType",j.SIGNATURE),P(Oe,"_defaultDrawingOptions",null);let Wf=Oe;var Ct,Zt,Zn,Ji,tr,fl,Zi,xa,ui,ts,pl,it,ql,Yl,Pd,kd,Md,qf,Dd,ab;class Xf extends vt{constructor(e){super({...e,name:"stampEditor"});g(this,it);g(this,Ct,null);g(this,Zt,null);g(this,Zn,null);g(this,Ji,null);g(this,tr,null);g(this,fl,"");g(this,Zi,null);g(this,xa,!1);g(this,ui,null);g(this,ts,!1);g(this,pl,!1);f(this,Ji,e.bitmapUrl),f(this,tr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){vt.initialize(e,s)}static isHandlingMimeForPasting(e){return Id.includes(e)}static paste(e,s){s.pasteEditor({mode:j.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await n.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;i(this,Zt)&&(f(this,Ct,null),this._uiManager.imageManager.deleteId(i(this,Zt)),(e=i(this,Zi))==null||e.remove(),f(this,Zi,null),i(this,ui)&&(clearTimeout(i(this,ui)),f(this,ui,null))),super.remove()}rebuild(){if(!this.parent){i(this,Zt)&&m(this,it,Pd).call(this);return}super.rebuild(),this.div!==null&&(i(this,Zt)&&i(this,Zi)===null&&m(this,it,Pd).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(i(this,Zn)||i(this,Ct)||i(this,Ji)||i(this,tr)||i(this,Zt)||i(this,xa))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}
12render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),i(this,xa)||(i(this,Ct)?m(this,it,kd).call(this):m(this,it,Pd).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(f(this,Zt,n),r&&f(this,Ct,r),f(this,xa,!1),m(this,it,kd).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;i(this,ui)!==null&&clearTimeout(i(this,ui)),f(this,ui,setTimeout(()=>{f(this,ui,null),m(this,it,qf).call(this)},200))}copyCanvas(e,s,n=!1){e||(e=224);const{width:r,height:a}=i(this,Ct),o=new Hs;let l=i(this,Ct),h=r,c=a,d=null;if(s){if(r>s||a>s){const T=Math.min(s/r,s/a);h=Math.floor(r*T),c=Math.floor(a*T)}d=document.createElement("canvas");const b=d.width=Math.ceil(h*o.sx),y=d.height=Math.ceil(c*o.sy);i(this,ts)||(l=m(this,it,Md).call(this,b,y));const A=d.getContext("2d");A.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":Cb.isDarkMode&&(v="#8f8f9d",w="#42414d");const S=15,_=S*o.sx,E=S*o.sy,C=new OffscreenCanvas(_*2,E*2),x=C.getContext("2d");x.fillStyle=v,x.fillRect(0,0,_*2,E*2),x.fillStyle=w,x.fillRect(0,0,_,E),x.fillRect(_,E,_,E),A.fillStyle=A.createPattern(C,"repeat"),A.fillRect(0,0,b,y),A.drawImage(l,0,0,l.width,l.height,0,0,b,y)}let p=null;if(n){let b,y;if(o.symmetric&&l.width<e&&l.height<e)b=l.width,y=l.height;else if(l=i(this,Ct),r>e||a>e){const w=Math.min(e/r,e/a);b=Math.floor(r*w),y=Math.floor(a*w),i(this,ts)||(l=m(this,it,Md).call(this,b,y))}const v=new OffscreenCanvas(b,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,b,y),p={width:b,height:y,data:v.getImageData(0,0,b,y).data}}return{canvas:d,width:h,height:c,imageData:p}}static async deserialize(e,s,n){var v;let r=null,a=!1;if(e instanceof _m){const{data:{rect:w,rotation:S,id:_,structParent:E,popupRef:C,richText:x,contentsObj:T,creationDate:k,modificationDate:M},container:I,parent:{page:{pageNumber:R}},canvas:H}=e;let q,G;H?(delete e.canvas,{id:q,bitmap:G}=n.imageManager.getFromCanvas(I.id,H),H.remove()):(a=!0,e._hasNoCanvas=!0);const tt=((v=await s._structTree.getAriaAttributes(`${ip}${_}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:j.STAMP,bitmapId:q,bitmap:G,pageIndex:R-1,rect:w.slice(0),rotation:S,annotationElementId:_,id:_,deleted:!1,accessibilityData:{decorative:!1,altText:tt},isSvg:!1,structParent:E,popupRef:C,richText:x,comment:(T==null?void 0:T.str)||null,creationDate:k,modificationDate:M}}const o=await super.deserialize(e,s,n),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:d,isSvg:p,accessibilityData:b}=e;a?(n.addMissingCanvas(e.id,o),f(o,xa,!0)):d&&n.imageManager.isValidId(d)?(f(o,Zt,d),h&&f(o,Ct,h)):f(o,Ji,c),f(o,ts,p);const[y,A]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/A,b&&(o.altTextData=b),o._initialData=r,e.comment&&o.setCommentData(e),f(o,pl,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n=Object.assign(super.serialize(e),{bitmapId:i(this,Zt),isSvg:i(this,ts)});if(this.addComment(n),e)return n.bitmapUrl=m(this,it,Dd).call(this,!0),n.accessibilityData=this.serializeAltText(!0),n.isCopy=!0,n;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(n.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=m(this,it,ab).call(this,n);return l.isSame?null:(l.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1,n.id=this.annotationElementId,delete n.bitmapId,n)}if(s===null)return n;s.stamps||(s.stamps=new Map);const o=i(this,ts)?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!s.stamps.has(i(this,Zt)))s.stamps.set(i(this,Zt),{area:o,serialized:n}),n.bitmap=m(this,it,Dd).call(this,!1);else if(i(this,ts)){const l=s.stamps.get(i(this,Zt));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=m(this,it,Dd).call(this,!1))}return n}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Ct=new WeakMap,Zt=new WeakMap,Zn=new WeakMap,Ji=new WeakMap,tr=new WeakMap,fl=new WeakMap,Zi=new WeakMap,xa=new WeakMap,ui=new WeakMap,ts=new WeakMap,pl=new WeakMap,it=new WeakSet,ql=function(e,s=!1){if(!e){this.remove();return}
12f(this,Ct,e.bitmap),s||(f(this,Zt,e.id),f(this,ts,e.isSvg)),e.file&&f(this,fl,e.file.name),m(this,it,kd).call(this)},Yl=function(){if(f(this,Zn,null),this._uiManager.enableWaiting(!1),!!i(this,Zi)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&i(this,Ct)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&i(this,Ct)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Pd=function(){if(i(this,Zt)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(i(this,Zt)).then(n=>m(this,it,ql).call(this,n,!0)).finally(()=>m(this,it,Yl).call(this));return}if(i(this,Ji)){const n=i(this,Ji);f(this,Ji,null),this._uiManager.enableWaiting(!0),f(this,Zn,this._uiManager.imageManager.getFromUrl(n).then(r=>m(this,it,ql).call(this,r)).finally(()=>m(this,it,Yl).call(this)));return}if(i(this,tr)){const n=i(this,tr);f(this,tr,null),this._uiManager.enableWaiting(!0),f(this,Zn,this._uiManager.imageManager.getFromFile(n).then(r=>m(this,it,ql).call(this,r)).finally(()=>m(this,it,Yl).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Id.join(",");const s=this._uiManager._signal;f(this,Zn,new Promise(n=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),m(this,it,ql).call(this,r)}n()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:s})}).finally(()=>m(this,it,Yl).call(this))),e.click()},kd=function(){var h;const{div:e}=this;let{width:s,height:n}=i(this,Ct);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,n=this.height*a;else if(s>o*r||n>o*a){const c=Math.min(o*r/s,o*a/n);s*=c,n*=c}this._uiManager.enableWaiting(!1);const l=f(this,Zi,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=n/a,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),m(this,it,qf).call(this),i(this,pl)||(this.parent.addUndoableEditor(this),f(this,pl,!0)),this._reportTelemetry({action:"inserted_image"}),i(this,fl)&&this.div.setAttribute("aria-description",i(this,fl)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},Md=function(e,s){const{width:n,height:r}=i(this,Ct);let a=n,o=r,l=i(this,Ct);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=d.transferToImageBitmap()}return l},qf=function(){const[e,s]=this.parentDimensions,{width:n,height:r}=this,a=new Hs,o=Math.ceil(n*e*a.sx),l=Math.ceil(r*s*a.sy),h=i(this,Zi);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=i(this,ts)?i(this,Ct):m(this,it,Md).call(this,o,l),d=h.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(c,0,0,c.width,c.height,0,0,o,l)},Dd=function(e){if(e){if(i(this,ts)){const r=this._uiManager.imageManager.getSvgUrl(i(this,Zt));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=i(this,Ct),s.getContext("2d").drawImage(i(this,Ct),0,0),s.toDataURL()}if(i(this,ts)){const[s,n]=this.pageDimensions,r=Math.round(this.width*s*ln.PDF_TO_CSS_UNITS),a=Math.round(this.height*n*ln.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(i(this,Ct),0,0,i(this,Ct).width,i(this,Ct).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(i(this,Ct))},ab=function(e){var o;const{pageIndex:s,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},P(Xf,"_type","stamp"),P(Xf,"_editorType",j.STAMP);var Ta,gl,er,sr,tn,Fe,ir,ml,bl,Ns,en,te,sn,nr,Al,B,rr,bt,Yf,ob,Gs,Kf,Qf,Rd;const Cs=class Cs{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){g(this,bt);g(this,Ta);g(this,gl,!1);g(this,er,null);g(this,sr,null);g(this,tn,null);g(this,Fe,new Map);g(this,ir,!1);g(this,ml,!1);g(this,bl,!1);g(this,Ns,null);g(this,en,null);g(this,te,null);g(this,sn,null);g(this,nr,null);g(this,Al,-1);g(this,B);const d=[...i(Cs,rr).values()];if(!Cs._initialized){Cs._initialized=!0;for(const p of d)p.initialize(c,t)}
12t.registerEditorTypes(d),f(this,B,t),this.pageIndex=e,this.div=s,f(this,Ta,r),f(this,er,a),this.viewport=h,f(this,te,l),this.drawLayer=o,this._structTree=n,i(this,B).addLayer(this)}get isEmpty(){return i(this,Fe).size===0}get isInvisible(){return this.isEmpty&&i(this,B).getMode()===j.NONE}updateToolbar(t){i(this,B).updateToolbar(t)}updateMode(t=i(this,B).getMode()){switch(m(this,bt,Rd).call(this),t){case j.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case j.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case j.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===j.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of i(Cs,rr).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=i(this,te))==null?void 0:e.div)}setEditingState(t){i(this,B).setEditingState(t)}addCommands(t){i(this,B).addCommands(t)}cleanUndoStack(t){i(this,B).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=i(this,er))==null||e.div.classList.toggle("disabled",!t)}async enable(){var s;f(this,bl,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=i(this,nr))==null||s.abort(),f(this,nr,null);const t=new Set;for(const n of i(this,bt,Yf))n.enableEditing(),n.show(!0),n.annotationElementId&&(i(this,B).removeChangedExistingAnnotation(n),t.add(n.annotationElementId));const e=i(this,er);if(e)for(const n of e.getEditableAnnotations()){if(n.hide(),i(this,B).isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;const r=await this.deserialize(n);r&&(this.addOrRebuild(r),r.enableEditing())}f(this,bl,!1),i(this,B)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var s;if(f(this,ml,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),i(this,te)&&!i(this,nr)){f(this,nr,new AbortController);const n=i(this,B).combinedSignal(i(this,nr));i(this,te).div.addEventListener("pointerdown",r=>{const{clientX:o,clientY:l,timeStamp:h}=r,c=i(this,Al);if(h-c>500){f(this,Al,h);return}f(this,Al,-1);const{classList:d}=this.div;d.toggle("getElements",!0);const p=document.elementsFromPoint(o,l);if(d.toggle("getElements",!1),!this.div.contains(p[0]))return;let b;const y=new RegExp(`^${Ql}[0-9]+$`);for(const v of p)if(y.test(v.id)){b=v.id;break}if(!b)return;const A=i(this,Fe).get(b);(A==null?void 0:A.annotationElementId)===null&&(r.stopPropagation(),r.preventDefault(),A.dblclick(r))},{signal:n,capture:!0})}const t=i(this,er);if(t){const n=new Map,r=new Map;for(const o of i(this,bt,Yf)){if(o.disableEditing(),!o.annotationElementId){o.updateFakeAnnotationElement(t);continue}if(o.serialize()!==null){n.set(o.annotationElementId,o);continue}else r.set(o.annotationElementId,o);(s=this.getEditableAnnotation(o.annotationElementId))==null||s.show(),o.remove()}const a=t.getEditableAnnotations();for(const o of a){const{id:l}=o.data;if(i(this,B).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=r.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=n.get(l),h&&(i(this,B).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}m(this,bt,Rd).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const n of i(Cs,rr).values())e.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),f(this,ml,!1)}getEditableAnnotation(t){var e;return((e=i(this,er))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){i(this,B).getActive()!==t&&i(this,B).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=i(this,te))!=null&&t.div&&!i(this,sn)){f(this,sn,new AbortController);const e=i(this,B).combinedSignal(i(this,sn));i(this,te).div.addEventListener("pointerdown",m(this,bt,ob).bind(this),{signal:e}),i(this,te).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=i(this,te))!=null&&t.div&&i(this,sn)&&(i(this,sn).abort(),f(this,sn,null),i(this,te).div.classList.remove("highlighting"))}enableClick(){if(i(this,sr))return;f(this,sr,new AbortController);const t=i(this,B).combinedSignal(i(this,sr));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=i(this,sr))==null||t.abort(),f(this,sr,null)}attach(t){i(this,Fe).set(t.id,t);const{annotationElementId:e}=t;e&&i(this,B).isDeletedAnnotationElement(e)&&i(this,B).removeDeletedAnnotationElement(t)}detach(t){var e;i(this,Fe).delete(t.id),(e=i(this,Ta))==null||e.removePointerInTextLayer(t.contentDiv),!i(this,ml)&&t.annotationElementId&&i(this,B).addDeletedAnnotationElement(t)}remove(t){this.detach(t),i(this,B).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(i(this,B).addDeletedAnnotationElement(t.annotationElementId),vt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}
12add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),i(this,B).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!i(this,bl)),i(this,B).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!i(this,tn)&&(t._focusEventsAllowed=!1,f(this,tn,setTimeout(()=>{f(this,tn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:i(this,B)._signal}),e.focus())},0))),t._structTreeParentId=(s=i(this,Ta))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of i(this,Fe).values())if(e.uid===t)return e;return null}getNextId(){return i(this,B).getId()}combinedSignal(t){return i(this,B).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=i(this,bt,Gs))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await i(this,B).updateMode(t.mode);const{offsetX:s,offsetY:n}=m(this,bt,Qf).call(this),r=this.getNextId(),a=m(this,bt,Kf).call(this,{parent:this,id:r,x:s,y:n,uiManager:i(this,B),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=i(Cs,rr).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,i(this,B)))||null}createAndAddNewEditor(t,e,s={}){const n=this.getNextId(),r=m(this,bt,Kf).call(this,{parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:i(this,B),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(m(this,bt,Qf).call(this),!0,t)}setSelected(t){i(this,B).setSelected(t)}toggleSelected(t){i(this,B).toggleSelected(t)}unselect(t){i(this,B).unselect(t)}pointerup(t){var n;const{isMac:e}=ee.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!i(this,ir)||(f(this,ir,!1),(n=i(this,bt,Gs))!=null&&n.isDrawer&&i(this,bt,Gs).supportMultipleDrawings))return;if(!i(this,gl)){f(this,gl,!0);return}const s=i(this,B).getMode();if(s===j.STAMP||s===j.SIGNATURE){i(this,B).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var n;if(i(this,B).getMode()===j.HIGHLIGHT&&this.enableTextSelection(),i(this,ir)){f(this,ir,!1);return}const{isMac:e}=ee.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(f(this,ir,!0),(n=i(this,bt,Gs))!=null&&n.isDrawer){this.startDrawingSession(t);return}const s=i(this,B).getActive();f(this,gl,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),i(this,Ns)){i(this,bt,Gs).startDrawing(this,i(this,B),!1,t);return}i(this,B).setCurrentDrawingSession(this),f(this,Ns,new AbortController);const e=i(this,B).combinedSignal(i(this,Ns));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(f(this,en,null),this.commitOrRemove())},{signal:e}),i(this,bt,Gs).startDrawing(this,i(this,B),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&f(this,en,e);return}i(this,en)&&setTimeout(()=>{var e;(e=i(this,en))==null||e.focus(),f(this,en,null)},0)}endDrawingSession(t=!1){return i(this,Ns)?(i(this,B).setCurrentDrawingSession(null),i(this,Ns).abort(),f(this,Ns,null),f(this,en,null),i(this,bt,Gs).endDrawing(t)):null}findNewParent(t,e,s){const n=i(this,B).findParent(e,s);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return i(this,Ns)?(this.endDrawingSession(),!0):!1}onScaleChanging(){i(this,Ns)&&i(this,bt,Gs).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=i(this,B).getActive())==null?void 0:t.parent)===this&&(i(this,B).commitOrRemove(),i(this,B).setActiveEditor(null)),i(this,tn)&&(clearTimeout(i(this,tn)),f(this,tn,null));for(const s of i(this,Fe).values())(e=i(this,Ta))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,i(this,Fe).clear(),i(this,B).removeLayer(this)}render({viewport:t}){this.viewport=t,ar(this.div,t);for(const e of i(this,B).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){i(this,B).commitOrRemove(),m(this,bt,Rd).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ar(this.div,{rotation:s}),e!==s)for(const n of i(this,Fe).values())n.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return i(this,B).viewParameters.realScale}};Ta=new WeakMap,gl=new WeakMap,er=new WeakMap,sr=new WeakMap,tn=new WeakMap,Fe=new WeakMap,ir=new WeakMap,ml=new WeakMap,bl=new WeakMap,Ns=new WeakMap,en=new WeakMap,te=new WeakMap,sn=new WeakMap,nr=new WeakMap,Al=new WeakMap,B=new WeakMap,rr=new WeakMap,bt=new WeakSet,Yf=function(){return i(this,Fe).size!==0?i(this,Fe).values():i(this,B).getEditors(this.pageIndex)},ob=function(t){i(this,B).unselectAll();const{target:e}=t;if(e===i(this,te).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&i(this,te).div.contains(e)){const{isMac:s}=ee.platform;if(t.button!==0||t.ctrlKey&&s)return;i(this,B).showAllEditors("highlight",!0,!0),i(this,te).div.classList.add("free"),this.toggleDrawing(),zd.startHighlighting(this,i(this,B).direction==="ltr",{target:i(this,te).div,x:t.x,y:t.y}),i(this,te).div.addEventListener("pointerup",()=>{i(this,te).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:i(this,B)._signal}),t.preventDefault()}},Gs=function(){return i(Cs,rr).get(i(this,B).getMode())},Kf=function(t){const e=i(this,bt,Gs);return e?new e.prototype.constructor(t):null},Qf=function(){const{x:t,y:e,width:s,height:n}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+n),h=(r+o)/2-t,c=(a+l)/2-e,[d,p]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:p}},Rd=function(){for(const t of i(this,Fe).values())t.isEmpty()&&t.remove()},P(Cs,"_initialized",!1),g(Cs,rr,new Map([Mf,Uf,Xf,zd,Wf].map(t=>[t._editorType,t])));let jd=Cs;var Os,Se,Pa,Oc,cu,lb,gi,Jf,hb,Zf;const jt=class jt{constructor({pageIndex:t}){g(this,gi);g(this,Os,null);g(this,Se,new Map);g(this,Pa,new Map);this.pageIndex=t}setParent(t){if(!i(this,Os)){f(this,Os,t);return}if(i(this,Os)!==t){if(i(this,Se).size>0)for(const e of i(this,Se).values())e.remove(),t.append(e);f(this,Os,t)}}static get _svgFactory(){return Y(this,"_svgFactory",new ih)}draw(t,e=!1,s=!1){const n=zt(jt,Oc)._++,r=m(this,gi,Jf).call(this),a=jt._svgFactory.createElement("defs");r.append(a);const o=jt._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&i(this,Pa).set(n,o);const h=s?m(this,gi,hb).call(this,a,l):null,c=jt._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),i(this,Se).set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=zt(jt,Oc)._++,n=m(this,gi,Jf).call(this),r=jt._svgFactory.createElement("defs");n.append(r);const a=jt._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=jt._svgFactory.createElement("mask");r.append(d),l=`mask_p${this.pageIndex}_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const p=jt._svgFactory.createElement("rect");d.append(p),p.setAttribute("width","1"),p.setAttribute("height","1"),p.setAttribute("fill","white");const b=jt._svgFactory.createElement("use");d.append(b),b.setAttribute("href",`#${o}`),b.setAttribute("stroke","none"),b.setAttribute("fill","black"),b.setAttribute("fill-rule","nonzero"),b.classList.add("mask")}const h=jt._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return n.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(n,t),i(this,Se).set(s,n),s}finalizeDraw(t,e){i(this,Pa).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:n,rootClass:r,path:a}=e,o=typeof t=="number"?i(this,Se).get(t):t;if(o){if(s&&m(this,gi,Zf).call(this,o,s),n&&m(l=jt,cu,lb).call(l,o,n),r){const{classList:h}=o;for(const[c,d]of Object.entries(r))h.toggle(c,d)}if(a){const c=o.firstChild.firstChild;m(this,gi,Zf).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=i(this,Se).get(t);s&&(i(e,Os).append(s),i(this,Se).delete(t),i(e,Se).set(t,s))}remove(t){i(this,Pa).delete(t),i(this,Os)!==null&&(i(this,Se).get(t).remove(),i(this,Se).delete(t))}destroy(){f(this,Os,null);for(const t of i(this,Se).values())t.remove();i(this,Se).clear(),i(this,Pa).clear()}};Os=new WeakMap,Se=new WeakMap,Pa=new WeakMap,Oc=new WeakMap,cu=new WeakSet,lb=function(t,[e,s,n,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*n}%`,a.height=`${100*r}%`},gi=new WeakSet,Jf=function(){const t=jt._svgFactory.create(1,1,!0);return i(this,Os).append(t),t.setAttribute("aria-hidden",!0),t},hb=function(t,e){const s=jt._svgFactory.createElement("clipPath");t.append(s);const n=`clip_${e}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const r=jt._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),n},Zf=function(t,e){for(const[s,n]of Object.entries(e))n===null?t.removeAttribute(s):t.setAttribute(s,n)},g(jt,cu),g(jt,Oc,0);
12let Vd=jt;globalThis._pdfjsTestingUtils={HighlightOutliner:Rf};globalThis.pdfjsLib={AbortException:on,AnnotationEditorLayer:jd,AnnotationEditorParamsType:Z,AnnotationEditorType:j,AnnotationEditorUIManager:or,AnnotationLayer:Ud,AnnotationMode:nn,AnnotationType:It,applyOpacity:rg,build:cm,ColorPicker:sh,createValidAbsoluteUrl:tp,CSSConstants:ng,DOMSVGFactory:ih,DrawLayer:Vd,FeatureTest:ee,fetchData:_l,findContrastColor:ag,getDocument:am,getFilenameFromUrl:eg,getPdfFilenameFromUrl:sg,getRGB:Sl,getUuid:sp,getXfaPageViewport:ig,GlobalWorkerOptions:fi,ImageKind:Kl,InvalidPDFException:Ld,isDataScheme:$c,isPdfFile:pu,isValidExplicitDest:Hg,MathClamp:Ae,noContextMenu:rs,normalizeUnicode:Zp,OPS:yl,OutputScale:Hs,PasswordResponses:Qp,PDFDataRangeTransport:hp,PDFDateString:th,PDFWorker:vl,PermissionFlag:Kp,PixelsPerInch:ln,RenderingCancelledException:fu,renderRichText:rp,ResponseException:Jl,setLayerDimensions:ar,shadow:Y,SignatureExtractor:pi,stopEvent:Pt,SupportedImageMimeTypes:Id,TextLayer:wl,TouchManager:eh,updateUrlHash:ep,Util:N,VerbosityLevel:Bc,version:hm,XfaLayer:np};const ZA=Object.freeze(Object.defineProperty({__proto__:null,AbortException:on,AnnotationEditorLayer:jd,AnnotationEditorParamsType:Z,AnnotationEditorType:j,AnnotationEditorUIManager:or,AnnotationLayer:Ud,AnnotationMode:nn,AnnotationType:It,CSSConstants:ng,ColorPicker:sh,DOMSVGFactory:ih,DrawLayer:Vd,FeatureTest:ee,GlobalWorkerOptions:fi,ImageKind:Kl,InvalidPDFException:Ld,MathClamp:Ae,OPS:yl,OutputScale:Hs,PDFDataRangeTransport:hp,PDFDateString:th,PDFWorker:vl,PasswordResponses:Qp,PermissionFlag:Kp,PixelsPerInch:ln,RenderingCancelledException:fu,ResponseException:Jl,SignatureExtractor:pi,SupportedImageMimeTypes:Id,TextLayer:wl,TouchManager:eh,Util:N,VerbosityLevel:Bc,XfaLayer:np,applyOpacity:rg,build:cm,createValidAbsoluteUrl:tp,fetchData:_l,findContrastColor:ag,getDocument:am,getFilenameFromUrl:eg,getPdfFilenameFromUrl:sg,getRGB:Sl,getUuid:sp,getXfaPageViewport:ig,isDataScheme:$c,isPdfFile:pu,isValidExplicitDest:Hg,noContextMenu:rs,normalizeUnicode:Zp,renderRichText:rp,setLayerDimensions:ar,shadow:Y,stopEvent:Pt,updateUrlHash:ep,version:hm},Symbol.toStringTag,{value:"Module"}));export{Ud as A,fi as G,wl as T,nn as a,am as g,ZA as p};
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.