@printstack/print-studio 0.1.0 → 0.1.2

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.
Files changed (72) hide show
  1. package/README.md +122 -154
  2. package/assets/render.worker-DkH7TepL.js +109 -0
  3. package/{cloneDeep-C5UZRjbH.js → cloneDeep-waBDTGc3.js} +10 -4
  4. package/components/print-s-logo/print-s-logo.vue.d.ts +1 -1
  5. package/components/s-form/types.d.ts +1 -1
  6. package/core/coordinate-space.d.ts +16 -0
  7. package/core/document-model.d.ts +1 -1
  8. package/core/element-registry.d.ts +3 -8
  9. package/core/page-extensions.d.ts +1 -1
  10. package/core/types.d.ts +8 -0
  11. package/core.js +2 -2
  12. package/designer/commands/menu-adapter.d.ts +3 -3
  13. package/designer/commands/menu-types.d.ts +8 -1
  14. package/designer/commands/types.d.ts +2 -0
  15. package/designer/components/dialogs/preview-dialog.vue.d.ts +10 -1
  16. package/designer/components/dialogs/print-preview-dialog.vue.d.ts +14 -0
  17. package/designer/components/dialogs/print-preview-source.d.ts +22 -0
  18. package/designer/components/dialogs/use-document-preview.d.ts +5 -1
  19. package/designer/components/dialogs/use-preview-renderer.d.ts +2 -0
  20. package/designer/components/dialogs/use-print-preview.d.ts +33 -0
  21. package/designer/components/fields/use-table-draft.d.ts +0 -4
  22. package/designer/components/panels/layer-row-types.d.ts +37 -0
  23. package/designer/components/panels/layer-row.vue.d.ts +17 -0
  24. package/designer/components/stage/marquee-overlay.vue.d.ts +8 -0
  25. package/designer/components/stage/node-style.d.ts +3 -0
  26. package/designer/components/stage/selection-member.vue.d.ts +14 -0
  27. package/designer/composables/use-theme.d.ts +3 -0
  28. package/designer/facade/editing.d.ts +2 -2
  29. package/designer/facade/entities.d.ts +1156 -22
  30. package/designer/facade/output.d.ts +2 -2
  31. package/designer/frame/print-designer-frame.vue.d.ts +2 -2
  32. package/designer/frame/shared.d.ts +2 -0
  33. package/designer/frame/view.d.ts +9 -0
  34. package/designer/interactions/marquee.d.ts +1 -1
  35. package/designer/interactions/move.d.ts +3 -1
  36. package/designer/mount-print-designer.d.ts +1 -1
  37. package/designer/mount-print-preview.d.ts +5 -0
  38. package/designer/plugins/plugin-manager.d.ts +3 -3
  39. package/designer/plugins/types.d.ts +1 -1
  40. package/designer/print-designer.vue.d.ts +2 -2
  41. package/designer/print-preview.vue.d.ts +4 -0
  42. package/designer/stores/document-store.d.ts +72 -0
  43. package/designer/stores/editor-store.d.ts +770 -14
  44. package/designer/stores/page-store.d.ts +25 -1
  45. package/designer/stores/template-store.d.ts +52 -4
  46. package/designer/stores/types.d.ts +1 -0
  47. package/designer/stores/ui-store.d.ts +232 -3
  48. package/designer/stores/view-store.d.ts +10 -1
  49. package/designer.d.ts +1 -1
  50. package/designer.js +3 -3
  51. package/{document-model-DC9sn2WV.js → document-model-Cc5RoO4j.js} +160 -179
  52. package/elements/table/table-style.d.ts +3 -10
  53. package/host-OAp3gFDx.js +123 -0
  54. package/index.js +5 -5
  55. package/locales/runtime.d.ts +8 -2
  56. package/locales/translations/zh-CN/app.json.d.ts +1 -0
  57. package/locales/translations/zh-CN/designer.json.d.ts +9 -4
  58. package/{mount-print-designer-BzHLGlv-.js → mount-print-designer-DnHTrBE9.js} +4 -3
  59. package/mount-print-preview-Bcb08lJ-.js +66 -0
  60. package/package.json +1 -1
  61. package/presets-BunYODhE.js +13 -0
  62. package/{registries-BOU8RLim.js → registries-sg39PGF1.js} +793 -790
  63. package/runtime/browser-output.d.ts +2 -0
  64. package/runtime.js +4 -4
  65. package/{saas-B3fJOgHX.js → saas-D-q51uTz.js} +1 -1
  66. package/saas.js +1 -1
  67. package/{studio-C_rqbJ9q.js → studio-B3B6zI06.js} +830 -754
  68. package/studio-types.d.ts +3 -2
  69. package/style.css +1 -1
  70. package/vue.js +1035 -941
  71. package/assets/render.worker-Cfbk18NW.js +0 -109
  72. package/presets-Cwp20ef6.js +0 -133
@@ -1,4 +1,4 @@
1
- import { A as e, B as t, I as n, j as r, t as i } from "./cloneDeep-C5UZRjbH.js";
1
+ import { A as e, B as t, I as n, j as r, t as i } from "./cloneDeep-waBDTGc3.js";
2
2
  // node_modules/.pnpm/uuid@14.0.3/node_modules/uuid/dist/stringify.js
3
3
  var a = [];
4
4
  for (let e = 0; e < 256; ++e) a.push((e + 256).toString(16).slice(1));
