@reffy/infinite-canvas 0.0.10 → 0.0.11

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/index.js CHANGED
@@ -1,24 +1,24 @@
1
- var ie = (s) => {
1
+ var se = (s) => {
2
2
  throw TypeError(s);
3
3
  };
4
- var se = (s, t, e) => t.has(s) || ie("Cannot " + e);
5
- var l = (s, t, e) => (se(s, t, "read from private field"), e ? e.call(s) : t.get(s)), L = (s, t, e) => t.has(s) ? ie("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), I = (s, t, e, i) => (se(s, t, "write to private field"), i ? i.call(s, e) : t.set(s, e), e);
6
- import { makeObservable as Me, computed as st, action as b, observable as B, reaction as Qe } from "mobx";
7
- import { css as Je, LitElement as ti } from "lit";
4
+ var re = (s, t, e) => t.has(s) || se("Cannot " + e);
5
+ var f = (s, t, e) => (re(s, t, "read from private field"), e ? e.call(s) : t.get(s)), O = (s, t, e) => t.has(s) ? se("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), I = (s, t, e, i) => (re(s, t, "write to private field"), i ? i.call(s, e) : t.set(s, e), e);
6
+ import { makeObservable as Ee, computed as nt, action as b, observable as B, reaction as Je } from "mobx";
7
+ import { css as ti, LitElement as ei } from "lit";
8
8
  import Y from "dexie";
9
- import { v4 as ei } from "uuid";
10
- import ii from "eventemitter3";
11
- import si from "stats.js";
12
- const pt = ["TOP", "BOTTOM", "LEFT", "RIGHT"], Mt = ["TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT"], re = {
9
+ import { v4 as ii } from "uuid";
10
+ import si from "eventemitter3";
11
+ import ri from "stats.js";
12
+ const yt = ["TOP", "BOTTOM", "LEFT", "RIGHT"], Et = ["TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT"], ne = {
13
13
  TOPLEFT: "TOPRIGHT",
14
14
  TOPRIGHT: "TOPLEFT",
15
15
  BOTTOMLEFT: "BOTTOMRIGHT",
16
16
  BOTTOMRIGHT: "BOTTOMLEFT"
17
17
  };
18
- function ne(s) {
19
- return re[s] ? re[s] : s;
18
+ function ae(s) {
19
+ return ne[s] ? ne[s] : s;
20
20
  }
21
- const Ee = 8, qt = 2, M = {
21
+ const Te = 8, Kt = 2, E = {
22
22
  identity: function() {
23
23
  return [1, 0, 0, 0, 1, 0, 0, 0, 1];
24
24
  },
@@ -33,22 +33,22 @@ const Ee = 8, qt = 2, M = {
33
33
  return [s, 0, 0, 0, t, 0, 0, 0, 1];
34
34
  },
35
35
  multiply: function(s, t) {
36
- var e = s[0], i = s[1], r = s[2], n = s[3], a = s[4], o = s[5], h = s[6], c = s[7], u = s[8], f = t[0], g = t[1], m = t[2], w = t[3], x = t[4], C = t[5], v = t[6], A = t[7], T = t[8];
36
+ var e = s[0], i = s[1], r = s[2], n = s[3], a = s[4], o = s[5], h = s[6], c = s[7], l = s[8], u = t[0], g = t[1], m = t[2], w = t[3], x = t[4], C = t[5], v = t[6], A = t[7], T = t[8];
37
37
  return [
38
- f * e + g * n + m * h,
39
- f * i + g * a + m * c,
40
- f * r + g * o + m * u,
38
+ u * e + g * n + m * h,
39
+ u * i + g * a + m * c,
40
+ u * r + g * o + m * l,
41
41
  w * e + x * n + C * h,
42
42
  w * i + x * a + C * c,
43
- w * r + x * o + C * u,
43
+ w * r + x * o + C * l,
44
44
  v * e + A * n + T * h,
45
45
  v * i + A * a + T * c,
46
- v * r + A * o + T * u
46
+ v * r + A * o + T * l
47
47
  ];
48
48
  },
49
49
  inverse(s) {
50
- const t = [9], e = s[0], i = s[1], r = s[2], n = s[3], a = s[4], o = s[5], h = s[6], c = s[7], u = s[8], f = u * a - o * c, g = -u * n + o * h, m = c * n - a * h, x = 1 / (e * f + i * g + r * m);
51
- return t[0] = f * x, t[1] = (-u * i + r * c) * x, t[2] = (o * i - r * a) * x, t[3] = g * x, t[4] = (u * e - r * h) * x, t[5] = (-o * e + r * n) * x, t[6] = m * x, t[7] = (-c * e + i * h) * x, t[8] = (a * e - i * n) * x, t;
50
+ const t = [9], e = s[0], i = s[1], r = s[2], n = s[3], a = s[4], o = s[5], h = s[6], c = s[7], l = s[8], u = l * a - o * c, g = -l * n + o * h, m = c * n - a * h, x = 1 / (e * u + i * g + r * m);
51
+ return t[0] = u * x, t[1] = (-l * i + r * c) * x, t[2] = (o * i - r * a) * x, t[3] = g * x, t[4] = (l * e - r * h) * x, t[5] = (-o * e + r * n) * x, t[6] = m * x, t[7] = (-c * e + i * h) * x, t[8] = (a * e - i * n) * x, t;
52
52
  },
53
53
  projection(s, t) {
54
54
  const e = [9];
@@ -62,27 +62,27 @@ const Ee = 8, qt = 2, M = {
62
62
  ];
63
63
  }
64
64
  };
65
- function Xt(s, t, e) {
66
- const i = ae(s, s.VERTEX_SHADER, t), r = ae(s, s.FRAGMENT_SHADER, e), n = s.createProgram();
65
+ function Ht(s, t, e) {
66
+ const i = oe(s, s.VERTEX_SHADER, t), r = oe(s, s.FRAGMENT_SHADER, e), n = s.createProgram();
67
67
  if (s.attachShader(n, i), s.attachShader(n, r), s.linkProgram(n), !s.getProgramParameter(n, s.LINK_STATUS))
68
68
  throw s.deleteProgram(n), s.deleteShader(i), s.deleteShader(r), new Error(
69
69
  "Program was not created or the link to shaders was not successful."
70
70
  );
71
71
  return s.detachShader(n, i), s.detachShader(n, r), n;
72
72
  }
73
- function ae(s, t, e) {
73
+ function oe(s, t, e) {
74
74
  const i = s.createShader(t);
75
75
  if (s.shaderSource(i, e), s.compileShader(i), s.getShaderParameter(i, s.COMPILE_STATUS))
76
76
  return i;
77
77
  throw s.deleteShader(i), new Error("Shader was not created.");
78
78
  }
79
- function ri(s, t, e, i, r, n) {
80
- const a = r.getBoundingClientRect(), o = window.devicePixelRatio || 1, h = (s - a.left) * o, c = (t - a.top) * o, u = h / e * 2 - 1, f = c / i * -2 + 1, g = M.projection(e, i), m = M.multiply(g, n), w = M.inverse(m), [x, C] = M.transformPoint(w, [u, f]);
79
+ function ni(s, t, e, i, r, n) {
80
+ const a = r.getBoundingClientRect(), o = window.devicePixelRatio || 1, h = (s - a.left) * o, c = (t - a.top) * o, l = h / e * 2 - 1, u = c / i * -2 + 1, g = E.projection(e, i), m = E.multiply(g, n), w = E.inverse(m), [x, C] = E.transformPoint(w, [l, u]);
81
81
  return [x, C];
82
82
  }
83
- function wt(s, t, e) {
83
+ function K(s, t, e) {
84
84
  const { gl: i, canvas: r } = e;
85
- return ri(
85
+ return ni(
86
86
  s,
87
87
  t,
88
88
  i.canvas.width,
@@ -98,26 +98,26 @@ function U(s, t, e) {
98
98
  s[1] * i + s[4] * r + s[7]
99
99
  ];
100
100
  }
101
- function ni(s) {
101
+ function ai(s) {
102
102
  return Math.hypot(s[0], s[1]);
103
103
  }
104
- function ai(s) {
104
+ function oi(s) {
105
105
  return Math.hypot(s[3], s[4]);
106
106
  }
107
- function J(s) {
108
- return [ni(s), ai(s)];
107
+ function tt(s) {
108
+ return [ai(s), oi(s)];
109
109
  }
110
- function oe(s) {
110
+ function he(s) {
111
111
  return s / Math.abs(s);
112
112
  }
113
- function Et(s) {
114
- return [oe(s[0]), oe(s[4])];
113
+ function Tt(s) {
114
+ return [he(s[0]), he(s[4])];
115
115
  }
116
- const Lt = (s, t) => Math.abs(s) < t ? 0 : Math.sign(s), Dt = (s, t, e) => {
116
+ const Dt = (s, t) => Math.abs(s) < t ? 0 : Math.sign(s), Bt = (s, t, e) => {
117
117
  const i = s * t;
118
- return Lt(s, e) !== Lt(i, e);
118
+ return Dt(s, e) !== Dt(i, e);
119
119
  };
120
- async function oi(s) {
120
+ async function hi(s) {
121
121
  return new Promise((t, e) => {
122
122
  let i = new FileReader();
123
123
  i.onload = (r) => {
@@ -125,7 +125,7 @@ async function oi(s) {
125
125
  }, i.onerror = e, i.readAsDataURL(s);
126
126
  });
127
127
  }
128
- const hi = [
128
+ const ci = [
129
129
  "image/webp",
130
130
  "image/png",
131
131
  "image/jpeg",
@@ -137,25 +137,25 @@ const hi = [
137
137
  "image/apng"
138
138
  // will be rendered as a still image
139
139
  ];
140
- function ci(s) {
141
- return hi.includes(s);
140
+ function di(s) {
141
+ return ci.includes(s);
142
142
  }
143
- async function Kt(s) {
143
+ async function Qt(s) {
144
144
  const e = new TextEncoder().encode(s), i = await crypto.subtle.digest("SHA-256", e);
145
145
  return Array.from(new Uint8Array(i)).map((n) => n.toString(16).padStart(2, "0")).join("");
146
146
  }
147
- function di(s) {
147
+ function li(s) {
148
148
  const t = /^data:([^;]+);base64,/.exec(s);
149
149
  return t ? t[1] : void 0;
150
150
  }
151
- async function li(s, t) {
151
+ async function ui(s, t) {
152
152
  const e = [];
153
153
  if (s.length > 0)
154
154
  for (let i = 0; i < s.length; i++) {
155
155
  const r = s[i];
156
- if (ci(r.type))
156
+ if (di(r.type))
157
157
  try {
158
- const n = await oi(r);
158
+ const n = await hi(r);
159
159
  typeof n == "string" ? e.push(await t(n)) : console.error("Image not added");
160
160
  } catch {
161
161
  console.error("Failed to copy image.");
@@ -163,15 +163,15 @@ async function li(s, t) {
163
163
  }
164
164
  return e;
165
165
  }
166
- function ui(s, t) {
166
+ function fi(s, t) {
167
167
  const e = JSON.stringify(t, null, 2), i = new Blob([e], { type: "application/json" }), r = URL.createObjectURL(i), n = document.createElement("a");
168
168
  n.href = r, n.download = s, document.body.appendChild(n), n.click(), n.remove(), URL.revokeObjectURL(r);
169
169
  }
170
- async function fi(s) {
170
+ async function mi(s) {
171
171
  const t = await s.text();
172
172
  return JSON.parse(t);
173
173
  }
174
- function Te(s, t = 1) {
174
+ function _e(s, t = 1) {
175
175
  return new Promise((e, i) => {
176
176
  const r = new Image();
177
177
  r.onload = () => {
@@ -184,18 +184,18 @@ function Te(s, t = 1) {
184
184
  }, r.onerror = i, r.src = s;
185
185
  });
186
186
  }
187
- const nt = [0.33, 0.6, 0.95, 1], bt = [
187
+ const ot = [0.33, 0.6, 0.95, 1], Ct = [
188
188
  0.33,
189
189
  0.6,
190
190
  0.95,
191
191
  0.6
192
- ], mi = [
192
+ ], gi = [
193
193
  0.33,
194
194
  0.6,
195
195
  0.95,
196
196
  0.4
197
197
  ];
198
- function Bt(s, t, e = "Add Child") {
198
+ function zt(s, t, e = "Add Child") {
199
199
  return {
200
200
  label: e,
201
201
  do() {
@@ -208,7 +208,7 @@ function Bt(s, t, e = "Add Child") {
208
208
  }
209
209
  };
210
210
  }
211
- function gi(s, t, e = "Remove Child") {
211
+ function pi(s, t, e = "Remove Child") {
212
212
  let i = -1;
213
213
  return {
214
214
  label: e,
@@ -224,7 +224,7 @@ function gi(s, t, e = "Remove Child") {
224
224
  }
225
225
  };
226
226
  }
227
- function pi(s, t, e = "Remove Children") {
227
+ function xi(s, t, e = "Remove Children") {
228
228
  let i = [];
229
229
  return {
230
230
  label: e,
@@ -247,8 +247,8 @@ function pi(s, t, e = "Remove Children") {
247
247
  }
248
248
  };
249
249
  }
250
- const xi = ["image/", "text/plain"], yi = () => "clipboard" in navigator && "writeText" in navigator.clipboard;
251
- async function _e(s, t) {
250
+ const yi = ["image/", "text/plain"], wi = () => "clipboard" in navigator && "writeText" in navigator.clipboard;
251
+ async function Re(s, t) {
252
252
  const e = {
253
253
  type: "infinite_canvas",
254
254
  elements: s.map((n) => ({
@@ -261,17 +261,17 @@ async function _e(s, t) {
261
261
  }, i = JSON.stringify(e), r = new ClipboardItem({
262
262
  "text/plain": new Blob([i], { type: "text/plain" })
263
263
  });
264
- if (yi())
264
+ if (wi())
265
265
  try {
266
266
  await navigator.clipboard.write([r]);
267
267
  return;
268
268
  } catch (n) {
269
269
  console.error(n);
270
270
  }
271
- if (!wi(i))
271
+ if (!vi(i))
272
272
  throw new Error("Error copying to clipboard.");
273
273
  }
274
- function wi(s) {
274
+ function vi(s) {
275
275
  s || (s = " ");
276
276
  const t = document.documentElement.getAttribute("dir") === "rtl", e = document.createElement("textarea");
277
277
  e.style.border = "0", e.style.padding = "0", e.style.margin = "0", e.style.position = "absolute", e.style[t ? "right" : "left"] = "-9999px";
@@ -285,16 +285,16 @@ function wi(s) {
285
285
  }
286
286
  return e.remove(), r;
287
287
  }
288
- async function Re(s, t, e, i, r = !0) {
289
- const n = await navigator.clipboard.read(), a = n[0].types, [o, h] = r ? [s, t] : wt(s, t, e);
288
+ async function Ie(s, t, e, i, r = !0) {
289
+ const n = await navigator.clipboard.read(), a = n[0].types, [o, h] = r ? [s, t] : K(s, t, e);
290
290
  for (const c of a) {
291
- if (!xi.find(
291
+ if (!yi.find(
292
292
  (m) => m.endsWith("/") ? c.startsWith(m) : c === m
293
293
  )) continue;
294
- const f = await n[0].getType(c);
294
+ const u = await n[0].getType(c);
295
295
  try {
296
296
  if (c === "text/plain") {
297
- const m = JSON.parse(await f.text());
297
+ const m = JSON.parse(await u.text());
298
298
  if (m.elements.length === 0) return;
299
299
  let w = 1 / 0, x = 1 / 0;
300
300
  for (const v of m.elements)
@@ -310,7 +310,7 @@ async function Re(s, t, e, i, r = !0) {
310
310
  )
311
311
  )
312
312
  );
313
- i.push(Bt(e, C));
313
+ i.push(zt(e, C));
314
314
  return;
315
315
  }
316
316
  } catch (m) {
@@ -320,8 +320,8 @@ async function Re(s, t, e, i, r = !0) {
320
320
  let g;
321
321
  if (c.startsWith("image/svg"))
322
322
  try {
323
- const m = await f.text();
324
- g = await Te(
323
+ const m = await u.text();
324
+ g = await _e(
325
325
  `data:image/svg+xml;base64,${btoa(m)}`
326
326
  );
327
327
  } catch (m) {
@@ -332,7 +332,7 @@ async function Re(s, t, e, i, r = !0) {
332
332
  try {
333
333
  g = await new Promise((m, w) => {
334
334
  const x = new FileReader();
335
- x.onloadend = () => m(x.result), x.onerror = w, x.readAsDataURL(f);
335
+ x.onloadend = () => m(x.result), x.onerror = w, x.readAsDataURL(u);
336
336
  });
337
337
  } catch (m) {
338
338
  console.error("Image read failed", m);
@@ -340,7 +340,7 @@ async function Re(s, t, e, i, r = !0) {
340
340
  }
341
341
  try {
342
342
  const m = await e.addImageToCanvas(g, o, h);
343
- i.push(Bt(e, [m]));
343
+ i.push(zt(e, [m]));
344
344
  return;
345
345
  } catch (m) {
346
346
  console.error("Failed to add image to canvas", m);
@@ -354,14 +354,14 @@ const H = {
354
354
  }, N = {
355
355
  Save: "save",
356
356
  Change: "statechange"
357
- }, tt = {
357
+ }, it = {
358
358
  start: "startloading",
359
359
  done: "completeloading"
360
- }, et = {
360
+ }, st = {
361
361
  Save: "save",
362
362
  SaveCompleted: "savecompleted",
363
363
  SaveFailed: "savefailed"
364
- }, vi = `
364
+ }, bi = `
365
365
  attribute vec2 a_position;
366
366
 
367
367
  uniform vec2 u_resolution;
@@ -379,14 +379,14 @@ void main() {
379
379
 
380
380
  gl_Position = vec4(clipSpace * vec2(1, -1), z, 1);
381
381
  }
382
- `, bi = `
382
+ `, Ci = `
383
383
  precision mediump float;
384
384
  uniform vec4 u_color;
385
385
 
386
386
  void main() {
387
387
  gl_FragColor = u_color;
388
388
  }
389
- `, Ci = (
389
+ `, Si = (
390
390
  /* glsl */
391
391
  `
392
392
  #extension GL_OES_standard_derivatives : enable
@@ -417,7 +417,7 @@ void main() {
417
417
  gl_Position = vec4(a_Position, z, 1.0);
418
418
  }
419
419
  `
420
- ), Si = (
420
+ ), Mi = (
421
421
  /* glsl */
422
422
  `
423
423
  #extension GL_OES_standard_derivatives : enable
@@ -478,7 +478,7 @@ void main() {
478
478
  gl_FragColor = render_grid_checkerboard(v_Position);
479
479
  }
480
480
  `
481
- ), Mi = `
481
+ ), Ei = `
482
482
  attribute vec2 a_position;
483
483
  attribute vec2 a_texCoord;
484
484
 
@@ -499,7 +499,7 @@ void main() {
499
499
 
500
500
  v_texCoord = a_texCoord;
501
501
  }
502
- `, Ei = `
502
+ `, Ti = `
503
503
  #ifdef GL_FRAGMENT_PRECISION_HIGH
504
504
  precision highp float;
505
505
  #else
@@ -515,45 +515,45 @@ void main() {
515
515
  }
516
516
  `;
517
517
  var z = /* @__PURE__ */ ((s) => (s[s.ACTIVE = 0] = "ACTIVE", s[s.PASSIVE = 1] = "PASSIVE", s))(z || {});
518
- class he {
518
+ class ce {
519
519
  constructor(t, e) {
520
- this.sides = /* @__PURE__ */ new Map(), this.corners = /* @__PURE__ */ new Map(), this.borderSize = 0, this.boxSize = 0, this.mode = z.ACTIVE, this.target = t, this.setDimension(), this.mode = e ?? z.ACTIVE, this.borderSize = qt, this.boxSize = Ee / 2, this.addSides(), this.mode === z.ACTIVE && this.addCorners();
520
+ this.sides = /* @__PURE__ */ new Map(), this.corners = /* @__PURE__ */ new Map(), this.borderSize = 0, this.boxSize = 0, this.mode = z.ACTIVE, this.target = t, this.setDimension(), this.mode = e ?? z.ACTIVE, this.borderSize = Kt, this.boxSize = Te / 2, this.addSides(), this.mode === z.ACTIVE && this.addCorners();
521
521
  }
522
522
  setDimension() {
523
523
  const t = this.target.getEdge();
524
524
  this.width = t.maxX - t.minX, this.height = t.maxY - t.minY;
525
525
  }
526
526
  getSidesInScreenSpace(t, e) {
527
- const [i, r] = e ? J(e) : [1, 1], { width: n, height: a, borderSize: o } = this, [h, c] = U(e), [u, f] = Et(e);
527
+ const [i, r] = e ? tt(e) : [1, 1], { width: n, height: a, borderSize: o } = this, [h, c] = U(e), [l, u] = Tt(e);
528
528
  return {
529
529
  TOP: {
530
- x: u > 0 ? h : h - n * i,
530
+ x: l > 0 ? h : h - n * i,
531
531
  y: c,
532
532
  width: n * i,
533
533
  height: o
534
534
  },
535
535
  BOTTOM: {
536
- x: u > 0 ? h : h - n * i,
537
- y: c + a * r * f,
536
+ x: l > 0 ? h : h - n * i,
537
+ y: c + a * r * u,
538
538
  width: n * i,
539
539
  height: o
540
540
  },
541
541
  LEFT: {
542
542
  x: h,
543
- y: f > 0 ? c : c - a * r,
543
+ y: u > 0 ? c : c - a * r,
544
544
  width: o,
545
545
  height: a * r
546
546
  },
547
547
  RIGHT: {
548
- x: h + n * i * u,
549
- y: f > 0 ? c : c - a * r,
548
+ x: h + n * i * l,
549
+ y: u > 0 ? c : c - a * r,
550
550
  width: o,
551
551
  height: a * r
552
552
  }
553
553
  }[t];
554
554
  }
555
555
  getCornersInScreenSpace(t, e) {
556
- const [i, r] = e ? J(e) : [1, 1], { width: n, height: a, boxSize: o } = this, [h, c] = U(e), [u, f] = Et(e);
556
+ const [i, r] = e ? tt(e) : [1, 1], { width: n, height: a, boxSize: o } = this, [h, c] = U(e), [l, u] = Tt(e);
557
557
  return {
558
558
  TOPLEFT: {
559
559
  x: h - o,
@@ -562,20 +562,20 @@ class he {
562
562
  height: o * 2
563
563
  },
564
564
  TOPRIGHT: {
565
- x: h - o + n * i * u,
565
+ x: h - o + n * i * l,
566
566
  y: c - o,
567
567
  width: o * 2,
568
568
  height: o * 2
569
569
  },
570
570
  BOTTOMLEFT: {
571
571
  x: h - o,
572
- y: c - o + a * r * f,
572
+ y: c - o + a * r * u,
573
573
  width: o * 2,
574
574
  height: o * 2
575
575
  },
576
576
  BOTTOMRIGHT: {
577
- x: h - o + n * i * u,
578
- y: c - o + a * r * f,
577
+ x: h - o + n * i * l,
578
+ y: c - o + a * r * u,
579
579
  width: o * 2,
580
580
  height: o * 2
581
581
  }
@@ -595,21 +595,21 @@ class he {
595
595
  */
596
596
  hitTest(t, e, i) {
597
597
  if (this.mode === z.PASSIVE) return;
598
- const [r, n] = J(this.target.worldMatrix), [a, o] = Et(this.target.worldMatrix), [h, c] = U(i, t, e), u = 4;
599
- for (const T of Mt) {
598
+ const [r, n] = tt(this.target.worldMatrix), [a, o] = Tt(this.target.worldMatrix), [h, c] = U(i, t, e), l = 4;
599
+ for (const T of Et) {
600
600
  const S = this.getCornersInScreenSpace(
601
601
  T,
602
602
  this.target.worldMatrix
603
603
  );
604
- if (h >= S.x - u && h <= S.x + S.width + u && c >= S.y - u && c <= S.y + S.height + u)
604
+ if (h >= S.x - l && h <= S.x + S.width + l && c >= S.y - l && c <= S.y + S.height + l)
605
605
  return T;
606
606
  }
607
- for (const T of pt) {
607
+ for (const T of yt) {
608
608
  const S = this.getSidesInScreenSpace(T, this.target.worldMatrix);
609
- if (h >= S.x - u && h <= S.x + S.width + u && c >= S.y - u && c <= S.y + S.height + u)
609
+ if (h >= S.x - l && h <= S.x + S.width + l && c >= S.y - l && c <= S.y + S.height + l)
610
610
  return T;
611
611
  }
612
- const [f, g] = U(this.target.worldMatrix), m = this.width * r * a, w = this.height * n * o, x = Math.min(f, f + m), C = Math.max(f, f + m), v = Math.min(g, g + w), A = Math.max(g, g + w);
612
+ const [u, g] = U(this.target.worldMatrix), m = this.width * r * a, w = this.height * n * o, x = Math.min(u, u + m), C = Math.max(u, u + m), v = Math.min(g, g + w), A = Math.max(g, g + w);
613
613
  if (h >= x && h <= C && c >= v && c <= A)
614
614
  return "CENTER";
615
615
  }
@@ -634,8 +634,8 @@ class he {
634
634
  }
635
635
  resize(t, e, i) {
636
636
  if (this.target instanceof Z) {
637
- const r = Math.abs(this.width), n = Math.abs(this.height), a = r / n, o = this.target.sx, h = this.target.sy, c = 1e-6, u = Math.abs(r * o) < c ? c * Lt(r * o || 1, c) : r * o, f = Math.abs(n * h) < c ? c * Lt(n * h || 1, c) : n * h, g = t / u, m = e / f, w = c, x = i === "LEFT" || i === "BOTTOMLEFT" || i === "TOPLEFT" ? 1 - g : i === "RIGHT" || i === "BOTTOMRIGHT" || i === "TOPRIGHT" ? 1 + g : i === "TOP" ? 1 - m : 1 + m;
638
- if (Dt(o, x, w) || Dt(h, x, w)) return;
637
+ const r = Math.abs(this.width), n = Math.abs(this.height), a = r / n, o = this.target.sx, h = this.target.sy, c = 1e-6, l = Math.abs(r * o) < c ? c * Dt(r * o || 1, c) : r * o, u = Math.abs(n * h) < c ? c * Dt(n * h || 1, c) : n * h, g = t / l, m = e / u, w = c, x = i === "LEFT" || i === "BOTTOMLEFT" || i === "TOPLEFT" ? 1 - g : i === "RIGHT" || i === "BOTTOMRIGHT" || i === "TOPRIGHT" ? 1 + g : i === "TOP" ? 1 - m : 1 + m;
638
+ if (Bt(o, x, w) || Bt(h, x, w)) return;
639
639
  const C = r * o * x, v = n * h * x;
640
640
  if (Math.abs(C) < w || Math.abs(v) < w) return;
641
641
  if (this.target.updateScale(x, x), i === "LEFT") {
@@ -677,45 +677,45 @@ class he {
677
677
  };
678
678
  }
679
679
  addCorners() {
680
- for (const t of Mt) {
680
+ for (const t of Et) {
681
681
  const e = new Z(
682
682
  this.getCornersInScreenSpace(t, this.target.worldMatrix)
683
683
  );
684
- e.color = this.mode === z.ACTIVE ? nt : bt, this.corners.set(t, e);
684
+ e.color = this.mode === z.ACTIVE ? ot : Ct, this.corners.set(t, e);
685
685
  }
686
686
  }
687
687
  removeCorners() {
688
688
  this.corners.clear();
689
689
  }
690
690
  updateCorners() {
691
- for (const t of Mt) {
691
+ for (const t of Et) {
692
692
  const e = this.getCornersInScreenSpace(
693
693
  t,
694
694
  this.target.worldMatrix
695
695
  ), i = this.corners.get(t);
696
- i && (i.setTranslation(e.x, e.y), i.width = e.width, i.height = e.height, i.color = this.mode === z.ACTIVE ? nt : bt);
696
+ i && (i.setTranslation(e.x, e.y), i.width = e.width, i.height = e.height, i.color = this.mode === z.ACTIVE ? ot : Ct);
697
697
  }
698
698
  }
699
699
  addSides() {
700
- for (const t of pt) {
700
+ for (const t of yt) {
701
701
  const e = new Z(
702
702
  this.getSidesInScreenSpace(t, this.target.worldMatrix)
703
703
  );
704
- e.color = this.mode === z.ACTIVE ? nt : bt, this.sides.set(t, e);
704
+ e.color = this.mode === z.ACTIVE ? ot : Ct, this.sides.set(t, e);
705
705
  }
706
706
  }
707
707
  updateSides() {
708
- for (const t of pt) {
708
+ for (const t of yt) {
709
709
  const e = this.getSidesInScreenSpace(t, this.target.worldMatrix), i = this.sides.get(t);
710
- i && (i.setTranslation(e.x, e.y), i.width = e.width, i.height = e.height, i.color = this.mode === z.ACTIVE ? nt : bt);
710
+ i && (i.setTranslation(e.x, e.y), i.width = e.width, i.height = e.height, i.color = this.mode === z.ACTIVE ? ot : Ct);
711
711
  }
712
712
  }
713
713
  }
714
- const Ht = [
715
- ...Mt,
716
- ...pt
714
+ const Nt = [
715
+ ...Et,
716
+ ...yt
717
717
  ];
718
- class Ti {
718
+ class _i {
719
719
  constructor(t) {
720
720
  this.targets = [], this.handles = /* @__PURE__ */ new Map(), this.borderSize = 0, this.boxSize = 0, this.scale = [1, 1], t && t.forEach((e) => this.add(e)), this.addHandles();
721
721
  }
@@ -732,7 +732,7 @@ class Ti {
732
732
  r.render(t, e);
733
733
  }
734
734
  update() {
735
- this.borderSize = qt, this.boxSize = Ee / 2, this.recalculateBounds(), this.updateHandles();
735
+ this.borderSize = Kt, this.boxSize = Te / 2, this.recalculateBounds(), this.updateHandles();
736
736
  }
737
737
  destroy() {
738
738
  for (const [t, e] of this.handles.entries())
@@ -744,18 +744,18 @@ class Ti {
744
744
  }
745
745
  // dx and dy are in world units
746
746
  resize(t, e, i, r) {
747
- const n = this.width, a = this.height, o = i.includes("TOP"), h = i.includes("BOTTOM"), c = i.includes("LEFT"), u = i.includes("RIGHT"), f = c ? this.x + n : u ? this.x : this.x + n / 2, g = o ? this.y + a : h ? this.y : this.y + a / 2, m = 1e-6, w = Math.abs(n) < m ? n < 0 ? -m : m : n, x = Math.abs(a) < m ? a < 0 ? -m : m : a, [C, v] = J(r), A = t * C / w, T = e * v / x, S = i.includes("LEFT") ? 1 - A : i.includes("RIGHT") ? 1 + A : i === "TOP" ? 1 - T : 1 + T;
748
- if (Dt(this.scale[0], S, m) || Dt(this.scale[1], S, m))
747
+ const n = this.width, a = this.height, o = i.includes("TOP"), h = i.includes("BOTTOM"), c = i.includes("LEFT"), l = i.includes("RIGHT"), u = c ? this.x + n : l ? this.x : this.x + n / 2, g = o ? this.y + a : h ? this.y : this.y + a / 2, m = 1e-6, w = Math.abs(n) < m ? n < 0 ? -m : m : n, x = Math.abs(a) < m ? a < 0 ? -m : m : a, [C, v] = tt(r), A = t * C / w, T = e * v / x, S = i.includes("LEFT") ? 1 - A : i.includes("RIGHT") ? 1 + A : i === "TOP" ? 1 - T : 1 + T;
748
+ if (Bt(this.scale[0], S, m) || Bt(this.scale[1], S, m))
749
749
  return;
750
- const Fe = n * S, Ge = a * S;
751
- if (!(Math.abs(Fe) < m || Math.abs(Ge) < m))
752
- for (const vt of this.targets) {
753
- const Xe = vt.x, He = vt.y, [te, ee] = U(r, Xe, He), Ne = f + (te - f) * S, Ye = g + (ee - g) * S, $e = Ne - te, je = Ye - ee, Ve = Math.abs(C) < m ? C < 0 ? -m : m : C, Ze = Math.abs(v) < m ? v < 0 ? -m : m : v, qe = $e / Ve, Ke = je / Ze;
754
- vt.updateScale(S, S), vt.updateTranslation(qe, Ke);
750
+ const Ge = n * S, Xe = a * S;
751
+ if (!(Math.abs(Ge) < m || Math.abs(Xe) < m))
752
+ for (const bt of this.targets) {
753
+ const He = bt.x, Ne = bt.y, [ee, ie] = U(r, He, Ne), Ye = u + (ee - u) * S, $e = g + (ie - g) * S, je = Ye - ee, Ve = $e - ie, Ze = Math.abs(C) < m ? C < 0 ? -m : m : C, qe = Math.abs(v) < m ? v < 0 ? -m : m : v, Ke = je / Ze, Qe = Ve / qe;
754
+ bt.updateScale(S, S), bt.updateTranslation(Ke, Qe);
755
755
  }
756
756
  }
757
757
  flip(t, e, i) {
758
- J(t);
758
+ tt(t);
759
759
  const r = [], [n, a] = i(this.x, this.y);
760
760
  for (const o of this.targets) {
761
761
  const h = {
@@ -820,17 +820,17 @@ class Ti {
820
820
  (a.y + a.height * a.sy) / 2
821
821
  ];
822
822
  if (t === "height") {
823
- const u = a.height * a.sy, f = Math.abs(n / u);
824
- a.updateScale(f, f);
823
+ const l = a.height * a.sy, u = Math.abs(n / l);
824
+ a.updateScale(u, u);
825
825
  } else if (t === "width") {
826
- const u = a.width * a.sx, f = Math.abs(n / u);
827
- a.updateScale(f, f);
826
+ const l = a.width * a.sx, u = Math.abs(n / l);
827
+ a.updateScale(u, u);
828
828
  } else if (t === "scale") {
829
- const u = Math.sign(a.sx), f = Math.sign(a.sy);
830
- a.setScale(n * u, n * f);
829
+ const l = Math.sign(a.sx), u = Math.sign(a.sy);
830
+ a.setScale(n * l, n * u);
831
831
  } else if (t === "size") {
832
- const u = a.width * a.height * a.sx * a.sy, f = Math.sqrt(Math.abs(n / u));
833
- a.updateScale(f, f);
832
+ const l = a.width * a.height * a.sx * a.sy, u = Math.sqrt(Math.abs(n / l));
833
+ a.updateScale(u, u);
834
834
  }
835
835
  const c = [
836
836
  (a.x + a.width * a.sx) / 2,
@@ -866,25 +866,25 @@ class Ti {
866
866
  }
867
867
  hitTest(t, e, i) {
868
868
  const [r, n] = U(i, t, e), a = 4;
869
- for (const f of Ht) {
870
- const g = this.getHandleConfig(f);
869
+ for (const u of Nt) {
870
+ const g = this.getHandleConfig(u);
871
871
  if (r >= g.x - a && r <= g.x + g.width + a && n >= g.y - a && n <= g.y + g.height + a)
872
- return f;
872
+ return u;
873
873
  }
874
- const o = Math.min(this.x, this.x + this.width), h = Math.max(this.x, this.x + this.width), c = Math.min(this.y, this.y + this.height), u = Math.max(this.y, this.y + this.height);
875
- if (r >= o && r <= h && n >= c && n <= u)
874
+ const o = Math.min(this.x, this.x + this.width), h = Math.max(this.x, this.x + this.width), c = Math.min(this.y, this.y + this.height), l = Math.max(this.y, this.y + this.height);
875
+ if (r >= o && r <= h && n >= c && n <= l)
876
876
  return "CENTER";
877
877
  }
878
878
  getBounds() {
879
879
  const t = Array.from(this.targets);
880
880
  let e = 1 / 0, i = 1 / 0, r = -1 / 0, n = -1 / 0;
881
881
  for (const a of t) {
882
- const [o, h] = U(a.worldMatrix), [c, u] = U(
882
+ const [o, h] = U(a.worldMatrix), [c, l] = U(
883
883
  a.worldMatrix,
884
884
  a.width,
885
885
  a.height
886
886
  );
887
- e = Math.min(e, a.sx < 0 ? c : o), i = Math.min(i, a.sy < 0 ? u : h), r = Math.max(r, a.sx < 0 ? o : c), n = Math.max(n, a.sy < 0 ? h : u);
887
+ e = Math.min(e, a.sx < 0 ? c : o), i = Math.min(i, a.sy < 0 ? l : h), r = Math.max(r, a.sx < 0 ? o : c), n = Math.max(n, a.sy < 0 ? h : l);
888
888
  }
889
889
  return { minX: e, minY: i, maxX: r, maxY: n };
890
890
  }
@@ -893,13 +893,13 @@ class Ti {
893
893
  this.x = this.scale[0] < 0 ? i : t, this.y = this.scale[1] < 0 ? r : e, this.width = this.scale[0] * (i - t), this.height = this.scale[1] * (r - e);
894
894
  }
895
895
  addHandles() {
896
- for (const t of Ht) {
896
+ for (const t of Nt) {
897
897
  const e = this.getHandleConfig(t), i = new Z(e);
898
- i.color = nt, this.handles.set(t, i);
898
+ i.color = ot, this.handles.set(t, i);
899
899
  }
900
900
  }
901
901
  updateHandles() {
902
- for (const t of Ht) {
902
+ for (const t of Nt) {
903
903
  const e = this.handles.get(t), i = this.getHandleConfig(t);
904
904
  e && (e.setTranslation(i.x, i.y), e.width = i.width, e.height = i.height);
905
905
  }
@@ -958,7 +958,7 @@ class Ti {
958
958
  }[t];
959
959
  }
960
960
  }
961
- class dt {
961
+ class et {
962
962
  // matrix: number[];
963
963
  constructor(t, e, i, r) {
964
964
  this.minX = t, this.minY = e, this.maxX = i, this.maxY = r;
@@ -970,8 +970,8 @@ class dt {
970
970
  return t.minX <= e.maxX && t.maxX >= e.minX && t.minY <= e.maxY && t.maxY >= e.minY;
971
971
  }
972
972
  }
973
- const ce = ["CENTER", ...pt];
974
- class _i {
973
+ const de = ["CENTER", ...yt];
974
+ class Ri {
975
975
  constructor(t, e, i) {
976
976
  this.width = 0, this.height = 0, this.rects = /* @__PURE__ */ new Map(), this.borderSize = 0;
977
977
  const [r, n] = U(i, t, e);
@@ -1018,7 +1018,7 @@ class _i {
1018
1018
  r.render(t, e);
1019
1019
  }
1020
1020
  update() {
1021
- this.borderSize = qt, this.updateRects();
1021
+ this.borderSize = Kt, this.updateRects();
1022
1022
  }
1023
1023
  destroy() {
1024
1024
  for (const [t, e] of this.rects.entries())
@@ -1030,26 +1030,26 @@ class _i {
1030
1030
  */
1031
1031
  getBoundingBox(t) {
1032
1032
  const [e, i] = t(this.x, this.y), [r, n] = t(this.x + this.width, this.y + this.height), a = Math.min(e, r), o = Math.max(e, r), h = Math.min(i, n), c = Math.max(i, n);
1033
- return new dt(a, h, o, c);
1033
+ return new et(a, h, o, c);
1034
1034
  }
1035
1035
  resize(t, e, i) {
1036
- const [r, n] = J(i);
1036
+ const [r, n] = tt(i);
1037
1037
  this.width += t * r, this.height += e * n;
1038
1038
  }
1039
1039
  addRects() {
1040
- for (const t of ce) {
1040
+ for (const t of de) {
1041
1041
  const e = this.getRectConfig(t), i = new Z(e);
1042
- i.color = nt, this.rects.set(t, i);
1042
+ i.color = ot, this.rects.set(t, i);
1043
1043
  }
1044
1044
  }
1045
1045
  updateRects() {
1046
- for (const t of ce) {
1046
+ for (const t of de) {
1047
1047
  const e = this.rects.get(t), i = this.getRectConfig(t);
1048
- e && (e.setTranslation(i.x, i.y), e.width = i.width, e.height = i.height, t === "CENTER" && (e.color = mi));
1048
+ e && (e.setTranslation(i.x, i.y), e.width = i.width, e.height = i.height, t === "CENTER" && (e.color = gi));
1049
1049
  }
1050
1050
  }
1051
1051
  }
1052
- class Ri {
1052
+ class Ii {
1053
1053
  constructor(t = {}) {
1054
1054
  const {
1055
1055
  x: e = 0,
@@ -1059,7 +1059,7 @@ class Ri {
1059
1059
  rotation: a = 0,
1060
1060
  zoom: o = 1
1061
1061
  } = t;
1062
- this.x = e, this.y = i, this.width = r, this.height = n, this.rotation = a, this.zoom = o, Me(this, {
1062
+ this.x = e, this.y = i, this.width = r, this.height = n, this.rotation = a, this.zoom = o, Ee(this, {
1063
1063
  x: B,
1064
1064
  y: B,
1065
1065
  width: B,
@@ -1075,7 +1075,7 @@ class Ri {
1075
1075
  setSize: b,
1076
1076
  setZoom: b,
1077
1077
  setRotation: b,
1078
- stateVector: st
1078
+ stateVector: nt
1079
1079
  });
1080
1080
  }
1081
1081
  // Actions
@@ -1116,53 +1116,53 @@ class Ri {
1116
1116
  return [this.x, this.y, this.width, this.height, this.rotation, this.zoom];
1117
1117
  }
1118
1118
  get translationMatrix() {
1119
- return M.translation(this.x, this.y);
1119
+ return E.translation(this.x, this.y);
1120
1120
  }
1121
1121
  get rotationMatrix() {
1122
- return M.rotation(this.rotation);
1122
+ return E.rotation(this.rotation);
1123
1123
  }
1124
1124
  get scaleMatrix() {
1125
- return M.scaling(this.zoom, this.zoom);
1125
+ return E.scaling(this.zoom, this.zoom);
1126
1126
  }
1127
1127
  get cameraMatrix() {
1128
- const t = M.multiply(this.translationMatrix, this.rotationMatrix);
1129
- return M.multiply(t, this.scaleMatrix);
1128
+ const t = E.multiply(this.translationMatrix, this.rotationMatrix);
1129
+ return E.multiply(t, this.scaleMatrix);
1130
1130
  }
1131
1131
  get canvasMatrix() {
1132
- return M.inverse(this.cameraMatrix);
1132
+ return E.inverse(this.cameraMatrix);
1133
1133
  }
1134
1134
  }
1135
- function de(s, t) {
1135
+ function le(s, t) {
1136
1136
  s.setTranslation(t.x, t.y), s.setScale(t.sx, t.sy);
1137
1137
  }
1138
- function le(s, t, e) {
1138
+ function ue(s, t, e) {
1139
1139
  return {
1140
1140
  label: "Flip",
1141
1141
  do() {
1142
- for (const i of s) de(i.ref, i.end);
1142
+ for (const i of s) le(i.ref, i.end);
1143
1143
  e && (e.scale[t === "horizontal" ? 0 : 1] *= -1);
1144
1144
  },
1145
1145
  undo() {
1146
- for (const i of s) de(i.ref, i.start);
1146
+ for (const i of s) le(i.ref, i.start);
1147
1147
  e && (e.scale[t === "horizontal" ? 0 : 1] *= -1);
1148
1148
  }
1149
1149
  };
1150
1150
  }
1151
- function ue(s, t) {
1151
+ function fe(s, t) {
1152
1152
  s.setTranslation(t.x, t.y), s.setScale(t.sx, t.sy);
1153
1153
  }
1154
- function $t(s, t = "Transform") {
1154
+ function jt(s, t = "Transform") {
1155
1155
  return {
1156
1156
  label: t,
1157
1157
  do() {
1158
- for (const e of s) ue(e.ref, e.end);
1158
+ for (const e of s) fe(e.ref, e.end);
1159
1159
  },
1160
1160
  undo() {
1161
- for (const e of s) ue(e.ref, e.start);
1161
+ for (const e of s) fe(e.ref, e.start);
1162
1162
  }
1163
1163
  };
1164
1164
  }
1165
- class Ii {
1165
+ class Pi {
1166
1166
  // #canvas: Canvas;
1167
1167
  #s;
1168
1168
  #i = /* @__PURE__ */ new Set();
@@ -1184,14 +1184,14 @@ class Ii {
1184
1184
  }
1185
1185
  set selected(t) {
1186
1186
  this.#i.clear(), t.forEach((e) => {
1187
- this.#i.add(e), this.#e.add(new he(e));
1187
+ this.#i.add(e), this.#e.add(new ce(e));
1188
1188
  });
1189
1189
  }
1190
1190
  get marqueeBox() {
1191
1191
  return this.#r;
1192
1192
  }
1193
1193
  set marqueeBox(t) {
1194
- this.#r = new _i(
1194
+ this.#r = new Ri(
1195
1195
  t.x,
1196
1196
  t.y,
1197
1197
  this.getWorldMatrix()
@@ -1200,16 +1200,16 @@ class Ii {
1200
1200
  constructor(t, e, i, r, n, a, o, h) {
1201
1201
  this.#n = i, this.#h = r, this.#s = t, this.#a = e, this.getWorldMatrix = n, this.getCanvasChildren = a, this.getWorldCoords = o, this.getMarqueeCoords = h;
1202
1202
  const c = Object.getPrototypeOf(this);
1203
- for (const u of Object.getOwnPropertyNames(c)) {
1204
- const f = this[u];
1205
- typeof f == "function" && u !== "constructor" && (this[u] = f.bind(this));
1203
+ for (const l of Object.getOwnPropertyNames(c)) {
1204
+ const u = this[l];
1205
+ typeof u == "function" && l !== "constructor" && (this[l] = u.bind(this));
1206
1206
  }
1207
1207
  }
1208
1208
  // add, remove selected
1209
1209
  add(t) {
1210
1210
  t.forEach((e) => {
1211
- this.#i.has(e) || (this.#i.add(e), this.#e.add(new he(e)));
1212
- }), this.#e.size > 1 && (this.#e.forEach((e) => e.setPassive()), this.#t || (this.#t = new Ti([])), this.selected.forEach((e) => this.#t.add(e)));
1211
+ this.#i.has(e) || (this.#i.add(e), this.#e.add(new ce(e)));
1212
+ }), this.#e.size > 1 && (this.#e.forEach((e) => e.setPassive()), this.#t || (this.#t = new _i([])), this.selected.forEach((e) => this.#t.add(e)));
1213
1213
  }
1214
1214
  remove(t) {
1215
1215
  t.forEach((e) => {
@@ -1226,7 +1226,7 @@ class Ii {
1226
1226
  this.remove(e);
1227
1227
  for (const i of e)
1228
1228
  i.destroy();
1229
- this.#s.push(pi(t, e));
1229
+ this.#s.push(xi(t, e));
1230
1230
  }
1231
1231
  /**
1232
1232
  * Checks first if there is a hit in a multibounding and its handles. If not, check the one bounding box that is active.
@@ -1252,12 +1252,12 @@ class Ii {
1252
1252
  if (this.#t) {
1253
1253
  const i = this.#t.hitTest(t, e, this.getWorldMatrix());
1254
1254
  if (i)
1255
- return this.#t.scale[0] * this.#t.scale[1] < 0 ? ne(i) : i;
1255
+ return this.#t.scale[0] * this.#t.scale[1] < 0 ? ae(i) : i;
1256
1256
  }
1257
1257
  for (const i of this.#e.values()) {
1258
1258
  const r = i.hitTest(t, e, this.getWorldMatrix());
1259
1259
  if (r)
1260
- return i.target.sx * i.target.sy < 0 ? ne(r) : r;
1260
+ return i.target.sx * i.target.sy < 0 ? ae(r) : r;
1261
1261
  }
1262
1262
  }
1263
1263
  /**
@@ -1315,25 +1315,25 @@ class Ii {
1315
1315
  this.getWorldCoords
1316
1316
  );
1317
1317
  this.#s.push(
1318
- le(e, t, this.multiBoundingBox)
1318
+ ue(e, t, this.multiBoundingBox)
1319
1319
  );
1320
1320
  } else {
1321
1321
  const e = [];
1322
1322
  for (const i of this.boundingBoxes)
1323
1323
  e.push(i.flip(t));
1324
- this.#s.push(le(e, t));
1324
+ this.#s.push(ue(e, t));
1325
1325
  }
1326
1326
  this.#a.emit(N.Change);
1327
1327
  }
1328
1328
  alignSelection(t) {
1329
1329
  if (!this.multiBoundingBox) return;
1330
1330
  const e = this.multiBoundingBox.align(t);
1331
- this.#s.push($t(e)), this.#a.emit(N.Change);
1331
+ this.#s.push(jt(e)), this.#a.emit(N.Change);
1332
1332
  }
1333
1333
  normalize(t, e = "first") {
1334
1334
  if (!this.multiBoundingBox) return;
1335
1335
  const i = this.multiBoundingBox.normalize(t, e);
1336
- this.#s.push($t(i)), this.#a.emit(N.Change);
1336
+ this.#s.push(jt(i)), this.#a.emit(N.Change);
1337
1337
  }
1338
1338
  onPointerMove(t, e, i, r, n, a, o, h) {
1339
1339
  if (a())
@@ -1342,10 +1342,10 @@ class Ii {
1342
1342
  this.resize(i, r, n);
1343
1343
  else if (this.marqueeBox) {
1344
1344
  this.marqueeBox.resize(i, r, h());
1345
- const c = this.getCanvasChildren(), u = this.marqueeBox.getBoundingBox(this.getMarqueeCoords);
1346
- for (const f of c) {
1347
- const g = f.getBoundingBox();
1348
- dt.isColliding(g, u) && !this.#i.has(f) ? this.add([f]) : !dt.isColliding(g, u) && this.#i.has(f) && this.remove([f]);
1345
+ const c = this.getCanvasChildren(), l = this.marqueeBox.getBoundingBox(this.getMarqueeCoords);
1346
+ for (const u of c) {
1347
+ const g = u.getBoundingBox();
1348
+ et.isColliding(g, l) && !this.#i.has(u) ? this.add([u]) : !et.isColliding(g, l) && this.#i.has(u) && this.remove([u]);
1349
1349
  }
1350
1350
  } else
1351
1351
  this.move(i, r);
@@ -1378,8 +1378,8 @@ class Ii {
1378
1378
  // }
1379
1379
  // }
1380
1380
  }
1381
- var ft = /* @__PURE__ */ ((s) => (s[s.SELECT = 0] = "SELECT", s[s.PAN = 1] = "PAN", s))(ft || {});
1382
- const Pi = {
1381
+ var mt = /* @__PURE__ */ ((s) => (s[s.SELECT = 0] = "SELECT", s[s.PAN = 1] = "PAN", s))(mt || {});
1382
+ const Ai = {
1383
1383
  TOP: "ns-resize",
1384
1384
  BOTTOM: "ns-resize",
1385
1385
  LEFT: "ew-resize",
@@ -1390,12 +1390,12 @@ const Pi = {
1390
1390
  BOTTOMLEFT: "nesw-resize",
1391
1391
  CENTER: "grab"
1392
1392
  };
1393
- class Ai {
1393
+ class Li {
1394
1394
  constructor(t) {
1395
1395
  for (const e in t)
1396
1396
  e in t && t[e] !== void 0 && (this[e] = t[e]);
1397
1397
  this.onPointerDown = this.onPointerDown.bind(this), this.onPointerMoveWhileDown = this.onPointerMoveWhileDown.bind(this), this.onPointerUp = this.onPointerUp.bind(this), this.addOnPointerMove(), this.addOnWheel(t.onWheel), this.addOnPointerDown(), window.addEventListener("copy", async (e) => {
1398
- e.preventDefault(), !this.isContextMenuActive() && await _e(this.getSelected());
1398
+ e.preventDefault(), !this.isContextMenuActive() && await Re(this.getSelected());
1399
1399
  }), window.addEventListener("paste", async (e) => {
1400
1400
  e.preventDefault(), !this.isContextMenuActive() && await t.paste(
1401
1401
  this.state.lastPointerPos.x,
@@ -1417,7 +1417,7 @@ class Ai {
1417
1417
  this.state.lastPointerPos.x,
1418
1418
  this.state.lastPointerPos.y
1419
1419
  );
1420
- this.setCursorStyle(Pi[e] || "default");
1420
+ this.setCursorStyle(Ai[e] || "default");
1421
1421
  });
1422
1422
  }
1423
1423
  addOnWheel(t) {
@@ -1473,7 +1473,7 @@ class Ai {
1473
1473
  })).filter(
1474
1474
  (e) => e.start.x !== e.end.x || e.start.y !== e.end.y || e.start.sx !== e.end.sx || e.start.sy !== e.end.sy
1475
1475
  );
1476
- t.length && this.history.push($t(t));
1476
+ t.length && this.history.push(jt(t));
1477
1477
  }
1478
1478
  this.currentTransform = void 0, this.state.resizingDirection = null, this.closeMarquee(), this.eventHub.emit("save");
1479
1479
  }
@@ -1481,7 +1481,7 @@ class Ai {
1481
1481
  const i = this.getChildren();
1482
1482
  for (let r = i.length - 1; r >= 0; r--) {
1483
1483
  const n = i[r];
1484
- if (n instanceof lt && n.hitTest && n.hitTest(t, e))
1484
+ if (n instanceof ut && n.hitTest && n.hitTest(t, e))
1485
1485
  return n;
1486
1486
  }
1487
1487
  return null;
@@ -1525,7 +1525,7 @@ class Oi {
1525
1525
  return t.key.toLowerCase() === "s" && t.ctrlKey;
1526
1526
  }
1527
1527
  }
1528
- class Li {
1528
+ class Di {
1529
1529
  #s = !1;
1530
1530
  get isActive() {
1531
1531
  return this.#s;
@@ -1542,22 +1542,22 @@ class Li {
1542
1542
  }), n("contextmenu", this.customContextMenu);
1543
1543
  }
1544
1544
  }
1545
- function fe(s, t) {
1545
+ function me(s, t) {
1546
1546
  s.renderOrder = t.renderOrder;
1547
1547
  }
1548
- function Di(s, t = "Order") {
1548
+ function Bi(s, t = "Order") {
1549
1549
  return {
1550
1550
  label: t,
1551
1551
  do() {
1552
- for (const e of s) fe(e.ref, e.end);
1552
+ for (const e of s) me(e.ref, e.end);
1553
1553
  },
1554
1554
  undo() {
1555
- for (const e of s) fe(e.ref, e.start);
1555
+ for (const e of s) me(e.ref, e.start);
1556
1556
  }
1557
1557
  };
1558
1558
  }
1559
- class Bi {
1560
- constructor(t = ft.SELECT) {
1559
+ class zi {
1560
+ constructor(t = mt.SELECT) {
1561
1561
  this.lastPointerPos = { x: 0, y: 0 }, this.startWorldX = 0, this.startWorldY = 0, this.lastWorldX = 0, this.lastWorldY = 0, this.resizingDirection = null, this.mode = t;
1562
1562
  }
1563
1563
  // computed
@@ -1575,7 +1575,7 @@ class Bi {
1575
1575
  this.mode = t;
1576
1576
  }
1577
1577
  toggleMode() {
1578
- this.mode = this.mode === ft.PAN ? ft.SELECT : ft.PAN;
1578
+ this.mode = this.mode === mt.PAN ? mt.SELECT : mt.PAN;
1579
1579
  }
1580
1580
  setResizingDirection(t) {
1581
1581
  this.resizingDirection = t;
@@ -1591,10 +1591,10 @@ class Bi {
1591
1591
  this.lastWorldX = t, this.lastWorldY = e;
1592
1592
  }
1593
1593
  }
1594
- class zi {
1594
+ class ki {
1595
1595
  // reduces constant work to re-render if there are no changes
1596
1596
  constructor() {
1597
- this.translation = [0, 0], this.angleRadians = 0, this.scale = [1, 1], this.localMatrix = M.identity(), this.worldMatrix = M.identity(), this.children = [], this.parent = null, this.renderDirtyFlag = !0, Me(this, {
1597
+ this.translation = [0, 0], this.angleRadians = 0, this.scale = [1, 1], this.localMatrix = E.identity(), this.worldMatrix = E.identity(), this.children = [], this.parent = null, this.renderDirtyFlag = !0, Ee(this, {
1598
1598
  translation: B.struct,
1599
1599
  angleRadians: B,
1600
1600
  scale: B.struct,
@@ -1603,11 +1603,11 @@ class zi {
1603
1603
  children: B.shallow,
1604
1604
  parent: B.ref,
1605
1605
  renderDirtyFlag: B,
1606
- x: st,
1607
- y: st,
1608
- scaleX: st,
1609
- scaleY: st,
1610
- dirty: st,
1606
+ x: nt,
1607
+ y: nt,
1608
+ scaleX: nt,
1609
+ scaleY: nt,
1610
+ dirty: nt,
1611
1611
  setTranslation: b,
1612
1612
  setScale: b,
1613
1613
  flipVertical: b,
@@ -1700,11 +1700,11 @@ class zi {
1700
1700
  this.renderDirtyFlag && (this.renderDirtyFlag = !1, this.updateLocalMatrix());
1701
1701
  }
1702
1702
  updateLocalMatrix() {
1703
- const t = M.translation(this.translation[0], this.translation[1]), e = M.rotation(this.angleRadians), i = M.scaling(this.scale[0], this.scale[1]);
1704
- this.localMatrix = M.multiply(M.multiply(t, e), i);
1703
+ const t = E.translation(this.translation[0], this.translation[1]), e = E.rotation(this.angleRadians), i = E.scaling(this.scale[0], this.scale[1]);
1704
+ this.localMatrix = E.multiply(E.multiply(t, e), i);
1705
1705
  }
1706
1706
  updateWorldMatrix(t) {
1707
- this.worldMatrix = t ? M.multiply(t, this.localMatrix) : this.localMatrix.slice();
1707
+ this.worldMatrix = t ? E.multiply(t, this.localMatrix) : this.localMatrix.slice();
1708
1708
  const e = this.worldMatrix;
1709
1709
  this.children.forEach((i) => {
1710
1710
  i.updateWorldMatrix(e);
@@ -1714,7 +1714,7 @@ class zi {
1714
1714
  this.worldMatrix = t;
1715
1715
  }
1716
1716
  }
1717
- class Ie {
1717
+ class Pe {
1718
1718
  get x() {
1719
1719
  return this.state.x;
1720
1720
  }
@@ -1788,7 +1788,7 @@ class Ie {
1788
1788
  return this.state.clearChildren();
1789
1789
  }
1790
1790
  constructor() {
1791
- this.state = new zi(), this.setWorldMatrix = this.setWorldMatrix.bind(this), this.updateWorldMatrix = this.updateWorldMatrix.bind(this);
1791
+ this.state = new ki(), this.setWorldMatrix = this.setWorldMatrix.bind(this), this.updateWorldMatrix = this.updateWorldMatrix.bind(this);
1792
1792
  }
1793
1793
  appendChild(t) {
1794
1794
  return t.setParent(this), !t._emitter && this._emitter && (t._emitter = this._emitter), t;
@@ -1813,7 +1813,7 @@ class Ie {
1813
1813
  return this._emitter.emit(t.type, t), !t.defaultPrevented;
1814
1814
  }
1815
1815
  }
1816
- class Pe extends Ie {
1816
+ class Ae extends Pe {
1817
1817
  constructor() {
1818
1818
  super(...arguments), this.initialized = !1;
1819
1819
  }
@@ -1831,9 +1831,9 @@ class Pe extends Ie {
1831
1831
  t.uniform2f(this.resolutionLocation, t.canvas.width, t.canvas.height), t.uniformMatrix3fv(this.matrixLocation, !1, this.worldMatrix);
1832
1832
  }
1833
1833
  }
1834
- const Ut = class Ut extends Pe {
1834
+ const Wt = class Wt extends Ae {
1835
1835
  constructor(t, e, i = 1, r = 1) {
1836
- super(), this._seq = Ut._seqCounter++, this.culled = !1, this._renderOrder = 0, this.color = [1, 0, 0.5, 1], this.setTranslation(t, e), this.setScale(i, r);
1836
+ super(), this._seq = Wt._seqCounter++, this.culled = !1, this._renderOrder = 0, this.color = [1, 0, 0.5, 1], this.setTranslation(t, e), this.setScale(i, r);
1837
1837
  }
1838
1838
  get renderOrder() {
1839
1839
  return this._renderOrder;
@@ -1869,9 +1869,9 @@ const Ut = class Ut extends Pe {
1869
1869
  this.positionBuffer && (this.positionBuffer = void 0), this.initialized = !1;
1870
1870
  }
1871
1871
  };
1872
- Ut._seqCounter = 0;
1873
- let lt = Ut;
1874
- class Z extends lt {
1872
+ Wt._seqCounter = 0;
1873
+ let ut = Wt;
1874
+ class Z extends ut {
1875
1875
  constructor(t) {
1876
1876
  super(t.x, t.y, t.sx, t.sy), this._width = t.width ?? 100, this._height = t.height ?? 100;
1877
1877
  }
@@ -1919,7 +1919,7 @@ class Z extends lt {
1919
1919
  */
1920
1920
  getBoundingBox() {
1921
1921
  const t = this.state.translation[0], e = t + this.width * this.state.scaleX, i = this.state.translation[1], r = i + this.height * this.state.scaleY, n = Math.min(t, e), a = Math.max(t, e), o = Math.min(i, r), h = Math.max(i, r);
1922
- return this.AABB = new dt(n, o, a, h), this.AABB;
1922
+ return this.AABB = new et(n, o, a, h), this.AABB;
1923
1923
  }
1924
1924
  getEdge() {
1925
1925
  const t = this.x, e = this.y;
@@ -1931,11 +1931,11 @@ class Z extends lt {
1931
1931
  };
1932
1932
  }
1933
1933
  hitTest(t, e) {
1934
- const [i, r] = J(this.worldMatrix), [n, a] = Et(this.worldMatrix), [o, h] = U(this.parent.worldMatrix, t, e), [c, u] = U(this.worldMatrix), f = this.width * i * n, g = this.height * r * a, m = Math.min(c, c + f), w = Math.max(c, c + f), x = Math.min(u, u + g), C = Math.max(u, u + g);
1934
+ const [i, r] = tt(this.worldMatrix), [n, a] = Tt(this.worldMatrix), [o, h] = U(this.parent.worldMatrix, t, e), [c, l] = U(this.worldMatrix), u = this.width * i * n, g = this.height * r * a, m = Math.min(c, c + u), w = Math.max(c, c + u), x = Math.min(l, l + g), C = Math.max(l, l + g);
1935
1935
  return o >= m && o <= w && h >= x && h <= C;
1936
1936
  }
1937
1937
  }
1938
- class xt extends Z {
1938
+ class wt extends Z {
1939
1939
  constructor(t) {
1940
1940
  super(t), this.texCoordArray = new Float32Array([
1941
1941
  0,
@@ -2020,8 +2020,8 @@ class xt extends Z {
2020
2020
  typeof OffscreenCanvas < "u" ? h = new OffscreenCanvas(a, o) : (h = document.createElement("canvas"), h.width = a, h.height = o);
2021
2021
  const c = h.getContext("2d");
2022
2022
  c.clearRect(0, 0, a, o);
2023
- const u = Math.min(a / i, o / r), f = Math.round(i * u), g = Math.round(r * u), m = Math.round((a - f) / 2), w = Math.round((o - g) / 2);
2024
- c.drawImage(this._image, 0, 0, i, r, m, w, f, g), this.lowResBitmap = await createImageBitmap(h), this.setLowResTextureFromBitmap(t, this.lowResBitmap);
2023
+ const l = Math.min(a / i, o / r), u = Math.round(i * l), g = Math.round(r * l), m = Math.round((a - u) / 2), w = Math.round((o - g) / 2);
2024
+ c.drawImage(this._image, 0, 0, i, r, m, w, u, g), this.lowResBitmap = await createImageBitmap(h), this.setLowResTextureFromBitmap(t, this.lowResBitmap);
2025
2025
  } catch (e) {
2026
2026
  console.error("Failed to create/upload low-res image", e);
2027
2027
  }
@@ -2150,8 +2150,8 @@ class xt extends Z {
2150
2150
  }
2151
2151
  }
2152
2152
  }
2153
- var Tt = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.GRID = 1] = "GRID", s))(Tt || {});
2154
- class Ae extends Pe {
2153
+ var _t = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.GRID = 1] = "GRID", s))(_t || {});
2154
+ class Le extends Ae {
2155
2155
  constructor() {
2156
2156
  super(...arguments), this.buffer = null, this.vertexCount = 0, this.gridType = 1, this.zoom = 1;
2157
2157
  }
@@ -2171,7 +2171,7 @@ class Ae extends Pe {
2171
2171
  this.vertexCount = c.length / 2, t.bindBuffer(t.ARRAY_BUFFER, this.buffer), t.bufferData(t.ARRAY_BUFFER, c, t.STATIC_DRAW);
2172
2172
  }
2173
2173
  this.initialized || (this.setUpVertexData(t, e), this.setUpUniforms(t, e), this.initialized = !0);
2174
- const i = t.drawingBufferWidth, r = t.drawingBufferHeight, n = M.inverse(M.projection(i, r)), a = M.inverse(this.worldMatrix), o = M.multiply(a, n);
2174
+ const i = t.drawingBufferWidth, r = t.drawingBufferHeight, n = E.inverse(E.projection(i, r)), a = E.inverse(this.worldMatrix), o = E.multiply(a, n);
2175
2175
  this.viewProjectionInvLocation && t.uniformMatrix3fv(
2176
2176
  this.viewProjectionInvLocation,
2177
2177
  !1,
@@ -2199,10 +2199,10 @@ class Ae extends Pe {
2199
2199
  ), t.uniformMatrix3fv(this.viewProjectionInvLocation, !1, i), t.uniform1f(this.zoomScaleLocation, this.zoom), t.uniform1f(this.checkboardStyleLocation, 1);
2200
2200
  }
2201
2201
  }
2202
- const ki = 0.02, Ui = 20;
2203
- class Wi {
2202
+ const Ui = 0.02, Wi = 20;
2203
+ class Fi {
2204
2204
  constructor(t, e, i, r) {
2205
- this.viewportX = 0, this.viewportY = 0, this.state = t, this.updateCameraPos = this.updateCameraPos.bind(this), this.updateZoom = this.updateZoom.bind(this), this.onWheel = this.onWheel.bind(this), this.worldToCamera = this.worldToCamera.bind(this), this.getWorldCoords = r, this.setWorldMatrix = e, this.updateWorldMatrix = i, this.updateReaction = Qe(
2205
+ this.viewportX = 0, this.viewportY = 0, this.state = t, this.updateCameraPos = this.updateCameraPos.bind(this), this.updateZoom = this.updateZoom.bind(this), this.onWheel = this.onWheel.bind(this), this.worldToCamera = this.worldToCamera.bind(this), this.getWorldCoords = r, this.setWorldMatrix = e, this.updateWorldMatrix = i, this.updateReaction = Je(
2206
2206
  () => this.state.stateVector,
2207
2207
  () => this.updateViewMatrix()
2208
2208
  ), this.updateViewMatrix();
@@ -2221,7 +2221,7 @@ class Wi {
2221
2221
  this.state.width + this.viewportX,
2222
2222
  this.state.height + this.viewportY
2223
2223
  );
2224
- return new dt(t, e, i, r);
2224
+ return new et(t, e, i, r);
2225
2225
  }
2226
2226
  onWheel(t) {
2227
2227
  t.preventDefault();
@@ -2237,7 +2237,7 @@ class Wi {
2237
2237
  updateZoom(t, e, i) {
2238
2238
  const [r, n] = this.getWorldCoords(t, e);
2239
2239
  this.state.setZoom(
2240
- Math.min(Ui, Math.max(ki, this.state.zoom * i))
2240
+ Math.min(Wi, Math.max(Ui, this.state.zoom * i))
2241
2241
  );
2242
2242
  const [a, o] = this.getWorldCoords(t, e);
2243
2243
  this.state.incrementPosition(r - a, n - o);
@@ -2250,8 +2250,8 @@ class Wi {
2250
2250
  this.updateReaction && (this.updateReaction(), this.updateReaction = void 0);
2251
2251
  }
2252
2252
  }
2253
- const me = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjYjNiM2IzIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xLjUgNmEyLjI1IDIuMjUgMCAwIDEgMi4yNS0yLjI1aDE2LjVBMi4yNSAyLjI1IDAgMCAxIDIyLjUgNnYxMmEyLjI1IDIuMjUgMCAwIDEtMi4yNSAyLjI1SDMuNzVBMi4yNSAyLjI1IDAgMCAxIDEuNSAxOHpNMyAxNi4wNlYxOGMwIC40MTQuMzM2Ljc1Ljc1Ljc1aDE2LjVBLjc1Ljc1IDAgMCAwIDIxIDE4di0xLjk0bC0yLjY5LTIuNjg5YTEuNSAxLjUgMCAwIDAtMi4xMiAwbC0uODguODc5bC45Ny45N2EuNzUuNzUgMCAxIDEtMS4wNiAxLjA2bC01LjE2LTUuMTU5YTEuNSAxLjUgMCAwIDAtMi4xMiAwem0xMC4xMjUtNy44MWExLjEyNSAxLjEyNSAwIDEgMSAyLjI1IDBhMS4xMjUgMS4xMjUgMCAwIDEtMi4yNSAwIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", it = 240;
2254
- function ge(s) {
2253
+ const ge = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjYjNiM2IzIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xLjUgNmEyLjI1IDIuMjUgMCAwIDEgMi4yNS0yLjI1aDE2LjVBMi4yNSAyLjI1IDAgMCAxIDIyLjUgNnYxMmEyLjI1IDIuMjUgMCAwIDEtMi4yNSAyLjI1SDMuNzVBMi4yNSAyLjI1IDAgMCAxIDEuNSAxOHpNMyAxNi4wNlYxOGMwIC40MTQuMzM2Ljc1Ljc1Ljc1aDE2LjVBLjc1Ljc1IDAgMCAwIDIxIDE4di0xLjk0bC0yLjY5LTIuNjg5YTEuNSAxLjUgMCAwIDAtMi4xMiAwbC0uODguODc5bC45Ny45N2EuNzUuNzUgMCAxIDEtMS4wNiAxLjA2bC01LjE2LTUuMTU5YTEuNSAxLjUgMCAwIDAtMi4xMiAwem0xMC4xMjUtNy44MWExLjEyNSAxLjEyNSAwIDEgMSAyLjI1IDBhMS4xMjUgMS4xMjUgMCAwIDEtMi4yNSAwIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", rt = 240;
2254
+ function pe(s) {
2255
2255
  return {
2256
2256
  x: s.x ?? 0,
2257
2257
  y: s.y ?? 0,
@@ -2259,37 +2259,37 @@ function ge(s) {
2259
2259
  sy: s.sy ?? 1
2260
2260
  };
2261
2261
  }
2262
- function Nt(s) {
2262
+ function Yt(s) {
2263
2263
  return s.children.map(Oe);
2264
2264
  }
2265
2265
  function Oe(s) {
2266
- return s instanceof xt ? {
2266
+ return s instanceof wt ? {
2267
2267
  type: "Img",
2268
2268
  id: s.seq,
2269
2269
  renderOrder: s.renderOrder,
2270
- transform: ge(s),
2270
+ transform: pe(s),
2271
2271
  width: s.width,
2272
2272
  height: s.height,
2273
2273
  fileId: s.fileId,
2274
- children: s.children?.length ? Nt(s) : void 0
2274
+ children: s.children?.length ? Yt(s) : void 0
2275
2275
  } : s instanceof Z ? {
2276
2276
  type: "Rect",
2277
2277
  id: s.seq,
2278
2278
  renderOrder: s.renderOrder,
2279
- transform: ge(s),
2279
+ transform: pe(s),
2280
2280
  width: s.width,
2281
2281
  height: s.height,
2282
2282
  color: s.color,
2283
- children: s.children?.length ? Nt(s) : void 0
2284
- } : s instanceof Ae ? {
2283
+ children: s.children?.length ? Yt(s) : void 0
2284
+ } : s instanceof Le ? {
2285
2285
  type: "Grid",
2286
2286
  style: s.gridType
2287
2287
  } : {
2288
2288
  type: "Renderable",
2289
- children: s.children?.length ? Nt(s) : void 0
2289
+ children: s.children?.length ? Yt(s) : void 0
2290
2290
  };
2291
2291
  }
2292
- function jt(s, t) {
2292
+ function Vt(s, t) {
2293
2293
  const { gl: e } = s;
2294
2294
  return {
2295
2295
  version: 1,
@@ -2307,7 +2307,7 @@ function jt(s, t) {
2307
2307
  files: t
2308
2308
  };
2309
2309
  }
2310
- async function Vt(s, t, e, i) {
2310
+ async function Zt(s, t, e, i) {
2311
2311
  t.children.length = 0, s.camera && (t.camera.state.setZoom(s.camera.zoom), t.camera.state.setX(s.camera.x), t.camera.state.setY(s.camera.y));
2312
2312
  async function r(n, a) {
2313
2313
  let o;
@@ -2325,28 +2325,28 @@ async function Vt(s, t, e, i) {
2325
2325
  try {
2326
2326
  h = s.files && Array.isArray(s.files) ? s.files.find(
2327
2327
  (m) => m.id === n.fileId
2328
- )?.dataURL ?? me : me, i && i(h);
2329
- const c = n.width, u = n.height, f = await Gi(
2328
+ )?.dataURL ?? ge : ge, i && i(h);
2329
+ const c = n.width, l = n.height, u = await Xi(
2330
2330
  h,
2331
2331
  c * n.transform.sx,
2332
- u * n.transform.sy
2332
+ l * n.transform.sy
2333
2333
  );
2334
- o = new xt({
2334
+ o = new wt({
2335
2335
  x: n.transform.x,
2336
2336
  y: n.transform.y,
2337
- src: f,
2337
+ src: u,
2338
2338
  width: c,
2339
- height: u
2339
+ height: l
2340
2340
  }), e(n.fileId).then((g) => {
2341
2341
  o.src = g.dataURL;
2342
- }).catch((g) => console.error("Image not loaded", g)), o.fileId = n.fileId ?? await Kt(h), o.setScale(n.transform.sx, n.transform.sy), t.appendChild(o), typeof n.renderOrder == "number" && (o.renderOrder = n.renderOrder);
2342
+ }).catch((g) => console.error("Image not loaded", g)), o.fileId = n.fileId ?? await Qt(h), o.setScale(n.transform.sx, n.transform.sy), t.appendChild(o), typeof n.renderOrder == "number" && (o.renderOrder = n.renderOrder);
2343
2343
  } catch {
2344
2344
  console.error(`Failed to match image to restore with source: ${h}`);
2345
2345
  } finally {
2346
2346
  break;
2347
2347
  }
2348
2348
  case "Grid":
2349
- a instanceof zt && (a.grid.gridType = n.style);
2349
+ a instanceof kt && (a.grid.gridType = n.style);
2350
2350
  break;
2351
2351
  }
2352
2352
  if (n.children)
@@ -2354,33 +2354,33 @@ async function Vt(s, t, e, i) {
2354
2354
  }
2355
2355
  return await r(s.root, t), t;
2356
2356
  }
2357
- async function Fi(s) {
2357
+ async function Gi(s) {
2358
2358
  const t = new Image();
2359
2359
  return t.crossOrigin = "anonymous", new Promise((e, i) => {
2360
2360
  t.onload = () => e(t), t.onerror = (r) => i(r), t.src = s;
2361
2361
  });
2362
2362
  }
2363
- async function Gi(s, t, e, i = "#d6d6d6ff") {
2363
+ async function Xi(s, t, e, i = "#d6d6d6ff") {
2364
2364
  let r = null, n;
2365
2365
  s instanceof Blob ? (r = URL.createObjectURL(s), n = r) : n = s;
2366
2366
  try {
2367
2367
  let a = null;
2368
2368
  try {
2369
- a = await Fi(n);
2369
+ a = await Gi(n);
2370
2370
  } catch {
2371
2371
  }
2372
- const o = t && t > 0 ? t : a?.naturalWidth ?? it, h = e && e > 0 ? e : a?.naturalHeight ?? it, c = document.createElement("canvas");
2372
+ const o = t && t > 0 ? t : a?.naturalWidth ?? rt, h = e && e > 0 ? e : a?.naturalHeight ?? rt, c = document.createElement("canvas");
2373
2373
  c.width = o, c.height = h;
2374
- const u = c.getContext("2d");
2375
- if (u.fillStyle = i, u.fillRect(0, 0, o, h), a) {
2376
- const f = Math.min(
2374
+ const l = c.getContext("2d");
2375
+ if (l.fillStyle = i, l.fillRect(0, 0, o, h), a) {
2376
+ const u = Math.min(
2377
2377
  o / a.naturalWidth,
2378
2378
  h / a.naturalHeight
2379
- ), g = a.naturalHeight * f, m = a.naturalWidth * f;
2380
- let w = it, x = it;
2381
- (it > g || it > m) && (w = m, x = g);
2379
+ ), g = a.naturalHeight * u, m = a.naturalWidth * u;
2380
+ let w = rt, x = rt;
2381
+ (rt > g || rt > m) && (w = m, x = g);
2382
2382
  const C = Math.round((o - w) / 2), v = Math.round((h - x) / 2);
2383
- u.drawImage(
2383
+ l.drawImage(
2384
2384
  a,
2385
2385
  0,
2386
2386
  0,
@@ -2397,67 +2397,67 @@ async function Gi(s, t, e, i = "#d6d6d6ff") {
2397
2397
  r && URL.revokeObjectURL(r);
2398
2398
  }
2399
2399
  }
2400
- var W, F, K, at, y, G, ot, Q, X, V, P, ht, Wt, ct;
2401
- const R = class R extends Ie {
2400
+ var W, F, Q, ht, y, G, ct, J, X, V, P, dt, Ft, lt;
2401
+ const R = class R extends Pe {
2402
2402
  constructor(e, i, r, n, a, o) {
2403
2403
  super();
2404
- L(this, W);
2405
- L(this, F);
2406
- L(this, K);
2407
- L(this, at);
2408
- L(this, y);
2409
- L(this, G);
2410
- L(this, ot);
2411
- L(this, Q);
2412
- L(this, X);
2413
- L(this, V);
2414
- L(this, P);
2415
- L(this, ht);
2416
- L(this, Wt);
2417
- L(this, ct);
2418
- I(this, V, !0), this.orderDirty = !0, this.renderList = [], I(this, W, e), I(this, F, r), I(this, K, i), I(this, X, new Ae()), I(this, y, e.getContext("webgl", {
2404
+ O(this, W);
2405
+ O(this, F);
2406
+ O(this, Q);
2407
+ O(this, ht);
2408
+ O(this, y);
2409
+ O(this, G);
2410
+ O(this, ct);
2411
+ O(this, J);
2412
+ O(this, X);
2413
+ O(this, V);
2414
+ O(this, P);
2415
+ O(this, dt);
2416
+ O(this, Ft);
2417
+ O(this, lt);
2418
+ I(this, V, !0), this.orderDirty = !0, this.renderList = [], I(this, W, e), I(this, F, r), I(this, Q, i), I(this, X, new Le()), I(this, y, e.getContext("webgl", {
2419
2419
  alpha: !0,
2420
2420
  premultipliedAlpha: !1
2421
- })), l(this, y).enable(l(this, y).BLEND), l(this, y).blendFunc(l(this, y).SRC_ALPHA, l(this, y).ONE_MINUS_SRC_ALPHA), l(this, y).getExtension("OES_standard_derivatives"), l(this, y).enable(l(this, y).DEPTH_TEST), l(this, y).depthFunc(l(this, y).LEQUAL), I(this, G, Xt(l(this, y), vi, bi)), I(this, ot, Xt(l(this, y), Mi, Ei)), I(this, Q, Xt(l(this, y), Ci, Si)), this.writeToStorage = n, this.saveImgFileToStorage = a, this.getContainerDimension = o, this.engine = this.engine.bind(this), this.getBoundingClientRect = this.getBoundingClientRect.bind(this), this.appendChild = this.appendChild.bind(this), this.addImageToCanvas = this.addImageToCanvas.bind(this), this.setShapeZOrder = this.setShapeZOrder.bind(this), this.toggleGrid = this.toggleGrid.bind(this), this.changeMode = this.changeMode.bind(this), this.getSelected = this.getSelected.bind(this), this.updateZoomByFixedAmount = this.updateZoomByFixedAmount.bind(this), this.assignEventListener = this.assignEventListener.bind(this), this.getWorldsCoordsFromCanvas = (g, m) => wt(g, m, this);
2422
- const h = (g, m) => wt(
2421
+ })), f(this, y).enable(f(this, y).BLEND), f(this, y).blendFunc(f(this, y).SRC_ALPHA, f(this, y).ONE_MINUS_SRC_ALPHA), f(this, y).getExtension("OES_standard_derivatives"), f(this, y).enable(f(this, y).DEPTH_TEST), f(this, y).depthFunc(f(this, y).LEQUAL), I(this, G, Ht(f(this, y), bi, Ci)), I(this, ct, Ht(f(this, y), Ei, Ti)), I(this, J, Ht(f(this, y), Si, Mi)), this.writeToStorage = n, this.saveImgFileToStorage = a, this.getContainerDimension = o, this.engine = this.engine.bind(this), this.getBoundingClientRect = this.getBoundingClientRect.bind(this), this.appendChild = this.appendChild.bind(this), this.addImageToCanvas = this.addImageToCanvas.bind(this), this.setShapeZOrder = this.setShapeZOrder.bind(this), this.toggleGrid = this.toggleGrid.bind(this), this.changeMode = this.changeMode.bind(this), this.getSelected = this.getSelected.bind(this), this.updateZoomByFixedAmount = this.updateZoomByFixedAmount.bind(this), this.assignEventListener = this.assignEventListener.bind(this), this.getWorldsCoordsFromCanvas = (g, m) => K(g, m, this);
2422
+ const h = (g, m) => K(
2423
2423
  g + this.camera.viewportX,
2424
2424
  m + this.camera.viewportY,
2425
2425
  this
2426
2426
  );
2427
- this.exportState = this.exportState.bind(this), this.importState = this.importState.bind(this), this.clearChildren = this.clearChildren.bind(this), I(this, P, new Ii(
2427
+ this.exportState = this.exportState.bind(this), this.importState = this.importState.bind(this), this.clearChildren = this.clearChildren.bind(this), I(this, P, new Pi(
2428
2428
  i,
2429
2429
  r,
2430
2430
  this.gl,
2431
- l(this, G),
2431
+ f(this, G),
2432
2432
  () => this.worldMatrix,
2433
2433
  () => this.children,
2434
2434
  this.getWorldsCoordsFromCanvas,
2435
2435
  h
2436
2436
  ));
2437
- const c = new Ri({});
2438
- I(this, at, new Wi(
2437
+ const c = new Ii({});
2438
+ I(this, ht, new Fi(
2439
2439
  c,
2440
2440
  this.setWorldMatrix,
2441
2441
  this.updateWorldMatrix,
2442
2442
  this.getWorldsCoordsFromCanvas
2443
- )), I(this, Wt, new Oi(
2443
+ )), I(this, Ft, new Oi(
2444
2444
  i,
2445
2445
  r,
2446
2446
  () => this.selectionManager.deleteSelected(this),
2447
2447
  this.assignEventListener
2448
- )), I(this, ct, new Li(
2448
+ )), I(this, lt, new Di(
2449
2449
  r,
2450
2450
  this.selectionManager.isMultiBoundingBoxHit,
2451
2451
  this.selectionManager.isBoundingBoxHit,
2452
2452
  this.getWorldsCoordsFromCanvas,
2453
2453
  this.assignEventListener
2454
2454
  ));
2455
- const u = new Bi(), f = {
2455
+ const l = new zi(), u = {
2456
2456
  history: i,
2457
2457
  eventHub: r,
2458
- state: u,
2459
- isContextMenuActive: () => l(this, ct).isActive,
2460
- getSelected: () => l(this, P).selected,
2458
+ state: l,
2459
+ isContextMenuActive: () => f(this, lt).isActive,
2460
+ getSelected: () => f(this, P).selected,
2461
2461
  getChildren: () => this.children,
2462
2462
  getWorldMatrix: () => this.worldMatrix,
2463
2463
  getCanvasGlobalClick: () => this.isGlobalClick,
@@ -2466,10 +2466,10 @@ const R = class R extends Ie {
2466
2466
  updateCameraPos: this.camera.updateCameraPos,
2467
2467
  onWheel: this.camera.onWheel,
2468
2468
  setCursorStyle: (g) => e.style.cursor = g,
2469
- paste: (g, m) => Re(g, m, this, i),
2469
+ paste: (g, m) => Ie(g, m, this, i),
2470
2470
  assignEventListener: this.assignEventListener,
2471
- closeMarquee: l(this, P).clearMarquee,
2472
- selectionPointerMove: (g, m, w, x, C) => l(this, P).onPointerMove(
2471
+ closeMarquee: f(this, P).clearMarquee,
2472
+ selectionPointerMove: (g, m, w, x, C) => f(this, P).onPointerMove(
2473
2473
  g,
2474
2474
  m,
2475
2475
  w,
@@ -2486,47 +2486,47 @@ const R = class R extends Ie {
2486
2486
  isSelection: this.selectionManager.isRectSelected,
2487
2487
  hitTestAdjustedCorner: this.selectionManager.hitTestAdjustedCorner
2488
2488
  };
2489
- I(this, ht, new Ai(f)), l(this, F).on("save", this.writeToStorage);
2489
+ I(this, dt, new Li(u)), f(this, F).on("save", this.writeToStorage);
2490
2490
  }
2491
2491
  // Call this whenever children/layers/z-order change
2492
2492
  markOrderDirty() {
2493
2493
  this.orderDirty = !0;
2494
2494
  }
2495
2495
  get gl() {
2496
- return l(this, y);
2496
+ return f(this, y);
2497
2497
  }
2498
2498
  get grid() {
2499
- return l(this, X);
2499
+ return f(this, X);
2500
2500
  }
2501
2501
  get history() {
2502
- return l(this, K);
2502
+ return f(this, Q);
2503
2503
  }
2504
2504
  get eventHub() {
2505
- return l(this, F);
2505
+ return f(this, F);
2506
2506
  }
2507
2507
  get pointerEventManager() {
2508
- return l(this, ht);
2508
+ return f(this, dt);
2509
2509
  }
2510
2510
  get selectionManager() {
2511
- return l(this, P);
2511
+ return f(this, P);
2512
2512
  }
2513
2513
  get contextMenuManager() {
2514
- return l(this, ct);
2514
+ return f(this, lt);
2515
2515
  }
2516
2516
  get canvas() {
2517
- return l(this, W);
2517
+ return f(this, W);
2518
2518
  }
2519
2519
  get camera() {
2520
- return l(this, at);
2520
+ return f(this, ht);
2521
2521
  }
2522
2522
  get isGlobalClick() {
2523
- return l(this, V);
2523
+ return f(this, V);
2524
2524
  }
2525
2525
  set isGlobalClick(e) {
2526
2526
  I(this, V, e);
2527
2527
  }
2528
2528
  get basicShapeProgram() {
2529
- return l(this, G);
2529
+ return f(this, G);
2530
2530
  }
2531
2531
  engine() {
2532
2532
  return this;
@@ -2538,99 +2538,104 @@ const R = class R extends Ie {
2538
2538
  return this.renderList.length;
2539
2539
  }
2540
2540
  appendChild(e) {
2541
- if (super.appendChild(e), e instanceof lt) {
2541
+ if (super.appendChild(e), e instanceof ut) {
2542
2542
  const i = this.children.map((n) => n.renderOrder), r = i.length ? Math.max(...i) : 0;
2543
2543
  e.renderOrder = r + 1;
2544
2544
  }
2545
2545
  return this.markOrderDirty(), e;
2546
2546
  }
2547
2547
  removeChild(e) {
2548
- this.state.removeChild(e), l(this, P) && l(this, P).remove([e]), e.destroy(), this.markOrderDirty();
2548
+ this.state.removeChild(e), f(this, P) && f(this, P).remove([e]), e.destroy(), this.markOrderDirty();
2549
2549
  }
2550
2550
  getChild(e) {
2551
2551
  return this.state.getChild(e);
2552
2552
  }
2553
2553
  updateWorldMatrix() {
2554
- l(this, X).updateWorldMatrix(this.worldMatrix), this.children.forEach((e) => {
2554
+ f(this, X).updateWorldMatrix(this.worldMatrix), this.children.forEach((e) => {
2555
2555
  e.updateWorldMatrix(this.worldMatrix);
2556
- }), l(this, P).update();
2556
+ }), f(this, P).update();
2557
2557
  }
2558
2558
  render() {
2559
- l(this, y).clearColor(0, 0, 0, 0), l(this, y).clear(l(this, y).COLOR_BUFFER_BIT | l(this, y).DEPTH_BUFFER_BIT), l(this, y).viewport(0, 0, l(this, y).canvas.width, l(this, y).canvas.height);
2559
+ f(this, y).clearColor(0, 0, 0, 0), f(this, y).clear(f(this, y).COLOR_BUFFER_BIT | f(this, y).DEPTH_BUFFER_BIT), f(this, y).viewport(0, 0, f(this, y).canvas.width, f(this, y).canvas.height);
2560
2560
  const e = this.canvas.parentElement.getBoundingClientRect();
2561
2561
  this.camera.setViewPortDimension(
2562
2562
  e.width,
2563
2563
  e.height
2564
- ), l(this, y).useProgram(l(this, Q));
2565
- const i = l(this, y).getUniformLocation(l(this, Q), "u_z");
2566
- l(this, y).uniform1f(i, 0), l(this, X).render(l(this, y), l(this, Q));
2564
+ ), f(this, y).useProgram(f(this, J));
2565
+ const i = f(this, y).getUniformLocation(f(this, J), "u_z");
2566
+ f(this, y).uniform1f(i, 0), f(this, X).render(f(this, y), f(this, J));
2567
2567
  const r = this.camera.getBoundingBox();
2568
2568
  this.renderList = [];
2569
- for (const n of this.children)
2570
- dt.isColliding(r, n.getBoundingBox()) ? (this.renderList.push(n), n.culled = !1) : n.culled = !0;
2571
- this.renderList.forEach((n) => {
2572
- if (n instanceof xt) {
2573
- const a = n.determineIfLowRes(
2574
- r,
2569
+ for (const l of this.children)
2570
+ et.isColliding(r, l.getBoundingBox()) ? (this.renderList.push(l), l.culled = !1) : l.culled = !0;
2571
+ const [n, a] = K(0, 0, this), [o, h] = K(
2572
+ window.screen.width,
2573
+ window.screen.height,
2574
+ this
2575
+ ), c = new et(n, a, o, h);
2576
+ this.renderList.forEach((l) => {
2577
+ if (l instanceof wt) {
2578
+ const u = l.determineIfLowRes(
2579
+ c,
2575
2580
  this.camera.state.zoom
2576
2581
  );
2577
- n.setUseLowRes(a, this.gl);
2582
+ l.setUseLowRes(u, this.gl);
2578
2583
  }
2579
2584
  });
2580
- for (const n of this.renderList) {
2581
- let a;
2582
- n instanceof xt ? a = l(this, ot) : n instanceof lt && (a = l(this, G)), l(this, y).useProgram(a);
2583
- const o = l(this, y).getUniformLocation(a, "u_z");
2584
- l(this, y).uniform1f(o, n.getZ()), n.render(l(this, y), a);
2585
+ for (const l of this.renderList) {
2586
+ let u;
2587
+ l instanceof wt ? u = f(this, ct) : l instanceof ut && (u = f(this, G)), f(this, y).useProgram(u);
2588
+ const g = f(this, y).getUniformLocation(u, "u_z");
2589
+ f(this, y).uniform1f(g, l.getZ()), l.render(f(this, y), u);
2585
2590
  }
2586
- l(this, P).render(l(this, G));
2591
+ f(this, P).render(f(this, G));
2587
2592
  }
2588
2593
  destroy() {
2589
- l(this, y).deleteProgram(l(this, G)), l(this, y).deleteProgram(l(this, ot)), this.children.forEach((e) => {
2594
+ f(this, y).deleteProgram(f(this, G)), f(this, y).deleteProgram(f(this, ct)), this.children.forEach((e) => {
2590
2595
  "destroy" in e && e.destroy();
2591
2596
  }), this.clearChildren();
2592
2597
  }
2593
2598
  getDOM() {
2594
- return l(this, W);
2599
+ return f(this, W);
2595
2600
  }
2596
2601
  assignEventListener(e, i, r) {
2597
- l(this, W).addEventListener(e, i, r);
2602
+ f(this, W).addEventListener(e, i, r);
2598
2603
  }
2599
2604
  hitTest(e, i) {
2600
- return I(this, V, !0), l(this, V);
2605
+ return I(this, V, !0), f(this, V);
2601
2606
  }
2602
2607
  async addImageToCanvas(e, i, r, n = 1, a = 1, o = !1) {
2603
- const h = new xt({ x: i, y: r, src: e, sx: n, sy: a });
2608
+ const h = new wt({ x: i, y: r, src: e, sx: n, sy: a });
2604
2609
  if (this.saveImgFileToStorage(e).then((c) => h.fileId = c), o) {
2605
2610
  const c = new Image();
2606
- c.src = e.startsWith("data:image/png") ? e : await Te(e), c.onload = () => {
2607
- const u = c.naturalWidth || c.width || 0, f = c.naturalHeight || c.height || 0;
2608
- (u || f) && h.updateTranslation(-u / 2, -f / 2), h.src = c.src, this.appendChild(h);
2611
+ c.src = e.startsWith("data:image/png") ? e : await _e(e), c.onload = () => {
2612
+ const l = c.naturalWidth || c.width || 0, u = c.naturalHeight || c.height || 0;
2613
+ (l || u) && h.updateTranslation(-l / 2, -u / 2), h.src = c.src, this.appendChild(h);
2609
2614
  };
2610
2615
  }
2611
- return l(this, F).emit("save"), l(this, F).emit(N.Change), h;
2616
+ return f(this, F).emit("save"), f(this, F).emit(N.Change), h;
2612
2617
  }
2613
2618
  exportState() {
2614
- return jt(this);
2619
+ return Vt(this);
2615
2620
  }
2616
2621
  async importState(e, i) {
2617
- return await Vt(e, this, i);
2622
+ return await Zt(e, this, i);
2618
2623
  }
2619
2624
  clearChildren() {
2620
- this.selectionManager.clear(), this.state.clearChildren(), l(this, K).clear();
2625
+ this.selectionManager.clear(), this.state.clearChildren(), f(this, Q).clear();
2621
2626
  }
2622
2627
  toggleGrid() {
2623
- l(this, X).changeGridType(
2624
- l(this, X).gridType === Tt.GRID ? Tt.NONE : Tt.GRID
2628
+ f(this, X).changeGridType(
2629
+ f(this, X).gridType === _t.GRID ? _t.NONE : _t.GRID
2625
2630
  );
2626
2631
  }
2627
2632
  getSelected() {
2628
- return l(this, P).selected;
2633
+ return f(this, P).selected;
2629
2634
  }
2630
2635
  setShapeZOrder(e = !0) {
2631
- if (l(this, P).multiBoundingBox || l(this, P).boundingBoxes.size != 1)
2636
+ if (f(this, P).multiBoundingBox || f(this, P).boundingBoxes.size != 1)
2632
2637
  return;
2633
- const i = Array.from(l(this, P).boundingBoxes)[0].target, r = {
2638
+ const i = Array.from(f(this, P).boundingBoxes)[0].target, r = {
2634
2639
  ref: i,
2635
2640
  start: {
2636
2641
  renderOrder: i.renderOrder
@@ -2641,20 +2646,20 @@ const R = class R extends Ie {
2641
2646
  const a = Math.max(...n), o = Math.min(...n);
2642
2647
  i.renderOrder = e ? a + 1 : o - 1, r.end = {
2643
2648
  renderOrder: i.renderOrder
2644
- }, this.markOrderDirty(), l(this, K).push(Di([r])), l(this, F).emit(N.Change);
2649
+ }, this.markOrderDirty(), f(this, Q).push(Bi([r])), f(this, F).emit(N.Change);
2645
2650
  }
2646
2651
  changeMode() {
2647
- l(this, ht).changeMode(), l(this, P).clear();
2652
+ f(this, dt).changeMode(), f(this, P).clear();
2648
2653
  }
2649
2654
  updateZoomByFixedAmount(e = 1) {
2650
- l(this, at).updateZoom(
2651
- l(this, W).width / 2,
2652
- l(this, W).height / 2,
2655
+ f(this, ht).updateZoom(
2656
+ f(this, W).width / 2,
2657
+ f(this, W).height / 2,
2653
2658
  Math.exp(0.5 * 0.3 * e)
2654
2659
  );
2655
2660
  }
2656
2661
  getBoundingClientRect() {
2657
- return l(this, W).getBoundingClientRect();
2662
+ return f(this, W).getBoundingClientRect();
2658
2663
  }
2659
2664
  wrapWebGLContext(e) {
2660
2665
  const i = e.createTexture.bind(e);
@@ -2676,7 +2681,7 @@ const R = class R extends Ie {
2676
2681
  };
2677
2682
  }
2678
2683
  };
2679
- W = new WeakMap(), F = new WeakMap(), K = new WeakMap(), at = new WeakMap(), y = new WeakMap(), G = new WeakMap(), ot = new WeakMap(), Q = new WeakMap(), X = new WeakMap(), V = new WeakMap(), P = new WeakMap(), ht = new WeakMap(), Wt = new WeakMap(), ct = new WeakMap(), R.webglStats = {
2684
+ W = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), ht = new WeakMap(), y = new WeakMap(), G = new WeakMap(), ct = new WeakMap(), J = new WeakMap(), X = new WeakMap(), V = new WeakMap(), P = new WeakMap(), dt = new WeakMap(), Ft = new WeakMap(), lt = new WeakMap(), R.webglStats = {
2680
2685
  buffersCreated: 0,
2681
2686
  buffersDeleted: 0,
2682
2687
  programsCreated: 0,
@@ -2686,9 +2691,9 @@ W = new WeakMap(), F = new WeakMap(), K = new WeakMap(), at = new WeakMap(), y =
2686
2691
  shadersCreated: 0,
2687
2692
  shadersDeleted: 0
2688
2693
  };
2689
- let zt = R;
2690
- const pe = 25;
2691
- class Xi {
2694
+ let kt = R;
2695
+ const xe = 25;
2696
+ class Hi {
2692
2697
  constructor() {
2693
2698
  this._undoStack = [], this._redoStack = [], this._openGroup = null;
2694
2699
  }
@@ -2703,7 +2708,7 @@ class Xi {
2703
2708
  if (this._openGroup)
2704
2709
  this._openGroup.push(t);
2705
2710
  else {
2706
- for (; this._undoStack.length >= pe; )
2711
+ for (; this._undoStack.length >= xe; )
2707
2712
  this._undoStack.shift();
2708
2713
  this._undoStack.push([t]), t.do(), this._redoStack.length = 0;
2709
2714
  }
@@ -2713,7 +2718,7 @@ class Xi {
2713
2718
  const t = this._openGroup;
2714
2719
  this._openGroup = null;
2715
2720
  for (const e of t) e.do();
2716
- for (; this._undoStack.length >= pe; )
2721
+ for (; this._undoStack.length >= xe; )
2717
2722
  this._undoStack.shift();
2718
2723
  this._undoStack.push(t), this._redoStack.length = 0, this._openLabel = void 0;
2719
2724
  }
@@ -2744,23 +2749,23 @@ class Xi {
2744
2749
  this._undoStack.length = 0, this._redoStack.length = 0, this._openGroup = null, this._openLabel = void 0;
2745
2750
  }
2746
2751
  }
2747
- const Hi = (s) => (t, e) => {
2752
+ const Ni = (s) => (t, e) => {
2748
2753
  e !== void 0 ? e.addInitializer((() => {
2749
2754
  customElements.define(s, t);
2750
2755
  })) : customElements.define(s, t);
2751
2756
  };
2752
- const _t = globalThis, Qt = _t.ShadowRoot && (_t.ShadyCSS === void 0 || _t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Le = Symbol(), xe = /* @__PURE__ */ new WeakMap();
2753
- let Ni = class {
2757
+ const Rt = globalThis, Jt = Rt.ShadowRoot && (Rt.ShadyCSS === void 0 || Rt.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, De = Symbol(), ye = /* @__PURE__ */ new WeakMap();
2758
+ let Yi = class {
2754
2759
  constructor(t, e, i) {
2755
- if (this._$cssResult$ = !0, i !== Le) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
2760
+ if (this._$cssResult$ = !0, i !== De) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
2756
2761
  this.cssText = t, this.t = e;
2757
2762
  }
2758
2763
  get styleSheet() {
2759
2764
  let t = this.o;
2760
2765
  const e = this.t;
2761
- if (Qt && t === void 0) {
2766
+ if (Jt && t === void 0) {
2762
2767
  const i = e !== void 0 && e.length === 1;
2763
- i && (t = xe.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && xe.set(e, t));
2768
+ i && (t = ye.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && ye.set(e, t));
2764
2769
  }
2765
2770
  return t;
2766
2771
  }
@@ -2768,21 +2773,21 @@ let Ni = class {
2768
2773
  return this.cssText;
2769
2774
  }
2770
2775
  };
2771
- const Yi = (s) => new Ni(typeof s == "string" ? s : s + "", void 0, Le), $i = (s, t) => {
2772
- if (Qt) s.adoptedStyleSheets = t.map(((e) => e instanceof CSSStyleSheet ? e : e.styleSheet));
2776
+ const $i = (s) => new Yi(typeof s == "string" ? s : s + "", void 0, De), ji = (s, t) => {
2777
+ if (Jt) s.adoptedStyleSheets = t.map(((e) => e instanceof CSSStyleSheet ? e : e.styleSheet));
2773
2778
  else for (const e of t) {
2774
- const i = document.createElement("style"), r = _t.litNonce;
2779
+ const i = document.createElement("style"), r = Rt.litNonce;
2775
2780
  r !== void 0 && i.setAttribute("nonce", r), i.textContent = e.cssText, s.appendChild(i);
2776
2781
  }
2777
- }, ye = Qt ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((t) => {
2782
+ }, we = Jt ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((t) => {
2778
2783
  let e = "";
2779
2784
  for (const i of t.cssRules) e += i.cssText;
2780
- return Yi(e);
2785
+ return $i(e);
2781
2786
  })(s) : s;
2782
- const { is: ji, defineProperty: Vi, getOwnPropertyDescriptor: Zi, getOwnPropertyNames: qi, getOwnPropertySymbols: Ki, getPrototypeOf: Qi } = Object, Ft = globalThis, we = Ft.trustedTypes, Ji = we ? we.emptyScript : "", ts = Ft.reactiveElementPolyfillSupport, yt = (s, t) => s, Zt = { toAttribute(s, t) {
2787
+ const { is: Vi, defineProperty: Zi, getOwnPropertyDescriptor: qi, getOwnPropertyNames: Ki, getOwnPropertySymbols: Qi, getPrototypeOf: Ji } = Object, Gt = globalThis, ve = Gt.trustedTypes, ts = ve ? ve.emptyScript : "", es = Gt.reactiveElementPolyfillSupport, vt = (s, t) => s, qt = { toAttribute(s, t) {
2783
2788
  switch (t) {
2784
2789
  case Boolean:
2785
- s = s ? Ji : null;
2790
+ s = s ? ts : null;
2786
2791
  break;
2787
2792
  case Object:
2788
2793
  case Array:
@@ -2807,23 +2812,23 @@ const { is: ji, defineProperty: Vi, getOwnPropertyDescriptor: Zi, getOwnProperty
2807
2812
  }
2808
2813
  }
2809
2814
  return e;
2810
- } }, De = (s, t) => !ji(s, t), ve = { attribute: !0, type: String, converter: Zt, reflect: !1, useDefault: !1, hasChanged: De };
2811
- Symbol.metadata ??= Symbol("metadata"), Ft.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
2812
- class ut extends HTMLElement {
2815
+ } }, Be = (s, t) => !Vi(s, t), be = { attribute: !0, type: String, converter: qt, reflect: !1, useDefault: !1, hasChanged: Be };
2816
+ Symbol.metadata ??= Symbol("metadata"), Gt.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
2817
+ class ft extends HTMLElement {
2813
2818
  static addInitializer(t) {
2814
2819
  this._$Ei(), (this.l ??= []).push(t);
2815
2820
  }
2816
2821
  static get observedAttributes() {
2817
2822
  return this.finalize(), this._$Eh && [...this._$Eh.keys()];
2818
2823
  }
2819
- static createProperty(t, e = ve) {
2824
+ static createProperty(t, e = be) {
2820
2825
  if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
2821
2826
  const i = Symbol(), r = this.getPropertyDescriptor(t, i, e);
2822
- r !== void 0 && Vi(this.prototype, t, r);
2827
+ r !== void 0 && Zi(this.prototype, t, r);
2823
2828
  }
2824
2829
  }
2825
2830
  static getPropertyDescriptor(t, e, i) {
2826
- const { get: r, set: n } = Zi(this.prototype, t) ?? { get() {
2831
+ const { get: r, set: n } = qi(this.prototype, t) ?? { get() {
2827
2832
  return this[e];
2828
2833
  }, set(a) {
2829
2834
  this[e] = a;
@@ -2834,17 +2839,17 @@ class ut extends HTMLElement {
2834
2839
  }, configurable: !0, enumerable: !0 };
2835
2840
  }
2836
2841
  static getPropertyOptions(t) {
2837
- return this.elementProperties.get(t) ?? ve;
2842
+ return this.elementProperties.get(t) ?? be;
2838
2843
  }
2839
2844
  static _$Ei() {
2840
- if (this.hasOwnProperty(yt("elementProperties"))) return;
2841
- const t = Qi(this);
2845
+ if (this.hasOwnProperty(vt("elementProperties"))) return;
2846
+ const t = Ji(this);
2842
2847
  t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
2843
2848
  }
2844
2849
  static finalize() {
2845
- if (this.hasOwnProperty(yt("finalized"))) return;
2846
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(yt("properties"))) {
2847
- const e = this.properties, i = [...qi(e), ...Ki(e)];
2850
+ if (this.hasOwnProperty(vt("finalized"))) return;
2851
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(vt("properties"))) {
2852
+ const e = this.properties, i = [...Ki(e), ...Qi(e)];
2848
2853
  for (const r of i) this.createProperty(r, e[r]);
2849
2854
  }
2850
2855
  const t = this[Symbol.metadata];
@@ -2863,8 +2868,8 @@ class ut extends HTMLElement {
2863
2868
  const e = [];
2864
2869
  if (Array.isArray(t)) {
2865
2870
  const i = new Set(t.flat(1 / 0).reverse());
2866
- for (const r of i) e.unshift(ye(r));
2867
- } else t !== void 0 && e.push(ye(t));
2871
+ for (const r of i) e.unshift(we(r));
2872
+ } else t !== void 0 && e.push(we(t));
2868
2873
  return e;
2869
2874
  }
2870
2875
  static _$Eu(t, e) {
@@ -2890,7 +2895,7 @@ class ut extends HTMLElement {
2890
2895
  }
2891
2896
  createRenderRoot() {
2892
2897
  const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
2893
- return $i(t, this.constructor.elementStyles), t;
2898
+ return ji(t, this.constructor.elementStyles), t;
2894
2899
  }
2895
2900
  connectedCallback() {
2896
2901
  this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach(((t) => t.hostConnected?.()));
@@ -2906,14 +2911,14 @@ class ut extends HTMLElement {
2906
2911
  _$ET(t, e) {
2907
2912
  const i = this.constructor.elementProperties.get(t), r = this.constructor._$Eu(t, i);
2908
2913
  if (r !== void 0 && i.reflect === !0) {
2909
- const n = (i.converter?.toAttribute !== void 0 ? i.converter : Zt).toAttribute(e, i.type);
2914
+ const n = (i.converter?.toAttribute !== void 0 ? i.converter : qt).toAttribute(e, i.type);
2910
2915
  this._$Em = t, n == null ? this.removeAttribute(r) : this.setAttribute(r, n), this._$Em = null;
2911
2916
  }
2912
2917
  }
2913
2918
  _$AK(t, e) {
2914
2919
  const i = this.constructor, r = i._$Eh.get(t);
2915
2920
  if (r !== void 0 && this._$Em !== r) {
2916
- const n = i.getPropertyOptions(r), a = typeof n.converter == "function" ? { fromAttribute: n.converter } : n.converter?.fromAttribute !== void 0 ? n.converter : Zt;
2921
+ const n = i.getPropertyOptions(r), a = typeof n.converter == "function" ? { fromAttribute: n.converter } : n.converter?.fromAttribute !== void 0 ? n.converter : qt;
2917
2922
  this._$Em = r;
2918
2923
  const o = a.fromAttribute(e, n.type);
2919
2924
  this[r] = o ?? this._$Ej?.get(r) ?? o, this._$Em = null;
@@ -2922,7 +2927,7 @@ class ut extends HTMLElement {
2922
2927
  requestUpdate(t, e, i) {
2923
2928
  if (t !== void 0) {
2924
2929
  const r = this.constructor, n = this[t];
2925
- if (i ??= r.getPropertyOptions(t), !((i.hasChanged ?? De)(n, e) || i.useDefault && i.reflect && n === this._$Ej?.get(t) && !this.hasAttribute(r._$Eu(t, i)))) return;
2930
+ if (i ??= r.getPropertyOptions(t), !((i.hasChanged ?? Be)(n, e) || i.useDefault && i.reflect && n === this._$Ej?.get(t) && !this.hasAttribute(r._$Eu(t, i)))) return;
2926
2931
  this.C(t, e, i);
2927
2932
  }
2928
2933
  this.isUpdatePending === !1 && (this._$ES = this._$EP());
@@ -2990,8 +2995,8 @@ class ut extends HTMLElement {
2990
2995
  firstUpdated(t) {
2991
2996
  }
2992
2997
  }
2993
- ut.elementStyles = [], ut.shadowRootOptions = { mode: "open" }, ut[yt("elementProperties")] = /* @__PURE__ */ new Map(), ut[yt("finalized")] = /* @__PURE__ */ new Map(), ts?.({ ReactiveElement: ut }), (Ft.reactiveElementVersions ??= []).push("2.1.1");
2994
- class Be {
2998
+ ft.elementStyles = [], ft.shadowRootOptions = { mode: "open" }, ft[vt("elementProperties")] = /* @__PURE__ */ new Map(), ft[vt("finalized")] = /* @__PURE__ */ new Map(), es?.({ ReactiveElement: ft }), (Gt.reactiveElementVersions ??= []).push("2.1.1");
2999
+ class ze {
2995
3000
  constructor(t, e) {
2996
3001
  this.options = [], this.rootNode = e, this._el = document.createElement("div"), this._el.classList.add("context-menu"), t.options.forEach((i, r) => {
2997
3002
  this.createOptionGroup(i), r !== t.options.length - 1 && this.addDivider();
@@ -3006,7 +3011,7 @@ class Be {
3006
3011
  t.appendChild(this.el);
3007
3012
  }
3008
3013
  createOptionGroup(t) {
3009
- const e = new es(t, this.rootNode);
3014
+ const e = new is(t, this.rootNode);
3010
3015
  this.options.push(e), this.el.appendChild(e.el);
3011
3016
  }
3012
3017
  addDivider() {
@@ -3014,7 +3019,7 @@ class Be {
3014
3019
  t.classList.add("context-menu-divider"), this.el.appendChild(t);
3015
3020
  }
3016
3021
  }
3017
- class es {
3022
+ class is {
3018
3023
  constructor(t, e) {
3019
3024
  this.childOptions = [], this.rootNode = e, this._el = document.createElement("div"), this.createOptionElement = this.createOptionElement.bind(this), t.childOptions.forEach((i) => this.createOptionElement(i));
3020
3025
  }
@@ -3026,43 +3031,43 @@ class es {
3026
3031
  }
3027
3032
  createOptionElement(t) {
3028
3033
  t.parent = this;
3029
- const e = new is(t, this.rootNode);
3034
+ const e = new ss(t, this.rootNode);
3030
3035
  this.childOptions.push(e);
3031
3036
  }
3032
3037
  }
3033
- class is {
3038
+ class ss {
3034
3039
  get el() {
3035
3040
  return this._el;
3036
3041
  }
3037
3042
  constructor(t, e) {
3038
3043
  this.displayText = t.text, this.rootNode = e, this.parent = t.parent, this._el = document.createElement("button"), this._el.textContent = t.text, this._el.classList.add("context-menu-option"), this.parent.el.appendChild(this._el), "onClick" in t && this._el.addEventListener("click", t.onClick), this._el.addEventListener(
3039
3044
  "pointerenter",
3040
- (i) => ss(i, t, this._el, this.rootNode)
3045
+ (i) => rs(i, t, this._el, this.rootNode)
3041
3046
  ), this._el.addEventListener("contextmenu", (i) => {
3042
3047
  i.preventDefault();
3043
3048
  });
3044
3049
  }
3045
3050
  }
3046
- function ss(s, t, e, i) {
3051
+ function rs(s, t, e, i) {
3047
3052
  if (!i) return;
3048
3053
  const r = i.querySelector(".sub-context-menu");
3049
3054
  if (r && r.remove(), t.subMenu) {
3050
- const n = new Be(t.subMenu, this);
3055
+ const n = new ze(t.subMenu, this);
3051
3056
  i.appendChild(n.el), n.el.id = `${t.text}-context-menu`, n.el.classList.add("sub-context-menu");
3052
- const a = i.getBoundingClientRect(), o = e.getBoundingClientRect(), h = n.el.getBoundingClientRect(), c = a.right - a.left, u = a.bottom - a.top, f = o.right + h.width;
3053
- o.top + h.height > u ? n._el.style.top = `${o.bottom - h.height}px` : n._el.style.top = `${o.top}px`, f > c ? n._el.style.left = `${o.left - h.width}px` : n._el.style.left = `${o.right}px`;
3057
+ const a = i.getBoundingClientRect(), o = e.getBoundingClientRect(), h = n.el.getBoundingClientRect(), c = a.right - a.left, l = a.bottom - a.top, u = o.right + h.width;
3058
+ o.top + h.height > l ? n._el.style.top = `${o.bottom - h.height}px` : n._el.style.top = `${o.top}px`, u > c ? n._el.style.left = `${o.left - h.width}px` : n._el.style.left = `${o.right}px`;
3054
3059
  }
3055
3060
  }
3056
- const Ct = 5;
3057
- function Gt(s) {
3061
+ const St = 5;
3062
+ function Xt(s) {
3058
3063
  const t = this;
3059
3064
  return function(...e) {
3060
3065
  const i = s.apply(t, e);
3061
3066
  return t.clearContextMenu(), i;
3062
3067
  };
3063
3068
  }
3064
- function rs(s, t, e = "single") {
3065
- const i = new Be(
3069
+ function ns(s, t, e = "single") {
3070
+ const i = new ze(
3066
3071
  e === "single" ? this.singleImageMenuOptions : e === "multi" ? this.multiImageMenuOptions : this.canvasImageMenuOptions,
3067
3072
  this.rootDiv
3068
3073
  );
@@ -3071,26 +3076,26 @@ function rs(s, t, e = "single") {
3071
3076
  return;
3072
3077
  }
3073
3078
  i.attachToParent(this.rootDiv);
3074
- const r = this.getBoundingClientRect(), n = s - r.left, a = t - r.top, o = r.right - r.left, h = r.bottom - r.top, c = i.el.getBoundingClientRect(), u = [
3079
+ const r = this.getBoundingClientRect(), n = s - r.left, a = t - r.top, o = r.right - r.left, h = r.bottom - r.top, c = i.el.getBoundingClientRect(), l = [
3075
3080
  n + c.width > o ? 1 : 0,
3076
3081
  a + c.height > h ? 1 : 0
3077
- ], f = c.height * u[1], g = c.width * u[0];
3078
- if (f > h) {
3079
- const m = h - 2 * Ct;
3080
- i._el.style.height = `${m}px`, i._el.style.top = `${Ct}px`;
3082
+ ], u = c.height * l[1], g = c.width * l[0];
3083
+ if (u > h) {
3084
+ const m = h - 2 * St;
3085
+ i._el.style.height = `${m}px`, i._el.style.top = `${St}px`;
3081
3086
  } else
3082
- i._el.style.top = `${a - f}px`;
3083
- g > o ? (i._el.style.width = `${o - 2 * Ct}px`, i._el.style.left = `${Ct}px`) : i._el.style.left = `${n - g}px`;
3087
+ i._el.style.top = `${a - u}px`;
3088
+ g > o ? (i._el.style.width = `${o - 2 * St}px`, i._el.style.left = `${St}px`) : i._el.style.left = `${n - g}px`;
3084
3089
  }
3085
- function ns() {
3090
+ function as() {
3086
3091
  const s = this.renderRoot.querySelector(".context-menu");
3087
3092
  s && (s.remove(), this.eventHub.emit(H.Close));
3088
3093
  }
3089
- function as() {
3094
+ function os() {
3090
3095
  return this.renderRoot.querySelector(".context-menu") !== null;
3091
3096
  }
3092
- function os() {
3093
- const s = Gt.bind(this);
3097
+ function hs() {
3098
+ const s = Xt.bind(this);
3094
3099
  return {
3095
3100
  options: [
3096
3101
  {
@@ -3130,8 +3135,8 @@ function os() {
3130
3135
  ]
3131
3136
  };
3132
3137
  }
3133
- function hs(s) {
3134
- const t = Gt.bind(this);
3138
+ function cs(s) {
3139
+ const t = Xt.bind(this);
3135
3140
  return {
3136
3141
  options: [
3137
3142
  ...s ?? [],
@@ -3150,8 +3155,8 @@ function hs(s) {
3150
3155
  ]
3151
3156
  };
3152
3157
  }
3153
- function cs(s) {
3154
- const t = Gt.bind(this);
3158
+ function ds(s) {
3159
+ const t = Xt.bind(this);
3155
3160
  return {
3156
3161
  options: [
3157
3162
  ...s ?? [],
@@ -3273,8 +3278,8 @@ function cs(s) {
3273
3278
  ]
3274
3279
  };
3275
3280
  }
3276
- function ds(s) {
3277
- const t = Gt.bind(this);
3281
+ function ls(s) {
3282
+ const t = Xt.bind(this);
3278
3283
  return {
3279
3284
  options: [
3280
3285
  ...s ?? [],
@@ -3305,7 +3310,7 @@ function ds(s) {
3305
3310
  ]
3306
3311
  };
3307
3312
  }
3308
- class Jt {
3313
+ class te {
3309
3314
  _touch() {
3310
3315
  this._lastRetrieved = Date.now();
3311
3316
  }
@@ -3325,24 +3330,24 @@ class Jt {
3325
3330
  return this._lastRetrieved;
3326
3331
  }
3327
3332
  constructor(t) {
3328
- this._dataURL = t, this._mimetype = di(t), this._created = Date.now(), this._lastRetrieved = Date.now();
3333
+ this._dataURL = t, this._mimetype = li(t), this._created = Date.now(), this._lastRetrieved = Date.now();
3329
3334
  }
3330
3335
  static async create(t) {
3331
- const e = new Jt(t);
3332
- return e._id = await Kt(t), e;
3336
+ const e = new te(t);
3337
+ return e._id = await Qt(t), e;
3333
3338
  }
3334
3339
  }
3335
- class ls {
3336
- }
3337
3340
  class us {
3338
3341
  }
3339
- function ze(s) {
3342
+ class fs {
3343
+ }
3344
+ function ke(s) {
3340
3345
  s.Version.prototype._parseStoresSpec = Y.override(
3341
3346
  s.Version.prototype._parseStoresSpec,
3342
- fs
3343
- ), s.open = Y.override(s.open, gs(s));
3347
+ ms
3348
+ ), s.open = Y.override(s.open, ps(s));
3344
3349
  }
3345
- function fs(s) {
3350
+ function ms(s) {
3346
3351
  return function(t, e) {
3347
3352
  s.call(this, t, e), Object.keys(e).forEach(function(i) {
3348
3353
  let r = e[i];
@@ -3350,38 +3355,38 @@ function fs(s) {
3350
3355
  });
3351
3356
  };
3352
3357
  }
3353
- function ms(s) {
3358
+ function gs(s) {
3354
3359
  return function(e, i) {
3355
3360
  let r;
3356
- return e === void 0 && s.schema.primKey.uuid && (e = r = ei(), s.schema.primKey.keyPath && Y.setByKeyPath(i, s.schema.primKey.keyPath, e)), r;
3361
+ return e === void 0 && s.schema.primKey.uuid && (e = r = ii(), s.schema.primKey.keyPath && Y.setByKeyPath(i, s.schema.primKey.keyPath, e)), r;
3357
3362
  };
3358
3363
  }
3359
- function gs(s) {
3364
+ function ps(s) {
3360
3365
  return function(e) {
3361
3366
  return function() {
3362
3367
  return Object.keys(s._allTables).forEach((i) => {
3363
3368
  let r = s._allTables[i];
3364
- r.hook("creating").subscribe(ms(r));
3369
+ r.hook("creating").subscribe(gs(r));
3365
3370
  }), e.apply(this, arguments);
3366
3371
  };
3367
3372
  };
3368
3373
  }
3369
- Y.UUIDPrimaryKey = ze;
3370
- Y.addons.push(ze);
3374
+ Y.UUIDPrimaryKey = ke;
3375
+ Y.addons.push(ke);
3371
3376
  Y.UUIDPrimaryKey;
3372
- const ps = {
3377
+ const xs = {
3373
3378
  files: "$$id, mimetype, created, lastRetrieved"
3374
- }, be = {
3379
+ }, Ce = {
3375
3380
  MAX_IMAGE_ENTRIES: 1e3
3376
3381
  };
3377
- class St extends ls {
3382
+ class Mt extends us {
3378
3383
  constructor() {
3379
- super(), this.dbQueue = new Se(), this.cache = /* @__PURE__ */ new Map(), this.CACHE_LIMIT = 500, this.dbQueue = new Se(), this.dbPromise = this.initDb();
3384
+ super(), this.dbQueue = new Me(), this.cache = /* @__PURE__ */ new Map(), this.CACHE_LIMIT = 500, this.dbQueue = new Me(), this.dbPromise = this.initDb();
3380
3385
  }
3381
3386
  async initDb() {
3382
3387
  return $(async () => {
3383
3388
  let t = new Y("InfiniteCanvas");
3384
- return Y.UUIDPrimaryKey(t), t.version(1).stores(ps), await t.open(), t;
3389
+ return Y.UUIDPrimaryKey(t), t.version(1).stores(xs), await t.open(), t;
3385
3390
  });
3386
3391
  }
3387
3392
  async getIndexDb() {
@@ -3394,11 +3399,11 @@ class St extends ls {
3394
3399
  * @returns the file ID
3395
3400
  */
3396
3401
  async write(t) {
3397
- const e = await Jt.create(t), i = ws(e.dataURL);
3402
+ const e = await te.create(t), i = vs(e.dataURL);
3398
3403
  return this.dbQueue.add(
3399
3404
  () => $(async () => {
3400
3405
  const r = await this.getIndexDb();
3401
- return await r.transaction("rw", r.files, async () => (await ys(r), await r.files.add({
3406
+ return await r.transaction("rw", r.files, async () => (await ws(r), await r.files.add({
3402
3407
  id: e.id,
3403
3408
  blob: i,
3404
3409
  dataURL: e.dataURL,
@@ -3472,7 +3477,7 @@ class St extends ls {
3472
3477
  });
3473
3478
  }
3474
3479
  }
3475
- class Yt extends us {
3480
+ class $t extends fs {
3476
3481
  constructor(t) {
3477
3482
  super(), this.key = "infinite_canvas", this.key = t;
3478
3483
  }
@@ -3507,17 +3512,17 @@ class Yt extends us {
3507
3512
  return this.write(t);
3508
3513
  }
3509
3514
  }
3510
- class Ce extends Error {
3515
+ class Se extends Error {
3511
3516
  constructor(t) {
3512
3517
  super(t), this.name = "QuotaExceededError";
3513
3518
  }
3514
3519
  }
3515
- class xs extends Error {
3520
+ class ys extends Error {
3516
3521
  constructor(t) {
3517
3522
  super(t), this.name = "DatabaseLimitError";
3518
3523
  }
3519
3524
  }
3520
- class Se {
3525
+ class Me {
3521
3526
  constructor() {
3522
3527
  this.queue = Promise.resolve();
3523
3528
  }
@@ -3531,26 +3536,26 @@ const $ = async (s) => {
3531
3536
  try {
3532
3537
  return await s();
3533
3538
  } catch (t) {
3534
- throw t instanceof DOMException && t.name === "QuotaExceededError" ? new Ce(
3539
+ throw t instanceof DOMException && t.name === "QuotaExceededError" ? new Se(
3535
3540
  "Storage quota exceeded. Please free up space."
3536
- ) : t instanceof Y.QuotaExceededError ? new Ce(
3541
+ ) : t instanceof Y.QuotaExceededError ? new Se(
3537
3542
  "Database quota exceeded. Please free up space."
3538
3543
  ) : t;
3539
3544
  }
3540
3545
  };
3541
- async function ys(s) {
3542
- if (await s.files.count() >= be.MAX_IMAGE_ENTRIES)
3543
- throw new xs(
3544
- `Cannot save image: limit of ${be.MAX_IMAGE_ENTRIES} reached`
3546
+ async function ws(s) {
3547
+ if (await s.files.count() >= Ce.MAX_IMAGE_ENTRIES)
3548
+ throw new ys(
3549
+ `Cannot save image: limit of ${Ce.MAX_IMAGE_ENTRIES} reached`
3545
3550
  );
3546
3551
  }
3547
- function ws(s) {
3552
+ function vs(s) {
3548
3553
  const t = s.split(","), e = t[0], i = t[1], r = e.match(/:(.*?);/), n = r ? r[1] : "application/octet-stream", a = atob(i), o = a.length, h = new Uint8Array(o);
3549
3554
  for (let c = 0; c < o; c++)
3550
3555
  h[c] = a.charCodeAt(c);
3551
3556
  return new Blob([h], { type: n });
3552
3557
  }
3553
- class vs {
3558
+ class bs {
3554
3559
  get el() {
3555
3560
  return this._el;
3556
3561
  }
@@ -3582,34 +3587,34 @@ class vs {
3582
3587
  this._el.parentNode && this._el.parentNode.removeChild(this._el);
3583
3588
  }
3584
3589
  }
3585
- function bs(s, t) {
3586
- const e = new vs({ type: s, message: t });
3590
+ function Cs(s, t) {
3591
+ const e = new bs({ type: s, message: t });
3587
3592
  e.attachToParent(this.renderRoot);
3588
3593
  const i = this.getBoundingClientRect();
3589
3594
  return e.el.style.width = `${i.right}px`, e.el.style.height = `${i.bottom}px`, e._el.style.top = `${-i.bottom}px`, e;
3590
3595
  }
3591
- function Cs() {
3596
+ function Ss() {
3592
3597
  const s = this.renderRoot.querySelector(".canvas-loader");
3593
3598
  s && s.remove();
3594
3599
  }
3595
- var Ss = Object.getOwnPropertyDescriptor, ke = (s) => {
3600
+ var Ms = Object.getOwnPropertyDescriptor, Ue = (s) => {
3596
3601
  throw TypeError(s);
3597
- }, Ms = (s, t, e, i) => {
3598
- for (var r = i > 1 ? void 0 : i ? Ss(t, e) : t, n = s.length - 1, a; n >= 0; n--)
3602
+ }, Es = (s, t, e, i) => {
3603
+ for (var r = i > 1 ? void 0 : i ? Ms(t, e) : t, n = s.length - 1, a; n >= 0; n--)
3599
3604
  (a = s[n]) && (r = a(r) || r);
3600
3605
  return r;
3601
- }, Ue = (s, t, e) => t.has(s) || ke("Cannot " + e), d = (s, t, e) => (Ue(s, t, "read from private field"), e ? e.call(s) : t.get(s)), D = (s, t, e) => t.has(s) ? ke("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), E = (s, t, e, i) => (Ue(s, t, "write to private field"), t.set(s, e), e), p, _, Rt, j, O, k, mt, It, gt, q, rt, Pt, At, Ot;
3602
- let kt = class extends ti {
3606
+ }, We = (s, t, e) => t.has(s) || Ue("Cannot " + e), d = (s, t, e) => (We(s, t, "read from private field"), e ? e.call(s) : t.get(s)), D = (s, t, e) => t.has(s) ? Ue("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), M = (s, t, e, i) => (We(s, t, "write to private field"), t.set(s, e), e), p, _, It, j, L, k, gt, Pt, pt, xt, q, at, At, Lt, Ot;
3607
+ let Ut = class extends ei {
3603
3608
  constructor() {
3604
- super(...arguments), this.name = "Reffy", this.displayMode = "fullscreen", D(this, p), D(this, _), D(this, Rt), D(this, j), D(this, O), D(this, k), D(this, mt, 3e5), D(this, It), D(this, gt), D(this, q), D(this, rt), D(this, Pt), D(this, At), D(this, Ot), this.handleGlobalPointerDown = (s) => {
3609
+ super(...arguments), this.name = "Reffy", this.displayMode = "fullscreen", D(this, p), D(this, _), D(this, It), D(this, j), D(this, L), D(this, k), D(this, gt, 3e5), D(this, Pt), D(this, pt), D(this, xt), D(this, q), D(this, at), D(this, At), D(this, Lt), D(this, Ot), this.handleGlobalPointerDown = (s) => {
3605
3610
  !this.contains(s.target) && !this.renderRoot.contains(s.target) && this.clearContextMenu();
3606
3611
  };
3607
3612
  }
3608
3613
  get singleImageMenuOptions() {
3609
- return d(this, Pt);
3614
+ return d(this, At);
3610
3615
  }
3611
3616
  get multiImageMenuOptions() {
3612
- return d(this, At);
3617
+ return d(this, Lt);
3613
3618
  }
3614
3619
  get canvasImageMenuOptions() {
3615
3620
  return d(this, Ot);
@@ -3618,10 +3623,10 @@ let kt = class extends ti {
3618
3623
  return d(this, p);
3619
3624
  }
3620
3625
  get onCanvasChange() {
3621
- return d(this, rt);
3626
+ return d(this, at);
3622
3627
  }
3623
3628
  set onCanvasChange(s) {
3624
- E(this, rt, s);
3629
+ M(this, at, s);
3625
3630
  }
3626
3631
  get eventHub() {
3627
3632
  return d(this, _);
@@ -3642,7 +3647,7 @@ let kt = class extends ti {
3642
3647
  "pointerdown",
3643
3648
  this.handleGlobalPointerDown,
3644
3649
  !0
3645
- ), d(this, Rt)?.disconnect(), E(this, Rt, void 0), d(this, p).destroy(), super.disconnectedCallback();
3650
+ ), window.removeEventListener("resize", d(this, xt)), d(this, It)?.disconnect(), M(this, It, void 0), d(this, p).destroy(), super.disconnectedCallback();
3646
3651
  }
3647
3652
  firstUpdated(s) {
3648
3653
  try {
@@ -3659,11 +3664,11 @@ let kt = class extends ti {
3659
3664
  e && i && this.resizeCanvas(e, i);
3660
3665
  }
3661
3666
  async initCanvas() {
3662
- await this.warmUpStorage(), E(this, j, new Xi()), E(this, _, new ii());
3667
+ await this.warmUpStorage(), M(this, j, new Hi()), M(this, _, new si());
3663
3668
  const s = document.createElement("div");
3664
- s.style.overflow = "hidden", this.renderRoot.appendChild(s), E(this, q, s);
3669
+ s.style.overflow = "hidden", this.renderRoot.appendChild(s), M(this, q, s);
3665
3670
  const t = document.createElement("canvas");
3666
- this.assignFileStorage = this.assignFileStorage.bind(this), this.getImageFileMetadata = this.getImageFileMetadata.bind(this), this.getAllImageFileMetdata = this.getAllImageFileMetdata.bind(this), this.saveImageFileMetadata = this.saveImageFileMetadata.bind(this), this.restoreStateFromCanvasStorage = this.restoreStateFromCanvasStorage.bind(this), this.assignCanvasStorage = this.assignCanvasStorage.bind(this), this.saveToCanvasStorage = this.saveToCanvasStorage.bind(this), this.debounceSaveToCanvasStorage = this.debounceSaveToCanvasStorage.bind(this), this.importCanvas = this.importCanvas.bind(this), this.exportCanvas = this.exportCanvas.bind(this), this.addContextMenu = rs.bind(this), this.clearContextMenu = ns.bind(this), this.isContextMenuActive = as.bind(this), this.getContainerSize = this.getContainerSize.bind(this), s.contains(t) || s.appendChild(t), this.registerSignal(), E(this, p, new zt(
3671
+ this.assignFileStorage = this.assignFileStorage.bind(this), this.getImageFileMetadata = this.getImageFileMetadata.bind(this), this.getAllImageFileMetdata = this.getAllImageFileMetdata.bind(this), this.saveImageFileMetadata = this.saveImageFileMetadata.bind(this), this.restoreStateFromCanvasStorage = this.restoreStateFromCanvasStorage.bind(this), this.assignCanvasStorage = this.assignCanvasStorage.bind(this), this.saveToCanvasStorage = this.saveToCanvasStorage.bind(this), this.debounceSaveToCanvasStorage = this.debounceSaveToCanvasStorage.bind(this), this.importCanvas = this.importCanvas.bind(this), this.exportCanvas = this.exportCanvas.bind(this), this.addContextMenu = ns.bind(this), this.clearContextMenu = as.bind(this), this.isContextMenuActive = os.bind(this), this.getContainerSize = this.getContainerSize.bind(this), s.contains(t) || s.appendChild(t), this.registerSignal(), M(this, p, new kt(
3667
3672
  t,
3668
3673
  d(this, j),
3669
3674
  d(this, _),
@@ -3676,14 +3681,14 @@ let kt = class extends ti {
3676
3681
  } catch {
3677
3682
  console.error("Failed to restore canvas");
3678
3683
  }
3679
- this.resizeCanvas(s, t);
3680
- const e = os.bind(this)();
3681
- E(this, Pt, hs.bind(this)(
3684
+ this.resizeCanvas(s, t), M(this, xt, () => this.resizeCanvas(s, t)), window.addEventListener("resize", d(this, xt));
3685
+ const e = hs.bind(this)();
3686
+ M(this, At, cs.bind(this)(
3682
3687
  e.options
3683
- )), E(this, Ot, ds.bind(this)()), E(this, At, cs.bind(this)(
3688
+ )), M(this, Ot, ls.bind(this)()), M(this, Lt, ds.bind(this)(
3684
3689
  e.options
3685
3690
  )), this.dispatchEvent(new Event("load"));
3686
- const i = new si();
3691
+ const i = new ri();
3687
3692
  i.showPanel(0), this.renderRoot.contains(i.dom) || this.renderRoot.appendChild(i.dom);
3688
3693
  const r = () => {
3689
3694
  i && i.update(), d(this, p).render(), requestAnimationFrame(r);
@@ -3699,26 +3704,24 @@ let kt = class extends ti {
3699
3704
  s.style.width = this.displayMode === "fullscreen" ? "100vw" : this.normalizeCssSize(this.width), s.style.height = this.displayMode === "fullscreen" ? "100vh" : this.normalizeCssSize(this.height), s.style.overflow = "hidden";
3700
3705
  const e = window.devicePixelRatio || 1;
3701
3706
  let i = window.screen.width, r = window.screen.height;
3702
- const n = Math.round(i * e), a = Math.round(r * e);
3703
- (t.width !== n || t.height !== a) && (t.width = n, t.height = a), t.style.width = `${i}px`, t.style.height = `${r}px`;
3704
- const o = s.getBoundingClientRect();
3705
- this.canvas.camera.viewportX = o.x, this.canvas.camera.viewportY = o.y, this.canvas.camera.state.setHeight(o.height), this.canvas.camera.state.setWidth(o.width);
3707
+ const n = s.getBoundingClientRect(), a = Math.round(i * e), o = Math.round(r * e);
3708
+ (t.width !== a || t.height !== o) && (t.width = a, t.height = o), t.style.width = `${i}px`, t.style.height = `${r}px`, this.canvas.camera.viewportX = n.x, this.canvas.camera.viewportY = n.y, this.canvas.camera.state.setHeight(n.height), this.canvas.camera.state.setWidth(n.width);
3706
3709
  }
3707
3710
  // Register signal
3708
3711
  registerSignal() {
3709
- d(this, _).on(tt.start, bs.bind(this), "spinner"), d(this, _).on(tt.done, Cs.bind(this)), d(this, _).on(H.Open, this.addContextMenu), d(this, _).on(H.Close, this.clearContextMenu), d(this, _).on(N.Change, () => {
3710
- d(this, rt) && d(this, rt).call(this);
3711
- }), d(this, _).on(et.Save, this.saveToCanvasStorage), d(this, _).on(et.SaveCompleted, () => {
3712
+ d(this, _).on(it.start, Cs.bind(this), "spinner"), d(this, _).on(it.done, Ss.bind(this)), d(this, _).on(H.Open, this.addContextMenu), d(this, _).on(H.Close, this.clearContextMenu), d(this, _).on(N.Change, () => {
3713
+ d(this, at) && d(this, at).call(this);
3714
+ }), d(this, _).on(st.Save, this.saveToCanvasStorage), d(this, _).on(st.SaveCompleted, () => {
3712
3715
  }), d(this, _).on(
3713
- et.SaveFailed,
3716
+ st.SaveFailed,
3714
3717
  () => console.error("Failed to Save!")
3715
3718
  );
3716
3719
  }
3717
3720
  // need to check if this is good practice
3718
3721
  async warmUpStorage() {
3719
- d(this, O) || E(this, O, new St());
3722
+ d(this, L) || M(this, L, new Mt());
3720
3723
  try {
3721
- await d(this, O).readAll();
3724
+ await d(this, L).readAll();
3722
3725
  } catch (s) {
3723
3726
  console.error("Storage warm-up failed", s);
3724
3727
  }
@@ -3736,17 +3739,17 @@ let kt = class extends ti {
3736
3739
  * @param storage Canvas storage stores the positions of all the renderables
3737
3740
  * @param saveFrequency How often should auto save execute
3738
3741
  */
3739
- assignCanvasStorage(s, t = d(this, mt)) {
3740
- E(this, k, s), E(this, mt, t), d(this, gt) && clearInterval(d(this, gt)), E(this, gt, setInterval(
3742
+ assignCanvasStorage(s, t = d(this, gt)) {
3743
+ M(this, k, s), M(this, gt, t), d(this, pt) && clearInterval(d(this, pt)), M(this, pt, setInterval(
3741
3744
  this.saveToCanvasStorage,
3742
- d(this, mt)
3745
+ d(this, gt)
3743
3746
  ));
3744
3747
  }
3745
3748
  /**
3746
3749
  * @param storage File storage captures the information about the image data that has previously been added. Made more efficient by using SHA of the image data for storage.
3747
3750
  */
3748
3751
  assignFileStorage(s) {
3749
- E(this, O, s);
3752
+ M(this, L, s);
3750
3753
  }
3751
3754
  /**
3752
3755
  * Duplicate images will not be written to the database
@@ -3754,10 +3757,10 @@ let kt = class extends ti {
3754
3757
  * @returns The unique ID that the image has been logged with. This is a hashed version of the image data URL
3755
3758
  */
3756
3759
  async saveImageFileMetadata(s) {
3757
- d(this, O) || E(this, O, new St());
3760
+ d(this, L) || M(this, L, new Mt());
3758
3761
  try {
3759
- const t = await Kt(s);
3760
- return await d(this, O).checkIfImageStored(t) ? t : await d(this, O).write(s);
3762
+ const t = await Qt(s);
3763
+ return await d(this, L).checkIfImageStored(t) ? t : await d(this, L).write(s);
3761
3764
  } catch (t) {
3762
3765
  console.error(t);
3763
3766
  }
@@ -3767,9 +3770,9 @@ let kt = class extends ti {
3767
3770
  * @returns
3768
3771
  */
3769
3772
  async getImageFileMetadata(s) {
3770
- d(this, O) || E(this, O, new St());
3773
+ d(this, L) || M(this, L, new Mt());
3771
3774
  try {
3772
- return await d(this, O).read(s);
3775
+ return await d(this, L).read(s);
3773
3776
  } catch (t) {
3774
3777
  console.error(t);
3775
3778
  }
@@ -3778,9 +3781,9 @@ let kt = class extends ti {
3778
3781
  * @returns All file metadata saved in connected storage
3779
3782
  */
3780
3783
  async getAllImageFileMetdata() {
3781
- d(this, O) || E(this, O, new St());
3784
+ d(this, L) || M(this, L, new Mt());
3782
3785
  try {
3783
- return await d(this, O).readAll();
3786
+ return await d(this, L).readAll();
3784
3787
  } catch (s) {
3785
3788
  console.error(s);
3786
3789
  }
@@ -3789,15 +3792,15 @@ let kt = class extends ti {
3789
3792
  * Schedule the auto save to the canvas storage based on timer
3790
3793
  */
3791
3794
  debounceSaveToCanvasStorage(s = 1e3) {
3792
- d(this, k) || E(this, k, new Yt(this.name)), clearTimeout(d(this, It)), E(this, It, setTimeout(this.saveToCanvasStorage, s));
3795
+ d(this, k) || M(this, k, new $t(this.name)), clearTimeout(d(this, Pt)), M(this, Pt, setTimeout(this.saveToCanvasStorage, s));
3793
3796
  }
3794
3797
  async saveToCanvasStorage() {
3795
- d(this, k) || E(this, k, new Yt(this.name)), d(this, k).write(jt(d(this, p))).then(() => d(this, _).emit(et.SaveCompleted)).catch(() => d(this, _).emit(et.SaveFailed));
3798
+ d(this, k) || M(this, k, new $t(this.name)), d(this, k).write(Vt(d(this, p))).then(() => d(this, _).emit(st.SaveCompleted)).catch(() => d(this, _).emit(st.SaveFailed));
3796
3799
  }
3797
3800
  async restoreStateFromCanvasStorage() {
3798
- d(this, k) || E(this, k, new Yt(this.name));
3801
+ d(this, k) || M(this, k, new $t(this.name));
3799
3802
  const s = await d(this, k).read(), t = JSON.parse(s);
3800
- t && await Vt(t, d(this, p), this.getImageFileMetadata);
3803
+ t && await Zt(t, d(this, p), this.getImageFileMetadata);
3801
3804
  }
3802
3805
  // Canvas API
3803
3806
  togglePointerMode() {
@@ -3814,30 +3817,30 @@ let kt = class extends ti {
3814
3817
  }
3815
3818
  async addImages(s) {
3816
3819
  if (!d(this, p)) return;
3817
- const t = d(this, p).getBoundingClientRect(), e = t.left + t.width / 2, i = t.top + t.height / 2, [r, n] = wt(e, i, d(this, p)), a = await li(
3820
+ const t = d(this, p).getBoundingClientRect(), e = t.left + t.width / 2, i = t.top + t.height / 2, [r, n] = K(e, i, d(this, p)), a = await ui(
3818
3821
  s,
3819
3822
  (o) => d(this, p).addImageToCanvas(o, r, n, 1, 1, !0)
3820
3823
  );
3821
- d(this, j).push(Bt(d(this, p), a));
3824
+ d(this, j).push(zt(d(this, p), a));
3822
3825
  }
3823
3826
  async removeImage(s) {
3824
3827
  if (!d(this, p)) return;
3825
3828
  const t = d(this, p).getChild(s);
3826
- d(this, p).removeChild(t), d(this, j).push(gi(d(this, p), t));
3829
+ d(this, p).removeChild(t), d(this, j).push(pi(d(this, p), t));
3827
3830
  }
3828
3831
  /**
3829
3832
  * @param url Currently only accept base64 url and the image is automatically added to screen center
3830
3833
  */
3831
3834
  async addImageFromUrl(s) {
3832
3835
  if (!d(this, p)) return;
3833
- const t = d(this, p).getBoundingClientRect(), e = t.left + t.width / 2, i = t.top + t.height / 2, [r, n] = wt(e, i, d(this, p)), a = await d(this, p).addImageToCanvas(s, r, n, 1, 1, !0);
3834
- d(this, j).push(Bt(d(this, p), [a]));
3836
+ const t = d(this, p).getBoundingClientRect(), e = t.left + t.width / 2, i = t.top + t.height / 2, [r, n] = K(e, i, d(this, p)), a = await d(this, p).addImageToCanvas(s, r, n, 1, 1, !0);
3837
+ d(this, j).push(zt(d(this, p), [a]));
3835
3838
  }
3836
3839
  async copyImage() {
3837
- d(this, p) && await _e(d(this, p).getSelected());
3840
+ d(this, p) && await Re(d(this, p).getSelected());
3838
3841
  }
3839
3842
  async pasteImage(s) {
3840
- d(this, p) && await Re(s.clientX, s.clientY, d(this, p), d(this, j), !1);
3843
+ d(this, p) && await Ie(s.clientX, s.clientY, d(this, p), d(this, j), !1);
3841
3844
  }
3842
3845
  flipVertical() {
3843
3846
  d(this, p) && d(this, p).selectionManager.flip("vertical");
@@ -3859,22 +3862,22 @@ let kt = class extends ti {
3859
3862
  }
3860
3863
  async exportCanvas(s = "infinite-canvas.json") {
3861
3864
  if (!d(this, p)) return;
3862
- d(this, _).emit(tt.start, "spinner");
3863
- const t = await this.getAllImageFileMetdata(), e = jt(d(this, p), t);
3864
- ui(s, e), d(this, _).emit(tt.done);
3865
+ d(this, _).emit(it.start, "spinner");
3866
+ const t = await this.getAllImageFileMetdata(), e = Vt(d(this, p), t);
3867
+ fi(s, e), d(this, _).emit(it.done);
3865
3868
  }
3866
3869
  async importCanvas(s) {
3867
- if (d(this, _).emit(tt.start, "spinner"), !d(this, p) || !s || s.length !== 1) return;
3870
+ if (d(this, _).emit(it.start, "spinner"), !d(this, p) || !s || s.length !== 1) return;
3868
3871
  const t = s[0];
3869
3872
  if (!t.type || !t.type.includes("json") && !t.name.toLowerCase().endsWith(".json"))
3870
3873
  return;
3871
- const e = await fi(t);
3872
- await Vt(
3874
+ const e = await mi(t);
3875
+ await Zt(
3873
3876
  e,
3874
3877
  d(this, p),
3875
3878
  this.getImageFileMetadata,
3876
3879
  this.saveImageFileMetadata
3877
- ), d(this, _).emit(et.Save), d(this, _).emit(tt.done);
3880
+ ), d(this, _).emit(st.Save), d(this, _).emit(it.done);
3878
3881
  }
3879
3882
  clearCanvas() {
3880
3883
  d(this, p) && d(this, p).clearChildren();
@@ -3896,25 +3899,26 @@ let kt = class extends ti {
3896
3899
  };
3897
3900
  p = /* @__PURE__ */ new WeakMap();
3898
3901
  _ = /* @__PURE__ */ new WeakMap();
3899
- Rt = /* @__PURE__ */ new WeakMap();
3902
+ It = /* @__PURE__ */ new WeakMap();
3900
3903
  j = /* @__PURE__ */ new WeakMap();
3901
- O = /* @__PURE__ */ new WeakMap();
3904
+ L = /* @__PURE__ */ new WeakMap();
3902
3905
  k = /* @__PURE__ */ new WeakMap();
3903
- mt = /* @__PURE__ */ new WeakMap();
3904
- It = /* @__PURE__ */ new WeakMap();
3905
3906
  gt = /* @__PURE__ */ new WeakMap();
3906
- q = /* @__PURE__ */ new WeakMap();
3907
- rt = /* @__PURE__ */ new WeakMap();
3908
3907
  Pt = /* @__PURE__ */ new WeakMap();
3908
+ pt = /* @__PURE__ */ new WeakMap();
3909
+ xt = /* @__PURE__ */ new WeakMap();
3910
+ q = /* @__PURE__ */ new WeakMap();
3911
+ at = /* @__PURE__ */ new WeakMap();
3909
3912
  At = /* @__PURE__ */ new WeakMap();
3913
+ Lt = /* @__PURE__ */ new WeakMap();
3910
3914
  Ot = /* @__PURE__ */ new WeakMap();
3911
- kt.properties = {
3915
+ Ut.properties = {
3912
3916
  name: { type: String, reflect: !0 },
3913
3917
  width: { type: String, reflect: !0 },
3914
3918
  height: { type: String, reflect: !0 },
3915
3919
  displayMode: { type: String, reflect: !0 }
3916
3920
  };
3917
- kt.styles = Je`
3921
+ Ut.styles = ti`
3918
3922
  :host {
3919
3923
  position: relative;
3920
3924
  overflow: hidden;
@@ -4043,10 +4047,10 @@ kt.styles = Je`
4043
4047
  word-break: break-word;
4044
4048
  }
4045
4049
  `;
4046
- kt = Ms([
4047
- Hi("infinite-canvas")
4048
- ], kt);
4049
- class We {
4050
+ Ut = Es([
4051
+ Ni("infinite-canvas")
4052
+ ], Ut);
4053
+ class Fe {
4050
4054
  constructor(t) {
4051
4055
  if (!t) throw new Error("InfiniteCanvasElement is required");
4052
4056
  this.el = t, this.assignCanvasStorage = this.assignCanvasStorage.bind(this), this.zoomIn = this.zoomIn.bind(this), this.zoomOut = this.zoomOut.bind(this), this.toggleMode = this.toggleMode.bind(this), this.addImageFromLocal = this.addImageFromLocal.bind(this), this.exportCanvas = this.exportCanvas.bind(this), this.importCanvas = this.importCanvas.bind(this), this.clearCanvas = this.clearCanvas.bind(this);
@@ -4058,7 +4062,7 @@ class We {
4058
4062
  )) : e = t, !e) throw new Error("infinite-canvas element not found");
4059
4063
  return e.canvas || await new Promise(
4060
4064
  (i) => e.addEventListener("load", () => i(), { once: !0 })
4061
- ), new We(e);
4065
+ ), new Fe(e);
4062
4066
  }
4063
4067
  /**
4064
4068
  * Without assigning storage, the canvas will not save any data
@@ -4100,11 +4104,11 @@ class We {
4100
4104
  }
4101
4105
  }
4102
4106
  export {
4103
- Wi as Camera,
4104
- zt as Canvas,
4105
- We as InfiniteCanvasAPI,
4106
- kt as InfiniteCanvasElement,
4107
- Ui as ZOOM_MAX,
4108
- ki as ZOOM_MIN
4107
+ Fi as Camera,
4108
+ kt as Canvas,
4109
+ Fe as InfiniteCanvasAPI,
4110
+ Ut as InfiniteCanvasElement,
4111
+ Wi as ZOOM_MAX,
4112
+ Ui as ZOOM_MIN
4109
4113
  };
4110
4114
  //# sourceMappingURL=index.js.map