extract2md
Version:
Client-side PDF to Markdown conversion with OCR and optional LLM rewrite. Core dependencies bundled for offline use.
2 lines • 974 kB
JavaScript
/*! For license information please see pdf.worker.min.mjs.LICENSE.txt */
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],a=1.35,s=.25925925925925924,i="pdfjs_internal_editor_",n={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},r="Group",o={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"},c={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},l={O:"PageOpen",C:"PageClose"},h=10,u=11,d=12,f=37,g=42,p=44,m=58,b=59,w=70,y=71,k=83,x=91;let v=1;function C(e){v>=5&&console.log(`Info: ${e}`)}function A(e){v>=1&&console.log(`Warning: ${e}`)}function S(e){throw new Error(e)}function I(e,t){e||S(t)}function B(e,t=null,a=null){if(!e)return null;if(a&&"string"==typeof e){if(a.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(a.tryConvertEncoding)try{e=G(e)}catch{}}const s=t?URL.parse(e,t):URL.parse(e);return function(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function F(e,t,a,s=!1){return Object.defineProperty(e,t,{value:a,enumerable:!s,configurable:!0,writable:!1}),a}const M=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=new Error,e.constructor=e,e}();class T extends M{constructor(e,t){super(e,"PasswordException"),this.code=t}}class D extends M{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class O extends M{constructor(e){super(e,"InvalidPDFException")}}class R extends M{constructor(e,t,a){super(e,"ResponseException"),this.status=t,this.missing=a}}class N extends M{constructor(e){super(e,"FormatError")}}class _ extends M{constructor(e){super(e,"AbortException")}}function P(e){"object"==typeof e&&void 0!==e?.length||S("Invalid argument for bytesToString");const t=e.length,a=8192;if(t<a)return String.fromCharCode.apply(null,e);const s=[];for(let i=0;i<t;i+=a){const n=Math.min(i+a,t),r=e.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function E(e){"string"!=typeof e&&S("Invalid argument for stringToBytes");const t=e.length,a=new Uint8Array(t);for(let s=0;s<t;++s)a[s]=255&e.charCodeAt(s);return a}function L(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}function U(e){return Object.keys(e).length}class q{static get isLittleEndian(){return F(this,"isLittleEndian",function(){const e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return F(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return F(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return F(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){if("undefined"!=typeof navigator&&"string"==typeof navigator?.platform&&"string"==typeof navigator?.userAgent){const{platform:e,userAgent:t}=navigator;return F(this,"platform",{isAndroid:t.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:t.includes("Firefox")})}return F(this,"platform",{isAndroid:!1,isLinux:!1,isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return F(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const j=Array.from(Array(256).keys(),(e=>e.toString(16).padStart(2,"0")));class ${static makeHexColor(e,t,a){return`#${j[e]}${j[t]}${j[a]}`}static scaleMinMax(e,t){let a;e[0]?(e[0]<0&&(a=t[0],t[0]=t[2],t[2]=a),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(a=t[1],t[1]=t[3],t[3]=a),t[1]*=e[3],t[3]*=e[3]):(a=t[0],t[0]=t[1],t[1]=a,a=t[2],t[2]=t[3],t[3]=a,e[1]<0&&(a=t[1],t[1]=t[3],t[3]=a),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(a=t[0],t[0]=t[2],t[2]=a),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 applyTransform(e,t,a=0){const s=e[a],i=e[a+1];e[a]=s*t[0]+i*t[2]+t[4],e[a+1]=s*t[1]+i*t[3]+t[5]}static applyTransformToBezier(e,t,a=0){const s=t[0],i=t[1],n=t[2],r=t[3],o=t[4],c=t[5];for(let t=0;t<6;t+=2){const l=e[a+t],h=e[a+t+1];e[a+t]=l*s+h*n+o,e[a+t+1]=l*i+h*r+c}}static applyInverseTransform(e,t){const a=e[0],s=e[1],i=t[0]*t[3]-t[1]*t[2];e[0]=(a*t[3]-s*t[2]+t[2]*t[5]-t[4]*t[3])/i,e[1]=(-a*t[1]+s*t[0]+t[4]*t[1]-t[5]*t[0])/i}static axialAlignedBoundingBox(e,t,a){const s=t[0],i=t[1],n=t[2],r=t[3],o=t[4],c=t[5],l=e[0],h=e[1],u=e[2],d=e[3];let f=s*l+o,g=f,p=s*u+o,m=p,b=r*h+c,w=b,y=r*d+c,k=y;if(0!==i||0!==n){const e=i*l,t=i*u,a=n*h,s=n*d;f+=a,m+=a,p+=s,g+=s,b+=e,k+=e,y+=t,w+=t}a[0]=Math.min(a[0],f,p,g,m),a[1]=Math.min(a[1],b,y,w,k),a[2]=Math.max(a[2],f,p,g,m),a[3]=Math.max(a[3],b,y,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 a=e[0],s=e[1],i=e[2],n=e[3],r=a**2+s**2,o=a*i+s*n,c=i**2+n**2,l=(r+c)/2,h=Math.sqrt(l**2-(r*c-o**2));t[0]=Math.sqrt(l+h||1),t[1]=Math.sqrt(l-h||1)}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const a=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),s=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(a>s)return null;const i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),n=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>n?null:[a,i,s,n]}static pointBoundingBox(e,t,a){a[0]=Math.min(a[0],e),a[1]=Math.min(a[1],t),a[2]=Math.max(a[2],e),a[3]=Math.max(a[3],t)}static rectBoundingBox(e,t,a,s,i){i[0]=Math.min(i[0],e,a),i[1]=Math.min(i[1],t,s),i[2]=Math.max(i[2],e,a),i[3]=Math.max(i[3],t,s)}static#e(e,t,a,s,i,n,r,o,c,l){if(c<=0||c>=1)return;const h=1-c,u=c*c,d=u*c,f=h*(h*(h*e+3*c*t)+3*u*a)+d*s,g=h*(h*(h*i+3*c*n)+3*u*r)+d*o;l[0]=Math.min(l[0],f),l[1]=Math.min(l[1],g),l[2]=Math.max(l[2],f),l[3]=Math.max(l[3],g)}static#t(e,t,a,s,i,n,r,o,c,l,h,u){if(Math.abs(c)<1e-12)return void(Math.abs(l)>=1e-12&&this.#e(e,t,a,s,i,n,r,o,-h/l,u));const d=l**2-4*h*c;if(d<0)return;const f=Math.sqrt(d),g=2*c;this.#e(e,t,a,s,i,n,r,o,(-l+f)/g,u),this.#e(e,t,a,s,i,n,r,o,(-l-f)/g,u)}static bezierBoundingBox(e,t,a,s,i,n,r,o,c){c[0]=Math.min(c[0],e,r),c[1]=Math.min(c[1],t,o),c[2]=Math.max(c[2],e,r),c[3]=Math.max(c[3],t,o),this.#t(e,a,i,r,t,s,n,o,3*(3*(a-i)-e+r),6*(e-2*a+i),3*(a-e),c),this.#t(e,a,i,r,t,s,n,o,3*(3*(s-n)-t+o),6*(t-2*s+n),3*(s-t),c)}}const H=[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 z(e){if(e[0]>="ï"){let t;if("þ"===e[0]&&"ÿ"===e[1]?(t="utf-16be",e.length%2==1&&(e=e.slice(0,-1))):"ÿ"===e[0]&&"þ"===e[1]?(t="utf-16le",e.length%2==1&&(e=e.slice(0,-1))):"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(t="utf-8"),t)try{const a=new TextDecoder(t,{fatal:!0}),s=E(e),i=a.decode(s);return i.includes("")?i.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g,""):i}catch(e){A(`stringToPDFString: "${e}".`)}}const t=[];for(let a=0,s=e.length;a<s;a++){const i=e.charCodeAt(a);if(27===i){for(;++a<s&&27!==e.charCodeAt(a););continue}const n=H[i];t.push(n?String.fromCharCode(n):e.charAt(a))}return t.join("")}function G(e){return decodeURIComponent(escape(e))}function W(e){return unescape(encodeURIComponent(e))}function V(e,t){if(e.length!==t.length)return!1;for(let a=0,s=e.length;a<s;a++)if(e[a]!==t[a])return!1;return!0}function X(e=new Date){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 K=null,Y=null;function J(e,t,a){return Math.min(Math.max(e,t),a)}function Z(e){return Uint8Array.prototype.toHex?e.toHex():Array.from(e,(e=>j[e])).join("")}"function"!=typeof Promise.try&&(Promise.try=function(e,...t){return new Promise((a=>{a(e(...t))}))}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(e){return e.reduce(((e,t)=>e+t),0)});const Q=Symbol("CIRCULAR_REF"),ee=Symbol("EOF");let te=Object.create(null),ae=Object.create(null),se=Object.create(null);class ie{constructor(e){this.name=e}static get(e){return ae[e]||=new ie(e)}}class ne{constructor(e){this.cmd=e}static get(e){return te[e]||=new ne(e)}}const re=function(){return re};class oe{constructor(e=null){this._map=new Map,this.xref=e,this.objId=null,this.suppressEncryption=!1,this.__nonSerializable__=re}assignXref(e){this.xref=e}get size(){return this._map.size}get(e,t,a){let s=this._map.get(e);return void 0===s&&void 0!==t&&(s=this._map.get(t),void 0===s&&void 0!==a&&(s=this._map.get(a))),s instanceof ce&&this.xref?this.xref.fetch(s,this.suppressEncryption):s}async getAsync(e,t,a){let s=this._map.get(e);return void 0===s&&void 0!==t&&(s=this._map.get(t),void 0===s&&void 0!==a&&(s=this._map.get(a))),s instanceof ce&&this.xref?this.xref.fetchAsync(s,this.suppressEncryption):s}getArray(e,t,a){let s=this._map.get(e);if(void 0===s&&void 0!==t&&(s=this._map.get(t),void 0===s&&void 0!==a&&(s=this._map.get(a))),s instanceof ce&&this.xref&&(s=this.xref.fetch(s,this.suppressEncryption)),Array.isArray(s)){s=s.slice();for(let e=0,t=s.length;e<t;e++)s[e]instanceof ce&&this.xref&&(s[e]=this.xref.fetch(s[e],this.suppressEncryption))}return s}getRaw(e){return this._map.get(e)}getKeys(){return[...this._map.keys()]}getRawValues(){return[...this._map.values()]}set(e,t){this._map.set(e,t)}has(e){return this._map.has(e)}*[Symbol.iterator](){for(const[e,t]of this._map)yield[e,t instanceof ce&&this.xref?this.xref.fetch(t,this.suppressEncryption):t]}static get empty(){const e=new oe(null);return e.set=(e,t)=>{S("Should not call `set` on the empty dictionary.")},F(this,"empty",e)}static merge({xref:e,dictArray:t,mergeSubDicts:a=!1}){const s=new oe(e),i=new Map;for(const e of t)if(e instanceof oe)for(const[t,s]of e._map){let e=i.get(t);if(void 0===e)e=[],i.set(t,e);else if(!(a&&s instanceof oe))continue;e.push(s)}for(const[t,a]of i){if(1===a.length||!(a[0]instanceof oe)){s._map.set(t,a[0]);continue}const i=new oe(e);for(const e of a)for(const[t,a]of e._map)i._map.has(t)||i._map.set(t,a);i.size>0&&s._map.set(t,i)}return i.clear(),s.size>0?s:oe.empty}clone(){const e=new oe(this.xref);for(const t of this.getKeys())e.set(t,this.getRaw(t));return e}delete(e){delete this._map[e]}}class ce{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=se[e];if(t)return t;const a=/^(\d+)R(\d*)$/.exec(e);return a&&"0"!==a[1]?se[e]=new ce(parseInt(a[1]),a[2]?parseInt(a[2]):0):null}static get(e,t){const a=0===t?`${e}R`:`${e}R${t}`;return se[a]||=new ce(e,t)}}class le{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 he{constructor(){this._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[ce.fromString(e),t]}}function ue(e,t){return e instanceof ie&&(void 0===t||e.name===t)}function de(e,t){return e instanceof ne&&(void 0===t||e.cmd===t)}function fe(e,t){return e instanceof oe&&(void 0===t||ue(e.get("Type"),t))}function ge(e,t){return e.num===t.num&&e.gen===t.gen}class pe{get length(){S("Abstract getter `length` accessed")}get isEmpty(){S("Abstract getter `isEmpty` accessed")}get isDataLoaded(){return F(this,"isDataLoaded",!0)}getByte(){S("Abstract method `getByte` called")}getBytes(e){S("Abstract method `getBytes` called")}async getImageData(e,t){return this.getBytes(e,t)}async asyncGetBytes(){S("Abstract method `asyncGetBytes` called")}get isAsync(){return!1}get isAsyncDecoder(){return!1}get canAsyncDecodeImageFromBuffer(){return!1}async getTransferableImage(){return null}peekByte(){const e=this.getByte();return-1!==e&&this.pos--,e}peekBytes(e){const t=this.getBytes(e);return this.pos-=t.length,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){S("Abstract method `getByteRange` called")}getString(e){return P(this.getBytes(e))}skip(e){this.pos+=e||1}reset(){S("Abstract method `reset` called")}moveStart(){S("Abstract method `moveStart` called")}makeSubStream(e,t,a=null){S("Abstract method `makeSubStream` called")}getBaseStreams(){return null}}const me=/^[1-9]\.\d$/,be=2**31-1,we=[1,0,0,1,0,0],ye=["ColorSpace","ExtGState","Font","Pattern","Properties","Shading","XObject"],ke=["ExtGState","Font","Properties","XObject"];function xe(e){let t;return function(){return e&&(t=Object.create(null),e(t),e=null),t}}class ve extends M{constructor(e,t){super(`Missing data [${e}, ${t})`,"MissingDataException"),this.begin=e,this.end=t}}class Ce extends M{constructor(e){super(e,"ParserEOFException")}}class Ae extends M{constructor(e){super(e,"XRefEntryException")}}class Se extends M{constructor(e){super(e,"XRefParseException")}}function Ie(e){const t=e.length;if(0===t)return new Uint8Array(0);if(1===t)return new Uint8Array(e[0]);let a=0;for(let s=0;s<t;s++)a+=e[s].byteLength;const s=new Uint8Array(a);let i=0;for(let a=0;a<t;a++){const t=new Uint8Array(e[a]);s.set(t,i),i+=t.byteLength}return s}async function Be(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch file "${e}" with "${t.statusText}".`);return new Uint8Array(await t.arrayBuffer())}function Fe({dict:e,key:t,getArray:a=!1,stopWhenFound:s=!0}){let i;const n=new le;for(;e instanceof oe&&(!e.objId||!n.has(e.objId));){e.objId&&n.put(e.objId);const r=a?e.getArray(t):e.get(t);if(void 0!==r){if(s)return r;(i||=[]).push(r)}e=e.get("Parent")}return i}const Me=["","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 Te(e,t=!1){I(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const a="M".repeat(e/1e3|0)+Me[e%1e3/100|0]+Me[10+(e%100/10|0)]+Me[20+e%10];return t?a.toLowerCase():a}function De(e){return e>0?Math.ceil(Math.log2(e)):0}function Oe(e,t){return e[t]<<24>>24}function Re(e,t){return(e[t]<<24|e[t+1]<<16)>>16}function Ne(e,t){return e[t]<<8|e[t+1]}function _e(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Pe(e){return 32===e||9===e||13===e||10===e}function Ee(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 Le(e,t){return Ee(e,6)?e:t}function Ue(e,t){return Ee(e,4)?e:t}function qe(e,t){return Ee(e,4)?$.normalizeRect(e):t}function je(e){const t=/(.+)\[(\d+)\]$/;return e.split(".").map((e=>{const a=e.match(t);return a?{name:a[1],pos:parseInt(a[2],10)}:{name:e,pos:0}}))}function $e(e){const t=[];let a=0;for(let s=0,i=e.length;s<i;s++){const i=e.charCodeAt(s);(i<33||i>126||35===i||40===i||41===i||60===i||62===i||91===i||93===i||123===i||125===i||47===i||37===i)&&(a<s&&t.push(e.substring(a,s)),t.push(`#${i.toString(16)}`),a=s+1)}return 0===t.length?e:(a<e.length&&t.push(e.substring(a,e.length)),t.join(""))}function He(e){return e.replaceAll(/([()\\\n\r])/g,(e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`))}function ze(e,t,a,s){if(!e)return;let i=null;if(e instanceof ce){if(s.has(e))return;i=e,s.put(i),e=t.fetch(e)}if(Array.isArray(e))for(const i of e)ze(i,t,a,s);else if(e instanceof oe){if(ue(e.get("S"),"JavaScript")){const t=e.get("JS");let s;t instanceof pe?s=t.getString():"string"==typeof t&&(s=t),s&&=z(s).replaceAll("\0",""),s&&a.push(s)}ze(e.getRaw("Next"),t,a,s)}i&&s.remove(i)}function Ge(e,t,a){const s=Object.create(null),i=Fe({dict:t,key:"AA",stopWhenFound:!1});if(i)for(let t=i.length-1;t>=0;t--){const n=i[t];if(n instanceof oe)for(const t of n.getKeys()){const i=a[t];if(!i)continue;const r=[];ze(n.getRaw(t),e,r,new le),r.length>0&&(s[i]=r)}}if(t.has("A")){const a=[];ze(t.get("A"),e,a,new le),a.length>0&&(s.Action=a)}return U(s)>0?s:null}const We={60:"<",62:">",38:"&",34:""",39:"'"};function*Ve(e){for(let t=0,a=e.length;t<a;t++){const a=e.codePointAt(t);a>55295&&(a<57344||a>65533)&&t++,yield a}}function Xe(e){const t=[];let a=0;for(let s=0,i=e.length;s<i;s++){const i=e.codePointAt(s);if(32<=i&&i<=126){const n=We[i];n&&(a<s&&t.push(e.substring(a,s)),t.push(n),a=s+1)}else a<s&&t.push(e.substring(a,s)),t.push(`&#x${i.toString(16).toUpperCase()};`),i>55295&&(i<57344||i>65533)&&s++,a=s+1}return 0===t.length?e:(a<e.length&&t.push(e.substring(a,e.length)),t.join(""))}function Ke(e,t=!1){const a=/^("|').*("|')$/.exec(e);if(a&&a[1]===a[2]){if(new RegExp(`[^\\\\]${a[1]}`).test(e.slice(1,-1)))return t&&A(`FontFamily contains unescaped ${a[1]}: ${e}.`),!1}else for(const a of e.split(/[ \t]+/))if(/^(\d|(-(\d|-)))/.test(a)||!/^[\w-\\]+$/.test(a))return t&&A(`FontFamily contains invalid <custom-ident>: ${e}.`),!1;return!0}function Ye(e){const t=new Set(["100","200","300","400","500","600","700","800","900","1000","normal","bold","bolder","lighter"]),{fontFamily:a,fontWeight:s,italicAngle:i}=e;if(!Ke(a,!0))return!1;const n=s?s.toString():"";e.fontWeight=t.has(n)?n:"400";const r=parseFloat(i);return e.italicAngle=isNaN(r)||r<-90||r>90?"14":i.toString(),!0}function Je(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 Ze(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 Qe(e){if(!e)return null;const t=new Map;for(const[a,s]of e){if(!a.startsWith(i))continue;let e=t.get(s.pageIndex);e||(e=[],t.set(s.pageIndex,e)),e.push(s)}return t.size>0?t:null}function et(e){return function(e){return/^[\x00-\x7F]*$/.test(e)}(e)?e:at(e,!0)}function tt(e){const t=[];for(let a=0,s=e.length;a<s;a++){const s=e.charCodeAt(a);t.push(j[s>>8&255],j[255&s])}return t.join("")}function at(e,t=!1){const a=[];t&&a.push("þÿ");for(let t=0,s=e.length;t<s;t++){const s=e.charCodeAt(t);a.push(String.fromCharCode(s>>8&255),String.fromCharCode(255&s))}return a.join("")}function st(e,t,a){switch(e){case 90:return[0,1,-1,0,t,0];case 180:return[-1,0,0,-1,t,a];case 270:return[0,-1,1,0,0,a];default:throw new Error("Invalid rotation")}}function it(e){return Math.ceil(Math.ceil(Math.log2(1+e))/8)}class nt{static _module=null;static _mustAddAlpha=!1;static _destBuffer=null}let rt;const ot="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&ot.decode();let ct=null;function lt(){return null!==ct&&0!==ct.byteLength||(ct=new Uint8Array(rt.memory.buffer)),ct}let ht=0;function ut(e,t){const a=t(1*e.length,1)>>>0;return lt().set(e,a/1),ht=e.length,a}const dt=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"}),ft=Object.freeze({Perceptual:0,0:"Perceptual",RelativeColorimetric:1,1:"RelativeColorimetric",Saturation:2,2:"Saturation",AbsoluteColorimetric:3,3:"AbsoluteColorimetric"});function gt(){const e={wbg:{}};return e.wbg.__wbg_copyresult_b08ee7d273f295dd=function(e,t){!function(e,t){const{_module:a,_mustAddAlpha:s,_destBuffer:i}=nt,n=new Uint8Array(a.memory.buffer,e,t);if(n.length!==i.length)if(s)for(let e=0,t=0,a=n.length;e<a;e+=3,t+=4)i[t]=n[e],i[t+1]=n[e+1],i[t+2]=n[e+2],i[t+3]=255;else for(let e=0,t=0,a=n.length;e<a;e+=3,t+=4)i[t]=n[e],i[t+1]=n[e+1],i[t+2]=n[e+2];else i.set(n)}(e>>>0,t>>>0)},e.wbg.__wbg_copyrgb_d60ce17bb05d9b67=function(e){!function(e){nt._destBuffer.set(new Uint8Array(nt._module.memory.buffer,e,3))}(e>>>0)},e.wbg.__wbindgen_init_externref_table=function(){const e=rt.__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(e,t){return e>>>=0,ot.decode(lt().subarray(e,e+t))}(e,t))},e}function pt(e,t){return rt=e.exports,mt.__wbindgen_wasm_module=t,ct=null,rt.__wbindgen_start(),rt}async function mt(e){if(void 0!==rt)return rt;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")),void 0===e&&(e=new URL("qcms_bg.wasm",import.meta.url));const t=gt();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:a,module:s}=await async function(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 a=await e.arrayBuffer();return await WebAssembly.instantiate(a,t)}{const a=await WebAssembly.instantiate(e,t);return a instanceof WebAssembly.Instance?{instance:a,module:e}:a}}(await e,t);return pt(a,s)}class bt{constructor(e,t){this.name=e,this.numComps=t}getRgb(e,t){const a=new Uint8ClampedArray(3);return this.getRgbItem(e,t,a,0),a}getRgbItem(e,t,a,s){S("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,a,s,i,n,r){S("Should not call ColorSpace.getRgbBuffer")}getOutputLength(e,t){S("Should not call ColorSpace.getOutputLength")}isPassthrough(e){return!1}isDefaultDecode(e,t){return bt.isDefaultDecode(e,this.numComps)}fillRgb(e,t,a,s,i,n,r,o,c){const l=t*a;let h=null;const u=1<<r,d=a!==i||t!==s;if(this.isPassthrough(r))h=o;else if(1===this.numComps&&l>u&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const t=r<=8?new Uint8Array(u):new Uint16Array(u);for(let e=0;e<u;e++)t[e]=e;const a=new Uint8ClampedArray(3*u);if(this.getRgbBuffer(t,0,u,a,0,r,0),d){h=new Uint8Array(3*l);let e=0;for(let t=0;t<l;++t){const s=3*o[t];h[e++]=a[s],h[e++]=a[s+1],h[e++]=a[s+2]}}else{let t=0;for(let s=0;s<l;++s){const i=3*o[s];e[t++]=a[i],e[t++]=a[i+1],e[t++]=a[i+2],t+=c}}}else d?(h=new Uint8ClampedArray(3*l),this.getRgbBuffer(o,0,l,h,0,r,0)):this.getRgbBuffer(o,0,s*n,e,0,r,c);if(h)if(d)!function(e,t,a,s,i,n,r){r=1!==r?0:r;const o=a/i,c=s/n;let l,h=0;const u=new Uint16Array(i),d=3*a;for(let e=0;e<i;e++)u[e]=3*Math.floor(e*o);for(let a=0;a<n;a++){const s=Math.floor(a*c)*d;for(let a=0;a<i;a++)l=s+u[a],t[h++]=e[l++],t[h++]=e[l++],t[h++]=e[l++],h+=r}}(h,e,t,a,s,i,c);else{let t=0,a=0;for(let i=0,r=s*n;i<r;i++)e[t++]=h[a++],e[t++]=h[a++],e[t++]=h[a++],t+=c}}get usesZeroToOneRange(){return F(this,"usesZeroToOneRange",!0)}static isDefaultDecode(e,t){if(!Array.isArray(e))return!0;if(2*t!==e.length)return A("The decode map is not the correct length"),!0;for(let t=0,a=e.length;t<a;t+=2)if(0!==e[t]||1!==e[t+1])return!1;return!0}}class wt extends bt{constructor(e,t,a){super("Alternate",e),this.base=t,this.tintFn=a,this.tmpBuf=new Float32Array(t.numComps)}getRgbItem(e,t,a,s){const i=this.tmpBuf;this.tintFn(e,t,i,0),this.base.getRgbItem(i,0,a,s)}getRgbBuffer(e,t,a,s,i,n,r){const o=this.tintFn,c=this.base,l=1/((1<<n)-1),h=c.numComps,u=c.usesZeroToOneRange,d=(c.isPassthrough(8)||!u)&&0===r;let f=d?i:0;const g=d?s:new Uint8ClampedArray(h*a),p=this.numComps,m=new Float32Array(p),b=new Float32Array(h);let w,y;for(w=0;w<a;w++){for(y=0;y<p;y++)m[y]=e[t++]*l;if(o(m,0,b,0),u)for(y=0;y<h;y++)g[f++]=255*b[y];else c.getRgbItem(b,0,g,f),f+=h}d||c.getRgbBuffer(g,0,a,s,i,8,r)}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps/this.numComps,t)}}class yt extends bt{constructor(e){super("Pattern",null),this.base=e}isDefaultDecode(e,t){S("Should not call PatternCS.isDefaultDecode")}}class kt extends bt{constructor(e,t,a){super("Indexed",1),this.base=e,this.highVal=t;const s=e.numComps*(t+1);if(this.lookup=new Uint8Array(s),a instanceof pe){const e=a.getBytes(s);this.lookup.set(e)}else{if("string"!=typeof a)throw new N(`IndexedCS - unrecognized lookup table: ${a}`);for(let e=0;e<s;++e)this.lookup[e]=255&a.charCodeAt(e)}}getRgbItem(e,t,a,s){const{base:i,highVal:n,lookup:r}=this,o=J(Math.round(e[t]),0,n)*i.numComps;i.getRgbBuffer(r,o,1,a,s,8,0)}getRgbBuffer(e,t,a,s,i,n,r){const{base:o,highVal:c,lookup:l}=this,{numComps:h}=o,u=o.getOutputLength(h,r);for(let n=0;n<a;++n){const a=J(Math.round(e[t++]),0,c)*h;o.getRgbBuffer(l,a,1,s,i,8,r),i+=u}}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps,t)}isDefaultDecode(e,t){return!Array.isArray(e)||(2!==e.length?(A("Decode map length is not correct"),!0):!Number.isInteger(t)||t<1?(A("Bits per component is not correct"),!0):0===e[0]&&e[1]===(1<<t)-1)}}class xt extends bt{constructor(){super("DeviceGray",1)}getRgbItem(e,t,a,s){const i=255*e[t];a[s]=a[s+1]=a[s+2]=i}getRgbBuffer(e,t,a,s,i,n,r){const o=255/((1<<n)-1);let c=t,l=i;for(let t=0;t<a;++t){const t=o*e[c++];s[l++]=t,s[l++]=t,s[l++]=t,l+=r}}getOutputLength(e,t){return e*(3+t)}}class vt extends bt{constructor(){super("DeviceRGB",3)}getRgbItem(e,t,a,s){a[s]=255*e[t],a[s+1]=255*e[t+1],a[s+2]=255*e[t+2]}getRgbBuffer(e,t,a,s,i,n,r){if(8===n&&0===r)return void s.set(e.subarray(t,t+3*a),i);const o=255/((1<<n)-1);let c=t,l=i;for(let t=0;t<a;++t)s[l++]=o*e[c++],s[l++]=o*e[c++],s[l++]=o*e[c++],l+=r}getOutputLength(e,t){return e*(3+t)/3|0}isPassthrough(e){return 8===e}}class Ct extends bt{constructor(){super("DeviceRGBA",4)}getOutputLength(e,t){return 4*e}isPassthrough(e){return 8===e}fillRgb(e,t,a,s,i,n,r,o,c){a!==i||t!==s?function(e,t,a,s,i,n,r){const o=a/i,c=s/n;let l=0;const h=new Uint16Array(i);if(1===r){for(let e=0;e<i;e++)h[e]=Math.floor(e*o);const s=new Uint32Array(e.buffer),r=new Uint32Array(t.buffer),u=q.isLittleEndian?16777215:4294967040;for(let e=0;e<n;e++){const t=s.subarray(Math.floor(e*c)*a);for(let e=0;e<i;e++)r[l++]|=t[h[e]]&u}}else{const s=4,r=a*s;for(let e=0;e<i;e++)h[e]=Math.floor(e*o)*s;for(let a=0;a<n;a++){const s=e.subarray(Math.floor(a*c)*r);for(let e=0;e<i;e++){const a=h[e];t[l++]=s[a],t[l++]=s[a+1],t[l++]=s[a+2]}}}}(o,e,t,a,s,i,c):function(e,t,a){if(1===a){const a=new Uint32Array(e.buffer),s=new Uint32Array(t.buffer),i=q.isLittleEndian?16777215:4294967040;for(let e=0,t=a.length;e<t;e++)s[e]|=a[e]&i}else{let a=0;for(let s=0,i=e.length;s<i;s+=4)t[a++]=e[s],t[a++]=e[s+1],t[a++]=e[s+2]}}(o,e,c)}}class At extends bt{constructor(){super("DeviceCMYK",4)}#a(e,t,a,s,i){const n=e[t]*a,r=e[t+1]*a,o=e[t+2]*a,c=e[t+3]*a;s[i]=255+n*(-4.387332384609988*n+54.48615194189176*r+18.82290502165302*o+212.25662451639585*c-285.2331026137004)+r*(1.7149763477362134*r-5.6096736904047315*o+-17.873870861415444*c-5.497006427196366)+o*(-2.5217340131683033*o-21.248923337353073*c+17.5119270841813)+c*(-21.86122147463605*c-189.48180835922747),s[i+1]=255+n*(8.841041422036149*n+60.118027045597366*r+6.871425592049007*o+31.159100130055922*c-79.2970844816548)+r*(-15.310361306967817*r+17.575251261109482*o+131.35250912493976*c-190.9453302588951)+o*(4.444339102852739*o+9.8632861493405*c-24.86741582555878)+c*(-20.737325471181034*c-187.80453709719578),s[i+2]=255+n*(.8842522430003296*n+8.078677503112928*r+30.89978309703729*o-.23883238689178934*c-14.183576799673286)+r*(10.49593273432072*r+63.02378494754052*o+50.606957656360734*c-112.23884253719248)+o*(.03296041114873217*o+115.60384449646641*c-193.58209356861505)+c*(-22.33816807309886*c-180.12613974708367)}getRgbItem(e,t,a,s){this.#a(e,t,1,a,s)}getRgbBuffer(e,t,a,s,i,n,r){const o=1/((1<<n)-1);for(let n=0;n<a;n++)this.#a(e,t,o,s,i),t+=4,i+=3+r}getOutputLength(e,t){return e/4*(3+t)|0}}class St extends bt{constructor(e,t,a){if(super("CalGray",1),!e)throw new N("WhitePoint missing - required for color space CalGray");if([this.XW,this.YW,this.ZW]=e,[this.XB,this.YB,this.ZB]=t||[0,0,0],this.G=a||1,this.XW<0||this.ZW<0||1!==this.YW)throw new N(`Invalid WhitePoint components for ${this.name}, no fallback available`);(this.XB<0||this.YB<0||this.ZB<0)&&(C(`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||A(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ZB: ${this.ZB}, only default values are supported.`),this.G<1&&(C(`Invalid Gamma: ${this.G} for ${this.name}, falling back to default.`),this.G=1)}#a(e,t,a,s,i){const n=(e[t]*i)**this.G,r=this.YW*n,o=Math.max(295.8*r**.3333333333333333-40.8,0);a[s]=o,a[s+1]=o,a[s+2]=o}getRgbItem(e,t,a,s){this.#a(e,t,a,s,1)}getRgbBuffer(e,t,a,s,i,n,r){const o=1/((1<<n)-1);for(let n=0;n<a;++n)this.#a(e,t,s,i,o),t+=1,i+=3+r}getOutputLength(e,t){return e*(3+t)}}class It extends bt{static#s=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#n=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]);static#r=new Float32Array([1,1,1]);static#o=new Float32Array(3);static#c=new Float32Array(3);static#l=new Float32Array(3);static#h=(24/116)**3/8;constructor(e,t,a,s){if(super("CalRGB",3),!e)throw new N("WhitePoint missing - required for color space CalRGB");const[i,n,r]=this.whitePoint=e,[o,c,l]=this.blackPoint=t||new Float32Array(3);if([this.GR,this.GG,this.GB]=a||new Float32Array([1,1,1]),[this.MXA,this.MYA,this.MZA,this.MXB,this.MYB,this.MZB,this.MXC,this.MYC,this.MZC]=s||new Float32Array([1,0,0,0,1,0,0,0,1]),i<0||r<0||1!==n)throw new N(`Invalid WhitePoint components for ${this.name}, no fallback available`);(o<0||c<0||l<0)&&(C(`Invalid BlackPoint for ${this.name} [${o}, ${c}, ${l}], falling back to default.`),this.blackPoint=new Float32Array(3)),(this.GR<0||this.GG<0||this.GB<0)&&(C(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ${this.name}, falling back to default.`),this.GR=this.GG=this.GB=1)}#u(e,t,a){a[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2],a[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2],a[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2]}#d(e,t,a){a[0]=1*t[0]/e[0],a[1]=1*t[1]/e[1],a[2]=1*t[2]/e[2]}#f(e,t,a){a[0]=.95047*t[0]/e[0],a[1]=1*t[1]/e[1],a[2]=1.08883*t[2]/e[2]}#g(e){return e<=.0031308?J(12.92*e,0,1):e>=.99554525?1:J(1.055*e**(1/2.4)-.055,0,1)}#p(e){return e<0?-this.#p(-e):e>8?((e+16)/116)**3:e*It.#h}#m(e,t,a){if(0===e[0]&&0===e[1]&&0===e[2])return a[0]=t[0],a[1]=t[1],void(a[2]=t[2]);const s=this.#p(0),i=(1-s)/(1-this.#p(e[0])),n=1-i,r=(1-s)/(1-this.#p(e[1])),o=1-r,c=(1-s)/(1-this.#p(e[2])),l=1-c;a[0]=t[0]*i+n,a[1]=t[1]*r+o,a[2]=t[2]*c+l}#b(e,t,a){if(1===e[0]&&1===e[2])return a[0]=t[0],a[1]=t[1],void(a[2]=t[2]);const s=a;this.#u(It.#s,t,s);const i=It.#o;this.#d(e,s,i),this.#u(It.#i,i,a)}#w(e,t,a){const s=a;this.#u(It.#s,t,s);const i=It.#o;this.#f(e,s,i),this.#u(It.#i,i,a)}#a(e,t,a,s,i){const n=J(e[t]*i,0,1),r=J(e[t+1]*i,0,1),o=J(e[t+2]*i,0,1),c=1===n?1:n**this.GR,l=1===r?1:r**this.GG,h=1===o?1:o**this.GB,u=this.MXA*c+this.MXB*l+this.MXC*h,d=this.MYA*c+this.MYB*l+this.MYC*h,f=this.MZA*c+this.MZB*l+this.MZC*h,g=It.#c;g[0]=u,g[1]=d,g[2]=f;const p=It.#l;this.#b(this.whitePoint,g,p);const m=It.#c;this.#m(this.blackPoint,p,m);const b=It.#l;this.#w(It.#r,m,b);const w=It.#c;this.#u(It.#n,b,w),a[s]=255*this.#g(w[0]),a[s+1]=255*this.#g(w[1]),a[s+2]=255*this.#g(w[2])}getRgbItem(e,t,a,s){this.#a(e,t,a,s,1)}getRgbBuffer(e,t,a,s,i,n,r){const o=1/((1<<n)-1);for(let n=0;n<a;++n)this.#a(e,t,s,i,o),t+=3,i+=3+r}getOutputLength(e,t){return e*(3+t)/3|0}}class Bt extends bt{constructor(e,t,a){if(super("Lab",3),!e)throw new N("WhitePoint missing - required for color space Lab");if([this.XW,this.YW,this.ZW]=e,[this.amin,this.amax,this.bmin,this.bmax]=a||[-100,100,-100,100],[this.XB,this.YB,this.ZB]=t||[0,0,0],this.XW<0||this.ZW<0||1!==this.YW)throw new N("Invalid WhitePoint components, no fallback available");(this.XB<0||this.YB<0||this.ZB<0)&&(C("Invalid BlackPoint, falling back to default"),this.XB=this.YB=this.ZB=0),(this.amin>this.amax||this.bmin>this.bmax)&&(C("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)}#k(e,t,a,s){return a+e*(s-a)/t}#a(e,t,a,s,i){let n=e[t],r=e[t+1],o=e[t+2];!1!==a&&(n=this.#k(n,a,0,100),r=this.#k(r,a,this.amin,this.amax),o=this.#k(o,a,this.bmin,this.bmax)),r>this.amax?r=this.amax:r<this.amin&&(r=this.amin),o>this.bmax?o=this.bmax:o<this.bmin&&(o=this.bmin);const c=(n+16)/116,l=c+r/500,h=c-o/200,u=this.XW*this.#y(l),d=this.YW*this.#y(c),f=this.ZW*this.#y(h);let g,p,m;this.ZW<1?(g=3.1339*u+-1.617*d+-.4906*f,p=-.9785*u+1.916*d+.0333*f,m=.072*u+-.229*d+1.4057*f):(g=3.2406*u+-1.5372*d+-.4986*f,p=-.9689*u+1.8758*d+.0415*f,m=.0557*u+-.204*d+1.057*f),s[i]=255*Math.sqrt(g),s[i+1]=255*Math.sqrt(p),s[i+2]=255*Math.sqrt(m)}getRgbItem(e,t,a,s){this.#a(e,t,!1,a,s)}getRgbBuffer(e,t,a,s,i,n,r){const o=(1<<n)-1;for(let n=0;n<a;n++)this.#a(e,t,o,s,i),t+=3,i+=3+r}getOutputLength(e,t){return e*(3+t)/3|0}isDefaultDecode(e,t){return!0}get usesZeroToOneRange(){return F(this,"usesZeroToOneRange",!1)}}function Ft(e){const t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),t.response}class Mt extends bt{#x;#v;static#C=!0;static#A=null;static#S=new FinalizationRegistry((e=>{!function(e){rt.qcms_drop_transformer(e)}(e)}));constructor(e,t,a){if(!Mt.isUsable)throw new Error("No ICC color space support");let s;switch(super(t,a),a){case 1:s=dt.Gray8,this.#v=(e,t)=>function(e,t){rt.qcms_convert_one(e,t)}(this.#x,255*e[t]);break;case 3:s=dt.RGB8,this.#v=(e,t)=>function(e,t,a,s){rt.qcms_convert_three(e,t,a,s)}(this.#x,255*e[t],255*e[t+1],255*e[t+2]);break;case 4:s=dt.CMYK,this.#v=(e,t)=>function(e,t,a,s,i){rt.qcms_convert_four(e,t,a,s,i)}(this.#x,255*e[t],255*e[t+1],255*e[t+2],255*e[t+3]);break;default:throw new Error(`Unsupported number of components: ${a}`)}if(this.#x=function(e,t,a){const s=ut(e,rt.__wbindgen_malloc),i=ht;return rt.qcms_transformer_from_memory(s,i,t,a)>>>0}(e,s,ft.Perceptual),!this.#x)throw new Error("Failed to create ICC color space");Mt.#S.register(this,this.#x)}getRgbItem(e,t,a,s){nt._destBuffer=a.subarray(s,s+3),this.#v(e,t),nt._destBuffer=null}getRgbBuffer(e,t,a,s,i,n,r){if(e=e.subarray(t,t+a*this.numComps),8!==n){const t=255/((1<<n)-1);for(let a=0,s=e.length;a<s;a++)e[a]*=t}nt._mustAddAlpha=r&&s.buffer===e.buffer,nt._destBuffer=s.subarray(i,i+a*(3+r)),function(e,t){const a=ut(t,rt.__wbindgen_malloc),s=ht;rt.qcms_convert_array(e,a,s)}(this.#x,e),nt._mustAddAlpha=!1,nt._destBuffer=null}getOutputLength(e,t){return e/this.numComps*(3+t)|0}static setOptions({useWasm:e,useWorkerFetch:t,wasmUrl:a}){t?(this.#C=e,this.#A=a):this.#C=!1}static get isUsable(){let e=!1;if(this.#C)if(this.#A)try{this._module=nt._module=function(e){if(void 0!==rt)return rt;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=gt();return e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e)),pt(new WebAssembly.Instance(e,t),e)}({module:Ft(`${this.#A}qcms_bg.wasm`)}),e=!!this._module}catch(e){A(`ICCBased color space: "${e}".`)}else A("No ICC color space support due to missing `wasmUrl` API option");return F(this,"isUsable",e)}}class Tt extends Mt{static#I;constructor(){super(new Uint8Array(Ft(`${Tt.#I}CGATS001Compat-v2-micro.icc`)),"DeviceCMYK",4)}static setOptions({iccUrl:e}){this.#I=e}static get isUsable(){let e=!1;return Mt.isUsable&&(this.#I?e=!0:A("No CMYK ICC profile support due to missing `iccUrl` API option")),F(this,"isUsable",e)}}class Dt extends pe{constructor(e,t,a,s){super(),this.bytes=e instanceof Uint8Array?e:new Uint8Array(e),this.start=t||0,this.pos=this.start,this.end=t+a||this.bytes.length,this.dict=s}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,a=this.pos,s=this.end;if(!e)return t.subarray(a,s);let i=a+e;return i>s&&(i=s),this.pos=i,t.subarray(a,i)}getByteRange(e,t){return e<0&&(e=0),t>this.end&&(t=this.end),this.bytes.subarray(e,t)}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(e,t,a=null){return new Dt(this.bytes.buffer,e,t,a)}}class Ot extends Dt{constructor(e){super(E(e))}}class Rt extends Dt{constructor(){super(new Uint8Array(0))}}class Nt extends Dt{constructor(e,t,a){super(new Uint8Array(e),0,e,null),this.chunkSize=t,this._loadedChunks=new Set,this.numChunks=Math.ceil(e/t),this.manager=a,this.progressiveDataLength=0,this.lastSuccessfulEnsureByteChunk=-1}getMissingChunks(){const e=[];for(let t=0,a=this.numChunks;t<a;++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 a=this.chunkSize;if(e%a!=0)throw new Error(`Bad begin offset: ${e}`);const s=e+t.byteLength;if(s%a!=0&&s!==this.bytes.length)throw new Error(`Bad end offset: ${s}`);this.bytes.set(new Uint8Array(t),e);const i=Math.floor(e/a),n=Math.floor((s-1)/a)+1;for(let e=i;e<n;++e)this._loadedChunks.add(e)}onReceiveProgressiveData(e){let t=this.progressiveDataLength;const a=Math.floor(t/this.chunkSize);this.bytes.set(new Uint8Array(e),t),t+=e.byteLength,this.progressiveDataLength=t;const s=t>=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(let e=a;e<s;++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 ve(e,e+1);this.lastSuccessfulEnsureByteChunk=t}}ensureRange(e,t){if(e>=t)return;if(t<=this.progressiveDataLength)return;const a=Math.floor(e/this.chunkSize);if(a>this.numChunks)return;const s=Math.min(Math.floor((t-1)/this.chunkSize)+1,this.numChunks);for(let i=a;i<s;++i)if(!this._loadedChunks.has(i))throw new ve(e,t)}nextEmptyChunk(e){const t=this.numChunks;for(let a=0;a<t;++a){const s=(e+a)%t;if(!this._loadedChunks.has(s))return s}return null}hasChunk(e){return this._loadedChunks.has(e)}getByte(){const e=this.pos;return e>=this.end?-1:(e>=this.progressiveDataLength&&this.ensureByte(e),this.bytes[this.pos++])}getBytes(e){const t=this.bytes,a=this.pos,s=this.end;if(!e)return s>this.progressiveDataLength&&this.ensureRange(a,s),t.subarray(a,s);let i=a+e;return i>s&&(i=s),i>this.progressiveDataLength&&this.ensureRange(a,i),this.pos=i,t.subarray(a,i)}getByteRange(e,t){return e<0&&(e=0),t>this.end&&(t=this.end),t>this.progressiveDataLength&&this.ensureRange(e,t),this.bytes.subarray(e,t)}makeSubStream(e,t,a=null){function s(){}t?e+t>this.progressiveDataLength&&this.ensureRange(e,e+t):e>=this.progressiveDataLength&&this.ensureByte(e),s.prototype=Object.create(this),s.prototype.getMissingChunks=function(){const e=this.chunkSize,t=Math.floor(this.start/e),a=Math.floor((this.end-1)/e)+1,s=[];for(let e=t;e<a;++e)this._loadedChunks.has(e)||s.push(e);return s},Object.defineProperty(s.prototype,"isDataLoaded",{get(){return this.numChunksLoaded===this.numChunks||0===this.getMissingChunks().length},configurable:!0});const i=new s;return i.pos=i.start=e,i.end=e+t||this.end,i.dict=a,i}getBaseStreams(){return[this]}}class _t{constructor(e,t){this.length=t.length,this.chunkSize=t.rangeChunkSize,this.stream=new Nt(this.length,this.chunkSize,this),this.pdfNetworkStream=e,this.disableAutoFetch=t.disableAutoFetch,this.msgHandler=t.msgHandler,this.currRequestId=0,this._chunksNeededByRequest=new Map,this._requestsByChunk=new Map,this._promisesByRequest=new Map,this.progressiveDataLength=0,this.aborted=!1,this._loadedStreamCapability=Promise.withResolvers()}sendRequest(e,t){const a=this.pdfNetworkStream.getRangeReader(e,t);a.isStreamingSupported||(a.onProgress=this.onProgress.bind(this));let s=[],i=0;return new Promise(((e,t)=>{const n=({value:r,done:o})=>{try{if(o){const t=Ie(s);return s=null,void e(t)}i+=r.byteLength,a.isStreamingSupported&&this.onProgress({loaded:i}),s.push(r),a.read().then(n,t)}catch(e){t(e)}};a.read().then(n,t)})).then((t=>{this.aborted||this.onReceiveData({chunk:t,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++,a=new Set;this._chunksNeededByRequest.set(t,a);for(const t of e)this.stream.hasChunk(t)||a.add(t);if(0===a.size)return Promise.resolve();const s=Promise.withResolvers();this._promisesByRequest.set(t,s);const i=[];for(const e of a){let a=this._requestsByChunk.get(e);a||(a=[],this._requestsByChunk.set(e,a),i.push(e)),a.push(t)}if(i.length>0){const e=this.groupChunks(i);for(const t of e){const e=t.beginChunk*this.chunkSize,a=Math.min(t.endChunk*this.chunkSize,this.length);this.sendRequest(e,a).catch(s.reject)}}return s.promise.catch((e=>{if(!this.aborted)throw e}))}getStream(){return this.stream}requestRange(e,t){t=Math.min(t,this.length);const a=this.getBeginChunk(e),s=this.getEndChunk(t),i=[];for(let e=a;e<s;++e)i.push(e);return this._requestChunks(i)}requestRanges(e=[]){const t=[];for(const a of e){const e=this.getBeginChunk(a.begin),s=this.getEndChunk(a.end);for(let a=e;a<s;++a)t.includes(a)||t.push(a)}return t.sort(((e,t)=>e-t)),this._requestChunks(t)}groupChunks(e){const t=[];let a=-1,s=-1;for(let i=0,n=e.length;i<n;++i){const n=e[i];a<0&&(a=n),s>=0&&s+1!==n&&(t.push({beginChunk:a,endChunk:s+1}),a=n),i+1===e.length&&t.push({beginChunk:a,endChunk:n+1}),s=n}return t}onProgress(e){this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize+e.loaded,total:this.length})}onReceiveData(e){const t=e.chunk,a=void 0===e.begin,s=a?this.progressiveDataLength:e.begin,i=s+t.byteLength,n=Math.floor(s/this.chunkSize),r=i<this.length?Math.floor(i/this.chunkSize):Math.ceil(i/this.chunkSize);a?(this.stream.onReceiveProgressiveData(t),this.progressiveDataLength=i):this.stream.onReceiveData(s,t),this.stream.isDataLoaded&&this._loadedStreamCapability.resolve(this.stream);const o=[];for(let e=n;e<r;++e){const t=this._requestsByChunk.get(e);if(t){this._requestsByChunk.delete(e);for(const a of t){const t=this._chunksNeededByRequest.get(a);t.has(e)&&t.delete(e),t.size>0||o.push(a)}}}if(!this.disableAutoFetch&&0===this._requestsByChunk.size){let e;if(1===this.stream.numChunksLoaded){const t=this.stream.numChunks-1;this.stream.hasChunk(t)||(e=t)}else e=this.stream.nextEmptyChunk(r);Number.isInteger(e)&&this._requestChunks([e])}for(const e of o){const t=this._promisesByRequest.get(e);this._promisesByRequest.delete(e),t.resolve()}this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize,total:this.length})}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.pdfNetworkStream?.cancelAllRequests(e);for(const t of this._promisesByRequest.values())t.reject(e)}}function Pt(e){switch(e.kind){case 1:return Et(e);case 2:return function({src:e,srcPos:t=0,dest:a,destPos:s=0,width:i,height:n}){let r=0;const o=i*n*3,c=o>>2,l=new Uint32Array(e.buffer,t,c);if(q.isLittleEndian){for(;r<c-2;r+=3,s+=4){const e=l[r],t=l[r+1],i=l[r+2];a[s]=4278190080|e,a[s+1]=e>>>24|t<<8|4278190080,a[s+2]=t>>>16|i<<16|4278190080,a[s+3]=i>>>8|4278190080}for(let i=4*r,n=t+o;i<n;i+=3)a[s++]=e[i]|e[i+1]<<8|e[i+2]<<16|4278190080}else{for(;r<c-2;r+=3,s+=4){const e=l[r],t=l[r+1],i=l[r+2];a[s]=255|e,a[s+1]=e<<24|t>>>8|255,a[s+2]=t<<16|i>>>16|255,a[s+3]=i<<8|255}for(let i=4*r,n=t+o;i<n;i+=3)a[s++]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|255}return{srcPos:t+o,destPos:s}}(e)}return null}function Et({src:e,srcPos:t=0,dest:a,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const o=q.isLittleEndian?4278190080:255,[c,l]=r?[n,o]:[o,n],h=s>>3,u=7&s,d=e.length;a=new Uint32Array(a.buffer);let f=0;for(let s=0;s<i;s++){for(const s=t+h;t<s;t++){const s=t<d?e[t]:255;a[f++]=128&s?l:c,a[f++]=64&s?l:c,a[f++]=32&s?l:c,a[f++]=16&s?l:c,a[f++]=8&s?l:c,a[f++]=4&s?l:c,a[f++]=2&s?l:c,a[f++]=1&s?l:c}if(0===u)continue;const s=t<d?e[t++]:255;for(let e=0;e<u;e++)a[f++]=s&1<<7-e?l:c}return{srcPos:t,destPos:f}}class Lt{static#B=2048;static#F=q.isImageDecoderSupported;constructor(e,t){this._imgData=e,this._isMask=t}static get canUseImageDecoder(){return F(this,"canUseImageDecoder",this.#F?ImageDecoder.isTypeSupported("image/bmp"):Promise.resolve(!1))}static needsToBeResized(e,t){if(e<=this.#B&&t<=this.#B)return!1;const{MAX_DIM:a}=this;if(e>a||t>a)return!0;const s=e*t;return this._hasMaxArea?s>this.MAX_AREA:!(s<this.#B**2)&&(this._areGoodDims(e,t)?(this.#B=Math.max(this.#B,Math.floor(Math.sqrt(e*t))),!1):(this.#B=this._guessMax(this.#B,a,128,0),s>(this.MAX_AREA=this.#B**2)))}static get MAX_DIM(){return F(this,"MAX_DIM",this._guessMax(2048,65537,0,1))}static get MAX_AREA(){return this._hasMaxArea=!0,F(this,"MAX_AREA",this._guessMax(this.#B,this.MAX_DIM,128,0)**2)}static set MAX_AREA(e){e>=0&&(this._hasMaxArea=!0,F(this,"MAX_AREA",e))}static setOptions({canvasMaxAreaInBytes:e=-1,isImageDecoderSupported:t=!1}){this._hasMaxArea||(this.MAX_AREA=e>>2),this.#F=t}static _areGoodDims(e,t){try{const a=new OffscreenCanvas(e,t),s=a.getContext("2d");s.fillRect(0,0,1,1);const i=s.getImageData(0,0,1,1).data[3];return a.width=a.height=1,0!==i}catch{return!1}}static _guessMax(e,t,a,s){for(;e+a+1<t;){const a=Math.floor((e+t)/2),i=s||a;this._areGoodDims(a,i)?e=a:t=a}return e}static async createImage(e,t=!1){return new Lt(e,t)._createImage()}async _createImage(){const{_imgData:e}=this,{width:t,height:a}=e;if(t*a*4>be){const e=this.#M();if(e)return e}const s=this._encodeBMP();let i,n;await Lt.canUseImageDecoder?(i=new ImageDecoder({data:s,type:"image/bmp",preferAnimation:!1,transfer:[s.buffer]}),n=i.decode().catch((e=>(A(`BMP image decoding failed: ${e}`),createImageBitmap(new Blob([this._encodeBMP().buffer],{type:"image/bmp"}))))).finally((()=>{i.close()}))):n=createImageBitmap(new Blob([s.buffer],{type:"image/bmp"}));const{MAX_AREA:r,MAX_DIM:o}=Lt,c=Math.max(t/o,a/o,Math.sqrt(t*a/r)),l=Math.max(c,2),h=Math.round(10*(c+1.25))/10/l,u=Math.floor(Math.log2(h)),d=new Array(u+2).fill(2);d[0]=l,d.splice(-1,1,h/(1<<u));let f=t,g=a;const p=await n;let m=p.image||p;for(const e of d){const t=f,a=g;f=Math.floor(f/e)-1,g=Math.floor(g/e)-1;const s=new OffscreenCanvas(f,g);s.getContext("2d").drawImage(m,0,0,t,a,0,0,f,g),m.close(),m=s.transferToImageBitmap()}return e.data=null,e.bitmap=m,e.width=f,e.height=g,e}#M(){const{_imgData:e}=this,{data:t,width:a,height:s,kind:i}=e,n=a*s*4,r=Math.ceil(Math.log2(n/be)),o=a>>r,c=s>>r;let l,h=s;try{l=new Uint8Array(n)}catch{let e=Math.floor(Math.log2(n+1));for(;;)try{l=new Uint8Array(2**e-1);break}catch{e-=1}h=Math.floor((2**e-1)/(4*a));const t=a*h*4;t<l.length&&(l=new Uint8Array(t))}const u=new Uint32Array(l.buffer),d=new Uint32Array(o*c);let f=0,g=0;const p=Math.ceil(s/h),m=s%h==0?s:s%h;for(let e=0;e<p;e++){const s=e<p-1?h:m;({srcPos:f}=Pt({kind:i,src:t,dest:u,width:a,height:s,inverseDecode:this._isMask,srcPos:f}));for(let e=0,t=s>>r;e<t;e++){const t=u.subarray((e<<r)*a);for(let e=0;e<o;e++)d[g++]=t[e<<r]}}if(Lt.needsToBeResized(o,c))return e.data=d,e.width=o,e.height=c,e.kind=3,null;const b=new OffscreenCanvas(o,c);return b.getContext("2d",{willReadFrequently:!0}).putImageData(new ImageData(new Uint8ClampedArray(d.buffer),o,c),0,0),e.data=null,e.bitmap=b.transferToImageBitmap(),e.width=o,e.height=c,e}_encodeBMP(){const{width:e,height:t,kind:a}=this._imgData;let s,i=this._imgData.data,n=new Uint8Array(0),r=n,o=0;switch(a){case 1:{s=1,n=new Uint8Array(this._isMask?[255,255,255,255,0,0,0,0]:[0,0,0,0,255,255,255,255]);const a=e+7>>3,r=a+3&-4;if(a!==r){const e=new Uint8Array(r*t);let s=0;for(let n=0,o=t*a;n<o;n+=a,s+=r)e.set(i.subarray(n,n+a),s);i=e}break}case 2:if(s=24,3&e){const a=3*e,s=a+3&-4,n=s-a,r=new Uint8Array(s*t);let o=0;for(let e=0,s=t*a;e<s;e+=a){const t=i.subarray(e,e+a);for(let e=0;e<a;e+=3)r[o++]=t[e+2],r[o++]=t[e+1],r[o++]=t[e];o+=n}i=r}else for(let e=0,t=i.length;e<t;e+=3){const t=i[e];i[e]=i[e+2],i[e+2]=t}break;case 3:s=32,o=3,r=new Uint8Array(68);const a=new DataView(r.buffer);q.isLittleEndian?(a.setUint32(0,255,!0),a.setUint32(4,65280,!0),a.setUint32(8,16711680,!0),a.setUint32(12,4278190080,!0)):(a.setUint32(0,4278190080,!0),a.setUint32(4,16711680,!0),a.setUint32(8,65280,!0),a.setUint32(12,255,!0));break;default:throw new Error("invalid format")}let c=0;const l=40+r.length,h=14+l+n.length+i.length,u=new Uint8Array(h),d=new DataView(u.buffer);return d.setUint16(c,19778,!0),c+=2,d.setUint32(c,h,!0),c+=4,d.setUint32(c,0,!0),c+=4,d.setUint32(c,14+l+n.length,!0),c+=4,d.setUint32(c,l,!0),c+=4,d.setInt32(c,e,!0),c+=4,d.setInt32(c,-t,!0),c+=4,d.setUint16(c,1,!0),c+=2,d.setU