1var gy=Object.defineProperty;var Kp=d=>{throw TypeError(d)};var my=(d,t,e)=>t in d?gy(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e;var R=(d,t,e)=>my(d,typeof t!="symbol"?t+"":t,e),Wu=(d,t,e)=>t.has(d)||Kp("Cannot "+e);var i=(d,t,e)=>(Wu(d,t,"read from private field"),e?e.call(d):t.get(d)),g=(d,t,e)=>t.has(d)?Kp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(d):t.set(d,e),f=(d,t,e,s)=>(Wu(d,t,"write to private field"),s?s.call(d,e):t.set(d,e),e),m=(d,t,e)=>(Wu(d,t,"access private method"),e);var Kt=(d,t,e,s)=>({set _(n){f(d,t,n,e)},get _(){return i(d,t,s)}});import{j as jt}from"./state-DKBP_IF5.js";import{g as by,r as j}from"./react-vendor-Unhn4PzF.js";import{i as wt,c as Iu}from"./charts-D5dg506X.js";window.CESIUM_BASE_URL="/cesium/";const Fe=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),sf=[.001,0,0,.001,0,0],Xu=1.35,ms={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Ri={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},yh="pdfjs_internal_editor_",X={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},et={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},Ig={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},he={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},bh={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Gt={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},Ja={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},ad={ERRORS:0,WARNINGS:1,INFOS:5},Ul={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},gd={moveTo:0,lineTo:1,curveTo:2,closePath:3},Fg={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Fu=ad.WARNINGS;function yy(d){Number.isInteger(d)&&(Fu=d)}function Ay(){return Fu}function Nu(d){Fu>=ad.INFOS&&console.info(`Info: ${d}`)}function q(d){Fu>=ad.WARNINGS&&console.warn(`Warning: ${d}`)}function Et(d){throw new Error(d)}function it(d,t){d||Et(t)}function wy(d){switch(d?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function kp(d,t=null,e=null){if(!d)return null;
1if(e&&typeof d=="string"&&(e.addDefaultProtocol&&d.startsWith("www.")&&d.match(/\./g)?.length>=2&&(d=`http://${d}`),e.tryConvertEncoding))try{d=Cy(d)}catch{}const s=t?URL.parse(d,t):URL.parse(d);return wy(s)?s:null}function Rp(d,t,e=!1){const s=URL.parse(d);return s?(s.hash=t,s.href):e&&kp(d,"http://example.com")?d.split("#",1)[0]+`${t?`#${t}`:""}`:""}function J(d,t,e,s=!1){return Object.defineProperty(d,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Xa=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Jp extends Xa{constructor(t,e){super(t,"PasswordException"),this.code=e}}class qu extends Xa{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class iu extends Xa{constructor(t){super(t,"InvalidPDFException")}}class Ah extends Xa{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class vy extends Xa{constructor(t){super(t,"FormatError")}}class vn extends Xa{constructor(t){super(t,"AbortException")}}function Ng(d){(typeof d!="object"||d?.length===void 0)&&Et("Invalid argument for bytesToString");const t=d.length,e=8192;if(t<e)return String.fromCharCode.apply(null,d);const s=[];for(let n=0;n<t;n+=e){const r=Math.min(n+e,t),a=d.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function od(d){typeof d!="string"&&Et("Invalid argument for stringToBytes");const t=d.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=d.charCodeAt(s)&255;return e}function Ey(d){return String.fromCharCode(d>>24&255,d>>16&255,d>>8&255,d&255)}function Sy(){const d=new Uint8Array(4);return d[0]=1,new Uint32Array(d.buffer,0,1)[0]===1}function _y(){try{return new Function(""),!0}catch{return!1}}class le{static get isLittleEndian(){return J(this,"isLittleEndian",Sy())}static get isEvalSupported(){return J(this,"isEvalSupported",_y())}static get isOffscreenCanvasSupported(){return J(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return J(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return J(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return J(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Yu=Array.from(Array(256).keys(),d=>d.toString(16).padStart(2,"0"));var An,Cd,nf;class O{static makeHexColor(t,e,s){return`#${Yu[t]}${Yu[e]}${Yu[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 u=t[s+c],p=t[s+c+1];t[s+c]=u*n+p*a+l,t[s+c+1]=u*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],u=t[1],p=t[2],b=t[3];let A=n*c+l,y=A,v=n*p+l,w=v,E=o*u+h,S=E,_=o*b+h,C=_;if(r!==0||a!==0){const T=r*c,x=r*p,P=a*u,k=a*b;A+=P,w+=P,v+=k,y+=k,E+=T,C+=T,_+=x,S+=x}s[0]=Math.min(s[0],A,v,y,w),s[1]=Math.min(s[1],E,_,S,C),s[2]=Math.max(s[2],A,v,y,w),s[3]=Math.max(s[3],E,_,S,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+
1a**2,c=(o+h)/2,u=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+u||1),e[1]=Math.sqrt(c-u||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,An,nf).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,An,nf).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)}}An=new WeakSet,Cd=function(t,e,s,n,r,a,o,l,h,c){if(h<=0||h>=1)return;const u=1-h,p=h*h,b=p*h,A=u*(u*(u*t+3*h*e)+3*p*s)+b*n,y=u*(u*(u*r+3*h*a)+3*p*o)+b*l;c[0]=Math.min(c[0],A),c[1]=Math.min(c[1],y),c[2]=Math.max(c[2],A),c[3]=Math.max(c[3],y)},nf=function(t,e,s,n,r,a,o,l,h,c,u,p){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&m(this,An,Cd).call(this,t,e,s,n,r,a,o,l,-u/c,p);return}const b=c**2-4*u*h;if(b<0)return;const A=Math.sqrt(b),y=2*h;m(this,An,Cd).call(this,t,e,s,n,r,a,o,l,(-c+A)/y,p),m(this,An,Cd).call(this,t,e,s,n,r,a,o,l,(-c-A)/y,p)},g(O,An);function Cy(d){return decodeURIComponent(escape(d))}let Ku=null,Qp=null;function Og(d){return Ku||(Ku=/([\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,Qp=new Map([["ï¬
","ſt"]])),d.replaceAll(Ku,(t,e,s)=>e?e.normalize("NFKC"):Qp.get(s))}function Mp(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const d=new Uint8Array(32);return crypto.getRandomValues(d),Ng(d)}const Dp="pdfjs_internal_id_";function Ty(d,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,n,...r]=e;if(!d(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 Te(d,t,e){return Math.min(Math.max(d,t),e)}function Bg(d){return Uint8Array.prototype.toBase64?d.toBase64():btoa(Ng(d))}function xy(d){return Uint8Array.fromBase64?Uint8Array.fromBase64(d):od(atob(d))}typeof Promise.try!="function"&&(Promise.try=function(d,...t){return new Promise(e=>{e(d(...t))})});typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(d){return d.reduce((t,e)=>t+e,0)});class wh{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function n(r){if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(wh.shouldBuildText(o))r?.attributes?.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const l of r.children)n(l)}return n(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class Lp{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){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 u=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=u}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(n.children.length===0){if(n.value){const u=document.createTextNode(n.value);a.append(u),o&&wh.shouldBuildText(n.name)&&h.push(u)}return{textDivs:h}}const c=[[n,-1,a]];for(;c.length>0;){const[u,p,b]=c.at(-1);if(p+1===u.children.length){c.pop();continue}const A=u.children[++c.at(-1)[1]];if(A===null)continue;const{name:y}=A;if(y==="#text"){const w=document.createTextNode(A.value);h.push(w),b.append(w);continue}const v=A?.attributes?.xmlns?document.createElementNS(A.attributes.xmlns,y):document.createElement(y);if(b.append(v),A.attributes&&this.setAttributes({html:v,element:A,storage:e,intent:r,linkService:s}),A.children?.length>0)c.push([A,-1,v]);else if(A.value){const w=document.createTextNode(A.value);o&&wh.shouldBuildText(y)&&h.push(w),v.append(w)}}for(const u of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))u.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 Li="http://www.w3.org/2000/svg",Rr=class Rr{};R(Rr,"CSS",96),R(Rr,"PDF",72),R(Rr,"PDF_TO_CSS_UNITS",Rr.CSS/Rr.PDF);let En=Rr;async function Gl(d,t="text"){if(Kl(d,document.baseURI)){const e=await fetch(d);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",d,!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 ld{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,u,p,b;switch(n%=360,n<0&&(n+=360),n){case 180:c=-1,u=0,p=0,b=1;break;case 90:c=0,u=1,p=1,b=0;break;case 270:c=0,u=-1,p=-1,b=0;break;case 0:c=1,u=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 A,y,v,w;c===0?(A=Math.abs(h-t[1])*s+r,y=Math.abs(l-t[0])*s+a,v=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(A=Math.abs(l-t[0])*s+r,y=Math.abs(h-t[1])*s+a,v=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,u*s,p*s,b*s,A-c*s*l-p*s*h,y-u*s*l-b*s*h],this.width=v,this.height=w}get rawDims(){const t=this.viewBox;return J(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 ld({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 O.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];O.applyTransform(e,this.transform);const s=[t[2],t[3]];return O.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return O.applyInverseTransform(s,this.transform),s}}class Ou extends Xa{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function hd(d){const t=d.length;let e=0;for(;e<t&&d[e].trim()==="";)e++;return d.substring(e,e+5).toLowerCase()==="data:"}
1function Bu(d){return typeof d=="string"&&/\.pdf$/i.test(d)}function Hg(d){return[d]=d.split(/[#?]/,1),d.substring(d.lastIndexOf("/")+1)}function Ug(d,t="document.pdf"){if(typeof d!="string")return t;if(hd(d))return q('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}}}}})(d);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 Zp{constructor(){R(this,"started",Object.create(null));R(this,"times",[])}time(t){t in this.started&&q(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||q(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:n,end:r}of this.times)t.push(`${s.padEnd(e)} ${r-n}ms 2`);return t.join("")}}function Kl(d,t){const e=t?URL.parse(d,t):URL.parse(d);return e?.protocol==="http:"||e?.protocol==="https:"}function ws(d){d.preventDefault()}function Ft(d){d.preventDefault(),d.stopPropagation()}function Py(d){console.log("Deprecated API usage: "+d)}var Th;class vh{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;i(this,Th)||f(this,Th,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=i(this,Th).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";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,h==="-"?(a+=c,o+=u):h==="+"&&(a-=c,o-=u),new Date(Date.UTC(s,n,r,a,o,l))}}Th=new WeakMap,g(vh,Th);function $g(d,{scale:t=1,rotation:e=0}){const{width:s,height:n}=d.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new ld({viewBox:r,userUnit:1,scale:t,rotation:e})}function zl(d){if(d.startsWith("#")){const t=parseInt(d.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return d.startsWith("rgb(")?d.slice(4,-1).split(",").map(t=>parseInt(t)):d.startsWith("rgba(")?d.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(q(`Not a valid color format: "${d}"`),[0,0,0])}function ky(d){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of d.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;d.set(e,zl(s))}t.remove()}function It(d){const{a:t,b:e,c:s,d:n,e:r,f:a}=d.getTransform();return[t,e,s,n,r,a]}function ni(d){const{a:t,b:e,c:s,d:n,e:r,f:a}=d.getTransform().invertSelf();return[t,e,s,n,r,a]}function Er(d,t,e=!1,s=!0){if(t instanceof ld){const{pageWidth:n,pageHeight:r}=t.rawDims,{style:a}=d,o=le.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})`,u=o?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=c,a.height=u):(a.width=u,a.height=c)}s&&d.setAttribute("data-main-rotation",t.rotation)}class si{constructor(){const{pixelRatio:t}=si;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=si.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>
2=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 nu=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Ry{static get isDarkMode(){return J(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class jg{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(),J(this,"commentForegroundColor",zl(s))}}function Gg(d,t,e,s){s=Math.min(Math.max(s??1,0),1);const n=255*(1-s);return d=Math.round(d*s+n),t=Math.round(t*s+n),e=Math.round(e*s+n),[d,t,e]}function tg(d,t){const e=d[0]/255,s=d[1]/255,n=d[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 rf(d,t){const e=d[0],s=d[1],n=d[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 eg(d){return d<=.03928?d/12.92:((d+.055)/1.055)**2.4}function sg(d,t,e){rf(d,e),e.map(eg);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];rf(t,e),e.map(eg);const n=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const ig=new Map;function zg(d,t){const e=d[0]+d[1]*256+d[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=ig.get(e);if(s)return s;const n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);tg(d,a);const o=n.subarray(6,9);tg(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]),sg(a,o,r)<h){let c,u;l?(c=a[2],u=1):(c=0,u=a[2]);const p=.005;for(;u-c>p;){const b=a[2]=(c+u)/2;l===sg(a,o,r)<h?c=b:u=b}a[2]=l?u:c}return rf(a,r),s=O.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),ig.set(e,s),s}function Ip({html:d,dir:t,className:e},s){const n=document.createDocumentFragment();if(typeof d=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=d.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 Lp.render({xfaHtml:d,div:n,intent:"richText"});n.firstChild.classList.add("richText",e),s.append(n)}var Pn,kn,Cs,Ts,xh,Rn,po,go,Ph,gu,Vg,be,Wg,Xg,Qa,Jl;const Ni=class Ni{constructor(t){g(this,be);g(this,Pn,null);g(this,kn,null);g(this,Cs);g(this,Ts,null);g(this,xh,null);g(this,Rn,null);g(this,po,null);g(this,go,null);f(this,Cs,t),i(Ni,Ph)||f(Ni,Ph,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,Pn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=i(this,Cs)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",ws,{signal:e}),t.addEventListener("pointerdown",m(Ni,gu,Vg),{signal:e}));const s=f(this,Ts,document.createElement("div"));s.className="buttons",t.append(s);const n=i(this,Cs).toolbarPosition;if(n){const{style:r}=t,a=i(this,Cs)._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,Pn)}hide(){i(this,Pn).classList.add("hidden"),i(this,kn)?.hideDropdown()}show(){i(this,Pn).classList.remove("hidden"),i(this,xh)?.shown(),i(this,Rn)?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=i(this,Cs),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",i(Ni,Ph)[t]),m(this,be,Qa).call(this,s)&&s.addEventListener("click",n=>{e.delete()},{signal:e._signal}),i(this,Ts).append(s)}async addAltText(t){const e=await t.render();
2m(this,be,Qa).call(this,e),i(this,Ts).append(e,i(this,be,Jl)),f(this,xh,t)}addComment(t,e=null){if(i(this,Rn))return;const s=t.renderForToolbar();if(!s)return;m(this,be,Qa).call(this,s);const n=f(this,po,i(this,be,Jl));e?(i(this,Ts).insertBefore(s,e),i(this,Ts).insertBefore(n,e)):i(this,Ts).append(s,n),f(this,Rn,t),t.toolbar=this}addColorPicker(t){if(i(this,kn))return;f(this,kn,t);const e=t.renderButton();m(this,be,Qa).call(this,e),i(this,Ts).append(e,i(this,be,Jl))}async addEditSignatureButton(t){const e=f(this,go,await t.renderEditButton(i(this,Cs)));m(this,be,Qa).call(this,e),i(this,Ts).append(e,i(this,be,Jl))}removeButton(t){switch(t){case"comment":i(this,Rn)?.removeToolbarCommentButton(),f(this,Rn,null),i(this,po)?.remove(),f(this,po,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,Ts).querySelector(s);n&&t==="comment"&&this.addComment(e,n)}updateEditSignatureButton(t){i(this,go)&&(i(this,go).title=t)}remove(){i(this,Pn).remove(),i(this,kn)?.destroy(),f(this,kn,null)}};Pn=new WeakMap,kn=new WeakMap,Cs=new WeakMap,Ts=new WeakMap,xh=new WeakMap,Rn=new WeakMap,po=new WeakMap,go=new WeakMap,Ph=new WeakMap,gu=new WeakSet,Vg=function(t){t.stopPropagation()},be=new WeakSet,Wg=function(t){i(this,Cs)._focusEventsAllowed=!1,Ft(t)},Xg=function(t){i(this,Cs)._focusEventsAllowed=!0,Ft(t)},Qa=function(t){const e=i(this,Cs)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",m(this,be,Wg).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",m(this,be,Xg).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ws,{signal:e}),!0)},Jl=function(){const t=document.createElement("div");return t.className="divider",t},g(Ni,gu),g(Ni,Ph,null);let af=Ni;var kh,Lr,Bi,Sn,qg,Yg,of;class My{constructor(t){g(this,Sn);g(this,kh,null);g(this,Lr,null);g(this,Bi);f(this,Bi,t)}show(t,e,s){const[n,r]=m(this,Sn,Yg).call(this,e,s),{style:a}=i(this,Lr)||f(this,Lr,m(this,Sn,qg).call(this));t.append(i(this,Lr)),a.insetInlineEnd=`${100*n}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){i(this,Lr).remove()}}kh=new WeakMap,Lr=new WeakMap,Bi=new WeakMap,Sn=new WeakSet,qg=function(){const t=f(this,Lr,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=i(this,Bi)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",ws,{signal:e});const s=f(this,kh,document.createElement("div"));return s.className="buttons",t.append(s),i(this,Bi).hasCommentManager()&&m(this,Sn,of).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{i(this,Bi).commentSelection("floating_button")}),m(this,Sn,of).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{i(this,Bi).highlightSelection("floating_button")}),t},Yg=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]},of=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,Bi)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",ws,{signal:o}),r.addEventListener("click",n,{signal:o})),i(this,kh).append(r)};function Kg(d,t,e){for(const s of e)t.addEventListener(s,d[s].bind(d))}var mu;class Dy{constructor(){g(this,mu,0)}get id(){return`${yh}${Kt(this,mu)._++}`}}mu=new WeakMap;var mo,Rh,we,bo,Td;const Vp=class Vp{constructor(){g(this,bo);g(this,mo,Mp());g(this,Rh,0);g(this,we,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(()=>
2(s.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return J(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:n,type:r}=t;return m(this,bo,Td).call(this,`${e}_${s}_${n}_${r}`,t)}async getFromUrl(t){return m(this,bo,Td).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,bo,Td).call(this,t,s)}async getFromId(t){i(this,we)||f(this,we,new Map);const e=i(this,we).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,we)||f(this,we,new Map);let s=i(this,we).get(t);if(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,mo)}_${Kt(this,Rh)._++}`,refCounter:1,isSvg:!1},i(this,we).set(t,s),i(this,we).set(s.id,s),s}getSvgUrl(t){const e=i(this,we).get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){i(this,we)||f(this,we,new Map);const e=i(this,we).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(s.width,s.height);n.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=n.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${i(this,mo)}_`)}};mo=new WeakMap,Rh=new WeakMap,we=new WeakMap,bo=new WeakSet,Td=async function(t,e){i(this,we)||f(this,we,new Map);let s=i(this,we).get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${i(this,mo)}_${Kt(this,Rh)._++}`,refCounter:0,isSvg:!1});let n;if(typeof e=="string"?(s.url=e,n=await Gl(e,"blob")):e instanceof File?n=s.file=e:e instanceof Blob&&(n=e),n.type==="image/svg+xml"){const r=Vp._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 u=s.svgUrl=a.result;o.src=await r?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=c});a.readAsDataURL(n),await l}else s.bitmap=await createImageBitmap(n);s.refCounter=1}catch(n){q(n),s=null}return i(this,we).set(t,s),s&&i(this,we).set(s.id,s),s};let lf=Vp;var zt,Mn,Mh,Lt;class Ly{constructor(t=128){g(this,zt,[]);g(this,Mn,!1);g(this,Mh);g(this,Lt,-1);f(this,Mh,t)}add({cmd:t,undo:e,post:s,mustExec:n,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(n&&t(),i(this,Mn))return;const l={cmd:t,undo:e,post:s,type:r};if(i(this,Lt)===-1){i(this,zt).length>0&&(i(this,zt).length=0),f(this,Lt,0),i(this,zt).push(l);return}if(a&&i(this,zt)[i(this,Lt)].type===r){o&&(l.undo=i(this,zt)[i(this,Lt)].undo),i(this,zt)[i(this,Lt)]=l;return}const h=i(this,Lt)+1;h===i(this,Mh)?i(this,zt).splice(0,1):(f(this,Lt,h),h<i(this,zt).length&&i(this,zt).splice(h)),i(this,zt).push(l)}undo(){if(i(this,Lt)===-1)return;f(this,Mn,!0);const{undo:t,post:e}=i(this,zt)[i(this,Lt)];t(),e?.(),f(this,Mn,!1),f(this,Lt,i(this,Lt)-1)}redo(){if(i(this,Lt)<i(this,zt).length-1){f(this,Lt,i(this,Lt)+1),f(this,Mn,!0);const{cmd:t,post:e}=i(this,zt)[i(this,Lt)];t(),e?.(),f(this,Mn,!1)}}hasSomethingToUndo(){return i(this,Lt)!==-1}hasSomethingToRedo(){return i(this,Lt)<i(this,zt).length-1}cleanType(t){if(i(this,Lt)!==-1){for(let e=i(this,Lt);e>=0;e--)if(i(this,zt)[e].type!==t){i(this,zt).splice(e+1,i(this,Lt)-e),f(this,Lt,e);return}i(this,zt).length=0,f(this,Lt,-1)}}destroy(){f(this,zt,null)}}zt=new WeakMap,Mn=new WeakMap,Mh=new WeakMap,Lt=new WeakMap;var bu,Jg;class cd{constructor(t){g(this,bu);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=le.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,bu,Jg).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||Ft(e))}}bu=new WeakSet,Jg=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 yu=class yu{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return ky(t),J(this,"_colors",t)}convert(t){const e=zl(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 yu._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?O.makeHexColor(...e):t}};R(yu,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let hf=yu;var yo,Ze,Ao,Ot,Qt,wo,xs,vo,Ps,ve,Dn,Ln,Eo,In,oi,ks,Ir,Dh,Lh,So,Ih,li,Fn,_o,Nn,hi,Au,On,Co,Fh,Bn,Fr,To,Hn,Nh,Xt,ht,Hi,Un,$n,Oh,xo,Bh,jn,ci,Ui,Hh,Uh,Rs,L,xd,cf,Qg,Zg,Ql,tm,em,sm,df,im,uf,ff,nm,Re,Ii,rm,am,pf,om,Zl,gf;const ao=class ao{constructor(t,e,s,n,r,a,o,l,h,c,u,p,b,A,y,v){g(this,L);g(this,yo,new AbortController);g(this,Ze,null);g(this,Ao,null);g(this,Ot,new Map);g(this,Qt,new Map);g(this,wo,null);g(this,xs,null);g(this,vo,null);g(this,Ps,new Ly);g(this,ve,null);g(this,Dn,null);g(this,Ln,null);g(this,Eo,0);g(this,In,new Set);g(this,oi,null);g(this,ks,null);g(this,Ir,new Set);R(this,"_editorUndoBar",null);g(this,Dh,!1);g(this,Lh,!1);g(this,So,!1);g(this,Ih,null);g(this,li,null);g(this,Fn,null);g(this,_o,null);g(this,Nn,!1);g(this,hi,null);g(this,Au,new Dy);g(this,On,!1);g(this,Co,!1);g(this,Fh,!1);g(this,Bn,null);g(this,Fr,null);g(this,To,null);g(this,Hn,null);g(this,Nh,null);g(this,Xt,X.NONE);g(this,ht,new Set);g(this,Hi,null);g(this,Un,null);g(this,$n,null);g(this,Oh,null);g(this,xo,null);g(this,Bh,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});g(this,jn,[0,0]);g(this,ci,null);g(this,Ui,null);g(this,Hh,null);g(this,Uh,null);g(this,Rs,null);const w=this._signal=i(this,yo).signal;f(this,Ui,t),f(this,Hh,e),f(this,Uh,s),f(this,wo,n),f(this,ve,r),f(this,Un,a),f(this,xo,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",E=>this.updateParams(E.type,E.value),{signal:w}),window.addEventListener("pointerdown",()=>{f(this,Co,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{f(this,Co,!1)},{capture:!0,signal:w}),m(this,L,tm).call(this),m(this,L,nm).call(this),m(this,L,df).call(this),f(this,xs,l.annotationStorage),f(this,Ih,l.filterFactory),f(this,$n,h),f(this,_o,c||null),f(this,Dh,u),f(this,Lh,p),f(this,So,b),f(this,Nh,A||null),this.viewParameters={realScale:En.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=y||null,this._supportsPinchToZoom=v!==!1,r?.setSidebarUiManager(this)}static get _keyboardManager(){const t=ao.prototype,e=a=>i(a,Ui).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 J(this,"_keyboardManager",new cd([[["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,Ui).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&i(a,Ui).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(){i(this,Rs)?.resolve(),f(this,Rs,null),i(this,yo)?.abort(),f(this,yo,null),this._signal=null;
2for(const t of i(this,Qt).values())t.destroy();i(this,Qt).clear(),i(this,Ot).clear(),i(this,Ir).clear(),i(this,Hn)?.clear(),f(this,Ze,null),i(this,ht).clear(),i(this,Ps).destroy(),i(this,wo)?.destroy(),i(this,ve)?.destroy(),i(this,Un)?.destroy(),i(this,hi)?.hide(),f(this,hi,null),i(this,To)?.destroy(),f(this,To,null),f(this,Ao,null),i(this,li)&&(clearTimeout(i(this,li)),f(this,li,null)),i(this,ci)&&(clearTimeout(i(this,ci)),f(this,ci,null)),this._editorUndoBar?.destroy(),f(this,xo,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return i(this,Nh)}get useNewAltTextFlow(){return i(this,Lh)}get useNewAltTextWhenAddingImage(){return i(this,So)}get hcmFilter(){return J(this,"hcmFilter",i(this,$n)?i(this,Ih).addHCMFilter(i(this,$n).foreground,i(this,$n).background):"none")}get direction(){return J(this,"direction",getComputedStyle(i(this,Ui)).direction)}get _highlightColors(){return J(this,"_highlightColors",i(this,_o)?new Map(i(this,_o).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 J(this,"highlightColors",null);const e=new Map,s=!!i(this,$n);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 J(this,"highlightColors",e)}get highlightColorNames(){return J(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,Ln,t)}setMainHighlightColorPicker(t){f(this,To,t)}editAltText(t,e=!1){i(this,wo)?.editAltText(this,t,e)}hasCommentManager(){return!!i(this,ve)}editComment(t,e,s,n){i(this,ve)?.showDialog(this,t,e,s,n)}selectComment(t,e){i(this,Qt).get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){i(this,ve)?.updateComment(t.getData())}updatePopupColor(t){i(this,ve)?.updatePopupColor(t)}removeComment(t){i(this,ve)?.removeComments([t.uid])}toggleComment(t,e,s=void 0){i(this,ve)?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&i(this,ve)?.makeCommentColor(t,e)||null}getCommentDialogElement(){return i(this,ve)?.dialogElement||null}async waitForEditorsRendered(t){if(i(this,Qt).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){i(this,Un)?.getSignature({uiManager:this,editor:t})}get signatureManager(){return i(this,Un)}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,Ui).focus()}findParent(t,e){for(const s of i(this,Qt).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,Hh).classList.toggle("noUserSelect",t)}addShouldRescale(t){i(this,Ir).add(t)}removeShouldRescale(t){i(this,Ir).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*En.PDF_TO_CSS_UNITS;for(const e of i(this,Ir))e.onScaleChanging();i(this,Ln)?.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,L,xd).call(this,s).closest(".textLayer"),u=this.getSelectionBoxes(c);if(!u)return;s.empty();const p=m(this,L,cf).call(this,c),b=i(this,Xt)===X.NONE,A=()=>{const y=p?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o,text:l});b&&this.showAllEditors("highlight",!0,!0),e&&y?.editComment()};if(b){this.switchToMode(X.HIGHLIGHT,A);return}A()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!i(this,xs))return null;const e=`${yh}${t}`,s=i(this,xs).getRawValue(e);return s&&i(this,xs).remove(e),s}
2addToAnnotationStorage(t){!t.isEmpty()&&i(this,xs)&&!i(this,xs).has(t.id)&&i(this,xs).setValue(t.id,t)}a11yAlert(t,e=null){const s=i(this,Uh);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,Nn)&&(f(this,Nn,!1),m(this,L,Ql).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of i(this,ht))if(e.div.contains(t)){f(this,Fr,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!i(this,Fr))return;const[t,e]=i(this,Fr);f(this,Fr,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,L,df).call(this),m(this,L,uf).call(this)}removeEditListeners(){m(this,L,im).call(this),m(this,L,ff).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of i(this,ks))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,ks))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),i(this,Ze)?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of i(this,ht)){const n=s.serialize(!0);n&&e.push(n)}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,ks))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){q(`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,L,pf).call(this,l);m(this,L,gf).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){q(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),i(this,Xt)!==X.NONE&&!this.isEditorHandlingKeyboard&&ao._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,i(this,Nn)&&(f(this,Nn,!1),m(this,L,Ql).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,L,em).call(this),m(this,L,uf).call(this),m(this,L,Re).call(this,{isEditing:i(this,Xt)!==X.NONE,isEmpty:m(this,L,Zl).call(this),hasSomethingToUndo:i(this,Ps).hasSomethingToUndo(),hasSomethingToRedo:i(this,Ps).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,L,sm).call(this),m(this,L,ff).call(this),m(this,L,Re).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!i(this,ks)){f(this,ks,t);for(const e of i(this,ks))m(this,L,Ii).call(this,e.defaultPropertiesToUpdate)}}getId(){return i(this,Au).id}get currentLayer(){return i(this,Qt).get(i(this,Eo))}getLayer(t){return i(this,Qt).get(t)}get currentPageIndex(){return i(this,Eo)}addLayer(t){i(this,Qt).set(t.pageIndex,t),i(this,On)?t.enable():t.disable()}removeLayer(t){i(this,Qt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,n=!1,r=!1){if(i(this,Xt)!==t&&!(i(this,Rs)&&(await i(this,Rs).promise,!i(this,Rs)))){if(f(this,Rs,Promise.withResolvers()),i(this,Ln)?.commitOrRemove(),i(this,Xt)===X.POPUP&&i(this,ve)?.hideSidebar(),i(this,ve)?.destroyPopup(),f(this,Xt,t),t===X.NONE){this.setEditingState(!1),m(this,L,am).call(this);for(const a of i(this,Ot).values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),i(this,Rs).resolve();return}for(const a of i(this,Ot).values())a.addStandaloneCommentButton();t===X.SIGNATURE&&await i(this,Un)?.loadSignatures(),this.setEditingState(!0),await m(this,L,rm).call(this),this.unselectAll();for(const a of i(this,Qt).values())a.updateMode(t);if(t===X.POPUP){i(this,Ao)||f(this,Ao,await i(this,xo).getAnnotationsByType(new Set(i(this,ks).map(l
2=>l._editorType))));const a=new Set,o=[];for(const l of i(this,Ot).values()){const{annotationElementId:h,hasComment:c,deleted:u}=l;h&&a.add(h),c&&!u&&o.push(l.getData())}for(const l of i(this,Ao)){const{id:h,popupRef:c,contentsObj:u}=l;c&&u?.str&&!a.has(h)&&!i(this,In).has(h)&&o.push(l)}i(this,ve)?.showSidebar(o)}if(!e){s&&this.addNewEditorFromKeyboard(),i(this,Rs).resolve();return}for(const a of i(this,Ot).values())a.uid===e?(this.setSelected(a),r?a.editComment():n?a.enterInEditMode():a.focus()):a.unselect();i(this,Rs).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==i(this,Xt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(i(this,ks)){switch(t){case et.CREATE:this.currentLayer.addNewEditor(e);return;case et.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(i(this,Oh)||f(this,Oh,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of i(this,ht))s.updateParams(t,e);else for(const s of i(this,ks))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const r of i(this,Ot).values())r.editorType===t&&r.show(e);(i(this,Oh)?.get(et.HIGHLIGHT_SHOW_ALL)??!0)!==e&&m(this,L,Ii).call(this,[[et.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(i(this,Fh)!==t){f(this,Fh,t);for(const e of i(this,Qt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of i(this,Ot).values())e.pageIndex===t&&(yield e)}getEditor(t){return i(this,Ot).get(t)}addEditor(t){i(this,Ot).set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(i(this,li)&&clearTimeout(i(this,li)),f(this,li,setTimeout(()=>{this.focusMainContainer(),f(this,li,null)},0))),i(this,Ot).delete(t.id),t.annotationElementId&&i(this,Hn)?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!i(this,In).has(t.annotationElementId))&&i(this,xs)?.remove(t.id)}addDeletedAnnotationElement(t){i(this,In).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return i(this,In).has(t)}removeDeletedAnnotationElement(t){i(this,In).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){i(this,Ze)!==t&&(f(this,Ze,t),t&&m(this,L,Ii).call(this,t.propertiesToUpdate))}updateUI(t){i(this,L,om)===t&&m(this,L,Ii).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){m(this,L,Ii).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(i(this,ht).has(t)){i(this,ht).delete(t),t.unselect(),m(this,L,Re).call(this,{hasSelectedEditor:this.hasSelection});return}i(this,ht).add(t),t.select(),m(this,L,Ii).call(this,t.propertiesToUpdate),m(this,L,Re).call(this,{hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.id}),i(this,Ln)?.commitOrRemove();for(const e of i(this,ht))e!==t&&e.unselect();i(this,ht).clear(),i(this,ht).add(t),t.select(),m(this,L,Ii).call(this,t.propertiesToUpdate),m(this,L,Re).call(this,{hasSelectedEditor:!0})}isSelected(t){return i(this,ht).has(t)}get firstSelectedEditor(){return i(this,ht).values().next().value}unselect(t){t.unselect(),i(this,ht).delete(t),m(this,L,Re).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return i(this,ht).size!==0}get isEnterHandled(){return i(this,ht).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){i(this,Ps).undo(),m(this,L,Re).call(this,{hasSomethingToUndo:i(this,Ps).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,L,Zl).call(this)}),this._editorUndoBar?.hide()}redo(){i(this,Ps).redo(),m(this,L,Re).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:i(this,Ps).hasSomethingToRedo(),isEmpty:m(this,L,Zl).call(this)})}addCommands(t){i(this,Ps).add(t),m(this,L,Re).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,L,Zl).call(this)})}cleanUndoStack(t){i(this,Ps).cleanType(t)}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...i(this,ht)],s=()=>{this._editorUndoBar?.show(n,e.length===1?e[0].editorType:e.length);for(const r of e)r.remove()},n=()=>{for(const r of e)m(this,L,pf).call(this,r)};this.addCommands({cmd:s,undo:n,mustExec:!0})}commitOrRemove(){i(this,Ze)?.commitOrRemove()}hasSomethingToControl(){return i(this,Ze)||this.hasSelection}selectAll(){for(const t of i(this,ht))t.commit();m(this,L,gf).call(this,i(this,Ot).values())}unselectAll(){if(!(i(this,Ze)&&(i(this,Ze).commitOrRemove(),i(this,Xt)!==X.NONE))&&!i(this,Ln)?.commitOrRemove()&&this.hasSelection){for(const t of i(this,ht))t.unselect();i(this,ht).clear(),m(this,L,Re).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;i(this,jn)[0]+=t,i(this,jn)[1]+=e;const[n,r]=i(this,jn),a=[...i(this,ht)],o=1e3;i(this,ci)&&clearTimeout(i(this,ci)),f(this,ci,setTimeout(()=>{f(this,ci,null),i(this,jn)[0]=i(this,jn)[1]=0,this.addCommands({cmd:()=>{for(const l of a)i(this,Ot).has(l.id)&&(l.translateInPage(n,r),l.translationDone())},undo:()=>{for(const l of a)i(this,Ot).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,oi,new Map);for(const t of i(this,ht))i(this,oi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!i(this,oi))return!1;this.disableUserSelect(!1);const t=i(this,oi);f(this,oi,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,Ot).has(n.id)){const l=i(this,Qt).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,oi))for(const s of i(this,oi).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||i(this,ht).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return i(this,Ze)===t}getActive(){return i(this,Ze)}getMode(){return i(this,Xt)}isEditingMode(){return i(this,Xt)!==X.NONE}get imageManager(){return J(this,"imageManager",new lf)}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,u,p)=>({x:(c-n)/a,y:1-(h+u-s)/r,width:p/a,height:u/r});break;case"180":o=(h,c,u,p)=>({x:1-(h+u-s)/r,y:1-(c+p-n)/a,width:u/r,height:p/a});break;case"270":o=(h,c,u,p)=>({x:1-(c+p-n)/a,y:(h-s)/r,width:p/a,height:u/r});break;default:o=(h,c,u,p)=>({x:(h-s)/r,y:(c-n)/a,width:u/r,height:p/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const u=e.getRangeAt(h);if(!u.collapsed)for(const{x:p,y:b,width:A,height:y}of u.getClientRects())A===0||y===0||l.push(o(p,b,A,y))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(i(this,vo)||f(this,vo,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){i(this,vo)?.delete(t)}renderAnnotationElement(t){const e=i(this,vo)?.get(t.data.id);if(!e)return;const s=i(this,xs).getRawValue(e);s&&(i(this,Xt)===X.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){const n=i(this,Hn)?.get(t);n&&(n.setCanvas(e,s),i(this,Hn).delete(t))}addMissingCanvas(t,e){(i(this,Hn)||f(this,Hn,new Map)).set(t,e)}};yo=new WeakMap,Ze=new WeakMap,Ao=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,wo=new WeakMap,xs=new WeakMap,vo=new WeakMap,Ps=new WeakMap,ve=new WeakMap,Dn=new WeakMap,Ln=new WeakMap,Eo=new WeakMap,In=new WeakMap,oi=new WeakMap,ks=new WeakMap,Ir=new WeakMap,Dh=new WeakMap,Lh=new WeakMap,So=new WeakMap,Ih=new WeakMap,li=new WeakMap,Fn=new WeakMap,_o=new WeakMap,Nn=new WeakMap,hi=new WeakMap,Au=new WeakMap,On=new WeakMap,Co=new WeakMap,Fh=new WeakMap,Bn=new WeakMap,Fr=new WeakMap,To=new WeakMap,Hn=new WeakMap,Nh=new WeakMap,Xt=new WeakMap,ht=new WeakMap,Hi=new WeakMap,Un=new WeakMap,$n=new WeakMap,Oh=new WeakMap,xo=new WeakMap,Bh=new WeakMap,jn=new WeakMap,ci=new WeakMap,Ui=new WeakMap,Hh=new WeakMap,Uh=new WeakMap,Rs=new WeakMap,L=new WeakSet,xd=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},cf=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of i(this,Qt).values())if(s.hasTextLayer(t))return s;return null},Qg=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=m(this,L,xd).call(this,t).closest(".textLayer"),n=this.getSelectionBoxes(s);n&&(i(this,hi)||f(this,hi,new My(this)),i(this,hi).show(s,n,this.direction==="ltr"))},Zg=function(){const t=document.getSelection();if(!t||t.isCollapsed){i(this,Hi)&&(i(this,hi)?.hide(),f(this,Hi,null),m(this,L,Re).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===i(this,Hi))return;const n=m(this,L,xd).call(this,t).closest(".textLayer");if(!n){i(this,Hi)&&(i(this,hi)?.hide(),f(this,Hi,null),m(this,L,Re).call(this,{hasSelectedText:!1}));return}if(i(this,hi)?.hide(),f(this,Hi,e),m(this,L,Re).call(this,{hasSelectedText:!0}),!(i(this,Xt)!==X.HIGHLIGHT&&i(this,Xt)!==X.NONE)&&(i(this,Xt)===X.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),f(this,Nn,this.isShiftKeyDown),!this.isShiftKeyDown)){const r=i(this,Xt)===X.HIGHLIGHT?m(this,L,cf).call(this,n):null;
2if(r?.toggleDrawing(),i(this,Co)){const a=new AbortController,o=this.combinedSignal(a),l=h=>{h.type==="pointerup"&&h.button!==0||(a.abort(),r?.toggleDrawing(!0),h.type==="pointerup"&&m(this,L,Ql).call(this,"main_toolbar"))};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}else r?.toggleDrawing(!0),m(this,L,Ql).call(this,"main_toolbar")}},Ql=function(t=""){i(this,Xt)===X.HIGHLIGHT?this.highlightSelection(t):i(this,Dh)&&m(this,L,Qg).call(this)},tm=function(){document.addEventListener("selectionchange",m(this,L,Zg).bind(this),{signal:this._signal})},em=function(){if(i(this,Fn))return;f(this,Fn,new AbortController);const t=this.combinedSignal(i(this,Fn));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},sm=function(){i(this,Fn)?.abort(),f(this,Fn,null)},df=function(){if(i(this,Bn))return;f(this,Bn,new AbortController);const t=this.combinedSignal(i(this,Bn));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},im=function(){i(this,Bn)?.abort(),f(this,Bn,null)},uf=function(){if(i(this,Dn))return;f(this,Dn,new AbortController);const t=this.combinedSignal(i(this,Dn));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})},ff=function(){i(this,Dn)?.abort(),f(this,Dn,null)},nm=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Re=function(t){Object.entries(t).some(([s,n])=>i(this,Bh)[s]!==n)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(i(this,Bh),t)}),i(this,Xt)===X.HIGHLIGHT&&t.hasSelectedEditor===!1&&m(this,L,Ii).call(this,[[et.HIGHLIGHT_FREE,!0]]))},Ii=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},rm=async function(){if(!i(this,On)){f(this,On,!0);const t=[];for(const e of i(this,Qt).values())t.push(e.enable());await Promise.all(t);for(const e of i(this,Ot).values())e.enable()}},am=function(){if(this.unselectAll(),i(this,On)){f(this,On,!1);for(const t of i(this,Qt).values())t.disable();for(const t of i(this,Ot).values())t.disable()}},pf=function(t){const e=i(this,Qt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},om=function(){let t=null;for(t of i(this,ht));return t},Zl=function(){if(i(this,Ot).size===0)return!0;if(i(this,Ot).size===1)for(const t of i(this,Ot).values())return t.isEmpty();return!1},gf=function(t){for(const e of i(this,ht))e.unselect();i(this,ht).clear();for(const e of t)e.isEmpty()||(i(this,ht).add(e),e.select());m(this,L,Re).call(this,{hasSelectedEditor:this.hasSelection})},R(ao,"TRANSLATE_SMALL",1),R(ao,"TRANSLATE_BIG",10);let Sr=ao;var ee,di,js,Po,ui,ts,ko,fi,je,$i,Nr,pi,Gn,ei,th,Pd;const Me=class Me{constructor(t){g(this,ei);g(this,ee,null);g(this,di,!1);g(this,js,null);g(this,Po,null);g(this,ui,null);g(this,ts,null);g(this,ko,!1);g(this,fi,null);g(this,je,null);g(this,$i,null);g(this,Nr,null);g(this,pi,!1);f(this,je,t),f(this,pi,t._uiManager.useNewAltTextFlow),i(Me,Gn)||f(Me,Gn,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){Me._l10n??(Me._l10n=t)}async render(){const t=f(this,js,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=f(this,Po,document.createElement("span"));t.append(e),i(this,pi)?(t.classList.add("new"),t.setAttribute("data-l10n-id",i(Me,Gn).missing),e.setAttribute("data-l10n-id",i(Me,Gn)["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,je)._uiManager._signal;t.addEventListener("contextmenu",ws,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const n=r=>{r.preventDefault(),i(this,je)._uiManager.editAltText(i(this,je)),i(this,pi)&&i(this,je)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:i(this,ei,th)}})};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(f(this,ko,!0),n(r))},{signal:s}),await m(this,ei,Pd).call(this),t}finish(){i(this,js)&&(i(this,js).focus({focusVisible:i(this,ko)}),f(this,ko,!1))}isEmpty(){return i(this,pi)?i(this,ee)===null:!i(this,ee)&&!i(this,di)}hasData(){return i(this,pi)?i(this,ee)!==null||!!i(this,$i):this.isEmpty()}get guessedText(){return i(this,$i)}async setGuessedText(t){i(this,ee)===null&&(f(this,$i,t),f(this,Nr,await Me._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,ei,Pd).call(this))}toggleAltTextBadge(t=!1){if(!i(this,pi)||i(this,ee)){i(this,fi)?.remove(),f(this,fi,null);return}if(!i(this,fi)){const e=f(this,fi,document.createElement("div"));e.className="noAltTextBadge",i(this,je).div.append(e)}i(this,fi).classList.toggle("hidden",!t)}serialize(t){let e=i(this,ee);return!t&&i(this,$i)===e&&(e=i(this,Nr)),{altText:e,decorative:i(this,di),guessedText:i(this,$i),textWithDisclaimer:i(this,Nr)}}get data(){return{altText:i(this,ee),decorative:i(this,di)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:n,cancel:r=!1}){s&&(f(this,$i,s),f(this,Nr,n)),!(i(this,ee)===t&&i(this,di)===e)&&(r||(f(this,ee,t),f(this,di,e)),m(this,ei,Pd).call(this))}toggle(t=!1){i(this,js)&&(!t&&i(this,ts)&&(clearTimeout(i(this,ts)),f(this,ts,null)),i(this,js).disabled=!t)}shown(){i(this,je)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:i(this,ei,th)}})}destroy(){i(this,js)?.remove(),f(this,js,null),f(this,Po,null),f(this,ui,null),i(this,fi)?.remove(),f(this,fi,null)}};ee=new WeakMap,di=new WeakMap,js=new WeakMap,Po=new WeakMap,ui=new WeakMap,ts=new WeakMap,ko=new WeakMap,fi=new WeakMap,je=new WeakMap,$i=new WeakMap,Nr=new WeakMap,pi=new WeakMap,Gn=new WeakMap,ei=new WeakSet,th=function(){return i(this,ee)&&"added"||i(this,ee)===null&&this.guessedText&&"review"||"missing"},Pd=async function(){const t=i(this,js);if(!t)return;if(i(this,pi)){if(t.classList.toggle("done",!!i(this,ee)),t.setAttribute("data-l10n-id",i(Me,Gn)[i(this,ei,th)]),i(this,Po)?.setAttribute("data-l10n-id",i(Me,Gn)[`${i(this,ei,th)}-label`]),!i(this,ee)){i(this,ui)?.remove();return}}else{if(!i(this,ee)&&!i(this,di)){t.classList.remove("done"),i(this,ui)?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=i(this,ui);if(!e){f(this,ui,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${i(this,je).id}`;const n=100,r=i(this,je)._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(i(this,ts)),f(this,ts,null)},{once:!0}),t.addEventListener("mouseenter",()=>{f(this,ts,setTimeout(()=>{f(this,ts,null),i(this,ui).classList.add("show"),i(this,je)._reportTelemetry({action:"alt_text_tooltip"})},n))},{signal:r}),t.addEventListener("mouseleave",()=>{i(this,ts)&&(clearTimeout(i(this,ts)),f(this,ts,null)),i(this,ui)?.classList.remove("show")},{signal:r})}i(this,di)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=i(this,ee)),e.parentNode||t.append(e),i(this,je).getElementForAltText()?.setAttribute("aria-describedby",e.id)},g(Me,Gn,null),R(Me,"_l10n",null);let ru=Me;var ce,Ms,Or,St,$h,Br,Gs,Hr,Ur,$r,jh,mf;class md{constructor(t){g(this,jh);g(this,ce,null);g(this,Ms,null);g(this,Or,!1);g(this,St,null);g(this,$h,null);g(this,Br,null);g(this,Gs,null);g(this,Hr,null);g(this,Ur,!1);g(this,$r,null);f(this,St,t)}renderForToolbar(){const t=f(this,Ms,document.createElement("button"));
2return t.className="comment",m(this,jh,mf).call(this,t,!1)}renderForStandalone(){const t=f(this,ce,document.createElement("button"));t.className="annotationCommentButton";const e=i(this,St).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(i(this,St)._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,St).commentButtonColor;n&&(s.backgroundColor=n)}return m(this,jh,mf).call(this,t,!0)}focusButton(){setTimeout(()=>{(i(this,ce)??i(this,Ms))?.focus()},0)}onUpdatedColor(){if(!i(this,ce))return;const t=i(this,St).commentButtonColor;t&&(i(this,ce).style.backgroundColor=t),i(this,St)._uiManager.updatePopupColor(i(this,St))}get commentButtonWidth(){return(i(this,ce)?.getBoundingClientRect().width??0)/i(this,St).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(i(this,$r))return i(this,$r);if(!i(this,ce))return null;const{x:t,y:e,height:s}=i(this,ce).getBoundingClientRect(),{x:n,y:r,width:a,height:o}=i(this,St).parent.boundingClientRect;return[(t-n)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){f(this,$r,t)}hasDefaultPopupPosition(){return i(this,$r)===null}removeStandaloneCommentButton(){i(this,ce)?.remove(),f(this,ce,null)}removeToolbarCommentButton(){i(this,Ms)?.remove(),f(this,Ms,null)}setCommentButtonStates({selected:t,hasPopup:e}){i(this,ce)&&(i(this,ce).classList.toggle("selected",t),i(this,ce).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,n;if(e)[s,n]=e;else{[s,n]=i(this,St).commentButtonPosition;const{width:c,height:u,x:p,y:b}=i(this,St);s=p+s*c,n=b+n*u}const r=i(this,St).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;i(this,St)._uiManager.editComment(i(this,St),a+s*l,o+n*h,{...t,parentDimensions:r})}finish(){i(this,Ms)&&(i(this,Ms).focus({focusVisible:i(this,Or)}),f(this,Or,!1))}isDeleted(){return i(this,Ur)||i(this,Gs)===""}isEmpty(){return i(this,Gs)===null}hasBeenEdited(){return this.isDeleted()||i(this,Gs)!==i(this,$h)}serialize(){return this.data}get data(){return{text:i(this,Gs),richText:i(this,Br),date:i(this,Hr),deleted:this.isDeleted()}}set data(t){if(t!==i(this,Gs)&&f(this,Br,null),t===null){f(this,Gs,""),f(this,Ur,!0);return}f(this,Gs,t),f(this,Hr,new Date),f(this,Ur,!1)}setInitialText(t,e=null){f(this,$h,t),this.data=t,f(this,Hr,null),f(this,Br,e)}shown(){}destroy(){i(this,Ms)?.remove(),f(this,Ms,null),i(this,ce)?.remove(),f(this,ce,null),f(this,Gs,""),f(this,Br,null),f(this,Hr,null),f(this,St,null),f(this,Or,!1),f(this,Ur,!1)}}ce=new WeakMap,Ms=new WeakMap,Or=new WeakMap,St=new WeakMap,$h=new WeakMap,Br=new WeakMap,Gs=new WeakMap,Hr=new WeakMap,Ur=new WeakMap,$r=new WeakMap,jh=new WeakSet,mf=function(t,e){if(!i(this,St)._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,St)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const s=i(this,St)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",ws,{signal:s}),e&&(t.addEventListener("focusin",r=>{i(this,St)._focusEventsAllowed=!1,Ft(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{i(this,St)._focusEventsAllowed=!0,Ft(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const n=r=>{r.preventDefault(),t===i(this,Ms)?this.edit():i(this,St).toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(f(this,Or,!0),n(r))},{signal:s}),t.addEventListener("pointerenter",()=>{i(this,St).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{i(this,St).toggleComment(!1,!1)},{signal:s}),t};var Ro,jr,Gh,zh,Vh,Wh,Xh,ji,Gr,Gi,zr,zi,_r,lm,hm,cm;const Wp=class Wp{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:n=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){g(this,_r);g(this,Ro);g(this,jr,!1);g(this,Gh,null);g(this,zh);g(this,Vh);g(this,Wh);g(this,Xh);g(this,ji,null);g(this,Gr);g(this,Gi,null);g(this,zr);g(this,zi,null);f(this,Ro,t),f(this,Gh,s),f(this,zh,e),f(this,Vh,n),f(this,Wh,r),f(this,Xh,a),f(this,zr,new AbortController),f(this,Gr,AbortSignal.any([o,i(this,zr).signal])),t.addEventListener("touchstart",m(this,_r,lm).bind(this),{passive:!1,signal:i(this,Gr)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/si.pixelRatio}destroy(){i(this,zr)?.abort(),f(this,zr,null),i(this,ji)?.abort(),f(this,ji,null)}};Ro=new WeakMap,jr=new WeakMap,Gh=new WeakMap,zh=new WeakMap,Vh=new WeakMap,Wh=new WeakMap,Xh=new WeakMap,ji=new WeakMap,Gr=new WeakMap,Gi=new WeakMap,zr=new WeakMap,zi=new WeakMap,_r=new WeakSet,lm=function(t){var n,r,a;if((n=i(this,zh))!=null&&n.call(this))return;if(t.touches.length===1){if(i(this,ji))return;const o=f(this,ji,new AbortController),l=AbortSignal.any([i(this,Gr),o.signal]),h=i(this,Ro),c={capture:!0,signal:l,passive:!1},u=p=>{p.pointerType==="touch"&&(i(this,ji)?.abort(),f(this,ji,null))};h.addEventListener("pointerdown",p=>{p.pointerType==="touch"&&(Ft(p),u(p))},c),h.addEventListener("pointerup",u,c),h.addEventListener("pointercancel",u,c);return}if(!i(this,zi)){f(this,zi,new AbortController);const o=AbortSignal.any([i(this,Gr),i(this,zi).signal]),l=i(this,Ro),h={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",m(this,_r,hm).bind(this),h);const c=m(this,_r,cm).bind(this);l.addEventListener("touchend",c,h),l.addEventListener("touchcancel",c,h),h.capture=!0,l.addEventListener("pointerdown",Ft,h),l.addEventListener("pointermove",Ft,h),l.addEventListener("pointercancel",Ft,h),l.addEventListener("pointerup",Ft,h),(r=i(this,Vh))==null||r.call(this)}if(Ft(t),t.touches.length!==2||(a=i(this,Gh))!=null&&a.call(this)){f(this,Gi,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),f(this,Gi,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},hm=function(t){var _;if(!i(this,Gi)||t.touches.length!==2)return;Ft(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,Gi),{touch0X:h,touch0Y:c,touch1X:u,touch1Y:p}=l,b=u-h,A=p-c,y=a-n,v=o-r,w=Math.hypot(y,v)||1,E=Math.hypot(b,A)||1;if(!i(this,jr)&&Math.abs(E-w)<=Wp.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!i(this,jr)){f(this,jr,!0);return}const S=[(n+a)/2,(r+o)/2];(_=i(this,Wh))==null||_.call(this,S,E,w)},cm=function(t){var e;t.touches.length>=2||(i(this,zi)&&(i(this,zi).abort(),f(this,zi,null),(e=i(this,Xh))==null||e.call(this)),i(this,Gi)&&(Ft(t),f(this,Gi,null),f(this,jr,!1)))};let Eh=Wp;var Vr,zs,kt,yt,Vi,Mo,zn,qh,de,Wr,Wi,gi,Vn,Yh,Xr,es,Kh,qr,Xi,mi,Do,Lo,Ds,Yr,Jh,wu,z,bf,Qh,yf,kd,dm,um,Af,Rd,wf,fm,pm,gm,vf,mm,Ef,bm,ym,Am,Sf,eh;const Y=class Y{constructor(t){g(this,z);g(this,Vr,null);g(this,zs,null);g(this,kt,null);g(this,yt,null);g(this,Vi,null);g(this,Mo,!1);g(this,zn,null);g(this,qh,"");g(this,de,null);g(this,Wr,null);g(this,Wi,null);g(this,gi,null);g(this,Vn,null);g(this,Yh,"");g(this,Xr,!1);g(this,es,null);g(this,Kh,!1);g(this,qr,!1);g(this,Xi,!1);g(this,mi,null);g(this,Do,0);g(this,Lo,0);g(this,Ds,null);g(this,Yr,null);R(this,"isSelected",!1);R(this,"_isCopy",!1);R(this,"_editToolbar",null);R(this,"_initialOptions",Object.create(null));R(this,"_initialData",null);R(this,"_isVisible",!0);R(this,"_uiManager",null);R(this,"_focusEventsAllowed",!0);g(this,Jh,!1);g(this,wu,Y._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=Y.prototype._resizeWithKeyboard,e=Sr.TRANSLATE_SMALL,s=Sr.TRANSLATE_BIG;return J(this,"_resizerKeyboardManager",new cd([[["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"],Y.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 J(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Iy({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(Y._l10n??(Y._l10n=t),Y._l10nResizer||(Y._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"})),Y._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);Y._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Et("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return i(this,Jh)}set _isDraggable(t){f(this,Jh,t),this.div?.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,wu)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(m(this,z,eh).call(this),i(this,gi)?.remove(),f(this,gi,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(i(this,Xr)?f(this,Xr,!1):this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,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,bf).call(this,this.parentDimensions,t,e)}translateInPage(t,e){i(this,es)||f(this,es,[this.x,this.y,this.width,this.height]),m(this,z,bf).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){i(this,es)||f(this,es,[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:u,y:p}=this.div.getBoundingClientRect();this.parent.findNewParent(this,u,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,es)&&(i(this,es)[0]!==this.x||i(this,es)[1]!==this.y)}get _hasBeenResized(){return!!i(this,es)&&(i(this,es)[2]!==this.width||i(this,es)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=Y,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=Te(r,0,s-o),a=Te(a,0,n-l);break;case 90:r=Te(r,0,s-l),a=Te(a,o,n);break;case 180:r=Te(r,o,s),a=Te(a,l,n);break;case 270:r=Te(r,l,s),a=Te(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=Y,Qh,yf).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=Y,Qh,yf).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(){i(this,kt)?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||i(this,qr))return this._editToolbar;this._editToolbar=new af(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(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,i(this,kt)?.destroy()}
2addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return i(this,kt)||(ru.initialize(Y._l10n),f(this,kt,new ru(this)),i(this,Vr)&&(i(this,kt).data=i(this,Vr),f(this,Vr,null))),i(this,kt)}get altTextData(){return i(this,kt)?.data}set altTextData(t){i(this,kt)&&(i(this,kt).data=t)}get guessedAltText(){return i(this,kt)?.guessedText}async setGuessedAltText(t){await i(this,kt)?.setGuessedText(t)}serializeAltText(t){return i(this,kt)?.serialize(t)}hasAltText(){return!!i(this,kt)&&!i(this,kt).isEmpty()}hasAltTextData(){return i(this,kt)?.hasData()??!1}focusCommentButton(){i(this,yt)?.focusButton()}addCommentButton(){return i(this,yt)||f(this,yt,new md(this))}addStandaloneCommentButton(){if(i(this,Vi)){this._uiManager.isEditingMode()&&i(this,Vi).classList.remove("hidden");return}this.hasComment&&(f(this,Vi,i(this,yt).renderForStandalone()),this.div.append(i(this,Vi)))}removeStandaloneCommentButton(){i(this,yt).removeStandaloneCommentButton(),f(this,Vi,null)}hideStandaloneCommentButton(){i(this,Vi)?.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:s,deleted:n}}=i(this,yt);return{text:e,richText:t,date:s,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){i(this,yt)||f(this,yt,new md(this)),i(this,yt).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,yt)||f(this,yt,new md(this)),i(this,yt).setInitialText(t,s),!this.annotationElementId))return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){return i(this,yt)?.hasBeenEdited()}get hasDeletedComment(){return i(this,yt)?.isDeleted()}get hasComment(){return!!i(this,yt)&&!i(this,yt).isEmpty()&&!i(this,yt).isDeleted()}async editComment(t){i(this,yt)||f(this,yt,new md(this)),i(this,yt).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){i(this,yt).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,yt).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){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,Mo)?-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,Ef).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),Kg(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(i(this,Yr)||f(this,Yr,new Eh({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:m(this,z,fm).bind(this),onPinching:m(this,z,pm).bind(this),onPinchEnd:m(this,z,gm).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}pointerdown(t){const{isMac:e}=le.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(f(this,Xr,!0),this._isDraggable){m(this,z,mm).call(this,t);return}m(this,z,vf).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){i(this,mi)&&clearTimeout(i(this,mi)),f(this,mi,setTimeout(()=>{f(this,mi,null),this.parent?.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const n=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/n,c=e/n,u=this.x*r,p=this.y*a,b=this.width*r,A=this.height*a;switch(s){case 0:return[u+h+o,a-p-c-A+l,u+h+b+o,a-p-c+l];case 90:return[u+c+o,a-p+h+l,u+c+A+o,a-p+h+b+l];case 180:return[u-h-b+o,a-p+c+l,u-h+o,a-p+c+A+l];case 270:return[u-c-A+o,a-p-h-b+l,u-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)}getNonHCMColor(){return this.color&&Y._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){i(this,yt)?.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,qr,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),f(this,qr,!1),!0):!1}isInEditMode(){return i(this,qr)}shouldGetKeyboardEvents(){return i(this,Xi)}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,Ef).call(this)}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,s){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,Vr,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(){if(i(this,Vn)?.abort(),f(this,Vn,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),i(this,mi)&&(clearTimeout(i(this,mi)),f(this,mi,null)),m(this,z,eh).call(this),this.removeEditToolbar(),i(this,Ds)){for(const t of i(this,Ds).values())clearTimeout(t);f(this,Ds,null)}this.parent=null,i(this,Yr)?.destroy(),f(this,Yr,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,z,dm).call(this),i(this,de).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[Y._round(s+(r-s)*t),Y._round(n+(a-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return i(this,yt).commentPopupPositionInLayer}set commentPopupPosition(t){i(this,yt).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return i(this,yt).hasDefaultPopupPosition()}get commentButtonWidth(){return i(this,yt).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){i(this,yt).setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),f(this,Wi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=i(this,de).children;if(!i(this,zs)){f(this,zs,Array.from(e));const a=m(this,z,bm).bind(this),o=m(this,z,ym).bind(this),l=this._uiManager._signal;for(const h of i(this,zs)){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,Am).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",Y._l10nResizer[c])}}const s=i(this,zs)[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,zs).length/4);if(r!==n){if(r<n)for(let o=0;o<n-r;o++)i(this,de).append(i(this,de).firstChild);else if(r>n)for(let o=0;o<r-n;o++)i(this,de).firstChild.before(i(this,de).lastChild);let a=0;for(const o of e){const h=i(this,zs)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",Y._l10nResizer[h])}}m(this,z,Sf).call(this,0),f(this,Xi,!0),i(this,de).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){i(this,Xi)&&m(this,z,wf).call(this,i(this,Yh),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){m(this,z,eh).call(this),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),i(this,kt)?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,i(this,de)?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),i(this,kt)?.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,Kh)}set isEditing(t){f(this,Kh,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,Ds)||f(this,Ds,new Map);const{action:s}=t;let n=i(this,Ds).get(s);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(t),i(this,Ds).delete(s),i(this,Ds).size===0&&f(this,Ds,null)},Y._telemetryTimeout),i(this,Ds).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,Mo,!1)}disable(){this.div&&(this.div.tabIndex=-1),f(this,Mo,!0)}updateFakeAnnotationElement(t){if(!i(this,gi)&&!this.deleted){f(this,gi,t.addFakeAnnotation(this));return}if(this.deleted){i(this,gi).remove(),f(this,gi,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&i(this,gi).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?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};Vr=new WeakMap,zs=new WeakMap,kt=new WeakMap,yt=new WeakMap,Vi=new WeakMap,Mo=new WeakMap,zn=new WeakMap,qh=new WeakMap,de=new WeakMap,Wr=new WeakMap,Wi=new WeakMap,gi=new WeakMap,Vn=new WeakMap,Yh=new WeakMap,Xr=new WeakMap,es=new WeakMap,Kh=new WeakMap,qr=new WeakMap,Xi=new WeakMap,mi=new WeakMap,Do=new WeakMap,Lo=new WeakMap,Ds=new WeakMap,Yr=new WeakMap,Jh=new WeakMap,wu=new WeakMap,z=new WeakSet,bf=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()},Qh=new WeakSet,yf=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]}},kd=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]}},dm=function(){if(i(this,de))return;f(this,de,document.createElement("div")),i(this,de).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,de).append(n),n.classList.add("resizer",s),n.setAttribute("data-resizer-name",s),n.addEventListener("pointerdown",m(this,z,um).bind(this,s),{signal:e}),n.addEventListener("contextmenu",ws,{signal:e}),n.tabIndex=-1}this.div.prepend(i(this,de))},um=function(t,e){e.preventDefault();const{isMac:s}=le.platform;if(e.button!==0||e.ctrlKey&&s)return;i(this,kt)?.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,f(this,Wr,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",m(this,z,wf).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Ft,{passive:!1,signal:a}),window.addEventListener("contextmenu",ws,{signal:a}),f(this,Wi,{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=()=>{r.abort(),this.parent.togglePointerEvents(!0),i(this,kt)?.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=o,this.div.style.cursor=l,m(this,z,Rd).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},Af=function(t,e,s,n){this.width=s,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Rd=function(){if(!i(this,Wi))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:n}=i(this,Wi);f(this,Wi,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,Af).bind(this,r,a,o,l),undo:m(this,z,Af).bind(this,t,e,s,n),mustExec:!0})},wf=function(t,e){const[s,n]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=Y.MIN_SIZE/s,c=Y.MIN_SIZE/n,u=m(this,z,kd).call(this,this.rotation),p=(I,H)=>[u[0]*I+u[2]*H,u[1]*I+u[3]*H],b=m(this,z,kd).call(this,360-this.rotation),A=(I,H)=>[b[0]*I+b[2]*H,b[1]*I+b[3]*H];let y,v,w=!1,E=!1;switch(t){case"topLeft":w=!0,y=(I,H)=>[0,0],v=(I,H)=>[I,H];break;case"topMiddle":y=(I,H)=>[I/2,0],v=(I,H)=>[I/2,H];break;case"topRight":w=!0,y=(I,H)=>[I,0],v=(I,H)=>[0,H];break;case"middleRight":E=!0,y=(I,H)=>[I,H/2],v=(I,H)=>[0,H/2];break;case"bottomRight":w=!0,y=(I,H)=>[I,H],v=(I,H)=>[0,0];break;case"bottomMiddle":y=(I,H)=>[I/2,H],v=(I,H)=>[I/2,0];break;case"bottomLeft":w=!0,y=(I,H)=>[0,H],v=(I,H)=>[I,0];break;case"middleLeft":E=!0,y=(I,H)=>[0,H/2],v=(I,H)=>[I,H/2];break}const S=y(o,l),_=v(o,l);let C=p(..._);const T=Y._round(r+C[0]),x=Y._round(a+C[1]);let P=1,k=1,M,D;if(e.fromKeyboard)({deltaX:M,deltaY:D}=e);else{const{screenX:I,screenY:H}=e,[W,ot]=i(this,Wr);[M,D]=this.screenToPageTranslation(I-W,H-ot),i(this,Wr)[0]=I,i(this,Wr)[1]=H}if([M,D]=A(M/s,D/n),w){const I=Math.hypot(o,l);P=k=Math.max(Math.min(Math.hypot(_[0]-S[0]-M,_[1]-S[1]-D)/I,1/o,1/l),h/o,c/l)}else E?P=Te(Math.abs(_[0]-S[0]-M),h,1)/o:k=Te(Math.abs(_[1]-S[1]-D),c,1)/l;const V=Y._round(o*P),G=Y._round(l*k);C=p(...v(V,G));const $=T-C[0],st=x-C[1];i(this,es)||f(this,es,[this.x,this.y,this.width,this.height]),this.width=V,this.height=G,this.x=$,this.y=st,this.setDims(),this.fixAndSetPosition(),this._onResizing()},fm=function(){f(this,Wi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),i(this,kt)?.toggle(!1),this.parent.togglePointerEvents(!1)},pm=function(t,e,s){let r=.7*(s/e)+1-.7;
2if(r===1)return;const a=m(this,z,kd).call(this,this.rotation),o=(T,x)=>[a[0]*T+a[2]*x,a[1]*T+a[3]*x],[l,h]=this.parentDimensions,c=this.x,u=this.y,p=this.width,b=this.height,A=Y.MIN_SIZE/l,y=Y.MIN_SIZE/h;r=Math.max(Math.min(r,1/p,1/b),A/p,y/b);const v=Y._round(p*r),w=Y._round(b*r);if(v===p&&w===b)return;i(this,es)||f(this,es,[c,u,p,b]);const E=o(p/2,b/2),S=Y._round(c+E[0]),_=Y._round(u+E[1]),C=o(v/2,w/2);this.x=S-C[0],this.y=_-C[1],this.width=v,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},gm=function(){i(this,kt)?.toggle(!0),this.parent.togglePointerEvents(!0),m(this,z,Rd).call(this)},vf=function(t){const{isMac:e}=le.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},mm=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,zn,null),f(this,Xr,!1),this._uiManager.endDragSession()||m(this,z,vf).call(this,h),s&&this._onStopDragging()};e&&(f(this,Do,t.clientX),f(this,Lo,t.clientY),f(this,zn,t.pointerId),f(this,qh,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:u,pointerId:p}=h;if(p!==i(this,zn)){Ft(h);return}const[b,A]=this.screenToPageTranslation(c-i(this,Do),u-i(this,Lo));f(this,Do,c),f(this,Lo,u),this._uiManager.dragSelectedEditors(b,A)},a),window.addEventListener("touchmove",Ft,a),window.addEventListener("pointerdown",h=>{h.pointerType===i(this,qh)&&(i(this,Yr)||h.isPrimary)&&o(h),Ft(h)},a));const l=h=>{if(!i(this,zn)||i(this,zn)===h.pointerId){o(h);return}Ft(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Ef=function(){if(i(this,Vn)||!this.div)return;f(this,Vn,new AbortController);const t=this._uiManager.combinedSignal(i(this,Vn));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},bm=function(t){Y._resizerKeyboardManager.exec(this,t)},ym=function(t){i(this,Xi)&&t.relatedTarget?.parentNode!==i(this,de)&&m(this,z,eh).call(this)},Am=function(t){f(this,Yh,i(this,Xi)?t:"")},Sf=function(t){if(i(this,zs))for(const e of i(this,zs))e.tabIndex=t},eh=function(){f(this,Xi,!1),m(this,z,Sf).call(this,-1),m(this,z,Rd).call(this)},g(Y,Qh),R(Y,"_l10n",null),R(Y,"_l10nResizer",null),R(Y,"_borderLineWidth",-1),R(Y,"_colorManager",new hf),R(Y,"_zIndex",1),R(Y,"_telemetryTimeout",1e3);let _t=Y;class Iy extends _t{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const ng=3285377520,Ss=4294901760,ri=65535;class wm{constructor(t){this.h1=t?t&4294967295:ng,this.h2=t?t&4294967295:ng}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let y=0,v=t.length;y<v;y++){const w=t.charCodeAt(y);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 u=3432918353,p=461845907,b=u&ri,A=p&ri;for(let y=0;y<n;y++)y&1?(o=a[y],o=o*u&Ss|o*b&ri,o=o<<15|o>>>17,o=o*p&Ss|o*A&ri,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[y],l=l*u&Ss|l*b&ri,l=l<<15|l>>>17,l=l*p&Ss|l*A&ri,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*u&Ss|o*b&ri,o=o<<15|o>>>17,o=o*p&Ss|o*A&ri,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&Ss|t*36045&ri,e=e*4283543511&Ss|((e<<16|t>>>16)*2950163797&Ss)>>>16,t^=e>>>1,t=t*444984403&Ss|t*60499&ri,e=e*3301882366&Ss|((e<<16|t>>>16)*3120437893&Ss)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const _f=Object.freeze({map:null,hash:"",transfer:void 0});var Kr,Jr,qi,ue,vu,vm;class Fp{constructor(){g(this,vu);g(this,Kr,!1);g(this,Jr,null);g(this,qi,null);g(this,ue,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=i(this,ue).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return i(this,ue).get(t)}remove(t){const e=i(this,ue).get(t);if(e!==void 0&&(e instanceof _t&&i(this,qi).delete(e.annotationElementId),i(this,ue).delete(t),i(this,ue).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const s of i(this,ue).values())if(s instanceof _t)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=i(this,ue).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,ue).set(t,e);n&&m(this,vu,vm).call(this),e instanceof _t&&((i(this,qi)||f(this,qi,new Map)).set(e.annotationElementId,e),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type))}has(t){return i(this,ue).has(t)}get size(){return i(this,ue).size}resetModified(){i(this,Kr)&&(f(this,Kr,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Em(this)}get serializable(){if(i(this,ue).size===0)return _f;const t=new Map,e=new wm,s=[],n=Object.create(null);let r=!1;
2for(const[a,o]of i(this,ue)){const l=o instanceof _t?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}:_f}get editorStats(){let t=null;const e=new Map;let s=0,n=0;for(const r of i(this,ue).values()){if(!(r instanceof _t)){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 u=l.get(h);u||(u=new Map,l.set(h,u));const p=u.get(c)??0;u.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,Jr,null)}updateEditor(t,e){const s=i(this,qi)?.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return i(this,qi)?.get(t)||null}get modifiedIds(){if(i(this,Jr))return i(this,Jr);const t=[];if(i(this,qi))for(const e of i(this,qi).values())e.serialize()&&t.push(e.annotationElementId);return f(this,Jr,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return i(this,ue).entries()}}Kr=new WeakMap,Jr=new WeakMap,qi=new WeakMap,ue=new WeakMap,vu=new WeakSet,vm=function(){i(this,Kr)||(f(this,Kr,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Zh;class Em extends Fp{constructor(e){super();g(this,Zh);const{map:s,hash:n,transfer:r}=e.serializable,a=structuredClone(s,r?{transfer:r}:null);f(this,Zh,{map:a,hash:n,transfer:r})}get print(){Et("Should not call PrintAnnotationStorage.print")}get serializable(){return i(this,Zh)}get modifiedIds(){return J(this,"modifiedIds",{ids:new Set,hash:""})}}Zh=new WeakMap;var Io;class Fy{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){g(this,Io,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,Io).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||i(this,Io).has(t.loadedName))){if(it(!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,Io).add(n),s?.(t)}catch{q(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}Et("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 q(`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(){const t=!!this._document?.fonts;return J(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return J(this,"isSyncFontLoadingSupported",Fe||le.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(it(!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 J(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(_,C){return _.charCodeAt(C)<<24|_.charCodeAt(C+1)<<16|_.charCodeAt(C+2)<<8|_.charCodeAt(C+3)&255}function n(_,C,T,x){const P=_.substring(0,C),k=_.substring(C+T);return P+x+k}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(_,C){if(++h>30){q("Load test font never loaded."),C();return}if(l.font="30px "+_,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(c.bind(null,_,C))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let p=this._loadTestFont;p=n(p,976,u.length,u);const A=16,y=1482184792;let v=s(p,A);for(r=0,a=u.length-3;r<a;r+=4)v=v-y+s(u,r)|0;r<u.length&&(v=v-y+s(u+"XXX",r)|0),p=n(p,A,4,Ey(v));const w=`url(data:font/opentype;base64,${btoa(p)});`,E=`@font-face {font-family:"${u}";src:${w}}`;this.insertRule(E);const S=this._document.createElement("div");S.style.visibility="hidden",S.style.width=S.style.height="10px",S.style.position="absolute",
2S.style.top=S.style.left="0px";for(const _ of[t.loadedName,u]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=_,S.append(C)}this._document.body.append(S),c(u,()=>{S.remove(),e.complete()})}}Io=new WeakMap;var dt;class Ny{constructor(t,e=null,s,n){g(this,dt);this.compiledGlyphs=Object.create(null),f(this,dt,t),this._inspectFont=e,s&&Object.assign(this,s),n&&(this.charProcOperatorList=n)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Bg(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let n;try{n=t.get(s)}catch(a){q(`getPathGenerator - ignoring character: "${a}".`)}const r=new Path2D(n||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return i(this,dt).black}get bold(){return i(this,dt).bold}get disableFontFace(){return i(this,dt).disableFontFace??!1}get fontExtraProperties(){return i(this,dt).fontExtraProperties??!1}get isInvalidPDFjsFont(){return i(this,dt).isInvalidPDFjsFont}get isType3Font(){return i(this,dt).isType3Font}get italic(){return i(this,dt).italic}get missingFile(){return i(this,dt).missingFile}get remeasure(){return i(this,dt).remeasure}get vertical(){return i(this,dt).vertical}get ascent(){return i(this,dt).ascent}get defaultWidth(){return i(this,dt).defaultWidth}get descent(){return i(this,dt).descent}get bbox(){return i(this,dt).bbox}get fontMatrix(){return i(this,dt).fontMatrix}get fallbackName(){return i(this,dt).fallbackName}get loadedName(){return i(this,dt).loadedName}get mimetype(){return i(this,dt).mimetype}get name(){return i(this,dt).name}get data(){return i(this,dt).data}clearData(){i(this,dt).clearData()}get cssFontInfo(){return i(this,dt).cssFontInfo}get systemFontInfo(){return i(this,dt).systemFontInfo}get defaultVMetrics(){return i(this,dt).defaultVMetrics}}dt=new WeakMap;function Oy(d){if(d instanceof URL)return d.href;if(typeof d=="string"){if(Fe)return d;const t=URL.parse(d,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 By(d){if(Fe&&typeof Buffer<"u"&&d instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(d instanceof Uint8Array&&d.byteLength===d.buffer.byteLength)return d;if(typeof d=="string")return od(d);if(d instanceof ArrayBuffer||ArrayBuffer.isView(d)||typeof d=="object"&&!isNaN(d?.length))return new Uint8Array(d);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function bd(d){if(typeof d!="string")return null;if(d.endsWith("/"))return d;throw new Error(`Invalid factory url: "${d}" must include trailing slash.`)}const Cf=d=>typeof d=="object"&&Number.isInteger(d?.num)&&d.num>=0&&Number.isInteger(d?.gen)&&d.gen>=0,Hy=d=>typeof d=="object"&&typeof d?.name=="string",Sm=Ty.bind(null,Cf,Hy);var Yi,Eu;class Uy{constructor(){g(this,Yi,new Map);g(this,Eu,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};i(this,Eu).then(()=>{for(const[n]of i(this,Yi))n.call(this,s)})}addEventListener(t,e,s=null){let n=null;if(s?.signal instanceof AbortSignal){const{signal:r}=s;if(r.aborted){q("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);n=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}i(this,Yi).set(e,n)}removeEventListener(t,e){i(this,Yi).get(e)?.(),i(this,Yi).delete(e)}terminate(){for(const[,t]of i(this,Yi))t?.();i(this,Yi).clear()}}Yi=new WeakMap,Eu=new WeakMap;const yd={DATA:1,ERROR:2},Wt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function rg(){}function Ue(d){if(d instanceof vn||d instanceof iu||d instanceof Jp||d instanceof Ah||d instanceof qu)return d;switch(d instanceof Error||typeof d=="object"&&d!==null||Et('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),d.name){case"AbortException":return new vn(d.message);case"InvalidPDFException":return new iu(d.message);case"PasswordException":return new Jp(d.message,d.code);case"ResponseException":return new Ah(d.message,d.status,d.missing);case"UnknownErrorException":return new qu(d.message,d.details)}return new qu(d.message,d.toString())}var Fo,Os,_m,Cm,Tm,Md;class sh{constructor(t,e,s){g(this,Os);g(this,Fo,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,Os,_m).bind(this),{signal:i(this,Fo).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)}
2sendWithPromise(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:Wt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{it(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:Wt.CANCEL,streamId:r,reason:Ue(h)}),c.promise}},s)}destroy(){i(this,Fo)?.abort(),f(this,Fo,null)}}Fo=new WeakMap,Os=new WeakSet,_m=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){m(this,Os,Tm).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===yd.DATA)n.resolve(t.data);else if(t.callback===yd.ERROR)n.reject(Ue(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:yd.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:n,callback:yd.ERROR,callbackId:t.callbackId,reason:Ue(a)})});return}if(t.streamId){m(this,Os,Cm).call(this,t);return}e(t.data)},Cm=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,u){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:Wt.ENQUEUE,streamId:e,chunk:h},u)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:n,stream:Wt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){it(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:n,stream:Wt.ERROR,streamId:e,reason:Ue(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:Wt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Wt.START_COMPLETE,streamId:e,reason:Ue(h)})})},Tm=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 Wt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(Ue(t.reason));break;case Wt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(Ue(t.reason));break;case Wt.PULL:if(!o){r.postMessage({sourceName:s,targetName:n,stream:Wt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||rg).then(function(){r.postMessage({sourceName:s,targetName:n,stream:Wt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Wt.PULL_COMPLETE,streamId:e,reason:Ue(h)})});break;case Wt.ENQUEUE:if(it(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Wt.CLOSE:if(it(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),m(this,Os,Md).call(this,a,e);break;case Wt.ERROR:it(a,"error should have stream controller"),a.controller.error(Ue(t.reason)),m(this,Os,Md).call(this,a,e);break;case Wt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(Ue(t.reason)),m(this,Os,Md).call(this,a,e);break;case Wt.CANCEL:if(!o)break;const l=Ue(t.reason);Promise.try(o.onCancel||rg,l).then(function(){r.postMessage({sourceName:s,targetName:n,stream:Wt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Wt.CANCEL_COMPLETE,streamId:e,reason:Ue(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Md=async function(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]};var tc;class xm{constructor({enableHWA:t=!1}){g(this,tc,!1);f(this,tc,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,tc)})}}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){Et("Abstract method `_createCanvas` called.")}}tc=new WeakMap;class $y extends xm{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 Pm{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){Et("Abstract method `_fetch` called.")}}class ag extends Pm{async _fetch(t){const e=await Gl(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):od(e)}}class km{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 Qr,No,Ki,Ji,Ee,Zr,ta,F,Ae,ih,Za,Dd,to,Rm,Tf,eo,nh,rh,xf,ah;
2class jy extends km{constructor({docId:e,ownerDocument:s=globalThis.document}){super();g(this,F);g(this,Qr);g(this,No);g(this,Ki);g(this,Ji);g(this,Ee);g(this,Zr);g(this,ta,0);f(this,Ji,e),f(this,Ee,s)}addFilter(e){if(!e)return"none";let s=i(this,F,Ae).get(e);if(s)return s;const[n,r,a]=m(this,F,Dd).call(this,e),o=e.length===1?n:`${n}${r}${a}`;if(s=i(this,F,Ae).get(o),s)return i(this,F,Ae).set(e,s),s;const l=`g_${i(this,Ji)}_transfer_map_${Kt(this,ta)._++}`,h=m(this,F,to).call(this,l);i(this,F,Ae).set(e,h),i(this,F,Ae).set(o,h);const c=m(this,F,eo).call(this,l);return m(this,F,rh).call(this,n,r,a,c),h}addHCMFilter(e,s){const n=`${e}-${s}`,r="base";let a=i(this,F,ih).get(r);if(a?.key===n||(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},i(this,F,ih).set(r,a)),!e||!s))return a.url;const o=m(this,F,ah).call(this,e);e=O.makeHexColor(...o);const l=m(this,F,ah).call(this,s);if(s=O.makeHexColor(...l),i(this,F,Za).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let A=0;A<=255;A++){const y=A/255;h[A]=y<=.03928?y/12.92:((y+.055)/1.055)**2.4}const c=h.join(","),u=`g_${i(this,Ji)}_hcm_filter`,p=a.filter=m(this,F,eo).call(this,u);m(this,F,rh).call(this,c,c,c,p),m(this,F,Tf).call(this,p);const b=(A,y)=>{const v=o[A]/255,w=l[A]/255,E=new Array(y+1);for(let S=0;S<=y;S++)E[S]=v+S/y*(w-v);return E.join(",")};return m(this,F,rh).call(this,b(0,5),b(1,5),b(2,5),p),a.url=m(this,F,to).call(this,u),a.url}addAlphaFilter(e){let s=i(this,F,Ae).get(e);if(s)return s;const[n]=m(this,F,Dd).call(this,[e]),r=`alpha_${n}`;if(s=i(this,F,Ae).get(r),s)return i(this,F,Ae).set(e,s),s;const a=`g_${i(this,Ji)}_alpha_map_${Kt(this,ta)._++}`,o=m(this,F,to).call(this,a);i(this,F,Ae).set(e,o),i(this,F,Ae).set(r,o);const l=m(this,F,eo).call(this,a);return m(this,F,xf).call(this,n,l),o}addLuminosityFilter(e){let s=i(this,F,Ae).get(e||"luminosity");if(s)return s;let n,r;if(e?([n]=m(this,F,Dd).call(this,[e]),r=`luminosity_${n}`):r="luminosity",s=i(this,F,Ae).get(r),s)return i(this,F,Ae).set(e,s),s;const a=`g_${i(this,Ji)}_luminosity_map_${Kt(this,ta)._++}`,o=m(this,F,to).call(this,a);i(this,F,Ae).set(e,o),i(this,F,Ae).set(r,o);const l=m(this,F,eo).call(this,a);return m(this,F,Rm).call(this,l),e&&m(this,F,xf).call(this,n,l),o}addHighlightHCMFilter(e,s,n,r,a){const o=`${s}-${n}-${r}-${a}`;let l=i(this,F,ih).get(e);if(l?.key===o||(l?(l.filter?.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},i(this,F,ih).set(e,l)),!s||!n))return l.url;const[h,c]=[s,n].map(m(this,F,ah).bind(this));let u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),p=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[b,A]=[r,a].map(m(this,F,ah).bind(this));p<u&&([u,p,b,A]=[p,u,A,b]),i(this,F,Za).style.color="";const y=(E,S,_)=>{const C=new Array(256),T=(p-u)/_,x=E/255,P=(S-E)/(255*_);let k=0;for(let M=0;M<=_;M++){const D=Math.round(u+M*T),V=x+M*P;for(let G=k;G<=D;G++)C[G]=V;k=D+1}for(let M=k;M<256;M++)C[M]=C[k-1];return C.join(",")},v=`g_${i(this,Ji)}_hcm_${e}_filter`,w=l.filter=m(this,F,eo).call(this,v);return m(this,F,Tf).call(this,w),m(this,F,rh).call(this,y(b[0],A[0],5),y(b[1],A[1],5),y(b[2],A[2],5),w),l.url=m(this,F,to).call(this,v),l.url}destroy(e=!1){e&&i(this,Zr)?.size||(i(this,Ki)?.parentNode.parentNode.remove(),f(this,Ki,null),i(this,No)?.clear(),f(this,No,null),i(this,Zr)?.clear(),f(this,Zr,null),f(this,ta,0))}}Qr=new WeakMap,No=new WeakMap,Ki=new WeakMap,Ji=new WeakMap,Ee=new WeakMap,Zr=new WeakMap,ta=new WeakMap,F=new WeakSet,Ae=function(){return i(this,No)||f(this,No,new Map)},ih=function(){return i(this,Zr)||f(this,Zr,new Map)},Za=function(){if(!i(this,Ki)){const e=i(this,Ee).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,Ee).createElementNS(Li,"svg");n.setAttribute("width",0),n.setAttribute("height",0),f(this,Ki,i(this,Ee).createElementNS(Li,"defs")),e.append(n),n.append(i(this,Ki)),i(this,Ee).body.append(e)}return i(this,Ki)},Dd=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let p=0;p<256;
2p++)c[p]=h[p]/255;const u=c.join(",");return[u,u,u]}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(",")]},to=function(e){if(i(this,Qr)===void 0){f(this,Qr,"");const s=i(this,Ee).URL;s!==i(this,Ee).baseURI&&(hd(s)?q('#createUrl: ignore "data:"-URL for performance reasons.'):f(this,Qr,Rp(s,"")))}return`url(${i(this,Qr)}#${e})`},Rm=function(e){const s=i(this,Ee).createElementNS(Li,"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)},Tf=function(e){const s=i(this,Ee).createElementNS(Li,"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)},eo=function(e){const s=i(this,Ee).createElementNS(Li,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),i(this,F,Za).append(s),s},nh=function(e,s,n){const r=i(this,Ee).createElementNS(Li,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),e.append(r)},rh=function(e,s,n,r){const a=i(this,Ee).createElementNS(Li,"feComponentTransfer");r.append(a),m(this,F,nh).call(this,a,"feFuncR",e),m(this,F,nh).call(this,a,"feFuncG",s),m(this,F,nh).call(this,a,"feFuncB",n)},xf=function(e,s){const n=i(this,Ee).createElementNS(Li,"feComponentTransfer");
2s.append(n),m(this,F,nh).call(this,n,"feFuncA",e)},ah=function(e){return i(this,F,Za).style.color=e,zl(getComputedStyle(i(this,F,Za)).getPropertyValue("color"))};class Mm{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){Et("Abstract method `_fetch` called.")}}class og extends Mm{async _fetch(t){const e=await Gl(t,"arraybuffer");return new Uint8Array(e)}}class Dm{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){Et("Abstract method `_fetch` called.")}}class lg extends Dm{async _fetch(t){const e=await Gl(t,"arraybuffer");return new Uint8Array(e)}}Fe&&q("Please use the `legacy` build in Node.js environments.");async function Np(d){const e=await process.getBuiltinModule("fs").promises.readFile(d);return new Uint8Array(e)}class Gy extends km{}class zy extends xm{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Vy extends Pm{async _fetch(t){return Np(t)}}class Wy extends Mm{async _fetch(t){return Np(t)}}class Xy extends Dm{async _fetch(t){return Np(t)}}const Ka="__forcedDependency",{floor:hg,ceil:cg}=Math;function Ad(d,t,e,s,n,r){d[t*4+0]=Math.min(d[t*4+0],e),d[t*4+1]=Math.min(d[t*4+1],s),d[t*4+2]=Math.max(d[t*4+2],n),d[t*4+3]=Math.max(d[t*4+3],r)}const Pf=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var Oo,Wn;class qy{constructor(t,e){g(this,Oo);g(this,Wn);f(this,Oo,t),f(this,Wn,e)}get length(){return i(this,Oo).length}isEmpty(t){return i(this,Oo)[t]===Pf}minX(t){return i(this,Wn)[t*4+0]/256}minY(t){return i(this,Wn)[t*4+1]/256}maxX(t){return(i(this,Wn)[t*4+2]+1)/256}maxY(t){return(i(this,Wn)[t*4+3]+1)/256}}Oo=new WeakMap,Wn=new WeakMap;const wd=(d,t)=>{if(!d)return;let e=d.get(t);return e||(e={dependencies:new Set,isRenderingOperation:!1},d.set(t,e)),e};var Ge,ze,ea,Vs,sa,Qi,ct,ut,Zi,Ve,ec,Bo,ia,na,tn,Se,bi,sc,kf;class Yy{constructor(t,e,s=!1){g(this,sc);g(this,Ge,{__proto__:null});g(this,ze,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Ka]:[]});g(this,ea,new Map);g(this,Vs,[]);g(this,sa,[]);g(this,Qi,[[1,0,0,1,0,0]]);g(this,ct,[-1/0,-1/0,1/0,1/0]);g(this,ut,new Float64Array([1/0,1/0,-1/0,-1/0]));g(this,Zi,-1);g(this,Ve,new Set);g(this,ec,new Map);g(this,Bo,new Map);g(this,ia);g(this,na);g(this,tn);g(this,Se);g(this,bi);f(this,ia,t.width),f(this,na,t.height),m(this,sc,kf).call(this,e),s&&f(this,bi,new Map)}growOperationsCount(t){t>=i(this,Se).length&&m(this,sc,kf).call(this,t,i(this,Se))}save(t){return f(this,Ge,{__proto__:i(this,Ge)}),f(this,ze,{__proto__:i(this,ze),transform:{__proto__:i(this,ze).transform},moveText:{__proto__:i(this,ze).moveText},sameLineText:{__proto__:i(this,ze).sameLineText},[Ka]:{__proto__:i(this,ze)[Ka]}}),f(this,ct,{__proto__:i(this,ct)}),i(this,Vs).push(t),this}restore(t){const e=Object.getPrototypeOf(i(this,Ge));if(e===null)return this;f(this,Ge,e),f(this,ze,Object.getPrototypeOf(i(this,ze))),f(this,ct,Object.getPrototypeOf(i(this,ct)));const s=i(this,Vs).pop();return s!==void 0&&(wd(i(this,bi),t)?.dependencies.add(s),i(this,Se)[t]=i(this,Se)[s]),this}recordOpenMarker(t){return i(this,Vs).push(t),this}getOpenMarker(){return i(this,Vs).length===0?null:i(this,Vs).at(-1)}recordCloseMarker(t){const e=i(this,Vs).pop();return e!==void 0&&(wd(i(this,bi),t)?.dependencies.add(e),i(this,Se)[t]=i(this,Se)[e]),this}beginMarkedContent(t){return i(this,sa).push(t),this}endMarkedContent(t){const e=i(this,sa).pop();return e!==void 0&&(wd(i(this,bi),t)?.dependencies.add(e),i(this,Se)[t]=i(this,Se)[e]),this}pushBaseTransform(t){return i(this,Qi).push(O.multiplyByDOMMatrix(i(this,Qi).at(-1),t.getTransform())),this}popBaseTransform(){return i(this,Qi).length>1&&i(this,Qi).pop(),this}recordSimpleData(t,e){return i(this,Ge)[t]=e,this}recordIncrementalData(t,e){return i(this,ze)[t].push(e),this}resetIncrementalData(t,e){return i(this,ze)[t].length=0,this}recordNamedData(t,e){return i(this,ea).set(t,e),this}recordSimpleDataFromNamed(t,e,s){i(this,Ge)[t]=i(this,ea).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Ka,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in i(this,Ge)&&this.recordFutureForcedDependency(e,i(this,Ge)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of i(this,Ve))this.recordFutureForcedDependency(Ka,t);return this}resetBBox(t){return i(this,Zi)!==t&&(f(this,Zi,t),i(this,ut)[0]=1/0,i(this,ut)[1]=1/0,i(this,ut)[2]=-1/0,i(this,ut)[3]=-1/0),this}recordClipBox(t,e,s,n,r,a){const o=O.multiplyByDOMMatrix(i(this,Qi).at(-1),e.getTransform()),l=[1/0,1/0,-1/0,-1/0];O.axialAlignedBoundingBox([s,r,n,a],o,l);const h=O.intersect(i(this,ct),l);return h?(i(this,ct)[0]=h[0],i(this,ct)[1]=h[1],i(this,ct)[2]=h[2],i(this,ct)[3]=h[3]):(i(this,ct)[0]=i(this,ct)[1]=1/0,i(this,ct)[2]=i(this,ct)[3]=-1/0),this}recordBBox(t,e,s,n,r,a){const o=i(this,ct);if(o[0]===1/0)return this;const l=O.multiplyByDOMMatrix(i(this,Qi).at(-1),e.getTransform());if(o[0]===-1/0)return O.axialAlignedBoundingBox([s,r,n,a],l,i(this,ut)),this;const h=[1/0,1/0,-1/0,-1/0];return O.axialAlignedBoundingBox([s,r,n,a],l,h),i(this,ut)[0]=Math.min(i(this,ut)[0],Math.max(h[0],o[0])),i(this,ut)[1]=Math.min(i(this,ut)[1],Math.max(h[1],o[1])),i(this,ut)[2]=Math.max(i(this,ut)[2],Math.min(h[2],o[2])),i(this,ut)[3]=Math.max(i(this,ut)[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,Bo).get(s),h!==!1&&(c=[0,0,0,0],O.axialAlignedBoundingBox(l,s.fontMatrix,c),(n!==1||r!==0||a!==0)&&O.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 u=o();return l&&c&&h===void 0&&(h=c[0]<=r-u.actualBoundingBoxLeft&&c[2]>=r+u.actualBoundingBoxRight&&c[1]<=a-u.actualBoundingBoxAscent&&c[3]>=a+u.actualBoundingBoxDescent,i(this,Bo).set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-u.actualBoundingBoxLeft,r+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(t){return i(this,ut)[0]=Math.max(0,i(this,ct)[0]),i(this,ut)[1]=Math.max(0,i(this,ct)[1]),i(this,ut)[2]=Math.min(i(this,ia),i(this,ct)[2]),i(this,ut)[3]=Math.min(i(this,na),i(this,ct)[3]),this}getSimpleIndex(t){return i(this,Ge)[t]}recordDependencies(t,e){const s=i(this,Ve),n=i(this,Ge),r=i(this,ze);for(const a of e)a in i(this,Ge)?s.add(n[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return i(this,ea).has(e)&&i(this,Ve).add(i(this,ea).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Ka]),i(this,bi)){const s=wd(i(this,bi),t),{dependencies:n}=s;i(this,Ve).forEach(n.add,n),i(this,Vs).forEach(n.add,n),i(this,sa).forEach(n.add,n),n.delete(t),s.isRenderingOperation=!0}if(i(this,Zi)===t){const s=hg(i(this,ut)[0]*256/i(this,ia)),n=hg(i(this,ut)[1]*256/i(this,na)),r=cg(i(this,ut)[2]*256/i(this,ia)),a=cg(i(this,ut)[3]*256/i(this,na));Ad(i(this,tn),t,s,n,r,a);for(const o of i(this,Ve))o!==t&&Ad(i(this,tn),o,s,n,r,a);for(const o of i(this,Vs))o!==t&&Ad(i(this,tn),o,s,n,r,a);for(const o of i(this,sa))o!==t&&Ad(i(this,tn),o,s,n,r,a);e||(i(this,Ve).clear(),f(this,Zi,-1))}return this}recordShowTextOperation(t,e=!1){const s=Array.from(i(this,Ve));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,Zi)===t&&(f(this,Zi,-1),i(this,ct)[0]=Math.max(i(this,ct)[0],i(this,ut)[0]),i(this,ct)[1]=Math.max(i(this,ct)[1],i(this,ut)[1]),i(this,ct)[2]=Math.min(i(this,ct)[2],i(this,ut)[2]),i(this,ct)[3]=Math.min(i(this,ct)[3],i(this,ut)[3]),e||i(this,Ve).clear()),this}_takePendingDependencies(){const t=i(this,Ve);return f(this,Ve,new Set),t}_extractOperation(t){const e=i(this,ec).get(t);return i(this,ec).delete(t),e}_pushPendingDependencies(t){for(const e of t)i(this,Ve).add(e)}take(){return i(this,Bo).clear(),new qy(i(this,Se),i(this,tn))}takeDebugMetadata(){return i(this,bi)}}Ge=new WeakMap,ze=new WeakMap,ea=new WeakMap,Vs=new WeakMap,sa=new WeakMap,Qi=new WeakMap,ct=new WeakMap,ut=new WeakMap,Zi=new WeakMap,Ve=new WeakMap,ec=new WeakMap,Bo=new WeakMap,ia=new WeakMap,na=new WeakMap,tn=new WeakMap,Se=new WeakMap,bi=new WeakMap,sc=new WeakSet,kf=function(t,e){const s=new ArrayBuffer(t*4);f(this,tn,new Uint8ClampedArray(s)),f(this,Se,new Uint32Array(s)),e&&e.length>0?(i(this,Se).set(e),i(this,Se).fill(Pf,e.length)):i(this,Se).fill(Pf)};var At,Bt,Ws,Ho,Uo;const Xp=class Xp{constructor(t,e,s){g(this,At);g(this,Bt);g(this,Ws);g(this,Ho,0);g(this,Uo,0);if(t instanceof Xp&&i(t,Ws)===!!s)return t;f(this,At,t),f(this,Bt,e),f(this,Ws,!!s)}growOperationsCount(){throw new Error("Unreachable")}save(t){return Kt(this,Uo)._++,i(this,At).save(i(this,Bt)),this}restore(t){return i(this,Uo)>0&&(i(this,At).restore(i(this,Bt)),Kt(this,Uo)._--),this}recordOpenMarker(t){return Kt(this,Ho)._++,this}getOpenMarker(){return i(this,Ho)>0?i(this,Bt):i(this,At).getOpenMarker()}recordCloseMarker(t){return Kt(this,Ho)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return i(this,At).pushBaseTransform(t),this}popBaseTransform(){return i(this,At).popBaseTransform(),this}recordSimpleData(t,e){return i(this,At).recordSimpleData(t,i(this,Bt)),this}recordIncrementalData(t,e){return i(this,At).recordIncrementalData(t,i(this,Bt)),this}resetIncrementalData(t,e){return i(this,At).resetIncrementalData(t,i(this,Bt)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return i(this,At).recordSimpleDataFromNamed(t,e,i(this,Bt)),this}recordFutureForcedDependency(t,e){return i(this,At).recordFutureForcedDependency(t,i(this,Bt)),this}inheritSimpleDataAsFutureForcedDependencies(t){return i(this,At).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return i(this,At).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return i(this,Ws)||i(this,At).resetBBox(i(this,Bt)),this}recordClipBox(t,e,s,n,r,a){return i(this,Ws)||i(this,At).recordClipBox(i(this,Bt),e,s,n,r,a),this}recordBBox(t,e,s,n,r,a){return i(this,Ws)||i(this,At).recordBBox(i(this,Bt),e,s,n,r,a),this}recordCharacterBBox(t,e,s,n,r,a,o){return i(this,Ws)||i(this,At).recordCharacterBBox(i(this,Bt),e,s,n,r,a,o),this}recordFullPageBBox(t){return i(this,Ws)||i(this,At).recordFullPageBBox(i(this,Bt)),this}getSimpleIndex(t){return i(this,At).getSimpleIndex(t)}recordDependencies(t,e){return i(this,At).recordDependencies(i(this,Bt),e),this}recordNamedDependency(t,e){return i(this,At).recordNamedDependency(i(this,Bt),e),this}recordOperation(t){return i(this,At).recordOperation(i(this,Bt),!0),this}recordShowTextOperation(t){return i(this,At).recordShowTextOperation(i(this,Bt),!0),this}bboxToClipBoxDropOperation(t){return i(this,Ws)||i(this,At).bboxToClipBoxDropOperation(i(this,Bt),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};At=new WeakMap,Bt=new WeakMap,Ws=new WeakMap,Ho=new WeakMap,Uo=new WeakMap;let au=Xp;const _s={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"]},ge={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Rf(d,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),d.clip(n)}class Op{isModifyingCurrentTransform(){return!1}getPattern(){Et("Abstract method `getPattern` called.")}}class Ky extends Op{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===ge.STROKE||n===ge.FILL){const a=e.current.getClippedPathBoundingBox(n,It(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=O.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Rf(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat");const u=new DOMMatrix(s);r.setTransform(u)}else Rf(t,this._bbox),r=this._createGradient(t);return r}}function Ju(d,t,e,s,n,r,a,o){const l=t.coords,h=t.colors,c=d.data,u=d.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,A=(l[e+1]+t.offsetY)*t.scaleY,y=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY,w=(l[n]+t.offsetX)*t.scaleX,E=(l[n+1]+t.offsetY)*t.scaleY;if(A>=E)return;const S=h[r],_=h[r+1],C=h[r+2],T=h[a],x=h[a+1],P=h[a+2],k=h[o],M=h[o+1],D=h[o+2],V=Math.round(A),G=Math.round(E);let $,st,I,H,W,ot,Pe,vs;for(let Mt=V;Mt<=G;Mt++){if(Mt<v){const bt=Mt<A?0:(A-Mt)/(A-v);$=b-(b-y)*bt,st=S-(S-T)*bt,I=_-(_-x)*bt,H=C-(C-P)*bt}else{let bt;Mt>E?bt=1:v===E?bt=0:bt=(v-Mt)/(v-E),$=y-(y-w)*bt,st=T-(T-k)*bt,I=x-(x-M)*bt,H=P-(P-D)*bt}let mt;Mt<A?mt=0:Mt>E?mt=1:mt=(A-Mt)/(A-E),W=b-(b-w)*mt,ot=S-(S-k)*mt,Pe=_-(_-M)*mt,vs=C-(C-D)*mt;const Be=Math.round(Math.min($,W)),He=Math.round(Math.max($,W));let ke=u*Mt+Be*4;for(let bt=Be;bt<=He;bt++)mt=($-bt)/($-W),mt<0?mt=0:mt>1&&(mt=1),c[ke++]=st-(st-ot)*mt|0,c[ke++]=I-(I-Pe)*mt|0,c[ke++]=H-(H-vs)*mt|0,c[ke++]=255}}function Jy(d,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 u=0;u<h;u++,c++)Ju(d,e,s[c],s[c+1],s[c+o],n[c],n[c+1],n[c+o]),Ju(d,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)Ju(d,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 Qy extends Op{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,u=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/u,A=c/p,y={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/b,scaleY:1/A},v=u+4,w=p+4,E=s.getCanvas("mesh",v,w),S=E.context,_=S.createImageData(u,p);if(e){const T=_.data;for(let x=0,P=T.length;x<P;x+=4)T[x]=e[0],T[x+1]=e[1],T[x+2]=e[2],T[x+3]=255}for(const T of this._figures)Jy(_,T,y);return S.putImageData(_,2,2),{canvas:E.canvas,offsetX:o-2*b,offsetY:l-2*A,scaleX:b,scaleY:A}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,n){Rf(t,this._bbox);const r=new Float32Array(2);if(n===ge.SHADING)O.singularValueDecompose2dScale(It(t),r);
2else if(this.matrix){O.singularValueDecompose2dScale(this.matrix,r);const[o,l]=r;O.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=o,r[1]*=l}else O.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,n===ge.SHADING?null:this._background,e.cachedCanvases);return n!==ge.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 Zy extends Op{getPattern(){return"hotpink"}}function tA(d){switch(d[0]){case"RadialAxial":return new Ky(d);case"Mesh":return new Qy(d);case"Dummy":return new Zy}throw new Error(`Unknown IR type: ${d[0]}`)}const dg={COLORED:1,UNCOLORED:2},Su=class Su{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){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),Nu("TilingType: "+a);const u=s[0],p=s[1],b=s[2],A=s[3],y=b-u,v=A-p,w=new Float32Array(2);O.singularValueDecompose2dScale(this.matrix,w);const[E,S]=w;O.singularValueDecompose2dScale(this.baseTransform,w);const _=E*w[0],C=S*w[1];let T=y,x=v,P=!1,k=!1;const M=Math.ceil(h*_),D=Math.ceil(c*C),V=Math.ceil(y*_),G=Math.ceil(v*C);M>=V?T=h:P=!0,D>=G?x=c:k=!0;const $=this.getSizeAndScale(T,this.ctx.canvas.width,_),st=this.getSizeAndScale(x,this.ctx.canvas.height,C),I=t.cachedCanvases.getCanvas("pattern",$.size,st.size),H=I.context,W=l.createCanvasGraphics(H,e);if(W.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(W,r,o),H.translate(-$.scale*u,-st.scale*p),W.transform(0,$.scale,0,0,st.scale,0,0),H.save(),W.dependencyTracker?.save(),this.clipBbox(W,u,p,b,A),W.baseTransform=It(W.ctx),W.executeOperatorList(n),W.endDrawing(),W.dependencyTracker?.restore(),H.restore(),P||k){const ot=I.canvas;P&&(T=h),k&&(x=c);const Pe=this.getSizeAndScale(T,this.ctx.canvas.width,_),vs=this.getSizeAndScale(x,this.ctx.canvas.height,C),Mt=Pe.size,mt=vs.size,Be=t.cachedCanvases.getCanvas("pattern-workaround",Mt,mt),He=Be.context,ke=P?Math.floor(y/h):0,bt=k?Math.floor(v/c):0;for(let Ke=0;Ke<=ke;Ke++)for(let Es=0;Es<=bt;Es++)He.drawImage(ot,Mt*Ke,mt*Es,Mt,mt,0,0,Mt,mt);return{canvas:Be.canvas,scaleX:Pe.scale,scaleY:vs.scale,offsetX:u,offsetY:p}}return{canvas:I.canvas,scaleX:$.scale,scaleY:st.scale,offsetX:u,offsetY:p}}getSizeAndScale(t,e,s){const n=Math.max(Su.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),O.axialAlignedBoundingBox([e,s,n,r],It(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const n=t.ctx,r=t.current;switch(e){case dg.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;n.fillStyle=r.fillColor=a,n.strokeStyle=r.strokeColor=o;break;case dg.UNCOLORED:n.fillStyle=n.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new vy(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,n,r){let a=s;n!==ge.SHADING&&(a=O.transform(a,e.baseTransform),this.matrix&&(a=O.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}};R(Su,"MAX_PATTERN_SIZE",3e3);let Mf=Su;function eA({src:d,srcPos:t=0,dest:e,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=le.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,u=s&7,p=d.length;e=new Uint32Array(e.buffer);let b=0;for(let A=0;A<n;A++){for(const v=t+c;t<v;t++){const w=t<p?d[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(u===0)continue;const y=t<p?d[t++]:255;for(let v=0;v<u;v++)e[b++]=y&1<<7-v?h:l}return{srcPos:t,destPos:b}}const ug=16,fg=100,sA=15,pg=10,Ye=16,Qu=new DOMMatrix,bs=new Float32Array(2),ro=new Float32Array([1/0,1/0,-1/0,-1/0]);function iA(d,t){if(d._removeMirroring)throw new Error("Context is already forwarding operations.");d.__originalSave=d.save,d.__originalRestore=d.restore,d.__originalRotate=d.rotate,d.__originalScale=d.scale,d.__originalTranslate=d.translate,d.__originalTransform=d.transform,d.__originalSetTransform=d.setTransform,d.__originalResetTransform=d.resetTransform,d.__originalClip=d.clip,d.__originalMoveTo=d.moveTo,d.__originalLineTo=d.lineTo,d.__originalBezierCurveTo=d.bezierCurveTo,d.__originalRect=d.rect,d.__originalClosePath=d.closePath,d.__originalBeginPath=d.beginPath,d._removeMirroring=()=>{d.save=d.__originalSave,d.restore=d.__originalRestore,d.rotate=d.__originalRotate,d.scale=d.__originalScale,d.translate=d.__originalTranslate,d.transform=d.__originalTransform,d.setTransform=d.__originalSetTransform,d.resetTransform=d.__originalResetTransform,d.clip=d.__originalClip,d.moveTo=d.__originalMoveTo,d.lineTo=d.__originalLineTo,d.bezierCurveTo=d.__originalBezierCurveTo,d.rect=d.__originalRect,d.closePath=d.__originalClosePath,d.beginPath=d.__originalBeginPath,delete d._removeMirroring},d.save=function(){t.save(),this.__originalSave()}
2,d.restore=function(){t.restore(),this.__originalRestore()},d.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},d.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},d.transform=function(e,s,n,r,a,o){t.transform(e,s,n,r,a,o),this.__originalTransform(e,s,n,r,a,o)},d.setTransform=function(e,s,n,r,a,o){t.setTransform(e,s,n,r,a,o),this.__originalSetTransform(e,s,n,r,a,o)},d.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},d.rotate=function(e){t.rotate(e),this.__originalRotate(e)},d.clip=function(e){t.clip(e),this.__originalClip(e)},d.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},d.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},d.bezierCurveTo=function(e,s,n,r,a,o){t.bezierCurveTo(e,s,n,r,a,o),this.__originalBezierCurveTo(e,s,n,r,a,o)},d.rect=function(e,s,n,r){t.rect(e,s,n,r),this.__originalRect(e,s,n,r)},d.closePath=function(){t.closePath(),this.__originalClosePath()},d.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class nA{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 vd(d,t,e,s,n,r,a,o,l,h){const[c,u,p,b,A,y]=It(d);if(u===0&&p===0){const E=a*c+A,S=Math.round(E),_=o*b+y,C=Math.round(_),T=(a+l)*c+A,x=Math.abs(Math.round(T)-S)||1,P=(o+h)*b+y,k=Math.abs(Math.round(P)-C)||1;return d.setTransform(Math.sign(c),0,0,Math.sign(b),S,C),d.drawImage(t,e,s,n,r,0,0,x,k),d.setTransform(c,u,p,b,A,y),[x,k]}if(c===0&&b===0){const E=o*p+A,S=Math.round(E),_=a*u+y,C=Math.round(_),T=(o+h)*p+A,x=Math.abs(Math.round(T)-S)||1,P=(a+l)*u+y,k=Math.abs(Math.round(P)-C)||1;return d.setTransform(0,Math.sign(u),Math.sign(p),0,S,C),d.drawImage(t,e,s,n,r,0,0,k,x),d.setTransform(c,u,p,b,A,y),[k,x]}d.drawImage(t,e,s,n,r,a,o,l,h);const v=Math.hypot(c,u),w=Math.hypot(p,b);return[v*l,w*h]}class gg{constructor(t,e,s){R(this,"alphaIsShape",!1);R(this,"fontSize",0);R(this,"fontSizeScale",1);R(this,"textMatrix",null);R(this,"textMatrixScale",1);R(this,"fontMatrix",sf);R(this,"leading",0);R(this,"x",0);R(this,"y",0);R(this,"lineX",0);R(this,"lineY",0);R(this,"charSpacing",0);R(this,"wordSpacing",0);R(this,"textHScale",1);R(this,"textRenderingMode",he.FILL);R(this,"textRise",0);R(this,"fillColor","#000000");R(this,"strokeColor","#000000");R(this,"patternFill",!1);R(this,"patternStroke",!1);R(this,"fillAlpha",1);R(this,"strokeAlpha",1);R(this,"lineWidth",1);R(this,"activeSMask",null);R(this,"transferMaps","none");s?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=ro.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=ge.FILL,e=null){const s=this.minMax.slice();if(t===ge.STROKE){e||Et("Stroke bounding box must include transform."),O.singularValueDecompose2dScale(e,bs);const n=bs[0]*this.lineWidth/2,r=bs[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=O.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(ro,0)}getClippedPathBoundingBox(t=ge.FILL,e=null){return O.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function mg(d,t){if(t instanceof ImageData){d.putImageData(t,0,0);return}const e=t.height,s=t.width,n=e%Ye,r=(e-n)/Ye,a=n===0?r:r+1,o=d.createImageData(s,Ye);let l=0,h;const c=t.data,u=o.data;let p,b,A,y;if(t.kind===bh.GRAYSCALE_1BPP){const v=c.byteLength,w=new Uint32Array(u.buffer,0,u.byteLength>>2),E=w.length,S=s+7>>3,_=4294967295,C=le.isLittleEndian?4278190080:255;for(p=0;p<a;p++){for(A=p<r?Ye:n,h=0,b=0;b<A;b++){const T=v-l;let x=0;const P=T>S?s:T*8-7,k=P&-8;let M=0,D=0;for(;x<k;x+=8)D=c[l++],w[h++]=D&128?_:C,w[h++]=D&64?_:C,w[h++]=D&32?_:C,w[h++]=D&16?_:C,w[h++]=D&8?_:C,w[h++]=D&4?_:C,w[h++]=D&2?_:C,w[h++]=D&1?_:C;for(;x<P;
2x++)M===0&&(D=c[l++],M=128),w[h++]=D&M?_:C,M>>=1}for(;h<E;)w[h++]=0;d.putImageData(o,0,p*Ye)}}else if(t.kind===bh.RGBA_32BPP){for(b=0,y=s*Ye*4,p=0;p<r;p++)u.set(c.subarray(l,l+y)),l+=y,d.putImageData(o,0,b),b+=Ye;p<a&&(y=s*n*4,u.set(c.subarray(l,l+y)),d.putImageData(o,0,b))}else if(t.kind===bh.RGB_24BPP)for(A=Ye,y=s*A,p=0;p<a;p++){for(p>=r&&(A=n,y=s*A),h=0,b=y;b--;)u[h++]=c[l++],u[h++]=c[l++],u[h++]=c[l++],u[h++]=255;d.putImageData(o,0,p*Ye)}else throw new Error(`bad image kind: ${t.kind}`)}function bg(d,t){if(t.bitmap){d.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,n=e%Ye,r=(e-n)/Ye,a=n===0?r:r+1,o=d.createImageData(s,Ye);let l=0;const h=t.data,c=o.data;for(let u=0;u<a;u++){const p=u<r?Ye:n;({srcPos:l}=eA({src:h,srcPos:l,dest:c,width:s,height:p,nonBlackColor:0})),d.putImageData(o,0,u*Ye)}}function Wl(d,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)d[s]!==void 0&&(t[s]=d[s]);d.setLineDash!==void 0&&(t.setLineDash(d.getLineDash()),t.lineDashOffset=d.lineDashOffset)}function Ed(d){d.strokeStyle=d.fillStyle="#000000",d.fillRule="nonzero",d.globalAlpha=1,d.lineWidth=1,d.lineCap="butt",d.lineJoin="miter",d.miterLimit=10,d.globalCompositeOperation="source-over",d.font="10px sans-serif",d.setLineDash!==void 0&&(d.setLineDash([]),d.lineDashOffset=0);const{filter:t}=d;t!=="none"&&t!==""&&(d.filter="none")}function yg(d,t){if(t)return!0;O.singularValueDecompose2dScale(d,bs);const e=Math.fround(si.pixelRatio*En.PDF_TO_CSS_UNITS);return bs[0]<=e&&bs[1]<=e}const rA=["butt","round","square"],aA=["miter","round","bevel"],oA={},Ag={};var ii,Df,Lf,If;const qp=class qp{constructor(t,e,s,n,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c){g(this,ii);this.ctx=t,this.current=new gg(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 nA(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){return typeof e=="string"?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background: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(...It(this.compositeCtx))}this.ctx.save(),Ed(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=It(this.ctx)}executeOperatorList(t,e,s,n,r){const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>pg&&typeof s=="function",u=c?Date.now()+sA:0;let p=0;const b=this.commonObjs,A=this.objs;let y,v;for(;;){if(n!==void 0&&l===n.nextBreakPoint)return n.breakIt(l,s),l;if(!r||r(l))if(y=o[l],v=a[l]??null,y!==Ul.dependency)v===null?this[y](l):this[y](l,...v);else for(const w of v){this.dependencyTracker?.recordNamedData(w,l);const E=w.startsWith("g_")?b:A;if(!E.has(w))return E.get(w,s),l}if(l++,l===h)return l;if(c&&++p>pg){if(Date.now()>u)return s(),l;p=0}}}endDrawing(){m(this,ii,Df).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,ii,Lf).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,u;for(;r>2&&o>1||a>2&&l>1;){let p=o,b=l;r>2&&o>1&&(p=o>
vendor: 1,542 bytes, line 2
2=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),u=c.context,u.clearRect(0,0,p,b),u.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){const s=this.ctx,{width:n,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=It(s);let h,c,u,p;if((e.bitmap||e.data)&&e.count>1){const M=e.bitmap||e.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.get(M),h||(h=new Map,this._cachedBitmapsMap.set(M,h));const D=h.get(c);if(D&&!o){const V=Math.round(Math.min(l[0],l[2])+l[4]),G=Math.round(Math.min(l[1],l[3])+l[5]);return this.dependencyTracker?.recordDependencies(t,_s.transformAndFill),{canvas:D,offsetX:V,offsetY:G}}u=D}u||(p=this.cachedCanvases.getCanvas("maskCanvas",n,r),bg(p.context,e));let b=O.transform(l,[1/n,0,0,-1/r,0,0]);b=O.transform(b,[1,0,0,1,0,-r]);const A=ro.slice();O.axialAlignedBoundingBox([0,0,n,r],b,A);const[y,v,w,E]=A,S=Math.round(w-y)||1,_=Math.round(E-v)||1,C=this.cachedCanvases.getCanvas("fillCanvas",S,_),T=C.context,x=y,P=v;T.translate(-x,-P),T.transform(...b),u||(u=this._scaleImage(p.canvas,ni(T)),u=u.img,h&&o&&h.set(c,u)),T.imageSmoothingEnabled=yg(It(T),e.interpolate),vd(T,u,0,0,u.width,u.height,0,0,n,r),T.globalCompositeOperation="source-in";const k=O.transform(ni(T),[1,0,0,1,-x,-P]);return T.fillStyle=o?a.getPattern(s,this,k,ge.FILL,t):a,T.fillRect(0,0,n,r),h&&!o&&
2(this.cachedCanvases.delete("fillCanvas"),h.set(c,C.canvas)),this.dependencyTracker?.recordDependencies(t,_s.transformAndFill),{canvas:C.canvas,offsetX:Math.round(x),offsetY:Math.round(P)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=rA[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=aA[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.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){for(const[s,n]of e)switch(s){case"LW":this.setLineWidth(t,n);break;case"LC":this.setLineCap(t,n);break;case"LJ":this.setLineJoin(t,n);break;case"ML":this.setMiterLimit(t,n);break;case"D":this.setDash(t,n[0],n[1]);break;case"RI":this.setRenderingIntent(t,n);break;case"FL":this.setFlatness(t,n);break;case"Font":this.setFont(t,n[0],n[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=n;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=n;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=n;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);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()),Wl(this.suspendedCtx,a),iA(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(),Wl(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,u){let p=t.canvas,b=l-c,A=h-u;if(a)if(b<0||A<0||b+s>p.width||A+n>p.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,n),w=v.context;w.drawImage(p,-b,-A),w.globalCompositeOperation="destination-atop",w.fillStyle=a,w.fillRect(0,0,s,n),w.globalCompositeOperation="source-over",p=v.canvas,b=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(b,A,s,n),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=a,t.fillRect(b,A,s,n),t.restore()}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 y=new Path2D;y.rect(l,h,s,n),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(p,b,A,s,n,l,h,s,n),e.restore(
2)}save(t){this.inSMaskMode&&Wl(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Wl(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,n,r,a,o){this.dependencyTracker?.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===Ul.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 gd.moveTo:a.moveTo(r[o++],r[o++]);break;case gd.lineTo:a.lineTo(r[o++],r[o++]);break;case gd.curveTo:a.bezierCurveTo(r[o++],r[o++],r[o++],r[o++],r[o++],r[o++]);break;case gd.closePath:a.closePath();break;default:q(`Unrecognized drawing path operator: ${r[o-1]}`);break}r=a}O.axialAlignedBoundingBox(n,It(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&r?.getPattern){const a=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,ni(n),ge.STROKE,t),a){const o=new Path2D;o.addPath(e,n.getTransform().invertSelf().multiplySelf(a)),e=o}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,_s.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(ge.STROKE,It(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){const n=this.ctx,r=this.current.fillColor,a=this.current.patternFill;let o=!1;if(a){const h=r.isModifyingCurrentTransform()?n.getTransform():null;if(this.dependencyTracker?.save(t),n.save(),n.fillStyle=r.getPattern(n,this,ni(n),ge.FILL,t),h){const c=new Path2D;c.addPath(e,n.getTransform().invertSelf().multiplySelf(h)),e=c}o=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),this.dependencyTracker?.recordDependencies(t,_s.fill),o&&(n.restore(),this.dependencyTracker?.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){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,_s.rawFillPath).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=oA}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Ag}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){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){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);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||sf,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&q("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=n.systemFontInfo?.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<ug?c=ug:s>fg&&(c=fg),this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.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){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}
2paintChar(t,e,s,n,r,a){const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,u=l.fontSize/l.fontSizeScale,p=c&he.FILL_STROKE_MASK,b=!!(c&he.ADD_TO_PATH_FLAG),A=l.patternFill&&!h.missingFile,y=l.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||b||A||y)&&!h.missingFile&&(v=h.getPathGenerator(this.commonObjs,e)),v&&(h.disableFontFace||A||y)){o.save(),o.translate(s,n),o.scale(u,-u),this.dependencyTracker?.recordCharacterBBox(t,o,h);let w;if(p===he.FILL||p===he.FILL_STROKE)if(r){w=o.getTransform(),o.setTransform(...r);const E=m(this,ii,If).call(this,v,w,r);o.fill(E)}else o.fill(v);if(p===he.STROKE||p===he.FILL_STROKE)if(a){w||(w=o.getTransform()),o.setTransform(...a);const{a:E,b:S,c:_,d:C}=w,T=O.inverseTransform(a),x=O.transform([E,S,_,C,0,0],T);O.singularValueDecompose2dScale(x,bs),o.lineWidth*=Math.max(bs[0],bs[1])/u,o.stroke(m(this,ii,If).call(this,v,w,a))}else o.lineWidth/=u,o.stroke(v);o.restore()}else(p===he.FILL||p===he.FILL_STROKE)&&(o.fillText(e,s,n),this.dependencyTracker?.recordCharacterBBox(t,o,h,u,s,n,()=>o.measureText(e))),(p===he.STROKE||p===he.FILL_STROKE)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,h,u,s,n,()=>o.measureText(e)).recordDependencies(t,_s.stroke),o.strokeText(e,s,n));b&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:It(o),x:s,y:n,fontSize:u,path:v}),this.dependencyTracker?.recordCharacterBBox(t,o,h,u,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 J(this,"isFontSubpixelAAEnabled",s)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,_s.showText).resetBBox(t),this.current.textRenderingMode&he.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,n=s.font;if(n.isType3Font){this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t);return}const r=s.fontSize;if(r===0){this.dependencyTracker?.recordOperation(t);return}const a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,h=s.wordSpacing,c=s.fontDirection,u=s.textHScale*c,p=e.length,b=n.vertical,A=b?1:-1,y=n.defaultVMetrics,v=r*s.fontMatrix[0],w=s.textRenderingMode===he.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(u,-1):a.scale(u,1);let E,S;if(s.patternFill){a.save();const P=s.fillColor.getPattern(a,this,ni(a),ge.FILL,t);E=It(a),a.restore(),a.fillStyle=P}if(s.patternStroke){a.save();const P=s.strokeColor.getPattern(a,this,ni(a),ge.STROKE,t);S=It(a),a.restore(),a.strokeStyle=P}let _=s.lineWidth;const C=s.textMatrixScale;if(C===0||_===0){const P=s.textRenderingMode&he.FILL_STROKE_MASK;(P===he.STROKE||P===he.FILL_STROKE)&&(_=this.getSinglePixelWidth())}else _/=C;if(o!==1&&(a.scale(o,o),_/=o),a.lineWidth=_,n.isInvalidPDFjsFont){const P=[];let k=0;for(const D of e)P.push(D.unicode),k+=D.width;const M=P.join("");if(a.fillText(M,0,0),this.dependencyTracker!==null){const D=a.measureText(M);this.dependencyTracker.recordBBox(t,this.ctx,-D.actualBoundingBoxLeft,D.actualBoundingBoxRight,-D.actualBoundingBoxAscent,D.actualBoundingBoxDescent).recordShowTextOperation(t)}
2s.x+=k*v*u,a.restore(),this.compose();return}let T=0,x;for(x=0;x<p;++x){const P=e[x];if(typeof P=="number"){T+=A*P*r/1e3;continue}let k=!1;const M=(P.isSpace?h:0)+l,D=P.fontChar,V=P.accent;let G,$,st=P.width;if(b){const W=P.vmetric||y,ot=-(P.vmetric?W[1]:st*.5)*v,Pe=W[2]*v;st=W?-W[0]:st,G=ot/o,$=(T+Pe)/o}else G=T/o,$=0;let I;if(n.remeasure&&st>0){I=a.measureText(D);const W=I.width*1e3/r*o;if(st<W&&this.isFontSubpixelAAEnabled){const ot=st/W;k=!0,a.save(),a.scale(ot,1),G/=ot}else st!==W&&(G+=(st-W)/2e3*r/o)}if(this.contentVisible&&(P.isInFont||n.missingFile)){if(w&&!V)a.fillText(D,G,$),this.dependencyTracker?.recordCharacterBBox(t,a,I?{bbox:null}:n,r/o,G,$,()=>I??a.measureText(D));else if(this.paintChar(t,D,G,$,E,S),V){const W=G+r*V.offset.x/o,ot=$-r*V.offset.y/o;this.paintChar(t,V.fontChar,W,ot,E,S)}}const H=b?st*v-M*c:st*v+M*c;T+=H,k&&a.restore()}b?s.y-=T:s.x+=T*u,a.restore(),this.compose(),this.dependencyTracker?.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,u=n.textHScale*o,p=n.fontMatrix||sf,b=e.length,A=n.textRenderingMode===he.INVISIBLE;let y,v,w,E;if(A||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(u,o);const S=this.dependencyTracker;for(this.dependencyTracker=S?new au(S,t):null,y=0;y<b;
2++y){if(v=e[y],typeof v=="number"){E=l*v*a/1e3,this.ctx.translate(E,0),n.x+=E*u;continue}const _=(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()):q(`Type3 character "${v.operatorListId}" is not available.`);const T=[v.width,0];O.applyTransform(T,p),w=T[0]*a+_,s.translate(w,0),n.x+=w*u}s.restore(),S&&(this.dependencyTracker=S)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,n,r,a,o){const l=new Path2D;l.rect(n,r,a-n,o-r),this.ctx.clip(l),this.dependencyTracker?.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||It(this.ctx),r={createCanvasGraphics:(a,o)=>new qp(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new au(this.dependencyTracker,o,!0):null)};s=new Mf(e,this.ctx,r,n)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
2setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,s=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=tA(this.getObject(t,e)),this.cachedPatterns.set(e,n)),s&&(n.matrix=s),n}shadingFill(t,e){if(!this.contentVisible)return;const s=this.ctx;this.save(t);const n=this._getPattern(t,e);s.fillStyle=n.getPattern(s,this,ni(s),ge.SHADING,t);const r=ni(s);if(r){const{width:a,height:o}=s.canvas,l=ro.slice();O.axialAlignedBoundingBox([0,0,a,o],r,l);const[h,c,u,p]=l;this.ctx.fillRect(h,c,u-h,p-c)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,_s.transform).recordDependencies(t,_s.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){Et("Should not call beginInlineImage")}beginImageData(){Et("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=It(this.ctx),s)){O.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[n,r,a,o]=s,l=new Path2D;l.rect(n,r,a-n,o-r),this.ctx.clip(l),this.dependencyTracker?.recordClipBox(t,this.ctx,n,a,r,o),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;
2e.isolated||Nu("TODO: Support non-isolated groups."),e.knockout&&q("Knockout groups not supported.");const n=It(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=ro.slice();O.axialAlignedBoundingBox(e.bbox,It(s),r);const a=[0,0,s.canvas.width,s.canvas.height];r=O.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 u="groupAt"+this.groupLevel;e.smask&&(u+="_smask_"+this.smaskCounter++%2);const p=this.cachedCanvases.getCanvas(u,h,c),b=p.context;b.translate(-o,-l),b.transform(...n);let A=new Path2D;const[y,v,w,E]=e.bbox;if(A.rect(y,v,w-y,E-v),e.matrix){const S=new Path2D;S.addPath(A,new DOMMatrix(e.matrix)),A=S}b.clip(A),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()),Wl(s,b),this.ctx=b,this.dependencyTracker?.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){if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const r=It(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...r);const a=ro.slice();O.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],r,a),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,e,s,n,r,a){if(m(this,ii,Df).call(this),Ed(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,O.singularValueDecompose2dScale(It(this.ctx),bs);const{viewportScale:h}=this,c=Math.ceil(o*this.outputScaleX*h),u=Math.ceil(l*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);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(bs[0],0,0,-bs[1],0,l*bs[1]),Ed(this.ctx)}else{Ed(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],o,l),this.ctx.clip(h)}}this.current=new gg(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,ii,Lf).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){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),this.dependencyTracker?.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){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=this.ctx;l.save();const h=It(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]),this.dependencyTracker?.resetBBox(t);for(let u=0,p=o.length;u<p;u+=2){const b=O.transform(h,[s,n,r,a,o[u],o[u+1]]);l.drawImage(c.canvas,b[4],b[5]),this.dependencyTracker?.recordBBox(t,this.ctx,b[4],b[4]+c.canvas.width,b[5],b[5]+c.canvas.height)}l.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx,n=this.current.fillColor,r=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,_s.transformAndFill);for(const a of e){const{data:o,width:l,height:h,transform:c}=a,u=this.cachedCanvases.getCanvas("maskCanvas",l,h),p=u.context;p.save();const b=this.getObject(t,o,a);bg(p,b),p.globalCompositeOperation="source-in",p.fillStyle=r?n.getPattern(p,this,ni(s),ge.FILL,t):n,p.fillRect(0,0,l,h),p.restore(
2),s.save(),s.transform(...c),s.scale(1,-1),vd(s,u.canvas,0,0,l,h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,s,0,l,0,h),s.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){q("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){q("Dependent image isn't ready yet");return}const o=a.width,l=a.height,h=[];for(let c=0,u=r.length;c<u;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){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 c=this.cachedCanvases.getCanvas("inlineImage",s,n).context;mg(c,e),o=this.applyTransferMapsToCanvas(c)}const l=this._scaleImage(o,ni(r));r.imageSmoothingEnabled=yg(It(r),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,r,0,s,-n,0).recordDependencies(t,_s.imageXObject).recordOperation(t),vd(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-n,s,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible)return;const n=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const a=e.width,o=e.height,h=this.cachedCanvases.getCanvas("inlineImage",a,o).context;mg(h,e),r=this.applyTransferMapsToCanvas(h)}this.dependencyTracker?.resetBBox(t);for(const a of s)n.save(),n.transform(...a.transform),n.scale(1,-1),vd(n,r,a.x,a.y,a.w,a.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,_s.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){this.dependencyTracker?.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(n||(this.pendingClip===Ag?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=It(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,u=h*t;a=c<1?1/c:1,o=u<1?1/u: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 u=t*l;a=c>u?c/u:1,o=h>u?h/u: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),Qu.a=1/r,Qu.d=1/a;const l=new Path2D;if(l.addPath(t,Qu),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}};ii=new WeakSet,Df=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)},Lf=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}}},If=function(t,e,s){const n=new Path2D;return n.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),n};let co=qp;for(const d in Ul)co.prototype[d]!==void 0&&(co.prototype[Ul[d]]=co.prototype[d]);var $o,jo,ic,Go,Ld;const oo=class oo{constructor(t){g(this,Go);g(this,$o);g(this,jo);g(this,ic);f(this,$o,t),f(this,jo,new DataView(i(this,$o))),f(this,ic,new TextDecoder)}static write(t){const e=new TextEncoder,s={};let n=0;for(const h of oo.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 oo.strings){const c=s[h],u=c.length;o.setUint32(l,u),a.set(c,l+4),l+=4+u}return it(l===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}get fontFamily(){return m(this,Go,Ld).call(this,0)}get fontWeight(){return m(this,Go,Ld).call(this,1)}get italicAngle(){return m(this,Go,Ld).call(this,2)}};$o=new WeakMap,jo=new WeakMap,ic=new WeakMap,Go=new WeakSet,Ld=function(t){it(t<oo.strings.length,"Invalid string index");let e=0;for(let n=0;n<t;n++)e+=i(this,jo).getUint32(e)+4;const s=i(this,jo).getUint32(e);return i(this,ic).decode(new Uint8Array(i(this,$o),e+4,s))},R(oo,"strings",["fontFamily","fontWeight","italicAngle"]);let ou=oo;var Xn,yi,ra,aa,oh;const lo=class lo{constructor(t){g(this,aa);g(this,Xn);g(this,yi);g(this,ra);f(this,Xn,t),f(this,yi,new DataView(i(this,Xn))),f(this,ra,new TextDecoder)}static write(t){const e=new TextEncoder,s={};let n=0;for(const p of lo.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 u=0;c.setUint8(u++,t.guessFallback?1:0),c.setUint32(u,0),u+=4,n=0;for(const p of lo.strings){const b=s[p],A=b.length;n+=4+A,c.setUint32(u,A),h.set(b,u+4),u+=4+A}return c.setUint32(u-n-4,n),t.style&&(c.setUint32(u,r.length),h.set(r,u+4),u+=4+r.length,c.setUint32(u,a.length),h.set(a,u+4),u+=4+a.length),it(u<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(u)}get guessFallback(){return i(this,yi).getUint8(0)!==0}get css(){return m(this,aa,oh).call(this,0)}get loadedName(){return m(this,aa,oh).call(this,1)}get baseFontName(){return m(this,aa,oh).call(this,2)}get src(){return m(this,aa,oh).call(this,3)}get style(){let t=1;t+=4+i(this,yi).getUint32(t);const e=i(this,yi).getUint32(t),s=i(this,ra).decode(new Uint8Array(i(this,Xn),t+4,e));t+=4+e;const n=i(this,yi).getUint32(t),r=i(this,ra).decode(new Uint8Array(i(this,Xn),t+4,n));return{style:s,weight:r}}};Xn=new WeakMap,yi=new WeakMap,ra=new WeakMap,aa=new WeakSet,oh=function(t){it(t<lo.strings.length,"Invalid string index");let e=5;for(let n=0;n<t;n++)e+=i(this,yi).getUint32(e)+4;const s=i(this,yi).getUint32(e);return i(this,ra).decode(new Uint8Array(i(this,Xn),e+4,s))},R(lo,"strings",["css","loadedName","baseFontName","src"]);let lu=lo;var zo,Vo,Wo,Xo,ss,Ai,nc,ft,$t,Us,Id,lh;const K=class K{constructor({data:t,extra:e}){g(this,$t);g(this,Ai);g(this,nc);g(this,ft);f(this,Ai,t),f(this,nc,new TextDecoder),f(this,ft,new DataView(i(this,Ai))),e&&Object.assign(this,e)}get black(){return m(this,$t,Us).call(this,0)}get bold(){return m(this,$t,Us).call(this,1)}get disableFontFace(){return m(this,$t,Us).call(this,2)}get fontExtraProperties(){return m(this,$t,Us).call(this,3)}get isInvalidPDFjsFont(){return m(this,$t,Us).call(this,4)}get isType3Font(){return m(this,$t,Us).call(this,5)}get italic(){return m(this,$t,Us).call(this,6)}get missingFile(){return m(this,$t,Us).call(this,7)}get remeasure(){return m(this,$t,Us).call(this,8)}get vertical(){return m(this,$t,Us).call(this,9)}get ascent(){return m(this,$t,Id).call(this,0)}get defaultWidth(){return m(this,$t,Id).call(this,1)}get descent(){return m(this,$t,Id).call(this,2)}get bbox(){let t=i(K,Vo);if(i(this,ft).getUint8(t)===0)return;t+=1;const s=[];for(let n=0;n<4;n++)s.push(i(this,ft).getInt16(t,!0)),t+=2;return s}get fontMatrix(){let t=i(K,Wo);if(i(this,ft).getUint8(t)===0)return;t+=1;const s=[];for(let n=0;n<6;n++)s.push(i(this,ft).getFloat64(t,!0)),t+=8;return s}get defaultVMetrics(){let t=i(K,Xo);if(i(this,ft).getUint8(t)===0)return;t+=1;const s=[];for(let n=0;n<3;n++)s.push(i(this,ft).getInt16(t,!0)),t+=2;return s}get fallbackName(){return m(this,$t,lh).call(this,0)}get loadedName(){return m(this,$t,lh).call(this,1)}get mimetype(){return m(this,$t,lh).call(this,2)}get name(){return m(this,$t,lh).call(this,3)}get data(){let t=i(K,ss);const e=i(this,ft).getUint32(t);t+=4+e;const s=i(this,ft).getUint32(t);t+=4+s;const n=i(this,ft).getUint32(t);t+=4+n;const r=i(this,ft).getUint32(t);if(r!==0)return new Uint8Array(i(this,Ai),t+4,r)}clearData(){let t=i(K,ss);const e=i(this,ft).getUint32(t);t+=4+e;const s=i(this,ft).getUint32(t);t+=4+s;const n=i(this,ft).getUint32(t);t+=4+n;const r=i(this,ft).getUint32(t);new Uint8Array(i(this,Ai),t+4,r).fill(0),i(this,ft).setUint32(t,0)}get cssFontInfo(){let t=i(K,ss);const e=i(this,ft).getUint32(t);t+=4+e;const s=i(this,ft).getUint32(t);t+=4+s;const n=i(this,ft).getUint32(t);if(n===0)return null;
2const r=new Uint8Array(n);return r.set(new Uint8Array(i(this,Ai),t+4,n)),new ou(r.buffer)}get systemFontInfo(){let t=i(K,ss);const e=i(this,ft).getUint32(t);t+=4+e;const s=i(this,ft).getUint32(t);if(s===0)return null;const n=new Uint8Array(s);return n.set(new Uint8Array(i(this,Ai),t+4,s)),new lu(n.buffer)}static write(t){const e=t.systemFontInfo?lu.write(t.systemFontInfo):null,s=t.cssFontInfo?ou.write(t.cssFontInfo):null,n=new TextEncoder,r={};let a=0;for(const y of K.strings)r[y]=n.encode(t[y]),a+=4+r[y].length;const o=i(K,ss)+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 u=0;const p=K.bools.length;let b=0,A=0;for(let y=0;y<p;y++){const v=t[K.bools[y]];b|=(v===void 0?0:v?2:1)<<A,A+=2,(A===8||y===p-1)&&(c.setUint8(u++,b),b=0,A=0)}it(u===i(K,zo),"FontInfo.write: Boolean properties offset mismatch");for(const y of K.numbers)c.setFloat64(u,t[y]),u+=8;if(it(u===i(K,Vo),"FontInfo.write: Number properties offset mismatch"),t.bbox){c.setUint8(u++,4);for(const y of t.bbox)c.setInt16(u,y,!0),u+=2}else c.setUint8(u++,0),u+=8;if(it(u===i(K,Wo),"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){c.setUint8(u++,6);for(const y of t.fontMatrix)c.setFloat64(u,y,!0),u+=8}else c.setUint8(u++,0),u+=48;if(it(u===i(K,Xo),"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){c.setUint8(u++,1);for(const y of t.defaultVMetrics)c.setInt16(u,y,!0),u+=2}else c.setUint8(u++,0),u+=6;it(u===i(K,ss),"FontInfo.write: DefaultVMetrics properties offset mismatch"),c.setUint32(i(K,ss),0),u+=4;for(const y of K.strings){const v=r[y],w=v.length;c.setUint32(u,w),h.set(v,u+4),u+=4+w}if(c.setUint32(i(K,ss),u-i(K,ss)-4),!e)c.setUint32(u,0),u+=4;else{const y=e.byteLength;c.setUint32(u,y),it(u+4+y<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(e),u+4),u+=4+y}if(!s)c.setUint32(u,0),u+=4;else{const y=s.byteLength;c.setUint32(u,y),it(u+4+y<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(s),u+4),u+=4+y}return t.data===void 0?(c.setUint32(u,0),u+=4):(c.setUint32(u,t.data.length),h.set(t.data,u+4),u+=4+t.data.length),it(u<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(u)}};zo=new WeakMap,Vo=new WeakMap,Wo=new WeakMap,Xo=new WeakMap,ss=new WeakMap,Ai=new WeakMap,nc=new WeakMap,ft=new WeakMap,$t=new WeakSet,Us=function(t){it(t<K.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,n=i(this,ft).getUint8(e)>>s&3;return n===0?void 0:n===2},Id=function(t){return it(t<K.numbers.length,"Invalid number index"),i(this,ft).getFloat64(i(K,zo)+t*8)},lh=function(t){it(t<K.strings.length,"Invalid string index");let e=i(K,ss)+4;for(let r=0;r<t;r++)e+=i(this,ft).getUint32(e)+4;const s=i(this,ft).getUint32(e),n=new Uint8Array(s);return n.set(new Uint8Array(i(this,Ai),e+4,s)),i(this,nc).decode(n)},R(K,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),R(K,"numbers",["ascent","defaultWidth","descent"]),R(K,"strings",["fallbackName","loadedName","mimetype","name"]),g(K,zo,Math.ceil(K.bools.length*2/8)),g(K,Vo,i(K,zo)+K.numbers.length*8),g(K,Wo,i(K,Vo)+1+8),g(K,Xo,i(K,Wo)+1+48),g(K,ss,i(K,Xo)+1+6);let Ff=K;var rc,ac;class ti{static get workerPort(){return i(this,rc)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");f(this,rc,t)}static get workerSrc(){return i(this,ac)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");f(this,ac,t)}}rc=new WeakMap,ac=new WeakMap,g(ti,rc,null),g(ti,ac,"");var qo,oc;class lA{constructor({parsedData:t,rawData:e}){g(this,qo);g(this,oc);f(this,qo,t),f(this,oc,e)}getRaw(){return i(this,oc)}get(t){return i(this,qo).get(t)??null}[Symbol.iterator](){return i(this,qo).entries()}}qo=new WeakMap,oc=new WeakMap;const so=Symbol("INTERNAL");var lc,hc,cc,Yo;class hA{constructor(t,{name:e,intent:s,usage:n,rbGroups:r}){g(this,lc,!1);g(this,hc,!1);g(this,cc,!1);g(this,Yo,!0);f(this,lc,!!(t&ms.DISPLAY)),f(this,hc,!!(t&ms.PRINT)),this.name=e,this.intent=s,this.usage=n,this.rbGroups=r}get visible(){if(i(this,cc))return i(this,Yo);if(!i(this,Yo))return!1;const{print:t,view:e}=this.usage;return i(this,lc)?e?.viewState!=="OFF":i(this,hc)?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==so&&Et("Internal method `_setVisible` called."),f(this,cc,s),f(this,Yo,e)}}lc=new WeakMap,hc=new WeakMap,cc=new WeakMap,Yo=new WeakMap;var qn,pt,Ko,Jo,dc,Nf;class cA{constructor(t,e=ms.DISPLAY){g(this,dc);g(this,qn,null);g(this,pt,new Map);g(this,Ko,null);g(this,Jo,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,f(this,Jo,t.order);for(const s of t.groups)i(this,pt).set(s.id,new hA(e,s));if(t.baseState==="OFF")for(const s of i(this,pt).values())s._setVisible(so,!1);for(const s of t.on)i(this,pt).get(s)._setVisible(so,!0);for(const s of t.off)i(this,pt).get(s)._setVisible(so,!1);f(this,Ko,this.getHash())}}isVisible(t){if(i(this,pt).size===0)return!0;
2if(!t)return Nu("Optional content group not defined."),!0;if(t.type==="OCG")return i(this,pt).has(t.id)?i(this,pt).get(t.id).visible:(q(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,dc,Nf).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!i(this,pt).has(e))return q(`Optional content group not found: ${e}`),!0;if(i(this,pt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!i(this,pt).has(e))return q(`Optional content group not found: ${e}`),!0;if(!i(this,pt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!i(this,pt).has(e))return q(`Optional content group not found: ${e}`),!0;if(!i(this,pt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!i(this,pt).has(e))return q(`Optional content group not found: ${e}`),!0;if(i(this,pt).get(e).visible)return!1}return!0}return q(`Unknown optional content policy ${t.policy}.`),!0}return q(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){const n=i(this,pt).get(t);if(!n){q(`Optional content group not found: ${t}`);return}if(s&&e&&n.rbGroups.length)for(const r of n.rbGroups)for(const a of r)a!==t&&i(this,pt).get(a)?._setVisible(so,!1,!0);n._setVisible(so,!!e,!0),f(this,qn,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,pt).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,qn,null)}get hasInitialVisibility(){return i(this,Ko)===null||this.getHash()===i(this,Ko)}getOrder(){return i(this,pt).size?i(this,Jo)?i(this,Jo).slice():[...i(this,pt).keys()]:null}getGroup(t){return i(this,pt).get(t)||null}getHash(){if(i(this,qn)!==null)return i(this,qn);const t=new wm;for(const[e,s]of i(this,pt))t.update(`${e}:${s.visible}`);return f(this,qn,t.hexdigest())}[Symbol.iterator](){return i(this,pt).entries()}}qn=new WeakMap,pt=new WeakMap,Ko=new WeakMap,Jo=new WeakMap,dc=new WeakSet,Nf=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,dc,Nf).call(this,r);else if(i(this,pt).has(r))a=i(this,pt).get(r).visible;else return q(`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 dA{constructor(t,{disableRange:e=!1,disableStream:s=!1}){it(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?.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)});it(n,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){it(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new uA(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new fA(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class uA{constructor(t,e,s=!1,n=null){this._stream=t,this._done=s||!1,this._filename=Bu(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 fA{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 pA(d){let t=!0,e=s("filename\\*","i").exec(d);if(e){e=e[1];let c=o(e);return c=unescape(c),c=l(c),c=h(c),r(c)}if(e=a(d),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(d),e){e=e[1];let c=o(e);return c=h(c),r(c)}function s(c,u){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function n(c,u){if(c){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const p=new TextDecoder(c,{fatal:!0}),b=od(u);u=p.decode(b),t=!1}catch{}}return u}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 u=[];let p;const b=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(p=b.exec(c))!==null;){let[,y,v,w]=p;if(y=parseInt(y,10),y in u){if(y===0)break;continue}u[y]=[v,w]}const A=[];for(let y=0;y<u.length&&y in u;++y){let[v,w]=u[y];w=o(w),v&&(w=unescape(w),y===0&&(w=l(w))),A.push(w)}return A.join("")}function o(c){if(c.startsWith('"')){const u=c.slice(1).split('\\"');for(let p=0;p<u.length;++p){const b=u[p].indexOf('"');b!==-1&&(u[p]=u[p].slice(0,b),u.length=p+1),u[p]=u[p].replaceAll(/\\(.)/g,"$1")}c=u.join('"')}return c}function l(c){const u=c.indexOf("'");if(u===-1)return c;const p=c.slice(0,u),A=c.slice(u+1).replace(/^[^']*'/,"");return n(p,A)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(u,p,b,A){if(b==="q"||b==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(y,v){return String.fromCharCode(parseInt(v,16))}),n(p,A);try{A=atob(A)}catch{}return n(p,A)})}return""}function Lm(d,t){const e=new Headers;if(!d||!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 Hu(d){return URL.parse(d)?.origin??null}function Im({responseHeaders:d,isHttp:t,rangeChunkSize:e,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(d.get("Content-Length"),10);return!Number.isInteger(r)||(n.suggestedLength=r,r<=2*e)||s||!t||d.get("Accept-Ranges")!=="bytes"||(d.get("Content-Encoding")||"identity")!=="identity"||(n.allowRangeRequests=!0),n}function Fm(d){const t=d.get("Content-Disposition");if(t){let e=pA(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Bu(e))return e}return null}function dd(d,t){return new Ah(`Unexpected server response (${d}) while retrieving PDF "${t}".`,d,d===404||d===0&&t.startsWith("file:"))}function Nm(d){return d===200||d===206}
2function Om(d,t,e){return{method:"GET",headers:d,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Bm(d){return d instanceof Uint8Array?d.buffer:d instanceof ArrayBuffer?d:(q(`getArrayBuffer - unexpected data format: ${d}`),new Uint8Array(d).buffer)}class gA{constructor(t){R(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Lm(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return it(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new mA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new bA(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class mA{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,Om(s,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=Hu(r.url),!Nm(r.status))throw dd(r.status,n);this._reader=r.body.getReader(),this._headersCapability.resolve();const a=r.headers,{allowRangeRequests:o,suggestedLength:l}=Im({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=Fm(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new vn("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Bm(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class bA{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,Om(r,this._withCredentials,this._abortController)).then(o=>{const l=Hu(o.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!Nm(o.status))throw dd(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(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Bm(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const Zu=200,tf=206;function yA(d){const t=d.response;return typeof t!="string"?t:od(t).buffer}class AA{constructor({url:t,httpHeaders:e,withCredentials:s}){R(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Lm(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=tf):n.expectedStatus=Zu,e.responseType="arraybuffer",it(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){const s=this.pendingRequests[t];s&&s.onProgress?.(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||Zu;if(!(r===Zu&&s.expectedStatus===tf)&&r!==s.expectedStatus){s.onError(n.status);return}const o=yA(n);if(r===tf){const l=n.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);h?s.onDone({begin:parseInt(h[1],10),chunk:o}):(q('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 wA{constructor(t){this._source=t,this._manager=new AA(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 it(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new vA(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new EA(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class vA{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=Hu(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}=Im({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=Fm(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=dd(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){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._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 EA{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(){const t=Hu(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=dd(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest
2(this._requestId),this._close()}}const SA=/^[a-z][a-z0-9\-+.]+:/i;function _A(d){if(SA.test(d))return new URL(d);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(d))}class CA{constructor(t){this.source=t,this.url=_A(t.url),it(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return it(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new TA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new xA(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class TA{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=dd(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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new vn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class xA{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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Xl=Symbol("INITIAL_DATA");var is,uc,Of;class Hm{constructor(){g(this,uc);g(this,is,Object.create(null))}get(t,e=null){if(e){const n=m(this,uc,Of).call(this,t);return n.promise.then(()=>e(n.data)),null}const s=i(this,is)[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,is)[t];return!!e&&e.data!==Xl}delete(t){const e=i(this,is)[t];return!e||e.data===Xl?!1:(delete i(this,is)[t],!0)}resolve(t,e=null){const s=m(this,uc,Of).call(this,t);s.data=e,s.resolve()}clear(){for(const t in i(this,is)){const{data:e}=i(this,is)[t];e?.bitmap?.close()}f(this,is,Object.create(null))}*[Symbol.iterator](){for(const t in i(this,is)){const{data:e}=i(this,is)[t];e!==Xl&&(yield[t,e])}}}is=new WeakMap,uc=new WeakSet,Of=function(t){var e;return(e=i(this,is))[t]||(e[t]={...Promise.withResolvers(),data:Xl})};const PA=1e5,wg=30;var Yn,We,fc,pc,oa,en,gc,mc,la,Qo,Zo,Kn,tl,bc,el,ha,yc,Ac,Ut,sl,ca,wc,Jn,il,_n,Um,$m,Bf,As,Fd,Hf,jm,Gm;let Sh=(Ut=class{constructor({textContentSource:t,container:e,viewport:s}){g(this,_n);g(this,Yn,Promise.withResolvers());g(this,We,null);g(this,fc,!1);g(this,pc,!!globalThis.FontInspector?.enabled);g(this,oa,null);g(this,en,null);g(this,gc,0);g(this,mc,0);g(this,la,null);g(this,Qo,null);g(this,Zo,0);g(this,Kn,0);g(this,tl,Object.create(null));g(this,bc,[]);g(this,el,null);g(this,ha,[]);g(this,yc,new WeakMap);g(this,Ac,null);var l;if(t instanceof ReadableStream)f(this,el,t);else if(typeof t=="object")f(this,el,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');f(this,We,f(this,Qo,e)),f(this,Kn,s.scale*si.pixelRatio),f(this,Zo,s.rotation),f(this,en,{div:null,properties:null,ctx:null});const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;f(this,Ac,[1,0,0,-1,-a,o+r]),f(this,mc,n),f(this,gc,r),m(l=Ut,As,jm).call(l),Er(e,s),i(this,Yn).promise.finally(()=>{i(Ut,il).delete(this),f(this,en,null),f(this,tl,null)}
2).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=le.platform;return J(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{i(this,la).read().then(({value:e,done:s})=>{if(s){i(this,Yn).resolve();return}i(this,oa)??f(this,oa,e.lang),Object.assign(i(this,tl),e.styles),m(this,_n,Um).call(this,e.items),t()},i(this,Yn).reject)};return f(this,la,i(this,el).getReader()),i(Ut,il).add(this),t(),i(this,Yn).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*si.pixelRatio,n=t.rotation;if(n!==i(this,Zo)&&(e?.(),f(this,Zo,n),Er(i(this,Qo),{rotation:n})),s!==i(this,Kn)){e?.(),f(this,Kn,s);const a={div:null,properties:null,ctx:m(r=Ut,As,Fd).call(r,i(this,oa))};for(const o of i(this,ha))a.properties=i(this,yc).get(o),a.div=o,m(this,_n,Bf).call(this,a)}}cancel(){const t=new vn("TextLayer task cancelled.");i(this,la)?.cancel(t).catch(()=>{}),f(this,la,null),i(this,Yn).reject(t)}get textDivs(){return i(this,ha)}get textContentItemsStr(){return i(this,bc)}static cleanup(){if(!(i(this,il).size>0)){i(this,sl).clear();for(const{canvas:t}of i(this,ca).values())t.remove();i(this,ca).clear()}}},Yn=new WeakMap,We=new WeakMap,fc=new WeakMap,pc=new WeakMap,oa=new WeakMap,en=new WeakMap,gc=new WeakMap,mc=new WeakMap,la=new WeakMap,Qo=new WeakMap,Zo=new WeakMap,Kn=new WeakMap,tl=new WeakMap,bc=new WeakMap,el=new WeakMap,ha=new WeakMap,yc=new WeakMap,Ac=new WeakMap,sl=new WeakMap,ca=new WeakMap,wc=new WeakMap,Jn=new WeakMap,il=new WeakMap,_n=new WeakSet,Um=function(t){var n,r;if(i(this,fc))return;(r=i(this,en)).ctx??(r.ctx=m(n=Ut,As,Fd).call(n,i(this,oa)));const e=i(this,ha),s=i(this,bc);for(const a of t){if(e.length>PA){q("Ignoring additional textDivs for performance reasons."),f(this,fc,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=i(this,We);f(this,We,document.createElement("span")),i(this,We).classList.add("markedContent"),a.id&&i(this,We).setAttribute("id",`${a.id}`),o.append(i(this,We))}else a.type==="endMarkedContent"&&f(this,We,i(this,We).parentNode);continue}s.push(a.str),m(this,_n,$m).call(this,a)}},$m=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};i(this,ha).push(e);const n=O.transform(i(this,Ac),t.transform);let r=Math.atan2(n[1],n[0]);const a=i(this,tl)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=i(this,pc)&&a.fontSubstitution||a.fontFamily;o=Ut.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*m(y=Ut,As,Gm).call(y,o,a,i(this,oa));let c,u;r===0?(c=n[4],u=n[5]-h):(c=n[4]+h*Math.sin(r),u=n[5]-h*Math.cos(r));const p="calc(var(--total-scale-factor) *",b=e.style;i(this,We)===i(this,Qo)?(b.left=`${(100*c/i(this,mc)).toFixed(2)}%`,b.top=`${(100*u/i(this,gc)).toFixed(2)}%`):(b.left=`${p}${c.toFixed(2)}px)`,b.top=`${p}${u.toFixed(2)}px)`),b.fontSize=`${p}${(i(Ut,Jn)*l).toFixed(2)}px)`,b.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,i(this,pc)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let A=!1;if(t.str.length>1)A=!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&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),i(this,yc).set(e,s),i(this,en).div=e,i(this,en).properties=s,m(this,_n,Bf).call(this,i(this,en)),s.hasText&&i(this,We).append(e),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),i(this,We).append(v)}},Bf=function(t){var o;const{div:e,properties:s,ctx:n}=t,{style:r}=e;let a="";if(i(Ut,Jn)>1&&(a=`scale(${1/i(Ut,Jn)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=r,{canvasWidth:h,fontSize:c}=s;m(o=Ut,As,Hf).call(o,n,c*i(this,Kn),l);const{width:u}=n.measureText(e.textContent);u>0&&(a=`scaleX(${h*i(this,Kn)/u}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)},As=new WeakSet,Fd=function(t=null){let e=i(this,ca).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,ca).set(t,e),i(this,wc).set(e,{size:0,family:""})}return e},Hf=function(t,e,s){const n=i(this,wc).get(t);e===n.size&&s===n.family||(t.font=`${e}px ${s}`,n.size=e,n.family=s)},jm=function(){if(i(this,Jn)!==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,Jn,t.getBoundingClientRect().height),t.remove()},Gm=function(t,e,s){const n=i(this,sl).get(t);if(n)return n;const r=m(this,As,Fd).call(this,s);r.canvas.width=r.canvas.height=wg,m(this,As,Hf).call(this,r,wg,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):(le.platform.isFirefox&&q("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.desce
2nt)),i(this,sl).set(t,h),h},g(Ut,As),g(Ut,sl,new Map),g(Ut,ca,new Map),g(Ut,wc,new WeakMap),g(Ut,Jn,null),g(Ut,il,new Set),Ut);const kA=100;function Bp(d={}){typeof d=="string"||d instanceof URL?d={url:d}:(d instanceof ArrayBuffer||ArrayBuffer.isView(d))&&(d={data:d});const t=new Uf,{docId:e}=t,s=d.url?Oy(d.url):null,n=d.data?By(d.data):null,r=d.httpHeaders||null,a=d.withCredentials===!0,o=d.password??null,l=d.range instanceof Hp?d.range:null,h=Number.isInteger(d.rangeChunkSize)&&d.rangeChunkSize>0?d.rangeChunkSize:2**16;let c=d.worker instanceof $l?d.worker:null;const u=d.verbosity,p=typeof d.docBaseUrl=="string"&&!hd(d.docBaseUrl)?d.docBaseUrl:null,b=bd(d.cMapUrl),A=d.cMapPacked!==!1,y=d.CMapReaderFactory||(Fe?Vy:ag),v=bd(d.iccUrl),w=bd(d.standardFontDataUrl),E=d.StandardFontDataFactory||(Fe?Wy:og),S=bd(d.wasmUrl),_=d.WasmFactory||(Fe?Xy:lg),C=d.stopAtErrors!==!0,T=Number.isInteger(d.maxImageSize)&&d.maxImageSize>-1?d.maxImageSize:-1,x=d.isEvalSupported!==!1,P=typeof d.isOffscreenCanvasSupported=="boolean"?d.isOffscreenCanvasSupported:!Fe,k=typeof d.isImageDecoderSupported=="boolean"?d.isImageDecoderSupported:!Fe&&(le.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(d.canvasMaxAreaInBytes)?d.canvasMaxAreaInBytes:-1,D=typeof d.disableFontFace=="boolean"?d.disableFontFace:Fe,V=d.fontExtraProperties===!0,G=d.enableXfa===!0,$=d.ownerDocument||globalThis.document,st=d.disableRange===!0,I=d.disableStream===!0,H=d.disableAutoFetch===!0,W=d.pdfBug===!0,ot=d.CanvasFactory||(Fe?zy:$y),Pe=d.FilterFactory||(Fe?Gy:jy),vs=d.enableHWA===!0,Mt=d.useWasm!==!1,mt=l?l.length:d.length??NaN,Be=typeof d.useSystemFonts=="boolean"?d.useSystemFonts:!Fe&&!D,He=typeof d.useWorkerFetch=="boolean"?d.useWorkerFetch:!!(y===ag&&E===og&&_===lg&&b&&w&&S&&Kl(b,document.baseURI)&&Kl(w,document.baseURI)&&Kl(S,document.baseURI)),ke=null;yy(u);const bt={canvasFactory:new ot({ownerDocument:$,enableHWA:vs}),filterFactory:new Pe({docId:e,ownerDocument:$}),cMapReaderFactory:He?null:new y({baseUrl:b,isCompressed:A}),standardFontDataFactory:He?null:new E({baseUrl:w}),wasmFactory:He?null:new _({baseUrl:S})};c||(c=$l.create({verbosity:u,port:ti.workerPort}),t._worker=c);const Ke={docId:e,apiVersion:"5.4.296",data:n,password:o,disableAutoFetch:H,rangeChunkSize:h,length:mt,docBaseUrl:p,enableXfa:G,evaluatorOptions:{maxImageSize:T,disableFontFace:D,ignoreErrors:C,isEvalSupported:x,isOffscreenCanvasSupported:P,isImageDecoderSupported:k,canvasMaxAreaInBytes:M,fontExtraProperties:V,useSystemFonts:Be,useWasm:Mt,useWorkerFetch:He,cMapUrl:b,iccUrl:v,standardFontDataUrl:w,wasmUrl:S}},Es={ownerDocument:$,pdfBug:W,styleElement:ke,loadingParams:{disableAutoFetch:H,enableXfa:G}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Vl=c.messageHandler.sendWithPromise("GetDocRequest",Ke,n?[n.buffer]:null);let Bs;if(l)Bs=new dA(l,{disableRange:st,disableStream:I});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");const Ct=Kl(s)?gA:Fe?CA:wA;Bs=new Ct({url:s,length:mt,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:st,disableStream:I})}return Vl.then(Ct=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const xt=new sh(e,Ct,c.port),Yt=new DA(xt,t,Bs,Es,bt,vs);t._transport=Yt,xt.send("Ready",null)})}).catch(t._capability.reject),t}var _u;const Cu=class Cu{constructor(){R(this,"_capability",Promise.withResolvers());R(this,"_transport",null);R(this,"_worker",null);R(this,"docId",`d${Kt(Cu,_u)._++}`);R(this,"destroyed",!1);R(this,"onPassword",null);R(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}};_u=new WeakMap,g(Cu,_u,0);let Uf=Cu;var da,vc,Ec,Sc,_c,Lg;let Hp=(Lg=class{constructor(t,e,s=!1,n=null){g(this,da,Promise.withResolvers());g(this,vc,[]);g(this,Ec,[]);g(this,Sc,[]);g(this,_c,[]);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=n}addRangeListener(t){i(this,_c).push(t)}addProgressListener(t){i(this,Sc).push(t)}addProgressiveReadListener(t){i(this,Ec).push(t)}addProgressiveDoneListener(t){i(this,vc).push(t)}onDataRange(t,e){for(const s of i(this,_c))s(t,e)}onDataProgress(t,e){i(this,da).promise.then(()=>{for(const s of i(this,Sc))s(t,e)})}onDataProgressiveRead(t){i(this,da).promise.then(()=>{for(const e of i(this,Ec))e(t)})}onDataProgressiveDone(){i(this,da).promise.then(()=>{for(const t of i(this,vc))t()})}transportReady(){i(this,da).resolve()}requestDataRange(t,e){Et("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},da=new WeakMap,vc=new WeakMap,Ec=new WeakMap,Sc=new WeakMap,_c=new WeakMap,Lg);class RA{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 J(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}
2=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var sn,ua,hh;class MA{constructor(t,e,s,n=!1){g(this,ua);g(this,sn,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=n?new Zp:null,this._pdfBug=n,this.commonObjs=s.commonObjs,this.objs=new Hm,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 ld({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return J(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}
2render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:n="display",annotationMode:r=Ri.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:u=null,isEditing:p=!1,recordOperations:b=!1,operationsFilter:A=null}){this._stats?.time("Overall");const y=this._transport.getRenderingIntent(n,r,u,p),{renderingIntent:v,cacheKey:w}=y;f(this,sn,!1),l||(l=this._transport.getOptionalContentConfig(v));let E=this._intentStates.get(w);E||(E=Object.create(null),this._intentStates.set(w,E)),E.streamReaderCancelTimeout&&(clearTimeout(E.streamReaderCancelTimeout),E.streamReaderCancelTimeout=null);const S=!!(v&ms.PRINT);E.displayReadyCapability||(E.displayReadyCapability=Promise.withResolvers(),E.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(y));const _=!!(this._pdfBug&&globalThis.StepperManager?.enabled),C=!this.recordedBBoxes&&(b||_),T=k=>{if(E.renderTasks.delete(x),C){const M=x.gfx?.dependencyTracker.take();M&&(x.stepper&&x.stepper.setOperatorBBoxes(M,x.gfx.dependencyTracker.takeDebugMetadata()),b&&(this.recordedBBoxes=M))}S&&f(this,sn,!0),m(this,ua,hh).call(this),k?(x.capability.reject(k),this._abortOperatorList({intentState:E,reason:k instanceof Error?k:new Error(k)})):x.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new $f({callback:T,params:{canvas:e,canvasContext:t,dependencyTracker:C?new Yy(e,E.operatorList.length,_):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:E.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!S,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:A});(E.renderTasks||(E.renderTasks=new Set)).add(x);const P=x.task;return Promise.all([E.displayReadyCapability.promise,l]).then(([k,M])=>{if(this.destroyed){T();return}if(this._stats?.time("Rendering"),!(M.renderingIntent&v))throw new Error("Mu
2st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:k,optionalContentConfig:M}),x.operatorListChanged()}).catch(T),P}getOperatorList({intent:t="display",annotationMode:e=Ri.ENABLE,printAnnotationStorage:s=null,isEditing:n=!1}={}){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},this._stats?.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=>wh.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,sn,!1),Promise.all(t)}cleanup(t=!1){f(this,sn,!0);const e=m(this,ua,hh).call(this);return t&&e&&this._stats&&(this._stats=new Zp),e}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,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,ua,hh).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:u,done:p})=>{if(p){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,h),c())},u=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const p of h.renderTasks)p.operatorListChanged();m(this,ua,hh).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(u);else if(h.opListReadCapability)h.opListReadCapability.reject(u);else throw u}})};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 Ou){let n=kA;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 vn(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}}sn=new WeakMap,ua=new WeakSet,hh=function(){if(!i(this,sn)||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,sn,!1),!0};var Qn,Xs,nn,fa,Tu,pa,ga,Ne,Nd,zm,Vm,ch,nl,Od;const Pt=class Pt{constructor({name:t=null,port:e=null,verbosity:s=Ay()}={}){g(this,Ne);g(this,Qn,Promise.withResolvers());g(this,Xs,null);g(this,nn,null);g(this,fa,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(i(Pt,ga).has(e))throw new Error("Cannot use more than one PDFWorker per port.");i(Pt,ga).set(e,this),m(this,Ne,zm).call(this,e)}else m(this,Ne,Vm).call(this)}get promise(){return i(this,Qn).promise}get port(){return i(this,nn)}get messageHandler(){return i(this,Xs)}destroy(){this.destroyed=!0,i(this,fa)?.terminate(),f(this,fa,null),i(Pt,ga).delete(i(this,nn)),f(this,nn,null),i(this,Xs)?.destroy(),f(this,Xs,null)}static create(t){const e=i(this,ga).get(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 Pt(t)}static get workerSrc(){if(ti.workerSrc)return ti.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return J(this,"_setupFakeWorkerGlobal",(async()=>i(this,nl,Od)?i(this,nl,Od):(await import(this.workerSrc)).WorkerMessageHandler)())}};Qn=new WeakMap,Xs=new WeakMap,nn=new WeakMap,fa=new WeakMap,Tu=new WeakMap,pa=new WeakMap,ga=new WeakMap,Ne=new WeakSet,Nd=function(){i(this,Qn).resolve(),i(this,Xs).send("configure",{verbosity:this.verbosity})},zm=function(t){f(this,nn,t),f(this,Xs,new sh("main","worker",t)),i(this,Xs).on("ready",()=>{}),m(this,Ne,Nd).call(this)},Vm=function(){if(i(Pt,pa)||i(Pt,nl,Od)){m(this,Ne,ch).call(this);return}let{workerSrc:t}=Pt;try{Pt._isSameOrigin(window.location,t)||(t=Pt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new sh("main","worker",e),n=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?i(this,Qn).reject(new Error("Worker was destroyed")):m(this,Ne,ch).call(this)},r=new AbortController;e.addEventListener("error",()=>{i(this,fa)||n()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){n();return}f(this,Xs,s),f(this,nn,e),f(this,fa,e),m(this,Ne,Nd).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){n();return}try{a()}catch{m(this,Ne,ch).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Nu("The worker has been disabled.")}m(this,Ne,ch).call(this)},ch=function(){i(Pt,pa)||(q("Setting up fake worker."),f(Pt,pa,!0)),Pt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){i(this,Qn).reject(new Error("Worker was destroyed"));return}const e=new Uy;f(this,nn,e);const s=`fake${Kt(Pt,Tu)._++}`,n=new sh(s+"_worker",s,e);t.setup(n,e),f(this,Xs,new sh(s,s+"_worker",e)),m(this,Ne,Nd).call(this)}).catch(t=>{i(this,Qn).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},nl=new WeakSet,Od=function(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}},g(Pt,nl),g(Pt,Tu,0),g(Pt,pa,!1),g(Pt,ga,new WeakMap),Fe&&(f(Pt,pa,!0),ti.workerSrc||(ti.workerSrc="./pdf.worker.mjs")),Pt._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!s?.origin||s.origin==="null")return!1;const n=new URL(e,s);return s.origin===n.origin},Pt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Pt.fromPort=t=>{if(Py("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return Pt.create(t)};let $l=Pt;var rn,wi,rl,al,an,ma,dh;class DA{constructor(t,e,s,n,r,a){g(this,ma);g(this,rn,new Map);g(this,wi,new Map);g(this,rl,new Map);g(this,al,new Map);g(this,an,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Hm,this.fontLoader=new Fy({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 J(this,"annotationStorage",new Fp)}getRenderingIntent(t,e=Ri.ENABLE,s=null,n=!1,r=!1){let a=ms.DISPLAY,o=_f;switch(t){case"any":a=ms.ANY;break;case"display":break;case"print":a=ms.PRINT;break;default:q(`getRenderingIntent - invalid intent: ${t}`)}const l=a&ms.PRINT&&s instanceof Em?s:this.annotationStorage;switch(e){case Ri.DISABLE:a+=ms.ANNOTATIONS_DISABLE;break;case Ri.ENABLE:break;case Ri.ENABLE_FORMS:a+=ms.ANNOTATIONS_FORMS;break;case Ri.ENABLE_STORAGE:a+=ms.ANNOTATIONS_STORAGE,o=l.serializable;break;default:q(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(a+=ms.IS_EDITING),r&&(a+=ms.OPLIST);const{ids:h,hash:c}=l.modifiedIds,u=[a,o.hash,c];
2return{renderingIntent:a,cacheKey:u.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),i(this,an)?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of i(this,wi).values())t.push(s._destroy());i(this,wi).clear(),i(this,rl).clear(),i(this,al).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),i(this,rn).clear(),this.filterFactory.destroy(),Sh.cleanup(),this._networkStream?.cancelAllRequests(new vn("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,n)=>{it(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}it(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=>{await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:a}=this._fullReader;return(!n||!r)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=o=>{e.onProgress?.({loaded:o.loaded,total:o.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,n)=>{it(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}it(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 RA(s,this))}),t.on("DocException",s=>{e._capability.reject(Ue(s))}),t.on("PasswordRequest",s=>{f(this,an,Promise.withResolvers());try{if(!e.onPassword)throw Ue(s);const n=r=>{r instanceof Error?i(this,an).reject(r):i(this,an).resolve({password:r})};e.onPassword(n,s.code)}catch(n){i(this,an).reject(n)}return i(this,an).promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;i(this,wi).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,n,r])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(n){case"Font":if("error"in r){const c=r.error;q(`Error during font loading: ${c}`),this.commonObjs.resolve(s,c);break}const a=new Ff(r),o=this._params.pdfBug&&globalThis.FontInspector?.enabled?(c,u)=>globalThis.FontInspector.fontAdded(c,u):null,l=new Ny(a,o,r.extra,r.charProcOperatorList);this.fontLoader.bind(l).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l.fontExtraProperties&&l.data&&l.clearData(),this.commonObjs.resolve(s,l)});break;case"CopyLocalImage":const{imageRef:h}=r;it(h,"The imageRef must be defined.");for(const c of i(this,wi).values())for(const[,u]of c.objs)if(u?.ref===h)return u.dataLen?(this.commonObjs.resolve(s,structuredClone(u)),u.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])=>{if(this.destroyed)return;const o=i(this,wi).get(n);if(!o.objs.has(s)){if(o._intentStates.size===0){a?.bitmap?.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=>{this.destroyed||e.onProgress?.({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(){this.annotationStorage.size<=0&&q("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=i(this,rl).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,al).set(r.refStr,t);const a=new MA(e,r,this,this._params.pdfBug);return i(this,wi).set(e,a),a});return i(this,rl).set(e,n),n}getPageIndex(t){return Cf(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,ma,dh).call(this,"GetFieldObjects")}hasJSActions(){return m(this,ma,dh).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,ma,dh).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,ma,dh).call(this,"GetOptionalContentConfig").then(e=>new cA(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=i(this,rn).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(n=>({info:n[0],metadata:n[1]?new lA(n[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return i(this,rn).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,wi).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),i(this,rn).clear(),this.filterFactory.destroy(!0),Sh.cleanup()}}cachedPageNumber(t){if(!Cf(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return i(this,al).get(e)??null}}rn=new WeakMap,wi=new WeakMap,rl=new WeakMap,al=new WeakMap,an=new WeakMap,ma=new WeakSet,dh=function(t,e=null){const s=i(this,rn).get(t);if(s)return s;const n=this.messageHandler.sendWithPromise(t,e);return i(this,rn).set(t,n),n};var Zn;class LA{constructor(t){g(this,Zn,null);R(this,"onContinue",null);R(this,"onError",null);f(this,Zn,t)}get promise(){return i(this,Zn).capability.promise}cancel(t=0){i(this,Zn).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=i(this,Zn).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=i(this,Zn);return t.form||t.canvas&&e?.size>0}}Zn=new WeakMap;var tr,ba;const Mr=class Mr{constructor({callback:t,params:e,objs:s,commonObjs:n,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:p=null,enableHWA:b=!1,operationsFilter:A=null}){g(this,tr,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=u,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 LA(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=A}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(i(Mr,ba).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(Mr,ba).add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{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 co(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,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),i(this,tr)&&(window.cancelAnimationFrame(i(this,tr)),f(this,tr,null)),i(Mr,ba).delete(this._canvas),t||(t=new Ou(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?f(this,tr,window.requestAnimationFrame(()=>{f(this,tr,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(Mr,ba).delete(this._canvas),this.callback())))}};tr=new WeakMap,ba=new WeakMap,g(Mr,ba,new WeakSet);let $f=Mr;const Wm="5.4.296",Xm="f56dc8601";var ns,ya,ol,Zt,Cc,ll,on,Tc,er,qs,xc,gt,jf,Gf,zf,xr,qm,xn;const $e=class $e{constructor({editor:t=null,uiManager:e=null}){g(this,gt);g(this,ns,null);g(this,ya,null);g(this,ol);g(this,Zt,null);g(this,Cc,!1);g(this,ll,!1);g(this,on,null);g(this,Tc);g(this,er,null);g(this,qs,null);t?(f(this,ll,!1),f(this,on,t)):f(this,ll,!0),f(this,qs,t?._uiManager||e),f(this,Tc,i(this,qs)._eventBus),f(this,ol,t?.color?.toUpperCase()||i(this,qs)?.highlightColors.values().next().value||"#FFFF98"),i($e,xc)||f($e,xc,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 J(this,"_keyboardManager",new cd([[["Escape","mac+Escape"],$e.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],$e.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],$e.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],$e.prototype._moveToPrevious],[["Home","mac+Home"],$e.prototype._moveToBeginning],[["End","mac+End"],$e.prototype._moveToEnd]]))}renderButton(){const t=f(this,ns,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",i(this,on)&&(t.ariaControls=`${i(this,on).id}_colorpicker_dropdown`);const e=i(this,qs)._signal;t.addEventListener("click",m(this,gt,xr).bind(this),{signal:e}),t.addEventListener("keydown",m(this,gt,zf).bind(this),{signal:e});const s=f(this,ya,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=i(this,ol),t.append(s),t}renderMainDropdown(){const t=f(this,Zt,m(this,gt,jf).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===i(this,ns)){m(this,gt,xr).call(this,t);return}const e=t.target.getAttribute("data-color");e&&m(this,gt,Gf).call(this,e,t)}_moveToNext(t){if(!i(this,gt,xn)){m(this,gt,xr).call(this,t);return}if(t.target===i(this,ns)){i(this,Zt).firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===i(this,Zt)?.firstChild||t.target===i(this,ns)){i(this,gt,xn)&&this._hideDropdownFromKeyboard();return}i(this,gt,xn)||m(this,gt,xr).call(this,t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!i(this,gt,xn)){m(this,gt,xr).call(this,t);return}i(this,Zt).firstChild?.focus()}_moveToEnd(t){if(!i(this,gt,xn)){m(this,gt,xr).call(this,t);return}i(this,Zt).lastChild?.focus()}hideDropdown(){i(this,Zt)?.classList.add("hidden"),i(this,ns).ariaExpanded="false",i(this,er)?.abort(),f(this,er,null)}_hideDropdownFromKeyboard(){if(!i(this,ll)){if(!i(this,gt,xn)){i(this,on)?.unselect();return}this.hideDropdown(),i(this,ns).focus({preventScroll:!0,focusVisible:i(this,Cc)})}}updateColor(t){if(i(this,ya)&&(i(this,ya).style.backgroundColor=t),!i(this,Zt))return;const e=i(this,qs).highlightColors.values();for(const s of i(this,Zt).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){i(this,ns)?.remove(),f(this,ns,null),f(this,ya,null),i(this,Zt)?.remove(),f(this,Zt,null)}};ns=new WeakMap,ya=new WeakMap,ol=new WeakMap,Zt=new WeakMap,Cc=new WeakMap,ll=new WeakMap,on=new WeakMap,Tc=new WeakMap,er=new WeakMap,qs=new WeakMap,xc=new WeakMap,gt=new WeakSet,jf=function(){const t=document.createElement("div"),e=i(this,qs)._signal;t.addEventListener("contextmenu",ws,{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,on)&&(t.id=`${i(this,on).id}_colorpicker_dropdown`);for(const[s,n]of i(this,qs).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($e,xc)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.ariaSelected=n===i(this,ol),r.addEventListener("click",m(this,gt,Gf).bind(this,n),{signal:e}),t.append(r)}return t.addEventListener("keydown",m(this,gt,zf).bind(this),{signal:e}),t},Gf=function(t,e){e.stopPropagation(),i(this,Tc).dispatch("switchannotationeditorparams",{source:this,type:et.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},zf=function(t){$e._keyboardManager.exec(this,t)},xr=function(t){if(i(this,gt,xn)){this.hideDropdown();return}
2if(f(this,Cc,t.detail===0),i(this,er)||(f(this,er,new AbortController),window.addEventListener("pointerdown",m(this,gt,qm).bind(this),{signal:i(this,qs).combinedSignal(i(this,er))})),i(this,ns).ariaExpanded="true",i(this,Zt)){i(this,Zt).classList.remove("hidden");return}const e=f(this,Zt,m(this,gt,jf).call(this));i(this,ns).append(e)},qm=function(t){i(this,Zt)?.contains(t.target)||this.hideDropdown()},xn=function(){return i(this,Zt)&&!i(this,Zt).classList.contains("hidden")},g($e,xc,null);let _h=$e;var vi,Pc,hl,kc;const Dr=class Dr{constructor(t){g(this,vi,null);g(this,Pc,null);g(this,hl,null);f(this,Pc,t),f(this,hl,t._uiManager),i(Dr,kc)||f(Dr,kc,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(i(this,vi))return i(this,vi);const{editorType:t,colorType:e,colorValue:s}=i(this,Pc),n=f(this,vi,document.createElement("input"));return n.type="color",n.value=s||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",i(Dr,kc)[t]),n.addEventListener("input",()=>{i(this,hl).updateParams(e,n.value)},{signal:i(this,hl)._signal}),n}update(t){i(this,vi)&&(i(this,vi).value=t)}destroy(){i(this,vi)?.remove(),f(this,vi,null)}hideDropdown(){}};vi=new WeakMap,Pc=new WeakMap,hl=new WeakMap,kc=new WeakMap,g(Dr,kc,null);let hu=Dr;function vg(d){return Math.floor(Math.max(0,Math.min(1,d))*255).toString(16).padStart(2,"0")}function ql(d){return Math.max(0,Math.min(255,255*d))}class Eg{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=ql(t),[t,t,t]}static G_HTML([t]){const e=vg(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(ql)}static RGB_HTML(t){return`#${t.map(vg).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[ql(1-Math.min(1,t+n)),ql(1-Math.min(1,s+n)),ql(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 IA{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){Et("Abstract method `_createSVG` called.")}}class Ch extends IA{_createSVG(t){return document.createElementNS(Li,t)}}const FA=9,Va=new WeakSet,NA=new Date().getTimezoneOffset()*60*1e3;class Sg{static create(t){switch(t.data.annotationType){case Gt.LINK:return new Up(t);case Gt.TEXT:return new BA(t);case Gt.WIDGET:switch(t.data.fieldType){case"Tx":return new HA(t);case"Btn":return t.data.radioButton?new Jm(t):t.data.checkBox?new $A(t):new jA(t);case"Ch":return new GA(t);case"Sig":return new UA(t)}return new qa(t);case Gt.POPUP:return new Wf(t);case Gt.FREETEXT:return new sb(t);case Gt.LINE:return new VA(t);case Gt.SQUARE:return new WA(t);case Gt.CIRCLE:return new XA(t);case Gt.POLYLINE:return new ib(t);case Gt.CARET:return new YA(t);case Gt.INK:return new $p(t);case Gt.POLYGON:return new qA(t);case Gt.HIGHLIGHT:return new nb(t);case Gt.UNDERLINE:return new KA(t);case Gt.SQUIGGLY:return new JA(t);case Gt.STRIKEOUT:return new QA(t);case Gt.STAMP:return new rb(t);case Gt.FILEATTACHMENT:return new ZA(t);default:return new Nt(t)}}}var Aa,cl,Ls,Rc,Vf;const Yp=class Yp{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:n=!1}={}){g(this,Rc);g(this,Aa,null);g(this,cl,!1);g(this,Ls,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?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Yp._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}
2get commentButtonPosition(){const t=this.annotationStorage?.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?.length>=8){for(let o=0;o<e.length;o+=8)e[o+1]>a?(a=e[o+1],r=e[o+2]):e[o+1]===a&&(r=Math.max(r,e[o+2]));return[r,a]}if(s?.length>=1){for(const o of s)for(let l=0,h=o.length;l<h;l+=2)o[l+1]>a?(a=o[l+1],r=o[l]):o[l+1]===a&&(r=Math.max(r,o[l]));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(){const{data:t}=this;return this.annotationStorage.getRawValue(`${yh}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${yh}${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(){(i(this,Ls)?.popup||this.popup)?.remove(),f(this,Ls,this.popup=null)}updateEdited(t){if(!this.container)return;t.rect&&(i(this,Aa)||f(this,Aa,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&m(this,Rc,Vf).call(this,e);let n=i(this,Ls)?.popup||this.popup;!n&&s?.text&&(this._createPopup(s),n=i(this,Ls).popup),n&&(n.updateEdited(t),s?.deleted&&(n.remove(),f(this,Ls,null),this.popup=null))}resetEdited(){i(this,Aa)&&(m(this,Rc,Vf).call(this,i(this,Aa).rect),i(this,Ls)?.popup.resetEdited(),f(this,Aa,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 qa)&&!(this instanceof Up)&&(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 Wf){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const y=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(y>0||v>0){const E=`calc(${y}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;a.borderRadius=E}else if(this instanceof Jm){const E=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;a.borderRadius=E}switch(e.borderStyle.style){case Ja.SOLID:a.borderStyle="solid";break;case Ja.DASHED:a.borderStyle="dashed";break;case Ja.BEVELED:q("Unimplemented border style: beveled");break;case Ja.INSET:q("Unimplemented border style: inset");break;case Ja.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(f(this,cl,!0),a.borderColor=O.makeHexColor(w[0]|0,w[1]|0,w[2]|0)):a.borderWidth=0}const h=O.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:u,pageX:p,pageY:b}=n.rawDims;a.left=`${100*(h[0]-p)/c}%`,a.top=`${100*(h[1]-b)/u}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/c}%`,a.height=`${100*l/u}%`):this.setRotation(A,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]=Eg[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Eg[`${a}_rgb`](o)})};return J(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))(t[n]||s[n])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[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(y=>Math.fround(y));if(t.length===8){const[y,v,w,E]=t.subarray(2,6);if(n===y&&r===v&&e===w&&s===E)return}const{style:a}=this.container;let o;if(i(this,cl)){const{borderColor:y,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="${y}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=n-e,h=r-s,{svgFactory:c}=this,u=c.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0),u.role="none";const p=c.createElement("defs");u.append(p);const b=c.createElement("clipPath"),A=`clippath_${this.data.id}`;b.setAttribute("id",A),b.setAttribute("clipPathUnits","objectBoundingBox"),p.append(b);for(let y=2,v=t.length;y<v;y+=8){const w=t[y],E=t[y+1],S=t[y+2],_=t[y+3],C=c.createElement("rect"),T=(S-e)/l,x=(r-E)/h,P=(w-S)/l,k=(E-_)/h;C.setAttribute("x",T),C.setAttribute("y",x),C.setAttribute("width",P),C.setAttribute("height",k),b.append(C),o?.push(`<rect vector-effect="non-scaling-stroke" x="${T}" y="${x}" width="${P}" height="${k}"/>`)}i(this,cl)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${A})`}_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,Ls,new Wf({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,Ls)||this.popup||this.data.popupRef)}get extraPopupElement(){return i(this,Ls)}render(){Et("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&&!Va.has(h)){q(`_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&&Va.has(n)&&s.push({id:a,exportValue:r,domElement:n})}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};Aa=new WeakMap,cl=new WeakMap,Ls=new WeakMap,Rc=new WeakSet,Vf=function(t){const{container:{style:e},data:{rect:s,rotation:n},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;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 Nt=Yp;class OA extends Nt{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 ys,Pr,Ym,Km;class Up extends Nt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!s?.ignoreBorder,createQuadrilaterals:!0});g(this,ys);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,ys,Ym).call(this,n,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(m(this,ys,Km).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,ys,Pr).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,ys,Pr).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]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1))}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),m(this,ys,Pr).call(this)}_bindResetFormAction(e,s){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),m(this,ys,Pr).call(this),!this._fieldObjects){q('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{n?.();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const u=new Set(a);for(const p of r){const b=this._fieldObjects[p]||[];for(const{id:A}of b)u.add(A)}for(const p of Object.values(this._fieldObjects))for(const b of p)u.has(b.id)===o&&l.push(b)}else for(const u of Object.values(this._fieldObjects))l.push(...u);const h=this.annotationStorage,c=[];for(const u of l){const{id:p}=u;switch(c.push(p),u.type){case"text":{const A=u.defaultValue||"";h.setValue(p,{value:A});break}case"checkbox":case"radiobutton":{const A=u.defaultValue===u.exportValues;h.setValue(p,{value:A});break}case"combobox":case"listbox":{const A=u.defaultValue||"";h.setValue(p,{value:A});break}default:continue}const b=document.querySelector(`[data-element-id="${p}"]`);if(b){if(!Va.has(b)){q(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;b.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}}),!1}}}ys=new WeakSet,Pr=function(){this.container.setAttribute("data-internal-link","")},Ym=function(e,s,n="",r=null){e.href=this.linkService.getAnchorUrl(""),s.description?e.title=s.description:n&&(e.title=n),e.onclick=()=>(this.downloadManager?.openOrDownloadData(s.content,s.filename,r),!1),m(this,ys,Pr).call(this)},Km=function(e,s,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),n&&(e.title=n),m(this,ys,Pr).call(this)};class BA extends Nt{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 qa extends Nt{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return le.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,n,r){s.includes("mouse")?t.addEventListener(s,a=>{this.linkService.eventBus?.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=>{if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(a)}})})}_setEventListeners(t,e,s,n){for(const[r,a]of s)(a==="Action"||this.data.actions?.[a])&&((a==="Focus"||a==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,r,a,n),a==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):a==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":O.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||FA,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/(Xu*n))||1,u=h/c;a=Math.min(n,l(u/Xu))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(n,l(h/Xu))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=O.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 HA extends qa{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(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const n=t.getValue(e,{value:this.data.fieldValue});let r=n.value||"";const a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&r.length>a&&(r=r.slice(0,a));let o=n.formattedValue||this.data.textContent?.join(` 3`)||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));const l={userValue:r,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=o??r,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",o??r),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Va.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:h,datetimeType:c,timeStep:u}=this.data,p=!!c&&this.enableScripting;h&&(s.title=h),this._setRequired(s,this.data.required),a&&(s.maxLength=a),s.addEventListener("input",A=>{t.setValue(e,{value:A.target.value}),this.setPropertyOnSiblings(s,"value",A.target.value,"value"),l.formattedValue=null}),s.addEventListener("resetform",A=>{const y=this.data.defaultFieldValue??"";s.value=l.userValue=y,l.formattedValue=null});let b=A=>{const{formattedValue:y}=l;y!=null&&(A.target.value=y),A.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",y=>{if(l.focused)return;const{target:v}=y;if(p&&(v.type=c,u&&(v.step=u)),l.userValue){const w=l.userValue;if(p)if(c==="time"){const E=new Date(w),S=[E.getHours(),E.getMinutes(),E.getSeconds()];v.value=S.map(_=>_.toString().padStart(2,"0")).join(":")}else v.value=new Date(w-NA).toISOString().split(c==="date"?"T":".",1)[0];else v.value=w}l.lastCommittedValue=v.value,l.commitKey=1,this.data.actions?.Focus||(l.focused=!0)}),s.addEventListener("updatefromsandbox",y=>{this.showElementAndHideCanvas(y.target);const v={value(w){l.userValue=w.detail.value??"",p||t.setValue(e,{value:l.userValue.toString()}),w.target.value=l.userValue},formattedValue(w){const{formattedValue:E}=w.detail;l.formattedValue=E,E!=null&&w.target!==document.activeElement&&(w.target.value=E);const S={formattedValue:E};p&&(S.value=E),t.setValue(e,S)},selRange(w){w.target.setSelectionRange(...w.detail.selRange)},charLimit:w=>{const{charLimit:E}=w.detail,{target:S}=w;if(E===0){S.removeAttribute("maxLength");return}S.setAttribute("maxLength",E);let _=l.userValue;!_||_.length<=E||(_=_.slice(0,E),S.value=l.userValue=_,t.setValue(e,{value:_}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:1,selStart:S.selectionStart,selEnd:S.selectionEnd}}))}};this._dispatchEventFromSandbox(v,y)}),s.addEventListener("keydown",y=>{l.commitKey=1;let v=-1;if(y.key==="Escape"?v=0:y.key==="Enter"&&!this.data.multiLine?v=2:y.key==="Tab"&&(l.commitKey=3),v===-1)return;const{value:w}=y.target;l.lastCommittedValue!==w&&(l.lastCommittedValue=w,l.userValue=w,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,willCommit:!0,commitKey:v,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}))});const A=b;b=null,s.addEventListener("blur",y=>{if(!l.focused||!y.relatedTarget)return;this.data.actions?.Blur||(l.focused=!1);const{target:v}=y;let{value:w}=v;if(p){if(w&&c==="time"){const E=w.split(":").map(S=>parseInt(S,10));w=new Date(2e3,0,1,E[0],E[1],E[2]||0).valueOf(),v.step=""}else w.includes("T")||(w=`${w}T00:00`),w=new Date(w).valueOf();v.type="text"}l.userValue=w,l.lastCommittedValue!==w&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,willCommit:!0,commitKey:l.commitKey,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}),A(y)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",y=>{l.lastCommittedValue=null;const{data:v,target:w}=y,{value:E,selectionStart:S,selectionEnd:_}=w;let C=S,T=_;switch(y.inputType){case"deleteWordBackward":{const x=E.substring(0,S).match(/\w*[^\
vendor: 4,181 bytes, line 3
3w]*$/);x&&(C-=x[0].length);break}case"deleteWordForward":{const x=E.substring(S).match(/^[^\w]*\w*/);x&&(T+=x[0].length);break}case"deleteContentBackward":S===_&&(C-=1);break;case"deleteContentForward":S===_&&(T+=1);break}y.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,change:v||"",willCommit:!1,selStart:C,selEnd:T}})}),this._setEventListeners(s,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],y=>y.target.value)}if(b&&s.addEventListener("blur",b),this.data.comb){const y=(this.data.rect[2]-this.data.rect[0])/a;s.classList.add("comb"),s.style.letterSpacing=`calc(${y}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 UA extends qa{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class $A extends qa{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 Va.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 Jm extends qa{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(Va.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 u of this._getElementsByName(h.target.name)){const p=c&&u.id===s;u.domElement&&(u.domElement.checked=p),t.setValue(u.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 jA extends Up{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 GA extends qa{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");Va.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 u=this.data.defaultFieldValue;for(const p of n.options)p.selected=p.value===u});for(const c of this.data.options){const u=document.createElement("option");u.textContent=c.displayValue,u.value=c.exportValue,s.value.includes(c.exportValue)&&(u.setAttribute("selected",!0),r=!1),n.append(u)}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 u=c?"value":"textContent",{options:p,multiple:b}=n;return b?Array.prototype.filter.call(p,A=>A.selected).map(A=>A[u]):p.selectedIndex===-1?null:p[p.selectedIndex][u]};let l=o(!1);const h=c=>{const u=c.target.options;return Array.prototype.map.call(u,p=>({displayValue:p.textContent,exportValue:p.value}))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",c=>{const u={value(p){a?.();const b=p.detail.value,A=new Set(Array.isArray(b)?b:[b]);for(const y of n.options)y.selected=A.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(p){n.multiple=!0},remove(p){const b=n.options,A=p.detail.remove;b[A].selected=!1,n.remove(A),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:A,exportValue:y}=p.detail.insert,v=n.children[b],w=document.createElement("option");w.textContent=A,w.value=y,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 A of b){const{displayValue:y,exportValue:v}=A,w=document.createElement("option");w.textContent=y,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 A of p.target.options)A.selected=b.has(A.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(p){p.target.disabled=!p.detail.editable}};this._dispatchEventFromSandbox(u,c)}),n.addEventListener("input",c=>{const u=o(!0),p=o(!1);t.setValue(e,{value:u}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:p,changeEx:u,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 Mc,Xf;class Wf extends Nt{constructor(e){const{data:s,elements:n,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&Nt._hasPopupData(s)});g(this,Mc);if(this.elements=n,a&&Nt._hasPopupData(s)){const o=this.popup=m(this,Mc,Xf).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,Mc,Xf).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=>`${Dp}${r}`).join(",")),this.container}}Mc=new WeakSet,Xf=function(){return new zA({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 rs,sr,xu,Pu,dl,ul,Ht,Ei,ir,wa,fl,pl,Si,as,ln,hn,se,cn,nr,Dc,dn,gl,va,rr,_e,ar,Z,Bd,qf,Yf,Kf,Hd,Jf,Qm,Zm,tb,eb,Ud,$d,Qf;class zA{constructor({container:t,color:e,elements:s,titleObj:n,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:u,commentManager:p=null}){g(this,Z);g(this,rs,null);g(this,sr,m(this,Z,tb).bind(this));g(this,xu,m(this,Z,Qf).bind(this));g(this,Pu,m(this,Z,$d).bind(this));g(this,dl,m(this,Z,Ud).bind(this));g(this,ul,null);g(this,Ht,null);g(this,Ei,null);g(this,ir,null);g(this,wa,null);g(this,fl,null);g(this,pl,null);g(this,Si,!1);g(this,as,null);g(this,ln,null);g(this,hn,null);g(this,se,null);g(this,cn,null);g(this,nr,null);g(this,Dc,null);g(this,dn,null);g(this,gl,null);g(this,va,null);g(this,rr,!1);g(this,_e,null);g(this,ar,null);f(this,Ht,t),f(this,gl,n),f(this,Ei,a),f(this,dn,o),f(this,fl,l),f(this,ul,e),f(this,Dc,h),f(this,pl,c),f(this,wa,s),f(this,rs,p),f(this,_e,s[0]),f(this,ir,vh.toDateObject(r)),this.trigger=s.flatMap(b=>b.getElementsToTriggerPopup()),p?this.renderCommentButton():(m(this,Z,Bd).call(this),i(this,Ht).hidden=!0,u&&m(this,Z,Ud).call(this))}renderCommentButton(){if(i(this,se)||(i(this,cn)||m(this,Z,qf).call(this),!i(this,cn)))return;const{signal:t}=f(this,ln,new AbortController),e=!!i(this,_e).extraPopupElement,s=()=>{i(this,rs).toggleCommentPopup(this,!0,void 0,!e)},n=()=>{i(this,rs).toggleCommentPopup(this,!1,!0,!e)},r=()=>{i(this,rs).toggleCommentPopup(this,!1,!1)};if(e){f(this,se,i(this,_e).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",i(this,sr),{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,se,document.createElement("button"));a.className="annotationCommentButton";const o=i(this,_e).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,Z,Kf).call(this),m(this,Z,Yf).call(this),a.addEventListener("keydown",i(this,sr),{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,_e).commentData;return t?i(this,fl)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{i(this,se)?.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:n,modificationDate:r}=i(this,_e).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:n,modificationDate:r}}get elementBeforePopup(){return i(this,se)}get comment(){return i(this,ar)||f(this,ar,i(this,_e).commentText),i(this,ar)}set comment(t){t!==this.comment&&(i(this,_e).commentText=f(this,ar,t))}get parentBoundingClientRect(){return i(this,_e).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){i(this,se)&&(i(this,se).classList.toggle("selected",t),i(this,se).ariaExpanded=e)}setSelectedCommentButton(t){i(this,se).classList.toggle("selected",t)}get commentPopupPosition(){if(i(this,nr))return i(this,nr);const{x:t,y:e,height:s}=i(this,se).getBoundingClientRect(),{x:n,y:r,width:a,height:o}=i(this,_e).layer.getBoundingClientRect();return[(t-n)/a,(e+s-r)/o]}set commentPopupPosition(t){f(this,nr,t)}hasDefaultPopupPosition(){return i(this,nr)===null}get commentButtonPosition(){return i(this,cn)}get commentButtonWidth(){return i(this,se).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=i(this,nr)||this.commentButtonPosition.map(h=>h/100),n=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=n;i(this,rs).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:n})}
3render(){if(i(this,as))return;const t=f(this,as,document.createElement("div"));if(t.className="popup",i(this,ul)){const s=t.style.outlineColor=O.makeHexColor(...i(this,ul));t.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`}const e=document.createElement("span");if(e.className="header",i(this,gl)?.str){const s=document.createElement("span");s.className="title",e.append(s),{dir:s.dir,str:s.textContent}=i(this,gl)}if(t.append(e),i(this,ir)){const s=document.createElement("time");s.className="popupDate",s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:i(this,ir).valueOf()})),s.dateTime=i(this,ir).toISOString(),e.append(s)}Ip({html:i(this,Z,Hd)||i(this,Ei).str,dir:i(this,Ei)?.dir,className:"popupContent"},t),i(this,Ht).append(t)}updateEdited({rect:t,popup:e,deleted:s}){if(i(this,rs)){s?(this.remove(),f(this,ar,null)):e&&(e.deleted?this.remove():(m(this,Z,Kf).call(this),f(this,ar,e.text))),t&&(f(this,cn,null),m(this,Z,qf).call(this),m(this,Z,Yf).call(this));return}if(s||e?.deleted){this.remove();return}m(this,Z,Bd).call(this),i(this,va)||f(this,va,{contentsObj:i(this,Ei),richText:i(this,dn)}),t&&f(this,hn,null),e&&e.text&&(f(this,dn,m(this,Z,Zm).call(this,e.text)),f(this,ir,vh.toDateObject(e.date)),f(this,Ei,null)),i(this,as)?.remove(),f(this,as,null)}resetEdited(){i(this,va)&&({contentsObj:Kt(this,Ei)._,richText:Kt(this,dn)._}=i(this,va),f(this,va,null),i(this,as)?.remove(),f(this,as,null),f(this,hn,null))}remove(){if(i(this,ln)?.abort(),f(this,ln,null),i(this,as)?.remove(),f(this,as,null),f(this,rr,!1),f(this,Si,!1),i(this,se)?.remove(),f(this,se,null),this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}forceHide(){f(this,rr,this.isVisible),i(this,rr)&&(i(this,Ht).hidden=!0)}maybeShow(){i(this,rs)||(m(this,Z,Bd).call(this),i(this,rr)&&(i(this,as)||m(this,Z,$d).call(this),f(this,rr,!1),i(this,Ht).hidden=!1))}get isVisible(){return i(this,rs)?!1:i(this,Ht).hidden===!1}}rs=new WeakMap,sr=new WeakMap,xu=new WeakMap,Pu=new WeakMap,dl=new WeakMap,ul=new WeakMap,Ht=new WeakMap,Ei=new WeakMap,ir=new WeakMap,wa=new WeakMap,fl=new WeakMap,pl=new WeakMap,Si=new WeakMap,as=new WeakMap,ln=new WeakMap,hn=new WeakMap,se=new WeakMap,cn=new WeakMap,nr=new WeakMap,Dc=new WeakMap,dn=new WeakMap,gl=new WeakMap,va=new WeakMap,rr=new WeakMap,_e=new WeakMap,ar=new WeakMap,Z=new WeakSet,Bd=function(){if(i(this,ln))return;f(this,ln,new AbortController);const{signal:t}=i(this,ln);for(const e of this.trigger)e.addEventListener("click",i(this,dl),{signal:t}),e.addEventListener("pointerenter",i(this,Pu),{signal:t}),e.addEventListener("pointerleave",i(this,xu),{signal:t}),e.classList.add("popupTriggerArea");for(const e of i(this,wa))e.container?.addEventListener("keydown",i(this,sr),{signal:t})},qf=function(){const t=i(this,wa).find(e=>e.hasCommentButton);t&&f(this,cn,t._normalizePoint(t.commentButtonPosition))},Yf=function(){if(i(this,_e).extraPopupElement&&!i(this,_e).editor)return;this.renderCommentButton();const[t,e]=i(this,cn),{style:s}=i(this,se);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},Kf=function(){i(this,_e).extraPopupElement||(this.renderCommentButton(),i(this,se).style.backgroundColor=this.commentButtonColor||"")},Hd=function(){const t=i(this,dn),e=i(this,Ei);return t?.str&&(!e?.str||e.str===t.str)&&i(this,dn).html||null},Jf=function(){return i(this,Z,Hd)?.attributes?.style?.fontSize||0},Qm=function(){return i(this,Z,Hd)?.attributes?.style?.color||null},Zm=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:i(this,Z,Qm),fontSize:i(this,Z,Jf)?`calc(${i(this,Z,Jf)}px * var(--total-scale-factor))`:""}};for(const r of t.split(` 4`))e.push({name:"span",value:r,attributes:n});return s},tb=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&i(this,Si))&&m(this,Z,Ud).call(this)},eb=function(){if(i(this,hn)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:n,pageY:r}}}=i(this,fl);let a=!!i(this,pl),o=a?i(this,pl):i(this,Dc);for(const A of i(this,wa))if(!o||O.intersect(A.data.rect,o)!==null){o=A.data.rect,a=!0;break}const l=O.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,u=l[0]+c,p=l[1];f(this,hn,[100*(u-n)/e,100*(p-r)/s]);const{style:b}=i(this,Ht);b.left=`${i(this,hn)[0]}%`,b.top=`${i(this,hn)[1]}%`},Ud=function(){if(i(this,rs)){i(this,rs).toggleCommentPopup(this,!1);return}f(this,Si,!i(this,Si)),i(this,Si)?(m(this,Z,$d).call(this),i(this,Ht).addEventListener("click",i(this,dl)),i(this,Ht).addEventListener("keydown",i(this,sr))):(m(this,Z,Qf).call(this),i(this,Ht).removeEventListener("click",i(this,dl)),i(this,Ht).removeEventListener("keydown",i(this,sr)))},$d=function(){i(this,as)||this.render(),this.isVisible?i(this,Si)&&i(this,Ht).classList.add("focused"):(m(this,Z,eb).call(this),i(this,Ht).hidden=!1,i(this,Ht).style.zIndex=parseInt(i(this,Ht).style.zIndex)+1e3)},Qf=function(){i(this,Ht).classList.remove("focused"),!(i(this,Si)||!this.isVisible)&&(i(this,Ht).hidden=!0,i(this,Ht).style.zIndex=parseInt(i(this,Ht).style.zIndex)-1e3)};class sb extends Nt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=X.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 Lc;class VA extends Nt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Lc,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,Lc,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,Lc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Lc=new WeakMap;var Ic;class WA extends Nt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Ic,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,Ic,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,Ic)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ic=new WeakMap;var Fc;class XA extends Nt{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 Nc;class ib extends Nt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Nc,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 u=0,p=s.length;u<p;u+=2){const b=s[u]-e[0],A=e[3]-s[u+1];h.push(`${b},${A}`)}h=h.join(" ");const c=f(this,Nc,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,Nc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Nc=new WeakMap;class qA extends ib{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class YA extends Nt{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 Oc,Ea,Bc,Zf;class $p extends Nt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Bc);g(this,Oc,null);g(this,Ea,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?X.HIGHLIGHT:X.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,Bc,Zf).call(this,s,e),c=this.svgFactory.create(l,h,!0),u=f(this,Oc,this.svgFactory.createElement("svg:g"));c.append(u),u.setAttribute("stroke-width",r.width||1),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),u.setAttribute("stroke-miterlimit",10),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),u.setAttribute("transform",o);for(let p=0,b=n.length;p<b;p++){const A=this.svgFactory.createElement(this.svgElementName);i(this,Ea).push(A),A.setAttribute("points",n[p].join(",")),u.append(A)}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,Oc);if(s>=0&&a.setAttribute("stroke-width",s||1),n)for(let o=0,l=i(this,Ea).length;o<l;o++)i(this,Ea)[o].setAttribute("points",n[o].join(","));if(r){const{transform:o,width:l,height:h}=m(this,Bc,Zf).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return i(this,Ea)}addHighlightArea(){this.container.classList.add("highlightArea")}}Oc=new WeakMap,Ea=new WeakMap,Bc=new WeakSet,Zf=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]}}};
4class nb extends Nt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=X.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}}class KA extends Nt{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 JA extends Nt{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 QA extends Nt{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 rb extends Nt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=X.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 Hc,Uc,tp;class ZA extends Nt{constructor(e){super(e,{isRenderable:!0});g(this,Uc);g(this,Hc,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,this.linkService.eventBus?.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,Uc,tp).bind(this)),f(this,Hc,n);const{isMac:r}=le.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&m(this,Uc,tp).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return i(this,Hc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Hc=new WeakMap,Uc=new WeakSet,tp=function(){this.downloadManager?.openOrDownloadData(this.content,this.filename)};var ml,Sa,bl,or,$c,_a,Cr,ep,sp,yl;let jp=(yl=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:n,page:r,viewport:
4a,structTreeLayer:o,commentManager:l,linkService:h,annotationStorage:c}){g(this,Cr);g(this,ml,null);g(this,Sa,null);g(this,bl,null);g(this,or,new Map);g(this,$c,null);g(this,_a,null);this.div=t,f(this,ml,e),f(this,Sa,s),f(this,$c,o||null),f(this,_a,h||null),f(this,bl,c||new Fp),this.page=r,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=n,this._commentManager=l||null}hasEditableAnnotations(){return i(this,or).size>0}async render(t){const{annotations:e}=t,s=this.div;Er(s,this.viewport);const n=new Map,r={data:null,layer:s,linkService:i(this,_a),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Ch,annotationStorage:i(this,bl),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const a of e){if(a.noHTML)continue;const o=a.annotationType===Gt.POPUP;if(o){const c=n.get(a.id);if(!c)continue;r.elements=c}else if(a.rect[2]===a.rect[0]||a.rect[3]===a.rect[1])continue;r.data=a;const l=Sg.create(r);if(!l.isRenderable)continue;if(!o&&a.popupRef){const c=n.get(a.popupRef);c?c.push(l):n.set(a.popupRef,[l])}const h=l.render();a.hidden&&(h.style.visibility="hidden"),await m(this,Cr,ep).call(this,h,a.id,r.elements),l.extraPopupElement?.popup?.renderCommentButton(),l._isEditable&&(i(this,or).set(l.data.id,l),this._annotationEditorUIManager?.renderAnnotationElement(l))}m(this,Cr,sp).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:i(this,_a),svgFactory:new Ch,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=yl._defaultBorderStyle),e.data=s;const n=Sg.create(e);if(!n.isRenderable)continue;const r=n.render();await m(this,Cr,ep).call(this,r,s.id,null)}}update({viewport:t}){const e=this.div;this.viewport=t,Er(e,{rotation:t.rotation}),m(this,Cr,sp).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(i(this,or).values())}getEditableAnnotation(t){return i(this,or).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:n}=t,r=new OA({data:{id:s,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:i(this,_a),annotationStorage:i(this,bl)}),a=r.render();return e.append(a),i(this,ml)?.moveElementInDOM(e,a,a,!1),r.createOrUpdatePopup(),r}static get _defaultBorderStyle(){return J(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Ja.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},ml=new WeakMap,Sa=new WeakMap,bl=new WeakMap,or=new WeakMap,$c=new WeakMap,_a=new WeakMap,Cr=new WeakSet,ep=async function(t,e,s){const n=t.firstChild||t,r=n.id=`${Dp}${e}`,a=await i(this,$c)?.getAriaAttributes(r);if(a)for(const[o,l]of a)n.setAttribute(o,l);s?s.at(-1).container.after(t):(this.div.append(t),i(this,ml)?.moveElementInDOM(this.div,t,n,!1))},sp=function(){if(!i(this,Sa))return;const t=this.div;for(const[e,s]of i(this,Sa)){const n=t.querySelector(`[data-annotation-id="${e}"]`);if(!n)continue;s.className="annotationContent";const{firstChild:r}=n;r?r.nodeName==="CANVAS"?r.replaceWith(s):r.classList.contains("annotationContent")?r.after(s):r.before(s):n.append(s);const a=i(this,or).get(e);a&&(a._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,n.id,s),a._hasNoCanvas=!1):a.canvas=s)}i(this,Sa).clear()},yl);const Sd=/\r\n?|\n/g;var os,jc,Ca,ls,qt,ab,ob,lb,jd,wn,Gd,zd,hb,np,cb;const Tt=class Tt extends _t{constructor(e){super({...e,name:"freeTextEditor"});g(this,qt);g(this,os,"");g(this,jc,`${this.id}-editor`);g(this,Ca,null);g(this,ls);R(this,"_colorPicker",null);this.color=e.color||Tt._defaultColor||_t._defaultLineColor,f(this,ls,e.fontSize||Tt._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=Tt.prototype,s=a=>a.isEmpty(),n=Sr.TRANSLATE_SMALL,r=Sr.TRANSLATE_BIG;return J(this,"_keyboardManager",new cd([[["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){_t.initialize(e,s);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}
4static updateDefaultParams(e,s){switch(e){case et.FREETEXT_SIZE:Tt._defaultFontSize=s;break;case et.FREETEXT_COLOR:Tt._defaultColor=s;break}}updateParams(e,s){switch(e){case et.FREETEXT_SIZE:m(this,qt,ab).call(this,s);break;case et.FREETEXT_COLOR:m(this,qt,ob).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[et.FREETEXT_SIZE,Tt._defaultFontSize],[et.FREETEXT_COLOR,Tt._defaultColor||_t._defaultLineColor]]}get propertiesToUpdate(){return[[et.FREETEXT_SIZE,i(this,ls)],[et.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new hu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return et.FREETEXT_COLOR}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-Tt._internalPadding*e,-(Tt._internalPadding+i(this,ls))*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,Ca,new AbortController);const e=this._uiManager.combinedSignal(i(this,Ca));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(){return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",i(this,jc)),this._isDraggable=!0,i(this,Ca)?.abort(),f(this,Ca,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){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=i(this,os),s=f(this,os,m(this,qt,lb).call(this).trimEnd());if(e===s)return;const n=r=>{if(f(this,os,r),!r){this.remove();return}m(this,qt,zd).call(this),this._uiManager.rebuild(this),m(this,qt,jd).call(this)};this.addCommands({cmd:()=>{n(s)},undo:()=>{n(e)},mustExec:!1}),m(this,qt,jd).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){Tt._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,jc)),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,ls)}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,u]=this.pageDimensions,[p,b]=this.pageTranslation;let A,y;switch(this.rotation){case 0:A=e+(o[0]-p)/c,y=s+this.height-(o[1]-b)/u;break;case 90:A=e+(o[0]-p)/c,y=s-(o[1]-b)/u,[l,h]=[h,-l];break;case 180:A=e-this.width+(o[0]-p)/c,y=s-(o[1]-b)/u,[l,h]=[-l,-h];break;case 270:A=e+(o[0]-p-this.height*u)/c,y=s+(o[1]-b-this.width*c)/u,[l,h]=[-h,l];break}this.setAt(A*r,y*a,l,h)}else this._moveAfterPaste(e,s);m(this,qt,zd).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var A,y,v;const s=e.clipboardData||window.clipboardData,{types:n}=s;if(n.length===1&&n[0]==="text/plain")return;e.preventDefault();const r=m(A=Tt,wn,np).call(A,s.getData("text")||"").replaceAll(Sd,` 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=[],u=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(u.push(l.nodeValue.slice(h).replaceAll(Sd,"")),w!==this.editorDiv){let E=c;for(const S of this.editorDiv.childNodes){if(S===w){E=u;continue}E.push(m(y=Tt,wn,Gd).call(y,S))}}c.push(l.nodeValue.slice(0,h).replaceAll(Sd,""))}else if(l===this.editorDiv){let w=c,E=0;for(const S of this.editorDiv.childNodes)E++===h&&(w=u),w.push(m(v=Tt,wn,Gd).call(v,S))}f(this,os,`${c.join(` 7`)}${r}${u.join(` 8`)}`),m(this,qt,zd).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 E=w.nodeValue.length;if(b<=E){p.setStart(w,b),p.setEnd(w,b);break}b-=E}a.removeAllRanges(),a.addRange(p)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=Tt._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,n){var o;let r=null;if(e instanceof sb){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:u,id:p,popupRef:b,richText:A,contentsObj:y,creationDate:v,modificationDate:w},textContent:E,textPosition:S,parent:{page:{pageNumber:_}}}=e;if(!E||E.length===0)return null;r=e={annotationType:X.FREETEXT,color:Array.from(h),fontSize:l,value:E.join(` 9`),position:S,pageIndex:_-1,rect:c.slice(0),rotation:u,annotationElementId:p,id:p,deleted:!1,popupRef:b,comment:y?.str||null,richText:A,creationDate:v,modificationDate:w}}const a=await super.deserialize(e,s,n);return f(a,ls,e.fontSize),a.color=O.makeHexColor(...e.color),f(a,os,m(o=Tt,wn,np).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=_t._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:s,fontSize:i(this,ls),value:m(this,qt,hb).call(this)});return this.addComment(n),e?(n.isCopy=!0,n):this.annotationElementId&&!m(this,qt,cb).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,ls)}px * var(--total-scale-factor))`,n.color=this.color,s.replaceChildren();for(const r of i(this,os).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,os)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};os=new WeakMap,jc=new WeakMap,Ca=new WeakMap,ls=new WeakMap,qt=new WeakSet,ab=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-i(this,ls))*this.parentScale),f(this,ls,r),m(this,qt,jd).call(this)},n=i(this,ls);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:et.FREETEXT_S
10IZE,overwriteIfSameType:!0,keepUndo:!0})},ob=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:et.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},lb=function(){var n;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)s?.nodeType===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(m(n=Tt,wn,Gd).call(n,r)),s=r);return e.join(` 11`)},jd=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()},wn=new WeakSet,Gd=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Sd,"")},zd=function(){if(this.editorDiv.replaceChildren(),!!i(this,os))for(const e of i(this,os).split(` 12`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},hb=function(){return i(this,os).replaceAll("Â "," ")},np=function(e){return e.replaceAll(" ","Â ")},cb=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(Tt,wn),R(Tt,"_freeTextDefaultContent",""),R(Tt,"_internalPadding",0),R(Tt,"_defaultColor",null),R(Tt,"_defaultFontSize",10),R(Tt,"_type","freetext"),R(Tt,"_editorType",X.FREETEXT);let ip=Tt;class N{toSVGPath(){Et("Abstract method `toSVGPath` must be implemented.")}get box(){Et("Abstract getter `box` must be implemented.")}serialize(t,e){Et("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]}}R(N,"PRECISION",1e-4);var hs,Ys,Al,wl,_i,tt,Ta,xa,Gc,zc,vl,El,lr,Vc,ku,Ru,te,uh,db,ub,fb,pb,gb,mb;const Oi=class Oi{constructor({x:t,y:e},s,n,r,a,o=0){g(this,te);g(this,hs);g(this,Ys,[]);g(this,Al);g(this,wl);g(this,_i,[]);g(this,tt,new Float32Array(18));g(this,Ta);g(this,xa);g(this,Gc);g(this,zc);g(this,vl);g(this,El);g(this,lr,[]);f(this,hs,s),f(this,El,r*n),f(this,wl,a),i(this,tt).set([NaN,NaN,NaN,NaN,t,e],6),f(this,Al,o),f(this,zc,i(Oi,Vc)*n),f(this,Gc,i(Oi,Ru)*n),f(this,vl,n),i(this,lr).push(t,e)}isEmpty(){return isNaN(i(this,tt)[8])}add({x:t,y:e}){f(this,Ta,t),f(this,xa,e);const[s,n,r,a]=i(this,hs);let[o,l,h,c]=i(this,tt).subarray(8,12);const u=t-h,p=e-c,b=Math.hypot(u,p);if(b<i(this,Gc))return!1;const A=b-i(this,zc),y=A/b,v=y*u,w=y*p;let E=o,S=l;o=h,l=c,h+=v,c+=w,i(this,lr)?.push(t,e);const _=-w/A,C=v/A,T=_*i(this,El),x=C*i(this,El);return i(this,tt).set(i(this,tt).subarray(2,8),0),i(this,tt).set([h+T,c+x],4),i(this,tt).set(i(this,tt).subarray(14,18),12),i(this,tt).set([h-T,c-x],16),isNaN(i(this,tt)[6])?(i(this,_i).length===0&&(i(this,tt).set([o+T,l+x],2),i(this,_i).push(NaN,NaN,NaN,NaN,(o+T-s)/r,(l+x-n)/a),i(this,tt).set([o-T,l-x],14),i(this,Ys).push(NaN,NaN,NaN,NaN,(o-T-s)/r,(l-x-n)/a)),i(this,tt).set([E,S,o,l,h,c],6),!this.isEmpty()):(i(this,tt).set([E,S,o,l,h,c],6),Math.abs(Math.atan2(S-l,E-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=i(this,tt).subarray(2,6),i(this,_i).push(NaN,NaN,NaN,NaN,((o+
12h)/2-s)/r,((l+c)/2-n)/a),[o,l,E,S]=i(this,tt).subarray(14,18),i(this,Ys).push(NaN,NaN,NaN,NaN,((E+o)/2-s)/r,((S+l)/2-n)/a),!0):([E,S,o,l,h,c]=i(this,tt).subarray(0,6),i(this,_i).push(((E+5*o)/6-s)/r,((S+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,E,S]=i(this,tt).subarray(12,18),i(this,Ys).push(((E+5*o)/6-s)/r,((S+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,_i),e=i(this,Ys);if(isNaN(i(this,tt)[6])&&!this.isEmpty())return m(this,te,db).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,te,fb).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,te,ub).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,n,r,a){return new bb(t,e,s,n,r,a)}getOutlines(){const t=i(this,_i),e=i(this,Ys),s=i(this,tt),[n,r,a,o]=i(this,hs),l=new Float32Array((i(this,lr)?.length??0)+2);for(let u=0,p=l.length-2;u<p;u+=2)l[u]=(i(this,lr)[u]-n)/a,l[u+1]=(i(this,lr)[u+1]-r)/o;if(l[l.length-2]=(i(this,Ta)-n)/a,l[l.length-1]=(i(this,xa)-r)/o,isNaN(s[6])&&!this.isEmpty())return m(this,te,pb).call(this,l);const h=new Float32Array(i(this,_i).length+24+i(this,Ys).length);let c=t.length;for(let u=0;u<c;u+=2){if(isNaN(t[u])){h[u]=h[u+1]=NaN;continue}h[u]=t[u],h[u+1]=t[u+1]}c=m(this,te,mb).call(this,h,c);for(let u=e.length-6;u>=6;u-=6)for(let p=0;p<6;p+=2){if(isNaN(e[u+p])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[u+p],h[c+1]=e[u+p+1],c+=2}return m(this,te,gb).call(this,h,c),this.newFreeDrawOutline(h,l,i(this,hs),i(this,vl),i(this,Al),i(this,wl))}};hs=new WeakMap,Ys=new WeakMap,Al=new WeakMap,wl=new WeakMap,_i=new WeakMap,tt=new WeakMap,Ta=new WeakMap,xa=new WeakMap,Gc=new WeakMap,zc=new WeakMap,vl=new WeakMap,El=new WeakMap,lr=new WeakMap,Vc=new WeakMap,ku=new WeakMap,Ru=new WeakMap,te=new WeakSet,uh=function(){const t=i(this,tt).subarray(4,6),e=i(this,tt).subarray(16,18),[s,n,r,a]=i(this,hs);return[(i(this,Ta)+(t[0]-e[0])/2-s)/r,(i(this,xa)+(t[1]-e[1])/2-n)/a,(i(this,Ta)+(e[0]-t[0])/2-s)/r,(i(this,xa)+(e[1]-t[1])/2-n)/a]},db=function(){const[t,e,s,n]=i(this,hs),[r,a,o,l]=m(this,te,uh).call(this);return`M${(i(this,tt)[2]-t)/s} ${(i(this,tt)[3]-e)/n} L${(i(this,tt)[4]-t)/s} ${(i(this,tt)[5]-e)/n} L${r} ${a} L${o} ${l} L${(i(this,tt)[16]-t)/s} ${(i(this,tt)[17]-e)/n} L${(i(this,tt)[14]-t)/s} ${(i(this,tt)[15]-e)/n} Z`},ub=function(t){const e=i(this,Ys);t.push(`L${e[4]} ${e[5]} Z`)},fb=function(t){const[e,s,n,r]=i(this,hs),a=i(this,tt).subarray(4,6),o=i(this,tt).subarray(16,18),[l,h,c,u]=m(this,te,uh).call(this);t.push(`L${(a[0]-e)/n} ${(a[1]-s)/r} L${l} ${h} L${c} ${u} L${(o[0]-e)/n} ${(o[1]-s)/r}`)},pb=function(t){const e=i(this,tt),[s,n,r,a]=i(this,hs),[o,l,h,c]=m(this,te,uh).call(this),u=new Float32Array(36);return u.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(u,t,i(this,hs),i(this,vl),i(this,Al),i(this,wl))},gb=function(t,e){const s=i(this,Ys);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},mb=function(t,e){const s=i(this,tt).subarray(4,6),n=i(this,tt).subarray(16,18),[r,a,o,l]=i(this,hs),[h,c,u,p]=m(this,te,uh).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,u,p,NaN,NaN,NaN,NaN,(n[0]-r)/o,(n[1]-a)/l],e),e+=24},g(Oi,Vc,8),g(Oi,ku,2),g(Oi,Ru,i(Oi,Vc)+i(Oi,ku));let cu=Oi;var Sl,Pa,un,Wc,cs,Xc,Vt,Mu,yb;class bb extends N{constructor(e,s,n,r,a,o){super();g(this,Mu);g(this,Sl);g(this,Pa,new Float32Array(4));g(this,un);g(this,Wc);g(this,cs);g(this,Xc);g(this,Vt);f(this,Vt,e),f(this,cs,s),f(this,Sl,n),f(this,Xc,r),f(this,un,a),f(this,Wc,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],m(this,Mu,yb).call(this,o);const[l,h,c,u]=i(this,Pa);for(let p=0,b=e.length;p<b;p+=2)e[p]=(e[p]-l)/c,e[p+1]=(e[p+1]-h)/u;for(let p=0,b=s.length;p<b;p+=2)s[p]=(s[p]-l)/c,s[p+1]=(s[p+1]-h)/u}toSVGPath(){const e=[`M${i(this,Vt)[4]} ${i(this,Vt)[5]}`];for(let s=6,n=i(this,Vt).length;s<n;s+=6){if(isNaN(i(this,Vt)[s])){e.push(`L${i(this,Vt)[s+4]} ${i(this,Vt)[s+5]}`);continue}e.push(`C${i(this,Vt)[s]} ${i(this,Vt)[s+1]} ${i(this,Vt)[s+2]} ${i(this,Vt)[s+3]} ${i(this,Vt)[s+4]} ${i(this,Vt)[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=N._rescale(i(this,Vt),e,r,o,-l),c=N._rescale(i(this,cs),e,r,o,-l);break;case 90:h=N._rescaleAndSwap(i(this,Vt),e,s,o,l),c=N._rescaleAndSwap(i(this,cs),e,s,o,l);break;case 180:h=N._rescale(i(this,Vt),n,s,-o,l),c=N._rescale(i(this,cs),n,s,-o,l);break;case 270:h=N._rescaleAndSwap(i(this,Vt),n,r,-o,-l),c=N._rescaleAndSwap(i(this,cs),n,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return i(this,Pa)}newOutliner(e,s,n,r,a,o=0){return new cu(e,s,n,r,a,o)}getNewOutline(e,s){const[n,r,a,o]=i(this,Pa),[l,h,c,u]=i(this,Sl),p=a*c,b=o*u,A=n*c+l,y=r*u+h,v=this.newOutliner({x:i(this,cs)[0]*p+A,y:i(this,cs)[1]*b+y},i(this,Sl),i(this,Xc),e,i(this,Wc),s??i(this,un));for(let w=2;w<i(this,cs).length;w+=2)v.add({x:i(this,cs)[w]*p+A,y:i(this,cs)[w+1]*b+y});return v.getOutlines()}}Sl=new WeakMap,Pa=new WeakMap,un=new WeakMap,Wc=new WeakMap,cs=new WeakMap,Xc=new WeakMap,Vt=new WeakMap,Mu=new WeakSet,yb=function(e){const s=i(this,Vt);let n=s[4],r=s[5];const a=[n,r,n,r];let o=n,l=r,h=n,c=r;const u=e?Math.max:Math.min,p=new Float32Array(4);for(let A=6,y=s.length;A<y;A+=6){const v=s[A+4],w=s[A+5];isNaN(s[A])?(O.pointBoundingBox(v,w,a),l>w?(o=v,l=w):l===w&&(o=u(o,v)),c<w?(h=v,c=w):c===w&&(h=u(h,v))):(p[0]=p[1]=1/0,p[2]=p[3]=-1/0,O.bezierBoundingBox(n,r,...s.slice(A,A+6),p),O.rectBoundingBox(p[0],p[1],p[2],p[3],a),l>p[1]?(o=p[0],l=p[1]):l===p[1]&&(o=u(o,p[0])),c<p[3]?(h=p[2],c=p[3]):c===p[3]&&(h=u(h,p[2]))),n=v,r=w}const b=i(this,Pa);b[0]=a[0]-i(this,un),b[1]=a[1]-i(this,un),b[2]=a[2]-a[0]+2*i(this,un),b[3]=a[3]-a[1]+2*i(this,un),this.firstPoint=[o,l],this.lastPoint=[h,c]};var qc,Yc,Kc,hr,Ks,Oe,Ab,Vd,wb,vb,ap;class rp{constructor(t,e=0,s=0,n=!0){g(this,Oe);g(this,qc);g(this,Yc);g(this,Kc);g(this,hr,[]);g(this,Ks,[]);const r=[1/0,1/0,-1/0,-1/0],a=10**-4;for(const{x:y,y:v,width:w,height:E}
12of t){const S=Math.floor((y-e)/a)*a,_=Math.ceil((y+w+e)/a)*a,C=Math.floor((v-e)/a)*a,T=Math.ceil((v+E+e)/a)*a,x=[S,C,T,!0],P=[_,C,T,!1];i(this,hr).push(x,P),O.rectBoundingBox(S,C,_,T,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 u=n?-1/0:1/0,p=1/0;const b=i(this,hr).at(n?-1:-2),A=[b[0],b[2]];for(const y of i(this,hr)){const[v,w,E,S]=y;!S&&n?w<p?(p=w,u=v):w===p&&(u=Math.max(u,v)):S&&!n&&(w<p?(p=w,u=v):w===p&&(u=Math.min(u,v))),y[0]=(v-h)/o,y[1]=(w-c)/l,y[2]=(E-c)/l}f(this,qc,new Float32Array([h,c,o,l])),f(this,Yc,[u,p]),f(this,Kc,A)}getOutlines(){i(this,hr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of i(this,hr))e[3]?(t.push(...m(this,Oe,ap).call(this,e)),m(this,Oe,wb).call(this,e)):(m(this,Oe,vb).call(this,e),t.push(...m(this,Oe,ap).call(this,e)));return m(this,Oe,Ab).call(this,t)}}qc=new WeakMap,Yc=new WeakMap,Kc=new WeakMap,hr=new WeakMap,Ks=new WeakMap,Oe=new WeakSet,Ab=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,u]=a;s.delete(a);let p=o,b=l;for(r=[o,h],n.push(r);;){let A;if(s.has(c))A=c;else if(s.has(u))A=u;else break;s.delete(A),[o,l,h,c,u]=A,p!==o&&(r.push(p,b,o,b===l?l:h),p=o),b=b===l?h:l}r.push(p,b)}return new tw(n,i(this,qc),i(this,Yc),i(this,Kc))},Vd=function(t){const e=i(this,Ks);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},wb=function([,t,e]){const s=m(this,Oe,Vd).call(this,t);i(this,Ks).splice(s,0,[t,e])},vb=function([,t,e]){const s=m(this,Oe,Vd).call(this,t);for(let n=s;n<i(this,Ks).length;n++){const[r,a]=i(this,Ks)[n];if(r!==t)break;if(r===t&&a===e){i(this,Ks).splice(n,1);return}}for(let n=s-1;n>=0;n--){const[r,a]=i(this,Ks)[n];if(r!==t)break;if(r===t&&a===e){i(this,Ks).splice(n,1);return}}},ap=function(t){const[e,s,n]=t,r=[[e,s,n]],a=m(this,Oe,Vd).call(this,n);for(let o=0;o<a;o++){const[l,h]=i(this,Ks)[o];for(let c=0,u=r.length;c<u;c++){const[,p,b]=r[c];if(!(h<=p||b<=l)){if(p>=l){if(b>h)r[c][1]=h;else{if(u===1)return[];r.splice(c,1),c--,u--}continue}r[c][2]=l,b>h&&r.push([e,h,b])}}}return r};var Jc,_l;class tw extends N{constructor(e,s,n,r){super();g(this,Jc);g(this,_l);f(this,_l,e),f(this,Jc,s),this.firstPoint=n,this.lastPoint=r}toSVGPath(){const e=[];for(const s of i(this,_l)){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,_l)){const u=new Array(c.length);for(let p=0;p<c.length;p+=2)u[p]=e+c[p]*l,u[p+1]=r-c[p+1]*h;o.push(u)}return o}get box(){return i(this,Jc)}get classNamesForOutlining(){return["highlightOutline"]}}Jc=new WeakMap,_l=new WeakMap;class op extends cu{newFreeDrawOutline(t,e,s,n,r,a){return new ew(t,e,s,n,r,a)}}class ew extends bb{newOutliner(t,e,s,n,r,a=0){return new op(t,e,s,n,r,a)}}var Cl,Qc,fn,ka,Zc,Xe,td,ed,Ra,ds,us,fe,Tl,xl,Ce,Pl,Is,sd,Q,lp,Wd,Eb,Sb,_b,hp,kr,Ns,io,Cb,Xd,qd,Tb,xb,Pb,kb,Rb;const at=class at extends _t{constructor(e){super({...e,name:"highlightEditor"});g(this,Q);g(this,Cl,null);g(this,Qc,0);g(this,fn);g(this,ka,null);g(this,Zc,null);g(this,Xe,null);g(this,td,null);g(this,ed,0);g(this,Ra,null);g(this,ds,null);g(this,us,null);g(this,fe,!1);g(this,Tl,null);g(this,xl,null);g(this,Ce,null);g(this,Pl,"");g(this,Is);g(this,sd,"");this.color=e.color||at._defaultColor,f(this,Is,e.thickness||at._defaultThickness),this.opacity=e.opacity||at._defaultOpacity,f(this,fn,e.boxes||null),f(this,sd,e.methodOfCreation||""),f(this,Pl,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(f(this,fe,!0),m(this,Q,Wd).call(this,e),m(this,Q,kr).call(this)):i(this,fn)&&(f(this,Cl,e.anchorNode),f(this,Qc,e.anchorOffset),f(this,td,e.focusNode),f(this,ed,e.focusOffset),m(this,Q,lp).call(this),m(this,Q,kr).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=at.prototype;return J(this,"_keyboardManager",new cd([[["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,fe)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:i(this,Is),methodOfCreation:i(this,sd)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("
12color").size}}static initialize(e,s){_t.initialize(e,s),at._defaultColor||(at._defaultColor=s.highlightColors?.values().next().value||"#fff066")}static updateDefaultParams(e,s){switch(e){case et.HIGHLIGHT_COLOR:at._defaultColor=s;break;case et.HIGHLIGHT_THICKNESS:at._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return i(this,xl)}get commentButtonPosition(){return i(this,Tl)}updateParams(e,s){switch(e){case et.HIGHLIGHT_COLOR:m(this,Q,Eb).call(this,s);break;case et.HIGHLIGHT_THICKNESS:m(this,Q,Sb).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[et.HIGHLIGHT_COLOR,at._defaultColor],[et.HIGHLIGHT_THICKNESS,at._defaultThickness]]}get propertiesToUpdate(){return[[et.HIGHLIGHT_COLOR,this.color||at._defaultColor],[et.HIGHLIGHT_THICKNESS,i(this,Is)||at._defaultThickness],[et.HIGHLIGHT_FREE,i(this,fe)]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(i(this,us),{root:{fill:this.color,"fill-opacity":this.opacity}}),i(this,Zc)?.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",f(this,Zc,new _h({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,Q,qd).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,m(this,Q,qd).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){m(this,Q,hp).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,Q,kr).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let s=!1;this.parent&&!e?m(this,Q,hp).call(this):e&&(m(this,Q,kr).call(this,e),s=!this.parent&&this.div?.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,fe)?(e=(e-this.rotation+360)%360,n=m(r=at,Ns,io).call(r,i(this,ds).box,e)):n=m(a=at,Ns,io).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(i(this,us),{bbox:n,root:{"data-main-rotation":e}}),s.updateProperties(i(this,Ce),{bbox:m(o=at,Ns,io).call(o,i(this,Xe).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();i(this,Pl)&&(e.setAttribute("aria-label",i(this,Pl)),e.setAttribute("role","mark")),i(this,fe)?e.classList.add("free"):this.div.addEventListener("keydown",m(this,Q,Cb).bind(this),{signal:this._uiManager._signal});const s=f(this,Ra,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=i(this,ka),this.setDims(this.width,this.height),Kg(this,i(this,Ra),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(i(this,Ce),{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(i(this,Ce),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:m(this,Q,Xd).call(this,!0);break;case 1:case 3:m(this,Q,Xd).call(this,!1);break}}select(){super.select(),i(this,Ce)&&this.parent?.drawLayer.updateProperties(i(this,Ce),{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),i(this,Ce)&&(this.parent?.drawLayer.updateProperties(i(this,Ce),{rootClass:{selected:!1}}),i(this,fe)||m(this,Q,Xd).call(this,!1))}get _mustFixPosition(){return!i(this,fe)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(i(this,us),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(i(this,Ce),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:n,x:r,y:a}){const{x:o,y:l,width:h,height:c}=n.getBoundingClientRect(),u=new AbortController,p=e.combinedSignal(u),b=A=>{u.abort(),m(this,Ns,kb).call(this,e,A)};window.addEventListener("blur",b,{signal:p}),window.addEventListener("pointerup",b,{signal:p}),window.addEventListener("pointerdown",Ft,{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",ws,{signal:p}),n.addEventListener("pointermove",m(this,Ns,Pb).bind(this,e),{signal:p}),this._freeHighlight=new op({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 y,v,w,E;let r=null;if(e instanceof nb){const{data:{quadPoints:S,rect:_,rotation:C,id:T,color:x,opacity:P,popupRef:k,richText:M,contentsObj:D,creationDate:V,modificationDate:G},parent:{page:{pageNumber:$}}}=e;r=e={annotationType:X.HIGHLIGHT,color:Array.from(x),opacity:P,quadPoints:S,boxes:null,pageIndex:$-1,rect:_.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:k,richText:M,comment:D?.str||null,creationDate:V,modificationDate:G}}else if(e instanceof $p){const{data:{inkLists:S,rect:_,rotation:C,id:T,color:x,borderStyle:{rawWidth:P},popupRef:k,richText:M,contentsObj:D,creationDate:V,modificationDate:G},parent:{page:{pageNumber:$}}}=e;r=e={annotationType:X.HIGHLIGHT,color:Array.from(x),thickness:P,inkLists:S,boxes:null,pageIndex:$-1,rect:_.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:k,richText:M,comment:D?.str||null,creationDate:V,modificationDate:G}}const{color:a,quadPoints:o,inkLists:l,opacity:h}=e,c=await super.deserialize(e,s,n);c.color=O.makeHexColor(...a),c.opacity=h||1,l&&f(c,Is,e.thickness),c._initialData=r,e.comment&&c.setCommentData(e);const[u,p]=c.pageDimensions,[b,A]=c.pageTranslation;if(o){const S=f(c,fn,[]);for(let _=0;_<o.length;_+=8)S.push({x:(o[_]-b)/u,y:1-(o[_+1]-A)/p,width:(o[_+2]-o[_])/u,height:(o[_+1]-o[_+5])/p});m(y=c,Q,lp).call(y),m(v=c,Q,kr).call(v),c.rotate(c.rotation)}else if(l){f(c,fe,!0);const S=l[0],_={x:S[0]-b,y:p-(S[1]-A)},C=new op(_,[0,0,u,p],1,i(c,Is)/2,!0,.001);for(let P=0,k=S.length;P<k;P+=2)_.x=S[P]-b,_.y=p-(S[P+1]-A),C.add(_);const{id:T,clipPathId:x}=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,Q,Wd).call(w,{highlightOutlines:C.getOutlines(),highlightId:T,clipPathId:x}),m(E=c,Q,kr).call(E),c.rotate(c.parentRotation)}return c}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=_t._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:s,opacity:this.opacity,thickness:i(this,Is),quadPoints:m(this,Q,Tb).call(this),outlines:m(this,Q,xb).call(this,n.rect)}),this.addComment(n),this.annotationElementId&&!m(this,Q,Rb).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}};Cl=new WeakMap,Qc=new WeakMap,fn=new WeakMap,ka=new WeakMap,Zc=new WeakMap,Xe=new WeakMap,td=new WeakMap,ed=new WeakMap,Ra=new WeakMap,ds=new WeakMap,us=new WeakMap,fe=new WeakMap,Tl=new WeakMap,xl=new WeakMap,Ce=new WeakMap,Pl=new WeakMap,Is=new WeakMap,sd=new WeakMap,Q=new WeakSet,lp=function(){const e=new rp(i(this,fn),.001);f(this,ds,e.getOutlines()),[this.x,this.y,this.width,this.height]=i(this,ds).box;const s=new rp(i(this,fn),.0025,.001,this._uiManager.direction==="ltr");f(this,Xe,s.getOutlines());const{firstPoint:n}=i(this,ds);f(this,Tl,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]);const{lastPoint:r}=i(this,Xe);f(this,xl,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},Wd=function({highlightOutlines:e,highlightId:s,clipPathId:n}){var p,b;if(f(this,ds,e),f(this,Xe,e.getNewOutline(i(this,Is)/2+1.5,.0025)),s>=0)f(this,us,s),f(this,ka,n),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),f(this,Ce,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:i(this,Xe).box,path:{d:i(this,Xe).toSVGPath()}},!0));else if(this.parent){const A=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(i(this,us),{bbox:m(p=at,Ns,io).call(p,i(this,ds).box,(A-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(i(this,Ce),{bbox:m(b=at,Ns,io).call(b,i(this,Xe).box,A),path:{d:i(this,Xe).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[A,y]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*y/A,this.height=h*A/y;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[A,y]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*y/A,this.height=h*A/y;break}}const{firstPoint:c}=e;f(this,Tl,[(c[0]-a)/l,(c[1]-o)/h]);const{lastPoint:u}=i(this,Xe);f(this,xl,[(u[0]-a)/l,(u[1]-o)/h])},Eb=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,at._defaultOpacity),undo:s.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:et.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},Sb=function(e){const s=i(this,Is),n=r=>
12{f(this,Is,r),m(this,Q,_b).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:et.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},_b=function(e){i(this,fe)&&(m(this,Q,Wd).call(this,{highlightOutlines:i(this,ds).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))},hp=function(){i(this,us)===null||!this.parent||(this.parent.drawLayer.remove(i(this,us)),f(this,us,null),this.parent.drawLayer.remove(i(this,Ce)),f(this,Ce,null))},kr=function(e=this.parent){i(this,us)===null&&({id:Kt(this,us)._,clipPathId:Kt(this,ka)._}=e.drawLayer.draw({bbox:i(this,ds).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:i(this,fe)},path:{d:i(this,ds).toSVGPath()}},!1,!0),f(this,Ce,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:i(this,fe)},bbox:i(this,Xe).box,path:{d:i(this,Xe).toSVGPath()}},i(this,fe))),i(this,Ra)&&(i(this,Ra).style.clipPath=i(this,ka)))},Ns=new WeakSet,io=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]},Cb=function(e){at._keyboardManager.exec(this,e)},Xd=function(e){if(!i(this,Cl))return;const s=window.getSelection();e?s.setPosition(i(this,Cl),i(this,Qc)):s.setPosition(i(this,td),i(this,ed))},qd=function(){return i(this,fe)?this.rotation:0},Tb=function(){if(i(this,fe))return null;const[e,s]=this.pageDimensions,[n,r]=this.pageTranslation,a=i(this,fn),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:u,height:p}of a){const b=h*e+n,A=(1-c)*s+r;o[l]=o[l+4]=b,o[l+1]=o[l+3]=A,o[l+2]=o[l+6]=b+u*e,o[l+5]=o[l+7]=A-p*s,l+=8}return o},xb=function(e){return i(this,ds).serialize(e,m(this,Q,qd).call(this))},Pb=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},kb=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=""},Rb=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((n,r)=>n!==s[r])},g(at,Ns),R(at,"_defaultColor",null),R(at,"_defaultOpacity",1),R(at,"_defaultThickness",12),R(at,"_type","highlight"),R(at,"_editorType",X.HIGHLIGHT),R(at,"_freeHighlightId",-1),R(at,"_freeHighlight",null),R(at,"_freeHighlightClipId","");let du=at;var Ma;class Mb{constructor(){g(this,Ma,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,Ma)[t]=e}toSVGProperties(){const t=i(this,Ma);return f(this,Ma,Object.create(null)),{root:t}}reset(){f(this,Ma,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Et("Not implemented")}}Ma=new WeakMap;var fs,kl,ie,Da,La,cr,dr,ur,Ia,nt,cp,dp,up,fh,Db,Yd,ph,no;const B=class B extends _t{constructor(e){super(e);g(this,nt);g(this,fs,null);g(this,kl);R(this,"_colorPicker",null);R(this,"_drawId",null);f(this,kl,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines(e){e.drawOutlines&&(m(this,nt,cp).call(this,e),m(this,nt,fh).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){Et("Not implemented")}static get typesMap(){Et("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(B,ie).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=>{r.updateProperty(s,l);const h=i(this,fs).updateProperty(s,l);h&&m(this,nt,ph).call(this,h),this.parent?.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(){this.parent?.drawLayer.updateProperties(this._drawId,B._mergeSVGProperties(i(this,fs).getPathResizingSVGProperties(m(this,nt,Yd).call(this)),{bbox:m(this,nt,no).c
12all(this)}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,B._mergeSVGProperties(i(this,fs).getPathResizedSVGProperties(m(this,nt,Yd).call(this)),{bbox:m(this,nt,no).call(this)}))}_onTranslating(e,s){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:m(this,nt,no).call(this)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,B._mergeSVGProperties(i(this,fs).getPathTranslatedSVGProperties(m(this,nt,Yd).call(this),this.parentDimensions),{bbox:m(this,nt,no).call(this)}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,i(this,kl)&&(f(this,kl,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){m(this,nt,up).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,nt,fh).call(this),m(this,nt,ph).call(this,i(this,fs).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),m(this,nt,up).call(this)):e&&(this._uiManager.addShouldRescale(this),m(this,nt,fh).call(this,e),s=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,B._mergeSVGProperties({bbox:m(this,nt,no).call(this)},i(this,fs).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&m(this,nt,ph).call(this,i(this,fs).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){Et("Not implemented")}static startDrawing(e,s,n,r){const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(i(B,dr)&&i(B,dr)!==c)return;const{viewport:{rotation:u}}=e,{width:p,height:b}=a.getBoundingClientRect(),A=f(B,Da,new AbortController),y=e.combinedSignal(A);if(i(B,cr)||f(B,cr,h),i(B,dr)??f(B,dr,c),window.addEventListener("pointerup",v=>{i(B,cr)===v.pointerId?this._endDraw(v):i(B,ur)?.delete(v.pointerId)},{signal:y}),window.addEventListener("pointercancel",v=>{i(B,cr)===v.pointerId?this._currentParent.endDrawingSession():i(B,ur)?.delete(v.pointerId)},{signal:y}),window.addEventListener("pointerdown",v=>{i(B,dr)===v.pointerType&&((i(B,ur)||f(B,ur,new Set)).add(v.pointerId),i(B,ie).isCancellable()&&(i(B,ie).removeLastElement(),i(B,ie).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:y}),window.addEventListener("contextmenu",ws,{signal:y}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:y}),a.addEventListener("touchmove",v=>{v.timeStamp===i(B,Ia)&&Ft(v)},{signal:y}),e.toggleDrawing(),s._editorUndoBar?.hide(),i(B,ie)){e.drawLayer.updateProperties(this._currentDrawId,i(B,ie).startNew(o,l,p,b,u));return}s.updateUIForDefaultProperties(this),f(B,ie,this.createDrawerInstance(o,l,p,b,u)),f(B,La,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(i(B,La).toSVGProperties(),i(B,ie).defaultSVGProperties),!0,!1)}static _drawMove(e){if(f(B,Ia,-1),!i(B,ie))return;const{offsetX:s,offsetY:n,pointerId:r}=e;if(i(B,cr)===r){if(i(B,ur)?.size>=1){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,i(B,ie).add(s,n)),f(B,Ia,e.timeStamp),Ft(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,f(B,ie,null),f(B,La,null),f(B,dr,null),f(B,Ia,NaN)),i(B,Da)&&(i(B,Da).abort(),f(B,Da,null),f(B,cr,NaN),f(B,ur,null))}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),e?.target===s.div&&s.drawLayer.updateProperties(this._currentDrawId,i(B,ie).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const n=i(B,ie),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:et.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(et.DRAW_STEP),!i(B,ie).isEmpty()){const{pageDimensions:[n,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:i(B,ie).getOutlines(n*a,r*a,a,this._INNER_MARGIN),drawingOptions:i(B,La),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){Et("Not implemented")}static async deserialize(e,s,n){var u,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(u=c,nt,cp).call(u,{drawOutlines:h}),m(p=c,nt,fh).call(p),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,n]=this.pageTranslation,[r,a]=this.pageDimensions;return i(this,fs).serialize([s,n,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};fs=new WeakMap,kl=new WeakMap,ie=new WeakMap,Da=new WeakMap,La=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,Ia=new WeakMap,nt=new WeakSet,cp=function({drawOutlines:e,drawId:s,drawingOptions:n}){f(this,fs,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,nt,dp).call(this,e,this.parent),m(this,nt,ph).call(this,e.box)},dp=function(e,s){const{id:n}=s.drawLayer.draw(B._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n},up=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},fh=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,nt,dp).call(this,i(this,fs),e)}},Db=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]}},Yd=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]}},ph=function(e){[this.x,this.y,this.width,this.height]=m(this,nt,Db).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},no=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)];
12case 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]}},R(B,"_currentDrawId",-1),R(B,"_currentParent",null),g(B,ie,null),g(B,Da,null),g(B,La,null),g(B,cr,NaN),g(B,dr,null),g(B,ur,null),g(B,Ia,NaN),R(B,"_INNER_MARGIN",3);let uu=B;var Ci,ne,re,Fa,Rl,De,pe,Fs,Na,Oa,Ba,Ml,Kd;class sw{constructor(t,e,s,n,r,a){g(this,Ml);g(this,Ci,new Float64Array(6));g(this,ne);g(this,re);g(this,Fa);g(this,Rl);g(this,De);g(this,pe,"");g(this,Fs,0);g(this,Na,new ud);g(this,Oa);g(this,Ba);f(this,Oa,s),f(this,Ba,n),f(this,Fa,r),f(this,Rl,a),[t,e]=m(this,Ml,Kd).call(this,t,e);const o=f(this,ne,[NaN,NaN,NaN,NaN,t,e]);f(this,De,[t,e]),f(this,re,[{line:o,points:i(this,De)}]),i(this,Ci).set(o,0)}updateProperty(t,e){t==="stroke-width"&&f(this,Rl,e)}isEmpty(){return!i(this,re)||i(this,re).length===0}isCancellable(){return i(this,De).length<=10}add(t,e){[t,e]=m(this,Ml,Kd).call(this,t,e);const[s,n,r,a]=i(this,Ci).subarray(2,6),o=t-r,l=e-a;return Math.hypot(i(this,Oa)*o,i(this,Ba)*l)<=2?null:(i(this,De).push(t,e),isNaN(s)?(i(this,Ci).set([r,a,t,e],2),i(this,ne).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(i(this,Ci)[0])&&i(this,ne).splice(6,6),i(this,Ci).set([s,n,r,a,t,e],0),i(this,ne).push(...N.createBezierPoints(s,n,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(i(this,De).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,n,r){f(this,Oa,s),f(this,Ba,n),f(this,Fa,r),[t,e]=m(this,Ml,Kd).call(this,t,e);const a=f(this,ne,[NaN,NaN,NaN,NaN,t,e]);f(this,De,[t,e]);const o=i(this,re).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),i(this,re).push({line:a,points:i(this,De)}),i(this,Ci).set(a,0),f(this,Fs,0),this.toSVGPath(),null}getLastElement(){return i(this,re).at(-1)}setLastElement(t){return i(this,re)?(i(this,re).push(t),f(this,ne,t.line),f(this,De,t.points),f(this,Fs,0),{path:{d:this.toSVGPath()}}):i(this,Na).setLastElement(t)}removeLastElement(){if(!i(this,re))return i(this,Na).removeLastElement();i(this,re).pop(),f(this,pe,"");for(let t=0,e=i(this,re).length;t<e;t++){const{line:s,points:n}=i(this,re)[t];f(this,ne,s),f(this,De,n),f(this,Fs,0),this.toSVGPath()}return{path:{d:i(this,pe)}}}toSVGPath(){const t=N.svgRound(i(this,ne)[4]),e=N.svgRound(i(this,ne)[5]);if(i(this,De).length===2)return f(this,pe,`${i(this,pe)} M ${t} ${e} Z`),i(this,pe);if(i(this,De).length<=6){const n=i(this,pe).lastIndexOf("M");f(this,pe,`${i(this,pe).slice(0,n)} M ${t} ${e}`),f(this,Fs,6)}if(i(this,De).length===4){const n=N.svgRound(i(this,ne)[10]),r=N.svgRound(i(this,ne)[11]);return f(this,pe,`${i(this,pe)} L ${n} ${r}`),f(this,Fs,12),i(this,pe)}const s=[];i(this,Fs)===0&&(s.push(`M ${t} ${e}`),f(this,Fs,6));for(let n=i(this,Fs),r=i(this,ne).length;n<r;n+=6){const[a,o,l,h,c,u]=i(this,ne).slice(n,n+6).map(N.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}return f(this,pe,i(this,pe)+s.join(" ")),f(this,Fs,i(this,ne).length),i(this,pe)}getOutlines(t,e,s,n){const r=i(this,re).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),i(this,Na).build(i(this,re),t,e,s,i(this,Fa),i(this,Rl),n),f(this,Ci,null),f(this,ne,null),f(this,re,null),f(this,pe,null),i(this,Na)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Ci=new WeakMap,ne=new WeakMap,re=new WeakMap,Fa=new WeakMap,Rl=new WeakMap,De=new WeakMap,pe=new WeakMap,Fs=new WeakMap,Na=new WeakMap,Oa=new WeakMap,Ba=new WeakMap,Ml=new WeakSet,Kd=function(t,e){return N._normalizePoint(t,e,i(this,Oa),i(this,Ba),i(this,Fa))};var Le,id,nd,ps,Ti,xi,Dl,Ll,Ha,me,Fi,Lb,Ib,Fb;class ud extends N{constructor(){super(...arguments);g(this,me);g(this,Le);g(this,id,0);g(this,nd);g(this,ps);g(this,Ti);g(this,xi);g(this,Dl);g(this,Ll);g(this,Ha)}build(e,s,n,r,a,o,l){f(this,Ti,s),f(this,xi,n),f(this,Dl,r),f(this,Ll,a),f(this,Ha,o),f(this,nd,l??0),f(this,ps,e),m(this,me,Ib).call(this)}get thickness(){return i(this,Ha)}setLastElement(e){return i(this,ps).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return i(this,ps).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of i(this,ps)){if(e.push(`M${N.svgRound(s[4])} ${N.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${N.svgRound(s[10])} ${N.svgRound(s[11])}`);continue}for(let n=6,r=s.length;n<r;n+=6){const[a,o,l,h,c,u]=s.subarray(n,n+6).map(N.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}}return e.join("")}serialize([e,s,n,r],a){const o=[],l=[],[h,c,u,p]=m(this,me,Lb).call(this);let b,A,y,v,w,E,S,_,C;switch(i(this,Ll)){case 0:C=N._rescale,b=e,A=s+r,y=n,v=-r,w=e+h*n,E=s+(1-c-p)*r,S=e+(h+u)*n,_=s+(1-c)*r;break;case 90:C=N._rescaleAndSwap,b=e,A=s,y=n,v=r,w=e+c*n,E=s+h*r,S=e+(c+p)*n,_=s+(h+u)*r;break;case 180:C=N._rescale,b=e+n,A=s,y=-n,v=r,w=e+(1-h-u)*n,E=s+c*r,S=e+(1-h)*n,_=s+(c+p)*r;break;case 270:C=N._rescaleAndSwap,b=e+n,A=s+r,y=-n,v=-r,w=e+(1-c-p)*n,E=s+(1-h-u)*r,S=e+(1-c)*n,_=s+(1-h)*r;break}for(const{line:T,points:x}
12of i(this,ps))o.push(C(T,b,A,y,v,a?new Array(T.length):null)),l.push(C(x,b,A,y,v,a?new Array(x.length):null));return{lines:o,points:l,rect:[w,E,S,_]}}static deserialize(e,s,n,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const u=[];let p,b,A,y,v;switch(h){case 0:v=N._rescale,p=-e/n,b=s/r+1,A=1/n,y=-1/r;break;case 90:v=N._rescaleAndSwap,p=-s/r,b=-e/n,A=1/r,y=1/n;break;case 180:v=N._rescale,p=e/n+1,b=-s/r,A=-1/n,y=1/r;break;case 270:v=N._rescaleAndSwap,p=s/r+1,b=e/n+1,A=-1/r,y=-1/n;break}if(!o){o=[];for(const E of l){const S=E.length;if(S===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,E[0],E[1]]));continue}if(S===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,E[0],E[1],NaN,NaN,NaN,NaN,E[2],E[3]]));continue}const _=new Float32Array(3*(S-2));o.push(_);let[C,T,x,P]=E.subarray(0,4);_.set([NaN,NaN,NaN,NaN,C,T],0);for(let k=4;k<S;k+=2){const M=E[k],D=E[k+1];_.set(N.createBezierPoints(C,T,x,P,M,D),(k-2)*3),[C,T,x,P]=[x,P,M,D]}}}for(let E=0,S=o.length;E<S;E++)u.push({line:v(o[E].map(_=>_??NaN),p,b,A,y),points:v(l[E].map(_=>_??NaN),p,b,A,y)});const w=new this.prototype.constructor;return w.build(u,n,r,1,h,c,a),w}get box(){return i(this,Le)}updateProperty(e,s){return e==="stroke-width"?m(this,me,Fb).call(this,s):null}updateParentDimensions([e,s],n){const[r,a]=m(this,me,Fi).call(this);f(this,Ti,e),f(this,xi,s),f(this,Dl,n);const[o,l]=m(this,me,Fi).call(this),h=o-r,c=l-a,u=i(this,Le);return u[0]-=h,u[1]-=c,u[2]+=2*h,u[3]+=2*c,u}updateRotation(e){return f(this,id,e),{path:{transform:this.rotationTransform}}}get viewBox(){return i(this,Le).map(N.svgRound).join(" ")}get defaultProperties(){const[e,s]=i(this,Le);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=i(this,Le);let n=0,r=0,a=0,o=0,l=0,h=0;switch(i(this,id)){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} ${N.svgRound(l)} ${N.svgRound(h)})`}getPathResizingSVGProperties([e,s,n,r]){const[a,o]=m(this,me,Fi).call(this),[l,h,c,u]=i(this,Le);if(Math.abs(c-a)<=N.PRECISION||Math.abs(u-o)<=N.PRECISION){const v=e+n/2-(l+c/2),w=s+r/2-(h+u/2);return{path:{"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const p=(n-2*a)/(c-2*a),b=(r-2*o)/(u-2*o),A=c/n,y=u/r;return{path:{"transform-origin":`${N.svgRound(l)} ${N.svgRound(h)}`,transform:`${this.rotationTransform} scale(${A} ${y}) translate(${N.svgRound(a)} ${N.svgRound(o)}) scale(${p} ${b}) translate(${N.svgRound(-a)} ${N.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,n,r]){const[a,o]=m(this,me,Fi).call(this),l=i(this,Le),[h,c,u,p]=l;if(l[0]=e,l[1]=s,l[2]=n,l[3]=r,Math.abs(u-a)<=N.PRECISION||Math.abs(p-o)<=N.PRECISION){const w=e+n/2-(h+u/2),E=s+r/2-(c+p/2);for(const{line:S,points:_}of i(this,ps))N._translate(S,w,E,S),N._translate(_,w,E,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const b=(n-2*a)/(u-2*a),A=(r-2*o)/(p-2*o),y=-b*(h+a)+e+a,v=-A*(c+o)+s+o;if(b!==1||A!==1||y!==0||v!==0)for(const{line:w,points:E}of i(this,ps))N._rescale(w,y,v,b,A,w),N._rescale(E,y,v,b,A,E);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],n){const[r,a]=n,o=i(this,Le),l=e-o[0],h=s-o[1];if(i(this,Ti)===r&&i(this,xi)===a)for(const{line:c,points:u}of i(this,ps))N._translate(c,l,h,c),N._translate(u,l,h,u);else{const c=i(this,Ti)/r,u=i(this,xi)/a;f(this,Ti,r),f(this,xi,a);for(const{line:p,points:b}of i(this,ps))N._rescale(p,l,h,c,u,p),N._rescale(b,l,h,c,u,b);o[2]*=c,o[3]*=u}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`}}}get defaultSVGProperties(){const e=i(this,Le);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${N.svgRound(e[0])} ${N.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Le=new WeakMap,id=new WeakMap,nd=new WeakMap,ps=new WeakMap,Ti=new WeakMap,xi=new WeakMap,Dl=new WeakMap,Ll=new WeakMap,Ha=new WeakMap,me=new WeakSet,Fi=function(e=i(this,Ha)
12){const s=i(this,nd)+e/2*i(this,Dl);return i(this,Ll)%180===0?[s/i(this,Ti),s/i(this,xi)]:[s/i(this,xi),s/i(this,Ti)]},Lb=function(){const[e,s,n,r]=i(this,Le),[a,o]=m(this,me,Fi).call(this,0);return[e+a,s+o,n-2*a,r-2*o]},Ib=function(){const e=f(this,Le,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of i(this,ps)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)O.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,u,p,b,A,y]=r.subarray(l,l+6);O.bezierBoundingBox(a,o,c,u,p,b,A,y,e),a=A,o=y}}const[s,n]=m(this,me,Fi).call(this);e[0]=Te(e[0]-s,0,1),e[1]=Te(e[1]-n,0,1),e[2]=Te(e[2]+s,0,1),e[3]=Te(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]},Fb=function(e){const[s,n]=m(this,me,Fi).call(this);f(this,Ha,e);const[r,a]=m(this,me,Fi).call(this),[o,l]=[r-s,a-n],h=i(this,Le);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class Uu extends Mb{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:_t._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 Uu(this._viewParameters);return t.updateAll(this),t}}var Du,Nb;const ho=class ho extends uu{constructor(e){super({...e,name:"inkEditor"});g(this,Du);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){_t.initialize(e,s),this._defaultDrawingOptions=new Uu(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return J(this,"typesMap",new Map([[et.INK_THICKNESS,"stroke-width"],[et.INK_COLOR,"stroke"],[et.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,n,r,a){return new sw(e,s,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,n,r,a,o){return ud.deserialize(e,s,n,r,a,o)}static async deserialize(e,s,n){let r=null;if(e instanceof $p){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:u,opacity:p,borderStyle:{rawWidth:b},popupRef:A,richText:y,contentsObj:v,creationDate:w,modificationDate:E},parent:{page:{pageNumber:S}}}=e;r=e={annotationType:X.INK,color:Array.from(u),thickness:b,opacity:p,paths:{points:o},boxes:null,pageIndex:S-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:A,richText:y,comment:v?.str||null,creationDate:w,modificationDate:E}}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 hu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return et.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}){this._drawingOptions=ho.getDefaultDrawingOptions({stroke:O.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:_t._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,Du,Nb).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}};Du=new WeakSet,Nb=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}
12,R(ho,"_type","ink"),R(ho,"_editorType",X.INK),R(ho,"_defaultDrawingOptions",null);let fp=ho;class pp extends ud{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const _d=8,Yl=3;var Ua,lt,gp,Js,Ob,Bb,mp,Jd,Hb,Ub,$b,bp,yp,jb;class Mi{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 u=200,p=c.font=`${s} ${n} ${u}px ${e}`,{actualBoundingBoxLeft:b,actualBoundingBoxRight:A,actualBoundingBoxAscent:y,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:E,width:S}=c.measureText(t),_=1.5,C=Math.ceil(Math.max(Math.abs(b)+Math.abs(A)||0,S)*_),T=Math.ceil(Math.max(Math.abs(y)+Math.abs(v)||u,Math.abs(w)+Math.abs(E)||u)*_);h=new OffscreenCanvas(C,T),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=p,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,C,T),c.fillStyle="black",c.fillText(t,C*(_-1)/2,T*(3-_)/2);const x=m(this,lt,bp).call(this,c.getImageData(0,0,C,T).data),P=m(this,lt,$b).call(this,x),k=m(this,lt,yp).call(this,P),M=m(this,lt,mp).call(this,x,C,T,k);return this.processDrawnLines({lines:{curves:M,width:C,height:T},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,lt,jb).call(this,t),[h,c]=m(this,lt,Ub).call(this,a,o,l,Math.hypot(o,l)*i(this,Ua).sigmaSFactor,i(this,Ua).sigmaR,i(this,Ua).kernelSize),u=m(this,lt,yp).call(this,c),p=m(this,lt,mp).call(this,h,o,l,u);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,u=t.thickness??0,p=[],b=Math.min(e/h,s/c),A=b/e,y=b/s,v=[];for(const{points:E}of l){const S=a?m(this,lt,Hb).call(this,E):E;if(!S)continue;v.push(S);const _=S.length,C=new Float32Array(_),T=new Float32Array(3*(_===2?2:_-2));if(p.push({line:T,points:C}),_===2){C[0]=S[0]*A,C[1]=S[1]*y,T.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[x,P,k,M]=S;x*=A,P*=y,k*=A,M*=y,C.set([x,P,k,M],0),T.set([NaN,NaN,NaN,NaN,x,P],0);for(let D=4;D<_;D+=2){const V=C[D]=S[D]*A,G=C[D+1]=S[D+1]*y;T.set(N.createBezierPoints(x,P,k,M,V,G),(D-2)*3),[x,P,k,M]=[k,M,V,G]}}if(p.length===0)return null;const w=o?new pp:new ud;return w.build(p,e,s,1,n,o?0:u,r),{outline:w,newCurves:v,areContours:o,thickness:u,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 S of t){l+=S.length;for(let _=2,C=S.length;_<C;_++){const T=S[_]-S[_-2];a=Math.min(a,T),o=Math.max(o,T)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,u=_d+Yl*c,p=new Uint32Array(u);let b=0;p[b++]=u*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 S of t)p[b++]=S.length-2,p[b++]=S[0],p[b++]=S[1];const A=new CompressionStream("deflate-raw"),y=A.writable.getWriter();await y.ready,y.write(p);const v=h.prototype.constructor;for(const S of t){const _=new v(S.length-2);for(let C=2,T=S.length;C<T;C++)_[C-2]=S[C]-S[C-2];y.write(_)}y.close();const w=await new Response(A.readable).arrayBuffer(),E=new Uint8Array(w);return Bg(E)}static async decompressSignature(t){try{const e=xy(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 S of s)a||(a=new Uint8Array(new Uint32Array(S.buffer,0,4)[0])),a.set(S,o),o+=S.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],u=l[3],p=l[4]===0,b=l[5],A=l[6],y=l[7],v=[],w=(_d+Yl*A)*Uint32Array.BYTES_PER_ELEMENT;let E;switch(y){case Int8Array.BYTES_PER_ELEMENT:E=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:E=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:E=new Int32Array(a.buffer,w);break}o=0;for(let S=0;S<A;S++){const _=l[Yl*S+_d],C=new Float32Array(_+2);v.push(C);for(let T=0;T<Yl-1;T++)C[T]=l[Yl*S+_d+T+1];for(let T=0;T<_;T++)C[T+2]=C[T]+E[o++]}return{areContours:p,thickness:b,outlines:v,width:c,height:u}}catch(e){return q(`decompressSignature: ${e}`),null}}}
12Ua=new WeakMap,lt=new WeakSet,gp=function(t,e,s,n){return s-=t,n-=e,s===0?n>0?0:4:s===1?n+6:2-n},Js=new WeakMap,Ob=function(t,e,s,n,r,a,o){const l=m(this,lt,gp).call(this,s,n,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,u=i(this,Js)[2*c],p=i(this,Js)[2*c+1];if(t[(s+u)*e+(n+p)]!==0)return c}return-1},Bb=function(t,e,s,n,r,a,o){const l=m(this,lt,gp).call(this,s,n,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,u=i(this,Js)[2*c],p=i(this,Js)[2*c+1];if(t[(s+u)*e+(n+p)]!==0)return c}return-1},mp=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 u=1;u<e-1;u++){const p=c*e+u,b=a[p];if(b===0)continue;let A=c,y=u;if(b===1&&a[p-1]===0)o+=1,y-=1;else if(b>=1&&a[p+1]===0)o+=1,y+=1,b>1&&(l=b);else{b!==1&&(l=Math.abs(b));continue}const v=[u,c],w=y===u+1,E={isHole:w,points:v,id:o,parent:0};h.push(E);let S;for(const D of h)if(D.id===l){S=D;break}S?S.isHole?E.parent=w?S.parent:l:E.parent=w?l:S.parent:E.parent=w?l:0;const _=m(this,lt,Ob).call(this,a,e,c,u,A,y,0);if(_===-1){a[p]=-o,a[p]!==1&&(l=Math.abs(a[p]));continue}let C=i(this,Js)[2*_],T=i(this,Js)[2*_+1];const x=c+C,P=u+T;A=x,y=P;let k=c,M=u;for(;;){const D=m(this,lt,Bb).call(this,a,e,k,M,A,y,1);C=i(this,Js)[2*D],T=i(this,Js)[2*D+1];const V=k+C,G=M+T;v.push(G,V);const $=k*e+M;if(a[$+1]===0?a[$]=-o:a[$]===1&&(a[$]=o),V===c&&G===u&&k===x&&M===P){a[p]!==1&&(l=Math.abs(a[p]));break}else A=k,y=M,k=V,M=G}}}return h},Jd=function(t,e,s,n){if(s-e<=4){for(let x=e;x<s-2;x+=2)n.push(t[x],t[x+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,u=l/h,p=c*a-u*r,b=l/o,A=1/h,y=Math.atan(b),v=Math.cos(y),w=Math.sin(y),E=A*(Math.abs(v)+Math.abs(w)),S=A*(1-E+E**2),_=Math.max(Math.atan(Math.abs(w+v)*S),Math.atan(Math.abs(w-v)*S));let C=0,T=e;for(let x=e+2;x<s-2;x+=2){const P=Math.abs(p-c*t[x+1]+u*t[x]);P>C&&(T=x,C=P)}C>(h*_)**2?(m(this,lt,Jd).call(this,t,e,T+2,n),m(this,lt,Jd).call(this,t,T,s,n)):n.push(r,a)},Hb=function(t){const e=[],s=t.length;return m(this,lt,Jd).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},Ub=function(t,e,s,n,r,a){const o=new Float32Array(a**2),l=-2*n**2,h=a>>1;for(let y=0;y<a;y++){const v=(y-h)**2;for(let w=0;w<a;w++)o[y*a+w]=Math.exp((v+(w-h)**2)/l)}const c=new Float32Array(256),u=-2*r**2;for(let y=0;y<256;y++)c[y]=Math.exp(y**2/u);const p=t.length,b=new Uint8Array(p),A=new Uint32Array(256);for(let y=0;y<s;y++)for(let v=0;v<e;v++){const w=y*e+v,E=t[w];let S=0,_=0;for(let T=0;T<a;T++){const x=y+T-h;if(!(x<0||x>=s))for(let P=0;P<a;P++){const k=v+P-h;if(k<0||k>=e)continue;const M=t[x*e+k],D=o[T*a+P]*c[Math.abs(M-E)];S+=M*D,_+=D}}const C=b[w]=Math.round(S/_);A[C]++}return[b,A]},$b=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},bp=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},yp=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},jb=function(t){const e=t,{width:s,height:n}=t,{maxDim:r}=i(this,Ua);let a=s,o=n;if(s>r||n>r){let p=s,b=n,A=Math.log2(Math.max(s,n)/r);const y=Math.floor(A);A=A===y?y-1:y;for(let w=0;w<A;w++){a=Math.ceil(p/2),o=Math.ceil(b/2);const E=new OffscreenCanvas(a,o);E.getContext("2d").drawImage(t,0,0,p,b,0,0,a,o),p=a,b=o,t!==e&&t.close(),t=E.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,lt,bp).call(this,c),a,o]},g(Mi,lt),g(Mi,Ua,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),g(Mi,Js,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class Gp extends Mb{constructor(){super(),super.updateProperties({fill:_t._defaultLineColor,"stroke-width":0})}clone(){const t=new Gp;return t.updateAll(this),t}}class zp extends Uu{constructor(t){super(t),super.updateProperties({stroke:_t._defaultLineColor,"stroke-width":1})}clone(){const t=new zp(this._viewParameters);return t.updateAll(this),t}}var fr,Pi,pr,$a;const Qe=class Qe extends uu{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});g(this,fr,!1);g(this,Pi,null);g(this,pr,null);g(this,$a,null);this._willKeepAspectRatio=!0,f(this,pr,e.signatureData||null),f(this,Pi,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){_t.initialize(e,s),this._defaultDrawingOptions=new Gp,this._defaultDrawnSignatureOptions=new zp(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return J(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!i(this,Pi)}}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,pr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=i(this,pr),{rawDims:{pageWidth:u,pageHeight:p},rotation:b}=this.parent.viewport,A=Mi.processDrawnLines({lines:r,pageWidth:u,pageHeight:p,rotation:b,innerMargin:Qe._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(A,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,Pi)||""}));return n&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){f(this,$a,e),this.addEditToolbar()}getUuid(){return i(this,$a)}get description(){return i(this,Pi)}set description(e){f(this,Pi,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s?.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:n,width:r,height:a}=i(this,pr),o=Math.max(r,a),l=Mi.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,pr,e);f(this,fr,l instanceof pp),this.description=n;let h;i(this,fr)?h=Qe.getDefaultDrawingOptions():(h=Qe._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let u=s/c;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,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 Mi.process(e,s,n,r,Qe._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:n,pageHeight:r},rotation:a}=this.parent.viewport;return Mi.extractContoursFromText(e,s,n,r,a,Qe._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return Mi.processDrawnLines({lines:e,pageWidth:s,pageHeight:n,rotation:r,innerMargin:Qe._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Qe.getDefaultDrawingOptions():(this._drawingOptions=Qe._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,fr),color:[0,0,0],thickness:i(this,fr)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:n},a.uuid=i(this,$a),a.isCopy=!0):a.lines=s,i(this,Pi)&&(a.accessibilityData={type:"Figure",alt:i(this,Pi)}),a}static deserializeDraw(e,s,n,r,a,o){return o.areContours?pp.deserialize(e,s,n,r,a,o):ud.deserialize(e,s,n,r,a,o)}static async deserialize(e,s,n){const r=await super.deserialize(e,s,n);return f(r,fr,e.areContours),r.description=e.accessibilityData?.alt||"",f(r,$a,e.uuid),r}};fr=new WeakMap,Pi=new WeakMap,pr=new WeakMap,$a=new WeakMap,R(Qe,"_type","signature"),R(Qe,"_editorType",X.SIGNATURE),R(Qe,"_defaultDrawingOptions",null);let Ap=Qe;var Rt,ae,gr,pn,mr,Il,gn,ja,ki,gs,Fl,rt,gh,mh,Qd,Zd,tu,vp,eu,Gb;class wp extends _t{constructor(e){super({...e,name:"stampEditor"});g(this,rt);g(this,Rt,null);g(this,ae,null);g(this,gr,null);g(this,pn,null);g(this,mr,null);g(this,Il,"");g(this,gn,null);g(this,ja,!1);g(this,ki,null);g(this,gs,!1);g(this,Fl,!1);f(this,pn,e.bitmapUrl),f(this,mr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){_t.initialize(e,s)}static isHandlingMimeForPasting(e){return nu.includes(e)}static paste(e,s){s.pasteEditor({mode:X.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.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(){i(this,ae)&&(f(this,Rt,null),this._uiManager.imageManager.deleteId(i(this,ae)),i(this,gn)?.remove(),f(this,gn,null),i(this,ki)&&(clearTimeout(i(this,ki)),f(this,ki,null))),super.remove()}rebuild(){if(!this.parent){i(this,ae)&&m(this,rt,Qd).call(this);return}super.rebuild(),this.div!==null&&(i(this,ae)&&i(this,gn)===null&&m(this,rt,Qd).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(i(this,gr)||i(this,Rt)||i(this,pn)||i(this,mr)||i(this,ae)||i(this,ja))}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,ja)||(i(this,Rt)?m(this,rt,Zd).call(this):m(this,rt,Qd).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,ae,n),r&&f(this,Rt,r),f(this,ja,!1),m(this,rt,Zd).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;i(this,ki)!==null&&clearTimeout(i(this,ki)),f(this,ki,setTimeout(()=>{f(this,ki,null),m(this,rt,vp).call(this)},200))}copyCanvas(e,s,n=!1){e||(e=224);const{width:r,height:a}=i(this,Rt),o=new si;let l=i(this,Rt),h=r,c=a,u=null;if(s){if(r>s||a>s){const x=Math.min(s/r,s/a);h=Math.floor(r*x),c=Math.floor(a*x)}u=document.createElement("canvas");const b=u.width=Math.ceil(h*o.sx),A=u.height=Math.ceil(c*o.sy);i(this,gs)||(l=m(this,rt,tu).call(this,b,A));const y=u.getContext("2d");y.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":Ry.isDarkMode&&(v="#8f8f9d",w="#42414d");const E=15,S=E*o.sx,_=E*o.sy,C=new OffscreenCanvas(S*2,_*2),T=C.getContext("2d");T.fillStyle=v,T.fillRect(0,0,S*2,_*2),T.fillStyle=w,T.fillRect(0,0,S,_),T.fillRect(S,_,S,_),y.fillStyle=y.createPattern(C,"repeat"),y.fillRect(0,0,b,A),y.drawImage(l,0,0,l.width,l.height,0,0,b,A)}let p=null;if(n){let b,A;if(o.symmetric&&l.width<e&&l.height<e)b=l.width,A=l.height;else if(l=i(this,Rt),r>e||a>e){const w=Math.min(e/r,e/a);b=Math.floor(r*w),A=Math.floor(a*w),i(this,gs)||(l=m(this,rt,tu).call(this,b,A))}const v=new OffscreenCanvas(b,A).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,b,A),p={width:b,height:A,data:v.getImageData(0,0,b,A).data}}return{canvas:u,width:h,height:c,imageData:p}}static async deserialize(e,s,n){let r=null,a=!1;if(e instanceof rb){const{data:{rect:v,rotation:w,id:E,structParent:S,popupRef:_,richText:C,contentsObj:T,creationDate:x,modificationDate:P},container:k,parent:{page:{pageNumber:M}},canvas:D}=e;let V,G;D?(delete e.canvas,{id:V,bitmap:G}=n.imageManager.getFromCanvas(k.id,D),D.remove()):(a=!0,e._hasNoCanvas=!0);const $=(await s._structTree.getAriaAttributes(`${Dp}${E}`))?.get("aria-label")||"";r=e={annotationType:X.STAMP,bitmapId:V,bitmap:G,pageIndex:M-1,rect:v.slice(0),rotation:w,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:$},isSvg:!1,structParent:S,popupRef:_,richText:C,comment:T?.str||null,creationDate:x,modificationDate:P}}const o=await super.deserialize(e,s,n),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:u,isSvg:p,accessibilityData:b}=e;a?(n.addMissingCanvas(e.id,o),f(o,ja,!0)):u&&n.imageManager.isValidId(u)?(f(o,ae,u),h&&f(o,Rt,h)):f(o,pn,c),f(o,gs,p);const[A,y]=o.pageDimensions;return o.width=(l[2]-l[0])/A,o.height=(l[3]-l[1])/y,b&&(o.altTextData=b),o._initialData=r,e.comment&&o.setCommentData(e),f(o,Fl,!!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,ae),isSvg:i(this,gs)});if(this.addComment(n),e)return n.bitmapUrl=m(this,rt,eu).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,rt,Gb).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,gs)?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!s.stamps.has(i(this,ae)))s.stamps.set(i(this,ae),{area:o,serialized:n}),n.bitmap=m(this,rt,eu).call(this,!1);else if(i(this,gs)){const l=s.stamps.get(i(this,ae));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=m(this,rt,eu).call(this,!1))}return n}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Rt=new WeakMap,ae=new WeakMap,gr=new WeakMap,pn=new WeakMap,mr=new WeakMap,Il=new WeakMap,gn=new WeakMap,ja=new WeakMap,ki=new WeakMap,gs=new WeakMap,Fl=new WeakMap,rt=new WeakSet,gh=function(e,s=!1){if(!e){this.remove();return}f(this,Rt,e.bitmap),s||(f(this,ae,e.id),f(this,gs,e.isSvg)),e.file&&f(this,Il,e.file.name),m(this,rt,Zd).call(this)},mh=function(){if(f(this,gr,null),this._uiManager.enableWaiting(!1),!!i(this,gn)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&i(this,Rt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&i(this,Rt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Qd=function(){if(i(this,ae)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(i(this,ae)).then(n=>m(this,rt,gh).call(this,n,!0)).finally(()=>m(this,rt,mh).call(this));return}if(i(this,pn)){const n=i(this,pn);f(this,pn,null),this._uiManager.enableWaiting(!0),f(this,gr,this._uiManager.imageManager.getFromUrl(n).then(r=>m(this,rt,gh).call(this,r)).finally(()=>m(this,rt,mh).call(this)));return}if(i(this,mr)){const n=i(this,mr);f(this,mr,null),this._uiManager.enableWaiting(!0),f(this,gr,this._uiManager.imageManager.getFromFile(n).then(r=>m(this,rt,gh).call(this,r)).finally(()=>m(this,rt,mh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=nu.join(",");const s=this._uiManager._signal;f(this,gr,new Promise(n=>{e.addEventListener("change",async()=>
12{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,rt,gh).call(this,r)}n()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:s})}).finally(()=>m(this,rt,mh).call(this))),e.click()},Zd=function(){const{div:e}=this;let{width:s,height:n}=i(this,Rt);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 h=Math.min(o*r/s,o*a/n);s*=h,n*=h}this._uiManager.enableWaiting(!1);const l=f(this,gn,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=n/a,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),m(this,rt,vp).call(this),i(this,Fl)||(this.parent.addUndoableEditor(this),f(this,Fl,!0)),this._reportTelemetry({action:"inserted_image"}),i(this,Il)&&this.div.setAttribute("aria-description",i(this,Il)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},tu=function(e,s){const{width:n,height:r}=i(this,Rt);let a=n,o=r,l=i(this,Rt);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 u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=u.transferToImageBitmap()}return l},vp=function(){const[e,s]=this.parentDimensions,{width:n,height:r}=this,a=new si,o=Math.ceil(n*e*a.sx),l=Math.ceil(r*s*a.sy),h=i(this,gn);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=i(this,gs)?i(this,Rt):m(this,rt,tu).call(this,o,l),u=h.getContext("2d");u.filter=this._uiManager.hcmFilter,u.drawImage(c,0,0,c.width,c.height,0,0,o,l)},eu=function(e){if(e){if(i(this,gs)){const r=this._uiManager.imageManager.getSvgUrl(i(this,ae));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=i(this,Rt),s.getContext("2d").drawImage(i(this,Rt),0,0),s.toDataURL()}if(i(this,gs)){const[s,n]=this.pageDimensions,r=Math.round(this.width*s*En.PDF_TO_CSS_UNITS),a=Math.round(this.height*n*En.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(i(this,Rt),0,0,i(this,Rt).width,i(this,Rt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(i(this,Rt))},Gb=function(e){const{pageIndex:s,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===s,a=(e.accessibilityData?.alt||"")===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},R(wp,"_type","stamp"),R(wp,"_editorType",X.STAMP);var Ga,Nl,br,yr,mn,qe,Ar,Ol,Bl,Qs,bn,oe,yn,wr,Hl,U,vr,vt,Ep,zb,ai,Sp,_p,su;const $s=class $s{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){g(this,vt);g(this,Ga);g(this,Nl,!1);g(this,br,null);g(this,yr,null);g(this,mn,null);g(this,qe,new Map);g(this,Ar,!1);g(this,Ol,!1);g(this,Bl,!1);g(this,Qs,null);g(this,bn,null);g(this,oe,null);g(this,yn,null);g(this,wr,null);g(this,Hl,-1);g(this,U);const u=[...i($s,vr).values()];if(!$s._initialized){$s._initialized=!0;for(const p of u)p.initialize(c,t)}t.registerEditorTypes(u),f(this,U,t),this.pageIndex=e,this.div=s,f(this,Ga,r),f(this,br,a),this.viewport=h,f(this,oe,l),this.drawLayer=o,this._structTree=n,i(this,U).addLayer(this)}get isEmpty(){return i(this,qe).size===0}get isInvisible(){return this.isEmpty&&i(this,U).getMode()===X.NONE}updateToolbar(t){i(this,U).updateToolbar(t)}updateMode(t=i(this,U).getMode()){switch(m(this,vt,su).call(this),t){case X.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case X.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case X.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===X.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of i($s,vr).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===i(this,oe)?.div}setEditingState(t){i(this,U).setEditingState(t)}addCommands(t){i(this,U).addCommands(t)}cleanUndoStack(t){i(this,U).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){i(this,br)?.div.classList.toggle("disabled",!t)}async enable(){f(this,Bl,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),i(this,wr)?.abort(),f(this,wr,null);const t=new Set;for(const s of i(this,vt,Ep))s.enableEditing(),s.show(!0),s.annotationElementId&&(i(this,U).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));const e=i(this,br);if(e)for(const s of e.getEditableAnnotations()){if(s.hide(),i(this,U).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const n=await this.deserialize(s);n&&(this.addOrRebuild(n),n.enableEditing())}f(this,Bl,!1),i(this,U)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(f(this,Ol,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),i(this,oe)&&!i(this,wr)){f(this,wr,new AbortController);const s=i(this,U).combinedSignal(i(this,wr));i(this,oe).div.addEventListener("pointerdown",n=>{const{clientX:a,clientY:o,timeStamp:l}=n,h=i(this,Hl);if(l-h>500){f(this,Hl,l);return}
12f(this,Hl,-1);const{classList:c}=this.div;c.toggle("getElements",!0);const u=document.elementsFromPoint(a,o);if(c.toggle("getElements",!1),!this.div.contains(u[0]))return;let p;const b=new RegExp(`^${yh}[0-9]+$`);for(const y of u)if(b.test(y.id)){p=y.id;break}if(!p)return;const A=i(this,qe).get(p);A?.annotationElementId===null&&(n.stopPropagation(),n.preventDefault(),A.dblclick(n))},{signal:s,capture:!0})}const t=i(this,br);if(t){const s=new Map,n=new Map;for(const a of i(this,vt,Ep)){if(a.disableEditing(),!a.annotationElementId){a.updateFakeAnnotationElement(t);continue}if(a.serialize()!==null){s.set(a.annotationElementId,a);continue}else n.set(a.annotationElementId,a);this.getEditableAnnotation(a.annotationElementId)?.show(),a.remove()}const r=t.getEditableAnnotations();for(const a of r){const{id:o}=a.data;if(i(this,U).isDeletedAnnotationElement(o)){a.updateEdited({deleted:!0});continue}let l=n.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=s.get(o),l&&(i(this,U).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}m(this,vt,su).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const s of i($s,vr).values())e.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),f(this,Ol,!1)}getEditableAnnotation(t){return i(this,br)?.getEditableAnnotation(t)||null}setActiveEditor(t){i(this,U).getActive()!==t&&i(this,U).setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,i(this,oe)?.div&&!i(this,yn)){f(this,yn,new AbortController);const t=i(this,U).combinedSignal(i(this,yn));i(this,oe).div.addEventListener("pointerdown",m(this,vt,zb).bind(this),{signal:t}),i(this,oe).div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,i(this,oe)?.div&&i(this,yn)&&(i(this,yn).abort(),f(this,yn,null),i(this,oe).div.classList.remove("highlighting"))}enableClick(){if(i(this,yr))return;f(this,yr,new AbortController);const t=i(this,U).combinedSignal(i(this,yr));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(){i(this,yr)?.abort(),f(this,yr,null)}attach(t){i(this,qe).set(t.id,t);const{annotationElementId:e}=t;e&&i(this,U).isDeletedAnnotationElement(e)&&i(this,U).removeDeletedAnnotationElement(t)}detach(t){i(this,qe).delete(t.id),i(this,Ga)?.removePointerInTextLayer(t.contentDiv),!i(this,Ol)&&t.annotationElementId&&i(this,U).addDeletedAnnotationElement(t)}remove(t){this.detach(t),i(this,U).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(i(this,U).addDeletedAnnotationElement(t.annotationElementId),_t.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),i(this,U).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,U).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!i(this,mn)&&(t._focusEventsAllowed=!1,f(this,mn,setTimeout(()=>{f(this,mn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:i(this,U)._signal}),e.focus())},0))),t._structTreeParentId=i(this,Ga)?.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,qe).values())if(e.uid===t)return e;return null}getNextId(){return i(this,U).getId()}combinedSignal(t){return i(this,U).combinedSignal(t)}canCreateNewEmptyEditor(){return i(this,vt,ai)?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await i(this,U).updateMode(t.mode);const{offsetX:s,offsetY:n}=m(this,vt,_p).call(this),r=this.getNextId(),a=m(this,vt,Sp).call(this,{parent:this,id:r,x:s,y:n,uiManager:i(this,U),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){return await i($s,vr).get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,i(this,U))||null}createAndAddNewEditor(t,e,s={}){const n=this.getNextId(),r=m(this,vt,Sp).call(this,{parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:i(this,U),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(m(this,vt,_p).call(this),!0,t)}setSelected(t){i(this,U).setSelected(t)}toggleSelected(t){i(this,U).toggleSelected(t)}unselect(t){i(this,U).unselect(t)}pointerup(t){const{isMac:e}=le.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!i(this,Ar)||(f
12(this,Ar,!1),i(this,vt,ai)?.isDrawer&&i(this,vt,ai).supportMultipleDrawings))return;if(!i(this,Nl)){f(this,Nl,!0);return}const s=i(this,U).getMode();if(s===X.STAMP||s===X.SIGNATURE){i(this,U).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(i(this,U).getMode()===X.HIGHLIGHT&&this.enableTextSelection(),i(this,Ar)){f(this,Ar,!1);return}const{isMac:e}=le.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(f(this,Ar,!0),i(this,vt,ai)?.isDrawer){this.startDrawingSession(t);return}const s=i(this,U).getActive();f(this,Nl,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),i(this,Qs)){i(this,vt,ai).startDrawing(this,i(this,U),!1,t);return}i(this,U).setCurrentDrawingSession(this),f(this,Qs,new AbortController);const e=i(this,U).combinedSignal(i(this,Qs));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(f(this,bn,null),this.commitOrRemove())},{signal:e}),i(this,vt,ai).startDrawing(this,i(this,U),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&f(this,bn,e);return}i(this,bn)&&setTimeout(()=>{i(this,bn)?.focus(),f(this,bn,null)},0)}endDrawingSession(t=!1){return i(this,Qs)?(i(this,U).setCurrentDrawingSession(null),i(this,Qs).abort(),f(this,Qs,null),f(this,bn,null),i(this,vt,ai).endDrawing(t)):null}findNewParent(t,e,s){const n=i(this,U).findParent(e,s);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return i(this,Qs)?(this.endDrawingSession(),!0):!1}onScaleChanging(){i(this,Qs)&&i(this,vt,ai).onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),i(this,U).getActive()?.parent===this&&(i(this,U).commitOrRemove(),i(this,U).setActiveEditor(null)),i(this,mn)&&(clearTimeout(i(this,mn)),f(this,mn,null));for(const t of i(this,qe).values())i(this,Ga)?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,i(this,qe).clear(),i(this,U).removeLayer(this)}render({viewport:t}){this.viewport=t,Er(this.div,t);for(const e of i(this,U).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){i(this,U).commitOrRemove(),m(this,vt,su).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Er(this.div,{rotation:s}),e!==s)for(const n of i(this,qe).values())n.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return i(this,U).viewParameters.realScale}};Ga=new WeakMap,Nl=new WeakMap,br=new WeakMap,yr=new WeakMap,mn=new WeakMap,qe=new WeakMap,Ar=new WeakMap,Ol=new WeakMap,Bl=new WeakMap,Qs=new WeakMap,bn=new WeakMap,oe=new WeakMap,yn=new WeakMap,wr=new WeakMap,Hl=new WeakMap,U=new WeakMap,vr=new WeakMap,vt=new WeakSet,Ep=function(){return i(this,qe).size!==0?i(this,qe).values():i(this,U).getEditors(this.pageIndex)},zb=function(t){i(this,U).unselectAll();const{target:e}=t;if(e===i(this,oe).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&i(this,oe).div.contains(e)){const{isMac:s}=le.platform;if(t.button!==0||t.ctrlKey&&s)return;i(this,U).showAllEditors("highlight",!0,!0),i(this,oe).div.classList.add("free"),this.toggleDrawing(),du.startHighlighting(this,i(this,U).direction==="ltr",{target:i(this,oe).div,x:t.x,y:t.y}),i(this,oe).div.addEventListener("pointerup",()=>{i(this,oe).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:i(this,U)._signal}),t.preventDefault()}},ai=function(){return i($s,vr).get(i(this,U).getMode())},Sp=function(t){const e=i(this,vt,ai);return e?new e.prototype.constructor(t):null},_p=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,[u,p]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:u,offsetY:p}},su=function(){for(const t of i(this,qe).values())t.isEmpty()&&t.remove()},R($s,"_initialized",!1),g($s,vr,new Map([ip,fp,wp,du,Ap].map(t=>[t._editorType,t])));let fu=$s;var Zs,Ie,za,rd,Lu,Vb,Di,Cp,Wb,Tp;const Jt=class Jt{constructor({pageIndex:t}){g(this,Di);g(this,Zs,null);g(this,Ie,new Map);g(this,za,new Map);this.pageIndex=t}setParent(t){if(!i(this,Zs)){f(this,Zs,t);return}if(i(this,Zs)!==t){if(i(this,Ie).size>0)for(const e of i(this,Ie).values())e.remove(),t.append(e);f(this,Zs,t)}}static get _svgFactory(){return J(this,"_svgFactory",new Ch)}draw(t,e=!1,s=!1){const n=Kt(Jt,rd)._++,r=m(this,Di,Cp).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,za).set(n,o);const h=s?m(this,Di,Wb).call(this,a,l):null,c=Jt._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),i(this,Ie).set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=Kt(Jt,rd)._++,n=m(this,Di,Cp).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 u=Jt._svgFactory.createElement("mask");r.append(u),l=`mask_p${this.pageIndex}_${s}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const p=Jt._svgFactory.createElement("rect");u.append(p),p.setAttribute("width","1"),p.setAttribute("height","1"),p.setAttribute("fill","white");const b=Jt._svgFactory.createElement("use");u.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,Ie).set(s,n),s}finalizeDraw(t,e){i(this,za).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,Ie).get(t):t;if(o){if(s&&m(this,Di,Tp).call(this,o,s),n&&m(l=Jt,Lu,Vb).call(l,o,n),r){const{classList:h}=o;for(const[c,u]of Object.entries(r))h.toggle(c,u)}if(a){const c=o.firstChild.firstChild;m(this,Di,Tp).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=i(this,Ie).get(t);s&&(i(e,Zs).append(s),i(this,Ie).delete(t),i(e,Ie).set(t,s))}remove(t){i(this,za).delete(t),i(this,Zs)!==null&&(i(this,Ie).get(t).remove(),i(this,Ie).delete(t))}destroy(){f(this,Zs,null);for(const t of i(this,Ie).values())t.remove();i(this,Ie).clear(),i(this,za).clear()}};Zs=new WeakMap,Ie=new WeakMap,za=new WeakMap,rd=new WeakMap,Lu=new WeakSet,Vb=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}%`},Di=new WeakSet,Cp=function(){const t=Jt._svgFactory.create(1,1,!0);return i(this,Zs).append(t),t.setAttribute("aria-hidden",!0),t},Wb=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},Tp=function(t,e){for(const[s,n]of Object.entries(e))n===null?t.removeAttribute(s):t.setAttribute(s,n)},g(Jt,Lu),g(Jt,rd,0);let pu=Jt;globalThis._pdfjsTestingUtils={HighlightOutliner:rp};globalThis.pdfjsLib={AbortException:vn,AnnotationEditorLayer:fu,AnnotationEditorParamsType:et,AnnotationEditorType:X,AnnotationEditorUIManager:Sr,AnnotationLayer:jp,AnnotationMode:Ri,AnnotationType:Gt,applyOpacity:Gg,build:Xm,ColorPicker:_h,createValidAbsoluteUrl:kp,CSSConstants:jg,DOMSVGFactory:Ch,DrawLayer:pu,FeatureTest:le,fetchData:Gl,findContrastColor:zg,getDocument:Bp,getFilenameFromUrl:Hg,getPdfFilenameFromUrl:Ug,getRGB:zl,getUuid:Mp,getXfaPageViewport:$g,GlobalWorkerOptions:ti,ImageKind:bh,InvalidPDFException:iu,isDataScheme:hd,isPdfFile:Bu,isValidExplicitDest:Sm,MathClamp:Te,noContextMenu:ws,normalizeUnicode:Og,OPS:Ul,OutputScale:si,PasswordResponses:Fg,PDFDataRangeTransport:Hp,PDFDateString:vh,PDFWorker:$l,PermissionFlag:Ig,PixelsPerInch:En,RenderingCancelledException:Ou,renderRichText:Ip,ResponseException:Ah,setLayerDimensions:Er,shadow:J,SignatureExtractor:Mi,stopEvent:Ft,SupportedImageMimeTypes:nu,TextLayer:Sh,TouchManager:Eh,updateUrlHash:Rp,Util:O,VerbosityLevel:ad,version:Wm,XfaLayer:Lp};const iw=Object.freeze(Object.defineProperty({__proto__:null,AbortException:vn,AnnotationEditorLayer:fu,AnnotationEditorParamsType:et,AnnotationEditorType:X,AnnotationEditorUIManager:Sr,AnnotationLayer:jp,AnnotationMode:Ri,AnnotationType:Gt,CSSConstants:jg,ColorPicker:_h,DOMSVGFactory:Ch,DrawLayer:pu,FeatureTest:le,GlobalWorkerOptions:ti,ImageKind:bh,InvalidPDFException:iu,MathClamp:Te,OPS:Ul,OutputScale:si,PDFDataRangeTransport:Hp,PDFDateString:vh,PDFWorker:$l,PasswordResponses:Fg,PermissionFlag:Ig,PixelsPerInch:En,RenderingCancelledException:Ou,Re
12sponseException:Ah,SignatureExtractor:Mi,SupportedImageMimeTypes:nu,TextLayer:Sh,TouchManager:Eh,Util:O,VerbosityLevel:ad,XfaLayer:Lp,applyOpacity:Gg,build:Xm,createValidAbsoluteUrl:kp,fetchData:Gl,findContrastColor:zg,getDocument:Bp,getFilenameFromUrl:Hg,getPdfFilenameFromUrl:Ug,getRGB:zl,getUuid:Mp,getXfaPageViewport:$g,isDataScheme:hd,isPdfFile:Bu,isValidExplicitDest:Sm,noContextMenu:ws,normalizeUnicode:Og,renderRichText:Ip,setLayerDimensions:Er,shadow:J,stopEvent:Ft,updateUrlHash:Rp,version:Wm},Symbol.toStringTag,{value:"Module"}));var _g=Object.prototype.hasOwnProperty;function Cg(d,t,e){for(e of d.keys())if(uo(e,t))return e}function uo(d,t){var e,s,n;if(d===t)return!0;if(d&&t&&(e=d.constructor)===t.constructor){if(e===Date)return d.getTime()===t.getTime();if(e===RegExp)return d.toString()===t.toString();if(e===Array){if((s=d.length)===t.length)for(;s--&&uo(d[s],t[s]););return s===-1}if(e===Set){if(d.size!==t.size)return!1;for(s of d)if(n=s,n&&typeof n=="object"&&(n=Cg(t,n),!n)||!t.has(n))return!1;return!0}if(e===Map){if(d.size!==t.size)return!1;for(s of d)if(n=s[0],n&&typeof n=="object"&&(n=Cg(t,n),!n)||!uo(s[1],t.get(n)))return!1;return!0}if(e===ArrayBuffer)d=new Uint8Array(d),t=new Uint8Array(t);else if(e===DataView){if((s=d.byteLength)===t.byteLength)for(;s--&&d.getInt8(s)===t.getInt8(s););return s===-1}if(ArrayBuffer.isView(d)){if((s=d.byteLength)===t.byteLength)for(;s--&&d[s]===t[s];);return s===-1}if(!e||typeof d=="object"){s=0;for(e in d)if(_g.call(d,e)&&++s&&!_g.call(t,e)||!(e in t)||!uo(d[e],t[e]))return!1;return Object.keys(t).length===s}}return d!==d&&t!==t}function fd(d){let t=!1;return{promise:new Promise((s,n)=>{d.then(r=>!t&&s(r)).catch(r=>!t&&n(r))}),cancel(){t=!0}}}const nw=["onCopy","onCut","onPaste"],rw=["onCompositionEnd","onCompositionStart","onCompositionUpdate"],aw=["onFocus","onBlur"],ow=["onInput","onInvalid","onReset","onSubmit"],lw=["onLoad","onError"],hw=["onKeyDown","onKeyPress","onKeyUp"],cw=["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],dw=["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],uw=["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],fw=["onSelect"],pw=["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],gw=["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],mw=["onScroll"],bw=["onWheel"],yw=["onAnimationStart","onAnimationEnd","onAnimationIteration"],Aw=["onTransitionEnd"],ww=["onToggle"],vw=["onChange"],Ew=[...nw,...rw,...aw,...ow,...lw,...hw,...cw,...dw,...uw,...fw,...pw,...gw,...mw,...bw,...yw,...Aw,...vw,...ww];function Xb(d,t){const e={};for(const s of Ew){const n=d[s];n&&(t?e[s]=(r=>n(r,t(s))):e[s]=n)}return e}var ef,Tg;function Sw(){if(Tg)return ef;Tg=1;var d=function(){};return ef=d,ef}var _w=Sw();const xe=by(_w),qb=j.createContext(null),Cw="noopener noreferrer nofollow";class Tw{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHash(){}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return wt(this.pdfViewer),this.pdfViewer.currentPageNumber||0}set page(t){wt(this.pdfViewer),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||Cw,t.target=s?"_blank":this.externalLinkTarget||""}goToDestination(t){return new Promise(e=>{wt(this.pdfDocument),wt(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{wt(Array.isArray(e));const s=e[0];new Promise(n=>{wt(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(r=>{n(r)}).catch(()=>{wt(!1)}):typeof s=="number"?n(s):wt(!1)}).then(n=>{const r=n+1;wt(this.pdfViewer),wt(r>=1&&r<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:n,pageNumber:r})})})}goToPage(t){const e=t-1;wt(this.pdfViewer),wt(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}goToXY(){}cachePageRef(){}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}executeNamedAction(){}executeSetOCGState(){}isPageVisible(){return!0}isPageCached(){return!0}navigateTo(t){this.goToDestination(t)}}function fo({children:d,type:t}){return jt.jsx("div",{className:`react-pdf__message react-pdf__message--${t}`,children:d})}const xg={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};function xw(d,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return d}}function jl(){return j.useReducer(xw,{value:void 0,error:void 0})}const $u=typeof window<"u",Yb=$u&&window.location.protocol==="file:";function Pw(d){return typeof d<"u"}function Tr(d){return Pw(d)&&d!==null}
12function kw(d){return typeof d=="string"}function Rw(d){return d instanceof ArrayBuffer}function Mw(d){return wt($u),d instanceof Blob}function xp(d){return kw(d)&&/^data:/.test(d)}function Pg(d){wt(xp(d));const[t="",e=""]=d.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function Dw(){return $u&&window.devicePixelRatio||1}const Kb="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function kg(){xe(!Yb,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${Kb}`)}function Lw(){xe(!Yb,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${Kb}`)}function Wa(d){d?.cancel&&d.cancel()}function Pp(d,t){return Object.defineProperty(d,"width",{get(){return this.getViewport({scale:t}).width},configurable:!0}),Object.defineProperty(d,"height",{get(){return this.getViewport({scale:t}).height},configurable:!0}),Object.defineProperty(d,"originalWidth",{get(){return this.getViewport({scale:1}).width},configurable:!0}),Object.defineProperty(d,"originalHeight",{get(){return this.getViewport({scale:1}).height},configurable:!0}),d}function Jb(d){return d.name==="AbortException"||d.name==="RenderingCancelledException"}function Iw(d){return new Promise((t,e)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return e(new Error("Error while reading a file."));t(s.result)},s.onerror=n=>{if(!n.target)return e(new Error("Error while reading a file."));const{error:r}=n.target;if(!r)return e(new Error("Error while reading a file."));switch(r.code){case r.NOT_FOUND_ERR:return e(new Error("Error while reading a file: File not found."));case r.SECURITY_ERR:return e(new Error("Error while reading a file: Security error."));case r.ABORT_ERR:return e(new Error("Error while reading a file: Aborted."));default:return e(new Error("Error while reading a file."))}},s.readAsArrayBuffer(d)})}const{PDFDataRangeTransport:Fw}=iw,Nw=(d,t)=>{switch(t){case xg.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");d(e);break}case xg.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");d(e);break}}};function Rg(d){return typeof d=="object"&&d!==null&&("data"in d||"range"in d||"url"in d)}const nv=j.forwardRef(function({children:t,className:e,error:s="Failed to load PDF file.",externalLinkRel:n,externalLinkTarget:r,file:a,inputRef:o,imageResourcesPath:l,loading:h="Loading PDFâ¦",noData:c="No PDF file specified.",onItemClick:u,onLoadError:p,onLoadProgress:b,onLoadSuccess:A,onPassword:y=Nw,onSourceError:v,onSourceSuccess:w,options:E,renderMode:S,rotate:_,scale:C,...T},x){const[P,k]=jl(),{value:M,error:D}=P,[V,G]=jl(),{value:$,error:st}=V,I=j.useRef(new Tw),H=j.useRef([]),W=j.useRef(void 0),ot=j.useRef(void 0);a&&a!==W.current&&Rg(a)&&(xe(!uo(a,W.current),`File prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),W.current=a),E&&E!==ot.current&&(xe(!uo(E,ot.current),`Options prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),ot.current=E);const Pe=j.useRef({scrollPageIntoView:xt=>{const{dest:Yt,pageNumber:Dt,pageIndex:ye=Dt-1}=xt;if(u){u({dest:Yt,pageIndex:ye,pageNumber:Dt});return}const Je=H.current[ye];if(Je){Je.scrollIntoView();return}xe(!1,`An internal link leading to page ${Dt} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});j.useImperativeHandle(x,()=>({linkService:I,pages:H,viewer:Pe}),[]);function vs(){w&&w()}function Mt(){D&&(xe(!1,D.toString()),v&&v(D))}function mt(){k({type:"RESET"})}j.useEffect(mt,[a,k]);const Be=j.useCallback(async()=>{if(!a)return null;if(typeof a=="string")return xp(a)?{data:Pg(a)}:(kg(),{url:a});if(a instanceof Fw)return{range:a};if(Rw(a))return{data:a};if($u&&Mw(a))return{data:await Iw(a)};if(wt(typeof a=="object"),wt(Rg(a)),"url"in a&&typeof a.url=="string"){if(xp(a.url)){const{url:xt,...Yt}=a;return{data:Pg(xt),...Yt}}kg()}return a},[a]);j.useEffect(()=>{const xt=fd(Be());return xt.promise.then(Yt=>{k({type:"RESOLVE",value:Yt})}).catch(Yt=>{k({type:"REJECT",error:Yt})}),()=>{Wa(xt)}},[Be,k]),j.useEffect(()=>{if(!(typeof M>"u")){if(M===!1){Mt();return}vs()}},[M]);
12function He(){$&&(A&&A($),H.current=new Array($.numPages),I.current.setDocument($))}function ke(){st&&(xe(!1,st.toString()),p&&p(st))}j.useEffect(function(){G({type:"RESET"})},[G,M]),j.useEffect(function(){if(!M)return;const Yt=E?{...M,...E}:M,Dt=Bp(Yt);b&&(Dt.onProgress=b),y&&(Dt.onPassword=y);const ye=Dt;return ye.promise.then(Je=>{ye.destroyed||G({type:"RESOLVE",value:Je})}).catch(Je=>{ye.destroyed||G({type:"REJECT",error:Je})}),()=>{ye.destroy()}},[E,G,M]),j.useEffect(()=>{if(!(typeof $>"u")){if($===!1){ke();return}He()}},[$]),j.useEffect(function(){I.current.setViewer(Pe.current),I.current.setExternalLinkRel(n),I.current.setExternalLinkTarget(r)},[n,r]);const bt=j.useCallback((xt,Yt)=>{H.current[xt]=Yt},[]),Ke=j.useCallback(xt=>{delete H.current[xt]},[]),Es=j.useMemo(()=>({imageResourcesPath:l,linkService:I.current,onItemClick:u,pdf:$,registerPage:bt,renderMode:S,rotate:_,scale:C,unregisterPage:Ke}),[l,u,$,bt,S,_,C,Ke]),Vl=j.useMemo(()=>Xb(T,()=>$),[T,$]);function Bs(){function xt(Dt){return!!Dt?.pdf}if(!xt(Es))throw new Error("pdf is undefined");const Yt=typeof t=="function"?t(Es):t;return jt.jsx(qb.Provider,{value:Es,children:Yt})}function Ct(){return a?$==null?jt.jsx(fo,{type:"loading",children:typeof h=="function"?h():h}):$===!1?jt.jsx(fo,{type:"error",children:typeof s=="function"?s():s}):Bs():jt.jsx(fo,{type:"no-data",children:typeof c=="function"?c():c})}return jt.jsx("div",{className:Iu("react-pdf__Document",e),ref:o,...Vl,children:Ct()})});function Qb(){return j.useContext(qb)}function Zb(){for(var d=[],t=0;t<arguments.length;t++)d[t]=arguments[t];var e=d.filter(Boolean);if(e.length<=1){var s=e[0];return s||null}return function(r){for(var a=0,o=e;a<o.length;a++){var l=o[a];typeof l=="function"?l(r):l&&(l.current=r)}}}const ty=j.createContext(null);function ju(){return j.useContext(ty)}function Ow(){const d=Qb(),t=ju();wt(t);const e={...d,...t},{filterAnnotations:s,imageResourcesPath:n,linkService:r,onGetAnnotationsError:a,onGetAnnotationsSuccess:o,onRenderAnnotationLayerError:l,onRenderAnnotationLayerSuccess:h,page:c,pdf:u,renderForms:p,rotate:b,scale:A=1}=e;wt(u),wt(c),wt(r);const[y,v]=jl(),{value:w,error:E}=y,S=j.useRef(null);xe(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function _(){w&&o&&o(w)}function C(){E&&(xe(!1,E.toString()),a&&a(E))}j.useEffect(function(){v({type:"RESET"})},[v,c]),j.useEffect(function(){if(!c)return;const M=fd(c.getAnnotations()),D=M;return M.promise.then(V=>{v({type:"RESOLVE",value:V}
12)}).catch(V=>{v({type:"REJECT",error:V})}),()=>{Wa(D)}},[v,c]),j.useEffect(()=>{if(w!==void 0){if(w===!1){C();return}_()}},[w]);function T(){h&&h()}function x(k){xe(!1,`${k}`),l&&l(k)}const P=j.useMemo(()=>c.getViewport({scale:A,rotation:b}),[c,b,A]);return j.useEffect(function(){if(!u||!c||!r||!w)return;const{current:M}=S;if(!M)return;const D=P.clone({dontFlip:!0}),V={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,annotationStorage:u.annotationStorage,commentManager:null,div:M,l10n:null,linkService:r,page:c,structTreeLayer:null,viewport:D},G={annotations:s?s({annotations:w}):w,annotationStorage:u.annotationStorage,div:M,imageResourcesPath:n,linkService:r,page:c,renderForms:p,viewport:D};M.innerHTML="";try{new jp(V).render(G),T()}catch($){x($)}return()=>{}},[w,s,n,r,c,u,p,P]),jt.jsx("div",{className:Iu("react-pdf__Page__annotations","annotationLayer"),ref:S})}const ey={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},Bw=/^H(\d+)$/;function Hw(d){return d in ey}function Gu(d){return"children"in d}function sy(d){return Gu(d)?d.children.length===1&&0 in d.children&&"id"in d.children[0]:!1}function Uw(d){const t={};if(Gu(d)){const{role:e}=d,s=e.match(Bw);if(s)t.role="heading",t["aria-level"]=Number(s[1]);else if(Hw(e)){const n=ey[e];n&&(t.role=n)}}return t}function iy(d){const t={};if(Gu(d)){if(d.alt!==void 0&&(t["aria-label"]=d.alt),d.lang!==void 0&&(t.lang=d.lang),sy(d)){const[e]=d.children;if(e){const s=iy(e);return{...t,...s}}}}else"id"in d&&(t["aria-owns"]=d.id);return t}function $w(d){return d?{...Uw(d),...iy(d)}:null}function ny({className:d,node:t}){const e=j.useMemo(()=>$w(t),[t]),s=j.useMemo(()=>!Gu(t)||sy(t)?null:t.children.map((n,r)=>jt.jsx(ny,{node:n},r)),[t]);return jt.jsx("span",{className:d,...e,children:s})}function jw(){const d=ju();wt(d);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=d,[s,n]=jl(),{value:r,error:a}=s,{customTextRenderer:o,page:l}=d;function h(){r&&e&&e(r)}function c(){a&&(xe(!1,a.toString()),t&&t(a))}return j.useEffect(function(){n({type:"RESET"})},[n,l]),j.useEffect(function(){if(o||!l)return;const p=fd(l.getStructTree()),b=p;return p.promise.then(A=>{n({type:"RESOLVE",value:A})}).catch(A=>{n({type:"REJECT",error:A})}),()=>Wa(b)},[o,l,n]),j.useEffect(()=>{if(r!==void 0){if(r===!1){c();return}h()}},[r]),r?jt.jsx(ny,{className:"react-pdf__Page__structTree structTree",node:r}):null}const Mg=Ri;function Gw(d){const t=ju();wt(t);const e={...t,...d},{_className:s,canvasBackground:n,devicePixelRatio:r=Dw(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:h,renderTextLayer:c,pageColors:u,rotate:p,scale:b}=e,{canvasRef:A}=d;wt(l);const y=j.useRef(null);function v(){l&&o&&o(Pp(l,b))}function w(C){Jb(C)||(xe(!1,C.toString()),a&&a(C))}const E=j.useMemo(()=>l.getViewport({scale:b*r,rotation:p}),[r,l,p,b]),S=j.useMemo(()=>l.getViewport({scale:b,rotation:p}),[l,p,b]);j.useEffect(function(){if(!l)return;l.cleanup();const{current:T}=y;if(!T)return;T.width=E.width,T.height=E.height,T.style.width=`${Math.floor(S.width)}px`,T.style.height=`${Math.floor(S.height)}px`,T.style.visibility="hidden";const x={annotationMode:h?Mg.ENABLE_FORMS:Mg.ENABLE,canvas:T,canvasContext:T.getContext("2d",{alpha:!1}),pageColors:u,viewport:E};n&&(x.background=n);const P=l.render(x),k=P;return P.promise.then(()=>{T.style.visibility="",v()}).catch(w),()=>Wa(k)},[n,l,u,h,E,S]);const _=j.useCallback(()=>{const{current:C}=y;C&&(C.width=0,C.height=0)},[]);return j.useEffect(()=>_,[_]),jt.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:Zb(A,y),style:{display:"block",userSelect:"none"},children:c?jt.jsx(jw,{}):null})}function zw(d){return"str"in d}const Vw=new Set(["base","embed","iframe","link","meta","object","script","style","template"]),Ww=new Set(["action","formaction","href","poster","src","xlink:href"]);function Xw(d){let t="";for(const e of d){const s=e.charCodeAt(0);s<=32||s===127||(t+=e.toLowerCase())}return t.startsWith("javascript:")||t.startsWith("vbscript:")}function qw(d){return d.nodeType===Node.ELEMENT_NODE}function ry(d){return qw(d)&&d instanceof HTMLElement}function Yw(d){return ry(d)&&Vw.has(d.tagName.toLowerCase())}function Kw(d){const t=document.createElement(d.tagName.toLowerCase());
12return Array.from(d.attributes).forEach(e=>{const s=e.name.toLowerCase();s.startsWith("on")||s==="srcdoc"||Ww.has(s)&&Xw(e.value)||t.setAttribute(e.name,e.value)}),Array.from(d.childNodes).forEach(e=>{t.append(ay(e))}),t}function ay(d){var t;return ry(d)&&!Yw(d)?Kw(d):document.createTextNode((t=d.textContent)!==null&&t!==void 0?t:"")}function Jw(d,t){const e=document.createElement("template");e.innerHTML=t;const s=document.createDocumentFragment();Array.from(e.content.childNodes).forEach(n=>{s.append(ay(n))}),d.replaceChildren(s)}function Qw(){const d=ju();wt(d);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:n,onRenderTextLayerSuccess:r,page:a,pageIndex:o,pageNumber:l,rotate:h,scale:c}=d;wt(a);const[u,p]=jl(),{value:b,error:A}=u,y=j.useRef(null);xe(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function v(){b&&s&&s(b)}function w(){A&&(xe(!1,A.toString()),e&&e(A))}j.useEffect(function(){p({type:"RESET"})},[a,p]),j.useEffect(function(){if(!a)return;const P=fd(a.getTextContent()),k=P;return P.promise.then(M=>{p({type:"RESOLVE",value:M})}).catch(M=>{p({type:"REJECT",error:M})}),()=>Wa(k)},[a,p]),j.useEffect(()=>{if(b!==void 0){if(b===!1){w();return}v()}},[b]);const E=j.useCallback(()=>{r&&r()},[r]),S=j.useCallback(x=>{Jb(x)||(xe(!1,x.toString()),n&&n(x))},[n]);function _(){const x=y.current;x&&x.classList.add("selecting")}function C(){const x=y.current;x&&x.classList.remove("selecting")}const T=j.useMemo(()=>a.getViewport({scale:c,rotation:h}),[a,h,c]);return j.useLayoutEffect(function(){if(!a||!b)return;const{current:P}=y;if(!P)return;P.innerHTML="";const k=a.streamTextContent({includeMarkedContent:!0}),M={container:P,textContentSource:k,viewport:T},D=new Sh(M),V=D;return D.render().then(()=>{const G=document.createElement("div");G.className="endOfContent",P.append(G);const $=P.querySelectorAll('[role="presentation"]');if(t){let st=0;b.items.forEach((I,H)=>{if(!zw(I))return;const W=$[st];if(!W)return;const ot=t({pageIndex:o,pageNumber:l,itemIndex:H,...I});Jw(W,ot),st+=I.str&&I.hasEOL?2:1})}E()}).catch(S),()=>Wa(V)},[t,S,E,a,o,l,b,T]),jt.jsx("div",{className:Iu("react-pdf__Page__textContent","textLayer"),onMouseUp:C,onMouseDown:_,ref:y})}const Dg=1;function rv(d){const e={...Qb(),...d},{_className:s="react-pdf__Page",_enableRegisterUnregisterPage:n=!0,canvasBackground:r,canvasRef:a,children:o,className:l,customRenderer:h,customTextRenderer:c,devicePixelRatio:u,error:p="Failed to load the page.",filterAnnotations:b,height:A,inputRef:y,loading:v="Loading pageâ¦",noData:w="No page specified.",onGetAnnotationsError:E,onGetAnnotationsSuccess:S,onGetStructTreeError:_,onGetStructTreeSuccess:C,onGetTextError:T,onGetTextSuccess:x,onLoadError:P,onLoadSuccess:k,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:D,onRenderError:V,onRenderSuccess:G,onRenderTextLayerError:$,onRenderTextLayerSuccess:st,pageColors:I,pageIndex:H,pageNumber:W,pdf:ot,registerPage:Pe,renderAnnotationLayer:vs=!0,renderForms:Mt=!1,renderMode:mt="canvas",renderTextLayer:Be=!0,rotate:He,scale:ke=Dg,unregisterPage:bt,width:Ke,...Es}=e,[Vl,Bs]=jl(),{value:Ct,error:xt}=Vl,Yt=j.useRef(null);wt(ot);const Dt=Tr(W)?W-1:H??null,ye=W??(Tr(H)?H+1:null),Je=He??(Ct?Ct.rotate:null),Hs=j.useMemo(()=>{if(!Ct)return null;let Cn=1;const Ya=ke??Dg;if(Ke||A){const Tn=Ct.getViewport({scale:1,rotation:Je});Ke?Cn=Ke/Tn.width:A&&(Cn=A/Tn.height)}return Ya*Cn},[A,Ct,Je,ke,Ke]);j.useEffect(function(){return()=>{Tr(Dt)&&n&&bt&&bt(Dt)}},[n,ot,Dt,bt]);function oy(){if(k){if(!Ct||!Hs)return;k(Pp(Ct,Hs))}if(n&&Pe){if(!Tr(Dt)||!Yt.current)return;Pe(Dt,Yt.current)}}function ly(){xt&&(xe(!1,xt.toString()),P&&P(xt))}j.useEffect(function(){Bs({type:"RESET"})},[Bs,ot,Dt]),j.useEffect(function(){if(!ot||!ye)return;const Ya=fd(ot.getPage(ye)),Tn=Ya;return Ya.promise.then(Vu=>{Bs({type:"RESOLVE",value:Vu})}).catch(Vu=>{Bs({type:"REJECT",error:Vu})}),()=>Wa(Tn)},[Bs,ot,ye]),j.useEffect(()=>{if(Ct!==void 0){if(Ct===!1){ly();return}oy()}},[Ct,Hs]);const zu=j.useMemo(()=>
12Tr(Dt)&&ye&&Tr(Je)&&Tr(Hs)?{_className:s,canvasBackground:r,customTextRenderer:c,devicePixelRatio:u,filterAnnotations:b,onGetAnnotationsError:E,onGetAnnotationsSuccess:S,onGetStructTreeError:_,onGetStructTreeSuccess:C,onGetTextError:T,onGetTextSuccess:x,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:D,onRenderError:V,onRenderSuccess:G,onRenderTextLayerError:$,onRenderTextLayerSuccess:st,page:Ct,pageColors:I,pageIndex:Dt,pageNumber:ye,renderForms:Mt,renderTextLayer:Be,rotate:Je,scale:Hs}:null,[s,r,c,u,b,E,S,_,C,T,x,M,D,V,G,$,st,Ct,I,Dt,ye,Mt,Be,Je,Hs]),hy=j.useMemo(()=>Xb(Es,()=>Ct&&(Hs?Pp(Ct,Hs):void 0)),[Es,Ct,Hs]),pd=`${Dt}@${Hs}/${Je}`;function cy(){switch(mt){case"custom":return wt(h),jt.jsx(h,{},`${pd}_custom`);case"none":return null;case"canvas":default:return jt.jsx(Gw,{canvasRef:a},`${pd}_canvas`)}}function dy(){return Be?jt.jsx(Qw,{},`${pd}_text`):null}function uy(){return vs?jt.jsx(Ow,{},`${pd}_annotations`):null}function fy(){function Cn(Tn){return!!Tn?.page}if(!Cn(zu))throw new Error("page is undefined");const Ya=typeof o=="function"?o(zu):o;return jt.jsxs(ty.Provider,{value:zu,children:[cy(),dy(),uy(),Ya]})}function py(){return ye?ot===null||Ct===void 0||Ct===null?jt.jsx(fo,{type:"loading",children:typeof v=="function"?v():v}):ot===!1||Ct===!1?jt.jsx(fo,{type:"error",children:typeof p=="function"?p():p}):fy():jt.jsx(fo,{type:"no-data",children:typeof w=="function"?w():w})}return jt.jsx("div",{className:Iu(s,l),"data-page-number":ye,ref:Zb(y,Yt),style:{"--scale-round-x":"1px","--scale-round-y":"1px","--scale-factor":"1","--user-unit":`${Hs}`,"--total-scale-factor":"calc(var(--scale-factor) * var(--user-unit))",backgroundColor:r||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"},...hy,children:py()})}Lw();ti.workerSrc="pdf.worker.mjs";export{nv as D,ti as G,rv 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.