28 lines
98 KiB
JavaScript
28 lines
98 KiB
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.4.149
|
||
|
|
* pdfjsBuild = 9e2e9e209
|
||
|
|
*/"object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&process.type;const e={ERRORS:0,WARNINGS:1,INFOS:5};let t=e.WARNINGS;function setVerbosityLevel(e){Number.isInteger(e)&&(t=e)}function getVerbosityLevel(){return t}function info(n){t>=e.INFOS&&console.log(`Info: ${n}`)}function util_warn(n){t>=e.WARNINGS&&console.log(`Warning: ${n}`)}function unreachable(e){throw new Error(e)}function shadow(e,t,n,r=!1){Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1});return n}const n=function BaseExceptionClosure(){function BaseException(e,t){this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class FormatError extends n{constructor(e){super(e,"FormatError")}}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 r=[];for(let i=0;i<t;i+=n){const s=Math.min(i+n,t),o=e.subarray(i,s);r.push(String.fromCharCode.apply(null,o))}return r.join("")}class util_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 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 r=Array.from(Array(256).keys(),(e=>e.toString(16).padStart(2,"0")));class util_Util{static makeHexColor(e,t,n){return`#${r[e]}${r[t]}${r[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 r=e[n],i=e[n+1];e[n]=r*t[0]+i*t[2]+t[4];e[n+1]=r*t[1]+i*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){const r=t[0],i=t[1],s=t[2],o=t[3],a=t[4],c=t[5];for(let t=0;t<6;t+=2){const l=e[n+t],h=e[n+t+1];e[n+t]=l*r+h*s+a;e[n+t+1]=l*i+h*o+c}}static applyInverseTransform(e,t){const n=e[0],r=e[1],i=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-r*t[2]+t[2]*t[5]-t[4]*t[3])/i;e[1]=(-n*t[1]+r*t[0]+t[4]*t[1]-t[5]*t[0])/i}static axialAlignedBoundingBox(e,t,n){const r=t[0],i=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=e[0],h=e[1],f=e[2],u=e[3];let d=r*l+a,m=d,g=r*f+a,p=g,b=o*h+c,w=b,y=o*u+c,C=y;if(0!==i||0!==s){const e=i*l,t=i*f,n=s*h,r=s*u;d+=n;p+=n;g+=r;m+=r;b+=e;C+=e;y+=t;w+=t}n[0]=Math.min(n[0],d,g,m,p);n[1]=Math.min(n[1],b,y,w,C);n[2]=Math.max(n[2],d,g,m,p);n[3]=Math.max(n[3],b,y,w,C)}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],r=e[1],i=e[2],s=e[3],o=n**2+r**2,a=n*i+r*s,c=i**2+s**2,l=(o+c)/2,h=Math.sqrt(l**2-(o*c-a**2));t[0]=Math.sq
|
||
|
|
/*webpackIgnore: true*/
|
||
|
|
/*@vite-ignore*/
|
||
|
|
t)).default()}catch(e){util_warn(`JpxImage#getJsModule: ${e}`)}e(n)}static async#L(e,t,n){const r="openjpeg.wasm";try{this.#M||(this.#E?this.#M=await async function fetchBinaryData(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())}(`${this.#A}${r}`):this.#M=await this.#T.sendWithPromise("FetchBinaryData",{type:"wasmFactory",filename:r}));return n((await WebAssembly.instantiate(this.#M,t)).instance)}catch(t){util_warn(`JpxImage#instantiateWasm: ${t}`);this.#U(e);return null}finally{this.#T=null}}static async decode(e,{numComponents:t=4,isIndexedColormap:n=!1,smaskInData:r=!1,reducePower:i=0}={}){if(!this.#P){const{promise:e,resolve:t}=Promise.withResolvers(),n=[e];this.#S?n.push(F({warn:util_warn,instantiateWasm:this.#L.bind(this,t)})):this.#U(t);this.#P=Promise.race(n)}const s=await this.#P;if(!s)throw new JpxError("OpenJPEG failed to initialize");let o;try{const a=e.length;o=s._malloc(a);s.writeArrayToMemory(e,o);if(s._jp2_decode(o,a,t>0?t:0,!!n,!!r,i)){const{errorMessages:e}=s;if(e){delete s.errorMessages;throw new JpxError(e)}throw new JpxError("Unknown error")}const{imageData:c}=s;s.imageData=null;return c}finally{o&&s._free(o)}}static cleanup(){this.#P=null}static parseImageProperties(e){if(!(e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw new JpxError("Invalid data format, must be a TypedArray.");let t=(e=new Stream(e)).getByte();for(;t>=0;){const n=t;t=e.getByte();if(65361===(n<<8|t)){e.skip(4);const t=e.getInt32()>>>0,n=e.getInt32()>>>0,r=e.getInt32()>>>0,i=e.getInt32()>>>0;e.skip(16);return{width:t-r,height:n-i,bitsPerComponent:8,componentsCount:e.getUint16()}}}throw new JpxError("No size marker found in JPX stream")}}globalThis.pdfjsImageDecoders={getVerbosityLevel,Jbig2Error,Jbig2Image,JpegError,JpegImage,JpxError,JpxImage,setVerbosityLevel,VerbosityLevel:e};export{Jbig2Error,Jbig2Image,JpegError,JpegImage,JpxError,JpxImage,e as VerbosityLevel,getVerbosityLevel,setVerbosityLevel};
|