pdfjs-dist
Version:
Generic build of Mozilla's PDF.js library.
25 lines • 1.24 MB
JavaScript
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright 2024 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* JavaScript code in this page
*/
/**
* pdfjsVersion = 5.5.207
* pdfjsBuild = 527964698
*/const e=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),t=[.001,0,0,.001,0,0],n=1.35,a=.35,s=.25925925925925924,r=1,i=2,o=4,l=8,f=16,c=64,h=128,u=256,m="pdfjs_internal_editor_",p=3,d=9,g=13,b=15,w=101,j={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},k=1,y=2,q=3,v=0,S=4,x=1,C=2,F=3,T={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},H="Group",O="R",R=1,D=2,M=4,E=16,N=32,z=128,L=512,U=1,_=2,X=4096,W=8192,K=32768,G=65536,V=131072,$=1048576,Y=2097152,J=8388608,Q=16777216,Z=1,ee=2,te=3,ne=4,ae=5,se={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"},re={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},ie={O:"PageOpen",C:"PageClose"},oe=1,le=5,fe=1,ce=2,he=3,ue=4,me=5,pe=6,de=7,ge=8,be=9,we=10,je=11,ke=12,ye=13,qe=14,ve=15,Se=16,xe=17,Ae=18,Ce=19,Ie=20,Fe=21,Te=22,He=23,Oe=24,Be=25,Re=26,De=27,Me=28,Pe=29,Ee=30,Ne=31,ze=32,Le=33,Ue=34,_e=35,Xe=36,We=37,Ke=38,Ge=39,Ve=40,$e=41,Ye=42,Je=43,Qe=44,Ze=45,et=46,tt=47,nt=48,at=49,st=50,rt=51,it=52,ot=53,lt=54,ft=55,ct=56,ht=57,ut=58,mt=59,pt=60,dt=61,gt=62,bt=63,wt=64,jt=65,kt=66,yt=67,qt=68,vt=69,St=70,xt=71,At=72,Ct=73,It=74,Ft=75,Tt=76,Ht=77,Ot=80,Bt=81,Rt=83,Dt=84,Mt=85,Pt=86,Et=87,Nt=88,zt=89,Lt=90,Ut=91,_t=92,Xt=93,Wt=94,Kt=0,Gt=1,Vt=2,$t=3,Yt=4,Jt=1,Qt=2;let Zt=oe;function getVerbosityLevel(){return Zt}function info(e){Zt>=le&&console.info(`Info: ${e}`)}function warn(e){Zt>=oe&&console.warn(`Warning: ${e}`)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function createValidAbsoluteUrl(e,t=null,n=null){if(!e)return null;if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=stringToUTF8String(e)}catch{}}const a=t?URL.parse(e,t):URL.parse(e);return function _isValidProtocol(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(a)?a:null}function shadow(e,t,n,a=!1){Object.defineProperty(e,t,{value:n,enumerable:!a,configurable:!0,writable:!1});return n}const en=function BaseExceptionClosure(){function BaseException(e,t){this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class PasswordException extends en{constructor(e,t){super(e,"PasswordException");this.code=t}}class UnknownErrorException extends en{constructor(e,t){super(e,"UnknownErrorException");this.details=t}}class InvalidPDFException extends en{constructor(e){super(e,"InvalidPDFException")}}class ResponseException extends en{constructor(e,t,n){super(e,"ResponseException");this.status=t;this.missing=n}}class FormatError extends en{constructor(e){super(e,"FormatError")}}class AbortException extends en{constructor(e){super(e,"AbortException")}}function bytesToString(e){"object"==typeof e&&void 0!==e?.length||unreachable("Invalid argument for bytesToString");const t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const a=[];for(let s=0;s<t;s+=n){const r=Math.min(s+n,t),i=e.subarray(s,r);a.push(String.fromCharCode.apply(null,i))}return a.join("")}function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let a=0;a<t;++a)n[a]=255&e.charCodeAt(a);return n}function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}function objectSize(e){return Object.keys(e).length}class FeatureTest{static get isLittleEndian(){return shadow(this,"isLittleEndian",function isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return 1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return shadow(this,"isEvalSupported",function isEvalSupported(){try{new Function("");return!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return shadow(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return shadow(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return shadow(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:e,userAgent:t}=navigator;return shadow(this,"platform",{isAndroid:t.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:t.includes("Firefox")})}static get isCSSRoundSupported(){return shadow(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const tn=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0"));class Util{static makeHexColor(e,t,n){return`#${tn[e]}${tn[t]}${tn[n]}`}static domMatrixToTransform(e){return[e.a,e.b,e.c,e.d,e.e,e.f]}static scaleMinMax(e,t){let n;if(e[0]){if(e[0]<0){n=t[0];t[0]=t[2];t[2]=n}t[0]*=e[0];t[2]*=e[0];if(e[3]<0){n=t[1];t[1]=t[3];t[3]=n}t[1]*=e[3];t[3]*=e[3]}else{n=t[0];t[0]=t[1];t[1]=n;n=t[2];t[2]=t[3];t[3]=n;if(e[1]<0){n=t[1];t[1]=t[3];t[3]=n}t[1]*=e[1];t[3]*=e[1];if(e[2]<0){n=t[0];t[0]=t[2];t[2]=n}t[0]*=e[2];t[2]*=e[2]}t[0]+=e[4];t[1]+=e[5];t[2]+=e[4];t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,n=0){const a=e[n],s=e[n+1];e[n]=a*t[0]+s*t[2]+t[4];e[n+1]=a*t[1]+s*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){const a=t[0],s=t[1],r=t[2],i=t[3],o=t[4],l=t[5];for(let t=0;t<6;t+=2){const f=e[n+t],c=e[n+t+1];e[n+t]=f*a+c*r+o;e[n+t+1]=f*s+c*i+l}}static applyInverseTransform(e,t){const n=e[0],a=e[1],s=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-a*t[2]+t[2]*t[5]-t[4]*t[3])/s;e[1]=(-n*t[1]+a*t[0]+t[4]*t[1]-t[5]*t[0])/s}static axialAlignedBoundingBox(e,t,n){const a=t[0],s=t[1],r=t[2],i=t[3],o=t[4],l=t[5],f=e[0],c=e[1],h=e[2],u=e[3];let m=a*f+o,p=m,d=a*h+o,g=d,b=i*c+l,w=b,j=i*u+l,k=j;if(0!==s||0!==r){const e=s*f,t=s*h,n=r*c,a=r*u;m+=n;g+=n;d+=a;p+=a;b+=e;k+=e;j+=t;w+=t}n[0]=Math.min(n[0],m,d,p,g);n[1]=Math.min(n[1],b,j,w,k);n[2]=Math.max(n[2],m,d,p,g);n[3]=Math.max(n[3],b,j,w,k)}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){const n=e[0],a=e[1],s=e[2],r=e[3],i=n**2+a**2,o=n*s+a*r,l=s**2+r**2,f=(i+l)/2,c=Math.sqrt(f**2-(i*l-o**2));t[0]=Math.sqrt(f+c||1);t[1]=Math.sqrt(f-c||1)}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){const n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>a)return null;const s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),r=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>r?null:[n,s,a,r]}static pointBoundingBox(e,t,n){n[0]=Math.min(n[0],e);n[1]=Math.min(n[1],t);n[2]=Math.max(n[2],e);n[3]=Math.max(n[3],t)}static rectBoundingBox(e,t,n,a,s){s[0]=Math.min(s[0],e,n);s[1]=Math.min(s[1],t,a);s[2]=Math.max(s[2],e,n);s[3]=Math.max(s[3],t,a)}static#e(e,t,n,a,s,r,i,o,l,f){if(l<=0||l>=1)return;const c=1-l,h=l*l,u=h*l,m=c*(c*(c*e+3*l*t)+3*h*n)+u*a,p=c*(c*(c*s+3*l*r)+3*h*i)+u*o;f[0]=Math.min(f[0],m);f[1]=Math.min(f[1],p);f[2]=Math.max(f[2],m);f[3]=Math.max(f[3],p)}static#t(e,t,n,a,s,r,i,o,l,f,c,h){if(Math.abs(l)<1e-12){Math.abs(f)>=1e-12&&this.#e(e,t,n,a,s,r,i,o,-c/f,h);return}const u=f**2-4*c*l;if(u<0)return;const m=Math.sqrt(u),p=2*l;this.#e(e,t,n,a,s,r,i,o,(-f+m)/p,h);this.#e(e,t,n,a,s,r,i,o,(-f-m)/p,h)}static bezierBoundingBox(e,t,n,a,s,r,i,o,l){l[0]=Math.min(l[0],e,i);l[1]=Math.min(l[1],t,o);l[2]=Math.max(l[2],e,i);l[3]=Math.max(l[3],t,o);this.#t(e,n,s,i,t,a,r,o,3*(3*(n-s)-e+i),6*(e-2*n+s),3*(n-e),l);this.#t(e,n,s,i,t,a,r,o,3*(3*(a-r)-t+o),6*(t-2*a+r),3*(a-t),l)}}const nn=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToPDFString(e,t=!1){if(e[0]>="ï"){let n;if("þ"===e[0]&&"ÿ"===e[1]){n="utf-16be";e.length%2==1&&(e=e.slice(0,-1))}else if("ÿ"===e[0]&&"þ"===e[1]){n="utf-16le";e.length%2==1&&(e=e.slice(0,-1))}else"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(n="utf-8");if(n)try{const a=new TextDecoder(n,{fatal:!0}),s=stringToBytes(e),r=a.decode(s);return t||!r.includes("")?r:r.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g,"")}catch(e){warn(`stringToPDFString: "${e}".`)}}const n=[];for(let a=0,s=e.length;a<s;a++){const r=e.charCodeAt(a);if(!t&&27===r){for(;++a<s&&27!==e.charCodeAt(a););continue}const i=nn[r];n.push(i?String.fromCharCode(i):e.charAt(a))}return n.join("")}function stringToUTF8String(e){return decodeURIComponent(escape(e))}function utf8StringToString(e){return unescape(encodeURIComponent(e))}function isArrayEqual(e,t){if(e.length!==t.length)return!1;for(let n=0,a=e.length;n<a;n++)if(e[n]!==t[n])return!1;return!0}function getModificationDate(e=new Date){e instanceof Date||(e=new Date(e));return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")}let an=null,sn=null;const makeArr=()=>[],makeMap=()=>new Map,makeObj=()=>Object.create(null);function MathClamp(e,t,n){return Math.min(Math.max(e,t),n)}"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(e){return e.reduce((e,t)=>e+t,0)});const rn=Symbol("CIRCULAR_REF"),on=Symbol("EOF");let ln=Object.create(null),fn=Object.create(null),cn=Object.create(null);class Name{constructor(e){this.name=e}static get(e){return fn[e]||=new Name(e)}}class Cmd{constructor(e){this.cmd=e}static get(e){return ln[e]||=new Cmd(e)}}const hn=function nonSerializableClosure(){return hn};class Dict{constructor(e=null){this._map=new Map;this.xref=e;this.objId=null;this.suppressEncryption=!1;this.__nonSerializable__=hn}assignXref(e){this.xref=e}get size(){return this._map.size}get(e,t,n){let a=this._map.get(e);if(void 0===a&&void 0!==t){a=this._map.get(t);void 0===a&&void 0!==n&&(a=this._map.get(n))}return a instanceof Ref&&this.xref?this.xref.fetch(a,this.suppressEncryption):a}async getAsync(e,t,n){let a=this._map.get(e);if(void 0===a&&void 0!==t){a=this._map.get(t);void 0===a&&void 0!==n&&(a=this._map.get(n))}return a instanceof Ref&&this.xref?this.xref.fetchAsync(a,this.suppressEncryption):a}getArray(e,t,n){let a=this._map.get(e);if(void 0===a&&void 0!==t){a=this._map.get(t);void 0===a&&void 0!==n&&(a=this._map.get(n))}a instanceof Ref&&this.xref&&(a=this.xref.fetch(a,this.suppressEncryption));if(Array.isArray(a)){a=a.slice();for(let e=0,t=a.length;e<t;e++)a[e]instanceof Ref&&this.xref&&(a[e]=this.xref.fetch(a[e],this.suppressEncryption))}return a}getRaw(e){return this._map.get(e)}getKeys(){return[...this._map.keys()]}getRawValues(){return[...this._map.values()]}getRawEntries(){return this._map.entries()}set(e,t){this._map.set(e,t)}setIfNotExists(e,t){this.has(e)||this.set(e,t)}setIfNumber(e,t){"number"==typeof t&&this.set(e,t)}setIfArray(e,t){(Array.isArray(t)||ArrayBuffer.isView(t))&&this.set(e,t)}setIfDefined(e,t){null!=t&&this.set(e,t)}setIfName(e,t){"string"==typeof t?this.set(e,Name.get(t)):t instanceof Name&&this.set(e,t)}setIfDict(e,t){t instanceof Dict&&this.set(e,t)}has(e){return this._map.has(e)}*[Symbol.iterator](){for(const[e,t]of this._map)yield[e,t instanceof Ref&&this.xref?this.xref.fetch(t,this.suppressEncryption):t]}static get empty(){const e=new Dict(null);e.set=(e,t)=>{unreachable("Should not call `set` on the empty dictionary.")};return shadow(this,"empty",e)}static merge({xref:e,dictArray:t,mergeSubDicts:n=!1}){const a=new Dict(e),s=new Map;for(const e of t)if(e instanceof Dict)for(const[t,a]of e._map){let e=s.get(t);if(void 0===e){e=[];s.set(t,e)}else if(!(n&&a instanceof Dict))continue;e.push(a)}for(const[t,n]of s){if(1===n.length||!(n[0]instanceof Dict)){a._map.set(t,n[0]);continue}const s=new Dict(e);for(const e of n)for(const[t,n]of e._map)s._map.has(t)||s._map.set(t,n);s.size>0&&a._map.set(t,s)}s.clear();return a.size>0?a:Dict.empty}clone(){const e=new Dict(this.xref);for(const t of this.getKeys())e.set(t,this.getRaw(t));return e}delete(e){this._map.delete(e)}}class Ref{constructor(e,t){this.num=e;this.gen=t}toString(){return 0===this.gen?`${this.num}R`:`${this.num}R${this.gen}`}static fromString(e){const t=cn[e];if(t)return t;const n=/^(\d+)R(\d*)$/.exec(e);return n&&"0"!==n[1]?cn[e]=new Ref(parseInt(n[1]),n[2]?parseInt(n[2]):0):null}static get(e,t){const n=0===t?`${e}R`:`${e}R${t}`;return cn[n]||=new Ref(e,t)}}class RefSet{constructor(e=null){this._set=new Set(e?._set)}has(e){return this._set.has(e.toString())}put(e){this._set.add(e.toString())}remove(e){this._set.delete(e.toString())}[Symbol.iterator](){return this._set.values()}clear(){this._set.clear()}}class RefSetCache{_map=new Map;get size(){return this._map.size}get(e){return this._map.get(e.toString())}has(e){return this._map.has(e.toString())}put(e,t){this._map.set(e.toString(),t)}putAlias(e,t){this._map.set(e.toString(),this.get(t))}[Symbol.iterator](){return this._map.values()}clear(){this._map.clear()}*values(){yield*this._map.values()}*items(){for(const[e,t]of this._map)yield[Ref.fromString(e),t]}*keys(){for(const e of this._map.keys())yield Ref.fromString(e)}}function isName(e,t){return e instanceof Name&&(void 0===t||e.name===t)}function isCmd(e,t){return e instanceof Cmd&&(void 0===t||e.cmd===t)}function isDict(e,t){return e instanceof Dict&&(void 0===t||isName(e.get("Type"),t))}function isRefsEqual(e,t){return e.num===t.num&&e.gen===t.gen}class BaseStream{get length(){unreachable("Abstract getter `length` accessed")}get isEmpty(){unreachable("Abstract getter `isEmpty` accessed")}get isDataLoaded(){return shadow(this,"isDataLoaded",!0)}getByte(){unreachable("Abstract method `getByte` called")}getBytes(e){unreachable("Abstract method `getBytes` called")}async getImageData(e,t){return this.getBytes(e,t)}async asyncGetBytes(){unreachable("Abstract method `asyncGetBytes` called")}get isAsync(){return!1}get isAsyncDecoder(){return!1}get isImageStream(){return!1}get canAsyncDecodeImageFromBuffer(){return!1}async getTransferableImage(){return null}peekByte(){const e=this.getByte();-1!==e&&this.pos--;return e}peekBytes(e){const t=this.getBytes(e);this.pos-=t.length;return t}getUint16(){const e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t}getInt32(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()}getByteRange(e,t){unreachable("Abstract method `getByteRange` called")}getString(e){return bytesToString(this.getBytes(e))}skip(e){this.pos+=e||1}reset(){unreachable("Abstract method `reset` called")}moveStart(){unreachable("Abstract method `moveStart` called")}makeSubStream(e,t,n=null){unreachable("Abstract method `makeSubStream` called")}getBaseStreams(){return null}getOriginalStream(){return this.stream?.getOriginalStream()||this}}const un=/^[1-9]\.\d$/,mn=2**31-1,pn=[1,0,0,1,0,0],dn=["ColorSpace","ExtGState","Font","Pattern","Properties","Shading","XObject"],gn=["ExtGState","Font","Properties","XObject"];function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}}class MissingDataException extends en{constructor(e,t){super(`Missing data [${e}, ${t})`,"MissingDataException");this.begin=e;this.end=t}}class ParserEOFException extends en{constructor(e){super(e,"ParserEOFException")}}class XRefEntryException extends en{constructor(e){super(e,"XRefEntryException")}}class XRefParseException extends en{constructor(e){super(e,"XRefParseException")}}function arrayBuffersToBytes(e){const t=e.length;if(0===t)return new Uint8Array(0);if(1===t)return new Uint8Array(e[0]);let n=0;for(let a=0;a<t;a++)n+=e[a].byteLength;const a=new Uint8Array(n);let s=0;for(let n=0;n<t;n++){const t=new Uint8Array(e[n]);a.set(t,s);s+=t.byteLength}return a}async function fetchBinaryData(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch file "${e}" with "${t.statusText}".`);return t.bytes()}function getInheritableProperty({dict:e,key:t,getArray:n=!1,stopWhenFound:a=!0}){let s;const r=new RefSet;for(;e instanceof Dict&&(!e.objId||!r.has(e.objId));){e.objId&&r.put(e.objId);const i=n?e.getArray(t):e.get(t);if(void 0!==i){if(a)return i;(s||=[]).push(i)}e=e.get("Parent")}return s}const bn=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"];function toRomanNumerals(e,t=!1){assert(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const n="M".repeat(e/1e3|0)+bn[e%1e3/100|0]+bn[10+(e%100/10|0)]+bn[20+e%10];return t?n.toLowerCase():n}function log2(e){return e>0?Math.ceil(Math.log2(e)):0}function readInt8(e,t){return e[t]<<24>>24}function readInt16(e,t){return(e[t]<<24|e[t+1]<<16)>>16}function readUint16(e,t){return e[t]<<8|e[t+1]}function readUint32(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function isWhiteSpace(e){return 32===e||9===e||13===e||10===e}function isNumberArray(e,t){return Array.isArray(e)?(null===t||e.length===t)&&e.every(e=>"number"==typeof e):ArrayBuffer.isView(e)&&!(e instanceof BigInt64Array||e instanceof BigUint64Array)&&(null===t||e.length===t)}function lookupMatrix(e,t){return isNumberArray(e,6)?e:t}function lookupRect(e,t){return isNumberArray(e,4)?e:t}function lookupNormalRect(e,t){return isNumberArray(e,4)?Util.normalizeRect(e):t}function parseXFAPath(e){const t=/(.+)\[(\d+)\]$/;return e.split(".").map(e=>{const n=e.match(t);return n?{name:n[1],pos:parseInt(n[2],10)}:{name:e,pos:0}})}function escapePDFName(e){const t=[];let n=0;for(let a=0,s=e.length;a<s;a++){const s=e.charCodeAt(a);if(s<33||s>126||35===s||40===s||41===s||60===s||62===s||91===s||93===s||123===s||125===s||47===s||37===s){n<a&&t.push(e.substring(n,a));t.push(`#${s.toString(16)}`);n=a+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n,e.length));return t.join("")}function escapeString(e){return e.replaceAll(/([()\\\n\r])/g,e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`)}function _collectJS(e,t,n,a){if(!e)return;let s=null;if(e instanceof Ref){if(a.has(e))return;s=e;a.put(s);e=t.fetch(e)}if(Array.isArray(e))for(const s of e)_collectJS(s,t,n,a);else if(e instanceof Dict){if(isName(e.get("S"),"JavaScript")){const t=e.get("JS");let a;t instanceof BaseStream?a=t.getString():"string"==typeof t&&(a=t);a&&=stringToPDFString(a,!0).replaceAll("\0","");a&&n.push(a.trim())}_collectJS(e.getRaw("Next"),t,n,a)}s&&a.remove(s)}function collectActions(e,t,n){const a=Object.create(null),s=getInheritableProperty({dict:t,key:"AA",stopWhenFound:!1});if(s)for(let t=s.length-1;t>=0;t--){const r=s[t];if(r instanceof Dict)for(const t of r.getKeys()){const s=n[t];if(!s)continue;const i=[];_collectJS(r.getRaw(t),e,i,new RefSet);i.length>0&&(a[s]=i)}}if(t.has("A")){const n=[];_collectJS(t.get("A"),e,n,new RefSet);n.length>0&&(a.Action=n)}return objectSize(a)>0?a:null}const wn={60:"<",62:">",38:"&",34:""",39:"'"};function*codePointIter(e){for(let t=0,n=e.length;t<n;t++){const n=e.codePointAt(t);n>55295&&(n<57344||n>65533)&&t++;yield n}}function encodeToXmlString(e){const t=[];let n=0;for(let a=0,s=e.length;a<s;a++){const s=e.codePointAt(a);if(32<=s&&s<=126){const r=wn[s];if(r){n<a&&t.push(e.substring(n,a));t.push(r);n=a+1}}else{n<a&&t.push(e.substring(n,a));t.push(`&#x${s.toString(16).toUpperCase()};`);s>55295&&(s<57344||s>65533)&&a++;n=a+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n,e.length));return t.join("")}function validateFontName(e,t=!1){const n=/^("|').*("|')$/.exec(e);if(n&&n[1]===n[2]){if(new RegExp(`[^\\\\]${n[1]}`).test(e.slice(1,-1))){t&&warn(`FontFamily contains unescaped ${n[1]}: ${e}.`);return!1}}else for(const n of e.split(/[ \t]+/))if(/^(\d|(-(\d|-)))/.test(n)||!/^[\w-\\]+$/.test(n)){t&&warn(`FontFamily contains invalid <custom-ident>: ${e}.`);return!1}return!0}function validateCSSFont(e){const t=new Set(["100","200","300","400","500","600","700","800","900","1000","normal","bold","bolder","lighter"]),{fontFamily:n,fontWeight:a,italicAngle:s}=e;if(!validateFontName(n,!0))return!1;const r=a?a.toString():"";e.fontWeight=t.has(r)?r:"400";const i=parseFloat(s);e.italicAngle=isNaN(i)||i<-90||i>90?"14":s.toString();return!0}function recoverJsURL(e){const t=new RegExp("^\\s*("+["app.launchURL","window.open","xfa.host.gotoURL"].join("|").replaceAll(".","\\.")+")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))","i").exec(e);return t?.[2]?{url:t[2],newWindow:"app.launchURL"===t[1]&&"true"===t[3]}:null}function numberToString(e){if(Number.isInteger(e))return e.toString();const t=Math.round(100*e);return t%100==0?(t/100).toString():t%10==0?e.toFixed(1):e.toFixed(2)}function getNewAnnotationsMap(e){if(!e)return null;const t=new Map;for(const[n,a]of e)n.startsWith(m)&&t.getOrInsertComputed(a.pageIndex,makeArr).push(a);return t.size>0?t:null}function stringToAsciiOrUTF16BE(e){return null==e||function isAscii(e){if("string"!=typeof e)return!1;return!e||/^[\x00-\x7F]*$/.test(e)}(e)?e:stringToUTF16String(e,!0)}function stringToUTF16HexString(e){const t=[];for(let n=0,a=e.length;n<a;n++){const a=e.charCodeAt(n);t.push(tn[a>>8&255],tn[255&a])}return t.join("")}function stringToUTF16String(e,t=!1){const n=[];t&&n.push("þÿ");for(let t=0,a=e.length;t<a;t++){const a=e.charCodeAt(t);n.push(String.fromCharCode(a>>8&255),String.fromCharCode(255&a))}return n.join("")}function getRotationMatrix(e,t,n){switch(e){case 90:return[0,1,-1,0,t,0];case 180:return[-1,0,0,-1,t,n];case 270:return[0,-1,1,0,0,n];default:throw new Error("Invalid rotation")}}function getSizeInBytes(e){return Math.ceil(Math.ceil(Math.log2(1+e))/8)}class QCMS{static#n=null;static _memory=null;static _mustAddAlpha=!1;static _destBuffer=null;static _destOffset=0;static _destLength=0;static _cssColor="";static _makeHexColor=null;static get _memoryArray(){const e=this.#n;return e?.byteLength?e:this.#n=new Uint8Array(this._memory.buffer)}}let jn;const kn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&kn.decode();let yn=null;function getUint8ArrayMemory0(){null!==yn&&0!==yn.byteLength||(yn=new Uint8Array(jn.memory.buffer));return yn}let qn=0;function passArray8ToWasm0(e,t){const n=t(1*e.length,1)>>>0;getUint8ArrayMemory0().set(e,n/1);qn=e.length;return n}const vn=Object.freeze({RGB8:0,0:"RGB8",RGBA8:1,1:"RGBA8",BGRA8:2,2:"BGRA8",Gray8:3,3:"Gray8",GrayA8:4,4:"GrayA8",CMYK:5,5:"CMYK"}),Sn=Object.freeze({Perceptual:0,0:"Perceptual",RelativeColorimetric:1,1:"RelativeColorimetric",Saturation:2,2:"Saturation",AbsoluteColorimetric:3,3:"AbsoluteColorimetric"});function __wbg_get_imports(){const e={wbg:{}};e.wbg.__wbg_copyresult_b08ee7d273f295dd=function(e,t){!function copy_result(e,t){const{_mustAddAlpha:n,_destBuffer:a,_destOffset:s,_destLength:r,_memoryArray:i}=QCMS;if(t!==r)if(n)for(let n=e,r=e+t,o=s;n<r;n+=3,o+=4){a[o]=i[n];a[o+1]=i[n+1];a[o+2]=i[n+2];a[o+3]=255}else for(let n=e,r=e+t,o=s;n<r;n+=3,o+=4){a[o]=i[n];a[o+1]=i[n+1];a[o+2]=i[n+2]}else a.set(i.subarray(e,e+t),s)}(e>>>0,t>>>0)};e.wbg.__wbg_copyrgb_d60ce17bb05d9b67=function(e){!function copy_rgb(e){const{_destBuffer:t,_destOffset:n,_memoryArray:a}=QCMS;t[n]=a[e];t[n+1]=a[e+1];t[n+2]=a[e+2]}(e>>>0)};e.wbg.__wbg_makecssRGB_893bf0cd9fdb302d=function(e){!function make_cssRGB(e){const{_memoryArray:t}=QCMS;QCMS._cssColor=QCMS._makeHexColor(t[e],t[e+1],t[e+2])}(e>>>0)};e.wbg.__wbindgen_init_externref_table=function(){const e=jn.__wbindgen_export_0,t=e.grow(4);e.set(0,void 0);e.set(t+0,void 0);e.set(t+1,null);e.set(t+2,!0);e.set(t+3,!1)};e.wbg.__wbindgen_throw=function(e,t){throw new Error(function getStringFromWasm0(e,t){e>>>=0;return kn.decode(getUint8ArrayMemory0().subarray(e,e+t))}(e,t))};return e}function __wbg_finalize_init(e,t){jn=e.exports;__wbg_init.__wbindgen_wasm_module=t;yn=null;jn.__wbindgen_start();return jn}async function __wbg_init(e){if(void 0!==jn)return jn;void 0!==e&&(Object.getPrototypeOf(e)===Object.prototype?({module_or_path:e}=e):console.warn("using deprecated parameters for the initialization function; pass a single object instead"));const t=__wbg_get_imports();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:n,module:a}=await async function __wbg_load(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}{const n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}(await e,t);return __wbg_finalize_init(n,a)}function isDefaultDecodeHelper(e,t){if(!Array.isArray(e))return!0;const n=e.length;if(n<t){warn("Decode map length is too short.");return!0}if(n>t){info("Truncating too long decode map.");e.length=t}return!1}class ColorSpace{static#a=new Uint8ClampedArray(3);constructor(e,t){this.name=e;this.numComps=t}getRgb(e,t,n=new Uint8ClampedArray(3)){this.getRgbItem(e,t,n,0);return n}getRgbHex(e,t){const n=this.getRgb(e,t,ColorSpace.#a);return Util.makeHexColor(n[0],n[1],n[2])}getRgbItem(e,t,n,a){unreachable("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,n,a,s,r,i){unreachable("Should not call ColorSpace.getRgbBuffer")}getOutputLength(e,t){unreachable("Should not call ColorSpace.getOutputLength")}isPassthrough(e){return!1}isDefaultDecode(e,t){return ColorSpace.isDefaultDecode(e,this.numComps)}fillRgb(e,t,n,a,s,r,i,o,l){const f=t*n;let c=null;const h=1<<i,u=n!==s||t!==a;if(this.isPassthrough(i))c=o;else if(1===this.numComps&&f>h&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const t=i<=8?new Uint8Array(h):new Uint16Array(h);for(let e=0;e<h;e++)t[e]=e;const n=new Uint8ClampedArray(3*h);this.getRgbBuffer(t,0,h,n,0,i,0);if(u){c=new Uint8Array(3*f);let e=0;for(let t=0;t<f;++t){const a=3*o[t];c[e++]=n[a];c[e++]=n[a+1];c[e++]=n[a+2]}}else{let t=0;for(let a=0;a<f;++a){const s=3*o[a];e[t++]=n[s];e[t++]=n[s+1];e[t++]=n[s+2];t+=l}}}else if(u){c=new Uint8ClampedArray(3*f);this.getRgbBuffer(o,0,f,c,0,i,0)}else this.getRgbBuffer(o,0,a*r,e,0,i,l);if(c)if(u)!function resizeRgbImage(e,t,n,a,s,r,i){i=1!==i?0:i;const o=n/s,l=a/r;let f,c=0;const h=new Uint16Array(s),u=3*n;for(let e=0;e<s;e++)h[e]=3*Math.floor(e*o);for(let n=0;n<r;n++){const a=Math.floor(n*l)*u;for(let n=0;n<s;n++){f=a+h[n];t[c++]=e[f++];t[c++]=e[f++];t[c++]=e[f++];c+=i}}}(c,e,t,n,a,s,l);else{let t=0,n=0;for(let s=0,i=a*r;s<i;s++){e[t++]=c[n++];e[t++]=c[n++];e[t++]=c[n++];t+=l}}}get usesZeroToOneRange(){return shadow(this,"usesZeroToOneRange",!0)}static isDefaultDecode(e,t){if(isDefaultDecodeHelper(e,2*t))return!0;for(let t=0,n=e.length;t<n;t+=2)if(0!==e[t]||1!==e[t+1])return!1;return!0}}class AlternateCS extends ColorSpace{constructor(e,t,n){super("Alternate",e);this.base=t;this.tintFn=n;this.tmpBuf=new Float32Array(t.numComps)}getRgbItem(e,t,n,a){const s=this.tmpBuf;this.tintFn(e,t,s,0);this.base.getRgbItem(s,0,n,a)}getRgbBuffer(e,t,n,a,s,r,i){const o=this.tintFn,l=this.base,f=1/((1<<r)-1),c=l.numComps,h=l.usesZeroToOneRange,u=(l.isPassthrough(8)||!h)&&0===i;let m=u?s:0;const p=u?a:new Uint8ClampedArray(c*n),d=this.numComps,g=new Float32Array(d),b=new Float32Array(c);let w,j;for(w=0;w<n;w++){for(j=0;j<d;j++)g[j]=e[t++]*f;o(g,0,b,0);if(h)for(j=0;j<c;j++)p[m++]=255*b[j];else{l.getRgbItem(b,0,p,m);m+=c}}u||l.getRgbBuffer(p,0,n,a,s,8,i)}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps/this.numComps,t)}}class PatternCS extends ColorSpace{constructor(e){super("Pattern",null);this.base=e}isDefaultDecode(e,t){unreachable("Should not call PatternCS.isDefaultDecode")}}class IndexedCS extends ColorSpace{constructor(e,t,n){super("Indexed",1);this.base=e;this.highVal=t;const a=e.numComps*(t+1);this.lookup=new Uint8Array(a);if(n instanceof BaseStream){const e=n.getBytes(a);this.lookup.set(e)}else{if("string"!=typeof n)throw new FormatError(`IndexedCS - unrecognized lookup table: ${n}`);for(let e=0;e<a;++e)this.lookup[e]=255&n.charCodeAt(e)}}getRgbItem(e,t,n,a){const{base:s,highVal:r,lookup:i}=this,o=MathClamp(Math.round(e[t]),0,r)*s.numComps;s.getRgbBuffer(i,o,1,n,a,8,0)}getRgbBuffer(e,t,n,a,s,r,i){const{base:o,highVal:l,lookup:f}=this,{numComps:c}=o,h=o.getOutputLength(c,i);for(let r=0;r<n;++r){const n=MathClamp(Math.round(e[t++]),0,l)*c;o.getRgbBuffer(f,n,1,a,s,8,i);s+=h}}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps,t)}isDefaultDecode(e,t){if(isDefaultDecodeHelper(e,2))return!0;if(!Number.isInteger(t)||t<1){warn("Bits per component is not correct");return!0}return 0===e[0]&&e[1]===(1<<t)-1}}class DeviceGrayCS extends ColorSpace{constructor(){super("DeviceGray",1)}getRgbItem(e,t,n,a){const s=255*e[t];n[a]=n[a+1]=n[a+2]=s}getRgbBuffer(e,t,n,a,s,r,i){const o=255/((1<<r)-1);let l=t,f=s;for(let t=0;t<n;++t){const t=o*e[l++];a[f++]=t;a[f++]=t;a[f++]=t;f+=i}}getOutputLength(e,t){return e*(3+t)}}class DeviceRgbCS extends ColorSpace{constructor(){super("DeviceRGB",3)}getRgbItem(e,t,n,a){n[a]=255*e[t];n[a+1]=255*e[t+1];n[a+2]=255*e[t+2]}getRgbBuffer(e,t,n,a,s,r,i){if(8===r&&0===i){a.set(e.subarray(t,t+3*n),s);return}const o=255/((1<<r)-1);let l=t,f=s;for(let t=0;t<n;++t){a[f++]=o*e[l++];a[f++]=o*e[l++];a[f++]=o*e[l++];f+=i}}getOutputLength(e,t){return e*(3+t)/3|0}isPassthrough(e){return 8===e}}class DeviceRgbaCS extends ColorSpace{constructor(){super("DeviceRGBA",4)}getOutputLength(e,t){return 4*e}isPassthrough(e){return 8===e}fillRgb(e,t,n,a,s,r,i,o,l){n!==s||t!==a?function resizeRgbaImage(e,t,n,a,s,r,i){const o=n/s,l=a/r;let f=0;const c=new Uint16Array(s);if(1===i){for(let e=0;e<s;e++)c[e]=Math.floor(e*o);const a=new Uint32Array(e.buffer),i=new Uint32Array(t.buffer),h=FeatureTest.isLittleEndian?16777215:4294967040;for(let e=0;e<r;e++){const t=a.subarray(Math.floor(e*l)*n);for(let e=0;e<s;e++)i[f++]|=t[c[e]]&h}}else{const a=4,i=n*a;for(let e=0;e<s;e++)c[e]=Math.floor(e*o)*a;for(let n=0;n<r;n++){const a=e.subarray(Math.floor(n*l)*i);for(let e=0;e<s;e++){const n=c[e];t[f++]=a[n];t[f++]=a[n+1];t[f++]=a[n+2]}}}}(o,e,t,n,a,s,l):function copyRgbaImage(e,t,n){if(1===n){const n=new Uint32Array(e.buffer),a=new Uint32Array(t.buffer),s=FeatureTest.isLittleEndian?16777215:4294967040;for(let e=0,t=n.length;e<t;e++)a[e]|=n[e]&s}else{let n=0;for(let a=0,s=e.length;a<s;a+=4){t[n++]=e[a];t[n++]=e[a+1];t[n++]=e[a+2]}}}(o,e,l)}}class DeviceCmykCS extends ColorSpace{constructor(){super("DeviceCMYK",4)}#s(e,t,n,a,s){const r=e[t]*n,i=e[t+1]*n,o=e[t+2]*n,l=e[t+3]*n;a[s]=255+r*(-4.387332384609988*r+54.48615194189176*i+18.82290502165302*o+212.25662451639585*l-285.2331026137004)+i*(1.7149763477362134*i-5.6096736904047315*o+-17.873870861415444*l-5.497006427196366)+o*(-2.5217340131683033*o-21.248923337353073*l+17.5119270841813)+l*(-21.86122147463605*l-189.48180835922747);a[s+1]=255+r*(8.841041422036149*r+60.118027045597366*i+6.871425592049007*o+31.159100130055922*l-79.2970844816548)+i*(-15.310361306967817*i+17.575251261109482*o+131.35250912493976*l-190.9453302588951)+o*(4.444339102852739*o+9.8632861493405*l-24.86741582555878)+l*(-20.737325471181034*l-187.80453709719578);a[s+2]=255+r*(.8842522430003296*r+8.078677503112928*i+30.89978309703729*o-.23883238689178934*l-14.183576799673286)+i*(10.49593273432072*i+63.02378494754052*o+50.606957656360734*l-112.23884253719248)+o*(.03296041114873217*o+115.60384449646641*l-193.58209356861505)+l*(-22.33816807309886*l-180.12613974708367)}getRgbItem(e,t,n,a){this.#s(e,t,1,n,a)}getRgbBuffer(e,t,n,a,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<n;r++){this.#s(e,t,o,a,s);t+=4;s+=3+i}}getOutputLength(e,t){return e/4*(3+t)|0}}class CalGrayCS extends ColorSpace{constructor(e,t,n){super("CalGray",1);if(!e)throw new FormatError("WhitePoint missing - required for color space CalGray");[this.XW,this.YW,this.ZW]=e;[this.XB,this.YB,this.ZB]=t||[0,0,0];this.G=n||1;if(this.XW<0||this.ZW<0||1!==this.YW)throw new FormatError(`Invalid WhitePoint components for ${this.name}, no fallback available`);if(this.XB<0||this.YB<0||this.ZB<0){info(`Invalid BlackPoint for ${this.name}, falling back to default.`);this.XB=this.YB=this.ZB=0}0===this.XB&&0===this.YB&&0===this.ZB||warn(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ZB: ${this.ZB}, only default values are supported.`);if(this.G<1){info(`Invalid Gamma: ${this.G} for ${this.name}, falling back to default.`);this.G=1}}#s(e,t,n,a,s){const r=(e[t]*s)**this.G,i=this.YW*r,o=Math.max(295.8*i**.3333333333333333-40.8,0);n[a]=o;n[a+1]=o;n[a+2]=o}getRgbItem(e,t,n,a){this.#s(e,t,n,a,1)}getRgbBuffer(e,t,n,a,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<n;++r){this.#s(e,t,a,s,o);t+=1;s+=3+i}}getOutputLength(e,t){return e*(3+t)}}class CalRGBCS extends ColorSpace{static#r=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]);static#i=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]);static#o=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]);static#l=new Float32Array([1,1,1]);static#f=new Float32Array(3);static#c=new Float32Array(3);static#h=new Float32Array(3);static#u=(24/116)**3/8;constructor(e,t,n,a){super("CalRGB",3);if(!e)throw new FormatError("WhitePoint missing - required for color space CalRGB");const[s,r,i]=this.whitePoint=e,[o,l,f]=this.blackPoint=t||new Float32Array(3);[this.GR,this.GG,this.GB]=n||new Float32Array([1,1,1]);[this.MXA,this.MYA,this.MZA,this.MXB,this.MYB,this.MZB,this.MXC,this.MYC,this.MZC]=a||new Float32Array([1,0,0,0,1,0,0,0,1]);if(s<0||i<0||1!==r)throw new FormatError(`Invalid WhitePoint components for ${this.name}, no fallback available`);if(o<0||l<0||f<0){info(`Invalid BlackPoint for ${this.name} [${o}, ${l}, ${f}], falling back to default.`);this.blackPoint=new Float32Array(3)}if(this.GR<0||this.GG<0||this.GB<0){info(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ${this.name}, falling back to default.`);this.GR=this.GG=this.GB=1}}#m(e,t,n){n[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];n[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2];n[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2]}#p(e,t,n){n[0]=1*t[0]/e[0];n[1]=1*t[1]/e[1];n[2]=1*t[2]/e[2]}#d(e,t,n){n[0]=.95047*t[0]/e[0];n[1]=1*t[1]/e[1];n[2]=1.08883*t[2]/e[2]}#g(e){return e<=.0031308?MathClamp(12.92*e,0,1):e>=.99554525?1:MathClamp(1.055*e**(1/2.4)-.055,0,1)}#b(e){return e<0?-this.#b(-e):e>8?((e+16)/116)**3:e*CalRGBCS.#u}#w(e,t,n){if(0===e[0]&&0===e[1]&&0===e[2]){n[0]=t[0];n[1]=t[1];n[2]=t[2];return}const a=this.#b(0),s=(1-a)/(1-this.#b(e[0])),r=1-s,i=(1-a)/(1-this.#b(e[1])),o=1-i,l=(1-a)/(1-this.#b(e[2])),f=1-l;n[0]=t[0]*s+r;n[1]=t[1]*i+o;n[2]=t[2]*l+f}#j(e,t,n){if(1===e[0]&&1===e[2]){n[0]=t[0];n[1]=t[1];n[2]=t[2];return}const a=n;this.#m(CalRGBCS.#r,t,a);const s=CalRGBCS.#f;this.#p(e,a,s);this.#m(CalRGBCS.#i,s,n)}#k(e,t,n){const a=n;this.#m(CalRGBCS.#r,t,a);const s=CalRGBCS.#f;this.#d(e,a,s);this.#m(CalRGBCS.#i,s,n)}#s(e,t,n,a,s){const r=MathClamp(e[t]*s,0,1),i=MathClamp(e[t+1]*s,0,1),o=MathClamp(e[t+2]*s,0,1),l=1===r?1:r**this.GR,f=1===i?1:i**this.GG,c=1===o?1:o**this.GB,h=this.MXA*l+this.MXB*f+this.MXC*c,u=this.MYA*l+this.MYB*f+this.MYC*c,m=this.MZA*l+this.MZB*f+this.MZC*c,p=CalRGBCS.#c;p[0]=h;p[1]=u;p[2]=m;const d=CalRGBCS.#h;this.#j(this.whitePoint,p,d);const g=CalRGBCS.#c;this.#w(this.blackPoint,d,g);const b=CalRGBCS.#h;this.#k(CalRGBCS.#l,g,b);const w=CalRGBCS.#c;this.#m(CalRGBCS.#o,b,w);n[a]=255*this.#g(w[0]);n[a+1]=255*this.#g(w[1]);n[a+2]=255*this.#g(w[2])}getRgbItem(e,t,n,a){this.#s(e,t,n,a,1)}getRgbBuffer(e,t,n,a,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<n;++r){this.#s(e,t,a,s,o);t+=3;s+=3+i}}getOutputLength(e,t){return e*(3+t)/3|0}}class LabCS extends ColorSpace{constructor(e,t,n){super("Lab",3);if(!e)throw new FormatError("WhitePoint missing - required for color space Lab");[this.XW,this.YW,this.ZW]=e;[this.amin,this.amax,this.bmin,this.bmax]=n||[-100,100,-100,100];[this.XB,this.YB,this.ZB]=t||[0,0,0];if(this.XW<0||this.ZW<0||1!==this.YW)throw new FormatError("Invalid WhitePoint components, no fallback available");if(this.XB<0||this.YB<0||this.ZB<0){info("Invalid BlackPoint, falling back to default");this.XB=this.YB=this.ZB=0}if(this.amin>this.amax||this.bmin>this.bmax){info("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin=-100;this.bmax=100}}#y(e){return e>=6/29?e**3:108/841*(e-4/29)}#q(e,t,n,a){return n+e*(a-n)/t}#s(e,t,n,a,s){let r=e[t],i=e[t+1],o=e[t+2];if(!1!==n){r=this.#q(r,n,0,100);i=this.#q(i,n,this.amin,this.amax);o=this.#q(o,n,this.bmin,this.bmax)}i>this.amax?i=this.amax:i<this.amin&&(i=this.amin);o>this.bmax?o=this.bmax:o<this.bmin&&(o=this.bmin);const l=(r+16)/116,f=l+i/500,c=l-o/200,h=this.XW*this.#y(f),u=this.YW*this.#y(l),m=this.ZW*this.#y(c);let p,d,g;if(this.ZW<1){p=3.1339*h+-1.617*u+-.4906*m;d=-.9785*h+1.916*u+.0333*m;g=.072*h+-.229*u+1.4057*m}else{p=3.2406*h+-1.5372*u+-.4986*m;d=-.9689*h+1.8758*u+.0415*m;g=.0557*h+-.204*u+1.057*m}a[s]=255*Math.sqrt(p);a[s+1]=255*Math.sqrt(d);a[s+2]=255*Math.sqrt(g)}getRgbItem(e,t,n,a){this.#s(e,t,!1,n,a)}getRgbBuffer(e,t,n,a,s,r,i){const o=(1<<r)-1;for(let r=0;r<n;r++){this.#s(e,t,o,a,s);t+=3;s+=3+i}}getOutputLength(e,t){return e*(3+t)/3|0}isDefaultDecode(e,t){return!0}get usesZeroToOneRange(){return shadow(this,"usesZeroToOneRange",!1)}}function fetchSync(e){const t=new XMLHttpRequest;t.open("GET",e,!1);t.responseType="arraybuffer";t.send(null);return t.response}class IccColorSpace extends ColorSpace{#v;#S;static#x=!0;static#A=null;static#C=null;constructor(e,t,n){if(!IccColorSpace.isUsable)throw new Error("No ICC color space support");super(t,n);let a;switch(n){case 1:a=vn.Gray8;this.#S=(e,t,n)=>function qcms_convert_one(e,t,n){jn.qcms_convert_one(e,t,n)}(this.#v,255*e[t],n);break;case 3:a=vn.RGB8;this.#S=(e,t,n)=>function qcms_convert_three(e,t,n,a,s){jn.qcms_convert_three(e,t,n,a,s)}(this.#v,255*e[t],255*e[t+1],255*e[t+2],n);break;case 4:a=vn.CMYK;this.#S=(e,t,n)=>function qcms_convert_four(e,t,n,a,s,r){jn.qcms_convert_four(e,t,n,a,s,r)}(this.#v,255*e[t],255*e[t+1],255*e[t+2],255*e[t+3],n);break;default:throw new Error(`Unsupported number of components: ${n}`)}this.#v=function qcms_transformer_from_memory(e,t,n){const a=passArray8ToWasm0(e,jn.__wbindgen_malloc),s=qn;return jn.qcms_transformer_from_memory(a,s,t,n)>>>0}(e,a,Sn.Perceptual);if(!this.#v)throw new Error("Failed to create ICC color space");IccColorSpace.#C||=new FinalizationRegistry(e=>{!function qcms_drop_transformer(e){jn.qcms_drop_transformer(e)}(e)});IccColorSpace.#C.register(this,this.#v)}getRgbHex(e,t){this.#S(e,t,!0);return QCMS._cssColor}getRgbItem(e,t,n,a){QCMS._destBuffer=n;QCMS._destOffset=a;QCMS._destLength=3;this.#S(e,t,!1);QCMS._destBuffer=null}getRgbBuffer(e,t,n,a,s,r,i){e=e.subarray(t,t+n*this.numComps);if(8!==r){const t=255/((1<<r)-1);for(let n=0,a=e.length;n<a;n++)e[n]*=t}QCMS._mustAddAlpha=i&&a.buffer===e.buffer;QCMS._destBuffer=a;QCMS._destOffset=s;QCMS._destLength=n*(3+i);!function qcms_convert_array(e,t){const n=passArray8ToWasm0(t,jn.__wbindgen_malloc),a=qn;jn.qcms_convert_array(e,n,a)}(this.#v,e);QCMS._mustAddAlpha=!1;QCMS._destBuffer=null}getOutputLength(e,t){return e/this.numComps*(3+t)|0}static setOptions({useWasm:e,useWorkerFetch:t,wasmUrl:n}){if(t){this.#x=e;this.#A=n}else this.#x=!1}static get isUsable(){let e=!1;if(this.#x)if(this.#A)try{this._module=function initSync(e){if(void 0!==jn)return jn;void 0!==e&&(Object.getPrototypeOf(e)===Object.prototype?({module:e}=e):console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const t=__wbg_get_imports();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));return __wbg_finalize_init(new WebAssembly.Instance(e,t),e)}({module:fetchSync(`${this.#A}qcms_bg.wasm`)});e=!!this._module;QCMS._memory=this._module.memory;QCMS._makeHexColor=Util.makeHexColor}catch(e){warn(`ICCBased color space: "${e}".`)}else warn("No ICC color space support due to missing `wasmUrl` API option");return shadow(this,"isUsable",e)}}class CmykICCBasedCS extends IccColorSpace{static#I;constructor(){super(new Uint8Array(fetchSync(`${CmykICCBasedCS.#I}CGATS001Compat-v2-micro.icc`)),"DeviceCMYK",4)}static setOptions({iccUrl:e}){this.#I=e}static get isUsable(){let e=!1;IccColorSpace.isUsable&&(this.#I?e=!0:warn("No CMYK ICC profile support due to missing `iccUrl` API option"));return shadow(this,"isUsable",e)}}class Stream extends BaseStream{constructor(e,t,n,a){super();this.bytes=e instanceof Uint8Array?e:new Uint8Array(e);this.start=t||0;this.pos=this.start;this.end=t+n||this.bytes.length;this.dict=a}get length(){return this.end-this.start}get isEmpty(){return 0===this.length}getByte(){return this.pos>=this.end?-1:this.bytes[this.pos++]}getBytes(e){const t=this.bytes,n=this.pos,a=this.end;if(!e){this.pos=a;return t.subarray(n,a)}let s=n+e;s>a&&(s=a);this.pos=s;return t.subarray(n,s)}getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);return this.bytes.subarray(e,t)}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(e,t,n=null){return new Stream(this.bytes.buffer,e,t,n)}clone(){return new Stream(this.bytes.buffer,this.start,this.end-this.start,this.dict.clone())}}class StringStream extends Stream{constructor(e){super(stringToBytes(e))}}class NullStream extends Stream{constructor(){super(new Uint8Array(0))}}class ChunkedStream extends Stream{progressiveDataLength=0;_lastSuccessfulEnsureByteChunk=-1;_loadedChunks=new Set;constructor(e,t,n){super(new Uint8Array(e),0,e,null);this.chunkSize=t;this.numChunks=Math.ceil(e/t);this.manager=n}getMissingChunks(){const e=[];for(let t=0,n=this.numChunks;t<n;++t)this._loadedChunks.has(t)||e.push(t);return e}get numChunksLoaded(){return this._loadedChunks.size}get isDataLoaded(){return this.numChunksLoaded===this.numChunks}onReceiveData(e,t){const n=this.chunkSize;if(e%n!==0)throw new Error(`Bad begin offset: ${e}`);const a=e+t.byteLength;if(a%n!==0&&a!==this.bytes.length)throw new Error(`Bad end offset: ${a}`);this.bytes.set(new Uint8Array(t),e);const s=Math.floor(e/n),r=Math.floor((a-1)/n)+1;for(let e=s;e<r;++e)this._loadedChunks.add(e)}onReceiveProgressiveData(e){let t=this.progressiveDataLength;const n=Math.floor(t/this.chunkSize);this.bytes.set(new Uint8Array(e),t);t+=e.byteLength;this.progressiveDataLength=t;const a=t>=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(let e=n;e<a;++e)this._loadedChunks.add(e)}ensureByte(e){if(e<this.progressiveDataLength)return;const t=Math.floor(e/this.chunkSize);if(!(t>this.numChunks)&&t!==this._lastSuccessfulEnsureByteChunk){if(!this._loadedChunks.has(t))throw new MissingDataException(e,e+1);this._lastSuccessfulEnsureByteChunk=t}}ensureRange(e,t){if(e>=t)return;if(t<=this.progressiveDataLength)return;const n=Math.floor(e/this.chunkSize);if(n>this.numChunks)return;const a=Math.min(Math.floor((t-1)/this.chunkSize)+1,this.numChunks);for(let s=n;s<a;++s)if(!this._loadedChunks.has(s))throw new MissingDataException(e,t)}nextEmptyChunk(e){const t=this.numChunks;for(let n=0;n<t;++n){const a=(e+n)%t;if(!this._loadedChunks.has(a))return a}return null}hasChunk(e){return this._loadedChunks.has(e)}getByte(){const e=this.pos;if(e>=this.end)return-1;e>=this.progressiveDataLength&&this.ensureByte(e);return this.bytes[this.pos++]}getBytes(e){const t=this.bytes,n=this.pos,a=this.end;if(!e){a>this.progressiveDataLength&&this.ensureRange(n,a);return t.subarray(n,a)}let s=n+e;s>a&&(s=a);s>this.progressiveDataLength&&this.ensureRange(n,s);this.pos=s;return t.subarray(n,s)}getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);t>this.progressiveDataLength&&this.ensureRange(e,t);return this.bytes.subarray(e,t)}makeSubStream(e,t,n=null){t?e+t>this.progressiveDataLength&&this.ensureRange(e,e+t):e>=this.progressiveDataLength&&this.ensureByte(e);function ChunkedStreamSubstream(){}ChunkedStreamSubstream.prototype=Object.create(this);ChunkedStreamSubstream.prototype.getMissingChunks=function(){const e=this.chunkSize,t=Math.floor(this.start/e),n=Math.floor((this.end-1)/e)+1,a=[];for(let e=t;e<n;++e)this._loadedChunks.has(e)||a.push(e);return a};Object.defineProperty(ChunkedStreamSubstream.prototype,"isDataLoaded",{get(){return this.numChunksLoaded===this.numChunks||0===this.getMissingChunks().length},configurable:!0});const a=new ChunkedStreamSubstream;a.pos=a.start=e;a.end=e+t||this.end;a.dict=n;return a}getBaseStreams(){return[this]}}class ChunkedStreamManager{aborted=!1;currRequestId=0;_chunksNeededByRequest=new Map;_loadedStreamCapability=Promise.withResolvers();_promisesByRequest=new Map;_requestsByChunk=new Map;constructor(e,t){this.length=t.length;this.chunkSize=t.rangeChunkSize;this.stream=new ChunkedStream(this.length,this.chunkSize,this);this.pdfStream=e;this.disableAutoFetch=t.disableAutoFetch;this.msgHandler=t.msgHandler}async sendRequest(e,t){const n=this.pdfStream.getRangeReader(e,t);let a=[];for(;;){const{value:e,done:t}=await n.read();if(this.aborted){a=null;return}if(t)break;a.push(e)}if(0===a.length&&this.disableAutoFetch)return;const s=arrayBuffersToBytes(a);a=null;this.onReceiveData({chunk:s.buffer,begin:e})}requestAllChunks(e=!1){if(!e){const e=this.stream.getMissingChunks();this._requestChunks(e)}return this._loadedStreamCapability.promise}_requestChunks(e){const t=this.currRequestId++,n=new Set;this._chunksNeededByRequest.set(t,n);for(const t of e)this.stream.hasChunk(t)||n.add(t);if(0===n.size)return Promise.resolve();const a=Promise.withResolvers();this._promisesByRequest.set(t,a);const s=[];for(const e of n){let n=this._requestsByChunk.get(e);if(!n){n=[];this._requestsByChunk.set(e,n);s.push(e)}n.push(t)}if(s.length>0){const e=this.groupChunks(s);for(const t of e){const e=t.beginChunk*this.chunkSize,n=Math.min(t.endChunk*this.chunkSize,this.length);this.sendRequest(e,n).catch(a.reject)}}return a.promise.catch(e=>{if(!this.aborted)throw e})}getStream(){return this.stream}requestRange(e,t){t=Math.min(t,this.length);const n=this.getBeginChunk(e),a=this.getEndChunk(t),s=[];for(let e=n;e<a;++e)s.push(e);return this._requestChunks(s)}requestRanges(e=[]){const t=[];for(const n of e){const e=this.getBeginChunk(n.begin),a=this.getEndChunk(n.end);for(let n=e;n<a;++n)t.includes(n)||t.push(n)}t.sort((e,t)=>e-t);return this._requestChunks(t)}groupChunks(e){const t=[];let n=-1,a=-1;for(let s=0,r=e.length;s<r;++s){const r=e[s];n<0&&(n=r);if(a>=0&&a+1!==r){t.push({beginChunk:n,endChunk:a+1});n=r}s+1===e.length&&t.push({beginChunk:n,endChunk:r+1});a=r}return t}onReceiveData(e){const{chunkSize:t,length:n,stream:a}=this,s=e.chunk,r=void 0===e.begin,i=r?a.progressiveDataLength:e.begin,o=i+s.byteLength,l=Math.floor(i/t),f=o<n?Math.floor(o/t):Math.ceil(o/t);r?a.onReceiveProgressiveData(s):a.onReceiveData(i,s);a.isDataLoaded&&this._loadedStreamCapability.resolve(a);const c=[];for(let e=l;e<f;++e){const t=this._requestsByChunk.get(e);if(t){this._requestsByChunk.delete(e);for(const n of t){const t=this._chunksNeededByRequest.get(n);t.has(e)&&t.delete(e);t.size>0||c.push(n)}}}if(!this.disableAutoFetch&&0===this._requestsByChunk.size){let e;if(1===a.numChunksLoaded){const t=a.numChunks-1;a.hasChunk(t)||(e=t)}else e=a.nextEmptyChunk(f);Number.isInteger(e)&&this._requestChunks([e])}for(const e of c){const t=this._promisesByRequest.get(e);this._promisesByRequest.delete(e);t.resolve()}this.msgHandler.send("DocProgress",{loaded:MathClamp(a.numChunksLoaded*t,a.progressiveDataLength,n),total:n})}onError(e){this._loadedStreamCapability.reject(e)}getBeginChunk(e){return Math.floor(e/this.chunkSize)}getEndChunk(e){return Math.floor((e-1)/this.chunkSize)+1}abort(e){this.aborted=!0;this.pdfStream?.cancelAllRequests(e);for(const t of this._promisesByRequest.values())t.reject(e)}}func