@printstack/print-studio 0.1.2 → 0.1.3
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/README.md +8 -2
- package/assets/{render.worker-DkH7TepL.js → render.worker-Dl59Xk1a.js} +11 -11
- package/components/button-group/ButtonGroup.d.ts +1 -1
- package/core/index.d.ts +1 -0
- package/core.js +10 -10
- package/designer/facade/entities.d.ts +4 -4
- package/designer/facade/use-print-studio.d.ts +1 -1
- package/designer/stores/editor-store.d.ts +2 -2
- package/designer/stores/selection-store.d.ts +1 -1
- package/designer.js +1 -1
- package/elements/index.d.ts +2 -4
- package/{registries-sg39PGF1.js → elements-YX-XUHtf.js} +2480 -3026
- package/host-oKlYakgn.js +123 -0
- package/index.d.ts +3 -1
- package/index.js +9 -8
- package/{mount-print-designer-DnHTrBE9.js → mount-print-designer-CAqO0T0k.js} +3 -3
- package/{mount-print-preview-Bcb08lJ-.js → mount-print-preview-DgDHL3E8.js} +2 -2
- package/package.json +19 -2
- package/parser/index.d.ts +1 -1
- package/parser/registry.d.ts +8 -0
- package/parser/render-runtime.d.ts +1 -1
- package/{presets-BunYODhE.js → presets-DmCp_Doe.js} +1 -1
- package/printer.d.ts +17 -0
- package/printer.js +3 -0
- package/registries-CyjYSHA7.js +1841 -0
- package/runtime/print-renderer.d.ts +3 -2
- package/runtime/registries.d.ts +1 -0
- package/runtime.js +31 -27
- package/{studio-B3B6zI06.js → studio-DHusmJyL.js} +1035 -1032
- package/studio.d.ts +1 -1
- package/style.css +1 -1
- package/vue.d.ts +1 -1
- package/vue.js +3158 -3158
- package/document-model-Cc5RoO4j.js +0 -1283
- package/host-OAp3gFDx.js +0 -123
|
@@ -1,1283 +0,0 @@
|
|
|
1
|
-
import { A as e, B as t, I as n, j as r, t as i } from "./cloneDeep-waBDTGc3.js";
|
|
2
|
-
// node_modules/.pnpm/uuid@14.0.3/node_modules/uuid/dist/stringify.js
|
|
3
|
-
var a = [];
|
|
4
|
-
for (let e = 0; e < 256; ++e) a.push((e + 256).toString(16).slice(1));
|
|
5
|
-
function o(e, t = 0) {
|
|
6
|
-
return (a[e[t + 0]] + a[e[t + 1]] + a[e[t + 2]] + a[e[t + 3]] + "-" + a[e[t + 4]] + a[e[t + 5]] + "-" + a[e[t + 6]] + a[e[t + 7]] + "-" + a[e[t + 8]] + a[e[t + 9]] + "-" + a[e[t + 10]] + a[e[t + 11]] + a[e[t + 12]] + a[e[t + 13]] + a[e[t + 14]] + a[e[t + 15]]).toLowerCase();
|
|
7
|
-
}
|
|
8
|
-
// node_modules/.pnpm/uuid@14.0.3/node_modules/uuid/dist/rng.js
|
|
9
|
-
var s = /* @__PURE__ */ new Uint8Array(16);
|
|
10
|
-
function c() {
|
|
11
|
-
return crypto.getRandomValues(s);
|
|
12
|
-
}
|
|
13
|
-
// node_modules/.pnpm/uuid@14.0.3/node_modules/uuid/dist/v7.js
|
|
14
|
-
var l = {};
|
|
15
|
-
function u(e, t, n) {
|
|
16
|
-
let r;
|
|
17
|
-
if (e) r = ee(e.random ?? e.rng?.() ?? c(), e.msecs, e.seq, t, n);
|
|
18
|
-
else {
|
|
19
|
-
let e = Date.now(), i = c();
|
|
20
|
-
d(l, e, i), r = ee(i, l.msecs, l.seq, t, n);
|
|
21
|
-
}
|
|
22
|
-
return t ?? o(r);
|
|
23
|
-
}
|
|
24
|
-
function d(e, t, n) {
|
|
25
|
-
return e.msecs ??= -Infinity, e.seq ??= 0, t > e.msecs ? (e.seq = te(n), e.msecs = t) : (e.seq = e.seq + 1 | 0, e.seq === 0 && e.msecs++), e;
|
|
26
|
-
}
|
|
27
|
-
function ee(e, t, n, r, i = 0) {
|
|
28
|
-
if (e.length < 16) throw Error("Random bytes length must be >= 16");
|
|
29
|
-
if (!r) r = /* @__PURE__ */ new Uint8Array(16), i = 0;
|
|
30
|
-
else if (i < 0 || i + 16 > r.length) throw RangeError(`UUID byte range ${i}:${i + 15} is out of buffer bounds`);
|
|
31
|
-
return t ??= Date.now(), n ??= te(e), r[i++] = t / 1099511627776 & 255, r[i++] = t / 4294967296 & 255, r[i++] = t / 16777216 & 255, r[i++] = t / 65536 & 255, r[i++] = t / 256 & 255, r[i++] = t & 255, r[i++] = 112 | n >>> 28 & 15, r[i++] = n >>> 20 & 255, r[i++] = 128 | n >>> 14 & 63, r[i++] = n >>> 6 & 255, r[i++] = n << 2 & 255 | e[10] & 3, r[i++] = e[11], r[i++] = e[12], r[i++] = e[13], r[i++] = e[14], r[i++] = e[15], r;
|
|
32
|
-
}
|
|
33
|
-
function te(e) {
|
|
34
|
-
return (e[6] & 127) << 24 | e[7] << 16 | e[8] << 8 | e[9];
|
|
35
|
-
}
|
|
36
|
-
// src/core/element-group.ts
|
|
37
|
-
function ne(e, t) {
|
|
38
|
-
let n = t.map((t) => e.elements.findIndex((e) => e.id === t));
|
|
39
|
-
return !n.some((e) => e < 0) && Math.max(...n) - Math.min(...n) + 1 === n.length;
|
|
40
|
-
}
|
|
41
|
-
function re(e, t) {
|
|
42
|
-
let n = /* @__PURE__ */ new Set([e.id]), r = e.parentId ? t.get(e.parentId) : void 0;
|
|
43
|
-
for (; r;) {
|
|
44
|
-
if (n.has(r.id)) return !0;
|
|
45
|
-
n.add(r.id), r = r.parentId ? t.get(r.parentId) : void 0;
|
|
46
|
-
}
|
|
47
|
-
return !1;
|
|
48
|
-
}
|
|
49
|
-
function ie(e) {
|
|
50
|
-
let t = { ...e };
|
|
51
|
-
return delete t.parentId, t;
|
|
52
|
-
}
|
|
53
|
-
function ae(e, t) {
|
|
54
|
-
let n = new Set(e.elements.map((e) => e.id)), r = /* @__PURE__ */ new Set(), i = [];
|
|
55
|
-
for (let a of t) {
|
|
56
|
-
if (r.has(a.id)) continue;
|
|
57
|
-
r.add(a.id);
|
|
58
|
-
let t = [...new Set(a.elementIds)].filter((e) => n.has(e));
|
|
59
|
-
t.length !== 0 && ne(e, t) && i.push({
|
|
60
|
-
...a,
|
|
61
|
-
elementIds: t
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
let a = !0;
|
|
65
|
-
for (; a;) {
|
|
66
|
-
a = !1;
|
|
67
|
-
let e = new Map(i.map((e) => [e.id, e])), t = [], n = /* @__PURE__ */ new Map();
|
|
68
|
-
for (let r of i) {
|
|
69
|
-
let i = r.parentId ? e.get(r.parentId) : void 0, o = !0;
|
|
70
|
-
if (r.parentId && (!i || re(r, e))) o = !1;
|
|
71
|
-
else if (i) {
|
|
72
|
-
let e = new Set(i.elementIds);
|
|
73
|
-
o = r.elementIds.every((t) => e.has(t));
|
|
74
|
-
}
|
|
75
|
-
let s = r.parentId ?? "", c = n.get(s) ?? /* @__PURE__ */ new Set();
|
|
76
|
-
if (o && r.elementIds.some((e) => c.has(e)) && (o = !1), !o) a = !0;
|
|
77
|
-
else {
|
|
78
|
-
for (let e of r.elementIds) c.add(e);
|
|
79
|
-
n.set(s, c), t.push(r);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
let r = new Set(t.map((e) => e.id));
|
|
83
|
-
i = t.map((e) => !e.parentId || r.has(e.parentId) ? e : ie(e));
|
|
84
|
-
}
|
|
85
|
-
return i;
|
|
86
|
-
}
|
|
87
|
-
function oe(e) {
|
|
88
|
-
if (!e.elementGroups || e.elementGroups.length === 0) return;
|
|
89
|
-
let t = [];
|
|
90
|
-
for (let n of X(e)) {
|
|
91
|
-
let r = e.elementGroups.filter((e) => e.pageId === n.id);
|
|
92
|
-
t.push(...ae(n, r));
|
|
93
|
-
}
|
|
94
|
-
e.elementGroups = t;
|
|
95
|
-
}
|
|
96
|
-
function se(e, t) {
|
|
97
|
-
let n = 0, r = e.parentId ? t.get(e.parentId) : void 0;
|
|
98
|
-
for (; r;) n += 1, r = r.parentId ? t.get(r.parentId) : void 0;
|
|
99
|
-
return n;
|
|
100
|
-
}
|
|
101
|
-
function ce(e, t) {
|
|
102
|
-
let n = t.filter((t) => t.pageId === e.id), r = new Map(n.map((e) => [e.id, e])), i = /* @__PURE__ */ new Map();
|
|
103
|
-
for (let e of n) {
|
|
104
|
-
let t = se(e, r);
|
|
105
|
-
for (let n of e.elementIds) {
|
|
106
|
-
let a = i.get(n);
|
|
107
|
-
(!a || se(a, r) < t) && i.set(n, e);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
let a = [], o = [];
|
|
111
|
-
for (let t of e.elements) {
|
|
112
|
-
let e = [], n = i.get(t.id);
|
|
113
|
-
for (; n;) e.unshift(n), n = n.parentId ? r.get(n.parentId) : void 0;
|
|
114
|
-
let s = 0;
|
|
115
|
-
for (; s < o.length && s < e.length && o[s].group.id === e[s].id;) s += 1;
|
|
116
|
-
o.length = s;
|
|
117
|
-
for (let t of e.slice(s)) {
|
|
118
|
-
let e = {
|
|
119
|
-
children: [],
|
|
120
|
-
group: t,
|
|
121
|
-
kind: "group"
|
|
122
|
-
};
|
|
123
|
-
(o.length > 0 ? o[o.length - 1].children : a).push(e), o.push(e);
|
|
124
|
-
}
|
|
125
|
-
(o.length > 0 ? o[o.length - 1].children : a).push({
|
|
126
|
-
kind: "element",
|
|
127
|
-
node: t
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return a;
|
|
131
|
-
}
|
|
132
|
-
function f(e) {
|
|
133
|
-
let t = [];
|
|
134
|
-
for (let n of e) n.kind === "element" ? t.push(n.node) : t.push(...f(n.children));
|
|
135
|
-
return t;
|
|
136
|
-
}
|
|
137
|
-
function p(e, t, n) {
|
|
138
|
-
for (let r of e) {
|
|
139
|
-
if (r.kind !== "group") continue;
|
|
140
|
-
let e = f(r.children).map((e) => e.id);
|
|
141
|
-
if (e.length === 0) continue;
|
|
142
|
-
let i = {
|
|
143
|
-
...ie(r.group),
|
|
144
|
-
elementIds: e
|
|
145
|
-
};
|
|
146
|
-
t && (i.parentId = t), n.push(i), p(r.children, r.group.id, n);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function le(e, t, n) {
|
|
150
|
-
t.elements = f(n);
|
|
151
|
-
let r = [];
|
|
152
|
-
p(n, void 0, r), e.elementGroups = [...(e.elementGroups ?? []).filter((e) => e.pageId !== t.id), ...r];
|
|
153
|
-
}
|
|
154
|
-
function m(e) {
|
|
155
|
-
return e.kind === "element" ? {
|
|
156
|
-
id: e.node.id,
|
|
157
|
-
kind: "element"
|
|
158
|
-
} : {
|
|
159
|
-
id: e.group.id,
|
|
160
|
-
kind: "group"
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
function h(e, t) {
|
|
164
|
-
let n = m(e);
|
|
165
|
-
return n.kind === t.kind && n.id === t.id;
|
|
166
|
-
}
|
|
167
|
-
function g(e, t, n = null) {
|
|
168
|
-
for (let [r, i] of e.entries()) {
|
|
169
|
-
if (h(i, t)) return {
|
|
170
|
-
index: r,
|
|
171
|
-
parent: n,
|
|
172
|
-
siblings: e
|
|
173
|
-
};
|
|
174
|
-
if (i.kind === "group") {
|
|
175
|
-
let e = g(i.children, t, i);
|
|
176
|
-
if (e) return e;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
function ue(e) {
|
|
182
|
-
return e.kind === "element" ? [e.node.id] : f(e.children).map((e) => e.id);
|
|
183
|
-
}
|
|
184
|
-
function _(e, t) {
|
|
185
|
-
return h(e, t) ? !0 : e.kind !== "element" && e.children.some((e) => _(e, t));
|
|
186
|
-
}
|
|
187
|
-
function v(e, t) {
|
|
188
|
-
for (let n of e) {
|
|
189
|
-
if (n.kind === "element") {
|
|
190
|
-
if (n.node.id === t) return [];
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
let e = v(n.children, t);
|
|
194
|
-
if (e.length > 0 || ue(n).includes(t)) return [n, ...e];
|
|
195
|
-
}
|
|
196
|
-
return [];
|
|
197
|
-
}
|
|
198
|
-
function de(e, t) {
|
|
199
|
-
if (t.length === 0) return;
|
|
200
|
-
let n = t.map((t) => v(e, t)), r = n[0], i;
|
|
201
|
-
for (let [e, t] of r.entries()) {
|
|
202
|
-
if (!n.every((n) => n[e]?.group.id === t.group.id)) break;
|
|
203
|
-
i = t;
|
|
204
|
-
}
|
|
205
|
-
return i?.group;
|
|
206
|
-
}
|
|
207
|
-
function fe(e) {
|
|
208
|
-
for (let t = e.length - 1; t >= 0; --t) {
|
|
209
|
-
let n = e[t];
|
|
210
|
-
n.kind === "group" && (fe(n.children), n.children.length === 0 && e.splice(t, 1));
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function pe(e, t, n) {
|
|
214
|
-
let r = [...new Set(t)];
|
|
215
|
-
if (r.length === 0) return !1;
|
|
216
|
-
let i = r.map((t) => v(e, t)), a = 0;
|
|
217
|
-
for (; i.every((e) => e[a] !== void 0 && e[a].group.id === i[0][a]?.group.id);) a += 1;
|
|
218
|
-
let o = a > 0 ? i[0][a - 1] : null, s = o ? o.children : e, c = /* @__PURE__ */ new Set();
|
|
219
|
-
for (let [e, t] of r.entries()) {
|
|
220
|
-
let n = i[e][a], r = n ? {
|
|
221
|
-
id: n.group.id,
|
|
222
|
-
kind: "group"
|
|
223
|
-
} : {
|
|
224
|
-
id: t,
|
|
225
|
-
kind: "element"
|
|
226
|
-
}, o = s.findIndex((e) => h(e, r));
|
|
227
|
-
o >= 0 && c.add(o);
|
|
228
|
-
}
|
|
229
|
-
if (c.size === 0 || o && c.size === s.length) return !1;
|
|
230
|
-
let l = [...c].sort((e, t) => e - t), u = l[l.length - 1], d = l.map((e) => s[e]);
|
|
231
|
-
for (let e of [...l].reverse()) s.splice(e, 1);
|
|
232
|
-
return s.splice(u - l.length + 1, 0, {
|
|
233
|
-
children: d,
|
|
234
|
-
group: n,
|
|
235
|
-
kind: "group"
|
|
236
|
-
}), !0;
|
|
237
|
-
}
|
|
238
|
-
function me(e, t) {
|
|
239
|
-
let n = g(e, {
|
|
240
|
-
id: t,
|
|
241
|
-
kind: "group"
|
|
242
|
-
});
|
|
243
|
-
if (!n) return !1;
|
|
244
|
-
let r = n.siblings[n.index];
|
|
245
|
-
return r.kind === "group" && (n.siblings.splice(n.index, 1, ...r.children), !0);
|
|
246
|
-
}
|
|
247
|
-
function he(e, t) {
|
|
248
|
-
let n = [];
|
|
249
|
-
function r(e) {
|
|
250
|
-
for (let t of e) n.push(m(t)), t.kind === "group" && r(t.children);
|
|
251
|
-
}
|
|
252
|
-
r(e);
|
|
253
|
-
let i = (e) => n.findIndex((t) => t.kind === e.kind && t.id === e.id);
|
|
254
|
-
return [...t].sort((e, t) => i(e) - i(t));
|
|
255
|
-
}
|
|
256
|
-
function ge(e, t, n, r) {
|
|
257
|
-
let i = he(e, t), a = [];
|
|
258
|
-
for (let t of i) {
|
|
259
|
-
let n = g(e, t);
|
|
260
|
-
if (!n) continue;
|
|
261
|
-
let r = n.siblings[n.index];
|
|
262
|
-
a.some((e) => _(e, t)) || a.push(r);
|
|
263
|
-
}
|
|
264
|
-
if (a.length === 0 || a.some((e) => _(e, n)) || r === "inside" && n.kind !== "group") return !1;
|
|
265
|
-
for (let t of a) {
|
|
266
|
-
let n = g(e, m(t));
|
|
267
|
-
n?.siblings.splice(n.index, 1);
|
|
268
|
-
}
|
|
269
|
-
let o = g(e, n);
|
|
270
|
-
if (!o) return !1;
|
|
271
|
-
let s = o.siblings[o.index];
|
|
272
|
-
return r === "inside" && s.kind === "group" ? s.children.push(...a) : r === "above" ? o.siblings.splice(o.index + 1, 0, ...a) : o.siblings.splice(o.index, 0, ...a), fe(e), !0;
|
|
273
|
-
}
|
|
274
|
-
function _e(e, t) {
|
|
275
|
-
let n = [];
|
|
276
|
-
for (let r of e) {
|
|
277
|
-
if (r.kind === "element") {
|
|
278
|
-
t.has(r.node.id) && n.push(m(r));
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
let e = ue(r);
|
|
282
|
-
e.length > 0 && e.every((e) => t.has(e)) ? n.push(m(r)) : n.push(..._e(r.children, t));
|
|
283
|
-
}
|
|
284
|
-
return n;
|
|
285
|
-
}
|
|
286
|
-
function ve(e, t, n) {
|
|
287
|
-
return "edge" in e ? e.edge === "front" ? n - 1 : 0 : Math.min(Math.max(t + e.offset, 0), n - 1);
|
|
288
|
-
}
|
|
289
|
-
function ye(e, t, n) {
|
|
290
|
-
let r = _e(e, new Set(t));
|
|
291
|
-
if (r.length === 0) return !1;
|
|
292
|
-
let i = ("edge" in n ? n.edge === "back" : n.offset > 0) ? [...r].reverse() : r, a = !1;
|
|
293
|
-
for (let t of i) {
|
|
294
|
-
let r = g(e, t);
|
|
295
|
-
if (!r) continue;
|
|
296
|
-
let { index: i, siblings: o } = r, s = ve(n, i, o.length);
|
|
297
|
-
if (s === i) continue;
|
|
298
|
-
let [c] = o.splice(i, 1);
|
|
299
|
-
o.splice(s, 0, c), a = !0;
|
|
300
|
-
}
|
|
301
|
-
return a;
|
|
302
|
-
}
|
|
303
|
-
function be(e, t) {
|
|
304
|
-
let n = [];
|
|
305
|
-
function r(e, i, a) {
|
|
306
|
-
for (let o of [...e].reverse()) o.kind === "element" ? n.push({
|
|
307
|
-
depth: i,
|
|
308
|
-
kind: "element",
|
|
309
|
-
node: o.node,
|
|
310
|
-
parentId: a
|
|
311
|
-
}) : (n.push({
|
|
312
|
-
depth: i,
|
|
313
|
-
group: o.group,
|
|
314
|
-
kind: "group",
|
|
315
|
-
parentId: a
|
|
316
|
-
}), t(o.group.id) || r(o.children, i + 1, o.group.id));
|
|
317
|
-
}
|
|
318
|
-
return r(e, 0, void 0), n;
|
|
319
|
-
}
|
|
320
|
-
function xe(e, n, r, i) {
|
|
321
|
-
let a = (e.elementGroups ?? []).filter((e) => e.pageId === n).length;
|
|
322
|
-
return {
|
|
323
|
-
elementIds: [],
|
|
324
|
-
id: r("layer-group"),
|
|
325
|
-
name: i ?? t("core.elementGroup.numberedName", { groupNumber: a + 1 }),
|
|
326
|
-
pageId: n
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function Se(e) {
|
|
330
|
-
if (!Array.isArray(e)) return [];
|
|
331
|
-
let n = [];
|
|
332
|
-
for (let r of e) {
|
|
333
|
-
if (!r || typeof r != "object") continue;
|
|
334
|
-
let e = r;
|
|
335
|
-
if (typeof e.id != "string" || typeof e.pageId != "string" || !Array.isArray(e.elementIds)) continue;
|
|
336
|
-
let i = {
|
|
337
|
-
elementIds: e.elementIds.filter((e) => typeof e == "string"),
|
|
338
|
-
id: e.id,
|
|
339
|
-
name: typeof e.name == "string" && e.name ? e.name : t("core.elementGroup.defaultName"),
|
|
340
|
-
pageId: e.pageId
|
|
341
|
-
};
|
|
342
|
-
typeof e.parentId == "string" && e.parentId && (i.parentId = e.parentId), n.push(i);
|
|
343
|
-
}
|
|
344
|
-
return n;
|
|
345
|
-
}
|
|
346
|
-
// src/core/units.ts
|
|
347
|
-
var y = 96 / 25.4, Ce = 25.4 / 72;
|
|
348
|
-
function we(e, t = 1) {
|
|
349
|
-
return e / (y * t);
|
|
350
|
-
}
|
|
351
|
-
function Te(e) {
|
|
352
|
-
return e * Ce;
|
|
353
|
-
}
|
|
354
|
-
function Ee(e, t = 1) {
|
|
355
|
-
return 96 / 72 * e * t;
|
|
356
|
-
}
|
|
357
|
-
function De(e, t, n) {
|
|
358
|
-
return e < t ? t : e > n ? n : e;
|
|
359
|
-
}
|
|
360
|
-
function b(e, t = 2) {
|
|
361
|
-
let n = 10 ** t;
|
|
362
|
-
return Math.round(e * n) / n;
|
|
363
|
-
}
|
|
364
|
-
// src/core/geometry.ts
|
|
365
|
-
function x(e) {
|
|
366
|
-
return (e % 360 + 540) % 360 - 180;
|
|
367
|
-
}
|
|
368
|
-
function Oe(e, t) {
|
|
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
|
-
return {
|
|
371
|
-
height: c * 2,
|
|
372
|
-
width: s * 2,
|
|
373
|
-
x: a - s,
|
|
374
|
-
y: o - c
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
function ke(e) {
|
|
378
|
-
if (e.length === 0) return null;
|
|
379
|
-
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
|
|
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);
|
|
381
|
-
return {
|
|
382
|
-
height: i - n,
|
|
383
|
-
width: r - t,
|
|
384
|
-
x: t,
|
|
385
|
-
y: n
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
function Ae(e) {
|
|
389
|
-
if (e.length === 0) return {
|
|
390
|
-
height: 1,
|
|
391
|
-
width: 1,
|
|
392
|
-
x: 0,
|
|
393
|
-
y: 0
|
|
394
|
-
};
|
|
395
|
-
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
|
|
396
|
-
for (let a of e) t = Math.min(t, a.x), n = Math.min(n, a.y), r = Math.max(r, a.x), i = Math.max(i, a.y);
|
|
397
|
-
return {
|
|
398
|
-
height: i - n,
|
|
399
|
-
width: r - t,
|
|
400
|
-
x: t,
|
|
401
|
-
y: n
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
function je(e, t, n) {
|
|
405
|
-
return e.map((e) => ({
|
|
406
|
-
x: b(e.x + t),
|
|
407
|
-
y: b(e.y + n)
|
|
408
|
-
}));
|
|
409
|
-
}
|
|
410
|
-
function Me(e, t, n, r) {
|
|
411
|
-
return e.map((e) => ({
|
|
412
|
-
x: b(t.x + (e.x - t.x) * n),
|
|
413
|
-
y: b(t.y + (e.y - t.y) * r)
|
|
414
|
-
}));
|
|
415
|
-
}
|
|
416
|
-
function S(e) {
|
|
417
|
-
if (e.length < 2) return 0;
|
|
418
|
-
let t = e[0], n = e[e.length - 1];
|
|
419
|
-
return x(Math.atan2(n.y - t.y, n.x - t.x) * 180 / Math.PI);
|
|
420
|
-
}
|
|
421
|
-
function Ne(e) {
|
|
422
|
-
if (e.length < 2) return 0;
|
|
423
|
-
let t = e[0], n = e[e.length - 1];
|
|
424
|
-
return Math.hypot(n.x - t.x, n.y - t.y);
|
|
425
|
-
}
|
|
426
|
-
var C = .01;
|
|
427
|
-
function w(e, t, n, r) {
|
|
428
|
-
let i = t, a = n(t), o = r && r(t) ? t : null, s = o ? a : Infinity;
|
|
429
|
-
for (let e = -1; e <= 1; e += 1) for (let c = -1; c <= 1; c += 1) {
|
|
430
|
-
let l = {
|
|
431
|
-
x: b(t.x + e * C),
|
|
432
|
-
y: b(t.y + c * C)
|
|
433
|
-
}, u = n(l);
|
|
434
|
-
u < a && (i = l, a = u), r && r(l) && u < s && (o = l, s = u);
|
|
435
|
-
}
|
|
436
|
-
return o ?? i;
|
|
437
|
-
}
|
|
438
|
-
function Pe(e, t, n, r) {
|
|
439
|
-
let i = x(n);
|
|
440
|
-
return w(e, t, (t) => {
|
|
441
|
-
let n = S([e, t]);
|
|
442
|
-
return Math.abs(x(n - i));
|
|
443
|
-
}, r);
|
|
444
|
-
}
|
|
445
|
-
function Fe(e, t, n, r) {
|
|
446
|
-
return w(e, t, (t) => Math.abs(Math.hypot(t.x - e.x, t.y - e.y) - n), r);
|
|
447
|
-
}
|
|
448
|
-
function T(e, t, n) {
|
|
449
|
-
let r = t * Math.PI / 180;
|
|
450
|
-
return {
|
|
451
|
-
x: b(e.x + Math.cos(r) * n),
|
|
452
|
-
y: b(e.y + Math.sin(r) * n)
|
|
453
|
-
};
|
|
454
|
-
}
|
|
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));
|
|
458
|
-
}
|
|
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);
|
|
462
|
-
}
|
|
463
|
-
function Re(e, t, n) {
|
|
464
|
-
let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
|
|
465
|
-
if (a === 0) return Math.hypot(e.x - t.x, e.y - t.y);
|
|
466
|
-
let o = De(((e.x - t.x) * r + (e.y - t.y) * i) / a, 0, 1);
|
|
467
|
-
return Math.hypot(e.x - (t.x + o * r), e.y - (t.y + o * i));
|
|
468
|
-
}
|
|
469
|
-
function E(e) {
|
|
470
|
-
return Array.isArray(e.points) && e.points.length > 0;
|
|
471
|
-
}
|
|
472
|
-
function D(e, t) {
|
|
473
|
-
let n = Ae(t);
|
|
474
|
-
return {
|
|
475
|
-
height: b(Math.max(n.height, 0)),
|
|
476
|
-
points: t.map((e) => ({
|
|
477
|
-
x: b(e.x),
|
|
478
|
-
y: b(e.y)
|
|
479
|
-
})),
|
|
480
|
-
rotation: 0,
|
|
481
|
-
width: b(Math.max(n.width, 0)),
|
|
482
|
-
x: b(n.x),
|
|
483
|
-
y: b(n.y)
|
|
484
|
-
};
|
|
485
|
-
}
|
|
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)
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
// src/core/render/element-warning.ts
|
|
493
|
-
function k(e, n) {
|
|
494
|
-
return t("core.pageExtensions.elementFailed", {
|
|
495
|
-
elementName: e.name || e.id,
|
|
496
|
-
message: n instanceof Error && n.cause ? r(n) + " · " + r(n.cause) : r(n)
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
function ze(e, t, n) {
|
|
500
|
-
let r = k(e, t);
|
|
501
|
-
n ? n(r) : console.warn(r);
|
|
502
|
-
}
|
|
503
|
-
// src/core/element-registry.ts
|
|
504
|
-
var Be = class {
|
|
505
|
-
definitions = /* @__PURE__ */ new Map();
|
|
506
|
-
listeners = /* @__PURE__ */ new Set();
|
|
507
|
-
get(e) {
|
|
508
|
-
return this.definitions.get(e);
|
|
509
|
-
}
|
|
510
|
-
list() {
|
|
511
|
-
return [...this.definitions.values()].sort((e, t) => e.order === t.order ? e.type.localeCompare(t.type) : e.order - t.order);
|
|
512
|
-
}
|
|
513
|
-
register(e) {
|
|
514
|
-
if (this.definitions.has(e.type)) throw Error(t("core.elementRegistry.duplicateElementType", { elementType: e.type }));
|
|
515
|
-
this.definitions.set(e.type, e), this.notify();
|
|
516
|
-
}
|
|
517
|
-
subscribe(e) {
|
|
518
|
-
return this.listeners.add(e), () => {
|
|
519
|
-
this.listeners.delete(e);
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
toolItems() {
|
|
523
|
-
return this.list().map((e) => ({
|
|
524
|
-
icon: e.icon,
|
|
525
|
-
get label() {
|
|
526
|
-
return e.label;
|
|
527
|
-
},
|
|
528
|
-
shortcut: e.shortcut,
|
|
529
|
-
type: e.type
|
|
530
|
-
}));
|
|
531
|
-
}
|
|
532
|
-
unregister(e) {
|
|
533
|
-
let t = this.definitions.delete(e);
|
|
534
|
-
return t && this.notify(), t;
|
|
535
|
-
}
|
|
536
|
-
notify() {
|
|
537
|
-
for (let e of this.listeners) e();
|
|
538
|
-
}
|
|
539
|
-
}, A = new Be();
|
|
540
|
-
function Ve(e) {
|
|
541
|
-
return e;
|
|
542
|
-
}
|
|
543
|
-
function He(e) {
|
|
544
|
-
return e?.elements ?? A;
|
|
545
|
-
}
|
|
546
|
-
function Ue(e, t) {
|
|
547
|
-
if (!t.node.visible) return null;
|
|
548
|
-
try {
|
|
549
|
-
return e.get(t.node.type)?.paginate?.(t);
|
|
550
|
-
} catch (e) {
|
|
551
|
-
return t.warnings.add(k(t.node, e)), null;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
// src/core/element-transform.ts
|
|
555
|
-
function j(e, t = A) {
|
|
556
|
-
let n = t.get(e.type)?.getMinSize?.({
|
|
557
|
-
node: e,
|
|
558
|
-
props: e.props
|
|
559
|
-
});
|
|
560
|
-
return {
|
|
561
|
-
height: Math.max(1, n?.height ?? 1),
|
|
562
|
-
width: Math.max(1, n?.width ?? 1)
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
function M(e, t, n = A, r = {}) {
|
|
566
|
-
let i = n.get(e.type), a = i?.aspectRatio, o = t;
|
|
567
|
-
if (a && a > 0 && (typeof t.width == "number" ? o = {
|
|
568
|
-
...t,
|
|
569
|
-
height: b(t.width / a)
|
|
570
|
-
} : typeof t.height == "number" && (o = {
|
|
571
|
-
...t,
|
|
572
|
-
width: b(t.height * a)
|
|
573
|
-
})), r.enforceMinimum !== !1 && i?.getMinSize && ("width" in t || "height" in t || "props" in t || "type" in t)) {
|
|
574
|
-
let t = {
|
|
575
|
-
...e,
|
|
576
|
-
...o
|
|
577
|
-
}, r = j(t, n);
|
|
578
|
-
t.width < r.width && (o = {
|
|
579
|
-
...o,
|
|
580
|
-
width: r.width
|
|
581
|
-
}, t = {
|
|
582
|
-
...e,
|
|
583
|
-
...o
|
|
584
|
-
}, r = j(t, n)), t.height < r.height && (o = {
|
|
585
|
-
...o,
|
|
586
|
-
height: r.height
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
return o;
|
|
590
|
-
}
|
|
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));
|
|
595
|
-
}
|
|
596
|
-
return e[t];
|
|
597
|
-
}
|
|
598
|
-
function Ge(e, t, n) {
|
|
599
|
-
if (typeof n != "number" || !Number.isFinite(n)) return {};
|
|
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 });
|
|
603
|
-
let r = e.points, i = r[0], a = r[r.length - 1];
|
|
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)]);
|
|
606
|
-
if (t === "height") {
|
|
607
|
-
let t = e.height > 0 ? n / e.height : 1;
|
|
608
|
-
return D(e, Me(r, {
|
|
609
|
-
x: e.x,
|
|
610
|
-
y: e.y
|
|
611
|
-
}, 1, t));
|
|
612
|
-
}
|
|
613
|
-
return { [t]: n };
|
|
614
|
-
}
|
|
615
|
-
// src/core/follow-block.ts
|
|
616
|
-
function Ke(e) {
|
|
617
|
-
return `${e.kind}:${e.id}`;
|
|
618
|
-
}
|
|
619
|
-
function qe(e, t, n) {
|
|
620
|
-
if (n.kind === "element") {
|
|
621
|
-
let r = e.pages.find((e) => e.id === t)?.elements.find((e) => e.id === n.id);
|
|
622
|
-
return r ? {
|
|
623
|
-
elementIds: [r.id],
|
|
624
|
-
name: r.name
|
|
625
|
-
} : void 0;
|
|
626
|
-
}
|
|
627
|
-
let r = (n.kind === "followBlock" ? e.followBlocks : e.repeatGroups)?.find((e) => e.id === n.id && e.pageId === t);
|
|
628
|
-
return r ? {
|
|
629
|
-
elementIds: r.elementIds,
|
|
630
|
-
name: r.name
|
|
631
|
-
} : void 0;
|
|
632
|
-
}
|
|
633
|
-
function N(e, t) {
|
|
634
|
-
let n = e.pages.find((e) => e.id === t.pageId), r = (e.followBlocks ?? []).filter((e) => e.id !== t.id), i = e.repeatGroups ?? [];
|
|
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";
|
|
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";
|
|
637
|
-
let a = [...r, t], o = /* @__PURE__ */ new Set([t.id]), s = t;
|
|
638
|
-
for (;;) {
|
|
639
|
-
let e = s.target;
|
|
640
|
-
if (e.kind === "element") return !n.elements.some((t) => t.id === e.id) || a.some((t) => t.elementIds.includes(e.id)) || i.some((t) => t.elementIds.includes(e.id)) ? "invalidTarget" : void 0;
|
|
641
|
-
if (e.kind === "repeatGroup") return i.some((n) => n.id === e.id && n.pageId === t.pageId) ? void 0 : "invalidTarget";
|
|
642
|
-
let r = a.find((n) => n.id === e.id && n.pageId === t.pageId);
|
|
643
|
-
if (!r) return "invalidTarget";
|
|
644
|
-
if (o.has(r.id)) return "cycle";
|
|
645
|
-
o.add(r.id), s = r;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
function Je(n) {
|
|
649
|
-
let r = /* @__PURE__ */ new Set();
|
|
650
|
-
for (let i of n.followBlocks ?? []) {
|
|
651
|
-
let a = r.has(i.id) ? "invalidMembers" : N(n, i);
|
|
652
|
-
if (a) throw new e(t(`core.followBlock.${a}`), { code: `follow.${a}` });
|
|
653
|
-
r.add(i.id);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
function Ye(e) {
|
|
657
|
-
if (!e.followBlocks) return;
|
|
658
|
-
e.followBlocks = e.followBlocks.map((t) => {
|
|
659
|
-
let n = e.pages.find((e) => e.id === t.pageId);
|
|
660
|
-
return {
|
|
661
|
-
...t,
|
|
662
|
-
elementIds: t.elementIds.filter((e) => n?.elements.some((t) => t.id === e))
|
|
663
|
-
};
|
|
664
|
-
});
|
|
665
|
-
let t = !0;
|
|
666
|
-
for (; t;) {
|
|
667
|
-
let n = e.followBlocks ?? [], r = /* @__PURE__ */ new Set();
|
|
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;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
// src/core/page-extensions.ts
|
|
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)));
|
|
674
|
-
if (!r?.owner) return;
|
|
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);
|
|
676
|
-
if (i && a && o) return {
|
|
677
|
-
capability: a,
|
|
678
|
-
purpose: o.purpose,
|
|
679
|
-
source: i
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
function F(e, t, n) {
|
|
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);
|
|
688
|
-
r === t ? n.get(t.type)?.pageExtensions?.reconcile?.(e, t) : (t.bindings = r.bindings, t.props = r.props);
|
|
689
|
-
}
|
|
690
|
-
function Xe(n, r, i) {
|
|
691
|
-
let a = n.templates?.flatMap((e) => e.requiredElements ?? []).find((e) => e.elementId === r.id);
|
|
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" });
|
|
693
|
-
}
|
|
694
|
-
function L(n) {
|
|
695
|
-
let r = [n.page, ...n.evenPage ? [n.evenPage] : []].flatMap((e) => e.elements);
|
|
696
|
-
for (let i of n.requiredElements ?? []) {
|
|
697
|
-
let a = r.find((e) => e.id === i.elementId);
|
|
698
|
-
if (!a || !a.visible || a.type !== i.type) throw new e(t("core.pageExtensions.invalidDependency", {
|
|
699
|
-
elementId: i.elementId,
|
|
700
|
-
templateName: n.name
|
|
701
|
-
}), { code: "template.invalid-dependency" });
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
function Ze(e, t, n, r, a = e) {
|
|
705
|
-
let o = r.get(t.type)?.pageExtensions;
|
|
706
|
-
if (o) for (let s of o.references(t)) {
|
|
707
|
-
let c = a.templates?.find((e) => e.id === s.templateId);
|
|
708
|
-
if (!c) continue;
|
|
709
|
-
if (K(c).some((e) => e.elements.some((e) => e.id === t.id))) {
|
|
710
|
-
o.rebind(n, s.purpose, "", "");
|
|
711
|
-
continue;
|
|
712
|
-
}
|
|
713
|
-
if (t.id === n.id && c.owner?.elementId === n.id) continue;
|
|
714
|
-
let l = i(c);
|
|
715
|
-
l.id = U("template"), l.builtin = !1, l.owner = {
|
|
716
|
-
elementId: n.id,
|
|
717
|
-
purpose: s.purpose
|
|
718
|
-
};
|
|
719
|
-
let u = /* @__PURE__ */ new Map();
|
|
720
|
-
l.page.id = l.id, l.evenPage && (l.evenPage.id = l.id + "-even");
|
|
721
|
-
for (let e of [l.page, ...l.evenPage ? [l.evenPage] : []]) e.elements = e.elements.map((e) => {
|
|
722
|
-
let t = J(e);
|
|
723
|
-
t.id = U("el"), u.set(e.id, t.id);
|
|
724
|
-
for (let e of r.get(t.type)?.pageExtensions?.references(t) ?? []) e.templateId === c.id && r.get(t.type)?.pageExtensions?.rebind(t, e.purpose, "", "");
|
|
725
|
-
return t;
|
|
726
|
-
});
|
|
727
|
-
let d = u.get(s.elementId) ?? s.elementId;
|
|
728
|
-
l.requiredElements = (c.requiredElements ?? [{
|
|
729
|
-
elementId: s.elementId,
|
|
730
|
-
type: t.type
|
|
731
|
-
}]).map((e) => ({
|
|
732
|
-
...e,
|
|
733
|
-
elementId: u.get(e.elementId) ?? e.elementId
|
|
734
|
-
})), e.templates ??= [], e.templates.push(l), o.rebind(n, s.purpose, l.id, d);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
function R(e, t) {
|
|
738
|
-
let n;
|
|
739
|
-
do {
|
|
740
|
-
let r = e.templates ?? [];
|
|
741
|
-
e.templates = r.filter((n) => {
|
|
742
|
-
if (!n.owner) return !0;
|
|
743
|
-
let r = Y(e, n.owner.elementId)?.node;
|
|
744
|
-
return r ? t ? t.get(r.type)?.pageExtensions?.references(r).some((e) => e.templateId === n.id) ?? !1 : !0 : !1;
|
|
745
|
-
}), n = e.templates.length !== r.length;
|
|
746
|
-
} while (n);
|
|
747
|
-
}
|
|
748
|
-
function Qe(n, r, i) {
|
|
749
|
-
for (let a of i.get(r.type)?.pageExtensions?.references(r) ?? []) {
|
|
750
|
-
let i = n.templates?.find((e) => e.id === a.templateId);
|
|
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" });
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
// src/core/page-layout.ts
|
|
755
|
-
function z(e) {
|
|
756
|
-
return V(e), {
|
|
757
|
-
height: e.height,
|
|
758
|
-
margins: e.margins === void 0 ? void 0 : B(e.margins),
|
|
759
|
-
width: e.width
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
function B(n) {
|
|
763
|
-
if (n === void 0) return {
|
|
764
|
-
bottom: 0,
|
|
765
|
-
left: 0,
|
|
766
|
-
right: 0,
|
|
767
|
-
top: 0
|
|
768
|
-
};
|
|
769
|
-
if (!n || ![
|
|
770
|
-
"bottom",
|
|
771
|
-
"left",
|
|
772
|
-
"right",
|
|
773
|
-
"top"
|
|
774
|
-
].every((e) => {
|
|
775
|
-
let t = n[e];
|
|
776
|
-
return typeof t == "number" && Number.isFinite(t) && t >= 0;
|
|
777
|
-
})) throw new e(t("core.pageLayout.invalidMargins"), { code: "page.invalid-margins" });
|
|
778
|
-
return {
|
|
779
|
-
bottom: n.bottom,
|
|
780
|
-
left: n.left,
|
|
781
|
-
right: n.right,
|
|
782
|
-
top: n.top
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
function V(n) {
|
|
786
|
-
let r = B(n.margins), i = n.width - r.left - r.right, a = n.height - r.top - r.bottom;
|
|
787
|
-
if (!Number.isFinite(i) || !Number.isFinite(a) || i <= 0 || a <= 0) throw new e(t("core.pageLayout.emptyContent"), { code: "page.empty-content" });
|
|
788
|
-
return {
|
|
789
|
-
height: a,
|
|
790
|
-
width: i,
|
|
791
|
-
x: r.left,
|
|
792
|
-
y: r.top
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
// src/core/parser-version.ts
|
|
796
|
-
var H = "1.0.0";
|
|
797
|
-
function $e(e) {
|
|
798
|
-
if (e === void 0) return H;
|
|
799
|
-
if (typeof e != "string" || !e.trim()) throw Error("Invalid parser version");
|
|
800
|
-
return e;
|
|
801
|
-
}
|
|
802
|
-
// src/core/document-model.ts
|
|
803
|
-
var et = "1.0";
|
|
804
|
-
function U(e = "id") {
|
|
805
|
-
return `${e}-${u()}`;
|
|
806
|
-
}
|
|
807
|
-
function W(e = 210, n = 297, r, i = {}) {
|
|
808
|
-
let a = {
|
|
809
|
-
background: "#ffffff",
|
|
810
|
-
elements: [],
|
|
811
|
-
guides: [],
|
|
812
|
-
height: n,
|
|
813
|
-
id: U("page"),
|
|
814
|
-
name: r ?? t("core.documentModel.defaultPageName"),
|
|
815
|
-
width: e,
|
|
816
|
-
...i
|
|
817
|
-
};
|
|
818
|
-
return V(a), a.margins !== void 0 && (a.margins = B(a.margins)), a;
|
|
819
|
-
}
|
|
820
|
-
var tt = "template-blank", nt = "template-none";
|
|
821
|
-
function G() {
|
|
822
|
-
let e = {
|
|
823
|
-
builtin: !0,
|
|
824
|
-
id: tt,
|
|
825
|
-
name: t("core.documentModel.blankTemplateName"),
|
|
826
|
-
page: W(210, 297)
|
|
827
|
-
};
|
|
828
|
-
return e.page.id = e.id, e.page.name = e.name, e;
|
|
829
|
-
}
|
|
830
|
-
function rt(n, r, i = 0, a = /* @__PURE__ */ new Set()) {
|
|
831
|
-
let o = [], s = r;
|
|
832
|
-
for (; s;) {
|
|
833
|
-
if (a.has(s.id)) throw new e(t("designer.templateStore.circularInheritance"));
|
|
834
|
-
a.add(s.id), o.push(s);
|
|
835
|
-
let r = s.baseTemplateId;
|
|
836
|
-
if (s = n.templates?.find((e) => e.id === r), s?.owner) throw new e(t("core.pageExtensions.internalTemplate"), { code: "template.internal-resource" });
|
|
837
|
-
}
|
|
838
|
-
let c = at(r, i), l = o.findIndex((e, t) => t > 0 && !it(e, i)), u = l < 0 ? o : o.slice(0, l);
|
|
839
|
-
return u.length === 1 ? {
|
|
840
|
-
...r,
|
|
841
|
-
page: c
|
|
842
|
-
} : {
|
|
843
|
-
...r,
|
|
844
|
-
background: u.find((e) => e.background !== void 0)?.background,
|
|
845
|
-
page: {
|
|
846
|
-
...c,
|
|
847
|
-
elements: u.reverse().flatMap((e) => at(e, i).elements)
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
function it(e, t) {
|
|
852
|
-
return t <= 0 || (t % 2 == 0 ? e.evenPages : e.oddPages) !== !1;
|
|
853
|
-
}
|
|
854
|
-
function K(e) {
|
|
855
|
-
return e.facingPages && e.evenPage ? [e.evenPage, e.page] : [e.page];
|
|
856
|
-
}
|
|
857
|
-
function at(e, t) {
|
|
858
|
-
return t > 0 && t % 2 == 0 && e.facingPages && e.evenPage ? ot(e.evenPage, e.page) : e.page;
|
|
859
|
-
}
|
|
860
|
-
function ot(e, t) {
|
|
861
|
-
if (e.margins !== void 0 || t.margins === void 0) return e;
|
|
862
|
-
let n = z({
|
|
863
|
-
...e,
|
|
864
|
-
margins: t.margins
|
|
865
|
-
});
|
|
866
|
-
return {
|
|
867
|
-
...e,
|
|
868
|
-
...n
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
function st(e, n) {
|
|
872
|
-
let r = {
|
|
873
|
-
id: U("template"),
|
|
874
|
-
name: e ?? t("core.documentModel.defaultTemplateName"),
|
|
875
|
-
page: W(n?.width ?? 210, n?.height ?? 297, e, { margins: n?.margins })
|
|
876
|
-
};
|
|
877
|
-
return r.page.id = r.id, r.page.name = r.name, r;
|
|
878
|
-
}
|
|
879
|
-
function q(e, n = {}, r = A) {
|
|
880
|
-
let i = r.get(e);
|
|
881
|
-
if (!i) throw Error(t("core.documentModel.unregisteredElementType", { elementType: e }));
|
|
882
|
-
let a = {
|
|
883
|
-
height: i.defaultSize.height,
|
|
884
|
-
id: U("el"),
|
|
885
|
-
locked: !1,
|
|
886
|
-
name: i.label,
|
|
887
|
-
opacity: 1,
|
|
888
|
-
props: i.createProps(),
|
|
889
|
-
rotation: 0,
|
|
890
|
-
type: e,
|
|
891
|
-
visible: !0,
|
|
892
|
-
width: i.defaultSize.width,
|
|
893
|
-
x: 0,
|
|
894
|
-
y: 0,
|
|
895
|
-
...n
|
|
896
|
-
};
|
|
897
|
-
lt(a, i), a.props = i.normalizeProps?.(a.props) ?? a.props, ct(a, i);
|
|
898
|
-
let o = n.height !== void 0 && n.width === void 0 ? { height: a.height } : { width: a.width };
|
|
899
|
-
return Object.assign(a, M(a, o, r)), a;
|
|
900
|
-
}
|
|
901
|
-
function ct(e, t = A.get(e.type)) {
|
|
902
|
-
let n = t?.measureSize?.({
|
|
903
|
-
mode: "design",
|
|
904
|
-
node: e,
|
|
905
|
-
props: e.props
|
|
906
|
-
});
|
|
907
|
-
n && (typeof n.height == "number" && (e.height = n.height), typeof n.width == "number" && (e.width = n.width));
|
|
908
|
-
}
|
|
909
|
-
function lt(e, t = A.get(e.type)) {
|
|
910
|
-
if (t?.pointBased && !Array.isArray(e.points)) {
|
|
911
|
-
let n = {
|
|
912
|
-
x: e.x,
|
|
913
|
-
y: e.y + e.height / 2
|
|
914
|
-
}, r = {
|
|
915
|
-
x: e.x + e.width,
|
|
916
|
-
y: n.y
|
|
917
|
-
}, i = t.pointBased.createPoints(n, r);
|
|
918
|
-
Object.assign(e, D(e, i));
|
|
919
|
-
}
|
|
920
|
-
return e;
|
|
921
|
-
}
|
|
922
|
-
function J(e) {
|
|
923
|
-
return {
|
|
924
|
-
...e,
|
|
925
|
-
props: JSON.parse(JSON.stringify(e.props)),
|
|
926
|
-
...e.points ? { points: e.points.map((e) => ({
|
|
927
|
-
x: e.x,
|
|
928
|
-
y: e.y
|
|
929
|
-
})) } : {}
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
function Y(e, t) {
|
|
933
|
-
for (let n of X(e)) {
|
|
934
|
-
let e = n.elements.findIndex((e) => e.id === t);
|
|
935
|
-
if (e >= 0) return {
|
|
936
|
-
index: e,
|
|
937
|
-
node: n.elements[e],
|
|
938
|
-
page: n
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
return null;
|
|
942
|
-
}
|
|
943
|
-
function X(e) {
|
|
944
|
-
let t = [...e.pages];
|
|
945
|
-
for (let n of e.templates ?? []) t.push(n.page), n.evenPage && t.push(n.evenPage);
|
|
946
|
-
return t;
|
|
947
|
-
}
|
|
948
|
-
function ut(e, t) {
|
|
949
|
-
return X(e).find((e) => e.id === t);
|
|
950
|
-
}
|
|
951
|
-
function Z(e, t, n = e.pages.findIndex((e) => e.id === t.id) + 1) {
|
|
952
|
-
let r = t.templateId ?? "template-blank", i = e.templates?.find((e) => e.id === r);
|
|
953
|
-
if (r !== "template-none" && i && i.owner === void 0 && it(i, n)) return rt(e, i, n);
|
|
954
|
-
}
|
|
955
|
-
function dt(e, t, n) {
|
|
956
|
-
return z(Z(e, t, n)?.page ?? t);
|
|
957
|
-
}
|
|
958
|
-
function ft(e, t = (e) => e, n = console.warn) {
|
|
959
|
-
if (!e.templates?.length) return e;
|
|
960
|
-
let i = e.pages.map((i, a) => {
|
|
961
|
-
let o;
|
|
962
|
-
try {
|
|
963
|
-
o = Z(e, i, a + 1), o && L(o);
|
|
964
|
-
} catch (e) {
|
|
965
|
-
return n(r(e)), {
|
|
966
|
-
...i,
|
|
967
|
-
templateId: nt
|
|
968
|
-
};
|
|
969
|
-
}
|
|
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);
|
|
971
|
-
if (!o || !s) return i;
|
|
972
|
-
let c = o.page.elements.map((e) => {
|
|
973
|
-
let n = J(e);
|
|
974
|
-
return n.id = U("el"), t(n);
|
|
975
|
-
});
|
|
976
|
-
return {
|
|
977
|
-
...z(o.page),
|
|
978
|
-
background: o.background ?? i.background,
|
|
979
|
-
elements: [...c, ...i.elements],
|
|
980
|
-
guides: i.guides,
|
|
981
|
-
id: i.id,
|
|
982
|
-
name: i.name
|
|
983
|
-
};
|
|
984
|
-
});
|
|
985
|
-
return {
|
|
986
|
-
...e,
|
|
987
|
-
pages: i,
|
|
988
|
-
templates: void 0
|
|
989
|
-
};
|
|
990
|
-
}
|
|
991
|
-
function pt() {
|
|
992
|
-
let e = W(210, 297, t("core.documentModel.initialPageName"));
|
|
993
|
-
return {
|
|
994
|
-
dataSources: mt(),
|
|
995
|
-
name: t("core.documentModel.defaultDocumentName"),
|
|
996
|
-
pages: [e],
|
|
997
|
-
parserVersion: H,
|
|
998
|
-
repeatGroups: [],
|
|
999
|
-
templates: [G()],
|
|
1000
|
-
version: "1.0"
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
function mt() {
|
|
1004
|
-
return [
|
|
1005
|
-
{
|
|
1006
|
-
description: t("core.documentModel.orderSourceDescription"),
|
|
1007
|
-
key: "data",
|
|
1008
|
-
label: t("core.documentModel.sampleOrderInfoName"),
|
|
1009
|
-
sampleData: {
|
|
1010
|
-
amount: 1280.5,
|
|
1011
|
-
date: "2026-11-03",
|
|
1012
|
-
description: t("core.documentModel.sampleOrderDescription"),
|
|
1013
|
-
orderNo: "SO202611030001"
|
|
1014
|
-
},
|
|
1015
|
-
schema: [
|
|
1016
|
-
{
|
|
1017
|
-
label: t("core.documentModel.orderNumberField"),
|
|
1018
|
-
name: "orderNo",
|
|
1019
|
-
type: "string"
|
|
1020
|
-
},
|
|
1021
|
-
{
|
|
1022
|
-
label: t("core.documentModel.orderDescriptionField"),
|
|
1023
|
-
name: "description",
|
|
1024
|
-
type: "string"
|
|
1025
|
-
},
|
|
1026
|
-
{
|
|
1027
|
-
label: t("core.documentModel.orderAmountField"),
|
|
1028
|
-
name: "amount",
|
|
1029
|
-
type: "number"
|
|
1030
|
-
},
|
|
1031
|
-
{
|
|
1032
|
-
label: t("core.documentModel.orderDateField"),
|
|
1033
|
-
name: "date",
|
|
1034
|
-
type: "date"
|
|
1035
|
-
}
|
|
1036
|
-
]
|
|
1037
|
-
},
|
|
1038
|
-
{
|
|
1039
|
-
description: t("core.documentModel.customerSourceDescription"),
|
|
1040
|
-
key: "customer",
|
|
1041
|
-
label: t("core.documentModel.customerSourceName"),
|
|
1042
|
-
sampleData: {
|
|
1043
|
-
name: t("core.documentModel.sampleCustomerName"),
|
|
1044
|
-
phone: "13800000000"
|
|
1045
|
-
},
|
|
1046
|
-
schema: [{
|
|
1047
|
-
label: t("core.documentModel.customerNameField"),
|
|
1048
|
-
name: "name",
|
|
1049
|
-
type: "string"
|
|
1050
|
-
}, {
|
|
1051
|
-
label: t("core.documentModel.customerPhoneField"),
|
|
1052
|
-
name: "phone",
|
|
1053
|
-
type: "string"
|
|
1054
|
-
}]
|
|
1055
|
-
},
|
|
1056
|
-
{
|
|
1057
|
-
description: t("core.documentModel.itemsSourceDescription"),
|
|
1058
|
-
key: "items",
|
|
1059
|
-
label: t("core.documentModel.itemsSourceName"),
|
|
1060
|
-
sampleData: [
|
|
1061
|
-
{
|
|
1062
|
-
amount: 100,
|
|
1063
|
-
name: t("core.documentModel.samplePaperProduct"),
|
|
1064
|
-
quantity: 2
|
|
1065
|
-
},
|
|
1066
|
-
{
|
|
1067
|
-
amount: 200,
|
|
1068
|
-
name: t("core.documentModel.sampleRibbonProduct"),
|
|
1069
|
-
quantity: 3
|
|
1070
|
-
},
|
|
1071
|
-
{
|
|
1072
|
-
amount: 299,
|
|
1073
|
-
name: t("core.documentModel.sampleScannerProduct"),
|
|
1074
|
-
quantity: 1
|
|
1075
|
-
}
|
|
1076
|
-
],
|
|
1077
|
-
schema: [{
|
|
1078
|
-
children: [
|
|
1079
|
-
{
|
|
1080
|
-
label: t("core.documentModel.sampleProductColumn"),
|
|
1081
|
-
name: "name",
|
|
1082
|
-
type: "string"
|
|
1083
|
-
},
|
|
1084
|
-
{
|
|
1085
|
-
label: t("core.documentModel.sampleQuantityColumn"),
|
|
1086
|
-
name: "quantity",
|
|
1087
|
-
type: "number"
|
|
1088
|
-
},
|
|
1089
|
-
{
|
|
1090
|
-
label: t("core.documentModel.itemAmountField"),
|
|
1091
|
-
name: "amount",
|
|
1092
|
-
type: "number"
|
|
1093
|
-
}
|
|
1094
|
-
],
|
|
1095
|
-
label: t("core.documentModel.itemsField"),
|
|
1096
|
-
name: "item",
|
|
1097
|
-
type: "array"
|
|
1098
|
-
}]
|
|
1099
|
-
}
|
|
1100
|
-
];
|
|
1101
|
-
}
|
|
1102
|
-
function ht(n) {
|
|
1103
|
-
if (!Array.isArray(n.pages) || n.pages.length === 0) throw new e(t("core.documentModel.missingPages"), { code: "document.no-pages" });
|
|
1104
|
-
}
|
|
1105
|
-
function gt(r, i = A) {
|
|
1106
|
-
if (!r || typeof r != "object") throw new e(t("core.documentModel.invalidDocument"), { code: "document.invalid" });
|
|
1107
|
-
let a = r;
|
|
1108
|
-
ht(a);
|
|
1109
|
-
let o = [], s = vt(a.templates, o, i), c = {
|
|
1110
|
-
name: "",
|
|
1111
|
-
pages: a.pages,
|
|
1112
|
-
templates: s,
|
|
1113
|
-
version: "1.0"
|
|
1114
|
-
}, l = a.pages.map((e, t) => {
|
|
1115
|
-
let n = e?.templateId, r = n && n !== "template-none" && !s.some((e) => e.id === n) ? {
|
|
1116
|
-
...e,
|
|
1117
|
-
templateId: void 0
|
|
1118
|
-
} : e, a = Z(c, r ?? {}, t + 1);
|
|
1119
|
-
return Q(a ? {
|
|
1120
|
-
...r,
|
|
1121
|
-
...z(a.page)
|
|
1122
|
-
} : r, t, o, i);
|
|
1123
|
-
}), u = {
|
|
1124
|
-
dataSources: n(Array.isArray(a.dataSources) ? a.dataSources : []),
|
|
1125
|
-
elementGroups: Se(a.elementGroups),
|
|
1126
|
-
followBlocks: _t(a.followBlocks),
|
|
1127
|
-
name: typeof a.name == "string" && a.name ? a.name : t("core.documentModel.defaultDocumentName"),
|
|
1128
|
-
pages: l,
|
|
1129
|
-
parserVersion: $e(a.parserVersion),
|
|
1130
|
-
repeatGroups: Ct(a.repeatGroups, l),
|
|
1131
|
-
templates: s,
|
|
1132
|
-
version: "1.0"
|
|
1133
|
-
};
|
|
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,
|
|
1137
|
-
skippedTypes: o
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1140
|
-
function _t(e) {
|
|
1141
|
-
if (!Array.isArray(e)) return [];
|
|
1142
|
-
let t = [];
|
|
1143
|
-
for (let n of e) {
|
|
1144
|
-
if (!n || typeof n != "object") continue;
|
|
1145
|
-
let e = n, r = e.target;
|
|
1146
|
-
typeof e.id == "string" && typeof e.pageId == "string" && Array.isArray(e.elementIds) && r && typeof r.id == "string" && [
|
|
1147
|
-
"element",
|
|
1148
|
-
"followBlock",
|
|
1149
|
-
"repeatGroup"
|
|
1150
|
-
].includes(r.kind) && t.push({
|
|
1151
|
-
elementIds: [...new Set(e.elementIds.filter((e) => typeof e == "string"))],
|
|
1152
|
-
gap: $(e.gap, 2),
|
|
1153
|
-
id: e.id,
|
|
1154
|
-
name: typeof e.name == "string" ? e.name : "",
|
|
1155
|
-
pageId: e.pageId,
|
|
1156
|
-
target: {
|
|
1157
|
-
id: r.id,
|
|
1158
|
-
kind: r.kind
|
|
1159
|
-
}
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
return t;
|
|
1163
|
-
}
|
|
1164
|
-
function Q(e, n, r, i) {
|
|
1165
|
-
let a = {
|
|
1166
|
-
background: typeof e?.background == "string" ? e.background : "#ffffff",
|
|
1167
|
-
elements: [],
|
|
1168
|
-
guides: yt(e?.guides),
|
|
1169
|
-
height: $(e?.height, 297),
|
|
1170
|
-
id: typeof e?.id == "string" ? e.id : U("page"),
|
|
1171
|
-
margins: e?.margins === void 0 ? void 0 : B(e.margins),
|
|
1172
|
-
name: typeof e?.name == "string" ? e.name : t("core.documentModel.numberedPageName", { pageNumber: n + 1 }),
|
|
1173
|
-
templateId: typeof e?.templateId == "string" ? e.templateId : void 0,
|
|
1174
|
-
width: $(e?.width, 210)
|
|
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);
|
|
1181
|
-
e && a.elements.push(e);
|
|
1182
|
-
}
|
|
1183
|
-
return a;
|
|
1184
|
-
}
|
|
1185
|
-
function vt(e, n, r) {
|
|
1186
|
-
let i = [];
|
|
1187
|
-
if (Array.isArray(e)) for (let a of e) {
|
|
1188
|
-
if (!a || typeof a != "object") continue;
|
|
1189
|
-
let e = a, o = typeof e.id == "string" && e.id ? e.id : U("template"), s = typeof e.name == "string" && e.name ? e.name : t("core.documentModel.defaultTemplateName"), c = Q(e.page ?? null, i.length, n, r);
|
|
1190
|
-
c.id = o, c.name = s;
|
|
1191
|
-
let l;
|
|
1192
|
-
(e.evenPage || e.facingPages) && (l = Q(e.evenPage ?? null, i.length, n, r), l.id = `${o}-even`, l.name = s, e.evenPage ? l = ot(l, c) : Object.assign(l, z(c))), i.push({
|
|
1193
|
-
background: typeof e.background == "string" && e.background ? e.background : void 0,
|
|
1194
|
-
baseTemplateId: typeof e.baseTemplateId == "string" ? e.baseTemplateId : void 0,
|
|
1195
|
-
builtin: e.builtin === !0,
|
|
1196
|
-
evenPage: l,
|
|
1197
|
-
evenPages: e.evenPages !== !1,
|
|
1198
|
-
facingPages: e.facingPages === !0,
|
|
1199
|
-
id: o,
|
|
1200
|
-
name: s,
|
|
1201
|
-
oddPages: e.oddPages !== !1,
|
|
1202
|
-
owner: e.owner && typeof e.owner.elementId == "string" && typeof e.owner.purpose == "string" ? { ...e.owner } : void 0,
|
|
1203
|
-
page: c,
|
|
1204
|
-
requiredElements: Array.isArray(e.requiredElements) ? e.requiredElements.filter((e) => typeof e?.elementId == "string" && typeof e?.type == "string").map((e) => ({ ...e })) : void 0
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
return i.some((e) => e.id === "template-blank") || i.unshift(G()), i;
|
|
1208
|
-
}
|
|
1209
|
-
function yt(e) {
|
|
1210
|
-
if (!Array.isArray(e)) return [];
|
|
1211
|
-
let t = [];
|
|
1212
|
-
for (let n of e) n && typeof n == "object" && typeof n.orientation == "string" && t.push({
|
|
1213
|
-
id: typeof n.id == "string" ? n.id : U("guide"),
|
|
1214
|
-
orientation: n.orientation === "vertical" ? "vertical" : "horizontal",
|
|
1215
|
-
position: $(n.position, 0)
|
|
1216
|
-
});
|
|
1217
|
-
return t;
|
|
1218
|
-
}
|
|
1219
|
-
function bt(e, t, n) {
|
|
1220
|
-
if (!e || typeof e != "object" || !("type" in e) || typeof e.type != "string") return;
|
|
1221
|
-
let r = n.get(e.type);
|
|
1222
|
-
if (!r) {
|
|
1223
|
-
t.includes(e.type) || t.push(e.type);
|
|
1224
|
-
return;
|
|
1225
|
-
}
|
|
1226
|
-
let i = e, a = q(e.type, {}, n), o = {
|
|
1227
|
-
bindings: xt(i.bindings),
|
|
1228
|
-
height: $(i.height, r.defaultSize.height),
|
|
1229
|
-
id: typeof i.id == "string" ? i.id : a.id,
|
|
1230
|
-
locked: i.locked === !0,
|
|
1231
|
-
name: typeof i.name == "string" ? i.name : r.label,
|
|
1232
|
-
opacity: $(i.opacity, 1),
|
|
1233
|
-
props: r.normalizeProps?.({
|
|
1234
|
-
...a.props,
|
|
1235
|
-
...i.props && typeof i.props == "object" ? i.props : {}
|
|
1236
|
-
}) ?? {
|
|
1237
|
-
...a.props,
|
|
1238
|
-
...i.props && typeof i.props == "object" ? i.props : {}
|
|
1239
|
-
},
|
|
1240
|
-
rotation: $(i.rotation, 0),
|
|
1241
|
-
type: e.type,
|
|
1242
|
-
visible: i.visible !== !1,
|
|
1243
|
-
width: $(i.width, r.defaultSize.width),
|
|
1244
|
-
x: $(i.x, 0),
|
|
1245
|
-
y: $(i.y, 0)
|
|
1246
|
-
};
|
|
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;
|
|
1248
|
-
}
|
|
1249
|
-
function xt(e) {
|
|
1250
|
-
if (e && typeof e == "object") return Object.fromEntries(Object.entries(e).filter((e) => typeof e[1] == "string"));
|
|
1251
|
-
}
|
|
1252
|
-
function St(e, t) {
|
|
1253
|
-
let n = (Array.isArray(t) ? t : []).filter((e) => e && typeof e == "object").map((e) => ({
|
|
1254
|
-
x: $(e.x, 0),
|
|
1255
|
-
y: $(e.y, 0)
|
|
1256
|
-
}));
|
|
1257
|
-
n.length === 0 ? Object.assign(e, D(e, e.points ?? [])) : Object.assign(e, D(e, n));
|
|
1258
|
-
}
|
|
1259
|
-
function Ct(e, n) {
|
|
1260
|
-
if (!Array.isArray(e)) return [];
|
|
1261
|
-
let r = [];
|
|
1262
|
-
for (let i of e) {
|
|
1263
|
-
if (!i || typeof i != "object") continue;
|
|
1264
|
-
let e = i, a = n.some((t) => t.id === e.pageId), o = Array.isArray(e.elementIds) ? e.elementIds.filter((t) => typeof t == "string" && n.some((n) => n.id === e.pageId && n.elements.some((e) => e.id === t))) : [];
|
|
1265
|
-
a && o.length !== 0 && typeof e.collection == "string" && e.collection && r.push({
|
|
1266
|
-
collection: e.collection,
|
|
1267
|
-
columns: Math.max(1, Math.trunc($(e.columns, 2))),
|
|
1268
|
-
direction: e.direction === "grid" || e.direction === "page" ? e.direction : "vertical",
|
|
1269
|
-
elementIds: o,
|
|
1270
|
-
gapX: $(e.gapX, 2),
|
|
1271
|
-
gapY: $(e.gapY, 2),
|
|
1272
|
-
id: typeof e.id == "string" ? e.id : U("group"),
|
|
1273
|
-
name: typeof e.name == "string" && e.name ? e.name : t("core.documentModel.defaultRepeatGroupName"),
|
|
1274
|
-
pageId: e.pageId,
|
|
1275
|
-
positionMode: e.positionMode === "flow" ? "flow" : "fixed"
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
return r;
|
|
1279
|
-
}
|
|
1280
|
-
function $(e, t) {
|
|
1281
|
-
return typeof e == "number" && Number.isFinite(e) ? e : t;
|
|
1282
|
-
}
|
|
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 };
|