@versa-stack/v-craft 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +41 -0
  3. package/dist/types/blueprints/default.d.ts +16 -0
  4. package/dist/types/components/CraftCanvas.vue.d.ts +13 -0
  5. package/dist/types/components/CraftComponentSimpleText.vue.d.ts +17 -0
  6. package/dist/types/components/CraftDropIndicator.vue.d.ts +2 -0
  7. package/dist/types/components/CraftEditor.vue.d.ts +34 -0
  8. package/dist/types/components/CraftEditorBlueprint.vue.d.ts +18 -0
  9. package/dist/types/components/CraftEditorBlueprintsList.vue.d.ts +22 -0
  10. package/dist/types/components/CraftEditorPanelBlueprints.vue.d.ts +10 -0
  11. package/dist/types/components/CraftEditorPanelForm.vue.d.ts +133 -0
  12. package/dist/types/components/CraftEditorPanelLayers.vue.d.ts +13 -0
  13. package/dist/types/components/CraftEditorPanelLayout.vue.d.ts +22 -0
  14. package/dist/types/components/CraftEditorPanelNodeEventsSettings.vue.d.ts +21 -0
  15. package/dist/types/components/CraftEditorPanelNodeLayer.vue.d.ts +19 -0
  16. package/dist/types/components/CraftEditorPanelNodeSettings.vue.d.ts +21 -0
  17. package/dist/types/components/CraftEditorPanelSettings.vue.d.ts +24 -0
  18. package/dist/types/components/CraftFrame.vue.d.ts +27 -0
  19. package/dist/types/components/CraftIframe.vue.d.ts +45 -0
  20. package/dist/types/components/CraftNodeEditor.vue.d.ts +8 -0
  21. package/dist/types/components/CraftNodeViewer.vue.d.ts +8 -0
  22. package/dist/types/components/CraftStaticRenderer.vue.d.ts +20 -0
  23. package/dist/types/components/composable/index.d.ts +2 -0
  24. package/dist/types/components/composable/useConnectCraftNodeToStore.d.ts +8 -0
  25. package/dist/types/components/composable/useCraftFrame.d.ts +387 -0
  26. package/dist/types/components/composable/useCraftNode.d.ts +8 -0
  27. package/dist/types/components/composable/useCraftNodeEvents.d.ts +6 -0
  28. package/dist/types/components/composable/useCraftNodeWrapper.d.ts +390 -0
  29. package/dist/types/components/composable/useDragCraftNode.d.ts +10 -0
  30. package/dist/types/components/composable/useModal.d.ts +5 -0
  31. package/dist/types/components/composable/useResolveCraftNode.d.ts +8 -0
  32. package/dist/types/components/index.d.ts +28 -0
  33. package/dist/types/components/utils.d.ts +12 -0
  34. package/dist/types/index.d.ts +17 -0
  35. package/dist/types/lib/CraftNodeResolver.d.ts +23 -0
  36. package/dist/types/lib/craftNode.d.ts +32 -0
  37. package/dist/types/lib/dragCraftNode/dragOver.d.ts +3 -0
  38. package/dist/types/lib/dragCraftNode/drop.d.ts +13 -0
  39. package/dist/types/lib/dragCraftNode/index.d.ts +5 -0
  40. package/dist/types/lib/dragCraftNode/mouse.d.ts +3 -0
  41. package/dist/types/lib/jsonPathTransform.d.ts +2 -0
  42. package/dist/types/lib/mapData.d.ts +3 -0
  43. package/dist/types/lib/model.d.ts +43 -0
  44. package/dist/types/lib/renderCraftNodes.d.ts +11 -0
  45. package/dist/types/lib/setValueByPath.d.ts +1 -0
  46. package/dist/types/lib/vNodeToCraftNode.d.ts +4 -0
  47. package/dist/types/resolvers/default.d.ts +27 -0
  48. package/dist/types/store/editor.d.ts +399 -0
  49. package/dist/types/store/indicator.d.ts +82 -0
  50. package/dist/v-craft.css +1 -0
  51. package/dist/v-craft.es.js +3027 -0
  52. package/dist/v-craft.es.js.map +1 -0
  53. package/package.json +85 -0
