mirage-engine 0.3.6 → 0.3.8

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.
@@ -1,40 +1,40 @@
1
1
  var _e = Object.defineProperty, Fe = Object.defineProperties;
2
2
  var Ne = Object.getOwnPropertyDescriptors;
3
- var be = Object.getOwnPropertySymbols;
3
+ var ye = Object.getOwnPropertySymbols;
4
4
  var ze = Object.prototype.hasOwnProperty, Xe = Object.prototype.propertyIsEnumerable;
5
- var oe = (s, e, t) => e in s ? _e(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, $ = (s, e) => {
5
+ var ae = (s, e, t) => e in s ? _e(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, $ = (s, e) => {
6
6
  for (var t in e || (e = {}))
7
- ze.call(e, t) && oe(s, t, e[t]);
8
- if (be)
9
- for (var t of be(e))
10
- Xe.call(e, t) && oe(s, t, e[t]);
7
+ ze.call(e, t) && ae(s, t, e[t]);
8
+ if (ye)
9
+ for (var t of ye(e))
10
+ Xe.call(e, t) && ae(s, t, e[t]);
11
11
  return s;
12
- }, we = (s, e) => Fe(s, Ne(e));
13
- var u = (s, e, t) => (oe(s, typeof e != "symbol" ? e + "" : e, t), t);
14
- var Ee = (s, e, t) => new Promise((i, r) => {
12
+ }, be = (s, e) => Fe(s, Ne(e));
13
+ var u = (s, e, t) => (ae(s, typeof e != "symbol" ? e + "" : e, t), t);
14
+ var we = (s, e, t) => new Promise((r, i) => {
15
15
  var o = (c) => {
16
16
  try {
17
17
  a(t.next(c));
18
18
  } catch (l) {
19
- r(l);
19
+ i(l);
20
20
  }
21
21
  }, n = (c) => {
22
22
  try {
23
23
  a(t.throw(c));
24
24
  } catch (l) {
25
- r(l);
25
+ i(l);
26
26
  }
27
- }, a = (c) => c.done ? i(c.value) : Promise.resolve(c.value).then(o, n);
27
+ }, a = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(o, n);
28
28
  a((t = t.apply(s, e)).next());
29
29
  });
30
30
  import * as y from "three";
31
- const Re = {
31
+ const Le = {
32
32
  INCLUDE_TREE: "include-tree",
33
33
  EXCLUDE_TREE: "exclude-tree",
34
34
  INCLUDE_SELF: "include-self",
35
35
  EXCLUDE_SELF: "exclude-self",
36
36
  END: "end"
37
- }, H = {
37
+ }, P = {
38
38
  NAME: "data-mirage-dom",
39
39
  KEY: "mirageDom",
40
40
  VALUES: {
@@ -48,30 +48,35 @@ const Re = {
48
48
  CAPTURE_2: "2",
49
49
  CAPTURE_3: "3",
50
50
  CAPTURE_4: "4",
51
- CAPTURE_5: "5"
52
- }, I = {
51
+ CAPTURE_5: "5",
52
+ CAPTURE_6: "6",
53
+ CAPTURE_7: "7",
54
+ CAPTURE_8: "8",
55
+ CAPTURE_9: "9",
56
+ CAPTURE_10: "10"
57
+ }, U = {
53
58
  NAME: "data-mirage-travel",
54
59
  KEY: "mirageTravel",
55
60
  VALUES: xe,
56
61
  MAX_LAYERS: Object.keys(xe).length - 1
57
- }, F = {
62
+ }, N = {
58
63
  NAME: "data-mirage-filter",
59
64
  KEY: "mirageFilter",
60
- VALUES: Re
65
+ VALUES: Le
61
66
  }, Y = {
62
67
  NAME: "data-mirage-select",
63
68
  KEY: "mirageSelect",
64
- VALUES: Re
69
+ VALUES: Le
65
70
  }, Ve = {
66
71
  NAME: "data-mirage-shader",
67
72
  KEY: "mirageShader"
68
- }, Ce = {
73
+ }, Ee = {
69
74
  NAME: "data-mirage-sandwich",
70
75
  KEY: "mirageSandwich",
71
76
  VALUES: {
72
77
  FRONT: "front"
73
78
  }
74
- }, te = 0, q = 1, Q = 2, Ye = 4, re = 8, ce = 16;
79
+ }, re = 0, q = 1, Z = 2, Ye = 4, ie = 8, ce = 16;
75
80
  function We(s) {
76
81
  const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
77
82
  return e ? {
@@ -100,7 +105,7 @@ class Me {
100
105
  u(this, "pendingStyles", /* @__PURE__ */ new Map());
101
106
  u(this, "isDomDirty", !1);
102
107
  u(this, "isRunning", !1);
103
- u(this, "pendingMask", te);
108
+ u(this, "pendingMask", re);
104
109
  u(this, "mutationTimer", null);
105
110
  u(this, "cssTimer", null);
106
111
  u(this, "resizeConfig");
@@ -115,7 +120,7 @@ class Me {
115
120
  u(this, "onScrollChange", /* @__PURE__ */ new Set());
116
121
  u(this, "onRender", /* @__PURE__ */ new Set());
117
122
  u(this, "onTransitionFinished", (e) => {
118
- this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= q | Q, this.cssTimer = window.setTimeout(() => {
123
+ this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= q | Z, this.cssTimer = window.setTimeout(() => {
119
124
  this.isDomDirty = !0, this.cssTimer = null;
120
125
  }, 50)));
121
126
  });
@@ -131,38 +136,38 @@ class Me {
131
136
  u(this, "renderLoop", () => {
132
137
  if (!this.isRunning)
133
138
  return;
134
- this.onBeforeRender.forEach((i) => i()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((i) => i(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = te);
139
+ this.onBeforeRender.forEach((r) => r()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((r) => r(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = re);
135
140
  const e = window.scrollX, t = window.scrollY;
136
- (e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((i) => i(e, t)), this.lastScrollX = e, this.lastScrollY = t, this.scrollTimer && clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
141
+ (e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((r) => r(e, t)), this.lastScrollX = e, this.lastScrollY = t, this.scrollTimer && clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
137
142
  this.pendingMask |= q, this.isDomDirty = !0, this.scrollTimer = null;
138
- }, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((i) => i(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((i) => i()), requestAnimationFrame(this.renderLoop);
143
+ }, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
139
144
  });
140
- var r, o;
145
+ var i, o;
141
146
  this.target = e;
142
- const i = (r = t.resizeDebounce) != null ? r : !0;
143
- i === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : i === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
147
+ const r = (i = t.resizeDebounce) != null ? i : !0;
148
+ r === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : r === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
144
149
  enabled: !0,
145
- delay: (o = i.delay) != null ? o : 150,
146
- onStart: i.onStart,
147
- onEnd: i.onEnd
150
+ delay: (o = r.delay) != null ? o : 150,
151
+ onStart: r.onStart,
152
+ onEnd: r.onEnd
148
153
  }, this.observer = new MutationObserver((n) => {
149
- let a = te;
154
+ let a = re;
150
155
  for (const c of n)
151
156
  if (c.type === "childList")
152
- a |= re, c.removedNodes.length > 0 && c.removedNodes.forEach((l) => {
157
+ a |= ie, c.removedNodes.length > 0 && c.removedNodes.forEach((l) => {
153
158
  l instanceof HTMLElement && this.pendingDeletions.add(l);
154
159
  });
155
160
  else if (c.type === "attributes")
156
161
  if (c.attributeName === "style") {
157
- a |= q | Q;
162
+ a |= q | Z;
158
163
  const l = c.target, d = He(l.style);
159
164
  this.pendingStyles.set(l, d);
160
165
  } else
161
- c.attributeName === "class" ? a |= q | Q : c.attributeName && c.attributeName.startsWith("data-") && (a |= q | Q, c.attributeName.startsWith("data-mirage") && (a |= re));
166
+ c.attributeName === "class" ? a |= q | Z : c.attributeName && c.attributeName.startsWith("data-") && (a |= q | Z, c.attributeName.startsWith("data-mirage") && (a |= ie));
162
167
  else
163
168
  c.type === "characterData" && (a |= ce | q);
164
- if (a !== te) {
165
- if (this.pendingMask |= a, a & re) {
169
+ if (a !== re) {
170
+ if (this.pendingMask |= a, a & ie) {
166
171
  this.clearTimers(), this.isDomDirty = !0;
167
172
  return;
168
173
  }
@@ -187,12 +192,12 @@ class Me {
187
192
  this.mutationTimer && (clearTimeout(this.mutationTimer), this.mutationTimer = null), this.cssTimer && (clearTimeout(this.cssTimer), this.cssTimer = null), this.scrollTimer && (clearTimeout(this.scrollTimer), this.scrollTimer = null);
188
193
  }
189
194
  }
190
- const W = 1, j = 2, R = {
195
+ const W = 1, K = 2, D = {
191
196
  BASE: 0,
192
197
  SELECTED: 1,
193
198
  getCaptureLayer: (s) => 31 - s,
194
199
  HIDDEN: 31
195
- }, Te = Object.values(F.VALUES);
200
+ }, Ce = Object.values(N.VALUES);
196
201
  class Ae {
197
202
  /**
198
203
  * Calculates or retrieves the exact alphabetic baseline (in pixels) for the given font.
@@ -208,15 +213,15 @@ class Ae {
208
213
  static calculateBaselineFromDOM(e) {
209
214
  if (typeof document == "undefined")
210
215
  return 0;
211
- const t = document.createElement("div"), i = document.createElement("span"), r = document.createElement("img");
212
- t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", i.style.margin = "0", i.style.padding = "0", i.style.border = "none", i.style.lineHeight = "normal", r.width = 1, r.height = 1, r.style.verticalAlign = "baseline", i.appendChild(document.createTextNode("Hidden Text")), t.appendChild(i), t.appendChild(r), document.body.appendChild(t);
213
- const o = r.offsetTop - i.offsetTop;
216
+ const t = document.createElement("div"), r = document.createElement("span"), i = document.createElement("img");
217
+ t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", r.style.margin = "0", r.style.padding = "0", r.style.border = "none", r.style.lineHeight = "normal", i.width = 1, i.height = 1, i.style.verticalAlign = "baseline", r.appendChild(document.createTextNode("Hidden Text")), t.appendChild(r), t.appendChild(i), document.body.appendChild(t);
218
+ const o = i.offsetTop - r.offsetTop;
214
219
  return document.body.removeChild(t), o;
215
220
  }
216
221
  }
217
222
  u(Ae, "cache", /* @__PURE__ */ new Map());
218
223
  class Pe extends y.MeshBasicMaterial {
219
- constructor(t, i, r, o, n = 2) {
224
+ constructor(t, r, i, o, n = 2) {
220
225
  super({
221
226
  transparent: !0,
222
227
  side: y.FrontSide,
@@ -227,12 +232,12 @@ class Pe extends y.MeshBasicMaterial {
227
232
  u(this, "qualityFactor");
228
233
  if (this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d"), !this.ctx)
229
234
  throw new Error("[Mirage] Failed to create canvas context");
230
- this.qualityFactor = n, this.map = new y.CanvasTexture(this.canvas), this.map.colorSpace = y.LinearSRGBColorSpace, this.map.minFilter = y.LinearFilter, this.map.magFilter = y.LinearFilter, this.updateText(t, i, r, o);
235
+ this.qualityFactor = n, this.map = new y.CanvasTexture(this.canvas), this.map.colorSpace = y.LinearSRGBColorSpace, this.map.minFilter = y.LinearFilter, this.map.magFilter = y.LinearFilter, this.updateText(t, r, i, o);
231
236
  }
232
- wrapText(t, i) {
233
- const r = t.split(`
237
+ wrapText(t, r) {
238
+ const i = t.split(`
234
239
  `), o = [];
235
- return r.forEach((n) => {
240
+ return i.forEach((n) => {
236
241
  const a = n.match(/[^\s\-]+\-?|\-|\s+/g) || [];
237
242
  if (a.length === 0) {
238
243
  o.push("");
@@ -241,51 +246,54 @@ class Pe extends y.MeshBasicMaterial {
241
246
  let c = a[0];
242
247
  for (let l = 1; l < a.length; l++) {
243
248
  const d = a[l];
244
- this.ctx.measureText(c + d).width <= i + 2 ? c += d : (c && o.push(c), c = d.trimStart());
249
+ this.ctx.measureText(c + d).width <= r + 2 ? c += d : (c && o.push(c), c = d.trimStart());
245
250
  }
246
251
  c && o.push(c);
247
252
  }), o;
248
253
  }
249
- updateText(t, i, r, o, n) {
254
+ updateText(t, r, i, o, n) {
250
255
  n !== void 0 && (this.qualityFactor = n);
251
- const c = (window.devicePixelRatio || 1) * this.qualityFactor, l = r * c, d = o * c;
252
- this.canvas.width !== l || this.canvas.height !== d ? (this.canvas.width = l, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(c, 0, 0, c, 0, 0), this.ctx.font = i.font, this.ctx.fillStyle = i.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
253
- const h = this.wrapText(t, r), f = i.lineHeight, p = Ae.getBaseline(i.font);
254
- h.forEach((g, m) => {
255
- const E = m * f + p;
256
- let L = 0;
257
- i.textAlign === "center" ? L = r / 2 : i.textAlign === "right" && (L = r), this.ctx.textAlign = i.textAlign, this.ctx.fillText(g, L, E);
256
+ const c = (window.devicePixelRatio || 1) * this.qualityFactor, l = i * c, d = o * c;
257
+ this.canvas.width !== l || this.canvas.height !== d ? (this.canvas.width = l, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(c, 0, 0, c, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
258
+ const h = this.wrapText(t, i), f = r.lineHeight, p = Ae.getBaseline(r.font);
259
+ h.forEach((g, v) => {
260
+ const x = v * f + p;
261
+ let M = 0;
262
+ r.textAlign === "center" ? M = i / 2 : r.textAlign === "right" && (M = i), this.ctx.textAlign = r.textAlign, this.ctx.fillText(g, M, x);
258
263
  }), this.map && (this.map.needsUpdate = !0);
259
264
  }
260
265
  dispose() {
261
266
  this.map && this.map.dispose(), super.dispose();
262
267
  }
263
268
  }
264
- function K(s) {
265
- return typeof s == "number" ? s : parseFloat(s) || 0;
269
+ function J(s, e = 0) {
270
+ if (typeof s == "number")
271
+ return s;
272
+ const t = parseFloat(s) || 0;
273
+ return typeof s == "string" && s.includes("%") ? t / 100 * e : t;
266
274
  }
267
- function Z(s) {
275
+ function ee(s) {
268
276
  if (!s || s === "transparent")
269
277
  return { color: new y.Color(16777215), alpha: 0 };
270
278
  const e = s.match(
271
279
  /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
272
280
  );
273
281
  if (e) {
274
- const t = parseInt(e[1], 10), i = parseInt(e[2], 10), r = parseInt(e[3], 10), o = e[4] !== void 0 ? parseFloat(e[4]) : 1;
275
- return { color: new y.Color(`rgb(${t}, ${i}, ${r})`), alpha: o };
282
+ const t = parseInt(e[1], 10), r = parseInt(e[2], 10), i = parseInt(e[3], 10), o = e[4] !== void 0 ? parseFloat(e[4]) : 1;
283
+ return { color: new y.Color(`rgb(${t}, ${r}, ${i})`), alpha: o };
276
284
  }
277
285
  return { color: new y.Color(s), alpha: 1 };
278
286
  }
279
287
  function Ge(s) {
280
288
  const e = [];
281
- let t = "", i = 0;
282
- for (let r = 0; r < s.length; r++) {
283
- const o = s[r];
289
+ let t = "", r = 0;
290
+ for (let i = 0; i < s.length; i++) {
291
+ const o = s[i];
284
292
  if (o === "(")
285
- i++;
293
+ r++;
286
294
  else if (o === ")")
287
- i--;
288
- else if (o === "," && i === 0) {
295
+ r--;
296
+ else if (o === "," && r === 0) {
289
297
  e.push(t.trim()), t = "";
290
298
  continue;
291
299
  }
@@ -299,24 +307,24 @@ function $e(s) {
299
307
  const e = s.match(/linear-gradient\((.*)\)/);
300
308
  if (!e)
301
309
  return null;
302
- const t = e[1], i = Ge(t);
303
- let r = Math.PI, o = 0;
304
- const n = i[0].trim();
310
+ const t = e[1], r = Ge(t);
311
+ let i = Math.PI, o = 0;
312
+ const n = r[0].trim();
305
313
  if (n.startsWith("to "))
306
- n === "to top" ? r = 0 : n === "to right" ? r = Math.PI / 2 : n === "to bottom" ? r = Math.PI : n === "to left" ? r = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? r = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? r = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? r = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (r = Math.PI * 1.75), o = 1;
314
+ n === "to top" ? i = 0 : n === "to right" ? i = Math.PI / 2 : n === "to bottom" ? i = Math.PI : n === "to left" ? i = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? i = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? i = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? i = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (i = Math.PI * 1.75), o = 1;
307
315
  else if (n.endsWith("deg") || n.endsWith("rad") || n.endsWith("turn")) {
308
316
  const c = parseFloat(n);
309
- n.endsWith("deg") ? r = c * (Math.PI / 180) : n.endsWith("rad") ? r = c : n.endsWith("turn") && (r = c * Math.PI * 2), o = 1;
317
+ n.endsWith("deg") ? i = c * (Math.PI / 180) : n.endsWith("rad") ? i = c : n.endsWith("turn") && (i = c * Math.PI * 2), o = 1;
310
318
  }
311
319
  const a = [];
312
- for (let c = o; c < i.length && !(a.length >= 8); c++) {
313
- const l = i[c].trim(), d = l.lastIndexOf(" ");
320
+ for (let c = o; c < r.length && !(a.length >= 8); c++) {
321
+ const l = r[c].trim(), d = l.lastIndexOf(" ");
314
322
  let h = l, f = null;
315
323
  if (d !== -1 && !l.endsWith(")")) {
316
324
  const g = l.substring(d + 1);
317
325
  (g.endsWith("%") || g.endsWith("px") || !isNaN(parseFloat(g))) && (h = l.substring(0, d).trim(), f = g);
318
326
  }
319
- const p = Z(h);
327
+ const p = ee(h);
320
328
  a.push({
321
329
  color: p.color,
322
330
  alpha: p.alpha,
@@ -340,7 +348,7 @@ function $e(s) {
340
348
  c = l;
341
349
  }
342
350
  }
343
- return { angle: r, stops: a };
351
+ return { angle: i, stops: a };
344
352
  }
345
353
  const qe = `varying vec2 vUv;
346
354
  varying vec4 vScreenPos;
@@ -431,6 +439,18 @@ void main() {
431
439
  vec2 p = (vUv - 0.5) * uSize;
432
440
  vec2 halfSize = uSize * 0.5;
433
441
 
442
+ // CSS Proportional Border-Radius Clamping
443
+ float tl = uBorderRadius.x;
444
+ float tr = uBorderRadius.y;
445
+ float br = uBorderRadius.z;
446
+ float bl = uBorderRadius.w;
447
+ float fTop = uSize.x / max(tl + tr, 0.0001);
448
+ float fBottom = uSize.x / max(bl + br, 0.0001);
449
+ float fLeft = uSize.y / max(tl + bl, 0.0001);
450
+ float fRight = uSize.y / max(tr + br, 0.0001);
451
+ float f = min(1.0, min(min(fTop, fBottom), min(fLeft, fRight)));
452
+ vec4 clampedRadius = uBorderRadius * f;
453
+
434
454
  #INJECT_UV_MODIFIER
435
455
 
436
456
  // color decision pipeline
@@ -444,9 +464,8 @@ void main() {
444
464
  #INJECT_BASE_COLOR
445
465
 
446
466
  // Hybrid SDF
447
- vec2 xRadii = mix(uBorderRadius.xw, uBorderRadius.yz, step(0.0, p.x));
467
+ vec2 xRadii = mix(clampedRadius.xw, clampedRadius.yz, step(0.0, p.x));
448
468
  float r = mix(xRadii.y, xRadii.x, step(0.0, p.y));
449
- r = min(r, min(halfSize.x, halfSize.y));
450
469
 
451
470
  float d = sdRoundedBox(p, halfSize, r);
452
471
 
@@ -484,50 +503,52 @@ uniform vec2 uTextureOffset;`, Je = `vec2 screenUv = (vScreenPos.xy / vScreenPos
484
503
  vec2 resultUv = screenUv;
485
504
 
486
505
  `, Qe = `vec4 texColor = texture2D(uTexture, resultUv);
487
- baseColor = blendSrcOver(baseColor, texColor);`, Se = {
506
+ baseColor = blendSrcOver(baseColor, texColor);`, Te = {
488
507
  vertexShader: qe,
489
508
  fragmentShader: je
490
- }, ae = {
509
+ }, Se = {
491
510
  declChunk: Ke,
492
511
  uvChunk: Je,
493
512
  baseColorChunk: Qe
494
513
  };
495
- function Ze(s, e, t, i = null, r) {
496
- var M;
497
- const o = i !== null || !!s.imageSrc;
514
+ function Ze(s, e, t, r = null, i) {
515
+ var E;
516
+ const o = r !== null || !!s.imageSrc;
498
517
  let n = "";
499
518
  const a = {};
500
- if (r != null && r.uniforms)
501
- for (const [w, b] of Object.entries(r.uniforms))
502
- typeof b == "number" ? (n += `uniform float ${w};
503
- `, a[w] = { value: b }) : Array.isArray(b) ? b.length === 2 ? (n += `uniform vec2 ${w};
504
- `, a[w] = { value: new y.Vector2(...b) }) : b.length === 3 ? (n += `uniform vec3 ${w};
505
- `, a[w] = { value: new y.Vector3(...b) }) : b.length === 4 && (n += `uniform vec4 ${w};
506
- `, a[w] = { value: new y.Vector4(...b) }) : (n += `uniform float ${w};
507
- `, a[w] = { value: b });
508
- const c = (o ? ae.declChunk : "") + `
509
- ` + n, l = s.isTraveler ? ae.uvChunk : `vec2 resultUv = vUv * uTextureRepeat + uTextureOffset;
510
- `, d = o ? l + ((r == null ? void 0 : r.uvModifier) || "") : "", h = o ? ae.baseColorChunk : "", f = (r == null ? void 0 : r.colorModifier) || "", p = Se.fragmentShader.replace("#INJECT_DECLARATIONS", c).replace("#INJECT_UV_MODIFIER", d).replace("#INJECT_BASE_COLOR", h).replace("#INJECT_COLOR_MODIFIER", f), g = Z(s.backgroundColor), m = Z(s.borderColor), E = {
519
+ if (i != null && i.uniforms)
520
+ for (const [C, b] of Object.entries(i.uniforms))
521
+ typeof b == "number" ? (n += `uniform float ${C};
522
+ `, a[C] = { value: b }) : Array.isArray(b) ? b.length === 2 ? (n += `uniform vec2 ${C};
523
+ `, a[C] = { value: new y.Vector2(...b) }) : b.length === 3 ? (n += `uniform vec3 ${C};
524
+ `, a[C] = { value: new y.Vector3(...b) }) : b.length === 4 && (n += `uniform vec4 ${C};
525
+ `, a[C] = { value: new y.Vector4(...b) }) : (n += `uniform float ${C};
526
+ `, a[C] = { value: b });
527
+ const c = i !== void 0, l = (o || c ? Se.declChunk : "") + `
528
+ ` + n, d = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
529
+ `, h = s.isTraveler ? `vec2 resultUv = screenUv;
530
+ ` : `vec2 resultUv = vUv * uTextureRepeat + uTextureOffset;
531
+ `, f = o || c ? d + h + ((i == null ? void 0 : i.uvModifier) || "") : "", p = o || c ? Se.baseColorChunk : "", g = (i == null ? void 0 : i.colorModifier) || "", v = Te.fragmentShader.replace("#INJECT_DECLARATIONS", l).replace("#INJECT_UV_MODIFIER", f).replace("#INJECT_BASE_COLOR", p).replace("#INJECT_COLOR_MODIFIER", g), x = ee(s.backgroundColor), M = ee(s.borderColor), A = {
511
532
  uSize: { value: new y.Vector2(e, t) },
512
533
  uBgColor: {
513
534
  value: new y.Vector4(
514
- g.color.r,
515
- g.color.g,
516
- g.color.b,
517
- g.alpha
535
+ x.color.r,
536
+ x.color.g,
537
+ x.color.b,
538
+ x.alpha
518
539
  )
519
540
  },
520
541
  uBorderColor: {
521
542
  value: new y.Vector4(
522
- m.color.r,
523
- m.color.g,
524
- m.color.b,
525
- m.alpha
543
+ M.color.r,
544
+ M.color.g,
545
+ M.color.b,
546
+ M.alpha
526
547
  )
527
548
  },
528
549
  uBorderRadius: { value: new y.Vector4(0, 0, 0, 0) },
529
- uBorderWidth: { value: K(s.borderWidth) },
530
- uOpacity: { value: (M = s.opacity) != null ? M : 1 },
550
+ uBorderWidth: { value: J(s.borderWidth) },
551
+ uOpacity: { value: (E = s.opacity) != null ? E : 1 },
531
552
  uTexture: { value: null },
532
553
  uTextureRepeat: { value: new y.Vector2(1, 1) },
533
554
  uTextureOffset: { value: new y.Vector2(0, 0) },
@@ -538,34 +559,38 @@ function Ze(s, e, t, i = null, r) {
538
559
  },
539
560
  uGradientStops: { value: new Float32Array(8) }
540
561
  };
541
- De(E.uBorderRadius.value, s.borderRadius), o && (E.uTexture.value = i);
542
- const L = new y.ShaderMaterial({
543
- uniforms: $($({}, E), a),
544
- vertexShader: Se.vertexShader,
545
- fragmentShader: p,
562
+ De(A.uBorderRadius.value, s.borderRadius, Math.min(e, t)), o && (A.uTexture.value = r);
563
+ const S = new y.ShaderMaterial({
564
+ uniforms: $($({}, A), a),
565
+ vertexShader: Te.vertexShader,
566
+ fragmentShader: v,
546
567
  transparent: !0,
547
568
  side: y.FrontSide
548
569
  // for better performance
549
570
  });
550
- return s.backgroundImage && le(L, { backgroundImage: s.backgroundImage }), L;
571
+ return s.backgroundImage && le(S, { backgroundImage: s.backgroundImage }), S;
551
572
  }
552
- function et(s, e, t, i, r) {
553
- const o = K(e.borderWidth);
573
+ function et(s, e, t, r, i) {
574
+ const o = J(e.borderWidth);
554
575
  le(s, {
555
576
  width: t,
556
- height: i,
577
+ height: r,
557
578
  borderRadius: e.borderRadius,
558
579
  borderWidth: o,
559
580
  backgroundColor: e.backgroundColor,
560
581
  borderColor: e.borderColor,
561
582
  opacity: e.opacity,
562
- texture: r,
583
+ texture: i,
563
584
  backgroundImage: e.backgroundImage
564
585
  });
565
586
  }
566
587
  function le(s, e) {
567
- var i, r, o;
568
- if (e.width !== void 0 && e.height !== void 0 && s.uniforms.uSize.value.set(e.width, e.height), e.borderRadius !== void 0 && De(s.uniforms.uBorderRadius.value, e.borderRadius), e.borderWidth !== void 0 && (s.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
588
+ var r, i, o;
589
+ if (e.width !== void 0 && e.height !== void 0 && s.uniforms.uSize.value.set(e.width, e.height), e.borderRadius !== void 0) {
590
+ const n = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(s.uniforms.uSize.value.x, s.uniforms.uSize.value.y);
591
+ De(s.uniforms.uBorderRadius.value, e.borderRadius, n);
592
+ }
593
+ if (e.borderWidth !== void 0 && (s.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
569
594
  if (Array.isArray(e.backgroundColor)) {
570
595
  const n = s.uniforms.uBgColor.value.w;
571
596
  s.uniforms.uBgColor.value.set(
@@ -575,7 +600,7 @@ function le(s, e) {
575
600
  n
576
601
  );
577
602
  } else if (typeof e.backgroundColor == "string") {
578
- const n = Z(e.backgroundColor);
603
+ const n = ee(e.backgroundColor);
579
604
  s.uniforms.uBgColor.value.set(
580
605
  n.color.r,
581
606
  n.color.g,
@@ -601,7 +626,7 @@ function le(s, e) {
601
626
  n
602
627
  );
603
628
  } else if (typeof e.borderColor == "string") {
604
- const n = Z(e.borderColor);
629
+ const n = ee(e.borderColor);
605
630
  s.uniforms.uBorderColor.value.set(
606
631
  n.color.r,
607
632
  n.color.g,
@@ -618,9 +643,9 @@ function le(s, e) {
618
643
  );
619
644
  }
620
645
  e.opacity !== void 0 && (s.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (s.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (s.uniforms.uBorderColor.value.w = e.borderOpacity), s.uniforms.uTexture && e.texture !== void 0 && (s.uniforms.uTexture.value = e.texture);
621
- const t = e.texture !== void 0 ? e.texture : (i = s.uniforms.uTexture) == null ? void 0 : i.value;
646
+ const t = e.texture !== void 0 ? e.texture : (r = s.uniforms.uTexture) == null ? void 0 : r.value;
622
647
  if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
623
- const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, c = (r = e.width) != null ? r : s.uniforms.uSize.value.x, l = (o = e.height) != null ? o : s.uniforms.uSize.value.y;
648
+ const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, c = (i = e.width) != null ? i : s.uniforms.uSize.value.x, l = (o = e.height) != null ? o : s.uniforms.uSize.value.y;
624
649
  if (n && a && c && l) {
625
650
  const d = n / a, h = c / l;
626
651
  if (d > h) {
@@ -654,8 +679,8 @@ function le(s, e) {
654
679
  for (const n of Object.keys(e))
655
680
  n !== "width" && n !== "height" && n !== "borderRadius" && n !== "borderWidth" && n !== "backgroundColor" && n !== "borderColor" && n !== "opacity" && n !== "bgOpacity" && n !== "borderOpacity" && n !== "texture" && n !== "backgroundImage" && s.uniforms[n] !== void 0 && (s.uniforms[n].value !== void 0 && s.uniforms[n].value !== null && typeof s.uniforms[n].value.set == "function" ? Array.isArray(e[n]) ? s.uniforms[n].value.set(...e[n]) : e[n] !== void 0 && (e[n].copy ? s.uniforms[n].value.copy(e[n]) : s.uniforms[n].value = e[n]) : s.uniforms[n].value = e[n]);
656
681
  }
657
- function De(s, e) {
658
- var a, c, l, d;
682
+ function De(s, e, t = 0) {
683
+ var c, l, d, h;
659
684
  if (e == null) {
660
685
  s.set(0, 0, 0, 0);
661
686
  return;
@@ -668,36 +693,36 @@ function De(s, e) {
668
693
  s.set(e[0], e[1], e[2], e[3]);
669
694
  return;
670
695
  }
671
- const t = e.split("/")[0].trim().split(/\s+/), i = K(t[0]), r = K((a = t[1]) != null ? a : t[0]), o = K((c = t[2]) != null ? c : t[0]), n = K((d = (l = t[3]) != null ? l : t[1]) != null ? d : t[0]);
672
- s.set(i, r, o, n);
696
+ const r = e.split("/")[0].trim().split(/\s+/), i = J(r[0], t), o = J((c = r[1]) != null ? c : r[0], t), n = J((l = r[2]) != null ? l : r[0], t), a = J((h = (d = r[3]) != null ? d : r[1]) != null ? h : r[0], t);
697
+ s.set(i, o, n, a);
673
698
  }
674
- const N = {
675
- create(s, e, t, i, r, o = 2, n = null, a) {
699
+ const z = {
700
+ create(s, e, t, r, i, o = 2, n = null, a) {
676
701
  return s === "BOX" ? Ze(
677
702
  e,
678
- i,
679
703
  r,
704
+ i,
680
705
  n,
681
706
  a
682
707
  ) : s === "TEXT" ? new Pe(
683
708
  t || "",
684
709
  e,
685
- i,
686
710
  r,
711
+ i,
687
712
  o
688
713
  ) : new y.MeshBasicMaterial({ visible: !1 });
689
714
  },
690
- update(s, e, t, i, r, o, n = 2, a) {
715
+ update(s, e, t, r, i, o, n = 2, a) {
691
716
  e === "BOX" ? et(
692
717
  s,
693
718
  t,
694
- r,
719
+ i,
695
720
  o,
696
721
  a
697
722
  ) : e === "TEXT" && s.updateText(
698
- i || "",
723
+ r || "",
699
724
  t,
700
- r,
725
+ i,
701
726
  o,
702
727
  n
703
728
  );
@@ -714,10 +739,10 @@ class tt {
714
739
  u(this, "elementUrls", /* @__PURE__ */ new WeakMap());
715
740
  u(this, "onUpdate");
716
741
  this.onUpdate = e, t && (this.observer = new IntersectionObserver(
717
- (i) => {
718
- for (const r of i) {
719
- const o = r.target;
720
- r.isIntersecting ? this.loadTexture(o) : this.disposeTexture(o);
742
+ (r) => {
743
+ for (const i of r) {
744
+ const o = i.target;
745
+ i.isIntersecting ? this.loadTexture(o) : this.disposeTexture(o);
721
746
  }
722
747
  },
723
748
  { rootMargin: "300px" }
@@ -732,31 +757,31 @@ class tt {
732
757
  e.nodeType === Node.ELEMENT_NODE && this.observer && this.observer.unobserve(e), this.disposeTexture(e), this.elementUrls.delete(e), this.loadStatus.delete(e);
733
758
  }
734
759
  loadTexture(e) {
735
- return Ee(this, null, function* () {
760
+ return we(this, null, function* () {
736
761
  if (this.loadStatus.get(e) || this.textures.has(e))
737
762
  return;
738
763
  const t = this.elementUrls.get(e);
739
764
  if (t) {
740
765
  this.loadStatus.set(e, !0);
741
766
  try {
742
- let i;
767
+ let r;
743
768
  if (t.startsWith("data:image/svg+xml"))
744
- i = yield new Promise((o, n) => {
769
+ r = yield new Promise((o, n) => {
745
770
  const a = new Image();
746
771
  a.onload = () => o(a), a.onerror = n, a.src = t;
747
772
  });
748
773
  else {
749
774
  const n = yield (yield fetch(t)).blob();
750
- i = yield createImageBitmap(n, { imageOrientation: "flipY" });
775
+ r = yield createImageBitmap(n, { imageOrientation: "flipY" });
751
776
  }
752
777
  if (this.elementUrls.get(e) !== t) {
753
- "close" in i && i.close();
778
+ "close" in r && r.close();
754
779
  return;
755
780
  }
756
- const r = new y.Texture(i);
757
- i instanceof HTMLImageElement || (r.flipY = !1), r.colorSpace = y.LinearSRGBColorSpace, r.needsUpdate = !0, this.textures.set(e, r), this.onUpdate(e, r);
758
- } catch (i) {
759
- console.warn("[MirageEngine] Failed to load texture:", t, i);
781
+ const i = new y.Texture(r);
782
+ r instanceof HTMLImageElement || (i.flipY = !1), i.colorSpace = y.LinearSRGBColorSpace, i.needsUpdate = !0, this.textures.set(e, i), this.onUpdate(e, i);
783
+ } catch (r) {
784
+ console.warn("[MirageEngine] Failed to load texture:", t, r);
760
785
  } finally {
761
786
  this.elementUrls.has(e) && this.loadStatus.set(e, !1);
762
787
  }
@@ -775,7 +800,7 @@ class tt {
775
800
  }
776
801
  }
777
802
  class rt {
778
- constructor(e, t, i, r) {
803
+ constructor(e, t, r, i) {
779
804
  u(this, "canvas");
780
805
  u(this, "scene");
781
806
  u(this, "camera");
@@ -793,16 +818,16 @@ class rt {
793
818
  u(this, "registry");
794
819
  u(this, "targetRect");
795
820
  u(this, "travelersByLayer", Array.from(
796
- { length: I.MAX_LAYERS },
821
+ { length: U.MAX_LAYERS },
797
822
  () => /* @__PURE__ */ new Set()
798
823
  ));
799
824
  u(this, "textureManager");
800
825
  // private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
801
826
  u(this, "fixedMeshes", /* @__PURE__ */ new Set());
802
827
  var a, c, l, d, h;
803
- this.target = e, this.mountContainer = i, this.registry = r, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (c = t.canvasSize) != null ? c : "viewport", this.clipArea = (l = t.travelerClipArea) != null ? l : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new tt((f, p) => {
828
+ this.target = e, this.mountContainer = r, this.registry = i, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (c = t.canvasSize) != null ? c : "viewport", this.clipArea = (l = t.travelerClipArea) != null ? l : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new tt((f, p) => {
804
829
  const g = this.registry.get(f);
805
- g && g.material instanceof y.ShaderMaterial && N.forceUpdateUniforms(g.material, { texture: p });
830
+ g && g.material instanceof y.ShaderMaterial && z.forceUpdateUniforms(g.material, { texture: p });
806
831
  }, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new y.Scene(), this.targetRect = this.target.getBoundingClientRect();
807
832
  const o = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
808
833
  this.camera = new y.OrthographicCamera(
@@ -824,15 +849,15 @@ class rt {
824
849
  return this.mode === "overlay" && this.canvasSize === "viewport";
825
850
  }
826
851
  getSceneLayer() {
827
- return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? R.SELECTED : R.BASE;
852
+ return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? D.SELECTED : D.BASE;
828
853
  }
829
854
  createRenderTarget() {
830
- for (let e = 0; e < I.MAX_LAYERS; e++) {
831
- const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, i = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
855
+ for (let e = 0; e < U.MAX_LAYERS; e++) {
856
+ const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, r = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
832
857
  this.renderTargets.push(
833
858
  new y.WebGLRenderTarget(
834
859
  t * this.qualityFactor,
835
- i * this.qualityFactor,
860
+ r * this.qualityFactor,
836
861
  {
837
862
  minFilter: y.LinearFilter,
838
863
  magFilter: y.LinearFilter,
@@ -872,15 +897,15 @@ class rt {
872
897
  this.canvas.style.width = `${e}px`, this.canvas.style.height = `${t}px`, this.mode === "duplicate" ? (this.canvas.style.position = "", this.canvas.style.top = "", this.canvas.style.left = "", this.canvas.style.display = "block") : (this.canvas.style.position = this.isViewport ? "fixed" : "absolute", this.canvas.style.top = this.isViewport ? `-${this.overscan}px` : `${this.target.offsetTop}px`, this.canvas.style.left = this.isViewport ? `-${this.overscan}px` : `${this.target.offsetLeft}px`, this.canvas.style.display = "block");
873
898
  }
874
899
  updateUniforms(e, t) {
875
- const i = this.registry.get(e);
876
- i && (i.traverse((r) => {
877
- r.isMesh && r.material && N.forceUpdateUniforms(
878
- r.material,
900
+ const r = this.registry.get(e);
901
+ r && (r.traverse((i) => {
902
+ i.isMesh && i.material && z.forceUpdateUniforms(
903
+ i.material,
879
904
  t
880
905
  );
881
- }), i.userData.nativeMesh && i.userData.nativeMesh.traverse((r) => {
882
- r.isMesh && r.material && N.forceUpdateUniforms(
883
- r.material,
906
+ }), r.userData.nativeMesh && r.userData.nativeMesh.traverse((i) => {
907
+ i.isMesh && i.material && z.forceUpdateUniforms(
908
+ i.material,
884
909
  t
885
910
  );
886
911
  }));
@@ -890,13 +915,13 @@ class rt {
890
915
  }
891
916
  setSize(e, t) {
892
917
  this.renderer.setSize(e, t);
893
- for (const i of this.renderTargets)
894
- i.setSize(e * this.qualityFactor, t * this.qualityFactor);
918
+ for (const r of this.renderTargets)
919
+ r.setSize(e * this.qualityFactor, t * this.qualityFactor);
895
920
  this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
896
921
  }
897
922
  syncScene(e, t) {
898
- const i = this.target.getBoundingClientRect(), r = this.isViewport ? window.innerWidth + this.overscan * 2 : i.width, o = this.isViewport ? window.innerHeight + this.overscan * 2 : i.height, n = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, c = Math.abs(r - n) > 0.1 || Math.abs(o - a) > 0.1, l = this.mode === "overlay" && (Math.abs(i.top - this.targetRect.top) > 0.1 || Math.abs(i.left - this.targetRect.left) > 0.1);
899
- c ? (this.targetRect = i, this.setSize(r, o), this.updateCanvasLayout()) : l ? (this.targetRect = i, this.updateCanvasLayout()) : this.targetRect = i, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
923
+ const r = this.target.getBoundingClientRect(), i = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, o = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, n = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, c = Math.abs(i - n) > 0.1 || Math.abs(o - a) > 0.1, l = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
924
+ c ? (this.targetRect = r, this.setSize(i, o), this.updateCanvasLayout()) : l ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
900
925
  const h = this.registry.get(d);
901
926
  if (h) {
902
927
  this.scene.remove(h);
@@ -915,11 +940,11 @@ class rt {
915
940
  // => 이후 activeElements를 이용하여 mesh를 정리!!!+ map에서도 삭제
916
941
  // private reconcileNode(node: SceneNode, activeElements: Set<HTMLElement>) {
917
942
  reconcileNode(e) {
918
- var r;
943
+ var i;
919
944
  let t = this.registry.get(e.element);
920
- const i = JSON.stringify(e.shaderHooks || null);
921
- if (t && t.userData.shaderHash !== i && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof y.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
922
- const o = new y.PlaneGeometry(1, 1), n = e.isTraveler ? (r = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : r.texture : this.textureManager.get(e.element), a = N.create(
945
+ const r = JSON.stringify(e.shaderHooks || null);
946
+ if (t && t.userData.shaderHash !== r && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof y.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
947
+ const o = new y.PlaneGeometry(1, 1), n = e.isTraveler ? (i = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : i.texture : this.textureManager.get(e.element), a = z.create(
923
948
  "BOX",
924
949
  e.styles,
925
950
  "",
@@ -929,10 +954,10 @@ class rt {
929
954
  n,
930
955
  e.shaderHooks
931
956
  );
932
- t = new y.Mesh(o, a), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = a, t.userData.domElement = e.element, t.userData.shaderHash = i;
957
+ t = new y.Mesh(o, a), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = a, t.userData.domElement = e.element, t.userData.shaderHash = r;
933
958
  }
934
959
  if (this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
935
- for (let o = 0; o < I.MAX_LAYERS; o++)
960
+ for (let o = 0; o < U.MAX_LAYERS; o++)
936
961
  o === e.captureLayer - 2 ? this.travelersByLayer[o].add(t) : this.travelersByLayer[o].delete(t);
937
962
  else
938
963
  for (const o of this.travelersByLayer)
@@ -947,184 +972,186 @@ class rt {
947
972
  !0
948
973
  ));
949
974
  }
950
- reconcileTextChild(e, t, i) {
975
+ reconcileTextChild(e, t, r) {
951
976
  var l;
952
- const r = t.textLines || [
977
+ const i = t.textLines || [
953
978
  { text: t.textContent || "", rect: t.rect }
954
- ], o = i ? t.nativeStyles : t.textStyles, n = JSON.stringify(o) + t.textContent + r.map((d) => d.text).join("|"), a = (l = e.userData) == null ? void 0 : l.textChildStyleHash;
979
+ ], o = r ? t.nativeStyles : t.textStyles, n = JSON.stringify(o) + t.textContent + i.map((d) => d.text).join("|"), a = (l = e.userData) == null ? void 0 : l.textChildStyleHash;
955
980
  if (t.dirtyMask & ce || n !== a) {
956
981
  e.children.filter(
957
982
  (g) => g.name.startsWith("TEXT_CHILD")
958
983
  ).forEach((g) => {
959
- var E;
960
- const m = g;
961
- (E = m.material.map) == null || E.dispose(), m.geometry.dispose(), e.remove(m);
984
+ var x;
985
+ const v = g;
986
+ (x = v.material.map) == null || x.dispose(), v.geometry.dispose(), e.remove(v);
962
987
  });
963
988
  const h = t.rect, f = h.x + h.width / 2, p = h.y + h.height / 2;
964
- r.forEach((g, m) => {
965
- const E = N.create(
989
+ i.forEach((g, v) => {
990
+ const x = z.create(
966
991
  "TEXT",
967
992
  o,
968
993
  g.text,
969
994
  g.rect.width,
970
995
  g.rect.height,
971
996
  this.qualityFactor
972
- ), L = new y.PlaneGeometry(1, 1), M = new y.Mesh(L, E);
973
- M.name = `TEXT_CHILD_${m}`;
974
- const w = t.rect.width === 0 ? 1 : g.rect.width / t.rect.width, b = t.rect.height === 0 ? 1 : g.rect.height / t.rect.height;
975
- M.scale.set(w, b, 1);
976
- const U = g.rect.x + g.rect.width / 2, A = g.rect.y + g.rect.height / 2, O = U - f, z = -(A - p);
977
- M.position.set(
997
+ ), M = new y.PlaneGeometry(1, 1), A = new y.Mesh(M, x);
998
+ A.name = `TEXT_CHILD_${v}`;
999
+ const S = t.rect.width === 0 ? 1 : g.rect.width / t.rect.width, E = t.rect.height === 0 ? 1 : g.rect.height / t.rect.height;
1000
+ A.scale.set(S, E, 1);
1001
+ const C = g.rect.x + g.rect.width / 2, b = g.rect.y + g.rect.height / 2, O = C - f, X = -(b - p);
1002
+ A.position.set(
978
1003
  t.rect.width === 0 ? 0 : O / t.rect.width,
979
- t.rect.height === 0 ? 0 : z / t.rect.height,
1004
+ t.rect.height === 0 ? 0 : X / t.rect.height,
980
1005
  5e-3
981
- ), e.add(M);
1006
+ ), e.add(A);
982
1007
  }), e.userData.textChildStyleHash = n;
983
1008
  }
984
1009
  e.children.forEach((d) => {
985
1010
  if (!d.name.startsWith("TEXT_CHILD"))
986
1011
  return;
987
- const h = d, f = t.visibility & W ? R.BASE : R.HIDDEN;
988
- if (h.layers.set(f), t.visibility & j && h.layers.enable(R.SELECTED), t.visibility & W)
989
- if (!i && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
1012
+ const h = d, f = t.visibility & W ? D.BASE : D.HIDDEN;
1013
+ if (h.layers.set(f), t.visibility & K && h.layers.enable(D.SELECTED), t.visibility & W)
1014
+ if (!r && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
990
1015
  for (let p = t.captureLayer; p < t.nativeLayer; p++)
991
- h.layers.enable(R.getCaptureLayer(p));
992
- else if (i && t.nativeLayer !== void 0)
993
- for (let p = Math.max(t.captureLayer, t.nativeLayer); p <= I.MAX_LAYERS + 1; p++)
994
- h.layers.enable(R.getCaptureLayer(p));
1016
+ h.layers.enable(D.getCaptureLayer(p));
1017
+ else if (r && t.nativeLayer !== void 0)
1018
+ for (let p = Math.max(t.captureLayer, t.nativeLayer); p <= U.MAX_LAYERS + 1; p++)
1019
+ h.layers.enable(D.getCaptureLayer(p));
995
1020
  else
996
- for (let p = t.captureLayer; p <= I.MAX_LAYERS + 1; p++)
997
- h.layers.enable(R.getCaptureLayer(p));
1021
+ for (let p = t.captureLayer; p <= U.MAX_LAYERS + 1; p++)
1022
+ h.layers.enable(D.getCaptureLayer(p));
998
1023
  });
999
1024
  }
1000
1025
  updateMeshProperties(e, t) {
1001
- var w, b, U;
1002
- const { rect: i, styles: r } = t, o = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / o, a = this.renderer.domElement.height / o;
1003
- e.material = e.userData.baseMaterial, e.scale.set(i.width, i.height, 1), e.userData.domRect = {
1004
- x: i.x,
1005
- y: i.y,
1006
- width: i.width,
1007
- height: i.height
1026
+ var S, E, C;
1027
+ const { rect: r, styles: i } = t, o = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / o, a = this.renderer.domElement.height / o;
1028
+ e.material = e.userData.baseMaterial, e.scale.set(r.width, r.height, 1), e.userData.domRect = {
1029
+ x: r.x,
1030
+ y: r.y,
1031
+ width: r.width,
1032
+ height: r.height
1008
1033
  };
1009
1034
  const c = 1e-3;
1010
1035
  this.renderOrder++;
1011
1036
  const l = this.targetRect.left + window.scrollX, d = this.targetRect.top + window.scrollY;
1012
1037
  let h, f;
1013
1038
  if (this.isViewport)
1014
- h = i.x - window.innerWidth / 2 + i.width / 2, f = -i.y + window.innerHeight / 2 - i.height / 2;
1039
+ h = r.x - window.innerWidth / 2 + r.width / 2, f = -r.y + window.innerHeight / 2 - r.height / 2;
1015
1040
  else {
1016
- const A = i.x - l, O = i.y - d;
1017
- h = A - n / 2 + i.width / 2, f = -O + a / 2 - i.height / 2;
1041
+ const b = r.x - l, O = r.y - d;
1042
+ h = b - n / 2 + r.width / 2, f = -O + a / 2 - r.height / 2;
1018
1043
  }
1019
1044
  e.position.set(
1020
1045
  h,
1021
1046
  f,
1022
- r.zIndex + this.renderOrder * c
1047
+ i.zIndex + this.renderOrder * c
1023
1048
  );
1024
- const p = i.x, g = i.y;
1025
- e.userData.basePosition = { x: h, y: f }, e.userData.originalBasePosition = { x: h, y: f }, e.userData.baseSize = { width: i.width, height: i.height }, e.userData.baseDOM = { x: p, y: g }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
1026
- const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, E = window.getComputedStyle(m);
1027
- let L = 0, M = 0;
1028
- if (E.transform && E.transform !== "none") {
1029
- const A = new DOMMatrix(E.transform);
1030
- L = A.m41, M = A.m42;
1049
+ const p = r.x, g = r.y;
1050
+ e.userData.basePosition = { x: h, y: f }, e.userData.originalBasePosition = { x: h, y: f }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: p, y: g }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
1051
+ const v = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, x = window.getComputedStyle(v);
1052
+ let M = 0, A = 0;
1053
+ if (x.transform && x.transform !== "none") {
1054
+ const b = new DOMMatrix(x.transform);
1055
+ M = b.m41, A = b.m42;
1031
1056
  }
1032
- if (e.userData.baseTransform = { x: L, y: M }, delete e.userData.originRatioX, delete e.userData.originRatioY, N.update(
1057
+ if (e.userData.baseTransform = { x: M, y: A }, delete e.userData.originRatioX, delete e.userData.originRatioY, z.update(
1033
1058
  e.userData.baseMaterial,
1034
1059
  "BOX",
1035
- r,
1060
+ i,
1036
1061
  "",
1037
- i.width,
1038
- i.height,
1062
+ r.width,
1063
+ r.height,
1039
1064
  this.qualityFactor,
1040
- t.isTraveler ? (w = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : w.texture : this.textureManager.get(t.element)
1065
+ t.isTraveler ? (S = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : S.texture : this.textureManager.get(t.element)
1041
1066
  ), t.nativeStyles && t.nativeRect) {
1042
1067
  if (!e.userData.nativeMesh) {
1043
- const k = N.create(
1068
+ const I = z.create(
1044
1069
  "BOX",
1045
1070
  t.nativeStyles,
1046
1071
  "",
1047
1072
  t.nativeRect.width,
1048
1073
  t.nativeRect.height,
1049
1074
  this.qualityFactor,
1050
- t.isTraveler ? (b = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : b.texture : this.textureManager.get(t.element),
1075
+ t.isTraveler ? (E = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : E.texture : this.textureManager.get(t.element),
1051
1076
  t.shaderHooks
1052
- ), P = new y.Mesh(e.geometry, k);
1053
- t.type === "TEXT" && (P.name = "BG_MESH"), this.scene.add(P), e.userData.nativeMesh = P;
1077
+ ), G = new y.Mesh(e.geometry, I);
1078
+ t.type === "TEXT" && (G.name = "BG_MESH"), this.scene.add(G), e.userData.nativeMesh = G;
1054
1079
  }
1055
- const A = e.userData.nativeMesh;
1056
- let O, z;
1080
+ const b = e.userData.nativeMesh;
1081
+ let O, X;
1057
1082
  if (this.isViewport)
1058
- O = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, z = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
1083
+ O = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, X = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
1059
1084
  else {
1060
- const k = t.nativeRect.x - l, P = t.nativeRect.y - d;
1061
- O = k - n / 2 + t.nativeRect.width / 2, z = -P + a / 2 - t.nativeRect.height / 2;
1085
+ const I = t.nativeRect.x - l, G = t.nativeRect.y - d;
1086
+ O = I - n / 2 + t.nativeRect.width / 2, X = -G + a / 2 - t.nativeRect.height / 2;
1062
1087
  }
1063
- A.scale.set(t.nativeRect.width, t.nativeRect.height, 1), A.position.set(
1088
+ b.scale.set(t.nativeRect.width, t.nativeRect.height, 1), b.position.set(
1064
1089
  O,
1065
- z,
1090
+ X,
1066
1091
  t.nativeStyles.zIndex + this.renderOrder * c
1067
- ), N.update(
1068
- A.material,
1092
+ ), z.update(
1093
+ b.material,
1069
1094
  "BOX",
1070
1095
  t.nativeStyles,
1071
1096
  "",
1072
1097
  t.nativeRect.width,
1073
1098
  t.nativeRect.height,
1074
1099
  this.qualityFactor,
1075
- t.isTraveler ? (U = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : U.texture : this.textureManager.get(t.element)
1100
+ t.isTraveler ? (C = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : C.texture : this.textureManager.get(t.element)
1076
1101
  );
1077
1102
  } else
1078
1103
  e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof y.Material && e.userData.nativeMesh.material.dispose(), delete e.userData.nativeMesh);
1079
1104
  }
1080
1105
  updateMeshLayers(e, t) {
1081
- const i = t.visibility & W ? R.BASE : R.HIDDEN;
1082
- if (e.layers.set(i), t.visibility & j && e.layers.enable(R.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
1083
- const r = e.userData.nativeMesh;
1084
- if (r.layers.set(R.HIDDEN), t.visibility & W) {
1106
+ const r = t.visibility & W ? D.BASE : D.HIDDEN;
1107
+ if (e.layers.set(r), t.visibility & K && e.layers.enable(D.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
1108
+ const i = e.userData.nativeMesh;
1109
+ if (i.layers.set(D.HIDDEN), t.visibility & W) {
1085
1110
  for (let o = t.captureLayer; o < t.nativeLayer; o++)
1086
- e.layers.enable(R.getCaptureLayer(o));
1087
- for (let o = Math.max(t.captureLayer, t.nativeLayer); o <= I.MAX_LAYERS + 1; o++)
1088
- r.layers.enable(R.getCaptureLayer(o));
1111
+ e.layers.enable(D.getCaptureLayer(o));
1112
+ for (let o = Math.max(t.captureLayer, t.nativeLayer); o <= U.MAX_LAYERS + 1; o++)
1113
+ i.layers.enable(D.getCaptureLayer(o));
1089
1114
  }
1090
1115
  } else if (t.visibility & W)
1091
- for (let r = t.captureLayer; r <= I.MAX_LAYERS + 1; r++)
1092
- e.layers.enable(R.getCaptureLayer(r));
1116
+ for (let i = t.captureLayer; i <= U.MAX_LAYERS + 1; i++)
1117
+ e.layers.enable(D.getCaptureLayer(i));
1093
1118
  }
1094
- captureRenderTarget(e, t, i) {
1095
- if (e.size === 0 || !i)
1119
+ captureRenderTarget(e, t, r) {
1120
+ if (e.size === 0 || !r)
1096
1121
  return;
1097
- const r = new y.Color(), o = this.renderer.getClearAlpha();
1098
- this.renderer.getClearColor(r), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(i), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
1122
+ const i = new y.Color(), o = this.renderer.getClearAlpha();
1123
+ this.renderer.getClearColor(i), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(r), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
1099
1124
  const n = new y.Vector3(), a = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, l = this.renderer.getPixelRatio();
1100
1125
  for (const d of e) {
1101
1126
  n.setFromMatrixPosition(d.matrixWorld), n.project(this.camera);
1102
1127
  const h = (n.x + 1) / 2 * a, f = (n.y + 1) / 2 * c;
1103
1128
  let p = 0, g = 1;
1104
1129
  typeof this.clipArea == "number" ? g = this.clipArea : this.clipArea.endsWith("%") ? g = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (p = parseFloat(this.clipArea));
1105
- const m = d.scale.x * g + 0.5, E = d.scale.y * g + 0.5, L = h - m / 2, M = f - E / 2, w = (L * this.qualityFactor - p) / l, b = (M * this.qualityFactor - p) / l, U = (m * this.qualityFactor + p * 2) / l, A = (E * this.qualityFactor + p * 2) / l;
1106
- this.renderer.setScissor(w, b, U, A), this.renderer.render(this.scene, this.camera);
1130
+ const v = d.scale.x * g + 0.5, x = d.scale.y * g + 0.5, M = h - v / 2, A = f - x / 2, S = (M * this.qualityFactor - p) / l, E = (A * this.qualityFactor - p) / l, C = (v * this.qualityFactor + p * 2) / l, b = (x * this.qualityFactor + p * 2) / l;
1131
+ this.renderer.setScissor(S, E, C, b), this.renderer.render(this.scene, this.camera);
1107
1132
  }
1108
- this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(r, o);
1133
+ this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i, o);
1109
1134
  }
1110
1135
  render() {
1111
- for (let e = 0; e < I.MAX_LAYERS; e++) {
1136
+ for (let e = 0; e < U.MAX_LAYERS; e++) {
1112
1137
  const t = e + 1;
1113
1138
  this.captureRenderTarget(
1114
1139
  this.travelersByLayer[e],
1115
- R.getCaptureLayer(t),
1140
+ D.getCaptureLayer(t),
1116
1141
  this.renderTargets[e]
1117
1142
  );
1118
1143
  }
1119
1144
  this.renderer.render(this.scene, this.camera);
1120
1145
  }
1121
1146
  syncMeshesByDOM() {
1122
- const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, i = this.renderer.getPixelRatio(), r = this.renderer.domElement.width / i, o = this.renderer.domElement.height / i;
1147
+ const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), i = this.renderer.domElement.width / r, o = this.renderer.domElement.height / r;
1123
1148
  this.scene.children.forEach((n) => {
1124
1149
  const a = n;
1125
1150
  if (!a.userData || !a.userData.domElement)
1126
1151
  return;
1127
1152
  const c = a.userData.domElement;
1153
+ if (!c.isConnected)
1154
+ return;
1128
1155
  let l;
1129
1156
  if (c.nodeType === Node.TEXT_NODE) {
1130
1157
  const h = document.createRange();
@@ -1144,14 +1171,14 @@ class rt {
1144
1171
  h = l.x - window.innerWidth / 2 + l.width / 2, f = -l.y + window.innerHeight / 2 - l.height / 2;
1145
1172
  else {
1146
1173
  const p = l.x - e, g = l.y - t;
1147
- h = p - r / 2 + l.width / 2, f = -g + o / 2 - l.height / 2;
1174
+ h = p - i / 2 + l.width / 2, f = -g + o / 2 - l.height / 2;
1148
1175
  }
1149
- if (a.position.setX(h), a.position.setY(f), a.scale.set(l.width, l.height, 1), a.material instanceof y.ShaderMaterial && N.forceUpdateUniforms(a.material, {
1176
+ if (a.position.setX(h), a.position.setY(f), a.scale.set(l.width, l.height, 1), a.updateMatrixWorld(), a.material instanceof y.ShaderMaterial && z.forceUpdateUniforms(a.material, {
1150
1177
  width: l.width,
1151
1178
  height: l.height
1152
1179
  }), a.userData.nativeMesh) {
1153
1180
  const p = a.userData.nativeMesh;
1154
- p.position.setX(h), p.position.setY(f), p.scale.set(l.width, l.height, 1);
1181
+ p.position.setX(h), p.position.setY(f), p.scale.set(l.width, l.height, 1), p.updateMatrixWorld();
1155
1182
  }
1156
1183
  }
1157
1184
  });
@@ -1159,31 +1186,31 @@ class rt {
1159
1186
  }
1160
1187
  function it(s) {
1161
1188
  const e = s.textContent || "", t = [];
1162
- let i = "", r = null, o = -1;
1189
+ let r = "", i = null, o = -1;
1163
1190
  const n = (l, d) => {
1164
1191
  for (let h = 0; h < l.length; h++) {
1165
1192
  const f = l[h], p = document.createRange();
1166
1193
  p.setStart(s, d + h), p.setEnd(s, d + h + 1);
1167
1194
  const g = p.getBoundingClientRect();
1168
1195
  if (g.width === 0 && g.height === 0) {
1169
- i += f;
1196
+ r += f;
1170
1197
  continue;
1171
1198
  }
1172
- o === -1 || Math.abs(g.top - o) > g.height / 2 ? (i && r && t.push({
1173
- text: i,
1199
+ o === -1 || Math.abs(g.top - o) > g.height / 2 ? (r && i && t.push({
1200
+ text: r,
1174
1201
  rect: {
1175
- left: r.left,
1176
- top: r.top,
1177
- width: r.right - r.left,
1178
- height: r.bottom - r.top
1202
+ left: i.left,
1203
+ top: i.top,
1204
+ width: i.right - i.left,
1205
+ height: i.bottom - i.top
1179
1206
  }
1180
- }), i = f, r = {
1207
+ }), r = f, i = {
1181
1208
  left: g.left,
1182
1209
  top: g.top,
1183
1210
  right: g.right,
1184
1211
  bottom: g.bottom
1185
- }, o = g.top) : (i += f, r && (r.left = Math.min(r.left, g.left), r.top = Math.min(r.top, g.top), r.right = Math.max(r.right, g.right), r.bottom = Math.max(
1186
- r.bottom,
1212
+ }, o = g.top) : (r += f, i && (i.left = Math.min(i.left, g.left), i.top = Math.min(i.top, g.top), i.right = Math.max(i.right, g.right), i.bottom = Math.max(
1213
+ i.bottom,
1187
1214
  g.bottom
1188
1215
  )));
1189
1216
  }
@@ -1198,47 +1225,47 @@ function it(s) {
1198
1225
  else {
1199
1226
  const f = h.length === 1 ? h[0] : d.getBoundingClientRect();
1200
1227
  if (f.width === 0 && f.height === 0) {
1201
- i += l, c += l.length;
1228
+ r += l, c += l.length;
1202
1229
  continue;
1203
1230
  }
1204
- o === -1 || Math.abs(f.top - o) > f.height / 2 ? (i && r && t.push({
1205
- text: i,
1231
+ o === -1 || Math.abs(f.top - o) > f.height / 2 ? (r && i && t.push({
1232
+ text: r,
1206
1233
  rect: {
1207
- left: r.left,
1208
- top: r.top,
1209
- width: r.right - r.left,
1210
- height: r.bottom - r.top
1234
+ left: i.left,
1235
+ top: i.top,
1236
+ width: i.right - i.left,
1237
+ height: i.bottom - i.top
1211
1238
  }
1212
- }), i = l, r = {
1239
+ }), r = l, i = {
1213
1240
  left: f.left,
1214
1241
  top: f.top,
1215
1242
  right: f.right,
1216
1243
  bottom: f.bottom
1217
- }, o = f.top) : (i += l, r && (r.left = Math.min(r.left, f.left), r.top = Math.min(r.top, f.top), r.right = Math.max(r.right, f.right), r.bottom = Math.max(
1218
- r.bottom,
1244
+ }, o = f.top) : (r += l, i && (i.left = Math.min(i.left, f.left), i.top = Math.min(i.top, f.top), i.right = Math.max(i.right, f.right), i.bottom = Math.max(
1245
+ i.bottom,
1219
1246
  f.bottom
1220
1247
  )));
1221
1248
  }
1222
1249
  c += l.length;
1223
1250
  }
1224
- return i && r && t.push({
1225
- text: i,
1251
+ return r && i && t.push({
1252
+ text: r,
1226
1253
  rect: {
1227
- left: r.left,
1228
- top: r.top,
1229
- width: r.right - r.left,
1230
- height: r.bottom - r.top
1254
+ left: i.left,
1255
+ top: i.top,
1256
+ width: i.right - i.left,
1257
+ height: i.bottom - i.top
1231
1258
  }
1232
1259
  }), t.filter(
1233
1260
  (l) => l.text.trim().length > 0 && l.rect.width > 0 && l.rect.height > 0
1234
1261
  );
1235
1262
  }
1236
- function Le(s) {
1263
+ function Re(s) {
1237
1264
  const e = parseFloat(s.fontSize);
1238
1265
  let t = parseFloat(s.lineHeight);
1239
1266
  isNaN(t) && (t = e * 1.2);
1240
- let i = parseFloat(s.letterSpacing);
1241
- return isNaN(i) && (i = 0), {
1267
+ let r = parseFloat(s.letterSpacing);
1268
+ return isNaN(r) && (r = 0), {
1242
1269
  font: `${s.fontStyle} ${s.fontWeight} ${s.fontSize} ${s.fontFamily}`,
1243
1270
  fontSize: s.fontSize,
1244
1271
  color: s.color,
@@ -1246,291 +1273,303 @@ function Le(s) {
1246
1273
  textBaseline: "alphabetic",
1247
1274
  direction: s.direction || "inherit",
1248
1275
  lineHeight: t,
1249
- letterSpacing: i
1276
+ letterSpacing: r
1250
1277
  };
1251
1278
  }
1252
- function ke(s, e = q | Q | Ye | ce | re, t, i = 1, r = 0, o = 2, n, a) {
1279
+ function ke(s, e = q | Z | Ye | ce | ie, t, r = 1, i = 0, o = 2, n, a) {
1253
1280
  var de, ue, fe, ge, pe, me;
1254
1281
  if (s.nodeType === Node.TEXT_NODE) {
1255
- const v = s;
1256
- if (!v.textContent || !v.textContent.trim())
1282
+ const m = s;
1283
+ if (!m.textContent || !m.textContent.trim())
1257
1284
  return null;
1258
- const C = v.textContent.replace(/\s+/g, " ");
1259
- if (C.length === 0)
1285
+ const R = m.textContent.replace(/\s+/g, " ");
1286
+ if (R.length === 0)
1260
1287
  return null;
1261
- const D = it(v);
1262
- if (D.length === 0)
1288
+ const k = it(m);
1289
+ if (k.length === 0)
1263
1290
  return null;
1264
- const B = v.parentElement, S = B ? window.getComputedStyle(B) : null;
1265
- if (!S)
1291
+ const _ = m.parentElement, L = _ ? window.getComputedStyle(_) : null;
1292
+ if (!L)
1266
1293
  return null;
1267
- const X = Math.min(...D.map((T) => T.rect.left)), x = Math.min(...D.map((T) => T.rect.top)), V = Math.max(...D.map((T) => T.rect.left + T.rect.width)), G = Math.max(...D.map((T) => T.rect.top + T.rect.height));
1294
+ const V = Math.min(...k.map((w) => w.rect.left)), B = Math.min(...k.map((w) => w.rect.top)), H = Math.max(...k.map((w) => w.rect.left + w.rect.width)), T = Math.max(...k.map((w) => w.rect.top + w.rect.height));
1268
1295
  return {
1269
1296
  id: Math.random().toString(36).substring(2, 9),
1270
1297
  type: "TEXT",
1271
- element: v,
1298
+ element: m,
1272
1299
  rect: {
1273
- x: X + window.scrollX,
1274
- y: x + window.scrollY,
1275
- width: V - X,
1276
- height: G - x
1300
+ x: V + window.scrollX,
1301
+ y: B + window.scrollY,
1302
+ width: H - V,
1303
+ height: T - B
1277
1304
  },
1278
1305
  styles: {
1279
1306
  backgroundColor: "transparent",
1280
1307
  backgroundImage: "",
1281
- opacity: B && B.dataset[H.KEY] === H.VALUES.HIDE ? 1 : parseFloat(S.opacity),
1282
- zIndex: (isNaN(parseInt(S.zIndex)) ? 0 : parseInt(S.zIndex)) + r,
1308
+ opacity: _ && _.dataset[P.KEY] === P.VALUES.HIDE ? 1 : parseFloat(L.opacity),
1309
+ zIndex: (isNaN(parseInt(L.zIndex)) ? 0 : parseInt(L.zIndex)) + i,
1283
1310
  borderRadius: "0px",
1284
1311
  borderColor: "transparent",
1285
1312
  borderWidth: "0px",
1286
1313
  isTraveler: !1
1287
1314
  },
1288
- textContent: C,
1289
- textLines: D.map((T) => ({
1290
- text: T.text.trim(),
1315
+ textContent: R,
1316
+ textLines: k.map((w) => ({
1317
+ text: w.text.trim(),
1291
1318
  rect: {
1292
- x: T.rect.left + window.scrollX,
1293
- y: T.rect.top + window.scrollY,
1294
- width: T.rect.width,
1295
- height: T.rect.height
1319
+ x: w.rect.left + window.scrollX,
1320
+ y: w.rect.top + window.scrollY,
1321
+ width: w.rect.width,
1322
+ height: w.rect.height
1296
1323
  }
1297
1324
  })),
1298
- textStyles: Le(S),
1325
+ textStyles: Re(L),
1299
1326
  dirtyMask: e,
1300
1327
  visibility: t,
1301
1328
  isTraveler: !1,
1302
- captureLayer: i,
1303
- isFixed: S.position === "fixed",
1329
+ captureLayer: r,
1330
+ isFixed: L.position === "fixed",
1304
1331
  nativeLayer: n,
1305
1332
  nativeStyles: a ? $($({
1306
1333
  backgroundColor: "transparent",
1307
1334
  backgroundImage: "",
1308
- opacity: B && B.dataset[H.KEY] === H.VALUES.HIDE ? 1 : parseFloat(S.opacity),
1309
- zIndex: (isNaN(parseInt(S.zIndex)) ? 0 : parseInt(S.zIndex)) + r,
1335
+ opacity: _ && _.dataset[P.KEY] === P.VALUES.HIDE ? 1 : parseFloat(L.opacity),
1336
+ zIndex: (isNaN(parseInt(L.zIndex)) ? 0 : parseInt(L.zIndex)) + i,
1310
1337
  borderRadius: "0px",
1311
1338
  borderColor: "transparent",
1312
1339
  borderWidth: "0px",
1313
1340
  isTraveler: !1
1314
- }, Le(S)), a) : void 0,
1341
+ }, Re(L)), a) : void 0,
1315
1342
  nativeRect: a ? {
1316
- x: X + window.scrollX,
1317
- y: x + window.scrollY,
1318
- width: V - X,
1319
- height: G - x
1343
+ x: V + window.scrollX,
1344
+ y: B + window.scrollY,
1345
+ width: H - V,
1346
+ height: T - B
1320
1347
  } : void 0,
1321
1348
  children: []
1322
1349
  };
1323
1350
  }
1324
1351
  if (s.nodeType !== Node.ELEMENT_NODE)
1325
1352
  return null;
1326
- const c = s, l = c.dataset[F.KEY];
1353
+ const c = s, l = c.dataset[N.KEY];
1327
1354
  let d = t, h = t;
1328
1355
  if (l) {
1329
- const v = new Set(l.split(/\s+/));
1330
- for (const C of v)
1331
- if (!Te.includes(C))
1356
+ const m = new Set(l.split(/\s+/));
1357
+ for (const R of m)
1358
+ if (!Ce.includes(R))
1332
1359
  throw new Error(
1333
- `[MirageEngine] Invalid filter token: '${C}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1360
+ `[MirageEngine] Invalid filter token: '${R}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1334
1361
  );
1335
- if (v.has(F.VALUES.END))
1362
+ if (m.has(N.VALUES.END))
1336
1363
  return null;
1337
- if (v.has(F.VALUES.INCLUDE_TREE) && v.has(F.VALUES.EXCLUDE_TREE))
1364
+ if (m.has(N.VALUES.INCLUDE_TREE) && m.has(N.VALUES.EXCLUDE_TREE))
1338
1365
  throw new Error(
1339
1366
  "[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
1340
1367
  );
1341
- if (v.has(F.VALUES.INCLUDE_SELF) && v.has(F.VALUES.EXCLUDE_SELF))
1368
+ if (m.has(N.VALUES.INCLUDE_SELF) && m.has(N.VALUES.EXCLUDE_SELF))
1342
1369
  throw new Error(
1343
1370
  "[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
1344
1371
  );
1345
- v.has(F.VALUES.INCLUDE_TREE) ? d = d | W : v.has(F.VALUES.EXCLUDE_TREE) && (d = d & ~W), h = d, v.has(F.VALUES.INCLUDE_SELF) ? h = h | W : v.has(F.VALUES.EXCLUDE_SELF) && (h = h & ~W);
1372
+ m.has(N.VALUES.INCLUDE_TREE) ? d = d | W : m.has(N.VALUES.EXCLUDE_TREE) && (d = d & ~W), h = d, m.has(N.VALUES.INCLUDE_SELF) ? h = h | W : m.has(N.VALUES.EXCLUDE_SELF) && (h = h & ~W);
1346
1373
  }
1347
1374
  const f = c.dataset[Y.KEY];
1348
1375
  if (f) {
1349
- const v = new Set(f.split(/\s+/));
1350
- for (const C of v)
1351
- if (!Te.includes(C))
1376
+ const m = new Set(f.split(/\s+/));
1377
+ for (const R of m)
1378
+ if (!Ce.includes(R))
1352
1379
  throw new Error(
1353
- `[MirageEngine] Invalid select token: '${C}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1380
+ `[MirageEngine] Invalid select token: '${R}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1354
1381
  );
1355
- if (v.has(Y.VALUES.END))
1382
+ if (m.has(Y.VALUES.END))
1356
1383
  return null;
1357
- if (v.has(Y.VALUES.INCLUDE_TREE) && v.has(Y.VALUES.EXCLUDE_TREE))
1384
+ if (m.has(Y.VALUES.INCLUDE_TREE) && m.has(Y.VALUES.EXCLUDE_TREE))
1358
1385
  throw new Error(
1359
1386
  "[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
1360
1387
  );
1361
- if (v.has(Y.VALUES.INCLUDE_SELF) && v.has(Y.VALUES.EXCLUDE_SELF))
1388
+ if (m.has(Y.VALUES.INCLUDE_SELF) && m.has(Y.VALUES.EXCLUDE_SELF))
1362
1389
  throw new Error(
1363
1390
  "[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
1364
1391
  );
1365
- v.has(Y.VALUES.INCLUDE_TREE) ? d = d | j : v.has(Y.VALUES.EXCLUDE_TREE) && (d = d & ~j), h = d, v.has(Y.VALUES.INCLUDE_SELF) ? h = h | j : v.has(Y.VALUES.EXCLUDE_SELF) && (h = h & ~j);
1392
+ m.has(Y.VALUES.INCLUDE_TREE) ? d = d | K : m.has(Y.VALUES.EXCLUDE_TREE) && (d = d & ~K), h = d, m.has(Y.VALUES.INCLUDE_SELF) ? h = h | K : m.has(Y.VALUES.EXCLUDE_SELF) && (h = h & ~K);
1366
1393
  }
1367
- const p = c.dataset[I.KEY];
1368
- let g = !1, m = a ? $({}, a) : {}, E = n;
1394
+ const p = c.dataset[U.KEY];
1395
+ let g = !1, v = a ? $({}, a) : {}, x = n;
1369
1396
  if (p) {
1370
- let v = 1;
1371
- const C = p.indexOf("{"), D = p.lastIndexOf("}");
1372
- let B = p;
1373
- if (C !== -1 && D !== -1 && D > C) {
1374
- B = p.substring(0, C).trim();
1375
- const x = p.substring(C, D + 1);
1397
+ let m = 1;
1398
+ const R = p.indexOf("{"), k = p.lastIndexOf("}");
1399
+ let _ = p;
1400
+ if (R !== -1 && k !== -1 && k > R) {
1401
+ _ = p.substring(0, R).trim();
1402
+ const T = p.substring(R, k + 1);
1376
1403
  try {
1377
- m = new Function("return " + x)();
1378
- } catch (V) {
1404
+ v = new Function("return " + T)();
1405
+ } catch (w) {
1379
1406
  console.warn(
1380
- `[MirageEngine] Failed to parse travel styles JSON: ${x}`
1407
+ `[MirageEngine] Failed to parse travel styles JSON: ${T}`
1381
1408
  );
1382
1409
  }
1383
1410
  }
1384
- const S = B.split(/\s+/);
1385
- let X = !1;
1386
- if (S.includes(I.VALUES.TRAVELER)) {
1387
- g = !0, X = !0;
1388
- const x = S.find((V) => !isNaN(parseInt(V, 10)));
1389
- x && (v = parseInt(x, 10));
1390
- } else if (S.includes(I.VALUES.NATIVE)) {
1391
- g = !1;
1392
- const x = S.find((V) => !isNaN(parseInt(V, 10)));
1393
- x && (E = parseInt(x, 10));
1411
+ const L = _.split(/\s+/);
1412
+ let V = !1;
1413
+ const B = L.indexOf(U.VALUES.TRAVELER);
1414
+ if (B !== -1) {
1415
+ g = !0, V = !0;
1416
+ const T = L[B + 1];
1417
+ if (T && !isNaN(parseInt(T, 10)))
1418
+ m = parseInt(T, 10);
1419
+ else {
1420
+ const w = L.find((j) => !isNaN(parseInt(j, 10)));
1421
+ w && (m = parseInt(w, 10));
1422
+ }
1423
+ }
1424
+ const H = L.indexOf(U.VALUES.NATIVE);
1425
+ if (H !== -1) {
1426
+ const T = L[H + 1];
1427
+ if (T && !isNaN(parseInt(T, 10)))
1428
+ x = parseInt(T, 10);
1429
+ else if (!g) {
1430
+ const w = L.find((j) => !isNaN(parseInt(j, 10)));
1431
+ w && (x = parseInt(w, 10));
1432
+ }
1394
1433
  }
1395
- if (X) {
1396
- const x = v + 1;
1397
- if (x < i)
1434
+ if (V) {
1435
+ const T = m + 1;
1436
+ if (T < r)
1398
1437
  throw new Error(
1399
- `[MirageEngine] Traveler layer (${v}) cannot be smaller than inherited capture layer (${i - 1}).`
1438
+ `[MirageEngine] Traveler layer (${m}) cannot be smaller than inherited capture layer (${r - 1}).`
1400
1439
  );
1401
- i = Math.min(x, I.MAX_LAYERS + 1);
1440
+ r = Math.min(T, U.MAX_LAYERS + 1);
1402
1441
  }
1403
1442
  }
1404
- const L = c.dataset[Ve.KEY];
1405
- let M;
1406
- L && (M = JSON.parse(L));
1407
- const w = c.getBoundingClientRect(), b = window.getComputedStyle(c);
1408
- if (w.width === 0 || w.height === 0 || b.display === "none")
1443
+ const M = c.dataset[Ve.KEY];
1444
+ let A;
1445
+ M && (A = JSON.parse(M));
1446
+ const S = c.getBoundingClientRect(), E = window.getComputedStyle(c);
1447
+ if (S.width === 0 || S.height === 0 || E.display === "none")
1409
1448
  return null;
1410
- let U = c.getAttribute("data-mid");
1411
- U || (U = Math.random().toString(36).substring(2, 11), c.setAttribute("data-mid", U));
1412
- const A = parseInt(b.zIndex), O = (isNaN(A) ? 0 : A) + r;
1413
- let z;
1449
+ let C = c.getAttribute("data-mid");
1450
+ C || (C = Math.random().toString(36).substring(2, 11), c.setAttribute("data-mid", C));
1451
+ const b = parseInt(E.zIndex), O = (isNaN(b) ? 0 : b) + i;
1452
+ let X;
1414
1453
  if (c.tagName === "IMG")
1415
- z = c.src;
1454
+ X = c.src;
1416
1455
  else if (c.tagName.toLowerCase() === "svg") {
1417
- const v = c.cloneNode(!0), C = m == null ? void 0 : m.color, D = m == null ? void 0 : m.fill, B = m == null ? void 0 : m.stroke, S = m == null ? void 0 : m.opacity, X = (T, ve) => {
1418
- const _ = window.getComputedStyle(T), J = ve, Oe = _.fill === _.color, Be = _.stroke === _.color, ie = D || (Oe ? C : void 0) || _.fill;
1419
- ie && ie !== "none" && (J.style.fill = ie);
1420
- const se = B || (Be ? C : void 0) || _.stroke;
1421
- se && se !== "none" && (J.style.stroke = se), _.strokeWidth && _.strokeWidth !== "0px" && (J.style.strokeWidth = _.strokeWidth);
1422
- const ye = C || _.color;
1423
- ye && (J.style.color = ye);
1424
- const ne = S || _.opacity;
1425
- ne && ne !== "1" && (J.style.opacity = ne);
1426
- for (let ee = 0; ee < T.children.length; ee++)
1427
- X(T.children[ee], ve.children[ee]);
1456
+ const m = c.cloneNode(!0), R = v == null ? void 0 : v.color, k = v == null ? void 0 : v.fill, _ = v == null ? void 0 : v.stroke, L = v == null ? void 0 : v.opacity, V = (w, j) => {
1457
+ const F = window.getComputedStyle(w), Q = j, Be = F.fill === F.color, Oe = F.stroke === F.color, se = k || (Be ? R : void 0) || F.fill;
1458
+ se && se !== "none" && (Q.style.fill = se);
1459
+ const ne = _ || (Oe ? R : void 0) || F.stroke;
1460
+ ne && ne !== "none" && (Q.style.stroke = ne), F.strokeWidth && F.strokeWidth !== "0px" && (Q.style.strokeWidth = F.strokeWidth);
1461
+ const ve = R || F.color;
1462
+ ve && (Q.style.color = ve);
1463
+ const oe = L || F.opacity;
1464
+ oe && oe !== "1" && (Q.style.opacity = oe);
1465
+ for (let te = 0; te < w.children.length; te++)
1466
+ V(w.children[te], j.children[te]);
1428
1467
  };
1429
- X(c, v);
1430
- const x = c.getBoundingClientRect(), V = window.devicePixelRatio * o;
1431
- v.hasAttribute("viewBox") || v.setAttribute("viewBox", `0 0 ${x.width} ${x.height}`), v.setAttribute("width", (x.width * V).toString()), v.setAttribute("height", (x.height * V).toString());
1432
- let G = new XMLSerializer().serializeToString(v);
1433
- G.includes("xmlns=") || (G = G.replace(
1468
+ V(c, m);
1469
+ const B = c.getBoundingClientRect(), H = window.devicePixelRatio * o;
1470
+ m.hasAttribute("viewBox") || m.setAttribute("viewBox", `0 0 ${B.width} ${B.height}`), m.setAttribute("width", (B.width * H).toString()), m.setAttribute("height", (B.height * H).toString());
1471
+ let T = new XMLSerializer().serializeToString(m);
1472
+ T.includes("xmlns=") || (T = T.replace(
1434
1473
  "<svg",
1435
1474
  '<svg xmlns="http://www.w3.org/2000/svg"'
1436
- )), z = `data:image/svg+xml;utf8,${encodeURIComponent(G)}`;
1437
- } else if (b.backgroundImage && b.backgroundImage !== "none") {
1438
- const v = b.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
1439
- v && (z = v[1]);
1440
- }
1441
- const k = {
1442
- backgroundColor: b.backgroundColor,
1443
- backgroundImage: b.backgroundImage,
1444
- opacity: c.dataset[H.KEY] === H.VALUES.HIDE ? 1 : parseFloat(b.opacity),
1475
+ )), X = `data:image/svg+xml;utf8,${encodeURIComponent(T)}`;
1476
+ } else if (E.backgroundImage && E.backgroundImage !== "none") {
1477
+ const m = E.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
1478
+ m && (X = m[1]);
1479
+ }
1480
+ const I = {
1481
+ backgroundColor: E.backgroundColor,
1482
+ backgroundImage: E.backgroundImage,
1483
+ opacity: c.dataset[P.KEY] === P.VALUES.HIDE ? 1 : parseFloat(E.opacity),
1445
1484
  zIndex: O,
1446
- borderRadius: b.borderRadius,
1447
- borderColor: b.borderColor,
1448
- borderWidth: b.borderWidth,
1449
- imageSrc: z,
1485
+ borderRadius: E.borderRadius,
1486
+ borderColor: E.borderColor,
1487
+ borderWidth: E.borderWidth,
1488
+ imageSrc: X,
1450
1489
  isTraveler: g
1451
- }, P = k;
1490
+ }, G = I;
1452
1491
  let Ie, Ue;
1453
1492
  const he = [];
1454
- return c.tagName.toLowerCase() !== "svg" && Array.from(c.childNodes).forEach((v) => {
1455
- const C = v.nodeType === Node.TEXT_NODE ? h : d, D = ke(
1456
- v,
1493
+ return c.tagName.toLowerCase() !== "svg" && Array.from(c.childNodes).forEach((m) => {
1494
+ const R = m.nodeType === Node.TEXT_NODE ? h : d, k = ke(
1495
+ m,
1457
1496
  e,
1458
- C,
1459
- i,
1497
+ R,
1498
+ r,
1460
1499
  O,
1461
1500
  o,
1462
- E,
1463
- v.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0
1501
+ m.nodeType === Node.TEXT_NODE ? x : void 0,
1502
+ m.nodeType === Node.TEXT_NODE && Object.keys(v).length > 0 ? v : void 0
1464
1503
  );
1465
- D && he.push(D);
1504
+ k && he.push(k);
1466
1505
  }), {
1467
- id: U,
1506
+ id: C,
1468
1507
  type: "BOX",
1469
1508
  element: c,
1470
1509
  rect: {
1471
- x: w.left + window.scrollX,
1472
- y: w.top + window.scrollY,
1473
- width: w.width,
1474
- height: w.height
1510
+ x: S.left + window.scrollX,
1511
+ y: S.top + window.scrollY,
1512
+ width: S.width,
1513
+ height: S.height
1475
1514
  },
1476
- styles: P,
1515
+ styles: G,
1477
1516
  textContent: Ie,
1478
1517
  textStyles: Ue,
1479
1518
  dirtyMask: e,
1480
1519
  visibility: h,
1481
1520
  isTraveler: g,
1482
- captureLayer: i,
1483
- nativeLayer: E,
1484
- nativeStyles: E !== void 0 ? we($({}, k), {
1485
- backgroundColor: (de = m.backgroundColor) != null ? de : k.backgroundColor,
1486
- backgroundImage: (ue = m.backgroundImage) != null ? ue : k.backgroundImage,
1487
- opacity: (fe = m.opacity) != null ? fe : k.opacity,
1488
- zIndex: m.zIndex !== void 0 ? m.zIndex + O : k.zIndex,
1489
- borderRadius: (ge = m.borderRadius) != null ? ge : k.borderRadius,
1490
- borderColor: (pe = m.borderColor) != null ? pe : k.borderColor,
1491
- borderWidth: (me = m.borderWidth) != null ? me : k.borderWidth,
1492
- isTraveler: k.isTraveler
1521
+ captureLayer: r,
1522
+ nativeLayer: x,
1523
+ nativeStyles: x !== void 0 ? be($({}, I), {
1524
+ backgroundColor: (de = v.backgroundColor) != null ? de : I.backgroundColor,
1525
+ backgroundImage: (ue = v.backgroundImage) != null ? ue : I.backgroundImage,
1526
+ opacity: (fe = v.opacity) != null ? fe : I.opacity,
1527
+ zIndex: v.zIndex !== void 0 ? v.zIndex + O : I.zIndex,
1528
+ borderRadius: (ge = v.borderRadius) != null ? ge : I.borderRadius,
1529
+ borderColor: (pe = v.borderColor) != null ? pe : I.borderColor,
1530
+ borderWidth: (me = v.borderWidth) != null ? me : I.borderWidth,
1531
+ isTraveler: I.isTraveler
1493
1532
  }) : void 0,
1494
- nativeRect: E !== void 0 ? {
1495
- x: m.x !== void 0 ? parseFloat(m.x) : w.left + window.scrollX,
1496
- y: m.y !== void 0 ? parseFloat(m.y) : w.top + window.scrollY,
1497
- width: m.width !== void 0 ? parseFloat(m.width) : w.width,
1498
- height: m.height !== void 0 ? parseFloat(m.height) : w.height
1533
+ nativeRect: x !== void 0 ? {
1534
+ x: v.x !== void 0 ? parseFloat(v.x) : S.left + window.scrollX,
1535
+ y: v.y !== void 0 ? parseFloat(v.y) : S.top + window.scrollY,
1536
+ width: v.width !== void 0 ? parseFloat(v.width) : S.width,
1537
+ height: v.height !== void 0 ? parseFloat(v.height) : S.height
1499
1538
  } : void 0,
1500
- isFixed: b.position === "fixed",
1539
+ isFixed: E.position === "fixed",
1501
1540
  children: he,
1502
- shaderHooks: M
1541
+ shaderHooks: A
1503
1542
  };
1504
1543
  }
1505
1544
  function st(s, e) {
1506
- e.size !== 0 && e.forEach((t, i) => {
1545
+ e.size !== 0 && e.forEach((t, r) => {
1507
1546
  var o, n, a, c;
1508
- const r = s.get(i);
1509
- !r || !r.userData.basePosition || (N.forceUpdateUniforms(r.material, {
1547
+ const i = s.get(r);
1548
+ !i || !i.userData.basePosition || (z.forceUpdateUniforms(i.material, {
1510
1549
  backgroundColor: t.backgroundColor,
1511
1550
  backgroundImage: t.backgroundImage,
1512
1551
  opacity: t.opacity,
1513
- borderRadius: (n = t.borderRadius) != null ? n : (o = r.userData.baseStyles) == null ? void 0 : o.borderRadius
1552
+ borderRadius: (n = t.borderRadius) != null ? n : (o = i.userData.baseStyles) == null ? void 0 : o.borderRadius
1514
1553
  // width and height are no longer updated here, they are updated in syncMeshesByDOM
1515
- }), r.userData.nativeMesh && N.forceUpdateUniforms(r.userData.nativeMesh.material, {
1554
+ }), i.userData.nativeMesh && z.forceUpdateUniforms(i.userData.nativeMesh.material, {
1516
1555
  backgroundColor: t.backgroundColor,
1517
1556
  backgroundImage: t.backgroundImage,
1518
1557
  opacity: t.opacity,
1519
- borderRadius: (c = t.borderRadius) != null ? c : (a = r.userData.baseStyles) == null ? void 0 : a.borderRadius
1558
+ borderRadius: (c = t.borderRadius) != null ? c : (a = i.userData.baseStyles) == null ? void 0 : a.borderRadius
1520
1559
  }));
1521
1560
  });
1522
1561
  }
1523
1562
  class nt {
1524
- constructor(e, t, i, r) {
1563
+ constructor(e, t, r, i) {
1525
1564
  u(this, "target");
1526
1565
  u(this, "renderer");
1527
1566
  u(this, "registry");
1528
1567
  u(this, "isTravelEnabled", !1);
1529
1568
  u(this, "tracker");
1530
- this.target = e, this.renderer = t, this.registry = i, this.tracker = new Me(e, {
1531
- resizeDebounce: r.resizeDebounce
1569
+ this.target = e, this.renderer = t, this.registry = r, this.tracker = new Me(e, {
1570
+ resizeDebounce: i.resizeDebounce
1532
1571
  }), this.tracker.onLayoutChange.add((o, n) => {
1533
- document.querySelector(`[${I.NAME}~='${I.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
1572
+ document.querySelector(`[${U.NAME}~='${U.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
1534
1573
  const c = ke(
1535
1574
  this.target,
1536
1575
  o,
@@ -1584,22 +1623,22 @@ class at {
1584
1623
  u(this, "syncer");
1585
1624
  u(this, "target");
1586
1625
  u(this, "registry");
1587
- var r, o, n;
1626
+ var i, o, n;
1588
1627
  if (this.target = e, this.registry = new ot(), !document.getElementById("mirage-engine-styles")) {
1589
1628
  const a = document.createElement("style");
1590
1629
  a.id = "mirage-engine-styles", a.textContent = `
1591
- [${H.NAME}="${H.VALUES.HIDE}"] {
1630
+ [${P.NAME}="${P.VALUES.HIDE}"] {
1592
1631
  opacity: 0 !important;
1593
1632
  }
1594
1633
  `, document.head.appendChild(a);
1595
1634
  }
1596
- let i;
1597
- if (t.mode === "duplicate" ? i = (o = (r = t.container) != null ? r : this.target.parentElement) != null ? o : void 0 : i = (n = this.target.parentElement) != null ? n : void 0, !i)
1635
+ let r;
1636
+ if (t.mode === "duplicate" ? r = (o = (i = t.container) != null ? i : this.target.parentElement) != null ? o : void 0 : r = (n = this.target.parentElement) != null ? n : void 0, !r)
1598
1637
  throw new Error("[Mirage] Cannot find a container (parent or option).");
1599
1638
  this.renderer = new rt(
1600
1639
  this.target,
1601
1640
  t,
1602
- i,
1641
+ r,
1603
1642
  this.registry
1604
1643
  ), this.renderer.mount(), this.syncer = new nt(this.target, this.renderer, this.registry, t);
1605
1644
  }
@@ -1638,10 +1677,10 @@ class at {
1638
1677
  }), window.addEventListener("keyup", (o) => {
1639
1678
  t[o.key] !== void 0 && (t[o.key] = !1);
1640
1679
  });
1641
- const i = 2, r = () => {
1642
- requestAnimationFrame(r), t.ArrowRight && e.position.setX(e.position.x + i), t.ArrowLeft && e.position.setX(e.position.x - i), t.ArrowUp && e.position.setY(e.position.y + i), t.ArrowDown && e.position.setY(e.position.y - i);
1680
+ const r = 2, i = () => {
1681
+ requestAnimationFrame(i), t.ArrowRight && e.position.setX(e.position.x + r), t.ArrowLeft && e.position.setX(e.position.x - r), t.ArrowUp && e.position.setY(e.position.y + r), t.ArrowDown && e.position.setY(e.position.y - r);
1643
1682
  };
1644
- r();
1683
+ i();
1645
1684
  }
1646
1685
  }
1647
1686
  class ct {
@@ -1683,24 +1722,24 @@ class ct {
1683
1722
  const e = document.querySelectorAll(this.frontSelector);
1684
1723
  this.frontLayer && e.forEach((t) => {
1685
1724
  var n;
1686
- const i = t.getBoundingClientRect(), r = window.getComputedStyle(t), o = document.createElement("div");
1725
+ const r = t.getBoundingClientRect(), i = window.getComputedStyle(t), o = document.createElement("div");
1687
1726
  o.className = "sand-placeholder", Object.assign(o.style, {
1688
- display: r.display === "inline" ? "inline-block" : r.display,
1689
- width: `${i.width}px`,
1690
- height: `${i.height}px`,
1727
+ display: i.display === "inline" ? "inline-block" : i.display,
1728
+ width: `${r.width}px`,
1729
+ height: `${r.height}px`,
1691
1730
  boxSizing: "border-box",
1692
- marginTop: r.marginTop,
1693
- marginBottom: r.marginBottom,
1694
- marginLeft: r.marginLeft,
1695
- marginRight: r.marginRight,
1731
+ marginTop: i.marginTop,
1732
+ marginBottom: i.marginBottom,
1733
+ marginLeft: i.marginLeft,
1734
+ marginRight: i.marginRight,
1696
1735
  visibility: "hidden",
1697
1736
  pointerEvents: "none"
1698
1737
  }), (n = t.parentNode) == null || n.insertBefore(o, t), this.frontLayer.appendChild(t), Object.assign(t.style, {
1699
1738
  position: "fixed",
1700
1739
  margin: "0",
1701
1740
  boxSizing: "border-box",
1702
- width: `${i.width}px`,
1703
- height: `${i.height}px`,
1741
+ width: `${r.width}px`,
1742
+ height: `${r.height}px`,
1704
1743
  pointerEvents: "auto"
1705
1744
  }), this.items.push({ placeholder: o, original: t });
1706
1745
  });
@@ -1708,9 +1747,9 @@ class ct {
1708
1747
  setupHooks() {
1709
1748
  this.tracker && this.tracker.onBeforeRender.add(() => {
1710
1749
  const e = this.items.map(({ placeholder: t }) => t.getBoundingClientRect());
1711
- this.items.forEach(({ original: t }, i) => {
1712
- const r = e[i];
1713
- t.style.top = `${r.top}px`, t.style.left = `${r.left}px`, t.style.width = `${r.width}px`, t.style.height = `${r.height}px`;
1750
+ this.items.forEach(({ original: t }, r) => {
1751
+ const i = e[r];
1752
+ t.style.top = `${i.top}px`, t.style.left = `${i.left}px`, t.style.width = `${i.width}px`, t.style.height = `${i.height}px`;
1714
1753
  });
1715
1754
  });
1716
1755
  }
@@ -1722,9 +1761,9 @@ class ht {
1722
1761
  if (!e)
1723
1762
  throw new Error("[Mirage] Target element is required.");
1724
1763
  if (this._engine = new at(e, t), t.sandwich !== !1) {
1725
- const i = typeof t.sandwich == "object" ? t.sandwich : {};
1764
+ const r = typeof t.sandwich == "object" ? t.sandwich : {};
1726
1765
  this._sandwich = new ct({
1727
- frontSelector: i.frontSelector || `[${Ce.NAME}='${Ce.VALUES.FRONT}']`
1766
+ frontSelector: r.frontSelector || `[${Ee.NAME}='${Ee.VALUES.FRONT}']`
1728
1767
  }), this._sandwich.useTracker(this._engine.getTracker());
1729
1768
  }
1730
1769
  }