@tuttarealstep/vue-pdf.js
Version:
A Vue component for displaying PDF files using the standard `pdf.js` viewer. This package provides a simple and powerful integration to embed PDF viewers in Vue applications.
1,607 lines • 2.18 MB
JavaScript
var iE = Object.defineProperty;
var Rl = (e) => {
throw TypeError(e);
};
var gE = (e, A, t) => A in e ? iE(e, A, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[A] = t;
var iA = (e, A, t) => gE(e, typeof A != "symbol" ? A + "" : A, t), tr = (e, A, t) => A.has(e) || Rl("Cannot " + t);
var x = (e, A, t) => (tr(e, A, "read from private field"), t ? t.call(e) : A.get(e)), CA = (e, A, t) => A.has(e) ? Rl("Cannot add the same private member more than once") : A instanceof WeakSet ? A.add(e) : A.set(e, t), NA = (e, A, t, i) => (tr(e, A, "write to private field"), i ? i.call(e, t) : A.set(e, t), t), J = (e, A, t) => (tr(e, A, "access private method"), t);
var Se = (e, A, t, i) => ({
set _(g) {
NA(e, A, g, t);
},
get _() {
return x(e, A, i);
}
});
import { u as _A, s as DA, a as PA, b as Ot, B as cg, A as nc, m as MI, o as Kf, U as Ee, w as S, c as le, i as ue, F as Z, M as Pe, d as ei, e as ft, f as ac, I as xt, g as sE, R as Mt, O as D, h as Po, D as Me, j as yi, k as Ss, P as ug, l as Jt, S as ql, C as jl, n as ps, p as Nl, q as Ht, T as oc, r as nE, t as Ua, v as aE, L as Lg, x as Rr, y as oE, z as IE, E as La, G as Gl, H as Oo, J as rE, _ as fE, K as lE, N as CE, Q as qr, V as Ic, W as Mi, X as gt, Y as Jg, Z as jr, $ as Si, a0 as Ys, a1 as cE, a2 as BE, a3 as rc, a4 as Hl, a5 as Wo, a6 as Ml, a7 as Nr, a8 as QE, a9 as EE, aa as hE, ab as uE, ac as dE, ad as wE, ae as Ul, af as mE, ag as Ll, ah as pE } from "./index-j_YHfX80.js";
const V = { test: (e) => /GENERIC/.test(e), eval: (e) => e === "BUNDLE_VERSION" ? "5.7.284" : null }, bE = Symbol("CIRCULAR_REF"), Et = Symbol("EOF");
let ko = /* @__PURE__ */ Object.create(null), Fo = /* @__PURE__ */ Object.create(null), Zs = /* @__PURE__ */ Object.create(null);
function xE() {
ko = /* @__PURE__ */ Object.create(null), Fo = /* @__PURE__ */ Object.create(null), Zs = /* @__PURE__ */ Object.create(null);
}
class gA {
constructor(A) {
(typeof V > "u" || V.test("TESTING")) && typeof A != "string" && _A('Name: The "name" must be a string.'), this.name = A;
}
static get(A) {
return Fo[A] || (Fo[A] = new gA(A));
}
}
class it {
constructor(A) {
(typeof V > "u" || V.test("TESTING")) && typeof A != "string" && _A('Cmd: The "cmd" must be a string.'), this.cmd = A;
}
static get(A) {
return ko[A] || (ko[A] = new it(A));
}
}
const fc = function() {
return fc;
};
var bt, un, So;
const Ei = class Ei {
constructor(A = null) {
CA(this, un);
iA(this, "__nonSerializable__", fc);
// Disable cloning of the Dict.
CA(this, bt, /* @__PURE__ */ new Map());
iA(this, "objId", null);
iA(this, "suppressEncryption", !1);
iA(this, "xref");
this.xref = A;
}
assignXref(A) {
this.xref = A;
}
get size() {
return x(this, bt).size;
}
// Automatically dereferences Ref objects.
get(A, t, i) {
return J(this, un, So).call(
this,
/* isAsync = */
!1,
A,
t,
i
);
}
// Same as get(), but returns a promise and uses fetchIfRefAsync().
async getAsync(A, t, i) {
return J(this, un, So).call(
this,
/* isAsync = */
!0,
A,
t,
i
);
}
// Same as get(), but dereferences all elements if the result is an Array.
getArray(A, t, i) {
let g = J(this, un, So).call(
this,
/* isAsync = */
!1,
A,
t,
i
);
if (Array.isArray(g)) {
g = g.slice();
for (let s = 0, n = g.length; s < n; s++)
g[s] instanceof sA && this.xref && (g[s] = this.xref.fetch(g[s], this.suppressEncryption));
}
return g;
}
// No dereferencing.
getRaw(A) {
return x(this, bt).get(A);
}
getKeys() {
return x(this, bt).keys();
}
// No dereferencing.
getRawValues() {
return x(this, bt).values();
}
getRawEntries() {
return x(this, bt).entries();
}
set(A, t) {
(typeof V > "u" || V.test("TESTING")) && (typeof A != "string" ? _A('Dict.set: The "key" must be a string.') : t === void 0 && _A('Dict.set: The "value" cannot be undefined.')), x(this, bt).set(A, t);
}
setIfNotExists(A, t) {
this.has(A) || this.set(A, t);
}
setIfNumber(A, t) {
typeof t == "number" && this.set(A, t);
}
setIfArray(A, t) {
(Array.isArray(t) || ArrayBuffer.isView(t)) && this.set(A, t);
}
setIfDefined(A, t) {
t != null && this.set(A, t);
}
setIfName(A, t) {
typeof t == "string" ? this.set(A, gA.get(t)) : t instanceof gA && this.set(A, t);
}
setIfDict(A, t) {
t instanceof Ei && this.set(A, t);
}
has(A) {
return x(this, bt).has(A);
}
*[Symbol.iterator]() {
for (const [A, t] of x(this, bt))
yield [
A,
t instanceof sA && this.xref ? this.xref.fetch(t, this.suppressEncryption) : t
];
}
static get empty() {
const A = new Ei(null);
return A.set = (t, i) => {
_A("Should not call `set` on the empty dictionary.");
}, DA(this, "empty", A);
}
static merge({ xref: A, dictArray: t, mergeSubDicts: i = !1 }) {
const g = new Ei(A), s = /* @__PURE__ */ new Map();
for (const n of t)
if (n instanceof Ei)
for (const [a, o] of n.getRawEntries()) {
let I = s.get(a);
if (I === void 0)
I = [], s.set(a, I);
else if (!i || !(o instanceof Ei))
continue;
I.push(o);
}
for (const [n, a] of s) {
if (a.length === 1 || !(a[0] instanceof Ei)) {
g.set(n, a[0]);
continue;
}
const o = new Ei(A);
for (const I of a)
for (const [r, f] of I.getRawEntries())
o.setIfNotExists(r, f);
o.size > 0 && g.set(n, o);
}
return s.clear(), g.size > 0 ? g : Ei.empty;
}
clone() {
const A = new Ei(this.xref);
for (const [t, i] of x(this, bt))
A.set(t, i);
return A;
}
delete(A) {
x(this, bt).delete(A);
}
};
bt = new WeakMap(), un = new WeakSet(), So = function(A, t, i, g) {
let s = x(this, bt).get(t);
return s === void 0 && i !== void 0 && ((typeof V > "u" || V.test("TESTING")) && i.length < t.length && _A("Dict.#getValue: Expected keys to be ordered by length."), s = x(this, bt).get(i), s === void 0 && g !== void 0 && ((typeof V > "u" || V.test("TESTING")) && g.length < i.length && _A("Dict.#getValue: Expected keys to be ordered by length."), s = x(this, bt).get(g))), s instanceof sA && this.xref ? A ? this.xref.fetchAsync(s, this.suppressEncryption) : this.xref.fetch(s, this.suppressEncryption) : s;
};
let H = Ei;
class sA {
constructor(A, t) {
this.num = A, this.gen = t;
}
toString() {
return this.gen === 0 ? `${this.num}R` : `${this.num}R${this.gen}`;
}
static fromString(A) {
const t = Zs[A];
if (t)
return t;
const i = /^(\d+)R(\d*)$/.exec(A);
return !i || i[1] === "0" ? null : Zs[A] = new sA(
parseInt(i[1], 10),
i[2] ? parseInt(i[2], 10) : 0
);
}
static get(A, t) {
const i = t === 0 ? `${A}R` : `${A}R${t}`;
return Zs[i] || (Zs[i] = new sA(A, t));
}
}
class Le {
constructor(A = null) {
(typeof V > "u" || V.test("TESTING")) && A && !(A instanceof Le) && _A('RefSet: Invalid "parent" value.'), this._set = new Set(A == null ? void 0 : A._set);
}
has(A) {
return (typeof V > "u" || V.test("TESTING")) && !(A instanceof sA) && typeof A != "string" && _A('RefSet: Invalid "ref" value in has.'), this._set.has(A.toString());
}
put(A) {
(typeof V > "u" || V.test("TESTING")) && !(A instanceof sA) && typeof A != "string" && _A('RefSet: Invalid "ref" value in put.'), this._set.add(A.toString());
}
remove(A) {
this._set.delete(A.toString());
}
[Symbol.iterator]() {
return this._set.values();
}
clear() {
this._set.clear();
}
}
class nt {
constructor() {
iA(this, "_map", /* @__PURE__ */ new Map());
}
get size() {
return this._map.size;
}
get(A) {
return this._map.get(A.toString());
}
has(A) {
return this._map.has(A.toString());
}
put(A, t) {
this._map.set(A.toString(), t);
}
putAlias(A, t) {
this._map.set(A.toString(), this.get(t));
}
[Symbol.iterator]() {
return this._map.values();
}
clear() {
this._map.clear();
}
*values() {
yield* this._map.values();
}
*items() {
for (const [A, t] of this._map)
yield [sA.fromString(A), t];
}
*keys() {
for (const A of this._map.keys())
yield sA.fromString(A);
}
}
function Be(e, A) {
return e instanceof gA && (A === void 0 || e.name === A);
}
function lt(e, A) {
return e instanceof it && (A === void 0 || e.cmd === A);
}
function lc(e, A) {
return e instanceof H && (A === void 0 || Be(e.get("Type"), A));
}
function zo(e, A) {
return (typeof V > "u" || V.test("TESTING")) && PA(
e instanceof sA && A instanceof sA,
"isRefsEqual: Both parameters should be `Ref`s."
), e.num === A.num && e.gen === A.gen;
}
class Ae {
constructor() {
(typeof V > "u" || V.test("TESTING")) && this.constructor === Ae && _A("Cannot initialize BaseStream.");
}
// eslint-disable-next-line getter-return
get length() {
_A("Abstract getter `length` accessed");
}
// eslint-disable-next-line getter-return
get isEmpty() {
_A("Abstract getter `isEmpty` accessed");
}
get isDataLoaded() {
return DA(this, "isDataLoaded", !0);
}
getByte() {
_A("Abstract method `getByte` called");
}
getBytes(A) {
_A("Abstract method `getBytes` called");
}
/**
* NOTE: This method can only be used to get image-data that is guaranteed
* to be fully loaded, since otherwise intermittent errors may occur;
* note the `ObjectLoader` class.
*/
async getImageData(A, t) {
return this.getBytes(A, t);
}
async asyncGetBytes() {
_A("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 A = this.getByte();
return A !== -1 && this.pos--, A;
}
peekBytes(A) {
const t = this.getBytes(A);
return this.pos -= t.length, t;
}
getUint16() {
const A = this.getByte(), t = this.getByte();
return A === -1 || t === -1 ? -1 : (A << 8) + t;
}
getInt32() {
const A = this.getByte(), t = this.getByte(), i = this.getByte(), g = this.getByte();
return (A << 24) + (t << 16) + (i << 8) + g;
}
getByteRange(A, t) {
_A("Abstract method `getByteRange` called");
}
getString(A) {
return Ot(this.getBytes(A));
}
skip(A) {
this.pos += A || 1;
}
reset() {
_A("Abstract method `reset` called");
}
moveStart() {
_A("Abstract method `moveStart` called");
}
makeSubStream(A, t, i = null) {
_A("Abstract method `makeSubStream` called");
}
/**
* @returns {Array | null}
*/
getBaseStreams() {
return null;
}
getOriginalStream() {
var A;
return ((A = this.stream) == null ? void 0 : A.getOriginalStream()) || this;
}
}
const Cc = /^[1-9]\.\d$/, vl = 2 ** 31 - 1, li = [1, 0, 0, 1, 0, 0], Gr = [
"ColorSpace",
"ExtGState",
"Font",
"Pattern",
"Properties",
"Shading",
"XObject"
], Hr = [
"ExtGState",
"Font",
"Properties",
"XObject"
];
function Je(e) {
let A;
return function() {
return e && (A = /* @__PURE__ */ Object.create(null), e(A), e = null), A;
};
}
class Ue extends cg {
constructor(A, t) {
super(`Missing data [${A}, ${t})`, "MissingDataException"), this.begin = A, this.end = t;
}
}
class Mr extends cg {
constructor(A) {
super(A, "ParserEOFException");
}
}
class Hg extends cg {
constructor(A) {
super(A, "XRefEntryException");
}
}
class bs extends cg {
constructor(A) {
super(A, "XRefParseException");
}
}
function cc(e) {
if (typeof V > "u" || V.test("TESTING"))
for (const s of e)
PA(
s instanceof ArrayBuffer,
"arrayBuffersToBytes - expected an ArrayBuffer."
);
const A = e.length;
if (A === 0)
return new Uint8Array(0);
if (A === 1)
return new Uint8Array(e[0]);
let t = 0;
for (let s = 0; s < A; s++)
t += e[s].byteLength;
const i = new Uint8Array(t);
let g = 0;
for (let s = 0; s < A; s++) {
const n = new Uint8Array(e[s]);
i.set(n, g), g += n.byteLength;
}
return i;
}
async function Xo(e) {
const A = await fetch(e);
if (!A.ok)
throw new Error(
`Failed to fetch file "${e}" with "${A.statusText}".`
);
return A.bytes();
}
function $t({
dict: e,
key: A,
getArray: t = !1,
stopWhenFound: i = !0
}) {
let g;
const s = new Le();
for (; e instanceof H && !(e.objId && s.has(e.objId)); ) {
e.objId && s.put(e.objId);
const n = t ? e.getArray(A) : e.get(A);
if (n !== void 0) {
if (i)
return n;
(g || (g = [])).push(n);
}
e = e.get("Parent");
}
return g;
}
function yE(e, A, t) {
const i = new Le(), g = e, s = { dict: null, ref: null };
for (; e instanceof H && !i.has(A) && (i.put(A), !e.has("T")); ) {
if (A = e.getRaw("Parent"), !(A instanceof sA))
return s;
e = t.fetch(A);
}
return e instanceof H && e !== g && (s.dict = e, s.ref = A), s;
}
function Ur(e, A) {
if (e === A)
return !0;
if (e instanceof H && A instanceof H) {
if (e.size !== A.size)
return !1;
for (const [t, i] of e.getRawEntries()) {
const g = A.getRaw(t);
if (g === void 0 || !Ur(i, g))
return !1;
}
return !0;
}
if (Array.isArray(e) && Array.isArray(A)) {
if (e.length !== A.length)
return !1;
for (let t = 0, i = e.length; t < i; t++)
if (!Ur(e[t], A[t]))
return !1;
return !0;
}
return !1;
}
const ir = [
"",
"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 DE(e, A = !1) {
PA(
Number.isInteger(e) && e > 0,
"The number should be a positive integer."
);
const t = "M".repeat(e / 1e3 | 0) + ir[e % 1e3 / 100 | 0] + ir[10 + (e % 100 / 10 | 0)] + ir[20 + e % 10];
return A ? t.toLowerCase() : t;
}
function Ci(e) {
return e === 32 || e === 9 || e === 13 || e === 10;
}
function kE(e, A) {
return Array.isArray(e) && e.length === A && e.every((t) => typeof t == "boolean");
}
function kt(e, A) {
return Array.isArray(e) ? (A === null || e.length === A) && e.every((t) => typeof t == "number") : ArrayBuffer.isView(e) && !(e instanceof BigInt64Array || e instanceof BigUint64Array) && (A === null || e.length === A);
}
function ag(e, A) {
return kt(e, 6) ? e : A;
}
function va(e, A) {
return kt(e, 4) ? e : A;
}
function Zi(e, A) {
return kt(e, 4) ? Ee.normalizeRect(e) : A;
}
function Bc(e) {
const A = /(.+)\[(\d+)\]$/;
return e.split(".").map((t) => {
const i = t.match(A);
return i ? { name: i[1], pos: parseInt(i[2], 10) } : { name: t, pos: 0 };
});
}
function Tf(e) {
const A = [];
let t = 0;
for (let i = 0, g = e.length; i < g; i++) {
const s = e.charCodeAt(i);
(s < 33 || s > 126 || s === 35 || s === 40 || s === 41 || s === 60 || s === 62 || s === 91 || s === 93 || s === 123 || s === 125 || s === 47 || s === 37) && (t < i && A.push(e.substring(t, i)), A.push(`#${s.toString(16)}`), t = i + 1);
}
return A.length === 0 ? e : (t < e.length && A.push(e.substring(t, e.length)), A.join(""));
}
function Mn(e) {
return e.replaceAll(/([()\\\n\r])/g, (A) => A === `
` ? "\\n" : A === "\r" ? "\\r" : `\\${A}`);
}
function Vo(e, A, t, i) {
if (!e)
return;
let g = null;
if (e instanceof sA) {
if (i.has(e))
return;
g = e, i.put(g), e = A.fetch(e);
}
if (Array.isArray(e))
for (const s of e)
Vo(s, A, t, i);
else if (e instanceof H) {
if (Be(e.get("S"), "JavaScript")) {
const s = e.get("JS");
let n;
s instanceof Ae ? n = s.getString() : typeof s == "string" && (n = s), n && (n = le(
n,
/* keepEscapeSequence = */
!0
).replaceAll("\0", "")), n && t.push(n.trim());
}
Vo(e.getRaw("Next"), A, t, i);
}
g && i.remove(g);
}
function UI(e, A, t) {
const i = /* @__PURE__ */ Object.create(null), g = $t({
dict: A,
key: "AA",
stopWhenFound: !1
});
if (g)
for (let s = g.length - 1; s >= 0; s--) {
const n = g[s];
if (n instanceof H)
for (const [a, o] of n.getRawEntries()) {
const I = t[a];
if (!I)
continue;
const r = new Le(), f = [];
Vo(o, e, f, r), f.length > 0 && (i[I] = f);
}
}
if (A.has("A")) {
const s = A.get("A"), n = new Le(), a = [];
Vo(s, e, a, n), a.length > 0 && (i.Action = a);
}
return Kf(i) > 0 ? i : null;
}
const FE = {
/* < */
60: "<",
/* > */
62: ">",
/* & */
38: "&",
/* " */
34: """,
/* ' */
39: "'"
};
function* SE(e) {
for (let A = 0, t = e.length; A < t; A++) {
const i = e.codePointAt(A);
i > 55295 && (i < 57344 || i > 65533) && A++, yield i;
}
}
function Bn(e) {
const A = [];
let t = 0;
for (let i = 0, g = e.length; i < g; i++) {
const s = e.codePointAt(i);
if (32 <= s && s <= 126) {
const n = FE[s];
n && (t < i && A.push(e.substring(t, i)), A.push(n), t = i + 1);
} else
t < i && A.push(e.substring(t, i)), A.push(`&#x${s.toString(16).toUpperCase()};`), s > 55295 && (s < 57344 || s > 65533) && i++, t = i + 1;
}
return A.length === 0 ? e : (t < e.length && A.push(e.substring(t, e.length)), A.join(""));
}
function Lr(e, A = !1) {
const t = /^("|').*("|')$/.exec(e);
if (t && t[1] === t[2]) {
if (new RegExp(`[^\\\\]${t[1]}`).test(e.slice(1, -1)))
return A && S(`FontFamily contains unescaped ${t[1]}: ${e}.`), !1;
} else
for (const i of e.split(/[ \t]+/))
if (/^(\d|(-(\d|-)))/.test(i) || !/^[\w-\\]+$/.test(i))
return A && S(`FontFamily contains invalid <custom-ident>: ${e}.`), !1;
return !0;
}
function RE(e) {
const A = "14", t = "400", i = /* @__PURE__ */ new Set([
"100",
"200",
"300",
"400",
"500",
"600",
"700",
"800",
"900",
"1000",
"normal",
"bold",
"bolder",
"lighter"
]), { fontFamily: g, fontWeight: s, italicAngle: n } = e;
if (!Lr(g, !0))
return !1;
const a = s ? s.toString() : "";
e.fontWeight = i.has(a) ? a : t;
const o = parseFloat(n);
return e.italicAngle = isNaN(o) || o < -90 || o > 90 ? A : n.toString(), !0;
}
function Qc(e) {
const A = ["app.launchURL", "window.open", "xfa.host.gotoURL"], i = new RegExp(
"^\\s*(" + A.join("|").replaceAll(".", "\\.") + `)\\((?:'|")([^'"]*)(?:'|")(?:,\\s*(\\w+)\\)|\\))`,
"i"
).exec(e);
return i != null && i[2] ? {
url: i[2],
newWindow: i[1] === "app.launchURL" && i[3] === "true"
} : null;
}
function Qe(e) {
if ((typeof V > "u" || V.test("TESTING")) && PA(
typeof e == "number",
`numberToString - the value (${e}) should be a number.`
), Number.isInteger(e))
return e.toString();
const A = Math.round(e * 100);
return A % 100 === 0 ? (A / 100).toString() : A % 10 === 0 ? e.toFixed(1) : e.toFixed(2);
}
function Pf(e) {
if (!e)
return null;
const A = /* @__PURE__ */ new Map();
for (const [t, i] of e)
t.startsWith(nc) && A.getOrInsertComputed(i.pageIndex, MI).push(i);
return A.size > 0 ? A : null;
}
function ht(e) {
return e == null || qE(e) ? e : Ec(
e,
/* bigEndian = */
!0
);
}
function qE(e) {
return typeof e != "string" ? !1 : !e || /^[\x00-\x7F]*$/.test(e);
}
function jE(e) {
const A = [];
for (let t = 0, i = e.length; t < i; t++) {
const g = e.charCodeAt(t);
A.push(Ee.hexNums[g >> 8 & 255], Ee.hexNums[g & 255]);
}
return A.join("");
}
function Ec(e, A = !1) {
const t = [];
A && t.push("þÿ");
for (let i = 0, g = e.length; i < g; i++) {
const s = e.charCodeAt(i);
t.push(
String.fromCharCode(s >> 8 & 255),
String.fromCharCode(s & 255)
);
}
return t.join("");
}
function Zo(e, A, t) {
switch (e) {
case 90:
return [0, 1, -1, 0, A, 0];
case 180:
return [-1, 0, 0, -1, A, t];
case 270:
return [0, -1, 1, 0, 0, t];
default:
throw new Error("Invalid rotation");
}
}
function Jl(e) {
return Math.ceil(Math.ceil(Math.log2(1 + e)) / 8);
}
var i0;
class ve {
static get _memoryArray() {
const A = x(this, i0);
return A != null && A.byteLength ? A : NA(this, i0, new Uint8Array(this._memory.buffer));
}
}
i0 = new WeakMap(), CA(ve, i0, null), iA(ve, "_memory", null), iA(ve, "_mustAddAlpha", !1), iA(ve, "_destBuffer", null), iA(ve, "_destOffset", 0), iA(ve, "_destLength", 0), iA(ve, "_cssColor", ""), iA(ve, "_makeHexColor", null);
function NE(e, A) {
const { _mustAddAlpha: t, _destBuffer: i, _destOffset: g, _destLength: s, _memoryArray: n } = ve;
if (A === s) {
i.set(n.subarray(e, e + A), g);
return;
}
if (t)
for (let a = e, o = e + A, I = g; a < o; a += 3, I += 4)
i[I] = n[a], i[I + 1] = n[a + 1], i[I + 2] = n[a + 2], i[I + 3] = 255;
else
for (let a = e, o = e + A, I = g; a < o; a += 3, I += 4)
i[I] = n[a], i[I + 1] = n[a + 1], i[I + 2] = n[a + 2];
}
function GE(e) {
const { _destBuffer: A, _destOffset: t, _memoryArray: i } = ve;
A[t] = i[e], A[t + 1] = i[e + 1], A[t + 2] = i[e + 2];
}
function HE(e) {
const { _memoryArray: A } = ve;
ve._cssColor = ve._makeHexColor(
A[e],
A[e + 1],
A[e + 2]
);
}
const gr = 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"
}), ME = Object.freeze({
Perceptual: 0,
0: "Perceptual",
RelativeColorimetric: 1,
1: "RelativeColorimetric",
Saturation: 2,
2: "Saturation",
AbsoluteColorimetric: 3,
3: "AbsoluteColorimetric"
});
function UE(e, A) {
const t = uc(A, Ut.__wbindgen_malloc), i = Of;
Ut.qcms_convert_array(e, t, i);
}
function LE(e, A, t, i, g, s) {
Ut.qcms_convert_four(e, A, t, i, g, s);
}
function vE(e, A, t) {
Ut.qcms_convert_one(e, A, t);
}
function JE(e, A, t, i, g) {
Ut.qcms_convert_three(e, A, t, i, g);
}
function YE(e) {
Ut.qcms_drop_transformer(e);
}
function KE(e, A, t) {
const i = uc(e, Ut.__wbindgen_malloc), g = Of;
return Ut.qcms_transformer_from_memory(i, g, A, t) >>> 0;
}
function TE() {
return {
__proto__: null,
"./qcms_bg.js": {
__proto__: null,
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(A, t) {
throw new Error(PE(A, t));
},
__wbg_copy_result_0d15f3bf9d9012ae: function(A, t) {
NE(A >>> 0, t >>> 0);
},
__wbg_copy_rgb_0106d9d9464fce43: function(A) {
GE(A >>> 0);
},
__wbg_make_cssRGB_8e24b34f71f5363e: function(A) {
HE(A >>> 0);
},
__wbindgen_init_externref_table: function() {
const A = Ut.__wbindgen_externrefs, t = A.grow(4);
A.set(0, void 0), A.set(t + 0, void 0), A.set(t + 1, null), A.set(t + 2, !0), A.set(t + 3, !1);
}
}
};
}
function PE(e, A) {
return e = e >>> 0, WE(e, A);
}
let ha = null;
function hc() {
return (ha === null || ha.byteLength === 0) && (ha = new Uint8Array(Ut.memory.buffer)), ha;
}
function uc(e, A) {
const t = A(e.length * 1, 1) >>> 0;
return hc().set(e, t / 1), Of = e.length, t;
}
let Ro = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 });
Ro.decode();
const OE = 2146435072;
let sr = 0;
function WE(e, A) {
return sr += A, sr >= OE && (Ro = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }), Ro.decode(), sr = A), Ro.decode(hc().subarray(e, e + A));
}
let Of = 0, Ut;
function zE(e, A) {
return Ut = e.exports, ha = null, Ut.__wbindgen_start(), Ut;
}
function XE(e) {
if (Ut !== void 0) return Ut;
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? { module: e } = e : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
const A = TE();
e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e));
const t = new WebAssembly.Instance(e, A);
return zE(t);
}
function VE(e, A, t, i, g, s, n) {
n = n !== 1 ? 0 : n;
const o = t / g, I = i / s;
let r = 0, f;
const l = new Uint16Array(g), C = t * 3;
for (let B = 0; B < g; B++)
l[B] = Math.floor(B * o) * 3;
for (let B = 0; B < s; B++) {
const c = Math.floor(B * I) * C;
for (let E = 0; E < g; E++)
f = c + l[E], A[r++] = e[f++], A[r++] = e[f++], A[r++] = e[f++], r += n;
}
}
function ZE(e, A, t, i, g, s, n) {
const a = t / g, o = i / s;
let I = 0;
const r = new Uint16Array(g);
if (n === 1) {
for (let B = 0; B < g; B++)
r[B] = Math.floor(B * a);
const f = new Uint32Array(e.buffer), l = new Uint32Array(A.buffer), C = ei.isLittleEndian ? 16777215 : 4294967040;
for (let B = 0; B < s; B++) {
const c = f.subarray(Math.floor(B * o) * t);
for (let E = 0; E < g; E++)
l[I++] |= c[r[E]] & C;
}
} else {
const l = t * 4;
for (let C = 0; C < g; C++)
r[C] = Math.floor(C * a) * 4;
for (let C = 0; C < s; C++) {
const B = e.subarray(Math.floor(C * o) * l);
for (let c = 0; c < g; c++) {
const E = r[c];
A[I++] = B[E], A[I++] = B[E + 1], A[I++] = B[E + 2];
}
}
}
}
function _E(e, A, t) {
if (t === 1) {
const i = new Uint32Array(e.buffer), g = new Uint32Array(A.buffer), s = ei.isLittleEndian ? 16777215 : 4294967040;
for (let n = 0, a = i.length; n < a; n++)
g[n] |= i[n] & s;
} else {
let i = 0;
for (let g = 0, s = e.length; g < s; g += 4)
A[i++] = e[g], A[i++] = e[g + 1], A[i++] = e[g + 2];
}
}
function dc(e, A) {
if (!Array.isArray(e))
return !0;
const t = e.length;
return t < A ? (S("Decode map length is too short."), !0) : (t > A && (ue("Truncating too long decode map."), e.length = A), !1);
}
var BI;
const In = class In {
constructor(A, t) {
(typeof V > "u" || V.test("TESTING")) && this.constructor === In && _A("Cannot initialize ColorSpace."), this.name = A, this.numComps = t;
}
/**
* Converts the color value to the RGB color. The color components are
* located in the src array starting from the srcOffset. Returns the array
* of the rgb components, each value ranging from [0,255].
*/
getRgb(A, t, i = new Uint8ClampedArray(3)) {
return this.getRgbItem(A, t, i, 0), i;
}
getRgbHex(A, t) {
const i = this.getRgb(A, t, x(In, BI));
return Ee.makeHexColor(i[0], i[1], i[2]);
}
/**
* Converts the color value to the RGB color, similar to the getRgb method.
* The result placed into the dest array starting from the destOffset.
*/
getRgbItem(A, t, i, g) {
_A("Should not call ColorSpace.getRgbItem");
}
/**
* Converts the specified number of the color values to the RGB colors.
* The colors are located in the src array starting from the srcOffset.
* The result is placed into the dest array starting from the destOffset.
* The src array items shall be in [0,2^bits) range, the dest array items
* will be in [0,255] range. alpha01 indicates how many alpha components
* there are in the dest array; it will be either 0 (RGB array) or 1 (RGBA
* array).
*/
getRgbBuffer(A, t, i, g, s, n, a) {
_A("Should not call ColorSpace.getRgbBuffer");
}
/**
* Determines the number of bytes required to store the result of the
* conversion done by the getRgbBuffer method. As in getRgbBuffer,
* |alpha01| is either 0 (RGB output) or 1 (RGBA output).
*/
getOutputLength(A, t) {
_A("Should not call ColorSpace.getOutputLength");
}
/**
* Returns true if source data will be equal the result/output data.
*/
isPassthrough(A) {
return !1;
}
/**
* Refer to the static `ColorSpace.isDefaultDecode` method below.
*/
isDefaultDecode(A, t) {
return In.isDefaultDecode(A, this.numComps);
}
/**
* Fills in the RGB colors in the destination buffer. alpha01 indicates
* how many alpha components there are in the dest array; it will be either
* 0 (RGB array) or 1 (RGBA array).
*/
fillRgb(A, t, i, g, s, n, a, o, I) {
(typeof V > "u" || V.test("TESTING")) && PA(
A instanceof Uint8ClampedArray,
'ColorSpace.fillRgb: Unsupported "dest" type.'
);
const r = t * i;
let f = null;
const l = 1 << a, C = i !== s || t !== g;
if (this.isPassthrough(a))
f = o;
else if (this.numComps === 1 && r > l && this.name !== "DeviceGray" && this.name !== "DeviceRGB") {
const B = a <= 8 ? new Uint8Array(l) : new Uint16Array(l);
for (let E = 0; E < l; E++)
B[E] = E;
const c = new Uint8ClampedArray(l * 3);
if (this.getRgbBuffer(
B,
0,
l,
c,
0,
a,
/* alpha01 = */
0
), C) {
f = new Uint8Array(r * 3);
let E = 0;
for (let h = 0; h < r; ++h) {
const d = o[h] * 3;
f[E++] = c[d], f[E++] = c[d + 1], f[E++] = c[d + 2];
}
} else {
let E = 0;
for (let h = 0; h < r; ++h) {
const d = o[h] * 3;
A[E++] = c[d], A[E++] = c[d + 1], A[E++] = c[d + 2], E += I;
}
}
} else C ? (f = new Uint8ClampedArray(r * 3), this.getRgbBuffer(
o,
0,
r,
f,
0,
a,
/* alpha01 = */
0
)) : this.getRgbBuffer(o, 0, g * n, A, 0, a, I);
if (f)
if (C)
VE(
f,
A,
t,
i,
g,
s,
I
);
else {
let B = 0, c = 0;
for (let E = 0, h = g * n; E < h; E++)
A[B++] = f[c++], A[B++] = f[c++], A[B++] = f[c++], B += I;
}
}
/**
* True if the colorspace has components in the default range of [0, 1].
* This should be true for all colorspaces except for lab color spaces
* which are [0,100], [-128, 127], [-128, 127].
*/
get usesZeroToOneRange() {
return DA(this, "usesZeroToOneRange", !0);
}
/**
* Checks if a decode map matches the default decode map for a color space.
* This handles the general decode maps where there are two values per
* component, e.g. [0, 1, 0, 1, 0, 1] for a RGB color.
* This does not handle Lab, Indexed, or Pattern decode maps since they are
* slightly different.
* @param {Array} decode - Decode map (usually from an image).
* @param {number} numComps - Number of components the color space has.
*/
static isDefaultDecode(A, t) {
if (dc(A, t * 2))
return !0;
for (let i = 0, g = A.length; i < g; i += 2)
if (A[i] !== 0 || A[i + 1] !== 1)
return !1;
return !0;
}
};
BI = new WeakMap(), CA(In, BI, new Uint8ClampedArray(3));
let dt = In;
class $E extends dt {
constructor(A, t, i) {
super("Alternate", A), this.base = t, this.tintFn = i, this.tmpBuf = new Float32Array(t.numComps);
}
getRgbItem(A, t, i, g) {
(typeof V > "u" || V.test("TESTING")) && PA(
i instanceof Uint8ClampedArray,
'AlternateCS.getRgbItem: Unsupported "dest" type.'
);
const s = this.tmpBuf;
this.tintFn(A, t, s, 0), this.base.getRgbItem(s, 0, i, g);
}
getRgbBuffer(A, t, i, g, s, n, a) {
(typeof V > "u" || V.test("TESTING")) && PA(
g instanceof Uint8ClampedArray,
'AlternateCS.getRgbBuffer: Unsupported "dest" type.'
);
const o = this.tintFn, I = this.base, r = 1 / ((1 << n) - 1), f = I.numComps, l = I.usesZeroToOneRange, C = (I.isPassthrough(8) || !l) && a === 0;
let B = C ? s : 0;
const c = C ? g : new Uint8ClampedArray(f * i), E = this.numComps, h = new Float32Array(E), d = new Float32Array(f);
let u, m;
for (u = 0; u < i; u++) {
for (m = 0; m < E; m++)
h[m] = A[t++] * r;
if (o(h, 0, d, 0), l)
for (m = 0; m < f; m++)
c[B++] = d[m] * 255;
else
I.getRgbItem(d, 0, c, B), B += f;
}
C || I.getRgbBuffer(c, 0, i, g, s, 8, a);
}
getOutputLength(A, t) {
return this.base.getOutputLength(
A * this.base.numComps / this.numComps,
t
);
}
}
class Yl extends dt {
constructor(A) {
super("Pattern", null), this.base = A;
}
isDefaultDecode(A, t) {
_A("Should not call PatternCS.isDefaultDecode");
}
}
class Ah extends dt {
constructor(A, t, i) {
super("Indexed", 1), this.base = A, this.highVal = t;
const g = A.numComps * (t + 1);
if (this.lookup = new Uint8Array(g), i instanceof Ae) {
const s = i.getBytes(g);
this.lookup.set(s);
} else if (typeof i == "string")
for (let s = 0; s < g; ++s)
this.lookup[s] = i.charCodeAt(s) & 255;
else
throw new Z(`IndexedCS - unrecognized lookup table: ${i}`);
}
getRgbItem(A, t, i, g) {
(typeof V > "u" || V.test("TESTING")) && PA(
i instanceof Uint8ClampedArray,
'IndexedCS.getRgbItem: Unsupported "dest" type.'
);
const { base: s, highVal: n, lookup: a } = this, o = Pe(Math.round(A[t]), 0, n) * s.numComps;
s.getRgbBuffer(a, o, 1, i, g, 8, 0);
}
getRgbBuffer(A, t, i, g, s, n, a) {
(typeof V > "u" || V.test("TESTING")) && PA(
g instanceof Uint8ClampedArray,
'IndexedCS.getRgbBuffer: Unsupported "dest" type.'
);
const { base: o, highVal: I, lookup: r } = this, { numComps: f } = o, l = o.getOutputLength(f, a);
for (let C = 0; C < i; ++C) {
const B = Pe(Math.round(A[t++]), 0, I) * f;
o.getRgbBuffer(r, B, 1, g, s, 8, a), s += l;
}
}
getOutputLength(A, t) {
return this.base.getOutputLength(A * this.base.numComps, t);
}
isDefaultDecode(A, t) {
return dc(A, 2) ? !0 : !Number.isInteger(t) || t < 1 ? (S("Bits per component is not correct"), !0) : A[0] === 0 && A[1] === (1 << t) - 1;
}
}
class eh extends dt {
constructor() {
super("DeviceGray", 1);
}
getRgbItem(A, t, i, g) {
(typeof V > "u" || V.test("TESTING")) && PA(
i instanceof Uint8ClampedArray,
'DeviceGrayCS.getRgbItem: Unsupported "dest" type.'
);
const s = A[t] * 255;
i[g] = i[g + 1] = i[g + 2] = s;
}
getRgbBuffer(A, t, i, g, s, n, a) {
(typeof V > "u" || V.test("TESTING")) && PA(
g instanceof Uint8ClampedArray,
'DeviceGrayCS.getRgbBuffer: Unsupported "dest" type.'
);
const o = 255 / ((1 << n) - 1);
let I = t, r = s;
for (let f = 0; f < i; ++f) {
const l = o * A[I++];
g[r++] = l, g[r++] = l, g[r++] = l, r += a;
}
}
getOutputLength(A, t) {
return A * (3 + t);
}
}
class th extends dt {
constructor() {
super("DeviceRGB", 3);
}
getRgbItem(A, t, i, g) {
(typeof V > "u" || V.test("TESTING")) && PA(
i instanceof Uint8ClampedArray,
'DeviceRgbCS.getRgbItem: Unsupported "dest" type.'
), i[g] = A[t] * 255, i[g + 1] = A[t + 1] * 255, i[g + 2] = A[t + 2] * 255;
}
getRgbBuffer(A, t, i, g, s, n, a) {
if ((typeof V > "u" || V.test("TESTING")) && PA(
g instanceof Uint8ClampedArray,
'DeviceRgbCS.getRgbBuffer: Unsupported "dest" type.'
), n === 8 && a === 0) {
g.set(A.subarray(t, t + i * 3), s);
return;
}
const o = 255 / ((1 << n) - 1);
let I = t, r = s;
for (let f = 0; f < i; ++f)
g[r++] = o * A[I++], g[r++] = o * A[I++], g[r++] = o * A[I++], r += a;
}
getOutputLength(A, t) {
return A * (3 + t) / 3 | 0;
}
isPassthrough(A) {
return A === 8;
}
}
class ih extends dt {
constructor() {
super("DeviceRGBA", 4);
}
getOutputLength(A, t) {
return A * 4;
}
isPassthrough(A) {
return A === 8;
}
fillRgb(A, t, i, g, s, n, a, o, I) {
(typeof V > "u" || V.test("TESTING")) && PA(
A instanceof Uint8ClampedArray,
'DeviceRgbaCS.fillRgb: Unsupported "dest" type.'
), i !== s || t !== g ? ZE(
o,
A,
t,
i,
g,
s,
I
) : _E(o, A, I);
}
}
var g0, vr;
class wc extends dt {
constructor() {
super("DeviceCMYK", 4);
CA(this, g0);
}
getRgbItem(t, i, g, s) {
(typeof V > "u" || V.test("TESTING")) && PA(
g instanceof Uint8ClampedArray,
'DeviceCmykCS.getRgbItem: Unsupported "dest" type.'
), J(this, g0, vr).call(this, t, i, 1, g, s);
}
getRgbBuffer(t, i, g, s, n, a, o) {
(typeof V > "u" || V.test("TESTING")) && PA(
s instanceof Uint8ClampedArray,
'DeviceCmykCS.getRgbBuffer: Unsupported "dest" type.'
);
const I = 1 / ((1 << a) - 1);
for (let r = 0; r < g; r++)
J(this, g0, vr).call(this, t, i, I, s, n), i += 4, n += 3 + o;
}
getOutputLength(t, i) {
return t / 4 * (3 + i) | 0;
}
}
g0 = new WeakSet(), // The coefficients below was found using numerical analysis: the method of
// steepest descent for the sum((f_i - color_value_i)^2) for r/g/b colors,
// where color_value is the tabular value from the table of sampled RGB colors
// from CMYK US Web Coated (SWOP) colorspace, and f_i is the corresponding
// CMYK color conversion using the estimation below:
// f(A, B,.. N) = Acc+Bcm+Ccy+Dck+c+Fmm+Gmy+Hmk+Im+Jyy+Kyk+Ly+Mkk+Nk+255
vr = function(t, i, g, s, n) {
const a = t[i] * g, o = t[i + 1] * g, I = t[i + 2] * g, r = t[i + 3] * g;
s[n] = 255 + a * (-4.387332384609988 * a + 54.48615194189176 * o + 18.82290502165302 * I + 212.25662451639585 * r + -285.2331026137004) + o * (1.7149763477362134 * o - 5.6096736904047315 * I + -17.873870861415444 * r - 5.497006427196366) + I * (-2.5217340131683033 * I - 21.248923337353073 * r + 17.5119270841813) + r * (-21.86122147463605 * r - 189.48180835922747), s[n + 1] = 255 + a * (8.841041422036149 * a + 60.118027045597366 * o + 6.871425592049007 * I + 31.159100130055922 * r + -79.2970844816548) + o * (-15.310361306967817 * o + 17.575251261109482 * I + 131.35250912493976 * r - 190.9453302588951) + I * (4.444339102852739 * I + 9.8632861493405 * r - 24.86741582555878) + r * (-20.737325471181034 * r - 187.80453709719578), s[n + 2] = 255 + a * (0.8842522430003296 * a + 8.078677503112928 * o + 30.89978309703729 * I - 0.23883238689178934 * r + -14.183576799673286) + o * (10.49593273432072 * o + 63.02378494754052 * I + 50.606957656360734 * r - 112.23884253719248) + I * (0.03296041114873217 * I + 115.60384449646641 * r + -193.58209356861505) + r * (-22.33816807309886 * r - 180.12613974708367);
};
var s0, Jr;
class gh extends dt {
constructor(t, i, g) {
super("CalGray", 1);
CA(this, s0);
if (!t)
throw new Z(
"WhitePoint missing - required for color space CalGray"
);
if ([this.XW, this.YW, this.ZW] = t, [this.XB, this.YB, this.ZB] = i || [0, 0, 0], this.G = g || 1, this.XW < 0 || this.ZW < 0 || this.YW !== 1)
throw new Z(
`Invalid WhitePoint components for ${this.name}, no fallback available`
);
(this.XB < 0 || this.YB < 0 || this.ZB < 0) && (ue(`Invalid BlackPoint for ${this.name}, falling back to default.`), this.XB = this.YB = this.ZB = 0), (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) && S(
`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ZB: ${this.ZB}, only default values are supported.`
), this.G < 1 && (ue(
`Invalid Gamma: ${this.G} for ${this.name}, falling back to default.`
), this.G = 1);
}
getRgbItem(t, i, g, s) {
(typeof V > "u" || V.test("TESTING")) && PA(
g instanceof Uint8ClampedArray,
'CalGrayCS.getRgbItem: Unsupported "dest" type.'
), J(this, s0, Jr).call(this, t, i, g, s, 1);
}
getRgbBuffer(t, i, g, s, n, a, o) {
(typeof V > "u" || V.test("TESTING")) && PA(
s instanceof Uint8ClampedArray,
'CalGrayCS.getRgbBuffer: Unsupported "dest" type.'
);
const I = 1 / ((1 << a) - 1);
for (let r = 0; r < g; ++r)
J(this, s0, Jr).call(this, t, i, s, n, I), i += 1, n += 3 + o;
}
getOutputLength(t, i) {
return t * (3 + i);
}
}
s0 = new WeakSet(), Jr = function(t, i, g, s, n) {
const o = (t[i] * n) ** this.G, I = this.YW * o, r = Math.max(295.8 * I ** 0.3333333333333333 - 40.8, 0);
g[s] = r, g[s + 1] = r, g[s + 2] = r;
};
var n0, a0, QI, EI, o0, dn, I0, hI, je, _s, mc, pc, qo, $s, bc, xc, yc, Kr;
const Ke = class Ke extends dt {
constructor(t, i, g, s) {
super("CalRGB", 3);
CA(this, je);
if (!t)
throw new Z(
"WhitePoint missing - required for color space CalRGB"
);
const [n, a, o] = this.whitePoint = t, [I, r, f] = this.blackPoint = i || new Float32Array(3);
if ([this.GR, this.GG, this.GB] = g || 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]), n < 0 || o < 0 || a !== 1)
throw new Z(
`Invalid WhitePoint components for ${this.name}, no fallback available`
);
(I < 0 || r < 0 || f < 0) && (ue(
`Invalid BlackPoint for ${this.name} [${I}, ${r}, ${f}], falling back to default.`
), this.blackPoint = new Float32Array(3)), (this.GR < 0 || this.GG < 0 || this.GB < 0) && (ue(
`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ${this.name}, falling back to default.`
), this.GR = this.GG = this.GB = 1);
}
getRgbItem(t, i, g, s) {
(typeof V > "u" || V.test("TESTING")) && PA(
g instanceof Uint8ClampedArray,
'CalRGBCS.getRgbItem: Unsupported "dest" type.'
), J(this, je, Kr).call(this, t, i, g, s, 1);
}
getRgbBuffer(t, i, g, s, n, a, o) {
(typeof V > "u" || V.test("TESTING")) && PA(
s instanceof Uint8ClampedArray,
'CalRGBCS.getRgbBuffer: Unsupported "dest" type.'
);
const I = 1 / ((1 << a) - 1);
for (let r = 0; r < g; ++r)
J(this, je, Kr).call(this, t, i, s, n, I), i += 3, n += 3 + o;
}
getOutputLength(t, i) {
return t * (3 + i) / 3 | 0;
}
};
n0 = new WeakMap(), a0 = new WeakMap(), QI = new WeakMap(), EI = new WeakMap(), o0 = new WeakMap(), dn = new WeakMap(), I0 = new WeakMap(), hI = new WeakMap(), je = new WeakSet(), _s = function(t, i, g) {
g[0] = t[0] * i[0] + t[1] * i[1] + t[2] * i[2], g[1] = t[3] * i[0] + t[4] * i[1] + t[5] * i[2], g[2] = t[6] * i[0] + t[7] * i[1] + t[8] * i[2];
}, mc = function(t, i, g) {
g[0] = i[0] * 1 / t[0], g[1] = i[1] * 1 / t[1], g[2] = i[2] * 1 / t[2];
}, pc = function(t, i, g) {
g[0] = i[0] * 0.95047 / t[0], g[1] = i[1] * 1 / t[1], g[2] = i[2] * 1.08883 / t[2];
}, qo = function(t) {
return t <= 31308e-7 ? Pe(12.92 * t, 0, 1) : t >= 0.99554525 ? 1 : Pe((1 + 0.055) * t ** (1 / 2.4) - 0.055, 0, 1);
}, $s = function(t) {
return t < 0 ? -J(this, je, $s).call(this, -t) : t > 8 ? ((t + 16) / 116) ** 3 : t * x(Ke, hI);
}, bc = function(t, i, g) {
if (t[0] === 0 && t[1] === 0 && t[2] === 0) {
g[0] = i[0], g[1] = i[1], g[2] = i[2];
return;
}
const s = J(this, je, $s).call(this, 0), n = s, a = J(this, je, $s).call(this, t[0]), o = s, I = J(this, je, $s).call(this, t[1]), r = s, f = J(this, je, $s).call(this, t[2]), l = (1 - n) / (1 - a), C = 1 - l, B = (1 - o) / (1 - I), c = 1 - B, E = (1 - r) / (1 - f), h = 1 - E;
g[0] = i[0] * l + C, g[1] = i[1] * B + c, g[2] = i[2] * E + h;
}, xc = function(t, i, g) {
if (t[0] === 1 && t[2] === 1) {
g[0] = i[0], g[1] = i[1], g[2] = i[2];
return;
}
const s = g;
J(this, je, _s).call(this, x(Ke, n0), i, s);
const n = x(Ke, o0);
J(this, je, mc).call(this, t, s, n), J(this, je, _s).call(this, x(Ke, a0), n, g);
}, yc = function(t, i, g) {
const s = g;
J(this, je, _s).call(this, x(Ke, n0), i, s);
const n = x(Ke, o0);
J(this, je, pc).call(this, t, s, n), J(this, je, _s).call(this, x(Ke, a0), n, g);
}, Kr = function(t, i, g, s, n) {
const a = Pe(t[i] * n, 0, 1), o = Pe(t[i + 1] * n, 0, 1), I = Pe(t[i + 2] * n, 0, 1), r = a === 1 ? 1 : a ** this.GR, f = o === 1 ? 1 : o ** this.GG, l = I === 1 ? 1 : I ** this.GB, C = this.MXA * r + this.MXB * f + this.MXC * l, B = this.MYA * r + this.MYB * f + this.MYC * l, c = this.MZA * r + this.MZB * f + this.MZC * l, E = x(Ke, dn);
E[0] = C, E[1] = B, E[2] = c;
const h = x(Ke, I0);
J(this, je, xc).call(this, this.whitePoint, E, h);
const d = x(Ke, dn);
J(this, je, bc).call(this, this.blackPoint, h, d);
const u = x(Ke, I0);
J(this, je, yc).call(this, x(Ke, EI), d, u);
const m = x(Ke, dn);
J(this, je, _s).call(this, x(Ke, QI), u, m), g[s] = J(this, je, qo).call(this, m[0]) * 255, g[s + 1] = J(this, je, qo).call(this, m[1]) * 255, g[s + 2] = J(this, je, qo).call(this, m[2]) * 255;
}, // See http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html for these
// matrices.
// prettier-ignore
CA(Ke, n0, new Float32Array([
0.8951,
0.2664,
-0.1614,
-0.7502,
1.7135,
0.0367,
0.0389,
-0.0685,
1.0296
])), // prettier-ignore
CA(Ke, a0, new Float32Array([
0.9869929,
-0.1470543,
0.1599627,
0.4323053,
0.5183603,
0.0492912,
-85287e-7,
0.0400428,
0.9684867
])), // See http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html.
// prettier-ignore
CA(Ke, QI, new Float32Array([
3.2404542,
-1.5371385,
-0.4985314,
-0.969266,
1.8760108,
0.041556,
0.0556434,
-0.2040259,
1.0572252
])), CA(Ke, EI, new Float32Array([1, 1, 1])), CA(Ke, o0, new Float32Array(3)), CA(Ke, dn, new Float32Array(3)), CA(Ke, I0, new Float32Array(3)), CA(Ke, hI, (24 / 116) ** 3 / 8);
let Yr = Ke;
var Ai, jo, No, Tr;
class sh extends dt {
constructor(t, i, g) {
super("Lab", 3);
CA(this, Ai);
if (!t)
throw new Z(
"WhitePoint missing - required for color space Lab"
);
if ([this.XW, this.YW, this.ZW] = t, [this.amin, this.amax, this.bmin, this.bmax] = g || [
-100,
100,
-100,
100
], [this.XB, this.YB, this.ZB] = i || [0, 0, 0], this.XW < 0 || this.ZW < 0 || this.YW !== 1)
throw new Z(
"Invalid WhitePoint components, no fallback available"
);
(this.XB < 0 || this.YB < 0 || this.ZB < 0) && (ue("Invalid BlackPoint, falling back to default"), this.XB = this.YB = this.ZB = 0), (this.amin > this.amax || this.bmin > this.bmax) && (ue("Invalid Range, falling back to defaults"), this.amin = -100, this.amax = 100, this.bmin = -100, this.bmax = 100);
}
getRgbItem(t, i, g, s) {
(typeof V > "u" || V.test("TESTING")) && PA(
g instanceof Uint8ClampedArray,
'LabCS.getRgbItem: Unsupported "dest" type.'
), J(this, Ai, Tr).call(this, t, i, !1, g, s);
}
getRgbBuffer(t, i, g, s, n, a, o) {
(typeof V > "u" || V.test("TESTING")) && PA(
s instanceof Uint8ClampedArray,
'LabCS.getRgbBuffer: Unsupported "dest" type.'
);
const I = (1 << a) - 1;
for (let r = 0; r < g; r++)
J(this, Ai, Tr).call(this, t, i, I, s, n), i += 3, n += 3 + o;
}
getOutputLength(t, i) {
return t * (3 + i) / 3 | 0;
}
isDefaultDecode(t, i) {
return !0;
}
get usesZeroToOneRange() {
return DA(this, "usesZeroToOneRange", !1);
}
}
Ai = new WeakSet(), // Function g(x) from spec
jo = function(t) {
return t >= 6 / 29 ? t ** 3 : 108 / 841 * (t - 4 / 29);
}, No = function(t, i, g, s) {
return g + t * (s - g) / i;
}, // If decoding is needed maxVal should be 2^bits per component - 1.
Tr = function(t, i, g, s, n) {
let a = t[i], o = t[i + 1], I = t[i + 2];
g !== !1 && (a = J(this, Ai, No).call(this, a, g, 0, 100), o = J(this, Ai, No).call(this, o, g, this.amin, this.amax), I = J(this, Ai, No).call(this, I, g, this.bmin, this.bmax)), o > this.amax ? o = this.amax : o < this.amin && (o = this.amin), I > this.bmax ? I = this.bmax : I < this.bmin && (I = this.bmin);
const r = (a + 16) / 116, f = r + o / 500, l = r - I / 200, C = this.XW * J(this, Ai, jo).call(this, f), B = this.YW * J(this, Ai, jo).call(this, r), c = this.ZW * J(this, Ai, jo).call(this, l);
let E, h, d;
this.ZW < 1 ? (E = C * 3.1339 + B * -1.617 + c * -0.4906, h = C * -0.9785 + B * 1.916 + c * 0.0333, d = C * 0.072 + B * -0.229 + c * 1.4057) : (E = C * 3.2406 + B * -1.5372 + c * -0.4986, h = C * -0.9689 + B * 1.8758 + c * 0.0415, d = C * 0.0557 + B * -0.204 + c * 1.057), s[n] = Math.sqrt(E) * 255, s[n + 1] = Math.sqrt(h) * 255, s[n + 2] = Math.sqrt(d) * 255;
};
function Dc(e) {
const A = new XMLHttpRequest();
return A.open("GET", e, !1), A.responseType = "arraybuffer", A.send(null), A.response;
}
var Ki, Fg, wn, mn, r0;
const Ji = class Ji extends dt {
constructor(t, i, g) {
if (!Ji.isUsable)
throw new Error("No ICC color space support");
super(i, g);
CA(this, Ki);
CA(this, Fg);
let s;
switch (g) {
case 1:
s = gr.Gray8, NA(this, Fg, (n, a, o) => vE(x(this, Ki), n[a] * 255, o));
break;
case 3:
s = gr.RGB8, NA(this, Fg, (n, a, o) => JE(
x(this, Ki),
n[a] * 255,
n[a + 1] * 255,
n[a + 2] * 255,
o
));
break;
case 4:
s = gr.CMYK, NA(this, Fg, (n, a, o) => LE(
x(this, Ki),
n[a] * 255,
n[a + 1] * 255,
n[a + 2] * 255,
n[a + 3] * 255,
o
));
break;
default:
throw new Error(`Unsupported number of components: ${g}`);
}
if (NA(this, Ki, KE(
t,
s,
ME.Perceptual
)), !x(this, Ki))
throw new Error("Failed to create ICC color space");
x(Ji, r0) || NA(Ji, r0, new FinalizationRegistry((n) => {
YE(n);
})), x(Ji, r0).register(this, x(this, Ki));
}
getRgbHex(t, i) {
return x(this, Fg).call(
this,
t,
i,
/* css */
!0
), ve._cssColor;
}
getRgbItem(t, i, g, s) {
ve._destBuffer = g, ve._destOffset = s, ve._destLength = 3, x(this, Fg).call(
this,
t,
i,
/* css */
!1
), ve._destBuffer = null;
}
getRgbBuffer(t, i, g, s, n, a, o) {
if (t = t.subarray(i, i + g * this.numComps), a !== 8) {
const I = 255 / ((1 << a) - 1);
for (let r = 0, f = t.length;