@@ -0,0 +1,3027 @@
1
+ import { defineComponent as $, useSlots as Ue, useAttrs as ot, inject as ae, computed as w, openBlock as v, createBlock as N, resolveDynamicComponent as me, normalizeProps as Ae, mergeProps as Oe, unref as f, createSlots as ge, renderList as M, withCtx as X, renderSlot as W, guardReactiveProps as it, createCommentVNode as x, markRaw as Be, ref as K, watch as le, normalizeClass as oe, createTextVNode as at, toDisplayString as ne, createElementBlock as E, withKeys as Pe, withModifiers as V, nextTick as ue, provide as re, resolveComponent as U, createVNode as G, Fragment as T, createElementVNode as O, toRef as ce, onUnmounted as Le, toRefs as fe, normalizeStyle as je, withDirectives as lt, Teleport as ut, vShow as ct, onMounted as Ne, onBeforeMount as dt, onBeforeUnmount as ft, readonly as ht, toHandlers as Fe, h as pt } from "vue";
2
+ import { defineStore as He, storeToRefs as Z } from "pinia";
3
+ import { v4 as de } from "uuid";
4
+ import { debounce as Ve } from "lodash-es";
5
+ import { FormKit as Ke, FormKitSchema as Xe } from "@formkit/vue";
6
+ const vt = /* @__PURE__ */ $({
7
+ name: "CraftCanvas",
8
+ __name: "CraftCanvas",
9
+ props: {
10
+ componentName: {}
11
+ },
12
+ setup(t) {
13
+ const e = Ue(), r = ot(), n = t, s = ae("resolver"), o = w(() => s?.value.resolve(n.componentName)), i = w(() => o.value?.componentName || n.componentName);
14
+ return (a, c) => i.value ? (v(), N(me(i.value), Ae(Oe({ key: 0 }, f(r))), ge({ _: 2 }, [
15
+ M(f(e), (u, d) => ({
16
+ name: d,
17
+ fn: X((h) => [
18
+ W(a.$slots, d, Ae(it(h || {})))
19
+ ])
20
+ }))
21
+ ]), 1040)) : x("", !0);
22
+ }
23
+ }), xe = (t) => {
24
+ const e = ae("resolver"), r = w(() => !e || !t?.value ? {} : e.value.resolve(
25
+ t.value.componentName
26
+ )), n = w(() => r.value?.defaultProps || {});
27
+ return {
28
+ resolvedNode: r,
29
+ resolver: e,
30
+ defaultProps: n
31
+ };
32
+ }, mt = () => {
33
+ const t = ae("craftNode");
34
+ if (!t)
35
+ throw new Error("craftNode or resolver not provided");
36
+ const { resolver: e, resolvedNode: r, defaultProps: n } = xe(t);
37
+ return {
38
+ craftNode: t,
39
+ resolver: e,
40
+ resolvedNode: r,
41
+ defaultProps: n
42
+ };
43
+ }, ze = (t) => t.visible === void 0 || t.visible, gt = (t) => {
44
+ let e = t;
45
+ const r = j();
46
+ for (; e.parentUuid; )
47
+ if (e = r.nodeMap.get(e.parentUuid), q(e))
48
+ return !0;
49
+ return !1;
50
+ }, yt = (t) => gt(t) ? t.rules?.canDrag ? t.rules.canDrag(t) : !0 : !1, qe = (t, e) => {
51
+ const r = j();
52
+ let n = e;
53
+ for (; n?.parentUuid; ) {
54
+ if (n.parentUuid === t.uuid)
55
+ return !0;
56
+ n = r.nodeMap.get(n.parentUuid);
57
+ }
58
+ return !1;
59
+ }, te = (t) => t.componentName === "CraftCanvas" ? t.props.componentName : t.componentName, ie = (t, e, r) => {
60
+ if (!q(e) || t.uuid === e.uuid)
61
+ return !1;
62
+ const n = r.resolve(te(e)), s = r.resolve(te(t)), o = n?.rules || {}, i = s?.rules || {};
63
+ if (t.parentUuid) {
64
+ const c = j().nodeMap.get(t.parentUuid), u = r.resolve(te(c))?.rules || {};
65
+ if (u.canMoveOut && !u.canMoveOut(t, e, r))
66
+ return;
67
+ }
68
+ return !(i.canMoveInto && !i.canMoveInto(t, e, r) || qe(t, e) || o.canMoveIn && !o.canMoveIn(t, e, r));
69
+ }, q = (t) => t.componentName === "CraftCanvas", pe = (t, e, r) => {
70
+ const n = j();
71
+ return e.uuid === t.uuid || !e.parentUuid ? !1 : ie(
72
+ t,
73
+ n.nodeMap.get(e.parentUuid),
74
+ r
75
+ );
76
+ }, We = (t) => (t.uuid || (t.uuid = de()), t.slots && Object.values(t.slots).forEach((e) => {
77
+ e.forEach((r) => (r.uuid || (r.uuid = de()), r.parentUuid !== t.uuid && (r.parentUuid = t.uuid), We(r), r));
78
+ }), t), j = He("editor", {
79
+ state: () => ({
80
+ nodeMap: /* @__PURE__ */ new Map(),
81
+ rootNodes: [],
82
+ selectedUuid: null,
83
+ draggedNode: null,
84
+ enabled: !1,
85
+ nodeRefsRecord: {},
86
+ resolver: null,
87
+ eventsContext: {},
88
+ nodeDataMap: {},
89
+ draggingDisabled: !1
90
+ }),
91
+ actions: {
92
+ clear() {
93
+ this.nodeMap.clear(), this.rootNodes = [], this.selectedUuid = null, this.draggedNode = null, this.nodeRefsRecord = {}, this.draggingDisabled = !1;
94
+ },
95
+ enable() {
96
+ this.enabled = !0;
97
+ },
98
+ disable() {
99
+ this.enabled = !1;
100
+ },
101
+ disableDragging() {
102
+ this.draggingDisabled = !0;
103
+ },
104
+ enableDragging() {
105
+ this.draggingDisabled = !1;
106
+ },
107
+ setResolver(t) {
108
+ this.resolver = t;
109
+ },
110
+ setNodeRef(t, e) {
111
+ this.nodeRefsRecord[t.uuid] = e;
112
+ },
113
+ toggleNodeVisibility(t) {
114
+ const e = this.nodeMap.get(t.uuid);
115
+ if (e) {
116
+ if (e.visible = !ze(e), e.slots) {
117
+ const r = (n) => (n.visible = e.visible, n.slots && Object.values(n.slots).forEach((s) => {
118
+ s.forEach((o) => r(o));
119
+ }), this.nodeMap.set(n.uuid, n), n);
120
+ Object.values(e.slots).forEach((n) => {
121
+ n.forEach((s) => r(s));
122
+ });
123
+ }
124
+ this.nodeMap.set(e.uuid, e);
125
+ }
126
+ },
127
+ setNodeData(t, e) {
128
+ this.nodeDataMap[t] = e;
129
+ },
130
+ updateNodeProps(t, e) {
131
+ const r = this.nodeMap.get(t);
132
+ r && Object.assign(r.props, e);
133
+ },
134
+ updateNodeEvents(t, e) {
135
+ const r = this.nodeMap.get(t);
136
+ r && (r.events || (r.events = {}), Object.assign(r.events, e));
137
+ },
138
+ setNodes(t) {
139
+ this.clear(), this.rootNodes = [];
140
+ const e = (r) => {
141
+ this.nodeMap.set(r.uuid, { ...r, slots: {} }), r.parentUuid || this.rootNodes.push(r.uuid), r.slots && Object.entries(r.slots).forEach(([n, s]) => {
142
+ s.forEach((o) => {
143
+ o.parentUuid = r.uuid, e(o), this.nodeMap.get(r.uuid).slots[n] || (this.nodeMap.get(r.uuid).slots[n] = []), this.nodeMap.get(r.uuid).slots[n].push(o);
144
+ });
145
+ });
146
+ };
147
+ t.forEach(e);
148
+ },
149
+ addNodeRecursively(t, e = null) {
150
+ const r = t.uuid || de(), n = { ...t, uuid: r, parentUuid: e };
151
+ this.nodeMap.set(r, Be(n)), e || this.rootNodes.push(r), t.slots && Object.values(t.slots).forEach((s) => {
152
+ s.forEach((o) => this.addNodeRecursively(o, r));
153
+ });
154
+ },
155
+ selectNode(t) {
156
+ this.selectedUuid = t?.uuid ?? null;
157
+ },
158
+ dragNode(t) {
159
+ this.draggedNode = t;
160
+ },
161
+ removeNode(t) {
162
+ this.emancipateNode(t), t.uuid === this.selectedUuid && (this.selectedUuid = null);
163
+ const e = (r) => {
164
+ r.slots && Object.values(r.slots).forEach((n) => {
165
+ n.forEach((s) => {
166
+ this.nodeMap.delete(s.uuid), delete this.nodeRefsRecord[s.uuid], e(s);
167
+ });
168
+ });
169
+ };
170
+ e(t), this.nodeMap.delete(t.uuid), delete this.nodeRefsRecord[t.uuid], t.parentUuid || (this.rootNodes = this.rootNodes.filter(
171
+ (r) => r !== t.uuid
172
+ ));
173
+ },
174
+ emancipateNode(t) {
175
+ const e = t.parentUuid;
176
+ if (!e) return t;
177
+ const r = this.nodeMap.get(e);
178
+ return r && r.slots && Object.entries(r.slots).forEach(([n, s]) => {
179
+ r.slots[n] = s.filter(
180
+ (o) => o.uuid !== t.uuid
181
+ );
182
+ }), t.parentUuid = null, this.nodeMap.get(t.uuid) === t && this.nodeMap.delete(t.uuid), t;
183
+ },
184
+ addNodeAndChildrenToMap(t) {
185
+ this.nodeMap.set(t.uuid, t), t.slots && Object.values(t.slots).forEach((e) => {
186
+ e.forEach((r) => this.addNodeAndChildrenToMap(r));
187
+ });
188
+ },
189
+ appendNodeTo(t, e, r = "default") {
190
+ if (!this.resolver) throw new Error("Resolver is not set.");
191
+ if (!ie(t, e, this.resolver))
192
+ throw new Error(
193
+ `${te(
194
+ t
195
+ )} is not allowed to be a child of ${te(e)}.`
196
+ );
197
+ t = this.emancipateNode(t), t.parentUuid = e.uuid;
198
+ const n = this.nodeMap.get(e.uuid);
199
+ n && (n.slots || (n.slots = {}), n.slots[r] || (n.slots[r] = []), n.slots[r].push(t), this.nodeMap.set(n.uuid, n)), this.addNodeAndChildrenToMap(t);
200
+ },
201
+ prependNodeTo(t, e, r = "default") {
202
+ if (!this.resolver) throw new Error("Resolver is not set");
203
+ if (!ie(t, e, this.resolver))
204
+ throw new Error(
205
+ `${te(
206
+ t
207
+ )} is not allowed to be a child of ${te(e)}.`
208
+ );
209
+ t = this.emancipateNode(t), t.parentUuid = e.uuid;
210
+ const n = this.nodeMap.get(e.uuid);
211
+ n && (n.slots || (n.slots = {}), n.slots[r] || (n.slots[r] = []), n.slots[r].unshift(t), this.nodeMap.set(n.uuid, n)), this.addNodeAndChildrenToMap(t);
212
+ },
213
+ insertNodeBefore(t, e, r) {
214
+ if (!this.resolver) throw new Error("Resolver is not set");
215
+ if (!pe(t, e, this.resolver))
216
+ throw new Error("Can not be the sibling of the target node.");
217
+ t = this.emancipateNode(t);
218
+ const n = e.parentUuid;
219
+ if (!n) throw new Error("Target node has no parent.");
220
+ const s = this.nodeMap.get(n);
221
+ if (s && s.slots) {
222
+ const o = r || Object.keys(s.slots).find(
223
+ (i) => s.slots[i].some((a) => a.uuid === e.uuid)
224
+ );
225
+ if (o && s.slots[o]) {
226
+ const i = s.slots[o].findIndex(
227
+ (a) => a.uuid === e.uuid
228
+ );
229
+ i !== -1 && (s.slots[o].splice(i, 0, t), t.parentUuid = n, this.nodeMap.set(s.uuid, s), this.addNodeAndChildrenToMap(t));
230
+ }
231
+ }
232
+ },
233
+ insertNodeAfter(t, e, r) {
234
+ if (!this.resolver) throw new Error("Resolver is not set");
235
+ if (!pe(t, e, this.resolver))
236
+ throw new Error("Can not be the sibling of the target node.");
237
+ t = this.emancipateNode(t);
238
+ const n = e.parentUuid;
239
+ if (!n) throw new Error("Target node has no parent.");
240
+ const s = this.nodeMap.get(n);
241
+ if (s && s.slots) {
242
+ const o = r || Object.keys(s.slots).find(
243
+ (i) => s.slots[i].some((a) => a.uuid === e.uuid)
244
+ );
245
+ if (o && s.slots[o]) {
246
+ const i = s.slots[o].findIndex(
247
+ (a) => a.uuid === e.uuid
248
+ );
249
+ i !== -1 && (s.slots[o].splice(i + 1, 0, t), t.parentUuid = n, this.nodeMap.set(s.uuid, s), this.addNodeAndChildrenToMap(t));
250
+ }
251
+ }
252
+ },
253
+ setEventsContext(t) {
254
+ this.eventsContext = t;
255
+ }
256
+ },
257
+ getters: {
258
+ hasNodes: (t) => t.nodeMap.size > 0,
259
+ selectedNode: (t) => t.selectedUuid && t.nodeMap.get(t.selectedUuid) || null,
260
+ selectedRef: (t) => t.selectedUuid ? t.nodeRefsRecord[t.selectedUuid] : null,
261
+ getRef: (t) => (e) => t.nodeRefsRecord[e],
262
+ allNodes: (t) => Array.from(t.nodeMap.values()),
263
+ getDraggedNode: (t) => t.draggedNode,
264
+ nodeTree: (t) => {
265
+ const e = (r) => {
266
+ const n = t.nodeMap.get(r);
267
+ if (!n)
268
+ throw new Error(`Node with UUID ${r} not found`);
269
+ const s = {};
270
+ return n.slots && Object.entries(n.slots).forEach(([o, i]) => {
271
+ s[o] = i.map((a) => e(a.uuid));
272
+ }), {
273
+ ...n,
274
+ slots: s
275
+ };
276
+ };
277
+ return t.rootNodes.map((r) => e(r));
278
+ }
279
+ }
280
+ }), bt = ["value", "onKeyup"], Et = /* @__PURE__ */ $({
281
+ __name: "CraftComponentSimpleText",
282
+ props: {
283
+ content: { default: "Lorem ipsum dolor sit amet..." },
284
+ placeholder: { default: "" },
285
+ componentName: { default: "div" }
286
+ },
287
+ emits: ["update:content"],
288
+ setup(t, { emit: e }) {
289
+ const r = t, n = e, s = K(!1), o = K(null), i = K(""), a = j(), { enabled: c } = Z(a), { craftNode: u } = mt(), d = w(() => c.value && !s.value), h = () => {
290
+ d.value && m();
291
+ }, m = () => {
292
+ i.value = r.content, s.value = !0, a.disableDragging(), ue(() => {
293
+ o.value && (o.value.focus(), p());
294
+ });
295
+ }, p = () => {
296
+ o.value && (o.value.style.height = "auto", o.value.style.height = `${o.value.scrollHeight}px`);
297
+ }, b = async () => {
298
+ if (a.enableDragging(), s.value) {
299
+ s.value = !1;
300
+ const D = o.value?.value.trim() || "";
301
+ if (D !== r.content) {
302
+ if (!u.value?.uuid)
303
+ return;
304
+ a.nodeMap.set(u.value.uuid, {
305
+ ...u.value,
306
+ props: {
307
+ ...u.value.props,
308
+ content: D
309
+ }
310
+ }), await ue(), n("update:content", D);
311
+ }
312
+ }
313
+ }, g = () => {
314
+ s.value = !1, n("update:content", i.value);
315
+ };
316
+ return le(c, (D) => {
317
+ !D && s.value && g();
318
+ }), (D, F) => (v(), N(me(t.componentName), {
319
+ class: oe({ "pre-wrap": !s.value, "editable-text": f(c), "is-editable": f(c), "is-editing": s.value }),
320
+ onDblclick: h
321
+ }, {
322
+ default: X(() => [
323
+ at(ne(s.value ? "" : t.content) + " ", 1),
324
+ s.value ? (v(), E("textarea", {
325
+ key: 0,
326
+ ref_key: "textareaRef",
327
+ ref: o,
328
+ class: "editable-text__textarea",
329
+ value: t.content,
330
+ onInput: p,
331
+ onBlur: b,
332
+ onKeyup: [
333
+ Pe(V(b, ["exact"]), ["enter"]),
334
+ Pe(g, ["esc"])
335
+ ]
336
+ }, null, 40, bt)) : x("", !0)
337
+ ]),
338
+ _: 1
339
+ }, 40, ["class"]));
340
+ }
341
+ });
342
+ class ye {
343
+ resolverMap = {};
344
+ constructor(e = {}) {
345
+ return this.setResolverMap(e), Be(this);
346
+ }
347
+ setResolverMap(e) {
348
+ this.resolverMap = {}, Object.entries(e).forEach(([r, n]) => {
349
+ this.resolverMap[n.componentName] = n;
350
+ });
351
+ }
352
+ resolve(e) {
353
+ return this.resolverMap[e];
354
+ }
355
+ getDefaultProps(e) {
356
+ return this.resolveNode(e)?.defaultProps || {};
357
+ }
358
+ resolveNode(e) {
359
+ return q(e) ? this.resolve(e.props.componentName) : this.resolve(e.componentName);
360
+ }
361
+ getSchema(e) {
362
+ return this.resolveNode(e)?.propsSchema || {};
363
+ }
364
+ getEventsSchema(e) {
365
+ return this.resolveNode(e)?.eventsSchema || {};
366
+ }
367
+ getRules(e) {
368
+ return this.resolveNode(e)?.rules || {};
369
+ }
370
+ }
371
+ const Ct = /* @__PURE__ */ $({
372
+ __name: "CraftEditor",
373
+ props: {
374
+ config: {},
375
+ useIframe: { type: Boolean, default: !1 },
376
+ iFrameStyleSheets: { default: () => [] },
377
+ inheritStyles: { type: Boolean, default: !1 }
378
+ },
379
+ emits: ["nodeDragStart", "nodeDragEnd", "iframeLoad"],
380
+ setup(t, { emit: e }) {
381
+ const r = t, n = e, s = j(), { getDraggedNode: o } = Z(s);
382
+ le(o, (a) => {
383
+ if (a) {
384
+ n("nodeDragStart", a);
385
+ return;
386
+ }
387
+ n("nodeDragEnd");
388
+ });
389
+ const i = K(new ye(r.config.resolverMap));
390
+ return re("resolver", i), (a, c) => {
391
+ const u = U("CraftFrame"), d = U("CraftEditorPanelLayout");
392
+ return v(), N(d, {
393
+ blueprints: t.config.blueprintsLibrary
394
+ }, ge({ _: 2 }, [
395
+ a.$slots["panel-layout"] ? {
396
+ name: "panel-layout",
397
+ fn: X(({ blueprints: h, deselectNodes: m }) => [
398
+ W(a.$slots, "panel-layout", {
399
+ blueprints: h,
400
+ deselectNodes: m
401
+ })
402
+ ]),
403
+ key: "0"
404
+ } : {
405
+ name: "default",
406
+ fn: X(() => [
407
+ G(u, {
408
+ useIframe: t.useIframe,
409
+ inheritStyles: t.inheritStyles,
410
+ iFrameStyleSheets: t.iFrameStyleSheets,
411
+ resolverMap: t.config.resolverMap,
412
+ onIframeLoad: c[0] || (c[0] = (h) => n("iframeLoad", h))
413
+ }, {
414
+ default: X(() => [
415
+ W(a.$slots, "default")
416
+ ]),
417
+ _: 3
418
+ }, 8, ["useIframe", "inheritStyles", "iFrameStyleSheets", "resolverMap"])
419
+ ]),
420
+ key: "1"
421
+ }
422
+ ]), 1032, ["blueprints"]);
423
+ };
424
+ }
425
+ }), Se = He("indicator", {
426
+ state: () => ({
427
+ barSize: 2,
428
+ visible: !1,
429
+ coordinates: {
430
+ top: 0,
431
+ left: 0
432
+ },
433
+ dimensions: {
434
+ width: 0,
435
+ height: 0
436
+ },
437
+ forbidden: !1
438
+ }),
439
+ actions: {
440
+ hide() {
441
+ this.visible = !1, this.forbidden = !1;
442
+ },
443
+ show() {
444
+ this.visible = !0;
445
+ },
446
+ setIsForbidden(t) {
447
+ this.forbidden = t;
448
+ },
449
+ pointBefore(t) {
450
+ this.show();
451
+ const { top: e, left: r, height: n } = t.getBoundingClientRect();
452
+ this.coordinates.top = e, this.coordinates.left = r, this.dimensions.width = this.barSize, this.dimensions.height = n;
453
+ },
454
+ pointAfter(t) {
455
+ this.show();
456
+ const { top: e, left: r, width: n, height: s } = t.getBoundingClientRect();
457
+ this.coordinates.top = e, this.coordinates.left = r + n, this.dimensions.width = this.barSize, this.dimensions.height = s;
458
+ },
459
+ pointInside(t) {
460
+ this.show();
461
+ const e = De(t), { top: r, left: n, width: s, height: o } = t.getBoundingClientRect(), i = Number.parseInt(e.paddingLeft), a = Number.parseInt(e.paddingTop), c = Number.parseInt(e.paddingRight);
462
+ this.coordinates.top = r + o - a, this.coordinates.left = n + i, this.dimensions.width = s - i - c, this.dimensions.height = this.barSize;
463
+ },
464
+ pointInsideTop(t) {
465
+ this.show();
466
+ const e = De(t), { top: r, left: n, width: s } = t.getBoundingClientRect(), o = Number.parseInt(e.paddingLeft), i = Number.parseInt(e.paddingTop), a = Number.parseInt(e.paddingRight);
467
+ this.coordinates.top = r + i, this.coordinates.left = n + o, this.dimensions.width = s - o - a, this.dimensions.height = this.barSize;
468
+ }
469
+ },
470
+ getters: {
471
+ isShown: (t) => t.visible,
472
+ isForbidden: (t) => t.forbidden,
473
+ position: (t) => t.coordinates,
474
+ size: (t) => t.dimensions
475
+ }
476
+ });
477
+ function De(t) {
478
+ const { paddingTop: e, paddingLeft: r, paddingRight: n, paddingBottom: s } = getComputedStyle(t), o = {
479
+ paddingTop: e,
480
+ paddingLeft: r,
481
+ paddingRight: n,
482
+ paddingBottom: s
483
+ };
484
+ return Object.keys(o).forEach((i) => {
485
+ o[i] = parseInt(o[i].slice(0, -2), 10);
486
+ }), o;
487
+ }
488
+ const wt = /* @__PURE__ */ $({
489
+ name: "CraftEditorBlueprint",
490
+ __name: "CraftEditorBlueprint",
491
+ props: {
492
+ craftNode: {}
493
+ },
494
+ setup(t) {
495
+ const e = j(), r = Se(), n = t, s = (i) => {
496
+ console.log("CraftEditorBlueprint - dragging node:", n.craftNode), console.log("CraftEditorBlueprint - node.componentName:", n.craftNode.componentName), console.log("CraftEditorBlueprint - node.props:", n.craftNode.props), e.dragNode(n.craftNode);
497
+ }, o = (i) => {
498
+ i.stopPropagation(), e.dragNode(null), r.hide();
499
+ };
500
+ return (i, a) => (v(), E("div", {
501
+ draggable: !0,
502
+ onDragstart: V(s, ["stop"]),
503
+ onDragend: o
504
+ }, [
505
+ W(i.$slots, "default")
506
+ ], 32));
507
+ }
508
+ }), Ye = (t, e) => Object.keys(t.blueprints).map((r) => {
509
+ const n = t.blueprints[r], s = e.getDefaultProps({
510
+ ...n,
511
+ uuid: de()
512
+ });
513
+ return {
514
+ ...n,
515
+ props: { ...s, ...n.props }
516
+ };
517
+ }), _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
518
+ __proto__: null,
519
+ blueprintsWithDefaults: Ye
520
+ }, Symbol.toStringTag, { value: "Module" })), Ot = { key: 0 }, Nt = { class: "flex flex-wrap gap-2 p-1" }, xt = { class: "v-craft-blueprint" }, St = { class: "v-craft-blueprint-label" }, At = /* @__PURE__ */ $({
521
+ __name: "CraftEditorBlueprintsList",
522
+ props: {
523
+ blueprints: {}
524
+ },
525
+ setup(t) {
526
+ const e = ae("resolver");
527
+ return (r, n) => {
528
+ const s = U("CraftEditorBlueprint");
529
+ return f(e) ? (v(), E("div", Ot, [
530
+ (v(!0), E(T, null, M(t.blueprints.groups, (o) => (v(), E("div", null, [
531
+ W(r.$slots, "blueprint-group", {
532
+ group: o,
533
+ resolver: f(e)
534
+ }, () => [
535
+ O("h4", null, ne(o.label), 1),
536
+ O("div", Nt, [
537
+ (v(!0), E(T, null, M(f(Ye)(o, f(e)), (i, a) => (v(), N(s, {
538
+ craftNode: i,
539
+ key: a
540
+ }, {
541
+ default: X(() => [
542
+ O("div", xt, [
543
+ O("div", St, ne(i.label), 1)
544
+ ])
545
+ ]),
546
+ _: 2
547
+ }, 1032, ["craftNode"]))), 128))
548
+ ])
549
+ ])
550
+ ]))), 256))
551
+ ])) : x("", !0);
552
+ };
553
+ }
554
+ }), Pt = { class: "v-craft-panel v-craft-blueprints-panel" }, Dt = { class: "v-craft-panel-content" }, kt = /* @__PURE__ */ $({
555
+ name: "CraftEditorPanelBlueprints",
556
+ __name: "CraftEditorPanelBlueprints",
557
+ props: {
558
+ blueprints: {}
559
+ },
560
+ emits: ["close"],
561
+ setup(t) {
562
+ return (e, r) => {
563
+ const n = U("CraftEditorBlueprintsList");
564
+ return v(), E("div", Pt, [
565
+ r[0] || (r[0] = O("h3", { class: "v-craft-title" }, "blueprints", -1)),
566
+ O("div", Dt, [
567
+ G(n, { blueprints: t.blueprints }, null, 8, ["blueprints"])
568
+ ])
569
+ ]);
570
+ };
571
+ }
572
+ }), be = (t, e) => {
573
+ const r = t.__vccOpts || t;
574
+ for (const [n, s] of e)
575
+ r[n] = s;
576
+ return r;
577
+ }, $t = /* @__PURE__ */ be(kt, [["__scopeId", "data-v-a6de4dca"]]), Rt = /* @__PURE__ */ $({
578
+ __name: "CraftEditorPanelForm",
579
+ props: {
580
+ craftNode: {},
581
+ model: {},
582
+ schema: { default: () => ({}) }
583
+ },
584
+ emits: ["update"],
585
+ setup(t, { emit: e }) {
586
+ const r = t, n = e, s = ce(r, "model"), o = ce(r, "schema"), i = ce(r, "craftNode"), a = w(
587
+ () => s.value ? { ...s.value } : {}
588
+ ), c = Ve((d) => {
589
+ n("update", d);
590
+ }, 50), u = (d) => {
591
+ d != null && c(d);
592
+ };
593
+ return Le(() => c.cancel()), (d, h) => W(d.$slots, "panel-content", {
594
+ craftNode: i.value,
595
+ model: a.value,
596
+ handleFormInput: u,
597
+ schema: o.value
598
+ });
599
+ }
600
+ }), It = { class: "v-craft-panel v-craft-layers-panel" }, Mt = { class: "v-craft-layers" }, Tt = { class: "v-craft-node-layers" }, Ut = /* @__PURE__ */ $({
601
+ name: "CraftEditorPanelLayers",
602
+ __name: "CraftEditorPanelLayers",
603
+ setup(t) {
604
+ const e = j(), { nodeTree: r } = Z(e), n = (s) => {
605
+ e.selectNode(s);
606
+ };
607
+ return (s, o) => {
608
+ const i = U("CraftEditorPanelNodeLayer");
609
+ return v(), E("div", It, [
610
+ o[0] || (o[0] = O("h3", { class: "v-craft-title" }, "tree", -1)),
611
+ O("div", Mt, [
612
+ O("ul", Tt, [
613
+ (v(!0), E(T, null, M(f(r), (a, c) => (v(), N(i, {
614
+ key: c,
615
+ craftNode: a,
616
+ onLayerClick: n
617
+ }, null, 8, ["craftNode"]))), 128))
618
+ ])
619
+ ])
620
+ ]);
621
+ };
622
+ }
623
+ }), Bt = /* @__PURE__ */ be(Ut, [["__scopeId", "data-v-e2502bab"]]), Lt = { key: 0 }, jt = {
624
+ key: 1,
625
+ class: "v-craft-panel-manager"
626
+ }, Ft = { class: "flex w-full justify-between gap-10" }, Ht = { class: "v-craft-grid-panel v-craft-panel-left shrink" }, Vt = { class: "v-craft-grid-panel v-craft-panel-right shrink" }, Kt = /* @__PURE__ */ $({
627
+ __name: "CraftEditorPanelLayout",
628
+ props: {
629
+ blueprints: {}
630
+ },
631
+ setup(t) {
632
+ const e = j(), r = () => {
633
+ e.selectNode(null);
634
+ };
635
+ return (n, s) => {
636
+ const o = U("CraftEditorPanelBlueprints"), i = U("CraftEditorPanelLayers"), a = U("CraftEditorPanelSettings");
637
+ return n.$slots["panel-layout"] ? (v(), E("div", Lt, [
638
+ W(n.$slots, "panel-layout", {
639
+ blueprints: t.blueprints,
640
+ deselectNodes: r
641
+ }, void 0, !0)
642
+ ])) : (v(), E("div", jt, [
643
+ O("div", Ft, [
644
+ O("div", Ht, [
645
+ G(o, { blueprints: t.blueprints }, null, 8, ["blueprints"])
646
+ ]),
647
+ O("div", {
648
+ class: "v-craft-panel-center flex grow",
649
+ onClick: V(r, ["stop"])
650
+ }, [
651
+ W(n.$slots, "default", {}, void 0, !0)
652
+ ]),
653
+ O("div", Vt, [
654
+ G(i),
655
+ G(a)
656
+ ])
657
+ ])
658
+ ]));
659
+ };
660
+ }
661
+ }), Xt = /* @__PURE__ */ be(Kt, [["__scopeId", "data-v-d60526f7"]]), zt = {
662
+ key: 0,
663
+ class: "v-craft-panel-settings formkit-fieldset v-craft-scrollable-content"
664
+ }, qt = /* @__PURE__ */ $({
665
+ __name: "CraftEditorPanelNodeEventsSettings",
666
+ props: {
667
+ craftNode: {},
668
+ schema: { default: () => ({}) }
669
+ },
670
+ emits: ["update:events"],
671
+ setup(t, { emit: e }) {
672
+ const r = t, { craftNode: n, schema: s } = fe(r), o = e;
673
+ return (i, a) => {
674
+ const c = U("CraftEditorPanelForm");
675
+ return v(), N(c, {
676
+ craftNode: f(n),
677
+ schema: f(s),
678
+ model: f(n)?.events,
679
+ onUpdate: a[0] || (a[0] = (u) => o("update:events", u))
680
+ }, {
681
+ "panel-content": X(({ craftNode: u, model: d, handleFormInput: h, schema: m }) => [
682
+ m ? (v(), E("fieldset", zt, [
683
+ a[1] || (a[1] = O("legend", { class: "formkit-legend" }, "Events", -1)),
684
+ (v(), N(f(Ke), {
685
+ key: u?.uuid,
686
+ type: "form",
687
+ value: d,
688
+ onInput: h,
689
+ actions: !1
690
+ }, {
691
+ default: X(() => [
692
+ G(f(Xe), {
693
+ schema: m
694
+ }, null, 8, ["schema"])
695
+ ]),
696
+ _: 2
697
+ }, 1032, ["value", "onInput"]))
698
+ ])) : x("", !0)
699
+ ]),
700
+ _: 1
701
+ }, 8, ["craftNode", "schema", "model"]);
702
+ };
703
+ }
704
+ }), Wt = { class: "v-craft-component-layer-face" }, Yt = { class: "v-craft-component-name" }, Qt = {
705
+ key: 0,
706
+ class: "v-craft-node-layers nested-layers"
707
+ }, Gt = /* @__PURE__ */ $({
708
+ __name: "CraftEditorPanelNodeLayer",
709
+ props: {
710
+ craftNode: {},
711
+ visible: { type: Boolean, default: !0 }
712
+ },
713
+ emits: ["layer-click"],
714
+ setup(t, { emit: e }) {
715
+ const r = t, { craftNode: n, visible: s } = fe(r), o = w(
716
+ () => s.value && n.value.visible === void 0 || n.value.visible
717
+ ), i = e, a = j(), { selectedNode: c } = Z(a), u = w(() => te(n.value)), d = w(
718
+ () => c?.value?.uuid === n.value.uuid
719
+ ), h = () => {
720
+ a.toggleNodeVisibility(n.value);
721
+ };
722
+ return (m, p) => {
723
+ const b = U("CraftEditorPanelNodeLayer", !0);
724
+ return v(), E("li", {
725
+ class: oe(["v-craft-node-layer", {
726
+ "v-craft-node-layer-selected": d.value
727
+ }]),
728
+ onClick: p[1] || (p[1] = V((g) => i("layer-click", f(n)), ["prevent", "stop"]))
729
+ }, [
730
+ O("div", Wt, [
731
+ O("div", Yt, ne(u.value), 1),
732
+ O("button", {
733
+ type: "button",
734
+ class: "v-craft-component-icon",
735
+ onClick: V(h, ["prevent", "stop"])
736
+ }, ne(o.value ? "hide" : "show"), 1)
737
+ ]),
738
+ f(n).slots && Object.keys(f(n).slots).length > 0 ? (v(), E("ul", Qt, [
739
+ (v(!0), E(T, null, M(f(n).slots, (g, D) => (v(), E(T, { key: D }, [
740
+ (v(!0), E(T, null, M(g, (F, A) => (v(), N(b, {
741
+ key: `${D}-${A}`,
742
+ craftNode: F,
743
+ onLayerClick: p[0] || (p[0] = (z) => i("layer-click", z)),
744
+ visible: o.value
745
+ }, null, 8, ["craftNode", "visible"]))), 128))
746
+ ], 64))), 128))
747
+ ])) : x("", !0)
748
+ ], 2);
749
+ };
750
+ }
751
+ }), Zt = /* @__PURE__ */ be(Gt, [["__scopeId", "data-v-0b94201d"]]), Jt = {
752
+ key: 0,
753
+ class: "v-craft-panel-settings formkit-fieldset v-craft-scrollable-content"
754
+ }, er = /* @__PURE__ */ $({
755
+ __name: "CraftEditorPanelNodeSettings",
756
+ props: {
757
+ craftNode: {},
758
+ schema: { default: () => ({}) }
759
+ },
760
+ emits: ["update:props"],
761
+ setup(t, { emit: e }) {
762
+ const r = t, { craftNode: n, schema: s } = fe(r), o = e;
763
+ return (i, a) => {
764
+ const c = U("CraftEditorPanelForm");
765
+ return v(), N(c, {
766
+ craftNode: f(n),
767
+ schema: f(s),
768
+ model: f(n)?.props,
769
+ onUpdate: a[0] || (a[0] = (u) => o("update:props", u))
770
+ }, {
771
+ "panel-content": X(({ craftNode: u, model: d, handleFormInput: h, schema: m }) => [
772
+ m ? (v(), E("fieldset", Jt, [
773
+ a[1] || (a[1] = O("legend", { class: "formkit-legend" }, "Properties", -1)),
774
+ (v(), N(f(Ke), {
775
+ key: u?.uuid,
776
+ type: "form",
777
+ value: d,
778
+ onInput: h,
779
+ actions: !1
780
+ }, {
781
+ default: X(() => [
782
+ G(f(Xe), {
783
+ schema: m
784
+ }, null, 8, ["schema"])
785
+ ]),
786
+ _: 2
787
+ }, 1032, ["value", "onInput"]))
788
+ ])) : x("", !0)
789
+ ]),
790
+ _: 1
791
+ }, 8, ["craftNode", "schema", "model"]);
792
+ };
793
+ }
794
+ }), tr = { class: "text-sm" }, rr = { key: 0 }, nr = {
795
+ key: 0,
796
+ class: "v-craft-settings"
797
+ }, sr = {
798
+ key: 1,
799
+ class: "v-craft-settings"
800
+ }, or = {
801
+ class: "v-craft-actions",
802
+ "data-type": "button"
803
+ }, ir = /* @__PURE__ */ $({
804
+ __name: "CraftEditorPanelSettings",
805
+ setup(t) {
806
+ const e = j(), { selectedNode: r } = Z(e), n = ae("resolver"), s = w(() => !r.value || !n?.value ? [] : n.value.getSchema(r.value)), o = w(() => !r.value || !n?.value ? [] : n.value.getEventsSchema(r.value)), i = w(
807
+ () => r.value && r.value.parentUuid
808
+ ), a = () => {
809
+ r.value && e.removeNode(r.value);
810
+ }, c = w(
811
+ () => r.value ? `${n?.value?.resolveNode(r.value)?.componentName || "Unknown"}` : ""
812
+ ), u = (h) => {
813
+ r.value && h && e.updateNodeProps(r.value.uuid, h);
814
+ }, d = (h) => {
815
+ r.value && h && e.updateNodeEvents(r.value.uuid, h);
816
+ };
817
+ return (h, m) => {
818
+ const p = U("CraftEditorPanelNodeSettings"), b = U("CraftEditorPanelNodeEventsSettings");
819
+ return W(h.$slots, "panel-content", {
820
+ selectedNode: f(r),
821
+ nodeName: c.value,
822
+ handlePropsUpdate: u,
823
+ schema: s.value,
824
+ eventsSchema: o.value,
825
+ handleEventsUpdate: d,
826
+ deleteable: i.value,
827
+ removeNode: a
828
+ }, () => [
829
+ O("div", {
830
+ ref: "panel",
831
+ class: "v-craft-panel v-craft-settings-panel",
832
+ onClick: V(() => !1, ["prevent", "stop"])
833
+ }, [
834
+ m[1] || (m[1] = O("h3", { class: "v-craft-title" }, "component inspector", -1)),
835
+ O("span", tr, ne(f(r)?.uuid), 1),
836
+ f(r) ? x("", !0) : (v(), E("div", rr, [...m[0] || (m[0] = [
837
+ O("p", null, "select a component to inspect", -1)
838
+ ])])),
839
+ O("div", {
840
+ class: oe(["v-craft-properties", { "v-craft-visible": f(r) }])
841
+ }, [
842
+ O("h4", null, ne(c.value), 1),
843
+ s.value ? (v(), E("div", nr, [
844
+ G(p, {
845
+ craftNode: f(r),
846
+ schema: s.value,
847
+ "onUpdate:props": u
848
+ }, null, 8, ["craftNode", "schema"])
849
+ ])) : x("", !0),
850
+ o.value && f(r) ? (v(), E("div", sr, [
851
+ G(b, {
852
+ craftNode: f(r),
853
+ schema: o.value,
854
+ "onUpdate:events": d
855
+ }, null, 8, ["craftNode", "schema"])
856
+ ])) : x("", !0),
857
+ O("div", or, [
858
+ i.value ? (v(), E("button", {
859
+ key: 0,
860
+ class: "formkit-input v-craft-delete",
861
+ onClick: V(a, ["prevent"])
862
+ }, " Delete ")) : x("", !0)
863
+ ])
864
+ ], 2)
865
+ ], 512)
866
+ ]);
867
+ };
868
+ }
869
+ }), ke = /* @__PURE__ */ $({
870
+ __name: "CraftDropIndicator",
871
+ setup(t) {
872
+ const e = Se(), r = () => {
873
+ const { top: n, left: s } = e.position, { width: o, height: i } = e.size;
874
+ return {
875
+ top: `${n}px`,
876
+ left: `${s}px`,
877
+ height: `${i}px`,
878
+ width: `${o}px`
879
+ };
880
+ };
881
+ return (n, s) => f(e).isShown ? (v(), E("div", {
882
+ key: 0,
883
+ class: oe(["v-craft-indicator", { "v-craft-forbidden": f(e).isForbidden }]),
884
+ style: je(r())
885
+ }, null, 6)) : x("", !0);
886
+ }
887
+ }), Qe = /* @__PURE__ */ $({
888
+ __name: "CraftIframe",
889
+ props: {
890
+ iframeClass: { default: "" },
891
+ iframeStyle: { type: [Boolean, null, String, Object, Array], default: () => ({}) },
892
+ inheritStyles: { type: Boolean, default: !1 },
893
+ styleSheets: { default: () => [] },
894
+ styles: { default: () => [] },
895
+ iframeId: { default: "v-craft-iframe" },
896
+ width: { default: "auto" },
897
+ height: { default: "auto" }
898
+ },
899
+ emits: ["iframeLoad"],
900
+ setup(t, { emit: e }) {
901
+ const r = t, n = K(), s = K(!1), o = K(), i = K(), a = K(), { height: c, width: u } = fe(r), d = w(() => c.value === "auto");
902
+ let h = 0, m = !1;
903
+ const p = () => {
904
+ ue(() => {
905
+ if (!n.value) {
906
+ console.error("iframe could not be loaded.");
907
+ return;
908
+ }
909
+ R("iframeLoad", n.value), n.value?.setAttribute("data-iframe-ready", "true"), z(), r.inheritStyles && D(), r.styles.forEach((y) => {
910
+ n.value && F(n.value, y);
911
+ }), r.styleSheets.forEach((y) => {
912
+ n.value && A(n.value, y);
913
+ }), s.value = !0, ue(() => {
914
+ n.value && (o.value = n.value?.contentWindow?.document.body, b());
915
+ });
916
+ });
917
+ };
918
+ le([u, c], ([y, k]) => {
919
+ b();
920
+ });
921
+ const b = () => {
922
+ if (!n.value)
923
+ return;
924
+ const y = n.value.contentWindow;
925
+ if (!y) return;
926
+ if (i.value?.disconnect(), a.value?.disconnect(), c.value !== "auto" || u.value !== "auto") {
927
+ n.value.style.height = `${c.value}px`, n.value.style.width = `${u.value}px`;
928
+ return;
929
+ }
930
+ n.value.style.width = "100%", n.value.style.height = "100%", i.value = new MutationObserver(() => {
931
+ setTimeout(g, 100);
932
+ }), i.value.observe(y.document.body, {
933
+ childList: !0,
934
+ subtree: !0,
935
+ attributes: !0,
936
+ characterData: !0
937
+ });
938
+ const k = new ResizeObserver(() => {
939
+ g(), k.disconnect();
940
+ });
941
+ k.observe(y.document.documentElement), g();
942
+ }, g = () => {
943
+ m || (m = !0, ue(() => {
944
+ const y = n.value?.contentWindow?.document;
945
+ if (!y) {
946
+ m = !1;
947
+ return;
948
+ }
949
+ const k = n.value?.parentElement;
950
+ let I = 0;
951
+ if (k) {
952
+ const B = k.clientHeight, Q = n.value?.offsetTop || 0;
953
+ I = B - Q;
954
+ }
955
+ const J = y.body, he = y.documentElement, P = Math.max(
956
+ 150,
957
+ J.scrollHeight,
958
+ J.offsetHeight,
959
+ he.scrollHeight,
960
+ he.offsetHeight
961
+ ), S = Math.max(P, I);
962
+ n.value && Math.abs(S - h) > 1 && (h = S, n.value.style.height = `${S}px`), m = !1;
963
+ }));
964
+ }, D = () => {
965
+ const y = n.value?.contentWindow?.parent.document;
966
+ if (!y) return;
967
+ Array.from(y.querySelectorAll("style") ?? []).forEach((J) => {
968
+ n.value?.contentDocument?.head.appendChild(J.cloneNode(!0));
969
+ }), Array.from(y.querySelectorAll("link[rel='stylesheet']") ?? []).forEach((J) => {
970
+ n.value?.contentDocument?.head.appendChild(J.cloneNode(!0));
971
+ });
972
+ }, F = (y, k) => {
973
+ const I = document.createElement("style");
974
+ I.innerHTML = k, y?.contentWindow?.document.getElementsByTagName("head").item(0)?.appendChild(I);
975
+ }, A = (y, k) => {
976
+ const I = document.createElement("link");
977
+ I.rel = "stylesheet", I.href = k, y.contentWindow?.document.head.appendChild(I);
978
+ }, z = () => {
979
+ const y = n.value?.contentWindow?.document;
980
+ if (!y) return;
981
+ const k = y.querySelector("body");
982
+ if (!k) return;
983
+ const I = y.createAttribute("id");
984
+ I.nodeValue = "v-craft-body", k.attributes.setNamedItem(I);
985
+ }, R = e;
986
+ return Le(() => {
987
+ i.value?.disconnect(), a.value?.disconnect();
988
+ }), (y, k) => lt((v(), E("div", {
989
+ class: oe({ "h-full": d.value })
990
+ }, [
991
+ O("iframe", {
992
+ id: "v-craft-iframe",
993
+ ref_key: "iframeRef",
994
+ ref: n,
995
+ class: oe(t.iframeClass),
996
+ style: je(t.iframeStyle),
997
+ onload: p
998
+ }, null, 6),
999
+ s.value ? (v(), N(ut, {
1000
+ key: 0,
1001
+ to: n.value?.contentWindow?.document.body
1002
+ }, [
1003
+ W(y.$slots, "default")
1004
+ ], 8, ["to"])) : x("", !0)
1005
+ ], 2)), [
1006
+ [ct, y.$slots.default]
1007
+ ]);
1008
+ }
1009
+ }), ar = (t) => typeof t.type == "symbol" ? "Fragment" : typeof t.type == "string" ? t.type : t.type.name ? t.type.name : "anonmymous", Ce = (t, e, r = null) => {
1010
+ const n = ar(e), { props: s } = e, o = {
1011
+ componentName: n,
1012
+ props: s,
1013
+ slots: {},
1014
+ parentUuid: r?.uuid ?? null,
1015
+ uuid: de()
1016
+ };
1017
+ return e.children && (typeof e.children == "object" && !Array.isArray(e.children) ? Object.entries(e.children).forEach(([i, a]) => {
1018
+ if (typeof a == "function") {
1019
+ const c = a();
1020
+ c && (o.slots[i] = $e(t, c, o));
1021
+ }
1022
+ }) : Array.isArray(e.children) && (o.slots.default = $e(t, e.children, o))), o;
1023
+ }, $e = (t, e, r) => !e || !(e instanceof Array) ? [] : e.map((n) => Ce(t, n, r)).filter((n) => !!n), lr = (t) => {
1024
+ const e = j(), { hasNodes: r } = Z(e), n = t ? K(new ye(t)) : ae("resolver");
1025
+ n?.value && e.setResolver(n.value), t && re("resolver", n);
1026
+ const s = () => {
1027
+ if (n?.value && !r.value) {
1028
+ const o = Ue(), a = (o.default ? o.default() : []).flatMap((c) => {
1029
+ if (c.key === "_default" && c.children && Array.isArray(c.children))
1030
+ return c.children.map((u) => {
1031
+ const d = Ce(n.value, u);
1032
+ return d || console.error("Invalid node created from child:", u), d;
1033
+ }).filter(Boolean);
1034
+ {
1035
+ const u = Ce(n.value, c);
1036
+ return u || console.error("Invalid node created from slot:", c), [u];
1037
+ }
1038
+ }).filter(Boolean);
1039
+ a.length && e.setNodes(a);
1040
+ }
1041
+ };
1042
+ return Ne(s), le(
1043
+ () => n?.value,
1044
+ (o) => {
1045
+ o && e.setResolver(o);
1046
+ }
1047
+ ), {
1048
+ editor: e,
1049
+ mountNodes: s
1050
+ };
1051
+ }, ur = { class: "v-craft-frame" }, cr = /* @__PURE__ */ $({
1052
+ name: "CraftFrame",
1053
+ __name: "CraftFrame",
1054
+ props: {
1055
+ iFrameHeight: { default: "auto" },
1056
+ iFrameStyle: { type: [Boolean, null, String, Object, Array], default: () => ({}) },
1057
+ iFrameStyleSheets: { default: () => [] },
1058
+ iFrameStyles: { default: () => [] },
1059
+ iFrameWidth: { default: "auto" },
1060
+ inheritStyles: { type: Boolean, default: !1 },
1061
+ resolverMap: {},
1062
+ useIframe: { type: Boolean, default: !1 },
1063
+ viewOnly: { type: Boolean, default: !1 }
1064
+ },
1065
+ emits: ["iframeLoad"],
1066
+ setup(t, { emit: e }) {
1067
+ const r = t, { iFrameWidth: n, iFrameHeight: s } = fe(r), o = (h) => {
1068
+ i("iframeLoad", h);
1069
+ }, i = e, { editor: a } = lr(r.resolverMap), { nodeTree: c, hasNodes: u, enabled: d } = Z(a);
1070
+ return (h, m) => {
1071
+ const p = U("CraftNodeViewer"), b = U("CraftNodeEditor");
1072
+ return v(), E("div", ur, [
1073
+ t.useIframe ? (v(), N(Qe, {
1074
+ key: 0,
1075
+ onIframeLoad: o,
1076
+ inheritStyles: t.inheritStyles,
1077
+ styles: [
1078
+ ...t.iFrameStyles
1079
+ ],
1080
+ "iframe-style": t.iFrameStyle,
1081
+ "style-sheets": t.iFrameStyleSheets,
1082
+ width: f(n),
1083
+ height: f(s)
1084
+ }, {
1085
+ default: X(() => [
1086
+ (t.viewOnly || !f(d)) && f(u) ? (v(!0), E(T, { key: 0 }, M(f(c), (g) => (v(), N(p, {
1087
+ key: `${g.uuid}-view`,
1088
+ craftNode: g
1089
+ }, null, 8, ["craftNode"]))), 128)) : x("", !0),
1090
+ !t.viewOnly && f(d) && f(u) ? (v(!0), E(T, { key: 1 }, M(f(c), (g) => (v(), N(b, {
1091
+ key: `${g.uuid}-edit`,
1092
+ craftNode: g
1093
+ }, null, 8, ["craftNode"]))), 128)) : x("", !0),
1094
+ !t.viewOnly && f(d) ? (v(), N(ke, { key: 2 })) : x("", !0)
1095
+ ]),
1096
+ _: 1
1097
+ }, 8, ["inheritStyles", "styles", "iframe-style", "style-sheets", "width", "height"])) : x("", !0),
1098
+ !t.useIframe && (t.viewOnly || !f(d)) && f(u) ? (v(!0), E(T, { key: 1 }, M(f(c), (g) => (v(), N(p, {
1099
+ key: `${g.uuid}-view`,
1100
+ craftNode: g
1101
+ }, null, 8, ["craftNode"]))), 128)) : x("", !0),
1102
+ !t.useIframe && !t.viewOnly && f(d) && f(u) ? (v(!0), E(T, { key: 2 }, M(f(c), (g) => (v(), N(b, {
1103
+ key: `${g.uuid}-edit`,
1104
+ craftNode: g
1105
+ }, null, 8, ["craftNode"]))), 128)) : x("", !0),
1106
+ !t.useIframe && !t.viewOnly && f(d) ? (v(), N(ke, { key: 3 })) : x("", !0)
1107
+ ]);
1108
+ };
1109
+ }
1110
+ }), dr = (t, e) => {
1111
+ const r = j(), { enabled: n, selectedUuid: s, draggingDisabled: o } = Z(r);
1112
+ let i = null;
1113
+ const a = () => {
1114
+ const h = e?.value?.$el;
1115
+ h && h !== i && (i = h, r.setNodeRef(t, h));
1116
+ };
1117
+ Ne(a), le(e, a, { flush: "post" });
1118
+ const c = w(
1119
+ () => s.value === t.uuid
1120
+ );
1121
+ return {
1122
+ isDraggable: w(() => n.value && !o.value && yt(t)),
1123
+ isSelected: c,
1124
+ selectNode: () => {
1125
+ n.value && r.selectNode(t);
1126
+ }
1127
+ };
1128
+ }, Ge = (t, e, r) => {
1129
+ const n = /* @__PURE__ */ new Map(), s = () => {
1130
+ !t.value?.events || !Object.values(t.value.events).length || Object.entries(t.value.events).forEach(([o, i]) => {
1131
+ if (!i.trim())
1132
+ return;
1133
+ const a = (...c) => {
1134
+ try {
1135
+ new Function(
1136
+ "ctx",
1137
+ "craftNode",
1138
+ "args",
1139
+ i
1140
+ )(
1141
+ { ...r, editor: e },
1142
+ e.nodeMap.get(t.value.uuid),
1143
+ ...c
1144
+ );
1145
+ } catch (u) {
1146
+ console.error(
1147
+ `Event code execution failed with code:
1148
+ ${i}
1149
+
1150
+ Error:`,
1151
+ u
1152
+ );
1153
+ }
1154
+ };
1155
+ n.set(o, a);
1156
+ });
1157
+ };
1158
+ return le(
1159
+ () => t,
1160
+ () => {
1161
+ s();
1162
+ }
1163
+ ), dt(() => {
1164
+ s();
1165
+ }), ft(() => {
1166
+ n.clear();
1167
+ }), {
1168
+ eventHandlers: w(() => Object.fromEntries(n))
1169
+ };
1170
+ }, Ze = (t) => {
1171
+ const e = (() => {
1172
+ try {
1173
+ return j();
1174
+ } catch {
1175
+ return null;
1176
+ }
1177
+ })(), r = w(() => e ? Z(e).enabled?.value ?? !1 : !1), n = w(() => t.value?.visible !== !1);
1178
+ return re("craftNode", ht(t)), {
1179
+ editor: e,
1180
+ craftNode: t,
1181
+ enabled: r,
1182
+ visible: n
1183
+ };
1184
+ }, Je = (t, e) => {
1185
+ const r = e.getBoundingClientRect();
1186
+ return t.clientX - r.left < r.width / 2;
1187
+ }, et = (t, e) => {
1188
+ const r = e.getBoundingClientRect();
1189
+ return t.clientY - r.top < r.height / 2;
1190
+ }, tt = (t, e) => {
1191
+ const r = e.getBoundingClientRect();
1192
+ return t.clientX - r.left < 15 || t.clientY - r.top < 15 || r.right - t.clientX < 15 || r.bottom - t.clientY < 15;
1193
+ }, rt = (t, e, { editor: r, indicator: n, craftNode: s, resolver: o }) => {
1194
+ if (r.draggedNode) {
1195
+ if (n.setIsForbidden(!pe(r.draggedNode, s.value, o)), Je(t, e)) {
1196
+ n.pointBefore(e);
1197
+ return;
1198
+ }
1199
+ n.pointAfter(e);
1200
+ }
1201
+ }, fr = (t, e, { editor: r, indicator: n, craftNode: s, resolver: o }) => {
1202
+ if (!r.draggedNode) return;
1203
+ const a = t.target.closest(".v-craft-drop-text");
1204
+ if (a) {
1205
+ const u = !ie(r.draggedNode, s.value, o);
1206
+ n.setIsForbidden(u), n.pointInside(a);
1207
+ return;
1208
+ }
1209
+ if (tt(t, e)) {
1210
+ rt(t, e, { editor: r, indicator: n, craftNode: s, resolver: o });
1211
+ return;
1212
+ }
1213
+ const c = !ie(r.draggedNode, s.value, o);
1214
+ if (n.setIsForbidden(c), et(t, e)) {
1215
+ n.pointInsideTop(e);
1216
+ return;
1217
+ }
1218
+ n.pointInside(e);
1219
+ }, hr = (t, e, r) => {
1220
+ if (q(r.craftNode.value)) {
1221
+ fr(t, e, r);
1222
+ return;
1223
+ }
1224
+ rt(t, e, r);
1225
+ }, nt = (t, e, r, n) => {
1226
+ if (!pe(
1227
+ r,
1228
+ n.craftNode.value,
1229
+ n.resolver
1230
+ ))
1231
+ return n.craftNode.value;
1232
+ const s = n.craftNode.value.parentUuid ? n.editor.nodeMap.get(n.craftNode.value.parentUuid) : null;
1233
+ if (!s)
1234
+ return n.craftNode.value;
1235
+ const o = Object.values(s.slots || {}).flat().find(
1236
+ (i) => i.uuid === n.craftNode.value.uuid
1237
+ );
1238
+ return !o || o.uuid === r.uuid || (Je(t, e) ? n.editor.insertNodeBefore(r, o) : n.editor.insertNodeAfter(r, o)), n.craftNode.value;
1239
+ }, pr = (t, e) => {
1240
+ if (!t.slots || Object.keys(t.slots).length === 0) {
1241
+ const n = e.resolveNode?.(t)?.slots;
1242
+ n && n.length > 0 ? (t.slots = {}, n.forEach((s) => {
1243
+ t.slots[s] = [];
1244
+ })) : t.slots = { default: [] };
1245
+ }
1246
+ return t;
1247
+ }, st = (t, e, r, n) => {
1248
+ const { editor: s, resolver: o, craftNode: i } = n, a = t.target, c = s.nodeMap.get(a.id);
1249
+ if (c && q(c))
1250
+ return st(t, e, r, { ...n, craftNode: K(c) }), n.craftNode.value;
1251
+ const u = a.closest(".v-craft-drop-text");
1252
+ let d = "default";
1253
+ if (u) {
1254
+ const h = u.getAttribute("data-slot-name");
1255
+ h && (d = h);
1256
+ } else {
1257
+ if (tt(t, e))
1258
+ return nt(t, e, r, n);
1259
+ const h = n.craftNode.value.slots || {}, m = Object.keys(h);
1260
+ d = m.length > 0 ? m[0] : "default";
1261
+ }
1262
+ return ie(
1263
+ r,
1264
+ n.craftNode.value,
1265
+ n.resolver
1266
+ ) && (et(t, e) ? n.editor.prependNodeTo(r, n.craftNode.value, d) : n.editor.appendNodeTo(r, n.craftNode.value, d)), n.craftNode.value;
1267
+ }, vr = (t, e, r) => {
1268
+ if (!r.editor.draggedNode)
1269
+ return r.craftNode.value;
1270
+ const n = (() => {
1271
+ let s;
1272
+ return r.editor.draggedNode?.uuid ? s = JSON.parse(JSON.stringify(r.editor.draggedNode)) : s = We(
1273
+ JSON.parse(JSON.stringify(r.editor.draggedNode))
1274
+ ), pr(s, r.resolver);
1275
+ })();
1276
+ return q(r.craftNode.value) ? st(t, e, n, r) : nt(t, e, n, r);
1277
+ }, Re = {
1278
+ handleDragOver: hr,
1279
+ handleDrop: vr
1280
+ }, mr = (t, e, r) => {
1281
+ const n = j(), s = Se(), o = (u) => {
1282
+ n.enabled && n.dragNode(t.value);
1283
+ }, i = Ve((u) => {
1284
+ n.enabled && e.value?.$el && Re.handleDragOver(u, e.value.$el, {
1285
+ editor: n,
1286
+ indicator: s,
1287
+ craftNode: t,
1288
+ resolver: r
1289
+ });
1290
+ }, 8);
1291
+ return {
1292
+ handleDragStart: o,
1293
+ handleDragOver: i,
1294
+ handleDrop: (u) => {
1295
+ n.enabled && e.value?.$el && Re.handleDrop(u, e.value.$el, {
1296
+ editor: n,
1297
+ indicator: s,
1298
+ craftNode: t,
1299
+ resolver: r
1300
+ });
1301
+ },
1302
+ handleDragEnd: () => {
1303
+ n.enabled && (n.dragNode(null), s.hide());
1304
+ }
1305
+ };
1306
+ }, gr = ["data-slot-name"], yr = { class: "v-craft-slot-name" }, br = /* @__PURE__ */ $({
1307
+ name: "CraftNodeEditor",
1308
+ __name: "CraftNodeEditor",
1309
+ props: {
1310
+ craftNode: {}
1311
+ },
1312
+ setup(t) {
1313
+ const r = ce(t, "craftNode"), { editor: n, visible: s } = Ze(r), { resolvedNode: o, defaultProps: i, resolver: a } = xe(r);
1314
+ a.value && re("resolver", a);
1315
+ const c = K(null), u = w(() => n?.nodeDataMap[r.value.uuid]), { isSelected: d, isDraggable: h, selectNode: m } = dr(
1316
+ r.value,
1317
+ c
1318
+ ), { handleDragStart: p, handleDragOver: b, handleDrop: g, handleDragEnd: D } = mr(r, c, a.value), { eventHandlers: F } = Ge(
1319
+ r,
1320
+ n,
1321
+ n?.eventsContext || {}
1322
+ ), A = w(() => a?.value?.resolve(r.value.componentName)?.componentName || r.value.componentName), z = () => {
1323
+ m();
1324
+ }, R = (P) => {
1325
+ let S = 0;
1326
+ for (let L = 0; L < P.length; L++)
1327
+ S = P.charCodeAt(L) + ((S << 5) - S);
1328
+ const B = S % 360, Q = 70 + S % 30, H = 45 + S % 30;
1329
+ return `hsla(${B}, ${Q}%, ${H}%, 0.9)`;
1330
+ }, y = w(() => R(r.value.uuid)), k = w(() => {
1331
+ const P = [], B = a?.value?.resolveNode?.(r.value)?.slots;
1332
+ return B && B.length > 0 ? P.push(...B) : P.push("default"), P;
1333
+ }), I = w(() => q(r.value) ? !0 : Object.values(r.value.slots || {}).some((P) => P.length > 0)), J = (P, S) => u.value ? u.value.slotName && u.value.slotName !== S ? [] : he(u.value, P) : [], he = (P, S) => P.type === "single" ? S.map((B) => ({
1334
+ key: `${B.uuid}-single`,
1335
+ craftNode: {
1336
+ ...B,
1337
+ props: {
1338
+ ...B.props,
1339
+ ...P.item || {}
1340
+ }
1341
+ }
1342
+ })) : P.type === "list" ? P.list ? S.reduce((B, Q) => B.concat(
1343
+ P.list.map((H, L) => ({
1344
+ key: `${Q.uuid}-data-${L}`,
1345
+ craftNode: {
1346
+ ...Q,
1347
+ props: {
1348
+ ...Q.props,
1349
+ ...H || {}
1350
+ }
1351
+ }
1352
+ }))
1353
+ ), []) : [] : [];
1354
+ return (P, S) => {
1355
+ const B = U("CraftNodeViewer"), Q = U("CraftNodeEditor", !0);
1356
+ return f(s) && r.value && f(o) ? (v(), N(me(f(o).componentName), Oe({
1357
+ key: 0,
1358
+ ref_key: "nodeRef",
1359
+ ref: c
1360
+ }, { ...f(i), ...r.value.props }, Fe(f(F)), {
1361
+ "data-node-name": A.value,
1362
+ style: { "--node-color": y.value },
1363
+ class: {
1364
+ "v-craft-node-selected": f(d),
1365
+ "v-craft-node": f(n)?.enabled,
1366
+ "v-craft-canvas": f(q)(r.value),
1367
+ "v-craft-empty": !r.value.slots || Object.keys(r.value.slots).length === 0 || Object.values(r.value.slots).every((H) => H.length === 0),
1368
+ "v-craft-other-node-dragged": f(n)?.draggedNode && !f(qe)(f(n).draggedNode, r.value)
1369
+ },
1370
+ draggable: f(n)?.enabled && f(h),
1371
+ onClick: V(z, ["prevent", "stop"]),
1372
+ onDragend: V(f(D), ["prevent", "stop"]),
1373
+ onDragover: V(f(b), ["prevent", "stop"]),
1374
+ onDragstart: V(f(p), ["stop"]),
1375
+ onDrop: V(f(g), ["prevent", "stop"])
1376
+ }), ge({ _: 2 }, [
1377
+ M(k.value, (H) => ({
1378
+ name: H,
1379
+ fn: X(() => [
1380
+ f(q)(r.value) && r.value.slots[H]?.length == 0 ? (v(), E("div", {
1381
+ key: 0,
1382
+ class: "v-craft-drop-text",
1383
+ "data-slot-name": H,
1384
+ onDragover: S[0] || (S[0] = V(
1385
+ //@ts-ignore
1386
+ (...L) => f(b) && f(b)(...L),
1387
+ ["prevent", "stop"]
1388
+ )),
1389
+ onDrop: S[1] || (S[1] = V(
1390
+ //@ts-ignore
1391
+ (...L) => f(g) && f(g)(...L),
1392
+ ["prevent", "stop"]
1393
+ ))
1394
+ }, [
1395
+ S[2] || (S[2] = O("span", { class: "v-craft-drop-text-label" }, "Drop a component here", -1)),
1396
+ O("span", yr, ne(H), 1)
1397
+ ], 40, gr)) : x("", !0),
1398
+ I.value ? (v(), E(T, { key: 1 }, [
1399
+ u.value?.type && u.value.slotName === H ? (v(!0), E(T, { key: 0 }, M(J(r.value.slots?.[H] || [], H), (L) => (v(), N(B, {
1400
+ key: L.key,
1401
+ craftNode: L.craftNode
1402
+ }, null, 8, ["craftNode"]))), 128)) : x("", !0),
1403
+ (v(!0), E(T, null, M(r.value.slots?.[H] || [], (L) => (v(), N(Q, {
1404
+ key: L.uuid,
1405
+ craftNode: L
1406
+ }, null, 8, ["craftNode"]))), 128))
1407
+ ], 64)) : x("", !0)
1408
+ ])
1409
+ }))
1410
+ ]), 1040, ["data-node-name", "style", "class", "draggable", "onDragend", "onDragover", "onDragstart", "onDrop"])) : x("", !0);
1411
+ };
1412
+ }
1413
+ }), ve = /* @__PURE__ */ $({
1414
+ name: "CraftNodeViewer",
1415
+ __name: "CraftNodeViewer",
1416
+ props: {
1417
+ craftNode: {},
1418
+ nodeDataMap: {},
1419
+ eventsContext: {}
1420
+ },
1421
+ setup(t) {
1422
+ const e = t, r = ce(e, "craftNode"), { editor: n, visible: s } = Ze(r), { resolvedNode: o, defaultProps: i, resolver: a } = xe(r);
1423
+ re("resolver", a);
1424
+ const c = w(() => ({
1425
+ ...i.value,
1426
+ ...r.value?.props
1427
+ })), u = w(() => e.nodeDataMap?.[r.value.uuid] || n?.nodeDataMap?.[r.value.uuid]), d = w(() => r.value.slots || {}), h = w(() => q(r.value)), m = w(() => {
1428
+ const A = [], R = a?.value?.resolveNode?.(r.value)?.slots;
1429
+ return R && R.length > 0 ? A.push(...R) : A.push("default"), A;
1430
+ }), p = w(() => h.value ? !0 : Object.values(d.value).some((A) => A.length > 0)), b = (A, z) => u.value ? u.value.slotName && u.value.slotName !== z ? [] : F(u.value, A) : [], g = K(null), { eventHandlers: D } = Ge(
1431
+ r,
1432
+ n,
1433
+ e.eventsContext || n?.eventsContext || {}
1434
+ );
1435
+ Ne(() => {
1436
+ g.value && r.value && n && n.setNodeRef(r.value, g.value);
1437
+ });
1438
+ const F = (A, z) => A.type === "single" ? z.map((R) => ({
1439
+ key: `${R.uuid}-single`,
1440
+ craftNode: {
1441
+ ...R,
1442
+ props: {
1443
+ ...R.props,
1444
+ ...A.item || {}
1445
+ }
1446
+ }
1447
+ })) : A.type === "list" ? A.list ? z.reduce((R, y) => R.concat(
1448
+ //@ts-ignore
1449
+ A.list.map((k, I) => ({
1450
+ key: `${y.uuid}-data-${I}`,
1451
+ craftNode: {
1452
+ ...y,
1453
+ props: {
1454
+ ...y.props,
1455
+ ...k || {}
1456
+ }
1457
+ }
1458
+ }))
1459
+ ), []) : [] : [];
1460
+ return (A, z) => f(s) && f(a) && f(o) ? (v(), N(me(f(o).componentName), Oe({
1461
+ key: 0,
1462
+ ref_key: "nodeRef",
1463
+ ref: g
1464
+ }, c.value, Fe(f(D))), ge({ _: 2 }, [
1465
+ M(m.value, (R) => ({
1466
+ name: R,
1467
+ fn: X(() => [
1468
+ p.value ? (v(), E(T, { key: 0 }, [
1469
+ u.value?.type ? (v(!0), E(T, { key: 1 }, M(b(d.value[R], R), (y) => (v(), N(ve, {
1470
+ key: y.key,
1471
+ craftNode: y.craftNode
1472
+ }, null, 8, ["craftNode"]))), 128)) : (v(!0), E(T, { key: 0 }, M(d.value[R], (y) => (v(), N(ve, {
1473
+ key: y.uuid,
1474
+ craftNode: y
1475
+ }, null, 8, ["craftNode"]))), 128))
1476
+ ], 64)) : x("", !0)
1477
+ ])
1478
+ }))
1479
+ ]), 1040)) : x("", !0);
1480
+ }
1481
+ }), Er = /* @__PURE__ */ $({
1482
+ name: "CraftStaticRenderer",
1483
+ __name: "CraftStaticRenderer",
1484
+ props: {
1485
+ nodes: {},
1486
+ resolverMap: {},
1487
+ nodeDataMap: {},
1488
+ eventsContext: {}
1489
+ },
1490
+ setup(t) {
1491
+ const e = t, r = w(() => new ye(e.resolverMap));
1492
+ return re("resolver", r), re("nodeDataMap", e.nodeDataMap || {}), re("eventsContext", e.eventsContext || {}), (n, s) => (v(!0), E(T, null, M(t.nodes, (o) => (v(), N(ve, {
1493
+ key: o.uuid,
1494
+ craftNode: o,
1495
+ nodeDataMap: t.nodeDataMap,
1496
+ eventsContext: t.eventsContext
1497
+ }, null, 8, ["craftNode", "nodeDataMap", "eventsContext"]))), 128));
1498
+ }
1499
+ }), Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1500
+ __proto__: null,
1501
+ CraftCanvas: vt,
1502
+ CraftComponentSimpleText: Et,
1503
+ CraftEditor: Ct,
1504
+ CraftEditorBlueprint: wt,
1505
+ CraftEditorBlueprintsList: At,
1506
+ CraftEditorPanelBlueprints: $t,
1507
+ CraftEditorPanelForm: Rt,
1508
+ CraftEditorPanelLayers: Bt,
1509
+ CraftEditorPanelLayout: Xt,
1510
+ CraftEditorPanelNodeEventsSettings: qt,
1511
+ CraftEditorPanelNodeLayer: Zt,
1512
+ CraftEditorPanelNodeSettings: er,
1513
+ CraftEditorPanelSettings: ir,
1514
+ CraftFrame: cr,
1515
+ CraftIframe: Qe,
1516
+ CraftNodeEditor: br,
1517
+ CraftNodeViewer: ve,
1518
+ CraftStaticRenderer: Er,
1519
+ Utils: _t
1520
+ }, Symbol.toStringTag, { value: "Module" })), Vr = {
1521
+ metadata: {
1522
+ name: "default"
1523
+ },
1524
+ label: "Default",
1525
+ blueprints: {
1526
+ CraftComponentSimpleText: {
1527
+ label: "Text",
1528
+ componentName: "CraftComponentSimpleText",
1529
+ props: {
1530
+ content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus arcu eu justo cursus faucibus. Phasellus non ex ac massa aliquet suscipit non eget odio. Aliquam eget laoreet ligula, at imperdiet tortor. Integer ut eros non velit rhoncus tincidunt. Mauris porta fringilla volutpat. Duis et nulla leo. Cras eu risus at nisl feugiat commodo vitae vel augue. Aenean at tempus velit. Duis eget convallis ipsum, eget suscipit felis. Quisque scelerisque euismod scelerisque.",
1531
+ componentName: "p"
1532
+ }
1533
+ }
1534
+ }
1535
+ };
1536
+ class Cr {
1537
+ /**
1538
+ * @callback HookCallback
1539
+ * @this {*|Jsep} this
1540
+ * @param {Jsep} env
1541
+ * @returns: void
1542
+ */
1543
+ /**
1544
+ * Adds the given callback to the list of callbacks for the given hook.
1545
+ *
1546
+ * The callback will be invoked when the hook it is registered for is run.
1547
+ *
1548
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
1549
+ *
1550
+ * @param {string|object} name The name of the hook, or an object of callbacks keyed by name
1551
+ * @param {HookCallback|boolean} callback The callback function which is given environment variables.
1552
+ * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
1553
+ * @public
1554
+ */
1555
+ add(e, r, n) {
1556
+ if (typeof arguments[0] != "string")
1557
+ for (let s in arguments[0])
1558
+ this.add(s, arguments[0][s], arguments[1]);
1559
+ else
1560
+ (Array.isArray(e) ? e : [e]).forEach(function(s) {
1561
+ this[s] = this[s] || [], r && this[s][n ? "unshift" : "push"](r);
1562
+ }, this);
1563
+ }
1564
+ /**
1565
+ * Runs a hook invoking all registered callbacks with the given environment variables.
1566
+ *
1567
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
1568
+ *
1569
+ * @param {string} name The name of the hook.
1570
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
1571
+ * @public
1572
+ */
1573
+ run(e, r) {
1574
+ this[e] = this[e] || [], this[e].forEach(function(n) {
1575
+ n.call(r && r.context ? r.context : r, r);
1576
+ });
1577
+ }
1578
+ }
1579
+ class wr {
1580
+ constructor(e) {
1581
+ this.jsep = e, this.registered = {};
1582
+ }
1583
+ /**
1584
+ * @callback PluginSetup
1585
+ * @this {Jsep} jsep
1586
+ * @returns: void
1587
+ */
1588
+ /**
1589
+ * Adds the given plugin(s) to the registry
1590
+ *
1591
+ * @param {object} plugins
1592
+ * @param {string} plugins.name The name of the plugin
1593
+ * @param {PluginSetup} plugins.init The init function
1594
+ * @public
1595
+ */
1596
+ register() {
1597
+ for (var e = arguments.length, r = new Array(e), n = 0; n < e; n++)
1598
+ r[n] = arguments[n];
1599
+ r.forEach((s) => {
1600
+ if (typeof s != "object" || !s.name || !s.init)
1601
+ throw new Error("Invalid JSEP plugin format");
1602
+ this.registered[s.name] || (s.init(this.jsep), this.registered[s.name] = s);
1603
+ });
1604
+ }
1605
+ }
1606
+ class l {
1607
+ /**
1608
+ * @returns {string}
1609
+ */
1610
+ static get version() {
1611
+ return "1.4.0";
1612
+ }
1613
+ /**
1614
+ * @returns {string}
1615
+ */
1616
+ static toString() {
1617
+ return "JavaScript Expression Parser (JSEP) v" + l.version;
1618
+ }
1619
+ // ==================== CONFIG ================================
1620
+ /**
1621
+ * @method addUnaryOp
1622
+ * @param {string} op_name The name of the unary op to add
1623
+ * @returns {Jsep}
1624
+ */
1625
+ static addUnaryOp(e) {
1626
+ return l.max_unop_len = Math.max(e.length, l.max_unop_len), l.unary_ops[e] = 1, l;
1627
+ }
1628
+ /**
1629
+ * @method jsep.addBinaryOp
1630
+ * @param {string} op_name The name of the binary op to add
1631
+ * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence
1632
+ * @param {boolean} [isRightAssociative=false] whether operator is right-associative
1633
+ * @returns {Jsep}
1634
+ */
1635
+ static addBinaryOp(e, r, n) {
1636
+ return l.max_binop_len = Math.max(e.length, l.max_binop_len), l.binary_ops[e] = r, n ? l.right_associative.add(e) : l.right_associative.delete(e), l;
1637
+ }
1638
+ /**
1639
+ * @method addIdentifierChar
1640
+ * @param {string} char The additional character to treat as a valid part of an identifier
1641
+ * @returns {Jsep}
1642
+ */
1643
+ static addIdentifierChar(e) {
1644
+ return l.additional_identifier_chars.add(e), l;
1645
+ }
1646
+ /**
1647
+ * @method addLiteral
1648
+ * @param {string} literal_name The name of the literal to add
1649
+ * @param {*} literal_value The value of the literal
1650
+ * @returns {Jsep}
1651
+ */
1652
+ static addLiteral(e, r) {
1653
+ return l.literals[e] = r, l;
1654
+ }
1655
+ /**
1656
+ * @method removeUnaryOp
1657
+ * @param {string} op_name The name of the unary op to remove
1658
+ * @returns {Jsep}
1659
+ */
1660
+ static removeUnaryOp(e) {
1661
+ return delete l.unary_ops[e], e.length === l.max_unop_len && (l.max_unop_len = l.getMaxKeyLen(l.unary_ops)), l;
1662
+ }
1663
+ /**
1664
+ * @method removeAllUnaryOps
1665
+ * @returns {Jsep}
1666
+ */
1667
+ static removeAllUnaryOps() {
1668
+ return l.unary_ops = {}, l.max_unop_len = 0, l;
1669
+ }
1670
+ /**
1671
+ * @method removeIdentifierChar
1672
+ * @param {string} char The additional character to stop treating as a valid part of an identifier
1673
+ * @returns {Jsep}
1674
+ */
1675
+ static removeIdentifierChar(e) {
1676
+ return l.additional_identifier_chars.delete(e), l;
1677
+ }
1678
+ /**
1679
+ * @method removeBinaryOp
1680
+ * @param {string} op_name The name of the binary op to remove
1681
+ * @returns {Jsep}
1682
+ */
1683
+ static removeBinaryOp(e) {
1684
+ return delete l.binary_ops[e], e.length === l.max_binop_len && (l.max_binop_len = l.getMaxKeyLen(l.binary_ops)), l.right_associative.delete(e), l;
1685
+ }
1686
+ /**
1687
+ * @method removeAllBinaryOps
1688
+ * @returns {Jsep}
1689
+ */
1690
+ static removeAllBinaryOps() {
1691
+ return l.binary_ops = {}, l.max_binop_len = 0, l;
1692
+ }
1693
+ /**
1694
+ * @method removeLiteral
1695
+ * @param {string} literal_name The name of the literal to remove
1696
+ * @returns {Jsep}
1697
+ */
1698
+ static removeLiteral(e) {
1699
+ return delete l.literals[e], l;
1700
+ }
1701
+ /**
1702
+ * @method removeAllLiterals
1703
+ * @returns {Jsep}
1704
+ */
1705
+ static removeAllLiterals() {
1706
+ return l.literals = {}, l;
1707
+ }
1708
+ // ==================== END CONFIG ============================
1709
+ /**
1710
+ * @returns {string}
1711
+ */
1712
+ get char() {
1713
+ return this.expr.charAt(this.index);
1714
+ }
1715
+ /**
1716
+ * @returns {number}
1717
+ */
1718
+ get code() {
1719
+ return this.expr.charCodeAt(this.index);
1720
+ }
1721
+ /**
1722
+ * @param {string} expr a string with the passed in express
1723
+ * @returns Jsep
1724
+ */
1725
+ constructor(e) {
1726
+ this.expr = e, this.index = 0;
1727
+ }
1728
+ /**
1729
+ * static top-level parser
1730
+ * @returns {jsep.Expression}
1731
+ */
1732
+ static parse(e) {
1733
+ return new l(e).parse();
1734
+ }
1735
+ /**
1736
+ * Get the longest key length of any object
1737
+ * @param {object} obj
1738
+ * @returns {number}
1739
+ */
1740
+ static getMaxKeyLen(e) {
1741
+ return Math.max(0, ...Object.keys(e).map((r) => r.length));
1742
+ }
1743
+ /**
1744
+ * `ch` is a character code in the next three functions
1745
+ * @param {number} ch
1746
+ * @returns {boolean}
1747
+ */
1748
+ static isDecimalDigit(e) {
1749
+ return e >= 48 && e <= 57;
1750
+ }
1751
+ /**
1752
+ * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.
1753
+ * @param {string} op_val
1754
+ * @returns {number}
1755
+ */
1756
+ static binaryPrecedence(e) {
1757
+ return l.binary_ops[e] || 0;
1758
+ }
1759
+ /**
1760
+ * Looks for start of identifier
1761
+ * @param {number} ch
1762
+ * @returns {boolean}
1763
+ */
1764
+ static isIdentifierStart(e) {
1765
+ return e >= 65 && e <= 90 || // A...Z
1766
+ e >= 97 && e <= 122 || // a...z
1767
+ e >= 128 && !l.binary_ops[String.fromCharCode(e)] || // any non-ASCII that is not an operator
1768
+ l.additional_identifier_chars.has(String.fromCharCode(e));
1769
+ }
1770
+ /**
1771
+ * @param {number} ch
1772
+ * @returns {boolean}
1773
+ */
1774
+ static isIdentifierPart(e) {
1775
+ return l.isIdentifierStart(e) || l.isDecimalDigit(e);
1776
+ }
1777
+ /**
1778
+ * throw error at index of the expression
1779
+ * @param {string} message
1780
+ * @throws
1781
+ */
1782
+ throwError(e) {
1783
+ const r = new Error(e + " at character " + this.index);
1784
+ throw r.index = this.index, r.description = e, r;
1785
+ }
1786
+ /**
1787
+ * Run a given hook
1788
+ * @param {string} name
1789
+ * @param {jsep.Expression|false} [node]
1790
+ * @returns {?jsep.Expression}
1791
+ */
1792
+ runHook(e, r) {
1793
+ if (l.hooks[e]) {
1794
+ const n = {
1795
+ context: this,
1796
+ node: r
1797
+ };
1798
+ return l.hooks.run(e, n), n.node;
1799
+ }
1800
+ return r;
1801
+ }
1802
+ /**
1803
+ * Runs a given hook until one returns a node
1804
+ * @param {string} name
1805
+ * @returns {?jsep.Expression}
1806
+ */
1807
+ searchHook(e) {
1808
+ if (l.hooks[e]) {
1809
+ const r = {
1810
+ context: this
1811
+ };
1812
+ return l.hooks[e].find(function(n) {
1813
+ return n.call(r.context, r), r.node;
1814
+ }), r.node;
1815
+ }
1816
+ }
1817
+ /**
1818
+ * Push `index` up to the next non-space character
1819
+ */
1820
+ gobbleSpaces() {
1821
+ let e = this.code;
1822
+ for (; e === l.SPACE_CODE || e === l.TAB_CODE || e === l.LF_CODE || e === l.CR_CODE; )
1823
+ e = this.expr.charCodeAt(++this.index);
1824
+ this.runHook("gobble-spaces");
1825
+ }
1826
+ /**
1827
+ * Top-level method to parse all expressions and returns compound or single node
1828
+ * @returns {jsep.Expression}
1829
+ */
1830
+ parse() {
1831
+ this.runHook("before-all");
1832
+ const e = this.gobbleExpressions(), r = e.length === 1 ? e[0] : {
1833
+ type: l.COMPOUND,
1834
+ body: e
1835
+ };
1836
+ return this.runHook("after-all", r);
1837
+ }
1838
+ /**
1839
+ * top-level parser (but can be reused within as well)
1840
+ * @param {number} [untilICode]
1841
+ * @returns {jsep.Expression[]}
1842
+ */
1843
+ gobbleExpressions(e) {
1844
+ let r = [], n, s;
1845
+ for (; this.index < this.expr.length; )
1846
+ if (n = this.code, n === l.SEMCOL_CODE || n === l.COMMA_CODE)
1847
+ this.index++;
1848
+ else if (s = this.gobbleExpression())
1849
+ r.push(s);
1850
+ else if (this.index < this.expr.length) {
1851
+ if (n === e)
1852
+ break;
1853
+ this.throwError('Unexpected "' + this.char + '"');
1854
+ }
1855
+ return r;
1856
+ }
1857
+ /**
1858
+ * The main parsing function.
1859
+ * @returns {?jsep.Expression}
1860
+ */
1861
+ gobbleExpression() {
1862
+ const e = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
1863
+ return this.gobbleSpaces(), this.runHook("after-expression", e);
1864
+ }
1865
+ /**
1866
+ * Search for the operation portion of the string (e.g. `+`, `===`)
1867
+ * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
1868
+ * and move down from 3 to 2 to 1 character until a matching binary operation is found
1869
+ * then, return that binary operation
1870
+ * @returns {string|boolean}
1871
+ */
1872
+ gobbleBinaryOp() {
1873
+ this.gobbleSpaces();
1874
+ let e = this.expr.substr(this.index, l.max_binop_len), r = e.length;
1875
+ for (; r > 0; ) {
1876
+ if (l.binary_ops.hasOwnProperty(e) && (!l.isIdentifierStart(this.code) || this.index + e.length < this.expr.length && !l.isIdentifierPart(this.expr.charCodeAt(this.index + e.length))))
1877
+ return this.index += r, e;
1878
+ e = e.substr(0, --r);
1879
+ }
1880
+ return !1;
1881
+ }
1882
+ /**
1883
+ * This function is responsible for gobbling an individual expression,
1884
+ * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
1885
+ * @returns {?jsep.BinaryExpression}
1886
+ */
1887
+ gobbleBinaryExpression() {
1888
+ let e, r, n, s, o, i, a, c, u;
1889
+ if (i = this.gobbleToken(), !i || (r = this.gobbleBinaryOp(), !r))
1890
+ return i;
1891
+ for (o = {
1892
+ value: r,
1893
+ prec: l.binaryPrecedence(r),
1894
+ right_a: l.right_associative.has(r)
1895
+ }, a = this.gobbleToken(), a || this.throwError("Expected expression after " + r), s = [i, o, a]; r = this.gobbleBinaryOp(); ) {
1896
+ if (n = l.binaryPrecedence(r), n === 0) {
1897
+ this.index -= r.length;
1898
+ break;
1899
+ }
1900
+ o = {
1901
+ value: r,
1902
+ prec: n,
1903
+ right_a: l.right_associative.has(r)
1904
+ }, u = r;
1905
+ const d = (h) => o.right_a && h.right_a ? n > h.prec : n <= h.prec;
1906
+ for (; s.length > 2 && d(s[s.length - 2]); )
1907
+ a = s.pop(), r = s.pop().value, i = s.pop(), e = {
1908
+ type: l.BINARY_EXP,
1909
+ operator: r,
1910
+ left: i,
1911
+ right: a
1912
+ }, s.push(e);
1913
+ e = this.gobbleToken(), e || this.throwError("Expected expression after " + u), s.push(o, e);
1914
+ }
1915
+ for (c = s.length - 1, e = s[c]; c > 1; )
1916
+ e = {
1917
+ type: l.BINARY_EXP,
1918
+ operator: s[c - 1].value,
1919
+ left: s[c - 2],
1920
+ right: e
1921
+ }, c -= 2;
1922
+ return e;
1923
+ }
1924
+ /**
1925
+ * An individual part of a binary expression:
1926
+ * e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
1927
+ * @returns {boolean|jsep.Expression}
1928
+ */
1929
+ gobbleToken() {
1930
+ let e, r, n, s;
1931
+ if (this.gobbleSpaces(), s = this.searchHook("gobble-token"), s)
1932
+ return this.runHook("after-token", s);
1933
+ if (e = this.code, l.isDecimalDigit(e) || e === l.PERIOD_CODE)
1934
+ return this.gobbleNumericLiteral();
1935
+ if (e === l.SQUOTE_CODE || e === l.DQUOTE_CODE)
1936
+ s = this.gobbleStringLiteral();
1937
+ else if (e === l.OBRACK_CODE)
1938
+ s = this.gobbleArray();
1939
+ else {
1940
+ for (r = this.expr.substr(this.index, l.max_unop_len), n = r.length; n > 0; ) {
1941
+ if (l.unary_ops.hasOwnProperty(r) && (!l.isIdentifierStart(this.code) || this.index + r.length < this.expr.length && !l.isIdentifierPart(this.expr.charCodeAt(this.index + r.length)))) {
1942
+ this.index += n;
1943
+ const o = this.gobbleToken();
1944
+ return o || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
1945
+ type: l.UNARY_EXP,
1946
+ operator: r,
1947
+ argument: o,
1948
+ prefix: !0
1949
+ });
1950
+ }
1951
+ r = r.substr(0, --n);
1952
+ }
1953
+ l.isIdentifierStart(e) ? (s = this.gobbleIdentifier(), l.literals.hasOwnProperty(s.name) ? s = {
1954
+ type: l.LITERAL,
1955
+ value: l.literals[s.name],
1956
+ raw: s.name
1957
+ } : s.name === l.this_str && (s = {
1958
+ type: l.THIS_EXP
1959
+ })) : e === l.OPAREN_CODE && (s = this.gobbleGroup());
1960
+ }
1961
+ return s ? (s = this.gobbleTokenProperty(s), this.runHook("after-token", s)) : this.runHook("after-token", !1);
1962
+ }
1963
+ /**
1964
+ * Gobble properties of of identifiers/strings/arrays/groups.
1965
+ * e.g. `foo`, `bar.baz`, `foo['bar'].baz`
1966
+ * It also gobbles function calls:
1967
+ * e.g. `Math.acos(obj.angle)`
1968
+ * @param {jsep.Expression} node
1969
+ * @returns {jsep.Expression}
1970
+ */
1971
+ gobbleTokenProperty(e) {
1972
+ this.gobbleSpaces();
1973
+ let r = this.code;
1974
+ for (; r === l.PERIOD_CODE || r === l.OBRACK_CODE || r === l.OPAREN_CODE || r === l.QUMARK_CODE; ) {
1975
+ let n;
1976
+ if (r === l.QUMARK_CODE) {
1977
+ if (this.expr.charCodeAt(this.index + 1) !== l.PERIOD_CODE)
1978
+ break;
1979
+ n = !0, this.index += 2, this.gobbleSpaces(), r = this.code;
1980
+ }
1981
+ this.index++, r === l.OBRACK_CODE ? (e = {
1982
+ type: l.MEMBER_EXP,
1983
+ computed: !0,
1984
+ object: e,
1985
+ property: this.gobbleExpression()
1986
+ }, e.property || this.throwError('Unexpected "' + this.char + '"'), this.gobbleSpaces(), r = this.code, r !== l.CBRACK_CODE && this.throwError("Unclosed ["), this.index++) : r === l.OPAREN_CODE ? e = {
1987
+ type: l.CALL_EXP,
1988
+ arguments: this.gobbleArguments(l.CPAREN_CODE),
1989
+ callee: e
1990
+ } : (r === l.PERIOD_CODE || n) && (n && this.index--, this.gobbleSpaces(), e = {
1991
+ type: l.MEMBER_EXP,
1992
+ computed: !1,
1993
+ object: e,
1994
+ property: this.gobbleIdentifier()
1995
+ }), n && (e.optional = !0), this.gobbleSpaces(), r = this.code;
1996
+ }
1997
+ return e;
1998
+ }
1999
+ /**
2000
+ * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
2001
+ * keep track of everything in the numeric literal and then calling `parseFloat` on that string
2002
+ * @returns {jsep.Literal}
2003
+ */
2004
+ gobbleNumericLiteral() {
2005
+ let e = "", r, n;
2006
+ for (; l.isDecimalDigit(this.code); )
2007
+ e += this.expr.charAt(this.index++);
2008
+ if (this.code === l.PERIOD_CODE)
2009
+ for (e += this.expr.charAt(this.index++); l.isDecimalDigit(this.code); )
2010
+ e += this.expr.charAt(this.index++);
2011
+ if (r = this.char, r === "e" || r === "E") {
2012
+ for (e += this.expr.charAt(this.index++), r = this.char, (r === "+" || r === "-") && (e += this.expr.charAt(this.index++)); l.isDecimalDigit(this.code); )
2013
+ e += this.expr.charAt(this.index++);
2014
+ l.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) || this.throwError("Expected exponent (" + e + this.char + ")");
2015
+ }
2016
+ return n = this.code, l.isIdentifierStart(n) ? this.throwError("Variable names cannot start with a number (" + e + this.char + ")") : (n === l.PERIOD_CODE || e.length === 1 && e.charCodeAt(0) === l.PERIOD_CODE) && this.throwError("Unexpected period"), {
2017
+ type: l.LITERAL,
2018
+ value: parseFloat(e),
2019
+ raw: e
2020
+ };
2021
+ }
2022
+ /**
2023
+ * Parses a string literal, staring with single or double quotes with basic support for escape codes
2024
+ * e.g. `"hello world"`, `'this is\nJSEP'`
2025
+ * @returns {jsep.Literal}
2026
+ */
2027
+ gobbleStringLiteral() {
2028
+ let e = "";
2029
+ const r = this.index, n = this.expr.charAt(this.index++);
2030
+ let s = !1;
2031
+ for (; this.index < this.expr.length; ) {
2032
+ let o = this.expr.charAt(this.index++);
2033
+ if (o === n) {
2034
+ s = !0;
2035
+ break;
2036
+ } else if (o === "\\")
2037
+ switch (o = this.expr.charAt(this.index++), o) {
2038
+ case "n":
2039
+ e += `
2040
+ `;
2041
+ break;
2042
+ case "r":
2043
+ e += "\r";
2044
+ break;
2045
+ case "t":
2046
+ e += " ";
2047
+ break;
2048
+ case "b":
2049
+ e += "\b";
2050
+ break;
2051
+ case "f":
2052
+ e += "\f";
2053
+ break;
2054
+ case "v":
2055
+ e += "\v";
2056
+ break;
2057
+ default:
2058
+ e += o;
2059
+ }
2060
+ else
2061
+ e += o;
2062
+ }
2063
+ return s || this.throwError('Unclosed quote after "' + e + '"'), {
2064
+ type: l.LITERAL,
2065
+ value: e,
2066
+ raw: this.expr.substring(r, this.index)
2067
+ };
2068
+ }
2069
+ /**
2070
+ * Gobbles only identifiers
2071
+ * e.g.: `foo`, `_value`, `$x1`
2072
+ * Also, this function checks if that identifier is a literal:
2073
+ * (e.g. `true`, `false`, `null`) or `this`
2074
+ * @returns {jsep.Identifier}
2075
+ */
2076
+ gobbleIdentifier() {
2077
+ let e = this.code, r = this.index;
2078
+ for (l.isIdentifierStart(e) ? this.index++ : this.throwError("Unexpected " + this.char); this.index < this.expr.length && (e = this.code, l.isIdentifierPart(e)); )
2079
+ this.index++;
2080
+ return {
2081
+ type: l.IDENTIFIER,
2082
+ name: this.expr.slice(r, this.index)
2083
+ };
2084
+ }
2085
+ /**
2086
+ * Gobbles a list of arguments within the context of a function call
2087
+ * or array literal. This function also assumes that the opening character
2088
+ * `(` or `[` has already been gobbled, and gobbles expressions and commas
2089
+ * until the terminator character `)` or `]` is encountered.
2090
+ * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
2091
+ * @param {number} termination
2092
+ * @returns {jsep.Expression[]}
2093
+ */
2094
+ gobbleArguments(e) {
2095
+ const r = [];
2096
+ let n = !1, s = 0;
2097
+ for (; this.index < this.expr.length; ) {
2098
+ this.gobbleSpaces();
2099
+ let o = this.code;
2100
+ if (o === e) {
2101
+ n = !0, this.index++, e === l.CPAREN_CODE && s && s >= r.length && this.throwError("Unexpected token " + String.fromCharCode(e));
2102
+ break;
2103
+ } else if (o === l.COMMA_CODE) {
2104
+ if (this.index++, s++, s !== r.length) {
2105
+ if (e === l.CPAREN_CODE)
2106
+ this.throwError("Unexpected token ,");
2107
+ else if (e === l.CBRACK_CODE)
2108
+ for (let i = r.length; i < s; i++)
2109
+ r.push(null);
2110
+ }
2111
+ } else if (r.length !== s && s !== 0)
2112
+ this.throwError("Expected comma");
2113
+ else {
2114
+ const i = this.gobbleExpression();
2115
+ (!i || i.type === l.COMPOUND) && this.throwError("Expected comma"), r.push(i);
2116
+ }
2117
+ }
2118
+ return n || this.throwError("Expected " + String.fromCharCode(e)), r;
2119
+ }
2120
+ /**
2121
+ * Responsible for parsing a group of things within parentheses `()`
2122
+ * that have no identifier in front (so not a function call)
2123
+ * This function assumes that it needs to gobble the opening parenthesis
2124
+ * and then tries to gobble everything within that parenthesis, assuming
2125
+ * that the next thing it should see is the close parenthesis. If not,
2126
+ * then the expression probably doesn't have a `)`
2127
+ * @returns {boolean|jsep.Expression}
2128
+ */
2129
+ gobbleGroup() {
2130
+ this.index++;
2131
+ let e = this.gobbleExpressions(l.CPAREN_CODE);
2132
+ if (this.code === l.CPAREN_CODE)
2133
+ return this.index++, e.length === 1 ? e[0] : e.length ? {
2134
+ type: l.SEQUENCE_EXP,
2135
+ expressions: e
2136
+ } : !1;
2137
+ this.throwError("Unclosed (");
2138
+ }
2139
+ /**
2140
+ * Responsible for parsing Array literals `[1, 2, 3]`
2141
+ * This function assumes that it needs to gobble the opening bracket
2142
+ * and then tries to gobble the expressions as arguments.
2143
+ * @returns {jsep.ArrayExpression}
2144
+ */
2145
+ gobbleArray() {
2146
+ return this.index++, {
2147
+ type: l.ARRAY_EXP,
2148
+ elements: this.gobbleArguments(l.CBRACK_CODE)
2149
+ };
2150
+ }
2151
+ }
2152
+ const _r = new Cr();
2153
+ Object.assign(l, {
2154
+ hooks: _r,
2155
+ plugins: new wr(l),
2156
+ // Node Types
2157
+ // ----------
2158
+ // This is the full set of types that any JSEP node can be.
2159
+ // Store them here to save space when minified
2160
+ COMPOUND: "Compound",
2161
+ SEQUENCE_EXP: "SequenceExpression",
2162
+ IDENTIFIER: "Identifier",
2163
+ MEMBER_EXP: "MemberExpression",
2164
+ LITERAL: "Literal",
2165
+ THIS_EXP: "ThisExpression",
2166
+ CALL_EXP: "CallExpression",
2167
+ UNARY_EXP: "UnaryExpression",
2168
+ BINARY_EXP: "BinaryExpression",
2169
+ ARRAY_EXP: "ArrayExpression",
2170
+ TAB_CODE: 9,
2171
+ LF_CODE: 10,
2172
+ CR_CODE: 13,
2173
+ SPACE_CODE: 32,
2174
+ PERIOD_CODE: 46,
2175
+ // '.'
2176
+ COMMA_CODE: 44,
2177
+ // ','
2178
+ SQUOTE_CODE: 39,
2179
+ // single quote
2180
+ DQUOTE_CODE: 34,
2181
+ // double quotes
2182
+ OPAREN_CODE: 40,
2183
+ // (
2184
+ CPAREN_CODE: 41,
2185
+ // )
2186
+ OBRACK_CODE: 91,
2187
+ // [
2188
+ CBRACK_CODE: 93,
2189
+ // ]
2190
+ QUMARK_CODE: 63,
2191
+ // ?
2192
+ SEMCOL_CODE: 59,
2193
+ // ;
2194
+ COLON_CODE: 58,
2195
+ // :
2196
+ // Operations
2197
+ // ----------
2198
+ // Use a quickly-accessible map to store all of the unary operators
2199
+ // Values are set to `1` (it really doesn't matter)
2200
+ unary_ops: {
2201
+ "-": 1,
2202
+ "!": 1,
2203
+ "~": 1,
2204
+ "+": 1
2205
+ },
2206
+ // Also use a map for the binary operations but set their values to their
2207
+ // binary precedence for quick reference (higher number = higher precedence)
2208
+ // see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
2209
+ binary_ops: {
2210
+ "||": 1,
2211
+ "??": 1,
2212
+ "&&": 2,
2213
+ "|": 3,
2214
+ "^": 4,
2215
+ "&": 5,
2216
+ "==": 6,
2217
+ "!=": 6,
2218
+ "===": 6,
2219
+ "!==": 6,
2220
+ "<": 7,
2221
+ ">": 7,
2222
+ "<=": 7,
2223
+ ">=": 7,
2224
+ "<<": 8,
2225
+ ">>": 8,
2226
+ ">>>": 8,
2227
+ "+": 9,
2228
+ "-": 9,
2229
+ "*": 10,
2230
+ "/": 10,
2231
+ "%": 10,
2232
+ "**": 11
2233
+ },
2234
+ // sets specific binary_ops as right-associative
2235
+ right_associative: /* @__PURE__ */ new Set(["**"]),
2236
+ // Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
2237
+ additional_identifier_chars: /* @__PURE__ */ new Set(["$", "_"]),
2238
+ // Literals
2239
+ // ----------
2240
+ // Store the values to return for the various literals we may encounter
2241
+ literals: {
2242
+ true: !0,
2243
+ false: !1,
2244
+ null: null
2245
+ },
2246
+ // Except for `this`, which is special. This could be changed to something like `'self'` as well
2247
+ this_str: "this"
2248
+ });
2249
+ l.max_unop_len = l.getMaxKeyLen(l.unary_ops);
2250
+ l.max_binop_len = l.getMaxKeyLen(l.binary_ops);
2251
+ const Y = (t) => new l(t).parse(), Or = Object.getOwnPropertyNames(class {
2252
+ });
2253
+ Object.getOwnPropertyNames(l).filter((t) => !Or.includes(t) && Y[t] === void 0).forEach((t) => {
2254
+ Y[t] = l[t];
2255
+ });
2256
+ Y.Jsep = l;
2257
+ const Nr = "ConditionalExpression";
2258
+ var xr = {
2259
+ name: "ternary",
2260
+ init(t) {
2261
+ t.hooks.add("after-expression", function(r) {
2262
+ if (r.node && this.code === t.QUMARK_CODE) {
2263
+ this.index++;
2264
+ const n = r.node, s = this.gobbleExpression();
2265
+ if (s || this.throwError("Expected expression"), this.gobbleSpaces(), this.code === t.COLON_CODE) {
2266
+ this.index++;
2267
+ const o = this.gobbleExpression();
2268
+ if (o || this.throwError("Expected expression"), r.node = {
2269
+ type: Nr,
2270
+ test: n,
2271
+ consequent: s,
2272
+ alternate: o
2273
+ }, n.operator && t.binary_ops[n.operator] <= 0.9) {
2274
+ let i = n;
2275
+ for (; i.right.operator && t.binary_ops[i.right.operator] <= 0.9; )
2276
+ i = i.right;
2277
+ r.node.test = i.right, i.right = r.node, r.node = n;
2278
+ }
2279
+ } else
2280
+ this.throwError("Expected :");
2281
+ }
2282
+ });
2283
+ }
2284
+ };
2285
+ Y.plugins.register(xr);
2286
+ const Me = 47, Sr = 92;
2287
+ var Ar = {
2288
+ name: "regex",
2289
+ init(t) {
2290
+ t.hooks.add("gobble-token", function(r) {
2291
+ if (this.code === Me) {
2292
+ const n = ++this.index;
2293
+ let s = !1;
2294
+ for (; this.index < this.expr.length; ) {
2295
+ if (this.code === Me && !s) {
2296
+ const o = this.expr.slice(n, this.index);
2297
+ let i = "";
2298
+ for (; ++this.index < this.expr.length; ) {
2299
+ const c = this.code;
2300
+ if (c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57)
2301
+ i += this.char;
2302
+ else
2303
+ break;
2304
+ }
2305
+ let a;
2306
+ try {
2307
+ a = new RegExp(o, i);
2308
+ } catch (c) {
2309
+ this.throwError(c.message);
2310
+ }
2311
+ return r.node = {
2312
+ type: t.LITERAL,
2313
+ value: a,
2314
+ raw: this.expr.slice(n - 1, this.index)
2315
+ }, r.node = this.gobbleTokenProperty(r.node), r.node;
2316
+ }
2317
+ this.code === t.OBRACK_CODE ? s = !0 : s && this.code === t.CBRACK_CODE && (s = !1), this.index += this.code === Sr ? 2 : 1;
2318
+ }
2319
+ this.throwError("Unclosed Regex");
2320
+ }
2321
+ });
2322
+ }
2323
+ };
2324
+ const Ee = 43, Pr = 45, se = {
2325
+ name: "assignment",
2326
+ assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
2327
+ updateOperators: [Ee, Pr],
2328
+ assignmentPrecedence: 0.9,
2329
+ init(t) {
2330
+ const e = [t.IDENTIFIER, t.MEMBER_EXP];
2331
+ se.assignmentOperators.forEach((n) => t.addBinaryOp(n, se.assignmentPrecedence, !0)), t.hooks.add("gobble-token", function(s) {
2332
+ const o = this.code;
2333
+ se.updateOperators.some((i) => i === o && i === this.expr.charCodeAt(this.index + 1)) && (this.index += 2, s.node = {
2334
+ type: "UpdateExpression",
2335
+ operator: o === Ee ? "++" : "--",
2336
+ argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
2337
+ prefix: !0
2338
+ }, (!s.node.argument || !e.includes(s.node.argument.type)) && this.throwError(`Unexpected ${s.node.operator}`));
2339
+ }), t.hooks.add("after-token", function(s) {
2340
+ if (s.node) {
2341
+ const o = this.code;
2342
+ se.updateOperators.some((i) => i === o && i === this.expr.charCodeAt(this.index + 1)) && (e.includes(s.node.type) || this.throwError(`Unexpected ${s.node.operator}`), this.index += 2, s.node = {
2343
+ type: "UpdateExpression",
2344
+ operator: o === Ee ? "++" : "--",
2345
+ argument: s.node,
2346
+ prefix: !1
2347
+ });
2348
+ }
2349
+ }), t.hooks.add("after-expression", function(s) {
2350
+ s.node && r(s.node);
2351
+ });
2352
+ function r(n) {
2353
+ se.assignmentOperators.has(n.operator) ? (n.type = "AssignmentExpression", r(n.left), r(n.right)) : n.operator || Object.values(n).forEach((s) => {
2354
+ s && typeof s == "object" && r(s);
2355
+ });
2356
+ }
2357
+ }
2358
+ };
2359
+ Y.plugins.register(Ar, se);
2360
+ Y.addUnaryOp("typeof");
2361
+ Y.addUnaryOp("void");
2362
+ Y.addLiteral("null", null);
2363
+ Y.addLiteral("undefined", void 0);
2364
+ const Dr = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]), _ = {
2365
+ /**
2366
+ * @param {jsep.Expression} ast
2367
+ * @param {Record<string, any>} subs
2368
+ */
2369
+ evalAst(t, e) {
2370
+ switch (t.type) {
2371
+ case "BinaryExpression":
2372
+ case "LogicalExpression":
2373
+ return _.evalBinaryExpression(t, e);
2374
+ case "Compound":
2375
+ return _.evalCompound(t, e);
2376
+ case "ConditionalExpression":
2377
+ return _.evalConditionalExpression(t, e);
2378
+ case "Identifier":
2379
+ return _.evalIdentifier(t, e);
2380
+ case "Literal":
2381
+ return _.evalLiteral(t, e);
2382
+ case "MemberExpression":
2383
+ return _.evalMemberExpression(t, e);
2384
+ case "UnaryExpression":
2385
+ return _.evalUnaryExpression(t, e);
2386
+ case "ArrayExpression":
2387
+ return _.evalArrayExpression(t, e);
2388
+ case "CallExpression":
2389
+ return _.evalCallExpression(t, e);
2390
+ case "AssignmentExpression":
2391
+ return _.evalAssignmentExpression(t, e);
2392
+ default:
2393
+ throw SyntaxError("Unexpected expression", t);
2394
+ }
2395
+ },
2396
+ evalBinaryExpression(t, e) {
2397
+ return {
2398
+ "||": (n, s) => n || s(),
2399
+ "&&": (n, s) => n && s(),
2400
+ "|": (n, s) => n | s(),
2401
+ "^": (n, s) => n ^ s(),
2402
+ "&": (n, s) => n & s(),
2403
+ // eslint-disable-next-line eqeqeq -- API
2404
+ "==": (n, s) => n == s(),
2405
+ // eslint-disable-next-line eqeqeq -- API
2406
+ "!=": (n, s) => n != s(),
2407
+ "===": (n, s) => n === s(),
2408
+ "!==": (n, s) => n !== s(),
2409
+ "<": (n, s) => n < s(),
2410
+ ">": (n, s) => n > s(),
2411
+ "<=": (n, s) => n <= s(),
2412
+ ">=": (n, s) => n >= s(),
2413
+ "<<": (n, s) => n << s(),
2414
+ ">>": (n, s) => n >> s(),
2415
+ ">>>": (n, s) => n >>> s(),
2416
+ "+": (n, s) => n + s(),
2417
+ "-": (n, s) => n - s(),
2418
+ "*": (n, s) => n * s(),
2419
+ "/": (n, s) => n / s(),
2420
+ "%": (n, s) => n % s()
2421
+ }[t.operator](_.evalAst(t.left, e), () => _.evalAst(t.right, e));
2422
+ },
2423
+ evalCompound(t, e) {
2424
+ let r;
2425
+ for (let n = 0; n < t.body.length; n++) {
2426
+ t.body[n].type === "Identifier" && ["var", "let", "const"].includes(t.body[n].name) && t.body[n + 1] && t.body[n + 1].type === "AssignmentExpression" && (n += 1);
2427
+ const s = t.body[n];
2428
+ r = _.evalAst(s, e);
2429
+ }
2430
+ return r;
2431
+ },
2432
+ evalConditionalExpression(t, e) {
2433
+ return _.evalAst(t.test, e) ? _.evalAst(t.consequent, e) : _.evalAst(t.alternate, e);
2434
+ },
2435
+ evalIdentifier(t, e) {
2436
+ if (Object.hasOwn(e, t.name))
2437
+ return e[t.name];
2438
+ throw ReferenceError(`${t.name} is not defined`);
2439
+ },
2440
+ evalLiteral(t) {
2441
+ return t.value;
2442
+ },
2443
+ evalMemberExpression(t, e) {
2444
+ const r = String(
2445
+ // NOTE: `String(value)` throws error when
2446
+ // value has overwritten the toString method to return non-string
2447
+ // i.e. `value = {toString: () => []}`
2448
+ t.computed ? _.evalAst(t.property) : t.property.name
2449
+ // `object.property` property is Identifier
2450
+ ), n = _.evalAst(t.object, e);
2451
+ if (n == null)
2452
+ throw TypeError(`Cannot read properties of ${n} (reading '${r}')`);
2453
+ if (!Object.hasOwn(n, r) && Dr.has(r))
2454
+ throw TypeError(`Cannot read properties of ${n} (reading '${r}')`);
2455
+ const s = n[r];
2456
+ return typeof s == "function" ? s.bind(n) : s;
2457
+ },
2458
+ evalUnaryExpression(t, e) {
2459
+ return {
2460
+ "-": (n) => -_.evalAst(n, e),
2461
+ "!": (n) => !_.evalAst(n, e),
2462
+ "~": (n) => ~_.evalAst(n, e),
2463
+ // eslint-disable-next-line no-implicit-coercion -- API
2464
+ "+": (n) => +_.evalAst(n, e),
2465
+ typeof: (n) => typeof _.evalAst(n, e),
2466
+ // eslint-disable-next-line no-void, sonarjs/void-use -- feature
2467
+ void: (n) => void _.evalAst(n, e)
2468
+ }[t.operator](t.argument);
2469
+ },
2470
+ evalArrayExpression(t, e) {
2471
+ return t.elements.map((r) => _.evalAst(r, e));
2472
+ },
2473
+ evalCallExpression(t, e) {
2474
+ const r = t.arguments.map((s) => _.evalAst(s, e)), n = _.evalAst(t.callee, e);
2475
+ if (n === Function)
2476
+ throw new Error("Function constructor is disabled");
2477
+ return n(...r);
2478
+ },
2479
+ evalAssignmentExpression(t, e) {
2480
+ if (t.left.type !== "Identifier")
2481
+ throw SyntaxError("Invalid left-hand side in assignment");
2482
+ const r = t.left.name, n = _.evalAst(t.right, e);
2483
+ return e[r] = n, e[r];
2484
+ }
2485
+ };
2486
+ class kr {
2487
+ /**
2488
+ * @param {string} expr Expression to evaluate
2489
+ */
2490
+ constructor(e) {
2491
+ this.code = e, this.ast = Y(this.code);
2492
+ }
2493
+ /**
2494
+ * @param {object} context Object whose items will be added
2495
+ * to evaluation
2496
+ * @returns {EvaluatedResult} Result of evaluated code
2497
+ */
2498
+ runInNewContext(e) {
2499
+ const r = Object.assign(/* @__PURE__ */ Object.create(null), e);
2500
+ return _.evalAst(this.ast, r);
2501
+ }
2502
+ }
2503
+ function ee(t, e) {
2504
+ return t = t.slice(), t.push(e), t;
2505
+ }
2506
+ function we(t, e) {
2507
+ return e = e.slice(), e.unshift(t), e;
2508
+ }
2509
+ class $r extends Error {
2510
+ /**
2511
+ * @param {AnyResult} value The evaluated scalar value
2512
+ */
2513
+ constructor(e) {
2514
+ super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'), this.avoidNew = !0, this.value = e, this.name = "NewError";
2515
+ }
2516
+ }
2517
+ function C(t, e, r, n, s) {
2518
+ if (!(this instanceof C))
2519
+ try {
2520
+ return new C(t, e, r, n, s);
2521
+ } catch (i) {
2522
+ if (!i.avoidNew)
2523
+ throw i;
2524
+ return i.value;
2525
+ }
2526
+ typeof t == "string" && (s = n, n = r, r = e, e = t, t = null);
2527
+ const o = t && typeof t == "object";
2528
+ if (t = t || {}, this.json = t.json || r, this.path = t.path || e, this.resultType = t.resultType || "value", this.flatten = t.flatten || !1, this.wrap = Object.hasOwn(t, "wrap") ? t.wrap : !0, this.sandbox = t.sandbox || {}, this.eval = t.eval === void 0 ? "safe" : t.eval, this.ignoreEvalErrors = typeof t.ignoreEvalErrors > "u" ? !1 : t.ignoreEvalErrors, this.parent = t.parent || null, this.parentProperty = t.parentProperty || null, this.callback = t.callback || n || null, this.otherTypeCallback = t.otherTypeCallback || s || function() {
2529
+ throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
2530
+ }, t.autostart !== !1) {
2531
+ const i = {
2532
+ path: o ? t.path : e
2533
+ };
2534
+ o ? "json" in t && (i.json = t.json) : i.json = r;
2535
+ const a = this.evaluate(i);
2536
+ if (!a || typeof a != "object")
2537
+ throw new $r(a);
2538
+ return a;
2539
+ }
2540
+ }
2541
+ C.prototype.evaluate = function(t, e, r, n) {
2542
+ let s = this.parent, o = this.parentProperty, {
2543
+ flatten: i,
2544
+ wrap: a
2545
+ } = this;
2546
+ if (this.currResultType = this.resultType, this.currEval = this.eval, this.currSandbox = this.sandbox, r = r || this.callback, this.currOtherTypeCallback = n || this.otherTypeCallback, e = e || this.json, t = t || this.path, t && typeof t == "object" && !Array.isArray(t)) {
2547
+ if (!t.path && t.path !== "")
2548
+ throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');
2549
+ if (!Object.hasOwn(t, "json"))
2550
+ throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
2551
+ ({
2552
+ json: e
2553
+ } = t), i = Object.hasOwn(t, "flatten") ? t.flatten : i, this.currResultType = Object.hasOwn(t, "resultType") ? t.resultType : this.currResultType, this.currSandbox = Object.hasOwn(t, "sandbox") ? t.sandbox : this.currSandbox, a = Object.hasOwn(t, "wrap") ? t.wrap : a, this.currEval = Object.hasOwn(t, "eval") ? t.eval : this.currEval, r = Object.hasOwn(t, "callback") ? t.callback : r, this.currOtherTypeCallback = Object.hasOwn(t, "otherTypeCallback") ? t.otherTypeCallback : this.currOtherTypeCallback, s = Object.hasOwn(t, "parent") ? t.parent : s, o = Object.hasOwn(t, "parentProperty") ? t.parentProperty : o, t = t.path;
2554
+ }
2555
+ if (s = s || null, o = o || null, Array.isArray(t) && (t = C.toPathString(t)), !t && t !== "" || !e)
2556
+ return;
2557
+ const c = C.toPathArray(t);
2558
+ c[0] === "$" && c.length > 1 && c.shift(), this._hasParentSelector = null;
2559
+ const u = this._trace(c, e, ["$"], s, o, r).filter(function(d) {
2560
+ return d && !d.isParentSelector;
2561
+ });
2562
+ return u.length ? !a && u.length === 1 && !u[0].hasArrExpr ? this._getPreferredOutput(u[0]) : u.reduce((d, h) => {
2563
+ const m = this._getPreferredOutput(h);
2564
+ return i && Array.isArray(m) ? d = d.concat(m) : d.push(m), d;
2565
+ }, []) : a ? [] : void 0;
2566
+ };
2567
+ C.prototype._getPreferredOutput = function(t) {
2568
+ const e = this.currResultType;
2569
+ switch (e) {
2570
+ case "all": {
2571
+ const r = Array.isArray(t.path) ? t.path : C.toPathArray(t.path);
2572
+ return t.pointer = C.toPointer(r), t.path = typeof t.path == "string" ? t.path : C.toPathString(t.path), t;
2573
+ }
2574
+ case "value":
2575
+ case "parent":
2576
+ case "parentProperty":
2577
+ return t[e];
2578
+ case "path":
2579
+ return C.toPathString(t[e]);
2580
+ case "pointer":
2581
+ return C.toPointer(t.path);
2582
+ default:
2583
+ throw new TypeError("Unknown result type");
2584
+ }
2585
+ };
2586
+ C.prototype._handleCallback = function(t, e, r) {
2587
+ if (e) {
2588
+ const n = this._getPreferredOutput(t);
2589
+ t.path = typeof t.path == "string" ? t.path : C.toPathString(t.path), e(n, r, t);
2590
+ }
2591
+ };
2592
+ C.prototype._trace = function(t, e, r, n, s, o, i, a) {
2593
+ let c;
2594
+ if (!t.length)
2595
+ return c = {
2596
+ path: r,
2597
+ value: e,
2598
+ parent: n,
2599
+ parentProperty: s,
2600
+ hasArrExpr: i
2601
+ }, this._handleCallback(c, o, "value"), c;
2602
+ const u = t[0], d = t.slice(1), h = [];
2603
+ function m(p) {
2604
+ Array.isArray(p) ? p.forEach((b) => {
2605
+ h.push(b);
2606
+ }) : h.push(p);
2607
+ }
2608
+ if ((typeof u != "string" || a) && e && Object.hasOwn(e, u))
2609
+ m(this._trace(d, e[u], ee(r, u), e, u, o, i));
2610
+ else if (u === "*")
2611
+ this._walk(e, (p) => {
2612
+ m(this._trace(d, e[p], ee(r, p), e, p, o, !0, !0));
2613
+ });
2614
+ else if (u === "..")
2615
+ m(this._trace(d, e, r, n, s, o, i)), this._walk(e, (p) => {
2616
+ typeof e[p] == "object" && m(this._trace(t.slice(), e[p], ee(r, p), e, p, o, !0));
2617
+ });
2618
+ else {
2619
+ if (u === "^")
2620
+ return this._hasParentSelector = !0, {
2621
+ path: r.slice(0, -1),
2622
+ expr: d,
2623
+ isParentSelector: !0
2624
+ };
2625
+ if (u === "~")
2626
+ return c = {
2627
+ path: ee(r, u),
2628
+ value: s,
2629
+ parent: n,
2630
+ parentProperty: null
2631
+ }, this._handleCallback(c, o, "property"), c;
2632
+ if (u === "$")
2633
+ m(this._trace(d, e, r, null, null, o, i));
2634
+ else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(u))
2635
+ m(this._slice(u, d, e, r, n, s, o));
2636
+ else if (u.indexOf("?(") === 0) {
2637
+ if (this.currEval === !1)
2638
+ throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
2639
+ const p = u.replace(/^\?\((.*?)\)$/u, "$1"), b = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(p);
2640
+ b ? this._walk(e, (g) => {
2641
+ const D = [b[2]], F = b[1] ? e[g][b[1]] : e[g];
2642
+ this._trace(D, F, r, n, s, o, !0).length > 0 && m(this._trace(d, e[g], ee(r, g), e, g, o, !0));
2643
+ }) : this._walk(e, (g) => {
2644
+ this._eval(p, e[g], g, r, n, s) && m(this._trace(d, e[g], ee(r, g), e, g, o, !0));
2645
+ });
2646
+ } else if (u[0] === "(") {
2647
+ if (this.currEval === !1)
2648
+ throw new Error("Eval [(expr)] prevented in JSONPath expression.");
2649
+ m(this._trace(we(this._eval(u, e, r.at(-1), r.slice(0, -1), n, s), d), e, r, n, s, o, i));
2650
+ } else if (u[0] === "@") {
2651
+ let p = !1;
2652
+ const b = u.slice(1, -2);
2653
+ switch (b) {
2654
+ case "scalar":
2655
+ (!e || !["object", "function"].includes(typeof e)) && (p = !0);
2656
+ break;
2657
+ case "boolean":
2658
+ case "string":
2659
+ case "undefined":
2660
+ case "function":
2661
+ typeof e === b && (p = !0);
2662
+ break;
2663
+ case "integer":
2664
+ Number.isFinite(e) && !(e % 1) && (p = !0);
2665
+ break;
2666
+ case "number":
2667
+ Number.isFinite(e) && (p = !0);
2668
+ break;
2669
+ case "nonFinite":
2670
+ typeof e == "number" && !Number.isFinite(e) && (p = !0);
2671
+ break;
2672
+ case "object":
2673
+ e && typeof e === b && (p = !0);
2674
+ break;
2675
+ case "array":
2676
+ Array.isArray(e) && (p = !0);
2677
+ break;
2678
+ case "other":
2679
+ p = this.currOtherTypeCallback(e, r, n, s);
2680
+ break;
2681
+ case "null":
2682
+ e === null && (p = !0);
2683
+ break;
2684
+ /* c8 ignore next 2 */
2685
+ default:
2686
+ throw new TypeError("Unknown value type " + b);
2687
+ }
2688
+ if (p)
2689
+ return c = {
2690
+ path: r,
2691
+ value: e,
2692
+ parent: n,
2693
+ parentProperty: s
2694
+ }, this._handleCallback(c, o, "value"), c;
2695
+ } else if (u[0] === "`" && e && Object.hasOwn(e, u.slice(1))) {
2696
+ const p = u.slice(1);
2697
+ m(this._trace(d, e[p], ee(r, p), e, p, o, i, !0));
2698
+ } else if (u.includes(",")) {
2699
+ const p = u.split(",");
2700
+ for (const b of p)
2701
+ m(this._trace(we(b, d), e, r, n, s, o, !0));
2702
+ } else !a && e && Object.hasOwn(e, u) && m(this._trace(d, e[u], ee(r, u), e, u, o, i, !0));
2703
+ }
2704
+ if (this._hasParentSelector)
2705
+ for (let p = 0; p < h.length; p++) {
2706
+ const b = h[p];
2707
+ if (b && b.isParentSelector) {
2708
+ const g = this._trace(b.expr, e, b.path, n, s, o, i);
2709
+ if (Array.isArray(g)) {
2710
+ h[p] = g[0];
2711
+ const D = g.length;
2712
+ for (let F = 1; F < D; F++)
2713
+ p++, h.splice(p, 0, g[F]);
2714
+ } else
2715
+ h[p] = g;
2716
+ }
2717
+ }
2718
+ return h;
2719
+ };
2720
+ C.prototype._walk = function(t, e) {
2721
+ if (Array.isArray(t)) {
2722
+ const r = t.length;
2723
+ for (let n = 0; n < r; n++)
2724
+ e(n);
2725
+ } else t && typeof t == "object" && Object.keys(t).forEach((r) => {
2726
+ e(r);
2727
+ });
2728
+ };
2729
+ C.prototype._slice = function(t, e, r, n, s, o, i) {
2730
+ if (!Array.isArray(r))
2731
+ return;
2732
+ const a = r.length, c = t.split(":"), u = c[2] && Number.parseInt(c[2]) || 1;
2733
+ let d = c[0] && Number.parseInt(c[0]) || 0, h = c[1] && Number.parseInt(c[1]) || a;
2734
+ d = d < 0 ? Math.max(0, d + a) : Math.min(a, d), h = h < 0 ? Math.max(0, h + a) : Math.min(a, h);
2735
+ const m = [];
2736
+ for (let p = d; p < h; p += u)
2737
+ this._trace(we(p, e), r, n, s, o, i, !0).forEach((g) => {
2738
+ m.push(g);
2739
+ });
2740
+ return m;
2741
+ };
2742
+ C.prototype._eval = function(t, e, r, n, s, o) {
2743
+ this.currSandbox._$_parentProperty = o, this.currSandbox._$_parent = s, this.currSandbox._$_property = r, this.currSandbox._$_root = this.json, this.currSandbox._$_v = e;
2744
+ const i = t.includes("@path");
2745
+ i && (this.currSandbox._$_path = C.toPathString(n.concat([r])));
2746
+ const a = this.currEval + "Script:" + t;
2747
+ if (!C.cache[a]) {
2748
+ let c = t.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
2749
+ if (i && (c = c.replaceAll("@path", "_$_path")), this.currEval === "safe" || this.currEval === !0 || this.currEval === void 0)
2750
+ C.cache[a] = new this.safeVm.Script(c);
2751
+ else if (this.currEval === "native")
2752
+ C.cache[a] = new this.vm.Script(c);
2753
+ else if (typeof this.currEval == "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
2754
+ const u = this.currEval;
2755
+ C.cache[a] = new u(c);
2756
+ } else if (typeof this.currEval == "function")
2757
+ C.cache[a] = {
2758
+ runInNewContext: (u) => this.currEval(c, u)
2759
+ };
2760
+ else
2761
+ throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
2762
+ }
2763
+ try {
2764
+ return C.cache[a].runInNewContext(this.currSandbox);
2765
+ } catch (c) {
2766
+ if (this.ignoreEvalErrors)
2767
+ return !1;
2768
+ throw new Error("jsonPath: " + c.message + ": " + t);
2769
+ }
2770
+ };
2771
+ C.cache = {};
2772
+ C.toPathString = function(t) {
2773
+ const e = t, r = e.length;
2774
+ let n = "$";
2775
+ for (let s = 1; s < r; s++)
2776
+ /^(~|\^|@.*?\(\))$/u.test(e[s]) || (n += /^[0-9*]+$/u.test(e[s]) ? "[" + e[s] + "]" : "['" + e[s] + "']");
2777
+ return n;
2778
+ };
2779
+ C.toPointer = function(t) {
2780
+ const e = t, r = e.length;
2781
+ let n = "";
2782
+ for (let s = 1; s < r; s++)
2783
+ /^(~|\^|@.*?\(\))$/u.test(e[s]) || (n += "/" + e[s].toString().replaceAll("~", "~0").replaceAll("/", "~1"));
2784
+ return n;
2785
+ };
2786
+ C.toPathArray = function(t) {
2787
+ const {
2788
+ cache: e
2789
+ } = C;
2790
+ if (e[t])
2791
+ return e[t].concat();
2792
+ const r = [], s = t.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function(o, i) {
2793
+ return "[#" + (r.push(i) - 1) + "]";
2794
+ }).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function(o, i) {
2795
+ return "['" + i.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
2796
+ }).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function(o, i) {
2797
+ return ";" + i.split("").join(";") + ";";
2798
+ }).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "").split(";").map(function(o) {
2799
+ const i = o.match(/#(\d+)/u);
2800
+ return !i || !i[1] ? o : r[i[1]];
2801
+ });
2802
+ return e[t] = s, e[t].concat();
2803
+ };
2804
+ C.prototype.safeVm = {
2805
+ Script: kr
2806
+ };
2807
+ const Rr = function(t, e, r) {
2808
+ const n = t.length;
2809
+ for (let s = 0; s < n; s++) {
2810
+ const o = t[s];
2811
+ r(o) && e.push(t.splice(s--, 1)[0]);
2812
+ }
2813
+ };
2814
+ class Ir {
2815
+ /**
2816
+ * @param {string} expr Expression to evaluate
2817
+ */
2818
+ constructor(e) {
2819
+ this.code = e;
2820
+ }
2821
+ /**
2822
+ * @param {object} context Object whose items will be added
2823
+ * to evaluation
2824
+ * @returns {EvaluatedResult} Result of evaluated code
2825
+ */
2826
+ runInNewContext(e) {
2827
+ let r = this.code;
2828
+ const n = Object.keys(e), s = [];
2829
+ Rr(n, s, (u) => typeof e[u] == "function");
2830
+ const o = n.map((u) => e[u]);
2831
+ r = s.reduce((u, d) => {
2832
+ let h = e[d].toString();
2833
+ return /function/u.test(h) || (h = "function " + h), "var " + d + "=" + h + ";" + u;
2834
+ }, "") + r, !/(['"])use strict\1/u.test(r) && !n.includes("arguments") && (r = "var arguments = undefined;" + r), r = r.replace(/;\s*$/u, "");
2835
+ const a = r.lastIndexOf(";"), c = a !== -1 ? r.slice(0, a + 1) + " return " + r.slice(a + 1) : " return " + r;
2836
+ return new Function(...n, c)(...o);
2837
+ }
2838
+ }
2839
+ C.prototype.vm = {
2840
+ Script: Ir
2841
+ };
2842
+ function Te(t, e, r) {
2843
+ const n = e.replace(/^\$\.?/, "").split(/\.|\[|\]/).filter(Boolean);
2844
+ let s = t;
2845
+ for (let i = 0; i < n.length - 1; i++) {
2846
+ const a = n[i], c = n[i + 1], u = /^\d+$/.test(c);
2847
+ if (a === "__proto__" || a === "constructor" || a === "prototype")
2848
+ throw new Error("Invalid path part: " + a);
2849
+ if (a in s || (s[a] = u ? [] : {}), u) {
2850
+ const d = parseInt(c, 10);
2851
+ Array.isArray(s[a]) || (s[a] = []), s[a].length <= d && (s[a][d] = i === n.length - 2 ? r : {}), s = s[a][d], i++;
2852
+ } else
2853
+ s = s[a];
2854
+ }
2855
+ const o = n[n.length - 1];
2856
+ if (o === "__proto__" || o === "constructor" || o === "prototype")
2857
+ throw new Error("Invalid path part: " + o);
2858
+ if (/^\d+$/.test(o)) {
2859
+ const i = parseInt(o, 10);
2860
+ Array.isArray(s) || (s = []), s[i] = r;
2861
+ } else
2862
+ s[o] = r;
2863
+ }
2864
+ const Xr = (t, e, r) => {
2865
+ const n = {
2866
+ type: e.type,
2867
+ item: e.type === "single" ? {} : void 0,
2868
+ list: e.type === "list" ? [] : void 0
2869
+ }, s = (i, a) => {
2870
+ let c = i;
2871
+ return a.patchSource === "value" ? a.value ?? a.defaultValue ?? null : (a.patchSource === "child" && (c = r), (a.type === "single" ? C({ path: a.fromPath, json: c, resultType: "value" }) : C({ path: a.fromPath, json: c })) ?? a.defaultValue ?? null);
2872
+ }, o = e.type === "single" ? C({ path: e.fromPath, json: t, resultType: "value" }) : C({ path: e.fromPath, json: t });
2873
+ return e.type === "single" ? e.patches.forEach((i) => {
2874
+ const a = s(o, i);
2875
+ Te(n.item, i.toPath, a);
2876
+ }) : e.type === "list" && (n.list = o.map((i) => {
2877
+ const a = {};
2878
+ return e.patches.forEach((c) => {
2879
+ const u = s(i, c);
2880
+ Te(a, c.toPath, u);
2881
+ }), a;
2882
+ })), n;
2883
+ };
2884
+ function Mr(t, e) {
2885
+ const r = {};
2886
+ return !t.events || !Object.keys(t.events).length || Object.entries(t.events).forEach(([n, s]) => {
2887
+ s?.trim() && (r[n] = (...o) => {
2888
+ try {
2889
+ new Function("ctx", "craftNode", "args", s)(e, t, ...o);
2890
+ } catch (i) {
2891
+ console.error(`Event code execution failed with code:
2892
+ ${s}
2893
+
2894
+ Error:`, i);
2895
+ }
2896
+ });
2897
+ }), r;
2898
+ }
2899
+ function Tr(t, e, r = "default") {
2900
+ if (!t.slots || !t.slots[r]) return [];
2901
+ const n = t.slots[r];
2902
+ return e.type === "single" ? n.map((s) => ({
2903
+ ...s,
2904
+ uuid: `${s.uuid}-single`,
2905
+ props: { ...s.props, ...e.item || {} }
2906
+ })) : e.type === "list" && e.list ? n.flatMap(
2907
+ (s) => e.list.map((o, i) => ({
2908
+ ...s,
2909
+ uuid: `${s.uuid}-data-${i}`,
2910
+ props: { ...s.props, ...o || {} }
2911
+ }))
2912
+ ) : [];
2913
+ }
2914
+ function _e(t, e, r, n, s) {
2915
+ if (!ze(t))
2916
+ return null;
2917
+ const o = e.resolveNode(t), i = o?.componentName || t.componentName, a = r?.[i] || i, c = {
2918
+ ...o?.defaultProps || {},
2919
+ ...t.props
2920
+ }, u = s ? Mr(t, s) : {}, d = n?.[t.uuid];
2921
+ let h;
2922
+ return d?.type ? h = Tr(t, d, d.slotName || "default").map((p) => _e(p, e, r, n, s)).filter((p) => p !== null) : t.slots && (h = Object.values(t.slots).flat().map((m) => _e(m, e, r, n, s)).filter((m) => m !== null)), pt(a, { key: t.uuid, ...c, ...u }, h);
2923
+ }
2924
+ function zr(t, e) {
2925
+ const r = new ye(e.resolverMap);
2926
+ return t.map(
2927
+ (n) => _e(
2928
+ n,
2929
+ r,
2930
+ e.componentRegistry,
2931
+ e.nodeDataMap,
2932
+ e.eventsContext
2933
+ )
2934
+ ).filter((n) => n !== null);
2935
+ }
2936
+ const qr = {
2937
+ CraftComponentSimpleText: {
2938
+ componentName: "CraftComponentSimpleText",
2939
+ eventsSchema: {
2940
+ $el: "div",
2941
+ children: [
2942
+ {
2943
+ $formkit: "textarea",
2944
+ name: "click",
2945
+ label: "onClick"
2946
+ }
2947
+ ]
2948
+ },
2949
+ propsSchema: [
2950
+ {
2951
+ $formkit: "select",
2952
+ label: "Type",
2953
+ name: "componentName",
2954
+ options: [
2955
+ "h1",
2956
+ "h2",
2957
+ "h3",
2958
+ "h4",
2959
+ "h5",
2960
+ "h6",
2961
+ "p",
2962
+ "span",
2963
+ "div",
2964
+ "blockquote"
2965
+ ]
2966
+ },
2967
+ {
2968
+ $formkit: "textarea",
2969
+ label: "Content",
2970
+ name: "content"
2971
+ },
2972
+ {
2973
+ $formkit: "text",
2974
+ label: "Class",
2975
+ name: "class"
2976
+ }
2977
+ ]
2978
+ },
2979
+ CraftCanvas: {
2980
+ componentName: "CraftCanvas"
2981
+ }
2982
+ }, Ur = (t) => {
2983
+ for (const e in Ie)
2984
+ t.component(e, Ie[e]);
2985
+ }, Wr = { install: Ur };
2986
+ export {
2987
+ vt as CraftCanvas,
2988
+ Et as CraftComponentSimpleText,
2989
+ Ct as CraftEditor,
2990
+ wt as CraftEditorBlueprint,
2991
+ At as CraftEditorBlueprintsList,
2992
+ $t as CraftEditorPanelBlueprints,
2993
+ Rt as CraftEditorPanelForm,
2994
+ Bt as CraftEditorPanelLayers,
2995
+ Xt as CraftEditorPanelLayout,
2996
+ qt as CraftEditorPanelNodeEventsSettings,
2997
+ Zt as CraftEditorPanelNodeLayer,
2998
+ er as CraftEditorPanelNodeSettings,
2999
+ ir as CraftEditorPanelSettings,
3000
+ cr as CraftFrame,
3001
+ Qe as CraftIframe,
3002
+ br as CraftNodeEditor,
3003
+ ye as CraftNodeResolver,
3004
+ ve as CraftNodeViewer,
3005
+ Er as CraftStaticRenderer,
3006
+ _t as Utils,
3007
+ Wr as VCraft,
3008
+ We as buildCraftNodeTree,
3009
+ ie as craftNodeCanBeChildOf,
3010
+ pe as craftNodeCanBeSiblingOf,
3011
+ gt as craftNodeInCanvas,
3012
+ qe as craftNodeIsAncestorOf,
3013
+ q as craftNodeIsCanvas,
3014
+ yt as craftNodeIsDraggable,
3015
+ Vr as defaultBlueprints,
3016
+ qr as defaultResolvers,
3017
+ ze as isVisible,
3018
+ Xr as mapData,
3019
+ _e as renderCraftNodeToVNode,
3020
+ zr as renderCraftNodesToVNodes,
3021
+ te as resolveNodeName,
3022
+ mt as useCraftNode,
3023
+ j as useEditor,
3024
+ Se as useIndicator,
3025
+ xe as useResolveCraftNode
3026
+ };
3027
+ //# sourceMappingURL=v-craft.es.js.map