PageSourceSearch

https://jgmarketingdesign.com/assets/pdf-BBO_BrAh.js

js jgmarketingdesign.com collected 2026-10-07 00:45:18 UTC 458,485 bytes, 55 lines download raw bytes

1var uy=Object.defineProperty;var dg=u=>{throw TypeError(u)};var fy=(u,t,e)=>t in u?uy(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var x=(u,t,e)=>fy(u,typeof t!="symbol"?t+"":t,e),hf=(u,t,e)=>t.has(u)||dg("Cannot "+e);var i=(u,t,e)=>(hf(u,t,"read from private field"),e?e.call(u):t.get(u)),g=(u,t,e)=>t.has(u)?dg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),f=(u,t,e,s)=>(hf(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),b=(u,t,e)=>(hf(u,t,"access private method"),e);var $t=(u,t,e,s)=>({set _(n){f(u,t,n,e)},get _(){return i(u,t,s)}});const ps=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),An=[1/0,1/0,-1/0,-1/0],Ir=new Float32Array(An),mf=[.001,0,0,.001,0,0],cf=1.35,fs={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},xn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},_h="pdfjs_internal_editor_",G={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},V={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},py={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Yt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Td={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},jt={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},oo={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Wu={ERRORS:0,WARNINGS:1,INFOS:5},Ri={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},Yl={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},gy={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Xu=Wu.WARNINGS;function my(u){Number.isInteger(u)&&(Xu=u)}function by(){return Xu}function Yu(u){Xu>=Wu.INFOS&&console.info(`Info: ${u}`)}function j(u){Xu>=Wu.WARNINGS&&console.warn(`Warning: ${u}`)}function nt(u){throw new Error(u)}function kt(u,t){u||nt(t)}function yy(u){switch(u==null?void 0:u.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function $g(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"){if(e.addDefaultProtocol&&u.startsWith("www.")){const n=u.match(/\./g);(n==null?void 0:n.length)>=2&&(u=`http://${u}`)}if(e.tryConvertEncoding)try{u=Sy(u)}catch{}}const s=t?URL.parse(u,t):URL.parse(u);return yy(s)?s:null}function zg(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&$g(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function bf(u){return u.substring(u.lastIndexOf("/")+1)}function $(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const no=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class ug extends no{constructor(t,e){super(t,"PasswordException"),this.code=e}}class df extends no{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class yf extends no{constructor(t){super(t,"InvalidPDFException")}}class cu extends no{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class Ay extends no{constructor(t){super(t,"FormatError")}}class Sr extends no{constructor(t){super(t,"AbortException")}}function wy(u){(typeof u!="object"||(u==null?void 0:u.length)===void 0)&&nt("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let n=0;n<t;n+=e){const r=Math.min(n+e,t),a=u.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}
1function Ku(u){typeof u!="string"&&nt("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=u.charCodeAt(s)&255;return e}function vy(){const u=new Uint8Array(4);return u[0]=1,new Uint32Array(u.buffer,0,1)[0]===1}class Wt{static get isLittleEndian(){return $(this,"isLittleEndian",vy())}static get isOffscreenCanvasSupported(){return $(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return $(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return $(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return $(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return $(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){var t,e;return $(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}static get isAlphaColorInputSupported(){return $(this,"isAlphaColorInputSupported",(()=>{if(typeof document>"u")return!1;const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",t.value!=="#ff0000"})())}}var wn,xd,Af;class M{static get hexNums(){return $(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const n=t[s],r=t[s+1];t[s]=n*e[0]+r*e[2]+e[4],t[s+1]=n*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const n=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5];for(let c=0;c<6;c+=2){const d=t[s+c],p=t[s+c+1];t[s+c]=d*n+p*a+l,t[s+c+1]=d*r+p*o+h}}static applyInverseTransform(t,e){const s=t[0],n=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const n=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5],c=t[0],d=t[1],p=t[2],m=t[3];let y=n*c+l,A=y,v=n*p+l,w=v,S=o*d+h,E=S,_=o*m+h,C=_;if(r!==0||a!==0){const T=r*c,P=r*p,D=a*d,k=a*m;y+=D,w+=D,v+=k,A+=k,S+=T,C+=T,_+=P,E+=P}s[0]=Math.min(s[0],y,v,A,w),s[1]=Math.min(s[1],S,_,E,C),s[2]=Math.max(s[2],y,v,A,w),s[3]=Math.max(s[3],S,_,E,C)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],n=t[1],r=t[2],a=t[3],o=s**2+n**2,l=s*r+n*a,h=r**2+a**2,c=(o+h)/2,d=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>n)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,n,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,n,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,n),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,n)}static bezierBoundingBox(t,e,s,n,r,a,o,l,h){h[0]=Math.min(h[0],t,o),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,o),h[3]=Math.max(h[3],e,l),b(this,wn,Af).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),b(this,wn,Af).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)}}wn=new WeakSet,xd=function(t,e,s,n,r,a,o,l,h,c){if(h<=0||h>=1)return;
1const d=1-h,p=h*h,m=p*h,y=d*(d*(d*t+3*h*e)+3*p*s)+m*n,A=d*(d*(d*r+3*h*a)+3*p*o)+m*l;c[0]=Math.min(c[0],y),c[1]=Math.min(c[1],A),c[2]=Math.max(c[2],y),c[3]=Math.max(c[3],A)},Af=function(t,e,s,n,r,a,o,l,h,c,d,p){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,wn,xd).call(this,t,e,s,n,r,a,o,l,-d/c,p);return}const m=c**2-4*d*h;if(m<0)return;const y=Math.sqrt(m),A=2*h;b(this,wn,xd).call(this,t,e,s,n,r,a,o,l,(-c+y)/A,p),b(this,wn,xd).call(this,t,e,s,n,r,a,o,l,(-c-y)/A,p)},g(M,wn);function Sy(u){return decodeURIComponent(escape(u))}let uf=null,fg=null;function Ey(u){return uf||(uf=/([\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,fg=new Map([["ſt","ſt"]])),u.replaceAll(uf,(t,e,s)=>e?e.normalize("NFKC"):fg.get(s))}function jg(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),wy(u)}const bo="pdfjs_internal_id_";function _y(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,n,...r]=e;if(!u(s)&&!Number.isInteger(s)||!t(n))return!1;const a=r.length;let o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}const Vp=()=>[],Wp=()=>new Map,wf=()=>Object.create(null);function Ct(u,t,e){return Math.min(Math.max(u,t),e)}class Ch{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function n(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(Ch.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const h of r.children)n(h)}return n(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class Vg{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:Object.hasOwn(o.attributes,"selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;n.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:n,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${n}`);for(const[l,h]of Object.entries(a))if(h!=null)switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,p;const e=t.annotationStorage,s=t.linkService,n=t.xfaHtml,r=t.intent||"display",a=document.createElement(n.name);n.attributes&&this.setAttributes({html:a,element:n,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const m=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=m}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];
1if(n.children.length===0){if(n.value){const m=document.createTextNode(n.value);a.append(m),o&&Ch.shouldBuildText(n.name)&&h.push(m)}return{textDivs:h}}const c=[[n,-1,a]];for(;c.length>0;){const[m,y,A]=c.at(-1);if(y+1===m.children.length){c.pop();continue}const v=m.children[++c.at(-1)[1]];if(v===null)continue;const{name:w}=v;if(w==="#text"){const E=document.createTextNode(v.value);h.push(E),A.append(E);continue}const S=(d=v==null?void 0:v.attributes)!=null&&d.xmlns?document.createElementNS(v.attributes.xmlns,w):document.createElement(w);if(A.append(S),v.attributes&&this.setAttributes({html:S,element:v,storage:e,intent:r,linkService:s}),((p=v.children)==null?void 0:p.length)>0)c.push([v,-1,S]);else if(v.value){const E=document.createTextNode(v.value);o&&Ch.shouldBuildText(w)&&h.push(E),S.append(E)}}for(const m of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))m.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 ki="http://www.w3.org/2000/svg",kr=class kr{};x(kr,"CSS",96),x(kr,"PDF",72),x(kr,"PDF_TO_CSS_UNITS",kr.CSS/kr.PDF);let Er=kr;async function Xp(u,t="text"){if(wh(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const n=new XMLHttpRequest;n.open("GET",u,!0),n.responseType=t==="bytes"?"arraybuffer":t,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE){if(n.status===200||n.status===0){switch(t){case"bytes":e(new Uint8Array(n.response));return;case"blob":case"json":e(n.response);return}e(n.responseText);return}s(new Error(n.statusText))}},n.send(null)})}class pd{constructor({viewBox:t,userUnit:e,scale:s,rotation:n,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=n,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,d,p,m;switch(n%=360,n<0&&(n+=360),n){case 180:c=-1,d=0,p=0,m=1;break;case 90:c=0,d=1,p=1,m=0;break;case 270:c=0,d=-1,p=-1,m=0;break;case 0:c=1,d=0,p=0,m=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(p=-p,m=-m);let y,A,v,w;c===0?(y=Math.abs(h-t[1])*s+r,A=Math.abs(l-t[0])*s+a,v=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(y=Math.abs(l-t[0])*s+r,A=Math.abs(h-t[1])*s+a,v=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,d*s,p*s,m*s,y-c*s*l-p*s*h,A-d*s*l-m*s*h],this.width=v,this.height=w}get rawDims(){const t=this.viewBox;return $(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 pd({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 M.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];M.applyTransform(e,this.transform);const s=[t[2],t[3]];return M.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return M.applyInverseTransform(s,this.transform),s}}class Yp extends no{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function qu(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function Kp(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function Cy(u){return[u]=u.split(/[#?]/,1),bf(u)}function Ty(u,t="document.pdf"){if(typeof u!="string")return t;if(qu(u))return j('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{try{return new URL(decodeURIComponent(o))}catch{try{return new URL(o,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{return null}}}}})(u);if(!s)return t;const n=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=bf(l),/^\.pdf$/i.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=bf(s.pathname);if(r.test(a))return n(a);if(s.searchParams.size>0){const o=h=>[...h].findLast(c=>r.test(c)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return n(l)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return n(l[0])}return t}var Pn;class pg{constructor(){g(this,Pn,new Map);x(this,"times",[])}time(t){i(this,Pn).has(t)&&j(`Timer is already running for ${t}`),i(this,Pn).set(t,Date.now())}timeEnd(t){i(this,Pn).has(t)||j(`Timer has not been started for ${t}`),this.times.push({name:t,start:i(this,Pn).get(t),end:Date.now()}),i(this,Pn).delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}
1ms
2`).join("")}}Pn=new WeakMap;function wh(u,t){const e=t?URL.parse(u,t):URL.parse(u);return/https?:/.test((e==null?void 0:e.protocol)??"")}function Fs(u){u.preventDefault()}function Pt(u){u.preventDefault(),u.stopPropagation()}function xy(u){console.log("Deprecated API usage: "+u)}var Mh;class du{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;i(this,Mh)||f(this,Mh,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=i(this,Mh).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 d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(a+=c,o+=d):h==="+"&&(a-=c,o-=d),new Date(Date.UTC(s,n,r,a,o,l))}}Mh=new WeakMap,g(du,Mh);function Py(u,{scale:t=1,rotation:e=0}){const{width:s,height:n}=u.attributes.style,r=[0,0,parseInt(s,10),parseInt(n,10)];return new pd({viewBox:r,userUnit:1,scale:t,rotation:e})}function qp(u){if(u.startsWith("#")){const e=u.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(u.startsWith("rgb(")){const[e,s,n]=u.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,n,1]}if(u.startsWith("rgba(")){const e=u.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=u.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function gd(u){const t=qp(u);return t?t.slice(0,3):(j(`Not a valid color format: "${u}"`),[0,0,0])}function ky(u){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of u.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;u.set(e,gd(s))}t.remove()}function vt(u){const{a:t,b:e,c:s,d:n,e:r,f:a}=u.getTransform();return[t,e,s,n,r,a]}function ei(u){const{a:t,b:e,c:s,d:n,e:r,f:a}=u.getTransform().invertSelf();return[t,e,s,n,r,a]}function eo(u,t,e=!1,s=!0){if(t instanceof pd){const{pageWidth:n,pageHeight:r}=t.rawDims,{style:a}=u,o=Wt.isCSSRoundSupported,l=`var(--total-scale-factor) * ${n}px`,h=`var(--total-scale-factor) * ${r}px`,c=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,d=o?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=c,a.height=d):(a.width=d,a.height=c)}s&&u.setAttribute("data-main-rotation",t.rotation)}class Ti{constructor(){const{pixelRatio:t}=Ti;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=Ti.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),n!==-1&&(o=n/t,l=n/e);const h=Math.min(a,o,l);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const vf=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class My{static get isDarkMode(){var t;return $(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class Dy{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(),$(this,"commentForegroundColor",gd(s))}}function Iy(u,t){t=Ct(t??1,0,1);const e=255*(1-t);return u.map(s=>Math.round(s*t+e))}function gg(u,t){const e=u[0]/255,s=u[1]/255,n=u[2]/255,r=Math.max(e,s,n),a=Math.min(e,s,n),o=(r+a)/2;if(r===a)t[0]=t[1]=0;else{const l=r-a;switch(t[1]=o<.5?l/(r+a):l/(2-r-a),r){case e:t[0]=((s-n)/l+(s<n?6:0))*60;break;case s:t[0]=((n-e)/l+2)*60;break;case n:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function Sf(u,t){const e=u[0],s=u[1],n=u[2],r=(1-Math.abs(2*n-1))*s,a=r*(1-Math.abs(e/60%2-1)),o=n-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+o,t[1]=a+o,t[2]=o;break;case 1:t[0]=a+o,t[1]=r+o,t[2]=o;break;case 2:t[0]=o,t[1]=r+o,t[2]=a+o;break;case 3:t[0]=o,t[1]=a+o,t[2]=r+o;break;case 4:t[0]=a+o,t[1]=o,t[2]=r+o;break;
2case 5:case 6:t[0]=r+o,t[1]=o,t[2]=a+o;break}}function mg(u){return u<=.03928?u/12.92:((u+.055)/1.055)**2.4}function bg(u,t,e){Sf(u,e),e.map(mg);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Sf(t,e),e.map(mg);const n=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const yg=new Map;function Ly(u,t){const e=u[0]+u[1]*256+u[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=yg.get(e);if(s)return s;const n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);gg(u,a);const o=n.subarray(6,9);gg(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]),bg(a,o,r)<h){let c,d;l?(c=a[2],d=1):(c=0,d=a[2]);const p=.005;for(;d-c>p;){const m=a[2]=(c+d)/2;l===bg(a,o,r)<h?c=m:d=m}a[2]=l?d:c}return Sf(a,r),s=M.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),yg.set(e,s),s}function Wg({html:u,dir:t,className:e},s){const n=document.createDocumentFragment();if(typeof u=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=u.split(/(?:\r\n?|\n)/);for(let o=0,l=a.length;o<l;++o){const h=a[o];r.append(document.createTextNode(h)),o<l-1&&r.append(document.createElement("br"))}n.append(r)}else Vg.render({xfaHtml:u,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",e),s.append(n)}function Xg(u){const t=new Path2D;if(!u)return t;for(let e=0,s=u.length;e<s;)switch(u[e++]){case Yl.moveTo:t.moveTo(u[e++],u[e++]);break;case Yl.lineTo:t.lineTo(u[e++],u[e++]);break;case Yl.curveTo:t.bezierCurveTo(u[e++],u[e++],u[e++],u[e++],u[e++],u[e++]);break;case Yl.quadraticCurveTo:t.quadraticCurveTo(u[e++],u[e++],u[e++],u[e++]);break;case Yl.closePath:t.closePath();break;default:j(`Unrecognized drawing path operator: ${u[e-1]}`);break}return t}var kn,Mn,ws,vs,Dh,Dn,vo,So,Ih,wu,Yg,ge,Kg,qg,lo,Jl;const Ii=class Ii{constructor(t){g(this,ge);g(this,kn,null);g(this,Mn,null);g(this,ws);g(this,vs,null);g(this,Dh,null);g(this,Dn,null);g(this,vo,null);g(this,So,null);f(this,ws,t),i(Ii,Ih)||f(Ii,Ih,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,kn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=i(this,ws)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Fs,{signal:e}),t.addEventListener("pointerdown",b(Ii,wu,Yg),{signal:e}));const s=f(this,vs,document.createElement("div"));s.className="buttons",t.append(s);const n=i(this,ws).toolbarPosition;if(n){const{style:r}=t,a=i(this,ws)._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,kn)}hide(){var t;i(this,kn).classList.add("hidden"),(t=i(this,Mn))==null||t.hideDropdown()}show(){var t,e;i(this,kn).classList.remove("hidden"),(t=i(this,Dh))==null||t.shown(),(e=i(this,Dn))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=i(this,ws),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",i(Ii,Ih)[t]),b(this,ge,lo).call(this,s)&&s.addEventListener("click",n=>{e.delete()},{signal:e._signal}),i(this,vs).append(s)}async addAltText(t){const e=await t.render();b(this,ge,lo).call(this,e),i(this,vs).append(e,i(this,ge,Jl)),f(this,Dh,t)}addComment(t,e=null){if(i(this,Dn))return;const s=t.renderForToolbar();if(!s)return;b(this,ge,lo).call(this,s);const n=f(this,vo,i(this,ge,Jl));e?(i(this,vs).insertBefore(s,e),i(this,vs).insertBefore(n,e)):i(this,vs).append(s,n),f(this,Dn,t),t.toolbar=this}addColorPicker(t){if(i(this,Mn))return;f(this,Mn,t);const e=t.renderButton();b(this,ge,lo).call(this,e),i(this,vs).append(e,i(this,ge,Jl))}async addEditSignatureButton(t){const e=f(this,So,await t.renderEditButton(i(this,ws)));b(this,ge,lo).call(this,e),i(this,vs).append(e,i(this,ge,Jl))}removeButton(t){var e,s;switch(t){case"comment":(e=i(this,Dn))==null||e.removeToolbarCommentButton(),f(this,Dn,null),(s=i(this,vo))==null||s.remove(),f(this,vo,null);break}}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;const n=i(this,vs).querySelector(s);n&&t==="comment"&&this.addComment(e,n)}updateEditSignatureButton(t){i(this,So)&&(i(this,So).title=t)}remove(){var t;i(this,kn).remove(),(t=i(this,Mn))==null||t.destroy(),f(this,Mn,null)}};kn=new WeakMap,Mn=new WeakMap,ws=new WeakMap,vs=new WeakMap,Dh=new WeakMap,Dn=new WeakMap,vo=new WeakMap,So=new WeakMap,Ih=new WeakMap,wu=new WeakSet,Yg=function(t){t.stopPropagation()},ge=new WeakSet,Kg=function(t){i(this,ws)._focusEventsAllowed=!1,Pt(t)},qg=function(t){i(this,ws)._focusEventsAllowed=!0,Pt(t)},lo=function(t){const e=i(this,ws)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,ge,Kg).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,ge,qg).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Fs,{signal:e}),!0)},Jl=function(){const t=document.createElement("div");return t.className="divider",t},g(Ii,wu),g(Ii,Ih,null);let Ef=Ii;var Lh,Lr,Fi,En,Qg,Jg,_f;class Ry{constructor(t){g(this,En);g(this,Lh,null);g(this,Lr,null);g(this,Fi);f(this,Fi,t)}show(t,e,s){const[n,r]=b(this,En,Jg).call(this,e,s),{style:a}=i(this,Lr)||f(this,Lr,b(this,En,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()}}Lh=new WeakMap,Lr=new WeakMap,Fi=new WeakMap,En=new WeakSet,Qg=function(){const t=f(this,Lr,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=i(this,Fi)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Fs,{signal:e});const s=f(this,Lh,document.createElement("div"));return s.className="buttons",t.append(s),i(this,Fi).hasCommentManager()&&b(this,En,_f).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{i(this,Fi).commentSelection("floating_button")}),b(this,En,_f).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{i(this,Fi).highlightSelection("floating_button")}),t},Jg=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]},_f=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,Fi)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",Fs,{signal:o}),r.addEventListener("click",n,{signal:o})),i(this,Lh).append(r)};function Zg(u,t,e){for(const s of e)t.addEventListener(s,u[s].bind(u))}
2var Rr,Fr,Eo,Or;const ct=class ct{static initializeAndAddPointerId(t){(i(ct,Fr)||f(ct,Fr,new Set)).add(t)}static setPointer(t,e){i(ct,Rr)||f(ct,Rr,e),i(ct,Or)??f(ct,Or,t)}static setTimeStamp(t){f(ct,Eo,t)}static isSamePointerId(t){return i(ct,Rr)===t}static isSamePointerIdOrRemove(t){var e;return i(ct,Rr)===t?!0:((e=i(ct,Fr))==null||e.delete(t),!1)}static isSamePointerType(t){return i(ct,Or)===t}static isInitializedAndDifferentPointerType(t){return i(ct,Or)!==null&&!ct.isSamePointerType(t)}static isSameTimeStamp(t){return i(ct,Eo)===t}static isUsingMultiplePointers(){var t;return((t=i(ct,Fr))==null?void 0:t.size)>=1}static clearPointerType(){f(ct,Or,null)}static clearPointerIds(){f(ct,Rr,NaN),f(ct,Fr,null)}static clearTimeStamp(){f(ct,Eo,NaN)}};Rr=new WeakMap,Fr=new WeakMap,Eo=new WeakMap,Or=new WeakMap,g(ct,Rr,NaN),g(ct,Fr,null),g(ct,Eo,NaN),g(ct,Or,null);let Ae=ct;var vu;class Fy{constructor(){g(this,vu,0)}get id(){return`${_h}${$t(this,vu)._++}`}}vu=new WeakMap;var _o,Rh,we,Co,Pd;const ig=class ig{constructor(){g(this,Co);g(this,_o,jg());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(()=>(s.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return $(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:n,type:r}=t;return b(this,Co,Pd).call(this,`${e}_${s}_${n}_${r}`,t)}async getFromUrl(t){return b(this,Co,Pd).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,Co,Pd).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!=null&&s.bitmap)return s.refCounter+=1,s;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),s={bitmap:n.transferToImageBitmap(),id:`image_${i(this,_o)}_${$t(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!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var n;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 r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(n=s.close)==null||n.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${i(this,_o)}_`)}};_o=new WeakMap,Rh=new WeakMap,we=new WeakMap,Co=new WeakSet,Pd=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!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${i(this,_o)}_${$t(this,Rh)._++}`,refCounter:0,isSvg:!1});let n;if(typeof e=="string"?(s.url=e,n=await Xp(e,"blob")):e instanceof File?n=s.file=e:e instanceof Blob&&(n=e),n.type==="image/svg+xml"){const r=ig._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const d=s.svgUrl=a.result;o.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=a.onerror=c});a.readAsDataURL(n),await l}else s.bitmap=await createImageBitmap(n);s.refCounter=1}catch(n){j(n),s=null}return i(this,we).set(t,s),s&&i(this,we).set(s.id,s),s};let Cf=ig;var Bt,In,Fh,Tt;class Oy{constructor(t=128){g(this,Bt,[]);g(this,In,!1);g(this,Fh);g(this,Tt,-1);f(this,Fh,t)}add({cmd:t,undo:e,post:s,mustExec:n,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(n&&t(),i(this,In))return;const l={cmd:t,undo:e,post:s,type:r};if(i(this,Tt)===-1){i(this,Bt).length>0&&(i(this,Bt).length=0),f(this,Tt,0),i(this,Bt).push(l);return}if(a&&i(this,Bt)[i(this,Tt)].type===r){o&&(l.undo=i(this,Bt)[i(this,Tt)].undo),i(this,Bt)[i(this,Tt)]=l;return}const h=i(this,Tt)+1;h===i(this,Fh)?i(this,Bt).splice(0,1):(f(this,Tt,h),h<i(this,Bt).length&&i(this,Bt).splice(h)),i(this,Bt).push(l)}undo(){if(i(this,Tt)===-1)return;f(this,In,!0);const{undo:t,post:e}=i(this,Bt)[i(this,Tt)];t(),e==null||e(),f(this,In,!1),f(this,Tt,i(this,Tt)-1)}redo(){if(i(this,Tt)<i(this,Bt).length-1){f(this,Tt,i(this,Tt)+1),f(this,In,!0);const{cmd:t,post:e}=i(this,Bt)[i(this,Tt)];t(),e==null||e(),f(this,In,!1)}}hasSomethingToUndo(){return i(this,Tt)!==-1}hasSomethingToRedo(){return i(this,Tt)<i(this,Bt).length-1}cleanType(t){if(i(this,Tt)!==-1){for(let e=i(this,Tt);e>=0;e--)if(i(this,Bt)[e].type!==t){i(this,Bt).splice(e+1,i(this,Tt)-e),f(this,Tt,e);return}i(this,Bt).length=0,f(this,Tt,-1)}}destroy(){f(this,Bt,null)}}Bt=new WeakMap,In=new WeakMap,Fh=new WeakMap,Tt=new WeakMap;var Su,tm;class md{constructor(t){g(this,Su);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Wt.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(b(this,Su,tm).call(this,e));if(!s)return;const{callback:n,options:{bubbles:r=!1,args:a=[],checker:o=null}}=s;o&&!o(t,e)||(n.bind(t,...a,e)(),r||Pt(e))}}Su=new WeakSet,tm=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 Eu=class Eu{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return ky(t),$(this,"_colors",t)}convert(t){const e=gd(t);
2if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,n]of this._colors)if(n.every((r,a)=>r===e[a]))return Eu._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?M.makeHexColor(...e):t}};x(Eu,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Tf=Eu;var To,qe,xo,Lt,xt,Po,ko,ke,Mo,Ss,Jt,Ln,Rn,Fn,On,ni,Es,Nr,Oh,Nh,Do,Bh,ri,Nn,Io,Bn,ai,_u,Oi,Lo,Hh,Hn,Br,Ro,Un,Uh,Vt,at,Ni,Gn,$n,Gh,Fo,$h,zn,oi,Bi,zh,jh,_s,L,kd,xf,em,sm,im,Zl,nm,rm,am,Pf,om,lm,hm,cm,xe,Mi,dm,um,kf,fm,th,Mf;const yo=class yo{constructor(t,e,s,n,r,a,o,l,h,c,d,p,m,y,A,v){g(this,L);g(this,To,new AbortController);g(this,qe,null);g(this,xo,null);g(this,Lt,new Map);g(this,xt,new Map);g(this,Po,null);g(this,ko,null);g(this,ke,null);g(this,Mo,null);g(this,Ss,new Oy);g(this,Jt,null);g(this,Ln,null);g(this,Rn,null);g(this,Fn,0);g(this,On,new Set);g(this,ni,null);g(this,Es,null);g(this,Nr,new Set);x(this,"_editorUndoBar",null);g(this,Oh,!1);g(this,Nh,!1);g(this,Do,!1);g(this,Bh,null);g(this,ri,null);g(this,Nn,null);g(this,Io,null);g(this,Bn,!1);g(this,ai,null);g(this,_u,new Fy);g(this,Oi,!1);g(this,Lo,!1);g(this,Hh,!1);g(this,Hn,null);g(this,Br,null);g(this,Ro,null);g(this,Un,null);g(this,Uh,null);g(this,Vt,G.NONE);g(this,at,new Set);g(this,Ni,null);g(this,Gn,null);g(this,$n,null);g(this,Gh,null);g(this,Fo,null);g(this,$h,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});g(this,zn,[0,0]);g(this,oi,null);g(this,Bi,null);g(this,zh,null);g(this,jh,null);g(this,_s,null);const w=this._signal=i(this,To).signal;f(this,Bi,t),f(this,zh,e),f(this,jh,s),f(this,ko,n),f(this,Jt,r),f(this,Gn,a),f(this,Fo,l),this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:w}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:w}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:w}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:w}),o._on("setpreference",this.onSetPreference.bind(this),{signal:w}),o._on("switchannotationeditorparams",S=>this.updateParams(S.type,S.value),{signal:w}),window.addEventListener("pointerdown",()=>{f(this,Lo,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{f(this,Lo,!1)},{capture:!0,signal:w}),window.addEventListener("beforeunload",b(this,L,em).bind(this),{capture:!0,signal:w}),b(this,L,nm).call(this),b(this,L,cm).call(this),b(this,L,Pf).call(this),f(this,ke,l.annotationStorage),f(this,Bh,l.filterFactory),f(this,$n,h),f(this,Io,c||null),f(this,Oh,d),f(this,Nh,p),f(this,Do,m),f(this,Uh,y||null),this.viewParameters={realScale:Er.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=A||null,this._supportsPinchToZoom=v!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=yo.prototype,e=a=>i(a,Bi).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 $(this,"_keyboardManager",new md([[["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,Bi).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&i(a,Bi).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,n,r,a,o,l,h;(t=i(this,_s))==null||t.resolve(),f(this,_s,null),(e=i(this,To))==null||e.abort(),f(this,To,null),this._signal=null;for(const c of i(this,xt).values())c.destroy();i(this,xt).clear(),i(this,Lt).clear(),i(this,Nr).clear(),(s=i(this,Un))==null||s.clear(),f(this,qe,null),i(this,at).clear(),i(this,Ss).destroy(),(n=i(this,ko))==null||n.destroy(),(r=i(this,Jt))==null||r.destroy(),(a=i(this,Gn))==null||a.destroy(),(o=i(this,ai))==null||o.hide(),f(this,ai,null),(l=i(this,Ro))==null||l.destroy(),f(this,Ro,null),f(this,xo,null),i(this,ri)&&
2(clearTimeout(i(this,ri)),f(this,ri,null)),i(this,oi)&&(clearTimeout(i(this,oi)),f(this,oi,null)),(h=this._editorUndoBar)==null||h.destroy(),f(this,Fo,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return i(this,Uh)}get useNewAltTextFlow(){return i(this,Nh)}get useNewAltTextWhenAddingImage(){return i(this,Do)}get hcmFilter(){return $(this,"hcmFilter",i(this,$n)?i(this,Bh).addHCMFilter(i(this,$n).foreground,i(this,$n).background):"none")}get direction(){return $(this,"direction",getComputedStyle(i(this,Bi)).direction)}get _highlightColors(){return $(this,"_highlightColors",i(this,Io)?new Map(i(this,Io).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return $(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 $(this,"highlightColors",e)}get highlightColorNames(){return $(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,Rn,t)}setMainHighlightColorPicker(t){f(this,Ro,t)}editAltText(t,e=!1){var s;(s=i(this,ko))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!i(this,Jt)}editComment(t,e,s,n){var r;(r=i(this,Jt))==null||r.showDialog(this,t,e,s,n)}selectComment(t,e){const s=i(this,xt).get(t),n=s==null?void 0:s.getEditorByUID(e);n==null||n.toggleComment(!0,!0)}updateComment(t){var e;(e=i(this,Jt))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=i(this,Jt))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=i(this,Jt))==null||e.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},n=()=>{var r;(r=this._editorUndoBar)==null||r.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:n,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){var n;(n=i(this,Jt))==null||n.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=i(this,Jt))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=i(this,Jt))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(i(this,xt).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),n=r=>{r.pageNumber===t&&(this._eventBus._off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n),await s}getSignature(t){var e;(e=i(this,Gn))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return i(this,Gn)}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,Do,e);break}}onPageChanging({pageNumber:t}){f(this,Fn,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();i(this,xt).delete(t),i(this,Fn)===t&&f(this,Fn,0)}focusMainContainer(){i(this,Bi).focus()}findParent(t,e){for(const s of i(this,xt).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,zh).classList.toggle("noUserSelect",t)}addShouldRescale(t){i(this,Nr).add(t)}removeShouldRescale(t){i(this,Nr).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Er.PDF_TO_CSS_UNITS;for(const s of i(this,Nr))s.onScaleChanging();(e=i(this,Rn))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=b(this,L,kd).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();const p=b(this,L,xf).call(this,c),m=i(this,Vt)===G.NONE,y=()=>{const A=p==null?void 0:p.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o,text:l});m&&this.showAllEditors("highlight",!0,!0),e&&(A==null||A.editComment())};if(m){this.switchToMode(G.HIGHLIGHT,y);return}y()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!i(this,ke))return null;const e=`${_h}${t}`,s=i(this,ke).getRawValue(e);return s&&i(this,ke).remove(e),s}
2addToAnnotationStorage(t){!t.isEmpty()&&i(this,ke)&&!i(this,ke).has(t.id)&&i(this,ke).setValue(t.id,t)}a11yAlert(t,e=null){const s=i(this,jh);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,Bn)&&(f(this,Bn,!1),b(this,L,Zl).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of i(this,at))if(e.div.contains(t)){f(this,Br,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!i(this,Br))return;const[t,e]=i(this,Br);f(this,Br,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,L,Pf).call(this),this.setEditingState(!0)}removeEditListeners(){b(this,L,om).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of i(this,Es))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,Es))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=i(this,qe))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const n of i(this,at)){const r=n.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const a of i(this,Es))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){j(`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)b(this,L,kf).call(this,l);b(this,L,Mf).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){j(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),i(this,Vt)!==G.NONE&&!this.isEditorHandlingKeyboard&&yo._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,i(this,Bn)&&(f(this,Bn,!1),b(this,L,Zl).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}}updatePageIndex(t,e){for(const n of this.getEditors(t))n.pageIndex=e;const s=i(this,Po).get(t);s&&(s.pageIndex=e,i(this,xt).set(e,s),i(this,Oi)?s.enable():s.disable())}startUpdatePages(){f(this,Po,new Map(i(this,xt))),i(this,xt).clear()}endUpdatePages(){f(this,Po,null)}clonePage(t,e){for(const s of this.getEditors(t)){const n=s.serialize(s.mode!==G.HIGHLIGHT);n&&(n.pageIndex=e,n.id=this.getId(),n.isClone=!0,delete n.popupRef,i(this,ke).setValue(n.id,n))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[n,r]of i(this,ke))r.pageIndex===s&&r.isClone&&(i(this,ke).remove(n),e.push(t.deserialize(r).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(b(this,L,rm).call(this),b(this,L,lm).call(this),b(this,L,xe).call(this,{isEditing:i(this,Vt)!==G.NONE,isEmpty:b(this,L,th).call(this),hasSomethingToUndo:i(this,Ss).hasSomethingToUndo(),hasSomethingToRedo:i(this,Ss).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,L,am).call(this),b(this,L,hm).call(this),b(this,L,xe).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!i(this,Es)){f(this,Es,t);for(const e of i(this,Es))b(this,L,Mi).call(this,e.defaultPropertiesToUpdate)}}getId(){return i(this,_u).id}get currentLayer(){return i(this,xt).get(i(this,Fn))}getLayer(t){return i(this,xt).get(t)}get currentPageIndex(){return i(this,Fn)}addLayer(t){i(this,xt).set(t.pageIndex,t),i(this,Oi)?t.enable():t.disable()}removeLayer(t){i(this,xt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,n=!1,r=!1,a=!1){var o,l,h,c,d,p;if(i(this,Vt)!==t&&!(i(this,_s)&&(await i(this,_s).promise,!i(this,_s)))){if(f(this,_s,Promise.withResolvers()),(o=i(this,Rn))==null||o.commitOrRemove(),i(this,Vt)===G.POPUP&&((l=i(this,Jt))==null||l.hideSidebar()),(h=i(this,Jt))==null||h.destroyPopup(),f(this,Vt,t),t===G.NONE){this.setEditingState(!1),b(this,L,um).call(this);for(const m of i(this,Lt).values())m.hideStandaloneCommentButton();(c=this._editorUndoBar)==null||c.hide(),this.toggleComment(null),i(this,_s).resolve();return}for(const m of i(this,Lt).values())m.addStandaloneCommentButton();t===G.SIGNATURE&&await((d=i(this,Gn))==null?void 0:d.loadSignatures()),s&&Ae.clearPointerType(),this.setEditingState(!0),await b(this,L,dm).call(this),this.unselectAll();for(const m of i(this,xt).values())m.updateMode(t);if(t===G.POPUP){i(this,xo)||f(this,xo,await i(this,Fo).getAnnotationsByType(new Set(i(this,Es).map(A=>A._editorType))));const m=new Set,y=[];for(const A of i(this,Lt).values()){const{annotationElementId:v,hasComment:w,deleted:S}=A;
2v&&m.add(v),w&&!S&&y.push(A.getData())}for(const A of i(this,xo)){const{id:v,popupRef:w,contentsObj:S}=A;w&&(S!=null&&S.str)&&!m.has(v)&&!i(this,On).has(v)&&y.push(A)}(p=i(this,Jt))==null||p.showSidebar(y)}if(!e){n&&this.addNewEditorFromKeyboard(),i(this,_s).resolve();return}for(const m of i(this,Lt).values())m.uid===e?(this.setSelected(m),a?m.editComment():r?m.enterInEditMode():m.focus()):m.unselect();i(this,_s).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==i(this,Vt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(i(this,Es)){switch(t){case V.CREATE:this.currentLayer.addNewEditor(e);return;case V.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(i(this,Gh)||f(this,Gh,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of i(this,at))s.updateParams(t,e);else for(const s of i(this,Es))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of i(this,Lt).values())a.editorType===t&&a.show(e);(((r=i(this,Gh))==null?void 0:r.get(V.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,L,Mi).call(this,[[V.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(i(this,Hh)!==t){f(this,Hh,t);for(const e of i(this,xt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of i(this,Lt).values())e.pageIndex===t&&(yield e)}getEditor(t){return i(this,Lt).get(t)}addEditor(t){i(this,Lt).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(i(this,ri)&&clearTimeout(i(this,ri)),f(this,ri,setTimeout(()=>{this.focusMainContainer(),f(this,ri,null)},0))),i(this,Lt).delete(t.id),t.annotationElementId&&((e=i(this,Un))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!i(this,On).has(t.annotationElementId))&&((s=i(this,ke))==null||s.remove(t.id))}addDeletedAnnotationElement(t){i(this,On).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return i(this,On).has(t)}removeDeletedAnnotationElement(t){i(this,On).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){i(this,qe)!==t&&(f(this,qe,t),t&&b(this,L,Mi).call(this,t.propertiesToUpdate))}updateUI(t){i(this,L,fm)===t&&b(this,L,Mi).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,L,Mi).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(i(this,at).has(t)){i(this,at).delete(t),t.unselect(),b(this,L,xe).call(this,{hasSelectedEditor:this.hasSelection});return}i(this,at).add(t),t.select(),b(this,L,Mi).call(this,t.propertiesToUpdate),b(this,L,xe).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=i(this,Rn))==null||e.commitOrRemove();for(const n of i(this,at))n!==t&&n.unselect();(s=i(this,Jt))==null||s.destroyPopup(),i(this,at).clear(),i(this,at).add(t),t.select(),b(this,L,Mi).call(this,t.propertiesToUpdate),b(this,L,xe).call(this,{hasSelectedEditor:!0})}isSelected(t){return i(this,at).has(t)}get firstSelectedEditor(){return i(this,at).values().next().value}unselect(t){t.unselect(),i(this,at).delete(t),b(this,L,xe).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return i(this,at).size!==0}get isEnterHandled(){return i(this,at).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;i(this,Ss).undo(),b(this,L,xe).call(this,{hasSomethingToUndo:i(this,Ss).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,L,th).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){i(this,Ss).redo(),b(this,L,xe).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:i(this,Ss).hasSomethingToRedo(),isEmpty:b(this,L,th).call(this)})}addCommands(t){i(this,Ss).add(t),b(this,L,xe).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,L,th).call(this)})}cleanUndoStack(t){i(this,Ss).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...i(this,at)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(n,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},n=()=>{for(const a of e)b(this,L,kf).call(this,a)};this.addCommands({cmd:s,undo:n,mustExec:!0})}commitOrRemove(){var t;(t=i(this,qe))==null||t.commitOrRemove()}hasSomethingToControl(){return i(this,qe)||this.hasSelection}selectAll(){for(const t of i(this,at))t.commit();b(this,L,Mf).call(this,i(this,Lt).values())}unselectAll(){var t,e;if(!(i(this,qe)&&(i(this,qe).commitOrRemove(),i(this,Vt)!==G.NONE))&&!((t=i(this,Rn))!=null&&t.commitOrRemove())&&((e
2=i(this,Jt))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of i(this,at))s.unselect();i(this,at).clear(),b(this,L,xe).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;i(this,zn)[0]+=t,i(this,zn)[1]+=e;const[n,r]=i(this,zn),a=[...i(this,at)],o=1e3;i(this,oi)&&clearTimeout(i(this,oi)),f(this,oi,setTimeout(()=>{f(this,oi,null),i(this,zn)[0]=i(this,zn)[1]=0,this.addCommands({cmd:()=>{for(const l of a)i(this,Lt).has(l.id)&&(l.translateInPage(n,r),l.translationDone())},undo:()=>{for(const l of a)i(this,Lt).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,ni,new Map);for(const t of i(this,at))i(this,ni).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!i(this,ni))return!1;this.disableUserSelect(!1);const t=i(this,ni);f(this,ni,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)=>{if(i(this,Lt).has(n.id)){const l=i(this,xt).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,ni))for(const s of i(this,ni).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||i(this,at).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return i(this,qe)===t}getActive(){return i(this,qe)}getMode(){return i(this,Vt)}isEditingMode(){return i(this,Vt)!==G.NONE}get imageManager(){return $(this,"imageManager",new Cf)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:n,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(h,c,d,p)=>({x:(c-n)/a,y:1-(h+d-s)/r,width:p/a,height:d/r});break;case"180":o=(h,c,d,p)=>({x:1-(h+d-s)/r,y:1-(c+p-n)/a,width:d/r,height:p/a});break;case"270":o=(h,c,d,p)=>({x:1-(c+p-n)/a,y:(h-s)/r,width:p/a,height:d/r});break;default:o=(h,c,d,p)=>({x:(h-s)/r,y:(c-n)/a,width:d/r,height:p/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:p,y:m,width:y,height:A}of d.getClientRects())y===0||A===0||l.push(o(p,m,y,A))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(i(this,Mo)||f(this,Mo,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=i(this,Mo))==null||e.delete(t)}renderAnnotationElement(t){var n;const e=(n=i(this,Mo))==null?void 0:n.get(t.data.id);if(!e)return;const s=i(this,ke).getRawValue(e);s&&(i(this,Vt)===G.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const n=(r=i(this,Un))==null?void 0:r.get(t);n&&(n.setCanvas(e,s),i(this,Un).delete(t))}addMissingCanvas(t,e){(i(this,Un)||f(this,Un,new Map)).set(t,e)}};To=new WeakMap,qe=new WeakMap,xo=new WeakMap,Lt=new WeakMap,xt=new WeakMap,Po=new WeakMap,ko=new WeakMap,ke=new WeakMap,Mo=new WeakMap,Ss=new WeakMap,Jt=new WeakMap,Ln=new WeakMap,Rn=new WeakMap,Fn=new WeakMap,On=new WeakMap,ni=new WeakMap,Es=new WeakMap,Nr=new WeakMap,Oh=new WeakMap,Nh=new WeakMap,Do=new WeakMap,Bh=new WeakMap,ri=new WeakMap,Nn=new WeakMap,Io=new WeakMap,Bn=new WeakMap,ai=new WeakMap,_u=new WeakMap,Oi=new WeakMap,Lo=new WeakMap,Hh=new WeakMap,Hn=new WeakMap,Br=new WeakMap,Ro=new WeakMap,Un=new WeakMap,Uh=new WeakMap,Vt=new WeakMap,at=new WeakMap,Ni=new WeakMap,Gn=new WeakMap,$n=new WeakMap,Gh=new WeakMap,Fo=new WeakMap,$h=new WeakMap,zn=new WeakMap,oi=new WeakMap,Bi=new WeakMap,zh=new WeakMap,jh=new WeakMap,_s=new WeakMap,L=new WeakSet,kd=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},xf=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of i(this,xt).values())if(s.hasTextLayer(t))return s;return null},em=function(t){var e;this.commitOrRemove(),(e=this.currentLayer)==null||e.endDrawingSession(!1)},sm=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;
2const s=b(this,L,kd).call(this,t).closest(".textLayer"),n=this.getSelectionBoxes(s);n&&(i(this,ai)||f(this,ai,new Ry(this)),i(this,ai).show(s,n,this.direction==="ltr"))},im=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){i(this,Ni)&&((r=i(this,ai))==null||r.hide(),f(this,Ni,null),b(this,L,xe).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===i(this,Ni))return;const n=b(this,L,kd).call(this,t).closest(".textLayer");if(!n){i(this,Ni)&&((a=i(this,ai))==null||a.hide(),f(this,Ni,null),b(this,L,xe).call(this,{hasSelectedText:!1}));return}if((o=i(this,ai))==null||o.hide(),f(this,Ni,e),b(this,L,xe).call(this,{hasSelectedText:!0}),!(i(this,Vt)!==G.HIGHLIGHT&&i(this,Vt)!==G.NONE)&&(i(this,Vt)===G.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),f(this,Bn,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=i(this,Vt)===G.HIGHLIGHT?b(this,L,xf).call(this,n):null;if(l==null||l.toggleDrawing(),i(this,Lo)){const h=new AbortController,c=this.combinedSignal(h),d=p=>{p.type==="pointerup"&&p.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),p.type==="pointerup"&&b(this,L,Zl).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("blur",d,{signal:c})}else l==null||l.toggleDrawing(!0),b(this,L,Zl).call(this,"main_toolbar")}},Zl=function(t=""){i(this,Vt)===G.HIGHLIGHT?this.highlightSelection(t):i(this,Oh)&&b(this,L,sm).call(this)},nm=function(){document.addEventListener("selectionchange",b(this,L,im).bind(this),{signal:this._signal})},rm=function(){if(i(this,Nn))return;f(this,Nn,new AbortController);const t=this.combinedSignal(i(this,Nn));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},am=function(){var t;(t=i(this,Nn))==null||t.abort(),f(this,Nn,null)},Pf=function(){if(i(this,Hn))return;f(this,Hn,new AbortController);const t=this.combinedSignal(i(this,Hn));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},om=function(){var t;(t=i(this,Hn))==null||t.abort(),f(this,Hn,null)},lm=function(){if(i(this,Ln))return;f(this,Ln,new AbortController);const t=this.combinedSignal(i(this,Ln));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})},hm=function(){var t;(t=i(this,Ln))==null||t.abort(),f(this,Ln,null)},cm=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},xe=function(t){Object.entries(t).some(([s,n])=>i(this,$h)[s]!==n)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(i(this,$h),t)}),i(this,Vt)===G.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,L,Mi).call(this,[[V.HIGHLIGHT_FREE,!0]]))},Mi=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},dm=async function(){if(!i(this,Oi)){f(this,Oi,!0);const t=[];for(const e of i(this,xt).values())t.push(e.enable());await Promise.all(t);for(const e of i(this,Lt).values())e.enable()}},um=function(){if(this.unselectAll(),i(this,Oi)){f(this,Oi,!1);for(const t of i(this,xt).values())t.disable();for(const t of i(this,Lt).values())t.disable()}},kf=function(t){const e=i(this,xt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},fm=function(){let t=null;for(t of i(this,at));return t},th=function(){if(i(this,Lt).size===0)return!0;if(i(this,Lt).size===1)for(const t of i(this,Lt).values())return t.isEmpty();return!1},Mf=function(t){for(const e of i(this,at))e.unselect();i(this,at).clear();for(const e of t)e.isEmpty()||(i(this,at).add(e),e.select());b(this,L,xe).call(this,{hasSelectedEditor:this.hasSelection})},x(yo,"TRANSLATE_SMALL",1),x(yo,"TRANSLATE_BIG",10);let so=yo;var Zt,li,Bs,Oo,hi,Qe,No,ci,Ge,Hi,Hr,di,jn,Js,eh,Md;const Pe=class Pe{constructor(t){g(this,Js);g(this,Zt,null);g(this,li,!1);g(this,Bs,null);g(this,Oo,null);g(this,hi,null);g(this,Qe,null);g(this,No,!1);g(this,ci,null);g(this,Ge,null);g(this,Hi,null);g(this,Hr,null);g(this,di,!1);f(this,Ge,t),f(this,di,t._uiManager.useNewAltTextFlow),i(Pe,jn)||f(Pe,jn,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){Pe._l10n??(Pe._l10n=t)}async render(){const t=f(this,Bs,document.createElement("button"));t.className="altText",t.tabIndex="0";
2const e=f(this,Oo,document.createElement("span"));t.append(e),i(this,di)?(t.classList.add("new"),t.setAttribute("data-l10n-id",i(Pe,jn).missing),e.setAttribute("data-l10n-id",i(Pe,jn)["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,Ge)._uiManager._signal;t.addEventListener("contextmenu",Fs,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const n=r=>{r.preventDefault(),i(this,Ge)._uiManager.editAltText(i(this,Ge)),i(this,di)&&i(this,Ge)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:i(this,Js,eh)}})};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(f(this,No,!0),n(r))},{signal:s}),await b(this,Js,Md).call(this),t}finish(){i(this,Bs)&&(i(this,Bs).focus({focusVisible:i(this,No)}),f(this,No,!1))}isEmpty(){return i(this,di)?i(this,Zt)===null:!i(this,Zt)&&!i(this,li)}hasData(){return i(this,di)?i(this,Zt)!==null||!!i(this,Hi):this.isEmpty()}get guessedText(){return i(this,Hi)}async setGuessedText(t){i(this,Zt)===null&&(f(this,Hi,t),f(this,Hr,await Pe._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,Js,Md).call(this))}toggleAltTextBadge(t=!1){var e;if(!i(this,di)||i(this,Zt)){(e=i(this,ci))==null||e.remove(),f(this,ci,null);return}if(!i(this,ci)){const s=f(this,ci,document.createElement("div"));s.className="noAltTextBadge",i(this,Ge).div.append(s)}i(this,ci).classList.toggle("hidden",!t)}serialize(t){let e=i(this,Zt);return!t&&i(this,Hi)===e&&(e=i(this,Hr)),{altText:e,decorative:i(this,li),guessedText:i(this,Hi),textWithDisclaimer:i(this,Hr)}}get data(){return{altText:i(this,Zt),decorative:i(this,li)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:n,cancel:r=!1}){s&&(f(this,Hi,s),f(this,Hr,n)),!(i(this,Zt)===t&&i(this,li)===e)&&(r||(f(this,Zt,t),f(this,li,e)),b(this,Js,Md).call(this))}toggle(t=!1){i(this,Bs)&&(!t&&i(this,Qe)&&(clearTimeout(i(this,Qe)),f(this,Qe,null)),i(this,Bs).disabled=!t)}shown(){i(this,Ge)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:i(this,Js,eh)}})}destroy(){var t,e;(t=i(this,Bs))==null||t.remove(),f(this,Bs,null),f(this,Oo,null),f(this,hi,null),(e=i(this,ci))==null||e.remove(),f(this,ci,null)}};Zt=new WeakMap,li=new WeakMap,Bs=new WeakMap,Oo=new WeakMap,hi=new WeakMap,Qe=new WeakMap,No=new WeakMap,ci=new WeakMap,Ge=new WeakMap,Hi=new WeakMap,Hr=new WeakMap,di=new WeakMap,jn=new WeakMap,Js=new WeakSet,eh=function(){return i(this,Zt)&&"added"||i(this,Zt)===null&&this.guessedText&&"review"||"missing"},Md=async function(){var n,r,a;const t=i(this,Bs);if(!t)return;if(i(this,di)){if(t.classList.toggle("done",!!i(this,Zt)),t.setAttribute("data-l10n-id",i(Pe,jn)[i(this,Js,eh)]),(n=i(this,Oo))==null||n.setAttribute("data-l10n-id",i(Pe,jn)[`${i(this,Js,eh)}-label`]),!i(this,Zt)){(r=i(this,hi))==null||r.remove();return}}else{if(!i(this,Zt)&&!i(this,li)){t.classList.remove("done"),(a=i(this,hi))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=i(this,hi);if(!e){f(this,hi,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${i(this,Ge).id}`;const o=100,l=i(this,Ge)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(i(this,Qe)),f(this,Qe,null)},{once:!0}),t.addEventListener("mouseenter",()=>{f(this,Qe,setTimeout(()=>{f(this,Qe,null),i(this,hi).classList.add("show"),i(this,Ge)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;i(this,Qe)&&(clearTimeout(i(this,Qe)),f(this,Qe,null)),(h=i(this,hi))==null||h.classList.remove("show")},{signal:l})}i(this,li)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=i(this,Zt)),e.parentNode||t.append(e);const s=i(this,Ge).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},g(Pe,jn,null),x(Pe,"_l10n",null);let uu=Pe;var oe,Cs,Ur,bt,Vh,Vn,Ts,Wn,Xn,Gr,Wh,Df;class yd{constructor(t){g(this,Wh);g(this,oe,null);g(this,Cs,null);g(this,Ur,!1);g(this,bt,null);g(this,Vh,null);g(this,Vn,null);g(this,Ts,null);g(this,Wn,null);g(this,Xn,!1);g(this,Gr,null);f(this,bt,t)}renderForToolbar(){const t=f(this,Cs,document.createElement("button"));
2return t.className="comment",b(this,Wh,Df).call(this,t,!1)}renderForStandalone(){const t=f(this,oe,document.createElement("button"));t.className="annotationCommentButton";const e=i(this,bt).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(i(this,bt)._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,bt).commentButtonColor;n&&(s.backgroundColor=n)}return b(this,Wh,Df).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=i(this,oe)??i(this,Cs))==null||t.focus()},0)}onUpdatedColor(){if(!i(this,oe))return;const t=i(this,bt).commentButtonColor;t&&(i(this,oe).style.backgroundColor=t),i(this,bt)._uiManager.updatePopupColor(i(this,bt))}get commentButtonWidth(){var t;return(((t=i(this,oe))==null?void 0:t.getBoundingClientRect().width)??0)/i(this,bt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(i(this,Gr))return i(this,Gr);if(!i(this,oe))return null;const{x:t,y:e,height:s}=i(this,oe).getBoundingClientRect(),{x:n,y:r,width:a,height:o}=i(this,bt).parent.boundingClientRect;return[(t-n)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){f(this,Gr,t)}hasDefaultPopupPosition(){return i(this,Gr)===null}removeStandaloneCommentButton(){var t;(t=i(this,oe))==null||t.remove(),f(this,oe,null)}removeToolbarCommentButton(){var t;(t=i(this,Cs))==null||t.remove(),f(this,Cs,null)}setCommentButtonStates({selected:t,hasPopup:e}){i(this,oe)&&(i(this,oe).classList.toggle("selected",t),i(this,oe).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,n;if(e)[s,n]=e;else{[s,n]=i(this,bt).commentButtonPosition;const{width:c,height:d,x:p,y:m}=i(this,bt);s=p+s*c,n=m+n*d}const r=i(this,bt).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;i(this,bt)._uiManager.editComment(i(this,bt),a+s*l,o+n*h,{...t,parentDimensions:r})}finish(){i(this,Cs)&&(i(this,Cs).focus({focusVisible:i(this,Ur)}),f(this,Ur,!1))}isDeleted(){return i(this,Xn)||i(this,Ts)===""}isEmpty(){return i(this,Ts)===null}hasBeenEdited(){return this.isDeleted()||i(this,Ts)!==i(this,Vh)}serialize(){return this.data}get data(){return{text:i(this,Ts),richText:i(this,Vn),date:i(this,Wn),deleted:this.isDeleted()}}set data(t){if(t!==i(this,Ts)&&f(this,Vn,null),t===null){f(this,Ts,""),f(this,Xn,!0);return}f(this,Ts,t),f(this,Wn,new Date),f(this,Xn,!1)}restoreData({text:t,richText:e,date:s}){f(this,Ts,t),f(this,Vn,e),f(this,Wn,s),f(this,Xn,!1)}setInitialText(t,e=null){f(this,Vh,t),this.data=t,f(this,Wn,null),f(this,Vn,e)}shown(){}destroy(){var t,e;(t=i(this,Cs))==null||t.remove(),f(this,Cs,null),(e=i(this,oe))==null||e.remove(),f(this,oe,null),f(this,Ts,""),f(this,Vn,null),f(this,Wn,null),f(this,bt,null),f(this,Ur,!1),f(this,Xn,!1)}}oe=new WeakMap,Cs=new WeakMap,Ur=new WeakMap,bt=new WeakMap,Vh=new WeakMap,Vn=new WeakMap,Ts=new WeakMap,Wn=new WeakMap,Xn=new WeakMap,Gr=new WeakMap,Wh=new WeakSet,Df=function(t,e){if(!i(this,bt)._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,bt)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=i(this,bt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",Fs,{signal:s}),e&&(t.addEventListener("focusin",r=>{i(this,bt)._focusEventsAllowed=!1,Pt(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{i(this,bt)._focusEventsAllowed=!0,Pt(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const n=r=>{r.preventDefault(),t===i(this,Cs)?this.edit():i(this,bt).toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(f(this,Ur,!0),n(r))},{signal:s}),t.addEventListener("pointerenter",()=>{i(this,bt).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{i(this,bt).toggleComment(!1,!1)},{signal:s}),t};var Bo,$r,Xh,Yh,Kh,qh,Qh,Ui,zr,Gi,jr,$i,_r,pm,gm,mm;const ng=class ng{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,Bo);g(this,$r,!1);g(this,Xh,null);g(this,Yh);g(this,Kh);g(this,qh);g(this,Qh);g(this,Ui,null);g(this,zr);g(this,Gi,null);g(this,jr);g(this,$i,null);f(this,Bo,t),f(this,Xh,s),f(this,Yh,e),f(this,Kh,n),f(this,qh,r),f(this,Qh,a),f(this,jr,new AbortController),f(this,zr,AbortSignal.any([o,i(this,jr).signal])),t.addEventListener("touchstart",b(this,_r,pm).bind(this),{passive:!1,signal:i(this,zr)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ti.pixelRatio}destroy(){var t,e;(t=i(this,jr))==null||t.abort(),f(this,jr,null),(e=i(this,Ui))==null||e.abort(),f(this,Ui,null)}};Bo=new WeakMap,$r=new WeakMap,Xh=new WeakMap,Yh=new WeakMap,Kh=new WeakMap,qh=new WeakMap,Qh=new WeakMap,Ui=new WeakMap,zr=new WeakMap,Gi=new WeakMap,jr=new WeakMap,$i=new WeakMap,_r=new WeakSet,pm=function(t){var n,r,a;if((n=i(this,Yh))!=null&&n.call(this))return;if(t.touches.length===1){if(i(this,Ui))return;const o=f(this,Ui,new AbortController),l=AbortSignal.any([i(this,zr),o.signal]),h=i(this,Bo),c={capture:!0,signal:l,passive:!1},d=p=>{var m;p.pointerType==="touch"&&((m=i(this,Ui))==null||m.abort(),f(this,Ui,null))};h.addEventListener("pointerdown",p=>{p.pointerType==="touch"&&(Pt(p),d(p))},c),h.addEventListener("pointerup",d,c),h.addEventListener("pointercancel",d,c);return}if(!i(this,$i)){f(this,$i,new AbortController);const o=AbortSignal.any([i(this,zr),i(this,$i).signal]),l=i(this,Bo),h={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",b(this,_r,gm).bind(this),h);const c=b(this,_r,mm).bind(this);l.addEventListener("touchend",c,h),l.addEventListener("touchcancel",c,h),h.capture=!0,l.addEventListener("pointerdown",Pt,h),l.addEventListener("pointermove",Pt,h),l.addEventListener("pointercancel",Pt,h),l.addEventListener("pointerup",Pt,h),(r=i(this,Kh))==null||r.call(this)}if(Pt(t),t.touches.length!==2||(a=i(this,Xh))!=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})},gm=function(t){var _;if(!i(this,Gi)||t.touches.length!==2)return;Pt(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:n,screenY:r}=e,{screenX:a,screenY:o}=s,l=i(this,Gi),{touch0X:h,touch0Y:c,touch1X:d,touch1Y:p}=l,m=d-h,y=p-c,A=a-n,v=o-r,w=Math.hypot(A,v)||1,S=Math.hypot(m,y)||1;if(!i(this,$r)&&Math.abs(S-w)<=ng.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!i(this,$r)){f(this,$r,!0);return}const E=[(n+a)/2,(r+o)/2];(_=i(this,qh))==null||_.call(this,E,S,w)},mm=function(t){var e;t.touches.length>=2||(i(this,$i)&&(i(this,$i).abort(),f(this,$i,null),(e=i(this,Qh))==null||e.call(this)),i(this,Gi)&&(Pt(t),f(this,Gi,null),f(this,$r,!1))
2)};let fu=ng;var Vr,Hs,Et,ot,zi,Ho,Yn,Jh,le,Wr,ji,xs,Kn,Zh,Xr,Je,tc,Yr,Vi,ui,Uo,Go,Ps,Kr,ec,Cu,U,If,sc,Lf,Dd,bm,ym,Rf,Id,Ff,Am,wm,vm,Of,Sm,Nf,Em,_m,Cm,Bf,sh;const z=class z{constructor(t){g(this,U);g(this,Vr,null);g(this,Hs,null);g(this,Et,null);g(this,ot,null);g(this,zi,null);g(this,Ho,!1);g(this,Yn,null);g(this,Jh,"");g(this,le,null);g(this,Wr,null);g(this,ji,null);g(this,xs,null);g(this,Kn,null);g(this,Zh,"");g(this,Xr,!1);g(this,Je,null);g(this,tc,!1);g(this,Yr,!1);g(this,Vi,!1);g(this,ui,null);g(this,Uo,0);g(this,Go,0);g(this,Ps,null);g(this,Kr,null);x(this,"isSelected",!1);x(this,"_isCopy",!1);x(this,"_editToolbar",null);x(this,"_initialOptions",Object.create(null));x(this,"_initialData",null);x(this,"_isVisible",!0);x(this,"_uiManager",null);x(this,"_focusEventsAllowed",!0);g(this,ec,!1);g(this,Cu,z._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,this.canAddComment=!0;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=z.prototype._resizeWithKeyboard,e=so.TRANSLATE_SMALL,s=so.TRANSLATE_BIG;return $(this,"_resizerKeyboardManager",new md([[["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"],z.prototype._stopResizingWithKeyboard]]))}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return $(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Ny({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(z._l10n??(z._l10n=t),z._l10nResizer||(z._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"})),z._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);z._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){nt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return i(this,ec)}set _isDraggable(t){var e;f(this,ec,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=i(this,Cu)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,U,sh).call(this),(e=i(this,xs))==null||e.remove(),f(this,xs,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(i(this,Xr)?f(this,Xr,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,n){const[r,a]=this.parentDimensions;[s,n]=this.screenToPageTranslation(s,n),this.x=(t+s)/r,this.y=(e+n)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,n]=this.parentDimensions;this.setAt(t*s,e*n,this.width*s,this.height*n),this._onTranslated()}translate(t,e){b(this,U,If).call(this,this.parentDimensions,t,e)}translateInPage(t,e){i(this,Je)||f(this,Je,[this.x,this.y,this.width,this.height]),b(this,U,If).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){i(this,Je)||f(this,Je,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[n,r]}=this;if(this.x+=t/n,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:p}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,p)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,h]=this.getBaseTranslation();a+=l,o+=h;const{style:c}=s;c.left=`${(100*a).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!i(this,Je)&&(i(this,Je)[0]!==this.x||i(this,Je)[1]!==this.y)}get _hasBeenResized(){return!!i(this,Je)&&(i(this,Je)[2]!==this.width||i(this,Je)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=z,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=Ct(r,0,s-o),a=Ct(a,0,n-l);break;case 90:r=Ct(r,0,s-l),a=Ct(a,o,n);break;case 180:r=Ct(r,o,s),a=Ct(a,l,n);break;case 270:r=Ct(r,l,s),a=Ct(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 b(s=z,sc,Lf).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=z,sc,Lf).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=i(this,Et))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||i(this,Yr))return this._editToolbar;this._editToolbar=new Ef(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}
2removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=i(this,Et))==null||e.destroy()}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return i(this,Et)||(uu.initialize(z._l10n),f(this,Et,new uu(this)),i(this,Vr)&&(i(this,Et).data=i(this,Vr),f(this,Vr,null))),i(this,Et)}get altTextData(){var t;return(t=i(this,Et))==null?void 0:t.data}set altTextData(t){i(this,Et)&&(i(this,Et).data=t)}get guessedAltText(){var t;return(t=i(this,Et))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=i(this,Et))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=i(this,Et))==null?void 0:e.serialize(t)}hasAltText(){return!!i(this,Et)&&!i(this,Et).isEmpty()}hasAltTextData(){var t;return((t=i(this,Et))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=i(this,ot))==null||t.focusButton()}addCommentButton(){return this.canAddComment?i(this,ot)||f(this,ot,new yd(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(i(this,zi)){this._uiManager.isEditingMode()&&i(this,zi).classList.remove("hidden");return}this.hasComment&&(f(this,zi,i(this,ot).renderForStandalone()),this.div.append(i(this,zi)))}}removeStandaloneCommentButton(){i(this,ot).removeStandaloneCommentButton(),f(this,zi,null)}hideStandaloneCommentButton(){var t;(t=i(this,zi))==null||t.classList.add("hidden")}get comment(){if(!i(this,ot))return null;const{data:{richText:t,text:e,date:s,deleted:n}}=i(this,ot);return{text:e,richText:t,date:s,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){i(this,ot)||f(this,ot,new yd(this)),typeof t=="object"&&t!==null?i(this,ot).restoreData(t):i(this,ot).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,ot)||f(this,ot,new yd(this)),i(this,ot).setInitialText(t,s),!this.annotationElementId))return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){var t;return(t=i(this,ot))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=i(this,ot))==null?void 0:t.isDeleted()}get hasComment(){return!!i(this,ot)&&!i(this,ot).isEmpty()&&!i(this,ot).isDeleted()}async editComment(t){i(this,ot)||f(this,ot,new yd(this)),i(this,ot).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){i(this,ot).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,ot).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=i(this,Ho)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),b(this,U,Nf).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),Zg(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(i(this,Kr)||f(this,Kr,new fu({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,U,Am).bind(this),onPinching:b(this,U,wm).bind(this),onPinchEnd:b(this,U,vm).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(f(this,Xr,!0),this._isDraggable){b(this,U,Sm).call(this,t);return}b(this,U,Of).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){i(this,ui)&&clearTimeout(i(this,ui)),f(this,ui,setTimeout(()=>{var t;f(this,ui,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const n=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/n,c=e/n,d=this.x*r,p=this.y*a,m=this.width*r,y=this.height*a;switch(s){case 0:return[d+h+o,a-p-c-y+l,d+h+m+o,a-p-c+l];case 90:return[d+c+o,a-p+h+l,d+c+y+o,a-p+h+m+l];case 180:return[d-h-m+o,a-p+c+l,d-h+o,a-p+c+y+l];case 270:return[d-c-y+o,a-p-h-m+l,d-c+o,a-p-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,n,r,a]=t,o=r-s,l=a-n;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-n,l,o];case 180:return[r,e-n,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&z._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=i(this,ot))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:n,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:h,modificationDate:c}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:h,modificationDate:s||c,popupRef:!r,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),f(this,Yr,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),f(this,Yr,!1),!0):!1}isInEditMode(){return i(this,Yr)}shouldGetKeyboardEvents(){return i(this,Vi)}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(){b(this,U,Nf).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const n=new this.prototype.constructor({parent:e,id:s.getId(),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(){var t,e,s;if((t=i(this,Kn))==null||t.abort(),f(this,Kn,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),i(this,ui)&&(clearTimeout(i(this,ui)),f(this,ui,null)),b(this,U,sh).call(this),this.removeEditToolbar(),i(this,Ps)){for(const n of i(this,Ps).values())clearTimeout(n);f(this,Ps,null)}this.parent=null,(e=i(this,Kr))==null||e.destroy(),f(this,Kr,null),(s=i(this,xs))==null||s.remove(),f(this,xs,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,U,bm).call(this),i(this,le).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[z._round(s+(r-s)*t),z._round(n+(a-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return i(this,ot).commentPopupPositionInLayer}set commentPopupPosition(t){i(this,ot).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return i(this,ot).hasDefaultPopupPosition()}get commentButtonWidth(){return i(this,ot).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=i(this,ot))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),f(this,ji,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=i(this,le).children;if(!i(this,Hs)){f(this,Hs,Array.from(e));const a=b(this,U,Em).bind(this),o=b(this,U,_m).bind(this),l=this._uiManager._signal;for(const h of i(this,Hs)){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",b(this,U,Cm).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",z._l10nResizer[c])}}const s=i(this,Hs)[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,Hs).length/4);if(r!==n){if(r<n)for(let o=0;o<n-r;o++)i(this,le).append(i(this,le).firstElementChild);else if(r>n)for(let o=0;o<r-n;o++)i(this,le).firstElementChild.before(i(this,le).lastElementChild);let a=0;for(const o of e){const h=i(this,Hs)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",z._l10nResizer[h])}}b(this,U,Bf).call(this,0),f(this,Vi,!0),i(this,le).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){i(this,Vi)&&b(this,U,Ff).call(this,i(this,Zh),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,U,sh).call(this),this.div.focus()}select(){var t,e,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var n,r;(n=this.div)!=null&&n.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=i(this,Et))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,s,n,r;this.isSelected&&(this.isSelected=!1,(t=i(this,le))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(n=this._editToolbar)==null||n.hide(),(r=i(this,Et))==null||r.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return i(this,tc)}set isEditing(t){f(this,tc,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,Ps)||f(this,Ps,new Map);const{action:s}=t;let n=i(this,Ps).get(s);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(t),i(this,Ps).delete(s),i(this,Ps).size===0&&f(this,Ps,null)},z._telemetryTimeout),i(this,Ps).set(s,n);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}
2show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),f(this,Ho,!1)}disable(){this.div&&(this.div.tabIndex=-1),f(this,Ho,!0)}updateFakeAnnotationElement(t){if(!i(this,xs)&&!this.deleted){f(this,xs,t.addFakeAnnotation(this));return}if(this.deleted){i(this,xs).remove(),f(this,xs,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&i(this,xs).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{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};Vr=new WeakMap,Hs=new WeakMap,Et=new WeakMap,ot=new WeakMap,zi=new WeakMap,Ho=new WeakMap,Yn=new WeakMap,Jh=new WeakMap,le=new WeakMap,Wr=new WeakMap,ji=new WeakMap,xs=new WeakMap,Kn=new WeakMap,Zh=new WeakMap,Xr=new WeakMap,Je=new WeakMap,tc=new WeakMap,Yr=new WeakMap,Vi=new WeakMap,ui=new WeakMap,Uo=new WeakMap,Go=new WeakMap,Ps=new WeakMap,Kr=new WeakMap,ec=new WeakMap,Cu=new WeakMap,U=new WeakSet,If=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()},sc=new WeakSet,Lf=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]}},Dd=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]}},bm=function(){if(i(this,le))return;f(this,le,document.createElement("div")),i(this,le).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,le).append(n),n.classList.add("resizer",s),n.setAttribute("data-resizer-name",s),n.addEventListener("pointerdown",b(this,U,ym).bind(this,s),{signal:e}),n.addEventListener("contextmenu",Fs,{signal:e}),n.tabIndex=-1}this.div.prepend(i(this,le))},ym=function(t,e){var c;e.preventDefault();const{isMac:s}=Wt.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=i(this,Et))==null||c.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,f(this,Wr,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,U,Ff).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Pt,{passive:!1,signal:a}),window.addEventListener("contextmenu",Fs,{signal:a}),f(this,ji,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var d;r.abort(),this.parent.togglePointerEvents(!0),(d=i(this,Et))==null||d.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,U,Id).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},Rf=function(t,e,s,n){this.width=s,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Id=function(){if(!i(this,ji))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:n}=i(this,ji);f(this,ji,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:b(this,U,Rf).bind(this,r,a,o,l),undo:b(this,U,Rf).bind(this,t,e,s,n),mustExec:!0})},Ff=function(t,e){const[s,n]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=z.MIN_SIZE/s,c=z.MIN_SIZE/n,d=b(this,U,Dd).call(this,this.rotation),p=(B,H)=>[d[0]*B+d[2]*H,d[1]*B+d[3]*H],m=b(this,U,Dd).call(this,360-this.rotation),y=(B,H)=>[m[0]*B+m[2]*H,m[1]*B+m[3]*H];let A,v,w=!1,S=!1;switch(t){case"topLeft":w=!0,A=(B,H)=>[0,0],v=(B,H)=>[B,H];break;case"topMiddle":A=(B,H)=>[B/2,0],v=(B,H)=>[B/2,H];break;case"topRight":w=!0,A=(B,H)=>[B,0],v=(B,H)=>[0,H];break;case"middleRight":S=!0,A=(B,H)=>[B,H/2],v=(B,H)=>[0,H/2];break;case"bottomRight":w=!0,A=(B,H)=>[B,H],v=(B,H)=>[0,0];break;case"bottomMiddle":A=(B,H)=>[B/2,H],v=(B,H)=>[B/2,0];break;case"bottomLeft":w=!0,A=(B,H)=>[0,H],v=(B,H)=>[B,0];break;case"middleLeft":S=!0,A=(B,H)=>[0,H/2],v=(B,H)=>[B,H/2];break}const E=A(o,l),_=v(o,l);let C=p(..._);const T=z._round(r+C[0]),P=z._round(a+C[1]);let D=1,k=1,R,I;if(e.fromKeyboard)({deltaX:R,deltaY:I}=e);else{const{screenX:B,screenY:H}=e,[ht,Be]=i(this,Wr);[R,I]=this.screenToPageTranslation(B-ht,H-Be),i(this,Wr)[0]=B,i(this,Wr)[1]=H}if([R,I]=y(R/s,I/n),w){const B=Math.hypot(o,l);D=k=Math.max(Math.min(Math.hypot(_[0]-E[0]-R,_[1]-E[1]-I)/B,1/o,1/l),h/o,c/l)}else S?D=Ct(Math.abs(_[0]-E[0]-R),h,1)/o:k=Ct(Math.abs(_[1]-E[1]-I),c,1)/l;const K=z._round(o*D),q=z._round(l*k);C=p(...v(K,q));const Y=T-C[0],J=P-C[1];i(this,Je)||f(this,Je,[this.x,this.y,this.width,this.height]),this.width=K,this.height=q,this.x=Y,this.y=J,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Am=function(){var t;f(this,ji,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=i(this,Et))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},wm=function(t,e,s){let r=.7*(s/e)+1-.7;
2if(r===1)return;const a=b(this,U,Dd).call(this,this.rotation),o=(T,P)=>[a[0]*T+a[2]*P,a[1]*T+a[3]*P],[l,h]=this.parentDimensions,c=this.x,d=this.y,p=this.width,m=this.height,y=z.MIN_SIZE/l,A=z.MIN_SIZE/h;r=Math.max(Math.min(r,1/p,1/m),y/p,A/m);const v=z._round(p*r),w=z._round(m*r);if(v===p&&w===m)return;i(this,Je)||f(this,Je,[c,d,p,m]);const S=o(p/2,m/2),E=z._round(c+S[0]),_=z._round(d+S[1]),C=o(v/2,w/2);this.x=E-C[0],this.y=_-C[1],this.width=v,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},vm=function(){var t;(t=i(this,Et))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,U,Id).call(this)},Of=function(t){const{isMac:e}=Wt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Sm=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,Yn,null),f(this,Xr,!1),this._uiManager.endDragSession()||b(this,U,Of).call(this,h),s&&this._onStopDragging()};e&&(f(this,Uo,t.clientX),f(this,Go,t.clientY),f(this,Yn,t.pointerId),f(this,Jh,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:p}=h;if(p!==i(this,Yn)){Pt(h);return}const[m,y]=this.screenToPageTranslation(c-i(this,Uo),d-i(this,Go));f(this,Uo,c),f(this,Go,d),this._uiManager.dragSelectedEditors(m,y)},a),window.addEventListener("touchmove",Pt,a),window.addEventListener("pointerdown",h=>{h.pointerType===i(this,Jh)&&(i(this,Kr)||h.isPrimary)&&o(h),Pt(h)},a));const l=h=>{if(!i(this,Yn)||i(this,Yn)===h.pointerId){o(h);return}Pt(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Nf=function(){if(i(this,Kn)||!this.div)return;f(this,Kn,new AbortController);const t=this._uiManager.combinedSignal(i(this,Kn));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Em=function(t){z._resizerKeyboardManager.exec(this,t)},_m=function(t){var e;i(this,Vi)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==i(this,le)&&b(this,U,sh).call(this)},Cm=function(t){f(this,Zh,i(this,Vi)?t:"")},Bf=function(t){if(i(this,Hs))for(const e of i(this,Hs))e.tabIndex=t},sh=function(){f(this,Vi,!1),b(this,U,Bf).call(this,-1),b(this,U,Id).call(this)},g(z,sc),x(z,"_l10n",null),x(z,"_l10nResizer",null),x(z,"_borderLineWidth",-1),x(z,"_colorManager",new Tf),x(z,"_zIndex",1),x(z,"_telemetryTimeout",1e3);let yt=z;class Ny extends yt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ag=3285377520,ys=4294901760,si=65535;class Hf{constructor(t){this.h1=t?t&4294967295:Ag,this.h2=t?t&4294967295:Ag}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let A=0,v=t.length;A<v;A++){const w=t.charCodeAt(A);w<=255?e[s++]=w:(e[s++]=w>>>8,e[s++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const n=s>>2,r=s-n*4,a=new Uint32Array(e.buffer,0,n);let o=0,l=0,h=this.h1,c=this.h2;const d=3432918353,p=461845907,m=d&si,y=p&si;for(let A=0;A<n;A++)A&1?(o=a[A],o=o*d&ys|o*m&si,o=o<<15|o>>>17,o=o*p&ys|o*y&si,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[A],l=l*d&ys|l*m&si,l=l<<15|l>>>17,l=l*p&ys|l*y&si,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=e[n*4+2]<<16;case 2:o^=e[n*4+1]<<8;case 1:o^=e[n*4],o=o*d&ys|o*m&si,o=o<<15|o>>>17,o=o*p&ys|o*y&si,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&ys|t*36045&si,e=e*4283543511&ys|((e<<16|t>>>16)*2950163797&ys)>>>16,t^=e>>>1,t=t*444984403&ys|t*60499&si,e=e*3301882366&ys|((e<<16|t>>>16)*3120437893&ys)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Th=Object.freeze({map:null,hash:"",transfer:void 0});var qr,Qr,Wi,he,Tu,Tm;class Qp{constructor(){g(this,Tu);g(this,qr,!1);g(this,Qr,null);g(this,Wi,null);g(this,he,new Map);x(this,"onSetModified",null);x(this,"onResetModified",null);x(this,"onAnnotationEditor",null)}getValue(t,e){const s=i(this,he).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return i(this,he).get(t)}remove(t){var s;const e=i(this,he).get(t);e!==void 0&&(e instanceof yt&&i(this,Wi).delete(e.annotationElementId),i(this,he).delete(t),i(this,he).size===0&&this.resetModified(),!i(this,he).values().some(n=>n instanceof yt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=i(this,he).get(t);let n=!1;
2if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(n=!0,s[a]=o);else n=!0,i(this,he).set(t,e);n&&b(this,Tu,Tm).call(this),e instanceof yt&&((i(this,Wi)||f(this,Wi,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return i(this,he).has(t)}get size(){return i(this,he).size}resetModified(){var t;i(this,qr)&&(f(this,qr,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new xm(this)}get serializable(){if(i(this,he).size===0)return Th;const t=new Map,e=new Hf,s=[],n=Object.create(null);let r=!1;for(const[a,o]of i(this,he)){const l=o instanceof yt?o.serialize(!1,n):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),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}:Th}get editorStats(){let t=null;const e=new Map;let s=0,n=0;for(const r of i(this,he).values()){if(!(r instanceof yt)){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;const d=l.getOrInsertComputed(h,Wp);d.set(c,(d.get(c)??0)+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,Qr,null)}updateEditor(t,e){var n;const s=(n=i(this,Wi))==null?void 0:n.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=i(this,Wi))==null?void 0:e.get(t))||null}get modifiedIds(){if(i(this,Qr))return i(this,Qr);const t=[];if(i(this,Wi))for(const s of i(this,Wi).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Hf;s.update(t.join(",")),e=s.hexdigest()}return f(this,Qr,{ids:new Set(t),hash:e})}[Symbol.iterator](){return i(this,he).entries()}}qr=new WeakMap,Qr=new WeakMap,Wi=new WeakMap,he=new WeakMap,Tu=new WeakSet,Tm=function(){var t;i(this,qr)||(f(this,qr,!0),(t=this.onSetModified)==null||t.call(this))};var ic;class xm extends Qp{constructor(e){super();g(this,ic,Th);const{serializable:s}=e;if(s===Th)return;const{map:n,hash:r,transfer:a}=s,o=structuredClone(n,a?{transfer:a}:null);f(this,ic,{map:o,hash:r,transfer:[]})}get print(){nt("Should not call PrintAnnotationStorage.print")}get serializable(){return i(this,ic)}get modifiedIds(){return $(this,"modifiedIds",{ids:new Set,hash:""})}}ic=new WeakMap;const ao="__forcedDependency",{floor:wg,ceil:vg}=Math;function Sg(u,t,e,s,n,r){u[t*4+0]=Math.min(u[t*4+0],e),u[t*4+1]=Math.min(u[t*4+1],s),u[t*4+2]=Math.max(u[t*4+2],n),u[t*4+3]=Math.max(u[t*4+3],r)}const Uf=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var $o,qn;class By{constructor(t,e){g(this,$o);g(this,qn);f(this,$o,t),f(this,qn,e)}get length(){return i(this,$o).length}isEmpty(t){return i(this,$o)[t]===Uf}minX(t){return i(this,qn)[t*4+0]/256}minY(t){return i(this,qn)[t*4+1]/256}maxX(t){return(i(this,qn)[t*4+2]+1)/256}maxY(t){return(i(this,qn)[t*4+3]+1)/256}}$o=new WeakMap,qn=new WeakMap;const Eg=(u,t)=>u==null?void 0:u.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var Xi,it,wt,Jr,Zr,ta,ve,nc,Gf;class Hy{constructor(t,e){g(this,nc);g(this,Xi,[[1,0,0,1,0,0]]);g(this,it,[-1/0,-1/0,1/0,1/0]);g(this,wt,new Float64Array(An));x(this,"_pendingBBoxIdx",-1);g(this,Jr);g(this,Zr);g(this,ta);g(this,ve);x(this,"_savesStack",[]);x(this,"_markedContentStack",[]);f(this,Jr,t.width),f(this,Zr,t.height),b(this,nc,Gf).call(this,e)}growOperationsCount(t){t>=i(this,ve).length&&b(this,nc,Gf).call(this,t,i(this,ve))}get clipBox(){return i(this,it)}save(t){return f(this,it,{__proto__:i(this,it)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(i(this,it));if(s===null)return this;f(this,it,s);const n=this._savesStack.pop();return n!==void 0&&(e==null||e(n,t),i(this,ve)[t]=i(this,ve)[n]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e==null||e(s,t),i(this,ve)[t]=i(this,ve)[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e==null||e(s,t),i(this,ve)[t]=i(this,ve)[s]),this}pushBaseTransform(t){return i(this,Xi).push(M.multiplyByDOMMatrix(i(this,Xi).at(-1),t.getTransform())),this}popBaseTransform(){return i(this,Xi).length>1&&i(this,Xi).pop(),this}
2resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,i(this,wt).set(An,0)),this}recordClipBox(t,e,s,n,r,a){const o=M.multiplyByDOMMatrix(i(this,Xi).at(-1),e.getTransform()),l=An.slice();M.axialAlignedBoundingBox([s,r,n,a],o,l);const h=M.intersect(i(this,it),l);return h?(i(this,it)[0]=h[0],i(this,it)[1]=h[1],i(this,it)[2]=h[2],i(this,it)[3]=h[3]):(i(this,it)[0]=i(this,it)[1]=1/0,i(this,it)[2]=i(this,it)[3]=-1/0),this}recordBBox(t,e,s,n,r,a){const o=i(this,it);if(o[0]===1/0)return this;const l=M.multiplyByDOMMatrix(i(this,Xi).at(-1),e.getTransform());if(o[0]===-1/0)return M.axialAlignedBoundingBox([s,r,n,a],l,i(this,wt)),this;const h=An.slice();return M.axialAlignedBoundingBox([s,r,n,a],l,h),i(this,wt)[0]=Ct(h[0],o[0],i(this,wt)[0]),i(this,wt)[1]=Ct(h[1],o[1],i(this,wt)[1]),i(this,wt)[2]=Ct(h[2],i(this,wt)[2],o[2]),i(this,wt)[3]=Ct(h[3],i(this,wt)[3],o[3]),this}recordFullPageBBox(t){return i(this,wt)[0]=Math.max(0,i(this,it)[0]),i(this,wt)[1]=Math.max(0,i(this,it)[1]),i(this,wt)[2]=Math.min(i(this,Jr),i(this,it)[2]),i(this,wt)[3]=Math.min(i(this,Zr),i(this,it)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const n=wg(i(this,wt)[0]*256/i(this,Jr)),r=wg(i(this,wt)[1]*256/i(this,Zr)),a=vg(i(this,wt)[2]*256/i(this,Jr)),o=vg(i(this,wt)[3]*256/i(this,Zr));if(Sg(i(this,ta),t,n,r,a,o),s)for(const l of s)for(const h of l)h!==t&&Sg(i(this,ta),h,n,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,i(this,it)[0]=Math.max(i(this,it)[0],i(this,wt)[0]),i(this,it)[1]=Math.max(i(this,it)[1],i(this,wt)[1]),i(this,it)[2]=Math.min(i(this,it)[2],i(this,wt)[2]),i(this,it)[3]=Math.min(i(this,it)[3],i(this,wt)[3])),this}take(){return new By(i(this,ve),i(this,ta))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,n=1,r=0,a=0,o){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}Xi=new WeakMap,it=new WeakMap,wt=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,ta=new WeakMap,ve=new WeakMap,nc=new WeakSet,Gf=function(t,e){const s=new ArrayBuffer(t*4);f(this,ta,new Uint8ClampedArray(s)),f(this,ve,new Uint32Array(s)),e&&e.length>0?(i(this,ve).set(e),i(this,ve).fill(Uf,e.length)):i(this,ve).fill(Uf)};var $e,ze,ea,Us,zo,Qn,Jn,dt;class Uy{constructor(t,e=!1){g(this,$e,{__proto__:null});g(this,ze,{__proto__:null,transform:[],moveText:[],sameLineText:[],[ao]:[]});g(this,ea,new Map);g(this,Us,new Set);g(this,zo,new Map);g(this,Qn);g(this,Jn);g(this,dt);f(this,dt,t),e&&(f(this,Qn,new Map),f(this,Jn,(s,n)=>{Eg(i(this,Qn),n).dependencies.add(s)}))}get clipBox(){return i(this,dt).clipBox}growOperationsCount(t){i(this,dt).growOperationsCount(t)}save(t){return f(this,$e,{__proto__:i(this,$e)}),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},[ao]:{__proto__:i(this,ze)[ao]}}),i(this,dt).save(t),this}restore(t){i(this,dt).restore(t,i(this,Jn));const e=Object.getPrototypeOf(i(this,$e));return e===null?this:(f(this,$e,e),f(this,ze,Object.getPrototypeOf(i(this,ze))),this)}recordOpenMarker(t){return i(this,dt).recordOpenMarker(t,i(this,Jn)),this}getOpenMarker(){return i(this,dt).getOpenMarker()}recordCloseMarker(t){return i(this,dt).recordCloseMarker(t,i(this,Jn)),this}beginMarkedContent(t){return i(this,dt).beginMarkedContent(t),this}endMarkedContent(t){return i(this,dt).endMarkedContent(t,i(this,Jn)),this}pushBaseTransform(t){return i(this,dt).pushBaseTransform(t),this}popBaseTransform(){return i(this,dt).popBaseTransform(),this}recordSimpleData(t,e){return i(this,$e)[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,$e)[t]=i(this,ea).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ao,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in i(this,$e)&&this.recordFutureForcedDependency(e,i(this,$e)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of i(this,Us))this.recordFutureForcedDependency(ao,t);return this}resetBBox(t){return i(this,dt).resetBBox(t),this}recordClipBox(t,e,s,n,r,a){return i(this,dt).recordClipBox(t,e,s,n,r,a),this}recordBBox(t,e,s,n,r,a){return i(this,dt).recordBBox(t,e,s,n,r,a),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,zo).get(s),h!==!1&&(c=[0,0,0,0],M.axialAlignedBoundingBox(l,s.fontMatrix,c),(n!==1||r!==0||a!==0)&&M.scaleMinMax([n,0,0,-n,r,a
2],c),h)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(t);const d=o();return l&&c&&h===void 0&&(h=c[0]<=r-d.actualBoundingBoxLeft&&c[2]>=r+d.actualBoundingBoxRight&&c[1]<=a-d.actualBoundingBoxAscent&&c[3]>=a+d.actualBoundingBoxDescent,i(this,zo).set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return i(this,dt).recordFullPageBBox(t),this}getSimpleIndex(t){return i(this,$e)[t]}recordDependencies(t,e){const s=i(this,Us),n=i(this,$e),r=i(this,ze);for(const a of e)a in i(this,$e)?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,Us).add(i(this,ea).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ao]),i(this,Qn)){const n=Eg(i(this,Qn),t),{dependencies:r}=n;i(this,Us).forEach(r.add,r),i(this,dt)._savesStack.forEach(r.add,r),i(this,dt)._markedContentStack.forEach(r.add,r),r.delete(t),n.isRenderingOperation=!0}const s=!e&&t===i(this,dt)._pendingBBoxIdx;return i(this,dt).recordOperation(t,e,[i(this,Us),i(this,dt)._savesStack,i(this,dt)._markedContentStack]),s&&i(this,Us).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(i(this,Us));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const n of s)this.recordIncrementalData("sameLineText",n);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===i(this,dt)._pendingBBoxIdx;return i(this,dt).bboxToClipBoxDropOperation(t),s&&i(this,Us).clear(),this}take(){return i(this,zo).clear(),i(this,dt).take()}takeDebugMetadata(){return i(this,Qn)}}$e=new WeakMap,ze=new WeakMap,ea=new WeakMap,Us=new WeakMap,zo=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,dt=new WeakMap;var ut,Rt,Gs,jo,Vo;const rg=class rg{constructor(t,e,s){g(this,ut);g(this,Rt);g(this,Gs);g(this,jo,0);g(this,Vo,0);if(t instanceof rg&&i(t,Gs)===!!s)return t;f(this,ut,t),f(this,Rt,e),f(this,Gs,!!s)}get clipBox(){return i(this,ut).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return $t(this,Vo)._++,i(this,ut).save(i(this,Rt)),this}restore(t){return i(this,Vo)>0&&(i(this,ut).restore(i(this,Rt)),$t(this,Vo)._--),this}recordOpenMarker(t){return $t(this,jo)._++,this}getOpenMarker(){return i(this,jo)>0?i(this,Rt):i(this,ut).getOpenMarker()}recordCloseMarker(t){return $t(this,jo)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return i(this,ut).pushBaseTransform(t),this}popBaseTransform(){return i(this,ut).popBaseTransform(),this}recordSimpleData(t,e){return i(this,ut).recordSimpleData(t,i(this,Rt)),this}recordIncrementalData(t,e){return i(this,ut).recordIncrementalData(t,i(this,Rt)),this}resetIncrementalData(t,e){return i(this,ut).resetIncrementalData(t,i(this,Rt)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return i(this,ut).recordSimpleDataFromNamed(t,e,i(this,Rt)),this}recordFutureForcedDependency(t,e){return i(this,ut).recordFutureForcedDependency(t,i(this,Rt)),this}inheritSimpleDataAsFutureForcedDependencies(t){return i(this,ut).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return i(this,ut).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return i(this,Gs)||i(this,ut).resetBBox(i(this,Rt)),this}recordClipBox(t,e,s,n,r,a){return i(this,Gs)||i(this,ut).recordClipBox(i(this,Rt),e,s,n,r,a),this}recordBBox(t,e,s,n,r,a){return i(this,Gs)||i(this,ut).recordBBox(i(this,Rt),e,s,n,r,a),this}recordCharacterBBox(t,e,s,n,r,a,o){return i(this,Gs)||i(this,ut).recordCharacterBBox(i(this,Rt),e,s,n,r,a,o),this}recordFullPageBBox(t){return i(this,Gs)||i(this,ut).recordFullPageBBox(i(this,Rt)),this}getSimpleIndex(t){return i(this,ut).getSimpleIndex(t)}recordDependencies(t,e){return i(this,ut).recordDependencies(i(this,Rt),e),this}recordNamedDependency(t,e){return i(this,ut).recordNamedDependency(i(this,Rt),e),this}recordOperation(t){return i(this,ut).recordOperation(i(this,Rt),!0),this}recordShowTextOperation(t){return i(this,ut).recordShowTextOperation(i(this,Rt),!0),this}bboxToClipBoxDropOperation(t){return i(this,Gs)||i(this,ut).bboxToClipBoxDropOperation(i(this,Rt),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};ut=new WeakMap,Rt=new WeakMap,Gs=new WeakMap,jo=new WeakMap,Vo=new WeakMap;let xh=rg;const As={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"]};var sa,ia,na,ra,aa,rc;const Sh=class Sh{constructor(t){g(this,sa);g(this,ia);g(this,na,4);g(this,ra,0);g(this,aa,new(i(Sh,rc))(i(this,na)*6));f(this,sa,t.width),f(this,ia,t.height)}record(t,e,s,n){if(i(this,ra)===i(this,na)){f(this,na,i(this,na)*2);const o=new(i(Sh,rc))(i(this,na)*6);o.set(i(this,aa)),f(this,aa,o)}const r=M.domMatrixToTransform(t.getTransform());let a;if(n[0]!==1/0){const o=An.slice();M.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=M.intersect(n,o);if(!l)return;const[h,c,d,p]=l;if(h!==o[0]||c!==o[1]||d!==o[2]||p!==o[3]){const m=Math.atan2(r[1],r[0]),y=Math.abs(Math.sin(m)),A=Math.abs(Math.cos(m));if(y<1e-6||A<1e-6||Math.abs(y-A)<1e-6)a=[h,c,h,p,d,c];else{const v=d-h,w=p-c,S=y*y,E=A*A,_=A*y,C=E-S,T=(w*E-v*_)/C,P=(w*_-v*S)/C;a=[h+P,c,h,c+T,d,p-T]}}}a||(a=[0,-s,0,0,e,-s],M.applyTransform(a,r,0),M.applyTransform(a,r,2),M.applyTransform(a,r,4)),a[0]/=i(this,sa),a[1]/=i(this,ia),a[2]/=i(this,sa),a[3]/=i(this,ia),a[4]/=i(this,sa),a[5]/=i(this,ia),i(this,aa).set(a,i(this,ra)*6),$t(this,ra)._++}take(){return i(this,aa).subarray(0,i(this,ra)*6)}};sa=new WeakMap,ia=new WeakMap,na=new WeakMap,ra=new WeakMap,aa=new WeakMap,rc=new WeakMap,g(Sh,rc,Wt.isFloat16ArraySupported?Float16Array:Float32Array);let $f=Sh;var Wo;class Gy{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){g(this,Wo,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,Wo).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||i(this,Wo).has(t.loadedName))){if(kt(!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,Wo).add(n),s==null||s(t)}catch{j(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}nt("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 j(`Failed to load font '${s.family}': '${n}'.`),t.disableFontFace=!0,n}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const n=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,n)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return $(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return $(this,"isSyncFontLoadingSupported",ps||Wt.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(kt(!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 $(this,"_loadTestFont",t)}
2_prepareFontLoadEvent(t,e){function s(C,T){return C.charCodeAt(T)<<24|C.charCodeAt(T+1)<<16|C.charCodeAt(T+2)<<8|C.charCodeAt(T+3)&255}function n(C){return String.fromCharCode(C>>24&255,C>>16&255,C>>8&255,C&255)}function r(C,T,P,D){const k=C.substring(0,T),R=C.substring(T+P);return k+D+R}let a,o;const l=this._document.createElement("canvas");l.width=1,l.height=1;const h=l.getContext("2d");let c=0;function d(C,T){if(++c>30){j("Load test font never loaded."),T();return}if(h.font="30px "+C,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0){T();return}setTimeout(d.bind(null,C,T))}const p=`lt${Date.now()}${this.loadTestFontId++}`;let m=this._loadTestFont;m=r(m,976,p.length,p);const A=16,v=1482184792;let w=s(m,A);for(a=0,o=p.length-3;a<o;a+=4)w=w-v+s(p,a)|0;a<p.length&&(w=w-v+s(p+"XXX",a)|0),m=r(m,A,4,n(w));const S=`url(data:font/opentype;base64,${btoa(m)});`,E=`@font-face {font-family:"${p}";src:${S}}`;this.insertRule(E);const _=this._document.createElement("div");_.style.visibility="hidden",_.style.width=_.style.height="10px",_.style.position="absolute",_.style.top=_.style.left="0px";for(const C of[t.loadedName,p]){const T=this._document.createElement("span");T.textContent="Hi",T.style.fontFamily=C,_.append(T)}this._document.body.append(_),d(p,()=>{_.remove(),e.complete()})}}Wo=new WeakMap;var ft;class $y{constructor(t,e=null,s,n){x(this,"compiledGlyphs",Object.create(null));g(this,ft);f(this,ft,t),this._inspectFont=e,s&&(this.charProcOperatorList=s),n&&Object.assign(this,n)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let n;try{n=t.get(s)}catch(a){j(`getPathGenerator - ignoring character: "${a}".`)}const r=Xg(n==null?void 0:n.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return i(this,ft).black}get bold(){return i(this,ft).bold}get disableFontFace(){return i(this,ft).disableFontFace}set disableFontFace(t){$(this,"disableFontFace",!!t)}get fontExtraProperties(){return i(this,ft).fontExtraProperties}get isInvalidPDFjsFont(){return i(this,ft).isInvalidPDFjsFont}get isType3Font(){return i(this,ft).isType3Font}get italic(){return i(this,ft).italic}get missingFile(){return i(this,ft).missingFile}get remeasure(){return i(this,ft).remeasure}get vertical(){return i(this,ft).vertical}get ascent(){return i(this,ft).ascent}get defaultWidth(){return i(this,ft).defaultWidth}get descent(){return i(this,ft).descent}get bbox(){return i(this,ft).bbox}get fontMatrix(){return i(this,ft).fontMatrix}get fallbackName(){return i(this,ft).fallbackName}get loadedName(){return i(this,ft).loadedName}get mimetype(){return i(this,ft).mimetype}get name(){return i(this,ft).name}get data(){return i(this,ft).data}clearData(){i(this,ft).clearData()}get cssFontInfo(){return i(this,ft).cssFontInfo}get systemFontInfo(){return i(this,ft).systemFontInfo}get defaultVMetrics(){return i(this,ft).defaultVMetrics}}ft=new WeakMap;class Pm{}x(Pm,"strings",["fontFamily","fontWeight","italicAngle"]);class km{}x(km,"strings",["css","loadedName","baseFontName","src"]);const ye=class ye{};x(ye,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),x(ye,"numbers",["ascent","defaultWidth","descent"]),x(ye,"strings",["fallbackName","loadedName","mimetype","name"]),x(ye,"OFFSET_NUMBERS",Math.ceil(ye.bools.length*2/8)),x(ye,"OFFSET_BBOX",ye.OFFSET_NUMBERS+ye.numbers.length*8),x(ye,"OFFSET_FONT_MATRIX",ye.OFFSET_BBOX+1+2*4),x(ye,"OFFSET_DEFAULT_VMETRICS",ye.OFFSET_FONT_MATRIX+1+8*6),x(ye,"OFFSET_STRINGS",ye.OFFSET_DEFAULT_VMETRICS+1+2*3);let Ye=ye;class Fe{}x(Fe,"KIND",0),x(Fe,"HAS_BBOX",1),x(Fe,"HAS_BACKGROUND",2),x(Fe,"SHADING_TYPE",3),x(Fe,"N_COORD",4),x(Fe,"N_COLOR",8),x(Fe,"N_STOP",12),x(Fe,"N_FIGURES",16);var ac,xu,Xo,Yo,Ld;class zy{constructor(t){g(this,Yo);g(this,ac);g(this,xu,new TextDecoder);g(this,Xo);f(this,ac,t),f(this,Xo,new DataView(t))}get fontFamily(){return b(this,Yo,Ld).call(this,0)}get fontWeight(){return b(this,Yo,Ld).call(this,1)}get italicAngle(){return b(this,Yo,Ld).call(this,2)}}ac=new WeakMap,xu=new WeakMap,Xo=new WeakMap,Yo=new WeakSet,Ld=function(t){kt(t<Pm.strings.length,"Invalid string index");let e=0;for(let n=0;n<t;n++)e+=i(this,Xo).getUint32(e)+4;const s=i(this,Xo).getUint32(e);return i(this,xu).decode(new Uint8Array(i(this,ac),e+4,s))};var oa,Ko,fi,la,ih;
2class jy{constructor(t){g(this,la);g(this,oa);g(this,Ko,new TextDecoder);g(this,fi);f(this,oa,t),f(this,fi,new DataView(t))}get guessFallback(){return i(this,fi).getUint8(0)!==0}get css(){return b(this,la,ih).call(this,0)}get loadedName(){return b(this,la,ih).call(this,1)}get baseFontName(){return b(this,la,ih).call(this,2)}get src(){return b(this,la,ih).call(this,3)}get style(){let t=1;t+=4+i(this,fi).getUint32(t);const e=i(this,fi).getUint32(t),s=i(this,Ko).decode(new Uint8Array(i(this,oa),t+4,e));t+=4+e;const n=i(this,fi).getUint32(t),r=i(this,Ko).decode(new Uint8Array(i(this,oa),t+4,n));return{style:s,weight:r}}}oa=new WeakMap,Ko=new WeakMap,fi=new WeakMap,la=new WeakSet,ih=function(t){kt(t<km.strings.length,"Invalid string index");let e=5;for(let n=0;n<t;n++)e+=i(this,fi).getUint32(e)+4;const s=i(this,fi).getUint32(e);return i(this,Ko).decode(new Uint8Array(i(this,oa),e+4,s))};var $s,Pu,Ht,lt,Os,Rd,Fd,nh,zf;class Vy{constructor({buffer:t,extra:e}){g(this,lt);g(this,$s);g(this,Pu,new TextDecoder);g(this,Ht);f(this,$s,t),f(this,Ht,new DataView(t)),e&&Object.assign(this,e)}get black(){return b(this,lt,Os).call(this,0)}get bold(){return b(this,lt,Os).call(this,1)}get disableFontFace(){return b(this,lt,Os).call(this,2)}get fontExtraProperties(){return b(this,lt,Os).call(this,3)}get isInvalidPDFjsFont(){return b(this,lt,Os).call(this,4)}get isType3Font(){return b(this,lt,Os).call(this,5)}get italic(){return b(this,lt,Os).call(this,6)}get missingFile(){return b(this,lt,Os).call(this,7)}get remeasure(){return b(this,lt,Os).call(this,8)}get vertical(){return b(this,lt,Os).call(this,9)}get ascent(){return b(this,lt,Rd).call(this,0)}get defaultWidth(){return b(this,lt,Rd).call(this,1)}get descent(){return b(this,lt,Rd).call(this,2)}get bbox(){return b(this,lt,Fd).call(this,Ye.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return b(this,lt,Fd).call(this,Ye.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return b(this,lt,Fd).call(this,Ye.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return b(this,lt,nh).call(this,0)}get loadedName(){return b(this,lt,nh).call(this,1)}get mimetype(){return b(this,lt,nh).call(this,2)}get name(){return b(this,lt,nh).call(this,3)}get data(){const{offset:t,length:e}=b(this,lt,zf).call(this);return e===0?void 0:new Uint8Array(i(this,$s),t+4,e)}clearData(){const{offset:t,length:e}=b(this,lt,zf).call(this);e!==0&&(i(this,Ht).setUint32(t,0),f(this,$s,new Uint8Array(i(this,$s),0,t+4).slice().buffer),f(this,Ht,new DataView(i(this,$s))))}get cssFontInfo(){let t=Ye.OFFSET_STRINGS;const e=i(this,Ht).getUint32(t);t+=4+e;const s=i(this,Ht).getUint32(t);t+=4+s;const n=i(this,Ht).getUint32(t);if(n===0)return null;const r=new Uint8Array(n);return r.set(new Uint8Array(i(this,$s),t+4,n)),new zy(r.buffer)}get systemFontInfo(){let t=Ye.OFFSET_STRINGS;const e=i(this,Ht).getUint32(t);t+=4+e;const s=i(this,Ht).getUint32(t);if(s===0)return null;const n=new Uint8Array(s);return n.set(new Uint8Array(i(this,$s),t+4,s)),new jy(n.buffer)}}$s=new WeakMap,Pu=new WeakMap,Ht=new WeakMap,lt=new WeakSet,Os=function(t){kt(t<Ye.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,n=i(this,Ht).getUint8(e)>>s&3;return n===0?void 0:n===2},Rd=function(t){return kt(t<Ye.numbers.length,"Invalid number index"),i(this,Ht).getFloat64(Ye.OFFSET_NUMBERS+t*8)},Fd=function(t,e,s,n){const r=i(this,Ht).getUint8(t);if(r===0)return;kt(r===e,"Invalid array length."),t+=1;const a=new Array(r);for(let o=0;o<r;o++)a[o]=i(this,Ht)[s](t,!0),t+=n;return a},nh=function(t){kt(t<Ye.strings.length,"Invalid string index");let e=Ye.OFFSET_STRINGS+4;for(let n=0;n<t;n++)e+=i(this,Ht).getUint32(e)+4;const s=i(this,Ht).getUint32(e);return i(this,Pu).decode(new Uint8Array(i(this,$s),e+4,s))},zf=function(){let t=Ye.OFFSET_STRINGS;const e=i(this,Ht).getUint32(t);t+=4+e;const s=i(this,Ht).getUint32(t);t+=4+s;const n=i(this,Ht).getUint32(t);t+=4+n;const r=i(this,Ht).getUint32(t);return{offset:t,length:r}};class Wy{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[Fe.KIND],s=!!this.data[Fe.HAS_BBOX],n=!!this.data[Fe.HAS_BACKGROUND],r=t.getUint32(Fe.N_COORD,!0),a=t.getUint32(Fe.N_COLOR,!0),o=t.getUint32(Fe.N_STOP,!0);let l=20;const h=new Float32Array(this.buffer,l,r*2);l+=r*8;const c=new Uint8Array(this.buffer,l,a*4);l+=a*4;const d=[];for(let y=0;y<o;++y){const A=t.getFloat32(l,!0);l+=4;
2const v=t.getUint32(l,!0);l+=4,d.push([A,`#${v.toString(16).padStart(6,"0")}`])}let p=null;if(s){p=[];for(let y=0;y<4;++y)p.push(t.getFloat32(l,!0)),l+=4}let m=null;if(n&&(m=new Uint8Array(this.buffer,l,3),l+=3),e===1)return["RadialAxial","axial",p,d,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",p,d,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(e===3){const y=this.data[Fe.SHADING_TYPE];let A=null;if(h.length>0){A=An.slice();for(let v=0,w=h.length;v<w;v+=2)M.pointBoundingBox(h[v],h[v+1],A)}return["Mesh",y,h,c,r,A,p,m]}throw new Error(`Unsupported pattern kind: ${e}`)}}var qo;class Xy{constructor(t){g(this,qo);f(this,qo,t)}get path(){return Wt.isFloat16ArraySupported?new Float16Array(i(this,qo)):new Float32Array(i(this,qo))}}qo=new WeakMap;function Yy(u){if(u instanceof URL)return u;if(typeof u=="string"){if(ps){if(/^[a-z][a-z0-9\-+.]+:/i.test(u))return new URL(u);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(u))}const t=URL.parse(u,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Ky(u){if(ps&&typeof Buffer<"u"&&u instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength)return u;if(typeof u=="string")return Ku(u);if(u instanceof ArrayBuffer||ArrayBuffer.isView(u)||typeof u=="object"&&!isNaN(u==null?void 0:u.length))return new Uint8Array(u);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Ad(u){if(typeof u!="string")return null;if(u.endsWith("/"))return u;throw new Error(`Invalid factory url: "${u}" must include trailing slash.`)}const jf=u=>typeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0,qy=u=>typeof u=="object"&&typeof(u==null?void 0:u.name)=="string",Qy=_y.bind(null,jf,qy);var Yi,ku;class Jy{constructor(){g(this,Yi,new Map);g(this,ku,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};i(this,ku).then(()=>{for(const[n]of i(this,Yi))n.call(this,s)})}addEventListener(t,e,s=null){let n=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){j("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){const s=i(this,Yi).get(e);s==null||s(),i(this,Yi).delete(e)}terminate(){for(const[,t]of i(this,Yi))t==null||t();i(this,Yi).clear()}}Yi=new WeakMap,ku=new WeakMap;const wd={DATA:1,ERROR:2},zt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function _g(){}function He(u){if(u instanceof Sr||u instanceof yf||u instanceof ug||u instanceof cu||u instanceof df)return u;switch(u instanceof Error||typeof u=="object"&&u!==null||nt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new Sr(u.message);case"InvalidPDFException":return new yf(u.message);case"PasswordException":return new ug(u.message,u.code);case"ResponseException":return new cu(u.message,u.status,u.missing);case"UnknownErrorException":return new df(u.message,u.details)}return new df(u.message,u.toString())}var Qo,Rs,Mm,Dm,Im,Od;class rh{constructor(t,e,s){g(this,Rs);g(this,Qo,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",b(this,Rs,Mm).bind(this),{signal:i(this,Qo).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:zt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{kt(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:zt.CANCEL,streamId:r,reason:He(h)}),c.promise}},s)}destroy(){var t;(t=i(this,Qo))==null||t.abort(),f(this,Qo,null)}}Qo=new WeakMap,Rs=new WeakSet,Mm=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,Rs,Im).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===wd.DATA)n.resolve(t.data);else if(t.callback===wd.ERROR)n.reject(He(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:wd.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:n,callback:wd.ERROR,callbackId:t.callbackId,reason:He(a)})});return}if(t.streamId){b(this,Rs,Dm).call(this,t);return}e(t.data)},Dm=function(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,c=1,d){if(this.isCancelled)return;const p=this.desiredSize;this.desiredSize-=c,p>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:n,stream:zt.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:n,stream:zt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){kt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:n,stream:zt.ERROR,streamId:e,reason:He(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:zt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:zt.START_COMPLETE,streamId:e,reason:He(h)})})},Im=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 zt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(He(t.reason));break;case zt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(He(t.reason));break;case zt.PULL:if(!o){r.postMessage({sourceName:s,targetName:n,stream:zt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||_g).then(function(){r.postMessage({sourceName:s,targetName:n,stream:zt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:zt.PULL_COMPLETE,streamId:e,reason:He(h)})});break;case zt.ENQUEUE:if(kt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case zt.CLOSE:if(kt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,Rs,Od).call(this,a,e);break;case zt.ERROR:kt(a,"error should have stream controller"),a.controller.error(He(t.reason)),b(this,Rs,Od).call(this,a,e);break;case zt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(He(t.reason)),b(this,Rs,Od).call(this,a,e);break;case zt.CANCEL:if(!o)break;const l=He(t.reason);Promise.try(o.onCancel||_g,l).then(function(){r.postMessage({sourceName:s,targetName:n,stream:zt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:zt.CANCEL_COMPLETE,streamId:e,reason:He(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Od=async function(t,e){var s,n,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(n=t.pullCall)==null?void 0:n.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var Mu;class Lm{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){g(this,Mu,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:nt(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const n=`${s}${e}`;return this._fetch(n,t).catch(r=>{throw new Error(`Unable to load ${i(this,Mu)[t]} data at: ${n}`)})}async _fetch(t,e){nt("Abstract method `_fetch` called.")}}Mu=new WeakMap;class Cg extends Lm{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",n=await Xp(t,s);return n instanceof Uint8Array?n:Ku(n)}}var oc;class Rm{constructor({enableHWA:t=!1}){g(this,oc,!1);f(this,oc,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,oc)})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){nt("Abstract method `_createCanvas` called.")}}oc=new WeakMap;class Zy extends Rm{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 Fm{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 ha,Jo,Ki,qi,Se,ca,da,F,be,ah,ho,Nd,co,Om,Vf,uo,oh,lh,Wf,hh;class tA extends Fm{constructor({docId:e,ownerDocument:s=globalThis.document}){super();g(this,F);g(this,ha);g(this,Jo);g(this,Ki);g(this,qi);g(this,Se);g(this,ca);g(this,da,0);f(this,qi,e),f(this,Se,s)}addFilter(e){if(!e)return"none";let s=i(this,F,be).get(e);if(s)return s;const[n,r,a]=b(this,F,Nd).call(this,e),o=e.length===1?n:`${n}${r}${a}`;if(s=i(this,F,be).get(o),s)return i(this,F,be).set(e,s),s;const l=`g_${i(this,qi)}_transfer_map_${$t(this,da)._++}
2`,h=b(this,F,co).call(this,l);i(this,F,be).set(e,h),i(this,F,be).set(o,h);const c=b(this,F,uo).call(this,l);return b(this,F,lh).call(this,n,r,a,c),h}addHCMFilter(e,s){var y;const n=`${e}-${s}`,r="base";let a=i(this,F,ah).get(r);if((a==null?void 0:a.key)===n||(a?((y=a.filter)==null||y.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},i(this,F,ah).set(r,a)),!e||!s))return a.url;const o=b(this,F,hh).call(this,e);e=M.makeHexColor(...o);const l=b(this,F,hh).call(this,s);if(s=M.makeHexColor(...l),i(this,F,ho).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let A=0;A<=255;A++){const v=A/255;h[A]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const c=h.join(","),d=`g_${i(this,qi)}_hcm_filter`,p=a.filter=b(this,F,uo).call(this,d);b(this,F,lh).call(this,c,c,c,p),b(this,F,Vf).call(this,p);const m=(A,v)=>{const w=o[A]/255,S=l[A]/255,E=new Array(v+1);for(let _=0;_<=v;_++)E[_]=w+_/v*(S-w);return E.join(",")};return b(this,F,lh).call(this,m(0,5),m(1,5),m(2,5),p),a.url=b(this,F,co).call(this,d),a.url}addAlphaFilter(e){let s=i(this,F,be).get(e);if(s)return s;const[n]=b(this,F,Nd).call(this,[e]),r=`alpha_${n}`;if(s=i(this,F,be).get(r),s)return i(this,F,be).set(e,s),s;const a=`g_${i(this,qi)}_alpha_map_${$t(this,da)._++}`,o=b(this,F,co).call(this,a);i(this,F,be).set(e,o),i(this,F,be).set(r,o);const l=b(this,F,uo).call(this,a);return b(this,F,Wf).call(this,n,l),o}addLuminosityFilter(e){let s=i(this,F,be).get(e||"luminosity");if(s)return s;let n,r;if(e?([n]=b(this,F,Nd).call(this,[e]),r=`luminosity_${n}`):r="luminosity",s=i(this,F,be).get(r),s)return i(this,F,be).set(e,s),s;const a=`g_${i(this,qi)}_luminosity_map_${$t(this,da)._++}`,o=b(this,F,co).call(this,a);i(this,F,be).set(e,o),i(this,F,be).set(r,o);const l=b(this,F,uo).call(this,a);return b(this,F,Om).call(this,l),e&&b(this,F,Wf).call(this,n,l),o}addHighlightHCMFilter(e,s,n,r,a){var S;const o=`${s}-${n}-${r}-${a}`;let l=i(this,F,ah).get(e);if((l==null?void 0:l.key)===o||(l?((S=l.filter)==null||S.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},i(this,F,ah).set(e,l)),!s||!n))return l.url;const[h,c]=[s,n].map(b(this,F,hh).bind(this));let d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),p=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[m,y]=[r,a].map(b(this,F,hh).bind(this));p<d&&([d,p,m,y]=[p,d,y,m]),i(this,F,ho).style.color="";const A=(E,_,C)=>{const T=new Array(256),P=(p-d)/C,D=E/255,k=(_-E)/(255*C);let R=0;for(let I=0;I<=C;I++){const K=Math.round(d+I*P),q=D+I*k;for(let Y=R;Y<=K;Y++)T[Y]=q;R=K+1}for(let I=R;I<256;I++)T[I]=T[R-1];return T.join(",")},v=`g_${i(this,qi)}_hcm_${e}_filter`,w=l.filter=b(this,F,uo).call(this,v);return b(this,F,Vf).call(this,w),b(this,F,lh).call(this,A(m[0],y[0],5),A(m[1],y[1],5),A(m[2],y[2],5),w),l.url=b(this,F,co).call(this,v),l.url}destroy(e=!1){var s,n,r,a;e&&((s=i(this,ca))!=null&&s.size)||((n=i(this,Ki))==null||n.parentNode.parentNode.remove(),f(this,Ki,null),(r=i(this,Jo))==null||r.clear(),f(this,Jo,null),(a=i(this,ca))==null||a.clear(),f(this,ca,null),f(this,da,0))}}ha=new WeakMap,Jo=new WeakMap,Ki=new WeakMap,qi=new WeakMap,Se=new WeakMap,ca=new WeakMap,da=new WeakMap,F=new WeakSet,be=function(){return i(this,Jo)||f(this,Jo,new Map)},ah=function(){return i(this,ca)||f(this,ca,new Map)},ho=function(){if(!i(this,Ki)){const e=i(this,Se).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,Se).createElementNS(ki,"svg");n.setAttribute("width",0),n.setAttribute("height",0),f(this,Ki,i(this,Se).createElementNS(ki,"defs")),e.append(n),n.append(i(this,Ki)),i(this,Se).body.append(e)}return i(this,Ki)},Nd=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let p=0;p<256;p++)c[p]=h[p]/255;const d=c.join(",");return[d,d,d]}const[s,n,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=n[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},co=function(e){if(i(this,ha)===void 0){f(this,ha,"");const s=i(this,Se).URL;s!==i(this,Se).baseURI&&(qu(s)?j('#createUrl: ignore "data:"-URL for performance reasons.'):f(this,ha,zg(s,"")))}return`url(${i(this,ha)}#${e})`},Om=function(e){const s=i(this,Se).createElementNS(ki,"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.a
2ppend(s)},Vf=function(e){const s=i(this,Se).createElementNS(ki,"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)},uo=function(e){const s=i(this,Se).createElementNS(ki,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),i(this,F,ho).append(s),s},oh=function(e,s,n){const r=i(this,Se).createElementNS(ki,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),e.append(r)},lh=function(e,s,n,r){const a=i(this,Se).createElementNS(ki,"feComponentTransfer");r.append(a),b(this,F,oh).call(this,a,"feFuncR",e),b(this,F,oh).call(this,a,"feFuncG",s),b(this,F,oh).call(this,a,"feFuncB",n)},Wf=function(e,s){const n=i(this,Se).createElementNS(ki,"feComponentTransfer");s.append(n),b(this,F,oh).call(this,n,"feFuncA",e)},hh=function(e){return i(this,F,ho).style.color=e,gd(getComputedStyle(i(this,F,ho)).getPropertyValue("color"))};ps&&j("Please use the `legacy` build in Node.js environments.");async function eA(u){const e=await process.getBuiltinModule("fs/promises").readFile(u);return new Uint8Array(e)}class sA extends Fm{}class iA extends Rm{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class nA extends Lm{async _fetch(t,e){return eA(t)}}const rA=`
3struct Uniforms {
4  offsetX      : f32,
5  offsetY      : f32,
6  scaleX       : f32,
7  scaleY       : f32,
8  paddedWidth  : f32,
9  paddedHeight : f32,
10  borderSize   : f32,
11  _pad         : f32,
12};
13
14@group(0) @binding(0) var<uniform> u : Uniforms;
15
16struct VertexInput {
17  @location(0) position : vec2<f32>,
18  @location(1) color    : vec4<f32>,
19};
20
21struct VertexOutput {
22  @builtin(position) position : vec4<f32>,
23  @location(0)       color    : vec3<f32>,
24};
25
26@vertex
27fn vs_main(in : VertexInput) -> VertexOutput {
28  var out : VertexOutput;
29  let cx = (in.position.x + u.offsetX) * u.scaleX;
30  let cy = (in.position.y + u.offsetY) * u.scaleY;
31  out.position = vec4<f32>(
32    ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
33    1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
34    0.0,
35    1.0
36  );
37  out.color = in.color.rgb;
38  return out;
39}
40
41@fragment
42fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
43  return vec4<f32>(in.color, 1.0);
44}
45`;var Du,Qi,ua,Zo,Iu,Nm;class aA{constructor(){g(this,Iu);g(this,Du,null);g(this,Qi,null);g(this,ua,null);g(this,Zo,null)}init(){return i(this,Du)||f(this,Du,b(this,Iu,Nm).call(this))}get isReady(){return i(this,Qi)!==null}loadMeshShader(){if(!i(this,Qi)||i(this,ua))return;const t=i(this,Qi).createShaderModule({code:rA});f(this,ua,i(this,Qi).createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:2*4,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:i(this,Zo)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,n,r,a,o,l){this.loadMeshShader();const h=i(this,Qi),{offsetX:c,offsetY:d,scaleX:p,scaleY:m}=n,y=h.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&h.queue.writeBuffer(y,0,t);const A=h.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&h.queue.writeBuffer(A,0,e);const v=h.createBuffer({size:8*4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.queue.writeBuffer(v,0,new Float32Array([c,d,p,m,a,o,l,0]));const w=h.createBindGroup({layout:i(this,ua).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:v}}]}),S=new OffscreenCanvas(a,o),E=S.getContext("webgpu");E.configure({device:h,format:i(this,Zo),alphaMode:r?"opaque":"premultiplied"});const _=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},C=h.createCommandEncoder(),T=C.beginRenderPass({colorAttachments:[{view:E.getCurrentTexture().createView(),clearValue:_,loadOp:"clear",storeOp:"store"}]});return s>0&&(T.setPipeline(i(this,ua)),T.setBindGroup(0,w),T.setVertexBuffer(0,y),T.setVertexBuffer(1,A),T.draw(s)),T.end(),h.queue.submit([C.finish()]),y.destroy(),A.destroy(),v.destroy(),S.transferToImageBitmap()}}Du=new WeakMap,Qi=new WeakMap,ua=new WeakMap,Zo=new WeakMap,Iu=new WeakSet,Nm=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();
45return e?(f(this,Zo,navigator.gpu.getPreferredCanvasFormat()),f(this,Qi,await e.requestDevice()),!0):!1}catch{return!1}};const Qu=new aA;function oA(){return Qu.init()}function lA(){return Qu.isReady}function hA(){Qu.loadMeshShader()}function cA(u,t,e,s,n,r,a,o){return Qu.draw(u,t,e,s,n,r,a,o)}const fe={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Bd(u,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],n=new Path2D;n.rect(t[0],t[1],e,s),u.clip(n)}class Jp{isModifyingCurrentTransform(){return!1}getPattern(){nt("Abstract method `getPattern` called.")}}class dA extends Jp{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,n=this._p0,r=this._p1;if(e&&(n=n.slice(),r=r.slice(),M.applyTransform(n,e),M.applyTransform(r,e)),this._type==="axial")s=t.createLinearGradient(n[0],n[1],r[0],r[1]);else if(this._type==="radial"){let a=this._r0,o=this._r1;if(e){const l=new Float32Array(2);M.singularValueDecompose2dScale(e,l),a*=l[0],o*=l[0]}s=t.createRadialGradient(n[0],n[1],a,r[0],r[1],o)}for(const a of this._colorStops)s.addColorStop(a[0],a[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,n=this._p0;e&&(s=s.slice(),n=n.slice(),M.applyTransform(s,e),M.applyTransform(n,e));let r=this._r1,a=this._r0;if(e){const h=new Float32Array(2);M.singularValueDecompose2dScale(e,h),r*=h[0],a*=h[0]}const o=t.createRadialGradient(s[0],s[1],r,n[0],n[1],a),l=this._colorStops.map(([h,c])=>[1-h,c]).reverse();for(const[h,c]of l)o.addColorStop(h,c);return o}getPattern(t,e,s,n){let r;if(n===fe.STROKE||n===fe.FILL){if(this.isOriginBased()){let p=M.transform(s,e.baseTransform);this.matrix&&(p=M.transform(p,this.matrix));const m=.001,y=Math.hypot(p[0],p[1]),A=Math.hypot(p[2],p[3]),v=(p[0]*p[2]+p[1]*p[3])/(y*A);if(Math.abs(v)<m)if(this.isRadial()){if(Math.abs(y-A)<m)return this._createGradient(t,p)}else return this._createGradient(t,p)}const a=e.current.getClippedPathBoundingBox(n,vt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=e.canvasFactory.create(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=M.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Bd(c,this._bbox),this.areConic()&&(c.fillStyle=this._createReversedGradient(c),c.fill()),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat"),e.canvasFactory.destroy(h);const d=new DOMMatrix(s);r.setTransform(d)}else this.areConic()&&(t.save(),Bd(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),Bd(t,this._bbox),r=this._createGradient(t);return r}}function uA(u,t,e,s,n,r,a,o){const l=t.coords,h=t.colors,c=u.data,d=u.width*4;let p;l[e*2+1]>l[s*2+1]&&(p=e,e=s,s=p,p=r,r=a,a=p),l[s*2+1]>l[n*2+1]&&(p=s,s=n,n=p,p=a,a=o,o=p),l[e*2+1]>l[s*2+1]&&(p=e,e=s,s=p,p=r,r=a,a=p);const m=(l[e*2]+t.offsetX)*t.scaleX,y=(l[e*2+1]+t.offsetY)*t.scaleY,A=(l[s*2]+t.offsetX)*t.scaleX,v=(l[s*2+1]+t.offsetY)*t.scaleY,w=(l[n*2]+t.offsetX)*t.scaleX,S=(l[n*2+1]+t.offsetY)*t.scaleY;if(y>=S)return;const E=h[r*4],_=h[r*4+1],C=h[r*4+2],T=h[a*4],P=h[a*4+1],D=h[a*4+2],k=h[o*4],R=h[o*4+1],I=h[o*4+2],K=Math.round(y),q=Math.round(S);let Y,J,B,H,ht,Be,me,Ce;for(let St=K;St<=q;St++){if(St<v){const Nt=St<y?0:(y-St)/(y-v);Y=m-(m-A)*Nt,J=E-(E-T)*Nt,B=_-(_-P)*Nt,H=C-(C-D)*Nt}else{let Nt;St>S?Nt=1:v===S?Nt=0:Nt=(v-St)/(v-S),Y=A-(A-w)*Nt,J=T-(T-k)*Nt,B=P-(P-R)*Nt,H=D-(D-I)*Nt}let Dt;St<y?Dt=0:St>S?Dt=1:Dt=(y-St)/(y-S),ht=m-(m-w)*Dt,Be=E-(E-k)*Dt,me=_-(_-R)*Dt,Ce=C-(C-I)*Dt;const Cr=Math.round(Math.min(Y,ht)),Te=Math.round(Math.max(Y,ht));let Xe=d*St+Cr*4;for(let Nt=Cr;Nt<=Te;Nt++)Dt=(Y-Nt)/(Y-ht),Dt<0?Dt=0:Dt>1&&(Dt=1),c[Xe++]=J-(J-Be)*Dt|0,c[Xe++]=B-(B-me)*Dt|0,c[Xe++]=H-(H-Ce)*
45Dt|0,c[Xe++]=255}}class fA extends Jp{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,hA()}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-o,c=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3)||1,p=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3)||1,m=h?h/d:1,y=c?c/p:1,A={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/m,scaleY:1/y},v=d+2*2,w=p+2*2,S=s.create(v,w);if(lA()&&this._vertexCount>48)S.context.drawImage(cA(this._posData,this._colData,this._vertexCount,A,e,v,w,2),0,0);else{const E=S.context.createImageData(d,p);if(e){const _=E.data;for(let C=0,T=_.length;C<T;C+=4)_[C]=e[0],_[C+1]=e[1],_[C+2]=e[2],_[C+3]=255}for(let _=0,C=this._vertexCount;_<C;_+=3)uA(E,A,_,_+1,_+2,_,_+1,_+2);S.context.putImageData(E,2,2)}return{canvas:S.canvas,offsetX:o-2*m,offsetY:l-2*y,scaleX:m,scaleY:y}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,n){Bd(t,this._bbox);const r=new Float32Array(2);if(n===fe.SHADING)M.singularValueDecompose2dScale(vt(t),r);else if(this.matrix){M.singularValueDecompose2dScale(this.matrix,r);const[l,h]=r;M.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=l,r[1]*=h}else M.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,n===fe.SHADING?null:this._background,e.canvasFactory);n!==fe.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY);const o=t.createPattern(a.canvas,"no-repeat");return e.canvasFactory.destroy(a),o}}class pA extends Jp{getPattern(){return"hotpink"}}function gA(u){switch(u[0]){case"RadialAxial":return new dA(u);case"Mesh":return new fA(u);case"Dummy":return new pA}throw new Error(`Unknown IR type: ${u[0]}`)}const Tg={COLORED:1,UNCOLORED:2},Lu=class Lu{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.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=n,this.patternBaseMatrix=this.matrix?M.transform(n,this.matrix):n}canSkipPatternCanvas([t,e,s,n]){const[r,a,o,l]=this.bbox,h=Math.abs(this.xstep),c=Math.abs(this.ystep);if(t>h+1e-6||e>c+1e-6)return null;const d=Math.floor((s-o)/h)+1,p=Math.ceil((s+t-r)/h)-1,m=Math.floor((n-l)/c)+1,y=Math.ceil((n+e-a)/c)-1;return p<=d&&y<=m?[d,m]:null}updatePatternDims(t,e){const s=M.inverseTransform(this.patternBaseMatrix),n=[t[0],t[1]],r=[t[2],t[3]];M.applyTransform(n,s),M.applyTransform(r,s),e[0]=Math.abs(r[0]-n[0]),e[1]=Math.abs(r[1]-n[1]),e[2]=Math.min(n[0],r[0]),e[3]=Math.min(n[1],r[1])}_renderTileCanvas(t,e,s,n){var p,m;const[r,a,o,l]=this.bbox,h=t.canvasFactory.create(s.size,n.size),c=h.context,d=this.canvasGraphicsFactory.createCanvasGraphics(c,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),c.translate(-s.scale*r,-n.scale*a),d.transform(0,s.scale,0,0,n.scale,0,0),c.save(),(p=d.dependencyTracker)==null||p.save(),this.clipBbox(d,r,a,o,l),d.baseTransform=vt(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),(m=d.dependencyTracker)==null||m.restore(),c.restore(),h}_getCombinedScales(){const t=new Float32Array(2);M.singularValueDecompose2dScale(this.matrix,t);const[e,s]=t;return M.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[n,r],a){const[o,l,h,c]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new xh(d,a)),t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(n*this.xstep,r*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const p=h-o,m=c-l,[y,A]=this._getCombinedScales(),v=this.getSizeAndScale(p,this.ctx.canvas.width,y),w=this.getSizeAndScale(m,this.ctx.canvas.height,A),S=this._renderTileCanvas(t,a,v,w);t.ctx.drawImage(S.canvas,o,l,p,m),t.canvasFactory.destroy(S)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,o,l,h,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=vt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();
45t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[s,n,r,a]=this.bbox,o=r-s,l=a-n;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),Yu("TilingType: "+this.tilingType);const[d,p]=this._getCombinedScales();let m=o,y=l,A=!1,v=!1;Math.ceil(h*d)>=Math.ceil(o*d)?m=h:A=!0,Math.ceil(c*p)>=Math.ceil(l*p)?y=c:v=!0;const w=this.getSizeAndScale(m,this.ctx.canvas.width,d),S=this.getSizeAndScale(y,this.ctx.canvas.height,p),E=this._renderTileCanvas(t,e,w,S);if(A||v){const _=E.canvas;A&&(m=h),v&&(y=c);const C=this.getSizeAndScale(m,this.ctx.canvas.width,d),T=this.getSizeAndScale(y,this.ctx.canvas.height,p),P=C.size,D=T.size,k=t.canvasFactory.create(P,D),R=k.context,I=A?Math.floor(o/h):0,K=v?Math.floor(l/c):0;for(let q=0;q<=I;q++)for(let Y=0;Y<=K;Y++)R.drawImage(_,P*q,D*Y,P,D,0,0,P,D);return t.canvasFactory.destroy(E),{canvas:k.canvas,canvasEntry:k,scaleX:C.scale,scaleY:T.scale,offsetX:s,offsetY:n}}return{canvas:E.canvas,canvasEntry:E,scaleX:w.scale,scaleY:S.scale,offsetX:s,offsetY:n}}getSizeAndScale(t,e,s){const n=Math.max(Lu.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,l=new Path2D;l.rect(e,s,a,o),M.axialAlignedBoundingBox([e,s,n,r],vt(t.ctx),t.current.minMax),t.ctx.clip(l),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){const n=t.ctx,r=t.current;switch(r.patternFill=r.patternStroke=!1,e){case Tg.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;n.fillStyle=r.fillColor=a,n.strokeStyle=r.strokeColor=o;break;case Tg.UNCOLORED:n.fillStyle=n.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new Ay(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,n,r){const a=n!==fe.SHADING?M.transform(s,this.patternBaseMatrix):s,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 e.canvasFactory.destroy(o.canvasEntry),h.setTransform(l),h}};x(Lu,"MAX_PATTERN_SIZE",3e3);let vh=Lu;function mA({src:u,srcPos:t=0,dest:e,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Wt.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,d=s&7,p=l^h,m=u.length;e=new Uint32Array(e.buffer);let y=0;for(let A=0;A<n;++A){for(const w=t+c;t<w;++t,y+=8){const S=u[t];e[y]=l^-(S>>7&1)&p,e[y+1]=l^-(S>>6&1)&p,e[y+2]=l^-(S>>5&1)&p,e[y+3]=l^-(S>>4&1)&p,e[y+4]=l^-(S>>3&1)&p,e[y+5]=l^-(S>>2&1)&p,e[y+6]=l^-(S>>1&1)&p,e[y+7]=l^-(S&1)&p}if(d===0)continue;const v=t<m?u[t++]:255;for(let w=0;w<d;++w,++y)e[y]=l^-(v>>7-w&1)&p}return{srcPos:t,destPos:y}}const xg=16,Pg=100,bA=15,kg=10,We=16,ff=new DOMMatrix,gs=new Float32Array(2);function yA(u,t){if(u._removeMirroring)throw new Error("Context is already forwarding operations.");u.__originalSave=u.save,u.__originalRestore=u.restore,u.__originalRotate=u.rotate,u.__originalScale=u.scale,u.__originalTranslate=u.translate,u.__originalTransform=u.transform,u.__originalSetTransform=u.setTransform,u.__originalResetTransform=u.resetTransform,u.__originalClip=u.clip,u.__originalMoveTo=u.moveTo,u.__originalLineTo=u.lineTo,u.__originalBezierCurveTo=u.bezierCurveTo,u.__originalRect=u.rect,u.__originalClosePath=u.closePath,u.__originalBeginPath=u.beginPath,u._removeMirroring=()=>{u.save=u.__originalSave,u.restore=u.__originalRestore,u.rotate=u.__originalRotate,u.scale=u.__originalScale,u.translate=u.__originalTranslate,u.transform=u.__originalTransform,u.setTransform=u.__originalSetTransform,u.resetTransform=u.__originalResetTransform,u.clip=u.__originalClip,u.moveTo=u.__originalMoveTo,u.lineTo=u.__originalLineTo,u.bezierCurveTo=u.__originalBezierCurveTo,u.rect=u.__originalRect,u.closePath=u.__originalClosePath,u.beginPath=u.__originalBeginPath,delete u._removeMirroring},u.save=function(){t.save(),this.__originalSave()},u.restore=function(){t.restore(),this.__originalRestore()},u.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},u.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},u.transform=function(e,s,n,r,a,o){t.transform(e,s,n,r,a,o),this.__originalTransform(e,s,n,r,a,o)},u.setTransform=function(e,s,n,r,a,o){s===void 0?(t.setTransform(e),this.__originalSetTransform(e)):(t.setTransform(e,s,n,r,a,o),this.__originalSetTransform(e,s,n,r,a,o))},u.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},u.rotate=function(e){t.rotate(e),this.__originalRotate(e)},u.clip=function(e){t.clip(e),this.__originalClip(e)},u.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},u.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},u.bezierCurveTo=function(e,s,n,r,a,o){t.bezierCurveTo(e,s,n,r,a,o),this.__originalBezierCurveTo(e,s,n,r,a,o)},u.rect=function(e,s,n,r){t.rect(e,s,n,r),this.__originalRect(e,s,n,r)},u.closePath=function(){t.closePath(),this.__originalClosePath()},u.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}function vd(u,t,e,s,n,r,a,o,l,h){const[c,d,p,m,y,A]=vt(u);
45if(d===0&&p===0){const S=a*c+y,E=Math.round(S),_=o*m+A,C=Math.round(_),T=(a+l)*c+y,P=Math.abs(Math.round(T)-E)||1,D=(o+h)*m+A,k=Math.abs(Math.round(D)-C)||1;return u.setTransform(Math.sign(c),0,0,Math.sign(m),E,C),u.drawImage(t,e,s,n,r,0,0,P,k),u.setTransform(c,d,p,m,y,A),[P,k]}if(c===0&&m===0){const S=o*p+y,E=Math.round(S),_=a*d+A,C=Math.round(_),T=(o+h)*p+y,P=Math.abs(Math.round(T)-E)||1,D=(a+l)*d+A,k=Math.abs(Math.round(D)-C)||1;return u.setTransform(0,Math.sign(d),Math.sign(p),0,E,C),u.drawImage(t,e,s,n,r,0,0,k,P),u.setTransform(c,d,p,m,y,A),[k,P]}u.drawImage(t,e,s,n,r,a,o,l,h);const v=Math.hypot(c,d),w=Math.hypot(p,m);return[v*l,w*h]}class Mg{constructor(t,e){x(this,"alphaIsShape",!1);x(this,"fontSize",0);x(this,"fontSizeScale",1);x(this,"textMatrix",null);x(this,"textMatrixScale",1);x(this,"fontMatrix",mf);x(this,"leading",0);x(this,"x",0);x(this,"y",0);x(this,"lineX",0);x(this,"lineY",0);x(this,"charSpacing",0);x(this,"wordSpacing",0);x(this,"textHScale",1);x(this,"textRenderingMode",Yt.FILL);x(this,"textRise",0);x(this,"fillColor","#000000");x(this,"strokeColor","#000000");x(this,"tilingPatternDims",null);x(this,"patternFill",!1);x(this,"patternStroke",!1);x(this,"fillAlpha",1);x(this,"strokeAlpha",1);x(this,"lineWidth",1);x(this,"activeSMask",null);x(this,"transferMaps","none");x(this,"minMax",Ir.slice());this.clipBox=new Float32Array([0,0,t,e])}clone(){var e;const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=(e=this.tilingPatternDims)==null?void 0:e.slice(),t}getPathBoundingBox(t=fe.FILL,e=null){const s=this.minMax.slice();if(t===fe.STROKE){e||nt("Stroke bounding box must include transform."),M.singularValueDecompose2dScale(e,gs);const n=gs[0]*this.lineWidth/2,r=gs[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=M.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(Ir,0)}getClippedPathBoundingBox(t=fe.FILL,e=null){return M.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Dg(u,t){if(t instanceof ImageData){u.putImageData(t,0,0);return}const e=t.height,s=t.width,n=e%We,r=(e-n)/We,a=n===0?r:r+1,o=u.createImageData(s,We);let l=0,h;const c=t.data,d=o.data;let p,m,y,A;if(t.kind===Td.GRAYSCALE_1BPP){const v=c.byteLength,w=new Uint32Array(d.buffer,0,d.byteLength>>2),S=w.length,E=s+7>>3,_=4294967295,C=Wt.isLittleEndian?4278190080:255;for(p=0;p<a;p++){for(y=p<r?We:n,h=0,m=0;m<y;m++){const T=v-l;let P=0;const D=T>E?s:T*8-7,k=D&-8;let R=0,I=0;for(;P<k;P+=8)I=c[l++],w[h++]=I&128?_:C,w[h++]=I&64?_:C,w[h++]=I&32?_:C,w[h++]=I&16?_:C,w[h++]=I&8?_:C,w[h++]=I&4?_:C,w[h++]=I&2?_:C,w[h++]=I&1?_:C;for(;P<D;P++)R===0&&(I=c[l++],R=128),w[h++]=I&R?_:C,R>>=1}for(;h<S;)w[h++]=0;u.putImageData(o,0,p*We)}}else if(t.kind===Td.RGBA_32BPP){for(m=0,A=s*We*4,p=0;p<r;p++)d.set(c.subarray(l,l+A)),l+=A,u.putImageData(o,0,m),m+=We;p<a&&(A=s*n*4,d.set(c.subarray(l,l+A)),u.putImageData(o,0,m))}else if(t.kind===Td.RGB_24BPP)for(y=We,A=s*y,p=0;p<a;p++){for(p>=r&&(y=n,A=s*y),h=0,m=A;m--;)d[h++]=c[l++],d[h++]=c[l++],d[h++]=c[l++],d[h++]=255;u.putImageData(o,0,p*We)}else throw new Error(`bad image kind: ${t.kind}`)}function Ig(u,t){if(t.bitmap){u.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,n=e%We,r=(e-n)/We,a=n===0?r:r+1,o=u.createImageData(s,We);let l=0;const h=t.data,c=o.data;for(let d=0;d<a;d++){const p=d<r?We:n;({srcPos:l}=mA({src:h,srcPos:l,dest:c,width:s,height:p,nonBlackColor:0})),u.putImageData(o,0,d*We)}}function Kl(u,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)u[s]!==void 0&&(t[s]=u[s]);u.setLineDash!==void 0&&(t.setLineDash(u.getLineDash()),t.lineDashOffset=u.lineDashOffset)}function Sd(u){u.strokeStyle=u.fillStyle="#000000",u.fillRule="nonzero",u.globalAlpha=1,u.lineWidth=1,u.lineCap="butt",u.lineJoin="miter",u.miterLimit=10,u.globalCompositeOperation="source-over",u.font="10px sans-serif",u.setLineDash!==void 0&&(u.setLineDash([]),u.lineDashOffset=0);const{filter:t}=u;t!=="none"&&t!==""&&(u.filter="none")}function Lg(u,t){if(t)return!0;M.singularValueDecompose2dScale(u,gs);const e=Math.fround(Ti.pixelRatio*Er.PDF_TO_CSS_UNITS);
45return gs[0]<=e&&gs[1]<=e}const AA=["butt","round","square"],wA=["miter","round","bevel"],vA={},Rg={};var ti,Xf,Yf,Kf;const ag=class ag{constructor(t,e,s,n,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c,d){g(this,ti);this.ctx=t,this.current=new Mg(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,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.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,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,this.imagesTracker=d??null}getObject(t,e,s=null){var n;return typeof e=="string"?((n=this.dependencyTracker)==null||n.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:n=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.transparentCanvasEntry=this.canvasFactory.create(r,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=l,this.ctx.save(),this.ctx.transform(...vt(this.compositeCtx))}this.ctx.save(),Sd(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=vt(this.ctx)}executeOperatorList(t,e,s,n,r){var w;const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>kg&&typeof s=="function",d=c?Date.now()+bA:0;let p=0;const m=this.commonObjs,y=this.objs;let A,v;for(;;){if(n!==void 0){if(l===n.nextBreakPoint)return n.breakIt(l,s),l;if(n.shouldSkip(l)){if(++l===h)return l;continue}}if(!r||r(l))if(A=o[l],v=a[l]??null,A!==Ri.dependency)v===null?this[A](l):this[A](l,...v);else for(const S of v){(w=this.dependencyTracker)==null||w.recordNamedData(S,l);const E=S.startsWith("g_")?m:y;if(!E.has(S))return E.get(S,s),l}if(l++,l===h)return l;if(c&&++p>kg){if(Date.now()>d)return s(),l;p=0}}}endDrawing(){b(this,ti,Xf).call(this);for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0,this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),b(this,ti,Yf).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,n=t.height??t.displayHeight,r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=[];let l=r,h=a,c=s,d=n;for(;l>2&&c>1||h>2&&d>1;){let w=c,S=d;l>2&&c>1&&(w=Math.ceil(c/2),l/=c/w),h>2&&d>1&&(S=Math.ceil(d/2),h/=d/S),o.push({newWidth:w,newHeight:S}),c=w,d=S}if(o.length===0)return{img:t,paintWidth:s,paintHeight:n,tmpCanvas:null};if(o.length===1){const{newWidth:w,newHeight:S}=o[0],E=this.canvasFactory.create(w,S);return E.context.drawImage(t,0,0,s,n,0,0,w,S),{img:E.canvas,paintWidth:w,paintHeight:S,tmpCanvas:E}}let p=this.canvasFactory.create(1,1),m=this.canvasFactory.create(1,1),y=s,A=n,v=t;for(const{newWidth:w,newHeight:S}of o)this.canvasFactory.reset(m,w,S),m.context.drawImage(v,0,0,y,A,0,0,w,S),[p,m]=[m,p],v=p.canvas,y=w,A=S;return this.canvasFactory.destroy(m),{img:p.canvas,paintWidth:y,paintHeight:A,tmpCanvas:p}}_createMaskCanvas(t,e){var I,K;const s=this.ctx,{width:n,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=vt(s);let h,c,d,p;if((e.bitmap||e.data)&&e.count>1){const q=e.bitmap||e.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.getOrInsertComputed(q,Wp);const Y=h.get(c);if(Y&&!o){const J=Math.round(Math.min(l[0],l[2])+l[4]),B=Math.round(Math.min(l[1],l[3])+l[5]);return(I=this.dependencyTracker)==null||I.recordDependencies(t,As.transformAndFill),{canvas:Y,offsetX:J,offsetY:B}}d=Y}
45d||(p=this.canvasFactory.create(n,r),Ig(p.context,e));let m=M.transform(l,[1/n,0,0,-1/r,0,0]);m=M.transform(m,[1,0,0,1,0,-r]);const y=Ir.slice();M.axialAlignedBoundingBox([0,0,n,r],m,y);const[A,v,w,S]=y,E=Math.round(w-A)||1,_=Math.round(S-v)||1,C=this.canvasFactory.create(E,_),T=C.context,P=A,D=v;T.translate(-P,-D),T.transform(...m);let k=null;if(!d){const q=this._scaleImage(p.canvas,ei(T));d=q.img,k=q.tmpCanvas,d!==p.canvas&&(this.canvasFactory.destroy(p),p=null),h&&o&&(h.set(c,d),k=null,p=null)}T.imageSmoothingEnabled=Lg(vt(T),e.interpolate),vd(T,d,0,0,d.width,d.height,0,0,n,r),k&&this.canvasFactory.destroy(k),p&&this.canvasFactory.destroy(p),T.globalCompositeOperation="source-in";const R=M.transform(ei(T),[1,0,0,1,-P,-D]);return T.fillStyle=o?a.getPattern(s,this,R,fe.FILL,t):a,T.fillRect(0,0,n,r),h&&!o&&h.set(c,C.canvas),(K=this.dependencyTracker)==null||K.recordDependencies(t,As.transformAndFill),{canvas:C.canvas,canvasEntry:h&&!o?null:C,offsetX:Math.round(P),offsetY:Math.round(D)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=AA[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=wA[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,n,r,a,o;for(const[l,h]of e)switch(l){case"LW":this.setLineWidth(t,h);break;case"LC":this.setLineCap(t,h);break;case"LJ":this.setLineJoin(t,h);break;case"ML":this.setMiterLimit(t,h);break;case"D":this.setDash(t,h[0],h[1]);break;case"RI":this.setRenderingIntent(t,h);break;case"FL":this.setFlatness(t,h);break;case"Font":this.setFont(t,h[0],h[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=h;break;case"ca":(n=this.dependencyTracker)==null||n.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=h;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=h?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0}_ensurePreparedSMask(t,e,s){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t,e,s))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask,this.ctx.canvas.width,this.ctx.canvas.height)}_prepareSMaskCanvas(t,e,s){const{canvas:n,subtype:r,backdrop:a,transferMap:o}=t,l=r==="Luminosity"||r==="Alpha"&&o;if(!a&&!l){this.smaskPreparedFor=t;return}let h,c,d;if(a&&l){const p=this.canvasFactory.create(e,s),m=p.context;m.drawImage(n,t.offsetX,t.offsetY),m.globalCompositeOperation="destination-atop",m.fillStyle=a,m.fillRect(0,0,e,s),m.globalCompositeOperation="source-over",h=this.canvasFactory.create(e,s);const y=h.context;y.filter=r==="Alpha"?this.filterFactory.addAlphaFilter(o):this.filterFactory.addLuminosityFilter(o),y.drawImage(p.canvas,0,0),y.filter="none",this.canvasFactory.destroy(p),c=d=0}else if(l){h=this.canvasFactory.create(n.width,n.height);const p=h.context;p.filter=r==="Alpha"?this.filterFactory.addAlphaFilter(o):this.filterFactory.addLuminosityFilter(o),p.drawImage(n,
450,0),p.filter="none",{offsetX:c,offsetY:d}=t}else{h=this.canvasFactory.create(e,s);const p=h.context;p.drawImage(n,t.offsetX,t.offsetY),p.globalCompositeOperation="destination-atop",p.fillStyle=a,p.fillRect(0,0,e,s),p.globalCompositeOperation="source-over",c=d=0}this.smaskPreparedEntry=h,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=c,this.smaskPreparedOffsetY=d}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:s}=this.ctx.canvas,n=this.canvasFactory.create(e,s);this.smaskScratchCanvas=n,this.suspendedCtx=this.ctx;const r=this.ctx=n.context;r.setTransform(this.suspendedCtx.getTransform()),Kl(this.suspendedCtx,r),yA(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask,e,s),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Kl(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}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(t[0],t[1],t[2]-t[0],t[3]-t[1]),this.ctx.restore()}composeSMask(t,e,s,n){const r=n[0],a=n[1],o=n[2]-r,l=n[3]-a;if(o===0||l===0)return;const h=this.smaskPreparedEntry;if(h){const c=r-this.smaskPreparedOffsetX,d=a-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const p=new Path2D;p.rect(r,a,o,l),s.clip(p),s.globalCompositeOperation="destination-in",s.drawImage(h.canvas,c,d,o,l,r,a,o,l),s.restore()}else this.genericComposeSMask(e.context,s,o,l,r,a,e.offsetX,e.offsetY);t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,r,a,o,l,r,a,o,l),t.restore()}genericComposeSMask(t,e,s,n,r,a,o,l){const h=t.canvas,c=r-o,d=a-l;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const p=new Path2D;p.rect(r,a,s,n),e.clip(p),e.globalCompositeOperation="destination-in",e.drawImage(h,c,d,s,n,r,a,s,n),e.restore()}save(t){var s;this.inSMaskMode&&Kl(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(Kl(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,n,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,n,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,n){let[r]=s;if(!n){r||(r=s[0]=new Path2D),e!==Ri.stroke&&e!==Ri.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(this.dependencyTracker!==null){const o=e===Ri.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-o,n[2]+o,n[1]-o,n[3]+o).recordDependencies(t,["transform"])}r instanceof Path2D||(r=s[0]=Xg(r)),M.axialAlignedBoundingBox(n,vt(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&e!==Ri.stroke&&e!==Ri.closeStroke&&this.current.fillColor instanceof vh){const o=M.intersect(this.current.clipBox,this.current.minMax);o?this.current.fillColor.updatePatternDims(o,a):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var a;const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&(r!=null&&r.getPattern)){const o=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,ei(n),fe.STROKE,t),o){const l=new Path2D;l.addPath(e,n.getTransform().invertSelf().multiplySelf(o)),e=l}
45this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);(a=this.dependencyTracker)==null||a.recordDependencies(t,As.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(fe.STROKE,vt(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var h,c,d;const n=this.ctx,r=this.current.fillColor,a=this.current.patternFill;let o=!1;const l=this.current.getClippedPathBoundingBox();if((h=this.dependencyTracker)==null||h.recordDependencies(t,As.fill),a){const p=this.current.tilingPatternDims,m=p&&r.canSkipPatternCanvas(p);if(m){r.drawPattern(this,e,this.pendingEOFill,m,t),this.pendingEOFill=!1,s&&this.consumePath(t,e,l),this.current.tilingPatternDims=null;return}const y=r.isModifyingCurrentTransform()?n.getTransform():null;if((c=this.dependencyTracker)==null||c.save(t),n.save(),n.fillStyle=r.getPattern(n,this,ei(n),fe.FILL,t),y){const A=new Path2D;A.addPath(e,n.getTransform().invertSelf().multiplySelf(y)),e=A}o=!0}this.contentVisible&&l!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),o&&(n.restore(),(d=this.dependencyTracker)==null||d.restore(t)),s&&this.consumePath(t,e,l)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var s;this.ctx.fill(e),(s=this.dependencyTracker)==null||s.recordDependencies(t,As.rawFillPath).recordOperation(t)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=vA}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Rg}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:n}=this;e!==void 0&&n.recordFutureForcedDependency("textClip",n.getOpenMarker()).recordFutureForcedDependency("textClip",t),n.recordCloseMarker(t)}if(e!==void 0){const n=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:h,path:c}of e)c&&n.addPath(c,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(h,-h));s.clip(n)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var d,p;(d=this.dependencyTracker)==null||d.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||mf,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&j("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=s,n.isType3Font)return;const a=n.loadedName||"sans-serif",o=((p=n.systemFontInfo)==null?void 0:p.css)||`"${a}", ${n.fallbackName}`;let l="normal";n.black?l="900":n.bold&&(l="bold");const h=n.italic?"italic":"normal";let c=s;s<xg?c=xg:s>Pg&&(c=Pg),this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}
45paintChar(t,e,s,n,r,a){var w,S,E,_;const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,d=l.fontSize/l.fontSizeScale,p=c&Yt.FILL_STROKE_MASK,m=!!(c&Yt.ADD_TO_PATH_FLAG),y=l.patternFill&&!h.missingFile,A=l.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||m||y||A)&&!h.missingFile&&(v=h.getPathGenerator(this.commonObjs,e)),v&&(h.disableFontFace||y||A)){o.save(),o.translate(s,n),o.scale(d,-d),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,h);let C;if(p===Yt.FILL||p===Yt.FILL_STROKE)if(r){C=o.getTransform(),o.setTransform(...r);const T=b(this,ti,Kf).call(this,v,C,r);o.fill(T)}else o.fill(v);if(p===Yt.STROKE||p===Yt.FILL_STROKE)if(a){C||(C=o.getTransform()),o.setTransform(...a);const{a:T,b:P,c:D,d:k}=C,R=M.inverseTransform(a),I=M.transform([T,P,D,k,0,0],R);M.singularValueDecompose2dScale(I,gs),o.lineWidth*=Math.max(gs[0],gs[1])/d,o.stroke(b(this,ti,Kf).call(this,v,C,a))}else o.lineWidth/=d,o.stroke(v);o.restore()}else(p===Yt.FILL||p===Yt.FILL_STROKE)&&(o.fillText(e,s,n),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,h,d,s,n,()=>o.measureText(e))),(p===Yt.STROKE||p===Yt.FILL_STROKE)&&(this.dependencyTracker&&((E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,h,d,s,n,()=>o.measureText(e)).recordDependencies(t,As.stroke)),o.strokeText(e,s,n));m&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:vt(o),x:s,y:n,fontSize:d,path:v}),(_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,h,d,s,n))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let n=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){n=!0;break}return $(this,"isFontSubpixelAAEnabled",n)}showText(t,e){var I,K,q,Y;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,As.showText).resetBBox(t),this.current.textRenderingMode&Yt.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,n=s.font;if(n.isType3Font){this.showType3Text(t,e),(I=this.dependencyTracker)==null||I.recordShowTextOperation(t);return}const r=s.fontSize;if(r===0){(K=this.dependencyTracker)==null||K.recordOperation(t);return}const a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,h=s.wordSpacing,c=s.fontDirection,d=s.textHScale*c,p=e.length,m=n.vertical,y=m?1:-1,A=n.defaultVMetrics,v=r*s.fontMatrix[0],w=s.textRenderingMode===Yt.FILL&&!n.disableFontFace&&!s.patternFill;a.save(),s.textMatrix&&a.transform(...s.textMatrix),a.translate(s.x,s.y+s.textRise),c>0?a.scale(d,-1):a.scale(d,1);let S,E;const _=s.textRenderingMode&Yt.FILL_STROKE_MASK,C=_===Yt.FILL||_===Yt.FILL_STROKE,T=_===Yt.STROKE||_===Yt.FILL_STROKE;let P=s.lineWidth;const D=s.textMatrixScale;if(D===0||P===0?T&&(P=this.getSinglePixelWidth()):P/=D,o!==1&&(a.scale(o,o),P/=o),a.lineWidth=P,C&&s.patternFill){a.save();const J=s.fillColor.getPattern(a,this,ei(a),fe.FILL,t);S=vt(a),a.restore(),a.fillStyle=J}if(T&&s.patternStroke){a.save();const J=s.strokeColor.getPattern(a,this,ei(a),fe.STROKE,t);E=vt(a),a.restore(),a.strokeStyle=J}if(n.isInvalidPDFjsFont){const J=[];let B=0;for(const ht of e)J.push(ht.unicode),B+=ht.width;const H=J.join("");if(a.fillText(H,0,0),this.dependencyTracker!==null){const ht=a.measureText(H);this.dependencyTracker.recordBBox(t,this.ctx,-ht.actualBoundingBoxLeft,ht.actualBoundingBoxRight,-ht.actualBoundingBoxAscent,ht.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=B*v*d,a.restore(),this.compose();return}let k=0,R;for(R=0;R<p;++R){const J=e[R];if(typeof J=="number"){k+=y*J*r/1e3;continue}let B=!1;const H=(J.isSpace?h:0)+l,ht=J.fontChar,Be=J.accent;let me,Ce,St=J.width;if(m){const Te=J.vmetric||A,Xe=-(J.vmetric?Te[1]:St*.5)*v,Nt=Te[2]*v;St=Te?-Te[0]:St,me=Xe/o,Ce=(k+Nt)/o}else me=k/o,Ce=0;let Dt;if(n.remeasure&&St>0){Dt=a.measureText(ht);const Te=Dt.width*1e3/r*o;if(St<Te&&this.isFontSubpixelAAEnabled){const Xe=St/Te;B=!0,a.save(),a.scale(Xe,1),me/=Xe}else St!==Te&&(me+=(St-Te)/2e3*r/o)}if(this.contentVisible&&(J.isInFont||n.missingFile)){if(w&&!Be)a.fillText(ht,me,Ce),(q
45=this.dependencyTracker)==null||q.recordCharacterBBox(t,a,Dt?{bbox:null}:n,r/o,me,Ce,()=>Dt??a.measureText(ht));else if(this.paintChar(t,ht,me,Ce,S,E),Be){const Te=me+r*Be.offset.x/o,Xe=Ce-r*Be.offset.y/o;this.paintChar(t,Be.fontChar,Te,Xe,S,E)}}const Cr=m?St*v-H*c:St*v+H*c;k+=Cr,B&&a.restore()}m?s.y-=k:s.x+=k*d,a.restore(),this.compose(),(Y=this.dependencyTracker)==null||Y.recordShowTextOperation(t)}showType3Text(t,e){const s=this.ctx,n=this.current,r=n.font,a=n.fontSize,o=n.fontDirection,l=r.vertical?1:-1,h=n.charSpacing,c=n.wordSpacing,d=n.textHScale*o,p=n.fontMatrix||mf,m=e.length,y=n.textRenderingMode===Yt.INVISIBLE;let A,v,w,S;if(y||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),n.textMatrix&&s.transform(...n.textMatrix),s.translate(n.x,n.y+n.textRise),s.scale(d,o);const E=this.dependencyTracker;for(this.dependencyTracker=E?new xh(E,t):null,A=0;A<m;++A){if(v=e[A],typeof v=="number"){S=l*v*a/1e3,this.ctx.translate(S,0),n.x+=S*d;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()):j(`Type3 character "${v.operatorListId}" is not available.`);const T=[v.width,0];M.applyTransform(T,p),w=T[0]*a+_,s.translate(w,0),n.x+=w*d}s.restore(),E&&(this.dependencyTracker=E)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,n,r,a,o){var h;const l=new Path2D;l.rect(n,r,a-n,o-r),this.ctx.clip(l),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,n,a,r,o).recordClipBox(t,this.ctx,n,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const n=this.baseTransform||vt(this.ctx),r={createCanvasGraphics:(a,o)=>new ag(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new xh(this.dependencyTracker,o,!0):null)};s=new vh(e,this.ctx,r,n)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("fillColor",t);const s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof vh?[0,0,0,0]:null}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
45setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=gA(this.getObject(t,e)),this.cachedPatterns.set(e,n)),s&&(n.matrix=s),n}shadingFill(t,e){var a;if(!this.contentVisible)return;const s=this.ctx;this.save(t);const n=this._getPattern(t,e);s.fillStyle=n.getPattern(s,this,ei(s),fe.SHADING,t);const r=ei(s);if(r){const{width:o,height:l}=s.canvas,h=Ir.slice();M.axialAlignedBoundingBox([0,0,o,l],r,h);const[c,d,p,m]=h;this.ctx.fillRect(c,d,p-c,m-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(a=this.dependencyTracker)==null||a.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,As.transform).recordDependencies(t,As.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){nt("Should not call beginInlineImage")}beginImageData(){nt("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var n;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=vt(this.ctx),s)){M.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,h=new Path2D;h.rect(r,a,o-r,l-a),this.ctx.clip(h),(n=this.dependencyTracker)==null||n.recordClipBox(t,this.ctx,r,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var y;if(!this.contentVisible)return;this.save(t);const{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);const n=this.ctx;
45if(e.isolated||Yu("TODO: Support non-isolated groups."),e.knockout&&j("Knockout groups not supported."),!e.needsIsolation&&n.globalAlpha===1&&n.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let A=new Path2D;const[v,w,S,E]=e.bbox;if(A.rect(v,w,S-v,E-w),e.matrix){const _=new Path2D;_.addPath(A,new DOMMatrix(e.matrix)),A=_}n.clip(A)}this.groupStack.push(null),this.groupLevel++;return}const r=vt(n);e.matrix&&n.transform(...e.matrix);const a=[0,0,n.canvas.width,n.canvas.height];let o;e.bbox?(o=Ir.slice(),M.axialAlignedBoundingBox(e.bbox,vt(n),o),o=M.intersect(o,a)||[0,0,0,0]):o=a;const l=Math.floor(o[0]),h=Math.floor(o[1]),c=Math.max(Math.ceil(o[2])-l,1),d=Math.max(Math.ceil(o[3])-h,1);this.current.startNewPathAndClipBox([0,0,c,d]);const p=this.canvasFactory.create(c,d);e.smask&&this.smaskGroupCanvases.push(p);const m=p.context;if(m.translate(-l,-h),m.transform(...r),!e.isolated&&!e.smask&&s&&e.needsIsolation&&(m.save(),m.setTransform(1,0,0,1,0,0),m.drawImage(n.canvas,-l,-h),m.restore()),e.bbox){let A=new Path2D;const[v,w,S,E]=e.bbox;if(A.rect(v,w,S-v,E-w),e.matrix){const _=new Path2D;_.addPath(A,new DOMMatrix(e.matrix)),A=_}m.clip(A)}e.smask&&this.smaskStack.push({canvas:p.canvas,context:m,offsetX:l,offsetY:h,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(n.setTransform(1,0,0,1,0,0),n.translate(l,h),n.save()),Kl(n,m),this.ctx=m,(y=this.dependencyTracker)==null||y.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(n),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(n),this.groupLevel++}endGroup(t,e){var r;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,n=this.groupStack.pop();if(n===null){this.restore(t);return}if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,(r=this.dependencyTracker)==null||r.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform()));else{this.ctx.restore();const a=vt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...a);const o=Ir.slice();M.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],a,o),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),this.compose(o)}}beginAnnotation(t,e,s,n,r,a){if(b(this,ti,Xf).call(this),Sd(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,M.singularValueDecompose2dScale(vt(this.ctx),gs);const{viewportScale:h}=this,c=Math.ceil(o*this.outputScaleX*h),d=Math.ceil(l*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,d);const{canvas:p,context:m}=this.annotationCanvas;this.annotationCanvasMap.set(e,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=m,this.ctx.save(),this.ctx.setTransform(gs[0],0,0,-gs[1],0,l*gs[1]),Sd(this.ctx)}else{Sd(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],o,l),this.ctx.clip(h)}}this.current=new Mg(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...n),this.transform(t,...r),this.baseTransform=vt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,ti,Yf).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){var o;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const n=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),(o=this.dependencyTracker)==null||o.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),n.restore(
45),r.canvasEntry&&this.canvasFactory.destroy(r.canvasEntry),this.compose()}paintImageMaskXObjectRepeat(t,e,s,n=0,r=0,a,o){var d,p,m;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=this.ctx;l.save();const h=vt(l);l.transform(s,n,r,a,0,0);const c=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),(d=this.dependencyTracker)==null||d.resetBBox(t);for(let y=0,A=o.length;y<A;y+=2){const v=M.transform(h,[s,n,r,a,o[y],o[y+1]]);l.drawImage(c.canvas,v[4],v[5]),(p=this.dependencyTracker)==null||p.recordBBox(t,this.ctx,v[4],v[4]+c.canvas.width,v[5],v[5]+c.canvas.height)}l.restore(),c.canvasEntry&&this.canvasFactory.destroy(c.canvasEntry),this.compose(),(m=this.dependencyTracker)==null||m.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var a,o,l;if(!this.contentVisible)return;const s=this.ctx,n=this.current.fillColor,r=this.current.patternFill;(a=this.dependencyTracker)==null||a.resetBBox(t).recordDependencies(t,As.transformAndFill);for(const h of e){const{data:c,width:d,height:p,transform:m}=h,y=this.canvasFactory.create(d,p),A=y.context;A.save();const v=this.getObject(t,c,h);Ig(A,v),A.globalCompositeOperation="source-in",A.fillStyle=r?n.getPattern(A,this,ei(s),fe.FILL,t):n,A.fillRect(0,0,d,p),A.restore(),s.save(),s.transform(...m),s.scale(1,-1),vd(s,y.canvas,0,0,d,p,0,-1,1,1),this.canvasFactory.destroy(y),(o=this.dependencyTracker)==null||o.recordBBox(t,s,0,d,0,p),s.restore()}this.compose(),(l=this.dependencyTracker)==null||l.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){j("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){j("Dependent image isn't ready yet");return}const o=a.width,l=a.height,h=[];for(let c=0,d=r.length;c<d;c+=2)h.push({transform:[s,0,0,n,r[c],r[c+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return{img:t.bitmap,canvasEntry:null};const{bitmap:e,width:s,height:n}=t,r=this.canvasFactory.create(s,n),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",{img:r.canvas,canvasEntry:r}}paintInlineImageXObject(t,e){var c;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,l=null;if(e.bitmap){const d=this.applyTransferMapsToBitmap(e);o=d.img,l=d.canvasEntry}else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)o=e;else{const d=this.canvasFactory.create(s,n);Dg(d.context,e),o=this.applyTransferMapsToCanvas(d.context),l=d}const h=this._scaleImage(o,ei(r));r.imageSmoothingEnabled=Lg(vt(r),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,r,0,s,-n,0).recordDependencies(t,As.imageXObject).recordOperation(t),(c=this.imagesTracker)==null||c.record(r,s,n,this.dependencyTracker.clipBox)),vd(r,h.img,0,0,h.paintWidth,h.paintHeight,0,-n,s,n),h.tmpCanvas&&this.canvasFactory.destroy(h.tmpCanvas),l&&this.canvasFactory.destroy(l),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,s){var o,l,h;if(!this.contentVisible)return;const n=this.ctx;let r,a=null;if(e.bitmap)r=e.bitmap;else{const c=e.width,d=e.height,p=this.canvasFactory.create(c,d);Dg(p.context,e),r=this.applyTransferMapsToCanvas(p.context),a=p}(o=this.dependencyTracker)==null||o.resetBBox(t);for(const c of s)n.save(),n.transform(...c.transform),n.scale(1,-1),vd(n,r,c.x,c.y,c.w,c.h,0,-1,1,1),(l=this.dependencyTracker)==null||l.recordBBox(t,n,0,1,-1,0),n.restore();a&&this.canvasFactory.destroy(a),(h=this.dependencyTracker)==null||h.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&((e=this.dependencyTracker)==null||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,As.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var n;(n=this.dependencyTracker)==null||n.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(n||(this.pendingClip===Rg?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=vt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:n,d:r}=this.ctx.getTransform();let a,o;if(s===0&&n===0){const l=Math.abs(e),h=Math.abs(r);if(l===h)if(t===0)a=o=1/l;else{const c=l*t;a=o=c<1?1/c:1}else if(t===0)a=1/l,o=1/h;else{const c=l*t,d=h*t;a=c<1?1/c:1,o=d<1?1/d:1}}else{const l=Math.abs(e*r-s*n),h=Math.hypot(e,s),c=Math.hypot(n,r);if(t===0)a=c/l,o=h/l;else{const d=t*l;a=c>d?c/d:1,o=h>d?h/d:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:n}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(n||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),ff.a=1/r,ff.d=1/a;const l=new Path2D;if(l.addPath(t,ff),o.length>0){const h=Math.max(r,a);
45s.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}};ti=new WeakSet,Xf=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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)},Yf=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}}},Kf=function(t,e,s){const n=new Path2D;return n.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),n};let wo=ag;for(const u in Ri)wo.prototype[u]!==void 0&&(wo.prototype[Ri[u]]=wo.prototype[u]);var lc,hc;class Ju{constructor(t,e,s){g(this,lc,null);g(this,hc,null);x(this,"_fullReader",null);x(this,"_rangeReaders",new Set);x(this,"_source",null);this._source=t,f(this,lc,e),f(this,hc,s)}get _progressiveDataLength(){var t;return((t=this._fullReader)==null?void 0:t._loaded)??0}getFullReader(){return kt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new(i(this,lc))(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new(i(this,hc))(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){var e;(e=this._fullReader)==null||e.cancel(t);for(const s of new Set(this._rangeReaders))s.cancel(t)}}lc=new WeakMap,hc=new WeakMap;class Zu{constructor(t){x(this,"onProgress",null);x(this,"_contentLength",0);x(this,"_filename",null);x(this,"_headersCapability",Promise.withResolvers());x(this,"_isRangeSupported",!1);x(this,"_isStreamingSupported",!1);x(this,"_loaded",0);x(this,"_stream",null);this._stream=t}_callOnProgress(){var t;(t=this.onProgress)==null||t.call(this,{loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){nt("Abstract method `read` called")}cancel(t){nt("Abstract method `cancel` called")}}class tf{constructor(t,e,s){x(this,"_stream",null);this._stream=t}async read(){nt("Abstract method `read` called")}cancel(t){nt("Abstract method `cancel` called")}}function SA(u){let t=!0,e=s("filename\\*","i").exec(u);if(e){e=e[1];let c=o(e);return c=unescape(c),c=l(c),c=h(c),r(c)}if(e=a(u),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(u),e){e=e[1];let c=o(e);return c=h(c),r(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function n(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const p=new TextDecoder(c,{fatal:!0}),m=Ku(d);d=p.decode(m),t=!1}catch{}}return d}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=n("utf-8",c),t&&(c=n("iso-8859-1",c))),c}function a(c){const d=[];let p;const m=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(p=m.exec(c))!==null;){let[,A,v,w]=p;if(A=parseInt(A,10),A in d){if(A===0)break;continue}d[A]=[v,w]}const y=[];for(let A=0;A<d.length&&A in d;++A){let[v,w]=d[A];w=o(w),v&&(w=unescape(w),A===0&&(w=l(w))),y.push(w)}return y.join("")}function o(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let p=0;p<d.length;++p){const m=d[p].indexOf('"');m!==-1&&(d[p]=d[p].slice(0,m),d.length=p+1),d[p]=d[p].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function l(c){const d=c.indexOf("'");if(d===-1)return c;const p=c.slice(0,d),y=c.slice(d+1).replace(/^[^']*'/,"");return n(p,y)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,p,m,y){if(m==="q"||m==="Q")return y=y.replaceAll("_"," "),y=y.replaceAll(/=([0-9a-fA-F]{2})/g,function(A,v){return String.fromCharCode(parseInt(v,16))}),n(p,y);try{y=atob(y)}catch{}return n(p,y)})}return""}function Bm(u,t){const e=new Headers;if(!u||!t||typeof t!="object")return e;for(const s in t){const n=t[s];n!==void 0&&e.append(s,n)}return e}function ef(u){var t;return((t=URL.parse(u))==null?void 0:t.origin)??null}function Hm({responseHeaders:u,isHttp:t,rangeChunkSize:e,disableRange:s}){const n={contentLength:0,isRangeSupported:!1},r=parseInt(u.get("Content-Length"),10);return!Number.isInteger(r)||(n.contentLength=r,r<=2*e)||s||!t||u.get("Accept-Ranges")!=="bytes"||(u.get("Content-Encoding")||"identity")==="identity"&&(n.isRangeSupported=!0),n}function Um(u){const t=u.get("Content-Disposition");if(t){let e=SA(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Kp(e))return e}return null}
45function sf(u,t){return new cu(`Unexpected server response (${u}) while retrieving PDF "${t.href}".`,u,u===404||u===0&&t.protocol==="file:")}function Gm(u,t){if(u!==t)throw new Error(`Expected range response-origin "${u}" to match "${t}".`)}function $m(u,t,e,s){return fetch(u,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function zm(u,t){if(u!==200&&u!==206)throw sf(u,t)}function nf(u){if(u instanceof Uint8Array)return u.buffer;if(u instanceof ArrayBuffer)return u;throw new Error(`getArrayBuffer - unexpected data: ${u}`)}class EA extends Ju{constructor(e){super(e,_A,CA);x(this,"_responseOrigin",null);const{httpHeaders:s,url:n}=e;kt(/https?:/.test(n.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Bm(!0,s)}}class _A extends Zu{constructor(e){super(e);x(this,"_abortController",new AbortController);x(this,"_reader",null);const{disableRange:s,disableStream:n,rangeChunkSize:r,url:a,withCredentials:o}=e._source;this._isStreamingSupported=!n;const l=new Headers(e.headers);$m(a,l,o,this._abortController).then(h=>{e._responseOrigin=ef(h.url),zm(h.status,a),this._reader=h.body.getReader();const c=h.headers,{contentLength:d,isRangeSupported:p}=Hm({responseHeaders:c,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=d,this._isRangeSupported=p,this._filename=Um(c),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Sr("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:nf(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class CA extends tf{constructor(e,s,n){super(e,s,n);x(this,"_abortController",new AbortController);x(this,"_readCapability",Promise.withResolvers());x(this,"_reader",null);const{url:r,withCredentials:a}=e._source,o=new Headers(e.headers);o.append("Range",`bytes=${s}-${n-1}`),$m(r,o,a,this._abortController).then(l=>{const h=ef(l.url);Gm(h,e._responseOrigin),zm(l.status,r),this._reader=l.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:nf(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function Fg(u){return u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength?u.buffer:new Uint8Array(u).buffer}function rf(){for(const u of this._requests)u.resolve({value:void 0,done:!0});this._requests.length=0}var Ru,jm;class TA extends Ju{constructor(e){super(e,xA,PA);g(this,Ru);x(this,"_progressiveDone",!1);x(this,"_queuedChunks",[]);const{pdfDataRangeTransport:s}=e,{initialData:n,progressiveDone:r}=s;if((n==null?void 0:n.length)>0){const o=Fg(n);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":b(this,Ru,jm).call(this,o.begin,o.chunk);break;case"progressiveDone":(l=this._fullReader)==null||l.progressiveDone(),this._progressiveDone=!0;break}};s.transportReady(a)}getFullReader(){const e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,s){const n=super.getRangeReader(e,s);return n&&(n.onDone=()=>this._rangeReaders.delete(n),this._source.pdfDataRangeTransport.requestDataRange(e,s)),n}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}}Ru=new WeakSet,jm=function(e,s){const n=Fg(s);if(e===void 0)this._fullReader?this._fullReader._enqueue(n):this._queuedChunks.push(n);else{const r=this._rangeReaders.keys().find(a=>a._begin===e);kt(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(n)}};var cc;class xA extends Zu{constructor(e){super(e);g(this,cc,rf.bind(this));x(this,"_done",!1);x(this,"_queuedChunks",null);x(this,"_requests",[]);const{pdfDataRangeTransport:s,disableRange:n,disableStream:r}=e._source,{length:a,contentDispositionFilename:o}=s;this._queuedChunks=e._queuedChunks||[];for(const h of this._queuedChunks)this._loaded+=h.byteLength;this._done=e._progressiveDone,this._contentLength=a,this._isStreamingSupported=!r,this._isRangeSupported=!n,Kp(o)&&(this._filename=o),this._headersCapability.resolve();const l=this._loaded;Promise.resolve().then(()=>{l>0&&this._loaded===l&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,i(this,cc).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&i(this,cc).call(this)}}cc=new WeakMap;var dc;class PA extends tf{constructor(e,s,n){super(e,s,n);g(this,dc,rf.bind(this));x(this,"onDone",null);x(this,"_begin",-1);x(this,"_done",!1);x(this,"_queuedChunk",null);x(this,"_requests",[]);this._begin=s}_enqueue(e){var s;this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),i(this,dc).call(this)),this._done=!0,(s=this.onDone)==null||s.call(this))}async read(){if(this._queuedChunk){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,i(this,dc).call(this),(s=this.onDone)==null||s.call(this)}}dc=new WeakMap;const pf=200,Og=206;function kA(u){return typeof u!="string"?u:Ku(u).buffer}var pi,Xl,Vm,Wm;class MA extends Ju{constructor(e){super(e,DA,IA);g(this,Xl);g(this,pi,new WeakMap);x(this,"_responseOrigin",null);const{httpHeaders:s,url:n}=e;this.url=n,this.isHttp=/https?:/.test(n.protocol),this.headers=Bm(this.isHttp,s)}_request(e){const s=new XMLHttpRequest,n={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};i(this,pi).set(s,n),s.open("GET",this.url),s.withCredentials=this._source.withCredentials;for(const[r,a]of this.headers)s.setRequestHeader(r,a);return this.isHttp&&"begin"in e&&"end"in e?(s.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),n.validateStatus=r=>r===Og||r===pf):n.validateStatus=r=>r===pf,s.responseType="arraybuffer",kt(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=b(this,Xl,Wm).bind(this,s),s.onprogress=b(this,Xl,Vm).bind(this,s),s.send(null),s}
45_abortRequest(e){i(this,pi).has(e)&&(i(this,pi).delete(e),e.abort())}getRangeReader(e,s){const n=super.getRangeReader(e,s);return n&&(n.onClosed=()=>this._rangeReaders.delete(n)),n}}pi=new WeakMap,Xl=new WeakSet,Vm=function(e,s){var r;const n=i(this,pi).get(e);(r=n==null?void 0:n.onProgress)==null||r.call(n,s)},Wm=function(e,s){const n=i(this,pi).get(e);if(!n||(e.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),e.readyState!==4)||!i(this,pi).has(e))return;if(i(this,pi).delete(e),e.status===0&&this.isHttp){n.onError(e.status);return}const r=e.status||pf;if(!n.validateStatus(r)){n.onError(e.status);return}const a=kA(e.response);if(r===Og){const o=e.getResponseHeader("Content-Range");/bytes (\d+)-(\d+)\/(\d+)/.test(o)?n.onDone(a):(j('Missing or invalid "Content-Range" header.'),n.onError(0))}else a?n.onDone(a):n.onError(e.status)};var uc,xi,Xm,Ym,Km,qm;class DA extends Zu{constructor(e){super(e);g(this,xi);g(this,uc,rf.bind(this));x(this,"_cachedChunks",[]);x(this,"_done",!1);x(this,"_requests",[]);x(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:b(this,xi,Xm).bind(this),onDone:b(this,xi,Ym).bind(this),onError:b(this,xi,Km).bind(this),onProgress:b(this,xi,qm).bind(this)})}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 e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e),i(this,uc).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}uc=new WeakMap,xi=new WeakSet,Xm=function(){const e=this._stream,{disableRange:s,rangeChunkSize:n}=e._source,r=this._fullRequestXhr;e._responseOrigin=ef(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?a.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(c=>{const[d,...p]=c.split(": ");return[d,p.join(": ")]}):[]),{contentLength:l,isRangeSupported:h}=Hm({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:n,disableRange:s});this._contentLength=l,this._isRangeSupported=h,this._filename=Um(o),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()},Ym=function(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&i(this,uc).call(this)},Km=function(e){this._storedError=sf(e,this._stream.url),this._headersCapability.reject(this._storedError);for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0},qm=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var fc,_n,Qm,Jm,qf;class IA extends tf{constructor(e,s,n){super(e,s,n);g(this,_n);g(this,fc,rf.bind(this));x(this,"onClosed",null);x(this,"_done",!1);x(this,"_queuedChunk",null);x(this,"_requests",[]);x(this,"_storedError",null);this._requestXhr=e._request({begin:s,end:n,onHeadersReceived:b(this,_n,Qm).bind(this),onDone:b(this,_n,Jm).bind(this),onError:b(this,_n,qf).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,i(this,fc).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}fc=new WeakMap,_n=new WeakSet,Qm=function(){var s;const e=ef((s=this._requestXhr)==null?void 0:s.responseURL);try{Gm(e,this._stream._responseOrigin)}catch(n){this._storedError=n,b(this,_n,qf).call(this,0)}},Jm=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,i(this,fc).call(this),(s=this.onClosed)==null||s.call(this)},qf=function(e){this._storedError??(this._storedError=sf(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function Zm(u,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),n=e.createReadStream(u,t);return s.toWeb(n)}class LA extends Ju{constructor(t){super(t,RA,FA);const{url:e}=t;
45kt(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class RA extends Zu{constructor(e){super(e);x(this,"_reader",null);const{disableRange:s,disableStream:n,rangeChunkSize:r,url:a}=e._source;this._isStreamingSupported=!n,process.getBuiltinModule("fs/promises").lstat(a).then(l=>{const h=Zm(a);this._reader=h.getReader();const{size:c}=l;this._contentLength=c,this._isRangeSupported=!s&&c>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Sr("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=sf(0,a)),this._headersCapability.reject(l)})}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:nf(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class FA extends tf{constructor(e,s,n){super(e,s,n);x(this,"_readCapability",Promise.withResolvers());x(this,"_reader",null);const{url:r}=e._source;try{const a=Zm(r,{start:s,end:n-1});this._reader=a.getReader(),this._readCapability.resolve()}catch(a){this._readCapability.reject(a)}}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:nf(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function OA(u){return wh(u)?EA:ps?LA:MA}var pc,gc;class bn{static get workerPort(){return i(this,pc)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");f(this,pc,t)}static get workerSrc(){return i(this,gc)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");f(this,gc,t)}}pc=new WeakMap,gc=new WeakMap,g(bn,pc,null),g(bn,gc,"");var tl,mc;class NA{constructor({parsedData:t,rawData:e}){g(this,tl);g(this,mc);f(this,tl,t),f(this,mc,e)}getRaw(){return i(this,mc)}get(t){return i(this,tl).get(t)??null}[Symbol.iterator](){return i(this,tl).entries()}}tl=new WeakMap,mc=new WeakMap;const fo=Symbol("INTERNAL");var bc,yc,Ac,el;class BA{constructor(t,{name:e,intent:s,usage:n,rbGroups:r}){g(this,bc,!1);g(this,yc,!1);g(this,Ac,!1);g(this,el,!0);f(this,bc,!!(t&fs.DISPLAY)),f(this,yc,!!(t&fs.PRINT)),this.name=e,this.intent=s,this.usage=n,this.rbGroups=r}get visible(){if(i(this,Ac))return i(this,el);if(!i(this,el))return!1;const{print:t,view:e}=this.usage;return i(this,bc)?(e==null?void 0:e.viewState)!=="OFF":i(this,yc)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==fo&&nt("Internal method `_setVisible` called."),f(this,Ac,s),f(this,el,e)}}bc=new WeakMap,yc=new WeakMap,Ac=new WeakMap,el=new WeakMap;var Zn,pt,sl,il,wc,Qf;class HA{constructor(t,e=fs.DISPLAY){g(this,wc);g(this,Zn,null);g(this,pt,new Map);g(this,sl,null);g(this,il,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,f(this,il,t.order);for(const s of t.groups)i(this,pt).set(s.id,new BA(e,s));if(t.baseState==="OFF")for(const s of i(this,pt).values())s._setVisible(fo,!1);for(const s of t.on)i(this,pt).get(s)._setVisible(fo,!0);for(const s of t.off)i(this,pt).get(s)._setVisible(fo,!1);f(this,sl,this.getHash())}}isVisible(t){if(i(this,pt).size===0)return!0;if(!t)return Yu("Optional content group not defined."),!0;if(t.type==="OCG")return i(this,pt).has(t.id)?i(this,pt).get(t.id).visible:(j(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,wc,Qf).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!i(this,pt).has(e))return j(`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 j(`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 j(`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 j(`Optional content group not found: ${e}`),!0;if(i(this,pt).get(e).visible)return!1}return!0}return j(`Unknown optional content policy ${t.policy}.`),!0}return j(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const n=i(this,pt).get(t);if(!n){j(`Optional content group not found: ${t}`);return}if(s&&e&&n.rbGroups.length)for(const a of n.rbGroups)for(const o of a)o!==t&&((r=i(this,pt).get(o))==null||r._setVisible(fo,!1,!0));n._setVisible(fo,!!e,!0),f(this,Zn,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,Zn,null)}get hasInitialVisibility(){return i(this,sl)===null||this.getHash()===i(this,sl)}getOrder(){return i(this,pt).size?i(this,il)?i(this,il).slice():[...i(this,pt).keys()]:null}getGroup(t){return i(this,pt).get(t)||null}getHash(){if(i(this,Zn)!==null)return i(this,Zn);const t=new Hf;for(const[e,s]of i(this,pt))t.update(`${e}:${s.visible}`);return f(this,Zn,t.hexdigest())}[Symbol.iterator](){return i(this,pt).entries()}}Zn=new WeakMap,pt=new WeakMap,sl=new WeakMap,il=new WeakMap,wc=new WeakSet,Qf=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=b(this,wc,Qf).call(this,r);else if(i(this,pt).has(r))a=i(this,pt).get(r).visible;else return j(`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"};var Ut,zs,ce,fa,gi,_e,ch,dh,Hd;class UA{constructor(){g(this,_e);g(this,Ut,null);g(this,zs,null);g(this,ce,0);g(this,fa,null);g(this,gi,null)}get pagesNumber(){return i(this,ce)}set pagesNumber(t){i(this,ce)!==t&&(f(this,ce,t),f(this,Ut,null),f(this,zs,null))}movePages(t,e,s){b(this,_e,ch).call(this);const n=i(this,Ut),r=b(this,_e,dh).call(this),a=e.length,o=new Uint32Array(a);let l=0;for(let p=0;p<a;p++){const m=e[p]-1;o[p]=n[m],m<s&&l++}const h=i(this,ce),c=h-a,d=Ct(s-l,0,c);for(let p=0,m=0;p<h;p++)t.has(p+1)||(n[m++]=n[p]);n.copyWithin(d+a,d,c),n.set(o,d),b(this,_e,Hd).call(this,r),n.every((p,m)=>p===m+1)&&f(this,Ut,null)}deletePages(t){b(this,_e,ch).call(this);const e=i(this,Ut),s=b(this,_e,dh).call(this);f(this,gi,{pageNumberToId:e.slice(),pagesNumber:i(this,ce),prevPageNumbers:i(this,zs).slice()});const n=i(this,ce)-t.length;f(this,ce,n);const r=f(this,Ut,new Uint32Array(n));f(this,zs,new Int32Array(n));let a=0,o=0;for(const l of t){const h=l-1;h!==a&&(r.set(e.subarray(a,h),o),o+=h-a),a=h+1}a<e.length&&r.set(e.subarray(a),o),b(this,_e,Hd).call(this,s,new Set(t))}cancelDelete(){i(this,gi)&&(f(this,Ut,i(this,gi).pageNumberToId),f(this,ce,i(this,gi).pagesNumber),f(this,zs,i(this,gi).prevPageNumbers),f(this,gi,null))}cleanSavedData(){f(this,gi,null)}copyPages(t){b(this,_e,ch).call(this),f(this,fa,{pageNumbers:t,pageIds:t.map(e=>i(this,Ut)[e-1])})}cancelCopy(){f(this,fa,null)}pastePages(t){b(this,_e,ch).call(this);const e=i(this,Ut),s=b(this,_e,dh).call(this),{pageNumbers:n,pageIds:r}=i(this,fa),a=i(this,ce)+n.length;f(this,ce,a);const o=f(this,Ut,new Uint32Array(a));f(this,zs,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(r,t),o.set(e.subarray(t),t+n.length),b(this,_e,Hd).call(this,s,null,t,n),f(this,fa,null)}hasBeenAltered(){return i(this,Ut)!==null}getPageMappingForSaving(t=null){t??(t=b(this,_e,dh).call(this));let e=0;for(const n of t.values())e=Math.max(e,n.length);const s=new Array(e);for(let n=0;n<e;n++)s[n]={document:null,pageIndices:[],includePages:[]};for(const[n,r]of t)for(let a=0,o=r.length;a<o;a++)s[a].includePages.push([n-1,r[a]-1]);for(const{includePages:n,pageIndices:r}of s){n.sort((a,o)=>a[0]-o[0]);for(let a=0,o=n.length;a<o;a++)r.push(n[a][1]),n[a]=n[a][0]}return s}extractPages(t){t=Array.from(t).sort((s,n)=>s-n);const e=new Map;for(let s=0,n=t.length;s<n;s++){const r=this.getPageId(t[s]);e.getOrInsertComputed(r,Vp).push(s+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){var e;return((e=i(this,zs))==null?void 0:e[t-1])??0}getPageNumber(t){if(!i(this,Ut))return t;const e=i(this,Ut);for(let s=0,n=i(this,ce);s<n;s++)if(e[s]===t)return s+1;return 0}getPageId(t){var e;return((e=i(this,Ut))==null?void 0:e[t-1])??t}getMapping(){var t;return(t=i(this,Ut))==null?void 0:t.subarray(0,this.pagesNumber)}}Ut=new WeakMap,zs=new WeakMap,ce=new WeakMap,fa=new WeakMap,gi=new WeakMap,_e=new WeakSet,ch=function(){if(i(this,Ut))return;const t=i(this,ce),e=f(this,Ut,new Uint32Array(t));for(let s=0;s<t;s++)e[s]=s+1;f(this,zs,new Int32Array(e))},dh=function(){const t=new Map,e=i(this,Ut);for(let s=0,n=i(this,ce);s<n;s++){const r=e[s],a=t.get(r);a?a.push(s+1):t.set(r,[s+1])}return t},Hd=function(t,e=null,s=-1,n=null){const r=i(this,zs),a=i(this,Ut),o=s+((n==null?void 0:n.length)??0),l=new Map;for(let h=0,c=i(this,ce);h<c;h++){if(h>=s&&h<o){r[h]=-n[h-s];continue}const d=a[h],p=t.get(d);let m=l.get(d)||0;if(e&&p)for(;m<p.length&&e.has(p[m]);)m++;r[h]=p==null?void 0:p[m],l.set(d,m+1)}};const po=Symbol("INITIAL_DATA"),Ng=()=>({...Promise.withResolvers(),data:po});var ks;class tb{constructor(){g(this,ks,new Map)}get(t,e=null){if(e){const n=i(this,ks).getOrInsertComputed(t,Ng);return n.promise.then(()=>e(n.data)),null}const s=i(this,ks).get(t);if(!s||s.data===po)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=i(this,ks).get(t);return!!e&&e.data!==po}delete(t){const e=i(this,ks).get(t);return!e||e.data===po?!1:(i(this,ks).delete(t),!0)}resolve(t,e=null){const s=i(this,ks).getOrInsertComputed(t,Ng);if(s.data!==po)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}
45of i(this,ks).values())(t=e==null?void 0:e.bitmap)==null||t.close();i(this,ks).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of i(this,ks))e!==po&&(yield[t,e])}}ks=new WeakMap;const GA=1e5,Bg=30;var Gg,tr,Me,vc,Sc,nl,pa,Ji,Ec,_c,ga,Cc,rl,er,al,Tc,ol,ma,xc,Pc,ll,ba,kc,hl,cl,Cn,eb,sb,Jf,bs,Ud,Zf,ib,nb;const ae=class ae{constructor({textContentSource:t,images:e,container:s,viewport:n}){g(this,Cn);g(this,tr,Promise.withResolvers());g(this,Me,null);g(this,vc,!1);g(this,Sc,!!((Gg=globalThis.FontInspector)!=null&&Gg.enabled));g(this,nl,null);g(this,pa,null);g(this,Ji,null);g(this,Ec,0);g(this,_c,0);g(this,ga,null);g(this,Cc,null);g(this,rl,0);g(this,er,0);g(this,al,Object.create(null));g(this,Tc,[]);g(this,ol,null);g(this,ma,[]);g(this,xc,new WeakMap);g(this,Pc,null);var h;if(t instanceof ReadableStream)f(this,ol,t);else if(typeof t=="object")f(this,ol,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');f(this,Me,f(this,Cc,s)),f(this,nl,e),f(this,er,n.scale*Ti.pixelRatio),f(this,rl,n.rotation),f(this,Ji,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=n.rawDims;f(this,Pc,[1,0,0,-1,-o,l+a]),f(this,_c,r),f(this,Ec,a),b(h=ae,bs,ib).call(h),s.style.setProperty("--min-font-size",i(ae,hl)),eo(s,n),i(this,tr).promise.finally(()=>{i(ae,cl).delete(this),f(this,Ji,null),f(this,al,null)}
45).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Wt.platform;return $(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){i(this,nl)&&i(this,Me).append(i(this,nl).render());const t=()=>{i(this,ga).read().then(({value:e,done:s})=>{if(s){i(this,tr).resolve();return}i(this,pa)??f(this,pa,e.lang),Object.assign(i(this,al),e.styles),b(this,Cn,eb).call(this,e.items),t()},i(this,tr).reject)};return f(this,ga,i(this,ol).getReader()),i(ae,cl).add(this),t(),i(this,tr).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*Ti.pixelRatio,n=t.rotation;if(n!==i(this,rl)&&(e==null||e(),f(this,rl,n),eo(i(this,Cc),{rotation:n})),s!==i(this,er)){e==null||e(),f(this,er,s);const a={div:null,properties:null,ctx:b(r=ae,bs,Ud).call(r,i(this,pa))};for(const o of i(this,ma))a.properties=i(this,xc).get(o),a.div=o,b(this,Cn,Jf).call(this,a)}}cancel(){var e;const t=new Sr("TextLayer task cancelled.");(e=i(this,ga))==null||e.cancel(t).catch(()=>{}),f(this,ga,null),i(this,tr).reject(t)}get textDivs(){return i(this,ma)}get textContentItemsStr(){return i(this,Tc)}static cleanup(){if(!(i(this,cl).size>0)){i(this,ll).clear();for(const{canvas:t}of i(this,ba).values())t.remove();i(this,ba).clear()}}};tr=new WeakMap,Me=new WeakMap,vc=new WeakMap,Sc=new WeakMap,nl=new WeakMap,pa=new WeakMap,Ji=new WeakMap,Ec=new WeakMap,_c=new WeakMap,ga=new WeakMap,Cc=new WeakMap,rl=new WeakMap,er=new WeakMap,al=new WeakMap,Tc=new WeakMap,ol=new WeakMap,ma=new WeakMap,xc=new WeakMap,Pc=new WeakMap,ll=new WeakMap,ba=new WeakMap,kc=new WeakMap,hl=new WeakMap,cl=new WeakMap,Cn=new WeakSet,eb=function(t){var n,r;if(i(this,vc))return;(r=i(this,Ji)).ctx??(r.ctx=b(n=ae,bs,Ud).call(n,i(this,pa)));const e=i(this,ma),s=i(this,Tc);for(const a of t){if(e.length>GA){j("Ignoring additional textDivs for performance reasons."),f(this,vc,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=i(this,Me);f(this,Me,document.createElement("span")),i(this,Me).classList.add("markedContent"),a.id&&i(this,Me).setAttribute("id",`${a.id}`),a.tag==="Artifact"&&(i(this,Me).ariaHidden=!0),o.append(i(this,Me))}else a.type==="endMarkedContent"&&f(this,Me,i(this,Me).parentNode);continue}s.push(a.str),b(this,Cn,sb).call(this,a)}},sb=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};i(this,ma).push(e);const n=M.transform(i(this,Pc),t.transform);let r=Math.atan2(n[1],n[0]);const a=i(this,al)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=i(this,Sc)&&a.fontSubstitution||a.fontFamily;o=ae.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*b(y=ae,bs,nb).call(y,o,a,i(this,pa));let c,d;
45r===0?(c=n[4],d=n[5]-h):(c=n[4]+h*Math.sin(r),d=n[5]-h*Math.cos(r));const p=e.style;p.left=`${(100*c/i(this,_c)).toFixed(2)}%`,p.top=`${(100*d/i(this,Ec)).toFixed(2)}%`,p.setProperty("--font-height",`${l.toFixed(2)}px`),p.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,i(this,Sc)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let m=!1;if(t.str.length>1)m=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const A=Math.abs(t.transform[0]),v=Math.abs(t.transform[3]);A!==v&&Math.max(A,v)/Math.min(A,v)>1.5&&(m=!0)}if(m&&(s.canvasWidth=a.vertical?t.height:t.width),i(this,xc).set(e,s),i(this,Ji).div=e,i(this,Ji).properties=s,b(this,Cn,Jf).call(this,i(this,Ji)),s.hasText&&i(this,Me).append(e),s.hasEOL){const A=document.createElement("br");A.setAttribute("role","presentation"),i(this,Me).append(A)}},Jf=function(t){var a;const{div:e,properties:s,ctx:n}=t,{style:r}=e;if(s.canvasWidth!==0&&s.hasText){const{fontFamily:o}=r,{canvasWidth:l,fontSize:h}=s;b(a=ae,bs,Zf).call(a,n,h*i(this,er),o);const{width:c}=n.measureText(e.textContent);c>0&&r.setProperty("--scale-x",l*i(this,er)/c)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},bs=new WeakSet,Ud=function(t=null){let e=i(this,ba).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,ba).set(t,e),i(this,kc).set(e,{size:0,family:""})}return e},Zf=function(t,e,s){const n=i(this,kc).get(t);e===n.size&&s===n.family||(t.font=`${e}px ${s}`,n.size=e,n.family=s)},ib=function(){if(i(this,hl)!==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,hl,t.getBoundingClientRect().height),t.remove()},nb=function(t,e,s){const n=i(this,ll).get(t);if(n)return n;const r=b(this,bs,Ud).call(this,s);r.canvas.width=r.canvas.height=Bg,b(this,bs,Zf).call(this,r,Bg,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):(Wt.platform.isFirefox&&j("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),i(this,ll).set(t,h),h},g(ae,bs),g(ae,ll,new Map),g(ae,ba,new Map),g(ae,kc,new WeakMap),g(ae,hl,null),g(ae,cl,new Set);let Ph=ae;const $A=100;function zA(u={}){typeof u=="string"||u instanceof URL?u={url:u}:(u instanceof ArrayBuffer||ArrayBuffer.isView(u))&&(u={data:u});const t=new tp,{docId:e}=t,s=u.url?Yy(u.url):null,n=u.data?Ky(u.data):null,r=u.httpHeaders||null,a=u.withCredentials===!0,o=u.password??null,l=u.range instanceof rb?u.range:null,h=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:2**16;let c=u.worker instanceof kh?u.worker:null;const d=u.verbosity,p=typeof u.docBaseUrl=="string"&&!qu(u.docBaseUrl)?u.docBaseUrl:null,m=Ad(u.cMapUrl),y=u.cMapPacked!==!1,A=Ad(u.iccUrl),v=Ad(u.standardFontDataUrl),w=Ad(u.wasmUrl),S=u.stopAtErrors!==!0,E=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,_=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!ps,C=typeof u.isImageDecoderSupported=="boolean"?u.isImageDecoderSupported:!ps&&(Wt.platform.isFirefox||!globalThis.chrome),T=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,P=typeof u.disableFontFace=="boolean"?u.disableFontFace:ps,D=u.fontExtraProperties===!0,k=u.enableXfa===!0,R=u.ownerDocument||globalThis.document,I=u.disableRange===!0,K=u.disableStream===!0,q=u.disableAutoFetch===!0,Y=u.pdfBug===!0,J=u.CanvasFactory||(ps?iA:Zy),B=u.FilterFactory||(ps?sA:tA),H=u.BinaryDataFactory||(ps?nA:Cg),ht=u.enableHWA===!0,me=u.enableWebGPU===!0?oA():Promise.resolve(!1),Ce=u.useWasm!==!1,St=u.pagesMapper||new UA,Dt=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!ps&&!P,Cr=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:!!(H===Cg&&m&&y&&v&&w&&wh(m,document.baseURI)&&wh(v,document.baseURI)&&wh(w,document.baseURI)),Te=null;my(d);const Xe={canvasFactory:new J({ownerDocument:R,enableHWA:ht}),filterFactory:new B({docId:e,ownerDocument:R}),binaryDataFactory:Cr?null:new H({cMapUrl:m,standardFontDataUrl:v,wasmUrl:w})};c||(c=kh.create({verbosity:d,port:bn.workerPort}),t._worker=c);const Nt={docId:e,apiVersion:"5.7.284",data:n,password:o,disableAutoFetch:q,rangeChunkSize:h,docBaseUrl:p,enableXfa:k,evaluatorOptions:{maxImageSize:E,disableFontFace:P,ignoreErrors:S,isOffscreenCanvasSupported:_,isImageDecoderSupported:C,canvasMaxAreaInBytes:T,fontExtraProperties:D,useSystemFonts:Dt,useWasm:Ce,useWorkerFetch:Cr,cMapUrl:m,cMapPacked:y,iccUrl:A,standardFontDataUrl:v,wasmUrl:w,hasGPU:!1}},ly={ownerDocument:R,pdfBug:Y,styleElement:Te,enableHWA:ht,loadingParams:{disableAutoFetch:q,enableXfa:k}};return Promise.all([c.promise,me]).then(function([,hy]){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");Nt.evaluatorOptions.hasGPU=hy;
45const cy=c.messageHandler.sendWithPromise("GetDocRequest",Nt,n?[n.buffer]:null);let of;if(!n)if(l)of=new TA({pdfDataRangeTransport:l,disableRange:I,disableStream:K});else if(s){const lf=OA(s);of=new lf({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:I,disableStream:K})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return cy.then(lf=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const cg=new rh(e,lf,c.port),dy=new VA(cg,t,of,ly,Xe,St);t._transport=dy,cg.send("Ready",null)})}).catch(t._capability.reject),t}var Fu;const Ou=class Ou{constructor(){x(this,"_capability",Promise.withResolvers());x(this,"_transport",null);x(this,"_worker",null);x(this,"docId",`d${$t(Ou,Fu)._++}`);x(this,"destroyed",!1);x(this,"onPassword",null);x(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,n;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(n=this._worker)==null||n.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Fu=new WeakMap,g(Ou,Fu,0);let tp=Ou;var dl,ya;class rb{constructor(t,e,s=!1,n=null){g(this,dl,Promise.withResolvers());g(this,ya,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=n,Object.defineProperty(this,"onDataProgress",{value:()=>{xy("`PDFDataRangeTransport.prototype.onDataProgress` - method was removed, since loading progress is now reported automatically through the `PDFDataTransportStream` class (and related code).")}})}onDataRange(t,e){i(this,ya).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){i(this,dl).promise.then(()=>{i(this,ya).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){i(this,dl).promise.then(()=>{i(this,ya).call(this,{type:"progressiveDone"})})}transportReady(t){f(this,ya,t),i(this,dl).resolve()}requestDataRange(t,e){nt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}dl=new WeakMap,ya=new WeakMap;class jA{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return $(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}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 Zi,Aa,wa,uh;const og=class og{constructor(t,e,s,n,r=!1){g(this,wa);g(this,Zi,!1);g(this,Aa,null);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new pg:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new tb,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,f(this,Aa,n),this.imageCoordinates=null}clone(t){const e=new og(t,this._pageInfo,this._transport,i(this,Aa),this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}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 pd({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}
45=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 $(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:n="display",annotationMode:r=xn.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:p=!1,recordImages:m=!1,recordOperations:y=!1,operationsFilter:A=null}){var q,Y,J;(q=this._stats)==null||q.time("Overall");const v=this._transport.getRenderingIntent(n,r,d,p),{renderingIntent:w,cacheKey:S}=v;f(this,Zi,!1),l||(l=this._transport.getOptionalContentConfig(w));const E=this._intentStates.getOrInsertComputed(S,wf);E.streamReaderCancelTimeout&&(clearTimeout(E.streamReaderCancelTimeout),E.streamReaderCancelTimeout=null);const _=!!(w&fs.PRINT);E.displayReadyCapability||(E.displayReadyCapability=Promise.withResolvers(),E.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(Y=this._stats)==null||Y.time("Page Request"),this._pumpOperatorList(v));const C=!!(this._pdfBug&&((J=globalThis.StepperManager)!=null&&J.enabled)),T=!!e&&!this.recordedBBoxes&&(y||C),P=!!e&&!this.imageCoordinates&&m,D=B=>{var H,ht,Be,me;if(E.renderTasks.delete(I),T){const Ce=(H=I.gfx)==null?void 0:H.dependencyTracker.take();Ce&&((ht=I.stepper)==null||ht.setOperatorBBoxes(Ce,I.gfx.dependencyTracker.takeDebugMetadata()),y&&(this.recordedBBoxes=Ce))}P&&!B&&(this.imageCoordinates=(Be=I.gfx)==null?void 0:Be.imagesTracker.take()),_&&f(this,Zi,!0),b(this,wa,uh).call(this),B?(I.capability.reject(B),this._abortOperatorList({intentState:E,reason:B instanceof Error?B:new Error(B)})):I.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(me=globalThis.Stats)!=null&&me.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let k=null,R=null;(T||P)&&(R=new Hy(e,E.operatorList.length)),T&&(k=new Uy(R,C));const I=new sp({callback:D,params:{canvas:e,canvasContext:t,dependencyTracker:k??R,imagesTracker:P?new $f(e):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:!_,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:A});(E.renderTasks||(E.renderTasks=new Set)).add(I);const K=I.task;return Promise.all([E.displayReadyCapability.promise,l]).then(([B,H])=>{var ht;if(this.destroyed){D();return}if((ht=this._stats)==null||ht.time("Rendering"),!(H.renderingIntent&w))throw new Error("Mu
45st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");I.initializeGraphics({transparency:B,optionalContentConfig:H}),I.operatorListChanged()}).catch(D),K}getOperatorList({intent:t="display",annotationMode:e=xn.ENABLE,printAnnotationStorage:s=null,isEditing:n=!1}={}){var h;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,n,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,wf);let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:i(this,Aa).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(n){return n.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>Ch.textContent(n));const e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(const n of e)s.lang??(s.lang=n.lang),Object.assign(s.styles,n.styles),s.items.push(...n.items);return s}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,Zi,!1),Promise.all(t)}cleanup(t=!1){f(this,Zi,!0);const e=b(this,wa,uh).call(this);return t&&e&&this._stats&&(this._stats=new pg),e}_startRenderPage(t,e){var n,r;const s=this._intentStates.get(e);s&&((n=this._stats)==null||n.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,n=t.length;s<n;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&b(this,wa,uh).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:n}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:i(this,Aa).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:n},void 0,a).getReader(),h=this._intentStates.get(e);h.streamReader=l;const c=()=>{l.read().then(({value:d,done:p})=>{if(p){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,h),c())},d=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const p of h.renderTasks)p.operatorListChanged();b(this,wa,uh).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(d);else if(h.opListReadCapability)h.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Yp){let n=$A;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 Sr(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}};Zi=new WeakMap,Aa=new WeakMap,wa=new WeakSet,uh=function(){if(!i(this,Zi)||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,Zi,!1),!0};let ep=og;var sr,js,tn,va,Nu,Sa,Ea,Oe,Gd,ab,ob,fh,ul,$d;const It=class It{constructor({name:t=null,port:e=null,verbosity:s=by()}={}){g(this,Oe);g(this,sr,Promise.withResolvers());g(this,js,null);g(this,tn,null);g(this,va,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(i(It,Ea).has(e))throw new Error("Cannot use more than one PDFWorker per port.");i(It,Ea).set(e,this),b(this,Oe,ab).call(this,e)}else b(this,Oe,ob).call(this)}get promise(){return i(this,sr).promise}get port(){return i(this,tn)}get messageHandler(){return i(this,js)}destroy(){var t,e;this.destroyed=!0,(t=i(this,va))==null||t.terminate(),f(this,va,null),i(It,Ea).delete(i(this,tn)),f(this,tn,null),(e=i(this,js))==null||e.destroy(),f(this,js,null)}static create(t){const e=i(this,Ea).get(t==null?void 0:t.port);
45if(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 It(t)}static get workerSrc(){if(bn.workerSrc)return bn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return $(this,"_setupFakeWorkerGlobal",(async()=>i(this,ul,$d)?i(this,ul,$d):(await import(this.workerSrc)).WorkerMessageHandler)())}};sr=new WeakMap,js=new WeakMap,tn=new WeakMap,va=new WeakMap,Nu=new WeakMap,Sa=new WeakMap,Ea=new WeakMap,Oe=new WeakSet,Gd=function(){i(this,sr).resolve(),i(this,js).send("configure",{verbosity:this.verbosity})},ab=function(t){f(this,tn,t),f(this,js,new rh("main","worker",t)),i(this,js).on("ready",()=>{}),b(this,Oe,Gd).call(this)},ob=function(){if(i(It,Sa)||i(It,ul,$d)){b(this,Oe,fh).call(this);return}let{workerSrc:t}=It;try{It._isSameOrigin(window.location,t)||(t=It._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new rh("main","worker",e),n=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?i(this,sr).reject(new Error("Worker was destroyed")):b(this,Oe,fh).call(this)},r=new AbortController;e.addEventListener("error",()=>{i(this,va)||n()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){n();return}f(this,js,s),f(this,tn,e),f(this,va,e),b(this,Oe,Gd).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){n();return}try{a()}catch{b(this,Oe,fh).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Yu("The worker has been disabled.")}b(this,Oe,fh).call(this)},fh=function(){i(It,Sa)||(j("Setting up fake worker."),f(It,Sa,!0)),It._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){i(this,sr).reject(new Error("Worker was destroyed"));return}const e=new Jy;f(this,tn,e);const s=`fake${$t(It,Nu)._++}`,n=new rh(s+"_worker",s,e);t.setup(n,e),f(this,js,new rh(s,s+"_worker",e)),b(this,Oe,Gd).call(this)}).catch(t=>{i(this,sr).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},ul=new WeakSet,$d=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},g(It,ul),g(It,Nu,0),g(It,Sa,!1),g(It,Ea,new WeakMap),ps&&(f(It,Sa,!0),bn.workerSrc||(bn.workerSrc="./pdf.worker.mjs")),It._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const n=new URL(e,s);return s.origin===n.origin},It._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let kh=It;var Ze,_a,en,Vs,Ca,fl,sn,Zs,ph,zd;class VA{constructor(t,e,s,n,r,a){g(this,Zs);x(this,"downloadInfoCapability",Promise.withResolvers());g(this,Ze,null);g(this,_a,new Map);g(this,en,null);g(this,Vs,new Map);g(this,Ca,new Map);g(this,fl,new Map);g(this,sn,null);this.messageHandler=t,this.loadingTask=e,f(this,en,s),this.commonObjs=new tb,this.fontLoader=new Gy({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.enableHWA=n.enableHWA,this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;i(this,Vs).set(e,t),i(this,Ca).set(e,Promise.resolve(t))}get annotationStorage(){return $(this,"annotationStorage",new Qp)}getRenderingIntent(t,e=xn.ENABLE,s=null,n=!1,r=!1){let a=fs.DISPLAY,o=Th;switch(t){case"any":a=fs.ANY;break;case"display":break;case"print":a=fs.PRINT;break;default:j(`getRenderingIntent - invalid intent: ${t}`)}const l=a&fs.PRINT&&s instanceof xm?s:this.annotationStorage;switch(e){case xn.DISABLE:a+=fs.ANNOTATIONS_DISABLE;break;case xn.ENABLE:break;case xn.ENABLE_FORMS:a+=fs.ANNOTATIONS_FORMS;break;case xn.ENABLE_STORAGE:a+=fs.ANNOTATIONS_STORAGE,o=l.serializable;break;default:j(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(a+=fs.IS_EDITING),r&&(a+=fs.OPLIST);const{ids:h,hash:c}=l.modifiedIds,d=[a,o.hash,c];return{renderingIntent:a,cacheKey:d.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=i(this,sn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const n of i(this,Vs).values())t.push(n._destroy());i(this,Vs).clear(),i(this,Ca).clear(),i(this,fl).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();
45const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var n,r;this.commonObjs.clear(),this.fontLoader.clear(),i(this,_a).clear(),this.filterFactory.destroy(),Ph.cleanup(),(n=i(this,en))==null||n.cancelAllRequests(new Sr("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,n)=>{kt(i(this,en),"GetReader - no `BasePDFStream` instance available."),f(this,Ze,i(this,en).getFullReader()),i(this,Ze).onProgress=r=>b(this,Zs,zd).call(this,r),n.onPull=()=>{i(this,Ze).read().then(function({value:r,done:a}){if(a){n.close();return}kt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{n.error(r)})},n.onCancel=r=>{i(this,Ze).cancel(r),n.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await i(this,Ze).headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:a}=i(this,Ze);return n&&r&&(i(this,Ze).onProgress=null),{isStreamingSupported:n,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,n)=>{kt(i(this,en),"GetRangeReader - no `BasePDFStream` instance available.");const r=i(this,en).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}kt(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.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new jA(s,this))}),t.on("DocException",s=>{e._capability.reject(He(s))}),t.on("PasswordRequest",s=>{f(this,sn,Promise.withResolvers());try{if(!e.onPassword)throw He(s);const n=r=>{r instanceof Error?i(this,sn).reject(r):i(this,sn).resolve({password:r})};e.onPassword(n,s.code)}catch(n){i(this,sn).reject(n)}return i(this,sn).promise}),t.on("DataLoaded",s=>{b(this,Zs,zd).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;i(this,Vs).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,n,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(n){case"Font":if("error"in r){const p=r.error;j(`Error during font loading: ${p}`),this.commonObjs.resolve(s,p);break}const o=new Vy(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(p,m)=>globalThis.FontInspector.fontAdded(p,m):null,h=new $y(o,l,r.charProcOperatorList,r.extra);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{h.fontExtraProperties||h.clearData(),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:c}=r;kt(c,"The imageRef must be defined.");for(const p of i(this,Vs).values())for(const[,m]of p.objs){if((m==null?void 0:m.ref)!==c)continue;if(!m.dataLen)return null;const y=structuredClone(m);return this.commonObjs.resolve(s,y),m.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new Xy(r));break;case"Image":this.commonObjs.resolve(s,r);break;case"Pattern":const d=new Wy(r);this.commonObjs.resolve(s,d.getIR());break;default:throw new Error(`Got unknown common object type ${n}`)}return null}),t.on("obj",([s,n,r,a])=>{var l;if(this.destroyed)return;const o=i(this,Vs).get(n);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{this.destroyed||b(this,Zs,zd).call(this,s)}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}
45getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&j("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=i(this,Ze))==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){const e={pageInfos:t};let s;if(this.annotationStorage.size>0){const{map:n,transfer:r}=this.annotationStorage.serializable;e.annotationStorage=n,s=r}return this.messageHandler.sendWithPromise("ExtractPages",e,s).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.pagesMapper.getPageId(t)-1,n=i(this,Ca).get(e);if(n)return n;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&i(this,fl).set(a.refStr,s);const o=new ep(e,a,this,this.pagesMapper,this._params.pdfBug);return i(this,Vs).set(e,o),o});return i(this,Ca).set(e,r),r}async getPageIndex(t){if(!jf(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return b(this,Zs,ph).call(this,"GetFieldObjects")}hasJSActions(){return b(this,Zs,ph).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 b(this,Zs,ph).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return b(this,Zs,ph).call(this,"GetOptionalContentConfig").then(e=>new HA(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return i(this,_a).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,n;return{info:e[0],metadata:e[1]?new NA(e[1]):null,contentDispositionFilename:((s=i(this,Ze))==null?void 0:s.filename)??null,contentLength:((n=i(this,Ze))==null?void 0:n.contentLength)??null,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of i(this,Vs).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),i(this,_a).clear(),this.filterFactory.destroy(!0),Ph.cleanup()}}cachedPageNumber(t){if(!jf(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=i(this,fl).get(e);if(s>=0){const n=this.pagesMapper.getPageNumber(s+1);if(n!==0)return n}return null}}Ze=new WeakMap,_a=new WeakMap,en=new WeakMap,Vs=new WeakMap,Ca=new WeakMap,fl=new WeakMap,sn=new WeakMap,Zs=new WeakSet,ph=function(t,e=null){return i(this,_a).getOrInsertComputed(t,()=>
45this.messageHandler.sendWithPromise(t,e))},zd=function({loaded:t,total:e}){var s,n;(n=(s=this.loadingTask).onProgress)==null||n.call(s,{loaded:t,total:e,percent:e?Ct(Math.round(t/e*100),0,100):NaN})};class WA{constructor(t){x(this,"_internalRenderTask",null);x(this,"onContinue",null);x(this,"onError",null);this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&(e==null?void 0:e.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var ir,Ta;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:d=!1,pageColors:p=null,enableHWA:m=!1,operationsFilter:y=null}){g(this,ir,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=n,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=d,this.pageColors=p,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new WA(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=m,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=y}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var h,c;if(this.cancelled)return;if(this._canvas){if(i(Mr,Ta).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,Ta).add(this._canvas)}this._pdfBug&&((h=globalThis.StepperManager)!=null&&h.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,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new wo(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,o),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(c=this.graphicsReadyCallback)==null||c.call(this)}cancel(t=null,e=0){var s,n,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),i(this,ir)&&(window.cancelAnimationFrame(i(this,ir)),f(this,ir,null)),i(Mr,Ta).delete(this._canvas),t||(t=new Yp(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(n=this.task).onError)==null||r.call(n,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?f(this,ir,window.requestAnimationFrame(()=>{f(this,ir,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,Ta).delete(this._canvas),this.callback())))}};ir=new WeakMap,Ta=new WeakMap,g(Mr,Ta,new WeakSet);let sp=Mr;const XA="5.7.284",YA="7e5b36c2d";
45var ts,xa,pl,qt,Mc,gl,nn,Dc,nr,Ws,Ic,gt,ip,np,rp,Tr,lb,Tn;const Ue=class Ue{constructor({editor:t=null,uiManager:e=null}){g(this,gt);g(this,ts,null);g(this,xa,null);g(this,pl);g(this,qt,null);g(this,Mc,!1);g(this,gl,!1);g(this,nn,null);g(this,Dc);g(this,nr,null);g(this,Ws,null);var s,n;t?(f(this,gl,!1),f(this,nn,t)):f(this,gl,!0),f(this,Ws,(t==null?void 0:t._uiManager)||e),f(this,Dc,i(this,Ws)._eventBus),f(this,pl,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((n=i(this,Ws))==null?void 0:n.highlightColors.values().next().value)||"#FFFF98"),i(Ue,Ic)||f(Ue,Ic,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 $(this,"_keyboardManager",new md([[["Escape","mac+Escape"],Ue.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Ue.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Ue.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Ue.prototype._moveToPrevious],[["Home","mac+Home"],Ue.prototype._moveToBeginning],[["End","mac+End"],Ue.prototype._moveToEnd]]))}renderButton(){const t=f(this,ts,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",i(this,nn)&&(t.ariaControls=`${i(this,nn).id}_colorpicker_dropdown`);const e=i(this,Ws)._signal;t.addEventListener("click",b(this,gt,Tr).bind(this),{signal:e}),t.addEventListener("keydown",b(this,gt,rp).bind(this),{signal:e});const s=f(this,xa,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=i(this,pl),t.append(s),t}renderMainDropdown(){const t=f(this,qt,b(this,gt,ip).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===i(this,ts)){b(this,gt,Tr).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,gt,np).call(this,e,t)}_moveToNext(t){var e,s;if(!i(this,gt,Tn)){b(this,gt,Tr).call(this,t);return}if(t.target===i(this,ts)){(e=i(this,qt).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=i(this,qt))==null?void 0:e.firstElementChild)||t.target===i(this,ts)){i(this,gt,Tn)&&this._hideDropdownFromKeyboard();return}i(this,gt,Tn)||b(this,gt,Tr).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!i(this,gt,Tn)){b(this,gt,Tr).call(this,t);return}(e=i(this,qt).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!i(this,gt,Tn)){b(this,gt,Tr).call(this,t);return}(e=i(this,qt).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=i(this,qt))==null||t.classList.add("hidden"),i(this,ts).ariaExpanded="false",(e=i(this,nr))==null||e.abort(),f(this,nr,null)}_hideDropdownFromKeyboard(){var t;if(!i(this,gl)){if(!i(this,gt,Tn)){(t=i(this,nn))==null||t.unselect();return}this.hideDropdown(),i(this,ts).focus({preventScroll:!0,focusVisible:i(this,Mc)})}}updateColor(t){if(i(this,xa)&&(i(this,xa).style.backgroundColor=t),!i(this,qt))return;const e=i(this,Ws).highlightColors.values();for(const s of i(this,qt).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=i(this,ts))==null||t.remove(),f(this,ts,null),f(this,xa,null),(e=i(this,qt))==null||e.remove(),f(this,qt,null)}};ts=new WeakMap,xa=new WeakMap,pl=new WeakMap,qt=new WeakMap,Mc=new WeakMap,gl=new WeakMap,nn=new WeakMap,Dc=new WeakMap,nr=new WeakMap,Ws=new WeakMap,Ic=new WeakMap,gt=new WeakSet,ip=function(){const t=document.createElement("div"),e=i(this,Ws)._signal;t.addEventListener("contextmenu",Fs,{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,nn)&&(t.id=`${i(this,nn).id}_colorpicker_dropdown`);for(const[s,n]of i(this,Ws).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(Ue,Ic)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.ariaSelected=n===i(this,pl),r.addEventListener("click",b(this,gt,np).bind(this,n),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,gt,rp).bind(this),{signal:e}),t},np=function(t,e){e.stopPropagation(),i(this,Dc).dispatch("switchannotationeditorparams",{source:this,type:V.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},rp=function(t){Ue._keyboardManager.exec(this,t)},Tr=function(t){if(i(this,gt,Tn)){this.hideDropdown();return}if(f(this,Mc,t.detail===0),i(this,nr)||(f(this,nr,new AbortController),window.addEventListener("pointerdown",b(this,gt,lb).bind(this),{signal:i(this,Ws).combinedSignal(i(this,nr))})),i(this,ts).ariaExpanded="true",i(this,qt)){i(this,qt).classList.remove("hidden");return}const e=f(this,qt,b(this,gt,ip).call(this));i(this,ts).append(e)},lb=function(t){var e;(e=i(this,qt))!=null&&e.contains(t.target)||this.hideDropdown()},Tn=function(){return i(this,qt)&&!i(this,qt).classList.contains("hidden")},g(Ue,Ic,null);let pu=Ue;var es,ml,Pa,rn,Lc;const Dr=class Dr{constructor(t){g(this,es,null);g(this,ml,!1);g(this,Pa,null);g(this,rn,null);f(this,Pa,t),f(this,rn,t._uiManager),i(Dr,Lc)||f(Dr,Lc,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(i(this,es))return i(this,es);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:n,color:r,opacity:a}=i(this,Pa),o=f(this,ml,Wt.isAlphaColorInputSupported&&n!==void 0),l=f(this,es,document.createElement("input"));if(l.type="color",o){l.setAttribute("alpha","");const h=M.hexNums[Math.round((a??1)*255)];l.value=(r||"#000000")+h}else l.value=r||"#000000";return l.className="basicColorPicker",l.tabIndex=0,l.setAttribute("data-l10n-id",i(Dr,Lc)[t]),l.addEventListener("input",()=>{if(o){const h=qp(l.value);
45if(!h)return;const[c,d,p,m]=h,y=M.makeHexColor(c,d,p);s!==void 0?i(this,rn).updateParams(s,{color:y,opacity:m}):(i(this,rn).updateParams(e,y),i(this,rn).updateParams(n,m))}else i(this,rn).updateParams(e,l.value)},{signal:i(this,rn)._signal}),l}update(t){if(i(this,es))if(i(this,ml)){const e=M.hexNums[Math.round(i(this,Pa).opacity*255)];i(this,es).value=t+e}else i(this,es).value=t}updateOpacity(t){if(!i(this,es)||!i(this,ml))return;const e=M.hexNums[Math.round(t*255)];i(this,es).value=i(this,Pa).color+e}destroy(){var t;(t=i(this,es))==null||t.remove(),f(this,es,null)}hideDropdown(){}};es=new WeakMap,ml=new WeakMap,Pa=new WeakMap,rn=new WeakMap,Lc=new WeakMap,g(Dr,Lc,null);let gu=Dr;function Hg(u){return Math.floor(Ct(u,0,1)*255).toString(16).padStart(2,"0")}function ql(u){return Ct(u,0,1)*255}class Ug{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=Hg(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(Hg).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 KA{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),s||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){nt("Abstract method `_createSVG` called.")}}class mu extends KA{_createSVG(t){return document.createElementNS(ki,t)}}const qA=9,io=new WeakSet,QA=new Date().getTimezoneOffset()*60*1e3;class gf{static create(t){switch(t.data.annotationType){case jt.LINK:return new Zp(t);case jt.TEXT:return new ZA(t);case jt.WIDGET:switch(t.data.fieldType){case"Tx":return new t0(t);case"Btn":return t.data.radioButton?new db(t):t.data.checkBox?new s0(t):new i0(t);case"Ch":return new n0(t);case"Sig":return new e0(t)}return new ro(t);case jt.POPUP:return new op(t);case jt.FREETEXT:return new mb(t);case jt.LINE:return new a0(t);case jt.SQUARE:return new o0(t);case jt.CIRCLE:return new l0(t);case jt.POLYLINE:return new bb(t);case jt.CARET:return new c0(t);case jt.INK:return new tg(t);case jt.POLYGON:return new h0(t);case jt.HIGHLIGHT:return new yb(t);case jt.UNDERLINE:return new d0(t);case jt.SQUIGGLY:return new u0(t);case jt.STRIKEOUT:return new f0(t);case jt.STAMP:return new Ab(t);case jt.FILEATTACHMENT:return new p0(t);default:return new Mt(t)}}}var ka,bl,Ms,Rc,ap;const lg=class lg{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:n=!1}={}){g(this,Rc);g(this,ka,null);g(this,bl,!1);g(this,Ms,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,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(s)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return lg._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}
45get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:n}=this.data;let r=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;l<e.length;l+=8)e[l+1]>a?(a=e[l+1],r=e[l+2]):e[l+1]===a&&(r=Math.max(r,e[l+2]));return[r,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let h=0,c=l.length;h<c;h+=2)l[h+1]>a?(a=l[h+1],r=l[h]):l[h+1]===a&&(r=Math.max(r,l[h]));if(r!==1/0)return[r,a]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-a)/n,t}get commentText(){var e,s,n;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${_h}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((n=t.contentsObj)==null?void 0:n.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${_h}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=i(this,Ms))==null?void 0:t.popup)||this.popup)==null||e.remove(),f(this,Ms,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(i(this,ka)||f(this,ka,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,Rc,ap).call(this,e);let n=((r=i(this,Ms))==null?void 0:r.popup)||this.popup;!n&&(s!=null&&s.text)&&(this._createPopup(s),n=i(this,Ms).popup),n&&(n.updateEdited(t),s!=null&&s.deleted&&(n.remove(),f(this,Ms,null),this.popup=null))}resetEdited(){var t;i(this,ka)&&(b(this,Rc,ap).call(this,i(this,ka).rect),(t=i(this,Ms))==null||t.popup.resetEdited(),f(this,ka,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 ro)&&!(this instanceof Zp)&&(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 op){const{rotation:A}=e;return!e.hasOwnCanvas&&A!==0&&this.setRotation(A,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const A=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(A>0||v>0){const S=`calc(${A}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;a.borderRadius=S}else if(this instanceof db){const S=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;a.borderRadius=S}switch(e.borderStyle.style){case oo.SOLID:a.borderStyle="solid";break;case oo.DASHED:a.borderStyle="dashed";break;case oo.BEVELED:j("Unimplemented border style: beveled");break;case oo.INSET:j("Unimplemented border style: inset");break;case oo.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(f(this,bl,!0),a.borderColor=M.makeHexColor(...w)):a.borderWidth=0}const h=M.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:p,pageY:m}=n.rawDims;a.left=`${100*(h[0]-p)/c}%`,a.top=`${100*(h[1]-m)/d}%`;const{rotation:y}=e;return e.hasOwnCanvas||y===0?(a.width=`${100*o/c}%`,a.height=`${100*l/d}%`):this.setRotation(y,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:n}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/n}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,n)=>{const r=n.detail[e],a=r[0],o=r.slice(1);n.target.style[s]=Ug[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Ug[`${a}_rgb`](o)})};return $(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(()=>
45e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const n of Object.keys(e.detail)){const r=t[n]||s[n];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[n,r]of Object.entries(e)){const a=s[n];if(a){const o={detail:{[n]:r},target:t};a(o),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,n,r]=this.data.rect.map(A=>Math.fround(A));if(t.length===8){const[A,v,w,S]=t.subarray(2,6);if(n===A&&r===v&&e===w&&s===S)return}const{style:a}=this.container;let o;if(i(this,bl)){const{borderColor:A,borderWidth:v}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${A}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=n-e,h=r-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const p=c.createElement("defs");d.append(p);const m=c.createElement("clipPath"),y=`clippath_${this.data.id}`;m.setAttribute("id",y),m.setAttribute("clipPathUnits","objectBoundingBox"),p.append(m);for(let A=2,v=t.length;A<v;A+=8){const w=t[A],S=t[A+1],E=t[A+2],_=t[A+3],C=c.createElement("rect"),T=(E-e)/l,P=(r-S)/h,D=(w-E)/l,k=(S-_)/h;C.setAttribute("x",T),C.setAttribute("y",P),C.setAttribute("width",D),C.setAttribute("height",k),m.append(C),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${T}" y="${P}" width="${D}" height="${k}"/>`)}i(this,bl)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${y})`}_createPopup(t=null){const{data:e}=this;let s,n;t?(s={str:t.text},n=t.date):(s=e.contentsObj,n=e.modificationDate),f(this,Ms,new op({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]}))}get hasPopupElement(){return!!(i(this,Ms)||this.popup||this.data.popupRef)}get extraPopupElement(){return i(this,Ms)}render(){nt("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&&!io.has(h)){j(`_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&&io.has(n)&&s.push({id:a,exportValue:r,domElement:n})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};ka=new WeakMap,bl=new WeakMap,Ms=new WeakMap,Rc=new WeakSet,ap=function(t){const{container:{style:e},data:{rect:s,rotation:n},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,n===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(n)};let Mt=lg;class JA extends Mt{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)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}
45get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}var ms,xr,hb,cb;class Zp extends Mt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});g(this,ms);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?(b(this,ms,hb).call(this,n,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(b(this,ms,cb).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.contentElement=n,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==="")&&b(this,ms,xr).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),b(this,ms,xr).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=n.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),b(this,ms,xr).call(this)}_bindResetFormAction(e,s){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),b(this,ms,xr).call(this),!this._fieldObjects){j('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{var d;n==null||n();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const p=new Set(a);for(const m of r){const y=this._fieldObjects[m]||[];for(const{id:A}of y)p.add(A)}for(const m of Object.values(this._fieldObjects))for(const y of m)p.has(y.id)===o&&l.push(y)}else for(const p of Object.values(this._fieldObjects))l.push(...p);const h=this.annotationStorage,c=[];for(const p of l){const{id:m}=p;switch(c.push(m),p.type){case"text":{const A=p.defaultValue||"";h.setValue(m,{value:A});break}case"checkbox":case"radiobutton":{const A=p.defaultValue===p.exportValues;h.setValue(m,{value:A});break}case"combobox":case"listbox":{const A=p.defaultValue||"";h.setValue(m,{value:A});break}default:continue}const y=document.querySelector(`[data-element-id="${m}"]`);if(y){if(!io.has(y)){j(`_bindResetFormAction - element not allowed: ${m}`);continue}}else continue;y.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}ms=new WeakSet,xr=function(){this.container.setAttribute("data-internal-link","")},hb=function(e,s,n="",r=null){e.href=this.linkService.getAnchorUrl(""),s.description?e.title=s.description:n&&(e.title=n),e.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(s.content,s.filename,r),!1},b(this,ms,xr).call(this)},cb=function(e,s,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),n&&(e.title=n),b(this,ms,xr).call(this)};class ZA extends Mt{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.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}
45class ro extends Mt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Wt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,n,r){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(a)}}))})}_setEventListeners(t,e,s,n){var r,a,o;for(const[l,h]of s)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,h,n),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":M.makeHexColor(...e)}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||qA,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/(cf*n))||1,d=h/c;a=Math.min(n,l(d/cf))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(n,l(h/cf))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=M.makeHexColor(...s),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 t0 extends ro{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;
45for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[n]:s})}render(){var n,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let h=a.formattedValue||((n=this.data.textContent)==null?void 0:n.join(`
46`))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const c={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",h??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),io.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:d,datetimeType:p,timeStep:m}=this.data,y=!!p&&this.enableScripting;d&&(s.title=d),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",v=>{t.setValue(e,{value:v.target.value}),this.setPropertyOnSiblings(s,"value",v.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",v=>{const w=this.data.defaultFieldValue??"";s.value=c.userValue=w,c.formattedValue=null});let A=v=>{const{formattedValue:w}=c;w!=null&&(v.target.value=w),v.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var E;if(c.focused)return;const{target:S}=w;if(y&&(S.type=p,m&&(S.step=m)),c.userValue){const _=c.userValue;if(y)if(p==="time"){const C=new Date(_),T=[C.getHours(),C.getMinutes(),C.getSeconds()];S.value=T.map(P=>P.toString().padStart(2,"0")).join(":")}else S.value=new Date(_-QA).toISOString().split(p==="date"?"T":".",1)[0];else S.value=_}c.lastCommittedValue=S.value,c.commitKey=1,(E=this.data.actions)!=null&&E.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",w=>{this.showElementAndHideCanvas(w.target);const S={value(E){c.userValue=E.detail.value??"",y||t.setValue(e,{value:c.userValue.toString()}),E.target.value=c.userValue},formattedValue(E){const{formattedValue:_}=E.detail;c.formattedValue=_,_!=null&&E.target!==document.activeElement&&(E.target.value=_);const C={formattedValue:_};y&&(C.value=_),t.setValue(e,C)},selRange(E){E.target.setSelectionRange(...E.detail.selRange)},charLimit:E=>{var P;const{charLimit:_}=E.detail,{target:C}=E;if(_===0){C.removeAttribute("maxLength");return}C.setAttribute("maxLength",_);let T=c.userValue;!T||T.length<=_||(T=T.slice(0,_),C.value=c.userValue=T,t.setValue(e,{value:T}),(P=this.linkService.eventBus)==null||P.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:T,willCommit:!0,commitKey:1,selStart:C.selectionStart,selEnd:C.selectionEnd}}))}};this._dispatchEventFromSandbox(S,w)}),s.addEventListener("keydown",w=>{var _;c.commitKey=1;let S=-1;if(w.key==="Escape"?S=0:w.key==="Enter"&&!this.data.multiLine?S=2:w.key==="Tab"&&(c.commitKey=3),S===-1)return;const{value:E}=w.target;c.lastCommittedValue!==E&&(c.lastCommittedValue=E,c.userValue=E,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:S,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const v=A;A=null,s.addEventListener("blur",w=>{var _,C;if(!c.focused||!w.relatedTarget)return;(_=this.data.actions)!=null&&_.Blur||(c.focused=!1);const{target:S}=w;let{value:E}=S;if(y){if(E&&p==="time"){const T=E.split(":").map(P=>parseInt(P,10));E=new Date(2e3,0,1,T[0],T[1],T[2]||0).valueOf(),S.step=""}else E.includes("T")||(E=`${E}T00:00`),E=new Date(E).valueOf();S.type="text"}c.userValue=E,c.lastCommittedValue!==E&&((C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,
46commitKey:c.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),v(w)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",w=>{var k;c.lastCommittedValue=null;const{data:S,target:E}=w,{value:_,selectionStart:C,selectionEnd:T}=E;let P=C,D=T;switch(w.inputType){case"deleteWordBackward":{const R=_.substring(0,C).match(/\w*[^\w]*$/);R&&(P-=R[0].length);break}case"deleteWordForward":{const R=_.substring(C).match(/^[^\w]*\w*/);R&&(D+=R[0].length);break}case"deleteContentBackward":C===T&&(P-=1);break;case"deleteContentForward":C===T&&(D+=1);break}w.preventDefault(),(k=this.linkService.eventBus)==null||k.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:S||"",willCommit:!1,selStart:P,selEnd:D}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(A&&s.addEventListener("blur",A),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${w}px * var(--total-scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class e0 extends ro{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class s0 extends ro{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 io.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 db extends ro{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(io.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const c=a===h.detail.value;for(const d of this._getElementsByName(h.target.name)){const p=c&&d.id===s;d.domElement&&(d.domElement.checked=p),t.setValue(d.id,{value:p})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}
46return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class i0 extends Zp{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 n0 extends ro{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");io.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",d=>{const p=this.data.defaultFieldValue;for(const m of n.options)m.selected=m.value===p});const a=(d,p)=>{const m=p.replaceAll(" "," ");d.textContent=m,m!==p&&d.setAttribute("display-value",p)};for(const d of this.data.options){const p=document.createElement("option");a(p,d.displayValue),p.value=d.exportValue,s.value.includes(d.exportValue)&&(p.setAttribute("selected",!0),r=!1),n.append(p)}let o=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),n.prepend(d),o=()=>{d.remove(),n.removeEventListener("input",o),o=null},n.addEventListener("input",o)}const l=d=>{const p=d?"value":"textContent",{options:m,multiple:y}=n;return y?Array.prototype.filter.call(m,A=>A.selected).map(A=>A[p]):m.selectedIndex===-1?null:m[m.selectedIndex][p]};let h=l(!1);const c=d=>{const p=d.target.options;return Array.prototype.map.call(p,m=>({displayValue:m.getAttribute("display-value")||m.textContent,exportValue:m.value}))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",d=>{const p={value(m){o==null||o();const y=m.detail.value,A=new Set(Array.isArray(y)?y:[y]);for(const v of n.options)v.selected=A.has(v.value);t.setValue(e,{value:l(!0)}),h=l(!1)},multipleSelection(m){n.multiple=!0},remove(m){const y=n.options,A=m.detail.remove;y[A].selected=!1,n.remove(A),y.length>0&&Array.prototype.findIndex.call(y,w=>w.selected)===-1&&(y[0].selected=!0),t.setValue(e,{value:l(!0),items:c(m)}),h=l(!1)},clear(m){for(;n.length!==0;)n.remove(0);t.setValue(e,{value:null,items:[]}),h=l(!1)},insert(m){const{index:y,displayValue:A,exportValue:v}=m.detail.insert,w=n.children[y],S=document.createElement("option");a(S,A),S.value=v,w?w.before(S):n.append(S),t.setValue(e,{value:l(!0),items:c(m)}),h=l(!1)},items(m){const{items:y}=m.detail;for(;n.length!==0;)n.remove(0);for(const A of y){const{displayValue:v,exportValue:w}=A,S=document.createElement("option");a(S,v),S.value=w,n.append(S)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:l(!0),items:c(m)}),h=l(!1)},indices(m){const y=new Set(m.detail.indices);for(const A of m.target.options)A.selected=y.has(A.index);t.setValue(e,{value:l(!0)}),h=l(!1)},editable(m){m.target.disabled=!m.detail.editable}};this._dispatchEventFromSandbox(p,d)}),n.addEventListener("input",d=>{var y;const p=l(!0),m=l(!1);t.setValue(e,{value:p}),d.preventDefault(),(y=this.linkService.eventBus)==null||y.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:m,changeEx:p,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"]],d=>d.target.value)):n.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}var Fc,lp;class op extends Mt{constructor(e){const{data:s,elements:n,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&Mt._hasPopupData(s)});g(this,Fc);if(this.elements=n,a&&Mt._hasPopupData(s)){const o=this.popup=b(this,Fc,lp).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";
46const s=this.popup=b(this,Fc,lp).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=>`${bo}${r}`).join(",")),this.container}}Fc=new WeakSet,lp=function(){return new r0({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 ss,rr,Bu,Hu,yl,Al,Ft,mi,ar,Ma,wl,vl,bi,is,an,on,Ot,ln,or,Oc,hn,Sl,Da,lr,te,hr,X,jd,hp,cp,dp,Vd,up,ub,fb,pb,gb,Wd,Xd,fp;class r0{constructor({container:t,color:e,elements:s,titleObj:n,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:d,commentManager:p=null}){g(this,X);g(this,ss,null);g(this,rr,b(this,X,pb).bind(this));g(this,Bu,b(this,X,fp).bind(this));g(this,Hu,b(this,X,Xd).bind(this));g(this,yl,b(this,X,Wd).bind(this));g(this,Al,null);g(this,Ft,null);g(this,mi,null);g(this,ar,null);g(this,Ma,null);g(this,wl,null);g(this,vl,null);g(this,bi,!1);g(this,is,null);g(this,an,null);g(this,on,null);g(this,Ot,null);g(this,ln,null);g(this,or,null);g(this,Oc,null);g(this,hn,null);g(this,Sl,null);g(this,Da,null);g(this,lr,!1);g(this,te,null);g(this,hr,null);f(this,Ft,t),f(this,Sl,n),f(this,mi,a),f(this,hn,o),f(this,wl,l),f(this,Al,e),f(this,Oc,h),f(this,vl,c),f(this,Ma,s),f(this,ss,p),f(this,te,s[0]),f(this,ar,du.toDateObject(r)),this.trigger=s.flatMap(m=>m.getElementsToTriggerPopup()),p||(b(this,X,jd).call(this),i(this,Ft).hidden=!0,d&&b(this,X,Wd).call(this))}renderCommentButton(){if(i(this,Ot)){i(this,Ot).parentNode||i(this,te).container.after(i(this,Ot));return}if(i(this,ln)||b(this,X,hp).call(this),!i(this,ln))return;const{signal:t}=f(this,an,new AbortController),e=i(this,te).hasOwnCommentButton,s=()=>{i(this,ss).toggleCommentPopup(this,!0,void 0,!e)},n=()=>{i(this,ss).toggleCommentPopup(this,!1,!0,!e)},r=()=>{i(this,ss).toggleCommentPopup(this,!1,!1)};if(e){f(this,Ot,i(this,te).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",i(this,rr),{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,Ot,document.createElement("button"));a.className="annotationCommentButton";const o=i(this,te).container;a.style.zIndex=parseInt(o.style.zIndex,10)+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),b(this,X,dp).call(this),b(this,X,cp).call(this),a.addEventListener("keydown",i(this,rr),{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,te).commentData;return t?i(this,wl)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=i(this,Ot))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:n,modificationDate:r}=i(this,te).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:n,modificationDate:r}}get elementBeforePopup(){return i(this,Ot)}get comment(){return i(this,hr)||f(this,hr,i(this,te).commentText),i(this,hr)}set comment(t){t!==this.comment&&(i(this,te).commentText=f(this,hr,t))}focus(){var t;(t=i(this,te).container)==null||t.focus()}get parentBoundingClientRect(){return i(this,te).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){i(this,Ot)&&(i(this,Ot).classList.toggle("selected",t),i(this,Ot).ariaExpanded=e)}setSelectedCommentButton(t){i(this,Ot).classList.toggle("selected",t)}get commentPopupPosition(){if(i(this,or))return i(this,or);const{x:t,y:e,height:s}=i(this,Ot).getBoundingClientRect(),{x:n,y:r,width:a,height:o}=i(this,te).layer.getBoundingClientRect();return[(t-n)/a,(e+s-r)/o]}set commentPopupPosition(t){f(this,or,t)}hasDefaultPopupPosition(){return i(this,or)===null}get commentButtonPosition(){return i(this,ln)}get commentButtonWidth(){return i(this,Ot).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=i(this,or)||this.commentButtonPosition.map(h=>h/100),n=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=n;i(this,ss).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:n})}render(){var s,n;if(i(this,is))return;const t=f(this,is,document.createElement("div"));if(t.className="popup",i(this,Al)){const r=t.style.outlineColor=M.makeHexColor(...i(this,Al));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=i(this,Sl))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=i(this,Sl)}if(t.append(e),i(this,ar)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:i(this,ar).valueOf()})),r.dateTime=i(this,ar).toISOString(),e.append(r)}Wg({html:i(this,X,Vd)||i(this,mi).str,dir:(n=i(this,mi))==null?void 0:n.dir,className:"popupContent"},t),i(this,Ft).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var n;if(i(this,ss)){s?(this.remove(),f(this,hr,null)):e&&(e.deleted?this.remove():(b(this,X,dp).call(this),f(this,hr,e.text))),t&&(f(this,ln,null),b(this,X,hp).call(this),b(this,X,cp).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}b(this,X,jd).call(this),i(this,Da)||f(this,Da,{contentsObj:i(this,mi),richText:i(this,hn)}),t&&f(this,on,null),e&&e.text&&(f(this,hn,b(this,X,fb).call(this,e.text)),f(this,ar,du.toDateObject(e.date)),f(this,mi,null)),(n=i(this,is))==null||n.remove(),f(this,is,null)}resetEdited(){var t;i(this,Da)&&({contentsObj:$t(this,mi)._,richText:$t(this,hn)._}=i(this,Da),f(this,Da,null),(t=i(this,is))==null||t.remove(),f(this,is,null),f(this,on,null))}remove(){var t,e,s;if((t=i(this,an))==null||t.abort(),f(this,an,null),(e=i(this,is))==null||e.remove(),f(this,is,null),f(this,lr,!1),f(this,bi,!1),(s=i(this,Ot))==null||s.remove(),f(this,Ot,null),this.trigger)for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){f(this,lr,this.isVisible),i(this,lr)&&(i(this,Ft).hidden=!0)}maybeShow(){i(this,ss)||(b(this,X,jd).call(this),i(this,lr)&&(i(this,is)||b(this,X,Xd).call(this),f(this,lr,!1),i(this,Ft).hidden=!1))}get isVisible(){return i(this,ss)?!1:i(this,Ft).hidden===!1}}ss=new WeakMap,rr=new WeakMap,Bu=new WeakMap,Hu=new WeakMap,yl=new WeakMap,Al=new WeakMap,Ft=new WeakMap,mi=new WeakMap,ar=new WeakMap,Ma=new WeakMap,wl=new WeakMap,vl=new WeakMap,bi=new WeakMap,is=new WeakMap,an=new WeakMap,on=new WeakMap,Ot=new WeakMap,ln=new WeakMap,or=new WeakMap,Oc=new WeakMap,hn=new WeakMap,Sl=new WeakMap,Da=new WeakMap,lr=new WeakMap,te=new WeakMap,hr=ne
46w WeakMap,X=new WeakSet,jd=function(){var e;if(i(this,an))return;f(this,an,new AbortController);const{signal:t}=i(this,an);for(const s of this.trigger)s.addEventListener("click",i(this,yl),{signal:t}),s.addEventListener("pointerenter",i(this,Hu),{signal:t}),s.addEventListener("pointerleave",i(this,Bu),{signal:t}),s.classList.add("popupTriggerArea");for(const s of i(this,Ma))(e=s.container)==null||e.addEventListener("keydown",i(this,rr),{signal:t})},hp=function(){const t=i(this,Ma).find(e=>e.hasCommentButton);t&&f(this,ln,t._normalizePoint(t.commentButtonPosition))},cp=function(){if(i(this,te).extraPopupElement&&!i(this,te).editor)return;i(this,Ot)||this.renderCommentButton();const[t,e]=i(this,ln),{style:s}=i(this,Ot);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},dp=function(){i(this,te).extraPopupElement||(i(this,Ot)||this.renderCommentButton(),i(this,Ot).style.backgroundColor=this.commentButtonColor||"")},Vd=function(){const t=i(this,hn),e=i(this,mi);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&i(this,hn).html||null},up=function(){var t,e,s;return((s=(e=(t=i(this,X,Vd))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},ub=function(){var t,e,s;return((s=(e=(t=i(this,X,Vd))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},fb=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:i(this,X,ub),fontSize:i(this,X,up)?`calc(${i(this,X,up)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
47`))e.push({name:"span",value:r,attributes:n});return s},pb=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&i(this,bi))&&b(this,X,Wd).call(this)},gb=function(){if(i(this,on)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:n,pageY:r}}}=i(this,wl);let a=!!i(this,vl),o=a?i(this,vl):i(this,Oc);for(const y of i(this,Ma))if(!o||M.intersect(y.data.rect,o)!==null){o=y.data.rect,a=!0;break}const l=M.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),c=a?o[2]-o[0]+5:0,d=l[0]+c,p=l[1];f(this,on,[100*(d-n)/e,100*(p-r)/s]);const{style:m}=i(this,Ft);m.left=`${i(this,on)[0]}%`,m.top=`${i(this,on)[1]}%`},Wd=function(){if(i(this,ss)){i(this,ss).toggleCommentPopup(this,!1);return}f(this,bi,!i(this,bi)),i(this,bi)?(b(this,X,Xd).call(this),i(this,Ft).addEventListener("click",i(this,yl)),i(this,Ft).addEventListener("keydown",i(this,rr))):(b(this,X,fp).call(this),i(this,Ft).removeEventListener("click",i(this,yl)),i(this,Ft).removeEventListener("keydown",i(this,rr)))},Xd=function(){i(this,is)||this.render(),this.isVisible?i(this,bi)&&i(this,Ft).classList.add("focused"):(b(this,X,gb).call(this),i(this,Ft).hidden=!1,i(this,Ft).style.zIndex=parseInt(i(this,Ft).style.zIndex,10)+1e3)},fp=function(){i(this,Ft).classList.remove("focused"),!(i(this,bi)||!this.isVisible)&&(i(this,Ft).hidden=!0,i(this,Ft).style.zIndex=parseInt(i(this,Ft).style.zIndex,10)-1e3)};class mb extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=G.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=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.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var Nc;class a0 extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Nc,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,Nc,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.re
47ct[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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return i(this,Nc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Nc=new WeakMap;var Bc;class o0 extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Bc,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,Bc,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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return i(this,Bc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Bc=new WeakMap;var Hc;class l0 extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Hc,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,Hc,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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return i(this,Hc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Hc=new WeakMap;var Uc;class bb extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Uc,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:n,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let h=[];for(let d=0,p=s.length;d<p;d+=2){const m=s[d]-e[0],y=e[3]-s[d+1];h.push(`${m},${y}`)}h=h.join(" ");const c=f(this,Uc,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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return i(this,Uc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Uc=new WeakMap;class h0 extends bb{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class c0 extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}var Gc,Ia,$c,pp;class tg extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,$c);g(this,Gc,null);g(this,Ia,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?G.HIGHLIGHT:G.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}=b(this,$c,pp).call(this,s,e),c=this.svgFactory.create(l,h,!0),d=f(this,Gc,this.svgFactory.createElement("svg:g"));c.append(d),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",o);for(let p=0,m=n.length;p<m;p++){const y=this.svgFactory.createElement(this.svgElementName);i(this,Ia).push(y),y.setAttribute("points",n[p].join(",")),d.append(y)}return!a&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:n,rect:r}=e,a=i(this,Gc);if(s>=0&&a.setAttribute("stroke-width",s||1),n)for(let o=0,l=i(this,Ia).length;o<l;o++)i(this,Ia)[o].setAttribute("points",n[o].join(","));if(r){const{transform:o,width:l,height:h}=b(this,$c,pp).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return i(this,Ia)}addHighlightArea(){this.container.classList.add("highlightArea")}}Gc=new WeakMap,Ia=new WeakMap,$c=new WeakSet,pp=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class yb extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=G.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,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}}
47class d0 extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,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 u0 extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,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 f0 extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,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 Ab extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=G.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var zc,jc,gp;class p0 extends Mt{constructor(e){var n;super(e,{isRenderable:!0});g(this,jc);g(this,zc,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(n=this.linkService.eventBus)==null||n.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let n;s.hasAppearance||s.fillAlpha===0?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),n.addEventListener("dblclick",b(this,jc,gp).bind(this)),f(this,zc,n);const{isMac:r}=Wt.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,jc,gp).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return i(this,zc)}addHighlightArea(){this.container.classList.add("highlightArea")}}zc=new WeakMap,jc=new WeakSet,gp=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var La,Ra,El,cr,Vc,Fa,ns,Wc,vn,Yd,bp;const hg=class hg{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:n,page:r,viewport:
47a,structTreeLayer:o,commentManager:l,linkService:h,annotationStorage:c}){g(this,vn);g(this,La,null);g(this,Ra,null);g(this,El,null);g(this,cr,new Map);g(this,Vc,null);g(this,Fa,null);g(this,ns,[]);g(this,Wc,!1);x(this,"zIndex",0);this.div=t,f(this,La,e),f(this,Ra,s),f(this,Vc,o||null),f(this,Fa,h||null),f(this,El,c||new Qp),this.page=r,this.viewport=a,this._annotationEditorUIManager=n,this._commentManager=l||null}hasEditableAnnotations(){return i(this,cr).size>0}async render(t){var o;const{annotations:e}=t,s=this.div;eo(s,this.viewport);const n=new Map,r=[],a={data:null,layer:s,linkService:i(this,Fa),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new mu,annotationStorage:i(this,El),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const l of e){if(l.noHTML)continue;const h=l.annotationType===jt.POPUP;if(h){const p=n.get(l.id);if(!p)continue;if(!this._commentManager){r.push(l);continue}a.elements=p}else if(l.rect[2]===l.rect[0]||l.rect[3]===l.rect[1])continue;a.data=l;const c=gf.create(a);if(!c.isRenderable)continue;h||(i(this,ns).push(c),l.popupRef&&n.getOrInsertComputed(l.popupRef,Vp).push(c));const d=c.render();l.hidden&&(d.style.visibility="hidden"),c._isEditable&&(i(this,cr).set(c.data.id,c),(o=this._annotationEditorUIManager)==null||o.renderAnnotationElement(c))}await b(this,vn,Yd).call(this);for(const l of r){const h=a.elements=n.get(l.id);a.data=l;const c=gf.create(a);if(!c.isRenderable)continue;const d=c.render();c.contentElement.id=`${bo}${l.id}`,l.hidden&&(d.style.visibility="hidden"),h.at(-1).container.after(d)}b(this,vn,bp).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:i(this,Fa),svgFactory:new mu,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=hg._defaultBorderStyle),e.data=s;const n=gf.create(e);n.isRenderable&&(n.render(),n.contentElement.id=`${bo}${s.id}`,i(this,ns).push(n))}await b(this,vn,Yd).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,eo(e,{rotation:t.rotation}),b(this,vn,bp).call(this),e.hidden=!1}getEditableAnnotations(){return i(this,cr).values()}getEditableAnnotation(t){return i(this,cr).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:n}=t,r=new JA({data:{id:s,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:i(this,Fa),annotationStorage:i(this,El)});return r.render(),r.contentElement.id=`${bo}${s}`,r.createOrUpdatePopup(),i(this,ns).push(r),r}removeAnnotation(t){var n;const e=i(this,ns).findIndex(r=>r.data.id===t);if(e<0)return;const[s]=i(this,ns).splice(e,1);(n=i(this,La))==null||n.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);b(this,vn,Yd).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return $(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:oo.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};La=new WeakMap,Ra=new WeakMap,El=new WeakMap,cr=new WeakMap,Vc=new WeakMap,Fa=new WeakMap,ns=new WeakMap,Wc=new WeakMap,vn=new WeakSet,Yd=async function(){var s,n,r;if(i(this,ns).length===0)return;this.div.replaceChildren();const t=[];if(!i(this,Wc)){f(this,Wc,!0);for(const{contentElement:a,data:{id:o}}of i(this,ns)){const l=a.id=`${bo}${o}`;t.push((s=i(this,Vc))==null?void 0:s.getAriaAttributes(l).then(h=>{if(h)for(const[c,d]of h)a.setAttribute(c,d)}))}}i(this,ns).sort(({data:{rect:[a,o,l,h]}},{data:{rect:[c,d,p,m]}})=>{if(a===l&&o===h)return 1;if(c===p&&d===m)return-1;const y=h,A=o,v=(o+h)/2,w=m,S=d,E=(d+m)/2;if(v>=w&&E<=A)return-1;if(E>=y&&v<=S)return 1;const _=(a+l)/2,C=(c+p)/2;return _-C});const e=document.createDocumentFragment();for(const a of i(this,ns))e.append(a.container),this._commentManager?(r=((n=a.extraPopupElement)==null?void 0:n.popup)||a.popup)==null||r.renderCommentButton():a.extraPopupElement&&e.append(a.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),i(this,La))for(const a of i(this,ns))i(this,La).addPointerInTextLayer(a.contentElement,!1)},bp=function(){var e;if(!i(this,Ra))return;const t=this.div;for(const[s,n]of i(this,Ra)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;n.className="annotationContent";const{firstChild:a}=r;a?a.nodeName==="CANVAS"?a.replaceWith(n):a.classList.contains("annotationContent")?a.after(n):a.before(n):r.append(n);const o=i(this,cr).get(s);o&&(o._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,n),o._hasNoCanvas=!1):o.canvas=n)}i(this,Ra).clear()};let mp=hg;const Ed=/\r\n?|\n/g;var rs,Xc,Oa,as,Xt,wb,vb,Sb,Kd,Sn,qd,Qd,Eb,Ap,_b;const At=class At extends yt{constructor(e){super({...e,name:"freeTextEditor"});g(this,Xt);g(this,rs,"");g(this,Xc,`${this.id}-editor`);g(this,Oa,null);g(this,as);x(this,"_colorPicker",null);this.color=e.color||At._defaultColor||yt._defaultLineColor,f(this,as,e.fontSize||At._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static get _keyboardManager(){const e=At.prototype,s=a=>a.isEmpty(),n=so.TRANSLATE_SMALL,r=so.TRANSLATE_BIG;return $(this,"_keyboardManager",new md([[["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){yt.initialize(e,s);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}
47static updateDefaultParams(e,s){switch(e){case V.FREETEXT_SIZE:At._defaultFontSize=s;break;case V.FREETEXT_COLOR:At._defaultColor=s;break}}updateParams(e,s){switch(e){case V.FREETEXT_SIZE:b(this,Xt,wb).call(this,s);break;case V.FREETEXT_COLOR:b(this,Xt,vb).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[V.FREETEXT_SIZE,At._defaultFontSize],[V.FREETEXT_COLOR,At._defaultColor||yt._defaultLineColor]]}get propertiesToUpdate(){return[[V.FREETEXT_SIZE,i(this,as)],[V.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new gu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return V.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-At._internalPadding*e,-(At._internalPadding+i(this,as))*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,Oa,new AbortController);const e=this._uiManager.combinedSignal(i(this,Oa));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",i(this,Xc)),this._isDraggable=!0,(e=i(this,Oa))==null||e.abort(),f(this,Oa,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=i(this,rs),s=f(this,rs,b(this,Xt,Sb).call(this).trimEnd());if(e===s)return;const n=r=>{if(f(this,rs,r),!r){this.remove();return}b(this,Xt,Qd).call(this),this._uiManager.rebuild(this),b(this,Xt,Kd).call(this)};this.addCommands({cmd:()=>{n(s)},undo:()=>{n(e)},mustExec:!1}),b(this,Xt,Kd).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){At._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,Xc)),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,as)}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;
47if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[c,d]=this.pageDimensions,[p,m]=this.pageTranslation;let y,A;switch(this.rotation){case 0:y=e+(o[0]-p)/c,A=s+this.height-(o[1]-m)/d;break;case 90:y=e+(o[0]-p)/c,A=s-(o[1]-m)/d,[l,h]=[h,-l];break;case 180:y=e-this.width+(o[0]-p)/c,A=s-(o[1]-m)/d,[l,h]=[-l,-h];break;case 270:y=e+(o[0]-p-this.height*d)/c,A=s+(o[1]-m-this.width*c)/d,[l,h]=[-h,l];break}this.setAt(y*r,A*a,l,h)}else this._moveAfterPaste(e,s);b(this,Xt,Qd).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var y,A,v;const s=e.clipboardData||window.clipboardData,{types:n}=s;if(n.length===1&&n[0]==="text/plain")return;e.preventDefault();const r=b(y=At,Sn,Ap).call(y,s.getData("text")||"").replaceAll(Ed,`
48`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
49`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,c=[],d=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(d.push(l.nodeValue.slice(h).replaceAll(Ed,"")),w!==this.editorDiv){let S=c;for(const E of this.editorDiv.childNodes){if(E===w){S=d;continue}S.push(b(A=At,Sn,qd).call(A,E))}}c.push(l.nodeValue.slice(0,h).replaceAll(Ed,""))}else if(l===this.editorDiv){let w=c,S=0;for(const E of this.editorDiv.childNodes)S++===h&&(w=d),w.push(b(v=At,Sn,qd).call(v,E))}f(this,rs,`${c.join(`
50`)}${r}${d.join(`
51`)}`),b(this,Xt,Qd).call(this);const p=new Range;let m=Math.sumPrecise(c.map(w=>w.length));for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const S=w.nodeValue.length;if(m<=S){p.setStart(w,m),p.setEnd(w,m);break}m-=S}a.removeAllRanges(),a.addRange(p)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=At._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,n){var o;let r=null;if(e instanceof mb){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:d,id:p,popupRef:m,richText:y,contentsObj:A,creationDate:v,modificationDate:w},textContent:S,textPosition:E,parent:{page:{pageNumber:_}}}=e;if(!S||S.length===0)return null;r=e={annotationType:G.FREETEXT,color:Array.from(h),fontSize:l,value:S.join(`
52`),position:E,pageIndex:_-1,rect:c.slice(0),rotation:d,annotationElementId:p,id:p,deleted:!1,popupRef:m,comment:(A==null?void 0:A.str)||null,richText:y,creationDate:v,modificationDate:w}}const a=await super.deserialize(e,s,n);return f(a,as,e.fontSize),a.color=M.makeHexColor(...e.color),f(a,rs,b(o=At,Sn,Ap).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=yt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:s,fontSize:i(this,as),value:b(this,Xt,Eb).call(this)});return this.addComment(n),e?(n.isCopy=!0,n):this.annotationElementId&&!b(this,Xt,_b).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,as)}px * var(--total-scale-factor))`,n.color=this.color,s.replaceChildren();for(const r of i(this,rs).split(`
53`)){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,rs)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};rs=new WeakMap,Xc=new WeakMap,Oa=new WeakMap,as=new WeakMap,Xt=new WeakSet,wb=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-i(this,as))*this.parentScale),f(this,as,r),b(this,Xt,Kd).c
53all(this)},n=i(this,as);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},vb=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:V.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Sb=function(){var n;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(b(n=At,Sn,qd).call(n,r)),s=r);return e.join(`
54`)},Kd=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()},Sn=new WeakSet,qd=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Ed,"")},Qd=function(){if(this.editorDiv.replaceChildren(),!!i(this,rs))for(const e of i(this,rs).split(`
55`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Eb=function(){return i(this,rs).replaceAll(" "," ")},Ap=function(e){return e.replaceAll(" "," ")},_b=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(At,Sn),x(At,"_freeTextDefaultContent",""),x(At,"_internalPadding",0),x(At,"_defaultColor",null),x(At,"_defaultFontSize",10),x(At,"_type","freetext"),x(At,"_editorType",G.FREETEXT);let yp=At;class O{toSVGPath(){nt("Abstract method `toSVGPath` must be implemented.")}get box(){nt("Abstract getter `box` must be implemented.")}serialize(t,e){nt("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]}}x(O,"PRECISION",1e-4);var os,Xs,_l,Cl,yi,Q,Na,Ba,Yc,Kc,Tl,xl,dr,qc,Uu,Gu,Qt,gh,Cb,Tb,xb,Pb,kb,Mb;const Li=class Li{constructor({x:t,y:e},s,n,r,a,o=0){g(this,Qt);g(this,os);g(this,Xs,[]);g(this,_l);g(this,Cl);g(this,yi,[]);g(this,Q,new Float32Array(18));g(this,Na);g(this,Ba);g(this,Yc);g(this,Kc);g(this,Tl);g(this,xl);g(this,dr,[]);f(this,os,s),f(this,xl,r*n),f(this,Cl,a),i(this,Q).set([NaN,NaN,NaN,NaN,t,e],6),f(this,_l,o),f(this,Kc,i(Li,qc)*n),f(this,Yc,i(Li,Gu)*n),f(this,Tl,n),i(this,dr).push(t,e)}isEmpty(){return isNaN(i(this,Q)[8])}add({x:t,y:e}){var k;f(this,Na,t),f(this,Ba,e);const[s,n,r,a]=i(this,os);let[o,l,h,c]=i(this,Q).subarray(8,12);const d=t-h,p=e-c,m=Math.hypot(d,p);if(m<i(this,Yc))return!1;const y=m-i(this,Kc),A=y/m,v=A*d,w=A*p;let S=o,E=l;o=h,l=c,h+=v,c+=w,(k=i(this,dr))==null||k.push(t,e);const _=-w/y,C=v/y,T=_*i(this,xl),P=C*i(this,xl);return i(this,Q).set(i(this,Q).subarray(2,8),0),i(this,Q).set([h+T,c+P],4),i(this,Q).set(i(this,Q).subarray(14,18),12),i(this,Q).set([h-T,c-P],16),isNaN(i(this,Q)[6])?(i(this,yi).length===0&&(i(this,Q).set([o+T,l+P],2),i(this,yi).push(NaN,NaN,NaN,NaN,(o+T-s)/r,(l+P-n)/a),i(this,Q).set([o-T,l-P],14),i(this,Xs).push(NaN,NaN,NaN,NaN,(o-T-s)/r,(l-P-n)/a)),i(this,Q).set([S,E,o,l,h,c],6),!this.isEmpty()):(i(this,Q).set([S,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,S-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=i(this,Q).subarray(2,6),i(this,yi).push(NaN,NaN,NaN,NaN,((o+
55h)/2-s)/r,((l+c)/2-n)/a),[o,l,S,E]=i(this,Q).subarray(14,18),i(this,Xs).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((E+l)/2-n)/a),!0):([S,E,o,l,h,c]=i(this,Q).subarray(0,6),i(this,yi).push(((S+5*o)/6-s)/r,((E+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),[h,c,o,l,S,E]=i(this,Q).subarray(12,18),i(this,Xs).push(((S+5*o)/6-s)/r,((E+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,yi),e=i(this,Xs);if(isNaN(i(this,Q)[6])&&!this.isEmpty())return b(this,Qt,Cb).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]}`);b(this,Qt,xb).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 b(this,Qt,Tb).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,n,r,a){return new Db(t,e,s,n,r,a)}getOutlines(){var d;const t=i(this,yi),e=i(this,Xs),s=i(this,Q),[n,r,a,o]=i(this,os),l=new Float32Array((((d=i(this,dr))==null?void 0:d.length)??0)+2);for(let p=0,m=l.length-2;p<m;p+=2)l[p]=(i(this,dr)[p]-n)/a,l[p+1]=(i(this,dr)[p+1]-r)/o;if(l[l.length-2]=(i(this,Na)-n)/a,l[l.length-1]=(i(this,Ba)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,Qt,Pb).call(this,l);const h=new Float32Array(i(this,yi).length+24+i(this,Xs).length);let c=t.length;for(let p=0;p<c;p+=2){if(isNaN(t[p])){h[p]=h[p+1]=NaN;continue}h[p]=t[p],h[p+1]=t[p+1]}c=b(this,Qt,Mb).call(this,h,c);for(let p=e.length-6;p>=6;p-=6)for(let m=0;m<6;m+=2){if(isNaN(e[p+m])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[p+m],h[c+1]=e[p+m+1],c+=2}return b(this,Qt,kb).call(this,h,c),this.newFreeDrawOutline(h,l,i(this,os),i(this,Tl),i(this,_l),i(this,Cl))}};os=new WeakMap,Xs=new WeakMap,_l=new WeakMap,Cl=new WeakMap,yi=new WeakMap,Q=new WeakMap,Na=new WeakMap,Ba=new WeakMap,Yc=new WeakMap,Kc=new WeakMap,Tl=new WeakMap,xl=new WeakMap,dr=new WeakMap,qc=new WeakMap,Uu=new WeakMap,Gu=new WeakMap,Qt=new WeakSet,gh=function(){const t=i(this,Q).subarray(4,6),e=i(this,Q).subarray(16,18),[s,n,r,a]=i(this,os);return[(i(this,Na)+(t[0]-e[0])/2-s)/r,(i(this,Ba)+(t[1]-e[1])/2-n)/a,(i(this,Na)+(e[0]-t[0])/2-s)/r,(i(this,Ba)+(e[1]-t[1])/2-n)/a]},Cb=function(){const[t,e,s,n]=i(this,os),[r,a,o,l]=b(this,Qt,gh).call(this);return`M${(i(this,Q)[2]-t)/s} ${(i(this,Q)[3]-e)/n} L${(i(this,Q)[4]-t)/s} ${(i(this,Q)[5]-e)/n} L${r} ${a} L${o} ${l} L${(i(this,Q)[16]-t)/s} ${(i(this,Q)[17]-e)/n} L${(i(this,Q)[14]-t)/s} ${(i(this,Q)[15]-e)/n} Z`},Tb=function(t){const e=i(this,Xs);t.push(`L${e[4]} ${e[5]} Z`)},xb=function(t){const[e,s,n,r]=i(this,os),a=i(this,Q).subarray(4,6),o=i(this,Q).subarray(16,18),[l,h,c,d]=b(this,Qt,gh).call(this);t.push(`L${(a[0]-e)/n} ${(a[1]-s)/r} L${l} ${h} L${c} ${d} L${(o[0]-e)/n} ${(o[1]-s)/r}`)},Pb=function(t){const e=i(this,Q),[s,n,r,a]=i(this,os),[o,l,h,c]=b(this,Qt,gh).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-n)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-n)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-n)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-n)/a],0),this.newFreeDrawOutline(d,t,i(this,os),i(this,Tl),i(this,_l),i(this,Cl))},kb=function(t,e){const s=i(this,Xs);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Mb=function(t,e){const s=i(this,Q).subarray(4,6),n=i(this,Q).subarray(16,18),[r,a,o,l]=i(this,os),[h,c,d,p]=b(this,Qt,gh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,d,p,NaN,NaN,NaN,NaN,(n[0]-r)/o,(n[1]-a)/l],e),e+=24},g(Li,qc,8),g(Li,Uu,2),g(Li,Gu,i(Li,qc)+i(Li,Uu));let bu=Li;var Pl,Ha,cn,Qc,ls,Jc,Gt,$u,Ib;class Db extends O{constructor(e,s,n,r,a,o){super();g(this,$u);g(this,Pl);g(this,Ha,new Float32Array(4));g(this,cn);g(this,Qc);g(this,ls);g(this,Jc);g(this,Gt);f(this,Gt,e),f(this,ls,s),f(this,Pl,n),f(this,Jc,r),f(this,cn,a),f(this,Qc,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,$u,Ib).call(this,o);const[l,h,c,d]=i(this,Ha);for(let p=0,m=e.length;p<m;p+=2)e[p]=(e[p]-l)/c,e[p+1]=(e[p+1]-h)/d;for(let p=0,m=s.length;p<m;p+=2)s[p]=(s[p]-l)/c,s[p+1]=(s[p+1]-h)/d}toSVGPath(){const e=[`M${i(this,Gt)[4]} ${i(this,Gt)[5]}`];for(let s=6,n=i(this,Gt).length;s<n;s+=6){if(isNaN(i(this,Gt)[s])){e.push(`L${i(this,Gt)[s+4]} ${i(this,Gt)[s+5]}`);continue}e.push(`C${i(this,Gt)[s]} ${i(this,Gt)[s+1]} ${i(this,Gt)[s+2]} ${i(this,Gt)[s+3]} ${i(this,Gt)[s+4]} ${i(this,Gt)[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=O._rescale(i(this,Gt),e,r,o,-l),c=O._rescale(i(this,ls),e,r,o,-l);break;case 90:h=O._rescaleAndSwap(i(this,Gt),e,s,o,l),c=O._rescaleAndSwap(i(this,ls),e,s,o,l);break;case 180:h=O._rescale(i(this,Gt),n,s,-o,l),c=O._rescale(i(this,ls),n,s,-o,l);break;case 270:h=O._rescaleAndSwap(i(this,Gt),n,r,-o,-l),c=O._rescaleAndSwap(i(this,ls),n,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return i(this,Ha)}newOutliner(e,s,n,r,a,o=0){return new bu(e,s,n,r,a,o)}getNewOutline(e,s){const[n,r,a,o]=i(this,Ha),[l,h,c,d]=i(this,Pl),p=a*c,m=o*d,y=n*c+l,A=r*d+h,v=this.newOutliner({x:i(this,ls)[0]*p+y,y:i(this,ls)[1]*m+A},i(this,Pl),i(this,Jc),e,i(this,Qc),s??i(this,cn));for(let w=2;w<i(this,ls).length;w+=2)v.add({x:i(this,ls)[w]*p+y,y:i(this,ls)[w+1]*m+A});return v.getOutlines()}}Pl=new WeakMap,Ha=new WeakMap,cn=new WeakMap,Qc=new WeakMap,ls=new WeakMap,Jc=new WeakMap,Gt=new WeakMap,$u=ne
55w WeakSet,Ib=function(e){const s=i(this,Gt);let n=s[4],r=s[5];const a=[n,r,n,r];let o=n,l=r,h=n,c=r;const d=e?Math.max:Math.min,p=new Float32Array(4);for(let y=6,A=s.length;y<A;y+=6){const v=s[y+4],w=s[y+5];isNaN(s[y])?(M.pointBoundingBox(v,w,a),l>w?(o=v,l=w):l===w&&(o=d(o,v)),c<w?(h=v,c=w):c===w&&(h=d(h,v))):(p.set(An,0),M.bezierBoundingBox(n,r,...s.slice(y,y+6),p),M.rectBoundingBox(...p,a),l>p[1]?(o=p[0],l=p[1]):l===p[1]&&(o=d(o,p[0])),c<p[3]?(h=p[2],c=p[3]):c===p[3]&&(h=d(h,p[2]))),n=v,r=w}const m=i(this,Ha);m[0]=a[0]-i(this,cn),m[1]=a[1]-i(this,cn),m[2]=a[2]-a[0]+2*i(this,cn),m[3]=a[3]-a[1]+2*i(this,cn),this.firstPoint=[o,l],this.lastPoint=[h,c]};var Zc,td,ed,ur,Ys,Ne,Lb,Jd,Rb,Fb,vp;class wp{constructor(t,e=0,s=0,n=!0){g(this,Ne);g(this,Zc);g(this,td);g(this,ed);g(this,ur,[]);g(this,Ys,[]);const r=An.slice(),o=10**-4;for(const{x:v,y:w,width:S,height:E}of t){const _=Math.floor((v-e)/o)*o,C=Math.ceil((v+S+e)/o)*o,T=Math.floor((w-e)/o)*o,P=Math.ceil((w+E+e)/o)*o,D=[_,T,P,!0],k=[C,T,P,!1];i(this,ur).push(D,k),M.rectBoundingBox(_,T,C,P,r)}const l=r[2]-r[0]+2*s,h=r[3]-r[1]+2*s,c=r[0]-s,d=r[1]-s;let p=n?-1/0:1/0,m=1/0;const y=i(this,ur).at(n?-1:-2),A=[y[0],y[2]];for(const v of i(this,ur)){const[w,S,E,_]=v;!_&&n?S<m?(m=S,p=w):S===m&&(p=Math.max(p,w)):_&&!n&&(S<m?(m=S,p=w):S===m&&(p=Math.min(p,w))),v[0]=(w-c)/l,v[1]=(S-d)/h,v[2]=(E-d)/h}f(this,Zc,new Float32Array([c,d,l,h])),f(this,td,[p,m]),f(this,ed,A)}getOutlines(){i(this,ur).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of i(this,ur))e[3]?(t.push(...b(this,Ne,vp).call(this,e)),b(this,Ne,Rb).call(this,e)):(b(this,Ne,Fb).call(this,e),t.push(...b(this,Ne,vp).call(this,e)));return b(this,Ne,Lb).call(this,t)}}Zc=new WeakMap,td=new WeakMap,ed=new WeakMap,ur=new WeakMap,Ys=new WeakMap,Ne=new WeakSet,Lb=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],h=e[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const n=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,d]=a;s.delete(a);let p=o,m=l;for(r=[o,h],n.push(r);;){let y;if(s.has(c))y=c;else if(s.has(d))y=d;else break;s.delete(y),[o,l,h,c,d]=y,p!==o&&(r.push(p,m,o,m===l?l:h),p=o),m=m===l?h:l}r.push(p,m)}return new g0(n,i(this,Zc),i(this,td),i(this,ed))},Jd=function(t){const e=i(this,Ys);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},Rb=function([,t,e]){const s=b(this,Ne,Jd).call(this,t);i(this,Ys).splice(s,0,[t,e])},Fb=function([,t,e]){const s=b(this,Ne,Jd).call(this,t);for(let n=s;n<i(this,Ys).length;n++){const[r,a]=i(this,Ys)[n];if(r!==t)break;if(r===t&&a===e){i(this,Ys).splice(n,1);return}}for(let n=s-1;n>=0;n--){const[r,a]=i(this,Ys)[n];if(r!==t)break;if(r===t&&a===e){i(this,Ys).splice(n,1);return}}},vp=function(t){const[e,s,n]=t,r=[[e,s,n]],a=b(this,Ne,Jd).call(this,n);for(let o=0;o<a;o++){const[l,h]=i(this,Ys)[o];for(let c=0,d=r.length;c<d;c++){const[,p,m]=r[c];if(!(h<=p||m<=l)){if(p>=l){if(m>h)r[c][1]=h;else{if(d===1)return[];r.splice(c,1),c--,d--}continue}r[c][2]=l,m>h&&r.push([e,h,m])}}}return r};var sd,kl;class g0 extends O{constructor(e,s,n,r){super();g(this,sd);g(this,kl);f(this,kl,e),f(this,sd,s),this.firstPoint=n,this.lastPoint=r}toSVGPath(){const e=[];for(const s of i(this,kl)){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,kl)){const d=new Array(c.length);for(let p=0;p<c.length;p+=2)d[p]=e+c[p]*l,d[p+1]=r-c[p+1]*h;o.push(d)}return o}get box(){return i(this,sd)}get classNamesForOutlining(){return["highlightOutline"]}}sd=new WeakMap,kl=new WeakMap;class Sp extends bu{newFreeDrawOutline(t,e,s,n,r,a){return new m0(t,e,s,n,r,a)}}class m0 extends Db{newOutliner(t,e,s,n,r,a=0){return new Sp(t,e,s,n,r,a)}}var Ml,id,dn,Ua,nd,je,rd,ad,Ga,hs,cs,de,Dl,Il,Ee,Ll,Ds,od,W,Ep,Zd,Ob,Nb,Bb,_p,Pr,Ls,go,Hb,tu,eu,Ub,Gb,$b,zb,jb;const st=class st extends yt{constructor(e){super({...e,name:"highlightEditor"});g(this,W);g(this,Ml,null);g(this,id,0);g(this,dn);g(this,Ua,null);g(this,nd,null);g(this,je,null);g(this,rd,null);g(this,ad,0);g(this,Ga,null);g(this,hs,null);g(this,cs,null);g(this,de,!1);g(this,Dl,null);g(this,Il,null);g(this,Ee,null);g(this,Ll,"");g(this,Ds);g(this,od,"");this.color=e.color||st._defaultColor,f(this,Ds,e.thickness||st._defaultThickness),this.opacity=e.opacity||st._defaultOpacity,f(this,dn,e.boxes||null),f(this,od,e.methodOfCreation||""),f(this,Ll,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(f(this,de,!0),b(this,W,Zd).call(this,e),b(this,W,Pr).call(this)):i(this,dn)&&(f(this,Ml,e.anchorNode),f(this,id,e.anchorOffset),f(this,rd,e.focusNode),f(this,ad,e.focusOffset),b(this,W,Ep).call(this),b(this,W,Pr).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=st.prototype;return $(this,"_keyboardManager",new md([[["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,de)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:i(this,Ds),methodOfCreation:i(this,od)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("
55color").size}}static initialize(e,s){var n;yt.initialize(e,s),st._defaultColor||(st._defaultColor=((n=s.highlightColors)==null?void 0:n.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case V.HIGHLIGHT_COLOR:st._defaultColor=s;break;case V.HIGHLIGHT_THICKNESS:st._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return i(this,Il)}get commentButtonPosition(){return i(this,Dl)}updateParams(e,s){switch(e){case V.HIGHLIGHT_COLOR:b(this,W,Ob).call(this,s);break;case V.HIGHLIGHT_THICKNESS:b(this,W,Nb).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[V.HIGHLIGHT_COLOR,st._defaultColor],[V.HIGHLIGHT_THICKNESS,st._defaultThickness]]}get propertiesToUpdate(){return[[V.HIGHLIGHT_COLOR,this.color||st._defaultColor],[V.HIGHLIGHT_THICKNESS,i(this,Ds)||st._defaultThickness],[V.HIGHLIGHT_FREE,i(this,de)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(i(this,cs),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=i(this,nd))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",f(this,nd,new pu({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(b(this,W,eu).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,W,eu).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){b(this,W,_p).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,W,Pr).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let s=!1;this.parent&&!e?b(this,W,_p).call(this):e&&(b(this,W,Pr).call(this,e),s=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let n;i(this,de)?(e=(e-this.rotation+360)%360,n=b(r=st,Ls,go).call(r,i(this,hs).box,e)):n=b(a=st,Ls,go).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(i(this,cs),{bbox:n,root:{"data-main-rotation":e}}),s.updateProperties(i(this,Ee),{bbox:b(o=st,Ls,go).call(o,i(this,je).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();i(this,Ll)&&(e.setAttribute("aria-label",i(this,Ll)),e.setAttribute("role","mark")),i(this,de)?e.classList.add("free"):this.div.addEventListener("keydown",b(this,W,Hb).bind(this),{signal:this._uiManager._signal});const s=f(this,Ga,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=i(this,Ua),this.setDims(),Zg(this,i(this,Ga),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(i(this,Ee),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(i(this,Ee),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,W,tu).call(this,!0);break;case 1:case 3:b(this,W,tu).call(this,!1);break}}select(){var e;super.select(),i(this,Ee)&&((e=this.parent)==null||e.drawLayer.updateProperties(i(this,Ee),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),i(this,Ee)&&((e=this.parent)==null||e.drawLayer.updateProperties(i(this,Ee),{rootClass:{selected:!1}}),i(this,de)||b(this,W,tu).call(this,!1))}get _mustFixPosition(){return!i(this,de)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(i(this,cs),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(i(this,Ee),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:n,x:r,y:a}){const{x:o,y:l,width:h,height:c}=n.getBoundingClientRect(),d=new AbortController,p=e.combinedSignal(d),m=y=>{d.abort(),b(this,Ls,zb).call(this,e,y)};window.addEventListener("blur",m,{signal:p}),window.addEventListener("pointerup",m,{signal:p}),window.addEventListener("pointerdown",Pt,{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",Fs,{signal:p}),n.addEventListener("pointermove",b(this,Ls,$b).bind(this,e),{signal:p}),this._freeHighlight=new Sp({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 v,w,S,E;let r=null;if(e instanceof yb){const{data:{quadPoints:_,rect:C,rotation:T,id:P,color:D,opacity:k,popupRef:R,richText:I,contentsObj:K,creationDate:q,modificationDate:Y},parent:{page:{pageNumber:J}}}=e;r=e={annotationType:G.HIGHLIGHT,color:Array.from(D),opacity:k,quadPoints:_,boxes:null,pageIndex:J-1,rect:C.slice(0),rotation:T,annotationElementId:P,id:P,deleted:!1,popupRef:R,richText:I,comment:(K==null?void 0:K.str)||null,creationDate:q,modificationDate:Y}}else if(e instanceof tg){const{data:{inkLists:_,rect:C,rotation:T,id:P,color:D,borderStyle:{rawWidth:k},popupRef:R,richText:I,contentsObj:K,creationDate:q,modificationDate:Y},parent:{page:{pageNumber:J}}}=e;r=e={annotationType:G.HIGHLIGHT,color:Array.from(D),thickness:k,inkLists:_,boxes:null,pageIndex:J-1,rect:C.slice(0),rotation:T,annotationElementId:P,id:P,deleted:!1,popupRef:R,richText:I,comment:(K==null?void 0:K.str)||null,creationDate:q,modificationDate:Y}}const{color:a,quadPoints:o,inkLists:l,outlines:h,opacity:c}=e,d=await super.deserialize(e,s,n);d.color=M.makeHexColor(...a),d.opacity=c||1,l&&f(d,Ds,e.thickness),d._initialData=r,e.comment&&d.setCommentData(e);const[p,m]=d.pageDimensions,[y,A]=d.pageTranslation;if(o){const _=f(d,dn,[]);for(let C=0;C<o.length;C+=8)_.push({x:(o[C]-y)/p,y:1-(o[C+1]-A)/m,width:(o[C+2]-o[C])/p,height:(o[C+1]-o[C+5])/m});b(v=d,W,Ep).call(v),b(w=d,W,Pr).call(w),d.rotate(d.rotation)}else if(l||h){f(d,de,!0);const _=(l||h.points)[0],C={x:_[0]-y,y:m-(_[1]-A)},T=new Sp(C,[0,0,p,m],1,i(d,Ds)/2,!0,.001);for(let k=0,R=_.length;k<R;k+=2)C.x=_[k]-y,C.y=m-(_[k+1]-A),T.add(C);const{id:P,clipPathId:D}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:T.toSVGPath()}},!0,!0);b(S=d,W,Zd).call(S,{highlightOutlines:T.getOutlines(),highlightId:P,clipPathId:D}),b(E=d,W,Pr).call(E),d.rotate(d.parentRotation)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=yt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:s,opacity:this.opacity,thickness:i(this,Ds),quadPoints:b(this,W,Ub).call(this),outlines:b(this,W,Gb).call(this,n.rect)}),this.addComment(n),this.annotationElementId&&!b(this,W,jb).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}};Ml=new WeakMap,id=new WeakMap,dn=new WeakMap,Ua=new WeakMap,nd=new WeakMap,je=new WeakMap,rd=new WeakMap,ad=new WeakMap,Ga=new WeakMap,hs=new WeakMap,cs=new WeakMap,de=new WeakMap,Dl=new WeakMap,Il=new WeakMap,Ee=new WeakMap,Ll=new WeakMap,Ds=new WeakMap,od=new WeakMap,W=new WeakSet,Ep=function(){const e=new wp(i(this,dn),.001);f(this,hs,e.getOutlines()),[this.x,this.y,this.width,this.height]=i(this,hs).box;const s=new wp(i(this,dn),.0025,.001,this._uiManager.direction==="ltr");f(this,je,s.getOutlines());const{firstPoint:n}=i(this,hs);f(this,Dl,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]);const{lastPoint:r}=i(this,je);f(this,Il,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},Zd=function({highlightOutlines:e,highlightId:s,clipPathId:n}){var p,m;if(f(this,hs,e),f(this,je,e.getNewOutline(i(this,Ds)/2+1.5,.0025)),s>=0)f(this,cs,s),f(this,Ua,n),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),f(this,Ee,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:i(this,je).box,path:{d:i(this,je).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(i(this,cs),{bbox:b(p=st,Ls,go).call(p,i(this,hs).box,(y-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(i(this,Ee),{bbox:b(m=st,Ls,go).call(m,i(this,je).box,y),path:{d:i(this,je).toSVGPath()}})}const[a,o,l,h]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[y,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/y,this.height=h*y/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[y,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/y,this.height=h*y/A;break}}const{firstPoint:c}=e;f(this,Dl,[(c[0]-a)/l,(c[1]-o)/h]);const{lastPoint:d}=i(this,je);f(this,Il,[(d[0]-a)/l,(d[1]-o)/h])},Ob=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,st._defaultOpacity),undo:s.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},Nb=function(e){const s=i(this,Ds),n=r=>{f(this,Ds,r),b(this,W,Bb).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:V.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Bb=function(e){i(this,de)&&(b(this,W,Zd).call(this,{highlightOutlines:i(this,hs).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},_p=function(){i(this,cs)===null||!this.parent||(this.parent.drawLayer.remove(i(this,cs)),f(this,cs,null),this.parent.drawLayer.remove(i(this,Ee)),f(this,Ee,null))},Pr=function(e=this.parent){i(this,cs)===null&&({id:$t(this,cs)._,clipPathId:$t(this,Ua
55)._}=e.drawLayer.draw({bbox:i(this,hs).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:i(this,de)},path:{d:i(this,hs).toSVGPath()}},!1,!0),f(this,Ee,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:i(this,de)},bbox:i(this,je).box,path:{d:i(this,je).toSVGPath()}},i(this,de))),i(this,Ga)&&(i(this,Ga).style.clipPath=i(this,Ua)))},Ls=new WeakSet,go=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]},Hb=function(e){st._keyboardManager.exec(this,e)},tu=function(e){if(!i(this,Ml))return;const s=window.getSelection();e?s.setPosition(i(this,Ml),i(this,id)):s.setPosition(i(this,rd),i(this,ad))},eu=function(){return i(this,de)?this.rotation:0},Ub=function(){if(i(this,de))return null;const[e,s]=this.pageDimensions,[n,r]=this.pageTranslation,a=i(this,dn),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:d,height:p}of a){const m=h*e+n,y=(1-c)*s+r;o[l]=o[l+4]=m,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=m+d*e,o[l+5]=o[l+7]=y-p*s,l+=8}return o},Gb=function(e){return i(this,hs).serialize(e,b(this,W,eu).call(this))},$b=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},zb=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=""},jb=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((n,r)=>n!==s[r])},g(st,Ls),x(st,"_defaultColor",null),x(st,"_defaultOpacity",1),x(st,"_defaultThickness",12),x(st,"_type","highlight"),x(st,"_editorType",G.HIGHLIGHT),x(st,"_freeHighlightId",-1),x(st,"_freeHighlight",null),x(st,"_freeHighlightClipId","");let yu=st;var $a;class Vb{constructor(){g(this,$a,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,$a)[t]=e}toSVGProperties(){const t=i(this,$a);return f(this,$a,Object.create(null)),{root:t}}reset(){f(this,$a,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){nt("Not implemented")}}$a=new WeakMap;var De,Rl,ee,za,ja,tt,Cp,Tp,xp,mh,Wb,su,bh,mo;const Z=class Z extends yt{constructor(e){super(e);g(this,tt);g(this,De,null);g(this,Rl);x(this,"_colorPicker",null);x(this,"_drawId",null);f(this,Rl,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(b(this,tt,Cp).call(this,e),b(this,tt,mh).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){nt("Not implemented")}static get typesMap(){nt("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(Z,ee).updateProperty(n,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)e.push([n,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[n,r]of this.constructor.typesMap)e.push([n,s[r]]);return e}_updateProperty(e,s,n){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=i(this,De).updateProperty(s,l);h&&b(this,tt,bh).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};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})}_updateColorAndOpacity(e,s){const n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),a=this._drawingOptions,o=a[n],l=a[r],h=(c,d)=>{var p;a.updateProperty(n,c),a.updateProperty(r,d),i(this,De).updateProperty(n,c),i(this,De).updateProperty(r,d),(p=this.parent)==null||p.drawLayer.updateProperties(this._drawId,a.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:h.bind(this,e,s),undo:h.bind(this,o,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Z._mergeSVGProperties(i(this,De).getPathResizingSVGProperties(b(this,tt,su).call(this)),{bbox:b(this,tt,mo).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Z._mergeSVGProperties(i(this,De).getPathResizedSVGProperties(b(this,tt,su).call(this)),{bbox:b(this,tt,mo).call(this)}))}_onTranslating(e,s){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{bbox:b(this,tt,mo).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Z._mergeSVGProperties(i(this,De).getPathTranslatedSVGProperties(b(this,tt,su).call(this),this.parentDimensions),{bbox:b(this,tt,mo).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,i(this,Rl)&&(f(this,Rl,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){b(this,tt,xp).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,tt,mh).call(this),b(this,tt,bh).call(this,i(this,De).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,tt,xp).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,tt,mh).call(this,e),s=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Z._mergeSVGProperties({bbox:b(this,tt,mo).call(this)},i(this,De).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,tt,bh).call(this,i(this,De).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}
55render(){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){nt("Not implemented")}static startDrawing(e,s,n,r){var v;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(Ae.isInitializedAndDifferentPointerType(c))return;const{viewport:{rotation:d}}=e,{width:p,height:m}=a.getBoundingClientRect(),y=f(Z,za,new AbortController),A=e.combinedSignal(y);if(Ae.setPointer(c,h),window.addEventListener("pointerup",w=>{Ae.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:A}),window.addEventListener("pointercancel",w=>{Ae.isSamePointerIdOrRemove(w.pointerId)&&this._currentParent.endDrawingSession()},{signal:A}),window.addEventListener("pointerdown",w=>{Ae.isSamePointerType(w.pointerType)&&(Ae.initializeAndAddPointerId(w.pointerId),i(Z,ee).isCancellable()&&(i(Z,ee).removeLastElement(),i(Z,ee).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:A}),window.addEventListener("contextmenu",Fs,{signal:A}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:A}),a.addEventListener("touchmove",w=>{Ae.isSameTimeStamp(w.timeStamp)&&Pt(w)},{signal:A}),e.toggleDrawing(),(v=s._editorUndoBar)==null||v.hide(),i(Z,ee)){e.drawLayer.updateProperties(this._currentDrawId,i(Z,ee).startNew(o,l,p,m,d));return}s.updateUIForDefaultProperties(this),f(Z,ee,this.createDrawerInstance(o,l,p,m,d)),f(Z,ja,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(i(Z,ja).toSVGProperties(),i(Z,ee).defaultSVGProperties),!0,!1)}static _drawMove(e){if(Ae.isSameTimeStamp(e.timeStamp),!i(Z,ee))return;const{offsetX:s,offsetY:n,pointerId:r}=e;if(Ae.isSamePointerId(r)){if(Ae.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,i(Z,ee).add(s,n)),Ae.setTimeStamp(e.timeStamp),Pt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,f(Z,ee,null),f(Z,ja,null),Ae.clearTimeStamp()),i(Z,za)&&(i(Z,za).abort(),f(Z,za,null),Ae.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,i(Z,ee).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const n=i(Z,ee),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:V.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(V.DRAW_STEP),!i(Z,ee).isEmpty()){const{pageDimensions:[n,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:i(Z,ee).getOutlines(n*a,r*a,a,this._INNER_MARGIN),drawingOptions:i(Z,ja),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){nt("Not implemented")}static async deserialize(e,s,n){var d,p;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),c=await super.deserialize(e,s,n);return c.createDrawingOptions(e),b(d=c,tt,Cp).call(d,{drawOutlines:h}),b(p=c,tt,mh).call(p),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,n]=this.pageTranslation,[r,a]=this.pageDimensions;return i(this,De).serialize([s,n,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};De=new WeakMap,Rl=new WeakMap,ee=new WeakMap,za=new WeakMap,ja=new WeakMap,tt=new WeakSet,Cp=function({drawOutlines:e,drawId:s,drawingOptions:n}){f(this,De,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=b(this,tt,Tp).call(this,e,this.parent),b(this,tt,bh).call(this,e.box)},Tp=function(e,s){const{id:n}=s.drawLayer.draw(Z._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n},xp=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},mh=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=b(this,tt,Tp).call(this,i(this,De),e)}},Wb=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]}},su=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]}},bh=function(e){[this.x,this.y,this.width,this.height]=b(this,tt,Wb).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},mo=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)];
55case 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]}},x(Z,"_currentDrawId",-1),x(Z,"_currentParent",null),g(Z,ee,null),g(Z,za,null),g(Z,ja,null),x(Z,"_INNER_MARGIN",3);let Au=Z;var Ai,se,ie,Va,Fl,Ie,ue,Is,Wa,Xa,Ya,Ol,iu;class b0{constructor(t,e,s,n,r,a){g(this,Ol);g(this,Ai,new Float64Array(6));g(this,se);g(this,ie);g(this,Va);g(this,Fl);g(this,Ie);g(this,ue,"");g(this,Is,0);g(this,Wa,new bd);g(this,Xa);g(this,Ya);f(this,Xa,s),f(this,Ya,n),f(this,Va,r),f(this,Fl,a),[t,e]=b(this,Ol,iu).call(this,t,e);const o=f(this,se,[NaN,NaN,NaN,NaN,t,e]);f(this,Ie,[t,e]),f(this,ie,[{line:o,points:i(this,Ie)}]),i(this,Ai).set(o,0)}updateProperty(t,e){t==="stroke-width"&&f(this,Fl,e)}isEmpty(){return!i(this,ie)||i(this,ie).length===0}isCancellable(){return i(this,Ie).length<=10}add(t,e){[t,e]=b(this,Ol,iu).call(this,t,e);const[s,n,r,a]=i(this,Ai).subarray(2,6),o=t-r,l=e-a;return Math.hypot(i(this,Xa)*o,i(this,Ya)*l)<=2?null:(i(this,Ie).push(t,e),isNaN(s)?(i(this,Ai).set([r,a,t,e],2),i(this,se).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(i(this,Ai)[0])&&i(this,se).splice(6,6),i(this,Ai).set([s,n,r,a,t,e],0),i(this,se).push(...O.createBezierPoints(s,n,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(i(this,Ie).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,n,r){f(this,Xa,s),f(this,Ya,n),f(this,Va,r),[t,e]=b(this,Ol,iu).call(this,t,e);const a=f(this,se,[NaN,NaN,NaN,NaN,t,e]);f(this,Ie,[t,e]);const o=i(this,ie).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),i(this,ie).push({line:a,points:i(this,Ie)}),i(this,Ai).set(a,0),f(this,Is,0),this.toSVGPath(),null}getLastElement(){return i(this,ie).at(-1)}setLastElement(t){return i(this,ie)?(i(this,ie).push(t),f(this,se,t.line),f(this,Ie,t.points),f(this,Is,0),{path:{d:this.toSVGPath()}}):i(this,Wa).setLastElement(t)}removeLastElement(){if(!i(this,ie))return i(this,Wa).removeLastElement();i(this,ie).pop(),f(this,ue,"");for(let t=0,e=i(this,ie).length;t<e;t++){const{line:s,points:n}=i(this,ie)[t];f(this,se,s),f(this,Ie,n),f(this,Is,0),this.toSVGPath()}return{path:{d:i(this,ue)}}}toSVGPath(){const t=O.svgRound(i(this,se)[4]),e=O.svgRound(i(this,se)[5]);if(i(this,Ie).length===2)return f(this,ue,`${i(this,ue)} M ${t} ${e} Z`),i(this,ue);if(i(this,Ie).length<=6){const n=i(this,ue).lastIndexOf("M");f(this,ue,`${i(this,ue).slice(0,n)} M ${t} ${e}`),f(this,Is,6)}if(i(this,Ie).length===4){const n=O.svgRound(i(this,se)[10]),r=O.svgRound(i(this,se)[11]);return f(this,ue,`${i(this,ue)} L ${n} ${r}`),f(this,Is,12),i(this,ue)}const s=[];i(this,Is)===0&&(s.push(`M ${t} ${e}`),f(this,Is,6));for(let n=i(this,Is),r=i(this,se).length;n<r;n+=6){const[a,o,l,h,c,d]=i(this,se).slice(n,n+6).map(O.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}return f(this,ue,i(this,ue)+s.join(" ")),f(this,Is,i(this,se).length),i(this,ue)}getOutlines(t,e,s,n){const r=i(this,ie).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),i(this,Wa).build(i(this,ie),t,e,s,i(this,Va),i(this,Fl),n),f(this,Ai,null),f(this,se,null),f(this,ie,null),f(this,ue,null),i(this,Wa)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Ai=new WeakMap,se=new WeakMap,ie=new WeakMap,Va=new WeakMap,Fl=new WeakMap,Ie=new WeakMap,ue=new WeakMap,Is=new WeakMap,Wa=new WeakMap,Xa=new WeakMap,Ya=new WeakMap,Ol=new WeakSet,iu=function(t,e){return O._normalizePoint(t,e,i(this,Xa),i(this,Ya),i(this,Va))};var Le,ld,hd,ds,wi,vi,Nl,Bl,Ka,pe,Di,Xb,Yb,Kb;class bd extends O{constructor(){super(...arguments);g(this,pe);g(this,Le);g(this,ld,0);g(this,hd);g(this,ds);g(this,wi);g(this,vi);g(this,Nl);g(this,Bl);g(this,Ka)}build(e,s,n,r,a,o,l){f(this,wi,s),f(this,vi,n),f(this,Nl,r),f(this,Bl,a),f(this,Ka,o),f(this,hd,l??0),f(this,ds,e),b(this,pe,Yb).call(this)}get thickness(){return i(this,Ka)}setLastElement(e){return i(this,ds).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return i(this,ds).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of i(this,ds)){if(e.push(`M${O.svgRound(s[4])} ${O.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${O.svgRound(s[10])} ${O.svgRound(s[11])}`);continue}for(let n=6,r=s.length;n<r;n+=6){const[a,o,l,h,c,d]=s.subarray(n,n+6).map(O.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}}return e.join("")}serialize([e,s,n,r],a){const o=[],l=[],[h,c,d,p]=b(this,pe,Xb).call(this);let m,y,A,v,w,S,E,_,C;switch(i(this,Bl)){case 0:C=O._rescale,m=e,y=s+r,A=n,v=-r,w=e+h*n,S=s+(1-c-p)*r,E=e+(h+d)*n,_=s+(1-c)*r;break;case 90:C=O._rescaleAndSwap,m=e,y=s,A=n,v=r,w=e+c*n,S=s+h*r,E=e+(c+p)*n,_=s+(h+d)*r;break;case 180:C=O._rescale,m=e+n,y=s,A=-n,v=r,w=e+(1-h-d)*n,S=s+c*r,E=e+(1-h)*n,_=s+(c+p)*r;break;case 270:C=O._rescaleAndSwap,m=e+n,y=s+r,A=-n,v=-r,w=e+(1-c-p)*n,S=s+(1-h-d)*r,E=e+(1-c)*n,_=s+(1-h)*r;break}for(const{line:T,points:P}of i(this,ds))o.push(C(T,m,y,A,v,a?new Array(T.length):null)),l.push(C(P,m,y,A,v,a?new Array(P.length):null));return{lines:o,points:l,rect:[w,S,E,_]}}static deserialize(e,s,n,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const d=[];let p,m,y,A,v;switch(h){case 0:v=O._rescale,p=-e/n,m=s/r+1,y=1/n,A=-1/r;break;case 90:v=O._rescaleAndSwap,p=-s/r,m=-e/n,y=1/r,A=1/n;break;case 180:v=O._rescale,p=e/n+1,m=-s/r,y=-1/n,A=1/r;break;case 270:v=O._rescaleAndSwap,p=s/r+1,m=e/n+1,y=-1/r,A=-1/n;break}if(!o){o=[];for(const S of l){const E=S.length;if(E===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(E===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}const _=new Float32Array(3*(E-2));o.push(_);let[C,T,P,D]=S.subarray(0,4);_.set([NaN,NaN,NaN,NaN,C,T],0);for(let k=4;k<E;k+=2){const R=S[k],I=S[k+1];_.set(O.createBezierPoints(C,T,P,D,R,I),(k-2)*3),[C,T,P,D]=[P,D,R,I]}}}for(let S=0,E=o.length;S<E;S++)d.push({line:v(o[S].map(_=>_??NaN),p,m,y,A),points:v(l[S].map(_=>_??NaN),p,m,y,A)});const w=new this.prototype.constructor;return w.build(d,n,r,1,h,c,a),w}get box(){return i(this,Le)}updateProperty(e,s){return e==="stroke-width"?b(this,pe,Kb).call(this,s):null}updateParentDimensions([e,s],n){const[r,a]=b(this,pe,Di).call(this);f(this,wi,e),f(this,vi,s),f(this,Nl,n);const[o,l]=b(this,pe,Di).call(this),h=o-r,c=l-a,d=i(this,Le);return d[0]-=h,d[1]-=c,d[2]+=2*h,d[3]+=2*c,d}updateRotation(e){return f(this,ld,e),{path:{transform:this.rotationTransform}}}get viewBox(){return i(this,Le).map(O.svgRound).join(" ")}get defaultProperties(){const[e,s]=i(this,Le);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.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,ld)){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} ${O.svgRound(l)} ${O.svgRound(h)})`}getPathResizingSVGProperties([e,s,n,r]){const[a,o]=b(this,pe,Di).call(this),[l,h,c,d]=i(this,Le);if(Math.abs(c-a)<=O.PRECISION||Math.abs(d-o)<=O.PRECISION){const v=e+n/2-(l+c/2),w=s+r/2-(h+d/2);return{path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const p=(n-2*a)/(c-2*a),m=(r-2*o)/(d-2*o),y=c/n,A=d/r;return{path:{"transform-origin":`${O.svgRound(l)} ${O.svgRound(h)}`,transform:`${this.rotationTransform} scale(${y} ${A}) translate(${O.svgRound(a)} ${O.svgRound(o)}) scale(${p} ${m}) translate(${O.svgRound(-a)} ${O.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,n,r]){const[a,o]=b(this,pe,Di).call(this),l=i(this,Le),[h,c,d,p]=l;if(l[0]=e,l[1]=s,l[2]=n,l[3]=r,Math.abs(d-a)<=O.PRECISION||Math.abs(p-o)<=O.PRECISION){const w=e+n/2-(h+d/2),S=s+r/2-(c+p/2);for(const{line:E,points:_}of i(this,ds))O._translate(E,w,S,E),O._translate(_,w,S,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const m=(n-2*a)/(d-2*a),y=(r-2*o)/(p-2*o),A=-m*(h+a)+e+a,v=-y*(c+o)+s+o;if(m!==1||y!==1||A!==0||v!==0)for(const{line:w,points:S}of i(this,ds))O._rescale(w,A,v,m,y,w),O._rescale(S,A,v,m,y,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.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,wi)===r&&i(this,vi)===a)for(const{line:c,points:d}of i(this,ds))O._translate(c,l,h,c),O._translate(d,l,h,d);else{const c=i(this,wi)/r,d=i(this,vi)/a;f(this,wi,r),f(this,vi,a);for(const{line:p,points:m}of i(this,ds))O._rescale(p,l,h,c,d,p),O._rescale(m,l,h,c,d,m);o[2]*=c,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get defaultSVGProperties(){const e=i(this,Le);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e[0])} ${O.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Le=new WeakMap,ld=new WeakMap,hd=new WeakMap,ds=new WeakMap,wi=new WeakMap,vi=new WeakMap,Nl=new WeakMap,Bl=new WeakMap,Ka=new WeakMap,pe=new WeakSet,Di=function(e=i(this,Ka)){const s=i(this,hd)+e/2*i(this,Nl);return i(this,Bl)%180===0?[s/i(this,wi),s/i(this,vi)]:[s/i(this,vi),s/i(this,wi)]},Xb=function(){const[e,s,n,r]=i(this,Le),[a,o]=b(this,pe,Di).call(this,0);return[e+a,s+o,n-2*a,r-2*o]},Yb=function(){const e=f(this,Le,Ir.slice());for(const{line:r}of i(this,ds)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)M.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;
55l+=6){const[c,d,p,m,y,A]=r.subarray(l,l+6);M.bezierBoundingBox(a,o,c,d,p,m,y,A,e),a=y,o=A}}const[s,n]=b(this,pe,Di).call(this);e[0]=Ct(e[0]-s,0,1),e[1]=Ct(e[1]-n,0,1),e[2]=Ct(e[2]+s,0,1),e[3]=Ct(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]},Kb=function(e){const[s,n]=b(this,pe,Di).call(this);f(this,Ka,e);const[r,a]=b(this,pe,Di).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 af extends Vb{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:yt._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 af(this._viewParameters);return t.updateAll(this),t}}var zu,qb;const Ao=class Ao extends Au{constructor(e){super({...e,name:"inkEditor"});g(this,zu);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){yt.initialize(e,s),this._defaultDrawingOptions=new af(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return $(this,"typesMap",new Map([[V.INK_THICKNESS,"stroke-width"],[V.INK_COLOR,"stroke"],[V.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,n,r,a){return new b0(e,s,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,n,r,a,o){return bd.deserialize(e,s,n,r,a,o)}static async deserialize(e,s,n){let r=null;if(e instanceof tg){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,opacity:p,borderStyle:{rawWidth:m},popupRef:y,richText:A,contentsObj:v,creationDate:w,modificationDate:S},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:G.INK,color:Array.from(d),thickness:m,opacity:p,paths:{points:o},boxes:null,pageIndex:E-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:y,richText:A,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:S}}const a=await super.deserialize(e,s,n);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new gu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return V.INK_COLOR}get colorAndOpacityType(){return V.INK_COLOR_AND_OPACITY}get opacityType(){return V.INK_OPACITY}updateParams(e,s){if(e===V.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===V.INK_COLOR_AND_OPACITY){super.updateDefaultParams(V.INK_COLOR,s.color),super.updateDefaultParams(V.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}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=Ao.getDefaultDrawingOptions({stroke:M.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:yt._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:n}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!b(this,zu,qb).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}};zu=new WeakSet,qb=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},x(Ao,"_type","ink"),x(Ao,"_editorType",G.INK),x(Ao,"_defaultDrawingOptions",null);let Pp=Ao;class kp extends bd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const _d=8,Ql=3;var qa,rt,Mp,Ks,Qb,Jb,Dp,nu,Zb,ty,ey,Ip,Lp,sy;class yn{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:n},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const d=200,p=c.font=`${s} ${n} ${d}px ${e}`,{actualBoundingBoxLeft:m,actualBoundingBoxRight:y,actualBoundingBoxAscent:A,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:S,width:E}=c.measureText(t),_=1.5,C=Math.ceil(Math.max(Math.abs(m)+Math.abs(y)||0,E)*_),T=Math.ceil(Math.max(Math.abs(A)+Math.abs(v)||d,Math.abs(w)+Math.abs(S)||d)*_);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 P=b(this,rt,Ip).call(this,c.getImageData(0,0,C,T).data),D=b(this,rt,ey).call(this,P),k=b(this,rt,Lp).call(this,D),R=b(this,rt,Dp).call(this,P,C,T,k);return this.processDrawnLines({lines:{curves:R,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]=b(this,rt,sy).call(this,t),[h,c]=b(this,rt,ty).call(this,a,o,l,Math.hypot(o,l)*i(this,qa).sigmaSFactor,i(this,qa).sigmaR,i(this,qa).kernelSize),d=b(this,rt,Lp).call(this,c),p=b(this,rt,Dp).call(this,h,o,l,d);return this.processDrawnLines({lines:{curves:p,width:o,height:l},pageWidth:e,pageHeight:s,rotation:n,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:n,innerMargin:r,mustSmooth:a,areContours:o}){n%180!==0&&([e,s]=[s,e]);const{curves:l,width:h,height:c}=t,d=t.thickness??0,p=[],m=Math.min(e/h,s/c),y=m/e,A=m/s,v=[];for(const{points:S}of l){const E=a?b(this,rt,Zb).call(this,S):S;if(!E)continue;v.push(E);const _=E.length,C=new Float32Array(_),T=new Float32Array(3*(_===2?2:_-2));if(p.push({line:T,points:C}
55),_===2){C[0]=E[0]*y,C[1]=E[1]*A,T.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[P,D,k,R]=E;P*=y,D*=A,k*=y,R*=A,C.set([P,D,k,R],0),T.set([NaN,NaN,NaN,NaN,P,D],0);for(let I=4;I<_;I+=2){const K=C[I]=E[I]*y,q=C[I+1]=E[I+1]*A;T.set(O.createBezierPoints(P,D,k,R,K,q),(I-2)*3),[P,D,k,R]=[k,R,K,q]}}if(p.length===0)return null;const w=o?new kp:new bd;return w.build(p,e,s,1,n,o?0:d,r),{outline:w,newCurves:v,areContours:o,thickness:d,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:n,height:r}){let a=1/0,o=-1/0,l=0;for(const S of t){l+=S.length;for(let E=2,_=S.length;E<_;E++){const C=S[E]-S[E-2];a=Math.min(a,C),o=Math.max(o,C)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,d=_d+Ql*c,p=new Uint32Array(d);let m=0;p[m++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,p[m++]=0,p[m++]=n,p[m++]=r,p[m++]=e?0:1,p[m++]=Math.max(0,Math.floor(s??0)),p[m++]=c,p[m++]=h.BYTES_PER_ELEMENT;for(const S of t)p[m++]=S.length-2,p[m++]=S[0],p[m++]=S[1];const y=new CompressionStream("deflate-raw"),A=y.writable.getWriter();await A.ready,A.write(p);const v=h.prototype.constructor;for(const S of t){const E=new v(S.length-2);for(let _=2,C=S.length;_<C;_++)E[_-2]=S[_]-S[_-2];A.write(E)}return A.close(),(await new Response(y.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(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 E of s)a||(a=new Uint8Array(new Uint32Array(E.buffer,0,4)[0])),a.set(E,o),o+=E.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],p=l[4]===0,m=l[5],y=l[6],A=l[7],v=[],w=(_d+Ql*y)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(A){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,w);break}o=0;for(let E=0;E<y;E++){const _=l[Ql*E+_d],C=new Float32Array(_+2);v.push(C);for(let T=0;T<Ql-1;T++)C[T]=l[Ql*E+_d+T+1];for(let T=0;T<_;T++)C[T+2]=C[T]+S[o++]}return{areContours:p,thickness:m,outlines:v,width:c,height:d}}catch(e){return j(`decompressSignature: ${e}`),null}}}qa=new WeakMap,rt=new WeakSet,Mp=function(t,e,s,n){return s-=t,n-=e,s===0?n>0?0:4:s===1?n+6:2-n},Ks=new WeakMap,Qb=function(t,e,s,n,r,a,o){const l=b(this,rt,Mp).call(this,s,n,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,d=i(this,Ks)[2*c],p=i(this,Ks)[2*c+1];if(t[(s+d)*e+(n+p)]!==0)return c}return-1},Jb=function(t,e,s,n,r,a,o){const l=b(this,rt,Mp).call(this,s,n,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,d=i(this,Ks)[2*c],p=i(this,Ks)[2*c+1];if(t[(s+d)*e+(n+p)]!==0)return c}return-1},Dp=function(t,e,s,n){const r=t.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=t[c]<=n?1:0;for(let c=1;c<s-1;c++)a[c*e]=a[c*e+e-1]=0;for(let c=0;c<e;c++)a[c]=a[e*s-1-c]=0;let o=1,l;const h=[];for(let c=1;c<s-1;c++){l=1;for(let d=1;d<e-1;d++){const p=c*e+d,m=a[p];if(m===0)continue;let y=c,A=d;if(m===1&&a[p-1]===0)o+=1,A-=1;else if(m>=1&&a[p+1]===0)o+=1,A+=1,m>1&&(l=m);else{m!==1&&(l=Math.abs(m));continue}const v=[d,c],w=A===d+1,S={isHole:w,points:v,id:o,parent:0};h.push(S);let E;for(const I of h)if(I.id===l){E=I;break}E?E.isHole?S.parent=w?E.parent:l:S.parent=w?l:E.parent:S.parent=w?l:0;const _=b(this,rt,Qb).call(this,a,e,c,d,y,A,0);if(_===-1){a[p]=-o,a[p]!==1&&(l=Math.abs(a[p]));continue}let C=i(this,Ks)[2*_],T=i(this,Ks)[2*_+1];const P=c+C,D=d+T;y=P,A=D;let k=c,R=d;for(;;){const I=b(this,rt,Jb).call(this,a,e,k,R,y,A,1);C=i(this,Ks)[2*I],T=i(this,Ks)[2*I+1];const K=k+C,q=R+T;v.push(q,K);const Y=k*e+R;if(a[Y+1]===0?a[Y]=-o:a[Y]===1&&(a[Y]=o),K===c&&q===d&&k===P&&R===D){a[p]!==1&&(l=Math.abs(a[p]));break}else y=k,A=R,k=K,R=q}}}return h},nu=function(t,e,s,n){if(s-e<=4){for(let P=e;P<s-2;P+=2)n.push(t[P],t[P+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,h=Math.hypot(o,l),c=o/h,d=l/h,p=c*a-d*r,m=l/o,y=1/h,A=Math.atan(m),v=Math.cos(A),w=Math.sin(A),S=y*(Math.abs(v)+Math.abs(w)),E=y*(1-S+S**2),_=Math.max(Math.atan(Math.abs(w+v)*E),Math.atan(Math.abs(w-v)*E));let C=0,T=e;for(let P=e+2;P<s-2;
55P+=2){const D=Math.abs(p-c*t[P+1]+d*t[P]);D>C&&(T=P,C=D)}C>(h*_)**2?(b(this,rt,nu).call(this,t,e,T+2,n),b(this,rt,nu).call(this,t,T,s,n)):n.push(r,a)},Zb=function(t){const e=[],s=t.length;return b(this,rt,nu).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},ty=function(t,e,s,n,r,a){const o=new Float32Array(a**2),l=-2*n**2,h=a>>1;for(let A=0;A<a;A++){const v=(A-h)**2;for(let w=0;w<a;w++)o[A*a+w]=Math.exp((v+(w-h)**2)/l)}const c=new Float32Array(256),d=-2*r**2;for(let A=0;A<256;A++)c[A]=Math.exp(A**2/d);const p=t.length,m=new Uint8Array(p),y=new Uint32Array(256);for(let A=0;A<s;A++)for(let v=0;v<e;v++){const w=A*e+v,S=t[w];let E=0,_=0;for(let T=0;T<a;T++){const P=A+T-h;if(!(P<0||P>=s))for(let D=0;D<a;D++){const k=v+D-h;if(k<0||k>=e)continue;const R=t[P*e+k],I=o[T*a+D]*c[Math.abs(R-S)];E+=R*I,_+=I}}const C=m[w]=Math.round(E/_);y[C]++}return[m,y]},ey=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Ip=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},Lp=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},sy=function(t){const e=t,{width:s,height:n}=t,{maxDim:r}=i(this,qa);let a=s,o=n;if(s>r||n>r){let p=s,m=n,y=Math.log2(Math.max(s,n)/r);const A=Math.floor(y);y=y===A?A-1:A;for(let w=0;w<y;w++){a=Math.ceil(p/2),o=Math.ceil(m/2);const S=new OffscreenCanvas(a,o);S.getContext("2d").drawImage(t,0,0,p,m,0,0,a,o),p=a,m=o,t!==e&&t.close(),t=S.transferToImageBitmap()}const v=Math.min(r/a,r/o);a=Math.round(a*v),o=Math.round(o*v)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,a,o),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,a,o);const c=h.getImageData(0,0,a,o).data;return[b(this,rt,Ip).call(this,c),a,o]},g(yn,rt),g(yn,qa,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),g(yn,Ks,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class eg extends Vb{constructor(){super(),super.updateProperties({fill:yt._defaultLineColor,"stroke-width":0})}clone(){const t=new eg;return t.updateAll(this),t}}class sg extends af{constructor(t){super(t),super.updateProperties({stroke:yt._defaultLineColor,"stroke-width":1})}clone(){const t=new sg(this._viewParameters);return t.updateAll(this),t}}var fr,Si,pr,Qa;const Ke=class Ke extends Au{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});g(this,fr,!1);g(this,Si,null);g(this,pr,null);g(this,Qa,null);this._willKeepAspectRatio=!0,f(this,pr,e.signatureData||null),f(this,Si,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){yt.initialize(e,s),this._defaultDrawingOptions=new eg,this._defaultDrawnSignatureOptions=new sg(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return $(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!i(this,Si)}}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()}render(){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:d,pageHeight:p},rotation:m}=this.parent.viewport,y=yn.processDrawnLines({lines:r,pageWidth:d,pageHeight:p,rotation:m,innerMargin:Ke._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(y,c,l,h)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:i(this,Si)||""}));return n&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){f(this,Qa,e),this.addEditToolbar()}getUuid(){return i(this,Qa)}get description(){return i(this,Si)}set description(e){f(this,Si,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:n,width:r,height:a}=i(this,pr),o=Math.max(r,a),l=yn.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 kp),this.description=n;let h;i(this,fr)?h=Ke.getDefaultDrawingOptions():(h=Ke._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let d=s/c;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!n}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return yn.process(e,s,n,r,Ke._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:n,pageHeight:r},rotation:a}=this.parent.viewport;return yn.extractContoursFromText(e,s,n,r,a,Ke._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return yn.processDrawnLines({lines:e,pageWidth:s,pageHeight:n,rotation:r,innerMargin:Ke._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Ke.getDefaultDrawingOptions():(this._drawingOptions=Ke._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,Qa),a.isCopy=!0):a.lines=s,i(this,Si)&&(a.accessibilityData={type:"Figure",alt:i(this,Si)}),a}static deserializeDraw(e,s,n,r,a,o){return o.areContours?kp.deserialize(e,s,n,r,a,o):bd.deserialize(e,s,n,r,a,o)}static async deserialize(e,s,n){var a;const r=await super.deserialize(e,s,n);return f(r,fr,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",f(r,Qa,e.uuid),r}};
55fr=new WeakMap,Si=new WeakMap,pr=new WeakMap,Qa=new WeakMap,x(Ke,"_type","signature"),x(Ke,"_editorType",G.SIGNATURE),x(Ke,"_defaultDrawingOptions",null);let Rp=Ke;var _t,ne,gr,un,mr,Hl,fn,Ja,Ei,us,Ul,et,yh,Ah,ru,au,ou,Op,lu,iy;class Fp extends yt{constructor(e){super({...e,name:"stampEditor"});g(this,et);g(this,_t,null);g(this,ne,null);g(this,gr,null);g(this,un,null);g(this,mr,null);g(this,Hl,"");g(this,fn,null);g(this,Ja,!1);g(this,Ei,null);g(this,us,!1);g(this,Ul,!1);f(this,un,e.bitmapUrl),f(this,mr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){yt.initialize(e,s)}static isHandlingMimeForPasting(e){return vf.includes(e)}static paste(e,s){s.pasteEditor({mode:G.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await n.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;i(this,ne)&&(f(this,_t,null),this._uiManager.imageManager.deleteId(i(this,ne)),(e=i(this,fn))==null||e.remove(),f(this,fn,null),i(this,Ei)&&(clearTimeout(i(this,Ei)),f(this,Ei,null))),super.remove()}rebuild(){if(!this.parent){i(this,ne)&&b(this,et,ru).call(this);return}super.rebuild(),this.div!==null&&(i(this,ne)&&i(this,fn)===null&&b(this,et,ru).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(i(this,gr)||i(this,_t)||i(this,un)||i(this,mr)||i(this,ne)||i(this,Ja))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){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,_t)?b(this,et,au).call(this):b(this,et,ru).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,ne,n),r&&f(this,_t,r),f(this,Ja,!1),b(this,et,au).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;i(this,Ei)!==null&&clearTimeout(i(this,Ei)),f(this,Ei,setTimeout(()=>{f(this,Ei,null),b(this,et,Op).call(this)},200))}copyCanvas(e,s,n=!1){e||(e=224);const{width:r,height:a}=i(this,_t),o=new Ti;let l=i(this,_t),h=r,c=a,d=null;if(s){if(r>s||a>s){const P=Math.min(s/r,s/a);h=Math.floor(r*P),c=Math.floor(a*P)}d=document.createElement("canvas");const m=d.width=Math.ceil(h*o.sx),y=d.height=Math.ceil(c*o.sy);i(this,us)||(l=b(this,et,ou).call(this,m,y));const A=d.getContext("2d");A.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":My.isDarkMode&&(v="#8f8f9d",w="#42414d");const S=15,E=S*o.sx,_=S*o.sy,C=new OffscreenCanvas(E*2,_*2),T=C.getContext("2d");T.fillStyle=v,T.fillRect(0,0,E*2,_*2),T.fillStyle=w,T.fillRect(0,0,E,_),T.fillRect(E,_,E,_),A.fillStyle=A.createPattern(C,"repeat"),A.fillRect(0,0,m,y),A.drawImage(l,0,0,l.width,l.height,0,0,m,y)}let p=null;if(n){let m,y;if(o.symmetric&&l.width<e&&l.height<e)m=l.width,y=l.height;else if(l=i(this,_t),r>e||a>e){const w=Math.min(e/r,e/a);m=Math.floor(r*w),y=Math.floor(a*w),i(this,us)||(l=b(this,et,ou).call(this,m,y))}const v=new OffscreenCanvas(m,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,m,y),p={width:m,height:y,data:v.getImageData(0,0,m,y).data}}return{canvas:d,width:h,height:c,imageData:p}}static async deserialize(e,s,n){var v;let r=null,a=!1;if(e instanceof Ab){const{data:{rect:w,rotation:S,id:E,structParent:_,popupRef:C,richText:T,contentsObj:P,creationDate:D,modificationDate:k},container:R,parent:{page:{pageNumber:I}},canvas:K}=e;let q,Y;K?(delete e.canvas,{id:q,bitmap:Y}=n.imageManager.getFromCanvas(R.id,K),K.remove()):(a=!0,e._hasNoCanvas=!0);const J=((v=await s._structTree.getAriaAttributes(`${bo}${E}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:G.STAMP,bitmapId:q,bitmap:Y,pageIndex:I-1,rect:w.slice(0),rotation:S,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:J},isSvg:!1,structParent:_,popupRef:C,richText:T,comment:(P==null?void 0:P.str)||null,creationDate:D,modificationDate:k}}const o=await super.deserialize(e,s,n),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:d,isSvg:p,accessibilityData:m}=e;a?(n.addMissingCanvas(e.id,o),f(o,Ja,!0)):d&&n.imageManager.isValidId(d)?(f(o,ne,d),h&&f(o,_t,h)):f(o,un,c),f(o,us,p);const[y,A]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/A,m&&(o.altTextData=m),o._initialData=r,e.comment&&o.setCommentData(e),f(o,Ul,!!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,ne),isSvg:i(this,us)});if(this.addComment(n),e)return n.bitmapUrl=b(this,et,lu).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=b(this,et,iy).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,us)?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!s.stamps.has(i(this,ne)))s.stamps.set(i(this,ne),{area:o,serialized:n}),n.bitmap=b(this,et,lu).call(this,!1);else if(i(this,us)){const l=s.stamps.get(i(this,ne));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,et,lu).call(this,!1))}return n}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}_t=new WeakMap,ne=new WeakMap,gr=new WeakMap,un=new WeakMap,mr=new WeakMap,Hl
55=new WeakMap,fn=new WeakMap,Ja=new WeakMap,Ei=new WeakMap,us=new WeakMap,Ul=new WeakMap,et=new WeakSet,yh=function(e,s=!1){if(!e){this.remove();return}f(this,_t,e.bitmap),s||(f(this,ne,e.id),f(this,us,e.isSvg)),e.file&&f(this,Hl,e.file.name),b(this,et,au).call(this)},Ah=function(){if(f(this,gr,null),this._uiManager.enableWaiting(!1),!!i(this,fn)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&i(this,_t)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&i(this,_t)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},ru=function(){if(i(this,ne)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(i(this,ne)).then(n=>b(this,et,yh).call(this,n,!0)).finally(()=>b(this,et,Ah).call(this));return}if(i(this,un)){const n=i(this,un);f(this,un,null),this._uiManager.enableWaiting(!0),f(this,gr,this._uiManager.imageManager.getFromUrl(n).then(r=>b(this,et,yh).call(this,r)).finally(()=>b(this,et,Ah).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=>b(this,et,yh).call(this,r)).finally(()=>b(this,et,Ah).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=vf.join(",");const s=this._uiManager._signal;f(this,gr,new Promise(n=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,et,yh).call(this,r)}n()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:s})}).finally(()=>b(this,et,Ah).call(this))),e.click()},au=function(){var h;const{div:e}=this;let{width:s,height:n}=i(this,_t);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,n=this.height*a;else if(s>o*r||n>o*a){const c=Math.min(o*r/s,o*a/n);s*=c,n*=c}this._uiManager.enableWaiting(!1);const l=f(this,fn,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=n/a,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),b(this,et,Op).call(this),i(this,Ul)||(this.parent.addUndoableEditor(this),f(this,Ul,!0)),this._reportTelemetry({action:"inserted_image"}),i(this,Hl)&&this.div.setAttribute("aria-description",i(this,Hl)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},ou=function(e,s){const{width:n,height:r}=i(this,_t);let a=n,o=r,l=i(this,_t);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=d.transferToImageBitmap()}return l},Op=function(){const[e,s]=this.parentDimensions,{width:n,height:r}=this,a=new Ti,o=Math.ceil(n*e*a.sx),l=Math.ceil(r*s*a.sy),h=i(this,fn);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=i(this,us)?i(this,_t):b(this,et,ou).call(this,o,l),d=h.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(c,0,0,c.width,c.height,0,0,o,l)},lu=function(e){if(e){if(i(this,us)){const r=this._uiManager.imageManager.getSvgUrl(i(this,ne));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=i(this,_t),s.getContext("2d").drawImage(i(this,_t),0,0),s.toDataURL()}if(i(this,us)){const[s,n]=this.pageDimensions,r=Math.round(this.width*s*Er.PDF_TO_CSS_UNITS),a=Math.round(this.height*n*Er.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(i(this,_t),0,0,i(this,_t).width,i(this,_t).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(i(this,_t))},iy=function(e){var o;const{pageIndex:s,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},x(Fp,"_type","stamp"),x(Fp,"_editorType",G.STAMP);var Za,Gl,br,yr,pn,Ve,Ar,$l,zl,qs,gn,re,mn,wr,jl,N,vr,mt,Bp,ny,ii,Hp,Up,hu;const Ns=class Ns{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){g(this,mt);g(this,Za);g(this,Gl,!1);g(this,br,null);g(this,yr,null);g(this,pn,null);g(this,Ve,new Map);g(this,Ar,!1);g(this,$l,!1);g(this,zl,!1);g(this,qs,null);g(this,gn,null);g(this,re,null);g(this,mn,null);g(this,wr,null);g(this,jl,-1);g(this,N);const d=[...i(Ns,vr).values()];if(!Ns._initialized){Ns._initialized=!0;for(const p of d)p.initialize(c,t)}
55t.registerEditorTypes(d),f(this,N,t),this.pageIndex=e,this.div=s,f(this,Za,r),f(this,br,a),this.viewport=h,f(this,re,l),this.drawLayer=o,this._structTree=n,i(this,N).addLayer(this)}get isEmpty(){return i(this,Ve).size===0}get isInvisible(){return this.isEmpty&&i(this,N).getMode()===G.NONE}updateToolbar(t){i(this,N).updateToolbar(t)}updateMode(t=i(this,N).getMode()){switch(b(this,mt,hu).call(this),t){case G.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case G.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case G.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===G.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of i(Ns,vr).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=i(this,re))==null?void 0:e.div)}setEditingState(t){i(this,N).setEditingState(t)}addCommands(t){i(this,N).addCommands(t)}cleanUndoStack(t){i(this,N).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=i(this,br))==null||e.togglePointerEvents(t)}async enable(){var s;f(this,zl,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=i(this,wr))==null||s.abort(),f(this,wr,null);const t=new Set;for(const n of i(this,mt,Bp))n.enableEditing(),n.show(!0),n.annotationElementId&&(i(this,N).removeChangedExistingAnnotation(n),t.add(n.annotationElementId));const e=i(this,br);if(e)for(const n of e.getEditableAnnotations()){if(n.hide(),i(this,N).isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;const r=await this.deserialize(n);r&&(this.addOrRebuild(r),r.enableEditing())}f(this,zl,!1),i(this,N)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var n;if(f(this,$l,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),i(this,re)&&!i(this,wr)){f(this,wr,new AbortController);const r=i(this,N).combinedSignal(i(this,wr));i(this,re).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,d=i(this,jl);if(c-d>500){f(this,jl,c);return}f(this,jl,-1);const{classList:p}=this.div;p.toggle("getElements",!0);const m=document.elementsFromPoint(l,h);if(p.toggle("getElements",!1),!this.div.contains(m[0]))return;let y;const A=new RegExp(`^${_h}[0-9]+$`);for(const w of m)if(A.test(w.id)){y=w.id;break}if(!y)return;const v=i(this,Ve).get(y);(v==null?void 0:v.annotationElementId)===null&&(Pt(a),v.dblclick(a))},{signal:r,capture:!0})}const t=i(this,br),e=[];if(t){const r=new Map,a=new Map;for(const o of i(this,mt,Bp)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(n=this.getEditableAnnotation(o.annotationElementId))==null||n.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(i(this,N).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=a.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=r.get(l),h&&(i(this,N).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,mt,hu).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of i(Ns,vr).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),f(this,$l,!1)}getEditableAnnotation(t){var e;return((e=i(this,br))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){i(this,N).getActive()!==t&&i(this,N).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=i(this,re))!=null&&t.div&&!i(this,mn)){f(this,mn,new AbortController);const e=i(this,N).combinedSignal(i(this,mn));i(this,re).div.addEventListener("pointerdown",b(this,mt,ny).bind(this),{signal:e}),i(this,re).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=i(this,re))!=null&&t.div&&i(this,mn)&&(i(this,mn).abort(),f(this,mn,null),i(this,re).div.classList.remove("highlighting"))}enableClick(){if(i(this,yr))return;f(this,yr,new AbortController);const t=i(this,N).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(){var t;(t=i(this,yr))==null||t.abort(),f(this,yr,null)}attach(t){i(this,Ve).set(t.id,t);const{annotationElementId:e}=t;e&&i(this,N).isDeletedAnnotationElement(e)&&i(this,N).removeDeletedAnnotationElement(t)}detach(t){var e;i(this,Ve).delete(t.id),(e=i(this,Za))==null||e.removePointerInTextLayer(t.contentDiv),!i(this,$l)&&t.annotationElementId&&i(this,N).addDeletedAnnotationElement(t)}remove(t){this.detach(t),i(this,N).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(i(this,N).addDeletedAnnotationElement(t),yt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}
55add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),i(this,N).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!i(this,zl)),i(this,N).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!i(this,pn)&&(t._focusEventsAllowed=!1,f(this,pn,setTimeout(()=>{f(this,pn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:i(this,N)._signal}),e.focus())},0))),t._structTreeParentId=(s=i(this,Za))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of i(this,Ve).values())if(e.uid===t)return e;return null}combinedSignal(t){return i(this,N).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=i(this,mt,ii))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await i(this,N).updateMode(t.mode);const{offsetX:s,offsetY:n}=b(this,mt,Up).call(this),r=i(this,N).getId(),a=b(this,mt,Hp).call(this,{parent:this,id:r,x:s,y:n,uiManager:i(this,N),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=i(Ns,vr).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,i(this,N)))||null}createAndAddNewEditor(t,e,s={}){const n=i(this,N).getId(),r=b(this,mt,Hp).call(this,{parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:i(this,N),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,mt,Up).call(this),!0,t)}setSelected(t){i(this,N).setSelected(t)}toggleSelected(t){i(this,N).toggleSelected(t)}unselect(t){i(this,N).unselect(t)}pointerup(t){var n;const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!i(this,Ar)||(f(this,Ar,!1),(n=i(this,mt,ii))!=null&&n.isDrawer&&i(this,mt,ii).supportMultipleDrawings))return;if(!i(this,Gl)){f(this,Gl,!0);return}const s=i(this,N).getMode();if(s===G.STAMP||s===G.POPUP||s===G.SIGNATURE){i(this,N).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var n;if(i(this,N).getMode()===G.HIGHLIGHT&&this.enableTextSelection(),i(this,Ar)){f(this,Ar,!1);return}const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(f(this,Ar,!0),(n=i(this,mt,ii))!=null&&n.isDrawer){this.startDrawingSession(t);return}const s=i(this,N).getActive();f(this,Gl,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),i(this,qs)){i(this,mt,ii).startDrawing(this,i(this,N),!1,t);return}i(this,N).setCurrentDrawingSession(this),f(this,qs,new AbortController);const e=i(this,N).combinedSignal(i(this,qs));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(f(this,gn,null),this.commitOrRemove())},{signal:e}),i(this,mt,ii).startDrawing(this,i(this,N),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&f(this,gn,e);return}i(this,gn)&&setTimeout(()=>{var e;(e=i(this,gn))==null||e.focus(),f(this,gn,null)},0)}endDrawingSession(t=!1){return i(this,qs)?(i(this,N).setCurrentDrawingSession(null),i(this,qs).abort(),f(this,qs,null),f(this,gn,null),i(this,mt,ii).endDrawing(t)):null}findNewParent(t,e,s){const n=i(this,N).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,mt,ii).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=i(this,N).getActive())==null?void 0:t.parent)===this&&(i(this,N).commitOrRemove(),i(this,N).setActiveEditor(null)),i(this,pn)&&(clearTimeout(i(this,pn)),f(this,pn,null));for(const s of i(this,Ve).values())(e=i(this,Za))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,i(this,Ve).clear(),i(this,N).removeLayer(this)}async render({viewport:t}){this.viewport=t,eo(this.div,t);for(const e of i(this,N).getEditors(this.pageIndex))this.add(e),e.rebuild();await i(this,N).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){i(this,N).commitOrRemove(),b(this,mt,hu).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,eo(this.div,{rotation:s}),e!==s)for(const n of i(this,Ve).values())n.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return i(this,N).viewParameters.realScale}};Za=new WeakMap,Gl=new WeakMap,br=new WeakMap,yr=new WeakMap,pn=new WeakMap,Ve=new WeakMap,Ar=new WeakMap,$l=new WeakMap,zl=new WeakMap,qs=new WeakMap,gn=new WeakMap,re=new WeakMap,mn=new WeakMap,wr=new WeakMap,jl=new WeakMap,N=new WeakMap,vr=new WeakMap,mt=new WeakSet,Bp=function(){return i(this,Ve).size!==0?i(this,Ve).values():i(this,N).getEditors(this.pageIndex)},ny=function(t){i(this,N).unselectAll();const{target:e}=t;if(e===i(this,re).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImagePlaceholder"))&&i(this,re).div.contains(e)){const{isMac:s}=Wt.platform;if(t.button!==0||t.ctrlKey&&s)return;i(this,N).showAllEditors("highlight",!0,!0),i(this,re).div.classList.add("free"),this.toggleDrawing(),yu.startHighlighting(this,i(this,N).direction==="ltr",{target:i(this,re).div,x:t.x,y:t.y}),i(this,re).div.addEventListener("pointerup",()=>{i(this,re).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:i(this,N)._signal}),t.preventDefault()}},ii=function(){return i(Ns,vr).get(i(this,N).getMode())},Hp=function(t){const e=i(this,mt,ii);return e?new e.prototype.constructor(t):null},Up=function(){const{x:t,y:e,width:s,height:n}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+n),h=(r+o)/2-t,c=(a+l)/2-e,[d,p]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:p}},hu=function(){for(const t of i(this,Ve).values())t.isEmpty()&&t.remove()},x(Ns,"_initialized",!1),g(Ns,vr,new Map([yp,Pp,Fp,yu,Rp].map(t=>[t._editorType,t])));let Np=Ns;var Qs,Re,to,cd,ju,ry,Pi,$p,ay,zp;const Kt=class Kt{constructor(){g(this,Pi);g(this,Qs,null);g(this,Re,new Map);g(this,to,new Map)}setParent(t){if(!i(this,Qs)){f(this,Qs,t);return}if(i(this,Qs)!==t){if(i(this,Re).size>0)for(const e of i(this,Re).values())e.remove(),t.append(e);f(this,Qs,t)}}static get _svgFactory(){return $(this,"_svgFactory",new mu)}draw(t,e=!1,s=!1){const n=$t(Kt,cd)._++,r=b(this,Pi,$p).call(this),a=Kt._svgFactory.createElement("defs");r.append(a);const o=Kt._svgFactory.createElement("path");a.append(o);const l=`path_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&i(this,to).set(n,o);const h=s?b(this,Pi,ay).call(this,a,l):null,c=Kt._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),i(this,Re).set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=$t(Kt,cd)._++,n=b(this,Pi,$p).call(this),r=Kt._svgFactory.createElement("defs");n.append(r);const a=Kt._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=Kt._svgFactory.createElement("mask");r.append(d),l=`mask_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const p=Kt._svgFactory.createElement("rect");d.append(p),p.setAttribute("width","1"),p.setAttribute("height","1"),p.setAttribute("fill","white");const m=Kt._svgFactory.createElement("use");d.append(m),m.setAttribute("href",`#${o}`),m.setAttribute("stroke","none"),m.setAttribute("fill","black"),m.setAttribute("fill-rule","nonzero"),m.classList.add("mask")}const h=Kt._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,Re).set(s,n),s}finalizeDraw(t,e){i(this,to).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,Re).get(t):t;if(o){if(s&&b(this,Pi,zp).call(this,o,s),n&&b(l=Kt,ju,ry).call(l,o,n),r){const{classList:h}=o;for(const[c,d]of Object.entries(r))h.toggle(c,d)}if(a){const c=o.firstElementChild.firstElementChild;b(this,Pi,zp).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=i(this,Re).get(t);s&&(i(e,Qs).append(s),i(this,Re).delete(t),i(e,Re).set(t,s))}remove(t){i(this,to).delete(t),i(this,Qs)!==null&&(i(this,Re).get(t).remove(),i(this,Re).delete(t))}destroy(){f(this,Qs,null);for(const t of i(this,Re).values())t.remove();i(this,Re).clear(),i(this,to).clear()}};Qs=new WeakMap,Re=new WeakMap,to=new WeakMap,cd=new WeakMap,ju=new WeakSet,ry=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}%`},Pi=new WeakSet,$p=function(){const t=Kt._svgFactory.create(1,1,!0);return i(this,Qs).append(t),t.setAttribute("aria-hidden",!0),t},ay=function(t,e){const s=Kt._svgFactory.createElement("clipPath");t.append(s);const n=`clip_${e}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const r=Kt._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),n},zp=function(t,e){for(const[s,n]of Object.entries(e))n===null?t.removeAttribute(s):t.setAttribute(s,n)},g(Kt,ju),g(Kt,cd,0);let Gp=Kt;function Cd(u){return`${(u*100).toFixed(2)}%`}var Vl,dd,ud,Wl,_i,Ci,fd,Vu,oy;const Eh=class Eh{constructor(t,e,s,n){g(this,Vu);g(this,Vl,[]);g(this,dd,new Map);g(this,ud,null);g(this,Wl,0);g(this,_i,0);g(this,Ci,0);f(this,Wl,t),f(this,Vl,e),f(this,_i,s.rawDims.pageWidth),f(this,Ci,s.rawDims.pageHeight),f(this,ud,n)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<i(this,Vl).length;e+=6){const s=b(this,Vu,oy).call(this,i(this,Vl).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var w;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,n=i(this,dd).get(s);if(!n)return;const r=(w=i(Eh,fd))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),f(Eh,fd,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=n,d=i(this,ud).call(this),p=Math.ceil(o*d.width),m=Math.ceil(l*d.height),y=Math.floor((o+h/i(this,_i)
55)*d.width),A=Math.floor((l+c/i(this,Ci))*d.height);s.width=y-p,s.height=A-m;const v=s.getContext("2d");v.setTransform(...a),v.translate(-p,-m),v.drawImage(d,0,0)}),t}};Vl=new WeakMap,dd=new WeakMap,ud=new WeakMap,Wl=new WeakMap,_i=new WeakMap,Ci=new WeakMap,fd=new WeakMap,Vu=new WeakSet,oy=function([t,e,s,n,r,a]){const o=Math.hypot((r-t)*i(this,_i),(a-e)*i(this,Ci)),l=Math.hypot((s-t)*i(this,_i),(n-e)*i(this,Ci));if(o<i(this,Wl)||l<i(this,Wl))return null;const h=[(r-t)*i(this,_i)/o,(a-e)*i(this,Ci)/o,(s-t)*i(this,_i)/l,(n-e)*i(this,Ci)/l,0,0],c=M.inverseTransform(h),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:Cd(t),top:Cd(e),width:Cd(o/i(this,_i)),height:Cd(l/i(this,Ci)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),i(this,dd).set(d,{inverseTransform:c,width:o,height:l,x1:t,y1:e}),d},g(Eh,fd,null);let jp=Eh;globalThis._pdfjsTestingUtils={HighlightOutliner:wp};globalThis.pdfjsLib={AbortException:Sr,AnnotationEditorLayer:Np,AnnotationEditorParamsType:V,AnnotationEditorType:G,AnnotationEditorUIManager:so,AnnotationLayer:mp,AnnotationMode:xn,AnnotationType:jt,applyOpacity:Iy,build:YA,ColorPicker:pu,createValidAbsoluteUrl:$g,CSSConstants:Dy,DOMSVGFactory:mu,DrawLayer:Gp,FeatureTest:Wt,fetchData:Xp,findContrastColor:Ly,getDocument:zA,getFilenameFromUrl:Cy,getPdfFilenameFromUrl:Ty,getRGB:gd,getRGBA:qp,getUuid:jg,getXfaPageViewport:Py,GlobalWorkerOptions:bn,ImageKind:Td,InvalidPDFException:yf,isDataScheme:qu,isPdfFile:Kp,isValidExplicitDest:Qy,makeArr:Vp,makeMap:Wp,makeObj:wf,MathClamp:Ct,noContextMenu:Fs,normalizeUnicode:Ey,OPS:Ri,OutputScale:Ti,PasswordResponses:gy,PDFDataRangeTransport:rb,PDFDateString:du,PDFWorker:kh,PermissionFlag:py,PixelsPerInch:Er,RenderingCancelledException:Yp,renderRichText:Wg,ResponseException:cu,setLayerDimensions:eo,shadow:$,SignatureExtractor:yn,stopEvent:Pt,SupportedImageMimeTypes:vf,TextLayer:Ph,TextLayerImages:jp,TouchManager:fu,updateUrlHash:zg,Util:M,VerbosityLevel:Wu,version:XA,XfaLayer:Vg};export{Sr as AbortException,Np as AnnotationEditorLayer,V as AnnotationEditorParamsType,G as AnnotationEditorType,so as AnnotationEditorUIManager,mp as AnnotationLayer,xn as AnnotationMode,jt as AnnotationType,Dy as CSSConstants,pu as ColorPicker,mu as DOMSVGFactory,Gp as DrawLayer,Wt as FeatureTest,bn as GlobalWorkerOptions,Td as ImageKind,yf as InvalidPDFException,Ct as MathClamp,Ri as OPS,Ti as OutputScale,rb as PDFDataRangeTransport,du as PDFDateString,kh as PDFWorker,gy as PasswordResponses,py as PermissionFlag,Er as PixelsPerInch,Yp as RenderingCancelledException,cu as ResponseException,yn as SignatureExtractor,vf as SupportedImageMimeTypes,Ph as TextLayer,jp as TextLayerImages,fu as TouchManager,M as Util,Wu as VerbosityLevel,Vg as XfaLayer,Iy as applyOpacity,YA as build,$g as createValidAbsoluteUrl,Xp as fetchData,Ly as findContrastColor,zA as getDocument,Cy as getFilenameFromUrl,Ty as getPdfFilenameFromUrl,gd as getRGB,qp as getRGBA,jg as getUuid,Py as getXfaPageViewport,qu as isDataScheme,Kp as isPdfFile,Qy as isValidExplicitDest,Vp as makeArr,Wp as makeMap,wf as makeObj,Fs as noContextMenu,Ey as normalizeUnicode,Wg as renderRichText,eo as setLayerDimensions,$ as shadow,Pt as stopEvent,zg as updateUrlHash,XA as version};

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