@mirage-engine/core 0.3.2 → 0.3.4

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