mirage-engine 0.3.13 → 0.3.14

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,13 +1,13 @@
1
1
  var Oe = Object.defineProperty, _e = Object.defineProperties;
2
2
  var Ne = Object.getOwnPropertyDescriptors;
3
3
  var we = Object.getOwnPropertySymbols;
4
- var ze = Object.prototype.hasOwnProperty, Xe = Object.prototype.propertyIsEnumerable;
5
- var me = (s, e, t) => e in s ? Oe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, j = (s, e) => {
4
+ var Xe = Object.prototype.hasOwnProperty, ze = Object.prototype.propertyIsEnumerable;
5
+ var me = (s, e, t) => e in s ? Oe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, J = (s, e) => {
6
6
  for (var t in e || (e = {}))
7
- ze.call(e, t) && me(s, t, e[t]);
7
+ Xe.call(e, t) && me(s, t, e[t]);
8
8
  if (we)
9
9
  for (var t of we(e))
10
- Xe.call(e, t) && me(s, t, e[t]);
10
+ ze.call(e, t) && me(s, t, e[t]);
11
11
  return s;
12
12
  }, xe = (s, e) => _e(s, Ne(e));
13
13
  var u = (s, e, t) => (me(s, typeof e != "symbol" ? e + "" : e, t), t);
@@ -34,7 +34,7 @@ const Ae = {
34
34
  INCLUDE_SELF: "include-self",
35
35
  EXCLUDE_SELF: "exclude-self",
36
36
  END: "end"
37
- }, q = {
37
+ }, K = {
38
38
  NAME: "data-mirage-dom",
39
39
  KEY: "mirageDom",
40
40
  VALUES: {
@@ -59,11 +59,11 @@ const Ae = {
59
59
  KEY: "mirageTravel",
60
60
  VALUES: Ce,
61
61
  MAX_LAYERS: Object.keys(Ce).length - 1
62
- }, V = {
62
+ }, W = {
63
63
  NAME: "data-mirage-filter",
64
64
  KEY: "mirageFilter",
65
65
  VALUES: Ae
66
- }, P = {
66
+ }, G = {
67
67
  NAME: "data-mirage-select",
68
68
  KEY: "mirageSelect",
69
69
  VALUES: Ae
@@ -76,7 +76,7 @@ const Ae = {
76
76
  VALUES: {
77
77
  FRONT: "front"
78
78
  }
79
- }, de = 0, K = 1, ce = 2, Ye = 4, ue = 8, ve = 16;
79
+ }, de = 0, Q = 1, ce = 2, Ye = 4, ue = 8, ve = 16;
80
80
  function We(s) {
81
81
  const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
82
82
  return e ? {
@@ -120,7 +120,7 @@ class De {
120
120
  u(this, "onScrollChange", /* @__PURE__ */ new Set());
121
121
  u(this, "onRender", /* @__PURE__ */ new Set());
122
122
  u(this, "onTransitionFinished", (e) => {
123
- this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= K | ce, 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 | ce, this.cssTimer = window.setTimeout(() => {
124
124
  this.isDomDirty = !0, this.cssTimer = null;
125
125
  }, 50)));
126
126
  });
@@ -139,7 +139,7 @@ class De {
139
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 = de);
140
140
  const e = window.scrollX, t = window.scrollY;
141
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(() => {
142
- this.pendingMask |= K, this.isDomDirty = !0, this.scrollTimer = null;
142
+ this.pendingMask |= Q, this.isDomDirty = !0, this.scrollTimer = null;
143
143
  }, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
144
144
  });
145
145
  var i, l;
@@ -159,13 +159,13 @@ class De {
159
159
  });
160
160
  else if (o.type === "attributes")
161
161
  if (o.attributeName === "style") {
162
- a |= K | ce;
162
+ a |= Q | ce;
163
163
  const c = o.target, d = He(c.style);
164
164
  this.pendingStyles.set(c, d);
165
165
  } else
166
- o.attributeName === "class" ? a |= K | ce : o.attributeName && o.attributeName.startsWith("data-") && (a |= K | ce, o.attributeName.startsWith("data-mirage") && (a |= ue));
166
+ o.attributeName === "class" ? a |= Q | ce : o.attributeName && o.attributeName.startsWith("data-") && (a |= Q | ce, o.attributeName.startsWith("data-mirage") && (a |= ue));
167
167
  else
168
- o.type === "characterData" && (a |= ve | K);
168
+ o.type === "characterData" && (a |= ve | Q);
169
169
  if (a !== de) {
170
170
  if (this.pendingMask |= a, a & ue) {
171
171
  this.clearTimers(), this.isDomDirty = !0;
@@ -192,12 +192,12 @@ class De {
192
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);
193
193
  }
194
194
  }
195
- const W = 1, te = 2, B = {
195
+ const H = 1, ie = 2, I = {
196
196
  BASE: 0,
197
197
  SELECTED: 1,
198
198
  getCaptureLayer: (s) => 31 - s,
199
199
  HIDDEN: 31
200
- }, Te = Object.values(V.VALUES);
200
+ }, Te = Object.values(W.VALUES);
201
201
  class ke {
202
202
  /**
203
203
  * Calculates or retrieves the exact alphabetic baseline (in pixels) for the given font.
@@ -257,16 +257,16 @@ class Pe extends y.MeshBasicMaterial {
257
257
  this.canvas.width !== c || this.canvas.height !== d ? (this.canvas.width = c, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(o, 0, 0, o, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
258
258
  const h = this.wrapText(t, i), g = r.lineHeight, v = ke.getBaseline(r.font);
259
259
  h.forEach((p, m) => {
260
- const w = m * g + v;
261
- let L = 0;
262
- r.textAlign === "center" ? L = i / 2 : r.textAlign === "right" && (L = i), this.ctx.textAlign = r.textAlign, this.ctx.fillText(p, L, w);
260
+ const E = m * g + v;
261
+ let M = 0;
262
+ r.textAlign === "center" ? M = i / 2 : r.textAlign === "right" && (M = i), this.ctx.textAlign = r.textAlign, this.ctx.fillText(p, M, E);
263
263
  }), this.map && (this.map.needsUpdate = !0);
264
264
  }
265
265
  dispose() {
266
266
  this.map && this.map.dispose(), super.dispose();
267
267
  }
268
268
  }
269
- function re(s, e = 0) {
269
+ function se(s, e = 0) {
270
270
  if (typeof s == "number")
271
271
  return s;
272
272
  const t = parseFloat(s) || 0;
@@ -512,43 +512,43 @@ baseColor = blendSrcOver(baseColor, texColor);`, Re = {
512
512
  baseColorChunk: Qe
513
513
  };
514
514
  function Ze(s, e, t, r = null, i) {
515
- var E;
515
+ var C;
516
516
  const l = r !== null || !!s.imageSrc;
517
517
  let n = "";
518
518
  const a = {};
519
519
  if (i != null && i.uniforms)
520
- for (const [S, x] of Object.entries(i.uniforms))
521
- typeof x == "number" ? (n += `uniform float ${S};
522
- `, a[S] = { value: x }) : Array.isArray(x) ? x.length === 2 ? (n += `uniform vec2 ${S};
523
- `, a[S] = { value: new y.Vector2(...x) }) : x.length === 3 ? (n += `uniform vec3 ${S};
524
- `, a[S] = { value: new y.Vector3(...x) }) : x.length === 4 && (n += `uniform vec4 ${S};
525
- `, a[S] = { value: new y.Vector4(...x) }) : (n += `uniform float ${S};
526
- `, a[S] = { value: x });
520
+ for (const [S, w] of Object.entries(i.uniforms))
521
+ typeof w == "number" ? (n += `uniform float ${S};
522
+ `, a[S] = { value: w }) : Array.isArray(w) ? w.length === 2 ? (n += `uniform vec2 ${S};
523
+ `, a[S] = { value: new y.Vector2(...w) }) : w.length === 3 ? (n += `uniform vec3 ${S};
524
+ `, a[S] = { value: new y.Vector3(...w) }) : w.length === 4 && (n += `uniform vec4 ${S};
525
+ `, a[S] = { value: new y.Vector4(...w) }) : (n += `uniform float ${S};
526
+ `, a[S] = { value: w });
527
527
  const o = i !== void 0, c = (l || o ? Le.declChunk : "") + `
528
528
  ` + n, d = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
529
529
  `, h = s.isTraveler ? `vec2 resultUv = screenUv;
530
530
  ` : `vec2 resultUv = vUv * uTextureRepeat + uTextureOffset;
531
- `, g = l || o ? d + h + ((i == null ? void 0 : i.uvModifier) || "") : "", v = l || o ? Le.baseColorChunk : "", p = (i == null ? void 0 : i.colorModifier) || "", m = Re.fragmentShader.replace("#INJECT_DECLARATIONS", c).replace("#INJECT_UV_MODIFIER", g).replace("#INJECT_BASE_COLOR", v).replace("#INJECT_COLOR_MODIFIER", p), w = le(s.backgroundColor), L = le(s.borderColor), M = {
531
+ `, g = l || o ? d + h + ((i == null ? void 0 : i.uvModifier) || "") : "", v = l || o ? Le.baseColorChunk : "", p = (i == null ? void 0 : i.colorModifier) || "", m = Re.fragmentShader.replace("#INJECT_DECLARATIONS", c).replace("#INJECT_UV_MODIFIER", g).replace("#INJECT_BASE_COLOR", v).replace("#INJECT_COLOR_MODIFIER", p), E = le(s.backgroundColor), M = le(s.borderColor), L = {
532
532
  uSize: { value: new y.Vector2(e, t) },
533
533
  uBgColor: {
534
534
  value: new y.Vector4(
535
- w.color.r,
536
- w.color.g,
537
- w.color.b,
538
- w.alpha
535
+ E.color.r,
536
+ E.color.g,
537
+ E.color.b,
538
+ E.alpha
539
539
  )
540
540
  },
541
541
  uBorderColor: {
542
542
  value: new y.Vector4(
543
- L.color.r,
544
- L.color.g,
545
- L.color.b,
546
- L.alpha
543
+ M.color.r,
544
+ M.color.g,
545
+ M.color.b,
546
+ M.alpha
547
547
  )
548
548
  },
549
549
  uBorderRadius: { value: new y.Vector4(0, 0, 0, 0) },
550
- uBorderWidth: { value: re(s.borderWidth) },
551
- uOpacity: { value: (E = s.opacity) != null ? E : 1 },
550
+ uBorderWidth: { value: se(s.borderWidth) },
551
+ uOpacity: { value: (C = s.opacity) != null ? C : 1 },
552
552
  uTexture: { value: null },
553
553
  uTextureRepeat: { value: new y.Vector2(1, 1) },
554
554
  uTextureOffset: { value: new y.Vector2(0, 0) },
@@ -559,19 +559,19 @@ function Ze(s, e, t, r = null, i) {
559
559
  },
560
560
  uGradientStops: { value: new Float32Array(8) }
561
561
  };
562
- Ie(M.uBorderRadius.value, s.borderRadius, Math.min(e, t)), l && (M.uTexture.value = r);
563
- const T = new y.ShaderMaterial({
564
- uniforms: j(j({}, M), a),
562
+ Ie(L.uBorderRadius.value, s.borderRadius, Math.min(e, t)), l && (L.uTexture.value = r);
563
+ const R = new y.ShaderMaterial({
564
+ uniforms: J(J({}, L), a),
565
565
  vertexShader: Re.vertexShader,
566
566
  fragmentShader: m,
567
567
  transparent: !0,
568
568
  side: y.FrontSide
569
569
  // for better performance
570
570
  });
571
- return s.backgroundImage && ye(T, { backgroundImage: s.backgroundImage }), T;
571
+ return s.backgroundImage && ye(R, { backgroundImage: s.backgroundImage }), R;
572
572
  }
573
573
  function et(s, e, t, r, i) {
574
- const l = re(e.borderWidth);
574
+ const l = se(e.borderWidth);
575
575
  ye(s, {
576
576
  width: t,
577
577
  height: r,
@@ -693,10 +693,10 @@ function Ie(s, e, t = 0) {
693
693
  s.set(e[0], e[1], e[2], e[3]);
694
694
  return;
695
695
  }
696
- const r = e.split("/")[0].trim().split(/\s+/), i = re(r[0], t), l = re((o = r[1]) != null ? o : r[0], t), n = re((c = r[2]) != null ? c : r[0], t), a = re((h = (d = r[3]) != null ? d : r[1]) != null ? h : r[0], t);
696
+ const r = e.split("/")[0].trim().split(/\s+/), i = se(r[0], t), l = se((o = r[1]) != null ? o : r[0], t), n = se((c = r[2]) != null ? c : r[0], t), a = se((h = (d = r[3]) != null ? d : r[1]) != null ? h : r[0], t);
697
697
  s.set(i, l, n, a);
698
698
  }
699
- const Y = {
699
+ const V = {
700
700
  create(s, e, t, r, i, l = 2, n = null, a) {
701
701
  return s === "BOX" ? Ze(
702
702
  e,
@@ -827,7 +827,7 @@ class rt {
827
827
  var a, o, c, d, h;
828
828
  this.target = e, this.mountContainer = r, this.registry = i, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (o = t.canvasSize) != null ? o : "viewport", this.clipArea = (c = t.travelerClipArea) != null ? c : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new tt((g, v) => {
829
829
  const p = this.registry.get(g);
830
- p && p.material instanceof y.ShaderMaterial && Y.forceUpdateUniforms(p.material, { texture: v });
830
+ p && p.material instanceof y.ShaderMaterial && V.forceUpdateUniforms(p.material, { texture: v });
831
831
  }, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new y.Scene(), this.targetRect = this.target.getBoundingClientRect();
832
832
  const l = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
833
833
  this.camera = new y.OrthographicCamera(
@@ -849,7 +849,7 @@ class rt {
849
849
  return this.mode === "overlay" && this.canvasSize === "viewport";
850
850
  }
851
851
  getSceneLayer() {
852
- return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? B.SELECTED : B.BASE;
852
+ return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? I.SELECTED : I.BASE;
853
853
  }
854
854
  createRenderTarget() {
855
855
  for (let e = 0; e < O.MAX_LAYERS; e++) {
@@ -899,12 +899,12 @@ class rt {
899
899
  updateUniforms(e, t) {
900
900
  const r = this.registry.get(e);
901
901
  r && (r.traverse((i) => {
902
- i.isMesh && i.material && Y.forceUpdateUniforms(
902
+ i.isMesh && i.material && V.forceUpdateUniforms(
903
903
  i.material,
904
904
  t
905
905
  );
906
906
  }), r.userData.nativeMesh && r.userData.nativeMesh.traverse((i) => {
907
- i.isMesh && i.material && Y.forceUpdateUniforms(
907
+ i.isMesh && i.material && V.forceUpdateUniforms(
908
908
  i.material,
909
909
  t
910
910
  );
@@ -944,7 +944,7 @@ class rt {
944
944
  let t = this.registry.get(e.element);
945
945
  const r = JSON.stringify(e.shaderHooks || null);
946
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 n = new y.PlaneGeometry(1, 1), a = e.isTraveler ? (i = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : i.texture : this.textureManager.get(e.element), o = Y.create(
947
+ const n = new y.PlaneGeometry(1, 1), a = e.isTraveler ? (i = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : i.texture : this.textureManager.get(e.element), o = V.create(
948
948
  "BOX",
949
949
  e.styles,
950
950
  "",
@@ -981,29 +981,29 @@ class rt {
981
981
  e.children.filter(
982
982
  (p) => p.name.startsWith("TEXT_CHILD")
983
983
  ).forEach((p) => {
984
- var w;
984
+ var E;
985
985
  const m = p;
986
- (w = m.material.map) == null || w.dispose(), m.geometry.dispose(), e.remove(m);
986
+ (E = m.material.map) == null || E.dispose(), m.geometry.dispose(), e.remove(m);
987
987
  });
988
988
  const h = t.rect, g = h.x + h.width / 2, v = h.y + h.height / 2;
989
989
  i.forEach((p, m) => {
990
- const w = Y.create(
990
+ const E = V.create(
991
991
  "TEXT",
992
992
  l,
993
993
  p.text,
994
994
  p.rect.width,
995
995
  p.rect.height,
996
996
  this.qualityFactor
997
- ), L = new y.PlaneGeometry(1, 1), M = new y.Mesh(L, w);
998
- M.name = `TEXT_CHILD_${m}`;
999
- const T = t.rect.width === 0 ? 1 : p.rect.width / t.rect.width, E = t.rect.height === 0 ? 1 : p.rect.height / t.rect.height;
1000
- M.scale.set(T, E, 1);
1001
- const S = p.rect.x + p.rect.width / 2, x = p.rect.y + p.rect.height / 2, R = S - g, A = -(x - v);
1002
- M.position.set(
1003
- t.rect.width === 0 ? 0 : R / t.rect.width,
1004
- t.rect.height === 0 ? 0 : A / t.rect.height,
997
+ ), M = new y.PlaneGeometry(1, 1), L = new y.Mesh(M, E);
998
+ L.name = `TEXT_CHILD_${m}`;
999
+ const R = t.rect.width === 0 ? 1 : p.rect.width / t.rect.width, C = t.rect.height === 0 ? 1 : p.rect.height / t.rect.height;
1000
+ L.scale.set(R, C, 1);
1001
+ const S = p.rect.x + p.rect.width / 2, w = p.rect.y + p.rect.height / 2, B = S - g, _ = -(w - v);
1002
+ L.position.set(
1003
+ t.rect.width === 0 ? 0 : B / t.rect.width,
1004
+ t.rect.height === 0 ? 0 : _ / t.rect.height,
1005
1005
  5e-3
1006
- ), e.add(M);
1006
+ ), e.add(L);
1007
1007
  }), e.userData.textChildStyleHash = n;
1008
1008
  }
1009
1009
  e.children.forEach((d) => {
@@ -1011,21 +1011,21 @@ class rt {
1011
1011
  return;
1012
1012
  const h = d;
1013
1013
  if (r && t.nativeLayer !== void 0)
1014
- h.layers.set(B.HIDDEN), t.visibility & W && h.layers.enable(B.getCaptureLayer(t.nativeLayer));
1014
+ h.layers.set(I.HIDDEN), t.visibility & H && h.layers.enable(I.getCaptureLayer(t.nativeLayer));
1015
1015
  else {
1016
- const g = t.visibility & W ? B.BASE : B.HIDDEN;
1017
- if (h.layers.set(g), t.visibility & te && h.layers.enable(B.SELECTED), t.visibility & W)
1016
+ const g = t.visibility & H ? I.BASE : I.HIDDEN;
1017
+ if (h.layers.set(g), t.visibility & ie && h.layers.enable(I.SELECTED), t.visibility & H)
1018
1018
  if (!r && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
1019
1019
  for (let v = t.captureLayer; v <= O.MAX_LAYERS + 1; v++)
1020
- v !== t.nativeLayer && h.layers.enable(B.getCaptureLayer(v));
1020
+ v !== t.nativeLayer && h.layers.enable(I.getCaptureLayer(v));
1021
1021
  else
1022
1022
  for (let v = t.captureLayer; v <= O.MAX_LAYERS + 1; v++)
1023
- h.layers.enable(B.getCaptureLayer(v));
1023
+ h.layers.enable(I.getCaptureLayer(v));
1024
1024
  }
1025
1025
  });
1026
1026
  }
1027
1027
  updateMeshProperties(e, t) {
1028
- var T, E, S;
1028
+ var R, C, S;
1029
1029
  const { rect: r, styles: i } = t, l = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / l, a = this.renderer.domElement.height / l;
1030
1030
  e.material = e.userData.baseMaterial, e.scale.set(r.width, r.height, 1), e.userData.domRect = {
1031
1031
  x: r.x,
@@ -1040,8 +1040,8 @@ class rt {
1040
1040
  if (this.isViewport)
1041
1041
  h = r.x - window.innerWidth / 2 + r.width / 2, g = -r.y + window.innerHeight / 2 - r.height / 2;
1042
1042
  else {
1043
- const x = r.x - c, R = r.y - d;
1044
- h = x - n / 2 + r.width / 2, g = -R + a / 2 - r.height / 2;
1043
+ const w = r.x - c, B = r.y - d;
1044
+ h = w - n / 2 + r.width / 2, g = -B + a / 2 - r.height / 2;
1045
1045
  }
1046
1046
  e.position.set(
1047
1047
  h,
@@ -1050,13 +1050,13 @@ class rt {
1050
1050
  );
1051
1051
  const v = r.x, p = r.y;
1052
1052
  e.userData.basePosition = { x: h, y: g }, e.userData.originalBasePosition = { x: h, y: g }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: v, y: p }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
1053
- const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, w = window.getComputedStyle(m);
1054
- let L = 0, M = 0;
1055
- if (w.transform && w.transform !== "none") {
1056
- const x = new DOMMatrix(w.transform);
1057
- L = x.m41, M = x.m42;
1053
+ const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, E = window.getComputedStyle(m);
1054
+ let M = 0, L = 0;
1055
+ if (E.transform && E.transform !== "none") {
1056
+ const w = new DOMMatrix(E.transform);
1057
+ M = w.m41, L = w.m42;
1058
1058
  }
1059
- if (e.userData.baseTransform = { x: L, y: M }, delete e.userData.originRatioX, delete e.userData.originRatioY, Y.update(
1059
+ if (e.userData.baseTransform = { x: M, y: L }, delete e.userData.originRatioX, delete e.userData.originRatioY, V.update(
1060
1060
  e.userData.baseMaterial,
1061
1061
  "BOX",
1062
1062
  i,
@@ -1064,73 +1064,73 @@ class rt {
1064
1064
  r.width,
1065
1065
  r.height,
1066
1066
  this.qualityFactor,
1067
- t.isTraveler ? (T = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : T.texture : this.textureManager.get(t.element)
1067
+ t.isTraveler ? (R = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : R.texture : this.textureManager.get(t.element)
1068
1068
  ), t.nativeStyles && t.nativeRect) {
1069
1069
  if (!e.userData.nativeMesh) {
1070
- const _ = Y.create(
1070
+ const N = V.create(
1071
1071
  "BOX",
1072
1072
  t.nativeStyles,
1073
1073
  "",
1074
1074
  t.nativeRect.width,
1075
1075
  t.nativeRect.height,
1076
1076
  this.qualityFactor,
1077
- t.isTraveler ? (E = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : E.texture : this.textureManager.get(t.element),
1077
+ t.isTraveler ? (C = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : C.texture : this.textureManager.get(t.element),
1078
1078
  t.shaderHooks
1079
- ), N = new y.Mesh(e.geometry, _);
1080
- t.type === "TEXT" && (N.name = "BG_MESH"), this.scene.add(N), e.userData.nativeMesh = N;
1079
+ ), X = new y.Mesh(e.geometry, N);
1080
+ t.type === "TEXT" && (X.name = "BG_MESH"), this.scene.add(X), e.userData.nativeMesh = X;
1081
1081
  }
1082
- const x = e.userData.nativeMesh;
1083
- let R, A;
1082
+ const w = e.userData.nativeMesh;
1083
+ let B, _;
1084
1084
  if (this.isViewport)
1085
- R = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, A = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
1085
+ B = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, _ = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
1086
1086
  else {
1087
- const _ = t.nativeRect.x - c, N = t.nativeRect.y - d;
1088
- R = _ - n / 2 + t.nativeRect.width / 2, A = -N + a / 2 - t.nativeRect.height / 2;
1087
+ const N = t.nativeRect.x - c, X = t.nativeRect.y - d;
1088
+ B = N - n / 2 + t.nativeRect.width / 2, _ = -X + a / 2 - t.nativeRect.height / 2;
1089
1089
  }
1090
- let U = t.nativeRect.width, G = t.nativeRect.height, ie = R, se = A;
1090
+ let b = t.nativeRect.width, U = t.nativeRect.height, $ = B, q = _;
1091
1091
  if (t.nativeStyles.transform) {
1092
- const _ = t.nativeStyles.transform, N = _.match(/scale\(([\d.]+%?)\)/);
1093
- if (N) {
1094
- let f = parseFloat(N[1]);
1095
- N[1].includes("%") && (f /= 100), U *= f, G *= f;
1092
+ const N = t.nativeStyles.transform, X = N.match(/scale\(([\d.]+%?)\)/);
1093
+ if (X) {
1094
+ let f = parseFloat(X[1]);
1095
+ X[1].includes("%") && (f /= 100), b *= f, U *= f;
1096
1096
  }
1097
- const J = _.match(/scaleX\(([\d.]+%?)\)/);
1098
- if (J) {
1099
- let f = parseFloat(J[1]);
1100
- J[1].includes("%") && (f /= 100), U *= f;
1097
+ const Z = N.match(/scaleX\(([\d.]+%?)\)/);
1098
+ if (Z) {
1099
+ let f = parseFloat(Z[1]);
1100
+ Z[1].includes("%") && (f /= 100), b *= f;
1101
1101
  }
1102
- const Q = _.match(/scaleY\(([\d.]+%?)\)/);
1103
- if (Q) {
1104
- let f = parseFloat(Q[1]);
1105
- Q[1].includes("%") && (f /= 100), G *= f;
1102
+ const ee = N.match(/scaleY\(([\d.]+%?)\)/);
1103
+ if (ee) {
1104
+ let f = parseFloat(ee[1]);
1105
+ ee[1].includes("%") && (f /= 100), U *= f;
1106
1106
  }
1107
- const Z = _.match(/translate\(([^,]+),\s*([^)]+)\)/);
1108
- if (Z) {
1109
- const f = Z[1].trim(), b = Z[2].trim();
1110
- let k = parseFloat(f);
1111
- f.includes("%") && (k = k / 100 * t.nativeRect.width);
1112
- let F = parseFloat(b);
1113
- b.includes("%") && (F = F / 100 * t.nativeRect.height), ie += k, se -= F;
1107
+ const te = N.match(/translate\(([^,]+),\s*([^)]+)\)/);
1108
+ if (te) {
1109
+ const f = te[1].trim(), x = te[2].trim();
1110
+ let D = parseFloat(f);
1111
+ f.includes("%") && (D = D / 100 * t.nativeRect.width);
1112
+ let F = parseFloat(x);
1113
+ x.includes("%") && (F = F / 100 * t.nativeRect.height), $ += D, q -= F;
1114
1114
  }
1115
- const ne = _.match(/translateX\(([^)]+)\)/);
1115
+ const ne = N.match(/translateX\(([^)]+)\)/);
1116
1116
  if (ne) {
1117
1117
  const f = ne[1].trim();
1118
- let b = parseFloat(f);
1119
- f.includes("%") && (b = b / 100 * t.nativeRect.width), ie += b;
1118
+ let x = parseFloat(f);
1119
+ f.includes("%") && (x = x / 100 * t.nativeRect.width), $ += x;
1120
1120
  }
1121
- const ae = _.match(/translateY\(([^)]+)\)/);
1121
+ const ae = N.match(/translateY\(([^)]+)\)/);
1122
1122
  if (ae) {
1123
1123
  const f = ae[1].trim();
1124
- let b = parseFloat(f);
1125
- f.includes("%") && (b = b / 100 * t.nativeRect.height), se -= b;
1124
+ let x = parseFloat(f);
1125
+ f.includes("%") && (x = x / 100 * t.nativeRect.height), q -= x;
1126
1126
  }
1127
1127
  }
1128
- x.scale.set(U, G, 1), x.position.set(
1129
- ie,
1130
- se,
1128
+ w.scale.set(b, U, 1), w.position.set(
1129
+ $,
1130
+ q,
1131
1131
  t.nativeStyles.zIndex + this.renderOrder * o
1132
- ), Y.update(
1133
- x.material,
1132
+ ), V.update(
1133
+ w.material,
1134
1134
  "BOX",
1135
1135
  t.nativeStyles,
1136
1136
  "",
@@ -1143,17 +1143,17 @@ class rt {
1143
1143
  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);
1144
1144
  }
1145
1145
  updateMeshLayers(e, t) {
1146
- const r = t.visibility & W ? B.BASE : B.HIDDEN;
1147
- if (e.layers.set(r), t.visibility & te && e.layers.enable(B.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
1146
+ const r = t.visibility & H ? I.BASE : I.HIDDEN;
1147
+ if (e.layers.set(r), t.visibility & ie && e.layers.enable(I.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
1148
1148
  const i = e.userData.nativeMesh;
1149
- if (i.layers.set(B.HIDDEN), t.visibility & W) {
1150
- i.layers.enable(B.getCaptureLayer(t.nativeLayer));
1149
+ if (i.layers.set(I.HIDDEN), t.visibility & H) {
1150
+ i.layers.enable(I.getCaptureLayer(t.nativeLayer));
1151
1151
  for (let l = t.captureLayer; l <= O.MAX_LAYERS + 1; l++)
1152
- l !== t.nativeLayer && e.layers.enable(B.getCaptureLayer(l));
1152
+ l !== t.nativeLayer && e.layers.enable(I.getCaptureLayer(l));
1153
1153
  }
1154
- } else if (t.visibility & W)
1154
+ } else if (t.visibility & H)
1155
1155
  for (let i = t.captureLayer; i <= O.MAX_LAYERS + 1; i++)
1156
- e.layers.enable(B.getCaptureLayer(i));
1156
+ e.layers.enable(I.getCaptureLayer(i));
1157
1157
  }
1158
1158
  captureRenderTarget(e, t, r) {
1159
1159
  if (e.size === 0 || !r)
@@ -1166,8 +1166,8 @@ class rt {
1166
1166
  const h = (n.x + 1) / 2 * a, g = (n.y + 1) / 2 * o;
1167
1167
  let v = 0, p = 1;
1168
1168
  typeof this.clipArea == "number" ? p = this.clipArea : this.clipArea.endsWith("%") ? p = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (v = parseFloat(this.clipArea));
1169
- const m = d.scale.x * p + 0.5, w = d.scale.y * p + 0.5, L = h - m / 2, M = g - w / 2, T = (L * this.qualityFactor - v) / c, E = (M * this.qualityFactor - v) / c, S = (m * this.qualityFactor + v * 2) / c, x = (w * this.qualityFactor + v * 2) / c;
1170
- this.renderer.setScissor(T, E, S, x), this.renderer.render(this.scene, this.camera);
1169
+ const m = d.scale.x * p + 0.5, E = d.scale.y * p + 0.5, M = h - m / 2, L = g - E / 2, R = (M * this.qualityFactor - v) / c, C = (L * this.qualityFactor - v) / c, S = (m * this.qualityFactor + v * 2) / c, w = (E * this.qualityFactor + v * 2) / c;
1170
+ this.renderer.setScissor(R, C, S, w), this.renderer.render(this.scene, this.camera);
1171
1171
  }
1172
1172
  this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i, l);
1173
1173
  }
@@ -1176,7 +1176,7 @@ class rt {
1176
1176
  const t = e + 1;
1177
1177
  this.captureRenderTarget(
1178
1178
  this.travelersByLayer[e],
1179
- B.getCaptureLayer(t),
1179
+ I.getCaptureLayer(t),
1180
1180
  this.renderTargets[e]
1181
1181
  );
1182
1182
  }
@@ -1212,40 +1212,53 @@ class rt {
1212
1212
  const v = c.x - e, p = c.y - t;
1213
1213
  h = v - i / 2 + c.width / 2, g = -p + l / 2 - c.height / 2;
1214
1214
  }
1215
- if (a.position.setX(h), a.position.setY(g), a.scale.set(c.width, c.height, 1), a.updateMatrixWorld(), a.material instanceof y.ShaderMaterial && Y.forceUpdateUniforms(a.material, {
1215
+ if (a.position.setX(h), a.position.setY(g), a.scale.set(c.width, c.height, 1), a.updateMatrixWorld(), a.material instanceof y.ShaderMaterial && V.forceUpdateUniforms(a.material, {
1216
1216
  width: c.width,
1217
1217
  height: c.height
1218
1218
  }), a.userData.nativeMesh) {
1219
1219
  const v = a.userData.nativeMesh;
1220
- let p = c.width, m = c.height, w = h, L = g;
1220
+ let p = c.width, m = c.height, E = h, M = g;
1221
1221
  if (a.userData.nativeTransform) {
1222
- const M = a.userData.nativeTransform, T = M.match(/scale\(([\d.]+%?)\)/);
1223
- if (T) {
1224
- let R = parseFloat(T[1]);
1225
- T[1].includes("%") && (R /= 100), p *= R, m *= R;
1222
+ const L = a.userData.nativeTransform, R = L.match(/scale\(([\d.]+%?)\)/);
1223
+ if (R) {
1224
+ let b = parseFloat(R[1]);
1225
+ R[1].includes("%") && (b /= 100), p *= b, m *= b;
1226
1226
  }
1227
- const E = M.match(/translate\(([^,]+),\s*([^)]+)\)/);
1228
- if (E) {
1229
- const R = E[1].trim(), A = E[2].trim();
1230
- let U = parseFloat(R);
1231
- R.includes("%") && (U = U / 100 * c.width);
1232
- let G = parseFloat(A);
1233
- A.includes("%") && (G = G / 100 * c.height), w += U, L -= G;
1227
+ const C = L.match(/scaleX\(([\d.]+%?)\)/);
1228
+ if (C) {
1229
+ let b = parseFloat(C[1]);
1230
+ C[1].includes("%") && (b /= 100), p *= b;
1234
1231
  }
1235
- const S = M.match(/translateX\(([^)]+)\)/);
1232
+ const S = L.match(/scaleY\(([\d.]+%?)\)/);
1236
1233
  if (S) {
1237
- const R = S[1].trim();
1238
- let A = parseFloat(R);
1239
- R.includes("%") && (A = A / 100 * c.width), w += A;
1234
+ let b = parseFloat(S[1]);
1235
+ S[1].includes("%") && (b /= 100), m *= b;
1236
+ }
1237
+ const w = L.match(/translate\(([^,]+),\s*([^)]+)\)/);
1238
+ if (w) {
1239
+ const b = w[1].trim(), U = w[2].trim();
1240
+ let $ = parseFloat(b);
1241
+ b.includes("%") && ($ = $ / 100 * c.width);
1242
+ let q = parseFloat(U);
1243
+ U.includes("%") && (q = q / 100 * c.height), E += $, M -= q;
1240
1244
  }
1241
- const x = M.match(/translateY\(([^)]+)\)/);
1242
- if (x) {
1243
- const R = x[1].trim();
1244
- let A = parseFloat(R);
1245
- R.includes("%") && (A = A / 100 * c.height), L -= A;
1245
+ const B = L.match(/translateX\(([^)]+)\)/);
1246
+ if (B) {
1247
+ const b = B[1].trim();
1248
+ let U = parseFloat(b);
1249
+ b.includes("%") && (U = U / 100 * c.width), E += U;
1250
+ }
1251
+ const _ = L.match(/translateY\(([^)]+)\)/);
1252
+ if (_) {
1253
+ const b = _[1].trim();
1254
+ let U = parseFloat(b);
1255
+ b.includes("%") && (U = U / 100 * c.height), M -= U;
1246
1256
  }
1247
1257
  }
1248
- v.position.setX(w), v.position.setY(L), v.scale.set(p, m, 1), v.updateMatrixWorld();
1258
+ v.position.setX(E), v.position.setY(M), v.scale.set(p, m, 1), v.updateMatrixWorld(), v.material instanceof y.ShaderMaterial && V.forceUpdateUniforms(v.material, {
1259
+ width: p,
1260
+ height: m
1261
+ });
1249
1262
  }
1250
1263
  }
1251
1264
  });
@@ -1343,283 +1356,283 @@ function Me(s) {
1343
1356
  letterSpacing: r
1344
1357
  };
1345
1358
  }
1346
- function Ue(s, e = K | ce | Ye | ve | ue, t, r = 1, i = 0, l = 2, n, a) {
1347
- var N, J, Q, Z, ne, ae;
1359
+ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, l = 2, n, a) {
1360
+ var X, Z, ee, te, ne, ae;
1348
1361
  if (s.nodeType === Node.TEXT_NODE) {
1349
1362
  const f = s;
1350
1363
  if (!f.textContent || !f.textContent.trim())
1351
1364
  return null;
1352
- const b = f.textContent.replace(/\s+/g, " ");
1353
- if (b.length === 0)
1365
+ const x = f.textContent.replace(/\s+/g, " ");
1366
+ if (x.length === 0)
1354
1367
  return null;
1355
- const k = it(f);
1356
- if (k.length === 0)
1368
+ const D = it(f);
1369
+ if (D.length === 0)
1357
1370
  return null;
1358
- const F = f.parentElement, I = F ? window.getComputedStyle(F) : null;
1359
- if (!I)
1371
+ const F = f.parentElement, k = F ? window.getComputedStyle(F) : null;
1372
+ if (!k)
1360
1373
  return null;
1361
- const H = Math.min(...k.map((C) => C.rect.left)), z = Math.min(...k.map((C) => C.rect.top)), $ = Math.max(...k.map((C) => C.rect.left + C.rect.width)), D = Math.max(...k.map((C) => C.rect.top + C.rect.height));
1374
+ const P = Math.min(...D.map((T) => T.rect.left)), z = Math.min(...D.map((T) => T.rect.top)), j = Math.max(...D.map((T) => T.rect.left + T.rect.width)), A = Math.max(...D.map((T) => T.rect.top + T.rect.height));
1362
1375
  return {
1363
1376
  id: Math.random().toString(36).substring(2, 9),
1364
1377
  type: "TEXT",
1365
1378
  element: f,
1366
1379
  rect: {
1367
- x: H + window.scrollX,
1380
+ x: P + window.scrollX,
1368
1381
  y: z + window.scrollY,
1369
- width: $ - H,
1370
- height: D - z
1382
+ width: j - P,
1383
+ height: A - z
1371
1384
  },
1372
1385
  styles: {
1373
1386
  backgroundColor: "transparent",
1374
1387
  backgroundImage: "",
1375
- opacity: F && F.dataset[q.KEY] === q.VALUES.HIDE ? 1 : parseFloat(I.opacity),
1376
- zIndex: (isNaN(parseInt(I.zIndex)) ? 0 : parseInt(I.zIndex)) + i,
1388
+ opacity: F && F.dataset[K.KEY] === K.VALUES.HIDE ? 1 : parseFloat(k.opacity),
1389
+ zIndex: (isNaN(parseInt(k.zIndex)) ? 0 : parseInt(k.zIndex)) + i,
1377
1390
  borderRadius: "0px",
1378
1391
  borderColor: "transparent",
1379
1392
  borderWidth: "0px",
1380
1393
  isTraveler: !1
1381
1394
  },
1382
- textContent: b,
1383
- textLines: k.map((C) => ({
1384
- text: C.text.trim(),
1395
+ textContent: x,
1396
+ textLines: D.map((T) => ({
1397
+ text: T.text.trim(),
1385
1398
  rect: {
1386
- x: C.rect.left + window.scrollX,
1387
- y: C.rect.top + window.scrollY,
1388
- width: C.rect.width,
1389
- height: C.rect.height
1399
+ x: T.rect.left + window.scrollX,
1400
+ y: T.rect.top + window.scrollY,
1401
+ width: T.rect.width,
1402
+ height: T.rect.height
1390
1403
  }
1391
1404
  })),
1392
- textStyles: Me(I),
1405
+ textStyles: Me(k),
1393
1406
  dirtyMask: e,
1394
1407
  visibility: t,
1395
1408
  isTraveler: !1,
1396
1409
  captureLayer: r,
1397
- isFixed: I.position === "fixed",
1410
+ isFixed: k.position === "fixed",
1398
1411
  nativeLayer: n,
1399
- nativeStyles: a ? j(j({
1412
+ nativeStyles: a ? J(J({
1400
1413
  backgroundColor: "transparent",
1401
1414
  backgroundImage: "",
1402
- opacity: F && F.dataset[q.KEY] === q.VALUES.HIDE ? 1 : parseFloat(I.opacity),
1403
- zIndex: (isNaN(parseInt(I.zIndex)) ? 0 : parseInt(I.zIndex)) + i,
1415
+ opacity: F && F.dataset[K.KEY] === K.VALUES.HIDE ? 1 : parseFloat(k.opacity),
1416
+ zIndex: (isNaN(parseInt(k.zIndex)) ? 0 : parseInt(k.zIndex)) + i,
1404
1417
  borderRadius: "0px",
1405
1418
  borderColor: "transparent",
1406
1419
  borderWidth: "0px",
1407
1420
  isTraveler: !1
1408
- }, Me(I)), a) : void 0,
1421
+ }, Me(k)), a) : void 0,
1409
1422
  nativeRect: a ? {
1410
- x: H + window.scrollX,
1423
+ x: P + window.scrollX,
1411
1424
  y: z + window.scrollY,
1412
- width: $ - H,
1413
- height: D - z
1425
+ width: j - P,
1426
+ height: A - z
1414
1427
  } : void 0,
1415
1428
  children: []
1416
1429
  };
1417
1430
  }
1418
1431
  if (s.nodeType !== Node.ELEMENT_NODE)
1419
1432
  return null;
1420
- const o = s, c = o.dataset[V.KEY];
1433
+ const o = s, c = o.dataset[W.KEY];
1421
1434
  let d = t, h = t;
1422
1435
  if (c) {
1423
1436
  const f = new Set(c.split(/\s+/));
1424
- for (const b of f)
1425
- if (!Te.includes(b))
1437
+ for (const x of f)
1438
+ if (!Te.includes(x))
1426
1439
  throw new Error(
1427
- `[MirageEngine] Invalid filter token: '${b}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1440
+ `[MirageEngine] Invalid filter token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1428
1441
  );
1429
- if (f.has(V.VALUES.END))
1442
+ if (f.has(W.VALUES.END))
1430
1443
  return null;
1431
- if (f.has(V.VALUES.INCLUDE_TREE) && f.has(V.VALUES.EXCLUDE_TREE))
1444
+ if (f.has(W.VALUES.INCLUDE_TREE) && f.has(W.VALUES.EXCLUDE_TREE))
1432
1445
  throw new Error(
1433
1446
  "[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
1434
1447
  );
1435
- if (f.has(V.VALUES.INCLUDE_SELF) && f.has(V.VALUES.EXCLUDE_SELF))
1448
+ if (f.has(W.VALUES.INCLUDE_SELF) && f.has(W.VALUES.EXCLUDE_SELF))
1436
1449
  throw new Error(
1437
1450
  "[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
1438
1451
  );
1439
- f.has(V.VALUES.INCLUDE_TREE) ? d = d | W : f.has(V.VALUES.EXCLUDE_TREE) && (d = d & ~W), h = d, f.has(V.VALUES.INCLUDE_SELF) ? h = h | W : f.has(V.VALUES.EXCLUDE_SELF) && (h = h & ~W);
1452
+ f.has(W.VALUES.INCLUDE_TREE) ? d = d | H : f.has(W.VALUES.EXCLUDE_TREE) && (d = d & ~H), h = d, f.has(W.VALUES.INCLUDE_SELF) ? h = h | H : f.has(W.VALUES.EXCLUDE_SELF) && (h = h & ~H);
1440
1453
  }
1441
- const g = o.dataset[P.KEY];
1454
+ const g = o.dataset[G.KEY];
1442
1455
  if (g) {
1443
1456
  const f = new Set(g.split(/\s+/));
1444
- for (const b of f)
1445
- if (!Te.includes(b))
1457
+ for (const x of f)
1458
+ if (!Te.includes(x))
1446
1459
  throw new Error(
1447
- `[MirageEngine] Invalid select token: '${b}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1460
+ `[MirageEngine] Invalid select token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1448
1461
  );
1449
- if (f.has(P.VALUES.END))
1462
+ if (f.has(G.VALUES.END))
1450
1463
  return null;
1451
- if (f.has(P.VALUES.INCLUDE_TREE) && f.has(P.VALUES.EXCLUDE_TREE))
1464
+ if (f.has(G.VALUES.INCLUDE_TREE) && f.has(G.VALUES.EXCLUDE_TREE))
1452
1465
  throw new Error(
1453
1466
  "[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
1454
1467
  );
1455
- if (f.has(P.VALUES.INCLUDE_SELF) && f.has(P.VALUES.EXCLUDE_SELF))
1468
+ if (f.has(G.VALUES.INCLUDE_SELF) && f.has(G.VALUES.EXCLUDE_SELF))
1456
1469
  throw new Error(
1457
1470
  "[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
1458
1471
  );
1459
- f.has(P.VALUES.INCLUDE_TREE) ? d = d | te : f.has(P.VALUES.EXCLUDE_TREE) && (d = d & ~te), h = d, f.has(P.VALUES.INCLUDE_SELF) ? h = h | te : f.has(P.VALUES.EXCLUDE_SELF) && (h = h & ~te);
1472
+ f.has(G.VALUES.INCLUDE_TREE) ? d = d | ie : f.has(G.VALUES.EXCLUDE_TREE) && (d = d & ~ie), h = d, f.has(G.VALUES.INCLUDE_SELF) ? h = h | ie : f.has(G.VALUES.EXCLUDE_SELF) && (h = h & ~ie);
1460
1473
  }
1461
1474
  const v = o.dataset[O.KEY];
1462
- let p = !1, m = a ? j({}, a) : {}, w = n;
1475
+ let p = !1, m = a ? J({}, a) : {}, E = n;
1463
1476
  if (v) {
1464
1477
  let f = 1;
1465
- const b = v.indexOf("{"), k = v.lastIndexOf("}");
1478
+ const x = v.indexOf("{"), D = v.lastIndexOf("}");
1466
1479
  let F = v;
1467
- if (b !== -1 && k !== -1 && k > b) {
1468
- F = v.substring(0, b).trim();
1469
- const D = v.substring(b, k + 1);
1480
+ if (x !== -1 && D !== -1 && D > x) {
1481
+ F = v.substring(0, x).trim();
1482
+ const A = v.substring(x, D + 1);
1470
1483
  try {
1471
- m = new Function("return " + D)();
1472
- } catch (C) {
1484
+ m = new Function("return " + A)();
1485
+ } catch (T) {
1473
1486
  console.warn(
1474
- `[MirageEngine] Failed to parse travel styles JSON: ${D}`
1487
+ `[MirageEngine] Failed to parse travel styles JSON: ${A}`
1475
1488
  );
1476
1489
  }
1477
1490
  }
1478
- const I = F.split(/\s+/);
1479
- let H = !1;
1480
- const z = I.indexOf(O.VALUES.TRAVELER);
1491
+ const k = F.split(/\s+/);
1492
+ let P = !1;
1493
+ const z = k.indexOf(O.VALUES.TRAVELER);
1481
1494
  if (z !== -1) {
1482
- p = !0, H = !0;
1483
- const D = I[z + 1];
1484
- if (D && !isNaN(parseInt(D, 10)))
1485
- f = parseInt(D, 10);
1495
+ p = !0, P = !0;
1496
+ const A = k[z + 1];
1497
+ if (A && !isNaN(parseInt(A, 10)))
1498
+ f = parseInt(A, 10);
1486
1499
  else {
1487
- const C = I.find((ee) => !isNaN(parseInt(ee, 10)));
1488
- C && (f = parseInt(C, 10));
1500
+ const T = k.find((re) => !isNaN(parseInt(re, 10)));
1501
+ T && (f = parseInt(T, 10));
1489
1502
  }
1490
1503
  }
1491
- const $ = I.indexOf(O.VALUES.NATIVE);
1492
- if ($ !== -1) {
1493
- const D = I[$ + 1];
1494
- if (D && !isNaN(parseInt(D, 10)))
1495
- w = parseInt(D, 10);
1504
+ const j = k.indexOf(O.VALUES.NATIVE);
1505
+ if (j !== -1) {
1506
+ const A = k[j + 1];
1507
+ if (A && !isNaN(parseInt(A, 10)))
1508
+ E = parseInt(A, 10);
1496
1509
  else if (!p) {
1497
- const C = I.find((ee) => !isNaN(parseInt(ee, 10)));
1498
- C && (w = parseInt(C, 10));
1510
+ const T = k.find((re) => !isNaN(parseInt(re, 10)));
1511
+ T && (E = parseInt(T, 10));
1499
1512
  }
1500
1513
  }
1501
- if (H) {
1502
- const D = f + 1;
1503
- if (D < r)
1514
+ if (P) {
1515
+ const A = f + 1;
1516
+ if (A < r)
1504
1517
  throw new Error(
1505
1518
  `[MirageEngine] Traveler layer (${f}) cannot be smaller than inherited capture layer (${r - 1}).`
1506
1519
  );
1507
- r = Math.min(D, O.MAX_LAYERS + 1);
1520
+ r = Math.min(A, O.MAX_LAYERS + 1);
1508
1521
  }
1509
1522
  }
1510
- const L = o.dataset[Ve.KEY];
1511
- let M;
1512
- L && (M = JSON.parse(L));
1513
- const T = o.getBoundingClientRect(), E = window.getComputedStyle(o);
1514
- if (T.width === 0 || T.height === 0 || E.display === "none")
1523
+ const M = o.dataset[Ve.KEY];
1524
+ let L;
1525
+ M && (L = JSON.parse(M));
1526
+ const R = o.getBoundingClientRect(), C = window.getComputedStyle(o);
1527
+ if (R.width === 0 || R.height === 0 || C.display === "none")
1515
1528
  return null;
1516
1529
  let S = o.getAttribute("data-mid");
1517
1530
  S || (S = Math.random().toString(36).substring(2, 11), o.setAttribute("data-mid", S));
1518
- const x = parseInt(E.zIndex), R = (isNaN(x) ? 0 : x) + i;
1519
- let A;
1531
+ const w = parseInt(C.zIndex), B = (isNaN(w) ? 0 : w) + i;
1532
+ let _;
1520
1533
  if (o.tagName === "IMG")
1521
- A = o.src;
1534
+ _ = o.src;
1522
1535
  else if (o.tagName.toLowerCase() === "svg") {
1523
- const f = o.cloneNode(!0), b = m == null ? void 0 : m.color, k = m == null ? void 0 : m.fill, F = m == null ? void 0 : m.stroke, I = m == null ? void 0 : m.opacity, H = (C, ee) => {
1524
- const X = window.getComputedStyle(C), oe = ee, Be = X.fill === X.color, Fe = X.stroke === X.color, fe = k || (Be ? b : void 0) || X.fill;
1536
+ const f = o.cloneNode(!0), x = m == null ? void 0 : m.color, D = m == null ? void 0 : m.fill, F = m == null ? void 0 : m.stroke, k = m == null ? void 0 : m.opacity, P = (T, re) => {
1537
+ const Y = window.getComputedStyle(T), oe = re, Fe = Y.fill === Y.color, Be = Y.stroke === Y.color, fe = D || (Fe ? x : void 0) || Y.fill;
1525
1538
  fe && fe !== "none" && (oe.style.fill = fe);
1526
- const ge = F || (Fe ? b : void 0) || X.stroke;
1527
- ge && ge !== "none" && (oe.style.stroke = ge), X.strokeWidth && X.strokeWidth !== "0px" && (oe.style.strokeWidth = X.strokeWidth);
1528
- const be = b || X.color;
1539
+ const ge = F || (Be ? x : void 0) || Y.stroke;
1540
+ ge && ge !== "none" && (oe.style.stroke = ge), Y.strokeWidth && Y.strokeWidth !== "0px" && (oe.style.strokeWidth = Y.strokeWidth);
1541
+ const be = x || Y.color;
1529
1542
  be && (oe.style.color = be);
1530
- const pe = I || X.opacity;
1543
+ const pe = k || Y.opacity;
1531
1544
  pe && pe !== "1" && (oe.style.opacity = pe);
1532
- for (let he = 0; he < C.children.length; he++)
1533
- H(C.children[he], ee.children[he]);
1545
+ for (let he = 0; he < T.children.length; he++)
1546
+ P(T.children[he], re.children[he]);
1534
1547
  };
1535
- H(o, f);
1536
- const z = o.getBoundingClientRect(), $ = window.devicePixelRatio * l;
1537
- f.hasAttribute("viewBox") || f.setAttribute("viewBox", `0 0 ${z.width} ${z.height}`), f.setAttribute("width", (z.width * $).toString()), f.setAttribute("height", (z.height * $).toString());
1538
- let D = new XMLSerializer().serializeToString(f);
1539
- D.includes("xmlns=") || (D = D.replace(
1548
+ P(o, f);
1549
+ const z = o.getBoundingClientRect(), j = window.devicePixelRatio * l;
1550
+ f.hasAttribute("viewBox") || f.setAttribute("viewBox", `0 0 ${z.width} ${z.height}`), f.setAttribute("width", (z.width * j).toString()), f.setAttribute("height", (z.height * j).toString());
1551
+ let A = new XMLSerializer().serializeToString(f);
1552
+ A.includes("xmlns=") || (A = A.replace(
1540
1553
  "<svg",
1541
1554
  '<svg xmlns="http://www.w3.org/2000/svg"'
1542
- )), A = `data:image/svg+xml;utf8,${encodeURIComponent(D)}`;
1543
- } else if (E.backgroundImage && E.backgroundImage !== "none") {
1544
- const f = E.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
1545
- f && (A = f[1]);
1546
- }
1547
- const U = {
1548
- backgroundColor: E.backgroundColor,
1549
- backgroundImage: E.backgroundImage,
1550
- opacity: o.dataset[q.KEY] === q.VALUES.HIDE ? 1 : parseFloat(E.opacity),
1551
- zIndex: R,
1552
- borderRadius: E.borderRadius,
1553
- borderColor: E.borderColor,
1554
- borderWidth: E.borderWidth,
1555
- imageSrc: A,
1555
+ )), _ = `data:image/svg+xml;utf8,${encodeURIComponent(A)}`;
1556
+ } else if (C.backgroundImage && C.backgroundImage !== "none") {
1557
+ const f = C.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
1558
+ f && (_ = f[1]);
1559
+ }
1560
+ const b = {
1561
+ backgroundColor: C.backgroundColor,
1562
+ backgroundImage: C.backgroundImage,
1563
+ opacity: o.dataset[K.KEY] === K.VALUES.HIDE ? 1 : parseFloat(C.opacity),
1564
+ zIndex: B,
1565
+ borderRadius: C.borderRadius,
1566
+ borderColor: C.borderColor,
1567
+ borderWidth: C.borderWidth,
1568
+ imageSrc: _,
1556
1569
  isTraveler: p
1557
- }, G = U;
1558
- let ie, se;
1559
- const _ = [];
1570
+ }, U = b;
1571
+ let $, q;
1572
+ const N = [];
1560
1573
  return o.tagName.toLowerCase() !== "svg" && Array.from(o.childNodes).forEach((f) => {
1561
- const b = f.nodeType === Node.TEXT_NODE ? h : d, k = Ue(
1574
+ const x = f.nodeType === Node.TEXT_NODE ? h : d, D = Ue(
1562
1575
  f,
1563
1576
  e,
1564
- b,
1577
+ x,
1565
1578
  r,
1566
- R,
1579
+ B,
1567
1580
  l,
1568
- f.nodeType === Node.TEXT_NODE ? w : void 0,
1581
+ f.nodeType === Node.TEXT_NODE ? E : void 0,
1569
1582
  f.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0
1570
1583
  );
1571
- k && _.push(k);
1584
+ D && N.push(D);
1572
1585
  }), {
1573
1586
  id: S,
1574
1587
  type: "BOX",
1575
1588
  element: o,
1576
1589
  rect: {
1577
- x: T.left + window.scrollX,
1578
- y: T.top + window.scrollY,
1579
- width: T.width,
1580
- height: T.height
1590
+ x: R.left + window.scrollX,
1591
+ y: R.top + window.scrollY,
1592
+ width: R.width,
1593
+ height: R.height
1581
1594
  },
1582
- styles: G,
1583
- textContent: ie,
1584
- textStyles: se,
1595
+ styles: U,
1596
+ textContent: $,
1597
+ textStyles: q,
1585
1598
  dirtyMask: e,
1586
1599
  visibility: h,
1587
1600
  isTraveler: p,
1588
1601
  captureLayer: r,
1589
- nativeLayer: w,
1590
- nativeStyles: w !== void 0 ? xe(j({}, U), {
1591
- backgroundColor: (N = m.backgroundColor) != null ? N : U.backgroundColor,
1592
- backgroundImage: (J = m.backgroundImage) != null ? J : U.backgroundImage,
1593
- opacity: (Q = m.opacity) != null ? Q : U.opacity,
1594
- zIndex: m.zIndex !== void 0 ? m.zIndex + R : U.zIndex,
1595
- borderRadius: (Z = m.borderRadius) != null ? Z : U.borderRadius,
1596
- borderColor: (ne = m.borderColor) != null ? ne : U.borderColor,
1597
- borderWidth: (ae = m.borderWidth) != null ? ae : U.borderWidth,
1598
- isTraveler: U.isTraveler,
1602
+ nativeLayer: E,
1603
+ nativeStyles: E !== void 0 ? xe(J({}, b), {
1604
+ backgroundColor: (X = m.backgroundColor) != null ? X : b.backgroundColor,
1605
+ backgroundImage: (Z = m.backgroundImage) != null ? Z : b.backgroundImage,
1606
+ opacity: (ee = m.opacity) != null ? ee : b.opacity,
1607
+ zIndex: m.zIndex !== void 0 ? m.zIndex + B : b.zIndex,
1608
+ borderRadius: (te = m.borderRadius) != null ? te : b.borderRadius,
1609
+ borderColor: (ne = m.borderColor) != null ? ne : b.borderColor,
1610
+ borderWidth: (ae = m.borderWidth) != null ? ae : b.borderWidth,
1611
+ isTraveler: b.isTraveler,
1599
1612
  transform: m.transform
1600
1613
  }) : void 0,
1601
- nativeRect: w !== void 0 ? {
1602
- x: m.x !== void 0 ? parseFloat(m.x) : T.left + window.scrollX,
1603
- y: m.y !== void 0 ? parseFloat(m.y) : T.top + window.scrollY,
1604
- width: m.width !== void 0 ? parseFloat(m.width) : T.width,
1605
- height: m.height !== void 0 ? parseFloat(m.height) : T.height
1614
+ nativeRect: E !== void 0 ? {
1615
+ x: m.x !== void 0 ? parseFloat(m.x) : R.left + window.scrollX,
1616
+ y: m.y !== void 0 ? parseFloat(m.y) : R.top + window.scrollY,
1617
+ width: m.width !== void 0 ? parseFloat(m.width) : R.width,
1618
+ height: m.height !== void 0 ? parseFloat(m.height) : R.height
1606
1619
  } : void 0,
1607
- isFixed: E.position === "fixed",
1608
- children: _,
1609
- shaderHooks: M
1620
+ isFixed: C.position === "fixed",
1621
+ children: N,
1622
+ shaderHooks: L
1610
1623
  };
1611
1624
  }
1612
1625
  function st(s, e) {
1613
1626
  e.size !== 0 && e.forEach((t, r) => {
1614
1627
  var l, n, a, o;
1615
1628
  const i = s.get(r);
1616
- !i || !i.userData.basePosition || (Y.forceUpdateUniforms(i.material, {
1629
+ !i || !i.userData.basePosition || (V.forceUpdateUniforms(i.material, {
1617
1630
  backgroundColor: t.backgroundColor,
1618
1631
  backgroundImage: t.backgroundImage,
1619
1632
  opacity: t.opacity,
1620
1633
  borderRadius: (n = t.borderRadius) != null ? n : (l = i.userData.baseStyles) == null ? void 0 : l.borderRadius
1621
1634
  // width and height are no longer updated here, they are updated in syncMeshesByDOM
1622
- }), i.userData.nativeMesh && Y.forceUpdateUniforms(i.userData.nativeMesh.material, {
1635
+ }), i.userData.nativeMesh && V.forceUpdateUniforms(i.userData.nativeMesh.material, {
1623
1636
  backgroundColor: t.backgroundColor,
1624
1637
  backgroundImage: t.backgroundImage,
1625
1638
  opacity: t.opacity,
@@ -1641,7 +1654,7 @@ class nt {
1641
1654
  const o = Ue(
1642
1655
  this.target,
1643
1656
  l,
1644
- W,
1657
+ H,
1645
1658
  1,
1646
1659
  0,
1647
1660
  this.renderer.qualityFactor
@@ -1695,7 +1708,7 @@ class ot {
1695
1708
  if (this.target = e, this.registry = new at(), !document.getElementById("mirage-engine-styles")) {
1696
1709
  const a = document.createElement("style");
1697
1710
  a.id = "mirage-engine-styles", a.textContent = `
1698
- [${q.NAME}="${q.VALUES.HIDE}"] {
1711
+ [${K.NAME}="${K.VALUES.HIDE}"] {
1699
1712
  opacity: 0 !important;
1700
1713
  }
1701
1714
  `, document.head.appendChild(a);