UNPKG

@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,769 lines 2.91 MB
var kJ = Object.defineProperty; var tW = (e) => { throw TypeError(e); }; var xJ = (e, l, t) => l in e ? kJ(e, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[l] = t; var r = (e, l, t) => xJ(e, typeof l != "symbol" ? l + "" : l, t), sW = (e, l, t) => l.has(e) || tW("Cannot " + t), qo = (e, l) => Object(l) !== l ? tW('Cannot use the "in" operator on this value') : e.has(l), i = (e, l, t) => (sW(e, l, "read from private field"), t ? t.call(e) : l.get(e)), N = (e, l, t) => l.has(e) ? tW("Cannot add the same private member more than once") : l instanceof WeakSet ? l.add(e) : l.set(e, t), Z = (e, l, t, s) => (sW(e, l, "write to private field"), s ? s.call(e, t) : l.set(e, t), t), V = (e, l, t) => (sW(e, l, "access private method"), t); var tt = (e, l, t, s) => ({ set _(d) { Z(e, l, d, t); }, get _() { return i(e, l, s); } }); import { openBlock as Va, createElementBlock as ha, createStaticVNode as uW, createElementVNode as o, createTextVNode as $o, defineComponent as Kh, onMounted as oo, watch as gN, withDirectives as mo, vShow as Bo, inject as WB, createVNode as xa, unref as GW, ref as lm, shallowRef as XU, provide as tm, onUpdated as IJ, nextTick as zJ, onUnmounted as CJ, normalizeClass as DJ, renderSlot as wJ, isRef as gJ } from "vue"; const Us = (typeof PDFJSDev > "u" || PDFJSDev.test("GENERIC")) && typeof process == "object" && process + "" == "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser"), JW = [1e-3, 0, 0, 1e-3, 0, 0], rc = 1.35, jJ = 0.35, _2 = jJ / rc, Js = { ANY: 1, DISPLAY: 2, PRINT: 4, SAVE: 8, ANNOTATIONS_FORMS: 16, ANNOTATIONS_STORAGE: 32, ANNOTATIONS_DISABLE: 64, IS_EDITING: 128, OPLIST: 256 }, Wt = { DISABLE: 0, ENABLE: 1, ENABLE_FORMS: 2, ENABLE_STORAGE: 3 }, KJ = "pdfjs_internal_editor_", I = { DISABLE: -1, NONE: 0, FREETEXT: 3, HIGHLIGHT: 9, STAMP: 13, INK: 15, SIGNATURE: 101 }, sl = { RESIZE: 1, CREATE: 2, FREETEXT_SIZE: 11, FREETEXT_COLOR: 12, FREETEXT_OPACITY: 13, INK_COLOR: 21, INK_THICKNESS: 22, INK_OPACITY: 23, HIGHLIGHT_COLOR: 31, HIGHLIGHT_DEFAULT_COLOR: 32, HIGHLIGHT_THICKNESS: 33, HIGHLIGHT_FREE: 34, HIGHLIGHT_SHOW_ALL: 35, DRAW_STEP: 41 }, $Q = { PRINT: 4, MODIFY_CONTENTS: 8, COPY: 16, MODIFY_ANNOTATIONS: 32, FILL_INTERACTIVE_FORMS: 256, COPY_FOR_ACCESSIBILITY: 512, ASSEMBLE: 1024, PRINT_HIGH_QUALITY: 2048 }, Et = { FILL: 0, STROKE: 1, FILL_STROKE: 2, INVISIBLE: 3, FILL_ADD_TO_PATH: 4, STROKE_ADD_TO_PATH: 5, FILL_STROKE_ADD_TO_PATH: 6, ADD_TO_PATH: 7, FILL_STROKE_MASK: 3, ADD_TO_PATH_FLAG: 4 }, Ia = { GRAYSCALE_1BPP: 1, RGB_24BPP: 2, RGBA_32BPP: 3 }, Cl = { TEXT: 1, LINK: 2, FREETEXT: 3, LINE: 4, SQUARE: 5, CIRCLE: 6, POLYGON: 7, POLYLINE: 8, HIGHLIGHT: 9, UNDERLINE: 10, SQUIGGLY: 11, STRIKEOUT: 12, STAMP: 13, CARET: 14, INK: 15, POPUP: 16, FILEATTACHMENT: 17, SOUND: 18, MOVIE: 19, WIDGET: 20, SCREEN: 21, PRINTERMARK: 22, TRAPNET: 23, WATERMARK: 24, THREED: 25, REDACT: 26 }, q2 = { GROUP: "Group", REPLY: "R" }, $2 = { INVISIBLE: 1, HIDDEN: 2, PRINT: 4, NOZOOM: 8, NOROTATE: 16, NOVIEW: 32, READONLY: 64, LOCKED: 128, TOGGLENOVIEW: 256, LOCKEDCONTENTS: 512 }, lY = { READONLY: 1, REQUIRED: 2, NOEXPORT: 4, MULTILINE: 4096, PASSWORD: 8192, NOTOGGLETOOFF: 16384, RADIO: 32768, PUSHBUTTON: 65536, COMBO: 131072, EDIT: 262144, SORT: 524288, FILESELECT: 1048576, MULTISELECT: 2097152, DONOTSPELLCHECK: 4194304, DONOTSCROLL: 8388608, COMB: 16777216, RICHTEXT: 33554432, RADIOSINUNISON: 33554432, COMMITONSELCHANGE: 67108864 }, ba = { SOLID: 1, DASHED: 2, BEVELED: 3, INSET: 4, UNDERLINE: 5 }, tY = { 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" }, sY = { WC: "WillClose", WS: "WillSave", DS: "DidSave", WP: "WillPrint", DP: "DidPrint" }, dY = { O: "PageOpen", C: "PageClose" }, jN = { ERRORS: 0, WARNINGS: 1, INFOS: 5 }, eN = { // Intentionally start from 1 so it is easy to spot bad operators that will be // 0's. // PLEASE NOTE: We purposely keep any removed operators commented out, since // re-numbering the list would risk breaking third-party users. dependency: 1, setLineWidth: 2, setLineCap: 3, setLineJoin: 4, setMiterLimit: 5, setDash: 6, setRenderingIntent: 7, setFlatness: 8, setGState: 9, save: 10, restore: 11, transform: 12, moveTo: 13, lineTo: 14, curveTo: 15, curveTo2: 16, curveTo3: 17, closePath: 18, rectangle: 19, stroke: 20, closeStroke: 21, fill: 22, eoFill: 23, fillStroke: 24, eoFillStroke: 25, closeFillStroke: 26, closeEOFillStroke: 27, endPath: 28, clip: 29, eoClip: 30, beginText: 31, endText: 32, setCharSpacing: 33, setWordSpacing: 34, setHScale: 35, setLeading: 36, setFont: 37, setTextRenderingMode: 38, setTextRise: 39, moveText: 40, setLeadingMoveText: 41, setTextMatrix: 42, nextLine: 43, showText: 44, showSpacedText: 45, nextLineShowText: 46, nextLineSetSpacingShowText: 47, setCharWidth: 48, setCharWidthAndBounds: 49, setStrokeColorSpace: 50, setFillColorSpace: 51, setStrokeColor: 52, setStrokeColorN: 53, setFillColor: 54, setFillColorN: 55, setStrokeGray: 56, setFillGray: 57, setStrokeRGBColor: 58, setFillRGBColor: 59, setStrokeCMYKColor: 60, setFillCMYKColor: 61, shadingFill: 62, beginInlineImage: 63, beginImageData: 64, endInlineImage: 65, paintXObject: 66, markPoint: 67, markPointProps: 68, beginMarkedContent: 69, beginMarkedContentProps: 70, endMarkedContent: 71, beginCompat: 72, endCompat: 73, paintFormXObjectBegin: 74, paintFormXObjectEnd: 75, beginGroup: 76, endGroup: 77, // beginAnnotations: 78, // endAnnotations: 79, beginAnnotation: 80, endAnnotation: 81, // paintJpegXObject: 82, paintImageMaskXObject: 83, paintImageMaskXObjectGroup: 84, paintImageXObject: 85, paintInlineImageXObject: 86, paintInlineImageXObjectGroup: 87, paintImageXObjectRepeat: 88, paintImageMaskXObjectRepeat: 89, paintSolidColorImageMask: 90, constructPath: 91, setStrokeTransparent: 92, setFillTransparent: 93, rawFillPath: 94 }, qh = { moveTo: 0, lineTo: 1, curveTo: 2, closePath: 3 }, bB = { NEED_PASSWORD: 1, INCORRECT_PASSWORD: 2 }; let KN = jN.WARNINGS; function OJ(e) { Number.isInteger(e) && (KN = e); } function HJ() { return KN; } function ON(e) { KN >= jN.INFOS && console.log(`Info: ${e}`); } function il(e) { KN >= jN.WARNINGS && console.log(`Warning: ${e}`); } function al(e) { throw new Error(e); } function Gl(e, l) { e || al(l); } function vJ(e) { switch (e == null ? void 0 : e.protocol) { case "http:": case "https:": case "ftp:": case "mailto:": case "tel:": return !0; default: return !1; } } function HN(e, l = null, t = null) { if (!e) return null; if (t && typeof e == "string") { if (t.addDefaultProtocol && e.startsWith("www.")) { const d = e.match(/\./g); (d == null ? void 0 : d.length) >= 2 && (e = `http://${e}`); } if (t.tryConvertEncoding) try { e = $J(e); } catch { } } const s = l ? URL.parse(e, l) : URL.parse(e); return vJ(s) ? s : null; } function yU(e, l, t = !1) { const s = URL.parse(e); return s ? (s.hash = l, s.href) : t && HN(e, "http://example.com") ? e.split("#", 1)[0] + `${l ? `#${l}` : ""}` : ""; } function _(e, l, t, s = !1) { return (typeof PDFJSDev > "u" || PDFJSDev.test("TESTING")) && Gl( l in e, `shadow: Property "${l && l.toString()}" not found in object.` ), Object.defineProperty(e, l, { value: t, enumerable: !s, configurable: !0, writable: !1 }), t; } const Ra = function() { function l(t, s) { (typeof PDFJSDev > "u" || PDFJSDev.test("TESTING")) && this.constructor === l && al("Cannot initialize BaseException."), this.message = t, this.name = s; } return l.prototype = new Error(), l.constructor = l, l; }(); class sm extends Ra { constructor(l, t) { super(l, "PasswordException"), this.code = t; } } class dW extends Ra { constructor(l, t) { super(l, "UnknownErrorException"), this.details = t; } } class aN extends Ra { constructor(l) { super(l, "InvalidPDFException"); } } class jc extends Ra { constructor(l, t, s) { super(l, "ResponseException"), this.status = t, this.missing = s; } } class PJ extends Ra { constructor(l) { super(l, "FormatError"); } } class dF extends Ra { constructor(l) { super(l, "AbortException"); } } function SB(e) { (typeof e != "object" || (e == null ? void 0 : e.length) === void 0) && al("Invalid argument for bytesToString"); const l = e.length, t = 8192; if (l < t) return String.fromCharCode.apply(null, e); const s = []; for (let d = 0; d < l; d += t) { const U = Math.min(d + t, l), n = e.subarray(d, U); s.push(String.fromCharCode.apply(null, n)); } return s.join(""); } function HQ(e) { typeof e != "string" && al("Invalid argument for stringToBytes"); const l = e.length, t = new Uint8Array(l); for (let s = 0; s < l; ++s) t[s] = e.charCodeAt(s) & 255; return t; } function fJ(e) { return (typeof PDFJSDev > "u" || PDFJSDev.test("TESTING")) && Gl( typeof e == "number" && Math.abs(e) < 2 ** 32, `string32: Unexpected input "${e}".` ), String.fromCharCode( e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, e & 255 ); } function iY(e) { return Object.keys(e).length; } function AJ() { const e = new Uint8Array(4); return e[0] = 1, new Uint32Array(e.buffer, 0, 1)[0] === 1; } function _J() { try { return new Function(""), !0; } catch { return !1; } } class Ol { static get isLittleEndian() { return _(this, "isLittleEndian", AJ()); } static get isEvalSupported() { return _(this, "isEvalSupported", _J()); } static get isOffscreenCanvasSupported() { return _( this, "isOffscreenCanvasSupported", typeof OffscreenCanvas < "u" ); } static get isImageDecoderSupported() { return _( this, "isImageDecoderSupported", typeof ImageDecoder < "u" ); } static get platform() { const { platform: l, userAgent: t } = navigator; return _(this, "platform", { isAndroid: t.includes("Android"), isLinux: l.includes("Linux"), isMac: l.includes("Mac"), isWindows: l.includes("Win"), isFirefox: typeof PDFJSDev < "u" && PDFJSDev.test("MOZCENTRAL") || t.includes("Firefox") }); } static get isCSSRoundSupported() { var l, t; return _( this, "isCSSRoundSupported", (t = (l = globalThis.CSS) == null ? void 0 : l.supports) == null ? void 0 : t.call(l, "width: round(1.5px, 1px)") ); } } const cR = Array.from( Array(256).keys(), (e) => e.toString(16).padStart(2, "0") ); var BU, ZR, LW; class O { static makeHexColor(l, t, s) { return `#${cR[l]}${cR[t]}${cR[s]}`; } // Apply a scaling matrix to some min/max values. // If a scaling factor is negative then min and max must be // swapped. static scaleMinMax(l, t) { let s; l[0] ? (l[0] < 0 && (s = t[0], t[0] = t[2], t[2] = s), t[0] *= l[0], t[2] *= l[0], l[3] < 0 && (s = t[1], t[1] = t[3], t[3] = s), t[1] *= l[3], t[3] *= l[3]) : (s = t[0], t[0] = t[1], t[1] = s, s = t[2], t[2] = t[3], t[3] = s, l[1] < 0 && (s = t[1], t[1] = t[3], t[3] = s), t[1] *= l[1], t[3] *= l[1], l[2] < 0 && (s = t[0], t[0] = t[2], t[2] = s), t[0] *= l[2], t[2] *= l[2]), t[0] += l[4], t[1] += l[5], t[2] += l[4], t[3] += l[5]; } // Concatenates two transformation matrices together and returns the result. static transform(l, t) { return [ l[0] * t[0] + l[2] * t[1], l[1] * t[0] + l[3] * t[1], l[0] * t[2] + l[2] * t[3], l[1] * t[2] + l[3] * t[3], l[0] * t[4] + l[2] * t[5] + l[4], l[1] * t[4] + l[3] * t[5] + l[5] ]; } // For 2d affine transforms static applyTransform(l, t, s = 0) { const d = l[s], U = l[s + 1]; l[s] = d * t[0] + U * t[2] + t[4], l[s + 1] = d * t[1] + U * t[3] + t[5]; } static applyTransformToBezier(l, t, s = 0) { const d = t[0], U = t[1], n = t[2], F = t[3], a = t[4], Q = t[5]; for (let c = 0; c < 6; c += 2) { const h = l[s + c], R = l[s + c + 1]; l[s + c] = h * d + R * n + a, l[s + c + 1] = h * U + R * F + Q; } } static applyInverseTransform(l, t) { const s = l[0], d = l[1], U = t[0] * t[3] - t[1] * t[2]; l[0] = (s * t[3] - d * t[2] + t[2] * t[5] - t[4] * t[3]) / U, l[1] = (-s * t[1] + d * t[0] + t[4] * t[1] - t[5] * t[0]) / U; } // Applies the transform to the rectangle and finds the minimum axially // aligned bounding box. static axialAlignedBoundingBox(l, t, s) { const d = t[0], U = t[1], n = t[2], F = t[3], a = t[4], Q = t[5], c = l[0], h = l[1], R = l[2], W = l[3]; let S = d * c + a, b = S, m = d * R + a, B = m, G = F * h + Q, M = G, u = F * W + Q, J = u; if (U !== 0 || n !== 0) { const L = U * c, E = U * R, p = n * h, T = n * W; S += p, B += p, m += T, b += T, G += L, J += L, u += E, M += E; } s[0] = Math.min(s[0], S, m, b, B), s[1] = Math.min(s[1], G, u, M, J), s[2] = Math.max(s[2], S, m, b, B), s[3] = Math.max(s[3], G, u, M, J); } static inverseTransform(l) { const t = l[0] * l[3] - l[1] * l[2]; return [ l[3] / t, -l[1] / t, -l[2] / t, l[0] / t, (l[2] * l[5] - l[4] * l[3]) / t, (l[4] * l[1] - l[5] * l[0]) / t ]; } // This calculation uses Singular Value Decomposition. // The SVD can be represented with formula A = USV. We are interested in the // matrix S here because it represents the scale values. static singularValueDecompose2dScale(l, t) { const s = l[0], d = l[1], U = l[2], n = l[3], F = s ** 2 + d ** 2, a = s * U + d * n, Q = U ** 2 + n ** 2, c = (F + Q) / 2, h = Math.sqrt(c ** 2 - (F * Q - a ** 2)); t[0] = Math.sqrt(c + h || 1), t[1] = Math.sqrt(c - h || 1); } // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2) // For coordinate systems whose origin lies in the bottom-left, this // means normalization to (BL,TR) ordering. For systems with origin in the // top-left, this means (TL,BR) ordering. static normalizeRect(l) { const t = l.slice(0); return l[0] > l[2] && (t[0] = l[2], t[2] = l[0]), l[1] > l[3] && (t[1] = l[3], t[3] = l[1]), t; } // Returns a rectangle [x1, y1, x2, y2] corresponding to the // intersection of rect1 and rect2. If no intersection, returns 'null' // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2] static intersect(l, t) { const s = Math.max( Math.min(l[0], l[2]), Math.min(t[0], t[2]) ), d = Math.min( Math.max(l[0], l[2]), Math.max(t[0], t[2]) ); if (s > d) return null; const U = Math.max( Math.min(l[1], l[3]), Math.min(t[1], t[3]) ), n = Math.min( Math.max(l[1], l[3]), Math.max(t[1], t[3]) ); return U > n ? null : [s, U, d, n]; } static pointBoundingBox(l, t, s) { s[0] = Math.min(s[0], l), s[1] = Math.min(s[1], t), s[2] = Math.max(s[2], l), s[3] = Math.max(s[3], t); } static rectBoundingBox(l, t, s, d, U) { U[0] = Math.min(U[0], l, s), U[1] = Math.min(U[1], t, d), U[2] = Math.max(U[2], l, s), U[3] = Math.max(U[3], t, d); } // From https://github.com/adobe-webplatform/Snap.svg/blob/b365287722a72526000ac4bfcf0ce4cac2faa015/src/path.js#L852 static bezierBoundingBox(l, t, s, d, U, n, F, a, Q) { Q[0] = Math.min(Q[0], l, F), Q[1] = Math.min(Q[1], t, a), Q[2] = Math.max(Q[2], l, F), Q[3] = Math.max(Q[3], t, a), V(this, BU, LW).call(this, l, s, U, F, t, d, n, a, 3 * (-l + 3 * (s - U) + F), 6 * (l - 2 * s + U), 3 * (s - l), Q), V(this, BU, LW).call(this, l, s, U, F, t, d, n, a, 3 * (-t + 3 * (d - n) + a), 6 * (t - 2 * d + n), 3 * (d - t), Q); } } BU = new WeakSet(), ZR = function(l, t, s, d, U, n, F, a, Q, c) { if (Q <= 0 || Q >= 1) return; const h = 1 - Q, R = Q * Q, W = R * Q, S = h * (h * (h * l + 3 * Q * t) + 3 * R * s) + W * d, b = h * (h * (h * U + 3 * Q * n) + 3 * R * F) + W * a; c[0] = Math.min(c[0], S), c[1] = Math.min(c[1], b), c[2] = Math.max(c[2], S), c[3] = Math.max(c[3], b); }, LW = function(l, t, s, d, U, n, F, a, Q, c, h, R) { if (Math.abs(Q) < 1e-12) { Math.abs(c) >= 1e-12 && V(this, BU, ZR).call(this, l, t, s, d, U, n, F, a, -h / c, R); return; } const W = c ** 2 - 4 * h * Q; if (W < 0) return; const S = Math.sqrt(W), b = 2 * Q; V(this, BU, ZR).call(this, l, t, s, d, U, n, F, a, (-c + S) / b, R), V(this, BU, ZR).call(this, l, t, s, d, U, n, F, a, (-c - S) / b, R); }, N(O, BU); const qJ = [ 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 UY(e, l = !1) { if (e[0] >= "ï") { let s; if (e[0] === "þ" && e[1] === "ÿ" ? (s = "utf-16be", e.length % 2 === 1 && (e = e.slice(0, -1))) : e[0] === "ÿ" && e[1] === "þ" ? (s = "utf-16le", e.length % 2 === 1 && (e = e.slice(0, -1))) : e[0] === "ï" && e[1] === "»" && e[2] === "¿" && (s = "utf-8"), s) try { const d = new TextDecoder(s, { fatal: !0 }), U = HQ(e), n = d.decode(U); return l || !n.includes("\x1B") ? n : n.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, ""); } catch (d) { il(`stringToPDFString: "${d}".`); } } const t = []; for (let s = 0, d = e.length; s < d; s++) { const U = e.charCodeAt(s); if (!l && U === 27) { for (; ++s < d && e.charCodeAt(s) !== 27; ) ; continue; } const n = qJ[U]; t.push(n ? String.fromCharCode(n) : e.charAt(s)); } return t.join(""); } function $J(e) { return decodeURIComponent(escape(e)); } function nY(e) { return unescape(encodeURIComponent(e)); } function FY(e, l) { if (e.length !== l.length) return !1; for (let t = 0, s = e.length; t < s; t++) if (e[t] !== l[t]) return !1; return !0; } function eY(e = /* @__PURE__ */ 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 iW = null, dm = null; function oB(e) { return iW || (iW = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu, dm = /* @__PURE__ */ new Map([["ſt", "ſt"]])), e.replaceAll( iW, (l, t, s) => t ? t.normalize("NFKC") : dm.get(s) ); } function Mo() { if (typeof PDFJSDev < "u" && PDFJSDev.test("MOZCENTRAL") || typeof crypto.randomUUID == "function") return crypto.randomUUID(); const e = new Uint8Array(32); return crypto.getRandomValues(e), SB(e); } const uo = "pdfjs_internal_id_"; function lL(e, l, t) { if (!Array.isArray(t) || t.length < 2) return !1; const [s, d, ...U] = t; if (!e(s) && !Number.isInteger(s) || !l(d)) return !1; const n = U.length; let F = !0; switch (d.name) { case "XYZ": if (n < 2 || n > 3) return !1; break; case "Fit": case "FitB": return n === 0; case "FitH": case "FitBH": case "FitV": case "FitBV": if (n > 1) return !1; break; case "FitR": if (n !== 4) return !1; F = !1; break; default: return !1; } for (const a of U) if (!(typeof a == "number" || F && a === null)) return !1; return !0; } function ut(e, l, t) { return Math.min(Math.max(e, l), t); } function aY(e) { return Uint8Array.prototype.toHex ? e.toHex() : Array.from(e, (l) => cR[l]).join(""); } function mB(e) { return Uint8Array.prototype.toBase64 ? e.toBase64() : btoa(SB(e)); } function tL(e) { return Uint8Array.fromBase64 ? Uint8Array.fromBase64(e) : HQ(atob(e)); } (typeof PDFJSDev > "u" || PDFJSDev.test("SKIP_BABEL")) && typeof Promise.try != "function" && (Promise.try = function(e, ...l) { return new Promise((t) => { t(e(...l)); }); }); typeof Math.sumPrecise != "function" && (Math.sumPrecise = function(e) { return e.reduce((l, t) => l + t, 0); }); typeof PDFJSDev < "u" && !PDFJSDev.test("SKIP_BABEL") && typeof AbortSignal.any != "function" && (AbortSignal.any = function(e) { const l = new AbortController(), { signal: t } = l; for (const s of e) if (s.aborted) return l.abort(s.reason), t; for (const s of e) s.addEventListener( "abort", () => { l.abort(s.reason); }, { signal: t } // Automatically remove the listener. ); return t; }); const Ri = "http://www.w3.org/2000/svg", RF = class RF { }; r(RF, "CSS", 96), r(RF, "PDF", 72), r(RF, "PDF_TO_CSS_UNITS", RF.CSS / RF.PDF); let et = RF; async function tF(e, l = "text") { if (typeof PDFJSDev < "u" && PDFJSDev.test("MOZCENTRAL") || lc(e, document.baseURI)) { const t = await fetch(e); if (!t.ok) throw new Error(t.statusText); switch (l) { case "arraybuffer": return t.arrayBuffer(); case "blob": return t.blob(); case "json": return t.json(); } return t.text(); } return new Promise((t, s) => { const d = new XMLHttpRequest(); d.open( "GET", e, /* async = */ !0 ), d.responseType = l, d.onreadystatechange = () => { if (d.readyState === XMLHttpRequest.DONE) { if (d.status === 200 || d.status === 0) { switch (l) { case "arraybuffer": case "blob": case "json": t(d.response); return; } t(d.responseText); return; } s(new Error(d.statusText)); } }, d.send(null); }); } class Oh { /** * @param {PageViewportParameters} */ constructor({ viewBox: l, userUnit: t, scale: s, rotation: d, offsetX: U = 0, offsetY: n = 0, dontFlip: F = !1 }) { this.viewBox = l, this.userUnit = t, this.scale = s, this.rotation = d, this.offsetX = U, this.offsetY = n, s *= t; const a = (l[2] + l[0]) / 2, Q = (l[3] + l[1]) / 2; let c, h, R, W; switch (d %= 360, d < 0 && (d += 360), d) { case 180: c = -1, h = 0, R = 0, W = 1; break; case 90: c = 0, h = 1, R = 1, W = 0; break; case 270: c = 0, h = -1, R = -1, W = 0; break; case 0: c = 1, h = 0, R = 0, W = -1; break; default: throw new Error( "PageViewport: Invalid rotation, must be a multiple of 90 degrees." ); } F && (R = -R, W = -W); let S, b, m, B; c === 0 ? (S = Math.abs(Q - l[1]) * s + U, b = Math.abs(a - l[0]) * s + n, m = (l[3] - l[1]) * s, B = (l[2] - l[0]) * s) : (S = Math.abs(a - l[0]) * s + U, b = Math.abs(Q - l[1]) * s + n, m = (l[2] - l[0]) * s, B = (l[3] - l[1]) * s), this.transform = [ c * s, h * s, R * s, W * s, S - c * s * a - R * s * Q, b - h * s * a - W * s * Q ], this.width = m, this.height = B; } /** * The original, un-scaled, viewport dimensions. * @type {Object} */ get rawDims() { const l = this.viewBox; return _(this, "rawDims", { pageWidth: l[2] - l[0], pageHeight: l[3] - l[1], pageX: l[0], pageY: l[1] }); } /** * Clones viewport, with optional additional properties. * @param {PageViewportCloneParameters} [params] * @returns {PageViewport} Cloned viewport. */ clone({ scale: l = this.scale, rotation: t = this.rotation, offsetX: s = this.offsetX, offsetY: d = this.offsetY, dontFlip: U = !1 } = {}) { return new Oh({ viewBox: this.viewBox.slice(), userUnit: this.userUnit, scale: l, rotation: t, offsetX: s, offsetY: d, dontFlip: U }); } /** * Converts PDF point to the viewport coordinates. For examples, useful for * converting PDF location into canvas pixel coordinates. * @param {number} x - The x-coordinate. * @param {number} y - The y-coordinate. * @returns {Array} Array containing `x`- and `y`-coordinates of the * point in the viewport coordinate space. * @see {@link convertToPdfPoint} * @see {@link convertToViewportRectangle} */ convertToViewportPoint(l, t) { const s = [l, t]; return O.applyTransform(s, this.transform), s; } /** * Converts PDF rectangle to the viewport coordinates. * @param {Array} rect - The xMin, yMin, xMax and yMax coordinates. * @returns {Array} Array containing corresponding coordinates of the * rectangle in the viewport coordinate space. * @see {@link convertToViewportPoint} */ convertToViewportRectangle(l) { const t = [l[0], l[1]]; O.applyTransform(t, this.transform); const s = [l[2], l[3]]; return O.applyTransform(s, this.transform), [t[0], t[1], s[0], s[1]]; } /** * Converts viewport coordinates to the PDF location. For examples, useful * for converting canvas pixel location into PDF one. * @param {number} x - The x-coordinate. * @param {number} y - The y-coordinate. * @returns {Array} Array containing `x`- and `y`-coordinates of the * point in the PDF coordinate space. * @see {@link convertToViewportPoint} */ convertToPdfPoint(l, t) { const s = [l, t]; return O.applyInverseTransform(s, this.transform), s; } } class iF extends Ra { constructor(l, t = 0) { super(l, "RenderingCancelledException"), this.extraDelay = t; } } function CQ(e) { const l = e.length; let t = 0; for (; t < l && e[t].trim() === ""; ) t++; return e.substring(t, t + 5).toLowerCase() === "data:"; } function Hh(e) { return typeof e == "string" && /\.pdf$/i.test(e); } function BB(e) { return [e] = e.split(/[#?]/, 1), e.substring(e.lastIndexOf("/") + 1); } function TW(e, l = "document.pdf") { if (typeof e != "string") return l; if (CQ(e)) return il('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'), l; const t = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/, s = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i, d = t.exec(e); let U = s.exec(d[1]) || s.exec(d[2]) || s.exec(d[3]); if (U && (U = U[0], U.includes("%"))) try { U = s.exec( decodeURIComponent(U) )[0]; } catch { } return U || l; } class im { constructor() { r(this, "started", /* @__PURE__ */ Object.create(null)); r(this, "times", []); } time(l) { l in this.started && il(`Timer is already running for ${l}`), this.started[l] = Date.now(); } timeEnd(l) { l in this.started || il(`Timer has not been started for ${l}`), this.times.push({ name: l, start: this.started[l], end: Date.now() }), delete this.started[l]; } toString() { const l = []; let t = 0; for (const { name: s } of this.times) t = Math.max(s.length, t); for (const { name: s, start: d, end: U } of this.times) l.push(`${s.padEnd(t)} ${U - d}ms `); return l.join(""); } } function lc(e, l) { if (typeof PDFJSDev < "u" && PDFJSDev.test("MOZCENTRAL")) throw new Error("Not implemented: isValidFetchUrl"); const t = l ? URL.parse(e, l) : URL.parse(e); return (t == null ? void 0 : t.protocol) === "http:" || (t == null ? void 0 : t.protocol) === "https:"; } function Pt(e) { e.preventDefault(); } function Nl(e) { e.preventDefault(), e.stopPropagation(); } function sL(e) { console.log("Deprecated API usage: " + e); } var _c; class vN { /** * Convert a PDF date string to a JavaScript `Date` object. * * The PDF date string format is described in section 7.9.4 of the official * PDF 32000-1:2008 specification. However, in the PDF 1.7 reference (sixth * edition) Adobe describes the same format including a trailing apostrophe. * This syntax in incorrect, but Adobe Acrobat creates PDF files that contain * them. We ignore all apostrophes as they are not necessary for date parsing. * * Moreover, Adobe Acrobat doesn't handle changing the date to universal time * and doesn't use the user's time zone (effectively ignoring the HH' and mm' * parts of the date string). * * @param {string} input * @returns {Date|null} */ static toDateObject(l) { if (!l || typeof l != "string") return null; i(this, _c) || Z(this, _c, new RegExp( "^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?" // Trailing apostrophe (optional) )); const t = i(this, _c).exec(l); if (!t) return null; const s = parseInt(t[1], 10); let d = parseInt(t[2], 10); d = d >= 1 && d <= 12 ? d - 1 : 0; let U = parseInt(t[3], 10); U = U >= 1 && U <= 31 ? U : 1; let n = parseInt(t[4], 10); n = n >= 0 && n <= 23 ? n : 0; let F = parseInt(t[5], 10); F = F >= 0 && F <= 59 ? F : 0; let a = parseInt(t[6], 10); a = a >= 0 && a <= 59 ? a : 0; const Q = t[7] || "Z"; let c = parseInt(t[8], 10); c = c >= 0 && c <= 23 ? c : 0; let h = parseInt(t[9], 10) || 0; return h = h >= 0 && h <= 59 ? h : 0, Q === "-" ? (n += c, F += h) : Q === "+" && (n -= c, F -= h), new Date(Date.UTC(s, d, U, n, F, a)); } } _c = new WeakMap(), N(vN, _c); function MB(e, { scale: l = 1, rotation: t = 0 }) { const { width: s, height: d } = e.attributes.style, U = [0, 0, parseInt(s), parseInt(d)]; return new Oh({ viewBox: U, userUnit: 1, scale: l, rotation: t }); } function Go(e) { if (e.startsWith("#")) { const l = parseInt(e.slice(1), 16); return [ (l & 16711680) >> 16, (l & 65280) >> 8, l & 255 ]; } return e.startsWith("rgb(") ? e.slice( /* "rgb(".length */ 4, -1 ).split(",").map((l) => parseInt(l)) : e.startsWith("rgba(") ? e.slice( /* "rgba(".length */ 5, -1 ).split(",").map((l) => parseInt(l)).slice(0, 3) : (il(`Not a valid color format: "${e}"`), [0, 0, 0]); } function dL(e) { const l = document.createElement("span"); l.style.visibility = "hidden", l.style.colorScheme = "only light", document.body.append(l); for (const t of e.keys()) { l.style.color = t; const s = window.getComputedStyle(l).color; e.set(t, Go(s)); } l.remove(); } function xl(e) { const { a: l, b: t, c: s, d, e: U, f: n } = e.getTransform(); return [l, t, s, d, U, n]; } function Xd(e) { const { a: l, b: t, c: s, d, e: U, f: n } = e.getTransform().invertSelf(); return [l, t, s, d, U, n]; } function uU(e, l, t = !1, s = !0) { if (l instanceof Oh) { const { pageWidth: d, pageHeight: U } = l.rawDims, { style: n } = e, F = Ol.isCSSRoundSupported, a = `var(--total-scale-factor) * ${d}px`, Q = `var(--total-scale-factor) * ${U}px`, c = F ? `round(down, ${a}, var(--scale-round-x))` : `calc(${a})`, h = F ? `round(down, ${Q}, var(--scale-round-y))` : `calc(${Q})`; !t || l.rotation % 180 === 0 ? (n.width = c, n.height = h) : (n.width = h, n.height = c); } s && e.setAttribute("data-main-rotation", l.rotation); } class Tt { constructor() { const { pixelRatio: l } = Tt; this.sx = l, this.sy = l; } /** * @type {boolean} Returns `true` when scaling is required, `false` otherwise. */ get scaled() { return this.sx !== 1 || this.sy !== 1; } /** * @type {boolean} Returns `true` when scaling is symmetric, * `false` otherwise. */ get symmetric() { return this.sx === this.sy; } /** * @returns {boolean} Returns `true` if scaling was limited, * `false` otherwise. */ limitCanvas(l, t, s, d, U = -1) { let n = 1 / 0, F = 1 / 0, a = 1 / 0; s = Tt.capPixels(s, U), s > 0 && (n = Math.sqrt(s / (l * t))), d !== -1 && (F = d / l, a = d / t); const Q = Math.min(n, F, a); return this.sx > Q || this.sy > Q ? (this.sx = Q, this.sy = Q, !0) : !1; } static get pixelRatio() { return globalThis.devicePixelRatio || 1; } static capPixels(l, t) { if (t >= 0) { const s = Math.ceil( (typeof PDFJSDev < "u" && PDFJSDev.test("TESTING") ? window.innerWidth * window.innerHeight : window.screen.availWidth * window.screen.availHeight) * this.pixelRatio ** 2 * (1 + t / 100) ); return l > 0 ? Math.min(l, s) : s; } return l; } } const SF = [ "image/apng", "image/avif", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg+xml", "image/webp", "image/x-icon" ]; var rU, mF, rs, kU, qc, wa, $c, SN, uB, Lt, GB, JB, tc, LB, VR; const Si = class Si { constructor(l) { N(this, Lt); N(this, rU, null); N(this, mF, null); N(this, rs); N(this, kU, null); N(this, qc, null); N(this, wa, null); Z(this, rs, l), i(Si, $c) || Z(Si, $c, Object.freeze({ freetext: "pdfjs-editor-remove-freetext-button", highlight: "pdfjs-editor-remove-highlight-button", ink: "pdfjs-editor-remove-ink-button", stamp: "pdfjs-editor-remove-stamp-button", signature: "pdfjs-editor-remove-signature-button" })); } render() { const l = Z(this, rU, document.createElement("div")); l.classList.add("editToolbar", "hidden"), l.setAttribute("role", "toolbar"); const t = i(this, rs)._uiManager._signal; l.addEventListener("contextmenu", Pt, { signal: t }), l.addEventListener("pointerdown", V(Si, SN, uB), { signal: t }); const s = Z(this, kU, document.createElement("div")); s.className = "buttons", l.append(s); const d = i(this, rs).toolbarPosition; if (d) { const { style: U } = l, n = i(this, rs)._uiManager.direction === "ltr" ? 1 - d[0] : d[0]; U.insetInlineEnd = `${100 * n}%`, U.top = `calc(${100 * d[1]}% + var(--editor-toolbar-vert-offset))`; } return V(this, Lt, LB).call(this), l; } get div() { return i(this, rU); } hide() { var l; i(this, rU).classList.add("hidden"), (l = i(this, mF)) == null || l.hideDropdown(); } show() { var l; i(this, rU).classList.remove("hidden"), (l = i(this, qc)) == null || l.shown(); } async addAltText(l) { const t = await l.render(); V(this, Lt, tc).call(this, t), i(this, kU).prepend(t, i(this, Lt, VR)), Z(this, qc, l); } addColorPicker(l) { Z(this, mF, l); const t = l.renderButton(); V(this, Lt, tc).call(this, t), i(this, kU).prepend(t, i(this, Lt, VR)); } async addEditSignatureButton(l) { const t = Z(this, wa, await l.renderEditButton(i(this, rs))); V(this, Lt, tc).call(this, t), i(this, kU).prepend(t, i(this, Lt, VR)); } updateEditSignatureButton(l) { i(this, wa) && (i(this, wa).title = l); } remove() { var l; i(this, rU).remove(), (l = i(this, mF)) == null || l.destroy(), Z(this, mF, null); } }; rU = new WeakMap(), mF = new WeakMap(), rs = new WeakMap(), kU = new WeakMap(), qc = new WeakMap(), wa = new WeakMap(), $c = new WeakMap(), SN = new WeakSet(), uB = function(l) { l.stopPropagation(); }, Lt = new WeakSet(), GB = function(l) { i(this, rs)._focusEventsAllowed = !1, Nl(l); }, JB = function(l) { i(this, rs)._focusEventsAllowed = !0, Nl(l); }, tc = function(l) { const t = i(this, rs)._uiManager._signal; l.addEventListener("focusin", V(this, Lt, GB).bind(this), { capture: !0, signal: t }), l.addEventListener("focusout", V(this, Lt, JB).bind(this), { capture: !0, signal: t }), l.addEventListener("contextmenu", Pt, { signal: t }); }, LB = function() { const { editorType: l, _uiManager: t } = i(this, rs), s = document.createElement("button"); s.className = "delete", s.tabIndex = 0, s.setAttribute("data-l10n-id", i(Si, $c)[l]), V(this, Lt, tc).call(this, s), s.addEventListener( "click", (d) => { t.delete(); }, { signal: t._signal } ), i(this, kU).append(s); }, VR = function() { const l = document.createElement("div"); return l.className = "divider", l; }, N(Si, SN), N(Si, $c, null); let EW = Si; var lZ, BF, MF, nF, TB, EB, pB; class iL { constructor(l) { N(this, nF); N(this, lZ, null); N(this, BF, null); N(this, MF); Z(this, MF, l); } show(l, t, s) { const [d, U] = V(this, nF, EB).call(this, t, s), { style: n } = i(this, BF) || Z(this, BF, V(this, nF, TB).call(this)); l.append(i(this, BF)), n.insetInlineEnd = `${100 * d}%`, n.top = `calc(${100 * U}% + var(--editor-toolbar-vert-offset))`; } hide() { i(this, BF).remove(); } } lZ = new WeakMap(), BF = new WeakMap(), MF = new WeakMap(), nF = new WeakSet(), TB = function() { const l = Z(this, BF, document.createElement("div")); l.className = "editToolbar", l.setAttribute("role", "toolbar"), l.addEventListener("contextmenu", Pt, { signal: i(this, MF)._signal }); const t = Z(this, lZ, document.createElement("div")); return t.className = "buttons", l.append(t), V(this, nF, pB).call(this), l; }, EB = function(l, t) { let s = 0, d = 0; for (const U of l) { const n = U.y + U.height; if (n < s) continue; const F = U.x + (t ? U.width : 0); if (n > s) { d = F, s = n; continue; } t ? F > d && (d = F) : F < d && (d = F); } return [t ? 1 - d : d, s]; }, pB = function() { const l = document.createElement("button"); l.className = "highlightButton", l.tabIndex = 0, l.setAttribute("data-l10n-id", "pdfjs-highlight-floating-button1"); const t = document.createElement("span"); l.append(t), t.className = "visuallyHidden", t.setAttribute("data-l10n-id", "pdfjs-highlight-floating-button-label"); const s = i(this, MF)._signal; l.addEventListener("contextmenu", Pt, { signal: s }), l.addEventListener( "click", () => { i(this, MF).highlightSelection("floating_button"); }, { signal: s } ), i(this, lZ).append(l); }; function YB(e, l, t) { for (const s of t) l.addEventListener(s, e[s].bind(e)); } var tZ; class UL { constructor() { N(this, tZ, 0); typeof PDFJSDev < "u" && PDFJSDev.test("TESTING") && Object.defineProperty(this, "reset", { value: () => Z(this, tZ, 0) }); } /** * Get a unique id. * @returns {string} */ get id() { return `${KJ}${tt(this, tZ)._++}`; } } tZ = new WeakMap(); var ga, sZ, Yt, ja, hR; const jo = class jo { constructor() { N(this, ja); N(this, ga, Mo()); N(this, sZ, 0); N(this, Yt, null); } static get _isSVGFittingCanvas() { const l = 'data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>', s = new OffscreenCanvas(1, 3).getContext("2d", { willReadFrequently: !0 }), d = new Image(); d.src = l; const U = d.decode().then(() => (s.drawImage(d, 0, 0, 1, 1, 0, 0, 1, 3), new Uint32Array(s.getImageData(0, 0, 1, 1).data.buffer)[0] === 0)); return _(this, "_isSVGFittingCanvas", U); } async getFromFile(l) { const { lastModified: t, name: s, size: d, type: U } = l; return V(this, ja, hR).call(this, `${t}_${s}_${d}_${U}`, l); } async getFromUrl(l) { return V(this, ja, hR).call(this, l, l); } async getFromBlob(l, t) { const s = await t; return V(this, ja, hR).call(this, l, s); } async getFromId(l) { i(this, Yt) || Z(this, Yt, /* @__PURE__ */ new Map()); const t = i(this, Yt).get(l); if (!t) return null; if (t.bitmap) return t.refCounter += 1, t; if (t.file) return this.getFromFile(t.file); if (t.blobPromise) { const { blobPromise: s } = t; return delete t.blobPromise, this.getFromBlob(t.id, s); } return this.getFromUrl(t.url); } getFromCanvas(l, t) { i(this, Yt) || Z(this, Yt, /* @__PURE__ */ new Map()); let s = i(this, Yt).get(l); if (s != null && s.bitmap) return s.refCounter += 1, s; const d = new OffscreenCanvas(t.width, t.height); return d.getContext("2d").drawImage(t, 0, 0), s = { bitmap: d.transferToImageBitmap(), id: `image_${i(this, ga)}_${tt(this, sZ)._++}`, refCounter: 1, isSvg: !1 }, i(this, Yt).set(l, s), i(this, Yt).set(s.id, s), s; } getSvgUrl(l) { const t = i(this, Yt).get(l); return t != null && t.isSvg ? t.svgUrl : null; } deleteId(l) { var d; i(this, Yt) || Z(this, Yt, /* @__PURE__ */ new Map()); const t = i(this, Yt).get(l); if (!t || (t.refCounter -= 1, t.refCounter !== 0)) return; const { bitmap: s } = t; if (!t.url && !t.file) { const U = new OffscreenCanvas(s.width, s.height); U.getContext("bitmaprenderer").transferFromImageBitmap(s), t.blobPromise = U.convertToBlob(); } (d = s.close) == null || d.call(s), t.bitmap = null; } // We can use the id only if it belongs this manager. // We must take care of having the right manager because we can copy/paste // some images from other documents, hence it'd be a pity to use an id from an // other manager. isValidId(l) { return l.startsWith(`image_${i(this, ga)}_`); } }; ga = new WeakMap(), sZ = new WeakMap(), Yt = new WeakMap(), ja = new WeakSet(), hR = async function(l, t) { i(this, Yt) || Z(this, Yt, /* @__PURE__ */ new Map()); let s = i(this, Yt).get(l); if (s === null) return null; if (s != null && s.bitmap) return s.refCounter += 1, s; try { s || (s = { bitmap: null, id: `image_${i(this, ga)}_${tt(this, sZ)._++}`, refCounter: 0, isSvg: !1 }); let d; if (typeof t == "string" ? (s.url = t, d = await tF(t, "blob")) : t instanceof File ? d = s.file = t : t instanceof Blob && (d = t), d.type === "image/svg+xml") { const U = jo._isSVGFittingCanvas, n = new FileReader(), F = new Image(), a = new Promise((Q, c) => { F.onload = () => { s.bitmap = F, s.isSvg = !0, Q(); }, n.onload = async () => { const h = s.svgUrl = n.result; F.src = await U ? `${h}#svgView(preserveAspectRatio(none))` : h; }, F.onerror = n.onerror = c; }); n.readAsDataURL(d), await a; } else s.bitmap = await createImageBitmap(d); s.refCounter = 1; } catch (d) { il(d), s = null; } return i(this, Yt).set(l, s), s && i(this, Yt).set(s.id, s), s; }; let pW = jo; var wl, xU, dZ, rl; class nL { constructor(l = 128) { N(this, wl, []); N(this, xU, !1); N(this, dZ); N(this, rl, -1); Z(this, dZ, l); } /** * @typedef {Object} addOptions * @property {function} cmd * @property {function} undo * @property {function} [post] * @property {boolean} mustExec * @property {number} type * @property {boolean} overwriteIfSameType * @property {boolean} keepUndo */ /** * Add a new couple of commands to be used in case of redo/undo. * @param {addOptions} options */ add({ cmd: l, undo: t, post: s, mustExec: d, type: U = NaN, overwriteIfSameType: n = !1, keepUndo: F = !1 }) { if (d && l(), i(this, xU)) return; const a = { cmd: l, undo: t, post: s, type: U }; if (i(this, rl) === -1) { i(this, wl).length > 0 && (i(this, wl).length = 0), Z(this, rl, 0), i(this, wl).push(a); return; } if (n && i(this, wl)[i(this, rl)].type === U) { F && (a.undo = i(this, wl)[i(this, rl)].undo), i(this, wl)[i(this, rl)] = a; return; } const Q = i(this, rl) + 1; Q === i(this, dZ) ? i(this, wl).splice(0, 1) : (Z(this, rl, Q), Q < i(this, wl).length && i(this, wl).splice(Q)), i(this, wl).push(a); } /** * Undo the last command. */ undo() { if (i(this, rl) === -1) return; Z(this, xU, !0); const { undo: l, post: t } = i(this, wl)[i(this, rl)]; l(), t == null || t(), Z(this, xU, !1), Z(this, rl, i(this, rl) - 1); } /** * Redo the last command. */ redo() { if (i(this, rl) < i(this, wl).length - 1) { Z(this, rl, i(this, rl) + 1), Z(this, xU, !0); const { cmd: l, post: t } = i(this, wl)[i(this, rl)]; l(), t == null || t(), Z(this, xU, !1); } } /** * Check if there is something to undo. * @returns {boolean} */ hasSomethingToUndo() { return i(this, rl) !== -1; } /** * Check if there is something to redo. * @returns {boolean} */ hasSomethingToRedo() { return i(this, rl) < i(this, wl).length - 1; } cleanType(l) { if (i(this, rl) !== -1) { for (let t = i(this, rl); t >= 0; t--) if (i(this, wl)[t].type !== l) { i(this, wl).splice(t + 1, i(this, rl) - t), Z(this, rl, t); return; } i(this, wl).length = 0, Z(this, rl, -1); } } destroy() { Z(this, wl, null); } } wl = new WeakMap(), xU = new WeakMap(), dZ = new WeakMap(), rl = new WeakMap(); var oN, XB; class vh { /** * Create a new keyboard manager class. * @param {Array<Array>} callbacks - an array containing an array of shortcuts * and a callback to call. * A shortcut is a string like `ctrl+c` or `mac+ctrl+c` for mac OS. */ constructor(l) { N(this, oN); this.buffer = [], this.callbacks = /* @__PURE__ */ new Map(), this.allKeys = /* @__PURE__ */ new Set(); const { isMac: t } = Ol.platform; for (const [s, d, U = {}] of l) for (const n of s) { const F = n.startsWith("mac+"); t && F ? (this.callbacks.set(n.slice(4), { callback: d, options: U }), this.allKeys.add(n.split("+").at(-1))) : !t && !F && (this.callbacks.set(n, { callback: d, options: U }), this.allKeys.add(n.split("+").at(-1))); } } /** * Execute a callback, if any, for a given keyboard event. * The self is used as `this` in the callback. * @param {Object} self * @param {KeyboardEvent} event * @returns */ exec(l, t) { if (!this.allKeys.has(t.key)) return; const s = this.callbacks.get(V(this, oN, XB).call(this, t)); if (!s) return; const { callback: d, options: { bubbles: U = !1, args: n = [], checker: F = null } } = s; F && !F(l, t) || (d.bind(l, ...n, t)(), U || Nl(t)); } } oN = new WeakSet(), /** * Serialize an event into a string in order to match a * potential key for a callback. * @param {KeyboardEvent} event * @returns {string} */ XB = function(l) { l.altKey && this.buffer.push("alt"), l.ctrlKey && this.buffer.push("ctrl"), l.metaKey && this.buffer.push("meta"), l.shiftKey && this.buffer.push("shift"), this.buffer.push(l.key); const t = this.buffer.join("+"); return this.buffer.length = 0, t; }; const Cc = class Cc { get _colors() { if (typeof PDFJSDev < "u" && PDFJSDev.test("LIB") && typeof document > "u") return _(this, "_colors", Cc._colorsMapping); const l = /* @__PURE__ */ new Map([ ["CanvasText", null], ["Canvas", null] ]); return dL(l), _(this, "_colors", l); } /** * In High Contrast Mode, the color on the screen is not always the * real color used in the pdf. * For example in some cases white can appear to be black but when saving * we want to have white. * @param {string} color * @returns {Array<number>} */ convert(l) { const t = Go(l); if (!window.matchMedia("(forced-colors: active)").matches) return t; for (const [s, d] of this._colors) if (d.every((U, n) => U === t[n])) return Cc._colorsMapping.get(s); return t; } /** * An input element must have its color value as a hex string * and not as color name. * So this function converts a name into an hex string. * @param {string} name * @returns {string} */ getHexCode(l) { const t = this._colors.get(l); return t ? O.makeHexColor(...t) : l; } }; r(Cc, "_colorsMapping", /* @__PURE__ */ new Map([ ["CanvasText", [0, 0, 0]], ["Canvas", [255, 255, 255]] ])); let YW = Cc; var Ka, as, it, St, Oa, Bi, Ha, ks, IU, zU, va, uF, Id, sd, GF, iZ, UZ, Pa, nZ, zd, CU, fa, DU, Cd, FZ, wU, eZ, gU, JF, LF, jU, aZ, ct, bl, Mi, KU, TF, QZ, cZ, OU, Dd, ui, ZZ, xs, z, RR, XW, yB, rB, NR, kB, xB, IB, yW, zB, rW, kW, CB, Ct, Ni, DB, wB, xW, gB, sc, IW; const ya = class ya { constructor(l, t, s, d, U, n, F, a, Q, c, h, R, W, S) { N(this, z); N(this, Ka, new AbortController()); N(this, as, null); N(this, it, /* @__PURE__ */ new Map()); N(this, St, /* @__PURE__ */ new Map()); N(this, Oa, null); N(this, Bi, null); N(this, Ha, null); N(this, ks, new nL()); N(this, IU, null); N(this, zU, null); N(this, va, 0); N(this, uF, /* @__PURE__ */ new Set()); N(this, Id, null); N(this, sd, null); N(this, GF, /* @__PURE__ */ new Set()); r(this, "_editorUndoB