@nightshadeui/canvas 3.1.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/canvas.mjs CHANGED
@@ -1,2147 +1,2033 @@
1
- import { openBlock as U, createElementBlock as q, createElementVNode as j, normalizeStyle as Z, createCommentVNode as Me, resolveComponent as ot, createBlock as Kt, withCtx as G, createVNode as F, toDisplayString as X, withModifiers as B, normalizeClass as Oe, renderSlot as it, normalizeProps as Pe, guardReactiveProps as Ce, Fragment as je, renderList as _e, markRaw as Ee, reactive as Ie } from "vue";
2
- const tt = (r, t) => {
3
- const e = r.__vccOpts || r;
4
- for (const [n, o] of t)
5
- e[n] = o;
6
- return e;
7
- }, Te = {
8
- props: {
9
- canvas: { type: Object, required: !0 }
10
- }
11
- }, ze = {
12
- key: 0,
13
- class: "CanvasBoxSelect tone-primary"
1
+ import { Fragment as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createVNode as a, guardReactiveProps as o, markRaw as s, normalizeClass as c, normalizeProps as l, normalizeStyle as u, openBlock as d, reactive as f, renderList as p, renderSlot as m, resolveComponent as h, toDisplayString as g, withCtx as _, withModifiers as v } from "vue";
2
+ // \0rolldown/runtime.js
3
+ var ee = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), y = (e, t) => {
4
+ let n = e.__vccOpts || e;
5
+ for (let [e, r] of t) n[e] = r;
6
+ return n;
7
+ }, te = { props: { canvas: {
8
+ type: Object,
9
+ required: !0
10
+ } } }, ne = {
11
+ key: 0,
12
+ class: "CanvasBoxSelect tone-primary"
14
13
  };
