diff --git "a/src/backend/gradio_pdf/templates/example/index.js" "b/src/backend/gradio_pdf/templates/example/index.js"
new file mode 100644--- /dev/null
+++ "b/src/backend/gradio_pdf/templates/example/index.js"
@@ -0,0 +1,12261 @@
+var Zi = Object.defineProperty;
+var ts = (dt, d, et) => d in dt ? Zi(dt, d, { enumerable: !0, configurable: !0, writable: !0, value: et }) : dt[d] = et;
+var ee = (dt, d, et) => (ts(dt, typeof d != "symbol" ? d + "" : d, et), et), Ne = (dt, d, et) => {
+ if (!d.has(dt))
+ throw TypeError("Cannot " + et);
+};
+var t = (dt, d, et) => (Ne(dt, d, "read from private field"), et ? et.call(dt) : d.get(dt)), L = (dt, d, et) => {
+ if (d.has(dt))
+ throw TypeError("Cannot add the same private member more than once");
+ d instanceof WeakSet ? d.add(dt) : d.set(dt, et);
+}, Z = (dt, d, et, l) => (Ne(dt, d, "write to private field"), l ? l.call(dt, et) : d.set(dt, et), et);
+var ge = (dt, d, et, l) => ({
+ set _(P) {
+ Z(dt, d, P, et);
+ },
+ get _() {
+ return t(dt, d, l);
+ }
+}), W = (dt, d, et) => (Ne(dt, d, "access private method"), et);
+function getDefaultExportFromCjs(dt) {
+ return dt && dt.__esModule && Object.prototype.hasOwnProperty.call(dt, "default") ? dt.default : dt;
+}
+function getAugmentedNamespace(dt) {
+ if (dt.__esModule)
+ return dt;
+ var d = dt.default;
+ if (typeof d == "function") {
+ var et = function l() {
+ return this instanceof l ? Reflect.construct(d, arguments, this.constructor) : d.apply(this, arguments);
+ };
+ et.prototype = d.prototype;
+ } else
+ et = {};
+ return Object.defineProperty(et, "__esModule", { value: !0 }), Object.keys(dt).forEach(function(l) {
+ var P = Object.getOwnPropertyDescriptor(dt, l);
+ Object.defineProperty(et, l, P.get ? P : {
+ enumerable: !0,
+ get: function() {
+ return dt[l];
+ }
+ });
+ }), et;
+}
+function commonjsRequire(dt) {
+ throw new Error('Could not dynamically require "' + dt + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
+}
+var pdf = { exports: {} };
+const __viteBrowserExternal = {}, __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
+ __proto__: null,
+ default: __viteBrowserExternal
+}, Symbol.toStringTag, { value: "Module" })), require$$5 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
+(function(module, exports) {
+ (function(d, et) {
+ module.exports = d.pdfjsLib = et();
+ })(globalThis, () => (
+ /******/
+ (() => {
+ var __webpack_modules__ = [
+ ,
+ /* 1 */
+ /***/
+ (dt, d) => {
+ var $t;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.VerbosityLevel = d.Util = d.UnknownErrorException = d.UnexpectedResponseException = d.TextRenderingMode = d.RenderingIntentFlag = d.PromiseCapability = d.PermissionFlag = d.PasswordResponses = d.PasswordException = d.PageActionEventType = d.OPS = d.MissingPDFException = d.MAX_IMAGE_SIZE_TO_CACHE = d.LINE_FACTOR = d.LINE_DESCENT_FACTOR = d.InvalidPDFException = d.ImageKind = d.IDENTITY_MATRIX = d.FormatError = d.FeatureTest = d.FONT_IDENTITY_MATRIX = d.DocumentActionEventType = d.CMapCompressionType = d.BaseException = d.BASELINE_FACTOR = d.AnnotationType = d.AnnotationReplyType = d.AnnotationPrefix = d.AnnotationMode = d.AnnotationFlag = d.AnnotationFieldFlag = d.AnnotationEditorType = d.AnnotationEditorPrefix = d.AnnotationEditorParamsType = d.AnnotationBorderStyleType = d.AnnotationActionEventType = d.AbortException = void 0, d.assert = lt, d.bytesToString = N, d.createValidAbsoluteUrl = wt, d.getModificationDate = Ct, d.getUuid = Vt, d.getVerbosityLevel = V, d.info = st, d.isArrayBuffer = ht, d.isArrayEqual = Et, d.isNodeJS = void 0, d.normalizeUnicode = Xt, d.objectFromMap = ct, d.objectSize = nt, d.setVerbosityLevel = E, d.shadow = xt, d.string32 = Q, d.stringToBytes = tt, d.stringToPDFString = ft, d.stringToUTF8String = K, d.unreachable = H, d.utf8StringToString = J, d.warn = at;
+ const et = typeof process == "object" && process + "" == "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
+ d.isNodeJS = et;
+ const l = [1, 0, 0, 1, 0, 0];
+ d.IDENTITY_MATRIX = l;
+ const P = [1e-3, 0, 0, 1e-3, 0, 0];
+ d.FONT_IDENTITY_MATRIX = P;
+ const rt = 1e7;
+ d.MAX_IMAGE_SIZE_TO_CACHE = rt;
+ const X = 1.35;
+ d.LINE_FACTOR = X;
+ const pt = 0.35;
+ d.LINE_DESCENT_FACTOR = pt;
+ const B = pt / X;
+ d.BASELINE_FACTOR = B;
+ const F = {
+ ANY: 1,
+ DISPLAY: 2,
+ PRINT: 4,
+ SAVE: 8,
+ ANNOTATIONS_FORMS: 16,
+ ANNOTATIONS_STORAGE: 32,
+ ANNOTATIONS_DISABLE: 64,
+ OPLIST: 256
+ };
+ d.RenderingIntentFlag = F;
+ const g = {
+ DISABLE: 0,
+ ENABLE: 1,
+ ENABLE_FORMS: 2,
+ ENABLE_STORAGE: 3
+ };
+ d.AnnotationMode = g;
+ const O = "pdfjs_internal_editor_";
+ d.AnnotationEditorPrefix = O;
+ const I = {
+ DISABLE: -1,
+ NONE: 0,
+ FREETEXT: 3,
+ STAMP: 13,
+ INK: 15
+ };
+ d.AnnotationEditorType = I;
+ const x = {
+ RESIZE: 1,
+ CREATE: 2,
+ FREETEXT_SIZE: 11,
+ FREETEXT_COLOR: 12,
+ FREETEXT_OPACITY: 13,
+ INK_COLOR: 21,
+ INK_THICKNESS: 22,
+ INK_OPACITY: 23
+ };
+ d.AnnotationEditorParamsType = x;
+ const v = {
+ PRINT: 4,
+ MODIFY_CONTENTS: 8,
+ COPY: 16,
+ MODIFY_ANNOTATIONS: 32,
+ FILL_INTERACTIVE_FORMS: 256,
+ COPY_FOR_ACCESSIBILITY: 512,
+ ASSEMBLE: 1024,
+ PRINT_HIGH_QUALITY: 2048
+ };
+ d.PermissionFlag = v;
+ const A = {
+ 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
+ };
+ d.TextRenderingMode = A;
+ const u = {
+ GRAYSCALE_1BPP: 1,
+ RGB_24BPP: 2,
+ RGBA_32BPP: 3
+ };
+ d.ImageKind = u;
+ const _ = {
+ 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
+ };
+ d.AnnotationType = _;
+ const w = {
+ GROUP: "Group",
+ REPLY: "R"
+ };
+ d.AnnotationReplyType = w;
+ const C = {
+ INVISIBLE: 1,
+ HIDDEN: 2,
+ PRINT: 4,
+ NOZOOM: 8,
+ NOROTATE: 16,
+ NOVIEW: 32,
+ READONLY: 64,
+ LOCKED: 128,
+ TOGGLENOVIEW: 256,
+ LOCKEDCONTENTS: 512
+ };
+ d.AnnotationFlag = C;
+ const y = {
+ 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
+ };
+ d.AnnotationFieldFlag = y;
+ const a = {
+ SOLID: 1,
+ DASHED: 2,
+ BEVELED: 3,
+ INSET: 4,
+ UNDERLINE: 5
+ };
+ d.AnnotationBorderStyleType = a;
+ const c = {
+ 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"
+ };
+ d.AnnotationActionEventType = c;
+ const k = {
+ WC: "WillClose",
+ WS: "WillSave",
+ DS: "DidSave",
+ WP: "WillPrint",
+ DP: "DidPrint"
+ };
+ d.DocumentActionEventType = k;
+ const p = {
+ O: "PageOpen",
+ C: "PageClose"
+ };
+ d.PageActionEventType = p;
+ const r = {
+ ERRORS: 0,
+ WARNINGS: 1,
+ INFOS: 5
+ };
+ d.VerbosityLevel = r;
+ const T = {
+ NONE: 0,
+ BINARY: 1
+ };
+ d.CMapCompressionType = T;
+ const m = {
+ 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,
+ beginAnnotation: 80,
+ endAnnotation: 81,
+ paintImageMaskXObject: 83,
+ paintImageMaskXObjectGroup: 84,
+ paintImageXObject: 85,
+ paintInlineImageXObject: 86,
+ paintInlineImageXObjectGroup: 87,
+ paintImageXObjectRepeat: 88,
+ paintImageMaskXObjectRepeat: 89,
+ paintSolidColorImageMask: 90,
+ constructPath: 91
+ };
+ d.OPS = m;
+ const U = {
+ NEED_PASSWORD: 1,
+ INCORRECT_PASSWORD: 2
+ };
+ d.PasswordResponses = U;
+ let z = r.WARNINGS;
+ function E(ot) {
+ Number.isInteger(ot) && (z = ot);
+ }
+ function V() {
+ return z;
+ }
+ function st(ot) {
+ z >= r.INFOS && console.log(`Info: ${ot}`);
+ }
+ function at(ot) {
+ z >= r.WARNINGS && console.log(`Warning: ${ot}`);
+ }
+ function H(ot) {
+ throw new Error(ot);
+ }
+ function lt(ot, Y) {
+ ot || H(Y);
+ }
+ function gt(ot) {
+ switch (ot == null ? void 0 : ot.protocol) {
+ case "http:":
+ case "https:":
+ case "ftp:":
+ case "mailto:":
+ case "tel:":
+ return !0;
+ default:
+ return !1;
+ }
+ }
+ function wt(ot, Y = null, G = null) {
+ if (!ot)
+ return null;
+ try {
+ if (G && typeof ot == "string") {
+ if (G.addDefaultProtocol && ot.startsWith("www.")) {
+ const At = ot.match(/\./g);
+ (At == null ? void 0 : At.length) >= 2 && (ot = `http://${ot}`);
+ }
+ if (G.tryConvertEncoding)
+ try {
+ ot = K(ot);
+ } catch {
+ }
+ }
+ const bt = Y ? new URL(ot, Y) : new URL(ot);
+ if (gt(bt))
+ return bt;
+ } catch {
+ }
+ return null;
+ }
+ function xt(ot, Y, G, bt = !1) {
+ return Object.defineProperty(ot, Y, {
+ value: G,
+ enumerable: !bt,
+ configurable: !0,
+ writable: !1
+ }), G;
+ }
+ const S = function() {
+ function Y(G, bt) {
+ this.constructor === Y && H("Cannot initialize BaseException."), this.message = G, this.name = bt;
+ }
+ return Y.prototype = new Error(), Y.constructor = Y, Y;
+ }();
+ d.BaseException = S;
+ class i extends S {
+ constructor(Y, G) {
+ super(Y, "PasswordException"), this.code = G;
+ }
+ }
+ d.PasswordException = i;
+ class n extends S {
+ constructor(Y, G) {
+ super(Y, "UnknownErrorException"), this.details = G;
+ }
+ }
+ d.UnknownErrorException = n;
+ class s extends S {
+ constructor(Y) {
+ super(Y, "InvalidPDFException");
+ }
+ }
+ d.InvalidPDFException = s;
+ class o extends S {
+ constructor(Y) {
+ super(Y, "MissingPDFException");
+ }
+ }
+ d.MissingPDFException = o;
+ class h extends S {
+ constructor(Y, G) {
+ super(Y, "UnexpectedResponseException"), this.status = G;
+ }
+ }
+ d.UnexpectedResponseException = h;
+ class b extends S {
+ constructor(Y) {
+ super(Y, "FormatError");
+ }
+ }
+ d.FormatError = b;
+ class M extends S {
+ constructor(Y) {
+ super(Y, "AbortException");
+ }
+ }
+ d.AbortException = M;
+ function N(ot) {
+ (typeof ot != "object" || (ot == null ? void 0 : ot.length) === void 0) && H("Invalid argument for bytesToString");
+ const Y = ot.length, G = 8192;
+ if (Y < G)
+ return String.fromCharCode.apply(null, ot);
+ const bt = [];
+ for (let At = 0; At < Y; At += G) {
+ const te = Math.min(At + G, Y), Zt = ot.subarray(At, te);
+ bt.push(String.fromCharCode.apply(null, Zt));
+ }
+ return bt.join("");
+ }
+ function tt(ot) {
+ typeof ot != "string" && H("Invalid argument for stringToBytes");
+ const Y = ot.length, G = new Uint8Array(Y);
+ for (let bt = 0; bt < Y; ++bt)
+ G[bt] = ot.charCodeAt(bt) & 255;
+ return G;
+ }
+ function Q(ot) {
+ return String.fromCharCode(ot >> 24 & 255, ot >> 16 & 255, ot >> 8 & 255, ot & 255);
+ }
+ function nt(ot) {
+ return Object.keys(ot).length;
+ }
+ function ct(ot) {
+ const Y = /* @__PURE__ */ Object.create(null);
+ for (const [G, bt] of ot)
+ Y[G] = bt;
+ return Y;
+ }
+ function yt() {
+ const ot = new Uint8Array(4);
+ return ot[0] = 1, new Uint32Array(ot.buffer, 0, 1)[0] === 1;
+ }
+ function ut() {
+ try {
+ return new Function(""), !0;
+ } catch {
+ return !1;
+ }
+ }
+ class Ft {
+ static get isLittleEndian() {
+ return xt(this, "isLittleEndian", yt());
+ }
+ static get isEvalSupported() {
+ return xt(this, "isEvalSupported", ut());
+ }
+ static get isOffscreenCanvasSupported() {
+ return xt(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas < "u");
+ }
+ static get platform() {
+ return typeof navigator > "u" ? xt(this, "platform", {
+ isWin: !1,
+ isMac: !1
+ }) : xt(this, "platform", {
+ isWin: navigator.platform.includes("Win"),
+ isMac: navigator.platform.includes("Mac")
+ });
+ }
+ static get isCSSRoundSupported() {
+ var Y, G;
+ return xt(this, "isCSSRoundSupported", (G = (Y = globalThis.CSS) == null ? void 0 : Y.supports) == null ? void 0 : G.call(Y, "width: round(1.5px, 1px)"));
+ }
+ }
+ d.FeatureTest = Ft;
+ const Bt = [...Array(256).keys()].map((ot) => ot.toString(16).padStart(2, "0"));
+ class St {
+ static makeHexColor(Y, G, bt) {
+ return `#${Bt[Y]}${Bt[G]}${Bt[bt]}`;
+ }
+ static scaleMinMax(Y, G) {
+ let bt;
+ Y[0] ? (Y[0] < 0 && (bt = G[0], G[0] = G[1], G[1] = bt), G[0] *= Y[0], G[1] *= Y[0], Y[3] < 0 && (bt = G[2], G[2] = G[3], G[3] = bt), G[2] *= Y[3], G[3] *= Y[3]) : (bt = G[0], G[0] = G[2], G[2] = bt, bt = G[1], G[1] = G[3], G[3] = bt, Y[1] < 0 && (bt = G[2], G[2] = G[3], G[3] = bt), G[2] *= Y[1], G[3] *= Y[1], Y[2] < 0 && (bt = G[0], G[0] = G[1], G[1] = bt), G[0] *= Y[2], G[1] *= Y[2]), G[0] += Y[4], G[1] += Y[4], G[2] += Y[5], G[3] += Y[5];
+ }
+ static transform(Y, G) {
+ return [Y[0] * G[0] + Y[2] * G[1], Y[1] * G[0] + Y[3] * G[1], Y[0] * G[2] + Y[2] * G[3], Y[1] * G[2] + Y[3] * G[3], Y[0] * G[4] + Y[2] * G[5] + Y[4], Y[1] * G[4] + Y[3] * G[5] + Y[5]];
+ }
+ static applyTransform(Y, G) {
+ const bt = Y[0] * G[0] + Y[1] * G[2] + G[4], At = Y[0] * G[1] + Y[1] * G[3] + G[5];
+ return [bt, At];
+ }
+ static applyInverseTransform(Y, G) {
+ const bt = G[0] * G[3] - G[1] * G[2], At = (Y[0] * G[3] - Y[1] * G[2] + G[2] * G[5] - G[4] * G[3]) / bt, te = (-Y[0] * G[1] + Y[1] * G[0] + G[4] * G[1] - G[5] * G[0]) / bt;
+ return [At, te];
+ }
+ static getAxialAlignedBoundingBox(Y, G) {
+ const bt = this.applyTransform(Y, G), At = this.applyTransform(Y.slice(2, 4), G), te = this.applyTransform([Y[0], Y[3]], G), Zt = this.applyTransform([Y[2], Y[1]], G);
+ return [Math.min(bt[0], At[0], te[0], Zt[0]), Math.min(bt[1], At[1], te[1], Zt[1]), Math.max(bt[0], At[0], te[0], Zt[0]), Math.max(bt[1], At[1], te[1], Zt[1])];
+ }
+ static inverseTransform(Y) {
+ const G = Y[0] * Y[3] - Y[1] * Y[2];
+ return [Y[3] / G, -Y[1] / G, -Y[2] / G, Y[0] / G, (Y[2] * Y[5] - Y[4] * Y[3]) / G, (Y[4] * Y[1] - Y[5] * Y[0]) / G];
+ }
+ static singularValueDecompose2dScale(Y) {
+ const G = [Y[0], Y[2], Y[1], Y[3]], bt = Y[0] * G[0] + Y[1] * G[2], At = Y[0] * G[1] + Y[1] * G[3], te = Y[2] * G[0] + Y[3] * G[2], Zt = Y[2] * G[1] + Y[3] * G[3], $ = (bt + Zt) / 2, vt = Math.sqrt((bt + Zt) ** 2 - 4 * (bt * Zt - te * At)) / 2, Lt = $ + vt || 1, Tt = $ - vt || 1;
+ return [Math.sqrt(Lt), Math.sqrt(Tt)];
+ }
+ static normalizeRect(Y) {
+ const G = Y.slice(0);
+ return Y[0] > Y[2] && (G[0] = Y[2], G[2] = Y[0]), Y[1] > Y[3] && (G[1] = Y[3], G[3] = Y[1]), G;
+ }
+ static intersect(Y, G) {
+ const bt = Math.max(Math.min(Y[0], Y[2]), Math.min(G[0], G[2])), At = Math.min(Math.max(Y[0], Y[2]), Math.max(G[0], G[2]));
+ if (bt > At)
+ return null;
+ const te = Math.max(Math.min(Y[1], Y[3]), Math.min(G[1], G[3])), Zt = Math.min(Math.max(Y[1], Y[3]), Math.max(G[1], G[3]));
+ return te > Zt ? null : [bt, te, At, Zt];
+ }
+ static bezierBoundingBox(Y, G, bt, At, te, Zt, $, vt) {
+ const Lt = [], Tt = [[], []];
+ let Ot, Nt, Jt, _t, Yt, It, R, e;
+ for (let q = 0; q < 2; ++q) {
+ if (q === 0 ? (Nt = 6 * Y - 12 * bt + 6 * te, Ot = -3 * Y + 9 * bt - 9 * te + 3 * $, Jt = 3 * bt - 3 * Y) : (Nt = 6 * G - 12 * At + 6 * Zt, Ot = -3 * G + 9 * At - 9 * Zt + 3 * vt, Jt = 3 * At - 3 * G), Math.abs(Ot) < 1e-12) {
+ if (Math.abs(Nt) < 1e-12)
+ continue;
+ _t = -Jt / Nt, 0 < _t && _t < 1 && Lt.push(_t);
+ continue;
+ }
+ R = Nt * Nt - 4 * Jt * Ot, e = Math.sqrt(R), !(R < 0) && (Yt = (-Nt + e) / (2 * Ot), 0 < Yt && Yt < 1 && Lt.push(Yt), It = (-Nt - e) / (2 * Ot), 0 < It && It < 1 && Lt.push(It));
+ }
+ let f = Lt.length, D;
+ const j = f;
+ for (; f--; )
+ _t = Lt[f], D = 1 - _t, Tt[0][f] = D * D * D * Y + 3 * D * D * _t * bt + 3 * D * _t * _t * te + _t * _t * _t * $, Tt[1][f] = D * D * D * G + 3 * D * D * _t * At + 3 * D * _t * _t * Zt + _t * _t * _t * vt;
+ return Tt[0][j] = Y, Tt[1][j] = G, Tt[0][j + 1] = $, Tt[1][j + 1] = vt, Tt[0].length = Tt[1].length = j + 2, [Math.min(...Tt[0]), Math.min(...Tt[1]), Math.max(...Tt[0]), Math.max(...Tt[1])];
+ }
+ }
+ d.Util = St;
+ const Dt = [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 ft(ot) {
+ if (ot[0] >= "ï") {
+ let G;
+ if (ot[0] === "þ" && ot[1] === "ÿ" ? G = "utf-16be" : ot[0] === "ÿ" && ot[1] === "þ" ? G = "utf-16le" : ot[0] === "ï" && ot[1] === "»" && ot[2] === "¿" && (G = "utf-8"), G)
+ try {
+ const bt = new TextDecoder(G, {
+ fatal: !0
+ }), At = tt(ot);
+ return bt.decode(At);
+ } catch (bt) {
+ at(`stringToPDFString: "${bt}".`);
+ }
+ }
+ const Y = [];
+ for (let G = 0, bt = ot.length; G < bt; G++) {
+ const At = Dt[ot.charCodeAt(G)];
+ Y.push(At ? String.fromCharCode(At) : ot.charAt(G));
+ }
+ return Y.join("");
+ }
+ function K(ot) {
+ return decodeURIComponent(escape(ot));
+ }
+ function J(ot) {
+ return unescape(encodeURIComponent(ot));
+ }
+ function ht(ot) {
+ return typeof ot == "object" && (ot == null ? void 0 : ot.byteLength) !== void 0;
+ }
+ function Et(ot, Y) {
+ if (ot.length !== Y.length)
+ return !1;
+ for (let G = 0, bt = ot.length; G < bt; G++)
+ if (ot[G] !== Y[G])
+ return !1;
+ return !0;
+ }
+ function Ct(ot = /* @__PURE__ */ new Date()) {
+ return [ot.getUTCFullYear().toString(), (ot.getUTCMonth() + 1).toString().padStart(2, "0"), ot.getUTCDate().toString().padStart(2, "0"), ot.getUTCHours().toString().padStart(2, "0"), ot.getUTCMinutes().toString().padStart(2, "0"), ot.getUTCSeconds().toString().padStart(2, "0")].join("");
+ }
+ class jt {
+ constructor() {
+ L(this, $t, !1);
+ this.promise = new Promise((Y, G) => {
+ this.resolve = (bt) => {
+ Z(this, $t, !0), Y(bt);
+ }, this.reject = (bt) => {
+ Z(this, $t, !0), G(bt);
+ };
+ });
+ }
+ get settled() {
+ return t(this, $t);
+ }
+ }
+ $t = new WeakMap(), d.PromiseCapability = jt;
+ let Gt = null, Ht = null;
+ function Xt(ot) {
+ return Gt || (Gt = /([\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, Ht = /* @__PURE__ */ new Map([["ſt", "ſt"]])), ot.replaceAll(Gt, (Y, G, bt) => G ? G.normalize("NFKC") : Ht.get(bt));
+ }
+ function Vt() {
+ if (typeof crypto < "u" && typeof (crypto == null ? void 0 : crypto.randomUUID) == "function")
+ return crypto.randomUUID();
+ const ot = new Uint8Array(32);
+ if (typeof crypto < "u" && typeof (crypto == null ? void 0 : crypto.getRandomValues) == "function")
+ crypto.getRandomValues(ot);
+ else
+ for (let Y = 0; Y < 32; Y++)
+ ot[Y] = Math.floor(Math.random() * 255);
+ return N(ot);
+ }
+ const Wt = "pdfjs_internal_id_";
+ d.AnnotationPrefix = Wt;
+ },
+ /* 2 */
+ /***/
+ (__unused_webpack_module, exports, __w_pdfjs_require__) => {
+ var dt, et, l, P, he, X, Ee, B, F, g, O, I, x, v, A, u, we, w, C, Be, a, c;
+ Object.defineProperty(exports, "__esModule", {
+ value: !0
+ }), exports.RenderTask = exports.PDFWorkerUtil = exports.PDFWorker = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFDocumentLoadingTask = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.DefaultStandardFontDataFactory = exports.DefaultFilterFactory = exports.DefaultCanvasFactory = exports.DefaultCMapReaderFactory = void 0, Object.defineProperty(exports, "SVGGraphics", {
+ enumerable: !0,
+ get: function() {
+ return _displaySvg.SVGGraphics;
+ }
+ }), exports.build = void 0, exports.getDocument = getDocument, exports.version = void 0;
+ var _util = __w_pdfjs_require__(1), _annotation_storage = __w_pdfjs_require__(3), _display_utils = __w_pdfjs_require__(6), _font_loader = __w_pdfjs_require__(9), _displayNode_utils = __w_pdfjs_require__(10), _canvas = __w_pdfjs_require__(11), _worker_options = __w_pdfjs_require__(14), _message_handler = __w_pdfjs_require__(15), _metadata = __w_pdfjs_require__(16), _optional_content_config = __w_pdfjs_require__(17), _transport_stream = __w_pdfjs_require__(18), _displayFetch_stream = __w_pdfjs_require__(19), _displayNetwork = __w_pdfjs_require__(22), _displayNode_stream = __w_pdfjs_require__(23), _displaySvg = __w_pdfjs_require__(24), _xfa_text = __w_pdfjs_require__(25);
+ const DEFAULT_RANGE_CHUNK_SIZE = 65536, RENDERING_CANCELLED_TIMEOUT = 100, DELAYED_CLEANUP_TIMEOUT = 5e3, DefaultCanvasFactory = _util.isNodeJS ? _displayNode_utils.NodeCanvasFactory : _display_utils.DOMCanvasFactory;
+ exports.DefaultCanvasFactory = DefaultCanvasFactory;
+ const DefaultCMapReaderFactory = _util.isNodeJS ? _displayNode_utils.NodeCMapReaderFactory : _display_utils.DOMCMapReaderFactory;
+ exports.DefaultCMapReaderFactory = DefaultCMapReaderFactory;
+ const DefaultFilterFactory = _util.isNodeJS ? _displayNode_utils.NodeFilterFactory : _display_utils.DOMFilterFactory;
+ exports.DefaultFilterFactory = DefaultFilterFactory;
+ const DefaultStandardFontDataFactory = _util.isNodeJS ? _displayNode_utils.NodeStandardFontDataFactory : _display_utils.DOMStandardFontDataFactory;
+ exports.DefaultStandardFontDataFactory = DefaultStandardFontDataFactory;
+ function getDocument(p) {
+ if (typeof p == "string" || p instanceof URL ? p = {
+ url: p
+ } : (0, _util.isArrayBuffer)(p) && (p = {
+ data: p
+ }), typeof p != "object")
+ throw new Error("Invalid parameter in getDocument, need parameter object.");
+ if (!p.url && !p.data && !p.range)
+ throw new Error("Invalid parameter object: need either .data, .range or .url");
+ const r = new PDFDocumentLoadingTask(), {
+ docId: T
+ } = r, m = p.url ? getUrlProp(p.url) : null, U = p.data ? getDataProp(p.data) : null, z = p.httpHeaders || null, E = p.withCredentials === !0, V = p.password ?? null, st = p.range instanceof PDFDataRangeTransport ? p.range : null, at = Number.isInteger(p.rangeChunkSize) && p.rangeChunkSize > 0 ? p.rangeChunkSize : DEFAULT_RANGE_CHUNK_SIZE;
+ let H = p.worker instanceof PDFWorker ? p.worker : null;
+ const lt = p.verbosity, gt = typeof p.docBaseUrl == "string" && !(0, _display_utils.isDataScheme)(p.docBaseUrl) ? p.docBaseUrl : null, wt = typeof p.cMapUrl == "string" ? p.cMapUrl : null, xt = p.cMapPacked !== !1, S = p.CMapReaderFactory || DefaultCMapReaderFactory, i = typeof p.standardFontDataUrl == "string" ? p.standardFontDataUrl : null, n = p.StandardFontDataFactory || DefaultStandardFontDataFactory, s = p.stopAtErrors !== !0, o = Number.isInteger(p.maxImageSize) && p.maxImageSize > -1 ? p.maxImageSize : -1, h = p.isEvalSupported !== !1, b = typeof p.isOffscreenCanvasSupported == "boolean" ? p.isOffscreenCanvasSupported : !_util.isNodeJS, M = Number.isInteger(p.canvasMaxAreaInBytes) ? p.canvasMaxAreaInBytes : -1, N = typeof p.disableFontFace == "boolean" ? p.disableFontFace : _util.isNodeJS, tt = p.fontExtraProperties === !0, Q = p.enableXfa === !0, nt = p.ownerDocument || globalThis.document, ct = p.disableRange === !0, yt = p.disableStream === !0, ut = p.disableAutoFetch === !0, Ft = p.pdfBug === !0, Bt = st ? st.length : p.length ?? NaN, St = typeof p.useSystemFonts == "boolean" ? p.useSystemFonts : !_util.isNodeJS && !N, Dt = typeof p.useWorkerFetch == "boolean" ? p.useWorkerFetch : S === _display_utils.DOMCMapReaderFactory && n === _display_utils.DOMStandardFontDataFactory && wt && i && (0, _display_utils.isValidFetchUrl)(wt, document.baseURI) && (0, _display_utils.isValidFetchUrl)(i, document.baseURI), ft = p.canvasFactory || new DefaultCanvasFactory({
+ ownerDocument: nt
+ }), K = p.filterFactory || new DefaultFilterFactory({
+ docId: T,
+ ownerDocument: nt
+ }), J = null;
+ (0, _util.setVerbosityLevel)(lt);
+ const ht = {
+ canvasFactory: ft,
+ filterFactory: K
+ };
+ if (Dt || (ht.cMapReaderFactory = new S({
+ baseUrl: wt,
+ isCompressed: xt
+ }), ht.standardFontDataFactory = new n({
+ baseUrl: i
+ })), !H) {
+ const jt = {
+ verbosity: lt,
+ port: _worker_options.GlobalWorkerOptions.workerPort
+ };
+ H = jt.port ? PDFWorker.fromPort(jt) : new PDFWorker(jt), r._worker = H;
+ }
+ const Et = {
+ docId: T,
+ apiVersion: "3.11.174",
+ data: U,
+ password: V,
+ disableAutoFetch: ut,
+ rangeChunkSize: at,
+ length: Bt,
+ docBaseUrl: gt,
+ enableXfa: Q,
+ evaluatorOptions: {
+ maxImageSize: o,
+ disableFontFace: N,
+ ignoreErrors: s,
+ isEvalSupported: h,
+ isOffscreenCanvasSupported: b,
+ canvasMaxAreaInBytes: M,
+ fontExtraProperties: tt,
+ useSystemFonts: St,
+ cMapUrl: Dt ? wt : null,
+ standardFontDataUrl: Dt ? i : null
+ }
+ }, Ct = {
+ ignoreErrors: s,
+ isEvalSupported: h,
+ disableFontFace: N,
+ fontExtraProperties: tt,
+ enableXfa: Q,
+ ownerDocument: nt,
+ disableAutoFetch: ut,
+ pdfBug: Ft,
+ styleElement: J
+ };
+ return H.promise.then(function() {
+ if (r.destroyed)
+ throw new Error("Loading aborted");
+ const jt = _fetchDocument(H, Et), Gt = new Promise(function(Ht) {
+ let Xt;
+ st ? Xt = new _transport_stream.PDFDataTransportStream({
+ length: Bt,
+ initialData: st.initialData,
+ progressiveDone: st.progressiveDone,
+ contentDispositionFilename: st.contentDispositionFilename,
+ disableRange: ct,
+ disableStream: yt
+ }, st) : U || (Xt = ((Wt) => _util.isNodeJS ? new _displayNode_stream.PDFNodeStream(Wt) : (0, _display_utils.isValidFetchUrl)(Wt.url) ? new _displayFetch_stream.PDFFetchStream(Wt) : new _displayNetwork.PDFNetworkStream(Wt))({
+ url: m,
+ length: Bt,
+ httpHeaders: z,
+ withCredentials: E,
+ rangeChunkSize: at,
+ disableRange: ct,
+ disableStream: yt
+ })), Ht(Xt);
+ });
+ return Promise.all([jt, Gt]).then(function([Ht, Xt]) {
+ if (r.destroyed)
+ throw new Error("Loading aborted");
+ const Vt = new _message_handler.MessageHandler(T, Ht, H.port), Wt = new WorkerTransport(Vt, r, Xt, Ct, ht);
+ r._transport = Wt, Vt.send("Ready", null);
+ });
+ }).catch(r._capability.reject), r;
+ }
+ async function _fetchDocument(p, r) {
+ if (p.destroyed)
+ throw new Error("Worker was destroyed");
+ const T = await p.messageHandler.sendWithPromise("GetDocRequest", r, r.data ? [r.data.buffer] : null);
+ if (p.destroyed)
+ throw new Error("Worker was destroyed");
+ return T;
+ }
+ function getUrlProp(p) {
+ if (p instanceof URL)
+ return p.href;
+ try {
+ return new URL(p, window.location).href;
+ } catch {
+ if (_util.isNodeJS && typeof p == "string")
+ return p;
+ }
+ throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.");
+ }
+ function getDataProp(p) {
+ if (_util.isNodeJS && typeof Buffer < "u" && p instanceof Buffer)
+ throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");
+ if (p instanceof Uint8Array && p.byteLength === p.buffer.byteLength)
+ return p;
+ if (typeof p == "string")
+ return (0, _util.stringToBytes)(p);
+ if (typeof p == "object" && !isNaN(p == null ? void 0 : p.length) || (0, _util.isArrayBuffer)(p))
+ return new Uint8Array(p);
+ throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.");
+ }
+ const d = class d {
+ constructor() {
+ this._capability = new _util.PromiseCapability(), this._transport = null, this._worker = null, this.docId = `d${ge(d, dt)._++}`, this.destroyed = !1, this.onPassword = null, this.onProgress = null;
+ }
+ get promise() {
+ return this._capability.promise;
+ }
+ async destroy() {
+ var r, T, m;
+ this.destroyed = !0;
+ try {
+ (r = this._worker) != null && r.port && (this._worker._pendingDestroy = !0), await ((T = this._transport) == null ? void 0 : T.destroy());
+ } catch (U) {
+ throw (m = this._worker) != null && m.port && delete this._worker._pendingDestroy, U;
+ }
+ this._transport = null, this._worker && (this._worker.destroy(), this._worker = null);
+ }
+ };
+ dt = new WeakMap(), L(d, dt, 0);
+ let PDFDocumentLoadingTask = d;
+ exports.PDFDocumentLoadingTask = PDFDocumentLoadingTask;
+ class PDFDataRangeTransport {
+ constructor(r, T, m = !1, U = null) {
+ this.length = r, this.initialData = T, this.progressiveDone = m, this.contentDispositionFilename = U, this._rangeListeners = [], this._progressListeners = [], this._progressiveReadListeners = [], this._progressiveDoneListeners = [], this._readyCapability = new _util.PromiseCapability();
+ }
+ addRangeListener(r) {
+ this._rangeListeners.push(r);
+ }
+ addProgressListener(r) {
+ this._progressListeners.push(r);
+ }
+ addProgressiveReadListener(r) {
+ this._progressiveReadListeners.push(r);
+ }
+ addProgressiveDoneListener(r) {
+ this._progressiveDoneListeners.push(r);
+ }
+ onDataRange(r, T) {
+ for (const m of this._rangeListeners)
+ m(r, T);
+ }
+ onDataProgress(r, T) {
+ this._readyCapability.promise.then(() => {
+ for (const m of this._progressListeners)
+ m(r, T);
+ });
+ }
+ onDataProgressiveRead(r) {
+ this._readyCapability.promise.then(() => {
+ for (const T of this._progressiveReadListeners)
+ T(r);
+ });
+ }
+ onDataProgressiveDone() {
+ this._readyCapability.promise.then(() => {
+ for (const r of this._progressiveDoneListeners)
+ r();
+ });
+ }
+ transportReady() {
+ this._readyCapability.resolve();
+ }
+ requestDataRange(r, T) {
+ (0, _util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange");
+ }
+ abort() {
+ }
+ }
+ exports.PDFDataRangeTransport = PDFDataRangeTransport;
+ class PDFDocumentProxy {
+ constructor(r, T) {
+ this._pdfInfo = r, this._transport = T, Object.defineProperty(this, "getJavaScript", {
+ value: () => ((0, _display_utils.deprecated)("`PDFDocumentProxy.getJavaScript`, please use `PDFDocumentProxy.getJSActions` instead."), this.getJSActions().then((m) => {
+ if (!m)
+ return m;
+ const U = [];
+ for (const z in m)
+ U.push(...m[z]);
+ return U;
+ }))
+ });
+ }
+ get annotationStorage() {
+ return this._transport.annotationStorage;
+ }
+ get filterFactory() {
+ return this._transport.filterFactory;
+ }
+ get numPages() {
+ return this._pdfInfo.numPages;
+ }
+ get fingerprints() {
+ return this._pdfInfo.fingerprints;
+ }
+ get isPureXfa() {
+ return (0, _util.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
+ }
+ get allXfaHtml() {
+ return this._transport._htmlForXfa;
+ }
+ getPage(r) {
+ return this._transport.getPage(r);
+ }
+ getPageIndex(r) {
+ return this._transport.getPageIndex(r);
+ }
+ getDestinations() {
+ return this._transport.getDestinations();
+ }
+ getDestination(r) {
+ return this._transport.getDestination(r);
+ }
+ getPageLabels() {
+ return this._transport.getPageLabels();
+ }
+ getPageLayout() {
+ return this._transport.getPageLayout();
+ }
+ getPageMode() {
+ return this._transport.getPageMode();
+ }
+ getViewerPreferences() {
+ return this._transport.getViewerPreferences();
+ }
+ getOpenAction() {
+ return this._transport.getOpenAction();
+ }
+ getAttachments() {
+ return this._transport.getAttachments();
+ }
+ getJSActions() {
+ return this._transport.getDocJSActions();
+ }
+ getOutline() {
+ return this._transport.getOutline();
+ }
+ getOptionalContentConfig() {
+ return this._transport.getOptionalContentConfig();
+ }
+ getPermissions() {
+ return this._transport.getPermissions();
+ }
+ getMetadata() {
+ return this._transport.getMetadata();
+ }
+ getMarkInfo() {
+ return this._transport.getMarkInfo();
+ }
+ getData() {
+ return this._transport.getData();
+ }
+ saveDocument() {
+ return this._transport.saveDocument();
+ }
+ getDownloadInfo() {
+ return this._transport.downloadInfoCapability.promise;
+ }
+ cleanup(r = !1) {
+ return this._transport.startCleanup(r || this.isPureXfa);
+ }
+ destroy() {
+ return this.loadingTask.destroy();
+ }
+ get loadingParams() {
+ return this._transport.loadingParams;
+ }
+ get loadingTask() {
+ return this._transport.loadingTask;
+ }
+ getFieldObjects() {
+ return this._transport.getFieldObjects();
+ }
+ hasJSActions() {
+ return this._transport.hasJSActions();
+ }
+ getCalculationOrderIds() {
+ return this._transport.getCalculationOrderIds();
+ }
+ }
+ exports.PDFDocumentProxy = PDFDocumentProxy;
+ class PDFPageProxy {
+ constructor(r, T, m, U = !1) {
+ L(this, P);
+ L(this, X);
+ L(this, et, null);
+ L(this, l, !1);
+ this._pageIndex = r, this._pageInfo = T, this._transport = m, this._stats = U ? new _display_utils.StatTimer() : null, this._pdfBug = U, this.commonObjs = m.commonObjs, this.objs = new PDFObjects(), this._maybeCleanupAfterRender = !1, this._intentStates = /* @__PURE__ */ new Map(), this.destroyed = !1;
+ }
+ get pageNumber() {
+ return this._pageIndex + 1;
+ }
+ get rotate() {
+ return this._pageInfo.rotate;
+ }
+ get ref() {
+ return this._pageInfo.ref;
+ }
+ get userUnit() {
+ return this._pageInfo.userUnit;
+ }
+ get view() {
+ return this._pageInfo.view;
+ }
+ getViewport({
+ scale: r,
+ rotation: T = this.rotate,
+ offsetX: m = 0,
+ offsetY: U = 0,
+ dontFlip: z = !1
+ } = {}) {
+ return new _display_utils.PageViewport({
+ viewBox: this.view,
+ scale: r,
+ rotation: T,
+ offsetX: m,
+ offsetY: U,
+ dontFlip: z
+ });
+ }
+ getAnnotations({
+ intent: r = "display"
+ } = {}) {
+ const T = this._transport.getRenderingIntent(r);
+ return this._transport.getAnnotations(this._pageIndex, T.renderingIntent);
+ }
+ getJSActions() {
+ return this._transport.getPageJSActions(this._pageIndex);
+ }
+ get filterFactory() {
+ return this._transport.filterFactory;
+ }
+ get isPureXfa() {
+ return (0, _util.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
+ }
+ async getXfa() {
+ var r;
+ return ((r = this._transport._htmlForXfa) == null ? void 0 : r.children[this._pageIndex]) || null;
+ }
+ render({
+ canvasContext: r,
+ viewport: T,
+ intent: m = "display",
+ annotationMode: U = _util.AnnotationMode.ENABLE,
+ transform: z = null,
+ background: E = null,
+ optionalContentConfigPromise: V = null,
+ annotationCanvasMap: st = null,
+ pageColors: at = null,
+ printAnnotationStorage: H = null
+ }) {
+ var n, s;
+ (n = this._stats) == null || n.time("Overall");
+ const lt = this._transport.getRenderingIntent(m, U, H);
+ Z(this, l, !1), W(this, X, Ee).call(this), V || (V = this._transport.getOptionalContentConfig());
+ let gt = this._intentStates.get(lt.cacheKey);
+ gt || (gt = /* @__PURE__ */ Object.create(null), this._intentStates.set(lt.cacheKey, gt)), gt.streamReaderCancelTimeout && (clearTimeout(gt.streamReaderCancelTimeout), gt.streamReaderCancelTimeout = null);
+ const wt = !!(lt.renderingIntent & _util.RenderingIntentFlag.PRINT);
+ gt.displayReadyCapability || (gt.displayReadyCapability = new _util.PromiseCapability(), gt.operatorList = {
+ fnArray: [],
+ argsArray: [],
+ lastChunk: !1,
+ separateAnnots: null
+ }, (s = this._stats) == null || s.time("Page Request"), this._pumpOperatorList(lt));
+ const xt = (o) => {
+ var h, b;
+ gt.renderTasks.delete(S), (this._maybeCleanupAfterRender || wt) && Z(this, l, !0), W(this, P, he).call(this, !wt), o ? (S.capability.reject(o), this._abortOperatorList({
+ intentState: gt,
+ reason: o instanceof Error ? o : new Error(o)
+ })) : S.capability.resolve(), (h = this._stats) == null || h.timeEnd("Rendering"), (b = this._stats) == null || b.timeEnd("Overall");
+ }, S = new InternalRenderTask({
+ callback: xt,
+ params: {
+ canvasContext: r,
+ viewport: T,
+ transform: z,
+ background: E
+ },
+ objs: this.objs,
+ commonObjs: this.commonObjs,
+ annotationCanvasMap: st,
+ operatorList: gt.operatorList,
+ pageIndex: this._pageIndex,
+ canvasFactory: this._transport.canvasFactory,
+ filterFactory: this._transport.filterFactory,
+ useRequestAnimationFrame: !wt,
+ pdfBug: this._pdfBug,
+ pageColors: at
+ });
+ (gt.renderTasks || (gt.renderTasks = /* @__PURE__ */ new Set())).add(S);
+ const i = S.task;
+ return Promise.all([gt.displayReadyCapability.promise, V]).then(([o, h]) => {
+ var b;
+ if (this.destroyed) {
+ xt();
+ return;
+ }
+ (b = this._stats) == null || b.time("Rendering"), S.initializeGraphics({
+ transparency: o,
+ optionalContentConfig: h
+ }), S.operatorListChanged();
+ }).catch(xt), i;
+ }
+ getOperatorList({
+ intent: r = "display",
+ annotationMode: T = _util.AnnotationMode.ENABLE,
+ printAnnotationStorage: m = null
+ } = {}) {
+ var st;
+ function U() {
+ E.operatorList.lastChunk && (E.opListReadCapability.resolve(E.operatorList), E.renderTasks.delete(V));
+ }
+ const z = this._transport.getRenderingIntent(r, T, m, !0);
+ let E = this._intentStates.get(z.cacheKey);
+ E || (E = /* @__PURE__ */ Object.create(null), this._intentStates.set(z.cacheKey, E));
+ let V;
+ return E.opListReadCapability || (V = /* @__PURE__ */ Object.create(null), V.operatorListChanged = U, E.opListReadCapability = new _util.PromiseCapability(), (E.renderTasks || (E.renderTasks = /* @__PURE__ */ new Set())).add(V), E.operatorList = {
+ fnArray: [],
+ argsArray: [],
+ lastChunk: !1,
+ separateAnnots: null
+ }, (st = this._stats) == null || st.time("Page Request"), this._pumpOperatorList(z)), E.opListReadCapability.promise;
+ }
+ streamTextContent({
+ includeMarkedContent: r = !1,
+ disableNormalization: T = !1
+ } = {}) {
+ return this._transport.messageHandler.sendWithStream("GetTextContent", {
+ pageIndex: this._pageIndex,
+ includeMarkedContent: r === !0,
+ disableNormalization: T === !0
+ }, {
+ highWaterMark: 100,
+ size(U) {
+ return U.items.length;
+ }
+ });
+ }
+ getTextContent(r = {}) {
+ if (this._transport._htmlForXfa)
+ return this.getXfa().then((m) => _xfa_text.XfaText.textContent(m));
+ const T = this.streamTextContent(r);
+ return new Promise(function(m, U) {
+ function z() {
+ E.read().then(function({
+ value: st,
+ done: at
+ }) {
+ if (at) {
+ m(V);
+ return;
+ }
+ Object.assign(V.styles, st.styles), V.items.push(...st.items), z();
+ }, U);
+ }
+ const E = T.getReader(), V = {
+ items: [],
+ styles: /* @__PURE__ */ Object.create(null)
+ };
+ z();
+ });
+ }
+ getStructTree() {
+ return this._transport.getStructTree(this._pageIndex);
+ }
+ _destroy() {
+ this.destroyed = !0;
+ const r = [];
+ for (const T of this._intentStates.values())
+ if (this._abortOperatorList({
+ intentState: T,
+ reason: new Error("Page was destroyed."),
+ force: !0
+ }), !T.opListReadCapability)
+ for (const m of T.renderTasks)
+ r.push(m.completed), m.cancel();
+ return this.objs.clear(), Z(this, l, !1), W(this, X, Ee).call(this), Promise.all(r);
+ }
+ cleanup(r = !1) {
+ Z(this, l, !0);
+ const T = W(this, P, he).call(this, !1);
+ return r && T && this._stats && (this._stats = new _display_utils.StatTimer()), T;
+ }
+ _startRenderPage(r, T) {
+ var U, z;
+ const m = this._intentStates.get(T);
+ m && ((U = this._stats) == null || U.timeEnd("Page Request"), (z = m.displayReadyCapability) == null || z.resolve(r));
+ }
+ _renderPageChunk(r, T) {
+ for (let m = 0, U = r.length; m < U; m++)
+ T.operatorList.fnArray.push(r.fnArray[m]), T.operatorList.argsArray.push(r.argsArray[m]);
+ T.operatorList.lastChunk = r.lastChunk, T.operatorList.separateAnnots = r.separateAnnots;
+ for (const m of T.renderTasks)
+ m.operatorListChanged();
+ r.lastChunk && W(this, P, he).call(this, !0);
+ }
+ _pumpOperatorList({
+ renderingIntent: r,
+ cacheKey: T,
+ annotationStorageSerializable: m
+ }) {
+ const {
+ map: U,
+ transfers: z
+ } = m, V = this._transport.messageHandler.sendWithStream("GetOperatorList", {
+ pageIndex: this._pageIndex,
+ intent: r,
+ cacheKey: T,
+ annotationStorage: U
+ }, z).getReader(), st = this._intentStates.get(T);
+ st.streamReader = V;
+ const at = () => {
+ V.read().then(({
+ value: H,
+ done: lt
+ }) => {
+ if (lt) {
+ st.streamReader = null;
+ return;
+ }
+ this._transport.destroyed || (this._renderPageChunk(H, st), at());
+ }, (H) => {
+ if (st.streamReader = null, !this._transport.destroyed) {
+ if (st.operatorList) {
+ st.operatorList.lastChunk = !0;
+ for (const lt of st.renderTasks)
+ lt.operatorListChanged();
+ W(this, P, he).call(this, !0);
+ }
+ if (st.displayReadyCapability)
+ st.displayReadyCapability.reject(H);
+ else if (st.opListReadCapability)
+ st.opListReadCapability.reject(H);
+ else
+ throw H;
+ }
+ });
+ };
+ at();
+ }
+ _abortOperatorList({
+ intentState: r,
+ reason: T,
+ force: m = !1
+ }) {
+ if (r.streamReader) {
+ if (r.streamReaderCancelTimeout && (clearTimeout(r.streamReaderCancelTimeout), r.streamReaderCancelTimeout = null), !m) {
+ if (r.renderTasks.size > 0)
+ return;
+ if (T instanceof _display_utils.RenderingCancelledException) {
+ let U = RENDERING_CANCELLED_TIMEOUT;
+ T.extraDelay > 0 && T.extraDelay < 1e3 && (U += T.extraDelay), r.streamReaderCancelTimeout = setTimeout(() => {
+ r.streamReaderCancelTimeout = null, this._abortOperatorList({
+ intentState: r,
+ reason: T,
+ force: !0
+ });
+ }, U);
+ return;
+ }
+ }
+ if (r.streamReader.cancel(new _util.AbortException(T.message)).catch(() => {
+ }), r.streamReader = null, !this._transport.destroyed) {
+ for (const [U, z] of this._intentStates)
+ if (z === r) {
+ this._intentStates.delete(U);
+ break;
+ }
+ this.cleanup();
+ }
+ }
+ }
+ get stats() {
+ return this._stats;
+ }
+ }
+ et = new WeakMap(), l = new WeakMap(), P = new WeakSet(), he = function(r = !1) {
+ if (W(this, X, Ee).call(this), !t(this, l) || this.destroyed)
+ return !1;
+ if (r)
+ return Z(this, et, setTimeout(() => {
+ Z(this, et, null), W(this, P, he).call(this, !1);
+ }, DELAYED_CLEANUP_TIMEOUT)), !1;
+ for (const {
+ renderTasks: T,
+ operatorList: m
+ } of this._intentStates.values())
+ if (T.size > 0 || !m.lastChunk)
+ return !1;
+ return this._intentStates.clear(), this.objs.clear(), Z(this, l, !1), !0;
+ }, X = new WeakSet(), Ee = function() {
+ t(this, et) && (clearTimeout(t(this, et)), Z(this, et, null));
+ }, exports.PDFPageProxy = PDFPageProxy;
+ class LoopbackPort {
+ constructor() {
+ L(this, B, /* @__PURE__ */ new Set());
+ L(this, F, Promise.resolve());
+ }
+ postMessage(r, T) {
+ const m = {
+ data: structuredClone(r, T ? {
+ transfer: T
+ } : null)
+ };
+ t(this, F).then(() => {
+ for (const U of t(this, B))
+ U.call(this, m);
+ });
+ }
+ addEventListener(r, T) {
+ t(this, B).add(T);
+ }
+ removeEventListener(r, T) {
+ t(this, B).delete(T);
+ }
+ terminate() {
+ t(this, B).clear();
+ }
+ }
+ B = new WeakMap(), F = new WeakMap(), exports.LoopbackPort = LoopbackPort;
+ const PDFWorkerUtil = {
+ isWorkerDisabled: !1,
+ fallbackWorkerSrc: null,
+ fakeWorkerId: 0
+ };
+ exports.PDFWorkerUtil = PDFWorkerUtil;
+ {
+ if (_util.isNodeJS && typeof commonjsRequire == "function")
+ PDFWorkerUtil.isWorkerDisabled = !0, PDFWorkerUtil.fallbackWorkerSrc = "./pdf.worker.js";
+ else if (typeof document == "object") {
+ const p = (g = document == null ? void 0 : document.currentScript) == null ? void 0 : g.src;
+ p && (PDFWorkerUtil.fallbackWorkerSrc = p.replace(/(\.(?:min\.)?js)(\?.*)?$/i, ".worker$1$2"));
+ }
+ PDFWorkerUtil.isSameOrigin = function(p, r) {
+ let T;
+ try {
+ if (T = new URL(p), !T.origin || T.origin === "null")
+ return !1;
+ } catch {
+ return !1;
+ }
+ const m = new URL(r, T);
+ return T.origin === m.origin;
+ }, PDFWorkerUtil.createCDNWrapper = function(p) {
+ const r = `importScripts("${p}");`;
+ return URL.createObjectURL(new Blob([r]));
+ };
+ }
+ const _PDFWorker = class _PDFWorker {
+ constructor({
+ name: p = null,
+ port: r = null,
+ verbosity: T = (0, _util.getVerbosityLevel)()
+ } = {}) {
+ var m;
+ if (this.name = p, this.destroyed = !1, this.verbosity = T, this._readyCapability = new _util.PromiseCapability(), this._port = null, this._webWorker = null, this._messageHandler = null, r) {
+ if ((m = t(_PDFWorker, O)) != null && m.has(r))
+ throw new Error("Cannot use more than one PDFWorker per port.");
+ (t(_PDFWorker, O) || Z(_PDFWorker, O, /* @__PURE__ */ new WeakMap())).set(r, this), this._initializeFromPort(r);
+ return;
+ }
+ this._initialize();
+ }
+ get promise() {
+ return this._readyCapability.promise;
+ }
+ get port() {
+ return this._port;
+ }
+ get messageHandler() {
+ return this._messageHandler;
+ }
+ _initializeFromPort(p) {
+ this._port = p, this._messageHandler = new _message_handler.MessageHandler("main", "worker", p), this._messageHandler.on("ready", function() {
+ }), this._readyCapability.resolve(), this._messageHandler.send("configure", {
+ verbosity: this.verbosity
+ });
+ }
+ _initialize() {
+ if (!PDFWorkerUtil.isWorkerDisabled && !_PDFWorker._mainThreadWorkerMessageHandler) {
+ let {
+ workerSrc: p
+ } = _PDFWorker;
+ try {
+ PDFWorkerUtil.isSameOrigin(window.location.href, p) || (p = PDFWorkerUtil.createCDNWrapper(new URL(p, window.location).href));
+ const r = new Worker(p), T = new _message_handler.MessageHandler("main", "worker", r), m = () => {
+ r.removeEventListener("error", U), T.destroy(), r.terminate(), this.destroyed ? this._readyCapability.reject(new Error("Worker was destroyed")) : this._setupFakeWorker();
+ }, U = () => {
+ this._webWorker || m();
+ };
+ r.addEventListener("error", U), T.on("test", (E) => {
+ if (r.removeEventListener("error", U), this.destroyed) {
+ m();
+ return;
+ }
+ E ? (this._messageHandler = T, this._port = r, this._webWorker = r, this._readyCapability.resolve(), T.send("configure", {
+ verbosity: this.verbosity
+ })) : (this._setupFakeWorker(), T.destroy(), r.terminate());
+ }), T.on("ready", (E) => {
+ if (r.removeEventListener("error", U), this.destroyed) {
+ m();
+ return;
+ }
+ try {
+ z();
+ } catch {
+ this._setupFakeWorker();
+ }
+ });
+ const z = () => {
+ const E = new Uint8Array();
+ T.send("test", E, [E.buffer]);
+ };
+ z();
+ return;
+ } catch {
+ (0, _util.info)("The worker has been disabled.");
+ }
+ }
+ this._setupFakeWorker();
+ }
+ _setupFakeWorker() {
+ PDFWorkerUtil.isWorkerDisabled || ((0, _util.warn)("Setting up fake worker."), PDFWorkerUtil.isWorkerDisabled = !0), _PDFWorker._setupFakeWorkerGlobal.then((p) => {
+ if (this.destroyed) {
+ this._readyCapability.reject(new Error("Worker was destroyed"));
+ return;
+ }
+ const r = new LoopbackPort();
+ this._port = r;
+ const T = `fake${PDFWorkerUtil.fakeWorkerId++}`, m = new _message_handler.MessageHandler(T + "_worker", T, r);
+ p.setup(m, r);
+ const U = new _message_handler.MessageHandler(T, T + "_worker", r);
+ this._messageHandler = U, this._readyCapability.resolve(), U.send("configure", {
+ verbosity: this.verbosity
+ });
+ }).catch((p) => {
+ this._readyCapability.reject(new Error(`Setting up fake worker failed: "${p.message}".`));
+ });
+ }
+ destroy() {
+ var p;
+ this.destroyed = !0, this._webWorker && (this._webWorker.terminate(), this._webWorker = null), (p = t(_PDFWorker, O)) == null || p.delete(this._port), this._port = null, this._messageHandler && (this._messageHandler.destroy(), this._messageHandler = null);
+ }
+ static fromPort(p) {
+ var T;
+ if (!(p != null && p.port))
+ throw new Error("PDFWorker.fromPort - invalid method signature.");
+ const r = (T = t(this, O)) == null ? void 0 : T.get(p.port);
+ if (r) {
+ if (r._pendingDestroy)
+ throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");
+ return r;
+ }
+ return new _PDFWorker(p);
+ }
+ static get workerSrc() {
+ if (_worker_options.GlobalWorkerOptions.workerSrc)
+ return _worker_options.GlobalWorkerOptions.workerSrc;
+ if (PDFWorkerUtil.fallbackWorkerSrc !== null)
+ return _util.isNodeJS || (0, _display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'), PDFWorkerUtil.fallbackWorkerSrc;
+ throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
+ }
+ static get _mainThreadWorkerMessageHandler() {
+ var p;
+ try {
+ return ((p = globalThis.pdfjsWorker) == null ? void 0 : p.WorkerMessageHandler) || null;
+ } catch {
+ return null;
+ }
+ }
+ static get _setupFakeWorkerGlobal() {
+ const loader = async () => {
+ const mainWorkerMessageHandler = this._mainThreadWorkerMessageHandler;
+ if (mainWorkerMessageHandler)
+ return mainWorkerMessageHandler;
+ if (_util.isNodeJS && typeof commonjsRequire == "function") {
+ const worker = eval("require")(this.workerSrc);
+ return worker.WorkerMessageHandler;
+ }
+ return await (0, _display_utils.loadScript)(this.workerSrc), window.pdfjsWorker.WorkerMessageHandler;
+ };
+ return (0, _util.shadow)(this, "_setupFakeWorkerGlobal", loader());
+ }
+ };
+ O = new WeakMap(), L(_PDFWorker, O, void 0);
+ let PDFWorker = _PDFWorker;
+ exports.PDFWorker = PDFWorker;
+ class WorkerTransport {
+ constructor(r, T, m, U, z) {
+ L(this, u);
+ L(this, I, /* @__PURE__ */ new Map());
+ L(this, x, /* @__PURE__ */ new Map());
+ L(this, v, /* @__PURE__ */ new Map());
+ L(this, A, null);
+ this.messageHandler = r, this.loadingTask = T, this.commonObjs = new PDFObjects(), this.fontLoader = new _font_loader.FontLoader({
+ ownerDocument: U.ownerDocument,
+ styleElement: U.styleElement
+ }), this._params = U, this.canvasFactory = z.canvasFactory, this.filterFactory = z.filterFactory, this.cMapReaderFactory = z.cMapReaderFactory, this.standardFontDataFactory = z.standardFontDataFactory, this.destroyed = !1, this.destroyCapability = null, this._networkStream = m, this._fullReader = null, this._lastProgress = null, this.downloadInfoCapability = new _util.PromiseCapability(), this.setupMessageHandler();
+ }
+ get annotationStorage() {
+ return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
+ }
+ getRenderingIntent(r, T = _util.AnnotationMode.ENABLE, m = null, U = !1) {
+ let z = _util.RenderingIntentFlag.DISPLAY, E = _annotation_storage.SerializableEmpty;
+ switch (r) {
+ case "any":
+ z = _util.RenderingIntentFlag.ANY;
+ break;
+ case "display":
+ break;
+ case "print":
+ z = _util.RenderingIntentFlag.PRINT;
+ break;
+ default:
+ (0, _util.warn)(`getRenderingIntent - invalid intent: ${r}`);
+ }
+ switch (T) {
+ case _util.AnnotationMode.DISABLE:
+ z += _util.RenderingIntentFlag.ANNOTATIONS_DISABLE;
+ break;
+ case _util.AnnotationMode.ENABLE:
+ break;
+ case _util.AnnotationMode.ENABLE_FORMS:
+ z += _util.RenderingIntentFlag.ANNOTATIONS_FORMS;
+ break;
+ case _util.AnnotationMode.ENABLE_STORAGE:
+ z += _util.RenderingIntentFlag.ANNOTATIONS_STORAGE, E = (z & _util.RenderingIntentFlag.PRINT && m instanceof _annotation_storage.PrintAnnotationStorage ? m : this.annotationStorage).serializable;
+ break;
+ default:
+ (0, _util.warn)(`getRenderingIntent - invalid annotationMode: ${T}`);
+ }
+ return U && (z += _util.RenderingIntentFlag.OPLIST), {
+ renderingIntent: z,
+ cacheKey: `${z}_${E.hash}`,
+ annotationStorageSerializable: E
+ };
+ }
+ destroy() {
+ var m;
+ if (this.destroyCapability)
+ return this.destroyCapability.promise;
+ this.destroyed = !0, this.destroyCapability = new _util.PromiseCapability(), (m = t(this, A)) == null || m.reject(new Error("Worker was destroyed during onPassword callback"));
+ const r = [];
+ for (const U of t(this, x).values())
+ r.push(U._destroy());
+ t(this, x).clear(), t(this, v).clear(), this.hasOwnProperty("annotationStorage") && this.annotationStorage.resetModified();
+ const T = this.messageHandler.sendWithPromise("Terminate", null);
+ return r.push(T), Promise.all(r).then(() => {
+ var U;
+ this.commonObjs.clear(), this.fontLoader.clear(), t(this, I).clear(), this.filterFactory.destroy(), (U = this._networkStream) == null || U.cancelAllRequests(new _util.AbortException("Worker was terminated.")), this.messageHandler && (this.messageHandler.destroy(), this.messageHandler = null), this.destroyCapability.resolve();
+ }, this.destroyCapability.reject), this.destroyCapability.promise;
+ }
+ setupMessageHandler() {
+ const {
+ messageHandler: r,
+ loadingTask: T
+ } = this;
+ r.on("GetReader", (m, U) => {
+ (0, _util.assert)(this._networkStream, "GetReader - no `IPDFStream` instance available."), this._fullReader = this._networkStream.getFullReader(), this._fullReader.onProgress = (z) => {
+ this._lastProgress = {
+ loaded: z.loaded,
+ total: z.total
+ };
+ }, U.onPull = () => {
+ this._fullReader.read().then(function({
+ value: z,
+ done: E
+ }) {
+ if (E) {
+ U.close();
+ return;
+ }
+ (0, _util.assert)(z instanceof ArrayBuffer, "GetReader - expected an ArrayBuffer."), U.enqueue(new Uint8Array(z), 1, [z]);
+ }).catch((z) => {
+ U.error(z);
+ });
+ }, U.onCancel = (z) => {
+ this._fullReader.cancel(z), U.ready.catch((E) => {
+ if (!this.destroyed)
+ throw E;
+ });
+ };
+ }), r.on("ReaderHeadersReady", (m) => {
+ const U = new _util.PromiseCapability(), z = this._fullReader;
+ return z.headersReady.then(() => {
+ var E;
+ (!z.isStreamingSupported || !z.isRangeSupported) && (this._lastProgress && ((E = T.onProgress) == null || E.call(T, this._lastProgress)), z.onProgress = (V) => {
+ var st;
+ (st = T.onProgress) == null || st.call(T, {
+ loaded: V.loaded,
+ total: V.total
+ });
+ }), U.resolve({
+ isStreamingSupported: z.isStreamingSupported,
+ isRangeSupported: z.isRangeSupported,
+ contentLength: z.contentLength
+ });
+ }, U.reject), U.promise;
+ }), r.on("GetRangeReader", (m, U) => {
+ (0, _util.assert)(this._networkStream, "GetRangeReader - no `IPDFStream` instance available.");
+ const z = this._networkStream.getRangeReader(m.begin, m.end);
+ if (!z) {
+ U.close();
+ return;
+ }
+ U.onPull = () => {
+ z.read().then(function({
+ value: E,
+ done: V
+ }) {
+ if (V) {
+ U.close();
+ return;
+ }
+ (0, _util.assert)(E instanceof ArrayBuffer, "GetRangeReader - expected an ArrayBuffer."), U.enqueue(new Uint8Array(E), 1, [E]);
+ }).catch((E) => {
+ U.error(E);
+ });
+ }, U.onCancel = (E) => {
+ z.cancel(E), U.ready.catch((V) => {
+ if (!this.destroyed)
+ throw V;
+ });
+ };
+ }), r.on("GetDoc", ({
+ pdfInfo: m
+ }) => {
+ this._numPages = m.numPages, this._htmlForXfa = m.htmlForXfa, delete m.htmlForXfa, T._capability.resolve(new PDFDocumentProxy(m, this));
+ }), r.on("DocException", function(m) {
+ let U;
+ switch (m.name) {
+ case "PasswordException":
+ U = new _util.PasswordException(m.message, m.code);
+ break;
+ case "InvalidPDFException":
+ U = new _util.InvalidPDFException(m.message);
+ break;
+ case "MissingPDFException":
+ U = new _util.MissingPDFException(m.message);
+ break;
+ case "UnexpectedResponseException":
+ U = new _util.UnexpectedResponseException(m.message, m.status);
+ break;
+ case "UnknownErrorException":
+ U = new _util.UnknownErrorException(m.message, m.details);
+ break;
+ default:
+ (0, _util.unreachable)("DocException - expected a valid Error.");
+ }
+ T._capability.reject(U);
+ }), r.on("PasswordRequest", (m) => {
+ if (Z(this, A, new _util.PromiseCapability()), T.onPassword) {
+ const U = (z) => {
+ z instanceof Error ? t(this, A).reject(z) : t(this, A).resolve({
+ password: z
+ });
+ };
+ try {
+ T.onPassword(U, m.code);
+ } catch (z) {
+ t(this, A).reject(z);
+ }
+ } else
+ t(this, A).reject(new _util.PasswordException(m.message, m.code));
+ return t(this, A).promise;
+ }), r.on("DataLoaded", (m) => {
+ var U;
+ (U = T.onProgress) == null || U.call(T, {
+ loaded: m.length,
+ total: m.length
+ }), this.downloadInfoCapability.resolve(m);
+ }), r.on("StartRenderPage", (m) => {
+ if (this.destroyed)
+ return;
+ t(this, x).get(m.pageIndex)._startRenderPage(m.transparency, m.cacheKey);
+ }), r.on("commonobj", ([m, U, z]) => {
+ var E;
+ if (!this.destroyed && !this.commonObjs.has(m))
+ switch (U) {
+ case "Font":
+ const V = this._params;
+ if ("error" in z) {
+ const H = z.error;
+ (0, _util.warn)(`Error during font loading: ${H}`), this.commonObjs.resolve(m, H);
+ break;
+ }
+ const st = V.pdfBug && ((E = globalThis.FontInspector) != null && E.enabled) ? (H, lt) => globalThis.FontInspector.fontAdded(H, lt) : null, at = new _font_loader.FontFaceObject(z, {
+ isEvalSupported: V.isEvalSupported,
+ disableFontFace: V.disableFontFace,
+ ignoreErrors: V.ignoreErrors,
+ inspectFont: st
+ });
+ this.fontLoader.bind(at).catch((H) => r.sendWithPromise("FontFallback", {
+ id: m
+ })).finally(() => {
+ !V.fontExtraProperties && at.data && (at.data = null), this.commonObjs.resolve(m, at);
+ });
+ break;
+ case "FontPath":
+ case "Image":
+ case "Pattern":
+ this.commonObjs.resolve(m, z);
+ break;
+ default:
+ throw new Error(`Got unknown common object type ${U}`);
+ }
+ }), r.on("obj", ([m, U, z, E]) => {
+ var st;
+ if (this.destroyed)
+ return;
+ const V = t(this, x).get(U);
+ if (!V.objs.has(m))
+ switch (z) {
+ case "Image":
+ if (V.objs.resolve(m, E), E) {
+ let at;
+ if (E.bitmap) {
+ const {
+ width: H,
+ height: lt
+ } = E;
+ at = H * lt * 4;
+ } else
+ at = ((st = E.data) == null ? void 0 : st.length) || 0;
+ at > _util.MAX_IMAGE_SIZE_TO_CACHE && (V._maybeCleanupAfterRender = !0);
+ }
+ break;
+ case "Pattern":
+ V.objs.resolve(m, E);
+ break;
+ default:
+ throw new Error(`Got unknown object type ${z}`);
+ }
+ }), r.on("DocProgress", (m) => {
+ var U;
+ this.destroyed || (U = T.onProgress) == null || U.call(T, {
+ loaded: m.loaded,
+ total: m.total
+ });
+ }), r.on("FetchBuiltInCMap", (m) => this.destroyed ? Promise.reject(new Error("Worker was destroyed.")) : this.cMapReaderFactory ? this.cMapReaderFactory.fetch(m) : Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))), r.on("FetchStandardFontData", (m) => this.destroyed ? Promise.reject(new Error("Worker was destroyed.")) : this.standardFontDataFactory ? this.standardFontDataFactory.fetch(m) : Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")));
+ }
+ getData() {
+ return this.messageHandler.sendWithPromise("GetData", null);
+ }
+ saveDocument() {
+ var m;
+ this.annotationStorage.size <= 0 && (0, _util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");
+ const {
+ map: r,
+ transfers: T
+ } = this.annotationStorage.serializable;
+ return this.messageHandler.sendWithPromise("SaveDocument", {
+ isPureXfa: !!this._htmlForXfa,
+ numPages: this._numPages,
+ annotationStorage: r,
+ filename: ((m = this._fullReader) == null ? void 0 : m.filename) ?? null
+ }, T).finally(() => {
+ this.annotationStorage.resetModified();
+ });
+ }
+ getPage(r) {
+ if (!Number.isInteger(r) || r <= 0 || r > this._numPages)
+ return Promise.reject(new Error("Invalid page request."));
+ const T = r - 1, m = t(this, v).get(T);
+ if (m)
+ return m;
+ const U = this.messageHandler.sendWithPromise("GetPage", {
+ pageIndex: T
+ }).then((z) => {
+ if (this.destroyed)
+ throw new Error("Transport destroyed");
+ const E = new PDFPageProxy(T, z, this, this._params.pdfBug);
+ return t(this, x).set(T, E), E;
+ });
+ return t(this, v).set(T, U), U;
+ }
+ getPageIndex(r) {
+ return typeof r != "object" || r === null || !Number.isInteger(r.num) || r.num < 0 || !Number.isInteger(r.gen) || r.gen < 0 ? Promise.reject(new Error("Invalid pageIndex request.")) : this.messageHandler.sendWithPromise("GetPageIndex", {
+ num: r.num,
+ gen: r.gen
+ });
+ }
+ getAnnotations(r, T) {
+ return this.messageHandler.sendWithPromise("GetAnnotations", {
+ pageIndex: r,
+ intent: T
+ });
+ }
+ getFieldObjects() {
+ return W(this, u, we).call(this, "GetFieldObjects");
+ }
+ hasJSActions() {
+ return W(this, u, we).call(this, "HasJSActions");
+ }
+ getCalculationOrderIds() {
+ return this.messageHandler.sendWithPromise("GetCalculationOrderIds", null);
+ }
+ getDestinations() {
+ return this.messageHandler.sendWithPromise("GetDestinations", null);
+ }
+ getDestination(r) {
+ return typeof r != "string" ? Promise.reject(new Error("Invalid destination request.")) : this.messageHandler.sendWithPromise("GetDestination", {
+ id: r
+ });
+ }
+ getPageLabels() {
+ return this.messageHandler.sendWithPromise("GetPageLabels", null);
+ }
+ getPageLayout() {
+ return this.messageHandler.sendWithPromise("GetPageLayout", null);
+ }
+ getPageMode() {
+ return this.messageHandler.sendWithPromise("GetPageMode", null);
+ }
+ getViewerPreferences() {
+ return this.messageHandler.sendWithPromise("GetViewerPreferences", null);
+ }
+ getOpenAction() {
+ return this.messageHandler.sendWithPromise("GetOpenAction", null);
+ }
+ getAttachments() {
+ return this.messageHandler.sendWithPromise("GetAttachments", null);
+ }
+ getDocJSActions() {
+ return W(this, u, we).call(this, "GetDocJSActions");
+ }
+ getPageJSActions(r) {
+ return this.messageHandler.sendWithPromise("GetPageJSActions", {
+ pageIndex: r
+ });
+ }
+ getStructTree(r) {
+ return this.messageHandler.sendWithPromise("GetStructTree", {
+ pageIndex: r
+ });
+ }
+ getOutline() {
+ return this.messageHandler.sendWithPromise("GetOutline", null);
+ }
+ getOptionalContentConfig() {
+ return this.messageHandler.sendWithPromise("GetOptionalContentConfig", null).then((r) => new _optional_content_config.OptionalContentConfig(r));
+ }
+ getPermissions() {
+ return this.messageHandler.sendWithPromise("GetPermissions", null);
+ }
+ getMetadata() {
+ const r = "GetMetadata", T = t(this, I).get(r);
+ if (T)
+ return T;
+ const m = this.messageHandler.sendWithPromise(r, null).then((U) => {
+ var z, E;
+ return {
+ info: U[0],
+ metadata: U[1] ? new _metadata.Metadata(U[1]) : null,
+ contentDispositionFilename: ((z = this._fullReader) == null ? void 0 : z.filename) ?? null,
+ contentLength: ((E = this._fullReader) == null ? void 0 : E.contentLength) ?? null
+ };
+ });
+ return t(this, I).set(r, m), m;
+ }
+ getMarkInfo() {
+ return this.messageHandler.sendWithPromise("GetMarkInfo", null);
+ }
+ async startCleanup(r = !1) {
+ if (!this.destroyed) {
+ await this.messageHandler.sendWithPromise("Cleanup", null);
+ for (const T of t(this, x).values())
+ if (!T.cleanup())
+ throw new Error(`startCleanup: Page ${T.pageNumber} is currently rendering.`);
+ this.commonObjs.clear(), r || this.fontLoader.clear(), t(this, I).clear(), this.filterFactory.destroy(!0);
+ }
+ }
+ get loadingParams() {
+ const {
+ disableAutoFetch: r,
+ enableXfa: T
+ } = this._params;
+ return (0, _util.shadow)(this, "loadingParams", {
+ disableAutoFetch: r,
+ enableXfa: T
+ });
+ }
+ }
+ I = new WeakMap(), x = new WeakMap(), v = new WeakMap(), A = new WeakMap(), u = new WeakSet(), we = function(r, T = null) {
+ const m = t(this, I).get(r);
+ if (m)
+ return m;
+ const U = this.messageHandler.sendWithPromise(r, T);
+ return t(this, I).set(r, U), U;
+ };
+ class PDFObjects {
+ constructor() {
+ L(this, C);
+ L(this, w, /* @__PURE__ */ Object.create(null));
+ }
+ get(r, T = null) {
+ if (T) {
+ const U = W(this, C, Be).call(this, r);
+ return U.capability.promise.then(() => T(U.data)), null;
+ }
+ const m = t(this, w)[r];
+ if (!(m != null && m.capability.settled))
+ throw new Error(`Requesting object that isn't resolved yet ${r}.`);
+ return m.data;
+ }
+ has(r) {
+ const T = t(this, w)[r];
+ return (T == null ? void 0 : T.capability.settled) || !1;
+ }
+ resolve(r, T = null) {
+ const m = W(this, C, Be).call(this, r);
+ m.data = T, m.capability.resolve();
+ }
+ clear() {
+ var r;
+ for (const T in t(this, w)) {
+ const {
+ data: m
+ } = t(this, w)[T];
+ (r = m == null ? void 0 : m.bitmap) == null || r.close();
+ }
+ Z(this, w, /* @__PURE__ */ Object.create(null));
+ }
+ }
+ w = new WeakMap(), C = new WeakSet(), Be = function(r) {
+ var T;
+ return (T = t(this, w))[r] || (T[r] = {
+ capability: new _util.PromiseCapability(),
+ data: null
+ });
+ };
+ class RenderTask {
+ constructor(r) {
+ L(this, a, null);
+ Z(this, a, r), this.onContinue = null;
+ }
+ get promise() {
+ return t(this, a).capability.promise;
+ }
+ cancel(r = 0) {
+ t(this, a).cancel(null, r);
+ }
+ get separateAnnots() {
+ const {
+ separateAnnots: r
+ } = t(this, a).operatorList;
+ if (!r)
+ return !1;
+ const {
+ annotationCanvasMap: T
+ } = t(this, a);
+ return r.form || r.canvas && (T == null ? void 0 : T.size) > 0;
+ }
+ }
+ a = new WeakMap(), exports.RenderTask = RenderTask;
+ const k = class k {
+ constructor({
+ callback: r,
+ params: T,
+ objs: m,
+ commonObjs: U,
+ annotationCanvasMap: z,
+ operatorList: E,
+ pageIndex: V,
+ canvasFactory: st,
+ filterFactory: at,
+ useRequestAnimationFrame: H = !1,
+ pdfBug: lt = !1,
+ pageColors: gt = null
+ }) {
+ this.callback = r, this.params = T, this.objs = m, this.commonObjs = U, this.annotationCanvasMap = z, this.operatorListIdx = null, this.operatorList = E, this._pageIndex = V, this.canvasFactory = st, this.filterFactory = at, this._pdfBug = lt, this.pageColors = gt, this.running = !1, this.graphicsReadyCallback = null, this.graphicsReady = !1, this._useRequestAnimationFrame = H === !0 && typeof window < "u", this.cancelled = !1, this.capability = new _util.PromiseCapability(), this.task = new RenderTask(this), this._cancelBound = this.cancel.bind(this), this._continueBound = this._continue.bind(this), this._scheduleNextBound = this._scheduleNext.bind(this), this._nextBound = this._next.bind(this), this._canvas = T.canvasContext.canvas;
+ }
+ get completed() {
+ return this.capability.promise.catch(function() {
+ });
+ }
+ initializeGraphics({
+ transparency: r = !1,
+ optionalContentConfig: T
+ }) {
+ var V, st;
+ if (this.cancelled)
+ return;
+ if (this._canvas) {
+ if (t(k, c).has(this._canvas))
+ throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");
+ t(k, c).add(this._canvas);
+ }
+ this._pdfBug && ((V = globalThis.StepperManager) != null && V.enabled) && (this.stepper = globalThis.StepperManager.create(this._pageIndex), this.stepper.init(this.operatorList), this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint());
+ const {
+ canvasContext: m,
+ viewport: U,
+ transform: z,
+ background: E
+ } = this.params;
+ this.gfx = new _canvas.CanvasGraphics(m, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
+ optionalContentConfig: T
+ }, this.annotationCanvasMap, this.pageColors), this.gfx.beginDrawing({
+ transform: z,
+ viewport: U,
+ transparency: r,
+ background: E
+ }), this.operatorListIdx = 0, this.graphicsReady = !0, (st = this.graphicsReadyCallback) == null || st.call(this);
+ }
+ cancel(r = null, T = 0) {
+ var m;
+ this.running = !1, this.cancelled = !0, (m = this.gfx) == null || m.endDrawing(), t(k, c).delete(this._canvas), this.callback(r || new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex + 1}`, T));
+ }
+ operatorListChanged() {
+ var r;
+ if (!this.graphicsReady) {
+ this.graphicsReadyCallback || (this.graphicsReadyCallback = this._continueBound);
+ return;
+ }
+ (r = this.stepper) == null || r.updateOperatorList(this.operatorList), !this.running && this._continue();
+ }
+ _continue() {
+ this.running = !0, !this.cancelled && (this.task.onContinue ? this.task.onContinue(this._scheduleNextBound) : this._scheduleNext());
+ }
+ _scheduleNext() {
+ this._useRequestAnimationFrame ? window.requestAnimationFrame(() => {
+ this._nextBound().catch(this._cancelBound);
+ }) : Promise.resolve().then(this._nextBound).catch(this._cancelBound);
+ }
+ async _next() {
+ this.cancelled || (this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper), this.operatorListIdx === this.operatorList.argsArray.length && (this.running = !1, this.operatorList.lastChunk && (this.gfx.endDrawing(), t(k, c).delete(this._canvas), this.callback())));
+ }
+ };
+ c = new WeakMap(), L(k, c, /* @__PURE__ */ new WeakSet());
+ let InternalRenderTask = k;
+ const version = "3.11.174";
+ exports.version = version;
+ const build = "ce8716743";
+ exports.build = build;
+ },
+ /* 3 */
+ /***/
+ (dt, d, et) => {
+ var F, g, O, Ai, x;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.SerializableEmpty = d.PrintAnnotationStorage = d.AnnotationStorage = void 0;
+ var l = et(1), P = et(4), rt = et(8);
+ const X = Object.freeze({
+ map: null,
+ hash: "",
+ transfers: void 0
+ });
+ d.SerializableEmpty = X;
+ class pt {
+ constructor() {
+ L(this, O);
+ L(this, F, !1);
+ L(this, g, /* @__PURE__ */ new Map());
+ this.onSetModified = null, this.onResetModified = null, this.onAnnotationEditor = null;
+ }
+ getValue(A, u) {
+ const _ = t(this, g).get(A);
+ return _ === void 0 ? u : Object.assign(u, _);
+ }
+ getRawValue(A) {
+ return t(this, g).get(A);
+ }
+ remove(A) {
+ if (t(this, g).delete(A), t(this, g).size === 0 && this.resetModified(), typeof this.onAnnotationEditor == "function") {
+ for (const u of t(this, g).values())
+ if (u instanceof P.AnnotationEditor)
+ return;
+ this.onAnnotationEditor(null);
+ }
+ }
+ setValue(A, u) {
+ const _ = t(this, g).get(A);
+ let w = !1;
+ if (_ !== void 0)
+ for (const [C, y] of Object.entries(u))
+ _[C] !== y && (w = !0, _[C] = y);
+ else
+ w = !0, t(this, g).set(A, u);
+ w && W(this, O, Ai).call(this), u instanceof P.AnnotationEditor && typeof this.onAnnotationEditor == "function" && this.onAnnotationEditor(u.constructor._type);
+ }
+ has(A) {
+ return t(this, g).has(A);
+ }
+ getAll() {
+ return t(this, g).size > 0 ? (0, l.objectFromMap)(t(this, g)) : null;
+ }
+ setAll(A) {
+ for (const [u, _] of Object.entries(A))
+ this.setValue(u, _);
+ }
+ get size() {
+ return t(this, g).size;
+ }
+ resetModified() {
+ t(this, F) && (Z(this, F, !1), typeof this.onResetModified == "function" && this.onResetModified());
+ }
+ get print() {
+ return new B(this);
+ }
+ get serializable() {
+ if (t(this, g).size === 0)
+ return X;
+ const A = /* @__PURE__ */ new Map(), u = new rt.MurmurHash3_64(), _ = [], w = /* @__PURE__ */ Object.create(null);
+ let C = !1;
+ for (const [y, a] of t(this, g)) {
+ const c = a instanceof P.AnnotationEditor ? a.serialize(!1, w) : a;
+ c && (A.set(y, c), u.update(`${y}:${JSON.stringify(c)}`), C || (C = !!c.bitmap));
+ }
+ if (C)
+ for (const y of A.values())
+ y.bitmap && _.push(y.bitmap);
+ return A.size > 0 ? {
+ map: A,
+ hash: u.hexdigest(),
+ transfers: _
+ } : X;
+ }
+ }
+ F = new WeakMap(), g = new WeakMap(), O = new WeakSet(), Ai = function() {
+ t(this, F) || (Z(this, F, !0), typeof this.onSetModified == "function" && this.onSetModified());
+ }, d.AnnotationStorage = pt;
+ class B extends pt {
+ constructor(u) {
+ super();
+ L(this, x, void 0);
+ const {
+ map: _,
+ hash: w,
+ transfers: C
+ } = u.serializable, y = structuredClone(_, C ? {
+ transfer: C
+ } : null);
+ Z(this, x, {
+ map: y,
+ hash: w,
+ transfers: C
+ });
+ }
+ get print() {
+ (0, l.unreachable)("Should not call PrintAnnotationStorage.print");
+ }
+ get serializable() {
+ return t(this, x);
+ }
+ }
+ x = new WeakMap(), d.PrintAnnotationStorage = B;
+ },
+ /* 4 */
+ /***/
+ (dt, d, et) => {
+ var B, F, g, O, I, x, v, A, u, _, w, C, y, a, c, Ue, p, je, T, He, U, We, E, yi, st, vi, H, Si, gt, Ge, xt, Ei;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.AnnotationEditor = void 0;
+ var l = et(5), P = et(1), rt = et(6);
+ const i = class i {
+ constructor(s) {
+ L(this, c);
+ L(this, p);
+ L(this, U);
+ L(this, E);
+ L(this, st);
+ L(this, H);
+ L(this, gt);
+ L(this, xt);
+ L(this, B, "");
+ L(this, F, !1);
+ L(this, g, null);
+ L(this, O, null);
+ L(this, I, null);
+ L(this, x, !1);
+ L(this, v, null);
+ L(this, A, this.focusin.bind(this));
+ L(this, u, this.focusout.bind(this));
+ L(this, _, !1);
+ L(this, w, !1);
+ L(this, C, !1);
+ ee(this, "_initialOptions", /* @__PURE__ */ Object.create(null));
+ ee(this, "_uiManager", null);
+ ee(this, "_focusEventsAllowed", !0);
+ ee(this, "_l10nPromise", null);
+ L(this, y, !1);
+ L(this, a, i._zIndex++);
+ this.constructor === i && (0, P.unreachable)("Cannot initialize AnnotationEditor."), this.parent = s.parent, this.id = s.id, this.width = this.height = null, this.pageIndex = s.parent.pageIndex, this.name = s.name, this.div = null, this._uiManager = s.uiManager, this.annotationElementId = null, this._willKeepAspectRatio = !1, this._initialOptions.isCentered = s.isCentered, this._structTreeParentId = null;
+ const {
+ rotation: o,
+ rawDims: {
+ pageWidth: h,
+ pageHeight: b,
+ pageX: M,
+ pageY: N
+ }
+ } = this.parent.viewport;
+ this.rotation = o, this.pageRotation = (360 + o - this._uiManager.viewParameters.rotation) % 360, this.pageDimensions = [h, b], this.pageTranslation = [M, N];
+ const [tt, Q] = this.parentDimensions;
+ this.x = s.x / tt, this.y = s.y / Q, this.isAttachedToDOM = !1, this.deleted = !1;
+ }
+ get editorType() {
+ return Object.getPrototypeOf(this).constructor._type;
+ }
+ static get _defaultLineColor() {
+ return (0, P.shadow)(this, "_defaultLineColor", this._colorManager.getHexCode("CanvasText"));
+ }
+ static deleteAnnotationElement(s) {
+ const o = new pt({
+ id: s.parent.getNextId(),
+ parent: s.parent,
+ uiManager: s._uiManager
+ });
+ o.annotationElementId = s.annotationElementId, o.deleted = !0, o._uiManager.addToAnnotationStorage(o);
+ }
+ static initialize(s, o = null) {
+ if (i._l10nPromise || (i._l10nPromise = new Map(["editor_alt_text_button_label", "editor_alt_text_edit_button_label", "editor_alt_text_decorative_tooltip"].map((b) => [b, s.get(b)]))), o != null && o.strings)
+ for (const b of o.strings)
+ i._l10nPromise.set(b, s.get(b));
+ if (i._borderLineWidth !== -1)
+ return;
+ const h = getComputedStyle(document.documentElement);
+ i._borderLineWidth = parseFloat(h.getPropertyValue("--outline-width")) || 0;
+ }
+ static updateDefaultParams(s, o) {
+ }
+ static get defaultPropertiesToUpdate() {
+ return [];
+ }
+ static isHandlingMimeForPasting(s) {
+ return !1;
+ }
+ static paste(s, o) {
+ (0, P.unreachable)("Not implemented");
+ }
+ get propertiesToUpdate() {
+ return [];
+ }
+ get _isDraggable() {
+ return t(this, y);
+ }
+ set _isDraggable(s) {
+ var o;
+ Z(this, y, s), (o = this.div) == null || o.classList.toggle("draggable", s);
+ }
+ center() {
+ const [s, o] = this.pageDimensions;
+ switch (this.parentRotation) {
+ case 90:
+ this.x -= this.height * o / (s * 2), this.y += this.width * s / (o * 2);
+ break;
+ case 180:
+ this.x += this.width / 2, this.y += this.height / 2;
+ break;
+ case 270:
+ this.x += this.height * o / (s * 2), this.y -= this.width * s / (o * 2);
+ break;
+ default:
+ this.x -= this.width / 2, this.y -= this.height / 2;
+ break;
+ }
+ this.fixAndSetPosition();
+ }
+ addCommands(s) {
+ this._uiManager.addCommands(s);
+ }
+ get currentLayer() {
+ return this._uiManager.currentLayer;
+ }
+ setInBackground() {
+ this.div.style.zIndex = 0;
+ }
+ setInForeground() {
+ this.div.style.zIndex = t(this, a);
+ }
+ setParent(s) {
+ s !== null && (this.pageIndex = s.pageIndex, this.pageDimensions = s.pageDimensions), this.parent = s;
+ }
+ focusin(s) {
+ this._focusEventsAllowed && (t(this, _) ? Z(this, _, !1) : this.parent.setSelected(this));
+ }
+ focusout(s) {
+ var h;
+ if (!this._focusEventsAllowed || !this.isAttachedToDOM)
+ return;
+ const o = s.relatedTarget;
+ o != null && o.closest(`#${this.id}`) || (s.preventDefault(), (h = this.parent) != null && h.isMultipleSelection || this.commitOrRemove());
+ }
+ commitOrRemove() {
+ this.isEmpty() ? this.remove() : this.commit();
+ }
+ commit() {
+ this.addToAnnotationStorage();
+ }
+ addToAnnotationStorage() {
+ this._uiManager.addToAnnotationStorage(this);
+ }
+ setAt(s, o, h, b) {
+ const [M, N] = this.parentDimensions;
+ [h, b] = this.screenToPageTranslation(h, b), this.x = (s + h) / M, this.y = (o + b) / N, this.fixAndSetPosition();
+ }
+ translate(s, o) {
+ W(this, c, Ue).call(this, this.parentDimensions, s, o);
+ }
+ translateInPage(s, o) {
+ W(this, c, Ue).call(this, this.pageDimensions, s, o), this.div.scrollIntoView({
+ block: "nearest"
+ });
+ }
+ drag(s, o) {
+ const [h, b] = this.parentDimensions;
+ if (this.x += s / h, this.y += o / b, this.parent && (this.x < 0 || this.x > 1 || this.y < 0 || this.y > 1)) {
+ const {
+ x: nt,
+ y: ct
+ } = this.div.getBoundingClientRect();
+ this.parent.findNewParent(this, nt, ct) && (this.x -= Math.floor(this.x), this.y -= Math.floor(this.y));
+ }
+ let {
+ x: M,
+ y: N
+ } = this;
+ const [tt, Q] = W(this, p, je).call(this);
+ M += tt, N += Q, this.div.style.left = `${(100 * M).toFixed(2)}%`, this.div.style.top = `${(100 * N).toFixed(2)}%`, this.div.scrollIntoView({
+ block: "nearest"
+ });
+ }
+ fixAndSetPosition() {
+ const [s, o] = this.pageDimensions;
+ let {
+ x: h,
+ y: b,
+ width: M,
+ height: N
+ } = this;
+ switch (M *= s, N *= o, h *= s, b *= o, this.rotation) {
+ case 0:
+ h = Math.max(0, Math.min(s - M, h)), b = Math.max(0, Math.min(o - N, b));
+ break;
+ case 90:
+ h = Math.max(0, Math.min(s - N, h)), b = Math.min(o, Math.max(M, b));
+ break;
+ case 180:
+ h = Math.min(s, Math.max(M, h)), b = Math.min(o, Math.max(N, b));
+ break;
+ case 270:
+ h = Math.min(s, Math.max(N, h)), b = Math.max(0, Math.min(o - M, b));
+ break;
+ }
+ this.x = h /= s, this.y = b /= o;
+ const [tt, Q] = W(this, p, je).call(this);
+ h += tt, b += Q;
+ const {
+ style: nt
+ } = this.div;
+ nt.left = `${(100 * h).toFixed(2)}%`, nt.top = `${(100 * b).toFixed(2)}%`, this.moveInDOM();
+ }
+ screenToPageTranslation(s, o) {
+ var h;
+ return W(h = i, T, He).call(h, s, o, this.parentRotation);
+ }
+ pageTranslationToScreen(s, o) {
+ var h;
+ return W(h = i, T, He).call(h, s, o, 360 - this.parentRotation);
+ }
+ get parentScale() {
+ return this._uiManager.viewParameters.realScale;
+ }
+ get parentRotation() {
+ return (this._uiManager.viewParameters.rotation + this.pageRotation) % 360;
+ }
+ get parentDimensions() {
+ const {
+ parentScale: s,
+ pageDimensions: [o, h]
+ } = this, b = o * s, M = h * s;
+ return P.FeatureTest.isCSSRoundSupported ? [Math.round(b), Math.round(M)] : [b, M];
+ }
+ setDims(s, o) {
+ var M;
+ const [h, b] = this.parentDimensions;
+ this.div.style.width = `${(100 * s / h).toFixed(2)}%`, t(this, x) || (this.div.style.height = `${(100 * o / b).toFixed(2)}%`), (M = t(this, g)) == null || M.classList.toggle("small", s < i.SMALL_EDITOR_SIZE || o < i.SMALL_EDITOR_SIZE);
+ }
+ fixDims() {
+ const {
+ style: s
+ } = this.div, {
+ height: o,
+ width: h
+ } = s, b = h.endsWith("%"), M = !t(this, x) && o.endsWith("%");
+ if (b && M)
+ return;
+ const [N, tt] = this.parentDimensions;
+ b || (s.width = `${(100 * parseFloat(h) / N).toFixed(2)}%`), !t(this, x) && !M && (s.height = `${(100 * parseFloat(o) / tt).toFixed(2)}%`);
+ }
+ getInitialTranslation() {
+ return [0, 0];
+ }
+ async addAltTextButton() {
+ if (t(this, g))
+ return;
+ const s = Z(this, g, document.createElement("button"));
+ s.className = "altText";
+ const o = await i._l10nPromise.get("editor_alt_text_button_label");
+ s.textContent = o, s.setAttribute("aria-label", o), s.tabIndex = "0", s.addEventListener("contextmenu", rt.noContextMenu), s.addEventListener("pointerdown", (h) => h.stopPropagation()), s.addEventListener("click", (h) => {
+ h.preventDefault(), this._uiManager.editAltText(this);
+ }, {
+ capture: !0
+ }), s.addEventListener("keydown", (h) => {
+ h.target === s && h.key === "Enter" && (h.preventDefault(), this._uiManager.editAltText(this));
+ }), W(this, gt, Ge).call(this), this.div.append(s), i.SMALL_EDITOR_SIZE || (i.SMALL_EDITOR_SIZE = Math.min(128, Math.round(s.getBoundingClientRect().width * 1.4)));
+ }
+ getClientDimensions() {
+ return this.div.getBoundingClientRect();
+ }
+ get altTextData() {
+ return {
+ altText: t(this, B),
+ decorative: t(this, F)
+ };
+ }
+ set altTextData({
+ altText: s,
+ decorative: o
+ }) {
+ t(this, B) === s && t(this, F) === o || (Z(this, B, s), Z(this, F, o), W(this, gt, Ge).call(this));
+ }
+ render() {
+ this.div = document.createElement("div"), this.div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360), this.div.className = this.name, this.div.setAttribute("id", this.id), this.div.setAttribute("tabIndex", 0), this.setInForeground(), this.div.addEventListener("focusin", t(this, A)), this.div.addEventListener("focusout", t(this, u));
+ const [s, o] = this.parentDimensions;
+ this.parentRotation % 180 !== 0 && (this.div.style.maxWidth = `${(100 * o / s).toFixed(2)}%`, this.div.style.maxHeight = `${(100 * s / o).toFixed(2)}%`);
+ const [h, b] = this.getInitialTranslation();
+ return this.translate(h, b), (0, l.bindEvents)(this, this.div, ["pointerdown"]), this.div;
+ }
+ pointerdown(s) {
+ const {
+ isMac: o
+ } = P.FeatureTest.platform;
+ if (s.button !== 0 || s.ctrlKey && o) {
+ s.preventDefault();
+ return;
+ }
+ Z(this, _, !0), W(this, xt, Ei).call(this, s);
+ }
+ moveInDOM() {
+ var s;
+ (s = this.parent) == null || s.moveEditorInDOM(this);
+ }
+ _setParentAndPosition(s, o, h) {
+ s.changeParent(this), this.x = o, this.y = h, this.fixAndSetPosition();
+ }
+ getRect(s, o) {
+ const h = this.parentScale, [b, M] = this.pageDimensions, [N, tt] = this.pageTranslation, Q = s / h, nt = o / h, ct = this.x * b, yt = this.y * M, ut = this.width * b, Ft = this.height * M;
+ switch (this.rotation) {
+ case 0:
+ return [ct + Q + N, M - yt - nt - Ft + tt, ct + Q + ut + N, M - yt - nt + tt];
+ case 90:
+ return [ct + nt + N, M - yt + Q + tt, ct + nt + Ft + N, M - yt + Q + ut + tt];
+ case 180:
+ return [ct - Q - ut + N, M - yt + nt + tt, ct - Q + N, M - yt + nt + Ft + tt];
+ case 270:
+ return [ct - nt - Ft + N, M - yt - Q - ut + tt, ct - nt + N, M - yt - Q + tt];
+ default:
+ throw new Error("Invalid rotation");
+ }
+ }
+ getRectInCurrentCoords(s, o) {
+ const [h, b, M, N] = s, tt = M - h, Q = N - b;
+ switch (this.rotation) {
+ case 0:
+ return [h, o - N, tt, Q];
+ case 90:
+ return [h, o - b, Q, tt];
+ case 180:
+ return [M, o - b, tt, Q];
+ case 270:
+ return [M, o - N, Q, tt];
+ default:
+ throw new Error("Invalid rotation");
+ }
+ }
+ onceAdded() {
+ }
+ isEmpty() {
+ return !1;
+ }
+ enableEditMode() {
+ Z(this, C, !0);
+ }
+ disableEditMode() {
+ Z(this, C, !1);
+ }
+ isInEditMode() {
+ return t(this, C);
+ }
+ shouldGetKeyboardEvents() {
+ return !1;
+ }
+ needsToBeRebuilt() {
+ return this.div && !this.isAttachedToDOM;
+ }
+ rebuild() {
+ var s, o;
+ (s = this.div) == null || s.addEventListener("focusin", t(this, A)), (o = this.div) == null || o.addEventListener("focusout", t(this, u));
+ }
+ serialize(s = !1, o = null) {
+ (0, P.unreachable)("An editor must be serializable");
+ }
+ static deserialize(s, o, h) {
+ const b = new this.prototype.constructor({
+ parent: o,
+ id: o.getNextId(),
+ uiManager: h
+ });
+ b.rotation = s.rotation;
+ const [M, N] = b.pageDimensions, [tt, Q, nt, ct] = b.getRectInCurrentCoords(s.rect, N);
+ return b.x = tt / M, b.y = Q / N, b.width = nt / M, b.height = ct / N, b;
+ }
+ remove() {
+ var s;
+ this.div.removeEventListener("focusin", t(this, A)), this.div.removeEventListener("focusout", t(this, u)), this.isEmpty() || this.commit(), this.parent ? this.parent.remove(this) : this._uiManager.removeEditor(this), (s = t(this, g)) == null || s.remove(), Z(this, g, null), Z(this, O, null);
+ }
+ get isResizable() {
+ return !1;
+ }
+ makeResizable() {
+ this.isResizable && (W(this, E, yi).call(this), t(this, v).classList.remove("hidden"));
+ }
+ select() {
+ var s;
+ this.makeResizable(), (s = this.div) == null || s.classList.add("selectedEditor");
+ }
+ unselect() {
+ var s, o, h;
+ (s = t(this, v)) == null || s.classList.add("hidden"), (o = this.div) == null || o.classList.remove("selectedEditor"), (h = this.div) != null && h.contains(document.activeElement) && this._uiManager.currentLayer.div.focus();
+ }
+ updateParams(s, o) {
+ }
+ disableEditing() {
+ t(this, g) && (t(this, g).hidden = !0);
+ }
+ enableEditing() {
+ t(this, g) && (t(this, g).hidden = !1);
+ }
+ enterInEditMode() {
+ }
+ get contentDiv() {
+ return this.div;
+ }
+ get isEditing() {
+ return t(this, w);
+ }
+ set isEditing(s) {
+ Z(this, w, s), this.parent && (s ? (this.parent.setSelected(this), this.parent.setActiveEditor(this)) : this.parent.setActiveEditor(null));
+ }
+ setAspectRatio(s, o) {
+ Z(this, x, !0);
+ const h = s / o, {
+ style: b
+ } = this.div;
+ b.aspectRatio = h, b.height = "auto";
+ }
+ static get MIN_SIZE() {
+ return 16;
+ }
+ };
+ B = new WeakMap(), F = new WeakMap(), g = new WeakMap(), O = new WeakMap(), I = new WeakMap(), x = new WeakMap(), v = new WeakMap(), A = new WeakMap(), u = new WeakMap(), _ = new WeakMap(), w = new WeakMap(), C = new WeakMap(), y = new WeakMap(), a = new WeakMap(), c = new WeakSet(), Ue = function([s, o], h, b) {
+ [h, b] = this.screenToPageTranslation(h, b), this.x += h / s, this.y += b / o, this.fixAndSetPosition();
+ }, p = new WeakSet(), je = function() {
+ const [s, o] = this.parentDimensions, {
+ _borderLineWidth: h
+ } = i, b = h / s, M = h / o;
+ switch (this.rotation) {
+ case 90:
+ return [-b, M];
+ case 180:
+ return [b, M];
+ case 270:
+ return [b, -M];
+ default:
+ return [-b, -M];
+ }
+ }, T = new WeakSet(), He = function(s, o, h) {
+ switch (h) {
+ case 90:
+ return [o, -s];
+ case 180:
+ return [-s, -o];
+ case 270:
+ return [-o, s];
+ default:
+ return [s, o];
+ }
+ }, U = new WeakSet(), We = function(s) {
+ switch (s) {
+ case 90: {
+ const [o, h] = this.pageDimensions;
+ return [0, -o / h, h / o, 0];
+ }
+ case 180:
+ return [-1, 0, 0, -1];
+ case 270: {
+ const [o, h] = this.pageDimensions;
+ return [0, o / h, -h / o, 0];
+ }
+ default:
+ return [1, 0, 0, 1];
+ }
+ }, E = new WeakSet(), yi = function() {
+ if (t(this, v))
+ return;
+ Z(this, v, document.createElement("div")), t(this, v).classList.add("resizers");
+ const s = ["topLeft", "topRight", "bottomRight", "bottomLeft"];
+ this._willKeepAspectRatio || s.push("topMiddle", "middleRight", "bottomMiddle", "middleLeft");
+ for (const o of s) {
+ const h = document.createElement("div");
+ t(this, v).append(h), h.classList.add("resizer", o), h.addEventListener("pointerdown", W(this, st, vi).bind(this, o)), h.addEventListener("contextmenu", rt.noContextMenu);
+ }
+ this.div.prepend(t(this, v));
+ }, st = new WeakSet(), vi = function(s, o) {
+ o.preventDefault();
+ const {
+ isMac: h
+ } = P.FeatureTest.platform;
+ if (o.button !== 0 || o.ctrlKey && h)
+ return;
+ const b = W(this, H, Si).bind(this, s), M = this._isDraggable;
+ this._isDraggable = !1;
+ const N = {
+ passive: !0,
+ capture: !0
+ };
+ window.addEventListener("pointermove", b, N);
+ const tt = this.x, Q = this.y, nt = this.width, ct = this.height, yt = this.parent.div.style.cursor, ut = this.div.style.cursor;
+ this.div.style.cursor = this.parent.div.style.cursor = window.getComputedStyle(o.target).cursor;
+ const Ft = () => {
+ this._isDraggable = M, window.removeEventListener("pointerup", Ft), window.removeEventListener("blur", Ft), window.removeEventListener("pointermove", b, N), this.parent.div.style.cursor = yt, this.div.style.cursor = ut;
+ const Bt = this.x, St = this.y, Dt = this.width, ft = this.height;
+ Bt === tt && St === Q && Dt === nt && ft === ct || this.addCommands({
+ cmd: () => {
+ this.width = Dt, this.height = ft, this.x = Bt, this.y = St;
+ const [K, J] = this.parentDimensions;
+ this.setDims(K * Dt, J * ft), this.fixAndSetPosition();
+ },
+ undo: () => {
+ this.width = nt, this.height = ct, this.x = tt, this.y = Q;
+ const [K, J] = this.parentDimensions;
+ this.setDims(K * nt, J * ct), this.fixAndSetPosition();
+ },
+ mustExec: !0
+ });
+ };
+ window.addEventListener("pointerup", Ft), window.addEventListener("blur", Ft);
+ }, H = new WeakSet(), Si = function(s, o) {
+ const [h, b] = this.parentDimensions, M = this.x, N = this.y, tt = this.width, Q = this.height, nt = i.MIN_SIZE / h, ct = i.MIN_SIZE / b, yt = (bt) => Math.round(bt * 1e4) / 1e4, ut = W(this, U, We).call(this, this.rotation), Ft = (bt, At) => [ut[0] * bt + ut[2] * At, ut[1] * bt + ut[3] * At], Bt = W(this, U, We).call(this, 360 - this.rotation), St = (bt, At) => [Bt[0] * bt + Bt[2] * At, Bt[1] * bt + Bt[3] * At];
+ let Dt, ft, K = !1, J = !1;
+ switch (s) {
+ case "topLeft":
+ K = !0, Dt = (bt, At) => [0, 0], ft = (bt, At) => [bt, At];
+ break;
+ case "topMiddle":
+ Dt = (bt, At) => [bt / 2, 0], ft = (bt, At) => [bt / 2, At];
+ break;
+ case "topRight":
+ K = !0, Dt = (bt, At) => [bt, 0], ft = (bt, At) => [0, At];
+ break;
+ case "middleRight":
+ J = !0, Dt = (bt, At) => [bt, At / 2], ft = (bt, At) => [0, At / 2];
+ break;
+ case "bottomRight":
+ K = !0, Dt = (bt, At) => [bt, At], ft = (bt, At) => [0, 0];
+ break;
+ case "bottomMiddle":
+ Dt = (bt, At) => [bt / 2, At], ft = (bt, At) => [bt / 2, 0];
+ break;
+ case "bottomLeft":
+ K = !0, Dt = (bt, At) => [0, At], ft = (bt, At) => [bt, 0];
+ break;
+ case "middleLeft":
+ J = !0, Dt = (bt, At) => [0, At / 2], ft = (bt, At) => [bt, At / 2];
+ break;
+ }
+ const ht = Dt(tt, Q), Et = ft(tt, Q);
+ let Ct = Ft(...Et);
+ const jt = yt(M + Ct[0]), Gt = yt(N + Ct[1]);
+ let Ht = 1, Xt = 1, [Vt, Wt] = this.screenToPageTranslation(o.movementX, o.movementY);
+ if ([Vt, Wt] = St(Vt / h, Wt / b), K) {
+ const bt = Math.hypot(tt, Q);
+ Ht = Xt = Math.max(Math.min(Math.hypot(Et[0] - ht[0] - Vt, Et[1] - ht[1] - Wt) / bt, 1 / tt, 1 / Q), nt / tt, ct / Q);
+ } else
+ J ? Ht = Math.max(nt, Math.min(1, Math.abs(Et[0] - ht[0] - Vt))) / tt : Xt = Math.max(ct, Math.min(1, Math.abs(Et[1] - ht[1] - Wt))) / Q;
+ const $t = yt(tt * Ht), ot = yt(Q * Xt);
+ Ct = Ft(...ft($t, ot));
+ const Y = jt - Ct[0], G = Gt - Ct[1];
+ this.width = $t, this.height = ot, this.x = Y, this.y = G, this.setDims(h * $t, b * ot), this.fixAndSetPosition();
+ }, gt = new WeakSet(), Ge = async function() {
+ var h;
+ const s = t(this, g);
+ if (!s)
+ return;
+ if (!t(this, B) && !t(this, F)) {
+ s.classList.remove("done"), (h = t(this, O)) == null || h.remove();
+ return;
+ }
+ i._l10nPromise.get("editor_alt_text_edit_button_label").then((b) => {
+ s.setAttribute("aria-label", b);
+ });
+ let o = t(this, O);
+ if (!o) {
+ Z(this, O, o = document.createElement("span")), o.className = "tooltip", o.setAttribute("role", "tooltip");
+ const b = o.id = `alt-text-tooltip-${this.id}`;
+ s.setAttribute("aria-describedby", b);
+ const M = 100;
+ s.addEventListener("mouseenter", () => {
+ Z(this, I, setTimeout(() => {
+ Z(this, I, null), t(this, O).classList.add("show"), this._uiManager._eventBus.dispatch("reporttelemetry", {
+ source: this,
+ details: {
+ type: "editing",
+ subtype: this.editorType,
+ data: {
+ action: "alt_text_tooltip"
+ }
+ }
+ });
+ }, M));
+ }), s.addEventListener("mouseleave", () => {
+ var N;
+ clearTimeout(t(this, I)), Z(this, I, null), (N = t(this, O)) == null || N.classList.remove("show");
+ });
+ }
+ s.classList.add("done"), o.innerText = t(this, F) ? await i._l10nPromise.get("editor_alt_text_decorative_tooltip") : t(this, B), o.parentNode || s.append(o);
+ }, xt = new WeakSet(), Ei = function(s) {
+ if (!this._isDraggable)
+ return;
+ const o = this._uiManager.isSelected(this);
+ this._uiManager.setUpDragSession();
+ let h, b;
+ o && (h = {
+ passive: !0,
+ capture: !0
+ }, b = (N) => {
+ const [tt, Q] = this.screenToPageTranslation(N.movementX, N.movementY);
+ this._uiManager.dragSelectedEditors(tt, Q);
+ }, window.addEventListener("pointermove", b, h));
+ const M = () => {
+ if (window.removeEventListener("pointerup", M), window.removeEventListener("blur", M), o && window.removeEventListener("pointermove", b, h), Z(this, _, !1), !this._uiManager.endDragSession()) {
+ const {
+ isMac: N
+ } = P.FeatureTest.platform;
+ s.ctrlKey && !N || s.shiftKey || s.metaKey && N ? this.parent.toggleSelected(this) : this.parent.setSelected(this);
+ }
+ };
+ window.addEventListener("pointerup", M), window.addEventListener("blur", M);
+ }, L(i, T), ee(i, "_borderLineWidth", -1), ee(i, "_colorManager", new l.ColorManager()), ee(i, "_zIndex", 1), ee(i, "SMALL_EDITOR_SIZE", 0);
+ let X = i;
+ d.AnnotationEditor = X;
+ class pt extends X {
+ constructor(s) {
+ super(s), this.annotationElementId = s.annotationElementId, this.deleted = !0;
+ }
+ serialize() {
+ return {
+ id: this.annotationElementId,
+ deleted: !0,
+ pageIndex: this.pageIndex
+ };
+ }
+ }
+ },
+ /* 5 */
+ /***/
+ (dt, d, et) => {
+ var x, v, A, u, _, ze, y, a, c, k, p, wi, m, U, z, E, V, st, at, H, lt, gt, wt, xt, S, i, n, s, o, h, b, M, N, tt, Q, nt, ct, yt, ut, Ft, Bt, St, Dt, ft, K, J, ht, Ci, Ct, Xe, Gt, Ve, Xt, Ce, Wt, qe, ot, $e, G, re, At, me, Zt, Ti, vt, Pi, Tt, Ye, Nt, be, _t, Ke;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.KeyboardManager = d.CommandManager = d.ColorManager = d.AnnotationEditorUIManager = void 0, d.bindEvents = rt, d.opacityToHex = X;
+ var l = et(1), P = et(6);
+ function rt(R, e, f) {
+ for (const D of f)
+ e.addEventListener(D, R[D].bind(R));
+ }
+ function X(R) {
+ return Math.round(Math.min(255, Math.max(1, 255 * R))).toString(16).padStart(2, "0");
+ }
+ class pt {
+ constructor() {
+ L(this, x, 0);
+ }
+ getId() {
+ return `${l.AnnotationEditorPrefix}${ge(this, x)._++}`;
+ }
+ }
+ x = new WeakMap();
+ const C = class C {
+ constructor() {
+ L(this, _);
+ L(this, v, (0, l.getUuid)());
+ L(this, A, 0);
+ L(this, u, null);
+ }
+ static get _isSVGFittingCanvas() {
+ const e = 'data:image/svg+xml;charset=UTF-8,', D = new OffscreenCanvas(1, 3).getContext("2d"), j = new Image();
+ j.src = e;
+ const q = j.decode().then(() => (D.drawImage(j, 0, 0, 1, 1, 0, 0, 1, 3), new Uint32Array(D.getImageData(0, 0, 1, 1).data.buffer)[0] === 0));
+ return (0, l.shadow)(this, "_isSVGFittingCanvas", q);
+ }
+ async getFromFile(e) {
+ const {
+ lastModified: f,
+ name: D,
+ size: j,
+ type: q
+ } = e;
+ return W(this, _, ze).call(this, `${f}_${D}_${j}_${q}`, e);
+ }
+ async getFromUrl(e) {
+ return W(this, _, ze).call(this, e, e);
+ }
+ async getFromId(e) {
+ t(this, u) || Z(this, u, /* @__PURE__ */ new Map());
+ const f = t(this, u).get(e);
+ return f ? f.bitmap ? (f.refCounter += 1, f) : f.file ? this.getFromFile(f.file) : this.getFromUrl(f.url) : null;
+ }
+ getSvgUrl(e) {
+ const f = t(this, u).get(e);
+ return f != null && f.isSvg ? f.svgUrl : null;
+ }
+ deleteId(e) {
+ t(this, u) || Z(this, u, /* @__PURE__ */ new Map());
+ const f = t(this, u).get(e);
+ f && (f.refCounter -= 1, f.refCounter === 0 && (f.bitmap = null));
+ }
+ isValidId(e) {
+ return e.startsWith(`image_${t(this, v)}_`);
+ }
+ };
+ v = new WeakMap(), A = new WeakMap(), u = new WeakMap(), _ = new WeakSet(), ze = async function(e, f) {
+ t(this, u) || Z(this, u, /* @__PURE__ */ new Map());
+ let D = t(this, u).get(e);
+ if (D === null)
+ return null;
+ if (D != null && D.bitmap)
+ return D.refCounter += 1, D;
+ try {
+ D || (D = {
+ bitmap: null,
+ id: `image_${t(this, v)}_${ge(this, A)._++}`,
+ refCounter: 0,
+ isSvg: !1
+ });
+ let j;
+ if (typeof f == "string") {
+ D.url = f;
+ const q = await fetch(f);
+ if (!q.ok)
+ throw new Error(q.statusText);
+ j = await q.blob();
+ } else
+ j = D.file = f;
+ if (j.type === "image/svg+xml") {
+ const q = C._isSVGFittingCanvas, it = new FileReader(), mt = new Image(), kt = new Promise((Pt, zt) => {
+ mt.onload = () => {
+ D.bitmap = mt, D.isSvg = !0, Pt();
+ }, it.onload = async () => {
+ const Mt = D.svgUrl = it.result;
+ mt.src = await q ? `${Mt}#svgView(preserveAspectRatio(none))` : Mt;
+ }, mt.onerror = it.onerror = zt;
+ });
+ it.readAsDataURL(j), await kt;
+ } else
+ D.bitmap = await createImageBitmap(j);
+ D.refCounter = 1;
+ } catch (j) {
+ console.error(j), D = null;
+ }
+ return t(this, u).set(e, D), D && t(this, u).set(D.id, D), D;
+ };
+ let B = C;
+ class F {
+ constructor(e = 128) {
+ L(this, y, []);
+ L(this, a, !1);
+ L(this, c, void 0);
+ L(this, k, -1);
+ Z(this, c, e);
+ }
+ add({
+ cmd: e,
+ undo: f,
+ mustExec: D,
+ type: j = NaN,
+ overwriteIfSameType: q = !1,
+ keepUndo: it = !1
+ }) {
+ if (D && e(), t(this, a))
+ return;
+ const mt = {
+ cmd: e,
+ undo: f,
+ type: j
+ };
+ if (t(this, k) === -1) {
+ t(this, y).length > 0 && (t(this, y).length = 0), Z(this, k, 0), t(this, y).push(mt);
+ return;
+ }
+ if (q && t(this, y)[t(this, k)].type === j) {
+ it && (mt.undo = t(this, y)[t(this, k)].undo), t(this, y)[t(this, k)] = mt;
+ return;
+ }
+ const kt = t(this, k) + 1;
+ kt === t(this, c) ? t(this, y).splice(0, 1) : (Z(this, k, kt), kt < t(this, y).length && t(this, y).splice(kt)), t(this, y).push(mt);
+ }
+ undo() {
+ t(this, k) !== -1 && (Z(this, a, !0), t(this, y)[t(this, k)].undo(), Z(this, a, !1), Z(this, k, t(this, k) - 1));
+ }
+ redo() {
+ t(this, k) < t(this, y).length - 1 && (Z(this, k, t(this, k) + 1), Z(this, a, !0), t(this, y)[t(this, k)].cmd(), Z(this, a, !1));
+ }
+ hasSomethingToUndo() {
+ return t(this, k) !== -1;
+ }
+ hasSomethingToRedo() {
+ return t(this, k) < t(this, y).length - 1;
+ }
+ destroy() {
+ Z(this, y, null);
+ }
+ }
+ y = new WeakMap(), a = new WeakMap(), c = new WeakMap(), k = new WeakMap(), d.CommandManager = F;
+ class g {
+ constructor(e) {
+ L(this, p);
+ this.buffer = [], this.callbacks = /* @__PURE__ */ new Map(), this.allKeys = /* @__PURE__ */ new Set();
+ const {
+ isMac: f
+ } = l.FeatureTest.platform;
+ for (const [D, j, q = {}] of e)
+ for (const it of D) {
+ const mt = it.startsWith("mac+");
+ f && mt ? (this.callbacks.set(it.slice(4), {
+ callback: j,
+ options: q
+ }), this.allKeys.add(it.split("+").at(-1))) : !f && !mt && (this.callbacks.set(it, {
+ callback: j,
+ options: q
+ }), this.allKeys.add(it.split("+").at(-1)));
+ }
+ }
+ exec(e, f) {
+ if (!this.allKeys.has(f.key))
+ return;
+ const D = this.callbacks.get(W(this, p, wi).call(this, f));
+ if (!D)
+ return;
+ const {
+ callback: j,
+ options: {
+ bubbles: q = !1,
+ args: it = [],
+ checker: mt = null
+ }
+ } = D;
+ mt && !mt(e, f) || (j.bind(e, ...it)(), q || (f.stopPropagation(), f.preventDefault()));
+ }
+ }
+ p = new WeakSet(), wi = function(e) {
+ e.altKey && this.buffer.push("alt"), e.ctrlKey && this.buffer.push("ctrl"), e.metaKey && this.buffer.push("meta"), e.shiftKey && this.buffer.push("shift"), this.buffer.push(e.key);
+ const f = this.buffer.join("+");
+ return this.buffer.length = 0, f;
+ }, d.KeyboardManager = g;
+ const T = class T {
+ get _colors() {
+ const e = /* @__PURE__ */ new Map([["CanvasText", null], ["Canvas", null]]);
+ return (0, P.getColorValues)(e), (0, l.shadow)(this, "_colors", e);
+ }
+ convert(e) {
+ const f = (0, P.getRGB)(e);
+ if (!window.matchMedia("(forced-colors: active)").matches)
+ return f;
+ for (const [D, j] of this._colors)
+ if (j.every((q, it) => q === f[it]))
+ return T._colorsMapping.get(D);
+ return f;
+ }
+ getHexCode(e) {
+ const f = this._colors.get(e);
+ return f ? l.Util.makeHexColor(...f) : e;
+ }
+ };
+ ee(T, "_colorsMapping", /* @__PURE__ */ new Map([["CanvasText", [0, 0, 0]], ["Canvas", [255, 255, 255]]]));
+ let O = T;
+ d.ColorManager = O;
+ const It = class It {
+ constructor(e, f, D, j, q, it) {
+ L(this, ht);
+ L(this, Ct);
+ L(this, Gt);
+ L(this, Xt);
+ L(this, Wt);
+ L(this, ot);
+ L(this, G);
+ L(this, At);
+ L(this, Zt);
+ L(this, vt);
+ L(this, Tt);
+ L(this, Nt);
+ L(this, _t);
+ L(this, m, null);
+ L(this, U, /* @__PURE__ */ new Map());
+ L(this, z, /* @__PURE__ */ new Map());
+ L(this, E, null);
+ L(this, V, null);
+ L(this, st, new F());
+ L(this, at, 0);
+ L(this, H, /* @__PURE__ */ new Set());
+ L(this, lt, null);
+ L(this, gt, null);
+ L(this, wt, /* @__PURE__ */ new Set());
+ L(this, xt, null);
+ L(this, S, new pt());
+ L(this, i, !1);
+ L(this, n, !1);
+ L(this, s, null);
+ L(this, o, l.AnnotationEditorType.NONE);
+ L(this, h, /* @__PURE__ */ new Set());
+ L(this, b, null);
+ L(this, M, this.blur.bind(this));
+ L(this, N, this.focus.bind(this));
+ L(this, tt, this.copy.bind(this));
+ L(this, Q, this.cut.bind(this));
+ L(this, nt, this.paste.bind(this));
+ L(this, ct, this.keydown.bind(this));
+ L(this, yt, this.onEditingAction.bind(this));
+ L(this, ut, this.onPageChanging.bind(this));
+ L(this, Ft, this.onScaleChanging.bind(this));
+ L(this, Bt, this.onRotationChanging.bind(this));
+ L(this, St, {
+ isEditing: !1,
+ isEmpty: !0,
+ hasSomethingToUndo: !1,
+ hasSomethingToRedo: !1,
+ hasSelectedEditor: !1
+ });
+ L(this, Dt, [0, 0]);
+ L(this, ft, null);
+ L(this, K, null);
+ L(this, J, null);
+ Z(this, K, e), Z(this, J, f), Z(this, E, D), this._eventBus = j, this._eventBus._on("editingaction", t(this, yt)), this._eventBus._on("pagechanging", t(this, ut)), this._eventBus._on("scalechanging", t(this, Ft)), this._eventBus._on("rotationchanging", t(this, Bt)), Z(this, V, q.annotationStorage), Z(this, xt, q.filterFactory), Z(this, b, it), this.viewParameters = {
+ realScale: P.PixelsPerInch.PDF_TO_CSS_UNITS,
+ rotation: 0
+ };
+ }
+ static get _keyboardManager() {
+ const e = It.prototype, f = (q) => {
+ const {
+ activeElement: it
+ } = document;
+ return it && t(q, K).contains(it) && q.hasSomethingToControl();
+ }, D = this.TRANSLATE_SMALL, j = this.TRANSLATE_BIG;
+ return (0, l.shadow)(this, "_keyboardManager", new g([[["ctrl+a", "mac+meta+a"], e.selectAll], [["ctrl+z", "mac+meta+z"], e.undo], [["ctrl+y", "ctrl+shift+z", "mac+meta+shift+z", "ctrl+shift+Z", "mac+meta+shift+Z"], e.redo], [["Backspace", "alt+Backspace", "ctrl+Backspace", "shift+Backspace", "mac+Backspace", "mac+alt+Backspace", "mac+ctrl+Backspace", "Delete", "ctrl+Delete", "shift+Delete", "mac+Delete"], e.delete], [["Escape", "mac+Escape"], e.unselectAll], [["ArrowLeft", "mac+ArrowLeft"], e.translateSelectedEditors, {
+ args: [-D, 0],
+ checker: f
+ }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], e.translateSelectedEditors, {
+ args: [-j, 0],
+ checker: f
+ }], [["ArrowRight", "mac+ArrowRight"], e.translateSelectedEditors, {
+ args: [D, 0],
+ checker: f
+ }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], e.translateSelectedEditors, {
+ args: [j, 0],
+ checker: f
+ }], [["ArrowUp", "mac+ArrowUp"], e.translateSelectedEditors, {
+ args: [0, -D],
+ checker: f
+ }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], e.translateSelectedEditors, {
+ args: [0, -j],
+ checker: f
+ }], [["ArrowDown", "mac+ArrowDown"], e.translateSelectedEditors, {
+ args: [0, D],
+ checker: f
+ }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], e.translateSelectedEditors, {
+ args: [0, j],
+ checker: f
+ }]]));
+ }
+ destroy() {
+ W(this, Xt, Ce).call(this), W(this, Ct, Xe).call(this), this._eventBus._off("editingaction", t(this, yt)), this._eventBus._off("pagechanging", t(this, ut)), this._eventBus._off("scalechanging", t(this, Ft)), this._eventBus._off("rotationchanging", t(this, Bt));
+ for (const e of t(this, z).values())
+ e.destroy();
+ t(this, z).clear(), t(this, U).clear(), t(this, wt).clear(), Z(this, m, null), t(this, h).clear(), t(this, st).destroy(), t(this, E).destroy();
+ }
+ get hcmFilter() {
+ return (0, l.shadow)(this, "hcmFilter", t(this, b) ? t(this, xt).addHCMFilter(t(this, b).foreground, t(this, b).background) : "none");
+ }
+ get direction() {
+ return (0, l.shadow)(this, "direction", getComputedStyle(t(this, K)).direction);
+ }
+ editAltText(e) {
+ var f;
+ (f = t(this, E)) == null || f.editAltText(this, e);
+ }
+ onPageChanging({
+ pageNumber: e
+ }) {
+ Z(this, at, e - 1);
+ }
+ focusMainContainer() {
+ t(this, K).focus();
+ }
+ findParent(e, f) {
+ for (const D of t(this, z).values()) {
+ const {
+ x: j,
+ y: q,
+ width: it,
+ height: mt
+ } = D.div.getBoundingClientRect();
+ if (e >= j && e <= j + it && f >= q && f <= q + mt)
+ return D;
+ }
+ return null;
+ }
+ disableUserSelect(e = !1) {
+ t(this, J).classList.toggle("noUserSelect", e);
+ }
+ addShouldRescale(e) {
+ t(this, wt).add(e);
+ }
+ removeShouldRescale(e) {
+ t(this, wt).delete(e);
+ }
+ onScaleChanging({
+ scale: e
+ }) {
+ this.commitOrRemove(), this.viewParameters.realScale = e * P.PixelsPerInch.PDF_TO_CSS_UNITS;
+ for (const f of t(this, wt))
+ f.onScaleChanging();
+ }
+ onRotationChanging({
+ pagesRotation: e
+ }) {
+ this.commitOrRemove(), this.viewParameters.rotation = e;
+ }
+ addToAnnotationStorage(e) {
+ !e.isEmpty() && t(this, V) && !t(this, V).has(e.id) && t(this, V).setValue(e.id, e);
+ }
+ blur() {
+ if (!this.hasSelection)
+ return;
+ const {
+ activeElement: e
+ } = document;
+ for (const f of t(this, h))
+ if (f.div.contains(e)) {
+ Z(this, s, [f, e]), f._focusEventsAllowed = !1;
+ break;
+ }
+ }
+ focus() {
+ if (!t(this, s))
+ return;
+ const [e, f] = t(this, s);
+ Z(this, s, null), f.addEventListener("focusin", () => {
+ e._focusEventsAllowed = !0;
+ }, {
+ once: !0
+ }), f.focus();
+ }
+ addEditListeners() {
+ W(this, Gt, Ve).call(this), W(this, Wt, qe).call(this);
+ }
+ removeEditListeners() {
+ W(this, Xt, Ce).call(this), W(this, ot, $e).call(this);
+ }
+ copy(e) {
+ var D;
+ if (e.preventDefault(), (D = t(this, m)) == null || D.commitOrRemove(), !this.hasSelection)
+ return;
+ const f = [];
+ for (const j of t(this, h)) {
+ const q = j.serialize(!0);
+ q && f.push(q);
+ }
+ f.length !== 0 && e.clipboardData.setData("application/pdfjs", JSON.stringify(f));
+ }
+ cut(e) {
+ this.copy(e), this.delete();
+ }
+ paste(e) {
+ e.preventDefault();
+ const {
+ clipboardData: f
+ } = e;
+ for (const q of f.items)
+ for (const it of t(this, gt))
+ if (it.isHandlingMimeForPasting(q.type)) {
+ it.paste(q, this.currentLayer);
+ return;
+ }
+ let D = f.getData("application/pdfjs");
+ if (!D)
+ return;
+ try {
+ D = JSON.parse(D);
+ } catch (q) {
+ (0, l.warn)(`paste: "${q.message}".`);
+ return;
+ }
+ if (!Array.isArray(D))
+ return;
+ this.unselectAll();
+ const j = this.currentLayer;
+ try {
+ const q = [];
+ for (const kt of D) {
+ const Pt = j.deserialize(kt);
+ if (!Pt)
+ return;
+ q.push(Pt);
+ }
+ const it = () => {
+ for (const kt of q)
+ W(this, Tt, Ye).call(this, kt);
+ W(this, _t, Ke).call(this, q);
+ }, mt = () => {
+ for (const kt of q)
+ kt.remove();
+ };
+ this.addCommands({
+ cmd: it,
+ undo: mt,
+ mustExec: !0
+ });
+ } catch (q) {
+ (0, l.warn)(`paste: "${q.message}".`);
+ }
+ }
+ keydown(e) {
+ var f;
+ (f = this.getActive()) != null && f.shouldGetKeyboardEvents() || It._keyboardManager.exec(this, e);
+ }
+ onEditingAction(e) {
+ ["undo", "redo", "delete", "selectAll"].includes(e.name) && this[e.name]();
+ }
+ setEditingState(e) {
+ e ? (W(this, ht, Ci).call(this), W(this, Gt, Ve).call(this), W(this, Wt, qe).call(this), W(this, G, re).call(this, {
+ isEditing: t(this, o) !== l.AnnotationEditorType.NONE,
+ isEmpty: W(this, Nt, be).call(this),
+ hasSomethingToUndo: t(this, st).hasSomethingToUndo(),
+ hasSomethingToRedo: t(this, st).hasSomethingToRedo(),
+ hasSelectedEditor: !1
+ })) : (W(this, Ct, Xe).call(this), W(this, Xt, Ce).call(this), W(this, ot, $e).call(this), W(this, G, re).call(this, {
+ isEditing: !1
+ }), this.disableUserSelect(!1));
+ }
+ registerEditorTypes(e) {
+ if (!t(this, gt)) {
+ Z(this, gt, e);
+ for (const f of t(this, gt))
+ W(this, At, me).call(this, f.defaultPropertiesToUpdate);
+ }
+ }
+ getId() {
+ return t(this, S).getId();
+ }
+ get currentLayer() {
+ return t(this, z).get(t(this, at));
+ }
+ getLayer(e) {
+ return t(this, z).get(e);
+ }
+ get currentPageIndex() {
+ return t(this, at);
+ }
+ addLayer(e) {
+ t(this, z).set(e.pageIndex, e), t(this, i) ? e.enable() : e.disable();
+ }
+ removeLayer(e) {
+ t(this, z).delete(e.pageIndex);
+ }
+ updateMode(e, f = null) {
+ if (t(this, o) !== e) {
+ if (Z(this, o, e), e === l.AnnotationEditorType.NONE) {
+ this.setEditingState(!1), W(this, vt, Pi).call(this);
+ return;
+ }
+ this.setEditingState(!0), W(this, Zt, Ti).call(this), this.unselectAll();
+ for (const D of t(this, z).values())
+ D.updateMode(e);
+ if (f) {
+ for (const D of t(this, U).values())
+ if (D.annotationElementId === f) {
+ this.setSelected(D), D.enterInEditMode();
+ break;
+ }
+ }
+ }
+ }
+ updateToolbar(e) {
+ e !== t(this, o) && this._eventBus.dispatch("switchannotationeditormode", {
+ source: this,
+ mode: e
+ });
+ }
+ updateParams(e, f) {
+ if (t(this, gt)) {
+ if (e === l.AnnotationEditorParamsType.CREATE) {
+ this.currentLayer.addNewEditor(e);
+ return;
+ }
+ for (const D of t(this, h))
+ D.updateParams(e, f);
+ for (const D of t(this, gt))
+ D.updateDefaultParams(e, f);
+ }
+ }
+ enableWaiting(e = !1) {
+ if (t(this, n) !== e) {
+ Z(this, n, e);
+ for (const f of t(this, z).values())
+ e ? f.disableClick() : f.enableClick(), f.div.classList.toggle("waiting", e);
+ }
+ }
+ getEditors(e) {
+ const f = [];
+ for (const D of t(this, U).values())
+ D.pageIndex === e && f.push(D);
+ return f;
+ }
+ getEditor(e) {
+ return t(this, U).get(e);
+ }
+ addEditor(e) {
+ t(this, U).set(e.id, e);
+ }
+ removeEditor(e) {
+ var f;
+ t(this, U).delete(e.id), this.unselect(e), (!e.annotationElementId || !t(this, H).has(e.annotationElementId)) && ((f = t(this, V)) == null || f.remove(e.id));
+ }
+ addDeletedAnnotationElement(e) {
+ t(this, H).add(e.annotationElementId), e.deleted = !0;
+ }
+ isDeletedAnnotationElement(e) {
+ return t(this, H).has(e);
+ }
+ removeDeletedAnnotationElement(e) {
+ t(this, H).delete(e.annotationElementId), e.deleted = !1;
+ }
+ setActiveEditor(e) {
+ t(this, m) !== e && (Z(this, m, e), e && W(this, At, me).call(this, e.propertiesToUpdate));
+ }
+ toggleSelected(e) {
+ if (t(this, h).has(e)) {
+ t(this, h).delete(e), e.unselect(), W(this, G, re).call(this, {
+ hasSelectedEditor: this.hasSelection
+ });
+ return;
+ }
+ t(this, h).add(e), e.select(), W(this, At, me).call(this, e.propertiesToUpdate), W(this, G, re).call(this, {
+ hasSelectedEditor: !0
+ });
+ }
+ setSelected(e) {
+ for (const f of t(this, h))
+ f !== e && f.unselect();
+ t(this, h).clear(), t(this, h).add(e), e.select(), W(this, At, me).call(this, e.propertiesToUpdate), W(this, G, re).call(this, {
+ hasSelectedEditor: !0
+ });
+ }
+ isSelected(e) {
+ return t(this, h).has(e);
+ }
+ unselect(e) {
+ e.unselect(), t(this, h).delete(e), W(this, G, re).call(this, {
+ hasSelectedEditor: this.hasSelection
+ });
+ }
+ get hasSelection() {
+ return t(this, h).size !== 0;
+ }
+ undo() {
+ t(this, st).undo(), W(this, G, re).call(this, {
+ hasSomethingToUndo: t(this, st).hasSomethingToUndo(),
+ hasSomethingToRedo: !0,
+ isEmpty: W(this, Nt, be).call(this)
+ });
+ }
+ redo() {
+ t(this, st).redo(), W(this, G, re).call(this, {
+ hasSomethingToUndo: !0,
+ hasSomethingToRedo: t(this, st).hasSomethingToRedo(),
+ isEmpty: W(this, Nt, be).call(this)
+ });
+ }
+ addCommands(e) {
+ t(this, st).add(e), W(this, G, re).call(this, {
+ hasSomethingToUndo: !0,
+ hasSomethingToRedo: !1,
+ isEmpty: W(this, Nt, be).call(this)
+ });
+ }
+ delete() {
+ if (this.commitOrRemove(), !this.hasSelection)
+ return;
+ const e = [...t(this, h)], f = () => {
+ for (const j of e)
+ j.remove();
+ }, D = () => {
+ for (const j of e)
+ W(this, Tt, Ye).call(this, j);
+ };
+ this.addCommands({
+ cmd: f,
+ undo: D,
+ mustExec: !0
+ });
+ }
+ commitOrRemove() {
+ var e;
+ (e = t(this, m)) == null || e.commitOrRemove();
+ }
+ hasSomethingToControl() {
+ return t(this, m) || this.hasSelection;
+ }
+ selectAll() {
+ for (const e of t(this, h))
+ e.commit();
+ W(this, _t, Ke).call(this, t(this, U).values());
+ }
+ unselectAll() {
+ if (t(this, m)) {
+ t(this, m).commitOrRemove();
+ return;
+ }
+ if (this.hasSelection) {
+ for (const e of t(this, h))
+ e.unselect();
+ t(this, h).clear(), W(this, G, re).call(this, {
+ hasSelectedEditor: !1
+ });
+ }
+ }
+ translateSelectedEditors(e, f, D = !1) {
+ if (D || this.commitOrRemove(), !this.hasSelection)
+ return;
+ t(this, Dt)[0] += e, t(this, Dt)[1] += f;
+ const [j, q] = t(this, Dt), it = [...t(this, h)], mt = 1e3;
+ t(this, ft) && clearTimeout(t(this, ft)), Z(this, ft, setTimeout(() => {
+ Z(this, ft, null), t(this, Dt)[0] = t(this, Dt)[1] = 0, this.addCommands({
+ cmd: () => {
+ for (const kt of it)
+ t(this, U).has(kt.id) && kt.translateInPage(j, q);
+ },
+ undo: () => {
+ for (const kt of it)
+ t(this, U).has(kt.id) && kt.translateInPage(-j, -q);
+ },
+ mustExec: !1
+ });
+ }, mt));
+ for (const kt of it)
+ kt.translateInPage(e, f);
+ }
+ setUpDragSession() {
+ if (this.hasSelection) {
+ this.disableUserSelect(!0), Z(this, lt, /* @__PURE__ */ new Map());
+ for (const e of t(this, h))
+ t(this, lt).set(e, {
+ savedX: e.x,
+ savedY: e.y,
+ savedPageIndex: e.pageIndex,
+ newX: 0,
+ newY: 0,
+ newPageIndex: -1
+ });
+ }
+ }
+ endDragSession() {
+ if (!t(this, lt))
+ return !1;
+ this.disableUserSelect(!1);
+ const e = t(this, lt);
+ Z(this, lt, null);
+ let f = !1;
+ for (const [{
+ x: j,
+ y: q,
+ pageIndex: it
+ }, mt] of e)
+ mt.newX = j, mt.newY = q, mt.newPageIndex = it, f || (f = j !== mt.savedX || q !== mt.savedY || it !== mt.savedPageIndex);
+ if (!f)
+ return !1;
+ const D = (j, q, it, mt) => {
+ if (t(this, U).has(j.id)) {
+ const kt = t(this, z).get(mt);
+ kt ? j._setParentAndPosition(kt, q, it) : (j.pageIndex = mt, j.x = q, j.y = it);
+ }
+ };
+ return this.addCommands({
+ cmd: () => {
+ for (const [j, {
+ newX: q,
+ newY: it,
+ newPageIndex: mt
+ }] of e)
+ D(j, q, it, mt);
+ },
+ undo: () => {
+ for (const [j, {
+ savedX: q,
+ savedY: it,
+ savedPageIndex: mt
+ }] of e)
+ D(j, q, it, mt);
+ },
+ mustExec: !0
+ }), !0;
+ }
+ dragSelectedEditors(e, f) {
+ if (t(this, lt))
+ for (const D of t(this, lt).keys())
+ D.drag(e, f);
+ }
+ rebuild(e) {
+ if (e.parent === null) {
+ const f = this.getLayer(e.pageIndex);
+ f ? (f.changeParent(e), f.addOrRebuild(e)) : (this.addEditor(e), this.addToAnnotationStorage(e), e.rebuild());
+ } else
+ e.parent.addOrRebuild(e);
+ }
+ isActive(e) {
+ return t(this, m) === e;
+ }
+ getActive() {
+ return t(this, m);
+ }
+ getMode() {
+ return t(this, o);
+ }
+ get imageManager() {
+ return (0, l.shadow)(this, "imageManager", new B());
+ }
+ };
+ m = new WeakMap(), U = new WeakMap(), z = new WeakMap(), E = new WeakMap(), V = new WeakMap(), st = new WeakMap(), at = new WeakMap(), H = new WeakMap(), lt = new WeakMap(), gt = new WeakMap(), wt = new WeakMap(), xt = new WeakMap(), S = new WeakMap(), i = new WeakMap(), n = new WeakMap(), s = new WeakMap(), o = new WeakMap(), h = new WeakMap(), b = new WeakMap(), M = new WeakMap(), N = new WeakMap(), tt = new WeakMap(), Q = new WeakMap(), nt = new WeakMap(), ct = new WeakMap(), yt = new WeakMap(), ut = new WeakMap(), Ft = new WeakMap(), Bt = new WeakMap(), St = new WeakMap(), Dt = new WeakMap(), ft = new WeakMap(), K = new WeakMap(), J = new WeakMap(), ht = new WeakSet(), Ci = function() {
+ window.addEventListener("focus", t(this, N)), window.addEventListener("blur", t(this, M));
+ }, Ct = new WeakSet(), Xe = function() {
+ window.removeEventListener("focus", t(this, N)), window.removeEventListener("blur", t(this, M));
+ }, Gt = new WeakSet(), Ve = function() {
+ window.addEventListener("keydown", t(this, ct), {
+ capture: !0
+ });
+ }, Xt = new WeakSet(), Ce = function() {
+ window.removeEventListener("keydown", t(this, ct), {
+ capture: !0
+ });
+ }, Wt = new WeakSet(), qe = function() {
+ document.addEventListener("copy", t(this, tt)), document.addEventListener("cut", t(this, Q)), document.addEventListener("paste", t(this, nt));
+ }, ot = new WeakSet(), $e = function() {
+ document.removeEventListener("copy", t(this, tt)), document.removeEventListener("cut", t(this, Q)), document.removeEventListener("paste", t(this, nt));
+ }, G = new WeakSet(), re = function(e) {
+ Object.entries(e).some(([D, j]) => t(this, St)[D] !== j) && this._eventBus.dispatch("annotationeditorstateschanged", {
+ source: this,
+ details: Object.assign(t(this, St), e)
+ });
+ }, At = new WeakSet(), me = function(e) {
+ this._eventBus.dispatch("annotationeditorparamschanged", {
+ source: this,
+ details: e
+ });
+ }, Zt = new WeakSet(), Ti = function() {
+ if (!t(this, i)) {
+ Z(this, i, !0);
+ for (const e of t(this, z).values())
+ e.enable();
+ }
+ }, vt = new WeakSet(), Pi = function() {
+ if (this.unselectAll(), t(this, i)) {
+ Z(this, i, !1);
+ for (const e of t(this, z).values())
+ e.disable();
+ }
+ }, Tt = new WeakSet(), Ye = function(e) {
+ const f = t(this, z).get(e.pageIndex);
+ f ? f.addOrRebuild(e) : this.addEditor(e);
+ }, Nt = new WeakSet(), be = function() {
+ if (t(this, U).size === 0)
+ return !0;
+ if (t(this, U).size === 1)
+ for (const e of t(this, U).values())
+ return e.isEmpty();
+ return !1;
+ }, _t = new WeakSet(), Ke = function(e) {
+ t(this, h).clear();
+ for (const f of e)
+ f.isEmpty() || (t(this, h).add(f), f.select());
+ W(this, G, re).call(this, {
+ hasSelectedEditor: !0
+ });
+ }, ee(It, "TRANSLATE_SMALL", 1), ee(It, "TRANSLATE_BIG", 10);
+ let I = It;
+ d.AnnotationEditorUIManager = I;
+ },
+ /* 6 */
+ /***/
+ (dt, d, et) => {
+ var at, H, lt, gt, wt, xt, S, i, n, s, o, h, de, M, ue, tt, Je, nt, Te, yt, Pe, Ft, _e, St, Ae;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.StatTimer = d.RenderingCancelledException = d.PixelsPerInch = d.PageViewport = d.PDFDateString = d.DOMStandardFontDataFactory = d.DOMSVGFactory = d.DOMFilterFactory = d.DOMCanvasFactory = d.DOMCMapReaderFactory = void 0, d.deprecated = k, d.getColorValues = U, d.getCurrentTransform = z, d.getCurrentTransformInverse = E, d.getFilenameFromUrl = _, d.getPdfFilenameFromUrl = w, d.getRGB = m, d.getXfaPageViewport = T, d.isDataScheme = A, d.isPdfFile = u, d.isValidFetchUrl = y, d.loadScript = c, d.noContextMenu = a, d.setLayerDimensions = V;
+ var l = et(7), P = et(1);
+ const rt = "http://www.w3.org/2000/svg", st = class st {
+ };
+ ee(st, "CSS", 96), ee(st, "PDF", 72), ee(st, "PDF_TO_CSS_UNITS", st.CSS / st.PDF);
+ let X = st;
+ d.PixelsPerInch = X;
+ class pt extends l.BaseFilterFactory {
+ constructor({
+ docId: J,
+ ownerDocument: ht = globalThis.document
+ } = {}) {
+ super();
+ L(this, h);
+ L(this, M);
+ L(this, tt);
+ L(this, nt);
+ L(this, yt);
+ L(this, Ft);
+ L(this, St);
+ L(this, at, void 0);
+ L(this, H, void 0);
+ L(this, lt, void 0);
+ L(this, gt, void 0);
+ L(this, wt, void 0);
+ L(this, xt, void 0);
+ L(this, S, void 0);
+ L(this, i, void 0);
+ L(this, n, void 0);
+ L(this, s, void 0);
+ L(this, o, 0);
+ Z(this, lt, J), Z(this, gt, ht);
+ }
+ addFilter(J) {
+ if (!J)
+ return "none";
+ let ht = t(this, h, de).get(J);
+ if (ht)
+ return ht;
+ let Et, Ct, jt, Gt;
+ if (J.length === 1) {
+ const Wt = J[0], $t = new Array(256);
+ for (let ot = 0; ot < 256; ot++)
+ $t[ot] = Wt[ot] / 255;
+ Gt = Et = Ct = jt = $t.join(",");
+ } else {
+ const [Wt, $t, ot] = J, Y = new Array(256), G = new Array(256), bt = new Array(256);
+ for (let At = 0; At < 256; At++)
+ Y[At] = Wt[At] / 255, G[At] = $t[At] / 255, bt[At] = ot[At] / 255;
+ Et = Y.join(","), Ct = G.join(","), jt = bt.join(","), Gt = `${Et}${Ct}${jt}`;
+ }
+ if (ht = t(this, h, de).get(Gt), ht)
+ return t(this, h, de).set(J, ht), ht;
+ const Ht = `g_${t(this, lt)}_transfer_map_${ge(this, o)._++}`, Xt = `url(#${Ht})`;
+ t(this, h, de).set(J, Xt), t(this, h, de).set(Gt, Xt);
+ const Vt = W(this, nt, Te).call(this, Ht);
+ return W(this, Ft, _e).call(this, Et, Ct, jt, Vt), Xt;
+ }
+ addHCMFilter(J, ht) {
+ var $t;
+ const Et = `${J}-${ht}`;
+ if (t(this, xt) === Et)
+ return t(this, S);
+ if (Z(this, xt, Et), Z(this, S, "none"), ($t = t(this, wt)) == null || $t.remove(), !J || !ht)
+ return t(this, S);
+ const Ct = W(this, St, Ae).call(this, J);
+ J = P.Util.makeHexColor(...Ct);
+ const jt = W(this, St, Ae).call(this, ht);
+ if (ht = P.Util.makeHexColor(...jt), t(this, M, ue).style.color = "", J === "#000000" && ht === "#ffffff" || J === ht)
+ return t(this, S);
+ const Gt = new Array(256);
+ for (let ot = 0; ot <= 255; ot++) {
+ const Y = ot / 255;
+ Gt[ot] = Y <= 0.03928 ? Y / 12.92 : ((Y + 0.055) / 1.055) ** 2.4;
+ }
+ const Ht = Gt.join(","), Xt = `g_${t(this, lt)}_hcm_filter`, Vt = Z(this, i, W(this, nt, Te).call(this, Xt));
+ W(this, Ft, _e).call(this, Ht, Ht, Ht, Vt), W(this, tt, Je).call(this, Vt);
+ const Wt = (ot, Y) => {
+ const G = Ct[ot] / 255, bt = jt[ot] / 255, At = new Array(Y + 1);
+ for (let te = 0; te <= Y; te++)
+ At[te] = G + te / Y * (bt - G);
+ return At.join(",");
+ };
+ return W(this, Ft, _e).call(this, Wt(0, 5), Wt(1, 5), Wt(2, 5), Vt), Z(this, S, `url(#${Xt})`), t(this, S);
+ }
+ addHighlightHCMFilter(J, ht, Et, Ct) {
+ var bt;
+ const jt = `${J}-${ht}-${Et}-${Ct}`;
+ if (t(this, n) === jt)
+ return t(this, s);
+ if (Z(this, n, jt), Z(this, s, "none"), (bt = t(this, i)) == null || bt.remove(), !J || !ht)
+ return t(this, s);
+ const [Gt, Ht] = [J, ht].map(W(this, St, Ae).bind(this));
+ let Xt = Math.round(0.2126 * Gt[0] + 0.7152 * Gt[1] + 0.0722 * Gt[2]), Vt = Math.round(0.2126 * Ht[0] + 0.7152 * Ht[1] + 0.0722 * Ht[2]), [Wt, $t] = [Et, Ct].map(W(this, St, Ae).bind(this));
+ Vt < Xt && ([Xt, Vt, Wt, $t] = [Vt, Xt, $t, Wt]), t(this, M, ue).style.color = "";
+ const ot = (At, te, Zt) => {
+ const $ = new Array(256), vt = (Vt - Xt) / Zt, Lt = At / 255, Tt = (te - At) / (255 * Zt);
+ let Ot = 0;
+ for (let Nt = 0; Nt <= Zt; Nt++) {
+ const Jt = Math.round(Xt + Nt * vt), _t = Lt + Nt * Tt;
+ for (let Yt = Ot; Yt <= Jt; Yt++)
+ $[Yt] = _t;
+ Ot = Jt + 1;
+ }
+ for (let Nt = Ot; Nt < 256; Nt++)
+ $[Nt] = $[Ot - 1];
+ return $.join(",");
+ }, Y = `g_${t(this, lt)}_hcm_highlight_filter`, G = Z(this, i, W(this, nt, Te).call(this, Y));
+ return W(this, tt, Je).call(this, G), W(this, Ft, _e).call(this, ot(Wt[0], $t[0], 5), ot(Wt[1], $t[1], 5), ot(Wt[2], $t[2], 5), G), Z(this, s, `url(#${Y})`), t(this, s);
+ }
+ destroy(J = !1) {
+ J && (t(this, S) || t(this, s)) || (t(this, H) && (t(this, H).parentNode.parentNode.remove(), Z(this, H, null)), t(this, at) && (t(this, at).clear(), Z(this, at, null)), Z(this, o, 0));
+ }
+ }
+ at = new WeakMap(), H = new WeakMap(), lt = new WeakMap(), gt = new WeakMap(), wt = new WeakMap(), xt = new WeakMap(), S = new WeakMap(), i = new WeakMap(), n = new WeakMap(), s = new WeakMap(), o = new WeakMap(), h = new WeakSet(), de = function() {
+ return t(this, at) || Z(this, at, /* @__PURE__ */ new Map());
+ }, M = new WeakSet(), ue = function() {
+ if (!t(this, H)) {
+ const J = t(this, gt).createElement("div"), {
+ style: ht
+ } = J;
+ ht.visibility = "hidden", ht.contain = "strict", ht.width = ht.height = 0, ht.position = "absolute", ht.top = ht.left = 0, ht.zIndex = -1;
+ const Et = t(this, gt).createElementNS(rt, "svg");
+ Et.setAttribute("width", 0), Et.setAttribute("height", 0), Z(this, H, t(this, gt).createElementNS(rt, "defs")), J.append(Et), Et.append(t(this, H)), t(this, gt).body.append(J);
+ }
+ return t(this, H);
+ }, tt = new WeakSet(), Je = function(J) {
+ const ht = t(this, gt).createElementNS(rt, "feColorMatrix");
+ ht.setAttribute("type", "matrix"), ht.setAttribute("values", "0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"), J.append(ht);
+ }, nt = new WeakSet(), Te = function(J) {
+ const ht = t(this, gt).createElementNS(rt, "filter");
+ return ht.setAttribute("color-interpolation-filters", "sRGB"), ht.setAttribute("id", J), t(this, M, ue).append(ht), ht;
+ }, yt = new WeakSet(), Pe = function(J, ht, Et) {
+ const Ct = t(this, gt).createElementNS(rt, ht);
+ Ct.setAttribute("type", "discrete"), Ct.setAttribute("tableValues", Et), J.append(Ct);
+ }, Ft = new WeakSet(), _e = function(J, ht, Et, Ct) {
+ const jt = t(this, gt).createElementNS(rt, "feComponentTransfer");
+ Ct.append(jt), W(this, yt, Pe).call(this, jt, "feFuncR", J), W(this, yt, Pe).call(this, jt, "feFuncG", ht), W(this, yt, Pe).call(this, jt, "feFuncB", Et);
+ }, St = new WeakSet(), Ae = function(J) {
+ return t(this, M, ue).style.color = J, m(getComputedStyle(t(this, M, ue)).getPropertyValue("color"));
+ }, d.DOMFilterFactory = pt;
+ class B extends l.BaseCanvasFactory {
+ constructor({
+ ownerDocument: K = globalThis.document
+ } = {}) {
+ super(), this._document = K;
+ }
+ _createCanvas(K, J) {
+ const ht = this._document.createElement("canvas");
+ return ht.width = K, ht.height = J, ht;
+ }
+ }
+ d.DOMCanvasFactory = B;
+ async function F(ft, K = !1) {
+ if (y(ft, document.baseURI)) {
+ const J = await fetch(ft);
+ if (!J.ok)
+ throw new Error(J.statusText);
+ return K ? new Uint8Array(await J.arrayBuffer()) : (0, P.stringToBytes)(await J.text());
+ }
+ return new Promise((J, ht) => {
+ const Et = new XMLHttpRequest();
+ Et.open("GET", ft, !0), K && (Et.responseType = "arraybuffer"), Et.onreadystatechange = () => {
+ if (Et.readyState === XMLHttpRequest.DONE) {
+ if (Et.status === 200 || Et.status === 0) {
+ let Ct;
+ if (K && Et.response ? Ct = new Uint8Array(Et.response) : !K && Et.responseText && (Ct = (0, P.stringToBytes)(Et.responseText)), Ct) {
+ J(Ct);
+ return;
+ }
+ }
+ ht(new Error(Et.statusText));
+ }
+ }, Et.send(null);
+ });
+ }
+ class g extends l.BaseCMapReaderFactory {
+ _fetchData(K, J) {
+ return F(K, this.isCompressed).then((ht) => ({
+ cMapData: ht,
+ compressionType: J
+ }));
+ }
+ }
+ d.DOMCMapReaderFactory = g;
+ class O extends l.BaseStandardFontDataFactory {
+ _fetchData(K) {
+ return F(K, !0);
+ }
+ }
+ d.DOMStandardFontDataFactory = O;
+ class I extends l.BaseSVGFactory {
+ _createSVG(K) {
+ return document.createElementNS(rt, K);
+ }
+ }
+ d.DOMSVGFactory = I;
+ class x {
+ constructor({
+ viewBox: K,
+ scale: J,
+ rotation: ht,
+ offsetX: Et = 0,
+ offsetY: Ct = 0,
+ dontFlip: jt = !1
+ }) {
+ this.viewBox = K, this.scale = J, this.rotation = ht, this.offsetX = Et, this.offsetY = Ct;
+ const Gt = (K[2] + K[0]) / 2, Ht = (K[3] + K[1]) / 2;
+ let Xt, Vt, Wt, $t;
+ switch (ht %= 360, ht < 0 && (ht += 360), ht) {
+ case 180:
+ Xt = -1, Vt = 0, Wt = 0, $t = 1;
+ break;
+ case 90:
+ Xt = 0, Vt = 1, Wt = 1, $t = 0;
+ break;
+ case 270:
+ Xt = 0, Vt = -1, Wt = -1, $t = 0;
+ break;
+ case 0:
+ Xt = 1, Vt = 0, Wt = 0, $t = -1;
+ break;
+ default:
+ throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
+ }
+ jt && (Wt = -Wt, $t = -$t);
+ let ot, Y, G, bt;
+ Xt === 0 ? (ot = Math.abs(Ht - K[1]) * J + Et, Y = Math.abs(Gt - K[0]) * J + Ct, G = (K[3] - K[1]) * J, bt = (K[2] - K[0]) * J) : (ot = Math.abs(Gt - K[0]) * J + Et, Y = Math.abs(Ht - K[1]) * J + Ct, G = (K[2] - K[0]) * J, bt = (K[3] - K[1]) * J), this.transform = [Xt * J, Vt * J, Wt * J, $t * J, ot - Xt * J * Gt - Wt * J * Ht, Y - Vt * J * Gt - $t * J * Ht], this.width = G, this.height = bt;
+ }
+ get rawDims() {
+ const {
+ viewBox: K
+ } = this;
+ return (0, P.shadow)(this, "rawDims", {
+ pageWidth: K[2] - K[0],
+ pageHeight: K[3] - K[1],
+ pageX: K[0],
+ pageY: K[1]
+ });
+ }
+ clone({
+ scale: K = this.scale,
+ rotation: J = this.rotation,
+ offsetX: ht = this.offsetX,
+ offsetY: Et = this.offsetY,
+ dontFlip: Ct = !1
+ } = {}) {
+ return new x({
+ viewBox: this.viewBox.slice(),
+ scale: K,
+ rotation: J,
+ offsetX: ht,
+ offsetY: Et,
+ dontFlip: Ct
+ });
+ }
+ convertToViewportPoint(K, J) {
+ return P.Util.applyTransform([K, J], this.transform);
+ }
+ convertToViewportRectangle(K) {
+ const J = P.Util.applyTransform([K[0], K[1]], this.transform), ht = P.Util.applyTransform([K[2], K[3]], this.transform);
+ return [J[0], J[1], ht[0], ht[1]];
+ }
+ convertToPdfPoint(K, J) {
+ return P.Util.applyInverseTransform([K, J], this.transform);
+ }
+ }
+ d.PageViewport = x;
+ class v extends P.BaseException {
+ constructor(K, J = 0) {
+ super(K, "RenderingCancelledException"), this.extraDelay = J;
+ }
+ }
+ d.RenderingCancelledException = v;
+ function A(ft) {
+ const K = ft.length;
+ let J = 0;
+ for (; J < K && ft[J].trim() === ""; )
+ J++;
+ return ft.substring(J, J + 5).toLowerCase() === "data:";
+ }
+ function u(ft) {
+ return typeof ft == "string" && /\.pdf$/i.test(ft);
+ }
+ function _(ft, K = !1) {
+ return K || ([ft] = ft.split(/[#?]/, 1)), ft.substring(ft.lastIndexOf("/") + 1);
+ }
+ function w(ft, K = "document.pdf") {
+ if (typeof ft != "string")
+ return K;
+ if (A(ft))
+ return (0, P.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'), K;
+ const J = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/, ht = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i, Et = J.exec(ft);
+ let Ct = ht.exec(Et[1]) || ht.exec(Et[2]) || ht.exec(Et[3]);
+ if (Ct && (Ct = Ct[0], Ct.includes("%")))
+ try {
+ Ct = ht.exec(decodeURIComponent(Ct))[0];
+ } catch {
+ }
+ return Ct || K;
+ }
+ class C {
+ constructor() {
+ ee(this, "started", /* @__PURE__ */ Object.create(null));
+ ee(this, "times", []);
+ }
+ time(K) {
+ K in this.started && (0, P.warn)(`Timer is already running for ${K}`), this.started[K] = Date.now();
+ }
+ timeEnd(K) {
+ K in this.started || (0, P.warn)(`Timer has not been started for ${K}`), this.times.push({
+ name: K,
+ start: this.started[K],
+ end: Date.now()
+ }), delete this.started[K];
+ }
+ toString() {
+ const K = [];
+ let J = 0;
+ for (const {
+ name: ht
+ } of this.times)
+ J = Math.max(ht.length, J);
+ for (const {
+ name: ht,
+ start: Et,
+ end: Ct
+ } of this.times)
+ K.push(`${ht.padEnd(J)} ${Ct - Et}ms
+`);
+ return K.join("");
+ }
+ }
+ d.StatTimer = C;
+ function y(ft, K) {
+ try {
+ const {
+ protocol: J
+ } = K ? new URL(ft, K) : new URL(ft);
+ return J === "http:" || J === "https:";
+ } catch {
+ return !1;
+ }
+ }
+ function a(ft) {
+ ft.preventDefault();
+ }
+ function c(ft, K = !1) {
+ return new Promise((J, ht) => {
+ const Et = document.createElement("script");
+ Et.src = ft, Et.onload = function(Ct) {
+ K && Et.remove(), J(Ct);
+ }, Et.onerror = function() {
+ ht(new Error(`Cannot load script at: ${Et.src}`));
+ }, (document.head || document.documentElement).append(Et);
+ });
+ }
+ function k(ft) {
+ console.log("Deprecated API usage: " + ft);
+ }
+ let p;
+ class r {
+ static toDateObject(K) {
+ if (!K || typeof K != "string")
+ return null;
+ p || (p = new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));
+ const J = p.exec(K);
+ if (!J)
+ return null;
+ const ht = parseInt(J[1], 10);
+ let Et = parseInt(J[2], 10);
+ Et = Et >= 1 && Et <= 12 ? Et - 1 : 0;
+ let Ct = parseInt(J[3], 10);
+ Ct = Ct >= 1 && Ct <= 31 ? Ct : 1;
+ let jt = parseInt(J[4], 10);
+ jt = jt >= 0 && jt <= 23 ? jt : 0;
+ let Gt = parseInt(J[5], 10);
+ Gt = Gt >= 0 && Gt <= 59 ? Gt : 0;
+ let Ht = parseInt(J[6], 10);
+ Ht = Ht >= 0 && Ht <= 59 ? Ht : 0;
+ const Xt = J[7] || "Z";
+ let Vt = parseInt(J[8], 10);
+ Vt = Vt >= 0 && Vt <= 23 ? Vt : 0;
+ let Wt = parseInt(J[9], 10) || 0;
+ return Wt = Wt >= 0 && Wt <= 59 ? Wt : 0, Xt === "-" ? (jt += Vt, Gt += Wt) : Xt === "+" && (jt -= Vt, Gt -= Wt), new Date(Date.UTC(ht, Et, Ct, jt, Gt, Ht));
+ }
+ }
+ d.PDFDateString = r;
+ function T(ft, {
+ scale: K = 1,
+ rotation: J = 0
+ }) {
+ const {
+ width: ht,
+ height: Et
+ } = ft.attributes.style, Ct = [0, 0, parseInt(ht), parseInt(Et)];
+ return new x({
+ viewBox: Ct,
+ scale: K,
+ rotation: J
+ });
+ }
+ function m(ft) {
+ if (ft.startsWith("#")) {
+ const K = parseInt(ft.slice(1), 16);
+ return [(K & 16711680) >> 16, (K & 65280) >> 8, K & 255];
+ }
+ return ft.startsWith("rgb(") ? ft.slice(4, -1).split(",").map((K) => parseInt(K)) : ft.startsWith("rgba(") ? ft.slice(5, -1).split(",").map((K) => parseInt(K)).slice(0, 3) : ((0, P.warn)(`Not a valid color format: "${ft}"`), [0, 0, 0]);
+ }
+ function U(ft) {
+ const K = document.createElement("span");
+ K.style.visibility = "hidden", document.body.append(K);
+ for (const J of ft.keys()) {
+ K.style.color = J;
+ const ht = window.getComputedStyle(K).color;
+ ft.set(J, m(ht));
+ }
+ K.remove();
+ }
+ function z(ft) {
+ const {
+ a: K,
+ b: J,
+ c: ht,
+ d: Et,
+ e: Ct,
+ f: jt
+ } = ft.getTransform();
+ return [K, J, ht, Et, Ct, jt];
+ }
+ function E(ft) {
+ const {
+ a: K,
+ b: J,
+ c: ht,
+ d: Et,
+ e: Ct,
+ f: jt
+ } = ft.getTransform().invertSelf();
+ return [K, J, ht, Et, Ct, jt];
+ }
+ function V(ft, K, J = !1, ht = !0) {
+ if (K instanceof x) {
+ const {
+ pageWidth: Et,
+ pageHeight: Ct
+ } = K.rawDims, {
+ style: jt
+ } = ft, Gt = P.FeatureTest.isCSSRoundSupported, Ht = `var(--scale-factor) * ${Et}px`, Xt = `var(--scale-factor) * ${Ct}px`, Vt = Gt ? `round(${Ht}, 1px)` : `calc(${Ht})`, Wt = Gt ? `round(${Xt}, 1px)` : `calc(${Xt})`;
+ !J || K.rotation % 180 === 0 ? (jt.width = Vt, jt.height = Wt) : (jt.width = Wt, jt.height = Vt);
+ }
+ ht && ft.setAttribute("data-main-rotation", K.rotation);
+ }
+ },
+ /* 7 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.BaseStandardFontDataFactory = d.BaseSVGFactory = d.BaseFilterFactory = d.BaseCanvasFactory = d.BaseCMapReaderFactory = void 0;
+ var l = et(1);
+ class P {
+ constructor() {
+ this.constructor === P && (0, l.unreachable)("Cannot initialize BaseFilterFactory.");
+ }
+ addFilter(g) {
+ return "none";
+ }
+ addHCMFilter(g, O) {
+ return "none";
+ }
+ addHighlightHCMFilter(g, O, I, x) {
+ return "none";
+ }
+ destroy(g = !1) {
+ }
+ }
+ d.BaseFilterFactory = P;
+ class rt {
+ constructor() {
+ this.constructor === rt && (0, l.unreachable)("Cannot initialize BaseCanvasFactory.");
+ }
+ create(g, O) {
+ if (g <= 0 || O <= 0)
+ throw new Error("Invalid canvas size");
+ const I = this._createCanvas(g, O);
+ return {
+ canvas: I,
+ context: I.getContext("2d")
+ };
+ }
+ reset(g, O, I) {
+ if (!g.canvas)
+ throw new Error("Canvas is not specified");
+ if (O <= 0 || I <= 0)
+ throw new Error("Invalid canvas size");
+ g.canvas.width = O, g.canvas.height = I;
+ }
+ destroy(g) {
+ if (!g.canvas)
+ throw new Error("Canvas is not specified");
+ g.canvas.width = 0, g.canvas.height = 0, g.canvas = null, g.context = null;
+ }
+ _createCanvas(g, O) {
+ (0, l.unreachable)("Abstract method `_createCanvas` called.");
+ }
+ }
+ d.BaseCanvasFactory = rt;
+ class X {
+ constructor({
+ baseUrl: g = null,
+ isCompressed: O = !0
+ }) {
+ this.constructor === X && (0, l.unreachable)("Cannot initialize BaseCMapReaderFactory."), this.baseUrl = g, this.isCompressed = O;
+ }
+ async fetch({
+ name: g
+ }) {
+ if (!this.baseUrl)
+ throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');
+ if (!g)
+ throw new Error("CMap name must be specified.");
+ const O = this.baseUrl + g + (this.isCompressed ? ".bcmap" : ""), I = this.isCompressed ? l.CMapCompressionType.BINARY : l.CMapCompressionType.NONE;
+ return this._fetchData(O, I).catch((x) => {
+ throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${O}`);
+ });
+ }
+ _fetchData(g, O) {
+ (0, l.unreachable)("Abstract method `_fetchData` called.");
+ }
+ }
+ d.BaseCMapReaderFactory = X;
+ class pt {
+ constructor({
+ baseUrl: g = null
+ }) {
+ this.constructor === pt && (0, l.unreachable)("Cannot initialize BaseStandardFontDataFactory."), this.baseUrl = g;
+ }
+ async fetch({
+ filename: g
+ }) {
+ if (!this.baseUrl)
+ throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');
+ if (!g)
+ throw new Error("Font filename must be specified.");
+ const O = `${this.baseUrl}${g}`;
+ return this._fetchData(O).catch((I) => {
+ throw new Error(`Unable to load font data at: ${O}`);
+ });
+ }
+ _fetchData(g) {
+ (0, l.unreachable)("Abstract method `_fetchData` called.");
+ }
+ }
+ d.BaseStandardFontDataFactory = pt;
+ class B {
+ constructor() {
+ this.constructor === B && (0, l.unreachable)("Cannot initialize BaseSVGFactory.");
+ }
+ create(g, O, I = !1) {
+ if (g <= 0 || O <= 0)
+ throw new Error("Invalid SVG dimensions");
+ const x = this._createSVG("svg:svg");
+ return x.setAttribute("version", "1.1"), I || (x.setAttribute("width", `${g}px`), x.setAttribute("height", `${O}px`)), x.setAttribute("preserveAspectRatio", "none"), x.setAttribute("viewBox", `0 0 ${g} ${O}`), x;
+ }
+ createElement(g) {
+ if (typeof g != "string")
+ throw new Error("Invalid SVG element type");
+ return this._createSVG(g);
+ }
+ _createSVG(g) {
+ (0, l.unreachable)("Abstract method `_createSVG` called.");
+ }
+ }
+ d.BaseSVGFactory = B;
+ },
+ /* 8 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.MurmurHash3_64 = void 0;
+ var l = et(1);
+ const P = 3285377520, rt = 4294901760, X = 65535;
+ class pt {
+ constructor(F) {
+ this.h1 = F ? F & 4294967295 : P, this.h2 = F ? F & 4294967295 : P;
+ }
+ update(F) {
+ let g, O;
+ if (typeof F == "string") {
+ g = new Uint8Array(F.length * 2), O = 0;
+ for (let k = 0, p = F.length; k < p; k++) {
+ const r = F.charCodeAt(k);
+ r <= 255 ? g[O++] = r : (g[O++] = r >>> 8, g[O++] = r & 255);
+ }
+ } else if ((0, l.isArrayBuffer)(F))
+ g = F.slice(), O = g.byteLength;
+ else
+ throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");
+ const I = O >> 2, x = O - I * 4, v = new Uint32Array(g.buffer, 0, I);
+ let A = 0, u = 0, _ = this.h1, w = this.h2;
+ const C = 3432918353, y = 461845907, a = C & X, c = y & X;
+ for (let k = 0; k < I; k++)
+ k & 1 ? (A = v[k], A = A * C & rt | A * a & X, A = A << 15 | A >>> 17, A = A * y & rt | A * c & X, _ ^= A, _ = _ << 13 | _ >>> 19, _ = _ * 5 + 3864292196) : (u = v[k], u = u * C & rt | u * a & X, u = u << 15 | u >>> 17, u = u * y & rt | u * c & X, w ^= u, w = w << 13 | w >>> 19, w = w * 5 + 3864292196);
+ switch (A = 0, x) {
+ case 3:
+ A ^= g[I * 4 + 2] << 16;
+ case 2:
+ A ^= g[I * 4 + 1] << 8;
+ case 1:
+ A ^= g[I * 4], A = A * C & rt | A * a & X, A = A << 15 | A >>> 17, A = A * y & rt | A * c & X, I & 1 ? _ ^= A : w ^= A;
+ }
+ this.h1 = _, this.h2 = w;
+ }
+ hexdigest() {
+ let F = this.h1, g = this.h2;
+ return F ^= g >>> 1, F = F * 3981806797 & rt | F * 36045 & X, g = g * 4283543511 & rt | ((g << 16 | F >>> 16) * 2950163797 & rt) >>> 16, F ^= g >>> 1, F = F * 444984403 & rt | F * 60499 & X, g = g * 3301882366 & rt | ((g << 16 | F >>> 16) * 3120437893 & rt) >>> 16, F ^= g >>> 1, (F >>> 0).toString(16).padStart(8, "0") + (g >>> 0).toString(16).padStart(8, "0");
+ }
+ }
+ d.MurmurHash3_64 = pt;
+ },
+ /* 9 */
+ /***/
+ (dt, d, et) => {
+ var X;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.FontLoader = d.FontFaceObject = void 0;
+ var l = et(1);
+ class P {
+ constructor({
+ ownerDocument: B = globalThis.document,
+ styleElement: F = null
+ }) {
+ L(this, X, /* @__PURE__ */ new Set());
+ this._document = B, this.nativeFontFaces = /* @__PURE__ */ new Set(), this.styleElement = null, this.loadingRequests = [], this.loadTestFontId = 0;
+ }
+ addNativeFontFace(B) {
+ this.nativeFontFaces.add(B), this._document.fonts.add(B);
+ }
+ removeNativeFontFace(B) {
+ this.nativeFontFaces.delete(B), this._document.fonts.delete(B);
+ }
+ insertRule(B) {
+ this.styleElement || (this.styleElement = this._document.createElement("style"), this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));
+ const F = this.styleElement.sheet;
+ F.insertRule(B, F.cssRules.length);
+ }
+ clear() {
+ for (const B of this.nativeFontFaces)
+ this._document.fonts.delete(B);
+ this.nativeFontFaces.clear(), t(this, X).clear(), this.styleElement && (this.styleElement.remove(), this.styleElement = null);
+ }
+ async loadSystemFont(B) {
+ if (!(!B || t(this, X).has(B.loadedName))) {
+ if ((0, l.assert)(!this.disableFontFace, "loadSystemFont shouldn't be called when `disableFontFace` is set."), this.isFontLoadingAPISupported) {
+ const {
+ loadedName: F,
+ src: g,
+ style: O
+ } = B, I = new FontFace(F, g, O);
+ this.addNativeFontFace(I);
+ try {
+ await I.load(), t(this, X).add(F);
+ } catch {
+ (0, l.warn)(`Cannot load system font: ${B.baseFontName}, installing it could help to improve PDF rendering.`), this.removeNativeFontFace(I);
+ }
+ return;
+ }
+ (0, l.unreachable)("Not implemented: loadSystemFont without the Font Loading API.");
+ }
+ }
+ async bind(B) {
+ if (B.attached || B.missingFile && !B.systemFontInfo)
+ return;
+ if (B.attached = !0, B.systemFontInfo) {
+ await this.loadSystemFont(B.systemFontInfo);
+ return;
+ }
+ if (this.isFontLoadingAPISupported) {
+ const g = B.createNativeFontFace();
+ if (g) {
+ this.addNativeFontFace(g);
+ try {
+ await g.loaded;
+ } catch (O) {
+ throw (0, l.warn)(`Failed to load font '${g.family}': '${O}'.`), B.disableFontFace = !0, O;
+ }
+ }
+ return;
+ }
+ const F = B.createFontFaceRule();
+ if (F) {
+ if (this.insertRule(F), this.isSyncFontLoadingSupported)
+ return;
+ await new Promise((g) => {
+ const O = this._queueLoadingCallback(g);
+ this._prepareFontLoadEvent(B, O);
+ });
+ }
+ }
+ get isFontLoadingAPISupported() {
+ var F;
+ const B = !!((F = this._document) != null && F.fonts);
+ return (0, l.shadow)(this, "isFontLoadingAPISupported", B);
+ }
+ get isSyncFontLoadingSupported() {
+ let B = !1;
+ return (l.isNodeJS || typeof navigator < "u" && /Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)) && (B = !0), (0, l.shadow)(this, "isSyncFontLoadingSupported", B);
+ }
+ _queueLoadingCallback(B) {
+ function F() {
+ for ((0, l.assert)(!O.done, "completeRequest() cannot be called twice."), O.done = !0; g.length > 0 && g[0].done; ) {
+ const I = g.shift();
+ setTimeout(I.callback, 0);
+ }
+ }
+ const {
+ loadingRequests: g
+ } = this, O = {
+ done: !1,
+ complete: F,
+ callback: B
+ };
+ return g.push(O), O;
+ }
+ get _loadTestFont() {
+ const B = atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");
+ return (0, l.shadow)(this, "_loadTestFont", B);
+ }
+ _prepareFontLoadEvent(B, F) {
+ function g(m, U) {
+ return m.charCodeAt(U) << 24 | m.charCodeAt(U + 1) << 16 | m.charCodeAt(U + 2) << 8 | m.charCodeAt(U + 3) & 255;
+ }
+ function O(m, U, z, E) {
+ const V = m.substring(0, U), st = m.substring(U + z);
+ return V + E + st;
+ }
+ let I, x;
+ const v = this._document.createElement("canvas");
+ v.width = 1, v.height = 1;
+ const A = v.getContext("2d");
+ let u = 0;
+ function _(m, U) {
+ if (++u > 30) {
+ (0, l.warn)("Load test font never loaded."), U();
+ return;
+ }
+ if (A.font = "30px " + m, A.fillText(".", 0, 20), A.getImageData(0, 0, 1, 1).data[3] > 0) {
+ U();
+ return;
+ }
+ setTimeout(_.bind(null, m, U));
+ }
+ const w = `lt${Date.now()}${this.loadTestFontId++}`;
+ let C = this._loadTestFont;
+ C = O(C, 976, w.length, w);
+ const a = 16, c = 1482184792;
+ let k = g(C, a);
+ for (I = 0, x = w.length - 3; I < x; I += 4)
+ k = k - c + g(w, I) | 0;
+ I < w.length && (k = k - c + g(w + "XXX", I) | 0), C = O(C, a, 4, (0, l.string32)(k));
+ const p = `url(data:font/opentype;base64,${btoa(C)});`, r = `@font-face {font-family:"${w}";src:${p}}`;
+ this.insertRule(r);
+ const T = this._document.createElement("div");
+ T.style.visibility = "hidden", T.style.width = T.style.height = "10px", T.style.position = "absolute", T.style.top = T.style.left = "0px";
+ for (const m of [B.loadedName, w]) {
+ const U = this._document.createElement("span");
+ U.textContent = "Hi", U.style.fontFamily = m, T.append(U);
+ }
+ this._document.body.append(T), _(w, () => {
+ T.remove(), F.complete();
+ });
+ }
+ }
+ X = new WeakMap(), d.FontLoader = P;
+ class rt {
+ constructor(B, {
+ isEvalSupported: F = !0,
+ disableFontFace: g = !1,
+ ignoreErrors: O = !1,
+ inspectFont: I = null
+ }) {
+ this.compiledGlyphs = /* @__PURE__ */ Object.create(null);
+ for (const x in B)
+ this[x] = B[x];
+ this.isEvalSupported = F !== !1, this.disableFontFace = g === !0, this.ignoreErrors = O === !0, this._inspectFont = I;
+ }
+ createNativeFontFace() {
+ var F;
+ if (!this.data || this.disableFontFace)
+ return null;
+ let B;
+ if (!this.cssFontInfo)
+ B = new FontFace(this.loadedName, this.data, {});
+ else {
+ const g = {
+ weight: this.cssFontInfo.fontWeight
+ };
+ this.cssFontInfo.italicAngle && (g.style = `oblique ${this.cssFontInfo.italicAngle}deg`), B = new FontFace(this.cssFontInfo.fontFamily, this.data, g);
+ }
+ return (F = this._inspectFont) == null || F.call(this, this), B;
+ }
+ createFontFaceRule() {
+ var O;
+ if (!this.data || this.disableFontFace)
+ return null;
+ const B = (0, l.bytesToString)(this.data), F = `url(data:${this.mimetype};base64,${btoa(B)});`;
+ let g;
+ if (!this.cssFontInfo)
+ g = `@font-face {font-family:"${this.loadedName}";src:${F}}`;
+ else {
+ let I = `font-weight: ${this.cssFontInfo.fontWeight};`;
+ this.cssFontInfo.italicAngle && (I += `font-style: oblique ${this.cssFontInfo.italicAngle}deg;`), g = `@font-face {font-family:"${this.cssFontInfo.fontFamily}";${I}src:${F}}`;
+ }
+ return (O = this._inspectFont) == null || O.call(this, this, F), g;
+ }
+ getPathGenerator(B, F) {
+ if (this.compiledGlyphs[F] !== void 0)
+ return this.compiledGlyphs[F];
+ let g;
+ try {
+ g = B.get(this.loadedName + "_path_" + F);
+ } catch (O) {
+ if (!this.ignoreErrors)
+ throw O;
+ return (0, l.warn)(`getPathGenerator - ignoring character: "${O}".`), this.compiledGlyphs[F] = function(I, x) {
+ };
+ }
+ if (this.isEvalSupported && l.FeatureTest.isEvalSupported) {
+ const O = [];
+ for (const I of g) {
+ const x = I.args !== void 0 ? I.args.join(",") : "";
+ O.push("c.", I.cmd, "(", x, `);
+`);
+ }
+ return this.compiledGlyphs[F] = new Function("c", "size", O.join(""));
+ }
+ return this.compiledGlyphs[F] = function(O, I) {
+ for (const x of g)
+ x.cmd === "scale" && (x.args = [I, -I]), O[x.cmd].apply(O, x.args);
+ };
+ }
+ }
+ d.FontFaceObject = rt;
+ },
+ /* 10 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.NodeStandardFontDataFactory = d.NodeFilterFactory = d.NodeCanvasFactory = d.NodeCMapReaderFactory = void 0;
+ var l = et(7);
+ et(1);
+ const P = function(F) {
+ return new Promise((g, O) => {
+ require$$5.readFile(F, (x, v) => {
+ if (x || !v) {
+ O(new Error(x));
+ return;
+ }
+ g(new Uint8Array(v));
+ });
+ });
+ };
+ class rt extends l.BaseFilterFactory {
+ }
+ d.NodeFilterFactory = rt;
+ class X extends l.BaseCanvasFactory {
+ _createCanvas(g, O) {
+ return require$$5.createCanvas(g, O);
+ }
+ }
+ d.NodeCanvasFactory = X;
+ class pt extends l.BaseCMapReaderFactory {
+ _fetchData(g, O) {
+ return P(g).then((I) => ({
+ cMapData: I,
+ compressionType: O
+ }));
+ }
+ }
+ d.NodeCMapReaderFactory = pt;
+ class B extends l.BaseStandardFontDataFactory {
+ _fetchData(g) {
+ return P(g);
+ }
+ }
+ d.NodeStandardFontDataFactory = B;
+ },
+ /* 11 */
+ /***/
+ (dt, d, et) => {
+ var H, Qe, gt, Ze;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.CanvasGraphics = void 0;
+ var l = et(1), P = et(6), rt = et(12), X = et(13);
+ const pt = 16, B = 100, F = 4096, g = 15, O = 10, I = 1e3, x = 16;
+ function v(S, i) {
+ if (S._removeMirroring)
+ throw new Error("Context is already forwarding operations.");
+ S.__originalSave = S.save, S.__originalRestore = S.restore, S.__originalRotate = S.rotate, S.__originalScale = S.scale, S.__originalTranslate = S.translate, S.__originalTransform = S.transform, S.__originalSetTransform = S.setTransform, S.__originalResetTransform = S.resetTransform, S.__originalClip = S.clip, S.__originalMoveTo = S.moveTo, S.__originalLineTo = S.lineTo, S.__originalBezierCurveTo = S.bezierCurveTo, S.__originalRect = S.rect, S.__originalClosePath = S.closePath, S.__originalBeginPath = S.beginPath, S._removeMirroring = () => {
+ S.save = S.__originalSave, S.restore = S.__originalRestore, S.rotate = S.__originalRotate, S.scale = S.__originalScale, S.translate = S.__originalTranslate, S.transform = S.__originalTransform, S.setTransform = S.__originalSetTransform, S.resetTransform = S.__originalResetTransform, S.clip = S.__originalClip, S.moveTo = S.__originalMoveTo, S.lineTo = S.__originalLineTo, S.bezierCurveTo = S.__originalBezierCurveTo, S.rect = S.__originalRect, S.closePath = S.__originalClosePath, S.beginPath = S.__originalBeginPath, delete S._removeMirroring;
+ }, S.save = function() {
+ i.save(), this.__originalSave();
+ }, S.restore = function() {
+ i.restore(), this.__originalRestore();
+ }, S.translate = function(s, o) {
+ i.translate(s, o), this.__originalTranslate(s, o);
+ }, S.scale = function(s, o) {
+ i.scale(s, o), this.__originalScale(s, o);
+ }, S.transform = function(s, o, h, b, M, N) {
+ i.transform(s, o, h, b, M, N), this.__originalTransform(s, o, h, b, M, N);
+ }, S.setTransform = function(s, o, h, b, M, N) {
+ i.setTransform(s, o, h, b, M, N), this.__originalSetTransform(s, o, h, b, M, N);
+ }, S.resetTransform = function() {
+ i.resetTransform(), this.__originalResetTransform();
+ }, S.rotate = function(s) {
+ i.rotate(s), this.__originalRotate(s);
+ }, S.clip = function(s) {
+ i.clip(s), this.__originalClip(s);
+ }, S.moveTo = function(n, s) {
+ i.moveTo(n, s), this.__originalMoveTo(n, s);
+ }, S.lineTo = function(n, s) {
+ i.lineTo(n, s), this.__originalLineTo(n, s);
+ }, S.bezierCurveTo = function(n, s, o, h, b, M) {
+ i.bezierCurveTo(n, s, o, h, b, M), this.__originalBezierCurveTo(n, s, o, h, b, M);
+ }, S.rect = function(n, s, o, h) {
+ i.rect(n, s, o, h), this.__originalRect(n, s, o, h);
+ }, S.closePath = function() {
+ i.closePath(), this.__originalClosePath();
+ }, S.beginPath = function() {
+ i.beginPath(), this.__originalBeginPath();
+ };
+ }
+ class A {
+ constructor(i) {
+ this.canvasFactory = i, this.cache = /* @__PURE__ */ Object.create(null);
+ }
+ getCanvas(i, n, s) {
+ let o;
+ return this.cache[i] !== void 0 ? (o = this.cache[i], this.canvasFactory.reset(o, n, s)) : (o = this.canvasFactory.create(n, s), this.cache[i] = o), o;
+ }
+ delete(i) {
+ delete this.cache[i];
+ }
+ clear() {
+ for (const i in this.cache) {
+ const n = this.cache[i];
+ this.canvasFactory.destroy(n), delete this.cache[i];
+ }
+ }
+ }
+ function u(S, i, n, s, o, h, b, M, N, tt) {
+ const [Q, nt, ct, yt, ut, Ft] = (0, P.getCurrentTransform)(S);
+ if (nt === 0 && ct === 0) {
+ const Dt = b * Q + ut, ft = Math.round(Dt), K = M * yt + Ft, J = Math.round(K), ht = (b + N) * Q + ut, Et = Math.abs(Math.round(ht) - ft) || 1, Ct = (M + tt) * yt + Ft, jt = Math.abs(Math.round(Ct) - J) || 1;
+ return S.setTransform(Math.sign(Q), 0, 0, Math.sign(yt), ft, J), S.drawImage(i, n, s, o, h, 0, 0, Et, jt), S.setTransform(Q, nt, ct, yt, ut, Ft), [Et, jt];
+ }
+ if (Q === 0 && yt === 0) {
+ const Dt = M * ct + ut, ft = Math.round(Dt), K = b * nt + Ft, J = Math.round(K), ht = (M + tt) * ct + ut, Et = Math.abs(Math.round(ht) - ft) || 1, Ct = (b + N) * nt + Ft, jt = Math.abs(Math.round(Ct) - J) || 1;
+ return S.setTransform(0, Math.sign(nt), Math.sign(ct), 0, ft, J), S.drawImage(i, n, s, o, h, 0, 0, jt, Et), S.setTransform(Q, nt, ct, yt, ut, Ft), [jt, Et];
+ }
+ S.drawImage(i, n, s, o, h, b, M, N, tt);
+ const Bt = Math.hypot(Q, nt), St = Math.hypot(ct, yt);
+ return [Bt * N, St * tt];
+ }
+ function _(S) {
+ const {
+ width: i,
+ height: n
+ } = S;
+ if (i > I || n > I)
+ return null;
+ const s = 1e3, o = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]), h = i + 1;
+ let b = new Uint8Array(h * (n + 1)), M, N, tt;
+ const Q = i + 7 & -8;
+ let nt = new Uint8Array(Q * n), ct = 0;
+ for (const St of S.data) {
+ let Dt = 128;
+ for (; Dt > 0; )
+ nt[ct++] = St & Dt ? 0 : 255, Dt >>= 1;
+ }
+ let yt = 0;
+ for (ct = 0, nt[ct] !== 0 && (b[0] = 1, ++yt), N = 1; N < i; N++)
+ nt[ct] !== nt[ct + 1] && (b[N] = nt[ct] ? 2 : 1, ++yt), ct++;
+ for (nt[ct] !== 0 && (b[N] = 2, ++yt), M = 1; M < n; M++) {
+ ct = M * Q, tt = M * h, nt[ct - Q] !== nt[ct] && (b[tt] = nt[ct] ? 1 : 8, ++yt);
+ let St = (nt[ct] ? 4 : 0) + (nt[ct - Q] ? 8 : 0);
+ for (N = 1; N < i; N++)
+ St = (St >> 2) + (nt[ct + 1] ? 4 : 0) + (nt[ct - Q + 1] ? 8 : 0), o[St] && (b[tt + N] = o[St], ++yt), ct++;
+ if (nt[ct - Q] !== nt[ct] && (b[tt + N] = nt[ct] ? 2 : 4, ++yt), yt > s)
+ return null;
+ }
+ for (ct = Q * (n - 1), tt = M * h, nt[ct] !== 0 && (b[tt] = 8, ++yt), N = 1; N < i; N++)
+ nt[ct] !== nt[ct + 1] && (b[tt + N] = nt[ct] ? 4 : 8, ++yt), ct++;
+ if (nt[ct] !== 0 && (b[tt + N] = 4, ++yt), yt > s)
+ return null;
+ const ut = new Int32Array([0, h, -1, 0, -h, 0, 0, 0, 1]), Ft = new Path2D();
+ for (M = 0; yt && M <= n; M++) {
+ let St = M * h;
+ const Dt = St + i;
+ for (; St < Dt && !b[St]; )
+ St++;
+ if (St === Dt)
+ continue;
+ Ft.moveTo(St % h, M);
+ const ft = St;
+ let K = b[St];
+ do {
+ const J = ut[K];
+ do
+ St += J;
+ while (!b[St]);
+ const ht = b[St];
+ ht !== 5 && ht !== 10 ? (K = ht, b[St] = 0) : (K = ht & 51 * K >> 4, b[St] &= K >> 2 | K << 2), Ft.lineTo(St % h, St / h | 0), b[St] || --yt;
+ } while (ft !== St);
+ --M;
+ }
+ return nt = null, b = null, function(St) {
+ St.save(), St.scale(1 / i, -1 / n), St.translate(0, -n), St.fill(Ft), St.beginPath(), St.restore();
+ };
+ }
+ class w {
+ constructor(i, n) {
+ this.alphaIsShape = !1, this.fontSize = 0, this.fontSizeScale = 1, this.textMatrix = l.IDENTITY_MATRIX, this.textMatrixScale = 1, this.fontMatrix = l.FONT_IDENTITY_MATRIX, this.leading = 0, this.x = 0, this.y = 0, this.lineX = 0, this.lineY = 0, this.charSpacing = 0, this.wordSpacing = 0, this.textHScale = 1, this.textRenderingMode = l.TextRenderingMode.FILL, this.textRise = 0, this.fillColor = "#000000", this.strokeColor = "#000000", this.patternFill = !1, this.fillAlpha = 1, this.strokeAlpha = 1, this.lineWidth = 1, this.activeSMask = null, this.transferMaps = "none", this.startNewPathAndClipBox([0, 0, i, n]);
+ }
+ clone() {
+ const i = Object.create(this);
+ return i.clipBox = this.clipBox.slice(), i;
+ }
+ setCurrentPoint(i, n) {
+ this.x = i, this.y = n;
+ }
+ updatePathMinMax(i, n, s) {
+ [n, s] = l.Util.applyTransform([n, s], i), this.minX = Math.min(this.minX, n), this.minY = Math.min(this.minY, s), this.maxX = Math.max(this.maxX, n), this.maxY = Math.max(this.maxY, s);
+ }
+ updateRectMinMax(i, n) {
+ const s = l.Util.applyTransform(n, i), o = l.Util.applyTransform(n.slice(2), i);
+ this.minX = Math.min(this.minX, s[0], o[0]), this.minY = Math.min(this.minY, s[1], o[1]), this.maxX = Math.max(this.maxX, s[0], o[0]), this.maxY = Math.max(this.maxY, s[1], o[1]);
+ }
+ updateScalingPathMinMax(i, n) {
+ l.Util.scaleMinMax(i, n), this.minX = Math.min(this.minX, n[0]), this.maxX = Math.max(this.maxX, n[1]), this.minY = Math.min(this.minY, n[2]), this.maxY = Math.max(this.maxY, n[3]);
+ }
+ updateCurvePathMinMax(i, n, s, o, h, b, M, N, tt, Q) {
+ const nt = l.Util.bezierBoundingBox(n, s, o, h, b, M, N, tt);
+ if (Q) {
+ Q[0] = Math.min(Q[0], nt[0], nt[2]), Q[1] = Math.max(Q[1], nt[0], nt[2]), Q[2] = Math.min(Q[2], nt[1], nt[3]), Q[3] = Math.max(Q[3], nt[1], nt[3]);
+ return;
+ }
+ this.updateRectMinMax(i, nt);
+ }
+ getPathBoundingBox(i = rt.PathType.FILL, n = null) {
+ const s = [this.minX, this.minY, this.maxX, this.maxY];
+ if (i === rt.PathType.STROKE) {
+ n || (0, l.unreachable)("Stroke bounding box must include transform.");
+ const o = l.Util.singularValueDecompose2dScale(n), h = o[0] * this.lineWidth / 2, b = o[1] * this.lineWidth / 2;
+ s[0] -= h, s[1] -= b, s[2] += h, s[3] += b;
+ }
+ return s;
+ }
+ updateClipFromPath() {
+ const i = l.Util.intersect(this.clipBox, this.getPathBoundingBox());
+ this.startNewPathAndClipBox(i || [0, 0, 0, 0]);
+ }
+ isEmptyClip() {
+ return this.minX === 1 / 0;
+ }
+ startNewPathAndClipBox(i) {
+ this.clipBox = i, this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = 0, this.maxY = 0;
+ }
+ getClippedPathBoundingBox(i = rt.PathType.FILL, n = null) {
+ return l.Util.intersect(this.clipBox, this.getPathBoundingBox(i, n));
+ }
+ }
+ function C(S, i) {
+ if (typeof ImageData < "u" && i instanceof ImageData) {
+ S.putImageData(i, 0, 0);
+ return;
+ }
+ const n = i.height, s = i.width, o = n % x, h = (n - o) / x, b = o === 0 ? h : h + 1, M = S.createImageData(s, x);
+ let N = 0, tt;
+ const Q = i.data, nt = M.data;
+ let ct, yt, ut, Ft;
+ if (i.kind === l.ImageKind.GRAYSCALE_1BPP) {
+ const Bt = Q.byteLength, St = new Uint32Array(nt.buffer, 0, nt.byteLength >> 2), Dt = St.length, ft = s + 7 >> 3, K = 4294967295, J = l.FeatureTest.isLittleEndian ? 4278190080 : 255;
+ for (ct = 0; ct < b; ct++) {
+ for (ut = ct < h ? x : o, tt = 0, yt = 0; yt < ut; yt++) {
+ const ht = Bt - N;
+ let Et = 0;
+ const Ct = ht > ft ? s : ht * 8 - 7, jt = Ct & -8;
+ let Gt = 0, Ht = 0;
+ for (; Et < jt; Et += 8)
+ Ht = Q[N++], St[tt++] = Ht & 128 ? K : J, St[tt++] = Ht & 64 ? K : J, St[tt++] = Ht & 32 ? K : J, St[tt++] = Ht & 16 ? K : J, St[tt++] = Ht & 8 ? K : J, St[tt++] = Ht & 4 ? K : J, St[tt++] = Ht & 2 ? K : J, St[tt++] = Ht & 1 ? K : J;
+ for (; Et < Ct; Et++)
+ Gt === 0 && (Ht = Q[N++], Gt = 128), St[tt++] = Ht & Gt ? K : J, Gt >>= 1;
+ }
+ for (; tt < Dt; )
+ St[tt++] = 0;
+ S.putImageData(M, 0, ct * x);
+ }
+ } else if (i.kind === l.ImageKind.RGBA_32BPP) {
+ for (yt = 0, Ft = s * x * 4, ct = 0; ct < h; ct++)
+ nt.set(Q.subarray(N, N + Ft)), N += Ft, S.putImageData(M, 0, yt), yt += x;
+ ct < b && (Ft = s * o * 4, nt.set(Q.subarray(N, N + Ft)), S.putImageData(M, 0, yt));
+ } else if (i.kind === l.ImageKind.RGB_24BPP)
+ for (ut = x, Ft = s * ut, ct = 0; ct < b; ct++) {
+ for (ct >= h && (ut = o, Ft = s * ut), tt = 0, yt = Ft; yt--; )
+ nt[tt++] = Q[N++], nt[tt++] = Q[N++], nt[tt++] = Q[N++], nt[tt++] = 255;
+ S.putImageData(M, 0, ct * x);
+ }
+ else
+ throw new Error(`bad image kind: ${i.kind}`);
+ }
+ function y(S, i) {
+ if (i.bitmap) {
+ S.drawImage(i.bitmap, 0, 0);
+ return;
+ }
+ const n = i.height, s = i.width, o = n % x, h = (n - o) / x, b = o === 0 ? h : h + 1, M = S.createImageData(s, x);
+ let N = 0;
+ const tt = i.data, Q = M.data;
+ for (let nt = 0; nt < b; nt++) {
+ const ct = nt < h ? x : o;
+ ({
+ srcPos: N
+ } = (0, X.convertBlackAndWhiteToRGBA)({
+ src: tt,
+ srcPos: N,
+ dest: Q,
+ width: s,
+ height: ct,
+ nonBlackColor: 0
+ })), S.putImageData(M, 0, nt * x);
+ }
+ }
+ function a(S, i) {
+ const n = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font", "filter"];
+ for (const s of n)
+ S[s] !== void 0 && (i[s] = S[s]);
+ S.setLineDash !== void 0 && (i.setLineDash(S.getLineDash()), i.lineDashOffset = S.lineDashOffset);
+ }
+ function c(S) {
+ if (S.strokeStyle = S.fillStyle = "#000000", S.fillRule = "nonzero", S.globalAlpha = 1, S.lineWidth = 1, S.lineCap = "butt", S.lineJoin = "miter", S.miterLimit = 10, S.globalCompositeOperation = "source-over", S.font = "10px sans-serif", S.setLineDash !== void 0 && (S.setLineDash([]), S.lineDashOffset = 0), !l.isNodeJS) {
+ const {
+ filter: i
+ } = S;
+ i !== "none" && i !== "" && (S.filter = "none");
+ }
+ }
+ function k(S, i, n, s) {
+ const o = S.length;
+ for (let h = 3; h < o; h += 4) {
+ const b = S[h];
+ if (b === 0)
+ S[h - 3] = i, S[h - 2] = n, S[h - 1] = s;
+ else if (b < 255) {
+ const M = 255 - b;
+ S[h - 3] = S[h - 3] * b + i * M >> 8, S[h - 2] = S[h - 2] * b + n * M >> 8, S[h - 1] = S[h - 1] * b + s * M >> 8;
+ }
+ }
+ }
+ function p(S, i, n) {
+ const s = S.length, o = 1 / 255;
+ for (let h = 3; h < s; h += 4) {
+ const b = n ? n[S[h]] : S[h];
+ i[h] = i[h] * b * o | 0;
+ }
+ }
+ function r(S, i, n) {
+ const s = S.length;
+ for (let o = 3; o < s; o += 4) {
+ const h = S[o - 3] * 77 + S[o - 2] * 152 + S[o - 1] * 28;
+ i[o] = n ? i[o] * n[h >> 8] >> 8 : i[o] * h >> 16;
+ }
+ }
+ function T(S, i, n, s, o, h, b, M, N, tt, Q) {
+ const nt = !!h, ct = nt ? h[0] : 0, yt = nt ? h[1] : 0, ut = nt ? h[2] : 0, Ft = o === "Luminosity" ? r : p, St = Math.min(s, Math.ceil(1048576 / n));
+ for (let Dt = 0; Dt < s; Dt += St) {
+ const ft = Math.min(St, s - Dt), K = S.getImageData(M - tt, Dt + (N - Q), n, ft), J = i.getImageData(M, Dt + N, n, ft);
+ nt && k(K.data, ct, yt, ut), Ft(K.data, J.data, b), i.putImageData(J, M, Dt + N);
+ }
+ }
+ function m(S, i, n, s) {
+ const o = s[0], h = s[1], b = s[2] - o, M = s[3] - h;
+ b === 0 || M === 0 || (T(i.context, n, b, M, i.subtype, i.backdrop, i.transferMap, o, h, i.offsetX, i.offsetY), S.save(), S.globalAlpha = 1, S.globalCompositeOperation = "source-over", S.setTransform(1, 0, 0, 1, 0, 0), S.drawImage(n.canvas, 0, 0), S.restore());
+ }
+ function U(S, i) {
+ const n = l.Util.singularValueDecompose2dScale(S);
+ n[0] = Math.fround(n[0]), n[1] = Math.fround(n[1]);
+ const s = Math.fround((globalThis.devicePixelRatio || 1) * P.PixelsPerInch.PDF_TO_CSS_UNITS);
+ return i !== void 0 ? i : n[0] <= s || n[1] <= s;
+ }
+ const z = ["butt", "round", "square"], E = ["miter", "round", "bevel"], V = {}, st = {}, xt = class xt {
+ constructor(i, n, s, o, h, {
+ optionalContentConfig: b,
+ markedContentStack: M = null
+ }, N, tt) {
+ L(this, H);
+ L(this, gt);
+ this.ctx = i, this.current = new w(this.ctx.canvas.width, this.ctx.canvas.height), this.stateStack = [], this.pendingClip = null, this.pendingEOFill = !1, this.res = null, this.xobjs = null, this.commonObjs = n, this.objs = s, this.canvasFactory = o, this.filterFactory = h, this.groupStack = [], this.processingType3 = null, this.baseTransform = null, this.baseTransformStack = [], this.groupLevel = 0, this.smaskStack = [], this.smaskCounter = 0, this.tempSMask = null, this.suspendedCtx = null, this.contentVisible = !0, this.markedContentStack = M || [], this.optionalContentConfig = b, this.cachedCanvases = new A(this.canvasFactory), this.cachedPatterns = /* @__PURE__ */ new Map(), this.annotationCanvasMap = N, this.viewportScale = 1, this.outputScaleX = 1, this.outputScaleY = 1, this.pageColors = tt, this._cachedScaleForStroking = [-1, 0], this._cachedGetSinglePixelWidth = null, this._cachedBitmapsMap = /* @__PURE__ */ new Map();
+ }
+ getObject(i, n = null) {
+ return typeof i == "string" ? i.startsWith("g_") ? this.commonObjs.get(i) : this.objs.get(i) : n;
+ }
+ beginDrawing({
+ transform: i,
+ viewport: n,
+ transparency: s = !1,
+ background: o = null
+ }) {
+ const h = this.ctx.canvas.width, b = this.ctx.canvas.height, M = this.ctx.fillStyle;
+ if (this.ctx.fillStyle = o || "#ffffff", this.ctx.fillRect(0, 0, h, b), this.ctx.fillStyle = M, s) {
+ const N = this.cachedCanvases.getCanvas("transparent", h, b);
+ this.compositeCtx = this.ctx, this.transparentCanvas = N.canvas, this.ctx = N.context, this.ctx.save(), this.ctx.transform(...(0, P.getCurrentTransform)(this.compositeCtx));
+ }
+ this.ctx.save(), c(this.ctx), i && (this.ctx.transform(...i), this.outputScaleX = i[0], this.outputScaleY = i[0]), this.ctx.transform(...n.transform), this.viewportScale = n.scale, this.baseTransform = (0, P.getCurrentTransform)(this.ctx);
+ }
+ executeOperatorList(i, n, s, o) {
+ const h = i.argsArray, b = i.fnArray;
+ let M = n || 0;
+ const N = h.length;
+ if (N === M)
+ return M;
+ const tt = N - M > O && typeof s == "function", Q = tt ? Date.now() + g : 0;
+ let nt = 0;
+ const ct = this.commonObjs, yt = this.objs;
+ let ut;
+ for (; ; ) {
+ if (o !== void 0 && M === o.nextBreakPoint)
+ return o.breakIt(M, s), M;
+ if (ut = b[M], ut !== l.OPS.dependency)
+ this[ut].apply(this, h[M]);
+ else
+ for (const Ft of h[M]) {
+ const Bt = Ft.startsWith("g_") ? ct : yt;
+ if (!Bt.has(Ft))
+ return Bt.get(Ft, s), M;
+ }
+ if (M++, M === N)
+ return M;
+ if (tt && ++nt > O) {
+ if (Date.now() > Q)
+ return s(), M;
+ nt = 0;
+ }
+ }
+ }
+ endDrawing() {
+ W(this, H, Qe).call(this), this.cachedCanvases.clear(), this.cachedPatterns.clear();
+ for (const i of this._cachedBitmapsMap.values()) {
+ for (const n of i.values())
+ typeof HTMLCanvasElement < "u" && n instanceof HTMLCanvasElement && (n.width = n.height = 0);
+ i.clear();
+ }
+ this._cachedBitmapsMap.clear(), W(this, gt, Ze).call(this);
+ }
+ _scaleImage(i, n) {
+ const s = i.width, o = i.height;
+ let h = Math.max(Math.hypot(n[0], n[1]), 1), b = Math.max(Math.hypot(n[2], n[3]), 1), M = s, N = o, tt = "prescale1", Q, nt;
+ for (; h > 2 && M > 1 || b > 2 && N > 1; ) {
+ let ct = M, yt = N;
+ h > 2 && M > 1 && (ct = M >= 16384 ? Math.floor(M / 2) - 1 || 1 : Math.ceil(M / 2), h /= M / ct), b > 2 && N > 1 && (yt = N >= 16384 ? Math.floor(N / 2) - 1 || 1 : Math.ceil(N) / 2, b /= N / yt), Q = this.cachedCanvases.getCanvas(tt, ct, yt), nt = Q.context, nt.clearRect(0, 0, ct, yt), nt.drawImage(i, 0, 0, M, N, 0, 0, ct, yt), i = Q.canvas, M = ct, N = yt, tt = tt === "prescale1" ? "prescale2" : "prescale1";
+ }
+ return {
+ img: i,
+ paintWidth: M,
+ paintHeight: N
+ };
+ }
+ _createMaskCanvas(i) {
+ const n = this.ctx, {
+ width: s,
+ height: o
+ } = i, h = this.current.fillColor, b = this.current.patternFill, M = (0, P.getCurrentTransform)(n);
+ let N, tt, Q, nt;
+ if ((i.bitmap || i.data) && i.count > 1) {
+ const Et = i.bitmap || i.data.buffer;
+ tt = JSON.stringify(b ? M : [M.slice(0, 4), h]), N = this._cachedBitmapsMap.get(Et), N || (N = /* @__PURE__ */ new Map(), this._cachedBitmapsMap.set(Et, N));
+ const Ct = N.get(tt);
+ if (Ct && !b) {
+ const jt = Math.round(Math.min(M[0], M[2]) + M[4]), Gt = Math.round(Math.min(M[1], M[3]) + M[5]);
+ return {
+ canvas: Ct,
+ offsetX: jt,
+ offsetY: Gt
+ };
+ }
+ Q = Ct;
+ }
+ Q || (nt = this.cachedCanvases.getCanvas("maskCanvas", s, o), y(nt.context, i));
+ let ct = l.Util.transform(M, [1 / s, 0, 0, -1 / o, 0, 0]);
+ ct = l.Util.transform(ct, [1, 0, 0, 1, 0, -o]);
+ const yt = l.Util.applyTransform([0, 0], ct), ut = l.Util.applyTransform([s, o], ct), Ft = l.Util.normalizeRect([yt[0], yt[1], ut[0], ut[1]]), Bt = Math.round(Ft[2] - Ft[0]) || 1, St = Math.round(Ft[3] - Ft[1]) || 1, Dt = this.cachedCanvases.getCanvas("fillCanvas", Bt, St), ft = Dt.context, K = Math.min(yt[0], ut[0]), J = Math.min(yt[1], ut[1]);
+ ft.translate(-K, -J), ft.transform(...ct), Q || (Q = this._scaleImage(nt.canvas, (0, P.getCurrentTransformInverse)(ft)), Q = Q.img, N && b && N.set(tt, Q)), ft.imageSmoothingEnabled = U((0, P.getCurrentTransform)(ft), i.interpolate), u(ft, Q, 0, 0, Q.width, Q.height, 0, 0, s, o), ft.globalCompositeOperation = "source-in";
+ const ht = l.Util.transform((0, P.getCurrentTransformInverse)(ft), [1, 0, 0, 1, -K, -J]);
+ return ft.fillStyle = b ? h.getPattern(n, this, ht, rt.PathType.FILL) : h, ft.fillRect(0, 0, s, o), N && !b && (this.cachedCanvases.delete("fillCanvas"), N.set(tt, Dt.canvas)), {
+ canvas: Dt.canvas,
+ offsetX: Math.round(K),
+ offsetY: Math.round(J)
+ };
+ }
+ setLineWidth(i) {
+ i !== this.current.lineWidth && (this._cachedScaleForStroking[0] = -1), this.current.lineWidth = i, this.ctx.lineWidth = i;
+ }
+ setLineCap(i) {
+ this.ctx.lineCap = z[i];
+ }
+ setLineJoin(i) {
+ this.ctx.lineJoin = E[i];
+ }
+ setMiterLimit(i) {
+ this.ctx.miterLimit = i;
+ }
+ setDash(i, n) {
+ const s = this.ctx;
+ s.setLineDash !== void 0 && (s.setLineDash(i), s.lineDashOffset = n);
+ }
+ setRenderingIntent(i) {
+ }
+ setFlatness(i) {
+ }
+ setGState(i) {
+ for (const [n, s] of i)
+ switch (n) {
+ case "LW":
+ this.setLineWidth(s);
+ break;
+ case "LC":
+ this.setLineCap(s);
+ break;
+ case "LJ":
+ this.setLineJoin(s);
+ break;
+ case "ML":
+ this.setMiterLimit(s);
+ break;
+ case "D":
+ this.setDash(s[0], s[1]);
+ break;
+ case "RI":
+ this.setRenderingIntent(s);
+ break;
+ case "FL":
+ this.setFlatness(s);
+ break;
+ case "Font":
+ this.setFont(s[0], s[1]);
+ break;
+ case "CA":
+ this.current.strokeAlpha = s;
+ break;
+ case "ca":
+ this.current.fillAlpha = s, this.ctx.globalAlpha = s;
+ break;
+ case "BM":
+ this.ctx.globalCompositeOperation = s;
+ break;
+ case "SMask":
+ this.current.activeSMask = s ? this.tempSMask : null, this.tempSMask = null, this.checkSMaskState();
+ break;
+ case "TR":
+ this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(s);
+ break;
+ }
+ }
+ get inSMaskMode() {
+ return !!this.suspendedCtx;
+ }
+ checkSMaskState() {
+ const i = this.inSMaskMode;
+ this.current.activeSMask && !i ? this.beginSMaskMode() : !this.current.activeSMask && i && this.endSMaskMode();
+ }
+ beginSMaskMode() {
+ if (this.inSMaskMode)
+ throw new Error("beginSMaskMode called while already in smask mode");
+ const i = this.ctx.canvas.width, n = this.ctx.canvas.height, s = "smaskGroupAt" + this.groupLevel, o = this.cachedCanvases.getCanvas(s, i, n);
+ this.suspendedCtx = this.ctx, this.ctx = o.context;
+ const h = this.ctx;
+ h.setTransform(...(0, P.getCurrentTransform)(this.suspendedCtx)), a(this.suspendedCtx, h), v(h, this.suspendedCtx), this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
+ }
+ endSMaskMode() {
+ if (!this.inSMaskMode)
+ throw new Error("endSMaskMode called while not in smask mode");
+ this.ctx._removeMirroring(), a(this.ctx, this.suspendedCtx), this.ctx = this.suspendedCtx, this.suspendedCtx = null;
+ }
+ compose(i) {
+ if (!this.current.activeSMask)
+ return;
+ i ? (i[0] = Math.floor(i[0]), i[1] = Math.floor(i[1]), i[2] = Math.ceil(i[2]), i[3] = Math.ceil(i[3])) : i = [0, 0, this.ctx.canvas.width, this.ctx.canvas.height];
+ const n = this.current.activeSMask, s = this.suspendedCtx;
+ m(s, n, this.ctx, i), this.ctx.save(), this.ctx.setTransform(1, 0, 0, 1, 0, 0), this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height), this.ctx.restore();
+ }
+ save() {
+ this.inSMaskMode ? (a(this.ctx, this.suspendedCtx), this.suspendedCtx.save()) : this.ctx.save();
+ const i = this.current;
+ this.stateStack.push(i), this.current = i.clone();
+ }
+ restore() {
+ this.stateStack.length === 0 && this.inSMaskMode && this.endSMaskMode(), this.stateStack.length !== 0 && (this.current = this.stateStack.pop(), this.inSMaskMode ? (this.suspendedCtx.restore(), a(this.suspendedCtx, this.ctx)) : this.ctx.restore(), this.checkSMaskState(), this.pendingClip = null, this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null);
+ }
+ transform(i, n, s, o, h, b) {
+ this.ctx.transform(i, n, s, o, h, b), this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null;
+ }
+ constructPath(i, n, s) {
+ const o = this.ctx, h = this.current;
+ let b = h.x, M = h.y, N, tt;
+ const Q = (0, P.getCurrentTransform)(o), nt = Q[0] === 0 && Q[3] === 0 || Q[1] === 0 && Q[2] === 0, ct = nt ? s.slice(0) : null;
+ for (let yt = 0, ut = 0, Ft = i.length; yt < Ft; yt++)
+ switch (i[yt] | 0) {
+ case l.OPS.rectangle:
+ b = n[ut++], M = n[ut++];
+ const Bt = n[ut++], St = n[ut++], Dt = b + Bt, ft = M + St;
+ o.moveTo(b, M), Bt === 0 || St === 0 ? o.lineTo(Dt, ft) : (o.lineTo(Dt, M), o.lineTo(Dt, ft), o.lineTo(b, ft)), nt || h.updateRectMinMax(Q, [b, M, Dt, ft]), o.closePath();
+ break;
+ case l.OPS.moveTo:
+ b = n[ut++], M = n[ut++], o.moveTo(b, M), nt || h.updatePathMinMax(Q, b, M);
+ break;
+ case l.OPS.lineTo:
+ b = n[ut++], M = n[ut++], o.lineTo(b, M), nt || h.updatePathMinMax(Q, b, M);
+ break;
+ case l.OPS.curveTo:
+ N = b, tt = M, b = n[ut + 4], M = n[ut + 5], o.bezierCurveTo(n[ut], n[ut + 1], n[ut + 2], n[ut + 3], b, M), h.updateCurvePathMinMax(Q, N, tt, n[ut], n[ut + 1], n[ut + 2], n[ut + 3], b, M, ct), ut += 6;
+ break;
+ case l.OPS.curveTo2:
+ N = b, tt = M, o.bezierCurveTo(b, M, n[ut], n[ut + 1], n[ut + 2], n[ut + 3]), h.updateCurvePathMinMax(Q, N, tt, b, M, n[ut], n[ut + 1], n[ut + 2], n[ut + 3], ct), b = n[ut + 2], M = n[ut + 3], ut += 4;
+ break;
+ case l.OPS.curveTo3:
+ N = b, tt = M, b = n[ut + 2], M = n[ut + 3], o.bezierCurveTo(n[ut], n[ut + 1], b, M, b, M), h.updateCurvePathMinMax(Q, N, tt, n[ut], n[ut + 1], b, M, b, M, ct), ut += 4;
+ break;
+ case l.OPS.closePath:
+ o.closePath();
+ break;
+ }
+ nt && h.updateScalingPathMinMax(Q, ct), h.setCurrentPoint(b, M);
+ }
+ closePath() {
+ this.ctx.closePath();
+ }
+ stroke(i = !0) {
+ const n = this.ctx, s = this.current.strokeColor;
+ n.globalAlpha = this.current.strokeAlpha, this.contentVisible && (typeof s == "object" && (s != null && s.getPattern) ? (n.save(), n.strokeStyle = s.getPattern(n, this, (0, P.getCurrentTransformInverse)(n), rt.PathType.STROKE), this.rescaleAndStroke(!1), n.restore()) : this.rescaleAndStroke(!0)), i && this.consumePath(this.current.getClippedPathBoundingBox()), n.globalAlpha = this.current.fillAlpha;
+ }
+ closeStroke() {
+ this.closePath(), this.stroke();
+ }
+ fill(i = !0) {
+ const n = this.ctx, s = this.current.fillColor, o = this.current.patternFill;
+ let h = !1;
+ o && (n.save(), n.fillStyle = s.getPattern(n, this, (0, P.getCurrentTransformInverse)(n), rt.PathType.FILL), h = !0);
+ const b = this.current.getClippedPathBoundingBox();
+ this.contentVisible && b !== null && (this.pendingEOFill ? (n.fill("evenodd"), this.pendingEOFill = !1) : n.fill()), h && n.restore(), i && this.consumePath(b);
+ }
+ eoFill() {
+ this.pendingEOFill = !0, this.fill();
+ }
+ fillStroke() {
+ this.fill(!1), this.stroke(!1), this.consumePath();
+ }
+ eoFillStroke() {
+ this.pendingEOFill = !0, this.fillStroke();
+ }
+ closeFillStroke() {
+ this.closePath(), this.fillStroke();
+ }
+ closeEOFillStroke() {
+ this.pendingEOFill = !0, this.closePath(), this.fillStroke();
+ }
+ endPath() {
+ this.consumePath();
+ }
+ clip() {
+ this.pendingClip = V;
+ }
+ eoClip() {
+ this.pendingClip = st;
+ }
+ beginText() {
+ this.current.textMatrix = l.IDENTITY_MATRIX, this.current.textMatrixScale = 1, this.current.x = this.current.lineX = 0, this.current.y = this.current.lineY = 0;
+ }
+ endText() {
+ const i = this.pendingTextPaths, n = this.ctx;
+ if (i === void 0) {
+ n.beginPath();
+ return;
+ }
+ n.save(), n.beginPath();
+ for (const s of i)
+ n.setTransform(...s.transform), n.translate(s.x, s.y), s.addToPath(n, s.fontSize);
+ n.restore(), n.clip(), n.beginPath(), delete this.pendingTextPaths;
+ }
+ setCharSpacing(i) {
+ this.current.charSpacing = i;
+ }
+ setWordSpacing(i) {
+ this.current.wordSpacing = i;
+ }
+ setHScale(i) {
+ this.current.textHScale = i / 100;
+ }
+ setLeading(i) {
+ this.current.leading = -i;
+ }
+ setFont(i, n) {
+ var Q;
+ const s = this.commonObjs.get(i), o = this.current;
+ if (!s)
+ throw new Error(`Can't find font for ${i}`);
+ if (o.fontMatrix = s.fontMatrix || l.FONT_IDENTITY_MATRIX, (o.fontMatrix[0] === 0 || o.fontMatrix[3] === 0) && (0, l.warn)("Invalid font matrix for font " + i), n < 0 ? (n = -n, o.fontDirection = -1) : o.fontDirection = 1, this.current.font = s, this.current.fontSize = n, s.isType3Font)
+ return;
+ const h = s.loadedName || "sans-serif", b = ((Q = s.systemFontInfo) == null ? void 0 : Q.css) || `"${h}", ${s.fallbackName}`;
+ let M = "normal";
+ s.black ? M = "900" : s.bold && (M = "bold");
+ const N = s.italic ? "italic" : "normal";
+ let tt = n;
+ n < pt ? tt = pt : n > B && (tt = B), this.current.fontSizeScale = n / tt, this.ctx.font = `${N} ${M} ${tt}px ${b}`;
+ }
+ setTextRenderingMode(i) {
+ this.current.textRenderingMode = i;
+ }
+ setTextRise(i) {
+ this.current.textRise = i;
+ }
+ moveText(i, n) {
+ this.current.x = this.current.lineX += i, this.current.y = this.current.lineY += n;
+ }
+ setLeadingMoveText(i, n) {
+ this.setLeading(-n), this.moveText(i, n);
+ }
+ setTextMatrix(i, n, s, o, h, b) {
+ this.current.textMatrix = [i, n, s, o, h, b], this.current.textMatrixScale = Math.hypot(i, n), this.current.x = this.current.lineX = 0, this.current.y = this.current.lineY = 0;
+ }
+ nextLine() {
+ this.moveText(0, this.current.leading);
+ }
+ paintChar(i, n, s, o) {
+ const h = this.ctx, b = this.current, M = b.font, N = b.textRenderingMode, tt = b.fontSize / b.fontSizeScale, Q = N & l.TextRenderingMode.FILL_STROKE_MASK, nt = !!(N & l.TextRenderingMode.ADD_TO_PATH_FLAG), ct = b.patternFill && !M.missingFile;
+ let yt;
+ (M.disableFontFace || nt || ct) && (yt = M.getPathGenerator(this.commonObjs, i)), M.disableFontFace || ct ? (h.save(), h.translate(n, s), h.beginPath(), yt(h, tt), o && h.setTransform(...o), (Q === l.TextRenderingMode.FILL || Q === l.TextRenderingMode.FILL_STROKE) && h.fill(), (Q === l.TextRenderingMode.STROKE || Q === l.TextRenderingMode.FILL_STROKE) && h.stroke(), h.restore()) : ((Q === l.TextRenderingMode.FILL || Q === l.TextRenderingMode.FILL_STROKE) && h.fillText(i, n, s), (Q === l.TextRenderingMode.STROKE || Q === l.TextRenderingMode.FILL_STROKE) && h.strokeText(i, n, s)), nt && (this.pendingTextPaths || (this.pendingTextPaths = [])).push({
+ transform: (0, P.getCurrentTransform)(h),
+ x: n,
+ y: s,
+ fontSize: tt,
+ addToPath: yt
+ });
+ }
+ get isFontSubpixelAAEnabled() {
+ const {
+ context: i
+ } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
+ i.scale(1.5, 1), i.fillText("I", 0, 10);
+ const n = i.getImageData(0, 0, 10, 10).data;
+ let s = !1;
+ for (let o = 3; o < n.length; o += 4)
+ if (n[o] > 0 && n[o] < 255) {
+ s = !0;
+ break;
+ }
+ return (0, l.shadow)(this, "isFontSubpixelAAEnabled", s);
+ }
+ showText(i) {
+ const n = this.current, s = n.font;
+ if (s.isType3Font)
+ return this.showType3Text(i);
+ const o = n.fontSize;
+ if (o === 0)
+ return;
+ const h = this.ctx, b = n.fontSizeScale, M = n.charSpacing, N = n.wordSpacing, tt = n.fontDirection, Q = n.textHScale * tt, nt = i.length, ct = s.vertical, yt = ct ? 1 : -1, ut = s.defaultVMetrics, Ft = o * n.fontMatrix[0], Bt = n.textRenderingMode === l.TextRenderingMode.FILL && !s.disableFontFace && !n.patternFill;
+ h.save(), h.transform(...n.textMatrix), h.translate(n.x, n.y + n.textRise), tt > 0 ? h.scale(Q, -1) : h.scale(Q, 1);
+ let St;
+ if (n.patternFill) {
+ h.save();
+ const ht = n.fillColor.getPattern(h, this, (0, P.getCurrentTransformInverse)(h), rt.PathType.FILL);
+ St = (0, P.getCurrentTransform)(h), h.restore(), h.fillStyle = ht;
+ }
+ let Dt = n.lineWidth;
+ const ft = n.textMatrixScale;
+ if (ft === 0 || Dt === 0) {
+ const ht = n.textRenderingMode & l.TextRenderingMode.FILL_STROKE_MASK;
+ (ht === l.TextRenderingMode.STROKE || ht === l.TextRenderingMode.FILL_STROKE) && (Dt = this.getSinglePixelWidth());
+ } else
+ Dt /= ft;
+ if (b !== 1 && (h.scale(b, b), Dt /= b), h.lineWidth = Dt, s.isInvalidPDFjsFont) {
+ const ht = [];
+ let Et = 0;
+ for (const Ct of i)
+ ht.push(Ct.unicode), Et += Ct.width;
+ h.fillText(ht.join(""), 0, 0), n.x += Et * Ft * Q, h.restore(), this.compose();
+ return;
+ }
+ let K = 0, J;
+ for (J = 0; J < nt; ++J) {
+ const ht = i[J];
+ if (typeof ht == "number") {
+ K += yt * ht * o / 1e3;
+ continue;
+ }
+ let Et = !1;
+ const Ct = (ht.isSpace ? N : 0) + M, jt = ht.fontChar, Gt = ht.accent;
+ let Ht, Xt, Vt = ht.width;
+ if (ct) {
+ const $t = ht.vmetric || ut, ot = -(ht.vmetric ? $t[1] : Vt * 0.5) * Ft, Y = $t[2] * Ft;
+ Vt = $t ? -$t[0] : Vt, Ht = ot / b, Xt = (K + Y) / b;
+ } else
+ Ht = K / b, Xt = 0;
+ if (s.remeasure && Vt > 0) {
+ const $t = h.measureText(jt).width * 1e3 / o * b;
+ if (Vt < $t && this.isFontSubpixelAAEnabled) {
+ const ot = Vt / $t;
+ Et = !0, h.save(), h.scale(ot, 1), Ht /= ot;
+ } else
+ Vt !== $t && (Ht += (Vt - $t) / 2e3 * o / b);
+ }
+ if (this.contentVisible && (ht.isInFont || s.missingFile)) {
+ if (Bt && !Gt)
+ h.fillText(jt, Ht, Xt);
+ else if (this.paintChar(jt, Ht, Xt, St), Gt) {
+ const $t = Ht + o * Gt.offset.x / b, ot = Xt - o * Gt.offset.y / b;
+ this.paintChar(Gt.fontChar, $t, ot, St);
+ }
+ }
+ const Wt = ct ? Vt * Ft - Ct * tt : Vt * Ft + Ct * tt;
+ K += Wt, Et && h.restore();
+ }
+ ct ? n.y -= K : n.x += K * Q, h.restore(), this.compose();
+ }
+ showType3Text(i) {
+ const n = this.ctx, s = this.current, o = s.font, h = s.fontSize, b = s.fontDirection, M = o.vertical ? 1 : -1, N = s.charSpacing, tt = s.wordSpacing, Q = s.textHScale * b, nt = s.fontMatrix || l.FONT_IDENTITY_MATRIX, ct = i.length, yt = s.textRenderingMode === l.TextRenderingMode.INVISIBLE;
+ let ut, Ft, Bt, St;
+ if (!(yt || h === 0)) {
+ for (this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null, n.save(), n.transform(...s.textMatrix), n.translate(s.x, s.y), n.scale(Q, b), ut = 0; ut < ct; ++ut) {
+ if (Ft = i[ut], typeof Ft == "number") {
+ St = M * Ft * h / 1e3, this.ctx.translate(St, 0), s.x += St * Q;
+ continue;
+ }
+ const Dt = (Ft.isSpace ? tt : 0) + N, ft = o.charProcOperatorList[Ft.operatorListId];
+ if (!ft) {
+ (0, l.warn)(`Type3 character "${Ft.operatorListId}" is not available.`);
+ continue;
+ }
+ this.contentVisible && (this.processingType3 = Ft, this.save(), n.scale(h, h), n.transform(...nt), this.executeOperatorList(ft), this.restore()), Bt = l.Util.applyTransform([Ft.width, 0], nt)[0] * h + Dt, n.translate(Bt, 0), s.x += Bt * Q;
+ }
+ n.restore(), this.processingType3 = null;
+ }
+ }
+ setCharWidth(i, n) {
+ }
+ setCharWidthAndBounds(i, n, s, o, h, b) {
+ this.ctx.rect(s, o, h - s, b - o), this.ctx.clip(), this.endPath();
+ }
+ getColorN_Pattern(i) {
+ let n;
+ if (i[0] === "TilingPattern") {
+ const s = i[1], o = this.baseTransform || (0, P.getCurrentTransform)(this.ctx), h = {
+ createCanvasGraphics: (b) => new xt(b, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
+ optionalContentConfig: this.optionalContentConfig,
+ markedContentStack: this.markedContentStack
+ })
+ };
+ n = new rt.TilingPattern(i, s, this.ctx, h, o);
+ } else
+ n = this._getPattern(i[1], i[2]);
+ return n;
+ }
+ setStrokeColorN() {
+ this.current.strokeColor = this.getColorN_Pattern(arguments);
+ }
+ setFillColorN() {
+ this.current.fillColor = this.getColorN_Pattern(arguments), this.current.patternFill = !0;
+ }
+ setStrokeRGBColor(i, n, s) {
+ const o = l.Util.makeHexColor(i, n, s);
+ this.ctx.strokeStyle = o, this.current.strokeColor = o;
+ }
+ setFillRGBColor(i, n, s) {
+ const o = l.Util.makeHexColor(i, n, s);
+ this.ctx.fillStyle = o, this.current.fillColor = o, this.current.patternFill = !1;
+ }
+ _getPattern(i, n = null) {
+ let s;
+ return this.cachedPatterns.has(i) ? s = this.cachedPatterns.get(i) : (s = (0, rt.getShadingPattern)(this.getObject(i)), this.cachedPatterns.set(i, s)), n && (s.matrix = n), s;
+ }
+ shadingFill(i) {
+ if (!this.contentVisible)
+ return;
+ const n = this.ctx;
+ this.save();
+ const s = this._getPattern(i);
+ n.fillStyle = s.getPattern(n, this, (0, P.getCurrentTransformInverse)(n), rt.PathType.SHADING);
+ const o = (0, P.getCurrentTransformInverse)(n);
+ if (o) {
+ const {
+ width: h,
+ height: b
+ } = n.canvas, [M, N, tt, Q] = l.Util.getAxialAlignedBoundingBox([0, 0, h, b], o);
+ this.ctx.fillRect(M, N, tt - M, Q - N);
+ } else
+ this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
+ this.compose(this.current.getClippedPathBoundingBox()), this.restore();
+ }
+ beginInlineImage() {
+ (0, l.unreachable)("Should not call beginInlineImage");
+ }
+ beginImageData() {
+ (0, l.unreachable)("Should not call beginImageData");
+ }
+ paintFormXObjectBegin(i, n) {
+ if (this.contentVisible && (this.save(), this.baseTransformStack.push(this.baseTransform), Array.isArray(i) && i.length === 6 && this.transform(...i), this.baseTransform = (0, P.getCurrentTransform)(this.ctx), n)) {
+ const s = n[2] - n[0], o = n[3] - n[1];
+ this.ctx.rect(n[0], n[1], s, o), this.current.updateRectMinMax((0, P.getCurrentTransform)(this.ctx), n), this.clip(), this.endPath();
+ }
+ }
+ paintFormXObjectEnd() {
+ this.contentVisible && (this.restore(), this.baseTransform = this.baseTransformStack.pop());
+ }
+ beginGroup(i) {
+ if (!this.contentVisible)
+ return;
+ this.save(), this.inSMaskMode && (this.endSMaskMode(), this.current.activeSMask = null);
+ const n = this.ctx;
+ i.isolated || (0, l.info)("TODO: Support non-isolated groups."), i.knockout && (0, l.warn)("Knockout groups not supported.");
+ const s = (0, P.getCurrentTransform)(n);
+ if (i.matrix && n.transform(...i.matrix), !i.bbox)
+ throw new Error("Bounding box is required.");
+ let o = l.Util.getAxialAlignedBoundingBox(i.bbox, (0, P.getCurrentTransform)(n));
+ const h = [0, 0, n.canvas.width, n.canvas.height];
+ o = l.Util.intersect(o, h) || [0, 0, 0, 0];
+ const b = Math.floor(o[0]), M = Math.floor(o[1]);
+ let N = Math.max(Math.ceil(o[2]) - b, 1), tt = Math.max(Math.ceil(o[3]) - M, 1), Q = 1, nt = 1;
+ N > F && (Q = N / F, N = F), tt > F && (nt = tt / F, tt = F), this.current.startNewPathAndClipBox([0, 0, N, tt]);
+ let ct = "groupAt" + this.groupLevel;
+ i.smask && (ct += "_smask_" + this.smaskCounter++ % 2);
+ const yt = this.cachedCanvases.getCanvas(ct, N, tt), ut = yt.context;
+ ut.scale(1 / Q, 1 / nt), ut.translate(-b, -M), ut.transform(...s), i.smask ? this.smaskStack.push({
+ canvas: yt.canvas,
+ context: ut,
+ offsetX: b,
+ offsetY: M,
+ scaleX: Q,
+ scaleY: nt,
+ subtype: i.smask.subtype,
+ backdrop: i.smask.backdrop,
+ transferMap: i.smask.transferMap || null,
+ startTransformInverse: null
+ }) : (n.setTransform(1, 0, 0, 1, 0, 0), n.translate(b, M), n.scale(Q, nt), n.save()), a(n, ut), this.ctx = ut, this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]), this.groupStack.push(n), this.groupLevel++;
+ }
+ endGroup(i) {
+ if (!this.contentVisible)
+ return;
+ this.groupLevel--;
+ const n = this.ctx, s = this.groupStack.pop();
+ if (this.ctx = s, this.ctx.imageSmoothingEnabled = !1, i.smask)
+ this.tempSMask = this.smaskStack.pop(), this.restore();
+ else {
+ this.ctx.restore();
+ const o = (0, P.getCurrentTransform)(this.ctx);
+ this.restore(), this.ctx.save(), this.ctx.setTransform(...o);
+ const h = l.Util.getAxialAlignedBoundingBox([0, 0, n.canvas.width, n.canvas.height], o);
+ this.ctx.drawImage(n.canvas, 0, 0), this.ctx.restore(), this.compose(h);
+ }
+ }
+ beginAnnotation(i, n, s, o, h) {
+ if (W(this, H, Qe).call(this), c(this.ctx), this.ctx.save(), this.save(), this.baseTransform && this.ctx.setTransform(...this.baseTransform), Array.isArray(n) && n.length === 4) {
+ const b = n[2] - n[0], M = n[3] - n[1];
+ if (h && this.annotationCanvasMap) {
+ s = s.slice(), s[4] -= n[0], s[5] -= n[1], n = n.slice(), n[0] = n[1] = 0, n[2] = b, n[3] = M;
+ const [N, tt] = l.Util.singularValueDecompose2dScale((0, P.getCurrentTransform)(this.ctx)), {
+ viewportScale: Q
+ } = this, nt = Math.ceil(b * this.outputScaleX * Q), ct = Math.ceil(M * this.outputScaleY * Q);
+ this.annotationCanvas = this.canvasFactory.create(nt, ct);
+ const {
+ canvas: yt,
+ context: ut
+ } = this.annotationCanvas;
+ this.annotationCanvasMap.set(i, yt), this.annotationCanvas.savedCtx = this.ctx, this.ctx = ut, this.ctx.save(), this.ctx.setTransform(N, 0, 0, -tt, 0, M * tt), c(this.ctx);
+ } else
+ c(this.ctx), this.ctx.rect(n[0], n[1], b, M), this.ctx.clip(), this.endPath();
+ }
+ this.current = new w(this.ctx.canvas.width, this.ctx.canvas.height), this.transform(...s), this.transform(...o);
+ }
+ endAnnotation() {
+ this.annotationCanvas && (this.ctx.restore(), W(this, gt, Ze).call(this), this.ctx = this.annotationCanvas.savedCtx, delete this.annotationCanvas.savedCtx, delete this.annotationCanvas);
+ }
+ paintImageMaskXObject(i) {
+ if (!this.contentVisible)
+ return;
+ const n = i.count;
+ i = this.getObject(i.data, i), i.count = n;
+ const s = this.ctx, o = this.processingType3;
+ if (o && (o.compiled === void 0 && (o.compiled = _(i)), o.compiled)) {
+ o.compiled(s);
+ return;
+ }
+ const h = this._createMaskCanvas(i), b = h.canvas;
+ s.save(), s.setTransform(1, 0, 0, 1, 0, 0), s.drawImage(b, h.offsetX, h.offsetY), s.restore(), this.compose();
+ }
+ paintImageMaskXObjectRepeat(i, n, s = 0, o = 0, h, b) {
+ if (!this.contentVisible)
+ return;
+ i = this.getObject(i.data, i);
+ const M = this.ctx;
+ M.save();
+ const N = (0, P.getCurrentTransform)(M);
+ M.transform(n, s, o, h, 0, 0);
+ const tt = this._createMaskCanvas(i);
+ M.setTransform(1, 0, 0, 1, tt.offsetX - N[4], tt.offsetY - N[5]);
+ for (let Q = 0, nt = b.length; Q < nt; Q += 2) {
+ const ct = l.Util.transform(N, [n, s, o, h, b[Q], b[Q + 1]]), [yt, ut] = l.Util.applyTransform([0, 0], ct);
+ M.drawImage(tt.canvas, yt, ut);
+ }
+ M.restore(), this.compose();
+ }
+ paintImageMaskXObjectGroup(i) {
+ if (!this.contentVisible)
+ return;
+ const n = this.ctx, s = this.current.fillColor, o = this.current.patternFill;
+ for (const h of i) {
+ const {
+ data: b,
+ width: M,
+ height: N,
+ transform: tt
+ } = h, Q = this.cachedCanvases.getCanvas("maskCanvas", M, N), nt = Q.context;
+ nt.save();
+ const ct = this.getObject(b, h);
+ y(nt, ct), nt.globalCompositeOperation = "source-in", nt.fillStyle = o ? s.getPattern(nt, this, (0, P.getCurrentTransformInverse)(n), rt.PathType.FILL) : s, nt.fillRect(0, 0, M, N), nt.restore(), n.save(), n.transform(...tt), n.scale(1, -1), u(n, Q.canvas, 0, 0, M, N, 0, -1, 1, 1), n.restore();
+ }
+ this.compose();
+ }
+ paintImageXObject(i) {
+ if (!this.contentVisible)
+ return;
+ const n = this.getObject(i);
+ if (!n) {
+ (0, l.warn)("Dependent image isn't ready yet");
+ return;
+ }
+ this.paintInlineImageXObject(n);
+ }
+ paintImageXObjectRepeat(i, n, s, o) {
+ if (!this.contentVisible)
+ return;
+ const h = this.getObject(i);
+ if (!h) {
+ (0, l.warn)("Dependent image isn't ready yet");
+ return;
+ }
+ const b = h.width, M = h.height, N = [];
+ for (let tt = 0, Q = o.length; tt < Q; tt += 2)
+ N.push({
+ transform: [n, 0, 0, s, o[tt], o[tt + 1]],
+ x: 0,
+ y: 0,
+ w: b,
+ h: M
+ });
+ this.paintInlineImageXObjectGroup(h, N);
+ }
+ applyTransferMapsToCanvas(i) {
+ return this.current.transferMaps !== "none" && (i.filter = this.current.transferMaps, i.drawImage(i.canvas, 0, 0), i.filter = "none"), i.canvas;
+ }
+ applyTransferMapsToBitmap(i) {
+ if (this.current.transferMaps === "none")
+ return i.bitmap;
+ const {
+ bitmap: n,
+ width: s,
+ height: o
+ } = i, h = this.cachedCanvases.getCanvas("inlineImage", s, o), b = h.context;
+ return b.filter = this.current.transferMaps, b.drawImage(n, 0, 0), b.filter = "none", h.canvas;
+ }
+ paintInlineImageXObject(i) {
+ if (!this.contentVisible)
+ return;
+ const n = i.width, s = i.height, o = this.ctx;
+ if (this.save(), !l.isNodeJS) {
+ const {
+ filter: M
+ } = o;
+ M !== "none" && M !== "" && (o.filter = "none");
+ }
+ o.scale(1 / n, -1 / s);
+ let h;
+ if (i.bitmap)
+ h = this.applyTransferMapsToBitmap(i);
+ else if (typeof HTMLElement == "function" && i instanceof HTMLElement || !i.data)
+ h = i;
+ else {
+ const N = this.cachedCanvases.getCanvas("inlineImage", n, s).context;
+ C(N, i), h = this.applyTransferMapsToCanvas(N);
+ }
+ const b = this._scaleImage(h, (0, P.getCurrentTransformInverse)(o));
+ o.imageSmoothingEnabled = U((0, P.getCurrentTransform)(o), i.interpolate), u(o, b.img, 0, 0, b.paintWidth, b.paintHeight, 0, -s, n, s), this.compose(), this.restore();
+ }
+ paintInlineImageXObjectGroup(i, n) {
+ if (!this.contentVisible)
+ return;
+ const s = this.ctx;
+ let o;
+ if (i.bitmap)
+ o = i.bitmap;
+ else {
+ const h = i.width, b = i.height, N = this.cachedCanvases.getCanvas("inlineImage", h, b).context;
+ C(N, i), o = this.applyTransferMapsToCanvas(N);
+ }
+ for (const h of n)
+ s.save(), s.transform(...h.transform), s.scale(1, -1), u(s, o, h.x, h.y, h.w, h.h, 0, -1, 1, 1), s.restore();
+ this.compose();
+ }
+ paintSolidColorImageMask() {
+ this.contentVisible && (this.ctx.fillRect(0, 0, 1, 1), this.compose());
+ }
+ markPoint(i) {
+ }
+ markPointProps(i, n) {
+ }
+ beginMarkedContent(i) {
+ this.markedContentStack.push({
+ visible: !0
+ });
+ }
+ beginMarkedContentProps(i, n) {
+ i === "OC" ? this.markedContentStack.push({
+ visible: this.optionalContentConfig.isVisible(n)
+ }) : this.markedContentStack.push({
+ visible: !0
+ }), this.contentVisible = this.isContentVisible();
+ }
+ endMarkedContent() {
+ this.markedContentStack.pop(), this.contentVisible = this.isContentVisible();
+ }
+ beginCompat() {
+ }
+ endCompat() {
+ }
+ consumePath(i) {
+ const n = this.current.isEmptyClip();
+ this.pendingClip && this.current.updateClipFromPath(), this.pendingClip || this.compose(i);
+ const s = this.ctx;
+ this.pendingClip && (n || (this.pendingClip === st ? s.clip("evenodd") : s.clip()), this.pendingClip = null), this.current.startNewPathAndClipBox(this.current.clipBox), s.beginPath();
+ }
+ getSinglePixelWidth() {
+ if (!this._cachedGetSinglePixelWidth) {
+ const i = (0, P.getCurrentTransform)(this.ctx);
+ if (i[1] === 0 && i[2] === 0)
+ this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(i[0]), Math.abs(i[3]));
+ else {
+ const n = Math.abs(i[0] * i[3] - i[2] * i[1]), s = Math.hypot(i[0], i[2]), o = Math.hypot(i[1], i[3]);
+ this._cachedGetSinglePixelWidth = Math.max(s, o) / n;
+ }
+ }
+ return this._cachedGetSinglePixelWidth;
+ }
+ getScaleForStroking() {
+ if (this._cachedScaleForStroking[0] === -1) {
+ const {
+ lineWidth: i
+ } = this.current, {
+ a: n,
+ b: s,
+ c: o,
+ d: h
+ } = this.ctx.getTransform();
+ let b, M;
+ if (s === 0 && o === 0) {
+ const N = Math.abs(n), tt = Math.abs(h);
+ if (N === tt)
+ if (i === 0)
+ b = M = 1 / N;
+ else {
+ const Q = N * i;
+ b = M = Q < 1 ? 1 / Q : 1;
+ }
+ else if (i === 0)
+ b = 1 / N, M = 1 / tt;
+ else {
+ const Q = N * i, nt = tt * i;
+ b = Q < 1 ? 1 / Q : 1, M = nt < 1 ? 1 / nt : 1;
+ }
+ } else {
+ const N = Math.abs(n * h - s * o), tt = Math.hypot(n, s), Q = Math.hypot(o, h);
+ if (i === 0)
+ b = Q / N, M = tt / N;
+ else {
+ const nt = i * N;
+ b = Q > nt ? Q / nt : 1, M = tt > nt ? tt / nt : 1;
+ }
+ }
+ this._cachedScaleForStroking[0] = b, this._cachedScaleForStroking[1] = M;
+ }
+ return this._cachedScaleForStroking;
+ }
+ rescaleAndStroke(i) {
+ const {
+ ctx: n
+ } = this, {
+ lineWidth: s
+ } = this.current, [o, h] = this.getScaleForStroking();
+ if (n.lineWidth = s || 1, o === 1 && h === 1) {
+ n.stroke();
+ return;
+ }
+ const b = n.getLineDash();
+ if (i && n.save(), n.scale(o, h), b.length > 0) {
+ const M = Math.max(o, h);
+ n.setLineDash(b.map((N) => N / M)), n.lineDashOffset /= M;
+ }
+ n.stroke(), i && n.restore();
+ }
+ isContentVisible() {
+ for (let i = this.markedContentStack.length - 1; i >= 0; i--)
+ if (!this.markedContentStack[i].visible)
+ return !1;
+ return !0;
+ }
+ };
+ H = new WeakSet(), Qe = function() {
+ for (; this.stateStack.length || this.inSMaskMode; )
+ this.restore();
+ this.ctx.restore(), this.transparentCanvas && (this.ctx = this.compositeCtx, this.ctx.save(), this.ctx.setTransform(1, 0, 0, 1, 0, 0), this.ctx.drawImage(this.transparentCanvas, 0, 0), this.ctx.restore(), this.transparentCanvas = null);
+ }, gt = new WeakSet(), Ze = function() {
+ if (this.pageColors) {
+ const i = this.filterFactory.addHCMFilter(this.pageColors.foreground, this.pageColors.background);
+ if (i !== "none") {
+ const n = this.ctx.filter;
+ this.ctx.filter = i, this.ctx.drawImage(this.ctx.canvas, 0, 0), this.ctx.filter = n;
+ }
+ }
+ };
+ let at = xt;
+ d.CanvasGraphics = at;
+ for (const S in l.OPS)
+ at.prototype[S] !== void 0 && (at.prototype[l.OPS[S]] = at.prototype[S]);
+ },
+ /* 12 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.TilingPattern = d.PathType = void 0, d.getShadingPattern = x;
+ var l = et(1), P = et(6);
+ const rt = {
+ FILL: "Fill",
+ STROKE: "Stroke",
+ SHADING: "Shading"
+ };
+ d.PathType = rt;
+ function X(_, w) {
+ if (!w)
+ return;
+ const C = w[2] - w[0], y = w[3] - w[1], a = new Path2D();
+ a.rect(w[0], w[1], C, y), _.clip(a);
+ }
+ class pt {
+ constructor() {
+ this.constructor === pt && (0, l.unreachable)("Cannot initialize BaseShadingPattern.");
+ }
+ getPattern() {
+ (0, l.unreachable)("Abstract method `getPattern` called.");
+ }
+ }
+ class B extends pt {
+ constructor(w) {
+ super(), this._type = w[1], this._bbox = w[2], this._colorStops = w[3], this._p0 = w[4], this._p1 = w[5], this._r0 = w[6], this._r1 = w[7], this.matrix = null;
+ }
+ _createGradient(w) {
+ let C;
+ this._type === "axial" ? C = w.createLinearGradient(this._p0[0], this._p0[1], this._p1[0], this._p1[1]) : this._type === "radial" && (C = w.createRadialGradient(this._p0[0], this._p0[1], this._r0, this._p1[0], this._p1[1], this._r1));
+ for (const y of this._colorStops)
+ C.addColorStop(y[0], y[1]);
+ return C;
+ }
+ getPattern(w, C, y, a) {
+ let c;
+ if (a === rt.STROKE || a === rt.FILL) {
+ const k = C.current.getClippedPathBoundingBox(a, (0, P.getCurrentTransform)(w)) || [0, 0, 0, 0], p = Math.ceil(k[2] - k[0]) || 1, r = Math.ceil(k[3] - k[1]) || 1, T = C.cachedCanvases.getCanvas("pattern", p, r, !0), m = T.context;
+ m.clearRect(0, 0, m.canvas.width, m.canvas.height), m.beginPath(), m.rect(0, 0, m.canvas.width, m.canvas.height), m.translate(-k[0], -k[1]), y = l.Util.transform(y, [1, 0, 0, 1, k[0], k[1]]), m.transform(...C.baseTransform), this.matrix && m.transform(...this.matrix), X(m, this._bbox), m.fillStyle = this._createGradient(m), m.fill(), c = w.createPattern(T.canvas, "no-repeat");
+ const U = new DOMMatrix(y);
+ c.setTransform(U);
+ } else
+ X(w, this._bbox), c = this._createGradient(w);
+ return c;
+ }
+ }
+ function F(_, w, C, y, a, c, k, p) {
+ const r = w.coords, T = w.colors, m = _.data, U = _.width * 4;
+ let z;
+ r[C + 1] > r[y + 1] && (z = C, C = y, y = z, z = c, c = k, k = z), r[y + 1] > r[a + 1] && (z = y, y = a, a = z, z = k, k = p, p = z), r[C + 1] > r[y + 1] && (z = C, C = y, y = z, z = c, c = k, k = z);
+ const E = (r[C] + w.offsetX) * w.scaleX, V = (r[C + 1] + w.offsetY) * w.scaleY, st = (r[y] + w.offsetX) * w.scaleX, at = (r[y + 1] + w.offsetY) * w.scaleY, H = (r[a] + w.offsetX) * w.scaleX, lt = (r[a + 1] + w.offsetY) * w.scaleY;
+ if (V >= lt)
+ return;
+ const gt = T[c], wt = T[c + 1], xt = T[c + 2], S = T[k], i = T[k + 1], n = T[k + 2], s = T[p], o = T[p + 1], h = T[p + 2], b = Math.round(V), M = Math.round(lt);
+ let N, tt, Q, nt, ct, yt, ut, Ft;
+ for (let Bt = b; Bt <= M; Bt++) {
+ if (Bt < at) {
+ const J = Bt < V ? 0 : (V - Bt) / (V - at);
+ N = E - (E - st) * J, tt = gt - (gt - S) * J, Q = wt - (wt - i) * J, nt = xt - (xt - n) * J;
+ } else {
+ let J;
+ Bt > lt ? J = 1 : at === lt ? J = 0 : J = (at - Bt) / (at - lt), N = st - (st - H) * J, tt = S - (S - s) * J, Q = i - (i - o) * J, nt = n - (n - h) * J;
+ }
+ let St;
+ Bt < V ? St = 0 : Bt > lt ? St = 1 : St = (V - Bt) / (V - lt), ct = E - (E - H) * St, yt = gt - (gt - s) * St, ut = wt - (wt - o) * St, Ft = xt - (xt - h) * St;
+ const Dt = Math.round(Math.min(N, ct)), ft = Math.round(Math.max(N, ct));
+ let K = U * Bt + Dt * 4;
+ for (let J = Dt; J <= ft; J++)
+ St = (N - J) / (N - ct), St < 0 ? St = 0 : St > 1 && (St = 1), m[K++] = tt - (tt - yt) * St | 0, m[K++] = Q - (Q - ut) * St | 0, m[K++] = nt - (nt - Ft) * St | 0, m[K++] = 255;
+ }
+ }
+ function g(_, w, C) {
+ const y = w.coords, a = w.colors;
+ let c, k;
+ switch (w.type) {
+ case "lattice":
+ const p = w.verticesPerRow, r = Math.floor(y.length / p) - 1, T = p - 1;
+ for (c = 0; c < r; c++) {
+ let m = c * p;
+ for (let U = 0; U < T; U++, m++)
+ F(_, C, y[m], y[m + 1], y[m + p], a[m], a[m + 1], a[m + p]), F(_, C, y[m + p + 1], y[m + 1], y[m + p], a[m + p + 1], a[m + 1], a[m + p]);
+ }
+ break;
+ case "triangles":
+ for (c = 0, k = y.length; c < k; c += 3)
+ F(_, C, y[c], y[c + 1], y[c + 2], a[c], a[c + 1], a[c + 2]);
+ break;
+ default:
+ throw new Error("illegal figure");
+ }
+ }
+ class O extends pt {
+ constructor(w) {
+ super(), this._coords = w[2], this._colors = w[3], this._figures = w[4], this._bounds = w[5], this._bbox = w[7], this._background = w[8], this.matrix = null;
+ }
+ _createMeshCanvas(w, C, y) {
+ const p = Math.floor(this._bounds[0]), r = Math.floor(this._bounds[1]), T = Math.ceil(this._bounds[2]) - p, m = Math.ceil(this._bounds[3]) - r, U = Math.min(Math.ceil(Math.abs(T * w[0] * 1.1)), 3e3), z = Math.min(Math.ceil(Math.abs(m * w[1] * 1.1)), 3e3), E = T / U, V = m / z, st = {
+ coords: this._coords,
+ colors: this._colors,
+ offsetX: -p,
+ offsetY: -r,
+ scaleX: 1 / E,
+ scaleY: 1 / V
+ }, at = U + 2 * 2, H = z + 2 * 2, lt = y.getCanvas("mesh", at, H, !1), gt = lt.context, wt = gt.createImageData(U, z);
+ if (C) {
+ const S = wt.data;
+ for (let i = 0, n = S.length; i < n; i += 4)
+ S[i] = C[0], S[i + 1] = C[1], S[i + 2] = C[2], S[i + 3] = 255;
+ }
+ for (const S of this._figures)
+ g(wt, S, st);
+ return gt.putImageData(wt, 2, 2), {
+ canvas: lt.canvas,
+ offsetX: p - 2 * E,
+ offsetY: r - 2 * V,
+ scaleX: E,
+ scaleY: V
+ };
+ }
+ getPattern(w, C, y, a) {
+ X(w, this._bbox);
+ let c;
+ if (a === rt.SHADING)
+ c = l.Util.singularValueDecompose2dScale((0, P.getCurrentTransform)(w));
+ else if (c = l.Util.singularValueDecompose2dScale(C.baseTransform), this.matrix) {
+ const p = l.Util.singularValueDecompose2dScale(this.matrix);
+ c = [c[0] * p[0], c[1] * p[1]];
+ }
+ const k = this._createMeshCanvas(c, a === rt.SHADING ? null : this._background, C.cachedCanvases);
+ return a !== rt.SHADING && (w.setTransform(...C.baseTransform), this.matrix && w.transform(...this.matrix)), w.translate(k.offsetX, k.offsetY), w.scale(k.scaleX, k.scaleY), w.createPattern(k.canvas, "no-repeat");
+ }
+ }
+ class I extends pt {
+ getPattern() {
+ return "hotpink";
+ }
+ }
+ function x(_) {
+ switch (_[0]) {
+ case "RadialAxial":
+ return new B(_);
+ case "Mesh":
+ return new O(_);
+ case "Dummy":
+ return new I();
+ }
+ throw new Error(`Unknown IR type: ${_[0]}`);
+ }
+ const v = {
+ COLORED: 1,
+ UNCOLORED: 2
+ }, u = class u {
+ constructor(w, C, y, a, c) {
+ this.operatorList = w[2], this.matrix = w[3] || [1, 0, 0, 1, 0, 0], this.bbox = w[4], this.xstep = w[5], this.ystep = w[6], this.paintType = w[7], this.tilingType = w[8], this.color = C, this.ctx = y, this.canvasGraphicsFactory = a, this.baseTransform = c;
+ }
+ createPatternCanvas(w) {
+ const C = this.operatorList, y = this.bbox, a = this.xstep, c = this.ystep, k = this.paintType, p = this.tilingType, r = this.color, T = this.canvasGraphicsFactory;
+ (0, l.info)("TilingType: " + p);
+ const m = y[0], U = y[1], z = y[2], E = y[3], V = l.Util.singularValueDecompose2dScale(this.matrix), st = l.Util.singularValueDecompose2dScale(this.baseTransform), at = [V[0] * st[0], V[1] * st[1]], H = this.getSizeAndScale(a, this.ctx.canvas.width, at[0]), lt = this.getSizeAndScale(c, this.ctx.canvas.height, at[1]), gt = w.cachedCanvases.getCanvas("pattern", H.size, lt.size, !0), wt = gt.context, xt = T.createCanvasGraphics(wt);
+ xt.groupLevel = w.groupLevel, this.setFillAndStrokeStyleToContext(xt, k, r);
+ let S = m, i = U, n = z, s = E;
+ return m < 0 && (S = 0, n += Math.abs(m)), U < 0 && (i = 0, s += Math.abs(U)), wt.translate(-(H.scale * S), -(lt.scale * i)), xt.transform(H.scale, 0, 0, lt.scale, 0, 0), wt.save(), this.clipBbox(xt, S, i, n, s), xt.baseTransform = (0, P.getCurrentTransform)(xt.ctx), xt.executeOperatorList(C), xt.endDrawing(), {
+ canvas: gt.canvas,
+ scaleX: H.scale,
+ scaleY: lt.scale,
+ offsetX: S,
+ offsetY: i
+ };
+ }
+ getSizeAndScale(w, C, y) {
+ w = Math.abs(w);
+ const a = Math.max(u.MAX_PATTERN_SIZE, C);
+ let c = Math.ceil(w * y);
+ return c >= a ? c = a : y = c / w, {
+ scale: y,
+ size: c
+ };
+ }
+ clipBbox(w, C, y, a, c) {
+ const k = a - C, p = c - y;
+ w.ctx.rect(C, y, k, p), w.current.updateRectMinMax((0, P.getCurrentTransform)(w.ctx), [C, y, a, c]), w.clip(), w.endPath();
+ }
+ setFillAndStrokeStyleToContext(w, C, y) {
+ const a = w.ctx, c = w.current;
+ switch (C) {
+ case v.COLORED:
+ const k = this.ctx;
+ a.fillStyle = k.fillStyle, a.strokeStyle = k.strokeStyle, c.fillColor = k.fillStyle, c.strokeColor = k.strokeStyle;
+ break;
+ case v.UNCOLORED:
+ const p = l.Util.makeHexColor(y[0], y[1], y[2]);
+ a.fillStyle = p, a.strokeStyle = p, c.fillColor = p, c.strokeColor = p;
+ break;
+ default:
+ throw new l.FormatError(`Unsupported paint type: ${C}`);
+ }
+ }
+ getPattern(w, C, y, a) {
+ let c = y;
+ a !== rt.SHADING && (c = l.Util.transform(c, C.baseTransform), this.matrix && (c = l.Util.transform(c, this.matrix)));
+ const k = this.createPatternCanvas(C);
+ let p = new DOMMatrix(c);
+ p = p.translate(k.offsetX, k.offsetY), p = p.scale(1 / k.scaleX, 1 / k.scaleY);
+ const r = w.createPattern(k.canvas, "repeat");
+ return r.setTransform(p), r;
+ }
+ };
+ ee(u, "MAX_PATTERN_SIZE", 3e3);
+ let A = u;
+ d.TilingPattern = A;
+ },
+ /* 13 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.convertBlackAndWhiteToRGBA = rt, d.convertToRGBA = P, d.grayToRGBA = pt;
+ var l = et(1);
+ function P(B) {
+ switch (B.kind) {
+ case l.ImageKind.GRAYSCALE_1BPP:
+ return rt(B);
+ case l.ImageKind.RGB_24BPP:
+ return X(B);
+ }
+ return null;
+ }
+ function rt({
+ src: B,
+ srcPos: F = 0,
+ dest: g,
+ width: O,
+ height: I,
+ nonBlackColor: x = 4294967295,
+ inverseDecode: v = !1
+ }) {
+ const A = l.FeatureTest.isLittleEndian ? 4278190080 : 255, [u, _] = v ? [x, A] : [A, x], w = O >> 3, C = O & 7, y = B.length;
+ g = new Uint32Array(g.buffer);
+ let a = 0;
+ for (let c = 0; c < I; c++) {
+ for (const p = F + w; F < p; F++) {
+ const r = F < y ? B[F] : 255;
+ g[a++] = r & 128 ? _ : u, g[a++] = r & 64 ? _ : u, g[a++] = r & 32 ? _ : u, g[a++] = r & 16 ? _ : u, g[a++] = r & 8 ? _ : u, g[a++] = r & 4 ? _ : u, g[a++] = r & 2 ? _ : u, g[a++] = r & 1 ? _ : u;
+ }
+ if (C === 0)
+ continue;
+ const k = F < y ? B[F++] : 255;
+ for (let p = 0; p < C; p++)
+ g[a++] = k & 1 << 7 - p ? _ : u;
+ }
+ return {
+ srcPos: F,
+ destPos: a
+ };
+ }
+ function X({
+ src: B,
+ srcPos: F = 0,
+ dest: g,
+ destPos: O = 0,
+ width: I,
+ height: x
+ }) {
+ let v = 0;
+ const A = B.length >> 2, u = new Uint32Array(B.buffer, F, A);
+ if (l.FeatureTest.isLittleEndian) {
+ for (; v < A - 2; v += 3, O += 4) {
+ const _ = u[v], w = u[v + 1], C = u[v + 2];
+ g[O] = _ | 4278190080, g[O + 1] = _ >>> 24 | w << 8 | 4278190080, g[O + 2] = w >>> 16 | C << 16 | 4278190080, g[O + 3] = C >>> 8 | 4278190080;
+ }
+ for (let _ = v * 4, w = B.length; _ < w; _ += 3)
+ g[O++] = B[_] | B[_ + 1] << 8 | B[_ + 2] << 16 | 4278190080;
+ } else {
+ for (; v < A - 2; v += 3, O += 4) {
+ const _ = u[v], w = u[v + 1], C = u[v + 2];
+ g[O] = _ | 255, g[O + 1] = _ << 24 | w >>> 8 | 255, g[O + 2] = w << 16 | C >>> 16 | 255, g[O + 3] = C << 8 | 255;
+ }
+ for (let _ = v * 4, w = B.length; _ < w; _ += 3)
+ g[O++] = B[_] << 24 | B[_ + 1] << 16 | B[_ + 2] << 8 | 255;
+ }
+ return {
+ srcPos: F,
+ destPos: O
+ };
+ }
+ function pt(B, F) {
+ if (l.FeatureTest.isLittleEndian)
+ for (let g = 0, O = B.length; g < O; g++)
+ F[g] = B[g] * 65793 | 4278190080;
+ else
+ for (let g = 0, O = B.length; g < O; g++)
+ F[g] = B[g] * 16843008 | 255;
+ }
+ },
+ /* 14 */
+ /***/
+ (dt, d) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.GlobalWorkerOptions = void 0;
+ const et = /* @__PURE__ */ Object.create(null);
+ d.GlobalWorkerOptions = et, et.workerPort = null, et.workerSrc = "";
+ },
+ /* 15 */
+ /***/
+ (dt, d, et) => {
+ var B, xi, g, ki, I, xe;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.MessageHandler = void 0;
+ var l = et(1);
+ const P = {
+ UNKNOWN: 0,
+ DATA: 1,
+ ERROR: 2
+ }, rt = {
+ UNKNOWN: 0,
+ CANCEL: 1,
+ CANCEL_COMPLETE: 2,
+ CLOSE: 3,
+ ENQUEUE: 4,
+ ERROR: 5,
+ PULL: 6,
+ PULL_COMPLETE: 7,
+ START_COMPLETE: 8
+ };
+ function X(v) {
+ switch (v instanceof Error || typeof v == "object" && v !== null || (0, l.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'), v.name) {
+ case "AbortException":
+ return new l.AbortException(v.message);
+ case "MissingPDFException":
+ return new l.MissingPDFException(v.message);
+ case "PasswordException":
+ return new l.PasswordException(v.message, v.code);
+ case "UnexpectedResponseException":
+ return new l.UnexpectedResponseException(v.message, v.status);
+ case "UnknownErrorException":
+ return new l.UnknownErrorException(v.message, v.details);
+ default:
+ return new l.UnknownErrorException(v.message, v.toString());
+ }
+ }
+ class pt {
+ constructor(A, u, _) {
+ L(this, B);
+ L(this, g);
+ L(this, I);
+ this.sourceName = A, this.targetName = u, this.comObj = _, this.callbackId = 1, this.streamId = 1, this.streamSinks = /* @__PURE__ */ Object.create(null), this.streamControllers = /* @__PURE__ */ Object.create(null), this.callbackCapabilities = /* @__PURE__ */ Object.create(null), this.actionHandler = /* @__PURE__ */ Object.create(null), this._onComObjOnMessage = (w) => {
+ const C = w.data;
+ if (C.targetName !== this.sourceName)
+ return;
+ if (C.stream) {
+ W(this, g, ki).call(this, C);
+ return;
+ }
+ if (C.callback) {
+ const a = C.callbackId, c = this.callbackCapabilities[a];
+ if (!c)
+ throw new Error(`Cannot resolve callback ${a}`);
+ if (delete this.callbackCapabilities[a], C.callback === P.DATA)
+ c.resolve(C.data);
+ else if (C.callback === P.ERROR)
+ c.reject(X(C.reason));
+ else
+ throw new Error("Unexpected callback case");
+ return;
+ }
+ const y = this.actionHandler[C.action];
+ if (!y)
+ throw new Error(`Unknown action from worker: ${C.action}`);
+ if (C.callbackId) {
+ const a = this.sourceName, c = C.sourceName;
+ new Promise(function(k) {
+ k(y(C.data));
+ }).then(function(k) {
+ _.postMessage({
+ sourceName: a,
+ targetName: c,
+ callback: P.DATA,
+ callbackId: C.callbackId,
+ data: k
+ });
+ }, function(k) {
+ _.postMessage({
+ sourceName: a,
+ targetName: c,
+ callback: P.ERROR,
+ callbackId: C.callbackId,
+ reason: X(k)
+ });
+ });
+ return;
+ }
+ if (C.streamId) {
+ W(this, B, xi).call(this, C);
+ return;
+ }
+ y(C.data);
+ }, _.addEventListener("message", this._onComObjOnMessage);
+ }
+ on(A, u) {
+ const _ = this.actionHandler;
+ if (_[A])
+ throw new Error(`There is already an actionName called "${A}"`);
+ _[A] = u;
+ }
+ send(A, u, _) {
+ this.comObj.postMessage({
+ sourceName: this.sourceName,
+ targetName: this.targetName,
+ action: A,
+ data: u
+ }, _);
+ }
+ sendWithPromise(A, u, _) {
+ const w = this.callbackId++, C = new l.PromiseCapability();
+ this.callbackCapabilities[w] = C;
+ try {
+ this.comObj.postMessage({
+ sourceName: this.sourceName,
+ targetName: this.targetName,
+ action: A,
+ callbackId: w,
+ data: u
+ }, _);
+ } catch (y) {
+ C.reject(y);
+ }
+ return C.promise;
+ }
+ sendWithStream(A, u, _, w) {
+ const C = this.streamId++, y = this.sourceName, a = this.targetName, c = this.comObj;
+ return new ReadableStream({
+ start: (k) => {
+ const p = new l.PromiseCapability();
+ return this.streamControllers[C] = {
+ controller: k,
+ startCall: p,
+ pullCall: null,
+ cancelCall: null,
+ isClosed: !1
+ }, c.postMessage({
+ sourceName: y,
+ targetName: a,
+ action: A,
+ streamId: C,
+ data: u,
+ desiredSize: k.desiredSize
+ }, w), p.promise;
+ },
+ pull: (k) => {
+ const p = new l.PromiseCapability();
+ return this.streamControllers[C].pullCall = p, c.postMessage({
+ sourceName: y,
+ targetName: a,
+ stream: rt.PULL,
+ streamId: C,
+ desiredSize: k.desiredSize
+ }), p.promise;
+ },
+ cancel: (k) => {
+ (0, l.assert)(k instanceof Error, "cancel must have a valid reason");
+ const p = new l.PromiseCapability();
+ return this.streamControllers[C].cancelCall = p, this.streamControllers[C].isClosed = !0, c.postMessage({
+ sourceName: y,
+ targetName: a,
+ stream: rt.CANCEL,
+ streamId: C,
+ reason: X(k)
+ }), p.promise;
+ }
+ }, _);
+ }
+ destroy() {
+ this.comObj.removeEventListener("message", this._onComObjOnMessage);
+ }
+ }
+ B = new WeakSet(), xi = function(A) {
+ const u = A.streamId, _ = this.sourceName, w = A.sourceName, C = this.comObj, y = this, a = this.actionHandler[A.action], c = {
+ enqueue(k, p = 1, r) {
+ if (this.isCancelled)
+ return;
+ const T = this.desiredSize;
+ this.desiredSize -= p, T > 0 && this.desiredSize <= 0 && (this.sinkCapability = new l.PromiseCapability(), this.ready = this.sinkCapability.promise), C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.ENQUEUE,
+ streamId: u,
+ chunk: k
+ }, r);
+ },
+ close() {
+ this.isCancelled || (this.isCancelled = !0, C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.CLOSE,
+ streamId: u
+ }), delete y.streamSinks[u]);
+ },
+ error(k) {
+ (0, l.assert)(k instanceof Error, "error must have a valid reason"), !this.isCancelled && (this.isCancelled = !0, C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.ERROR,
+ streamId: u,
+ reason: X(k)
+ }));
+ },
+ sinkCapability: new l.PromiseCapability(),
+ onPull: null,
+ onCancel: null,
+ isCancelled: !1,
+ desiredSize: A.desiredSize,
+ ready: null
+ };
+ c.sinkCapability.resolve(), c.ready = c.sinkCapability.promise, this.streamSinks[u] = c, new Promise(function(k) {
+ k(a(A.data, c));
+ }).then(function() {
+ C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.START_COMPLETE,
+ streamId: u,
+ success: !0
+ });
+ }, function(k) {
+ C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.START_COMPLETE,
+ streamId: u,
+ reason: X(k)
+ });
+ });
+ }, g = new WeakSet(), ki = function(A) {
+ const u = A.streamId, _ = this.sourceName, w = A.sourceName, C = this.comObj, y = this.streamControllers[u], a = this.streamSinks[u];
+ switch (A.stream) {
+ case rt.START_COMPLETE:
+ A.success ? y.startCall.resolve() : y.startCall.reject(X(A.reason));
+ break;
+ case rt.PULL_COMPLETE:
+ A.success ? y.pullCall.resolve() : y.pullCall.reject(X(A.reason));
+ break;
+ case rt.PULL:
+ if (!a) {
+ C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.PULL_COMPLETE,
+ streamId: u,
+ success: !0
+ });
+ break;
+ }
+ a.desiredSize <= 0 && A.desiredSize > 0 && a.sinkCapability.resolve(), a.desiredSize = A.desiredSize, new Promise(function(c) {
+ var k;
+ c((k = a.onPull) == null ? void 0 : k.call(a));
+ }).then(function() {
+ C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.PULL_COMPLETE,
+ streamId: u,
+ success: !0
+ });
+ }, function(c) {
+ C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.PULL_COMPLETE,
+ streamId: u,
+ reason: X(c)
+ });
+ });
+ break;
+ case rt.ENQUEUE:
+ if ((0, l.assert)(y, "enqueue should have stream controller"), y.isClosed)
+ break;
+ y.controller.enqueue(A.chunk);
+ break;
+ case rt.CLOSE:
+ if ((0, l.assert)(y, "close should have stream controller"), y.isClosed)
+ break;
+ y.isClosed = !0, y.controller.close(), W(this, I, xe).call(this, y, u);
+ break;
+ case rt.ERROR:
+ (0, l.assert)(y, "error should have stream controller"), y.controller.error(X(A.reason)), W(this, I, xe).call(this, y, u);
+ break;
+ case rt.CANCEL_COMPLETE:
+ A.success ? y.cancelCall.resolve() : y.cancelCall.reject(X(A.reason)), W(this, I, xe).call(this, y, u);
+ break;
+ case rt.CANCEL:
+ if (!a)
+ break;
+ new Promise(function(c) {
+ var k;
+ c((k = a.onCancel) == null ? void 0 : k.call(a, X(A.reason)));
+ }).then(function() {
+ C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.CANCEL_COMPLETE,
+ streamId: u,
+ success: !0
+ });
+ }, function(c) {
+ C.postMessage({
+ sourceName: _,
+ targetName: w,
+ stream: rt.CANCEL_COMPLETE,
+ streamId: u,
+ reason: X(c)
+ });
+ }), a.sinkCapability.reject(X(A.reason)), a.isCancelled = !0, delete this.streamSinks[u];
+ break;
+ default:
+ throw new Error("Unexpected stream case");
+ }
+ }, I = new WeakSet(), xe = async function(A, u) {
+ var _, w, C;
+ await Promise.allSettled([(_ = A.startCall) == null ? void 0 : _.promise, (w = A.pullCall) == null ? void 0 : w.promise, (C = A.cancelCall) == null ? void 0 : C.promise]), delete this.streamControllers[u];
+ }, d.MessageHandler = pt;
+ },
+ /* 16 */
+ /***/
+ (dt, d, et) => {
+ var rt, X;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.Metadata = void 0;
+ var l = et(1);
+ class P {
+ constructor({
+ parsedData: B,
+ rawData: F
+ }) {
+ L(this, rt, void 0);
+ L(this, X, void 0);
+ Z(this, rt, B), Z(this, X, F);
+ }
+ getRaw() {
+ return t(this, X);
+ }
+ get(B) {
+ return t(this, rt).get(B) ?? null;
+ }
+ getAll() {
+ return (0, l.objectFromMap)(t(this, rt));
+ }
+ has(B) {
+ return t(this, rt).has(B);
+ }
+ }
+ rt = new WeakMap(), X = new WeakMap(), d.Metadata = P;
+ },
+ /* 17 */
+ /***/
+ (dt, d, et) => {
+ var B, F, g, O, I, x, ti;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.OptionalContentConfig = void 0;
+ var l = et(1), P = et(8);
+ const rt = Symbol("INTERNAL");
+ class X {
+ constructor(u, _) {
+ L(this, B, !0);
+ this.name = u, this.intent = _;
+ }
+ get visible() {
+ return t(this, B);
+ }
+ _setVisible(u, _) {
+ u !== rt && (0, l.unreachable)("Internal method `_setVisible` called."), Z(this, B, _);
+ }
+ }
+ B = new WeakMap();
+ class pt {
+ constructor(u) {
+ L(this, x);
+ L(this, F, null);
+ L(this, g, /* @__PURE__ */ new Map());
+ L(this, O, null);
+ L(this, I, null);
+ if (this.name = null, this.creator = null, u !== null) {
+ this.name = u.name, this.creator = u.creator, Z(this, I, u.order);
+ for (const _ of u.groups)
+ t(this, g).set(_.id, new X(_.name, _.intent));
+ if (u.baseState === "OFF")
+ for (const _ of t(this, g).values())
+ _._setVisible(rt, !1);
+ for (const _ of u.on)
+ t(this, g).get(_)._setVisible(rt, !0);
+ for (const _ of u.off)
+ t(this, g).get(_)._setVisible(rt, !1);
+ Z(this, O, this.getHash());
+ }
+ }
+ isVisible(u) {
+ if (t(this, g).size === 0)
+ return !0;
+ if (!u)
+ return (0, l.warn)("Optional content group not defined."), !0;
+ if (u.type === "OCG")
+ return t(this, g).has(u.id) ? t(this, g).get(u.id).visible : ((0, l.warn)(`Optional content group not found: ${u.id}`), !0);
+ if (u.type === "OCMD") {
+ if (u.expression)
+ return W(this, x, ti).call(this, u.expression);
+ if (!u.policy || u.policy === "AnyOn") {
+ for (const _ of u.ids) {
+ if (!t(this, g).has(_))
+ return (0, l.warn)(`Optional content group not found: ${_}`), !0;
+ if (t(this, g).get(_).visible)
+ return !0;
+ }
+ return !1;
+ } else if (u.policy === "AllOn") {
+ for (const _ of u.ids) {
+ if (!t(this, g).has(_))
+ return (0, l.warn)(`Optional content group not found: ${_}`), !0;
+ if (!t(this, g).get(_).visible)
+ return !1;
+ }
+ return !0;
+ } else if (u.policy === "AnyOff") {
+ for (const _ of u.ids) {
+ if (!t(this, g).has(_))
+ return (0, l.warn)(`Optional content group not found: ${_}`), !0;
+ if (!t(this, g).get(_).visible)
+ return !0;
+ }
+ return !1;
+ } else if (u.policy === "AllOff") {
+ for (const _ of u.ids) {
+ if (!t(this, g).has(_))
+ return (0, l.warn)(`Optional content group not found: ${_}`), !0;
+ if (t(this, g).get(_).visible)
+ return !1;
+ }
+ return !0;
+ }
+ return (0, l.warn)(`Unknown optional content policy ${u.policy}.`), !0;
+ }
+ return (0, l.warn)(`Unknown group type ${u.type}.`), !0;
+ }
+ setVisibility(u, _ = !0) {
+ if (!t(this, g).has(u)) {
+ (0, l.warn)(`Optional content group not found: ${u}`);
+ return;
+ }
+ t(this, g).get(u)._setVisible(rt, !!_), Z(this, F, null);
+ }
+ get hasInitialVisibility() {
+ return t(this, O) === null || this.getHash() === t(this, O);
+ }
+ getOrder() {
+ return t(this, g).size ? t(this, I) ? t(this, I).slice() : [...t(this, g).keys()] : null;
+ }
+ getGroups() {
+ return t(this, g).size > 0 ? (0, l.objectFromMap)(t(this, g)) : null;
+ }
+ getGroup(u) {
+ return t(this, g).get(u) || null;
+ }
+ getHash() {
+ if (t(this, F) !== null)
+ return t(this, F);
+ const u = new P.MurmurHash3_64();
+ for (const [_, w] of t(this, g))
+ u.update(`${_}:${w.visible}`);
+ return Z(this, F, u.hexdigest());
+ }
+ }
+ F = new WeakMap(), g = new WeakMap(), O = new WeakMap(), I = new WeakMap(), x = new WeakSet(), ti = function(u) {
+ const _ = u.length;
+ if (_ < 2)
+ return !0;
+ const w = u[0];
+ for (let C = 1; C < _; C++) {
+ const y = u[C];
+ let a;
+ if (Array.isArray(y))
+ a = W(this, x, ti).call(this, y);
+ else if (t(this, g).has(y))
+ a = t(this, g).get(y).visible;
+ else
+ return (0, l.warn)(`Optional content group not found: ${y}`), !0;
+ switch (w) {
+ case "And":
+ if (!a)
+ return !1;
+ break;
+ case "Or":
+ if (a)
+ return !0;
+ break;
+ case "Not":
+ return !a;
+ default:
+ return !0;
+ }
+ }
+ return w === "And";
+ }, d.OptionalContentConfig = pt;
+ },
+ /* 18 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.PDFDataTransportStream = void 0;
+ var l = et(1), P = et(6);
+ class rt {
+ constructor({
+ length: F,
+ initialData: g,
+ progressiveDone: O = !1,
+ contentDispositionFilename: I = null,
+ disableRange: x = !1,
+ disableStream: v = !1
+ }, A) {
+ if ((0, l.assert)(A, 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'), this._queuedChunks = [], this._progressiveDone = O, this._contentDispositionFilename = I, (g == null ? void 0 : g.length) > 0) {
+ const u = g instanceof Uint8Array && g.byteLength === g.buffer.byteLength ? g.buffer : new Uint8Array(g).buffer;
+ this._queuedChunks.push(u);
+ }
+ this._pdfDataRangeTransport = A, this._isStreamingSupported = !v, this._isRangeSupported = !x, this._contentLength = F, this._fullRequestReader = null, this._rangeReaders = [], this._pdfDataRangeTransport.addRangeListener((u, _) => {
+ this._onReceiveData({
+ begin: u,
+ chunk: _
+ });
+ }), this._pdfDataRangeTransport.addProgressListener((u, _) => {
+ this._onProgress({
+ loaded: u,
+ total: _
+ });
+ }), this._pdfDataRangeTransport.addProgressiveReadListener((u) => {
+ this._onReceiveData({
+ chunk: u
+ });
+ }), this._pdfDataRangeTransport.addProgressiveDoneListener(() => {
+ this._onProgressiveDone();
+ }), this._pdfDataRangeTransport.transportReady();
+ }
+ _onReceiveData({
+ begin: F,
+ chunk: g
+ }) {
+ const O = g instanceof Uint8Array && g.byteLength === g.buffer.byteLength ? g.buffer : new Uint8Array(g).buffer;
+ if (F === void 0)
+ this._fullRequestReader ? this._fullRequestReader._enqueue(O) : this._queuedChunks.push(O);
+ else {
+ const I = this._rangeReaders.some(function(x) {
+ return x._begin !== F ? !1 : (x._enqueue(O), !0);
+ });
+ (0, l.assert)(I, "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");
+ }
+ }
+ get _progressiveDataLength() {
+ var F;
+ return ((F = this._fullRequestReader) == null ? void 0 : F._loaded) ?? 0;
+ }
+ _onProgress(F) {
+ var g, O, I, x;
+ F.total === void 0 ? (O = (g = this._rangeReaders[0]) == null ? void 0 : g.onProgress) == null || O.call(g, {
+ loaded: F.loaded
+ }) : (x = (I = this._fullRequestReader) == null ? void 0 : I.onProgress) == null || x.call(I, {
+ loaded: F.loaded,
+ total: F.total
+ });
+ }
+ _onProgressiveDone() {
+ var F;
+ (F = this._fullRequestReader) == null || F.progressiveDone(), this._progressiveDone = !0;
+ }
+ _removeRangeReader(F) {
+ const g = this._rangeReaders.indexOf(F);
+ g >= 0 && this._rangeReaders.splice(g, 1);
+ }
+ getFullReader() {
+ (0, l.assert)(!this._fullRequestReader, "PDFDataTransportStream.getFullReader can only be called once.");
+ const F = this._queuedChunks;
+ return this._queuedChunks = null, new X(this, F, this._progressiveDone, this._contentDispositionFilename);
+ }
+ getRangeReader(F, g) {
+ if (g <= this._progressiveDataLength)
+ return null;
+ const O = new pt(this, F, g);
+ return this._pdfDataRangeTransport.requestDataRange(F, g), this._rangeReaders.push(O), O;
+ }
+ cancelAllRequests(F) {
+ var g;
+ (g = this._fullRequestReader) == null || g.cancel(F);
+ for (const O of this._rangeReaders.slice(0))
+ O.cancel(F);
+ this._pdfDataRangeTransport.abort();
+ }
+ }
+ d.PDFDataTransportStream = rt;
+ class X {
+ constructor(F, g, O = !1, I = null) {
+ this._stream = F, this._done = O || !1, this._filename = (0, P.isPdfFile)(I) ? I : null, this._queuedChunks = g || [], this._loaded = 0;
+ for (const x of this._queuedChunks)
+ this._loaded += x.byteLength;
+ this._requests = [], this._headersReady = Promise.resolve(), F._fullRequestReader = this, this.onProgress = null;
+ }
+ _enqueue(F) {
+ this._done || (this._requests.length > 0 ? this._requests.shift().resolve({
+ value: F,
+ done: !1
+ }) : this._queuedChunks.push(F), this._loaded += F.byteLength);
+ }
+ get headersReady() {
+ return this._headersReady;
+ }
+ get filename() {
+ return this._filename;
+ }
+ get isRangeSupported() {
+ return this._stream._isRangeSupported;
+ }
+ get isStreamingSupported() {
+ return this._stream._isStreamingSupported;
+ }
+ get contentLength() {
+ return this._stream._contentLength;
+ }
+ async read() {
+ if (this._queuedChunks.length > 0)
+ return {
+ value: this._queuedChunks.shift(),
+ done: !1
+ };
+ if (this._done)
+ return {
+ value: void 0,
+ done: !0
+ };
+ const F = new l.PromiseCapability();
+ return this._requests.push(F), F.promise;
+ }
+ cancel(F) {
+ this._done = !0;
+ for (const g of this._requests)
+ g.resolve({
+ value: void 0,
+ done: !0
+ });
+ this._requests.length = 0;
+ }
+ progressiveDone() {
+ this._done || (this._done = !0);
+ }
+ }
+ class pt {
+ constructor(F, g, O) {
+ this._stream = F, this._begin = g, this._end = O, this._queuedChunk = null, this._requests = [], this._done = !1, this.onProgress = null;
+ }
+ _enqueue(F) {
+ if (!this._done) {
+ if (this._requests.length === 0)
+ this._queuedChunk = F;
+ else {
+ this._requests.shift().resolve({
+ value: F,
+ done: !1
+ });
+ for (const O of this._requests)
+ O.resolve({
+ value: void 0,
+ done: !0
+ });
+ this._requests.length = 0;
+ }
+ this._done = !0, this._stream._removeRangeReader(this);
+ }
+ }
+ get isStreamingSupported() {
+ return !1;
+ }
+ async read() {
+ if (this._queuedChunk) {
+ const g = this._queuedChunk;
+ return this._queuedChunk = null, {
+ value: g,
+ done: !1
+ };
+ }
+ if (this._done)
+ return {
+ value: void 0,
+ done: !0
+ };
+ const F = new l.PromiseCapability();
+ return this._requests.push(F), F.promise;
+ }
+ cancel(F) {
+ this._done = !0;
+ for (const g of this._requests)
+ g.resolve({
+ value: void 0,
+ done: !0
+ });
+ this._requests.length = 0, this._stream._removeRangeReader(this);
+ }
+ }
+ },
+ /* 19 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.PDFFetchStream = void 0;
+ var l = et(1), P = et(20);
+ function rt(O, I, x) {
+ return {
+ method: "GET",
+ headers: O,
+ signal: x.signal,
+ mode: "cors",
+ credentials: I ? "include" : "same-origin",
+ redirect: "follow"
+ };
+ }
+ function X(O) {
+ const I = new Headers();
+ for (const x in O) {
+ const v = O[x];
+ v !== void 0 && I.append(x, v);
+ }
+ return I;
+ }
+ function pt(O) {
+ return O instanceof Uint8Array ? O.buffer : O instanceof ArrayBuffer ? O : ((0, l.warn)(`getArrayBuffer - unexpected data format: ${O}`), new Uint8Array(O).buffer);
+ }
+ class B {
+ constructor(I) {
+ this.source = I, this.isHttp = /^https?:/i.test(I.url), this.httpHeaders = this.isHttp && I.httpHeaders || {}, this._fullRequestReader = null, this._rangeRequestReaders = [];
+ }
+ get _progressiveDataLength() {
+ var I;
+ return ((I = this._fullRequestReader) == null ? void 0 : I._loaded) ?? 0;
+ }
+ getFullReader() {
+ return (0, l.assert)(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once."), this._fullRequestReader = new F(this), this._fullRequestReader;
+ }
+ getRangeReader(I, x) {
+ if (x <= this._progressiveDataLength)
+ return null;
+ const v = new g(this, I, x);
+ return this._rangeRequestReaders.push(v), v;
+ }
+ cancelAllRequests(I) {
+ var x;
+ (x = this._fullRequestReader) == null || x.cancel(I);
+ for (const v of this._rangeRequestReaders.slice(0))
+ v.cancel(I);
+ }
+ }
+ d.PDFFetchStream = B;
+ class F {
+ constructor(I) {
+ this._stream = I, this._reader = null, this._loaded = 0, this._filename = null;
+ const x = I.source;
+ this._withCredentials = x.withCredentials || !1, this._contentLength = x.length, this._headersCapability = new l.PromiseCapability(), this._disableRange = x.disableRange || !1, this._rangeChunkSize = x.rangeChunkSize, !this._rangeChunkSize && !this._disableRange && (this._disableRange = !0), this._abortController = new AbortController(), this._isStreamingSupported = !x.disableStream, this._isRangeSupported = !x.disableRange, this._headers = X(this._stream.httpHeaders);
+ const v = x.url;
+ fetch(v, rt(this._headers, this._withCredentials, this._abortController)).then((A) => {
+ if (!(0, P.validateResponseStatus)(A.status))
+ throw (0, P.createResponseStatusError)(A.status, v);
+ this._reader = A.body.getReader(), this._headersCapability.resolve();
+ const u = (C) => A.headers.get(C), {
+ allowRangeRequests: _,
+ suggestedLength: w
+ } = (0, P.validateRangeRequestCapabilities)({
+ getResponseHeader: u,
+ isHttp: this._stream.isHttp,
+ rangeChunkSize: this._rangeChunkSize,
+ disableRange: this._disableRange
+ });
+ this._isRangeSupported = _, this._contentLength = w || this._contentLength, this._filename = (0, P.extractFilenameFromHeader)(u), !this._isStreamingSupported && this._isRangeSupported && this.cancel(new l.AbortException("Streaming is disabled."));
+ }).catch(this._headersCapability.reject), this.onProgress = null;
+ }
+ get headersReady() {
+ return this._headersCapability.promise;
+ }
+ get filename() {
+ return this._filename;
+ }
+ get contentLength() {
+ return this._contentLength;
+ }
+ get isRangeSupported() {
+ return this._isRangeSupported;
+ }
+ get isStreamingSupported() {
+ return this._isStreamingSupported;
+ }
+ async read() {
+ var v;
+ await this._headersCapability.promise;
+ const {
+ value: I,
+ done: x
+ } = await this._reader.read();
+ return x ? {
+ value: I,
+ done: x
+ } : (this._loaded += I.byteLength, (v = this.onProgress) == null || v.call(this, {
+ loaded: this._loaded,
+ total: this._contentLength
+ }), {
+ value: pt(I),
+ done: !1
+ });
+ }
+ cancel(I) {
+ var x;
+ (x = this._reader) == null || x.cancel(I), this._abortController.abort();
+ }
+ }
+ class g {
+ constructor(I, x, v) {
+ this._stream = I, this._reader = null, this._loaded = 0;
+ const A = I.source;
+ this._withCredentials = A.withCredentials || !1, this._readCapability = new l.PromiseCapability(), this._isStreamingSupported = !A.disableStream, this._abortController = new AbortController(), this._headers = X(this._stream.httpHeaders), this._headers.append("Range", `bytes=${x}-${v - 1}`);
+ const u = A.url;
+ fetch(u, rt(this._headers, this._withCredentials, this._abortController)).then((_) => {
+ if (!(0, P.validateResponseStatus)(_.status))
+ throw (0, P.createResponseStatusError)(_.status, u);
+ this._readCapability.resolve(), this._reader = _.body.getReader();
+ }).catch(this._readCapability.reject), this.onProgress = null;
+ }
+ get isStreamingSupported() {
+ return this._isStreamingSupported;
+ }
+ async read() {
+ var v;
+ await this._readCapability.promise;
+ const {
+ value: I,
+ done: x
+ } = await this._reader.read();
+ return x ? {
+ value: I,
+ done: x
+ } : (this._loaded += I.byteLength, (v = this.onProgress) == null || v.call(this, {
+ loaded: this._loaded
+ }), {
+ value: pt(I),
+ done: !1
+ });
+ }
+ cancel(I) {
+ var x;
+ (x = this._reader) == null || x.cancel(I), this._abortController.abort();
+ }
+ }
+ },
+ /* 20 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.createResponseStatusError = B, d.extractFilenameFromHeader = pt, d.validateRangeRequestCapabilities = X, d.validateResponseStatus = F;
+ var l = et(1), P = et(21), rt = et(6);
+ function X({
+ getResponseHeader: g,
+ isHttp: O,
+ rangeChunkSize: I,
+ disableRange: x
+ }) {
+ const v = {
+ allowRangeRequests: !1,
+ suggestedLength: void 0
+ }, A = parseInt(g("Content-Length"), 10);
+ return !Number.isInteger(A) || (v.suggestedLength = A, A <= 2 * I) || x || !O || g("Accept-Ranges") !== "bytes" || (g("Content-Encoding") || "identity") !== "identity" || (v.allowRangeRequests = !0), v;
+ }
+ function pt(g) {
+ const O = g("Content-Disposition");
+ if (O) {
+ let I = (0, P.getFilenameFromContentDispositionHeader)(O);
+ if (I.includes("%"))
+ try {
+ I = decodeURIComponent(I);
+ } catch {
+ }
+ if ((0, rt.isPdfFile)(I))
+ return I;
+ }
+ return null;
+ }
+ function B(g, O) {
+ return g === 404 || g === 0 && O.startsWith("file:") ? new l.MissingPDFException('Missing PDF "' + O + '".') : new l.UnexpectedResponseException(`Unexpected server response (${g}) while retrieving PDF "${O}".`, g);
+ }
+ function F(g) {
+ return g === 200 || g === 206;
+ }
+ },
+ /* 21 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.getFilenameFromContentDispositionHeader = P;
+ var l = et(1);
+ function P(rt) {
+ let X = !0, pt = B("filename\\*", "i").exec(rt);
+ if (pt) {
+ pt = pt[1];
+ let A = I(pt);
+ return A = unescape(A), A = x(A), A = v(A), g(A);
+ }
+ if (pt = O(rt), pt) {
+ const A = v(pt);
+ return g(A);
+ }
+ if (pt = B("filename", "i").exec(rt), pt) {
+ pt = pt[1];
+ let A = I(pt);
+ return A = v(A), g(A);
+ }
+ function B(A, u) {
+ return new RegExp("(?:^|;)\\s*" + A + '\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)', u);
+ }
+ function F(A, u) {
+ if (A) {
+ if (!/^[\x00-\xFF]+$/.test(u))
+ return u;
+ try {
+ const _ = new TextDecoder(A, {
+ fatal: !0
+ }), w = (0, l.stringToBytes)(u);
+ u = _.decode(w), X = !1;
+ } catch {
+ }
+ }
+ return u;
+ }
+ function g(A) {
+ return X && /[\x80-\xff]/.test(A) && (A = F("utf-8", A), X && (A = F("iso-8859-1", A))), A;
+ }
+ function O(A) {
+ const u = [];
+ let _;
+ const w = B("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
+ for (; (_ = w.exec(A)) !== null; ) {
+ let [, y, a, c] = _;
+ if (y = parseInt(y, 10), y in u) {
+ if (y === 0)
+ break;
+ continue;
+ }
+ u[y] = [a, c];
+ }
+ const C = [];
+ for (let y = 0; y < u.length && y in u; ++y) {
+ let [a, c] = u[y];
+ c = I(c), a && (c = unescape(c), y === 0 && (c = x(c))), C.push(c);
+ }
+ return C.join("");
+ }
+ function I(A) {
+ if (A.startsWith('"')) {
+ const u = A.slice(1).split('\\"');
+ for (let _ = 0; _ < u.length; ++_) {
+ const w = u[_].indexOf('"');
+ w !== -1 && (u[_] = u[_].slice(0, w), u.length = _ + 1), u[_] = u[_].replaceAll(/\\(.)/g, "$1");
+ }
+ A = u.join('"');
+ }
+ return A;
+ }
+ function x(A) {
+ const u = A.indexOf("'");
+ if (u === -1)
+ return A;
+ const _ = A.slice(0, u), C = A.slice(u + 1).replace(/^[^']*'/, "");
+ return F(_, C);
+ }
+ function v(A) {
+ return !A.startsWith("=?") || /[\x00-\x19\x80-\xff]/.test(A) ? A : A.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function(u, _, w, C) {
+ if (w === "q" || w === "Q")
+ return C = C.replaceAll("_", " "), C = C.replaceAll(/=([0-9a-fA-F]{2})/g, function(y, a) {
+ return String.fromCharCode(parseInt(a, 16));
+ }), F(_, C);
+ try {
+ C = atob(C);
+ } catch {
+ }
+ return F(_, C);
+ });
+ }
+ return "";
+ }
+ },
+ /* 22 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.PDFNetworkStream = void 0;
+ var l = et(1), P = et(20);
+ const rt = 200, X = 206;
+ function pt(I) {
+ const x = I.response;
+ return typeof x != "string" ? x : (0, l.stringToBytes)(x).buffer;
+ }
+ class B {
+ constructor(x, v = {}) {
+ this.url = x, this.isHttp = /^https?:/i.test(x), this.httpHeaders = this.isHttp && v.httpHeaders || /* @__PURE__ */ Object.create(null), this.withCredentials = v.withCredentials || !1, this.currXhrId = 0, this.pendingRequests = /* @__PURE__ */ Object.create(null);
+ }
+ requestRange(x, v, A) {
+ const u = {
+ begin: x,
+ end: v
+ };
+ for (const _ in A)
+ u[_] = A[_];
+ return this.request(u);
+ }
+ requestFull(x) {
+ return this.request(x);
+ }
+ request(x) {
+ const v = new XMLHttpRequest(), A = this.currXhrId++, u = this.pendingRequests[A] = {
+ xhr: v
+ };
+ v.open("GET", this.url), v.withCredentials = this.withCredentials;
+ for (const _ in this.httpHeaders) {
+ const w = this.httpHeaders[_];
+ w !== void 0 && v.setRequestHeader(_, w);
+ }
+ return this.isHttp && "begin" in x && "end" in x ? (v.setRequestHeader("Range", `bytes=${x.begin}-${x.end - 1}`), u.expectedStatus = X) : u.expectedStatus = rt, v.responseType = "arraybuffer", x.onError && (v.onerror = function(_) {
+ x.onError(v.status);
+ }), v.onreadystatechange = this.onStateChange.bind(this, A), v.onprogress = this.onProgress.bind(this, A), u.onHeadersReceived = x.onHeadersReceived, u.onDone = x.onDone, u.onError = x.onError, u.onProgress = x.onProgress, v.send(null), A;
+ }
+ onProgress(x, v) {
+ var u;
+ const A = this.pendingRequests[x];
+ A && ((u = A.onProgress) == null || u.call(A, v));
+ }
+ onStateChange(x, v) {
+ var y, a, c;
+ const A = this.pendingRequests[x];
+ if (!A)
+ return;
+ const u = A.xhr;
+ if (u.readyState >= 2 && A.onHeadersReceived && (A.onHeadersReceived(), delete A.onHeadersReceived), u.readyState !== 4 || !(x in this.pendingRequests))
+ return;
+ if (delete this.pendingRequests[x], u.status === 0 && this.isHttp) {
+ (y = A.onError) == null || y.call(A, u.status);
+ return;
+ }
+ const _ = u.status || rt;
+ if (!(_ === rt && A.expectedStatus === X) && _ !== A.expectedStatus) {
+ (a = A.onError) == null || a.call(A, u.status);
+ return;
+ }
+ const C = pt(u);
+ if (_ === X) {
+ const k = u.getResponseHeader("Content-Range"), p = /bytes (\d+)-(\d+)\/(\d+)/.exec(k);
+ A.onDone({
+ begin: parseInt(p[1], 10),
+ chunk: C
+ });
+ } else
+ C ? A.onDone({
+ begin: 0,
+ chunk: C
+ }) : (c = A.onError) == null || c.call(A, u.status);
+ }
+ getRequestXhr(x) {
+ return this.pendingRequests[x].xhr;
+ }
+ isPendingRequest(x) {
+ return x in this.pendingRequests;
+ }
+ abortRequest(x) {
+ const v = this.pendingRequests[x].xhr;
+ delete this.pendingRequests[x], v.abort();
+ }
+ }
+ class F {
+ constructor(x) {
+ this._source = x, this._manager = new B(x.url, {
+ httpHeaders: x.httpHeaders,
+ withCredentials: x.withCredentials
+ }), this._rangeChunkSize = x.rangeChunkSize, this._fullRequestReader = null, this._rangeRequestReaders = [];
+ }
+ _onRangeRequestReaderClosed(x) {
+ const v = this._rangeRequestReaders.indexOf(x);
+ v >= 0 && this._rangeRequestReaders.splice(v, 1);
+ }
+ getFullReader() {
+ return (0, l.assert)(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once."), this._fullRequestReader = new g(this._manager, this._source), this._fullRequestReader;
+ }
+ getRangeReader(x, v) {
+ const A = new O(this._manager, x, v);
+ return A.onClosed = this._onRangeRequestReaderClosed.bind(this), this._rangeRequestReaders.push(A), A;
+ }
+ cancelAllRequests(x) {
+ var v;
+ (v = this._fullRequestReader) == null || v.cancel(x);
+ for (const A of this._rangeRequestReaders.slice(0))
+ A.cancel(x);
+ }
+ }
+ d.PDFNetworkStream = F;
+ class g {
+ constructor(x, v) {
+ this._manager = x;
+ const A = {
+ onHeadersReceived: this._onHeadersReceived.bind(this),
+ onDone: this._onDone.bind(this),
+ onError: this._onError.bind(this),
+ onProgress: this._onProgress.bind(this)
+ };
+ this._url = v.url, this._fullRequestId = x.requestFull(A), this._headersReceivedCapability = new l.PromiseCapability(), this._disableRange = v.disableRange || !1, this._contentLength = v.length, this._rangeChunkSize = v.rangeChunkSize, !this._rangeChunkSize && !this._disableRange && (this._disableRange = !0), this._isStreamingSupported = !1, this._isRangeSupported = !1, this._cachedChunks = [], this._requests = [], this._done = !1, this._storedError = void 0, this._filename = null, this.onProgress = null;
+ }
+ _onHeadersReceived() {
+ const x = this._fullRequestId, v = this._manager.getRequestXhr(x), A = (w) => v.getResponseHeader(w), {
+ allowRangeRequests: u,
+ suggestedLength: _
+ } = (0, P.validateRangeRequestCapabilities)({
+ getResponseHeader: A,
+ isHttp: this._manager.isHttp,
+ rangeChunkSize: this._rangeChunkSize,
+ disableRange: this._disableRange
+ });
+ u && (this._isRangeSupported = !0), this._contentLength = _ || this._contentLength, this._filename = (0, P.extractFilenameFromHeader)(A), this._isRangeSupported && this._manager.abortRequest(x), this._headersReceivedCapability.resolve();
+ }
+ _onDone(x) {
+ if (x && (this._requests.length > 0 ? this._requests.shift().resolve({
+ value: x.chunk,
+ done: !1
+ }) : this._cachedChunks.push(x.chunk)), this._done = !0, !(this._cachedChunks.length > 0)) {
+ for (const v of this._requests)
+ v.resolve({
+ value: void 0,
+ done: !0
+ });
+ this._requests.length = 0;
+ }
+ }
+ _onError(x) {
+ this._storedError = (0, P.createResponseStatusError)(x, this._url), this._headersReceivedCapability.reject(this._storedError);
+ for (const v of this._requests)
+ v.reject(this._storedError);
+ this._requests.length = 0, this._cachedChunks.length = 0;
+ }
+ _onProgress(x) {
+ var v;
+ (v = this.onProgress) == null || v.call(this, {
+ loaded: x.loaded,
+ total: x.lengthComputable ? x.total : this._contentLength
+ });
+ }
+ get filename() {
+ return this._filename;
+ }
+ get isRangeSupported() {
+ return this._isRangeSupported;
+ }
+ get isStreamingSupported() {
+ return this._isStreamingSupported;
+ }
+ get contentLength() {
+ return this._contentLength;
+ }
+ get headersReady() {
+ return this._headersReceivedCapability.promise;
+ }
+ async read() {
+ if (this._storedError)
+ throw this._storedError;
+ if (this._cachedChunks.length > 0)
+ return {
+ value: this._cachedChunks.shift(),
+ done: !1
+ };
+ if (this._done)
+ return {
+ value: void 0,
+ done: !0
+ };
+ const x = new l.PromiseCapability();
+ return this._requests.push(x), x.promise;
+ }
+ cancel(x) {
+ this._done = !0, this._headersReceivedCapability.reject(x);
+ for (const v of this._requests)
+ v.resolve({
+ value: void 0,
+ done: !0
+ });
+ this._requests.length = 0, this._manager.isPendingRequest(this._fullRequestId) && this._manager.abortRequest(this._fullRequestId), this._fullRequestReader = null;
+ }
+ }
+ class O {
+ constructor(x, v, A) {
+ this._manager = x;
+ const u = {
+ onDone: this._onDone.bind(this),
+ onError: this._onError.bind(this),
+ onProgress: this._onProgress.bind(this)
+ };
+ this._url = x.url, this._requestId = x.requestRange(v, A, u), this._requests = [], this._queuedChunk = null, this._done = !1, this._storedError = void 0, this.onProgress = null, this.onClosed = null;
+ }
+ _close() {
+ var x;
+ (x = this.onClosed) == null || x.call(this, this);
+ }
+ _onDone(x) {
+ const v = x.chunk;
+ this._requests.length > 0 ? this._requests.shift().resolve({
+ value: v,
+ done: !1
+ }) : this._queuedChunk = v, this._done = !0;
+ for (const A of this._requests)
+ A.resolve({
+ value: void 0,
+ done: !0
+ });
+ this._requests.length = 0, this._close();
+ }
+ _onError(x) {
+ this._storedError = (0, P.createResponseStatusError)(x, this._url);
+ for (const v of this._requests)
+ v.reject(this._storedError);
+ this._requests.length = 0, this._queuedChunk = null;
+ }
+ _onProgress(x) {
+ var v;
+ this.isStreamingSupported || (v = this.onProgress) == null || v.call(this, {
+ loaded: x.loaded
+ });
+ }
+ get isStreamingSupported() {
+ return !1;
+ }
+ async read() {
+ if (this._storedError)
+ throw this._storedError;
+ if (this._queuedChunk !== null) {
+ const v = this._queuedChunk;
+ return this._queuedChunk = null, {
+ value: v,
+ done: !1
+ };
+ }
+ if (this._done)
+ return {
+ value: void 0,
+ done: !0
+ };
+ const x = new l.PromiseCapability();
+ return this._requests.push(x), x.promise;
+ }
+ cancel(x) {
+ this._done = !0;
+ for (const v of this._requests)
+ v.resolve({
+ value: void 0,
+ done: !0
+ });
+ this._requests.length = 0, this._manager.isPendingRequest(this._requestId) && this._manager.abortRequest(this._requestId), this._close();
+ }
+ }
+ },
+ /* 23 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.PDFNodeStream = void 0;
+ var l = et(1), P = et(20);
+ const rt = /^file:\/\/\/[a-zA-Z]:\//;
+ function X(A) {
+ const u = require$$5, _ = u.parse(A);
+ return _.protocol === "file:" || _.host ? _ : /^[a-z]:[/\\]/i.test(A) ? u.parse(`file:///${A}`) : (_.host || (_.protocol = "file:"), _);
+ }
+ class pt {
+ constructor(u) {
+ this.source = u, this.url = X(u.url), this.isHttp = this.url.protocol === "http:" || this.url.protocol === "https:", this.isFsUrl = this.url.protocol === "file:", this.httpHeaders = this.isHttp && u.httpHeaders || {}, this._fullRequestReader = null, this._rangeRequestReaders = [];
+ }
+ get _progressiveDataLength() {
+ var u;
+ return ((u = this._fullRequestReader) == null ? void 0 : u._loaded) ?? 0;
+ }
+ getFullReader() {
+ return (0, l.assert)(!this._fullRequestReader, "PDFNodeStream.getFullReader can only be called once."), this._fullRequestReader = this.isFsUrl ? new x(this) : new O(this), this._fullRequestReader;
+ }
+ getRangeReader(u, _) {
+ if (_ <= this._progressiveDataLength)
+ return null;
+ const w = this.isFsUrl ? new v(this, u, _) : new I(this, u, _);
+ return this._rangeRequestReaders.push(w), w;
+ }
+ cancelAllRequests(u) {
+ var _;
+ (_ = this._fullRequestReader) == null || _.cancel(u);
+ for (const w of this._rangeRequestReaders.slice(0))
+ w.cancel(u);
+ }
+ }
+ d.PDFNodeStream = pt;
+ class B {
+ constructor(u) {
+ this._url = u.url, this._done = !1, this._storedError = null, this.onProgress = null;
+ const _ = u.source;
+ this._contentLength = _.length, this._loaded = 0, this._filename = null, this._disableRange = _.disableRange || !1, this._rangeChunkSize = _.rangeChunkSize, !this._rangeChunkSize && !this._disableRange && (this._disableRange = !0), this._isStreamingSupported = !_.disableStream, this._isRangeSupported = !_.disableRange, this._readableStream = null, this._readCapability = new l.PromiseCapability(), this._headersCapability = new l.PromiseCapability();
+ }
+ get headersReady() {
+ return this._headersCapability.promise;
+ }
+ get filename() {
+ return this._filename;
+ }
+ get contentLength() {
+ return this._contentLength;
+ }
+ get isRangeSupported() {
+ return this._isRangeSupported;
+ }
+ get isStreamingSupported() {
+ return this._isStreamingSupported;
+ }
+ async read() {
+ var w;
+ if (await this._readCapability.promise, this._done)
+ return {
+ value: void 0,
+ done: !0
+ };
+ if (this._storedError)
+ throw this._storedError;
+ const u = this._readableStream.read();
+ return u === null ? (this._readCapability = new l.PromiseCapability(), this.read()) : (this._loaded += u.length, (w = this.onProgress) == null || w.call(this, {
+ loaded: this._loaded,
+ total: this._contentLength
+ }), {
+ value: new Uint8Array(u).buffer,
+ done: !1
+ });
+ }
+ cancel(u) {
+ if (!this._readableStream) {
+ this._error(u);
+ return;
+ }
+ this._readableStream.destroy(u);
+ }
+ _error(u) {
+ this._storedError = u, this._readCapability.resolve();
+ }
+ _setReadableStream(u) {
+ this._readableStream = u, u.on("readable", () => {
+ this._readCapability.resolve();
+ }), u.on("end", () => {
+ u.destroy(), this._done = !0, this._readCapability.resolve();
+ }), u.on("error", (_) => {
+ this._error(_);
+ }), !this._isStreamingSupported && this._isRangeSupported && this._error(new l.AbortException("streaming is disabled")), this._storedError && this._readableStream.destroy(this._storedError);
+ }
+ }
+ class F {
+ constructor(u) {
+ this._url = u.url, this._done = !1, this._storedError = null, this.onProgress = null, this._loaded = 0, this._readableStream = null, this._readCapability = new l.PromiseCapability();
+ const _ = u.source;
+ this._isStreamingSupported = !_.disableStream;
+ }
+ get isStreamingSupported() {
+ return this._isStreamingSupported;
+ }
+ async read() {
+ var w;
+ if (await this._readCapability.promise, this._done)
+ return {
+ value: void 0,
+ done: !0
+ };
+ if (this._storedError)
+ throw this._storedError;
+ const u = this._readableStream.read();
+ return u === null ? (this._readCapability = new l.PromiseCapability(), this.read()) : (this._loaded += u.length, (w = this.onProgress) == null || w.call(this, {
+ loaded: this._loaded
+ }), {
+ value: new Uint8Array(u).buffer,
+ done: !1
+ });
+ }
+ cancel(u) {
+ if (!this._readableStream) {
+ this._error(u);
+ return;
+ }
+ this._readableStream.destroy(u);
+ }
+ _error(u) {
+ this._storedError = u, this._readCapability.resolve();
+ }
+ _setReadableStream(u) {
+ this._readableStream = u, u.on("readable", () => {
+ this._readCapability.resolve();
+ }), u.on("end", () => {
+ u.destroy(), this._done = !0, this._readCapability.resolve();
+ }), u.on("error", (_) => {
+ this._error(_);
+ }), this._storedError && this._readableStream.destroy(this._storedError);
+ }
+ }
+ function g(A, u) {
+ return {
+ protocol: A.protocol,
+ auth: A.auth,
+ host: A.hostname,
+ port: A.port,
+ path: A.path,
+ method: "GET",
+ headers: u
+ };
+ }
+ class O extends B {
+ constructor(u) {
+ super(u);
+ const _ = (w) => {
+ if (w.statusCode === 404) {
+ const c = new l.MissingPDFException(`Missing PDF "${this._url}".`);
+ this._storedError = c, this._headersCapability.reject(c);
+ return;
+ }
+ this._headersCapability.resolve(), this._setReadableStream(w);
+ const C = (c) => this._readableStream.headers[c.toLowerCase()], {
+ allowRangeRequests: y,
+ suggestedLength: a
+ } = (0, P.validateRangeRequestCapabilities)({
+ getResponseHeader: C,
+ isHttp: u.isHttp,
+ rangeChunkSize: this._rangeChunkSize,
+ disableRange: this._disableRange
+ });
+ this._isRangeSupported = y, this._contentLength = a || this._contentLength, this._filename = (0, P.extractFilenameFromHeader)(C);
+ };
+ if (this._request = null, this._url.protocol === "http:") {
+ const w = require$$5;
+ this._request = w.request(g(this._url, u.httpHeaders), _);
+ } else {
+ const w = require$$5;
+ this._request = w.request(g(this._url, u.httpHeaders), _);
+ }
+ this._request.on("error", (w) => {
+ this._storedError = w, this._headersCapability.reject(w);
+ }), this._request.end();
+ }
+ }
+ class I extends F {
+ constructor(u, _, w) {
+ super(u), this._httpHeaders = {};
+ for (const y in u.httpHeaders) {
+ const a = u.httpHeaders[y];
+ a !== void 0 && (this._httpHeaders[y] = a);
+ }
+ this._httpHeaders.Range = `bytes=${_}-${w - 1}`;
+ const C = (y) => {
+ if (y.statusCode === 404) {
+ const a = new l.MissingPDFException(`Missing PDF "${this._url}".`);
+ this._storedError = a;
+ return;
+ }
+ this._setReadableStream(y);
+ };
+ if (this._request = null, this._url.protocol === "http:") {
+ const y = require$$5;
+ this._request = y.request(g(this._url, this._httpHeaders), C);
+ } else {
+ const y = require$$5;
+ this._request = y.request(g(this._url, this._httpHeaders), C);
+ }
+ this._request.on("error", (y) => {
+ this._storedError = y;
+ }), this._request.end();
+ }
+ }
+ class x extends B {
+ constructor(u) {
+ super(u);
+ let _ = decodeURIComponent(this._url.path);
+ rt.test(this._url.href) && (_ = _.replace(/^\//, ""));
+ const w = require$$5;
+ w.lstat(_, (C, y) => {
+ if (C) {
+ C.code === "ENOENT" && (C = new l.MissingPDFException(`Missing PDF "${_}".`)), this._storedError = C, this._headersCapability.reject(C);
+ return;
+ }
+ this._contentLength = y.size, this._setReadableStream(w.createReadStream(_)), this._headersCapability.resolve();
+ });
+ }
+ }
+ class v extends F {
+ constructor(u, _, w) {
+ super(u);
+ let C = decodeURIComponent(this._url.path);
+ rt.test(this._url.href) && (C = C.replace(/^\//, ""));
+ const y = require$$5;
+ this._setReadableStream(y.createReadStream(C, {
+ start: _,
+ end: w - 1
+ }));
+ }
+ }
+ },
+ /* 24 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.SVGGraphics = void 0;
+ var l = et(6), P = et(1);
+ const rt = {
+ fontStyle: "normal",
+ fontWeight: "normal",
+ fillColor: "#000000"
+ }, X = "http://www.w3.org/XML/1998/namespace", pt = "http://www.w3.org/1999/xlink", B = ["butt", "round", "square"], F = ["miter", "round", "bevel"], g = function(y, a = "", c = !1) {
+ if (URL.createObjectURL && typeof Blob < "u" && !c)
+ return URL.createObjectURL(new Blob([y], {
+ type: a
+ }));
+ const k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+ let p = `data:${a};base64,`;
+ for (let r = 0, T = y.length; r < T; r += 3) {
+ const m = y[r] & 255, U = y[r + 1] & 255, z = y[r + 2] & 255, E = m >> 2, V = (m & 3) << 4 | U >> 4, st = r + 1 < T ? (U & 15) << 2 | z >> 6 : 64, at = r + 2 < T ? z & 63 : 64;
+ p += k[E] + k[V] + k[st] + k[at];
+ }
+ return p;
+ }, O = function() {
+ const y = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), a = 12, c = new Int32Array(256);
+ for (let z = 0; z < 256; z++) {
+ let E = z;
+ for (let V = 0; V < 8; V++)
+ E = E & 1 ? 3988292384 ^ E >> 1 & 2147483647 : E >> 1 & 2147483647;
+ c[z] = E;
+ }
+ function k(z, E, V) {
+ let st = -1;
+ for (let at = E; at < V; at++) {
+ const H = (st ^ z[at]) & 255, lt = c[H];
+ st = st >>> 8 ^ lt;
+ }
+ return st ^ -1;
+ }
+ function p(z, E, V, st) {
+ let at = st;
+ const H = E.length;
+ V[at] = H >> 24 & 255, V[at + 1] = H >> 16 & 255, V[at + 2] = H >> 8 & 255, V[at + 3] = H & 255, at += 4, V[at] = z.charCodeAt(0) & 255, V[at + 1] = z.charCodeAt(1) & 255, V[at + 2] = z.charCodeAt(2) & 255, V[at + 3] = z.charCodeAt(3) & 255, at += 4, V.set(E, at), at += E.length;
+ const lt = k(V, st + 4, at);
+ V[at] = lt >> 24 & 255, V[at + 1] = lt >> 16 & 255, V[at + 2] = lt >> 8 & 255, V[at + 3] = lt & 255;
+ }
+ function r(z, E, V) {
+ let st = 1, at = 0;
+ for (let H = E; H < V; ++H)
+ st = (st + (z[H] & 255)) % 65521, at = (at + st) % 65521;
+ return at << 16 | st;
+ }
+ function T(z) {
+ if (!P.isNodeJS)
+ return m(z);
+ try {
+ const E = parseInt(process.versions.node) >= 8 ? z : Buffer.from(z), V = require$$5.deflateSync(E, {
+ level: 9
+ });
+ return V instanceof Uint8Array ? V : new Uint8Array(V);
+ } catch (E) {
+ (0, P.warn)("Not compressing PNG because zlib.deflateSync is unavailable: " + E);
+ }
+ return m(z);
+ }
+ function m(z) {
+ let E = z.length;
+ const V = 65535, st = Math.ceil(E / V), at = new Uint8Array(2 + E + st * 5 + 4);
+ let H = 0;
+ at[H++] = 120, at[H++] = 156;
+ let lt = 0;
+ for (; E > V; )
+ at[H++] = 0, at[H++] = 255, at[H++] = 255, at[H++] = 0, at[H++] = 0, at.set(z.subarray(lt, lt + V), H), H += V, lt += V, E -= V;
+ at[H++] = 1, at[H++] = E & 255, at[H++] = E >> 8 & 255, at[H++] = ~E & 65535 & 255, at[H++] = (~E & 65535) >> 8 & 255, at.set(z.subarray(lt), H), H += z.length - lt;
+ const gt = r(z, 0, z.length);
+ return at[H++] = gt >> 24 & 255, at[H++] = gt >> 16 & 255, at[H++] = gt >> 8 & 255, at[H++] = gt & 255, at;
+ }
+ function U(z, E, V, st) {
+ const at = z.width, H = z.height;
+ let lt, gt, wt;
+ const xt = z.data;
+ switch (E) {
+ case P.ImageKind.GRAYSCALE_1BPP:
+ gt = 0, lt = 1, wt = at + 7 >> 3;
+ break;
+ case P.ImageKind.RGB_24BPP:
+ gt = 2, lt = 8, wt = at * 3;
+ break;
+ case P.ImageKind.RGBA_32BPP:
+ gt = 6, lt = 8, wt = at * 4;
+ break;
+ default:
+ throw new Error("invalid format");
+ }
+ const S = new Uint8Array((1 + wt) * H);
+ let i = 0, n = 0;
+ for (let N = 0; N < H; ++N)
+ S[i++] = 0, S.set(xt.subarray(n, n + wt), i), n += wt, i += wt;
+ if (E === P.ImageKind.GRAYSCALE_1BPP && st) {
+ i = 0;
+ for (let N = 0; N < H; N++) {
+ i++;
+ for (let tt = 0; tt < wt; tt++)
+ S[i++] ^= 255;
+ }
+ }
+ const s = new Uint8Array([at >> 24 & 255, at >> 16 & 255, at >> 8 & 255, at & 255, H >> 24 & 255, H >> 16 & 255, H >> 8 & 255, H & 255, lt, gt, 0, 0, 0]), o = T(S), h = y.length + a * 3 + s.length + o.length, b = new Uint8Array(h);
+ let M = 0;
+ return b.set(y, M), M += y.length, p("IHDR", s, b, M), M += a + s.length, p("IDATA", o, b, M), M += a + o.length, p("IEND", new Uint8Array(0), b, M), g(b, "image/png", V);
+ }
+ return function(E, V, st) {
+ const at = E.kind === void 0 ? P.ImageKind.GRAYSCALE_1BPP : E.kind;
+ return U(E, at, V, st);
+ };
+ }();
+ class I {
+ constructor() {
+ this.fontSizeScale = 1, this.fontWeight = rt.fontWeight, this.fontSize = 0, this.textMatrix = P.IDENTITY_MATRIX, this.fontMatrix = P.FONT_IDENTITY_MATRIX, this.leading = 0, this.textRenderingMode = P.TextRenderingMode.FILL, this.textMatrixScale = 1, this.x = 0, this.y = 0, this.lineX = 0, this.lineY = 0, this.charSpacing = 0, this.wordSpacing = 0, this.textHScale = 1, this.textRise = 0, this.fillColor = rt.fillColor, this.strokeColor = "#000000", this.fillAlpha = 1, this.strokeAlpha = 1, this.lineWidth = 1, this.lineJoin = "", this.lineCap = "", this.miterLimit = 0, this.dashArray = [], this.dashPhase = 0, this.dependencies = [], this.activeClipUrl = null, this.clipGroup = null, this.maskId = "";
+ }
+ clone() {
+ return Object.create(this);
+ }
+ setCurrentPoint(a, c) {
+ this.x = a, this.y = c;
+ }
+ }
+ function x(y) {
+ let a = [];
+ const c = [];
+ for (const k of y) {
+ if (k.fn === "save") {
+ a.push({
+ fnId: 92,
+ fn: "group",
+ items: []
+ }), c.push(a), a = a.at(-1).items;
+ continue;
+ }
+ k.fn === "restore" ? a = c.pop() : a.push(k);
+ }
+ return a;
+ }
+ function v(y) {
+ if (Number.isInteger(y))
+ return y.toString();
+ const a = y.toFixed(10);
+ let c = a.length - 1;
+ if (a[c] !== "0")
+ return a;
+ do
+ c--;
+ while (a[c] === "0");
+ return a.substring(0, a[c] === "." ? c : c + 1);
+ }
+ function A(y) {
+ if (y[4] === 0 && y[5] === 0) {
+ if (y[1] === 0 && y[2] === 0)
+ return y[0] === 1 && y[3] === 1 ? "" : `scale(${v(y[0])} ${v(y[3])})`;
+ if (y[0] === y[3] && y[1] === -y[2]) {
+ const a = Math.acos(y[0]) * 180 / Math.PI;
+ return `rotate(${v(a)})`;
+ }
+ } else if (y[0] === 1 && y[1] === 0 && y[2] === 0 && y[3] === 1)
+ return `translate(${v(y[4])} ${v(y[5])})`;
+ return `matrix(${v(y[0])} ${v(y[1])} ${v(y[2])} ${v(y[3])} ${v(y[4])} ${v(y[5])})`;
+ }
+ let u = 0, _ = 0, w = 0;
+ class C {
+ constructor(a, c, k = !1) {
+ (0, l.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."), this.svgFactory = new l.DOMSVGFactory(), this.current = new I(), this.transformMatrix = P.IDENTITY_MATRIX, this.transformStack = [], this.extraStack = [], this.commonObjs = a, this.objs = c, this.pendingClip = null, this.pendingEOFill = !1, this.embedFonts = !1, this.embeddedFonts = /* @__PURE__ */ Object.create(null), this.cssStyle = null, this.forceDataSchema = !!k, this._operatorIdMapping = [];
+ for (const p in P.OPS)
+ this._operatorIdMapping[P.OPS[p]] = p;
+ }
+ getObject(a, c = null) {
+ return typeof a == "string" ? a.startsWith("g_") ? this.commonObjs.get(a) : this.objs.get(a) : c;
+ }
+ save() {
+ this.transformStack.push(this.transformMatrix);
+ const a = this.current;
+ this.extraStack.push(a), this.current = a.clone();
+ }
+ restore() {
+ this.transformMatrix = this.transformStack.pop(), this.current = this.extraStack.pop(), this.pendingClip = null, this.tgrp = null;
+ }
+ group(a) {
+ this.save(), this.executeOpTree(a), this.restore();
+ }
+ loadDependencies(a) {
+ const c = a.fnArray, k = a.argsArray;
+ for (let p = 0, r = c.length; p < r; p++)
+ if (c[p] === P.OPS.dependency)
+ for (const T of k[p]) {
+ const m = T.startsWith("g_") ? this.commonObjs : this.objs, U = new Promise((z) => {
+ m.get(T, z);
+ });
+ this.current.dependencies.push(U);
+ }
+ return Promise.all(this.current.dependencies);
+ }
+ transform(a, c, k, p, r, T) {
+ const m = [a, c, k, p, r, T];
+ this.transformMatrix = P.Util.transform(this.transformMatrix, m), this.tgrp = null;
+ }
+ getSVG(a, c) {
+ this.viewport = c;
+ const k = this._initialize(c);
+ return this.loadDependencies(a).then(() => (this.transformMatrix = P.IDENTITY_MATRIX, this.executeOpTree(this.convertOpList(a)), k));
+ }
+ convertOpList(a) {
+ const c = this._operatorIdMapping, k = a.argsArray, p = a.fnArray, r = [];
+ for (let T = 0, m = p.length; T < m; T++) {
+ const U = p[T];
+ r.push({
+ fnId: U,
+ fn: c[U],
+ args: k[T]
+ });
+ }
+ return x(r);
+ }
+ executeOpTree(a) {
+ for (const c of a) {
+ const k = c.fn, p = c.fnId, r = c.args;
+ switch (p | 0) {
+ case P.OPS.beginText:
+ this.beginText();
+ break;
+ case P.OPS.dependency:
+ break;
+ case P.OPS.setLeading:
+ this.setLeading(r);
+ break;
+ case P.OPS.setLeadingMoveText:
+ this.setLeadingMoveText(r[0], r[1]);
+ break;
+ case P.OPS.setFont:
+ this.setFont(r);
+ break;
+ case P.OPS.showText:
+ this.showText(r[0]);
+ break;
+ case P.OPS.showSpacedText:
+ this.showText(r[0]);
+ break;
+ case P.OPS.endText:
+ this.endText();
+ break;
+ case P.OPS.moveText:
+ this.moveText(r[0], r[1]);
+ break;
+ case P.OPS.setCharSpacing:
+ this.setCharSpacing(r[0]);
+ break;
+ case P.OPS.setWordSpacing:
+ this.setWordSpacing(r[0]);
+ break;
+ case P.OPS.setHScale:
+ this.setHScale(r[0]);
+ break;
+ case P.OPS.setTextMatrix:
+ this.setTextMatrix(r[0], r[1], r[2], r[3], r[4], r[5]);
+ break;
+ case P.OPS.setTextRise:
+ this.setTextRise(r[0]);
+ break;
+ case P.OPS.setTextRenderingMode:
+ this.setTextRenderingMode(r[0]);
+ break;
+ case P.OPS.setLineWidth:
+ this.setLineWidth(r[0]);
+ break;
+ case P.OPS.setLineJoin:
+ this.setLineJoin(r[0]);
+ break;
+ case P.OPS.setLineCap:
+ this.setLineCap(r[0]);
+ break;
+ case P.OPS.setMiterLimit:
+ this.setMiterLimit(r[0]);
+ break;
+ case P.OPS.setFillRGBColor:
+ this.setFillRGBColor(r[0], r[1], r[2]);
+ break;
+ case P.OPS.setStrokeRGBColor:
+ this.setStrokeRGBColor(r[0], r[1], r[2]);
+ break;
+ case P.OPS.setStrokeColorN:
+ this.setStrokeColorN(r);
+ break;
+ case P.OPS.setFillColorN:
+ this.setFillColorN(r);
+ break;
+ case P.OPS.shadingFill:
+ this.shadingFill(r[0]);
+ break;
+ case P.OPS.setDash:
+ this.setDash(r[0], r[1]);
+ break;
+ case P.OPS.setRenderingIntent:
+ this.setRenderingIntent(r[0]);
+ break;
+ case P.OPS.setFlatness:
+ this.setFlatness(r[0]);
+ break;
+ case P.OPS.setGState:
+ this.setGState(r[0]);
+ break;
+ case P.OPS.fill:
+ this.fill();
+ break;
+ case P.OPS.eoFill:
+ this.eoFill();
+ break;
+ case P.OPS.stroke:
+ this.stroke();
+ break;
+ case P.OPS.fillStroke:
+ this.fillStroke();
+ break;
+ case P.OPS.eoFillStroke:
+ this.eoFillStroke();
+ break;
+ case P.OPS.clip:
+ this.clip("nonzero");
+ break;
+ case P.OPS.eoClip:
+ this.clip("evenodd");
+ break;
+ case P.OPS.paintSolidColorImageMask:
+ this.paintSolidColorImageMask();
+ break;
+ case P.OPS.paintImageXObject:
+ this.paintImageXObject(r[0]);
+ break;
+ case P.OPS.paintInlineImageXObject:
+ this.paintInlineImageXObject(r[0]);
+ break;
+ case P.OPS.paintImageMaskXObject:
+ this.paintImageMaskXObject(r[0]);
+ break;
+ case P.OPS.paintFormXObjectBegin:
+ this.paintFormXObjectBegin(r[0], r[1]);
+ break;
+ case P.OPS.paintFormXObjectEnd:
+ this.paintFormXObjectEnd();
+ break;
+ case P.OPS.closePath:
+ this.closePath();
+ break;
+ case P.OPS.closeStroke:
+ this.closeStroke();
+ break;
+ case P.OPS.closeFillStroke:
+ this.closeFillStroke();
+ break;
+ case P.OPS.closeEOFillStroke:
+ this.closeEOFillStroke();
+ break;
+ case P.OPS.nextLine:
+ this.nextLine();
+ break;
+ case P.OPS.transform:
+ this.transform(r[0], r[1], r[2], r[3], r[4], r[5]);
+ break;
+ case P.OPS.constructPath:
+ this.constructPath(r[0], r[1]);
+ break;
+ case P.OPS.endPath:
+ this.endPath();
+ break;
+ case 92:
+ this.group(c.items);
+ break;
+ default:
+ (0, P.warn)(`Unimplemented operator ${k}`);
+ break;
+ }
+ }
+ }
+ setWordSpacing(a) {
+ this.current.wordSpacing = a;
+ }
+ setCharSpacing(a) {
+ this.current.charSpacing = a;
+ }
+ nextLine() {
+ this.moveText(0, this.current.leading);
+ }
+ setTextMatrix(a, c, k, p, r, T) {
+ const m = this.current;
+ m.textMatrix = m.lineMatrix = [a, c, k, p, r, T], m.textMatrixScale = Math.hypot(a, c), m.x = m.lineX = 0, m.y = m.lineY = 0, m.xcoords = [], m.ycoords = [], m.tspan = this.svgFactory.createElement("svg:tspan"), m.tspan.setAttributeNS(null, "font-family", m.fontFamily), m.tspan.setAttributeNS(null, "font-size", `${v(m.fontSize)}px`), m.tspan.setAttributeNS(null, "y", v(-m.y)), m.txtElement = this.svgFactory.createElement("svg:text"), m.txtElement.append(m.tspan);
+ }
+ beginText() {
+ const a = this.current;
+ a.x = a.lineX = 0, a.y = a.lineY = 0, a.textMatrix = P.IDENTITY_MATRIX, a.lineMatrix = P.IDENTITY_MATRIX, a.textMatrixScale = 1, a.tspan = this.svgFactory.createElement("svg:tspan"), a.txtElement = this.svgFactory.createElement("svg:text"), a.txtgrp = this.svgFactory.createElement("svg:g"), a.xcoords = [], a.ycoords = [];
+ }
+ moveText(a, c) {
+ const k = this.current;
+ k.x = k.lineX += a, k.y = k.lineY += c, k.xcoords = [], k.ycoords = [], k.tspan = this.svgFactory.createElement("svg:tspan"), k.tspan.setAttributeNS(null, "font-family", k.fontFamily), k.tspan.setAttributeNS(null, "font-size", `${v(k.fontSize)}px`), k.tspan.setAttributeNS(null, "y", v(-k.y));
+ }
+ showText(a) {
+ const c = this.current, k = c.font, p = c.fontSize;
+ if (p === 0)
+ return;
+ const r = c.fontSizeScale, T = c.charSpacing, m = c.wordSpacing, U = c.fontDirection, z = c.textHScale * U, E = k.vertical, V = E ? 1 : -1, st = k.defaultVMetrics, at = p * c.fontMatrix[0];
+ let H = 0;
+ for (const wt of a) {
+ if (wt === null) {
+ H += U * m;
+ continue;
+ } else if (typeof wt == "number") {
+ H += V * wt * p / 1e3;
+ continue;
+ }
+ const xt = (wt.isSpace ? m : 0) + T, S = wt.fontChar;
+ let i, n, s = wt.width;
+ if (E) {
+ let h;
+ const b = wt.vmetric || st;
+ h = wt.vmetric ? b[1] : s * 0.5, h = -h * at;
+ const M = b[2] * at;
+ s = b ? -b[0] : s, i = h / r, n = (H + M) / r;
+ } else
+ i = H / r, n = 0;
+ (wt.isInFont || k.missingFile) && (c.xcoords.push(c.x + i), E && c.ycoords.push(-c.y + n), c.tspan.textContent += S);
+ const o = E ? s * at - xt * U : s * at + xt * U;
+ H += o;
+ }
+ c.tspan.setAttributeNS(null, "x", c.xcoords.map(v).join(" ")), E ? c.tspan.setAttributeNS(null, "y", c.ycoords.map(v).join(" ")) : c.tspan.setAttributeNS(null, "y", v(-c.y)), E ? c.y -= H : c.x += H * z, c.tspan.setAttributeNS(null, "font-family", c.fontFamily), c.tspan.setAttributeNS(null, "font-size", `${v(c.fontSize)}px`), c.fontStyle !== rt.fontStyle && c.tspan.setAttributeNS(null, "font-style", c.fontStyle), c.fontWeight !== rt.fontWeight && c.tspan.setAttributeNS(null, "font-weight", c.fontWeight);
+ const lt = c.textRenderingMode & P.TextRenderingMode.FILL_STROKE_MASK;
+ if (lt === P.TextRenderingMode.FILL || lt === P.TextRenderingMode.FILL_STROKE ? (c.fillColor !== rt.fillColor && c.tspan.setAttributeNS(null, "fill", c.fillColor), c.fillAlpha < 1 && c.tspan.setAttributeNS(null, "fill-opacity", c.fillAlpha)) : c.textRenderingMode === P.TextRenderingMode.ADD_TO_PATH ? c.tspan.setAttributeNS(null, "fill", "transparent") : c.tspan.setAttributeNS(null, "fill", "none"), lt === P.TextRenderingMode.STROKE || lt === P.TextRenderingMode.FILL_STROKE) {
+ const wt = 1 / (c.textMatrixScale || 1);
+ this._setStrokeAttributes(c.tspan, wt);
+ }
+ let gt = c.textMatrix;
+ c.textRise !== 0 && (gt = gt.slice(), gt[5] += c.textRise), c.txtElement.setAttributeNS(null, "transform", `${A(gt)} scale(${v(z)}, -1)`), c.txtElement.setAttributeNS(X, "xml:space", "preserve"), c.txtElement.append(c.tspan), c.txtgrp.append(c.txtElement), this._ensureTransformGroup().append(c.txtElement);
+ }
+ setLeadingMoveText(a, c) {
+ this.setLeading(-c), this.moveText(a, c);
+ }
+ addFontStyle(a) {
+ if (!a.data)
+ throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');
+ this.cssStyle || (this.cssStyle = this.svgFactory.createElement("svg:style"), this.cssStyle.setAttributeNS(null, "type", "text/css"), this.defs.append(this.cssStyle));
+ const c = g(a.data, a.mimetype, this.forceDataSchema);
+ this.cssStyle.textContent += `@font-face { font-family: "${a.loadedName}"; src: url(${c}); }
+`;
+ }
+ setFont(a) {
+ const c = this.current, k = this.commonObjs.get(a[0]);
+ let p = a[1];
+ c.font = k, this.embedFonts && !k.missingFile && !this.embeddedFonts[k.loadedName] && (this.addFontStyle(k), this.embeddedFonts[k.loadedName] = k), c.fontMatrix = k.fontMatrix || P.FONT_IDENTITY_MATRIX;
+ let r = "normal";
+ k.black ? r = "900" : k.bold && (r = "bold");
+ const T = k.italic ? "italic" : "normal";
+ p < 0 ? (p = -p, c.fontDirection = -1) : c.fontDirection = 1, c.fontSize = p, c.fontFamily = k.loadedName, c.fontWeight = r, c.fontStyle = T, c.tspan = this.svgFactory.createElement("svg:tspan"), c.tspan.setAttributeNS(null, "y", v(-c.y)), c.xcoords = [], c.ycoords = [];
+ }
+ endText() {
+ var c;
+ const a = this.current;
+ a.textRenderingMode & P.TextRenderingMode.ADD_TO_PATH_FLAG && ((c = a.txtElement) != null && c.hasChildNodes()) && (a.element = a.txtElement, this.clip("nonzero"), this.endPath());
+ }
+ setLineWidth(a) {
+ a > 0 && (this.current.lineWidth = a);
+ }
+ setLineCap(a) {
+ this.current.lineCap = B[a];
+ }
+ setLineJoin(a) {
+ this.current.lineJoin = F[a];
+ }
+ setMiterLimit(a) {
+ this.current.miterLimit = a;
+ }
+ setStrokeAlpha(a) {
+ this.current.strokeAlpha = a;
+ }
+ setStrokeRGBColor(a, c, k) {
+ this.current.strokeColor = P.Util.makeHexColor(a, c, k);
+ }
+ setFillAlpha(a) {
+ this.current.fillAlpha = a;
+ }
+ setFillRGBColor(a, c, k) {
+ this.current.fillColor = P.Util.makeHexColor(a, c, k), this.current.tspan = this.svgFactory.createElement("svg:tspan"), this.current.xcoords = [], this.current.ycoords = [];
+ }
+ setStrokeColorN(a) {
+ this.current.strokeColor = this._makeColorN_Pattern(a);
+ }
+ setFillColorN(a) {
+ this.current.fillColor = this._makeColorN_Pattern(a);
+ }
+ shadingFill(a) {
+ const {
+ width: c,
+ height: k
+ } = this.viewport, p = P.Util.inverseTransform(this.transformMatrix), [r, T, m, U] = P.Util.getAxialAlignedBoundingBox([0, 0, c, k], p), z = this.svgFactory.createElement("svg:rect");
+ z.setAttributeNS(null, "x", r), z.setAttributeNS(null, "y", T), z.setAttributeNS(null, "width", m - r), z.setAttributeNS(null, "height", U - T), z.setAttributeNS(null, "fill", this._makeShadingPattern(a)), this.current.fillAlpha < 1 && z.setAttributeNS(null, "fill-opacity", this.current.fillAlpha), this._ensureTransformGroup().append(z);
+ }
+ _makeColorN_Pattern(a) {
+ return a[0] === "TilingPattern" ? this._makeTilingPattern(a) : this._makeShadingPattern(a);
+ }
+ _makeTilingPattern(a) {
+ const c = a[1], k = a[2], p = a[3] || P.IDENTITY_MATRIX, [r, T, m, U] = a[4], z = a[5], E = a[6], V = a[7], st = `shading${w++}`, [at, H, lt, gt] = P.Util.normalizeRect([...P.Util.applyTransform([r, T], p), ...P.Util.applyTransform([m, U], p)]), [wt, xt] = P.Util.singularValueDecompose2dScale(p), S = z * wt, i = E * xt, n = this.svgFactory.createElement("svg:pattern");
+ n.setAttributeNS(null, "id", st), n.setAttributeNS(null, "patternUnits", "userSpaceOnUse"), n.setAttributeNS(null, "width", S), n.setAttributeNS(null, "height", i), n.setAttributeNS(null, "x", `${at}`), n.setAttributeNS(null, "y", `${H}`);
+ const s = this.svg, o = this.transformMatrix, h = this.current.fillColor, b = this.current.strokeColor, M = this.svgFactory.create(lt - at, gt - H);
+ if (this.svg = M, this.transformMatrix = p, V === 2) {
+ const N = P.Util.makeHexColor(...c);
+ this.current.fillColor = N, this.current.strokeColor = N;
+ }
+ return this.executeOpTree(this.convertOpList(k)), this.svg = s, this.transformMatrix = o, this.current.fillColor = h, this.current.strokeColor = b, n.append(M.childNodes[0]), this.defs.append(n), `url(#${st})`;
+ }
+ _makeShadingPattern(a) {
+ switch (typeof a == "string" && (a = this.objs.get(a)), a[0]) {
+ case "RadialAxial":
+ const c = `shading${w++}`, k = a[3];
+ let p;
+ switch (a[1]) {
+ case "axial":
+ const r = a[4], T = a[5];
+ p = this.svgFactory.createElement("svg:linearGradient"), p.setAttributeNS(null, "id", c), p.setAttributeNS(null, "gradientUnits", "userSpaceOnUse"), p.setAttributeNS(null, "x1", r[0]), p.setAttributeNS(null, "y1", r[1]), p.setAttributeNS(null, "x2", T[0]), p.setAttributeNS(null, "y2", T[1]);
+ break;
+ case "radial":
+ const m = a[4], U = a[5], z = a[6], E = a[7];
+ p = this.svgFactory.createElement("svg:radialGradient"), p.setAttributeNS(null, "id", c), p.setAttributeNS(null, "gradientUnits", "userSpaceOnUse"), p.setAttributeNS(null, "cx", U[0]), p.setAttributeNS(null, "cy", U[1]), p.setAttributeNS(null, "r", E), p.setAttributeNS(null, "fx", m[0]), p.setAttributeNS(null, "fy", m[1]), p.setAttributeNS(null, "fr", z);
+ break;
+ default:
+ throw new Error(`Unknown RadialAxial type: ${a[1]}`);
+ }
+ for (const r of k) {
+ const T = this.svgFactory.createElement("svg:stop");
+ T.setAttributeNS(null, "offset", r[0]), T.setAttributeNS(null, "stop-color", r[1]), p.append(T);
+ }
+ return this.defs.append(p), `url(#${c})`;
+ case "Mesh":
+ return (0, P.warn)("Unimplemented pattern Mesh"), null;
+ case "Dummy":
+ return "hotpink";
+ default:
+ throw new Error(`Unknown IR type: ${a[0]}`);
+ }
+ }
+ setDash(a, c) {
+ this.current.dashArray = a, this.current.dashPhase = c;
+ }
+ constructPath(a, c) {
+ const k = this.current;
+ let p = k.x, r = k.y, T = [], m = 0;
+ for (const U of a)
+ switch (U | 0) {
+ case P.OPS.rectangle:
+ p = c[m++], r = c[m++];
+ const z = c[m++], E = c[m++], V = p + z, st = r + E;
+ T.push("M", v(p), v(r), "L", v(V), v(r), "L", v(V), v(st), "L", v(p), v(st), "Z");
+ break;
+ case P.OPS.moveTo:
+ p = c[m++], r = c[m++], T.push("M", v(p), v(r));
+ break;
+ case P.OPS.lineTo:
+ p = c[m++], r = c[m++], T.push("L", v(p), v(r));
+ break;
+ case P.OPS.curveTo:
+ p = c[m + 4], r = c[m + 5], T.push("C", v(c[m]), v(c[m + 1]), v(c[m + 2]), v(c[m + 3]), v(p), v(r)), m += 6;
+ break;
+ case P.OPS.curveTo2:
+ T.push("C", v(p), v(r), v(c[m]), v(c[m + 1]), v(c[m + 2]), v(c[m + 3])), p = c[m + 2], r = c[m + 3], m += 4;
+ break;
+ case P.OPS.curveTo3:
+ p = c[m + 2], r = c[m + 3], T.push("C", v(c[m]), v(c[m + 1]), v(p), v(r), v(p), v(r)), m += 4;
+ break;
+ case P.OPS.closePath:
+ T.push("Z");
+ break;
+ }
+ T = T.join(" "), k.path && a.length > 0 && a[0] !== P.OPS.rectangle && a[0] !== P.OPS.moveTo ? T = k.path.getAttributeNS(null, "d") + T : (k.path = this.svgFactory.createElement("svg:path"), this._ensureTransformGroup().append(k.path)), k.path.setAttributeNS(null, "d", T), k.path.setAttributeNS(null, "fill", "none"), k.element = k.path, k.setCurrentPoint(p, r);
+ }
+ endPath() {
+ const a = this.current;
+ if (a.path = null, !this.pendingClip)
+ return;
+ if (!a.element) {
+ this.pendingClip = null;
+ return;
+ }
+ const c = `clippath${u++}`, k = this.svgFactory.createElement("svg:clipPath");
+ k.setAttributeNS(null, "id", c), k.setAttributeNS(null, "transform", A(this.transformMatrix));
+ const p = a.element.cloneNode(!0);
+ if (this.pendingClip === "evenodd" ? p.setAttributeNS(null, "clip-rule", "evenodd") : p.setAttributeNS(null, "clip-rule", "nonzero"), this.pendingClip = null, k.append(p), this.defs.append(k), a.activeClipUrl) {
+ a.clipGroup = null;
+ for (const r of this.extraStack)
+ r.clipGroup = null;
+ k.setAttributeNS(null, "clip-path", a.activeClipUrl);
+ }
+ a.activeClipUrl = `url(#${c})`, this.tgrp = null;
+ }
+ clip(a) {
+ this.pendingClip = a;
+ }
+ closePath() {
+ const a = this.current;
+ if (a.path) {
+ const c = `${a.path.getAttributeNS(null, "d")}Z`;
+ a.path.setAttributeNS(null, "d", c);
+ }
+ }
+ setLeading(a) {
+ this.current.leading = -a;
+ }
+ setTextRise(a) {
+ this.current.textRise = a;
+ }
+ setTextRenderingMode(a) {
+ this.current.textRenderingMode = a;
+ }
+ setHScale(a) {
+ this.current.textHScale = a / 100;
+ }
+ setRenderingIntent(a) {
+ }
+ setFlatness(a) {
+ }
+ setGState(a) {
+ for (const [c, k] of a)
+ switch (c) {
+ case "LW":
+ this.setLineWidth(k);
+ break;
+ case "LC":
+ this.setLineCap(k);
+ break;
+ case "LJ":
+ this.setLineJoin(k);
+ break;
+ case "ML":
+ this.setMiterLimit(k);
+ break;
+ case "D":
+ this.setDash(k[0], k[1]);
+ break;
+ case "RI":
+ this.setRenderingIntent(k);
+ break;
+ case "FL":
+ this.setFlatness(k);
+ break;
+ case "Font":
+ this.setFont(k);
+ break;
+ case "CA":
+ this.setStrokeAlpha(k);
+ break;
+ case "ca":
+ this.setFillAlpha(k);
+ break;
+ default:
+ (0, P.warn)(`Unimplemented graphic state operator ${c}`);
+ break;
+ }
+ }
+ fill() {
+ const a = this.current;
+ a.element && (a.element.setAttributeNS(null, "fill", a.fillColor), a.element.setAttributeNS(null, "fill-opacity", a.fillAlpha), this.endPath());
+ }
+ stroke() {
+ const a = this.current;
+ a.element && (this._setStrokeAttributes(a.element), a.element.setAttributeNS(null, "fill", "none"), this.endPath());
+ }
+ _setStrokeAttributes(a, c = 1) {
+ const k = this.current;
+ let p = k.dashArray;
+ c !== 1 && p.length > 0 && (p = p.map(function(r) {
+ return c * r;
+ })), a.setAttributeNS(null, "stroke", k.strokeColor), a.setAttributeNS(null, "stroke-opacity", k.strokeAlpha), a.setAttributeNS(null, "stroke-miterlimit", v(k.miterLimit)), a.setAttributeNS(null, "stroke-linecap", k.lineCap), a.setAttributeNS(null, "stroke-linejoin", k.lineJoin), a.setAttributeNS(null, "stroke-width", v(c * k.lineWidth) + "px"), a.setAttributeNS(null, "stroke-dasharray", p.map(v).join(" ")), a.setAttributeNS(null, "stroke-dashoffset", v(c * k.dashPhase) + "px");
+ }
+ eoFill() {
+ var a;
+ (a = this.current.element) == null || a.setAttributeNS(null, "fill-rule", "evenodd"), this.fill();
+ }
+ fillStroke() {
+ this.stroke(), this.fill();
+ }
+ eoFillStroke() {
+ var a;
+ (a = this.current.element) == null || a.setAttributeNS(null, "fill-rule", "evenodd"), this.fillStroke();
+ }
+ closeStroke() {
+ this.closePath(), this.stroke();
+ }
+ closeFillStroke() {
+ this.closePath(), this.fillStroke();
+ }
+ closeEOFillStroke() {
+ this.closePath(), this.eoFillStroke();
+ }
+ paintSolidColorImageMask() {
+ const a = this.svgFactory.createElement("svg:rect");
+ a.setAttributeNS(null, "x", "0"), a.setAttributeNS(null, "y", "0"), a.setAttributeNS(null, "width", "1px"), a.setAttributeNS(null, "height", "1px"), a.setAttributeNS(null, "fill", this.current.fillColor), this._ensureTransformGroup().append(a);
+ }
+ paintImageXObject(a) {
+ const c = this.getObject(a);
+ if (!c) {
+ (0, P.warn)(`Dependent image with object ID ${a} is not ready yet`);
+ return;
+ }
+ this.paintInlineImageXObject(c);
+ }
+ paintInlineImageXObject(a, c) {
+ const k = a.width, p = a.height, r = O(a, this.forceDataSchema, !!c), T = this.svgFactory.createElement("svg:rect");
+ T.setAttributeNS(null, "x", "0"), T.setAttributeNS(null, "y", "0"), T.setAttributeNS(null, "width", v(k)), T.setAttributeNS(null, "height", v(p)), this.current.element = T, this.clip("nonzero");
+ const m = this.svgFactory.createElement("svg:image");
+ m.setAttributeNS(pt, "xlink:href", r), m.setAttributeNS(null, "x", "0"), m.setAttributeNS(null, "y", v(-p)), m.setAttributeNS(null, "width", v(k) + "px"), m.setAttributeNS(null, "height", v(p) + "px"), m.setAttributeNS(null, "transform", `scale(${v(1 / k)} ${v(-1 / p)})`), c ? c.append(m) : this._ensureTransformGroup().append(m);
+ }
+ paintImageMaskXObject(a) {
+ const c = this.getObject(a.data, a);
+ if (c.bitmap) {
+ (0, P.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");
+ return;
+ }
+ const k = this.current, p = c.width, r = c.height, T = k.fillColor;
+ k.maskId = `mask${_++}`;
+ const m = this.svgFactory.createElement("svg:mask");
+ m.setAttributeNS(null, "id", k.maskId);
+ const U = this.svgFactory.createElement("svg:rect");
+ U.setAttributeNS(null, "x", "0"), U.setAttributeNS(null, "y", "0"), U.setAttributeNS(null, "width", v(p)), U.setAttributeNS(null, "height", v(r)), U.setAttributeNS(null, "fill", T), U.setAttributeNS(null, "mask", `url(#${k.maskId})`), this.defs.append(m), this._ensureTransformGroup().append(U), this.paintInlineImageXObject(c, m);
+ }
+ paintFormXObjectBegin(a, c) {
+ if (Array.isArray(a) && a.length === 6 && this.transform(a[0], a[1], a[2], a[3], a[4], a[5]), c) {
+ const k = c[2] - c[0], p = c[3] - c[1], r = this.svgFactory.createElement("svg:rect");
+ r.setAttributeNS(null, "x", c[0]), r.setAttributeNS(null, "y", c[1]), r.setAttributeNS(null, "width", v(k)), r.setAttributeNS(null, "height", v(p)), this.current.element = r, this.clip("nonzero"), this.endPath();
+ }
+ }
+ paintFormXObjectEnd() {
+ }
+ _initialize(a) {
+ const c = this.svgFactory.create(a.width, a.height), k = this.svgFactory.createElement("svg:defs");
+ c.append(k), this.defs = k;
+ const p = this.svgFactory.createElement("svg:g");
+ return p.setAttributeNS(null, "transform", A(a.transform)), c.append(p), this.svg = p, c;
+ }
+ _ensureClipGroup() {
+ if (!this.current.clipGroup) {
+ const a = this.svgFactory.createElement("svg:g");
+ a.setAttributeNS(null, "clip-path", this.current.activeClipUrl), this.svg.append(a), this.current.clipGroup = a;
+ }
+ return this.current.clipGroup;
+ }
+ _ensureTransformGroup() {
+ return this.tgrp || (this.tgrp = this.svgFactory.createElement("svg:g"), this.tgrp.setAttributeNS(null, "transform", A(this.transformMatrix)), this.current.activeClipUrl ? this._ensureClipGroup().append(this.tgrp) : this.svg.append(this.tgrp)), this.tgrp;
+ }
+ }
+ d.SVGGraphics = C;
+ },
+ /* 25 */
+ /***/
+ (dt, d) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.XfaText = void 0;
+ class et {
+ static textContent(P) {
+ const rt = [], X = {
+ items: rt,
+ styles: /* @__PURE__ */ Object.create(null)
+ };
+ function pt(B) {
+ var O;
+ if (!B)
+ return;
+ let F = null;
+ const g = B.name;
+ if (g === "#text")
+ F = B.value;
+ else if (et.shouldBuildText(g))
+ (O = B == null ? void 0 : B.attributes) != null && O.textContent ? F = B.attributes.textContent : B.value && (F = B.value);
+ else
+ return;
+ if (F !== null && rt.push({
+ str: F
+ }), !!B.children)
+ for (const I of B.children)
+ pt(I);
+ }
+ return pt(P), X;
+ }
+ static shouldBuildText(P) {
+ return !(P === "textarea" || P === "input" || P === "option" || P === "select");
+ }
+ }
+ d.XfaText = et;
+ },
+ /* 26 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.TextLayerRenderTask = void 0, d.renderTextLayer = A, d.updateTextLayer = u;
+ var l = et(1), P = et(6);
+ const rt = 1e5, X = 30, pt = 0.8, B = /* @__PURE__ */ new Map();
+ function F(_, w) {
+ let C;
+ if (w && l.FeatureTest.isOffscreenCanvasSupported)
+ C = new OffscreenCanvas(_, _).getContext("2d", {
+ alpha: !1
+ });
+ else {
+ const y = document.createElement("canvas");
+ y.width = y.height = _, C = y.getContext("2d", {
+ alpha: !1
+ });
+ }
+ return C;
+ }
+ function g(_, w) {
+ const C = B.get(_);
+ if (C)
+ return C;
+ const y = F(X, w);
+ y.font = `${X}px ${_}`;
+ const a = y.measureText("");
+ let c = a.fontBoundingBoxAscent, k = Math.abs(a.fontBoundingBoxDescent);
+ if (c) {
+ const r = c / (c + k);
+ return B.set(_, r), y.canvas.width = y.canvas.height = 0, r;
+ }
+ y.strokeStyle = "red", y.clearRect(0, 0, X, X), y.strokeText("g", 0, 0);
+ let p = y.getImageData(0, 0, X, X).data;
+ k = 0;
+ for (let r = p.length - 1 - 3; r >= 0; r -= 4)
+ if (p[r] > 0) {
+ k = Math.ceil(r / 4 / X);
+ break;
+ }
+ y.clearRect(0, 0, X, X), y.strokeText("A", 0, X), p = y.getImageData(0, 0, X, X).data, c = 0;
+ for (let r = 0, T = p.length; r < T; r += 4)
+ if (p[r] > 0) {
+ c = X - Math.floor(r / 4 / X);
+ break;
+ }
+ if (y.canvas.width = y.canvas.height = 0, c) {
+ const r = c / (c + k);
+ return B.set(_, r), r;
+ }
+ return B.set(_, pt), pt;
+ }
+ function O(_, w, C) {
+ const y = document.createElement("span"), a = {
+ angle: 0,
+ canvasWidth: 0,
+ hasText: w.str !== "",
+ hasEOL: w.hasEOL,
+ fontSize: 0
+ };
+ _._textDivs.push(y);
+ const c = l.Util.transform(_._transform, w.transform);
+ let k = Math.atan2(c[1], c[0]);
+ const p = C[w.fontName];
+ p.vertical && (k += Math.PI / 2);
+ const r = Math.hypot(c[2], c[3]), T = r * g(p.fontFamily, _._isOffscreenCanvasSupported);
+ let m, U;
+ k === 0 ? (m = c[4], U = c[5] - T) : (m = c[4] + T * Math.sin(k), U = c[5] - T * Math.cos(k));
+ const z = "calc(var(--scale-factor)*", E = y.style;
+ _._container === _._rootContainer ? (E.left = `${(100 * m / _._pageWidth).toFixed(2)}%`, E.top = `${(100 * U / _._pageHeight).toFixed(2)}%`) : (E.left = `${z}${m.toFixed(2)}px)`, E.top = `${z}${U.toFixed(2)}px)`), E.fontSize = `${z}${r.toFixed(2)}px)`, E.fontFamily = p.fontFamily, a.fontSize = r, y.setAttribute("role", "presentation"), y.textContent = w.str, y.dir = w.dir, _._fontInspectorEnabled && (y.dataset.fontName = w.fontName), k !== 0 && (a.angle = k * (180 / Math.PI));
+ let V = !1;
+ if (w.str.length > 1)
+ V = !0;
+ else if (w.str !== " " && w.transform[0] !== w.transform[3]) {
+ const st = Math.abs(w.transform[0]), at = Math.abs(w.transform[3]);
+ st !== at && Math.max(st, at) / Math.min(st, at) > 1.5 && (V = !0);
+ }
+ V && (a.canvasWidth = p.vertical ? w.height : w.width), _._textDivProperties.set(y, a), _._isReadableStream && _._layoutText(y);
+ }
+ function I(_) {
+ const {
+ div: w,
+ scale: C,
+ properties: y,
+ ctx: a,
+ prevFontSize: c,
+ prevFontFamily: k
+ } = _, {
+ style: p
+ } = w;
+ let r = "";
+ if (y.canvasWidth !== 0 && y.hasText) {
+ const {
+ fontFamily: T
+ } = p, {
+ canvasWidth: m,
+ fontSize: U
+ } = y;
+ (c !== U || k !== T) && (a.font = `${U * C}px ${T}`, _.prevFontSize = U, _.prevFontFamily = T);
+ const {
+ width: z
+ } = a.measureText(w.textContent);
+ z > 0 && (r = `scaleX(${m * C / z})`);
+ }
+ y.angle !== 0 && (r = `rotate(${y.angle}deg) ${r}`), r.length > 0 && (p.transform = r);
+ }
+ function x(_) {
+ if (_._canceled)
+ return;
+ const w = _._textDivs, C = _._capability;
+ if (w.length > rt) {
+ C.resolve();
+ return;
+ }
+ if (!_._isReadableStream)
+ for (const a of w)
+ _._layoutText(a);
+ C.resolve();
+ }
+ class v {
+ constructor({
+ textContentSource: w,
+ container: C,
+ viewport: y,
+ textDivs: a,
+ textDivProperties: c,
+ textContentItemsStr: k,
+ isOffscreenCanvasSupported: p
+ }) {
+ var z;
+ this._textContentSource = w, this._isReadableStream = w instanceof ReadableStream, this._container = this._rootContainer = C, this._textDivs = a || [], this._textContentItemsStr = k || [], this._isOffscreenCanvasSupported = p, this._fontInspectorEnabled = !!((z = globalThis.FontInspector) != null && z.enabled), this._reader = null, this._textDivProperties = c || /* @__PURE__ */ new WeakMap(), this._canceled = !1, this._capability = new l.PromiseCapability(), this._layoutTextParams = {
+ prevFontSize: null,
+ prevFontFamily: null,
+ div: null,
+ scale: y.scale * (globalThis.devicePixelRatio || 1),
+ properties: null,
+ ctx: F(0, p)
+ };
+ const {
+ pageWidth: r,
+ pageHeight: T,
+ pageX: m,
+ pageY: U
+ } = y.rawDims;
+ this._transform = [1, 0, 0, -1, -m, U + T], this._pageWidth = r, this._pageHeight = T, (0, P.setLayerDimensions)(C, y), this._capability.promise.finally(() => {
+ this._layoutTextParams = null;
+ }).catch(() => {
+ });
+ }
+ get promise() {
+ return this._capability.promise;
+ }
+ cancel() {
+ this._canceled = !0, this._reader && (this._reader.cancel(new l.AbortException("TextLayer task cancelled.")).catch(() => {
+ }), this._reader = null), this._capability.reject(new l.AbortException("TextLayer task cancelled."));
+ }
+ _processItems(w, C) {
+ for (const y of w) {
+ if (y.str === void 0) {
+ if (y.type === "beginMarkedContentProps" || y.type === "beginMarkedContent") {
+ const a = this._container;
+ this._container = document.createElement("span"), this._container.classList.add("markedContent"), y.id !== null && this._container.setAttribute("id", `${y.id}`), a.append(this._container);
+ } else
+ y.type === "endMarkedContent" && (this._container = this._container.parentNode);
+ continue;
+ }
+ this._textContentItemsStr.push(y.str), O(this, y, C);
+ }
+ }
+ _layoutText(w) {
+ const C = this._layoutTextParams.properties = this._textDivProperties.get(w);
+ if (this._layoutTextParams.div = w, I(this._layoutTextParams), C.hasText && this._container.append(w), C.hasEOL) {
+ const y = document.createElement("br");
+ y.setAttribute("role", "presentation"), this._container.append(y);
+ }
+ }
+ _render() {
+ const w = new l.PromiseCapability();
+ let C = /* @__PURE__ */ Object.create(null);
+ if (this._isReadableStream) {
+ const y = () => {
+ this._reader.read().then(({
+ value: a,
+ done: c
+ }) => {
+ if (c) {
+ w.resolve();
+ return;
+ }
+ Object.assign(C, a.styles), this._processItems(a.items, C), y();
+ }, w.reject);
+ };
+ this._reader = this._textContentSource.getReader(), y();
+ } else if (this._textContentSource) {
+ const {
+ items: y,
+ styles: a
+ } = this._textContentSource;
+ this._processItems(y, a), w.resolve();
+ } else
+ throw new Error('No "textContentSource" parameter specified.');
+ w.promise.then(() => {
+ C = null, x(this);
+ }, this._capability.reject);
+ }
+ }
+ d.TextLayerRenderTask = v;
+ function A(_) {
+ !_.textContentSource && (_.textContent || _.textContentStream) && ((0, P.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters will be removed in the future, please use `textContentSource` instead."), _.textContentSource = _.textContent || _.textContentStream);
+ const {
+ container: w,
+ viewport: C
+ } = _, y = getComputedStyle(w), a = y.getPropertyValue("visibility"), c = parseFloat(y.getPropertyValue("--scale-factor"));
+ a === "visible" && (!c || Math.abs(c - C.scale) > 1e-5) && console.error("The `--scale-factor` CSS-variable must be set, to the same value as `viewport.scale`, either on the `container`-element itself or higher up in the DOM.");
+ const k = new v(_);
+ return k._render(), k;
+ }
+ function u({
+ container: _,
+ viewport: w,
+ textDivs: C,
+ textDivProperties: y,
+ isOffscreenCanvasSupported: a,
+ mustRotate: c = !0,
+ mustRescale: k = !0
+ }) {
+ if (c && (0, P.setLayerDimensions)(_, {
+ rotation: w.rotation
+ }), k) {
+ const p = F(0, a), T = {
+ prevFontSize: null,
+ prevFontFamily: null,
+ div: null,
+ scale: w.scale * (globalThis.devicePixelRatio || 1),
+ properties: null,
+ ctx: p
+ };
+ for (const m of C)
+ T.properties = y.get(m), T.div = m, I(T);
+ }
+ }
+ },
+ /* 27 */
+ /***/
+ (dt, d, et) => {
+ var g, O, I, x, v, A, u, _, w, C, y, ei, c, ke, p, ii, T, si;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.AnnotationEditorLayer = void 0;
+ var l = et(1), P = et(4), rt = et(28), X = et(33), pt = et(6), B = et(34);
+ const U = class U {
+ constructor({
+ uiManager: E,
+ pageIndex: V,
+ div: st,
+ accessibilityManager: at,
+ annotationLayer: H,
+ viewport: lt,
+ l10n: gt
+ }) {
+ L(this, y);
+ L(this, c);
+ L(this, p);
+ L(this, T);
+ L(this, g, void 0);
+ L(this, O, !1);
+ L(this, I, null);
+ L(this, x, this.pointerup.bind(this));
+ L(this, v, this.pointerdown.bind(this));
+ L(this, A, /* @__PURE__ */ new Map());
+ L(this, u, !1);
+ L(this, _, !1);
+ L(this, w, !1);
+ L(this, C, void 0);
+ const wt = [rt.FreeTextEditor, X.InkEditor, B.StampEditor];
+ if (!U._initialized) {
+ U._initialized = !0;
+ for (const xt of wt)
+ xt.initialize(gt);
+ }
+ E.registerEditorTypes(wt), Z(this, C, E), this.pageIndex = V, this.div = st, Z(this, g, at), Z(this, I, H), this.viewport = lt, t(this, C).addLayer(this);
+ }
+ get isEmpty() {
+ return t(this, A).size === 0;
+ }
+ updateToolbar(E) {
+ t(this, C).updateToolbar(E);
+ }
+ updateMode(E = t(this, C).getMode()) {
+ W(this, T, si).call(this), E === l.AnnotationEditorType.INK ? (this.addInkEditorIfNeeded(!1), this.disableClick()) : this.enableClick(), E !== l.AnnotationEditorType.NONE && (this.div.classList.toggle("freeTextEditing", E === l.AnnotationEditorType.FREETEXT), this.div.classList.toggle("inkEditing", E === l.AnnotationEditorType.INK), this.div.classList.toggle("stampEditing", E === l.AnnotationEditorType.STAMP), this.div.hidden = !1);
+ }
+ addInkEditorIfNeeded(E) {
+ if (!E && t(this, C).getMode() !== l.AnnotationEditorType.INK)
+ return;
+ if (!E) {
+ for (const st of t(this, A).values())
+ if (st.isEmpty()) {
+ st.setInBackground();
+ return;
+ }
+ }
+ W(this, c, ke).call(this, {
+ offsetX: 0,
+ offsetY: 0
+ }, !1).setInBackground();
+ }
+ setEditingState(E) {
+ t(this, C).setEditingState(E);
+ }
+ addCommands(E) {
+ t(this, C).addCommands(E);
+ }
+ enable() {
+ this.div.style.pointerEvents = "auto";
+ const E = /* @__PURE__ */ new Set();
+ for (const st of t(this, A).values())
+ st.enableEditing(), st.annotationElementId && E.add(st.annotationElementId);
+ if (!t(this, I))
+ return;
+ const V = t(this, I).getEditableAnnotations();
+ for (const st of V) {
+ if (st.hide(), t(this, C).isDeletedAnnotationElement(st.data.id) || E.has(st.data.id))
+ continue;
+ const at = this.deserialize(st);
+ at && (this.addOrRebuild(at), at.enableEditing());
+ }
+ }
+ disable() {
+ var V;
+ Z(this, w, !0), this.div.style.pointerEvents = "none";
+ const E = /* @__PURE__ */ new Set();
+ for (const st of t(this, A).values()) {
+ if (st.disableEditing(), !st.annotationElementId || st.serialize() !== null) {
+ E.add(st.annotationElementId);
+ continue;
+ }
+ (V = this.getEditableAnnotation(st.annotationElementId)) == null || V.show(), st.remove();
+ }
+ if (t(this, I)) {
+ const st = t(this, I).getEditableAnnotations();
+ for (const at of st) {
+ const {
+ id: H
+ } = at.data;
+ E.has(H) || t(this, C).isDeletedAnnotationElement(H) || at.show();
+ }
+ }
+ W(this, T, si).call(this), this.isEmpty && (this.div.hidden = !0), Z(this, w, !1);
+ }
+ getEditableAnnotation(E) {
+ var V;
+ return ((V = t(this, I)) == null ? void 0 : V.getEditableAnnotation(E)) || null;
+ }
+ setActiveEditor(E) {
+ t(this, C).getActive() !== E && t(this, C).setActiveEditor(E);
+ }
+ enableClick() {
+ this.div.addEventListener("pointerdown", t(this, v)), this.div.addEventListener("pointerup", t(this, x));
+ }
+ disableClick() {
+ this.div.removeEventListener("pointerdown", t(this, v)), this.div.removeEventListener("pointerup", t(this, x));
+ }
+ attach(E) {
+ t(this, A).set(E.id, E);
+ const {
+ annotationElementId: V
+ } = E;
+ V && t(this, C).isDeletedAnnotationElement(V) && t(this, C).removeDeletedAnnotationElement(E);
+ }
+ detach(E) {
+ var V;
+ t(this, A).delete(E.id), (V = t(this, g)) == null || V.removePointerInTextLayer(E.contentDiv), !t(this, w) && E.annotationElementId && t(this, C).addDeletedAnnotationElement(E);
+ }
+ remove(E) {
+ this.detach(E), t(this, C).removeEditor(E), E.div.contains(document.activeElement) && setTimeout(() => {
+ t(this, C).focusMainContainer();
+ }, 0), E.div.remove(), E.isAttachedToDOM = !1, t(this, _) || this.addInkEditorIfNeeded(!1);
+ }
+ changeParent(E) {
+ var V;
+ E.parent !== this && (E.annotationElementId && (t(this, C).addDeletedAnnotationElement(E.annotationElementId), P.AnnotationEditor.deleteAnnotationElement(E), E.annotationElementId = null), this.attach(E), (V = E.parent) == null || V.detach(E), E.setParent(this), E.div && E.isAttachedToDOM && (E.div.remove(), this.div.append(E.div)));
+ }
+ add(E) {
+ if (this.changeParent(E), t(this, C).addEditor(E), this.attach(E), !E.isAttachedToDOM) {
+ const V = E.render();
+ this.div.append(V), E.isAttachedToDOM = !0;
+ }
+ E.fixAndSetPosition(), E.onceAdded(), t(this, C).addToAnnotationStorage(E);
+ }
+ moveEditorInDOM(E) {
+ var st;
+ if (!E.isAttachedToDOM)
+ return;
+ const {
+ activeElement: V
+ } = document;
+ E.div.contains(V) && (E._focusEventsAllowed = !1, setTimeout(() => {
+ E.div.contains(document.activeElement) ? E._focusEventsAllowed = !0 : (E.div.addEventListener("focusin", () => {
+ E._focusEventsAllowed = !0;
+ }, {
+ once: !0
+ }), V.focus());
+ }, 0)), E._structTreeParentId = (st = t(this, g)) == null ? void 0 : st.moveElementInDOM(this.div, E.div, E.contentDiv, !0);
+ }
+ addOrRebuild(E) {
+ E.needsToBeRebuilt() ? E.rebuild() : this.add(E);
+ }
+ addUndoableEditor(E) {
+ const V = () => E._uiManager.rebuild(E), st = () => {
+ E.remove();
+ };
+ this.addCommands({
+ cmd: V,
+ undo: st,
+ mustExec: !1
+ });
+ }
+ getNextId() {
+ return t(this, C).getId();
+ }
+ pasteEditor(E, V) {
+ t(this, C).updateToolbar(E), t(this, C).updateMode(E);
+ const {
+ offsetX: st,
+ offsetY: at
+ } = W(this, p, ii).call(this), H = this.getNextId(), lt = W(this, y, ei).call(this, {
+ parent: this,
+ id: H,
+ x: st,
+ y: at,
+ uiManager: t(this, C),
+ isCentered: !0,
+ ...V
+ });
+ lt && this.add(lt);
+ }
+ deserialize(E) {
+ switch (E.annotationType ?? E.annotationEditorType) {
+ case l.AnnotationEditorType.FREETEXT:
+ return rt.FreeTextEditor.deserialize(E, this, t(this, C));
+ case l.AnnotationEditorType.INK:
+ return X.InkEditor.deserialize(E, this, t(this, C));
+ case l.AnnotationEditorType.STAMP:
+ return B.StampEditor.deserialize(E, this, t(this, C));
+ }
+ return null;
+ }
+ addNewEditor() {
+ W(this, c, ke).call(this, W(this, p, ii).call(this), !0);
+ }
+ setSelected(E) {
+ t(this, C).setSelected(E);
+ }
+ toggleSelected(E) {
+ t(this, C).toggleSelected(E);
+ }
+ isSelected(E) {
+ return t(this, C).isSelected(E);
+ }
+ unselect(E) {
+ t(this, C).unselect(E);
+ }
+ pointerup(E) {
+ const {
+ isMac: V
+ } = l.FeatureTest.platform;
+ if (!(E.button !== 0 || E.ctrlKey && V) && E.target === this.div && t(this, u)) {
+ if (Z(this, u, !1), !t(this, O)) {
+ Z(this, O, !0);
+ return;
+ }
+ if (t(this, C).getMode() === l.AnnotationEditorType.STAMP) {
+ t(this, C).unselectAll();
+ return;
+ }
+ W(this, c, ke).call(this, E, !1);
+ }
+ }
+ pointerdown(E) {
+ if (t(this, u)) {
+ Z(this, u, !1);
+ return;
+ }
+ const {
+ isMac: V
+ } = l.FeatureTest.platform;
+ if (E.button !== 0 || E.ctrlKey && V || E.target !== this.div)
+ return;
+ Z(this, u, !0);
+ const st = t(this, C).getActive();
+ Z(this, O, !st || st.isEmpty());
+ }
+ findNewParent(E, V, st) {
+ const at = t(this, C).findParent(V, st);
+ return at === null || at === this ? !1 : (at.changeParent(E), !0);
+ }
+ destroy() {
+ var E, V;
+ ((E = t(this, C).getActive()) == null ? void 0 : E.parent) === this && (t(this, C).commitOrRemove(), t(this, C).setActiveEditor(null));
+ for (const st of t(this, A).values())
+ (V = t(this, g)) == null || V.removePointerInTextLayer(st.contentDiv), st.setParent(null), st.isAttachedToDOM = !1, st.div.remove();
+ this.div = null, t(this, A).clear(), t(this, C).removeLayer(this);
+ }
+ render({
+ viewport: E
+ }) {
+ this.viewport = E, (0, pt.setLayerDimensions)(this.div, E);
+ for (const V of t(this, C).getEditors(this.pageIndex))
+ this.add(V);
+ this.updateMode();
+ }
+ update({
+ viewport: E
+ }) {
+ t(this, C).commitOrRemove(), this.viewport = E, (0, pt.setLayerDimensions)(this.div, {
+ rotation: E.rotation
+ }), this.updateMode();
+ }
+ get pageDimensions() {
+ const {
+ pageWidth: E,
+ pageHeight: V
+ } = this.viewport.rawDims;
+ return [E, V];
+ }
+ };
+ g = new WeakMap(), O = new WeakMap(), I = new WeakMap(), x = new WeakMap(), v = new WeakMap(), A = new WeakMap(), u = new WeakMap(), _ = new WeakMap(), w = new WeakMap(), C = new WeakMap(), y = new WeakSet(), ei = function(E) {
+ switch (t(this, C).getMode()) {
+ case l.AnnotationEditorType.FREETEXT:
+ return new rt.FreeTextEditor(E);
+ case l.AnnotationEditorType.INK:
+ return new X.InkEditor(E);
+ case l.AnnotationEditorType.STAMP:
+ return new B.StampEditor(E);
+ }
+ return null;
+ }, c = new WeakSet(), ke = function(E, V) {
+ const st = this.getNextId(), at = W(this, y, ei).call(this, {
+ parent: this,
+ id: st,
+ x: E.offsetX,
+ y: E.offsetY,
+ uiManager: t(this, C),
+ isCentered: V
+ });
+ return at && this.add(at), at;
+ }, p = new WeakSet(), ii = function() {
+ const {
+ x: E,
+ y: V,
+ width: st,
+ height: at
+ } = this.div.getBoundingClientRect(), H = Math.max(0, E), lt = Math.max(0, V), gt = Math.min(window.innerWidth, E + st), wt = Math.min(window.innerHeight, V + at), xt = (H + gt) / 2 - E, S = (lt + wt) / 2 - V, [i, n] = this.viewport.rotation % 180 === 0 ? [xt, S] : [S, xt];
+ return {
+ offsetX: i,
+ offsetY: n
+ };
+ }, T = new WeakSet(), si = function() {
+ Z(this, _, !0);
+ for (const E of t(this, A).values())
+ E.isEmpty() && E.remove();
+ Z(this, _, !1);
+ }, ee(U, "_initialized", !1);
+ let F = U;
+ d.AnnotationEditorLayer = F;
+ },
+ /* 28 */
+ /***/
+ (dt, d, et) => {
+ var B, F, g, O, I, x, v, A, u, _, Fi, C, Mi, a, Ri, k, ye, r, ni, m, Di, z, ri;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.FreeTextEditor = void 0;
+ var l = et(1), P = et(5), rt = et(4), X = et(29);
+ const V = class V extends rt.AnnotationEditor {
+ constructor(H) {
+ super({
+ ...H,
+ name: "freeTextEditor"
+ });
+ L(this, _);
+ L(this, C);
+ L(this, a);
+ L(this, k);
+ L(this, r);
+ L(this, m);
+ L(this, z);
+ L(this, B, this.editorDivBlur.bind(this));
+ L(this, F, this.editorDivFocus.bind(this));
+ L(this, g, this.editorDivInput.bind(this));
+ L(this, O, this.editorDivKeydown.bind(this));
+ L(this, I, void 0);
+ L(this, x, "");
+ L(this, v, `${this.id}-editor`);
+ L(this, A, void 0);
+ L(this, u, null);
+ Z(this, I, H.color || V._defaultColor || rt.AnnotationEditor._defaultLineColor), Z(this, A, H.fontSize || V._defaultFontSize);
+ }
+ static get _keyboardManager() {
+ const H = V.prototype, lt = (xt) => xt.isEmpty(), gt = P.AnnotationEditorUIManager.TRANSLATE_SMALL, wt = P.AnnotationEditorUIManager.TRANSLATE_BIG;
+ return (0, l.shadow)(this, "_keyboardManager", new P.KeyboardManager([[["ctrl+s", "mac+meta+s", "ctrl+p", "mac+meta+p"], H.commitOrRemove, {
+ bubbles: !0
+ }], [["ctrl+Enter", "mac+meta+Enter", "Escape", "mac+Escape"], H.commitOrRemove], [["ArrowLeft", "mac+ArrowLeft"], H._translateEmpty, {
+ args: [-gt, 0],
+ checker: lt
+ }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], H._translateEmpty, {
+ args: [-wt, 0],
+ checker: lt
+ }], [["ArrowRight", "mac+ArrowRight"], H._translateEmpty, {
+ args: [gt, 0],
+ checker: lt
+ }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], H._translateEmpty, {
+ args: [wt, 0],
+ checker: lt
+ }], [["ArrowUp", "mac+ArrowUp"], H._translateEmpty, {
+ args: [0, -gt],
+ checker: lt
+ }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], H._translateEmpty, {
+ args: [0, -wt],
+ checker: lt
+ }], [["ArrowDown", "mac+ArrowDown"], H._translateEmpty, {
+ args: [0, gt],
+ checker: lt
+ }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], H._translateEmpty, {
+ args: [0, wt],
+ checker: lt
+ }]]));
+ }
+ static initialize(H) {
+ rt.AnnotationEditor.initialize(H, {
+ strings: ["free_text2_default_content", "editor_free_text2_aria_label"]
+ });
+ const lt = getComputedStyle(document.documentElement);
+ this._internalPadding = parseFloat(lt.getPropertyValue("--freetext-padding"));
+ }
+ static updateDefaultParams(H, lt) {
+ switch (H) {
+ case l.AnnotationEditorParamsType.FREETEXT_SIZE:
+ V._defaultFontSize = lt;
+ break;
+ case l.AnnotationEditorParamsType.FREETEXT_COLOR:
+ V._defaultColor = lt;
+ break;
+ }
+ }
+ updateParams(H, lt) {
+ switch (H) {
+ case l.AnnotationEditorParamsType.FREETEXT_SIZE:
+ W(this, _, Fi).call(this, lt);
+ break;
+ case l.AnnotationEditorParamsType.FREETEXT_COLOR:
+ W(this, C, Mi).call(this, lt);
+ break;
+ }
+ }
+ static get defaultPropertiesToUpdate() {
+ return [[l.AnnotationEditorParamsType.FREETEXT_SIZE, V._defaultFontSize], [l.AnnotationEditorParamsType.FREETEXT_COLOR, V._defaultColor || rt.AnnotationEditor._defaultLineColor]];
+ }
+ get propertiesToUpdate() {
+ return [[l.AnnotationEditorParamsType.FREETEXT_SIZE, t(this, A)], [l.AnnotationEditorParamsType.FREETEXT_COLOR, t(this, I)]];
+ }
+ _translateEmpty(H, lt) {
+ this._uiManager.translateSelectedEditors(H, lt, !0);
+ }
+ getInitialTranslation() {
+ const H = this.parentScale;
+ return [-V._internalPadding * H, -(V._internalPadding + t(this, A)) * H];
+ }
+ rebuild() {
+ this.parent && (super.rebuild(), this.div !== null && (this.isAttachedToDOM || this.parent.add(this)));
+ }
+ enableEditMode() {
+ this.isInEditMode() || (this.parent.setEditingState(!1), this.parent.updateToolbar(l.AnnotationEditorType.FREETEXT), super.enableEditMode(), this.overlayDiv.classList.remove("enabled"), this.editorDiv.contentEditable = !0, this._isDraggable = !1, this.div.removeAttribute("aria-activedescendant"), this.editorDiv.addEventListener("keydown", t(this, O)), this.editorDiv.addEventListener("focus", t(this, F)), this.editorDiv.addEventListener("blur", t(this, B)), this.editorDiv.addEventListener("input", t(this, g)));
+ }
+ disableEditMode() {
+ this.isInEditMode() && (this.parent.setEditingState(!0), super.disableEditMode(), this.overlayDiv.classList.add("enabled"), this.editorDiv.contentEditable = !1, this.div.setAttribute("aria-activedescendant", t(this, v)), this._isDraggable = !0, this.editorDiv.removeEventListener("keydown", t(this, O)), this.editorDiv.removeEventListener("focus", t(this, F)), this.editorDiv.removeEventListener("blur", t(this, B)), this.editorDiv.removeEventListener("input", t(this, g)), this.div.focus({
+ preventScroll: !0
+ }), this.isEditing = !1, this.parent.div.classList.add("freeTextEditing"));
+ }
+ focusin(H) {
+ this._focusEventsAllowed && (super.focusin(H), H.target !== this.editorDiv && this.editorDiv.focus());
+ }
+ onceAdded() {
+ var H;
+ if (this.width) {
+ W(this, z, ri).call(this);
+ return;
+ }
+ this.enableEditMode(), this.editorDiv.focus(), (H = this._initialOptions) != null && H.isCentered && this.center(), this._initialOptions = null;
+ }
+ isEmpty() {
+ return !this.editorDiv || this.editorDiv.innerText.trim() === "";
+ }
+ remove() {
+ this.isEditing = !1, this.parent && (this.parent.setEditingState(!0), this.parent.div.classList.add("freeTextEditing")), super.remove();
+ }
+ commit() {
+ if (!this.isInEditMode())
+ return;
+ super.commit(), this.disableEditMode();
+ const H = t(this, x), lt = Z(this, x, W(this, a, Ri).call(this).trimEnd());
+ if (H === lt)
+ return;
+ const gt = (wt) => {
+ if (Z(this, x, wt), !wt) {
+ this.remove();
+ return;
+ }
+ W(this, r, ni).call(this), this._uiManager.rebuild(this), W(this, k, ye).call(this);
+ };
+ this.addCommands({
+ cmd: () => {
+ gt(lt);
+ },
+ undo: () => {
+ gt(H);
+ },
+ mustExec: !1
+ }), W(this, k, ye).call(this);
+ }
+ shouldGetKeyboardEvents() {
+ return this.isInEditMode();
+ }
+ enterInEditMode() {
+ this.enableEditMode(), this.editorDiv.focus();
+ }
+ dblclick(H) {
+ this.enterInEditMode();
+ }
+ keydown(H) {
+ H.target === this.div && H.key === "Enter" && (this.enterInEditMode(), H.preventDefault());
+ }
+ editorDivKeydown(H) {
+ V._keyboardManager.exec(this, H);
+ }
+ editorDivFocus(H) {
+ this.isEditing = !0;
+ }
+ editorDivBlur(H) {
+ this.isEditing = !1;
+ }
+ editorDivInput(H) {
+ this.parent.div.classList.toggle("freeTextEditing", this.isEmpty());
+ }
+ disableEditing() {
+ this.editorDiv.setAttribute("role", "comment"), this.editorDiv.removeAttribute("aria-multiline");
+ }
+ enableEditing() {
+ this.editorDiv.setAttribute("role", "textbox"), this.editorDiv.setAttribute("aria-multiline", !0);
+ }
+ render() {
+ if (this.div)
+ return this.div;
+ let H, lt;
+ this.width && (H = this.x, lt = this.y), super.render(), this.editorDiv = document.createElement("div"), this.editorDiv.className = "internal", this.editorDiv.setAttribute("id", t(this, v)), this.enableEditing(), rt.AnnotationEditor._l10nPromise.get("editor_free_text2_aria_label").then((wt) => {
+ var xt;
+ return (xt = this.editorDiv) == null ? void 0 : xt.setAttribute("aria-label", wt);
+ }), rt.AnnotationEditor._l10nPromise.get("free_text2_default_content").then((wt) => {
+ var xt;
+ return (xt = this.editorDiv) == null ? void 0 : xt.setAttribute("default-content", wt);
+ }), this.editorDiv.contentEditable = !0;
+ const {
+ style: gt
+ } = this.editorDiv;
+ if (gt.fontSize = `calc(${t(this, A)}px * var(--scale-factor))`, gt.color = t(this, I), this.div.append(this.editorDiv), this.overlayDiv = document.createElement("div"), this.overlayDiv.classList.add("overlay", "enabled"), this.div.append(this.overlayDiv), (0, P.bindEvents)(this, this.div, ["dblclick", "keydown"]), this.width) {
+ const [wt, xt] = this.parentDimensions;
+ if (this.annotationElementId) {
+ const {
+ position: S
+ } = t(this, u);
+ let [i, n] = this.getInitialTranslation();
+ [i, n] = this.pageTranslationToScreen(i, n);
+ const [s, o] = this.pageDimensions, [h, b] = this.pageTranslation;
+ let M, N;
+ switch (this.rotation) {
+ case 0:
+ M = H + (S[0] - h) / s, N = lt + this.height - (S[1] - b) / o;
+ break;
+ case 90:
+ M = H + (S[0] - h) / s, N = lt - (S[1] - b) / o, [i, n] = [n, -i];
+ break;
+ case 180:
+ M = H - this.width + (S[0] - h) / s, N = lt - (S[1] - b) / o, [i, n] = [-i, -n];
+ break;
+ case 270:
+ M = H + (S[0] - h - this.height * o) / s, N = lt + (S[1] - b - this.width * s) / o, [i, n] = [-n, i];
+ break;
+ }
+ this.setAt(M * wt, N * xt, i, n);
+ } else
+ this.setAt(H * wt, lt * xt, this.width * wt, this.height * xt);
+ W(this, r, ni).call(this), this._isDraggable = !0, this.editorDiv.contentEditable = !1;
+ } else
+ this._isDraggable = !1, this.editorDiv.contentEditable = !0;
+ return this.div;
+ }
+ get contentDiv() {
+ return this.editorDiv;
+ }
+ static deserialize(H, lt, gt) {
+ let wt = null;
+ if (H instanceof X.FreeTextAnnotationElement) {
+ const {
+ data: {
+ defaultAppearanceData: {
+ fontSize: S,
+ fontColor: i
+ },
+ rect: n,
+ rotation: s,
+ id: o
+ },
+ textContent: h,
+ textPosition: b,
+ parent: {
+ page: {
+ pageNumber: M
+ }
+ }
+ } = H;
+ if (!h || h.length === 0)
+ return null;
+ wt = H = {
+ annotationType: l.AnnotationEditorType.FREETEXT,
+ color: Array.from(i),
+ fontSize: S,
+ value: h.join(`
+`),
+ position: b,
+ pageIndex: M - 1,
+ rect: n,
+ rotation: s,
+ id: o,
+ deleted: !1
+ };
+ }
+ const xt = super.deserialize(H, lt, gt);
+ return Z(xt, A, H.fontSize), Z(xt, I, l.Util.makeHexColor(...H.color)), Z(xt, x, H.value), xt.annotationElementId = H.id || null, Z(xt, u, wt), xt;
+ }
+ serialize(H = !1) {
+ if (this.isEmpty())
+ return null;
+ if (this.deleted)
+ return {
+ pageIndex: this.pageIndex,
+ id: this.annotationElementId,
+ deleted: !0
+ };
+ const lt = V._internalPadding * this.parentScale, gt = this.getRect(lt, lt), wt = rt.AnnotationEditor._colorManager.convert(this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : t(this, I)), xt = {
+ annotationType: l.AnnotationEditorType.FREETEXT,
+ color: wt,
+ fontSize: t(this, A),
+ value: t(this, x),
+ pageIndex: this.pageIndex,
+ rect: gt,
+ rotation: this.rotation,
+ structTreeParentId: this._structTreeParentId
+ };
+ return H ? xt : this.annotationElementId && !W(this, m, Di).call(this, xt) ? null : (xt.id = this.annotationElementId, xt);
+ }
+ };
+ B = new WeakMap(), F = new WeakMap(), g = new WeakMap(), O = new WeakMap(), I = new WeakMap(), x = new WeakMap(), v = new WeakMap(), A = new WeakMap(), u = new WeakMap(), _ = new WeakSet(), Fi = function(H) {
+ const lt = (wt) => {
+ this.editorDiv.style.fontSize = `calc(${wt}px * var(--scale-factor))`, this.translate(0, -(wt - t(this, A)) * this.parentScale), Z(this, A, wt), W(this, k, ye).call(this);
+ }, gt = t(this, A);
+ this.addCommands({
+ cmd: () => {
+ lt(H);
+ },
+ undo: () => {
+ lt(gt);
+ },
+ mustExec: !0,
+ type: l.AnnotationEditorParamsType.FREETEXT_SIZE,
+ overwriteIfSameType: !0,
+ keepUndo: !0
+ });
+ }, C = new WeakSet(), Mi = function(H) {
+ const lt = t(this, I);
+ this.addCommands({
+ cmd: () => {
+ Z(this, I, this.editorDiv.style.color = H);
+ },
+ undo: () => {
+ Z(this, I, this.editorDiv.style.color = lt);
+ },
+ mustExec: !0,
+ type: l.AnnotationEditorParamsType.FREETEXT_COLOR,
+ overwriteIfSameType: !0,
+ keepUndo: !0
+ });
+ }, a = new WeakSet(), Ri = function() {
+ const H = this.editorDiv.getElementsByTagName("div");
+ if (H.length === 0)
+ return this.editorDiv.innerText;
+ const lt = [];
+ for (const gt of H)
+ lt.push(gt.innerText.replace(/\r\n?|\n/, ""));
+ return lt.join(`
+`);
+ }, k = new WeakSet(), ye = function() {
+ const [H, lt] = this.parentDimensions;
+ let gt;
+ if (this.isAttachedToDOM)
+ gt = this.div.getBoundingClientRect();
+ else {
+ const {
+ currentLayer: wt,
+ div: xt
+ } = this, S = xt.style.display;
+ xt.style.display = "hidden", wt.div.append(this.div), gt = xt.getBoundingClientRect(), xt.remove(), xt.style.display = S;
+ }
+ this.rotation % 180 === this.parentRotation % 180 ? (this.width = gt.width / H, this.height = gt.height / lt) : (this.width = gt.height / H, this.height = gt.width / lt), this.fixAndSetPosition();
+ }, r = new WeakSet(), ni = function() {
+ if (this.editorDiv.replaceChildren(), !!t(this, x))
+ for (const H of t(this, x).split(`
+`)) {
+ const lt = document.createElement("div");
+ lt.append(H ? document.createTextNode(H) : document.createElement("br")), this.editorDiv.append(lt);
+ }
+ }, m = new WeakSet(), Di = function(H) {
+ const {
+ value: lt,
+ fontSize: gt,
+ color: wt,
+ rect: xt,
+ pageIndex: S
+ } = t(this, u);
+ return H.value !== lt || H.fontSize !== gt || H.rect.some((i, n) => Math.abs(i - xt[n]) >= 1) || H.color.some((i, n) => i !== wt[n]) || H.pageIndex !== S;
+ }, z = new WeakSet(), ri = function(H = !1) {
+ if (!this.annotationElementId)
+ return;
+ if (W(this, k, ye).call(this), !H && (this.width === 0 || this.height === 0)) {
+ setTimeout(() => W(this, z, ri).call(this, !0), 0);
+ return;
+ }
+ const lt = V._internalPadding * this.parentScale;
+ t(this, u).rect = this.getRect(lt, lt);
+ }, ee(V, "_freeTextDefaultContent", ""), ee(V, "_internalPadding", 0), ee(V, "_defaultColor", null), ee(V, "_defaultFontSize", 10), ee(V, "_type", "freetext");
+ let pt = V;
+ d.FreeTextEditor = pt;
+ },
+ /* 29 */
+ /***/
+ (dt, d, et) => {
+ var n, o, ce, b, Ii, N, tt, Q, nt, ct, yt, ut, Ft, Bt, St, Dt, ft, K, J, ht, Et, Ct, jt, Li, Ht, Fe, Vt, ai, $t, oi, Y, G, bt, At, te, Zt, $, li, Lt, Tt, Ot, Nt, Oi, _t, ci;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.StampAnnotationElement = d.InkAnnotationElement = d.FreeTextAnnotationElement = d.AnnotationLayer = void 0;
+ var l = et(1), P = et(6), rt = et(3), X = et(30), pt = et(31), B = et(32);
+ const F = 1e3, g = 9, O = /* @__PURE__ */ new WeakSet();
+ function I(It) {
+ return {
+ width: It[2] - It[0],
+ height: It[3] - It[1]
+ };
+ }
+ class x {
+ static create(R) {
+ switch (R.data.annotationType) {
+ case l.AnnotationType.LINK:
+ return new A(R);
+ case l.AnnotationType.TEXT:
+ return new u(R);
+ case l.AnnotationType.WIDGET:
+ switch (R.data.fieldType) {
+ case "Tx":
+ return new w(R);
+ case "Btn":
+ return R.data.radioButton ? new a(R) : R.data.checkBox ? new y(R) : new c(R);
+ case "Ch":
+ return new k(R);
+ case "Sig":
+ return new C(R);
+ }
+ return new _(R);
+ case l.AnnotationType.POPUP:
+ return new p(R);
+ case l.AnnotationType.FREETEXT:
+ return new T(R);
+ case l.AnnotationType.LINE:
+ return new m(R);
+ case l.AnnotationType.SQUARE:
+ return new U(R);
+ case l.AnnotationType.CIRCLE:
+ return new z(R);
+ case l.AnnotationType.POLYLINE:
+ return new E(R);
+ case l.AnnotationType.CARET:
+ return new st(R);
+ case l.AnnotationType.INK:
+ return new at(R);
+ case l.AnnotationType.POLYGON:
+ return new V(R);
+ case l.AnnotationType.HIGHLIGHT:
+ return new H(R);
+ case l.AnnotationType.UNDERLINE:
+ return new lt(R);
+ case l.AnnotationType.SQUIGGLY:
+ return new gt(R);
+ case l.AnnotationType.STRIKEOUT:
+ return new wt(R);
+ case l.AnnotationType.STAMP:
+ return new xt(R);
+ case l.AnnotationType.FILEATTACHMENT:
+ return new S(R);
+ default:
+ return new v(R);
+ }
+ }
+ }
+ const s = class s {
+ constructor(R, {
+ isRenderable: e = !1,
+ ignoreBorder: f = !1,
+ createQuadrilaterals: D = !1
+ } = {}) {
+ L(this, n, !1);
+ this.isRenderable = e, this.data = R.data, this.layer = R.layer, this.linkService = R.linkService, this.downloadManager = R.downloadManager, this.imageResourcesPath = R.imageResourcesPath, this.renderForms = R.renderForms, this.svgFactory = R.svgFactory, this.annotationStorage = R.annotationStorage, this.enableScripting = R.enableScripting, this.hasJSActions = R.hasJSActions, this._fieldObjects = R.fieldObjects, this.parent = R.parent, e && (this.container = this._createContainer(f)), D && this._createQuadrilaterals();
+ }
+ static _hasPopupData({
+ titleObj: R,
+ contentsObj: e,
+ richText: f
+ }) {
+ return !!(R != null && R.str || e != null && e.str || f != null && f.str);
+ }
+ get hasPopupData() {
+ return s._hasPopupData(this.data);
+ }
+ _createContainer(R) {
+ const {
+ data: e,
+ parent: {
+ page: f,
+ viewport: D
+ }
+ } = this, j = document.createElement("section");
+ j.setAttribute("data-annotation-id", e.id), this instanceof _ || (j.tabIndex = F), j.style.zIndex = this.parent.zIndex++, this.data.popupRef && j.setAttribute("aria-haspopup", "dialog"), e.noRotate && j.classList.add("norotate");
+ const {
+ pageWidth: q,
+ pageHeight: it,
+ pageX: mt,
+ pageY: kt
+ } = D.rawDims;
+ if (!e.rect || this instanceof p) {
+ const {
+ rotation: Ut
+ } = e;
+ return !e.hasOwnCanvas && Ut !== 0 && this.setRotation(Ut, j), j;
+ }
+ const {
+ width: Pt,
+ height: zt
+ } = I(e.rect), Mt = l.Util.normalizeRect([e.rect[0], f.view[3] - e.rect[1] + f.view[1], e.rect[2], f.view[3] - e.rect[3] + f.view[1]]);
+ if (!R && e.borderStyle.width > 0) {
+ j.style.borderWidth = `${e.borderStyle.width}px`;
+ const Ut = e.borderStyle.horizontalCornerRadius, qt = e.borderStyle.verticalCornerRadius;
+ if (Ut > 0 || qt > 0) {
+ const Qt = `calc(${Ut}px * var(--scale-factor)) / calc(${qt}px * var(--scale-factor))`;
+ j.style.borderRadius = Qt;
+ } else if (this instanceof a) {
+ const Qt = `calc(${Pt}px * var(--scale-factor)) / calc(${zt}px * var(--scale-factor))`;
+ j.style.borderRadius = Qt;
+ }
+ switch (e.borderStyle.style) {
+ case l.AnnotationBorderStyleType.SOLID:
+ j.style.borderStyle = "solid";
+ break;
+ case l.AnnotationBorderStyleType.DASHED:
+ j.style.borderStyle = "dashed";
+ break;
+ case l.AnnotationBorderStyleType.BEVELED:
+ (0, l.warn)("Unimplemented border style: beveled");
+ break;
+ case l.AnnotationBorderStyleType.INSET:
+ (0, l.warn)("Unimplemented border style: inset");
+ break;
+ case l.AnnotationBorderStyleType.UNDERLINE:
+ j.style.borderBottomStyle = "solid";
+ break;
+ }
+ const Kt = e.borderColor || null;
+ Kt ? (Z(this, n, !0), j.style.borderColor = l.Util.makeHexColor(Kt[0] | 0, Kt[1] | 0, Kt[2] | 0)) : j.style.borderWidth = 0;
+ }
+ j.style.left = `${100 * (Mt[0] - mt) / q}%`, j.style.top = `${100 * (Mt[1] - kt) / it}%`;
+ const {
+ rotation: Rt
+ } = e;
+ return e.hasOwnCanvas || Rt === 0 ? (j.style.width = `${100 * Pt / q}%`, j.style.height = `${100 * zt / it}%`) : this.setRotation(Rt, j), j;
+ }
+ setRotation(R, e = this.container) {
+ if (!this.data.rect)
+ return;
+ const {
+ pageWidth: f,
+ pageHeight: D
+ } = this.parent.viewport.rawDims, {
+ width: j,
+ height: q
+ } = I(this.data.rect);
+ let it, mt;
+ R % 180 === 0 ? (it = 100 * j / f, mt = 100 * q / D) : (it = 100 * q / f, mt = 100 * j / D), e.style.width = `${it}%`, e.style.height = `${mt}%`, e.setAttribute("data-main-rotation", (360 - R) % 360);
+ }
+ get _commonActions() {
+ const R = (e, f, D) => {
+ const j = D.detail[e], q = j[0], it = j.slice(1);
+ D.target.style[f] = X.ColorConverters[`${q}_HTML`](it), this.annotationStorage.setValue(this.data.id, {
+ [f]: X.ColorConverters[`${q}_rgb`](it)
+ });
+ };
+ return (0, l.shadow)(this, "_commonActions", {
+ display: (e) => {
+ const {
+ display: f
+ } = e.detail, D = f % 2 === 1;
+ this.container.style.visibility = D ? "hidden" : "visible", this.annotationStorage.setValue(this.data.id, {
+ noView: D,
+ noPrint: f === 1 || f === 2
+ });
+ },
+ print: (e) => {
+ this.annotationStorage.setValue(this.data.id, {
+ noPrint: !e.detail.print
+ });
+ },
+ hidden: (e) => {
+ const {
+ hidden: f
+ } = e.detail;
+ this.container.style.visibility = f ? "hidden" : "visible", this.annotationStorage.setValue(this.data.id, {
+ noPrint: f,
+ noView: f
+ });
+ },
+ focus: (e) => {
+ setTimeout(() => e.target.focus({
+ preventScroll: !1
+ }), 0);
+ },
+ userName: (e) => {
+ e.target.title = e.detail.userName;
+ },
+ readonly: (e) => {
+ e.target.disabled = e.detail.readonly;
+ },
+ required: (e) => {
+ this._setRequired(e.target, e.detail.required);
+ },
+ bgColor: (e) => {
+ R("bgColor", "backgroundColor", e);
+ },
+ fillColor: (e) => {
+ R("fillColor", "backgroundColor", e);
+ },
+ fgColor: (e) => {
+ R("fgColor", "color", e);
+ },
+ textColor: (e) => {
+ R("textColor", "color", e);
+ },
+ borderColor: (e) => {
+ R("borderColor", "borderColor", e);
+ },
+ strokeColor: (e) => {
+ R("strokeColor", "borderColor", e);
+ },
+ rotation: (e) => {
+ const f = e.detail.rotation;
+ this.setRotation(f), this.annotationStorage.setValue(this.data.id, {
+ rotation: f
+ });
+ }
+ });
+ }
+ _dispatchEventFromSandbox(R, e) {
+ const f = this._commonActions;
+ for (const D of Object.keys(e.detail)) {
+ const j = R[D] || f[D];
+ j == null || j(e);
+ }
+ }
+ _setDefaultPropertiesFromJS(R) {
+ if (!this.enableScripting)
+ return;
+ const e = this.annotationStorage.getRawValue(this.data.id);
+ if (!e)
+ return;
+ const f = this._commonActions;
+ for (const [D, j] of Object.entries(e)) {
+ const q = f[D];
+ if (q) {
+ const it = {
+ detail: {
+ [D]: j
+ },
+ target: R
+ };
+ q(it), delete e[D];
+ }
+ }
+ }
+ _createQuadrilaterals() {
+ if (!this.container)
+ return;
+ const {
+ quadPoints: R
+ } = this.data;
+ if (!R)
+ return;
+ const [e, f, D, j] = this.data.rect;
+ if (R.length === 1) {
+ const [, {
+ x: qt,
+ y: Kt
+ }, {
+ x: Qt,
+ y: se
+ }] = R[0];
+ if (D === qt && j === Kt && e === Qt && f === se)
+ return;
+ }
+ const {
+ style: q
+ } = this.container;
+ let it;
+ if (t(this, n)) {
+ const {
+ borderColor: qt,
+ borderWidth: Kt
+ } = q;
+ q.borderWidth = 0, it = ["url('data:image/svg+xml;utf8,", '')"), q.backgroundImage = it.join("")), this.container.append(zt), this.container.style.clipPath = `url(#${Ut})`;
+ }
+ _createPopup() {
+ const {
+ container: R,
+ data: e
+ } = this;
+ R.setAttribute("aria-haspopup", "dialog");
+ const f = new p({
+ data: {
+ color: e.color,
+ titleObj: e.titleObj,
+ modificationDate: e.modificationDate,
+ contentsObj: e.contentsObj,
+ richText: e.richText,
+ parentRect: e.rect,
+ borderStyle: 0,
+ id: `popup_${e.id}`,
+ rotation: e.rotation
+ },
+ parent: this.parent,
+ elements: [this]
+ });
+ this.parent.div.append(f.render());
+ }
+ render() {
+ (0, l.unreachable)("Abstract method `AnnotationElement.render` called");
+ }
+ _getElementsByName(R, e = null) {
+ const f = [];
+ if (this._fieldObjects) {
+ const D = this._fieldObjects[R];
+ if (D)
+ for (const {
+ page: j,
+ id: q,
+ exportValues: it
+ } of D) {
+ if (j === -1 || q === e)
+ continue;
+ const mt = typeof it == "string" ? it : null, kt = document.querySelector(`[data-element-id="${q}"]`);
+ if (kt && !O.has(kt)) {
+ (0, l.warn)(`_getElementsByName - element not allowed: ${q}`);
+ continue;
+ }
+ f.push({
+ id: q,
+ exportValue: mt,
+ domElement: kt
+ });
+ }
+ return f;
+ }
+ for (const D of document.getElementsByName(R)) {
+ const {
+ exportValue: j
+ } = D, q = D.getAttribute("data-element-id");
+ q !== e && O.has(D) && f.push({
+ id: q,
+ exportValue: j,
+ domElement: D
+ });
+ }
+ return f;
+ }
+ show() {
+ var R;
+ this.container && (this.container.hidden = !1), (R = this.popup) == null || R.maybeShow();
+ }
+ hide() {
+ var R;
+ this.container && (this.container.hidden = !0), (R = this.popup) == null || R.forceHide();
+ }
+ getElementsToTriggerPopup() {
+ return this.container;
+ }
+ addHighlightArea() {
+ const R = this.getElementsToTriggerPopup();
+ if (Array.isArray(R))
+ for (const e of R)
+ e.classList.add("highlightArea");
+ else
+ R.classList.add("highlightArea");
+ }
+ _editOnDoubleClick() {
+ const {
+ annotationEditorType: R,
+ data: {
+ id: e
+ }
+ } = this;
+ this.container.addEventListener("dblclick", () => {
+ var f;
+ (f = this.linkService.eventBus) == null || f.dispatch("switchannotationeditormode", {
+ source: this,
+ mode: R,
+ editId: e
+ });
+ });
+ }
+ };
+ n = new WeakMap();
+ let v = s;
+ class A extends v {
+ constructor(e, f = null) {
+ super(e, {
+ isRenderable: !0,
+ ignoreBorder: !!(f != null && f.ignoreBorder),
+ createQuadrilaterals: !0
+ });
+ L(this, o);
+ L(this, b);
+ this.isTooltipOnly = e.data.isTooltipOnly;
+ }
+ render() {
+ const {
+ data: e,
+ linkService: f
+ } = this, D = document.createElement("a");
+ D.setAttribute("data-element-id", e.id);
+ let j = !1;
+ return e.url ? (f.addLinkAttributes(D, e.url, e.newWindow), j = !0) : e.action ? (this._bindNamedAction(D, e.action), j = !0) : e.attachment ? (this._bindAttachment(D, e.attachment), j = !0) : e.setOCGState ? (W(this, b, Ii).call(this, D, e.setOCGState), j = !0) : e.dest ? (this._bindLink(D, e.dest), j = !0) : (e.actions && (e.actions.Action || e.actions["Mouse Up"] || e.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions && (this._bindJSAction(D, e), j = !0), e.resetForm ? (this._bindResetFormAction(D, e.resetForm), j = !0) : this.isTooltipOnly && !j && (this._bindLink(D, ""), j = !0)), this.container.classList.add("linkAnnotation"), j && this.container.append(D), this.container;
+ }
+ _bindLink(e, f) {
+ e.href = this.linkService.getDestinationHash(f), e.onclick = () => (f && this.linkService.goToDestination(f), !1), (f || f === "") && W(this, o, ce).call(this);
+ }
+ _bindNamedAction(e, f) {
+ e.href = this.linkService.getAnchorUrl(""), e.onclick = () => (this.linkService.executeNamedAction(f), !1), W(this, o, ce).call(this);
+ }
+ _bindAttachment(e, f) {
+ e.href = this.linkService.getAnchorUrl(""), e.onclick = () => {
+ var D;
+ return (D = this.downloadManager) == null || D.openOrDownloadData(this.container, f.content, f.filename), !1;
+ }, W(this, o, ce).call(this);
+ }
+ _bindJSAction(e, f) {
+ e.href = this.linkService.getAnchorUrl("");
+ const D = /* @__PURE__ */ new Map([["Action", "onclick"], ["Mouse Up", "onmouseup"], ["Mouse Down", "onmousedown"]]);
+ for (const j of Object.keys(f.actions)) {
+ const q = D.get(j);
+ q && (e[q] = () => {
+ var it;
+ return (it = this.linkService.eventBus) == null || it.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: f.id,
+ name: j
+ }
+ }), !1;
+ });
+ }
+ e.onclick || (e.onclick = () => !1), W(this, o, ce).call(this);
+ }
+ _bindResetFormAction(e, f) {
+ const D = e.onclick;
+ if (D || (e.href = this.linkService.getAnchorUrl("")), W(this, o, ce).call(this), !this._fieldObjects) {
+ (0, l.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'), D || (e.onclick = () => !1);
+ return;
+ }
+ e.onclick = () => {
+ var zt;
+ D == null || D();
+ const {
+ fields: j,
+ refs: q,
+ include: it
+ } = f, mt = [];
+ if (j.length !== 0 || q.length !== 0) {
+ const Mt = new Set(q);
+ for (const Rt of j) {
+ const Ut = this._fieldObjects[Rt] || [];
+ for (const {
+ id: qt
+ } of Ut)
+ Mt.add(qt);
+ }
+ for (const Rt of Object.values(this._fieldObjects))
+ for (const Ut of Rt)
+ Mt.has(Ut.id) === it && mt.push(Ut);
+ } else
+ for (const Mt of Object.values(this._fieldObjects))
+ mt.push(...Mt);
+ const kt = this.annotationStorage, Pt = [];
+ for (const Mt of mt) {
+ const {
+ id: Rt
+ } = Mt;
+ switch (Pt.push(Rt), Mt.type) {
+ case "text": {
+ const qt = Mt.defaultValue || "";
+ kt.setValue(Rt, {
+ value: qt
+ });
+ break;
+ }
+ case "checkbox":
+ case "radiobutton": {
+ const qt = Mt.defaultValue === Mt.exportValues;
+ kt.setValue(Rt, {
+ value: qt
+ });
+ break;
+ }
+ case "combobox":
+ case "listbox": {
+ const qt = Mt.defaultValue || "";
+ kt.setValue(Rt, {
+ value: qt
+ });
+ break;
+ }
+ default:
+ continue;
+ }
+ const Ut = document.querySelector(`[data-element-id="${Rt}"]`);
+ if (Ut) {
+ if (!O.has(Ut)) {
+ (0, l.warn)(`_bindResetFormAction - element not allowed: ${Rt}`);
+ continue;
+ }
+ } else
+ continue;
+ Ut.dispatchEvent(new Event("resetform"));
+ }
+ return this.enableScripting && ((zt = this.linkService.eventBus) == null || zt.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: "app",
+ ids: Pt,
+ name: "ResetForm"
+ }
+ })), !1;
+ };
+ }
+ }
+ o = new WeakSet(), ce = function() {
+ this.container.setAttribute("data-internal-link", "");
+ }, b = new WeakSet(), Ii = function(e, f) {
+ e.href = this.linkService.getAnchorUrl(""), e.onclick = () => (this.linkService.executeSetOCGState(f), !1), W(this, o, ce).call(this);
+ };
+ class u extends v {
+ constructor(R) {
+ super(R, {
+ isRenderable: !0
+ });
+ }
+ render() {
+ this.container.classList.add("textAnnotation");
+ const R = document.createElement("img");
+ return R.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg", R.alt = "[{{type}} Annotation]", R.dataset.l10nId = "text_annotation_type", R.dataset.l10nArgs = JSON.stringify({
+ type: this.data.name
+ }), !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.append(R), this.container;
+ }
+ }
+ class _ extends v {
+ render() {
+ return this.data.alternativeText && (this.container.title = this.data.alternativeText), this.container;
+ }
+ showElementAndHideCanvas(R) {
+ var e;
+ this.data.hasOwnCanvas && (((e = R.previousSibling) == null ? void 0 : e.nodeName) === "CANVAS" && (R.previousSibling.hidden = !0), R.hidden = !1);
+ }
+ _getKeyModifier(R) {
+ const {
+ isWin: e,
+ isMac: f
+ } = l.FeatureTest.platform;
+ return e && R.ctrlKey || f && R.metaKey;
+ }
+ _setEventListener(R, e, f, D, j) {
+ f.includes("mouse") ? R.addEventListener(f, (q) => {
+ var it;
+ (it = this.linkService.eventBus) == null || it.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: this.data.id,
+ name: D,
+ value: j(q),
+ shift: q.shiftKey,
+ modifier: this._getKeyModifier(q)
+ }
+ });
+ }) : R.addEventListener(f, (q) => {
+ var it;
+ if (f === "blur") {
+ if (!e.focused || !q.relatedTarget)
+ return;
+ e.focused = !1;
+ } else if (f === "focus") {
+ if (e.focused)
+ return;
+ e.focused = !0;
+ }
+ j && ((it = this.linkService.eventBus) == null || it.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: this.data.id,
+ name: D,
+ value: j(q)
+ }
+ }));
+ });
+ }
+ _setEventListeners(R, e, f, D) {
+ var j, q, it;
+ for (const [mt, kt] of f)
+ (kt === "Action" || (j = this.data.actions) != null && j[kt]) && ((kt === "Focus" || kt === "Blur") && (e || (e = {
+ focused: !1
+ })), this._setEventListener(R, e, mt, kt, D), kt === "Focus" && !((q = this.data.actions) != null && q.Blur) ? this._setEventListener(R, e, "blur", "Blur", null) : kt === "Blur" && !((it = this.data.actions) != null && it.Focus) && this._setEventListener(R, e, "focus", "Focus", null));
+ }
+ _setBackgroundColor(R) {
+ const e = this.data.backgroundColor || null;
+ R.style.backgroundColor = e === null ? "transparent" : l.Util.makeHexColor(e[0], e[1], e[2]);
+ }
+ _setTextStyle(R) {
+ const e = ["left", "center", "right"], {
+ fontColor: f
+ } = this.data.defaultAppearanceData, D = this.data.defaultAppearanceData.fontSize || g, j = R.style;
+ let q;
+ const it = 2, mt = (kt) => Math.round(10 * kt) / 10;
+ if (this.data.multiLine) {
+ const kt = Math.abs(this.data.rect[3] - this.data.rect[1] - it), Pt = Math.round(kt / (l.LINE_FACTOR * D)) || 1, zt = kt / Pt;
+ q = Math.min(D, mt(zt / l.LINE_FACTOR));
+ } else {
+ const kt = Math.abs(this.data.rect[3] - this.data.rect[1] - it);
+ q = Math.min(D, mt(kt / l.LINE_FACTOR));
+ }
+ j.fontSize = `calc(${q}px * var(--scale-factor))`, j.color = l.Util.makeHexColor(f[0], f[1], f[2]), this.data.textAlignment !== null && (j.textAlign = e[this.data.textAlignment]);
+ }
+ _setRequired(R, e) {
+ e ? R.setAttribute("required", !0) : R.removeAttribute("required"), R.setAttribute("aria-required", e);
+ }
+ }
+ class w extends _ {
+ constructor(R) {
+ const e = R.renderForms || !R.data.hasAppearance && !!R.data.fieldValue;
+ super(R, {
+ isRenderable: e
+ });
+ }
+ setPropertyOnSiblings(R, e, f, D) {
+ const j = this.annotationStorage;
+ for (const q of this._getElementsByName(R.name, R.id))
+ q.domElement && (q.domElement[e] = f), j.setValue(q.id, {
+ [D]: f
+ });
+ }
+ render() {
+ var D, j;
+ const R = this.annotationStorage, e = this.data.id;
+ this.container.classList.add("textWidgetAnnotation");
+ let f = null;
+ if (this.renderForms) {
+ const q = R.getValue(e, {
+ value: this.data.fieldValue
+ });
+ let it = q.value || "";
+ const mt = R.getValue(e, {
+ charLimit: this.data.maxLen
+ }).charLimit;
+ mt && it.length > mt && (it = it.slice(0, mt));
+ let kt = q.formattedValue || ((D = this.data.textContent) == null ? void 0 : D.join(`
+`)) || null;
+ kt && this.data.comb && (kt = kt.replaceAll(/\s+/g, ""));
+ const Pt = {
+ userValue: it,
+ formattedValue: kt,
+ lastCommittedValue: null,
+ commitKey: 1,
+ focused: !1
+ };
+ this.data.multiLine ? (f = document.createElement("textarea"), f.textContent = kt ?? it, this.data.doNotScroll && (f.style.overflowY = "hidden")) : (f = document.createElement("input"), f.type = "text", f.setAttribute("value", kt ?? it), this.data.doNotScroll && (f.style.overflowX = "hidden")), this.data.hasOwnCanvas && (f.hidden = !0), O.add(f), f.setAttribute("data-element-id", e), f.disabled = this.data.readOnly, f.name = this.data.fieldName, f.tabIndex = F, this._setRequired(f, this.data.required), mt && (f.maxLength = mt), f.addEventListener("input", (Mt) => {
+ R.setValue(e, {
+ value: Mt.target.value
+ }), this.setPropertyOnSiblings(f, "value", Mt.target.value, "value"), Pt.formattedValue = null;
+ }), f.addEventListener("resetform", (Mt) => {
+ const Rt = this.data.defaultFieldValue ?? "";
+ f.value = Pt.userValue = Rt, Pt.formattedValue = null;
+ });
+ let zt = (Mt) => {
+ const {
+ formattedValue: Rt
+ } = Pt;
+ Rt != null && (Mt.target.value = Rt), Mt.target.scrollLeft = 0;
+ };
+ if (this.enableScripting && this.hasJSActions) {
+ f.addEventListener("focus", (Rt) => {
+ if (Pt.focused)
+ return;
+ const {
+ target: Ut
+ } = Rt;
+ Pt.userValue && (Ut.value = Pt.userValue), Pt.lastCommittedValue = Ut.value, Pt.commitKey = 1, Pt.focused = !0;
+ }), f.addEventListener("updatefromsandbox", (Rt) => {
+ this.showElementAndHideCanvas(Rt.target);
+ const Ut = {
+ value(qt) {
+ Pt.userValue = qt.detail.value ?? "", R.setValue(e, {
+ value: Pt.userValue.toString()
+ }), qt.target.value = Pt.userValue;
+ },
+ formattedValue(qt) {
+ const {
+ formattedValue: Kt
+ } = qt.detail;
+ Pt.formattedValue = Kt, Kt != null && qt.target !== document.activeElement && (qt.target.value = Kt), R.setValue(e, {
+ formattedValue: Kt
+ });
+ },
+ selRange(qt) {
+ qt.target.setSelectionRange(...qt.detail.selRange);
+ },
+ charLimit: (qt) => {
+ var ie;
+ const {
+ charLimit: Kt
+ } = qt.detail, {
+ target: Qt
+ } = qt;
+ if (Kt === 0) {
+ Qt.removeAttribute("maxLength");
+ return;
+ }
+ Qt.setAttribute("maxLength", Kt);
+ let se = Pt.userValue;
+ !se || se.length <= Kt || (se = se.slice(0, Kt), Qt.value = Pt.userValue = se, R.setValue(e, {
+ value: se
+ }), (ie = this.linkService.eventBus) == null || ie.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: e,
+ name: "Keystroke",
+ value: se,
+ willCommit: !0,
+ commitKey: 1,
+ selStart: Qt.selectionStart,
+ selEnd: Qt.selectionEnd
+ }
+ }));
+ }
+ };
+ this._dispatchEventFromSandbox(Ut, Rt);
+ }), f.addEventListener("keydown", (Rt) => {
+ var Kt;
+ Pt.commitKey = 1;
+ let Ut = -1;
+ if (Rt.key === "Escape" ? Ut = 0 : Rt.key === "Enter" && !this.data.multiLine ? Ut = 2 : Rt.key === "Tab" && (Pt.commitKey = 3), Ut === -1)
+ return;
+ const {
+ value: qt
+ } = Rt.target;
+ Pt.lastCommittedValue !== qt && (Pt.lastCommittedValue = qt, Pt.userValue = qt, (Kt = this.linkService.eventBus) == null || Kt.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: e,
+ name: "Keystroke",
+ value: qt,
+ willCommit: !0,
+ commitKey: Ut,
+ selStart: Rt.target.selectionStart,
+ selEnd: Rt.target.selectionEnd
+ }
+ }));
+ });
+ const Mt = zt;
+ zt = null, f.addEventListener("blur", (Rt) => {
+ var qt;
+ if (!Pt.focused || !Rt.relatedTarget)
+ return;
+ Pt.focused = !1;
+ const {
+ value: Ut
+ } = Rt.target;
+ Pt.userValue = Ut, Pt.lastCommittedValue !== Ut && ((qt = this.linkService.eventBus) == null || qt.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: e,
+ name: "Keystroke",
+ value: Ut,
+ willCommit: !0,
+ commitKey: Pt.commitKey,
+ selStart: Rt.target.selectionStart,
+ selEnd: Rt.target.selectionEnd
+ }
+ })), Mt(Rt);
+ }), (j = this.data.actions) != null && j.Keystroke && f.addEventListener("beforeinput", (Rt) => {
+ var oe;
+ Pt.lastCommittedValue = null;
+ const {
+ data: Ut,
+ target: qt
+ } = Rt, {
+ value: Kt,
+ selectionStart: Qt,
+ selectionEnd: se
+ } = qt;
+ let ie = Qt, ne = se;
+ switch (Rt.inputType) {
+ case "deleteWordBackward": {
+ const le = Kt.substring(0, Qt).match(/\w*[^\w]*$/);
+ le && (ie -= le[0].length);
+ break;
+ }
+ case "deleteWordForward": {
+ const le = Kt.substring(Qt).match(/^[^\w]*\w*/);
+ le && (ne += le[0].length);
+ break;
+ }
+ case "deleteContentBackward":
+ Qt === se && (ie -= 1);
+ break;
+ case "deleteContentForward":
+ Qt === se && (ne += 1);
+ break;
+ }
+ Rt.preventDefault(), (oe = this.linkService.eventBus) == null || oe.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: e,
+ name: "Keystroke",
+ value: Kt,
+ change: Ut || "",
+ willCommit: !1,
+ selStart: ie,
+ selEnd: ne
+ }
+ });
+ }), this._setEventListeners(f, Pt, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], (Rt) => Rt.target.value);
+ }
+ if (zt && f.addEventListener("blur", zt), this.data.comb) {
+ const Rt = (this.data.rect[2] - this.data.rect[0]) / mt;
+ f.classList.add("comb"), f.style.letterSpacing = `calc(${Rt}px * var(--scale-factor) - 1ch)`;
+ }
+ } else
+ f = document.createElement("div"), f.textContent = this.data.fieldValue, f.style.verticalAlign = "middle", f.style.display = "table-cell";
+ return this._setTextStyle(f), this._setBackgroundColor(f), this._setDefaultPropertiesFromJS(f), this.container.append(f), this.container;
+ }
+ }
+ class C extends _ {
+ constructor(R) {
+ super(R, {
+ isRenderable: !!R.data.hasOwnCanvas
+ });
+ }
+ }
+ class y extends _ {
+ constructor(R) {
+ super(R, {
+ isRenderable: R.renderForms
+ });
+ }
+ render() {
+ const R = this.annotationStorage, e = this.data, f = e.id;
+ let D = R.getValue(f, {
+ value: e.exportValue === e.fieldValue
+ }).value;
+ typeof D == "string" && (D = D !== "Off", R.setValue(f, {
+ value: D
+ })), this.container.classList.add("buttonWidgetAnnotation", "checkBox");
+ const j = document.createElement("input");
+ return O.add(j), j.setAttribute("data-element-id", f), j.disabled = e.readOnly, this._setRequired(j, this.data.required), j.type = "checkbox", j.name = e.fieldName, D && j.setAttribute("checked", !0), j.setAttribute("exportValue", e.exportValue), j.tabIndex = F, j.addEventListener("change", (q) => {
+ const {
+ name: it,
+ checked: mt
+ } = q.target;
+ for (const kt of this._getElementsByName(it, f)) {
+ const Pt = mt && kt.exportValue === e.exportValue;
+ kt.domElement && (kt.domElement.checked = Pt), R.setValue(kt.id, {
+ value: Pt
+ });
+ }
+ R.setValue(f, {
+ value: mt
+ });
+ }), j.addEventListener("resetform", (q) => {
+ const it = e.defaultFieldValue || "Off";
+ q.target.checked = it === e.exportValue;
+ }), this.enableScripting && this.hasJSActions && (j.addEventListener("updatefromsandbox", (q) => {
+ const it = {
+ value(mt) {
+ mt.target.checked = mt.detail.value !== "Off", R.setValue(f, {
+ value: mt.target.checked
+ });
+ }
+ };
+ this._dispatchEventFromSandbox(it, q);
+ }), this._setEventListeners(j, null, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], (q) => q.target.checked)), this._setBackgroundColor(j), this._setDefaultPropertiesFromJS(j), this.container.append(j), this.container;
+ }
+ }
+ class a extends _ {
+ constructor(R) {
+ super(R, {
+ isRenderable: R.renderForms
+ });
+ }
+ render() {
+ this.container.classList.add("buttonWidgetAnnotation", "radioButton");
+ const R = this.annotationStorage, e = this.data, f = e.id;
+ let D = R.getValue(f, {
+ value: e.fieldValue === e.buttonValue
+ }).value;
+ typeof D == "string" && (D = D !== e.buttonValue, R.setValue(f, {
+ value: D
+ }));
+ const j = document.createElement("input");
+ if (O.add(j), j.setAttribute("data-element-id", f), j.disabled = e.readOnly, this._setRequired(j, this.data.required), j.type = "radio", j.name = e.fieldName, D && j.setAttribute("checked", !0), j.tabIndex = F, j.addEventListener("change", (q) => {
+ const {
+ name: it,
+ checked: mt
+ } = q.target;
+ for (const kt of this._getElementsByName(it, f))
+ R.setValue(kt.id, {
+ value: !1
+ });
+ R.setValue(f, {
+ value: mt
+ });
+ }), j.addEventListener("resetform", (q) => {
+ const it = e.defaultFieldValue;
+ q.target.checked = it != null && it === e.buttonValue;
+ }), this.enableScripting && this.hasJSActions) {
+ const q = e.buttonValue;
+ j.addEventListener("updatefromsandbox", (it) => {
+ const mt = {
+ value: (kt) => {
+ const Pt = q === kt.detail.value;
+ for (const zt of this._getElementsByName(kt.target.name)) {
+ const Mt = Pt && zt.id === f;
+ zt.domElement && (zt.domElement.checked = Mt), R.setValue(zt.id, {
+ value: Mt
+ });
+ }
+ }
+ };
+ this._dispatchEventFromSandbox(mt, it);
+ }), this._setEventListeners(j, null, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], (it) => it.target.checked);
+ }
+ return this._setBackgroundColor(j), this._setDefaultPropertiesFromJS(j), this.container.append(j), this.container;
+ }
+ }
+ class c extends A {
+ constructor(R) {
+ super(R, {
+ ignoreBorder: R.data.hasAppearance
+ });
+ }
+ render() {
+ const R = super.render();
+ R.classList.add("buttonWidgetAnnotation", "pushButton"), this.data.alternativeText && (R.title = this.data.alternativeText);
+ const e = R.lastChild;
+ return this.enableScripting && this.hasJSActions && e && (this._setDefaultPropertiesFromJS(e), e.addEventListener("updatefromsandbox", (f) => {
+ this._dispatchEventFromSandbox({}, f);
+ })), R;
+ }
+ }
+ class k extends _ {
+ constructor(R) {
+ super(R, {
+ isRenderable: R.renderForms
+ });
+ }
+ render() {
+ this.container.classList.add("choiceWidgetAnnotation");
+ const R = this.annotationStorage, e = this.data.id, f = R.getValue(e, {
+ value: this.data.fieldValue
+ }), D = document.createElement("select");
+ O.add(D), D.setAttribute("data-element-id", e), D.disabled = this.data.readOnly, this._setRequired(D, this.data.required), D.name = this.data.fieldName, D.tabIndex = F;
+ let j = this.data.combo && this.data.options.length > 0;
+ this.data.combo || (D.size = this.data.options.length, this.data.multiSelect && (D.multiple = !0)), D.addEventListener("resetform", (Pt) => {
+ const zt = this.data.defaultFieldValue;
+ for (const Mt of D.options)
+ Mt.selected = Mt.value === zt;
+ });
+ for (const Pt of this.data.options) {
+ const zt = document.createElement("option");
+ zt.textContent = Pt.displayValue, zt.value = Pt.exportValue, f.value.includes(Pt.exportValue) && (zt.setAttribute("selected", !0), j = !1), D.append(zt);
+ }
+ let q = null;
+ if (j) {
+ const Pt = document.createElement("option");
+ Pt.value = " ", Pt.setAttribute("hidden", !0), Pt.setAttribute("selected", !0), D.prepend(Pt), q = () => {
+ Pt.remove(), D.removeEventListener("input", q), q = null;
+ }, D.addEventListener("input", q);
+ }
+ const it = (Pt) => {
+ const zt = Pt ? "value" : "textContent", {
+ options: Mt,
+ multiple: Rt
+ } = D;
+ return Rt ? Array.prototype.filter.call(Mt, (Ut) => Ut.selected).map((Ut) => Ut[zt]) : Mt.selectedIndex === -1 ? null : Mt[Mt.selectedIndex][zt];
+ };
+ let mt = it(!1);
+ const kt = (Pt) => {
+ const zt = Pt.target.options;
+ return Array.prototype.map.call(zt, (Mt) => ({
+ displayValue: Mt.textContent,
+ exportValue: Mt.value
+ }));
+ };
+ return this.enableScripting && this.hasJSActions ? (D.addEventListener("updatefromsandbox", (Pt) => {
+ const zt = {
+ value(Mt) {
+ q == null || q();
+ const Rt = Mt.detail.value, Ut = new Set(Array.isArray(Rt) ? Rt : [Rt]);
+ for (const qt of D.options)
+ qt.selected = Ut.has(qt.value);
+ R.setValue(e, {
+ value: it(!0)
+ }), mt = it(!1);
+ },
+ multipleSelection(Mt) {
+ D.multiple = !0;
+ },
+ remove(Mt) {
+ const Rt = D.options, Ut = Mt.detail.remove;
+ Rt[Ut].selected = !1, D.remove(Ut), Rt.length > 0 && Array.prototype.findIndex.call(Rt, (Kt) => Kt.selected) === -1 && (Rt[0].selected = !0), R.setValue(e, {
+ value: it(!0),
+ items: kt(Mt)
+ }), mt = it(!1);
+ },
+ clear(Mt) {
+ for (; D.length !== 0; )
+ D.remove(0);
+ R.setValue(e, {
+ value: null,
+ items: []
+ }), mt = it(!1);
+ },
+ insert(Mt) {
+ const {
+ index: Rt,
+ displayValue: Ut,
+ exportValue: qt
+ } = Mt.detail.insert, Kt = D.children[Rt], Qt = document.createElement("option");
+ Qt.textContent = Ut, Qt.value = qt, Kt ? Kt.before(Qt) : D.append(Qt), R.setValue(e, {
+ value: it(!0),
+ items: kt(Mt)
+ }), mt = it(!1);
+ },
+ items(Mt) {
+ const {
+ items: Rt
+ } = Mt.detail;
+ for (; D.length !== 0; )
+ D.remove(0);
+ for (const Ut of Rt) {
+ const {
+ displayValue: qt,
+ exportValue: Kt
+ } = Ut, Qt = document.createElement("option");
+ Qt.textContent = qt, Qt.value = Kt, D.append(Qt);
+ }
+ D.options.length > 0 && (D.options[0].selected = !0), R.setValue(e, {
+ value: it(!0),
+ items: kt(Mt)
+ }), mt = it(!1);
+ },
+ indices(Mt) {
+ const Rt = new Set(Mt.detail.indices);
+ for (const Ut of Mt.target.options)
+ Ut.selected = Rt.has(Ut.index);
+ R.setValue(e, {
+ value: it(!0)
+ }), mt = it(!1);
+ },
+ editable(Mt) {
+ Mt.target.disabled = !Mt.detail.editable;
+ }
+ };
+ this._dispatchEventFromSandbox(zt, Pt);
+ }), D.addEventListener("input", (Pt) => {
+ var Mt;
+ const zt = it(!0);
+ R.setValue(e, {
+ value: zt
+ }), Pt.preventDefault(), (Mt = this.linkService.eventBus) == null || Mt.dispatch("dispatcheventinsandbox", {
+ source: this,
+ detail: {
+ id: e,
+ name: "Keystroke",
+ value: mt,
+ changeEx: zt,
+ willCommit: !1,
+ commitKey: 1,
+ keyDown: !1
+ }
+ });
+ }), this._setEventListeners(D, null, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"], ["input", "Action"], ["input", "Validate"]], (Pt) => Pt.target.value)) : D.addEventListener("input", function(Pt) {
+ R.setValue(e, {
+ value: it(!0)
+ });
+ }), this.data.combo && this._setTextStyle(D), this._setBackgroundColor(D), this._setDefaultPropertiesFromJS(D), this.container.append(D), this.container;
+ }
+ }
+ class p extends v {
+ constructor(R) {
+ const {
+ data: e,
+ elements: f
+ } = R;
+ super(R, {
+ isRenderable: v._hasPopupData(e)
+ }), this.elements = f;
+ }
+ render() {
+ this.container.classList.add("popupAnnotation");
+ const R = new r({
+ container: this.container,
+ color: this.data.color,
+ titleObj: this.data.titleObj,
+ modificationDate: this.data.modificationDate,
+ contentsObj: this.data.contentsObj,
+ richText: this.data.richText,
+ rect: this.data.rect,
+ parentRect: this.data.parentRect || null,
+ parent: this.parent,
+ elements: this.elements,
+ open: this.data.open
+ }), e = [];
+ for (const f of this.elements)
+ f.popup = R, e.push(f.data.id), f.addHighlightArea();
+ return this.container.setAttribute("aria-controls", e.map((f) => `${l.AnnotationPrefix}${f}`).join(",")), this.container;
+ }
+ }
+ class r {
+ constructor({
+ container: R,
+ color: e,
+ elements: f,
+ titleObj: D,
+ modificationDate: j,
+ contentsObj: q,
+ richText: it,
+ parent: mt,
+ rect: kt,
+ parentRect: Pt,
+ open: zt
+ }) {
+ L(this, jt);
+ L(this, Ht);
+ L(this, Vt);
+ L(this, $t);
+ L(this, N, null);
+ L(this, tt, W(this, jt, Li).bind(this));
+ L(this, Q, W(this, $t, oi).bind(this));
+ L(this, nt, W(this, Vt, ai).bind(this));
+ L(this, ct, W(this, Ht, Fe).bind(this));
+ L(this, yt, null);
+ L(this, ut, null);
+ L(this, Ft, null);
+ L(this, Bt, null);
+ L(this, St, null);
+ L(this, Dt, null);
+ L(this, ft, !1);
+ L(this, K, null);
+ L(this, J, null);
+ L(this, ht, null);
+ L(this, Et, null);
+ L(this, Ct, !1);
+ var Rt;
+ Z(this, ut, R), Z(this, Et, D), Z(this, Ft, q), Z(this, ht, it), Z(this, St, mt), Z(this, yt, e), Z(this, J, kt), Z(this, Dt, Pt), Z(this, Bt, f);
+ const Mt = P.PDFDateString.toDateObject(j);
+ Mt && Z(this, N, mt.l10n.get("annotation_date_string", {
+ date: Mt.toLocaleDateString(),
+ time: Mt.toLocaleTimeString()
+ })), this.trigger = f.flatMap((Ut) => Ut.getElementsToTriggerPopup());
+ for (const Ut of this.trigger)
+ Ut.addEventListener("click", t(this, ct)), Ut.addEventListener("mouseenter", t(this, nt)), Ut.addEventListener("mouseleave", t(this, Q)), Ut.classList.add("popupTriggerArea");
+ for (const Ut of f)
+ (Rt = Ut.container) == null || Rt.addEventListener("keydown", t(this, tt));
+ t(this, ut).hidden = !0, zt && W(this, Ht, Fe).call(this);
+ }
+ render() {
+ if (t(this, K))
+ return;
+ const {
+ page: {
+ view: R
+ },
+ viewport: {
+ rawDims: {
+ pageWidth: e,
+ pageHeight: f,
+ pageX: D,
+ pageY: j
+ }
+ }
+ } = t(this, St), q = Z(this, K, document.createElement("div"));
+ if (q.className = "popup", t(this, yt)) {
+ const ie = q.style.outlineColor = l.Util.makeHexColor(...t(this, yt));
+ CSS.supports("background-color", "color-mix(in srgb, red 30%, white)") ? q.style.backgroundColor = `color-mix(in srgb, ${ie} 30%, white)` : q.style.backgroundColor = l.Util.makeHexColor(...t(this, yt).map((oe) => Math.floor(0.7 * (255 - oe) + oe)));
+ }
+ const it = document.createElement("span");
+ it.className = "header";
+ const mt = document.createElement("h1");
+ if (it.append(mt), {
+ dir: mt.dir,
+ str: mt.textContent
+ } = t(this, Et), q.append(it), t(this, N)) {
+ const ie = document.createElement("span");
+ ie.classList.add("popupDate"), t(this, N).then((ne) => {
+ ie.textContent = ne;
+ }), it.append(ie);
+ }
+ const kt = t(this, Ft), Pt = t(this, ht);
+ if (Pt != null && Pt.str && (!(kt != null && kt.str) || kt.str === Pt.str))
+ B.XfaLayer.render({
+ xfaHtml: Pt.html,
+ intent: "richText",
+ div: q
+ }), q.lastChild.classList.add("richText", "popupContent");
+ else {
+ const ie = this._formatContents(kt);
+ q.append(ie);
+ }
+ let zt = !!t(this, Dt), Mt = zt ? t(this, Dt) : t(this, J);
+ for (const ie of t(this, Bt))
+ if (!Mt || l.Util.intersect(ie.data.rect, Mt) !== null) {
+ Mt = ie.data.rect, zt = !0;
+ break;
+ }
+ const Rt = l.Util.normalizeRect([Mt[0], R[3] - Mt[1] + R[1], Mt[2], R[3] - Mt[3] + R[1]]), Ut = 5, qt = zt ? Mt[2] - Mt[0] + Ut : 0, Kt = Rt[0] + qt, Qt = Rt[1], {
+ style: se
+ } = t(this, ut);
+ se.left = `${100 * (Kt - D) / e}%`, se.top = `${100 * (Qt - j) / f}%`, t(this, ut).append(q);
+ }
+ _formatContents({
+ str: R,
+ dir: e
+ }) {
+ const f = document.createElement("p");
+ f.classList.add("popupContent"), f.dir = e;
+ const D = R.split(/(?:\r\n?|\n)/);
+ for (let j = 0, q = D.length; j < q; ++j) {
+ const it = D[j];
+ f.append(document.createTextNode(it)), j < q - 1 && f.append(document.createElement("br"));
+ }
+ return f;
+ }
+ forceHide() {
+ Z(this, Ct, this.isVisible), t(this, Ct) && (t(this, ut).hidden = !0);
+ }
+ maybeShow() {
+ t(this, Ct) && (Z(this, Ct, !1), t(this, ut).hidden = !1);
+ }
+ get isVisible() {
+ return t(this, ut).hidden === !1;
+ }
+ }
+ N = new WeakMap(), tt = new WeakMap(), Q = new WeakMap(), nt = new WeakMap(), ct = new WeakMap(), yt = new WeakMap(), ut = new WeakMap(), Ft = new WeakMap(), Bt = new WeakMap(), St = new WeakMap(), Dt = new WeakMap(), ft = new WeakMap(), K = new WeakMap(), J = new WeakMap(), ht = new WeakMap(), Et = new WeakMap(), Ct = new WeakMap(), jt = new WeakSet(), Li = function(R) {
+ R.altKey || R.shiftKey || R.ctrlKey || R.metaKey || (R.key === "Enter" || R.key === "Escape" && t(this, ft)) && W(this, Ht, Fe).call(this);
+ }, Ht = new WeakSet(), Fe = function() {
+ Z(this, ft, !t(this, ft)), t(this, ft) ? (W(this, Vt, ai).call(this), t(this, ut).addEventListener("click", t(this, ct)), t(this, ut).addEventListener("keydown", t(this, tt))) : (W(this, $t, oi).call(this), t(this, ut).removeEventListener("click", t(this, ct)), t(this, ut).removeEventListener("keydown", t(this, tt)));
+ }, Vt = new WeakSet(), ai = function() {
+ t(this, K) || this.render(), this.isVisible ? t(this, ft) && t(this, ut).classList.add("focused") : (t(this, ut).hidden = !1, t(this, ut).style.zIndex = parseInt(t(this, ut).style.zIndex) + 1e3);
+ }, $t = new WeakSet(), oi = function() {
+ t(this, ut).classList.remove("focused"), !(t(this, ft) || !this.isVisible) && (t(this, ut).hidden = !0, t(this, ut).style.zIndex = parseInt(t(this, ut).style.zIndex) - 1e3);
+ };
+ class T extends v {
+ constructor(R) {
+ super(R, {
+ isRenderable: !0,
+ ignoreBorder: !0
+ }), this.textContent = R.data.textContent, this.textPosition = R.data.textPosition, this.annotationEditorType = l.AnnotationEditorType.FREETEXT;
+ }
+ render() {
+ if (this.container.classList.add("freeTextAnnotation"), this.textContent) {
+ const R = document.createElement("div");
+ R.classList.add("annotationTextContent"), R.setAttribute("role", "comment");
+ for (const e of this.textContent) {
+ const f = document.createElement("span");
+ f.textContent = e, R.append(f);
+ }
+ this.container.append(R);
+ }
+ return !this.data.popupRef && this.hasPopupData && this._createPopup(), this._editOnDoubleClick(), this.container;
+ }
+ }
+ d.FreeTextAnnotationElement = T;
+ class m extends v {
+ constructor(e) {
+ super(e, {
+ isRenderable: !0,
+ ignoreBorder: !0
+ });
+ L(this, Y, null);
+ }
+ render() {
+ this.container.classList.add("lineAnnotation");
+ const e = this.data, {
+ width: f,
+ height: D
+ } = I(e.rect), j = this.svgFactory.create(f, D, !0), q = Z(this, Y, this.svgFactory.createElement("svg:line"));
+ return q.setAttribute("x1", e.rect[2] - e.lineCoordinates[0]), q.setAttribute("y1", e.rect[3] - e.lineCoordinates[1]), q.setAttribute("x2", e.rect[2] - e.lineCoordinates[2]), q.setAttribute("y2", e.rect[3] - e.lineCoordinates[3]), q.setAttribute("stroke-width", e.borderStyle.width || 1), q.setAttribute("stroke", "transparent"), q.setAttribute("fill", "transparent"), j.append(q), this.container.append(j), !e.popupRef && this.hasPopupData && this._createPopup(), this.container;
+ }
+ getElementsToTriggerPopup() {
+ return t(this, Y);
+ }
+ addHighlightArea() {
+ this.container.classList.add("highlightArea");
+ }
+ }
+ Y = new WeakMap();
+ class U extends v {
+ constructor(e) {
+ super(e, {
+ isRenderable: !0,
+ ignoreBorder: !0
+ });
+ L(this, G, null);
+ }
+ render() {
+ this.container.classList.add("squareAnnotation");
+ const e = this.data, {
+ width: f,
+ height: D
+ } = I(e.rect), j = this.svgFactory.create(f, D, !0), q = e.borderStyle.width, it = Z(this, G, this.svgFactory.createElement("svg:rect"));
+ return it.setAttribute("x", q / 2), it.setAttribute("y", q / 2), it.setAttribute("width", f - q), it.setAttribute("height", D - q), it.setAttribute("stroke-width", q || 1), it.setAttribute("stroke", "transparent"), it.setAttribute("fill", "transparent"), j.append(it), this.container.append(j), !e.popupRef && this.hasPopupData && this._createPopup(), this.container;
+ }
+ getElementsToTriggerPopup() {
+ return t(this, G);
+ }
+ addHighlightArea() {
+ this.container.classList.add("highlightArea");
+ }
+ }
+ G = new WeakMap();
+ class z extends v {
+ constructor(e) {
+ super(e, {
+ isRenderable: !0,
+ ignoreBorder: !0
+ });
+ L(this, bt, null);
+ }
+ render() {
+ this.container.classList.add("circleAnnotation");
+ const e = this.data, {
+ width: f,
+ height: D
+ } = I(e.rect), j = this.svgFactory.create(f, D, !0), q = e.borderStyle.width, it = Z(this, bt, this.svgFactory.createElement("svg:ellipse"));
+ return it.setAttribute("cx", f / 2), it.setAttribute("cy", D / 2), it.setAttribute("rx", f / 2 - q / 2), it.setAttribute("ry", D / 2 - q / 2), it.setAttribute("stroke-width", q || 1), it.setAttribute("stroke", "transparent"), it.setAttribute("fill", "transparent"), j.append(it), this.container.append(j), !e.popupRef && this.hasPopupData && this._createPopup(), this.container;
+ }
+ getElementsToTriggerPopup() {
+ return t(this, bt);
+ }
+ addHighlightArea() {
+ this.container.classList.add("highlightArea");
+ }
+ }
+ bt = new WeakMap();
+ class E extends v {
+ constructor(e) {
+ super(e, {
+ isRenderable: !0,
+ ignoreBorder: !0
+ });
+ L(this, At, null);
+ this.containerClassName = "polylineAnnotation", this.svgElementName = "svg:polyline";
+ }
+ render() {
+ this.container.classList.add(this.containerClassName);
+ const e = this.data, {
+ width: f,
+ height: D
+ } = I(e.rect), j = this.svgFactory.create(f, D, !0);
+ let q = [];
+ for (const mt of e.vertices) {
+ const kt = mt.x - e.rect[0], Pt = e.rect[3] - mt.y;
+ q.push(kt + "," + Pt);
+ }
+ q = q.join(" ");
+ const it = Z(this, At, this.svgFactory.createElement(this.svgElementName));
+ return it.setAttribute("points", q), it.setAttribute("stroke-width", e.borderStyle.width || 1), it.setAttribute("stroke", "transparent"), it.setAttribute("fill", "transparent"), j.append(it), this.container.append(j), !e.popupRef && this.hasPopupData && this._createPopup(), this.container;
+ }
+ getElementsToTriggerPopup() {
+ return t(this, At);
+ }
+ addHighlightArea() {
+ this.container.classList.add("highlightArea");
+ }
+ }
+ At = new WeakMap();
+ class V extends E {
+ constructor(R) {
+ super(R), this.containerClassName = "polygonAnnotation", this.svgElementName = "svg:polygon";
+ }
+ }
+ class st extends v {
+ constructor(R) {
+ super(R, {
+ isRenderable: !0,
+ ignoreBorder: !0
+ });
+ }
+ render() {
+ return this.container.classList.add("caretAnnotation"), !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container;
+ }
+ }
+ class at extends v {
+ constructor(e) {
+ super(e, {
+ isRenderable: !0,
+ ignoreBorder: !0
+ });
+ L(this, te, []);
+ this.containerClassName = "inkAnnotation", this.svgElementName = "svg:polyline", this.annotationEditorType = l.AnnotationEditorType.INK;
+ }
+ render() {
+ this.container.classList.add(this.containerClassName);
+ const e = this.data, {
+ width: f,
+ height: D
+ } = I(e.rect), j = this.svgFactory.create(f, D, !0);
+ for (const q of e.inkLists) {
+ let it = [];
+ for (const kt of q) {
+ const Pt = kt.x - e.rect[0], zt = e.rect[3] - kt.y;
+ it.push(`${Pt},${zt}`);
+ }
+ it = it.join(" ");
+ const mt = this.svgFactory.createElement(this.svgElementName);
+ t(this, te).push(mt), mt.setAttribute("points", it), mt.setAttribute("stroke-width", e.borderStyle.width || 1), mt.setAttribute("stroke", "transparent"), mt.setAttribute("fill", "transparent"), !e.popupRef && this.hasPopupData && this._createPopup(), j.append(mt);
+ }
+ return this.container.append(j), this.container;
+ }
+ getElementsToTriggerPopup() {
+ return t(this, te);
+ }
+ addHighlightArea() {
+ this.container.classList.add("highlightArea");
+ }
+ }
+ te = new WeakMap(), d.InkAnnotationElement = at;
+ class H extends v {
+ constructor(R) {
+ super(R, {
+ isRenderable: !0,
+ ignoreBorder: !0,
+ createQuadrilaterals: !0
+ });
+ }
+ render() {
+ return !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.classList.add("highlightAnnotation"), this.container;
+ }
+ }
+ class lt extends v {
+ constructor(R) {
+ super(R, {
+ isRenderable: !0,
+ ignoreBorder: !0,
+ createQuadrilaterals: !0
+ });
+ }
+ render() {
+ return !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.classList.add("underlineAnnotation"), this.container;
+ }
+ }
+ class gt extends v {
+ constructor(R) {
+ super(R, {
+ isRenderable: !0,
+ ignoreBorder: !0,
+ createQuadrilaterals: !0
+ });
+ }
+ render() {
+ return !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.classList.add("squigglyAnnotation"), this.container;
+ }
+ }
+ class wt extends v {
+ constructor(R) {
+ super(R, {
+ isRenderable: !0,
+ ignoreBorder: !0,
+ createQuadrilaterals: !0
+ });
+ }
+ render() {
+ return !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.classList.add("strikeoutAnnotation"), this.container;
+ }
+ }
+ class xt extends v {
+ constructor(R) {
+ super(R, {
+ isRenderable: !0,
+ ignoreBorder: !0
+ });
+ }
+ render() {
+ return this.container.classList.add("stampAnnotation"), !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container;
+ }
+ }
+ d.StampAnnotationElement = xt;
+ class S extends v {
+ constructor(e) {
+ var j;
+ super(e, {
+ isRenderable: !0
+ });
+ L(this, $);
+ L(this, Zt, null);
+ const {
+ filename: f,
+ content: D
+ } = this.data.file;
+ this.filename = (0, P.getFilenameFromUrl)(f, !0), this.content = D, (j = this.linkService.eventBus) == null || j.dispatch("fileattachmentannotation", {
+ source: this,
+ filename: f,
+ content: D
+ });
+ }
+ render() {
+ this.container.classList.add("fileAttachmentAnnotation");
+ const {
+ container: e,
+ data: f
+ } = this;
+ let D;
+ f.hasAppearance || f.fillAlpha === 0 ? D = document.createElement("div") : (D = document.createElement("img"), D.src = `${this.imageResourcesPath}annotation-${/paperclip/i.test(f.name) ? "paperclip" : "pushpin"}.svg`, f.fillAlpha && f.fillAlpha < 1 && (D.style = `filter: opacity(${Math.round(f.fillAlpha * 100)}%);`)), D.addEventListener("dblclick", W(this, $, li).bind(this)), Z(this, Zt, D);
+ const {
+ isMac: j
+ } = l.FeatureTest.platform;
+ return e.addEventListener("keydown", (q) => {
+ q.key === "Enter" && (j ? q.metaKey : q.ctrlKey) && W(this, $, li).call(this);
+ }), !f.popupRef && this.hasPopupData ? this._createPopup() : D.classList.add("popupTriggerArea"), e.append(D), e;
+ }
+ getElementsToTriggerPopup() {
+ return t(this, Zt);
+ }
+ addHighlightArea() {
+ this.container.classList.add("highlightArea");
+ }
+ }
+ Zt = new WeakMap(), $ = new WeakSet(), li = function() {
+ var e;
+ (e = this.downloadManager) == null || e.openOrDownloadData(this.container, this.content, this.filename);
+ };
+ class i {
+ constructor({
+ div: R,
+ accessibilityManager: e,
+ annotationCanvasMap: f,
+ l10n: D,
+ page: j,
+ viewport: q
+ }) {
+ L(this, Nt);
+ L(this, _t);
+ L(this, Lt, null);
+ L(this, Tt, null);
+ L(this, Ot, /* @__PURE__ */ new Map());
+ this.div = R, Z(this, Lt, e), Z(this, Tt, f), this.l10n = D, this.page = j, this.viewport = q, this.zIndex = 0, this.l10n || (this.l10n = pt.NullL10n);
+ }
+ async render(R) {
+ const {
+ annotations: e
+ } = R, f = this.div;
+ (0, P.setLayerDimensions)(f, this.viewport);
+ const D = /* @__PURE__ */ new Map(), j = {
+ data: null,
+ layer: f,
+ linkService: R.linkService,
+ downloadManager: R.downloadManager,
+ imageResourcesPath: R.imageResourcesPath || "",
+ renderForms: R.renderForms !== !1,
+ svgFactory: new P.DOMSVGFactory(),
+ annotationStorage: R.annotationStorage || new rt.AnnotationStorage(),
+ enableScripting: R.enableScripting === !0,
+ hasJSActions: R.hasJSActions,
+ fieldObjects: R.fieldObjects,
+ parent: this,
+ elements: null
+ };
+ for (const q of e) {
+ if (q.noHTML)
+ continue;
+ const it = q.annotationType === l.AnnotationType.POPUP;
+ if (it) {
+ const Pt = D.get(q.id);
+ if (!Pt)
+ continue;
+ j.elements = Pt;
+ } else {
+ const {
+ width: Pt,
+ height: zt
+ } = I(q.rect);
+ if (Pt <= 0 || zt <= 0)
+ continue;
+ }
+ j.data = q;
+ const mt = x.create(j);
+ if (!mt.isRenderable)
+ continue;
+ if (!it && q.popupRef) {
+ const Pt = D.get(q.popupRef);
+ Pt ? Pt.push(mt) : D.set(q.popupRef, [mt]);
+ }
+ mt.annotationEditorType > 0 && t(this, Ot).set(mt.data.id, mt);
+ const kt = mt.render();
+ q.hidden && (kt.style.visibility = "hidden"), W(this, Nt, Oi).call(this, kt, q.id);
+ }
+ W(this, _t, ci).call(this), await this.l10n.translate(f);
+ }
+ update({
+ viewport: R
+ }) {
+ const e = this.div;
+ this.viewport = R, (0, P.setLayerDimensions)(e, {
+ rotation: R.rotation
+ }), W(this, _t, ci).call(this), e.hidden = !1;
+ }
+ getEditableAnnotations() {
+ return Array.from(t(this, Ot).values());
+ }
+ getEditableAnnotation(R) {
+ return t(this, Ot).get(R);
+ }
+ }
+ Lt = new WeakMap(), Tt = new WeakMap(), Ot = new WeakMap(), Nt = new WeakSet(), Oi = function(R, e) {
+ var D;
+ const f = R.firstChild || R;
+ f.id = `${l.AnnotationPrefix}${e}`, this.div.append(R), (D = t(this, Lt)) == null || D.moveElementInDOM(this.div, R, f, !1);
+ }, _t = new WeakSet(), ci = function() {
+ if (!t(this, Tt))
+ return;
+ const R = this.div;
+ for (const [e, f] of t(this, Tt)) {
+ const D = R.querySelector(`[data-annotation-id="${e}"]`);
+ if (!D)
+ continue;
+ const {
+ firstChild: j
+ } = D;
+ j ? j.nodeName === "CANVAS" ? j.replaceWith(f) : j.before(f) : D.append(f);
+ }
+ t(this, Tt).clear();
+ }, d.AnnotationLayer = i;
+ },
+ /* 30 */
+ /***/
+ (dt, d) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.ColorConverters = void 0;
+ function et(rt) {
+ return Math.floor(Math.max(0, Math.min(1, rt)) * 255).toString(16).padStart(2, "0");
+ }
+ function l(rt) {
+ return Math.max(0, Math.min(255, 255 * rt));
+ }
+ class P {
+ static CMYK_G([X, pt, B, F]) {
+ return ["G", 1 - Math.min(1, 0.3 * X + 0.59 * B + 0.11 * pt + F)];
+ }
+ static G_CMYK([X]) {
+ return ["CMYK", 0, 0, 0, 1 - X];
+ }
+ static G_RGB([X]) {
+ return ["RGB", X, X, X];
+ }
+ static G_rgb([X]) {
+ return X = l(X), [X, X, X];
+ }
+ static G_HTML([X]) {
+ const pt = et(X);
+ return `#${pt}${pt}${pt}`;
+ }
+ static RGB_G([X, pt, B]) {
+ return ["G", 0.3 * X + 0.59 * pt + 0.11 * B];
+ }
+ static RGB_rgb(X) {
+ return X.map(l);
+ }
+ static RGB_HTML(X) {
+ return `#${X.map(et).join("")}`;
+ }
+ static T_HTML() {
+ return "#00000000";
+ }
+ static T_rgb() {
+ return [null];
+ }
+ static CMYK_RGB([X, pt, B, F]) {
+ return ["RGB", 1 - Math.min(1, X + F), 1 - Math.min(1, B + F), 1 - Math.min(1, pt + F)];
+ }
+ static CMYK_rgb([X, pt, B, F]) {
+ return [l(1 - Math.min(1, X + F)), l(1 - Math.min(1, B + F)), l(1 - Math.min(1, pt + F))];
+ }
+ static CMYK_HTML(X) {
+ const pt = this.CMYK_RGB(X).slice(1);
+ return this.RGB_HTML(pt);
+ }
+ static RGB_CMYK([X, pt, B]) {
+ const F = 1 - X, g = 1 - pt, O = 1 - B, I = Math.min(F, g, O);
+ return ["CMYK", F, g, O, I];
+ }
+ }
+ d.ColorConverters = P;
+ },
+ /* 31 */
+ /***/
+ (dt, d) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.NullL10n = void 0, d.getL10nFallback = l;
+ const et = {
+ of_pages: "of {{pagesCount}}",
+ page_of_pages: "({{pageNumber}} of {{pagesCount}})",
+ document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
+ document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
+ document_properties_date_string: "{{date}}, {{time}}",
+ document_properties_page_size_unit_inches: "in",
+ document_properties_page_size_unit_millimeters: "mm",
+ document_properties_page_size_orientation_portrait: "portrait",
+ document_properties_page_size_orientation_landscape: "landscape",
+ document_properties_page_size_name_a3: "A3",
+ document_properties_page_size_name_a4: "A4",
+ document_properties_page_size_name_letter: "Letter",
+ document_properties_page_size_name_legal: "Legal",
+ document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
+ document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
+ document_properties_linearized_yes: "Yes",
+ document_properties_linearized_no: "No",
+ additional_layers: "Additional Layers",
+ page_landmark: "Page {{page}}",
+ thumb_page_title: "Page {{page}}",
+ thumb_page_canvas: "Thumbnail of Page {{page}}",
+ find_reached_top: "Reached top of document, continued from bottom",
+ find_reached_bottom: "Reached end of document, continued from top",
+ "find_match_count[one]": "{{current}} of {{total}} match",
+ "find_match_count[other]": "{{current}} of {{total}} matches",
+ "find_match_count_limit[one]": "More than {{limit}} match",
+ "find_match_count_limit[other]": "More than {{limit}} matches",
+ find_not_found: "Phrase not found",
+ page_scale_width: "Page Width",
+ page_scale_fit: "Page Fit",
+ page_scale_auto: "Automatic Zoom",
+ page_scale_actual: "Actual Size",
+ page_scale_percent: "{{scale}}%",
+ loading_error: "An error occurred while loading the PDF.",
+ invalid_file_error: "Invalid or corrupted PDF file.",
+ missing_file_error: "Missing PDF file.",
+ unexpected_response_error: "Unexpected server response.",
+ rendering_error: "An error occurred while rendering the page.",
+ annotation_date_string: "{{date}}, {{time}}",
+ printing_not_supported: "Warning: Printing is not fully supported by this browser.",
+ printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
+ web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
+ free_text2_default_content: "Start typing…",
+ editor_free_text2_aria_label: "Text Editor",
+ editor_ink2_aria_label: "Draw Editor",
+ editor_ink_canvas_aria_label: "User-created image",
+ editor_alt_text_button_label: "Alt text",
+ editor_alt_text_edit_button_label: "Edit alt text",
+ editor_alt_text_decorative_tooltip: "Marked as decorative"
+ };
+ et.print_progress_percent = "{{progress}}%";
+ function l(X, pt) {
+ switch (X) {
+ case "find_match_count":
+ X = `find_match_count[${pt.total === 1 ? "one" : "other"}]`;
+ break;
+ case "find_match_count_limit":
+ X = `find_match_count_limit[${pt.limit === 1 ? "one" : "other"}]`;
+ break;
+ }
+ return et[X] || "";
+ }
+ function P(X, pt) {
+ return pt ? X.replaceAll(/\{\{\s*(\w+)\s*\}\}/g, (B, F) => F in pt ? pt[F] : "{{" + F + "}}") : X;
+ }
+ const rt = {
+ async getLanguage() {
+ return "en-us";
+ },
+ async getDirection() {
+ return "ltr";
+ },
+ async get(X, pt = null, B = l(X, pt)) {
+ return P(B, pt);
+ },
+ async translate(X) {
+ }
+ };
+ d.NullL10n = rt;
+ },
+ /* 32 */
+ /***/
+ (dt, d, et) => {
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.XfaLayer = void 0;
+ var l = et(25);
+ class P {
+ static setupStorage(X, pt, B, F, g) {
+ const O = F.getValue(pt, {
+ value: null
+ });
+ switch (B.name) {
+ case "textarea":
+ if (O.value !== null && (X.textContent = O.value), g === "print")
+ break;
+ X.addEventListener("input", (I) => {
+ F.setValue(pt, {
+ value: I.target.value
+ });
+ });
+ break;
+ case "input":
+ if (B.attributes.type === "radio" || B.attributes.type === "checkbox") {
+ if (O.value === B.attributes.xfaOn ? X.setAttribute("checked", !0) : O.value === B.attributes.xfaOff && X.removeAttribute("checked"), g === "print")
+ break;
+ X.addEventListener("change", (I) => {
+ F.setValue(pt, {
+ value: I.target.checked ? I.target.getAttribute("xfaOn") : I.target.getAttribute("xfaOff")
+ });
+ });
+ } else {
+ if (O.value !== null && X.setAttribute("value", O.value), g === "print")
+ break;
+ X.addEventListener("input", (I) => {
+ F.setValue(pt, {
+ value: I.target.value
+ });
+ });
+ }
+ break;
+ case "select":
+ if (O.value !== null) {
+ X.setAttribute("value", O.value);
+ for (const I of B.children)
+ I.attributes.value === O.value ? I.attributes.selected = !0 : I.attributes.hasOwnProperty("selected") && delete I.attributes.selected;
+ }
+ X.addEventListener("input", (I) => {
+ const x = I.target.options, v = x.selectedIndex === -1 ? "" : x[x.selectedIndex].value;
+ F.setValue(pt, {
+ value: v
+ });
+ });
+ break;
+ }
+ }
+ static setAttributes({
+ html: X,
+ element: pt,
+ storage: B = null,
+ intent: F,
+ linkService: g
+ }) {
+ const {
+ attributes: O
+ } = pt, I = X instanceof HTMLAnchorElement;
+ O.type === "radio" && (O.name = `${O.name}-${F}`);
+ for (const [x, v] of Object.entries(O))
+ if (v != null)
+ switch (x) {
+ case "class":
+ v.length && X.setAttribute(x, v.join(" "));
+ break;
+ case "dataId":
+ break;
+ case "id":
+ X.setAttribute("data-element-id", v);
+ break;
+ case "style":
+ Object.assign(X.style, v);
+ break;
+ case "textContent":
+ X.textContent = v;
+ break;
+ default:
+ (!I || x !== "href" && x !== "newWindow") && X.setAttribute(x, v);
+ }
+ I && g.addLinkAttributes(X, O.href, O.newWindow), B && O.dataId && this.setupStorage(X, O.dataId, pt, B);
+ }
+ static render(X) {
+ var A;
+ const pt = X.annotationStorage, B = X.linkService, F = X.xfaHtml, g = X.intent || "display", O = document.createElement(F.name);
+ F.attributes && this.setAttributes({
+ html: O,
+ element: F,
+ intent: g,
+ linkService: B
+ });
+ const I = [[F, -1, O]], x = X.div;
+ if (x.append(O), X.viewport) {
+ const u = `matrix(${X.viewport.transform.join(",")})`;
+ x.style.transform = u;
+ }
+ g !== "richText" && x.setAttribute("class", "xfaLayer xfaFont");
+ const v = [];
+ for (; I.length > 0; ) {
+ const [u, _, w] = I.at(-1);
+ if (_ + 1 === u.children.length) {
+ I.pop();
+ continue;
+ }
+ const C = u.children[++I.at(-1)[1]];
+ if (C === null)
+ continue;
+ const {
+ name: y
+ } = C;
+ if (y === "#text") {
+ const c = document.createTextNode(C.value);
+ v.push(c), w.append(c);
+ continue;
+ }
+ const a = (A = C == null ? void 0 : C.attributes) != null && A.xmlns ? document.createElementNS(C.attributes.xmlns, y) : document.createElement(y);
+ if (w.append(a), C.attributes && this.setAttributes({
+ html: a,
+ element: C,
+ storage: pt,
+ intent: g,
+ linkService: B
+ }), C.children && C.children.length > 0)
+ I.push([C, -1, a]);
+ else if (C.value) {
+ const c = document.createTextNode(C.value);
+ l.XfaText.shouldBuildText(y) && v.push(c), a.append(c);
+ }
+ }
+ for (const u of x.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))
+ u.setAttribute("readOnly", !0);
+ return {
+ textDivs: v
+ };
+ }
+ static update(X) {
+ const pt = `matrix(${X.viewport.transform.join(",")})`;
+ X.div.style.transform = pt, X.div.hidden = !1;
+ }
+ }
+ d.XfaLayer = P;
+ },
+ /* 33 */
+ /***/
+ (dt, d, et) => {
+ var F, g, O, I, x, v, A, u, _, w, C, y, a, c, k, Ni, r, Bi, m, Ui, z, ji, V, hi, at, Hi, lt, di, wt, Wi, S, Gi, n, zi, o, Xi, b, Vi, N, ae, Q, ui, ct, Me, ut, Re, Bt, fe, Dt, fi, K, De, ht, qi, Ct, pi, Gt, $i, Xt, Yi, Wt, gi, ot, Ie, G, pe;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.InkEditor = void 0;
+ var l = et(1), P = et(4), rt = et(29), X = et(6), pt = et(5);
+ const At = class At extends P.AnnotationEditor {
+ constructor($) {
+ super({
+ ...$,
+ name: "inkEditor"
+ });
+ L(this, k);
+ L(this, r);
+ L(this, m);
+ L(this, z);
+ L(this, V);
+ L(this, at);
+ L(this, lt);
+ L(this, wt);
+ L(this, S);
+ L(this, n);
+ L(this, o);
+ L(this, b);
+ L(this, N);
+ L(this, Q);
+ L(this, ct);
+ L(this, ut);
+ L(this, Bt);
+ L(this, Dt);
+ L(this, K);
+ L(this, Xt);
+ L(this, Wt);
+ L(this, ot);
+ L(this, G);
+ L(this, F, 0);
+ L(this, g, 0);
+ L(this, O, this.canvasPointermove.bind(this));
+ L(this, I, this.canvasPointerleave.bind(this));
+ L(this, x, this.canvasPointerup.bind(this));
+ L(this, v, this.canvasPointerdown.bind(this));
+ L(this, A, new Path2D());
+ L(this, u, !1);
+ L(this, _, !1);
+ L(this, w, !1);
+ L(this, C, null);
+ L(this, y, 0);
+ L(this, a, 0);
+ L(this, c, null);
+ this.color = $.color || null, this.thickness = $.thickness || null, this.opacity = $.opacity || null, this.paths = [], this.bezierPath2D = [], this.allRawPaths = [], this.currentPath = [], this.scaleFactor = 1, this.translationX = this.translationY = 0, this.x = 0, this.y = 0, this._willKeepAspectRatio = !0;
+ }
+ static initialize($) {
+ P.AnnotationEditor.initialize($, {
+ strings: ["editor_ink_canvas_aria_label", "editor_ink2_aria_label"]
+ });
+ }
+ static updateDefaultParams($, vt) {
+ switch ($) {
+ case l.AnnotationEditorParamsType.INK_THICKNESS:
+ At._defaultThickness = vt;
+ break;
+ case l.AnnotationEditorParamsType.INK_COLOR:
+ At._defaultColor = vt;
+ break;
+ case l.AnnotationEditorParamsType.INK_OPACITY:
+ At._defaultOpacity = vt / 100;
+ break;
+ }
+ }
+ updateParams($, vt) {
+ switch ($) {
+ case l.AnnotationEditorParamsType.INK_THICKNESS:
+ W(this, k, Ni).call(this, vt);
+ break;
+ case l.AnnotationEditorParamsType.INK_COLOR:
+ W(this, r, Bi).call(this, vt);
+ break;
+ case l.AnnotationEditorParamsType.INK_OPACITY:
+ W(this, m, Ui).call(this, vt);
+ break;
+ }
+ }
+ static get defaultPropertiesToUpdate() {
+ return [[l.AnnotationEditorParamsType.INK_THICKNESS, At._defaultThickness], [l.AnnotationEditorParamsType.INK_COLOR, At._defaultColor || P.AnnotationEditor._defaultLineColor], [l.AnnotationEditorParamsType.INK_OPACITY, Math.round(At._defaultOpacity * 100)]];
+ }
+ get propertiesToUpdate() {
+ return [[l.AnnotationEditorParamsType.INK_THICKNESS, this.thickness || At._defaultThickness], [l.AnnotationEditorParamsType.INK_COLOR, this.color || At._defaultColor || P.AnnotationEditor._defaultLineColor], [l.AnnotationEditorParamsType.INK_OPACITY, Math.round(100 * (this.opacity ?? At._defaultOpacity))]];
+ }
+ rebuild() {
+ this.parent && (super.rebuild(), this.div !== null && (this.canvas || (W(this, ct, Me).call(this), W(this, ut, Re).call(this)), this.isAttachedToDOM || (this.parent.add(this), W(this, Bt, fe).call(this)), W(this, G, pe).call(this)));
+ }
+ remove() {
+ this.canvas !== null && (this.isEmpty() || this.commit(), this.canvas.width = this.canvas.height = 0, this.canvas.remove(), this.canvas = null, t(this, C).disconnect(), Z(this, C, null), super.remove());
+ }
+ setParent($) {
+ !this.parent && $ ? this._uiManager.removeShouldRescale(this) : this.parent && $ === null && this._uiManager.addShouldRescale(this), super.setParent($);
+ }
+ onScaleChanging() {
+ const [$, vt] = this.parentDimensions, Lt = this.width * $, Tt = this.height * vt;
+ this.setDimensions(Lt, Tt);
+ }
+ enableEditMode() {
+ t(this, u) || this.canvas === null || (super.enableEditMode(), this._isDraggable = !1, this.canvas.addEventListener("pointerdown", t(this, v)));
+ }
+ disableEditMode() {
+ !this.isInEditMode() || this.canvas === null || (super.disableEditMode(), this._isDraggable = !this.isEmpty(), this.div.classList.remove("editing"), this.canvas.removeEventListener("pointerdown", t(this, v)));
+ }
+ onceAdded() {
+ this._isDraggable = !this.isEmpty();
+ }
+ isEmpty() {
+ return this.paths.length === 0 || this.paths.length === 1 && this.paths[0].length === 0;
+ }
+ commit() {
+ t(this, u) || (super.commit(), this.isEditing = !1, this.disableEditMode(), this.setInForeground(), Z(this, u, !0), this.div.classList.add("disabled"), W(this, G, pe).call(this, !0), this.makeResizable(), this.parent.addInkEditorIfNeeded(!0), this.moveInDOM(), this.div.focus({
+ preventScroll: !0
+ }));
+ }
+ focusin($) {
+ this._focusEventsAllowed && (super.focusin($), this.enableEditMode());
+ }
+ canvasPointerdown($) {
+ $.button !== 0 || !this.isInEditMode() || t(this, u) || (this.setInForeground(), $.preventDefault(), $.type !== "mouse" && this.div.focus(), W(this, at, Hi).call(this, $.offsetX, $.offsetY));
+ }
+ canvasPointermove($) {
+ $.preventDefault(), W(this, lt, di).call(this, $.offsetX, $.offsetY);
+ }
+ canvasPointerup($) {
+ $.preventDefault(), W(this, Q, ui).call(this, $);
+ }
+ canvasPointerleave($) {
+ W(this, Q, ui).call(this, $);
+ }
+ get isResizable() {
+ return !this.isEmpty() && t(this, u);
+ }
+ render() {
+ if (this.div)
+ return this.div;
+ let $, vt;
+ this.width && ($ = this.x, vt = this.y), super.render(), P.AnnotationEditor._l10nPromise.get("editor_ink2_aria_label").then((Jt) => {
+ var _t;
+ return (_t = this.div) == null ? void 0 : _t.setAttribute("aria-label", Jt);
+ });
+ const [Lt, Tt, Ot, Nt] = W(this, z, ji).call(this);
+ if (this.setAt(Lt, Tt, 0, 0), this.setDims(Ot, Nt), W(this, ct, Me).call(this), this.width) {
+ const [Jt, _t] = this.parentDimensions;
+ this.setAspectRatio(this.width * Jt, this.height * _t), this.setAt($ * Jt, vt * _t, this.width * Jt, this.height * _t), Z(this, w, !0), W(this, Bt, fe).call(this), this.setDims(this.width * Jt, this.height * _t), W(this, N, ae).call(this), this.div.classList.add("disabled");
+ } else
+ this.div.classList.add("editing"), this.enableEditMode();
+ return W(this, ut, Re).call(this), this.div;
+ }
+ setDimensions($, vt) {
+ const Lt = Math.round($), Tt = Math.round(vt);
+ if (t(this, y) === Lt && t(this, a) === Tt)
+ return;
+ Z(this, y, Lt), Z(this, a, Tt), this.canvas.style.visibility = "hidden";
+ const [Ot, Nt] = this.parentDimensions;
+ this.width = $ / Ot, this.height = vt / Nt, this.fixAndSetPosition(), t(this, u) && W(this, Dt, fi).call(this, $, vt), W(this, Bt, fe).call(this), W(this, N, ae).call(this), this.canvas.style.visibility = "visible", this.fixDims();
+ }
+ static deserialize($, vt, Lt) {
+ var j, q, it;
+ if ($ instanceof rt.InkAnnotationElement)
+ return null;
+ const Tt = super.deserialize($, vt, Lt);
+ Tt.thickness = $.thickness, Tt.color = l.Util.makeHexColor(...$.color), Tt.opacity = $.opacity;
+ const [Ot, Nt] = Tt.pageDimensions, Jt = Tt.width * Ot, _t = Tt.height * Nt, Yt = Tt.parentScale, It = $.thickness / 2;
+ Z(Tt, u, !0), Z(Tt, y, Math.round(Jt)), Z(Tt, a, Math.round(_t));
+ const {
+ paths: R,
+ rect: e,
+ rotation: f
+ } = $;
+ for (let {
+ bezier: mt
+ } of R) {
+ mt = W(j = At, Gt, $i).call(j, mt, e, f);
+ const kt = [];
+ Tt.paths.push(kt);
+ let Pt = Yt * (mt[0] - It), zt = Yt * (mt[1] - It);
+ for (let Rt = 2, Ut = mt.length; Rt < Ut; Rt += 6) {
+ const qt = Yt * (mt[Rt] - It), Kt = Yt * (mt[Rt + 1] - It), Qt = Yt * (mt[Rt + 2] - It), se = Yt * (mt[Rt + 3] - It), ie = Yt * (mt[Rt + 4] - It), ne = Yt * (mt[Rt + 5] - It);
+ kt.push([[Pt, zt], [qt, Kt], [Qt, se], [ie, ne]]), Pt = ie, zt = ne;
+ }
+ const Mt = W(this, ht, qi).call(this, kt);
+ Tt.bezierPath2D.push(Mt);
+ }
+ const D = W(q = Tt, Wt, gi).call(q);
+ return Z(Tt, g, Math.max(P.AnnotationEditor.MIN_SIZE, D[2] - D[0])), Z(Tt, F, Math.max(P.AnnotationEditor.MIN_SIZE, D[3] - D[1])), W(it = Tt, Dt, fi).call(it, Jt, _t), Tt;
+ }
+ serialize() {
+ if (this.isEmpty())
+ return null;
+ const $ = this.getRect(0, 0), vt = P.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);
+ return {
+ annotationType: l.AnnotationEditorType.INK,
+ color: vt,
+ thickness: this.thickness,
+ opacity: this.opacity,
+ paths: W(this, Xt, Yi).call(this, this.scaleFactor / this.parentScale, this.translationX, this.translationY, $),
+ pageIndex: this.pageIndex,
+ rect: $,
+ rotation: this.rotation,
+ structTreeParentId: this._structTreeParentId
+ };
+ }
+ };
+ F = new WeakMap(), g = new WeakMap(), O = new WeakMap(), I = new WeakMap(), x = new WeakMap(), v = new WeakMap(), A = new WeakMap(), u = new WeakMap(), _ = new WeakMap(), w = new WeakMap(), C = new WeakMap(), y = new WeakMap(), a = new WeakMap(), c = new WeakMap(), k = new WeakSet(), Ni = function($) {
+ const vt = this.thickness;
+ this.addCommands({
+ cmd: () => {
+ this.thickness = $, W(this, G, pe).call(this);
+ },
+ undo: () => {
+ this.thickness = vt, W(this, G, pe).call(this);
+ },
+ mustExec: !0,
+ type: l.AnnotationEditorParamsType.INK_THICKNESS,
+ overwriteIfSameType: !0,
+ keepUndo: !0
+ });
+ }, r = new WeakSet(), Bi = function($) {
+ const vt = this.color;
+ this.addCommands({
+ cmd: () => {
+ this.color = $, W(this, N, ae).call(this);
+ },
+ undo: () => {
+ this.color = vt, W(this, N, ae).call(this);
+ },
+ mustExec: !0,
+ type: l.AnnotationEditorParamsType.INK_COLOR,
+ overwriteIfSameType: !0,
+ keepUndo: !0
+ });
+ }, m = new WeakSet(), Ui = function($) {
+ $ /= 100;
+ const vt = this.opacity;
+ this.addCommands({
+ cmd: () => {
+ this.opacity = $, W(this, N, ae).call(this);
+ },
+ undo: () => {
+ this.opacity = vt, W(this, N, ae).call(this);
+ },
+ mustExec: !0,
+ type: l.AnnotationEditorParamsType.INK_OPACITY,
+ overwriteIfSameType: !0,
+ keepUndo: !0
+ });
+ }, z = new WeakSet(), ji = function() {
+ const {
+ parentRotation: $,
+ parentDimensions: [vt, Lt]
+ } = this;
+ switch ($) {
+ case 90:
+ return [0, Lt, Lt, vt];
+ case 180:
+ return [vt, Lt, vt, Lt];
+ case 270:
+ return [vt, 0, Lt, vt];
+ default:
+ return [0, 0, vt, Lt];
+ }
+ }, V = new WeakSet(), hi = function() {
+ const {
+ ctx: $,
+ color: vt,
+ opacity: Lt,
+ thickness: Tt,
+ parentScale: Ot,
+ scaleFactor: Nt
+ } = this;
+ $.lineWidth = Tt * Ot / Nt, $.lineCap = "round", $.lineJoin = "round", $.miterLimit = 10, $.strokeStyle = `${vt}${(0, pt.opacityToHex)(Lt)}`;
+ }, at = new WeakSet(), Hi = function($, vt) {
+ this.canvas.addEventListener("contextmenu", X.noContextMenu), this.canvas.addEventListener("pointerleave", t(this, I)), this.canvas.addEventListener("pointermove", t(this, O)), this.canvas.addEventListener("pointerup", t(this, x)), this.canvas.removeEventListener("pointerdown", t(this, v)), this.isEditing = !0, t(this, w) || (Z(this, w, !0), W(this, Bt, fe).call(this), this.thickness || (this.thickness = At._defaultThickness), this.color || (this.color = At._defaultColor || P.AnnotationEditor._defaultLineColor), this.opacity ?? (this.opacity = At._defaultOpacity)), this.currentPath.push([$, vt]), Z(this, _, !1), W(this, V, hi).call(this), Z(this, c, () => {
+ W(this, n, zi).call(this), t(this, c) && window.requestAnimationFrame(t(this, c));
+ }), window.requestAnimationFrame(t(this, c));
+ }, lt = new WeakSet(), di = function($, vt) {
+ const [Lt, Tt] = this.currentPath.at(-1);
+ if (this.currentPath.length > 1 && $ === Lt && vt === Tt)
+ return;
+ const Ot = this.currentPath;
+ let Nt = t(this, A);
+ if (Ot.push([$, vt]), Z(this, _, !0), Ot.length <= 2) {
+ Nt.moveTo(...Ot[0]), Nt.lineTo($, vt);
+ return;
+ }
+ Ot.length === 3 && (Z(this, A, Nt = new Path2D()), Nt.moveTo(...Ot[0])), W(this, o, Xi).call(this, Nt, ...Ot.at(-3), ...Ot.at(-2), $, vt);
+ }, wt = new WeakSet(), Wi = function() {
+ if (this.currentPath.length === 0)
+ return;
+ const $ = this.currentPath.at(-1);
+ t(this, A).lineTo(...$);
+ }, S = new WeakSet(), Gi = function($, vt) {
+ Z(this, c, null), $ = Math.min(Math.max($, 0), this.canvas.width), vt = Math.min(Math.max(vt, 0), this.canvas.height), W(this, lt, di).call(this, $, vt), W(this, wt, Wi).call(this);
+ let Lt;
+ if (this.currentPath.length !== 1)
+ Lt = W(this, b, Vi).call(this);
+ else {
+ const _t = [$, vt];
+ Lt = [[_t, _t.slice(), _t.slice(), _t]];
+ }
+ const Tt = t(this, A), Ot = this.currentPath;
+ this.currentPath = [], Z(this, A, new Path2D());
+ const Nt = () => {
+ this.allRawPaths.push(Ot), this.paths.push(Lt), this.bezierPath2D.push(Tt), this.rebuild();
+ }, Jt = () => {
+ this.allRawPaths.pop(), this.paths.pop(), this.bezierPath2D.pop(), this.paths.length === 0 ? this.remove() : (this.canvas || (W(this, ct, Me).call(this), W(this, ut, Re).call(this)), W(this, G, pe).call(this));
+ };
+ this.addCommands({
+ cmd: Nt,
+ undo: Jt,
+ mustExec: !0
+ });
+ }, n = new WeakSet(), zi = function() {
+ if (!t(this, _))
+ return;
+ Z(this, _, !1);
+ const $ = Math.ceil(this.thickness * this.parentScale), vt = this.currentPath.slice(-3), Lt = vt.map((Nt) => Nt[0]), Tt = vt.map((Nt) => Nt[1]);
+ Math.min(...Lt) - $, Math.max(...Lt) + $, Math.min(...Tt) - $, Math.max(...Tt) + $;
+ const {
+ ctx: Ot
+ } = this;
+ Ot.save(), Ot.clearRect(0, 0, this.canvas.width, this.canvas.height);
+ for (const Nt of this.bezierPath2D)
+ Ot.stroke(Nt);
+ Ot.stroke(t(this, A)), Ot.restore();
+ }, o = new WeakSet(), Xi = function($, vt, Lt, Tt, Ot, Nt, Jt) {
+ const _t = (vt + Tt) / 2, Yt = (Lt + Ot) / 2, It = (Tt + Nt) / 2, R = (Ot + Jt) / 2;
+ $.bezierCurveTo(_t + 2 * (Tt - _t) / 3, Yt + 2 * (Ot - Yt) / 3, It + 2 * (Tt - It) / 3, R + 2 * (Ot - R) / 3, It, R);
+ }, b = new WeakSet(), Vi = function() {
+ const $ = this.currentPath;
+ if ($.length <= 2)
+ return [[$[0], $[0], $.at(-1), $.at(-1)]];
+ const vt = [];
+ let Lt, [Tt, Ot] = $[0];
+ for (Lt = 1; Lt < $.length - 2; Lt++) {
+ const [e, f] = $[Lt], [D, j] = $[Lt + 1], q = (e + D) / 2, it = (f + j) / 2, mt = [Tt + 2 * (e - Tt) / 3, Ot + 2 * (f - Ot) / 3], kt = [q + 2 * (e - q) / 3, it + 2 * (f - it) / 3];
+ vt.push([[Tt, Ot], mt, kt, [q, it]]), [Tt, Ot] = [q, it];
+ }
+ const [Nt, Jt] = $[Lt], [_t, Yt] = $[Lt + 1], It = [Tt + 2 * (Nt - Tt) / 3, Ot + 2 * (Jt - Ot) / 3], R = [_t + 2 * (Nt - _t) / 3, Yt + 2 * (Jt - Yt) / 3];
+ return vt.push([[Tt, Ot], It, R, [_t, Yt]]), vt;
+ }, N = new WeakSet(), ae = function() {
+ if (this.isEmpty()) {
+ W(this, K, De).call(this);
+ return;
+ }
+ W(this, V, hi).call(this);
+ const {
+ canvas: $,
+ ctx: vt
+ } = this;
+ vt.setTransform(1, 0, 0, 1, 0, 0), vt.clearRect(0, 0, $.width, $.height), W(this, K, De).call(this);
+ for (const Lt of this.bezierPath2D)
+ vt.stroke(Lt);
+ }, Q = new WeakSet(), ui = function($) {
+ this.canvas.removeEventListener("pointerleave", t(this, I)), this.canvas.removeEventListener("pointermove", t(this, O)), this.canvas.removeEventListener("pointerup", t(this, x)), this.canvas.addEventListener("pointerdown", t(this, v)), setTimeout(() => {
+ this.canvas.removeEventListener("contextmenu", X.noContextMenu);
+ }, 10), W(this, S, Gi).call(this, $.offsetX, $.offsetY), this.addToAnnotationStorage(), this.setInBackground();
+ }, ct = new WeakSet(), Me = function() {
+ this.canvas = document.createElement("canvas"), this.canvas.width = this.canvas.height = 0, this.canvas.className = "inkEditorCanvas", P.AnnotationEditor._l10nPromise.get("editor_ink_canvas_aria_label").then(($) => {
+ var vt;
+ return (vt = this.canvas) == null ? void 0 : vt.setAttribute("aria-label", $);
+ }), this.div.append(this.canvas), this.ctx = this.canvas.getContext("2d");
+ }, ut = new WeakSet(), Re = function() {
+ Z(this, C, new ResizeObserver(($) => {
+ const vt = $[0].contentRect;
+ vt.width && vt.height && this.setDimensions(vt.width, vt.height);
+ })), t(this, C).observe(this.div);
+ }, Bt = new WeakSet(), fe = function() {
+ if (!t(this, w))
+ return;
+ const [$, vt] = this.parentDimensions;
+ this.canvas.width = Math.ceil(this.width * $), this.canvas.height = Math.ceil(this.height * vt), W(this, K, De).call(this);
+ }, Dt = new WeakSet(), fi = function($, vt) {
+ const Lt = W(this, ot, Ie).call(this), Tt = ($ - Lt) / t(this, g), Ot = (vt - Lt) / t(this, F);
+ this.scaleFactor = Math.min(Tt, Ot);
+ }, K = new WeakSet(), De = function() {
+ const $ = W(this, ot, Ie).call(this) / 2;
+ this.ctx.setTransform(this.scaleFactor, 0, 0, this.scaleFactor, this.translationX * this.scaleFactor + $, this.translationY * this.scaleFactor + $);
+ }, ht = new WeakSet(), qi = function($) {
+ const vt = new Path2D();
+ for (let Lt = 0, Tt = $.length; Lt < Tt; Lt++) {
+ const [Ot, Nt, Jt, _t] = $[Lt];
+ Lt === 0 && vt.moveTo(...Ot), vt.bezierCurveTo(Nt[0], Nt[1], Jt[0], Jt[1], _t[0], _t[1]);
+ }
+ return vt;
+ }, Ct = new WeakSet(), pi = function($, vt, Lt) {
+ const [Tt, Ot, Nt, Jt] = vt;
+ switch (Lt) {
+ case 0:
+ for (let _t = 0, Yt = $.length; _t < Yt; _t += 2)
+ $[_t] += Tt, $[_t + 1] = Jt - $[_t + 1];
+ break;
+ case 90:
+ for (let _t = 0, Yt = $.length; _t < Yt; _t += 2) {
+ const It = $[_t];
+ $[_t] = $[_t + 1] + Tt, $[_t + 1] = It + Ot;
+ }
+ break;
+ case 180:
+ for (let _t = 0, Yt = $.length; _t < Yt; _t += 2)
+ $[_t] = Nt - $[_t], $[_t + 1] += Ot;
+ break;
+ case 270:
+ for (let _t = 0, Yt = $.length; _t < Yt; _t += 2) {
+ const It = $[_t];
+ $[_t] = Nt - $[_t + 1], $[_t + 1] = Jt - It;
+ }
+ break;
+ default:
+ throw new Error("Invalid rotation");
+ }
+ return $;
+ }, Gt = new WeakSet(), $i = function($, vt, Lt) {
+ const [Tt, Ot, Nt, Jt] = vt;
+ switch (Lt) {
+ case 0:
+ for (let _t = 0, Yt = $.length; _t < Yt; _t += 2)
+ $[_t] -= Tt, $[_t + 1] = Jt - $[_t + 1];
+ break;
+ case 90:
+ for (let _t = 0, Yt = $.length; _t < Yt; _t += 2) {
+ const It = $[_t];
+ $[_t] = $[_t + 1] - Ot, $[_t + 1] = It - Tt;
+ }
+ break;
+ case 180:
+ for (let _t = 0, Yt = $.length; _t < Yt; _t += 2)
+ $[_t] = Nt - $[_t], $[_t + 1] -= Ot;
+ break;
+ case 270:
+ for (let _t = 0, Yt = $.length; _t < Yt; _t += 2) {
+ const It = $[_t];
+ $[_t] = Jt - $[_t + 1], $[_t + 1] = Nt - It;
+ }
+ break;
+ default:
+ throw new Error("Invalid rotation");
+ }
+ return $;
+ }, Xt = new WeakSet(), Yi = function($, vt, Lt, Tt) {
+ var Yt, It;
+ const Ot = [], Nt = this.thickness / 2, Jt = $ * vt + Nt, _t = $ * Lt + Nt;
+ for (const R of this.paths) {
+ const e = [], f = [];
+ for (let D = 0, j = R.length; D < j; D++) {
+ const [q, it, mt, kt] = R[D], Pt = $ * q[0] + Jt, zt = $ * q[1] + _t, Mt = $ * it[0] + Jt, Rt = $ * it[1] + _t, Ut = $ * mt[0] + Jt, qt = $ * mt[1] + _t, Kt = $ * kt[0] + Jt, Qt = $ * kt[1] + _t;
+ D === 0 && (e.push(Pt, zt), f.push(Pt, zt)), e.push(Mt, Rt, Ut, qt, Kt, Qt), f.push(Mt, Rt), D === j - 1 && f.push(Kt, Qt);
+ }
+ Ot.push({
+ bezier: W(Yt = At, Ct, pi).call(Yt, e, Tt, this.rotation),
+ points: W(It = At, Ct, pi).call(It, f, Tt, this.rotation)
+ });
+ }
+ return Ot;
+ }, Wt = new WeakSet(), gi = function() {
+ let $ = 1 / 0, vt = -1 / 0, Lt = 1 / 0, Tt = -1 / 0;
+ for (const Ot of this.paths)
+ for (const [Nt, Jt, _t, Yt] of Ot) {
+ const It = l.Util.bezierBoundingBox(...Nt, ...Jt, ..._t, ...Yt);
+ $ = Math.min($, It[0]), Lt = Math.min(Lt, It[1]), vt = Math.max(vt, It[2]), Tt = Math.max(Tt, It[3]);
+ }
+ return [$, Lt, vt, Tt];
+ }, ot = new WeakSet(), Ie = function() {
+ return t(this, u) ? Math.ceil(this.thickness * this.parentScale) : 0;
+ }, G = new WeakSet(), pe = function($ = !1) {
+ if (this.isEmpty())
+ return;
+ if (!t(this, u)) {
+ W(this, N, ae).call(this);
+ return;
+ }
+ const vt = W(this, Wt, gi).call(this), Lt = W(this, ot, Ie).call(this);
+ Z(this, g, Math.max(P.AnnotationEditor.MIN_SIZE, vt[2] - vt[0])), Z(this, F, Math.max(P.AnnotationEditor.MIN_SIZE, vt[3] - vt[1]));
+ const Tt = Math.ceil(Lt + t(this, g) * this.scaleFactor), Ot = Math.ceil(Lt + t(this, F) * this.scaleFactor), [Nt, Jt] = this.parentDimensions;
+ this.width = Tt / Nt, this.height = Ot / Jt, this.setAspectRatio(Tt, Ot);
+ const _t = this.translationX, Yt = this.translationY;
+ this.translationX = -vt[0], this.translationY = -vt[1], W(this, Bt, fe).call(this), W(this, N, ae).call(this), Z(this, y, Tt), Z(this, a, Ot), this.setDims(Tt, Ot);
+ const It = $ ? Lt / this.scaleFactor / 2 : 0;
+ this.translate(_t - this.translationX - It, Yt - this.translationY - It);
+ }, L(At, ht), L(At, Ct), L(At, Gt), ee(At, "_defaultColor", null), ee(At, "_defaultOpacity", 1), ee(At, "_defaultThickness", 1), ee(At, "_type", "ink");
+ let B = At;
+ d.InkEditor = B;
+ },
+ /* 34 */
+ /***/
+ (dt, d, et) => {
+ var B, F, g, O, I, x, v, A, u, _, w, ve, y, Se, c, Le, p, mi, T, Ki, U, Ji, E, bi, st, Oe, H, Qi;
+ Object.defineProperty(d, "__esModule", {
+ value: !0
+ }), d.StampEditor = void 0;
+ var l = et(1), P = et(4), rt = et(6), X = et(29);
+ const gt = class gt extends P.AnnotationEditor {
+ constructor(S) {
+ super({
+ ...S,
+ name: "stampEditor"
+ });
+ L(this, w);
+ L(this, y);
+ L(this, c);
+ L(this, p);
+ L(this, T);
+ L(this, U);
+ L(this, E);
+ L(this, st);
+ L(this, H);
+ L(this, B, null);
+ L(this, F, null);
+ L(this, g, null);
+ L(this, O, null);
+ L(this, I, null);
+ L(this, x, null);
+ L(this, v, null);
+ L(this, A, null);
+ L(this, u, !1);
+ L(this, _, !1);
+ Z(this, O, S.bitmapUrl), Z(this, I, S.bitmapFile);
+ }
+ static initialize(S) {
+ P.AnnotationEditor.initialize(S);
+ }
+ static get supportedTypes() {
+ const S = ["apng", "avif", "bmp", "gif", "jpeg", "png", "svg+xml", "webp", "x-icon"];
+ return (0, l.shadow)(this, "supportedTypes", S.map((i) => `image/${i}`));
+ }
+ static get supportedTypesStr() {
+ return (0, l.shadow)(this, "supportedTypesStr", this.supportedTypes.join(","));
+ }
+ static isHandlingMimeForPasting(S) {
+ return this.supportedTypes.includes(S);
+ }
+ static paste(S, i) {
+ i.pasteEditor(l.AnnotationEditorType.STAMP, {
+ bitmapFile: S.getAsFile()
+ });
+ }
+ remove() {
+ var S, i;
+ t(this, F) && (Z(this, B, null), this._uiManager.imageManager.deleteId(t(this, F)), (S = t(this, x)) == null || S.remove(), Z(this, x, null), (i = t(this, v)) == null || i.disconnect(), Z(this, v, null)), super.remove();
+ }
+ rebuild() {
+ if (!this.parent) {
+ t(this, F) && W(this, c, Le).call(this);
+ return;
+ }
+ super.rebuild(), this.div !== null && (t(this, F) && W(this, c, Le).call(this), this.isAttachedToDOM || this.parent.add(this));
+ }
+ onceAdded() {
+ this._isDraggable = !0, this.div.focus();
+ }
+ isEmpty() {
+ return !(t(this, g) || t(this, B) || t(this, O) || t(this, I));
+ }
+ get isResizable() {
+ return !0;
+ }
+ render() {
+ if (this.div)
+ return this.div;
+ let S, i;
+ if (this.width && (S = this.x, i = this.y), super.render(), this.div.hidden = !0, t(this, B) ? W(this, p, mi).call(this) : W(this, c, Le).call(this), this.width) {
+ const [n, s] = this.parentDimensions;
+ this.setAt(S * n, i * s, this.width * n, this.height * s);
+ }
+ return this.div;
+ }
+ static deserialize(S, i, n) {
+ if (S instanceof X.StampAnnotationElement)
+ return null;
+ const s = super.deserialize(S, i, n), {
+ rect: o,
+ bitmapUrl: h,
+ bitmapId: b,
+ isSvg: M,
+ accessibilityData: N
+ } = S;
+ b && n.imageManager.isValidId(b) ? Z(s, F, b) : Z(s, O, h), Z(s, u, M);
+ const [tt, Q] = s.pageDimensions;
+ return s.width = (o[2] - o[0]) / tt, s.height = (o[3] - o[1]) / Q, N && (s.altTextData = N), s;
+ }
+ serialize(S = !1, i = null) {
+ if (this.isEmpty())
+ return null;
+ const n = {
+ annotationType: l.AnnotationEditorType.STAMP,
+ bitmapId: t(this, F),
+ pageIndex: this.pageIndex,
+ rect: this.getRect(0, 0),
+ rotation: this.rotation,
+ isSvg: t(this, u),
+ structTreeParentId: this._structTreeParentId
+ };
+ if (S)
+ return n.bitmapUrl = W(this, st, Oe).call(this, !0), n.accessibilityData = this.altTextData, n;
+ const {
+ decorative: s,
+ altText: o
+ } = this.altTextData;
+ if (!s && o && (n.accessibilityData = {
+ type: "Figure",
+ alt: o
+ }), i === null)
+ return n;
+ i.stamps || (i.stamps = /* @__PURE__ */ new Map());
+ const h = t(this, u) ? (n.rect[2] - n.rect[0]) * (n.rect[3] - n.rect[1]) : null;
+ if (!i.stamps.has(t(this, F)))
+ i.stamps.set(t(this, F), {
+ area: h,
+ serialized: n
+ }), n.bitmap = W(this, st, Oe).call(this, !1);
+ else if (t(this, u)) {
+ const b = i.stamps.get(t(this, F));
+ h > b.area && (b.area = h, b.serialized.bitmap.close(), b.serialized.bitmap = W(this, st, Oe).call(this, !1));
+ }
+ return n;
+ }
+ };
+ B = new WeakMap(), F = new WeakMap(), g = new WeakMap(), O = new WeakMap(), I = new WeakMap(), x = new WeakMap(), v = new WeakMap(), A = new WeakMap(), u = new WeakMap(), _ = new WeakMap(), w = new WeakSet(), ve = function(S, i = !1) {
+ if (!S) {
+ this.remove();
+ return;
+ }
+ Z(this, B, S.bitmap), i || (Z(this, F, S.id), Z(this, u, S.isSvg)), W(this, p, mi).call(this);
+ }, y = new WeakSet(), Se = function() {
+ Z(this, g, null), this._uiManager.enableWaiting(!1), t(this, x) && this.div.focus();
+ }, c = new WeakSet(), Le = function() {
+ if (t(this, F)) {
+ this._uiManager.enableWaiting(!0), this._uiManager.imageManager.getFromId(t(this, F)).then((i) => W(this, w, ve).call(this, i, !0)).finally(() => W(this, y, Se).call(this));
+ return;
+ }
+ if (t(this, O)) {
+ const i = t(this, O);
+ Z(this, O, null), this._uiManager.enableWaiting(!0), Z(this, g, this._uiManager.imageManager.getFromUrl(i).then((n) => W(this, w, ve).call(this, n)).finally(() => W(this, y, Se).call(this)));
+ return;
+ }
+ if (t(this, I)) {
+ const i = t(this, I);
+ Z(this, I, null), this._uiManager.enableWaiting(!0), Z(this, g, this._uiManager.imageManager.getFromFile(i).then((n) => W(this, w, ve).call(this, n)).finally(() => W(this, y, Se).call(this)));
+ return;
+ }
+ const S = document.createElement("input");
+ S.type = "file", S.accept = gt.supportedTypesStr, Z(this, g, new Promise((i) => {
+ S.addEventListener("change", async () => {
+ if (!S.files || S.files.length === 0)
+ this.remove();
+ else {
+ this._uiManager.enableWaiting(!0);
+ const n = await this._uiManager.imageManager.getFromFile(S.files[0]);
+ W(this, w, ve).call(this, n);
+ }
+ i();
+ }), S.addEventListener("cancel", () => {
+ this.remove(), i();
+ });
+ }).finally(() => W(this, y, Se).call(this))), S.click();
+ }, p = new WeakSet(), mi = function() {
+ const {
+ div: S
+ } = this;
+ let {
+ width: i,
+ height: n
+ } = t(this, B);
+ const [s, o] = this.pageDimensions, h = 0.75;
+ if (this.width)
+ i = this.width * s, n = this.height * o;
+ else if (i > h * s || n > h * o) {
+ const tt = Math.min(h * s / i, h * o / n);
+ i *= tt, n *= tt;
+ }
+ const [b, M] = this.parentDimensions;
+ this.setDims(i * b / s, n * M / o), this._uiManager.enableWaiting(!1);
+ const N = Z(this, x, document.createElement("canvas"));
+ S.append(N), S.hidden = !1, W(this, E, bi).call(this, i, n), W(this, H, Qi).call(this), t(this, _) || (this.parent.addUndoableEditor(this), Z(this, _, !0)), this._uiManager._eventBus.dispatch("reporttelemetry", {
+ source: this,
+ details: {
+ type: "editing",
+ subtype: this.editorType,
+ data: {
+ action: "inserted_image"
+ }
+ }
+ }), this.addAltTextButton();
+ }, T = new WeakSet(), Ki = function(S, i) {
+ var h;
+ const [n, s] = this.parentDimensions;
+ this.width = S / n, this.height = i / s, this.setDims(S, i), (h = this._initialOptions) != null && h.isCentered ? this.center() : this.fixAndSetPosition(), this._initialOptions = null, t(this, A) !== null && clearTimeout(t(this, A)), Z(this, A, setTimeout(() => {
+ Z(this, A, null), W(this, E, bi).call(this, S, i);
+ }, 200));
+ }, U = new WeakSet(), Ji = function(S, i) {
+ const {
+ width: n,
+ height: s
+ } = t(this, B);
+ let o = n, h = s, b = t(this, B);
+ for (; o > 2 * S || h > 2 * i; ) {
+ const M = o, N = h;
+ o > 2 * S && (o = o >= 16384 ? Math.floor(o / 2) - 1 : Math.ceil(o / 2)), h > 2 * i && (h = h >= 16384 ? Math.floor(h / 2) - 1 : Math.ceil(h / 2));
+ const tt = new OffscreenCanvas(o, h);
+ tt.getContext("2d").drawImage(b, 0, 0, M, N, 0, 0, o, h), b = tt.transferToImageBitmap();
+ }
+ return b;
+ }, E = new WeakSet(), bi = function(S, i) {
+ S = Math.ceil(S), i = Math.ceil(i);
+ const n = t(this, x);
+ if (!n || n.width === S && n.height === i)
+ return;
+ n.width = S, n.height = i;
+ const s = t(this, u) ? t(this, B) : W(this, U, Ji).call(this, S, i), o = n.getContext("2d");
+ o.filter = this._uiManager.hcmFilter, o.drawImage(s, 0, 0, s.width, s.height, 0, 0, S, i);
+ }, st = new WeakSet(), Oe = function(S) {
+ if (S) {
+ if (t(this, u)) {
+ const s = this._uiManager.imageManager.getSvgUrl(t(this, F));
+ if (s)
+ return s;
+ }
+ const i = document.createElement("canvas");
+ return {
+ width: i.width,
+ height: i.height
+ } = t(this, B), i.getContext("2d").drawImage(t(this, B), 0, 0), i.toDataURL();
+ }
+ if (t(this, u)) {
+ const [i, n] = this.pageDimensions, s = Math.round(this.width * i * rt.PixelsPerInch.PDF_TO_CSS_UNITS), o = Math.round(this.height * n * rt.PixelsPerInch.PDF_TO_CSS_UNITS), h = new OffscreenCanvas(s, o);
+ return h.getContext("2d").drawImage(t(this, B), 0, 0, t(this, B).width, t(this, B).height, 0, 0, s, o), h.transferToImageBitmap();
+ }
+ return structuredClone(t(this, B));
+ }, H = new WeakSet(), Qi = function() {
+ Z(this, v, new ResizeObserver((S) => {
+ const i = S[0].contentRect;
+ i.width && i.height && W(this, T, Ki).call(this, i.width, i.height);
+ })), t(this, v).observe(this.div);
+ }, ee(gt, "_type", "stamp");
+ let pt = gt;
+ d.StampEditor = pt;
+ }
+ /******/
+ ], __webpack_module_cache__ = {};
+ function __w_pdfjs_require__(dt) {
+ var d = __webpack_module_cache__[dt];
+ if (d !== void 0)
+ return d.exports;
+ var et = __webpack_module_cache__[dt] = {
+ /******/
+ // no module.id needed
+ /******/
+ // no module.loaded needed
+ /******/
+ exports: {}
+ /******/
+ };
+ return __webpack_modules__[dt](et, et.exports, __w_pdfjs_require__), et.exports;
+ }
+ var __webpack_exports__ = {};
+ return (() => {
+ var dt = __webpack_exports__;
+ Object.defineProperty(dt, "__esModule", {
+ value: !0
+ }), Object.defineProperty(dt, "AbortException", {
+ enumerable: !0,
+ get: function() {
+ return d.AbortException;
+ }
+ }), Object.defineProperty(dt, "AnnotationEditorLayer", {
+ enumerable: !0,
+ get: function() {
+ return rt.AnnotationEditorLayer;
+ }
+ }), Object.defineProperty(dt, "AnnotationEditorParamsType", {
+ enumerable: !0,
+ get: function() {
+ return d.AnnotationEditorParamsType;
+ }
+ }), Object.defineProperty(dt, "AnnotationEditorType", {
+ enumerable: !0,
+ get: function() {
+ return d.AnnotationEditorType;
+ }
+ }), Object.defineProperty(dt, "AnnotationEditorUIManager", {
+ enumerable: !0,
+ get: function() {
+ return X.AnnotationEditorUIManager;
+ }
+ }), Object.defineProperty(dt, "AnnotationLayer", {
+ enumerable: !0,
+ get: function() {
+ return pt.AnnotationLayer;
+ }
+ }), Object.defineProperty(dt, "AnnotationMode", {
+ enumerable: !0,
+ get: function() {
+ return d.AnnotationMode;
+ }
+ }), Object.defineProperty(dt, "CMapCompressionType", {
+ enumerable: !0,
+ get: function() {
+ return d.CMapCompressionType;
+ }
+ }), Object.defineProperty(dt, "DOMSVGFactory", {
+ enumerable: !0,
+ get: function() {
+ return l.DOMSVGFactory;
+ }
+ }), Object.defineProperty(dt, "FeatureTest", {
+ enumerable: !0,
+ get: function() {
+ return d.FeatureTest;
+ }
+ }), Object.defineProperty(dt, "GlobalWorkerOptions", {
+ enumerable: !0,
+ get: function() {
+ return B.GlobalWorkerOptions;
+ }
+ }), Object.defineProperty(dt, "ImageKind", {
+ enumerable: !0,
+ get: function() {
+ return d.ImageKind;
+ }
+ }), Object.defineProperty(dt, "InvalidPDFException", {
+ enumerable: !0,
+ get: function() {
+ return d.InvalidPDFException;
+ }
+ }), Object.defineProperty(dt, "MissingPDFException", {
+ enumerable: !0,
+ get: function() {
+ return d.MissingPDFException;
+ }
+ }), Object.defineProperty(dt, "OPS", {
+ enumerable: !0,
+ get: function() {
+ return d.OPS;
+ }
+ }), Object.defineProperty(dt, "PDFDataRangeTransport", {
+ enumerable: !0,
+ get: function() {
+ return et.PDFDataRangeTransport;
+ }
+ }), Object.defineProperty(dt, "PDFDateString", {
+ enumerable: !0,
+ get: function() {
+ return l.PDFDateString;
+ }
+ }), Object.defineProperty(dt, "PDFWorker", {
+ enumerable: !0,
+ get: function() {
+ return et.PDFWorker;
+ }
+ }), Object.defineProperty(dt, "PasswordResponses", {
+ enumerable: !0,
+ get: function() {
+ return d.PasswordResponses;
+ }
+ }), Object.defineProperty(dt, "PermissionFlag", {
+ enumerable: !0,
+ get: function() {
+ return d.PermissionFlag;
+ }
+ }), Object.defineProperty(dt, "PixelsPerInch", {
+ enumerable: !0,
+ get: function() {
+ return l.PixelsPerInch;
+ }
+ }), Object.defineProperty(dt, "PromiseCapability", {
+ enumerable: !0,
+ get: function() {
+ return d.PromiseCapability;
+ }
+ }), Object.defineProperty(dt, "RenderingCancelledException", {
+ enumerable: !0,
+ get: function() {
+ return l.RenderingCancelledException;
+ }
+ }), Object.defineProperty(dt, "SVGGraphics", {
+ enumerable: !0,
+ get: function() {
+ return et.SVGGraphics;
+ }
+ }), Object.defineProperty(dt, "UnexpectedResponseException", {
+ enumerable: !0,
+ get: function() {
+ return d.UnexpectedResponseException;
+ }
+ }), Object.defineProperty(dt, "Util", {
+ enumerable: !0,
+ get: function() {
+ return d.Util;
+ }
+ }), Object.defineProperty(dt, "VerbosityLevel", {
+ enumerable: !0,
+ get: function() {
+ return d.VerbosityLevel;
+ }
+ }), Object.defineProperty(dt, "XfaLayer", {
+ enumerable: !0,
+ get: function() {
+ return F.XfaLayer;
+ }
+ }), Object.defineProperty(dt, "build", {
+ enumerable: !0,
+ get: function() {
+ return et.build;
+ }
+ }), Object.defineProperty(dt, "createValidAbsoluteUrl", {
+ enumerable: !0,
+ get: function() {
+ return d.createValidAbsoluteUrl;
+ }
+ }), Object.defineProperty(dt, "getDocument", {
+ enumerable: !0,
+ get: function() {
+ return et.getDocument;
+ }
+ }), Object.defineProperty(dt, "getFilenameFromUrl", {
+ enumerable: !0,
+ get: function() {
+ return l.getFilenameFromUrl;
+ }
+ }), Object.defineProperty(dt, "getPdfFilenameFromUrl", {
+ enumerable: !0,
+ get: function() {
+ return l.getPdfFilenameFromUrl;
+ }
+ }), Object.defineProperty(dt, "getXfaPageViewport", {
+ enumerable: !0,
+ get: function() {
+ return l.getXfaPageViewport;
+ }
+ }), Object.defineProperty(dt, "isDataScheme", {
+ enumerable: !0,
+ get: function() {
+ return l.isDataScheme;
+ }
+ }), Object.defineProperty(dt, "isPdfFile", {
+ enumerable: !0,
+ get: function() {
+ return l.isPdfFile;
+ }
+ }), Object.defineProperty(dt, "loadScript", {
+ enumerable: !0,
+ get: function() {
+ return l.loadScript;
+ }
+ }), Object.defineProperty(dt, "noContextMenu", {
+ enumerable: !0,
+ get: function() {
+ return l.noContextMenu;
+ }
+ }), Object.defineProperty(dt, "normalizeUnicode", {
+ enumerable: !0,
+ get: function() {
+ return d.normalizeUnicode;
+ }
+ }), Object.defineProperty(dt, "renderTextLayer", {
+ enumerable: !0,
+ get: function() {
+ return P.renderTextLayer;
+ }
+ }), Object.defineProperty(dt, "setLayerDimensions", {
+ enumerable: !0,
+ get: function() {
+ return l.setLayerDimensions;
+ }
+ }), Object.defineProperty(dt, "shadow", {
+ enumerable: !0,
+ get: function() {
+ return d.shadow;
+ }
+ }), Object.defineProperty(dt, "updateTextLayer", {
+ enumerable: !0,
+ get: function() {
+ return P.updateTextLayer;
+ }
+ }), Object.defineProperty(dt, "version", {
+ enumerable: !0,
+ get: function() {
+ return et.version;
+ }
+ });
+ var d = __w_pdfjs_require__(1), et = __w_pdfjs_require__(2), l = __w_pdfjs_require__(6), P = __w_pdfjs_require__(26), rt = __w_pdfjs_require__(27), X = __w_pdfjs_require__(5), pt = __w_pdfjs_require__(29), B = __w_pdfjs_require__(14), F = __w_pdfjs_require__(32);
+ })(), __webpack_exports__;
+ })()
+ ));
+})(pdf);
+var pdfExports = pdf.exports;
+const pdfjsLib = /* @__PURE__ */ getDefaultExportFromCjs(pdfExports), Example_svelte_svelte_type_style_lang = "", {
+ SvelteComponent,
+ append,
+ attr,
+ binding_callbacks,
+ detach,
+ element,
+ init,
+ insert,
+ noop,
+ safe_not_equal,
+ set_style,
+ toggle_class
+} = window.__gradio__svelte__internal;
+function create_fragment(dt) {
+ let d, et;
+ return {
+ c() {
+ d = element("div"), et = element("canvas"), set_style(d, "justify-content", "center"), set_style(d, "align-items", "center"), set_style(d, "display", "flex"), set_style(d, "flex-direction", "column"), attr(d, "class", "svelte-1gecy8w"), toggle_class(
+ d,
+ "table",
+ /*type*/
+ dt[0] === "table"
+ ), toggle_class(
+ d,
+ "gallery",
+ /*type*/
+ dt[0] === "gallery"
+ ), toggle_class(
+ d,
+ "selected",
+ /*selected*/
+ dt[1]
+ );
+ },
+ m(l, P) {
+ insert(l, d, P), append(d, et), dt[5](et);
+ },
+ p(l, [P]) {
+ P & /*type*/
+ 1 && toggle_class(
+ d,
+ "table",
+ /*type*/
+ l[0] === "table"
+ ), P & /*type*/
+ 1 && toggle_class(
+ d,
+ "gallery",
+ /*type*/
+ l[0] === "gallery"
+ ), P & /*selected*/
+ 2 && toggle_class(
+ d,
+ "selected",
+ /*selected*/
+ l[1]
+ );
+ },
+ i: noop,
+ o: noop,
+ d(l) {
+ l && detach(d), dt[5](null);
+ }
+ };
+}
+function instance(dt, d, et) {
+ let { value: l } = d, { samples_dir: P } = d, { type: rt } = d, { selected: X = !1 } = d;
+ pdfjsLib.GlobalWorkerOptions.workerSrc = "https://cdn.bootcss.com/pdf.js/3.11.174/pdf.worker.js";
+ let pt, B;
+ async function F(I) {
+ pt = await pdfjsLib.getDocument(I).promise, g();
+ }
+ function g() {
+ pt.getPage(1).then((I) => {
+ const x = B.getContext("2d");
+ x.clearRect(0, 0, B.width, B.height);
+ const v = I.getViewport({ scale: 0.2 }), A = { canvasContext: x, viewport: v };
+ et(2, B.width = v.width, B), et(2, B.height = v.height, B), I.render(A);
+ });
+ }
+ function O(I) {
+ binding_callbacks[I ? "unshift" : "push"](() => {
+ B = I, et(2, B);
+ });
+ }
+ return dt.$$set = (I) => {
+ "value" in I && et(3, l = I.value), "samples_dir" in I && et(4, P = I.samples_dir), "type" in I && et(0, rt = I.type), "selected" in I && et(1, X = I.selected);
+ }, dt.$$.update = () => {
+ dt.$$.dirty & /*samples_dir, value*/
+ 24 && F(P + l);
+ }, [rt, X, B, l, P, O];
+}
+class Example extends SvelteComponent {
+ constructor(d) {
+ super(), init(this, d, instance, create_fragment, safe_not_equal, {
+ value: 3,
+ samples_dir: 4,
+ type: 0,
+ selected: 1
+ });
+ }
+}
+export {
+ Example as default
+};