@mirage-engine/core 0.3.17 → 0.3.19

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,34 +1,34 @@
1
- var Oe = Object.defineProperty, Xe = Object.defineProperties;
2
- var _e = Object.getOwnPropertyDescriptors;
3
- var xe = Object.getOwnPropertySymbols;
4
- var Ne = Object.prototype.hasOwnProperty, ze = Object.prototype.propertyIsEnumerable;
5
- var ve = (r, e, t) => e in r ? Oe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, te = (r, e) => {
1
+ var Xe = Object.defineProperty, Ne = Object.defineProperties;
2
+ var ze = Object.getOwnPropertyDescriptors;
3
+ var Ee = Object.getOwnPropertySymbols;
4
+ var Ve = Object.prototype.hasOwnProperty, Ye = Object.prototype.propertyIsEnumerable;
5
+ var be = (i, e, t) => e in i ? Xe(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, te = (i, e) => {
6
6
  for (var t in e || (e = {}))
7
- Ne.call(e, t) && ve(r, t, e[t]);
8
- if (xe)
9
- for (var t of xe(e))
10
- ze.call(e, t) && ve(r, t, e[t]);
11
- return r;
12
- }, Se = (r, e) => Xe(r, _e(e));
13
- var p = (r, e, t) => (ve(r, typeof e != "symbol" ? e + "" : e, t), t);
14
- var Ee = (r, e, t) => new Promise((i, s) => {
15
- var c = (n) => {
7
+ Ve.call(e, t) && be(i, t, e[t]);
8
+ if (Ee)
9
+ for (var t of Ee(e))
10
+ Ye.call(e, t) && be(i, t, e[t]);
11
+ return i;
12
+ }, Ce = (i, e) => Ne(i, ze(e));
13
+ var g = (i, e, t) => (be(i, typeof e != "symbol" ? e + "" : e, t), t);
14
+ var Te = (i, e, t) => new Promise((r, s) => {
15
+ var c = (l) => {
16
16
  try {
17
- a(t.next(n));
18
- } catch (l) {
19
- s(l);
17
+ a(t.next(l));
18
+ } catch (n) {
19
+ s(n);
20
20
  }
21
- }, o = (n) => {
21
+ }, o = (l) => {
22
22
  try {
23
- a(t.throw(n));
24
- } catch (l) {
25
- s(l);
23
+ a(t.throw(l));
24
+ } catch (n) {
25
+ s(n);
26
26
  }
27
- }, a = (n) => n.done ? i(n.value) : Promise.resolve(n.value).then(c, o);
28
- a((t = t.apply(r, e)).next());
27
+ }, a = (l) => l.done ? r(l.value) : Promise.resolve(l.value).then(c, o);
28
+ a((t = t.apply(i, e)).next());
29
29
  });
30
30
  import * as w from "three";
31
- const De = {
31
+ const Ie = {
32
32
  INCLUDE_TREE: "include-tree",
33
33
  EXCLUDE_TREE: "exclude-tree",
34
34
  INCLUDE_SELF: "include-self",
@@ -41,7 +41,7 @@ const De = {
41
41
  HIDE: "hide",
42
42
  SHOW: "show"
43
43
  }
44
- }, Ce = {
44
+ }, Re = {
45
45
  TRAVELER: "traveler",
46
46
  NATIVE: "native",
47
47
  CAPTURE_1: "1",
@@ -54,31 +54,31 @@ const De = {
54
54
  CAPTURE_8: "8",
55
55
  CAPTURE_9: "9",
56
56
  CAPTURE_10: "10"
57
- }, _ = {
57
+ }, N = {
58
58
  NAME: "data-mirage-travel",
59
59
  KEY: "mirageTravel",
60
- VALUES: Ce,
61
- MAX_LAYERS: Object.keys(Ce).length - 1
62
- }, G = {
60
+ VALUES: Re,
61
+ MAX_LAYERS: Object.keys(Re).length - 1
62
+ }, H = {
63
63
  NAME: "data-mirage-filter",
64
64
  KEY: "mirageFilter",
65
- VALUES: De
66
- }, j = {
65
+ VALUES: Ie
66
+ }, $ = {
67
67
  NAME: "data-mirage-select",
68
68
  KEY: "mirageSelect",
69
- VALUES: De
70
- }, Ve = {
69
+ VALUES: Ie
70
+ }, We = {
71
71
  NAME: "data-mirage-shader",
72
72
  KEY: "mirageShader"
73
- }, ct = {
73
+ }, dt = {
74
74
  NAME: "data-mirage-sandwich",
75
75
  KEY: "mirageSandwich",
76
76
  VALUES: {
77
77
  FRONT: "front"
78
78
  }
79
- }, ue = 0, re = 1, he = 2, Ye = 4, fe = 8, we = 16;
80
- function We(r) {
81
- const e = r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
79
+ }, ge = 0, re = 1, ue = 2, Pe = 4, pe = 8, ye = 16;
80
+ function He(i) {
81
+ const e = i.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
82
82
  return e ? {
83
83
  r: parseInt(e[1]) / 255,
84
84
  g: parseInt(e[2]) / 255,
@@ -86,46 +86,46 @@ function We(r) {
86
86
  a: e[4] !== void 0 ? parseFloat(e[4]) : 1
87
87
  } : { r: 1, g: 1, b: 1, a: 1 };
88
88
  }
89
- function Pe(r) {
89
+ function Ge(i) {
90
90
  const e = {};
91
- if (r.opacity && (e.opacity = parseFloat(r.opacity)), r.backgroundColor) {
92
- const t = We(r.backgroundColor);
91
+ if (i.opacity && (e.opacity = parseFloat(i.opacity)), i.backgroundColor) {
92
+ const t = He(i.backgroundColor);
93
93
  e.backgroundColor = [t.r, t.g, t.b, t.a];
94
94
  }
95
- if (r.backgroundImage ? e.backgroundImage = r.backgroundImage : r.background && (e.backgroundImage = r.background), r.boxShadow && (e.boxShadow = r.boxShadow), r.borderRadius && (e.borderRadius = parseFloat(r.borderRadius)), r.width && (e.width = parseFloat(r.width)), r.height && (e.height = parseFloat(r.height)), r.transform && r.transform !== "none") {
96
- const t = new DOMMatrix(r.transform);
95
+ if (i.backgroundImage ? e.backgroundImage = i.backgroundImage : i.background && (e.backgroundImage = i.background), i.boxShadow && (e.boxShadow = i.boxShadow), i.borderRadius && (e.borderRadius = parseFloat(i.borderRadius)), i.width && (e.width = parseFloat(i.width)), i.height && (e.height = parseFloat(i.height)), i.transform && i.transform !== "none") {
96
+ const t = new DOMMatrix(i.transform);
97
97
  e.x = t.m41, e.y = t.m42, e.z = t.m43;
98
98
  }
99
99
  return e;
100
100
  }
101
- class He {
101
+ class qe {
102
102
  constructor(e, t) {
103
- p(this, "target");
104
- p(this, "observer");
105
- p(this, "pendingDeletions", /* @__PURE__ */ new Set());
106
- p(this, "pendingStyles", /* @__PURE__ */ new Map());
107
- p(this, "isDomDirty", !1);
108
- p(this, "isRunning", !1);
109
- p(this, "pendingMask", ue);
110
- p(this, "mutationTimer", null);
111
- p(this, "cssTimer", null);
112
- p(this, "resizeConfig");
113
- p(this, "resizeTimer", null);
114
- p(this, "isResizing", !1);
115
- p(this, "lastScrollX", 0);
116
- p(this, "lastScrollY", 0);
117
- p(this, "scrollTimer", null);
118
- p(this, "onBeforeRender", /* @__PURE__ */ new Set());
119
- p(this, "onLayoutChange", /* @__PURE__ */ new Set());
120
- p(this, "onStyleChange", /* @__PURE__ */ new Set());
121
- p(this, "onScrollChange", /* @__PURE__ */ new Set());
122
- p(this, "onRender", /* @__PURE__ */ new Set());
123
- p(this, "onTransitionFinished", (e) => {
124
- this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= re | he, this.cssTimer = window.setTimeout(() => {
103
+ g(this, "target");
104
+ g(this, "observer");
105
+ g(this, "pendingDeletions", /* @__PURE__ */ new Set());
106
+ g(this, "pendingStyles", /* @__PURE__ */ new Map());
107
+ g(this, "isDomDirty", !1);
108
+ g(this, "isRunning", !1);
109
+ g(this, "pendingMask", ge);
110
+ g(this, "mutationTimer", null);
111
+ g(this, "cssTimer", null);
112
+ g(this, "resizeConfig");
113
+ g(this, "resizeTimer", null);
114
+ g(this, "isResizing", !1);
115
+ g(this, "lastScrollX", 0);
116
+ g(this, "lastScrollY", 0);
117
+ g(this, "scrollTimer", null);
118
+ g(this, "onBeforeRender", /* @__PURE__ */ new Set());
119
+ g(this, "onLayoutChange", /* @__PURE__ */ new Set());
120
+ g(this, "onStyleChange", /* @__PURE__ */ new Set());
121
+ g(this, "onScrollChange", /* @__PURE__ */ new Set());
122
+ g(this, "onRender", /* @__PURE__ */ new Set());
123
+ g(this, "onTransitionFinished", (e) => {
124
+ this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= re | ue, this.cssTimer = window.setTimeout(() => {
125
125
  this.isDomDirty = !0, this.cssTimer = null;
126
126
  }, 50)));
127
127
  });
128
- p(this, "onWindowResize", () => {
128
+ g(this, "onWindowResize", () => {
129
129
  if (!this.resizeConfig.enabled) {
130
130
  this.isDomDirty = !0;
131
131
  return;
@@ -134,41 +134,41 @@ class He {
134
134
  this.isDomDirty = !0, this.resizeConfig.onEnd && this.resizeConfig.onEnd(), this.isResizing = !1, this.resizeTimer = null;
135
135
  }, this.resizeConfig.delay);
136
136
  });
137
- p(this, "renderLoop", () => {
137
+ g(this, "renderLoop", () => {
138
138
  if (!this.isRunning)
139
139
  return;
140
- this.onBeforeRender.forEach((i) => i()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((i) => i(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = ue);
140
+ this.onBeforeRender.forEach((r) => r()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((r) => r(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = ge);
141
141
  const e = window.scrollX, t = window.scrollY;
142
- (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(() => {
142
+ (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(() => {
143
143
  this.pendingMask |= re, this.isDomDirty = !0, this.scrollTimer = null;
144
- }, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((i) => i(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((i) => i()), requestAnimationFrame(this.renderLoop);
144
+ }, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
145
145
  });
146
146
  var s, c;
147
147
  this.target = e;
148
- const i = (s = t.resizeDebounce) != null ? s : !0;
149
- i === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : i === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
148
+ const r = (s = t.resizeDebounce) != null ? s : !0;
149
+ r === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : r === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
150
150
  enabled: !0,
151
- delay: (c = i.delay) != null ? c : 150,
152
- onStart: i.onStart,
153
- onEnd: i.onEnd
151
+ delay: (c = r.delay) != null ? c : 150,
152
+ onStart: r.onStart,
153
+ onEnd: r.onEnd
154
154
  }, this.observer = new MutationObserver((o) => {
155
- let a = ue;
156
- for (const n of o)
157
- if (n.type === "childList")
158
- a |= fe, n.removedNodes.length > 0 && n.removedNodes.forEach((l) => {
159
- l instanceof HTMLElement && this.pendingDeletions.add(l);
155
+ let a = ge;
156
+ for (const l of o)
157
+ if (l.type === "childList")
158
+ a |= pe, l.removedNodes.length > 0 && l.removedNodes.forEach((n) => {
159
+ n instanceof HTMLElement && this.pendingDeletions.add(n);
160
160
  });
161
- else if (n.type === "attributes")
162
- if (n.attributeName === "style") {
163
- a |= re | he;
164
- const l = n.target, d = Pe(l.style);
165
- this.pendingStyles.set(l, d);
161
+ else if (l.type === "attributes")
162
+ if (l.attributeName === "style") {
163
+ a |= re | ue;
164
+ const n = l.target, u = Ge(n.style);
165
+ this.pendingStyles.set(n, u);
166
166
  } else
167
- n.attributeName === "class" ? a |= re | he : n.attributeName && n.attributeName.startsWith("data-") && (a |= re | he, n.attributeName.startsWith("data-mirage") && (a |= fe));
167
+ l.attributeName === "class" ? a |= re | ue : l.attributeName && l.attributeName.startsWith("data-") && (a |= re | ue, l.attributeName.startsWith("data-mirage") && (a |= pe));
168
168
  else
169
- n.type === "characterData" && (a |= we | re);
170
- if (a !== ue) {
171
- if (this.pendingMask |= a, a & fe) {
169
+ l.type === "characterData" && (a |= ye | re);
170
+ if (a !== ge) {
171
+ if (this.pendingMask |= a, a & pe) {
172
172
  this.clearTimers(), this.isDomDirty = !0;
173
173
  return;
174
174
  }
@@ -193,13 +193,13 @@ class He {
193
193
  this.mutationTimer && (clearTimeout(this.mutationTimer), this.mutationTimer = null), this.cssTimer && (clearTimeout(this.cssTimer), this.cssTimer = null), this.scrollTimer && (clearTimeout(this.scrollTimer), this.scrollTimer = null);
194
194
  }
195
195
  }
196
- const q = 1, ae = 2, ht = 0, B = {
196
+ const G = 1, ae = 2, ut = 0, F = {
197
197
  BASE: 0,
198
198
  SELECTED: 1,
199
- getCaptureLayer: (r) => 31 - r,
199
+ getCaptureLayer: (i) => 31 - i,
200
200
  HIDDEN: 31
201
- }, Te = Object.values(G.VALUES);
202
- class Ae {
201
+ }, Me = Object.values(H.VALUES);
202
+ class ke {
203
203
  /**
204
204
  * Calculates or retrieves the exact alphabetic baseline (in pixels) for the given font.
205
205
  * @param font CSS font shorthand string (e.g., "400 16px Inter")
@@ -214,28 +214,28 @@ class Ae {
214
214
  static calculateBaselineFromDOM(e) {
215
215
  if (typeof document == "undefined")
216
216
  return 0;
217
- const t = document.createElement("div"), i = document.createElement("span"), s = document.createElement("img");
218
- 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", s.width = 1, s.height = 1, s.style.verticalAlign = "baseline", i.appendChild(document.createTextNode("Hidden Text")), t.appendChild(i), t.appendChild(s), document.body.appendChild(t);
219
- const c = s.offsetTop - i.offsetTop;
217
+ const t = document.createElement("div"), r = document.createElement("span"), s = document.createElement("img");
218
+ 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", s.width = 1, s.height = 1, s.style.verticalAlign = "baseline", r.appendChild(document.createTextNode("Hidden Text")), t.appendChild(r), t.appendChild(s), document.body.appendChild(t);
219
+ const c = s.offsetTop - r.offsetTop;
220
220
  return document.body.removeChild(t), c;
221
221
  }
222
222
  }
223
- p(Ae, "cache", /* @__PURE__ */ new Map());
224
- class Ge extends w.MeshBasicMaterial {
225
- constructor(t, i, s, c, o = 2) {
223
+ g(ke, "cache", /* @__PURE__ */ new Map());
224
+ class $e extends w.MeshBasicMaterial {
225
+ constructor(t, r, s, c, o = 2) {
226
226
  super({
227
227
  transparent: !0,
228
228
  side: w.FrontSide,
229
229
  color: 16777215
230
230
  });
231
- p(this, "canvas");
232
- p(this, "ctx");
233
- p(this, "qualityFactor");
231
+ g(this, "canvas");
232
+ g(this, "ctx");
233
+ g(this, "qualityFactor");
234
234
  if (this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d"), !this.ctx)
235
235
  throw new Error("[Mirage] Failed to create canvas context");
236
- this.qualityFactor = o, this.map = new w.CanvasTexture(this.canvas), this.map.colorSpace = w.LinearSRGBColorSpace, this.map.minFilter = w.LinearFilter, this.map.magFilter = w.LinearFilter, this.updateText(t, i, s, c);
236
+ this.qualityFactor = o, this.map = new w.CanvasTexture(this.canvas), this.map.colorSpace = w.LinearSRGBColorSpace, this.map.minFilter = w.LinearFilter, this.map.magFilter = w.LinearFilter, this.updateText(t, r, s, c);
237
237
  }
238
- wrapText(t, i) {
238
+ wrapText(t, r) {
239
239
  const s = t.split(`
240
240
  `), c = [];
241
241
  return s.forEach((o) => {
@@ -244,57 +244,57 @@ class Ge extends w.MeshBasicMaterial {
244
244
  c.push("");
245
245
  return;
246
246
  }
247
- let n = a[0];
248
- for (let l = 1; l < a.length; l++) {
249
- const d = a[l];
250
- this.ctx.measureText(n + d).width <= i + 2 ? n += d : (n && c.push(n), n = d.trimStart());
247
+ let l = a[0];
248
+ for (let n = 1; n < a.length; n++) {
249
+ const u = a[n];
250
+ this.ctx.measureText(l + u).width <= r + 2 ? l += u : (l && c.push(l), l = u.trimStart());
251
251
  }
252
- n && c.push(n);
252
+ l && c.push(l);
253
253
  }), c;
254
254
  }
255
- updateText(t, i, s, c, o) {
255
+ updateText(t, r, s, c, o) {
256
256
  o !== void 0 && (this.qualityFactor = o);
257
- const n = (window.devicePixelRatio || 1) * this.qualityFactor, l = s * n, d = c * n;
258
- 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(n, 0, 0, n, 0, 0), this.ctx.font = i.font, this.ctx.fillStyle = i.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
259
- const h = this.wrapText(t, s), u = i.lineHeight, f = Ae.getBaseline(i.font);
260
- h.forEach((g, v) => {
261
- const b = v * u + f;
262
- let C = 0;
263
- i.textAlign === "center" ? C = s / 2 : i.textAlign === "right" && (C = s), this.ctx.textAlign = i.textAlign, this.ctx.fillText(g, C, b);
257
+ const l = (window.devicePixelRatio || 1) * this.qualityFactor, n = s * l, u = c * l;
258
+ this.canvas.width !== n || this.canvas.height !== u ? (this.canvas.width = n, this.canvas.height = u) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(l, 0, 0, l, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
259
+ const h = this.wrapText(t, s), d = r.lineHeight, p = ke.getBaseline(r.font);
260
+ h.forEach((f, L) => {
261
+ const m = L * d + p;
262
+ let b = 0;
263
+ r.textAlign === "center" ? b = s / 2 : r.textAlign === "right" && (b = s), this.ctx.textAlign = r.textAlign, this.ctx.fillText(f, b, m);
264
264
  }), this.map && (this.map.needsUpdate = !0);
265
265
  }
266
266
  dispose() {
267
267
  this.map && this.map.dispose(), super.dispose();
268
268
  }
269
269
  }
270
- function ne(r, e = 0) {
271
- if (typeof r == "number")
272
- return r;
273
- const t = parseFloat(r) || 0;
274
- return typeof r == "string" && r.includes("%") ? t / 100 * e : t;
270
+ function le(i, e = 0) {
271
+ if (typeof i == "number")
272
+ return i;
273
+ const t = parseFloat(i) || 0;
274
+ return typeof i == "string" && i.includes("%") ? t / 100 * e : t;
275
275
  }
276
- function le(r) {
277
- if (!r || r === "transparent")
276
+ function ce(i) {
277
+ if (!i || i === "transparent")
278
278
  return { color: new w.Color(16777215), alpha: 0 };
279
- const e = r.match(
279
+ const e = i.match(
280
280
  /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
281
281
  );
282
282
  if (e) {
283
- const t = parseInt(e[1], 10), i = parseInt(e[2], 10), s = parseInt(e[3], 10), c = e[4] !== void 0 ? parseFloat(e[4]) : 1;
284
- return { color: new w.Color(`rgb(${t}, ${i}, ${s})`), alpha: c };
283
+ const t = parseInt(e[1], 10), r = parseInt(e[2], 10), s = parseInt(e[3], 10), c = e[4] !== void 0 ? parseFloat(e[4]) : 1;
284
+ return { color: new w.Color(`rgb(${t}, ${r}, ${s})`), alpha: c };
285
285
  }
286
- return { color: new w.Color(r), alpha: 1 };
286
+ return { color: new w.Color(i), alpha: 1 };
287
287
  }
288
- function Ie(r) {
288
+ function Ue(i) {
289
289
  const e = [];
290
- let t = "", i = 0;
291
- for (let s = 0; s < r.length; s++) {
292
- const c = r[s];
290
+ let t = "", r = 0;
291
+ for (let s = 0; s < i.length; s++) {
292
+ const c = i[s];
293
293
  if (c === "(")
294
- i++;
294
+ r++;
295
295
  else if (c === ")")
296
- i--;
297
- else if (c === "," && i === 0) {
296
+ r--;
297
+ else if (c === "," && r === 0) {
298
298
  e.push(t.trim()), t = "";
299
299
  continue;
300
300
  }
@@ -302,78 +302,78 @@ function Ie(r) {
302
302
  }
303
303
  return t && e.push(t.trim()), e;
304
304
  }
305
- function qe(r) {
306
- if (!r || typeof r != "string" || !r.includes("linear-gradient"))
305
+ function je(i) {
306
+ if (!i || typeof i != "string" || !i.includes("linear-gradient"))
307
307
  return null;
308
- const e = r.match(/linear-gradient\((.*)\)/);
308
+ const e = i.match(/linear-gradient\((.*)\)/);
309
309
  if (!e)
310
310
  return null;
311
- const t = e[1], i = Ie(t);
311
+ const t = e[1], r = Ue(t);
312
312
  let s = Math.PI, c = 0;
313
- const o = i[0].trim();
313
+ const o = r[0].trim();
314
314
  if (o.startsWith("to "))
315
315
  o === "to top" ? s = 0 : o === "to right" ? s = Math.PI / 2 : o === "to bottom" ? s = Math.PI : o === "to left" ? s = Math.PI * 1.5 : o === "to top right" || o === "to right top" ? s = Math.PI / 4 : o === "to bottom right" || o === "to right bottom" ? s = Math.PI * 0.75 : o === "to bottom left" || o === "to left bottom" ? s = Math.PI * 1.25 : (o === "to top left" || o === "to left top") && (s = Math.PI * 1.75), c = 1;
316
316
  else if (o.endsWith("deg") || o.endsWith("rad") || o.endsWith("turn")) {
317
- const n = parseFloat(o);
318
- o.endsWith("deg") ? s = n * (Math.PI / 180) : o.endsWith("rad") ? s = n : o.endsWith("turn") && (s = n * Math.PI * 2), c = 1;
317
+ const l = parseFloat(o);
318
+ o.endsWith("deg") ? s = l * (Math.PI / 180) : o.endsWith("rad") ? s = l : o.endsWith("turn") && (s = l * Math.PI * 2), c = 1;
319
319
  }
320
320
  const a = [];
321
- for (let n = c; n < i.length && !(a.length >= 8); n++) {
322
- const l = i[n].trim(), d = l.lastIndexOf(" ");
323
- let h = l, u = null;
324
- if (d !== -1 && !l.endsWith(")")) {
325
- const g = l.substring(d + 1);
326
- (g.endsWith("%") || g.endsWith("px") || !isNaN(parseFloat(g))) && (h = l.substring(0, d).trim(), u = g);
321
+ for (let l = c; l < r.length && !(a.length >= 8); l++) {
322
+ const n = r[l].trim(), u = n.lastIndexOf(" ");
323
+ let h = n, d = null;
324
+ if (u !== -1 && !n.endsWith(")")) {
325
+ const f = n.substring(u + 1);
326
+ (f.endsWith("%") || f.endsWith("px") || !isNaN(parseFloat(f))) && (h = n.substring(0, u).trim(), d = f);
327
327
  }
328
- const f = le(h);
328
+ const p = ce(h);
329
329
  a.push({
330
- color: f.color,
331
- alpha: f.alpha,
332
- rawStop: u,
330
+ color: p.color,
331
+ alpha: p.alpha,
332
+ rawStop: d,
333
333
  stop: 0
334
334
  });
335
335
  }
336
336
  if (a.length > 0) {
337
- for (let l = 0; l < a.length; l++)
338
- a[l].rawStop !== null && (a[l].stop = parseFloat(a[l].rawStop) / 100);
337
+ for (let n = 0; n < a.length; n++)
338
+ a[n].rawStop !== null && (a[n].stop = parseFloat(a[n].rawStop) / 100);
339
339
  a[0].rawStop === null && (a[0].stop = 0), a.length > 1 && a[a.length - 1].rawStop === null && (a[a.length - 1].stop = 1);
340
- let n = 0;
341
- for (let l = 1; l < a.length; l++)
342
- if (a[l].rawStop !== null || l === a.length - 1) {
343
- const d = l - n;
344
- if (d > 1) {
345
- const h = a[n].stop, f = (a[l].stop - h) / d;
346
- for (let g = 1; g < d; g++)
347
- a[n + g].stop = h + f * g;
340
+ let l = 0;
341
+ for (let n = 1; n < a.length; n++)
342
+ if (a[n].rawStop !== null || n === a.length - 1) {
343
+ const u = n - l;
344
+ if (u > 1) {
345
+ const h = a[l].stop, p = (a[n].stop - h) / u;
346
+ for (let f = 1; f < u; f++)
347
+ a[l + f].stop = h + p * f;
348
348
  }
349
- n = l;
349
+ l = n;
350
350
  }
351
351
  }
352
352
  return { angle: s, stops: a };
353
353
  }
354
- function $e(r) {
355
- if (!r || r === "none")
354
+ function Ke(i) {
355
+ if (!i || i === "none")
356
356
  return null;
357
- const e = Ie(r);
357
+ const e = Ue(i);
358
358
  if (e.length === 0)
359
359
  return null;
360
- const t = e[0].trim(), i = /(rgba?\([^)]+\)|#[0-9a-fA-F]+|[a-zA-Z]+)/, s = t.match(i);
360
+ const t = e[0].trim(), r = /(rgba?\([^)]+\)|#[0-9a-fA-F]+|[a-zA-Z]+)/, s = t.match(r);
361
361
  let c = "transparent", o = t;
362
362
  if (s && s[1] !== "inset") {
363
- const f = s[1];
364
- (f.startsWith("rgb") || f.startsWith("#") || f === "black" || f === "white" || f === "transparent") && (c = f, o = t.replace(f, "").trim());
363
+ const p = s[1];
364
+ (p.startsWith("rgb") || p.startsWith("#") || p === "black" || p === "white" || p === "transparent") && (c = p, o = t.replace(p, "").trim());
365
365
  }
366
366
  o = o.replace("inset", "").trim();
367
- const a = o.split(/\s+/).map((f) => parseFloat(f) || 0), n = a[0] || 0, l = a[1] || 0, d = a[2] || 0, h = a[3] || 0, u = le(c);
368
- return { offsetX: n, offsetY: l, blurRadius: d, spreadRadius: h, color: u.color, alpha: u.alpha };
367
+ const a = o.split(/\s+/).map((p) => parseFloat(p) || 0), l = a[0] || 0, n = a[1] || 0, u = a[2] || 0, h = a[3] || 0, d = ce(c);
368
+ return { offsetX: l, offsetY: n, blurRadius: u, spreadRadius: h, color: d.color, alpha: d.alpha };
369
369
  }
370
- const je = `varying vec2 vUv;
370
+ const Je = `varying vec2 vUv;
371
371
  varying vec4 vScreenPos;
372
372
  void main() {
373
373
  vUv = uv;
374
374
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
375
375
  vScreenPos = gl_Position;
376
- }`, Ke = `varying vec2 vUv;
376
+ }`, Ze = `varying vec2 vUv;
377
377
  uniform vec2 uSize;
378
378
  uniform vec2 uMeshSize;
379
379
  uniform vec4 uShadowColor;
@@ -532,40 +532,40 @@ void main() {
532
532
 
533
533
  // #include <colorspace_fragment>
534
534
  }
535
- `, Je = `uniform sampler2D uTexture;
535
+ `, Qe = `uniform sampler2D uTexture;
536
536
  varying vec4 vScreenPos;
537
537
  uniform vec2 uTextureRepeat;
538
- uniform vec2 uTextureOffset;`, Ze = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
538
+ uniform vec2 uTextureOffset;`, et = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
539
539
  vec2 resultUv = screenUv;
540
540
 
541
- `, Qe = `vec4 texColor = texture2D(uTexture, resultUv);
542
- baseColor = blendSrcOver(baseColor, texColor);`, Re = {
543
- vertexShader: je,
544
- fragmentShader: Ke
545
- }, Me = {
546
- declChunk: Je,
547
- uvChunk: Ze,
548
- baseColorChunk: Qe
541
+ `, tt = `vec4 texColor = texture2D(uTexture, resultUv);
542
+ baseColor = blendSrcOver(baseColor, texColor);`, Le = {
543
+ vertexShader: Je,
544
+ fragmentShader: Ze
545
+ }, De = {
546
+ declChunk: Qe,
547
+ uvChunk: et,
548
+ baseColorChunk: tt
549
549
  };
550
- function et(r, e, t, i = null, s) {
551
- var S;
552
- const c = i !== null || !!r.imageSrc;
550
+ function rt(i, e, t, r = null, s) {
551
+ var C;
552
+ const c = r !== null || !!i.imageSrc;
553
553
  let o = "";
554
554
  const a = {};
555
555
  if (s != null && s.uniforms)
556
- for (const [R, E] of Object.entries(s.uniforms))
557
- typeof E == "number" ? (o += `uniform float ${R};
558
- `, a[R] = { value: E }) : Array.isArray(E) ? E.length === 2 ? (o += `uniform vec2 ${R};
559
- `, a[R] = { value: new w.Vector2(...E) }) : E.length === 3 ? (o += `uniform vec3 ${R};
560
- `, a[R] = { value: new w.Vector3(...E) }) : E.length === 4 && (o += `uniform vec4 ${R};
561
- `, a[R] = { value: new w.Vector4(...E) }) : (o += `uniform float ${R};
562
- `, a[R] = { value: E });
563
- const n = s !== void 0, l = (c || n ? Me.declChunk : "") + `
564
- ` + o, d = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
565
- `, h = r.isTraveler ? `vec2 resultUv = screenUv;
556
+ for (const [y, S] of Object.entries(s.uniforms))
557
+ typeof S == "number" ? (o += `uniform float ${y};
558
+ `, a[y] = { value: S }) : Array.isArray(S) ? S.length === 2 ? (o += `uniform vec2 ${y};
559
+ `, a[y] = { value: new w.Vector2(...S) }) : S.length === 3 ? (o += `uniform vec3 ${y};
560
+ `, a[y] = { value: new w.Vector3(...S) }) : S.length === 4 && (o += `uniform vec4 ${y};
561
+ `, a[y] = { value: new w.Vector4(...S) }) : (o += `uniform float ${y};
562
+ `, a[y] = { value: S });
563
+ const l = s !== void 0, n = (c || l ? De.declChunk : "") + `
564
+ ` + o, u = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
565
+ `, h = i.isTraveler ? `vec2 resultUv = screenUv;
566
566
  ` : `vec2 localUv = (p / uSize) + 0.5;
567
567
  vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
568
- `, u = c || n ? d + h + ((s == null ? void 0 : s.uvModifier) || "") : "", f = c || n ? Me.baseColorChunk : "", g = (s == null ? void 0 : s.colorModifier) || "", v = Re.fragmentShader.replace("#INJECT_DECLARATIONS", l).replace("#INJECT_UV_MODIFIER", u).replace("#INJECT_BASE_COLOR", f).replace("#INJECT_COLOR_MODIFIER", g), b = le(r.backgroundColor), C = le(r.borderColor), I = {
568
+ `, d = c || l ? u + h + ((s == null ? void 0 : s.uvModifier) || "") : "", p = c || l ? De.baseColorChunk : "", f = (s == null ? void 0 : s.colorModifier) || "", L = Le.fragmentShader.replace("#INJECT_DECLARATIONS", n).replace("#INJECT_UV_MODIFIER", d).replace("#INJECT_BASE_COLOR", p).replace("#INJECT_COLOR_MODIFIER", f), m = ce(i.backgroundColor), b = ce(i.borderColor), E = {
569
569
  uSize: { value: new w.Vector2(e, t) },
570
570
  uMeshSize: { value: new w.Vector2(e, t) },
571
571
  uShadowColor: { value: new w.Vector4(0, 0, 0, 0) },
@@ -574,23 +574,23 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
574
574
  uShadowSpread: { value: 0 },
575
575
  uBgColor: {
576
576
  value: new w.Vector4(
577
- b.color.r,
578
- b.color.g,
579
- b.color.b,
580
- b.alpha
577
+ m.color.r,
578
+ m.color.g,
579
+ m.color.b,
580
+ m.alpha
581
581
  )
582
582
  },
583
583
  uBorderColor: {
584
584
  value: new w.Vector4(
585
- C.color.r,
586
- C.color.g,
587
- C.color.b,
588
- C.alpha
585
+ b.color.r,
586
+ b.color.g,
587
+ b.color.b,
588
+ b.alpha
589
589
  )
590
590
  },
591
591
  uBorderRadius: { value: new w.Vector4(0, 0, 0, 0) },
592
- uBorderWidth: { value: ne(r.borderWidth) },
593
- uOpacity: { value: (S = r.opacity) != null ? S : 1 },
592
+ uBorderWidth: { value: le(i.borderWidth) },
593
+ uOpacity: { value: (C = i.opacity) != null ? C : 1 },
594
594
  uTexture: { value: null },
595
595
  uTextureRepeat: { value: new w.Vector2(1, 1) },
596
596
  uTextureOffset: { value: new w.Vector2(0, 0) },
@@ -601,22 +601,22 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
601
601
  },
602
602
  uGradientStops: { value: new Float32Array(8) }
603
603
  };
604
- ke(I.uBorderRadius.value, r.borderRadius, Math.min(e, t)), c && (I.uTexture.value = i);
605
- const D = new w.ShaderMaterial({
606
- uniforms: te(te({}, I), a),
607
- vertexShader: Re.vertexShader,
608
- fragmentShader: v,
604
+ Be(E.uBorderRadius.value, i.borderRadius, Math.min(e, t)), c && (E.uTexture.value = r);
605
+ const A = new w.ShaderMaterial({
606
+ uniforms: te(te({}, E), a),
607
+ vertexShader: Le.vertexShader,
608
+ fragmentShader: L,
609
609
  transparent: !0,
610
610
  side: w.FrontSide
611
611
  // for better performance
612
612
  });
613
- return r.backgroundImage && be(D, { backgroundImage: r.backgroundImage }), D;
613
+ return i.backgroundImage && xe(A, { backgroundImage: i.backgroundImage }), A;
614
614
  }
615
- function tt(r, e, t, i, s) {
616
- const c = ne(e.borderWidth);
617
- be(r, {
615
+ function it(i, e, t, r, s) {
616
+ const c = le(e.borderWidth);
617
+ xe(i, {
618
618
  width: t,
619
- height: i,
619
+ height: r,
620
620
  borderRadius: e.borderRadius,
621
621
  borderWidth: c,
622
622
  backgroundColor: e.backgroundColor,
@@ -627,40 +627,40 @@ function tt(r, e, t, i, s) {
627
627
  boxShadow: e.boxShadow
628
628
  });
629
629
  }
630
- function be(r, e) {
631
- var i, s, c;
630
+ function xe(i, e) {
631
+ var r, s, c;
632
632
  if (e.boxShadow !== void 0) {
633
- const o = $e(e.boxShadow);
634
- o ? (r.uniforms.uShadowColor.value.set(o.color.r, o.color.g, o.color.b, o.alpha), r.uniforms.uShadowOffset.value.set(o.offsetX, o.offsetY), r.uniforms.uShadowBlur.value = o.blurRadius, r.uniforms.uShadowSpread.value = o.spreadRadius, r.userData.shadowPadding = o.blurRadius + o.spreadRadius + Math.max(Math.abs(o.offsetX), Math.abs(o.offsetY))) : (r.uniforms.uShadowColor.value.w = 0, r.userData.shadowPadding = 0);
633
+ const o = Ke(e.boxShadow);
634
+ o ? (i.uniforms.uShadowColor.value.set(o.color.r, o.color.g, o.color.b, o.alpha), i.uniforms.uShadowOffset.value.set(o.offsetX, o.offsetY), i.uniforms.uShadowBlur.value = o.blurRadius, i.uniforms.uShadowSpread.value = o.spreadRadius, i.userData.shadowPadding = o.blurRadius + o.spreadRadius + Math.max(Math.abs(o.offsetX), Math.abs(o.offsetY))) : (i.uniforms.uShadowColor.value.w = 0, i.userData.shadowPadding = 0);
635
635
  }
636
- if (e.width !== void 0 && e.height !== void 0 && r.uniforms.uSize.value.set(e.width, e.height), r.uniforms.uMeshSize) {
637
- const o = r.userData.shadowPadding || 0, a = e.width !== void 0 ? e.width : r.uniforms.uSize.value.x, n = e.height !== void 0 ? e.height : r.uniforms.uSize.value.y;
638
- r.uniforms.uMeshSize.value.set(a + o * 2, n + o * 2);
636
+ if (e.width !== void 0 && e.height !== void 0 && i.uniforms.uSize.value.set(e.width, e.height), i.uniforms.uMeshSize) {
637
+ const o = i.userData.shadowPadding || 0, a = e.width !== void 0 ? e.width : i.uniforms.uSize.value.x, l = e.height !== void 0 ? e.height : i.uniforms.uSize.value.y;
638
+ i.uniforms.uMeshSize.value.set(a + o * 2, l + o * 2);
639
639
  }
640
640
  if (e.borderRadius !== void 0) {
641
- const o = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(r.uniforms.uSize.value.x, r.uniforms.uSize.value.y);
642
- ke(r.uniforms.uBorderRadius.value, e.borderRadius, o);
641
+ const o = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(i.uniforms.uSize.value.x, i.uniforms.uSize.value.y);
642
+ Be(i.uniforms.uBorderRadius.value, e.borderRadius, o);
643
643
  }
644
- if (e.borderWidth !== void 0 && (r.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
644
+ if (e.borderWidth !== void 0 && (i.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
645
645
  if (Array.isArray(e.backgroundColor)) {
646
- const o = e.backgroundColor[3] !== void 0 ? e.backgroundColor[3] : r.uniforms.uBgColor.value.w;
647
- r.uniforms.uBgColor.value.set(
646
+ const o = e.backgroundColor[3] !== void 0 ? e.backgroundColor[3] : i.uniforms.uBgColor.value.w;
647
+ i.uniforms.uBgColor.value.set(
648
648
  e.backgroundColor[0],
649
649
  e.backgroundColor[1],
650
650
  e.backgroundColor[2],
651
651
  o
652
652
  );
653
653
  } else if (typeof e.backgroundColor == "string") {
654
- const o = le(e.backgroundColor);
655
- r.uniforms.uBgColor.value.set(
654
+ const o = ce(e.backgroundColor);
655
+ i.uniforms.uBgColor.value.set(
656
656
  o.color.r,
657
657
  o.color.g,
658
658
  o.color.b,
659
659
  o.alpha
660
660
  );
661
661
  } else {
662
- const o = r.uniforms.uBgColor.value.w;
663
- r.uniforms.uBgColor.value.set(
662
+ const o = i.uniforms.uBgColor.value.w;
663
+ i.uniforms.uBgColor.value.set(
664
664
  e.backgroundColor.r,
665
665
  e.backgroundColor.g,
666
666
  e.backgroundColor.b,
@@ -669,129 +669,129 @@ function be(r, e) {
669
669
  }
670
670
  if (e.borderColor !== void 0)
671
671
  if (Array.isArray(e.borderColor)) {
672
- const o = r.uniforms.uBorderColor.value.w;
673
- r.uniforms.uBorderColor.value.set(
672
+ const o = i.uniforms.uBorderColor.value.w;
673
+ i.uniforms.uBorderColor.value.set(
674
674
  e.borderColor[0],
675
675
  e.borderColor[1],
676
676
  e.borderColor[2],
677
677
  o
678
678
  );
679
679
  } else if (typeof e.borderColor == "string") {
680
- const o = le(e.borderColor);
681
- r.uniforms.uBorderColor.value.set(
680
+ const o = ce(e.borderColor);
681
+ i.uniforms.uBorderColor.value.set(
682
682
  o.color.r,
683
683
  o.color.g,
684
684
  o.color.b,
685
685
  o.alpha
686
686
  );
687
687
  } else {
688
- const o = r.uniforms.uBorderColor.value.w;
689
- r.uniforms.uBorderColor.value.set(
688
+ const o = i.uniforms.uBorderColor.value.w;
689
+ i.uniforms.uBorderColor.value.set(
690
690
  e.borderColor.r,
691
691
  e.borderColor.g,
692
692
  e.borderColor.b,
693
693
  o
694
694
  );
695
695
  }
696
- e.opacity !== void 0 && (r.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (r.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (r.uniforms.uBorderColor.value.w = e.borderOpacity), r.uniforms.uTexture && e.texture !== void 0 && (r.uniforms.uTexture.value = e.texture);
697
- const t = e.texture !== void 0 ? e.texture : (i = r.uniforms.uTexture) == null ? void 0 : i.value;
696
+ e.opacity !== void 0 && (i.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (i.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (i.uniforms.uBorderColor.value.w = e.borderOpacity), i.uniforms.uTexture && e.texture !== void 0 && (i.uniforms.uTexture.value = e.texture);
697
+ const t = e.texture !== void 0 ? e.texture : (r = i.uniforms.uTexture) == null ? void 0 : r.value;
698
698
  if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
699
- const o = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, n = (s = e.width) != null ? s : r.uniforms.uSize.value.x, l = (c = e.height) != null ? c : r.uniforms.uSize.value.y;
700
- if (o && a && n && l) {
701
- const d = o / a, h = n / l;
702
- if (d > h) {
703
- const u = h / d;
704
- r.uniforms.uTextureRepeat.value.set(u, 1), r.uniforms.uTextureOffset.value.set((1 - u) / 2, 0);
699
+ const o = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, l = (s = e.width) != null ? s : i.uniforms.uSize.value.x, n = (c = e.height) != null ? c : i.uniforms.uSize.value.y;
700
+ if (o && a && l && n) {
701
+ const u = o / a, h = l / n;
702
+ if (u > h) {
703
+ const d = h / u;
704
+ i.uniforms.uTextureRepeat.value.set(d, 1), i.uniforms.uTextureOffset.value.set((1 - d) / 2, 0);
705
705
  } else {
706
- const u = d / h;
707
- r.uniforms.uTextureRepeat.value.set(1, u), r.uniforms.uTextureOffset.value.set(0, (1 - u) / 2);
706
+ const d = u / h;
707
+ i.uniforms.uTextureRepeat.value.set(1, d), i.uniforms.uTextureOffset.value.set(0, (1 - d) / 2);
708
708
  }
709
709
  }
710
710
  } else
711
- r.uniforms.uTextureRepeat && (r.uniforms.uTextureRepeat.value.set(1, 1), r.uniforms.uTextureOffset.value.set(0, 0));
711
+ i.uniforms.uTextureRepeat && (i.uniforms.uTextureRepeat.value.set(1, 1), i.uniforms.uTextureOffset.value.set(0, 0));
712
712
  if (e.backgroundImage !== void 0) {
713
- const o = qe(e.backgroundImage);
713
+ const o = je(e.backgroundImage);
714
714
  if (o) {
715
- r.uniforms.uGradientCount.value = o.stops.length, r.uniforms.uGradientAngle.value = o.angle;
715
+ i.uniforms.uGradientCount.value = o.stops.length, i.uniforms.uGradientAngle.value = o.angle;
716
716
  for (let a = 0; a < 8; a++)
717
717
  if (a < o.stops.length) {
718
- const n = o.stops[a];
719
- r.uniforms.uGradientColors.value[a].set(
720
- n.color.r,
721
- n.color.g,
722
- n.color.b,
723
- n.alpha
724
- ), r.uniforms.uGradientStops.value[a] = n.stop;
718
+ const l = o.stops[a];
719
+ i.uniforms.uGradientColors.value[a].set(
720
+ l.color.r,
721
+ l.color.g,
722
+ l.color.b,
723
+ l.alpha
724
+ ), i.uniforms.uGradientStops.value[a] = l.stop;
725
725
  } else
726
- r.uniforms.uGradientColors.value[a].set(0, 0, 0, 0), r.uniforms.uGradientStops.value[a] = 1;
726
+ i.uniforms.uGradientColors.value[a].set(0, 0, 0, 0), i.uniforms.uGradientStops.value[a] = 1;
727
727
  } else
728
- r.uniforms.uGradientCount.value = 0;
728
+ i.uniforms.uGradientCount.value = 0;
729
729
  }
730
730
  for (const o of Object.keys(e))
731
- o !== "width" && o !== "height" && o !== "borderRadius" && o !== "borderWidth" && o !== "backgroundColor" && o !== "borderColor" && o !== "opacity" && o !== "bgOpacity" && o !== "borderOpacity" && o !== "texture" && o !== "backgroundImage" && o !== "boxShadow" && r.uniforms[o] !== void 0 && (r.uniforms[o].value !== void 0 && r.uniforms[o].value !== null && typeof r.uniforms[o].value.set == "function" ? Array.isArray(e[o]) ? r.uniforms[o].value.set(...e[o]) : e[o] !== void 0 && (e[o].copy ? r.uniforms[o].value.copy(e[o]) : r.uniforms[o].value = e[o]) : r.uniforms[o].value = e[o]);
731
+ o !== "width" && o !== "height" && o !== "borderRadius" && o !== "borderWidth" && o !== "backgroundColor" && o !== "borderColor" && o !== "opacity" && o !== "bgOpacity" && o !== "borderOpacity" && o !== "texture" && o !== "backgroundImage" && o !== "boxShadow" && i.uniforms[o] !== void 0 && (i.uniforms[o].value !== void 0 && i.uniforms[o].value !== null && typeof i.uniforms[o].value.set == "function" ? Array.isArray(e[o]) ? i.uniforms[o].value.set(...e[o]) : e[o] !== void 0 && (e[o].copy ? i.uniforms[o].value.copy(e[o]) : i.uniforms[o].value = e[o]) : i.uniforms[o].value = e[o]);
732
732
  }
733
- function ke(r, e, t = 0) {
734
- var n, l, d, h;
733
+ function Be(i, e, t = 0) {
734
+ var l, n, u, h;
735
735
  if (e == null) {
736
- r.set(0, 0, 0, 0);
736
+ i.set(0, 0, 0, 0);
737
737
  return;
738
738
  }
739
739
  if (typeof e == "number") {
740
- r.set(e, e, e, e);
740
+ i.set(e, e, e, e);
741
741
  return;
742
742
  }
743
743
  if (Array.isArray(e)) {
744
- r.set(e[0], e[1], e[2], e[3]);
744
+ i.set(e[0], e[1], e[2], e[3]);
745
745
  return;
746
746
  }
747
- const i = e.split("/")[0].trim().split(/\s+/), s = ne(i[0], t), c = ne((n = i[1]) != null ? n : i[0], t), o = ne((l = i[2]) != null ? l : i[0], t), a = ne((h = (d = i[3]) != null ? d : i[1]) != null ? h : i[0], t);
748
- r.set(s, c, o, a);
747
+ const r = e.split("/")[0].trim().split(/\s+/), s = le(r[0], t), c = le((l = r[1]) != null ? l : r[0], t), o = le((n = r[2]) != null ? n : r[0], t), a = le((h = (u = r[3]) != null ? u : r[1]) != null ? h : r[0], t);
748
+ i.set(s, c, o, a);
749
749
  }
750
750
  const W = {
751
- create(r, e, t, i, s, c = 2, o = null, a) {
752
- return r === "BOX" ? et(
751
+ create(i, e, t, r, s, c = 2, o = null, a) {
752
+ return i === "BOX" ? rt(
753
753
  e,
754
- i,
754
+ r,
755
755
  s,
756
756
  o,
757
757
  a
758
- ) : r === "TEXT" ? new Ge(
758
+ ) : i === "TEXT" ? new $e(
759
759
  t || "",
760
760
  e,
761
- i,
761
+ r,
762
762
  s,
763
763
  c
764
764
  ) : new w.MeshBasicMaterial({ visible: !1 });
765
765
  },
766
- update(r, e, t, i, s, c, o = 2, a) {
767
- e === "BOX" ? tt(
768
- r,
766
+ update(i, e, t, r, s, c, o = 2, a) {
767
+ e === "BOX" ? it(
768
+ i,
769
769
  t,
770
770
  s,
771
771
  c,
772
772
  a
773
- ) : e === "TEXT" && r.updateText(
774
- i || "",
773
+ ) : e === "TEXT" && i.updateText(
774
+ r || "",
775
775
  t,
776
776
  s,
777
777
  c,
778
778
  o
779
779
  );
780
780
  },
781
- forceUpdateUniforms(r, e) {
782
- be(r, e);
781
+ forceUpdateUniforms(i, e) {
782
+ xe(i, e);
783
783
  }
784
784
  };
785
- class rt {
785
+ class st {
786
786
  constructor(e, t = !0) {
787
- p(this, "observer");
788
- p(this, "textures", /* @__PURE__ */ new WeakMap());
789
- p(this, "loadStatus", /* @__PURE__ */ new WeakMap());
790
- p(this, "elementUrls", /* @__PURE__ */ new WeakMap());
791
- p(this, "onUpdate");
787
+ g(this, "observer");
788
+ g(this, "textures", /* @__PURE__ */ new WeakMap());
789
+ g(this, "loadStatus", /* @__PURE__ */ new WeakMap());
790
+ g(this, "elementUrls", /* @__PURE__ */ new WeakMap());
791
+ g(this, "onUpdate");
792
792
  this.onUpdate = e, t && (this.observer = new IntersectionObserver(
793
- (i) => {
794
- for (const s of i) {
793
+ (r) => {
794
+ for (const s of r) {
795
795
  const c = s.target;
796
796
  s.isIntersecting ? this.loadTexture(c) : this.disposeTexture(c);
797
797
  }
@@ -808,31 +808,31 @@ class rt {
808
808
  e.nodeType === Node.ELEMENT_NODE && this.observer && this.observer.unobserve(e), this.disposeTexture(e), this.elementUrls.delete(e), this.loadStatus.delete(e);
809
809
  }
810
810
  loadTexture(e) {
811
- return Ee(this, null, function* () {
811
+ return Te(this, null, function* () {
812
812
  if (this.loadStatus.get(e) || this.textures.has(e))
813
813
  return;
814
814
  const t = this.elementUrls.get(e);
815
815
  if (t) {
816
816
  this.loadStatus.set(e, !0);
817
817
  try {
818
- let i;
818
+ let r;
819
819
  if (t.startsWith("data:image/svg+xml"))
820
- i = yield new Promise((c, o) => {
820
+ r = yield new Promise((c, o) => {
821
821
  const a = new Image();
822
822
  a.onload = () => c(a), a.onerror = o, a.src = t;
823
823
  });
824
824
  else {
825
825
  const o = yield (yield fetch(t)).blob();
826
- i = yield createImageBitmap(o, { imageOrientation: "flipY" });
826
+ r = yield createImageBitmap(o, { imageOrientation: "flipY" });
827
827
  }
828
828
  if (this.elementUrls.get(e) !== t) {
829
- "close" in i && i.close();
829
+ "close" in r && r.close();
830
830
  return;
831
831
  }
832
- const s = new w.Texture(i);
833
- i instanceof HTMLImageElement || (s.flipY = !1), s.colorSpace = w.LinearSRGBColorSpace, s.needsUpdate = !0, this.textures.set(e, s), this.onUpdate(e, s);
834
- } catch (i) {
835
- console.warn("[MirageEngine] Failed to load texture:", t, i);
832
+ const s = new w.Texture(r);
833
+ r instanceof HTMLImageElement || (s.flipY = !1), s.colorSpace = w.LinearSRGBColorSpace, s.needsUpdate = !0, this.textures.set(e, s), this.onUpdate(e, s);
834
+ } catch (r) {
835
+ console.warn("[MirageEngine] Failed to load texture:", t, r);
836
836
  } finally {
837
837
  this.elementUrls.has(e) && this.loadStatus.set(e, !1);
838
838
  }
@@ -850,35 +850,35 @@ class rt {
850
850
  this.observer && this.observer.disconnect();
851
851
  }
852
852
  }
853
- class it {
854
- constructor(e, t, i, s) {
855
- p(this, "canvas");
856
- p(this, "scene");
857
- p(this, "camera");
858
- p(this, "renderer");
859
- p(this, "renderTargets", []);
860
- p(this, "renderOrder", 0);
861
- p(this, "qualityFactor", 2);
862
- p(this, "mode", "overlay");
863
- p(this, "canvasSize", "viewport");
864
- p(this, "clipArea", 1);
865
- p(this, "targetLayer", "base");
866
- p(this, "overscan", 200);
867
- p(this, "target");
868
- p(this, "mountContainer");
869
- p(this, "registry");
870
- p(this, "targetRect");
871
- p(this, "travelersByLayer", Array.from(
872
- { length: _.MAX_LAYERS },
853
+ class ot {
854
+ constructor(e, t, r, s) {
855
+ g(this, "canvas");
856
+ g(this, "scene");
857
+ g(this, "camera");
858
+ g(this, "renderer");
859
+ g(this, "renderTargets", []);
860
+ g(this, "renderOrder", 0);
861
+ g(this, "qualityFactor", 2);
862
+ g(this, "mode", "overlay");
863
+ g(this, "canvasSize", "viewport");
864
+ g(this, "clipArea", 1);
865
+ g(this, "targetLayer", "base");
866
+ g(this, "overscan", 200);
867
+ g(this, "target");
868
+ g(this, "mountContainer");
869
+ g(this, "registry");
870
+ g(this, "targetRect");
871
+ g(this, "travelersByLayer", Array.from(
872
+ { length: N.MAX_LAYERS },
873
873
  () => /* @__PURE__ */ new Set()
874
874
  ));
875
- p(this, "textureManager");
875
+ g(this, "textureManager");
876
876
  // private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
877
- p(this, "fixedMeshes", /* @__PURE__ */ new Set());
878
- var a, n, l, d, h;
879
- this.target = e, this.mountContainer = i, this.registry = s, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (n = t.canvasSize) != null ? n : "viewport", this.clipArea = (l = t.travelerClipArea) != null ? l : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new rt((u, f) => {
880
- const g = this.registry.get(u);
881
- g && g.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(g.material, { texture: f });
877
+ g(this, "fixedMeshes", /* @__PURE__ */ new Set());
878
+ var a, l, n, u, h;
879
+ this.target = e, this.mountContainer = r, this.registry = s, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (l = t.canvasSize) != null ? l : "viewport", this.clipArea = (n = t.travelerClipArea) != null ? n : 1, this.targetLayer = (u = t.layer) != null ? u : "base", this.textureManager = new st((d, p) => {
880
+ const f = this.registry.get(d);
881
+ f && f.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(f.material, { texture: p });
882
882
  }, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new w.Scene(), this.targetRect = this.target.getBoundingClientRect();
883
883
  const c = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, o = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
884
884
  this.camera = new w.OrthographicCamera(
@@ -900,15 +900,15 @@ class it {
900
900
  return this.mode === "overlay" && this.canvasSize === "viewport";
901
901
  }
902
902
  getSceneLayer() {
903
- return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? B.SELECTED : B.BASE;
903
+ return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? F.SELECTED : F.BASE;
904
904
  }
905
905
  createRenderTarget() {
906
- for (let e = 0; e < _.MAX_LAYERS; e++) {
907
- const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, i = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
906
+ for (let e = 0; e < N.MAX_LAYERS; e++) {
907
+ const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, r = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
908
908
  this.renderTargets.push(
909
909
  new w.WebGLRenderTarget(
910
910
  t * this.qualityFactor,
911
- i * this.qualityFactor,
911
+ r * this.qualityFactor,
912
912
  {
913
913
  minFilter: w.LinearFilter,
914
914
  magFilter: w.LinearFilter,
@@ -948,13 +948,13 @@ class it {
948
948
  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");
949
949
  }
950
950
  updateUniforms(e, t) {
951
- const i = this.registry.get(e);
952
- i && (i.traverse((s) => {
951
+ const r = this.registry.get(e);
952
+ r && (r.traverse((s) => {
953
953
  s.isMesh && s.material && W.forceUpdateUniforms(
954
954
  s.material,
955
955
  t
956
956
  );
957
- }), i.userData.nativeMesh && i.userData.nativeMesh.traverse((s) => {
957
+ }), r.userData.nativeMesh && r.userData.nativeMesh.traverse((s) => {
958
958
  s.isMesh && s.material && W.forceUpdateUniforms(
959
959
  s.material,
960
960
  t
@@ -966,23 +966,23 @@ class it {
966
966
  }
967
967
  setSize(e, t) {
968
968
  this.renderer.setSize(e, t);
969
- for (const i of this.renderTargets)
970
- i.setSize(e * this.qualityFactor, t * this.qualityFactor);
969
+ for (const r of this.renderTargets)
970
+ r.setSize(e * this.qualityFactor, t * this.qualityFactor);
971
971
  this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
972
972
  }
973
973
  syncScene(e, t) {
974
- const i = this.target.getBoundingClientRect(), s = this.isViewport ? window.innerWidth + this.overscan * 2 : i.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : i.height, o = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, n = Math.abs(s - o) > 0.1 || Math.abs(c - 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);
975
- n ? (this.targetRect = i, this.setSize(s, c), this.updateCanvasLayout()) : l ? (this.targetRect = i, this.updateCanvasLayout()) : this.targetRect = i, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
976
- const h = this.registry.get(d);
974
+ const r = this.target.getBoundingClientRect(), s = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, o = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, l = Math.abs(s - o) > 0.1 || Math.abs(c - a) > 0.1, n = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
975
+ l ? (this.targetRect = r, this.setSize(s, c), this.updateCanvasLayout()) : n ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((u) => {
976
+ const h = this.registry.get(u);
977
977
  if (h) {
978
978
  this.scene.remove(h);
979
- for (const u of this.travelersByLayer)
980
- u.delete(h);
979
+ for (const d of this.travelersByLayer)
980
+ d.delete(h);
981
981
  this.fixedMeshes.delete(h), h.geometry.dispose(), h.userData.nativeMesh && (this.scene.remove(h.userData.nativeMesh), Array.isArray(h.userData.nativeMesh.material) ? h.userData.nativeMesh.material.forEach(
982
- (u) => u.dispose()
983
- ) : h.userData.nativeMesh.material.dispose(), h.userData.nativeMesh.geometry.dispose()), h.traverse((u) => {
984
- u instanceof w.Mesh && (u.geometry && u.geometry.dispose(), u.material && (Array.isArray(u.material) ? u.material.forEach((f) => f.dispose()) : u.material.dispose()));
985
- }), this.registry.remove(d), this.textureManager.unregister(d);
982
+ (d) => d.dispose()
983
+ ) : h.userData.nativeMesh.material.dispose(), h.userData.nativeMesh.geometry.dispose()), h.traverse((d) => {
984
+ d instanceof w.Mesh && (d.geometry && d.geometry.dispose(), d.material && (Array.isArray(d.material) ? d.material.forEach((p) => p.dispose()) : d.material.dispose()));
985
+ }), this.registry.remove(u), this.textureManager.unregister(u);
986
986
  }
987
987
  });
988
988
  }
@@ -993,9 +993,9 @@ class it {
993
993
  reconcileNode(e) {
994
994
  var s, c;
995
995
  let t = this.registry.get(e.element);
996
- const i = JSON.stringify(e.shaderHooks || null);
997
- if (t && t.userData.shaderHash !== i && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof w.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
998
- const o = new w.PlaneGeometry(1, 1), a = e.isTraveler ? (s = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : s.texture : this.textureManager.get(e.element), n = W.create(
996
+ const r = JSON.stringify(e.shaderHooks || null);
997
+ if (t && t.userData.shaderHash !== r && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof w.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
998
+ const o = new w.PlaneGeometry(1, 1), a = e.isTraveler ? (s = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : s.texture : this.textureManager.get(e.element), l = W.create(
999
999
  "BOX",
1000
1000
  e.styles,
1001
1001
  "",
@@ -1005,10 +1005,10 @@ class it {
1005
1005
  a,
1006
1006
  e.shaderHooks
1007
1007
  );
1008
- t = new w.Mesh(o, n), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = n, t.userData.domElement = e.element, t.userData.shaderHash = i;
1008
+ t = new w.Mesh(o, l), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = l, t.userData.domElement = e.element, t.userData.shaderHash = r;
1009
1009
  }
1010
- if ((c = e.nativeStyles) != null && c.transform ? t.userData.nativeTransform = e.nativeStyles.transform : t.userData.nativeTransform = void 0, this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
1011
- for (let o = 0; o < _.MAX_LAYERS; o++)
1010
+ if (t.userData.clipElements = e.clipElements, (c = e.nativeStyles) != null && c.transform ? t.userData.nativeTransform = e.nativeStyles.transform : t.userData.nativeTransform = void 0, this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
1011
+ for (let o = 0; o < N.MAX_LAYERS; o++)
1012
1012
  o === e.captureLayer - 2 ? this.travelersByLayer[o].add(t) : this.travelersByLayer[o].delete(t);
1013
1013
  else
1014
1014
  for (const o of this.travelersByLayer)
@@ -1023,371 +1023,407 @@ class it {
1023
1023
  !0
1024
1024
  ));
1025
1025
  }
1026
- reconcileTextChild(e, t, i) {
1027
- var l;
1026
+ reconcileTextChild(e, t, r) {
1027
+ var n;
1028
1028
  const s = t.textLines || [
1029
1029
  { text: t.textContent || "", rect: t.rect }
1030
- ], c = i ? t.nativeStyles : t.textStyles, o = JSON.stringify(c) + t.textContent + s.map((d) => d.text).join("|"), a = (l = e.userData) == null ? void 0 : l.textChildStyleHash;
1031
- if (t.dirtyMask & we || o !== a) {
1030
+ ], c = r ? t.nativeStyles : t.textStyles, o = JSON.stringify(c) + t.textContent + s.map((u) => u.text).join("|"), a = (n = e.userData) == null ? void 0 : n.textChildStyleHash;
1031
+ if (t.dirtyMask & ye || o !== a) {
1032
1032
  e.children.filter(
1033
- (g) => g.name.startsWith("TEXT_CHILD")
1034
- ).forEach((g) => {
1035
- var b;
1036
- const v = g;
1037
- (b = v.material.map) == null || b.dispose(), v.geometry.dispose(), e.remove(v);
1033
+ (f) => f.name.startsWith("TEXT_CHILD")
1034
+ ).forEach((f) => {
1035
+ var m;
1036
+ const L = f;
1037
+ (m = L.material.map) == null || m.dispose(), L.geometry.dispose(), e.remove(L);
1038
1038
  });
1039
- const h = t.rect, u = h.x + h.width / 2, f = h.y + h.height / 2;
1040
- s.forEach((g, v) => {
1041
- const b = W.create(
1039
+ const h = t.rect, d = h.x + h.width / 2, p = h.y + h.height / 2;
1040
+ s.forEach((f, L) => {
1041
+ const m = W.create(
1042
1042
  "TEXT",
1043
1043
  c,
1044
- g.text,
1045
- g.rect.width,
1046
- g.rect.height,
1044
+ f.text,
1045
+ f.rect.width,
1046
+ f.rect.height,
1047
1047
  this.qualityFactor
1048
- ), C = new w.PlaneGeometry(1, 1), I = new w.Mesh(C, b);
1049
- I.name = `TEXT_CHILD_${v}`;
1050
- const D = t.rect.width === 0 ? 1 : g.rect.width / t.rect.width, S = t.rect.height === 0 ? 1 : g.rect.height / t.rect.height;
1051
- I.scale.set(D, S, 1);
1052
- const R = g.rect.x + g.rect.width / 2, E = g.rect.y + g.rect.height / 2, V = R - u, N = -(E - f);
1053
- I.position.set(
1054
- t.rect.width === 0 ? 0 : V / t.rect.width,
1055
- t.rect.height === 0 ? 0 : N / t.rect.height,
1048
+ ), b = new w.PlaneGeometry(1, 1), E = new w.Mesh(b, m);
1049
+ E.name = `TEXT_CHILD_${L}`;
1050
+ const A = t.rect.width === 0 ? 1 : f.rect.width / t.rect.width, C = t.rect.height === 0 ? 1 : f.rect.height / t.rect.height;
1051
+ E.scale.set(A, C, 1);
1052
+ const y = f.rect.x + f.rect.width / 2, S = f.rect.y + f.rect.height / 2, X = y - d, z = -(S - p);
1053
+ E.position.set(
1054
+ t.rect.width === 0 ? 0 : X / t.rect.width,
1055
+ t.rect.height === 0 ? 0 : z / t.rect.height,
1056
1056
  5e-3
1057
- ), e.add(I);
1057
+ ), e.add(E);
1058
1058
  }), e.userData.textChildStyleHash = o;
1059
1059
  }
1060
- e.children.forEach((d) => {
1061
- if (!d.name.startsWith("TEXT_CHILD"))
1060
+ e.children.forEach((u) => {
1061
+ if (!u.name.startsWith("TEXT_CHILD"))
1062
1062
  return;
1063
- const h = d;
1064
- if (i && t.nativeLayer !== void 0)
1065
- h.layers.set(B.HIDDEN), t.visibility & q && h.layers.enable(B.getCaptureLayer(t.nativeLayer));
1063
+ const h = u;
1064
+ if (r && t.nativeLayer !== void 0)
1065
+ h.layers.set(F.HIDDEN), t.visibility & G && h.layers.enable(F.getCaptureLayer(t.nativeLayer));
1066
1066
  else {
1067
- const u = t.visibility & q ? B.BASE : B.HIDDEN;
1068
- if (h.layers.set(u), t.visibility & ae && h.layers.enable(B.SELECTED), t.visibility & q)
1069
- if (!i && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
1070
- for (let f = t.captureLayer; f <= _.MAX_LAYERS + 1; f++)
1071
- f !== t.nativeLayer && h.layers.enable(B.getCaptureLayer(f));
1067
+ const d = t.visibility & G ? F.BASE : F.HIDDEN;
1068
+ if (h.layers.set(d), t.visibility & ae && h.layers.enable(F.SELECTED), t.visibility & G)
1069
+ if (!r && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
1070
+ for (let p = t.captureLayer; p <= N.MAX_LAYERS + 1; p++)
1071
+ p !== t.nativeLayer && h.layers.enable(F.getCaptureLayer(p));
1072
1072
  else
1073
- for (let f = t.captureLayer; f <= _.MAX_LAYERS + 1; f++)
1074
- h.layers.enable(B.getCaptureLayer(f));
1073
+ for (let p = t.captureLayer; p <= N.MAX_LAYERS + 1; p++)
1074
+ h.layers.enable(F.getCaptureLayer(p));
1075
1075
  }
1076
1076
  });
1077
1077
  }
1078
1078
  updateMeshProperties(e, t) {
1079
- var S, R, E, V, N;
1080
- const { rect: i, styles: s } = t, c = this.renderer.getPixelRatio(), o = this.renderer.domElement.width / c, a = this.renderer.domElement.height / c;
1079
+ var C, y, S, X, z;
1080
+ const { rect: r, styles: s } = t, c = this.renderer.getPixelRatio(), o = this.renderer.domElement.width / c, a = this.renderer.domElement.height / c;
1081
1081
  e.material = e.userData.baseMaterial;
1082
- let n = ((S = e.material.userData) == null ? void 0 : S.shadowPadding) || 0;
1083
- e.scale.set(i.width + n * 2, i.height + n * 2, 1), e.userData.domRect = {
1084
- x: i.x,
1085
- y: i.y,
1086
- width: i.width,
1087
- height: i.height
1082
+ let l = ((C = e.material.userData) == null ? void 0 : C.shadowPadding) || 0;
1083
+ e.scale.set(r.width + l * 2, r.height + l * 2, 1), e.userData.domRect = {
1084
+ x: r.x,
1085
+ y: r.y,
1086
+ width: r.width,
1087
+ height: r.height
1088
1088
  };
1089
- const l = 1e-3;
1089
+ const n = 1e-3;
1090
1090
  this.renderOrder++;
1091
- const d = this.targetRect.left + window.scrollX, h = this.targetRect.top + window.scrollY;
1092
- let u, f;
1091
+ const u = this.targetRect.left + window.scrollX, h = this.targetRect.top + window.scrollY;
1092
+ let d, p;
1093
1093
  if (this.isViewport)
1094
- u = i.x - window.innerWidth / 2 + i.width / 2, f = -i.y + window.innerHeight / 2 - i.height / 2;
1094
+ d = r.x - window.innerWidth / 2 + r.width / 2, p = -r.y + window.innerHeight / 2 - r.height / 2;
1095
1095
  else {
1096
- const M = i.x - d, P = i.y - h;
1097
- u = M - o / 2 + i.width / 2, f = -P + a / 2 - i.height / 2;
1096
+ const U = r.x - u, I = r.y - h;
1097
+ d = U - o / 2 + r.width / 2, p = -I + a / 2 - r.height / 2;
1098
1098
  }
1099
1099
  e.position.set(
1100
- u,
1101
- f,
1102
- s.zIndex + this.renderOrder * l
1100
+ d,
1101
+ p,
1102
+ s.zIndex + this.renderOrder * n
1103
1103
  );
1104
- const g = i.x, v = i.y;
1105
- e.userData.basePosition = { x: u, y: f }, e.userData.originalBasePosition = { x: u, y: f }, e.userData.baseSize = { width: i.width, height: i.height }, e.userData.baseDOM = { x: g, y: v }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
1106
- const b = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, C = window.getComputedStyle(b);
1107
- let I = 0, D = 0;
1108
- if (C.transform && C.transform !== "none") {
1109
- const M = new DOMMatrix(C.transform);
1110
- I = M.m41, D = M.m42;
1104
+ const f = r.x, L = r.y;
1105
+ e.userData.basePosition = { x: d, y: p }, e.userData.originalBasePosition = { x: d, y: p }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: f, y: L }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
1106
+ const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, b = window.getComputedStyle(m);
1107
+ let E = 0, A = 0;
1108
+ if (b.transform && b.transform !== "none") {
1109
+ const U = new DOMMatrix(b.transform);
1110
+ E = U.m41, A = U.m42;
1111
1111
  }
1112
- if (e.userData.baseTransform = { x: I, y: D }, delete e.userData.originRatioX, delete e.userData.originRatioY, W.update(
1112
+ if (e.userData.baseTransform = { x: E, y: A }, delete e.userData.originRatioX, delete e.userData.originRatioY, W.update(
1113
1113
  e.userData.baseMaterial,
1114
1114
  "BOX",
1115
1115
  s,
1116
1116
  "",
1117
- i.width,
1118
- i.height,
1117
+ r.width,
1118
+ r.height,
1119
1119
  this.qualityFactor,
1120
- t.isTraveler ? (R = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : R.texture : this.textureManager.get(t.element)
1120
+ t.isTraveler ? (y = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : y.texture : this.textureManager.get(t.element)
1121
1121
  ), t.nativeStyles && t.nativeRect) {
1122
1122
  if (!e.userData.nativeMesh) {
1123
- const z = W.create(
1123
+ const B = W.create(
1124
1124
  "BOX",
1125
1125
  t.nativeStyles,
1126
1126
  "",
1127
1127
  t.nativeRect.width,
1128
1128
  t.nativeRect.height,
1129
1129
  this.qualityFactor,
1130
- t.isTraveler ? (E = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : E.texture : this.textureManager.get(t.element),
1130
+ t.isTraveler ? (S = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : S.texture : this.textureManager.get(t.element),
1131
1131
  t.shaderHooks
1132
- ), Y = new w.Mesh(e.geometry, z);
1133
- t.type === "TEXT" && (Y.name = "BG_MESH"), this.scene.add(Y), e.userData.nativeMesh = Y;
1132
+ ), V = new w.Mesh(e.geometry, B);
1133
+ t.type === "TEXT" && (V.name = "BG_MESH"), this.scene.add(V), e.userData.nativeMesh = V;
1134
1134
  }
1135
- const M = e.userData.nativeMesh;
1136
- let P, J;
1135
+ const U = e.userData.nativeMesh;
1136
+ let I, j;
1137
1137
  if (this.isViewport)
1138
- P = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, J = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
1138
+ I = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, j = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
1139
1139
  else {
1140
- const z = t.nativeRect.x - d, Y = t.nativeRect.y - h;
1141
- P = z - o / 2 + t.nativeRect.width / 2, J = -Y + a / 2 - t.nativeRect.height / 2;
1140
+ const B = t.nativeRect.x - u, V = t.nativeRect.y - h;
1141
+ I = B - o / 2 + t.nativeRect.width / 2, j = -V + a / 2 - t.nativeRect.height / 2;
1142
1142
  }
1143
- let Z = t.nativeRect.width, L = t.nativeRect.height, F = P, $ = J;
1143
+ let J = t.nativeRect.width, Z = t.nativeRect.height, M = I, O = j;
1144
1144
  if (t.nativeStyles.transform) {
1145
- const z = t.nativeStyles.transform, Y = z.match(/scale\(([\d.]+%?)\)/);
1146
- if (Y) {
1147
- let y = parseFloat(Y[1]);
1148
- Y[1].includes("%") && (y /= 100), Z *= y, L *= y;
1145
+ const B = t.nativeStyles.transform, V = B.match(/scale\(([\d.]+%?)\)/);
1146
+ if (V) {
1147
+ let x = parseFloat(V[1]);
1148
+ V[1].includes("%") && (x /= 100), J *= x, Z *= x;
1149
1149
  }
1150
- const ie = z.match(/scaleX\(([\d.]+%?)\)/);
1150
+ const ie = B.match(/scaleX\(([\d.]+%?)\)/);
1151
1151
  if (ie) {
1152
- let y = parseFloat(ie[1]);
1153
- ie[1].includes("%") && (y /= 100), Z *= y;
1152
+ let x = parseFloat(ie[1]);
1153
+ ie[1].includes("%") && (x /= 100), J *= x;
1154
1154
  }
1155
- const se = z.match(/scaleY\(([\d.]+%?)\)/);
1155
+ const se = B.match(/scaleY\(([\d.]+%?)\)/);
1156
1156
  if (se) {
1157
- let y = parseFloat(se[1]);
1158
- se[1].includes("%") && (y /= 100), L *= y;
1157
+ let x = parseFloat(se[1]);
1158
+ se[1].includes("%") && (x /= 100), Z *= x;
1159
1159
  }
1160
- const m = z.match(/translate\(([^,]+),\s*([^)]+)\)/);
1161
- if (m) {
1162
- const y = m[1].trim(), x = m[2].trim();
1163
- let X = parseFloat(y);
1164
- y.includes("%") && (X = X / 100 * t.nativeRect.width);
1165
- let O = parseFloat(x);
1166
- x.includes("%") && (O = O / 100 * t.nativeRect.height), F += X, $ -= O;
1160
+ const oe = B.match(/translate\(([^,]+),\s*([^)]+)\)/);
1161
+ if (oe) {
1162
+ const x = oe[1].trim(), T = oe[2].trim();
1163
+ let _ = parseFloat(x);
1164
+ x.includes("%") && (_ = _ / 100 * t.nativeRect.width);
1165
+ let D = parseFloat(T);
1166
+ T.includes("%") && (D = D / 100 * t.nativeRect.height), M += _, O -= D;
1167
1167
  }
1168
- const A = z.match(/translateX\(([^)]+)\)/);
1169
- if (A) {
1170
- const y = A[1].trim();
1171
- let x = parseFloat(y);
1172
- y.includes("%") && (x = x / 100 * t.nativeRect.width), F += x;
1168
+ const he = B.match(/translateX\(([^)]+)\)/);
1169
+ if (he) {
1170
+ const x = he[1].trim();
1171
+ let T = parseFloat(x);
1172
+ x.includes("%") && (T = T / 100 * t.nativeRect.width), M += T;
1173
1173
  }
1174
- const U = z.match(/translateY\(([^)]+)\)/);
1175
- if (U) {
1176
- const y = U[1].trim();
1177
- let x = parseFloat(y);
1178
- y.includes("%") && (x = x / 100 * t.nativeRect.height), $ -= x;
1174
+ const v = B.match(/translateY\(([^)]+)\)/);
1175
+ if (v) {
1176
+ const x = v[1].trim();
1177
+ let T = parseFloat(x);
1178
+ x.includes("%") && (T = T / 100 * t.nativeRect.height), O -= T;
1179
1179
  }
1180
1180
  }
1181
- let K = ((V = M.material.userData) == null ? void 0 : V.shadowPadding) || 0;
1182
- M.scale.set(Z + K * 2, L + K * 2, 1), M.position.set(
1183
- F,
1184
- $,
1185
- t.nativeStyles.zIndex + this.renderOrder * l
1181
+ let K = ((X = U.material.userData) == null ? void 0 : X.shadowPadding) || 0;
1182
+ U.scale.set(J + K * 2, Z + K * 2, 1), U.position.set(
1183
+ M,
1184
+ O,
1185
+ t.nativeStyles.zIndex + this.renderOrder * n
1186
1186
  ), W.update(
1187
- M.material,
1187
+ U.material,
1188
1188
  "BOX",
1189
1189
  t.nativeStyles,
1190
1190
  "",
1191
1191
  t.nativeRect.width,
1192
1192
  t.nativeRect.height,
1193
1193
  this.qualityFactor,
1194
- t.isTraveler ? (N = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : N.texture : this.textureManager.get(t.element)
1194
+ t.isTraveler ? (z = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : z.texture : this.textureManager.get(t.element)
1195
1195
  );
1196
1196
  } else
1197
1197
  e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof w.Material && e.userData.nativeMesh.material.dispose(), delete e.userData.nativeMesh);
1198
1198
  }
1199
1199
  updateMeshLayers(e, t) {
1200
- const i = t.visibility & q ? B.BASE : B.HIDDEN;
1201
- if (e.layers.set(i), t.visibility & ae && e.layers.enable(B.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
1200
+ const r = t.visibility & G ? F.BASE : F.HIDDEN;
1201
+ if (e.layers.set(r), t.visibility & ae && e.layers.enable(F.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
1202
1202
  const s = e.userData.nativeMesh;
1203
- if (s.layers.set(B.HIDDEN), t.visibility & q) {
1204
- s.layers.enable(B.getCaptureLayer(t.nativeLayer));
1205
- for (let c = t.captureLayer; c <= _.MAX_LAYERS + 1; c++)
1206
- c !== t.nativeLayer && e.layers.enable(B.getCaptureLayer(c));
1203
+ if (s.layers.set(F.HIDDEN), t.visibility & G) {
1204
+ s.layers.enable(F.getCaptureLayer(t.nativeLayer));
1205
+ for (let c = t.captureLayer; c <= N.MAX_LAYERS + 1; c++)
1206
+ c !== t.nativeLayer && e.layers.enable(F.getCaptureLayer(c));
1207
1207
  }
1208
- } else if (t.visibility & q)
1209
- for (let s = t.captureLayer; s <= _.MAX_LAYERS + 1; s++)
1210
- e.layers.enable(B.getCaptureLayer(s));
1208
+ } else if (t.visibility & G)
1209
+ for (let s = t.captureLayer; s <= N.MAX_LAYERS + 1; s++)
1210
+ e.layers.enable(F.getCaptureLayer(s));
1211
1211
  }
1212
- captureRenderTarget(e, t, i) {
1213
- if (e.size === 0 || !i)
1212
+ captureRenderTarget(e, t, r) {
1213
+ if (e.size === 0 || !r)
1214
1214
  return;
1215
1215
  const s = new w.Color(), c = this.renderer.getClearAlpha();
1216
- this.renderer.getClearColor(s), 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);
1217
- const o = new w.Vector3(), a = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, l = this.renderer.getPixelRatio();
1218
- for (const d of e) {
1219
- o.setFromMatrixPosition(d.matrixWorld), o.project(this.camera);
1220
- const h = (o.x + 1) / 2 * a, u = (o.y + 1) / 2 * n;
1221
- let f = 0, g = 1;
1222
- typeof this.clipArea == "number" ? g = this.clipArea : this.clipArea.endsWith("%") ? g = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (f = parseFloat(this.clipArea));
1223
- const v = d.scale.x * g + 0.5, b = d.scale.y * g + 0.5, C = h - v / 2, I = u - b / 2, D = (C * this.qualityFactor - f) / l, S = (I * this.qualityFactor - f) / l, R = (v * this.qualityFactor + f * 2) / l, E = (b * this.qualityFactor + f * 2) / l;
1224
- this.renderer.setScissor(D, S, R, E), this.renderer.render(this.scene, this.camera);
1216
+ this.renderer.getClearColor(s), 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);
1217
+ const o = new w.Vector3(), a = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, l = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, n = this.renderer.getPixelRatio();
1218
+ for (const u of e) {
1219
+ o.setFromMatrixPosition(u.matrixWorld), o.project(this.camera);
1220
+ const h = (o.x + 1) / 2 * a, d = (o.y + 1) / 2 * l;
1221
+ let p = 0, f = 1;
1222
+ typeof this.clipArea == "number" ? f = this.clipArea : this.clipArea.endsWith("%") ? f = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (p = parseFloat(this.clipArea));
1223
+ const L = u.scale.x * f + 0.5, m = u.scale.y * f + 0.5, b = h - L / 2, E = d - m / 2, A = (b * this.qualityFactor - p) / n, C = (E * this.qualityFactor - p) / n, y = (L * this.qualityFactor + p * 2) / n, S = (m * this.qualityFactor + p * 2) / n;
1224
+ this.renderer.setScissor(A, C, y, S), this.renderer.render(this.scene, this.camera);
1225
1225
  }
1226
1226
  this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(s, c);
1227
1227
  }
1228
1228
  render() {
1229
- for (let e = 0; e < _.MAX_LAYERS; e++) {
1230
- const t = e + 1;
1229
+ for (let l = 0; l < N.MAX_LAYERS; l++) {
1230
+ const n = l + 1;
1231
1231
  this.captureRenderTarget(
1232
- this.travelersByLayer[e],
1233
- B.getCaptureLayer(t),
1234
- this.renderTargets[e]
1232
+ this.travelersByLayer[l],
1233
+ F.getCaptureLayer(n),
1234
+ this.renderTargets[l]
1235
1235
  );
1236
1236
  }
1237
- this.renderer.render(this.scene, this.camera);
1237
+ const e = this.renderer.getContext(), t = this.renderer.getPixelRatio(), r = this.renderer.domElement.height / t, s = this.renderer.domElement, c = s.getBoundingClientRect().top, o = s.getBoundingClientRect().left, a = (l, n) => {
1238
+ if (n && n.width > 0 && n.height > 0) {
1239
+ const u = Math.floor((n.x - o) * t), h = Math.floor(
1240
+ (r - (n.y - c + n.height)) * t
1241
+ ), d = Math.ceil(n.width * t), p = Math.ceil(n.height * t);
1242
+ l.onBeforeRender = () => {
1243
+ e.enable(e.SCISSOR_TEST), e.scissor(u, h, d, p);
1244
+ }, l.onAfterRender = () => {
1245
+ e.disable(e.SCISSOR_TEST);
1246
+ }, l.__hasScissorHook = !0;
1247
+ } else
1248
+ l.__hasScissorHook && (l.onBeforeRender = () => {
1249
+ }, l.onAfterRender = () => {
1250
+ }, l.__hasScissorHook = !1);
1251
+ };
1252
+ this.scene.children.forEach((l) => {
1253
+ var h;
1254
+ const n = l, u = (h = n.userData) == null ? void 0 : h.scissorRect;
1255
+ a(n, u), n.children.forEach((d) => {
1256
+ d.name.startsWith("TEXT_CHILD") && a(d, u);
1257
+ });
1258
+ }), this.renderer.render(this.scene, this.camera);
1238
1259
  }
1239
1260
  syncMeshesByDOM() {
1240
- const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, i = this.renderer.getPixelRatio(), s = this.renderer.domElement.width / i, c = this.renderer.domElement.height / i;
1261
+ const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), s = this.renderer.domElement.width / r, c = this.renderer.domElement.height / r;
1241
1262
  this.scene.children.forEach((o) => {
1242
- var h, u;
1263
+ var h, d;
1243
1264
  const a = o;
1244
1265
  if (!a.userData || !a.userData.domElement)
1245
1266
  return;
1246
- const n = a.userData.domElement;
1247
- if (!n.isConnected)
1267
+ const l = a.userData.domElement;
1268
+ if (!l.isConnected)
1248
1269
  return;
1249
- let l;
1250
- if (n.nodeType === Node.TEXT_NODE) {
1251
- const f = document.createRange();
1252
- f.selectNode(n), l = f.getBoundingClientRect();
1270
+ let n;
1271
+ if (l.nodeType === Node.TEXT_NODE) {
1272
+ const p = document.createRange();
1273
+ p.selectNode(l), n = p.getBoundingClientRect();
1253
1274
  } else
1254
- l = n.getBoundingClientRect();
1255
- const d = a.userData.domRect;
1256
- if (!d || Math.abs(l.x - d.x) > 0.5 || Math.abs(l.y - d.y) > 0.5 || Math.abs(l.width - d.width) > 0.5 || Math.abs(l.height - d.height) > 0.5) {
1275
+ n = l.getBoundingClientRect();
1276
+ const u = a.userData.domRect;
1277
+ if (!u || Math.abs(n.x - u.x) > 0.5 || Math.abs(n.y - u.y) > 0.5 || Math.abs(n.width - u.width) > 0.5 || Math.abs(n.height - u.height) > 0.5) {
1257
1278
  a.userData.domRect = {
1258
- x: l.x,
1259
- y: l.y,
1260
- width: l.width,
1261
- height: l.height
1279
+ x: n.x,
1280
+ y: n.y,
1281
+ width: n.width,
1282
+ height: n.height
1262
1283
  };
1263
- let f, g;
1284
+ const p = a.userData.clipElements;
1285
+ if (p && p.length > 0) {
1286
+ let b = -1 / 0, E = -1 / 0, A = 1 / 0, C = 1 / 0;
1287
+ for (const y of p) {
1288
+ const S = y.getBoundingClientRect();
1289
+ b = Math.max(b, S.left), E = Math.max(E, S.top), A = Math.min(A, S.right), C = Math.min(C, S.bottom);
1290
+ }
1291
+ a.userData.scissorRect = {
1292
+ x: b,
1293
+ y: E,
1294
+ width: Math.max(0, A - b),
1295
+ height: Math.max(0, C - E)
1296
+ };
1297
+ } else
1298
+ a.userData.scissorRect = void 0;
1299
+ let f, L;
1264
1300
  if (this.isViewport)
1265
- f = l.x - window.innerWidth / 2 + l.width / 2, g = -l.y + window.innerHeight / 2 - l.height / 2;
1301
+ f = n.x - window.innerWidth / 2 + n.width / 2, L = -n.y + window.innerHeight / 2 - n.height / 2;
1266
1302
  else {
1267
- const b = l.x - e, C = l.y - t;
1268
- f = b - s / 2 + l.width / 2, g = -C + c / 2 - l.height / 2;
1303
+ const b = n.x - e, E = n.y - t;
1304
+ f = b - s / 2 + n.width / 2, L = -E + c / 2 - n.height / 2;
1269
1305
  }
1270
- a.position.setX(f), a.position.setY(g);
1271
- let v = ((h = a.material.userData) == null ? void 0 : h.shadowPadding) || 0;
1272
- if (a.scale.set(l.width + v * 2, l.height + v * 2, 1), a.updateMatrixWorld(), a.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(a.material, {
1273
- width: l.width,
1274
- height: l.height
1306
+ a.position.setX(f), a.position.setY(L);
1307
+ let m = ((h = a.material.userData) == null ? void 0 : h.shadowPadding) || 0;
1308
+ if (a.scale.set(n.width + m * 2, n.height + m * 2, 1), a.updateMatrixWorld(), a.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(a.material, {
1309
+ width: n.width,
1310
+ height: n.height
1275
1311
  }), a.userData.nativeMesh) {
1276
1312
  const b = a.userData.nativeMesh;
1277
- let C = l.width, I = l.height, D = f, S = g;
1313
+ let E = n.width, A = n.height, C = f, y = L;
1278
1314
  if (a.userData.nativeTransform) {
1279
- const E = a.userData.nativeTransform, V = E.match(/scale\(([\d.]+%?)\)/);
1280
- if (V) {
1281
- let L = parseFloat(V[1]);
1282
- V[1].includes("%") && (L /= 100), C *= L, I *= L;
1315
+ const X = a.userData.nativeTransform, z = X.match(/scale\(([\d.]+%?)\)/);
1316
+ if (z) {
1317
+ let M = parseFloat(z[1]);
1318
+ z[1].includes("%") && (M /= 100), E *= M, A *= M;
1283
1319
  }
1284
- const N = E.match(/scaleX\(([\d.]+%?)\)/);
1285
- if (N) {
1286
- let L = parseFloat(N[1]);
1287
- N[1].includes("%") && (L /= 100), C *= L;
1320
+ const U = X.match(/scaleX\(([\d.]+%?)\)/);
1321
+ if (U) {
1322
+ let M = parseFloat(U[1]);
1323
+ U[1].includes("%") && (M /= 100), E *= M;
1288
1324
  }
1289
- const M = E.match(/scaleY\(([\d.]+%?)\)/);
1290
- if (M) {
1291
- let L = parseFloat(M[1]);
1292
- M[1].includes("%") && (L /= 100), I *= L;
1325
+ const I = X.match(/scaleY\(([\d.]+%?)\)/);
1326
+ if (I) {
1327
+ let M = parseFloat(I[1]);
1328
+ I[1].includes("%") && (M /= 100), A *= M;
1293
1329
  }
1294
- const P = E.match(/translate\(([^,]+),\s*([^)]+)\)/);
1295
- if (P) {
1296
- const L = P[1].trim(), F = P[2].trim();
1297
- let $ = parseFloat(L);
1298
- L.includes("%") && ($ = $ / 100 * l.width);
1299
- let K = parseFloat(F);
1300
- F.includes("%") && (K = K / 100 * l.height), D += $, S -= K;
1330
+ const j = X.match(/translate\(([^,]+),\s*([^)]+)\)/);
1331
+ if (j) {
1332
+ const M = j[1].trim(), O = j[2].trim();
1333
+ let K = parseFloat(M);
1334
+ M.includes("%") && (K = K / 100 * n.width);
1335
+ let B = parseFloat(O);
1336
+ O.includes("%") && (B = B / 100 * n.height), C += K, y -= B;
1301
1337
  }
1302
- const J = E.match(/translateX\(([^)]+)\)/);
1338
+ const J = X.match(/translateX\(([^)]+)\)/);
1303
1339
  if (J) {
1304
- const L = J[1].trim();
1305
- let F = parseFloat(L);
1306
- L.includes("%") && (F = F / 100 * l.width), D += F;
1340
+ const M = J[1].trim();
1341
+ let O = parseFloat(M);
1342
+ M.includes("%") && (O = O / 100 * n.width), C += O;
1307
1343
  }
1308
- const Z = E.match(/translateY\(([^)]+)\)/);
1344
+ const Z = X.match(/translateY\(([^)]+)\)/);
1309
1345
  if (Z) {
1310
- const L = Z[1].trim();
1311
- let F = parseFloat(L);
1312
- L.includes("%") && (F = F / 100 * l.height), S -= F;
1346
+ const M = Z[1].trim();
1347
+ let O = parseFloat(M);
1348
+ M.includes("%") && (O = O / 100 * n.height), y -= O;
1313
1349
  }
1314
1350
  }
1315
- let R = ((u = b.material.userData) == null ? void 0 : u.shadowPadding) || 0;
1316
- b.position.setX(D), b.position.setY(S), b.scale.set(C + R * 2, I + R * 2, 1), b.updateMatrixWorld(), b.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(b.material, {
1317
- width: C,
1318
- height: I
1351
+ let S = ((d = b.material.userData) == null ? void 0 : d.shadowPadding) || 0;
1352
+ b.position.setX(C), b.position.setY(y), b.scale.set(E + S * 2, A + S * 2, 1), b.updateMatrixWorld(), b.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(b.material, {
1353
+ width: E,
1354
+ height: A
1319
1355
  });
1320
1356
  }
1321
1357
  }
1322
1358
  });
1323
1359
  }
1324
1360
  }
1325
- function st(r) {
1326
- const e = r.textContent || "", t = [];
1327
- let i = "", s = null, c = -1;
1328
- const o = (l, d) => {
1329
- for (let h = 0; h < l.length; h++) {
1330
- const u = l[h], f = document.createRange();
1331
- f.setStart(r, d + h), f.setEnd(r, d + h + 1);
1332
- const g = f.getBoundingClientRect();
1333
- if (g.width === 0 && g.height === 0) {
1334
- i += u;
1361
+ function nt(i) {
1362
+ const e = i.textContent || "", t = [];
1363
+ let r = "", s = null, c = -1;
1364
+ const o = (n, u) => {
1365
+ for (let h = 0; h < n.length; h++) {
1366
+ const d = n[h], p = document.createRange();
1367
+ p.setStart(i, u + h), p.setEnd(i, u + h + 1);
1368
+ const f = p.getBoundingClientRect();
1369
+ if (f.width === 0 && f.height === 0) {
1370
+ r += d;
1335
1371
  continue;
1336
1372
  }
1337
- c === -1 || Math.abs(g.top - c) > g.height / 2 ? (i && s && t.push({
1338
- text: i,
1373
+ c === -1 || Math.abs(f.top - c) > f.height / 2 ? (r && s && t.push({
1374
+ text: r,
1339
1375
  rect: {
1340
1376
  left: s.left,
1341
1377
  top: s.top,
1342
1378
  width: s.right - s.left,
1343
1379
  height: s.bottom - s.top
1344
1380
  }
1345
- }), i = u, s = {
1346
- left: g.left,
1347
- top: g.top,
1348
- right: g.right,
1349
- bottom: g.bottom
1350
- }, c = g.top) : (i += u, s && (s.left = Math.min(s.left, g.left), s.top = Math.min(s.top, g.top), s.right = Math.max(s.right, g.right), s.bottom = Math.max(
1381
+ }), r = d, s = {
1382
+ left: f.left,
1383
+ top: f.top,
1384
+ right: f.right,
1385
+ bottom: f.bottom
1386
+ }, c = f.top) : (r += d, s && (s.left = Math.min(s.left, f.left), s.top = Math.min(s.top, f.top), s.right = Math.max(s.right, f.right), s.bottom = Math.max(
1351
1387
  s.bottom,
1352
- g.bottom
1388
+ f.bottom
1353
1389
  )));
1354
1390
  }
1355
1391
  }, a = e.match(/[^\s\-]+\-?|\-|\s+/g) || [];
1356
- let n = 0;
1357
- for (const l of a) {
1358
- const d = document.createRange();
1359
- d.setStart(r, n), d.setEnd(r, n + l.length);
1360
- const h = d.getClientRects();
1392
+ let l = 0;
1393
+ for (const n of a) {
1394
+ const u = document.createRange();
1395
+ u.setStart(i, l), u.setEnd(i, l + n.length);
1396
+ const h = u.getClientRects();
1361
1397
  if (h.length > 1)
1362
- o(l, n);
1398
+ o(n, l);
1363
1399
  else {
1364
- const u = h.length === 1 ? h[0] : d.getBoundingClientRect();
1365
- if (u.width === 0 && u.height === 0) {
1366
- i += l, n += l.length;
1400
+ const d = h.length === 1 ? h[0] : u.getBoundingClientRect();
1401
+ if (d.width === 0 && d.height === 0) {
1402
+ r += n, l += n.length;
1367
1403
  continue;
1368
1404
  }
1369
- c === -1 || Math.abs(u.top - c) > u.height / 2 ? (i && s && t.push({
1370
- text: i,
1405
+ c === -1 || Math.abs(d.top - c) > d.height / 2 ? (r && s && t.push({
1406
+ text: r,
1371
1407
  rect: {
1372
1408
  left: s.left,
1373
1409
  top: s.top,
1374
1410
  width: s.right - s.left,
1375
1411
  height: s.bottom - s.top
1376
1412
  }
1377
- }), i = l, s = {
1378
- left: u.left,
1379
- top: u.top,
1380
- right: u.right,
1381
- bottom: u.bottom
1382
- }, c = u.top) : (i += l, s && (s.left = Math.min(s.left, u.left), s.top = Math.min(s.top, u.top), s.right = Math.max(s.right, u.right), s.bottom = Math.max(
1413
+ }), r = n, s = {
1414
+ left: d.left,
1415
+ top: d.top,
1416
+ right: d.right,
1417
+ bottom: d.bottom
1418
+ }, c = d.top) : (r += n, s && (s.left = Math.min(s.left, d.left), s.top = Math.min(s.top, d.top), s.right = Math.max(s.right, d.right), s.bottom = Math.max(
1383
1419
  s.bottom,
1384
- u.bottom
1420
+ d.bottom
1385
1421
  )));
1386
1422
  }
1387
- n += l.length;
1423
+ l += n.length;
1388
1424
  }
1389
- return i && s && t.push({
1390
- text: i,
1425
+ return r && s && t.push({
1426
+ text: r,
1391
1427
  rect: {
1392
1428
  left: s.left,
1393
1429
  top: s.top,
@@ -1395,297 +1431,300 @@ function st(r) {
1395
1431
  height: s.bottom - s.top
1396
1432
  }
1397
1433
  }), t.filter(
1398
- (l) => l.text.trim().length > 0 && l.rect.width > 0 && l.rect.height > 0
1434
+ (n) => n.text.trim().length > 0 && n.rect.width > 0 && n.rect.height > 0
1399
1435
  );
1400
1436
  }
1401
- function Le(r) {
1402
- const e = parseFloat(r.fontSize);
1403
- let t = parseFloat(r.lineHeight);
1437
+ function Ae(i) {
1438
+ const e = parseFloat(i.fontSize);
1439
+ let t = parseFloat(i.lineHeight);
1404
1440
  isNaN(t) && (t = e * 1.2);
1405
- let i = parseFloat(r.letterSpacing);
1406
- return isNaN(i) && (i = 0), {
1407
- font: `${r.fontStyle} ${r.fontWeight} ${r.fontSize} ${r.fontFamily}`,
1408
- fontSize: r.fontSize,
1409
- color: r.color,
1410
- textAlign: r.textAlign || "start",
1441
+ let r = parseFloat(i.letterSpacing);
1442
+ return isNaN(r) && (r = 0), {
1443
+ font: `${i.fontStyle} ${i.fontWeight} ${i.fontSize} ${i.fontFamily}`,
1444
+ fontSize: i.fontSize,
1445
+ color: i.color,
1446
+ textAlign: i.textAlign || "start",
1411
1447
  textBaseline: "alphabetic",
1412
- direction: r.direction || "inherit",
1448
+ direction: i.direction || "inherit",
1413
1449
  lineHeight: t,
1414
- letterSpacing: i
1450
+ letterSpacing: r
1415
1451
  };
1416
1452
  }
1417
- function Ue(r, e = re | he | Ye | we | fe, t, i = 1, s = 0, c = 2, o, a) {
1418
- var F, $, K, z, Y, ie, se;
1419
- if (r.nodeType === Node.TEXT_NODE) {
1420
- const m = r;
1421
- if (!m.textContent || !m.textContent.trim())
1453
+ function Fe(i, e = re | ue | Pe | ye | pe, t, r = 1, s = 0, c = 2, o, a, l) {
1454
+ var K, B, V, ie, se, oe, he;
1455
+ if (i.nodeType === Node.TEXT_NODE) {
1456
+ const v = i;
1457
+ if (!v.textContent || !v.textContent.trim())
1422
1458
  return null;
1423
- const A = m.textContent.replace(/\s+/g, " ");
1424
- if (A.length === 0)
1459
+ const x = v.textContent.replace(/\s+/g, " ");
1460
+ if (x.length === 0)
1425
1461
  return null;
1426
- const U = st(m);
1427
- if (U.length === 0)
1462
+ const T = nt(v);
1463
+ if (T.length === 0)
1428
1464
  return null;
1429
- const y = m.parentElement, x = y ? window.getComputedStyle(y) : null;
1430
- if (!x)
1465
+ const _ = v.parentElement, D = _ ? window.getComputedStyle(_) : null;
1466
+ if (!D)
1431
1467
  return null;
1432
- const X = Math.min(...U.map((T) => T.rect.left)), O = Math.min(...U.map((T) => T.rect.top)), Q = Math.max(...U.map((T) => T.rect.left + T.rect.width)), k = Math.max(...U.map((T) => T.rect.top + T.rect.height));
1468
+ const q = Math.min(...T.map((R) => R.rect.left)), Y = Math.min(...T.map((R) => R.rect.top)), Q = Math.max(...T.map((R) => R.rect.left + R.rect.width)), k = Math.max(...T.map((R) => R.rect.top + R.rect.height));
1433
1469
  return {
1434
1470
  id: Math.random().toString(36).substring(2, 9),
1435
1471
  type: "TEXT",
1436
- element: m,
1472
+ element: v,
1437
1473
  rect: {
1438
- x: X + window.scrollX,
1439
- y: O + window.scrollY,
1440
- width: Q - X,
1441
- height: k - O
1474
+ x: q + window.scrollX,
1475
+ y: Y + window.scrollY,
1476
+ width: Q - q,
1477
+ height: k - Y
1442
1478
  },
1443
1479
  styles: {
1444
1480
  backgroundColor: "transparent",
1445
1481
  backgroundImage: "",
1446
- opacity: y && y.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(x.opacity),
1447
- zIndex: (isNaN(parseInt(x.zIndex)) ? 0 : parseInt(x.zIndex)) + s,
1482
+ opacity: _ && _.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(D.opacity),
1483
+ zIndex: (isNaN(parseInt(D.zIndex)) ? 0 : parseInt(D.zIndex)) + s,
1448
1484
  borderRadius: "0px",
1449
1485
  borderColor: "transparent",
1450
1486
  borderWidth: "0px",
1451
1487
  isTraveler: !1
1452
1488
  },
1453
- textContent: A,
1454
- textLines: U.map((T) => ({
1455
- text: T.text.trim(),
1489
+ textContent: x,
1490
+ textLines: T.map((R) => ({
1491
+ text: R.text.trim(),
1456
1492
  rect: {
1457
- x: T.rect.left + window.scrollX,
1458
- y: T.rect.top + window.scrollY,
1459
- width: T.rect.width,
1460
- height: T.rect.height
1493
+ x: R.rect.left + window.scrollX,
1494
+ y: R.rect.top + window.scrollY,
1495
+ width: R.rect.width,
1496
+ height: R.rect.height
1461
1497
  }
1462
1498
  })),
1463
- textStyles: Le(x),
1499
+ textStyles: Ae(D),
1464
1500
  dirtyMask: e,
1465
1501
  visibility: t,
1466
1502
  isTraveler: !1,
1467
- captureLayer: i,
1468
- isFixed: x.position === "fixed",
1503
+ captureLayer: r,
1504
+ isFixed: D.position === "fixed",
1469
1505
  nativeLayer: o,
1470
1506
  nativeStyles: a ? te(te({
1471
1507
  backgroundColor: "transparent",
1472
1508
  backgroundImage: "",
1473
- opacity: y && y.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(x.opacity),
1474
- zIndex: (isNaN(parseInt(x.zIndex)) ? 0 : parseInt(x.zIndex)) + s,
1509
+ opacity: _ && _.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(D.opacity),
1510
+ zIndex: (isNaN(parseInt(D.zIndex)) ? 0 : parseInt(D.zIndex)) + s,
1475
1511
  borderRadius: "0px",
1476
1512
  borderColor: "transparent",
1477
1513
  borderWidth: "0px",
1478
1514
  isTraveler: !1
1479
- }, Le(x)), a) : void 0,
1515
+ }, Ae(D)), a) : void 0,
1480
1516
  nativeRect: a ? {
1481
- x: X + window.scrollX,
1482
- y: O + window.scrollY,
1483
- width: Q - X,
1484
- height: k - O
1517
+ x: q + window.scrollX,
1518
+ y: Y + window.scrollY,
1519
+ width: Q - q,
1520
+ height: k - Y
1485
1521
  } : void 0,
1522
+ clipElements: l,
1486
1523
  children: []
1487
1524
  };
1488
1525
  }
1489
- if (r.nodeType !== Node.ELEMENT_NODE)
1526
+ if (i.nodeType !== Node.ELEMENT_NODE)
1490
1527
  return null;
1491
- const n = r, l = n.dataset[G.KEY];
1492
- let d = t, h = t;
1493
- if (l) {
1494
- const m = new Set(l.split(/\s+/));
1495
- for (const A of m)
1496
- if (!Te.includes(A))
1528
+ const n = i, u = n.dataset[H.KEY];
1529
+ let h = t, d = t;
1530
+ if (u) {
1531
+ const v = new Set(u.split(/\s+/));
1532
+ for (const x of v)
1533
+ if (!Me.includes(x))
1497
1534
  throw new Error(
1498
- `[MirageEngine] Invalid filter token: '${A}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1535
+ `[MirageEngine] Invalid filter token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1499
1536
  );
1500
- if (m.has(G.VALUES.END))
1537
+ if (v.has(H.VALUES.END))
1501
1538
  return null;
1502
- if (m.has(G.VALUES.INCLUDE_TREE) && m.has(G.VALUES.EXCLUDE_TREE))
1539
+ if (v.has(H.VALUES.INCLUDE_TREE) && v.has(H.VALUES.EXCLUDE_TREE))
1503
1540
  throw new Error(
1504
1541
  "[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
1505
1542
  );
1506
- if (m.has(G.VALUES.INCLUDE_SELF) && m.has(G.VALUES.EXCLUDE_SELF))
1543
+ if (v.has(H.VALUES.INCLUDE_SELF) && v.has(H.VALUES.EXCLUDE_SELF))
1507
1544
  throw new Error(
1508
1545
  "[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
1509
1546
  );
1510
- m.has(G.VALUES.INCLUDE_TREE) ? d = d | q : m.has(G.VALUES.EXCLUDE_TREE) && (d = d & ~q), h = d, m.has(G.VALUES.INCLUDE_SELF) ? h = h | q : m.has(G.VALUES.EXCLUDE_SELF) && (h = h & ~q);
1547
+ v.has(H.VALUES.INCLUDE_TREE) ? h = h | G : v.has(H.VALUES.EXCLUDE_TREE) && (h = h & ~G), d = h, v.has(H.VALUES.INCLUDE_SELF) ? d = d | G : v.has(H.VALUES.EXCLUDE_SELF) && (d = d & ~G);
1511
1548
  }
1512
- const u = n.dataset[j.KEY];
1513
- if (u) {
1514
- const m = new Set(u.split(/\s+/));
1515
- for (const A of m)
1516
- if (!Te.includes(A))
1549
+ const p = n.dataset[$.KEY];
1550
+ if (p) {
1551
+ const v = new Set(p.split(/\s+/));
1552
+ for (const x of v)
1553
+ if (!Me.includes(x))
1517
1554
  throw new Error(
1518
- `[MirageEngine] Invalid select token: '${A}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1555
+ `[MirageEngine] Invalid select token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
1519
1556
  );
1520
- if (m.has(j.VALUES.END))
1557
+ if (v.has($.VALUES.END))
1521
1558
  return null;
1522
- if (m.has(j.VALUES.INCLUDE_TREE) && m.has(j.VALUES.EXCLUDE_TREE))
1559
+ if (v.has($.VALUES.INCLUDE_TREE) && v.has($.VALUES.EXCLUDE_TREE))
1523
1560
  throw new Error(
1524
1561
  "[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
1525
1562
  );
1526
- if (m.has(j.VALUES.INCLUDE_SELF) && m.has(j.VALUES.EXCLUDE_SELF))
1563
+ if (v.has($.VALUES.INCLUDE_SELF) && v.has($.VALUES.EXCLUDE_SELF))
1527
1564
  throw new Error(
1528
1565
  "[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
1529
1566
  );
1530
- m.has(j.VALUES.INCLUDE_TREE) ? d = d | ae : m.has(j.VALUES.EXCLUDE_TREE) && (d = d & ~ae), h = d, m.has(j.VALUES.INCLUDE_SELF) ? h = h | ae : m.has(j.VALUES.EXCLUDE_SELF) && (h = h & ~ae);
1567
+ v.has($.VALUES.INCLUDE_TREE) ? h = h | ae : v.has($.VALUES.EXCLUDE_TREE) && (h = h & ~ae), d = h, v.has($.VALUES.INCLUDE_SELF) ? d = d | ae : v.has($.VALUES.EXCLUDE_SELF) && (d = d & ~ae);
1531
1568
  }
1532
- const f = n.dataset[_.KEY];
1533
- let g = !1, v = a ? te({}, a) : {}, b = o;
1569
+ const f = n.dataset[N.KEY];
1570
+ let L = !1, m = a ? te({}, a) : {}, b = o;
1534
1571
  if (f) {
1535
- let m = 1;
1536
- const A = f.indexOf("{"), U = f.lastIndexOf("}");
1537
- let y = f;
1538
- if (A !== -1 && U !== -1 && U > A) {
1539
- y = f.substring(0, A).trim();
1540
- const k = f.substring(A, U + 1);
1572
+ let v = 1;
1573
+ const x = f.indexOf("{"), T = f.lastIndexOf("}");
1574
+ let _ = f;
1575
+ if (x !== -1 && T !== -1 && T > x) {
1576
+ _ = f.substring(0, x).trim();
1577
+ const k = f.substring(x, T + 1);
1541
1578
  try {
1542
- v = new Function("return " + k)();
1543
- } catch (T) {
1579
+ m = new Function("return " + k)();
1580
+ } catch (R) {
1544
1581
  console.warn(
1545
1582
  `[MirageEngine] Failed to parse travel styles JSON: ${k}`
1546
1583
  );
1547
1584
  }
1548
1585
  }
1549
- const x = y.split(/\s+/);
1550
- let X = !1;
1551
- const O = x.indexOf(_.VALUES.TRAVELER);
1552
- if (O !== -1) {
1553
- g = !0, X = !0;
1554
- const k = x[O + 1];
1586
+ const D = _.split(/\s+/);
1587
+ let q = !1;
1588
+ const Y = D.indexOf(N.VALUES.TRAVELER);
1589
+ if (Y !== -1) {
1590
+ L = !0, q = !0;
1591
+ const k = D[Y + 1];
1555
1592
  if (k && !isNaN(parseInt(k, 10)))
1556
- m = parseInt(k, 10);
1593
+ v = parseInt(k, 10);
1557
1594
  else {
1558
- const T = x.find((oe) => !isNaN(parseInt(oe, 10)));
1559
- T && (m = parseInt(T, 10));
1595
+ const R = D.find((ne) => !isNaN(parseInt(ne, 10)));
1596
+ R && (v = parseInt(R, 10));
1560
1597
  }
1561
1598
  }
1562
- const Q = x.indexOf(_.VALUES.NATIVE);
1599
+ const Q = D.indexOf(N.VALUES.NATIVE);
1563
1600
  if (Q !== -1) {
1564
- const k = x[Q + 1];
1601
+ const k = D[Q + 1];
1565
1602
  if (k && !isNaN(parseInt(k, 10)))
1566
1603
  b = parseInt(k, 10);
1567
- else if (!g) {
1568
- const T = x.find((oe) => !isNaN(parseInt(oe, 10)));
1569
- T && (b = parseInt(T, 10));
1604
+ else if (!L) {
1605
+ const R = D.find((ne) => !isNaN(parseInt(ne, 10)));
1606
+ R && (b = parseInt(R, 10));
1570
1607
  }
1571
1608
  }
1572
- if (X) {
1573
- const k = m + 1;
1574
- if (k < i)
1609
+ if (q) {
1610
+ const k = v + 1;
1611
+ if (k < r)
1575
1612
  throw new Error(
1576
- `[MirageEngine] Traveler layer (${m}) cannot be smaller than inherited capture layer (${i - 1}).`
1613
+ `[MirageEngine] Traveler layer (${v}) cannot be smaller than inherited capture layer (${r - 1}).`
1577
1614
  );
1578
- i = Math.min(k, _.MAX_LAYERS + 1);
1615
+ r = Math.min(k, N.MAX_LAYERS + 1);
1579
1616
  }
1580
1617
  }
1581
- const C = n.dataset[Ve.KEY];
1582
- let I;
1583
- C && (I = JSON.parse(C));
1584
- const D = n.getBoundingClientRect(), S = window.getComputedStyle(n);
1585
- if (D.width === 0 || D.height === 0 || S.display === "none")
1618
+ const E = n.dataset[We.KEY];
1619
+ let A;
1620
+ E && (A = JSON.parse(E));
1621
+ const C = n.getBoundingClientRect(), y = window.getComputedStyle(n);
1622
+ if (C.width === 0 || C.height === 0 || y.display === "none")
1586
1623
  return null;
1587
- let R = n.getAttribute("data-mid");
1588
- R || (R = Math.random().toString(36).substring(2, 11), n.setAttribute("data-mid", R));
1589
- const E = parseInt(S.zIndex), V = (isNaN(E) ? 0 : E) + s;
1590
- let N;
1624
+ let S = n.getAttribute("data-mid");
1625
+ S || (S = Math.random().toString(36).substring(2, 11), n.setAttribute("data-mid", S));
1626
+ const X = parseInt(y.zIndex), z = (isNaN(X) ? 0 : X) + s;
1627
+ let U;
1591
1628
  if (n.tagName === "IMG")
1592
- N = n.src;
1629
+ U = n.src;
1593
1630
  else if (n.tagName.toLowerCase() === "svg") {
1594
- const m = n.cloneNode(!0), A = v == null ? void 0 : v.color, U = v == null ? void 0 : v.fill, y = v == null ? void 0 : v.stroke, x = v == null ? void 0 : v.opacity, X = (T, oe) => {
1595
- const H = window.getComputedStyle(T), ce = oe, Fe = H.fill === H.color, Be = H.stroke === H.color, ge = U || (Fe ? A : void 0) || H.fill;
1596
- ge && ge !== "none" && (ce.style.fill = ge);
1597
- const pe = y || (Be ? A : void 0) || H.stroke;
1598
- pe && pe !== "none" && (ce.style.stroke = pe), H.strokeWidth && H.strokeWidth !== "0px" && (ce.style.strokeWidth = H.strokeWidth);
1599
- const ye = A || H.color;
1600
- ye && (ce.style.color = ye);
1601
- const me = x || H.opacity;
1602
- me && me !== "1" && (ce.style.opacity = me);
1603
- for (let de = 0; de < T.children.length; de++)
1604
- X(T.children[de], oe.children[de]);
1631
+ const v = n.cloneNode(!0), x = m == null ? void 0 : m.color, T = m == null ? void 0 : m.fill, _ = m == null ? void 0 : m.stroke, D = m == null ? void 0 : m.opacity, q = (R, ne) => {
1632
+ const P = window.getComputedStyle(R), de = ne, Oe = P.fill === P.color, _e = P.stroke === P.color, me = T || (Oe ? x : void 0) || P.fill;
1633
+ me && me !== "none" && (de.style.fill = me);
1634
+ const ve = _ || (_e ? x : void 0) || P.stroke;
1635
+ ve && ve !== "none" && (de.style.stroke = ve), P.strokeWidth && P.strokeWidth !== "0px" && (de.style.strokeWidth = P.strokeWidth);
1636
+ const Se = x || P.color;
1637
+ Se && (de.style.color = Se);
1638
+ const we = D || P.opacity;
1639
+ we && we !== "1" && (de.style.opacity = we);
1640
+ for (let fe = 0; fe < R.children.length; fe++)
1641
+ q(R.children[fe], ne.children[fe]);
1605
1642
  };
1606
- X(n, m);
1607
- const O = n.getBoundingClientRect(), Q = window.devicePixelRatio * c;
1608
- m.hasAttribute("viewBox") || m.setAttribute("viewBox", `0 0 ${O.width} ${O.height}`), m.setAttribute("width", (O.width * Q).toString()), m.setAttribute("height", (O.height * Q).toString());
1609
- let k = new XMLSerializer().serializeToString(m);
1643
+ q(n, v);
1644
+ const Y = n.getBoundingClientRect(), Q = window.devicePixelRatio * c;
1645
+ v.hasAttribute("viewBox") || v.setAttribute("viewBox", `0 0 ${Y.width} ${Y.height}`), v.setAttribute("width", (Y.width * Q).toString()), v.setAttribute("height", (Y.height * Q).toString());
1646
+ let k = new XMLSerializer().serializeToString(v);
1610
1647
  k.includes("xmlns=") || (k = k.replace(
1611
1648
  "<svg",
1612
1649
  '<svg xmlns="http://www.w3.org/2000/svg"'
1613
- )), N = `data:image/svg+xml;utf8,${encodeURIComponent(k)}`;
1614
- } else if (S.backgroundImage && S.backgroundImage !== "none") {
1615
- const m = S.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
1616
- m && (N = m[1]);
1617
- }
1618
- const M = {
1619
- backgroundColor: S.backgroundColor,
1620
- backgroundImage: S.backgroundImage,
1621
- opacity: n.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(S.opacity),
1622
- zIndex: V,
1623
- borderRadius: S.borderRadius,
1624
- borderColor: S.borderColor,
1625
- borderWidth: S.borderWidth,
1626
- boxShadow: S.boxShadow,
1627
- imageSrc: N,
1628
- isTraveler: g
1629
- }, P = M;
1650
+ )), U = `data:image/svg+xml;utf8,${encodeURIComponent(k)}`;
1651
+ } else if (y.backgroundImage && y.backgroundImage !== "none") {
1652
+ const v = y.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
1653
+ v && (U = v[1]);
1654
+ }
1655
+ const I = {
1656
+ backgroundColor: y.backgroundColor,
1657
+ backgroundImage: y.backgroundImage,
1658
+ opacity: n.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(y.opacity),
1659
+ zIndex: z,
1660
+ borderRadius: y.borderRadius,
1661
+ borderColor: y.borderColor,
1662
+ borderWidth: y.borderWidth,
1663
+ boxShadow: y.boxShadow,
1664
+ imageSrc: U,
1665
+ isTraveler: L
1666
+ }, j = I;
1630
1667
  let J, Z;
1631
- const L = [];
1632
- return n.tagName.toLowerCase() !== "svg" && Array.from(n.childNodes).forEach((m) => {
1633
- const A = m.nodeType === Node.TEXT_NODE ? h : d, U = Ue(
1634
- m,
1668
+ const M = [], O = y.overflow === "hidden" ? [...l || [], n] : l;
1669
+ return n.tagName.toLowerCase() !== "svg" && Array.from(n.childNodes).forEach((v) => {
1670
+ const x = v.nodeType === Node.TEXT_NODE ? d : h, T = Fe(
1671
+ v,
1635
1672
  e,
1636
- A,
1637
- i,
1638
- V,
1673
+ x,
1674
+ r,
1675
+ z,
1639
1676
  c,
1640
- m.nodeType === Node.TEXT_NODE ? b : void 0,
1641
- m.nodeType === Node.TEXT_NODE && Object.keys(v).length > 0 ? v : void 0
1677
+ v.nodeType === Node.TEXT_NODE ? b : void 0,
1678
+ v.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0,
1679
+ O
1642
1680
  );
1643
- U && L.push(U);
1681
+ T && M.push(T);
1644
1682
  }), {
1645
- id: R,
1683
+ id: S,
1646
1684
  type: "BOX",
1647
1685
  element: n,
1648
1686
  rect: {
1649
- x: D.left + window.scrollX,
1650
- y: D.top + window.scrollY,
1651
- width: D.width,
1652
- height: D.height
1687
+ x: C.left + window.scrollX,
1688
+ y: C.top + window.scrollY,
1689
+ width: C.width,
1690
+ height: C.height
1653
1691
  },
1654
- styles: P,
1692
+ styles: j,
1655
1693
  textContent: J,
1656
1694
  textStyles: Z,
1657
1695
  dirtyMask: e,
1658
- visibility: h,
1659
- isTraveler: g,
1660
- captureLayer: i,
1696
+ visibility: d,
1697
+ isTraveler: L,
1698
+ captureLayer: r,
1661
1699
  nativeLayer: b,
1662
- nativeStyles: b !== void 0 ? Se(te({}, M), {
1663
- backgroundColor: (F = v.backgroundColor) != null ? F : M.backgroundColor,
1664
- backgroundImage: ($ = v.backgroundImage) != null ? $ : M.backgroundImage,
1665
- opacity: (K = v.opacity) != null ? K : M.opacity,
1666
- zIndex: v.zIndex !== void 0 ? v.zIndex + V : M.zIndex,
1667
- borderRadius: (z = v.borderRadius) != null ? z : M.borderRadius,
1668
- borderColor: (Y = v.borderColor) != null ? Y : M.borderColor,
1669
- borderWidth: (ie = v.borderWidth) != null ? ie : M.borderWidth,
1670
- boxShadow: (se = v.boxShadow) != null ? se : M.boxShadow,
1671
- isTraveler: M.isTraveler,
1672
- transform: v.transform
1700
+ nativeStyles: b !== void 0 ? Ce(te({}, I), {
1701
+ backgroundColor: (K = m.backgroundColor) != null ? K : I.backgroundColor,
1702
+ backgroundImage: (B = m.backgroundImage) != null ? B : I.backgroundImage,
1703
+ opacity: (V = m.opacity) != null ? V : I.opacity,
1704
+ zIndex: m.zIndex !== void 0 ? m.zIndex + z : I.zIndex,
1705
+ borderRadius: (ie = m.borderRadius) != null ? ie : I.borderRadius,
1706
+ borderColor: (se = m.borderColor) != null ? se : I.borderColor,
1707
+ borderWidth: (oe = m.borderWidth) != null ? oe : I.borderWidth,
1708
+ boxShadow: (he = m.boxShadow) != null ? he : I.boxShadow,
1709
+ isTraveler: I.isTraveler,
1710
+ transform: m.transform
1673
1711
  }) : void 0,
1674
1712
  nativeRect: b !== void 0 ? {
1675
- x: v.x !== void 0 ? parseFloat(v.x) : D.left + window.scrollX,
1676
- y: v.y !== void 0 ? parseFloat(v.y) : D.top + window.scrollY,
1677
- width: v.width !== void 0 ? parseFloat(v.width) : D.width,
1678
- height: v.height !== void 0 ? parseFloat(v.height) : D.height
1713
+ x: m.x !== void 0 ? parseFloat(m.x) : C.left + window.scrollX,
1714
+ y: m.y !== void 0 ? parseFloat(m.y) : C.top + window.scrollY,
1715
+ width: m.width !== void 0 ? parseFloat(m.width) : C.width,
1716
+ height: m.height !== void 0 ? parseFloat(m.height) : C.height
1679
1717
  } : void 0,
1680
- isFixed: S.position === "fixed",
1681
- children: L,
1682
- shaderHooks: I
1718
+ isFixed: y.position === "fixed",
1719
+ clipElements: l,
1720
+ children: M,
1721
+ shaderHooks: A
1683
1722
  };
1684
1723
  }
1685
- function ot(r, e) {
1686
- e.size !== 0 && e.forEach((t, i) => {
1687
- var c, o, a, n;
1688
- const s = r.get(i);
1724
+ function at(i, e) {
1725
+ e.size !== 0 && e.forEach((t, r) => {
1726
+ var c, o, a, l;
1727
+ const s = i.get(r);
1689
1728
  !s || !s.userData.basePosition || (W.forceUpdateUniforms(s.material, {
1690
1729
  backgroundColor: t.backgroundColor,
1691
1730
  backgroundImage: t.backgroundImage,
@@ -1698,32 +1737,32 @@ function ot(r, e) {
1698
1737
  backgroundImage: t.backgroundImage,
1699
1738
  boxShadow: t.boxShadow,
1700
1739
  opacity: t.opacity,
1701
- borderRadius: (n = t.borderRadius) != null ? n : (a = s.userData.baseStyles) == null ? void 0 : a.borderRadius
1740
+ borderRadius: (l = t.borderRadius) != null ? l : (a = s.userData.baseStyles) == null ? void 0 : a.borderRadius
1702
1741
  }));
1703
1742
  });
1704
1743
  }
1705
- class at {
1706
- constructor(e, t, i, s) {
1707
- p(this, "target");
1708
- p(this, "renderer");
1709
- p(this, "registry");
1710
- p(this, "isTravelEnabled", !1);
1711
- p(this, "tracker");
1712
- this.target = e, this.renderer = t, this.registry = i, this.tracker = new He(e, {
1744
+ class lt {
1745
+ constructor(e, t, r, s) {
1746
+ g(this, "target");
1747
+ g(this, "renderer");
1748
+ g(this, "registry");
1749
+ g(this, "isTravelEnabled", !1);
1750
+ g(this, "tracker");
1751
+ this.target = e, this.renderer = t, this.registry = r, this.tracker = new qe(e, {
1713
1752
  resizeDebounce: s.resizeDebounce
1714
1753
  }), this.tracker.onLayoutChange.add((c, o) => {
1715
- document.querySelector(`[${_.NAME}~='${_.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
1716
- const n = Ue(
1754
+ document.querySelector(`[${N.NAME}~='${N.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
1755
+ const l = Fe(
1717
1756
  this.target,
1718
1757
  c,
1719
- q,
1758
+ G,
1720
1759
  1,
1721
1760
  0,
1722
1761
  this.renderer.qualityFactor
1723
1762
  );
1724
- n && this.renderer.syncScene(n, o);
1763
+ l && this.renderer.syncScene(l, o);
1725
1764
  }), this.tracker.onStyleChange.add((c) => {
1726
- ot(this.registry, c);
1765
+ at(this.registry, c);
1727
1766
  }), this.tracker.onRender.add(() => {
1728
1767
  this.renderer.syncMeshesByDOM(), this.renderer.render();
1729
1768
  });
@@ -1735,9 +1774,9 @@ class at {
1735
1774
  this.tracker.stop();
1736
1775
  }
1737
1776
  }
1738
- class nt {
1777
+ class ct {
1739
1778
  constructor() {
1740
- p(this, "store");
1779
+ g(this, "store");
1741
1780
  this.store = /* @__PURE__ */ new WeakMap();
1742
1781
  }
1743
1782
  register(e, t) {
@@ -1760,14 +1799,14 @@ class nt {
1760
1799
  this.store.delete(e);
1761
1800
  }
1762
1801
  }
1763
- class dt {
1802
+ class ft {
1764
1803
  constructor(e, t) {
1765
- p(this, "renderer");
1766
- p(this, "syncer");
1767
- p(this, "target");
1768
- p(this, "registry");
1804
+ g(this, "renderer");
1805
+ g(this, "syncer");
1806
+ g(this, "target");
1807
+ g(this, "registry");
1769
1808
  var s, c, o;
1770
- if (this.target = e, this.registry = new nt(), !document.getElementById("mirage-engine-styles")) {
1809
+ if (this.target = e, this.registry = new ct(), !document.getElementById("mirage-engine-styles")) {
1771
1810
  const a = document.createElement("style");
1772
1811
  a.id = "mirage-engine-styles", a.textContent = `
1773
1812
  [${ee.NAME}="${ee.VALUES.HIDE}"] {
@@ -1775,15 +1814,15 @@ class dt {
1775
1814
  }
1776
1815
  `, document.head.appendChild(a);
1777
1816
  }
1778
- let i;
1779
- if (t.mode === "duplicate" ? i = (c = (s = t.container) != null ? s : this.target.parentElement) != null ? c : void 0 : i = (o = this.target.parentElement) != null ? o : void 0, !i)
1817
+ let r;
1818
+ if (t.mode === "duplicate" ? r = (c = (s = t.container) != null ? s : this.target.parentElement) != null ? c : void 0 : r = (o = this.target.parentElement) != null ? o : void 0, !r)
1780
1819
  throw new Error("[Mirage] Cannot find a container (parent or option).");
1781
- this.renderer = new it(
1820
+ this.renderer = new ot(
1782
1821
  this.target,
1783
1822
  t,
1784
- i,
1823
+ r,
1785
1824
  this.registry
1786
- ), this.renderer.mount(), this.syncer = new at(this.target, this.renderer, this.registry, t);
1825
+ ), this.renderer.mount(), this.syncer = new lt(this.target, this.renderer, this.registry, t);
1787
1826
  }
1788
1827
  start() {
1789
1828
  this.syncer.start();
@@ -1820,32 +1859,32 @@ class dt {
1820
1859
  }), window.addEventListener("keyup", (c) => {
1821
1860
  t[c.key] !== void 0 && (t[c.key] = !1);
1822
1861
  });
1823
- const i = 2, s = () => {
1824
- requestAnimationFrame(s), 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);
1862
+ const r = 2, s = () => {
1863
+ requestAnimationFrame(s), 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);
1825
1864
  };
1826
1865
  s();
1827
1866
  }
1828
1867
  }
1829
1868
  export {
1830
- Te as ALLOWED_FILTERS,
1869
+ Me as ALLOWED_FILTERS,
1831
1870
  ee as ATTR_DOM,
1832
- G as ATTR_FILTER,
1833
- ct as ATTR_SANDWICH,
1834
- j as ATTR_SELECT,
1835
- Ve as ATTR_SHADER,
1836
- _ as ATTR_TRAVEL,
1837
- we as DIRTY_CONTENT,
1838
- ue as DIRTY_NONE,
1871
+ H as ATTR_FILTER,
1872
+ dt as ATTR_SANDWICH,
1873
+ $ as ATTR_SELECT,
1874
+ We as ATTR_SHADER,
1875
+ N as ATTR_TRAVEL,
1876
+ ye as DIRTY_CONTENT,
1877
+ ge as DIRTY_NONE,
1839
1878
  re as DIRTY_RECT,
1840
- fe as DIRTY_STRUCTURE,
1841
- he as DIRTY_STYLE,
1842
- Ye as DIRTY_ZINDEX,
1843
- ht as EXCLUDED,
1844
- dt as Engine,
1879
+ pe as DIRTY_STRUCTURE,
1880
+ ue as DIRTY_STYLE,
1881
+ Pe as DIRTY_ZINDEX,
1882
+ ut as EXCLUDED,
1883
+ ft as Engine,
1845
1884
  ae as SELECT_LAYER,
1846
- B as THREE_LAYERS,
1847
- Ce as TRAVEL_VALUES,
1848
- He as Tracker,
1849
- q as USER_LAYER,
1850
- Pe as extractFromStyle
1885
+ F as THREE_LAYERS,
1886
+ Re as TRAVEL_VALUES,
1887
+ qe as Tracker,
1888
+ G as USER_LAYER,
1889
+ Ge as extractFromStyle
1851
1890
  };