@libresign/pdf-elements 1.0.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { defineComponent as I, openBlock as m, createElementBlock as v, normalizeStyle as E, renderSlot as M, createElementVNode as P, withModifiers as R, createCommentVNode as $, normalizeClass as Y, Fragment as z, renderList as B, markRaw as y, resolveComponent as Z, createVNode as K, createBlock as J, withCtx as N, toDisplayString as U } from "vue";
2
- const Q = I({
1
+ import { defineComponent as V, openBlock as m, createElementBlock as v, normalizeStyle as R, renderSlot as M, createElementVNode as P, withModifiers as E, createCommentVNode as C, normalizeClass as Y, Fragment as z, renderList as H, markRaw as y, resolveComponent as I, createVNode as x, createBlock as J, withCtx as N, toDisplayString as U } from "vue";
2
+ const Q = V({
3
3
  name: "PDFPage",
4
4
  emits: ["onMeasure"],
5
5
  props: {
@@ -79,16 +79,16 @@ const Q = I({
79
79
  }
80
80
  }
81
81
  }
82
- }), V = (e, t) => {
82
+ }), Z = (e, t) => {
83
83
  const i = e.__vccOpts || e;
84
- for (const [s, o] of t)
85
- i[s] = o;
84
+ for (const [s, n] of t)
85
+ i[s] = n;
86
86
  return i;
87
87
  }, _ = { ref: "canvas" };
88
- function ee(e, t, i, s, o, a) {
88
+ function ee(e, t, i, s, n, a) {
89
89
  return m(), v("canvas", _, null, 512);
90
90
  }
91
- const te = /* @__PURE__ */ V(Q, [["render", ee], ["__scopeId", "data-v-2a60d679"]]), ie = I({
91
+ const te = /* @__PURE__ */ Z(Q, [["render", ee], ["__scopeId", "data-v-2a60d679"]]), ie = V({
92
92
  name: "DraggableElement",
93
93
  props: {
94
94
  object: {
@@ -208,7 +208,7 @@ const te = /* @__PURE__ */ V(Q, [["render", ee], ["__scopeId", "data-v-2a60d679"
208
208
  return ["top-left", "top-right", "bottom-left", "bottom-right"];
209
209
  },
210
210
  elementStyle() {
211
- const e = this.pagesScale || 1, t = this.mode === "drag", i = this.mode === "resize", s = t ? this.offsetX : 0, o = t ? this.offsetY : 0, a = i ? this.resizeOffsetX : 0, n = i ? this.resizeOffsetY : 0, h = i ? this.resizeOffsetW : 0, r = i ? this.resizeOffsetH : 0, l = this.object.x + s + a, u = this.object.y + o + n, c = this.object.width + h, d = this.object.height + r;
211
+ const e = this.pagesScale || 1, t = this.mode === "drag", i = this.mode === "resize", s = t ? this.offsetX : 0, n = t ? this.offsetY : 0, a = i ? this.resizeOffsetX : 0, o = i ? this.resizeOffsetY : 0, r = i ? this.resizeOffsetW : 0, h = i ? this.resizeOffsetH : 0, l = this.object.x + s + a, u = this.object.y + n + o, c = this.object.width + r, d = this.object.height + h;
212
212
  return {
213
213
  left: `${l * e}px`,
214
214
  top: `${u * e}px`,
@@ -218,9 +218,9 @@ const te = /* @__PURE__ */ V(Q, [["render", ee], ["__scopeId", "data-v-2a60d679"
218
218
  };
219
219
  },
220
220
  toolbarStyle() {
221
- const e = this.pagesScale || 1, t = this.mode === "drag", i = this.mode === "resize", s = t ? this.offsetX : 0, o = t ? this.offsetY : 0, a = i ? this.resizeOffsetX : 0, n = i ? this.resizeOffsetY : 0, h = i ? this.resizeOffsetW : 0, r = this.object.x + s + a, l = this.object.y + o + n, u = this.object.width + h, d = l - 60, g = d < 0 ? l + 8 : d;
221
+ const e = this.pagesScale || 1, t = this.mode === "drag", i = this.mode === "resize", s = t ? this.offsetX : 0, n = t ? this.offsetY : 0, a = i ? this.resizeOffsetX : 0, o = i ? this.resizeOffsetY : 0, r = i ? this.resizeOffsetW : 0, h = this.object.x + s + a, l = this.object.y + n + o, u = this.object.width + r, d = l - 60, g = d < 0 ? l + 8 : d;
222
222
  return {
223
- left: `${(r + u / 2) * e}px`,
223
+ left: `${(h + u / 2) * e}px`,
224
224
  top: `${g * e}px`,
225
225
  transform: "translateX(-50%)"
226
226
  };
@@ -261,9 +261,9 @@ const te = /* @__PURE__ */ V(Q, [["render", ee], ["__scopeId", "data-v-2a60d679"
261
261
  this.currentPageRect = i;
262
262
  let s = { x: 0, y: 0 };
263
263
  if (i) {
264
- const o = i.left + this.object.x * this.pagesScale, a = i.top + this.object.y * this.pagesScale;
264
+ const n = i.left + this.object.x * this.pagesScale, a = i.top + this.object.y * this.pagesScale;
265
265
  s = {
266
- x: t.left - o,
266
+ x: t.left - n,
267
267
  y: t.top - a
268
268
  };
269
269
  }
@@ -277,14 +277,14 @@ const te = /* @__PURE__ */ V(Q, [["render", ee], ["__scopeId", "data-v-2a60d679"
277
277
  const t = e.type.includes("touch") ? e.touches[0]?.clientX : e.clientX, i = e.type.includes("touch") ? e.touches[0]?.clientY : e.clientY;
278
278
  if (t === void 0 || i === void 0) return;
279
279
  this.lastMouseX = t, this.lastMouseY = i;
280
- const s = (t - this.startX) / this.pagesScale, o = (i - this.startY) / this.pagesScale;
280
+ const s = (t - this.startX) / this.pagesScale, n = (i - this.startY) / this.pagesScale;
281
281
  if (this.mode === "drag") {
282
282
  const c = this.currentPageRect;
283
283
  if (c) {
284
284
  const d = t - this.pointerOffsetDoc.x, g = i - this.pointerOffsetDoc.y, f = (d - c.left) / this.pagesScale, b = (g - c.top) / this.pagesScale;
285
285
  this.offsetX = f - this.object.x, this.offsetY = b - this.object.y;
286
286
  } else
287
- this.offsetX = s, this.offsetY = o;
287
+ this.offsetX = s, this.offsetY = n;
288
288
  this.onDragMove(t, i), this.isBeingDraggedGlobally && this.onUpdate({
289
289
  _globalDrag: !0,
290
290
  _mouseX: t,
@@ -293,25 +293,25 @@ const te = /* @__PURE__ */ V(Q, [["render", ee], ["__scopeId", "data-v-2a60d679"
293
293
  return;
294
294
  }
295
295
  const a = 16 / (this.pagesScale || 1);
296
- let n = this.startWidth, h = this.startHeight, r = this.startLeft, l = this.startTop;
296
+ let o = this.startWidth, r = this.startHeight, h = this.startLeft, l = this.startTop;
297
297
  const u = this.direction.includes("right") ? s : this.direction.includes("left") ? -s : 0;
298
- if (n = this.startWidth + u, n < a && (n = a), h = n / this.aspectRatio, this.direction.includes("left") && (r = this.startLeft + (this.startWidth - n), r < 0)) {
299
- const c = -r;
300
- r = 0, n = n - c, h = n / this.aspectRatio;
298
+ if (o = this.startWidth + u, o < a && (o = a), r = o / this.aspectRatio, this.direction.includes("left") && (h = this.startLeft + (this.startWidth - o), h < 0)) {
299
+ const c = -h;
300
+ h = 0, o = o - c, r = o / this.aspectRatio;
301
301
  }
302
- if (this.direction.includes("top") && (l = this.startTop + (this.startHeight - h), l < 0)) {
302
+ if (this.direction.includes("top") && (l = this.startTop + (this.startHeight - r), l < 0)) {
303
303
  const c = -l;
304
- l = 0, h = h - c, n = h * this.aspectRatio, this.direction.includes("left") && (r = this.startLeft + (this.startWidth - n));
304
+ l = 0, r = r - c, o = r * this.aspectRatio, this.direction.includes("left") && (h = this.startLeft + (this.startWidth - o));
305
305
  }
306
- if (r + n > this.pageWidth) {
307
- const c = r + n - this.pageWidth;
308
- n -= c, h = n / this.aspectRatio;
306
+ if (h + o > this.pageWidth) {
307
+ const c = h + o - this.pageWidth;
308
+ o -= c, r = o / this.aspectRatio;
309
309
  }
310
- if (l + h > this.pageHeight) {
311
- const c = l + h - this.pageHeight;
312
- h -= c, n = h * this.aspectRatio, this.direction.includes("left") && (r = this.startLeft + (this.startWidth - n));
310
+ if (l + r > this.pageHeight) {
311
+ const c = l + r - this.pageHeight;
312
+ r -= c, o = r * this.aspectRatio, this.direction.includes("left") && (h = this.startLeft + (this.startWidth - o));
313
313
  }
314
- this.resizeOffsetX = r - this.object.x, this.resizeOffsetY = l - this.object.y, this.resizeOffsetW = n - this.object.width, this.resizeOffsetH = h - this.object.height, this.rafId = null;
314
+ this.resizeOffsetX = h - this.object.x, this.resizeOffsetY = l - this.object.y, this.resizeOffsetW = o - this.object.width, this.resizeOffsetH = r - this.object.height, this.rafId = null;
315
315
  })));
316
316
  },
317
317
  stopInteraction() {
@@ -348,12 +348,12 @@ const te = /* @__PURE__ */ V(Q, [["render", ee], ["__scopeId", "data-v-2a60d679"
348
348
  }
349
349
  }
350
350
  }), se = { class: "draggable-wrapper" }, ne = ["onMousedown", "onTouchstart"];
351
- function oe(e, t, i, s, o, a) {
351
+ function oe(e, t, i, s, n, a) {
352
352
  return m(), v("div", se, [
353
353
  e.isSelected && !e.isBeingDraggedGlobally && e.showSelectionUi && e.showDefaultActions ? (m(), v("div", {
354
354
  key: 0,
355
355
  class: "actions-toolbar",
356
- style: E(e.toolbarStyle)
356
+ style: R(e.toolbarStyle)
357
357
  }, [
358
358
  M(e.$slots, "actions", {
359
359
  object: e.object,
@@ -364,7 +364,7 @@ function oe(e, t, i, s, o, a) {
364
364
  class: "action-btn",
365
365
  type: "button",
366
366
  title: "Duplicate",
367
- onClick: t[0] || (t[0] = R((...n) => e.onDuplicate && e.onDuplicate(...n), ["stop"]))
367
+ onClick: t[0] || (t[0] = E((...o) => e.onDuplicate && e.onDuplicate(...o), ["stop"]))
368
368
  }, [...t[5] || (t[5] = [
369
369
  P("svg", {
370
370
  width: "16",
@@ -379,7 +379,7 @@ function oe(e, t, i, s, o, a) {
379
379
  class: "action-btn",
380
380
  type: "button",
381
381
  title: "Delete",
382
- onClick: t[1] || (t[1] = R((...n) => e.onDelete && e.onDelete(...n), ["stop"]))
382
+ onClick: t[1] || (t[1] = E((...o) => e.onDelete && e.onDelete(...o), ["stop"]))
383
383
  }, [...t[6] || (t[6] = [
384
384
  P("svg", {
385
385
  width: "16",
@@ -391,15 +391,15 @@ function oe(e, t, i, s, o, a) {
391
391
  ], -1)
392
392
  ])])
393
393
  ], !0)
394
- ], 4)) : $("", !0),
394
+ ], 4)) : C("", !0),
395
395
  P("div", {
396
396
  class: Y(["draggable-element", { selected: e.isSelected && e.showSelectionUi }]),
397
397
  draggable: "false",
398
- onDragstart: t[2] || (t[2] = R(() => {
398
+ onDragstart: t[2] || (t[2] = E(() => {
399
399
  }, ["prevent"])),
400
- style: E([e.elementStyle, e.dragElementStyle]),
401
- onMousedown: t[3] || (t[3] = (...n) => e.handleElementClick && e.handleElementClick(...n)),
402
- onTouchstart: t[4] || (t[4] = (...n) => e.handleElementClick && e.handleElementClick(...n))
400
+ style: R([e.elementStyle, e.dragElementStyle]),
401
+ onMousedown: t[3] || (t[3] = (...o) => e.handleElementClick && e.handleElementClick(...o)),
402
+ onTouchstart: t[4] || (t[4] = (...o) => e.handleElementClick && e.handleElementClick(...o))
403
403
  }, [
404
404
  M(e.$slots, "default", {
405
405
  object: e.object,
@@ -407,27 +407,27 @@ function oe(e, t, i, s, o, a) {
407
407
  onDelete: e.onDelete,
408
408
  onResize: e.startResizeFromSlot
409
409
  }, void 0, !0),
410
- e.isSelected && e.showSelectionUi ? (m(!0), v(z, { key: 0 }, B(e.resizeDirections, (n) => (m(), v("button", {
411
- key: n,
412
- class: Y(["resize-handle", `handle-${n}`]),
410
+ e.isSelected && e.showSelectionUi ? (m(!0), v(z, { key: 0 }, H(e.resizeDirections, (o) => (m(), v("button", {
411
+ key: o,
412
+ class: Y(["resize-handle", `handle-${o}`]),
413
413
  type: "button",
414
- onMousedown: R((h) => e.startResize(n, h), ["stop", "prevent"]),
415
- onTouchstart: R((h) => e.startResize(n, h), ["stop", "prevent"])
416
- }, null, 42, ne))), 128)) : $("", !0)
414
+ onMousedown: E((r) => e.startResize(o, r), ["stop", "prevent"]),
415
+ onTouchstart: E((r) => e.startResize(o, r), ["stop", "prevent"])
416
+ }, null, 42, ne))), 128)) : C("", !0)
417
417
  ], 38)
418
418
  ]);
419
419
  }
420
- const ae = /* @__PURE__ */ V(ie, [["render", oe], ["__scopeId", "data-v-c700849e"]]);
421
- let H = null, A = null, W = null, X = null;
420
+ const ae = /* @__PURE__ */ Z(ie, [["render", oe], ["__scopeId", "data-v-c700849e"]]);
421
+ let B = null, A = null, W = null, X = null;
422
422
  function re(e) {
423
423
  const t = e;
424
424
  return t.default?.PDFWorker ? t.default : t;
425
425
  }
426
426
  function he() {
427
- return A || (A = import("./pdf-uHvE5neP.mjs").then(re)), A;
427
+ return A || (A = import("./pdf-l6QfMa5e.mjs").then(re)), A;
428
428
  }
429
429
  function le() {
430
- return W || (W = import("./pdf.worker.min-DmO9Xdfo.mjs").then(
430
+ return W || (W = import("./pdf.worker.min-BIavBz9-.mjs").then(
431
431
  (e) => e.default
432
432
  )), W;
433
433
  }
@@ -441,10 +441,10 @@ async function ce(e) {
441
441
  }
442
442
  }
443
443
  async function de(e) {
444
- return H || (await ce(e), H = new e.PDFWorker({})), H;
444
+ return B || (await ce(e), B = new e.PDFWorker({})), B;
445
445
  }
446
- function Ce(e) {
447
- X = e, H = null, A && A.then((t) => {
446
+ function je(e) {
447
+ X = e, B = null, A && A.then((t) => {
448
448
  t?.GlobalWorkerOptions && (t.GlobalWorkerOptions.workerSrc = e);
449
449
  }).catch((t) => {
450
450
  console.warn("setWorkerPath: failed to update pdfjs workerSrc immediately", t);
@@ -456,32 +456,32 @@ function G(e) {
456
456
  s.onload = () => t(s.result), s.onerror = i, s.readAsArrayBuffer(e);
457
457
  });
458
458
  }
459
- async function x(e, t = {}) {
460
- const i = await he(), s = await de(i), o = e instanceof ArrayBuffer, a = ArrayBuffer.isView(e), n = typeof Blob < "u" && e instanceof Blob;
461
- if (e && typeof e == "object" && !o && !a && !n)
459
+ async function K(e, t = {}) {
460
+ const i = await he(), s = await de(i), n = e instanceof ArrayBuffer, a = ArrayBuffer.isView(e), o = typeof Blob < "u" && e instanceof Blob;
461
+ if (e && typeof e == "object" && !n && !a && !o)
462
462
  return i.getDocument({ ...e, ...t, worker: s }).promise;
463
463
  if (typeof e == "string")
464
464
  return i.getDocument({ url: e, ...t, worker: s }).promise;
465
- if (n) {
466
- const r = await G(e);
467
- return i.getDocument({ data: r, ...t, worker: s }).promise;
465
+ if (o) {
466
+ const h = await G(e);
467
+ return i.getDocument({ data: h, ...t, worker: s }).promise;
468
468
  }
469
- const h = o ? e : new Uint8Array(
469
+ const r = n ? e : new Uint8Array(
470
470
  e.buffer,
471
471
  e.byteOffset,
472
472
  e.byteLength
473
473
  );
474
- return i.getDocument({ data: h, ...t, worker: s }).promise;
474
+ return i.getDocument({ data: r, ...t, worker: s }).promise;
475
475
  }
476
- function F(e, t, i, s, o, a) {
476
+ function L(e, t, i, s, n, a) {
477
477
  return {
478
- x: Math.max(0, Math.min(e, o - i)),
478
+ x: Math.max(0, Math.min(e, n - i)),
479
479
  y: Math.max(0, Math.min(t, a - s))
480
480
  };
481
481
  }
482
- function ge(e, t, i, s, o, a) {
483
- const n = Math.max(0, e), h = Math.max(0, t), r = Math.min(o, e + i), l = Math.min(a, t + s);
484
- return r <= n || l <= h ? 0 : (r - n) * (l - h);
482
+ function ge(e, t, i, s, n, a) {
483
+ const o = Math.max(0, e), r = Math.max(0, t), h = Math.min(n, e + i), l = Math.min(a, t + s);
484
+ return h <= o || l <= r ? 0 : (h - o) * (l - r);
485
485
  }
486
486
  function ue(e, t, i = 300) {
487
487
  return {
@@ -500,7 +500,7 @@ function q(e, t) {
500
500
  function pe(e, t) {
501
501
  return !e || !t ? !1 : e.allObjects.some((i) => i.some((s) => s.id === t));
502
502
  }
503
- function L(e, t) {
503
+ function F(e, t) {
504
504
  if (!(!e || !t)) {
505
505
  for (let i = 0; i < e.allObjects.length; i++)
506
506
  if (e.allObjects[i].some((s) => s.id === t))
@@ -508,28 +508,28 @@ function L(e, t) {
508
508
  }
509
509
  }
510
510
  function me(e, t, i, s) {
511
- const o = e?.allObjects?.[t];
512
- if (!o) return !1;
513
- const a = o.findIndex((n) => n.id === i);
514
- return a === -1 ? !1 : (o.splice(a, 1, { ...o[a], ...s }), !0);
511
+ const n = e?.allObjects?.[t];
512
+ if (!n) return !1;
513
+ const a = n.findIndex((o) => o.id === i);
514
+ return a === -1 ? !1 : (n.splice(a, 1, { ...n[a], ...s }), !0);
515
515
  }
516
516
  function ve(e, t, i) {
517
517
  const s = e?.allObjects?.[t];
518
518
  if (!s) return !1;
519
- const o = s.findIndex((a) => a.id === i);
520
- return o === -1 ? !1 : (s.splice(o, 1), !0);
519
+ const n = s.findIndex((a) => a.id === i);
520
+ return n === -1 ? !1 : (s.splice(n, 1), !0);
521
521
  }
522
522
  function we(e, t, i, s) {
523
- const o = e[t];
524
- if (o)
525
- return o;
526
- const a = i.getCanvasMeasurement(), n = {
523
+ const n = e[t];
524
+ if (n)
525
+ return n;
526
+ const a = i.getCanvasMeasurement(), o = {
527
527
  width: a.canvasWidth / s,
528
528
  height: a.canvasHeight / s
529
529
  };
530
- return e[t] = n, n;
530
+ return e[t] = o, o;
531
531
  }
532
- const be = I({
532
+ const be = V({
533
533
  name: "PDFElements",
534
534
  emits: ["pdf-elements:end-init", "pdf-elements:delete-object", "pdf-elements:object-click"],
535
535
  components: {
@@ -593,6 +593,10 @@ const be = I({
593
593
  type: Boolean,
594
594
  default: !1
595
595
  },
596
+ pageAriaLabel: {
597
+ type: Function,
598
+ default: null
599
+ },
596
600
  pdfjsOptions: {
597
601
  type: Object,
598
602
  default: () => ({})
@@ -658,29 +662,29 @@ const be = I({
658
662
  this.autoFitApplied = !1;
659
663
  for (let t = 0; t < this.initFiles.length; t++) {
660
664
  const i = this.initFiles[t], s = this.initFileNames[t] || `document-${t + 1}.pdf`;
661
- let o;
665
+ let n;
662
666
  if (i instanceof Blob) {
663
- const r = await G(i);
664
- o = await x({ data: r }, this.pdfjsOptions);
667
+ const h = await G(i);
668
+ n = await K({ data: h }, this.pdfjsOptions);
665
669
  } else
666
- o = await x(i, this.pdfjsOptions);
667
- const a = [], n = Array(o.numPages).fill(0);
668
- for (let r = 1; r <= o.numPages; r++) {
669
- const l = o.getPage(r);
670
+ n = await K(i, this.pdfjsOptions);
671
+ const a = [], o = Array(n.numPages).fill(0);
672
+ for (let h = 1; h <= n.numPages; h++) {
673
+ const l = n.getPage(h);
670
674
  l.then((u) => {
671
- n.splice(r - 1, 1, u.getViewport({ scale: 1 }).width), this.autoFitZoom && this.scheduleAutoFitZoom();
675
+ o.splice(h - 1, 1, u.getViewport({ scale: 1 }).width), this.autoFitZoom && this.scheduleAutoFitZoom();
672
676
  }), a.push(l);
673
677
  }
674
- const h = y(a);
678
+ const r = y(a);
675
679
  e.push({
676
680
  name: s,
677
681
  file: i,
678
- pdfDoc: y(o),
679
- numPages: o.numPages,
680
- pages: h,
681
- pageWidths: n,
682
- pagesScale: Array(o.numPages).fill(this.scale),
683
- allObjects: Array(o.numPages).fill(0).map(() => [])
682
+ pdfDoc: y(n),
683
+ numPages: n.numPages,
684
+ pages: r,
685
+ pageWidths: o,
686
+ pagesScale: Array(n.numPages).fill(this.scale),
687
+ allObjects: Array(n.numPages).fill(0).map(() => [])
684
688
  });
685
689
  }
686
690
  this.pdfDocuments = e, this._pageMeasurementCache = y({}), e.length && (this.selectedDocIndex = 0, this.selectedPageIndex = 0, this.$emit("pdf-elements:end-init", { docsCount: e.length }), this.$nextTick(() => {
@@ -690,14 +694,14 @@ const be = I({
690
694
  selectPage(e, t) {
691
695
  this.selectedDocIndex = e, this.selectedPageIndex = t;
692
696
  },
693
- startDraggingElement(e, t, i, s, o, a, n) {
694
- this.isDraggingElement = !0, this.draggingObject = { ...i }, this.draggingDocIndex = e, this.draggingPageIndex = t, this.draggingScale = this.getDisplayedPageScale(e, t), this.lastMouseClientPos.x = s, this.lastMouseClientPos.y = o, this.draggingElementShift = n && typeof n.x == "number" && typeof n.y == "number" ? n : { x: 0, y: 0 }, this.cachePageBounds();
695
- const h = this.getPageRect(e, t);
697
+ startDraggingElement(e, t, i, s, n, a, o) {
698
+ this.isDraggingElement = !0, this.draggingObject = { ...i }, this.draggingDocIndex = e, this.draggingPageIndex = t, this.draggingScale = this.getDisplayedPageScale(e, t), this.lastMouseClientPos.x = s, this.lastMouseClientPos.y = n, this.draggingElementShift = o && typeof o.x == "number" && typeof o.y == "number" ? o : { x: 0, y: 0 }, this.cachePageBounds();
699
+ const r = this.getPageRect(e, t);
696
700
  if (a && typeof a.x == "number" && typeof a.y == "number")
697
- this.draggingInitialMouseOffset.x = a.x, this.draggingInitialMouseOffset.y = a.y, this.draggingClientPosition.x = s - this.draggingInitialMouseOffset.x, this.draggingClientPosition.y = o - this.draggingInitialMouseOffset.y;
698
- else if (h) {
699
- const r = h.left + i.x * this.draggingScale, l = h.top + i.y * this.draggingScale;
700
- this.draggingInitialMouseOffset.x = s - r, this.draggingInitialMouseOffset.y = o - l, this.draggingClientPosition.x = s - this.draggingInitialMouseOffset.x, this.draggingClientPosition.y = o - this.draggingInitialMouseOffset.y;
701
+ this.draggingInitialMouseOffset.x = a.x, this.draggingInitialMouseOffset.y = a.y, this.draggingClientPosition.x = s - this.draggingInitialMouseOffset.x, this.draggingClientPosition.y = n - this.draggingInitialMouseOffset.y;
702
+ else if (r) {
703
+ const h = r.left + i.x * this.draggingScale, l = r.top + i.y * this.draggingScale;
704
+ this.draggingInitialMouseOffset.x = s - h, this.draggingInitialMouseOffset.y = n - l, this.draggingClientPosition.x = s - this.draggingInitialMouseOffset.x, this.draggingClientPosition.y = n - this.draggingInitialMouseOffset.y;
701
705
  }
702
706
  },
703
707
  updateDraggingPosition(e, t) {
@@ -717,8 +721,8 @@ const be = I({
717
721
  );
718
722
  i !== void 0 && this.$nextTick(() => {
719
723
  this.selectPage(t, i);
720
- const s = `draggable${t}-${i}-${e}`, o = this.$refs[s];
721
- o && Array.isArray(o) && o[0] && (o[0].isSelected = !0);
724
+ const s = `draggable${t}-${i}-${e}`, n = this.$refs[s];
725
+ n && Array.isArray(n) && n[0] && (n[0].isSelected = !0);
722
726
  });
723
727
  }
724
728
  this.isDraggingElement = !1, this.draggingObject = null, this.draggingDocIndex = -1, this.draggingPageIndex = -1, this.draggingElementShift = { x: 0, y: 0 }, this.pendingDragClientPos = null;
@@ -727,33 +731,33 @@ const be = I({
727
731
  this.pdfDocuments.length && (this.attachAddingListeners(), this.isAddingMode = !0, this.previewElement = { ...e }, this.previewPageDocIndex = 0, this.previewPageIndex = 0, this.previewVisible = !1, this.previewScale = { x: 1, y: 1 }, this.cachePageBounds());
728
732
  },
729
733
  cachePageBounds() {
730
- const e = {}, t = [], i = this.$el, s = i?.scrollTop || 0, o = i?.clientHeight || 0;
731
- if (!this.isAddingMode && !this.isDraggingElement && s === this._lastPageBoundsScrollTop && o === this._lastPageBoundsClientHeight)
734
+ const e = {}, t = [], i = this.$el, s = i?.scrollTop || 0, n = i?.clientHeight || 0;
735
+ if (!this.isAddingMode && !this.isDraggingElement && s === this._lastPageBoundsScrollTop && n === this._lastPageBoundsClientHeight)
732
736
  return;
733
- this._lastPageBoundsScrollTop = s, this._lastPageBoundsClientHeight = o;
734
- const { minY: a, maxY: n } = ue(s, o);
735
- for (let h = 0; h < this.pdfDocuments.length; h++)
736
- for (let r = 0; r < this.pdfDocuments[h].pages.length; r++) {
737
- const l = this.getPageCanvasElement(h, r);
737
+ this._lastPageBoundsScrollTop = s, this._lastPageBoundsClientHeight = n;
738
+ const { minY: a, maxY: o } = ue(s, n);
739
+ for (let r = 0; r < this.pdfDocuments.length; r++)
740
+ for (let h = 0; h < this.pdfDocuments[r].pages.length; h++) {
741
+ const l = this.getPageCanvasElement(r, h);
738
742
  if (!l) continue;
739
- if (o) {
743
+ if (n) {
740
744
  const d = l.closest(".page-wrapper") || l, g = d.offsetTop || 0, f = d.offsetHeight || 0;
741
- if (!fe(g, f, a, n))
745
+ if (!fe(g, f, a, o))
742
746
  continue;
743
747
  }
744
748
  const u = l.getBoundingClientRect(), c = {
745
- docIndex: h,
746
- pageIndex: r,
749
+ docIndex: r,
750
+ pageIndex: h,
747
751
  rect: u
748
752
  };
749
- e[`${h}-${r}`] = c, t.push(c);
753
+ e[`${r}-${h}`] = c, t.push(c);
750
754
  }
751
755
  this._pagesBoundingRects = y(e), this._pagesBoundingRectsList = y(t), this.pageBoundsVersion++;
752
756
  },
753
757
  cachePageBoundsForPage(e, t) {
754
758
  const i = this.getPageCanvasElement(e, t);
755
759
  if (!i) return;
756
- const s = i.getBoundingClientRect(), o = {
760
+ const s = i.getBoundingClientRect(), n = {
757
761
  ...this._pagesBoundingRects,
758
762
  [`${e}-${t}`]: {
759
763
  docIndex: e,
@@ -761,7 +765,7 @@ const be = I({
761
765
  rect: s
762
766
  }
763
767
  };
764
- this._pagesBoundingRects = y(o), this._pagesBoundingRectsList = y(Object.values(o)), this.pageBoundsVersion++;
768
+ this._pagesBoundingRects = y(n), this._pagesBoundingRectsList = y(Object.values(n)), this.pageBoundsVersion++;
765
769
  },
766
770
  getPageBoundsMap() {
767
771
  return this._pagesBoundingRects || {};
@@ -795,8 +799,8 @@ const be = I({
795
799
  if (l && s)
796
800
  return l / s;
797
801
  }
798
- const n = i.pagesScale[t] || 1, h = this.visualScale && this.scale ? this.visualScale / this.scale : 1;
799
- return n * h;
802
+ const o = i.pagesScale[t] || 1, r = this.visualScale && this.scale ? this.visualScale / this.scale : 1;
803
+ return o * r;
800
804
  },
801
805
  getPageComponent(e, t) {
802
806
  const i = this.$refs[`page${e}-${t}`];
@@ -808,8 +812,8 @@ const be = I({
808
812
  },
809
813
  onViewportScroll() {
810
814
  this.viewportRafId || (this.viewportRafId = window.requestAnimationFrame(() => {
811
- const e = this.$el, t = e?.scrollTop || 0, i = e?.clientWidth || 0, s = t !== this.lastScrollTop, o = i !== this.lastClientWidth;
812
- this.lastScrollTop = t, this.lastClientWidth = i, (this.isAddingMode || this.isDraggingElement) && (s || o) && this.cachePageBounds(), this.autoFitZoom && !this.isAddingMode && !this.isDraggingElement && i && o && (this.lastContainerWidth = i, this.autoFitApplied = !1, this.scheduleAutoFitZoom()), this.viewportRafId = 0;
815
+ const e = this.$el, t = e?.scrollTop || 0, i = e?.clientWidth || 0, s = t !== this.lastScrollTop, n = i !== this.lastClientWidth;
816
+ this.lastScrollTop = t, this.lastClientWidth = i, (this.isAddingMode || this.isDraggingElement) && (s || n) && this.cachePageBounds(), this.autoFitZoom && !this.isAddingMode && !this.isDraggingElement && i && n && (this.lastContainerWidth = i, this.autoFitApplied = !1, this.scheduleAutoFitZoom()), this.viewportRafId = 0;
813
817
  }));
814
818
  },
815
819
  handleMouseMove(e) {
@@ -819,10 +823,10 @@ const be = I({
819
823
  this.hoverRafId = 0;
820
824
  const s = this.pendingHoverClientPos;
821
825
  if (!s) return;
822
- const o = s.x, a = s.y;
823
- let n = null;
824
- if (this.lastHoverRect && o >= this.lastHoverRect.left && o <= this.lastHoverRect.right && a >= this.lastHoverRect.top && a <= this.lastHoverRect.bottom)
825
- n = {
826
+ const n = s.x, a = s.y;
827
+ let o = null;
828
+ if (this.lastHoverRect && n >= this.lastHoverRect.left && n <= this.lastHoverRect.right && a >= this.lastHoverRect.top && a <= this.lastHoverRect.bottom)
829
+ o = {
826
830
  docIndex: this.previewPageDocIndex,
827
831
  pageIndex: this.previewPageIndex,
828
832
  rect: this.lastHoverRect
@@ -830,37 +834,37 @@ const be = I({
830
834
  else {
831
835
  const S = this.getPageBoundsList().length ? this.getPageBoundsList() : Object.values(this.getPageBoundsMap());
832
836
  for (let w = 0; w < S.length; w++) {
833
- const j = S[w], C = j.rect;
834
- if (o >= C.left && o <= C.right && a >= C.top && a <= C.bottom) {
835
- n = j;
837
+ const $ = S[w], j = $.rect;
838
+ if (n >= j.left && n <= j.right && a >= j.top && a <= j.bottom) {
839
+ o = $;
836
840
  break;
837
841
  }
838
842
  }
839
843
  }
840
- if (!n) {
844
+ if (!o) {
841
845
  this.previewVisible = !1, this.previewScale = { x: 1, y: 1 }, this.lastHoverRect = null;
842
846
  return;
843
847
  }
844
- this.previewPageDocIndex = n.docIndex, this.previewPageIndex = n.pageIndex, this.lastHoverRect = n.rect;
845
- const h = this.getPageCanvasElement(n.docIndex, n.pageIndex), r = this.pdfDocuments[n.docIndex]?.pagesScale?.[n.pageIndex] || 1, l = h?.width || n.rect.width, u = h?.height || n.rect.height, c = l ? n.rect.width / l : 1, d = u ? n.rect.height / u : 1, g = (o - n.rect.left) / c / r, f = (a - n.rect.top) / d / r, b = l / r, D = u / r;
846
- this.previewScale.x = r, this.previewScale.y = r;
847
- let p = g - this.previewElement.width / 2, O = f - this.previewElement.height / 2;
848
- p = Math.max(0, Math.min(p, b - this.previewElement.width)), O = Math.max(0, Math.min(O, D - this.previewElement.height)), this.previewPosition.x = p, this.previewPosition.y = O, this.previewVisible = !0;
848
+ this.previewPageDocIndex = o.docIndex, this.previewPageIndex = o.pageIndex, this.lastHoverRect = o.rect;
849
+ const r = this.getPageCanvasElement(o.docIndex, o.pageIndex), h = this.pdfDocuments[o.docIndex]?.pagesScale?.[o.pageIndex] || 1, l = r?.width || o.rect.width, u = r?.height || o.rect.height, c = l ? o.rect.width / l : 1, d = u ? o.rect.height / u : 1, g = (n - o.rect.left) / c / h, f = (a - o.rect.top) / d / h, b = l / h, O = u / h;
850
+ this.previewScale.x = h, this.previewScale.y = h;
851
+ let p = g - this.previewElement.width / 2, D = f - this.previewElement.height / 2;
852
+ p = Math.max(0, Math.min(p, b - this.previewElement.width)), D = Math.max(0, Math.min(D, O - this.previewElement.height)), this.previewPosition.x = p, this.previewPosition.y = D, this.previewVisible = !0;
849
853
  })));
850
854
  },
851
855
  handleOverlayClick(e, t, i) {
852
856
  if (!this.emitObjectClick) return;
853
- const { x: s, y: o } = this.getPointerPosition(i);
854
- if (!Number.isFinite(s) || !Number.isFinite(o)) return;
857
+ const { x: s, y: n } = this.getPointerPosition(i);
858
+ if (!Number.isFinite(s) || !Number.isFinite(n)) return;
855
859
  this.cachePageBoundsForPage(e, t);
856
860
  const a = this.getPageRect(e, t);
857
861
  if (!a) return;
858
- const n = this.getDisplayedPageScale(e, t) || 1, h = (s - a.left) / n, r = (o - a.top) / n, u = this.pdfDocuments?.[e]?.allObjects?.[t] || [];
862
+ const o = this.getDisplayedPageScale(e, t) || 1, r = (s - a.left) / o, h = (n - a.top) / o, u = this.pdfDocuments?.[e]?.allObjects?.[t] || [];
859
863
  if (u.length === 0) return;
860
864
  let c = null;
861
865
  for (let d = u.length - 1; d >= 0; d--) {
862
- const g = u[d], f = Number(g.x), b = Number(g.y), D = Number(g.width), p = Number(g.height);
863
- if ([f, b, D, p].every(Number.isFinite) && h >= f && h <= f + D && r >= b && r <= b + p) {
866
+ const g = u[d], f = Number(g.x), b = Number(g.y), O = Number(g.width), p = Number(g.height);
867
+ if ([f, b, O, p].every(Number.isFinite) && r >= f && r <= f + O && h >= b && h <= b + p) {
864
868
  c = g;
865
869
  break;
866
870
  }
@@ -875,6 +879,22 @@ const be = I({
875
879
  handleKeyDown(e) {
876
880
  e.key === "Escape" && this.isAddingMode && this.cancelAdding();
877
881
  },
882
+ getOverlayAriaLabel(e, t) {
883
+ const i = this.pdfDocuments?.[e], s = i?.name ?? `Document ${e + 1}`, n = this.pdfDocuments?.length ?? 1, a = i?.numPages ?? 0, o = t + 1;
884
+ if (this.pageAriaLabel)
885
+ return this.pageAriaLabel({ docIndex: e, docName: s, totalDocs: n, pageNumber: o, totalPages: a, isAddingMode: this.isAddingMode });
886
+ const r = n > 1 ? `Document ${e + 1} of ${n} (${s}), ` : "";
887
+ return this.isAddingMode ? `${r}Page ${o} of ${a}. Press Enter or Space to place here.` : `${r}Page ${o} of ${a}.`;
888
+ },
889
+ handleOverlayKeyDown(e, t, i) {
890
+ if (!this.isAddingMode || !this.previewElement || i.key !== "Enter" && i.key !== " ") return;
891
+ i.preventDefault();
892
+ const s = this.getPageWidth(e, t), n = this.getPageHeight(e, t), a = this.getDisplayedPageScale(e, t) || 1;
893
+ this.previewPageDocIndex = e, this.previewPageIndex = t, this.previewScale = { x: a, y: a }, this.previewPosition = {
894
+ x: Math.round((s - this.previewElement.width) / 2),
895
+ y: Math.round((n - this.previewElement.height) / 2)
896
+ }, this.previewVisible = !0, this.finishAdding();
897
+ },
878
898
  handleWheel(e) {
879
899
  if (!e.ctrlKey) return;
880
900
  e.preventDefault();
@@ -900,10 +920,10 @@ const be = I({
900
920
  return;
901
921
  }
902
922
  t.allObjects[this.previewPageIndex].push(e);
903
- const o = this.previewPageIndex, a = this.previewPageDocIndex, n = e.id;
923
+ const n = this.previewPageIndex, a = this.previewPageDocIndex, o = e.id;
904
924
  this.cancelAdding(), this.$nextTick(() => {
905
- const h = `draggable${a}-${o}-${n}`, r = this.$refs[h];
906
- r && Array.isArray(r) && r[0] && (r[0].isSelected = !0);
925
+ const r = `draggable${a}-${n}-${o}`, h = this.$refs[r];
926
+ h && Array.isArray(h) && h[0] && (h[0].isSelected = !0);
907
927
  });
908
928
  },
909
929
  cancelAdding() {
@@ -921,12 +941,12 @@ const be = I({
921
941
  },
922
942
  addObjectToPage(e, t = this.selectedPageIndex, i = this.selectedDocIndex) {
923
943
  if (i < 0 || i >= this.pdfDocuments.length || t < 0 || t >= this.pdfDocuments[i].pages.length) return !1;
924
- const s = this.pdfDocuments[i], o = this.getPageComponent(i, t);
925
- if (!o) return !1;
944
+ const s = this.pdfDocuments[i], n = this.getPageComponent(i, t);
945
+ if (!n) return !1;
926
946
  let a = e;
927
947
  (!a.id || this.objectIdExists(i, a.id)) && (a = { ...a, id: this.generateObjectId() });
928
- const n = this.getCachedMeasurement(i, t, o), h = n.width, r = n.height;
929
- return a.x < 0 || a.y < 0 || a.x + a.width > h || a.y + a.height > r ? !1 : (s.allObjects[t].push(a), this.objectIndexCache[`${i}-${a.id}`] = t, !0);
948
+ const o = this.getCachedMeasurement(i, t, n), r = o.width, h = o.height;
949
+ return a.x < 0 || a.y < 0 || a.x + a.width > r || a.y + a.height > h ? !1 : (s.allObjects[t].push(a), this.objectIndexCache[`${i}-${a.id}`] = t, !0);
930
950
  },
931
951
  objectIdExists(e, t) {
932
952
  if (!t) return !1;
@@ -936,8 +956,8 @@ const be = I({
936
956
  return pe(s, t);
937
957
  },
938
958
  updateObjectInPage(e, t, i, s) {
939
- const o = this.pdfDocuments[e];
940
- me(o, t, i, s);
959
+ const n = this.pdfDocuments[e];
960
+ me(n, t, i, s);
941
961
  },
942
962
  removeObjectFromPage(e, t, i) {
943
963
  const s = this.pdfDocuments[e];
@@ -946,20 +966,20 @@ const be = I({
946
966
  getAllObjects(e = this.selectedDocIndex) {
947
967
  if (e < 0 || e >= this.pdfDocuments.length) return [];
948
968
  const t = this.pdfDocuments[e], i = [];
949
- return t.allObjects.forEach((s, o) => {
950
- const a = this.getPageComponent(e, o);
969
+ return t.allObjects.forEach((s, n) => {
970
+ const a = this.getPageComponent(e, n);
951
971
  if (!a) return;
952
- const h = this.getCachedMeasurement(e, o, a).height, r = t.pagesScale[o] || 1;
972
+ const r = this.getCachedMeasurement(e, n, a).height, h = t.pagesScale[n] || 1;
953
973
  s.forEach((l) => {
954
974
  i.push({
955
975
  ...l,
956
- pageIndex: o,
957
- pageNumber: o + 1,
958
- scale: r,
976
+ pageIndex: n,
977
+ pageNumber: n + 1,
978
+ scale: h,
959
979
  normalizedCoordinates: {
960
980
  llx: Math.round(l.x),
961
- lly: Math.round(h - l.y),
962
- ury: Math.round(h - l.y - l.height),
981
+ lly: Math.round(r - l.y),
982
+ ury: Math.round(r - l.y - l.height),
963
983
  width: Math.round(l.width),
964
984
  height: Math.round(l.height)
965
985
  }
@@ -969,46 +989,46 @@ const be = I({
969
989
  },
970
990
  updateObject(e, t, i) {
971
991
  if (e < 0 || e >= this.pdfDocuments.length) return;
972
- const s = this.pdfDocuments[e], o = `${e}-${t}`;
973
- let a = this.objectIndexCache[o];
974
- if (a === void 0 && (a = L(s, t), a !== void 0 && (this.objectIndexCache[o] = a)), a === void 0) return;
975
- const n = s.allObjects[a]?.find((h) => h.id === t);
976
- if (n) {
992
+ const s = this.pdfDocuments[e], n = `${e}-${t}`;
993
+ let a = this.objectIndexCache[n];
994
+ if (a === void 0 && (a = F(s, t), a !== void 0 && (this.objectIndexCache[n] = a)), a === void 0) return;
995
+ const o = s.allObjects[a]?.find((r) => r.id === t);
996
+ if (o) {
977
997
  if (i._globalDrag && i._mouseX !== void 0 && i._mouseY !== void 0) {
978
- const h = i._mouseX, r = i._mouseY, l = this.getPageBoundsMap();
998
+ const r = i._mouseX, h = i._mouseY, l = this.getPageBoundsMap();
979
999
  (!l || Object.keys(l).length === 0) && this.cachePageBounds();
980
1000
  const u = this.getPageRect(e, a);
981
1001
  if (u) {
982
- const c = this.getDisplayedPageScale(e, a), d = (h - u.left - this.draggingElementShift.x) / c - this.draggingInitialMouseOffset.x / c, g = (r - u.top - this.draggingElementShift.y) / c - this.draggingInitialMouseOffset.y / c;
1002
+ const c = this.getDisplayedPageScale(e, a), d = (r - u.left - this.draggingElementShift.x) / c - this.draggingInitialMouseOffset.x / c, g = (h - u.top - this.draggingElementShift.y) / c - this.draggingInitialMouseOffset.y / c;
983
1003
  this.updateObjectInPage(e, a, t, { x: d, y: g });
984
1004
  }
985
1005
  return;
986
1006
  }
987
1007
  if (i.x !== void 0 || i.y !== void 0) {
988
- const h = i.x !== void 0 ? i.x : n.x, r = i.y !== void 0 ? i.y : n.y, l = i.width !== void 0 ? i.width : n.width, u = i.height !== void 0 ? i.height : n.height, { width: c, height: d } = this.getPageSize(e, a);
989
- if (h >= 0 && r >= 0 && h + l <= c && r + u <= d) {
1008
+ const r = i.x !== void 0 ? i.x : o.x, h = i.y !== void 0 ? i.y : o.y, l = i.width !== void 0 ? i.width : o.width, u = i.height !== void 0 ? i.height : o.height, { width: c, height: d } = this.getPageSize(e, a);
1009
+ if (r >= 0 && h >= 0 && r + l <= c && h + u <= d) {
990
1010
  this.updateObjectInPage(e, a, t, i);
991
1011
  return;
992
1012
  }
993
1013
  let g = a, f = 0;
994
1014
  for (let p = 0; p < s.pages.length; p++) {
995
- const O = this.getPageWidth(e, p), S = this.getPageHeight(e, p), w = ge(h, r, l, u, O, S);
1015
+ const D = this.getPageWidth(e, p), S = this.getPageHeight(e, p), w = ge(r, h, l, u, D, S);
996
1016
  w > f && (f = w, g = p);
997
1017
  }
998
1018
  if (g !== a) {
999
- const { width: p, height: O } = this.getPageSize(e, g), { x: S, y: w } = F(h, r, l, u, p, O);
1019
+ const { width: p, height: D } = this.getPageSize(e, g), { x: S, y: w } = L(r, h, l, u, p, D);
1000
1020
  this.removeObjectFromPage(e, a, t);
1001
- const j = {
1002
- ...n,
1021
+ const $ = {
1022
+ ...o,
1003
1023
  ...i,
1004
1024
  x: S,
1005
1025
  y: w
1006
1026
  };
1007
- s.allObjects[g].push(j), this.objectIndexCache[`${e}-${t}`] = g;
1027
+ s.allObjects[g].push($), this.objectIndexCache[`${e}-${t}`] = g;
1008
1028
  return;
1009
1029
  }
1010
- const { width: b, height: D } = this.getPageSize(e, a);
1011
- if (h < 0 || r < 0 || h + l > b || r + u > D)
1030
+ const { width: b, height: O } = this.getPageSize(e, a);
1031
+ if (r < 0 || h < 0 || r + l > b || h + u > O)
1012
1032
  return;
1013
1033
  }
1014
1034
  this.updateObjectInPage(e, a, t, i);
@@ -1017,30 +1037,30 @@ const be = I({
1017
1037
  deleteObject(e, t) {
1018
1038
  if (e < 0 || e >= this.pdfDocuments.length) return;
1019
1039
  const i = this.pdfDocuments[e];
1020
- let s = null, o = -1;
1021
- i.allObjects.some((a, n) => {
1022
- const h = a.findIndex((r) => r.id === t);
1023
- return h === -1 ? !1 : (s = a[h], o = n, a.splice(h, 1), !0);
1040
+ let s = null, n = -1;
1041
+ i.allObjects.some((a, o) => {
1042
+ const r = a.findIndex((h) => h.id === t);
1043
+ return r === -1 ? !1 : (s = a[r], n = o, a.splice(r, 1), !0);
1024
1044
  }), delete this.objectIndexCache[`${e}-${t}`], s && this.$emit("pdf-elements:delete-object", {
1025
1045
  object: s,
1026
1046
  docIndex: e,
1027
- pageIndex: o
1047
+ pageIndex: n
1028
1048
  });
1029
1049
  },
1030
1050
  duplicateObject(e, t) {
1031
1051
  if (e < 0 || e >= this.pdfDocuments.length) return;
1032
1052
  const i = this.pdfDocuments[e], s = `${e}-${t}`;
1033
- let o = this.objectIndexCache[s];
1034
- if (o === void 0 && (o = L(i, t), o !== void 0 && (this.objectIndexCache[s] = o)), o === void 0) return;
1035
- const a = i.allObjects[o]?.find((g) => g.id === t);
1053
+ let n = this.objectIndexCache[s];
1054
+ if (n === void 0 && (n = F(i, t), n !== void 0 && (this.objectIndexCache[s] = n)), n === void 0) return;
1055
+ const a = i.allObjects[n]?.find((g) => g.id === t);
1036
1056
  if (!a) return;
1037
- const { width: n, height: h } = this.getPageSize(e, o), r = 12, { x: l, y: u } = F(
1038
- a.x + r,
1039
- a.y + r,
1057
+ const { width: o, height: r } = this.getPageSize(e, n), h = 12, { x: l, y: u } = L(
1058
+ a.x + h,
1059
+ a.y + h,
1040
1060
  a.width,
1041
1061
  a.height,
1042
- n,
1043
- h
1062
+ o,
1063
+ r
1044
1064
  );
1045
1065
  let c = a.signer;
1046
1066
  c?.element && Object.prototype.hasOwnProperty.call(c.element, "elementId") && (c = {
@@ -1054,42 +1074,42 @@ const be = I({
1054
1074
  y: u,
1055
1075
  signer: c
1056
1076
  };
1057
- i.allObjects[o].push(d), this.objectIndexCache[`${e}-${d.id}`] = o, this.$nextTick(() => {
1058
- const g = `draggable${e}-${o}-${d.id}`, f = this.$refs[g];
1077
+ i.allObjects[n].push(d), this.objectIndexCache[`${e}-${d.id}`] = n, this.$nextTick(() => {
1078
+ const g = `draggable${e}-${n}-${d.id}`, f = this.$refs[g];
1059
1079
  f && Array.isArray(f) && f[0] && (f[0].isSelected = !0);
1060
1080
  });
1061
1081
  },
1062
1082
  checkAndMoveObjectPage(e, t, i, s) {
1063
1083
  if (e < 0 || e >= this.pdfDocuments.length) return;
1064
- const o = this.pdfDocuments[e], a = `${e}-${t}`;
1065
- let n = this.objectIndexCache[a];
1066
- if (n === void 0 && (n = L(o, t), n !== void 0 && (this.objectIndexCache[a] = n)), n === void 0) return;
1067
- const h = o.allObjects[n]?.find((w) => w.id === t);
1068
- if (!h) return n;
1069
- let r = n;
1084
+ const n = this.pdfDocuments[e], a = `${e}-${t}`;
1085
+ let o = this.objectIndexCache[a];
1086
+ if (o === void 0 && (o = F(n, t), o !== void 0 && (this.objectIndexCache[a] = o)), o === void 0) return;
1087
+ const r = n.allObjects[o]?.find((w) => w.id === t);
1088
+ if (!r) return o;
1089
+ let h = o;
1070
1090
  const l = this.getPageBoundsList(), u = this.getPageBoundsMap(), c = l.length ? l : Object.values(u);
1071
1091
  for (let w = 0; w < c.length; w++) {
1072
- const { docIndex: j, pageIndex: C, rect: k } = c[w];
1073
- if (j === e && i >= k.left && i <= k.right && s >= k.top && s <= k.bottom) {
1074
- r = C;
1092
+ const { docIndex: $, pageIndex: j, rect: k } = c[w];
1093
+ if ($ === e && i >= k.left && i <= k.right && s >= k.top && s <= k.bottom) {
1094
+ h = j;
1075
1095
  break;
1076
1096
  }
1077
1097
  }
1078
- const d = this.getPageRect(e, r);
1079
- if (!d) return n;
1080
- const g = this.getDisplayedPageScale(e, r), f = (i - d.left - this.draggingElementShift.x) / g - this.draggingInitialMouseOffset.x / g, b = (s - d.top - this.draggingElementShift.y) / g - this.draggingInitialMouseOffset.y / g, { width: D, height: p } = this.getPageSize(e, r), { x: O, y: S } = F(
1098
+ const d = this.getPageRect(e, h);
1099
+ if (!d) return o;
1100
+ const g = this.getDisplayedPageScale(e, h), f = (i - d.left - this.draggingElementShift.x) / g - this.draggingInitialMouseOffset.x / g, b = (s - d.top - this.draggingElementShift.y) / g - this.draggingInitialMouseOffset.y / g, { width: O, height: p } = this.getPageSize(e, h), { x: D, y: S } = L(
1081
1101
  f,
1082
1102
  b,
1083
- h.width,
1084
- h.height,
1085
- D,
1103
+ r.width,
1104
+ r.height,
1105
+ O,
1086
1106
  p
1087
1107
  );
1088
- return r !== n ? (this.removeObjectFromPage(e, n, t), o.allObjects[r].push({
1089
- ...h,
1090
- x: O,
1108
+ return h !== o ? (this.removeObjectFromPage(e, o, t), n.allObjects[h].push({
1109
+ ...r,
1110
+ x: D,
1091
1111
  y: S
1092
- }), this.objectIndexCache[a] = r) : (O !== h.x || S !== h.y) && this.updateObjectInPage(e, n, t, { x: O, y: S }), r;
1112
+ }), this.objectIndexCache[a] = h) : (D !== r.x || S !== r.y) && this.updateObjectInPage(e, o, t, { x: D, y: S }), h;
1093
1113
  },
1094
1114
  onMeasure(e, t, i) {
1095
1115
  t < 0 || t >= this.pdfDocuments.length || (this.pdfDocuments[t].pagesScale.splice(i, 1, e.scale), this._pageMeasurementCache[`${t}-${i}`] = null, this.cachePageBoundsForPage(t, i), this.autoFitZoom && this.scheduleAutoFitZoom());
@@ -1140,7 +1160,7 @@ const be = I({
1140
1160
  const s = this.$el?.querySelectorAll("canvas");
1141
1161
  if (!s?.length) return;
1142
1162
  t = Math.max(...Array.from(s).map(
1143
- (o) => o.width / (this.scale || 1)
1163
+ (n) => n.width / (this.scale || 1)
1144
1164
  ));
1145
1165
  }
1146
1166
  const i = this.calculateOptimalScale(t);
@@ -1150,19 +1170,19 @@ const be = I({
1150
1170
  }), ye = {
1151
1171
  key: 0,
1152
1172
  class: "pages-container"
1153
- }, Pe = ["onMousedown", "onTouchstart"], Oe = ["onClick", "onTouchend"], De = {
1173
+ }, Pe = ["onMousedown", "onTouchstart"], De = ["role", "tabindex", "aria-label", "onClick", "onTouchend", "onKeydown"], Oe = {
1154
1174
  key: 0,
1155
1175
  class: "page-footer"
1156
1176
  };
1157
- function Se(e, t, i, s, o, a) {
1158
- const n = Z("PDFPage"), h = Z("DraggableElement");
1177
+ function Se(e, t, i, s, n, a) {
1178
+ const o = I("PDFPage"), r = I("DraggableElement");
1159
1179
  return m(), v("div", {
1160
- style: E({ width: e.width, height: e.height }),
1180
+ style: R({ width: e.width, height: e.height }),
1161
1181
  class: "pdf-elements-root"
1162
1182
  }, [
1163
1183
  e.pdfDocuments.length ? (m(), v("div", ye, [
1164
- (m(!0), v(z, null, B(e.pdfDocuments, (r, l) => (m(), v("div", { key: l }, [
1165
- (m(!0), v(z, null, B(r.pages, (u, c) => (m(), v("div", {
1184
+ (m(!0), v(z, null, H(e.pdfDocuments, (h, l) => (m(), v("div", { key: l }, [
1185
+ (m(!0), v(z, null, H(h.pages, (u, c) => (m(), v("div", {
1166
1186
  key: `${l}-${c}`,
1167
1187
  class: "page-slot"
1168
1188
  }, [
@@ -1174,7 +1194,7 @@ function Se(e, t, i, s, o, a) {
1174
1194
  P("div", {
1175
1195
  class: Y(["page-canvas", { "shadow-outline": l === e.selectedDocIndex && c === e.selectedPageIndex }])
1176
1196
  }, [
1177
- K(n, {
1197
+ x(o, {
1178
1198
  ref_for: !0,
1179
1199
  ref: `page${l}-${c}`,
1180
1200
  page: u,
@@ -1183,15 +1203,20 @@ function Se(e, t, i, s, o, a) {
1183
1203
  }, null, 8, ["page", "scale", "onOnMeasure"]),
1184
1204
  P("div", {
1185
1205
  class: "overlay",
1206
+ role: e.isAddingMode ? "button" : void 0,
1207
+ tabindex: e.isAddingMode ? 0 : -1,
1208
+ "aria-label": e.getOverlayAriaLabel(l, c),
1186
1209
  onMousemove: t[0] || (t[0] = (...d) => e.handleMouseMove && e.handleMouseMove(...d)),
1187
1210
  onTouchmove: t[1] || (t[1] = (...d) => e.handleMouseMove && e.handleMouseMove(...d)),
1188
1211
  onClick: (d) => e.handleOverlayClick(l, c, d),
1189
- onTouchend: (d) => e.handleOverlayClick(l, c, d)
1212
+ onTouchend: (d) => e.handleOverlayClick(l, c, d),
1213
+ onKeydown: (d) => e.handleOverlayKeyDown(l, c, d)
1190
1214
  }, [
1191
1215
  e.isAddingMode && e.previewPageDocIndex === l && e.previewPageIndex === c && e.previewElement && e.previewVisible ? (m(), v("div", {
1192
1216
  key: 0,
1193
1217
  class: "preview-element",
1194
- style: E({
1218
+ "aria-hidden": "true",
1219
+ style: R({
1195
1220
  left: `${e.previewPosition.x * e.previewScale.x}px`,
1196
1221
  top: `${e.previewPosition.y * e.previewScale.y}px`,
1197
1222
  width: `${e.previewElement.width * e.previewScale.x}px`,
@@ -1207,8 +1232,8 @@ function Se(e, t, i, s, o, a) {
1207
1232
  isSelected: !1
1208
1233
  }, void 0, !0)
1209
1234
  ], !0)
1210
- ], 4)) : $("", !0),
1211
- (m(!0), v(z, null, B(r.allObjects[c], (d) => (m(), J(h, {
1235
+ ], 4)) : C("", !0),
1236
+ (m(!0), v(z, null, H(h.allObjects[c], (d) => (m(), J(r, {
1212
1237
  key: d.id,
1213
1238
  ref_for: !0,
1214
1239
  ref: `draggable${l}-${c}-${d.id}`,
@@ -1220,7 +1245,7 @@ function Se(e, t, i, s, o, a) {
1220
1245
  "on-update": (g) => e.updateObject(l, d.id, g),
1221
1246
  "on-delete": () => e.deleteObject(l, d.id),
1222
1247
  "on-duplicate": () => e.duplicateObject(l, d.id),
1223
- "on-drag-start": (g, f, b, D) => e.startDraggingElement(l, c, d, g, f, b, D),
1248
+ "on-drag-start": (g, f, b, O) => e.startDraggingElement(l, c, d, g, f, b, O),
1224
1249
  "on-drag-move": e.updateDraggingPosition,
1225
1250
  "on-drag-end": e.stopDraggingElement,
1226
1251
  "is-being-dragged-globally": e.isDraggingElement && e.draggingObject && e.draggingObject.id === d.id,
@@ -1255,20 +1280,20 @@ function Se(e, t, i, s, o, a) {
1255
1280
  ]),
1256
1281
  _: 2
1257
1282
  }, 1032, ["object", "pages-scale", "page-width", "page-height", "read-only", "on-update", "on-delete", "on-duplicate", "on-drag-start", "on-drag-move", "on-drag-end", "is-being-dragged-globally", "dragging-client-pos", "current-doc-index", "current-page-index", "global-drag-doc-index", "global-drag-page-index", "show-selection-ui", "show-default-actions", "ignore-click-outside-selectors"]))), 128))
1258
- ], 40, Oe)
1283
+ ], 40, De)
1259
1284
  ], 2),
1260
- e.showPageFooter ? (m(), v("div", De, [
1261
- P("span", null, U(r.name), 1),
1262
- P("span", null, U(e.formatPageNumber(c + 1, r.numPages)), 1)
1263
- ])) : $("", !0)
1285
+ e.showPageFooter ? (m(), v("div", Oe, [
1286
+ P("span", null, U(h.name), 1),
1287
+ P("span", null, U(e.formatPageNumber(c + 1, h.numPages)), 1)
1288
+ ])) : C("", !0)
1264
1289
  ], 40, Pe)
1265
1290
  ]))), 128))
1266
1291
  ]))), 128))
1267
- ])) : $("", !0),
1292
+ ])) : C("", !0),
1268
1293
  e.isDraggingElement && e.draggingObject ? (m(), v("div", {
1269
1294
  key: 1,
1270
1295
  class: "drag-portal",
1271
- style: E({
1296
+ style: R({
1272
1297
  position: "fixed",
1273
1298
  left: `${e.draggingClientPosition.x}px`,
1274
1299
  top: `${e.draggingClientPosition.y}px`,
@@ -1286,10 +1311,10 @@ function Se(e, t, i, s, o, a) {
1286
1311
  isSelected: !1
1287
1312
  }, void 0, !0)
1288
1313
  ], !0)
1289
- ], 4)) : $("", !0)
1314
+ ], 4)) : C("", !0)
1290
1315
  ], 4);
1291
1316
  }
1292
- const T = /* @__PURE__ */ V(be, [["render", Se], ["__scopeId", "data-v-eb792162"]]), Me = (e) => {
1317
+ const T = /* @__PURE__ */ Z(be, [["render", Se], ["__scopeId", "data-v-d63caaf3"]]), Me = (e) => {
1293
1318
  const t = T.name || "PDFElements";
1294
1319
  e.component(t, T);
1295
1320
  };
@@ -1297,5 +1322,5 @@ T.install = Me;
1297
1322
  export {
1298
1323
  T as PDFElements,
1299
1324
  T as default,
1300
- Ce as setWorkerPath
1325
+ je as setWorkerPath
1301
1326
  };