@agile-team/mach-report 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ReportPreview-CrVeTKu1.cjs +6 -0
- package/dist/ReportPreview-DgsOdO4y.js +559 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +531 -510
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +4 -4
- package/dist/plugin-Cl-IqCqx.cjs +1 -0
- package/dist/plugin-Dp3kKWiQ.js +92 -0
- package/dist/style.css +1 -1
- package/dist/vue/ReportPreview.d.ts +27 -3
- package/dist/vue/adapters.d.ts +3 -0
- package/dist/vue/async.d.cts +193 -64
- package/dist/vue/async.d.ts +193 -64
- package/dist/vue/controller.d.ts +24 -0
- package/dist/vue/errors.d.ts +16 -0
- package/dist/vue/index.d.cts +2 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/injection-keys.d.ts +2 -0
- package/dist/vue/plugin.d.ts +262 -2
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +41 -32
- package/package.json +1 -1
- package/dist/ReportPreview-DWLjYi_p.js +0 -527
- package/dist/ReportPreview-rBtmbu3W.cjs +0 -6
- package/dist/plugin-BIJxGHZX.cjs +0 -1
- package/dist/plugin-DrV67_VW.js +0 -89
package/dist/pdf.cjs
CHANGED
|
@@ -81,4 +81,4 @@ end
|
|
|
81
81
|
end`},sd=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"<"+t.join("")+">"},$o=function(t){return ho(t,4)},R5=function(t){if(DA(t))return $o(t);if(TA(t)){var e=Lp(t),r=Np(t);return""+$o(e)+$o(r)}var n=_s(t),i="0x"+n+" is not a valid UTF-8 or UTF-16 codepoint.";throw new Error(i)},M5=function(t){var e=0,r=function(n){e|=1<<n-1};return t.fixedPitch&&r(1),t.serif&&r(2),r(3),t.script&&r(4),t.nonsymbolic&&r(6),t.italic&&r(7),t.allCap&&r(17),t.smallCap&&r(18),t.forceBold&&r(19),e},L5=function(t){var e=t["OS/2"]?t["OS/2"].sFamilyClass:0,r=M5({fixedPitch:t.post.isFixedPitch,serif:1<=e&&e<=7,script:e===10,italic:t.head.macStyle.italic});return r},vt=(function(t){se(e,t);function e(r){var n=t.call(this)||this;return n.value=r,n}return e.prototype.asBytes=function(){for(var r=[],n="",i=!1,a=function(h){h!==void 0&&r.push(h),i=!1},o=0,s=this.value.length;o<s;o++){var u=this.value[o],f=Ve(u),l=this.value[o+1];i?f===k.Newline||f===k.CarriageReturn?a():f===k.n?a(k.Newline):f===k.r?a(k.CarriageReturn):f===k.t?a(k.Tab):f===k.b?a(k.Backspace):f===k.f?a(k.FormFeed):f===k.LeftParen?a(k.LeftParen):f===k.RightParen?a(k.RightParen):f===k.Backspace?a(k.BackSlash):f>=k.Zero&&f<=k.Seven?(n+=u,(n.length===3||!(l>="0"&&l<="7"))&&(a(parseInt(n,8)),n="")):a(f):f===k.BackSlash?i=!0:a(f)}return new Uint8Array(r)},e.prototype.decodeText=function(){var r=this.asBytes();return Vp(r)?Up(r):Hp(r)},e.prototype.decodeDate=function(){var r=this.decodeText(),n=Rp(r);if(!n)throw new Kp(r);return n},e.prototype.asString=function(){return this.value},e.prototype.clone=function(){return e.of(this.value)},e.prototype.toString=function(){return"("+this.value+")"},e.prototype.sizeInBytes=function(){return this.value.length+2},e.prototype.copyBytesInto=function(r,n){return r[n++]=k.LeftParen,n+=Jt(this.value,r,n),r[n++]=k.RightParen,this.value.length+2},e.of=function(r){return new e(r)},e.fromDate=function(r){var n=Nr(String(r.getUTCFullYear()),4,"0"),i=Nr(String(r.getUTCMonth()+1),2,"0"),a=Nr(String(r.getUTCDate()),2,"0"),o=Nr(String(r.getUTCHours()),2,"0"),s=Nr(String(r.getUTCMinutes()),2,"0"),u=Nr(String(r.getUTCSeconds()),2,"0");return new e("D:"+n+i+a+o+s+u+"Z")},e})(nr),Yc=(function(){function t(e,r,n,i){var a=this;this.allGlyphsInFontSortedById=function(){for(var o=new Array(a.font.characterSet.length),s=0,u=o.length;s<u;s++){var f=a.font.characterSet[s];o[s]=a.font.glyphForCodePoint(f)}return xA(o.sort(wA),function(l){return l.id})},this.font=e,this.scale=1e3/this.font.unitsPerEm,this.fontData=r,this.fontName=this.font.postscriptName||"Font",this.customName=n,this.fontFeatures=i,this.baseFontName="",this.glyphCache=dn.populatedBy(this.allGlyphsInFontSortedById)}return t.for=function(e,r,n,i){return Ze(this,void 0,void 0,function(){var a;return Ye(this,function(o){switch(o.label){case 0:return[4,e.create(r)];case 1:return a=o.sent(),[2,new t(a,r,n,i)]}})})},t.prototype.encodeText=function(e){for(var r=this.font.layout(e,this.fontFeatures).glyphs,n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=ho(r[i].id,4);return Ie.of(n.join(""))},t.prototype.widthOfTextAtSize=function(e,r){for(var n=this.font.layout(e,this.fontFeatures).glyphs,i=0,a=0,o=n.length;a<o;a++)i+=n[a].advanceWidth*this.scale;var s=r/1e3;return i*s},t.prototype.heightOfFontAtSize=function(e,r){r===void 0&&(r={});var n=r.descender,i=n===void 0?!0:n,a=this.font,o=a.ascent,s=a.descent,u=a.bbox,f=(o||u.maxY)*this.scale,l=(s||u.minY)*this.scale,h=f-l;return i||(h-=Math.abs(s)||0),h/1e3*e},t.prototype.sizeOfFontAtHeight=function(e){var r=this.font,n=r.ascent,i=r.descent,a=r.bbox,o=(n||a.maxY)*this.scale,s=(i||a.minY)*this.scale;return 1e3*e/(o-s)},t.prototype.embedIntoContext=function(e,r){return this.baseFontName=this.customName||e.addRandomSuffix(this.fontName),this.embedFontDict(e,r)},t.prototype.embedFontDict=function(e,r){return Ze(this,void 0,void 0,function(){var n,i,a;return Ye(this,function(o){switch(o.label){case 0:return[4,this.embedCIDFontDict(e)];case 1:return n=o.sent(),i=this.embedUnicodeCmap(e),a=e.obj({Type:"Font",Subtype:"Type0",BaseFont:this.baseFontName,Encoding:"Identity-H",DescendantFonts:[n],ToUnicode:i}),r?(e.assign(r,a),[2,r]):[2,e.register(a)]}})})},t.prototype.isCFF=function(){return this.font.cff},t.prototype.embedCIDFontDict=function(e){return Ze(this,void 0,void 0,function(){var r,n;return Ye(this,function(i){switch(i.label){case 0:return[4,this.embedFontDescriptor(e)];case 1:return r=i.sent(),n=e.obj({Type:"Font",Subtype:this.isCFF()?"CIDFontType0":"CIDFontType2",CIDToGIDMap:"Identity",BaseFont:this.baseFontName,CIDSystemInfo:{Registry:vt.of("Adobe"),Ordering:vt.of("Identity"),Supplement:0},FontDescriptor:r,W:this.computeWidths()}),[2,e.register(n)]}})})},t.prototype.embedFontDescriptor=function(e){return Ze(this,void 0,void 0,function(){var r,n,i,a,o,s,u,f,l,h,d,v,g,b,w;return Ye(this,function(x){switch(x.label){case 0:return[4,this.embedFontStream(e)];case 1:return r=x.sent(),n=this.scale,i=this.font,a=i.italicAngle,o=i.ascent,s=i.descent,u=i.capHeight,f=i.xHeight,l=this.font.bbox,h=l.minX,d=l.minY,v=l.maxX,g=l.maxY,b=e.obj((w={Type:"FontDescriptor",FontName:this.baseFontName,Flags:L5(this.font),FontBBox:[h*n,d*n,v*n,g*n],ItalicAngle:a,Ascent:o*n,Descent:s*n,CapHeight:(u||o)*n,XHeight:(f||0)*n,StemV:0},w[this.isCFF()?"FontFile3":"FontFile2"]=r,w)),[2,e.register(b)]}})})},t.prototype.serializeFont=function(){return Ze(this,void 0,void 0,function(){return Ye(this,function(e){return[2,this.fontData]})})},t.prototype.embedFontStream=function(e){return Ze(this,void 0,void 0,function(){var r,n,i;return Ye(this,function(a){switch(a.label){case 0:return i=(n=e).flateStream,[4,this.serializeFont()];case 1:return r=i.apply(n,[a.sent(),{Subtype:this.isCFF()?"CIDFontType0C":void 0}]),[2,e.register(r)]}})})},t.prototype.embedUnicodeCmap=function(e){var r=I5(this.glyphCache.access(),this.glyphId.bind(this)),n=e.flateStream(r);return e.register(n)},t.prototype.glyphId=function(e){return e?e.id:-1},t.prototype.computeWidths=function(){for(var e=this.glyphCache.access(),r=[],n=[],i=0,a=e.length;i<a;i++){var o=e[i],s=e[i-1],u=this.glyphId(o),f=this.glyphId(s);i===0?r.push(u):u-f!==1&&(r.push(n),r.push(u),n=[]),n.push(o.advanceWidth*this.scale)}return r.push(n),r},t})(),N5=(function(t){se(e,t);function e(r,n,i,a){var o=t.call(this,r,n,i,a)||this;return o.subset=o.font.createSubset(),o.glyphs=[],o.glyphCache=dn.populatedBy(function(){return o.glyphs}),o.glyphIdMap=new Map,o}return e.for=function(r,n,i,a){return Ze(this,void 0,void 0,function(){var o;return Ye(this,function(s){switch(s.label){case 0:return[4,r.create(n)];case 1:return o=s.sent(),[2,new e(o,n,i,a)]}})})},e.prototype.encodeText=function(r){for(var n=this.font.layout(r,this.fontFeatures).glyphs,i=new Array(n.length),a=0,o=n.length;a<o;a++){var s=n[a],u=this.subset.includeGlyph(s);this.glyphs[u-1]=s,this.glyphIdMap.set(s.id,u),i[a]=ho(u,4)}return this.glyphCache.invalidate(),Ie.of(i.join(""))},e.prototype.isCFF=function(){return this.subset.cff},e.prototype.glyphId=function(r){return r?this.glyphIdMap.get(r.id):-1},e.prototype.serializeFont=function(){var r=this;return new Promise(function(n,i){var a=[];r.subset.encodeStream().on("data",function(o){return a.push(o)}).on("end",function(){return n(bA(a))}).on("error",function(o){return i(o)})})},e})(Yc),Hf;(function(t){t.Source="Source",t.Data="Data",t.Alternative="Alternative",t.Supplement="Supplement",t.EncryptedPayload="EncryptedPayload",t.FormData="EncryptedPayload",t.Schema="Schema",t.Unspecified="Unspecified"})(Hf||(Hf={}));var U5=(function(){function t(e,r,n){n===void 0&&(n={}),this.fileData=e,this.fileName=r,this.options=n}return t.for=function(e,r,n){return n===void 0&&(n={}),new t(e,r,n)},t.prototype.embedIntoContext=function(e,r){return Ze(this,void 0,void 0,function(){var n,i,a,o,s,u,f,l,h;return Ye(this,function(d){return n=this.options,i=n.mimeType,a=n.description,o=n.creationDate,s=n.modificationDate,u=n.afRelationship,f=e.flateStream(this.fileData,{Type:"EmbeddedFile",Subtype:i??void 0,Params:{Size:this.fileData.length,CreationDate:o?vt.fromDate(o):void 0,ModDate:s?vt.fromDate(s):void 0}}),l=e.register(f),h=e.obj({Type:"Filespec",F:vt.of(this.fileName),UF:Ie.fromText(this.fileName),EF:{F:l},Desc:a?Ie.fromText(a):void 0,AFRelationship:u??void 0}),r?(e.assign(r,h),[2,r]):[2,e.register(h)]})})},t})(),ud=[65472,65473,65474,65475,65477,65478,65479,65480,65481,65482,65483,65484,65485,65486,65487],$i;(function(t){t.DeviceGray="DeviceGray",t.DeviceRGB="DeviceRGB",t.DeviceCMYK="DeviceCMYK"})($i||($i={}));var z5={1:$i.DeviceGray,3:$i.DeviceRGB,4:$i.DeviceCMYK},Qp=(function(){function t(e,r,n,i,a){this.imageData=e,this.bitsPerComponent=r,this.width=n,this.height=i,this.colorSpace=a}return t.for=function(e){return Ze(this,void 0,void 0,function(){var r,n,i,a,o,s,u,f,l,h;return Ye(this,function(d){if(r=new DataView(e.buffer),n=r.getUint16(0),n!==65496)throw new Error("SOI not found in JPEG");for(i=2;i<r.byteLength&&(a=r.getUint16(i),i+=2,!ud.includes(a));)i+=r.getUint16(i);if(!ud.includes(a))throw new Error("Invalid JPEG");if(i+=2,o=r.getUint8(i++),s=r.getUint16(i),i+=2,u=r.getUint16(i),i+=2,f=r.getUint8(i++),l=z5[f],!l)throw new Error("Unknown JPEG channel.");return h=l,[2,new t(e,o,u,s,h)]})})},t.prototype.embedIntoContext=function(e,r){return Ze(this,void 0,void 0,function(){var n;return Ye(this,function(i){return n=e.stream(this.imageData,{Type:"XObject",Subtype:"Image",BitsPerComponent:this.bitsPerComponent,Width:this.width,Height:this.height,ColorSpace:this.colorSpace,Filter:"DCTDecode",Decode:this.colorSpace===$i.DeviceCMYK?[1,0,1,0,1,0,1,0]:void 0}),r?(e.assign(r,n),[2,r]):[2,e.register(n)]})})},t})(),ie={};ie.toRGBA8=function(t){var e=t.width,r=t.height;if(t.tabs.acTL==null)return[ie.toRGBA8.decodeImage(t.data,e,r,t).buffer];var n=[];t.frames[0].data==null&&(t.frames[0].data=t.data);for(var i=e*r*4,a=new Uint8Array(i),o=new Uint8Array(i),s=new Uint8Array(i),u=0;u<t.frames.length;u++){var f=t.frames[u],l=f.rect.x,h=f.rect.y,d=f.rect.width,v=f.rect.height,g=ie.toRGBA8.decodeImage(f.data,d,v,t);if(u!=0)for(var b=0;b<i;b++)s[b]=a[b];if(f.blend==0?ie._copyTile(g,d,v,a,e,r,l,h,0):f.blend==1&&ie._copyTile(g,d,v,a,e,r,l,h,1),n.push(a.buffer.slice(0)),f.dispose!=0){if(f.dispose==1)ie._copyTile(o,d,v,a,e,r,l,h,0);else if(f.dispose==2)for(var b=0;b<i;b++)a[b]=s[b]}}return n};ie.toRGBA8.decodeImage=function(t,e,r,n){var i=e*r,a=ie.decode._getBPP(n),o=Math.ceil(e*a/8),s=new Uint8Array(i*4),u=new Uint32Array(s.buffer),f=n.ctype,l=n.depth,h=ie._bin.readUshort;if(f==6){var d=i<<2;if(l==8)for(var v=0;v<d;v+=4)s[v]=t[v],s[v+1]=t[v+1],s[v+2]=t[v+2],s[v+3]=t[v+3];if(l==16)for(var v=0;v<d;v++)s[v]=t[v<<1]}else if(f==2){var g=n.tabs.tRNS;if(g==null){if(l==8)for(var v=0;v<i;v++){var b=v*3;u[v]=255<<24|t[b+2]<<16|t[b+1]<<8|t[b]}if(l==16)for(var v=0;v<i;v++){var b=v*6;u[v]=255<<24|t[b+4]<<16|t[b+2]<<8|t[b]}}else{var w=g[0],x=g[1],T=g[2];if(l==8)for(var v=0;v<i;v++){var A=v<<2,b=v*3;u[v]=255<<24|t[b+2]<<16|t[b+1]<<8|t[b],t[b]==w&&t[b+1]==x&&t[b+2]==T&&(s[A+3]=0)}if(l==16)for(var v=0;v<i;v++){var A=v<<2,b=v*6;u[v]=255<<24|t[b+4]<<16|t[b+2]<<8|t[b],h(t,b)==w&&h(t,b+2)==x&&h(t,b+4)==T&&(s[A+3]=0)}}}else if(f==3){var R=n.tabs.PLTE,P=n.tabs.tRNS,I=P?P.length:0;if(l==1)for(var B=0;B<r;B++)for(var j=B*o,W=B*e,v=0;v<e;v++){var A=W+v<<2,N=t[j+(v>>3)]>>7-((v&7)<<0)&1,V=3*N;s[A]=R[V],s[A+1]=R[V+1],s[A+2]=R[V+2],s[A+3]=N<I?P[N]:255}if(l==2)for(var B=0;B<r;B++)for(var j=B*o,W=B*e,v=0;v<e;v++){var A=W+v<<2,N=t[j+(v>>2)]>>6-((v&3)<<1)&3,V=3*N;s[A]=R[V],s[A+1]=R[V+1],s[A+2]=R[V+2],s[A+3]=N<I?P[N]:255}if(l==4)for(var B=0;B<r;B++)for(var j=B*o,W=B*e,v=0;v<e;v++){var A=W+v<<2,N=t[j+(v>>1)]>>4-((v&1)<<2)&15,V=3*N;s[A]=R[V],s[A+1]=R[V+1],s[A+2]=R[V+2],s[A+3]=N<I?P[N]:255}if(l==8)for(var v=0;v<i;v++){var A=v<<2,N=t[v],V=3*N;s[A]=R[V],s[A+1]=R[V+1],s[A+2]=R[V+2],s[A+3]=N<I?P[N]:255}}else if(f==4){if(l==8)for(var v=0;v<i;v++){var A=v<<2,Z=v<<1,U=t[Z];s[A]=U,s[A+1]=U,s[A+2]=U,s[A+3]=t[Z+1]}if(l==16)for(var v=0;v<i;v++){var A=v<<2,Z=v<<2,U=t[Z];s[A]=U,s[A+1]=U,s[A+2]=U,s[A+3]=t[Z+2]}}else if(f==0)for(var w=n.tabs.tRNS?n.tabs.tRNS:-1,B=0;B<r;B++){var ee=B*o,Y=B*e;if(l==1)for(var $=0;$<e;$++){var U=255*(t[ee+($>>>3)]>>>7-($&7)&1),J=U==w*255?0:255;u[Y+$]=J<<24|U<<16|U<<8|U}else if(l==2)for(var $=0;$<e;$++){var U=85*(t[ee+($>>>2)]>>>6-(($&3)<<1)&3),J=U==w*85?0:255;u[Y+$]=J<<24|U<<16|U<<8|U}else if(l==4)for(var $=0;$<e;$++){var U=17*(t[ee+($>>>1)]>>>4-(($&1)<<2)&15),J=U==w*17?0:255;u[Y+$]=J<<24|U<<16|U<<8|U}else if(l==8)for(var $=0;$<e;$++){var U=t[ee+$],J=U==w?0:255;u[Y+$]=J<<24|U<<16|U<<8|U}else if(l==16)for(var $=0;$<e;$++){var U=t[ee+($<<1)],J=h(t,ee+($<<v))==w?0:255;u[Y+$]=J<<24|U<<16|U<<8|U}}return s};ie.decode=function(t){for(var e=new Uint8Array(t),r=8,n=ie._bin,i=n.readUshort,a=n.readUint,o={tabs:{},frames:[]},s=new Uint8Array(e.length),u=0,f,l=0,h=[137,80,78,71,13,10,26,10],d=0;d<8;d++)if(e[d]!=h[d])throw"The input is not a PNG file!";for(;r<e.length;){var v=n.readUint(e,r);r+=4;var g=n.readASCII(e,r,4);if(r+=4,g=="IHDR")ie.decode._IHDR(e,r,o);else if(g=="IDAT"){for(var d=0;d<v;d++)s[u+d]=e[r+d];u+=v}else if(g=="acTL")o.tabs[g]={num_frames:a(e,r),num_plays:a(e,r+4)},f=new Uint8Array(e.length);else if(g=="fcTL"){if(l!=0){var b=o.frames[o.frames.length-1];b.data=ie.decode._decompress(o,f.slice(0,l),b.rect.width,b.rect.height),l=0}var w={x:a(e,r+12),y:a(e,r+16),width:a(e,r+4),height:a(e,r+8)},x=i(e,r+22);x=i(e,r+20)/(x==0?100:x);var T={rect:w,delay:Math.round(x*1e3),dispose:e[r+24],blend:e[r+25]};o.frames.push(T)}else if(g=="fdAT"){for(var d=0;d<v-4;d++)f[l+d]=e[r+d+4];l+=v-4}else if(g=="pHYs")o.tabs[g]=[n.readUint(e,r),n.readUint(e,r+4),e[r+8]];else if(g=="cHRM"){o.tabs[g]=[];for(var d=0;d<8;d++)o.tabs[g].push(n.readUint(e,r+d*4))}else if(g=="tEXt"){o.tabs[g]==null&&(o.tabs[g]={});var A=n.nextZero(e,r),R=n.readASCII(e,r,A-r),P=n.readASCII(e,A+1,r+v-A-1);o.tabs[g][R]=P}else if(g=="iTXt"){o.tabs[g]==null&&(o.tabs[g]={});var A=0,I=r;A=n.nextZero(e,I);var R=n.readASCII(e,I,A-I);I=A+1,e[I],e[I+1],I+=2,A=n.nextZero(e,I),n.readASCII(e,I,A-I),I=A+1,A=n.nextZero(e,I),n.readUTF8(e,I,A-I),I=A+1;var P=n.readUTF8(e,I,v-(I-r));o.tabs[g][R]=P}else if(g=="PLTE")o.tabs[g]=n.readBytes(e,r,v);else if(g=="hIST"){var B=o.tabs.PLTE.length/3;o.tabs[g]=[];for(var d=0;d<B;d++)o.tabs[g].push(i(e,r+d*2))}else if(g=="tRNS")o.ctype==3?o.tabs[g]=n.readBytes(e,r,v):o.ctype==0?o.tabs[g]=i(e,r):o.ctype==2&&(o.tabs[g]=[i(e,r),i(e,r+2),i(e,r+4)]);else if(g=="gAMA")o.tabs[g]=n.readUint(e,r)/1e5;else if(g=="sRGB")o.tabs[g]=e[r];else if(g=="bKGD")o.ctype==0||o.ctype==4?o.tabs[g]=[i(e,r)]:o.ctype==2||o.ctype==6?o.tabs[g]=[i(e,r),i(e,r+2),i(e,r+4)]:o.ctype==3&&(o.tabs[g]=e[r]);else if(g=="IEND")break;r+=v,n.readUint(e,r),r+=4}if(l!=0){var b=o.frames[o.frames.length-1];b.data=ie.decode._decompress(o,f.slice(0,l),b.rect.width,b.rect.height),l=0}return o.data=ie.decode._decompress(o,s,o.width,o.height),delete o.compress,delete o.interlace,delete o.filter,o};ie.decode._decompress=function(t,e,r,n){var i=ie.decode._getBPP(t),a=Math.ceil(r*i/8),o=new Uint8Array((a+1+t.interlace)*n);return e=ie.decode._inflate(e,o),t.interlace==0?e=ie.decode._filterZero(e,t,0,r,n):t.interlace==1&&(e=ie.decode._readInterlace(e,t)),e};ie.decode._inflate=function(t,e){var r=ie.inflateRaw(new Uint8Array(t.buffer,2,t.length-6),e);return r};ie.inflateRaw=(function(){var t={};return t.H={},t.H.N=function(e,r){var n=Uint8Array,i=0,a=0,o=0,s=0,u=0,f=0,l=0,h=0,d=0,v,g;if(e[0]==3&&e[1]==0)return r||new n(0);var b=t.H,w=b.b,x=b.e,T=b.R,A=b.n,R=b.A,P=b.Z,I=b.m,B=r==null;for(B&&(r=new n(e.length>>>2<<3));i==0;){if(i=w(e,d,1),a=w(e,d+1,2),d+=3,a==0){(d&7)!=0&&(d+=8-(d&7));var j=(d>>>3)+4,W=e[j-4]|e[j-3]<<8;B&&(r=t.H.W(r,h+W)),r.set(new n(e.buffer,e.byteOffset+j,W),h),d=j+W<<3,h+=W;continue}if(B&&(r=t.H.W(r,h+(1<<17))),a==1&&(v=I.J,g=I.h,f=511,l=31),a==2){o=x(e,d,5)+257,s=x(e,d+5,5)+1,u=x(e,d+10,4)+4,d+=14;for(var N=1,V=0;V<38;V+=2)I.Q[V]=0,I.Q[V+1]=0;for(var V=0;V<u;V++){var Z=x(e,d+V*3,3);I.Q[(I.X[V]<<1)+1]=Z,Z>N&&(N=Z)}d+=3*u,A(I.Q,N),R(I.Q,N,I.u),v=I.w,g=I.d,d=T(I.u,(1<<N)-1,o+s,e,d,I.v);var U=b.V(I.v,0,o,I.C);f=(1<<U)-1;var ee=b.V(I.v,o,s,I.D);l=(1<<ee)-1,A(I.C,U),R(I.C,U,v),A(I.D,ee),R(I.D,ee,g)}for(;;){var Y=v[P(e,d)&f];d+=Y&15;var $=Y>>>4;if(!($>>>8))r[h++]=$;else{if($==256)break;var J=h+$-254;if($>264){var ce=I.q[$-257];J=h+(ce>>>3)+x(e,d,ce&7),d+=ce&7}var de=g[P(e,d)&l];d+=de&15;var we=de>>>4,me=I.c[we],Te=(me>>>4)+w(e,d,me&15);for(d+=me&15;h<J;)r[h]=r[h++-Te],r[h]=r[h++-Te],r[h]=r[h++-Te],r[h]=r[h++-Te];h=J}}}return r.length==h?r:r.slice(0,h)},t.H.W=function(e,r){var n=e.length;if(r<=n)return e;var i=new Uint8Array(n<<1);return i.set(e,0),i},t.H.R=function(e,r,n,i,a,o){for(var s=t.H.e,u=t.H.Z,f=0;f<n;){var l=e[u(i,a)&r];a+=l&15;var h=l>>>4;if(h<=15)o[f]=h,f++;else{var d=0,v=0;h==16?(v=3+s(i,a,2),a+=2,d=o[f-1]):h==17?(v=3+s(i,a,3),a+=3):h==18&&(v=11+s(i,a,7),a+=7);for(var g=f+v;f<g;)o[f]=d,f++}}return a},t.H.V=function(e,r,n,i){for(var a=0,o=0,s=i.length>>>1;o<n;){var u=e[o+r];i[o<<1]=0,i[(o<<1)+1]=u,u>a&&(a=u),o++}for(;o<s;)i[o<<1]=0,i[(o<<1)+1]=0,o++;return a},t.H.n=function(e,r){for(var n=t.H.m,i=e.length,a,o,s,u,f,l=n.j,u=0;u<=r;u++)l[u]=0;for(u=1;u<i;u+=2)l[e[u]]++;var h=n.K;for(a=0,l[0]=0,o=1;o<=r;o++)a=a+l[o-1]<<1,h[o]=a;for(s=0;s<i;s+=2)f=e[s+1],f!=0&&(e[s]=h[f],h[f]++)},t.H.A=function(e,r,n){for(var i=e.length,a=t.H.m,o=a.r,s=0;s<i;s+=2)if(e[s+1]!=0)for(var u=s>>1,f=e[s+1],l=u<<4|f,h=r-f,d=e[s]<<h,v=d+(1<<h);d!=v;){var g=o[d]>>>15-r;n[g]=l,d++}},t.H.l=function(e,r){for(var n=t.H.m.r,i=15-r,a=0;a<e.length;a+=2){var o=e[a]<<r-e[a+1];e[a]=n[o]>>>i}},t.H.M=function(e,r,n){n=n<<(r&7);var i=r>>>3;e[i]|=n,e[i+1]|=n>>>8},t.H.I=function(e,r,n){n=n<<(r&7);var i=r>>>3;e[i]|=n,e[i+1]|=n>>>8,e[i+2]|=n>>>16},t.H.e=function(e,r,n){return(e[r>>>3]|e[(r>>>3)+1]<<8)>>>(r&7)&(1<<n)-1},t.H.b=function(e,r,n){return(e[r>>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16)>>>(r&7)&(1<<n)-1},t.H.Z=function(e,r){return(e[r>>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16)>>>(r&7)},t.H.i=function(e,r){return(e[r>>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16|e[(r>>>3)+3]<<24)>>>(r&7)},t.H.m=(function(){var e=Uint16Array,r=Uint32Array;return{K:new e(16),j:new e(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new e(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new r(32),J:new e(512),_:[],h:new e(32),$:[],w:new e(32768),C:[],v:[],d:new e(32768),D:[],u:new e(512),Q:[],r:new e(32768),s:new r(286),Y:new r(30),a:new r(19),t:new r(15e3),k:new e(65536),g:new e(32768)}})(),(function(){for(var e=t.H.m,r=32768,n=0;n<r;n++){var i=n;i=(i&2863311530)>>>1|(i&1431655765)<<1,i=(i&3435973836)>>>2|(i&858993459)<<2,i=(i&4042322160)>>>4|(i&252645135)<<4,i=(i&4278255360)>>>8|(i&16711935)<<8,e.r[n]=(i>>>16|i<<16)>>>17}function a(o,s,u){for(;s--!=0;)o.push(0,u)}for(var n=0;n<32;n++)e.q[n]=e.S[n]<<3|e.T[n],e.c[n]=e.p[n]<<4|e.z[n];a(e._,144,8),a(e._,112,9),a(e._,24,7),a(e._,8,8),t.H.n(e._,9),t.H.A(e._,9,e.J),t.H.l(e._,9),a(e.$,32,5),t.H.n(e.$,5),t.H.A(e.$,5,e.h),t.H.l(e.$,5),a(e.Q,19,0),a(e.C,286,0),a(e.D,30,0),a(e.v,320,0)})(),t.H.N})();ie.decode._readInterlace=function(t,e){for(var r=e.width,n=e.height,i=ie.decode._getBPP(e),a=i>>3,o=Math.ceil(r*i/8),s=new Uint8Array(n*o),u=0,f=[0,0,4,0,2,0,1],l=[0,4,0,2,0,1,0],h=[8,8,8,4,4,2,2],d=[8,8,4,4,2,2,1],v=0;v<7;){for(var g=h[v],b=d[v],w=0,x=0,T=f[v];T<n;)T+=g,x++;for(var A=l[v];A<r;)A+=b,w++;var R=Math.ceil(w*i/8);ie.decode._filterZero(t,e,u,w,x);for(var P=0,I=f[v];I<n;){for(var B=l[v],j=u+P*R<<3;B<r;){if(i==1){var W=t[j>>3];W=W>>7-(j&7)&1,s[I*o+(B>>3)]|=W<<7-((B&7)<<0)}if(i==2){var W=t[j>>3];W=W>>6-(j&7)&3,s[I*o+(B>>2)]|=W<<6-((B&3)<<1)}if(i==4){var W=t[j>>3];W=W>>4-(j&7)&15,s[I*o+(B>>1)]|=W<<4-((B&1)<<2)}if(i>=8)for(var N=I*o+B*a,V=0;V<a;V++)s[N+V]=t[(j>>3)+V];j+=i,B+=b}P++,I+=g}w*x!=0&&(u+=x*(1+R)),v=v+1}return s};ie.decode._getBPP=function(t){var e=[1,null,3,1,2,null,4][t.ctype];return e*t.depth};ie.decode._filterZero=function(t,e,r,n,i){var a=ie.decode._getBPP(e),o=Math.ceil(n*a/8),s=ie.decode._paeth;a=Math.ceil(a/8);var u=0,f=1,l=t[r],h=0;if(l>1&&(t[r]=[0,0,1][l-2]),l==3)for(h=a;h<o;h++)t[h+1]=t[h+1]+(t[h+1-a]>>>1)&255;for(var d=0;d<i;d++)if(u=r+d*o,f=u+d+1,l=t[f-1],h=0,l==0)for(;h<o;h++)t[u+h]=t[f+h];else if(l==1){for(;h<a;h++)t[u+h]=t[f+h];for(;h<o;h++)t[u+h]=t[f+h]+t[u+h-a]}else if(l==2)for(;h<o;h++)t[u+h]=t[f+h]+t[u+h-o];else if(l==3){for(;h<a;h++)t[u+h]=t[f+h]+(t[u+h-o]>>>1);for(;h<o;h++)t[u+h]=t[f+h]+(t[u+h-o]+t[u+h-a]>>>1)}else{for(;h<a;h++)t[u+h]=t[f+h]+s(0,t[u+h-o],0);for(;h<o;h++)t[u+h]=t[f+h]+s(t[u+h-a],t[u+h-o],t[u+h-a-o])}return t};ie.decode._paeth=function(t,e,r){var n=t+e-r,i=n-t,a=n-e,o=n-r;return i*i<=a*a&&i*i<=o*o?t:a*a<=o*o?e:r};ie.decode._IHDR=function(t,e,r){var n=ie._bin;r.width=n.readUint(t,e),e+=4,r.height=n.readUint(t,e),e+=4,r.depth=t[e],e++,r.ctype=t[e],e++,r.compress=t[e],e++,r.filter=t[e],e++,r.interlace=t[e],e++};ie._bin={nextZero:function(t,e){for(;t[e]!=0;)e++;return e},readUshort:function(t,e){return t[e]<<8|t[e+1]},writeUshort:function(t,e,r){t[e]=r>>8&255,t[e+1]=r&255},readUint:function(t,e){return t[e]*(256*256*256)+(t[e+1]<<16|t[e+2]<<8|t[e+3])},writeUint:function(t,e,r){t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=r&255},readASCII:function(t,e,r){for(var n="",i=0;i<r;i++)n+=String.fromCharCode(t[e+i]);return n},writeASCII:function(t,e,r){for(var n=0;n<r.length;n++)t[e+n]=r.charCodeAt(n)},readBytes:function(t,e,r){for(var n=[],i=0;i<r;i++)n.push(t[e+i]);return n},pad:function(t){return t.length<2?"0"+t:t},readUTF8:function(t,e,r){for(var n="",i,a=0;a<r;a++)n+="%"+ie._bin.pad(t[e+a].toString(16));try{i=decodeURIComponent(n)}catch{return ie._bin.readASCII(t,e,r)}return i}};ie._copyTile=function(t,e,r,n,i,a,o,s,u){for(var f=Math.min(e,i),l=Math.min(r,a),h=0,d=0,v=0;v<l;v++)for(var g=0;g<f;g++)if(o>=0&&s>=0?(h=v*e+g<<2,d=(s+v)*i+o+g<<2):(h=(-s+v)*e-o+g<<2,d=v*i+g<<2),u==0)n[d]=t[h],n[d+1]=t[h+1],n[d+2]=t[h+2],n[d+3]=t[h+3];else if(u==1){var b=t[h+3]*.00392156862745098,w=t[h]*b,x=t[h+1]*b,T=t[h+2]*b,A=n[d+3]*(1/255),R=n[d]*A,P=n[d+1]*A,I=n[d+2]*A,B=1-b,j=b+A*B,W=j==0?0:1/j;n[d+3]=255*j,n[d+0]=(w+R*B)*W,n[d+1]=(x+P*B)*W,n[d+2]=(T+I*B)*W}else if(u==2){var b=t[h+3],w=t[h],x=t[h+1],T=t[h+2],A=n[d+3],R=n[d],P=n[d+1],I=n[d+2];b==A&&w==R&&x==P&&T==I?(n[d]=0,n[d+1]=0,n[d+2]=0,n[d+3]=0):(n[d]=w,n[d+1]=x,n[d+2]=T,n[d+3]=b)}else if(u==3){var b=t[h+3],w=t[h],x=t[h+1],T=t[h+2],A=n[d+3],R=n[d],P=n[d+1],I=n[d+2];if(b==A&&w==R&&x==P&&T==I)continue;if(b<220&&A>20)return!1}return!0};ie.encode=function(t,e,r,n,i,a,o){n==null&&(n=0),o==null&&(o=!1);var s=ie.encode.compress(t,e,r,n,[!1,!1,!1,0,o]);return ie.encode.compressPNG(s,-1),ie.encode._main(s,e,r,i,a)};ie.encodeLL=function(t,e,r,n,i,a,o,s){for(var u={ctype:0+(n==1?0:2)+(i==0?0:4),depth:a,frames:[]},f=(n+i)*a,l=f*e,h=0;h<t.length;h++)u.frames.push({rect:{x:0,y:0,width:e,height:r},img:new Uint8Array(t[h]),blend:0,dispose:1,bpp:Math.ceil(f/8),bpl:Math.ceil(l/8)});ie.encode.compressPNG(u,0,!0);var d=ie.encode._main(u,e,r,o,s);return d};ie.encode._main=function(t,e,r,n,i){i==null&&(i={});var a=ie.crc.crc,o=ie._bin.writeUint,s=ie._bin.writeUshort,u=ie._bin.writeASCII,f=8,l=t.frames.length>1,h=!1,d=33+(l?20:0);if(i.sRGB!=null&&(d+=13),i.pHYs!=null&&(d+=21),t.ctype==3){for(var v=t.plte.length,g=0;g<v;g++)t.plte[g]>>>24!=255&&(h=!0);d+=8+v*3+4+(h?8+v*1+4:0)}for(var b=0;b<t.frames.length;b++){var w=t.frames[b];l&&(d+=38),d+=w.cimg.length+12,b!=0&&(d+=4)}d+=12;for(var x=new Uint8Array(d),T=[137,80,78,71,13,10,26,10],g=0;g<8;g++)x[g]=T[g];if(o(x,f,13),f+=4,u(x,f,"IHDR"),f+=4,o(x,f,e),f+=4,o(x,f,r),f+=4,x[f]=t.depth,f++,x[f]=t.ctype,f++,x[f]=0,f++,x[f]=0,f++,x[f]=0,f++,o(x,f,a(x,f-17,17)),f+=4,i.sRGB!=null&&(o(x,f,1),f+=4,u(x,f,"sRGB"),f+=4,x[f]=i.sRGB,f++,o(x,f,a(x,f-5,5)),f+=4),i.pHYs!=null&&(o(x,f,9),f+=4,u(x,f,"pHYs"),f+=4,o(x,f,i.pHYs[0]),f+=4,o(x,f,i.pHYs[1]),f+=4,x[f]=i.pHYs[2],f++,o(x,f,a(x,f-13,13)),f+=4),l&&(o(x,f,8),f+=4,u(x,f,"acTL"),f+=4,o(x,f,t.frames.length),f+=4,o(x,f,i.loop!=null?i.loop:0),f+=4,o(x,f,a(x,f-12,12)),f+=4),t.ctype==3){var v=t.plte.length;o(x,f,v*3),f+=4,u(x,f,"PLTE"),f+=4;for(var g=0;g<v;g++){var A=g*3,R=t.plte[g],P=R&255,I=R>>>8&255,B=R>>>16&255;x[f+A+0]=P,x[f+A+1]=I,x[f+A+2]=B}if(f+=v*3,o(x,f,a(x,f-v*3-4,v*3+4)),f+=4,h){o(x,f,v),f+=4,u(x,f,"tRNS"),f+=4;for(var g=0;g<v;g++)x[f+g]=t.plte[g]>>>24&255;f+=v,o(x,f,a(x,f-v-4,v+4)),f+=4}}for(var j=0,b=0;b<t.frames.length;b++){var w=t.frames[b];l&&(o(x,f,26),f+=4,u(x,f,"fcTL"),f+=4,o(x,f,j++),f+=4,o(x,f,w.rect.width),f+=4,o(x,f,w.rect.height),f+=4,o(x,f,w.rect.x),f+=4,o(x,f,w.rect.y),f+=4,s(x,f,n[b]),f+=2,s(x,f,1e3),f+=2,x[f]=w.dispose,f++,x[f]=w.blend,f++,o(x,f,a(x,f-30,30)),f+=4);var W=w.cimg,v=W.length;o(x,f,v+(b==0?0:4)),f+=4;var N=f;u(x,f,b==0?"IDAT":"fdAT"),f+=4,b!=0&&(o(x,f,j++),f+=4),x.set(W,f),f+=v,o(x,f,a(x,N,f-N)),f+=4}return o(x,f,0),f+=4,u(x,f,"IEND"),f+=4,o(x,f,a(x,f-4,4)),f+=4,x.buffer};ie.encode.compressPNG=function(t,e,r){for(var n=0;n<t.frames.length;n++){var i=t.frames[n];i.rect.width;var a=i.rect.height,o=new Uint8Array(a*i.bpl+a);i.cimg=ie.encode._filterZero(i.img,a,i.bpp,i.bpl,o,e,r)}};ie.encode.compress=function(t,e,r,n,i){for(var a=i[0],o=i[1],s=i[2],u=i[3],f=i[4],l=6,h=8,d=255,v=0;v<t.length;v++)for(var g=new Uint8Array(t[v]),b=g.length,w=0;w<b;w+=4)d&=g[w+3];var x=d!=255,T=ie.encode.framize(t,e,r,a,o,s),A={},R=[],P=[];if(n!=0){for(var I=[],w=0;w<T.length;w++)I.push(T[w].img.buffer);for(var B=ie.encode.concatRGBA(I),j=ie.quantize(B,n),W=0,N=new Uint8Array(j.abuf),w=0;w<T.length;w++){var V=T[w].img,Z=V.length;P.push(new Uint8Array(j.inds.buffer,W>>2,Z>>2));for(var v=0;v<Z;v+=4)V[v]=N[W+v],V[v+1]=N[W+v+1],V[v+2]=N[W+v+2],V[v+3]=N[W+v+3];W+=Z}for(var w=0;w<j.plte.length;w++)R.push(j.plte[w].est.rgba)}else for(var v=0;v<T.length;v++){var U=T[v],ee=new Uint32Array(U.img.buffer),Y=U.rect.width,b=ee.length,$=new Uint8Array(b);P.push($);for(var w=0;w<b;w++){var J=ee[w];if(w!=0&&J==ee[w-1])$[w]=$[w-1];else if(w>Y&&J==ee[w-Y])$[w]=$[w-Y];else{var ce=A[J];if(ce==null&&(A[J]=ce=R.length,R.push(J),R.length>=300))break;$[w]=ce}}}var de=R.length;de<=256&&f==!1&&(de<=2?h=1:de<=4?h=2:de<=16?h=4:h=8,h=Math.max(h,u));for(var v=0;v<T.length;v++){var U=T[v];U.rect.x,U.rect.y;var Y=U.rect.width,we=U.rect.height,me=U.img;new Uint32Array(me.buffer);var Te=4*Y,Le=4;if(de<=256&&f==!1){Te=Math.ceil(h*Y/8);for(var Ge=new Uint8Array(Te*we),Xe=P[v],Fe=0;Fe<we;Fe++){var w=Fe*Te,Ne=Fe*Y;if(h==8)for(var le=0;le<Y;le++)Ge[w+le]=Xe[Ne+le];else if(h==4)for(var le=0;le<Y;le++)Ge[w+(le>>1)]|=Xe[Ne+le]<<4-(le&1)*4;else if(h==2)for(var le=0;le<Y;le++)Ge[w+(le>>2)]|=Xe[Ne+le]<<6-(le&3)*2;else if(h==1)for(var le=0;le<Y;le++)Ge[w+(le>>3)]|=Xe[Ne+le]<<7-(le&7)*1}me=Ge,l=3,Le=1}else if(x==!1&&T.length==1){for(var Ge=new Uint8Array(Y*we*3),De=Y*we,w=0;w<De;w++){var V=w*3,xe=w*4;Ge[V]=me[xe],Ge[V+1]=me[xe+1],Ge[V+2]=me[xe+2]}me=Ge,l=2,Le=3,Te=3*Y}U.img=me,U.bpl=Te,U.bpp=Le}return{ctype:l,depth:h,plte:R,frames:T}};ie.encode.framize=function(t,e,r,n,i,a){for(var o=[],s=0;s<t.length;s++){var u=new Uint8Array(t[s]),f=new Uint32Array(u.buffer),l,h=0,d=0,v=e,g=r,b=n?1:0;if(s!=0){for(var w=a||n||s==1||o[s-2].dispose!=0?1:2,x=0,T=1e9,A=0;A<w;A++){for(var U=new Uint8Array(t[s-1-A]),R=new Uint32Array(t[s-1-A]),P=e,I=r,B=-1,j=-1,W=0;W<r;W++)for(var N=0;N<e;N++){var V=W*e+N;f[V]!=R[V]&&(N<P&&(P=N),N>B&&(B=N),W<I&&(I=W),W>j&&(j=W))}B==-1&&(P=I=B=j=0),i&&((P&1)==1&&P--,(I&1)==1&&I--);var Z=(B-P+1)*(j-I+1);Z<T&&(T=Z,x=A,h=P,d=I,v=B-P+1,g=j-I+1)}var U=new Uint8Array(t[s-1-x]);x==1&&(o[s-1].dispose=2),l=new Uint8Array(v*g*4),ie._copyTile(U,e,r,l,v,g,-h,-d,0),b=ie._copyTile(u,e,r,l,v,g,-h,-d,3)?1:0,b==1?ie.encode._prepareDiff(u,e,r,l,{x:h,y:d,width:v,height:g}):ie._copyTile(u,e,r,l,v,g,-h,-d,0)}else l=u.slice(0);o.push({rect:{x:h,y:d,width:v,height:g},img:l,blend:b,dispose:0})}if(n)for(var s=0;s<o.length;s++){var ee=o[s];if(ee.blend!=1){var Y=ee.rect,$=o[s-1].rect,J=Math.min(Y.x,$.x),ce=Math.min(Y.y,$.y),de=Math.max(Y.x+Y.width,$.x+$.width),we=Math.max(Y.y+Y.height,$.y+$.height),me={x:J,y:ce,width:de-J,height:we-ce};o[s-1].dispose=1,s-1!=0&&ie.encode._updateFrame(t,e,r,o,s-1,me,i),ie.encode._updateFrame(t,e,r,o,s,me,i)}}var Te=0;if(t.length!=1)for(var V=0;V<o.length;V++){var ee=o[V];Te+=ee.rect.width*ee.rect.height}return o};ie.encode._updateFrame=function(t,e,r,n,i,a,o){for(var s=Uint8Array,u=Uint32Array,f=new s(t[i-1]),l=new u(t[i-1]),h=i+1<t.length?new s(t[i+1]):null,d=new s(t[i]),v=new u(d.buffer),g=e,b=r,w=-1,x=-1,T=0;T<a.height;T++)for(var A=0;A<a.width;A++){var R=a.x+A,P=a.y+T,I=P*e+R,B=v[I];B==0||n[i-1].dispose==0&&l[I]==B&&(h==null||h[I*4+3]!=0)||(R<g&&(g=R),R>w&&(w=R),P<b&&(b=P),P>x&&(x=P))}w==-1&&(g=b=w=x=0),o&&((g&1)==1&&g--,(b&1)==1&&b--),a={x:g,y:b,width:w-g+1,height:x-b+1};var j=n[i];j.rect=a,j.blend=1,j.img=new Uint8Array(a.width*a.height*4),n[i-1].dispose==0?(ie._copyTile(f,e,r,j.img,a.width,a.height,-a.x,-a.y,0),ie.encode._prepareDiff(d,e,r,j.img,a)):ie._copyTile(d,e,r,j.img,a.width,a.height,-a.x,-a.y,0)};ie.encode._prepareDiff=function(t,e,r,n,i){ie._copyTile(t,e,r,n,i.width,i.height,-i.x,-i.y,2)};ie.encode._filterZero=function(t,e,r,n,i,a,o){var s=[],u=[0,1,2,3,4];a!=-1?u=[a]:(e*n>5e5||r==1)&&(u=[0]);var f;o&&(f={level:0});for(var l=o&&UZIP!=null?UZIP:Ir,h=0;h<u.length;h++){for(var d=0;d<e;d++)ie.encode._filterLine(i,t,d,n,r,u[h]);s.push(l.deflate(i,f))}for(var v,g=1e9,h=0;h<s.length;h++)s[h].length<g&&(v=h,g=s[h].length);return s[v]};ie.encode._filterLine=function(t,e,r,n,i,a){var o=r*n,s=o+r,u=ie.decode._paeth;if(t[s]=a,s++,a==0)if(n<500)for(var f=0;f<n;f++)t[s+f]=e[o+f];else t.set(new Uint8Array(e.buffer,o,n),s);else if(a==1){for(var f=0;f<i;f++)t[s+f]=e[o+f];for(var f=i;f<n;f++)t[s+f]=e[o+f]-e[o+f-i]+256&255}else if(r==0){for(var f=0;f<i;f++)t[s+f]=e[o+f];if(a==2)for(var f=i;f<n;f++)t[s+f]=e[o+f];if(a==3)for(var f=i;f<n;f++)t[s+f]=e[o+f]-(e[o+f-i]>>1)+256&255;if(a==4)for(var f=i;f<n;f++)t[s+f]=e[o+f]-u(e[o+f-i],0,0)+256&255}else{if(a==2)for(var f=0;f<n;f++)t[s+f]=e[o+f]+256-e[o+f-n]&255;if(a==3){for(var f=0;f<i;f++)t[s+f]=e[o+f]+256-(e[o+f-n]>>1)&255;for(var f=i;f<n;f++)t[s+f]=e[o+f]+256-(e[o+f-n]+e[o+f-i]>>1)&255}if(a==4){for(var f=0;f<i;f++)t[s+f]=e[o+f]+256-u(0,e[o+f-n],0)&255;for(var f=i;f<n;f++)t[s+f]=e[o+f]+256-u(e[o+f-i],e[o+f-n],e[o+f-i-n])&255}}};ie.crc={table:(function(){for(var t=new Uint32Array(256),e=0;e<256;e++){for(var r=e,n=0;n<8;n++)r&1?r=3988292384^r>>>1:r=r>>>1;t[e]=r}return t})(),update:function(t,e,r,n){for(var i=0;i<n;i++)t=ie.crc.table[(t^e[r+i])&255]^t>>>8;return t},crc:function(t,e,r){return ie.crc.update(4294967295,t,e,r)^4294967295}};ie.quantize=function(t,e){var r=new Uint8Array(t),n=r.slice(0),i=new Uint32Array(n.buffer),a=ie.quantize.getKDtree(n,e),o=a[0],s=a[1];ie.quantize.planeDst;for(var u=r,f=i,l=u.length,h=new Uint8Array(r.length>>2),d=0;d<l;d+=4){var v=u[d]*.00392156862745098,g=u[d+1]*(1/255),b=u[d+2]*(1/255),w=u[d+3]*(1/255),x=ie.quantize.getNearest(o,v,g,b,w);h[d>>2]=x.ind,f[d>>2]=x.est.rgba}return{abuf:n.buffer,inds:h,plte:s}};ie.quantize.getKDtree=function(t,e,r){r==null&&(r=1e-4);var n=new Uint32Array(t.buffer),i={i0:0,i1:t.length,bst:null,est:null,tdst:0,left:null,right:null};i.bst=ie.quantize.stats(t,i.i0,i.i1),i.est=ie.quantize.estats(i.bst);for(var a=[i];a.length<e;){for(var o=0,s=0,u=0;u<a.length;u++)a[u].est.L>o&&(o=a[u].est.L,s=u);if(o<r)break;var f=a[s],l=ie.quantize.splitPixels(t,n,f.i0,f.i1,f.est.e,f.est.eMq255),h=f.i0>=l||f.i1<=l;if(h){f.est.L=0;continue}var d={i0:f.i0,i1:l,bst:null,est:null,tdst:0,left:null,right:null};d.bst=ie.quantize.stats(t,d.i0,d.i1),d.est=ie.quantize.estats(d.bst);var v={i0:l,i1:f.i1,bst:null,est:null,tdst:0,left:null,right:null};v.bst={R:[],m:[],N:f.bst.N-d.bst.N};for(var u=0;u<16;u++)v.bst.R[u]=f.bst.R[u]-d.bst.R[u];for(var u=0;u<4;u++)v.bst.m[u]=f.bst.m[u]-d.bst.m[u];v.est=ie.quantize.estats(v.bst),f.left=d,f.right=v,a[s]=d,a.push(v)}a.sort(function(g,b){return b.bst.N-g.bst.N});for(var u=0;u<a.length;u++)a[u].ind=u;return[i,a]};ie.quantize.getNearest=function(t,e,r,n,i){if(t.left==null)return t.tdst=ie.quantize.dist(t.est.q,e,r,n,i),t;var a=ie.quantize.planeDst(t.est,e,r,n,i),o=t.left,s=t.right;a>0&&(o=t.right,s=t.left);var u=ie.quantize.getNearest(o,e,r,n,i);if(u.tdst<=a*a)return u;var f=ie.quantize.getNearest(s,e,r,n,i);return f.tdst<u.tdst?f:u};ie.quantize.planeDst=function(t,e,r,n,i){var a=t.e;return a[0]*e+a[1]*r+a[2]*n+a[3]*i-t.eMq};ie.quantize.dist=function(t,e,r,n,i){var a=e-t[0],o=r-t[1],s=n-t[2],u=i-t[3];return a*a+o*o+s*s+u*u};ie.quantize.splitPixels=function(t,e,r,n,i,a){var o=ie.quantize.vecDot;for(n-=4;r<n;){for(;o(t,r,i)<=a;)r+=4;for(;o(t,n,i)>a;)n-=4;if(r>=n)break;var s=e[r>>2];e[r>>2]=e[n>>2],e[n>>2]=s,r+=4,n-=4}for(;o(t,r,i)>a;)r-=4;return r+4};ie.quantize.vecDot=function(t,e,r){return t[e]*r[0]+t[e+1]*r[1]+t[e+2]*r[2]+t[e+3]*r[3]};ie.quantize.stats=function(t,e,r){for(var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=[0,0,0,0],a=r-e>>2,o=e;o<r;o+=4){var s=t[o]*.00392156862745098,u=t[o+1]*(1/255),f=t[o+2]*(1/255),l=t[o+3]*(1/255);i[0]+=s,i[1]+=u,i[2]+=f,i[3]+=l,n[0]+=s*s,n[1]+=s*u,n[2]+=s*f,n[3]+=s*l,n[5]+=u*u,n[6]+=u*f,n[7]+=u*l,n[10]+=f*f,n[11]+=f*l,n[15]+=l*l}return n[4]=n[1],n[8]=n[2],n[9]=n[6],n[12]=n[3],n[13]=n[7],n[14]=n[11],{R:n,m:i,N:a}};ie.quantize.estats=function(t){var e=t.R,r=t.m,n=t.N,i=r[0],a=r[1],o=r[2],s=r[3],u=n==0?0:1/n,f=[e[0]-i*i*u,e[1]-i*a*u,e[2]-i*o*u,e[3]-i*s*u,e[4]-a*i*u,e[5]-a*a*u,e[6]-a*o*u,e[7]-a*s*u,e[8]-o*i*u,e[9]-o*a*u,e[10]-o*o*u,e[11]-o*s*u,e[12]-s*i*u,e[13]-s*a*u,e[14]-s*o*u,e[15]-s*s*u],l=f,h=ie.M4,d=[.5,.5,.5,.5],v=0,g=0;if(n!=0)for(var b=0;b<10&&(d=h.multVec(l,d),g=Math.sqrt(h.dot(d,d)),d=h.sml(1/g,d),!(Math.abs(g-v)<1e-9));b++)v=g;var w=[i*u,a*u,o*u,s*u],x=h.dot(h.sml(255,w),d);return{Cov:f,q:w,e:d,L:v,eMq255:x,eMq:h.dot(d,w),rgba:(Math.round(255*w[3])<<24|Math.round(255*w[2])<<16|Math.round(255*w[1])<<8|Math.round(255*w[0])<<0)>>>0}};ie.M4={multVec:function(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3],t[4]*e[0]+t[5]*e[1]+t[6]*e[2]+t[7]*e[3],t[8]*e[0]+t[9]*e[1]+t[10]*e[2]+t[11]*e[3],t[12]*e[0]+t[13]*e[1]+t[14]*e[2]+t[15]*e[3]]},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},sml:function(t,e){return[t*e[0],t*e[1],t*e[2],t*e[3]]}};ie.encode.concatRGBA=function(t){for(var e=0,r=0;r<t.length;r++)e+=t[r].byteLength;for(var n=new Uint8Array(e),i=0,r=0;r<t.length;r++){for(var a=new Uint8Array(t[r]),o=a.length,s=0;s<o;s+=4){var u=a[s],f=a[s+1],l=a[s+2],h=a[s+3];h==0&&(u=f=l=0),n[i+s]=u,n[i+s+1]=f,n[i+s+2]=l,n[i+s+3]=h}i+=o}return n.buffer};var j5=function(t){if(t===0)return fi.Greyscale;if(t===2)return fi.Truecolour;if(t===3)return fi.IndexedColour;if(t===4)return fi.GreyscaleWithAlpha;if(t===6)return fi.TruecolourWithAlpha;throw new Error("Unknown color type: "+t)},V5=function(t){for(var e=Math.floor(t.length/4),r=new Uint8Array(e*3),n=new Uint8Array(e*1),i=0,a=0,o=0;i<t.length;)r[a++]=t[i++],r[a++]=t[i++],r[a++]=t[i++],n[o++]=t[i++];return{rgbChannel:r,alphaChannel:n}},fi;(function(t){t.Greyscale="Greyscale",t.Truecolour="Truecolour",t.IndexedColour="IndexedColour",t.GreyscaleWithAlpha="GreyscaleWithAlpha",t.TruecolourWithAlpha="TruecolourWithAlpha"})(fi||(fi={}));var q5=(function(){function t(e){var r=ie.decode(e),n=ie.toRGBA8(r);if(n.length>1)throw new Error("Animated PNGs are not supported");var i=new Uint8Array(n[0]),a=V5(i),o=a.rgbChannel,s=a.alphaChannel;this.rgbChannel=o;var u=s.some(function(f){return f<255});u&&(this.alphaChannel=s),this.type=j5(r.ctype),this.width=r.width,this.height=r.height,this.bitsPerComponent=8}return t.load=function(e){return new t(e)},t})(),_p=(function(){function t(e){this.image=e,this.bitsPerComponent=e.bitsPerComponent,this.width=e.width,this.height=e.height,this.colorSpace="DeviceRGB"}return t.for=function(e){return Ze(this,void 0,void 0,function(){var r;return Ye(this,function(n){return r=q5.load(e),[2,new t(r)]})})},t.prototype.embedIntoContext=function(e,r){return Ze(this,void 0,void 0,function(){var n,i;return Ye(this,function(a){return n=this.embedAlphaChannel(e),i=e.flateStream(this.image.rgbChannel,{Type:"XObject",Subtype:"Image",BitsPerComponent:this.image.bitsPerComponent,Width:this.image.width,Height:this.image.height,ColorSpace:this.colorSpace,SMask:n}),r?(e.assign(r,i),[2,r]):[2,e.register(i)]})})},t.prototype.embedAlphaChannel=function(e){if(this.image.alphaChannel){var r=e.flateStream(this.image.alphaChannel,{Type:"XObject",Subtype:"Image",Height:this.image.height,Width:this.image.width,BitsPerComponent:this.image.bitsPerComponent,ColorSpace:"DeviceGray",Decode:[0,1]});return e.register(r)}},t})(),$p=(function(){function t(e,r,n){this.bytes=e,this.start=r||0,this.pos=this.start,this.end=r&&n?r+n:this.bytes.length}return Object.defineProperty(t.prototype,"length",{get:function(){return this.end-this.start},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this.length===0},enumerable:!1,configurable:!0}),t.prototype.getByte=function(){return this.pos>=this.end?-1:this.bytes[this.pos++]},t.prototype.getUint16=function(){var e=this.getByte(),r=this.getByte();return e===-1||r===-1?-1:(e<<8)+r},t.prototype.getInt32=function(){var e=this.getByte(),r=this.getByte(),n=this.getByte(),i=this.getByte();return(e<<24)+(r<<16)+(n<<8)+i},t.prototype.getBytes=function(e,r){r===void 0&&(r=!1);var n=this.bytes,i=this.pos,a=this.end;if(e){var s=i+e;s>a&&(s=a),this.pos=s;var o=n.subarray(i,s);return r?new Uint8ClampedArray(o):o}else{var o=n.subarray(i,a);return r?new Uint8ClampedArray(o):o}},t.prototype.peekByte=function(){var e=this.getByte();return this.pos--,e},t.prototype.peekBytes=function(e,r){r===void 0&&(r=!1);var n=this.getBytes(e,r);return this.pos-=n.length,n},t.prototype.skip=function(e){e||(e=1),this.pos+=e},t.prototype.reset=function(){this.pos=this.start},t.prototype.moveStart=function(){this.start=this.pos},t.prototype.makeSubStream=function(e,r){return new t(this.bytes,e,r)},t.prototype.decode=function(){return this.bytes},t})(),W5=new Uint8Array(0),go=(function(){function t(e){if(this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=W5,this.minBufferLength=512,e)for(;this.minBufferLength<e;)this.minBufferLength*=2}return Object.defineProperty(t.prototype,"isEmpty",{get:function(){for(;!this.eof&&this.bufferLength===0;)this.readBlock();return this.bufferLength===0},enumerable:!1,configurable:!0}),t.prototype.getByte=function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return-1;this.readBlock()}return this.buffer[this.pos++]},t.prototype.getUint16=function(){var e=this.getByte(),r=this.getByte();return e===-1||r===-1?-1:(e<<8)+r},t.prototype.getInt32=function(){var e=this.getByte(),r=this.getByte(),n=this.getByte(),i=this.getByte();return(e<<24)+(r<<16)+(n<<8)+i},t.prototype.getBytes=function(e,r){r===void 0&&(r=!1);var n,i=this.pos;if(e){for(this.ensureBuffer(i+e),n=i+e;!this.eof&&this.bufferLength<n;)this.readBlock();var a=this.bufferLength;n>a&&(n=a)}else{for(;!this.eof;)this.readBlock();n=this.bufferLength}this.pos=n;var o=this.buffer.subarray(i,n);return r&&!(o instanceof Uint8ClampedArray)?new Uint8ClampedArray(o):o},t.prototype.peekByte=function(){var e=this.getByte();return this.pos--,e},t.prototype.peekBytes=function(e,r){r===void 0&&(r=!1);var n=this.getBytes(e,r);return this.pos-=n.length,n},t.prototype.skip=function(e){e||(e=1),this.pos+=e},t.prototype.reset=function(){this.pos=0},t.prototype.makeSubStream=function(e,r){for(var n=e+r;this.bufferLength<=n&&!this.eof;)this.readBlock();return new $p(this.buffer,e,r)},t.prototype.decode=function(){for(;!this.eof;)this.readBlock();return this.buffer.subarray(0,this.bufferLength)},t.prototype.readBlock=function(){throw new Er(this.constructor.name,"readBlock")},t.prototype.ensureBuffer=function(e){var r=this.buffer;if(e<=r.byteLength)return r;for(var n=this.minBufferLength;n<e;)n*=2;var i=new Uint8Array(n);return i.set(r),this.buffer=i},t})(),fd=function(t){return t===32||t===9||t===13||t===10},G5=(function(t){se(e,t);function e(r,n){var i=t.call(this,n)||this;return i.stream=r,i.input=new Uint8Array(5),n&&(n=.8*n),i}return e.prototype.readBlock=function(){for(var r=126,n=122,i=-1,a=this.stream,o=a.getByte();fd(o);)o=a.getByte();if(o===i||o===r){this.eof=!0;return}var s=this.bufferLength,u,f;if(o===n){for(u=this.ensureBuffer(s+4),f=0;f<4;++f)u[s+f]=0;this.bufferLength+=4}else{var l=this.input;for(l[0]=o,f=1;f<5;++f){for(o=a.getByte();fd(o);)o=a.getByte();if(l[f]=o,o===i||o===r)break}if(u=this.ensureBuffer(s+f-1),this.bufferLength+=f-1,f<5){for(;f<5;++f)l[f]=117;this.eof=!0}var h=0;for(f=0;f<5;++f)h=h*85+(l[f]-33);for(f=3;f>=0;--f)u[s+f]=h&255,h>>=8}},e})(go),H5=(function(t){se(e,t);function e(r,n){var i=t.call(this,n)||this;return i.stream=r,i.firstDigit=-1,n&&(n=.5*n),i}return e.prototype.readBlock=function(){var r=8e3,n=this.stream.getBytes(r);if(!n.length){this.eof=!0;return}for(var i=n.length+1>>1,a=this.ensureBuffer(this.bufferLength+i),o=this.bufferLength,s=this.firstDigit,u=0,f=n.length;u<f;u++){var l=n[u],h=void 0;if(l>=48&&l<=57)h=l&15;else if(l>=65&&l<=70||l>=97&&l<=102)h=(l&15)+9;else if(l===62){this.eof=!0;break}else continue;s<0?s=h:(a[o++]=s<<4|h,s=-1)}s>=0&&this.eof&&(a[o++]=s<<4,s=-1),this.firstDigit=s,this.bufferLength=o},e})(go),cd=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),K5=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),X5=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),Z5=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],Y5=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5],J5=(function(t){se(e,t);function e(r,n){var i=t.call(this,n)||this;i.stream=r;var a=r.getByte(),o=r.getByte();if(a===-1||o===-1)throw new Error("Invalid header in flate stream: "+a+", "+o);if((a&15)!==8)throw new Error("Unknown compression method in flate stream: "+a+", "+o);if(((a<<8)+o)%31!==0)throw new Error("Bad FCHECK in flate stream: "+a+", "+o);if(o&32)throw new Error("FDICT bit set in flate stream: "+a+", "+o);return i.codeSize=0,i.codeBuf=0,i}return e.prototype.readBlock=function(){var r,n,i=this.stream,a=this.getBits(3);if(a&1&&(this.eof=!0),a>>=1,a===0){var o=void 0;if((o=i.getByte())===-1)throw new Error("Bad block header in flate stream");var s=o;if((o=i.getByte())===-1)throw new Error("Bad block header in flate stream");if(s|=o<<8,(o=i.getByte())===-1)throw new Error("Bad block header in flate stream");var u=o;if((o=i.getByte())===-1)throw new Error("Bad block header in flate stream");if(u|=o<<8,u!==(~s&65535)&&(s!==0||u!==0))throw new Error("Bad uncompressed block length in flate stream");this.codeBuf=0,this.codeSize=0;var f=this.bufferLength;r=this.ensureBuffer(f+s);var l=f+s;if(this.bufferLength=l,s===0)i.peekByte()===-1&&(this.eof=!0);else for(var h=f;h<l;++h){if((o=i.getByte())===-1){this.eof=!0;break}r[h]=o}return}var d,v;if(a===1)d=Z5,v=Y5;else if(a===2){var g=this.getBits(5)+257,b=this.getBits(5)+1,w=this.getBits(4)+4,x=new Uint8Array(cd.length),T=void 0;for(T=0;T<w;++T)x[cd[T]]=this.getBits(3);var A=this.generateHuffmanTable(x);n=0,T=0;for(var R=g+b,P=new Uint8Array(R),I=void 0,B=void 0,j=void 0;T<R;){var W=this.getCode(A);if(W===16)I=2,B=3,j=n;else if(W===17)I=3,B=3,j=n=0;else if(W===18)I=7,B=11,j=n=0;else{P[T++]=n=W;continue}for(var N=this.getBits(I)+B;N-- >0;)P[T++]=j}d=this.generateHuffmanTable(P.subarray(0,g)),v=this.generateHuffmanTable(P.subarray(g,R))}else throw new Error("Unknown block type in flate stream");r=this.buffer;for(var V=r?r.length:0,Z=this.bufferLength;;){var U=this.getCode(d);if(U<256){Z+1>=V&&(r=this.ensureBuffer(Z+1),V=r.length),r[Z++]=U;continue}if(U===256){this.bufferLength=Z;return}U-=257,U=K5[U];var ee=U>>16;ee>0&&(ee=this.getBits(ee)),n=(U&65535)+ee,U=this.getCode(v),U=X5[U],ee=U>>16,ee>0&&(ee=this.getBits(ee));var Y=(U&65535)+ee;Z+n>=V&&(r=this.ensureBuffer(Z+n),V=r.length);for(var $=0;$<n;++$,++Z)r[Z]=r[Z-Y]}},e.prototype.getBits=function(r){for(var n=this.stream,i=this.codeSize,a=this.codeBuf,o;i<r;){if((o=n.getByte())===-1)throw new Error("Bad encoding in flate stream");a|=o<<i,i+=8}return o=a&(1<<r)-1,this.codeBuf=a>>r,this.codeSize=i-=r,o},e.prototype.getCode=function(r){for(var n=this.stream,i=r[0],a=r[1],o=this.codeSize,s=this.codeBuf,u;o<a&&(u=n.getByte())!==-1;)s|=u<<o,o+=8;var f=i[s&(1<<a)-1];typeof i=="number"&&console.log("FLATE:",f);var l=f>>16,h=f&65535;if(l<1||o<l)throw new Error("Bad encoding in flate stream");return this.codeBuf=s>>l,this.codeSize=o-l,h},e.prototype.generateHuffmanTable=function(r){var n=r.length,i=0,a;for(a=0;a<n;++a)r[a]>i&&(i=r[a]);for(var o=1<<i,s=new Int32Array(o),u=1,f=0,l=2;u<=i;++u,f<<=1,l<<=1)for(var h=0;h<n;++h)if(r[h]===u){var d=0,v=f;for(a=0;a<u;++a)d=d<<1|v&1,v>>=1;for(a=d;a<o;a+=l)s[a]=u<<16|h;++f}return[s,i]},e})(go),Q5=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,n)||this;a.stream=r,a.cachedData=0,a.bitsCached=0;for(var o=4096,s={earlyChange:i,codeLength:9,nextCode:258,dictionaryValues:new Uint8Array(o),dictionaryLengths:new Uint16Array(o),dictionaryPrevCodes:new Uint16Array(o),currentSequence:new Uint8Array(o),currentSequenceLength:0},u=0;u<256;++u)s.dictionaryValues[u]=u,s.dictionaryLengths[u]=1;return a.lzwState=s,a}return e.prototype.readBlock=function(){var r=512,n=r*2,i=r,a,o,s,u=this.lzwState;if(u){var f=u.earlyChange,l=u.nextCode,h=u.dictionaryValues,d=u.dictionaryLengths,v=u.dictionaryPrevCodes,g=u.codeLength,b=u.prevCode,w=u.currentSequence,x=u.currentSequenceLength,T=0,A=this.bufferLength,R=this.ensureBuffer(this.bufferLength+n);for(a=0;a<r;a++){var P=this.readBits(g),I=x>0;if(!P||P<256)w[0]=P,x=1;else if(P>=258)if(P<l)for(x=d[P],o=x-1,s=P;o>=0;o--)w[o]=h[s],s=v[s];else w[x++]=w[0];else if(P===256){g=9,l=258,x=0;continue}else{this.eof=!0,delete this.lzwState;break}if(I&&(v[l]=b,d[l]=d[b]+1,h[l]=w[0],l++,g=l+f&l+f-1?g:Math.min(Math.log(l+f)/.6931471805599453+1,12)|0),b=P,T+=x,n<T){do n+=i;while(n<T);R=this.ensureBuffer(this.bufferLength+n)}for(o=0;o<x;o++)R[A++]=w[o]}u.nextCode=l,u.codeLength=g,u.prevCode=b,u.currentSequenceLength=x,this.bufferLength=A}},e.prototype.readBits=function(r){for(var n=this.bitsCached,i=this.cachedData;n<r;){var a=this.stream.getByte();if(a===-1)return this.eof=!0,null;i=i<<8|a,n+=8}return this.bitsCached=n-=r,this.cachedData=i,i>>>n&(1<<r)-1},e})(go),_5=(function(t){se(e,t);function e(r,n){var i=t.call(this,n)||this;return i.stream=r,i}return e.prototype.readBlock=function(){var r=this.stream.getBytes(2);if(!r||r.length<2||r[0]===128){this.eof=!0;return}var n,i=this.bufferLength,a=r[0];if(a<128){if(n=this.ensureBuffer(i+a+1),n[i++]=r[1],a>0){var o=this.stream.getBytes(a);n.set(o,i),i+=a}}else{a=257-a;var s=r[1];n=this.ensureBuffer(i+a+1);for(var u=0;u<a;u++)n[i++]=s}this.bufferLength=i},e})(go),ld=function(t,e,r){if(e===O.of("FlateDecode"))return new J5(t);if(e===O.of("LZWDecode")){var n=1;if(r instanceof Ke){var i=r.lookup(O.of("EarlyChange"));i instanceof ze&&(n=i.asNumber())}return new Q5(t,void 0,n)}if(e===O.of("ASCII85Decode"))return new G5(t);if(e===O.of("ASCIIHexDecode"))return new H5(t);if(e===O.of("RunLengthDecode"))return new _5(t);throw new s5(e.asString())},e1=function(t){var e=t.dict,r=t.contents,n=new $p(r),i=e.lookup(O.of("Filter")),a=e.lookup(O.of("DecodeParms"));if(i instanceof O)n=ld(n,i,a);else if(i instanceof ht)for(var o=0,s=i.size();o<s;o++)n=ld(n,i.lookup(o,O),a&&a.lookupMaybe(o,Ke));else if(i)throw new ws([O,ht],i);return n},$5=function(t){var e=t.MediaBox(),r=e.lookup(2,ze).asNumber()-e.lookup(0,ze).asNumber(),n=e.lookup(3,ze).asNumber()-e.lookup(1,ze).asNumber();return{left:0,bottom:0,right:r,top:n}},eC=function(t){return[1,0,0,1,-t.left,-t.bottom]},t1=(function(){function t(e,r,n){this.page=e;var i=r??$5(e);this.width=i.right-i.left,this.height=i.top-i.bottom,this.boundingBox=i,this.transformationMatrix=n??eC(i)}return t.for=function(e,r,n){return Ze(this,void 0,void 0,function(){return Ye(this,function(i){return[2,new t(e,r,n)]})})},t.prototype.embedIntoContext=function(e,r){return Ze(this,void 0,void 0,function(){var n,i,a,o,s,u,f,l,h,d;return Ye(this,function(v){if(n=this.page.normalizedEntries(),i=n.Contents,a=n.Resources,!i)throw new u5;return o=this.decodeContents(i),s=this.boundingBox,u=s.left,f=s.bottom,l=s.right,h=s.top,d=e.flateStream(o,{Type:"XObject",Subtype:"Form",FormType:1,BBox:[u,f,l,h],Matrix:this.transformationMatrix,Resources:a}),r?(e.assign(r,d),[2,r]):[2,e.register(d)]})})},t.prototype.decodeContents=function(e){for(var r=Uint8Array.of(k.Newline),n=[],i=0,a=e.size();i<a;i++){var o=e.lookup(i,vr),s=void 0;if(o instanceof to)s=e1(o).decode();else if(o instanceof ja)s=o.getUnencodedContents();else throw new f5(o);n.push(s,r)}return mA.apply(void 0,n)},t})(),jo=function(t,e){if(t!==void 0)return e[t]},Va;(function(t){t.UseNone="UseNone",t.UseOutlines="UseOutlines",t.UseThumbs="UseThumbs",t.UseOC="UseOC"})(Va||(Va={}));var qa;(function(t){t.L2R="L2R",t.R2L="R2L"})(qa||(qa={}));var Wa;(function(t){t.None="None",t.AppDefault="AppDefault"})(Wa||(Wa={}));var Ss;(function(t){t.Simplex="Simplex",t.DuplexFlipShortEdge="DuplexFlipShortEdge",t.DuplexFlipLongEdge="DuplexFlipLongEdge"})(Ss||(Ss={}));var hd=(function(){function t(e){this.dict=e}return t.prototype.lookupBool=function(e){var r=this.dict.lookup(O.of(e));if(r instanceof eo)return r},t.prototype.lookupName=function(e){var r=this.dict.lookup(O.of(e));if(r instanceof O)return r},t.prototype.HideToolbar=function(){return this.lookupBool("HideToolbar")},t.prototype.HideMenubar=function(){return this.lookupBool("HideMenubar")},t.prototype.HideWindowUI=function(){return this.lookupBool("HideWindowUI")},t.prototype.FitWindow=function(){return this.lookupBool("FitWindow")},t.prototype.CenterWindow=function(){return this.lookupBool("CenterWindow")},t.prototype.DisplayDocTitle=function(){return this.lookupBool("DisplayDocTitle")},t.prototype.NonFullScreenPageMode=function(){return this.lookupName("NonFullScreenPageMode")},t.prototype.Direction=function(){return this.lookupName("Direction")},t.prototype.PrintScaling=function(){return this.lookupName("PrintScaling")},t.prototype.Duplex=function(){return this.lookupName("Duplex")},t.prototype.PickTrayByPDFSize=function(){return this.lookupBool("PickTrayByPDFSize")},t.prototype.PrintPageRange=function(){var e=this.dict.lookup(O.of("PrintPageRange"));if(e instanceof ht)return e},t.prototype.NumCopies=function(){var e=this.dict.lookup(O.of("NumCopies"));if(e instanceof ze)return e},t.prototype.getHideToolbar=function(){var e,r;return(r=(e=this.HideToolbar())===null||e===void 0?void 0:e.asBoolean())!==null&&r!==void 0?r:!1},t.prototype.getHideMenubar=function(){var e,r;return(r=(e=this.HideMenubar())===null||e===void 0?void 0:e.asBoolean())!==null&&r!==void 0?r:!1},t.prototype.getHideWindowUI=function(){var e,r;return(r=(e=this.HideWindowUI())===null||e===void 0?void 0:e.asBoolean())!==null&&r!==void 0?r:!1},t.prototype.getFitWindow=function(){var e,r;return(r=(e=this.FitWindow())===null||e===void 0?void 0:e.asBoolean())!==null&&r!==void 0?r:!1},t.prototype.getCenterWindow=function(){var e,r;return(r=(e=this.CenterWindow())===null||e===void 0?void 0:e.asBoolean())!==null&&r!==void 0?r:!1},t.prototype.getDisplayDocTitle=function(){var e,r;return(r=(e=this.DisplayDocTitle())===null||e===void 0?void 0:e.asBoolean())!==null&&r!==void 0?r:!1},t.prototype.getNonFullScreenPageMode=function(){var e,r,n=(e=this.NonFullScreenPageMode())===null||e===void 0?void 0:e.decodeText();return(r=jo(n,Va))!==null&&r!==void 0?r:Va.UseNone},t.prototype.getReadingDirection=function(){var e,r,n=(e=this.Direction())===null||e===void 0?void 0:e.decodeText();return(r=jo(n,qa))!==null&&r!==void 0?r:qa.L2R},t.prototype.getPrintScaling=function(){var e,r,n=(e=this.PrintScaling())===null||e===void 0?void 0:e.decodeText();return(r=jo(n,Wa))!==null&&r!==void 0?r:Wa.AppDefault},t.prototype.getDuplex=function(){var e,r=(e=this.Duplex())===null||e===void 0?void 0:e.decodeText();return jo(r,Ss)},t.prototype.getPickTrayByPDFSize=function(){var e;return(e=this.PickTrayByPDFSize())===null||e===void 0?void 0:e.asBoolean()},t.prototype.getPrintPageRange=function(){var e=this.PrintPageRange();if(!e)return[];for(var r=[],n=0;n<e.size();n+=2){var i=e.lookup(n,ze).asNumber(),a=e.lookup(n+1,ze).asNumber();r.push({start:i,end:a})}return r},t.prototype.getNumCopies=function(){var e,r;return(r=(e=this.NumCopies())===null||e===void 0?void 0:e.asNumber())!==null&&r!==void 0?r:1},t.prototype.setHideToolbar=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("HideToolbar"),r)},t.prototype.setHideMenubar=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("HideMenubar"),r)},t.prototype.setHideWindowUI=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("HideWindowUI"),r)},t.prototype.setFitWindow=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("FitWindow"),r)},t.prototype.setCenterWindow=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("CenterWindow"),r)},t.prototype.setDisplayDocTitle=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("DisplayDocTitle"),r)},t.prototype.setNonFullScreenPageMode=function(e){Bn(e,"nonFullScreenPageMode",Va);var r=O.of(e);this.dict.set(O.of("NonFullScreenPageMode"),r)},t.prototype.setReadingDirection=function(e){Bn(e,"readingDirection",qa);var r=O.of(e);this.dict.set(O.of("Direction"),r)},t.prototype.setPrintScaling=function(e){Bn(e,"printScaling",Wa);var r=O.of(e);this.dict.set(O.of("PrintScaling"),r)},t.prototype.setDuplex=function(e){Bn(e,"duplex",Ss);var r=O.of(e);this.dict.set(O.of("Duplex"),r)},t.prototype.setPickTrayByPDFSize=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("PickTrayByPDFSize"),r)},t.prototype.setPrintPageRange=function(e){Array.isArray(e)||(e=[e]);for(var r=[],n=0,i=e.length;n<i;n++)r.push(e[n].start),r.push(e[n].end);Wp(r,"printPageRange",["number"]);var a=this.dict.context.obj(r);this.dict.set(O.of("PrintPageRange"),a)},t.prototype.setNumCopies=function(e){lr(e,"numCopies",1,Number.MAX_VALUE),o5(e,"numCopies");var r=this.dict.context.obj(e);this.dict.set(O.of("NumCopies"),r)},t.fromDict=function(e){return new t(e)},t.create=function(e){var r=e.obj({});return new t(r)},t})(),tC=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+Tf/,r1=(function(){function t(e,r){this.dict=e,this.ref=r}return t.prototype.T=function(){return this.dict.lookupMaybe(O.of("T"),vt,Ie)},t.prototype.Ff=function(){var e=this.getInheritableAttribute(O.of("Ff"));return this.dict.context.lookupMaybe(e,ze)},t.prototype.V=function(){var e=this.getInheritableAttribute(O.of("V"));return this.dict.context.lookup(e)},t.prototype.Kids=function(){return this.dict.lookupMaybe(O.of("Kids"),ht)},t.prototype.DA=function(){var e=this.dict.lookup(O.of("DA"));if(e instanceof vt||e instanceof Ie)return e},t.prototype.setKids=function(e){this.dict.set(O.of("Kids"),this.dict.context.obj(e))},t.prototype.getParent=function(){var e=this.dict.get(O.of("Parent"));if(e instanceof pt){var r=this.dict.lookup(O.of("Parent"),Ke);return new t(r,e)}},t.prototype.setParent=function(e){e?this.dict.set(O.of("Parent"),e):this.dict.delete(O.of("Parent"))},t.prototype.getFullyQualifiedName=function(){var e=this.getParent();return e?e.getFullyQualifiedName()+"."+this.getPartialName():this.getPartialName()},t.prototype.getPartialName=function(){var e;return(e=this.T())===null||e===void 0?void 0:e.decodeText()},t.prototype.setPartialName=function(e){e?this.dict.set(O.of("T"),Ie.fromText(e)):this.dict.delete(O.of("T"))},t.prototype.setDefaultAppearance=function(e){this.dict.set(O.of("DA"),vt.of(e))},t.prototype.getDefaultAppearance=function(){var e=this.DA();return e instanceof Ie?e.decodeText():e?.asString()},t.prototype.setFontSize=function(e){var r,n=(r=this.getFullyQualifiedName())!==null&&r!==void 0?r:"",i=this.getDefaultAppearance();if(!i)throw new d5(n);var a=qc(i,tC);if(!a.match)throw new v5(n);var o=i.slice(0,a.pos-a.match[0].length),s=a.pos<=i.length?i.slice(a.pos):"",u=a.match[1],f=o+" /"+u+" "+e+" Tf "+s;this.setDefaultAppearance(f)},t.prototype.getFlags=function(){var e,r;return(r=(e=this.Ff())===null||e===void 0?void 0:e.asNumber())!==null&&r!==void 0?r:0},t.prototype.setFlags=function(e){this.dict.set(O.of("Ff"),ze.of(e))},t.prototype.hasFlag=function(e){var r=this.getFlags();return(r&e)!==0},t.prototype.setFlag=function(e){var r=this.getFlags();this.setFlags(r|e)},t.prototype.clearFlag=function(e){var r=this.getFlags();this.setFlags(r&~e)},t.prototype.setFlagTo=function(e,r){r?this.setFlag(e):this.clearFlag(e)},t.prototype.getInheritableAttribute=function(e){var r;return this.ascend(function(n){r||(r=n.dict.get(e))}),r},t.prototype.ascend=function(e){e(this);var r=this.getParent();r&&r.ascend(e)},t})(),gf=(function(){function t(e){this.dict=e}return t.prototype.W=function(){var e=this.dict.lookup(O.of("W"));if(e instanceof ze)return e},t.prototype.getWidth=function(){var e,r;return(r=(e=this.W())===null||e===void 0?void 0:e.asNumber())!==null&&r!==void 0?r:1},t.prototype.setWidth=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("W"),r)},t.fromDict=function(e){return new t(e)},t})(),rC=(function(){function t(e){this.dict=e}return t.prototype.Rect=function(){return this.dict.lookup(O.of("Rect"),ht)},t.prototype.AP=function(){return this.dict.lookupMaybe(O.of("AP"),Ke)},t.prototype.F=function(){var e=this.dict.lookup(O.of("F"));return this.dict.context.lookupMaybe(e,ze)},t.prototype.getRectangle=function(){var e,r=this.Rect();return(e=r?.asRectangle())!==null&&e!==void 0?e:{x:0,y:0,width:0,height:0}},t.prototype.setRectangle=function(e){var r=e.x,n=e.y,i=e.width,a=e.height,o=this.dict.context.obj([r,n,r+i,n+a]);this.dict.set(O.of("Rect"),o)},t.prototype.getAppearanceState=function(){var e=this.dict.lookup(O.of("AS"));if(e instanceof O)return e},t.prototype.setAppearanceState=function(e){this.dict.set(O.of("AS"),e)},t.prototype.setAppearances=function(e){this.dict.set(O.of("AP"),e)},t.prototype.ensureAP=function(){var e=this.AP();return e||(e=this.dict.context.obj({}),this.dict.set(O.of("AP"),e)),e},t.prototype.getNormalAppearance=function(){var e=this.ensureAP(),r=e.get(O.of("N"));if(r instanceof pt||r instanceof Ke)return r;throw new Error("Unexpected N type: "+r?.constructor.name)},t.prototype.setNormalAppearance=function(e){var r=this.ensureAP();r.set(O.of("N"),e)},t.prototype.setRolloverAppearance=function(e){var r=this.ensureAP();r.set(O.of("R"),e)},t.prototype.setDownAppearance=function(e){var r=this.ensureAP();r.set(O.of("D"),e)},t.prototype.removeRolloverAppearance=function(){var e=this.AP();e?.delete(O.of("R"))},t.prototype.removeDownAppearance=function(){var e=this.AP();e?.delete(O.of("D"))},t.prototype.getAppearances=function(){var e=this.AP();if(e){var r=e.lookup(O.of("N"),Ke,vr),n=e.lookupMaybe(O.of("R"),Ke,vr),i=e.lookupMaybe(O.of("D"),Ke,vr);return{normal:r,rollover:n,down:i}}},t.prototype.getFlags=function(){var e,r;return(r=(e=this.F())===null||e===void 0?void 0:e.asNumber())!==null&&r!==void 0?r:0},t.prototype.setFlags=function(e){this.dict.set(O.of("F"),ze.of(e))},t.prototype.hasFlag=function(e){var r=this.getFlags();return(r&e)!==0},t.prototype.setFlag=function(e){var r=this.getFlags();this.setFlags(r|e)},t.prototype.clearFlag=function(e){var r=this.getFlags();this.setFlags(r&~e)},t.prototype.setFlagTo=function(e,r){r?this.setFlag(e):this.clearFlag(e)},t.fromDict=function(e){return new t(e)},t})(),yf=(function(){function t(e){this.dict=e}return t.prototype.R=function(){var e=this.dict.lookup(O.of("R"));if(e instanceof ze)return e},t.prototype.BC=function(){var e=this.dict.lookup(O.of("BC"));if(e instanceof ht)return e},t.prototype.BG=function(){var e=this.dict.lookup(O.of("BG"));if(e instanceof ht)return e},t.prototype.CA=function(){var e=this.dict.lookup(O.of("CA"));if(e instanceof Ie||e instanceof vt)return e},t.prototype.RC=function(){var e=this.dict.lookup(O.of("RC"));if(e instanceof Ie||e instanceof vt)return e},t.prototype.AC=function(){var e=this.dict.lookup(O.of("AC"));if(e instanceof Ie||e instanceof vt)return e},t.prototype.getRotation=function(){var e;return(e=this.R())===null||e===void 0?void 0:e.asNumber()},t.prototype.getBorderColor=function(){var e=this.BC();if(e){for(var r=[],n=0,i=e?.size();n<i;n++){var a=e.get(n);a instanceof ze&&r.push(a.asNumber())}return r}},t.prototype.getBackgroundColor=function(){var e=this.BG();if(e){for(var r=[],n=0,i=e?.size();n<i;n++){var a=e.get(n);a instanceof ze&&r.push(a.asNumber())}return r}},t.prototype.getCaptions=function(){var e=this.CA(),r=this.RC(),n=this.AC();return{normal:e?.decodeText(),rollover:r?.decodeText(),down:n?.decodeText()}},t.prototype.setRotation=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("R"),r)},t.prototype.setBorderColor=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("BC"),r)},t.prototype.setBackgroundColor=function(e){var r=this.dict.context.obj(e);this.dict.set(O.of("BG"),r)},t.prototype.setCaptions=function(e){var r=Ie.fromText(e.normal);if(this.dict.set(O.of("CA"),r),e.rollover){var n=Ie.fromText(e.rollover);this.dict.set(O.of("RC"),n)}else this.dict.delete(O.of("RC"));if(e.down){var i=Ie.fromText(e.down);this.dict.set(O.of("AC"),i)}else this.dict.delete(O.of("AC"))},t.fromDict=function(e){return new t(e)},t})(),Kf=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.MK=function(){var r=this.dict.lookup(O.of("MK"));if(r instanceof Ke)return r},e.prototype.BS=function(){var r=this.dict.lookup(O.of("BS"));if(r instanceof Ke)return r},e.prototype.DA=function(){var r=this.dict.lookup(O.of("DA"));if(r instanceof vt||r instanceof Ie)return r},e.prototype.P=function(){var r=this.dict.get(O.of("P"));if(r instanceof pt)return r},e.prototype.setP=function(r){this.dict.set(O.of("P"),r)},e.prototype.setDefaultAppearance=function(r){this.dict.set(O.of("DA"),vt.of(r))},e.prototype.getDefaultAppearance=function(){var r=this.DA();return r instanceof Ie?r.decodeText():r?.asString()},e.prototype.getAppearanceCharacteristics=function(){var r=this.MK();if(r)return yf.fromDict(r)},e.prototype.getOrCreateAppearanceCharacteristics=function(){var r=this.MK();if(r)return yf.fromDict(r);var n=yf.fromDict(this.dict.context.obj({}));return this.dict.set(O.of("MK"),n.dict),n},e.prototype.getBorderStyle=function(){var r=this.BS();if(r)return gf.fromDict(r)},e.prototype.getOrCreateBorderStyle=function(){var r=this.BS();if(r)return gf.fromDict(r);var n=gf.fromDict(this.dict.context.obj({}));return this.dict.set(O.of("BS"),n.dict),n},e.prototype.getOnValue=function(){var r,n=(r=this.getAppearances())===null||r===void 0?void 0:r.normal;if(n instanceof Ke)for(var i=n.keys(),a=0,o=i.length;a<o;a++){var s=i[a];if(s!==O.of("Off"))return s}},e.fromDict=function(r){return new e(r)},e.create=function(r,n){var i=r.obj({Type:"Annot",Subtype:"Widget",Rect:[0,0,0,0],Parent:n});return new e(i)},e})(rC),la=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.FT=function(){var r=this.getInheritableAttribute(O.of("FT"));return this.dict.context.lookup(r,O)},e.prototype.getWidgets=function(){var r=this.Kids();if(!r)return[Kf.fromDict(this.dict)];for(var n=new Array(r.size()),i=0,a=r.size();i<a;i++){var o=r.lookup(i,Ke);n[i]=Kf.fromDict(o)}return n},e.prototype.addWidget=function(r){var n=this.normalizedEntries().Kids;n.push(r)},e.prototype.removeWidget=function(r){var n=this.Kids();if(n){if(r<0||r>n.size())throw new xs(r,0,n.size());n.remove(r)}else{if(r!==0)throw new xs(r,0,0);this.setKids([])}},e.prototype.normalizedEntries=function(){var r=this.Kids();return r||(r=this.dict.context.obj([this.ref]),this.dict.set(O.of("Kids"),r)),{Kids:r}},e.fromDict=function(r,n){return new e(r,n)},e})(r1),Jc=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.Opt=function(){return this.dict.lookupMaybe(O.of("Opt"),vt,Ie,ht)},e.prototype.setOpt=function(r){this.dict.set(O.of("Opt"),this.dict.context.obj(r))},e.prototype.getExportValues=function(){var r=this.Opt();if(r){if(r instanceof vt||r instanceof Ie)return[r];for(var n=[],i=0,a=r.size();i<a;i++){var o=r.lookup(i);(o instanceof vt||o instanceof Ie)&&n.push(o)}return n}},e.prototype.removeExportValue=function(r){var n=this.Opt();if(n)if(n instanceof vt||n instanceof Ie){if(r!==0)throw new xs(r,0,0);this.setOpt([])}else{if(r<0||r>n.size())throw new xs(r,0,n.size());n.remove(r)}},e.prototype.normalizeExportValues=function(){for(var r,n,i,a,o=(r=this.getExportValues())!==null&&r!==void 0?r:[],s=[],u=this.getWidgets(),f=0,l=u.length;f<l;f++){var h=u[f],d=(n=o[f])!==null&&n!==void 0?n:Ie.fromText((a=(i=h.getOnValue())===null||i===void 0?void 0:i.decodeText())!==null&&a!==void 0?a:"");s.push(d)}this.setOpt(s)},e.prototype.addOpt=function(r,n){var i;this.normalizeExportValues();var a=r.decodeText(),o;if(n)for(var s=(i=this.getExportValues())!==null&&i!==void 0?i:[],u=0,f=s.length;u<f;u++){var l=s[u];l.decodeText()===a&&(o=u)}var h=this.Opt();return h.push(r),o??h.size()-1},e.prototype.addWidgetWithOpt=function(r,n,i){var a=this.addOpt(n,i),o=O.of(String(a));return this.addWidget(r),o},e})(la),ru=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.setValue=function(r){var n,i=(n=this.getOnValue())!==null&&n!==void 0?n:O.of("Yes");if(r!==i&&r!==O.of("Off"))throw new Hc;this.dict.set(O.of("V"),r);for(var a=this.getWidgets(),o=0,s=a.length;o<s;o++){var u=a[o],f=u.getOnValue()===r?r:O.of("Off");u.setAppearanceState(f)}},e.prototype.getValue=function(){var r=this.V();return r instanceof O?r:O.of("Off")},e.prototype.getOnValue=function(){var r=this.getWidgets()[0];return r?.getOnValue()},e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Btn",Kids:[]}),i=r.register(n);return new e(n,i)},e})(Jc),Ut=function(t){return 1<<t},Lr;(function(t){t[t.ReadOnly=Ut(0)]="ReadOnly",t[t.Required=Ut(1)]="Required",t[t.NoExport=Ut(2)]="NoExport"})(Lr||(Lr={}));var Ar;(function(t){t[t.NoToggleToOff=Ut(14)]="NoToggleToOff",t[t.Radio=Ut(15)]="Radio",t[t.PushButton=Ut(16)]="PushButton",t[t.RadiosInUnison=Ut(25)]="RadiosInUnison"})(Ar||(Ar={}));var Tt;(function(t){t[t.Multiline=Ut(12)]="Multiline",t[t.Password=Ut(13)]="Password",t[t.FileSelect=Ut(20)]="FileSelect",t[t.DoNotSpellCheck=Ut(22)]="DoNotSpellCheck",t[t.DoNotScroll=Ut(23)]="DoNotScroll",t[t.Comb=Ut(24)]="Comb",t[t.RichText=Ut(25)]="RichText"})(Tt||(Tt={}));var dt;(function(t){t[t.Combo=Ut(17)]="Combo",t[t.Edit=Ut(18)]="Edit",t[t.Sort=Ut(19)]="Sort",t[t.MultiSelect=Ut(21)]="MultiSelect",t[t.DoNotSpellCheck=Ut(22)]="DoNotSpellCheck",t[t.CommitOnSelChange=Ut(26)]="CommitOnSelChange"})(dt||(dt={}));var n1=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.setValues=function(r){if(this.hasFlag(dt.Combo)&&!this.hasFlag(dt.Edit)&&!this.valuesAreValid(r))throw new Hc;if(r.length===0&&this.dict.delete(O.of("V")),r.length===1&&this.dict.set(O.of("V"),r[0]),r.length>1){if(!this.hasFlag(dt.MultiSelect))throw new h5;this.dict.set(O.of("V"),this.dict.context.obj(r))}this.updateSelectedIndices(r)},e.prototype.valuesAreValid=function(r){for(var n=this.getOptions(),i=function(u,f){var l=r[u].decodeText();if(!n.find(function(h){return l===(h.display||h.value).decodeText()}))return{value:!1}},a=0,o=r.length;a<o;a++){var s=i(a);if(typeof s=="object")return s.value}return!0},e.prototype.updateSelectedIndices=function(r){if(r.length>1){for(var n=new Array(r.length),i=this.getOptions(),a=function(u,f){var l=r[u].decodeText();n[u]=i.findIndex(function(h){return l===(h.display||h.value).decodeText()})},o=0,s=r.length;o<s;o++)a(o,s);this.dict.set(O.of("I"),this.dict.context.obj(n.sort()))}else this.dict.delete(O.of("I"))},e.prototype.getValues=function(){var r=this.V();if(r instanceof vt||r instanceof Ie)return[r];if(r instanceof ht){for(var n=[],i=0,a=r.size();i<a;i++){var o=r.lookup(i);(o instanceof vt||o instanceof Ie)&&n.push(o)}return n}return[]},e.prototype.Opt=function(){return this.dict.lookupMaybe(O.of("Opt"),vt,Ie,ht)},e.prototype.setOptions=function(r){for(var n=new Array(r.length),i=0,a=r.length;i<a;i++){var o=r[i],s=o.value,u=o.display;n[i]=this.dict.context.obj([s,u||s])}this.dict.set(O.of("Opt"),this.dict.context.obj(n))},e.prototype.getOptions=function(){var r=this.Opt();if(r instanceof vt||r instanceof Ie)return[{value:r,display:r}];if(r instanceof ht){for(var n=[],i=0,a=r.size();i<a;i++){var o=r.lookup(i);if((o instanceof vt||o instanceof Ie)&&n.push({value:o,display:o}),o instanceof ht&&o.size()>0){var s=o.lookup(0,vt,Ie),u=o.lookupMaybe(1,vt,Ie);n.push({value:s,display:u||s})}}return n}return[]},e})(la),nu=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Ch",Ff:dt.Combo,Kids:[]}),i=r.register(n);return new e(n,i)},e})(n1),As=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.addField=function(r){var n=this.normalizedEntries().Kids;n?.push(r)},e.prototype.normalizedEntries=function(){var r=this.Kids();return r||(r=this.dict.context.obj([]),this.dict.set(O.of("Kids"),r)),{Kids:r}},e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({}),i=r.register(n);return new e(n,i)},e})(r1),Qc=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e})(la),iu=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.MaxLen=function(){var r=this.dict.lookup(O.of("MaxLen"));if(r instanceof ze)return r},e.prototype.Q=function(){var r=this.dict.lookup(O.of("Q"));if(r instanceof ze)return r},e.prototype.setMaxLength=function(r){this.dict.set(O.of("MaxLen"),ze.of(r))},e.prototype.removeMaxLength=function(){this.dict.delete(O.of("MaxLen"))},e.prototype.getMaxLength=function(){var r;return(r=this.MaxLen())===null||r===void 0?void 0:r.asNumber()},e.prototype.setQuadding=function(r){this.dict.set(O.of("Q"),ze.of(r))},e.prototype.getQuadding=function(){var r;return(r=this.Q())===null||r===void 0?void 0:r.asNumber()},e.prototype.setValue=function(r){this.dict.set(O.of("V"),r)},e.prototype.removeValue=function(){this.dict.delete(O.of("V"))},e.prototype.getValue=function(){var r=this.V();if(r instanceof vt||r instanceof Ie)return r},e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Tx",Kids:[]}),i=r.register(n);return new e(n,i)},e})(la),au=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Btn",Ff:Ar.PushButton,Kids:[]}),i=r.register(n);return new e(n,i)},e})(Jc),ou=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.setValue=function(r){var n=this.getOnValues();if(!n.includes(r)&&r!==O.of("Off"))throw new Hc;this.dict.set(O.of("V"),r);for(var i=this.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a],u=s.getOnValue()===r?r:O.of("Off");s.setAppearanceState(u)}},e.prototype.getValue=function(){var r=this.V();return r instanceof O?r:O.of("Off")},e.prototype.getOnValues=function(){for(var r=this.getWidgets(),n=[],i=0,a=r.length;i<a;i++){var o=r[i].getOnValue();o&&n.push(o)}return n},e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Btn",Ff:Ar.Radio,Kids:[]}),i=r.register(n);return new e(n,i)},e})(Jc),su=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Ch",Kids:[]}),i=r.register(n);return new e(n,i)},e})(n1),_c=function(t){if(!t)return[];for(var e=[],r=0,n=t.size();r<n;r++){var i=t.get(r),a=t.lookup(r);i instanceof pt&&a instanceof Ke&&e.push([i1(a,i),i])}return e},i1=function(t,e){var r=nC(t);return r?As.fromDict(t,e):iC(t,e)},nC=function(t){var e=t.lookup(O.of("Kids"));if(e instanceof ht)for(var r=0,n=e.size();r<n;r++){var i=e.lookup(r),a=i instanceof Ke&&i.has(O.of("T"));if(a)return!0}return!1},iC=function(t,e){var r=$c(t,O.of("FT")),n=t.context.lookup(r,O);return n===O.of("Btn")?aC(t,e):n===O.of("Ch")?oC(t,e):n===O.of("Tx")?iu.fromDict(t,e):n===O.of("Sig")?Qc.fromDict(t,e):la.fromDict(t,e)},aC=function(t,e){var r,n=$c(t,O.of("Ff")),i=t.context.lookupMaybe(n,ze),a=(r=i?.asNumber())!==null&&r!==void 0?r:0;return Xf(a,Ar.PushButton)?au.fromDict(t,e):Xf(a,Ar.Radio)?ou.fromDict(t,e):ru.fromDict(t,e)},oC=function(t,e){var r,n=$c(t,O.of("Ff")),i=t.context.lookupMaybe(n,ze),a=(r=i?.asNumber())!==null&&r!==void 0?r:0;return Xf(a,dt.Combo)?nu.fromDict(t,e):su.fromDict(t,e)},Xf=function(t,e){return(t&e)!==0},$c=function(t,e){var r;return a1(t,function(n){r||(r=n.get(e))}),r},a1=function(t,e){e(t);var r=t.lookupMaybe(O.of("Parent"),Ke);r&&a1(r,e)},Cs=(function(){function t(e){this.dict=e}return t.prototype.Fields=function(){var e=this.dict.lookup(O.of("Fields"));if(e instanceof ht)return e},t.prototype.getFields=function(){for(var e=this.normalizedEntries().Fields,r=new Array(e.size()),n=0,i=e.size();n<i;n++){var a=e.get(n),o=e.lookup(n,Ke);r[n]=[i1(o,a),a]}return r},t.prototype.getAllFields=function(){var e=[],r=function(n){if(n)for(var i=0,a=n.length;i<a;i++){var o=n[i];e.push(o);var s=o[0];s instanceof As&&r(_c(s.Kids()))}};return r(this.getFields()),e},t.prototype.addField=function(e){var r=this.normalizedEntries().Fields;r?.push(e)},t.prototype.removeField=function(e){var r=e.getParent(),n=r===void 0?this.normalizedEntries().Fields:r.Kids(),i=n?.indexOf(e.ref);if(n===void 0||i===void 0)throw new Error("Tried to remove inexistent field "+e.getFullyQualifiedName());n.remove(i),r!==void 0&&n.size()===0&&this.removeField(r)},t.prototype.normalizedEntries=function(){var e=this.Fields();return e||(e=this.dict.context.obj([]),this.dict.set(O.of("Fields"),e)),{Fields:e}},t.fromDict=function(e){return new t(e)},t.create=function(e){var r=e.obj({Fields:[]});return new t(r)},t})(),o1=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.Pages=function(){return this.lookup(O.of("Pages"),Ke)},e.prototype.AcroForm=function(){return this.lookupMaybe(O.of("AcroForm"),Ke)},e.prototype.getAcroForm=function(){var r=this.AcroForm();if(r)return Cs.fromDict(r)},e.prototype.getOrCreateAcroForm=function(){var r=this.getAcroForm();if(!r){r=Cs.create(this.context);var n=this.context.register(r.dict);this.set(O.of("AcroForm"),n)}return r},e.prototype.ViewerPreferences=function(){return this.lookupMaybe(O.of("ViewerPreferences"),Ke)},e.prototype.getViewerPreferences=function(){var r=this.ViewerPreferences();if(r)return hd.fromDict(r)},e.prototype.getOrCreateViewerPreferences=function(){var r=this.getViewerPreferences();if(!r){r=hd.create(this.context);var n=this.context.register(r.dict);this.set(O.of("ViewerPreferences"),n)}return r},e.prototype.insertLeafNode=function(r,n){var i=this.get(O.of("Pages")),a=this.Pages().insertLeafNode(r,n);return a||i},e.prototype.removeLeafNode=function(r){this.Pages().removeLeafNode(r)},e.withContextAndPages=function(r,n){var i=new Map;return i.set(O.of("Type"),O.of("Catalog")),i.set(O.of("Pages"),n),new e(i,r)},e.fromMapWithContext=function(r,n){return new e(r,n)},e})(Ke),s1=(function(t){se(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.Parent=function(){return this.lookup(O.of("Parent"))},e.prototype.Kids=function(){return this.lookup(O.of("Kids"),ht)},e.prototype.Count=function(){return this.lookup(O.of("Count"),ze)},e.prototype.pushTreeNode=function(r){var n=this.Kids();n.push(r)},e.prototype.pushLeafNode=function(r){var n=this.Kids();this.insertLeafKid(n.size(),r)},e.prototype.insertLeafNode=function(r,n){var i=this.Kids(),a=this.Count().asNumber();if(n>a)throw new $0(n,a);for(var o=n,s=0,u=i.size();s<u;s++){if(o===0){this.insertLeafKid(s,r);return}var f=i.get(s),l=this.context.lookup(f);if(l instanceof e){if(l.Count().asNumber()>o)return l.insertLeafNode(r,o)||f;o-=l.Count().asNumber()}l instanceof vn&&(o-=1)}if(o===0){this.insertLeafKid(i.size(),r);return}throw new ed(n,"insertLeafNode")},e.prototype.removeLeafNode=function(r,n){n===void 0&&(n=!0);var i=this.Kids(),a=this.Count().asNumber();if(r>=a)throw new $0(r,a);for(var o=r,s=0,u=i.size();s<u;s++){var f=i.get(s),l=this.context.lookup(f);if(l instanceof e)if(l.Count().asNumber()>o){l.removeLeafNode(o,n),n&&l.Kids().size()===0&&i.remove(s);return}else o-=l.Count().asNumber();if(l instanceof vn)if(o===0){this.removeKid(s);return}else o-=1}throw new ed(r,"removeLeafNode")},e.prototype.ascend=function(r){r(this);var n=this.Parent();n&&n.ascend(r)},e.prototype.traverse=function(r){for(var n=this.Kids(),i=0,a=n.size();i<a;i++){var o=n.get(i),s=this.context.lookup(o);s instanceof e&&s.traverse(r),r(s,o)}},e.prototype.insertLeafKid=function(r,n){var i=this.Kids();this.ascend(function(a){var o=a.Count().asNumber()+1;a.set(O.of("Count"),ze.of(o))}),i.insert(r,n)},e.prototype.removeKid=function(r){var n=this.Kids(),i=n.lookup(r);i instanceof vn&&this.ascend(function(a){var o=a.Count().asNumber()-1;a.set(O.of("Count"),ze.of(o))}),n.remove(r)},e.withContext=function(r,n){var i=new Map;return i.set(O.of("Type"),O.of("Pages")),i.set(O.of("Kids"),r.obj([])),i.set(O.of("Count"),r.obj(0)),n&&i.set(O.of("Parent"),n),new e(i,r)},e.fromMapWithContext=function(r,n){return new e(r,n)},e})(Ke),er=new Uint8Array(256);er[k.Zero]=1;er[k.One]=1;er[k.Two]=1;er[k.Three]=1;er[k.Four]=1;er[k.Five]=1;er[k.Six]=1;er[k.Seven]=1;er[k.Eight]=1;er[k.Nine]=1;var uu=new Uint8Array(256);uu[k.Period]=1;uu[k.Plus]=1;uu[k.Minus]=1;var el=new Uint8Array(256);for(var Ca=0,sC=256;Ca<sC;Ca++)el[Ca]=er[Ca]||uu[Ca]?1:0;var dd=k.Newline,vd=k.CarriageReturn,uC=(function(){function t(e,r){r===void 0&&(r=!1),this.bytes=e,this.capNumbers=r}return t.prototype.parseRawInt=function(){for(var e="";!this.bytes.done();){var r=this.bytes.peek();if(!er[r])break;e+=hn(this.bytes.next())}var n=Number(e);if(!e||!isFinite(n))throw new td(this.bytes.position(),e);return n},t.prototype.parseRawNumber=function(){for(var e="";!this.bytes.done();){var r=this.bytes.peek();if(!el[r]||(e+=hn(this.bytes.next()),r===k.Period))break}for(;!this.bytes.done();){var r=this.bytes.peek();if(!er[r])break;e+=hn(this.bytes.next())}var n=Number(e);if(!e||!isFinite(n))throw new td(this.bytes.position(),e);if(n>Number.MAX_SAFE_INTEGER)if(this.capNumbers){var i="Parsed number that is too large for some PDF readers: "+e+", using Number.MAX_SAFE_INTEGER instead.";return console.warn(i),Number.MAX_SAFE_INTEGER}else{var i="Parsed number that is too large for some PDF readers: "+e+", not capping.";console.warn(i)}return n},t.prototype.skipWhitespace=function(){for(;!this.bytes.done()&&bn[this.bytes.peek()];)this.bytes.next()},t.prototype.skipLine=function(){for(;!this.bytes.done();){var e=this.bytes.peek();if(e===dd||e===vd)return;this.bytes.next()}},t.prototype.skipComment=function(){if(this.bytes.peek()!==k.Percent)return!1;for(;!this.bytes.done();){var e=this.bytes.peek();if(e===dd||e===vd)return!0;this.bytes.next()}return!0},t.prototype.skipWhitespaceAndComments=function(){for(this.skipWhitespace();this.skipComment();)this.skipWhitespace()},t.prototype.matchKeyword=function(e){for(var r=this.bytes.offset(),n=0,i=e.length;n<i;n++)if(this.bytes.done()||this.bytes.next()!==e[n])return this.bytes.moveTo(r),!1;return!0},t})(),fu=(function(){function t(e){this.idx=0,this.line=0,this.column=0,this.bytes=e,this.length=this.bytes.length}return t.prototype.moveTo=function(e){this.idx=e},t.prototype.next=function(){var e=this.bytes[this.idx++];return e===k.Newline?(this.line+=1,this.column=0):this.column+=1,e},t.prototype.assertNext=function(e){if(this.peek()!==e)throw new p5(this.position(),e,this.peek());return this.next()},t.prototype.peek=function(){return this.bytes[this.idx]},t.prototype.peekAhead=function(e){return this.bytes[this.idx+e]},t.prototype.peekAt=function(e){return this.bytes[e]},t.prototype.done=function(){return this.idx>=this.length},t.prototype.offset=function(){return this.idx},t.prototype.slice=function(e,r){return this.bytes.slice(e,r)},t.prototype.position=function(){return{line:this.line,column:this.column,offset:this.idx}},t.of=function(e){return new t(e)},t.fromPDFRawStream=function(e){return t.of(e1(e).decode())},t})(),fC=k.Space,Ea=k.CarriageReturn,Da=k.Newline,Ta=[k.s,k.t,k.r,k.e,k.a,k.m],Vo=[k.e,k.n,k.d,k.s,k.t,k.r,k.e,k.a,k.m],xt={header:[k.Percent,k.P,k.D,k.F,k.Dash],eof:[k.Percent,k.Percent,k.E,k.O,k.F],obj:[k.o,k.b,k.j],endobj:[k.e,k.n,k.d,k.o,k.b,k.j],xref:[k.x,k.r,k.e,k.f],trailer:[k.t,k.r,k.a,k.i,k.l,k.e,k.r],startxref:[k.s,k.t,k.a,k.r,k.t,k.x,k.r,k.e,k.f],true:[k.t,k.r,k.u,k.e],false:[k.f,k.a,k.l,k.s,k.e],null:[k.n,k.u,k.l,k.l],stream:Ta,streamEOF1:st(Ta,[fC,Ea,Da]),streamEOF2:st(Ta,[Ea,Da]),streamEOF3:st(Ta,[Ea]),streamEOF4:st(Ta,[Da]),endstream:Vo,EOF1endstream:st([Ea,Da],Vo),EOF2endstream:st([Ea],Vo),EOF3endstream:st([Da],Vo)},u1=(function(t){se(e,t);function e(r,n,i){i===void 0&&(i=!1);var a=t.call(this,r,i)||this;return a.context=n,a}return e.prototype.parseObject=function(){if(this.skipWhitespaceAndComments(),this.matchKeyword(xt.true))return eo.True;if(this.matchKeyword(xt.false))return eo.False;if(this.matchKeyword(xt.null))return ur;var r=this.bytes.peek();if(r===k.LessThan&&this.bytes.peekAhead(1)===k.LessThan)return this.parseDictOrStream();if(r===k.LessThan)return this.parseHexString();if(r===k.LeftParen)return this.parseString();if(r===k.ForwardSlash)return this.parseName();if(r===k.LeftSquareBracket)return this.parseArray();if(el[r])return this.parseNumberOrRef();throw new g5(this.bytes.position(),r)},e.prototype.parseNumberOrRef=function(){var r=this.parseRawNumber();this.skipWhitespaceAndComments();var n=this.bytes.offset();if(er[this.bytes.peek()]){var i=this.parseRawNumber();if(this.skipWhitespaceAndComments(),this.bytes.peek()===k.R)return this.bytes.assertNext(k.R),pt.of(r,i)}return this.bytes.moveTo(n),ze.of(r)},e.prototype.parseHexString=function(){var r="";for(this.bytes.assertNext(k.LessThan);!this.bytes.done()&&this.bytes.peek()!==k.GreaterThan;)r+=hn(this.bytes.next());return this.bytes.assertNext(k.GreaterThan),Ie.of(r)},e.prototype.parseString=function(){for(var r=0,n=!1,i="";!this.bytes.done();){var a=this.bytes.next();if(i+=hn(a),n||(a===k.LeftParen&&(r+=1),a===k.RightParen&&(r-=1)),a===k.BackSlash?n=!n:n&&(n=!1),r===0)return vt.of(i.substring(1,i.length-1))}throw new b5(this.bytes.position())},e.prototype.parseName=function(){this.bytes.assertNext(k.ForwardSlash);for(var r="";!this.bytes.done();){var n=this.bytes.peek();if(bn[n]||Br[n])break;r+=hn(n),this.bytes.next()}return O.of(r)},e.prototype.parseArray=function(){this.bytes.assertNext(k.LeftSquareBracket),this.skipWhitespaceAndComments();for(var r=ht.withContext(this.context);this.bytes.peek()!==k.RightSquareBracket;){var n=this.parseObject();r.push(n),this.skipWhitespaceAndComments()}return this.bytes.assertNext(k.RightSquareBracket),r},e.prototype.parseDict=function(){this.bytes.assertNext(k.LessThan),this.bytes.assertNext(k.LessThan),this.skipWhitespaceAndComments();for(var r=new Map;!this.bytes.done()&&this.bytes.peek()!==k.GreaterThan&&this.bytes.peekAhead(1)!==k.GreaterThan;){var n=this.parseName(),i=this.parseObject();r.set(n,i),this.skipWhitespaceAndComments()}this.skipWhitespaceAndComments(),this.bytes.assertNext(k.GreaterThan),this.bytes.assertNext(k.GreaterThan);var a=r.get(O.of("Type"));return a===O.of("Catalog")?o1.fromMapWithContext(r,this.context):a===O.of("Pages")?s1.fromMapWithContext(r,this.context):a===O.of("Page")?vn.fromMapWithContext(r,this.context):Ke.fromMapWithContext(r,this.context)},e.prototype.parseDictOrStream=function(){var r=this.bytes.position(),n=this.parseDict();if(this.skipWhitespaceAndComments(),!this.matchKeyword(xt.streamEOF1)&&!this.matchKeyword(xt.streamEOF2)&&!this.matchKeyword(xt.streamEOF3)&&!this.matchKeyword(xt.streamEOF4)&&!this.matchKeyword(xt.stream))return n;var i=this.bytes.offset(),a,o=n.get(O.of("Length"));o instanceof ze?(a=i+o.asNumber(),this.bytes.moveTo(a),this.skipWhitespaceAndComments(),this.matchKeyword(xt.endstream)||(this.bytes.moveTo(i),a=this.findEndOfStreamFallback(r))):a=this.findEndOfStreamFallback(r);var s=this.bytes.slice(i,a);return to.of(n,s)},e.prototype.findEndOfStreamFallback=function(r){for(var n=1,i=this.bytes.offset();!this.bytes.done()&&(i=this.bytes.offset(),this.matchKeyword(xt.stream)?n+=1:this.matchKeyword(xt.EOF1endstream)||this.matchKeyword(xt.EOF2endstream)||this.matchKeyword(xt.EOF3endstream)||this.matchKeyword(xt.endstream)?n-=1:this.bytes.next(),n!==0););if(n!==0)throw new m5(r);return i},e.forBytes=function(r,n,i){return new e(fu.of(r),n,i)},e.forByteStream=function(r,n,i){return i===void 0&&(i=!1),new e(r,n,i)},e})(uC),cC=(function(t){se(e,t);function e(r,n){var i=t.call(this,fu.fromPDFRawStream(r),r.dict.context)||this,a=r.dict;return i.alreadyParsed=!1,i.shouldWaitForTick=n||(function(){return!1}),i.firstOffset=a.lookup(O.of("First"),ze).asNumber(),i.objectCount=a.lookup(O.of("N"),ze).asNumber(),i}return e.prototype.parseIntoContext=function(){return Ze(this,void 0,void 0,function(){var r,n,i,a,o,s,u,f;return Ye(this,function(l){switch(l.label){case 0:if(this.alreadyParsed)throw new Gc("PDFObjectStreamParser","parseIntoContext");this.alreadyParsed=!0,r=this.parseOffsetsAndObjectNumbers(),n=0,i=r.length,l.label=1;case 1:return n<i?(a=r[n],o=a.objectNumber,s=a.offset,this.bytes.moveTo(this.firstOffset+s),u=this.parseObject(),f=pt.of(o,0),this.context.assign(f,u),this.shouldWaitForTick()?[4,oa()]:[3,3]):[3,4];case 2:l.sent(),l.label=3;case 3:return n++,[3,1];case 4:return[2]}})})},e.prototype.parseOffsetsAndObjectNumbers=function(){for(var r=[],n=0,i=this.objectCount;n<i;n++){this.skipWhitespaceAndComments();var a=this.parseRawInt();this.skipWhitespaceAndComments();var o=this.parseRawInt();r.push({objectNumber:a,offset:o})}return r},e.forStream=function(r,n){return new e(r,n)},e})(u1),lC=(function(){function t(e){this.alreadyParsed=!1,this.dict=e.dict,this.bytes=fu.fromPDFRawStream(e),this.context=this.dict.context;var r=this.dict.lookup(O.of("Size"),ze),n=this.dict.lookup(O.of("Index"));if(n instanceof ht){this.subsections=[];for(var i=0,a=n.size();i<a;i+=2){var o=n.lookup(i+0,ze).asNumber(),s=n.lookup(i+1,ze).asNumber();this.subsections.push({firstObjectNumber:o,length:s})}}else this.subsections=[{firstObjectNumber:0,length:r.asNumber()}];var u=this.dict.lookup(O.of("W"),ht);this.byteWidths=[-1,-1,-1];for(var i=0,a=u.size();i<a;i++)this.byteWidths[i]=u.lookup(i,ze).asNumber()}return t.prototype.parseIntoContext=function(){if(this.alreadyParsed)throw new Gc("PDFXRefStreamParser","parseIntoContext");this.alreadyParsed=!0,this.context.trailerInfo={Root:this.dict.get(O.of("Root")),Encrypt:this.dict.get(O.of("Encrypt")),Info:this.dict.get(O.of("Info")),ID:this.dict.get(O.of("ID"))};var e=this.parseEntries();return e},t.prototype.parseEntries=function(){for(var e=[],r=this.byteWidths,n=r[0],i=r[1],a=r[2],o=0,s=this.subsections.length;o<s;o++)for(var u=this.subsections[o],f=u.firstObjectNumber,l=u.length,h=0;h<l;h++){for(var d=0,v=0,g=n;v<g;v++)d=d<<8|this.bytes.next();for(var b=0,v=0,g=i;v<g;v++)b=b<<8|this.bytes.next();for(var w=0,v=0,g=a;v<g;v++)w=w<<8|this.bytes.next();n===0&&(d=1);var x=f+h,T={ref:pt.of(x,w),offset:b,deleted:d===0,inObjectStream:d===2};e.push(T)}return e},t.forStream=function(e){return new t(e)},t})(),hC=(function(t){se(e,t);function e(r,n,i,a){n===void 0&&(n=1/0),i===void 0&&(i=!1),a===void 0&&(a=!1);var o=t.call(this,fu.of(r),Gf.create(),a)||this;return o.alreadyParsed=!1,o.parsedObjects=0,o.shouldWaitForTick=function(){return o.parsedObjects+=1,o.parsedObjects%o.objectsPerTick===0},o.objectsPerTick=n,o.throwOnInvalidObject=i,o}return e.prototype.parseDocument=function(){return Ze(this,void 0,void 0,function(){var r,n;return Ye(this,function(i){switch(i.label){case 0:if(this.alreadyParsed)throw new Gc("PDFParser","parseDocument");this.alreadyParsed=!0,this.context.header=this.parseHeader(),i.label=1;case 1:return this.bytes.done()?[3,3]:[4,this.parseDocumentSection()];case 2:if(i.sent(),n=this.bytes.offset(),n===r)throw new w5(this.bytes.position());return r=n,[3,1];case 3:return this.maybeRecoverRoot(),this.context.lookup(pt.of(0))&&(console.warn("Removing parsed object: 0 0 R"),this.context.delete(pt.of(0))),[2,this.context]}})})},e.prototype.maybeRecoverRoot=function(){var r=function(l){return l instanceof Ke&&l.lookup(O.of("Type"))===O.of("Catalog")},n=this.context.lookup(this.context.trailerInfo.Root);if(!r(n))for(var i=this.context.enumerateIndirectObjects(),a=0,o=i.length;a<o;a++){var s=i[a],u=s[0],f=s[1];r(f)&&(this.context.trailerInfo.Root=u)}},e.prototype.parseHeader=function(){for(;!this.bytes.done();){if(this.matchKeyword(xt.header)){var r=this.parseRawInt();this.bytes.assertNext(k.Period);var n=this.parseRawInt(),i=tu.forVersion(r,n);return this.skipBinaryHeaderComment(),i}this.bytes.next()}throw new x5(this.bytes.position())},e.prototype.parseIndirectObjectHeader=function(){this.skipWhitespaceAndComments();var r=this.parseRawInt();this.skipWhitespaceAndComments();var n=this.parseRawInt();if(this.skipWhitespaceAndComments(),!this.matchKeyword(xt.obj))throw new F5(this.bytes.position(),xt.obj);return pt.of(r,n)},e.prototype.matchIndirectObjectHeader=function(){var r=this.bytes.offset();try{return this.parseIndirectObjectHeader(),!0}catch{return this.bytes.moveTo(r),!1}},e.prototype.parseIndirectObject=function(){return Ze(this,void 0,void 0,function(){var r,n;return Ye(this,function(i){switch(i.label){case 0:return r=this.parseIndirectObjectHeader(),this.skipWhitespaceAndComments(),n=this.parseObject(),this.skipWhitespaceAndComments(),this.matchKeyword(xt.endobj),n instanceof to&&n.dict.lookup(O.of("Type"))===O.of("ObjStm")?[4,cC.forStream(n,this.shouldWaitForTick).parseIntoContext()]:[3,2];case 1:return i.sent(),[3,3];case 2:n instanceof to&&n.dict.lookup(O.of("Type"))===O.of("XRef")?lC.forStream(n).parseIntoContext():this.context.assign(r,n),i.label=3;case 3:return[2,r]}})})},e.prototype.tryToParseInvalidIndirectObject=function(){var r=this.bytes.position(),n="Trying to parse invalid object: "+JSON.stringify(r)+")";if(this.throwOnInvalidObject)throw new Error(n);console.warn(n);var i=this.parseIndirectObjectHeader();console.warn("Invalid object ref: "+i),this.skipWhitespaceAndComments();for(var a=this.bytes.offset(),o=!0;!this.bytes.done()&&(this.matchKeyword(xt.endobj)&&(o=!1),!!o);)this.bytes.next();if(o)throw new y5(r);var s=this.bytes.offset()-xt.endobj.length,u=Jp.of(this.bytes.slice(a,s));return this.context.assign(i,u),i},e.prototype.parseIndirectObjects=function(){return Ze(this,void 0,void 0,function(){var r;return Ye(this,function(n){switch(n.label){case 0:this.skipWhitespaceAndComments(),n.label=1;case 1:if(!(!this.bytes.done()&&er[this.bytes.peek()]))return[3,8];r=this.bytes.offset(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.parseIndirectObject()];case 3:return n.sent(),[3,5];case 4:return n.sent(),this.bytes.moveTo(r),this.tryToParseInvalidIndirectObject(),[3,5];case 5:return this.skipWhitespaceAndComments(),this.skipJibberish(),this.shouldWaitForTick()?[4,oa()]:[3,7];case 6:n.sent(),n.label=7;case 7:return[3,1];case 8:return[2]}})})},e.prototype.maybeParseCrossRefSection=function(){if(this.skipWhitespaceAndComments(),!!this.matchKeyword(xt.xref)){this.skipWhitespaceAndComments();for(var r=-1,n=Xp.createEmpty();!this.bytes.done()&&er[this.bytes.peek()];){var i=this.parseRawInt();this.skipWhitespaceAndComments();var a=this.parseRawInt();this.skipWhitespaceAndComments();var o=this.bytes.peek();if(o===k.n||o===k.f){var s=pt.of(r,a);this.bytes.next()===k.n?n.addEntry(s,i):n.addDeletedEntry(s,i),r+=1}else r=i;this.skipWhitespaceAndComments()}return n}},e.prototype.maybeParseTrailerDict=function(){if(this.skipWhitespaceAndComments(),!!this.matchKeyword(xt.trailer)){this.skipWhitespaceAndComments();var r=this.parseDict(),n=this.context;n.trailerInfo={Root:r.get(O.of("Root"))||n.trailerInfo.Root,Encrypt:r.get(O.of("Encrypt"))||n.trailerInfo.Encrypt,Info:r.get(O.of("Info"))||n.trailerInfo.Info,ID:r.get(O.of("ID"))||n.trailerInfo.ID}}},e.prototype.maybeParseTrailer=function(){if(this.skipWhitespaceAndComments(),!!this.matchKeyword(xt.startxref)){this.skipWhitespaceAndComments();var r=this.parseRawInt();return this.skipWhitespace(),this.matchKeyword(xt.eof),this.skipWhitespaceAndComments(),this.matchKeyword(xt.eof),this.skipWhitespaceAndComments(),Zc.forLastCrossRefSectionOffset(r)}},e.prototype.parseDocumentSection=function(){return Ze(this,void 0,void 0,function(){return Ye(this,function(r){switch(r.label){case 0:return[4,this.parseIndirectObjects()];case 1:return r.sent(),this.maybeParseCrossRefSection(),this.maybeParseTrailerDict(),this.maybeParseTrailer(),this.skipJibberish(),[2]}})})},e.prototype.skipJibberish=function(){for(this.skipWhitespaceAndComments();!this.bytes.done();){var r=this.bytes.offset(),n=this.bytes.peek(),i=n>=k.Space&&n<=k.Tilde;if(i&&(this.matchKeyword(xt.xref)||this.matchKeyword(xt.trailer)||this.matchKeyword(xt.startxref)||this.matchIndirectObjectHeader())){this.bytes.moveTo(r);break}this.bytes.next()}},e.prototype.skipBinaryHeaderComment=function(){this.skipWhitespaceAndComments();try{var r=this.bytes.offset();this.parseIndirectObjectHeader(),this.bytes.moveTo(r)}catch{this.bytes.next(),this.skipWhitespaceAndComments()}},e.forBytesWithOptions=function(r,n,i,a){return new e(r,n,i,a)},e})(u1),Wr=function(t){return 1<<t},Ga;(function(t){t[t.Invisible=Wr(0)]="Invisible",t[t.Hidden=Wr(1)]="Hidden",t[t.Print=Wr(2)]="Print",t[t.NoZoom=Wr(3)]="NoZoom",t[t.NoRotate=Wr(4)]="NoRotate",t[t.NoView=Wr(5)]="NoView",t[t.ReadOnly=Wr(6)]="ReadOnly",t[t.Locked=Wr(7)]="Locked",t[t.ToggleNoView=Wr(8)]="ToggleNoView",t[t.LockedContents=Wr(9)]="LockedContents"})(Ga||(Ga={}));var cu=function(t){return t instanceof O?t:O.of(t)},je=function(t){return t instanceof ze?t:ze.of(t)},Je=function(t){return t instanceof ze?t.asNumber():t},ro;(function(t){t.Degrees="degrees",t.Radians="radians"})(ro||(ro={}));var Me=function(t){return q(t,"degreeAngle",["number"]),{type:ro.Degrees,angle:t}},f1=ro.Radians,c1=ro.Degrees,l1=function(t){return t*Math.PI/180},dC=function(t){return t*180/Math.PI},Qt=function(t){return t.type===f1?t.angle:t.type===c1?l1(t.angle):po("Invalid rotation: "+JSON.stringify(t))},h1=function(t){return t.type===f1?dC(t.angle):t.type===c1?t.angle:po("Invalid rotation: "+JSON.stringify(t))},wn=function(t){t===void 0&&(t=0);var e=t/90%4;return e===0?0:e===1?90:e===2?180:e===3?270:0},Si=function(t,e){e===void 0&&(e=0);var r=wn(e);return r===90||r===270?{width:t.height,height:t.width}:{width:t.width,height:t.height}},vC=function(t,e,r){e===void 0&&(e=0),r===void 0&&(r=0);var n=t.x,i=t.y,a=t.width,o=t.height,s=wn(r),u=e/2;return s===0?{x:n-u,y:i-u,width:a,height:o}:s===90?{x:n-o+u,y:i-u,width:o,height:a}:s===180?{x:n-a+u,y:i-o+u,width:a,height:o}:s===270?{x:n-u,y:i-a+u,width:o,height:a}:{x:n-u,y:i-u,width:a,height:o}},d1=function(){return at.of(rt.ClipNonZero)},Es=Math.cos,Ds=Math.sin,Ts=Math.tan,lu=function(t,e,r,n,i,a){return at.of(rt.ConcatTransformationMatrix,[je(t),je(e),je(r),je(n),je(i),je(a)])},Dr=function(t,e){return lu(1,0,0,1,t,e)},no=function(t,e){return lu(t,0,0,e,0,0)},ha=function(t){return lu(Es(Je(t)),Ds(Je(t)),-Ds(Je(t)),Es(Je(t)),0,0)},qo=function(t){return ha(l1(Je(t)))},tl=function(t,e){return lu(1,Ts(Je(t)),Ts(Je(e)),1,0,0)},hu=function(t,e){return at.of(rt.SetLineDashPattern,["["+t.map(je).join(" ")+"]",je(e)])},Ki;(function(t){t[t.Butt=0]="Butt",t[t.Round=1]="Round",t[t.Projecting=2]="Projecting"})(Ki||(Ki={}));var du=function(t){return at.of(rt.SetLineCapStyle,[je(t)])},pd;(function(t){t[t.Miter=0]="Miter",t[t.Round=1]="Round",t[t.Bevel=2]="Bevel"})(pd||(pd={}));var Ai=function(t){return at.of(rt.SetGraphicsStateParams,[cu(t)])},qt=function(){return at.of(rt.PushGraphicsState)},Wt=function(){return at.of(rt.PopGraphicsState)},yo=function(t){return at.of(rt.SetLineWidth,[je(t)])},hr=function(t,e,r,n,i,a){return at.of(rt.AppendBezierCurve,[je(t),je(e),je(r),je(n),je(i),je(a)])},Wo=function(t,e,r,n){return at.of(rt.CurveToReplicateInitialPoint,[je(t),je(e),je(r),je(n)])},qn=function(){return at.of(rt.ClosePath)},en=function(t,e){return at.of(rt.MoveTo,[je(t),je(e)])},Gt=function(t,e){return at.of(rt.LineTo,[je(t),je(e)])},mo=function(){return at.of(rt.StrokePath)},rl=function(){return at.of(rt.FillNonZero)},nl=function(){return at.of(rt.FillNonZeroAndStroke)},v1=function(){return at.of(rt.EndPath)},pC=function(){return at.of(rt.NextLine)},p1=function(t){return at.of(rt.ShowText,[t])},g1=function(){return at.of(rt.BeginText)},y1=function(){return at.of(rt.EndText)},il=function(t,e){return at.of(rt.SetFontAndSize,[cu(t),je(e)])},gC=function(t){return at.of(rt.SetTextLineHeight,[je(t)])},gd;(function(t){t[t.Fill=0]="Fill",t[t.Outline=1]="Outline",t[t.FillAndOutline=2]="FillAndOutline",t[t.Invisible=3]="Invisible",t[t.FillAndClip=4]="FillAndClip",t[t.OutlineAndClip=5]="OutlineAndClip",t[t.FillAndOutlineAndClip=6]="FillAndOutlineAndClip",t[t.Clip=7]="Clip"})(gd||(gd={}));var yC=function(t,e,r,n,i,a){return at.of(rt.SetTextMatrix,[je(t),je(e),je(r),je(n),je(i),je(a)])},m1=function(t,e,r,n,i){return yC(Es(Je(t)),Ds(Je(t))+Ts(Je(e)),-Ds(Je(t))+Ts(Je(r)),Es(Je(t)),n,i)},al=function(t){return at.of(rt.DrawObject,[cu(t)])},mC=function(t){return at.of(rt.NonStrokingColorGray,[je(t)])},bC=function(t){return at.of(rt.StrokingColorGray,[je(t)])},wC=function(t,e,r){return at.of(rt.NonStrokingColorRgb,[je(t),je(e),je(r)])},xC=function(t,e,r){return at.of(rt.StrokingColorRgb,[je(t),je(e),je(r)])},FC=function(t,e,r,n){return at.of(rt.NonStrokingColorCmyk,[je(t),je(e),je(r),je(n)])},SC=function(t,e,r,n){return at.of(rt.StrokingColorCmyk,[je(t),je(e),je(r),je(n)])},b1=function(t){return at.of(rt.BeginMarkedContent,[cu(t)])},w1=function(){return at.of(rt.EndMarkedContent)},Wn;(function(t){t.Grayscale="Grayscale",t.RGB="RGB",t.CMYK="CMYK"})(Wn||(Wn={}));var x1=function(t){return lr(t,"gray",0,1),{type:Wn.Grayscale,gray:t}},ft=function(t,e,r){return lr(t,"red",0,1),lr(e,"green",0,1),lr(r,"blue",0,1),{type:Wn.RGB,red:t,green:e,blue:r}},F1=function(t,e,r,n){return lr(t,"cyan",0,1),lr(e,"magenta",0,1),lr(r,"yellow",0,1),lr(n,"key",0,1),{type:Wn.CMYK,cyan:t,magenta:e,yellow:r,key:n}},ol=Wn.Grayscale,sl=Wn.RGB,ul=Wn.CMYK,Ci=function(t){return t.type===ol?mC(t.gray):t.type===sl?wC(t.red,t.green,t.blue):t.type===ul?FC(t.cyan,t.magenta,t.yellow,t.key):po("Invalid color: "+JSON.stringify(t))},bo=function(t){return t.type===ol?bC(t.gray):t.type===sl?xC(t.red,t.green,t.blue):t.type===ul?SC(t.cyan,t.magenta,t.yellow,t.key):po("Invalid color: "+JSON.stringify(t))},ir=function(t,e){return e===void 0&&(e=1),t?.length===1?x1(t[0]*e):t?.length===3?ft(t[0]*e,t[1]*e,t[2]*e):t?.length===4?F1(t[0]*e,t[1]*e,t[2]*e,t[3]*e):void 0},yd=function(t){return t.type===ol?[t.gray]:t.type===sl?[t.red,t.green,t.blue]:t.type===ul?[t.cyan,t.magenta,t.yellow,t.key]:po("Invalid color: "+JSON.stringify(t))},Ce=0,Ee=0,nt=0,it=0,Pa=0,Ia=0,md=new Map([["A",7],["a",7],["C",6],["c",6],["H",1],["h",1],["L",2],["l",2],["M",2],["m",2],["Q",4],["q",4],["S",4],["s",4],["T",2],["t",2],["V",1],["v",1],["Z",0],["z",0]]),AC=function(t){for(var e,r=[],n=[],i="",a=!1,o=0,s=0,u=t;s<u.length;s++){var f=u[s];if(md.has(f))o=md.get(f),e&&(i.length>0&&(n[n.length]=+i),r[r.length]={cmd:e,args:n},n=[],i="",a=!1),e=f;else if([" ",","].includes(f)||f==="-"&&i.length>0&&i[i.length-1]!=="e"||f==="."&&a){if(i.length===0)continue;n.length===o?(r[r.length]={cmd:e,args:n},n=[+i],e==="M"&&(e="L"),e==="m"&&(e="l")):n[n.length]=+i,a=f===".",i=["-","."].includes(f)?f:""}else i+=f,f==="."&&(a=!0)}return i.length>0&&(n.length===o?(r[r.length]={cmd:e,args:n},n=[+i],e==="M"&&(e="L"),e==="m"&&(e="l")):n[n.length]=+i),r[r.length]={cmd:e,args:n},r},CC=function(t){Ce=Ee=nt=it=Pa=Ia=0;for(var e=[],r=0;r<t.length;r++){var n=t[r];if(n.cmd&&typeof bd[n.cmd]=="function"){var i=bd[n.cmd](n.args);Array.isArray(i)?e=e.concat(i):e.push(i)}}return e},bd={M:function(t){return Ce=t[0],Ee=t[1],nt=it=null,Pa=Ce,Ia=Ee,en(Ce,Ee)},m:function(t){return Ce+=t[0],Ee+=t[1],nt=it=null,Pa=Ce,Ia=Ee,en(Ce,Ee)},C:function(t){return Ce=t[4],Ee=t[5],nt=t[2],it=t[3],hr(t[0],t[1],t[2],t[3],t[4],t[5])},c:function(t){var e=hr(t[0]+Ce,t[1]+Ee,t[2]+Ce,t[3]+Ee,t[4]+Ce,t[5]+Ee);return nt=Ce+t[2],it=Ee+t[3],Ce+=t[4],Ee+=t[5],e},S:function(t){(nt===null||it===null)&&(nt=Ce,it=Ee);var e=hr(Ce-(nt-Ce),Ee-(it-Ee),t[0],t[1],t[2],t[3]);return nt=t[0],it=t[1],Ce=t[2],Ee=t[3],e},s:function(t){(nt===null||it===null)&&(nt=Ce,it=Ee);var e=hr(Ce-(nt-Ce),Ee-(it-Ee),Ce+t[0],Ee+t[1],Ce+t[2],Ee+t[3]);return nt=Ce+t[0],it=Ee+t[1],Ce+=t[2],Ee+=t[3],e},Q:function(t){return nt=t[0],it=t[1],Ce=t[2],Ee=t[3],Wo(t[0],t[1],Ce,Ee)},q:function(t){var e=Wo(t[0]+Ce,t[1]+Ee,t[2]+Ce,t[3]+Ee);return nt=Ce+t[0],it=Ee+t[1],Ce+=t[2],Ee+=t[3],e},T:function(t){nt===null||it===null?(nt=Ce,it=Ee):(nt=Ce-(nt-Ce),it=Ee-(it-Ee));var e=Wo(nt,it,t[0],t[1]);return nt=Ce-(nt-Ce),it=Ee-(it-Ee),Ce=t[0],Ee=t[1],e},t:function(t){nt===null||it===null?(nt=Ce,it=Ee):(nt=Ce-(nt-Ce),it=Ee-(it-Ee));var e=Wo(nt,it,Ce+t[0],Ee+t[1]);return Ce+=t[0],Ee+=t[1],e},A:function(t){var e=wd(Ce,Ee,t);return Ce=t[5],Ee=t[6],e},a:function(t){t[5]+=Ce,t[6]+=Ee;var e=wd(Ce,Ee,t);return Ce=t[5],Ee=t[6],e},L:function(t){return Ce=t[0],Ee=t[1],nt=it=null,Gt(Ce,Ee)},l:function(t){return Ce+=t[0],Ee+=t[1],nt=it=null,Gt(Ce,Ee)},H:function(t){return Ce=t[0],nt=it=null,Gt(Ce,Ee)},h:function(t){return Ce+=t[0],nt=it=null,Gt(Ce,Ee)},V:function(t){return Ee=t[0],nt=it=null,Gt(Ce,Ee)},v:function(t){return Ee+=t[0],nt=it=null,Gt(Ce,Ee)},Z:function(){var t=qn();return Ce=Pa,Ee=Ia,t},z:function(){var t=qn();return Ce=Pa,Ee=Ia,t}},wd=function(t,e,r){for(var n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],u=r[5],f=r[6],l=EC(u,f,n,i,o,s,a,t,e),h=[],d=0,v=l;d<v.length;d++){var g=v[d],b=DC.apply(void 0,g);h.push(hr.apply(void 0,b))}return h},EC=function(t,e,r,n,i,a,o,s,u){var f=o*(Math.PI/180),l=Math.sin(f),h=Math.cos(f);r=Math.abs(r),n=Math.abs(n),nt=h*(s-t)*.5+l*(u-e)*.5,it=h*(u-e)*.5-l*(s-t)*.5;var d=nt*nt/(r*r)+it*it/(n*n);d>1&&(d=Math.sqrt(d),r*=d,n*=d);var v=h/r,g=l/r,b=-l/n,w=h/n,x=v*s+g*u,T=b*s+w*u,A=v*t+g*e,R=b*t+w*e,P=(A-x)*(A-x)+(R-T)*(R-T),I=1/P-.25;I<0&&(I=0);var B=Math.sqrt(I);a===i&&(B=-B);var j=.5*(x+A)-B*(R-T),W=.5*(T+R)+B*(A-x),N=Math.atan2(T-W,x-j),V=Math.atan2(R-W,A-j),Z=V-N;Z<0&&a===1?Z+=2*Math.PI:Z>0&&a===0&&(Z-=2*Math.PI);for(var U=Math.ceil(Math.abs(Z/(Math.PI*.5+.001))),ee=[],Y=0;Y<U;Y++){var $=N+Y*Z/U,J=N+(Y+1)*Z/U;ee[Y]=[j,W,$,J,r,n,l,h]}return ee},DC=function(t,e,r,n,i,a,o,s){var u=s*i,f=-o*a,l=o*i,h=s*a,d=.5*(n-r),v=8/3*Math.sin(d*.5)*Math.sin(d*.5)/Math.sin(d),g=t+Math.cos(r)-v*Math.sin(r),b=e+Math.sin(r)+v*Math.cos(r),w=t+Math.cos(n),x=e+Math.sin(n),T=w+v*Math.sin(n),A=x-v*Math.cos(n),R=[u*g+f*b,l*g+h*b,u*T+f*A,l*T+h*A,u*w+f*x,l*w+h*x];return R},TC=function(t){return CC(AC(t))},OC=function(t,e){for(var r=[qt(),e.graphicsState&&Ai(e.graphicsState),g1(),Ci(e.color),il(e.font,e.size),gC(e.lineHeight),m1(Qt(e.rotate),Qt(e.xSkew),Qt(e.ySkew),e.x,e.y)].filter(Boolean),n=0,i=t.length;n<i;n++)r.push(p1(t[n]),pC());return r.push(y1(),Wt()),r},S1=function(t,e){return[qt(),e.graphicsState&&Ai(e.graphicsState),Dr(e.x,e.y),ha(Qt(e.rotate)),no(e.width,e.height),tl(Qt(e.xSkew),Qt(e.ySkew)),al(t),Wt()].filter(Boolean)},kC=function(t,e){return[qt(),e.graphicsState&&Ai(e.graphicsState),Dr(e.x,e.y),ha(Qt(e.rotate)),no(e.xScale,e.yScale),tl(Qt(e.xSkew),Qt(e.ySkew)),al(t),Wt()].filter(Boolean)},PC=function(t){var e,r;return[qt(),t.graphicsState&&Ai(t.graphicsState),t.color&&bo(t.color),yo(t.thickness),hu((e=t.dashArray)!==null&&e!==void 0?e:[],(r=t.dashPhase)!==null&&r!==void 0?r:0),en(t.start.x,t.start.y),t.lineCap&&du(t.lineCap),en(t.start.x,t.start.y),Gt(t.end.x,t.end.y),mo(),Wt()].filter(Boolean)},sa=function(t){var e,r;return[qt(),t.graphicsState&&Ai(t.graphicsState),t.color&&Ci(t.color),t.borderColor&&bo(t.borderColor),yo(t.borderWidth),t.borderLineCap&&du(t.borderLineCap),hu((e=t.borderDashArray)!==null&&e!==void 0?e:[],(r=t.borderDashPhase)!==null&&r!==void 0?r:0),Dr(t.x,t.y),ha(Qt(t.rotate)),tl(Qt(t.xSkew),Qt(t.ySkew)),en(0,0),Gt(0,t.height),Gt(t.width,t.height),Gt(t.width,0),qn(),t.color&&t.borderWidth?nl():t.color?rl():t.borderColor?mo():qn(),Wt()].filter(Boolean)},Os=4*((Math.sqrt(2)-1)/3),IC=function(t){var e=Je(t.x),r=Je(t.y),n=Je(t.xScale),i=Je(t.yScale);e-=n,r-=i;var a=n*Os,o=i*Os,s=e+n*2,u=r+i*2,f=e+n,l=r+i;return[qt(),en(e,l),hr(e,l-o,f-a,r,f,r),hr(f+a,r,s,l-o,s,l),hr(s,l+o,f+a,u,f,u),hr(f-a,u,e,l+o,e,l),Wt()]},BC=function(t){var e=Je(t.x),r=Je(t.y),n=Je(t.xScale),i=Je(t.yScale),a=-n,o=-i,s=n*Os,u=i*Os,f=a+n*2,l=o+i*2,h=a+n,d=o+i;return[Dr(e,r),ha(Qt(t.rotate)),en(a,d),hr(a,d-u,h-s,o,h,o),hr(h+s,o,f,d-u,f,d),hr(f,d+u,h+s,l,h,l),hr(h-s,l,a,d+u,a,d)]},Zf=function(t){var e,r,n;return st([qt(),t.graphicsState&&Ai(t.graphicsState),t.color&&Ci(t.color),t.borderColor&&bo(t.borderColor),yo(t.borderWidth),t.borderLineCap&&du(t.borderLineCap),hu((e=t.borderDashArray)!==null&&e!==void 0?e:[],(r=t.borderDashPhase)!==null&&r!==void 0?r:0)],t.rotate===void 0?IC({x:t.x,y:t.y,xScale:t.xScale,yScale:t.yScale}):BC({x:t.x,y:t.y,xScale:t.xScale,yScale:t.yScale,rotate:(n=t.rotate)!==null&&n!==void 0?n:Me(0)}),[t.color&&t.borderWidth?nl():t.color?rl():t.borderColor?mo():qn(),Wt()]).filter(Boolean)},RC=function(t,e){var r,n,i;return st([qt(),e.graphicsState&&Ai(e.graphicsState),Dr(e.x,e.y),ha(Qt((r=e.rotate)!==null&&r!==void 0?r:Me(0))),e.scale?no(e.scale,-e.scale):no(1,-1),e.color&&Ci(e.color),e.borderColor&&bo(e.borderColor),e.borderWidth&&yo(e.borderWidth),e.borderLineCap&&du(e.borderLineCap),hu((n=e.borderDashArray)!==null&&n!==void 0?n:[],(i=e.borderDashPhase)!==null&&i!==void 0?i:0)],TC(t),[e.color&&e.borderWidth?nl():e.color?rl():e.borderColor?mo():qn(),Wt()]).filter(Boolean)},MC=function(t){var e=Je(t.size),r=-1+.75,n=-1+.51,i=1-.525,a=1-.31,o=-1+.325,s=.3995/(i-n)+n;return[qt(),t.color&&bo(t.color),yo(t.thickness),Dr(t.x,t.y),en(o*e,s*e),Gt(r*e,n*e),Gt(a*e,i*e),mo(),Wt()].filter(Boolean)},Qn=function(t){return t.rotation===0?[Dr(0,0),qo(0)]:t.rotation===90?[Dr(t.width,0),qo(90)]:t.rotation===180?[Dr(t.width,t.height),qo(180)]:t.rotation===270?[Dr(0,t.height),qo(270)]:[]},Go=function(t){var e=sa({x:t.x,y:t.y,width:t.width,height:t.height,borderWidth:t.borderWidth,color:t.color,borderColor:t.borderColor,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)});if(!t.filled)return e;var r=Je(t.width),n=Je(t.height),i=Math.min(r,n)/2,a=MC({x:r/2,y:n/2,size:i,thickness:t.thickness,color:t.markColor});return st([qt()],e,a,[Wt()])},Ho=function(t){var e=Je(t.width),r=Je(t.height),n=Math.min(e,r)/2,i=Zf({x:t.x,y:t.y,xScale:n,yScale:n,color:t.color,borderColor:t.borderColor,borderWidth:t.borderWidth});if(!t.filled)return i;var a=Zf({x:t.x,y:t.y,xScale:n*.45,yScale:n*.45,color:t.dotColor,borderColor:void 0,borderWidth:0});return st([qt()],i,a,[Wt()])},xd=function(t){var e=Je(t.x),r=Je(t.y),n=Je(t.width),i=Je(t.height),a=sa({x:e,y:r,width:n,height:i,borderWidth:t.borderWidth,color:t.color,borderColor:t.borderColor,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)}),o=fl(t.textLines,{color:t.textColor,font:t.font,size:t.fontSize,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)});return st([qt()],a,o,[Wt()])},fl=function(t,e){for(var r=[g1(),Ci(e.color),il(e.font,e.size)],n=0,i=t.length;n<i;n++){var a=t[n],o=a.encoded,s=a.x,u=a.y;r.push(m1(Qt(e.rotate),Qt(e.xSkew),Qt(e.ySkew),s,u),p1(o))}return r.push(y1()),r},A1=function(t){var e=Je(t.x),r=Je(t.y),n=Je(t.width),i=Je(t.height),a=Je(t.borderWidth),o=Je(t.padding),s=e+a/2+o,u=r+a/2+o,f=n-(a/2+o)*2,l=i-(a/2+o)*2,h=[en(s,u),Gt(s,u+l),Gt(s+f,u+l),Gt(s+f,u),qn(),d1(),v1()],d=sa({x:e,y:r,width:n,height:i,borderWidth:t.borderWidth,color:t.color,borderColor:t.borderColor,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)}),v=fl(t.textLines,{color:t.textColor,font:t.font,size:t.fontSize,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)}),g=st([b1("Tx"),qt()],v,[Wt(),w1()]);return st([qt()],d,h,g,[Wt()])},LC=function(t){for(var e=Je(t.x),r=Je(t.y),n=Je(t.width),i=Je(t.height),a=Je(t.lineHeight),o=Je(t.borderWidth),s=Je(t.padding),u=e+o/2+s,f=r+o/2+s,l=n-(o/2+s)*2,h=i-(o/2+s)*2,d=[en(u,f),Gt(u,f+h),Gt(u+l,f+h),Gt(u+l,f),qn(),d1(),v1()],v=sa({x:e,y:r,width:n,height:i,borderWidth:t.borderWidth,color:t.color,borderColor:t.borderColor,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)}),g=[],b=0,w=t.selectedLines.length;b<w;b++){var x=t.textLines[t.selectedLines[b]];g.push.apply(g,sa({x:x.x-s,y:x.y-(a-x.height)/2,width:n-o,height:x.height+(a-x.height)/2,borderWidth:0,color:t.selectedColor,borderColor:void 0,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)}))}var T=fl(t.textLines,{color:t.textColor,font:t.font,size:t.fontSize,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)}),A=st([b1("Tx"),qt()],T,[Wt(),w1()]);return st([qt()],v,g,d,A,[Wt()])},NC=(function(t){se(e,t);function e(){var r=this,n="Input document to `PDFDocument.load` is encrypted. You can use `PDFDocument.load(..., { ignoreEncryption: true })` if you wish to load the document anyways.";return r=t.call(this,n)||this,r}return e})(Error),UC=(function(t){se(e,t);function e(){var r=this,n="Input to `PDFDocument.embedFont` was a custom font, but no `fontkit` instance was found. You must register a `fontkit` instance with `PDFDocument.registerFontkit(...)` before embedding custom fonts.";return r=t.call(this,n)||this,r}return e})(Error),zC=(function(t){se(e,t);function e(){var r=this,n="A `page` passed to `PDFDocument.addPage` or `PDFDocument.insertPage` was from a different (foreign) PDF document. If you want to copy pages from one PDFDocument to another, you must use `PDFDocument.copyPages(...)` to copy the pages before adding or inserting them.";return r=t.call(this,n)||this,r}return e})(Error),jC=(function(t){se(e,t);function e(){var r=this,n="PDFDocument has no pages so `PDFDocument.removePage` cannot be called";return r=t.call(this,n)||this,r}return e})(Error),VC=(function(t){se(e,t);function e(r){var n=this,i='PDFDocument has no form field with the name "'+r+'"';return n=t.call(this,i)||this,n}return e})(Error),ii=(function(t){se(e,t);function e(r,n,i){var a,o,s=this,u=n?.name,f=(o=(a=i?.constructor)===null||a===void 0?void 0:a.name)!==null&&o!==void 0?o:i,l='Expected field "'+r+'" to be of type '+u+", "+("but it is actually of type "+f);return s=t.call(this,l)||this,s}return e})(Error);(function(t){se(e,t);function e(r){var n=this,i='Failed to select check box due to missing onValue: "'+r+'"';return n=t.call(this,i)||this,n}return e})(Error);var C1=(function(t){se(e,t);function e(r){var n=this,i='A field already exists with the specified name: "'+r+'"';return n=t.call(this,i)||this,n}return e})(Error),qC=(function(t){se(e,t);function e(r){var n=this,i='Field name contains invalid component: "'+r+'"';return n=t.call(this,i)||this,n}return e})(Error);(function(t){se(e,t);function e(r){var n=this,i='A non-terminal field already exists with the specified name: "'+r+'"';return n=t.call(this,i)||this,n}return e})(Error);var WC=(function(t){se(e,t);function e(r){var n=this,i="Reading rich text fields is not supported: Attempted to read rich text field: "+r;return n=t.call(this,i)||this,n}return e})(Error),GC=(function(t){se(e,t);function e(r,n){var i=this,a="Failed to layout combed text as lineLength="+r+" is greater than cellCount="+n;return i=t.call(this,a)||this,i}return e})(Error),HC=(function(t){se(e,t);function e(r,n,i){var a=this,o="Attempted to set text with length="+r+" for TextField with maxLength="+n+" and name="+i;return a=t.call(this,o)||this,a}return e})(Error),KC=(function(t){se(e,t);function e(r,n,i){var a=this,o="Attempted to set maxLength="+n+", which is less than "+r+", the length of this field's current value (name="+i+")";return a=t.call(this,o)||this,a}return e})(Error),Vt;(function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right"})(Vt||(Vt={}));var E1=4,D1=500,T1=function(t,e,r,n){n===void 0&&(n=!1);for(var i=E1;i<D1;){for(var a=0,o=0,s=t.length;o<s;o++){a+=1;for(var u=t[o],f=u.split(" "),l=r.width,h=0,d=f.length;h<d;h++){var v=h===d-1,g=v?f[h]:f[h]+" ",b=e.widthOfTextAtSize(g,i);l-=b,l<=0&&(a+=1,l=r.width-b)}}if(!n&&a>t.length)return i-1;var w=e.heightAtSize(i),x=w+w*.2,T=x*a;if(T>Math.abs(r.height))return i-1;i+=1}return i},XC=function(t,e,r,n){for(var i=r.width/n,a=r.height,o=E1,s=vA(t);o<D1;){for(var u=0,f=s.length;u<f;u++){var l=s[u],h=e.widthOfTextAtSize(l,o)>i*.75;if(h)return o-1}var d=e.heightAtSize(o,{descender:!1});if(d>a)return o-1;o+=1}return o},ZC=function(t){for(var e=t.length;e>0;e--)if(/\s/.test(t[e]))return e},YC=function(t,e,r,n){for(var i,a=t.length;a>0;){var o=t.substring(0,a),s=r.encodeText(o),u=r.widthOfTextAtSize(o,n);if(u<e){var f=t.substring(a)||void 0;return{line:o,encoded:s,width:u,remainder:f}}a=(i=ZC(o))!==null&&i!==void 0?i:0}return{line:t,encoded:r.encodeText(t),width:r.widthOfTextAtSize(t,n),remainder:void 0}},O1=function(t,e){var r=e.alignment,n=e.fontSize,i=e.font,a=e.bounds,o=Pp(vo(t));(n===void 0||n===0)&&(n=T1(o,i,a,!0));for(var s=i.heightAtSize(n),u=s+s*.2,f=[],l=a.x,h=a.y,d=a.x+a.width,v=a.y+a.height,g=a.y+a.height,b=0,w=o.length;b<w;b++)for(var x=o[b];x!==void 0;){var T=YC(x,a.width,i,n),A=T.line,R=T.encoded,P=T.width,I=T.remainder,B=r===Vt.Left?a.x:r===Vt.Center?a.x+a.width/2-P/2:r===Vt.Right?a.x+a.width-P:a.x;g-=u,B<l&&(l=B),g<h&&(h=g),B+P>d&&(d=B+P),g+s>v&&(v=g+s),f.push({text:A,encoded:R,width:P,height:s,x:B,y:g}),x=I?.trim()}return{fontSize:n,lineHeight:u,lines:f,bounds:{x:l,y:h,width:d-l,height:v-h}}},JC=function(t,e){var r=e.fontSize,n=e.font,i=e.bounds,a=e.cellCount,o=Ip(vo(t));if(o.length>a)throw new GC(o.length,a);(r===void 0||r===0)&&(r=XC(o,n,i,a));for(var s=i.width/a,u=n.heightAtSize(r,{descender:!1}),f=i.y+(i.height/2-u/2),l=[],h=i.x,d=i.y,v=i.x+i.width,g=i.y+i.height,b=0,w=0;b<a;){var x=Bp(o,w),T=x[0],A=x[1],R=n.encodeText(T),P=n.widthOfTextAtSize(T,r),I=i.x+(s*b+s/2),B=I-P/2;B<h&&(h=B),f<d&&(d=f),B+P>v&&(v=B+P),f+u>g&&(g=f+u),l.push({text:o,encoded:R,width:P,height:u,x:B,y:f}),b+=1,w+=A}return{fontSize:r,cells:l,bounds:{x:h,y:d,width:v-h,height:g-d}}},ks=function(t,e){var r=e.alignment,n=e.fontSize,i=e.font,a=e.bounds,o=Ip(vo(t));(n===void 0||n===0)&&(n=T1([o],i,a));var s=i.encodeText(o),u=i.widthOfTextAtSize(o,n),f=i.heightAtSize(n,{descender:!1}),l=r===Vt.Left?a.x:r===Vt.Center?a.x+a.width/2-u/2:r===Vt.Right?a.x+a.width-u:a.x,h=a.y+(a.height/2-f/2);return{fontSize:n,line:{text:o,encoded:s,width:u,height:f,x:l,y:h},bounds:{x:l,y:h,width:u,height:f}}},da=function(t){return"normal"in t?t:{normal:t}},QC=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]+(\d*\.\d+|\d+)[\0\t\n\f\r\ ]+Tf/,Gn=function(t){var e,r,n=(e=t.getDefaultAppearance())!==null&&e!==void 0?e:"",i=(r=qc(n,QC).match)!==null&&r!==void 0?r:[],a=Number(i[2]);return isFinite(a)?a:void 0},_C=/(\d*\.\d+|\d+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+(g|rg|k)/,kr=function(t){var e,r=(e=t.getDefaultAppearance())!==null&&e!==void 0?e:"",n=qc(r,_C).match,i=n??[],a=i[1],o=i[2],s=i[3],u=i[4],f=i[5];if(f==="g"&&a)return x1(Number(a));if(f==="rg"&&a&&o&&s)return ft(Number(a),Number(o),Number(s));if(f==="k"&&a&&o&&s&&u)return F1(Number(a),Number(o),Number(s),Number(u))},Pr=function(t,e,r,n){var i;n===void 0&&(n=0);var a=[Ci(e).toString(),il((i=r?.name)!==null&&i!==void 0?i:"dummy__noop",n).toString()].join(`
|
|
82
82
|
`);t.setDefaultAppearance(a)},$C=function(t,e){var r,n,i,a=kr(e),o=kr(t.acroField),s=e.getRectangle(),u=e.getAppearanceCharacteristics(),f=e.getBorderStyle(),l=(r=f?.getWidth())!==null&&r!==void 0?r:0,h=wn(u?.getRotation()),d=Si(s,h),v=d.width,g=d.height,b=Qn(qe(qe({},s),{rotation:h})),w=ft(0,0,0),x=(n=ir(u?.getBorderColor()))!==null&&n!==void 0?n:w,T=ir(u?.getBackgroundColor()),A=ir(u?.getBackgroundColor(),.8),R=(i=a??o)!==null&&i!==void 0?i:w;Pr(a?e:t.acroField,R);var P={x:0+l/2,y:0+l/2,width:v-l,height:g-l,thickness:1.5,borderWidth:l,borderColor:x,markColor:R};return{normal:{on:st(b,Go(qe(qe({},P),{color:T,filled:!0}))),off:st(b,Go(qe(qe({},P),{color:T,filled:!1})))},down:{on:st(b,Go(qe(qe({},P),{color:A,filled:!0}))),off:st(b,Go(qe(qe({},P),{color:A,filled:!1})))}}},eE=function(t,e){var r,n,i,a=kr(e),o=kr(t.acroField),s=e.getRectangle(),u=e.getAppearanceCharacteristics(),f=e.getBorderStyle(),l=(r=f?.getWidth())!==null&&r!==void 0?r:0,h=wn(u?.getRotation()),d=Si(s,h),v=d.width,g=d.height,b=Qn(qe(qe({},s),{rotation:h})),w=ft(0,0,0),x=(n=ir(u?.getBorderColor()))!==null&&n!==void 0?n:w,T=ir(u?.getBackgroundColor()),A=ir(u?.getBackgroundColor(),.8),R=(i=a??o)!==null&&i!==void 0?i:w;Pr(a?e:t.acroField,R);var P={x:v/2,y:g/2,width:v-l,height:g-l,borderWidth:l,borderColor:x,dotColor:R};return{normal:{on:st(b,Ho(qe(qe({},P),{color:T,filled:!0}))),off:st(b,Ho(qe(qe({},P),{color:T,filled:!1})))},down:{on:st(b,Ho(qe(qe({},P),{color:A,filled:!0}))),off:st(b,Ho(qe(qe({},P),{color:A,filled:!1})))}}},tE=function(t,e,r){var n,i,a,o,s,u=kr(e),f=kr(t.acroField),l=Gn(e),h=Gn(t.acroField),d=e.getRectangle(),v=e.getAppearanceCharacteristics(),g=e.getBorderStyle(),b=v?.getCaptions(),w=(n=b?.normal)!==null&&n!==void 0?n:"",x=(a=(i=b?.down)!==null&&i!==void 0?i:w)!==null&&a!==void 0?a:"",T=(o=g?.getWidth())!==null&&o!==void 0?o:0,A=wn(v?.getRotation()),R=Si(d,A),P=R.width,I=R.height,B=Qn(qe(qe({},d),{rotation:A})),j=ft(0,0,0),W=ir(v?.getBorderColor()),N=ir(v?.getBackgroundColor()),V=ir(v?.getBackgroundColor(),.8),Z={x:T,y:T,width:P-T*2,height:I-T*2},U=ks(w,{alignment:Vt.Center,fontSize:l??h,font:r,bounds:Z}),ee=ks(x,{alignment:Vt.Center,fontSize:l??h,font:r,bounds:Z}),Y=Math.min(U.fontSize,ee.fontSize),$=(s=u??f)!==null&&s!==void 0?s:j;Pr(u||l!==void 0?e:t.acroField,$,r,Y);var J={x:0+T/2,y:0+T/2,width:P-T,height:I-T,borderWidth:T,borderColor:W,textColor:$,font:r.name,fontSize:Y};return{normal:st(B,xd(qe(qe({},J),{color:N,textLines:[U.line]}))),down:st(B,xd(qe(qe({},J),{color:V,textLines:[ee.line]})))}},rE=function(t,e,r){var n,i,a,o,s=kr(e),u=kr(t.acroField),f=Gn(e),l=Gn(t.acroField),h=e.getRectangle(),d=e.getAppearanceCharacteristics(),v=e.getBorderStyle(),g=(n=t.getText())!==null&&n!==void 0?n:"",b=(i=v?.getWidth())!==null&&i!==void 0?i:0,w=wn(d?.getRotation()),x=Si(h,w),T=x.width,A=x.height,R=Qn(qe(qe({},h),{rotation:w})),P=ft(0,0,0),I=ir(d?.getBorderColor()),B=ir(d?.getBackgroundColor()),j,W,N=t.isCombed()?0:1,V={x:b+N,y:b+N,width:T-(b+N)*2,height:A-(b+N)*2};if(t.isMultiline()){var Z=O1(g,{alignment:t.getAlignment(),fontSize:f??l,font:r,bounds:V});j=Z.lines,W=Z.fontSize}else if(t.isCombed()){var Z=JC(g,{fontSize:f??l,font:r,bounds:V,cellCount:(a=t.getMaxLength())!==null&&a!==void 0?a:0});j=Z.cells,W=Z.fontSize}else{var Z=ks(g,{alignment:t.getAlignment(),fontSize:f??l,font:r,bounds:V});j=[Z.line],W=Z.fontSize}var U=(o=s??u)!==null&&o!==void 0?o:P;Pr(s||f!==void 0?e:t.acroField,U,r,W);var ee={x:0+b/2,y:0+b/2,width:T-b,height:A-b,borderWidth:b??0,borderColor:I,textColor:U,font:r.name,fontSize:W,color:B,textLines:j,padding:N};return st(R,A1(ee))},nE=function(t,e,r){var n,i,a,o=kr(e),s=kr(t.acroField),u=Gn(e),f=Gn(t.acroField),l=e.getRectangle(),h=e.getAppearanceCharacteristics(),d=e.getBorderStyle(),v=(n=t.getSelected()[0])!==null&&n!==void 0?n:"",g=(i=d?.getWidth())!==null&&i!==void 0?i:0,b=wn(h?.getRotation()),w=Si(l,b),x=w.width,T=w.height,A=Qn(qe(qe({},l),{rotation:b})),R=ft(0,0,0),P=ir(h?.getBorderColor()),I=ir(h?.getBackgroundColor()),B=1,j={x:g+B,y:g+B,width:x-(g+B)*2,height:T-(g+B)*2},W=ks(v,{alignment:Vt.Left,fontSize:u??f,font:r,bounds:j}),N=W.line,V=W.fontSize,Z=(a=o??s)!==null&&a!==void 0?a:R;Pr(o||u!==void 0?e:t.acroField,Z,r,V);var U={x:0+g/2,y:0+g/2,width:x-g,height:T-g,borderWidth:g??0,borderColor:P,textColor:Z,font:r.name,fontSize:V,color:I,textLines:[N],padding:B};return st(A,A1(U))},iE=function(t,e,r){var n,i,a=kr(e),o=kr(t.acroField),s=Gn(e),u=Gn(t.acroField),f=e.getRectangle(),l=e.getAppearanceCharacteristics(),h=e.getBorderStyle(),d=(n=h?.getWidth())!==null&&n!==void 0?n:0,v=wn(l?.getRotation()),g=Si(f,v),b=g.width,w=g.height,x=Qn(qe(qe({},f),{rotation:v})),T=ft(0,0,0),A=ir(l?.getBorderColor()),R=ir(l?.getBackgroundColor()),P=t.getOptions(),I=t.getSelected();t.isSorted()&&P.sort();for(var B="",j=0,W=P.length;j<W;j++)B+=P[j],j<W-1&&(B+=`
|
|
83
83
|
`);for(var N=1,V={x:d+N,y:d+N,width:b-(d+N)*2,height:w-(d+N)*2},Z=O1(B,{alignment:Vt.Left,fontSize:s??u,font:r,bounds:V}),U=Z.lines,ee=Z.fontSize,Y=Z.lineHeight,$=[],j=0,W=U.length;j<W;j++){var J=U[j];I.includes(J.text)&&$.push(j)}var ce=ft(153/255,193/255,218/255),de=(i=a??o)!==null&&i!==void 0?i:T;return Pr(a||s!==void 0?e:t.acroField,de,r,ee),st(x,LC({x:0+d/2,y:0+d/2,width:b-d,height:w-d,borderWidth:d??0,borderColor:A,textColor:de,font:r.name,fontSize:ee,color:R,textLines:U,lineHeight:Y,selectedColor:ce,selectedLines:$,padding:N}))},k1=(function(){function t(e,r,n){this.alreadyEmbedded=!1,q(e,"ref",[[pt,"PDFRef"]]),q(r,"doc",[[Hn,"PDFDocument"]]),q(n,"embedder",[[t1,"PDFPageEmbedder"]]),this.ref=e,this.doc=r,this.width=n.width,this.height=n.height,this.embedder=n}return t.prototype.scale=function(e){return q(e,"factor",["number"]),{width:this.width*e,height:this.height*e}},t.prototype.size=function(){return this.scale(1)},t.prototype.embed=function(){return Ze(this,void 0,void 0,function(){return Ye(this,function(e){switch(e.label){case 0:return this.alreadyEmbedded?[3,2]:[4,this.embedder.embedIntoContext(this.doc.context,this.ref)];case 1:e.sent(),this.alreadyEmbedded=!0,e.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})(),gr=(function(){function t(e,r,n){this.modified=!0,q(e,"ref",[[pt,"PDFRef"]]),q(r,"doc",[[Hn,"PDFDocument"]]),q(n,"embedder",[[Yc,"CustomFontEmbedder"],[Fs,"StandardFontEmbedder"]]),this.ref=e,this.doc=r,this.name=n.fontName,this.embedder=n}return t.prototype.encodeText=function(e){return q(e,"text",["string"]),this.modified=!0,this.embedder.encodeText(e)},t.prototype.widthOfTextAtSize=function(e,r){return q(e,"text",["string"]),q(r,"size",["number"]),this.embedder.widthOfTextAtSize(e,r)},t.prototype.heightAtSize=function(e,r){var n;return q(e,"size",["number"]),oe(r?.descender,"options.descender",["boolean"]),this.embedder.heightOfFontAtSize(e,{descender:(n=r?.descender)!==null&&n!==void 0?n:!0})},t.prototype.sizeAtHeight=function(e){return q(e,"height",["number"]),this.embedder.sizeOfFontAtHeight(e)},t.prototype.getCharacterSet=function(){return this.embedder instanceof Fs?this.embedder.encoding.supportedCodePoints:this.embedder.font.characterSet},t.prototype.embed=function(){return Ze(this,void 0,void 0,function(){return Ye(this,function(e){switch(e.label){case 0:return this.modified?[4,this.embedder.embedIntoContext(this.doc.context,this.ref)]:[3,2];case 1:e.sent(),this.modified=!1,e.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})(),Yf=(function(){function t(e,r,n){q(e,"ref",[[pt,"PDFRef"]]),q(r,"doc",[[Hn,"PDFDocument"]]),q(n,"embedder",[[Qp,"JpegEmbedder"],[_p,"PngEmbedder"]]),this.ref=e,this.doc=r,this.width=n.width,this.height=n.height,this.embedder=n}return t.prototype.scale=function(e){return q(e,"factor",["number"]),{width:this.width*e,height:this.height*e}},t.prototype.scaleToFit=function(e,r){q(e,"width",["number"]),q(r,"height",["number"]);var n=e/this.width,i=r/this.height,a=Math.min(n,i);return this.scale(a)},t.prototype.size=function(){return this.scale(1)},t.prototype.embed=function(){return Ze(this,void 0,void 0,function(){var e,r,n;return Ye(this,function(i){switch(i.label){case 0:return this.embedder?(this.embedTask||(e=this,r=e.doc,n=e.ref,this.embedTask=this.embedder.embedIntoContext(r.context,n)),[4,this.embedTask]):[2];case 1:return i.sent(),this.embedder=void 0,[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})(),zn;(function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right"})(zn||(zn={}));var va=function(t){oe(t?.x,"options.x",["number"]),oe(t?.y,"options.y",["number"]),oe(t?.width,"options.width",["number"]),oe(t?.height,"options.height",["number"]),oe(t?.textColor,"options.textColor",[[Object,"Color"]]),oe(t?.backgroundColor,"options.backgroundColor",[[Object,"Color"]]),oe(t?.borderColor,"options.borderColor",[[Object,"Color"]]),oe(t?.borderWidth,"options.borderWidth",["number"]),oe(t?.rotate,"options.rotate",[[Object,"Rotation"]])},Ei=(function(){function t(e,r,n){q(e,"acroField",[[la,"PDFAcroTerminal"]]),q(r,"ref",[[pt,"PDFRef"]]),q(n,"doc",[[Hn,"PDFDocument"]]),this.acroField=e,this.ref=r,this.doc=n}return t.prototype.getName=function(){var e;return(e=this.acroField.getFullyQualifiedName())!==null&&e!==void 0?e:""},t.prototype.isReadOnly=function(){return this.acroField.hasFlag(Lr.ReadOnly)},t.prototype.enableReadOnly=function(){this.acroField.setFlagTo(Lr.ReadOnly,!0)},t.prototype.disableReadOnly=function(){this.acroField.setFlagTo(Lr.ReadOnly,!1)},t.prototype.isRequired=function(){return this.acroField.hasFlag(Lr.Required)},t.prototype.enableRequired=function(){this.acroField.setFlagTo(Lr.Required,!0)},t.prototype.disableRequired=function(){this.acroField.setFlagTo(Lr.Required,!1)},t.prototype.isExported=function(){return!this.acroField.hasFlag(Lr.NoExport)},t.prototype.enableExporting=function(){this.acroField.setFlagTo(Lr.NoExport,!1)},t.prototype.disableExporting=function(){this.acroField.setFlagTo(Lr.NoExport,!0)},t.prototype.needsAppearancesUpdate=function(){throw new Er(this.constructor.name,"needsAppearancesUpdate")},t.prototype.defaultUpdateAppearances=function(e){throw new Er(this.constructor.name,"defaultUpdateAppearances")},t.prototype.markAsDirty=function(){this.doc.getForm().markFieldAsDirty(this.ref)},t.prototype.markAsClean=function(){this.doc.getForm().markFieldAsClean(this.ref)},t.prototype.isDirty=function(){return this.doc.getForm().fieldIsDirty(this.ref)},t.prototype.createWidget=function(e){var r,n=e.textColor,i=e.backgroundColor,a=e.borderColor,o=e.borderWidth,s=h1(e.rotate),u=e.caption,f=e.x,l=e.y,h=e.width+o,d=e.height+o,v=!!e.hidden,g=e.page;Gp(s,"degreesAngle",90);var b=Kf.create(this.doc.context,this.ref),w=vC({x:f,y:l,width:h,height:d},o,s);b.setRectangle(w),g&&b.setP(g);var x=b.getOrCreateAppearanceCharacteristics();i&&x.setBackgroundColor(yd(i)),x.setRotation(s),u&&x.setCaptions({normal:u}),a&&x.setBorderColor(yd(a));var T=b.getOrCreateBorderStyle();if(o!==void 0&&T.setWidth(o),b.setFlagTo(Ga.Print,!0),b.setFlagTo(Ga.Hidden,v),b.setFlagTo(Ga.Invisible,!1),n){var A=(r=this.acroField.getDefaultAppearance())!==null&&r!==void 0?r:"",R=A+`
|
|
84
|
-
`+Ci(n).toString();this.acroField.setDefaultAppearance(R)}return b},t.prototype.updateWidgetAppearanceWithFont=function(e,r,n){var i=n.normal,a=n.rollover,o=n.down;this.updateWidgetAppearances(e,{normal:this.createAppearanceStream(e,i,r),rollover:a&&this.createAppearanceStream(e,a,r),down:o&&this.createAppearanceStream(e,o,r)})},t.prototype.updateOnOffWidgetAppearance=function(e,r,n){var i=n.normal,a=n.rollover,o=n.down;this.updateWidgetAppearances(e,{normal:this.createAppearanceDict(e,i,r),rollover:a&&this.createAppearanceDict(e,a,r),down:o&&this.createAppearanceDict(e,o,r)})},t.prototype.updateWidgetAppearances=function(e,r){var n=r.normal,i=r.rollover,a=r.down;e.setNormalAppearance(n),i?e.setRolloverAppearance(i):e.removeRolloverAppearance(),a?e.setDownAppearance(a):e.removeDownAppearance()},t.prototype.createAppearanceStream=function(e,r,n){var i,a=this.acroField.dict.context,o=e.getRectangle(),s=o.width,u=o.height,f=n&&{Font:(i={},i[n.name]=n.ref,i)},l=a.formXObject(r,{Resources:f,BBox:a.obj([0,0,s,u]),Matrix:a.obj([1,0,0,1,0,0])}),h=a.register(l);return h},t.prototype.createImageAppearanceStream=function(e,r,n){var i,a,o=this.acroField.dict.context,s=e.getRectangle(),u=e.getAppearanceCharacteristics(),f=e.getBorderStyle(),l=(a=f?.getWidth())!==null&&a!==void 0?a:0,h=wn(u?.getRotation()),d=Qn(qe(qe({},s),{rotation:h})),v=Si(s,h),g=r.scaleToFit(v.width-l*2,v.height-l*2),b={x:l,y:l,width:g.width,height:g.height,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)};n===zn.Center?(b.x+=(v.width-l*2)/2-g.width/2,b.y+=(v.height-l*2)/2-g.height/2):n===zn.Right&&(b.x=v.width-l-g.width,b.y=v.height-l-g.height);var w=this.doc.context.addRandomSuffix("Image",10),x=st(d,S1(w,b)),T={XObject:(i={},i[w]=r.ref,i)},A=o.formXObject(x,{Resources:T,BBox:o.obj([0,0,s.width,s.height]),Matrix:o.obj([1,0,0,1,0,0])});return o.register(A)},t.prototype.createAppearanceDict=function(e,r,n){var i=this.acroField.dict.context,a=this.createAppearanceStream(e,r.on),o=this.createAppearanceStream(e,r.off),s=i.obj({});return s.set(n,a),s.set(O.of("Off"),o),s},t})(),Ba=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroCheckBox",[[ru,"PDFAcroCheckBox"]]),a.acroField=r,a}return e.prototype.check=function(){var r,n=(r=this.acroField.getOnValue())!==null&&r!==void 0?r:O.of("Yes");this.markAsDirty(),this.acroField.setValue(n)},e.prototype.uncheck=function(){this.markAsDirty(),this.acroField.setValue(O.of("Off"))},e.prototype.isChecked=function(){var r=this.acroField.getOnValue();return!!r&&r===this.acroField.getValue()},e.prototype.addToPage=function(r,n){var i,a,o,s,u,f;q(r,"page",[[Cr,"PDFPage"]]),va(n),n||(n={}),"textColor"in n||(n.textColor=ft(0,0,0)),"backgroundColor"in n||(n.backgroundColor=ft(1,1,1)),"borderColor"in n||(n.borderColor=ft(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var l=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:50,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,rotate:(f=n.rotate)!==null&&f!==void 0?f:Me(0),hidden:n.hidden,page:r.ref}),h=this.doc.context.register(l.dict);this.acroField.addWidget(h),l.setAppearanceState(O.of("Off")),this.updateWidgetAppearance(l,O.of("Yes")),r.node.addAnnot(h)},e.prototype.needsAppearancesUpdate=function(){for(var r,n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getAppearanceState(),u=(r=o.getAppearances())===null||r===void 0?void 0:r.normal;if(!(u instanceof Ke)||s&&!u.has(s))return!0}return!1},e.prototype.defaultUpdateAppearances=function(){this.updateAppearances()},e.prototype.updateAppearances=function(r){var n;oe(r,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a],u=(n=s.getOnValue())!==null&&n!==void 0?n:O.of("Yes");u&&this.updateWidgetAppearance(s,u,r)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??$C,o=da(a(this,r));this.updateOnOffWidgetAppearance(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),es=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroComboBox",[[nu,"PDFAcroComboBox"]]),a.acroField=r,a}return e.prototype.getOptions=function(){for(var r=this.acroField.getOptions(),n=new Array(r.length),i=0,a=n.length;i<a;i++){var o=r[i],s=o.display,u=o.value;n[i]=(s??u).decodeText()}return n},e.prototype.getSelected=function(){for(var r=this.acroField.getValues(),n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n},e.prototype.setOptions=function(r){q(r,"options",[Array]);for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]={value:Ie.fromText(r[i])};this.acroField.setOptions(n)},e.prototype.addOptions=function(r){q(r,"options",["string",Array]);for(var n=Array.isArray(r)?r:[r],i=this.acroField.getOptions(),a=new Array(n.length),o=0,s=n.length;o<s;o++)a[o]={value:Ie.fromText(n[o])};this.acroField.setOptions(i.concat(a))},e.prototype.select=function(r,n){n===void 0&&(n=!1),q(r,"options",["string",Array]),q(n,"merge",["boolean"]);var i=Array.isArray(r)?r:[r],a=this.getOptions(),o=i.find(function(h){return!a.includes(h)});o&&this.enableEditing(),this.markAsDirty(),(i.length>1||i.length===1&&n)&&this.enableMultiselect();for(var s=new Array(i.length),u=0,f=i.length;u<f;u++)s[u]=Ie.fromText(i[u]);if(n){var l=this.acroField.getValues();this.acroField.setValues(l.concat(s))}else this.acroField.setValues(s)},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValues([])},e.prototype.setFontSize=function(r){eu(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isEditable=function(){return this.acroField.hasFlag(dt.Edit)},e.prototype.enableEditing=function(){this.acroField.setFlagTo(dt.Edit,!0)},e.prototype.disableEditing=function(){this.acroField.setFlagTo(dt.Edit,!1)},e.prototype.isSorted=function(){return this.acroField.hasFlag(dt.Sort)},e.prototype.enableSorting=function(){this.acroField.setFlagTo(dt.Sort,!0)},e.prototype.disableSorting=function(){this.acroField.setFlagTo(dt.Sort,!1)},e.prototype.isMultiselect=function(){return this.acroField.hasFlag(dt.MultiSelect)},e.prototype.enableMultiselect=function(){this.acroField.setFlagTo(dt.MultiSelect,!0)},e.prototype.disableMultiselect=function(){this.acroField.setFlagTo(dt.MultiSelect,!1)},e.prototype.isSpellChecked=function(){return!this.acroField.hasFlag(dt.DoNotSpellCheck)},e.prototype.enableSpellChecking=function(){this.acroField.setFlagTo(dt.DoNotSpellCheck,!1)},e.prototype.disableSpellChecking=function(){this.acroField.setFlagTo(dt.DoNotSpellCheck,!0)},e.prototype.isSelectOnClick=function(){return this.acroField.hasFlag(dt.CommitOnSelChange)},e.prototype.enableSelectOnClick=function(){this.acroField.setFlagTo(dt.CommitOnSelChange,!0)},e.prototype.disableSelectOnClick=function(){this.acroField.setFlagTo(dt.CommitOnSelChange,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,u,f,l;q(r,"page",[[Cr,"PDFPage"]]),va(n),n||(n={}),"textColor"in n||(n.textColor=ft(0,0,0)),"backgroundColor"in n||(n.backgroundColor=ft(1,1,1)),"borderColor"in n||(n.borderColor=ft(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var h=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,rotate:(f=n.rotate)!==null&&f!==void 0?f:Me(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(h.dict);this.acroField.addWidget(d);var v=(l=n.font)!==null&&l!==void 0?l:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(h,v),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof vr;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){q(r,"font",[[gr,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){q(r,"font",[[gr,"PDFFont"]]),oe(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??nE,o=da(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),ts=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroListBox",[[su,"PDFAcroListBox"]]),a.acroField=r,a}return e.prototype.getOptions=function(){for(var r=this.acroField.getOptions(),n=new Array(r.length),i=0,a=n.length;i<a;i++){var o=r[i],s=o.display,u=o.value;n[i]=(s??u).decodeText()}return n},e.prototype.getSelected=function(){for(var r=this.acroField.getValues(),n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n},e.prototype.setOptions=function(r){q(r,"options",[Array]),this.markAsDirty();for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]={value:Ie.fromText(r[i])};this.acroField.setOptions(n)},e.prototype.addOptions=function(r){q(r,"options",["string",Array]),this.markAsDirty();for(var n=Array.isArray(r)?r:[r],i=this.acroField.getOptions(),a=new Array(n.length),o=0,s=n.length;o<s;o++)a[o]={value:Ie.fromText(n[o])};this.acroField.setOptions(i.concat(a))},e.prototype.select=function(r,n){n===void 0&&(n=!1),q(r,"options",["string",Array]),q(n,"merge",["boolean"]);var i=Array.isArray(r)?r:[r],a=this.getOptions();r5(i,"option",a),this.markAsDirty(),(i.length>1||i.length===1&&n)&&this.enableMultiselect();for(var o=new Array(i.length),s=0,u=i.length;s<u;s++)o[s]=Ie.fromText(i[s]);if(n){var f=this.acroField.getValues();this.acroField.setValues(f.concat(o))}else this.acroField.setValues(o)},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValues([])},e.prototype.setFontSize=function(r){eu(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isSorted=function(){return this.acroField.hasFlag(dt.Sort)},e.prototype.enableSorting=function(){this.acroField.setFlagTo(dt.Sort,!0)},e.prototype.disableSorting=function(){this.acroField.setFlagTo(dt.Sort,!1)},e.prototype.isMultiselect=function(){return this.acroField.hasFlag(dt.MultiSelect)},e.prototype.enableMultiselect=function(){this.acroField.setFlagTo(dt.MultiSelect,!0)},e.prototype.disableMultiselect=function(){this.acroField.setFlagTo(dt.MultiSelect,!1)},e.prototype.isSelectOnClick=function(){return this.acroField.hasFlag(dt.CommitOnSelChange)},e.prototype.enableSelectOnClick=function(){this.acroField.setFlagTo(dt.CommitOnSelChange,!0)},e.prototype.disableSelectOnClick=function(){this.acroField.setFlagTo(dt.CommitOnSelChange,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,u,f,l;q(r,"page",[[Cr,"PDFPage"]]),va(n),n||(n={}),"textColor"in n||(n.textColor=ft(0,0,0)),"backgroundColor"in n||(n.backgroundColor=ft(1,1,1)),"borderColor"in n||(n.borderColor=ft(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var h=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:100,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,rotate:(f=n.rotate)!==null&&f!==void 0?f:Me(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(h.dict);this.acroField.addWidget(d);var v=(l=n.font)!==null&&l!==void 0?l:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(h,v),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof vr;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){q(r,"font",[[gr,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){q(r,"font",[[gr,"PDFFont"]]),oe(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??iE,o=da(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),Ra=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroRadioButton",[[ou,"PDFAcroRadioButton"]]),a.acroField=r,a}return e.prototype.getOptions=function(){var r=this.acroField.getExportValues();if(r){for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n}for(var o=this.acroField.getOnValues(),s=new Array(o.length),i=0,a=s.length;i<a;i++)s[i]=o[i].decodeText();return s},e.prototype.getSelected=function(){var r=this.acroField.getValue();if(r!==O.of("Off")){var n=this.acroField.getExportValues();if(n){for(var i=this.acroField.getOnValues(),a=0,o=i.length;a<o;a++)if(i[a]===r)return n[a].decodeText()}return r.decodeText()}},e.prototype.select=function(r){q(r,"option",["string"]);var n=this.getOptions();Bn(r,"option",n),this.markAsDirty();var i=this.acroField.getOnValues(),a=this.acroField.getExportValues();if(a)for(var o=0,s=a.length;o<s;o++)a[o].decodeText()===r&&this.acroField.setValue(i[o]);else for(var o=0,s=i.length;o<s;o++){var u=i[o];u.decodeText()===r&&this.acroField.setValue(u)}},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValue(O.of("Off"))},e.prototype.isOffToggleable=function(){return!this.acroField.hasFlag(Ar.NoToggleToOff)},e.prototype.enableOffToggling=function(){this.acroField.setFlagTo(Ar.NoToggleToOff,!1)},e.prototype.disableOffToggling=function(){this.acroField.setFlagTo(Ar.NoToggleToOff,!0)},e.prototype.isMutuallyExclusive=function(){return!this.acroField.hasFlag(Ar.RadiosInUnison)},e.prototype.enableMutualExclusion=function(){this.acroField.setFlagTo(Ar.RadiosInUnison,!1)},e.prototype.disableMutualExclusion=function(){this.acroField.setFlagTo(Ar.RadiosInUnison,!0)},e.prototype.addOptionToPage=function(r,n,i){var a,o,s,u,f,l,h,d,v;q(r,"option",["string"]),q(n,"page",[[Cr,"PDFPage"]]),va(i);var g=this.createWidget({x:(a=i?.x)!==null&&a!==void 0?a:0,y:(o=i?.y)!==null&&o!==void 0?o:0,width:(s=i?.width)!==null&&s!==void 0?s:50,height:(u=i?.height)!==null&&u!==void 0?u:50,textColor:(f=i?.textColor)!==null&&f!==void 0?f:ft(0,0,0),backgroundColor:(l=i?.backgroundColor)!==null&&l!==void 0?l:ft(1,1,1),borderColor:(h=i?.borderColor)!==null&&h!==void 0?h:ft(0,0,0),borderWidth:(d=i?.borderWidth)!==null&&d!==void 0?d:1,rotate:(v=i?.rotate)!==null&&v!==void 0?v:Me(0),hidden:i?.hidden,page:n.ref}),b=this.doc.context.register(g.dict),w=this.acroField.addWidgetWithOpt(b,Ie.fromText(r),!this.isMutuallyExclusive());g.setAppearanceState(O.of("Off")),this.updateWidgetAppearance(g,w),n.node.addAnnot(b)},e.prototype.needsAppearancesUpdate=function(){for(var r,n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getAppearanceState(),u=(r=o.getAppearances())===null||r===void 0?void 0:r.normal;if(!(u instanceof Ke)||s&&!u.has(s))return!0}return!1},e.prototype.defaultUpdateAppearances=function(){this.updateAppearances()},e.prototype.updateAppearances=function(r){oe(r,"provider",[Function]);for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getOnValue();s&&this.updateWidgetAppearance(o,s,r)}},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??eE,o=da(a(this,r));this.updateOnOffWidgetAppearance(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),Jf=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroSignature",[[Qc,"PDFAcroSignature"]]),a.acroField=r,a}return e.prototype.needsAppearancesUpdate=function(){return!1},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),rs=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroText",[[iu,"PDFAcroText"]]),a.acroField=r,a}return e.prototype.getText=function(){var r=this.acroField.getValue();if(!r&&this.isRichFormatted())throw new WC(this.getName());return r?.decodeText()},e.prototype.setText=function(r){oe(r,"text",["string"]);var n=this.getMaxLength();if(n!==void 0&&r&&r.length>n)throw new HC(r.length,n,this.getName());this.markAsDirty(),this.disableRichFormatting(),r?this.acroField.setValue(Ie.fromText(r)):this.acroField.removeValue()},e.prototype.getAlignment=function(){var r=this.acroField.getQuadding();return r===0?Vt.Left:r===1?Vt.Center:r===2?Vt.Right:Vt.Left},e.prototype.setAlignment=function(r){Bn(r,"alignment",Vt),this.markAsDirty(),this.acroField.setQuadding(r)},e.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},e.prototype.setMaxLength=function(r){if(Mr(r,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),r===void 0)this.acroField.removeMaxLength();else{var n=this.getText();if(n&&n.length>r)throw new KC(n.length,r,this.getName());this.acroField.setMaxLength(r)}},e.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},e.prototype.setImage=function(r){for(var n=this.getAlignment(),i=n===Vt.Center?zn.Center:n===Vt.Right?zn.Right:zn.Left,a=this.acroField.getWidgets(),o=0,s=a.length;o<s;o++){var u=a[o],f=this.createImageAppearanceStream(u,r,i);this.updateWidgetAppearances(u,{normal:f})}this.markAsClean()},e.prototype.setFontSize=function(r){eu(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isMultiline=function(){return this.acroField.hasFlag(Tt.Multiline)},e.prototype.enableMultiline=function(){this.markAsDirty(),this.acroField.setFlagTo(Tt.Multiline,!0)},e.prototype.disableMultiline=function(){this.markAsDirty(),this.acroField.setFlagTo(Tt.Multiline,!1)},e.prototype.isPassword=function(){return this.acroField.hasFlag(Tt.Password)},e.prototype.enablePassword=function(){this.acroField.setFlagTo(Tt.Password,!0)},e.prototype.disablePassword=function(){this.acroField.setFlagTo(Tt.Password,!1)},e.prototype.isFileSelector=function(){return this.acroField.hasFlag(Tt.FileSelect)},e.prototype.enableFileSelection=function(){this.acroField.setFlagTo(Tt.FileSelect,!0)},e.prototype.disableFileSelection=function(){this.acroField.setFlagTo(Tt.FileSelect,!1)},e.prototype.isSpellChecked=function(){return!this.acroField.hasFlag(Tt.DoNotSpellCheck)},e.prototype.enableSpellChecking=function(){this.acroField.setFlagTo(Tt.DoNotSpellCheck,!1)},e.prototype.disableSpellChecking=function(){this.acroField.setFlagTo(Tt.DoNotSpellCheck,!0)},e.prototype.isScrollable=function(){return!this.acroField.hasFlag(Tt.DoNotScroll)},e.prototype.enableScrolling=function(){this.acroField.setFlagTo(Tt.DoNotScroll,!1)},e.prototype.disableScrolling=function(){this.acroField.setFlagTo(Tt.DoNotScroll,!0)},e.prototype.isCombed=function(){return this.acroField.hasFlag(Tt.Comb)&&!this.isMultiline()&&!this.isPassword()&&!this.isFileSelector()&&this.getMaxLength()!==void 0},e.prototype.enableCombing=function(){if(this.getMaxLength()===void 0){var r="PDFTextFields must have a max length in order to be combed";console.warn(r)}this.markAsDirty(),this.disableMultiline(),this.disablePassword(),this.disableFileSelection(),this.acroField.setFlagTo(Tt.Comb,!0)},e.prototype.disableCombing=function(){this.markAsDirty(),this.acroField.setFlagTo(Tt.Comb,!1)},e.prototype.isRichFormatted=function(){return this.acroField.hasFlag(Tt.RichText)},e.prototype.enableRichFormatting=function(){this.acroField.setFlagTo(Tt.RichText,!0)},e.prototype.disableRichFormatting=function(){this.acroField.setFlagTo(Tt.RichText,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,u,f,l;q(r,"page",[[Cr,"PDFPage"]]),va(n),n||(n={}),"textColor"in n||(n.textColor=ft(0,0,0)),"backgroundColor"in n||(n.backgroundColor=ft(1,1,1)),"borderColor"in n||(n.borderColor=ft(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var h=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,rotate:(f=n.rotate)!==null&&f!==void 0?f:Me(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(h.dict);this.acroField.addWidget(d);var v=(l=n.font)!==null&&l!==void 0?l:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(h,v),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof vr;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){q(r,"font",[[gr,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){q(r,"font",[[gr,"PDFFont"]]),oe(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??rE,o=da(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),io;(function(t){t.Courier="Courier",t.CourierBold="Courier-Bold",t.CourierOblique="Courier-Oblique",t.CourierBoldOblique="Courier-BoldOblique",t.Helvetica="Helvetica",t.HelveticaBold="Helvetica-Bold",t.HelveticaOblique="Helvetica-Oblique",t.HelveticaBoldOblique="Helvetica-BoldOblique",t.TimesRoman="Times-Roman",t.TimesRomanBold="Times-Bold",t.TimesRomanItalic="Times-Italic",t.TimesRomanBoldItalic="Times-BoldItalic",t.Symbol="Symbol",t.ZapfDingbats="ZapfDingbats"})(io||(io={}));var aE=(function(){function t(e,r){var n=this;this.embedDefaultFont=function(){return n.doc.embedStandardFont(io.Helvetica)},q(e,"acroForm",[[Cs,"PDFAcroForm"]]),q(r,"doc",[[Hn,"PDFDocument"]]),this.acroForm=e,this.doc=r,this.dirtyFields=new Set,this.defaultFontCache=dn.populatedBy(this.embedDefaultFont)}return t.prototype.hasXFA=function(){return this.acroForm.dict.has(O.of("XFA"))},t.prototype.deleteXFA=function(){this.acroForm.dict.delete(O.of("XFA"))},t.prototype.getFields=function(){for(var e=this.acroForm.getAllFields(),r=[],n=0,i=e.length;n<i;n++){var a=e[n],o=a[0],s=a[1],u=oE(o,s,this.doc);u&&r.push(u)}return r},t.prototype.getFieldMaybe=function(e){q(e,"name",["string"]);for(var r=this.getFields(),n=0,i=r.length;n<i;n++){var a=r[n];if(a.getName()===e)return a}},t.prototype.getField=function(e){q(e,"name",["string"]);var r=this.getFieldMaybe(e);if(r)return r;throw new VC(e)},t.prototype.getButton=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof ns)return r;throw new ii(e,ns,r)},t.prototype.getCheckBox=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof Ba)return r;throw new ii(e,Ba,r)},t.prototype.getDropdown=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof es)return r;throw new ii(e,es,r)},t.prototype.getOptionList=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof ts)return r;throw new ii(e,ts,r)},t.prototype.getRadioGroup=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof Ra)return r;throw new ii(e,Ra,r)},t.prototype.getSignature=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof Jf)return r;throw new ii(e,Jf,r)},t.prototype.getTextField=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof rs)return r;throw new ii(e,rs,r)},t.prototype.createButton=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=au.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),ns.of(i,i.ref,this.doc)},t.prototype.createCheckBox=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=ru.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),Ba.of(i,i.ref,this.doc)},t.prototype.createDropdown=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=nu.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),es.of(i,i.ref,this.doc)},t.prototype.createOptionList=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=su.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),ts.of(i,i.ref,this.doc)},t.prototype.createRadioGroup=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=ou.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),Ra.of(i,i.ref,this.doc)},t.prototype.createTextField=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=iu.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),rs.of(i,i.ref,this.doc)},t.prototype.flatten=function(e){e===void 0&&(e={updateFieldAppearances:!0}),e.updateFieldAppearances&&this.updateFieldAppearances();for(var r=this.getFields(),n=0,i=r.length;n<i;n++){for(var a=r[n],o=a.acroField.getWidgets(),s=0,u=o.length;s<u;s++){var f=o[s],l=this.findWidgetPage(f),h=this.findWidgetAppearanceRef(a,f),d=l.node.newXObject("FlatWidget",h),v=f.getRectangle(),g=st([qt(),Dr(v.x,v.y)],Qn(qe(qe({},v),{rotation:0})),[al(d),Wt()]).filter(Boolean);l.pushOperators.apply(l,g)}this.removeField(a)}},t.prototype.removeField=function(e){for(var r=e.acroField.getWidgets(),n=new Set,i=0,a=r.length;i<a;i++){var o=r[i],s=this.findWidgetAppearanceRef(e,o),u=this.findWidgetPage(o);n.add(u),u.node.removeAnnot(s)}n.forEach(function(v){return v.node.removeAnnot(e.ref)}),this.acroForm.removeField(e.acroField);for(var f=e.acroField.normalizedEntries().Kids,l=f.size(),h=0;h<l;h++){var d=f.get(h);d instanceof pt&&this.doc.context.delete(d)}this.doc.context.delete(e.ref)},t.prototype.updateFieldAppearances=function(e){oe(e,"font",[[gr,"PDFFont"]]),e=e??this.getDefaultFont();for(var r=this.getFields(),n=0,i=r.length;n<i;n++){var a=r[n];a.needsAppearancesUpdate()&&a.defaultUpdateAppearances(e)}},t.prototype.markFieldAsDirty=function(e){oe(e,"fieldRef",[[pt,"PDFRef"]]),this.dirtyFields.add(e)},t.prototype.markFieldAsClean=function(e){oe(e,"fieldRef",[[pt,"PDFRef"]]),this.dirtyFields.delete(e)},t.prototype.fieldIsDirty=function(e){return oe(e,"fieldRef",[[pt,"PDFRef"]]),this.dirtyFields.has(e)},t.prototype.getDefaultFont=function(){return this.defaultFontCache.access()},t.prototype.findWidgetPage=function(e){var r=e.P(),n=this.doc.getPages().find(function(a){return a.ref===r});if(n===void 0){var i=this.doc.context.getObjectRef(e.dict);if(i===void 0)throw new Error("Could not find PDFRef for PDFObject");if(n=this.doc.findPageForAnnotationRef(i),n===void 0)throw new Error("Could not find page for PDFRef "+i)}return n},t.prototype.findWidgetAppearanceRef=function(e,r){var n,i=r.getNormalAppearance();if(i instanceof Ke&&(e instanceof Ba||e instanceof Ra)){var a=e.acroField.getValue(),o=(n=i.get(a))!==null&&n!==void 0?n:i.get(O.of("Off"));o instanceof pt&&(i=o)}if(!(i instanceof pt)){var s=e.getName();throw new Error("Failed to extract appearance ref for: "+s)}return i},t.prototype.findOrCreateNonTerminals=function(e){for(var r=[this.acroForm],n=0,i=e.length;n<i;n++){var a=e[n];if(!a)throw new qC(a);var o=r[0],s=r[1],u=this.findNonTerminal(a,o);if(u)r=u;else{var f=As.create(this.doc.context);f.setPartialName(a),f.setParent(s);var l=this.doc.context.register(f.dict);o.addField(l),r=[f,l]}}return r},t.prototype.findNonTerminal=function(e,r){for(var n=r instanceof Cs?this.acroForm.getFields():_c(r.Kids()),i=0,a=n.length;i<a;i++){var o=n[i],s=o[0],u=o[1];if(s.getPartialName()===e){if(s instanceof As)return[s,u];throw new C1(e)}}},t.of=function(e,r){return new t(e,r)},t})(),oE=function(t,e,r){if(t instanceof au)return ns.of(t,e,r);if(t instanceof ru)return Ba.of(t,e,r);if(t instanceof nu)return es.of(t,e,r);if(t instanceof su)return ts.of(t,e,r);if(t instanceof iu)return rs.of(t,e,r);if(t instanceof ou)return Ra.of(t,e,r);if(t instanceof Qc)return Jf.of(t,e,r)},Ui=function(t){if(t.length===0)throw new Error("PDF field names must not be empty strings");for(var e=t.split("."),r=0,n=e.length;r<n;r++)if(e[r]==="")throw new Error('Periods in PDF field names must be separated by at least one character: "'+t+'"');return e.length===1?{nonTerminal:[],terminal:e[0]}:{nonTerminal:e.slice(0,e.length-1),terminal:e[e.length-1]}},zi=function(t,e,r){for(var n=t[0],i=t[1],a=e[0],o=e[1],s=n.normalizedEntries(),u=_c("Kids"in s?s.Kids:s.Fields),f=0,l=u.length;f<l;f++)if(u[f][0].getPartialName()===r)throw new C1(r);n.addField(o),a.setParent(i)},sE={A4:[595.28,841.89]},Qf;(function(t){t[t.Fastest=1/0]="Fastest",t[t.Fast=1500]="Fast",t[t.Medium=500]="Medium",t[t.Slow=100]="Slow"})(Qf||(Qf={}));var uE=(function(){function t(e,r,n){this.alreadyEmbedded=!1,this.ref=e,this.doc=r,this.embedder=n}return t.prototype.embed=function(){return Ze(this,void 0,void 0,function(){var e,r,n,i,a;return Ye(this,function(o){switch(o.label){case 0:return this.alreadyEmbedded?[3,2]:[4,this.embedder.embedIntoContext(this.doc.context,this.ref)];case 1:e=o.sent(),this.doc.catalog.has(O.of("Names"))||this.doc.catalog.set(O.of("Names"),this.doc.context.obj({})),r=this.doc.catalog.lookup(O.of("Names"),Ke),r.has(O.of("EmbeddedFiles"))||r.set(O.of("EmbeddedFiles"),this.doc.context.obj({})),n=r.lookup(O.of("EmbeddedFiles"),Ke),n.has(O.of("Names"))||n.set(O.of("Names"),this.doc.context.obj([])),i=n.lookup(O.of("Names"),ht),i.push(Ie.fromText(this.embedder.fileName)),i.push(e),this.doc.catalog.has(O.of("AF"))||this.doc.catalog.set(O.of("AF"),this.doc.context.obj([])),a=this.doc.catalog.lookup(O.of("AF"),ht),a.push(e),this.alreadyEmbedded=!0,o.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})(),fE=(function(){function t(e,r,n){this.alreadyEmbedded=!1,this.ref=e,this.doc=r,this.embedder=n}return t.prototype.embed=function(){return Ze(this,void 0,void 0,function(){var e,r,n,i,a,o,s;return Ye(this,function(u){switch(u.label){case 0:return this.alreadyEmbedded?[3,2]:(e=this.doc,r=e.catalog,n=e.context,[4,this.embedder.embedIntoContext(this.doc.context,this.ref)]);case 1:i=u.sent(),r.has(O.of("Names"))||r.set(O.of("Names"),n.obj({})),a=r.lookup(O.of("Names"),Ke),a.has(O.of("JavaScript"))||a.set(O.of("JavaScript"),n.obj({})),o=a.lookup(O.of("JavaScript"),Ke),o.has(O.of("Names"))||o.set(O.of("Names"),n.obj([])),s=o.lookup(O.of("Names"),ht),s.push(Ie.fromText(this.embedder.scriptName)),s.push(i),this.alreadyEmbedded=!0,u.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})(),cE=(function(){function t(e,r){this.script=e,this.scriptName=r}return t.for=function(e,r){return new t(e,r)},t.prototype.embedIntoContext=function(e,r){return Ze(this,void 0,void 0,function(){var n;return Ye(this,function(i){return n=e.obj({Type:"Action",S:"JavaScript",JS:Ie.fromText(this.script)}),r?(e.assign(r,n),[2,r]):[2,e.register(n)]})})},t})(),Hn=(function(){function t(e,r,n){var i=this;if(this.defaultWordBreaks=[" "],this.computePages=function(){var a=[];return i.catalog.Pages().traverse(function(o,s){if(o instanceof vn){var u=i.pageMap.get(o);u||(u=Cr.of(o,s,i),i.pageMap.set(o,u)),a.push(u)}}),a},this.getOrCreateForm=function(){var a=i.catalog.getOrCreateAcroForm();return aE.of(a,i)},q(e,"context",[[Gf,"PDFContext"]]),q(r,"ignoreEncryption",["boolean"]),this.context=e,this.catalog=e.lookup(e.trailerInfo.Root),this.isEncrypted=!!e.lookup(e.trailerInfo.Encrypt),this.pageCache=dn.populatedBy(this.computePages),this.pageMap=new Map,this.formCache=dn.populatedBy(this.getOrCreateForm),this.fonts=[],this.images=[],this.embeddedPages=[],this.embeddedFiles=[],this.javaScripts=[],!r&&this.isEncrypted)throw new NC;n&&this.updateInfoDict()}return t.load=function(e,r){return r===void 0&&(r={}),Ze(this,void 0,void 0,function(){var n,i,a,o,s,u,f,l,h,d,v,g;return Ye(this,function(b){switch(b.label){case 0:return n=r.ignoreEncryption,i=n===void 0?!1:n,a=r.parseSpeed,o=a===void 0?Qf.Slow:a,s=r.throwOnInvalidObject,u=s===void 0?!1:s,f=r.updateMetadata,l=f===void 0?!0:f,h=r.capNumbers,d=h===void 0?!1:h,q(e,"pdf",["string",Uint8Array,ArrayBuffer]),q(i,"ignoreEncryption",["boolean"]),q(o,"parseSpeed",["number"]),q(u,"throwOnInvalidObject",["boolean"]),v=Fa(e),[4,hC.forBytesWithOptions(v,o,u,d).parseDocument()];case 1:return g=b.sent(),[2,new t(g,i,l)]}})})},t.create=function(e){return e===void 0&&(e={}),Ze(this,void 0,void 0,function(){var r,n,i,a,o,s;return Ye(this,function(u){return r=e.updateMetadata,n=r===void 0?!0:r,i=Gf.create(),a=s1.withContext(i),o=i.register(a),s=o1.withContextAndPages(i,o),i.trailerInfo.Root=i.register(s),[2,new t(i,!1,n)]})})},t.prototype.registerFontkit=function(e){this.fontkit=e},t.prototype.getForm=function(){var e=this.formCache.access();return e.hasXFA()&&(console.warn("Removing XFA form data as pdf-lib does not support reading or writing XFA"),e.deleteXFA()),e},t.prototype.getTitle=function(){var e=this.getInfoDict().lookup(O.Title);if(e)return Cn(e),e.decodeText()},t.prototype.getAuthor=function(){var e=this.getInfoDict().lookup(O.Author);if(e)return Cn(e),e.decodeText()},t.prototype.getSubject=function(){var e=this.getInfoDict().lookup(O.Subject);if(e)return Cn(e),e.decodeText()},t.prototype.getKeywords=function(){var e=this.getInfoDict().lookup(O.Keywords);if(e)return Cn(e),e.decodeText()},t.prototype.getCreator=function(){var e=this.getInfoDict().lookup(O.Creator);if(e)return Cn(e),e.decodeText()},t.prototype.getProducer=function(){var e=this.getInfoDict().lookup(O.Producer);if(e)return Cn(e),e.decodeText()},t.prototype.getCreationDate=function(){var e=this.getInfoDict().lookup(O.CreationDate);if(e)return Cn(e),e.decodeDate()},t.prototype.getModificationDate=function(){var e=this.getInfoDict().lookup(O.ModDate);if(e)return Cn(e),e.decodeDate()},t.prototype.setTitle=function(e,r){q(e,"title",["string"]);var n=O.of("Title");if(this.getInfoDict().set(n,Ie.fromText(e)),r?.showInWindowTitleBar){var i=this.catalog.getOrCreateViewerPreferences();i.setDisplayDocTitle(!0)}},t.prototype.setAuthor=function(e){q(e,"author",["string"]);var r=O.of("Author");this.getInfoDict().set(r,Ie.fromText(e))},t.prototype.setSubject=function(e){q(e,"author",["string"]);var r=O.of("Subject");this.getInfoDict().set(r,Ie.fromText(e))},t.prototype.setKeywords=function(e){q(e,"keywords",[Array]);var r=O.of("Keywords");this.getInfoDict().set(r,Ie.fromText(e.join(" ")))},t.prototype.setCreator=function(e){q(e,"creator",["string"]);var r=O.of("Creator");this.getInfoDict().set(r,Ie.fromText(e))},t.prototype.setProducer=function(e){q(e,"creator",["string"]);var r=O.of("Producer");this.getInfoDict().set(r,Ie.fromText(e))},t.prototype.setLanguage=function(e){q(e,"language",["string"]);var r=O.of("Lang");this.catalog.set(r,vt.of(e))},t.prototype.setCreationDate=function(e){q(e,"creationDate",[[Date,"Date"]]);var r=O.of("CreationDate");this.getInfoDict().set(r,vt.fromDate(e))},t.prototype.setModificationDate=function(e){q(e,"modificationDate",[[Date,"Date"]]);var r=O.of("ModDate");this.getInfoDict().set(r,vt.fromDate(e))},t.prototype.getPageCount=function(){return this.pageCount===void 0&&(this.pageCount=this.getPages().length),this.pageCount},t.prototype.getPages=function(){return this.pageCache.access()},t.prototype.getPage=function(e){var r=this.getPages();return lr(e,"index",0,r.length-1),r[e]},t.prototype.getPageIndices=function(){return SA(0,this.getPageCount())},t.prototype.removePage=function(e){var r=this.getPageCount();if(this.pageCount===0)throw new jC;lr(e,"index",0,r-1),this.catalog.removeLeafNode(e),this.pageCount=r-1},t.prototype.addPage=function(e){return q(e,"page",["undefined",[Cr,"PDFPage"],Array]),this.insertPage(this.getPageCount(),e)},t.prototype.insertPage=function(e,r){var n=this.getPageCount();if(lr(e,"index",0,n),q(r,"page",["undefined",[Cr,"PDFPage"],Array]),!r||Array.isArray(r)){var i=Array.isArray(r)?r:sE.A4;r=Cr.create(this),r.setSize.apply(r,i)}else if(r.doc!==this)throw new zC;var a=this.catalog.insertLeafNode(r.ref,e);return r.node.setParent(a),this.pageMap.set(r.node,r),this.pageCache.invalidate(),this.pageCount=n+1,r},t.prototype.copyPages=function(e,r){return Ze(this,void 0,void 0,function(){var n,i,a,o,s,u,f,l;return Ye(this,function(h){switch(h.label){case 0:return q(e,"srcDoc",[[t,"PDFDocument"]]),q(r,"indices",[Array]),[4,e.flush()];case 1:for(h.sent(),n=od.for(e.context,this.context),i=e.getPages(),a=new Array(r.length),o=0,s=r.length;o<s;o++)u=i[r[o]],f=n.copy(u.node),l=this.context.register(f),a[o]=Cr.of(f,l,this);return[2,a]}})})},t.prototype.copy=function(){return Ze(this,void 0,void 0,function(){var e,r,n,i;return Ye(this,function(a){switch(a.label){case 0:return[4,t.create()];case 1:return e=a.sent(),[4,e.copyPages(this,this.getPageIndices())];case 2:for(r=a.sent(),n=0,i=r.length;n<i;n++)e.addPage(r[n]);return this.getAuthor()!==void 0&&e.setAuthor(this.getAuthor()),this.getCreationDate()!==void 0&&e.setCreationDate(this.getCreationDate()),this.getCreator()!==void 0&&e.setCreator(this.getCreator()),this.getModificationDate()!==void 0&&e.setModificationDate(this.getModificationDate()),this.getProducer()!==void 0&&e.setProducer(this.getProducer()),this.getSubject()!==void 0&&e.setSubject(this.getSubject()),this.getTitle()!==void 0&&e.setTitle(this.getTitle()),e.defaultWordBreaks=this.defaultWordBreaks,[2,e]}})})},t.prototype.addJavaScript=function(e,r){q(e,"name",["string"]),q(r,"script",["string"]);var n=cE.for(r,e),i=this.context.nextRef(),a=fE.of(i,this,n);this.javaScripts.push(a)},t.prototype.attach=function(e,r,n){return n===void 0&&(n={}),Ze(this,void 0,void 0,function(){var i,a,o,s;return Ye(this,function(u){return q(e,"attachment",["string",Uint8Array,ArrayBuffer]),q(r,"name",["string"]),oe(n.mimeType,"mimeType",["string"]),oe(n.description,"description",["string"]),oe(n.creationDate,"options.creationDate",[Date]),oe(n.modificationDate,"options.modificationDate",[Date]),br(n.afRelationship,"options.afRelationship",Hf),i=Fa(e),a=U5.for(i,r,n),o=this.context.nextRef(),s=uE.of(o,this,a),this.embeddedFiles.push(s),[2]})})},t.prototype.embedFont=function(e,r){return r===void 0&&(r={}),Ze(this,void 0,void 0,function(){var n,i,a,o,s,u,f,l,h,d;return Ye(this,function(v){switch(v.label){case 0:return n=r.subset,i=n===void 0?!1:n,a=r.customName,o=r.features,q(e,"font",["string",Uint8Array,ArrayBuffer]),q(i,"subset",["boolean"]),Q0(e)?(s=Fs.for(e,a),[3,7]):[3,1];case 1:return CA(e)?(u=Fa(e),f=this.assertFontkit(),i?[4,N5.for(f,u,a,o)]:[3,3]):[3,6];case 2:return l=v.sent(),[3,5];case 3:return[4,Yc.for(f,u,a,o)];case 4:l=v.sent(),v.label=5;case 5:return s=l,[3,7];case 6:throw new TypeError("`font` must be one of `StandardFonts | string | Uint8Array | ArrayBuffer`");case 7:return h=this.context.nextRef(),d=gr.of(h,this,s),this.fonts.push(d),[2,d]}})})},t.prototype.embedStandardFont=function(e,r){if(q(e,"font",["string"]),!Q0(e))throw new TypeError("`font` must be one of type `StandardFonts`");var n=Fs.for(e,r),i=this.context.nextRef(),a=gr.of(i,this,n);return this.fonts.push(a),a},t.prototype.embedJpg=function(e){return Ze(this,void 0,void 0,function(){var r,n,i,a;return Ye(this,function(o){switch(o.label){case 0:return q(e,"jpg",["string",Uint8Array,ArrayBuffer]),r=Fa(e),[4,Qp.for(r)];case 1:return n=o.sent(),i=this.context.nextRef(),a=Yf.of(i,this,n),this.images.push(a),[2,a]}})})},t.prototype.embedPng=function(e){return Ze(this,void 0,void 0,function(){var r,n,i,a;return Ye(this,function(o){switch(o.label){case 0:return q(e,"png",["string",Uint8Array,ArrayBuffer]),r=Fa(e),[4,_p.for(r)];case 1:return n=o.sent(),i=this.context.nextRef(),a=Yf.of(i,this,n),this.images.push(a),[2,a]}})})},t.prototype.embedPdf=function(e,r){return r===void 0&&(r=[0]),Ze(this,void 0,void 0,function(){var n,i,a;return Ye(this,function(o){switch(o.label){case 0:return q(e,"pdf",["string",Uint8Array,ArrayBuffer,[t,"PDFDocument"]]),q(r,"indices",[Array]),e instanceof t?(i=e,[3,3]):[3,1];case 1:return[4,t.load(e)];case 2:i=o.sent(),o.label=3;case 3:return n=i,a=AA(n.getPages(),r),[2,this.embedPages(a)]}})})},t.prototype.embedPage=function(e,r,n){return Ze(this,void 0,void 0,function(){var i;return Ye(this,function(a){switch(a.label){case 0:return q(e,"page",[[Cr,"PDFPage"]]),[4,this.embedPages([e],[r],[n])];case 1:return i=a.sent()[0],[2,i]}})})},t.prototype.embedPages=function(e,r,n){return r===void 0&&(r=[]),n===void 0&&(n=[]),Ze(this,void 0,void 0,function(){var f,l,i,a,o,s,u,f,l,h,d,v,g,b,w;return Ye(this,function(x){switch(x.label){case 0:if(e.length===0)return[2,[]];for(f=0,l=e.length-1;f<l;f++)if(i=e[f],a=e[f+1],i.node.context!==a.node.context)throw new c5;o=e[0].node.context,s=o===this.context?function(T){return T}:od.for(o,this.context).copy,u=new Array(e.length),f=0,l=e.length,x.label=1;case 1:return f<l?(h=s(e[f].node),d=r[f],v=n[f],[4,t1.for(h,d,v)]):[3,4];case 2:g=x.sent(),b=this.context.nextRef(),u[f]=k1.of(b,this,g),x.label=3;case 3:return f++,[3,1];case 4:return(w=this.embeddedPages).push.apply(w,u),[2,u]}})})},t.prototype.flush=function(){return Ze(this,void 0,void 0,function(){return Ye(this,function(e){switch(e.label){case 0:return[4,this.embedAll(this.fonts)];case 1:return e.sent(),[4,this.embedAll(this.images)];case 2:return e.sent(),[4,this.embedAll(this.embeddedPages)];case 3:return e.sent(),[4,this.embedAll(this.embeddedFiles)];case 4:return e.sent(),[4,this.embedAll(this.javaScripts)];case 5:return e.sent(),[2]}})})},t.prototype.save=function(e){return e===void 0&&(e={}),Ze(this,void 0,void 0,function(){var r,n,i,a,o,s,u,f,l,h;return Ye(this,function(d){switch(d.label){case 0:return r=e.useObjectStreams,n=r===void 0?!0:r,i=e.addDefaultPage,a=i===void 0?!0:i,o=e.objectsPerTick,s=o===void 0?50:o,u=e.updateFieldAppearances,f=u===void 0?!0:u,q(n,"useObjectStreams",["boolean"]),q(a,"addDefaultPage",["boolean"]),q(s,"objectsPerTick",["number"]),q(f,"updateFieldAppearances",["boolean"]),a&&this.getPageCount()===0&&this.addPage(),f&&(l=this.formCache.getValue(),l&&l.updateFieldAppearances()),[4,this.flush()];case 1:return d.sent(),h=n?P5:Yp,[2,h.forContext(this.context,s).serializeToBuffer()]}})})},t.prototype.saveAsBase64=function(e){return e===void 0&&(e={}),Ze(this,void 0,void 0,function(){var r,n,i,a,o;return Ye(this,function(s){switch(s.label){case 0:return r=e.dataUri,n=r===void 0?!1:r,i=oA(e,["dataUri"]),q(n,"dataUri",["boolean"]),[4,this.save(i)];case 1:return a=s.sent(),o=sA(a),[2,n?"data:application/pdf;base64,"+o:o]}})})},t.prototype.findPageForAnnotationRef=function(e){for(var r=this.getPages(),n=0,i=r.length;n<i;n++){var a=r[n],o=a.node.Annots();if(o?.indexOf(e)!==void 0)return a}},t.prototype.embedAll=function(e){return Ze(this,void 0,void 0,function(){var r,n;return Ye(this,function(i){switch(i.label){case 0:r=0,n=e.length,i.label=1;case 1:return r<n?[4,e[r].embed()]:[3,4];case 2:i.sent(),i.label=3;case 3:return r++,[3,1];case 4:return[2]}})})},t.prototype.updateInfoDict=function(){var e="pdf-lib (https://github.com/Hopding/pdf-lib)",r=new Date,n=this.getInfoDict();this.setProducer(e),this.setModificationDate(r),n.get(O.of("Creator"))||this.setCreator(e),n.get(O.of("CreationDate"))||this.setCreationDate(r)},t.prototype.getInfoDict=function(){var e=this.context.lookup(this.context.trailerInfo.Info);if(e instanceof Ke)return e;var r=this.context.obj({});return this.context.trailerInfo.Info=this.context.register(r),r},t.prototype.assertFontkit=function(){if(!this.fontkit)throw new UC;return this.fontkit},t})();function Cn(t){if(!(t instanceof Ie)&&!(t instanceof vt))throw new ws([Ie,vt],t)}var un;(function(t){t.Normal="Normal",t.Multiply="Multiply",t.Screen="Screen",t.Overlay="Overlay",t.Darken="Darken",t.Lighten="Lighten",t.ColorDodge="ColorDodge",t.ColorBurn="ColorBurn",t.HardLight="HardLight",t.SoftLight="SoftLight",t.Difference="Difference",t.Exclusion="Exclusion"})(un||(un={}));var Cr=(function(){function t(e,r,n){this.fontSize=24,this.fontColor=ft(0,0,0),this.lineHeight=24,this.x=0,this.y=0,q(e,"leafNode",[[vn,"PDFPageLeaf"]]),q(r,"ref",[[pt,"PDFRef"]]),q(n,"doc",[[Hn,"PDFDocument"]]),this.node=e,this.ref=r,this.doc=n}return t.prototype.setRotation=function(e){var r=h1(e);Gp(r,"degreesAngle",90),this.node.set(O.of("Rotate"),this.doc.context.obj(r))},t.prototype.getRotation=function(){var e=this.node.Rotate();return Me(e?e.asNumber():0)},t.prototype.setSize=function(e,r){q(e,"width",["number"]),q(r,"height",["number"]);var n=this.getMediaBox();this.setMediaBox(n.x,n.y,e,r);var i=this.getCropBox(),a=this.getBleedBox(),o=this.getTrimBox(),s=this.getArtBox(),u=this.node.CropBox(),f=this.node.BleedBox(),l=this.node.TrimBox(),h=this.node.ArtBox();u&&Uo(i,n)&&this.setCropBox(n.x,n.y,e,r),f&&Uo(a,n)&&this.setBleedBox(n.x,n.y,e,r),l&&Uo(o,n)&&this.setTrimBox(n.x,n.y,e,r),h&&Uo(s,n)&&this.setArtBox(n.x,n.y,e,r)},t.prototype.setWidth=function(e){q(e,"width",["number"]),this.setSize(e,this.getSize().height)},t.prototype.setHeight=function(e){q(e,"height",["number"]),this.setSize(this.getSize().width,e)},t.prototype.setMediaBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.MediaBox,a)},t.prototype.setCropBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.CropBox,a)},t.prototype.setBleedBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.BleedBox,a)},t.prototype.setTrimBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.TrimBox,a)},t.prototype.setArtBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.ArtBox,a)},t.prototype.getSize=function(){var e=this.getMediaBox(),r=e.width,n=e.height;return{width:r,height:n}},t.prototype.getWidth=function(){return this.getSize().width},t.prototype.getHeight=function(){return this.getSize().height},t.prototype.getMediaBox=function(){var e=this.node.MediaBox();return e.asRectangle()},t.prototype.getCropBox=function(){var e,r=this.node.CropBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getMediaBox()},t.prototype.getBleedBox=function(){var e,r=this.node.BleedBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.getTrimBox=function(){var e,r=this.node.TrimBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.getArtBox=function(){var e,r=this.node.ArtBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.translateContent=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]),this.node.normalize(),this.getContentStream();var n=this.createContentStream(qt(),Dr(e,r)),i=this.doc.context.register(n),a=this.createContentStream(Wt()),o=this.doc.context.register(a);this.node.wrapContentStreams(i,o)},t.prototype.scale=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]),this.setSize(this.getWidth()*e,this.getHeight()*r),this.scaleContent(e,r),this.scaleAnnotations(e,r)},t.prototype.scaleContent=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]),this.node.normalize(),this.getContentStream();var n=this.createContentStream(qt(),no(e,r)),i=this.doc.context.register(n),a=this.createContentStream(Wt()),o=this.doc.context.register(a);this.node.wrapContentStreams(i,o)},t.prototype.scaleAnnotations=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]);var n=this.node.Annots();if(n)for(var i=0;i<n.size();i++){var a=n.lookup(i);a instanceof Ke&&this.scaleAnnot(a,e,r)}},t.prototype.resetPosition=function(){this.getContentStream(!1),this.x=0,this.y=0},t.prototype.setFont=function(e){q(e,"font",[[gr,"PDFFont"]]),this.font=e,this.fontKey=this.node.newFontDictionary(this.font.name,this.font.ref)},t.prototype.setFontSize=function(e){q(e,"fontSize",["number"]),this.fontSize=e},t.prototype.setFontColor=function(e){q(e,"fontColor",[[Object,"Color"]]),this.fontColor=e},t.prototype.setLineHeight=function(e){q(e,"lineHeight",["number"]),this.lineHeight=e},t.prototype.getPosition=function(){return{x:this.x,y:this.y}},t.prototype.getX=function(){return this.x},t.prototype.getY=function(){return this.y},t.prototype.moveTo=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]),this.x=e,this.y=r},t.prototype.moveDown=function(e){q(e,"yDecrease",["number"]),this.y-=e},t.prototype.moveUp=function(e){q(e,"yIncrease",["number"]),this.y+=e},t.prototype.moveLeft=function(e){q(e,"xDecrease",["number"]),this.x-=e},t.prototype.moveRight=function(e){q(e,"xIncrease",["number"]),this.x+=e},t.prototype.pushOperators=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];Wp(e,"operator",[[at,"PDFOperator"]]);var n=this.getContentStream();n.push.apply(n,e)},t.prototype.drawText=function(e,r){var n,i,a,o,s,u,f;r===void 0&&(r={}),q(e,"text",["string"]),oe(r.color,"options.color",[[Object,"Color"]]),Mr(r.opacity,"opacity.opacity",0,1),oe(r.font,"options.font",[[gr,"PDFFont"]]),oe(r.size,"options.size",["number"]),oe(r.rotate,"options.rotate",[[Object,"Rotation"]]),oe(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),oe(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),oe(r.x,"options.x",["number"]),oe(r.y,"options.y",["number"]),oe(r.lineHeight,"options.lineHeight",["number"]),oe(r.maxWidth,"options.maxWidth",["number"]),oe(r.wordBreaks,"options.wordBreaks",[Array]),br(r.blendMode,"options.blendMode",un);for(var l=this.setOrEmbedFont(r.font),h=l.oldFont,d=l.newFont,v=l.newFontKey,g=r.size||this.fontSize,b=r.wordBreaks||this.doc.defaultWordBreaks,w=function(B){return d.widthOfTextAtSize(B,g)},x=r.maxWidth===void 0?Pp(vo(e)):gA(e,b,r.maxWidth,w),T=new Array(x.length),A=0,R=x.length;A<R;A++)T[A]=d.encodeText(x[A]);var P=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),I=this.getContentStream();I.push.apply(I,OC(T,{color:(n=r.color)!==null&&n!==void 0?n:this.fontColor,font:v,size:g,rotate:(i=r.rotate)!==null&&i!==void 0?i:Me(0),xSkew:(a=r.xSkew)!==null&&a!==void 0?a:Me(0),ySkew:(o=r.ySkew)!==null&&o!==void 0?o:Me(0),x:(s=r.x)!==null&&s!==void 0?s:this.x,y:(u=r.y)!==null&&u!==void 0?u:this.y,lineHeight:(f=r.lineHeight)!==null&&f!==void 0?f:this.lineHeight,graphicsState:P})),r.font&&(h?this.setFont(h):this.resetFont())},t.prototype.drawImage=function(e,r){var n,i,a,o,s,u,f;r===void 0&&(r={}),q(e,"image",[[Yf,"PDFImage"]]),oe(r.x,"options.x",["number"]),oe(r.y,"options.y",["number"]),oe(r.width,"options.width",["number"]),oe(r.height,"options.height",["number"]),oe(r.rotate,"options.rotate",[[Object,"Rotation"]]),oe(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),oe(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),Mr(r.opacity,"opacity.opacity",0,1),br(r.blendMode,"options.blendMode",un);var l=this.node.newXObject("Image",e.ref),h=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),d=this.getContentStream();d.push.apply(d,S1(l,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,width:(a=r.width)!==null&&a!==void 0?a:e.size().width,height:(o=r.height)!==null&&o!==void 0?o:e.size().height,rotate:(s=r.rotate)!==null&&s!==void 0?s:Me(0),xSkew:(u=r.xSkew)!==null&&u!==void 0?u:Me(0),ySkew:(f=r.ySkew)!==null&&f!==void 0?f:Me(0),graphicsState:h}))},t.prototype.drawPage=function(e,r){var n,i,a,o,s;r===void 0&&(r={}),q(e,"embeddedPage",[[k1,"PDFEmbeddedPage"]]),oe(r.x,"options.x",["number"]),oe(r.y,"options.y",["number"]),oe(r.xScale,"options.xScale",["number"]),oe(r.yScale,"options.yScale",["number"]),oe(r.width,"options.width",["number"]),oe(r.height,"options.height",["number"]),oe(r.rotate,"options.rotate",[[Object,"Rotation"]]),oe(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),oe(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),Mr(r.opacity,"opacity.opacity",0,1),br(r.blendMode,"options.blendMode",un);var u=this.node.newXObject("EmbeddedPdfPage",e.ref),f=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),l=r.width!==void 0?r.width/e.width:r.xScale!==void 0?r.xScale:1,h=r.height!==void 0?r.height/e.height:r.yScale!==void 0?r.yScale:1,d=this.getContentStream();d.push.apply(d,kC(u,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,xScale:l,yScale:h,rotate:(a=r.rotate)!==null&&a!==void 0?a:Me(0),xSkew:(o=r.xSkew)!==null&&o!==void 0?o:Me(0),ySkew:(s=r.ySkew)!==null&&s!==void 0?s:Me(0),graphicsState:f}))},t.prototype.drawSvgPath=function(e,r){var n,i,a,o,s,u,f,l,h;r===void 0&&(r={}),q(e,"path",["string"]),oe(r.x,"options.x",["number"]),oe(r.y,"options.y",["number"]),oe(r.scale,"options.scale",["number"]),oe(r.rotate,"options.rotate",[[Object,"Rotation"]]),oe(r.borderWidth,"options.borderWidth",["number"]),oe(r.color,"options.color",[[Object,"Color"]]),Mr(r.opacity,"opacity.opacity",0,1),oe(r.borderColor,"options.borderColor",[[Object,"Color"]]),oe(r.borderDashArray,"options.borderDashArray",[Array]),oe(r.borderDashPhase,"options.borderDashPhase",["number"]),br(r.borderLineCap,"options.borderLineCap",Ki),Mr(r.borderOpacity,"options.borderOpacity",0,1),br(r.blendMode,"options.blendMode",un);var d=this.maybeEmbedGraphicsState({opacity:r.opacity,borderOpacity:r.borderOpacity,blendMode:r.blendMode});!("color"in r)&&!("borderColor"in r)&&(r.borderColor=ft(0,0,0));var v=this.getContentStream();v.push.apply(v,RC(e,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,scale:r.scale,rotate:(a=r.rotate)!==null&&a!==void 0?a:Me(0),color:(o=r.color)!==null&&o!==void 0?o:void 0,borderColor:(s=r.borderColor)!==null&&s!==void 0?s:void 0,borderWidth:(u=r.borderWidth)!==null&&u!==void 0?u:0,borderDashArray:(f=r.borderDashArray)!==null&&f!==void 0?f:void 0,borderDashPhase:(l=r.borderDashPhase)!==null&&l!==void 0?l:void 0,borderLineCap:(h=r.borderLineCap)!==null&&h!==void 0?h:void 0,graphicsState:d}))},t.prototype.drawLine=function(e){var r,n,i,a,o;q(e.start,"options.start",[[Object,"{ x: number, y: number }"]]),q(e.end,"options.end",[[Object,"{ x: number, y: number }"]]),q(e.start.x,"options.start.x",["number"]),q(e.start.y,"options.start.y",["number"]),q(e.end.x,"options.end.x",["number"]),q(e.end.y,"options.end.y",["number"]),oe(e.thickness,"options.thickness",["number"]),oe(e.color,"options.color",[[Object,"Color"]]),oe(e.dashArray,"options.dashArray",[Array]),oe(e.dashPhase,"options.dashPhase",["number"]),br(e.lineCap,"options.lineCap",Ki),Mr(e.opacity,"opacity.opacity",0,1),br(e.blendMode,"options.blendMode",un);var s=this.maybeEmbedGraphicsState({borderOpacity:e.opacity,blendMode:e.blendMode});"color"in e||(e.color=ft(0,0,0));var u=this.getContentStream();u.push.apply(u,PC({start:e.start,end:e.end,thickness:(r=e.thickness)!==null&&r!==void 0?r:1,color:(n=e.color)!==null&&n!==void 0?n:void 0,dashArray:(i=e.dashArray)!==null&&i!==void 0?i:void 0,dashPhase:(a=e.dashPhase)!==null&&a!==void 0?a:void 0,lineCap:(o=e.lineCap)!==null&&o!==void 0?o:void 0,graphicsState:s}))},t.prototype.drawRectangle=function(e){var r,n,i,a,o,s,u,f,l,h,d,v,g;e===void 0&&(e={}),oe(e.x,"options.x",["number"]),oe(e.y,"options.y",["number"]),oe(e.width,"options.width",["number"]),oe(e.height,"options.height",["number"]),oe(e.rotate,"options.rotate",[[Object,"Rotation"]]),oe(e.xSkew,"options.xSkew",[[Object,"Rotation"]]),oe(e.ySkew,"options.ySkew",[[Object,"Rotation"]]),oe(e.borderWidth,"options.borderWidth",["number"]),oe(e.color,"options.color",[[Object,"Color"]]),Mr(e.opacity,"opacity.opacity",0,1),oe(e.borderColor,"options.borderColor",[[Object,"Color"]]),oe(e.borderDashArray,"options.borderDashArray",[Array]),oe(e.borderDashPhase,"options.borderDashPhase",["number"]),br(e.borderLineCap,"options.borderLineCap",Ki),Mr(e.borderOpacity,"options.borderOpacity",0,1),br(e.blendMode,"options.blendMode",un);var b=this.maybeEmbedGraphicsState({opacity:e.opacity,borderOpacity:e.borderOpacity,blendMode:e.blendMode});!("color"in e)&&!("borderColor"in e)&&(e.color=ft(0,0,0));var w=this.getContentStream();w.push.apply(w,sa({x:(r=e.x)!==null&&r!==void 0?r:this.x,y:(n=e.y)!==null&&n!==void 0?n:this.y,width:(i=e.width)!==null&&i!==void 0?i:150,height:(a=e.height)!==null&&a!==void 0?a:100,rotate:(o=e.rotate)!==null&&o!==void 0?o:Me(0),xSkew:(s=e.xSkew)!==null&&s!==void 0?s:Me(0),ySkew:(u=e.ySkew)!==null&&u!==void 0?u:Me(0),borderWidth:(f=e.borderWidth)!==null&&f!==void 0?f:0,color:(l=e.color)!==null&&l!==void 0?l:void 0,borderColor:(h=e.borderColor)!==null&&h!==void 0?h:void 0,borderDashArray:(d=e.borderDashArray)!==null&&d!==void 0?d:void 0,borderDashPhase:(v=e.borderDashPhase)!==null&&v!==void 0?v:void 0,graphicsState:b,borderLineCap:(g=e.borderLineCap)!==null&&g!==void 0?g:void 0}))},t.prototype.drawSquare=function(e){e===void 0&&(e={});var r=e.size;oe(r,"size",["number"]),this.drawRectangle(qe(qe({},e),{width:r,height:r}))},t.prototype.drawEllipse=function(e){var r,n,i,a,o,s,u,f,l,h,d;e===void 0&&(e={}),oe(e.x,"options.x",["number"]),oe(e.y,"options.y",["number"]),oe(e.xScale,"options.xScale",["number"]),oe(e.yScale,"options.yScale",["number"]),oe(e.rotate,"options.rotate",[[Object,"Rotation"]]),oe(e.color,"options.color",[[Object,"Color"]]),Mr(e.opacity,"opacity.opacity",0,1),oe(e.borderColor,"options.borderColor",[[Object,"Color"]]),Mr(e.borderOpacity,"options.borderOpacity",0,1),oe(e.borderWidth,"options.borderWidth",["number"]),oe(e.borderDashArray,"options.borderDashArray",[Array]),oe(e.borderDashPhase,"options.borderDashPhase",["number"]),br(e.borderLineCap,"options.borderLineCap",Ki),br(e.blendMode,"options.blendMode",un);var v=this.maybeEmbedGraphicsState({opacity:e.opacity,borderOpacity:e.borderOpacity,blendMode:e.blendMode});!("color"in e)&&!("borderColor"in e)&&(e.color=ft(0,0,0));var g=this.getContentStream();g.push.apply(g,Zf({x:(r=e.x)!==null&&r!==void 0?r:this.x,y:(n=e.y)!==null&&n!==void 0?n:this.y,xScale:(i=e.xScale)!==null&&i!==void 0?i:100,yScale:(a=e.yScale)!==null&&a!==void 0?a:100,rotate:(o=e.rotate)!==null&&o!==void 0?o:void 0,color:(s=e.color)!==null&&s!==void 0?s:void 0,borderColor:(u=e.borderColor)!==null&&u!==void 0?u:void 0,borderWidth:(f=e.borderWidth)!==null&&f!==void 0?f:0,borderDashArray:(l=e.borderDashArray)!==null&&l!==void 0?l:void 0,borderDashPhase:(h=e.borderDashPhase)!==null&&h!==void 0?h:void 0,borderLineCap:(d=e.borderLineCap)!==null&&d!==void 0?d:void 0,graphicsState:v}))},t.prototype.drawCircle=function(e){e===void 0&&(e={});var r=e.size,n=r===void 0?100:r;oe(n,"size",["number"]),this.drawEllipse(qe(qe({},e),{xScale:n,yScale:n}))},t.prototype.setOrEmbedFont=function(e){var r=this.font,n=this.fontKey;e?this.setFont(e):this.getFont();var i=this.font,a=this.fontKey;return{oldFont:r,oldFontKey:n,newFont:i,newFontKey:a}},t.prototype.getFont=function(){if(!this.font||!this.fontKey){var e=this.doc.embedStandardFont(io.Helvetica);this.setFont(e)}return[this.font,this.fontKey]},t.prototype.resetFont=function(){this.font=void 0,this.fontKey=void 0},t.prototype.getContentStream=function(e){return e===void 0&&(e=!0),e&&this.contentStream?this.contentStream:(this.contentStream=this.createContentStream(),this.contentStreamRef=this.doc.context.register(this.contentStream),this.node.addContentStream(this.contentStreamRef),this.contentStream)},t.prototype.createContentStream=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=this.doc.context.obj({}),i=ja.of(n,e);return i},t.prototype.maybeEmbedGraphicsState=function(e){var r=e.opacity,n=e.borderOpacity,i=e.blendMode;if(!(r===void 0&&n===void 0&&i===void 0)){var a=this.doc.context.obj({Type:"ExtGState",ca:r,CA:n,BM:i}),o=this.node.newExtGState("GS",a);return o}},t.prototype.scaleAnnot=function(e,r,n){for(var i=["RD","CL","Vertices","QuadPoints","L","Rect"],a=0,o=i.length;a<o;a++){var s=e.lookup(O.of(i[a]));s instanceof ht&&s.scalePDFNumbers(r,n)}var u=e.lookup(O.of("InkList"));if(u instanceof ht)for(var a=0,o=u.size();a<o;a++){var f=u.lookup(a);f instanceof ht&&f.scalePDFNumbers(r,n)}},t.of=function(e,r,n){return new t(e,r,n)},t.create=function(e){q(e,"doc",[[Hn,"PDFDocument"]]);var r=pt.of(-1),n=vn.withContextAndParent(e.context,r),i=e.context.register(n);return new t(n,i,e)},t})(),ns=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroButton",[[au,"PDFAcroPushButton"]]),a.acroField=r,a}return e.prototype.setImage=function(r,n){n===void 0&&(n=zn.Center);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a],u=this.createImageAppearanceStream(s,r,n);this.updateWidgetAppearances(s,{normal:u})}this.markAsClean()},e.prototype.setFontSize=function(r){eu(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.addToPage=function(r,n,i){var a,o,s,u,f,l,h,d,v,g,b;oe(r,"text",["string"]),oe(n,"page",[[Cr,"PDFPage"]]),va(i);var w=this.createWidget({x:((a=i?.x)!==null&&a!==void 0?a:0)-((o=i?.borderWidth)!==null&&o!==void 0?o:0)/2,y:((s=i?.y)!==null&&s!==void 0?s:0)-((u=i?.borderWidth)!==null&&u!==void 0?u:0)/2,width:(f=i?.width)!==null&&f!==void 0?f:100,height:(l=i?.height)!==null&&l!==void 0?l:50,textColor:(h=i?.textColor)!==null&&h!==void 0?h:ft(0,0,0),backgroundColor:(d=i?.backgroundColor)!==null&&d!==void 0?d:ft(.75,.75,.75),borderColor:i?.borderColor,borderWidth:(v=i?.borderWidth)!==null&&v!==void 0?v:0,rotate:(g=i?.rotate)!==null&&g!==void 0?g:Me(0),caption:r,hidden:i?.hidden,page:n.ref}),x=this.doc.context.register(w.dict);this.acroField.addWidget(x);var T=(b=i?.font)!==null&&b!==void 0?b:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(w,T),n.node.addAnnot(x)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof vr;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){q(r,"font",[[gr,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){q(r,"font",[[gr,"PDFFont"]]),oe(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??tE,o=da(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei);const lE=72/25.4;function At(t){return(t||0)*lE}function ai(t,e=[0,0,0]){if(!t)return ft(e[0],e[1],e[2]);const r=t.replace("#","");return/^[0-9a-f]{6}$/i.test(r)?ft(parseInt(r.slice(0,2),16)/255,parseInt(r.slice(2,4),16)/255,parseInt(r.slice(4,6),16)/255):ft(e[0],e[1],e[2])}function Fd(t){return Zt.resolveFontSize(t.style).fontSizePt}function hE(t){return Zt.resolveFontSize(t).fontSizePt}function dE(t,e){try{return t.encodeText(e),{encoded:e,supported:!0}}catch{return{encoded:"",supported:!1}}}function vE(t){const e=[];for(const r of t.richParagraphs??[]){const n=(r.segments??[]).map(i=>i.kind==="field"?i.field??"":i.text??"").join("");e.push(n)}return e}async function pE(t,e={}){const r=await Hn.create();r.registerFontkit(xi);const n=[],i=[];let a=0;const o=e.measurer??Zt.heuristicMeasurer,s=await r.embedFont(io.Helvetica),f=(e.customFontBytes?await r.embedFont(e.customFontBytes,{subset:!0}):void 0)??s,l=new Map;function h(w,x,T){return w?Zt.wrapText(w,x,{fontSizePt:T},o):[]}function d(w){const x=l.get(w);if(x)return x;const T=(async()=>{try{const A=/^data:image\/(png|jpe?g);base64,(.*)$/s.exec(w);if(!A)return null;const R=Uint8Array.from(atob(A[2]),P=>P.charCodeAt(0));return A[1]==="png"?await r.embedPng(R):await r.embedJpg(R)}catch{return null}})();return l.set(w,T),T}function v(w,x,T,A,R,P,I){const B=I?.align??P.style?.align,j=x.fontSizePt*Zt.LINE_HEIGHT;x.lines.forEach((W,N)=>{const{encoded:V,supported:Z}=dE(f,W);if(W&&!Z&&a++,!V)return;const U=f.widthOfTextAtSize(V,x.fontSizePt);let ee=T;B==="center"?ee=T+(R-U)/2:B==="right"&&(ee=T+R-U),w.drawText(V,{x:ee,y:A-x.fontSizePt-N*j,size:x.fontSizePt,font:f,color:ai(I?.color??P.style?.color)})})}function g(w,x,T,A,R){const P=Zt.resolveGridLayout(x,T.widthMm,T.heightMm),I=Zt.resolveBoxBorders(T.style),B=Zt.resolveStroke(T.style),j=ai(B.color,[.2,.2,.2]),W=Math.max(.1,B.widthPt);for(const N of P.cells){const V=N.cell.style?.backgroundColor;V&&w.drawRectangle({x:A+At(N.xMm),y:R-At(N.yMm)-At(N.heightMm),width:At(N.widthMm),height:At(N.heightMm),color:ai(V,[1,1,1])})}if(I.inner){for(const Y of P.edges)Y.kind==="v"?w.drawLine({start:{x:A+At(Y.pos),y:R-At(Y.to)},end:{x:A+At(Y.pos),y:R-At(Y.from)},thickness:W,color:j}):w.drawLine({start:{x:A+At(Y.from),y:R-At(Y.pos)},end:{x:A+At(Y.to),y:R-At(Y.pos)},thickness:W,color:j});const N=A,V=R-At(T.heightMm),Z=A+At(T.widthMm),U=R,ee=(Y,$,J,ce)=>w.drawLine({start:{x:Y,y:$},end:{x:J,y:ce},thickness:W,color:j});I.top&&ee(N,U,Z,U),I.right&&ee(Z,U,Z,V),I.bottom&&ee(Z,V,N,V),I.left&&ee(N,V,N,U)}for(const N of P.cells){const V=N.cell.style,Z=A+At(N.xMm),U=R-At(N.yMm),ee=At(N.widthMm),Y=At(N.heightMm),$=typeof N.cell.text=="string"?N.cell.text:"";if(!$)continue;const J=hE(V),ce=Math.max(1,Math.floor(Y/(J*Zt.LINE_HEIGHT))),de=h($,N.widthMm-1,J).slice(0,ce);v(w,{lines:de,fontSizePt:J},Z+1,U-(Y-de.length*J*Zt.LINE_HEIGHT)/2,ee-2,T,{color:V?.color,align:V?.align})}}for(let w=0;w<t.pages.length;w++){const x=t.pages[w],T=At(x.pageWidthMm),A=At(x.pageHeightMm),R=r.addPage([T,A]);for(const P of x.components){const I=At(P.leftMm),B=A-At(P.topMm),j=At(P.widthMm),W=At(P.heightMm);try{if(Zt.isImageBackedComponent(P)){const N=await d(P.imageData);N?R.drawImage(N,{x:I,y:B-W,width:j,height:W}):i.push(`page ${w+1} ${P.nid??P.kind}: 图片仅支持 data:image/(png|jpeg) base64,已跳过`);continue}switch(P.kind){case"text":{const N=Fd(P),V=Zt.isRichText(P)?vE(P):Array.isArray(P.lines)&&P.lines.length>0?P.lines:h(P.text??"",P.widthMm,N);Zt.isRichText(P)&&i.push(`page ${w+1} ${P.nid??"text"}: 富文本按纯文本降级导出(内联样式丢失)`),v(R,{lines:V,fontSizePt:N},I,B,j,P);break}case"rect":{const N=Zt.resolveBoxBorders(P.style),V=Zt.resolveStroke(P.style);P.style?.backgroundColor&&R.drawRectangle({x:I,y:B-W,width:j,height:W,color:ai(P.style.backgroundColor,[1,1,1])}),N.inner&&R.drawRectangle({x:I,y:B-W,width:j,height:W,borderColor:ai(V.color,[.2,.2,.2]),borderWidth:Math.max(.1,V.widthPt)}),P.grid&&g(R,P.grid,P,I,B);break}case"line":{const N=Zt.resolveStroke({...P.style,borderColor:P.style?.lineColor??P.style?.borderColor});R.drawLine({start:{x:I,y:B-W/2},end:{x:I+j,y:B-W/2},thickness:Math.max(.1,N.widthPt),color:ai(N.color,[.2,.2,.2])});break}case"ellipse":{const N=Zt.resolveStroke(P.style);R.drawEllipse({x:I+j/2,y:B-W/2,xScale:j/2,yScale:W/2,borderColor:ai(N.color,[.2,.2,.2]),borderWidth:Math.max(.1,N.widthPt)});break}default:{P.grid?g(R,P.grid,P,I,B):P.text&&v(R,{lines:[P.text],fontSizePt:Fd(P)},I,B,j,P);break}}}catch(N){n.push(`page ${w+1} comp ${P.nid??P.kind}: ${String(N)}`)}}}const b=await r.save();return{pdfDoc:r,bytes:b,pageErrors:n,unsupportedTextCount:a,fidelityWarnings:i}}const gE="mach-report-fonts",ua="fonts";function P1(){return new Promise((t,e)=>{const r=indexedDB.open(gE,1);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(ua)||n.createObjectStore(ua)},r.onsuccess=()=>t(r.result),r.onerror=()=>e(r.error)})}async function yE(t){try{const e=await P1();return await new Promise((r,n)=>{const a=e.transaction(ua,"readonly").objectStore(ua).get(t);a.onsuccess=()=>r(a.result??null),a.onerror=()=>n(a.error)})}catch{return null}}async function mE(t,e){try{const r=await P1();await new Promise((n,i)=>{const a=r.transaction(ua,"readwrite");a.objectStore(ua).put(e,t),a.oncomplete=()=>n(),a.onerror=()=>i(a.error)})}catch{}}const mf=new Map,bf=new Map;async function bE(t){const e=mf.get(t);if(e)return e;const r=bf.get(t);if(r)return r;const n=(async()=>{const i=await yE(t);if(i)return mf.set(t,i),i;try{const a=await fetch(t);if(!a.ok)return null;const o=new Uint8Array(await a.arrayBuffer());return mf.set(t,o),mE(t,o),o}catch{return null}})();bf.set(t,n);try{return await n}finally{bf.delete(t)}}exports.loadFontWithCache=bE;exports.renderPlanToPdf=pE;
|
|
84
|
+
`+Ci(n).toString();this.acroField.setDefaultAppearance(R)}return b},t.prototype.updateWidgetAppearanceWithFont=function(e,r,n){var i=n.normal,a=n.rollover,o=n.down;this.updateWidgetAppearances(e,{normal:this.createAppearanceStream(e,i,r),rollover:a&&this.createAppearanceStream(e,a,r),down:o&&this.createAppearanceStream(e,o,r)})},t.prototype.updateOnOffWidgetAppearance=function(e,r,n){var i=n.normal,a=n.rollover,o=n.down;this.updateWidgetAppearances(e,{normal:this.createAppearanceDict(e,i,r),rollover:a&&this.createAppearanceDict(e,a,r),down:o&&this.createAppearanceDict(e,o,r)})},t.prototype.updateWidgetAppearances=function(e,r){var n=r.normal,i=r.rollover,a=r.down;e.setNormalAppearance(n),i?e.setRolloverAppearance(i):e.removeRolloverAppearance(),a?e.setDownAppearance(a):e.removeDownAppearance()},t.prototype.createAppearanceStream=function(e,r,n){var i,a=this.acroField.dict.context,o=e.getRectangle(),s=o.width,u=o.height,f=n&&{Font:(i={},i[n.name]=n.ref,i)},l=a.formXObject(r,{Resources:f,BBox:a.obj([0,0,s,u]),Matrix:a.obj([1,0,0,1,0,0])}),h=a.register(l);return h},t.prototype.createImageAppearanceStream=function(e,r,n){var i,a,o=this.acroField.dict.context,s=e.getRectangle(),u=e.getAppearanceCharacteristics(),f=e.getBorderStyle(),l=(a=f?.getWidth())!==null&&a!==void 0?a:0,h=wn(u?.getRotation()),d=Qn(qe(qe({},s),{rotation:h})),v=Si(s,h),g=r.scaleToFit(v.width-l*2,v.height-l*2),b={x:l,y:l,width:g.width,height:g.height,rotate:Me(0),xSkew:Me(0),ySkew:Me(0)};n===zn.Center?(b.x+=(v.width-l*2)/2-g.width/2,b.y+=(v.height-l*2)/2-g.height/2):n===zn.Right&&(b.x=v.width-l-g.width,b.y=v.height-l-g.height);var w=this.doc.context.addRandomSuffix("Image",10),x=st(d,S1(w,b)),T={XObject:(i={},i[w]=r.ref,i)},A=o.formXObject(x,{Resources:T,BBox:o.obj([0,0,s.width,s.height]),Matrix:o.obj([1,0,0,1,0,0])});return o.register(A)},t.prototype.createAppearanceDict=function(e,r,n){var i=this.acroField.dict.context,a=this.createAppearanceStream(e,r.on),o=this.createAppearanceStream(e,r.off),s=i.obj({});return s.set(n,a),s.set(O.of("Off"),o),s},t})(),Ba=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroCheckBox",[[ru,"PDFAcroCheckBox"]]),a.acroField=r,a}return e.prototype.check=function(){var r,n=(r=this.acroField.getOnValue())!==null&&r!==void 0?r:O.of("Yes");this.markAsDirty(),this.acroField.setValue(n)},e.prototype.uncheck=function(){this.markAsDirty(),this.acroField.setValue(O.of("Off"))},e.prototype.isChecked=function(){var r=this.acroField.getOnValue();return!!r&&r===this.acroField.getValue()},e.prototype.addToPage=function(r,n){var i,a,o,s,u,f;q(r,"page",[[Cr,"PDFPage"]]),va(n),n||(n={}),"textColor"in n||(n.textColor=ft(0,0,0)),"backgroundColor"in n||(n.backgroundColor=ft(1,1,1)),"borderColor"in n||(n.borderColor=ft(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var l=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:50,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,rotate:(f=n.rotate)!==null&&f!==void 0?f:Me(0),hidden:n.hidden,page:r.ref}),h=this.doc.context.register(l.dict);this.acroField.addWidget(h),l.setAppearanceState(O.of("Off")),this.updateWidgetAppearance(l,O.of("Yes")),r.node.addAnnot(h)},e.prototype.needsAppearancesUpdate=function(){for(var r,n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getAppearanceState(),u=(r=o.getAppearances())===null||r===void 0?void 0:r.normal;if(!(u instanceof Ke)||s&&!u.has(s))return!0}return!1},e.prototype.defaultUpdateAppearances=function(){this.updateAppearances()},e.prototype.updateAppearances=function(r){var n;oe(r,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a],u=(n=s.getOnValue())!==null&&n!==void 0?n:O.of("Yes");u&&this.updateWidgetAppearance(s,u,r)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??$C,o=da(a(this,r));this.updateOnOffWidgetAppearance(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),es=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroComboBox",[[nu,"PDFAcroComboBox"]]),a.acroField=r,a}return e.prototype.getOptions=function(){for(var r=this.acroField.getOptions(),n=new Array(r.length),i=0,a=n.length;i<a;i++){var o=r[i],s=o.display,u=o.value;n[i]=(s??u).decodeText()}return n},e.prototype.getSelected=function(){for(var r=this.acroField.getValues(),n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n},e.prototype.setOptions=function(r){q(r,"options",[Array]);for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]={value:Ie.fromText(r[i])};this.acroField.setOptions(n)},e.prototype.addOptions=function(r){q(r,"options",["string",Array]);for(var n=Array.isArray(r)?r:[r],i=this.acroField.getOptions(),a=new Array(n.length),o=0,s=n.length;o<s;o++)a[o]={value:Ie.fromText(n[o])};this.acroField.setOptions(i.concat(a))},e.prototype.select=function(r,n){n===void 0&&(n=!1),q(r,"options",["string",Array]),q(n,"merge",["boolean"]);var i=Array.isArray(r)?r:[r],a=this.getOptions(),o=i.find(function(h){return!a.includes(h)});o&&this.enableEditing(),this.markAsDirty(),(i.length>1||i.length===1&&n)&&this.enableMultiselect();for(var s=new Array(i.length),u=0,f=i.length;u<f;u++)s[u]=Ie.fromText(i[u]);if(n){var l=this.acroField.getValues();this.acroField.setValues(l.concat(s))}else this.acroField.setValues(s)},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValues([])},e.prototype.setFontSize=function(r){eu(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isEditable=function(){return this.acroField.hasFlag(dt.Edit)},e.prototype.enableEditing=function(){this.acroField.setFlagTo(dt.Edit,!0)},e.prototype.disableEditing=function(){this.acroField.setFlagTo(dt.Edit,!1)},e.prototype.isSorted=function(){return this.acroField.hasFlag(dt.Sort)},e.prototype.enableSorting=function(){this.acroField.setFlagTo(dt.Sort,!0)},e.prototype.disableSorting=function(){this.acroField.setFlagTo(dt.Sort,!1)},e.prototype.isMultiselect=function(){return this.acroField.hasFlag(dt.MultiSelect)},e.prototype.enableMultiselect=function(){this.acroField.setFlagTo(dt.MultiSelect,!0)},e.prototype.disableMultiselect=function(){this.acroField.setFlagTo(dt.MultiSelect,!1)},e.prototype.isSpellChecked=function(){return!this.acroField.hasFlag(dt.DoNotSpellCheck)},e.prototype.enableSpellChecking=function(){this.acroField.setFlagTo(dt.DoNotSpellCheck,!1)},e.prototype.disableSpellChecking=function(){this.acroField.setFlagTo(dt.DoNotSpellCheck,!0)},e.prototype.isSelectOnClick=function(){return this.acroField.hasFlag(dt.CommitOnSelChange)},e.prototype.enableSelectOnClick=function(){this.acroField.setFlagTo(dt.CommitOnSelChange,!0)},e.prototype.disableSelectOnClick=function(){this.acroField.setFlagTo(dt.CommitOnSelChange,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,u,f,l;q(r,"page",[[Cr,"PDFPage"]]),va(n),n||(n={}),"textColor"in n||(n.textColor=ft(0,0,0)),"backgroundColor"in n||(n.backgroundColor=ft(1,1,1)),"borderColor"in n||(n.borderColor=ft(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var h=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,rotate:(f=n.rotate)!==null&&f!==void 0?f:Me(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(h.dict);this.acroField.addWidget(d);var v=(l=n.font)!==null&&l!==void 0?l:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(h,v),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof vr;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){q(r,"font",[[gr,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){q(r,"font",[[gr,"PDFFont"]]),oe(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??nE,o=da(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),ts=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroListBox",[[su,"PDFAcroListBox"]]),a.acroField=r,a}return e.prototype.getOptions=function(){for(var r=this.acroField.getOptions(),n=new Array(r.length),i=0,a=n.length;i<a;i++){var o=r[i],s=o.display,u=o.value;n[i]=(s??u).decodeText()}return n},e.prototype.getSelected=function(){for(var r=this.acroField.getValues(),n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n},e.prototype.setOptions=function(r){q(r,"options",[Array]),this.markAsDirty();for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]={value:Ie.fromText(r[i])};this.acroField.setOptions(n)},e.prototype.addOptions=function(r){q(r,"options",["string",Array]),this.markAsDirty();for(var n=Array.isArray(r)?r:[r],i=this.acroField.getOptions(),a=new Array(n.length),o=0,s=n.length;o<s;o++)a[o]={value:Ie.fromText(n[o])};this.acroField.setOptions(i.concat(a))},e.prototype.select=function(r,n){n===void 0&&(n=!1),q(r,"options",["string",Array]),q(n,"merge",["boolean"]);var i=Array.isArray(r)?r:[r],a=this.getOptions();r5(i,"option",a),this.markAsDirty(),(i.length>1||i.length===1&&n)&&this.enableMultiselect();for(var o=new Array(i.length),s=0,u=i.length;s<u;s++)o[s]=Ie.fromText(i[s]);if(n){var f=this.acroField.getValues();this.acroField.setValues(f.concat(o))}else this.acroField.setValues(o)},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValues([])},e.prototype.setFontSize=function(r){eu(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isSorted=function(){return this.acroField.hasFlag(dt.Sort)},e.prototype.enableSorting=function(){this.acroField.setFlagTo(dt.Sort,!0)},e.prototype.disableSorting=function(){this.acroField.setFlagTo(dt.Sort,!1)},e.prototype.isMultiselect=function(){return this.acroField.hasFlag(dt.MultiSelect)},e.prototype.enableMultiselect=function(){this.acroField.setFlagTo(dt.MultiSelect,!0)},e.prototype.disableMultiselect=function(){this.acroField.setFlagTo(dt.MultiSelect,!1)},e.prototype.isSelectOnClick=function(){return this.acroField.hasFlag(dt.CommitOnSelChange)},e.prototype.enableSelectOnClick=function(){this.acroField.setFlagTo(dt.CommitOnSelChange,!0)},e.prototype.disableSelectOnClick=function(){this.acroField.setFlagTo(dt.CommitOnSelChange,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,u,f,l;q(r,"page",[[Cr,"PDFPage"]]),va(n),n||(n={}),"textColor"in n||(n.textColor=ft(0,0,0)),"backgroundColor"in n||(n.backgroundColor=ft(1,1,1)),"borderColor"in n||(n.borderColor=ft(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var h=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:100,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,rotate:(f=n.rotate)!==null&&f!==void 0?f:Me(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(h.dict);this.acroField.addWidget(d);var v=(l=n.font)!==null&&l!==void 0?l:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(h,v),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof vr;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){q(r,"font",[[gr,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){q(r,"font",[[gr,"PDFFont"]]),oe(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??iE,o=da(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),Ra=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroRadioButton",[[ou,"PDFAcroRadioButton"]]),a.acroField=r,a}return e.prototype.getOptions=function(){var r=this.acroField.getExportValues();if(r){for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n}for(var o=this.acroField.getOnValues(),s=new Array(o.length),i=0,a=s.length;i<a;i++)s[i]=o[i].decodeText();return s},e.prototype.getSelected=function(){var r=this.acroField.getValue();if(r!==O.of("Off")){var n=this.acroField.getExportValues();if(n){for(var i=this.acroField.getOnValues(),a=0,o=i.length;a<o;a++)if(i[a]===r)return n[a].decodeText()}return r.decodeText()}},e.prototype.select=function(r){q(r,"option",["string"]);var n=this.getOptions();Bn(r,"option",n),this.markAsDirty();var i=this.acroField.getOnValues(),a=this.acroField.getExportValues();if(a)for(var o=0,s=a.length;o<s;o++)a[o].decodeText()===r&&this.acroField.setValue(i[o]);else for(var o=0,s=i.length;o<s;o++){var u=i[o];u.decodeText()===r&&this.acroField.setValue(u)}},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValue(O.of("Off"))},e.prototype.isOffToggleable=function(){return!this.acroField.hasFlag(Ar.NoToggleToOff)},e.prototype.enableOffToggling=function(){this.acroField.setFlagTo(Ar.NoToggleToOff,!1)},e.prototype.disableOffToggling=function(){this.acroField.setFlagTo(Ar.NoToggleToOff,!0)},e.prototype.isMutuallyExclusive=function(){return!this.acroField.hasFlag(Ar.RadiosInUnison)},e.prototype.enableMutualExclusion=function(){this.acroField.setFlagTo(Ar.RadiosInUnison,!1)},e.prototype.disableMutualExclusion=function(){this.acroField.setFlagTo(Ar.RadiosInUnison,!0)},e.prototype.addOptionToPage=function(r,n,i){var a,o,s,u,f,l,h,d,v;q(r,"option",["string"]),q(n,"page",[[Cr,"PDFPage"]]),va(i);var g=this.createWidget({x:(a=i?.x)!==null&&a!==void 0?a:0,y:(o=i?.y)!==null&&o!==void 0?o:0,width:(s=i?.width)!==null&&s!==void 0?s:50,height:(u=i?.height)!==null&&u!==void 0?u:50,textColor:(f=i?.textColor)!==null&&f!==void 0?f:ft(0,0,0),backgroundColor:(l=i?.backgroundColor)!==null&&l!==void 0?l:ft(1,1,1),borderColor:(h=i?.borderColor)!==null&&h!==void 0?h:ft(0,0,0),borderWidth:(d=i?.borderWidth)!==null&&d!==void 0?d:1,rotate:(v=i?.rotate)!==null&&v!==void 0?v:Me(0),hidden:i?.hidden,page:n.ref}),b=this.doc.context.register(g.dict),w=this.acroField.addWidgetWithOpt(b,Ie.fromText(r),!this.isMutuallyExclusive());g.setAppearanceState(O.of("Off")),this.updateWidgetAppearance(g,w),n.node.addAnnot(b)},e.prototype.needsAppearancesUpdate=function(){for(var r,n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getAppearanceState(),u=(r=o.getAppearances())===null||r===void 0?void 0:r.normal;if(!(u instanceof Ke)||s&&!u.has(s))return!0}return!1},e.prototype.defaultUpdateAppearances=function(){this.updateAppearances()},e.prototype.updateAppearances=function(r){oe(r,"provider",[Function]);for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getOnValue();s&&this.updateWidgetAppearance(o,s,r)}},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??eE,o=da(a(this,r));this.updateOnOffWidgetAppearance(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),Jf=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroSignature",[[Qc,"PDFAcroSignature"]]),a.acroField=r,a}return e.prototype.needsAppearancesUpdate=function(){return!1},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),rs=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroText",[[iu,"PDFAcroText"]]),a.acroField=r,a}return e.prototype.getText=function(){var r=this.acroField.getValue();if(!r&&this.isRichFormatted())throw new WC(this.getName());return r?.decodeText()},e.prototype.setText=function(r){oe(r,"text",["string"]);var n=this.getMaxLength();if(n!==void 0&&r&&r.length>n)throw new HC(r.length,n,this.getName());this.markAsDirty(),this.disableRichFormatting(),r?this.acroField.setValue(Ie.fromText(r)):this.acroField.removeValue()},e.prototype.getAlignment=function(){var r=this.acroField.getQuadding();return r===0?Vt.Left:r===1?Vt.Center:r===2?Vt.Right:Vt.Left},e.prototype.setAlignment=function(r){Bn(r,"alignment",Vt),this.markAsDirty(),this.acroField.setQuadding(r)},e.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},e.prototype.setMaxLength=function(r){if(Mr(r,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),r===void 0)this.acroField.removeMaxLength();else{var n=this.getText();if(n&&n.length>r)throw new KC(n.length,r,this.getName());this.acroField.setMaxLength(r)}},e.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},e.prototype.setImage=function(r){for(var n=this.getAlignment(),i=n===Vt.Center?zn.Center:n===Vt.Right?zn.Right:zn.Left,a=this.acroField.getWidgets(),o=0,s=a.length;o<s;o++){var u=a[o],f=this.createImageAppearanceStream(u,r,i);this.updateWidgetAppearances(u,{normal:f})}this.markAsClean()},e.prototype.setFontSize=function(r){eu(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isMultiline=function(){return this.acroField.hasFlag(Tt.Multiline)},e.prototype.enableMultiline=function(){this.markAsDirty(),this.acroField.setFlagTo(Tt.Multiline,!0)},e.prototype.disableMultiline=function(){this.markAsDirty(),this.acroField.setFlagTo(Tt.Multiline,!1)},e.prototype.isPassword=function(){return this.acroField.hasFlag(Tt.Password)},e.prototype.enablePassword=function(){this.acroField.setFlagTo(Tt.Password,!0)},e.prototype.disablePassword=function(){this.acroField.setFlagTo(Tt.Password,!1)},e.prototype.isFileSelector=function(){return this.acroField.hasFlag(Tt.FileSelect)},e.prototype.enableFileSelection=function(){this.acroField.setFlagTo(Tt.FileSelect,!0)},e.prototype.disableFileSelection=function(){this.acroField.setFlagTo(Tt.FileSelect,!1)},e.prototype.isSpellChecked=function(){return!this.acroField.hasFlag(Tt.DoNotSpellCheck)},e.prototype.enableSpellChecking=function(){this.acroField.setFlagTo(Tt.DoNotSpellCheck,!1)},e.prototype.disableSpellChecking=function(){this.acroField.setFlagTo(Tt.DoNotSpellCheck,!0)},e.prototype.isScrollable=function(){return!this.acroField.hasFlag(Tt.DoNotScroll)},e.prototype.enableScrolling=function(){this.acroField.setFlagTo(Tt.DoNotScroll,!1)},e.prototype.disableScrolling=function(){this.acroField.setFlagTo(Tt.DoNotScroll,!0)},e.prototype.isCombed=function(){return this.acroField.hasFlag(Tt.Comb)&&!this.isMultiline()&&!this.isPassword()&&!this.isFileSelector()&&this.getMaxLength()!==void 0},e.prototype.enableCombing=function(){if(this.getMaxLength()===void 0){var r="PDFTextFields must have a max length in order to be combed";console.warn(r)}this.markAsDirty(),this.disableMultiline(),this.disablePassword(),this.disableFileSelection(),this.acroField.setFlagTo(Tt.Comb,!0)},e.prototype.disableCombing=function(){this.markAsDirty(),this.acroField.setFlagTo(Tt.Comb,!1)},e.prototype.isRichFormatted=function(){return this.acroField.hasFlag(Tt.RichText)},e.prototype.enableRichFormatting=function(){this.acroField.setFlagTo(Tt.RichText,!0)},e.prototype.disableRichFormatting=function(){this.acroField.setFlagTo(Tt.RichText,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,u,f,l;q(r,"page",[[Cr,"PDFPage"]]),va(n),n||(n={}),"textColor"in n||(n.textColor=ft(0,0,0)),"backgroundColor"in n||(n.backgroundColor=ft(1,1,1)),"borderColor"in n||(n.borderColor=ft(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var h=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,rotate:(f=n.rotate)!==null&&f!==void 0?f:Me(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(h.dict);this.acroField.addWidget(d);var v=(l=n.font)!==null&&l!==void 0?l:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(h,v),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof vr;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){q(r,"font",[[gr,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){q(r,"font",[[gr,"PDFFont"]]),oe(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??rE,o=da(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei),io;(function(t){t.Courier="Courier",t.CourierBold="Courier-Bold",t.CourierOblique="Courier-Oblique",t.CourierBoldOblique="Courier-BoldOblique",t.Helvetica="Helvetica",t.HelveticaBold="Helvetica-Bold",t.HelveticaOblique="Helvetica-Oblique",t.HelveticaBoldOblique="Helvetica-BoldOblique",t.TimesRoman="Times-Roman",t.TimesRomanBold="Times-Bold",t.TimesRomanItalic="Times-Italic",t.TimesRomanBoldItalic="Times-BoldItalic",t.Symbol="Symbol",t.ZapfDingbats="ZapfDingbats"})(io||(io={}));var aE=(function(){function t(e,r){var n=this;this.embedDefaultFont=function(){return n.doc.embedStandardFont(io.Helvetica)},q(e,"acroForm",[[Cs,"PDFAcroForm"]]),q(r,"doc",[[Hn,"PDFDocument"]]),this.acroForm=e,this.doc=r,this.dirtyFields=new Set,this.defaultFontCache=dn.populatedBy(this.embedDefaultFont)}return t.prototype.hasXFA=function(){return this.acroForm.dict.has(O.of("XFA"))},t.prototype.deleteXFA=function(){this.acroForm.dict.delete(O.of("XFA"))},t.prototype.getFields=function(){for(var e=this.acroForm.getAllFields(),r=[],n=0,i=e.length;n<i;n++){var a=e[n],o=a[0],s=a[1],u=oE(o,s,this.doc);u&&r.push(u)}return r},t.prototype.getFieldMaybe=function(e){q(e,"name",["string"]);for(var r=this.getFields(),n=0,i=r.length;n<i;n++){var a=r[n];if(a.getName()===e)return a}},t.prototype.getField=function(e){q(e,"name",["string"]);var r=this.getFieldMaybe(e);if(r)return r;throw new VC(e)},t.prototype.getButton=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof ns)return r;throw new ii(e,ns,r)},t.prototype.getCheckBox=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof Ba)return r;throw new ii(e,Ba,r)},t.prototype.getDropdown=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof es)return r;throw new ii(e,es,r)},t.prototype.getOptionList=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof ts)return r;throw new ii(e,ts,r)},t.prototype.getRadioGroup=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof Ra)return r;throw new ii(e,Ra,r)},t.prototype.getSignature=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof Jf)return r;throw new ii(e,Jf,r)},t.prototype.getTextField=function(e){q(e,"name",["string"]);var r=this.getField(e);if(r instanceof rs)return r;throw new ii(e,rs,r)},t.prototype.createButton=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=au.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),ns.of(i,i.ref,this.doc)},t.prototype.createCheckBox=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=ru.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),Ba.of(i,i.ref,this.doc)},t.prototype.createDropdown=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=nu.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),es.of(i,i.ref,this.doc)},t.prototype.createOptionList=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=su.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),ts.of(i,i.ref,this.doc)},t.prototype.createRadioGroup=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=ou.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),Ra.of(i,i.ref,this.doc)},t.prototype.createTextField=function(e){q(e,"name",["string"]);var r=Ui(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=iu.create(this.doc.context);return i.setPartialName(r.terminal),zi(n,[i,i.ref],r.terminal),rs.of(i,i.ref,this.doc)},t.prototype.flatten=function(e){e===void 0&&(e={updateFieldAppearances:!0}),e.updateFieldAppearances&&this.updateFieldAppearances();for(var r=this.getFields(),n=0,i=r.length;n<i;n++){for(var a=r[n],o=a.acroField.getWidgets(),s=0,u=o.length;s<u;s++){var f=o[s],l=this.findWidgetPage(f),h=this.findWidgetAppearanceRef(a,f),d=l.node.newXObject("FlatWidget",h),v=f.getRectangle(),g=st([qt(),Dr(v.x,v.y)],Qn(qe(qe({},v),{rotation:0})),[al(d),Wt()]).filter(Boolean);l.pushOperators.apply(l,g)}this.removeField(a)}},t.prototype.removeField=function(e){for(var r=e.acroField.getWidgets(),n=new Set,i=0,a=r.length;i<a;i++){var o=r[i],s=this.findWidgetAppearanceRef(e,o),u=this.findWidgetPage(o);n.add(u),u.node.removeAnnot(s)}n.forEach(function(v){return v.node.removeAnnot(e.ref)}),this.acroForm.removeField(e.acroField);for(var f=e.acroField.normalizedEntries().Kids,l=f.size(),h=0;h<l;h++){var d=f.get(h);d instanceof pt&&this.doc.context.delete(d)}this.doc.context.delete(e.ref)},t.prototype.updateFieldAppearances=function(e){oe(e,"font",[[gr,"PDFFont"]]),e=e??this.getDefaultFont();for(var r=this.getFields(),n=0,i=r.length;n<i;n++){var a=r[n];a.needsAppearancesUpdate()&&a.defaultUpdateAppearances(e)}},t.prototype.markFieldAsDirty=function(e){oe(e,"fieldRef",[[pt,"PDFRef"]]),this.dirtyFields.add(e)},t.prototype.markFieldAsClean=function(e){oe(e,"fieldRef",[[pt,"PDFRef"]]),this.dirtyFields.delete(e)},t.prototype.fieldIsDirty=function(e){return oe(e,"fieldRef",[[pt,"PDFRef"]]),this.dirtyFields.has(e)},t.prototype.getDefaultFont=function(){return this.defaultFontCache.access()},t.prototype.findWidgetPage=function(e){var r=e.P(),n=this.doc.getPages().find(function(a){return a.ref===r});if(n===void 0){var i=this.doc.context.getObjectRef(e.dict);if(i===void 0)throw new Error("Could not find PDFRef for PDFObject");if(n=this.doc.findPageForAnnotationRef(i),n===void 0)throw new Error("Could not find page for PDFRef "+i)}return n},t.prototype.findWidgetAppearanceRef=function(e,r){var n,i=r.getNormalAppearance();if(i instanceof Ke&&(e instanceof Ba||e instanceof Ra)){var a=e.acroField.getValue(),o=(n=i.get(a))!==null&&n!==void 0?n:i.get(O.of("Off"));o instanceof pt&&(i=o)}if(!(i instanceof pt)){var s=e.getName();throw new Error("Failed to extract appearance ref for: "+s)}return i},t.prototype.findOrCreateNonTerminals=function(e){for(var r=[this.acroForm],n=0,i=e.length;n<i;n++){var a=e[n];if(!a)throw new qC(a);var o=r[0],s=r[1],u=this.findNonTerminal(a,o);if(u)r=u;else{var f=As.create(this.doc.context);f.setPartialName(a),f.setParent(s);var l=this.doc.context.register(f.dict);o.addField(l),r=[f,l]}}return r},t.prototype.findNonTerminal=function(e,r){for(var n=r instanceof Cs?this.acroForm.getFields():_c(r.Kids()),i=0,a=n.length;i<a;i++){var o=n[i],s=o[0],u=o[1];if(s.getPartialName()===e){if(s instanceof As)return[s,u];throw new C1(e)}}},t.of=function(e,r){return new t(e,r)},t})(),oE=function(t,e,r){if(t instanceof au)return ns.of(t,e,r);if(t instanceof ru)return Ba.of(t,e,r);if(t instanceof nu)return es.of(t,e,r);if(t instanceof su)return ts.of(t,e,r);if(t instanceof iu)return rs.of(t,e,r);if(t instanceof ou)return Ra.of(t,e,r);if(t instanceof Qc)return Jf.of(t,e,r)},Ui=function(t){if(t.length===0)throw new Error("PDF field names must not be empty strings");for(var e=t.split("."),r=0,n=e.length;r<n;r++)if(e[r]==="")throw new Error('Periods in PDF field names must be separated by at least one character: "'+t+'"');return e.length===1?{nonTerminal:[],terminal:e[0]}:{nonTerminal:e.slice(0,e.length-1),terminal:e[e.length-1]}},zi=function(t,e,r){for(var n=t[0],i=t[1],a=e[0],o=e[1],s=n.normalizedEntries(),u=_c("Kids"in s?s.Kids:s.Fields),f=0,l=u.length;f<l;f++)if(u[f][0].getPartialName()===r)throw new C1(r);n.addField(o),a.setParent(i)},sE={A4:[595.28,841.89]},Qf;(function(t){t[t.Fastest=1/0]="Fastest",t[t.Fast=1500]="Fast",t[t.Medium=500]="Medium",t[t.Slow=100]="Slow"})(Qf||(Qf={}));var uE=(function(){function t(e,r,n){this.alreadyEmbedded=!1,this.ref=e,this.doc=r,this.embedder=n}return t.prototype.embed=function(){return Ze(this,void 0,void 0,function(){var e,r,n,i,a;return Ye(this,function(o){switch(o.label){case 0:return this.alreadyEmbedded?[3,2]:[4,this.embedder.embedIntoContext(this.doc.context,this.ref)];case 1:e=o.sent(),this.doc.catalog.has(O.of("Names"))||this.doc.catalog.set(O.of("Names"),this.doc.context.obj({})),r=this.doc.catalog.lookup(O.of("Names"),Ke),r.has(O.of("EmbeddedFiles"))||r.set(O.of("EmbeddedFiles"),this.doc.context.obj({})),n=r.lookup(O.of("EmbeddedFiles"),Ke),n.has(O.of("Names"))||n.set(O.of("Names"),this.doc.context.obj([])),i=n.lookup(O.of("Names"),ht),i.push(Ie.fromText(this.embedder.fileName)),i.push(e),this.doc.catalog.has(O.of("AF"))||this.doc.catalog.set(O.of("AF"),this.doc.context.obj([])),a=this.doc.catalog.lookup(O.of("AF"),ht),a.push(e),this.alreadyEmbedded=!0,o.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})(),fE=(function(){function t(e,r,n){this.alreadyEmbedded=!1,this.ref=e,this.doc=r,this.embedder=n}return t.prototype.embed=function(){return Ze(this,void 0,void 0,function(){var e,r,n,i,a,o,s;return Ye(this,function(u){switch(u.label){case 0:return this.alreadyEmbedded?[3,2]:(e=this.doc,r=e.catalog,n=e.context,[4,this.embedder.embedIntoContext(this.doc.context,this.ref)]);case 1:i=u.sent(),r.has(O.of("Names"))||r.set(O.of("Names"),n.obj({})),a=r.lookup(O.of("Names"),Ke),a.has(O.of("JavaScript"))||a.set(O.of("JavaScript"),n.obj({})),o=a.lookup(O.of("JavaScript"),Ke),o.has(O.of("Names"))||o.set(O.of("Names"),n.obj([])),s=o.lookup(O.of("Names"),ht),s.push(Ie.fromText(this.embedder.scriptName)),s.push(i),this.alreadyEmbedded=!0,u.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})(),cE=(function(){function t(e,r){this.script=e,this.scriptName=r}return t.for=function(e,r){return new t(e,r)},t.prototype.embedIntoContext=function(e,r){return Ze(this,void 0,void 0,function(){var n;return Ye(this,function(i){return n=e.obj({Type:"Action",S:"JavaScript",JS:Ie.fromText(this.script)}),r?(e.assign(r,n),[2,r]):[2,e.register(n)]})})},t})(),Hn=(function(){function t(e,r,n){var i=this;if(this.defaultWordBreaks=[" "],this.computePages=function(){var a=[];return i.catalog.Pages().traverse(function(o,s){if(o instanceof vn){var u=i.pageMap.get(o);u||(u=Cr.of(o,s,i),i.pageMap.set(o,u)),a.push(u)}}),a},this.getOrCreateForm=function(){var a=i.catalog.getOrCreateAcroForm();return aE.of(a,i)},q(e,"context",[[Gf,"PDFContext"]]),q(r,"ignoreEncryption",["boolean"]),this.context=e,this.catalog=e.lookup(e.trailerInfo.Root),this.isEncrypted=!!e.lookup(e.trailerInfo.Encrypt),this.pageCache=dn.populatedBy(this.computePages),this.pageMap=new Map,this.formCache=dn.populatedBy(this.getOrCreateForm),this.fonts=[],this.images=[],this.embeddedPages=[],this.embeddedFiles=[],this.javaScripts=[],!r&&this.isEncrypted)throw new NC;n&&this.updateInfoDict()}return t.load=function(e,r){return r===void 0&&(r={}),Ze(this,void 0,void 0,function(){var n,i,a,o,s,u,f,l,h,d,v,g;return Ye(this,function(b){switch(b.label){case 0:return n=r.ignoreEncryption,i=n===void 0?!1:n,a=r.parseSpeed,o=a===void 0?Qf.Slow:a,s=r.throwOnInvalidObject,u=s===void 0?!1:s,f=r.updateMetadata,l=f===void 0?!0:f,h=r.capNumbers,d=h===void 0?!1:h,q(e,"pdf",["string",Uint8Array,ArrayBuffer]),q(i,"ignoreEncryption",["boolean"]),q(o,"parseSpeed",["number"]),q(u,"throwOnInvalidObject",["boolean"]),v=Fa(e),[4,hC.forBytesWithOptions(v,o,u,d).parseDocument()];case 1:return g=b.sent(),[2,new t(g,i,l)]}})})},t.create=function(e){return e===void 0&&(e={}),Ze(this,void 0,void 0,function(){var r,n,i,a,o,s;return Ye(this,function(u){return r=e.updateMetadata,n=r===void 0?!0:r,i=Gf.create(),a=s1.withContext(i),o=i.register(a),s=o1.withContextAndPages(i,o),i.trailerInfo.Root=i.register(s),[2,new t(i,!1,n)]})})},t.prototype.registerFontkit=function(e){this.fontkit=e},t.prototype.getForm=function(){var e=this.formCache.access();return e.hasXFA()&&(console.warn("Removing XFA form data as pdf-lib does not support reading or writing XFA"),e.deleteXFA()),e},t.prototype.getTitle=function(){var e=this.getInfoDict().lookup(O.Title);if(e)return Cn(e),e.decodeText()},t.prototype.getAuthor=function(){var e=this.getInfoDict().lookup(O.Author);if(e)return Cn(e),e.decodeText()},t.prototype.getSubject=function(){var e=this.getInfoDict().lookup(O.Subject);if(e)return Cn(e),e.decodeText()},t.prototype.getKeywords=function(){var e=this.getInfoDict().lookup(O.Keywords);if(e)return Cn(e),e.decodeText()},t.prototype.getCreator=function(){var e=this.getInfoDict().lookup(O.Creator);if(e)return Cn(e),e.decodeText()},t.prototype.getProducer=function(){var e=this.getInfoDict().lookup(O.Producer);if(e)return Cn(e),e.decodeText()},t.prototype.getCreationDate=function(){var e=this.getInfoDict().lookup(O.CreationDate);if(e)return Cn(e),e.decodeDate()},t.prototype.getModificationDate=function(){var e=this.getInfoDict().lookup(O.ModDate);if(e)return Cn(e),e.decodeDate()},t.prototype.setTitle=function(e,r){q(e,"title",["string"]);var n=O.of("Title");if(this.getInfoDict().set(n,Ie.fromText(e)),r?.showInWindowTitleBar){var i=this.catalog.getOrCreateViewerPreferences();i.setDisplayDocTitle(!0)}},t.prototype.setAuthor=function(e){q(e,"author",["string"]);var r=O.of("Author");this.getInfoDict().set(r,Ie.fromText(e))},t.prototype.setSubject=function(e){q(e,"author",["string"]);var r=O.of("Subject");this.getInfoDict().set(r,Ie.fromText(e))},t.prototype.setKeywords=function(e){q(e,"keywords",[Array]);var r=O.of("Keywords");this.getInfoDict().set(r,Ie.fromText(e.join(" ")))},t.prototype.setCreator=function(e){q(e,"creator",["string"]);var r=O.of("Creator");this.getInfoDict().set(r,Ie.fromText(e))},t.prototype.setProducer=function(e){q(e,"creator",["string"]);var r=O.of("Producer");this.getInfoDict().set(r,Ie.fromText(e))},t.prototype.setLanguage=function(e){q(e,"language",["string"]);var r=O.of("Lang");this.catalog.set(r,vt.of(e))},t.prototype.setCreationDate=function(e){q(e,"creationDate",[[Date,"Date"]]);var r=O.of("CreationDate");this.getInfoDict().set(r,vt.fromDate(e))},t.prototype.setModificationDate=function(e){q(e,"modificationDate",[[Date,"Date"]]);var r=O.of("ModDate");this.getInfoDict().set(r,vt.fromDate(e))},t.prototype.getPageCount=function(){return this.pageCount===void 0&&(this.pageCount=this.getPages().length),this.pageCount},t.prototype.getPages=function(){return this.pageCache.access()},t.prototype.getPage=function(e){var r=this.getPages();return lr(e,"index",0,r.length-1),r[e]},t.prototype.getPageIndices=function(){return SA(0,this.getPageCount())},t.prototype.removePage=function(e){var r=this.getPageCount();if(this.pageCount===0)throw new jC;lr(e,"index",0,r-1),this.catalog.removeLeafNode(e),this.pageCount=r-1},t.prototype.addPage=function(e){return q(e,"page",["undefined",[Cr,"PDFPage"],Array]),this.insertPage(this.getPageCount(),e)},t.prototype.insertPage=function(e,r){var n=this.getPageCount();if(lr(e,"index",0,n),q(r,"page",["undefined",[Cr,"PDFPage"],Array]),!r||Array.isArray(r)){var i=Array.isArray(r)?r:sE.A4;r=Cr.create(this),r.setSize.apply(r,i)}else if(r.doc!==this)throw new zC;var a=this.catalog.insertLeafNode(r.ref,e);return r.node.setParent(a),this.pageMap.set(r.node,r),this.pageCache.invalidate(),this.pageCount=n+1,r},t.prototype.copyPages=function(e,r){return Ze(this,void 0,void 0,function(){var n,i,a,o,s,u,f,l;return Ye(this,function(h){switch(h.label){case 0:return q(e,"srcDoc",[[t,"PDFDocument"]]),q(r,"indices",[Array]),[4,e.flush()];case 1:for(h.sent(),n=od.for(e.context,this.context),i=e.getPages(),a=new Array(r.length),o=0,s=r.length;o<s;o++)u=i[r[o]],f=n.copy(u.node),l=this.context.register(f),a[o]=Cr.of(f,l,this);return[2,a]}})})},t.prototype.copy=function(){return Ze(this,void 0,void 0,function(){var e,r,n,i;return Ye(this,function(a){switch(a.label){case 0:return[4,t.create()];case 1:return e=a.sent(),[4,e.copyPages(this,this.getPageIndices())];case 2:for(r=a.sent(),n=0,i=r.length;n<i;n++)e.addPage(r[n]);return this.getAuthor()!==void 0&&e.setAuthor(this.getAuthor()),this.getCreationDate()!==void 0&&e.setCreationDate(this.getCreationDate()),this.getCreator()!==void 0&&e.setCreator(this.getCreator()),this.getModificationDate()!==void 0&&e.setModificationDate(this.getModificationDate()),this.getProducer()!==void 0&&e.setProducer(this.getProducer()),this.getSubject()!==void 0&&e.setSubject(this.getSubject()),this.getTitle()!==void 0&&e.setTitle(this.getTitle()),e.defaultWordBreaks=this.defaultWordBreaks,[2,e]}})})},t.prototype.addJavaScript=function(e,r){q(e,"name",["string"]),q(r,"script",["string"]);var n=cE.for(r,e),i=this.context.nextRef(),a=fE.of(i,this,n);this.javaScripts.push(a)},t.prototype.attach=function(e,r,n){return n===void 0&&(n={}),Ze(this,void 0,void 0,function(){var i,a,o,s;return Ye(this,function(u){return q(e,"attachment",["string",Uint8Array,ArrayBuffer]),q(r,"name",["string"]),oe(n.mimeType,"mimeType",["string"]),oe(n.description,"description",["string"]),oe(n.creationDate,"options.creationDate",[Date]),oe(n.modificationDate,"options.modificationDate",[Date]),br(n.afRelationship,"options.afRelationship",Hf),i=Fa(e),a=U5.for(i,r,n),o=this.context.nextRef(),s=uE.of(o,this,a),this.embeddedFiles.push(s),[2]})})},t.prototype.embedFont=function(e,r){return r===void 0&&(r={}),Ze(this,void 0,void 0,function(){var n,i,a,o,s,u,f,l,h,d;return Ye(this,function(v){switch(v.label){case 0:return n=r.subset,i=n===void 0?!1:n,a=r.customName,o=r.features,q(e,"font",["string",Uint8Array,ArrayBuffer]),q(i,"subset",["boolean"]),Q0(e)?(s=Fs.for(e,a),[3,7]):[3,1];case 1:return CA(e)?(u=Fa(e),f=this.assertFontkit(),i?[4,N5.for(f,u,a,o)]:[3,3]):[3,6];case 2:return l=v.sent(),[3,5];case 3:return[4,Yc.for(f,u,a,o)];case 4:l=v.sent(),v.label=5;case 5:return s=l,[3,7];case 6:throw new TypeError("`font` must be one of `StandardFonts | string | Uint8Array | ArrayBuffer`");case 7:return h=this.context.nextRef(),d=gr.of(h,this,s),this.fonts.push(d),[2,d]}})})},t.prototype.embedStandardFont=function(e,r){if(q(e,"font",["string"]),!Q0(e))throw new TypeError("`font` must be one of type `StandardFonts`");var n=Fs.for(e,r),i=this.context.nextRef(),a=gr.of(i,this,n);return this.fonts.push(a),a},t.prototype.embedJpg=function(e){return Ze(this,void 0,void 0,function(){var r,n,i,a;return Ye(this,function(o){switch(o.label){case 0:return q(e,"jpg",["string",Uint8Array,ArrayBuffer]),r=Fa(e),[4,Qp.for(r)];case 1:return n=o.sent(),i=this.context.nextRef(),a=Yf.of(i,this,n),this.images.push(a),[2,a]}})})},t.prototype.embedPng=function(e){return Ze(this,void 0,void 0,function(){var r,n,i,a;return Ye(this,function(o){switch(o.label){case 0:return q(e,"png",["string",Uint8Array,ArrayBuffer]),r=Fa(e),[4,_p.for(r)];case 1:return n=o.sent(),i=this.context.nextRef(),a=Yf.of(i,this,n),this.images.push(a),[2,a]}})})},t.prototype.embedPdf=function(e,r){return r===void 0&&(r=[0]),Ze(this,void 0,void 0,function(){var n,i,a;return Ye(this,function(o){switch(o.label){case 0:return q(e,"pdf",["string",Uint8Array,ArrayBuffer,[t,"PDFDocument"]]),q(r,"indices",[Array]),e instanceof t?(i=e,[3,3]):[3,1];case 1:return[4,t.load(e)];case 2:i=o.sent(),o.label=3;case 3:return n=i,a=AA(n.getPages(),r),[2,this.embedPages(a)]}})})},t.prototype.embedPage=function(e,r,n){return Ze(this,void 0,void 0,function(){var i;return Ye(this,function(a){switch(a.label){case 0:return q(e,"page",[[Cr,"PDFPage"]]),[4,this.embedPages([e],[r],[n])];case 1:return i=a.sent()[0],[2,i]}})})},t.prototype.embedPages=function(e,r,n){return r===void 0&&(r=[]),n===void 0&&(n=[]),Ze(this,void 0,void 0,function(){var f,l,i,a,o,s,u,f,l,h,d,v,g,b,w;return Ye(this,function(x){switch(x.label){case 0:if(e.length===0)return[2,[]];for(f=0,l=e.length-1;f<l;f++)if(i=e[f],a=e[f+1],i.node.context!==a.node.context)throw new c5;o=e[0].node.context,s=o===this.context?function(T){return T}:od.for(o,this.context).copy,u=new Array(e.length),f=0,l=e.length,x.label=1;case 1:return f<l?(h=s(e[f].node),d=r[f],v=n[f],[4,t1.for(h,d,v)]):[3,4];case 2:g=x.sent(),b=this.context.nextRef(),u[f]=k1.of(b,this,g),x.label=3;case 3:return f++,[3,1];case 4:return(w=this.embeddedPages).push.apply(w,u),[2,u]}})})},t.prototype.flush=function(){return Ze(this,void 0,void 0,function(){return Ye(this,function(e){switch(e.label){case 0:return[4,this.embedAll(this.fonts)];case 1:return e.sent(),[4,this.embedAll(this.images)];case 2:return e.sent(),[4,this.embedAll(this.embeddedPages)];case 3:return e.sent(),[4,this.embedAll(this.embeddedFiles)];case 4:return e.sent(),[4,this.embedAll(this.javaScripts)];case 5:return e.sent(),[2]}})})},t.prototype.save=function(e){return e===void 0&&(e={}),Ze(this,void 0,void 0,function(){var r,n,i,a,o,s,u,f,l,h;return Ye(this,function(d){switch(d.label){case 0:return r=e.useObjectStreams,n=r===void 0?!0:r,i=e.addDefaultPage,a=i===void 0?!0:i,o=e.objectsPerTick,s=o===void 0?50:o,u=e.updateFieldAppearances,f=u===void 0?!0:u,q(n,"useObjectStreams",["boolean"]),q(a,"addDefaultPage",["boolean"]),q(s,"objectsPerTick",["number"]),q(f,"updateFieldAppearances",["boolean"]),a&&this.getPageCount()===0&&this.addPage(),f&&(l=this.formCache.getValue(),l&&l.updateFieldAppearances()),[4,this.flush()];case 1:return d.sent(),h=n?P5:Yp,[2,h.forContext(this.context,s).serializeToBuffer()]}})})},t.prototype.saveAsBase64=function(e){return e===void 0&&(e={}),Ze(this,void 0,void 0,function(){var r,n,i,a,o;return Ye(this,function(s){switch(s.label){case 0:return r=e.dataUri,n=r===void 0?!1:r,i=oA(e,["dataUri"]),q(n,"dataUri",["boolean"]),[4,this.save(i)];case 1:return a=s.sent(),o=sA(a),[2,n?"data:application/pdf;base64,"+o:o]}})})},t.prototype.findPageForAnnotationRef=function(e){for(var r=this.getPages(),n=0,i=r.length;n<i;n++){var a=r[n],o=a.node.Annots();if(o?.indexOf(e)!==void 0)return a}},t.prototype.embedAll=function(e){return Ze(this,void 0,void 0,function(){var r,n;return Ye(this,function(i){switch(i.label){case 0:r=0,n=e.length,i.label=1;case 1:return r<n?[4,e[r].embed()]:[3,4];case 2:i.sent(),i.label=3;case 3:return r++,[3,1];case 4:return[2]}})})},t.prototype.updateInfoDict=function(){var e="pdf-lib (https://github.com/Hopding/pdf-lib)",r=new Date,n=this.getInfoDict();this.setProducer(e),this.setModificationDate(r),n.get(O.of("Creator"))||this.setCreator(e),n.get(O.of("CreationDate"))||this.setCreationDate(r)},t.prototype.getInfoDict=function(){var e=this.context.lookup(this.context.trailerInfo.Info);if(e instanceof Ke)return e;var r=this.context.obj({});return this.context.trailerInfo.Info=this.context.register(r),r},t.prototype.assertFontkit=function(){if(!this.fontkit)throw new UC;return this.fontkit},t})();function Cn(t){if(!(t instanceof Ie)&&!(t instanceof vt))throw new ws([Ie,vt],t)}var un;(function(t){t.Normal="Normal",t.Multiply="Multiply",t.Screen="Screen",t.Overlay="Overlay",t.Darken="Darken",t.Lighten="Lighten",t.ColorDodge="ColorDodge",t.ColorBurn="ColorBurn",t.HardLight="HardLight",t.SoftLight="SoftLight",t.Difference="Difference",t.Exclusion="Exclusion"})(un||(un={}));var Cr=(function(){function t(e,r,n){this.fontSize=24,this.fontColor=ft(0,0,0),this.lineHeight=24,this.x=0,this.y=0,q(e,"leafNode",[[vn,"PDFPageLeaf"]]),q(r,"ref",[[pt,"PDFRef"]]),q(n,"doc",[[Hn,"PDFDocument"]]),this.node=e,this.ref=r,this.doc=n}return t.prototype.setRotation=function(e){var r=h1(e);Gp(r,"degreesAngle",90),this.node.set(O.of("Rotate"),this.doc.context.obj(r))},t.prototype.getRotation=function(){var e=this.node.Rotate();return Me(e?e.asNumber():0)},t.prototype.setSize=function(e,r){q(e,"width",["number"]),q(r,"height",["number"]);var n=this.getMediaBox();this.setMediaBox(n.x,n.y,e,r);var i=this.getCropBox(),a=this.getBleedBox(),o=this.getTrimBox(),s=this.getArtBox(),u=this.node.CropBox(),f=this.node.BleedBox(),l=this.node.TrimBox(),h=this.node.ArtBox();u&&Uo(i,n)&&this.setCropBox(n.x,n.y,e,r),f&&Uo(a,n)&&this.setBleedBox(n.x,n.y,e,r),l&&Uo(o,n)&&this.setTrimBox(n.x,n.y,e,r),h&&Uo(s,n)&&this.setArtBox(n.x,n.y,e,r)},t.prototype.setWidth=function(e){q(e,"width",["number"]),this.setSize(e,this.getSize().height)},t.prototype.setHeight=function(e){q(e,"height",["number"]),this.setSize(this.getSize().width,e)},t.prototype.setMediaBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.MediaBox,a)},t.prototype.setCropBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.CropBox,a)},t.prototype.setBleedBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.BleedBox,a)},t.prototype.setTrimBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.TrimBox,a)},t.prototype.setArtBox=function(e,r,n,i){q(e,"x",["number"]),q(r,"y",["number"]),q(n,"width",["number"]),q(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(O.ArtBox,a)},t.prototype.getSize=function(){var e=this.getMediaBox(),r=e.width,n=e.height;return{width:r,height:n}},t.prototype.getWidth=function(){return this.getSize().width},t.prototype.getHeight=function(){return this.getSize().height},t.prototype.getMediaBox=function(){var e=this.node.MediaBox();return e.asRectangle()},t.prototype.getCropBox=function(){var e,r=this.node.CropBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getMediaBox()},t.prototype.getBleedBox=function(){var e,r=this.node.BleedBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.getTrimBox=function(){var e,r=this.node.TrimBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.getArtBox=function(){var e,r=this.node.ArtBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.translateContent=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]),this.node.normalize(),this.getContentStream();var n=this.createContentStream(qt(),Dr(e,r)),i=this.doc.context.register(n),a=this.createContentStream(Wt()),o=this.doc.context.register(a);this.node.wrapContentStreams(i,o)},t.prototype.scale=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]),this.setSize(this.getWidth()*e,this.getHeight()*r),this.scaleContent(e,r),this.scaleAnnotations(e,r)},t.prototype.scaleContent=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]),this.node.normalize(),this.getContentStream();var n=this.createContentStream(qt(),no(e,r)),i=this.doc.context.register(n),a=this.createContentStream(Wt()),o=this.doc.context.register(a);this.node.wrapContentStreams(i,o)},t.prototype.scaleAnnotations=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]);var n=this.node.Annots();if(n)for(var i=0;i<n.size();i++){var a=n.lookup(i);a instanceof Ke&&this.scaleAnnot(a,e,r)}},t.prototype.resetPosition=function(){this.getContentStream(!1),this.x=0,this.y=0},t.prototype.setFont=function(e){q(e,"font",[[gr,"PDFFont"]]),this.font=e,this.fontKey=this.node.newFontDictionary(this.font.name,this.font.ref)},t.prototype.setFontSize=function(e){q(e,"fontSize",["number"]),this.fontSize=e},t.prototype.setFontColor=function(e){q(e,"fontColor",[[Object,"Color"]]),this.fontColor=e},t.prototype.setLineHeight=function(e){q(e,"lineHeight",["number"]),this.lineHeight=e},t.prototype.getPosition=function(){return{x:this.x,y:this.y}},t.prototype.getX=function(){return this.x},t.prototype.getY=function(){return this.y},t.prototype.moveTo=function(e,r){q(e,"x",["number"]),q(r,"y",["number"]),this.x=e,this.y=r},t.prototype.moveDown=function(e){q(e,"yDecrease",["number"]),this.y-=e},t.prototype.moveUp=function(e){q(e,"yIncrease",["number"]),this.y+=e},t.prototype.moveLeft=function(e){q(e,"xDecrease",["number"]),this.x-=e},t.prototype.moveRight=function(e){q(e,"xIncrease",["number"]),this.x+=e},t.prototype.pushOperators=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];Wp(e,"operator",[[at,"PDFOperator"]]);var n=this.getContentStream();n.push.apply(n,e)},t.prototype.drawText=function(e,r){var n,i,a,o,s,u,f;r===void 0&&(r={}),q(e,"text",["string"]),oe(r.color,"options.color",[[Object,"Color"]]),Mr(r.opacity,"opacity.opacity",0,1),oe(r.font,"options.font",[[gr,"PDFFont"]]),oe(r.size,"options.size",["number"]),oe(r.rotate,"options.rotate",[[Object,"Rotation"]]),oe(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),oe(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),oe(r.x,"options.x",["number"]),oe(r.y,"options.y",["number"]),oe(r.lineHeight,"options.lineHeight",["number"]),oe(r.maxWidth,"options.maxWidth",["number"]),oe(r.wordBreaks,"options.wordBreaks",[Array]),br(r.blendMode,"options.blendMode",un);for(var l=this.setOrEmbedFont(r.font),h=l.oldFont,d=l.newFont,v=l.newFontKey,g=r.size||this.fontSize,b=r.wordBreaks||this.doc.defaultWordBreaks,w=function(B){return d.widthOfTextAtSize(B,g)},x=r.maxWidth===void 0?Pp(vo(e)):gA(e,b,r.maxWidth,w),T=new Array(x.length),A=0,R=x.length;A<R;A++)T[A]=d.encodeText(x[A]);var P=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),I=this.getContentStream();I.push.apply(I,OC(T,{color:(n=r.color)!==null&&n!==void 0?n:this.fontColor,font:v,size:g,rotate:(i=r.rotate)!==null&&i!==void 0?i:Me(0),xSkew:(a=r.xSkew)!==null&&a!==void 0?a:Me(0),ySkew:(o=r.ySkew)!==null&&o!==void 0?o:Me(0),x:(s=r.x)!==null&&s!==void 0?s:this.x,y:(u=r.y)!==null&&u!==void 0?u:this.y,lineHeight:(f=r.lineHeight)!==null&&f!==void 0?f:this.lineHeight,graphicsState:P})),r.font&&(h?this.setFont(h):this.resetFont())},t.prototype.drawImage=function(e,r){var n,i,a,o,s,u,f;r===void 0&&(r={}),q(e,"image",[[Yf,"PDFImage"]]),oe(r.x,"options.x",["number"]),oe(r.y,"options.y",["number"]),oe(r.width,"options.width",["number"]),oe(r.height,"options.height",["number"]),oe(r.rotate,"options.rotate",[[Object,"Rotation"]]),oe(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),oe(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),Mr(r.opacity,"opacity.opacity",0,1),br(r.blendMode,"options.blendMode",un);var l=this.node.newXObject("Image",e.ref),h=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),d=this.getContentStream();d.push.apply(d,S1(l,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,width:(a=r.width)!==null&&a!==void 0?a:e.size().width,height:(o=r.height)!==null&&o!==void 0?o:e.size().height,rotate:(s=r.rotate)!==null&&s!==void 0?s:Me(0),xSkew:(u=r.xSkew)!==null&&u!==void 0?u:Me(0),ySkew:(f=r.ySkew)!==null&&f!==void 0?f:Me(0),graphicsState:h}))},t.prototype.drawPage=function(e,r){var n,i,a,o,s;r===void 0&&(r={}),q(e,"embeddedPage",[[k1,"PDFEmbeddedPage"]]),oe(r.x,"options.x",["number"]),oe(r.y,"options.y",["number"]),oe(r.xScale,"options.xScale",["number"]),oe(r.yScale,"options.yScale",["number"]),oe(r.width,"options.width",["number"]),oe(r.height,"options.height",["number"]),oe(r.rotate,"options.rotate",[[Object,"Rotation"]]),oe(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),oe(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),Mr(r.opacity,"opacity.opacity",0,1),br(r.blendMode,"options.blendMode",un);var u=this.node.newXObject("EmbeddedPdfPage",e.ref),f=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),l=r.width!==void 0?r.width/e.width:r.xScale!==void 0?r.xScale:1,h=r.height!==void 0?r.height/e.height:r.yScale!==void 0?r.yScale:1,d=this.getContentStream();d.push.apply(d,kC(u,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,xScale:l,yScale:h,rotate:(a=r.rotate)!==null&&a!==void 0?a:Me(0),xSkew:(o=r.xSkew)!==null&&o!==void 0?o:Me(0),ySkew:(s=r.ySkew)!==null&&s!==void 0?s:Me(0),graphicsState:f}))},t.prototype.drawSvgPath=function(e,r){var n,i,a,o,s,u,f,l,h;r===void 0&&(r={}),q(e,"path",["string"]),oe(r.x,"options.x",["number"]),oe(r.y,"options.y",["number"]),oe(r.scale,"options.scale",["number"]),oe(r.rotate,"options.rotate",[[Object,"Rotation"]]),oe(r.borderWidth,"options.borderWidth",["number"]),oe(r.color,"options.color",[[Object,"Color"]]),Mr(r.opacity,"opacity.opacity",0,1),oe(r.borderColor,"options.borderColor",[[Object,"Color"]]),oe(r.borderDashArray,"options.borderDashArray",[Array]),oe(r.borderDashPhase,"options.borderDashPhase",["number"]),br(r.borderLineCap,"options.borderLineCap",Ki),Mr(r.borderOpacity,"options.borderOpacity",0,1),br(r.blendMode,"options.blendMode",un);var d=this.maybeEmbedGraphicsState({opacity:r.opacity,borderOpacity:r.borderOpacity,blendMode:r.blendMode});!("color"in r)&&!("borderColor"in r)&&(r.borderColor=ft(0,0,0));var v=this.getContentStream();v.push.apply(v,RC(e,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,scale:r.scale,rotate:(a=r.rotate)!==null&&a!==void 0?a:Me(0),color:(o=r.color)!==null&&o!==void 0?o:void 0,borderColor:(s=r.borderColor)!==null&&s!==void 0?s:void 0,borderWidth:(u=r.borderWidth)!==null&&u!==void 0?u:0,borderDashArray:(f=r.borderDashArray)!==null&&f!==void 0?f:void 0,borderDashPhase:(l=r.borderDashPhase)!==null&&l!==void 0?l:void 0,borderLineCap:(h=r.borderLineCap)!==null&&h!==void 0?h:void 0,graphicsState:d}))},t.prototype.drawLine=function(e){var r,n,i,a,o;q(e.start,"options.start",[[Object,"{ x: number, y: number }"]]),q(e.end,"options.end",[[Object,"{ x: number, y: number }"]]),q(e.start.x,"options.start.x",["number"]),q(e.start.y,"options.start.y",["number"]),q(e.end.x,"options.end.x",["number"]),q(e.end.y,"options.end.y",["number"]),oe(e.thickness,"options.thickness",["number"]),oe(e.color,"options.color",[[Object,"Color"]]),oe(e.dashArray,"options.dashArray",[Array]),oe(e.dashPhase,"options.dashPhase",["number"]),br(e.lineCap,"options.lineCap",Ki),Mr(e.opacity,"opacity.opacity",0,1),br(e.blendMode,"options.blendMode",un);var s=this.maybeEmbedGraphicsState({borderOpacity:e.opacity,blendMode:e.blendMode});"color"in e||(e.color=ft(0,0,0));var u=this.getContentStream();u.push.apply(u,PC({start:e.start,end:e.end,thickness:(r=e.thickness)!==null&&r!==void 0?r:1,color:(n=e.color)!==null&&n!==void 0?n:void 0,dashArray:(i=e.dashArray)!==null&&i!==void 0?i:void 0,dashPhase:(a=e.dashPhase)!==null&&a!==void 0?a:void 0,lineCap:(o=e.lineCap)!==null&&o!==void 0?o:void 0,graphicsState:s}))},t.prototype.drawRectangle=function(e){var r,n,i,a,o,s,u,f,l,h,d,v,g;e===void 0&&(e={}),oe(e.x,"options.x",["number"]),oe(e.y,"options.y",["number"]),oe(e.width,"options.width",["number"]),oe(e.height,"options.height",["number"]),oe(e.rotate,"options.rotate",[[Object,"Rotation"]]),oe(e.xSkew,"options.xSkew",[[Object,"Rotation"]]),oe(e.ySkew,"options.ySkew",[[Object,"Rotation"]]),oe(e.borderWidth,"options.borderWidth",["number"]),oe(e.color,"options.color",[[Object,"Color"]]),Mr(e.opacity,"opacity.opacity",0,1),oe(e.borderColor,"options.borderColor",[[Object,"Color"]]),oe(e.borderDashArray,"options.borderDashArray",[Array]),oe(e.borderDashPhase,"options.borderDashPhase",["number"]),br(e.borderLineCap,"options.borderLineCap",Ki),Mr(e.borderOpacity,"options.borderOpacity",0,1),br(e.blendMode,"options.blendMode",un);var b=this.maybeEmbedGraphicsState({opacity:e.opacity,borderOpacity:e.borderOpacity,blendMode:e.blendMode});!("color"in e)&&!("borderColor"in e)&&(e.color=ft(0,0,0));var w=this.getContentStream();w.push.apply(w,sa({x:(r=e.x)!==null&&r!==void 0?r:this.x,y:(n=e.y)!==null&&n!==void 0?n:this.y,width:(i=e.width)!==null&&i!==void 0?i:150,height:(a=e.height)!==null&&a!==void 0?a:100,rotate:(o=e.rotate)!==null&&o!==void 0?o:Me(0),xSkew:(s=e.xSkew)!==null&&s!==void 0?s:Me(0),ySkew:(u=e.ySkew)!==null&&u!==void 0?u:Me(0),borderWidth:(f=e.borderWidth)!==null&&f!==void 0?f:0,color:(l=e.color)!==null&&l!==void 0?l:void 0,borderColor:(h=e.borderColor)!==null&&h!==void 0?h:void 0,borderDashArray:(d=e.borderDashArray)!==null&&d!==void 0?d:void 0,borderDashPhase:(v=e.borderDashPhase)!==null&&v!==void 0?v:void 0,graphicsState:b,borderLineCap:(g=e.borderLineCap)!==null&&g!==void 0?g:void 0}))},t.prototype.drawSquare=function(e){e===void 0&&(e={});var r=e.size;oe(r,"size",["number"]),this.drawRectangle(qe(qe({},e),{width:r,height:r}))},t.prototype.drawEllipse=function(e){var r,n,i,a,o,s,u,f,l,h,d;e===void 0&&(e={}),oe(e.x,"options.x",["number"]),oe(e.y,"options.y",["number"]),oe(e.xScale,"options.xScale",["number"]),oe(e.yScale,"options.yScale",["number"]),oe(e.rotate,"options.rotate",[[Object,"Rotation"]]),oe(e.color,"options.color",[[Object,"Color"]]),Mr(e.opacity,"opacity.opacity",0,1),oe(e.borderColor,"options.borderColor",[[Object,"Color"]]),Mr(e.borderOpacity,"options.borderOpacity",0,1),oe(e.borderWidth,"options.borderWidth",["number"]),oe(e.borderDashArray,"options.borderDashArray",[Array]),oe(e.borderDashPhase,"options.borderDashPhase",["number"]),br(e.borderLineCap,"options.borderLineCap",Ki),br(e.blendMode,"options.blendMode",un);var v=this.maybeEmbedGraphicsState({opacity:e.opacity,borderOpacity:e.borderOpacity,blendMode:e.blendMode});!("color"in e)&&!("borderColor"in e)&&(e.color=ft(0,0,0));var g=this.getContentStream();g.push.apply(g,Zf({x:(r=e.x)!==null&&r!==void 0?r:this.x,y:(n=e.y)!==null&&n!==void 0?n:this.y,xScale:(i=e.xScale)!==null&&i!==void 0?i:100,yScale:(a=e.yScale)!==null&&a!==void 0?a:100,rotate:(o=e.rotate)!==null&&o!==void 0?o:void 0,color:(s=e.color)!==null&&s!==void 0?s:void 0,borderColor:(u=e.borderColor)!==null&&u!==void 0?u:void 0,borderWidth:(f=e.borderWidth)!==null&&f!==void 0?f:0,borderDashArray:(l=e.borderDashArray)!==null&&l!==void 0?l:void 0,borderDashPhase:(h=e.borderDashPhase)!==null&&h!==void 0?h:void 0,borderLineCap:(d=e.borderLineCap)!==null&&d!==void 0?d:void 0,graphicsState:v}))},t.prototype.drawCircle=function(e){e===void 0&&(e={});var r=e.size,n=r===void 0?100:r;oe(n,"size",["number"]),this.drawEllipse(qe(qe({},e),{xScale:n,yScale:n}))},t.prototype.setOrEmbedFont=function(e){var r=this.font,n=this.fontKey;e?this.setFont(e):this.getFont();var i=this.font,a=this.fontKey;return{oldFont:r,oldFontKey:n,newFont:i,newFontKey:a}},t.prototype.getFont=function(){if(!this.font||!this.fontKey){var e=this.doc.embedStandardFont(io.Helvetica);this.setFont(e)}return[this.font,this.fontKey]},t.prototype.resetFont=function(){this.font=void 0,this.fontKey=void 0},t.prototype.getContentStream=function(e){return e===void 0&&(e=!0),e&&this.contentStream?this.contentStream:(this.contentStream=this.createContentStream(),this.contentStreamRef=this.doc.context.register(this.contentStream),this.node.addContentStream(this.contentStreamRef),this.contentStream)},t.prototype.createContentStream=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=this.doc.context.obj({}),i=ja.of(n,e);return i},t.prototype.maybeEmbedGraphicsState=function(e){var r=e.opacity,n=e.borderOpacity,i=e.blendMode;if(!(r===void 0&&n===void 0&&i===void 0)){var a=this.doc.context.obj({Type:"ExtGState",ca:r,CA:n,BM:i}),o=this.node.newExtGState("GS",a);return o}},t.prototype.scaleAnnot=function(e,r,n){for(var i=["RD","CL","Vertices","QuadPoints","L","Rect"],a=0,o=i.length;a<o;a++){var s=e.lookup(O.of(i[a]));s instanceof ht&&s.scalePDFNumbers(r,n)}var u=e.lookup(O.of("InkList"));if(u instanceof ht)for(var a=0,o=u.size();a<o;a++){var f=u.lookup(a);f instanceof ht&&f.scalePDFNumbers(r,n)}},t.of=function(e,r,n){return new t(e,r,n)},t.create=function(e){q(e,"doc",[[Hn,"PDFDocument"]]);var r=pt.of(-1),n=vn.withContextAndParent(e.context,r),i=e.context.register(n);return new t(n,i,e)},t})(),ns=(function(t){se(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q(r,"acroButton",[[au,"PDFAcroPushButton"]]),a.acroField=r,a}return e.prototype.setImage=function(r,n){n===void 0&&(n=zn.Center);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a],u=this.createImageAppearanceStream(s,r,n);this.updateWidgetAppearances(s,{normal:u})}this.markAsClean()},e.prototype.setFontSize=function(r){eu(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.addToPage=function(r,n,i){var a,o,s,u,f,l,h,d,v,g,b;oe(r,"text",["string"]),oe(n,"page",[[Cr,"PDFPage"]]),va(i);var w=this.createWidget({x:((a=i?.x)!==null&&a!==void 0?a:0)-((o=i?.borderWidth)!==null&&o!==void 0?o:0)/2,y:((s=i?.y)!==null&&s!==void 0?s:0)-((u=i?.borderWidth)!==null&&u!==void 0?u:0)/2,width:(f=i?.width)!==null&&f!==void 0?f:100,height:(l=i?.height)!==null&&l!==void 0?l:50,textColor:(h=i?.textColor)!==null&&h!==void 0?h:ft(0,0,0),backgroundColor:(d=i?.backgroundColor)!==null&&d!==void 0?d:ft(.75,.75,.75),borderColor:i?.borderColor,borderWidth:(v=i?.borderWidth)!==null&&v!==void 0?v:0,rotate:(g=i?.rotate)!==null&&g!==void 0?g:Me(0),caption:r,hidden:i?.hidden,page:n.ref}),x=this.doc.context.register(w.dict);this.acroField.addWidget(x);var T=(b=i?.font)!==null&&b!==void 0?b:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(w,T),n.node.addAnnot(x)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof vr;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){q(r,"font",[[gr,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){q(r,"font",[[gr,"PDFFont"]]),oe(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??tE,o=da(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(Ei);const lE=72/25.4;function At(t){return(t||0)*lE}function ai(t,e=[0,0,0]){if(!t)return ft(e[0],e[1],e[2]);const r=t.replace("#","");return/^[0-9a-f]{6}$/i.test(r)?ft(parseInt(r.slice(0,2),16)/255,parseInt(r.slice(2,4),16)/255,parseInt(r.slice(4,6),16)/255):ft(e[0],e[1],e[2])}function Fd(t){return Zt.resolveFontSize(t.style).fontSizePt}function hE(t){return Zt.resolveFontSize(t).fontSizePt}function dE(t,e){try{return t.encodeText(e),{encoded:e,supported:!0}}catch{return{encoded:"",supported:!1}}}function vE(t){const e=[];for(const r of t.richParagraphs??[]){const n=(r.segments??[]).map(i=>i.kind==="field"?i.field??"":i.text??"").join("");e.push(n)}return e}async function pE(t,e={}){const r=await Hn.create();r.registerFontkit(xi);const n=[],i=[];let a=0;const o=e.measurer??Zt.heuristicMeasurer,s=await r.embedFont(io.Helvetica),f=(e.customFontBytes?await r.embedFont(e.customFontBytes,{subset:!0}):void 0)??s,l=new Map;function h(w,x,T){return w?Zt.wrapText(w,x,{fontSizePt:T},o):[]}function d(w){const x=l.get(w);if(x)return x;const T=(async()=>{try{const A=/^data:image\/(png|jpe?g);base64,(.*)$/s.exec(w);if(!A)return null;const R=Uint8Array.from(atob(A[2]),P=>P.charCodeAt(0));return A[1]==="png"?await r.embedPng(R):await r.embedJpg(R)}catch{return null}})();return l.set(w,T),T}function v(w,x,T,A,R,P,I){const B=I?.align??P.style?.align,j=x.fontSizePt*Zt.LINE_HEIGHT;x.lines.forEach((W,N)=>{const{encoded:V,supported:Z}=dE(f,W);if(W&&!Z&&a++,!V)return;const U=f.widthOfTextAtSize(V,x.fontSizePt);let ee=T;B==="center"?ee=T+(R-U)/2:B==="right"&&(ee=T+R-U),w.drawText(V,{x:ee,y:A-x.fontSizePt-N*j,size:x.fontSizePt,font:f,color:ai(I?.color??P.style?.color)})})}function g(w,x,T,A,R){const P=Zt.resolveGridLayout(x,T.widthMm,T.heightMm),I=Zt.resolveBoxBorders(T.style),B=Zt.resolveStroke(T.style),j=ai(B.color,[.2,.2,.2]),W=Math.max(.1,B.widthPt);for(const N of P.cells){const V=N.cell.style?.backgroundColor;V&&w.drawRectangle({x:A+At(N.xMm),y:R-At(N.yMm)-At(N.heightMm),width:At(N.widthMm),height:At(N.heightMm),color:ai(V,[1,1,1])})}if(I.inner){for(const Y of P.edges)Y.kind==="v"?w.drawLine({start:{x:A+At(Y.pos),y:R-At(Y.to)},end:{x:A+At(Y.pos),y:R-At(Y.from)},thickness:W,color:j}):w.drawLine({start:{x:A+At(Y.from),y:R-At(Y.pos)},end:{x:A+At(Y.to),y:R-At(Y.pos)},thickness:W,color:j});const N=A,V=R-At(T.heightMm),Z=A+At(T.widthMm),U=R,ee=(Y,$,J,ce)=>w.drawLine({start:{x:Y,y:$},end:{x:J,y:ce},thickness:W,color:j});I.top&&ee(N,U,Z,U),I.right&&ee(Z,U,Z,V),I.bottom&&ee(Z,V,N,V),I.left&&ee(N,V,N,U)}for(const N of P.cells){const V=N.cell.style,Z=A+At(N.xMm),U=R-At(N.yMm),ee=At(N.widthMm),Y=At(N.heightMm),$=typeof N.cell.text=="string"?N.cell.text:"";if(!$)continue;const J=hE(V),ce=Math.max(1,Math.floor(Y/(J*Zt.LINE_HEIGHT))),de=h($,N.widthMm-1,J).slice(0,ce);v(w,{lines:de,fontSizePt:J},Z+1,U-(Y-de.length*J*Zt.LINE_HEIGHT)/2,ee-2,T,{color:V?.color,align:V?.align})}}for(let w=0;w<t.pages.length;w++){const x=t.pages[w],T=At(x.pageWidthMm),A=At(x.pageHeightMm),R=r.addPage([T,A]);for(const P of x.components){const I=At(P.leftMm),B=A-At(P.topMm),j=At(P.widthMm),W=At(P.heightMm);try{if(Zt.isImageBackedComponent(P)){const N=await d(P.imageData);N?R.drawImage(N,{x:I,y:B-W,width:j,height:W}):i.push(`page ${w+1} ${P.nid??P.kind}: 图片仅支持 data:image/(png|jpeg) base64,已跳过`);continue}switch(P.kind){case"text":{const N=Fd(P),V=Zt.isRichText(P)?vE(P):Array.isArray(P.lines)&&P.lines.length>0?P.lines:h(P.text??"",P.widthMm,N);Zt.isRichText(P)&&i.push(`page ${w+1} ${P.nid??"text"}: 富文本按纯文本降级导出(内联样式丢失)`),v(R,{lines:V,fontSizePt:N},I,B,j,P);break}case"rect":{const N=Zt.resolveBoxBorders(P.style),V=Zt.resolveStroke(P.style);P.style?.backgroundColor&&R.drawRectangle({x:I,y:B-W,width:j,height:W,color:ai(P.style.backgroundColor,[1,1,1])}),N.inner&&R.drawRectangle({x:I,y:B-W,width:j,height:W,borderColor:ai(V.color,[.2,.2,.2]),borderWidth:Math.max(.1,V.widthPt)}),P.grid&&g(R,P.grid,P,I,B);break}case"line":{const N=Zt.resolveStroke({...P.style,borderColor:P.style?.lineColor??P.style?.borderColor});R.drawLine({start:{x:I,y:B-W/2},end:{x:I+j,y:B-W/2},thickness:Math.max(.1,N.widthPt),color:ai(N.color,[.2,.2,.2])});break}case"ellipse":{const N=Zt.resolveStroke(P.style);R.drawEllipse({x:I+j/2,y:B-W/2,xScale:j/2,yScale:W/2,borderColor:ai(N.color,[.2,.2,.2]),borderWidth:Math.max(.1,N.widthPt)});break}default:{P.grid?g(R,P.grid,P,I,B):P.text&&v(R,{lines:[P.text],fontSizePt:Fd(P)},I,B,j,P);break}}}catch(N){n.push(`page ${w+1} comp ${P.nid??P.kind}: ${String(N)}`)}}}const b=await r.save();return{pdfDoc:r,bytes:b,pageErrors:n,unsupportedTextCount:a,fidelityWarnings:i}}const gE="mach-report-fonts",ua="fonts";function P1(){return new Promise((t,e)=>{const r=indexedDB.open(gE,1);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(ua)||n.createObjectStore(ua)},r.onsuccess=()=>t(r.result),r.onerror=()=>e(r.error)})}async function yE(t){try{const e=await P1();return await new Promise((r,n)=>{const a=e.transaction(ua,"readonly").objectStore(ua).get(t);a.onsuccess=()=>r(a.result??null),a.onerror=()=>n(a.error)})}catch{return null}}async function mE(t,e){try{const r=await P1();await new Promise((n,i)=>{const a=r.transaction(ua,"readwrite");a.objectStore(ua).put(e,t),a.oncomplete=()=>n(),a.onerror=()=>i(a.error)})}catch{}}const mf=new Map,bf=new Map;async function bE(t){const e=mf.get(t);if(e)return e;const r=bf.get(t);if(r)return r;const n=(async()=>{const i=await yE(t);if(i)return mf.set(t,i),i;try{const a=typeof AbortSignal<"u"&&"timeout"in AbortSignal?AbortSignal.timeout(15e3):void 0,o=await fetch(t,a?{signal:a}:void 0);if(!o.ok)return null;const s=new Uint8Array(await o.arrayBuffer());return mf.set(t,s),mE(t,s),s}catch{return null}})();bf.set(t,n);try{return await n}finally{bf.delete(t)}}exports.loadFontWithCache=bE;exports.renderPlanToPdf=pE;
|