brick-pdf 0.4.1 → 0.5.0

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/brick-pdf.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent as _, openBlock as a, createElementBlock as c, normalizeStyle as N, toDisplayString as w, renderSlot as Q, normalizeClass as Z, createElementVNode as m, Fragment as C, renderList as P, reactive as ze, provide as L, inject as D, toRaw as J, ref as E, computed as I, createTextVNode as le, createCommentVNode as $, createBlock as M, resolveDynamicComponent as ee, withCtx as Y, onMounted as ye, onBeforeUnmount as me, unref as k, resolveComponent as Te, withDirectives as ie, vModelSelect as se, createVNode as B, watch as Le } from "vue";
2
- import { useMagicKeys as De, whenever as ae } from "@vueuse/core";
3
- import ce from "sortablejs";
4
- function te() {
1
+ import { defineComponent as S, openBlock as a, createElementBlock as u, normalizeStyle as L, toDisplayString as w, Fragment as P, createTextVNode as pe, renderSlot as me, computed as x, normalizeClass as Y, createElementVNode as y, renderList as T, createCommentVNode as R, reactive as ze, provide as F, inject as B, toRaw as oe, ref as E, createBlock as H, resolveDynamicComponent as ve, withCtx as se, onMounted as Te, onBeforeUnmount as Re, unref as g, resolveComponent as Le, withModifiers as fe, withDirectives as ne, vModelSelect as Se, vModelCheckbox as tt, watchEffect as nt, createVNode as j, watch as De, nextTick as ot, vShow as xe, withKeys as rt } from "vue";
2
+ import { useElementSize as lt, useMagicKeys as it, whenever as Ce } from "@vueuse/core";
3
+ import we from "sortablejs";
4
+ function be() {
5
5
  return {
6
6
  pageSize: "A4",
7
7
  pageOrientation: "portrait",
@@ -14,72 +14,82 @@ function te() {
14
14
  content: []
15
15
  };
16
16
  }
17
- const q = /* @__PURE__ */ new Map();
18
- function z(e) {
19
- q.set(e.type, e);
17
+ const ae = /* @__PURE__ */ new Map();
18
+ function V(e) {
19
+ ae.set(e.type, e);
20
20
  }
21
- function U(e) {
22
- return q.get(e);
21
+ function W(e) {
22
+ return ae.get(e);
23
23
  }
24
- function Me() {
25
- return Array.from(q.values());
24
+ function st() {
25
+ return Array.from(ae.values());
26
26
  }
27
- function rr(e) {
28
- return q.delete(e);
27
+ function Xr(e) {
28
+ return ae.delete(e);
29
29
  }
30
- function Be() {
30
+ function at() {
31
31
  return { text: "New Text" };
32
32
  }
33
- function Oe() {
33
+ function ct() {
34
34
  return { fontSize: 12 };
35
35
  }
36
- function Ae(e) {
36
+ function ut(e) {
37
37
  const t = { text: e.props.text }, n = e.style;
38
38
  return n.fontSize && (t.fontSize = n.fontSize), n.bold && (t.bold = n.bold), n.italics && (t.italics = n.italics), n.color && (t.color = n.color), n.alignment && (t.alignment = n.alignment), n.margin && (t.margin = n.margin), n.font && (t.font = n.font), n.lineHeight && (t.lineHeight = n.lineHeight), n.characterSpacing && (t.characterSpacing = n.characterSpacing), n.decoration && (t.decoration = n.decoration), n.decorationStyle && (t.decorationStyle = n.decorationStyle), n.decorationColor && (t.decorationColor = n.decorationColor), n.background && (t.background = n.background), n.link && (t.link = n.link), n.opacity !== void 0 && (t.opacity = n.opacity), t;
39
39
  }
40
- const Ve = /* @__PURE__ */ _({
40
+ const dt = /* @__PURE__ */ S({
41
41
  __name: "TextRenderer",
42
42
  props: {
43
43
  node: {}
44
44
  },
45
45
  setup(e) {
46
- return (t, n) => (a(), c("div", {
46
+ return (t, n) => (a(), u("div", {
47
47
  class: "brick-el-text",
48
- style: N({
49
- fontSize: (e.node.style.fontSize ?? 12) + "px",
48
+ style: L({
49
+ fontSize: e.node.style.fontSize ? "calc(" + e.node.style.fontSize + " * var(--brick-pt, 1px))" : void 0,
50
50
  fontWeight: e.node.style.bold ? "bold" : "normal",
51
51
  fontStyle: e.node.style.italics ? "italic" : "normal",
52
52
  color: e.node.style.color,
53
53
  textAlign: e.node.style.alignment,
54
54
  lineHeight: e.node.style.lineHeight,
55
- textDecoration: e.node.style.decoration === "lineThrough" ? "line-through" : e.node.style.decoration,
56
- backgroundColor: e.node.style.background,
55
+ textDecorationLine: e.node.style.decoration === "lineThrough" ? "line-through" : e.node.style.decoration,
56
+ textDecorationStyle: e.node.style.decorationStyle,
57
+ textDecorationColor: e.node.style.decorationColor,
58
+ letterSpacing: e.node.style.characterSpacing ? "calc(" + e.node.style.characterSpacing + " * var(--brick-pt, 1px))" : void 0,
57
59
  opacity: e.node.style.opacity
58
60
  })
59
- }, w(e.node.props.text), 5));
61
+ }, [
62
+ e.node.style.background ? (a(), u("span", {
63
+ key: 0,
64
+ class: "brick-el-text__bg",
65
+ style: L({ backgroundColor: e.node.style.background })
66
+ }, w(e.node.props.text), 5)) : (a(), u(P, { key: 1 }, [
67
+ pe(w(e.node.props.text), 1)
68
+ ], 64))
69
+ ], 4));
60
70
  }
61
- }), x = (e, t) => {
71
+ }), $ = (e, t) => {
62
72
  const n = e.__vccOpts || e;
63
- for (const [i, s] of t)
64
- n[i] = s;
73
+ for (const [i, f] of t)
74
+ n[i] = f;
65
75
  return n;
66
- }, Fe = /* @__PURE__ */ x(Ve, [["__scopeId", "data-v-a7cd1565"]]), He = { class: "brick-text-editor" }, Je = /* @__PURE__ */ _({
76
+ }, pt = /* @__PURE__ */ $(dt, [["__scopeId", "data-v-3cef04a8"]]), ft = { class: "brick-text-editor" }, yt = /* @__PURE__ */ S({
67
77
  __name: "TextPropertyEditor",
68
78
  props: {
69
79
  node: {}
70
80
  },
71
81
  setup(e) {
72
- return (t, n) => (a(), c("div", He));
82
+ return (t, n) => (a(), u("div", ft));
73
83
  }
74
- }), Ue = {
84
+ }), mt = {
75
85
  type: "text",
76
86
  label: "Text",
77
87
  icon: "T",
78
88
  isContainer: !1,
79
- defaultProps: Be,
80
- defaultStyle: Oe,
81
- rendererComponent: Fe,
82
- propertyEditorComponent: Je,
89
+ defaultProps: at,
90
+ defaultStyle: ct,
91
+ rendererComponent: pt,
92
+ propertyEditorComponent: yt,
83
93
  propertyFields: [
84
94
  { key: "props.text", label: "Text Content", section: "content", type: "textarea", defaultValue: "New Text" },
85
95
  { key: "style.fontSize", label: "Font Size", section: "style", type: "number", min: 6, max: 72, step: 1, defaultValue: 12 },
@@ -104,110 +114,110 @@ const Ve = /* @__PURE__ */ _({
104
114
  { key: "style.link", label: "Link URL", section: "advanced", type: "text" },
105
115
  { key: "style.opacity", label: "Opacity", section: "advanced", type: "slider", min: 0, max: 1, step: 0.1, defaultValue: 1 }
106
116
  ],
107
- toPdfmake: Ae
117
+ toPdfmake: ut
108
118
  };
109
- function We() {
119
+ function vt() {
110
120
  return {};
111
121
  }
112
- function je() {
122
+ function bt() {
113
123
  return {};
114
124
  }
115
- function Ye(e, t) {
125
+ function gt(e, t) {
116
126
  const n = {
117
127
  stack: t(e.children)
118
128
  };
119
129
  return e.style.margin && (n.margin = e.style.margin), e.style.fillColor && (n.fillColor = e.style.fillColor), n;
120
130
  }
121
- const qe = /* @__PURE__ */ _({
131
+ const ht = /* @__PURE__ */ S({
122
132
  __name: "StackRenderer",
123
133
  props: {
124
134
  node: {},
125
135
  path: {}
126
136
  },
127
137
  setup(e) {
128
- return (t, n) => (a(), c("div", {
138
+ return (t, n) => (a(), u("div", {
129
139
  class: "brick-el-stack",
130
- style: N({ backgroundColor: e.node.style.fillColor })
140
+ style: L({ backgroundColor: e.node.style.fillColor })
131
141
  }, [
132
- Q(t.$slots, "default", {}, void 0, !0)
142
+ me(t.$slots, "default", {}, void 0, !0)
133
143
  ], 4));
134
144
  }
135
- }), Ke = /* @__PURE__ */ x(qe, [["__scopeId", "data-v-c59e7405"]]), Ge = { class: "brick-stack-editor" }, Xe = /* @__PURE__ */ _({
145
+ }), _t = /* @__PURE__ */ $(ht, [["__scopeId", "data-v-ee878376"]]), kt = { class: "brick-stack-editor" }, St = /* @__PURE__ */ S({
136
146
  __name: "StackPropertyEditor",
137
147
  props: {
138
148
  node: {}
139
149
  },
140
150
  setup(e) {
141
- return (t, n) => (a(), c("div", Ge));
151
+ return (t, n) => (a(), u("div", kt));
142
152
  }
143
- }), Qe = {
153
+ }), xt = {
144
154
  type: "stack",
145
155
  label: "Stack",
146
156
  icon: "☰",
147
157
  isContainer: !0,
148
158
  acceptsChildTypes: null,
149
- defaultProps: We,
150
- defaultStyle: je,
151
- rendererComponent: Ke,
152
- propertyEditorComponent: Xe,
159
+ defaultProps: vt,
160
+ defaultStyle: bt,
161
+ rendererComponent: _t,
162
+ propertyEditorComponent: St,
153
163
  propertyFields: [
154
164
  { key: "style.fillColor", label: "Fill Color", section: "style", type: "color" },
155
165
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
156
166
  ],
157
- toPdfmake: Ye
167
+ toPdfmake: gt
158
168
  };
159
- function Ze() {
169
+ function Ct() {
160
170
  return { columnGap: 10 };
161
171
  }
162
- function et() {
172
+ function wt() {
163
173
  return {};
164
174
  }
165
- function tt(e, t) {
175
+ function Pt(e, t) {
166
176
  const n = {
167
177
  columns: t(e.children),
168
178
  columnGap: e.props.columnGap ?? 10
169
179
  };
170
180
  return e.style.margin && (n.margin = e.style.margin), n;
171
181
  }
172
- const nt = /* @__PURE__ */ _({
182
+ const Et = /* @__PURE__ */ S({
173
183
  __name: "ColumnsRenderer",
174
184
  props: {
175
185
  node: {},
176
186
  path: {}
177
187
  },
178
188
  setup(e) {
179
- return (t, n) => (a(), c("div", {
189
+ return (t, n) => (a(), u("div", {
180
190
  class: "brick-el-columns",
181
- style: N({ "--column-gap": (e.node.props.columnGap ?? 10) + "px" })
191
+ style: L({ "--column-gap": "calc(" + (e.node.props.columnGap ?? 10) + " * var(--brick-pt, 1px))" })
182
192
  }, [
183
- Q(t.$slots, "default", {}, void 0, !0)
193
+ me(t.$slots, "default", {}, void 0, !0)
184
194
  ], 4));
185
195
  }
186
- }), ot = /* @__PURE__ */ x(nt, [["__scopeId", "data-v-217dd721"]]), rt = { class: "brick-columns-editor" }, lt = /* @__PURE__ */ _({
196
+ }), $t = /* @__PURE__ */ $(Et, [["__scopeId", "data-v-1f87347b"]]), It = { class: "brick-columns-editor" }, Nt = /* @__PURE__ */ S({
187
197
  __name: "ColumnsPropertyEditor",
188
198
  props: {
189
199
  node: {}
190
200
  },
191
201
  setup(e) {
192
- return (t, n) => (a(), c("div", rt));
202
+ return (t, n) => (a(), u("div", It));
193
203
  }
194
- }), it = {
204
+ }), zt = {
195
205
  type: "columns",
196
206
  label: "Columns",
197
207
  icon: "▥",
198
208
  isContainer: !0,
199
209
  acceptsChildTypes: null,
200
- defaultProps: Ze,
201
- defaultStyle: et,
202
- rendererComponent: ot,
203
- propertyEditorComponent: lt,
210
+ defaultProps: Ct,
211
+ defaultStyle: wt,
212
+ rendererComponent: $t,
213
+ propertyEditorComponent: Nt,
204
214
  propertyFields: [
205
215
  { key: "props.columnGap", label: "Column Gap", section: "layout", type: "number", min: 0, max: 50, step: 1, defaultValue: 10 },
206
216
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
207
217
  ],
208
- toPdfmake: tt
218
+ toPdfmake: Pt
209
219
  };
210
- function st() {
220
+ function Tt() {
211
221
  return {
212
222
  headerRows: 1,
213
223
  widths: ["*", "*"],
@@ -218,52 +228,77 @@ function st() {
218
228
  layout: "lightHorizontalLines"
219
229
  };
220
230
  }
221
- function at() {
231
+ function Rt() {
222
232
  return { fontSize: 12 };
223
233
  }
224
- function ct(e) {
234
+ function Lt(e) {
225
235
  const t = e.props.body, n = {
226
236
  table: {
227
237
  headerRows: e.props.headerRows,
228
238
  widths: e.props.widths,
229
239
  body: t.map(
230
- (s) => s.map((o) => ({ text: o }))
240
+ (f) => f.map((d) => ({ text: d }))
231
241
  )
232
242
  }
233
243
  }, i = e.props.layout;
234
244
  return i && i !== "none" && (n.layout = i), e.style.fontSize && (n.fontSize = e.style.fontSize), e.style.color && (n.color = e.style.color), e.style.margin && (n.margin = e.style.margin), n;
235
245
  }
236
- const dt = /* @__PURE__ */ _({
246
+ const Dt = { key: 0 }, Bt = /* @__PURE__ */ S({
237
247
  __name: "TableRenderer",
238
248
  props: {
239
249
  node: {}
240
250
  },
241
251
  setup(e) {
242
- return (t, n) => (a(), c("div", {
243
- class: Z(["brick-el-table", "brick-el-table--" + (e.node.props.layout ?? "lightHorizontalLines")]),
244
- style: N({ fontSize: (e.node.style.fontSize ?? 12) + "px", color: e.node.style.color })
252
+ const t = e, n = ["noBorders", "headerLineOnly", "lightHorizontalLines"], i = x(() => t.node.props.body ?? []), f = x(() => t.node.props.headerRows || 0), d = x(() => t.node.props.widths), m = x(() => {
253
+ const c = t.node.props.layout;
254
+ return c && n.includes(c) ? c : "default";
255
+ }), p = x(() => d.value?.length ?? i.value[0]?.length ?? 0), s = (c) => `calc(${c} * var(--brick-pt, 1px))`, l = x(() => {
256
+ const c = d.value, v = !!c?.some((k) => k === "auto"), b = !c || c.some((k) => k === "*");
257
+ return { tableLayout: v ? "auto" : "fixed", width: b ? "100%" : void 0 };
258
+ });
259
+ function o(c) {
260
+ return typeof c == "number" ? s(c) : void 0;
261
+ }
262
+ function r(c, v) {
263
+ const b = v === p.value - 1;
264
+ let k = 4, C = 4;
265
+ m.value === "noBorders" ? (k = v === 0 ? 0 : 4, C = b ? 0 : 4) : m.value !== "default" && (k = v === 0 ? 0 : 8, C = b ? 0 : 8);
266
+ const _ = {
267
+ padding: `${s(2)} ${s(C)} ${s(2)} ${s(k)}`
268
+ };
269
+ if (c > 0 && (m.value === "lightHorizontalLines" || m.value === "headerLineOnly")) {
270
+ const I = c === f.value ? 2 : m.value === "lightHorizontalLines" ? 1 : 0, O = m.value === "lightHorizontalLines" && c !== 1 ? "#aaa" : "black";
271
+ I && (_.borderTop = `${s(I)} solid ${O}`);
272
+ }
273
+ return _;
274
+ }
275
+ return (c, v) => (a(), u("div", {
276
+ class: Y(["brick-el-table", "brick-el-table--" + m.value]),
277
+ style: L({ fontSize: e.node.style.fontSize ? s(e.node.style.fontSize) : void 0, color: e.node.style.color })
245
278
  }, [
246
- m("table", null, [
247
- m("thead", null, [
248
- (a(!0), c(C, null, P(e.node.props.body.slice(0, e.node.props.headerRows), (i, s) => (a(), c("tr", {
249
- key: "h" + s
250
- }, [
251
- (a(!0), c(C, null, P(i, (o, y) => (a(), c("th", { key: y }, w(o), 1))), 128))
252
- ]))), 128))
253
- ]),
254
- m("tbody", null, [
255
- (a(!0), c(C, null, P(e.node.props.body.slice(e.node.props.headerRows), (i, s) => (a(), c("tr", {
256
- key: "b" + s
257
- }, [
258
- (a(!0), c(C, null, P(i, (o, y) => (a(), c("td", { key: y }, w(o), 1))), 128))
279
+ y("table", {
280
+ style: L(l.value)
281
+ }, [
282
+ d.value ? (a(), u("colgroup", Dt, [
283
+ (a(!0), u(P, null, T(d.value, (b, k) => (a(), u("col", {
284
+ key: k,
285
+ style: L({ width: o(b) })
286
+ }, null, 4))), 128))
287
+ ])) : R("", !0),
288
+ y("tbody", null, [
289
+ (a(!0), u(P, null, T(i.value, (b, k) => (a(), u("tr", { key: k }, [
290
+ (a(!0), u(P, null, T(b, (C, _) => (a(), u("td", {
291
+ key: _,
292
+ style: L(r(k, _))
293
+ }, w(C), 5))), 128))
259
294
  ]))), 128))
260
295
  ])
261
- ])
296
+ ], 4)
262
297
  ], 6));
263
298
  }
264
- }), ut = /* @__PURE__ */ x(dt, [["__scopeId", "data-v-b863b05d"]]), ge = /* @__PURE__ */ Symbol("brick-pdf-document-store");
265
- function de(e) {
266
- const t = te();
299
+ }), Mt = /* @__PURE__ */ $(Bt, [["__scopeId", "data-v-45332671"]]), Be = /* @__PURE__ */ Symbol("brick-pdf-document-store");
300
+ function Pe(e) {
301
+ const t = be();
267
302
  return {
268
303
  pageSize: e.pageSize ?? t.pageSize,
269
304
  pageOrientation: e.pageOrientation ?? t.pageOrientation,
@@ -273,184 +308,184 @@ function de(e) {
273
308
  content: e.content ?? t.content
274
309
  };
275
310
  }
276
- function X(e) {
311
+ function ye(e) {
277
312
  e.props = e.props ?? {}, e.style = e.style ?? {}, e.children = e.children ?? [];
278
- for (const t of e.children) X(t);
313
+ for (const t of e.children) ye(t);
279
314
  return e;
280
315
  }
281
- function pt(e) {
282
- const t = e ? de(e) : te();
283
- for (const d of t.content) X(d);
316
+ function Ot(e) {
317
+ const t = e ? Pe(e) : be();
318
+ for (const s of t.content) ye(s);
284
319
  const n = ze(t);
285
- function i(d, r) {
286
- const l = r ?? n.content;
287
- for (let u = 0; u < l.length; u++) {
288
- const g = l[u];
289
- if (g) {
290
- if (g.id === d)
291
- return { node: g, parent: l, index: u };
292
- if (g.children.length > 0) {
293
- const f = i(d, g.children);
294
- if (f) return f;
320
+ function i(s, l) {
321
+ const o = l ?? n.content;
322
+ for (let r = 0; r < o.length; r++) {
323
+ const c = o[r];
324
+ if (c) {
325
+ if (c.id === s)
326
+ return { node: c, parent: o, index: r };
327
+ if (c.children.length > 0) {
328
+ const v = i(s, c.children);
329
+ if (v) return v;
295
330
  }
296
331
  }
297
332
  }
298
333
  return null;
299
334
  }
300
- function s(d) {
301
- n.content.splice(0, n.content.length, ...d);
335
+ function f(s) {
336
+ n.content.splice(0, n.content.length, ...s);
302
337
  }
303
- function o() {
304
- return JSON.parse(JSON.stringify(J(n.content)));
338
+ function d() {
339
+ return JSON.parse(JSON.stringify(oe(n.content)));
305
340
  }
306
- function y(d) {
307
- const r = de(d);
308
- for (const l of r.content) X(l);
309
- n.pageSize = r.pageSize, n.pageOrientation = r.pageOrientation, n.pageMargins = r.pageMargins, n.defaultStyle = r.defaultStyle, n.styles = r.styles, n.content.splice(0, n.content.length, ...r.content);
341
+ function m(s) {
342
+ const l = Pe(s);
343
+ for (const o of l.content) ye(o);
344
+ n.pageSize = l.pageSize, n.pageOrientation = l.pageOrientation, n.pageMargins = l.pageMargins, n.defaultStyle = l.defaultStyle, n.styles = l.styles, n.content.splice(0, n.content.length, ...l.content);
310
345
  }
311
346
  function p() {
312
- return JSON.parse(JSON.stringify(J(n)));
347
+ return JSON.parse(JSON.stringify(oe(n)));
313
348
  }
314
- return { document: n, findNodeById: i, replaceContent: s, snapshotContent: o, loadDocument: y, exportDocument: p };
349
+ return { document: n, findNodeById: i, replaceContent: f, snapshotContent: d, loadDocument: m, exportDocument: p };
315
350
  }
316
- function ft(e) {
317
- L(ge, e);
351
+ function At(e) {
352
+ F(Be, e);
318
353
  }
319
- function ne() {
320
- const e = D(ge);
354
+ function G() {
355
+ const e = B(Be);
321
356
  if (!e)
322
357
  throw new Error("useDocumentStore() requires a BrickPdf ancestor component");
323
358
  return e;
324
359
  }
325
- const be = /* @__PURE__ */ Symbol("brick-pdf-selection");
326
- function yt(e) {
327
- const t = E(null), n = I(() => t.value ? e.findNodeById(t.value)?.node ?? null : null);
328
- function i(o) {
329
- t.value = o;
360
+ const Me = /* @__PURE__ */ Symbol("brick-pdf-selection");
361
+ function Vt(e) {
362
+ const t = E(null), n = x(() => t.value ? e.findNodeById(t.value)?.node ?? null : null);
363
+ function i(d) {
364
+ t.value = d;
330
365
  }
331
- function s() {
366
+ function f() {
332
367
  t.value = null;
333
368
  }
334
- return { selectedId: t, selectedNode: n, select: i, deselect: s };
369
+ return { selectedId: t, selectedNode: n, select: i, deselect: f };
335
370
  }
336
- function mt(e) {
337
- L(be, e);
371
+ function Ht(e) {
372
+ F(Me, e);
338
373
  }
339
- function W() {
340
- const e = D(be);
374
+ function Q() {
375
+ const e = B(Me);
341
376
  if (!e)
342
377
  throw new Error("useSelection() requires a BrickPdf ancestor component");
343
378
  return e;
344
379
  }
345
- const he = /* @__PURE__ */ Symbol("brick-pdf-element-actions");
346
- let gt = 0;
347
- function ve() {
348
- return `el-${Date.now()}-${++gt}`;
380
+ const Oe = /* @__PURE__ */ Symbol("brick-pdf-element-actions");
381
+ let Ft = 0;
382
+ function Ae() {
383
+ return `el-${Date.now()}-${++Ft}`;
349
384
  }
350
- function _e(e) {
385
+ function Ve(e) {
351
386
  return {
352
387
  ...e,
353
- id: ve(),
388
+ id: Ae(),
354
389
  props: structuredClone(e.props),
355
390
  style: structuredClone(e.style),
356
- children: e.children.map(_e)
391
+ children: e.children.map(Ve)
357
392
  };
358
393
  }
359
- function bt(e, t) {
360
- function n(r, l, u) {
361
- const g = U(r);
362
- if (!g) return null;
394
+ function Ut(e, t) {
395
+ function n(l, o, r) {
396
+ const c = W(l);
397
+ if (!c) return null;
363
398
  t.record();
364
- const f = {
365
- id: ve(),
366
- type: r,
367
- props: g.defaultProps(),
368
- style: g.defaultStyle(),
399
+ const v = {
400
+ id: Ae(),
401
+ type: l,
402
+ props: c.defaultProps(),
403
+ style: c.defaultStyle(),
369
404
  children: []
370
- }, b = l ? e.findNodeById(l)?.node.children : e.document.content;
405
+ }, b = o ? e.findNodeById(o)?.node.children : e.document.content;
371
406
  if (!b) return null;
372
- const h = u ?? b.length;
373
- return b.splice(h, 0, f), f;
407
+ const k = r ?? b.length;
408
+ return b.splice(k, 0, v), v;
374
409
  }
375
- function i(r) {
376
- const l = e.findNodeById(r);
377
- l && (t.record(), l.parent.splice(l.index, 1));
410
+ function i(l) {
411
+ const o = e.findNodeById(l);
412
+ o && (t.record(), o.parent.splice(o.index, 1));
378
413
  }
379
- function s(r, l, u) {
380
- const g = e.findNodeById(r);
381
- if (!g) return;
414
+ function f(l, o, r) {
415
+ const c = e.findNodeById(l);
416
+ if (!c) return;
382
417
  t.record();
383
- const f = g.parent.splice(g.index, 1)[0];
384
- if (!f) return;
385
- const b = l ? e.findNodeById(l)?.node.children : e.document.content;
386
- b && b.splice(u, 0, f);
418
+ const v = c.parent.splice(c.index, 1)[0];
419
+ if (!v) return;
420
+ const b = o ? e.findNodeById(o)?.node.children : e.document.content;
421
+ b && b.splice(r, 0, v);
387
422
  }
388
- function o(r) {
389
- const l = e.findNodeById(r);
390
- if (!l) return null;
423
+ function d(l) {
424
+ const o = e.findNodeById(l);
425
+ if (!o) return null;
391
426
  t.record();
392
- const u = _e(l.node);
393
- return l.parent.splice(l.index + 1, 0, u), u;
427
+ const r = Ve(o.node);
428
+ return o.parent.splice(o.index + 1, 0, r), r;
394
429
  }
395
- function y(r, l) {
396
- const u = e.findNodeById(r);
397
- u && (t.record(), Object.assign(u.node.props, l));
430
+ function m(l, o) {
431
+ const r = e.findNodeById(l);
432
+ r && (t.record(), Object.assign(r.node.props, o));
398
433
  }
399
- function p(r, l) {
400
- const u = e.findNodeById(r);
401
- u && (t.record(), Object.assign(u.node.style, l));
434
+ function p(l, o) {
435
+ const r = e.findNodeById(l);
436
+ r && (t.record(), Object.assign(r.node.style, o));
402
437
  }
403
- function d(r, l) {
404
- const u = e.findNodeById(r);
405
- u && (t.record(), l ? u.node.key = l : delete u.node.key);
438
+ function s(l, o) {
439
+ const r = e.findNodeById(l);
440
+ r && (t.record(), o ? r.node.key = o : delete r.node.key);
406
441
  }
407
- return { addElement: n, removeElement: i, moveElement: s, duplicateElement: o, updateProps: y, updateStyle: p, updateKey: d };
442
+ return { addElement: n, removeElement: i, moveElement: f, duplicateElement: d, updateProps: m, updateStyle: p, updateKey: s };
408
443
  }
409
- function ht(e) {
410
- L(he, e);
444
+ function Jt(e) {
445
+ F(Oe, e);
411
446
  }
412
- function j() {
413
- const e = D(he);
447
+ function re() {
448
+ const e = B(Oe);
414
449
  if (!e)
415
450
  throw new Error("useElementActions() requires a BrickPdf ancestor component");
416
451
  return e;
417
452
  }
418
- const ke = /* @__PURE__ */ Symbol("brick-pdf-history"), vt = 50;
419
- function _t(e) {
453
+ const He = /* @__PURE__ */ Symbol("brick-pdf-history"), Wt = 50;
454
+ function jt(e) {
420
455
  const t = E([]), n = E([]);
421
456
  let i = 0;
422
- const s = I(() => t.value.length > 0), o = I(() => n.value.length > 0);
423
- function y() {
424
- const r = Date.now();
425
- if (r - i < 100) return;
426
- i = r;
427
- const l = e.snapshotContent();
428
- t.value.push(l), t.value.length > vt && t.value.shift(), n.value = [];
457
+ const f = x(() => t.value.length > 0), d = x(() => n.value.length > 0);
458
+ function m() {
459
+ const l = Date.now();
460
+ if (l - i < 100) return;
461
+ i = l;
462
+ const o = e.snapshotContent();
463
+ t.value.push(o), t.value.length > Wt && t.value.shift(), n.value = [];
429
464
  }
430
465
  function p() {
431
- const r = t.value.pop();
432
- r && (n.value.push(e.snapshotContent()), e.replaceContent(r));
466
+ const l = t.value.pop();
467
+ l && (n.value.push(e.snapshotContent()), e.replaceContent(l));
433
468
  }
434
- function d() {
435
- const r = n.value.pop();
436
- r && (t.value.push(e.snapshotContent()), e.replaceContent(r));
469
+ function s() {
470
+ const l = n.value.pop();
471
+ l && (t.value.push(e.snapshotContent()), e.replaceContent(l));
437
472
  }
438
- return { canUndo: s, canRedo: o, record: y, undo: p, redo: d };
473
+ return { canUndo: f, canRedo: d, record: m, undo: p, redo: s };
439
474
  }
440
- function kt(e) {
441
- L(ke, e);
475
+ function Yt(e) {
476
+ F(He, e);
442
477
  }
443
- function St() {
444
- const e = D(ke);
478
+ function qt() {
479
+ const e = B(He);
445
480
  if (!e)
446
481
  throw new Error("useHistory() requires a BrickPdf ancestor component");
447
482
  return e;
448
483
  }
449
- const Se = /* @__PURE__ */ Symbol("brick-pdf-drag-drop");
450
- function xt(e, t) {
484
+ const Fe = /* @__PURE__ */ Symbol("brick-pdf-drag-drop");
485
+ function Kt(e, t) {
451
486
  const n = E(!1);
452
- function i(o) {
453
- return ce.create(o, {
487
+ function i(d) {
488
+ return we.create(d, {
454
489
  group: { name: "brick-elements", pull: "clone", put: !1 },
455
490
  sort: !1,
456
491
  animation: 150,
@@ -462,8 +497,8 @@ function xt(e, t) {
462
497
  }
463
498
  });
464
499
  }
465
- function s(o, y) {
466
- return ce.create(o, {
500
+ function f(d, m) {
501
+ return we.create(d, {
467
502
  group: { name: "brick-elements", put: !0 },
468
503
  animation: 150,
469
504
  fallbackOnBody: !0,
@@ -474,302 +509,300 @@ function xt(e, t) {
474
509
  n.value = !0;
475
510
  },
476
511
  onAdd(p) {
477
- const d = p.item, r = d.dataset.elementId, l = d.dataset.elementType, u = (g) => {
478
- if (!y || !g) return !1;
479
- const f = e.findNodeById(y);
480
- if (!f) return !1;
481
- const b = U(f.node.type);
482
- return !!(b?.acceptsChildTypes && !b.acceptsChildTypes.includes(g));
512
+ const s = p.item, l = s.dataset.elementId, o = s.dataset.elementType, r = (c) => {
513
+ if (!m || !c) return !1;
514
+ const v = e.findNodeById(m);
515
+ if (!v) return !1;
516
+ const b = W(v.node.type);
517
+ return !!(b?.acceptsChildTypes && !b.acceptsChildTypes.includes(c));
483
518
  };
484
- if (r) {
485
- if (d.parentNode?.removeChild(d), u(l)) return;
486
- t.moveElement(r, y, p.newIndex ?? 0);
519
+ if (l) {
520
+ if (r(o)) {
521
+ p.from.insertBefore(s, p.from.children[p.oldIndex ?? 0] ?? null);
522
+ return;
523
+ }
524
+ s.parentNode?.removeChild(s), t.moveElement(l, m, p.newIndex ?? 0);
487
525
  return;
488
526
  }
489
- l && (d.parentNode?.removeChild(d), !u(l) && t.addElement(l, y, p.newIndex));
527
+ o && (s.parentNode?.removeChild(s), !r(o) && t.addElement(o, m, p.newIndex));
490
528
  },
491
529
  onEnd(p) {
492
- if (n.value = !1, p.from === p.to && p.oldIndex !== void 0 && p.newIndex !== void 0 && p.oldIndex !== p.newIndex && p.item.dataset.elementId) {
493
- const d = y ? e.findNodeById(y)?.node.children : e.document.content;
494
- if (!d) return;
495
- const r = d.splice(p.oldIndex, 1)[0];
496
- r && d.splice(p.newIndex, 0, r);
497
- }
530
+ n.value = !1, p.from === p.to && p.oldIndex !== void 0 && p.newIndex !== void 0 && p.oldIndex !== p.newIndex && p.item.dataset.elementId && t.moveElement(p.item.dataset.elementId, m, p.newIndex);
498
531
  }
499
532
  });
500
533
  }
501
- return { initToolbar: i, initContainer: s, isDragging: n };
534
+ return { initToolbar: i, initContainer: f, isDragging: n };
502
535
  }
503
- function Ct(e) {
504
- L(Se, e);
536
+ function Xt(e) {
537
+ F(Fe, e);
505
538
  }
506
- function xe() {
507
- const e = D(Se);
539
+ function ge() {
540
+ const e = B(Fe);
508
541
  if (!e)
509
542
  throw new Error("useDragDrop() requires a BrickPdf ancestor component");
510
543
  return e;
511
544
  }
512
- const ue = {
545
+ const Ee = {
513
546
  regular: "https://cdn.jsdelivr.net/npm/@expo-google-fonts/noto-sans-jp/NotoSansJP_400Regular.ttf",
514
547
  bold: "https://cdn.jsdelivr.net/npm/@expo-google-fonts/noto-sans-jp/NotoSansJP_700Bold.ttf"
515
- }, A = {
548
+ }, X = {
516
549
  regular: "NotoSansJP-Regular.ttf",
517
550
  bold: "NotoSansJP-Bold.ttf"
518
- }, wt = "NotoSansJP";
519
- function Pt(e) {
551
+ }, Gt = "NotoSansJP";
552
+ function Qt(e) {
520
553
  const t = new Uint8Array(e), n = 32768;
521
554
  let i = "";
522
- for (let s = 0; s < t.length; s += n) {
523
- const o = t.subarray(s, s + n);
524
- i += String.fromCharCode.apply(null, Array.from(o));
555
+ for (let f = 0; f < t.length; f += n) {
556
+ const d = t.subarray(f, f + n);
557
+ i += String.fromCharCode.apply(null, Array.from(d));
525
558
  }
526
559
  return btoa(i);
527
560
  }
528
- async function pe(e) {
561
+ async function $e(e) {
529
562
  const t = await fetch(e);
530
563
  if (!t.ok)
531
564
  throw new Error(`Failed to load font ${e}: HTTP ${t.status}`);
532
565
  const n = await t.arrayBuffer();
533
- return Pt(n);
566
+ return Qt(n);
534
567
  }
535
- let H = null;
536
- function Et() {
537
- return H || (H = (async () => {
568
+ let te = null;
569
+ function Zt() {
570
+ return te || (te = (async () => {
538
571
  const [e, t] = await Promise.all([
539
- pe(ue.regular),
540
- pe(ue.bold)
572
+ $e(Ee.regular),
573
+ $e(Ee.bold)
541
574
  ]);
542
575
  return {
543
576
  vfs: {
544
- [A.regular]: e,
545
- [A.bold]: t
577
+ [X.regular]: e,
578
+ [X.bold]: t
546
579
  },
547
580
  fonts: {
548
- [wt]: {
549
- normal: A.regular,
550
- bold: A.bold,
551
- italics: A.regular,
552
- bolditalics: A.bold
581
+ [Gt]: {
582
+ normal: X.regular,
583
+ bold: X.bold,
584
+ italics: X.regular,
585
+ bolditalics: X.bold
553
586
  }
554
587
  }
555
588
  };
556
589
  })().catch((e) => {
557
- throw H = null, e;
558
- }), H);
590
+ throw te = null, e;
591
+ }), te);
559
592
  }
560
- const Ce = /* @__PURE__ */ Symbol("brick-pdf-export");
561
- function It(e) {
562
- return e.map(we);
593
+ const Ue = /* @__PURE__ */ Symbol("brick-pdf-export");
594
+ function en(e) {
595
+ return e.map(Je);
563
596
  }
564
- function we(e) {
565
- const t = U(e.type);
566
- return t ? t.toPdfmake(e, It) : { text: `[Unknown: ${e.type}]` };
597
+ function Je(e) {
598
+ const t = W(e.type);
599
+ return t ? t.toPdfmake(e, en) : { text: `[Unknown: ${e.type}]` };
567
600
  }
568
- function $t(e) {
601
+ function tn(e) {
569
602
  function t() {
570
- const o = e.document;
603
+ const d = e.document;
571
604
  return {
572
- pageSize: o.pageSize,
573
- pageOrientation: o.pageOrientation,
574
- pageMargins: o.pageMargins,
575
- defaultStyle: JSON.parse(JSON.stringify(J(o.defaultStyle))),
576
- styles: JSON.parse(JSON.stringify(J(o.styles))),
577
- content: o.content.map(we)
605
+ pageSize: d.pageSize,
606
+ pageOrientation: d.pageOrientation,
607
+ pageMargins: d.pageMargins,
608
+ defaultStyle: JSON.parse(JSON.stringify(oe(d.defaultStyle))),
609
+ styles: JSON.parse(JSON.stringify(oe(d.styles))),
610
+ content: d.content.map(Je)
578
611
  };
579
612
  }
580
613
  async function n() {
581
- const o = await import("pdfmake/build/pdfmake"), y = await import("pdfmake/build/vfs_fonts"), p = o.default || o, d = y.pdfMake?.vfs ?? y.default ?? {}, r = await Et();
582
- return p.addVirtualFileSystem({ ...d, ...r.vfs }), p.setFonts({
614
+ const d = await import("pdfmake/build/pdfmake"), m = await import("pdfmake/build/vfs_fonts"), p = d.default || d, s = m.pdfMake?.vfs ?? m.default ?? {}, l = await Zt();
615
+ return p.addVirtualFileSystem({ ...s, ...l.vfs }), p.setFonts({
583
616
  Roboto: {
584
617
  normal: "Roboto-Regular.ttf",
585
618
  bold: "Roboto-Medium.ttf",
586
619
  italics: "Roboto-Italic.ttf",
587
620
  bolditalics: "Roboto-MediumItalic.ttf"
588
621
  },
589
- ...r.fonts
622
+ ...l.fonts
590
623
  }), p;
591
624
  }
592
- function i(o) {
593
- const y = t();
625
+ function i(d) {
626
+ const m = t();
594
627
  n().then((p) => {
595
- p.createPdf(y).download(o ?? "document.pdf");
628
+ p.createPdf(m).download(d ?? "document.pdf");
596
629
  });
597
630
  }
598
- function s() {
599
- const o = t();
600
- n().then((y) => {
601
- y.createPdf(o).open();
631
+ function f() {
632
+ const d = t();
633
+ n().then((m) => {
634
+ m.createPdf(d).open();
602
635
  });
603
636
  }
604
- return { toDocumentDefinition: t, exportPdf: i, openPdf: s };
637
+ return { toDocumentDefinition: t, exportPdf: i, openPdf: f };
605
638
  }
606
- function Rt(e) {
607
- L(Ce, e);
639
+ function nn(e) {
640
+ F(Ue, e);
608
641
  }
609
- function Nt() {
610
- const e = D(Ce);
642
+ function on() {
643
+ const e = B(Ue);
611
644
  if (!e)
612
645
  throw new Error("usePdfExport() requires a BrickPdf ancestor component");
613
646
  return e;
614
647
  }
615
- const Pe = /* @__PURE__ */ Symbol("brick-pdf-clipboard");
616
- let zt = 0;
617
- function Tt() {
618
- return `el-${Date.now()}-${++zt}`;
648
+ const We = /* @__PURE__ */ Symbol("brick-pdf-clipboard");
649
+ let rn = 0;
650
+ function ln() {
651
+ return `el-${Date.now()}-${++rn}`;
619
652
  }
620
- function Ee(e) {
653
+ function je(e) {
621
654
  return {
622
655
  ...e,
623
- id: Tt(),
656
+ id: ln(),
624
657
  props: structuredClone(e.props),
625
658
  style: structuredClone(e.style),
626
- children: e.children.map(Ee)
659
+ children: e.children.map(je)
627
660
  };
628
661
  }
629
- function Lt(e, t) {
630
- const n = E(null), i = E(!1), s = E(null), o = E(!1);
631
- function y(r) {
632
- const l = e.findNodeById(r);
633
- l && (n.value = structuredClone(l.node), i.value = !1, s.value = null, o.value = !0);
662
+ function sn(e, t) {
663
+ const n = E(null), i = E(!1), f = E(null), d = E(!1);
664
+ function m(l) {
665
+ const o = e.findNodeById(l);
666
+ o && (n.value = structuredClone(o.node), i.value = !1, f.value = null, d.value = !0);
634
667
  }
635
- function p(r) {
636
- const l = e.findNodeById(r);
637
- l && (n.value = structuredClone(l.node), i.value = !0, s.value = r, o.value = !0);
668
+ function p(l) {
669
+ const o = e.findNodeById(l);
670
+ o && (n.value = structuredClone(o.node), i.value = !0, f.value = l, d.value = !0);
638
671
  }
639
- function d(r) {
672
+ function s(l) {
640
673
  if (!n.value) return;
641
- i.value && s.value && (t.removeElement(s.value), i.value = !1, s.value = null);
642
- const l = Ee(n.value), u = r ? e.findNodeById(r)?.node.children : e.document.content;
643
- u && (u.push(l), i.value && (n.value = null, o.value = !1));
674
+ i.value && f.value && (t.removeElement(f.value), i.value = !1, f.value = null);
675
+ const o = je(n.value), r = l ? e.findNodeById(l)?.node.children : e.document.content;
676
+ r && (r.push(o), i.value && (n.value = null, d.value = !1));
644
677
  }
645
- return { hasClipboard: o, copy: y, cut: p, paste: d };
678
+ return { hasClipboard: d, copy: m, cut: p, paste: s };
646
679
  }
647
- function Dt(e) {
648
- L(Pe, e);
680
+ function an(e) {
681
+ F(We, e);
649
682
  }
650
- function lr() {
651
- const e = D(Pe);
683
+ function Gr() {
684
+ const e = B(We);
652
685
  if (!e)
653
686
  throw new Error("useClipboard() requires a BrickPdf ancestor component");
654
687
  return e;
655
688
  }
656
- const Ie = /* @__PURE__ */ Symbol("brick-pdf-resize");
657
- function Mt(e) {
689
+ const Ye = /* @__PURE__ */ Symbol("brick-pdf-resize");
690
+ function cn(e) {
658
691
  const t = E(!1);
659
- function n(i, s, o, y) {
692
+ function n(i, f, d, m) {
660
693
  t.value = !0;
661
- const p = y.clientX, d = y.clientY, r = o.width, l = o.height;
662
- function u(f) {
663
- const b = f.clientX - p, h = f.clientY - d;
664
- let v = r, S = l;
665
- s.includes("e") && (v = r + b), s.includes("w") && (v = r - b), s.includes("s") && (S = l + h), s.includes("n") && (S = l - h), v = Math.max(20, v), S = Math.max(20, S), e.updateStyle(i, {
666
- width: Math.round(v),
667
- height: Math.round(S)
694
+ const p = m.clientX, s = m.clientY, l = d.width, o = d.height;
695
+ function r(v) {
696
+ const b = v.clientX - p, k = v.clientY - s;
697
+ let C = l, _ = o;
698
+ f.includes("e") && (C = l + b), f.includes("w") && (C = l - b), f.includes("s") && (_ = o + k), f.includes("n") && (_ = o - k), C = Math.max(20, C), _ = Math.max(20, _), e.updateStyle(i, {
699
+ width: Math.round(C),
700
+ height: Math.round(_)
668
701
  });
669
702
  }
670
- function g() {
671
- t.value = !1, document.removeEventListener("pointermove", u), document.removeEventListener("pointerup", g);
703
+ function c() {
704
+ t.value = !1, document.removeEventListener("pointermove", r), document.removeEventListener("pointerup", c);
672
705
  }
673
- document.addEventListener("pointermove", u), document.addEventListener("pointerup", g);
706
+ document.addEventListener("pointermove", r), document.addEventListener("pointerup", c);
674
707
  }
675
708
  return { isResizing: t, startResize: n };
676
709
  }
677
- function Bt(e) {
678
- L(Ie, e);
710
+ function un(e) {
711
+ F(Ye, e);
679
712
  }
680
- function ir() {
681
- const e = D(Ie);
713
+ function Qr() {
714
+ const e = B(Ye);
682
715
  if (!e)
683
716
  throw new Error("useResize() requires a BrickPdf ancestor component");
684
717
  return e;
685
718
  }
686
- const Ot = { class: "brick-table-editor" }, At = { class: "brick-table-editor__grid" }, Vt = ["onClick"], Ft = { class: "brick-table-editor__row-header" }, Ht = ["onClick"], Jt = ["value", "onInput"], Ut = /* @__PURE__ */ _({
719
+ const dn = { class: "brick-table-editor" }, pn = { class: "brick-table-editor__grid" }, fn = ["onClick"], yn = { class: "brick-table-editor__row-header" }, mn = ["onClick"], vn = ["value", "onInput"], bn = /* @__PURE__ */ S({
687
720
  __name: "TablePropertyEditor",
688
721
  props: {
689
722
  node: {}
690
723
  },
691
724
  setup(e) {
692
- const t = e, n = j();
725
+ const t = e, n = re();
693
726
  function i() {
694
727
  return t.node.props.body ?? [];
695
728
  }
696
- function s() {
729
+ function f() {
697
730
  return t.node.props.widths ?? [];
698
731
  }
699
- function o(l, u, g) {
700
- const f = i().map((b) => [...b]);
701
- f[l][u] = g, n.updateProps(t.node.id, { body: f });
732
+ function d(o, r, c) {
733
+ const v = i().map((b) => [...b]);
734
+ v[o][r] = c, n.updateProps(t.node.id, { body: v });
702
735
  }
703
- function y() {
704
- const l = i().map((g) => [...g]), u = l[0]?.length ?? 2;
705
- l.push(Array(u).fill("")), n.updateProps(t.node.id, { body: l });
736
+ function m() {
737
+ const o = i().map((c) => [...c]), r = o[0]?.length ?? 2;
738
+ o.push(Array(r).fill("")), n.updateProps(t.node.id, { body: o });
706
739
  }
707
- function p(l) {
708
- const u = i().map((f) => [...f]);
709
- if (u.length <= 1) return;
710
- u.splice(l, 1), t.node.props.headerRows > u.length ? n.updateProps(t.node.id, { body: u, headerRows: u.length }) : n.updateProps(t.node.id, { body: u });
740
+ function p(o) {
741
+ const r = i().map((v) => [...v]);
742
+ if (r.length <= 1) return;
743
+ r.splice(o, 1), t.node.props.headerRows > r.length ? n.updateProps(t.node.id, { body: r, headerRows: r.length }) : n.updateProps(t.node.id, { body: r });
711
744
  }
712
- function d() {
713
- const l = i().map((g) => [...g, ""]), u = [...s(), "*"];
714
- n.updateProps(t.node.id, { body: l, widths: u });
745
+ function s() {
746
+ const o = i().map((c) => [...c, ""]), r = [...f(), "*"];
747
+ n.updateProps(t.node.id, { body: o, widths: r });
715
748
  }
716
- function r(l) {
717
- const u = i().map((f) => {
718
- const b = [...f];
719
- return b.splice(l, 1), b;
749
+ function l(o) {
750
+ const r = i().map((v) => {
751
+ const b = [...v];
752
+ return b.splice(o, 1), b;
720
753
  });
721
- if ((u[0]?.length ?? 0) < 1) return;
722
- const g = [...s()];
723
- g.splice(l, 1), n.updateProps(t.node.id, { body: u, widths: g });
754
+ if ((r[0]?.length ?? 0) < 1) return;
755
+ const c = [...f()];
756
+ c.splice(o, 1), n.updateProps(t.node.id, { body: r, widths: c });
724
757
  }
725
- return (l, u) => (a(), c("div", Ot, [
726
- m("div", { class: "brick-table-editor__actions" }, [
727
- m("button", {
758
+ return (o, r) => (a(), u("div", dn, [
759
+ y("div", { class: "brick-table-editor__actions" }, [
760
+ y("button", {
728
761
  class: "brick-table-editor__btn",
729
- onClick: y
762
+ onClick: m
730
763
  }, "+ Row"),
731
- m("button", {
764
+ y("button", {
732
765
  class: "brick-table-editor__btn",
733
- onClick: d
766
+ onClick: s
734
767
  }, "+ Column")
735
768
  ]),
736
- m("div", At, [
737
- m("table", null, [
738
- m("thead", null, [
739
- m("tr", null, [
740
- u[0] || (u[0] = m("th", { class: "brick-table-editor__corner" }, null, -1)),
741
- (a(!0), c(C, null, P(i()[0] ?? [], (g, f) => (a(), c("th", {
742
- key: f,
769
+ y("div", pn, [
770
+ y("table", null, [
771
+ y("thead", null, [
772
+ y("tr", null, [
773
+ r[0] || (r[0] = y("th", { class: "brick-table-editor__corner" }, null, -1)),
774
+ (a(!0), u(P, null, T(i()[0] ?? [], (c, v) => (a(), u("th", {
775
+ key: v,
743
776
  class: "brick-table-editor__col-header"
744
777
  }, [
745
- le(" Col " + w(f + 1) + " ", 1),
746
- (i()[0]?.length ?? 0) > 1 ? (a(), c("button", {
778
+ pe(" Col " + w(v + 1) + " ", 1),
779
+ (i()[0]?.length ?? 0) > 1 ? (a(), u("button", {
747
780
  key: 0,
748
781
  class: "brick-table-editor__remove-btn",
749
782
  title: "Remove column",
750
- onClick: (b) => r(f)
751
- }, "x", 8, Vt)) : $("", !0)
783
+ onClick: (b) => l(v)
784
+ }, "x", 8, fn)) : R("", !0)
752
785
  ]))), 128))
753
786
  ])
754
787
  ]),
755
- m("tbody", null, [
756
- (a(!0), c(C, null, P(i(), (g, f) => (a(), c("tr", { key: f }, [
757
- m("td", Ft, [
758
- le(w(f + 1) + " ", 1),
759
- i().length > 1 ? (a(), c("button", {
788
+ y("tbody", null, [
789
+ (a(!0), u(P, null, T(i(), (c, v) => (a(), u("tr", { key: v }, [
790
+ y("td", yn, [
791
+ pe(w(v + 1) + " ", 1),
792
+ i().length > 1 ? (a(), u("button", {
760
793
  key: 0,
761
794
  class: "brick-table-editor__remove-btn",
762
795
  title: "Remove row",
763
- onClick: (b) => p(f)
764
- }, "x", 8, Ht)) : $("", !0)
796
+ onClick: (b) => p(v)
797
+ }, "x", 8, mn)) : R("", !0)
765
798
  ]),
766
- (a(!0), c(C, null, P(g, (b, h) => (a(), c("td", { key: h }, [
767
- m("input", {
799
+ (a(!0), u(P, null, T(c, (b, k) => (a(), u("td", { key: k }, [
800
+ y("input", {
768
801
  class: "brick-table-editor__cell",
769
802
  type: "text",
770
803
  value: b,
771
- onInput: (v) => o(f, h, v.target.value)
772
- }, null, 40, Jt)
804
+ onInput: (C) => d(v, k, C.target.value)
805
+ }, null, 40, vn)
773
806
  ]))), 128))
774
807
  ]))), 128))
775
808
  ])
@@ -777,15 +810,15 @@ const Ot = { class: "brick-table-editor" }, At = { class: "brick-table-editor__g
777
810
  ])
778
811
  ]));
779
812
  }
780
- }), Wt = /* @__PURE__ */ x(Ut, [["__scopeId", "data-v-4895020c"]]), jt = {
813
+ }), gn = /* @__PURE__ */ $(bn, [["__scopeId", "data-v-4895020c"]]), hn = {
781
814
  type: "table",
782
815
  label: "Table",
783
816
  icon: "▦",
784
817
  isContainer: !1,
785
- defaultProps: st,
786
- defaultStyle: at,
787
- rendererComponent: ut,
788
- propertyEditorComponent: Wt,
818
+ defaultProps: Tt,
819
+ defaultStyle: Rt,
820
+ rendererComponent: Mt,
821
+ propertyEditorComponent: gn,
789
822
  propertyFields: [
790
823
  { key: "props.headerRows", label: "Header Rows", section: "content", type: "number", min: 0, max: 10, step: 1, defaultValue: 1 },
791
824
  { key: "props.layout", label: "Border Style", section: "style", type: "select", options: [
@@ -793,67 +826,67 @@ const Ot = { class: "brick-table-editor" }, At = { class: "brick-table-editor__g
793
826
  { label: "Grid", value: "grid" },
794
827
  { label: "Header Only", value: "headerLineOnly" },
795
828
  { label: "No Borders", value: "noBorders" },
796
- { label: "None", value: "none" }
829
+ { label: "Default (grid)", value: "none" }
797
830
  ], defaultValue: "lightHorizontalLines" },
798
831
  { key: "style.fontSize", label: "Font Size", section: "style", type: "number", min: 6, max: 72, step: 1, defaultValue: 12 },
799
832
  { key: "style.color", label: "Text Color", section: "style", type: "color", defaultValue: "#000000" },
800
833
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
801
834
  ],
802
- toPdfmake: ct
835
+ toPdfmake: Lt
803
836
  };
804
- function Yt() {
837
+ function _n() {
805
838
  return { src: "", width: 200, height: 150, fit: null };
806
839
  }
807
- function qt() {
840
+ function kn() {
808
841
  return {};
809
842
  }
810
- function Kt(e) {
843
+ function Sn(e) {
811
844
  const t = {
812
845
  image: e.props.src
813
846
  };
814
847
  return e.props.width && (t.width = e.props.width), e.props.height && (t.height = e.props.height), e.props.fit && (t.fit = e.props.fit), e.style.margin && (t.margin = e.style.margin), e.style.alignment && (t.alignment = e.style.alignment), e.style.opacity !== void 0 && (t.opacity = e.style.opacity), t;
815
848
  }
816
- const Gt = { class: "brick-el-image" }, Xt = ["src"], Qt = {
849
+ const xn = { class: "brick-el-image" }, Cn = ["src"], wn = {
817
850
  key: 1,
818
851
  class: "brick-el-image__placeholder"
819
- }, Zt = /* @__PURE__ */ _({
852
+ }, Pn = /* @__PURE__ */ S({
820
853
  __name: "ImageRenderer",
821
854
  props: {
822
855
  node: {}
823
856
  },
824
857
  setup(e) {
825
- return (t, n) => (a(), c("div", Gt, [
826
- e.node.props.src ? (a(), c("img", {
858
+ return (t, n) => (a(), u("div", xn, [
859
+ e.node.props.src ? (a(), u("img", {
827
860
  key: 0,
828
861
  src: e.node.props.src,
829
- style: N({
830
- width: e.node.props.width + "px",
831
- height: e.node.props.height + "px",
832
- objectFit: "contain",
862
+ style: L({
863
+ width: e.node.props.width ? "calc(" + e.node.props.width + " * var(--brick-pt, 1px))" : void 0,
864
+ height: e.node.props.height ? "calc(" + e.node.props.height + " * var(--brick-pt, 1px))" : void 0,
865
+ objectFit: e.node.props.fit ? "contain" : "fill",
833
866
  opacity: e.node.style.opacity
834
867
  })
835
- }, null, 12, Xt)) : (a(), c("div", Qt, " No image selected "))
868
+ }, null, 12, Cn)) : (a(), u("div", wn, " No image selected "))
836
869
  ]));
837
870
  }
838
- }), en = /* @__PURE__ */ x(Zt, [["__scopeId", "data-v-38184258"]]), tn = { class: "brick-image-editor" }, nn = /* @__PURE__ */ _({
871
+ }), En = /* @__PURE__ */ $(Pn, [["__scopeId", "data-v-c4eec346"]]), $n = { class: "brick-image-editor" }, In = /* @__PURE__ */ S({
839
872
  __name: "ImagePropertyEditor",
840
873
  props: {
841
874
  node: {}
842
875
  },
843
876
  setup(e) {
844
- return (t, n) => (a(), c("div", tn));
877
+ return (t, n) => (a(), u("div", $n));
845
878
  }
846
- }), on = {
879
+ }), Nn = {
847
880
  type: "image",
848
881
  label: "Image",
849
882
  icon: "🖼",
850
883
  isContainer: !1,
851
- defaultProps: Yt,
852
- defaultStyle: qt,
853
- rendererComponent: en,
854
- propertyEditorComponent: nn,
884
+ defaultProps: _n,
885
+ defaultStyle: kn,
886
+ rendererComponent: En,
887
+ propertyEditorComponent: In,
855
888
  propertyFields: [
856
- { key: "props.src", label: "Image (Base64)", section: "content", type: "file" },
889
+ { key: "props.src", label: "Image (Base64)", section: "content", type: "file", accept: "image/png,image/jpeg" },
857
890
  { key: "props.width", label: "Width", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 200 },
858
891
  { key: "props.height", label: "Height", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 150 },
859
892
  { key: "style.alignment", label: "Alignment", section: "style", type: "select", options: [
@@ -864,53 +897,53 @@ const Gt = { class: "brick-el-image" }, Xt = ["src"], Qt = {
864
897
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] },
865
898
  { key: "style.opacity", label: "Opacity", section: "advanced", type: "slider", min: 0, max: 1, step: 0.1, defaultValue: 1 }
866
899
  ],
867
- toPdfmake: Kt
900
+ toPdfmake: Sn
868
901
  };
869
- function rn() {
902
+ function zn() {
870
903
  return { ordered: !1, items: ["Item 1", "Item 2", "Item 3"] };
871
904
  }
872
- function ln() {
905
+ function Tn() {
873
906
  return { fontSize: 12 };
874
907
  }
875
- function sn(e) {
908
+ function Rn(e) {
876
909
  const t = e.props.items, i = e.props.ordered ? { ol: t } : { ul: t };
877
910
  return e.style.fontSize && (i.fontSize = e.style.fontSize), e.style.color && (i.color = e.style.color), e.style.margin && (i.margin = e.style.margin), i;
878
911
  }
879
- const an = /* @__PURE__ */ _({
912
+ const Ln = /* @__PURE__ */ S({
880
913
  __name: "ListRenderer",
881
914
  props: {
882
915
  node: {}
883
916
  },
884
917
  setup(e) {
885
- return (t, n) => (a(), c("div", {
918
+ return (t, n) => (a(), u("div", {
886
919
  class: "brick-el-list",
887
- style: N({ fontSize: (e.node.style.fontSize ?? 12) + "px", color: e.node.style.color })
920
+ style: L({ fontSize: e.node.style.fontSize ? "calc(" + e.node.style.fontSize + " * var(--brick-pt, 1px))" : void 0, color: e.node.style.color })
888
921
  }, [
889
- (a(), M(ee(e.node.props.ordered ? "ol" : "ul"), null, {
890
- default: Y(() => [
891
- (a(!0), c(C, null, P(e.node.props.items, (i, s) => (a(), c("li", { key: s }, w(i), 1))), 128))
922
+ (a(), H(ve(e.node.props.ordered ? "ol" : "ul"), null, {
923
+ default: se(() => [
924
+ (a(!0), u(P, null, T(e.node.props.items, (i, f) => (a(), u("li", { key: f }, w(i), 1))), 128))
892
925
  ]),
893
926
  _: 1
894
927
  }))
895
928
  ], 4));
896
929
  }
897
- }), cn = /* @__PURE__ */ x(an, [["__scopeId", "data-v-8107f859"]]), dn = { class: "brick-list-editor" }, un = /* @__PURE__ */ _({
930
+ }), Dn = /* @__PURE__ */ $(Ln, [["__scopeId", "data-v-ff2edb53"]]), Bn = { class: "brick-list-editor" }, Mn = /* @__PURE__ */ S({
898
931
  __name: "ListPropertyEditor",
899
932
  props: {
900
933
  node: {}
901
934
  },
902
935
  setup(e) {
903
- return (t, n) => (a(), c("div", dn));
936
+ return (t, n) => (a(), u("div", Bn));
904
937
  }
905
- }), pn = {
938
+ }), On = {
906
939
  type: "list",
907
940
  label: "List",
908
941
  icon: "☰",
909
942
  isContainer: !1,
910
- defaultProps: rn,
911
- defaultStyle: ln,
912
- rendererComponent: cn,
913
- propertyEditorComponent: un,
943
+ defaultProps: zn,
944
+ defaultStyle: Tn,
945
+ rendererComponent: Dn,
946
+ propertyEditorComponent: Mn,
914
947
  propertyFields: [
915
948
  { key: "props.ordered", label: "Ordered", section: "content", type: "toggle", defaultValue: !1 },
916
949
  { key: "props.items", label: "Items", section: "content", type: "textarea", defaultValue: `Item 1
@@ -920,54 +953,54 @@ Item 3` },
920
953
  { key: "style.color", label: "Color", section: "style", type: "color", defaultValue: "#000000" },
921
954
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
922
955
  ],
923
- toPdfmake: sn
956
+ toPdfmake: Rn
924
957
  };
925
- function fn() {
958
+ function An() {
926
959
  return { data: "https://example.com", fit: 100 };
927
960
  }
928
- function yn() {
961
+ function Vn() {
929
962
  return {};
930
963
  }
931
- function mn(e) {
964
+ function Hn(e) {
932
965
  const t = {
933
966
  qr: e.props.data,
934
967
  fit: e.props.fit ?? 100
935
968
  };
936
969
  return e.style.alignment && (t.alignment = e.style.alignment), e.style.margin && (t.margin = e.style.margin), t;
937
970
  }
938
- const gn = { class: "brick-el-qr__preview" }, bn = /* @__PURE__ */ _({
971
+ const Fn = { class: "brick-el-qr__preview" }, Un = /* @__PURE__ */ S({
939
972
  __name: "QrRenderer",
940
973
  props: {
941
974
  node: {}
942
975
  },
943
976
  setup(e) {
944
- return (t, n) => (a(), c("div", {
977
+ return (t, n) => (a(), u("div", {
945
978
  class: "brick-el-qr",
946
- style: N({
947
- width: (e.node.props.fit ?? 100) + "px",
948
- height: (e.node.props.fit ?? 100) + "px"
979
+ style: L({
980
+ width: "calc(" + (e.node.props.fit ?? 100) + " * var(--brick-pt, 1px))",
981
+ height: "calc(" + (e.node.props.fit ?? 100) + " * var(--brick-pt, 1px))"
949
982
  })
950
983
  }, [
951
- m("div", gn, "QR: " + w(e.node.props.data), 1)
984
+ y("div", Fn, "QR: " + w(e.node.props.data), 1)
952
985
  ], 4));
953
986
  }
954
- }), hn = /* @__PURE__ */ x(bn, [["__scopeId", "data-v-f106ba48"]]), vn = { class: "brick-qr-editor" }, _n = /* @__PURE__ */ _({
987
+ }), Jn = /* @__PURE__ */ $(Un, [["__scopeId", "data-v-f9071a9d"]]), Wn = { class: "brick-qr-editor" }, jn = /* @__PURE__ */ S({
955
988
  __name: "QrPropertyEditor",
956
989
  props: {
957
990
  node: {}
958
991
  },
959
992
  setup(e) {
960
- return (t, n) => (a(), c("div", vn));
993
+ return (t, n) => (a(), u("div", Wn));
961
994
  }
962
- }), kn = {
995
+ }), Yn = {
963
996
  type: "qr",
964
997
  label: "QR Code",
965
998
  icon: "⊞",
966
999
  isContainer: !1,
967
- defaultProps: fn,
968
- defaultStyle: yn,
969
- rendererComponent: hn,
970
- propertyEditorComponent: _n,
1000
+ defaultProps: An,
1001
+ defaultStyle: Vn,
1002
+ rendererComponent: Jn,
1003
+ propertyEditorComponent: jn,
971
1004
  propertyFields: [
972
1005
  { key: "props.data", label: "QR Data", section: "content", type: "text", defaultValue: "https://example.com" },
973
1006
  { key: "props.fit", label: "Size (px)", section: "layout", type: "number", min: 50, max: 500, step: 10, defaultValue: 100 },
@@ -978,56 +1011,56 @@ const gn = { class: "brick-el-qr__preview" }, bn = /* @__PURE__ */ _({
978
1011
  ] },
979
1012
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
980
1013
  ],
981
- toPdfmake: mn
1014
+ toPdfmake: Hn
982
1015
  };
983
- function Sn() {
1016
+ function qn() {
984
1017
  return {
985
1018
  svg: '<svg viewBox="0 0 100 100"><rect width="100" height="100" fill="#eee" /><text x="50" y="55" text-anchor="middle" font-size="12">SVG</text></svg>',
986
1019
  width: 200,
987
1020
  height: 200
988
1021
  };
989
1022
  }
990
- function xn() {
1023
+ function Kn() {
991
1024
  return {};
992
1025
  }
993
- function Cn(e) {
1026
+ function Xn(e) {
994
1027
  const t = {
995
1028
  svg: e.props.svg
996
1029
  };
997
1030
  return e.props.width && (t.width = e.props.width), e.props.height && (t.height = e.props.height), e.style.margin && (t.margin = e.style.margin), e.style.alignment && (t.alignment = e.style.alignment), t;
998
1031
  }
999
- const wn = ["innerHTML"], Pn = /* @__PURE__ */ _({
1032
+ const Gn = ["innerHTML"], Qn = /* @__PURE__ */ S({
1000
1033
  __name: "SvgRenderer",
1001
1034
  props: {
1002
1035
  node: {}
1003
1036
  },
1004
1037
  setup(e) {
1005
- return (t, n) => (a(), c("div", {
1038
+ return (t, n) => (a(), u("div", {
1006
1039
  class: "brick-el-svg",
1007
- style: N({
1008
- width: e.node.props.width + "px",
1009
- height: e.node.props.height + "px"
1040
+ style: L({
1041
+ width: "calc(" + e.node.props.width + " * var(--brick-pt, 1px))",
1042
+ height: "calc(" + e.node.props.height + " * var(--brick-pt, 1px))"
1010
1043
  }),
1011
1044
  innerHTML: e.node.props.svg
1012
- }, null, 12, wn));
1045
+ }, null, 12, Gn));
1013
1046
  }
1014
- }), En = /* @__PURE__ */ x(Pn, [["__scopeId", "data-v-5e9f3319"]]), In = { class: "brick-svg-editor" }, $n = /* @__PURE__ */ _({
1047
+ }), Zn = /* @__PURE__ */ $(Qn, [["__scopeId", "data-v-ab0b9b0b"]]), eo = { class: "brick-svg-editor" }, to = /* @__PURE__ */ S({
1015
1048
  __name: "SvgPropertyEditor",
1016
1049
  props: {
1017
1050
  node: {}
1018
1051
  },
1019
1052
  setup(e) {
1020
- return (t, n) => (a(), c("div", In));
1053
+ return (t, n) => (a(), u("div", eo));
1021
1054
  }
1022
- }), Rn = {
1055
+ }), no = {
1023
1056
  type: "svg",
1024
1057
  label: "SVG",
1025
1058
  icon: "◇",
1026
1059
  isContainer: !1,
1027
- defaultProps: Sn,
1028
- defaultStyle: xn,
1029
- rendererComponent: En,
1030
- propertyEditorComponent: $n,
1060
+ defaultProps: qn,
1061
+ defaultStyle: Kn,
1062
+ rendererComponent: Zn,
1063
+ propertyEditorComponent: to,
1031
1064
  propertyFields: [
1032
1065
  { key: "props.svg", label: "SVG Markup", section: "content", type: "textarea" },
1033
1066
  { key: "props.width", label: "Width", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 200 },
@@ -1039,613 +1072,867 @@ const wn = ["innerHTML"], Pn = /* @__PURE__ */ _({
1039
1072
  ] },
1040
1073
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
1041
1074
  ],
1042
- toPdfmake: Cn
1075
+ toPdfmake: Xn
1043
1076
  };
1044
- function Nn() {
1077
+ function oo() {
1045
1078
  return {};
1046
1079
  }
1047
- function zn() {
1080
+ function ro() {
1048
1081
  return {};
1049
1082
  }
1050
- function Tn(e) {
1083
+ function lo(e) {
1051
1084
  return { text: "", pageBreak: "after" };
1052
1085
  }
1053
- const Ln = { class: "brick-el-pagebreak" }, Dn = /* @__PURE__ */ _({
1086
+ const io = { class: "brick-el-pagebreak" }, so = /* @__PURE__ */ S({
1054
1087
  __name: "PageBreakRenderer",
1055
1088
  props: {
1056
1089
  node: {}
1057
1090
  },
1058
1091
  setup(e) {
1059
- return (t, n) => (a(), c("div", Ln, [...n[0] || (n[0] = [
1060
- m("hr", null, null, -1),
1061
- m("span", null, "Page Break", -1),
1062
- m("hr", null, null, -1)
1092
+ return (t, n) => (a(), u("div", io, [...n[0] || (n[0] = [
1093
+ y("hr", null, null, -1),
1094
+ y("span", null, "Page Break", -1),
1095
+ y("hr", null, null, -1)
1063
1096
  ])]));
1064
1097
  }
1065
- }), Mn = /* @__PURE__ */ x(Dn, [["__scopeId", "data-v-60c05148"]]), Bn = { class: "brick-pagebreak-editor" }, On = /* @__PURE__ */ _({
1098
+ }), ao = /* @__PURE__ */ $(so, [["__scopeId", "data-v-60c05148"]]), co = { class: "brick-pagebreak-editor" }, uo = /* @__PURE__ */ S({
1066
1099
  __name: "PageBreakPropertyEditor",
1067
1100
  props: {
1068
1101
  node: {}
1069
1102
  },
1070
1103
  setup(e) {
1071
- return (t, n) => (a(), c("div", Bn, [...n[0] || (n[0] = [
1072
- m("p", { style: { color: "#999", "font-size": "12px" } }, "No configurable properties.", -1)
1104
+ return (t, n) => (a(), u("div", co, [...n[0] || (n[0] = [
1105
+ y("p", { style: { color: "#999", "font-size": "12px" } }, "No configurable properties.", -1)
1073
1106
  ])]));
1074
1107
  }
1075
- }), An = {
1108
+ }), po = {
1076
1109
  type: "pageBreak",
1077
1110
  label: "Page Break",
1078
1111
  icon: "⏎",
1079
1112
  isContainer: !1,
1080
- defaultProps: Nn,
1081
- defaultStyle: zn,
1082
- rendererComponent: Mn,
1083
- propertyEditorComponent: On,
1113
+ defaultProps: oo,
1114
+ defaultStyle: ro,
1115
+ rendererComponent: ao,
1116
+ propertyEditorComponent: uo,
1084
1117
  propertyFields: [],
1085
- toPdfmake: Tn
1118
+ toPdfmake: lo
1086
1119
  };
1087
- let fe = !1;
1088
- function Vn() {
1089
- fe || (fe = !0, z(Ue), z(Qe), z(it), z(jt), z(on), z(pn), z(kn), z(Rn), z(An));
1120
+ let Ie = !1;
1121
+ function fo() {
1122
+ Ie || (Ie = !0, V(mt), V(xt), V(zt), V(hn), V(Nn), V(On), V(Yn), V(no), V(po));
1123
+ }
1124
+ function M(e) {
1125
+ return `calc(${e} * var(--brick-pt, 1px))`;
1126
+ }
1127
+ const le = /* @__PURE__ */ Symbol("brick-pdf-canvas");
1128
+ function ce(e, t) {
1129
+ for (const n of e) {
1130
+ if (n.id === t) return [];
1131
+ const i = ce(n.children, t);
1132
+ if (i) return [n, ...i];
1133
+ }
1134
+ return null;
1090
1135
  }
1091
- const Fn = {
1092
- key: 0,
1093
- class: "brick-dropzone__empty"
1094
- }, Hn = /* @__PURE__ */ _({
1136
+ const yo = /* @__PURE__ */ S({
1095
1137
  __name: "DropZone",
1096
1138
  props: {
1097
1139
  parentId: {},
1098
- layout: {}
1140
+ layout: {},
1141
+ empty: { type: Boolean }
1099
1142
  },
1100
1143
  setup(e) {
1101
1144
  const t = e, n = E(null);
1102
1145
  let i = null;
1103
- const s = xe(), { isDragging: o } = s;
1104
- return ye(() => {
1105
- n.value && (i = s.initContainer(n.value, t.parentId));
1106
- }), me(() => {
1146
+ const f = ge(), { isDragging: d } = f;
1147
+ return Te(() => {
1148
+ n.value && (i = f.initContainer(n.value, t.parentId));
1149
+ }), Re(() => {
1107
1150
  i?.destroy();
1108
- }), (y, p) => (a(), c("div", {
1151
+ }), (m, p) => (a(), u("div", {
1109
1152
  ref_key: "el",
1110
1153
  ref: n,
1111
- class: Z(["brick-dropzone", { "brick-dropzone--horizontal": e.layout === "horizontal", "brick-dropzone--drag-active": k(o) && e.layout === "horizontal" }])
1154
+ class: Y(["brick-dropzone", {
1155
+ "brick-dropzone--horizontal": e.layout === "horizontal",
1156
+ "brick-dropzone--drag-active": g(d) && e.layout === "horizontal",
1157
+ "brick-dropzone--empty": e.empty
1158
+ }])
1112
1159
  }, [
1113
- Q(y.$slots, "default", {}, void 0, !0),
1114
- y.$slots.default ? $("", !0) : (a(), c("div", Fn, " Drop elements here "))
1160
+ me(m.$slots, "default", {}, void 0, !0)
1115
1161
  ], 2));
1116
1162
  }
1117
- }), $e = /* @__PURE__ */ x(Hn, [["__scopeId", "data-v-b9596dad"]]), Jn = ["data-element-id", "data-element-type"], Un = {
1163
+ }), qe = /* @__PURE__ */ $(yo, [["__scopeId", "data-v-582e7b20"]]), mo = ["data-element-id", "data-element-type"], vo = {
1118
1164
  key: 1,
1119
1165
  class: "brick-canvas-element__unknown"
1120
- }, Wn = /* @__PURE__ */ _({
1166
+ }, bo = { class: "brick-canvas-element__chip-label" }, go = /* @__PURE__ */ S({
1121
1167
  __name: "CanvasElement",
1122
1168
  props: {
1123
1169
  node: {},
1124
- path: {}
1170
+ path: {},
1171
+ inColumns: { type: Boolean }
1125
1172
  },
1126
1173
  setup(e) {
1127
- const t = e, n = W(), i = j(), s = E(null), o = I(() => U(t.node.type)), y = I(() => n.selectedId.value === t.node.id), p = I(() => o.value ? o.value.propertyFields.some((f) => f.key === "props.width" || f.key === "style.width") : !1), d = I(() => o.value ? o.value.propertyFields.some((f) => f.key === "props.height" || f.key === "style.height") : !1);
1128
- function r(f) {
1129
- f.stopPropagation(), n.select(t.node.id);
1174
+ const t = e, n = Q(), i = re(), f = G(), { isDragging: d } = ge(), m = B(le, null), p = E(null), s = x(() => W(t.node.type)), l = x(() => n.selectedId.value === t.node.id), o = x(() => m?.hoveredId.value === t.node.id), r = x(
1175
+ () => !!s.value?.isContainer && (!!m?.showOutlines.value || d.value)
1176
+ );
1177
+ function c() {
1178
+ m && (m.hoveredId.value = t.node.id);
1179
+ }
1180
+ function v() {
1181
+ const h = ce(f.document.content, t.node.id), N = h?.[h.length - 1];
1182
+ N && n.select(N.id);
1183
+ }
1184
+ const b = x(() => t.path.length > 1);
1185
+ function k() {
1186
+ const h = i.duplicateElement(t.node.id);
1187
+ h && n.select(h.id);
1188
+ }
1189
+ function C() {
1190
+ n.deselect(), i.removeElement(t.node.id);
1191
+ }
1192
+ const _ = x(() => {
1193
+ if (s.value)
1194
+ try {
1195
+ return s.value.toPdfmake(t.node, () => [])?.width;
1196
+ } catch {
1197
+ return;
1198
+ }
1199
+ }), I = x(
1200
+ () => !!t.inColumns && _.value !== void 0 && _.value !== "*"
1201
+ ), O = x(() => {
1202
+ const h = t.node.style.alignment, N = _.value;
1203
+ if (d.value || t.inColumns || typeof N != "number" || h !== "center" && h !== "right") return;
1204
+ const [z, , D] = t.node.style.margin ?? [0, 0, 0, 0];
1205
+ return h === "center" ? `calc(${M(z)} + (100% - ${M(N + z + D)}) / 2)` : `calc(100% - ${M(N + D)})`;
1206
+ }), ie = x(() => {
1207
+ const { style: h, props: N } = t.node, z = h.margin;
1208
+ return {
1209
+ width: typeof h.width == "number" ? M(h.width) : N.width ? M(N.width) : h.width,
1210
+ height: h.height ? M(h.height) : N.height ? M(N.height) : void 0,
1211
+ marginTop: z ? M(z[1]) : void 0,
1212
+ marginRight: z ? M(z[2]) : void 0,
1213
+ marginBottom: z ? M(z[3]) : void 0,
1214
+ marginLeft: O.value ?? (z ? M(z[0]) : void 0),
1215
+ textAlign: h.alignment
1216
+ };
1217
+ }), Z = x(() => s.value ? s.value.propertyFields.some((h) => h.key === "props.width" || h.key === "style.width") : !1), he = x(() => s.value ? s.value.propertyFields.some((h) => h.key === "props.height" || h.key === "style.height") : !1);
1218
+ function Ke(h) {
1219
+ h.stopPropagation(), n.select(t.node.id);
1130
1220
  }
1131
- function l(f) {
1132
- f.stopPropagation(), f.preventDefault();
1133
- const b = f.clientX, h = s.value?.offsetWidth ?? 200;
1134
- function v(R) {
1135
- const O = R.clientX - b, T = Math.max(20, h + O);
1136
- o.value?.propertyFields.some((F) => F.key === "props.width") ? i.updateProps(t.node.id, { width: Math.round(T) }) : i.updateStyle(t.node.id, { width: Math.round(T) });
1221
+ function U(h) {
1222
+ return Math.round(h / (m?.pxPerPt.value || 1));
1223
+ }
1224
+ function Xe(h) {
1225
+ h.stopPropagation(), h.preventDefault();
1226
+ const N = h.clientX, z = p.value?.offsetWidth ?? 200;
1227
+ function D(q) {
1228
+ const K = q.clientX - N, J = Math.max(20, z + K);
1229
+ s.value?.propertyFields.some((ee) => ee.key === "props.width") ? i.updateProps(t.node.id, { width: U(J) }) : i.updateStyle(t.node.id, { width: U(J) });
1137
1230
  }
1138
- function S() {
1139
- document.removeEventListener("pointermove", v), document.removeEventListener("pointerup", S), document.body.style.cursor = "", document.body.style.userSelect = "";
1231
+ function A() {
1232
+ document.removeEventListener("pointermove", D), document.removeEventListener("pointerup", A), document.body.style.cursor = "", document.body.style.userSelect = "";
1140
1233
  }
1141
- document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", v), document.addEventListener("pointerup", S);
1234
+ document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", D), document.addEventListener("pointerup", A);
1142
1235
  }
1143
- function u(f) {
1144
- f.stopPropagation(), f.preventDefault();
1145
- const b = f.clientY, h = s.value?.offsetHeight ?? 100;
1146
- function v(R) {
1147
- const O = R.clientY - b, T = Math.max(20, h + O);
1148
- o.value?.propertyFields.some((F) => F.key === "props.height") ? i.updateProps(t.node.id, { height: Math.round(T) }) : i.updateStyle(t.node.id, { height: Math.round(T) });
1236
+ function Ge(h) {
1237
+ h.stopPropagation(), h.preventDefault();
1238
+ const N = h.clientY, z = p.value?.offsetHeight ?? 100;
1239
+ function D(q) {
1240
+ const K = q.clientY - N, J = Math.max(20, z + K);
1241
+ s.value?.propertyFields.some((ee) => ee.key === "props.height") ? i.updateProps(t.node.id, { height: U(J) }) : i.updateStyle(t.node.id, { height: U(J) });
1149
1242
  }
1150
- function S() {
1151
- document.removeEventListener("pointermove", v), document.removeEventListener("pointerup", S), document.body.style.cursor = "", document.body.style.userSelect = "";
1243
+ function A() {
1244
+ document.removeEventListener("pointermove", D), document.removeEventListener("pointerup", A), document.body.style.cursor = "", document.body.style.userSelect = "";
1152
1245
  }
1153
- document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", v), document.addEventListener("pointerup", S);
1246
+ document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", D), document.addEventListener("pointerup", A);
1154
1247
  }
1155
- function g(f) {
1156
- f.stopPropagation(), f.preventDefault();
1157
- const b = f.clientX, h = f.clientY, v = s.value?.offsetWidth ?? 200, S = s.value?.offsetHeight ?? 100;
1158
- function R(T) {
1159
- const K = T.clientX - b, F = T.clientY - h, oe = Math.max(20, v + K), re = Math.max(20, S + F), Re = o.value?.propertyFields.some((G) => G.key === "props.width"), Ne = o.value?.propertyFields.some((G) => G.key === "props.height");
1160
- Re ? i.updateProps(t.node.id, { width: Math.round(oe) }) : i.updateStyle(t.node.id, { width: Math.round(oe) }), Ne ? i.updateProps(t.node.id, { height: Math.round(re) }) : i.updateStyle(t.node.id, { height: Math.round(re) });
1248
+ function Qe(h) {
1249
+ h.stopPropagation(), h.preventDefault();
1250
+ const N = h.clientX, z = h.clientY, D = p.value?.offsetWidth ?? 200, A = p.value?.offsetHeight ?? 100;
1251
+ function q(J) {
1252
+ const ue = J.clientX - N, ee = J.clientY - z, _e = Math.max(20, D + ue), ke = Math.max(20, A + ee), Ze = s.value?.propertyFields.some((de) => de.key === "props.width"), et = s.value?.propertyFields.some((de) => de.key === "props.height");
1253
+ Ze ? i.updateProps(t.node.id, { width: U(_e) }) : i.updateStyle(t.node.id, { width: U(_e) }), et ? i.updateProps(t.node.id, { height: U(ke) }) : i.updateStyle(t.node.id, { height: U(ke) });
1161
1254
  }
1162
- function O() {
1163
- document.removeEventListener("pointermove", R), document.removeEventListener("pointerup", O), document.body.style.cursor = "", document.body.style.userSelect = "";
1255
+ function K() {
1256
+ document.removeEventListener("pointermove", q), document.removeEventListener("pointerup", K), document.body.style.cursor = "", document.body.style.userSelect = "";
1164
1257
  }
1165
- document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", R), document.addEventListener("pointerup", O);
1258
+ document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", q), document.addEventListener("pointerup", K);
1166
1259
  }
1167
- return (f, b) => {
1168
- const h = Te("CanvasElement", !0);
1169
- return a(), c("div", {
1260
+ return (h, N) => {
1261
+ const z = Le("CanvasElement", !0);
1262
+ return a(), u("div", {
1170
1263
  ref_key: "elRef",
1171
- ref: s,
1172
- class: Z(["brick-canvas-element", { "brick-canvas-element--selected": y.value }]),
1264
+ ref: p,
1265
+ class: Y(["brick-canvas-element", {
1266
+ "brick-canvas-element--selected": l.value,
1267
+ "brick-canvas-element--hovered": o.value && !l.value && !g(d),
1268
+ "brick-canvas-element--guide": r.value,
1269
+ "brick-canvas-element--col-auto": I.value
1270
+ }]),
1173
1271
  "data-element-id": e.node.id,
1174
1272
  "data-element-type": e.node.type,
1175
- style: N({
1176
- width: typeof e.node.style.width == "number" ? e.node.style.width + "px" : e.node.props.width ? e.node.props.width + "px" : e.node.style.width,
1177
- height: e.node.style.height ? e.node.style.height + "px" : e.node.props.height ? e.node.props.height + "px" : void 0,
1178
- marginTop: e.node.style.margin?.[1] + "px",
1179
- marginRight: e.node.style.margin?.[2] + "px",
1180
- marginBottom: e.node.style.margin?.[3] + "px",
1181
- marginLeft: e.node.style.margin?.[0] + "px",
1182
- textAlign: e.node.style.alignment
1183
- }),
1184
- onClick: r
1273
+ style: L(ie.value),
1274
+ onClick: Ke,
1275
+ onMouseover: fe(c, ["stop"])
1185
1276
  }, [
1186
- o.value ? (a(), M(ee(o.value.rendererComponent), {
1277
+ s.value ? (a(), H(ve(s.value.rendererComponent), {
1187
1278
  key: 0,
1188
1279
  node: e.node,
1189
1280
  path: e.path
1190
1281
  }, {
1191
- default: Y(() => [
1192
- o.value.isContainer ? (a(), M($e, {
1282
+ default: se(() => [
1283
+ s.value.isContainer ? (a(), H(qe, {
1193
1284
  key: 0,
1194
1285
  "parent-id": e.node.id,
1195
- layout: e.node.type === "columns" ? "horizontal" : "vertical"
1286
+ layout: e.node.type === "columns" ? "horizontal" : "vertical",
1287
+ empty: e.node.children.length === 0
1196
1288
  }, {
1197
- default: Y(() => [
1198
- (a(!0), c(C, null, P(e.node.children, (v, S) => (a(), M(h, {
1199
- key: v.id,
1200
- node: v,
1201
- path: [...e.path, S]
1202
- }, null, 8, ["node", "path"]))), 128))
1289
+ default: se(() => [
1290
+ (a(!0), u(P, null, T(e.node.children, (D, A) => (a(), H(z, {
1291
+ key: D.id,
1292
+ node: D,
1293
+ path: [...e.path, A],
1294
+ "in-columns": e.node.type === "columns"
1295
+ }, null, 8, ["node", "path", "in-columns"]))), 128))
1203
1296
  ]),
1204
1297
  _: 1
1205
- }, 8, ["parent-id", "layout"])) : $("", !0)
1298
+ }, 8, ["parent-id", "layout", "empty"])) : R("", !0)
1206
1299
  ]),
1207
1300
  _: 1
1208
- }, 8, ["node", "path"])) : (a(), c("div", Un, " Unknown element: " + w(e.node.type), 1)),
1209
- y.value ? (a(), c(C, { key: 2 }, [
1210
- p.value ? (a(), c("div", {
1301
+ }, 8, ["node", "path"])) : (a(), u("div", vo, " Unknown element: " + w(e.node.type), 1)),
1302
+ l.value && s.value && !g(d) ? (a(), u("div", {
1303
+ key: 2,
1304
+ class: "brick-canvas-element__chip",
1305
+ onClick: N[0] || (N[0] = fe(() => {
1306
+ }, ["stop"]))
1307
+ }, [
1308
+ y("span", bo, w(s.value.icon) + " " + w(s.value.label), 1),
1309
+ b.value ? (a(), u("button", {
1310
+ key: 0,
1311
+ type: "button",
1312
+ title: "Select parent (Esc)",
1313
+ onClick: v
1314
+ }, "↑")) : R("", !0),
1315
+ y("button", {
1316
+ type: "button",
1317
+ title: "Duplicate",
1318
+ onClick: k
1319
+ }, "⧉"),
1320
+ y("button", {
1321
+ type: "button",
1322
+ title: "Delete",
1323
+ class: "brick-canvas-element__chip-danger",
1324
+ onClick: C
1325
+ }, "✕")
1326
+ ])) : R("", !0),
1327
+ l.value ? (a(), u(P, { key: 3 }, [
1328
+ Z.value ? (a(), u("div", {
1211
1329
  key: 0,
1212
1330
  class: "brick-resize-handle brick-resize-handle--e",
1213
- onPointerdown: l
1214
- }, null, 32)) : $("", !0),
1215
- d.value ? (a(), c("div", {
1331
+ onPointerdown: Xe
1332
+ }, null, 32)) : R("", !0),
1333
+ he.value ? (a(), u("div", {
1216
1334
  key: 1,
1217
1335
  class: "brick-resize-handle brick-resize-handle--s",
1218
- onPointerdown: u
1219
- }, null, 32)) : $("", !0),
1220
- p.value && d.value ? (a(), c("div", {
1336
+ onPointerdown: Ge
1337
+ }, null, 32)) : R("", !0),
1338
+ Z.value && he.value ? (a(), u("div", {
1221
1339
  key: 2,
1222
1340
  class: "brick-resize-handle brick-resize-handle--se",
1223
- onPointerdown: g
1224
- }, null, 32)) : $("", !0)
1225
- ], 64)) : $("", !0)
1226
- ], 14, Jn);
1341
+ onPointerdown: Qe
1342
+ }, null, 32)) : R("", !0)
1343
+ ], 64)) : R("", !0)
1344
+ ], 46, mo);
1227
1345
  };
1228
1346
  }
1229
- }), jn = /* @__PURE__ */ x(Wn, [["__scopeId", "data-v-6b9cadc1"]]), Yn = { class: "brick-doc-bar" }, qn = { class: "brick-doc-bar__field" }, Kn = ["value"], Gn = { class: "brick-doc-bar__field" }, Xn = { class: "brick-doc-bar__field brick-doc-bar__field--margins" }, Qn = { class: "brick-doc-bar__margins" }, Zn = ["placeholder", "title", "value", "onInput"], eo = { class: "brick-doc-bar__field" }, to = ["value"], no = /* @__PURE__ */ _({
1347
+ }), ho = /* @__PURE__ */ $(go, [["__scopeId", "data-v-462d5930"]]), _o = { class: "brick-doc-bar" }, ko = { class: "brick-doc-bar__field" }, So = ["value"], xo = { class: "brick-doc-bar__field" }, Co = { class: "brick-doc-bar__field brick-doc-bar__field--margins" }, wo = { class: "brick-doc-bar__margins" }, Po = ["placeholder", "title", "value", "onInput"], Eo = { class: "brick-doc-bar__field" }, $o = ["value"], Io = {
1348
+ key: 0,
1349
+ class: "brick-doc-bar__field brick-doc-bar__zoom"
1350
+ }, No = ["value"], zo = ["value"], To = {
1351
+ key: 1,
1352
+ class: "brick-doc-bar__field brick-doc-bar__toggle",
1353
+ title: "Show container outlines"
1354
+ }, Ro = /* @__PURE__ */ S({
1230
1355
  __name: "DocumentSettings",
1231
1356
  setup(e) {
1232
- const t = ne(), n = [
1357
+ const t = G(), n = B(le, null), i = [0.5, 0.75, 1, 1.25, 1.5, 2], f = [
1233
1358
  { label: "A3", value: "A3" },
1234
1359
  { label: "A4", value: "A4" },
1235
1360
  { label: "A5", value: "A5" },
1236
1361
  { label: "Letter", value: "LETTER" },
1237
1362
  { label: "Legal", value: "LEGAL" }
1238
1363
  ];
1239
- function i(s, o) {
1240
- const y = [...t.document.pageMargins];
1241
- y[s] = o, t.document.pageMargins = y;
1364
+ function d(p) {
1365
+ p.trim() === "" || Number.isNaN(Number(p)) || (t.document.defaultStyle ??= {}, t.document.defaultStyle.fontSize = Number(p));
1366
+ }
1367
+ function m(p, s) {
1368
+ const l = [...t.document.pageMargins];
1369
+ l[p] = s, t.document.pageMargins = l;
1242
1370
  }
1243
- return (s, o) => (a(), c("div", Yn, [
1244
- m("div", qn, [
1245
- o[3] || (o[3] = m("label", null, "Size", -1)),
1246
- ie(m("select", {
1247
- "onUpdate:modelValue": o[0] || (o[0] = (y) => k(t).document.pageSize = y)
1371
+ return (p, s) => (a(), u("div", _o, [
1372
+ y("div", ko, [
1373
+ s[5] || (s[5] = y("label", null, "Size", -1)),
1374
+ ne(y("select", {
1375
+ "onUpdate:modelValue": s[0] || (s[0] = (l) => g(t).document.pageSize = l)
1248
1376
  }, [
1249
- (a(), c(C, null, P(n, (y) => m("option", {
1250
- key: y.value,
1251
- value: y.value
1252
- }, w(y.label), 9, Kn)), 64))
1377
+ (a(), u(P, null, T(f, (l) => y("option", {
1378
+ key: l.value,
1379
+ value: l.value
1380
+ }, w(l.label), 9, So)), 64))
1253
1381
  ], 512), [
1254
- [se, k(t).document.pageSize]
1382
+ [Se, g(t).document.pageSize]
1255
1383
  ])
1256
1384
  ]),
1257
- m("div", Gn, [
1258
- o[5] || (o[5] = m("label", null, "Orientation", -1)),
1259
- ie(m("select", {
1260
- "onUpdate:modelValue": o[1] || (o[1] = (y) => k(t).document.pageOrientation = y)
1261
- }, [...o[4] || (o[4] = [
1262
- m("option", { value: "portrait" }, "Portrait", -1),
1263
- m("option", { value: "landscape" }, "Landscape", -1)
1385
+ y("div", xo, [
1386
+ s[7] || (s[7] = y("label", null, "Orientation", -1)),
1387
+ ne(y("select", {
1388
+ "onUpdate:modelValue": s[1] || (s[1] = (l) => g(t).document.pageOrientation = l)
1389
+ }, [...s[6] || (s[6] = [
1390
+ y("option", { value: "portrait" }, "Portrait", -1),
1391
+ y("option", { value: "landscape" }, "Landscape", -1)
1264
1392
  ])], 512), [
1265
- [se, k(t).document.pageOrientation]
1393
+ [Se, g(t).document.pageOrientation]
1266
1394
  ])
1267
1395
  ]),
1268
- m("div", Xn, [
1269
- o[6] || (o[6] = m("label", null, "Margins", -1)),
1270
- m("div", Qn, [
1271
- (a(), c(C, null, P(["L", "T", "R", "B"], (y, p) => m("input", {
1272
- key: p,
1396
+ y("div", Co, [
1397
+ s[8] || (s[8] = y("label", null, "Margins", -1)),
1398
+ y("div", wo, [
1399
+ (a(), u(P, null, T(["L", "T", "R", "B"], (l, o) => y("input", {
1400
+ key: o,
1273
1401
  type: "number",
1274
- placeholder: y,
1275
- title: y,
1276
- value: k(t).document.pageMargins[p],
1277
- onInput: (d) => i(p, Number(d.target.value))
1278
- }, null, 40, Zn)), 64))
1402
+ placeholder: l,
1403
+ title: l,
1404
+ value: g(t).document.pageMargins[o],
1405
+ onInput: (r) => m(o, Number(r.target.value))
1406
+ }, null, 40, Po)), 64))
1279
1407
  ])
1280
1408
  ]),
1281
- m("div", eo, [
1282
- o[7] || (o[7] = m("label", null, "Font Size", -1)),
1283
- m("input", {
1409
+ y("div", Eo, [
1410
+ s[9] || (s[9] = y("label", null, "Font Size", -1)),
1411
+ y("input", {
1284
1412
  type: "number",
1285
- value: k(t).document.defaultStyle?.fontSize ?? 12,
1413
+ value: g(t).document.defaultStyle?.fontSize ?? 12,
1286
1414
  min: "6",
1287
1415
  max: "72",
1288
- onInput: o[2] || (o[2] = (y) => (k(t).document.defaultStyle ??= {}).fontSize = Number(y.target.value))
1289
- }, null, 40, to)
1290
- ])
1416
+ onInput: s[2] || (s[2] = (l) => d(l.target.value))
1417
+ }, null, 40, $o)
1418
+ ]),
1419
+ g(n) ? (a(), u("div", Io, [
1420
+ s[11] || (s[11] = y("label", null, "Zoom", -1)),
1421
+ y("select", {
1422
+ value: g(n).zoom.value,
1423
+ onChange: s[3] || (s[3] = (l) => g(n).zoom.value = l.target.value === "fit" ? "fit" : Number(l.target.value))
1424
+ }, [
1425
+ s[10] || (s[10] = y("option", { value: "fit" }, "Fit width", -1)),
1426
+ (a(), u(P, null, T(i, (l) => y("option", {
1427
+ key: l,
1428
+ value: l
1429
+ }, w(Math.round(l * 100)) + "%", 9, zo)), 64))
1430
+ ], 40, No)
1431
+ ])) : R("", !0),
1432
+ g(n) ? (a(), u("label", To, [
1433
+ ne(y("input", {
1434
+ "onUpdate:modelValue": s[4] || (s[4] = (l) => g(n).showOutlines.value = l),
1435
+ type: "checkbox"
1436
+ }, null, 512), [
1437
+ [tt, g(n).showOutlines.value]
1438
+ ]),
1439
+ s[12] || (s[12] = y("span", null, "Outlines", -1))
1440
+ ])) : R("", !0)
1291
1441
  ]));
1292
1442
  }
1293
- }), oo = /* @__PURE__ */ x(no, [["__scopeId", "data-v-39a2b54f"]]), ro = { class: "brick-canvas" }, V = 0.75, lo = /* @__PURE__ */ _({
1443
+ }), Lo = /* @__PURE__ */ $(Ro, [["__scopeId", "data-v-6def1a4b"]]), Do = { class: "brick-canvas" }, Ne = 96 / 72, Bo = 24, Mo = /* @__PURE__ */ S({
1294
1444
  __name: "DesignCanvas",
1295
1445
  setup(e) {
1296
- const t = ne(), n = W(), i = {
1446
+ const t = G(), n = Q(), i = B(le, null), f = {
1297
1447
  A3: [841.89, 1190.55],
1298
1448
  A4: [595.28, 841.89],
1299
1449
  A5: [419.53, 595.28],
1300
1450
  LETTER: [612, 792],
1301
1451
  LEGAL: [612, 1008]
1302
- }, s = I(() => {
1303
- const [p, d] = i[t.document.pageSize] ?? i.A4, r = t.document.pageOrientation === "landscape" ? d : p;
1304
- return Math.round(r * V);
1305
- }), o = I(() => {
1306
- const [p, d] = i[t.document.pageSize] ?? i.A4, r = t.document.pageOrientation === "landscape" ? p : d;
1307
- return Math.round(r * V);
1452
+ }, d = x(() => {
1453
+ const [r, c] = f[t.document.pageSize] ?? f.A4;
1454
+ return t.document.pageOrientation === "landscape" ? [c, r] : [r, c];
1455
+ }), m = E(null), { width: p } = lt(m), s = x(() => {
1456
+ const r = i?.zoom.value ?? "fit";
1457
+ if (r !== "fit") return r * Ne;
1458
+ const c = p.value - Bo * 2;
1459
+ return c <= 0 ? 0.75 : Math.min(Math.max(c / d.value[0], 0.5), 2 * Ne);
1460
+ });
1461
+ nt(() => {
1462
+ i && (i.pxPerPt.value = s.value);
1463
+ });
1464
+ const l = x(() => {
1465
+ const r = s.value, [c, v] = d.value, [b, k, C, _] = t.document.pageMargins, I = t.document.defaultStyle?.fontSize;
1466
+ return {
1467
+ "--brick-pt": r + "px",
1468
+ width: c * r + "px",
1469
+ minHeight: v * r + "px",
1470
+ paddingTop: k * r + "px",
1471
+ paddingRight: C * r + "px",
1472
+ paddingBottom: _ * r + "px",
1473
+ paddingLeft: b * r + "px",
1474
+ fontSize: (I ?? 12) * r + "px"
1475
+ };
1308
1476
  });
1309
- function y(p) {
1310
- (p.target === p.currentTarget || p.target.classList.contains("brick-canvas__page")) && n.deselect();
1477
+ function o(r) {
1478
+ (r.target === r.currentTarget || r.target.classList.contains("brick-canvas__page")) && n.deselect();
1311
1479
  }
1312
- return (p, d) => (a(), c("div", ro, [
1313
- B(oo),
1314
- m("div", {
1480
+ return (r, c) => (a(), u("div", Do, [
1481
+ j(Lo),
1482
+ y("div", {
1483
+ ref_key: "scrollEl",
1484
+ ref: m,
1315
1485
  class: "brick-canvas__scroll",
1316
- onClick: y
1486
+ onClick: o,
1487
+ onMouseover: c[0] || (c[0] = (v) => g(i) && (g(i).hoveredId.value = null))
1317
1488
  }, [
1318
- m("div", {
1489
+ y("div", {
1319
1490
  class: "brick-canvas__page",
1320
- style: N({
1321
- width: s.value + "px",
1322
- minHeight: o.value + "px",
1323
- paddingTop: k(t).document.pageMargins[1] * V + "px",
1324
- paddingRight: k(t).document.pageMargins[2] * V + "px",
1325
- paddingBottom: k(t).document.pageMargins[3] * V + "px",
1326
- paddingLeft: k(t).document.pageMargins[0] * V + "px"
1327
- })
1491
+ style: L(l.value)
1328
1492
  }, [
1329
- B($e, { "parent-id": null }, {
1330
- default: Y(() => [
1331
- (a(!0), c(C, null, P(k(t).document.content, (r, l) => (a(), M(jn, {
1332
- key: r.id,
1333
- node: r,
1334
- path: [l]
1493
+ j(qe, {
1494
+ "parent-id": null,
1495
+ empty: g(t).document.content.length === 0
1496
+ }, {
1497
+ default: se(() => [
1498
+ (a(!0), u(P, null, T(g(t).document.content, (v, b) => (a(), H(ho, {
1499
+ key: v.id,
1500
+ node: v,
1501
+ path: [b]
1335
1502
  }, null, 8, ["node", "path"]))), 128))
1336
1503
  ]),
1337
1504
  _: 1
1338
- })
1505
+ }, 8, ["empty"])
1339
1506
  ], 4)
1340
- ])
1507
+ ], 544)
1341
1508
  ]));
1342
1509
  }
1343
- }), io = /* @__PURE__ */ x(lo, [["__scopeId", "data-v-364329ec"]]), so = ["data-element-type"], ao = { class: "brick-element-list__icon" }, co = { class: "brick-element-list__label" }, uo = /* @__PURE__ */ _({
1510
+ }), Oo = /* @__PURE__ */ $(Mo, [["__scopeId", "data-v-6498bac5"]]), Ao = ["data-element-type"], Vo = { class: "brick-element-list__icon" }, Ho = { class: "brick-element-list__label" }, Fo = /* @__PURE__ */ S({
1344
1511
  __name: "ToolbarElementList",
1345
1512
  setup(e) {
1346
1513
  const t = E(null);
1347
1514
  let n = null;
1348
- const i = xe(), s = Me();
1349
- return ye(() => {
1515
+ const i = ge(), f = st();
1516
+ return Te(() => {
1350
1517
  t.value && (n = i.initToolbar(t.value));
1351
- }), me(() => {
1518
+ }), Re(() => {
1352
1519
  n?.destroy();
1353
- }), (o, y) => (a(), c("div", {
1520
+ }), (d, m) => (a(), u("div", {
1354
1521
  ref_key: "el",
1355
1522
  ref: t,
1356
1523
  class: "brick-element-list"
1357
1524
  }, [
1358
- (a(!0), c(C, null, P(k(s), (p) => (a(), c("div", {
1525
+ (a(!0), u(P, null, T(g(f), (p) => (a(), u("div", {
1359
1526
  key: p.type,
1360
1527
  class: "brick-element-list__item",
1361
1528
  "data-element-type": p.type
1362
1529
  }, [
1363
- m("span", ao, w(p.icon), 1),
1364
- m("span", co, w(p.label), 1)
1365
- ], 8, so))), 128))
1530
+ y("span", Vo, w(p.icon), 1),
1531
+ y("span", Ho, w(p.label), 1)
1532
+ ], 8, Ao))), 128))
1366
1533
  ], 512));
1367
1534
  }
1368
- }), po = /* @__PURE__ */ x(uo, [["__scopeId", "data-v-2d0b1dbf"]]), fo = { class: "brick-field" }, yo = { class: "brick-field__label" }, mo = ["value"], go = ["value"], bo = ["value", "min", "max", "step"], ho = ["value"], vo = ["value"], _o = ["value"], ko = {
1535
+ }), Uo = /* @__PURE__ */ $(Fo, [["__scopeId", "data-v-2d0b1dbf"]]), Jo = { class: "brick-field" }, Wo = { class: "brick-field__label" }, jo = ["value"], Yo = ["value"], qo = ["value", "min", "max", "step"], Ko = ["value"], Xo = ["value"], Go = ["value"], Qo = {
1369
1536
  key: 5,
1370
1537
  class: "brick-field__toggle"
1371
- }, So = ["checked"], xo = {
1538
+ }, Zo = ["checked"], er = {
1372
1539
  key: 6,
1373
1540
  class: "brick-field__margin"
1374
- }, Co = ["placeholder", "value", "onInput"], wo = {
1541
+ }, tr = ["placeholder", "value", "onInput"], nr = {
1375
1542
  key: 7,
1376
1543
  class: "brick-field__slider"
1377
- }, Po = ["value", "min", "max", "step"], Eo = { class: "brick-field__slider-value" }, Io = /* @__PURE__ */ _({
1544
+ }, or = ["value", "min", "max", "step"], rr = { class: "brick-field__slider-value" }, lr = ["accept"], ir = /* @__PURE__ */ S({
1378
1545
  __name: "PropertyField",
1379
1546
  props: {
1380
1547
  descriptor: {},
1381
1548
  node: {}
1382
1549
  },
1383
1550
  setup(e) {
1384
- const t = e, n = j(), i = I(() => {
1385
- const d = t.descriptor.key.split("."), r = d[0], l = d[1];
1386
- if (r === "props")
1387
- return t.node.props[l];
1388
- if (r === "style")
1389
- return t.node.style[l];
1390
- }), s = I(() => {
1391
- const d = i.value;
1392
- return t.descriptor.type === "textarea" && Array.isArray(d) ? d.join(`
1393
- `) : d;
1551
+ const t = e, n = re(), i = x(() => {
1552
+ const l = t.descriptor.key.split("."), o = l[0], r = l[1];
1553
+ if (o === "props")
1554
+ return t.node.props[r];
1555
+ if (o === "style")
1556
+ return t.node.style[r];
1557
+ }), f = x(() => {
1558
+ const l = i.value;
1559
+ return t.descriptor.type === "textarea" && Array.isArray(l) ? l.join(`
1560
+ `) : l;
1394
1561
  });
1395
- function o(d) {
1396
- const r = t.descriptor.key.split("."), l = r[0], u = r[1];
1397
- let g = d;
1398
- t.descriptor.type === "textarea" && Array.isArray(i.value) && (g = d.split(`
1399
- `)), l === "props" ? n.updateProps(t.node.id, { [u]: g }) : l === "style" && n.updateStyle(t.node.id, { [u]: g });
1562
+ function d(l) {
1563
+ const o = t.descriptor.key.split("."), r = o[0], c = o[1];
1564
+ let v = l;
1565
+ t.descriptor.type === "textarea" && Array.isArray(i.value) && (v = l.split(`
1566
+ `)), r === "props" ? n.updateProps(t.node.id, { [c]: v }) : r === "style" && n.updateStyle(t.node.id, { [c]: v });
1567
+ }
1568
+ function m(l) {
1569
+ const o = l.target.value;
1570
+ o.trim() === "" || Number.isNaN(Number(o)) || d(Number(o));
1400
1571
  }
1401
- function y(d, r) {
1402
- const u = [...s.value ?? [0, 0, 0, 0]];
1403
- u[d] = r, o(u);
1572
+ function p(l, o) {
1573
+ const c = [...f.value ?? [0, 0, 0, 0]];
1574
+ c[l] = o, d(c);
1404
1575
  }
1405
- function p(d) {
1406
- const l = d.target.files?.[0];
1407
- if (!l) return;
1408
- const u = new FileReader();
1409
- u.onload = () => {
1410
- o(u.result);
1411
- }, u.readAsDataURL(l);
1576
+ function s(l) {
1577
+ const r = l.target.files?.[0];
1578
+ if (!r) return;
1579
+ const c = new FileReader();
1580
+ c.onload = () => {
1581
+ d(c.result);
1582
+ }, c.readAsDataURL(r);
1412
1583
  }
1413
- return (d, r) => (a(), c("div", fo, [
1414
- m("label", yo, w(e.descriptor.label), 1),
1415
- e.descriptor.type === "text" ? (a(), c("input", {
1584
+ return (l, o) => (a(), u("div", Jo, [
1585
+ y("label", Wo, w(e.descriptor.label), 1),
1586
+ e.descriptor.type === "text" ? (a(), u("input", {
1416
1587
  key: 0,
1417
1588
  type: "text",
1418
1589
  class: "brick-field__input",
1419
- value: s.value,
1420
- onInput: r[0] || (r[0] = (l) => o(l.target.value))
1421
- }, null, 40, mo)) : e.descriptor.type === "textarea" ? (a(), c("textarea", {
1590
+ value: f.value,
1591
+ onInput: o[0] || (o[0] = (r) => d(r.target.value))
1592
+ }, null, 40, jo)) : e.descriptor.type === "textarea" ? (a(), u("textarea", {
1422
1593
  key: 1,
1423
1594
  class: "brick-field__textarea",
1424
- value: s.value,
1595
+ value: f.value,
1425
1596
  rows: "3",
1426
- onInput: r[1] || (r[1] = (l) => o(l.target.value))
1427
- }, null, 40, go)) : e.descriptor.type === "number" ? (a(), c("input", {
1597
+ onInput: o[1] || (o[1] = (r) => d(r.target.value))
1598
+ }, null, 40, Yo)) : e.descriptor.type === "number" ? (a(), u("input", {
1428
1599
  key: 2,
1429
1600
  type: "number",
1430
1601
  class: "brick-field__input",
1431
- value: s.value,
1602
+ value: f.value,
1432
1603
  min: e.descriptor.min,
1433
1604
  max: e.descriptor.max,
1434
1605
  step: e.descriptor.step,
1435
- onInput: r[2] || (r[2] = (l) => o(Number(l.target.value)))
1436
- }, null, 40, bo)) : e.descriptor.type === "color" ? (a(), c("input", {
1606
+ onInput: m
1607
+ }, null, 40, qo)) : e.descriptor.type === "color" ? (a(), u("input", {
1437
1608
  key: 3,
1438
1609
  type: "color",
1439
1610
  class: "brick-field__color",
1440
- value: s.value ?? "#000000",
1441
- onInput: r[3] || (r[3] = (l) => o(l.target.value))
1442
- }, null, 40, ho)) : e.descriptor.type === "select" ? (a(), c("select", {
1611
+ value: f.value ?? "#000000",
1612
+ onInput: o[2] || (o[2] = (r) => d(r.target.value))
1613
+ }, null, 40, Ko)) : e.descriptor.type === "select" ? (a(), u("select", {
1443
1614
  key: 4,
1444
1615
  class: "brick-field__select",
1445
- value: s.value,
1446
- onChange: r[4] || (r[4] = (l) => o(l.target.value || void 0))
1616
+ value: f.value,
1617
+ onChange: o[3] || (o[3] = (r) => d(r.target.value || void 0))
1447
1618
  }, [
1448
- (a(!0), c(C, null, P(e.descriptor.options, (l) => (a(), c("option", {
1449
- key: String(l.value),
1450
- value: l.value
1451
- }, w(l.label), 9, _o))), 128))
1452
- ], 40, vo)) : e.descriptor.type === "toggle" ? (a(), c("label", ko, [
1453
- m("input", {
1619
+ (a(!0), u(P, null, T(e.descriptor.options, (r) => (a(), u("option", {
1620
+ key: String(r.value),
1621
+ value: r.value
1622
+ }, w(r.label), 9, Go))), 128))
1623
+ ], 40, Xo)) : e.descriptor.type === "toggle" ? (a(), u("label", Qo, [
1624
+ y("input", {
1454
1625
  type: "checkbox",
1455
- checked: s.value,
1456
- onChange: r[5] || (r[5] = (l) => o(l.target.checked))
1457
- }, null, 40, So),
1458
- m("span", null, w(s.value ? "On" : "Off"), 1)
1459
- ])) : e.descriptor.type === "margin" ? (a(), c("div", xo, [
1460
- (a(), c(C, null, P(["L", "T", "R", "B"], (l, u) => m("input", {
1461
- key: l,
1626
+ checked: f.value,
1627
+ onChange: o[4] || (o[4] = (r) => d(r.target.checked))
1628
+ }, null, 40, Zo),
1629
+ y("span", null, w(f.value ? "On" : "Off"), 1)
1630
+ ])) : e.descriptor.type === "margin" ? (a(), u("div", er, [
1631
+ (a(), u(P, null, T(["L", "T", "R", "B"], (r, c) => y("input", {
1632
+ key: r,
1462
1633
  type: "number",
1463
1634
  class: "brick-field__margin-input",
1464
- placeholder: l,
1465
- value: (s.value ?? [0, 0, 0, 0])[u],
1466
- onInput: (g) => y(u, Number(g.target.value))
1467
- }, null, 40, Co)), 64))
1468
- ])) : e.descriptor.type === "slider" ? (a(), c("div", wo, [
1469
- m("input", {
1635
+ placeholder: r,
1636
+ value: (f.value ?? [0, 0, 0, 0])[c],
1637
+ onInput: (v) => p(c, Number(v.target.value))
1638
+ }, null, 40, tr)), 64))
1639
+ ])) : e.descriptor.type === "slider" ? (a(), u("div", nr, [
1640
+ y("input", {
1470
1641
  type: "range",
1471
- value: s.value,
1642
+ value: f.value,
1472
1643
  min: e.descriptor.min,
1473
1644
  max: e.descriptor.max,
1474
1645
  step: e.descriptor.step,
1475
- onInput: r[6] || (r[6] = (l) => o(Number(l.target.value)))
1476
- }, null, 40, Po),
1477
- m("span", Eo, w(s.value), 1)
1478
- ])) : e.descriptor.type === "file" ? (a(), c("input", {
1646
+ onInput: o[5] || (o[5] = (r) => d(Number(r.target.value)))
1647
+ }, null, 40, or),
1648
+ y("span", rr, w(f.value), 1)
1649
+ ])) : e.descriptor.type === "file" ? (a(), u("input", {
1479
1650
  key: 8,
1480
1651
  type: "file",
1481
- accept: "image/*",
1652
+ accept: e.descriptor.accept ?? "image/*",
1482
1653
  class: "brick-field__file",
1483
- onChange: p
1484
- }, null, 32)) : $("", !0)
1654
+ onChange: s
1655
+ }, null, 40, lr)) : R("", !0)
1485
1656
  ]));
1486
1657
  }
1487
- }), $o = /* @__PURE__ */ x(Io, [["__scopeId", "data-v-5a3bec1b"]]), Ro = {
1658
+ }), sr = /* @__PURE__ */ $(ir, [["__scopeId", "data-v-e439d522"]]), ar = {
1488
1659
  key: 0,
1489
1660
  class: "brick-property-editor"
1490
- }, No = { class: "brick-property-editor__type" }, zo = { class: "brick-property-editor__key" }, To = ["value"], Lo = {
1661
+ }, cr = {
1662
+ key: 0,
1663
+ class: "brick-property-editor__crumbs",
1664
+ "aria-label": "Element path"
1665
+ }, ur = ["onClick"], dr = { class: "brick-property-editor__type" }, pr = { class: "brick-property-editor__key" }, fr = ["value"], yr = {
1491
1666
  key: 0,
1492
1667
  class: "brick-property-editor__group"
1493
- }, Do = { class: "brick-property-editor__group-title" }, Mo = /* @__PURE__ */ _({
1668
+ }, mr = { class: "brick-property-editor__group-title" }, vr = /* @__PURE__ */ S({
1494
1669
  __name: "PropertyEditor",
1495
1670
  setup(e) {
1496
- const t = W(), n = j();
1497
- function i(d) {
1671
+ const t = Q(), n = re(), i = G(), f = x(() => {
1672
+ const o = t.selectedId.value;
1673
+ return o ? ce(i.document.content, o) ?? [] : [];
1674
+ });
1675
+ function d(o) {
1498
1676
  const r = t.selectedNode.value;
1499
- r && n.updateKey(r.id, d.target.value);
1677
+ r && n.updateKey(r.id, o.target.value);
1500
1678
  }
1501
- const s = I(() => {
1502
- const d = t.selectedNode.value;
1503
- return d ? U(d.type) : null;
1504
- }), o = I(() => {
1505
- if (!s.value) return {};
1506
- const d = {};
1507
- for (const r of s.value.propertyFields)
1508
- d[r.section] || (d[r.section] = []), d[r.section].push(r);
1509
- return d;
1510
- }), y = {
1679
+ const m = x(() => {
1680
+ const o = t.selectedNode.value;
1681
+ return o ? W(o.type) : null;
1682
+ }), p = x(() => {
1683
+ if (!m.value) return {};
1684
+ const o = {};
1685
+ for (const r of m.value.propertyFields)
1686
+ o[r.section] || (o[r.section] = []), o[r.section].push(r);
1687
+ return o;
1688
+ }), s = {
1511
1689
  content: "Content",
1512
1690
  style: "Style",
1513
1691
  layout: "Layout",
1514
1692
  advanced: "Advanced"
1515
- }, p = ["content", "style", "layout", "advanced"];
1516
- return (d, r) => k(t).selectedNode.value && s.value ? (a(), c("div", Ro, [
1517
- m("div", No, w(s.value.icon) + " " + w(s.value.label), 1),
1518
- m("div", zo, [
1519
- r[0] || (r[0] = m("label", { class: "brick-property-editor__key-label" }, "Key", -1)),
1520
- m("input", {
1693
+ }, l = ["content", "style", "layout", "advanced"];
1694
+ return (o, r) => g(t).selectedNode.value && m.value ? (a(), u("div", ar, [
1695
+ f.value.length ? (a(), u("nav", cr, [
1696
+ (a(!0), u(P, null, T(f.value, (c) => (a(), u(P, {
1697
+ key: c.id
1698
+ }, [
1699
+ y("button", {
1700
+ type: "button",
1701
+ class: "brick-property-editor__crumb",
1702
+ onClick: (v) => g(t).select(c.id)
1703
+ }, w(g(W)(c.type)?.label ?? c.type), 9, ur),
1704
+ r[0] || (r[0] = y("span", { class: "brick-property-editor__crumb-sep" }, "›", -1))
1705
+ ], 64))), 128))
1706
+ ])) : R("", !0),
1707
+ y("div", dr, w(m.value.icon) + " " + w(m.value.label), 1),
1708
+ y("div", pr, [
1709
+ r[1] || (r[1] = y("label", { class: "brick-property-editor__key-label" }, "Key", -1)),
1710
+ y("input", {
1521
1711
  type: "text",
1522
1712
  class: "brick-property-editor__key-input",
1523
- value: k(t).selectedNode.value.key ?? "",
1713
+ value: g(t).selectedNode.value.key ?? "",
1524
1714
  placeholder: "(optional identifier)",
1525
- onInput: i
1526
- }, null, 40, To)
1715
+ onInput: d
1716
+ }, null, 40, fr)
1527
1717
  ]),
1528
- (a(), c(C, null, P(p, (l) => (a(), c(C, { key: l }, [
1529
- o.value[l] ? (a(), c("div", Lo, [
1530
- m("div", Do, w(y[l]), 1),
1531
- (a(!0), c(C, null, P(o.value[l], (u) => (a(), M($o, {
1532
- key: u.key,
1533
- descriptor: u,
1534
- node: k(t).selectedNode.value
1718
+ (a(), u(P, null, T(l, (c) => (a(), u(P, { key: c }, [
1719
+ p.value[c] ? (a(), u("div", yr, [
1720
+ y("div", mr, w(s[c]), 1),
1721
+ (a(!0), u(P, null, T(p.value[c], (v) => (a(), H(sr, {
1722
+ key: v.key,
1723
+ descriptor: v,
1724
+ node: g(t).selectedNode.value
1535
1725
  }, null, 8, ["descriptor", "node"]))), 128))
1536
- ])) : $("", !0)
1726
+ ])) : R("", !0)
1537
1727
  ], 64))), 64)),
1538
- (a(), M(ee(s.value.propertyEditorComponent), {
1539
- node: k(t).selectedNode.value
1728
+ (a(), H(ve(m.value.propertyEditorComponent), {
1729
+ node: g(t).selectedNode.value
1540
1730
  }, null, 8, ["node"]))
1541
- ])) : $("", !0);
1731
+ ])) : R("", !0);
1732
+ }
1733
+ }), br = /* @__PURE__ */ $(vr, [["__scopeId", "data-v-6170de2b"]]), gr = { class: "brick-layers" }, hr = ["data-layer-id", "onClick", "onMouseenter"], _r = ["onClick"], kr = {
1734
+ key: 1,
1735
+ class: "brick-layers__caret-spacer"
1736
+ }, Sr = { class: "brick-layers__icon" }, xr = { class: "brick-layers__type" }, Cr = { class: "brick-layers__summary" }, wr = /* @__PURE__ */ S({
1737
+ name: "LayerTree",
1738
+ __name: "LayerTree",
1739
+ props: {
1740
+ nodes: {},
1741
+ depth: {}
1742
+ },
1743
+ setup(e) {
1744
+ const t = Q(), n = B(le, null), i = ze(/* @__PURE__ */ new Set());
1745
+ function f(p) {
1746
+ if (p.key) return p.key;
1747
+ const s = p.props.text;
1748
+ return typeof s == "string" && s.trim() ? s.trim().split(`
1749
+ `)[0] : "";
1750
+ }
1751
+ function d(p, s) {
1752
+ t.select(p.id), s.currentTarget.closest(".brick-pdf")?.querySelector(`.brick-canvas [data-element-id="${p.id}"]`)?.scrollIntoView({ block: "nearest", behavior: "smooth" });
1753
+ }
1754
+ function m(p) {
1755
+ i.has(p) ? i.delete(p) : i.add(p);
1756
+ }
1757
+ return (p, s) => {
1758
+ const l = Le("LayerTree", !0);
1759
+ return a(), u("ul", gr, [
1760
+ (a(!0), u(P, null, T(e.nodes, (o) => (a(), u("li", {
1761
+ key: o.id
1762
+ }, [
1763
+ y("div", {
1764
+ class: Y(["brick-layers__row", {
1765
+ "brick-layers__row--selected": g(t).selectedId.value === o.id,
1766
+ "brick-layers__row--hovered": g(n)?.hoveredId.value === o.id
1767
+ }]),
1768
+ "data-layer-id": o.id,
1769
+ style: L({ paddingLeft: 4 + (e.depth ?? 0) * 14 + "px" }),
1770
+ onClick: (r) => d(o, r),
1771
+ onMouseenter: (r) => g(n) && (g(n).hoveredId.value = o.id),
1772
+ onMouseleave: s[0] || (s[0] = (r) => g(n) && (g(n).hoveredId.value = null))
1773
+ }, [
1774
+ o.children.length ? (a(), u("button", {
1775
+ key: 0,
1776
+ type: "button",
1777
+ class: Y(["brick-layers__caret", { "brick-layers__caret--collapsed": i.has(o.id) }]),
1778
+ onClick: fe((r) => m(o.id), ["stop"])
1779
+ }, "▾", 10, _r)) : (a(), u("span", kr)),
1780
+ y("span", Sr, w(g(W)(o.type)?.icon ?? "?"), 1),
1781
+ y("span", xr, w(g(W)(o.type)?.label ?? o.type), 1),
1782
+ y("span", Cr, w(f(o)), 1)
1783
+ ], 46, hr),
1784
+ o.children.length && !i.has(o.id) ? (a(), H(l, {
1785
+ key: 0,
1786
+ nodes: o.children,
1787
+ depth: (e.depth ?? 0) + 1
1788
+ }, null, 8, ["nodes", "depth"])) : R("", !0)
1789
+ ]))), 128))
1790
+ ]);
1791
+ };
1542
1792
  }
1543
- }), Bo = /* @__PURE__ */ x(Mo, [["__scopeId", "data-v-e49ddc4f"]]), Oo = { class: "brick-toolbar" }, Ao = { class: "brick-toolbar__section" }, Vo = {
1793
+ }), Pr = /* @__PURE__ */ $(wr, [["__scopeId", "data-v-a3d66c12"]]), Er = { class: "brick-toolbar" }, $r = { class: "brick-toolbar__section" }, Ir = {
1794
+ class: "brick-toolbar__tabs",
1795
+ role: "tablist"
1796
+ }, Nr = ["aria-selected"], zr = ["aria-selected"], Tr = {
1797
+ key: 1,
1798
+ class: "brick-toolbar__empty"
1799
+ }, Rr = {
1544
1800
  key: 0,
1545
1801
  class: "brick-toolbar__section"
1546
- }, Fo = /* @__PURE__ */ _({
1802
+ }, Lr = /* @__PURE__ */ S({
1547
1803
  __name: "Toolbar",
1548
1804
  setup(e) {
1549
- const t = W();
1550
- return (n, i) => (a(), c("div", Oo, [
1551
- m("div", Ao, [
1552
- i[0] || (i[0] = m("h3", { class: "brick-toolbar__title" }, "Elements", -1)),
1553
- B(po)
1805
+ const t = Q(), n = G(), i = E("elements"), f = E(null);
1806
+ return De([() => t.selectedId.value, i], async ([d]) => {
1807
+ !d || i.value !== "layers" || (await ot(), f.value?.querySelector(`[data-layer-id="${d}"]`)?.scrollIntoView({ block: "nearest" }));
1808
+ }), (d, m) => (a(), u("div", Er, [
1809
+ y("div", $r, [
1810
+ y("div", Ir, [
1811
+ y("button", {
1812
+ type: "button",
1813
+ role: "tab",
1814
+ class: Y(["brick-toolbar__tab", { "brick-toolbar__tab--active": i.value === "elements" }]),
1815
+ "aria-selected": i.value === "elements",
1816
+ onClick: m[0] || (m[0] = (p) => i.value = "elements")
1817
+ }, "Elements", 10, Nr),
1818
+ y("button", {
1819
+ type: "button",
1820
+ role: "tab",
1821
+ class: Y(["brick-toolbar__tab", { "brick-toolbar__tab--active": i.value === "layers" }]),
1822
+ "aria-selected": i.value === "layers",
1823
+ onClick: m[1] || (m[1] = (p) => i.value = "layers")
1824
+ }, "Layers", 10, zr)
1825
+ ]),
1826
+ ne(j(Uo, null, null, 512), [
1827
+ [xe, i.value === "elements"]
1828
+ ]),
1829
+ ne(y("div", {
1830
+ ref_key: "layersEl",
1831
+ ref: f,
1832
+ class: "brick-toolbar__layers"
1833
+ }, [
1834
+ g(n).document.content.length ? (a(), H(Pr, {
1835
+ key: 0,
1836
+ nodes: g(n).document.content
1837
+ }, null, 8, ["nodes"])) : (a(), u("p", Tr, "No elements yet."))
1838
+ ], 512), [
1839
+ [xe, i.value === "layers"]
1840
+ ])
1554
1841
  ]),
1555
- k(t).selectedNode.value ? (a(), c("div", Vo, [
1556
- i[1] || (i[1] = m("h3", { class: "brick-toolbar__title" }, "Properties", -1)),
1557
- B(Bo)
1558
- ])) : $("", !0)
1842
+ g(t).selectedNode.value ? (a(), u("div", Rr, [
1843
+ m[2] || (m[2] = y("h3", { class: "brick-toolbar__title" }, "Properties", -1)),
1844
+ j(br)
1845
+ ])) : R("", !0)
1559
1846
  ]));
1560
1847
  }
1561
- }), Ho = /* @__PURE__ */ x(Fo, [["__scopeId", "data-v-0174c069"]]), Jo = { class: "brick-actionbar" }, Uo = { class: "brick-actionbar__group" }, Wo = ["disabled"], jo = ["disabled"], Yo = ["disabled"], qo = { class: "brick-actionbar__group" }, Ko = /* @__PURE__ */ _({
1848
+ }), Dr = /* @__PURE__ */ $(Lr, [["__scopeId", "data-v-06ce3a81"]]), Br = { class: "brick-actionbar" }, Mr = { class: "brick-actionbar__group" }, Or = ["disabled"], Ar = ["disabled"], Vr = ["disabled"], Hr = { class: "brick-actionbar__group" }, Fr = /* @__PURE__ */ S({
1562
1849
  __name: "ActionBar",
1563
1850
  setup(e) {
1564
- const t = St(), n = Nt(), i = W(), s = j(), o = ne(), y = E("document"), p = E(null);
1565
- function d() {
1566
- const f = i.selectedId.value;
1567
- f && (i.deselect(), s.removeElement(f));
1851
+ const t = qt(), n = on(), i = Q(), f = re(), d = G(), m = E("document"), p = E(null);
1852
+ function s() {
1853
+ const v = i.selectedId.value;
1854
+ v && (i.deselect(), f.removeElement(v));
1568
1855
  }
1569
- function r() {
1570
- const f = y.value.trim() || "document", b = f.endsWith(".pdf") ? f : f + ".pdf";
1856
+ function l() {
1857
+ const v = m.value.trim() || "document", b = v.endsWith(".pdf") ? v : v + ".pdf";
1571
1858
  n.exportPdf(b);
1572
1859
  }
1573
- function l() {
1574
- const f = o.exportDocument(), b = JSON.stringify(f, null, 2), h = new Blob([b], { type: "application/json" }), v = URL.createObjectURL(h), S = document.createElement("a"), R = y.value.trim() || "document";
1575
- S.href = v, S.download = R.endsWith(".json") ? R : R + ".json", S.click(), URL.revokeObjectURL(v);
1860
+ function o() {
1861
+ const v = d.exportDocument(), b = JSON.stringify(v, null, 2), k = new Blob([b], { type: "application/json" }), C = URL.createObjectURL(k), _ = document.createElement("a"), I = m.value.trim() || "document";
1862
+ _.href = C, _.download = I.endsWith(".json") ? I : I + ".json", _.click(), URL.revokeObjectURL(C);
1576
1863
  }
1577
- function u() {
1864
+ function r() {
1578
1865
  p.value?.click();
1579
1866
  }
1580
- function g(f) {
1581
- const b = f.target, h = b.files?.[0];
1582
- if (!h) return;
1583
- const v = new FileReader();
1584
- v.onload = () => {
1867
+ function c(v) {
1868
+ const b = v.target, k = b.files?.[0];
1869
+ if (!k) return;
1870
+ const C = new FileReader();
1871
+ C.onload = () => {
1585
1872
  try {
1586
- const S = JSON.parse(v.result);
1587
- if (!S.content || !S.pageSize) {
1873
+ const _ = JSON.parse(C.result);
1874
+ if (!_.content || !_.pageSize) {
1588
1875
  alert("Invalid brick-pdf JSON file.");
1589
1876
  return;
1590
1877
  }
1591
- i.deselect(), o.loadDocument(S);
1878
+ i.deselect(), d.loadDocument(_);
1592
1879
  } catch {
1593
1880
  alert("Failed to parse JSON file.");
1594
1881
  }
1595
- }, v.readAsText(h), b.value = "";
1882
+ }, C.readAsText(k), b.value = "";
1596
1883
  }
1597
- return (f, b) => (a(), c("div", Jo, [
1598
- m("div", Uo, [
1599
- m("button", {
1884
+ return (v, b) => (a(), u("div", Br, [
1885
+ y("div", Mr, [
1886
+ y("button", {
1600
1887
  class: "brick-actionbar__btn",
1601
- disabled: !k(t).canUndo.value,
1888
+ disabled: !g(t).canUndo.value,
1602
1889
  title: "Undo",
1603
- onClick: b[0] || (b[0] = (h) => k(t).undo())
1604
- }, " Undo ", 8, Wo),
1605
- m("button", {
1890
+ onClick: b[0] || (b[0] = (k) => g(t).undo())
1891
+ }, " Undo ", 8, Or),
1892
+ y("button", {
1606
1893
  class: "brick-actionbar__btn",
1607
- disabled: !k(t).canRedo.value,
1894
+ disabled: !g(t).canRedo.value,
1608
1895
  title: "Redo",
1609
- onClick: b[1] || (b[1] = (h) => k(t).redo())
1610
- }, " Redo ", 8, jo),
1611
- m("button", {
1896
+ onClick: b[1] || (b[1] = (k) => g(t).redo())
1897
+ }, " Redo ", 8, Ar),
1898
+ y("button", {
1612
1899
  class: "brick-actionbar__btn brick-actionbar__btn--danger",
1613
- disabled: !k(i).selectedId.value,
1900
+ disabled: !g(i).selectedId.value,
1614
1901
  title: "Delete selected element",
1615
- onClick: d
1616
- }, " Delete ", 8, Yo)
1902
+ onClick: s
1903
+ }, " Delete ", 8, Vr)
1617
1904
  ]),
1618
- m("div", qo, [
1619
- m("button", {
1905
+ y("div", Hr, [
1906
+ y("button", {
1620
1907
  class: "brick-actionbar__btn",
1621
1908
  title: "Import JSON",
1622
- onClick: u
1909
+ onClick: r
1623
1910
  }, " Import JSON "),
1624
- m("button", {
1911
+ y("button", {
1625
1912
  class: "brick-actionbar__btn",
1626
1913
  title: "Export JSON",
1627
- onClick: l
1914
+ onClick: o
1628
1915
  }, " Export JSON "),
1629
- m("button", {
1916
+ y("button", {
1630
1917
  class: "brick-actionbar__btn brick-actionbar__btn--primary",
1631
- onClick: r
1918
+ onClick: l
1632
1919
  }, " Export PDF "),
1633
- m("button", {
1920
+ y("button", {
1634
1921
  class: "brick-actionbar__btn",
1635
- onClick: b[2] || (b[2] = (h) => k(n).openPdf())
1922
+ onClick: b[2] || (b[2] = (k) => g(n).openPdf())
1636
1923
  }, " Preview ")
1637
1924
  ]),
1638
- m("input", {
1925
+ y("input", {
1639
1926
  ref_key: "fileInput",
1640
1927
  ref: p,
1641
1928
  type: "file",
1642
1929
  accept: ".json",
1643
1930
  style: { display: "none" },
1644
- onChange: g
1931
+ onChange: c
1645
1932
  }, null, 544)
1646
1933
  ]));
1647
1934
  }
1648
- }), Go = /* @__PURE__ */ x(Ko, [["__scopeId", "data-v-586445a9"]]), Xo = { class: "brick-pdf" }, Qo = { class: "brick-pdf__workspace" }, Zo = /* @__PURE__ */ _({
1935
+ }), Ur = /* @__PURE__ */ $(Fr, [["__scopeId", "data-v-586445a9"]]), Jr = { class: "brick-pdf__workspace" }, Wr = /* @__PURE__ */ S({
1649
1936
  __name: "BrickPdf",
1650
1937
  props: {
1651
1938
  modelValue: {}
@@ -1653,69 +1940,84 @@ const Fn = {
1653
1940
  emits: ["update:modelValue"],
1654
1941
  setup(e, { emit: t }) {
1655
1942
  const n = e, i = t;
1656
- Vn();
1657
- const s = pt(n.modelValue ?? te());
1658
- ft(s);
1659
- const o = yt(s);
1660
- mt(o);
1661
- const y = _t(s);
1662
- kt(y);
1663
- const p = bt(s, y);
1664
- ht(p);
1665
- const d = xt(s, p);
1666
- Ct(d);
1667
- const r = $t(s);
1668
- Rt(r);
1669
- const l = Lt(s, p);
1670
- Dt(l);
1671
- const u = Mt(p);
1672
- Bt(u);
1673
- const g = De(), f = g.Delete, b = g.Backspace;
1674
- return ae(f, () => {
1675
- if (!o.selectedId.value) return;
1676
- const h = document.activeElement;
1677
- if (h && (h.tagName === "INPUT" || h.tagName === "TEXTAREA" || h.tagName === "SELECT")) return;
1678
- const v = o.selectedId.value;
1679
- o.deselect(), p.removeElement(v);
1680
- }), ae(b, () => {
1681
- if (!o.selectedId.value) return;
1682
- const h = document.activeElement;
1683
- if (h && (h.tagName === "INPUT" || h.tagName === "TEXTAREA" || h.tagName === "SELECT")) return;
1684
- const v = o.selectedId.value;
1685
- o.deselect(), p.removeElement(v);
1686
- }), Le(
1687
- () => s.document,
1943
+ fo();
1944
+ const f = Ot(n.modelValue ?? be());
1945
+ At(f);
1946
+ const d = Vt(f);
1947
+ Ht(d);
1948
+ const m = jt(f);
1949
+ Yt(m);
1950
+ const p = Ut(f, m);
1951
+ Jt(p);
1952
+ const s = Kt(f, p);
1953
+ Xt(s);
1954
+ const l = tn(f);
1955
+ nn(l);
1956
+ const o = sn(f, p);
1957
+ an(o);
1958
+ const r = cn(p);
1959
+ un(r);
1960
+ const c = E(null);
1961
+ F(le, { hoveredId: c, showOutlines: E(!1), zoom: E("fit"), pxPerPt: E(1) });
1962
+ function v(_) {
1963
+ const I = d.selectedId.value;
1964
+ if (!I) return;
1965
+ const O = _.target;
1966
+ if (O && (O.tagName === "INPUT" || O.tagName === "TEXTAREA" || O.tagName === "SELECT")) return;
1967
+ const ie = ce(f.document.content, I), Z = ie?.[ie.length - 1];
1968
+ Z ? d.select(Z.id) : d.deselect();
1969
+ }
1970
+ const b = it(), k = b.Delete, C = b.Backspace;
1971
+ return Ce(k, () => {
1972
+ if (!d.selectedId.value) return;
1973
+ const _ = document.activeElement;
1974
+ if (_ && (_.tagName === "INPUT" || _.tagName === "TEXTAREA" || _.tagName === "SELECT" || _.isContentEditable)) return;
1975
+ const I = d.selectedId.value;
1976
+ d.deselect(), p.removeElement(I);
1977
+ }), Ce(C, () => {
1978
+ if (!d.selectedId.value) return;
1979
+ const _ = document.activeElement;
1980
+ if (_ && (_.tagName === "INPUT" || _.tagName === "TEXTAREA" || _.tagName === "SELECT" || _.isContentEditable)) return;
1981
+ const I = d.selectedId.value;
1982
+ d.deselect(), p.removeElement(I);
1983
+ }), De(
1984
+ () => f.document,
1688
1985
  () => {
1689
- i("update:modelValue", JSON.parse(JSON.stringify(J(s.document))));
1986
+ i("update:modelValue", JSON.parse(JSON.stringify(oe(f.document))));
1690
1987
  },
1691
1988
  { deep: !0 }
1692
- ), (h, v) => (a(), c("div", Xo, [
1693
- B(Go),
1694
- m("div", Qo, [
1695
- B(io),
1696
- B(Ho)
1989
+ ), (_, I) => (a(), u("div", {
1990
+ class: "brick-pdf",
1991
+ tabindex: "-1",
1992
+ onKeydown: rt(v, ["esc"]),
1993
+ onMouseleave: I[0] || (I[0] = (O) => c.value = null)
1994
+ }, [
1995
+ j(Ur),
1996
+ y("div", Jr, [
1997
+ j(Oo),
1998
+ j(Dr)
1697
1999
  ])
1698
- ]));
2000
+ ], 32));
1699
2001
  }
1700
- }), er = /* @__PURE__ */ x(Zo, [["__scopeId", "data-v-f9b95ad8"]]), sr = {
2002
+ }), jr = /* @__PURE__ */ $(Wr, [["__scopeId", "data-v-51e3c556"]]), Zr = {
1701
2003
  install(e) {
1702
- e.component("BrickPdf", er);
2004
+ e.component("BrickPdf", jr);
1703
2005
  }
1704
2006
  };
1705
2007
  export {
1706
- er as BrickPdf,
1707
- te as createDefaultDocument,
1708
- sr as default,
1709
- Me as getAllElementDefinitions,
1710
- U as getElementDefinition,
1711
- z as registerElement,
1712
- rr as unregisterElement,
1713
- lr as useClipboard,
1714
- ne as useDocumentStore,
1715
- xe as useDragDrop,
1716
- j as useElementActions,
1717
- St as useHistory,
1718
- Nt as usePdfExport,
1719
- ir as useResize,
1720
- W as useSelection
2008
+ jr as BrickPdf,
2009
+ be as createDefaultDocument,
2010
+ Zr as default,
2011
+ st as getAllElementDefinitions,
2012
+ W as getElementDefinition,
2013
+ V as registerElement,
2014
+ Xr as unregisterElement,
2015
+ Gr as useClipboard,
2016
+ G as useDocumentStore,
2017
+ ge as useDragDrop,
2018
+ re as useElementActions,
2019
+ qt as useHistory,
2020
+ on as usePdfExport,
2021
+ Qr as useResize,
2022
+ Q as useSelection
1721
2023
  };