@@ -344,28 +344,28 @@ function Se(e) {
344
344
  return n;
345
345
  }
346
346
  // src/core/units.ts
347
- var Ce = 96 / 25.4, we = 25.4 / 72;
348
- function Te(e, t = 1) {
349
- return e / (Ce * t);
347
+ var y = 96 / 25.4, Ce = 25.4 / 72;
348
+ function we(e, t = 1) {
349
+ return e / (y * t);
350
350
  }
351
- function Ee(e) {
352
- return e * we;
351
+ function Te(e) {
352
+ return e * Ce;
353
353
  }
354
- function De(e, t = 1) {
354
+ function Ee(e, t = 1) {
355
355
  return 96 / 72 * e * t;
356
356
  }
357
- function Oe(e, t, n) {
357
+ function De(e, t, n) {
358
358
  return e < t ? t : e > n ? n : e;
359
359
  }
360
- function y(e, t = 2) {
360
+ function b(e, t = 2) {
361
361
  let n = 10 ** t;
362
362
  return Math.round(e * n) / n;
363
363
  }
364
364
  // src/core/geometry.ts
365
- function b(e) {
365
+ function x(e) {
366
366
  return (e % 360 + 540) % 360 - 180;
367
367
  }
368
- function ke(e, t) {
368
+ function Oe(e, t) {
369
369
  let n = t * Math.PI / 180, r = Math.abs(Math.cos(n)), i = Math.abs(Math.sin(n)), a = e.x + e.width / 2, o = e.y + e.height / 2, s = e.width / 2 * r + e.height / 2 * i, c = e.width / 2 * i + e.height / 2 * r;
370
370
  return {
371
371
  height: c * 2,
@@ -374,7 +374,7 @@ function ke(e, t) {
374
374
  y: o - c
375
375
  };
376
376
  }
377
- function Ae(e) {
377
+ function ke(e) {
378
378
  if (e.length === 0) return null;
379
379
  let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
380
380
  for (let a of e) t = Math.min(t, a.x), n = Math.min(n, a.y), r = Math.max(r, a.x + a.width), i = Math.max(i, a.y + a.height);
@@ -385,7 +385,7 @@ function Ae(e) {
385
385
  y: n
386
386
  };
387
387
  }
388
- function je(e) {
388
+ function Ae(e) {
389
389
  if (e.length === 0) return {
390
390
  height: 1,
391
391
  width: 1,
@@ -401,31 +401,24 @@ function je(e) {
401
401
  y: n
402
402
  };
403
403
  }
404
- function Me(e, t, n) {
404
+ function je(e, t, n) {
405
405
  return e.map((e) => ({
406
- x: y(e.x + t),
407
- y: y(e.y + n)
406
+ x: b(e.x + t),
407
+ y: b(e.y + n)
408
408
  }));
409
409
  }
410
- function Ne(e, t, n, r) {
410
+ function Me(e, t, n, r) {
411
411
  return e.map((e) => ({
412
- x: y(t.x + (e.x - t.x) * n),
413
- y: y(t.y + (e.y - t.y) * r)
412
+ x: b(t.x + (e.x - t.x) * n),
413
+ y: b(t.y + (e.y - t.y) * r)
414
414
  }));
415
415
  }
416
- function Pe(e, t, n) {
417
- let r = n * Math.PI / 180, i = Math.cos(r), a = Math.sin(r), o = e.x - t.x, s = e.y - t.y;
418
- return {
419
- x: y(t.x + o * i - s * a),
420
- y: y(t.y + o * a + s * i)
421
- };
422
- }
423
- function x(e) {
416
+ function S(e) {
424
417
  if (e.length < 2) return 0;
425
418
  let t = e[0], n = e[e.length - 1];
426
- return b(Math.atan2(n.y - t.y, n.x - t.x) * 180 / Math.PI);
419
+ return x(Math.atan2(n.y - t.y, n.x - t.x) * 180 / Math.PI);
427
420
  }
428
- function S(e) {
421
+ function Ne(e) {
429
422
  if (e.length < 2) return 0;
430
423
  let t = e[0], n = e[e.length - 1];
431
424
  return Math.hypot(n.x - t.x, n.y - t.y);
@@ -435,80 +428,80 @@ function w(e, t, n, r) {
435
428
  let i = t, a = n(t), o = r && r(t) ? t : null, s = o ? a : Infinity;
436
429
  for (let e = -1; e <= 1; e += 1) for (let c = -1; c <= 1; c += 1) {
437
430
  let l = {
438
- x: y(t.x + e * C),
439
- y: y(t.y + c * C)
431
+ x: b(t.x + e * C),
432
+ y: b(t.y + c * C)
440
433
  }, u = n(l);
441
434
  u < a && (i = l, a = u), r && r(l) && u < s && (o = l, s = u);
442
435
  }
443
436
  return o ?? i;
444
437
  }
445
- function Fe(e, t, n, r) {
446
- let i = b(n);
438
+ function Pe(e, t, n, r) {
439
+ let i = x(n);
447
440
  return w(e, t, (t) => {
448
- let n = x([e, t]);
449
- return Math.abs(b(n - i));
441
+ let n = S([e, t]);
442
+ return Math.abs(x(n - i));
450
443
  }, r);
451
444
  }
452
- function Ie(e, t, n, r) {
445
+ function Fe(e, t, n, r) {
453
446
  return w(e, t, (t) => Math.abs(Math.hypot(t.x - e.x, t.y - e.y) - n), r);
454
447
  }
455
- function Le(e, t, n) {
448
+ function T(e, t, n) {
456
449
  let r = t * Math.PI / 180;
457
450
  return {
458
- x: y(e.x + Math.cos(r) * n),
459
- y: y(e.y + Math.sin(r) * n)
451
+ x: b(e.x + Math.cos(r) * n),
452
+ y: b(e.y + Math.sin(r) * n)
460
453
  };
461
454
  }
462
- function Re(e, t, n) {
463
- let r = y(x([e, t]));
464
- return Ie(e, Le(e, r, n), n, (t) => y(b(x([e, t])), 2) === y(b(r), 2));
455
+ function Ie(e, t, n) {
456
+ let r = b(S([e, t]));
457
+ return Fe(e, T(e, r, n), n, (t) => b(x(S([e, t])), 2) === b(x(r), 2));
465
458
  }
466
- function ze(e, t, n) {
467
- let r = y(S([e, t]));
468
- return Fe(e, Le(e, n, r), n, (t) => y(Math.hypot(t.x - e.x, t.y - e.y), 2) === r);
459
+ function Le(e, t, n) {
460
+ let r = b(Ne([e, t]));
461
+ return Pe(e, T(e, n, r), n, (t) => b(Math.hypot(t.x - e.x, t.y - e.y), 2) === r);
469
462
  }
470
- function Be(e, t, n) {
463
+ function Re(e, t, n) {
471
464
  let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
472
465
  if (a === 0) return Math.hypot(e.x - t.x, e.y - t.y);
473
- let o = Oe(((e.x - t.x) * r + (e.y - t.y) * i) / a, 0, 1);
466
+ let o = De(((e.x - t.x) * r + (e.y - t.y) * i) / a, 0, 1);
474
467
  return Math.hypot(e.x - (t.x + o * r), e.y - (t.y + o * i));
475
468
  }
476
- function T(e) {
469
+ function E(e) {
477
470
  return Array.isArray(e.points) && e.points.length > 0;
478
471
  }
479
- function E(e, t) {
480
- let n = je(t);
472
+ function D(e, t) {
473
+ let n = Ae(t);
481
474
  return {
482
- height: y(Math.max(n.height, 0)),
475
+ height: b(Math.max(n.height, 0)),
483
476
  points: t.map((e) => ({
484
- x: y(e.x),
485
- y: y(e.y)
477
+ x: b(e.x),
478
+ y: b(e.y)
486
479
  })),
487
480
  rotation: 0,
488
- width: y(Math.max(n.width, 0)),
489
- x: y(n.x),
490
- y: y(n.y)
481
+ width: b(Math.max(n.width, 0)),
482
+ x: b(n.x),
483
+ y: b(n.y)
491
484
  };
492
485
  }
493
- function D(e, t, n) {
494
- return T(e) ? E(e, Me(e.points, t, n)) : {
495
- x: y(e.x + t),
496
- y: y(e.y + n)
486
+ function O(e, t, n) {
487
+ return E(e) ? D(e, je(e.points, t, n)) : {
488
+ x: b(e.x + t),
489
+ y: b(e.y + n)
497
490
  };
498
491
  }
499
492
  // src/core/render/element-warning.ts
500
- function O(e, n) {
493
+ function k(e, n) {
501
494
  return t("core.pageExtensions.elementFailed", {
502
495
  elementName: e.name || e.id,
503
496
  message: n instanceof Error && n.cause ? r(n) + " · " + r(n.cause) : r(n)
504
497
  });
505
498
  }
506
- function Ve(e, t, n) {
507
- let r = O(e, t);
499
+ function ze(e, t, n) {
500
+ let r = k(e, t);
508
501
  n ? n(r) : console.warn(r);
509
502
  }
510
503
  // src/core/element-registry.ts
511
- var He = class {
504
+ var Be = class {
512
505
  definitions = /* @__PURE__ */ new Map();
513
506
  listeners = /* @__PURE__ */ new Set();
514
507
  get(e) {
@@ -543,23 +536,23 @@ var He = class {
543
536
  notify() {
544
537
  for (let e of this.listeners) e();
545
538
  }
546
- }, k = new He();
547
- function Ue(e) {
539
+ }, A = new Be();
540
+ function Ve(e) {
548
541
  return e;
549
542
  }
550
- function We(e) {
551
- return e?.elements ?? k;
543
+ function He(e) {
544
+ return e?.elements ?? A;
552
545
  }
553
- function Ge(e, t) {
546
+ function Ue(e, t) {
554
547
  if (!t.node.visible) return null;
555
548
  try {
556
549
  return e.get(t.node.type)?.paginate?.(t);
557
550
  } catch (e) {
558
- return t.warnings.add(O(t.node, e)), null;
551
+ return t.warnings.add(k(t.node, e)), null;
559
552
  }
560
553
  }
561
554
  // src/core/element-transform.ts
562
- function A(e, t = k) {
555
+ function j(e, t = A) {
563
556
  let n = t.get(e.type)?.getMinSize?.({
564
557
  node: e,
565
558
  props: e.props
@@ -569,50 +562,50 @@ function A(e, t = k) {
569
562
  width: Math.max(1, n?.width ?? 1)
570
563
  };
571
564
  }
572
- function j(e, t, n = k, r = {}) {
565
+ function M(e, t, n = A, r = {}) {
573
566
  let i = n.get(e.type), a = i?.aspectRatio, o = t;
574
567
  if (a && a > 0 && (typeof t.width == "number" ? o = {
575
568
  ...t,
576
- height: y(t.width / a)
569
+ height: b(t.width / a)
577
570
  } : typeof t.height == "number" && (o = {
578
571
  ...t,
579
- width: y(t.height * a)
572
+ width: b(t.height * a)
580
573
  })), r.enforceMinimum !== !1 && i?.getMinSize && ("width" in t || "height" in t || "props" in t || "type" in t)) {
581
574
  let t = {
582
575
  ...e,
583
576
  ...o
584
- }, r = A(t, n);
577
+ }, r = j(t, n);
585
578
  t.width < r.width && (o = {
586
579
  ...o,
587
580
  width: r.width
588
581
  }, t = {
589
582
  ...e,
590
583
  ...o
591
- }, r = A(t, n)), t.height < r.height && (o = {
584
+ }, r = j(t, n)), t.height < r.height && (o = {
592
585
  ...o,
593
586
  height: r.height
594
587
  });
595
588
  }
596
589
  return o;
597
590
  }
598
- function Ke(e, t) {
599
- if (T(e)) {
600
- if (t === "width") return y(S(e.points));
601
- if (t === "rotation") return y(x(e.points));
591
+ function We(e, t) {
592
+ if (E(e)) {
593
+ if (t === "width") return b(Ne(e.points));
594
+ if (t === "rotation") return b(S(e.points));
602
595
  }
603
596
  return e[t];
604
597
  }
605
- function qe(e, t, n) {
598
+ function Ge(e, t, n) {
606
599
  if (typeof n != "number" || !Number.isFinite(n)) return {};
607
- if (t === "x") return D(e, n - e.x, 0);
608
- if (t === "y") return D(e, 0, n - e.y);
609
- if (!T(e)) return j(e, { [t]: n });
600
+ if (t === "x") return O(e, n - e.x, 0);
601
+ if (t === "y") return O(e, 0, n - e.y);
602
+ if (!E(e)) return M(e, { [t]: n });
610
603
  let r = e.points, i = r[0], a = r[r.length - 1];
611
- if (t === "width") return E(e, [...r.slice(0, -1), Re(i, a, n)]);
612
- if (t === "rotation") return E(e, [...r.slice(0, -1), ze(i, a, n)]);
604
+ if (t === "width") return D(e, [...r.slice(0, -1), Ie(i, a, n)]);
605
+ if (t === "rotation") return D(e, [...r.slice(0, -1), Le(i, a, n)]);
613
606
  if (t === "height") {
614
607
  let t = e.height > 0 ? n / e.height : 1;
615
- return E(e, Ne(r, {
608
+ return D(e, Me(r, {
616
609
  x: e.x,
617
610
  y: e.y
618
611
  }, 1, t));
@@ -620,10 +613,10 @@ function qe(e, t, n) {
620
613
  return { [t]: n };
621
614
  }
622
615
  // src/core/follow-block.ts
623
- function Je(e) {
616
+ function Ke(e) {
624
617
  return `${e.kind}:${e.id}`;
625
618
  }
626
- function Ye(e, t, n) {
619
+ function qe(e, t, n) {
627
620
  if (n.kind === "element") {
628
621
  let r = e.pages.find((e) => e.id === t)?.elements.find((e) => e.id === n.id);
629
622
  return r ? {
@@ -637,7 +630,7 @@ function Ye(e, t, n) {
637
630
  name: r.name
638
631
  } : void 0;
639
632
  }
640
- function M(e, t) {
633
+ function N(e, t) {
641
634
  let n = e.pages.find((e) => e.id === t.pageId), r = (e.followBlocks ?? []).filter((e) => e.id !== t.id), i = e.repeatGroups ?? [];
642
635
  if (!n || !t.id || !Number.isFinite(t.gap) || t.elementIds.length === 0 || new Set(t.elementIds).size !== t.elementIds.length || t.elementIds.some((e) => !n.elements.some((t) => t.id === e))) return "invalidMembers";
643
636
  if (r.some((e) => e.elementIds.some((e) => t.elementIds.includes(e))) || i.some((e) => e.elementIds.some((e) => t.elementIds.includes(e)))) return "memberConflict";
@@ -652,15 +645,15 @@ function M(e, t) {
652
645
  o.add(r.id), s = r;
653
646
  }
654
647
  }
655
- function Xe(n) {
648
+ function Je(n) {
656
649
  let r = /* @__PURE__ */ new Set();
657
650
  for (let i of n.followBlocks ?? []) {
658
- let a = r.has(i.id) ? "invalidMembers" : M(n, i);
651
+ let a = r.has(i.id) ? "invalidMembers" : N(n, i);
659
652
  if (a) throw new e(t(`core.followBlock.${a}`), { code: `follow.${a}` });
660
653
  r.add(i.id);
661
654
  }
662
655
  }
663
- function Ze(e) {
656
+ function Ye(e) {
664
657
  if (!e.followBlocks) return;
665
658
  e.followBlocks = e.followBlocks.map((t) => {
666
659
  let n = e.pages.find((e) => e.id === t.pageId);
@@ -672,12 +665,12 @@ function Ze(e) {
672
665
  let t = !0;
673
666
  for (; t;) {
674
667
  let n = e.followBlocks ?? [], r = /* @__PURE__ */ new Set();
675
- e.followBlocks = n.filter((t) => r.has(t.id) || M(e, t) ? !1 : (r.add(t.id), !0)), t = (e.followBlocks?.length ?? 0) !== n.length;
668
+ e.followBlocks = n.filter((t) => r.has(t.id) || N(e, t) ? !1 : (r.add(t.id), !0)), t = (e.followBlocks?.length ?? 0) !== n.length;
676
669
  }
677
670
  }
678
671
  // src/core/page-extensions.ts
679
- function N(e, t, n) {
680
- let r = e.templates?.find((e) => e.owner && q(e).some((e) => e.elements.some((e) => e.id === t.id)));
672
+ function P(e, t, n) {
673
+ let r = e.templates?.find((e) => e.owner && K(e).some((e) => e.elements.some((e) => e.id === t.id)));
681
674
  if (!r?.owner) return;
682
675
  let i = Y(e, r.owner.elementId)?.node, a = i && n.get(i.type)?.pageExtensions, o = i && a?.references(i).find((e) => e.templateId === r.id && e.elementId === t.id && e.purpose === r.owner?.purpose);
683
676
  if (i && a && o) return {
@@ -686,19 +679,19 @@ function N(e, t, n) {
686
679
  source: i
687
680
  };
688
681
  }
689
- function P(e, t, n) {
690
- let r = N(e, t, n);
691
- return r?.capability.resolveTarget?.(r.source, t, r.purpose) ?? t;
692
- }
693
682
  function F(e, t, n) {
694
683
  let r = P(e, t, n);
684
+ return r?.capability.resolveTarget?.(r.source, t, r.purpose) ?? t;
685
+ }
686
+ function I(e, t, n) {
687
+ let r = F(e, t, n);
695
688
  r === t ? n.get(t.type)?.pageExtensions?.reconcile?.(e, t) : (t.bindings = r.bindings, t.props = r.props);
696
689
  }
697
- function Qe(n, r, i) {
690
+ function Xe(n, r, i) {
698
691
  let a = n.templates?.flatMap((e) => e.requiredElements ?? []).find((e) => e.elementId === r.id);
699
692
  if (a && (!i || i.id !== void 0 && i.id !== r.id || i.visible === !1 || i.type !== void 0 && i.type !== a.type)) throw new e(t("core.pageExtensions.requiredElement"), { code: "template.required-element" });
700
693
  }
701
- function I(n) {
694
+ function L(n) {
702
695
  let r = [n.page, ...n.evenPage ? [n.evenPage] : []].flatMap((e) => e.elements);
703
696
  for (let i of n.requiredElements ?? []) {
704
697
  let a = r.find((e) => e.id === i.elementId);
@@ -708,26 +701,16 @@ function I(n) {
708
701
  }), { code: "template.invalid-dependency" });
709
702
  }
710
703
  }
711
- function L(e, t, n, r, a = e) {
704
+ function Ze(e, t, n, r, a = e) {
712
705
  let o = r.get(t.type)?.pageExtensions;
713
706
  if (o) for (let s of o.references(t)) {
714
707
  let c = a.templates?.find((e) => e.id === s.templateId);
715
708
  if (!c) continue;
716
- if (q(c).some((e) => e.elements.some((e) => e.id === t.id))) {
709
+ if (K(c).some((e) => e.elements.some((e) => e.id === t.id))) {
717
710
  o.rebind(n, s.purpose, "", "");
718
711
  continue;
719
712
  }
720
713
  if (t.id === n.id && c.owner?.elementId === n.id) continue;
721
- if (t.id === n.id && !c.owner && !e.pages.some((e) => e.templateId === c.id) && !e.templates?.some((e) => e.baseTemplateId === c.id)) {
722
- c.owner = {
723
- elementId: n.id,
724
- purpose: s.purpose
725
- }, c.requiredElements = [{
726
- elementId: s.elementId,
727
- type: t.type
728
- }];
729
- continue;
730
- }
731
714
  let l = i(c);
732
715
  l.id = U("template"), l.builtin = !1, l.owner = {
733
716
  elementId: n.id,
@@ -762,7 +745,7 @@ function R(e, t) {
762
745
  }), n = e.templates.length !== r.length;
763
746
  } while (n);
764
747
  }
765
- function $e(n, r, i) {
748
+ function Qe(n, r, i) {
766
749
  for (let a of i.get(r.type)?.pageExtensions?.references(r) ?? []) {
767
750
  let i = n.templates?.find((e) => e.id === a.templateId);
768
751
  if (i?.owner && (i.owner.elementId !== r.id || i.owner.purpose !== a.purpose || !i.requiredElements?.some((e) => e.elementId === a.elementId))) throw new e(t("core.pageExtensions.internalTemplate"), { code: "template.owner-mismatch" });
@@ -811,13 +794,13 @@ function V(n) {
811
794
  }
812
795
  // src/core/parser-version.ts
813
796
  var H = "1.0.0";
814
- function et(e) {
797
+ function $e(e) {
815
798
  if (e === void 0) return H;
816
799
  if (typeof e != "string" || !e.trim()) throw Error("Invalid parser version");
817
800
  return e;
818
801
  }
819
802
  // src/core/document-model.ts
820
- var tt = "1.0";
803
+ var et = "1.0";
821
804
  function U(e = "id") {
822
805
  return `${e}-${u()}`;
823
806
  }
@@ -834,11 +817,11 @@ function W(e = 210, n = 297, r, i = {}) {
834
817
  };
835
818
  return V(a), a.margins !== void 0 && (a.margins = B(a.margins)), a;
836
819
  }
837
- var nt = "template-blank", G = "template-none";
838
- function K() {
820
+ var tt = "template-blank", nt = "template-none";
821
+ function G() {
839
822
  let e = {
840
823
  builtin: !0,
841
- id: nt,
824
+ id: tt,
842
825
  name: t("core.documentModel.blankTemplateName"),
843
826
  page: W(210, 297)
844
827
  };
@@ -868,7 +851,7 @@ function rt(n, r, i = 0, a = /* @__PURE__ */ new Set()) {
868
851
  function it(e, t) {
869
852
  return t <= 0 || (t % 2 == 0 ? e.evenPages : e.oddPages) !== !1;
870
853
  }
871
- function q(e) {
854
+ function K(e) {
872
855
  return e.facingPages && e.evenPage ? [e.evenPage, e.page] : [e.page];
873
856
  }
874
857
  function at(e, t) {
@@ -893,7 +876,7 @@ function st(e, n) {
893
876
  };
894
877
  return r.page.id = r.id, r.page.name = r.name, r;
895
878
  }
896
- function ct(e, n = {}, r = k) {
879
+ function q(e, n = {}, r = A) {
897
880
  let i = r.get(e);
898
881
  if (!i) throw Error(t("core.documentModel.unregisteredElementType", { elementType: e }));
899
882
  let a = {
@@ -911,11 +894,11 @@ function ct(e, n = {}, r = k) {
911
894
  y: 0,
912
895
  ...n
913
896
  };
914
- ut(a, i), a.props = i.normalizeProps?.(a.props) ?? a.props, lt(a, i);
897
+ lt(a, i), a.props = i.normalizeProps?.(a.props) ?? a.props, ct(a, i);
915
898
  let o = n.height !== void 0 && n.width === void 0 ? { height: a.height } : { width: a.width };
916
- return Object.assign(a, j(a, o, r)), a;
899
+ return Object.assign(a, M(a, o, r)), a;
917
900
  }
918
- function lt(e, t = k.get(e.type)) {
901
+ function ct(e, t = A.get(e.type)) {
919
902
  let n = t?.measureSize?.({
920
903
  mode: "design",
921
904
  node: e,
@@ -923,16 +906,16 @@ function lt(e, t = k.get(e.type)) {
923
906
  });
924
907
  n && (typeof n.height == "number" && (e.height = n.height), typeof n.width == "number" && (e.width = n.width));
925
908
  }
926
- function ut(e, t = k.get(e.type)) {
909
+ function lt(e, t = A.get(e.type)) {
927
910
  if (t?.pointBased && !Array.isArray(e.points)) {
928
- let n = t.pointBased.migrateRect ? t.pointBased.migrateRect(e) : [{
911
+ let n = {
929
912
  x: e.x,
930
913
  y: e.y + e.height / 2
931
- }, {
914
+ }, r = {
932
915
  x: e.x + e.width,
933
- y: e.y + e.height / 2
934
- }];
935
- Object.assign(e, E(e, n));
916
+ y: n.y
917
+ }, i = t.pointBased.createPoints(n, r);
918
+ Object.assign(e, D(e, i));
936
919
  }
937
920
  return e;
938
921
  }
@@ -962,26 +945,26 @@ function X(e) {
962
945
  for (let n of e.templates ?? []) t.push(n.page), n.evenPage && t.push(n.evenPage);
963
946
  return t;
964
947
  }
965
- function dt(e, t) {
948
+ function ut(e, t) {
966
949
  return X(e).find((e) => e.id === t);
967
950
  }
968
951
  function Z(e, t, n = e.pages.findIndex((e) => e.id === t.id) + 1) {
969
952
  let r = t.templateId ?? "template-blank", i = e.templates?.find((e) => e.id === r);
970
953
  if (r !== "template-none" && i && i.owner === void 0 && it(i, n)) return rt(e, i, n);
971
954
  }
972
- function ft(e, t, n) {
955
+ function dt(e, t, n) {
973
956
  return z(Z(e, t, n)?.page ?? t);
974
957
  }
975
- function pt(e, t = (e) => e, n = console.warn) {
958
+ function ft(e, t = (e) => e, n = console.warn) {
976
959
  if (!e.templates?.length) return e;
977
960
  let i = e.pages.map((i, a) => {
978
961
  let o;
979
962
  try {
980
- o = Z(e, i, a + 1), o && I(o);
963
+ o = Z(e, i, a + 1), o && L(o);
981
964
  } catch (e) {
982
965
  return n(r(e)), {
983
966
  ...i,
984
- templateId: G
967
+ templateId: nt
985
968
  };
986
969
  }
987
970
  let s = o !== void 0 && (o.background !== void 0 || o.page.elements.length > 0 || o.page.margins !== void 0 || i.margins !== void 0 || i.width !== o.page.width || i.height !== o.page.height);
@@ -1005,19 +988,19 @@ function pt(e, t = (e) => e, n = console.warn) {
1005
988
  templates: void 0
1006
989
  };
1007
990
  }
1008
- function mt() {
991
+ function pt() {
1009
992
  let e = W(210, 297, t("core.documentModel.initialPageName"));
1010
993
  return {
1011
- dataSources: ht(),
994
+ dataSources: mt(),
1012
995
  name: t("core.documentModel.defaultDocumentName"),
1013
996
  pages: [e],
1014
997
  parserVersion: H,
1015
998
  repeatGroups: [],
1016
- templates: [K()],
999
+ templates: [G()],
1017
1000
  version: "1.0"
1018
1001
  };
1019
1002
  }
1020
- function ht() {
1003
+ function mt() {
1021
1004
  return [
1022
1005
  {
1023
1006
  description: t("core.documentModel.orderSourceDescription"),
@@ -1116,50 +1099,45 @@ function ht() {
1116
1099
  }
1117
1100
  ];
1118
1101
  }
1119
- function gt(n) {
1102
+ function ht(n) {
1120
1103
  if (!Array.isArray(n.pages) || n.pages.length === 0) throw new e(t("core.documentModel.missingPages"), { code: "document.no-pages" });
1121
1104
  }
1122
- function _t(r, i = k) {
1105
+ function gt(r, i = A) {
1123
1106
  if (!r || typeof r != "object") throw new e(t("core.documentModel.invalidDocument"), { code: "document.invalid" });
1124
1107
  let a = r;
1125
- gt(a);
1126
- let o = [], s = !Array.isArray(a.templates) || a.templates.length === 0, c = yt(a.templates, o, i), l = {
1108
+ ht(a);
1109
+ let o = [], s = vt(a.templates, o, i), c = {
1127
1110
  name: "",
1128
1111
  pages: a.pages,
1129
- templates: c,
1112
+ templates: s,
1130
1113
  version: "1.0"
1131
- }, u = a.pages.map((e, t) => {
1132
- let n = e?.templateId, r = n && n !== "template-none" && !c.some((e) => e.id === n) ? {
1114
+ }, l = a.pages.map((e, t) => {
1115
+ let n = e?.templateId, r = n && n !== "template-none" && !s.some((e) => e.id === n) ? {
1133
1116
  ...e,
1134
1117
  templateId: void 0
1135
- } : e;
1136
- s && (r?.templateId === void 0 || r.templateId === "template-blank") && (r = {
1137
- ...r,
1138
- templateId: G
1139
- });
1140
- let a = Z(l, r ?? {}, t + 1);
1118
+ } : e, a = Z(c, r ?? {}, t + 1);
1141
1119
  return Q(a ? {
1142
1120
  ...r,
1143
1121
  ...z(a.page)
1144
1122
  } : r, t, o, i);
1145
- }), d = {
1123
+ }), u = {
1146
1124
  dataSources: n(Array.isArray(a.dataSources) ? a.dataSources : []),
1147
1125
  elementGroups: Se(a.elementGroups),
1148
- followBlocks: vt(a.followBlocks),
1126
+ followBlocks: _t(a.followBlocks),
1149
1127
  name: typeof a.name == "string" && a.name ? a.name : t("core.documentModel.defaultDocumentName"),
1150
- pages: u,
1151
- parserVersion: et(a.parserVersion),
1152
- repeatGroups: wt(a.repeatGroups, u),
1153
- templates: c,
1128
+ pages: l,
1129
+ parserVersion: $e(a.parserVersion),
1130
+ repeatGroups: Ct(a.repeatGroups, l),
1131
+ templates: s,
1154
1132
  version: "1.0"
1155
1133
  };
1156
- for (let e of [...X(d)]) for (let t of e.elements) L(d, t, t, i), F(d, t, i);
1157
- return Ze(d), R(d, i), oe(d), {
1158
- document: d,
1134
+ for (let e of [...X(u)]) for (let t of e.elements) I(u, t, i);
1135
+ return Ye(u), R(u, i), oe(u), {
1136
+ document: u,
1159
1137
  skippedTypes: o
1160
1138
  };
1161
1139
  }
1162
- function vt(e) {
1140
+ function _t(e) {
1163
1141
  if (!Array.isArray(e)) return [];
1164
1142
  let t = [];
1165
1143
  for (let n of e) {
@@ -1187,21 +1165,24 @@ function Q(e, n, r, i) {
1187
1165
  let a = {
1188
1166
  background: typeof e?.background == "string" ? e.background : "#ffffff",
1189
1167
  elements: [],
1190
- guides: bt(e?.guides),
1168
+ guides: yt(e?.guides),
1191
1169
  height: $(e?.height, 297),
1192
1170
  id: typeof e?.id == "string" ? e.id : U("page"),
1193
1171
  margins: e?.margins === void 0 ? void 0 : B(e.margins),
1194
1172
  name: typeof e?.name == "string" ? e.name : t("core.documentModel.numberedPageName", { pageNumber: n + 1 }),
1195
1173
  templateId: typeof e?.templateId == "string" ? e.templateId : void 0,
1196
1174
  width: $(e?.width, 210)
1197
- };
1198
- if (V(a), Array.isArray(e?.elements)) for (let t of e.elements) {
1199
- let e = xt(t, r, i);
1175
+ }, o = e?.position;
1176
+ if (o && Number.isFinite(o.x) && Number.isFinite(o.y) && (a.position = {
1177
+ x: Math.max(0, b(o.x, 2)),
1178
+ y: Math.max(0, b(o.y, 2))
1179
+ }), V(a), Array.isArray(e?.elements)) for (let t of e.elements) {
1180
+ let e = bt(t, r, i);
1200
1181
  e && a.elements.push(e);
1201
1182
  }
1202
1183
  return a;
1203
1184
  }
1204
- function yt(e, n, r) {
1185
+ function vt(e, n, r) {
1205
1186
  let i = [];
1206
1187
  if (Array.isArray(e)) for (let a of e) {
1207
1188
  if (!a || typeof a != "object") continue;
@@ -1223,9 +1204,9 @@ function yt(e, n, r) {
1223
1204
  requiredElements: Array.isArray(e.requiredElements) ? e.requiredElements.filter((e) => typeof e?.elementId == "string" && typeof e?.type == "string").map((e) => ({ ...e })) : void 0
1224
1205
  });
1225
1206
  }
1226
- return i.some((e) => e.id === "template-blank") || i.unshift(K()), i;
1207
+ return i.some((e) => e.id === "template-blank") || i.unshift(G()), i;
1227
1208
  }
1228
- function bt(e) {
1209
+ function yt(e) {
1229
1210
  if (!Array.isArray(e)) return [];
1230
1211
  let t = [];
1231
1212
  for (let n of e) n && typeof n == "object" && typeof n.orientation == "string" && t.push({
@@ -1235,15 +1216,15 @@ function bt(e) {
1235
1216
  });
1236
1217
  return t;
1237
1218
  }
1238
- function xt(e, t, n) {
1219
+ function bt(e, t, n) {
1239
1220
  if (!e || typeof e != "object" || !("type" in e) || typeof e.type != "string") return;
1240
1221
  let r = n.get(e.type);
1241
1222
  if (!r) {
1242
1223
  t.includes(e.type) || t.push(e.type);
1243
1224
  return;
1244
1225
  }
1245
- let i = e, a = ct(e.type, {}, n), o = {
1246
- bindings: St(i.bindings),
1226
+ let i = e, a = q(e.type, {}, n), o = {
1227
+ bindings: xt(i.bindings),
1247
1228
  height: $(i.height, r.defaultSize.height),
1248
1229
  id: typeof i.id == "string" ? i.id : a.id,
1249
1230
  locked: i.locked === !0,
@@ -1263,19 +1244,19 @@ function xt(e, t, n) {
1263
1244
  x: $(i.x, 0),
1264
1245
  y: $(i.y, 0)
1265
1246
  };
1266
- return r.pointBased && Ct(o, i.points), Object.assign(o, j(o, { width: o.width }, n)), o;
1247
+ return r.pointBased && (o.points = a.points?.map((e) => ({ ...e })), St(o, i.points)), Object.assign(o, M(o, { width: o.width }, n)), o;
1267
1248
  }
1268
- function St(e) {
1249
+ function xt(e) {
1269
1250
  if (e && typeof e == "object") return Object.fromEntries(Object.entries(e).filter((e) => typeof e[1] == "string"));
1270
1251
  }
1271
- function Ct(e, t) {
1252
+ function St(e, t) {
1272
1253
  let n = (Array.isArray(t) ? t : []).filter((e) => e && typeof e == "object").map((e) => ({
1273
1254
  x: $(e.x, 0),
1274
1255
  y: $(e.y, 0)
1275
1256
  }));
1276
- n.length === 0 ? ut(e) : Object.assign(e, E(e, n));
1257
+ n.length === 0 ? Object.assign(e, D(e, e.points ?? [])) : Object.assign(e, D(e, n));
1277
1258
  }
1278
- function wt(e, n) {
1259
+ function Ct(e, n) {
1279
1260
  if (!Array.isArray(e)) return [];
1280
1261
  let r = [];
1281
1262
  for (let i of e) {
@@ -1299,4 +1280,4 @@ function wt(e, n) {
1299
1280
  function $(e, t) {
1300
1281
  return typeof e == "number" && Number.isFinite(e) ? e : t;
1301
1282
  }
1302
- export { D as $, R as A, A as B, et as C, Qe as D, $e as E, Je as F, k as G, qe as H, Ze as I, O as J, Ge as K, Ye as L, P as M, I as N, L as O, M as P, ke as Q, Xe as R, H as S, z as T, He as U, Ke as V, Ue as W, Be as X, Ve as Y, Pe as Z, X as _, gt as a, Te as at, pt as b, ct as c, be as ct, mt as d, de as dt, Ae as et, st as f, pe as ft, q as g, me as gt, dt as h, ye as ht, lt as i, De as it, F as j, N as k, U as l, ce as lt, Y as m, oe as mt, tt as n, Oe as nt, J as o, y as ot, _t as p, ge as pt, We as q, G as r, Ee as rt, K as s, le as st, nt as t, Ce as tt, W as u, xe as ut, ft as v, V as w, rt as x, Z as y, j as z };
1283
+ export { ke as $, R as A, j as B, $e as C, Xe as D, Qe as E, Ke as F, A as G, Ge as H, Ye as I, k as J, Ue as K, qe as L, F as M, L as N, Ze as O, N as P, O as Q, Je as R, H as S, z as T, Be as U, We as V, Ve as W, Re as X, ze as Y, Oe as Z, X as _, ht as a, b as at, ft as b, q as c, ce as ct, pt as d, pe as dt, y as et, st as f, ge as ft, K as g, ut as h, me as ht, ct as i, we as it, I as j, P as k, U as l, xe as lt, Y as m, ye as mt, et as n, Te as nt, J as o, le as ot, gt as p, oe as pt, He as q, nt as r, Ee as rt, G as s, be as st, tt as t, De as tt, W as u, de as ut, dt as v, V as w, rt as x, Z as y, M as z };