>7-t&1)&u}return{srcPos:e,destPos:g}}const Tt=16,St=new DOMMatrix,_t=new Float32Array(2);function drawImageAtIntegerCoords(t,e,i,s,n,r,a,o,l,h){const[d,c,u,p,g,m]=getCurrentTransform(t);if(0===c&&0===u){const f=a*d+g,b=Math.round(f),y=o*p+m,A=Math.round(y),v=(a+l)*d+g,w=Math.abs(Math.round(v)-b)||1,x=(o+h)*p+m,C=Math.abs(Math.round(x)-A)||1;t.setTransform(Math.sign(d),0,0,Math.sign(p),b,A);t.drawImage(e,i,s,n,r,0,0,w,C);t.setTransform(d,c,u,p,g,m);return[w,C]}if(0===d&&0===p){const f=o*u+g,b=Math.round(f),y=a*c+m,A=Math.round(y),v=(o+h)*u+g,w=Math.abs(Math.round(v)-b)||1,x=(a+l)*c+m,C=Math.abs(Math.round(x)-A)||1;t.setTransform(0,Math.sign(c),Math.sign(u),0,b,A);t.drawImage(e,i,s,n,r,0,0,C,w);t.setTransform(d,c,u,p,g,m);return[C,w]}t.drawImage(e,i,s,n,r,a,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class CanvasExtraState{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=s;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=y;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=i.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){const t=Object.create(this);t.clipBox=this.clipBox.slice();t.minMax=this.minMax.slice();t.tilingPatternDims=this.tilingPatternDims?.slice();return t}getPathBoundingBox(t=vt,e=null){const i=this.minMax.slice();if(t===wt){e||unreachable("Stroke bounding box must include transform.");Util.singularValueDecompose2dScale(e,_t);const t=_t[0]*this.lineWidth/2,s=_t[1]*this.lineWidth/2;i[0]-=t;i[1]-=s;i[2]+=t;i[3]+=s}return i}updateClipFromPath(){const t=Util.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(i,0)}getClippedPathBoundingBox(t=vt,e=null){return Util.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function putBinaryImageData(t,e){if(e instanceof ImageData){t.putImageData(e,0,0);return}const i=e.height,s=e.width,n=i%Tt,r=(i-n)/Tt,a=0===n?r:r+1,o=t.createImageData(s,Tt);let l,h=0;const d=e.data,c=o.data;let u,p,g,m;if(e.kind===E.GRAYSCALE_1BPP){const e=d.byteLength,i=new Uint32Array(c.buffer,0,c.byteLength>>2),m=i.length,f=s+7>>3,b=4294967295,y=FeatureTest.isLittleEndian?4278190080:255;for(u=0;uf?s:8*t-7,a=-8&r;let o=0,c=0;for(;n>=1}}for(;l new CanvasGraphics(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new CanvasNestedDependencyTracker(this.dependencyTracker,e,!0):null)};i=new TilingPattern(e,this.ctx,s,t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.current.strokeColor=this.getColorN_Pattern(t,e);this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);const i=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0;this.current.tilingPatternDims=i instanceof TilingPattern?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.ctx.strokeStyle=this.current.strokeColor=e;this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.ctx.strokeStyle=this.current.strokeColor="transparent";this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t);this.ctx.fillStyle=this.current.fillColor=e;this.current.patternFill=!1;this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t);this.ctx.fillStyle=this.current.fillColor="transparent";this.current.patternFill=!1;this.current.tilingPatternDims=null}_getPattern(t,e,i=null){let s;if(this.cachedPatterns.has(e))s=this.cachedPatterns.get(e);else{s=function getShadingPattern(t){switch(t[0]){case"RadialAxial":return new RadialAxialShadingPattern(t);case"Mesh":return new MeshShadingPattern(t);case"Dummy":return new DummyShadingPattern}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e));this.cachedPatterns.set(e,s)}i&&(s.matrix=i);return s}shadingFill(t,e){if(!this.contentVisible)return;const s=this.ctx;this.save(t);const n=this._getPattern(t,e);s.fillStyle=n.getPattern(s,this,getCurrentTransformInverse(s),xt,t);const r=getCurrentTransformInverse(s);if(r){const{width:t,height:e}=s.canvas,n=i.slice();Util.axialAlignedBoundingBox([0,0,t,e],r,n);const[a,o,l,h]=n;this.ctx.fillRect(a,o,l-a,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,at).recordDependencies(t,it).recordOperation(t);this.compose(this.current.getClippedPathBoundingBox());this.restore(t)}beginInlineImage(){unreachable("Should not call beginInlineImage")}beginImageData(){unreachable("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible){this.save(t);this.baseTransformStack.push(this.baseTransform);e&&this.transform(t,...e);this.baseTransform=getCurrentTransform(this.ctx);if(i){Util.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[e,s,n,r]=i,a=new Path2D;a.rect(e,s,n-e,r-s);this.ctx.clip(a);this.dependencyTracker?.recordClipBox(t,this.ctx,e,n,s,r);this.endPath(t)}}}paintFormXObjectEnd(t){if(this.contentVisible){this.restore(t);this.baseTransform=this.baseTransformStack.pop()}}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);const{inSMaskMode:s}=this;if(s){this.endSMaskMode();this.current.activeSMask=null}const n=this.ctx;e.isolated||info("TODO: Support non-isolated groups.");e.knockout&&warn("Knockout groups not supported.");if(!e.needsIsolation&&1===n.globalAlpha&&"source-over"===n.globalCompositeOperation&&!s){if(e.bbox){let t=new Path2D;const[i,s,r,a]=e.bbox;t.rect(i,s,r-i,a-s);if(e.matrix){const i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix));t=i}n.clip(t)}this.groupStack.push(null);this.groupLevel++;return}const r=getCurrentTransform(n);e.matrix&&n.transform(...e.matrix);const a=[0,0,n.canvas.width,n.canvas.height];let o;if(e.bbox){o=i.slice();Util.axialAlignedBoundingBox(e.bbox,getCurrentTransform(n),o);o=Util.intersect(o,a)||[0,0,0,0]}else o=a;const l=Math.floor(o[0]),h=Math.floor(o[1]),d=Math.max(Math.ceil(o[2])-l,1),c=Math.max(Math.ceil(o[3])-h,1);this.current.startNewPathAndClipBox([0,0,d,c]);const u=this.canvasFactory.create(d,c);e.smask&&this.smaskGroupCanvases.push(u);const p=u.context;p.translate(-l,-h);p.transform(...r);if(!e.isolated&&!e.smask&&s&&e.needsIsolation){p.save();p.setTransform(1,0,0,1,0,0);p.drawImage(n.canvas,-l,-h);p.restore()}if(e.bbox){let t=new Path2D;const[i,s,n,r]=e.bbox;t.rect(i,s,n-i,r-s);if(e.matrix){const i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix));t=i}p.clip(t)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:p,offsetX:l,offsetY:h,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null});if(!e.smask||this.dependencyTracker){n.setTransform(1,0,0,1,0,0);n.translate(l,h);n.save()}copyCtxState(n,p);this.ctx=p;this.dependencyTracker?.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){if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,n=this.groupStack.pop();if(null!==n){this.ctx=n;this.ctx.imageSmoothingEnabled=!1;this.dependencyTracker?.popBaseTransform();if(e.smask){this.tempSMask=this.smaskStack.pop();this.restore(t);if(this.dependencyTracker){this.ctx.restore();this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())}}else{this.ctx.restore();const e=getCurrentTransform(this.ctx);this.restore(t);this.ctx.save();this.ctx.setTransform(...e);const n=i.slice();Util.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],e,n);this.ctx.drawImage(s.canvas,0,0);this.ctx.restore();this.canvasFactory.destroy({canvas:s.canvas,context:s});this.compose(n)}}else this.restore(t)}beginAnnotation(t,e,i,s,n,r){this.#zs();resetCtxToDefault(this.ctx);this.ctx.save();this.save(t);this.baseTransform&&this.ctx.setTransform(...this.baseTransform);if(i){const n=i[2]-i[0],a=i[3]-i[1];if(r&&this.annotationCanvasMap){(s=s.slice())[4]-=i[0];s[5]-=i[1];(i=i.slice())[0]=i[1]=0;i[2]=n;i[3]=a;Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx),_t);const{viewportScale:t}=this,r=Math.ceil(n*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l);this.annotationCanvas.savedCtx=this.ctx;this.ctx=h;this.ctx.save();this.ctx.setTransform(_t[0],0,0,-_t[1],0,a*_t[1]);resetCtxToDefault(this.ctx)}else{resetCtxToDefault(this.ctx);this.endPath(t);const e=new Path2D;e.rect(i[0],i[1],n,a);this.ctx.clip(e)}}this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.baseTransformStack.push(this.baseTransform);this.transform(t,...s);this.transform(t,...n);this.baseTransform=getCurrentTransform(this.ctx)}endAnnotation(t){if(this.annotationCanvas){this.ctx.restore();this.#Gs();this.ctx=this.annotationCanvas.savedCtx;delete this.annotationCanvas.savedCtx;delete this.annotationCanvas}this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const i=e.count;(e=this.getObject(t,e.data,e)).count=i;const s=this.ctx,n=this._createMaskCanvas(t,e),r=n.canvas;s.save();s.setTransform(1,0,0,1,0,0);s.drawImage(r,n.offsetX,n.offsetY);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+r.width,n.offsetY,n.offsetY+r.height).recordOperation(t);s.restore();n.canvasEntry&&this.canvasFactory.destroy(n.canvasEntry);this.compose()}paintImageMaskXObjectRepeat(t,e,i,s=0,n=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const o=this.ctx;o.save();const l=getCurrentTransform(o);o.transform(i,s,n,r,0,0);const h=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]);this.dependencyTracker?.resetBBox(t);for(let e=0,d=a.length;e >7-t&1)&u}return{srcPos:e,destPos:g}}function convertRGBToRGBA({src:t,srcPos:e=0,dest:i,destPos:n=0,width:s,height:r}){let a=0;const o=s*r*3,l=o>>2,h=new Uint32Array(t.buffer,e,l),c=FeatureTest.isLittleEndian?4278190080:255;if(FeatureTest.isLittleEndian){for(;a new CanvasGraphics(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new CanvasNestedDependencyTracker(this.dependencyTracker,e,!0):null)};i=new TilingPattern(e,this.ctx,n,t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.current.strokeColor=this.getColorN_Pattern(t,e);this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);const i=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0;this.current.tilingPatternDims=i instanceof TilingPattern?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.ctx.strokeStyle=this.current.strokeColor=e;this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.ctx.strokeStyle=this.current.strokeColor="transparent";this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t);this.ctx.fillStyle=this.current.fillColor=e;this.current.patternFill=!1;this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t);this.ctx.fillStyle=this.current.fillColor="transparent";this.current.patternFill=!1;this.current.tilingPatternDims=null}_getPattern(t,e,i=null){const n=this.cachedPatterns.getOrInsertComputed(e,()=>function getShadingPattern(t){switch(t[0]){case"RadialAxial":return new RadialAxialShadingPattern(t);case"Mesh":return new MeshShadingPattern(t);case"Dummy":return new DummyShadingPattern}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)));i&&(n.matrix=i);return n}shadingFill(t,e){if(!this.contentVisible)return;const i=this.#hs(this.current.fillAlpha),n=this.ctx;this.save(t);const r=this._getPattern(t,e);n.fillStyle=r.getPattern(n,this,getCurrentTransformInverse(n),kt,t);const a=getCurrentTransformInverse(n);if(a){const{width:t,height:e}=n.canvas,i=s.slice();Util.axialAlignedBoundingBox([0,0,t,e],a,i);const[r,o,l,h]=i;this.ctx.fillRect(r,o,l-r,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,ut).recordDependencies(t,lt).recordOperation(t);this.compose(this.current.getClippedPathBoundingBox());this.restore(t);this.#cs(i)}beginInlineImage(){unreachable("Should not call beginInlineImage")}beginImageData(){unreachable("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible){this.save(t);this.baseTransformStack.push(this.baseTransform);e&&this.transform(t,...e);this.baseTransform=getCurrentTransform(this.ctx);if(i){Util.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[e,n,s,r]=i,a=new Path2D;a.rect(e,n,s-e,r-n);this.ctx.clip(a);this.dependencyTracker?.recordClipBox(t,this.ctx,e,s,n,r);this.endPath(t)}}}paintFormXObjectEnd(t){if(this.contentVisible){this.restore(t);this.baseTransform=this.baseTransformStack.pop()}}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);const{inSMaskMode:i}=this;if(i){this.endSMaskMode();this.current.activeSMask=null}const n=this.ctx;if(!(e.needsIsolation&&(e.isolated||e.hasSoftMask)||e.knockout||e.isGray||0!==this.#qn||1!==n.globalAlpha||"source-over"!==n.globalCompositeOperation||i)){if(e.bbox){let t=new Path2D;const[i,s,r,a]=e.bbox;t.rect(i,s,r-i,a-s);if(e.matrix){const i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix));t=i}n.clip(t)}this.groupStack.push(null);this.#is.push(null);this.groupLevel++;return}e.isolated||e.knockout||0!==this.#qn||info("TODO: Fully support non-isolated non-knockout groups.");const r=getCurrentTransform(n);e.matrix&&n.transform(...e.matrix);const a=[0,0,n.canvas.width,n.canvas.height];let o;if(e.bbox){o=s.slice();Util.axialAlignedBoundingBox(e.bbox,getCurrentTransform(n),o);o=Util.intersect(o,a)||[0,0,0,0]}else 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 u=this.canvasFactory.create(c,d);e.smask&&this.smaskGroupCanvases.push(u);const p=u.context,g=e.knockout&&!e.isolated?n:null,m=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#qn>0,f=e.knockout?this.canvasFactory.create(c,d):null,b=this.#qn;e.knockout?this.#qn++:this.#qn=0;p.translate(-l,-h);p.transform(...r);const y=!e.isolated&&!e.smask&&e.needsIsolation,v=y&&!i&&0===b&&!e.knockout&&!e.isGray&&e.hasSoftMask&&1===n.globalAlpha&&"source-over"===n.globalCompositeOperation&&"none"===this.current.transferMaps;if(y&&(i||v)){p.save();p.setTransform(1,0,0,1,0,0);p.drawImage(n.canvas,-l,-h);p.restore()}if(e.bbox){let t=new Path2D;const[i,n,s,r]=e.bbox;t.rect(i,n,s-i,r-n);if(e.matrix){const i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix));t=i}p.clip(t)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:p,offsetX:l,offsetY:h,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null});if(!e.smask||this.dependencyTracker){n.setTransform(1,0,0,1,0,0);n.translate(l,h);n.save()}copyCtxState(n,p);this.ctx=p;this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(n);this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]);this.groupStack.push(n);this.#is.push({backdropCtx:g,savedKnockoutLevel:b,offsetX:l,offsetY:h,hasInnerBackdrop:m,replaceBackdrop:v,knockoutMaskEntry:f,knockoutTempEntry:null,knockoutBackdropEntry:null});this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,n=this.groupStack.pop(),r=this.#is.pop();r&&(this.#qn=r.savedKnockoutLevel);if(null!==n){e.isGray&&this.#us(i);this.ctx=n;this.ctx.imageSmoothingEnabled=!1;this.dependencyTracker?.popBaseTransform();if(e.smask){this.tempSMask=this.smaskStack.pop();this.restore(t);if(this.dependencyTracker){this.ctx.restore();this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())}this.#ss(r)}else{this.ctx.restore();const e=getCurrentTransform(this.ctx);this.restore(t);this.ctx.save();this.ctx.setTransform(...e);const a=s.slice();Util.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,a);const o=this.#is.at(-1);if(this.#qn>0)if(r.hasInnerBackdrop){const{width:t,height:s}=i.canvas,a=this.canvasFactory.create(t,s),o=a.context;o.drawImage(n.canvas,r.offsetX,r.offsetY,t,s,0,0,t,s);o.globalCompositeOperation="source-over";o.drawImage(i.canvas,0,0);const l=this.#as(i.canvas);o.globalCompositeOperation="destination-in";o.drawImage(l.canvas,0,0);const h=this.ctx.globalCompositeOperation,c=this.ctx.globalAlpha,d=this.ctx.filter;this.ctx.save();this.ctx.setTransform(...e);this.ctx.globalAlpha=1;FeatureTest.isCanvasFilterSupported&&(this.ctx.filter="none");this.ctx.globalCompositeOperation="destination-out";this.ctx.drawImage(l.canvas,0,0);this.ctx.globalCompositeOperation=h;this.ctx.globalAlpha=c;FeatureTest.isCanvasFilterSupported&&(this.ctx.filter=d??"none");this.ctx.drawImage(a.canvas,0,0);this.ctx.restore();this.canvasFactory.destroy(l);this.canvasFactory.destroy(a)}else{const t=o?.backdropCtx??null;this.#ls(this.ctx,i.canvas,{backdropCanvas:t?.canvas??null,destTransform:e,backdropOffset:t?[o.offsetX+r.offsetX,o.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(r.replaceBackdrop){const t=new Path2D;t.rect(0,0,i.canvas.width,i.canvas.height);this.ctx.clip(t);this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(i.canvas,0,0)}this.ctx.restore();this.canvasFactory.destroy({canvas:i.canvas,context:i});this.#ss(r);this.compose(a)}}else this.restore(t)}#us(t){const{canvas:e}=t,{width:i,height:n}=e;if(FeatureTest.isCanvasFilterSupported){t.save();t.setTransform(1,0,0,1,0,0);t.filter="grayscale(1)";t.globalAlpha=1;t.globalCompositeOperation="copy";t.drawImage(e,0,0);t.restore();return}const s=t.getImageData(0,0,i,n),{data:r}=s;for(let t=0,e=r.length;t c[1]){a=c[0];o=c[1]}else o===c[1]&&(a=d(a,c[0]));if(h {e?.updateEditSignatureButton(t)})}}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#Vl,r=Math.max(s,n);return{areContours:e,outline:SignatureExtractor.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,s){const{x:n,y:r}=this,{outline:a}=this.#Vl=t;this.#Gl=a instanceof ContourDrawOutline;this.description=i;let o;if(this.#Gl)o=SignatureEditor.getDefaultDrawingOptions();else{o=SignatureEditor._defaultDrawnSignatureOptions.clone();o.updateProperties({"stroke-width":a.thickness})}this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h;this.width*=h/this.height;if(this.width>=1){h*=.9/this.width;this.width=.9}this.height=h;this.setDims();this.x=n;this.y=r;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(s);this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}});this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return SignatureExtractor.process(t,e,i,s,SignatureEditor._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return SignatureExtractor.extractContoursFromText(t,e,i,s,n,SignatureEditor._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return SignatureExtractor.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:SignatureEditor._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){if(t)this._drawingOptions=SignatureEditor.getDefaultDrawingOptions();else{this._drawingOptions=SignatureEditor._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":e})}}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#Gl,color:[0,0,0],thickness:this.#Gl?0:s});this.addComment(n);if(t){n.paths={lines:e,points:i};n.uuid=this.#jl;n.isCopy=!0}else n.lines=e;this.#Wl&&(n.accessibilityData={type:"Figure",alt:this.#Wl});return n}static deserializeDraw(t,e,i,s,n,r){return r.areContours?ContourDrawOutline.deserialize(t,e,i,s,n,r):InkDrawOutline.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){const s=await super.deserialize(t,e,i);s.#Gl=t.areContours;s.description=t.accessibilityData?.alt||"";s.#jl=t.uuid;return s}}class StampEditor extends AnnotationEditor{#$l=null;#Xl=null;#ql=null;#Kl=null;#Yl=null;#Ql="";#Jl=null;#Zl=!1;#th=null;#eh=!1;#ih=!1;static _type="stamp";static _editorType=m.STAMP;constructor(t){super({...t,name:"stampEditor"});this.#Kl=t.bitmapUrl;this.#Yl=t.bitmapFile;this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){AnnotationEditor.initialize(t,e)}static isHandlingMimeForPasting(t){return j.includes(t)}static paste(t,e){e.pasteEditor({mode:m.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#sh(t,e=!1){if(t){this.#$l=t.bitmap;if(!e){this.#Xl=t.id;this.#eh=t.isSvg}t.file&&(this.#Ql=t.file.name);this.#nh()}else this.remove()}#rh(){this.#ql=null;this._uiManager.enableWaiting(!1);if(this.#Jl)if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#$l)this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#$l){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;await this.setGuessedAltText(o);e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1});return o}#ah(){if(this.#Xl){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(this.#Xl).then(t=>this.#sh(t,!0)).finally(()=>this.#rh());return}if(this.#Kl){const t=this.#Kl;this.#Kl=null;this._uiManager.enableWaiting(!0);this.#ql=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#sh(t)).finally(()=>this.#rh());return}if(this.#Yl){const t=this.#Yl;this.#Yl=null;this._uiManager.enableWaiting(!0);this.#ql=this._uiManager.imageManager.getFromFile(t).then(t=>this.#sh(t)).finally(()=>this.#rh());return}const t=document.createElement("input");t.type="file";t.accept=j.join(",");const e=this._uiManager._signal;this.#ql=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});this.#sh(e)}else this.remove();i()},{signal:e});t.addEventListener("cancel",()=>{this.remove();i()},{signal:e})}).finally(()=>this.#rh());t.click()}remove(){if(this.#Xl){this.#$l=null;this._uiManager.imageManager.deleteId(this.#Xl);this.#Jl?.remove();this.#Jl=null;if(this.#th){clearTimeout(this.#th);this.#th=null}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){this.#Xl&&null===this.#Jl&&this.#ah();this.isAttachedToDOM||this.parent.add(this)}}else this.#Xl&&this.#ah()}onceAdded(t){this._isDraggable=!0;t&&this.div.focus()}isEmpty(){return!(this.#ql||this.#$l||this.#Kl||this.#Yl||this.#Xl||this.#Zl)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this._isCopy){t=this.x;e=this.y}super.render();this.div.hidden=!0;this.createAltText();this.#Zl||(this.#$l?this.#nh():this.#ah());this._isCopy&&this._moveAfterPaste(t,e);this._uiManager.addShouldRescale(this);return this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove();if(i&&this._uiManager.imageManager.isValidId(i)){this.#Xl=i;s&&(this.#$l=s);this.#Zl=!1;this.#nh()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#th&&clearTimeout(this.#th);this.#th=setTimeout(()=>{this.#th=null;this.#oh()},200)}#nh(){const{div:t}=this;let{width:e,height:i}=this.#$l;const[s,n]=this.pageDimensions,r=.75;if(this.width){e=this.width*s;i=this.height*n}else if(e>r*s||i>r*n){const t=Math.min(r*s/e,r*n/i);e*=t;i*=t}this._uiManager.enableWaiting(!1);const a=this.#Jl=document.createElement("canvas");a.setAttribute("role","img");this.addContainer(a);this.width=e/s;this.height=i/n;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1);this.#oh();if(!this.#ih){this.parent.addUndoableEditor(this);this.#ih=!0}this._reportTelemetry({action:"inserted_image"});this.#Ql&&this.div.setAttribute("aria-description",this.#Ql);this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#$l,r=new OutputScale;let a=this.#$l,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t);l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#eh||(a=this.#lh(t,i));const d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";if("none"!==this._uiManager.hcmFilter)u="black";else if(ColorScheme.isDarkMode){c="#8f8f9d";u="#42414d"}const p=15,g=p*r.sx,m=p*r.sy,f=new OffscreenCanvas(2*g,2*m),b=f.getContext("2d");b.fillStyle=c;b.fillRect(0,0,2*g,2*m);b.fillStyle=u;b.fillRect(0,0,g,m);b.fillRect(g,m,g,m);d.fillStyle=d.createPattern(f,"repeat");d.fillRect(0,0,t,i);d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(r.symmetric&&a.width d[1]){a=d[0];o=d[1]}else o===d[1]&&(a=c(a,d[0]));if(h {e?.updateEditSignatureButton(t)})}}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:n,height:s}=this.#yh,r=Math.max(n,s);return{areContours:e,outline:SignatureExtractor.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:n,height:s},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,n){const{x:s,y:r}=this,{outline:a}=this.#yh=t;this.#fh=a instanceof ContourDrawOutline;this.description=i;let o;if(this.#fh)o=SignatureEditor.getDefaultDrawingOptions();else{o=SignatureEditor._defaultDrawnSignatureOptions.clone();o.updateProperties({"stroke-width":a.thickness})}this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h;this.width*=h/this.height;if(this.width>=1){h*=.9/this.width;this.width=.9}this.height=h;this.setDims();this.x=s;this.y=r;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(n);this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!i}});this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return SignatureExtractor.process(t,e,i,n,SignatureEditor._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:s}=this.parent.viewport;return SignatureExtractor.extractContoursFromText(t,e,i,n,s,SignatureEditor._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return SignatureExtractor.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:SignatureEditor._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){if(t)this._drawingOptions=SignatureEditor.getDefaultDrawingOptions();else{this._drawingOptions=SignatureEditor._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":e})}}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,s=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#fh,color:[0,0,0],thickness:this.#fh?0:n});this.addComment(s);if(t){s.paths={lines:e,points:i};s.uuid=this.#vh;s.isCopy=!0}else s.lines=e;this.#bh&&(s.accessibilityData={type:"Figure",alt:this.#bh});return s}static deserializeDraw(t,e,i,n,s,r){return r.areContours?ContourDrawOutline.deserialize(t,e,i,n,s,r):InkDrawOutline.deserialize(t,e,i,n,s,r)}static async deserialize(t,e,i){const n=await super.deserialize(t,e,i);n.#fh=t.areContours;n.description=t.accessibilityData?.alt||"";n.#vh=t.uuid;return n}}class StampEditor extends AnnotationEditor{#wh=null;#xh=null;#Ah=null;#Eh=null;#Ch=null;#Sh="";#Th=null;#_h=!1;#kh=null;#Dh=!1;#Mh=!1;static _type="stamp";static _editorType=y.STAMP;constructor(t){super({...t,name:"stampEditor"});this.#Eh=t.bitmapUrl;this.#Ch=t.bitmapFile;this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){AnnotationEditor.initialize(t,e)}static isHandlingMimeForPasting(t){return X.includes(t)}static paste(t,e){e.pasteEditor({mode:y.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#Ph(t,e=!1){if(t){this.#wh=t.bitmap;if(!e){this.#xh=t.id;this.#Dh=t.isSvg}t.file&&(this.#Sh=t.file.name);this.#Ih()}else this.remove()}#Fh(){this.#Ah=null;this._uiManager.enableWaiting(!1);if(this.#Th)if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#wh)this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#wh){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:s,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:n,width:s,height:r,channels:n.length/(s*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;await this.setGuessedAltText(o);e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1});return o}#Oh(){if(this.#xh){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(this.#xh).then(t=>this.#Ph(t,!0)).finally(()=>this.#Fh());return}if(this.#Eh){const t=this.#Eh;this.#Eh=null;this._uiManager.enableWaiting(!0);this.#Ah=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#Ph(t)).finally(()=>this.#Fh());return}if(this.#Ch){const t=this.#Ch;this.#Ch=null;this._uiManager.enableWaiting(!0);this.#Ah=this._uiManager.imageManager.getFromFile(t).then(t=>this.#Ph(t)).finally(()=>this.#Fh());return}const t=document.createElement("input");t.type="file";t.accept=X.join(",");const e=this._uiManager._signal;this.#Ah=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});this.#Ph(e)}else this.remove();i()},{signal:e});t.addEventListener("cancel",()=>{this.remove();i()},{signal:e})}).finally(()=>this.#Fh());t.click()}remove(){if(this.#xh){this.#wh=null;this._uiManager.imageManager.deleteId(this.#xh);this.#Th?.remove();this.#Th=null;if(this.#kh){clearTimeout(this.#kh);this.#kh=null}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){this.#xh&&null===this.#Th&&this.#Oh();this.isAttachedToDOM||this.parent.add(this)}}else this.#xh&&this.#Oh()}onceAdded(t){this._isDraggable=!0;t&&this.div.focus()}isEmpty(){return!(this.#Ah||this.#wh||this.#Eh||this.#Ch||this.#xh||this.#_h)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this._isCopy){t=this.x;e=this.y}super.render();this.div.hidden=!0;this.createAltText();this.#_h||(this.#wh?this.#Ih():this.#Oh());this._isCopy&&this._moveAfterPaste(t,e);this._uiManager.addShouldRescale(this);return this.div}setCanvas(t,e){const{id:i,bitmap:n}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove();if(i&&this._uiManager.imageManager.isValidId(i)){this.#xh=i;n&&(this.#wh=n);this.#_h=!1;this.#Ih()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#kh&&clearTimeout(this.#kh);this.#kh=setTimeout(()=>{this.#kh=null;this.#Rh()},200)}#Ih(){const{div:t}=this;let{width:e,height:i}=this.#wh;const[n,s]=this.pageDimensions,r=.75;if(this.width){e=this.width*n;i=this.height*s}else if(e>r*n||i>r*s){const t=Math.min(r*n/e,r*s/i);e*=t;i*=t}this._uiManager.enableWaiting(!1);const a=this.#Th=document.createElement("canvas");a.setAttribute("role","img");this.addContainer(a);this.width=e/n;this.height=i/s;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1);this.#Rh();if(!this.#Mh){this.parent.addUndoableEditor(this);this.#Mh=!0}this._reportTelemetry({action:"inserted_image"});this.#Sh&&this.div.setAttribute("aria-description",this.#Sh);this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.stamp)}copyCanvas(t,e,i=!1){t||=224;const{width:n,height:s}=this.#wh,r=new OutputScale;let a=this.#wh,o=n,l=s,h=null;if(e){if(n>e||s>e){const t=Math.min(e/n,e/s);o=Math.floor(n*t);l=Math.floor(s*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#Dh||(a=this.#Bh(t,i));const c=h.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";if("none"!==this._uiManager.hcmFilter)u="black";else if(ColorScheme.isDarkMode){d="#8f8f9d";u="#42414d"}const p=15,g=p*r.sx,m=p*r.sy,f=new OffscreenCanvas(2*g,2*m),b=f.getContext("2d");b.fillStyle=d;b.fillRect(0,0,2*g,2*m);b.fillStyle=u;b.fillRect(0,0,g,m);b.fillRect(g,m,g,m);c.fillStyle=c.createPattern(f,"repeat");c.fillRect(0,0,t,i);c.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let c=null;if(i){let e,i;if(r.symmetric&&a.width {if(Array.isArray(t))for(var n=0;nt-e);const e=new Map;for(let i=0,s=t.length;i({...Promise.withResolvers(),data:Ft});class PDFObjects{#wn=new Map;get(t,e=null){if(e){const i=this.#wn.getOrInsertComputed(t,dataObj);i.promise.then(()=>e(i.data));return null}const i=this.#wn.get(t);if(!i||i.data===Ft)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#wn.get(t);return!!e&&e.data!==Ft}delete(t){const e=this.#wn.get(t);if(!e||e.data===Ft)return!1;this.#wn.delete(t);return!0}resolve(t,e=null){const i=this.#wn.getOrInsertComputed(t,dataObj);if(i.data!==Ft)throw new Error(`Object already resolved ${t}.`);i.data=e;i.resolve()}clear(){for(const{data:t}of this.#wn.values())t?.bitmap?.close();this.#wn.clear()}*[Symbol.iterator](){for(const[t,{data:e}]of this.#wn)e!==Ft&&(yield[t,e])}}class TextLayer{#xn=Promise.withResolvers();#_t=null;#Cn=!1;#En=!!globalThis.FontInspector?.enabled;#Tn=null;#Sn=null;#_n=null;#Pn=0;#Dn=0;#Mn=null;#kn=null;#In=0;#Fn=0;#Bn=Object.create(null);#Rn=[];#On=null;#Ln=[];#Nn=new WeakMap;#Un=null;static#Hn=new Map;static#zn=new Map;static#Gn=new WeakMap;static#Wn=null;static#Vn=new Set;constructor({textContentSource:t,images:e,container:i,viewport:s}){if(t instanceof ReadableStream)this.#On=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#On=new ReadableStream({start(e){e.enqueue(t);e.close()}})}this.#_t=this.#kn=i;this.#Tn=e;this.#Fn=s.scale*OutputScale.pixelRatio;this.#In=s.rotation;this.#_n={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;this.#Un=[1,0,0,-1,-a,o+r];this.#Dn=n;this.#Pn=r;TextLayer.#jn();i.style.setProperty("--min-font-size",TextLayer.#Wn);setLayerDimensions(i,s);this.#xn.promise.finally(()=>{TextLayer.#Vn.delete(this);this.#_n=null;this.#Bn=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=FeatureTest.platform;return shadow(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){this.#Tn&&this.#_t.append(this.#Tn.render());const pump=()=>{this.#Mn.read().then(({value:t,done:e})=>{if(e)this.#xn.resolve();else{this.#Sn??=t.lang;Object.assign(this.#Bn,t.styles);this.#$n(t.items);pump()}},this.#xn.reject)};this.#Mn=this.#On.getReader();TextLayer.#Vn.add(this);pump();return this.#xn.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*OutputScale.pixelRatio,s=t.rotation;if(s!==this.#In){e?.();this.#In=s;setLayerDimensions(this.#kn,{rotation:s})}if(i!==this.#Fn){e?.();this.#Fn=i;const t={div:null,properties:null,ctx:TextLayer.#Xn(this.#Sn)};for(const e of this.#Ln){t.properties=this.#Nn.get(e);t.div=e;this.#qn(t)}}}cancel(){const t=new AbortException("TextLayer task cancelled.");this.#Mn?.cancel(t).catch(()=>{});this.#Mn=null;this.#xn.reject(t)}get textDivs(){return this.#Ln}get textContentItemsStr(){return this.#Rn}#$n(t){if(this.#Cn)return;this.#_n.ctx??=TextLayer.#Xn(this.#Sn);const e=this.#Ln,i=this.#Rn;for(const s of t){if(e.length>1e5){warn("Ignoring additional textDivs for performance reasons.");this.#Cn=!0;return}if(void 0!==s.str){i.push(s.str);this.#Kn(s)}else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#_t;this.#_t=document.createElement("span");this.#_t.classList.add("markedContent");s.id&&this.#_t.setAttribute("id",`${s.id}`);"Artifact"===s.tag&&(this.#_t.ariaHidden=!0);t.append(this.#_t)}else"endMarkedContent"===s.type&&(this.#_t=this.#_t.parentNode)}}#Kn(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#Ln.push(e);const s=Util.transform(this.#Un,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#Bn[t.fontName];r.vertical&&(n+=Math.PI/2);let a=this.#En&&r.fontSubstitution||r.fontFamily;a=TextLayer.fontFamilyMap.get(a)||a;const o=Math.hypot(s[2],s[3]),l=o*TextLayer.#Yn(a,r,this.#Sn);let h,d;if(0===n){h=s[4];d=s[5]-l}else{h=s[4]+l*Math.sin(n);d=s[5]-l*Math.cos(n)}const c=e.style;c.left=`${(100*h/this.#Dn).toFixed(2)}%`;c.top=`${(100*d/this.#Pn).toFixed(2)}%`;c.setProperty("--font-height",`${o.toFixed(2)}px`);c.fontFamily=a;i.fontSize=o;e.setAttribute("role","presentation");e.textContent=t.str;e.dir=t.dir;this.#En&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName);0!==n&&(i.angle=n*(180/Math.PI));let u=!1;if(t.str.length>1)u=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(u=!0)}u&&(i.canvasWidth=r.vertical?t.height:t.width);this.#Nn.set(e,i);this.#_n.div=e;this.#_n.properties=i;this.#qn(this.#_n);i.hasText&&this.#_t.append(e);if(i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation");this.#_t.append(t)}}#qn(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;if(0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=n,{canvasWidth:r,fontSize:a}=i;TextLayer.#Qn(s,a*this.#Fn,t);const{width:o}=s.measureText(e.textContent);o>0&&n.setProperty("--scale-x",r*this.#Fn/o)}0!==i.angle&&n.setProperty("--rotate",`${i.angle}deg`)}static cleanup(){if(!(this.#Vn.size>0)){this.#Hn.clear();for(const{canvas:t}of this.#zn.values())t.remove();this.#zn.clear()}}static#Xn(t=null){let e=this.#zn.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement";i.lang=t;document.body.append(i);e=i.getContext("2d",{alpha:!1,willReadFrequently:!0});this.#zn.set(t,e);this.#Gn.set(e,{size:0,family:""})}return e}static#Qn(t,e,i){const s=this.#Gn.get(t);if(e!==s.size||i!==s.family){t.font=`${e}px ${i}`;s.size=e;s.family=i}}static#jn(){if(null!==this.#Wn)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);this.#Wn=t.getBoundingClientRect().height;t.remove()}static#Yn(t,e,i){const s=this.#Hn.get(t);if(s)return s;const n=this.#Xn(i);n.canvas.width=n.canvas.height=30;this.#Qn(n,30,t);const r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;if(a)l=a/(a+o);else{FeatureTest.platform.isFirefox&&warn("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)}this.#Hn.set(t,l);return l}}function getDocument(e={}){"string"==typeof e||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const i=new PDFDocumentLoadingTask,{docId:s}=i,n=e.url?function getUrlProp(e){if(e instanceof URL)return e;if("string"==typeof e){if(t){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}const i=URL.parse(e,window.location);if(i)return i}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url):null,r=e.data?function getDataProp(e){if(t&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return stringToBytes(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,a=e.httpHeaders||null,o=!0===e.withCredentials,l=e.password??null,h=e.range instanceof PDFDataRangeTransport?e.range:null,d=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:65536;let c=e.worker instanceof PDFWorker?e.worker:null;const u=e.verbosity,p="string"!=typeof e.docBaseUrl||isDataScheme(e.docBaseUrl)?null:e.docBaseUrl,g=getFactoryUrlProp(e.cMapUrl),m=!1!==e.cMapPacked,f=getFactoryUrlProp(e.iccUrl),b=getFactoryUrlProp(e.standardFontDataUrl),y=getFactoryUrlProp(e.wasmUrl),A=!0!==e.stopAtErrors,v=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,w="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!t,x="boolean"==typeof e.isImageDecoderSupported?e.isImageDecoderSupported:!t&&(FeatureTest.platform.isFirefox||!globalThis.chrome),C=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,E="boolean"==typeof e.disableFontFace?e.disableFontFace:t,T=!0===e.fontExtraProperties,S=!0===e.enableXfa,_=e.ownerDocument||globalThis.document,P=!0===e.disableRange,D=!0===e.disableStream,M=!0===e.disableAutoFetch,k=!0===e.pdfBug,I=e.CanvasFactory||(t?NodeCanvasFactory:DOMCanvasFactory),F=e.FilterFactory||(t?NodeFilterFactory:DOMFilterFactory),B=e.BinaryDataFactory||(t?NodeBinaryDataFactory:DOMBinaryDataFactory),R=!0===e.enableHWA,O=!0===e.enableWebGPU?function initGPU(){return At.init()}():Promise.resolve(!1),L=!1!==e.useWasm,N=e.pagesMapper||new PagesMapper,U="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!t&&!E,H="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:!!(B===DOMBinaryDataFactory&&g&&m&&b&&y&&isValidFetchUrl(g,document.baseURI)&&isValidFetchUrl(b,document.baseURI)&&isValidFetchUrl(y,document.baseURI));setVerbosityLevel(u);const z={canvasFactory:new I({ownerDocument:_,enableHWA:R}),filterFactory:new F({docId:s,ownerDocument:_}),binaryDataFactory:H?null:new B({cMapUrl:g,standardFontDataUrl:b,wasmUrl:y})};if(!c){c=PDFWorker.create({verbosity:u,port:GlobalWorkerOptions.workerPort});i._worker=c}const G={docId:s,apiVersion:"5.7.284",data:r,password:l,disableAutoFetch:M,rangeChunkSize:d,docBaseUrl:p,enableXfa:S,evaluatorOptions:{maxImageSize:v,disableFontFace:E,ignoreErrors:A,isOffscreenCanvasSupported:w,isImageDecoderSupported:x,canvasMaxAreaInBytes:C,fontExtraProperties:T,useSystemFonts:U,useWasm:L,useWorkerFetch:H,cMapUrl:g,cMapPacked:m,iccUrl:f,standardFontDataUrl:b,wasmUrl:y,hasGPU:!1}},W={ownerDocument:_,pdfBug:k,styleElement:null,enableHWA:R,loadingParams:{disableAutoFetch:M,enableXfa:S}};Promise.all([c.promise,O]).then(function([,e]){if(i.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");G.evaluatorOptions.hasGPU=e;const l=c.messageHandler.sendWithPromise("GetDocRequest",G,r?[r.buffer]:null);let u;if(r);else if(h)u=new PDFDataTransportStream({pdfDataRangeTransport:h,disableRange:P,disableStream:D});else{if(!n)throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");{const e=function getNetworkStream(e){return isValidFetchUrl(e)?PDFFetchStream:t?PDFNodeStream:PDFNetworkStream}(n);u=new e({url:n,httpHeaders:a,withCredentials:o,rangeChunkSize:d,disableRange:P,disableStream:D})}}return l.then(t=>{if(i.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const e=new MessageHandler(s,t,c.port),n=new WorkerTransport(e,i,u,W,z,N);i._transport=n;e.send("Ready",null)})}).catch(i._capability.reject);return i}class PDFDocumentLoadingTask{static#xs=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+PDFDocumentLoadingTask.#xs++;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0);await(this._transport?.destroy())}catch(t){this._worker?.port&&delete this._worker._pendingDestroy;throw t}this._transport=null;this._worker?.destroy();this._worker=null}async getData(){return this._transport.getData()}}class PDFDataRangeTransport{#xn=Promise.withResolvers();#Jn=null;constructor(t,e,i=!1,s=null){this.length=t;this.initialData=e;this.progressiveDone=i;this.contentDispositionFilename=s;Object.defineProperty(this,"onDataProgress",{value:()=>{!function deprecated(t){console.log("Deprecated API usage: "+t)}("`PDFDataRangeTransport.prototype.onDataProgress` - method was removed, since loading progress is now reported automatically through the `PDFDataTransportStream` class (and related code).")}})}onDataRange(t,e){this.#Jn({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#xn.promise.then(()=>{this.#Jn({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#xn.promise.then(()=>{this.#Jn({type:"progressiveDone"})})}transportReady(t){this.#Jn=t;this.#xn.resolve()}requestDataRange(t,e){unreachable("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class PDFDocumentProxy{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 shadow(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()}}class PDFPageProxy{#Zn=!1;#tr=null;constructor(t,e,i,s,n=!1){this._pageIndex=t;this._pageInfo=e;this._transport=i;this._stats=n?new StatTimer:null;this._pdfBug=n;this.commonObjs=i.commonObjs;this.objs=new PDFObjects;this._intentStates=new Map;this.destroyed=!1;this.recordedBBoxes=null;this.#tr=s;this.imageCoordinates=null}clone(t){const e=new PDFPageProxy(t,this._pageInfo,this._transport,this.#tr,this._pdfBug);e.clonedFromIndex=this.clonedFromIndex??this._pageIndex;this._transport.updatePage(e);return 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:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new PageViewport({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return shadow(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:n=p.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:d=null,printAnnotationStorage:c=null,isEditing:u=!1,recordImages:g=!1,recordOperations:m=!1,operationsFilter:f=null}){this._stats?.time("Overall");const b=this._transport.getRenderingIntent(s,n,c,u),{renderingIntent:y,cacheKey:A}=b;this.#Zn=!1;l||=this._transport.getOptionalContentConfig(y);const v=this._intentStates.getOrInsertComputed(A,makeObj);if(v.streamReaderCancelTimeout){clearTimeout(v.streamReaderCancelTimeout);v.streamReaderCancelTimeout=null}const w=!!(y&o);if(!v.displayReadyCapability){v.displayReadyCapability=Promise.withResolvers();v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(b)}const x=!(!this._pdfBug||!globalThis.StepperManager?.enabled),C=!!e&&!this.recordedBBoxes&&(m||x),E=!!e&&!this.imageCoordinates&&g,complete=t=>{v.renderTasks.delete(_);if(C){const t=_.gfx?.dependencyTracker.take();if(t){_.stepper?.setOperatorBBoxes(t,_.gfx.dependencyTracker.takeDebugMetadata());m&&(this.recordedBBoxes=t)}}E&&!t&&(this.imageCoordinates=_.gfx?.imagesTracker.take());w&&(this.#Zn=!0);this.#er();if(t){_.capability.reject(t);this._abortOperatorList({intentState:v,reason:t instanceof Error?t:new Error(t)})}else _.capability.resolve();if(this._stats){this._stats.timeEnd("Rendering");this._stats.timeEnd("Overall");globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats)}};let T=null,S=null;(C||E)&&(S=new CanvasBBoxTracker(e,v.operatorList.length));C&&(T=new CanvasDependencyTracker(S,x));const _=new InternalRenderTask({callback:complete,params:{canvas:e,canvasContext:t,dependencyTracker:T??S,imagesTracker:E?new CanvasImagesTracker(e):null,viewport:i,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA,operationsFilter:f});(v.renderTasks||=new Set).add(_);const P=_.task;Promise.all([v.displayReadyCapability.promise,l]).then(([t,e])=>{if(this.destroyed)complete();else{this._stats?.time("Rendering");if(!(e.renderingIntent&y))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:t,optionalContentConfig:e});_.operatorListChanged()}}).catch(complete);return P}getOperatorList({intent:t="display",annotationMode:e=p.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0),r=this._intentStates.getOrInsertComputed(n.cacheKey,makeObj);let a;if(!r.opListReadCapability){a=Object.create(null);a.operatorListChanged=function operatorListChanged(){if(r.operatorList.lastChunk){r.opListReadCapability.resolve(r.operatorList);r.renderTasks.delete(a)}};r.opListReadCapability=Promise.withResolvers();(r.renderTasks||=new Set).add(a);r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(n)}return r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#tr.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>XfaText.textContent(t));const e=this.streamTextContent(t),i={items:[],styles:Object.create(null),lang:null};for await(const t of e){i.lang??=t.lang;Object.assign(i.styles,t.styles);i.items.push(...t.items)}return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values()){this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0});if(!e.opListReadCapability)for(const i of e.renderTasks){t.push(i.completed);i.cancel()}}this.objs.clear();this.#Zn=!1;return Promise.all(t)}cleanup(t=!1){this.#Zn=!0;const e=this.#er();t&&e&&(this._stats&&=new StatTimer);return e}#er(){if(!this.#Zn||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;this._intentStates.clear();this.objs.clear();this.#Zn=!1;return!0}_startRenderPage(t,e){const i=this._intentStates.get(e);if(i){this._stats?.timeEnd("Page Request");i.displayReadyCapability?.resolve(t)}}_renderPageChunk(t,e){for(let i=0,s=t.length;i{a.read().then(({value:t,done:e})=>{if(e)o.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(t,o);pump()}},t=>{o.streamReader=null;if(!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#er()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}})};pump()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout){clearTimeout(t.streamReaderCancelTimeout);t.streamReaderCancelTimeout=null}if(!i){if(t.renderTasks.size>0)return;if(e instanceof RenderingCancelledException){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay);t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null;this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}t.streamReader.cancel(new AbortException(e.message)).catch(()=>{});t.streamReader=null;if(!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class PDFWorker{#xn=Promise.withResolvers();#ir=null;#tn=null;#sr=null;static#nr=0;static#rr=!1;static#ar=new WeakMap;static{if(t){this.#rr=!0;GlobalWorkerOptions.workerSrc||="./pdf.worker.mjs"}this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;const s=new URL(e,i);return i.origin===s.origin};this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:i=getVerbosityLevel()}={}){this.name=t;this.destroyed=!1;this.verbosity=i;if(e){if(PDFWorker.#ar.has(e))throw new Error("Cannot use more than one PDFWorker per port.");PDFWorker.#ar.set(e,this);this.#or(e)}else this.#lr()}get promise(){return this.#xn.promise}#hr(){this.#xn.resolve();this.#ir.send("configure",{verbosity:this.verbosity})}get port(){return this.#tn}get messageHandler(){return this.#ir}#or(t){this.#tn=t;this.#ir=new MessageHandler("main","worker",t);this.#ir.on("ready",()=>{});this.#hr()}#lr(){if(PDFWorker.#rr||PDFWorker.#dr){this.#cr();return}let{workerSrc:t}=PDFWorker;try{PDFWorker._isSameOrigin(window.location,t)||(t=PDFWorker._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new MessageHandler("main","worker",e),terminateEarly=()=>{s.abort();i.destroy();e.terminate();this.destroyed?this.#xn.reject(new Error("Worker was destroyed")):this.#cr()},s=new AbortController;e.addEventListener("error",()=>{this.#sr||terminateEarly()},{signal:s.signal});i.on("test",t=>{s.abort();if(!this.destroyed&&t){this.#ir=i;this.#tn=e;this.#sr=e;this.#hr()}else terminateEarly()});i.on("ready",t=>{s.abort();if(this.destroyed)terminateEarly();else try{sendTest()}catch{this.#cr()}});const sendTest=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};sendTest();return}catch{info("The worker has been disabled.")}this.#cr()}#cr(){if(!PDFWorker.#rr){warn("Setting up fake worker.");PDFWorker.#rr=!0}PDFWorker._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this.#xn.reject(new Error("Worker was destroyed"));return}const e=new LoopbackPort;this.#tn=e;const i="fake"+PDFWorker.#nr++,s=new MessageHandler(i+"_worker",i,e);t.setup(s,e);this.#ir=new MessageHandler(i,i+"_worker",e);this.#hr()}).catch(t=>{this.#xn.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0;this.#sr?.terminate();this.#sr=null;PDFWorker.#ar.delete(this.#tn);this.#tn=null;this.#ir?.destroy();this.#ir=null}static create(t){const e=this.#ar.get(t?.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new PDFWorker(t)}static get workerSrc(){if(GlobalWorkerOptions.workerSrc)return GlobalWorkerOptions.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#dr(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return shadow(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#dr)return this.#dr;return(await import(
+ * pdfjsVersion = 6.2.108
+ * pdfjsBuild = 0365cbde0
+ */var t={9306(t,e,i){var n=i(4901),s=i(6823),r=TypeError;t.exports=function(t){if(n(t))return t;throw new r(s(t)+" is not a function")}},3506(t,e,i){var n=i(3925),s=String,r=TypeError;t.exports=function(t){if(n(t))return t;throw new r("Can't set "+s(t)+" as a prototype")}},7080(t,e,i){var n=i(4402).has;t.exports=function(t){n(t);return t}},3463(t){var e=TypeError;t.exports=function(t){if("string"==typeof t)return t;throw new e("Argument is not a string")}},4328(t,e,i){var n=i(4995),s=new n.WeakMap,r=n.set,a=n.remove;t.exports=function(t){r(s,t,1);a(s,t);return t}},6557(t,e,i){var n=i(4995).has;t.exports=function(t){n(t);return t}},6469(t,e,i){var n=i(8227),s=i(2360),r=i(4913).f,a=n("unscopables"),o=Array.prototype;void 0===o[a]&&r(o,a,{configurable:!0,value:s(null)});t.exports=function(t){o[a][t]=!0}},679(t,e,i){var n=i(1625),s=TypeError;t.exports=function(t,e){if(n(e,t))return t;throw new s("Incorrect invocation")}},3972(t,e,i){var n=i(34),s=String,r=TypeError;t.exports=function(t){if(void 0===t||n(t))return t;throw new r(s(t)+" is not an object or undefined")}},8551(t,e,i){var n=i(34),s=String,r=TypeError;t.exports=function(t){if(n(t))return t;throw new r(s(t)+" is not an object")}},4154(t,e,i){var n=i(6955),s=TypeError;t.exports=function(t){if("Uint8Array"===n(t))return t;throw new s("Argument is not an Uint8Array")}},7811(t){t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},7394(t,e,i){var n=i(4576),s=i(6706),r=i(2195),a=n.ArrayBuffer,o=n.TypeError;t.exports=a&&s(a.prototype,"byteLength","get")||function(t){if("ArrayBuffer"!==r(t))throw new o("ArrayBuffer expected");return t.byteLength}},3238(t,e,i){var n=i(4576),s=i(7811),r=i(7394),a=n.DataView;t.exports=function(t){if(!s||0!==r(t))return!1;try{new a(t);return!1}catch(t){return!0}}},5169(t,e,i){var n=i(3238),s=TypeError;t.exports=function(t){if(n(t))throw new s("ArrayBuffer is detached");return t}},4644(t,e,i){var n,s,r,a=i(7811),o=i(3724),l=i(4576),h=i(4901),c=i(34),d=i(9297),u=i(6955),p=i(6823),g=i(6699),m=i(6840),f=i(2106),b=i(1625),y=i(2787),v=i(2967),w=i(8227),x=i(3392),A=i(1181),E=A.enforce,C=A.get,S=l.Int8Array,T=S&&S.prototype,_=l.Uint8ClampedArray,k=_&&_.prototype,D=S&&y(S),M=T&&y(T),P=Object.prototype,I=l.TypeError,O=w("toStringTag"),R=x("TYPED_ARRAY_TAG"),B="TypedArrayConstructor",L=a&&!!v&&"Opera"!==u(l.opera),N=!1,U={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},H={BigInt64Array:8,BigUint64Array:8},getTypedArrayConstructor=function(t){var e=y(t);if(c(e)){var i=C(e);return i&&d(i,B)?i[B]:getTypedArrayConstructor(e)}},isTypedArray=function(t){if(!c(t))return!1;var e=u(t);return d(U,e)||d(H,e)};for(n in U)(r=(s=l[n])&&s.prototype)?E(r)[B]=s:L=!1;for(n in H)(r=(s=l[n])&&s.prototype)&&(E(r)[B]=s);if(!L||!h(D)||D===Function.prototype){D=function TypedArray(){throw new I("Incorrect invocation")};if(L)for(n in U)l[n]&&v(l[n],D)}if(!L||!M||M===P){M=D.prototype;if(L)for(n in U)l[n]&&v(l[n].prototype,M)}L&&y(k)!==M&&v(k,M);if(o&&!d(M,O)){N=!0;f(M,O,{configurable:!0,get:function(){return c(this)?this[R]:void 0}});for(n in U)l[n]&&g(l[n].prototype,R,n)}t.exports={NATIVE_ARRAY_BUFFER_VIEWS:L,TYPED_ARRAY_TAG:N&&R,aTypedArray:function(t){if(isTypedArray(t))return t;throw new I("Target is not a typed array")},aTypedArrayConstructor:function(t){if(h(t)&&(!v||b(D,t)))return t;throw new I(p(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,e,i,n){if(o){if(i)for(var s in U){var r=l[s];if(r&&d(r.prototype,t))try{delete r.prototype[t]}catch(i){try{r.prototype[t]=e}catch(t){}}}M[t]&&!i||m(M,t,i?e:L&&T[t]||e,n)}},exportTypedArrayStaticMethod:function(t,e,i){var n,s;if(o){if(v){if(i)for(n in U)if((s=l[n])&&d(s,t))try{delete s[t]}catch(t){}if(D[t]&&!i)return;try{return m(D,t,i?e:L&&D[t]||e)}catch(t){}}for(n in U)!(s=l[n])||s[t]&&!i||m(s,t,e)}},getTypedArrayConstructor,isView:function isView(t){if(!c(t))return!1;var e=u(t);return"DataView"===e||d(U,e)||d(H,e)},isTypedArray,TypedArray:D,TypedArrayPrototype:M}},5370(t,e,i){var n=i(6198);t.exports=function(t,e,i){for(var s=0,r=arguments.length>2?i:n(e),a=new t(r);r>s;)a[s]=e[s++];return a}},9617(t,e,i){var n=i(5397),s=i(5610),r=i(6198),createMethod=function(t){return function(e,i,a){var o=n(e),l=r(o);if(0===l)return!t&&-1;var h,c=s(a,l);if(t&&i!=i){for(;l>c;)if((h=o[c++])!=h)return!0}else for(;l>c;c++)if((t||c in o)&&o[c]===i)return t||c||0;return!t&&-1}};t.exports={includes:createMethod(!0),indexOf:createMethod(!1)}},4527(t,e,i){var n=i(3724),s=i(4376),r=TypeError,a=Object.getOwnPropertyDescriptor,o=n&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}();t.exports=o?function(t,e){if(s(t)&&!a(t,"length").writable)throw new r("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e}},7680(t,e,i){var n=i(9504);t.exports=n([].slice)},2804(t){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=e+"+/",n=e+"-_",inverse=function(t){for(var e={},i=0;i<64;i++)e[t.charAt(i)]=i;return e};t.exports={i2c:i,c2i:inverse(i),i2cUrl:n,c2iUrl:inverse(n)}},6319(t,e,i){var n=i(8551),s=i(9539);t.exports=function(t,e,i,r){try{return r?e(n(i)[0],i[1]):e(i)}catch(e){s(t,"throw",e)}}},2195(t,e,i){var n=i(9504),s=n({}.toString),r=n("".slice);t.exports=function(t){return r(s(t),8,-1)}},6955(t,e,i){var n=i(2140),s=i(4901),r=i(2195),a=i(8227)("toStringTag"),o=Object,l="Arguments"===r(function(){return arguments}());t.exports=n?r:function(t){var e,i,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=o(t),a))?i:l?r(e):"Object"===(n=r(e))&&s(e.callee)?"Arguments":n}},7740(t,e,i){var n=i(9297),s=i(5031),r=i(7347),a=i(4913);t.exports=function(t,e,i){for(var o=s(e),l=a.f,h=r.f,c=0;cs?(n+.05)/(s+.05):(s+.05)/(n+.05)}const Y=new Map;function findContrastColor(t,e){const i=t[0]+256*t[1]+65536*t[2]+16777216*e[0]+4294967296*e[1]+1099511627776*e[2];let n=Y.get(i);if(n)return n;const s=new Float32Array(9),r=s.subarray(0,3),a=s.subarray(3,6);RGBToHSL(t,a);const o=s.subarray(6,9);RGBToHSL(e,o);const l=o[2]<.5,h=l?12:4.5;a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]);if(contrastRatio(a,o,r)0}#gi(){if(this.#Ve||!this.div)return;this.#Ve=new AbortController;const t=this._uiManager.combinedSignal(this.#Ve);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t});this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#gi()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){const n=new this.prototype.constructor({parent:e,id:i.getId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation;n.#Be=t.accessibilityData;n._isCopy=t.isCopy||!1;const[s,r]=n.pageDimensions,[a,o,l,h]=n.getRectInCurrentCoords(t.rect,r);n.x=a/s;n.y=o/r;n.width=l/s;n.height=h/r;return n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){this.#Ve?.abort();this.#Ve=null;this.isEmpty()||this.commit();this.parent?this.parent.remove(this):this._uiManager.removeEditor(this);this.hideCommentPopup();if(this.#Qe){clearTimeout(this.#Qe);this.#Qe=null}this.#ri();this.removeEditToolbar();if(this.#ei){for(const t of this.#ei.values())clearTimeout(t);this.#ei=null}this.parent=null;this.#ii?.destroy();this.#ii=null;this.#We?.remove();this.#We=null}get isResizable(){return!1}makeResizable(){if(this.isResizable){this.#hi();this.#ze.classList.remove("hidden")}}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[i,n,s,r]=this.getPDFRect();return[AnnotationEditor._round(i+(s-i)*t),AnnotationEditor._round(n+(r-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#c.commentPopupPositionInLayer}set commentPopupPosition(t){this.#c.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#c.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#c.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#c?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this);this.#je={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#ze.children;if(!this.#Le){this.#Le=Array.from(e);const t=this.#wi.bind(this),i=this.#xi.bind(this),n=this._uiManager._signal;for(const e of this.#Le){const s=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton");e.addEventListener("keydown",t,{signal:n});e.addEventListener("blur",i,{signal:n});e.addEventListener("focus",this.#Ai.bind(this,s),{signal:n});e.setAttribute("data-l10n-id",AnnotationEditor._l10nResizer[s])}}const i=this.#Le[0];let n=0;for(const t of e){if(t===i)break;n++}const s=(360-this.rotation+this.parentRotation)%360/90*(this.#Le.length/4);if(s!==n){if(s>>8;e[i++]=255&s}}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice();i=e.byteLength}const n=i>>2,s=i-4*n,r=new Uint32Array(e.buffer,0,n);let a=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let t=0;t>7&1)&u;i[g+1]=l^-(n>>6&1)&u;i[g+2]=l^-(n>>5&1)&u;i[g+3]=l^-(n>>4&1)&u;i[g+4]=l^-(n>>3&1)&u;i[g+5]=l^-(n>>2&1)&u;i[g+6]=l^-(n>>1&1)&u;i[g+7]=l^-(1&n)&u}if(0===d)continue;const n=el[2*n+1]){u=i;i=n;n=u;u=r;r=a;a=u}if(l[2*n+1]>l[2*s+1]){u=n;n=s;s=u;u=a;a=o;o=u}if(l[2*i+1]>l[2*n+1]){u=i;i=n;n=u;u=r;r=a;a=u}const p=(l[2*i]+e.offsetX)*e.scaleX,g=(l[2*i+1]+e.offsetY)*e.scaleY,m=(l[2*n]+e.offsetX)*e.scaleX,f=(l[2*n+1]+e.offsetY)*e.scaleY,b=(l[2*s]+e.offsetX)*e.scaleX,y=(l[2*s+1]+e.offsetY)*e.scaleY;if(g>=y)return;const v=h[4*r],w=h[4*r+1],x=h[4*r+2],A=h[4*a],E=h[4*a+1],C=h[4*a+2],S=h[4*o],T=h[4*o+1],_=h[4*o+2],k=Math.round(g),D=Math.round(y);let M,P,I,O,R,B,L,N;for(let t=k;t<=D;t++){if(t=0&&n.setAttribute("stroke-width",e||1);if(i)for(let t=0,e=this.#Da.length;t0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,d=r;n=[e,a];s.push(n);for(;;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t);[e,r,a,o,l]=t;if(h!==e){n.push(h,d,e,d===r?r:a);h=e}d=d===r?a:r}n.push(h,d)}return new HighlightOutline(s,this.#Ja,this.#Eo,this.#To)}#Io(t){const e=this.#_o;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;rt!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted){t.hide();return null}const{points:e,rect:i}=this.serializeDraw(!1);t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment});return null}}class ContourDrawOutline extends InkDrawOutline{toSVGPath(){let t=super.toSVGPath();t.endsWith("Z")||(t+="Z");return t}}class SignatureExtractor{static#Dl={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Ml(t,e,i,s){s-=e;return 0===(i-=t)?s>0?0:4:1===i?s+6:2-s}static#kl=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#Il(t,e,i,s,n,r,a){const o=this.#Ml(i,s,n,r);for(let n=0;n<8;n++){const r=(-n+o-a+16)%8;if(0!==t[(i+this.#kl[2*r])*e+(s+this.#kl[2*r+1])])return r}return-1}static#Fl(t,e,i,s,n,r,a){const o=this.#Ml(i,s,n,r);for(let n=0;n<8;n++){const r=(n+o+a+16)%8;if(0!==t[(i+this.#kl[2*r])*e+(s+this.#kl[2*r+1])])return r}return-1}static#Bl(t,e,i,s){const n=t.length,r=new Int32Array(n);for(let e=0;e{await n.ready;await n.close()}).catch(()=>{});let r=null,a=0;for await(const t of i){r||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]);r.set(t,a);a+=t.length}const o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(0!==l)throw new Error(`Invalid version: ${l}`);const h=o[2],d=o[3],c=0===o[4],u=o[5],p=o[6],g=o[7],m=[],f=(8+3*p)*Uint32Array.BYTES_PER_ELEMENT;let b;switch(g){case Int8Array.BYTES_PER_ELEMENT:b=new Int8Array(r.buffer,f);break;case Int16Array.BYTES_PER_ELEMENT:b=new Int16Array(r.buffer,f);break;case Int32Array.BYTES_PER_ELEMENT:b=new Int32Array(r.buffer,f)}a=0;for(let t=0;t=1&&0===r[n+1])){1!==s&&(a=Math.abs(s));continue}o+=1;c+=1;s>1&&(a=s)}const d=[i,t],u=c===i+1,p={isHole:u,points:d,id:o,parent:0};l.push(p);let g;for(const t of l)if(t.id===a){g=t;break}g?g.isHole?p.parent=u?g.parent:a:p.parent=u?a:g.parent:p.parent=u?a:0;const m=this.#ah(r,e,t,i,h,c,0);if(-1===m){r[n]=-o;1!==r[n]&&(a=Math.abs(r[n]));continue}let f=this.#rh[2*m],b=this.#rh[2*m+1];const y=t+f,v=i+b;h=y;c=v;let w=t,x=i;for(;;){const s=this.#oh(r,e,w,x,h,c,1);f=this.#rh[2*s];b=this.#rh[2*s+1];const l=w+f,u=x+b;d.push(u,l);const p=w*e+x;0===r[p+1]?r[p]=-o:1===r[p]&&(r[p]=o);if(l===t&&u===i&&w===y&&x===v){1!==r[n]&&(a=Math.abs(r[n]));break}h=w;c=x;w=l;x=u}}}return l}static#hh(t,e,i,n){if(i-e<=4){for(let s=e;ss.intersectsNode(t));if(0===p.length)continue;let g=!1;if(!h){h=p[0];r=h;a=0;g=!0}if(!c){c=p.at(-1);o=c;l=c.childNodes.length;g=!0}if(o.nodeType===Node.ELEMENT_NODE)if(o.classList.contains("endOfContent")){const t=o.previousSibling;if(!t)continue;o=t;l=t.nodeType===Node.TEXT_NODE?t.textContent.length:t.childNodes.length}else if(o.classList.contains("textLayer")&&o.childNodes.length===l){const t=normalizeEdgeBoundary(o,l,c);if(!t)continue;o=t.container;l=t.offset}if(r.nodeType===Node.ELEMENT_NODE){const t=normalizeEdgeBoundary(r,a,h);if(!t)continue;r=t.container;a=t.offset}if(h!==c||g||!p.includes(h))for(const t of p){const e=t.firstChild;if(!e)continue;const i=document.createRange();t===h?i.setStart(r,a):i.setStartBefore(e);if(t===c)i.setEnd(o,l);else{const e=t.lastChild;if(!e)continue;if(e.nodeType===Node.ELEMENT_NODE&&e.classList.contains("endOfContent")){const t=e.previousSibling;if(!t)continue;i.setEndAfter(t)}else i.setEndAfter(e)}i.collapsed||n.push([i,t])}else n.push([s,h])}const s=new Set(n.map(t=>t[1]));for(const t of this.#dc)s.has(t)||this.#gc(t);for(const[t,i]of n){const n=DrawLayer.#uc.get(i);if(!n)continue;let s=e.get(i);if(!s){const t=i.getBoundingClientRect();s=(e,i,n,s)=>({x:(e-t.x)/t.width,y:(i-t.y)/t.height,width:n/t.width,height:s/t.height});e.set(i,s)}const r=[];for(let{x:e,y:i,width:n,height:a}of t.getClientRects())if(0!==n&&0!==a){({x:e,y:i,width:n,height:a}=s(e,i,n,a));1===n&&1===a||r.push(`M${e} ${i} h${n} v${a} h-${n} Z`)}if(0===r.length)continue;const a=n.drawLayer;let o=n.selectionDiv,l=n.path;if(!o){const t="clip_selection_"+DrawLayer.#oc++;o=document.createElement("div");o.className="selection";o.style.clipPath=`url(#${t})`;const e=a.#st?.createSelectionStyle(a.#Et);if(e)for(const[t,i]of Object.entries(e))o.style.setProperty(t,i);const i=DrawLayer._svgFactory.create(1,1,!0);i.setAttribute("aria-hidden","true");i.setAttribute("width","100%");i.setAttribute("height","100%");const s=DrawLayer._svgFactory.createElement("clipPath");s.setAttribute("id",t);s.setAttribute("clipPathUnits","objectBoundingBox");l=DrawLayer._svgFactory.createElement("path");s.append(l);i.append(s);o.append(i);n.path=l;n.selectionDiv=o}if(!o.parentNode&&a.#_a){a.#_a.append(o);this.#hc.add(o)}l.setAttribute("d",r.join(" "))}}static get _svgFactory(){return shadow(this,"_svgFactory",new DOMSVGFactory)}static#fc(t,[e,i,n,s]){const{style:r}=t;r.top=100*i+"%";r.left=100*e+"%";r.width=100*n+"%";r.height=100*s+"%"}#bc(){const t=DrawLayer._svgFactory.create(1,1,!0);this.#_a.append(t);t.setAttribute("aria-hidden","true");return t}#yc(t,e){const i=DrawLayer._svgFactory.createElement("clipPath");t.append(i);const n=`clip_${e}`;i.setAttribute("id",n);i.setAttribute("clipPathUnits","objectBoundingBox");const s=DrawLayer._svgFactory.createElement("use");i.append(s);s.setAttribute("href",`#${e}`);s.classList.add("clip");return n}#vc(t,e){for(const[i,n]of Object.entries(e))null===n?t.removeAttribute(i):t.setAttribute(i,n)}draw(t,e=!1,i=!1){const n=DrawLayer.#_++,s=this.#bc(),r=DrawLayer._svgFactory.createElement("defs");s.append(r);const a=DrawLayer._svgFactory.createElement("path");r.append(a);const o=`path_${n}`;a.setAttribute("id",o);a.setAttribute("vector-effect","non-scaling-stroke");e&&this.#ac.set(n,a);const l=i?this.#yc(r,o):null,h=DrawLayer._svgFactory.createElement("use");s.append(h);h.setAttribute("href",`#${o}`);this.updateProperties(s,t);this.#sc.set(n,s);return{id:n,clipPathId:`url(#${l})`}}drawOutline(t,e){const i=DrawLayer.#_++,n=this.#bc(),s=DrawLayer._svgFactory.createElement("defs");n.append(s);const r=DrawLayer._svgFactory.createElement("path");s.append(r);const a=`path_${i}`;r.setAttribute("id",a);r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const t=DrawLayer._svgFactory.createElement("mask");s.append(t);o=`mask_${i}`;t.setAttribute("id",o);t.setAttribute("maskUnits","objectBoundingBox");const e=DrawLayer._svgFactory.createElement("rect");t.append(e);e.setAttribute("width","1");e.setAttribute("height","1");e.setAttribute("fill","white");const n=DrawLayer._svgFactory.createElement("use");t.append(n);n.setAttribute("href",`#${a}`);n.setAttribute("stroke","none");n.setAttribute("fill","black");n.setAttribute("fill-rule","nonzero");n.classList.add("mask")}const l=DrawLayer._svgFactory.createElement("use");n.append(l);l.setAttribute("href",`#${a}`);o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();n.append(h);l.classList.add("mainOutline");h.classList.add("secondaryOutline");this.updateProperties(n,t);this.#sc.set(i,n);return i}finalizeDraw(t,e){this.#ac.delete(t);this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:n,rootClass:s,path:r}=e,a="number"==typeof t?this.#sc.get(t):t;if(a){i&&this.#vc(a,i);n&&DrawLayer.#fc(a,n);if(s){const{classList:t}=a;for(const[e,i]of Object.entries(s))t.toggle(e,i)}if(r){const t=a.firstElementChild.firstElementChild;this.#vc(t,r)}}}updateParent(t,e){if(e===this)return;const i=this.#sc.get(t);if(i){e.#_a.append(i);this.#sc.delete(t);e.#sc.set(t,i)}}remove(t){this.#ac.delete(t);if(null!==this.#_a){this.#sc.get(t).remove();this.#sc.delete(t)}}destroy(){this.#_a=null;for(const t of this.#sc.values())t.remove();this.#sc.clear();this.#ac.clear();this.#rc?.disconnect();this.#rc=null;if(this.#Kh){const t=DrawLayer.#uc.get(this.#Kh);if(t?.drawLayer===this){DrawLayer.#gc(this.#Kh);DrawLayer.#uc.delete(this.#Kh);DrawLayer.#dc.delete(this.#Kh);if(0===DrawLayer.#dc.size){DrawLayer.#lc?.abort();DrawLayer.#lc=null;DrawLayer.#cc=!1}}this.#Kh=null}}}function percentage(t){return`${(100*t).toFixed(2)}%`}class TextLayerImages{#wc=[];#xc=new Map;#Ac=null;#Ec=0;#Zs=0;#Qs=0;static#Cc=null;constructor(t,e,i,n){this.#Ec=t;this.#wc=e;this.#Zs=i.rawDims.pageWidth;this.#Qs=i.rawDims.pageHeight;this.#Ac=n}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e[],makeMap=()=>new Map,makeObj=()=>Object.create(null),ia=Symbol("CIRCULAR_REF"),oa=Symbol("EOF");let la=Object.create(null),fa=Object.create(null),ca=Object.create(null);class Name{constructor(e){this.name=e}static get(e){return fa[e]||=new Name(e)}}class Cmd{constructor(e){this.cmd=e}static get(e){return la[e]||=new Cmd(e)}}const ha=function nonSerializableClosure(){return ha};class Dict{__nonSerializable__=ha;#a=new Map;objId=null;suppressEncryption=!1;xref;constructor(e=null){this.xref=e}assignXref(e){this.xref=e}get size(){return this.#a.size}#n(e,t,a,n){let s=this.#a.get(t);if(void 0===s&&void 0!==a){s=this.#a.get(a);void 0===s&&void 0!==n&&(s=this.#a.get(n))}return s instanceof Ref&&this.xref?e?this.xref.fetchAsync(s,this.suppressEncryption):this.xref.fetch(s,this.suppressEncryption):s}get(e,t,a){return this.#n(!1,e,t,a)}async getAsync(e,t,a){return this.#n(!0,e,t,a)}getArray(e,t,a){let n=this.#n(!1,e,t,a);if(Array.isArray(n)){n=n.slice();for(let e=0,t=n.length;e126||35===s||40===s||41===s||60===s||62===s||91===s||93===s||123===s||125===s||47===s||37===s){a55295&&(s<57344||s>65533)&&n++;a=n+1}}if(0===t.length)return e;a>7&1)&u;a[p+1]=l^-(n>>6&1)&u;a[p+2]=l^-(n>>5&1)&u;a[p+3]=l^-(n>>4&1)&u;a[p+4]=l^-(n>>3&1)&u;a[p+5]=l^-(n>>2&1)&u;a[p+6]=l^-(n>>1&1)&u;a[p+7]=l^-(1&n)&u}if(0===h)continue;const n=tthis.amax||this.bmin>this.bmax){info("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin=-100;this.bmax=100}}#A(e){return e>=6/29?e**3:108/841*(e-4/29)}#x(e,t,n,a){return n+e*(a-n)/t}#l(e,t,n,a,r){let s=e[t],i=e[t+1],o=e[t+2];if(!1!==n){s=this.#x(s,n,0,100);i=this.#x(i,n,this.amin,this.amax);o=this.#x(o,n,this.bmin,this.bmax)}i>this.amax?i=this.amax:i=0&&a+1!==s){t.push({beginChunk:n,endChunk:a+1});n=s}r+1===e.length&&t.push({beginChunk:n,endChunk:s+1});a=s}return t}onReceiveData(e){const{chunkSize:t,length:n,stream:a}=this,r=e.chunk,s=void 0===e.begin,i=s?a.progressiveDataLength:e.begin,o=i+r.byteLength,l=Math.floor(i/t),f=o>>8|c;n[a+2]=t<<16|r>>>16|c;n[a+3]=r<<8|c}for(let r=4*i,s=t+o;r>3,h=7&a,u=l^f,m=e.length;n=new Uint32Array(n.buffer);let p=0;for(let a=0;a