15
- function Re(r, t, e, n, o, l) {
16
- return e.canvas.boxSelect.isSelecting() ? (U(), q("div", ze, [
17
- j("div", {
18
- class: "Box",
19
- style: Z(e.canvas.boxSelect.getSelectionStyle())
20
- }, null, 4)
21
- ])) : Me("", !0);
14
+ function re(e, t, a, o, s, c) {
15
+ return a.canvas.boxSelect.isSelecting() ? (d(), r("div", ne, [i("div", {
16
+ class: "Box",
17
+ style: u(a.canvas.boxSelect.getSelectionStyle())
18
+ }, null, 4)])) : n("", !0);
22
19
  }
23
- const De = /* @__PURE__ */ tt(Te, [["render", Re], ["__scopeId", "data-v-d6539bbd"]]), ke = {
24
- props: {
25
- canvas: { type: Object, required: !0 }
26
- },
27
- computed: {
28
- pagePos() {
29
- return this.canvas.inputStateManager.lastMousePos;
30
- },
31
- viewportPos() {
32
- return this.canvas.space.pageToViewport(this.pagePos);
33
- },
34
- canvasPos() {
35
- return this.canvas.space.pageToCanvas(this.pagePos);
36
- },
37
- localPos() {
38
- return this.canvas.space.pageToLocal(this.pagePos);
39
- }
40
- },
41
- methods: {
42
- format(r) {
43
- return `(${r.x.toFixed(2)}, ${r.y.toFixed(2)})`;
44
- }
45
- }
20
+ var b = /*#__PURE__*/ y(te, [["render", re], ["__scopeId", "data-v-d6539bbd"]]), ie = {
21
+ props: { canvas: {
22
+ type: Object,
23
+ required: !0
24
+ } },
25
+ computed: {
26
+ pagePos() {
27
+ return this.canvas.inputStateManager.lastMousePos;
28
+ },
29
+ viewportPos() {
30
+ return this.canvas.space.pageToViewport(this.pagePos);
31
+ },
32
+ canvasPos() {
33
+ return this.canvas.space.pageToCanvas(this.pagePos);
34
+ },
35
+ localPos() {
36
+ return this.canvas.space.pageToLocal(this.pagePos);
37
+ }
38
+ },
39
+ methods: { format(e) {
40
+ return `(${e.x.toFixed(2)}, ${e.y.toFixed(2)})`;
41
+ } }
46
42
  };
47
- function Be(r, t, e, n, o, l) {
48
- const g = ot("HGroup"), p = ot("VGroup");
49
- return U(), Kt(p, {
50
- class: "CanvasDebugCoords",
51
- gap: "s"
52
- }, {
53
- default: G(() => [
54
- F(g, { class: "Row" }, {
55
- default: G(() => [
56
- t[0] || (t[0] = j("strong", null, "page", -1)),
57
- j("span", null, X(l.format(l.pagePos)), 1)
58
- ]),
59
- _: 1
60
- }),
61
- F(g, { class: "Row" }, {
62
- default: G(() => [
63
- t[1] || (t[1] = j("strong", null, "viewport", -1)),
64
- j("span", null, X(l.format(l.viewportPos)), 1)
65
- ]),
66
- _: 1
67
- }),
68
- F(g, { class: "Row" }, {
69
- default: G(() => [
70
- t[2] || (t[2] = j("strong", null, "canvas", -1)),
71
- j("span", null, X(l.format(l.canvasPos)), 1)
72
- ]),
73
- _: 1
74
- }),
75
- F(g, { class: "Row" }, {
76
- default: G(() => [
77
- t[3] || (t[3] = j("strong", null, "local", -1)),
78
- j("span", null, X(l.format(l.localPos)), 1)
79
- ]),
80
- _: 1
81
- }),
82
- F(g, { class: "Row" }, {
83
- default: G(() => [
84
- t[4] || (t[4] = j("strong", null, "zoom", -1)),
85
- j("span", null, X(e.canvas.space.zoom.toFixed(2)), 1)
86
- ]),
87
- _: 1
88
- })
89
- ]),
90
- _: 1
91
- });
43
+ function ae(e, n, r, o, s, c) {
44
+ let l = h("HGroup"), u = h("VGroup");
45
+ return d(), t(u, {
46
+ class: "CanvasDebugCoords",
47
+ gap: "s"
48
+ }, {
49
+ default: _(() => [
50
+ a(l, { class: "Row" }, {
51
+ default: _(() => [n[0] ||= i("strong", null, "page", -1), i("span", null, g(c.format(c.pagePos)), 1)]),
52
+ _: 1
53
+ }),
54
+ a(l, { class: "Row" }, {
55
+ default: _(() => [n[1] ||= i("strong", null, "viewport", -1), i("span", null, g(c.format(c.viewportPos)), 1)]),
56
+ _: 1
57
+ }),
58
+ a(l, { class: "Row" }, {
59
+ default: _(() => [n[2] ||= i("strong", null, "canvas", -1), i("span", null, g(c.format(c.canvasPos)), 1)]),
60
+ _: 1
61
+ }),
62
+ a(l, { class: "Row" }, {
63
+ default: _(() => [n[3] ||= i("strong", null, "local", -1), i("span", null, g(c.format(c.localPos)), 1)]),
64
+ _: 1
65
+ }),
66
+ a(l, { class: "Row" }, {
67
+ default: _(() => [n[4] ||= i("strong", null, "zoom", -1), i("span", null, g(r.canvas.space.zoom.toFixed(2)), 1)]),
68
+ _: 1
69
+ })
70
+ ]),
71
+ _: 1
72
+ });
92
73
  }
93
- const ws = /* @__PURE__ */ tt(ke, [["render", Be], ["__scopeId", "data-v-30d3c083"]]), Ue = {
94
- props: {
95
- canvasObject: { type: Object, required: !0 },
96
- direction: { type: String, required: !0 }
97
- }
98
- };
99
- function Ve(r, t, e, n, o, l) {
100
- return U(), q("div", {
101
- class: Oe(["ResizeHandle", `ResizeHandle-${e.direction}`]),
102
- onUidragstart: t[0] || (t[0] = B((g) => e.canvasObject.startResizing(e.direction), ["stop", "prevent"])),
103
- onUidragmove: t[1] || (t[1] = B((...g) => e.canvasObject.onResizeMove && e.canvasObject.onResizeMove(...g), ["stop", "prevent"])),
104
- onUidragend: t[2] || (t[2] = B((...g) => e.canvasObject.onResizeEnd && e.canvasObject.onResizeEnd(...g), ["stop", "prevent"]))
105
- }, null, 34);
74
+ var oe = /*#__PURE__*/ y(ie, [["render", ae], ["__scopeId", "data-v-30d3c083"]]), se = { props: {
75
+ canvasObject: {
76
+ type: Object,
77
+ required: !0
78
+ },
79
+ direction: {
80
+ type: String,
81
+ required: !0
82
+ }
83
+ } };
84
+ function x(e, t, n, i, a, o) {
85
+ return d(), r("div", {
86
+ class: c(["ResizeHandle", `ResizeHandle-${n.direction}`]),
87
+ onUidragstart: t[0] ||= v((e) => n.canvasObject.startResizing(n.direction), ["stop", "prevent"]),
88
+ onUidragmove: t[1] ||= v((...e) => n.canvasObject.onResizeMove && n.canvasObject.onResizeMove(...e), ["stop", "prevent"]),
89
+ onUidragend: t[2] ||= v((...e) => n.canvasObject.onResizeEnd && n.canvasObject.onResizeEnd(...e), ["stop", "prevent"])
90
+ }, null, 34);
106
91
  }
107
- const Le = /* @__PURE__ */ tt(Ue, [["render", Ve], ["__scopeId", "data-v-8e1eca30"]]), Ae = {
108
- components: {
109
- CanvasObjectResize: Le
110
- },
111
- props: {
112
- canvas: { type: Object, required: !0 },
113
- objectId: { type: String, required: !0 },
114
- pos: { type: Object, required: !0 },
115
- isSelected: { type: Boolean, default: !1 },
116
- selectable: { type: Boolean, default: !0 },
117
- movable: { type: Boolean, default: !0 },
118
- snapToGrid: { type: Boolean, default: !0 },
119
- resizable: { type: String, default: "none" },
120
- bounds: { type: Array }
121
- },
122
- emits: [
123
- "update:pos",
124
- "update:isSelected"
125
- ],
126
- data() {
127
- return {
128
- canvasObject: null
129
- };
130
- },
131
- computed: {
132
- coords() {
133
- return this.canvasObject.getCanvasCoords();
134
- },
135
- slotProps() {
136
- return {
137
- canvas: this.canvas,
138
- objectId: this.objectId,
139
- isSelected: this.canvas.selection.isSelected(this.objectId),
140
- coords: this.coords,
141
- pos: this.pos
142
- };
143
- },
144
- resizeDirections() {
145
- return this.canvasObject.getResizeDirections();
146
- }
147
- },
148
- watch: {
149
- pos(r) {
150
- this.canvasObject.setPos(r);
151
- },
152
- isSelected(r) {
153
- this.canvasObject.setSelected(r);
154
- },
155
- selectable(r) {
156
- this.canvasObject.setSelectable(r);
157
- },
158
- movable(r) {
159
- this.canvasObject.setMovable(r);
160
- },
161
- snapToGrid(r) {
162
- this.canvasObject.setSnapToGrid(r);
163
- },
164
- resizable(r) {
165
- this.canvasObject.setResizable(r);
166
- },
167
- bounds(r) {
168
- this.canvasObject.setBounds(r);
169
- }
170
- },
171
- created() {
172
- this.canvasObject = this.canvas.createObjectController(this.objectId), this.canvas.events.objectPosUpdated.on(({ objectId: r, pos: t }) => {
173
- r === this.objectId && this.$emit("update:pos", t);
174
- }, this), this.canvas.events.selectionChanged.on((r) => {
175
- const t = r.includes(this.objectId);
176
- this.isSelected !== t && this.$emit("update:isSelected", t);
177
- }, this);
178
- },
179
- mounted() {
180
- const r = this.canvasObject;
181
- this.canvas.objectRegistry.register(r), r.setElement(this.$refs.rootEl), r.setPos(this.pos), r.setSelectable(this.selectable), r.setMovable(this.movable), r.setSnapToGrid(this.snapToGrid), r.setResizable(this.resizable), r.setBounds(this.bounds), r.setSelected(this.isSelected);
182
- },
183
- unmounted() {
184
- this.canvas.objectRegistry.unregister(this.objectId), this.canvasObject.setElement(null), this.canvas.selection.removeFromSelection(this.objectId), this.canvas.events.objectPosUpdated.removeAll(this), this.canvas.events.selectionChanged.removeAll(this);
185
- }
92
+ // src/components/CanvasObject.vue
93
+ var S = {
94
+ components: { CanvasObjectResize: /* @__PURE__ */ y(se, [["render", x], ["__scopeId", "data-v-8e1eca30"]]) },
95
+ props: {
96
+ canvas: {
97
+ type: Object,
98
+ required: !0
99
+ },
100
+ objectId: {
101
+ type: String,
102
+ required: !0
103
+ },
104
+ pos: {
105
+ type: Object,
106
+ required: !0
107
+ },
108
+ isSelected: {
109
+ type: Boolean,
110
+ default: !1
111
+ },
112
+ selectable: {
113
+ type: Boolean,
114
+ default: !0
115
+ },
116
+ movable: {
117
+ type: Boolean,
118
+ default: !0
119
+ },
120
+ snapToGrid: {
121
+ type: Boolean,
122
+ default: !0
123
+ },
124
+ resizable: {
125
+ type: String,
126
+ default: "none"
127
+ },
128
+ bounds: { type: Array }
129
+ },
130
+ emits: ["update:pos", "update:isSelected"],
131
+ data() {
132
+ return { canvasObject: null };
133
+ },
134
+ computed: {
135
+ coords() {
136
+ return this.canvasObject.getCanvasCoords();
137
+ },
138
+ slotProps() {
139
+ return {
140
+ canvas: this.canvas,
141
+ objectId: this.objectId,
142
+ isSelected: this.canvas.selection.isSelected(this.objectId),
143
+ coords: this.coords,
144
+ pos: this.pos
145
+ };
146
+ },
147
+ resizeDirections() {
148
+ return this.canvasObject.getResizeDirections();
149
+ }
150
+ },
151
+ watch: {
152
+ pos(e) {
153
+ this.canvasObject.setPos(e);
154
+ },
155
+ isSelected(e) {
156
+ this.canvasObject.setSelected(e);
157
+ },
158
+ selectable(e) {
159
+ this.canvasObject.setSelectable(e);
160
+ },
161
+ movable(e) {
162
+ this.canvasObject.setMovable(e);
163
+ },
164
+ snapToGrid(e) {
165
+ this.canvasObject.setSnapToGrid(e);
166
+ },
167
+ resizable(e) {
168
+ this.canvasObject.setResizable(e);
169
+ },
170
+ bounds(e) {
171
+ this.canvasObject.setBounds(e);
172
+ }
173
+ },
174
+ created() {
175
+ this.canvasObject = this.canvas.createObjectController(this.objectId), this.canvas.events.objectPosUpdated.on(({ objectId: e, pos: t }) => {
176
+ e === this.objectId && this.$emit("update:pos", t);
177
+ }, this), this.canvas.events.selectionChanged.on((e) => {
178
+ let t = e.includes(this.objectId);
179
+ this.isSelected !== t && this.$emit("update:isSelected", t);
180
+ }, this);
181
+ },
182
+ mounted() {
183
+ let e = this.canvasObject;
184
+ this.canvas.objectRegistry.register(e), e.setElement(this.$refs.rootEl), e.setPos(this.pos), e.setSelectable(this.selectable), e.setMovable(this.movable), e.setSnapToGrid(this.snapToGrid), e.setResizable(this.resizable), e.setBounds(this.bounds), e.setSelected(this.isSelected);
185
+ },
186
+ unmounted() {
187
+ this.canvas.objectRegistry.unregister(this.objectId), this.canvasObject.setElement(null), this.canvas.selection.removeFromSelection(this.objectId), this.canvas.events.objectPosUpdated.removeAll(this), this.canvas.events.selectionChanged.removeAll(this);
188
+ }
186
189
  };
187
- function Ge(r, t, e, n, o, l) {
188
- const g = ot("CanvasObjectResize");
189
- return U(), q("div", {
190
- ref: "rootEl",
191
- class: "CanvasObject",
192
- style: Z(o.canvasObject.getStyle()),
193
- onUiclick: t[0] || (t[0] = B((...p) => o.canvasObject.onUiClick && o.canvasObject.onUiClick(...p), ["stop", "prevent"])),
194
- onUidragstart: t[1] || (t[1] = B((...p) => o.canvasObject.onUiDragStart && o.canvasObject.onUiDragStart(...p), ["stop", "prevent"])),
195
- onUidragmove: t[2] || (t[2] = B((...p) => o.canvasObject.onUiDragMove && o.canvasObject.onUiDragMove(...p), ["stop", "prevent"])),
196
- onUidragend: t[3] || (t[3] = B((...p) => o.canvasObject.onUiDragEnd && o.canvasObject.onUiDragEnd(...p), ["stop", "prevent"]))
197
- }, [
198
- it(r.$slots, "default", Pe(Ce(l.slotProps))),
199
- (U(!0), q(je, null, _e(l.resizeDirections, (p) => (U(), Kt(g, {
200
- key: p,
201
- canvasObject: o.canvasObject,
202
- direction: p
203
- }, null, 8, ["canvasObject", "direction"]))), 128))
204
- ], 36);
190
+ function C(n, i, a, s, c, f) {
191
+ let g = h("CanvasObjectResize");
192
+ return d(), r("div", {
193
+ ref: "rootEl",
194
+ class: "CanvasObject",
195
+ style: u(c.canvasObject.getStyle()),
196
+ onUiclick: i[0] ||= v((...e) => c.canvasObject.onUiClick && c.canvasObject.onUiClick(...e), ["stop", "prevent"]),
197
+ onUidragstart: i[1] ||= v((...e) => c.canvasObject.onUiDragStart && c.canvasObject.onUiDragStart(...e), ["stop", "prevent"]),
198
+ onUidragmove: i[2] ||= v((...e) => c.canvasObject.onUiDragMove && c.canvasObject.onUiDragMove(...e), ["stop", "prevent"]),
199
+ onUidragend: i[3] ||= v((...e) => c.canvasObject.onUiDragEnd && c.canvasObject.onUiDragEnd(...e), ["stop", "prevent"])
200
+ }, [m(n.$slots, "default", l(o(f.slotProps))), (d(!0), r(e, null, p(f.resizeDirections, (e) => (d(), t(g, {
201
+ key: e,
202
+ canvasObject: c.canvasObject,
203
+ direction: e
204
+ }, null, 8, ["canvasObject", "direction"]))), 128))], 36);
205
205
  }
206
- const ms = /* @__PURE__ */ tt(Ae, [["render", Ge]]), $e = {
207
- components: {
208
- CanvasBoxSelect: De
209
- },
210
- props: {
211
- canvas: { type: Object, required: !0 }
212
- },
213
- mounted() {
214
- this.canvas.mount(this.$refs.viewport);
215
- },
216
- unmounted() {
217
- this.canvas.unmount();
218
- },
219
- methods: {
220
- onCanvasUiClick() {
221
- this.canvas.selection.deselectAll();
222
- }
223
- }
224
- }, Fe = { class: "CanvasView" };
225
- function Ke(r, t, e, n, o, l) {
226
- const g = ot("CanvasBoxSelect");
227
- return U(), q("div", Fe, [
228
- j("div", {
229
- ref: "viewport",
230
- class: "Viewport",
231
- onMousedown: t[0] || (t[0] = (...p) => e.canvas.pan.onMouseDown && e.canvas.pan.onMouseDown(...p)),
232
- onUidragstart: t[1] || (t[1] = (...p) => e.canvas.boxSelect.onUiDragStart && e.canvas.boxSelect.onUiDragStart(...p)),
233
- onUidragmove: t[2] || (t[2] = (...p) => e.canvas.boxSelect.onUiDragMove && e.canvas.boxSelect.onUiDragMove(...p)),
234
- onUidragend: t[3] || (t[3] = (...p) => e.canvas.boxSelect.onUiDragEnd && e.canvas.boxSelect.onUiDragEnd(...p)),
235
- onUiclick: t[4] || (t[4] = (...p) => l.onCanvasUiClick && l.onCanvasUiClick(...p)),
236
- onScroll: t[5] || (t[5] = (...p) => e.canvas.viewport.onScroll && e.canvas.viewport.onScroll(...p)),
237
- onWheel: t[6] || (t[6] = (...p) => e.canvas.zoom.onWheel && e.canvas.zoom.onWheel(...p))
238
- }, [
239
- j("div", {
240
- class: "Sizer",
241
- style: Z(e.canvas.viewport.getSizerStyle())
242
- }, null, 4),
243
- j("div", {
244
- class: "Canvas",
245
- style: Z(e.canvas.viewport.getCanvasStyle())
246
- }, [
247
- it(r.$slots, "default", {}, void 0, !0),
248
- j("div", {
249
- class: "Origin",
250
- style: Z(e.canvas.viewport.getOriginStyle())
251
- }, [
252
- it(r.$slots, "origin", {}, void 0, !0)
253
- ], 4)
254
- ], 4),
255
- F(g, { canvas: e.canvas }, null, 8, ["canvas"])
256
- ], 544),
257
- it(r.$slots, "overlays", {}, void 0, !0)
258
- ]);
206
+ var w = /*#__PURE__*/ y(S, [["render", C]]), ce = {
207
+ components: { CanvasBoxSelect: b },
208
+ props: { canvas: {
209
+ type: Object,
210
+ required: !0
211
+ } },
212
+ mounted() {
213
+ this.canvas.mount(this.$refs.viewport);
214
+ },
215
+ unmounted() {
216
+ this.canvas.unmount();
217
+ },
218
+ methods: { onCanvasUiClick() {
219
+ this.canvas.selection.deselectAll();
220
+ } }
221
+ }, le = { class: "CanvasView" };
222
+ function ue(e, t, n, o, s, c) {
223
+ let l = h("CanvasBoxSelect");
224
+ return d(), r("div", le, [i("div", {
225
+ ref: "viewport",
226
+ class: "Viewport",
227
+ onMousedown: t[0] ||= (...e) => n.canvas.pan.onMouseDown && n.canvas.pan.onMouseDown(...e),
228
+ onUidragstart: t[1] ||= (...e) => n.canvas.boxSelect.onUiDragStart && n.canvas.boxSelect.onUiDragStart(...e),
229
+ onUidragmove: t[2] ||= (...e) => n.canvas.boxSelect.onUiDragMove && n.canvas.boxSelect.onUiDragMove(...e),
230
+ onUidragend: t[3] ||= (...e) => n.canvas.boxSelect.onUiDragEnd && n.canvas.boxSelect.onUiDragEnd(...e),
231
+ onUiclick: t[4] ||= (...e) => c.onCanvasUiClick && c.onCanvasUiClick(...e),
232
+ onScroll: t[5] ||= (...e) => n.canvas.viewport.onScroll && n.canvas.viewport.onScroll(...e),
233
+ onWheel: t[6] ||= (...e) => n.canvas.zoom.onWheel && n.canvas.zoom.onWheel(...e)
234
+ }, [
235
+ i("div", {
236
+ class: "Sizer",
237
+ style: u(n.canvas.viewport.getSizerStyle())
238
+ }, null, 4),
239
+ i("div", {
240
+ class: "Canvas",
241
+ style: u(n.canvas.viewport.getCanvasStyle())
242
+ }, [m(e.$slots, "default", {}, void 0, !0), i("div", {
243
+ class: "Origin",
244
+ style: u(n.canvas.viewport.getOriginStyle())
245
+ }, [m(e.$slots, "origin", {}, void 0, !0)], 4)], 4),
246
+ a(l, { canvas: n.canvas }, null, 8, ["canvas"])
247
+ ], 544), m(e.$slots, "overlays", {}, void 0, !0)]);
259
248
  }
260
- const bs = /* @__PURE__ */ tt($e, [["render", Ke], ["__scopeId", "data-v-585857be"]]);
261
- function nt(r, t) {
262
- const e = { x: Math.min(r.x, t.x), y: Math.min(r.y, t.y) }, n = { x: Math.max(r.x, t.x), y: Math.max(r.y, t.y) };
263
- return [e, n];
249
+ var T = /*#__PURE__*/ y(ce, [["render", ue], ["__scopeId", "data-v-585857be"]]);
250
+ // ../util/out/box.js
251
+ function E(e, t) {
252
+ return [{
253
+ x: Math.min(e.x, t.x),
254
+ y: Math.min(e.y, t.y)
255
+ }, {
256
+ x: Math.max(e.x, t.x),
257
+ y: Math.max(e.y, t.y)
258
+ }];
264
259
  }
265
- function Bt(r, t) {
266
- const e = r[1].x >= t[0].x && t[1].x >= r[0].x, n = r[1].y >= t[0].y && t[1].y >= r[0].y;
267
- return e && n;
260
+ function D(e, t) {
261
+ let n = e[1].x >= t[0].x && t[1].x >= e[0].x, r = e[1].y >= t[0].y && t[1].y >= e[0].y;
262
+ return n && r;
268
263
  }
269
- let Ne = class {
270
- constructor(t) {
271
- this.target = t, this.entries = [];
272
- }
273
- add(t, e, n) {
274
- this.target.addEventListener(t, e, n), this.entries.push({ type: t, listener: e, options: n });
275
- }
276
- removeAll() {
277
- for (const t of this.entries)
278
- this.target.removeEventListener(t.type, t.listener, t.options);
279
- this.entries = [];
280
- }
264
+ // ../util/out/dom/DomEventProxy.js
265
+ var de = class {
266
+ constructor(e) {
267
+ this.target = e, this.entries = [];
268
+ }
269
+ add(e, t, n) {
270
+ this.target.addEventListener(e, t, n), this.entries.push({
271
+ type: e,
272
+ listener: t,
273
+ options: n
274
+ });
275
+ }
276
+ removeAll() {
277
+ for (let e of this.entries) this.target.removeEventListener(e.type, e.listener, e.options);
278
+ this.entries = [];
279
+ }
280
+ }, O = [
281
+ "button",
282
+ "a",
283
+ "input",
284
+ "textarea",
285
+ "select",
286
+ "[role=\"textbox\"]",
287
+ "[role=\"button\"]",
288
+ "[nodrag]"
289
+ ], k = class {
290
+ constructor() {
291
+ this.lastMousePos = {
292
+ x: window.innerWidth * .5,
293
+ y: window.innerHeight * .5
294
+ }, this.lmbPressed = !1, this.mmbPressed = !1, this.rmbPressed = !1, this.altKey = !1, this.ctrlKey = !1, this.metaKey = !1, this.shiftKey = !1, this.dragDistance = 4, this.windowEvents = new de(window), this.lastMouseDownPos = {
295
+ x: window.innerWidth * .5,
296
+ y: window.innerHeight * .5
297
+ }, this.lastMouseDownTarget = null, this.dragTarget = null, this.inClickVicinity = !1, this.listening = !1;
298
+ }
299
+ get ctrlOrMetaKey() {
300
+ return this.ctrlKey || this.metaKey;
301
+ }
302
+ mount() {
303
+ this.listening || (this.listening = !0, this.windowEvents.add("mousedown", (e) => this.onMouseDown(e)), this.windowEvents.add("mousemove", (e) => this.onMouseMove(e)), this.windowEvents.add("mouseup", (e) => this.onMouseUp(e)), this.windowEvents.add("keydown", (e) => this.onKeyDown(e)), this.windowEvents.add("keyup", (e) => this.onKeyUp(e)));
304
+ }
305
+ unmount() {
306
+ this.listening && (this.listening = !1, this.windowEvents.removeAll(), this.dragTarget = null, this.inClickVicinity = !1, this.lastMouseDownTarget = null);
307
+ }
308
+ onMouseDown(e) {
309
+ this.lastMousePos = {
310
+ x: e.pageX,
311
+ y: e.pageY
312
+ }, this.lmbPressed = e.button === 0, this.mmbPressed = e.button === 1, this.rmbPressed = e.button === 2, e.button === 0 && (this.lastMouseDownPos = {
313
+ x: e.pageX,
314
+ y: e.pageY
315
+ }, this.lastMouseDownTarget = e.target, this.inClickVicinity = !0);
316
+ }
317
+ onMouseMove(e) {
318
+ if (this.lastMousePos = {
319
+ x: e.pageX,
320
+ y: e.pageY
321
+ }, !this.lmbPressed) return;
322
+ if (this.dragTarget) {
323
+ this.dragTarget.dispatchEvent(this.cloneMouseEvent("uidragmove", e));
324
+ return;
325
+ }
326
+ if (!this.inClickVicinity || !this.lastMouseDownTarget) return;
327
+ let t = e.pageX - this.lastMouseDownPos.x, n = e.pageY - this.lastMouseDownPos.y;
328
+ Math.hypot(t, n) < this.dragDistance || (this.inClickVicinity = !1, this.isDragAllowed(this.lastMouseDownTarget) && (this.dragTarget = this.lastMouseDownTarget, this.dragTarget.dispatchEvent(this.cloneMouseEvent("uidragstart", e))));
329
+ }
330
+ onMouseUp(e) {
331
+ if (e.button === 0) {
332
+ let t = this.dragTarget, n = this.inClickVicinity, r = this.lastMouseDownTarget;
333
+ this.dragTarget = null, this.inClickVicinity = !1, this.lastMouseDownTarget = null, t && t.dispatchEvent(this.cloneMouseEvent("uidragend", e)), n && r && (r.dispatchEvent(this.cloneMouseEvent("uiclick", e)), this.dispatchActivate(r, e));
334
+ }
335
+ this.lastMousePos = {
336
+ x: e.pageX,
337
+ y: e.pageY
338
+ }, this.lmbPressed = !1, this.mmbPressed = !1, this.rmbPressed = !1;
339
+ }
340
+ onKeyDown(e) {
341
+ this.updateModifiers(e), (e.key === "Enter" || e.key === " ") && e.target && (e.target === document.body && e.key === " " && e.preventDefault(), this.dispatchActivate(e.target, e));
342
+ }
343
+ onKeyUp(e) {
344
+ this.updateModifiers(e);
345
+ }
346
+ updateModifiers(e) {
347
+ this.altKey = e.altKey, this.ctrlKey = e.ctrlKey, this.metaKey = e.metaKey, this.shiftKey = e.shiftKey;
348
+ }
349
+ dispatchActivate(e, t) {
350
+ e.closest(":disabled") || e.dispatchEvent(new CustomEvent("uiactivate", { detail: t }));
351
+ }
352
+ isDragAllowed(e) {
353
+ return e instanceof Element && !e.closest(O.join(","));
354
+ }
355
+ cloneMouseEvent(e, t) {
356
+ return new MouseEvent(e, {
357
+ bubbles: !0,
358
+ cancelable: !0,
359
+ clientX: t.clientX,
360
+ clientY: t.clientY,
361
+ screenX: t.screenX,
362
+ screenY: t.screenY,
363
+ button: t.button,
364
+ buttons: t.buttons,
365
+ ctrlKey: t.ctrlKey,
366
+ shiftKey: t.shiftKey,
367
+ altKey: t.altKey,
368
+ metaKey: t.metaKey
369
+ });
370
+ }
371
+ }, fe = /* @__PURE__ */ ee((() => {
372
+ var e;
373
+ (function(e) {
374
+ (function(t) {
375
+ var n = typeof globalThis == "object" ? globalThis : typeof global == "object" ? global : typeof self == "object" ? self : typeof this == "object" ? this : s(), r = i(e);
376
+ n.Reflect !== void 0 && (r = i(n.Reflect, r)), t(r, n), n.Reflect === void 0 && (n.Reflect = e);
377
+ function i(e, t) {
378
+ return function(n, r) {
379
+ Object.defineProperty(e, n, {
380
+ configurable: !0,
381
+ writable: !0,
382
+ value: r
383
+ }), t && t(n, r);
384
+ };
385
+ }
386
+ function a() {
387
+ try {
388
+ return Function("return this;")();
389
+ } catch {}
390
+ }
391
+ function o() {
392
+ try {
393
+ return (0, eval)("(function() { return this; })()");
394
+ } catch {}
395
+ }
396
+ function s() {
397
+ return a() || o();
398
+ }
399
+ })(function(e, t) {
400
+ var n = Object.prototype.hasOwnProperty, r = typeof Symbol == "function", i = r && Symbol.toPrimitive !== void 0 ? Symbol.toPrimitive : "@@toPrimitive", a = r && Symbol.iterator !== void 0 ? Symbol.iterator : "@@iterator", o = typeof Object.create == "function", s = { __proto__: [] } instanceof Array, c = !o && !s, l = {
401
+ create: o ? function() {
402
+ return J(Object.create(null));
403
+ } : s ? function() {
404
+ return J({ __proto__: null });
405
+ } : function() {
406
+ return J({});
407
+ },
408
+ has: c ? function(e, t) {
409
+ return n.call(e, t);
410
+ } : function(e, t) {
411
+ return t in e;
412
+ },
413
+ get: c ? function(e, t) {
414
+ return n.call(e, t) ? e[t] : void 0;
415
+ } : function(e, t) {
416
+ return e[t];
417
+ }
418
+ }, u = Object.getPrototypeOf(Function), d = typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : he(), f = typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : ge(), p = typeof WeakMap == "function" ? WeakMap : q(), m = r ? Symbol.for("@reflect-metadata:registry") : void 0, h = U(), g = W(h);
419
+ function _(e, t, n, r) {
420
+ if (E(n)) {
421
+ if (!M(e) || !me(t)) throw TypeError();
422
+ return oe(e, t);
423
+ }
424
+ if (!M(e) || !O(t) || !O(r) && !E(r) && !D(r)) throw TypeError();
425
+ return D(r) && (r = void 0), n = j(n), se(e, t, n, r);
426
+ }
427
+ e("decorate", _);
428
+ function v(e, t) {
429
+ function n(n, r) {
430
+ if (!O(n) || !E(r) && !P(r)) throw TypeError();
431
+ ce(e, t, n, r);
432
+ }
433
+ return n;
434
+ }
435
+ e("metadata", v);
436
+ function ee(e, t, n, r) {
437
+ if (!O(n)) throw TypeError();
438
+ return E(r) || (r = j(r)), ce(e, t, n, r);
439
+ }
440
+ e("defineMetadata", ee);
441
+ function y(e, t, n) {
442
+ if (!O(t)) throw TypeError();
443
+ return E(n) || (n = j(n)), x(e, t, n);
444
+ }
445
+ e("hasMetadata", y);
446
+ function te(e, t, n) {
447
+ if (!O(t)) throw TypeError();
448
+ return E(n) || (n = j(n)), S(e, t, n);
449
+ }
450
+ e("hasOwnMetadata", te);
451
+ function ne(e, t, n) {
452
+ if (!O(t)) throw TypeError();
453
+ return E(n) || (n = j(n)), C(e, t, n);
454
+ }
455
+ e("getMetadata", ne);
456
+ function re(e, t, n) {
457
+ if (!O(t)) throw TypeError();
458
+ return E(n) || (n = j(n)), w(e, t, n);
459
+ }
460
+ e("getOwnMetadata", re);
461
+ function b(e, t) {
462
+ if (!O(e)) throw TypeError();
463
+ return E(t) || (t = j(t)), le(e, t);
464
+ }
465
+ e("getMetadataKeys", b);
466
+ function ie(e, t) {
467
+ if (!O(e)) throw TypeError();
468
+ return E(t) || (t = j(t)), ue(e, t);
469
+ }
470
+ e("getOwnMetadataKeys", ie);
471
+ function ae(e, t, n) {
472
+ if (!O(t) || (E(n) || (n = j(n)), !O(t))) throw TypeError();
473
+ E(n) || (n = j(n));
474
+ var r = K(t, n, !1);
475
+ return !E(r) && r.OrdinaryDeleteMetadata(e, t, n);
476
+ }
477
+ e("deleteMetadata", ae);
478
+ function oe(e, t) {
479
+ for (var n = e.length - 1; n >= 0; --n) {
480
+ var r = e[n], i = r(t);
481
+ if (!E(i) && !D(i)) {
482
+ if (!me(i)) throw TypeError();
483
+ t = i;
484
+ }
485
+ }
486
+ return t;
487
+ }
488
+ function se(e, t, n, r) {
489
+ for (var i = e.length - 1; i >= 0; --i) {
490
+ var a = e[i], o = a(t, n, r);
491
+ if (!E(o) && !D(o)) {
492
+ if (!O(o)) throw TypeError();
493
+ r = o;
494
+ }
495
+ }
496
+ return r;
497
+ }
498
+ function x(e, t, n) {
499
+ if (S(e, t, n)) return !0;
500
+ var r = V(t);
501
+ return !D(r) && x(e, r, n);
502
+ }
503
+ function S(e, t, n) {
504
+ var r = K(t, n, !1);
505
+ return !E(r) && A(r.OrdinaryHasOwnMetadata(e, t, n));
506
+ }
507
+ function C(e, t, n) {
508
+ if (S(e, t, n)) return w(e, t, n);
509
+ var r = V(t);
510
+ if (!D(r)) return C(e, r, n);
511
+ }
512
+ function w(e, t, n) {
513
+ var r = K(t, n, !1);
514
+ if (!E(r)) return r.OrdinaryGetOwnMetadata(e, t, n);
515
+ }
516
+ function ce(e, t, n, r) {
517
+ K(n, r, !0).OrdinaryDefineOwnMetadata(e, t, n, r);
518
+ }
519
+ function le(e, t) {
520
+ var n = ue(e, t), r = V(e);
521
+ if (r === null) return n;
522
+ var i = le(r, t);
523
+ if (i.length <= 0) return n;
524
+ if (n.length <= 0) return i;
525
+ for (var a = new f(), o = [], s = 0, c = n; s < c.length; s++) {
526
+ var l = c[s], u = a.has(l);
527
+ u || (a.add(l), o.push(l));
528
+ }
529
+ for (var d = 0, p = i; d < p.length; d++) {
530
+ var l = p[d], u = a.has(l);
531
+ u || (a.add(l), o.push(l));
532
+ }
533
+ return o;
534
+ }
535
+ function ue(e, t) {
536
+ var n = K(e, t, !1);
537
+ return n ? n.OrdinaryOwnMetadataKeys(e, t) : [];
538
+ }
539
+ function T(e) {
540
+ if (e === null) return 1;
541
+ switch (typeof e) {
542
+ case "undefined": return 0;
543
+ case "boolean": return 2;
544
+ case "string": return 3;
545
+ case "symbol": return 4;
546
+ case "number": return 5;
547
+ case "object": return e === null ? 1 : 6;
548
+ default: return 6;
549
+ }
550
+ }
551
+ function E(e) {
552
+ return e === void 0;
553
+ }
554
+ function D(e) {
555
+ return e === null;
556
+ }
557
+ function de(e) {
558
+ return typeof e == "symbol";
559
+ }
560
+ function O(e) {
561
+ return typeof e == "object" ? e !== null : typeof e == "function";
562
+ }
563
+ function k(e, t) {
564
+ switch (T(e)) {
565
+ case 0: return e;
566
+ case 1: return e;
567
+ case 2: return e;
568
+ case 3: return e;
569
+ case 4: return e;
570
+ case 5: return e;
571
+ }
572
+ var n = t === 3 ? "string" : t === 5 ? "number" : "default", r = I(e, i);
573
+ if (r !== void 0) {
574
+ var a = r.call(e, n);
575
+ if (O(a)) throw TypeError();
576
+ return a;
577
+ }
578
+ return fe(e, n === "default" ? "number" : n);
579
+ }
580
+ function fe(e, t) {
581
+ if (t === "string") {
582
+ var n = e.toString;
583
+ if (N(n)) {
584
+ var r = n.call(e);
585
+ if (!O(r)) return r;
586
+ }
587
+ var i = e.valueOf;
588
+ if (N(i)) {
589
+ var r = i.call(e);
590
+ if (!O(r)) return r;
591
+ }
592
+ } else {
593
+ var i = e.valueOf;
594
+ if (N(i)) {
595
+ var r = i.call(e);
596
+ if (!O(r)) return r;
597
+ }
598
+ var a = e.toString;
599
+ if (N(a)) {
600
+ var r = a.call(e);
601
+ if (!O(r)) return r;
602
+ }
603
+ }
604
+ throw TypeError();
605
+ }
606
+ function A(e) {
607
+ return !!e;
608
+ }
609
+ function pe(e) {
610
+ return "" + e;
611
+ }
612
+ function j(e) {
613
+ var t = k(e, 3);
614
+ return de(t) ? t : pe(t);
615
+ }
616
+ function M(e) {
617
+ return Array.isArray ? Array.isArray(e) : e instanceof Object ? e instanceof Array : Object.prototype.toString.call(e) === "[object Array]";
618
+ }
619
+ function N(e) {
620
+ return typeof e == "function";
621
+ }
622
+ function me(e) {
623
+ return typeof e == "function";
624
+ }
625
+ function P(e) {
626
+ switch (T(e)) {
627
+ case 3: return !0;
628
+ case 4: return !0;
629
+ default: return !1;
630
+ }
631
+ }
632
+ function F(e, t) {
633
+ return e === t || e !== e && t !== t;
634
+ }
635
+ function I(e, t) {
636
+ var n = e[t];
637
+ if (n != null) {
638
+ if (!N(n)) throw TypeError();
639
+ return n;
640
+ }
641
+ }
642
+ function L(e) {
643
+ var t = I(e, a);
644
+ if (!N(t)) throw TypeError();
645
+ var n = t.call(e);
646
+ if (!O(n)) throw TypeError();
647
+ return n;
648
+ }
649
+ function R(e) {
650
+ return e.value;
651
+ }
652
+ function z(e) {
653
+ var t = e.next();
654
+ return !t.done && t;
655
+ }
656
+ function B(e) {
657
+ var t = e.return;
658
+ t && t.call(e);
659
+ }
660
+ function V(e) {
661
+ var t = Object.getPrototypeOf(e);
662
+ if (typeof e != "function" || e === u || t !== u) return t;
663
+ var n = e.prototype, r = n && Object.getPrototypeOf(n);
664
+ if (r == null || r === Object.prototype) return t;
665
+ var i = r.constructor;
666
+ return typeof i != "function" || i === e ? t : i;
667
+ }
668
+ function H() {
669
+ var e;
670
+ !E(m) && t.Reflect !== void 0 && !(m in t.Reflect) && typeof t.Reflect.defineMetadata == "function" && (e = G(t.Reflect));
671
+ var n, r, i, a = new p(), o = {
672
+ registerProvider: s,
673
+ getProvider: l,
674
+ setProvider: h
675
+ };
676
+ return o;
677
+ function s(t) {
678
+ if (!Object.isExtensible(o)) throw Error("Cannot add provider to a frozen registry.");
679
+ switch (!0) {
680
+ case e === t: break;
681
+ case E(n):
682
+ n = t;
683
+ break;
684
+ case n === t: break;
685
+ case E(r):
686
+ r = t;
687
+ break;
688
+ case r === t: break;
689
+ default: i === void 0 && (i = new f()), i.add(t);
690
+ }
691
+ }
692
+ function c(t, a) {
693
+ if (!E(n)) {
694
+ if (n.isProviderFor(t, a)) return n;
695
+ if (!E(r)) {
696
+ if (r.isProviderFor(t, a)) return n;
697
+ if (!E(i)) for (var o = L(i);;) {
698
+ var s = z(o);
699
+ if (!s) return;
700
+ var c = R(s);
701
+ if (c.isProviderFor(t, a)) return B(o), c;
702
+ }
703
+ }
704
+ }
705
+ if (!E(e) && e.isProviderFor(t, a)) return e;
706
+ }
707
+ function l(e, t) {
708
+ var n = a.get(e), r;
709
+ return E(n) || (r = n.get(t)), E(r) && (r = c(e, t), E(r) || (E(n) && (n = new d(), a.set(e, n)), n.set(t, r))), r;
710
+ }
711
+ function u(e) {
712
+ if (E(e)) throw TypeError();
713
+ return n === e || r === e || !E(i) && i.has(e);
714
+ }
715
+ function h(e, t, n) {
716
+ if (!u(n)) throw Error("Metadata provider not registered.");
717
+ var r = l(e, t);
718
+ if (r !== n) {
719
+ if (!E(r)) return !1;
720
+ var i = a.get(e);
721
+ E(i) && (i = new d(), a.set(e, i)), i.set(t, n);
722
+ }
723
+ return !0;
724
+ }
725
+ }
726
+ function U() {
727
+ var e;
728
+ return !E(m) && O(t.Reflect) && Object.isExtensible(t.Reflect) && (e = t.Reflect[m]), E(e) && (e = H()), !E(m) && O(t.Reflect) && Object.isExtensible(t.Reflect) && Object.defineProperty(t.Reflect, m, {
729
+ enumerable: !1,
730
+ configurable: !1,
731
+ writable: !1,
732
+ value: e
733
+ }), e;
734
+ }
735
+ function W(e) {
736
+ var t = new p(), n = {
737
+ isProviderFor: function(e, n) {
738
+ var r = t.get(e);
739
+ return !E(r) && r.has(n);
740
+ },
741
+ OrdinaryDefineOwnMetadata: o,
742
+ OrdinaryHasOwnMetadata: i,
743
+ OrdinaryGetOwnMetadata: a,
744
+ OrdinaryOwnMetadataKeys: s,
745
+ OrdinaryDeleteMetadata: c
746
+ };
747
+ return h.registerProvider(n), n;
748
+ function r(r, i, a) {
749
+ var o = t.get(r), s = !1;
750
+ if (E(o)) {
751
+ if (!a) return;
752
+ o = new d(), t.set(r, o), s = !0;
753
+ }
754
+ var c = o.get(i);
755
+ if (E(c)) {
756
+ if (!a) return;
757
+ if (c = new d(), o.set(i, c), !e.setProvider(r, i, n)) throw o.delete(i), s && t.delete(r), Error("Wrong provider for target.");
758
+ }
759
+ return c;
760
+ }
761
+ function i(e, t, n) {
762
+ var i = r(t, n, !1);
763
+ return !E(i) && A(i.has(e));
764
+ }
765
+ function a(e, t, n) {
766
+ var i = r(t, n, !1);
767
+ if (!E(i)) return i.get(e);
768
+ }
769
+ function o(e, t, n, i) {
770
+ r(n, i, !0).set(e, t);
771
+ }
772
+ function s(e, t) {
773
+ var n = [], i = r(e, t, !1);
774
+ if (E(i)) return n;
775
+ for (var a = L(i.keys()), o = 0;;) {
776
+ var s = z(a);
777
+ if (!s) return n.length = o, n;
778
+ var c = R(s);
779
+ try {
780
+ n[o] = c;
781
+ } catch (e) {
782
+ try {
783
+ B(a);
784
+ } finally {
785
+ throw e;
786
+ }
787
+ }
788
+ o++;
789
+ }
790
+ }
791
+ function c(e, n, i) {
792
+ var a = r(n, i, !1);
793
+ if (E(a) || !a.delete(e)) return !1;
794
+ if (a.size === 0) {
795
+ var o = t.get(n);
796
+ E(o) || (o.delete(i), o.size === 0 && t.delete(o));
797
+ }
798
+ return !0;
799
+ }
800
+ }
801
+ function G(e) {
802
+ var t = e.defineMetadata, n = e.hasOwnMetadata, r = e.getOwnMetadata, i = e.getOwnMetadataKeys, a = e.deleteMetadata, o = new p();
803
+ return {
804
+ isProviderFor: function(e, t) {
805
+ var n = o.get(e);
806
+ return !E(n) && n.has(t) ? !0 : i(e, t).length ? (E(n) && (n = new f(), o.set(e, n)), n.add(t), !0) : !1;
807
+ },
808
+ OrdinaryDefineOwnMetadata: t,
809
+ OrdinaryHasOwnMetadata: n,
810
+ OrdinaryGetOwnMetadata: r,
811
+ OrdinaryOwnMetadataKeys: i,
812
+ OrdinaryDeleteMetadata: a
813
+ };
814
+ }
815
+ function K(e, t, n) {
816
+ var r = h.getProvider(e, t);
817
+ if (!E(r)) return r;
818
+ if (n) {
819
+ if (h.setProvider(e, t, g)) return g;
820
+ throw Error("Illegal state.");
821
+ }
822
+ }
823
+ function he() {
824
+ var e = {}, t = [], n = function() {
825
+ function e(e, t, n) {
826
+ this._index = 0, this._keys = e, this._values = t, this._selector = n;
827
+ }
828
+ return e.prototype["@@iterator"] = function() {
829
+ return this;
830
+ }, e.prototype[a] = function() {
831
+ return this;
832
+ }, e.prototype.next = function() {
833
+ var e = this._index;
834
+ if (e >= 0 && e < this._keys.length) {
835
+ var n = this._selector(this._keys[e], this._values[e]);
836
+ return e + 1 >= this._keys.length ? (this._index = -1, this._keys = t, this._values = t) : this._index++, {
837
+ value: n,
838
+ done: !1
839
+ };
840
+ }
841
+ return {
842
+ value: void 0,
843
+ done: !0
844
+ };
845
+ }, e.prototype.throw = function(e) {
846
+ throw this._index >= 0 && (this._index = -1, this._keys = t, this._values = t), e;
847
+ }, e.prototype.return = function(e) {
848
+ return this._index >= 0 && (this._index = -1, this._keys = t, this._values = t), {
849
+ value: e,
850
+ done: !0
851
+ };
852
+ }, e;
853
+ }();
854
+ return function() {
855
+ function t() {
856
+ this._keys = [], this._values = [], this._cacheKey = e, this._cacheIndex = -2;
857
+ }
858
+ return Object.defineProperty(t.prototype, "size", {
859
+ get: function() {
860
+ return this._keys.length;
861
+ },
862
+ enumerable: !0,
863
+ configurable: !0
864
+ }), t.prototype.has = function(e) {
865
+ return this._find(e, !1) >= 0;
866
+ }, t.prototype.get = function(e) {
867
+ var t = this._find(e, !1);
868
+ return t >= 0 ? this._values[t] : void 0;
869
+ }, t.prototype.set = function(e, t) {
870
+ var n = this._find(e, !0);
871
+ return this._values[n] = t, this;
872
+ }, t.prototype.delete = function(t) {
873
+ var n = this._find(t, !1);
874
+ if (n >= 0) {
875
+ for (var r = this._keys.length, i = n + 1; i < r; i++) this._keys[i - 1] = this._keys[i], this._values[i - 1] = this._values[i];
876
+ return this._keys.length--, this._values.length--, F(t, this._cacheKey) && (this._cacheKey = e, this._cacheIndex = -2), !0;
877
+ }
878
+ return !1;
879
+ }, t.prototype.clear = function() {
880
+ this._keys.length = 0, this._values.length = 0, this._cacheKey = e, this._cacheIndex = -2;
881
+ }, t.prototype.keys = function() {
882
+ return new n(this._keys, this._values, r);
883
+ }, t.prototype.values = function() {
884
+ return new n(this._keys, this._values, i);
885
+ }, t.prototype.entries = function() {
886
+ return new n(this._keys, this._values, o);
887
+ }, t.prototype["@@iterator"] = function() {
888
+ return this.entries();
889
+ }, t.prototype[a] = function() {
890
+ return this.entries();
891
+ }, t.prototype._find = function(e, t) {
892
+ if (!F(this._cacheKey, e)) {
893
+ this._cacheIndex = -1;
894
+ for (var n = 0; n < this._keys.length; n++) if (F(this._keys[n], e)) {
895
+ this._cacheIndex = n;
896
+ break;
897
+ }
898
+ }
899
+ return this._cacheIndex < 0 && t && (this._cacheIndex = this._keys.length, this._keys.push(e), this._values.push(void 0)), this._cacheIndex;
900
+ }, t;
901
+ }();
902
+ function r(e, t) {
903
+ return e;
904
+ }
905
+ function i(e, t) {
906
+ return t;
907
+ }
908
+ function o(e, t) {
909
+ return [e, t];
910
+ }
911
+ }
912
+ function ge() {
913
+ return function() {
914
+ function e() {
915
+ this._map = new d();
916
+ }
917
+ return Object.defineProperty(e.prototype, "size", {
918
+ get: function() {
919
+ return this._map.size;
920
+ },
921
+ enumerable: !0,
922
+ configurable: !0
923
+ }), e.prototype.has = function(e) {
924
+ return this._map.has(e);
925
+ }, e.prototype.add = function(e) {
926
+ return this._map.set(e, e), this;
927
+ }, e.prototype.delete = function(e) {
928
+ return this._map.delete(e);
929
+ }, e.prototype.clear = function() {
930
+ this._map.clear();
931
+ }, e.prototype.keys = function() {
932
+ return this._map.keys();
933
+ }, e.prototype.values = function() {
934
+ return this._map.keys();
935
+ }, e.prototype.entries = function() {
936
+ return this._map.entries();
937
+ }, e.prototype["@@iterator"] = function() {
938
+ return this.keys();
939
+ }, e.prototype[a] = function() {
940
+ return this.keys();
941
+ }, e;
942
+ }();
943
+ }
944
+ function q() {
945
+ var e = l.create(), t = r();
946
+ return function() {
947
+ function e() {
948
+ this._key = r();
949
+ }
950
+ return e.prototype.has = function(e) {
951
+ var t = i(e, !1);
952
+ return t !== void 0 && l.has(t, this._key);
953
+ }, e.prototype.get = function(e) {
954
+ var t = i(e, !1);
955
+ return t === void 0 ? void 0 : l.get(t, this._key);
956
+ }, e.prototype.set = function(e, t) {
957
+ var n = i(e, !0);
958
+ return n[this._key] = t, this;
959
+ }, e.prototype.delete = function(e) {
960
+ var t = i(e, !1);
961
+ return t !== void 0 && delete t[this._key];
962
+ }, e.prototype.clear = function() {
963
+ this._key = r();
964
+ }, e;
965
+ }();
966
+ function r() {
967
+ var t;
968
+ do
969
+ t = "@@WeakMap@@" + s();
970
+ while (l.has(e, t));
971
+ return e[t] = !0, t;
972
+ }
973
+ function i(e, r) {
974
+ if (!n.call(e, t)) {
975
+ if (!r) return;
976
+ Object.defineProperty(e, t, { value: l.create() });
977
+ }
978
+ return e[t];
979
+ }
980
+ function a(e, t) {
981
+ for (var n = 0; n < t; ++n) e[n] = Math.random() * 255 | 0;
982
+ return e;
983
+ }
984
+ function o(e) {
985
+ if (typeof Uint8Array == "function") {
986
+ var t = new Uint8Array(e);
987
+ return typeof crypto < "u" ? crypto.getRandomValues(t) : typeof msCrypto < "u" ? msCrypto.getRandomValues(t) : a(t, e), t;
988
+ }
989
+ return a(Array(e), e);
990
+ }
991
+ function s() {
992
+ var e = o(16);
993
+ e[6] = e[6] & 79 | 64, e[8] = e[8] & 191 | 128;
994
+ for (var t = "", n = 0; n < 16; ++n) {
995
+ var r = e[n];
996
+ (n === 4 || n === 6 || n === 8) && (t += "-"), r < 16 && (t += "0"), t += r.toString(16).toLowerCase();
997
+ }
998
+ return t;
999
+ }
1000
+ }
1001
+ function J(e) {
1002
+ return e.__ = void 0, delete e.__, e;
1003
+ }
1004
+ });
1005
+ })(e ||= {});
1006
+ })), A = class extends Error {
1007
+ constructor() {
1008
+ super(...arguments), this.name = this.constructor.name;
1009
+ }
1010
+ }, pe = class extends A {
1011
+ constructor(e, t) {
1012
+ super(`"${t}" not found in Mesh "${e}"`);
1013
+ }
1014
+ }, j = class extends A {
1015
+ constructor(e) {
1016
+ super(`Invalid binding "${e}". Valid bindings are: string to constructor e.g. ("MyService", MyService) or abstract class to constructor e.g. (MyService, MyServiceImpl) orconstructor to self e.g. (MyService)`);
1017
+ }
281
1018
  };
282
- const Ye = [
283
- "button",
284
- "a",
285
- "input",
286
- "textarea",
287
- "select",
288
- '[role="textbox"]',
289
- '[role="button"]',
290
- "[nodrag]"
291
- ];
292
- class rt {
293
- constructor() {
294
- this.lastMousePos = { x: window.innerWidth * 0.5, y: window.innerHeight * 0.5 }, this.lmbPressed = !1, this.mmbPressed = !1, this.rmbPressed = !1, this.altKey = !1, this.ctrlKey = !1, this.metaKey = !1, this.shiftKey = !1, this.dragDistance = 4, this.windowEvents = new Ne(window), this.lastMouseDownPos = { x: window.innerWidth * 0.5, y: window.innerHeight * 0.5 }, this.lastMouseDownTarget = null, this.dragTarget = null, this.inClickVicinity = !1, this.listening = !1;
295
- }
296
- get ctrlOrMetaKey() {
297
- return this.ctrlKey || this.metaKey;
298
- }
299
- mount() {
300
- this.listening || (this.listening = !0, this.windowEvents.add("mousedown", (t) => this.onMouseDown(t)), this.windowEvents.add("mousemove", (t) => this.onMouseMove(t)), this.windowEvents.add("mouseup", (t) => this.onMouseUp(t)), this.windowEvents.add("keydown", (t) => this.onKeyDown(t)), this.windowEvents.add("keyup", (t) => this.onKeyUp(t)));
301
- }
302
- unmount() {
303
- this.listening && (this.listening = !1, this.windowEvents.removeAll(), this.dragTarget = null, this.inClickVicinity = !1, this.lastMouseDownTarget = null);
304
- }
305
- onMouseDown(t) {
306
- this.lastMousePos = { x: t.pageX, y: t.pageY }, this.lmbPressed = t.button === 0, this.mmbPressed = t.button === 1, this.rmbPressed = t.button === 2, t.button === 0 && (this.lastMouseDownPos = { x: t.pageX, y: t.pageY }, this.lastMouseDownTarget = t.target, this.inClickVicinity = !0);
307
- }
308
- onMouseMove(t) {
309
- if (this.lastMousePos = { x: t.pageX, y: t.pageY }, !this.lmbPressed)
310
- return;
311
- if (this.dragTarget) {
312
- this.dragTarget.dispatchEvent(this.cloneMouseEvent("uidragmove", t));
313
- return;
314
- }
315
- if (!this.inClickVicinity || !this.lastMouseDownTarget)
316
- return;
317
- const e = t.pageX - this.lastMouseDownPos.x, n = t.pageY - this.lastMouseDownPos.y;
318
- Math.hypot(e, n) < this.dragDistance || (this.inClickVicinity = !1, this.isDragAllowed(this.lastMouseDownTarget) && (this.dragTarget = this.lastMouseDownTarget, this.dragTarget.dispatchEvent(this.cloneMouseEvent("uidragstart", t))));
319
- }
320
- onMouseUp(t) {
321
- if (t.button === 0) {
322
- const e = this.dragTarget, n = this.inClickVicinity, o = this.lastMouseDownTarget;
323
- this.dragTarget = null, this.inClickVicinity = !1, this.lastMouseDownTarget = null, e && e.dispatchEvent(this.cloneMouseEvent("uidragend", t)), n && o && (o.dispatchEvent(this.cloneMouseEvent("uiclick", t)), this.dispatchActivate(o, t));
324
- }
325
- this.lastMousePos = { x: t.pageX, y: t.pageY }, this.lmbPressed = !1, this.mmbPressed = !1, this.rmbPressed = !1;
326
- }
327
- onKeyDown(t) {
328
- this.updateModifiers(t), (t.key === "Enter" || t.key === " ") && t.target && (t.target === document.body && t.key === " " && t.preventDefault(), this.dispatchActivate(t.target, t));
329
- }
330
- onKeyUp(t) {
331
- this.updateModifiers(t);
332
- }
333
- updateModifiers(t) {
334
- this.altKey = t.altKey, this.ctrlKey = t.ctrlKey, this.metaKey = t.metaKey, this.shiftKey = t.shiftKey;
335
- }
336
- dispatchActivate(t, e) {
337
- t.closest(":disabled") || t.dispatchEvent(new CustomEvent("uiactivate", { detail: e }));
338
- }
339
- isDragAllowed(t) {
340
- return t instanceof Element ? !t.closest(Ye.join(",")) : !1;
341
- }
342
- cloneMouseEvent(t, e) {
343
- return new MouseEvent(t, {
344
- bubbles: !0,
345
- cancelable: !0,
346
- clientX: e.clientX,
347
- clientY: e.clientY,
348
- screenX: e.screenX,
349
- screenY: e.screenY,
350
- button: e.button,
351
- buttons: e.buttons,
352
- ctrlKey: e.ctrlKey,
353
- shiftKey: e.shiftKey,
354
- altKey: e.altKey,
355
- metaKey: e.metaKey
356
- });
357
- }
358
- }
359
- var Ut = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Vt = {};
360
- var Lt;
361
- function He() {
362
- if (Lt) return Vt;
363
- Lt = 1;
364
- var r;
365
- return (function(t) {
366
- (function(e) {
367
- var n = typeof globalThis == "object" ? globalThis : typeof Ut == "object" ? Ut : typeof self == "object" ? self : typeof this == "object" ? this : S(), o = l(t);
368
- typeof n.Reflect < "u" && (o = l(n.Reflect, o)), e(o, n), typeof n.Reflect > "u" && (n.Reflect = t);
369
- function l(_, E) {
370
- return function(D, N) {
371
- Object.defineProperty(_, D, { configurable: !0, writable: !0, value: N }), E && E(D, N);
372
- };
373
- }
374
- function g() {
375
- try {
376
- return Function("return this;")();
377
- } catch {
378
- }
379
- }
380
- function p() {
381
- try {
382
- return (0, eval)("(function() { return this; })()");
383
- } catch {
384
- }
385
- }
386
- function S() {
387
- return g() || p();
388
- }
389
- })(function(e, n) {
390
- var o = Object.prototype.hasOwnProperty, l = typeof Symbol == "function", g = l && typeof Symbol.toPrimitive < "u" ? Symbol.toPrimitive : "@@toPrimitive", p = l && typeof Symbol.iterator < "u" ? Symbol.iterator : "@@iterator", S = typeof Object.create == "function", _ = { __proto__: [] } instanceof Array, E = !S && !_, D = {
391
- // create an object in dictionary mode (a.k.a. "slow" mode in v8)
392
- create: S ? function() {
393
- return pt(/* @__PURE__ */ Object.create(null));
394
- } : _ ? function() {
395
- return pt({ __proto__: null });
396
- } : function() {
397
- return pt({});
398
- },
399
- has: E ? function(s, i) {
400
- return o.call(s, i);
401
- } : function(s, i) {
402
- return i in s;
403
- },
404
- get: E ? function(s, i) {
405
- return o.call(s, i) ? s[i] : void 0;
406
- } : function(s, i) {
407
- return s[i];
408
- }
409
- }, N = Object.getPrototypeOf(Function), Y = typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : we(), ut = typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : me(), ht = typeof WeakMap == "function" ? WeakMap : be(), L = l ? /* @__PURE__ */ Symbol.for("@reflect-metadata:registry") : void 0, et = pe(), mt = ye(et);
410
- function qt(s, i, a, c) {
411
- if (y(a)) {
412
- if (!_t(s))
413
- throw new TypeError();
414
- if (!Et(i))
415
- throw new TypeError();
416
- return ae(s, i);
417
- } else {
418
- if (!_t(s))
419
- throw new TypeError();
420
- if (!O(i))
421
- throw new TypeError();
422
- if (!O(c) && !y(c) && !A(c))
423
- throw new TypeError();
424
- return A(c) && (c = void 0), a = T(a), ce(s, i, a, c);
425
- }
426
- }
427
- e("decorate", qt);
428
- function Jt(s, i) {
429
- function a(c, v) {
430
- if (!O(c))
431
- throw new TypeError();
432
- if (!y(v) && !fe(v))
433
- throw new TypeError();
434
- Mt(s, i, c, v);
435
- }
436
- return a;
437
- }
438
- e("metadata", Jt);
439
- function Qt(s, i, a, c) {
440
- if (!O(a))
441
- throw new TypeError();
442
- return y(c) || (c = T(c)), Mt(s, i, a, c);
443
- }
444
- e("defineMetadata", Qt);
445
- function te(s, i, a) {
446
- if (!O(i))
447
- throw new TypeError();
448
- return y(a) || (a = T(a)), bt(s, i, a);
449
- }
450
- e("hasMetadata", te);
451
- function ee(s, i, a) {
452
- if (!O(i))
453
- throw new TypeError();
454
- return y(a) || (a = T(a)), dt(s, i, a);
455
- }
456
- e("hasOwnMetadata", ee);
457
- function se(s, i, a) {
458
- if (!O(i))
459
- throw new TypeError();
460
- return y(a) || (a = T(a)), xt(s, i, a);
461
- }
462
- e("getMetadata", se);
463
- function ne(s, i, a) {
464
- if (!O(i))
465
- throw new TypeError();
466
- return y(a) || (a = T(a)), St(s, i, a);
467
- }
468
- e("getOwnMetadata", ne);
469
- function ie(s, i) {
470
- if (!O(s))
471
- throw new TypeError();
472
- return y(i) || (i = T(i)), Ot(s, i);
473
- }
474
- e("getMetadataKeys", ie);
475
- function re(s, i) {
476
- if (!O(s))
477
- throw new TypeError();
478
- return y(i) || (i = T(i)), Pt(s, i);
479
- }
480
- e("getOwnMetadataKeys", re);
481
- function oe(s, i, a) {
482
- if (!O(i))
483
- throw new TypeError();
484
- if (y(a) || (a = T(a)), !O(i))
485
- throw new TypeError();
486
- y(a) || (a = T(a));
487
- var c = H(
488
- i,
489
- a,
490
- /*Create*/
491
- !1
492
- );
493
- return y(c) ? !1 : c.OrdinaryDeleteMetadata(s, i, a);
494
- }
495
- e("deleteMetadata", oe);
496
- function ae(s, i) {
497
- for (var a = s.length - 1; a >= 0; --a) {
498
- var c = s[a], v = c(i);
499
- if (!y(v) && !A(v)) {
500
- if (!Et(v))
501
- throw new TypeError();
502
- i = v;
503
- }
504
- }
505
- return i;
506
- }
507
- function ce(s, i, a, c) {
508
- for (var v = s.length - 1; v >= 0; --v) {
509
- var C = s[v], P = C(i, a, c);
510
- if (!y(P) && !A(P)) {
511
- if (!O(P))
512
- throw new TypeError();
513
- c = P;
514
- }
515
- }
516
- return c;
517
- }
518
- function bt(s, i, a) {
519
- var c = dt(s, i, a);
520
- if (c)
521
- return !0;
522
- var v = vt(i);
523
- return A(v) ? !1 : bt(s, v, a);
524
- }
525
- function dt(s, i, a) {
526
- var c = H(
527
- i,
528
- a,
529
- /*Create*/
530
- !1
531
- );
532
- return y(c) ? !1 : jt(c.OrdinaryHasOwnMetadata(s, i, a));
533
- }
534
- function xt(s, i, a) {
535
- var c = dt(s, i, a);
536
- if (c)
537
- return St(s, i, a);
538
- var v = vt(i);
539
- if (!A(v))
540
- return xt(s, v, a);
541
- }
542
- function St(s, i, a) {
543
- var c = H(
544
- i,
545
- a,
546
- /*Create*/
547
- !1
548
- );
549
- if (!y(c))
550
- return c.OrdinaryGetOwnMetadata(s, i, a);
551
- }
552
- function Mt(s, i, a, c) {
553
- var v = H(
554
- a,
555
- c,
556
- /*Create*/
557
- !0
558
- );
559
- v.OrdinaryDefineOwnMetadata(s, i, a, c);
560
- }
561
- function Ot(s, i) {
562
- var a = Pt(s, i), c = vt(s);
563
- if (c === null)
564
- return a;
565
- var v = Ot(c, i);
566
- if (v.length <= 0)
567
- return a;
568
- if (a.length <= 0)
569
- return v;
570
- for (var C = new ut(), P = [], w = 0, u = a; w < u.length; w++) {
571
- var h = u[w], d = C.has(h);
572
- d || (C.add(h), P.push(h));
573
- }
574
- for (var f = 0, m = v; f < m.length; f++) {
575
- var h = m[f], d = C.has(h);
576
- d || (C.add(h), P.push(h));
577
- }
578
- return P;
579
- }
580
- function Pt(s, i) {
581
- var a = H(
582
- s,
583
- i,
584
- /*create*/
585
- !1
586
- );
587
- return a ? a.OrdinaryOwnMetadataKeys(s, i) : [];
588
- }
589
- function Ct(s) {
590
- if (s === null)
591
- return 1;
592
- switch (typeof s) {
593
- case "undefined":
594
- return 0;
595
- case "boolean":
596
- return 2;
597
- case "string":
598
- return 3;
599
- case "symbol":
600
- return 4;
601
- case "number":
602
- return 5;
603
- case "object":
604
- return s === null ? 1 : 6;
605
- default:
606
- return 6;
607
- }
608
- }
609
- function y(s) {
610
- return s === void 0;
611
- }
612
- function A(s) {
613
- return s === null;
614
- }
615
- function le(s) {
616
- return typeof s == "symbol";
617
- }
618
- function O(s) {
619
- return typeof s == "object" ? s !== null : typeof s == "function";
620
- }
621
- function ue(s, i) {
622
- switch (Ct(s)) {
623
- case 0:
624
- return s;
625
- case 1:
626
- return s;
627
- case 2:
628
- return s;
629
- case 3:
630
- return s;
631
- case 4:
632
- return s;
633
- case 5:
634
- return s;
635
- }
636
- var a = "string", c = It(s, g);
637
- if (c !== void 0) {
638
- var v = c.call(s, a);
639
- if (O(v))
640
- throw new TypeError();
641
- return v;
642
- }
643
- return he(s);
644
- }
645
- function he(s, i) {
646
- var a, c;
647
- {
648
- var v = s.toString;
649
- if (st(v)) {
650
- var c = v.call(s);
651
- if (!O(c))
652
- return c;
653
- }
654
- var a = s.valueOf;
655
- if (st(a)) {
656
- var c = a.call(s);
657
- if (!O(c))
658
- return c;
659
- }
660
- }
661
- throw new TypeError();
662
- }
663
- function jt(s) {
664
- return !!s;
665
- }
666
- function de(s) {
667
- return "" + s;
668
- }
669
- function T(s) {
670
- var i = ue(s);
671
- return le(i) ? i : de(i);
672
- }
673
- function _t(s) {
674
- return Array.isArray ? Array.isArray(s) : s instanceof Object ? s instanceof Array : Object.prototype.toString.call(s) === "[object Array]";
675
- }
676
- function st(s) {
677
- return typeof s == "function";
678
- }
679
- function Et(s) {
680
- return typeof s == "function";
681
- }
682
- function fe(s) {
683
- switch (Ct(s)) {
684
- case 3:
685
- return !0;
686
- case 4:
687
- return !0;
688
- default:
689
- return !1;
690
- }
691
- }
692
- function ft(s, i) {
693
- return s === i || s !== s && i !== i;
694
- }
695
- function It(s, i) {
696
- var a = s[i];
697
- if (a != null) {
698
- if (!st(a))
699
- throw new TypeError();
700
- return a;
701
- }
702
- }
703
- function Tt(s) {
704
- var i = It(s, p);
705
- if (!st(i))
706
- throw new TypeError();
707
- var a = i.call(s);
708
- if (!O(a))
709
- throw new TypeError();
710
- return a;
711
- }
712
- function zt(s) {
713
- return s.value;
714
- }
715
- function Rt(s) {
716
- var i = s.next();
717
- return i.done ? !1 : i;
718
- }
719
- function Dt(s) {
720
- var i = s.return;
721
- i && i.call(s);
722
- }
723
- function vt(s) {
724
- var i = Object.getPrototypeOf(s);
725
- if (typeof s != "function" || s === N || i !== N)
726
- return i;
727
- var a = s.prototype, c = a && Object.getPrototypeOf(a);
728
- if (c == null || c === Object.prototype)
729
- return i;
730
- var v = c.constructor;
731
- return typeof v != "function" || v === s ? i : v;
732
- }
733
- function ve() {
734
- var s;
735
- !y(L) && typeof n.Reflect < "u" && !(L in n.Reflect) && typeof n.Reflect.defineMetadata == "function" && (s = ge(n.Reflect));
736
- var i, a, c, v = new ht(), C = {
737
- registerProvider: P,
738
- getProvider: u,
739
- setProvider: d
740
- };
741
- return C;
742
- function P(f) {
743
- if (!Object.isExtensible(C))
744
- throw new Error("Cannot add provider to a frozen registry.");
745
- switch (!0) {
746
- case s === f:
747
- break;
748
- case y(i):
749
- i = f;
750
- break;
751
- case i === f:
752
- break;
753
- case y(a):
754
- a = f;
755
- break;
756
- case a === f:
757
- break;
758
- default:
759
- c === void 0 && (c = new ut()), c.add(f);
760
- break;
761
- }
762
- }
763
- function w(f, m) {
764
- if (!y(i)) {
765
- if (i.isProviderFor(f, m))
766
- return i;
767
- if (!y(a)) {
768
- if (a.isProviderFor(f, m))
769
- return i;
770
- if (!y(c))
771
- for (var x = Tt(c); ; ) {
772
- var M = Rt(x);
773
- if (!M)
774
- return;
775
- var I = zt(M);
776
- if (I.isProviderFor(f, m))
777
- return Dt(x), I;
778
- }
779
- }
780
- }
781
- if (!y(s) && s.isProviderFor(f, m))
782
- return s;
783
- }
784
- function u(f, m) {
785
- var x = v.get(f), M;
786
- return y(x) || (M = x.get(m)), y(M) && (M = w(f, m), y(M) || (y(x) && (x = new Y(), v.set(f, x)), x.set(m, M))), M;
787
- }
788
- function h(f) {
789
- if (y(f))
790
- throw new TypeError();
791
- return i === f || a === f || !y(c) && c.has(f);
792
- }
793
- function d(f, m, x) {
794
- if (!h(x))
795
- throw new Error("Metadata provider not registered.");
796
- var M = u(f, m);
797
- if (M !== x) {
798
- if (!y(M))
799
- return !1;
800
- var I = v.get(f);
801
- y(I) && (I = new Y(), v.set(f, I)), I.set(m, x);
802
- }
803
- return !0;
804
- }
805
- }
806
- function pe() {
807
- var s;
808
- return !y(L) && O(n.Reflect) && Object.isExtensible(n.Reflect) && (s = n.Reflect[L]), y(s) && (s = ve()), !y(L) && O(n.Reflect) && Object.isExtensible(n.Reflect) && Object.defineProperty(n.Reflect, L, {
809
- enumerable: !1,
810
- configurable: !1,
811
- writable: !1,
812
- value: s
813
- }), s;
814
- }
815
- function ye(s) {
816
- var i = new ht(), a = {
817
- isProviderFor: function(h, d) {
818
- var f = i.get(h);
819
- return y(f) ? !1 : f.has(d);
820
- },
821
- OrdinaryDefineOwnMetadata: P,
822
- OrdinaryHasOwnMetadata: v,
823
- OrdinaryGetOwnMetadata: C,
824
- OrdinaryOwnMetadataKeys: w,
825
- OrdinaryDeleteMetadata: u
826
- };
827
- return et.registerProvider(a), a;
828
- function c(h, d, f) {
829
- var m = i.get(h), x = !1;
830
- if (y(m)) {
831
- if (!f)
832
- return;
833
- m = new Y(), i.set(h, m), x = !0;
834
- }
835
- var M = m.get(d);
836
- if (y(M)) {
837
- if (!f)
838
- return;
839
- if (M = new Y(), m.set(d, M), !s.setProvider(h, d, a))
840
- throw m.delete(d), x && i.delete(h), new Error("Wrong provider for target.");
841
- }
842
- return M;
843
- }
844
- function v(h, d, f) {
845
- var m = c(
846
- d,
847
- f,
848
- /*Create*/
849
- !1
850
- );
851
- return y(m) ? !1 : jt(m.has(h));
852
- }
853
- function C(h, d, f) {
854
- var m = c(
855
- d,
856
- f,
857
- /*Create*/
858
- !1
859
- );
860
- if (!y(m))
861
- return m.get(h);
862
- }
863
- function P(h, d, f, m) {
864
- var x = c(
865
- f,
866
- m,
867
- /*Create*/
868
- !0
869
- );
870
- x.set(h, d);
871
- }
872
- function w(h, d) {
873
- var f = [], m = c(
874
- h,
875
- d,
876
- /*Create*/
877
- !1
878
- );
879
- if (y(m))
880
- return f;
881
- for (var x = m.keys(), M = Tt(x), I = 0; ; ) {
882
- var kt = Rt(M);
883
- if (!kt)
884
- return f.length = I, f;
885
- var xe = zt(kt);
886
- try {
887
- f[I] = xe;
888
- } catch (Se) {
889
- try {
890
- Dt(M);
891
- } finally {
892
- throw Se;
893
- }
894
- }
895
- I++;
896
- }
897
- }
898
- function u(h, d, f) {
899
- var m = c(
900
- d,
901
- f,
902
- /*Create*/
903
- !1
904
- );
905
- if (y(m) || !m.delete(h))
906
- return !1;
907
- if (m.size === 0) {
908
- var x = i.get(d);
909
- y(x) || (x.delete(f), x.size === 0 && i.delete(x));
910
- }
911
- return !0;
912
- }
913
- }
914
- function ge(s) {
915
- var i = s.defineMetadata, a = s.hasOwnMetadata, c = s.getOwnMetadata, v = s.getOwnMetadataKeys, C = s.deleteMetadata, P = new ht(), w = {
916
- isProviderFor: function(u, h) {
917
- var d = P.get(u);
918
- return !y(d) && d.has(h) ? !0 : v(u, h).length ? (y(d) && (d = new ut(), P.set(u, d)), d.add(h), !0) : !1;
919
- },
920
- OrdinaryDefineOwnMetadata: i,
921
- OrdinaryHasOwnMetadata: a,
922
- OrdinaryGetOwnMetadata: c,
923
- OrdinaryOwnMetadataKeys: v,
924
- OrdinaryDeleteMetadata: C
925
- };
926
- return w;
927
- }
928
- function H(s, i, a) {
929
- var c = et.getProvider(s, i);
930
- if (!y(c))
931
- return c;
932
- if (a) {
933
- if (et.setProvider(s, i, mt))
934
- return mt;
935
- throw new Error("Illegal state.");
936
- }
937
- }
938
- function we() {
939
- var s = {}, i = [], a = (
940
- /** @class */
941
- (function() {
942
- function w(u, h, d) {
943
- this._index = 0, this._keys = u, this._values = h, this._selector = d;
944
- }
945
- return w.prototype["@@iterator"] = function() {
946
- return this;
947
- }, w.prototype[p] = function() {
948
- return this;
949
- }, w.prototype.next = function() {
950
- var u = this._index;
951
- if (u >= 0 && u < this._keys.length) {
952
- var h = this._selector(this._keys[u], this._values[u]);
953
- return u + 1 >= this._keys.length ? (this._index = -1, this._keys = i, this._values = i) : this._index++, { value: h, done: !1 };
954
- }
955
- return { value: void 0, done: !0 };
956
- }, w.prototype.throw = function(u) {
957
- throw this._index >= 0 && (this._index = -1, this._keys = i, this._values = i), u;
958
- }, w.prototype.return = function(u) {
959
- return this._index >= 0 && (this._index = -1, this._keys = i, this._values = i), { value: u, done: !0 };
960
- }, w;
961
- })()
962
- ), c = (
963
- /** @class */
964
- (function() {
965
- function w() {
966
- this._keys = [], this._values = [], this._cacheKey = s, this._cacheIndex = -2;
967
- }
968
- return Object.defineProperty(w.prototype, "size", {
969
- get: function() {
970
- return this._keys.length;
971
- },
972
- enumerable: !0,
973
- configurable: !0
974
- }), w.prototype.has = function(u) {
975
- return this._find(
976
- u,
977
- /*insert*/
978
- !1
979
- ) >= 0;
980
- }, w.prototype.get = function(u) {
981
- var h = this._find(
982
- u,
983
- /*insert*/
984
- !1
985
- );
986
- return h >= 0 ? this._values[h] : void 0;
987
- }, w.prototype.set = function(u, h) {
988
- var d = this._find(
989
- u,
990
- /*insert*/
991
- !0
992
- );
993
- return this._values[d] = h, this;
994
- }, w.prototype.delete = function(u) {
995
- var h = this._find(
996
- u,
997
- /*insert*/
998
- !1
999
- );
1000
- if (h >= 0) {
1001
- for (var d = this._keys.length, f = h + 1; f < d; f++)
1002
- this._keys[f - 1] = this._keys[f], this._values[f - 1] = this._values[f];
1003
- return this._keys.length--, this._values.length--, ft(u, this._cacheKey) && (this._cacheKey = s, this._cacheIndex = -2), !0;
1004
- }
1005
- return !1;
1006
- }, w.prototype.clear = function() {
1007
- this._keys.length = 0, this._values.length = 0, this._cacheKey = s, this._cacheIndex = -2;
1008
- }, w.prototype.keys = function() {
1009
- return new a(this._keys, this._values, v);
1010
- }, w.prototype.values = function() {
1011
- return new a(this._keys, this._values, C);
1012
- }, w.prototype.entries = function() {
1013
- return new a(this._keys, this._values, P);
1014
- }, w.prototype["@@iterator"] = function() {
1015
- return this.entries();
1016
- }, w.prototype[p] = function() {
1017
- return this.entries();
1018
- }, w.prototype._find = function(u, h) {
1019
- if (!ft(this._cacheKey, u)) {
1020
- this._cacheIndex = -1;
1021
- for (var d = 0; d < this._keys.length; d++)
1022
- if (ft(this._keys[d], u)) {
1023
- this._cacheIndex = d;
1024
- break;
1025
- }
1026
- }
1027
- return this._cacheIndex < 0 && h && (this._cacheIndex = this._keys.length, this._keys.push(u), this._values.push(void 0)), this._cacheIndex;
1028
- }, w;
1029
- })()
1030
- );
1031
- return c;
1032
- function v(w, u) {
1033
- return w;
1034
- }
1035
- function C(w, u) {
1036
- return u;
1037
- }
1038
- function P(w, u) {
1039
- return [w, u];
1040
- }
1041
- }
1042
- function me() {
1043
- var s = (
1044
- /** @class */
1045
- (function() {
1046
- function i() {
1047
- this._map = new Y();
1048
- }
1049
- return Object.defineProperty(i.prototype, "size", {
1050
- get: function() {
1051
- return this._map.size;
1052
- },
1053
- enumerable: !0,
1054
- configurable: !0
1055
- }), i.prototype.has = function(a) {
1056
- return this._map.has(a);
1057
- }, i.prototype.add = function(a) {
1058
- return this._map.set(a, a), this;
1059
- }, i.prototype.delete = function(a) {
1060
- return this._map.delete(a);
1061
- }, i.prototype.clear = function() {
1062
- this._map.clear();
1063
- }, i.prototype.keys = function() {
1064
- return this._map.keys();
1065
- }, i.prototype.values = function() {
1066
- return this._map.keys();
1067
- }, i.prototype.entries = function() {
1068
- return this._map.entries();
1069
- }, i.prototype["@@iterator"] = function() {
1070
- return this.keys();
1071
- }, i.prototype[p] = function() {
1072
- return this.keys();
1073
- }, i;
1074
- })()
1075
- );
1076
- return s;
1077
- }
1078
- function be() {
1079
- var s = 16, i = D.create(), a = c();
1080
- return (
1081
- /** @class */
1082
- (function() {
1083
- function u() {
1084
- this._key = c();
1085
- }
1086
- return u.prototype.has = function(h) {
1087
- var d = v(
1088
- h,
1089
- /*create*/
1090
- !1
1091
- );
1092
- return d !== void 0 ? D.has(d, this._key) : !1;
1093
- }, u.prototype.get = function(h) {
1094
- var d = v(
1095
- h,
1096
- /*create*/
1097
- !1
1098
- );
1099
- return d !== void 0 ? D.get(d, this._key) : void 0;
1100
- }, u.prototype.set = function(h, d) {
1101
- var f = v(
1102
- h,
1103
- /*create*/
1104
- !0
1105
- );
1106
- return f[this._key] = d, this;
1107
- }, u.prototype.delete = function(h) {
1108
- var d = v(
1109
- h,
1110
- /*create*/
1111
- !1
1112
- );
1113
- return d !== void 0 ? delete d[this._key] : !1;
1114
- }, u.prototype.clear = function() {
1115
- this._key = c();
1116
- }, u;
1117
- })()
1118
- );
1119
- function c() {
1120
- var u;
1121
- do
1122
- u = "@@WeakMap@@" + w();
1123
- while (D.has(i, u));
1124
- return i[u] = !0, u;
1125
- }
1126
- function v(u, h) {
1127
- if (!o.call(u, a)) {
1128
- if (!h)
1129
- return;
1130
- Object.defineProperty(u, a, { value: D.create() });
1131
- }
1132
- return u[a];
1133
- }
1134
- function C(u, h) {
1135
- for (var d = 0; d < h; ++d)
1136
- u[d] = Math.random() * 255 | 0;
1137
- return u;
1138
- }
1139
- function P(u) {
1140
- if (typeof Uint8Array == "function") {
1141
- var h = new Uint8Array(u);
1142
- return typeof crypto < "u" ? crypto.getRandomValues(h) : typeof msCrypto < "u" ? msCrypto.getRandomValues(h) : C(h, u), h;
1143
- }
1144
- return C(new Array(u), u);
1145
- }
1146
- function w() {
1147
- var u = P(s);
1148
- u[6] = u[6] & 79 | 64, u[8] = u[8] & 191 | 128;
1149
- for (var h = "", d = 0; d < s; ++d) {
1150
- var f = u[d];
1151
- (d === 4 || d === 6 || d === 8) && (h += "-"), f < 16 && (h += "0"), h += f.toString(16).toLowerCase();
1152
- }
1153
- return h;
1154
- }
1155
- }
1156
- function pt(s) {
1157
- return s.__ = void 0, delete s.__, s;
1158
- }
1159
- });
1160
- })(r || (r = {})), Vt;
1161
- }
1162
- He();
1163
- class Nt extends Error {
1164
- constructor() {
1165
- super(...arguments), this.name = this.constructor.name;
1166
- }
1167
- }
1168
- class Xe extends Nt {
1169
- constructor(t, e) {
1170
- super(`"${e}" not found in Mesh "${t}"`);
1171
- }
1172
- }
1173
- class At extends Nt {
1174
- constructor(t) {
1175
- super(`Invalid binding "${t}". Valid bindings are: string to constructor e.g. ("MyService", MyService) or abstract class to constructor e.g. (MyService, MyServiceImpl) orconstructor to self e.g. (MyService)`);
1176
- }
1177
- }
1178
- function R(r) {
1179
- return typeof r == "string" ? r : r.name;
1180
- }
1181
- function We(r) {
1182
- return typeof r == "function" && r.prototype != null;
1183
- }
1184
- function Ze(r, ...t) {
1185
- return We(r) ? new r(...t) : r(...t);
1186
- }
1187
- const Yt = /* @__PURE__ */ Symbol.for("MESH_REF");
1188
- class at {
1189
- constructor(t = "default", e = void 0) {
1190
- this.name = t, this.parent = e, this.bindings = /* @__PURE__ */ new Map(), this.instances = /* @__PURE__ */ new Map(), this.middlewares = [], this.constant(at, this), this.injectRef(this);
1191
- }
1192
- *[Symbol.iterator]() {
1193
- yield* this.bindings.entries();
1194
- }
1195
- clone() {
1196
- const t = new at();
1197
- return t.parent = this.parent, t.bindings = new Map(this.bindings), t;
1198
- }
1199
- connect(t) {
1200
- const e = this.applyMiddleware(t);
1201
- return this.injectRef(e), e;
1202
- }
1203
- use(t) {
1204
- return this.middlewares.push(t), this;
1205
- }
1206
- service(t, e) {
1207
- const n = R(t);
1208
- if (typeof e == "function")
1209
- return this.bindings.set(n, { type: "service", class: e }), this;
1210
- if (typeof t == "function")
1211
- return this.bindings.set(n, { type: "service", class: t }), this;
1212
- throw new At(String(t));
1213
- }
1214
- scope(t, e) {
1215
- const n = R(t);
1216
- if (typeof e == "function")
1217
- return this.bindings.set(n, { type: "scope", factory: e }), this;
1218
- if (typeof t == "function")
1219
- return this.bindings.set(n, { type: "scope", factory: t }), this;
1220
- throw new At(String(t));
1221
- }
1222
- constant(t, e) {
1223
- const n = R(t);
1224
- return this.bindings.set(n, { type: "constant", value: e }), this;
1225
- }
1226
- alias(t, e) {
1227
- const n = R(t), o = R(e);
1228
- return this.bindings.set(n, { type: "alias", key: o }), this;
1229
- }
1230
- delete(t) {
1231
- const e = R(t);
1232
- return this.bindings.delete(e), this;
1233
- }
1234
- resolve(t, e = !0) {
1235
- const n = this.tryResolve(t, e);
1236
- if (n === void 0) {
1237
- const o = R(t);
1238
- throw new Xe(this.name, o);
1239
- }
1240
- return n;
1241
- }
1242
- tryResolve(t, e = !0) {
1243
- const n = R(t);
1244
- let o = this.instances.get(n);
1245
- if (o)
1246
- return o;
1247
- const l = this.bindings.get(n);
1248
- if (l)
1249
- return o = this.instantiate(l), o = this.connect(o), this.instances.set(n, o), o;
1250
- if (e && this.parent)
1251
- return this.parent.tryResolve(t);
1252
- }
1253
- getBinding(t, e = !0) {
1254
- const n = R(t), o = this.bindings.get(n);
1255
- if (o)
1256
- return o;
1257
- if (e && this.parent)
1258
- return this.parent.getBinding(t);
1259
- }
1260
- *allBindings() {
1261
- yield* this.bindings.entries(), this.parent && (yield* this.parent.allBindings());
1262
- }
1263
- *missingDeps() {
1264
- for (const t of this.allDeps())
1265
- this.getBinding(t.key) || (yield t);
1266
- }
1267
- *allDeps() {
1268
- const t = /* @__PURE__ */ new Set();
1269
- for (const [, e] of this.allBindings())
1270
- e.type === "service" && (yield* this.traverseClassDeps(e.class, t));
1271
- }
1272
- *traverseClassDeps(t, e = /* @__PURE__ */ new Set()) {
1273
- const n = Je(t);
1274
- for (const o of n) {
1275
- if (e.has(o.key))
1276
- continue;
1277
- e.add(o.key), yield o;
1278
- const l = this.getBinding(o.key);
1279
- l?.type === "service" && (yield* this.traverseClassDeps(l.class, e));
1280
- }
1281
- }
1282
- instantiate(t) {
1283
- switch (t.type) {
1284
- case "alias":
1285
- return this.resolve(t.key);
1286
- case "service": {
1287
- const e = t.class, n = class extends e {
1288
- };
1289
- return Object.defineProperty(n, "name", { value: e.name }), this.injectRef(n.prototype), new n();
1290
- }
1291
- case "constant":
1292
- return t.value;
1293
- case "scope":
1294
- return (n) => Ze(t.factory, n ?? this);
1295
- }
1296
- }
1297
- applyMiddleware(t) {
1298
- let e = t;
1299
- for (const n of this.middlewares)
1300
- e = n(e);
1301
- return this.parent && (e = this.parent.applyMiddleware(e)), e;
1302
- }
1303
- injectRef(t) {
1304
- typeof t == "object" && Object.defineProperty(t, Yt, {
1305
- get: () => this,
1306
- enumerable: !1,
1307
- configurable: !0
1308
- });
1309
- }
1310
- }
1311
- const qe = [];
1312
- function Je(r) {
1313
- const t = [];
1314
- let e = r;
1315
- for (; e !== Object.prototype; ) {
1316
- const n = qe.filter((o) => o.class === e);
1317
- t.push(...n), e = Object.getPrototypeOf(e);
1318
- }
1319
- return t;
1320
- }
1321
- const Qe = Object.getOwnPropertyNames(Reflect);
1322
- function b(r, t, e = !0) {
1323
- let n;
1324
- const o = {};
1325
- for (const l of Qe)
1326
- o[l] = function(g, ...p) {
1327
- let S = n;
1328
- return S || (S = r[Yt].resolve(t)), e && (n = S), Reflect[l](S, ...p);
1329
- };
1330
- return new Proxy(r, o);
1331
- }
1332
- class J {
1333
- constructor() {
1334
- this.autoCenter = !0, this.allowMultiSelect = !0;
1335
- }
1336
- set(t) {
1337
- Object.assign(this, t);
1338
- }
1019
+ // ../../node_modules/mesh-ioc/out/main/util.js
1020
+ function M(e) {
1021
+ return typeof e == "string" ? e : e.name;
1339
1022
  }
1340
- class ct {
1341
- constructor() {
1342
- this.objects = /* @__PURE__ */ new Map();
1343
- }
1344
- register(t) {
1345
- this.objects.set(t.objectId, t);
1346
- }
1347
- unregister(t) {
1348
- this.objects.delete(t);
1349
- }
1350
- get(t) {
1351
- return this.objects.get(t) ?? null;
1352
- }
1353
- getAll() {
1354
- return [...this.objects.values()];
1355
- }
1023
+ function N(e) {
1024
+ return typeof e == "function" && e.prototype != null;
1356
1025
  }
1357
- class $ {
1358
- constructor() {
1359
- this._groups = /* @__PURE__ */ new Map();
1360
- }
1361
- on(t, e = /* @__PURE__ */ Symbol()) {
1362
- let n = this._groups.get(e);
1363
- return n || (n = /* @__PURE__ */ new Set(), this._groups.set(e, n)), n.add(t), () => this.remove(t, e);
1364
- }
1365
- once(t, e = /* @__PURE__ */ Symbol()) {
1366
- const n = (o) => {
1367
- t(o), this.remove(n, e);
1368
- };
1369
- return this.on(n, e);
1370
- }
1371
- remove(t, e) {
1372
- const n = this._groups.get(e);
1373
- n && (n.delete(t), n.size === 0 && this._groups.delete(e));
1374
- }
1375
- removeAll(t) {
1376
- this._groups.delete(t);
1377
- }
1378
- emit(t) {
1379
- for (const e of this._groups.values())
1380
- for (const n of e)
1381
- n(t);
1382
- }
1026
+ function me(e, ...t) {
1027
+ return N(e) ? new e(...t) : e(...t);
1383
1028
  }
1384
- class K {
1385
- constructor() {
1386
- this.mounted = new $(), this.unmounted = new $(), this.selectionChanged = new $(), this.dragMove = new $(), this.dragEnd = new $(), this.objectPosUpdated = new $();
1387
- }
1388
- }
1389
- class Q {
1390
- constructor() {
1391
- this.selectedIds = /* @__PURE__ */ new Set(), this.events = b(this, K);
1392
- }
1393
- get size() {
1394
- return this.selectedIds.size;
1395
- }
1396
- getSelectedIds() {
1397
- return [...this.selectedIds];
1398
- }
1399
- getFirst() {
1400
- return [...this.selectedIds][0] ?? null;
1401
- }
1402
- isSelected(t) {
1403
- return this.selectedIds.has(t);
1404
- }
1405
- isSingleSelected(t) {
1406
- return this.selectedIds.size === 1 && this.selectedIds.has(t);
1407
- }
1408
- setSelectedIds(t) {
1409
- const e = new Set(this.selectedIds);
1410
- this.selectedIds = new Set(t), this.notifySelectionChanged(e);
1411
- }
1412
- selectSingle(t) {
1413
- if (this.isSingleSelected(t))
1414
- return;
1415
- const e = new Set(this.selectedIds);
1416
- this.selectedIds.clear(), this.selectedIds.add(t), this.notifySelectionChanged(e);
1417
- }
1418
- addToSelection(...t) {
1419
- const e = new Set(this.selectedIds);
1420
- for (const n of t)
1421
- this.selectedIds.add(n);
1422
- this.notifySelectionChanged(e);
1423
- }
1424
- removeFromSelection(...t) {
1425
- const e = new Set(this.selectedIds);
1426
- for (const n of t)
1427
- this.selectedIds.delete(n);
1428
- this.notifySelectionChanged(e);
1429
- }
1430
- toggleSelection(t) {
1431
- if (this.isSelected(t)) {
1432
- this.removeFromSelection(t);
1433
- return;
1434
- }
1435
- this.addToSelection(t);
1436
- }
1437
- deselectAll() {
1438
- if (this.selectedIds.size === 0)
1439
- return;
1440
- const t = new Set(this.selectedIds);
1441
- this.selectedIds.clear(), this.notifySelectionChanged(t);
1442
- }
1443
- notifySelectionChanged(t) {
1444
- if (t.size === this.selectedIds.size) {
1445
- let e = !1;
1446
- for (const n of t)
1447
- if (!this.selectedIds.has(n)) {
1448
- e = !0;
1449
- break;
1450
- }
1451
- if (!e)
1452
- return;
1453
- }
1454
- this.events.selectionChanged.emit(this.getSelectedIds());
1455
- }
1456
- setSelected(t, e) {
1457
- if (e) {
1458
- this.addToSelection(t);
1459
- return;
1460
- }
1461
- this.removeFromSelection(t);
1462
- }
1463
- }
1464
- function z(r, t, e) {
1465
- return Math.max(t, Math.min(e, r));
1466
- }
1467
- function Ht(r, t) {
1468
- return {
1469
- x: r.x - t.x,
1470
- y: r.y - t.y
1471
- };
1029
+ // ../../node_modules/mesh-ioc/out/main/mesh.js
1030
+ var P = Symbol.for("MESH_REF"), F = class e {
1031
+ constructor(t = "default", n = void 0) {
1032
+ this.name = t, this.parent = n, this.bindings = /* @__PURE__ */ new Map(), this.instances = /* @__PURE__ */ new Map(), this.middlewares = [], this.constant(e, this), this.injectRef(this);
1033
+ }
1034
+ *[Symbol.iterator]() {
1035
+ yield* this.bindings.entries();
1036
+ }
1037
+ clone() {
1038
+ let t = new e();
1039
+ return t.parent = this.parent, t.bindings = new Map(this.bindings), t;
1040
+ }
1041
+ connect(e) {
1042
+ let t = this.applyMiddleware(e);
1043
+ return this.injectRef(t), t;
1044
+ }
1045
+ use(e) {
1046
+ return this.middlewares.push(e), this;
1047
+ }
1048
+ service(e, t) {
1049
+ let n = M(e);
1050
+ if (typeof t == "function") return this.bindings.set(n, {
1051
+ type: "service",
1052
+ class: t
1053
+ }), this;
1054
+ if (typeof e == "function") return this.bindings.set(n, {
1055
+ type: "service",
1056
+ class: e
1057
+ }), this;
1058
+ throw new j(String(e));
1059
+ }
1060
+ scope(e, t) {
1061
+ let n = M(e);
1062
+ if (typeof t == "function") return this.bindings.set(n, {
1063
+ type: "scope",
1064
+ factory: t
1065
+ }), this;
1066
+ if (typeof e == "function") return this.bindings.set(n, {
1067
+ type: "scope",
1068
+ factory: e
1069
+ }), this;
1070
+ throw new j(String(e));
1071
+ }
1072
+ constant(e, t) {
1073
+ let n = M(e);
1074
+ return this.bindings.set(n, {
1075
+ type: "constant",
1076
+ value: t
1077
+ }), this;
1078
+ }
1079
+ alias(e, t) {
1080
+ let n = M(e), r = M(t);
1081
+ return this.bindings.set(n, {
1082
+ type: "alias",
1083
+ key: r
1084
+ }), this;
1085
+ }
1086
+ delete(e) {
1087
+ let t = M(e);
1088
+ return this.bindings.delete(t), this;
1089
+ }
1090
+ resolve(e, t = !0) {
1091
+ let n = this.tryResolve(e, t);
1092
+ if (n === void 0) {
1093
+ let t = M(e);
1094
+ throw new pe(this.name, t);
1095
+ }
1096
+ return n;
1097
+ }
1098
+ tryResolve(e, t = !0) {
1099
+ let n = M(e), r = this.instances.get(n);
1100
+ if (r) return r;
1101
+ let i = this.bindings.get(n);
1102
+ if (i) return r = this.instantiate(i), r = this.connect(r), this.instances.set(n, r), r;
1103
+ if (t && this.parent) return this.parent.tryResolve(e);
1104
+ }
1105
+ getBinding(e, t = !0) {
1106
+ let n = M(e), r = this.bindings.get(n);
1107
+ if (r) return r;
1108
+ if (t && this.parent) return this.parent.getBinding(e);
1109
+ }
1110
+ *allBindings() {
1111
+ yield* this.bindings.entries(), this.parent && (yield* this.parent.allBindings());
1112
+ }
1113
+ *missingDeps() {
1114
+ for (let e of this.allDeps()) this.getBinding(e.key) || (yield e);
1115
+ }
1116
+ *allDeps() {
1117
+ let e = /* @__PURE__ */ new Set();
1118
+ for (let [, t] of this.allBindings()) t.type === "service" && (yield* this.traverseClassDeps(t.class, e));
1119
+ }
1120
+ *traverseClassDeps(e, t = /* @__PURE__ */ new Set()) {
1121
+ let n = L(e);
1122
+ for (let e of n) {
1123
+ if (t.has(e.key)) continue;
1124
+ t.add(e.key), yield e;
1125
+ let n = this.getBinding(e.key);
1126
+ n?.type === "service" && (yield* this.traverseClassDeps(n.class, t));
1127
+ }
1128
+ }
1129
+ instantiate(e) {
1130
+ switch (e.type) {
1131
+ case "alias": return this.resolve(e.key);
1132
+ case "service": {
1133
+ let t = e.class, n = class extends t {};
1134
+ return Object.defineProperty(n, "name", { value: t.name }), this.injectRef(n.prototype), new n();
1135
+ }
1136
+ case "constant": return e.value;
1137
+ case "scope": return (t) => me(e.factory, t ?? this);
1138
+ }
1139
+ }
1140
+ applyMiddleware(e) {
1141
+ let t = e;
1142
+ for (let e of this.middlewares) t = e(t);
1143
+ return this.parent && (t = this.parent.applyMiddleware(t)), t;
1144
+ }
1145
+ injectRef(e) {
1146
+ typeof e == "object" && Object.defineProperty(e, P, {
1147
+ get: () => this,
1148
+ enumerable: !1,
1149
+ configurable: !0
1150
+ });
1151
+ }
1152
+ };
1153
+ fe();
1154
+ var I = [];
1155
+ function L(e) {
1156
+ let t = [], n = e;
1157
+ for (; n !== Object.prototype;) {
1158
+ let e = I.filter((e) => e.class === n);
1159
+ t.push(...e), n = Object.getPrototypeOf(n);
1160
+ }
1161
+ return t;
1472
1162
  }
1473
- function ts(r) {
1474
- const [t, e] = r;
1475
- return {
1476
- x: (e.x - t.x) * 0.5 + t.x,
1477
- y: (e.y - t.y) * 0.5 + t.y
1478
- };
1163
+ // ../../node_modules/mesh-ioc/out/main/proxy.js
1164
+ var R = Object.getOwnPropertyNames(Reflect);
1165
+ function z(e, t, n = !0) {
1166
+ let r, i = {};
1167
+ for (let a of R) i[a] = function(i, ...o) {
1168
+ let s = r;
1169
+ return s ||= e[P].resolve(t), n && (r = s), Reflect[a](s, ...o);
1170
+ };
1171
+ return new Proxy(e, i);
1479
1172
  }
1480
- function Xt(r, t, e) {
1481
- const n = r ?? document.documentElement;
1482
- return getComputedStyle(n).getPropertyValue(t).trim() || e;
1173
+ // src/CanvasConfig.ts
1174
+ var B = class {
1175
+ constructor() {
1176
+ this.autoCenter = !0, this.allowMultiSelect = !0;
1177
+ }
1178
+ set(e) {
1179
+ Object.assign(this, e);
1180
+ }
1181
+ }, V = class {
1182
+ constructor() {
1183
+ this.objects = /* @__PURE__ */ new Map();
1184
+ }
1185
+ register(e) {
1186
+ this.objects.set(e.objectId, e);
1187
+ }
1188
+ unregister(e) {
1189
+ this.objects.delete(e);
1190
+ }
1191
+ get(e) {
1192
+ return this.objects.get(e) ?? null;
1193
+ }
1194
+ getAll() {
1195
+ return [...this.objects.values()];
1196
+ }
1197
+ }, H = class {
1198
+ constructor() {
1199
+ this._groups = /* @__PURE__ */ new Map();
1200
+ }
1201
+ on(e, t = Symbol()) {
1202
+ let n = this._groups.get(t);
1203
+ return n || (n = /* @__PURE__ */ new Set(), this._groups.set(t, n)), n.add(e), () => this.remove(e, t);
1204
+ }
1205
+ once(e, t = Symbol()) {
1206
+ let n = (r) => {
1207
+ e(r), this.remove(n, t);
1208
+ };
1209
+ return this.on(n, t);
1210
+ }
1211
+ remove(e, t) {
1212
+ let n = this._groups.get(t);
1213
+ n && (n.delete(e), n.size === 0 && this._groups.delete(t));
1214
+ }
1215
+ removeAll(e) {
1216
+ this._groups.delete(e);
1217
+ }
1218
+ emit(e) {
1219
+ for (let t of this._groups.values()) for (let n of t) n(e);
1220
+ }
1221
+ }, U = class {
1222
+ constructor() {
1223
+ this.mounted = new H(), this.unmounted = new H(), this.selectionChanged = new H(), this.dragMove = new H(), this.dragEnd = new H(), this.objectPosUpdated = new H();
1224
+ }
1225
+ }, W = class {
1226
+ constructor() {
1227
+ this.selectedIds = /* @__PURE__ */ new Set(), this.events = z(this, U);
1228
+ }
1229
+ get size() {
1230
+ return this.selectedIds.size;
1231
+ }
1232
+ getSelectedIds() {
1233
+ return [...this.selectedIds];
1234
+ }
1235
+ getFirst() {
1236
+ return [...this.selectedIds][0] ?? null;
1237
+ }
1238
+ isSelected(e) {
1239
+ return this.selectedIds.has(e);
1240
+ }
1241
+ isSingleSelected(e) {
1242
+ return this.selectedIds.size === 1 && this.selectedIds.has(e);
1243
+ }
1244
+ setSelectedIds(e) {
1245
+ let t = new Set(this.selectedIds);
1246
+ this.selectedIds = new Set(e), this.notifySelectionChanged(t);
1247
+ }
1248
+ selectSingle(e) {
1249
+ if (this.isSingleSelected(e)) return;
1250
+ let t = new Set(this.selectedIds);
1251
+ this.selectedIds.clear(), this.selectedIds.add(e), this.notifySelectionChanged(t);
1252
+ }
1253
+ addToSelection(...e) {
1254
+ let t = new Set(this.selectedIds);
1255
+ for (let t of e) this.selectedIds.add(t);
1256
+ this.notifySelectionChanged(t);
1257
+ }
1258
+ removeFromSelection(...e) {
1259
+ let t = new Set(this.selectedIds);
1260
+ for (let t of e) this.selectedIds.delete(t);
1261
+ this.notifySelectionChanged(t);
1262
+ }
1263
+ toggleSelection(e) {
1264
+ this.isSelected(e) ? this.removeFromSelection(e) : this.addToSelection(e);
1265
+ }
1266
+ deselectAll() {
1267
+ if (this.selectedIds.size === 0) return;
1268
+ let e = new Set(this.selectedIds);
1269
+ this.selectedIds.clear(), this.notifySelectionChanged(e);
1270
+ }
1271
+ notifySelectionChanged(e) {
1272
+ if (e.size === this.selectedIds.size) {
1273
+ let t = !1;
1274
+ for (let n of e) if (!this.selectedIds.has(n)) {
1275
+ t = !0;
1276
+ break;
1277
+ }
1278
+ if (!t) return;
1279
+ }
1280
+ this.events.selectionChanged.emit(this.getSelectedIds());
1281
+ }
1282
+ setSelected(e, t) {
1283
+ t ? this.addToSelection(e) : this.removeFromSelection(e);
1284
+ }
1285
+ };
1286
+ // ../util/src/math.ts
1287
+ function G(e, t, n) {
1288
+ return Math.max(t, Math.min(n, e));
1483
1289
  }
1484
- function W(r, t, e) {
1485
- const n = Xt(r, t, String(e)), o = Number(n.replace(/px|em|%|vh|vw/g, ""));
1486
- return Number.isFinite(o) ? o : e;
1290
+ // ../util/src/point.ts
1291
+ function K(e, t) {
1292
+ return {
1293
+ x: e.x - t.x,
1294
+ y: e.y - t.y
1295
+ };
1487
1296
  }
1488
- function Gt(r, t, e) {
1489
- const n = r ?? document.documentElement, o = Xt(r, t, e), l = document.createElement("span");
1490
- l.style.position = "absolute", l.style.visibility = "hidden", l.style.pointerEvents = "none", l.style.color = e, l.style.color = o, n.appendChild(l);
1491
- const g = getComputedStyle(l).color.trim();
1492
- return l.remove(), g || e;
1297
+ // ../util/src/box.ts
1298
+ function he(e) {
1299
+ let [t, n] = e;
1300
+ return {
1301
+ x: (n.x - t.x) * .5 + t.x,
1302
+ y: (n.y - t.y) * .5 + t.y
1303
+ };
1493
1304
  }
1494
- class Wt {
1495
- constructor(t) {
1496
- this.target = t, this.entries = [];
1497
- }
1498
- add(t, e, n) {
1499
- this.target.addEventListener(t, e, n), this.entries.push({ type: t, listener: e, options: n });
1500
- }
1501
- removeAll() {
1502
- for (const t of this.entries)
1503
- this.target.removeEventListener(t.type, t.listener, t.options);
1504
- this.entries = [];
1505
- }
1305
+ // ../util/src/css.ts
1306
+ function ge(e, t, n) {
1307
+ let r = e ?? document.documentElement;
1308
+ return getComputedStyle(r).getPropertyValue(t).trim() || n;
1506
1309
  }
1507
- function es(r, t, e, n = 2, o, l = 1) {
1508
- const g = [0, ...ss(r, t), r], p = [0, r], S = [
1509
- `<svg xmlns="http://www.w3.org/2000/svg"
1510
- width="${r}"
1511
- height="${r}"
1512
- viewBox="0 0 ${r} ${r}">`
1513
- ];
1514
- if (l)
1515
- for (const _ of g)
1516
- for (const E of g)
1517
- S.push(
1518
- `<circle cx="${_}" cy="${E}" r="${l}" fill="${o}"/>`
1519
- );
1520
- if (n)
1521
- for (const _ of p)
1522
- for (const E of p)
1523
- S.push(
1524
- `<circle cx="${_}" cy="${E}" r="${n}" fill="${e}"/>`
1525
- );
1526
- return S.push("</svg>"), S.join("");
1310
+ function q(e, t, n) {
1311
+ let r = ge(e, t, String(n)), i = Number(r.replace(/px|em|%|vh|vw/g, ""));
1312
+ return Number.isFinite(i) ? i : n;
1527
1313
  }
1528
- function ss(r, t) {
1529
- const e = [], n = Math.round(r / t);
1530
- for (let o = 1; o < t; o++)
1531
- e.push(n * o);
1532
- return e;
1314
+ function J(e, t, n) {
1315
+ let r = e ?? document.documentElement, i = ge(e, t, n), a = document.createElement("span");
1316
+ a.style.position = "absolute", a.style.visibility = "hidden", a.style.pointerEvents = "none", a.style.color = n, a.style.color = i, r.appendChild(a);
1317
+ let o = getComputedStyle(a).color.trim();
1318
+ return a.remove(), o || n;
1533
1319
  }
1534
- class V {
1535
- constructor() {
1536
- this.zoom = 1, this.cellSize = 32, this.scrollPos = { x: 0, y: 0 }, this.viewportBox = [{ x: 0, y: 0 }, { x: 0, y: 0 }], this.canvasOrigin = { x: 0, y: 0 }, this.canvasSize = { x: 0, y: 0 };
1537
- }
1538
- localToCanvas(t) {
1539
- return {
1540
- x: t.x * this.cellSize + this.canvasOrigin.x,
1541
- y: t.y * this.cellSize + this.canvasOrigin.y
1542
- };
1543
- }
1544
- canvasToLocal(t) {
1545
- return {
1546
- x: (t.x - this.canvasOrigin.x) / this.cellSize,
1547
- y: (t.y - this.canvasOrigin.y) / this.cellSize
1548
- };
1549
- }
1550
- viewportToCanvas(t) {
1551
- return {
1552
- x: (t.x + this.scrollPos.x) / this.zoom,
1553
- y: (t.y + this.scrollPos.y) / this.zoom
1554
- };
1555
- }
1556
- canvasToViewport(t) {
1557
- return {
1558
- x: t.x * this.zoom - this.scrollPos.x,
1559
- y: t.y * this.zoom - this.scrollPos.y
1560
- };
1561
- }
1562
- viewportToLocal(t) {
1563
- return this.canvasToLocal(this.viewportToCanvas(t));
1564
- }
1565
- localToViewport(t) {
1566
- return this.canvasToViewport(this.localToCanvas(t));
1567
- }
1568
- pageToViewport(t) {
1569
- return {
1570
- x: t.x - this.viewportBox[0].x,
1571
- y: t.y - this.viewportBox[0].y
1572
- };
1573
- }
1574
- pageToCanvas(t) {
1575
- return this.viewportToCanvas(this.pageToViewport(t));
1576
- }
1577
- pageToLocal(t) {
1578
- return this.canvasToLocal(this.pageToCanvas(t));
1579
- }
1580
- getViewportCenterInLocal() {
1581
- const t = ts(this.viewportBox), e = this.pageToViewport(t);
1582
- return this.viewportToLocal(e);
1583
- }
1320
+ // ../util/src/dom/DomEventProxy.ts
1321
+ var _e = class {
1322
+ constructor(e) {
1323
+ this.target = e, this.entries = [];
1324
+ }
1325
+ add(e, t, n) {
1326
+ this.target.addEventListener(e, t, n), this.entries.push({
1327
+ type: e,
1328
+ listener: t,
1329
+ options: n
1330
+ });
1331
+ }
1332
+ removeAll() {
1333
+ for (let e of this.entries) this.target.removeEventListener(e.type, e.listener, e.options);
1334
+ this.entries = [];
1335
+ }
1336
+ }, Y = class {
1337
+ constructor() {
1338
+ this.zoom = 1, this.cellSize = 32, this.scrollPos = {
1339
+ x: 0,
1340
+ y: 0
1341
+ }, this.viewportBox = [{
1342
+ x: 0,
1343
+ y: 0
1344
+ }, {
1345
+ x: 0,
1346
+ y: 0
1347
+ }], this.canvasOrigin = {
1348
+ x: 0,
1349
+ y: 0
1350
+ }, this.canvasSize = {
1351
+ x: 0,
1352
+ y: 0
1353
+ };
1354
+ }
1355
+ localToCanvas(e) {
1356
+ return {
1357
+ x: e.x * this.cellSize + this.canvasOrigin.x,
1358
+ y: e.y * this.cellSize + this.canvasOrigin.y
1359
+ };
1360
+ }
1361
+ canvasToLocal(e) {
1362
+ return {
1363
+ x: (e.x - this.canvasOrigin.x) / this.cellSize,
1364
+ y: (e.y - this.canvasOrigin.y) / this.cellSize
1365
+ };
1366
+ }
1367
+ viewportToCanvas(e) {
1368
+ return {
1369
+ x: (e.x + this.scrollPos.x) / this.zoom,
1370
+ y: (e.y + this.scrollPos.y) / this.zoom
1371
+ };
1372
+ }
1373
+ canvasToViewport(e) {
1374
+ return {
1375
+ x: e.x * this.zoom - this.scrollPos.x,
1376
+ y: e.y * this.zoom - this.scrollPos.y
1377
+ };
1378
+ }
1379
+ viewportToLocal(e) {
1380
+ return this.canvasToLocal(this.viewportToCanvas(e));
1381
+ }
1382
+ localToViewport(e) {
1383
+ return this.canvasToViewport(this.localToCanvas(e));
1384
+ }
1385
+ pageToViewport(e) {
1386
+ return {
1387
+ x: e.x - this.viewportBox[0].x,
1388
+ y: e.y - this.viewportBox[0].y
1389
+ };
1390
+ }
1391
+ pageToCanvas(e) {
1392
+ return this.viewportToCanvas(this.pageToViewport(e));
1393
+ }
1394
+ pageToLocal(e) {
1395
+ return this.canvasToLocal(this.pageToCanvas(e));
1396
+ }
1397
+ getViewportCenterInLocal() {
1398
+ let e = he(this.viewportBox), t = this.pageToViewport(e);
1399
+ return this.viewportToLocal(t);
1400
+ }
1401
+ }, ve = class {
1402
+ constructor() {
1403
+ this.config = z(this, B), this.inputStateManager = z(this, k), this.objectRegistry = z(this, V), this.selection = z(this, W), this.space = z(this, Y), this.selectionOriginPos = null, this.initialSelectionIds = /* @__PURE__ */ new Set(), this.objectBoxes = [];
1404
+ }
1405
+ isSelecting() {
1406
+ return this.selectionOriginPos != null;
1407
+ }
1408
+ onUiDragStart(e) {
1409
+ this.config.allowMultiSelect && (this.isSelecting() || (this.selectionOriginPos = {
1410
+ x: e.pageX,
1411
+ y: e.pageY
1412
+ }, e.shiftKey ? this.initialSelectionIds = new Set(this.selection.getSelectedIds()) : (this.initialSelectionIds.clear(), this.selection.deselectAll()), this.captureObjectBoxes()));
1413
+ }
1414
+ onUiDragMove(e) {
1415
+ this.isSelecting() && (e.preventDefault(), this.updateSelection(e));
1416
+ }
1417
+ onUiDragEnd(e) {
1418
+ this.isSelecting() && this.updateSelection(e), this.stopSelecting();
1419
+ }
1420
+ getSelectionBox() {
1421
+ return this.selectionOriginPos ? E(this.space.pageToLocal(this.selectionOriginPos), this.space.pageToLocal(this.inputStateManager.lastMousePos)) : null;
1422
+ }
1423
+ getSelectionStyle() {
1424
+ if (!this.selectionOriginPos) return null;
1425
+ let e = E(this.selectionOriginPos, this.inputStateManager.lastMousePos), t = this.space.pageToCanvas(e[0]), n = this.space.pageToCanvas(e[1]);
1426
+ return {
1427
+ left: `${t.x}px`,
1428
+ top: `${t.y}px`,
1429
+ width: `${n.x - t.x}px`,
1430
+ height: `${n.y - t.y}px`
1431
+ };
1432
+ }
1433
+ stopSelecting() {
1434
+ this.selectionOriginPos = null, this.initialSelectionIds.clear(), this.objectBoxes = [];
1435
+ }
1436
+ captureObjectBoxes() {
1437
+ this.objectBoxes = [];
1438
+ let e = this.space.viewportBox;
1439
+ for (let t of this.objectRegistry.getAll()) {
1440
+ if (!t.isSelectable()) continue;
1441
+ let n = t.element;
1442
+ if (!n) continue;
1443
+ let r = n.getBoundingClientRect(), i = E({
1444
+ x: r.left,
1445
+ y: r.top
1446
+ }, {
1447
+ x: r.right,
1448
+ y: r.bottom
1449
+ });
1450
+ if (!D(i, e)) continue;
1451
+ let a = E(this.space.pageToLocal(i[0]), this.space.pageToLocal(i[1]));
1452
+ this.objectBoxes.push([t.objectId, a]);
1453
+ }
1454
+ }
1455
+ updateSelection(e) {
1456
+ let t = this.getSelectionBox();
1457
+ if (!t) return;
1458
+ let n = new Set(this.initialSelectionIds);
1459
+ for (let [e, r] of this.objectBoxes) D(t, r) && n.add(e);
1460
+ this.selection.setSelectedIds(n);
1461
+ }
1462
+ }, ye = /* @__PURE__ */ new Map();
1463
+ function be(e) {
1464
+ return function(t) {
1465
+ return (n, r) => {
1466
+ let i = ye.get(e) || [];
1467
+ ye.set(e, i), i.push({
1468
+ target: n.constructor,
1469
+ memberName: r,
1470
+ metadata: t
1471
+ });
1472
+ };
1473
+ };
1584
1474
  }
1585
- class $t {
1586
- constructor() {
1587
- this.config = b(this, J), this.inputStateManager = b(this, rt), this.objectRegistry = b(this, ct), this.selection = b(this, Q), this.space = b(this, V), this.selectionOriginPos = null, this.initialSelectionIds = /* @__PURE__ */ new Set(), this.objectBoxes = [];
1588
- }
1589
- isSelecting() {
1590
- return this.selectionOriginPos != null;
1591
- }
1592
- onUiDragStart(t) {
1593
- this.config.allowMultiSelect && (this.isSelecting() || (this.selectionOriginPos = { x: t.pageX, y: t.pageY }, t.shiftKey ? this.initialSelectionIds = new Set(this.selection.getSelectedIds()) : (this.initialSelectionIds.clear(), this.selection.deselectAll()), this.captureObjectBoxes()));
1594
- }
1595
- onUiDragMove(t) {
1596
- this.isSelecting() && (t.preventDefault(), this.updateSelection(t));
1597
- }
1598
- onUiDragEnd(t) {
1599
- this.isSelecting() && this.updateSelection(t), this.stopSelecting();
1600
- }
1601
- getSelectionBox() {
1602
- return this.selectionOriginPos ? nt(
1603
- this.space.pageToLocal(this.selectionOriginPos),
1604
- this.space.pageToLocal(this.inputStateManager.lastMousePos)
1605
- ) : null;
1606
- }
1607
- getSelectionStyle() {
1608
- if (!this.selectionOriginPos)
1609
- return null;
1610
- const t = nt(this.selectionOriginPos, this.inputStateManager.lastMousePos), e = this.space.pageToCanvas(t[0]), n = this.space.pageToCanvas(t[1]);
1611
- return {
1612
- left: `${e.x}px`,
1613
- top: `${e.y}px`,
1614
- width: `${n.x - e.x}px`,
1615
- height: `${n.y - e.y}px`
1616
- };
1617
- }
1618
- stopSelecting() {
1619
- this.selectionOriginPos = null, this.initialSelectionIds.clear(), this.objectBoxes = [];
1620
- }
1621
- captureObjectBoxes() {
1622
- this.objectBoxes = [];
1623
- const t = this.space.viewportBox;
1624
- for (const e of this.objectRegistry.getAll()) {
1625
- if (!e.isSelectable())
1626
- continue;
1627
- const n = e.element;
1628
- if (!n)
1629
- continue;
1630
- const o = n.getBoundingClientRect(), l = nt(
1631
- { x: o.left, y: o.top },
1632
- { x: o.right, y: o.bottom }
1633
- );
1634
- if (!Bt(l, t))
1635
- continue;
1636
- const g = nt(
1637
- this.space.pageToLocal(l[0]),
1638
- this.space.pageToLocal(l[1])
1639
- );
1640
- this.objectBoxes.push([e.objectId, g]);
1641
- }
1642
- }
1643
- updateSelection(t) {
1644
- const e = this.getSelectionBox();
1645
- if (!e)
1646
- return;
1647
- const n = new Set(this.initialSelectionIds);
1648
- for (const [o, l] of this.objectBoxes)
1649
- Bt(e, l) && n.add(o);
1650
- this.selection.setSelectedIds(n);
1651
- }
1475
+ function xe(e) {
1476
+ return ye.get(e) || [];
1652
1477
  }
1653
- const yt = /* @__PURE__ */ new Map();
1654
- function ns(r) {
1655
- return function(e) {
1656
- return (n, o) => {
1657
- const l = yt.get(r) || [];
1658
- yt.set(r, l), l.push({
1659
- target: n.constructor,
1660
- memberName: o,
1661
- metadata: e
1662
- });
1663
- };
1664
- };
1478
+ function Se(e, t, n = !0) {
1479
+ let r = [], i = xe(e), a = n ? t.allBindings() : t.bindings.entries();
1480
+ for (let [e, n] of a) if (n.type === "service") for (let { target: a, memberName: o, metadata: s } of i) (a === n.class || Object.prototype.isPrototypeOf.call(a, n.class)) && r.push({
1481
+ target: t.resolve(e),
1482
+ memberName: o,
1483
+ metadata: s
1484
+ });
1485
+ return r;
1665
1486
  }
1666
- function is(r) {
1667
- return yt.get(r) || [];
1487
+ function Ce(e, t, n = !0, ...r) {
1488
+ return Se(e, t, n).map((e) => e.target[e.memberName](...r));
1668
1489
  }
1669
- function rs(r, t, e = !0) {
1670
- const n = [], o = is(r), l = e ? t.allBindings() : t.bindings.entries();
1671
- for (const [g, p] of l)
1672
- if (p.type === "service")
1673
- for (const { target: S, memberName: _, metadata: E } of o)
1674
- (S === p.class || Object.prototype.isPrototypeOf.call(S, p.class)) && n.push({
1675
- target: t.resolve(g),
1676
- memberName: _,
1677
- metadata: E
1678
- });
1679
- return n;
1490
+ // ../../node_modules/@flexent/init-decorator/out/main/index.js
1491
+ var we = be("init");
1492
+ async function Te(e, t = !0) {
1493
+ let n = Ce("init", e, t);
1494
+ await Promise.all(n);
1680
1495
  }
1681
- function os(r, t, e = !0, ...n) {
1682
- return rs(r, t, e).map((g) => g.target[g.memberName](...n));
1496
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateMetadata.js
1497
+ function X(e, t) {
1498
+ if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
1683
1499
  }
1684
- const Zt = ns("init");
1685
- async function as(r, t = !0) {
1686
- const e = os("init", r, t);
1687
- await Promise.all(e);
1500
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
1501
+ function Ee(e, t, n, r) {
1502
+ var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
1503
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
1504
+ else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
1505
+ return i > 3 && a && Object.defineProperty(t, n, a), a;
1688
1506
  }
1689
- var cs = Object.defineProperty, ls = Object.getOwnPropertyDescriptor, us = (r, t, e, n) => {
1690
- for (var o = ls(t, e), l = r.length - 1, g; l >= 0; l--)
1691
- (g = r[l]) && (o = g(t, e, o) || o);
1692
- return o && cs(t, e, o), o;
1507
+ // src/CanvasMove.ts
1508
+ var De = class {
1509
+ constructor() {
1510
+ this.events = z(this, U), this.selection = z(this, W), this.objectRegistry = z(this, V), this.space = z(this, Y), this.movingIds = /* @__PURE__ */ new Set(), this.moveOriginPos = null;
1511
+ }
1512
+ init() {
1513
+ this.events.dragMove.on((e) => this.onDragMove(e)), this.events.dragEnd.on(() => this.stopMovingSelection()), this.events.unmounted.on(() => this.stopMovingSelection());
1514
+ }
1515
+ isMoving(e) {
1516
+ return this.movingIds.has(e);
1517
+ }
1518
+ startMovingSelection(e) {
1519
+ this.movingIds = new Set(this.selection.getSelectedIds()), this.moveOriginPos = {
1520
+ x: e.pageX,
1521
+ y: e.pageY
1522
+ };
1523
+ for (let e of this.movingIds) this.objectRegistry.get(e)?.onMoveStart();
1524
+ }
1525
+ onDragMove(e) {
1526
+ if (!this.moveOriginPos) return;
1527
+ let t = this.space.pageToLocal(this.moveOriginPos), n = K(this.space.pageToLocal({
1528
+ x: e.pageX,
1529
+ y: e.pageY
1530
+ }), t);
1531
+ for (let e of this.movingIds) this.objectRegistry.get(e)?.onMoveOffset(n);
1532
+ }
1533
+ stopMovingSelection() {
1534
+ for (let e of this.movingIds) this.objectRegistry.get(e)?.onMoveEnd();
1535
+ this.movingIds.clear(), this.moveOriginPos = null;
1536
+ }
1693
1537
  };
1694
- class wt {
1695
- constructor() {
1696
- this.events = b(this, K), this.selection = b(this, Q), this.objectRegistry = b(this, ct), this.space = b(this, V), this.movingIds = /* @__PURE__ */ new Set(), this.moveOriginPos = null;
1697
- }
1698
- init() {
1699
- this.events.dragMove.on((t) => this.onDragMove(t)), this.events.dragEnd.on(() => this.stopMovingSelection()), this.events.unmounted.on(() => this.stopMovingSelection());
1700
- }
1701
- isMoving(t) {
1702
- return this.movingIds.has(t);
1703
- }
1704
- startMovingSelection(t) {
1705
- this.movingIds = new Set(this.selection.getSelectedIds()), this.moveOriginPos = { x: t.pageX, y: t.pageY };
1706
- for (const e of this.movingIds)
1707
- this.objectRegistry.get(e)?.onMoveStart();
1708
- }
1709
- onDragMove(t) {
1710
- if (!this.moveOriginPos)
1711
- return;
1712
- const e = this.space.pageToLocal(this.moveOriginPos), n = this.space.pageToLocal({ x: t.pageX, y: t.pageY }), o = Ht(n, e);
1713
- for (const l of this.movingIds)
1714
- this.objectRegistry.get(l)?.onMoveOffset(o);
1715
- }
1716
- stopMovingSelection() {
1717
- for (const t of this.movingIds)
1718
- this.objectRegistry.get(t)?.onMoveEnd();
1719
- this.movingIds.clear(), this.moveOriginPos = null;
1720
- }
1721
- }
1722
- us([
1723
- Zt()
1724
- ], wt.prototype, "init");
1725
- class hs {
1726
- constructor(t) {
1727
- this.config = b(this, J), this.events = b(this, K), this.selection = b(this, Q), this.move = b(this, wt), this.space = b(this, V), this.element = null, this.selectable = !0, this.movable = !0, this.snapToGrid = !0, this.resizable = "none", this.bounds = [{ x: 1, y: 1 }, { x: 10, y: 10 }], this.pos = { x: 0, y: 0 }, this.localPos = { x: 0, y: 0, w: 1, h: 1 }, this.prevLocalPos = { x: 0, y: 0, w: 1, h: 1 }, this.resizingDirection = null, this.resizingBounds = [{ x: 0, y: 0 }, { x: 0, y: 0 }], this.objectId = t;
1728
- }
1729
- setElement(t) {
1730
- this.element = t;
1731
- }
1732
- getPos() {
1733
- return this.pos;
1734
- }
1735
- setPos(t) {
1736
- this.pos = t, !this.isMoving() && !this.isResizing() && this.recalcLocalPos();
1737
- }
1738
- getBounds() {
1739
- return this.bounds;
1740
- }
1741
- setBounds(t) {
1742
- this.bounds = t, !this.isMoving() && !this.isResizing() && this.recalcLocalPos();
1743
- }
1744
- isSelectable() {
1745
- return this.selectable;
1746
- }
1747
- setSelectable(t) {
1748
- this.selectable = t, t || this.selection.removeFromSelection(this.objectId);
1749
- }
1750
- isSelected() {
1751
- return this.selection.isSelected(this.objectId);
1752
- }
1753
- setSelected(t) {
1754
- t && !this.selectable || this.selection.setSelected(this.objectId, t);
1755
- }
1756
- isMovable() {
1757
- return this.movable;
1758
- }
1759
- setMovable(t) {
1760
- this.movable = t;
1761
- }
1762
- isSnapToGrid() {
1763
- return this.snapToGrid;
1764
- }
1765
- setSnapToGrid(t) {
1766
- this.snapToGrid = t;
1767
- }
1768
- isResizable() {
1769
- return this.resizable;
1770
- }
1771
- setResizable(t) {
1772
- this.resizable = t;
1773
- }
1774
- /* Render state */
1775
- getCanvasCoords() {
1776
- const t = this.space.localToCanvas({ x: this.localPos.x, y: this.localPos.y }), e = this.space.localToCanvas({
1777
- x: this.localPos.x + this.localPos.w,
1778
- y: this.localPos.y + this.localPos.h
1779
- }), n = Ht(e, t), o = this.pos.w === void 0 ? void 0 : n.x, l = this.pos.h === void 0 ? void 0 : n.y;
1780
- return {
1781
- x: t.x,
1782
- y: t.y,
1783
- w: o,
1784
- h: l
1785
- };
1786
- }
1787
- getStyle() {
1788
- const t = this.getCanvasCoords();
1789
- return {
1790
- position: "absolute",
1791
- left: `${t.x}px`,
1792
- top: `${t.y}px`,
1793
- width: t.w === void 0 ? void 0 : `${t.w}px`,
1794
- height: t.h === void 0 ? void 0 : `${t.h}px`
1795
- };
1796
- }
1797
- isMoving() {
1798
- return this.move.isMoving(this.objectId);
1799
- }
1800
- isResizing() {
1801
- return this.resizingDirection != null;
1802
- }
1803
- commitNewPos(t) {
1804
- Object.assign(this.pos, t), this.events.objectPosUpdated.emit({
1805
- objectId: this.objectId,
1806
- pos: { ...this.pos }
1807
- });
1808
- }
1809
- // Event handlers
1810
- /**
1811
- * Click handles selection
1812
- * Shift/Ctrl/Meta key allows multi-select, if allowed by canvas config
1813
- */
1814
- onUiClick(t) {
1815
- if (!this.selectable)
1816
- return;
1817
- const e = t.shiftKey || t.ctrlKey || t.metaKey;
1818
- if (this.config.allowMultiSelect && e) {
1819
- this.selection.toggleSelection(this.objectId);
1820
- return;
1821
- }
1822
- this.selection.selectSingle(this.objectId);
1823
- }
1824
- /**
1825
- * Dragging starts moving selected objects, if allowed.
1826
- * If not selected, single selection is performed first, then dragging starts.
1827
- */
1828
- onUiDragStart(t) {
1829
- this.movable && (this.isSelected() || (t.shiftKey ? this.selection.addToSelection(this.objectId) : this.selection.selectSingle(this.objectId)), !this.isResizing() && !this.isMoving() && this.move.startMovingSelection(t));
1830
- }
1831
- /**
1832
- * Drag move is re-emitted to global canvas events, so that each selected object moves.
1833
- * CanvasMove will call onMoveOffset on objects that are currently moving.
1834
- */
1835
- onUiDragMove(t) {
1836
- this.events.dragMove.emit(t);
1837
- }
1838
- /**
1839
- * Drag end is re-emitted to global canvas events, so that each selected object stops moving.
1840
- * CanvasMove will call onMoveEnd on objects that are currently moving.
1841
- */
1842
- onUiDragEnd(t) {
1843
- this.events.dragEnd.emit(t);
1844
- }
1845
- /* Moving */
1846
- /**
1847
- * Move start is called by CanvasMove when selected objects starts moving.
1848
- * It saves the previous local position, so that the offset can be calculated.
1849
- */
1850
- onMoveStart() {
1851
- this.prevLocalPos = { ...this.localPos };
1852
- }
1853
- /**
1854
- * Move offset is called by CanvasMove when selected objects moves.
1855
- * It calculates the new local position based on the previous local position and the offset.
1856
- */
1857
- onMoveOffset(t) {
1858
- this.movable && (this.localPos = {
1859
- x: this.prevLocalPos.x + t.x,
1860
- y: this.prevLocalPos.y + t.y,
1861
- w: this.prevLocalPos.w,
1862
- h: this.prevLocalPos.h
1863
- });
1864
- }
1865
- /**
1866
- * Move end is called by CanvasMove when selected objects stops moving.
1867
- * It commits the new local position to the object.
1868
- */
1869
- onMoveEnd() {
1870
- this.commitNewPos({
1871
- x: this.maybeRound(this.localPos.x),
1872
- y: this.maybeRound(this.localPos.y)
1873
- });
1874
- }
1875
- /* Resizing */
1876
- startResizing(t) {
1877
- this.resizable === "none" || !this.canResizeInDirection(t) || (this.resizingDirection = t, this.resizingBounds = this.getObjectBounds(), this.selection.selectSingle(this.objectId));
1878
- }
1879
- onResizeMove(t) {
1880
- if (!this.resizingDirection)
1881
- return;
1882
- const e = { x: t.pageX, y: t.pageY }, n = this.space.pageToLocal(e), [o, l] = this.getResizingUpdates(this.resizingDirection, n);
1883
- this.localPos = {
1884
- x: o.x,
1885
- y: o.y,
1886
- w: l.x - o.x,
1887
- h: l.y - o.y
1888
- };
1889
- }
1890
- onResizeEnd() {
1891
- this.resizingDirection && (this.commitNewPos({
1892
- x: this.maybeRound(this.localPos.x),
1893
- y: this.maybeRound(this.localPos.y),
1894
- w: z(this.maybeRound(this.localPos.w), this.bounds[0].x, this.bounds[1].x),
1895
- h: z(this.maybeRound(this.localPos.h), this.bounds[0].y, this.bounds[1].y)
1896
- }), this.resizingDirection = null);
1897
- }
1898
- getResizeDirections() {
1899
- switch (this.resizable) {
1900
- case "both":
1901
- return ["n", "ne", "e", "se", "s", "sw", "w", "nw"];
1902
- case "horizontal":
1903
- return ["e", "w"];
1904
- case "vertical":
1905
- return ["n", "s"];
1906
- default:
1907
- return [];
1908
- }
1909
- }
1910
- getObjectBounds() {
1911
- const t = { x: this.localPos.x, y: this.localPos.y }, e = {
1912
- x: this.localPos.x + this.localPos.w,
1913
- y: this.localPos.y + this.localPos.h
1914
- };
1915
- return [t, e];
1916
- }
1917
- canResizeInDirection(t) {
1918
- return this.getResizeDirections().includes(t);
1919
- }
1920
- recalcLocalPos() {
1921
- const t = this.pos.w ?? this.localPos.w, e = this.pos.h ?? this.localPos.h;
1922
- this.localPos = {
1923
- x: this.pos.x,
1924
- y: this.pos.y,
1925
- w: z(t, this.bounds[0].x, this.bounds[1].x),
1926
- h: z(e, this.bounds[0].y, this.bounds[1].y)
1927
- };
1928
- }
1929
- maybeRound(t) {
1930
- return this.snapToGrid ? Math.round(t) : t;
1931
- }
1932
- getResizingUpdates(t, e) {
1933
- const [n, o] = this.resizingBounds, l = z(e.x, o.x - this.bounds[1].x, o.x - this.bounds[0].x), g = z(e.x, n.x + this.bounds[0].x, n.x + this.bounds[1].x), p = z(e.y, o.y - this.bounds[1].y, o.y - this.bounds[0].y), S = z(e.y, n.y + this.bounds[0].y, n.y + this.bounds[1].y);
1934
- switch (t) {
1935
- case "n":
1936
- return [{ x: n.x, y: p }, { x: o.x, y: o.y }];
1937
- case "s":
1938
- return [{ x: n.x, y: n.y }, { x: o.x, y: S }];
1939
- case "w":
1940
- return [{ x: l, y: n.y }, { x: o.x, y: o.y }];
1941
- case "e":
1942
- return [{ x: n.x, y: n.y }, { x: g, y: o.y }];
1943
- case "ne":
1944
- return [{ x: n.x, y: p }, { x: g, y: o.y }];
1945
- case "nw":
1946
- return [{ x: l, y: p }, { x: o.x, y: o.y }];
1947
- case "se":
1948
- return [{ x: n.x, y: n.y }, { x: g, y: S }];
1949
- case "sw":
1950
- return [{ x: l, y: n.y }, { x: o.x, y: S }];
1951
- default:
1952
- return [{ x: n.x, y: n.y }, { x: o.x, y: o.y }];
1953
- }
1954
- }
1955
- }
1956
- class lt {
1957
- constructor() {
1958
- this.viewportEl = null, this.windowEvents = new Wt(window), this.config = b(this, J), this.space = b(this, V);
1959
- }
1960
- mount(t) {
1961
- this.viewportEl = t, this.recalcCanvasMetrics(), this.updateViewportBox(), this.centerOnOrigin(), this.onScroll(), this.windowEvents.add("resize", () => this.updateViewportBox()), this.windowEvents.add("scroll", () => this.updateViewportBox()), this.config.autoCenter && requestAnimationFrame(() => this.centerOnOrigin());
1962
- }
1963
- destroy() {
1964
- this.windowEvents.removeAll(), this.viewportEl = null, this.space.viewportBox = [{ x: 0, y: 0 }, { x: 0, y: 0 }];
1965
- }
1966
- getCanvasStyle() {
1967
- const t = Gt(this.viewportEl, "--CanvasView-grid-major-fill", "var(--border-deep)"), e = Gt(this.viewportEl, "--CanvasView-grid-minor-fill", "var(--border-base)"), n = W(this.viewportEl, "--CanvasView-grid-subdivisions", 4), o = W(this.viewportEl, "--CanvasView-grid-major-radius", 2), l = W(this.viewportEl, "--CanvasView-grid-minor-radius", 1), g = es(
1968
- this.space.cellSize,
1969
- n,
1970
- t,
1971
- o,
1972
- e,
1973
- l
1974
- );
1975
- return {
1976
- background: `url(${`data:image/svg+xml;base64,${window.btoa(g)}`}) repeat`,
1977
- width: `${this.space.canvasSize.x}px`,
1978
- height: `${this.space.canvasSize.y}px`,
1979
- transformOrigin: "0 0",
1980
- transform: `scale(${this.space.zoom})`
1981
- };
1982
- }
1983
- getOriginStyle() {
1984
- return {
1985
- left: `${this.space.canvasOrigin.x}px`,
1986
- top: `${this.space.canvasOrigin.y}px`
1987
- };
1988
- }
1989
- getSizerStyle() {
1990
- return {
1991
- width: `${this.space.canvasSize.x * this.space.zoom}px`,
1992
- height: `${this.space.canvasSize.y * this.space.zoom}px`
1993
- };
1994
- }
1995
- onScroll() {
1996
- this.viewportEl && (this.space.scrollPos = {
1997
- x: this.viewportEl.scrollLeft,
1998
- y: this.viewportEl.scrollTop
1999
- });
2000
- }
2001
- centerOnOrigin() {
2002
- if (!this.viewportEl)
2003
- return;
2004
- const t = this.getViewportSize();
2005
- this.setViewportScroll({
2006
- x: this.space.canvasOrigin.x * this.space.zoom - t.x * 0.5,
2007
- y: this.space.canvasOrigin.y * this.space.zoom - t.y * 0.5
2008
- });
2009
- }
2010
- scrollBy(t, e) {
2011
- this.viewportEl && this.setViewportScroll({
2012
- x: this.viewportEl.scrollLeft + t,
2013
- y: this.viewportEl.scrollTop + e
2014
- });
2015
- }
2016
- scrollToLocalPoint(t) {
2017
- const e = this.getViewportSize(), n = this.space.localToCanvas(t);
2018
- this.setViewportScroll({
2019
- x: n.x * this.space.zoom - e.x * 0.5,
2020
- y: n.y * this.space.zoom - e.y * 0.5
2021
- });
2022
- }
2023
- setViewportScroll(t) {
2024
- this.viewportEl && (this.viewportEl.scrollTo({
2025
- left: Math.max(0, t.x),
2026
- top: Math.max(0, t.y),
2027
- behavior: "auto"
2028
- }), this.onScroll());
2029
- }
2030
- updateViewportBox() {
2031
- if (!this.viewportEl) {
2032
- this.space.viewportBox = [{ x: 0, y: 0 }, { x: 0, y: 0 }];
2033
- return;
2034
- }
2035
- const t = this.viewportEl.getBoundingClientRect();
2036
- this.space.viewportBox = [
2037
- { x: t.left, y: t.top },
2038
- { x: t.right, y: t.bottom }
2039
- ];
2040
- }
2041
- getViewportSize() {
2042
- return {
2043
- x: this.space.viewportBox[1].x - this.space.viewportBox[0].x,
2044
- y: this.space.viewportBox[1].y - this.space.viewportBox[0].y
2045
- };
2046
- }
2047
- recalcCanvasMetrics() {
2048
- const t = W(this.viewportEl, "--CanvasView-margin-cells", 64);
2049
- this.space.cellSize = W(this.viewportEl, "--CanvasView-grid-cell-size", 32);
2050
- const e = t * this.space.cellSize;
2051
- this.space.canvasSize = { x: e * 2, y: e * 2 }, this.space.canvasOrigin = { x: e, y: e };
2052
- }
2053
- }
2054
- var ds = Object.defineProperty, fs = Object.getOwnPropertyDescriptor, vs = (r, t, e, n) => {
2055
- for (var o = fs(t, e), l = r.length - 1, g; l >= 0; l--)
2056
- (g = r[l]) && (o = g(t, e, o) || o);
2057
- return o && ds(t, e, o), o;
1538
+ Ee([
1539
+ we(),
1540
+ X("design:type", Function),
1541
+ X("design:paramtypes", []),
1542
+ X("design:returntype", void 0)
1543
+ ], De.prototype, "init", null);
1544
+ // src/CanvasObjectController.ts
1545
+ var Oe = class {
1546
+ constructor(e) {
1547
+ this.config = z(this, B), this.events = z(this, U), this.selection = z(this, W), this.move = z(this, De), this.space = z(this, Y), this.element = null, this.selectable = !0, this.movable = !0, this.snapToGrid = !0, this.resizable = "none", this.bounds = [{
1548
+ x: 1,
1549
+ y: 1
1550
+ }, {
1551
+ x: 10,
1552
+ y: 10
1553
+ }], this.pos = {
1554
+ x: 0,
1555
+ y: 0
1556
+ }, this.localPos = {
1557
+ x: 0,
1558
+ y: 0,
1559
+ w: 1,
1560
+ h: 1
1561
+ }, this.prevLocalPos = {
1562
+ x: 0,
1563
+ y: 0,
1564
+ w: 1,
1565
+ h: 1
1566
+ }, this.resizingDirection = null, this.resizingBounds = [{
1567
+ x: 0,
1568
+ y: 0
1569
+ }, {
1570
+ x: 0,
1571
+ y: 0
1572
+ }], this.objectId = e;
1573
+ }
1574
+ setElement(e) {
1575
+ this.element = e;
1576
+ }
1577
+ getPos() {
1578
+ return this.pos;
1579
+ }
1580
+ setPos(e) {
1581
+ this.pos = e, !this.isMoving() && !this.isResizing() && this.recalcLocalPos();
1582
+ }
1583
+ getBounds() {
1584
+ return this.bounds;
1585
+ }
1586
+ setBounds(e) {
1587
+ this.bounds = e, !this.isMoving() && !this.isResizing() && this.recalcLocalPos();
1588
+ }
1589
+ isSelectable() {
1590
+ return this.selectable;
1591
+ }
1592
+ setSelectable(e) {
1593
+ this.selectable = e, e || this.selection.removeFromSelection(this.objectId);
1594
+ }
1595
+ isSelected() {
1596
+ return this.selection.isSelected(this.objectId);
1597
+ }
1598
+ setSelected(e) {
1599
+ (!e || this.selectable) && this.selection.setSelected(this.objectId, e);
1600
+ }
1601
+ isMovable() {
1602
+ return this.movable;
1603
+ }
1604
+ setMovable(e) {
1605
+ this.movable = e;
1606
+ }
1607
+ isSnapToGrid() {
1608
+ return this.snapToGrid;
1609
+ }
1610
+ setSnapToGrid(e) {
1611
+ this.snapToGrid = e;
1612
+ }
1613
+ isResizable() {
1614
+ return this.resizable;
1615
+ }
1616
+ setResizable(e) {
1617
+ this.resizable = e;
1618
+ }
1619
+ getCanvasCoords() {
1620
+ let e = this.space.localToCanvas({
1621
+ x: this.localPos.x,
1622
+ y: this.localPos.y
1623
+ }), t = K(this.space.localToCanvas({
1624
+ x: this.localPos.x + this.localPos.w,
1625
+ y: this.localPos.y + this.localPos.h
1626
+ }), e), n = this.pos.w === void 0 ? void 0 : t.x, r = this.pos.h === void 0 ? void 0 : t.y;
1627
+ return {
1628
+ x: e.x,
1629
+ y: e.y,
1630
+ w: n,
1631
+ h: r
1632
+ };
1633
+ }
1634
+ getStyle() {
1635
+ let e = this.getCanvasCoords();
1636
+ return {
1637
+ position: "absolute",
1638
+ left: `${e.x}px`,
1639
+ top: `${e.y}px`,
1640
+ width: e.w === void 0 ? void 0 : `${e.w}px`,
1641
+ height: e.h === void 0 ? void 0 : `${e.h}px`
1642
+ };
1643
+ }
1644
+ isMoving() {
1645
+ return this.move.isMoving(this.objectId);
1646
+ }
1647
+ isResizing() {
1648
+ return this.resizingDirection != null;
1649
+ }
1650
+ commitNewPos(e) {
1651
+ Object.assign(this.pos, e), this.events.objectPosUpdated.emit({
1652
+ objectId: this.objectId,
1653
+ pos: { ...this.pos }
1654
+ });
1655
+ }
1656
+ onUiClick(e) {
1657
+ if (!this.selectable) return;
1658
+ let t = e.shiftKey || e.ctrlKey || e.metaKey;
1659
+ this.config.allowMultiSelect && t ? this.selection.toggleSelection(this.objectId) : this.selection.selectSingle(this.objectId);
1660
+ }
1661
+ onUiDragStart(e) {
1662
+ this.movable && (this.isSelected() || (e.shiftKey ? this.selection.addToSelection(this.objectId) : this.selection.selectSingle(this.objectId)), !this.isResizing() && !this.isMoving() && this.move.startMovingSelection(e));
1663
+ }
1664
+ onUiDragMove(e) {
1665
+ this.events.dragMove.emit(e);
1666
+ }
1667
+ onUiDragEnd(e) {
1668
+ this.events.dragEnd.emit(e);
1669
+ }
1670
+ onMoveStart() {
1671
+ this.prevLocalPos = { ...this.localPos };
1672
+ }
1673
+ onMoveOffset(e) {
1674
+ this.movable && (this.localPos = {
1675
+ x: this.prevLocalPos.x + e.x,
1676
+ y: this.prevLocalPos.y + e.y,
1677
+ w: this.prevLocalPos.w,
1678
+ h: this.prevLocalPos.h
1679
+ });
1680
+ }
1681
+ onMoveEnd() {
1682
+ this.commitNewPos({
1683
+ x: this.maybeRound(this.localPos.x),
1684
+ y: this.maybeRound(this.localPos.y)
1685
+ });
1686
+ }
1687
+ startResizing(e) {
1688
+ this.resizable !== "none" && this.canResizeInDirection(e) && (this.resizingDirection = e, this.resizingBounds = this.getObjectBounds(), this.selection.selectSingle(this.objectId));
1689
+ }
1690
+ onResizeMove(e) {
1691
+ if (!this.resizingDirection) return;
1692
+ let t = {
1693
+ x: e.pageX,
1694
+ y: e.pageY
1695
+ }, n = this.space.pageToLocal(t), [r, i] = this.getResizingUpdates(this.resizingDirection, n);
1696
+ this.localPos = {
1697
+ x: r.x,
1698
+ y: r.y,
1699
+ w: i.x - r.x,
1700
+ h: i.y - r.y
1701
+ };
1702
+ }
1703
+ onResizeEnd() {
1704
+ this.resizingDirection &&= (this.commitNewPos({
1705
+ x: this.maybeRound(this.localPos.x),
1706
+ y: this.maybeRound(this.localPos.y),
1707
+ w: G(this.maybeRound(this.localPos.w), this.bounds[0].x, this.bounds[1].x),
1708
+ h: G(this.maybeRound(this.localPos.h), this.bounds[0].y, this.bounds[1].y)
1709
+ }), null);
1710
+ }
1711
+ getResizeDirections() {
1712
+ switch (this.resizable) {
1713
+ case "both": return [
1714
+ "n",
1715
+ "ne",
1716
+ "e",
1717
+ "se",
1718
+ "s",
1719
+ "sw",
1720
+ "w",
1721
+ "nw"
1722
+ ];
1723
+ case "horizontal": return ["e", "w"];
1724
+ case "vertical": return ["n", "s"];
1725
+ default: return [];
1726
+ }
1727
+ }
1728
+ getObjectBounds() {
1729
+ return [{
1730
+ x: this.localPos.x,
1731
+ y: this.localPos.y
1732
+ }, {
1733
+ x: this.localPos.x + this.localPos.w,
1734
+ y: this.localPos.y + this.localPos.h
1735
+ }];
1736
+ }
1737
+ canResizeInDirection(e) {
1738
+ return this.getResizeDirections().includes(e);
1739
+ }
1740
+ recalcLocalPos() {
1741
+ let e = this.pos.w ?? this.localPos.w, t = this.pos.h ?? this.localPos.h;
1742
+ this.localPos = {
1743
+ x: this.pos.x,
1744
+ y: this.pos.y,
1745
+ w: G(e, this.bounds[0].x, this.bounds[1].x),
1746
+ h: G(t, this.bounds[0].y, this.bounds[1].y)
1747
+ };
1748
+ }
1749
+ maybeRound(e) {
1750
+ return this.snapToGrid ? Math.round(e) : e;
1751
+ }
1752
+ getResizingUpdates(e, t) {
1753
+ let [n, r] = this.resizingBounds, i = G(t.x, r.x - this.bounds[1].x, r.x - this.bounds[0].x), a = G(t.x, n.x + this.bounds[0].x, n.x + this.bounds[1].x), o = G(t.y, r.y - this.bounds[1].y, r.y - this.bounds[0].y), s = G(t.y, n.y + this.bounds[0].y, n.y + this.bounds[1].y);
1754
+ switch (e) {
1755
+ case "n": return [{
1756
+ x: n.x,
1757
+ y: o
1758
+ }, {
1759
+ x: r.x,
1760
+ y: r.y
1761
+ }];
1762
+ case "s": return [{
1763
+ x: n.x,
1764
+ y: n.y
1765
+ }, {
1766
+ x: r.x,
1767
+ y: s
1768
+ }];
1769
+ case "w": return [{
1770
+ x: i,
1771
+ y: n.y
1772
+ }, {
1773
+ x: r.x,
1774
+ y: r.y
1775
+ }];
1776
+ case "e": return [{
1777
+ x: n.x,
1778
+ y: n.y
1779
+ }, {
1780
+ x: a,
1781
+ y: r.y
1782
+ }];
1783
+ case "ne": return [{
1784
+ x: n.x,
1785
+ y: o
1786
+ }, {
1787
+ x: a,
1788
+ y: r.y
1789
+ }];
1790
+ case "nw": return [{
1791
+ x: i,
1792
+ y: o
1793
+ }, {
1794
+ x: r.x,
1795
+ y: r.y
1796
+ }];
1797
+ case "se": return [{
1798
+ x: n.x,
1799
+ y: n.y
1800
+ }, {
1801
+ x: a,
1802
+ y: s
1803
+ }];
1804
+ case "sw": return [{
1805
+ x: i,
1806
+ y: n.y
1807
+ }, {
1808
+ x: r.x,
1809
+ y: s
1810
+ }];
1811
+ default: return [{
1812
+ x: n.x,
1813
+ y: n.y
1814
+ }, {
1815
+ x: r.x,
1816
+ y: r.y
1817
+ }];
1818
+ }
1819
+ }
1820
+ }, Z = class {
1821
+ constructor() {
1822
+ this.viewportEl = null, this.windowEvents = new _e(window), this.config = z(this, B), this.space = z(this, Y);
1823
+ }
1824
+ mount(e) {
1825
+ this.viewportEl = e, this.recalcCanvasMetrics(), this.updateViewportBox(), this.centerOnOrigin(), this.onScroll(), this.windowEvents.add("resize", () => this.updateViewportBox()), this.windowEvents.add("scroll", () => this.updateViewportBox()), this.config.autoCenter && requestAnimationFrame(() => this.centerOnOrigin());
1826
+ }
1827
+ destroy() {
1828
+ this.windowEvents.removeAll(), this.viewportEl = null, this.space.viewportBox = [{
1829
+ x: 0,
1830
+ y: 0
1831
+ }, {
1832
+ x: 0,
1833
+ y: 0
1834
+ }];
1835
+ }
1836
+ getCanvasStyle() {
1837
+ let e = this.createGridSvg();
1838
+ return {
1839
+ background: `url(${`data:image/svg+xml;base64,${window.btoa(e)}`}) repeat`,
1840
+ width: `${this.space.canvasSize.x}px`,
1841
+ height: `${this.space.canvasSize.y}px`,
1842
+ transformOrigin: "0 0",
1843
+ transform: `scale(${this.space.zoom})`
1844
+ };
1845
+ }
1846
+ getOriginStyle() {
1847
+ return {
1848
+ left: `${this.space.canvasOrigin.x}px`,
1849
+ top: `${this.space.canvasOrigin.y}px`
1850
+ };
1851
+ }
1852
+ getSizerStyle() {
1853
+ return {
1854
+ width: `${this.space.canvasSize.x * this.space.zoom}px`,
1855
+ height: `${this.space.canvasSize.y * this.space.zoom}px`
1856
+ };
1857
+ }
1858
+ onScroll() {
1859
+ this.viewportEl && (this.space.scrollPos = {
1860
+ x: this.viewportEl.scrollLeft,
1861
+ y: this.viewportEl.scrollTop
1862
+ });
1863
+ }
1864
+ centerOnOrigin() {
1865
+ if (!this.viewportEl) return;
1866
+ let e = this.getViewportSize();
1867
+ this.setViewportScroll({
1868
+ x: this.space.canvasOrigin.x * this.space.zoom - e.x * .5,
1869
+ y: this.space.canvasOrigin.y * this.space.zoom - e.y * .5
1870
+ });
1871
+ }
1872
+ scrollBy(e, t) {
1873
+ this.viewportEl && this.setViewportScroll({
1874
+ x: this.viewportEl.scrollLeft + e,
1875
+ y: this.viewportEl.scrollTop + t
1876
+ });
1877
+ }
1878
+ scrollToLocalPoint(e) {
1879
+ let t = this.getViewportSize(), n = this.space.localToCanvas(e);
1880
+ this.setViewportScroll({
1881
+ x: n.x * this.space.zoom - t.x * .5,
1882
+ y: n.y * this.space.zoom - t.y * .5
1883
+ });
1884
+ }
1885
+ createGridSvg() {
1886
+ let e = this.space.cellSize, t = q(this.viewportEl, "--CanvasView-grid-subdivisions", 4), n = Math.round(e / t), r = Array.from({ length: t + 1 }, (e, t) => t * n);
1887
+ r[t] = e;
1888
+ let i = [{
1889
+ coords: r,
1890
+ radius: q(this.viewportEl, "--CanvasView-grid-minor-radius", 1),
1891
+ fill: J(this.viewportEl, "--CanvasView-grid-minor-fill", "var(--border-base)")
1892
+ }, {
1893
+ coords: [0, e],
1894
+ radius: q(this.viewportEl, "--CanvasView-grid-major-radius", 2),
1895
+ fill: J(this.viewportEl, "--CanvasView-grid-major-fill", "var(--border-deep)")
1896
+ }].filter((e) => e.radius > 0).flatMap((e) => e.coords.flatMap((t) => e.coords.map((n) => `<circle cx="${t}" cy="${n}" r="${e.radius}" fill="${e.fill}"/>`)));
1897
+ return [
1898
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}" viewBox="0 0 ${e} ${e}">`,
1899
+ ...i,
1900
+ "</svg>"
1901
+ ].join("");
1902
+ }
1903
+ setViewportScroll(e) {
1904
+ this.viewportEl && (this.viewportEl.scrollTo({
1905
+ left: Math.max(0, e.x),
1906
+ top: Math.max(0, e.y),
1907
+ behavior: "auto"
1908
+ }), this.onScroll());
1909
+ }
1910
+ updateViewportBox() {
1911
+ if (!this.viewportEl) {
1912
+ this.space.viewportBox = [{
1913
+ x: 0,
1914
+ y: 0
1915
+ }, {
1916
+ x: 0,
1917
+ y: 0
1918
+ }];
1919
+ return;
1920
+ }
1921
+ let e = this.viewportEl.getBoundingClientRect();
1922
+ this.space.viewportBox = [{
1923
+ x: e.left,
1924
+ y: e.top
1925
+ }, {
1926
+ x: e.right,
1927
+ y: e.bottom
1928
+ }];
1929
+ }
1930
+ getViewportSize() {
1931
+ return {
1932
+ x: this.space.viewportBox[1].x - this.space.viewportBox[0].x,
1933
+ y: this.space.viewportBox[1].y - this.space.viewportBox[0].y
1934
+ };
1935
+ }
1936
+ recalcCanvasMetrics() {
1937
+ let e = q(this.viewportEl, "--CanvasView-margin-cells", 64);
1938
+ this.space.cellSize = q(this.viewportEl, "--CanvasView-grid-cell-size", 32);
1939
+ let t = e * this.space.cellSize;
1940
+ this.space.canvasSize = {
1941
+ x: t * 2,
1942
+ y: t * 2
1943
+ }, this.space.canvasOrigin = {
1944
+ x: t,
1945
+ y: t
1946
+ };
1947
+ }
1948
+ }, Q = class {
1949
+ constructor() {
1950
+ this.viewport = z(this, Z), this.events = z(this, U), this.windowEvents = new _e(window), this.isPanning = !1;
1951
+ }
1952
+ init() {
1953
+ this.events.unmounted.on(() => this.stopPanning());
1954
+ }
1955
+ onMouseDown(e) {
1956
+ e.button === 1 && (e.preventDefault(), this.isPanning = !0, this.windowEvents.add("mousemove", (e) => this.onMouseMove(e)), this.windowEvents.add("mouseup", (e) => this.onMouseUp(e)));
1957
+ }
1958
+ stopPanning() {
1959
+ this.isPanning = !1, this.windowEvents.removeAll();
1960
+ }
1961
+ onMouseMove(e) {
1962
+ this.isPanning && this.viewport.scrollBy(-e.movementX, -e.movementY);
1963
+ }
1964
+ onMouseUp(e) {
1965
+ e.button === 1 && this.stopPanning();
1966
+ }
2058
1967
  };
2059
- class gt {
2060
- constructor() {
2061
- this.viewport = b(this, lt), this.events = b(this, K), this.windowEvents = new Wt(window), this.isPanning = !1;
2062
- }
2063
- init() {
2064
- this.events.unmounted.on(() => this.stopPanning());
2065
- }
2066
- onMouseDown(t) {
2067
- t.button === 1 && (t.preventDefault(), this.isPanning = !0, this.windowEvents.add("mousemove", (e) => this.onMouseMove(e)), this.windowEvents.add("mouseup", (e) => this.onMouseUp(e)));
2068
- }
2069
- stopPanning() {
2070
- this.isPanning = !1, this.windowEvents.removeAll();
2071
- }
2072
- onMouseMove(t) {
2073
- this.isPanning && this.viewport.scrollBy(-t.movementX, -t.movementY);
2074
- }
2075
- onMouseUp(t) {
2076
- t.button === 1 && this.stopPanning();
2077
- }
2078
- }
2079
- vs([
2080
- Zt()
2081
- ], gt.prototype, "init");
2082
- const k = [0.33, 0.5, 0.6, 0.75, 0.85, 1, 1.15, 1.25, 1.5, 1.75, 2], ps = Math.min(...k), ys = Math.max(...k);
2083
- class Ft {
2084
- constructor() {
2085
- this.viewport = b(this, lt), this.space = b(this, V);
2086
- }
2087
- onWheel(t) {
2088
- if (!t.ctrlKey)
2089
- return;
2090
- t.preventDefault();
2091
- const e = z(t.deltaY, -40, 40) / 400, n = Math.exp(-e);
2092
- this.setZoom(this.space.zoom * n);
2093
- }
2094
- setZoom(t) {
2095
- const e = this.space.getViewportCenterInLocal();
2096
- this.space.zoom = z(t, ps, ys), this.viewport.scrollToLocalPoint(e);
2097
- }
2098
- zoomIn() {
2099
- const t = this.getClosestZoomStepIndex();
2100
- t < k.length - 1 && this.setZoom(k[t + 1]);
2101
- }
2102
- zoomOut() {
2103
- const t = this.getClosestZoomStepIndex();
2104
- t > 0 && this.setZoom(k[t - 1]);
2105
- }
2106
- getClosestZoomStepIndex() {
2107
- let t = 0, e = Number.POSITIVE_INFINITY;
2108
- for (let n = 0; n < k.length; n++) {
2109
- const o = Math.abs(k[n] - this.space.zoom);
2110
- o < e && (e = o, t = n);
2111
- }
2112
- return t;
2113
- }
2114
- }
2115
- class Ss {
2116
- constructor(t = {}) {
2117
- this.mesh = Ee(new at()), this.boxSelect = b(this, $t), this.config = b(this, J), this.space = b(this, V), this.viewport = b(this, lt), this.pan = b(this, gt), this.events = b(this, K), this.inputStateManager = b(this, rt), this.objectRegistry = b(this, ct), this.selection = b(this, Q), this.zoom = b(this, Ft);
2118
- const e = t.inputStateManager ?? new rt();
2119
- this.ownsInputStateManager = t.inputStateManager == null, this.mesh.connect(this), this.mesh.use((n) => Ie(n)), this.mesh.constant(rt, e), this.mesh.service($t), this.mesh.service(lt), this.mesh.service(gt), this.mesh.service(J), this.mesh.service(V), this.mesh.service(K), this.mesh.service(wt), this.mesh.service(ct), this.mesh.service(Q), this.mesh.service(Ft), this.config.set(t), as(this.mesh);
2120
- }
2121
- createObjectController(t) {
2122
- return this.mesh.connect(new hs(t));
2123
- }
2124
- mount(t) {
2125
- this.viewport.mount(t), this.events.mounted.emit(), this.ownsInputStateManager && this.inputStateManager.mount();
2126
- }
2127
- unmount() {
2128
- this.viewport.destroy(), this.ownsInputStateManager && this.inputStateManager.unmount(), this.events.unmounted.emit();
2129
- }
2130
- }
2131
- export {
2132
- De as CanvasBoxSelect,
2133
- J as CanvasConfig,
2134
- Ss as CanvasController,
2135
- ws as CanvasDebugCoords,
2136
- K as CanvasEvents,
2137
- ms as CanvasObject,
2138
- hs as CanvasObjectController,
2139
- ct as CanvasObjectRegistry,
2140
- gt as CanvasPan,
2141
- Q as CanvasSelection,
2142
- V as CanvasSpace,
2143
- bs as CanvasView,
2144
- lt as CanvasViewport,
2145
- Ft as CanvasZoom,
2146
- rt as InputStateManager
1968
+ Ee([
1969
+ we(),
1970
+ X("design:type", Function),
1971
+ X("design:paramtypes", []),
1972
+ X("design:returntype", void 0)
1973
+ ], Q.prototype, "init", null);
1974
+ // src/CanvasZoom.ts
1975
+ var $ = [
1976
+ .33,
1977
+ .5,
1978
+ .6,
1979
+ .75,
1980
+ .85,
1981
+ 1,
1982
+ 1.15,
1983
+ 1.25,
1984
+ 1.5,
1985
+ 1.75,
1986
+ 2
1987
+ ], ke = Math.min(...$), Ae = Math.max(...$), je = class {
1988
+ constructor() {
1989
+ this.viewport = z(this, Z), this.space = z(this, Y);
1990
+ }
1991
+ onWheel(e) {
1992
+ if (!e.ctrlKey) return;
1993
+ e.preventDefault();
1994
+ let t = G(e.deltaY, -40, 40) / 400, n = Math.exp(-t);
1995
+ this.setZoom(this.space.zoom * n);
1996
+ }
1997
+ setZoom(e) {
1998
+ let t = this.space.getViewportCenterInLocal();
1999
+ this.space.zoom = G(e, ke, Ae), this.viewport.scrollToLocalPoint(t);
2000
+ }
2001
+ zoomIn() {
2002
+ let e = this.getClosestZoomStepIndex();
2003
+ e < $.length - 1 && this.setZoom($[e + 1]);
2004
+ }
2005
+ zoomOut() {
2006
+ let e = this.getClosestZoomStepIndex();
2007
+ e > 0 && this.setZoom($[e - 1]);
2008
+ }
2009
+ getClosestZoomStepIndex() {
2010
+ let e = 0, t = Infinity;
2011
+ for (let n = 0; n < $.length; n++) {
2012
+ let r = Math.abs($[n] - this.space.zoom);
2013
+ r < t && (t = r, e = n);
2014
+ }
2015
+ return e;
2016
+ }
2017
+ }, Me = class {
2018
+ constructor(e = {}) {
2019
+ this.mesh = s(new F()), this.boxSelect = z(this, ve), this.config = z(this, B), this.space = z(this, Y), this.viewport = z(this, Z), this.pan = z(this, Q), this.events = z(this, U), this.inputStateManager = z(this, k), this.objectRegistry = z(this, V), this.selection = z(this, W), this.zoom = z(this, je);
2020
+ let t = e.inputStateManager ?? new k();
2021
+ this.ownsInputStateManager = e.inputStateManager == null, this.mesh.connect(this), this.mesh.use((e) => f(e)), this.mesh.constant(k, t), this.mesh.service(ve), this.mesh.service(Z), this.mesh.service(Q), this.mesh.service(B), this.mesh.service(Y), this.mesh.service(U), this.mesh.service(De), this.mesh.service(V), this.mesh.service(W), this.mesh.service(je), this.config.set(e), Te(this.mesh);
2022
+ }
2023
+ createObjectController(e) {
2024
+ return this.mesh.connect(new Oe(e));
2025
+ }
2026
+ mount(e) {
2027
+ this.viewport.mount(e), this.events.mounted.emit(), this.ownsInputStateManager && this.inputStateManager.mount();
2028
+ }
2029
+ unmount() {
2030
+ this.viewport.destroy(), this.ownsInputStateManager && this.inputStateManager.unmount(), this.events.unmounted.emit();
2031
+ }
2147
2032
  };
2033
+ export { b as CanvasBoxSelect, B as CanvasConfig, Me as CanvasController, oe as CanvasDebugCoords, U as CanvasEvents, w as CanvasObject, Oe as CanvasObjectController, V as CanvasObjectRegistry, Q as CanvasPan, W as CanvasSelection, Y as CanvasSpace, T as CanvasView, Z as CanvasViewport, je as CanvasZoom, k as InputStateManager };