import { defineComponent as O, useTemplateRef as U, ref as W, inject as N, watch as S, onMounted as G, createElementBlock as B, openBlock as F, toRaw as q, provide as V, Fragment as Ie, withDirectives as ae, renderSlot as oe, createElementVNode as A, vShow as ie, computed as Q, onUnmounted as Re, createBlock as de, createCommentVNode as pe, createVNode as me, mergeProps as ee, withCtx as Me, normalizeStyle as Oe, toDisplayString as fe, shallowRef as te, isRef as Be } from "vue"; import * as b from "pdfjs-dist"; import { AnnotationEditorUIManager as He, AnnotationEditorType as ge, AnnotationEditorParamsType as M } from "pdfjs-dist"; const $e = "file-attachment", Ve = "form-text", Ue = "form-select", ze = "form-checkbox", We = "form-radio", Ke = "form-button", he = ["click", "dblclick", "mouseover", "input", "change"]; function ne(i, t, e) { const o = []; if (e) for (const n of e) n[i] === t && o.push(n); return o; } function X(i, t) { return { type: i, data: t }; } function K(i, t) { switch (i.type) { case "textarea": case "text": return X(Ve, { fieldName: i.name, value: i.value }); case "select-one": case "select-multiple": const e = []; for (const n of i.options) e.push({ value: n.value, label: n.label }); const o = []; for (const n of i.selectedOptions) o.push({ value: n.value, label: n.label }); return X(Ue, { fieldName: i.name, value: o, options: e }); case "checkbox": return X(ze, { fieldName: i.name, checked: i.checked }); case "radio": return X(We, { fieldName: i.name, ...t }); case "button": return X(Ke, { fieldName: i.name, ...t }); } } function Xe(i) { return X($e, i.file); } function ye(i) { for (const t of i.getElementsByTagName("span")) { let e = t.textContent; const o = JSON.parse(t.dataset.l10nArgs ?? "{}"); if (e) for (const n in o) e = e.replace(`{{${n}}}`, o[n]); t.textContent = e; } } function Ye(i, t, e) { let o = i.target; if (o.tagName !== "SECTION" && (o = o.parentNode), o.className.includes("popupAnnotation") || o.className.includes("textAnnotation")) ye(o); else if (o.className.includes("fileAttachmentAnnotation")) { ye(o); const n = o.dataset.annotationId; if (n && i.type === "dblclick") return Xe(ne("id", n, e)[0]); } else if (o.className.includes("textWidgetAnnotation") && i.type === "input") { let n = o.getElementsByTagName("input")[0]; return n || (n = o.getElementsByTagName("textarea")[0]), K(n); } else { if (o.className.includes("choiceWidgetAnnotation") && i.type === "input") return K(o.getElementsByTagName("select")[0]); if (o.className.includes("buttonWidgetAnnotation checkBox") && i.type === "change") return K(o.getElementsByTagName("input")[0]); if (o.className.includes("buttonWidgetAnnotation radioButton") && i.type === "change") { const n = o.dataset.annotationId; if (n) { const a = ne("id", n, e)[0], s = []; for (const r of ne("fieldName", a.fieldName, e)) r.buttonValue && s.push(r.buttonValue); return K(o.getElementsByTagName("input")[0], { value: a.buttonValue, defaultValue: a.fieldValue, options: s }); } } else if (o.className.includes("buttonWidgetAnnotation pushButton") && i.type === "click") { const n = o.dataset.annotationId; if (n) { const a = ne("id", n, e)[0]; return a.resetForm ? K( { name: a.fieldName, type: "button" }, { actions: a.actions, reset: !0 } ) : K( { name: a.fieldName, type: "button" }, { actions: a.actions, reset: !1 } ); } } } } const ce = Symbol(), ue = Symbol(), se = Symbol(), Le = Symbol(), be = Symbol(), Pe = Symbol(), _e = Symbol(), Se = Symbol(); function ve(i, t, e = 0) { let o = e, n = i.length - 1; for (; o < n; ) { const a = o + n >> 1; t(i[a]) ? n = a : o = a + 1; } return o; } function je(i, t, e) { if (!i) return [t, e]; const [o, n] = i, a = t, s = t + e - 1; let r = ve(o, (h) => h >= a); o[r] > a && --r; let c = ve(o, (h) => h >= s, r); o[c] > s && --c; const d = a + n[r], y = s + n[c] + 1 - d; return [d, y]; } function qe(i) { const t = i.items, e = [0]; let o = 0; for (const n of t) o += n.str.length, n.hasEOL && (o += 1), e.push(o); return e; } function xe(i, t, e) { const o = t.items; let n = 0, a = o.length - 1; for (; n < a; ) { const u = n + a + 1 >> 1; e[u] <= i ? n = u : a = u - 1; } const s = n, r = i - e[s], c = o[s], d = Math.min(r, c ? c.str.length : 0); return { idx: s, offset: d }; } function Ce(i, t, e) { const o = t.items; if (o.length === 0) return []; const n = qe(t), a = []; for (const s of i) { const r = s[0], c = s[1], d = s[2], [u, y] = e ? je(e, r, c) : [r, c], h = u + y - 1, m = xe(u, t, n), f = xe(h, t, n), l = o[f.idx], g = Math.min( f.offset + 1, l ? l.str.length : 0 ); a.push({ start: m, end: { idx: f.idx, offset: g }, str: d, oindex: r }); } return a; } function ke(i) { const t = i.items, e = []; for (const u of t) e.push(u.str), u.hasEOL && e.push(` `); const o = e.join(""); if (o.length === 0) return ["", null]; const n = [0, 0]; let a = 0; const s = /([\p{Ideographic}\u3040-\u30FF])\n([\p{Ideographic}\u3040-\u30FF])|(\S)-\n|(\n)/gmu, r = o.replace( s, (u, y, h, m, f, l) => { if (y && h) { const g = l + y.length; return n.push(g - a, a + 1), a += 1, y + h; } if (m) { const g = l + m.length; return n.push(g - a, a + 2), a += 2, m; } return f ? " " : u; } ); n.push(r.length, a); const c = new Uint32Array(n.length >> 1), d = new Int32Array(n.length >> 1); for (let u = 0, y = n.length; u < y; u += 2) c[u >> 1] = n[u], d[u >> 1] = n[u + 1]; return [r, [c, d]]; } function we({ width: i, height: t, left: e, top: o }, n, a) { if (i === 0 || t === 0) return null; const s = a.getBoundingClientRect(), r = n.convertToPdfPoint( e - s.left, o - s.top ), c = n.convertToPdfPoint( e - s.left + i, o - s.top + t ); return b.Util.normalizeRect([ r[0], r[1], c[0], c[1] ]); } function Ge(i, t, e) { const o = i.getClientRects(); if (o.length === 1) return { rect: we(o[0], t, e) }; const n = [1 / 0, 1 / 0, -1 / 0, -1 / 0], a = []; let s = 0; for (const r of o) { const c = we(r, t, e); c !== null && (a[s] = a[s + 4] = c[0], a[s + 1] = a[s + 3] = c[3], a[s + 2] = a[s + 6] = c[2], a[s + 5] = a[s + 7] = c[1], b.Util.rectBoundingBox( ...c, n ), s += 8); } return { quadPoints: new Float32Array(a), rect: n }; } function Ee(i, t) { let e = i; do { if (e.nodeType === Node.TEXT_NODE) { const o = e.textContent.length; if (t <= o) return [e, t]; t -= o; } else if (e.firstChild) { e = e.firstChild; continue; } for (; !e.nextSibling && e !== i; ) e = e.parentNode; e !== i && (e = e.nextSibling); } while (e !== i); throw new Error("Offset is bigger than container's contents length."); } function Je(i, t, e, o, n, a) { const { start: s, end: r } = i, c = o[s.idx], d = o[r.idx]; if (!c || !d) return null; const u = new Range(), [y, h] = Ee(c, s.offset), [m, f] = Ee(d, r.offset); return u.setStart(y, h), u.setEnd(m, f), { id: `inferred_link_${a}`, unsafeUrl: t, url: t, annotationType: b.AnnotationType.LINK, rotation: 0, ...Ge(u, e, n), // Populated in the annotationLayer to avoid unnecessary object creation, // since most inferred links overlap existing LinkAnnotations: borderStyle: null }; } function Ze(i) { const t = new RegExp("\\b(?:https?:\\/\\/|mailto:|www\\.)(?:[\\S--[\\p{P}<>]]|\\/|[\\S--[\\[\\]]]+[\\S--[\\p{P}<>]])+|(?=\\p{L})[\\S--[@\\p{Ps}\\p{Pe}<>]]+@([\\S--[[\\p{P}--\\-]<>]]+(?:\\.[\\S--[[\\p{P}--\\-]<>]]+)+)", "gmv"); t.lastIndex = 0; const e = []; let o; for (; (o = t.exec(i)) !== null; ) { const [n, a] = o; let s; if (n.startsWith("www.") || n.startsWith("http://") || n.startsWith("https://")) s = n; else if (a) { const c = URL.parse(`http://${a}`)?.hostname; if (!c || /\.\d+$/.test(c)) continue; } s ??= n.startsWith("mailto:") ? n : `mailto:${n}`; const r = b.createValidAbsoluteUrl(s, void 0, { addDefaultProtocol: !0 }); r && e.push({ url: r.href, index: o.index, length: n.length }); } return e; } async function Qe(i, t, e) { const o = await i.getTextContent({ disableNormalization: !0, includeMarkedContent: !0 }), [n, a] = ke(o), s = Ze(n), r = s.map((u) => [ u.index, u.length, u.url ]), c = Ce( r, o, a ), d = []; if (c.length > 0) { const u = document.createElement("div"); u.style.visibility = "hidden", u.className = "textLayer", t.parentElement?.appendChild(u); const y = new b.TextLayer({ textContentSource: i.streamTextContent(), container: u, viewport: e }); await y.render(); const h = y.textDivs; for (let m = 0; m < c.length; m++) { const f = c[m], l = s[m].url, g = Je( f, l, e, h, u, i._pageIndex * 100 + m ); g && d.push(g); } t.parentElement?.removeChild(u); } return d; } const et = /* @__PURE__ */ O({ __name: "AnnotationLayer", props: { page: {}, viewport: {}, document: {}, annotationsFilter: {}, annotationsMap: {}, imageResourcesPath: {}, hideForms: { type: Boolean }, enableScripting: { type: Boolean }, intent: {}, externalLinkEnabled: { type: Boolean }, externalLinkTarget: {} }, emits: ["annotation", "annotationLoaded"], setup(i, { emit: t }) { const e = i, o = t, n = U("layer"), a = W(), s = N(se), r = N(ce); function c(m) { const f = Ye( m, e.document, a.value ); Promise.resolve(f).then((l) => { l && o("annotation", l); }); } async function d() { return await q(e.document)?.getFieldObjects(); } async function u() { return await q(e.document)?.hasJSActions(); } async function y() { let f = await e.page?.getAnnotations({ intent: e.intent }); if (e.annotationsFilter) { const l = e.annotationsFilter; f = f.filter((g) => { const x = g.subtype, L = g.fieldType ? `${x}.${g.fieldType}` : null; return l?.includes(x) || L !== null && l?.includes(L); }); } return f; } async function h() { n.value.replaceChildren?.(); for (const T of he) n.value.removeEventListener(T, c); const m = q(e.document), f = e.page, l = e.viewport; a.value = await y(); const g = /* @__PURE__ */ new Map([]); for (const T of a.value) if (T.subtype === "Widget" && T.fieldType === "Btn" && T.pushButton) { const D = T.rect[2] - T.rect[0], I = T.rect[3] - T.rect[1], R = document.createElement("canvas"); R.setAttribute( "width", (D * l.scale).toString() ), R.setAttribute( "height", (I * l.scale).toString() ), g.set(T.id, R); } const x = m.annotationStorage; if (e.annotationsMap) for (const [T, D] of Object.entries(e.annotationsMap)) x.setValue(T, D); const L = s.linkService; L.setExternalLinkEnabled(e.externalLinkEnabled ?? !0), L.setExternalLinkTarget(e.externalLinkTarget ?? "_blank"); const w = { accessibilityManager: void 0, annotationCanvasMap: g, div: n.value, page: f, viewport: l.clone({ dontFlip: !0 }), annotationEditorUIManager: null, l10n: null, annotationStorage: x, linkService: L, commentManager: null, structTreeLayer: null }, _ = { annotations: a.value, viewport: l.clone({ dontFlip: !0 }), linkService: L, annotationCanvasMap: g, div: n.value, annotationStorage: x, renderForms: !e.hideForms, page: f, enableScripting: !1, hasJSActions: await u(), fieldObjects: await d(), downloadManager: null, imageResourcesPath: e.imageResourcesPath }, P = new b.AnnotationLayer(w); P.render(_).then(async () => { r.resolve(P); const T = await Qe( f, n.value, l.clone() ); P.addLinkAnnotations(T), o("annotationLoaded", await y()); }); for (const T of he) n.value.addEventListener(T, c); } return S( () => e.viewport, () => { e.page && e.viewport && n.value && h(); } ), G(() => { e.page && e.viewport && n.value && h(); }), (m, f) => (F(), B("div", { ref_key: "layer", ref: n, class: "annotationLayer", style: { display: "block" } }, null, 512)); } }); class tt { uiManager; constructor(t) { this.uiManager = t; } setUiManager(t) { this.uiManager = t; } _on(t, e) { } on(t, e) { this._on(t, e); } // In the original eventbus this dispatch method is actually the emitter // but for the sake of this library we will be using it as the listener dispatch(t, e) { if (this.uiManager) switch (t) { case "switchannotationeditorparams": this.uiManager.updateParams(e.type, e.value); break; } } } class nt { commentPopup = null; dialogElement; // Important for editor toolbar constructor(t) { this.dialogElement = document.createElement("div"), this.commentPopup = t; } setSidebarUiManager(t) { } showSidebar(t) { } hideSidebar() { } removeComments(t) { } selectComment(t) { } addComment(t) { } updateComment(t) { } makeCommentColor(t, e) { } destroyPopup() { } destroy() { } updatePopupColor(t) { } static _makeCommentColor(t, e) { return "transparent"; } toggleCommentPopup(t, e, o, n) { this.commentPopup.fn(t, e, o, n); } showDialog(t, e, o, n, a) { this.commentPopup.request(e, (s) => { e.comment = s, e.focusCommentButton(); }); } } class Y extends He { editorsAvailable = []; #e = []; #t; #a; #n; #o = []; static LAYER_EMITTER_ID = 1e4; constructor(t, e, o, n, a, s, r = []) { const c = new tt(), d = []; for (const u in n) { const y = n[u]; d.push( `${u}=${y[0]},${u}_HCM=${y[1]}` ); } super( null, null, null, null, e.fn ? new nt(e) : null, null, c, t, null, d.join(","), null, null, null, null, null, !1 ), this._supportsPinchToZoom = !1, c.setUiManager(this), this._eventBus = c, this.#e = r, this.#t = o, this.#a = a, this.#n = s; } get direction() { return "ltr"; } static get _keyboardManager() { return null; } get isEditorHandlingKeyboard() { return !1; } get isEnterHandled() { return !1; } get selectedEditors() { const t = []; for (const e of this.getEditors(this.currentPageIndex)) e.isSelected && t.push(e); return t; } editAltText(t) { this.#t.request && this.#t.request(t, (e) => { t.altTextData = { altText: e, decorative: null }; }); } // NOTE: Properties and methods related to signatures getSignature() { } get signatureManager() { return null; } // NOTE: Those methods are no required for basic editing functionality // since they are related to UI interactions that are not implemented // as part of this library design, but they are defined to override and avoid errors setMainHighlightColorPicker() { } keydown() { } keyup() { } undo() { } redo() { } dragOver() { } drop() { } copy() { } cut() { } async paste() { } addNewEditorFromKeyboard() { } focusMainContainer() { this.#a.focus(); } // This could be used for the wrapper
disableUserSelect(t) { } // This could be used to control text selection for text layer a11yAlert(t, e = null) { } // This could be used to announce messages for screen readers addEditListeners() { } removeEditListeners() { } setSelected(t) { if (super.setSelected(t), t.isSelected) { const e = this.#n[Y.LAYER_EMITTER_ID]; e && e("editorSelected", { editor: t }); } } // Note: Important methods to customize its original behavior addEditor(t) { if (super.addEditor(t), t.mode === ge.STAMP && (t._onResizing = () => { this.sizeSelectedEditors(t); }), t.mode === ge.INK) { const o = t._onResizing; t._onResizing = () => { o.call(t), this.sizeSelectedEditors(t); }; } const e = this.#n[Y.LAYER_EMITTER_ID]; e && e("editorAdded", { editor: t }); } removeEditor(t) { super.removeEditor(t); const e = this.#n[Y.LAYER_EMITTER_ID]; e && e("editorRemoved", { editor: t }); } highlightSelection(t = "", e = !1) { const o = document.getSelection(); if (!o || o.isCollapsed) return; const { anchorNode: n } = o, s = (n.nodeType === Node.TEXT_NODE ? n.parentElement : n).closest(".textLayer"); this.currentLayer.hasTextLayer(s) && super.highlightSelection(t, e); } addLayer(t) { super.addLayer(t); for (const e of this.#e) e(this.updateParams.bind(this)); } removeLayer(t) { super.removeLayer(t); } getMode() { return super.getMode(); } updateParams(t, e, o = !1) { if (super.updateParams(t, e), !o) { const n = [ M.FREETEXT_COLOR, M.HIGHLIGHT_COLOR, M.INK_COLOR ]; this.hasSelection && n.includes(t) && this.selectedEditors.forEach((s) => { const r = this.#n[s.mode]; r && r("colorChanged", { editor: s, color: e }); }); } } getId() { const t = Math.floor(Math.random() * 100); return super.getId() + t; } get currentLayer() { return super.currentLayer; } setUpDragSession() { super.setUpDragSession(), this.hasSelection && (this.#o = [], this.selectedEditors.forEach((t) => { t.isSelected && this.#o.push(t); })); } endDragSession() { const t = super.endDragSession(); return t && (this.#o = []), t; } dragSelectedEditors(t, e) { super.dragSelectedEditors(t, e), this.#o.forEach((o) => { const n = this.#n[o.mode]; n && n("dragging", { editor: o, ...this.#i(o) }); }); } sizeSelectedEditors(t) { const e = this.#n[t.mode]; e && e("resizing", { editor: t, ...this.#s(t) }); } #i(t) { return { x: t.x * t.pageDimensions[0], y: t.y * t.pageDimensions[1] }; } #s(t) { return { width: t.width * t.pageDimensions[0], height: t.height * t.pageDimensions[1], x: t.x * t.pageDimensions[0], y: t.y * t.pageDimensions[1] }; } } const ot = /* @__PURE__ */ O({ __name: "AnnotationEditorLayer", props: { page: {}, viewport: {}, document: {}, intent: {}, editorType: {}, editorLayer: { type: Boolean } }, emits: ["editorAdded", "editorRemoved", "editorSelected", "editorLoaded"], setup(i, { expose: t, emit: e }) { const o = { yellow: ["#FFEB3B", "#FFFFCC"], green: ["#8BC34A", "#53FFBC"], pink: ["#FFCBE6", "#F6B8FF"], red: ["#F44336", "#FF4F5F"], blue: ["#2196F3", "#80EBFF"] }, n = i, a = e, s = U("layer"); let r = null; const c = { fn: null, request: null }, d = { params: null, emit: null }, u = { fn: null, params: null, emit: null }, y = { params: null, emit: null }, h = { fn: (w) => { if (n.editorType !== b.AnnotationEditorType.STAMP) { console.warn("[vue-pdf] Cannot add stamp when editor type is not STAMP."); return; } typeof w == "string" ? r?.addNewEditor({ bitmapUrl: w }) : w ? r?.addNewEditor({ bitmapFile: w }) : r?.addNewEditor(); }, request: null, emit: null }; V(Se, d), V(Le, u), V(be, c), V(Pe, h), V(_e, y); const m = N(ue), f = N(ce), l = N(se); async function g() { if (!l.uiManager && !n.editorLayer) return; const w = n.page, _ = n.viewport; if (!l.uiManager) { const I = [ d.params, u.params, y.params ].filter((re) => re !== null), R = { [b.AnnotationEditorType.FREETEXT]: d.emit, [b.AnnotationEditorType.INK]: y.emit, [b.AnnotationEditorType.STAMP]: h.emit, [b.AnnotationEditorType.HIGHLIGHT]: u.emit, [Y.LAYER_EMITTER_ID]: a }; l.uiManager = new Y( n.document, c, h, u.fn?.() ?? o, l.wrapper.value, R, I ); } const [P, C] = await Promise.all([ m.promise, f.promise ]); r && r.pageIndex !== w._pageIndex && (r.destroy(), r = null); const T = _.clone({ dontFlip: !0 }); if (r) { r.pause(!0), r.update({ viewport: T }), l.uiManager?.onRotationChanging({ pagesRotation: T.rotation }), l.uiManager?.onScaleChanging({ scale: T.scale }), l.uiManager?.onPageChanging({ pageNumber: w.pageNumber }), r.pause(!1), l.uiManager?.updateMode(n.editorType); return; } const D = new b.DrawLayer(); D.setParent(l.wrapper.value), r = new b.AnnotationEditorLayer({ uiManager: l.uiManager, div: s.value, viewport: _.clone({ dontFlip: !0 }), enabled: !0, pageIndex: w.pageNumber - 1, l10n: null, textLayer: P ? { div: P } : void 0, // <-- Type casting to satisfy typescript bllsht :) drawLayer: D, mode: n.editorType, structTreeLayer: null, accessibilityManager: void 0, annotationLayer: C }), r.toggleDrawing = (I) => { s.value?.classList.toggle("drawing", !I); }, r.hasTextLayer = (I) => { const R = I.getAttribute("data-main-page"); return R ? parseInt(R) === w._pageIndex : !1; }, r.render({ viewport: _.clone({ dontFlip: !0 }) }), r.enable(), l.uiManager?.onRotationChanging({ pagesRotation: T.rotation }), l.uiManager?.onScaleChanging({ scale: T.scale }), l.uiManager?.onPageChanging({ pageNumber: w.pageNumber }), l.uiManager?.updateMode(n.editorType), a("editorLoaded"); } function x() { [ b.AnnotationEditorType.FREETEXT, b.AnnotationEditorType.HIGHLIGHT, b.AnnotationEditorType.INK, b.AnnotationEditorType.STAMP, b.AnnotationEditorType.NONE, b.AnnotationEditorType.DISABLE ].includes(n.editorType) ? g() : console.warn(`[vue-pdf] Unsupported editor type: ${n.editorType}.`); } function L() { l.uiManager?.unselectAll(); } return S( () => [n.editorLayer], ([w]) => { w && !l.uiManager ? n.page && n.viewport && s.value && x() : l.wrapper.value?.querySelectorAll("svg")?.forEach((P) => { w ? P.classList.remove("svg-editor-hidden") : P.classList.add("svg-editor-hidden"); }); } ), S( () => [n.viewport, n.editorType], () => { n.page && n.viewport && s.value && x(); } ), G(() => { n.page && n.viewport && s.value && x(); }), t({ unselectAll: L }), (w, _) => (F(), B(Ie, null, [ ae(A("div", { ref_key: "layer", ref: s, class: "annotationEditorLayer", id: "annotationEditorLayer" }, null, 512), [ [ie, i.editorLayer] ]), oe(w.$slots, "default") ], 64)); } }); function at(i, t, e) { const [o, n] = ke(i), a = ["g"]; e.ignoreCase && a.push("i"); let s = t.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); e.completeWords && (s = `\\b${s}\\b`); const r = new RegExp(s, a.join("")), c = []; let d; for (; (d = r.exec(o)) !== null; ) c.push([d.index, d[0].length, d[0]]); return [c, n]; } function it(i, t, e) { function o(n, a = -1, s = -1) { const r = t.items[n], c = []; let d = "", u = "", y = "", h = e[n]; if (!h) return; if (h.nodeType === Node.TEXT_NODE) { const l = document.createElement("span"); h.before(l), l.append(h), e[n] = l, h = l; } a >= 0 && s >= 0 ? d = r.str.substring(a, s) : a < 0 && s < 0 ? d = r.str : a >= 0 ? d = r.str.substring(a) : s >= 0 && (d = r.str.substring(0, s)); const m = document.createTextNode(d), f = document.createElement("span"); if (f.className = "highlight appended", f.append(m), c.push(f), a > 0) if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) { u = r.str.substring(0, a); const l = document.createTextNode(u); c.unshift(l); } else { let l = 0; const g = []; for (const x of h.childNodes) { const L = x.nodeType === Node.TEXT_NODE ? x.nodeValue : x.firstChild.nodeValue; l += L.length, l <= a ? g.push(x) : a >= l - L.length && s <= l && g.push( document.createTextNode( L.substring( 0, a - (l - L.length) ) ) ); } c.unshift(...g); } if (s > 0) { y = r.str.substring(s); const l = document.createTextNode(y); c.push(l); } h.replaceChildren(...c); } for (const n of i.sort((a, s) => a.oindex - s.oindex)) if (n.start.idx === n.end.idx) o(n.start.idx, n.start.offset, n.end.offset); else for (let a = n.start.idx, s = n.end.idx; a <= s; a++) a === n.start.idx ? o(a, n.start.offset) : a === n.end.idx ? o(a, -1, n.end.offset) : o(a); } function st(i, t) { const e = i.items.map((o) => o.str); for (let o = 0; o < t.length; o++) { const n = t[o]; if (n && n.nodeType !== Node.TEXT_NODE) { const a = document.createTextNode(e[o]); n.replaceChildren(a); } } } function rt(i, t, e) { const o = []; for (const n of i) { const [a, s] = at(t, n, e); o.push(...Ce(a, t, s)); } return o; } const lt = ["data-main-page"], ct = /* @__PURE__ */ O({ __name: "TextLayer", props: { page: {}, viewport: {}, highlightText: {}, highlightOptions: {}, highlightPages: {} }, emits: ["highlight", "textLoaded"], setup(i, { emit: t }) { const e = i, o = t, n = U("layer"), a = W(); let s = [], r; const c = N(ue); function d() { return Object.assign( {}, { ignoreCase: !0, completeWords: !1 }, e.highlightOptions ); } async function u(l = !1) { const g = e.page, x = await g?.getTextContent(); if (x && (l && st(x, s), e.highlightText && (!e.highlightPages || e.highlightPages.includes(g.pageNumber)))) { const L = typeof e.highlightText == "string" ? [e.highlightText] : e.highlightText, w = rt( L, x, d() ); it(w, x, s), o("highlight", { matches: w, textContent: x, textDivs: s, page: g?.pageNumber || 1 }); } } async function y() { r?.cancel(), n.value.replaceChildren?.(); const l = e.page, g = e.viewport, x = l?.streamTextContent({ includeMarkedContent: !0, disableNormalization: !0 }), L = new b.TextLayer({ container: n.value, textContentSource: x, viewport: g }); r = L; try { await L.render(), s = L.textDivs; const w = await l?.getTextContent(); o("textLoaded", { textDivs: s, textContent: w }), h(), u(), c.resolve(n.value); } catch { } } function h() { const l = document.createElement("div"); l.className = "endOfContent", n.value?.appendChild(l), a.value = l; } function m() { a.value && a.value.classList.add("active"); } function f() { a.value && a.value.classList.remove("active"); } return S( () => e.viewport, // eslint-disable-next-line @typescript-eslint/no-unused-vars (l) => { e.page && e.viewport && n.value && y(); } ), S( () => [e.highlightText, e.highlightOptions], // eslint-disable-next-line @typescript-eslint/no-unused-vars (l) => { u(!0); }, { deep: !0 } ), G(() => { e.page && e.viewport && n.value && y(); }), (l, g) => (F(), B("div", { ref_key: "layer", ref: n, class: "textLayer", "data-main-page": i.page?._pageIndex, onMousedown: m, onMouseup: f }, null, 40, lt)); } }), ut = /* @__PURE__ */ O({ __name: "XFALayer", props: { page: {}, document: {}, viewport: {} }, emits: ["xfaLoaded"], setup(i, { emit: t }) { const e = i, o = t, n = U("layer"), a = N(se); async function s() { n.value.replaceChildren?.(); const r = q(e.document), c = e.page, d = e.viewport; if (r.isPureXfa) { const u = await c.getXfa(), y = { div: n.value, viewport: d.clone({ dontFlip: !0 }), linkService: a.linkService, annotationStorage: r?.annotationStorage, xfaHtml: u }; b.XfaLayer.render(y), o("xfaLoaded"); } } return S( () => e.viewport, (r) => { e.page && e.viewport && n.value && s(); } ), G(() => { e.page && e.viewport && n.value && s(); }), (r, c) => (F(), B("div", { ref_key: "layer", ref: n, style: { display: "block" } }, null, 512)); } }), dt = "link", pt = "internal-link"; class mt { targets = ["_blank", "_self", "_parent", "_top"]; externalLinkEnabled; externalLinkTarget; externalLinkRel; #e = null; #t = null; eventBus = null; baseUrl; _ignoreDestinationZoom = !1; pdfDocument; pdfHistory; pdfViewer; constructor(t) { this.externalLinkEnabled = !0, this.externalLinkTarget = this.targets.indexOf("_blank"), this.externalLinkRel = "noopener noreferrer", this.#t = t; } setHistory(t) { this.pdfHistory = t; } setViewer(t) { this.pdfViewer = t; } setDocument(t) { this.#e = t; } setRootEmit(t) { this.#t = t; } get pagesCount() { return this.#e?.numPages || 0; } get page() { return 0; } set page(t) { } set rotation(t) { } get rotation() { return 0; } get isInPresentationMode() { return !1; } /** * @param {string|Array} dest - The named, or explicit, PDF destination. */ async goToDestination(t) { if (!this.#e) return; let e, o; if (typeof t == "string" ? e = await this.#e.getDestination(t) : e = await t, !Array.isArray(e)) { console.error( `goToDestination: "${e}" is not a valid destination array, for dest="${t}".` ); return; } const [n] = e; if (n && typeof n == "object") { if (o = this.#e.cachedPageNumber(n), !o) try { o = await this.#e.getPageIndex(n) + 1; } catch { console.error( `goToDestination: "${n}" is not a valid page reference, for dest="${t}".` ); return; } } else Number.isInteger(n) && (o = n + 1); if (!o || o < 1 || o > this.pagesCount) { console.error( `goToDestination: "${o}" is not a valid page number, for dest="${t}".` ); return; } const a = { left: 0, bottom: 0 }; switch (e[1].name) { case "XYZ": case "FitR": a.left = e[2], a.bottom = e[3]; break; case "FitV": case "FitBV": a.left = e[2]; break; case "FitH": case "FitBH": a.bottom = e[2], (a.bottom === null || typeof a.bottom != "number" || a.bottom < 0) && (a.bottom = 0); break; } this.#t("annotation", { type: pt, data: { referencedPage: o, offset: a } }); } addLinkAttributes(t, e, o = !1) { t.style.cursor = "pointer"; const n = typeof window < "u" && window.location ? window.location.href : "about:blank"; let a; try { a = new URL(e, n); } catch { return; } if (t.addEventListener("click", (d) => { this.#t("annotation", { type: dt, data: { url: a, unsafeUrl: e } }); }), !this.externalLinkEnabled) return; const s = a.protocol.toLowerCase(); if (!(s === "http:" || s === "https:" || s === "mailto:" || s === "tel:")) return; t.href = a.toString(), o ? t.target = "_blank" : this.externalLinkTarget !== -1 ? t.target = this.targets[this.externalLinkTarget] : t.removeAttribute("target"); const c = this.externalLinkRel; t.rel = c.includes("noopener") ? c : `noopener ${c}`.trim(); } getDestinationHash(t) { return "#"; } getAnchorUrl(t) { return "#"; } setExternalLinkTarget(t) { this.externalLinkTarget = this.targets.indexOf(t); } setExternalLinkRel(t) { this.externalLinkRel = t; } setExternalLinkEnabled(t) { this.externalLinkEnabled = t; } setHash(t) { } executeNamedAction(t) { } executeSetOCGState(t) { return new Promise(() => { }); } cachePageRef(t, e) { } goToPage(t) { } goToXY(t, e, o) { } } const ft = /* @__PURE__ */ O({ __name: "VuePDF", props: { pdf: {}, page: { default: 1 }, scale: { default: 1 }, rotation: {}, fitParent: { type: Boolean }, width: {}, height: {}, textLayer: { type: Boolean }, autoDestroy: { type: Boolean, default: !1 }, imageResourcesPath: {}, hideForms: { type: Boolean }, intent: { default: "display" }, annotationLayer: { type: Boolean }, annotationsFilter: {}, annotationsMap: {}, watermarkText: {}, watermarkOptions: {}, highlightText: {}, highlightOptions: {}, highlightPages: {}, editorLayer: { type: Boolean }, editorType: { default: 0 }, externalLinkEnabled: { type: Boolean, default: !0 }, externalLinkTarget: { default: "_blank" } }, emits: ["annotation", "highlight", "loaded", "textLoaded", "annotationLoaded", "xfaLoaded", "editorLoaded", "editorAdded", "editorRemoved", "editorSelected"], setup(i, { expose: t, emit: e }) { const o = i, n = e, a = U("container"), s = U("canvasWrapper"), r = U("loadingLayer"), c = W(!1); let d; const u = Q(() => ({ viewport: void 0, document: void 0, page: void 0 })), y = Q(() => ({ annotationsMap: o.annotationsMap, annotationsFilter: o.annotationsFilter, externalLinkEnabled: o.externalLinkEnabled, externalLinkTarget: o.externalLinkTarget, imageResourcesPath: o.imageResourcesPath, hideForms: o.hideForms, intent: o.intent })), h = Q(() => ({ highlightText: o.highlightText, highlightOptions: o.highlightOptions, highlightPages: o.highlightPages })), m = Q(() => ({ editorLayer: o.editorLayer, editorType: o.editorType, intent: o.intent })); let f, l; V(ce, { promise: new Promise((v) => { f = v; }), resolve: (v) => f(v) }), V(ue, { promise: new Promise((v) => { l = v; }), resolve: (v) => l(v) }); const g = { wrapper: s, container: a, uiManager: null, linkService: new mt(n) }; V(se, g); function x() { return Object.assign( {}, { columns: 4, rows: 4, rotation: 45, fontSize: 18, color: "rgba(211, 210, 211, 0.4)" }, o.watermarkOptions ); } function L(v) { if (!(typeof v == "number" && v % 90 === 0)) return 0; const p = v / 90; return p > 4 ? L(v - 360) : p < 0 ? L(v + 360) : v; } function w(v) { let p = o.scale; if (o.fitParent) { const E = s.value.parentNode.clientWidth, k = v.getViewport({ scale: 1 }).width; p = E / k; } else if (o.width) { const E = v.getViewport({ scale: 1 }).width; p = o.width / E; } else if (o.height) { const E = v.getViewport({ scale: 1 }).height; p = o.height / E; } return p; } function _(v = 1) { if (!o.watermarkText) return; const p = P(); if (!p) return; const E = p.getContext("2d"); if (!E) return; const k = x(), z = o.watermarkText, H = k.columns, $ = k.rows, j = H * $, le = k.rotation, J = k.fontSize * v; E.font = `${J}px Trebuchet MS`, E.fillStyle = k.color; for (let Z = 0; Z < j; Z++) { const Fe = Z % H * (p.width / H) + p.width / (H * 2), Ae = Math.floor(Z / H) * (p.height / $) + p.height / ($ * 2), De = E.measureText(z).width; E.save(), E.translate(Fe, Ae), E.rotate(-le * (Math.PI / 180)), E.fillText(z, -De / 2, J / 2), E.restore(); } } function P() { let v = null; return s.value?.childNodes.forEach((p) => { p.tagName === "CANVAS" && (v = p); }), v; } function C(v) { let p; const E = P(); E && E?.getAttribute("role") === "main" ? p = E : (p = document.createElement("canvas"), p.style.display = "block", p.setAttribute("dir", "ltr")); const k = window.devicePixelRatio || 1; return p.width = Math.floor(v.width * k), p.height = Math.floor(v.height * k), p.style.width = `${Math.floor(v.width)}px`, p.style.height = `${Math.floor(v.height)}px`, a.value?.style.setProperty("--scale-factor", `${v.scale}`), a.value?.style.setProperty("--user-unit", `${v.userUnit}`), a.value?.style.setProperty("--scale-round-y", "1px"), a.value?.style.setProperty("--scale-round-x", "1px"), a.value?.style.setProperty( "--total-scale-factor", "calc(var(--scale-factor) * var(--user-unit))" ), r.value.style.width = `${Math.floor(v.width)}px`, r.value.style.height = `${Math.floor(v.height)}px`, r.value.style.top = "0", r.value.style.left = "0", c.value = !0, p; } function T() { d && d.cancel(); } function D(v) { q(u.value.document)?.getPage(v).then((p) => { T(); const E = p.getViewport(), k = { scale: w(p), rotation: L((o.rotation || 0) + E.rotation) }, z = p.getViewport(k), H = P(), $ = C(z), j = window.devicePixelRatio || 1, le = j !== 1 ? [j, 0, 0, j, 0, 0] : void 0, J = { canvas: $, viewport: z, annotationMode: o.hideForms ? b.AnnotationMode.ENABLE : b.AnnotationMode.ENABLE_FORMS, transform: le, intent: o.intent }; $?.getAttribute("role") !== "main" ? H && s.value?.replaceChild($, H) : $.removeAttribute("role"), g.linkService.setDocument(u.value.document), u.value.page = p, u.value.viewport = z, d = p.render(J), d.promise.then(() => { c.value = !1, _(z.scale), n("loaded", u.value.viewport); }).catch(() => { }); }); } function I(v) { v.promise.then(async (p) => { u.value.document = p, D(o.page); }); } S( () => o.pdf, (v, p) => { T(), p && p !== v && !o.autoDestroy && p.destroy(), v !== void 0 && I(v); } ), S( () => [ o.scale, o.width, o.height, o.rotation, o.page, o.hideForms, o.intent ], () => { D(o.page); } ), G(() => { o.pdf !== void 0 && I(o.pdf); }), Re(() => { o.autoDestroy && o.pdf?.destroy(); }); function R() { o.pdf?.destroy(); } function re() { D(o.page); } function Ne() { T(); } return t({ reload: re, cancel: Ne, destroy: R }), (v, p) => (F(), B("div", { ref_key: "container", ref: a, class: "page", style: { position: "relative", "background-clip": "content-box" } }, [ A("div", { ref_key: "canvasWrapper", ref: s, class: "canvasWrapper" }, [...p[9] || (p[9] = [ A("canvas", { dir: "ltr", role: "main" }, null, -1) ])], 512), i.textLayer ? (F(), de(ct, ee({ key: 0 }, { ...u.value, ...h.value }, { onHighlight: p[0] || (p[0] = (E) => n("highlight", E)), onTextLoaded: p[1] || (p[1] = (E) => n("textLoaded", E)) }), null, 16)) : pe("", !0), i.annotationLayer ? (F(), de(et, ee({ key: 1 }, { ...u.value, ...y.value }, { onAnnotation: p[2] || (p[2] = (E) => n("annotation", E)), onAnnotationLoaded: p[3] || (p[3] = (E) => n("annotationLoaded", E)) }), null, 16)) : pe("", !0), me(ot, ee({ ...u.value, ...m.value }, { onEditorAdded: p[4] || (p[4] = (E) => n("editorAdded", E)), onEditorRemoved: p[5] || (p[5] = (E) => n("editorRemoved", E)), onEditorSelected: p[6] || (p[6] = (E) => n("editorSelected", E)), onEditorLoaded: p[7] || (p[7] = (E) => n("editorLoaded")) }), { default: Me(() => [ oe(v.$slots, "editors", {}, void 0, !0) ]), _: 3 }, 16), me(ut, ee({ ...u.value }, { onXfaLoaded: p[8] || (p[8] = (E) => n("xfaLoaded")) }), null, 16), ae(A("div", { ref_key: "loadingLayer", ref: r, style: { position: "absolute" } }, [ oe(v.$slots, "default", {}, void 0, !0) ], 512), [ [ie, c.value] ]), oe(v.$slots, "overlay", { width: u.value.viewport?.width, height: u.value.viewport?.height }, void 0, !0) ], 512)); } }), gt = (i, t) => { const e = i.__vccOpts || i; for (const [o, n] of t) e[o] = n; return e; }, Te = /* @__PURE__ */ gt(ft, [["__scopeId", "data-v-f567e772"]]), ht = { style: { display: "none" } }, Vt = /* @__PURE__ */ O({ __name: "PDFFreeTextAnnotation", props: { color: {}, fontSize: {} }, emits: ["dragging", "colorChanged"], setup(i, { emit: t }) { const e = i, o = t, n = N(Se); let a = null; function s(c) { a = c, r(); } function r() { a?.(M.FREETEXT_COLOR, e.color, !0), a?.(M.FREETEXT_SIZE, e.fontSize, !0); } return n.params = s, n.emit = o, S( () => [e.color, e.fontSize], () => { r(); } ), (c, d) => (F(), B("div", ht)); } }), yt = { style: { display: "none" } }, Ut = /* @__PURE__ */ O({ __name: "PDFHighlightAnnotation", props: { color: {}, thickness: {}, colorOptions: {} }, emits: ["colorChanged"], setup(i, { emit: t }) { const e = i, o = t, n = N(Le); let a = null; function s(c) { a = c, r(); } function r() { a?.(M.HIGHLIGHT_COLOR, e.color, !0), a?.(M.HIGHLIGHT_THICKNESS, e.thickness, !0); } return n.params = s, n.emit = o, n.fn = () => e.colorOptions, S( () => [e.color, e.thickness], () => { r(); } ), S( () => e.colorOptions, () => { console.warn( "[vue-pdf] Highlight color options can only be set once during initialization." ); } ), (c, d) => (F(), B("div", yt)); } }), vt = { style: { display: "none" } }, zt = /* @__PURE__ */ O({ __name: "PDFInkAnnotation", props: { color: {}, thickness: {}, opacity: {} }, emits: ["dragging", "resizing", "colorChanged"], setup(i, { emit: t }) { const e = i, o = t, n = N(_e); let a = null; function s(c) { a = c, r(); } function r() { a?.(M.INK_COLOR, e.color, !0), a?.(M.INK_THICKNESS, e.thickness, !0), a?.(M.INK_OPACITY, e.opacity, !0); } return n.params = s, n.emit = o, S( () => [e.color, e.thickness, e.opacity], () => { r(); } ), (c, d) => (F(), B("div", vt)); } }), xt = { class: "commentPopupTop" }, wt = { class: "commentPopupTime" }, Et = { class: "commentPopupButtons", style: { visibility: "visible !important" } }, Tt = { class: "commentPopupText" }, Wt = /* @__PURE__ */ O({ __name: "PDFCommentAnnotation", emits: ["comment", "removed"], setup(i, { emit: t }) { const e = t, o = N(be), n = W(!1), a = W(!1), s = W(), r = W({ x: 0, y: 0 }), c = U("popupContainer"); let d = null; function u(l, g, x, L) { if (!l) { n.value = !1; return; } if (x === void 0 ? (a.value = g, n.value = g, a.value && l.isSelected && (a.value = !1, n.value = !1)) : a.value || (n.value = x), l.isSelected = a.value, l.setCommentButtonStates({ selected: a.value, hasPopup: !0 }), l.hasComment && l.commentPopupPosition) { let [w, _] = l.commentPopupPosition; l?.elementBeforePopup?.after(c.value), r.value.x = w * 100, r.value.y = _ * 100; } try { const { contentsObj: w, richText: _, creationDate: P, modificationDate: C } = l.getData(), T = _?.str && (!w?.str || _.str === w.str) ? _.html : w?.str; s.value = { html: T, creationDate: P, modificationDate: C }, d = l; } catch { } } function y(l) { const g = b.PDFDateString.toDateObject(l); return g ? Intl.DateTimeFormat(void 0, { dateStyle: "long" }).format(g) : ""; } function h() { n.value = !1, a.value = !1, d?.editComment({ height: 0 }), d?.focus(); } function m() { d && (d.comment = null, n.value = !1, a.value = !1, d.focus(), e("removed", d)); } function f(l, g) { e("comment", l, (x) => { x !== null && x.length > 0 && g(x); }); } return o.fn = u, o.request = f, (l, g) => ae((F(), B("div", { ref_key: "popupContainer", ref: c, class: "commentPopup", tabindex: "-1", role: "dialog", "aria-modal": "false", style: Oe({ left: r.value.x + "%", top: r.value.y + "%" }) }, [ A("div", xt, [ A("time", wt, fe(y(s.value?.creationDate)), 1), ae(A("div", Et, [ A("button", { onClick: h, class: "commentPopupIcon commentPopupEdit toolbarButton", tabindex: "0", "data-l10n-id": "pdfjs-editor-edit-comment-popup-button", "aria-haspopup": "dialog" }), A("button", { onClick: m, class: "commentPopupIcon commentPopupDelete toolbarButton", tabindex: "0", "data-l10n-id": "pdfjs-editor-delete-comment-popup-button" }) ], 512), [ [ie, a.value] ]) ]), g[0] || (g[0] = A("hr", null, null, -1)), A("div", Tt, fe(s.value?.html), 1) ], 4)), [ [ie, n.value] ]); } }), Lt = { style: { display: "none" } }, Kt = /* @__PURE__ */ O({ __name: "PDFStampAnnotation", emits: ["altText", "dragging", "resizing"], setup(i, { expose: t, emit: e }) { const o = e, n = N( Pe ); function a(r = null) { n?.fn?.(r); } function s(r, c) { o("altText", r, (d) => { d !== null && d.length > 0 && c(d); }); } return n.request = s, n.emit = o, t({ addStamp: a }), (r, c) => (F(), B("div", Lt)); } }); function bt(i) { return !!(typeof i == "object" && i && "gen" in i && "num" in i); } async function Pt(i, t) { return typeof t == "string" ? i.getDestination(t) : t; } async function _t(i, t) { return t && bt(t[0]) ? t[0] : null; } const St = (i) => i.type === "XYZ" && i.spec.length === 3, Ct = (i) => i.type === "Fit" && i.spec.length === 0, kt = (i) => i.type === "FitH" && i.spec.length === 1, Nt = (i) => i.type === "FitV" && i.spec.length === 1, Ft = (i) => i.type === "FitR" && i.spec.length === 4, At = (i) => i.type === "FitB" && i.spec.length === 0, Dt = (i) => i.type === "FitBH" && i.spec.length === 1, It = (i) => i.type === "FitBV" && i.spec.length === 1; function Rt(i, t) { const e = { type: i, spec: t }; return St(e) || Ct(e) || kt(e) || Nt(e) || Ft(e) || At(e) || Dt(e) || It(e) ? e : (console.warn("no location type found for ", i, t), null); } const Mt = (i) => i && i.every((t) => !isNaN(t)); async function Ot() { return new Promise((i, t) => { const e = document.createElement("iframe"); e.width = "0px", e.height = "0px", e.style.cssText = "position: absolute; top:0; left:0", e.style.display = "none", e.onload = function() { i(e); }, document.body.appendChild(e); }); } function Bt(i, t, e) { const o = i.document.createElement("style"); o.textContent = ` @page { margin: 0; size: ${t}pt ${e}pt; } body { margin: 0; width: 100%; } canvas { page-break-after: always; page-break-before: avoid; page-break-inside: avoid; } `, i.document.head.appendChild(o); } function Xt(i, t = { onProgress: void 0, onPassword: void 0, onError: void 0, password: "" }) { const e = te(), o = te(), n = te(0), a = te({}); function s(y) { e.value && e.value.destroy(), o.value && o.value.destroy(); const h = b.getDocument(y); if (t.onProgress && (h.onProgress = t.onProgress), t.onPassword) h.onPassword = t.onPassword; else if (t.password) { const m = (f, l) => { f(t.password ?? ""); }; h.onPassword = m; } h.promise.then( async (m) => { o.value = m, e.value = m.loadingTask, n.value = m.numPages; const f = await m.getMetadata(), l = await m.getAttachments(), g = await m.getJSActions(), x = await m.getOutline(); a.value = { metadata: f, attachments: l, javascript: g, outline: x }; }, (m) => { typeof t.onError == "function" && t.onError(m); } ); } async function r(y) { const h = await e.value?.promise; if (!h) return null; const m = await Pt(h, y), f = await _t(h, m); if (!f || !m) return null; const l = await h.getPageIndex(f), g = m[1].name, x = m.slice(2), L = Mt(x) ? Rt(g, x) : null; return { pageIndex: l, location: L ?? { type: "Fit", spec: [] } }; } async function c() { if (!o.value) throw new Error("Current PDFDocumentProxy have not loaded yet"); try { return await o.value.saveDocument(); } catch (y) { return console.error("Error saving PDF document:", y), await o.value.getData(); } } async function d(y = "filename") { const h = await c(), m = new Blob([h], { type: "application/pdf" }), f = URL.createObjectURL(m), l = document.createElement("a"); document.body.appendChild(l), l.href = f, l.download = y, l.style.display = "none", l.click(), setTimeout(() => { URL.revokeObjectURL(f), document.body.removeChild(l); }, 10); } async function u(y = 150, h = "filename") { if (!e.value) throw new Error("Current PDFDocumentLoadingTask have not loaded yet"); const m = await e.value.promise, f = y / 72, l = 96 / 72, g = await Ot(), x = g.contentWindow; x.document.title = h; const L = [...Array(m.numPages).keys()].map((w) => w + 1); for (const w of L) { const _ = await m.getPage(w), P = _.getViewport({ scale: 1 }); w === 1 && Bt( x, P.width * f / l, P.height * f / l ); const C = document.createElement("canvas"); C.width = P.width * f, C.height = P.height * f; const T = C.cloneNode(); x?.document.body.appendChild(T), await _?.render({ canvas: C, intent: "print", transform: [f, 0, 0, f, 0, 0], viewport: P }).promise, T.getContext("2d")?.drawImage(C, 0, 0); } x?.focus(), x?.print(), document.body.removeChild(g); } return Be(i) ? (i.value && s(i.value), S(i, () => { i.value && s(i.value); })) : i && s(i), { pdf: e, pages: n, info: a, print: u, download: d, getPDFDestination: r }; } const Yt = { install(i) { i.component(Te.name, Te); } }; export { Wt as PDFCommentAnnotation, Vt as PDFFreeTextAnnotation, Ut as PDFHighlightAnnotation, zt as PDFInkAnnotation, Kt as PDFStampAnnotation, Te as VuePDF, Yt as VuePDFPlugin, Yt as default, Xt as usePDF };